xdmf-3.0+git20160803/0000740000175000017500000000000013003006564014066 5ustar alastairalastairxdmf-3.0+git20160803/XdmfGridTemplate.hpp0000640000175000017500000001733613003006557020015 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfTemplate.hpp */ /* */ /* Author: */ /* Andrew Burns */ /* andrew.j.burns2@us.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2013 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef XDMFGRIDTEMPLATE_HPP_ #define XDMFGRIDTEMPLATE_HPP_ // C Compatible Includes #include "Xdmf.hpp" #include "XdmfItem.hpp" #include "XdmfGridCollection.hpp" #include "XdmfItemFactory.hpp" #include "XdmfTemplate.hpp" #include "XdmfArray.hpp" #include "XdmfHeavyDataWriter.hpp" #ifdef __cplusplus // Includes /** * @brief Defines a template that can be filled with multiple sets of data. * * An XdmfTemplate defines a structure. The arrays within that structure * are stored if they are not initialized when the structure is first set. * Steps can then be added and references to heavy data are produced and * stored for later retrieval. * * This effectively lets an object have several variations with different * contained data. */ class XDMF_EXPORT XdmfGridTemplate : public XdmfTemplate, public XdmfGridCollection { public: /** * Creates a new instance of the XdmfTemplate object * * @return A constructed XdmfTemplate object. */ static shared_ptr New(); virtual ~XdmfGridTemplate(); LOKI_DEFINE_VISITABLE(XdmfGridTemplate, XdmfGrid); static const std::string ItemTag; /** * Writes all tracked arrays to heavy data via the provided * heavy data writer then stores the heavy data descriptions. * * @return The ID of the step that was added */ virtual unsigned int addStep(); std::map getItemProperties() const; std::string getItemTag() const; using XdmfGrid::insert; // Overriding the parent versions so that all of these reference the Base item // instead of the template virtual shared_ptr getTimes(); virtual shared_ptr getGridCollection(const unsigned int index); virtual shared_ptr getGridCollection(const unsigned int index) const; virtual shared_ptr getGridCollection(const std::string & Name); virtual shared_ptr getGridCollection(const std::string & Name) const; virtual unsigned int getNumberGridCollections() const; virtual void insert(const shared_ptr GridCollection); virtual void removeGridCollection(const unsigned int index); virtual void removeGridCollection(const std::string & Name); virtual shared_ptr getCurvilinearGrid(const unsigned int index); virtual shared_ptr getCurvilinearGrid(const unsigned int index) const; virtual shared_ptr getCurvilinearGrid(const std::string & Name); virtual shared_ptr getCurvilinearGrid(const std::string & Name) const; virtual unsigned int getNumberCurvilinearGrids() const; virtual void insert(const shared_ptr CurvilinearGrid); virtual void removeCurvilinearGrid(const unsigned int index); virtual void removeCurvilinearGrid(const std::string & Name); virtual shared_ptr getRectilinearGrid(const unsigned int index); virtual shared_ptr getRectilinearGrid(const unsigned int index) const; virtual shared_ptr getRectilinearGrid(const std::string & Name); virtual shared_ptr getRectilinearGrid(const std::string & Name) const; virtual unsigned int getNumberRectilinearGrids() const; virtual void insert(const shared_ptr RectilinearGrid); virtual void removeRectilinearGrid(const unsigned int index); virtual void removeRectilinearGrid(const std::string & Name); virtual shared_ptr getRegularGrid(const unsigned int index); virtual shared_ptr getRegularGrid(const unsigned int index) const; virtual shared_ptr getRegularGrid(const std::string & Name); virtual shared_ptr getRegularGrid(const std::string & Name) const; virtual unsigned int getNumberRegularGrids() const; virtual void insert(const shared_ptr RegularGrid); virtual void removeRegularGrid(const unsigned int index); virtual void removeRegularGrid(const std::string & Name); virtual shared_ptr getUnstructuredGrid(const unsigned int index); virtual shared_ptr getUnstructuredGrid(const unsigned int index) const; virtual shared_ptr getUnstructuredGrid(const std::string & Name); virtual shared_ptr getUnstructuredGrid(const std::string & Name) const; virtual unsigned int getNumberUnstructuredGrids() const; virtual void insert(const shared_ptr UnstructuredGrid); virtual void removeUnstructuredGrid(const unsigned int index); virtual void removeUnstructuredGrid(const std::string & Name); /** * */ virtual void removeStep(unsigned int stepId); virtual void setBase(shared_ptr newBase); /** * Reads in the heavy data associated with the provided step id. * * @param stepId The id of the step whose heavy data * is to be read in from file */ void setStep(unsigned int stepId); void setStep(shared_ptr time); void traverse(const shared_ptr visitor); XdmfGridTemplate(XdmfGridTemplate &); protected: XdmfGridTemplate(); virtual void populateItem(const std::map & itemProperties, const std::vector > & childItems, const XdmfCoreReader * const reader); shared_ptr mTimeCollection; private: XdmfGridTemplate(const XdmfGridTemplate &); // Not implemented. void operator=(const XdmfGridTemplate &); // Not implemented. }; #endif #ifdef __cplusplus extern "C" { #endif // C wrappers go here struct XDMFGRIDTEMPLATE; // Simply as a typedef to ensure correct typing typedef struct XDMFGRIDTEMPLATE XDMFGRIDTEMPLATE; XDMF_ITEM_C_CHILD_DECLARE(XdmfGridTemplate, XDMFGRIDTEMPLATE, XDMF) #ifdef __cplusplus } #endif #endif /* XDMFGRIDTEMPLATE_HPP_ */ xdmf-3.0+git20160803/XdmfGridTemplate.cpp0000640000175000017500000007054213003006557020006 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfTemplate.cpp */ /* */ /* Author: */ /* Andrew Burns */ /* andrew.j.burns2@us.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2013 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #include #include #include "XdmfArray.hpp" #include "XdmfCurvilinearGrid.hpp" #include "XdmfItem.hpp" #include "XdmfItemFactory.hpp" #include "XdmfReader.hpp" #include "XdmfGridCollection.hpp" #include "XdmfGridCollectionType.hpp" #include "XdmfGridTemplate.hpp" #include "XdmfRectilinearGrid.hpp" #include "XdmfRegularGrid.hpp" #include "XdmfTemplate.hpp" #include "XdmfTopology.hpp" #include "XdmfError.hpp" #include "XdmfUnstructuredGrid.hpp" #include "XdmfVisitor.hpp" #include "XdmfWriter.hpp" #include "XdmfSystemUtils.hpp" #include #include shared_ptr XdmfGridTemplate::New() { shared_ptr p(new XdmfGridTemplate()); return p; } XdmfGridTemplate::XdmfGridTemplate() : XdmfTemplate(), XdmfGridCollection(), mTimeCollection(XdmfArray::New()) { mTimeCollection->setName("Time Collection"); } XdmfGridTemplate::XdmfGridTemplate(XdmfGridTemplate & refTemplate) : XdmfTemplate(refTemplate), XdmfGridCollection(refTemplate), mTimeCollection(refTemplate.mTimeCollection) { } XdmfGridTemplate::~XdmfGridTemplate() { } const std::string XdmfGridTemplate::ItemTag = "Template"; unsigned int XdmfGridTemplate::addStep() { XdmfTemplate::addStep(); if (shared_dynamic_cast(mBase)->getTime()) { if (!mTimeCollection->isInitialized()) { mTimeCollection->read(); } mTimeCollection->pushBack(shared_dynamic_cast(mBase)->getTime()->getValue()); } return mCurrentStep; } std::map XdmfGridTemplate::getItemProperties() const { std::map templateProperties = XdmfGridCollection::getItemProperties(); templateProperties["BaseType"] = "Grid"; return templateProperties; } std::string XdmfGridTemplate::getItemTag() const { return ItemTag; } shared_ptr XdmfGridTemplate::getTimes() { return mTimeCollection; } shared_ptr XdmfGridTemplate::getGridCollection(const unsigned int index) { if (mBase) { if (index < getNumberSteps()) { this->clearStep(); this->setStep(index); if (shared_ptr grid = shared_dynamic_cast(mBase)) { return grid; } else { return shared_ptr(); } } else { return shared_ptr(); } } else { XdmfError::message(XdmfError::FATAL, "Error: Attempting to get GridCollection from template without a base"); return shared_ptr(); } } shared_ptr XdmfGridTemplate::getGridCollection(const unsigned int index) const { if (shared_ptr grid = shared_dynamic_cast(mBase)) { if (index != mCurrentStep) { XdmfError::message(XdmfError::FATAL, "Error: GridTemplates can not return a constant reference to its base on an index other than the currently loaded one."); return shared_ptr(); } else { return grid; } } else { return shared_ptr(); } } shared_ptr XdmfGridTemplate::getGridCollection(const std::string & Name) { if (mBase) { if (shared_ptr grid = shared_dynamic_cast(mBase)) { if (grid->getName().compare(Name) == 0) { return grid; } else { return shared_ptr(); } } else { return shared_ptr(); } } else { XdmfError::message(XdmfError::FATAL, "Error: Attempting to get GridCollection from template without a base"); return shared_ptr(); } } shared_ptr XdmfGridTemplate::getGridCollection(const std::string & Name) const { if (mBase) { if (shared_ptr grid = shared_dynamic_cast(mBase)) { if (grid->getName().compare(Name) == 0) { return grid; } else { return shared_ptr(); } } else { return shared_ptr(); } } else { XdmfError::message(XdmfError::FATAL, "Error: Attempting to get GridCollection from template without a base"); return shared_ptr(); } } unsigned int XdmfGridTemplate::getNumberGridCollections() const { if (shared_ptr grid = shared_dynamic_cast(mBase)) { return this->getNumberSteps(); } else { return 0; } } void XdmfGridTemplate::insert(const shared_ptr GridCollection) { XdmfError::message(XdmfError::FATAL, "Error: Attempting to use insert to add an XdmfGridCollection to an XdmfGridTemplate. " "Use addStep instead of insert to add to an XdmfGridTemplate"); } void XdmfGridTemplate::removeGridCollection(const unsigned int index) { if (mBase) { if (index < getNumberSteps()) { if (shared_ptr grid = shared_dynamic_cast(mBase)) { this->removeStep(index); } } } else { XdmfError::message(XdmfError::FATAL, "Error: Attempting to get GridCollection from template without a base"); } } void XdmfGridTemplate::removeGridCollection(const std::string & Name) { XdmfError::message(XdmfError::FATAL, "Error: Removing Grids by name from XdmfGridTemplate is not supported"); } shared_ptr XdmfGridTemplate::getCurvilinearGrid(const unsigned int index) { if (mBase) { if (index < getNumberSteps()) { this->clearStep(); this->setStep(index); if (shared_ptr grid = shared_dynamic_cast(mBase)) { return grid; } else { return shared_ptr(); } } else { return shared_ptr(); } } else { XdmfError::message(XdmfError::FATAL, "Error: Attempting to get CurvilinearGrid from template without a base"); return shared_ptr(); } } shared_ptr XdmfGridTemplate::getCurvilinearGrid(const unsigned int index) const { if (shared_ptr grid = shared_dynamic_cast(mBase)) { if (index != mCurrentStep) { XdmfError::message(XdmfError::FATAL, "Error: GridTemplates can not return a constant reference to its base on an index other than the currently loaded one."); return shared_ptr(); } else { return grid; } } else { return shared_ptr(); } } shared_ptr XdmfGridTemplate::getCurvilinearGrid(const std::string & Name) { if (mBase) { if (shared_ptr grid = shared_dynamic_cast(mBase)) { if (grid->getName().compare(Name) == 0) { return grid; } else { return shared_ptr(); } } else { return shared_ptr(); } } else { XdmfError::message(XdmfError::FATAL, "Error: Attempting to get CurvilinearGrid from template without a base"); return shared_ptr(); } } shared_ptr XdmfGridTemplate::getCurvilinearGrid(const std::string & Name) const { if (mBase) { if (shared_ptr grid = shared_dynamic_cast(mBase)) { if (grid->getName().compare(Name) == 0) { return grid; } else { return shared_ptr(); } } else { return shared_ptr(); } } else { XdmfError::message(XdmfError::FATAL, "Error: Attempting to get CurvilinearGrid from template without a base"); return shared_ptr(); } } unsigned int XdmfGridTemplate::getNumberCurvilinearGrids() const { if (shared_ptr grid = shared_dynamic_cast(mBase)) { return this->getNumberSteps(); } else { return 0; } } void XdmfGridTemplate::insert(const shared_ptr CurvilinearGrid) { XdmfError::message(XdmfError::FATAL, "Error: Attempting to use insert to add an XdmfCurvilinearGrid to an XdmfGridTemplate. " "Use addStep instead of insert to add to an XdmfGridTemplate"); } void XdmfGridTemplate::removeCurvilinearGrid(const unsigned int index) { if (mBase) { if (index < getNumberSteps()) { if (shared_ptr grid = shared_dynamic_cast(mBase)) { this->removeStep(index); } } } else { XdmfError::message(XdmfError::FATAL, "Error: Attempting to get CurvilinearGrid from template without a base"); } } void XdmfGridTemplate::removeCurvilinearGrid(const std::string & Name) { XdmfError::message(XdmfError::FATAL, "Error: Removing Grids by name from XdmfGridTemplate is not supported"); } shared_ptr XdmfGridTemplate::getRectilinearGrid(const unsigned int index) { if (mBase) { if (index < getNumberSteps()) { this->clearStep(); this->setStep(index); if (shared_ptr grid = shared_dynamic_cast(mBase)) { return grid; } else { return shared_ptr(); } } else { return shared_ptr(); } } else { XdmfError::message(XdmfError::FATAL, "Error: Attempting to get RectilinearGrid from template without a base"); return shared_ptr(); } } shared_ptr XdmfGridTemplate::getRectilinearGrid(const unsigned int index) const { if (shared_ptr grid = shared_dynamic_cast(mBase)) { if (index != mCurrentStep) { XdmfError::message(XdmfError::FATAL, "Error: GridTemplates can not return a constant reference to its base on an index other than the currently loaded one."); return shared_ptr(); } else { return grid; } } else { return shared_ptr(); } } shared_ptr XdmfGridTemplate::getRectilinearGrid(const std::string & Name) { if (mBase) { if (shared_ptr grid = shared_dynamic_cast(mBase)) { if (grid->getName().compare(Name) == 0) { return grid; } else { return shared_ptr(); } } else { return shared_ptr(); } } else { XdmfError::message(XdmfError::FATAL, "Error: Attempting to get RectilinearGrid from template without a base"); return shared_ptr(); } } shared_ptr XdmfGridTemplate::getRectilinearGrid(const std::string & Name) const { if (mBase) { if (shared_ptr grid = shared_dynamic_cast(mBase)) { if (grid->getName().compare(Name) == 0) { return grid; } else { return shared_ptr(); } } else { return shared_ptr(); } } else { XdmfError::message(XdmfError::FATAL, "Error: Attempting to get RectilinearGrid from template without a base"); return shared_ptr(); } } unsigned int XdmfGridTemplate::getNumberRectilinearGrids() const { if (shared_ptr grid = shared_dynamic_cast(mBase)) { return this->getNumberSteps(); } else { return 0; } } void XdmfGridTemplate::insert(const shared_ptr RectilinearGrid) { XdmfError::message(XdmfError::FATAL, "Error: Attempting to use insert to add a XdmfRectilinearGrid to an XdmfGridTemplate." "Use addStep instead of insert to add to an XdmfGridTemplate"); } void XdmfGridTemplate::removeRectilinearGrid(const unsigned int index) { if (mBase) { if (index < getNumberSteps()) { if (shared_ptr grid = shared_dynamic_cast(mBase)) { this->removeStep(index); } } } else { XdmfError::message(XdmfError::FATAL, "Error: Attempting to get RectilinearGrid from template without a base"); } } void XdmfGridTemplate::removeRectilinearGrid(const std::string & Name) { XdmfError::message(XdmfError::FATAL, "Error: Removing Grids by name from XdmfGridTemplate is not supported"); } shared_ptr XdmfGridTemplate::getRegularGrid(const unsigned int index) { if (mBase) { if (index < getNumberSteps()) { this->clearStep(); this->setStep(index); if (shared_ptr grid = shared_dynamic_cast(mBase)) { return grid; } else { return shared_ptr(); } } else { return shared_ptr(); } } else { XdmfError::message(XdmfError::FATAL, "Error: Attempting to get RegularGrid from template without a base"); return shared_ptr(); } } shared_ptr XdmfGridTemplate::getRegularGrid(const unsigned int index) const { if (shared_ptr grid = shared_dynamic_cast(mBase)) { if (index != mCurrentStep) { XdmfError::message(XdmfError::FATAL, "Error: GridTemplates can not return a constant reference to its base on an index other than the currently loaded one."); return shared_ptr(); } else { return grid; } } else { return shared_ptr(); } } shared_ptr XdmfGridTemplate::getRegularGrid(const std::string & Name) { if (mBase) { if (shared_ptr grid = shared_dynamic_cast(mBase)) { if (grid->getName().compare(Name) == 0) { return grid; } else { return shared_ptr(); } } else { return shared_ptr(); } } else { XdmfError::message(XdmfError::FATAL, "Error: Attempting to get RegularGrid from template without a base"); return shared_ptr(); } } shared_ptr XdmfGridTemplate::getRegularGrid(const std::string & Name) const { if (mBase) { if (shared_ptr grid = shared_dynamic_cast(mBase)) { if (grid->getName().compare(Name) == 0) { return grid; } else { return shared_ptr(); } } else { return shared_ptr(); } } else { XdmfError::message(XdmfError::FATAL, "Error: Attempting to get RegularGrid from template without a base"); return shared_ptr(); } } unsigned int XdmfGridTemplate::getNumberRegularGrids() const { if (shared_ptr grid = shared_dynamic_cast(mBase)) { return this->getNumberSteps(); } else { return 0; } } void XdmfGridTemplate::insert(const shared_ptr RegularGrid) { XdmfError::message(XdmfError::FATAL, "Error: Attempting to use insert to add an XdmfRegularGrid to an XdmfGridTemplate." "Use addStep instead of insert to add to an XdmfGridTemplate"); } void XdmfGridTemplate::removeRegularGrid(const unsigned int index) { if (mBase) { if (index < getNumberSteps()) { if (shared_ptr grid = shared_dynamic_cast(mBase)) { this->removeStep(index); } } } else { XdmfError::message(XdmfError::FATAL, "Error: Attempting to get RegularGrid from template without a base"); } } void XdmfGridTemplate::removeRegularGrid(const std::string & Name) { XdmfError::message(XdmfError::FATAL, "Error: Removing Grids by name from XdmfGridTemplate is not supported"); } shared_ptr XdmfGridTemplate::getUnstructuredGrid(const unsigned int index) { if (mBase) { if (index < getNumberSteps()) { this->clearStep(); this->setStep(index); if (shared_ptr grid = shared_dynamic_cast(mBase)) { return grid; } else { return shared_ptr(); } } else { return shared_ptr(); } } else { XdmfError::message(XdmfError::FATAL, "Error: Attempting to get UnstructuredGrid from template without a base"); return shared_ptr(); } } shared_ptr XdmfGridTemplate::getUnstructuredGrid(const unsigned int index) const { if (shared_ptr grid = shared_dynamic_cast(mBase)) { if (index != mCurrentStep) { XdmfError::message(XdmfError::FATAL, "Error: GridTemplates can not return a constant reference to its base on an index other than the currently loaded one."); return shared_ptr(); } else { return grid; } } else { return shared_ptr(); } } shared_ptr XdmfGridTemplate::getUnstructuredGrid(const std::string & Name) { if (mBase) { if (shared_ptr grid = shared_dynamic_cast(mBase)) { if (grid->getName().compare(Name) == 0) { return grid; } else { return shared_ptr(); } } else { return shared_ptr(); } } else { XdmfError::message(XdmfError::FATAL, "Error: Attempting to get UnstructuredGrid from template without a base"); return shared_ptr(); } } shared_ptr XdmfGridTemplate::getUnstructuredGrid(const std::string & Name) const { if (mBase) { if (shared_ptr grid = shared_dynamic_cast(mBase)) { if (grid->getName().compare(Name) == 0) { return grid; } else { return shared_ptr(); } } else { return shared_ptr(); } } else { XdmfError::message(XdmfError::FATAL, "Error: Attempting to get UnstructuredGrid from template without a base"); return shared_ptr(); } } unsigned int XdmfGridTemplate::getNumberUnstructuredGrids() const { if (shared_ptr grid = shared_dynamic_cast(mBase)) { return this->getNumberSteps(); } else { return 0; } } void XdmfGridTemplate::insert(const shared_ptr UnstructuredGrid) { XdmfError::message(XdmfError::FATAL, "Error: Attempting to use insert to add an XdmfUnstructuredGrid to an XdmfGridTemplate." "Use addStep instead of insert to add to an XdmfGridTemplate"); } void XdmfGridTemplate::removeUnstructuredGrid(const unsigned int index) { if (mBase) { if (index < getNumberSteps()) { if (shared_ptr grid = shared_dynamic_cast(mBase)) { this->removeStep(index); } } } else { XdmfError::message(XdmfError::FATAL, "Error: Attempting to get UnstructuredGrid from template without a base"); } } void XdmfGridTemplate::removeUnstructuredGrid(const std::string & Name) { XdmfError::message(XdmfError::FATAL, "Error: Removing Grids by name from XdmfGridTemplate is not supported"); } void XdmfGridTemplate::populateItem(const std::map & itemProperties, const std::vector > & childItems, const XdmfCoreReader * const reader) { // We are overrriding the populate item of the template and grid collection here // The template functions internally different from either. this->setType(XdmfGridCollectionType::New(itemProperties)); // The first child item is the base mBase = childItems[0]; mCurrentStep = 0; if (childItems.size() > 1) { for(std::vector >::const_iterator iter = childItems.begin() + 1; iter != childItems.end(); ++iter) { if(shared_ptr array = shared_dynamic_cast(*iter)) { if (array->getName().compare("Data Description") == 0) { // Split description into substrings based on the " character if (array->getNumberHeavyDataControllers() > 0 & !mHeavyWriter) { mHeavyWriter = reader->generateHeavyDataWriter(array->getHeavyDataController(0)->getName(), array->getHeavyDataController(0)->getFilePath()); } array->read(); // If a character array, create std::string version? TODO std::string descriptionString; if (array->getArrayType() == XdmfArrayType::Int8()) { descriptionString = std::string((char *)array->getValuesInternal()); } else if (array->getArrayType() == XdmfArrayType::String()) { descriptionString = array->getValue(0); } size_t index = descriptionString.find_first_of("\""); size_t previousIndex = 0; if (index != std::string::npos) { // Removing the prepended " previousIndex = index + 1; index = descriptionString.find_first_of("\"", previousIndex); } while (index != std::string::npos) { std::string type = descriptionString.substr(previousIndex, index - previousIndex); mDataTypes.push_back(type); previousIndex = index + 1; index = descriptionString.find_first_of("\"", previousIndex); if (index - previousIndex > 0) { std::string description; description = descriptionString.substr(previousIndex, index - previousIndex); mDataDescriptions.push_back(description); // create controllers here based on the type/description? // Is array type already filled? // Potentially call "fillControllers" after populating? if (index != std::string::npos) { previousIndex = index + 1; index = descriptionString.find_first_of("\"", previousIndex); } } else { XdmfError::message(XdmfError::FATAL, "Error: Type without a description in XdmfTemplate::populateItem"); } } } else if (array->getName().compare("Time Collection") == 0) { mTimeCollection = array; } else { mTrackedArrays.push_back(array.get()); mTrackedArrayDims.push_back(array->getDimensions()); mTrackedArrayTypes.push_back(array->getArrayType()); } } } } mDataControllers.resize(mDataTypes.size()); if (!mItemFactory) { mItemFactory = XdmfItemFactory::New(); } std::map populateProperties; if (mHeavyWriter) { // The heavy writer provides the XMLDir, which is used to get full paths for the controllers // It is assumed that the files that the controllers reference are in the same directory // as the file that the writer references std::string filepath = XdmfSystemUtils::getRealPath(mHeavyWriter->getFilePath()); size_t index = filepath.find_last_of("/\\"); filepath = filepath.substr(0, index + 1); populateProperties["XMLDir"] = filepath; } for (unsigned int i = 0; i < mDataDescriptions.size(); ++i) { populateProperties["Content"] = mDataDescriptions[i]; std::vector > readControllers = reader->generateHeavyDataControllers(populateProperties, mTrackedArrayDims[i % mTrackedArrays.size()], mTrackedArrayTypes[i % mTrackedArrays.size()], mDataTypes[i]); if (readControllers.size() > 0) { // Heavy data controllers reference the data for (unsigned int j = 0; j < readControllers.size(); ++j) { mDataControllers[i].push_back(readControllers[j]); } } } // Compare the first set of controllers to the size of the first array unsigned int controllerTotal = 0; for (unsigned int i = 0; i < mDataControllers[0].size(); ++i) { controllerTotal += mDataControllers[0][i]->getSize(); } // If the array is smaller, set the writer to append. if (controllerTotal > mTrackedArrays[0]->getSize()) { mHeavyWriter->setMode(XdmfHeavyDataWriter::Append); mNumSteps = controllerTotal / mTrackedArrays[0]->getSize(); } else { mNumSteps = mDataControllers.size() / mTrackedArrays.size(); } } void XdmfGridTemplate::removeStep(unsigned int stepId) { if (stepId < this->getNumberSteps()) { XdmfTemplate::removeStep(stepId); mTimeCollection->erase(stepId); } this->setIsChanged(true); } void XdmfGridTemplate::setBase(shared_ptr newBase) { if (shared_ptr grid = shared_dynamic_cast(newBase)) { XdmfTemplate::setBase(newBase); } else { XdmfError::message(XdmfError::FATAL, "Error: XdmfGridTemplate::setBase," " attempting to set a Base that is not grid type."); } } void XdmfGridTemplate::setStep(unsigned int stepId) { XdmfTemplate::setStep(stepId); if (mTimeCollection->getSize() >= stepId) { if (!mTimeCollection->isInitialized()) { mTimeCollection->read(); } if (shared_dynamic_cast(mBase)->getTime()) { shared_dynamic_cast(mBase)->getTime()->setValue(mTimeCollection->getValue(stepId)); } else { shared_dynamic_cast(mBase)->setTime(XdmfTime::New(mTimeCollection->getValue(stepId))); } } } void XdmfGridTemplate::setStep(shared_ptr time) { if (mTimeCollection->getSize() > 0) { if (!mTimeCollection->isInitialized()) { mTimeCollection->read(); } unsigned int index = 0; while (index < mTimeCollection->getSize() && time->getValue() != mTimeCollection->getValue(index)) { ++index; } if (index < mTimeCollection->getSize()) { this->setStep(index); } } } void XdmfGridTemplate::traverse(const shared_ptr visitor) { // We are only using the template traverse // since the grid data is only held in the Base if (mTimeCollection->getSize() > 0) { this->setType(XdmfGridCollectionType::Temporal()); } else { this->setType(XdmfGridCollectionType::Spatial()); } XdmfTemplate::traverse(visitor); mTimeCollection->accept(visitor); } XDMF_ITEM_C_CHILD_WRAPPER(XdmfGridTemplate, XDMFGRIDTEMPLATE) xdmf-3.0+git20160803/XdmfGrid.cpp0000640000175000017500000003516413003006557016313 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfGrid.cpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #include #include #include "XdmfAttribute.hpp" #include "XdmfError.hpp" #include "XdmfGeometry.hpp" #include "XdmfGrid.hpp" #include "XdmfMap.hpp" #include "XdmfSet.hpp" #include "XdmfTime.hpp" #include "XdmfTopology.hpp" XDMF_CHILDREN_IMPLEMENTATION(XdmfGrid, XdmfAttribute, Attribute, Name) XDMF_CHILDREN_IMPLEMENTATION(XdmfGrid, XdmfMap, Map, Name) XDMF_CHILDREN_IMPLEMENTATION(XdmfGrid, XdmfSet, Set, Name) XdmfGrid::XdmfGrid(const shared_ptr geometry, const shared_ptr topology, const std::string & name) : mGeometry(geometry), mTopology(topology), mName(name), mTime(shared_ptr()) { } XdmfGrid::XdmfGrid(XdmfGrid &refGrid): XdmfItem(refGrid), mAttributes(refGrid.mAttributes), mSets(refGrid.mSets), mMaps(refGrid.mMaps), mGeometry(refGrid.mGeometry), mTopology(refGrid.mTopology), mName(refGrid.mName), mTime(refGrid.mTime) { XdmfGridImpl * holder = refGrid.mImpl; XdmfGridImpl * duplicateImpl = holder->duplicate(); mImpl = duplicateImpl; } XdmfGrid::~XdmfGrid() { } const std::string XdmfGrid::ItemTag = "Grid"; shared_ptr XdmfGrid::getGridController() { return mGridController; } void XdmfGrid::copyGrid(shared_ptr sourceGrid) { this->setName(sourceGrid->getName()); this->setTime(sourceGrid->getTime()); while(this->getNumberAttributes() > 0) { this->removeAttribute(0); } for (unsigned int i = 0; i < sourceGrid->getNumberAttributes(); ++i) { this->insert(sourceGrid->getAttribute(i)); } while(this->getNumberInformations() > 0) { this->removeInformation(0); } for (unsigned int i = 0; i < sourceGrid->getNumberInformations(); ++i) { this->insert(sourceGrid->getInformation(i)); } while(this->getNumberSets() > 0) { this->removeSet(0); } for (unsigned int i = 0; i < sourceGrid->getNumberSets(); ++i) { this->insert(sourceGrid->getSet(i)); } while(this->getNumberMaps() > 0) { this->removeMap(0); } for (unsigned int i = 0; i < sourceGrid->getNumberMaps(); ++i) { this->insert(sourceGrid->getMap(i)); } } shared_ptr XdmfGrid::getGeometry() const { return mGeometry; } std::map XdmfGrid::getItemProperties() const { std::map gridProperties; gridProperties.insert(std::make_pair("Name", mName)); return gridProperties; } std::string XdmfGrid::getItemTag() const { return ItemTag; } std::string XdmfGrid::getName() const { return mName; } shared_ptr XdmfGrid::getTime() { return boost::const_pointer_cast (static_cast(*this).getTime()); } shared_ptr XdmfGrid::getTime() const { return mTime; } shared_ptr XdmfGrid::getTopology() const { return mTopology; } void XdmfGrid::populateItem(const std::map & itemProperties, const std::vector > & childItems, const XdmfCoreReader * const reader) { XdmfItem::populateItem(itemProperties, childItems, reader); std::map::const_iterator name = itemProperties.find("Name"); if(name != itemProperties.end()) { mName = name->second; } else { mName = ""; } for(std::vector >::const_iterator iter = childItems.begin(); iter != childItems.end(); ++iter) { if(shared_ptr attribute = shared_dynamic_cast(*iter)) { this->insert(attribute); } else if(shared_ptr geometry = shared_dynamic_cast(*iter)) { mGeometry = geometry; } else if(shared_ptr map = shared_dynamic_cast(*iter)) { this->insert(map); } else if(shared_ptr set = shared_dynamic_cast(*iter)) { this->insert(set); } else if(shared_ptr time = shared_dynamic_cast(*iter)) { mTime = time; } else if(shared_ptr topology = shared_dynamic_cast(*iter)) { mTopology = topology; } else if(shared_ptr gridController = shared_dynamic_cast(*iter)) { this->setGridController(gridController); } } } void XdmfGrid::read() { } void XdmfGrid::release() { this->setName(""); this->setTime(shared_ptr()); while(this->getNumberAttributes() > 0) { this->removeAttribute(0); } while(this->getNumberInformations() > 0) { this->removeInformation(0); } while(this->getNumberSets() > 0) { this->removeSet(0); } while(this->getNumberMaps() > 0) { this->removeMap(0); } } void XdmfGrid::setGridController(shared_ptr newController) { mGridController = newController; } void XdmfGrid::setName(const std::string & name) { mName = name; this->setIsChanged(true); } void XdmfGrid::setTime(const shared_ptr time) { mTime = time; this->setIsChanged(true); } void XdmfGrid::traverse(const shared_ptr visitor) { XdmfItem::traverse(visitor); if (mGridController) { mGridController->accept(visitor); } if(mTime) { mTime->accept(visitor); } if(mGeometry) { mGeometry->accept(visitor); } if(mTopology) { mTopology->accept(visitor); } for (unsigned int i = 0; i < mAttributes.size(); ++i) { mAttributes[i]->accept(visitor); } for (unsigned int i = 0; i < mMaps.size(); ++i) { mMaps[i]->accept(visitor); } for (unsigned int i = 0; i < mSets.size(); ++i) { mSets[i]->accept(visitor); } } // C Wrappers XDMFATTRIBUTE * XdmfGridGetAttribute(XDMFGRID * grid, unsigned int index) { XdmfItem * tempPointer = (XdmfItem *)(grid); XdmfGrid * gridPointer = dynamic_cast(tempPointer); return (XDMFATTRIBUTE *)((void *)(gridPointer->getAttribute(index).get())); } XDMFATTRIBUTE * XdmfGridGetAttributeByName(XDMFGRID * grid, char * Name) { XdmfItem * tempPointer = (XdmfItem *)(grid); XdmfGrid * gridPointer = dynamic_cast(tempPointer); return (XDMFATTRIBUTE *)((void *)(gridPointer->getAttribute(Name).get())); } unsigned int XdmfGridGetNumberAttributes(XDMFGRID * grid) { XdmfItem * tempPointer = (XdmfItem *)(grid); XdmfGrid * gridPointer = dynamic_cast(tempPointer); return gridPointer->getNumberAttributes(); } void XdmfGridInsertAttribute(XDMFGRID * grid, XDMFATTRIBUTE * Attribute, int passControl) { XdmfItem * tempPointer = (XdmfItem *)(grid); XdmfGrid * gridPointer = dynamic_cast(tempPointer); if (passControl) { gridPointer->insert(shared_ptr((XdmfAttribute *)Attribute)); } else { gridPointer->insert(shared_ptr((XdmfAttribute *)Attribute, XdmfNullDeleter())); } } void XdmfGridRemoveAttribute(XDMFGRID * grid, unsigned int index) { XdmfItem * tempPointer = (XdmfItem *)(grid); XdmfGrid * gridPointer = dynamic_cast(tempPointer); gridPointer->removeAttribute(index); } void XdmfGridRemoveAttributeByName(XDMFGRID * grid, char * Name) { XdmfItem * tempPointer = (XdmfItem *)(grid); XdmfGrid * gridPointer = dynamic_cast(tempPointer); gridPointer->removeAttribute(Name); } XDMFSET * XdmfGridGetSet(XDMFGRID * grid, unsigned int index) { XdmfItem * tempPointer = (XdmfItem *)(grid); XdmfGrid * gridPointer = dynamic_cast(tempPointer); return (XDMFSET *)((void *)(gridPointer->getSet(index).get())); } XDMFSET * XdmfGridGetSetByName(XDMFGRID * grid, char * Name) { XdmfItem * tempPointer = (XdmfItem *)(grid); XdmfGrid * gridPointer = dynamic_cast(tempPointer); return (XDMFSET *)((void *)(gridPointer->getSet(Name).get())); } unsigned int XdmfGridGetNumberSets(XDMFGRID * grid) { XdmfItem * tempPointer = (XdmfItem *)(grid); XdmfGrid * gridPointer = dynamic_cast(tempPointer); return gridPointer->getNumberSets(); } void XdmfGridInsertSet(XDMFGRID * grid, XDMFSET * Set, int passControl) { XdmfItem * tempPointer = (XdmfItem *)(grid); XdmfGrid * gridPointer = dynamic_cast(tempPointer); if (passControl) { gridPointer->insert(shared_ptr((XdmfSet *)Set)); } else { gridPointer->insert(shared_ptr((XdmfSet *)Set, XdmfNullDeleter())); } } void XdmfGridRemoveSet(XDMFGRID * grid, unsigned int index) { XdmfItem * tempPointer = (XdmfItem *)(grid); XdmfGrid * gridPointer = dynamic_cast(tempPointer); gridPointer->removeSet(index); } void XdmfGridRemoveSetByName(XDMFGRID * grid, char * Name) { XdmfItem * tempPointer = (XdmfItem *)(grid); XdmfGrid * gridPointer = dynamic_cast(tempPointer); gridPointer->removeSet(Name); } XDMFMAP * XdmfGridGetMap(XDMFGRID * grid, unsigned int index) { XdmfItem * tempPointer = (XdmfItem *)(grid); XdmfGrid * gridPointer = dynamic_cast(tempPointer); return (XDMFMAP *)((void *)(gridPointer->getMap(index).get())); } XDMFMAP * XdmfGridGetMapByName(XDMFGRID * grid, char * Name) { XdmfItem * tempPointer = (XdmfItem *)(grid); XdmfGrid * gridPointer = dynamic_cast(tempPointer); return (XDMFMAP *)((void *)(gridPointer->getMap(Name).get())); } unsigned int XdmfGridGetNumberMaps(XDMFGRID * grid) { XdmfItem * tempPointer = (XdmfItem *)(grid); XdmfGrid * gridPointer = dynamic_cast(tempPointer); return gridPointer->getNumberMaps(); } void XdmfGridInsertMap(XDMFGRID * grid, XDMFMAP * Map, int passControl) { XdmfItem * tempPointer = (XdmfItem *)(grid); XdmfGrid * gridPointer = dynamic_cast(tempPointer); if (passControl) { gridPointer->insert(shared_ptr((XdmfMap *)Map)); } else { gridPointer->insert(shared_ptr((XdmfMap *)Map, XdmfNullDeleter())); } } void XdmfGridRemoveMap(XDMFGRID * grid, unsigned int index) { XdmfItem * tempPointer = (XdmfItem *)(grid); XdmfGrid * gridPointer = dynamic_cast(tempPointer); gridPointer->removeMap(index); } void XdmfGridRemoveMapByName(XDMFGRID * grid, char * Name) { XdmfItem * tempPointer = (XdmfItem *)(grid); XdmfGrid * gridPointer = dynamic_cast(tempPointer); gridPointer->removeMap(Name); } XDMFGRIDCONTROLLER * XdmfGridGetGridController(XDMFGRID * grid) { XdmfItem * classedPointer = (XdmfItem *)grid; XdmfGrid * gridPointer = dynamic_cast(classedPointer); shared_ptr generatedController = gridPointer->getGridController(); return (XDMFGRIDCONTROLLER *)((void *)(generatedController.get())); } char * XdmfGridGetName(XDMFGRID * grid) { XdmfItem * tempPointer = (XdmfItem *)(grid); XdmfGrid * gridPointer = dynamic_cast(tempPointer); return strdup(gridPointer->getName().c_str()); } XDMFTIME * XdmfGridGetTime(XDMFGRID * grid) { XdmfItem * classedPointer = (XdmfItem *)grid; XdmfGrid * gridPointer = dynamic_cast(classedPointer); shared_ptr generatedTime = gridPointer->getTime(); return (XDMFTIME *)((void *)(generatedTime.get())); } void XdmfGridRead(XDMFGRID * grid, int * status) { XDMF_ERROR_WRAP_START(status) try { XdmfItem * classedPointer = (XdmfItem *)grid; XdmfGrid * gridPointer = dynamic_cast(classedPointer); gridPointer->read(); } catch (...) { XdmfItem * classedPointer = (XdmfItem *)grid; XdmfGrid * gridPointer = dynamic_cast(classedPointer); gridPointer->read(); } XDMF_ERROR_WRAP_END(status) } void XdmfGridRelease(XDMFGRID * grid) { XdmfItem * classedPointer = (XdmfItem *)grid; XdmfGrid * gridPointer = dynamic_cast(classedPointer); gridPointer->release(); } void XdmfGridSetGridController(XDMFGRID * grid, XDMFGRIDCONTROLLER * controller, int passControl) { XdmfItem * classedPointer = (XdmfItem *)grid; XdmfGrid * gridPointer = dynamic_cast(classedPointer); XdmfItem * controllerPointer = (XdmfItem *) controller; XdmfGridController * classedController = dynamic_cast(controllerPointer); if (passControl) { gridPointer->setGridController(shared_ptr(classedController)); } else { gridPointer->setGridController(shared_ptr(classedController, XdmfNullDeleter())); } } void XdmfGridSetName(XDMFGRID * grid, char * name, int * status) { XDMF_ERROR_WRAP_START(status) XdmfItem * tempPointer = (XdmfItem *)(grid); XdmfGrid * gridPointer = dynamic_cast(tempPointer); gridPointer->setName(name); XDMF_ERROR_WRAP_END(status) } void XdmfGridSetTime(XDMFGRID * grid, XDMFTIME * time, int passControl) { XdmfItem * classedPointer = (XdmfItem *)grid; XdmfGrid * gridPointer = dynamic_cast(classedPointer); if (passControl) { gridPointer->setTime(shared_ptr((XdmfTime *)time)); } else { gridPointer->setTime(shared_ptr((XdmfTime *)time, XdmfNullDeleter())); } } XDMF_ITEM_C_CHILD_WRAPPER(XdmfGrid, XDMFGRID) xdmf-3.0+git20160803/XdmfTopology.hpp0000640000175000017500000001535013003006557017242 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfTopology.hpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef XDMFTOPOLOGY_HPP_ #define XDMFTOPOLOGY_HPP_ // C Compatible Includes #include "Xdmf.hpp" #include "XdmfArray.hpp" #include "XdmfTopologyType.hpp" #ifdef __cplusplus /** * @brief Holds the connectivity information in an XdmfGrid. * * XdmfTopology is a required part of an XdmfGrid. It stores the * connectivity information for all points contained in an * XdmfGrid. XdmfTopology contains an XdmfTopologyType property which * should be set that specifies the element type stored. * * In the case of mixed topology types, the connectivity stores * topology type ids prior to each element's connectivity * information. For element types of varying sizes (Polyvertex, * Polyline, and Polygon), the topology type id is followed by a * number specifying the number of nodes in the element. For example, * a tetrahedron element (id 6) followed by a polygon element (id 3) * with 5 points would look similar the following: * * 6 20 25 100 200 3 5 300 301 302 303 304 * * The tetrahedron is composed of nodes 20, 25, 100, and 200. The * polygon is composed of nodes 300 to 304. * * Elements of type Polyhedron (i.e. N face cells, where each face is a M edge * polygon) are in the following format: * [nCellFaces, nFace0Pts, id0_0, id0_1, ..., nFace1Pts, id1_0, id1_1, ..., ...] */ class XDMF_EXPORT XdmfTopology : public XdmfArray { public: /** * Create a new XdmfTopology. * * Example of use: * * C++ * * @dontinclude ExampleXdmfTopology.cpp * @skipline //#initialization * @until //#initialization * * Python * * @dontinclude XdmfExampleTopology.py * @skipline #//initialization * @until #//initialization * * @return Constructed XdmfTopology. */ static shared_ptr New(); virtual ~XdmfTopology(); LOKI_DEFINE_VISITABLE(XdmfTopology, XdmfArray) static const std::string ItemTag; /** * */ int getBaseOffset() const; std::map getItemProperties() const; std::string getItemTag() const; /** * Get the number of elements this Topology contains. * * Example of use: * * C++ * * @dontinclude ExampleXdmfTopology.cpp * @skipline //#initialization * @until //#initialization * @skipline //#getNumberElements * @until //#getNumberElements * * Python * * @dontinclude XdmfExampleTopology.py * @skipline #//initialization * @until #//initialization * @skipline #//getNumberElements * @until #//getNumberElements * * @return Int of number elements in the Topology. */ virtual unsigned int getNumberElements() const; /** * Get the XdmfTopologyType associated with this topology. * * Example of use: * * C++ * * @dontinclude ExampleXdmfTopology.cpp * @skipline //#initialization * @until //#initialization * @skipline //#setType * @until //#setType * @skipline //#getType * @until //#getType * * Python * * @dontinclude XdmfExampleTopology.py * @skipline #//initialization * @until #//initialization * @skipline #//setType * @until #//setType * @skipline #//getType * @until #//getType * * @return XdmfTopologyType of the topology. */ shared_ptr getType() const; /** * */ void setBaseOffset(int offset); /** * Set the XdmfTopologyType associated with this topology. * * Example of use: * * C++ * * @dontinclude ExampleXdmfTopology.cpp * @skipline //#initialization * @until //#initialization * @skipline //#setType * @until //#setType * * Python * * @dontinclude XdmfExampleTopology.py * @skipline #//initialization * @until #//initialization * @skipline #//setType * @until #//setType * * @param type The XdmfTopologyType to set. */ void setType(const shared_ptr type); XdmfTopology(XdmfTopology &); protected: XdmfTopology(); virtual void populateItem(const std::map & itemProperties, const std::vector > & childItems, const XdmfCoreReader * const reader); private: XdmfTopology(const XdmfTopology &); void operator=(const XdmfTopology &); // Not implemented. shared_ptr mType; int mBaseOffset; }; #endif #ifdef __cplusplus extern "C" { #endif // C wrappers go here struct XDMFTOPOLOGY; // Simply as a typedef to ensure correct typing typedef struct XDMFTOPOLOGY XDMFTOPOLOGY; XDMF_EXPORT XDMFTOPOLOGY * XdmfTopologyNew(); XDMF_EXPORT unsigned int XdmfTopologyGetNumberElements(XDMFTOPOLOGY * topology, int * status); XDMF_EXPORT int XdmfTopologyGetType(XDMFTOPOLOGY * topology); XDMF_EXPORT void XdmfTopologySetType(XDMFTOPOLOGY * topology, int type, int * status); XDMF_EXPORT void XdmfTopologySetPolyType(XDMFTOPOLOGY * topology, int type, int nodes, int * status); XDMF_ITEM_C_CHILD_DECLARE(XdmfTopology, XDMFTOPOLOGY, XDMF) XDMF_ARRAY_C_CHILD_DECLARE(XdmfTopology, XDMFTOPOLOGY, XDMF) #ifdef __cplusplus } #endif #endif /* XDMFTOPOLOGY_HPP_ */ xdmf-3.0+git20160803/utils/0000740000175000017500000000000013003006557015230 5ustar alastairalastairxdmf-3.0+git20160803/utils/XdmfUtils.hpp0000640000175000017500000000707513003006557017673 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : Xdmf.hpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef _XDMFUTILS_HPP #define _XDMFUTILS_HPP /* Keep all our Win32 Conversions here */ #ifdef _WIN32 /* Used to export/import from the dlls */ #undef XDMFCORE_EXPORT #define XDMFCORE_EXPORT __declspec(dllimport) #undef XDMFCORE_TEMPLATE #define XDMFCORE_TEMPLATE extern #undef XDMFDSM_EXPORT #define XDMFDSM_EXPORT __declspec(dllimport) #undef XDMFDSM_TEMPLATE #define XDMFDSM_TEMPLATE extern #undef XDMF_EXPORT #define XDMF_EXPORT __declspec(dllimport) #undef XDMF_TEMPLATE #define XDMF_TEMPLATE extern #ifdef XdmfUtils_EXPORTS #define XDMFUTILS_EXPORT __declspec(dllexport) #define XDMFUTILS_TEMPLATE #else /* XdmfUtils_EXPORTS */ #define XDMFUTILS_EXPORT __declspec(dllimport) #define XDMFUTILS_TEMPLATE extern #endif /* XdmfUtils_EXPORTS */ /* Compiler Warnings */ #ifndef XDMF_DEBUG #pragma warning( disable : 4231 ) /* nonstandard extension used : 'extern' before template explicit instantiation */ #pragma warning( disable : 4251 ) /* needs to have dll-interface to be used by clients (Most of these guys are in private */ #pragma warning( disable : 4275 ) /* non dll-interface class 'std::_Container_base_aux' used as base for dll-interface class */ #pragma warning( disable : 4373 ) /* virtual function overrides, parameters only differed by const/volatile qualifiers */ #pragma warning( disable : 4748 ) /* /GS can not protect parameters and local variables from local buffer overrun (turned off op)*/ #endif /* XDMF_DEBUG */ /* Compiler Optimizations will result in an 'internal compiler error', so turn them off */ #pragma optimize("g", off) #else /* _WIN32 */ /* We don't need to export/import since there are no dlls */ #define XDMFCORE_EXPORT #define XDMFDSM_EXPORT #define XDMF_EXPORT #define XDMFUTILS_EXPORT #define XDMFCORE_TEMPLATE #define XDMFDSM_TEMPLATE #define XDMF_TEMPLATE #define XDMFUTILS_TEMPLATE #endif /* _WIN32 */ #endif /* _XDMFUTILS_HPP */ xdmf-3.0+git20160803/utils/XdmfGeometryConverter.cpp0000640000175000017500000003266313003006557022252 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfTopologyConverter.cpp */ /* */ /* Author: */ /* Andrew Burns */ /* andrew.j.burns2@us.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2013 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #include #include #include #include #include "XdmfAttribute.hpp" #include "XdmfAttributeCenter.hpp" #include "XdmfAttributeType.hpp" #include "XdmfGeometry.hpp" #include "XdmfGeometryType.hpp" #include "XdmfHeavyDataWriter.hpp" #include "XdmfSet.hpp" #include "XdmfSetType.hpp" #include "XdmfGeometry.hpp" #include "XdmfGeometryConverter.hpp" #include "XdmfGeometryType.hpp" #include "XdmfUnstructuredGrid.hpp" #include "XdmfError.hpp" shared_ptr XdmfGeometryConverter::New() { shared_ptr p(new XdmfGeometryConverter()); return p; } XdmfGeometryConverter::XdmfGeometryConverter() { } XdmfGeometryConverter::XdmfGeometryConverter(const XdmfGeometryConverter &) { } XdmfGeometryConverter::~XdmfGeometryConverter() { } shared_ptr XdmfGeometryConverter::convertToCartesian(const shared_ptr & geometryToConvert) const { if (geometryToConvert->getType() == XdmfGeometryType::NoGeometryType()) { XdmfError::message(XdmfError::FATAL, "Error: Converted Geometry size doesn't have a geometry type set"); } if (geometryToConvert->getType() == XdmfGeometryType::XY() || geometryToConvert->getType() == XdmfGeometryType::XYZ()) { // Already in Cartesian form return geometryToConvert; } else { shared_ptr returnGeometry = XdmfGeometry::New(); if (!geometryToConvert->isInitialized()) { geometryToConvert->read(); } if (geometryToConvert->getSize()%geometryToConvert->getType()->getDimensions() != 0) { XdmfError::message(XdmfError::FATAL, "Error: Converted Geometry size doesn't match number of dimensions"); } else { if (geometryToConvert->getType()->getDimensions() == 2) { // Polar to XY returnGeometry->setType(XdmfGeometryType::XY()); if (geometryToConvert->getSize() < 2) { return returnGeometry; } std::vector origin = geometryToConvert->getOrigin(); returnGeometry->setOrigin(origin); unsigned int i = 0; while(i+1 < geometryToConvert->getSize()) { double radius = geometryToConvert->getValue(i); double inclination = geometryToConvert->getValue(i+1); double x = (radius * std::sin(inclination)); double y = (radius * std::cos(inclination)); returnGeometry->pushBack(x); returnGeometry->pushBack(y); i = i + 2; } } else if (geometryToConvert->getType()->getDimensions() == 3) { // Spherical to XYZ returnGeometry->setType(XdmfGeometryType::XYZ()); if (geometryToConvert->getSize() < 3) { return returnGeometry; } std::vector origin = geometryToConvert->getOrigin(); returnGeometry->setOrigin(origin); unsigned int i = 0; while(i+2 < geometryToConvert->getSize()) { double radius = geometryToConvert->getValue(i); double inclination = geometryToConvert->getValue(i+1); double azimuth = geometryToConvert->getValue(i+2); double x = (radius * std::sin(inclination) * std::cos(azimuth)); double y = (radius * std::sin(inclination) * std::sin(azimuth)); double z = (radius * std::cos(inclination)); returnGeometry->pushBack(x); returnGeometry->pushBack(y); returnGeometry->pushBack(z); i = i + 3; } } else { XdmfError::message(XdmfError::FATAL, "Error: Converted Geometry has an invalid number of dimensions"); } } return returnGeometry; } } shared_ptr XdmfGeometryConverter::convertToSpherical(const shared_ptr & geometryToConvert) const { if (geometryToConvert->getType() == XdmfGeometryType::NoGeometryType()) { XdmfError::message(XdmfError::FATAL, "Error: Converted Geometry size doesn't have a geometry type set"); } if (geometryToConvert->getType() == XdmfGeometryType::Polar() || geometryToConvert->getType() == XdmfGeometryType::Spherical()) { // Already in Spherical form return geometryToConvert; } else { shared_ptr returnGeometry = XdmfGeometry::New(); if (!geometryToConvert->isInitialized()) { geometryToConvert->read(); } if (geometryToConvert->getSize()%geometryToConvert->getType()->getDimensions() != 0) { XdmfError::message(XdmfError::FATAL, "Error: Converted Geometry size doesn't match number of dimensions"); } else { if (geometryToConvert->getType()->getDimensions() == 2) { // XY to Polar returnGeometry->setType(XdmfGeometryType::Polar()); // insert origin std::vector origin = geometryToConvert->getOrigin(); returnGeometry->setOrigin(origin); unsigned int i = 0; while(i+1 < geometryToConvert->getSize()) { double x = geometryToConvert->getValue(i); double y = geometryToConvert->getValue(i+1); double radius = std::sqrt(std::pow(x, 2) + std::pow(y, 2)); double inclination = std::acos(x/radius); returnGeometry->pushBack(radius); returnGeometry->pushBack(inclination); i = i + 2; } } else if (geometryToConvert->getType()->getDimensions() == 3) { // XYZ to Spherical returnGeometry->setType(XdmfGeometryType::Spherical()); // insert origin std::vector origin = geometryToConvert->getOrigin(); returnGeometry->setOrigin(origin); unsigned int i = 0; while(i+2 < geometryToConvert->getSize()) { double x = geometryToConvert->getValue(i); double y = geometryToConvert->getValue(i+1); double z = geometryToConvert->getValue(i+2); double radius = std::sqrt(std::pow(x, 2) + std::pow(y, 2) + std::pow(z, 2)); double inclination = std::acos(z/radius); double azimuth = std::atan(y/x); returnGeometry->pushBack(radius); returnGeometry->pushBack(inclination); returnGeometry->pushBack(azimuth); i = i + 3; } } else { XdmfError::message(XdmfError::FATAL, "Error: Converted Geometry has an invalid number of dimensions"); } } return returnGeometry; } } void XdmfGeometryConverter::convertToCartesianOverwrite(shared_ptr & geometryToConvert) const { if (!(geometryToConvert->getType() == XdmfGeometryType::XY() || geometryToConvert->getType() == XdmfGeometryType::XYZ())) { shared_ptr tempGeometry = convertToCartesian(geometryToConvert); // Change the type of the geometry provided geometryToConvert->setType(tempGeometry->getType()); // Move values over to the original to complete the conversion geometryToConvert->swap(tempGeometry); } } void XdmfGeometryConverter::convertToSphericalOverwrite(shared_ptr & geometryToConvert) const { if (!(geometryToConvert->getType() == XdmfGeometryType::Polar() || geometryToConvert->getType() == XdmfGeometryType::Spherical())) { shared_ptr tempGeometry = convertToSpherical(geometryToConvert); // Change the type of the geometry provided geometryToConvert->setType(tempGeometry->getType()); // Move values over to the original to complete the conversion geometryToConvert->swap(tempGeometry); } } shared_ptr XdmfGeometryConverter::zeroOrigin(const shared_ptr & geometryToConvert) { shared_ptr returnGeometry = shared_ptr(); std::vector origin = geometryToConvert->getOrigin(); if (origin.size() < geometryToConvert->getType()->getDimensions()) { while (origin.size() < geometryToConvert->getType()->getDimensions()) { origin.push_back(0.0); } } if (geometryToConvert->getType() == XdmfGeometryType::XY() || geometryToConvert->getType() == XdmfGeometryType::XYZ()) { returnGeometry = XdmfGeometry::New(); returnGeometry->setType(geometryToConvert->getType()); returnGeometry->initialize(geometryToConvert->getArrayType(), geometryToConvert->getDimensions()); // Simply add the origin as an offset. unsigned int originIndex = 0; for (unsigned int i = 0; i < geometryToConvert->getSize(); ++i) { returnGeometry->insert(i, (geometryToConvert->getValue(i) + origin[originIndex])); originIndex = (originIndex + 1) % geometryToConvert->getType()->getDimensions(); } } else if (geometryToConvert->getType() == XdmfGeometryType::Polar() || geometryToConvert->getType() == XdmfGeometryType::Spherical()) { // The spherical version needs to convert to cartesian and back. returnGeometry = convertToSpherical(zeroOrigin(convertToCartesian(geometryToConvert))); } return returnGeometry; } void XdmfGeometryConverter::zeroOriginOverwrite(shared_ptr & geometryToConvert) { shared_ptr tempGeometry = zeroOrigin(geometryToConvert); geometryToConvert->swap(tempGeometry);; } // C Wrappers XDMFGEOMETRYCONVERTER * XdmfGeometryConverterNew() { shared_ptr generatedConverter = XdmfGeometryConverter::New(); return (XDMFGEOMETRYCONVERTER *)((void *)(new XdmfGeometryConverter(*generatedConverter.get()))); } XDMFGEOMETRY * XdmfGeometryConverterConvertToCartesian(XDMFGEOMETRYCONVERTER * converter, XDMFGEOMETRY * geometryToConvert) { shared_ptr tempGeo = shared_ptr((XdmfGeometry *) geometryToConvert, XdmfNullDeleter()); return (XDMFGEOMETRY *)((void *)(new XdmfGeometry(*((((XdmfGeometryConverter *)converter)->convertToCartesian(tempGeo)).get())))); } XDMFGEOMETRY * XdmfGeometryConverterConvertToSpherical(XDMFGEOMETRYCONVERTER * converter, XDMFGEOMETRY * geometryToConvert) { shared_ptr tempGeo = shared_ptr((XdmfGeometry *) geometryToConvert, XdmfNullDeleter()); return (XDMFGEOMETRY *)((void *)(new XdmfGeometry(*((((XdmfGeometryConverter *)converter)->convertToSpherical(tempGeo)).get())))); } void XdmfGeometryConverterConvertToCartesianOverwrite(XDMFGEOMETRYCONVERTER * converter, XDMFGEOMETRY * geometryToConvert) { shared_ptr tempGeo = shared_ptr((XdmfGeometry *) geometryToConvert, XdmfNullDeleter()); ((XdmfGeometryConverter *)converter)->convertToCartesianOverwrite(tempGeo); } void XdmfGeometryConverterConvertToSphericalOverwrite(XDMFGEOMETRYCONVERTER * converter, XDMFGEOMETRY * geometryToConvert) { shared_ptr tempGeo = shared_ptr((XdmfGeometry *) geometryToConvert, XdmfNullDeleter()); ((XdmfGeometryConverter *)converter)->convertToSphericalOverwrite(tempGeo); } XDMFGEOMETRY * XdmfGeometryConverterZeroOrigin(XDMFGEOMETRYCONVERTER * converter, XDMFGEOMETRY * geometryToConvert) { shared_ptr tempGeo = shared_ptr((XdmfGeometry *) geometryToConvert, XdmfNullDeleter()); return (XDMFGEOMETRY *)((void *)(new XdmfGeometry(*((((XdmfGeometryConverter *)converter)->zeroOrigin(tempGeo)).get())))); } void XdmfGeometryConverterZeroOriginOverwrite(XDMFGEOMETRYCONVERTER * converter, XDMFGEOMETRY * geometryToConvert) { shared_ptr tempGeo = shared_ptr((XdmfGeometry *) geometryToConvert, XdmfNullDeleter()); ((XdmfGeometryConverter *)converter)->zeroOriginOverwrite(tempGeo); } void XdmfGeometryConverterFree(XDMFGEOMETRYCONVERTER * converter) { if (converter != NULL) { delete ((XdmfGeometryConverter *)converter); converter = NULL; } } xdmf-3.0+git20160803/utils/XdmfExodusReader.hpp0000640000175000017500000000707013003006557021160 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfExodusReader.hpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef XDMFEXODUSREADER_HPP_ #define XDMFEXODUSREADER_HPP_ #ifdef __cplusplus // Forward Declarations class XdmfHeavyDataWriter; class XdmfUnstructuredGrid; // Includes #include #include "XdmfUtils.hpp" #include "XdmfSharedPtr.hpp" /** * @brief Reads an ExodusII file from disk into an Xdmf structure in * memory. */ class XDMFUTILS_EXPORT XdmfExodusReader { public: /** * Create a new XdmfExodusReader. * * @return constructed XdmfExodusReader. */ static shared_ptr New(); virtual ~XdmfExodusReader(); /** * Read the contents of an ExodusII file from disk into an Xdmf * structure in memory. * * @param fileName containing the path of the exodus file to read. * @param heavyDataWriter an XdmfHeavyDataWriter to write the mesh to. If no * heavyDataWriter is specified, all mesh data will remain in memory. * * @return an unstructured grid containing the mesh stored in the ExodusII * file. */ shared_ptr read(const std::string & fileName, const shared_ptr heavyDataWriter = shared_ptr()) const; protected: XdmfExodusReader(); private: XdmfExodusReader(const XdmfExodusReader &); // Not implemented. void operator=(const XdmfExodusReader &); // Not implemented. }; #endif #ifdef __cplusplus extern "C" { #endif // C wrappers go here struct XDMFEXODUSREADER; // Simply as a typedef to ensure correct typing typedef struct XDMFEXODUSREADER XDMFEXODUSREADER; XDMFUTILS_EXPORT XDMFEXODUSREADER * XdmfExodusReaderNew(); XDMFUTILS_EXPORT XDMFUNSTRUCTUREDGRID * XdmfExodusReaderRead(XDMFEXODUSREADER * reader, char * fileName, XDMFHEAVYDATAWRITER * heavyDataWriter); XDMFUTILS_EXPORT void XdmfExodusReaderFree(XDMFEXODUSREADER * reader); #ifdef __cplusplus } #endif #endif /* XDMFEXODUSREADER_HPP_ */ xdmf-3.0+git20160803/utils/XdmfFortran.cpp0000640000175000017500000136463013003006557020205 0ustar alastairalastair /*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : Id */ /* Date : $Date$ */ /* Version : $Revision$ */ /* */ /* Author: */ /* John Vines */ /* john.m.vines@us.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2009 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #include #include "XdmfFortran.hpp" #include "XdmfArrayType.hpp" #include "XdmfAttribute.hpp" #include "XdmfAttributeCenter.hpp" #include "XdmfAttributeType.hpp" #include "XdmfBinaryController.hpp" #include "XdmfDomain.hpp" #include "XdmfError.hpp" #include "XdmfFunction.hpp" #include "XdmfGeometry.hpp" #include "XdmfGeometryType.hpp" #include "XdmfGrid.hpp" #include "XdmfGridCollection.hpp" #include "XdmfGridCollectionType.hpp" #include "XdmfGridController.hpp" #include "XdmfInformation.hpp" #include "XdmfReader.hpp" #include "XdmfTime.hpp" #include "XdmfTopology.hpp" #include "XdmfTopologyType.hpp" #include "XdmfSet.hpp" #include "XdmfSetType.hpp" #include "XdmfSubset.hpp" #include "XdmfMap.hpp" #include "XdmfCurvilinearGrid.hpp" #include "XdmfRectilinearGrid.hpp" #include "XdmfRegularGrid.hpp" #include "XdmfUnstructuredGrid.hpp" #include "XdmfWriter.hpp" #include "XdmfHDF5Writer.hpp" #include "XdmfHDF5Controller.hpp" #include "string.h" #include #include #ifdef XDMF_BUILD_DSM #include #include "XdmfHDF5WriterDSM.hpp" #include "XdmfHDF5ControllerDSM.hpp" #endif template void XdmfFortran::insertElements(const T grid, std::vector > & mAttributes, std::vector > & mInformations, std::vector > & mSets, std::vector > & mMaps, shared_ptr mTime, shared_ptr mDomain, std::stack > & mGridCollections) { for(std::vector >::const_iterator iter = mAttributes.begin(); iter != mAttributes.end(); ++iter) { grid->insert(*iter); } mAttributes.clear(); for(std::vector >::const_iterator iter = mInformations.begin(); iter != mInformations.end(); ++iter) { grid->insert(*iter); } mInformations.clear(); for(std::vector >::const_iterator iter = mSets.begin(); iter != mSets.end(); ++iter) { grid->insert(*iter); } mSets.clear(); for(std::vector >::const_iterator iter = mMaps.begin(); iter != mMaps.end(); ++iter) { grid->insert(*iter); } mMaps.clear(); if(mTime) { grid->setTime(mTime); } if(mGridCollections.empty()) { mDomain->insert(grid); } else { mGridCollections.top()->insert(grid); } } // read values from an xdmf array for a number type void XdmfFortran::readFromArray(shared_ptr array, const int arrayType, void * const values, const unsigned int numValues, const unsigned int startIndex, const unsigned int arrayStride, const unsigned int valuesStride) { if (!array->isInitialized()) { array->read(); } switch(arrayType) { case XDMF_ARRAY_TYPE_INT8: array->getValues(startIndex, static_cast(values), numValues, arrayStride, valuesStride); break; case XDMF_ARRAY_TYPE_INT16: array->getValues(startIndex, static_cast(values), numValues, arrayStride, valuesStride); break; case XDMF_ARRAY_TYPE_INT32: array->getValues(startIndex, static_cast(values), numValues, arrayStride, valuesStride); break; case XDMF_ARRAY_TYPE_INT64: array->getValues(startIndex, static_cast(values), numValues, arrayStride, valuesStride); break; case XDMF_ARRAY_TYPE_UINT8: array->getValues(startIndex, static_cast(values), numValues, arrayStride, valuesStride); break; case XDMF_ARRAY_TYPE_UINT16: array->getValues(startIndex, static_cast(values), numValues, arrayStride, valuesStride); break; case XDMF_ARRAY_TYPE_UINT32: array->getValues(startIndex, static_cast(values), numValues, arrayStride, valuesStride); break; case XDMF_ARRAY_TYPE_FLOAT32: array->getValues(startIndex, static_cast(values), numValues, arrayStride, valuesStride); break; case XDMF_ARRAY_TYPE_FLOAT64: array->getValues(startIndex, static_cast(values), numValues, arrayStride, valuesStride); break; default: try { XdmfError::message(XdmfError::FATAL, "Invalid array number type"); } catch (XdmfError & e) { throw e; } } } // write values to xdmf array for a number type void XdmfFortran::writeToArray(shared_ptr array, const unsigned int numValues, const int arrayType, const void * const values, const unsigned int offset, const unsigned int arrayStride, const unsigned int valueStride) { switch(arrayType) { case XDMF_ARRAY_TYPE_INT8: array->insert(offset, static_cast(values), numValues, arrayStride, valueStride); break; case XDMF_ARRAY_TYPE_INT16: array->insert(offset, static_cast(values), numValues, arrayStride, valueStride); break; case XDMF_ARRAY_TYPE_INT32: array->insert(offset, static_cast(values), numValues, arrayStride, valueStride); break; case XDMF_ARRAY_TYPE_INT64: array->insert(offset, static_cast(values), numValues, arrayStride, valueStride); break; case XDMF_ARRAY_TYPE_UINT8: array->insert(offset, static_cast(values), numValues, arrayStride, valueStride); break; case XDMF_ARRAY_TYPE_UINT16: array->insert(offset, static_cast(values), numValues, arrayStride, valueStride); break; case XDMF_ARRAY_TYPE_UINT32: array->insert(offset, static_cast(values), numValues, arrayStride, valueStride); break; case XDMF_ARRAY_TYPE_FLOAT32: array->insert(offset, static_cast(values), numValues, arrayStride, valueStride); break; case XDMF_ARRAY_TYPE_FLOAT64: array->insert(offset, static_cast(values), numValues, arrayStride, valueStride); break; default: try { XdmfError::message(XdmfError::FATAL, "Invalid array type"); } catch (XdmfError & e) { throw e; } } } XdmfFortran::XdmfFortran() : mDomain(XdmfDomain::New()), mGeometry(shared_ptr()), mTime(shared_ptr()), mTopology(shared_ptr()), mBrick(shared_ptr()), mOrigin(shared_ptr()), mDimensions(shared_ptr()), mHeavyDataWriter(shared_ptr()), mDSMWriter(shared_ptr()), mSubsetReference(shared_ptr()), mMaxFileSize(0), mAllowSetSplitting(false) { } XdmfFortran::~XdmfFortran() { } int XdmfFortran::addAttribute(const char * const name, const int attributeCenter, const int attributeType, const unsigned int numValues, const int arrayType, const void * const values) { shared_ptr currAttribute = XdmfAttribute::New(); currAttribute->setName(name); switch(attributeCenter) { case XDMF_ATTRIBUTE_CENTER_GRID: currAttribute->setCenter(XdmfAttributeCenter::Grid()); break; case XDMF_ATTRIBUTE_CENTER_CELL: currAttribute->setCenter(XdmfAttributeCenter::Cell()); break; case XDMF_ATTRIBUTE_CENTER_FACE: currAttribute->setCenter(XdmfAttributeCenter::Face()); break; case XDMF_ATTRIBUTE_CENTER_EDGE: currAttribute->setCenter(XdmfAttributeCenter::Edge()); break; case XDMF_ATTRIBUTE_CENTER_NODE: currAttribute->setCenter(XdmfAttributeCenter::Node()); break; default: try { XdmfError::message(XdmfError::FATAL, "Invalid attribute center"); } catch (XdmfError & e) { throw e; } } switch(attributeType) { case XDMF_ATTRIBUTE_TYPE_SCALAR: currAttribute->setType(XdmfAttributeType::Scalar()); break; case XDMF_ATTRIBUTE_TYPE_VECTOR: currAttribute->setType(XdmfAttributeType::Vector()); break; case XDMF_ATTRIBUTE_TYPE_TENSOR: currAttribute->setType(XdmfAttributeType::Tensor()); break; case XDMF_ATTRIBUTE_TYPE_MATRIX: currAttribute->setType(XdmfAttributeType::Matrix()); break; case XDMF_ATTRIBUTE_TYPE_TENSOR6: currAttribute->setType(XdmfAttributeType::Tensor6()); break; case XDMF_ATTRIBUTE_TYPE_GLOBALID: currAttribute->setType(XdmfAttributeType::GlobalId()); break; default: try { XdmfError::message(XdmfError::FATAL, "Invalid attribute type"); } catch (XdmfError & e) { throw e; } } for(std::vector >::const_iterator iter = mInformations.begin(); iter != mInformations.end(); ++iter) { currAttribute->insert(*iter); } mInformations.clear(); // insert values into attribute writeToArray(currAttribute, numValues, arrayType, values); mAttributes.push_back(currAttribute); const int id = mPreviousAttributes.size(); mPreviousAttributes.push_back(currAttribute); return id; } void XdmfFortran::clearAttributeHeavyData(const int index) { if (index < mAttributes.size()) { while (mAttributes[index]->getNumberHeavyDataControllers() > 0) { mAttributes[index]->removeHeavyDataController(0); } } else { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } } void XdmfFortran::setAttributeHDF5(const int index, const char * hdf5File, const char * hdf5Dataset, const unsigned int start, const unsigned int stride, const unsigned int numValues, const unsigned int dataspace) { if (index < mAttributes.size()) { // create HDF5 link shared_ptr newController = XdmfHDF5Controller::New(std::string(hdf5File), std::string(hdf5Dataset), mAttributes[index]->getArrayType(), std::vector(1, start), std::vector(1, stride), std::vector(1, numValues), std::vector(1, dataspace)); while (mAttributes[index]->getNumberHeavyDataControllers() > 0) { mAttributes[index]->removeHeavyDataController(0); } mAttributes[index]->insert(newController); } else { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } } void XdmfFortran::setAttributeBinary(const int index, const char * binFile, const int endian, const unsigned int seek, const unsigned int start, const unsigned int stride, const unsigned int numValues, const unsigned int dataspace) { if (index < mAttributes.size()) { // create Binary link XdmfBinaryController::Endian newEndian = XdmfBinaryController::NATIVE; switch (endian) { case XDMF_BINARY_ENDIAN_NATIVE: newEndian = XdmfBinaryController::NATIVE; break; case XDMF_BINARY_ENDIAN_LITTLE: newEndian = XdmfBinaryController::LITTLE; break; case XDMF_BINARY_ENDIAN_BIG: newEndian = XdmfBinaryController::BIG; break; default: break; } shared_ptr newController = XdmfBinaryController::New(std::string(binFile), mAttributes[index]->getArrayType(), newEndian, seek, std::vector(1, start), std::vector(1, stride), std::vector(1, numValues), std::vector(1, dataspace)); while (mAttributes[index]->getNumberHeavyDataControllers() > 0) { mAttributes[index]->removeHeavyDataController(0); } mAttributes[index]->insert(newController); } else { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } } // unstructured version void XdmfFortran::addGrid(const char * const name, const bool writeToHDF5) { const shared_ptr grid = XdmfUnstructuredGrid::New(); grid->setName(name); if(mGeometry == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set geometry before adding grid."); } catch (XdmfError & e) { throw e; } } if(mTopology == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set topology before adding grid."); } catch (XdmfError & e) { throw e; } } grid->setGeometry(mGeometry); grid->setTopology(mTopology); insertElements(grid, mAttributes, mInformations, mSets, mMaps, mTime, mDomain, mGridCollections); if (writeToHDF5 && mHeavyDataWriter != NULL) { mHeavyDataWriter->openFile(); grid->accept(mHeavyDataWriter); mHeavyDataWriter->closeFile(); } } void XdmfFortran::addGridCurvilinear(const char * const name, const bool writeToHDF5) { if(mDimensions == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set dimensions before adding grid."); } catch (XdmfError & e) { throw e; } } const shared_ptr grid = XdmfCurvilinearGrid::New(mDimensions); grid->setName(name); if(mGeometry == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set geometry before adding grid."); } catch (XdmfError & e) { throw e; } } grid->setGeometry(mGeometry); insertElements(grid, mAttributes, mInformations, mSets, mMaps, mTime, mDomain, mGridCollections); if (writeToHDF5 && mHeavyDataWriter != NULL) { mHeavyDataWriter->openFile(); grid->accept(mHeavyDataWriter); mHeavyDataWriter->closeFile(); } } void XdmfFortran::addGridRectilinear(const char * const name, const bool writeToHDF5) { if(mCoordinates.empty()) { try { XdmfError::message(XdmfError::FATAL, "Must set Coordinates before adding grid."); } catch (XdmfError & e) { throw e; } } const shared_ptr grid = XdmfRectilinearGrid::New(mCoordinates); mCoordinates.clear(); grid->setName(name); insertElements(grid, mAttributes, mInformations, mSets, mMaps, mTime, mDomain, mGridCollections); if (writeToHDF5 && mHeavyDataWriter != NULL) { mHeavyDataWriter->openFile(); grid->accept(mHeavyDataWriter); mHeavyDataWriter->closeFile(); } } void XdmfFortran::addGridRegular(const char * const name, const bool writeToHDF5) { if(mBrick == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set brick size before adding grid."); } catch (XdmfError & e) { throw e; } } if(mDimensions == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set dimensions before adding grid."); } catch (XdmfError & e) { throw e; } } if(mOrigin == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set origin before adding grid."); } catch (XdmfError & e) { throw e; } } const shared_ptr grid = XdmfRegularGrid::New(mBrick, mDimensions, mOrigin); grid->setName(name); insertElements(grid, mAttributes, mInformations, mSets, mMaps, mTime, mDomain, mGridCollections); if (writeToHDF5 && mHeavyDataWriter != NULL) { mHeavyDataWriter->openFile(); grid->accept(mHeavyDataWriter); mHeavyDataWriter->closeFile(); } } void XdmfFortran::addGridCollection(const char * const name, const int gridCollectionType) { const shared_ptr gridCollection = XdmfGridCollection::New(); gridCollection->setName(name); switch(gridCollectionType) { case XDMF_GRID_COLLECTION_TYPE_SPATIAL: gridCollection->setType(XdmfGridCollectionType::Spatial()); break; case XDMF_GRID_COLLECTION_TYPE_TEMPORAL: gridCollection->setType(XdmfGridCollectionType::Temporal()); break; default: try { XdmfError::message(XdmfError::FATAL, "Invalid grid collection type"); } catch (XdmfError & e) { throw e; } } insertElements(gridCollection, mAttributes, mInformations, mSets, mMaps, mTime, mDomain, mGridCollections); mGridCollections.push(gridCollection); } void XdmfFortran::addGridCollectionReference(const char * filePath, const char * xmlPath) { shared_ptr gridCollection = XdmfGridCollection::New(); shared_ptr controller = XdmfGridController::New(std::string(filePath), std::string(xmlPath)); gridCollection->setGridController(controller); if(mGridCollections.empty()) { mDomain->insert(gridCollection); } else { mGridCollections.top()->insert(gridCollection); } } void XdmfFortran::addGridReference(const int gridType, const char * filePath, const char * xmlPath) { shared_ptr controller = XdmfGridController::New(std::string(filePath), std::string(xmlPath)); if (gridType == XDMF_GRID_TYPE_CURVILINEAR) { shared_ptr grid = XdmfCurvilinearGrid::New(0, 0); grid->setGridController(controller); if(mGridCollections.empty()) { mDomain->insert(grid); } else { mGridCollections.top()->insert(grid); } } else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) { shared_ptr placeholderXArray = XdmfArray::New(); shared_ptr placeholderYArray = XdmfArray::New(); shared_ptrgrid = XdmfRectilinearGrid::New(placeholderXArray, placeholderYArray); grid->setGridController(controller); if(mGridCollections.empty()) { mDomain->insert(grid); } else { mGridCollections.top()->insert(grid); } } else if (gridType == XDMF_GRID_TYPE_REGULAR) { shared_ptr grid = XdmfRegularGrid::New(0, 0, 0, 0, 0, 0); grid->setGridController(controller); if(mGridCollections.empty()) { mDomain->insert(grid); } else { mGridCollections.top()->insert(grid); } } else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) { shared_ptr grid = XdmfUnstructuredGrid::New(); grid->setGridController(controller); if(mGridCollections.empty()) { mDomain->insert(grid); } else { mGridCollections.top()->insert(grid); } } } int XdmfFortran::addInformation(const char * const key, const char * const value) { shared_ptr information = XdmfInformation::New(); information->setKey(key); information->setValue(value); mInformations.push_back(information); const int id = mPreviousInformations.size(); mPreviousInformations.push_back(information); return id; } void XdmfFortran::addPreviousAttribute(const int attributeId) { if(attributeId >= (int)mPreviousAttributes.size()) { try { XdmfError::message(XdmfError::FATAL, "Invalid attribute id"); } catch (XdmfError & e) { throw e; } } mAttributes.push_back(mPreviousAttributes[attributeId]); } void XdmfFortran::addPreviousInformation(const int informationId) { if(informationId >= (int)mPreviousInformations.size()) { try { XdmfError::message(XdmfError::FATAL, "Invalid information id"); } catch (XdmfError & e) { throw e; } } mInformations.push_back(mPreviousInformations[informationId]); } void XdmfFortran::closeGridCollection(const bool writeToHDF5) { if(!mGridCollections.empty()) { if (writeToHDF5 && mHeavyDataWriter != NULL) { mHeavyDataWriter->openFile(); mGridCollections.top()->accept(mHeavyDataWriter); mHeavyDataWriter->closeFile(); } mGridCollections.pop(); } } int XdmfFortran::setGeometry(const int geometryType, const unsigned int numValues, const int arrayType, const void * const pointValues) { mGeometry = XdmfGeometry::New(); switch(geometryType) { case XDMF_GEOMETRY_TYPE_XYZ: mGeometry->setType(XdmfGeometryType::XYZ()); break; case XDMF_GEOMETRY_TYPE_XY: mGeometry->setType(XdmfGeometryType::XY()); break; case XDMF_GEOMETRY_TYPE_POLAR: mGeometry->setType(XdmfGeometryType::Polar()); break; case XDMF_GEOMETRY_TYPE_SPHERICAL: mGeometry->setType(XdmfGeometryType::Spherical()); break; default: try { XdmfError::message(XdmfError::FATAL, "Invalid geometry type."); } catch (XdmfError & e) { throw e; } } // insert geometry values into array writeToArray(mGeometry, numValues, arrayType, pointValues); const int id = mPreviousGeometries.size(); mPreviousGeometries.push_back(mGeometry); return id; } void XdmfFortran::clearGeometryHeavyData() { if (mGeometry) { XdmfError::message(XdmfError::FATAL, "Error: Geometry needs to be set before hdf5 linkage can be cleared."); } while (mGeometry->getNumberHeavyDataControllers() > 0) { mGeometry->removeHeavyDataController(0); } } void XdmfFortran::setGeometryHDF5(const char * hdf5File, const char * hdf5Dataset, const unsigned int start, const unsigned int stride, const unsigned int numValues, const unsigned int dataspace) { if (!mGeometry) { XdmfError::message(XdmfError::FATAL, "Error: Geometry needs to be set before hdf5 linkage can be established"); } // create HDF5 link shared_ptr newController = XdmfHDF5Controller::New(std::string(hdf5File), std::string(hdf5Dataset), mGeometry->getArrayType(), std::vector(1, start), std::vector(1, stride), std::vector(1, numValues), std::vector(1, dataspace)); while (mGeometry->getNumberHeavyDataControllers() > 0) { mGeometry->removeHeavyDataController(0); } mGeometry->insert(newController); } void XdmfFortran::setGeometryBinary(const char * binFile, const int endian, const unsigned int seek, const unsigned int start, const unsigned int stride, const unsigned int numValues, const unsigned int dataspace) { if (!mGeometry) { XdmfError::message(XdmfError::FATAL, "Error: Geometry needs to be set before binary linkage can be established"); } XdmfBinaryController::Endian newEndian = XdmfBinaryController::NATIVE; switch (endian) { case XDMF_BINARY_ENDIAN_NATIVE: newEndian = XdmfBinaryController::NATIVE; break; case XDMF_BINARY_ENDIAN_LITTLE: newEndian = XdmfBinaryController::LITTLE; break; case XDMF_BINARY_ENDIAN_BIG: newEndian = XdmfBinaryController::BIG; break; default: break; } // create Binary link shared_ptr newController = XdmfBinaryController::New(std::string(binFile), mGeometry->getArrayType(), newEndian, seek, std::vector(1, start), std::vector(1, stride), std::vector(1, numValues), std::vector(1, dataspace)); while (mGeometry->getNumberHeavyDataControllers() > 0) { mGeometry->removeHeavyDataController(0); } mGeometry->insert(newController); } void XdmfFortran::setPreviousGeometry(const int geometryId) { if(geometryId >= (int)mPreviousGeometries.size()) { try { XdmfError::message(XdmfError::FATAL, "Invalid geometry id"); } catch (XdmfError & e) { throw e; } } mGeometry = mPreviousGeometries[geometryId]; } void XdmfFortran::setPreviousTopology(const int topologyId) { if(topologyId >= (int)mPreviousTopologies.size()) { try { XdmfError::message(XdmfError::FATAL, "Invalid topology id"); } catch (XdmfError & e) { throw e; } } mTopology = mPreviousTopologies[topologyId]; } void XdmfFortran::setTime(const double time) { mTime = XdmfTime::New(); mTime->setValue(time); } int XdmfFortran::setTopology(const int topologyType, const unsigned int numValues, const int arrayType, const void * const connectivityValues, const int numNodes) { mTopology = XdmfTopology::New(); switch(topologyType) { case XDMF_TOPOLOGY_TYPE_POLYVERTEX: mTopology->setType(XdmfTopologyType::Polyvertex()); break; case XDMF_TOPOLOGY_TYPE_POLYLINE: mTopology->setType(XdmfTopologyType::Polyline(numNodes)); break; case XDMF_TOPOLOGY_TYPE_POLYGON: mTopology->setType(XdmfTopologyType::Polygon(numNodes)); break; case XDMF_TOPOLOGY_TYPE_TRIANGLE: mTopology->setType(XdmfTopologyType::Triangle()); break; case XDMF_TOPOLOGY_TYPE_QUADRILATERAL: mTopology->setType(XdmfTopologyType::Quadrilateral()); break; case XDMF_TOPOLOGY_TYPE_TETRAHEDRON: mTopology->setType(XdmfTopologyType::Tetrahedron()); break; case XDMF_TOPOLOGY_TYPE_PYRAMID: mTopology->setType(XdmfTopologyType::Pyramid()); break; case XDMF_TOPOLOGY_TYPE_WEDGE: mTopology->setType(XdmfTopologyType::Wedge()); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON: mTopology->setType(XdmfTopologyType::Hexahedron()); break; case XDMF_TOPOLOGY_TYPE_EDGE_3: mTopology->setType(XdmfTopologyType::Edge_3()); break; case XDMF_TOPOLOGY_TYPE_TRIANGLE_6: mTopology->setType(XdmfTopologyType::Triangle_6()); break; case XDMF_TOPOLOGY_TYPE_QUADRILATERAL_8: mTopology->setType(XdmfTopologyType::Quadrilateral_8()); break; case XDMF_TOPOLOGY_TYPE_QUADRILATERAL_9: mTopology->setType(XdmfTopologyType::Quadrilateral_9()); break; case XDMF_TOPOLOGY_TYPE_TETRAHEDRON_10: mTopology->setType(XdmfTopologyType::Tetrahedron_10()); break; case XDMF_TOPOLOGY_TYPE_PYRAMID_13: mTopology->setType(XdmfTopologyType::Pyramid_13()); break; case XDMF_TOPOLOGY_TYPE_WEDGE_15: mTopology->setType(XdmfTopologyType::Wedge_15()); break; case XDMF_TOPOLOGY_TYPE_WEDGE_18: mTopology->setType(XdmfTopologyType::Wedge_18()); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_20: mTopology->setType(XdmfTopologyType::Hexahedron_20()); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_24: mTopology->setType(XdmfTopologyType::Hexahedron_24()); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_27: mTopology->setType(XdmfTopologyType::Hexahedron_27()); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_64: mTopology->setType(XdmfTopologyType::Hexahedron_64()); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_125: mTopology->setType(XdmfTopologyType::Hexahedron_125()); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_216: mTopology->setType(XdmfTopologyType::Hexahedron_216()); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_343: mTopology->setType(XdmfTopologyType::Hexahedron_343()); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_512: mTopology->setType(XdmfTopologyType::Hexahedron_512()); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_729: mTopology->setType(XdmfTopologyType::Hexahedron_729()); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_1000: mTopology->setType(XdmfTopologyType::Hexahedron_1000()); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_1331: mTopology->setType(XdmfTopologyType::Hexahedron_1331()); break; case XDMF_TOPOLOGY_TYPE_MIXED: mTopology->setType(XdmfTopologyType::Mixed()); break; default: try { XdmfError::message(XdmfError::FATAL, "Invalid topology type."); } catch (XdmfError & e) { throw e; } } // insert connectivity values into array writeToArray(mTopology, numValues, arrayType, connectivityValues); const int id = mPreviousTopologies.size(); mPreviousTopologies.push_back(mTopology); return id; } void XdmfFortran::clearTopologyHeavyData() { if (mTopology) { XdmfError::message(XdmfError::FATAL, "Error: Topology needs to be set before hdf5 linkage can be cleared."); } while (mTopology->getNumberHeavyDataControllers() > 0) { mTopology->removeHeavyDataController(0); } } void XdmfFortran::setTopologyHDF5(const char * hdf5File, const char * hdf5Dataset, const unsigned int start, const unsigned int stride, const unsigned int numValues, const unsigned int dataspace) { if (!mTopology) { XdmfError::message(XdmfError::FATAL, "Error: Topology needs to be set before hdf5 linkage can be established."); } shared_ptr newController = XdmfHDF5Controller::New(std::string(hdf5File), std::string(hdf5Dataset), mTopology->getArrayType(), std::vector(1, start), std::vector(1, stride), std::vector(1, numValues), std::vector(1, dataspace)); while (mTopology->getNumberHeavyDataControllers() > 0) { mTopology->removeHeavyDataController(0); } mTopology->insert(newController); } void XdmfFortran::setTopologyBinary(const char * binFile, const int endian, const unsigned int seek, const unsigned int start, const unsigned int stride, const unsigned int numValues, const unsigned int dataspace) { if (!mTopology) { XdmfError::message(XdmfError::FATAL, "Error: Topology needs to be set before hdf5 linkage can be established."); } XdmfBinaryController::Endian newEndian = XdmfBinaryController::NATIVE; switch (endian) { case XDMF_BINARY_ENDIAN_NATIVE: newEndian = XdmfBinaryController::NATIVE; break; case XDMF_BINARY_ENDIAN_LITTLE: newEndian = XdmfBinaryController::LITTLE; break; case XDMF_BINARY_ENDIAN_BIG: newEndian = XdmfBinaryController::BIG; break; default: break; } shared_ptr newController = XdmfBinaryController::New(std::string(binFile), mTopology->getArrayType(), newEndian, seek, std::vector(1, start), std::vector(1, stride), std::vector(1, numValues), std::vector(1, dataspace)); while (mTopology->getNumberHeavyDataControllers() > 0) { mTopology->removeHeavyDataController(0); } mTopology->insert(newController); } int XdmfFortran::retrieveNumDomainGridCollections() { return mDomain->getNumberGridCollections(); } int XdmfFortran::numGridCollectionGridCollections() { if (!mGridCollections.empty()) { return mGridCollections.top()->getNumberGridCollections(); } else { try { XdmfError::message(XdmfError::FATAL, "Error: No grid collections are open."); } catch (XdmfError & e) { throw e; } return -1; } } void XdmfFortran::retrieveDomainTag(char * returnTag, const int tagLength) { char * tempTag = strdup(mDomain->getItemTag().c_str()); memset(returnTag, 0, tagLength); memcpy(returnTag, tempTag, strlen(tempTag)+1); delete [] tempTag; } int XdmfFortran::retrieveDomainNumProperties() { return mDomain->getItemProperties().size(); } void XdmfFortran::retrieveDomainProperty(const int index, char * key, const int keyLength, char * value, const int valueLength) { if (index < (int)mDomain->getItemProperties().size()) { std::map::iterator walker = mDomain->getItemProperties().begin(); for (int i = 0; igetItemProperties().count(tempString))>0) { char * tempValue = strdup(mDomain->getItemProperties()[tempString].c_str()); memcpy(value, tempValue, strlen(tempValue)+1); delete [] tempValue; } } void XdmfFortran::readDomainGridCollection(const int index) { if ((int)mDomain->getNumberGridCollections() > index) { mDomain->getGridCollection(index)->read(); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::removeDomainGridCollection(const int index) { if ((int)mDomain->getNumberGridCollections() > index) { mDomain->removeGridCollection(index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::openDomainGridCollection(const int index, const int openMaps, const int openAttributes, const int openInformation, const int openSets) { if ((int)mDomain->getNumberGridCollections() > index) { shared_ptr openedGridCollection = mDomain->getGridCollection(index); int i; int n; if (openMaps) { n = openedGridCollection->getNumberMaps(); shared_ptr openedMap; for (i = 0; i < n; i++) { openedMap = openedGridCollection->getMap(i); mMaps.push_back(openedMap); mPreviousMaps.push_back(openedMap); } } if (openAttributes) { n = openedGridCollection->getNumberAttributes(); shared_ptr openedAttribute; for (i = 0; i < n; i++) { openedAttribute = openedGridCollection->getAttribute(i); mAttributes.push_back(openedAttribute); mPreviousAttributes.push_back(openedAttribute); } } if (openInformation) { n = openedGridCollection->getNumberInformations(); shared_ptr openedInformation; for (i = 0; i < n; i++) { openedInformation = openedGridCollection->getInformation(i); mInformations.push_back(openedInformation); mPreviousInformations.push_back(openedInformation); } } if (openSets) { n = openedGridCollection->getNumberSets(); shared_ptr openedSet; for (i = 0; i < n; i++) { openedSet = openedGridCollection->getSet(i); mSets.push_back(openedSet); } mGridCollections.push(openedGridCollection); } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::readGridCollectionGrid(const int gridType, const int index) { if (!mGridCollections.empty()) { if (gridType == XDMF_GRID_TYPE_CURVILINEAR) { if (index < (int)mGridCollections.top()->getNumberCurvilinearGrids()) { mGridCollections.top()->getCurvilinearGrid(index)->read(); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) { if (index < (int)mGridCollections.top()->getNumberRectilinearGrids()) { mGridCollections.top()->getRectilinearGrid(index)->read(); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_REGULAR) { if (index < (int)mGridCollections.top()->getNumberRegularGrids()) { mGridCollections.top()->getRegularGrid(index)->read(); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) { if (index < (int)mGridCollections.top()->getNumberUnstructuredGrids()) { mGridCollections.top()->getUnstructuredGrid(index)->read(); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); } catch (XdmfError & e) { throw e; } } } else { try { XdmfError::message(XdmfError::FATAL, "There is no grid collection currently loaded."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::removeGridCollectionGridCollection(const int index) { if (!mGridCollections.empty()) { if ((int)mGridCollections.top()->getNumberGridCollections() > index) { mGridCollections.top()->removeGridCollection(index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else { try { XdmfError::message(XdmfError::FATAL, "Error: No grid collections are open."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::openGridCollectionGridCollection(const int index, const int openMaps, const int openAttributes, const int openInformation, const int openSets) { if (!mGridCollections.empty()) { if ((int)mGridCollections.top()->getNumberGridCollections() > index) { shared_ptr openedGridCollection = mGridCollections.top()->getGridCollection(index); int i; int n; if (openMaps) { n = openedGridCollection->getNumberMaps(); shared_ptr openedMap; for (i = 0; i < n; i++) { openedMap = openedGridCollection->getMap(i); mMaps.push_back(openedMap); mPreviousMaps.push_back(openedMap); } } if (openAttributes) { n = openedGridCollection->getNumberAttributes(); shared_ptr openedAttribute; for (i = 0; i < n; i++) { openedAttribute = openedGridCollection->getAttribute(i); mAttributes.push_back(openedAttribute); mPreviousAttributes.push_back(openedAttribute); } } if (openInformation) { n = openedGridCollection->getNumberInformations(); shared_ptr openedInformation; for (i = 0; i < n; i++) { openedInformation = openedGridCollection->getInformation(i); mInformations.push_back(openedInformation); mPreviousInformations.push_back(openedInformation); } } if (openSets) { n = openedGridCollection->getNumberSets(); shared_ptr openedSet; for (i = 0; i < n; i++) { openedSet = openedGridCollection->getSet(i); mSets.push_back(openedSet); } mGridCollections.push(openedGridCollection); } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else { try { XdmfError::message(XdmfError::FATAL, "Error: No grid collections are open."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::readGridCollectionGridCollection(const int index) { if (!mGridCollections.empty()) { if ((int)mGridCollections.top()->getNumberGridCollections() > index) { mGridCollections.top()->getGridCollection(index)->read(); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else { try { XdmfError::message(XdmfError::FATAL, "Error: No grid collections are open."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::retrieveGridCollectionTag(char * returnTag, const int tagLength) { if (!mGridCollections.empty()) { char * tempTag = strdup(mGridCollections.top()->getItemTag().c_str()); memset(returnTag, 0, tagLength); memcpy(returnTag, tempTag, strlen(tempTag)+1); delete [] tempTag; } else { try { XdmfError::message(XdmfError::FATAL, "Error: No grid collections are open."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::retrieveGridCollectionName(char * returnName, const int nameLength) { if (!mGridCollections.empty()) { char * tempName = strdup(mGridCollections.top()->getName().c_str()); memset(returnName, 0, nameLength); memcpy(returnName, tempName, strlen(tempName)+1); delete [] tempName; } else { try { XdmfError::message(XdmfError::FATAL, "Error: No grid collections are open."); } catch (XdmfError & e) { throw e; } } } int XdmfFortran::retrieveGridCollectionNumProperties() { if (!mGridCollections.empty()) { return mGridCollections.top()->getItemProperties().size(); } else { try { XdmfError::message(XdmfError::FATAL, "Error: No grid collections are open."); } catch (XdmfError & e) { throw e; } return -1; } } void XdmfFortran::retrieveGridCollectionProperty(const int index, char * key, const int keyLength, char * value, const int valueLength) { if (!mGridCollections.empty()) { if (index < (int)mGridCollections.top()->getItemProperties().size()) { std::map::iterator walker = mGridCollections.top()->getItemProperties().begin(); for (int i = 0; igetItemProperties().count(tempString))>0) { char * tempValue = strdup(mGridCollections.top()->getItemProperties()[tempString].c_str()); memcpy(value, tempValue, strlen(tempValue)+1); delete [] tempValue; } } else { try { XdmfError::message(XdmfError::FATAL, "Error: No grid collections are open."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::openDomainGrid(const int gridType, const int index, const int openMaps, const int openAttributes, const int openInformation, const int openSets) { if (gridType == XDMF_GRID_TYPE_CURVILINEAR) { if (index < (int)mDomain->getNumberCurvilinearGrids()) { shared_ptr openedGrid = mDomain->getCurvilinearGrid(index); shared_ptr dataType; mGeometry = openedGrid->getGeometry(); mDimensions = openedGrid->getDimensions(); mTime = openedGrid->getTime(); int i; int n; if (openAttributes) { n = openedGrid->getNumberAttributes(); shared_ptr openedAttribute; for (i = 0; i < n; i++) { openedAttribute = openedGrid->getAttribute(i); mAttributes.push_back(openedAttribute); mPreviousAttributes.push_back(openedAttribute); } } if (openMaps) { n = openedGrid->getNumberMaps(); shared_ptr openedMap; for (i = 0; i < n; i++) { openedMap = openedGrid->getMap(i); mMaps.push_back(openedMap); mPreviousMaps.push_back(openedMap); } } if (openInformation) { n = openedGrid->getNumberInformations(); shared_ptr openedInformation; for (i = 0; i < n; i++) { openedInformation = openedGrid->getInformation(i); mInformations.push_back(openedInformation); mPreviousInformations.push_back(openedInformation); } } if (openSets) { n = openedGrid->getNumberSets(); shared_ptr openedSet; for (i = 0; i < n; i++) { openedSet = openedGrid->getSet(i); mSets.push_back(openedSet); } } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) { if (index < (int)mDomain->getNumberRectilinearGrids()) { shared_ptr openedGrid = mDomain->getRectilinearGrid(index); shared_ptr dataType; mCoordinates = openedGrid->getCoordinates(); mTime = openedGrid->getTime(); int i; int n; if (openAttributes) { n = openedGrid->getNumberAttributes(); shared_ptr openedAttribute; for (i = 0; i < n; i++) { openedAttribute = openedGrid->getAttribute(i); mAttributes.push_back(openedAttribute); mPreviousAttributes.push_back(openedAttribute); } } if (openMaps) { n = openedGrid->getNumberMaps(); shared_ptr openedMap; for (i = 0; i < n; i++) { openedMap = openedGrid->getMap(i); mMaps.push_back(openedMap); mPreviousMaps.push_back(openedMap); } } if (openInformation) { n = openedGrid->getNumberInformations(); shared_ptr openedInformation; for (i = 0; i < n; i++) { openedInformation = openedGrid->getInformation(i); mInformations.push_back(openedInformation); mPreviousInformations.push_back(openedInformation); } } if (openSets) { n = openedGrid->getNumberSets(); shared_ptr openedSet; for (i = 0; i < n; i++) { openedSet = openedGrid->getSet(i); mSets.push_back(openedSet); } } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_REGULAR) { if (index < (int)mDomain->getNumberRegularGrids()) { shared_ptr openedGrid = mDomain->getRegularGrid(index); shared_ptr dataType; mTime = openedGrid->getTime(); mBrick = openedGrid->getBrickSize(); mOrigin = openedGrid->getOrigin(); mDimensions = openedGrid->getDimensions(); int i; int n; if (openAttributes) { n = openedGrid->getNumberAttributes(); shared_ptr openedAttribute; for (i = 0; i < n; i++) { openedAttribute = openedGrid->getAttribute(i); mAttributes.push_back(openedAttribute); mPreviousAttributes.push_back(openedAttribute); } } if (openMaps) { n = openedGrid->getNumberMaps(); shared_ptr openedMap; for (i = 0; i < n; i++) { openedMap = openedGrid->getMap(i); mMaps.push_back(openedMap); mPreviousMaps.push_back(openedMap); } } if (openInformation) { n = openedGrid->getNumberInformations(); shared_ptr openedInformation; for (i = 0; i < n; i++) { openedInformation = openedGrid->getInformation(i); mInformations.push_back(openedInformation); mPreviousInformations.push_back(openedInformation); } } if (openSets) { n = openedGrid->getNumberSets(); shared_ptr openedSet; for (i = 0; i < n; i++) { openedSet = openedGrid->getSet(i); mSets.push_back(openedSet); } } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) { if (index < (int)mDomain->getNumberUnstructuredGrids()) { shared_ptr openedGrid = mDomain->getUnstructuredGrid(index); mTopology = openedGrid->getTopology(); mGeometry = openedGrid->getGeometry(); mTime = openedGrid->getTime(); int i; int n; if (openAttributes) { n = openedGrid->getNumberAttributes(); shared_ptr openedAttribute; for (i = 0; i < n; i++) { openedAttribute = openedGrid->getAttribute(i); mAttributes.push_back(openedAttribute); mPreviousAttributes.push_back(openedAttribute); } } if (openMaps) { n = openedGrid->getNumberMaps(); shared_ptr openedMap; for (i = 0; i < n; i++) { openedMap = openedGrid->getMap(i); mMaps.push_back(openedMap); mPreviousMaps.push_back(openedMap); } } if (openInformation) { n = openedGrid->getNumberInformations(); shared_ptr openedInformation; for (i = 0; i < n; i++) { openedInformation = openedGrid->getInformation(i); mInformations.push_back(openedInformation); mPreviousInformations.push_back(openedInformation); } } if (openSets) { n = openedGrid->getNumberSets(); shared_ptr openedSet; for (i = 0; i < n; i++) { openedSet = openedGrid->getSet(i); mSets.push_back(openedSet); } } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::readDomainGrid(const int gridType, const int index) { if (gridType == XDMF_GRID_TYPE_CURVILINEAR) { if (index < (int)mDomain->getNumberCurvilinearGrids()) { mDomain->getCurvilinearGrid(index)->read(); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) { if (index < (int)mDomain->getNumberRectilinearGrids()) { mDomain->getRectilinearGrid(index)->read(); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_REGULAR) { if (index < (int)mDomain->getNumberRegularGrids()) { mDomain->getRegularGrid(index)->read(); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) { if (index < (int)mDomain->getNumberUnstructuredGrids()) { mDomain->getUnstructuredGrid(index)->read(); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::removeDomainGrid(const int gridType, const int index) { if (gridType == XDMF_GRID_TYPE_CURVILINEAR) { if (index < (int)mDomain->getNumberCurvilinearGrids()) { mDomain->removeCurvilinearGrid(index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) { if (index < (int)mDomain->getNumberRectilinearGrids()) { mDomain->removeRectilinearGrid(index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_REGULAR) { if (index < (int)mDomain->getNumberRegularGrids()) { mDomain->removeRegularGrid(index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) { if (index < (int)mDomain->getNumberUnstructuredGrids()) { mDomain->removeUnstructuredGrid(index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::replaceDomainGrid(const int gridType, const int index, char * name) { int i; if (gridType == XDMF_GRID_TYPE_CURVILINEAR) { if (index < (int)mDomain->getNumberCurvilinearGrids()) { if(mDimensions == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set dimensions before replacing grid."); } catch (XdmfError & e) { throw e; } } if(mGeometry == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set geometry before adding grid."); } catch (XdmfError & e) { throw e; } } shared_ptr grid = mDomain->getCurvilinearGrid(index); grid->setName(name); grid->setGeometry(mGeometry); grid->setDimensions(mDimensions); for (i=grid->getNumberAttributes()-1;i>=0;i--) { grid->removeAttribute(0); } for(std::vector >::const_iterator iter = mAttributes.begin(); iter != mAttributes.end(); ++iter) { grid->insert(*iter); } mAttributes.clear(); for( i=grid->getNumberInformations()-1;i>=0;i--) { grid->removeInformation(0); } for(std::vector >::const_iterator iter = mInformations.begin(); iter != mInformations.end(); ++iter) { grid->insert(*iter); } mInformations.clear(); for (i=grid->getNumberSets()-1;i>=0;i--) { grid->removeSet(0); } for(std::vector >::const_iterator iter = mSets.begin(); iter != mSets.end(); ++iter) { grid->insert(*iter); } mSets.clear(); for (i=grid->getNumberMaps()-1;i>=0;i--) { grid->removeMap(0); } for(std::vector >::const_iterator iter = mMaps.begin(); iter != mMaps.end(); ++iter) { grid->insert(*iter); } mMaps.clear(); if(mTime) { grid->setTime(mTime); } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) { if (index < (int)mDomain->getNumberRectilinearGrids()) { if(mCoordinates.empty()) { try { XdmfError::message(XdmfError::FATAL, "Must set Coordinates before adding grid."); } catch (XdmfError & e) { throw e; } } shared_ptr grid = mDomain->getRectilinearGrid(index); grid->setCoordinates(mCoordinates); mCoordinates.clear(); for (i=grid->getNumberAttributes()-1;i>=0;i--) { grid->removeAttribute(0); } for(std::vector >::const_iterator iter = mAttributes.begin(); iter != mAttributes.end(); ++iter) { grid->insert(*iter); } mAttributes.clear(); for (i=grid->getNumberInformations()-1;i>=0;i--) { grid->removeInformation(0); } for(std::vector >::const_iterator iter = mInformations.begin(); iter != mInformations.end(); ++iter) { grid->insert(*iter); } mInformations.clear(); for (i=grid->getNumberSets()-1;i>=0;i--) { grid->removeSet(0); } for(std::vector >::const_iterator iter = mSets.begin(); iter != mSets.end(); ++iter) { grid->insert(*iter); } mSets.clear(); for (i=grid->getNumberMaps()-1;i>=0;i--) { grid->removeMap(0); } for(std::vector >::const_iterator iter = mMaps.begin(); iter != mMaps.end(); ++iter) { grid->insert(*iter); } mMaps.clear(); if(mTime) { grid->setTime(mTime); } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_REGULAR) { if (index < (int)mDomain->getNumberRegularGrids()) { if(mBrick == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set brick size before adding grid."); } catch (XdmfError & e) { throw e; } } if(mDimensions == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set dimensions before adding grid."); } catch (XdmfError & e) { throw e; } } if(mOrigin == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set origin before adding grid."); } catch (XdmfError & e) { throw e; } } shared_ptr grid = mDomain->getRegularGrid(index); grid->setOrigin(mOrigin); grid->setDimensions(mDimensions); grid->setBrickSize(mBrick); for (i=grid->getNumberAttributes()-1;i>=0;i--) { grid->removeAttribute(0); } for(std::vector >::const_iterator iter = mAttributes.begin(); iter != mAttributes.end(); ++iter) { grid->insert(*iter); } mAttributes.clear(); for (i=grid->getNumberInformations()-1;i>=0;i--) { grid->removeInformation(0); } for(std::vector >::const_iterator iter = mInformations.begin(); iter != mInformations.end(); ++iter) { grid->insert(*iter); } mInformations.clear(); for (i=grid->getNumberSets()-1;i>=0;i--) { grid->removeSet(0); } for(std::vector >::const_iterator iter = mSets.begin(); iter != mSets.end(); ++iter) { grid->insert(*iter); } mSets.clear(); for (i=grid->getNumberMaps()-1;i>=0;i--) { grid->removeMap(0); } for(std::vector >::const_iterator iter = mMaps.begin(); iter != mMaps.end(); ++iter) { grid->insert(*iter); } mMaps.clear(); if(mTime) { grid->setTime(mTime); } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) { if (index < (int)mDomain->getNumberUnstructuredGrids()) { if(mGeometry == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set geometry before adding grid."); } catch (XdmfError & e) { throw e; } } if(mTopology == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set topology before adding grid."); } catch (XdmfError & e) { throw e; } } shared_ptr grid = mDomain->getUnstructuredGrid(index); grid->setName(name); grid->setGeometry(mGeometry); grid->setTopology(mTopology); for (i=grid->getNumberAttributes()-1;i>=0;i--) { grid->removeAttribute(0); } for(std::vector >::const_iterator iter = mAttributes.begin(); iter != mAttributes.end(); ++iter) { grid->insert(*iter); } mAttributes.clear(); for (i=grid->getNumberInformations()-1;i>=0;i--) { grid->removeInformation(0); } for(std::vector >::const_iterator iter = mInformations.begin(); iter != mInformations.end(); ++iter) { grid->insert(*iter); } mInformations.clear(); for (i=grid->getNumberSets()-1;i>=0;i--) { grid->removeSet(0); } for(std::vector >::const_iterator iter = mSets.begin(); iter != mSets.end(); ++iter) { grid->insert(*iter); } mSets.clear(); for (i=grid->getNumberMaps()-1;i>=0;i--) { grid->removeMap(0); } for(std::vector >::const_iterator iter = mMaps.begin(); iter != mMaps.end(); ++iter) { grid->insert(*iter); } mMaps.clear(); if(mTime) { grid->setTime(mTime); } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } } void XdmfFortran::retrieveDomainGridName(const int gridType, const int index, char * returnName, const int nameLength) { shared_ptr openedGrid; if (gridType == XDMF_GRID_TYPE_CURVILINEAR) { if (index < (int)mDomain->getNumberCurvilinearGrids()) { openedGrid = mDomain->getCurvilinearGrid(index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) { if (index < (int)mDomain->getNumberRectilinearGrids()) { openedGrid = mDomain->getRectilinearGrid(index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_REGULAR) { if (index < (int)mDomain->getNumberRegularGrids()) { openedGrid = mDomain->getRegularGrid(index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) { if (index < (int)mDomain->getNumberUnstructuredGrids()) { openedGrid = mDomain->getUnstructuredGrid(index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); } catch (XdmfError & e) { throw e; } } char * tempName = strdup(openedGrid->getName().c_str()); memset(returnName, 0, nameLength); memcpy(returnName, tempName, strlen(tempName)+1); delete [] tempName; } void XdmfFortran::retrieveDomainGridTag(const int gridType, const int index, char * returnTag, const int tagLength) { shared_ptr openedGrid; if (gridType == XDMF_GRID_TYPE_CURVILINEAR) { if (index < (int)mDomain->getNumberCurvilinearGrids()) { openedGrid = mDomain->getCurvilinearGrid(index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) { if (index < (int)mDomain->getNumberRectilinearGrids()) { openedGrid = mDomain->getRectilinearGrid(index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_REGULAR) { if (index < (int)mDomain->getNumberRegularGrids()) { openedGrid = mDomain->getRegularGrid(index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) { if (index < (int)mDomain->getNumberUnstructuredGrids()) { openedGrid = mDomain->getUnstructuredGrid(index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); } catch (XdmfError & e) { throw e; } } char * tempTag = strdup(openedGrid->getItemTag().c_str()); memset(returnTag, 0, tagLength); memcpy(returnTag, tempTag, strlen(tempTag)+1); delete [] tempTag; } int XdmfFortran::retrieveDomainGridNumProperties(const int gridType, const int index) { if (gridType == XDMF_GRID_TYPE_CURVILINEAR) { if (index < (int)mDomain->getNumberCurvilinearGrids()) { return mDomain->getCurvilinearGrid(index)->getItemProperties().size(); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } return -1; } } else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) { if (index < (int)mDomain->getNumberRectilinearGrids()) { return mDomain->getRectilinearGrid(index)->getItemProperties().size(); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } return -1; } } else if (gridType == XDMF_GRID_TYPE_REGULAR) { if (index < (int)mDomain->getNumberRegularGrids()) { return mDomain->getRegularGrid(index)->getItemProperties().size(); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } return -1; } } else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) { if (index < (int)mDomain->getNumberUnstructuredGrids()) { return mDomain->getUnstructuredGrid(index)->getItemProperties().size(); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } return -1; } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); } catch (XdmfError & e) { throw e; } return -1; } } void XdmfFortran::retrieveDomainGridProperty(const int gridType, const int gridIndex, const int index, char * key, const int keyLength, char * value, const int valueLength) { shared_ptr openedGrid; if (gridType == XDMF_GRID_TYPE_CURVILINEAR) { if (index < (int)mDomain->getNumberCurvilinearGrids()) { openedGrid = mDomain->getCurvilinearGrid(index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) { if (index < (int)mDomain->getNumberRectilinearGrids()) { openedGrid = mDomain->getRectilinearGrid(index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_REGULAR) { if (index < (int)mDomain->getNumberRegularGrids()) { openedGrid = mDomain->getRegularGrid(index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) { if (index < (int)mDomain->getNumberUnstructuredGrids()) { openedGrid = mDomain->getUnstructuredGrid(index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); } catch (XdmfError & e) { throw e; } } if (index < (int)openedGrid->getItemProperties().size()) { std::map::iterator walker = openedGrid->getItemProperties().begin(); for (int i = 0; i openedGrid; if (gridType == XDMF_GRID_TYPE_CURVILINEAR) { if (index < (int)mDomain->getNumberCurvilinearGrids()) { openedGrid = mDomain->getCurvilinearGrid(index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) { if (index < (int)mDomain->getNumberRectilinearGrids()) { openedGrid = mDomain->getRectilinearGrid(index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_REGULAR) { if (index < (int)mDomain->getNumberRegularGrids()) { openedGrid = mDomain->getRegularGrid(index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) { if (index < (int)mDomain->getNumberUnstructuredGrids()) { openedGrid = mDomain->getUnstructuredGrid(index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); } catch (XdmfError & e) { throw e; } } std::string tempString = key; memset(value, 0, valueLength); if ((openedGrid->getItemProperties().count(tempString))>0) { char * tempValue = strdup(openedGrid->getItemProperties()[tempString].c_str()); memcpy(value, tempValue, strlen(tempValue)+1); delete [] tempValue; } } void XdmfFortran::openGridCollectionGrid(const int gridType, const int index, const int openMaps, const int openAttributes, const int openInformation, const int openSets) { if (!mGridCollections.empty()) { if (gridType == XDMF_GRID_TYPE_CURVILINEAR) { if (index < (int)mGridCollections.top()->getNumberCurvilinearGrids()) { shared_ptr openedGrid = mGridCollections.top()->getCurvilinearGrid(index); shared_ptr dataType; mGeometry = openedGrid->getGeometry(); mDimensions = openedGrid->getDimensions(); mTime = openedGrid->getTime(); int i; int n; if (openAttributes) { n = openedGrid->getNumberAttributes(); shared_ptr openedAttribute; for (i = 0; i < n; i++) { openedAttribute = openedGrid->getAttribute(i); mAttributes.push_back(openedAttribute); mPreviousAttributes.push_back(openedAttribute); } } if (openMaps) { n = openedGrid->getNumberMaps(); shared_ptr openedMap; for (i = 0; i < n; i++) { openedMap = openedGrid->getMap(i); mMaps.push_back(openedMap); mPreviousMaps.push_back(openedMap); } } if (openInformation) { n = openedGrid->getNumberInformations(); shared_ptr openedInformation; for (i = 0; i < n; i++) { openedInformation = openedGrid->getInformation(i); mInformations.push_back(openedInformation); mPreviousInformations.push_back(openedInformation); } } if (openSets) { n = openedGrid->getNumberSets(); shared_ptr openedSet; for (i = 0; i < n; i++) { openedSet = openedGrid->getSet(i); mSets.push_back(openedSet); } } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) { if (index < (int)mGridCollections.top()->getNumberRectilinearGrids()) { shared_ptr openedGrid = mGridCollections.top()->getRectilinearGrid(index); shared_ptr dataType; mCoordinates = openedGrid->getCoordinates(); mTime = openedGrid->getTime(); int i; int n; if (openAttributes) { n = openedGrid->getNumberAttributes(); shared_ptr openedAttribute; for (i = 0; i < n; i++) { openedAttribute = openedGrid->getAttribute(i); mAttributes.push_back(openedAttribute); mPreviousAttributes.push_back(openedAttribute); } } if (openMaps) { n = openedGrid->getNumberMaps(); shared_ptr openedMap; for (i = 0; i < n; i++) { openedMap = openedGrid->getMap(i); mMaps.push_back(openedMap); mPreviousMaps.push_back(openedMap); } } if (openInformation) { n = openedGrid->getNumberInformations(); shared_ptr openedInformation; for (i = 0; i < n; i++) { openedInformation = openedGrid->getInformation(i); mInformations.push_back(openedInformation); mPreviousInformations.push_back(openedInformation); } } if (openSets) { n = openedGrid->getNumberSets(); shared_ptr openedSet; for (i = 0; i < n; i++) { openedSet = openedGrid->getSet(i); mSets.push_back(openedSet); } } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_REGULAR) { if (index < (int)mGridCollections.top()->getNumberRegularGrids()) { shared_ptr openedGrid = mGridCollections.top()->getRegularGrid(index); shared_ptr dataType; mTime = openedGrid->getTime(); mBrick = openedGrid->getBrickSize(); mOrigin = openedGrid->getOrigin(); mDimensions = openedGrid->getDimensions(); int i; int n; if (openAttributes) { n = openedGrid->getNumberAttributes(); shared_ptr openedAttribute; for (i = 0; i < n; i++) { openedAttribute = openedGrid->getAttribute(i); mAttributes.push_back(openedAttribute); mPreviousAttributes.push_back(openedAttribute); } } if (openMaps) { n = openedGrid->getNumberMaps(); shared_ptr openedMap; for (i = 0; i < n; i++) { openedMap = openedGrid->getMap(i); mMaps.push_back(openedMap); mPreviousMaps.push_back(openedMap); } } if (openInformation) { n = openedGrid->getNumberInformations(); shared_ptr openedInformation; for (i = 0; i < n; i++) { openedInformation = openedGrid->getInformation(i); mInformations.push_back(openedInformation); mPreviousInformations.push_back(openedInformation); } } if (openSets) { n = openedGrid->getNumberSets(); shared_ptr openedSet; for (i = 0; i < n; i++) { openedSet = openedGrid->getSet(i); mSets.push_back(openedSet); } } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) { if (index < (int)mGridCollections.top()->getNumberUnstructuredGrids()) { shared_ptr openedGrid = mGridCollections.top()->getUnstructuredGrid(index); mTopology = openedGrid->getTopology(); mGeometry = openedGrid->getGeometry(); mTime = openedGrid->getTime(); int i; int n; if (openAttributes) { n = openedGrid->getNumberAttributes(); shared_ptr openedAttribute; for (i = 0; i < n; i++) { openedAttribute = openedGrid->getAttribute(i); mAttributes.push_back(openedAttribute); mPreviousAttributes.push_back(openedAttribute); } } if (openMaps) { n = openedGrid->getNumberMaps(); shared_ptr openedMap; for (i = 0; i < n; i++) { openedMap = openedGrid->getMap(i); mMaps.push_back(openedMap); mPreviousMaps.push_back(openedMap); } } if (openInformation) { n = openedGrid->getNumberInformations(); shared_ptr openedInformation; for (i = 0; i < n; i++) { openedInformation = openedGrid->getInformation(i); mInformations.push_back(openedInformation); mPreviousInformations.push_back(openedInformation); } } if (openSets) { n = openedGrid->getNumberSets(); shared_ptr openedSet; for (i = 0; i < n; i++) { openedSet = openedGrid->getSet(i); mSets.push_back(openedSet); } } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); } catch (XdmfError & e) { throw e; } } } else { try { XdmfError::message(XdmfError::FATAL, "There is no grid collection currently loaded."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::removeGridCollectionGrid(const int gridType, const int index) { if (!mGridCollections.empty()) { if (gridType == XDMF_GRID_TYPE_CURVILINEAR) { if (index < (int)mGridCollections.top()->getNumberCurvilinearGrids()) { mGridCollections.top()->removeCurvilinearGrid(index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) { if (index < (int)mGridCollections.top()->getNumberRectilinearGrids()) { mGridCollections.top()->removeRectilinearGrid(index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_REGULAR) { if (index < (int)mGridCollections.top()->getNumberRegularGrids()) { mGridCollections.top()->removeRegularGrid(index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) { if (index < (int)mGridCollections.top()->getNumberUnstructuredGrids()) { mGridCollections.top()->removeUnstructuredGrid(index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } } else { try { XdmfError::message(XdmfError::FATAL, "There is no grid collection currently loaded."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::replaceGridCollectionGrid(const int gridType, const int index, char * name) { if (!mGridCollections.empty()) { int i; if (gridType == XDMF_GRID_TYPE_CURVILINEAR) { if (index < (int)mGridCollections.top()->getNumberCurvilinearGrids()) { if(mDimensions == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set dimensions before replacing grid."); } catch (XdmfError & e) { throw e; } } if(mGeometry == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set geometry before adding grid."); } catch (XdmfError & e) { throw e; } } shared_ptr grid = mGridCollections.top()->getCurvilinearGrid(index); grid->setName(name); grid->setGeometry(mGeometry); grid->setDimensions(mDimensions); for (i=grid->getNumberAttributes()-1;i>=0;i--) { grid->removeAttribute(0); } for(std::vector >::const_iterator iter = mAttributes.begin(); iter != mAttributes.end(); ++iter) { grid->insert(*iter); } mAttributes.clear(); for( i=grid->getNumberInformations()-1;i>=0;i--) { grid->removeInformation(0); } for(std::vector >::const_iterator iter = mInformations.begin(); iter != mInformations.end(); ++iter) { grid->insert(*iter); } mInformations.clear(); for (i=grid->getNumberSets()-1;i>=0;i--) { grid->removeSet(0); } for(std::vector >::const_iterator iter = mSets.begin(); iter != mSets.end(); ++iter) { grid->insert(*iter); } mSets.clear(); for (i=grid->getNumberMaps()-1;i>=0;i--) { grid->removeMap(0); } for(std::vector >::const_iterator iter = mMaps.begin(); iter != mMaps.end(); ++iter) { grid->insert(*iter); } mMaps.clear(); if(mTime) { grid->setTime(mTime); } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) { if (index < (int)mGridCollections.top()->getNumberRectilinearGrids()) { if(mCoordinates.empty()) { try { XdmfError::message(XdmfError::FATAL, "Must set Coordinates before adding grid."); } catch (XdmfError & e) { throw e; } } shared_ptr grid = mGridCollections.top()->getRectilinearGrid(index); grid->setCoordinates(mCoordinates); mCoordinates.clear(); for (i=grid->getNumberAttributes()-1;i>=0;i--) { grid->removeAttribute(0); } for(std::vector >::const_iterator iter = mAttributes.begin(); iter != mAttributes.end(); ++iter) { grid->insert(*iter); } mAttributes.clear(); for (i=grid->getNumberInformations()-1;i>=0;i--) { grid->removeInformation(0); } for(std::vector >::const_iterator iter = mInformations.begin(); iter != mInformations.end(); ++iter) { grid->insert(*iter); } mInformations.clear(); for (i=grid->getNumberSets()-1;i>=0;i--) { grid->removeSet(0); } for(std::vector >::const_iterator iter = mSets.begin(); iter != mSets.end(); ++iter) { grid->insert(*iter); } mSets.clear(); for (i=grid->getNumberMaps()-1;i>=0;i--) { grid->removeMap(0); } for(std::vector >::const_iterator iter = mMaps.begin(); iter != mMaps.end(); ++iter) { grid->insert(*iter); } mMaps.clear(); if(mTime) { grid->setTime(mTime); } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_REGULAR) { if (index < (int)mGridCollections.top()->getNumberRegularGrids()) { if(mBrick == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set brick size before adding grid."); } catch (XdmfError & e) { throw e; } } if(mDimensions == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set dimensions before adding grid."); } catch (XdmfError & e) { throw e; } } if(mOrigin == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set origin before adding grid."); } catch (XdmfError & e) { throw e; } } shared_ptr grid = mGridCollections.top()->getRegularGrid(index); grid->setOrigin(mOrigin); grid->setDimensions(mDimensions); grid->setBrickSize(mBrick); for (i=grid->getNumberAttributes()-1;i>=0;i--) { grid->removeAttribute(0); } for(std::vector >::const_iterator iter = mAttributes.begin(); iter != mAttributes.end(); ++iter) { grid->insert(*iter); } mAttributes.clear(); for (i=grid->getNumberInformations()-1;i>=0;i--) { grid->removeInformation(0); } for(std::vector >::const_iterator iter = mInformations.begin(); iter != mInformations.end(); ++iter) { grid->insert(*iter); } mInformations.clear(); for (i=grid->getNumberSets()-1;i>=0;i--) { grid->removeSet(0); } for(std::vector >::const_iterator iter = mSets.begin(); iter != mSets.end(); ++iter) { grid->insert(*iter); } mSets.clear(); for (i=grid->getNumberMaps()-1;i>=0;i--) { grid->removeMap(0); } for(std::vector >::const_iterator iter = mMaps.begin(); iter != mMaps.end(); ++iter) { grid->insert(*iter); } mMaps.clear(); if(mTime) { grid->setTime(mTime); } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) { if (index < (int)mGridCollections.top()->getNumberUnstructuredGrids()) { if(mGeometry == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set geometry before adding grid."); } catch (XdmfError & e) { throw e; } } if(mTopology == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set topology before adding grid."); } catch (XdmfError & e) { throw e; } } shared_ptr grid = mGridCollections.top()->getUnstructuredGrid(index); grid->setName(name); grid->setGeometry(mGeometry); grid->setTopology(mTopology); for (i=grid->getNumberAttributes()-1;i>=0;i--) { grid->removeAttribute(0); } for(std::vector >::const_iterator iter = mAttributes.begin(); iter != mAttributes.end(); ++iter) { grid->insert(*iter); } mAttributes.clear(); for (i=grid->getNumberInformations()-1;i>=0;i--) { grid->removeInformation(0); } for(std::vector >::const_iterator iter = mInformations.begin(); iter != mInformations.end(); ++iter) { grid->insert(*iter); } mInformations.clear(); for (i=grid->getNumberSets()-1;i>=0;i--) { grid->removeSet(0); } for(std::vector >::const_iterator iter = mSets.begin(); iter != mSets.end(); ++iter) { grid->insert(*iter); } mSets.clear(); for (i=grid->getNumberMaps()-1;i>=0;i--) { grid->removeMap(0); } for(std::vector >::const_iterator iter = mMaps.begin(); iter != mMaps.end(); ++iter) { grid->insert(*iter); } mMaps.clear(); if(mTime) { grid->setTime(mTime); } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } } else { try { XdmfError::message(XdmfError::FATAL, "There is no grid collection currently loaded."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::retrieveGridCollectionGridName(const int gridType, const int index, char * returnName, const int nameLength) { if (!mGridCollections.empty()) { shared_ptr openedGrid; if (gridType == XDMF_GRID_TYPE_CURVILINEAR) { if (index < (int)mGridCollections.top()->getNumberCurvilinearGrids()) { openedGrid = mGridCollections.top()->getCurvilinearGrid(index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) { if (index < (int)mGridCollections.top()->getNumberRectilinearGrids()) { openedGrid = mGridCollections.top()->getRectilinearGrid(index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_REGULAR) { if (index < (int)mGridCollections.top()->getNumberRegularGrids()) { openedGrid = mGridCollections.top()->getRegularGrid(index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) { if (index < (int)mGridCollections.top()->getNumberUnstructuredGrids()) { openedGrid = mGridCollections.top()->getUnstructuredGrid(index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); } catch (XdmfError & e) { throw e; } } char * tempName = strdup(openedGrid->getName().c_str()); memset(returnName, 0, nameLength); memcpy(returnName, tempName, strlen(tempName)+1); delete [] tempName; } else { try { XdmfError::message(XdmfError::FATAL, "There is no grid collection currently loaded."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::retrieveGridCollectionGridTag(const int gridType, const int index, char * returnTag, const int tagLength) { if (!mGridCollections.empty()) { shared_ptr openedGrid; if (gridType == XDMF_GRID_TYPE_CURVILINEAR) { if (index < (int)mGridCollections.top()->getNumberCurvilinearGrids()) { openedGrid = mGridCollections.top()->getCurvilinearGrid(index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) { if (index < (int)mGridCollections.top()->getNumberRectilinearGrids()) { openedGrid = mGridCollections.top()->getRectilinearGrid(index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_REGULAR) { if (index < (int)mGridCollections.top()->getNumberRegularGrids()) { openedGrid = mGridCollections.top()->getRegularGrid(index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) { if (index < (int)mGridCollections.top()->getNumberUnstructuredGrids()) { openedGrid = mGridCollections.top()->getUnstructuredGrid(index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); } catch (XdmfError & e) { throw e; } } char * tempTag = strdup(openedGrid->getItemTag().c_str()); memset(returnTag, 0, tagLength); memcpy(returnTag, tempTag, strlen(tempTag)+1); delete [] tempTag; } else { try { XdmfError::message(XdmfError::FATAL, "There is no grid collection currently loaded."); } catch (XdmfError & e) { throw e; } } } int XdmfFortran::retrieveGridCollectionGridNumProperties(const int gridType, const int index) { if (!mGridCollections.empty()) { if (gridType == XDMF_GRID_TYPE_CURVILINEAR) { if (index < (int)mGridCollections.top()->getNumberCurvilinearGrids()) { return mGridCollections.top()->getCurvilinearGrid(index)->getItemProperties().size(); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } return -1; } } else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) { if (index < (int)mGridCollections.top()->getNumberRectilinearGrids()) { return mGridCollections.top()->getRectilinearGrid(index)->getItemProperties().size(); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } return -1; } } else if (gridType == XDMF_GRID_TYPE_REGULAR) { if (index < (int)mGridCollections.top()->getNumberRegularGrids()) { return mGridCollections.top()->getRegularGrid(index)->getItemProperties().size(); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } return -1; } } else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) { if (index < (int)mGridCollections.top()->getNumberUnstructuredGrids()) { return mGridCollections.top()->getUnstructuredGrid(index)->getItemProperties().size(); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } return -1; } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); } catch (XdmfError & e) { throw e; } return -1; } } else { try { XdmfError::message(XdmfError::FATAL, "There is no grid collection currently loaded."); } catch (XdmfError & e) { throw e; } return -1; } } void XdmfFortran::retrieveGridCollectionGridProperty(const int gridType, const int gridIndex, const int index, char * key, const int keyLength, char * value, const int valueLength) { if (!mGridCollections.empty()) { shared_ptr openedGrid; if (gridType == XDMF_GRID_TYPE_CURVILINEAR) { if (index < (int)mGridCollections.top()->getNumberCurvilinearGrids()) { openedGrid = mGridCollections.top()->getCurvilinearGrid(index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) { if (index < (int)mGridCollections.top()->getNumberRectilinearGrids()) { openedGrid = mGridCollections.top()->getRectilinearGrid(index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_REGULAR) { if (index < (int)mGridCollections.top()->getNumberRegularGrids()) { openedGrid = mGridCollections.top()->getRegularGrid(index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) { if (index < (int)mGridCollections.top()->getNumberUnstructuredGrids()) { openedGrid = mGridCollections.top()->getUnstructuredGrid(index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); } catch (XdmfError & e) { throw e; } } if (index < (int)openedGrid->getItemProperties().size()) { std::map::iterator walker = openedGrid->getItemProperties().begin(); for (int i = 0; i openedGrid; if (gridType == XDMF_GRID_TYPE_CURVILINEAR) { if (index < (int)mGridCollections.top()->getNumberCurvilinearGrids()) { openedGrid = mGridCollections.top()->getCurvilinearGrid(index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) { if (index < (int)mGridCollections.top()->getNumberRectilinearGrids()) { openedGrid = mGridCollections.top()->getRectilinearGrid(index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_REGULAR) { if (index < (int)mGridCollections.top()->getNumberRegularGrids()) { openedGrid = mGridCollections.top()->getRegularGrid(index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) { if (index < (int)mGridCollections.top()->getNumberUnstructuredGrids()) { openedGrid = mGridCollections.top()->getUnstructuredGrid(index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); } catch (XdmfError & e) { throw e; } } std::string tempString = key; memset(value, 0, valueLength); if ((openedGrid->getItemProperties().count(tempString))>0) { char * tempValue = strdup(openedGrid->getItemProperties()[tempString].c_str()); memcpy(value, tempValue, strlen(tempValue)+1); delete [] tempValue; } } else { try { XdmfError::message(XdmfError::FATAL, "There is no grid collection currently loaded."); } catch (XdmfError & e) { throw e; } } } int XdmfFortran::numDomainGrids(const int gridType) { if (gridType == XDMF_GRID_TYPE_CURVILINEAR) { return mDomain->getNumberCurvilinearGrids(); } else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) { return mDomain->getNumberRectilinearGrids(); } else if (gridType == XDMF_GRID_TYPE_REGULAR) { return mDomain->getNumberRegularGrids(); } else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) { return mDomain->getNumberUnstructuredGrids(); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); } catch (XdmfError & e) { throw e; } return -1; } } int XdmfFortran::numGridCollectionGrids(const int gridType) { if (!mGridCollections.empty()) { if (gridType == XDMF_GRID_TYPE_CURVILINEAR) { return mGridCollections.top()->getNumberCurvilinearGrids(); } else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) { return mGridCollections.top()->getNumberRectilinearGrids(); } else if (gridType == XDMF_GRID_TYPE_REGULAR) { return mGridCollections.top()->getNumberRegularGrids(); } else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) { return mGridCollections.top()->getNumberUnstructuredGrids(); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); } catch (XdmfError & e) { throw e; } return -1; } } else { try { XdmfError::message(XdmfError::FATAL, "Error: No Grid Collections have been loaded."); } catch (XdmfError & e) { throw e; } return -1; } } int XdmfFortran::retrieveGridCollectionType() { if (!mGridCollections.empty()) { shared_ptr returnType = mGridCollections.top()->getType(); if (returnType == XdmfGridCollectionType::Spatial()) { return XDMF_GRID_COLLECTION_TYPE_SPATIAL; } else if (returnType == XdmfGridCollectionType::Temporal()) { return XDMF_GRID_COLLECTION_TYPE_TEMPORAL; } else if (returnType == XdmfGridCollectionType::NoCollectionType()) { try { XdmfError::message(XdmfError::FATAL, "Error: No Grid Collection Type."); } catch (XdmfError & e) { throw e; } return -1; } else { try { XdmfError::message(XdmfError::FATAL, "Invalid Grid Collection Type."); } catch (XdmfError & e) { throw e; } return -1; } } else { try { XdmfError::message(XdmfError::FATAL, "There is no grid collection currently loaded."); } catch (XdmfError & e) { throw e; } return -1; } } float XdmfFortran::retrieveTime() { return static_cast(mTime->getValue()); } void XdmfFortran::retrieveGeometryTag(char * tag, const int tagLength) { if (mGeometry == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set geometry before its tag can be retrieved."); } catch (XdmfError & e) { throw e; } } else { char * tempTag = strdup(mGeometry->getItemTag().c_str()); memset(tag, 0, tagLength); memcpy(tag, tempTag, strlen(tempTag)+1); delete [] tempTag; } } int XdmfFortran::retrieveGeometryType() { if (mGeometry == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set geometry before its type can be retrieved."); } catch (XdmfError & e) { throw e; } return -1; } else { shared_ptr returnType = mGeometry->getType(); if (returnType == XdmfGeometryType::XY()) { return XDMF_GEOMETRY_TYPE_XY; } else if (returnType == XdmfGeometryType::XYZ()) { return XDMF_GEOMETRY_TYPE_XYZ; } else if (returnType == XdmfGeometryType::Polar()) { return XDMF_GEOMETRY_TYPE_POLAR; } else if (returnType == XdmfGeometryType::Spherical()) { return XDMF_GEOMETRY_TYPE_SPHERICAL; } else if (returnType == XdmfGeometryType::NoGeometryType()) { try { XdmfError::message(XdmfError::FATAL, "Uninitialized geometry type"); } catch (XdmfError & e) { throw e; } return -1; } else { try { XdmfError::message(XdmfError::FATAL, "Invalid geometry type"); } catch (XdmfError & e) { throw e; } return -1; } } } int XdmfFortran::retrieveGeometryValueType() { if (mGeometry == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set geometry before its value type can be retrieved."); } catch (XdmfError & e) { throw e; } return -1; } else { shared_ptr dataType = mGeometry->getArrayType(); if (dataType == XdmfArrayType::Int8()) { return XDMF_ARRAY_TYPE_INT8; } else if (dataType == XdmfArrayType::Int16()) { return XDMF_ARRAY_TYPE_INT16; } else if (dataType == XdmfArrayType::Int32()) { return XDMF_ARRAY_TYPE_INT32; } else if (dataType == XdmfArrayType::Int64()) { return XDMF_ARRAY_TYPE_INT64; } else if (dataType == XdmfArrayType::UInt8()) { return XDMF_ARRAY_TYPE_UINT8; } else if (dataType == XdmfArrayType::UInt16()) { return XDMF_ARRAY_TYPE_UINT16; } else if (dataType == XdmfArrayType::UInt32()) { return XDMF_ARRAY_TYPE_UINT32; } else if (dataType == XdmfArrayType::Float32()) { return XDMF_ARRAY_TYPE_FLOAT32; } else if (dataType == XdmfArrayType::Float64()) { return XDMF_ARRAY_TYPE_FLOAT64; } else if (dataType == XdmfArrayType::Uninitialized()) { try { XdmfError::message(XdmfError::FATAL, "Uninitialized Geometry Data Type."); } catch (XdmfError & e) { throw e; } return -1; } else { try { XdmfError::message(XdmfError::FATAL, "Invalid Geometry Data Type."); } catch (XdmfError & e) { throw e; } return -1; } } } void XdmfFortran::retrieveGeometryValues(void * values, const int dataType, const int numberRead, const int startIndex, const int arrayStride, const int valueStride) { if(mGeometry == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set geometry before its values can be retrieved."); } catch (XdmfError & e) { throw e; } } else { if (!mGeometry->isInitialized()) { mGeometry->read(); } readFromArray(mGeometry, dataType, values, numberRead, startIndex, arrayStride, valueStride); } } int XdmfFortran::retrieveGeometryNumPoints() { if (mGeometry == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set geometry before the number of points" " it contains can be retrieved."); } catch (XdmfError & e) { throw e; } return -1; } else { return mGeometry->getNumberPoints(); } } int XdmfFortran::retrieveGeometrySize() { if (mGeometry == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set geometry before its size can be retrieved."); } catch (XdmfError & e) { throw e; } return -1; } else { return mGeometry->getSize(); } } void XdmfFortran::clearPreviousGeometries() { mPreviousGeometries.clear(); } void XdmfFortran::modifyGeometryValues(void * values, const int arrayType, const int numValues, const int startIndex, const int arrayStride, const int valueStride) { if(mGeometry == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set geometry before its values can be modified."); } catch (XdmfError & e) { throw e; } } else { if (!mGeometry->isInitialized()) { mGeometry->read(); } writeToArray(mGeometry, numValues, arrayType, values, startIndex, arrayStride, valueStride); } } int XdmfFortran::retrieveGeometryNumProperties() { if (mGeometry == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set geometry before the number of properties" " it contains can be retrieved."); } catch (XdmfError & e) { throw e; } return -1; } else { return mGeometry->getItemProperties().size(); } } void XdmfFortran::retrieveGeometryProperty(const int index, char * key, const int keyLength, char * value, const int valueLength) { if (mGeometry == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set geometry before the properties" " it contains can be retrieved."); } catch (XdmfError & e) { throw e; } } else { if (index < (int)mGeometry->getItemProperties().size()) { std::map::iterator walker = mGeometry->getItemProperties().begin(); for (int i = 0; igetItemProperties().count(tempString))>0) { char * tempValue = strdup(mGeometry->getItemProperties()[tempString].c_str()); memcpy(value, tempValue, strlen(tempValue)+1); delete [] tempValue; } } } void XdmfFortran::setGeometryAsVariable(char * varname) { if (mGeometry == NULL) { try { XdmfError::message(XdmfError::FATAL, "Error: Must set geometry before it " "can be set as a variable."); } catch (XdmfError & e) { throw e; } } else { std::string newVar = varname; mVariableSet[newVar] = mGeometry; } } void XdmfFortran::setGeometryAsSubsetReference() { if (mGeometry == NULL) { try { XdmfError::message(XdmfError::FATAL, "Error: Must set geometry before it " "can be set as a variable."); } catch (XdmfError & e) { throw e; } } else { mSubsetReference = mGeometry; } } void XdmfFortran::retrieveTopologyTag(char * tag, const int tagLength) { if (mTopology == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set Topology before its tag can be retrieved."); } catch (XdmfError & e) { throw e; } } else { char * tempTag = strdup(mTopology->getItemTag().c_str()); memset(tag, 0, tagLength); memcpy(tag, tempTag, strlen(tempTag)+1); delete [] tempTag; } } int XdmfFortran::retrieveTopologyType() { if (mTopology == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set Topology before its type can be retrieved."); } catch (XdmfError & e) { throw e; } return -1; } else { shared_ptr returnType = mTopology->getType(); if (returnType == XdmfTopologyType::Polyvertex()) { return XDMF_TOPOLOGY_TYPE_POLYVERTEX; } else if (returnType == XdmfTopologyType::Polyline(0)) { return XDMF_TOPOLOGY_TYPE_POLYLINE; } else if (returnType == XdmfTopologyType::Polygon(0)) { return XDMF_TOPOLOGY_TYPE_POLYGON; } else if (returnType == XdmfTopologyType::Triangle()) { return XDMF_TOPOLOGY_TYPE_TRIANGLE; } else if (returnType == XdmfTopologyType::Quadrilateral()) { return XDMF_TOPOLOGY_TYPE_QUADRILATERAL; } else if (returnType == XdmfTopologyType::Tetrahedron()) { return XDMF_TOPOLOGY_TYPE_TETRAHEDRON; } else if (returnType == XdmfTopologyType::Pyramid()) { return XDMF_TOPOLOGY_TYPE_PYRAMID; } else if (returnType == XdmfTopologyType::Wedge()) { return XDMF_TOPOLOGY_TYPE_WEDGE; } else if (returnType == XdmfTopologyType::Hexahedron()) { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON; } else if (returnType == XdmfTopologyType::Edge_3()) { return XDMF_TOPOLOGY_TYPE_EDGE_3; } else if (returnType == XdmfTopologyType::Triangle_6()) { return XDMF_TOPOLOGY_TYPE_TRIANGLE_6; } else if (returnType == XdmfTopologyType::Quadrilateral_8()) { return XDMF_TOPOLOGY_TYPE_QUADRILATERAL_8; } else if (returnType == XdmfTopologyType::Quadrilateral_9()) { return XDMF_TOPOLOGY_TYPE_QUADRILATERAL_9; } else if (returnType == XdmfTopologyType::Tetrahedron_10()) { return XDMF_TOPOLOGY_TYPE_TETRAHEDRON_10; } else if (returnType == XdmfTopologyType::Pyramid_13()) { return XDMF_TOPOLOGY_TYPE_PYRAMID_13; } else if (returnType == XdmfTopologyType::Wedge_15()) { return XDMF_TOPOLOGY_TYPE_WEDGE_15; } else if (returnType == XdmfTopologyType::Wedge_18()) { return XDMF_TOPOLOGY_TYPE_WEDGE_18; } else if (returnType == XdmfTopologyType::Hexahedron_20()) { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_20; } else if (returnType == XdmfTopologyType::Hexahedron_24()) { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_24; } else if (returnType == XdmfTopologyType::Hexahedron_27()) { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_27; } else if (returnType == XdmfTopologyType::Hexahedron_64()) { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_64; } else if (returnType == XdmfTopologyType::Hexahedron_125()) { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_125; } else if (returnType == XdmfTopologyType::Hexahedron_216()) { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_216; } else if (returnType == XdmfTopologyType::Hexahedron_343()) { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_343; } else if (returnType == XdmfTopologyType::Hexahedron_512()) { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_512; } else if (returnType == XdmfTopologyType::Hexahedron_729()) { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_729; } else if (returnType == XdmfTopologyType::Hexahedron_1000()) { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_1000; } else if (returnType == XdmfTopologyType::Hexahedron_1331()) { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_1331; } else if (returnType == XdmfTopologyType::Mixed()) { return XDMF_TOPOLOGY_TYPE_MIXED; } else if (returnType == XdmfTopologyType::NoTopologyType()) { try { XdmfError::message(XdmfError::FATAL, "Uninitialized topology type."); } catch (XdmfError & e) { throw e; } return -1; } else { try { XdmfError::message(XdmfError::FATAL, "Invalid topology type."); } catch (XdmfError & e) { throw e; } return -1; } } } int XdmfFortran::retrieveTopologyValueType() { if (mTopology == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set Topology before its value type can be retrieved."); } catch (XdmfError & e) { throw e; } return -1; } else { shared_ptr dataType = mTopology->getArrayType(); if (dataType == XdmfArrayType::Int8()) { return XDMF_ARRAY_TYPE_INT8; } else if (dataType == XdmfArrayType::Int16()) { return XDMF_ARRAY_TYPE_INT16; } else if (dataType == XdmfArrayType::Int32()) { return XDMF_ARRAY_TYPE_INT32; } else if (dataType == XdmfArrayType::Int64()) { return XDMF_ARRAY_TYPE_INT64; } else if (dataType == XdmfArrayType::UInt8()) { return XDMF_ARRAY_TYPE_UINT8; } else if (dataType == XdmfArrayType::UInt16()) { return XDMF_ARRAY_TYPE_UINT16; } else if (dataType == XdmfArrayType::UInt32()) { return XDMF_ARRAY_TYPE_UINT32; } else if (dataType == XdmfArrayType::Float32()) { return XDMF_ARRAY_TYPE_FLOAT32; } else if (dataType == XdmfArrayType::Float64()) { return XDMF_ARRAY_TYPE_FLOAT64; } else if (dataType == XdmfArrayType::Uninitialized()) { try { XdmfError::message(XdmfError::FATAL, "Uninitialized Topology Data Type."); } catch (XdmfError & e) { throw e; } return -1; } else { try { XdmfError::message(XdmfError::FATAL, "Invalid Topology Data Type."); } catch (XdmfError & e) { throw e; } return -1; } } } void XdmfFortran::retrieveTopologyValues(void * values, const int dataType, const int numberRead, const int startIndex, const int arrayStride, const int valueStride) { if(mTopology == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set topology before its values can be retrieved."); } catch (XdmfError & e) { throw e; } } else { if (!mTopology->isInitialized()) { mTopology->read(); } readFromArray(mTopology, dataType, values, numberRead, startIndex, arrayStride, valueStride); } } int XdmfFortran::retrieveTopologyNumElements() { if (mTopology == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set Topology before the number of Elements" " it contains can be retrieved."); } catch (XdmfError & e) { throw e; } return -1; } else { return mTopology->getNumberElements(); } } int XdmfFortran::retrieveTopologySize() { if (mTopology == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set Topology before its size can be retrieved."); } catch (XdmfError & e) { throw e; } return -1; } else { return mTopology->getSize(); } } void XdmfFortran::clearPreviousTopologies() { mPreviousTopologies.clear(); } void XdmfFortran::modifyTopologyValues(void * values, const int arrayType, const int numValues, const int startIndex, const int arrayStride, const int valueStride) { if(mTopology == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set topology before its values can be modified."); } catch (XdmfError & e) { throw e; } } else { if (!mTopology->isInitialized()) { mTopology->read(); } writeToArray(mTopology, numValues, arrayType, values, startIndex, arrayStride, valueStride); } } int XdmfFortran::retrieveTopologyNumProperties() { if (mTopology == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set Topology before the number of properties" " it contains can be retrieved."); } catch (XdmfError & e) { throw e; } return -1; } else { return mTopology->getItemProperties().size(); } } void XdmfFortran::retrieveTopologyProperty(const int index, char * key, const int keyLength, char * value, const int valueLength) { if (mTopology == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set Topology before the properties it contains" " can be retrieved."); } catch (XdmfError & e) { throw e; } } else { if (index < (int)mTopology->getItemProperties().size()) { std::map::iterator walker = mTopology->getItemProperties().begin(); for (int i = 0; igetItemProperties().count(tempString))>0) { char * tempValue = strdup(mTopology->getItemProperties()[tempString].c_str()); memcpy(value, tempValue, strlen(tempValue)+1); delete [] tempValue; } } } void XdmfFortran::setTopologyAsVariable(char * varname) { if (mTopology == NULL) { try { XdmfError::message(XdmfError::FATAL, "Error: Must set Topology before it" " can be set as a variable."); } catch (XdmfError & e) { throw e; } } else { std::string newVar = varname; mVariableSet[newVar] = mTopology; } } void XdmfFortran::setTopologyAsSubsetReference() { if (mTopology == NULL) { try { XdmfError::message(XdmfError::FATAL, "Error: Must set Topology before it" " can be set as a variable."); } catch (XdmfError & e) { throw e; } } else { mSubsetReference = mTopology; } } int XdmfFortran::setDimensions(const int numValues, const int arrayType, void * pointValues) { mDimensions = XdmfArray::New(); // insert dimension values into array writeToArray(mDimensions, numValues, arrayType, pointValues); int id = mPreviousDimensions.size(); mPreviousDimensions.push_back(mDimensions); return id; } void XdmfFortran::clearDimensionsHeavyData() { if (mDimensions) { while (mDimensions->getNumberHeavyDataControllers() > 0) { mDimensions->removeHeavyDataController(0); } } else { try { XdmfError::message(XdmfError::FATAL, "Must set dimensions before hdf5 linkage" " can be established."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::setDimensionsHDF5(const char * hdf5File, const char * hdf5Dataset, const unsigned int start, const unsigned int stride, const unsigned int numValues, const unsigned int dataspace) { if (mDimensions) { shared_ptr newController = XdmfHDF5Controller::New(std::string(hdf5File), std::string(hdf5Dataset), mDimensions->getArrayType(), std::vector(1, start), std::vector(1, stride), std::vector(1, numValues), std::vector(1, dataspace)); while (mDimensions->getNumberHeavyDataControllers() > 0) { mDimensions->removeHeavyDataController(0); } mDimensions->insert(newController); } else { try { XdmfError::message(XdmfError::FATAL, "Must set dimensions before hdf5 linkage" " can be established."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::setDimensionsBinary(const char * binFile, const int endian, const unsigned int seek, const unsigned int start, const unsigned int stride, const unsigned int numValues, const unsigned int dataspace) { if (mDimensions) { XdmfBinaryController::Endian newEndian = XdmfBinaryController::NATIVE; switch (endian) { case XDMF_BINARY_ENDIAN_NATIVE: newEndian = XdmfBinaryController::NATIVE; break; case XDMF_BINARY_ENDIAN_LITTLE: newEndian = XdmfBinaryController::LITTLE; break; case XDMF_BINARY_ENDIAN_BIG: newEndian = XdmfBinaryController::BIG; break; default: break; } shared_ptr newController = XdmfBinaryController::New(std::string(binFile), mDimensions->getArrayType(), newEndian, seek, std::vector(1, start), std::vector(1, stride), std::vector(1, numValues), std::vector(1, dataspace)); while (mDimensions->getNumberHeavyDataControllers() > 0) { mDimensions->removeHeavyDataController(0); } mDimensions->insert(newController); } else { try { XdmfError::message(XdmfError::FATAL, "Must set dimensions before hdf5 linkage" " can be established."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::openPreviousDimensions(const int index) { if ((int)mPreviousDimensions.size()>index) { mDimensions = mPreviousDimensions[index]; } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::clearPreviousDimensions() { mPreviousDimensions.clear(); } void XdmfFortran::modifyDimensionsValues(void * values, const int arrayType, const int numValues, const int startIndex, const int arrayStride, const int valueStride) { if(mDimensions == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set dimensions before its values" " can be modified."); } catch (XdmfError & e) { throw e; } } else { if (!mDimensions->isInitialized()) { mDimensions->read(); } writeToArray(mDimensions, numValues, arrayType, values, startIndex, arrayStride, valueStride); } } void XdmfFortran::retrieveDimensionsTag(char * tag, const int tagLength) { if (mDimensions == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set dimensions before its tag can be retrieved."); } catch (XdmfError & e) { throw e; } } else { char * tempTag = strdup(mDimensions->getItemTag().c_str()); memset(tag, 0, tagLength); memcpy(tag, tempTag, strlen(tempTag)+1); delete [] tempTag; } } int XdmfFortran::retrieveDimensionsValueType() { if (mDimensions == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set dimensions before its value type" " can be retrieved."); } catch (XdmfError & e) { throw e; } return -1; } else { shared_ptr dataType = mDimensions->getArrayType(); if (dataType == XdmfArrayType::Int8()) { return XDMF_ARRAY_TYPE_INT8; } else if (dataType == XdmfArrayType::Int16()) { return XDMF_ARRAY_TYPE_INT16; } else if (dataType == XdmfArrayType::Int32()) { return XDMF_ARRAY_TYPE_INT32; } else if (dataType == XdmfArrayType::Int64()) { return XDMF_ARRAY_TYPE_INT64; } else if (dataType == XdmfArrayType::UInt8()) { return XDMF_ARRAY_TYPE_UINT8; } else if (dataType == XdmfArrayType::UInt16()) { return XDMF_ARRAY_TYPE_UINT16; } else if (dataType == XdmfArrayType::UInt32()) { return XDMF_ARRAY_TYPE_UINT32; } else if (dataType == XdmfArrayType::Float32()) { return XDMF_ARRAY_TYPE_FLOAT32; } else if (dataType == XdmfArrayType::Float64()) { return XDMF_ARRAY_TYPE_FLOAT64; } else if (dataType == XdmfArrayType::Uninitialized()) { try { XdmfError::message(XdmfError::FATAL, "Uninitialized Dimension Data Type."); } catch (XdmfError & e) { throw e; } return -1; } else { try { XdmfError::message(XdmfError::FATAL, "Invalid Dimension Data Type."); } catch (XdmfError & e) { throw e; } return -1; } } } void XdmfFortran::retrieveDimensionsValues(void * values, const int dataType, const int numberRead, const int startIndex, const int arrayStride, const int valueStride) { if(mDimensions == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set dimensions before its values" " can be retrieved."); } catch (XdmfError & e) { throw e; } } else { if (!mDimensions->isInitialized()) { mDimensions->read(); } readFromArray(mDimensions, dataType, values, numberRead, startIndex, arrayStride, valueStride); } } int XdmfFortran::retrieveDimensionsSize() { if (mDimensions == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set Dimensions before its size can be retrieved."); } catch (XdmfError & e) { throw e; } return -1; } else { return mDimensions->getSize(); } } int XdmfFortran::retrieveDimensionsNumProperties() { if (mDimensions == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set dimensions before the number of properties" " it contains can be retrieved."); } catch (XdmfError & e) { throw e; } return -1; } else { return mDimensions->getItemProperties().size(); } } void XdmfFortran::retrieveDimensionsProperty(const int index, char * key, const int keyLength, char * value, const int valueLength) { if (mDimensions == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set dimensions before the properties" " it contains can be retrieved."); } catch (XdmfError & e) { throw e; } } else { if (index < (int)mDimensions->getItemProperties().size()) { std::map::iterator walker = mDimensions->getItemProperties().begin(); for (int i = 0; igetItemProperties().count(tempString))>0) { char * tempValue = strdup(mDimensions->getItemProperties()[tempString].c_str()); memcpy(value, tempValue, strlen(tempValue)+1); delete [] tempValue; } } } int XdmfFortran::setOrigin(const int numValues, const int arrayType, void * pointValues) { mOrigin = XdmfArray::New(); // insert origin values into array writeToArray(mOrigin, numValues, arrayType, pointValues); int id = mPreviousOrigins.size(); mPreviousOrigins.push_back(mOrigin); return id; } void XdmfFortran::clearOriginHeavyData() { if (mOrigin) { while (mOrigin->getNumberHeavyDataControllers() > 0) { mOrigin->removeHeavyDataController(0); } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Must set Origin before hdf5 linkage can be established."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::setOriginHDF5(const char * hdf5File, const char * hdf5Dataset, const unsigned int start, const unsigned int stride, const unsigned int numValues, const unsigned int dataspace) { if (mOrigin) { shared_ptr newController = XdmfHDF5Controller::New(std::string(hdf5File), std::string(hdf5Dataset), mOrigin->getArrayType(), std::vector(1, start), std::vector(1, stride), std::vector(1, numValues), std::vector(1, dataspace)); while (mOrigin->getNumberHeavyDataControllers() > 0) { mOrigin->removeHeavyDataController(0); } mOrigin->insert(newController); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Must set Origin before hdf5 linkage can be established."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::setOriginBinary(const char * binFile, const int endian, const unsigned int seek, const unsigned int start, const unsigned int stride, const unsigned int numValues, const unsigned int dataspace) { if (mOrigin) { XdmfBinaryController::Endian newEndian = XdmfBinaryController::NATIVE; switch (endian) { case XDMF_BINARY_ENDIAN_NATIVE: newEndian = XdmfBinaryController::NATIVE; break; case XDMF_BINARY_ENDIAN_LITTLE: newEndian = XdmfBinaryController::LITTLE; break; case XDMF_BINARY_ENDIAN_BIG: newEndian = XdmfBinaryController::BIG; break; default: break; } shared_ptr newController = XdmfBinaryController::New(std::string(binFile), mOrigin->getArrayType(), newEndian, seek, std::vector(1, start), std::vector(1, stride), std::vector(1, numValues), std::vector(1, dataspace)); while (mOrigin->getNumberHeavyDataControllers() > 0) { mOrigin->removeHeavyDataController(0); } mOrigin->insert(newController); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Must set Origin before hdf5 linkage can be established."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::setPreviousOrigin(const int index) { if (index < (int)mPreviousOrigins.size()) { mOrigin = mPreviousOrigins[index]; } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of bounds."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::clearPreviousOrigins() { mPreviousOrigins.clear(); } void XdmfFortran::modifyOriginValues(void * values, const int arrayType, const int numValues, const int startIndex, const int arrayStride, const int valueStride) { if(mOrigin == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set origin before its values can be modified."); } catch (XdmfError & e) { throw e; } } else { if (!mOrigin->isInitialized()) { mOrigin->read(); } writeToArray(mOrigin, numValues, arrayType, values, startIndex, arrayStride, valueStride); } } void XdmfFortran::retrieveOriginTag(char * tag, const int tagLength) { if (mOrigin == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set origin before its tag can be retrieved."); } catch (XdmfError & e) { throw e; } } else { char * tempTag = strdup(mOrigin->getItemTag().c_str()); memset(tag, 0, tagLength); memcpy(tag, tempTag, strlen(tempTag)+1); delete [] tempTag; } } int XdmfFortran::retrieveOriginValueType() { if (mOrigin == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set origin before its value type" " can be retrieved."); } catch (XdmfError & e) { throw e; } return -1; } else { shared_ptr dataType = mOrigin->getArrayType(); if (dataType == XdmfArrayType::Int8()) { return XDMF_ARRAY_TYPE_INT8; } else if (dataType == XdmfArrayType::Int16()) { return XDMF_ARRAY_TYPE_INT16; } else if (dataType == XdmfArrayType::Int32()) { return XDMF_ARRAY_TYPE_INT32; } else if (dataType == XdmfArrayType::Int64()) { return XDMF_ARRAY_TYPE_INT64; } else if (dataType == XdmfArrayType::UInt8()) { return XDMF_ARRAY_TYPE_UINT8; } else if (dataType == XdmfArrayType::UInt16()) { return XDMF_ARRAY_TYPE_UINT16; } else if (dataType == XdmfArrayType::UInt32()) { return XDMF_ARRAY_TYPE_UINT32; } else if (dataType == XdmfArrayType::Float32()) { return XDMF_ARRAY_TYPE_FLOAT32; } else if (dataType == XdmfArrayType::Float64()) { return XDMF_ARRAY_TYPE_FLOAT64; } else if (dataType == XdmfArrayType::Uninitialized()) { try { XdmfError::message(XdmfError::FATAL, "Uninitialized Origin Data Type."); } catch (XdmfError & e) { throw e; } return -1; } else { try { XdmfError::message(XdmfError::FATAL, "Invalid Origin Data Type."); } catch (XdmfError & e) { throw e; } return -1; } } } void XdmfFortran::retrieveOriginValues(void * values, const int dataType, const int numberRead, const int startIndex, const int arrayStride, const int valueStride) { if(mOrigin == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set origin before its values can be retrieved."); } catch (XdmfError & e) { throw e; } } else { if (!mOrigin->isInitialized()) { mOrigin->read(); } readFromArray(mOrigin, dataType, values, numberRead, startIndex, arrayStride, valueStride); } } int XdmfFortran::retrieveOriginSize() { if (mOrigin == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set origin before its size can be retrieved."); } catch (XdmfError & e) { throw e; } return -1; } else { return mOrigin->getSize(); } } int XdmfFortran::retrieveOriginNumProperties() { if (mOrigin == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set origin before the number of properties" " it contains can be retrieved."); } catch (XdmfError & e) { throw e; } return -1; } else { return mOrigin->getItemProperties().size(); } } void XdmfFortran::retrieveOriginProperty(const int index, char * key, const int keyLength, char * value, const int valueLength) { if (mOrigin == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set Origin before the properties" " it contains can be retrieved."); } catch (XdmfError & e) { throw e; } } else { if (index < (int)mOrigin->getItemProperties().size()) { std::map::iterator walker = mOrigin->getItemProperties().begin(); for (int i = 0; igetItemProperties().count(tempString))>0) { char * tempValue = strdup(mOrigin->getItemProperties()[tempString].c_str()); memcpy(value, tempValue, strlen(tempValue)+1); delete [] tempValue; } } } int XdmfFortran::setBrick(const int numValues, const int arrayType, void * pointValues) { mBrick = XdmfArray::New(); // insert brick values into array writeToArray(mBrick, numValues, arrayType, pointValues); int id = mPreviousBricks.size(); mPreviousBricks.push_back(mBrick); return id; } void XdmfFortran::clearBrickHeavyData() { if (!mBrick) { while (mBrick->getNumberHeavyDataControllers() > 0) { mBrick->removeHeavyDataController(0); } } else { try { XdmfError::message(XdmfError::FATAL, "Must set Brick before hdf5 linkage" " can be established."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::setBrickHDF5(const char * hdf5File, const char * hdf5Dataset, const unsigned int start, const unsigned int stride, const unsigned int numValues, const unsigned int dataspace) { if (mBrick) { shared_ptr newController = XdmfHDF5Controller::New(std::string(hdf5File), std::string(hdf5Dataset), mBrick->getArrayType(), std::vector(1, start), std::vector(1, stride), std::vector(1, numValues), std::vector(1, dataspace)); while (mBrick->getNumberHeavyDataControllers() > 0) { mBrick->removeHeavyDataController(0); } mBrick->insert(newController); } else { try { XdmfError::message(XdmfError::FATAL, "Must set Brick before hdf5 linkage" " can be established."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::setBrickBinary(const char * binFile, const int endian, const unsigned int seek, const unsigned int start, const unsigned int stride, const unsigned int numValues, const unsigned int dataspace) { if (!mBrick) { XdmfBinaryController::Endian newEndian = XdmfBinaryController::NATIVE; switch (endian) { case XDMF_BINARY_ENDIAN_NATIVE: newEndian = XdmfBinaryController::NATIVE; break; case XDMF_BINARY_ENDIAN_LITTLE: newEndian = XdmfBinaryController::LITTLE; break; case XDMF_BINARY_ENDIAN_BIG: newEndian = XdmfBinaryController::BIG; break; default: break; } shared_ptr newController = XdmfBinaryController::New(std::string(binFile), mBrick->getArrayType(), newEndian, seek, std::vector(1, start), std::vector(1, stride), std::vector(1, numValues), std::vector(1, dataspace)); while (mBrick->getNumberHeavyDataControllers() > 0) { mBrick->removeHeavyDataController(0); } mBrick->insert(newController); } else { try { XdmfError::message(XdmfError::FATAL, "Must set Brick before hdf5 linkage" " can be established."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::setPreviousBrick(const int index) { if (index < (int)mPreviousBricks.size()) { mBrick = mPreviousBricks[index]; } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of bounds."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::clearPreviousBricks() { mPreviousBricks.clear(); } void XdmfFortran::modifyBrickValues(void * values, const int arrayType, const int numValues, const int startIndex, const int arrayStride, const int valueStride) { if(mBrick == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set brick before its values can be modified."); } catch (XdmfError & e) { throw e; } } else { if (!mBrick->isInitialized()) { mBrick->read(); } writeToArray(mBrick, numValues, arrayType, values, startIndex, arrayStride, valueStride); } } void XdmfFortran::retrieveBrickTag(char * tag, const int tagLength) { if (mBrick == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set Brick before its tag can be retrieved."); } catch (XdmfError & e) { throw e; } } else { char * tempTag = strdup(mBrick->getItemTag().c_str()); memset(tag, 0, tagLength); memcpy(tag, tempTag, strlen(tempTag)+1); delete [] tempTag; } } int XdmfFortran::retrieveBrickValueType() { if (mBrick == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set brick before its value type can be retrieved."); } catch (XdmfError & e) { throw e; } return -1; } else { shared_ptr dataType = mBrick->getArrayType(); if (dataType == XdmfArrayType::Int8()) { return XDMF_ARRAY_TYPE_INT8; } else if (dataType == XdmfArrayType::Int16()) { return XDMF_ARRAY_TYPE_INT16; } else if (dataType == XdmfArrayType::Int32()) { return XDMF_ARRAY_TYPE_INT32; } else if (dataType == XdmfArrayType::Int64()) { return XDMF_ARRAY_TYPE_INT64; } else if (dataType == XdmfArrayType::UInt8()) { return XDMF_ARRAY_TYPE_UINT8; } else if (dataType == XdmfArrayType::UInt16()) { return XDMF_ARRAY_TYPE_UINT16; } else if (dataType == XdmfArrayType::UInt32()) { return XDMF_ARRAY_TYPE_UINT32; } else if (dataType == XdmfArrayType::Float32()) { return XDMF_ARRAY_TYPE_FLOAT32; } else if (dataType == XdmfArrayType::Float64()) { return XDMF_ARRAY_TYPE_FLOAT64; } else if (dataType == XdmfArrayType::Uninitialized()) { try { XdmfError::message(XdmfError::FATAL, "Uninitialized Brick Data Type."); } catch (XdmfError & e) { throw e; } return -1; } else { try { XdmfError::message(XdmfError::FATAL, "Invalid Brick Data Type."); } catch (XdmfError & e) { throw e; } return -1; } } } void XdmfFortran::retrieveBrickValues(void * values, const int dataType, const int numberRead, const int startIndex, const int arrayStride, const int valueStride) { if(mBrick == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set brick before its values can be retrieved."); } catch (XdmfError & e) { throw e; } } else { if (!mBrick->isInitialized()) { mBrick->read(); } readFromArray(mBrick, dataType, values, numberRead, startIndex, arrayStride, valueStride); } } int XdmfFortran::retrieveBrickSize() { if (mBrick == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set brick before its size can be retrieved."); } catch (XdmfError & e) { throw e; } return -1; } else { return mBrick->getSize(); } } int XdmfFortran::retrieveBrickNumProperties() { if (mBrick == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set brick before the number of properties" " it contains can be retrieved."); } catch (XdmfError & e) { throw e; } return -1; } else { return mBrick->getItemProperties().size(); } } void XdmfFortran::retrieveBrickProperty(const int index, char * key, const int keyLength, char * value, const int valueLength) { if (mBrick == NULL) { try { XdmfError::message(XdmfError::FATAL, "Must set brick before the properties" " it contains can be retrieved."); } catch (XdmfError & e) { throw e; } } else { if (index < (int)mBrick->getItemProperties().size()) { std::map::iterator walker = mBrick->getItemProperties().begin(); for (int i = 0; igetItemProperties().count(tempString))>0) { char * tempValue = strdup(mBrick->getItemProperties()[tempString].c_str()); memcpy(value, tempValue, strlen(tempValue)+1); delete [] tempValue; } } } void XdmfFortran::addMap(char * name) { shared_ptr addedMap = XdmfMap::New(); addedMap->setName(name); mMaps.push_back(addedMap); } int XdmfFortran::retrieveNumMaps() { return mMaps.size(); } void XdmfFortran::clearMaps() { mMaps.clear(); } void XdmfFortran::retrieveMapTag(const int index, char * tag, const int tagLength) { if (index < (int)mMaps.size()) { char * tempTag = strdup(mMaps[index]->getItemTag().c_str()); memset(tag, 0, tagLength); memcpy(tag, tempTag, strlen(tempTag)+1); delete [] tempTag; } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::addRemoteNodeID(const int index, int localNodeID, int remoteTaskID, int remoteLocalNodeID) { mMaps[index]->insert(remoteTaskID, localNodeID, remoteLocalNodeID); } void XdmfFortran::retrieveRemoteNodeIDs(const int index, const int localNodeID, const int remoteTaskID, int * remoteNodeIDs) { if ((int)mMaps.size()>index) { if (!mMaps[index]->isInitialized()) { mMaps[index]->read(); } if (mMaps[index]->getRemoteNodeIds(remoteTaskID).count(localNodeID)>0) { std::set returnSet = mMaps[index]->getRemoteNodeIds(remoteTaskID)[localNodeID]; std::set::iterator walker; int i = 0; for (walker = returnSet.begin(); walker != returnSet.end();walker++) { remoteNodeIDs[i] = *walker; i++; } } else { try { XdmfError::message(XdmfError::FATAL, "The map does not contain a remote ID for the" " requested node."); } catch (XdmfError & e) { throw e; } } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of Range."); } catch (XdmfError & e) { throw e; } } } int XdmfFortran::retrieveNumRemoteNodeIDs(const int index, const int localNodeID, const int remoteTaskID) { if ((int)mMaps.size()isInitialized()) { mMaps[index]->read(); } if (mMaps[index]->getRemoteNodeIds(remoteTaskID).count(localNodeID)>0) { return mMaps[index]->getRemoteNodeIds(remoteTaskID)[localNodeID].size(); } else { return 0; } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of Range."); } catch (XdmfError & e) { throw e; } return -1; } } int XdmfFortran::storeMap(const int index) { if (index < (int)mMaps.size()) { int id = mPreviousMaps.size(); mPreviousMaps.push_back(mMaps[index]); return id; } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of Range."); } catch (XdmfError & e) { throw e; } return -1; } } void XdmfFortran::addPreviousMap(const int index) { if (index < (int)mPreviousMaps.size()) { mMaps.push_back(mPreviousMaps[index]); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::clearPreviousMaps() { mPreviousMaps.clear(); } void XdmfFortran::removeMap(const int index) { if (index < (int)mMaps.size()) { mMaps.erase(mMaps.begin()+index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } int XdmfFortran::retrieveMapNumProperties(const int index) { if (index < (int)mMaps.size()) { return mMaps[index]->getItemProperties().size(); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } return -1; } } void XdmfFortran::retrieveMapProperty(const int mapIndex, const int index, char * key, const int keyLength, char * value, const int valueLength) { if (mapIndex < (int)mMaps.size()) { if (index < (int)mMaps[index]->getItemProperties().size()) { std::map::iterator walker = mMaps[index]->getItemProperties().begin(); for (int i = 0; igetItemProperties().count(tempString))>0) { char * tempValue = strdup(mMaps[index]->getItemProperties()[tempString].c_str()); memcpy(value, tempValue, strlen(tempValue)+1); delete [] tempValue; } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } int XdmfFortran::retrieveNumAttributes() { return mAttributes.size(); } void XdmfFortran::clearAttributes() { mAttributes.clear(); } void XdmfFortran::retrieveAttributeTag(const int index, char * tag, const int tagLength) { if (index < (int)mAttributes.size()) { char * tempTag = strdup(mAttributes[index]->getItemTag().c_str()); memset(tag, 0, tagLength); memcpy(tag, tempTag, strlen(tempTag)+1); delete [] tempTag; } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::retrieveAttributeName(const int index, char * name, const int nameLength) { if (index < (int)mAttributes.size()) { char * tempName = strdup(mAttributes[index]->getName().c_str()); memset(name, 0, nameLength); memcpy(name, tempName, strlen(tempName)+1); delete [] tempName; } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } int XdmfFortran::retrieveAttributeValueType(const int index) { if (index < (int)mAttributes.size()) { shared_ptr dataType = mAttributes[index]->getArrayType(); if (dataType == XdmfArrayType::Int8()) { return XDMF_ARRAY_TYPE_INT8; } else if (dataType == XdmfArrayType::Int16()) { return XDMF_ARRAY_TYPE_INT16; } else if (dataType == XdmfArrayType::Int32()) { return XDMF_ARRAY_TYPE_INT32; } else if (dataType == XdmfArrayType::Int64()) { return XDMF_ARRAY_TYPE_INT64; } else if (dataType == XdmfArrayType::UInt8()) { return XDMF_ARRAY_TYPE_UINT8; } else if (dataType == XdmfArrayType::UInt16()) { return XDMF_ARRAY_TYPE_UINT16; } else if (dataType == XdmfArrayType::UInt32()) { return XDMF_ARRAY_TYPE_UINT32; } else if (dataType == XdmfArrayType::Float32()) { return XDMF_ARRAY_TYPE_FLOAT32; } else if (dataType == XdmfArrayType::Float64()) { return XDMF_ARRAY_TYPE_FLOAT64; } else if (dataType == XdmfArrayType::Uninitialized()) { try { XdmfError::message(XdmfError::FATAL, "Uninitialized Attribute Data Type."); } catch (XdmfError & e) { throw e; } return -1; } else { try { XdmfError::message(XdmfError::FATAL, "Invalid Attribute Data Type."); } catch (XdmfError & e) { throw e; } return -1; } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } return -1; } } void XdmfFortran::retrieveAttributeValues(const int index, void * values, const int dataType, const int numberRead, const int startIndex, const int arrayStride, const int valueStride) { if (index < (int)mAttributes.size()) { if (!mAttributes[index]->isInitialized()) { mAttributes[index]->read(); } readFromArray(mAttributes[index], dataType, values, numberRead, startIndex, arrayStride, valueStride); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::removeAttribute(const int index) { if (index < (int)mAttributes.size()) { mAttributes.erase(mAttributes.begin()+index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::replaceAttribute(const int index, char * name, int attributeCenter, int attributeType, const int numValues, const int arrayType, void * values) { if (index < (int)mAttributes.size()) { shared_ptr currAttribute = XdmfAttribute::New(); currAttribute->setName(name); switch(attributeCenter) { case XDMF_ATTRIBUTE_CENTER_GRID: currAttribute->setCenter(XdmfAttributeCenter::Grid()); break; case XDMF_ATTRIBUTE_CENTER_CELL: currAttribute->setCenter(XdmfAttributeCenter::Cell()); break; case XDMF_ATTRIBUTE_CENTER_FACE: currAttribute->setCenter(XdmfAttributeCenter::Face()); break; case XDMF_ATTRIBUTE_CENTER_EDGE: currAttribute->setCenter(XdmfAttributeCenter::Edge()); break; case XDMF_ATTRIBUTE_CENTER_NODE: currAttribute->setCenter(XdmfAttributeCenter::Node()); break; default: try { XdmfError::message(XdmfError::FATAL, "Invalid attribute center"); } catch (XdmfError & e) { throw e; } } switch(attributeType) { case XDMF_ATTRIBUTE_TYPE_SCALAR: currAttribute->setType(XdmfAttributeType::Scalar()); break; case XDMF_ATTRIBUTE_TYPE_VECTOR: currAttribute->setType(XdmfAttributeType::Vector()); break; case XDMF_ATTRIBUTE_TYPE_TENSOR: currAttribute->setType(XdmfAttributeType::Tensor()); break; case XDMF_ATTRIBUTE_TYPE_MATRIX: currAttribute->setType(XdmfAttributeType::Matrix()); break; case XDMF_ATTRIBUTE_TYPE_TENSOR6: currAttribute->setType(XdmfAttributeType::Tensor6()); break; case XDMF_ATTRIBUTE_TYPE_GLOBALID: currAttribute->setType(XdmfAttributeType::GlobalId()); break; default: try { XdmfError::message(XdmfError::FATAL, "Invalid attribute type"); } catch (XdmfError & e) { throw e; } } writeToArray(currAttribute, numValues, arrayType, values); mAttributes[index] = currAttribute; } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::openAttribute(const int index) { if (index < (int)mAttributes.size()) { int i; shared_ptr openedAttribute = mAttributes[index]; int n = openedAttribute->getNumberInformations(); shared_ptr openedInformation; for (i = 0; i < n; i++) { openedInformation = openedAttribute->getInformation(i); mInformations.push_back(openedInformation); mPreviousInformations.push_back(openedInformation); } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } int XdmfFortran::retrieveAttributeSize(const int index) { if (index < (int)mAttributes.size()) { return mAttributes[index]->getSize(); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } return -1; } } int XdmfFortran::retrieveAttributeType(const int index) { if (index < (int)mAttributes.size()) { shared_ptr returnType = mAttributes[index]->getType(); if (returnType == XdmfAttributeType::Scalar()) { return XDMF_ATTRIBUTE_TYPE_SCALAR; } else if (returnType == XdmfAttributeType::Vector()) { return XDMF_ATTRIBUTE_TYPE_VECTOR; } else if (returnType == XdmfAttributeType::Tensor()) { return XDMF_ATTRIBUTE_TYPE_TENSOR; } else if (returnType == XdmfAttributeType::Matrix()) { return XDMF_ATTRIBUTE_TYPE_MATRIX; } else if (returnType == XdmfAttributeType::Tensor6()) { return XDMF_ATTRIBUTE_TYPE_TENSOR6; } else if (returnType == XdmfAttributeType::GlobalId()) { return XDMF_ATTRIBUTE_TYPE_GLOBALID; } else { return XDMF_ATTRIBUTE_TYPE_NOTYPE; } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } return -1; } } int XdmfFortran::retrieveAttributeCenter(const int index) { if (index < (int)mAttributes.size()) { shared_ptr returnCenter = mAttributes[index]->getCenter(); if (returnCenter == XdmfAttributeCenter::Grid()) { return XDMF_ATTRIBUTE_CENTER_GRID; } else if (returnCenter == XdmfAttributeCenter::Cell()) { return XDMF_ATTRIBUTE_CENTER_CELL; } else if (returnCenter == XdmfAttributeCenter::Face()) { return XDMF_ATTRIBUTE_CENTER_FACE; } else if (returnCenter == XdmfAttributeCenter::Edge()) { return XDMF_ATTRIBUTE_CENTER_EDGE; } else if (returnCenter == XdmfAttributeCenter::Node()) { return XDMF_ATTRIBUTE_CENTER_NODE; } else { try { XdmfError::message(XdmfError::FATAL, "Error: Invalid Attribute Center."); } catch (XdmfError & e) { throw e; } return -1; } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } return -1; } } void XdmfFortran::clearPreviousAttributes() { mPreviousAttributes.clear(); } void XdmfFortran::modifyAttributeValues(const int index, void * values, const int arrayType, const int numValues, const int startIndex, const int arrayStride, const int valueStride) { if (index < (int)mAttributes.size()) { if (!mAttributes[index]->isInitialized()) { mAttributes[index]->read(); } writeToArray(mAttributes[index], numValues, arrayType, values, startIndex, arrayStride, valueStride); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } int XdmfFortran::retrieveAttributeNumProperties(const int index) { if (index < (int)mAttributes.size()) { return mAttributes[index]->getItemProperties().size(); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } return -1; } } void XdmfFortran::retrieveAttributeProperty(const int attributeIndex, const int index, char * key, const int keyLength, char * value, const int valueLength) { if (attributeIndex < (int)mAttributes.size()) { if (index < (int)mAttributes[attributeIndex]->getItemProperties().size()) { std::map::iterator walker = mAttributes[attributeIndex]->getItemProperties().begin(); for (int i = 0; igetItemProperties().count(tempString))>0) { char * tempValue = strdup(mAttributes[index]->getItemProperties()[tempString].c_str()); memcpy(value, tempValue, strlen(tempValue)+1); delete [] tempValue; } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::setAttributeAsVariable(char * varname, int index) { if (index < (int)mAttributes.size()) { std::string newVar = varname; mVariableSet[newVar] = mAttributes[index]; } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::setAttributeAsSubsetReference(int index) { if (index < (int)mAttributes.size()) { mSubsetReference = mAttributes[index]; } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } int XdmfFortran::addCoordinate(char * name, const int numValues, const int arrayType, void * values) { shared_ptr currArray = XdmfArray::New(); currArray->setName(name); writeToArray(currArray, numValues, arrayType, values); mCoordinates.push_back(currArray); const int id = mPreviousCoordinates.size(); mPreviousCoordinates.push_back(currArray); return id; } void XdmfFortran::addPreviousCoordinate(const int index) { if (index < (int)mPreviousCoordinates.size()) { mCoordinates.push_back(mPreviousCoordinates[index]); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::clearCoordinateHeavyData(const int index) { if (index < (int)mCoordinates.size()) { while (mCoordinates[index]->getNumberHeavyDataControllers() > 0) { mCoordinates[index]->removeHeavyDataController(0); } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::setCoordinateHDF5(const int index, const char * hdf5File, const char * hdf5Dataset, const unsigned int start, const unsigned int stride, const unsigned int numValues, const unsigned int dataspace) { if (index < (int)mCoordinates.size()) { shared_ptr newController = XdmfHDF5Controller::New(std::string(hdf5File), std::string(hdf5Dataset), mCoordinates[index]->getArrayType(), std::vector(1, start), std::vector(1, stride), std::vector(1, numValues), std::vector(1, dataspace)); while (mCoordinates[index]->getNumberHeavyDataControllers() > 0) { mCoordinates[index]->removeHeavyDataController(0); } mCoordinates[index]->insert(newController); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::setCoordinateBinary(const int index, const char * binFile, const int endian, const unsigned int seek, const unsigned int start, const unsigned int stride, const unsigned int numValues, const unsigned int dataspace) { if (index < (int)mCoordinates.size()) { XdmfBinaryController::Endian newEndian = XdmfBinaryController::NATIVE; switch (endian) { case XDMF_BINARY_ENDIAN_NATIVE: newEndian = XdmfBinaryController::NATIVE; break; case XDMF_BINARY_ENDIAN_LITTLE: newEndian = XdmfBinaryController::LITTLE; break; case XDMF_BINARY_ENDIAN_BIG: newEndian = XdmfBinaryController::BIG; break; default: break; } shared_ptr newController = XdmfBinaryController::New(std::string(binFile), mCoordinates[index]->getArrayType(), newEndian, seek, std::vector(1, start), std::vector(1, stride), std::vector(1, numValues), std::vector(1, dataspace)); while (mCoordinates[index]->getNumberHeavyDataControllers() > 0) { mCoordinates[index]->removeHeavyDataController(0); } mCoordinates[index]->insert(newController); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::clearPreviousCoordinates() { mPreviousCoordinates.clear(); } void XdmfFortran::modifyCoordinateValues(const int index, void * values, const int arrayType, const int numValues, const int startIndex, const int arrayStride, const int valueStride) { if (index < (int)mCoordinates.size()) { if (!mCoordinates[index]->isInitialized()) { mCoordinates[index]->read(); } writeToArray(mCoordinates[index], numValues, arrayType, values, startIndex, arrayStride, valueStride); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } int XdmfFortran::retrieveNumCoordinates() { return mCoordinates.size(); } void XdmfFortran::retrieveCoordinateTag(const int index, char * tag, const int tagLength) { if (index < (int)mCoordinates.size()) { char * tempTag = strdup(mCoordinates[index]->getItemTag().c_str()); memset(tag, 0, tagLength); memcpy(tag, tempTag, strlen(tempTag)+1); delete [] tempTag; } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::retrieveCoordinateName(const int index, char * name, const int nameLength) { if (index < (int)mCoordinates.size()) { char * tempName = strdup(mCoordinates[index]->getName().c_str()); memset(name, 0, nameLength); memcpy(name, tempName, strlen(tempName)+1); delete [] tempName; } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } int XdmfFortran::retrieveCoordinateValueType(const int index) { if (index < (int)mCoordinates.size()) { shared_ptr dataType = mCoordinates[index]->getArrayType(); if (dataType == XdmfArrayType::Int8()) { return XDMF_ARRAY_TYPE_INT8; } else if (dataType == XdmfArrayType::Int16()) { return XDMF_ARRAY_TYPE_INT16; } else if (dataType == XdmfArrayType::Int32()) { return XDMF_ARRAY_TYPE_INT32; } else if (dataType == XdmfArrayType::Int64()) { return XDMF_ARRAY_TYPE_INT64; } else if (dataType == XdmfArrayType::UInt8()) { return XDMF_ARRAY_TYPE_UINT8; } else if (dataType == XdmfArrayType::UInt16()) { return XDMF_ARRAY_TYPE_UINT16; } else if (dataType == XdmfArrayType::UInt32()) { return XDMF_ARRAY_TYPE_UINT32; } else if (dataType == XdmfArrayType::Float32()) { return XDMF_ARRAY_TYPE_FLOAT32; } else if (dataType == XdmfArrayType::Float64()) { return XDMF_ARRAY_TYPE_FLOAT64; } else if (dataType == XdmfArrayType::Uninitialized()) { try { XdmfError::message(XdmfError::FATAL, "Uninitialized Coordinate Data Type."); } catch (XdmfError & e) { throw e; } return -1; } else { try { XdmfError::message(XdmfError::FATAL, "Invalid Coordinate Data Type."); } catch (XdmfError & e) { throw e; } return -1; } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } return -1; } } void XdmfFortran::retrieveCoordinateValues(const int index, void * values, const int dataType, const int numberRead, const int startIndex, const int arrayStride, const int valueStride) { if (index < (int)mCoordinates.size()) { if (!mCoordinates[index]->isInitialized()) { mCoordinates[index]->read(); } readFromArray(mCoordinates[index], dataType, values, numberRead, startIndex, arrayStride, valueStride); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::removeCoordinate(const int index) { if (index < (int)mCoordinates.size()) { mCoordinates.erase(mCoordinates.begin()+index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::replaceCoordinate(const int index, char * name, const int numValues, const int arrayType, void * values) { if (index < (int)mCoordinates.size()) { shared_ptr currArray = XdmfArray::New(); currArray->setName(name); writeToArray(currArray, numValues, arrayType, values); mCoordinates[index] = currArray; } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } int XdmfFortran::retrieveCoordinateSize(const int index) { if (index < (int)mCoordinates.size()) { return mCoordinates[index]->getSize(); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } return -1; } } void XdmfFortran::clearCoordinates() { mCoordinates.clear(); } int XdmfFortran::retrieveCoordinateNumProperties(const int index) { if (index < (int)mCoordinates.size()) { return mCoordinates[index]->getItemProperties().size(); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } return -1; } } void XdmfFortran::retrieveCoordinateProperty(const int coordinateIndex, const int index, char * key, const int keyLength, char * value, const int valueLength) { if (coordinateIndex < (int)mCoordinates.size()) { if (index < (int)mCoordinates[coordinateIndex]->getItemProperties().size()) { std::map::iterator walker = mCoordinates[coordinateIndex]->getItemProperties().begin(); for (int i = 0; igetItemProperties().count(tempString))>0) { char * tempValue = strdup(mCoordinates[index]->getItemProperties()[tempString].c_str()); memcpy(value, tempValue, strlen(tempValue)+1); delete [] tempValue; } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::setCoordinateAsVariable(char * varname, int index) { if (index < (int)mCoordinates.size()) { std::string newVar = varname; mVariableSet[newVar] = mCoordinates[index]; } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::setCoordinateAsSubsetReference(int index) { if (index < (int)mCoordinates.size()) { mSubsetReference = mCoordinates[index]; } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } int XdmfFortran::addSet(char * name, const int newSetType, void * values, const int numValues, const int arrayType) { const shared_ptr newSet = XdmfSet::New(); newSet->setName(name); switch (newSetType) { case XDMF_SET_TYPE_NODE: newSet->setType(XdmfSetType::Node()); break; case XDMF_SET_TYPE_CELL: newSet->setType(XdmfSetType::Cell()); break; case XDMF_SET_TYPE_FACE: newSet->setType(XdmfSetType::Face()); break; case XDMF_SET_TYPE_EDGE: newSet->setType(XdmfSetType::Edge()); break; default: try { XdmfError::message(XdmfError::FATAL, "Invalid set type."); } catch (XdmfError & e) { throw e; } return -1; } for(std::vector >::const_iterator iter = mAttributes.begin(); iter != mAttributes.end(); ++iter) { newSet->insert(*iter); } mAttributes.clear(); if (!mInformations.empty()) { for(std::vector >::const_iterator iter = mInformations.begin(); iter != mInformations.end(); ++iter) { newSet->insert(*iter); } mInformations.clear(); } writeToArray(newSet, numValues, arrayType, values); mSets.push_back(newSet); int id = mPreviousSets.size(); mPreviousSets.push_back(newSet); return id; } void XdmfFortran::clearSetHeavyData(const int index) { if (index < (int)mSets.size()) { while (mSets[index]->getNumberHeavyDataControllers() > 0) { mSets[index]->removeHeavyDataController(0); } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::setSetHDF5(const int index, const char * hdf5File, const char * hdf5Dataset, const unsigned int start, const unsigned int stride, const unsigned int numValues, const unsigned int dataspace) { if (index < (int)mSets.size()) { shared_ptr newController = XdmfHDF5Controller::New(std::string(hdf5File), std::string(hdf5Dataset), mSets[index]->getArrayType(), std::vector(1, start), std::vector(1, stride), std::vector(1, numValues), std::vector(1, dataspace)); while (mSets[index]->getNumberHeavyDataControllers() > 0) { mSets[index]->removeHeavyDataController(0); } mSets[index]->insert(newController); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::setSetBinary(const int index, const char * binFile, const int endian, const unsigned int seek, const unsigned int start, const unsigned int stride, const unsigned int numValues, const unsigned int dataspace) { if (index < (int)mSets.size()) { XdmfBinaryController::Endian newEndian = XdmfBinaryController::NATIVE; switch (endian) { case XDMF_BINARY_ENDIAN_NATIVE: newEndian = XdmfBinaryController::NATIVE; break; case XDMF_BINARY_ENDIAN_LITTLE: newEndian = XdmfBinaryController::LITTLE; break; case XDMF_BINARY_ENDIAN_BIG: newEndian = XdmfBinaryController::BIG; break; default: break; } shared_ptr newController = XdmfBinaryController::New(std::string(binFile), mSets[index]->getArrayType(), newEndian, seek, std::vector(1, start), std::vector(1, stride), std::vector(1, numValues), std::vector(1, dataspace)); while (mSets[index]->getNumberHeavyDataControllers() > 0) { mSets[index]->removeHeavyDataController(0); } mSets[index]->insert(newController); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::clearSets() { mSets.clear(); } void XdmfFortran::addPreviousSet(const int index) { if (index < (int)mPreviousSets.size()) { mSets.push_back(mPreviousSets[index]); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::clearPreviousSets() { mPreviousSets.clear(); } void XdmfFortran::modifySetValues(const int index, void * values, const int arrayType, const int numValues, const int startIndex, const int arrayStride, const int valueStride) { if (index < (int)mSets.size()) { if (!mSets[index]->isInitialized()) { mSets[index]->read(); } writeToArray(mSets[index], numValues, arrayType, values, startIndex, arrayStride, valueStride); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::retrieveSetTag(const int index, char * tag, const int tagLength) { if (index < (int)mSets.size()) { char * tempTag = strdup(mSets[index]->getItemTag().c_str()); memset(tag, 0, tagLength); memcpy(tag, tempTag, strlen(tempTag)+1); delete [] tempTag; } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::retrieveSetName(const int index, char * name, const int nameLength) { if (index < (int)mSets.size()) { char * tempName = strdup(mSets[index]->getName().c_str()); memset(name, 0, nameLength); memcpy(name, tempName, strlen(tempName)+1); delete [] tempName; } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } int XdmfFortran::retrieveNumSets() { return mSets.size(); } int XdmfFortran::retrieveSetSize(const int index) { if (index < (int)mSets.size()) { return mSets[index]->getSize(); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } return -1; } } int XdmfFortran::retrieveSetValueType(const int index) { if (index < (int)mSets.size()) { shared_ptr dataType = mSets[index]->getArrayType(); if (dataType == XdmfArrayType::Int8()) { return XDMF_ARRAY_TYPE_INT8; } else if (dataType == XdmfArrayType::Int16()) { return XDMF_ARRAY_TYPE_INT16; } else if (dataType == XdmfArrayType::Int32()) { return XDMF_ARRAY_TYPE_INT32; } else if (dataType == XdmfArrayType::Int64()) { return XDMF_ARRAY_TYPE_INT64; } else if (dataType == XdmfArrayType::UInt8()) { return XDMF_ARRAY_TYPE_UINT8; } else if (dataType == XdmfArrayType::UInt16()) { return XDMF_ARRAY_TYPE_UINT16; } else if (dataType == XdmfArrayType::UInt32()) { return XDMF_ARRAY_TYPE_UINT32; } else if (dataType == XdmfArrayType::Float32()) { return XDMF_ARRAY_TYPE_FLOAT32; } else if (dataType == XdmfArrayType::Float64()) { return XDMF_ARRAY_TYPE_FLOAT64; } else if (dataType == XdmfArrayType::Uninitialized()) { try { XdmfError::message(XdmfError::FATAL, "Uninitialized Set Data Type."); } catch (XdmfError & e) { throw e; } return -1; } else { try { XdmfError::message(XdmfError::FATAL, "Invalid Set Data Type."); } catch (XdmfError & e) { throw e; } return -1; } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } return -1; } } void XdmfFortran::retrieveSetValues(const int index, void * values, const int dataType, const int numberRead, const int startIndex, const int arrayStride, const int valueStride) { if (index < (int)mSets.size()) { if (!mSets[index]->isInitialized()) { mSets[index]->read(); } readFromArray(mSets[index], dataType, values, numberRead, startIndex, arrayStride, valueStride); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } int XdmfFortran::retrieveSetType(const int index) { if (index < (int)mSets.size()) { shared_ptr returnType = mSets[index]->getType(); if (returnType == XdmfSetType::Node()) { return XDMF_SET_TYPE_NODE; } else if (returnType == XdmfSetType::Cell()) { return XDMF_SET_TYPE_CELL; } else if (returnType == XdmfSetType::Face()) { return XDMF_SET_TYPE_FACE; } else if (returnType == XdmfSetType::Edge()) { return XDMF_SET_TYPE_EDGE; } else if (returnType == XdmfSetType::NoSetType()) { try { XdmfError::message(XdmfError::FATAL, "Error: Uninitialized set type."); } catch (XdmfError & e) { throw e; } return -1; } else { try { XdmfError::message(XdmfError::FATAL, "Error: Invalid set type."); } catch (XdmfError & e) { throw e; } return -1; } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } return -1; } } void XdmfFortran::openSet(const int index, const int openAttribute, const int openInformation) { if (index < (int)mSets.size()) { shared_ptr openedSet = mSets[index]; int i; int n; n = openedSet->getNumberAttributes(); if (openAttribute) { shared_ptr openedAttribute; for (i = 0; i < n; i++) { openedAttribute = openedSet->getAttribute(i); mAttributes.push_back(openedAttribute); mPreviousAttributes.push_back(openedAttribute); } } if (openInformation) { n = openedSet->getNumberInformations(); shared_ptr openedInformation; for (i = 0; i < n; i++) { openedInformation = openedSet->getInformation(i); mInformations.push_back(openedInformation); mPreviousInformations.push_back(openedInformation); } } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::removeSet(const int index) { if (index < (int)mSets.size()) { mSets.erase(mSets.begin()+index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::replaceSet(const int index, char * name, const int newSetType, void * values, const int numValues, const int arrayType) { const shared_ptr newSet = XdmfSet::New(); newSet->setName(name); switch (newSetType) { case XDMF_SET_TYPE_NODE: newSet->setType(XdmfSetType::Node()); break; case XDMF_SET_TYPE_CELL: newSet->setType(XdmfSetType::Cell()); break; case XDMF_SET_TYPE_FACE: newSet->setType(XdmfSetType::Face()); break; case XDMF_SET_TYPE_EDGE: newSet->setType(XdmfSetType::Edge()); break; default: try { XdmfError::message(XdmfError::FATAL, "Invalid set type."); } catch (XdmfError & e) { throw e; } } for(std::vector >::const_iterator iter = mAttributes.begin(); iter != mAttributes.end(); ++iter) { newSet->insert(*iter); } mAttributes.clear(); if (!mInformations.empty()) { for(std::vector >::const_iterator iter = mInformations.begin(); iter != mInformations.end(); ++iter) { newSet->insert(*iter); } mInformations.clear(); } writeToArray(newSet, numValues, arrayType, values); mSets[index] = newSet; } int XdmfFortran::retrieveSetNumProperties(const int index) { if (index < (int)mSets.size()) { return mSets[index]->getItemProperties().size(); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } return -1; } } void XdmfFortran::retrieveSetProperty(const int setIndex, const int index, char * key, const int keyLength, char * value, const int valueLength) { if (setIndex < (int)mSets.size()) { if (index < (int)mSets[setIndex]->getItemProperties().size()) { std::map::iterator walker = mSets[setIndex]->getItemProperties().begin(); for (int i = 0; igetItemProperties().count(tempString))>0) { char * tempValue = strdup(mSets[index]->getItemProperties()[tempString].c_str()); memcpy(value, tempValue, strlen(tempValue)+1); delete [] tempValue; } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::setSetAsVariable(char * varname, int index) { if (index < (int)mSets.size()) { std::string newVar = varname; mVariableSet[newVar] = mSets[index]; } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::setSetAsSubsetReference(int index) { if (index < (int)mSets.size()) { mSubsetReference = mSets[index]; } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } int XdmfFortran::retrieveNumInformation() { return mInformations.size(); } void XdmfFortran::clearInformations() { mInformations.clear(); } void XdmfFortran::retrieveInformationTag(const int index, char * tag, const int tagLength) { if (index < (int)mInformations.size()) { char * tempTag = strdup(mInformations[index]->getItemTag().c_str()); memset(tag, 0, tagLength); memcpy(tag, tempTag, strlen(tempTag)+1); delete [] tempTag; } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::retrieveInformation(const int index, char * key, const int keyLength, char * value, const int valueLength) { if (index < (int)mInformations.size()) { char * tempKey = strdup(mInformations[index]->getKey().c_str()); char * tempValue = strdup(mInformations[index]->getValue().c_str()); memset(key, 0, keyLength); memset(value, 0, valueLength); memcpy(key, tempKey, strlen(tempKey)+1); memcpy(value, tempValue, strlen(tempValue)+1); delete [] tempKey; delete [] tempValue; } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::replaceInformation(const int index, char * key, char * value) { if (index < (int)mInformations.size()) { mInformations[index]->setKey(key); mInformations[index]->setValue(value); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::removeInformation(const int index) { if (index < (int)mInformations.size()) { mInformations.erase(mInformations.begin()+index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::openInformation(const int index) { if (index < (int)mInformations.size()) { shared_ptr sourceInformation = mInformations[index]; int i; int n = sourceInformation->getNumberInformations(); shared_ptr openedInformation; for (i = 0; i < n; i++) { openedInformation = sourceInformation->getInformation(i); mInformations.push_back(openedInformation); mPreviousInformations.push_back(openedInformation); } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::retrieveInformationByKey(char * key, char * value, const int valueLength) { unsigned int i; int found = 0; std::string searchString(key); char * tempValue; for (i=0;igetKey()) { found = 1; tempValue = strdup(mInformations[i]->getValue().c_str()); memset(value, 0, valueLength); memcpy(value, tempValue, strlen(tempValue)+1); i = mInformations.size(); delete [] tempValue; } } if (found == 0) { try { XdmfError::message(XdmfError::FATAL, "Error: Item with specifed key does not exist."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::replaceInformationByKey(char * key, char * value) { unsigned int i; int found = 0; std::string searchString(key); for (i=0;igetKey()) { mInformations[i]->setValue(value); i = mInformations.size(); found = 1; } } if (found == 0) { try { XdmfError::message(XdmfError::FATAL, "Error: Item with specifed key does not exist."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::removeInformationByKey(char * key) { unsigned int i; int found = 0; std::string searchString(key); for (i=0;igetKey()) { mInformations.erase(mInformations.begin()+i); i = mInformations.size(); found = 1; } } if (found == 0) { try { XdmfError::message(XdmfError::FATAL, "Error: Item with specifed key does not exist."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::clearPreviousInformation() { mPreviousInformations.clear(); } int XdmfFortran::retrieveInformationNumProperties(int const index) { if (index < (int)mInformations.size()) { return mInformations[index]->getItemProperties().size(); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } return -1; } } void XdmfFortran::retrieveInformationProperty(const int informationIndex, const int index, char * key, const int keyLength, char * value, const int valueLength) { if (informationIndex < (int)mInformations.size()) { if (index < (int)mInformations[informationIndex]->getItemProperties().size()) { std::map::iterator walker = mInformations[informationIndex]->getItemProperties().begin(); for (int i = 0; igetItemProperties().count(tempString))>0) { char * tempValue = strdup(mInformations[index]->getItemProperties()[tempString].c_str()); memcpy(value, tempValue, strlen(tempValue)+1); delete [] tempValue; } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::addInformationArray(const int index, char * name, void * values, const int numValues, const int arrayType) { if (index < (int)mInformations.size()) { shared_ptr newArray = XdmfArray::New(); newArray->setName(name); writeToArray(newArray, numValues, arrayType, values); mInformations[index]->insert(newArray); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::clearInformationArrayHeavyData(const int index, const int arrayIndex) { if (index < (int)mInformations.size()) { if (arrayIndex < (int)mInformations[index]->getNumberArrays()) { shared_ptr modifiedArray = mInformations[index]->getArray(arrayIndex); while (modifiedArray->getNumberHeavyDataControllers() > 0) { modifiedArray->removeHeavyDataController(0); } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::setInformationArrayHDF5(const int index, const int arrayIndex, const char * hdf5File, const char * hdf5Dataset, const unsigned int start, const unsigned int stride, const unsigned int numValues, const unsigned int dataspace) { if (index < (int)mInformations.size()) { if (arrayIndex < (int)mInformations[index]->getNumberArrays()) { shared_ptr modifiedArray = mInformations[index]->getArray(arrayIndex); shared_ptr newController = XdmfHDF5Controller::New(std::string(hdf5File), std::string(hdf5Dataset), modifiedArray->getArrayType(), std::vector(1, start), std::vector(1, stride), std::vector(1, numValues), std::vector(1, dataspace)); while (modifiedArray->getNumberHeavyDataControllers() > 0) { modifiedArray->removeHeavyDataController(0); } modifiedArray->insert(newController); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::setInformationArrayBinary(const int index, const int arrayIndex, const char * binFile, const int endian, const unsigned int seek, const unsigned int start, const unsigned int stride, const unsigned int numValues, const unsigned int dataspace) { if (index < (int)mInformations.size()) { if (arrayIndex < (int)mInformations[index]->getNumberArrays()) { shared_ptr modifiedArray = mInformations[index]->getArray(arrayIndex); XdmfBinaryController::Endian newEndian = XdmfBinaryController::NATIVE; switch (endian) { case XDMF_BINARY_ENDIAN_NATIVE: newEndian = XdmfBinaryController::NATIVE; break; case XDMF_BINARY_ENDIAN_LITTLE: newEndian = XdmfBinaryController::LITTLE; break; case XDMF_BINARY_ENDIAN_BIG: newEndian = XdmfBinaryController::BIG; break; default: break; } shared_ptr newController = XdmfBinaryController::New(std::string(binFile), mDimensions->getArrayType(), newEndian, seek, std::vector(1, start), std::vector(1, stride), std::vector(1, numValues), std::vector(1, dataspace)); while (modifiedArray->getNumberHeavyDataControllers() > 0) { modifiedArray->removeHeavyDataController(0); } modifiedArray->insert(newController); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::insertInformationIntoInformation(const int toIndex, const int fromIndex, const bool removeFromArray) { if (toIndex < (int)mInformations.size() && fromIndex < (int)mInformations.size()) { if (toIndex != fromIndex) { mInformations[toIndex]->insert(mInformations[fromIndex]); if (removeFromArray) { mInformations.erase(mInformations.begin()+fromIndex); } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Information may not be inserted into itself." " Doing so would cause an infinte loop when writing."); } catch (XdmfError & e) { throw e; } } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::modifyInformationArray(const int index, const int arrayIndex, void * values, const int arrayType, const int numValues, const int insertStart, const int arrayStride, const int valueStride) { if (index < (int)mInformations.size()) { if (arrayIndex < (int)mInformations[index]->getNumberArrays()) { shared_ptr modifiedArray = mInformations[index]->getArray(arrayIndex); if (!modifiedArray->isInitialized()) { modifiedArray->read(); } writeToArray(modifiedArray, numValues, arrayType, values, insertStart, arrayStride, valueStride); } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::removeInformationArray(const int index, const int arrayIndex) { if (index < (int)mInformations.size()) { if (arrayIndex < (int)mInformations[index]->getNumberArrays()) { mInformations[index]->removeArray(arrayIndex); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Array index out of range."); } catch (XdmfError & e) { throw e; } } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } int XdmfFortran::retrieveInformationArraySize(const int index, const int arrayIndex) { if (index < (int)mInformations.size()) { if (arrayIndex < (int)mInformations[index]->getNumberArrays()) { return mInformations[index]->getArray(arrayIndex)->getSize(); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Array index out of range."); } catch (XdmfError & e) { throw e; } } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } return -1; } int XdmfFortran::retrieveInformationArrayValueType(const int index, const int arrayIndex) { if (index < (int)mInformations.size()) { if (arrayIndex < (int)mInformations[index]->getNumberArrays()) { shared_ptr dataType = mInformations[index]->getArray(arrayIndex)->getArrayType(); if (dataType == XdmfArrayType::Int8()) { return XDMF_ARRAY_TYPE_INT8; } else if (dataType == XdmfArrayType::Int16()) { return XDMF_ARRAY_TYPE_INT16; } else if (dataType == XdmfArrayType::Int32()) { return XDMF_ARRAY_TYPE_INT32; } else if (dataType == XdmfArrayType::Int64()) { return XDMF_ARRAY_TYPE_INT64; } else if (dataType == XdmfArrayType::UInt8()) { return XDMF_ARRAY_TYPE_UINT8; } else if (dataType == XdmfArrayType::UInt16()) { return XDMF_ARRAY_TYPE_UINT16; } else if (dataType == XdmfArrayType::UInt32()) { return XDMF_ARRAY_TYPE_UINT32; } else if (dataType == XdmfArrayType::Float32()) { return XDMF_ARRAY_TYPE_FLOAT32; } else if (dataType == XdmfArrayType::Float64()) { return XDMF_ARRAY_TYPE_FLOAT64; } else if (dataType == XdmfArrayType::Uninitialized()) { try { XdmfError::message(XdmfError::FATAL, "Uninitialized Set Data Type."); } catch (XdmfError & e) { throw e; } return -1; } else { try { XdmfError::message(XdmfError::FATAL, "Invalid Set Data Type."); } catch (XdmfError & e) { throw e; } return -1; } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Array index out of range."); } catch (XdmfError & e) { throw e; } } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } return -1; } void XdmfFortran::retrieveInformationArrayValues(const int index, const int arrayIndex, void * values, const int dataType, const int numberRead, const int startIndex, const int arrayStride, const int valueStride) { if (index < (int)mInformations.size()) { if (arrayIndex < (int)mInformations[index]->getNumberArrays()) { if (!mInformations[index]->getArray(arrayIndex)->isInitialized()) { mInformations[index]->getArray(arrayIndex)->read(); } readFromArray(mInformations[index]->getArray(arrayIndex), dataType, values, numberRead, startIndex, arrayStride, valueStride); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Array index out of range."); } catch (XdmfError & e) { throw e; } } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::setInformationArrayAsVariable(char * varname, int infoindex, int index) { if (infoindex < (int)mInformations.size()) { if (index < mInformations[infoindex]->getNumberArrays()) { std::string newVar = varname; mVariableSet[newVar] = mInformations[infoindex]->getArray(index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::setInformationArrayAsSubsetReference(int infoindex, int index) { if (infoindex < (int)mInformations.size()) { if (index < mInformations[infoindex]->getNumberArrays()) { mSubsetReference = mInformations[infoindex]->getArray(index); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } int XdmfFortran::addFunctionAsAttribute(char * expression, const char * const name, const int attributeCenter, const int attributeType) { shared_ptr currAttribute = XdmfAttribute::New(); currAttribute->setName(name); switch(attributeCenter) { case XDMF_ATTRIBUTE_CENTER_GRID: currAttribute->setCenter(XdmfAttributeCenter::Grid()); break; case XDMF_ATTRIBUTE_CENTER_CELL: currAttribute->setCenter(XdmfAttributeCenter::Cell()); break; case XDMF_ATTRIBUTE_CENTER_FACE: currAttribute->setCenter(XdmfAttributeCenter::Face()); break; case XDMF_ATTRIBUTE_CENTER_EDGE: currAttribute->setCenter(XdmfAttributeCenter::Edge()); break; case XDMF_ATTRIBUTE_CENTER_NODE: currAttribute->setCenter(XdmfAttributeCenter::Node()); break; default: try { XdmfError::message(XdmfError::FATAL, "Invalid attribute center"); } catch (XdmfError & e) { throw e; } } switch(attributeType) { case XDMF_ATTRIBUTE_TYPE_SCALAR: currAttribute->setType(XdmfAttributeType::Scalar()); break; case XDMF_ATTRIBUTE_TYPE_VECTOR: currAttribute->setType(XdmfAttributeType::Vector()); break; case XDMF_ATTRIBUTE_TYPE_TENSOR: currAttribute->setType(XdmfAttributeType::Tensor()); break; case XDMF_ATTRIBUTE_TYPE_MATRIX: currAttribute->setType(XdmfAttributeType::Matrix()); break; case XDMF_ATTRIBUTE_TYPE_TENSOR6: currAttribute->setType(XdmfAttributeType::Tensor6()); break; case XDMF_ATTRIBUTE_TYPE_GLOBALID: currAttribute->setType(XdmfAttributeType::GlobalId()); break; default: try { XdmfError::message(XdmfError::FATAL, "Invalid attribute type"); } catch (XdmfError & e) { throw e; } } for(std::vector >::const_iterator iter = mInformations.begin(); iter != mInformations.end(); ++iter) { currAttribute->insert(*iter); } mInformations.clear(); // Set Function instead of setting values std::string expressionstring = std::string(expression); std::map > functionVariables = std::map >(mVariableSet); // Copy variables into new map shared_ptr function = XdmfFunction::New(expression, functionVariables); currAttribute->setReference(function); currAttribute->setReadMode(XdmfArray::Reference); mAttributes.push_back(currAttribute); const int id = mPreviousAttributes.size(); mPreviousAttributes.push_back(currAttribute); return id; } int XdmfFortran::addFunctionAsCoordinate(char * expression, char * name) { shared_ptr currArray = XdmfArray::New(); currArray->setName(name); // Set Function instead of setting values std::string expressionstring = std::string(expression); std::map > functionVariables = std::map >(mVariableSet); // Copy variables into new map shared_ptr function = XdmfFunction::New(expression, functionVariables); currArray->setReference(function); currArray->setReadMode(XdmfArray::Reference); mCoordinates.push_back(currArray); const int id = mPreviousCoordinates.size(); mPreviousCoordinates.push_back(currArray); return id; } int XdmfFortran::addFunctionAsSet(char * expression, char * name, const int newSetType) { const shared_ptr newSet = XdmfSet::New(); newSet->setName(name); switch (newSetType) { case XDMF_SET_TYPE_NODE: newSet->setType(XdmfSetType::Node()); break; case XDMF_SET_TYPE_CELL: newSet->setType(XdmfSetType::Cell()); break; case XDMF_SET_TYPE_FACE: newSet->setType(XdmfSetType::Face()); break; case XDMF_SET_TYPE_EDGE: newSet->setType(XdmfSetType::Edge()); break; default: try { XdmfError::message(XdmfError::FATAL, "Invalid set type."); } catch (XdmfError & e) { throw e; } return -1; } for(std::vector >::const_iterator iter = mAttributes.begin(); iter != mAttributes.end(); ++iter) { newSet->insert(*iter); } mAttributes.clear(); if (!mInformations.empty()) { for(std::vector >::const_iterator iter = mInformations.begin(); iter != mInformations.end(); ++iter) { newSet->insert(*iter); } mInformations.clear(); } // Set Function instead of setting values std::string expressionstring = std::string(expression); std::map > functionVariables = std::map >(mVariableSet); // Copy variables into new map shared_ptr function = XdmfFunction::New(expression, functionVariables); newSet->setReference(function); newSet->setReadMode(XdmfArray::Reference); mSets.push_back(newSet); int id = mPreviousSets.size(); mPreviousSets.push_back(newSet); return id; } void XdmfFortran::addFunctionAsInformationArray(char * expression, const int index, char * name) { if (index < (int)mInformations.size()) { shared_ptr newArray = XdmfArray::New(); newArray->setName(name); // Set Function instead of setting values std::string expressionstring = std::string(expression); std::map > functionVariables = std::map >(mVariableSet); // Copy variables into new map shared_ptr function = XdmfFunction::New(expression, functionVariables); newArray->setReference(function); newArray->setReadMode(XdmfArray::Reference); mInformations[index]->insert(newArray); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } int XdmfFortran::setFunctionAsTopology(char * expression, const int topologyType, const int numNodes) { mTopology = XdmfTopology::New(); switch(topologyType) { case XDMF_TOPOLOGY_TYPE_POLYVERTEX: mTopology->setType(XdmfTopologyType::Polyvertex()); break; case XDMF_TOPOLOGY_TYPE_POLYLINE: mTopology->setType(XdmfTopologyType::Polyline(numNodes)); break; case XDMF_TOPOLOGY_TYPE_POLYGON: mTopology->setType(XdmfTopologyType::Polygon(numNodes)); break; case XDMF_TOPOLOGY_TYPE_TRIANGLE: mTopology->setType(XdmfTopologyType::Triangle()); break; case XDMF_TOPOLOGY_TYPE_QUADRILATERAL: mTopology->setType(XdmfTopologyType::Quadrilateral()); break; case XDMF_TOPOLOGY_TYPE_TETRAHEDRON: mTopology->setType(XdmfTopologyType::Tetrahedron()); break; case XDMF_TOPOLOGY_TYPE_PYRAMID: mTopology->setType(XdmfTopologyType::Pyramid()); break; case XDMF_TOPOLOGY_TYPE_WEDGE: mTopology->setType(XdmfTopologyType::Wedge()); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON: mTopology->setType(XdmfTopologyType::Hexahedron()); break; case XDMF_TOPOLOGY_TYPE_EDGE_3: mTopology->setType(XdmfTopologyType::Edge_3()); break; case XDMF_TOPOLOGY_TYPE_TRIANGLE_6: mTopology->setType(XdmfTopologyType::Triangle_6()); break; case XDMF_TOPOLOGY_TYPE_QUADRILATERAL_8: mTopology->setType(XdmfTopologyType::Quadrilateral_8()); break; case XDMF_TOPOLOGY_TYPE_QUADRILATERAL_9: mTopology->setType(XdmfTopologyType::Quadrilateral_9()); break; case XDMF_TOPOLOGY_TYPE_TETRAHEDRON_10: mTopology->setType(XdmfTopologyType::Tetrahedron_10()); break; case XDMF_TOPOLOGY_TYPE_PYRAMID_13: mTopology->setType(XdmfTopologyType::Pyramid_13()); break; case XDMF_TOPOLOGY_TYPE_WEDGE_15: mTopology->setType(XdmfTopologyType::Wedge_15()); break; case XDMF_TOPOLOGY_TYPE_WEDGE_18: mTopology->setType(XdmfTopologyType::Wedge_18()); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_20: mTopology->setType(XdmfTopologyType::Hexahedron_20()); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_24: mTopology->setType(XdmfTopologyType::Hexahedron_24()); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_27: mTopology->setType(XdmfTopologyType::Hexahedron_27()); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_64: mTopology->setType(XdmfTopologyType::Hexahedron_64()); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_125: mTopology->setType(XdmfTopologyType::Hexahedron_125()); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_216: mTopology->setType(XdmfTopologyType::Hexahedron_216()); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_343: mTopology->setType(XdmfTopologyType::Hexahedron_343()); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_512: mTopology->setType(XdmfTopologyType::Hexahedron_512()); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_729: mTopology->setType(XdmfTopologyType::Hexahedron_729()); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_1000: mTopology->setType(XdmfTopologyType::Hexahedron_1000()); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_1331: mTopology->setType(XdmfTopologyType::Hexahedron_1331()); break; case XDMF_TOPOLOGY_TYPE_MIXED: mTopology->setType(XdmfTopologyType::Mixed()); break; default: try { XdmfError::message(XdmfError::FATAL, "Invalid topology type."); } catch (XdmfError & e) { throw e; } } // Set Function instead of setting values std::string expressionstring = std::string(expression); std::map > functionVariables = std::map >(mVariableSet); // Copy variables into new map shared_ptr function = XdmfFunction::New(expression, functionVariables); mTopology->setReference(function); mTopology->setReadMode(XdmfArray::Reference); const int id = mPreviousTopologies.size(); mPreviousTopologies.push_back(mTopology); return id; } int XdmfFortran::setFunctionAsGeometry(char * expression, const int geometryType) { mGeometry = XdmfGeometry::New(); switch(geometryType) { case XDMF_GEOMETRY_TYPE_XYZ: mGeometry->setType(XdmfGeometryType::XYZ()); break; case XDMF_GEOMETRY_TYPE_XY: mGeometry->setType(XdmfGeometryType::XY()); break; case XDMF_GEOMETRY_TYPE_POLAR: mGeometry->setType(XdmfGeometryType::Polar()); break; case XDMF_GEOMETRY_TYPE_SPHERICAL: mGeometry->setType(XdmfGeometryType::Spherical()); break; default: try { XdmfError::message(XdmfError::FATAL, "Invalid geometry type."); } catch (XdmfError & e) { throw e; } } // Set Function instead of setting values std::string expressionstring = std::string(expression); std::map > functionVariables = std::map >(mVariableSet); // Copy variables into new map shared_ptr function = XdmfFunction::New(expression, functionVariables); mGeometry->setReference(function); mGeometry->setReadMode(XdmfArray::Reference); const int id = mPreviousGeometries.size(); mPreviousGeometries.push_back(mGeometry); return id; } int XdmfFortran::addSubsetAsAttribute(int start, int stride, int dimensions, const char * const name, const int attributeCenter, const int attributeType) { shared_ptr currAttribute = XdmfAttribute::New(); currAttribute->setName(name); switch(attributeCenter) { case XDMF_ATTRIBUTE_CENTER_GRID: currAttribute->setCenter(XdmfAttributeCenter::Grid()); break; case XDMF_ATTRIBUTE_CENTER_CELL: currAttribute->setCenter(XdmfAttributeCenter::Cell()); break; case XDMF_ATTRIBUTE_CENTER_FACE: currAttribute->setCenter(XdmfAttributeCenter::Face()); break; case XDMF_ATTRIBUTE_CENTER_EDGE: currAttribute->setCenter(XdmfAttributeCenter::Edge()); break; case XDMF_ATTRIBUTE_CENTER_NODE: currAttribute->setCenter(XdmfAttributeCenter::Node()); break; default: try { XdmfError::message(XdmfError::FATAL, "Invalid attribute center"); } catch (XdmfError & e) { throw e; } } switch(attributeType) { case XDMF_ATTRIBUTE_TYPE_SCALAR: currAttribute->setType(XdmfAttributeType::Scalar()); break; case XDMF_ATTRIBUTE_TYPE_VECTOR: currAttribute->setType(XdmfAttributeType::Vector()); break; case XDMF_ATTRIBUTE_TYPE_TENSOR: currAttribute->setType(XdmfAttributeType::Tensor()); break; case XDMF_ATTRIBUTE_TYPE_MATRIX: currAttribute->setType(XdmfAttributeType::Matrix()); break; case XDMF_ATTRIBUTE_TYPE_TENSOR6: currAttribute->setType(XdmfAttributeType::Tensor6()); break; case XDMF_ATTRIBUTE_TYPE_GLOBALID: currAttribute->setType(XdmfAttributeType::GlobalId()); break; default: try { XdmfError::message(XdmfError::FATAL, "Invalid attribute type"); } catch (XdmfError & e) { throw e; } } for(std::vector >::const_iterator iter = mInformations.begin(); iter != mInformations.end(); ++iter) { currAttribute->insert(*iter); } mInformations.clear(); // Generate Subset instead of filling values std::vector newStart; newStart.push_back(start); std::vector newStride; newStride.push_back(stride); std::vector newDimension; newDimension.push_back(dimensions); shared_ptr subset = XdmfSubset::New(mSubsetReference, newStart, newStride, newDimension); currAttribute->setReference(subset); currAttribute->setReadMode(XdmfArray::Reference); mAttributes.push_back(currAttribute); const int id = mPreviousAttributes.size(); mPreviousAttributes.push_back(currAttribute); return id; } int XdmfFortran::addSubsetAsCoordinate(int start, int stride, int dimensions, char * name) { shared_ptr currArray = XdmfArray::New(); currArray->setName(name); // Generate Subset instead of filling values std::vector newStart; newStart.push_back(start); std::vector newStride; newStride.push_back(stride); std::vector newDimension; newDimension.push_back(dimensions); shared_ptr subset = XdmfSubset::New(mSubsetReference, newStart, newStride, newDimension); currArray->setReference(subset); currArray->setReadMode(XdmfArray::Reference); mCoordinates.push_back(currArray); const int id = mPreviousCoordinates.size(); mPreviousCoordinates.push_back(currArray); return id; } int XdmfFortran::addSubsetAsSet(int start, int stride, int dimensions, char * name, const int newSetType) { const shared_ptr newSet = XdmfSet::New(); newSet->setName(name); switch (newSetType) { case XDMF_SET_TYPE_NODE: newSet->setType(XdmfSetType::Node()); break; case XDMF_SET_TYPE_CELL: newSet->setType(XdmfSetType::Cell()); break; case XDMF_SET_TYPE_FACE: newSet->setType(XdmfSetType::Face()); break; case XDMF_SET_TYPE_EDGE: newSet->setType(XdmfSetType::Edge()); break; default: try { XdmfError::message(XdmfError::FATAL, "Invalid set type."); } catch (XdmfError & e) { throw e; } return -1; } for(std::vector >::const_iterator iter = mAttributes.begin(); iter != mAttributes.end(); ++iter) { newSet->insert(*iter); } mAttributes.clear(); if (!mInformations.empty()) { for(std::vector >::const_iterator iter = mInformations.begin(); iter != mInformations.end(); ++iter) { newSet->insert(*iter); } mInformations.clear(); } // Generate Subset instead of filling values std::vector newStart; newStart.push_back(start); std::vector newStride; newStride.push_back(stride); std::vector newDimension; newDimension.push_back(dimensions); shared_ptr subset = XdmfSubset::New(mSubsetReference, newStart, newStride, newDimension); newSet->setReference(subset); newSet->setReadMode(XdmfArray::Reference); mSets.push_back(newSet); int id = mPreviousSets.size(); mPreviousSets.push_back(newSet); return id; } void XdmfFortran::addSubsetAsInformationArray(int start, int stride, int dimensions, const int index, char * name) { if (index < (int)mInformations.size()) { shared_ptr newArray = XdmfArray::New(); newArray->setName(name); // Generate Subset instead of filling values std::vector newStart; newStart.push_back(start); std::vector newStride; newStride.push_back(stride); std::vector newDimension; newDimension.push_back(dimensions); shared_ptr subset = XdmfSubset::New(mSubsetReference, newStart, newStride, newDimension); newArray->setReference(subset); newArray->setReadMode(XdmfArray::Reference); mInformations[index]->insert(newArray); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); } catch (XdmfError & e) { throw e; } } } int XdmfFortran::setSubsetAsTopology(int start, int stride, int dimensions, const int topologyType, const int numNodes) { mTopology = XdmfTopology::New(); switch(topologyType) { case XDMF_TOPOLOGY_TYPE_POLYVERTEX: mTopology->setType(XdmfTopologyType::Polyvertex()); break; case XDMF_TOPOLOGY_TYPE_POLYLINE: mTopology->setType(XdmfTopologyType::Polyline(numNodes)); break; case XDMF_TOPOLOGY_TYPE_POLYGON: mTopology->setType(XdmfTopologyType::Polygon(numNodes)); break; case XDMF_TOPOLOGY_TYPE_TRIANGLE: mTopology->setType(XdmfTopologyType::Triangle()); break; case XDMF_TOPOLOGY_TYPE_QUADRILATERAL: mTopology->setType(XdmfTopologyType::Quadrilateral()); break; case XDMF_TOPOLOGY_TYPE_TETRAHEDRON: mTopology->setType(XdmfTopologyType::Tetrahedron()); break; case XDMF_TOPOLOGY_TYPE_PYRAMID: mTopology->setType(XdmfTopologyType::Pyramid()); break; case XDMF_TOPOLOGY_TYPE_WEDGE: mTopology->setType(XdmfTopologyType::Wedge()); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON: mTopology->setType(XdmfTopologyType::Hexahedron()); break; case XDMF_TOPOLOGY_TYPE_EDGE_3: mTopology->setType(XdmfTopologyType::Edge_3()); break; case XDMF_TOPOLOGY_TYPE_TRIANGLE_6: mTopology->setType(XdmfTopologyType::Triangle_6()); break; case XDMF_TOPOLOGY_TYPE_QUADRILATERAL_8: mTopology->setType(XdmfTopologyType::Quadrilateral_8()); break; case XDMF_TOPOLOGY_TYPE_QUADRILATERAL_9: mTopology->setType(XdmfTopologyType::Quadrilateral_9()); break; case XDMF_TOPOLOGY_TYPE_TETRAHEDRON_10: mTopology->setType(XdmfTopologyType::Tetrahedron_10()); break; case XDMF_TOPOLOGY_TYPE_PYRAMID_13: mTopology->setType(XdmfTopologyType::Pyramid_13()); break; case XDMF_TOPOLOGY_TYPE_WEDGE_15: mTopology->setType(XdmfTopologyType::Wedge_15()); break; case XDMF_TOPOLOGY_TYPE_WEDGE_18: mTopology->setType(XdmfTopologyType::Wedge_18()); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_20: mTopology->setType(XdmfTopologyType::Hexahedron_20()); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_24: mTopology->setType(XdmfTopologyType::Hexahedron_24()); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_27: mTopology->setType(XdmfTopologyType::Hexahedron_27()); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_64: mTopology->setType(XdmfTopologyType::Hexahedron_64()); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_125: mTopology->setType(XdmfTopologyType::Hexahedron_125()); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_216: mTopology->setType(XdmfTopologyType::Hexahedron_216()); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_343: mTopology->setType(XdmfTopologyType::Hexahedron_343()); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_512: mTopology->setType(XdmfTopologyType::Hexahedron_512()); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_729: mTopology->setType(XdmfTopologyType::Hexahedron_729()); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_1000: mTopology->setType(XdmfTopologyType::Hexahedron_1000()); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_1331: mTopology->setType(XdmfTopologyType::Hexahedron_1331()); break; case XDMF_TOPOLOGY_TYPE_MIXED: mTopology->setType(XdmfTopologyType::Mixed()); break; default: try { XdmfError::message(XdmfError::FATAL, "Invalid topology type."); } catch (XdmfError & e) { throw e; } } // Generate Subset instead of filling values std::vector newStart; newStart.push_back(start); std::vector newStride; newStride.push_back(stride); std::vector newDimension; newDimension.push_back(dimensions); shared_ptr subset = XdmfSubset::New(mSubsetReference, newStart, newStride, newDimension); mTopology->setReference(subset); mTopology->setReadMode(XdmfArray::Reference); const int id = mPreviousTopologies.size(); mPreviousTopologies.push_back(mTopology); return id; } int XdmfFortran::setSubsetAsGeometry(int start, int stride, int dimensions, const int geometryType) { mGeometry = XdmfGeometry::New(); switch(geometryType) { case XDMF_GEOMETRY_TYPE_XYZ: mGeometry->setType(XdmfGeometryType::XYZ()); break; case XDMF_GEOMETRY_TYPE_XY: mGeometry->setType(XdmfGeometryType::XY()); break; case XDMF_GEOMETRY_TYPE_POLAR: mGeometry->setType(XdmfGeometryType::Polar()); break; case XDMF_GEOMETRY_TYPE_SPHERICAL: mGeometry->setType(XdmfGeometryType::Spherical()); break; default: try { XdmfError::message(XdmfError::FATAL, "Invalid geometry type."); } catch (XdmfError & e) { throw e; } } // Generate Subset instead of filling values std::vector newStart; newStart.push_back(start); std::vector newStride; newStride.push_back(stride); std::vector newDimension; newDimension.push_back(dimensions); shared_ptr subset = XdmfSubset::New(mSubsetReference, newStart, newStride, newDimension); mGeometry->setReference(subset); mGeometry->setReadMode(XdmfArray::Reference); const int id = mPreviousGeometries.size(); mPreviousGeometries.push_back(mGeometry); return id; } void XdmfFortran::clearFunctionVariables() { mVariableSet.clear(); } void XdmfFortran::removeFunctionVariable(char * varname) { std::string tempstring = varname; mVariableSet.erase(tempstring); } void XdmfFortran::clearPrevious() { mPreviousTopologies.clear(); mPreviousGeometries.clear(); mPreviousAttributes.clear(); mPreviousMaps.clear(); mPreviousSets.clear(); mPreviousDimensions.clear(); mPreviousOrigins.clear(); mPreviousBricks.clear(); mPreviousCoordinates.clear(); } void XdmfFortran::setAllowSetSplitting(bool newAllow) { mAllowSetSplitting = newAllow; } void XdmfFortran::setMaxFileSize(int newSize) { mMaxFileSize = newSize; } void XdmfFortran::write(const char * const xmlFilePath, const int datalimit, const bool release) { shared_ptr writer; if (mHeavyDataWriter == NULL) { writer = XdmfWriter::New(xmlFilePath); mHeavyDataWriter = writer->getHeavyDataWriter(); } else { writer = XdmfWriter::New(xmlFilePath, mHeavyDataWriter); } writer->setLightDataLimit(datalimit); writer->getHeavyDataWriter()->setReleaseData(release); shared_dynamic_cast(writer->getHeavyDataWriter())->setFileSizeLimit(mMaxFileSize); shared_dynamic_cast(writer->getHeavyDataWriter())->setAllowSetSplitting(mAllowSetSplitting); mDomain->accept(writer); } void XdmfFortran::writeHDF5(const char * const xmlFilePath, const bool release) { if (mHeavyDataWriter == NULL || mHeavyDataWriter->getFilePath() != xmlFilePath) { shared_ptr writer = XdmfHDF5Writer::New(xmlFilePath); writer->setFileSizeLimit(mMaxFileSize); writer->setAllowSetSplitting(mAllowSetSplitting); writer->setReleaseData( release ); mHeavyDataWriter = writer; } if (mHeavyDataWriter->getReleaseData() != release) { mHeavyDataWriter->setReleaseData(release); } mHeavyDataWriter->openFile(); mDomain->accept(mHeavyDataWriter); mHeavyDataWriter->closeFile(); } void XdmfFortran::initHDF5(const char * const xmlFilePath, const bool release) { shared_ptr writer = XdmfHDF5Writer::New(xmlFilePath); writer->setFileSizeLimit(mMaxFileSize); writer->setAllowSetSplitting(mAllowSetSplitting); writer->setReleaseData(release); mHeavyDataWriter = writer; } #ifdef XDMF_BUILD_DSM void XdmfFortran::initDSMServer(const char * const filePath, MPI_Comm comm, int bufferSize, int startCoreIndex, int endCoreIndex) { // Non-Threaded version std::string writtenFile(filePath); if (bufferSize > 0) { mDSMWriter = XdmfHDF5WriterDSM::New(writtenFile, comm, (unsigned int) bufferSize, startCoreIndex, endCoreIndex); mDSMWriter->setMode(XdmfHeavyDataWriter::Hyperslab); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Non-positive DSM buffer size."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::acceptDSM(int numConnections) { if (mDSMWriter) { mDSMWriter->getServerBuffer()->GetComm()->OpenPort(); mDSMWriter->getServerBuffer()->SendAccept(numConnections); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Attempting to accept connection when DSM is not set up."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::closeDSMPort() { if (mDSMWriter) { mDSMWriter->getServerBuffer()->GetComm()->ClosePort(); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Attempting to close a port when DSM is not set up."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::connectDSM(const char * const filePath, MPI_Comm comm) { std::string writtenFile(filePath); XdmfDSMCommMPI * dsmComm = new XdmfDSMCommMPI(); dsmComm->DupComm(comm); dsmComm->Init(); XdmfDSMBuffer * dsmBuffer = new XdmfDSMBuffer(); dsmBuffer->SetIsServer(false); dsmBuffer->SetComm(dsmComm); dsmBuffer->SetIsConnected(true); mDSMWriter = XdmfHDF5WriterDSM::New(writtenFile, dsmBuffer); mDSMWriter->setMode(XdmfHeavyDataWriter::Hyperslab); // Currently uses default config file name mDSMWriter->getServerBuffer()->GetComm()->ReadDsmPortName(); mDSMWriter->getServerBuffer()->Connect(); // To check if the DSM writer is using server mode // bool test = mDSMWriter->getServerMode(); } MPI_Comm XdmfFortran::getDSMInterComm() { // Sanity check if (mDSMWriter) { return mDSMWriter->getServerBuffer()->GetComm()->GetInterComm(); } else { return MPI_COMM_NULL; } } MPI_Comm XdmfFortran::getDSMIntraComm() { // Sanity check if (mDSMWriter) { return mDSMWriter->getServerBuffer()->GetComm()->GetIntraComm(); } else { return MPI_COMM_NULL; } } // Call only on one core void XdmfFortran::stopDSM() { if (mDSMWriter) { mDSMWriter->stopDSM(); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Stop called when DSM not initialized."); } catch (XdmfError & e) { throw e; } } mDSMWriter = shared_ptr(); } void XdmfFortran::readFromDSM(const char * const dsmDataSetPath, const int arrayType, void * values, const int start, const int stride, const int dimensions, const int dataspace) { if (mDSMWriter) { shared_ptr writtenArrayType = shared_ptr(); switch(arrayType) { case XDMF_ARRAY_TYPE_INT8: writtenArrayType = XdmfArrayType::Int8(); break; case XDMF_ARRAY_TYPE_INT16: writtenArrayType = XdmfArrayType::Int16(); break; case XDMF_ARRAY_TYPE_INT32: writtenArrayType = XdmfArrayType::Int32(); break; case XDMF_ARRAY_TYPE_INT64: writtenArrayType = XdmfArrayType::Int64(); break; case XDMF_ARRAY_TYPE_UINT8: writtenArrayType = XdmfArrayType::UInt8(); break; case XDMF_ARRAY_TYPE_UINT16: writtenArrayType = XdmfArrayType::UInt16(); break; case XDMF_ARRAY_TYPE_UINT32: writtenArrayType = XdmfArrayType::UInt32(); break; case XDMF_ARRAY_TYPE_FLOAT32: writtenArrayType = XdmfArrayType::Float32(); break; case XDMF_ARRAY_TYPE_FLOAT64: writtenArrayType = XdmfArrayType::Float64(); break; default: try { XdmfError::message(XdmfError::FATAL, "Invalid array number type"); } catch (XdmfError & e) { throw e; } } std::vector startVector; startVector.push_back(start); std::vector strideVector; strideVector.push_back(stride); std::vector dimVector; dimVector.push_back(dimensions); std::vector dataVector; dataVector.push_back(dataspace); std::string writtenPath(dsmDataSetPath); shared_ptr writerController = XdmfHDF5ControllerDSM::New(mDSMWriter->getFilePath(), writtenPath, writtenArrayType, startVector, strideVector, dimVector, dataVector, mDSMWriter->getServerBuffer()); shared_ptr readArray = XdmfArray::New(); readArray->insert(writerController); readArray->read(); readFromArray(readArray, arrayType, values, dimensions, 0, 1, 1); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Attempting to read from DSM when DSM is not set up."); } catch (XdmfError & e) { throw e; } } } void XdmfFortran::writeToDSM(const char * const dsmDataSetPath, const int arrayType, void * values, const int start, const int stride, const int dimensions, const int dataspace) { if (mDSMWriter) { shared_ptr writtenArrayType = shared_ptr(); switch(arrayType) { case XDMF_ARRAY_TYPE_INT8: writtenArrayType = XdmfArrayType::Int8(); break; case XDMF_ARRAY_TYPE_INT16: writtenArrayType = XdmfArrayType::Int16(); break; case XDMF_ARRAY_TYPE_INT32: writtenArrayType = XdmfArrayType::Int32(); break; case XDMF_ARRAY_TYPE_INT64: writtenArrayType = XdmfArrayType::Int64(); break; case XDMF_ARRAY_TYPE_UINT8: writtenArrayType = XdmfArrayType::UInt8(); break; case XDMF_ARRAY_TYPE_UINT16: writtenArrayType = XdmfArrayType::UInt16(); break; case XDMF_ARRAY_TYPE_UINT32: writtenArrayType = XdmfArrayType::UInt32(); break; case XDMF_ARRAY_TYPE_FLOAT32: writtenArrayType = XdmfArrayType::Float32(); break; case XDMF_ARRAY_TYPE_FLOAT64: writtenArrayType = XdmfArrayType::Float64(); break; default: try { XdmfError::message(XdmfError::FATAL, "Invalid array number type"); } catch (XdmfError & e) { throw e; } } std::vector startVector; startVector.push_back(start); std::vector strideVector; strideVector.push_back(stride); std::vector dimVector; dimVector.push_back(dimensions); std::vector dataVector; dataVector.push_back(dataspace); std::string writtenPath(dsmDataSetPath); shared_ptr writerController = XdmfHDF5ControllerDSM::New(mDSMWriter->getFilePath(), writtenPath, writtenArrayType, startVector, strideVector, dimVector, dataVector, mDSMWriter->getServerBuffer()); shared_ptr writtenArray = XdmfArray::New(); writeToArray(writtenArray, dimensions, arrayType, values); writtenArray->insert(writerController); mDSMWriter->setNotifyOnWrite(false); writtenArray->accept(mDSMWriter); } else { try { XdmfError::message(XdmfError::FATAL, "Error: Attempting to write to DSM when DSM is not set up."); } catch (XdmfError & e) { throw e; } } } #endif void XdmfFortran::read(const char * const xmlFilePath) { shared_ptr reader = XdmfReader::New(); mDomain = shared_dynamic_cast(reader->read( xmlFilePath )); } //temporary fix, hopefully int XdmfFortran::setTopologyPolyline(const unsigned int nodesPerElement, const unsigned int numValues, const int arrayType, const void * const connectivityValues) { mTopology = XdmfTopology::New(); mTopology->setType(XdmfTopologyType::Polyline(nodesPerElement)); // insert connectivity values into array writeToArray(mTopology, numValues, arrayType, connectivityValues); const int id = mPreviousTopologies.size(); mPreviousTopologies.push_back(mTopology); return id; } int XdmfFortran::setTopologyPolygon(const unsigned int nodesPerElement, const unsigned int numValues, const int arrayType, const void * const connectivityValues) { mTopology = XdmfTopology::New(); mTopology->setType(XdmfTopologyType::Polygon(nodesPerElement)); // insert connectivity values into array writeToArray(mTopology, numValues, arrayType, connectivityValues); const int id = mPreviousTopologies.size(); mPreviousTopologies.push_back(mTopology); return id; } // // C++ will mangle the name based on the argument list. This tells the // compiler not to mangle the name so we can call it from 'C' (but // really Fortran in this case) // extern "C" { // C Wrapper Functions // Main Xdmf Functions void XdmfInit(long * pointer) { XdmfFortran * xdmfFortran = new XdmfFortran(); *pointer = reinterpret_cast(xdmfFortran); } void XdmfClose(long * pointer) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); delete xdmfFortran; } int XdmfAddAttribute(long * pointer, char * const name, int * attributeCenter, int * attributeType, int * numValues, int * arrayType, void * values) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); return xdmfFortran->addAttribute(name, *attributeCenter, *attributeType, *numValues, *arrayType, values); } void XdmfClearAttributeHeavyData(long * pointer, int * index) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); return xdmfFortran->clearAttributeHeavyData(*index); } void XdmfSetAttributeHDF5(long * pointer, int * index, char * const hdf5File, char * const hdf5Dataset, unsigned int * start, unsigned int * stride, unsigned int * numValues, unsigned int * dataspace) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->setAttributeHDF5(*index, hdf5File, hdf5Dataset, *start, *stride, *numValues, *dataspace); } void XdmfSetAttributeBinary(long * pointer, int * index, char * binFile, int * endian, unsigned int * seek, unsigned int * start, unsigned int * stride, unsigned int * numValues, unsigned int * dataspace) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->setAttributeBinary(*index, binFile, *endian, *seek, *start, *stride, *numValues, *dataspace); } void XdmfAddGrid(long * pointer, char * gridName, bool * writeToHDF5) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->addGrid(gridName, *writeToHDF5); } void XdmfAddGridCurvilinear(long * pointer, char * gridName, bool * writeToHDF5) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->addGridCurvilinear(gridName, *writeToHDF5); } void XdmfAddGridRectilinear(long * pointer, char * gridName, bool * writeToHDF5) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->addGridRectilinear(gridName, *writeToHDF5); } void XdmfAddGridRegular(long * pointer, char * gridName, bool * writeToHDF5) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->addGridRegular(gridName, *writeToHDF5); } void XdmfAddGridCollection(long * pointer, char * name, int * gridCollectionType) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->addGridCollection(name, *gridCollectionType); } void XdmfAddGridReference(long * pointer, int * gridType, char * filePath, const char * xmlPath) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->addGridReference(*gridType, filePath, xmlPath); } void XdmfAddGridCollectionReference(long * pointer, char * filePath, char * xmlPath) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->addGridCollectionReference(filePath, xmlPath); } int XdmfAddInformation(long * pointer, char * key, char * value) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); return xdmfFortran->addInformation(key, value); } void XdmfAddPreviousAttribute(long * pointer, int * attributeId) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->addPreviousAttribute(*attributeId); } void XdmfAddPreviousInformation(long * pointer, int * informationId) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->addPreviousInformation(*informationId); } void XdmfCloseGridCollection(long * pointer, bool * writeToHDF5) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->closeGridCollection(*writeToHDF5); } int XdmfSetGeometry(long * pointer, int * geometryType, int * numValues, int * arrayType, void * pointValues) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); return xdmfFortran->setGeometry(*geometryType, *numValues, *arrayType, pointValues); } void XdmfClearGeometryHeavyData(long * pointer) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); return xdmfFortran->clearGeometryHeavyData(); } void XdmfSetGeometryHDF5(long * pointer, char * hdf5File, char * hdf5Dataset, unsigned int * start, unsigned int * stride, unsigned int * numValues, unsigned int * dataspace) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->setGeometryHDF5(hdf5File, hdf5Dataset, *start, *stride, *numValues, *dataspace); } void XdmfSetGeometryBinary(long * pointer, char * binFile, int * endian, unsigned int * seek, unsigned int * start, unsigned int * stride, unsigned int * numValues, unsigned int * dataspace) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->setGeometryBinary(binFile, *endian, *seek, *start, *stride, *numValues, *dataspace); } void XdmfSetPreviousGeometry(long * pointer, int * geometryId) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->setPreviousGeometry(*geometryId); } void XdmfSetPreviousTopology(long * pointer, int * topologyId) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->setPreviousTopology(*topologyId); } void XdmfSetTime(long * pointer, double * time) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->setTime(*time); } int XdmfSetTopology(long * pointer, int * topologyType, int * numValues, int * arrayType, void * connectivityValues) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); return xdmfFortran->setTopology(*topologyType, *numValues, *arrayType, connectivityValues, 0); } void XdmfClearTopologyHeavyData(long * pointer) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); return xdmfFortran->clearTopologyHeavyData(); } void XdmfSetTopologyHDF5(long * pointer, char * hdf5File, char * hdf5Dataset, unsigned int * start, unsigned int * stride, unsigned int * numValues, unsigned int * dataspace) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->setTopologyHDF5(hdf5File, hdf5Dataset, *start, *stride, *numValues, *dataspace); } void XdmfsetTopologyBinary(long * pointer, char * binFile, int * endian, unsigned int * seek, unsigned int * start, unsigned int * stride, unsigned int * numValues, unsigned int * dataspace) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->setTopologyBinary(binFile, *endian, *seek, *start, *stride, *numValues, *dataspace); } void XdmfRetrieveNumDomainGridCollections(long * pointer, int * total) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *total = xdmfFortran->retrieveNumDomainGridCollections(); } void XdmfRetrieveNumGridCollectionGridCollections(long * pointer, int * total) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *total = xdmfFortran->numGridCollectionGridCollections(); } void XdmfRetrieveDomainTag(long * pointer, char * tag, int * tagLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveDomainTag(tag, *tagLength); } void XdmfRetrieveDomainNumProperties(long * pointer, int * total) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *total = xdmfFortran->retrieveDomainNumProperties(); } void XdmfRetrieveDomainProperty(long * pointer, int * index, char * key, int * keyLength, char * value, int * valueLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveDomainProperty(*index, key, *keyLength, value, *valueLength); } void XdmfRetrieveDomainPropertyByKey(long * pointer, char * key, char * value, int * valueLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveDomainPropertyByKey(key, value, *valueLength); } void XdmfOpenDomainGridCollection(long * pointer, int * index, int * openMaps, int * openAttributes, int * openInformation, int * openSets) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->openDomainGridCollection(*index, *openMaps, *openAttributes, *openInformation, *openSets); } void XdmfReadDomainGridCollection(long * pointer, int * index) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->readDomainGridCollection(*index); } void XdmfRemoveDomainGridCollection(long * pointer, int * index) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->removeDomainGridCollection(*index); } void XdmfOpenGridCollectionGridCollection(long * pointer, int * index, int * openMaps, int * openAttributes, int * openInformation, int * openSets) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->openGridCollectionGridCollection(*index, *openMaps, *openAttributes, *openInformation, *openSets); } void XdmfReadGridCollectionGridCollection(long * pointer, int * index) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->readGridCollectionGridCollection(*index); } void XdmfRemoveGridCollectionGridCollection(long * pointer, int * index) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->removeGridCollectionGridCollection(*index); } void XdmfRetrieveGridCollectionTag(long * pointer, char * tag, int * tagLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveGridCollectionTag(tag, *tagLength); } void XdmfRetrieveGridCollectionNumProperties(long * pointer, int * total) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *total = xdmfFortran->retrieveGridCollectionNumProperties(); } void XdmfRetrieveGridCollectionProperty(long * pointer, int * index, char * key, int * keyLength, char * value, int * valueLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveGridCollectionProperty(*index, key, *keyLength, value, *valueLength); } void XdmfRetrieveGridCollectionPropertyByKey(long * pointer, char * key, char * value, int * valueLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveGridCollectionPropertyByKey(key, value, *valueLength); } void XdmfRetrieveGridCollectionNumGrids(long * pointer, int * gridType, int * total) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *total = xdmfFortran->numGridCollectionGrids(*gridType); } void XdmfRetrieveDomainNumGrids(long * pointer, int * gridType, int * total) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *total = xdmfFortran->numDomainGrids(*gridType); } void XdmfOpenDomainGrid(long * pointer, int * gridType, int * index, int * openMaps, int * openAttributes, int * openInformation, int * openSets) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->openDomainGrid(*gridType, *index, *openMaps, *openAttributes, *openInformation, *openSets); } void XdmfReadDomainGrid(long * pointer, int * gridType, int * index) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->readDomainGrid(*gridType, *index); } void XdmfRemoveDomainGrid(long * pointer, int * gridType, int * index) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->removeDomainGrid(*gridType, *index); } void XdmfReplaceDomainGrid(long * pointer, int * gridType, int * index, char * name) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->replaceDomainGrid(*gridType, *index, name); } void XdmfRetrieveDomainGridTag(long * pointer, int * gridType, int * index, char * tag, int * tagLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveDomainGridTag(*gridType, *index, tag, *tagLength); } void XdmfRetrieveDomainGridName(long * pointer, int * gridType, int * index, char * name, int * nameLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveDomainGridName(*gridType, *index, name, *nameLength); } void XdmfRetrieveDomainGridNumProperties(long * pointer, int * gridType, int * index, int * total) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *total = xdmfFortran->retrieveDomainGridNumProperties(*gridType, *index); } void XdmfRetrieveDomainGridProperty(long * pointer, int * gridType, int * gridIndex, int * index, char * key, int * keyLength, char * value, int * valueLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveDomainGridProperty(*gridType, *gridIndex, *index, key, *keyLength, value, *valueLength); } void XdmfRetrieveDomainGridPropertyByKey(long * pointer, int * gridType, int * index, char * key, char * value, int * valueLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveDomainGridPropertyByKey(*gridType, *index, key, value, *valueLength); } void XdmfOpenGridCollectionGrid(long * pointer, int * gridType, int * index, int * openMaps, int * openAttributes, int * openInformation, int * openSets) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->openGridCollectionGrid(*gridType, *index, *openMaps, *openAttributes, *openInformation, *openSets); } void XdmfReadGridCollectionGrid(long * pointer, int * gridType, int * index) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->readGridCollectionGrid(*gridType, *index); } void XdmfRemoveGridCollectionGrid(long * pointer, int * gridType, int * index) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->removeGridCollectionGrid(*gridType, *index); } void XdmfReplaceGridCollectionGrid(long * pointer, int * gridType, int * index, char * name) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->replaceGridCollectionGrid(*gridType, *index, name); } void XdmfRetrieveGridCollectionGridTag(long * pointer, int * gridType, int * index, char * tag, int * tagLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveGridCollectionGridTag(*gridType, *index, tag, *tagLength); } void XdmfRetrieveGridCollectionGridName(long * pointer, int * gridType, int * index, char * name, int * nameLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveGridCollectionGridName(*gridType, *index, name, *nameLength); } void XdmfRetrieveGridCollectionGridNumProperties(long * pointer, int * gridType, int * index, int * total) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *total = xdmfFortran->retrieveGridCollectionGridNumProperties(*gridType, *index); } void XdmfRetrieveGridCollectionGridProperty(long * pointer, int * gridType, int * gridIndex, int * index, char * key, int * keyLength, char * value, int * valueLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveGridCollectionGridProperty(*gridType, *gridIndex, *index, key, *keyLength, value, *valueLength); } void XdmfRetrieveGridCollectionGridPropertyByKey(long * pointer, int * gridType, int *index, char * key, char * value, int * valueLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveGridCollectionGridPropertyByKey(*gridType, *index, key, value, *valueLength); } void XdmfRetrieveGridCollectionType(long * pointer, int * returnType) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *returnType = xdmfFortran->retrieveGridCollectionType(); } void XdmfRetrieveTime(long * pointer, double * total) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *total = xdmfFortran->retrieveTime(); } void XdmfRetrieveTopologyTag(long * pointer, char * tag, int * tagLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveTopologyTag(tag, *tagLength); } void XdmfRetrieveTopologyValues(long * pointer, void * values, int * dataType, int * numberRead, int * startIndex, int * arrayStride, int * valueStride) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveTopologyValues(values, *dataType, *numberRead, *startIndex, *arrayStride, *valueStride); } void XdmfRetrieveTopologyType(long * pointer, int * returnType) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *returnType = xdmfFortran->retrieveTopologyType(); } void XdmfRetrieveTopologyValueType(long * pointer, int * returnType) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *returnType = xdmfFortran->retrieveTopologyValueType(); } void XdmfRetrieveTopologyNumElements(long * pointer, int * total) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *total = xdmfFortran->retrieveTopologyNumElements(); } void XdmfRetrieveTopologySize(long * pointer, int * total) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *total = xdmfFortran->retrieveTopologySize(); } void XdmfClearPreviousTopologies(long * pointer) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->clearPreviousTopologies(); } void XdmfModifyTopologyValues(long * pointer, void * values, int * arrayType, int * numValues, int * startIndex, int * arrayStride, int * valueStride) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->modifyTopologyValues(values, *arrayType, *numValues, *startIndex, *arrayStride, *valueStride); } void XdmfRetrieveTopologyNumProperties(long * pointer, int * total) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *total = xdmfFortran->retrieveTopologyNumProperties(); } void XdmfRetrieveTopologyProperty(long * pointer, int * index, char * key, int * keyLength, char * value, int * valueLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveTopologyProperty(*index, key, *keyLength, value, *valueLength); } void XdmfRetrieveTopologyPropertyByKey(long * pointer, char * key, char * value, int * valueLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveTopologyPropertyByKey(key, value, *valueLength); } void XdmfSetTopologyAsVariable(long * pointer, char * varname) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->setTopologyAsVariable(varname); } void XdmfSetTopologyAsSubsetReference(long * pointer) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->setTopologyAsSubsetReference(); } void XdmfRetrieveGeometryTag(long * pointer, char * tag, int * tagLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveGeometryTag(tag, *tagLength); } void XdmfRetrieveGeometryValues(long * pointer, void * values, int * dataType, int * numberRead, int * startIndex, int * arrayStride, int * valueStride) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveGeometryValues(values, *dataType, *numberRead, *startIndex, *arrayStride, *valueStride); } void XdmfRetrieveGeometryType(long * pointer, int * returnType) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *returnType = xdmfFortran->retrieveGeometryType(); } void XdmfRetrieveGeometryValueType(long * pointer, int * returnType) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *returnType = xdmfFortran->retrieveGeometryValueType(); } void XdmfRetrieveGeometryNumPoints(long * pointer, int * total) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *total = xdmfFortran->retrieveGeometryNumPoints(); } void XdmfRetrieveGeometrySize(long * pointer, int * total) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *total = xdmfFortran->retrieveGeometrySize(); } void XdmfClearPreviousGeometries(long * pointer) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->clearPreviousGeometries(); } void XdmfModifyGeometryValues(long * pointer, void * values, int * arrayType, int * numValues, int * startIndex, int * arrayStride, int * valueStride) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->modifyGeometryValues(values, *arrayType, *numValues, *startIndex, *arrayStride, *valueStride); } void XdmfRetrieveGeometryNumProperties(long * pointer, int * total) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *total = xdmfFortran->retrieveGeometryNumProperties(); } void XdmfRetrieveGeometryProperty(long * pointer, int * index, char * key, int * keyLength, char * value, int * valueLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveGeometryProperty(*index, key, *keyLength, value, *valueLength); } void XdmfRetrieveGeometryPropertyByKey(long * pointer, char * key, char * value, int * valueLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveGeometryPropertyByKey(key, value, *valueLength); } void XdmfSetGeometryAsVariable(long * pointer, char * varname) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->setGeometryAsVariable(varname); } void XdmfSetGeometryAsSubsetReference(long * pointer) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->setGeometryAsSubsetReference(); } int XdmfSetDimensions(long * pointer, int * numValues, int * arrayType, void * pointValues) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); return xdmfFortran->setDimensions(*numValues, *arrayType, pointValues); } void XdmfClearDimensionsHeavyData(long * pointer) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); return xdmfFortran->clearDimensionsHeavyData(); } void XdmfSetDimensionsHDF5(long * pointer, char * hdf5File, char * hdf5Dataset, unsigned int * start, unsigned int * stride, unsigned int * numValues, unsigned int * dataspace) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->setDimensionsHDF5(hdf5File, hdf5Dataset, *start, *stride, *numValues, *dataspace); } void XdmfSetDimensionsBinary(long * pointer, char * binFile, int * endian, unsigned int * seek, unsigned int * start, unsigned int * stride, unsigned int * numValues, unsigned int * dataspace) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->setDimensionsBinary(binFile, *endian, *seek, *start, *stride, *numValues, *dataspace); } void XdmfOpenPreviousDimensions(long * pointer, int * index) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->openPreviousDimensions(*index); } void XdmfClearPreviousDimensions(long * pointer) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->clearPreviousDimensions(); } void XdmfModifyDimensionsValues(long * pointer, void * values, int * arrayType, int * numValues, int * startIndex, int * arrayStride, int * valueStride) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->modifyDimensionsValues(values, *arrayType, *numValues, *startIndex, *arrayStride, *valueStride); } void XdmfRetrieveDimensionsTag(long * pointer, char * tag, int * tagLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveDimensionsTag(tag, *tagLength); } void XdmfRetrieveDimensionsValues(long * pointer, void * values, int * dataType, int * numberRead, int * startIndex, int * arrayStride, int * valueStride) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveDimensionsValues(values, *dataType, *numberRead, *startIndex, *arrayStride, *valueStride); } void XdmfRetrieveDimensionsValueType(long * pointer, int * returnType) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *returnType = xdmfFortran->retrieveDimensionsValueType(); } void XdmfRetrieveDimensionsSize(long * pointer, int * total) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *total = xdmfFortran->retrieveDimensionsSize(); } void XdmfRetrieveDimensionsNumProperties(long * pointer, int * total) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *total = xdmfFortran->retrieveDimensionsNumProperties(); } void XdmfRetrieveDimensionsProperty(long * pointer, int * index, char * key, int * keyLength, char * value, int * valueLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveDimensionsProperty(*index, key, *keyLength, value, *valueLength); } void XdmfRetrieveDimensionsPropertyByKey(long * pointer, char * key, char * value, int * valueLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveDimensionsPropertyByKey(key, value, *valueLength); } int XdmfSetOrigin(long * pointer, int * numValues, int * arrayType, void * pointValues) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); return xdmfFortran->setOrigin(*numValues, *arrayType, pointValues); } void XdmfClearOriginHeavyData(long * pointer) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); return xdmfFortran->clearOriginHeavyData(); } void XdmfSetOriginHDF5(long * pointer, char * hdf5File, char * hdf5Dataset, unsigned int * start, unsigned int * stride, unsigned int * numValues, unsigned int * dataspace) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->setOriginHDF5(hdf5File, hdf5Dataset, *start, *stride, *numValues, *dataspace); } void XdmfSetOriginBinary(long * pointer, char * binFile, int * endian, unsigned int * seek, unsigned int * start, unsigned int * stride, unsigned int * numValues, unsigned int * dataspace) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->setOriginBinary(binFile, *endian, *seek, *start, *stride, *numValues, *dataspace); } void XdmfSetPreviousOrigin(long * pointer, int * index) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->setPreviousOrigin(*index); } void XdmfClearPreviousOrigins(long * pointer) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->clearPreviousOrigins(); } void XdmfModifyOriginValues(long * pointer, void * values, int * arrayType, int * numValues, int * startIndex, int * arrayStride, int * valueStride) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->modifyOriginValues(values, *arrayType, *numValues, *startIndex, *arrayStride, *valueStride); } void XdmfRetrieveOriginTag(long * pointer, char * tag, int * tagLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveOriginTag(tag, *tagLength); } void XdmfRetrieveOriginValues(long * pointer, void * values, int * dataType, int * numberRead, int * startIndex, int * arrayStride, int * valueStride) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveOriginValues(values, *dataType, *numberRead, *startIndex, *arrayStride, *valueStride); } void XdmfRetrieveOriginValueType(long * pointer, int * returnType) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *returnType = xdmfFortran->retrieveOriginValueType(); } void XdmfRetrieveOriginSize(long * pointer, int * total) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *total = xdmfFortran->retrieveOriginSize(); } void XdmfRetrieveOriginNumProperties(long * pointer, int * total) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *total = xdmfFortran->retrieveOriginNumProperties(); } void XdmfRetrieveOriginProperty(long * pointer, int * index, char * key, int * keyLength, char * value, int * valueLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveOriginProperty(*index, key, *keyLength, value, *valueLength); } void XdmfRetrieveOriginPropertyByKey(long * pointer, char * key, char * value, int * valueLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveOriginPropertyByKey(key, value, *valueLength); } int XdmfSetBrick(long * pointer, int * numValues, int * arrayType, void * pointValues) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); return xdmfFortran->setBrick(*numValues, *arrayType, pointValues); } void XdmfClearBrickHeavyData(long * pointer) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); return xdmfFortran->clearBrickHeavyData(); } void XdmfSetBrickHDF5(long * pointer, char * hdf5File, char * hdf5Dataset, unsigned int * start, unsigned int * stride, unsigned int * numValues, unsigned int * dataspace) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->setBrickHDF5(hdf5File, hdf5Dataset, *start, *stride, *numValues, *dataspace); } void XdmfSetBrickBinary(long * pointer, char * binFile, int * endian, unsigned int * seek, unsigned int * start, unsigned int * stride, unsigned int * numValues, unsigned int * dataspace) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->setBrickBinary(binFile, *endian, *seek, *start, *stride, *numValues, *dataspace); } void XdmfSetPreviousBrick(long * pointer, int * index) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->setPreviousBrick(*index); } void XdmfClearPreviousBricks(long * pointer) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->clearPreviousBricks(); } void XdmfModifyBrickValues(long * pointer, void * values, int * arrayType, int * numValues, int * startIndex, int * arrayStride, int * valueStride) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->modifyBrickValues(values, *arrayType, *numValues, *startIndex, *arrayStride, *valueStride); } void XdmfRetrieveBrickTag(long * pointer, char * tag, int * tagLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveBrickTag(tag, *tagLength); } void XdmfRetrieveBrickValues(long * pointer, void * values, int * dataType, int * numberRead, int * startIndex, int * arrayStride, int * valueStride) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveBrickValues(values, *dataType, *numberRead, *startIndex, *arrayStride, *valueStride); } void XdmfRetrieveBrickValueType(long * pointer, int * returnType) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *returnType = xdmfFortran->retrieveBrickValueType(); } void XdmfRetrieveBrickSize(long * pointer, int * total) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *total = xdmfFortran->retrieveBrickSize(); } void XdmfRetrieveBrickNumProperties(long * pointer, int * total) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *total = xdmfFortran->retrieveBrickNumProperties(); } void XdmfRetrieveBrickProperty(long * pointer, int * index, char * key, int * keyLength, char * value, int * valueLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveBrickProperty(*index, key, *keyLength, value, *valueLength); } void XdmfRetrieveBrickPropertyByKey(long * pointer, char * key, char * value, int * valueLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveBrickPropertyByKey(key, value, *valueLength); } void XdmfAddMap(long * pointer, char * name) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->addMap(name); } void XdmfRetrieveNumMaps(long * pointer, int * total) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *total = xdmfFortran->retrieveNumMaps(); } void XdmfRetrieveMapTag(long * pointer, int * index, char * tag, int * tagLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveMapTag(*index, tag, *tagLength); } void XdmfAddRemoteNodeID(long * pointer, int * index, int * localNodeID, int * remoteTaskID, int * remoteLocalNodeID) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->addRemoteNodeID(*index, *localNodeID, *remoteTaskID, *remoteLocalNodeID); } void XdmfRetrieveRemoteNodeIDs(long * pointer, int * index, int * localNodeID, int * remoteTaskID, int * remoteLocalNodeIDs) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveRemoteNodeIDs(*index, *localNodeID, *remoteTaskID, remoteLocalNodeIDs); } void XdmfRetrieveNumRemoteNodeIDs(long * pointer, int * index, int * localNodeID, int * remoteTaskID, int * total) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *total = xdmfFortran->retrieveNumRemoteNodeIDs(*index, *localNodeID, *remoteTaskID); } void XdmfClearMaps(long * pointer) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->clearMaps(); } void XdmfRemoveMap(long * pointer, int * index) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->removeMap(*index); } int XdmfStoreMap(long * pointer, int * index) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); return xdmfFortran->storeMap(*index); } void XdmfAddPreviousMap(long * pointer, int * index) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->addPreviousMap(*index); } void XdmfClearPreviousMaps(long * pointer) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->clearPreviousMaps(); } void XdmfRetrieveMapNumProperties(long * pointer, int * index, int * total) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *total = xdmfFortran->retrieveMapNumProperties(*index); } void XdmfRetrieveMapProperty(long * pointer, int * mapIndex, int * index, char * key, int * keyLength, char * value, int * valueLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveMapProperty(*mapIndex, *index, key, *keyLength, value, *valueLength); } void XdmfRetrieveMapPropertyByKey(long * pointer, int * index, char * key, char * value, int * valueLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveMapPropertyByKey(*index, key, value, *valueLength); } void XdmfClearAttributes(long * pointer) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->clearAttributes(); } void XdmfModifyAttributeValues(long * pointer, int * index, void * values, int * arrayType, int * numValues, int * startIndex, int * arrayStride, int * valueStride) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->modifyAttributeValues(*index, values, *arrayType, *numValues, *startIndex, *arrayStride, *valueStride); } void XdmfRetrieveNumAttributes(long * pointer, int * total) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *total = xdmfFortran->retrieveNumAttributes(); } void XdmfReplaceAttribute(long * pointer, int * index, char * name, int * attributeCenter, int * attributeType, int * numValues, int * arrayType, void * values) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->replaceAttribute(*index, name, *attributeCenter, *attributeType, *numValues, *arrayType, values); } void XdmfRemoveAttribute(long * pointer, int * index) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->removeAttribute(*index); } void XdmfOpenAttribute(long * pointer, int * index) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->openAttribute(*index); } void XdmfRetrieveAttributeTag(long * pointer, int * index, char * tag, int * tagLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveAttributeTag(*index, tag, *tagLength); } void XdmfRetrieveAttributeName(long * pointer, int * index, char * name, int * nameLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveAttributeName(*index, name, *nameLength); } void XdmfRetrieveAttributeValues(long * pointer, int * index, void * values, int * dataType, int * numberRead, int * startIndex, int * arrayStride, int * valueStride) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveAttributeValues(*index, values, *dataType, *numberRead, *startIndex, *arrayStride, *valueStride); } void XdmfRetrieveAttributeType(long * pointer, int * index, int * returnType) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *returnType = xdmfFortran->retrieveAttributeType(*index); } void XdmfRetrieveAttributeCenter(long * pointer, int * index, int * returnCenter) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *returnCenter = xdmfFortran->retrieveAttributeCenter(*index); } void XdmfRetrieveAttributeValueType(long * pointer, int * index, int * returnType) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *returnType = xdmfFortran->retrieveAttributeValueType(*index); } void XdmfRetrieveAttributeSize(long * pointer, int * index, int * total) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *total = xdmfFortran->retrieveAttributeSize(*index); } void XdmfClearPreviousAttributes(long * pointer) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->clearPreviousAttributes(); } void XdmfRetrieveAttributeNumProperties(long * pointer, int * index, int * total) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *total = xdmfFortran->retrieveAttributeNumProperties(*index); } void XdmfRetrieveAttributeProperty(long * pointer, int * attributeIndex, int * index, char * key, int * keyLength, char * value, int * valueLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveAttributeProperty(*attributeIndex, *index, key, *keyLength, value, *valueLength); } void XdmfRetrieveAttributePropertyByKey(long * pointer, int * index, char * key, char * value, int * valueLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveAttributePropertyByKey(*index, key, value, *valueLength); } void XdmfSetAttributeAsVariable(long * pointer, char * varname, int * index) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->setAttributeAsVariable(varname, *index); } void XdmfSetAttributeAsSubsetReference(long * pointer, int * index) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->setAttributeAsSubsetReference(*index); } void XdmfRetrieveNumCoordinates(long * pointer, int * total) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *total = xdmfFortran->retrieveNumCoordinates(); } int XdmfAddCoordinate(long * pointer, char * name, int * numValues, int * arrayType, void * values) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); return xdmfFortran->addCoordinate(name, *numValues, *arrayType, values); } void XdmfClearCoordinateHeavyData(long * pointer, int * index) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); return xdmfFortran->clearCoordinateHeavyData(*index); } void XdmfSetCoordinateHDF5(long * pointer, int * index, char * hdf5File, char * hdf5Dataset, unsigned int * start, unsigned int * stride, unsigned int * numValues, unsigned int * dataspace) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->setCoordinateHDF5(*index, hdf5File, hdf5Dataset, *start, *stride, *numValues, *dataspace); } void XdmfSetCoordinateBinary(long * pointer, int * index, char * binFile, int * endian, unsigned int * seek, unsigned int * start, unsigned int * stride, unsigned int * numValues, unsigned int * dataspace) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->setCoordinateBinary(*index, binFile, *endian, *seek, *start, *stride, *numValues, *dataspace); } void XdmfAddPreviousCoordinate(long * pointer, int * index) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->addPreviousCoordinate(*index); } void XdmfClearPreviousCoordinates(long * pointer) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->clearPreviousCoordinates(); } void XdmfReplaceCoordinate(long * pointer, int * index, char * name, int * numValues, int * arrayType, void * values) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->replaceCoordinate(*index, name, *numValues, *arrayType, values); } void XdmfRemoveCoordinate(long * pointer, int * index) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->removeCoordinate(*index); } void XdmfRetrieveCoordinateTag(long * pointer, int * index, char * tag, int * tagLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveCoordinateTag(*index, tag, *tagLength); } void XdmfRetrieveCooridnateName(long * pointer, int * index, char * name, int * nameLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveCoordinateName(*index, name, *nameLength); } void XdmfRetrieveCoordinateValues(long * pointer, int * index, void * values, int * dataType, int * numberRead, int * startIndex, int * arrayStride, int * valueStride) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveCoordinateValues(*index, values, *dataType, *numberRead, *startIndex, *arrayStride, *valueStride); } void XdmfRetrieveCoordinateValueType(long * pointer, int * index, int * returnType) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *returnType = xdmfFortran->retrieveCoordinateValueType(*index); } void XdmfRetrieveCoordinateSize(long * pointer, int * index, int * total) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *total = xdmfFortran->retrieveCoordinateSize(*index); } void XdmfClearCoordinates(long * pointer) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->clearCoordinates(); } void XdmfModifyCoordinateValues(long * pointer, int * index, void * values, int * arrayType, int * numValues, int * startIndex, int * arrayStride, int * valueStride) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->modifyCoordinateValues(*index, values, *arrayType, *numValues, *startIndex, *arrayStride, *valueStride); } void XdmfRetrieveCoordinateNumProperties(long * pointer, int * index, int * total) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *total = xdmfFortran->retrieveCoordinateNumProperties(*index); } void XdmfRetrieveCoordinateProperty(long * pointer, int * coordinateIndex, int * index, char * key, int * keyLength, char * value, int * valueLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveCoordinateProperty(*coordinateIndex, *index, key, *keyLength, value, *valueLength); } void XdmfRetrieveCoordinatePropertyByKey(long * pointer, int * index, char * key, char * value, int * valueLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveCoordinatePropertyByKey(*index, key, value, *valueLength); } void XdmfSetCoordinateAsVariable(long * pointer, char * varname, int * index) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->setCoordinateAsVariable(varname, *index); } void XdmfSetCoordinateAsSubsetReference(long * pointer, int * index) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->setCoordinateAsSubsetReference(*index); } void XdmfRetrieveSetTag(long * pointer, int * index, char * tag, int * tagLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveSetTag(*index, tag, *tagLength); } void XdmfRetrieveSetName(long * pointer, int * index, char * name, int * nameLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveSetTag(*index, name, *nameLength); } void XdmfRetrieveSetType(long * pointer, int * index, int * returnType) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *returnType = xdmfFortran->retrieveSetType(*index); } int XdmfAddSet(long * pointer, char * name, int * newSetType, char * values, int * numValues, int * arrayType) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); return xdmfFortran->addSet(name, *newSetType, values, *numValues, *arrayType); } void XdmfClearSetHeavyData(long * pointer, int * index) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); return xdmfFortran->clearSetHeavyData(*index); } void XdmfSetSetHDF5(long * pointer, int * index, char * hdf5File, char * hdf5Dataset, unsigned int * start, unsigned int * stride, unsigned int * numValues, unsigned int * dataspace) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->setSetHDF5(*index, hdf5File, hdf5Dataset, *start, *stride, *numValues, *dataspace); } void XdmfSetSetBinary(long * pointer, int * index, char * binFile, int * endian, unsigned int * seek, unsigned int * start, unsigned int * stride, unsigned int * numValues, unsigned int * dataspace) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->setSetBinary(*index, binFile, *endian, *seek, *start, *stride, *numValues, *dataspace); } void XdmfAddPreviousSet(long * pointer, int * index) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->addPreviousSet(*index); } void XdmfClearPreviousSets(long * pointer) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->clearPreviousSets(); } void XdmfClearSets(long * pointer) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->clearSets(); } void XdmfModifySetValues(long * pointer, int * index, void * values, int * arrayType, int * numValues, int * startIndex, int * arrayStride, int * valueStride) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->modifySetValues(*index, values, *arrayType, *numValues, *startIndex, *arrayStride, *valueStride); } void XdmfRetrieveNumSets(long * pointer, int * total) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *total = xdmfFortran->retrieveNumSets(); } void XdmfRetrieveSetSize(long * pointer, int * total, int * index) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *total = xdmfFortran->retrieveSetSize(*index); } void XdmfRetrieveSetValueType(long * pointer, int * index, int * returnType) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *returnType = xdmfFortran->retrieveSetValueType(*index); } void XdmfRetrieveSetValues(long * pointer, int * index, void * values, int * dataType, int * numberRead, int * startIndex, int * arrayStride, int * valueStride) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveSetValues(*index, values, *dataType, *numberRead, *startIndex, *arrayStride, *valueStride); } void XdmfOpenSet(long * pointer, int * index, int * openAttributes, int * openInformation) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->openSet(*index, *openAttributes, *openInformation); } void XdmfRemoveSet(long * pointer, int * index) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->removeSet(*index); } void XdmfReplaceSet(long * pointer, int * index, char * name, int * newSetType, char * values, int * numValues, int * arrayType) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->replaceSet(*index, name, *newSetType, values, *numValues, *arrayType); } void XdmfRetrieveSetNumProperties(long * pointer, int * index, int * total) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *total = xdmfFortran->retrieveSetNumProperties(*index); } void XdmfRetrieveSetProperty(long * pointer, int * setIndex, int * index, char * key, int * keyLength, char * value, int * valueLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveSetProperty(*setIndex, *index, key, *keyLength, value, *valueLength); } void XdmfRetrieveSetPropertyByKey(long * pointer, int * index, char * key, char * value, int * valueLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveSetPropertyByKey(*index, key, value, *valueLength); } void XdmfSetSetAsVariable(long * pointer, char * varname, int * index) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->setSetAsVariable(varname, *index); } void XdmfSetSetAsSubsetReference(long * pointer, int * index) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->setSetAsSubsetReference(*index); } void XdmfRetrieveNumInformation(long * pointer, int * total) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *total = xdmfFortran->retrieveNumInformation(); } void XdmfRetrieveInformationTag(long * pointer, int * index, char * tag, int * tagLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveInformationTag(*index, tag, *tagLength); } void XdmfRetrieveInformation(long * pointer, int * index, char * key, int * keyLength, char * value, int * valueLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveInformation(*index, key, *keyLength, value, *valueLength); } void XdmfRemoveInformation(long * pointer, int * index) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->removeInformation(*index); } void XdmfReplaceInformation(long * pointer, int * index, char * key, char * value) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->replaceInformation(*index, key, value); } void XdmfOpenInformation(long * pointer, int * index) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->openInformation(*index); } void XdmfRetrieveInformationByKey(long * pointer, char * key, char * value, int * valueLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveInformationByKey(key, value, *valueLength); } void XdmfRemoveInformationByKey(long * pointer, char * key) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->removeInformationByKey(key); } void XdmfReplaceInformationByKey(long * pointer, char * key, char * value) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->replaceInformationByKey(key, value); } void XdmfClearPreviousInformation(long * pointer) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->clearPreviousInformation(); } void XdmfClearInformations(long * pointer) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->clearInformations(); } void XdmfRetrieveInformationNumProperties(long * pointer, int * index, int * total) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *total = xdmfFortran->retrieveInformationNumProperties(*index); } void XdmfRetrieveInformationProperty(long * pointer, int * informationIndex, int * index, char * key, int * keyLength, char * value, int * valueLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveInformationProperty(*informationIndex, *index, key, *keyLength, value, *valueLength); } void XdmfRetrieveInformationPropertyByKey(long * pointer, int * index, char * key, char * value, int * valueLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveInformationPropertyByKey(*index, key, value, *valueLength); } void XdmfAddInformationArray(long * pointer, int * index, char * name, void * values, int * numValues, int * arrayType) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->addInformationArray(*index, name, values, *numValues, *arrayType); } void XdmfClearInformationArrayHeavyData(long * pointer, int * index, int * arrayIndex) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); return xdmfFortran->clearInformationArrayHeavyData(*index, *arrayIndex); } void XdmfSetInformationArrayHDF5(long * pointer, int * index, int * arrayIndex, char * hdf5File, char * hdf5Dataset, unsigned int * start, unsigned int * stride, unsigned int * numValues, unsigned int * dataspace) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->setInformationArrayHDF5(*index, *arrayIndex, hdf5File, hdf5Dataset, *start, *stride, *numValues, *dataspace); } void XdmfSetInformationArrayBinary(long * pointer, int * index, int * arrayIndex, char * binFile, int * endian, unsigned int * seek, unsigned int * start, unsigned int * stride, unsigned int * numValues, unsigned int * dataspace) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->setInformationArrayBinary(*index, *arrayIndex, binFile, *endian, *seek, *start, *stride, *numValues, *dataspace); } void XdmfInsertInformationIntoInformation(long * pointer, int * toIndex, int * fromIndex, bool * removeFromArray) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->insertInformationIntoInformation(*toIndex, *fromIndex, *removeFromArray); } void XdmfModifyInformationArray(long * pointer, int * index, int * arrayIndex, void * values, int * arrayType, int * numValues, int * insertStart, int * arrayStride, int * valueStride) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->modifyInformationArray(*index, *arrayIndex, values, *arrayType, *numValues, *insertStart, *arrayStride, *valueStride); } void XdmfRemoveInformationArray(long * pointer, int * index, int * arrayIndex) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->removeInformationArray(*index, *arrayIndex); } void XdmfRetrieveInformationArraySize(long * pointer, int * index, int * arrayIndex, int * total) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *total = xdmfFortran->retrieveInformationArraySize(*index, *arrayIndex); } void XdmfRetrieveInformationArrayValueType(long * pointer, int * index, int * arrayIndex, int * returnType) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); *returnType = xdmfFortran->retrieveInformationArrayValueType(*index, *arrayIndex); } void XdmfRetrieveInformationArrayValues(long * pointer, int * index, int * arrayIndex, void * values, int * dataType, int * numberRead, int * startIndex, int * arrayStride, int * valueStride) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveInformationArrayValues(*index, *arrayIndex, values, *dataType, *numberRead, *startIndex, *arrayStride, *valueStride); } void XdmfSetInformationArrayAsVariable(long * pointer, char * varname, int * infoindex, int * index) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->setInformationArrayAsVariable(varname, *infoindex, *index); } void XdmfSetInformationArrayAsSubsetReference(long * pointer, int * infoindex, int * index) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->setInformationArrayAsSubsetReference(*infoindex, *index); } int XdmfAddFunctionAsAttribute(long * pointer, char * expression, char * name, int * attributeCenter, int * attributeType) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); return xdmfFortran->addFunctionAsAttribute(expression, name, *attributeCenter, *attributeType); } int XdmfAddFunctionAsCoordinate(long * pointer, char * expression, char * name) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); return xdmfFortran->addFunctionAsCoordinate(expression, name); } int XdmfAddFunctionAsSet(long * pointer, char * expression, char * name, int * newSetType) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); return xdmfFortran->addFunctionAsSet(expression, name, *newSetType); } void XdmfAddFunctionAsInformationArray(long * pointer, char * expression, int * index, char * name) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->addFunctionAsInformationArray(expression, *index, name); } int XdmfSetFunctionAsTopology(long * pointer, char * expression, int * topologyType, int * numNodes) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); return xdmfFortran->setFunctionAsTopology(expression, *topologyType, *numNodes); } int XdmfSetFunctionAsGeometry(long * pointer, char * expression, int * geometryType) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); return xdmfFortran->setFunctionAsGeometry(expression, *geometryType); } int XdmfAddSubsetAsAttribute(long * pointer, int * start, int * stride, int * dimensions, char * name, int * attributeCenter, int * attributeType) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); return xdmfFortran->addSubsetAsAttribute(*start, *stride, *dimensions, name, *attributeCenter, *attributeType); } int XdmfAddSubsetAsCoordinate(long * pointer, int * start, int * stride, int * dimensions, char * name) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); return xdmfFortran->addSubsetAsCoordinate(*start, *stride, *dimensions, name); } int XdmfAddSubsetAsSet(long * pointer, int * start, int * stride, int * dimensions, char * name, int * newSetType) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); return xdmfFortran->addSubsetAsSet(*start, *stride, *dimensions, name, *newSetType); } void XdmfAddSubsetAsInformationArray(long * pointer, int * start, int * stride, int * dimensions, int * index, char * name) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->addSubsetAsInformationArray(*start, *stride, *dimensions, *index, name); } int XdmfSetSubsetAsTopology(long * pointer, int * start, int * stride, int * dimensions, int * topologyType, int * numNodes) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer);\ return xdmfFortran->setSubsetAsTopology(*start, *stride, *dimensions, *topologyType, *numNodes); } int XdmfSetSubsetAsGeometry(long * pointer, int * start, int * stride, int * dimensions, int * geometryType) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); return xdmfFortran->setSubsetAsGeometry(*start, *stride, *dimensions, *geometryType); } void XdmfClearFunctionVariables(long * pointer) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->clearFunctionVariables(); } void XdmfRemoveFunctionVariable(long * pointer, char * varname) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->removeFunctionVariable(varname); } void XdmfClearPrevious(long * pointer) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->clearPrevious(); } void XdmfSetAllowSetSplitting(long * pointer, bool * newAllow) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->setAllowSetSplitting(*newAllow); } void XdmfSetMaxFileSize(long * pointer, int * newSize) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->setMaxFileSize(*newSize); } void XdmfWrite(long * pointer, char * xmlFilePath, int * datalimit, bool * release) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->write(xmlFilePath, *datalimit, *release); } #ifdef XDMF_BUILD_DSM void XdmfInitDSMServer(long * pointer, char * filePath, MPI_Fint * comm, int * bufferSize, int * startCoreIndex, int * endCoreIndex) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); MPI_Comm tempComm = MPI_Comm_f2c(*comm); xdmfFortran->initDSMServer(filePath, tempComm, *bufferSize, *startCoreIndex, *endCoreIndex); } void XdmfAcceptDSM(long * pointer, int * numConnections) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->acceptDSM(*numConnections); } void XdmfCloseDSMPort(long * pointer) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->closeDSMPort(); } void XdmfConnectDSM(long * pointer, char * filePath, MPI_Fint * comm) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); MPI_Comm tempComm = MPI_Comm_f2c(*comm); xdmfFortran->connectDSM(filePath, tempComm); } void XdmfGetDSMInterComm(long * pointer, MPI_Fint * returnComm) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); MPI_Comm tempComm = xdmfFortran->getDSMInterComm(); *returnComm = MPI_Comm_c2f(tempComm); } void XdmfGetDSMIntraComm(long * pointer, MPI_Fint * returnComm) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); MPI_Comm tempComm = xdmfFortran->getDSMIntraComm(); *returnComm = MPI_Comm_c2f(tempComm); } void XdmfStopDSM(long * pointer) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->stopDSM(); } void XdmfReadFromDSM(long * pointer, char * dsmDataSetPath, int * arrayType, void * values, int * start, int * stride, int * dimensions, int * dataspace) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->readFromDSM(dsmDataSetPath, *arrayType, values, *start, *stride, *dimensions, *dataspace); } void XdmfWriteToDSM(long * pointer, char * dsmDataSetPath, int * arrayType, void * values, int * start, int * stride, int * dimensions, int * dataspace) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->writeToDSM(dsmDataSetPath, *arrayType, values, *start, *stride, *dimensions, *dataspace); } #endif void XdmfWriteHDF5(long * pointer, char * xmlFilePath, bool * release) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->writeHDF5(xmlFilePath, release); } void XdmfInitHDF5(long * pointer, char * xmlFilePath, bool * release) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->initHDF5(xmlFilePath, release); } void XdmfRead(long * pointer, char * xmlFilePath) { struct stat buffer; if ( stat(xmlFilePath, &buffer) == 0 ) { XdmfFortran * xdmfFortran = (XdmfFortran *) *pointer; xdmfFortran->read( xmlFilePath ); } } int XdmfSetTopologyPolyline(long * pointer, int * nodesPerElement, int * numValues, int * arrayType, void * connectivityValues) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); return xdmfFortran->setTopologyPolyline(*nodesPerElement, *numValues, *arrayType, connectivityValues); } int XdmfSetTopologyPolygon(long * pointer, int * nodesPerElement, int * numValues, int * arrayType, void * connectivityValues) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); return xdmfFortran->setTopologyPolygon(*nodesPerElement, *numValues, *arrayType, connectivityValues); } } xdmf-3.0+git20160803/utils/XdmfTopologyConverter.cpp0000640000175000017500000022140313003006557022263 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfTopologyConverter.cpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #include #include #include #include #include "XdmfAttribute.hpp" #include "XdmfAttributeCenter.hpp" #include "XdmfAttributeType.hpp" #include "XdmfGeometry.hpp" #include "XdmfGeometryType.hpp" #include "XdmfHeavyDataWriter.hpp" #include "XdmfSet.hpp" #include "XdmfSetType.hpp" #include "XdmfTopology.hpp" #include "XdmfTopologyConverter.hpp" #include "XdmfTopologyType.hpp" #include "XdmfUnstructuredGrid.hpp" #include "XdmfError.hpp" // // local methods // namespace { typedef std::pair, std::vector > OldFaceToNewFaceMap ; typedef std::vector > FaceHash; void handleSetConversion(const shared_ptr gridToConvert, const shared_ptr toReturn, const std::vector & oldIdToNewId, const shared_ptr heavyDataWriter) { for(unsigned int i=0; igetNumberSets(); ++i) { const shared_ptr set = gridToConvert->getSet(i); const shared_ptr setType = set->getType(); if(setType == XdmfSetType::Cell()) { toReturn->insert(set); } else if(setType == XdmfSetType::Node()) { bool releaseSet = false; if(!set->isInitialized()) { set->read(); releaseSet = true; } shared_ptr toReturnSet = XdmfSet::New(); toReturnSet->setName(set->getName()); toReturnSet->setType(set->getType()); toReturnSet->initialize(set->getArrayType(), set->getSize()); for(unsigned int i=0; igetSize(); ++i) { const unsigned int nodeId = set->getValue(i); const int newNodeId = oldIdToNewId[nodeId]; toReturnSet->insert(i, newNodeId); } if(releaseSet) { set->release(); } toReturn->insert(toReturnSet); if(heavyDataWriter) { toReturnSet->accept(heavyDataWriter); toReturnSet->release(); } } } } template void remapTopology(shared_ptr topology) { return; } template <> void remapTopology<2>(shared_ptr topology) { const unsigned int numberElements = topology->getNumberElements(); unsigned int oldElementIds[27]; unsigned int newElementIds[27]; unsigned int offset = 0; for(unsigned int i=0; igetValues(offset, oldElementIds, 27); newElementIds[0] = oldElementIds[0]; newElementIds[1] = oldElementIds[18]; newElementIds[2] = oldElementIds[24]; newElementIds[3] = oldElementIds[6]; newElementIds[4] = oldElementIds[2]; newElementIds[5] = oldElementIds[20]; newElementIds[6] = oldElementIds[26]; newElementIds[7] = oldElementIds[8]; newElementIds[8] = oldElementIds[9]; newElementIds[9] = oldElementIds[21]; newElementIds[10] = oldElementIds[15]; newElementIds[11] = oldElementIds[3]; newElementIds[12] = oldElementIds[11]; newElementIds[13] = oldElementIds[23]; newElementIds[14] = oldElementIds[17]; newElementIds[15] = oldElementIds[5]; newElementIds[16] = oldElementIds[1]; newElementIds[17] = oldElementIds[19]; newElementIds[18] = oldElementIds[25]; newElementIds[19] = oldElementIds[7]; newElementIds[20] = oldElementIds[4]; newElementIds[21] = oldElementIds[22]; newElementIds[22] = oldElementIds[10]; newElementIds[23] = oldElementIds[16]; newElementIds[24] = oldElementIds[12]; newElementIds[25] = oldElementIds[14]; newElementIds[26] = oldElementIds[13]; topology->insert(offset, newElementIds, 27); offset += 27; } } // Classes that perform topology conversions. Converter is the root // base class. Tessellator is a subclass of Converter that deals // with cases where the mesh only needs to be tessellated to carry // out the conversion (e.g. Hexahedron_64 to Hexahedron). class Converter { public: Converter() { } virtual ~Converter() { } virtual shared_ptr convert(const shared_ptr gridToConvert, const shared_ptr topologyType, const shared_ptr heavyDataWriter) const = 0; }; class Tessellator : public Converter { public: virtual ~Tessellator() { } shared_ptr convert(const shared_ptr gridToConvert, const shared_ptr topologyType, const shared_ptr heavyDataWriter) const { shared_ptr toReturn = XdmfUnstructuredGrid::New(); toReturn->setName(gridToConvert->getName()); toReturn->setGeometry(gridToConvert->getGeometry()); if(heavyDataWriter) { if(!toReturn->getGeometry()->isInitialized()) { toReturn->getGeometry()->read(); } toReturn->getGeometry()->accept(heavyDataWriter); toReturn->getGeometry()->release(); } bool releaseTopology = false; if(!gridToConvert->getTopology()->isInitialized()) { gridToConvert->getTopology()->read(); releaseTopology = true; } this->tesselateTopology(gridToConvert->getTopology(), toReturn->getTopology()); if(releaseTopology) { gridToConvert->getTopology()->release(); } if(heavyDataWriter) { toReturn->getTopology()->accept(heavyDataWriter); toReturn->getTopology()->release(); } for(unsigned int i=0; igetNumberAttributes(); ++i) { shared_ptr currAttribute = gridToConvert->getAttribute(i); shared_ptr createdAttribute = shared_ptr(); if(currAttribute->getCenter() == XdmfAttributeCenter::Node()) { createdAttribute = currAttribute; } else if(currAttribute->getCenter() == XdmfAttributeCenter::Cell()) { bool releaseAttribute = false; if(!currAttribute->isInitialized()) { currAttribute->read(); releaseAttribute = true; } createdAttribute = XdmfAttribute::New(); createdAttribute->setName(currAttribute->getName()); createdAttribute->setType(currAttribute->getType()); createdAttribute->setCenter(currAttribute->getCenter()); createdAttribute->initialize(currAttribute->getArrayType(), currAttribute->getSize() * mNumTesselations); for(unsigned int j=0; jgetSize(); ++j) { createdAttribute->insert(j * mNumTesselations, currAttribute, j, mNumTesselations, 1, 0); } if(releaseAttribute) { currAttribute->release(); } } if(createdAttribute) { toReturn->insert(createdAttribute); if(heavyDataWriter) { if(!createdAttribute->isInitialized()) { createdAttribute->read(); } createdAttribute->accept(heavyDataWriter); createdAttribute->release(); } } } return toReturn; } virtual void tesselateTopology(shared_ptr topologyToConvert, shared_ptr topologyToReturn) const = 0; protected: Tessellator(const unsigned int numTesselations) : mNumTesselations(numTesselations) { } const unsigned int mNumTesselations; }; template class HexahedronToHighOrderHexahedron : public Converter { public: HexahedronToHighOrderHexahedron() { } virtual ~HexahedronToHighOrderHexahedron() { } int reorder(unsigned int & a, unsigned int & b, unsigned int & c, unsigned int & d) const { int tmp; // Reorder to get smallest id in a. if (b < a && b < c && b < d) { tmp = a; a = b; b = c; c = d; d = tmp; return 1; } else if (c < a && c < b && c < d) { tmp = a; a = c; c = tmp; tmp = b; b = d; d = tmp; return 2; } else if (d < a && d < b && d < c) { tmp = a; a = d; d = c; c = b; b = tmp; return 3; } return 0; } void rotateQuad(unsigned int reorderVal, const std::vector & face, std::vector & newFace) const { switch (reorderVal) { case 0: { std::copy(face.begin(), face.end(), newFace.begin()); return; } case 1: { unsigned int index = 0; for(unsigned int i=mNodesPerEdge; i>0; --i) { for(unsigned int j=i-1; j=0; j-=mNodesPerEdge) { newFace[index++] = face[j]; } } return; } } } void addEdgeToHash(unsigned int a, unsigned int b, FaceHash & hash, std::vector & edge) const { // reorder to get lowest id in a bool swapped = false; if(a > b) { std::swap(a, b); swapped = true; } std::vector newEdge(edge.size()); if(swapped) { for(unsigned int i=0; i currEdge(1); currEdge[0] = b; currHash.push_back(std::make_pair(currEdge, newEdge)); } void addFaceToHash(unsigned int a, unsigned int b, unsigned int c, unsigned int d, FaceHash & hash, std::vector & face) const { const unsigned int reorderVal = reorder(a, b, c, d); std::vector newFace(face.size()); rotateQuad(reorderVal, face, newFace); // Look for existing cell in the hash; FaceHash::value_type & currHash = hash[a]; std::vector currFace(3); currFace[0] = b; currFace[1] = c; currFace[2] = d; currHash.push_back(std::make_pair(currFace, newFace)); } std::vector getEdge(unsigned int a, unsigned int b, FaceHash & hash) const { // reorder to get lowest id in a bool swapped = false; if(a > b) { std::swap(a, b); swapped = true; } // Look for existing cell in the hash; FaceHash::value_type & currHash = hash[a]; for(FaceHash::value_type::iterator iter = currHash.begin(); iter != currHash.end(); ++iter) { std::vector & currEdge = iter->first; if(currEdge.size() == 1) { if(b == currEdge[0]) { const std::vector edge = iter->second; std::vector returnValue(edge.size()); if(swapped) { for(unsigned int i=0; i(); } std::vector getFace(unsigned int a, unsigned int b, unsigned int c, unsigned int d, FaceHash & hash) const { unsigned int reorderVal = reorder(a, b, c, d); // need to rotate opposite of what we put in if(reorderVal == 1) { reorderVal = 3; } else if(reorderVal == 3) { reorderVal = 1; } // Look for existing cell in the hash; FaceHash::value_type & currHash = hash[a]; for(FaceHash::value_type::iterator iter = currHash.begin(); iter != currHash.end(); ++iter) { std::vector & currFace = iter->first; // 3 because b + c + d if(currFace.size() == 3) { if(b == currFace[0] && d == currFace[2]) { const std::vector & face = iter->second; std::vector returnValue(face.size()); rotateQuad(reorderVal, face, returnValue); currHash.erase(iter); return returnValue; } } } return std::vector(); } void calculateIntermediatePoint(double result[3], const double point1[3], const double point2[3], int index) const { const double scalar = points[index]; for (int i=0; i<3; ++i) { result[i] = point1[i]+scalar*(point2[i]-point1[i]); } } shared_ptr convert(const shared_ptr gridToConvert, const shared_ptr topologyType, const shared_ptr heavyDataWriter) const { shared_ptr toReturn = XdmfUnstructuredGrid::New(); toReturn->setName(gridToConvert->getName()); shared_ptr geometry = gridToConvert->getGeometry(); shared_ptr toReturnGeometry = toReturn->getGeometry(); toReturnGeometry->setType(geometry->getType()); toReturnGeometry->initialize(geometry->getArrayType()); bool releaseGeometry = false; if(!geometry->isInitialized()) { geometry->read(); releaseGeometry = true; } shared_ptr topology = gridToConvert->getTopology(); shared_ptr toReturnTopology = toReturn->getTopology(); toReturn->getTopology()->setType(topologyType); toReturnTopology->initialize(topology->getArrayType()); toReturnTopology->reserve(topologyType->getNodesPerElement() * topology->getNumberElements()); bool releaseTopology = false; if(!topology->isInitialized()) { topology->read(); releaseTopology = true; } // allocate storage for values used in loop unsigned int zeroIndex; unsigned int oneIndex; unsigned int twoIndex; unsigned int threeIndex; unsigned int fourIndex; unsigned int fiveIndex; unsigned int sixIndex; unsigned int sevenIndex; double elementCorner0[3]; double elementCorner1[3]; double elementCorner2[3]; double elementCorner3[3]; double elementCorner4[3]; double elementCorner5[3]; double elementCorner6[3]; double elementCorner7[3]; double planeCorner0[3]; double planeCorner1[3]; double planeCorner2[3]; double planeCorner3[3]; double lineEndPoint0[3]; double lineEndPoint1[3]; double (*newPoints)[3] = new double[mNumberPoints][3]; unsigned int largestId = 0; for(unsigned int i=0; igetSize(); ++i) { const unsigned int val = topology->getValue(i); largestId = std::max(val, largestId); } FaceHash hash(largestId + 1); std::vector oldIdToNewId(largestId + 1, -1); unsigned int offset = 0; for(unsigned int elem = 0; elemgetNumberElements(); ++elem) { // get indices of coner vertices of the element zeroIndex = topology->getValue(offset++); oneIndex = topology->getValue(offset++); twoIndex = topology->getValue(offset++); threeIndex = topology->getValue(offset++); fourIndex = topology->getValue(offset++); fiveIndex = topology->getValue(offset++); sixIndex = topology->getValue(offset++); sevenIndex = topology->getValue(offset++); // get previously added faces std::vector bottomFace = getFace(zeroIndex, threeIndex, twoIndex, oneIndex, hash); std::vector frontFace = getFace(zeroIndex, oneIndex, fiveIndex, fourIndex, hash); std::vector leftFace = getFace(zeroIndex, fourIndex, sevenIndex, threeIndex, hash); std::vector rightFace = getFace(oneIndex, twoIndex, sixIndex, fiveIndex, hash); std::vector backFace = getFace(threeIndex, sevenIndex, sixIndex, twoIndex, hash); std::vector topFace = getFace(fourIndex, fiveIndex, sixIndex, sevenIndex, hash); // get previously added edges std::vector bottomFrontEdge = getEdge(zeroIndex, oneIndex, hash); std::vector bottomRightEdge = getEdge(oneIndex, twoIndex, hash); std::vector bottomBackEdge = getEdge(twoIndex, threeIndex, hash); std::vector bottomLeftEdge = getEdge(threeIndex, zeroIndex, hash); std::vector topFrontEdge = getEdge(fourIndex, fiveIndex, hash); std::vector topRightEdge = getEdge(fiveIndex, sixIndex, hash); std::vector topBackEdge = getEdge(sixIndex, sevenIndex, hash); std::vector topLeftEdge = getEdge(sevenIndex, fourIndex, hash); std::vector frontLeftEdge = getEdge(zeroIndex, fourIndex, hash); std::vector frontRightEdge = getEdge(oneIndex, fiveIndex, hash); std::vector backRightEdge = getEdge(twoIndex, sixIndex, hash); std::vector backLeftEdge = getEdge(threeIndex, sevenIndex, hash); // get locations of corner vertices of the element geometry->getValues(zeroIndex * 3, &(elementCorner0[0]), 3); geometry->getValues(oneIndex * 3, &(elementCorner1[0]), 3); geometry->getValues(twoIndex * 3, &(elementCorner2[0]), 3); geometry->getValues(threeIndex * 3, &(elementCorner3[0]), 3); geometry->getValues(fourIndex * 3, &(elementCorner4[0]), 3); geometry->getValues(fiveIndex * 3, &(elementCorner5[0]), 3); geometry->getValues(sixIndex * 3, &(elementCorner6[0]), 3); geometry->getValues(sevenIndex * 3, &(elementCorner7[0]), 3); std::vector newIds(mNumberPoints, -1); // set new ids if they have been found previously newIds[mZeroIndex] = oldIdToNewId[zeroIndex]; newIds[mOneIndex] = oldIdToNewId[oneIndex]; newIds[mTwoIndex] = oldIdToNewId[twoIndex]; newIds[mThreeIndex] = oldIdToNewId[threeIndex]; newIds[mFourIndex] = oldIdToNewId[fourIndex]; newIds[mFiveIndex] = oldIdToNewId[fiveIndex]; newIds[mSixIndex] = oldIdToNewId[sixIndex]; newIds[mSevenIndex] = oldIdToNewId[sevenIndex]; // loop over i, j, k directions of element isolation i, j, and // k planes int pointIndex = 0; for(unsigned int i=0; i 0) { unsigned int index = 0; for(unsigned int i=0; i 0) { unsigned int index = 0; for(unsigned int i=0; i 0) { unsigned int index = 0; for(unsigned int i=mNumberPoints - mNodesPerFace; i 0) { unsigned int index = 0; for(unsigned int i=mNodesPerFace - mNodesPerEdge; i 0) { unsigned int index = 0; for(unsigned int i=mNodesPerEdge-1; i 0) { unsigned int index = 0; for(unsigned int i=0; i 0) { unsigned int index = 0; for(unsigned int i=mNumberPoints - mNodesPerFace; i 0) { unsigned int index = 0; for(int i=mNumberPoints - mNodesPerEdge; i>0; i-=mNodesPerFace) { newIds[i] = bottomBackEdge[index++]; } } if(bottomLeftEdge.size() > 0) { unsigned int index = 0; for(int i=mNodesPerFace - mNodesPerEdge; i>=0; i-=mNodesPerEdge) { newIds[i] = bottomLeftEdge[index++]; } } if(topFrontEdge.size() > 0) { unsigned int index = 0; for(unsigned int i=mNodesPerEdge - 1; i 0) { unsigned int index = 0; for(unsigned int i=mNumberPoints - mNodesPerFace + mNodesPerEdge - 1; i 0) { unsigned int index = 0; for(int i=mNumberPoints - 1; i>0; i-=mNodesPerFace) { newIds[i] = topBackEdge[index++]; } } if(topLeftEdge.size() > 0) { unsigned int index = 0; for(int i=mNodesPerFace - 1; i>0; i-=mNodesPerEdge) { newIds[i] = topLeftEdge[index++]; } } if(frontLeftEdge.size() > 0) { unsigned int index = 0; for(unsigned int i=0; i 0) { unsigned int index = 0; for(unsigned int i=mNumberPoints - mNodesPerFace; i 0) { unsigned int index = 0; for(unsigned int i=mNumberPoints - mNodesPerEdge; i 0) { unsigned int index = 0; for(unsigned int i=mNodesPerFace - mNodesPerEdge; igetNumberPoints(); newIds[i] = newId; toReturnGeometry->insert(newId * 3, &(newPoints[i][0]), 3); toReturnTopology->pushBack(newId); } else { // point added previously, so just add the found id toReturnTopology->pushBack(id); } } // add all faces to hash (mirror to match face on another element) if(bottomFace.size() == 0) { bottomFace.resize(mNodesPerFace); unsigned int index = 0; for(unsigned int i=0; i0; i-=mNodesPerFace) { bottomBackEdge[index++] = newIds[i]; } addEdgeToHash(twoIndex, threeIndex, hash, bottomBackEdge); } if(bottomLeftEdge.size() == 0) { bottomLeftEdge.resize(mNodesPerEdge); unsigned int index = 0; for(int i=mNodesPerFace - mNodesPerEdge; i>=0; i-=mNodesPerEdge) { bottomLeftEdge[index++] = newIds[i]; } addEdgeToHash(threeIndex, zeroIndex, hash, bottomLeftEdge); } if(topFrontEdge.size() == 0) { topFrontEdge.resize(mNodesPerEdge); unsigned int index = 0; for(unsigned int i=mNodesPerEdge - 1; i0; i-=mNodesPerFace) { topBackEdge[index++] = newIds[i]; } addEdgeToHash(sixIndex, sevenIndex, hash, topBackEdge); } if(topLeftEdge.size() == 0) { topLeftEdge.resize(mNodesPerEdge); unsigned int index = 0; for(int i=mNodesPerFace - 1; i>0; i-=mNodesPerEdge) { topLeftEdge[index++] = newIds[i]; } addEdgeToHash(sevenIndex, fourIndex, hash, topLeftEdge); } if(frontLeftEdge.size() == 0) { frontLeftEdge.resize(mNodesPerEdge); unsigned int index = 0; for(unsigned int i=0; irelease(); } if(releaseGeometry) { geometry->release(); } remapTopology(toReturnTopology); if(heavyDataWriter) { toReturnTopology->accept(heavyDataWriter); toReturnTopology->release(); toReturnGeometry->accept(heavyDataWriter); toReturnGeometry->release(); } handleSetConversion(gridToConvert, toReturn, oldIdToNewId, heavyDataWriter); return toReturn; } private: static const unsigned int mNodesPerEdge = ORDER + 1; static const unsigned int mNodesPerFace = (ORDER + 1) * (ORDER + 1); static const unsigned int mNumberPoints = (ORDER + 1) * (ORDER + 1) * (ORDER + 1); static const unsigned int mZeroIndex = 0; static const unsigned int mOneIndex = (ORDER + 1) * (ORDER + 1) * (ORDER + 1) - (ORDER + 1) * (ORDER + 1); static const unsigned int mTwoIndex = (ORDER + 1) * (ORDER + 1) * (ORDER + 1) - (ORDER + 1); static const unsigned int mThreeIndex = (ORDER + 1) * (ORDER + 1) - (ORDER + 1); static const unsigned int mFourIndex = ORDER; static const unsigned int mFiveIndex = (ORDER + 1) * (ORDER + 1) * (ORDER + 1) - (ORDER + 1) * (ORDER + 1) + ORDER; static const unsigned int mSixIndex = (ORDER + 1) * (ORDER + 1) * (ORDER + 1) - 1; static const unsigned int mSevenIndex = (ORDER + 1) * (ORDER + 1) - 1; static const double points[]; }; template <> const double HexahedronToHighOrderHexahedron<3, true>::points[] = { 0.0, 0.5-0.1*sqrt(5.0), 0.5+0.1*sqrt(5.0), 1.0 }; template <> const double HexahedronToHighOrderHexahedron<4, true>::points[] = { 0.0, 0.5-sqrt(21.0)/14.0, 0.5, 0.5+sqrt(21.0)/14.0, 1.0 }; template <> const double HexahedronToHighOrderHexahedron<5, true>::points[] = { 0.0, 0.5-sqrt((7.0+2.0*sqrt(7.0))/84.0), 0.5-sqrt((7.0-2.0*sqrt(7.0))/84.0), 0.5+sqrt((7.0-2.0*sqrt(7.0))/84.0), 0.5+sqrt((7.0+2.0*sqrt(7.0))/84.0), 1.0 }; template <> const double HexahedronToHighOrderHexahedron<6, true>::points[] = { 0.0, 0.5-sqrt((15.0+2.0*sqrt(15.0))/132.0), 0.5-sqrt((15.0-2.0*sqrt(15.0))/132.0), 0.5, 0.5+sqrt((15.0-2.0*sqrt(15.0))/132.0), 0.5+sqrt((15.0+2.0*sqrt(15.0))/132.0), 1.0 }; template <> const double HexahedronToHighOrderHexahedron<7, true>::points[] = { 0.0, 0.064129925745196714, 0.20414990928342885, 0.39535039104876057, 0.60464960895123943, 0.79585009071657109, 0.93587007425480329, 1.0 }; template <> const double HexahedronToHighOrderHexahedron<8, true>::points[] = { 0.0, 0.050121002294269912, 0.16140686024463108, 0.31844126808691087, 0.5, 0.68155873191308913, 0.83859313975536898, 0.94987899770573003, 1.0 }; template <> const double HexahedronToHighOrderHexahedron<9, true>::points[] = { 0.0, 0.040233045916770627, 0.13061306744724743, 0.26103752509477773, 0.4173605211668065, 0.58263947883319345, 0.73896247490522227, 0.86938693255275257, 0.95976695408322943, 1.0 }; template <> const double HexahedronToHighOrderHexahedron<10, true>::points[] = { 0.0, 0.032999284795970474, 0.10775826316842779, 0.21738233650189748, 0.35212093220653029, 0.5, 0.64787906779346971, 0.78261766349810258, 0.89224173683157226, 0.96700071520402953, 1.0 }; template <> const double HexahedronToHighOrderHexahedron<2, false>::points[] = { 0.0, 0.5, 1.0 }; template <> const double HexahedronToHighOrderHexahedron<3, false>::points[] = { 0.0, 1.0/3.0, 2.0/3.0, 1.0 }; template <> const double HexahedronToHighOrderHexahedron<4, false>::points[] = { 0.0, 0.25, 0.5, 0.75, 1.0 }; template <> const double HexahedronToHighOrderHexahedron<5, false>::points[] = { 0.0, 0.2, 0.4, 0.6, 0.8, 1.0 }; template <> const double HexahedronToHighOrderHexahedron<6, false>::points[] = { 0.0, 1.0/6.0, 1.0/3.0, 0.5, 2.0/3.0, 5.0/6.0, 1.0 }; template <> const double HexahedronToHighOrderHexahedron<7, false>::points[] = { 0.0, 1.0/7.0, 2.0/7.0, 3.0/7.0, 4.0/7.0, 5.0/7.0, 6.0/7.0, 1.0 }; template <> const double HexahedronToHighOrderHexahedron<8, false>::points[] = { 0.0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875, 1.0 }; template <> const double HexahedronToHighOrderHexahedron<9, false>::points[] = { 0.0, 1.0/9.0, 2.0/9.0, 1.0/3.0, 4.0/9.0, 5.0/9.0, 2.0/3.0, 7.0/9.0, 8.0/9.0, 1.0 }; template <> const double HexahedronToHighOrderHexahedron<10, false>::points[] = { 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0 }; template class HighOrderHexahedronToHexahedron : public Tessellator { public: HighOrderHexahedronToHexahedron() : Tessellator(ORDER * ORDER * ORDER) { } void tesselateTopology(shared_ptr topologyToConvert, shared_ptr topologyToReturn) const { topologyToReturn->setType(XdmfTopologyType::Hexahedron()); topologyToReturn->initialize(topologyToConvert->getArrayType(), 8 * ORDER * ORDER * ORDER * topologyToConvert->getNumberElements()); unsigned int newIndex = 0; int indexA = 0; int indexB = mNodesPerEdge * mNodesPerEdge; int indexC = mNodesPerEdge * mNodesPerEdge + mNodesPerEdge; int indexD = mNodesPerEdge; for(unsigned int i=0; igetNumberElements(); ++i) { for(unsigned int j=0; jinsert(newIndex++, topologyToConvert, indexA++); topologyToReturn->insert(newIndex++, topologyToConvert, indexB++); topologyToReturn->insert(newIndex++, topologyToConvert, indexC++); topologyToReturn->insert(newIndex++, topologyToConvert, indexD++); topologyToReturn->insert(newIndex++, topologyToConvert, indexA); topologyToReturn->insert(newIndex++, topologyToConvert, indexB); topologyToReturn->insert(newIndex++, topologyToConvert, indexC); topologyToReturn->insert(newIndex++, topologyToConvert, indexD); } indexA++; indexB++; indexC++; indexD++; } indexA += mNodesPerEdge; indexB += mNodesPerEdge; indexC += mNodesPerEdge; indexD += mNodesPerEdge; } indexA += mNodesPerEdge * mNodesPerEdge; indexB += mNodesPerEdge * mNodesPerEdge; indexC += mNodesPerEdge * mNodesPerEdge; indexD += mNodesPerEdge * mNodesPerEdge; } } private: static const unsigned int mNodesPerEdge = (ORDER + 1); }; } shared_ptr XdmfTopologyConverter::New() { shared_ptr p(new XdmfTopologyConverter()); return p; } XdmfTopologyConverter::XdmfTopologyConverter() { } XdmfTopologyConverter::XdmfTopologyConverter(const XdmfTopologyConverter &) { } XdmfTopologyConverter::~XdmfTopologyConverter() { } shared_ptr XdmfTopologyConverter::convert(const shared_ptr gridToConvert, const shared_ptr topologyType, const shared_ptr heavyDataWriter) const { // Make sure geometry and topology are non null if(!(gridToConvert->getGeometry() && gridToConvert->getTopology())) { XdmfError::message(XdmfError::FATAL, "Current grid's geometry or topology is null " "in XdmfTopologyConverter::convert"); } shared_ptr topologyTypeToConvert = gridToConvert->getTopology()->getType(); if(topologyTypeToConvert == topologyType) { // No conversion necessary return gridToConvert; } if(gridToConvert->getGeometry()->getType() != XdmfGeometryType::XYZ()) { XdmfError::message(XdmfError::FATAL, "Grid to convert's type is not 'XYZ' in " "XdmfTopologyConverter::convert"); } Converter * converter = NULL; if(topologyTypeToConvert == XdmfTopologyType::Hexahedron()) { if(topologyType == XdmfTopologyType::Hexahedron_27()) { converter = new HexahedronToHighOrderHexahedron<2, false>(); } else if(topologyType == XdmfTopologyType::Hexahedron_64()) { converter = new HexahedronToHighOrderHexahedron<3, false>(); } else if(topologyType == XdmfTopologyType::Hexahedron_Spectral_64()) { converter = new HexahedronToHighOrderHexahedron<3, true>(); } else if(topologyType == XdmfTopologyType::Hexahedron_125()) { converter = new HexahedronToHighOrderHexahedron<4, false>(); } else if(topologyType == XdmfTopologyType::Hexahedron_Spectral_125()) { converter = new HexahedronToHighOrderHexahedron<4, true>(); } else if(topologyType == XdmfTopologyType::Hexahedron_216()) { converter = new HexahedronToHighOrderHexahedron<5, false>(); } else if(topologyType == XdmfTopologyType::Hexahedron_Spectral_216()) { converter = new HexahedronToHighOrderHexahedron<5, true>(); } else if(topologyType == XdmfTopologyType::Hexahedron_343()) { converter = new HexahedronToHighOrderHexahedron<6, false>(); } else if(topologyType == XdmfTopologyType::Hexahedron_Spectral_343()) { converter = new HexahedronToHighOrderHexahedron<6, true>(); } else if(topologyType == XdmfTopologyType::Hexahedron_512()) { converter = new HexahedronToHighOrderHexahedron<7, false>(); } else if(topologyType == XdmfTopologyType::Hexahedron_Spectral_512()) { converter = new HexahedronToHighOrderHexahedron<7, true>(); } else if(topologyType == XdmfTopologyType::Hexahedron_729()) { converter = new HexahedronToHighOrderHexahedron<8, false>(); } else if(topologyType == XdmfTopologyType::Hexahedron_Spectral_729()) { converter = new HexahedronToHighOrderHexahedron<8, true>(); } else if(topologyType == XdmfTopologyType::Hexahedron_1000()) { converter = new HexahedronToHighOrderHexahedron<9, false>(); } else if(topologyType == XdmfTopologyType::Hexahedron_Spectral_1000()) { converter = new HexahedronToHighOrderHexahedron<9, true>(); } else if(topologyType == XdmfTopologyType::Hexahedron_1331()) { converter = new HexahedronToHighOrderHexahedron<10, false>(); } else if(topologyType == XdmfTopologyType::Hexahedron_Spectral_1331()) { converter = new HexahedronToHighOrderHexahedron<10, true>(); } } else if(topologyTypeToConvert == XdmfTopologyType::Hexahedron_64() || topologyTypeToConvert == XdmfTopologyType::Hexahedron_Spectral_64()) { if(topologyType == XdmfTopologyType::Hexahedron()) { converter = new HighOrderHexahedronToHexahedron<3>(); } } else if(topologyTypeToConvert == XdmfTopologyType::Hexahedron_125() || topologyTypeToConvert == XdmfTopologyType::Hexahedron_Spectral_125()) { if(topologyType == XdmfTopologyType::Hexahedron()) { converter = new HighOrderHexahedronToHexahedron<4>(); } } else if(topologyTypeToConvert == XdmfTopologyType::Hexahedron_216() || topologyTypeToConvert == XdmfTopologyType::Hexahedron_Spectral_216()) { if(topologyType == XdmfTopologyType::Hexahedron()) { converter = new HighOrderHexahedronToHexahedron<5>(); } } else if(topologyTypeToConvert == XdmfTopologyType::Hexahedron_343() || topologyTypeToConvert == XdmfTopologyType::Hexahedron_Spectral_343()) { if(topologyType == XdmfTopologyType::Hexahedron()) { converter = new HighOrderHexahedronToHexahedron<6>(); } } else if(topologyTypeToConvert == XdmfTopologyType::Hexahedron_512() || topologyTypeToConvert == XdmfTopologyType::Hexahedron_Spectral_512()) { if(topologyType == XdmfTopologyType::Hexahedron()) { converter = new HighOrderHexahedronToHexahedron<7>(); } } else if(topologyTypeToConvert == XdmfTopologyType::Hexahedron_729() || topologyTypeToConvert == XdmfTopologyType::Hexahedron_Spectral_729()) { if(topologyType == XdmfTopologyType::Hexahedron()) { converter = new HighOrderHexahedronToHexahedron<8>(); } } else if(topologyTypeToConvert == XdmfTopologyType::Hexahedron_1000() || topologyTypeToConvert == XdmfTopologyType::Hexahedron_Spectral_1000()) { if(topologyType == XdmfTopologyType::Hexahedron()) { converter = new HighOrderHexahedronToHexahedron<9>(); } } else if(topologyTypeToConvert == XdmfTopologyType::Hexahedron_1331() || topologyTypeToConvert == XdmfTopologyType::Hexahedron_Spectral_1331()) { if(topologyType == XdmfTopologyType::Hexahedron()) { converter = new HighOrderHexahedronToHexahedron<10>(); } } if(converter) { if(heavyDataWriter) { heavyDataWriter->openFile(); } shared_ptr toReturn = converter->convert(gridToConvert, topologyType, heavyDataWriter); if(heavyDataWriter) { heavyDataWriter->closeFile(); } delete converter; return toReturn; } else { XdmfError::message(XdmfError::FATAL, "Cannot convert topology type in " "XdmfTopologyConverter::convert"); } // not reached return shared_ptr(); } shared_ptr XdmfTopologyConverter::getExternalFaces(const shared_ptr convertedTopology) { if (convertedTopology->getSize() < convertedTopology->getType()->getNodesPerElement()) { XdmfError::message(XdmfError::FATAL, "Error: Not enough nodes for GetExternalSurface"); } long largestId = convertedTopology->getValue(0); for (unsigned int i = 1; i < convertedTopology->getSize(); ++i) { if (largestId < convertedTopology->getValue(i)) { largestId = convertedTopology->getValue(i); } } std::vector > > hash(largestId); if(convertedTopology->getType() == XdmfTopologyType::Tetrahedron()) { // This loop can be generalized in a later version for(unsigned int arrayOffset=0; arrayOffsetgetSize(); arrayOffset += convertedTopology->getType()->getNodesPerElement()) { std::vector faceNodes; for (unsigned int i = 0; i < convertedTopology->getType()->getNodesPerElement(); ++i) { faceNodes.push_back(convertedTopology->getValue(arrayOffset + i)); } std::vector< std::vector > faceVectors; // 0, 1, 3 face std::vector face1Vector; face1Vector.push_back(faceNodes[0]); face1Vector.push_back(faceNodes[1]); face1Vector.push_back(faceNodes[3]); faceVectors.push_back(face1Vector); // 0, 2, 1 face std::vector face2Vector; face2Vector.push_back(faceNodes[0]); face2Vector.push_back(faceNodes[2]); face2Vector.push_back(faceNodes[1]); faceVectors.push_back(face2Vector); // 0, 3, 2 face std::vector face3Vector; face3Vector.push_back(faceNodes[0]); face3Vector.push_back(faceNodes[3]); face3Vector.push_back(faceNodes[2]); faceVectors.push_back(face3Vector); // 1, 2, 3 face std::vector face4Vector; face4Vector.push_back(faceNodes[1]); face4Vector.push_back(faceNodes[2]); face4Vector.push_back(faceNodes[3]); faceVectors.push_back(face4Vector); for (unsigned int i = 0; i < faceVectors.size(); ++i) { insertInHash(faceVectors[i], hash, 3); } } // create new topology shared_ptr toReturn = XdmfTopology::New(); toReturn->setType(XdmfTopologyType::Triangle()); std::vector newCells; int index = 0; for(std::vector > >::const_iterator hashIter = hash.begin(); hashIter != hash.end(); ++hashIter, ++index) { const std::vector > & currHash = *hashIter; for(std::vector >::const_iterator currHashIter = currHash.begin(); currHashIter != currHash.end(); ++currHashIter) { const std::vector & currFaceIds = *currHashIter; newCells.push_back(index); newCells.push_back(currFaceIds[0]); newCells.push_back(currFaceIds[1]); } } toReturn->initialize(XdmfArrayType::Int64()); toReturn->insert(0, &newCells[0], newCells.size()); return toReturn; } else if(convertedTopology->getType() == XdmfTopologyType::Hexahedron()) { for(long arrayOffset=0; arrayOffsetgetSize(); arrayOffset += convertedTopology->getType()->getNodesPerElement()) { std::vector faceNodes; for (unsigned int i = 0; i < convertedTopology->getType()->getNodesPerElement(); ++i) { faceNodes.push_back(convertedTopology->getValue(arrayOffset + i)); } std::vector< std::vector > faceVectors; // 0, 1, 5, 4 face std::vector face1Vector; face1Vector.push_back(faceNodes[0]); face1Vector.push_back(faceNodes[1]); face1Vector.push_back(faceNodes[5]); face1Vector.push_back(faceNodes[4]); faceVectors.push_back(face1Vector); // 0, 3, 2, 1 face std::vector face2Vector; face2Vector.push_back(faceNodes[0]); face2Vector.push_back(faceNodes[3]); face2Vector.push_back(faceNodes[2]); face2Vector.push_back(faceNodes[1]); faceVectors.push_back(face2Vector); // 0, 4, 7, 3 face std::vector face3Vector; face3Vector.push_back(faceNodes[0]); face3Vector.push_back(faceNodes[4]); face3Vector.push_back(faceNodes[7]); face3Vector.push_back(faceNodes[3]); faceVectors.push_back(face3Vector); // 1, 2, 6, 5 face std::vector face4Vector; face4Vector.push_back(faceNodes[1]); face4Vector.push_back(faceNodes[2]); face4Vector.push_back(faceNodes[6]); face4Vector.push_back(faceNodes[5]); faceVectors.push_back(face4Vector); // 2, 3, 7, 6 face std::vector face5Vector; face5Vector.push_back(faceNodes[2]); face5Vector.push_back(faceNodes[3]); face5Vector.push_back(faceNodes[7]); face5Vector.push_back(faceNodes[6]); faceVectors.push_back(face5Vector); // 4, 5, 6, 7 face std::vector face6Vector; face6Vector.push_back(faceNodes[4]); face6Vector.push_back(faceNodes[5]); face6Vector.push_back(faceNodes[6]); face6Vector.push_back(faceNodes[7]); faceVectors.push_back(face6Vector); for (unsigned int i = 0; i < faceVectors.size(); ++i) { insertInHash(faceVectors[i], hash, 4); } } // create new topology shared_ptr toReturn = XdmfTopology::New(); toReturn->setType(XdmfTopologyType::Quadrilateral()); std::vector newCells; int index = 0; for(std::vector > >::const_iterator hashIter = hash.begin(); hashIter != hash.end(); ++hashIter, ++index) { const std::vector > & currHash = *hashIter; for(std::vector >::const_iterator currHashIter = currHash.begin(); currHashIter != currHash.end(); ++currHashIter) { const std::vector & currFaceIds = *currHashIter; newCells.push_back(index); newCells.push_back(currFaceIds[0]); newCells.push_back(currFaceIds[1]); newCells.push_back(currFaceIds[2]); } } toReturn->initialize(XdmfArrayType::Int64()); toReturn->insert(0, &newCells[0], newCells.size()); return toReturn; } else if(convertedTopology->getType() == XdmfTopologyType::Tetrahedron_10()) { for(long arrayOffset=0; arrayOffsetgetSize(); arrayOffset += convertedTopology->getType()->getNodesPerElement()) { std::vector faceNodes; for (unsigned int i = 0; i < convertedTopology->getType()->getNodesPerElement(); ++i) { faceNodes.push_back(convertedTopology->getValue(arrayOffset + i)); } std::vector< std::vector > faceVectors; // 0, 1, 3, 4, 8, 7 face std::vector face1Vector; face1Vector.push_back(faceNodes[0]); face1Vector.push_back(faceNodes[1]); face1Vector.push_back(faceNodes[3]); face1Vector.push_back(faceNodes[4]); face1Vector.push_back(faceNodes[8]); face1Vector.push_back(faceNodes[7]); faceVectors.push_back(face1Vector); // 0, 2, 1, 6, 5, 4 face std::vector face2Vector; face2Vector.push_back(faceNodes[0]); face2Vector.push_back(faceNodes[2]); face2Vector.push_back(faceNodes[1]); face2Vector.push_back(faceNodes[6]); face2Vector.push_back(faceNodes[5]); face2Vector.push_back(faceNodes[4]); faceVectors.push_back(face2Vector); // 0, 3, 2, 7, 9, 6 face std::vector face3Vector; face3Vector.push_back(faceNodes[0]); face3Vector.push_back(faceNodes[3]); face3Vector.push_back(faceNodes[2]); face3Vector.push_back(faceNodes[7]); face3Vector.push_back(faceNodes[9]); face3Vector.push_back(faceNodes[6]); faceVectors.push_back(face3Vector); // 1, 2, 3, 5, 9, 8 face std::vector face4Vector; face4Vector.push_back(faceNodes[1]); face4Vector.push_back(faceNodes[2]); face4Vector.push_back(faceNodes[3]); face4Vector.push_back(faceNodes[5]); face4Vector.push_back(faceNodes[9]); face4Vector.push_back(faceNodes[8]); faceVectors.push_back(face4Vector); for (unsigned int i = 0; i < faceVectors.size(); ++i) { insertInHash(faceVectors[i], hash, 3); } } // create new topology shared_ptr toReturn = XdmfTopology::New(); toReturn->setType(XdmfTopologyType::Triangle_6()); std::vector newCells; int index = 0; for(std::vector > >::const_iterator hashIter = hash.begin(); hashIter != hash.end(); ++hashIter, ++index) { const std::vector > & currHash = *hashIter; for(std::vector >::const_iterator currHashIter = currHash.begin(); currHashIter != currHash.end(); ++currHashIter) { const std::vector & currFaceIds = *currHashIter; newCells.push_back(index); newCells.push_back(currFaceIds[0]); newCells.push_back(currFaceIds[1]); newCells.push_back(currFaceIds[2]); newCells.push_back(currFaceIds[3]); newCells.push_back(currFaceIds[4]); } } toReturn->initialize(XdmfArrayType::Int64()); toReturn->insert(0, &newCells[0], newCells.size()); return toReturn; } else if(convertedTopology->getType() == XdmfTopologyType::Hexahedron_20()) { for(long arrayOffset=0; arrayOffsetgetSize(); arrayOffset += convertedTopology->getType()->getNodesPerElement()) { std::vector faceNodes; for (unsigned int i = 0; i < convertedTopology->getType()->getNodesPerElement(); ++i) { faceNodes.push_back(convertedTopology->getValue(arrayOffset + i)); } std::vector< std::vector > faceVectors; // 0, 1, 5, 4, 8, 17, 12, 16 face std::vector face1Vector; face1Vector.push_back(faceNodes[0]); face1Vector.push_back(faceNodes[1]); face1Vector.push_back(faceNodes[5]); face1Vector.push_back(faceNodes[4]); face1Vector.push_back(faceNodes[8]); face1Vector.push_back(faceNodes[17]); face1Vector.push_back(faceNodes[12]); face1Vector.push_back(faceNodes[16]); faceVectors.push_back(face1Vector); // 0, 3, 2, 1, 11, 10, 9, 8 face std::vector face2Vector; face2Vector.push_back(faceNodes[0]); face2Vector.push_back(faceNodes[3]); face2Vector.push_back(faceNodes[2]); face2Vector.push_back(faceNodes[1]); face2Vector.push_back(faceNodes[11]); face2Vector.push_back(faceNodes[10]); face2Vector.push_back(faceNodes[9]); face2Vector.push_back(faceNodes[8]); faceVectors.push_back(face2Vector); // 0, 4, 7, 3, 16, 15, 19, 11 face std::vector face3Vector; face3Vector.push_back(faceNodes[0]); face3Vector.push_back(faceNodes[4]); face3Vector.push_back(faceNodes[7]); face3Vector.push_back(faceNodes[3]); face3Vector.push_back(faceNodes[16]); face3Vector.push_back(faceNodes[15]); face3Vector.push_back(faceNodes[19]); face3Vector.push_back(faceNodes[11]); faceVectors.push_back(face3Vector); // 1, 2, 6, 5, 9, 18, 13, 17 face std::vector face4Vector; face4Vector.push_back(faceNodes[1]); face4Vector.push_back(faceNodes[2]); face4Vector.push_back(faceNodes[6]); face4Vector.push_back(faceNodes[5]); face4Vector.push_back(faceNodes[9]); face4Vector.push_back(faceNodes[18]); face4Vector.push_back(faceNodes[13]); face4Vector.push_back(faceNodes[17]); faceVectors.push_back(face4Vector); // 2, 3, 7, 6, 10, 19, 14, 18 face std::vector face5Vector; face5Vector.push_back(faceNodes[2]); face5Vector.push_back(faceNodes[3]); face5Vector.push_back(faceNodes[7]); face5Vector.push_back(faceNodes[6]); face5Vector.push_back(faceNodes[10]); face5Vector.push_back(faceNodes[19]); face5Vector.push_back(faceNodes[14]); face5Vector.push_back(faceNodes[18]); faceVectors.push_back(face5Vector); // 4, 5, 6, 7, 12, 13, 14, 15 face std::vector face6Vector; face6Vector.push_back(faceNodes[4]); face6Vector.push_back(faceNodes[5]); face6Vector.push_back(faceNodes[6]); face6Vector.push_back(faceNodes[7]); face6Vector.push_back(faceNodes[12]); face6Vector.push_back(faceNodes[13]); face6Vector.push_back(faceNodes[14]); face6Vector.push_back(faceNodes[15]); faceVectors.push_back(face6Vector); for (unsigned int i = 0; i < faceVectors.size(); ++i) { insertInHash(faceVectors[i], hash, 4); } } // create new topology shared_ptr toReturn = XdmfTopology::New(); toReturn->setType(XdmfTopologyType::Quadrilateral_8()); std::vector newCells; int index = 0; for(std::vector > >::const_iterator hashIter = hash.begin(); hashIter != hash.end(); ++hashIter, ++index) { const std::vector > & currHash = *hashIter; for(std::vector >::const_iterator currHashIter = currHash.begin(); currHashIter != currHash.end(); ++currHashIter) { const std::vector & currFaceIds = *currHashIter; newCells.push_back(index); newCells.push_back(currFaceIds[0]); newCells.push_back(currFaceIds[1]); newCells.push_back(currFaceIds[2]); newCells.push_back(currFaceIds[3]); newCells.push_back(currFaceIds[4]); newCells.push_back(currFaceIds[5]); newCells.push_back(currFaceIds[6]); } } toReturn->initialize(XdmfArrayType::Int64()); toReturn->insert(0, &newCells[0], newCells.size()); return toReturn; } XdmfError::message(XdmfError::FATAL, "Unsupported TopologyType when computing external surface"); return shared_ptr(); } void XdmfTopologyConverter::insertInHash(std::vector nodes, std::vector > > & hash, unsigned int numCornerNodes) { unsigned int minIndex = 0; for (unsigned int i = 0; i < numCornerNodes; ++i) { if (nodes[i] < nodes[minIndex]) { minIndex = i; } } if (minIndex !=0) { // If the min value is not the first value, rotate as appropriate std::vector sortedVector (nodes.begin()+minIndex, nodes.begin()+numCornerNodes); sortedVector.insert(sortedVector.end(), nodes.begin(), nodes.begin()+minIndex); if (nodes.size() > numCornerNodes) { sortedVector.insert(sortedVector.end(), nodes.begin()+numCornerNodes+minIndex, nodes.begin()+numCornerNodes+numCornerNodes); sortedVector.insert(sortedVector.end(), nodes.begin()+numCornerNodes, nodes.begin()+numCornerNodes+minIndex); } nodes = sortedVector; } // The nodes are now sorted so that the smallest corner is first // Look for existing cell in the hash; std::vector > & currHash = hash[nodes[0]]; for(std::vector >::iterator iter = currHash.begin(); iter != currHash.end(); ++iter) { std::vector & currFace = *iter; // size - 1 because the first value is used elsewhere if(currFace.size() == nodes.size()-1) { if ((nodes[1] == currFace[0] && nodes[numCornerNodes-1] == currFace[numCornerNodes-2]) || (nodes[1] == currFace[numCornerNodes-2] && nodes[numCornerNodes-1] == currFace[0])) { currHash.erase(iter); return; } } } std::vector newFace; for (unsigned int i = 1; i < nodes.size(); ++i) { newFace.push_back(nodes[i]); } currHash.push_back(newFace); } // C Wrappers shared_ptr convertIntToType(int type, int nodes = 0) { switch (type) { case XDMF_TOPOLOGY_TYPE_POLYVERTEX: return XdmfTopologyType::Polyvertex(); break; case XDMF_TOPOLOGY_TYPE_POLYLINE: return XdmfTopologyType::Polyline(nodes); break; case XDMF_TOPOLOGY_TYPE_POLYGON: return XdmfTopologyType::Polygon(nodes); break; case XDMF_TOPOLOGY_TYPE_TRIANGLE: return XdmfTopologyType::Triangle(); break; case XDMF_TOPOLOGY_TYPE_QUADRILATERAL: return XdmfTopologyType::Quadrilateral(); break; case XDMF_TOPOLOGY_TYPE_TETRAHEDRON: return XdmfTopologyType::Tetrahedron(); break; case XDMF_TOPOLOGY_TYPE_PYRAMID: return XdmfTopologyType::Pyramid(); break; case XDMF_TOPOLOGY_TYPE_WEDGE: return XdmfTopologyType::Wedge(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON: return XdmfTopologyType::Hexahedron(); break; case XDMF_TOPOLOGY_TYPE_EDGE_3: return XdmfTopologyType::Edge_3(); break; case XDMF_TOPOLOGY_TYPE_TRIANGLE_6: return XdmfTopologyType::Triangle_6(); break; case XDMF_TOPOLOGY_TYPE_QUADRILATERAL_8: return XdmfTopologyType::Quadrilateral_8(); break; case XDMF_TOPOLOGY_TYPE_QUADRILATERAL_9: return XdmfTopologyType::Quadrilateral_9(); break; case XDMF_TOPOLOGY_TYPE_TETRAHEDRON_10: return XdmfTopologyType::Tetrahedron_10(); break; case XDMF_TOPOLOGY_TYPE_PYRAMID_13: return XdmfTopologyType::Pyramid_13(); break; case XDMF_TOPOLOGY_TYPE_WEDGE_15: return XdmfTopologyType::Wedge_15(); break; case XDMF_TOPOLOGY_TYPE_WEDGE_18: return XdmfTopologyType::Wedge_18(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_20: return XdmfTopologyType::Hexahedron_20(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_24: return XdmfTopologyType::Hexahedron_24(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_27: return XdmfTopologyType::Hexahedron_27(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_64: return XdmfTopologyType::Hexahedron_64(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_125: return XdmfTopologyType::Hexahedron_125(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_216: return XdmfTopologyType::Hexahedron_216(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_343: return XdmfTopologyType::Hexahedron_343(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_512: return XdmfTopologyType::Hexahedron_512(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_729: return XdmfTopologyType::Hexahedron_729(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_1000: return XdmfTopologyType::Hexahedron_1000(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_1331: return XdmfTopologyType::Hexahedron_1331(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_64: return XdmfTopologyType::Hexahedron_Spectral_64(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_125: return XdmfTopologyType::Hexahedron_Spectral_125(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_216: return XdmfTopologyType::Hexahedron_Spectral_216(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_343: return XdmfTopologyType::Hexahedron_Spectral_343(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_512: return XdmfTopologyType::Hexahedron_Spectral_512(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_729: return XdmfTopologyType::Hexahedron_Spectral_729(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_1000: return XdmfTopologyType::Hexahedron_Spectral_1000(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_1331: return XdmfTopologyType::Hexahedron_Spectral_1331(); break; case XDMF_TOPOLOGY_TYPE_MIXED: return XdmfTopologyType::Mixed(); break; default: return shared_ptr(); break; } } XDMFTOPOLOGYCONVERTER * XdmfTopologyConverterNew() { shared_ptr generatedConverter = XdmfTopologyConverter::New(); return (XDMFTOPOLOGYCONVERTER *)((void *)(new XdmfTopologyConverter(*generatedConverter.get()))); } XDMFUNSTRUCTUREDGRID * XdmfTopologyConverterConvert(XDMFTOPOLOGYCONVERTER * converter, XDMFUNSTRUCTUREDGRID * gridToConvert, int topologytype, XDMFHEAVYDATAWRITER * heavyDataWriter) { XdmfItem * tempPointer = (XdmfItem *)(gridToConvert); XdmfUnstructuredGrid * gridPointer = dynamic_cast(tempPointer); shared_ptr tempgrid = shared_ptr((XdmfUnstructuredGrid *)gridPointer, XdmfNullDeleter()); shared_ptr convertedType = convertIntToType(topologytype); shared_ptr tempwriter = shared_ptr(); if (heavyDataWriter) { tempwriter = shared_ptr((XdmfHeavyDataWriter *)heavyDataWriter, XdmfNullDeleter()); return (XDMFUNSTRUCTUREDGRID *)((void *)((XdmfItem *)(new XdmfUnstructuredGrid(*((((XdmfTopologyConverter *)converter)->convert(tempgrid, convertedType, tempwriter)).get()))))); } else { return (XDMFUNSTRUCTUREDGRID *)((void *)((XdmfItem *)(new XdmfUnstructuredGrid(*((((XdmfTopologyConverter *)converter)->convert(tempgrid, convertedType)).get()))))); } } XDMFTOPOLOGY * XdmfTopologyConverterGetExternalFaces(XDMFTOPOLOGYCONVERTER * converter, XDMFTOPOLOGY * convertedTopology) { shared_ptr temptopo = shared_ptr((XdmfTopology *)convertedTopology, XdmfNullDeleter()); return (XDMFTOPOLOGY *)((void *)(new XdmfTopology(*((((XdmfTopologyConverter *)converter)->getExternalFaces(temptopo)).get())))); } void XdmfTopologyConverterFree(XDMFTOPOLOGYCONVERTER * converter) { if (converter != NULL) { delete ((XdmfTopologyConverter *)converter); converter = NULL; } } xdmf-3.0+git20160803/utils/CMakeLists.txt0000640000175000017500000001461213003006557017776 0ustar alastairalastairinclude_directories(${CMAKE_CURRENT_SOURCE_DIR}) option(XDMF_BUILD_EXODUS_IO OFF) option(XDMF_BUILD_PARTITIONER OFF) option(XDMF_BUILD_FORTRAN OFF) option(XDMF_BUILD_DSM OFF) set(XdmfUtilsSources XdmfDiff XdmfGeometryConverter XdmfTopologyConverter XdmfUtils) set(XdmfUtilsLinkLibraries Xdmf) if(XDMF_BUILD_FORTRAN) set(XdmfUtilsSources ${XdmfUtilsSources} XdmfFortran) enable_language (Fortran) if (XDMF_BUILD_DSM) # gcc doesn't automatically link to the fortran mpi libraries STRING(REGEX MATCH "gfortran" IS_GFORTRAN "${CMAKE_Fortran_COMPILER}") if (NOT "${IS_GFORTRAN}" STREQUAL "") EXECUTE_PROCESS( COMMAND ${MPIEXEC} --version OUTPUT_VARIABLE MPI_TYPE_OUTPUT ERROR_VARIABLE MPI_TYPE_ERROR ) if (NOT "${MPI_TYPE_ERROR}" STREQUAL "") STRING(REGEX MATCH "Open" IS_OPENMPI "${MPI_TYPE_ERROR}") elseif (NOT "${MPI_TYPE_OUTPUT}" STREQUAL "") STRING(REGEX MATCH "Open" IS_OPENMPI "${MPI_TYPE_OUTPUT}") endif () IF (NOT "${IS_OPENMPI}" STREQUAL "") if (NOT "${MPI_TYPE_ERROR}" STREQUAL "") STRING(REGEX MATCH "[0-9]+[.][0-9]+[.][0-9]+" MPI_VERSION "${MPI_TYPE_ERROR}") elseif (NOT "${MPI_TYPE_OUTPUT}" STREQUAL "") STRING(REGEX MATCH "[0-9]+[.][0-9]+[.][0-9]+" MPI_VERSION "${MPI_TYPE_OUTPUT}") endif () if (NOT "${MPI_VERSION}" STREQUAL "") STRING(REGEX MATCH "^[0-9]+" MPI_VERSION_MAJOR "${MPI_VERSION}") STRING(REGEX MATCH "[0-9]+[.][0-9]+$" MPI_VERSION_CUT "${MPI_VERSION}") STRING(REGEX MATCH "^[0-9]+" MPI_VERSION_MINOR "${MPI_VERSION_CUT}") if (("${MPI_VERSION_MAJOR}" EQUAL 1) OR ("${MPI_VERSION_MAJOR}" LESS 1)) if ("${MPI_VERSION_MAJOR}" EQUAL 1) if ("${MPI_VERSION_MINOR}" LESS 8) # Minor version is less than 1.8 set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -lmpi_f90") else ("${MPI_VERSION_MINOR}" LESS 8) # Version is 1.8.0 or greater set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -lmpi_mpifh") endif ("${MPI_VERSION_MINOR}" LESS 8) else ("${MPI_VERSION_MAJOR}" EQUAL 1) # Major version is less than 1 set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -lmpi_f90") endif ("${MPI_VERSION_MAJOR}" EQUAL 1) else (("${MPI_VERSION_MAJOR}" EQUAL 1) OR ("${MPI_VERSION_MAJOR}" LESS 1)) # Major version is greater than 1 set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -lmpi_mpifh") endif (("${MPI_VERSION_MAJOR}" EQUAL 1) OR ("${MPI_VERSION_MAJOR}" LESS 1)) endif (NOT "${MPI_VERSION}" STREQUAL "") ENDIF (NOT "${IS_OPENMPI}" STREQUAL "") endif (NOT "${IS_GFORTRAN}" STREQUAL "") endif (XDMF_BUILD_DSM) endif(XDMF_BUILD_FORTRAN) if (XDMF_BUILD_DSM) add_definitions(-DXDMF_BUILD_DSM) endif (XDMF_BUILD_DSM) if(XDMF_BUILD_EXODUS_IO) set(XDMF_SWIG_FLAGS ${XDMF_SWIG_FLAGS} -DXDMF_BUILD_EXODUS_IO) find_package(Exodus REQUIRED) if(EXODUS_FOUND) include_directories(${EXODUS_INCLUDE_DIR} ${NetCDF_INCLUDE_DIR}) endif(EXODUS_FOUND) set(XdmfUtilsSources ${XdmfUtilsSources} XdmfExodusReader XdmfExodusWriter) set(XdmfUtilsExecutables ${XdmfUtilsExecutables} XdmfExodusConverter) set(XdmfUtilsLinkLibraries ${XdmfUtilsLinkLibraries} ${EXODUS_LIBRARIES} ${NetCDF_LIBRARIES}) endif(XDMF_BUILD_EXODUS_IO) if(XDMF_BUILD_PARTITIONER) set(XDMF_SWIG_FLAGS ${XDMF_SWIG_FLAGS} -DXDMF_BUILD_PARTITIONER) find_package(Metis REQUIRED) if(METIS_FOUND) include_directories(${METIS_INCLUDE_DIR}) endif(METIS_FOUND) set(XdmfUtilsExecutables ${XdmfUtilsExecutables} XdmfPartitioner) set(XdmfUtilsSources ${XdmfUtilsSources} XdmfPartitioner) set(XdmfUtilsLinkLibraries ${XdmfUtilsLinkLibraries} ${METIS_LIBRARIES}) endif(XDMF_BUILD_PARTITIONER) add_library(XdmfUtilsObjects OBJECT ${XdmfUtilsSources}) add_library(XdmfUtils $) if (BUILD_SHARED_LIBS) add_library(XdmfUtils_Static STATIC $) if (UNIX) set_target_properties(XdmfUtils_Static PROPERTIES OUTPUT_NAME "XdmfUtils") endif (UNIX) endif (BUILD_SHARED_LIBS) target_link_libraries(XdmfUtils ${XdmfUtilsLinkLibraries}) if (BUILD_SHARED_LIBS) target_link_libraries(XdmfUtils_Static ${XdmfUtilsLinkLibraries}) endif (BUILD_SHARED_LIBS) if(WIN32) set_target_properties(${executable} PROPERTIES DEFINE_SYMBOL XdmfUtils_EXPORTS PREFIX ../ IMPORT_PREFIX ../ RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) endif(WIN32) foreach(executable ${XdmfUtilsExecutables}) add_executable(${executable} ${executable}) set_target_properties(${executable} PROPERTIES COMPILE_FLAGS -DBUILD_EXE) target_link_libraries(${executable} XdmfUtils) if(WIN32) set_target_properties(${executable} PROPERTIES DEFINE_SYMBOL XdmfUtils_EXPORTS) if(NOT MSVC10) set_target_properties(${executable} PROPERTIES PREFIX ../ IMPORT_PREFIX ../ RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) endif(NOT MSVC10) endif(WIN32) endforeach(executable ${XdmfUtilsExecutables}) if(XDMF_BUILD_TESTING) add_subdirectory(tests) endif(XDMF_BUILD_TESTING) if(XDMF_WRAP_JAVA) XDMF_SWIG_JAVA(XdmfUtils Compiled_Xdmf_Jar) endif(XDMF_WRAP_JAVA) if(XDMF_WRAP_PYTHON) if (NOT BUILD_SHARED_LIBS) message(FATAL_ERROR "Python Wrappers do not function" " properly without shared libraries") endif (NOT BUILD_SHARED_LIBS) XDMF_SWIG_PYTHON(XdmfUtils Xdmf) endif(XDMF_WRAP_PYTHON) foreach(source ${XdmfUtilsSources}) set(XdmfUtilsHeaders ${XdmfUtilsHeaders} ${source}.hpp) endforeach(source ${XdmfUtilsSources}) if(XDMF_BUILD_FORTRAN) set(XdmfUtilsHeaders ${XdmfUtilsHeaders} Xdmf.f) endif(XDMF_BUILD_FORTRAN) install(FILES ${XdmfUtilsHeaders} DESTINATION include) install(TARGETS XdmfUtils RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) if (BUILD_SHARED_LIBS) install(TARGETS XdmfUtils_Static RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) endif (BUILD_SHARED_LIBS) install(TARGETS ${XdmfUtilsExecutables} RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) xdmf-3.0+git20160803/utils/XdmfFortran.hpp0000640000175000017500000050455713003006557020215 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : Id */ /* Date : $Date$ */ /* Version : $Revision$ */ /* */ /* Author: */ /* John Vines */ /* john.m.vines@us.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2012 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #ifndef XDMFFORTRAN_HPP_ #define XDMFFORTRAN_HPP_ // Forward Declarations class XdmfAttribute; class XdmfDomain; class XdmfGeometry; class XdmfGridCollection; class XdmfFunction; class XdmfInformation; class XdmfTime; class XdmfTopology; class XdmfSubset; class XdmfArray; class XdmfMap; class XdmfSet; class XdmfCurvilinearGrid; class XdmfRectilinearGrid; class XdmfRegularGrid; class XdmfUnstructuredGrid; class XdmfHeavyDataWriter; class XdmfHDF5WriterDSM; //Includes #include #include #include #include "XdmfUtils.hpp" #include "XdmfSharedPtr.hpp" #ifdef XDMF_BUILD_DSM #include "mpi.h" #endif /** * Array Type */ #define XDMF_ARRAY_TYPE_INT8 0 #define XDMF_ARRAY_TYPE_INT16 1 #define XDMF_ARRAY_TYPE_INT32 2 #define XDMF_ARRAY_TYPE_INT64 3 #define XDMF_ARRAY_TYPE_UINT8 4 #define XDMF_ARRAY_TYPE_UINT16 5 #define XDMF_ARRAY_TYPE_UINT32 6 #define XDMF_ARRAY_TYPE_FLOAT32 7 #define XDMF_ARRAY_TYPE_FLOAT64 8 /** * Attribute Center */ #define XDMF_ATTRIBUTE_CENTER_GRID 100 #define XDMF_ATTRIBUTE_CENTER_CELL 101 #define XDMF_ATTRIBUTE_CENTER_FACE 102 #define XDMF_ATTRIBUTE_CENTER_EDGE 103 #define XDMF_ATTRIBUTE_CENTER_NODE 104 /** * Attribute Type */ #define XDMF_ATTRIBUTE_TYPE_SCALAR 200 #define XDMF_ATTRIBUTE_TYPE_VECTOR 201 #define XDMF_ATTRIBUTE_TYPE_TENSOR 202 #define XDMF_ATTRIBUTE_TYPE_MATRIX 203 #define XDMF_ATTRIBUTE_TYPE_TENSOR6 204 #define XDMF_ATTRIBUTE_TYPE_GLOBALID 205 #define XDMF_ATTRIBUTE_TYPE_NOTYPE 206 /** * Geometry Type */ #ifndef XDMF_GEOMETRY_TYPE_XYZ #define XDMF_GEOMETRY_TYPE_XYZ 301 #endif #ifndef XDMF_GEOMETRY_TYPE_XY #define XDMF_GEOMETRY_TYPE_XY 302 #endif #ifndef XDMF_GEOMETRY_TYPE_POLAR #define XDMF_GEOMETRY_TYPE_POLAR 303 #endif #ifndef XDMF_GEOMETRY_TYPE_SPHERICAL #define XDMF_GEOMETRY_TYPE_SPHERICAL 304 #endif /** * Grid Collection Type */ #define XDMF_GRID_COLLECTION_TYPE_SPATIAL 400 #define XDMF_GRID_COLLECTION_TYPE_TEMPORAL 401 /** * Topology Type */ #ifndef XDMF_C_TOPOLOGY_TYPES #define XDMF_C_TOPOLOGY_TYPES #define XDMF_TOPOLOGY_TYPE_POLYVERTEX 500 #define XDMF_TOPOLOGY_TYPE_POLYLINE 501 #define XDMF_TOPOLOGY_TYPE_POLYGON 502 #define XDMF_TOPOLOGY_TYPE_POLYHEDRON 503 #define XDMF_TOPOLOGY_TYPE_TRIANGLE 504 #define XDMF_TOPOLOGY_TYPE_QUADRILATERAL 505 #define XDMF_TOPOLOGY_TYPE_TETRAHEDRON 506 #define XDMF_TOPOLOGY_TYPE_PYRAMID 507 #define XDMF_TOPOLOGY_TYPE_WEDGE 508 #define XDMF_TOPOLOGY_TYPE_HEXAHEDRON 509 #define XDMF_TOPOLOGY_TYPE_EDGE_3 510 #define XDMF_TOPOLOGY_TYPE_TRIANGLE_6 511 #define XDMF_TOPOLOGY_TYPE_QUADRILATERAL_8 512 #define XDMF_TOPOLOGY_TYPE_QUADRILATERAL_9 513 #define XDMF_TOPOLOGY_TYPE_TETRAHEDRON_10 514 #define XDMF_TOPOLOGY_TYPE_PYRAMID_13 515 #define XDMF_TOPOLOGY_TYPE_WEDGE_15 516 #define XDMF_TOPOLOGY_TYPE_WEDGE_18 517 #define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_20 518 #define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_24 519 #define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_27 520 #define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_64 521 #define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_125 522 #define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_216 523 #define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_343 524 #define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_512 525 #define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_729 526 #define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_1000 527 #define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_1331 528 #define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_64 529 #define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_125 530 #define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_216 531 #define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_343 532 #define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_512 533 #define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_729 534 #define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_1000 535 #define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_1331 536 #define XDMF_TOPOLOGY_TYPE_MIXED 537 #endif /** * Set Type */ #define XDMF_SET_TYPE_NODE 601 #define XDMF_SET_TYPE_CELL 602 #define XDMF_SET_TYPE_FACE 603 #define XDMF_SET_TYPE_EDGE 604 /** * Grid Type */ #define XDMF_GRID_TYPE_CURVILINEAR 701 #define XDMF_GRID_TYPE_RECTILINEAR 702 #define XDMF_GRID_TYPE_REGULAR 703 #define XDMF_GRID_TYPE_UNSTRUCTURED 704 /** * Binary Endian */ #define XDMF_BINARY_ENDIAN_NATIVE 801 #define XDMF_BINARY_ENDIAN_LITTLE 802 #define XDMF_BINARY_ENDIAN_BIG 803 // This works with g77 and gfortran. Different compilers require different // name mangling. #if !defined(WIN32) #define XdmfInit xdmfinit_ #define XdmfClose xdmfclose_ #define XdmfAddAttribute xdmfaddattribute_ #define XdmfClearAttributeHeavyData xdmfclearattributeheavydata_ #define XdmfSetAttributeHDF5 xdmfsetattributehdf5_ #define XdmfSetAttributeBinary xdmfsetattributebinary_ #define XdmfAddGrid xdmfaddgrid_ #define XdmfAddGridCurvilinear xdmfaddgridcurvilinear_ #define XdmfAddGridRectilinear xdmfaddgridrectilinear_ #define XdmfAddGridRegular xdmfaddgridregular_ #define XdmfAddGridCollection xdmfaddgridcollection_ #define XdmfAddGridReference xdmfaddgridreference__ #define XdmfAddGridCollectionReference xdmfaddgridcollectionreference_ #define XdmfAddInformation xdmfaddinformation_ #define XdmfAddPreviousAttribute xdmfaddpreviousattribute_ #define XdmfAddPreviousInformation xdmfaddpreviousinformation_ #define XdmfCloseGridCollection xdmfclosegridcollection_ #define XdmfSetGeometry xdmfsetgeometry_ #define XdmfClearGeometryHeavyData xdmfcleargeometryheavydata_ #define XdmfSetGeometryHDF5 xdmfsetgeometryhdf5_ #define XdmfSetGeometryBinary xdmfsetgeometrybinary_ #define XdmfSetPreviousGeometry xdmfsetpreviousgeometry_ #define XdmfSetPreviousTopology xdmfsetprevioustopology_ #define XdmfSetTime xdmfsettime_ #define XdmfSetTopology xdmfsettopology_ #define XdmfClearTopologyHeavyData xdmfcleartopologyheavydata_ #define XdmfSetTopologyHDF5 xdmfsettopologyhdf5_ #define XdmfSetTopologyBinary xdmfsettopologybinary_ #define XdmfSetAllowSetSplitting xdmfsetallowsetsplitting_ #define XdmfSetMaxFileSize xdmfsetmaxfilesize_ #define XdmfWrite xdmfwrite_ #define XdmfRead xdmfread_ #define XdmfInitDSMServer xdmfinitdsmserver_ #define XdmfAcceptDSM xdmfacceptdsm_ #define XdmfCloseDSMPort xdmfclosedsmport_ #define XdmfConnectDSM xdmfconnectdsm_ #define XdmfGetDSMInterComm xdmfgetdsmintercomm_ #define XdmfGetDSMIntraComm xdmfgetdsmintracomm_ #define XdmfStopDSM xdmfstopdsm_ #define XdmfReadFromDSM xdmfreadfromdsm_ #define XdmfWriteToDSM xdmfwritetodsm_ #define XdmfWriteHDF5 xdmfwritehdf5_ #define XdmfInitHDF5 xdmfinithdf5_ #define XdmfSetTopologyPolyline xdmfsettopologypolyline_ #define XdmfSetTopologyPolygon xdmfsettopologypolygon_ #define XdmfRetrieveNumDomainGridCollections xdmfretrievenumdomaingridcollections_ #define XdmfRetrieveNumGridCollectionGridCollections xdmfretrievenumgridcollectiongridcollections_ #define XdmfRetrieveDomainTag xdmfretrievedomaintag_ #define XdmfRetrieveDomainNumProperties xdmfretrievedomainnumproperties_ #define XdmfRetrieveDomainProperty xdmfretrievedomainproperty_ #define XdmfRetrieveDomainPropertyByKey xdmfretrievedomainpropertybykey_ #define XdmfOpenDomainGridCollection xdmfopendomaingridcollection_ #define XdmfReadDomainnGridCollection xdmfreaddomaingridcollection_ #define XdmfRemoveDomainGridCollection xdmfremovedomaingridcollection_ #define XdmfOpenGridCollectionGridCollection xdmfopengridcollectiongridcollection_ #define XdmfReadGridCollectionGridCollection xdmfreadgridcollectiongridcollection_ #define XdmfRemoveGridCollectionGridCollection xdmfremovegricollectiongridcollection_ #define XdmfRetrieveGridCollectionTag xdmfretrievegridcollectiontag_ #define XdmfRetrieveGridCollectionNumProperties xdmfretrievegridcollectionnumproperties_ #define XdmfRetrieveGridCollectionProperty xdmfretrievegridcollectionproperty_ #define XdmfRetrieveGridCollectionPropertyByKey xdmfretrievegridcollectionpropertybykey_ #define XdmfRetrieveGridCollectionNumGrids xdmfretrievegridcollectionnumgrids_ #define XdmfRetrieveDomainNumGrids xdmfretrievedomainnumgrids_ #define XdmfOpenDomainGrid xdmfopendomaingrid_ #define XdmfReadDomainGrid xdmfreaddomaingrid_ #define XdmfRemoveDomainGrid xdmfremovedomaingrid_ #define XdmfReplaceDomainGrid xdmfreplacedomaingrid_ #define XdmfRetrieveDomainGridTag xdmfretrievedomaingridtag_ #define XdmfRetrieveDomainGridName xdmfretrievedomaingridname_ #define XdmfRetrieveDomainGridNumProperties xdmfretrievedomaingridnumproperties_ #define XdmfRetrieveDomainGridProperty xdmfretrievedomaingridproperty_ #define XdmfRetrieveDomainGridPropertyByKey xdmfretrievedomaingridpropertybykey_ #define XdmfOpenGridCollectionGrid xdmfopengridcollectiongrid_ #define XdmfReadGridCollectionGrid xdmfreadgridcollectiongrid_ #define XdmfRemoveGridCollectionGrid xdmfremovegridcollectiongrid_ #define XdmfReplaceGridCollectionGrid xdmfreplacegridcollectiongrid_ #define XdmfRetrieveGridCollectionGridTag xdmfretrievegridcollectiongridtag_ #define XdmfRetrieveGridCollectionGridName xdmfretrievegridcollectiongridname_ #define XdmfRetrieveGridCollectionGridNumProperties xdmfretrievegridcollectiongridnumproperties_ #define XdmfRetrieveGridCollectionGridProperty xdmfretrievegridcollectiongridproperty_ #define XdmfRetrieveGridCollectionGridPropertyByKey xdmfretrievegridcollectiongridpropertybykey_ #define XdmfRetrieveGridCollectionType xdmfretrievegridcollectiontype_ #define XdmfRetrieveTime xdmfretrievetime_ #define XdmfRetrieveTopologyTag xdmfretrievetopologytag_ #define XdmfRetrieveTopologyType xdmfretrievetopologytype_ #define XdmfRetrieveTopologyValueType xdmfretrievetopologyvaluetype_ #define XdmfRetrieveTopologyValues xdmfretrievetopologyvalues_ #define XdmfRetrieveTopologyNumElements xdmfretrievetopologynumelements_ #define XdmfRetrieveTopologySize xdmfretrievetopologysize_ #define XdmfClearPreviousTopologies xdmfclearprevioustopologies_ #define XdmfModifyTopologyValues xdmfmodifytopologyvalues_ #define XdmfRetrieveTopologyNumProperties xdmfretrievetopologynumproperties_ #define XdmfRetrieveTopologyProperty xdmfretrievetopologyproperty_ #define XdmfRetrieveTopologyPropertyByKey xdmfretrievetopologypropertybykey_ #define XdmfSetTopologyAsVariable xdmfsettopologyasvariable_ #define XdmfSetTopologyAsSubsetReference xdmfsettopologyassubsetreference_ #define XdmfRetrieveGeometryTag xdmfretrievegeometrytag_ #define XdmfRetrieveGeometryType xdmfretrievegeometrytype_ #define XdmfRetrieveGeometryValues xdmfretrievegeometryvalues_ #define XdmfRetrieveGeometryValueType xdmfretrievegeometryvaluetype_ #define XdmfRetrieveGeometryNumPoints xdmfretrievegeometrynumpoints_ #define XdmfRetrieveGeometrySize xdmfretrievegeometrysize_ #define XdmfClearPreviousGeometries xdmfclearpreviousgeometries_ #define XdmfModifyGeometryValues xdmfmodifygeometryvalues_ #define XdmfRetrieveGeometryNumProperties xdmfretrievegeometrynumproperties_ #define XdmfRetrieveGeometryProperty xdmfretrievegeometryproperty_ #define XdmfRetrieveGeometryPropertyByKey xdmfretrievegeometrypropertybykey_ #define XdmfSetGeometryAsVariable xdmfsetgeometryasvariable_ #define XdmfSetGeometryAsSubsetReference xdmfsetgeometryassubsetreference_ #define XdmfSetDimensions xdmfsetdimensions_ #define XdmfClearDimensionsHeavyData xdmfcleardimensionsheavydata_ #define XdmfSetDimensionsHDF5 xdmfsetdimensionshdf5_ #define XdmfSetDimensionsBinary xdmfsetdimensionsbinary_ #define XdmfOpenPreviousDimensions xdmfopenpreviousdimensions_ #define XdmfClearPreviousDimensions xdmfclearpreviousdimensions_ #define XdmfModifyDimensionsValues xdmfmodifydimensionsvalues_ #define XdmfRetrieveDimensionsTag xdmfretrievedimensionstag_ #define XdmfRetrieveDimensionsType xdmfretrievedimensionstype_ #define XdmfRetrieveDimensionsValueType xdmfretrievedimensionsvaluetype_ #define XdmfRetrieveDimensionsValues xdmfretrievedimensionsvalues_ #define XdmfRetrieveDimensionsNumElements xdmfretrievedimensionsnumelements_ #define XdmfRetrieveDimensionsSize xdmfretrievedimensionssize_ #define XdmfRetrieveDimensionsNumProperties xdmfretrievedimensionsnumproperties_ #define XdmfRetrieveDimensionsProperty xdmfretrievedimensionsproperty_ #define XdmfRetrieveDimensionsPropertyByKey xdmfretrievedimensionspropertybykey_ #define XdmfSetOrigin xdmfsetorigin_ #define XdmfClearOriginHeavyData xdmfclearoriginheavydata_ #define XdmfSetOriginHDF5 xdmfsetoriginhdf5_ #define XdmfSetOriginBinary xdmfsetoriginbinary_ #define XdmfSetPreviousOrigin xdmfsetpreviousorigin_ #define XdmfClearPreviousOrigins xdmfclearpreviousorigins_ #define XdmfModifyOriginValues xdmfmodifyoriginvalues_ #define XdmfRetrieveOriginTag xdmfretrieveorigintag_ #define XdmfRetrieveOriginType xdmfretrieveorigintype_ #define XdmfRetrieveOriginValueType xdmfretrieveoriginvaluetype_ #define XdmfRetrieveOriginValues xdmfretrieveoriginvalues_ #define XdmfRetrieveOriginNumElements xdmfretrieveoriginnumelements_ #define XdmfRetrieveOriginSize xdmfretrieveoriginsize_ #define XdmfRetrieveOriginNumProperties xdmfretrieveoriginnumproperties_ #define XdmfRetrieveOriginProperty xdmfretrieveoriginproperty_ #define XdmfRetrieveOriginPropertyByKey xdmfretrieveoriginpropertybykey_ #define XdmfSetBrick xdmfsetbrick_ #define XdmfClearBrickHeavyData xdmfclearbrickheavydata_ #define XdmfSetBrickHDF5 xdmfsetbrickhdf5_ #define XdmfSetBrickBinary xdmfsetbrickbinary_ #define XdmfSetPreviousBrick xdmfsetpreviousbrick_ #define XdmfClearPreviousBricks xdmfclearpreviousbricks_ #define XdmfModifyBrickValues xdmfmodifybrickvalues_ #define XdmfRetrieveBrickTag xdmfretrievebricktag_ #define XdmfRetrieveBrickType xdmfretrievebricktype_ #define XdmfRetrieveBrickValueType xdmfretrievebrickvaluetype_ #define XdmfRetrieveBrickValues xdmfretrievebrickvalues_ #define XdmfRetrieveBrickNumElements xdmfretrievebricknumelements_ #define XdmfRetrieveBrickSize xdmfretrievebricksize_ #define XdmfRetrieveBrickNumProperties xdmfretrievebricknumproperties_ #define XdmfRetrieveBrickProperty xdmfretrievebrickproperty_ #define XdmfRetrieveBrickPropertyByKey xdmfretrievebrickpropertybykey_ #define XdmfAddMap xdmfaddmap_ #define XdmfRetrieveNumMaps xdmfretrievenummaps_ #define XdmfAddRemoteNodeID xdmfaddremotenodeid_ #define XdmfRetrieveRemoteNodeIDs xdmfretrieveremotenodeids_ #define XdmfRetrieveNumRemoteNodeIDs xdmfretrievenumremotenodeids_ #define XdmfRemoveMap xdmfremovemap_ #define XdmfClearMaps xdmfclearmaps_ #define XdmfStoreMap xdmfstoremap_ #define XdmfAddPreviousMap xdmfaddpreviousmap_ #define XdmfClearPreviousMaps xdmfclearpreviousmaps_ #define XdmfRetrieveMapNumProperties xdmfretrievemapnumproperties_ #define XdmfRetrieveMapProperty xdmfretrievemapproperty_ #define XdmfRetrieveMapPropertyByKey xdmfretrievemappropertybykey_ #define XdmfRetrieveNumAttributes xdmfretrievenumattributes_ #define XdmfClearAttributes xdmfclearattributes_ #define XdmfModifyAttributeValues xdmfmodifyattributevalues_ #define XdmfRemoveAttribute xdmfremoveattribute_ #define XdmfReplaceAttribute xdmfreplaceattribute_ #define XdmfOpenAttribute xdmfopenattribute_ #define XdmfRetrieveAttributeTag xdmfretrieveattributetag_ #define XdmfRetrieveAttributeName xdmfretrieveattributename_ #define XdmfRetrieveAttributeType xdmfretrieveattributetype_ #define XdmfRetrieveAttributeCenter xdmfretrieveattributecenter_ #define XdmfRetrieveAttributeValues xdmfretrieveattributevalues_ #define XdmfRetrieveAttributeValueType xdmfretrieveattributevaluetype_ #define XdmfRetrieveAttributeSize xdmfretrieveattributesize_ #define XdmfClearPreviousAttributes xdmfclearpreviousattributes_ #define XdmfRetrieveAttributeNumProperties xdmfretrieveattributenumproperties_ #define XdmfRetrieveAttributeProperty xdmfretrieveattributeproperty_ #define XdmfRetrieveAttributePropertyByKey xdmfretrieveattributepropertybykey_ #define XdmfSetAttributeAsVariable xdmfsetattributeasvariable_ #define XdmfSetAttributeAsSubsetReference xdmfsetattributeassubsetreference_ #define XdmfAddCoordinate xdmfaddcoordinate_ #define XdmfClearCoordinateHeavyData xdmfclearcoordinateheavydata_ #define XdmfSetCoordinateHDF5 xdmfsetcoordinatehdf5_ #define XdmfSetCoordinateBinary xdmfsetcoordinatebinary_ #define XdmfAddPreviousCoordinate xdmfaddpreviouscoordinate_ #define XdmfClearPreviousCoordinates xdmfclearpreviouscoordinates_ #define XdmfModifyCoordinateValues xdmfmodifycoordinatevalues_ #define XdmfRetrieveNumCoordinates xdmfretrievenumcoordinates_ #define XdmfRemoveCoordinate xdmfremovecoordinate_ #define XdmfReplaceCoordinate xdmfreplacecoordinate_ #define XdmfRetrieveCoordinateTag xdmfretrievecoordinatetag_ #define XdmfRetrieveCoordinateName xdmfretrievecoordinatename_ #define XdmfRetrieveCoordinateValues xdmfretrievecoordinatevalues_ #define XdmfRetrieveCoordinateValueType xdmfretrievecoordinatevaluetype_ #define XdmfRetrieveCoordinateSize xdmfretrievecoordinatesize_ #define XdmfClearCoordinates xdmfclearcoordinates_ #define XdmfRetrieveCoordinateNumProperties xdmfretrievecoordinatenumproperties_ #define XdmfRetrieveCoordinateProperty xdmfretrievecoordinateproperty_ #define XdmfRetrieveCoordinatePropertyByKey xdmfretrievecoordinatepropertybykey_ #define XdmfSetCoordinateAsVariable xdmfsetcoordinateasvariable_ #define XdmfSetCoordinateAsSubsetReference xdmfsetcoordinateassubsetreference_ #define XdmfRetrieveSetTag xdmfretrievesettag_ #define XdmfRetrieveSetName xdmfretrievesetname_ #define XdmfRetrieveSetType xdmfretrievesettype_ #define XdmfAddSet xdmfaddset_ #define XdmfAddPreviousSet xdmfaddpreviousset_ #define XdmfClearSetHeavyData xdmfclearsetheavydata_ #define XdmfSetSetHDF5 xdmfsetsethdf5_ #define XdmfSetSetBinary xdmfsetsetbinary_ #define XdmfClearPreviousSets xdmfclearprevioussets_ #define XdmfClearSets xdmfclearsets_ #define XdmfModifySetValues xdmfmodifysetvalues_ #define XdmfRetrieveNumSets xdmfretrievenumsets_ #define XdmfRetrieveSetSize xdmfretrievesetsize_ #define XdmfRetrieveSetValues xdmfretrievesetvalues_ #define XdmfRetrieveSetValueType xdmfretrievesetvaluetype_ #define XdmfOpenSet xdmfopenset_ #define XdmfRemoveSet xdmfremoveset_ #define XdmfReplaceSet xdmfreplaceset_ #define XdmfRetrieveSetNumProperties xdmfretrievesetnumproperties_ #define XdmfRetrieveSetProperty xdmfretrievesetproperty_ #define XdmfRetrieveSetPropertyByKey xdmfretrievesetpropertybykey_ #define XdmfSetSetAsVariable xdmfsetsetasvariable_ #define XdmfSetSetAsSubsetReference xdmfsetsetassubsetreference_ #define XdmfRetrieveNumInformation xdmfretrievenuminformation_ #define XdmfRetrieveInformationTag xdmfretrieveinformationtag_ #define XdmfClearInformations xdmfclearinformations_ #define XdmfRetrieveInformation xdmfretrieveinformation_ #define XdmfRemoveInformation xdmfremoveinformation_ #define XdmfReplaceInformation xdmfreplaceinformation_ #define XdmfOpenInformation xdmfopeninformation_ #define XdmfRetrieveInformationByKey xdmfretrieveinformationbykey_ #define XdmfRemoveInformationByKey xdmfremoveinformationbykey_ #define XdmfReplaceInformationByKey xdmfreplaceinformationbykey_ #define XdmfClearPreviousInformation xdmfclearpreviousinformation_ #define XdmfRetrieveInformationNumProperties xdmfretrieveinformationnumproperties_ #define XdmfRetrieveInformationProperty xdmfretrieveinformationproperty_ #define XdmfRetrieveInformationPropertyByKey xdmfretrieveinformationpropertybykey_ #define XdmfAddInformationArray xdmfaddinformationarray_ #define XdmfClearInformationArrayHeavyData xdmfclearinformationarrayheavydata_ #define XdmfSetInformationArrayHDF5 xdmfsetinformationarrayhdf5_ #define XdmfSetInformationArrayBinary xdmfsetinformationarraybinary_ #define XdmfInsertInformationIntoInformation xdmfinsertinformationintoinformation_ #define XdmfModifyInformationArray xdmfmodifyinformationarray_ #define XdmfRemoveInformationArray xdmfremoveinformationarray_ #define XdmfRetrieveInformationArraySize xdmfretrieveinformationarraysize_ #define XdmfRetrieveInformationArrayValueType xdmfretrieveinformationarrayvaluetype_ #define XdmfRetrieveInformationArrayValues xdmfretrieveinformationarrayvalues_ #define XdmfSetInformationArrayAsVariable xdmfsetinformationarrayasvariable_ #define XdmfSetInformationArrayAsSubsetReference xdmfsetinformationarrayassubsetreference_ #define XdmfAddFunctionAsAttribute xdmfaddfunctionasattribute_ #define XdmfAddFunctionAsCoordinate xdmfaddfunctionascoordinate_ #define XdmfAddFunctionAsSet xdmfaddfunctionasset_ #define XdmfAddFunctionAsInformationArray xdmfaddfunctionasinformationarray_ #define XdmfSetFunctionAsTopology xdmfsetfunctionastopology_ #define XdmfSetFunctionAsGeometry xdmfsetfunctionasgeometry_ #define XdmfAddSubsetAsAttribute xdmfaddsubsetasattribute_ #define XdmfAddSubsetAsCoordinate xdmfaddsubsetascoordinate_ #define XdmfAddSubsetAsSet xdmfaddsubsetasset_ #define XdmfAddSubsetAsInformationArray xdmfaddsubsetasinformationarray_ #define XdmfSetSubsetAsTopology xdmfsetsubsetastopology_ #define XdmfSetSubsetAsGeometry xdmfsetsubsetasgeometry_ #define XdmfClearFunctionVariables xdmfclearfunctionvariables_ #define XdmfRemoveFunctionVariable xdmfremovefunctionvariable_ #define XdmfClearPrevious xdmfclearprevious_ #endif /** * @brief XdmfFortran provides an interface to outputting xdmf files * from Fortran. * * Fortran programs will include Xdmf.f and link against libXdmfUtils. */ class XDMFUTILS_EXPORT XdmfFortran { public: /** * Create a new xdmf file from fortran. * * @return Constructed XdmfFortran. */ XdmfFortran(); virtual ~XdmfFortran(); /** * Add an attribute that will be inserted into the next grid or grid * collection. * * @param name Name of the attribute. * @param attributeCenter The attribute center. * @param attributeType The attribute type. * @param numValues Number of attribute values to copy. * @param arrayType Type of attribute values. * @param values Array of attribute values. * * @return int providing id to fortran if reusing. */ int addAttribute(const char * const name, const int attributeCenter, const int attributeType, const unsigned int numValues, const int arrayType, const void * const values); /** * Remove heavy data linkage from the specified attribute. * * @param index Index of the Attribute which will have its heavydata linkage removed. */ void clearAttributeHeavyData(const int index); /** * Set HDF5 linkage for the specified attribute. * * @param index Index of the Attribute which will have its hdf5 linkage set. * @param hdf5File Filename for the hdf5 linkage * @param hdf5Dataset Dataset name for the hdf5 linkage * @param start Starting index in the hdf5 dataset * @param stride Distance between values in the hdf5 dataset * @param numValues Number of values in the hdf5 dataset * @param dataspace Total size of the hdf5 dataset. */ void setAttributeHDF5(const int index, const char * hdf5File, const char * hdf5Dataset, const unsigned int start, const unsigned int stride, const unsigned int numValues, const unsigned int dataspace); /** * Set Binary linkage for the specified attribute. * * @param index Index of the Attribute which will have its binary linkage set. * @param binFile Filename for the binary linkage * @param endian Endianness of the dataset * @param seek Offset of the dataset in the binary file * @param start Starting index in the binary dataset * @param stride Distance between values in the binary dataset * @param numValues Number of values in the binary dataset * @param dataspace Total size of the binary dataset. */ void setAttributeBinary(const int index, const char * binFile, const int endian, const unsigned int seek, const unsigned int start, const unsigned int stride, const unsigned int numValues, const unsigned int dataspace); /** * Add unstructured grid to domain or collection. Inserts geometry, topology, * attributes, and informations into grid. If no geometry or * topology is set, an error is generated. * The top of parentAttributes, parentInformations, and parentSets * are placed in mAttributes, mInformations, and mSets * * @param name Name of the grid. * @param writeToHDF5 Whether to write the grid to hdf5 after adding it */ void addGrid(const char * const name, const bool writeToHDF5); /** * Add curvilinear grid to domain or collection. Inserts geometry, dimensions, * attributes, and informations into grid. If no geometry or * dimensions are set, an error is generated. * The top of parentAttributes, parentInformations, and parentSets * are placed in mAttributes, mInformations, and mSets * * @param name Name of the grid. * @param writeToHDF5 Whether to write the grid to hdf5 after adding it */ void addGridCurvilinear(const char * const name, const bool writeToHDF5); /** * Add rectilinear grid to domain or collection. Inserts coordinate, * attributes, and informations into grid. If no geometry or * topology is set, an error is generated. * The top of parentAttributes, parentInformations, and parentSets * are placed in mAttributes, mInformations, and mSets * * @param name Name of the grid. * @param writeToHDF5 Whether to write the grid to hdf5 after adding it */ void addGridRectilinear(const char * const name, const bool writeToHDF5); /** * Add rectilinear grid to domain or collection. Inserts origin, brick, dimensions, * attributes, and informations into grid. If no geometry or * topology is set, an error is generated. * The top of parentAttributes, parentInformations, and parentSets * are placed in mAttributes, mInformations, and mSets * * @param name Name of the grid. * @param writeToHDF5 Whether to write the grid to hdf5 after adding it */ void addGridRegular(const char * const name, const bool writeToHDF5); /** * Add grid collection to domain or collection. Inserts attributes * and informations into collection. * The top of parentAttributes, parentInformations, and parentSets * are placed in mAttributes, mInformations, and mSets * * @param name Name of the collection. * @param gridCollectionType The grid collection type. */ void addGridCollection(const char * const name, const int gridCollectionType); /** * Adds a grid that is a reference to a file. * * @param filePath Path to the file where the grid is located. * @param xmlPath Xml path to the grid being referenced. */ void addGridCollectionReference(const char * filePath, const char * xmlPath); /** * Adds a grid that is a reference to a file. * * @param gridType The type of grid being referenced. * @param filePath Path to the file where the grid is located. * @param xmlPath Xml path to the grid being referenced. */ void addGridReference(const int gridType, const char * filePath, const char * xmlPath); /** * Add an information that will be inserted into the next added * grid or grid collection. * * @param key String containing the key of the information to * create. * @param value String containing the value of the information to * create. * * @return int providing id to fortran if reusing. */ int addInformation(const char * const key, const char * const value); /** * Add an attribute that will be inserted into the next grid or grid * collection. This will reuse a previously added attribute so that * xpointers can be used when writing to file (reducing file size). * * @param attributeId Returned from a previous addAttribute(). */ void addPreviousAttribute(const int attributeId); /** * Add an information that will be inserted into the next grid or grid * collection. This will reuse a previously added information so that * xpointers can be used when writing to file (reducing file size). * * @param informationId Returned from a previous addInformation(). */ void addPreviousInformation(const int informationId); /** * Closes grid collection. No additional grids or collections can be * added to the current collection. * * @param writeToHDF5 Whether to write the grid to hdf5 after adding it */ void closeGridCollection(const bool writeToHDF5); /** * Set the geometry (point data) that will be added to the next grid. * * @param geometryType The geometry type. * @param numValues Number of point values to copy. * @param arrayType Type of point values. * @param pointValues Array of point values. * * @return int providing id to fortran if reusing. */ int setGeometry(const int geometryType, const unsigned int numValues, const int arrayType, const void * const pointValues); /** * Remove heavy data linkage from the geometry. */ void clearGeometryHeavyData(); /** * Set HDF5 linkage for the geometry. * * @param hdf5File Filename for the hdf5 linkage * @param hdf5Dataset Dataset name for the hdf5 linkage * @param start Starting index in the hdf5 dataset * @param stride Distance between values in the hdf5 dataset * @param numValues Number of values in the hdf5 dataset * @param dataspace Total size of the hdf5 dataset. */ void setGeometryHDF5(const char * hdf5File, const char * hdf5Dataset, const unsigned int start, const unsigned int stride, const unsigned int numValues, const unsigned int dataspace); /** * Set Binary linkage for the geometry. * * @param binFile Filename for the binary linkage * @param endian Endianness of the dataset * @param seek Offset of the dataset in the binary file * @param start Starting index in the binary dataset * @param stride Distance between values in the binary dataset * @param numValues Number of values in the binary dataset * @param dataspace Total size of the binary dataset. */ void setGeometryBinary(const char * binFile, const int endian, const unsigned int seek, const unsigned int start, const unsigned int stride, const unsigned int numValues, const unsigned int dataspace); /** * Set the geometry (point data) that will be added to the next grid. * This will reuse a previously set geometry so that xpointers can be * used when writing to file (reducing file size); * * @param geometryId Returned from previous setGeometry() */ void setPreviousGeometry(const int geometryId); /** * Set the topology (connectivity data) that will be added to the * next grid. This will reuse a previously set topology so that * xpointers can be used when writing to file (reducing file size); * * @param topologyId Returned from previous setTopology() */ void setPreviousTopology(const int topologyId); /** * Set the time that will be added to the next grid or grid * collection. * * @param time Time value to insert. */ void setTime(const double time); /** * Set the topology (connectivity data) that will be added to the * next grid. * * @param topologyType The topology type. * @param numValues Number of connectivity values to copy. * @param arrayType Type of connectivity values. * @param connectivityValues Array of connectivity values. * * @return int providing id to fortran if reusing. */ int setTopology(const int topologyType, const unsigned int numValues, const int arrayType, const void * const connectivityValues, const int numNodes); /** * Remove heavy data linkage from the topology. */ void clearTopologyHeavyData(); /** * Set HDF5 linkage for the topology. * * @param hdf5File Filename for the hdf5 linkage * @param hdf5Dataset Dataset name for the hdf5 linkage * @param start Starting index in the hdf5 dataset * @param stride Distance between values in the hdf5 dataset * @param numValues Number of values in the hdf5 dataset * @param dataspace Total size of the hdf5 dataset. */ void setTopologyHDF5(const char * hdf5File, const char * hdf5Dataset, const unsigned int start, const unsigned int stride, const unsigned int numValues, const unsigned int dataspace); /** * Set Binary linkage for the topology. * * @param binFile Filename for the binary linkage * @param endian Endianness of the dataset * @param seek Offset of the dataset in the binary file * @param start Starting index in the binary dataset * @param stride Distance between values in the binary dataset * @param numValues Number of values in the binary dataset * @param dataspace Total size of the binary dataset. */ void setTopologyBinary(const char * binFile, const int endian, const unsigned int seek, const unsigned int start, const unsigned int stride, const unsigned int numValues, const unsigned int dataspace); /** * Returns the number of grid collections currently * contained in the domain * * @return The number of grid collections */ int retrieveNumDomainGridCollections(); /** * Returns the number of grid collections currently * contained in the grid collection on top of mGridCollections * * @return The number of grid collections */ int numGridCollectionGridCollections(); /** * Fills the provided character pointer with the value of the Domain's tag * * @param tag The pointer to the point where the string will be written * @param tagLength The size of the array assigned at the tag pointer */ void retrieveDomainTag(char * tag, const int tagLength); /** * Returns the number of properties contained within the domain. * * @return The number of properties that the domain has. */ int retrieveDomainNumProperties(); /** * Fills the key and length from the property at the index specified. * Since this refers to a map it is not completely reliable that the values will * stay at the same indexes when new values are added. * Using retrieve by key is more reliable. * * Throws an error if the index is out of bounds * * @param index The index of the property to fill from * @param key The pointer to the location where the key will be written * @param keyLength The size of the array assigned to the key pointer * @param value The pointer to the location where the value will be written * @param valueLength The size of the array assigned to the value pointer */ void retrieveDomainProperty(const int index, char * key, const int keyLength, char * value, const int valueLength); /** * Searches the properties of the domain for one with the specified key. * Stores the value found at a provided pointer. * * Throws an error if the key does not match any values * * @param key A pointer to the key being searched for * @param value A pointer to the location where the value will be written * @param valueLength The size of the Array assigned to the value pointer */ void retrieveDomainPropertyByKey(char * key, char * value, const int valueLength); /** * Makes the specified grid collection owned by the domain accessable * by adding it to mGridCollections. * Pushes the previous contents of mAttributes, mInformations, and mSets * onto parentAttributes, parentInformations, and parentSets * * Returns an error if the index is out of bounds * * @param index The index of the grid collection in the domain * that is to be opened * @param openMaps Set to 1 to open maps * @param openAttributes Set to 1 to open attributes * @param openInformation Set to 1 to open information * @param openSets Set to 1 to open sets */ void openDomainGridCollection(const int index, const int openMaps, const int openAttributes, const int openInformation, const int openSets); /** * Reads the the grid reference of the grid collection at the specified index in * the Domain. * * @param index The index of the grid collection to be read */ void readDomainGridCollection(const int index); /** * Removes the specifed grid collection from mDomain's grid collections * * Throws an error if the index is out of bounds * * @param index The index of the grid collection to be removed */ void removeDomainGridCollection(const int index); /** * Makes the specified grid collection owned by the grid collection on top of * mGridCollections accessable by adding it to mGridCollections. * Pushes the previous contents of mAttributes, mInformations, and mSets * onto parentAttributes, parentInformations, and parentSets * * Returns an error if the index is out of bounds * * @param index The index of the grid collection in the domain * that is to be opened * @param openMaps Set to 1 to open maps * @param openAttributes Set to 1 to open attributes * @param openInformation Set to 1 to open information * @param openSets Set to 1 to open sets */ void openGridCollectionGridCollection(const int index, const int openMaps, const int openAttributes, const int openInformation, const int openSets); /** * Reads the the grid reference of the grid collection at the specified index in * the grid collection on the top of the stack. * * @param index The index of the grid collection to be read */ void readGridCollectionGridCollection(const int index); /** * Removes the specifed grid collection from the * grid collections owned by the grid collection on top of mGridCollections * * Throws an error if the index is out of bounds * * @param index The index of the grid collection to be removed */ void removeGridCollectionGridCollection(const int index); /** * Fills the provided character pointer with the value of the name of the * grid collection on top of mGridCollections * * @param name The pointer to the point where the string * will be written * @param nameLength The size of the array assigned at the name pointer */ void retrieveGridCollectionName(char * name, const int nameLength); /** * Fills the provided character pointer with the value of the tag of the * grid collection on top of mGridCollections * * @param tag The pointer to the point where the string * will be written * @param tagLength The size of the array assigned at the tag pointer */ void retrieveGridCollectionTag(char * tag, const int tagLength); /** * Returns the number of properties contained within the grid collection on * top of mGridCollections. * * @return The number of properties that the grid collection has. */ int retrieveGridCollectionNumProperties(); /** * Fills the key and length from the property at the index specified. * Since this refers to a map it is not completely reliable that the values will * stay at the same indexes when new values are added. * Using retrieve by key is more reliable. * * Throws an error if the index is out of bounds * * @param index The index of the property to fill from * @param key The pointer to the location where the key * will be written * @param keyLength The size of the array assigned to the key pointer * @param value The pointer to the location where the value * will be written * @param valueLength The size of the array assigned to the value pointer */ void retrieveGridCollectionProperty(const int index, char * key, const int keyLength, char * value, const int valueLength); /** * Searches the properties of the Grid Collection on top of mGridCollections * for one with the specified key. * Stores the value found at a provided pointer. * * Throws an error if the key does not match any values * * @param key A pointer to the key being searched for * @param value A pointer to the location where the value * will be written * @param valueLength The size of the Array assigned to the value pointer */ void retrieveGridCollectionPropertyByKey(char * key, char * value, int const valueLength); /** * Opens a grid of the specified type from the domain by * placing its topography, geometry, time, etc.. * into the appropriate containers * * Returns an error if the index is out of bounds * * @param gridType The type of the grid expressed as an integer, * Ex: XDMF_GRID_TYPE_UNSTRUCTURED * @param index The index of the grid to be opened * @param openMaps Set to 1 to open maps * @param openAttributes Set to 1 to open attributes * @param openInformation Set to 1 to open information * @param openSets Set to 1 to open sets */ void openDomainGrid(const int gridType, const int index, const int openMaps, const int openAttributes, const int openInformation, const int openSets); /** * Read the grid reference of a grid of the specified type at the specified * index contained within the domain. */ void readDomainGrid(const int gridType, const int index); /** * Removes a grid of the specified type from the domain * * Returns an error if the index is out of bounds * * @param gridType The type of the grid expressed as an integer, * Ex: XDMF_GRID_TYPE_UNSTRUCTURED * @param index The index of the grid to be opened */ void removeDomainGrid(const int gridType, const int index); /** * Replaces a grid of the specified type from the domain by * placing the appropriate data into the specified grid * * Returns an error if the index is out of bounds * * @param gridType The type of the grid expressed as an integer, * Ex: XDMF_GRID_TYPE_UNSTRUCTURED * @param index The index of the grid to be opened * @param name A pointer to the name of the grid replacing * the indicated grid */ void replaceDomainGrid(const int gridType, const int index, char * name); /** * Retrieves the name of the specified grid and places it at the locaiton provided. * * Returns an error if the index is out of bounds * * @param gridType The of the specified grid represented as an integer, * Ex: XDMF_GRID_TYPE_UNSTRUCTURED * @param index The index of the specified grid * @param name The pointer to where the string will be written * @param nameLength The size of the array assigned to the name pointer */ void retrieveDomainGridName(const int gridType, const int index, char * name, const int nameLength); /** * Retrieves the tag of the specified grid and places it at the location provided. * * Returns an error if the index is out of bounds * * @param gridType The of the specified grid represented as an integer, * Ex: XDMF_GRID_TYPE_UNSTRUCTURED * @param index The index of the specified grid * @param tag The pointer to the point where the string will be written * @param tagLength The size of the array assigned at the tag pointer */ void retrieveDomainGridTag(const int gridType, const int index, char * tag, const int tagLength); /** * Retrieves the number of properties that the specified grid has. * * Returns an error if the index is out of bounds * * @param gridType The of the specified grid represented as an integer, * Ex: XDMF_GRID_TYPE_UNSTRUCTURED * @param index The index of the specified grid * * @return The number of properties that thte grid has. */ int retrieveDomainGridNumProperties(const int gridType, const int index); /** * Retrieves the key and value of the property at the specified index * in the properties of the grid at the specified index. * * Since the properties are stored in a map the location of individual pairs are mutable. * Use retrieve by key for more oonsistent results. * * Returns an error if the index is out of bounds * * @param gridType The of the specified grid represented as an integer, * Ex: XDMF_GRID_TYPE_UNSTRUCTURED * @param gridIndex The index of the specified grid * @param index The index of the property to fill from * @param key The pointer to the location where the key will be written * @param keyLength The size of the array assigned to the key pointer * @param value The pointer to the location where the value will be written * @param valueLength The size of the array assigned to the value pointer */ void retrieveDomainGridProperty(const int gridType, const int gridIndex, const int index, char * key, const int keyLength, char * value, const int valueLength); /** * Searches for the property that corresponds with the supplied key * in the properties of the grid at the specified index. * * Returns an error if the index is out of bounds * Returns an error if the key has no matching value * * @param gridType The of the specified grid represented as an integer, * Ex: XDMF_GRID_TYPE_UNSTRUCTURED * @param index The index of the specified grid * @param key A pointer to the key being searched for * @param value A pointer to the location where the value will be written * @param valueLength The size of the Array assigned to the value pointer */ void retrieveDomainGridPropertyByKey(const int gridType, const int index, char * key, char * value, const int valueLength); /** * Opens a grid of the specified type from the grid collection * on top of mGridCollections by placing its * topography, geometry, time, etc.. into the appropriate * containers * * Returns an error if the index is out of bounds * * @param gridType The type of the grid expressed as an integer, * Ex: XDMF_GRID_TYPE_UNSTRUCTURED * @param index The index of the grid to be opened * @param openMaps Set to 1 to open maps * @param openAttributes Set to 1 to open attributes * @param openInformation Set to 1 to open information * @param openSets Set to 1 to open sets */ void openGridCollectionGrid(const int gridType, const int index, const int openMaps, const int openAttributes, const int openInformation, const int openSets); /** * Reads the grid reference for a grid of the specified type * at the specified index of the grid collection on the top of the stack. */ void readGridCollectionGrid(const int gridType, const int index); /** * Removes a grid of the specified type from the grid collection * on top of mGridCollections * * Returns an error if the index is out of bounds * * @param gridType The type of the grid expressed as an integer, * Ex: XDMF_GRID_TYPE_UNSTRUCTURED * @param index The index of the grid to be opened */ void removeGridCollectionGrid(const int gridType, const int index); /** * Replaces a grid of the specified type from the grid collection * on top of mGridCollections by placing the appropriate data into it * * Returns an error if the index is out of bounds * * @param gridType The type of the grid expressed as an integer, * Ex: XDMF_GRID_TYPE_UNSTRUCTURED * @param index The index of the grid to be opened * @param name A pointer to the name of the grid to be * replacing the specified one */ void replaceGridCollectionGrid(const int gridType, const int index, char * name); /** * Retrieves the name of the specified grid and places it at the locaiton provided. * * Returns an error if the index is out of bounds * * @param gridType The type of the grid expressed as an integer, * Ex: XDMF_GRID_TYPE_UNSTRUCTURED * @param index The index of the specified grid * @param name The pointer to where the string will be written * @param nameLength The size of the array assigned to the name pointer */ void retrieveGridCollectionGridName(const int gridType, const int index, char * name, const int nameLength); /** * Retrieves the tag of the specified grid and places it at the location provided. * * Returns an error if the index is out of bounds * * @param gridType The type of the grid expressed as an integer, * Ex: XDMF_GRID_TYPE_UNSTRUCTURED * @param index The index of the specified grid * @param tag The pointer to the point where the string will be written * @param tagLength The size of the array assigned at the tag pointer */ void retrieveGridCollectionGridTag(const int gridType, const int index, char * tag, const int tagLength); /** * Retrieves the number of properties that the specified grid has. * * Returns an error if the index is out of bounds * * @param gridType The type of the grid expressed as an integer, * Ex: XDMF_GRID_TYPE_UNSTRUCTURED * @param index The index of the specified grid * * @return The number of properties that thte grid has. */ int retrieveGridCollectionGridNumProperties(const int gridType, const int index); /** * Retrieves the key and value of the property at the specified index * in the properties of the grid at the specified index. * * Since the properties are stored in a map the location of individual pairs are mutable. * Use retrieve by key for more oonsistent results. * * Returns an error if the index is out of bounds * * @param gridType The type of the grid expressed as an integer, * Ex: XDMF_GRID_TYPE_UNSTRUCTURED * @param GridIndex The index of the specified grid * @param index The index of the property to fill from * @param key The pointer to the location where the key will be written * @param keyLength The size of the array assigned to the key pointer * @param value The pointer to the location where the value will be written * @param valueLength The size of the array assigned to the value pointer */ void retrieveGridCollectionGridProperty(const int gridType, const int gridIndex, const int index, char * key, const int keyLength, char * value, const int valueLength); /** * Searches for the property that corresponds with the supplied key * in the properties of the grid at the specified index. * * Returns an error if the index is out of bounds * Returns an error if the key has no matching value * * @param gridType The type of the grid expressed as an integer, * Ex: XDMF_GRID_TYPE_UNSTRUCTURED * @param index The index of the specified grid * @param key A pointer to the key being searched for * @param value A pointer to the location where the value will be written * @param valueLength The size of the Array assigned to the value pointer */ void retrieveGridCollectionGridPropertyByKey(const int gridType, const int index, char * key, char * value, const int valueLength); /** * Returns the number of grids of a specified type that the domain contains * * @param gridType The specified type of grid as an integer, * Ex: XDMF_GRID_TYPE_UNSTRUCTURED * * @return The number of grids */ int numDomainGrids(const int gridType); /** * Returns the number of grids of a specified type that * the top grid collection in mGridCollections contains * * Returns an error if there are no grid collections in mGridCollections * * @param gridType The specified type of grid as an integer, * Ex: XDMF_GRID_TYPE_UNSTRUCTURED * * @return The number of grids */ int numGridCollectionGrids(const int gridType); /** * Returns the type of the grid collection on top of the mGridCollections stack * * @return The grid collection's type, Ex: XDMF_GRID_COLLECTION_TYPE_TEMPORAL */ int retrieveGridCollectionType(); /** * Returns the time stored in mTime * * @return The value of mTime as a float */ float retrieveTime(); /** * Retrieves the Geometry's tag and stores it into the provided pointer * * @param tag The location where the tag will be stored * @param tagLength The size fo the array at the provided pointer */ void retrieveGeometryTag(char * tag, const int tagLength); /** * Returns the geometry's type as an integer. * * Returns an error if it doesn't recognize the type or if the geometry isn't set * * @return The geometry's type, EX: XDMF_GEOMETRY_TYPE_XY */ int retrieveGeometryType(); /** * Returns the geometry's datatype as an integer. * * Returns an error if it doesn't recognize the type or if the geometry isn't set * * @return The geometry's type, EX: XDMF_ARRAY_TYPE_INT8 */ int retrieveGeometryValueType(); /** * Returns a pointer to the array of values contained in the geometry * * Returns an error if the geometry is not set * * @param values A void pointer to the array to recieve the * geometry's values * @param dataType An integer corresponding to the datatype that * the data will be stored in * @param numberRead The number of values read into the values array * @param startIndex The place to start reading from the attribute's array * @param arrayStride The distance between values read * (1 reads all values, 2 reads every other, ect..) * @param valueStride The distance between the places that the * read values are placed in the supplied array */ void retrieveGeometryValues(void * values, const int dataType, const int numberRead, const int startIndex, const int arrayStride, const int valueStride); /** * returns the number of points contained within the geometry * * @return The number of points */ int retrieveGeometryNumPoints(); /** * returns the size of the geometry * * @return The size */ int retrieveGeometrySize(); /** * Clears mPreviousGeometries. Use to reduce memory load. */ void clearPreviousGeometries(); /** * Overwrites a section of the geometry using the provided values. * * Returns an error if the geometry is not set * * @param values A pointer to the values to be written. * @param numValues The number of values to be pulled from the pointer. * @param arrayType The data type of the values to be inserted. * @param startIndex The point in the array for editing to start. * @param arrayStride The increment between value placements on the geometry. * @param valueStride The increment between value pulls from the * pointer written from. */ void modifyGeometryValues(void * values, const int arrayType, const int numValues, const int startIndex, const int arrayStride, const int valueStride); /** * Returns the number of properties currently stored in the geometry. * * @return The number of properties associated with the geometry */ int retrieveGeometryNumProperties(); /** * Retrieves the key and value of the property at the specifed index * of the Geometry * and modifies the values at the provided pointers * * Returns an error if the index is out of bounds * * @param index The index of the property that is * being retrieved * @param key A pointer to the location where the * key value will be stored * @param keyLength the size of the key variable * @param value A pointer to the location where the value * of the property will be stored * @param valueLength The size of the value variable */ void retrieveGeometryProperty(const int index, char * key, const int keyLength, char * value, const int valueLength); /** * Retrieves the value of a property of the geometry when given its key. * * Returns an error if the key has no matching value * * @param key A pointer to the value of the key that is * being searched for * @param value A pointer to the location where the value of the * property will be stored * @param valueLength The size of the value variable */ void retrieveGeometryPropertyByKey(char * key, char * value, const int valueLength); /** * Sets the current geometry as a function variable. * * @param varname The name that the geometry will be associated with. */ void setGeometryAsVariable(char * varname); /** * Sets the current geometry as the current subset reference. */ void setGeometryAsSubsetReference(); /** * Retrieves the topology's tag and stores it into the provided pointer * * @param tag The location where the tag will be stored * @param tagLength The size fo the array at the provided pointer */ void retrieveTopologyTag(char * tag, const int tagLength); /** * Returns the topology's type as an integer. * * Returns an error if it doesn't recognize the type or if the topology isn't set * * @return The topology's type, EX: XDMF_TOPOLOGY_TYPE_POLYVERTEX */ int retrieveTopologyType(); /** * Returns the topology's datatype as an integer. * * Returns an error if it doesn't recognize the type or if the topology isn't set * * @return The topology's data type, EX: XDMF_ARRAY_TYPE_INT8 */ int retrieveTopologyValueType(); /** * Returns a pointer to the array of values contained in the topology * * Returns an error if the topology is not set * * @param values A void pointer to the array to recieve the * topology's values * @param dataType An integer corresponding to the datatype that * the data will be stored in * @param numberRead The number of values read into the values array * @param startIndex The place to start reading from the attribute's array * @param arrayStride The distance between values read * (1 reads all values, 2 reads every other, ect..) * @param valueStride The distance between the places that the read values * are placed in the supplied array */ void retrieveTopologyValues(void * values, const int dataType, const int numberRead, const int startIndex, const int arrayStride, const int valueStride); /** * returns the number of elements contained within the topology * * @return The number of elements */ int retrieveTopologyNumElements(); /** * returns the size of the topology * * @return The size */ int retrieveTopologySize(); /** * Clears mPreviousTopologies. Use to reduce memory load. */ void clearPreviousTopologies(); /** * Overwrites a section of the topology using the provided values. * * Returns an error if the topology is not set * * @param values A pointer to the values to be written. * @param numValues The number of values to be pulled from the pointer. * @param arrayType The data type of the values to be inserted. * @param startIndex The point in the array for editing to start. * @param arrayStride The increment between value placements on the topology. * @param valueStride The increment between value pulls from the * pointer written from. */ void modifyTopologyValues(void * values, const int arrayType, const int numValues, const int startIndex, const int arrayStride, const int valueStride); /** * Returns the number of properties currently stored in the topology. * * @return The number of properties associated with the topology */ int retrieveTopologyNumProperties(); /** * Retrieves the key and value of the property at the specifed index of the Topology * and modifies the values at the provided pointers * * Returns an error if the index is out of bounds * * @param index The index of the property that is being retrieved * @param key A pointer to the location where the key value will be stored * @param keyLength the size of the key variable * @param value A pointer to the location where the value of the * property will be stored * @param valueLength The size of the value variable */ void retrieveTopologyProperty(const int index, char * key, const int keyLength, char * value, const int valueLength); /** * Retrieves the value of a property of the topology when given its key. * * Returns an error if the key has no matching value * * @param key A pointer to the value of the key that is * being searched for * @param value A pointer to the location where the value of * the property will be stored * @param valueLength The size of the value variable */ void retrieveTopologyPropertyByKey(char * key, char * value, const int valueLength); /** * Sets the topology as an array variable associated with a specific name. * Used in conjuction with Functions. * * @param varname The variable to accociate with the current topology. */ void setTopologyAsVariable(char * varname); /** * Sets the topology as the current subset reference. */ void setTopologyAsSubsetReference(); /** * Set the dimensions that will be added to the next grid. * * @param numValues Number of point values to copy. * @param arrayType Type of point values. * @param pointValues Array of point values. * * @return int providing id to fortran if reusing. */ int setDimensions(const int numValues, const int arrayType, void * pointValues); /** * Remove heavy data linkage from the dimensions. */ void clearDimensionsHeavyData(); /** * Set HDF5 linkage for the dimensions. * * @param hdf5File Filename for the hdf5 linkage * @param hdf5Dataset Dataset name for the hdf5 linkage * @param start Starting index in the hdf5 dataset * @param stride Distance between values in the hdf5 dataset * @param numValues Number of values in the hdf5 dataset * @param dataspace Total size of the hdf5 dataset. */ void setDimensionsHDF5(const char * hdf5File, const char * hdf5Dataset, const unsigned int start, const unsigned int stride, const unsigned int numValues, const unsigned int dataspace); /** * Set Binary linkage for the dimensions. * * @param binFile Filename for the binary linkage * @param endian Endianness of the dataset * @param seek Offset of the dataset in the binary file * @param start Starting index in the binary dataset * @param stride Distance between values in the binary dataset * @param numValues Number of values in the binary dataset * @param dataspace Total size of the binary dataset. */ void setDimensionsBinary(const char * binFile, const int endian, const unsigned int seek, const unsigned int start, const unsigned int stride, const unsigned int numValues, const unsigned int dataspace); /** * Replaces mDimensions with the specified dimensions from mPreviousDimensions * * Returns an error if the index is out of range * * @param index The index of the specified dimension */ void openPreviousDimensions(const int index); /** * Clears mPreviousDimensions. Use to reduce memory load. */ void clearPreviousDimensions(); /** * Overwrites a section of the dimensions using the provided values. * * Returns an error if the dimensions are not set * * @param values A pointer to the values to be written. * @param numValues The number of values to be pulled from the pointer. * @param arrayType The data type of the values to be inserted. * @param startIndex The point in the array for editing to start. * @param arrayStride The increment between value placements on * the dimensions. * @param valueStride The increment between value pulls from * the pointer written from. */ void modifyDimensionsValues(void * values, const int arrayType, const int numValues, const int startIndex, const int arrayStride, const int valueStride); /** * Retrieves the dimensions' tag and stores it into the provided pointer * * @param tag The location where the tag will be stored * @param tagLength The size fo the array at the provided pointer */ void retrieveDimensionsTag(char * tag, const int tagLength); /** * Returns the dimensions' datatype as an integer. * * Returns an error if it doesn't recognize the type or if the dimension isn't set * * @return The dimensions' type, EX: XDMF_ARRAY_TYPE_INT8 */ int retrieveDimensionsValueType(); /** * Returns a pointer to the array of values contained in the dimensions * * Returns an error if the dimensions are not set * * @param values A void pointer to the array to recieve the * geometry's values * @param dataType An integer corresponding to the datatype that * The data will be stored in * @param numberRead The number of values read into the values array * @param startIndex The place to start reading from the attribute's array * @param arrayStride The distance between values read * (1 reads all values, 2 reads every other, ect..) * @param valueStride The distance between the places that * the read values are placed in the supplied array */ void retrieveDimensionsValues(void * values, const int dataType, const int numberRead, const int startIndex, const int arrayStride, const int valueStride); /** * returns the size of the dimensions * * @return The size */ int retrieveDimensionsSize(); /** * Returns the number of properties currently stored in the dimensions. * * @return The number of properties associated with the dimensions */ int retrieveDimensionsNumProperties(); /** * Retrieves the key and value of the property at the specifed index of the dimensions * and modifies the values at the provided pointers * * Returns an error if the index is out of bounds * * @param index The index of the property that is being retrieved * @param key A pointer to the location where the * key value will be stored * @param keyLength The size of the key variable * @param value A pointer to the location where the value of * the property will be stored * @param valueLength The size of the value variable */ void retrieveDimensionsProperty(const int index, char * key, const int keyLength, char * value, const int valueLength); /** * Retrieves the value of a property of the dimensions when given its key. * * Returns an error if the key has no matching value * * @param key A pointer to the value of the key that is * being searched for * @param value A pointer to the location where the value of * the property will be stored * @param valueLength The size of the value variable */ void retrieveDimensionsPropertyByKey(char * key, char * value, const int valueLength); /** * Set the origin that will be added to the next grid. * * @param numValues Number of point values to copy. * @param arrayType Type of point values. * @param pointValues Array of point values. * * @return int providing id to fortran if reusing. */ int setOrigin(const int numValues, const int arrayType, void * pointValues); /** * Remove heavy data linkage from the origin. */ void clearOriginHeavyData(); /** * Set HDF5 linkage for the origin. * * @param hdf5File Filename for the hdf5 linkage * @param hdf5Dataset Dataset name for the hdf5 linkage * @param start Starting index in the hdf5 dataset * @param stride Distance between values in the hdf5 dataset * @param numValues Number of values in the hdf5 dataset * @param dataspace Total size of the hdf5 dataset. */ void setOriginHDF5(const char * hdf5File, const char * hdf5Dataset, const unsigned int start, const unsigned int stride, const unsigned int numValues, const unsigned int dataspace); /** * Set Binary linkage for the origin. * * @param binFile Filename for the binary linkage * @param endian Endianness of the dataset * @param seek Offset of the dataset in the binary file * @param start Starting index in the binary dataset * @param stride Distance between values in the binary dataset * @param numValues Number of values in the binary dataset * @param dataspace Total size of the binary dataset. */ void setOriginBinary(const char * binFile, const int endian, const unsigned int seek, const unsigned int start, const unsigned int stride, const unsigned int numValues, const unsigned int dataspace); /** * Sets mOrigin to a specified origin in mPreviousOrigins * * @param index The index of the specified origin */ void setPreviousOrigin(const int index); /** * Clears mPreviousOrigins. Use to reduce memory load. */ void clearPreviousOrigins(); /** * Overwrites a section of the origin using the provided values. * * Returns an error if the origin is not set * * @param values A pointer to the values to be written. * @param numValues The number of values to be pulled from * the pointer. * @param arrayType The data type of the values to be inserted. * @param startIndex The point in the array for editing to start. * @param arrayStride The increment between value placements on the origin. * @param valueStride The increment between value pulls from the * pointer written from. */ void modifyOriginValues(void * values, const int arrayType, const int numValues, const int startIndex, const int arrayStride, const int valueStride); /** * Retrieves the origin's tag and stores it into the provided pointer * * @param tag The location where the tag will be stored * @param tagLength The size fo the array at the provided pointer */ void retrieveOriginTag(char * tag, const int tagLength); /** * Returns the origin's datatype as an integer. * * Returns an error if it doesn't recognize the type or if the origin isn't set * * @return The origin's type, EX: XDMF_ARRAY_TYPE_INT8 */ int retrieveOriginValueType(); /** * Returns a pointer to the array of values contained in the origin * * Returns an error if the origin is not set * * @param values A void pointer to the array to recieve the * geometry's values * @param dataType An integer corresponding to the datatype that * the data will be stored in * @param numberRead The number of values read into the values array * @param startIndex The place to start reading from the attribute's array * @param arrayStride The distance between values read * (1 reads all values, 2 reads every other, ect..) * @param valueStride The distance between the places that the * read values are placed in the supplied array */ void retrieveOriginValues(void * values, const int dataType, const int numberRead, const int startIndex, const int arrayStride, const int valueStride); /** * returns the size of the origin * * @return The size */ int retrieveOriginSize(); /** * Returns the number of properties currently stored in the origin. * * @return The number of properties associated with the origin */ int retrieveOriginNumProperties(); /** * Retrieves the key and value of the property at the specifed index of the origin * and modifies the values at the provided pointers * * Returns an error if the index is out of bounds * * @param index The index of the property that is being retrieved * @param key A pointer to the location where the * key value will be stored * @param keyLength The size of the key variable * @param value A pointer to the location where the * value of the property will be stored * @param valueLength The size of the value variable */ void retrieveOriginProperty(const int index, char * key, const int keyLength, char * value, const int valueLength); /** * Retrieves the value of a property of the origin when given its key. * * Returns an error if the key has no matching value * * @param key A pointer to the value of the key that is * being searched for * @param value A pointer to the location where the * value of the property will be stored * @param valueLength The size of the value variable */ void retrieveOriginPropertyByKey(char * key, char * value, const int valueLength); /** * Set the brick size that will be added to the next grid. * * @param numValues Number of point values to copy. * @param arrayType Type of point values. * @param pointValues Array of point values. * * @return int providing id to fortran if reusing. */ int setBrick(const int numValues, const int arrayType, void * pointValues); /** * Remove heavy data linkage from the Brick size. */ void clearBrickHeavyData(); /** * Set HDF5 linkage for the brick size. * * @param hdf5File Filename for the hdf5 linkage * @param hdf5Dataset Dataset name for the hdf5 linkage * @param start Starting index in the hdf5 dataset * @param stride Distance between values in the hdf5 dataset * @param numValues Number of values in the hdf5 dataset * @param dataspace Total size of the hdf5 dataset. */ void setBrickHDF5(const char * hdf5File, const char * hdf5Dataset, const unsigned int start, const unsigned int stride, const unsigned int numValues, const unsigned int dataspace); /** * Set Binary linkage for the brick size. * * @param binFile Filename for the binary linkage * @param endian Endianness of the dataset * @param seek Offset of the dataset in the binary file * @param start Starting index in the binary dataset * @param stride Distance between values in the binary dataset * @param numValues Number of values in the binary dataset * @param dataspace Total size of the binary dataset. */ void setBrickBinary(const char * binFile, const int endian, const unsigned int seek, const unsigned int start, const unsigned int stride, const unsigned int numValues, const unsigned int dataspace); /** * Sets the brick size to a specified brick size stored in mPreviousBricks * * @param index The index of the specifed brick size */ void setPreviousBrick(const int index); /** * Clears mPreviousBricks. Use to reduce memory load. */ void clearPreviousBricks(); /** * Overwrites a section of the brick using the provided values. * * Returns an error if the brick is not set * * @param values A pointer to the values to be written. * @param numValues The number of values to be pulled from the pointer. * @param arrayType The data type of the values to be inserted. * @param startIndex The point in the array for editing to start. * @param arrayStride The increment between value placements on the brick. * @param valueStride The increment between value pulls from the * pointer written from. */ void modifyBrickValues(void * values, const int arrayType, const int numValues, const int startIndex, const int arrayStride, const int valueStride); /** * Retrieves the Geometry's tag and stores it into the provided pointer * * @param tag The location where the tag will be stored * @param tagLength The size fo the array at the provided pointer */ void retrieveBrickTag(char * tag, const int tagLength); /** * Returns the brick's datatype as an integer. * * Returns an error if it doesn't recognize the type or if the brick isn't set * * @return The brick's type, EX: XDMF_ARRAY_TYPE_INT8 */ int retrieveBrickValueType(); /** * Returns a pointer to the array of values contained in the brick * * Returns an error if the brick is not set * * @param values A void pointer to the array to recieve * the brick's values * @param dataType An integer corresponding to the datatype that * the data will be stored in * @param numberRead The number of values read into the values array * @param startIndex The place to start reading from the attribute's array * @param arrayStride The distance between values read * (1 reads all values, 2 reads every other, ect..) * @param valueStride The distance between the places that the read values * are placed in the supplied array */ void retrieveBrickValues(void * values, const int dataType, const int numberRead, const int startIndex, const int arrayStride, const int valueStride); /** * returns the size of the brick size * * @return The size */ int retrieveBrickSize(); /** * Returns the number of properties currently stored in the brick size. * * @return The number of properties associated with the brick */ int retrieveBrickNumProperties(); /** * Retrieves the key and value of the property at the specifed index of the brick size * and modifies the values at the provided pointers * * Returns an error if the index is out of bounds * * @param index The index of the property that is being retrieved * @param key A pointer to the location where the key value will be stored * @param keyLength The size of the key variable * @param value A pointer to the location where the value of the property * will be stored * @param valueLength The size of the value variable */ void retrieveBrickProperty(const int index, char * key, const int keyLength, char * value, const int valueLength); /** * Retrieves the value of a property of the brick size when given its key. * * Returns an error if the key has no matching value * * @param key A pointer to the value of the key that is * being searched for * @param value A pointer to the location where the value of * the property will be stored * @param valueLength The size of the value variable */ void retrieveBrickPropertyByKey(char * key, char * value, const int valueLength); /** * Pushes a blank map onto mMaps. * * @param name A pointer to the name of the map to be added */ void addMap(char * name); /** * Returns the number of maps stored in mMaps * * @return The number of maps */ int retrieveNumMaps(); /** * Retrieves the specified map's tag and stores it into the provided pointer * * Returns an error if the index is out of bounds * * @param index The index of the map whose tag is being retrieved * @param tag The location where the tag will be stored * @param tagLength The size fo the array at the provided pointer */ void retrieveMapTag(const int index, char * tag, const int tagLength); /** * Adds id dependancies to the specified map in mMaps * * @param index The index of the map for the data to * be added to * @param localNodeID The ID of the local node * @param remoteTaskID The task ID to be associated with * the local node * @param remoteLocalNodeID The remote local node to be associated * with the local node and task id */ void addRemoteNodeID(const int index, int localNodeID, int remoteTaskID, int remoteLocalNodeID); /** * Gets the remote local ids associated with the provided local node and * task from a specified map in mMaps * * @param index The index of the map which the data is to be * retrieved from * @param localNodeID The ID of the local node whose remote local * node is to be found * @param remoteTaskID The ID of the task whose remote local node * is to be found * @param remoteNodeID A pointer to the location where the remote local IDs * will be returned to */ void retrieveRemoteNodeIDs(const int index, const int localNodeID, const int remoteTaskID, int * remoteNodeIDs); /** * Gets the number of remote local ids associated with the provided local node * and task from a specified map in mMaps * * @param index The index of the map which the data is to be * retrieved from * @param localNodeID The ID of the local node whose number of * associated remote local nodes is to be found * @param remoteTaskID The ID of the task whose number of associated * remote local nodes is to be found * * @return The number of remote node ids associated with * the supplied IDs */ int retrieveNumRemoteNodeIDs(const int index, const int localNodeID, const int remoteTaskID); /** * Clears mMaps of all added maps. */ void clearMaps(); /** * Removes the specified map from mMaps. * * @param index The index of the map to be removed. */ void removeMap(const int index); /** * Stores specified mMap in mPreviousMaps. * * Gives an error if the index is out of bounds * * @param index The index of the specified map in mMaps * * @return The id of the corresponding map in mPreviousMaps */ int storeMap(const int index); /** * Replaces the current mMap with one specified from mPreviousMaps. * * Gives an error if the index is out of range. * * @param index The index of the specified map */ void addPreviousMap(const int index); /** * Clears mPreviousMaps. Use to reduce memory load. */ void clearPreviousMaps(); /** * Returns the number of properties currently stored in the specified map in mMaps. * * @param index The index of the specified map * * @return The number of properties associated with the map */ int retrieveMapNumProperties(const int index); /** * Retrieves the key and value of the property at the specifed index of the * specified map in mMaps and modifies the values at the provided pointers * * Returns an error if the index is out of bounds * * @param mapIndex The index of the specified map * @param index The index of the property that is being retrieved * @param key A pointer to the location where the key value * will be stored * @param keyLength The size of the key variable * @param value A pointer to the location where the value of * the property will be stored * @param valueLength The size of the value variable */ void retrieveMapProperty(const int mapIndex, const int index, char * key, const int keyLength, char * value, const int valueLength); /** * Retrieves the value of a property of the specified map when given its key. * * Returns an error if the key has no matching value * * @param index The index of the specified map * @param key A pointer to the value of the key that is * being searched for * @param value A pointer to the location where the value of * the property will be stored * @param valueLength The size of the value variable */ void retrieveMapPropertyByKey(const int index, char * key, char * value, const int valueLength); /** * Returns the number of attributes currently loaded. * * @return The number of attributes in mAttributes */ int retrieveNumAttributes(); /** * Removes the attribute at the supplied index from mAttributes * * Returns an error if the index is out of bounds * * @param index The index of the Attribute to be removed */ void removeAttribute(const int index); /** * Replaces the specified attribute in mAttributes with one made using the * supplied components * * Returns an error if the index is out of bounds * * @param index The index of the Attribute to be replaced * @param name A pointer to the name of the new attribute * @param attributeCenter An integer representation of the center of * the new attribute Ex:XDMF_ATTRIBUTE_CENTER_NODE * @param attributeType An integer representation of the type of * the new attribute Ex:XDMF_ATTRIBUTE_TYPE_SCALAR * @param numValues The number of values contained at the array * located at the supplied void pointer * @param arrayType An integer representation of the type of * data contained within the array * Ex:XDMF_ARRAY_TYPE_INT32 * @param values A pointer to the location of the values * that will be used to fill the new attribute */ void replaceAttribute(const int index, char * name, const int attributeCenter, const int attributeType, const int numValues, const int arrayType, void * values); /** * Opens the specified attribute by placing the information it contains in mInformations * * @param index The index of the specified information */ void openAttribute(const int index); /** * Retrieves the specified Attribute's tag and stores it into the provided pointer * * Returns an error if the index is out of bounds * * @param index The index of the attribute whose tag is being retrieved * @param tag The location where the tag will be stored * @param tagLength The size fo the array at the provided pointer */ void retrieveAttributeTag(const int index, char * tag, const int tagLength); /** * Retrieves the specified Attribute's name and stores it into the provided pointer * * Returns an error if the index is out of bounds * * @param index The index of the attribute whose name is being retrieved * @param name The location where the name will be stored * @param nameLength The size fo the array at the provided pointer */ void retrieveAttributeName(const int index, char * name, const int nameLength); /** * Clears mAttributes of all added attributes */ void clearAttributes(); /** * Returns a pointer the values of a specified attribute * * Returns an error if the index is out of bounds * * @param index The index that the specified Attribute exists at * @param values A void pointer to the array to recieve the * attribute's values * @param dataType An integer corresponding to the datatype that * the data will be stored in * @param numberRead The number of values read into the values array * @param startIndex The place to start reading from the attribute's array * @param arrayStride The distance between values read * (1 reads all values, 2 reads every other, ect..) * @param valueStride The distance between the places that the * read values are placed in the supplied array */ void retrieveAttributeValues(const int index, void * values, const int dataType, const int numberRead, const int startIndex, const int arrayStride, const int valueStride); /** * Returns the datatype of the specified attribute as an integer. * * Returns an error if the index is out of bounds * * @param index The index to the attribute * * @return The type of the specified attribute as an integer, * EX: XDMF_ARRAY_TYPE_INT8 */ int retrieveAttributeValueType(const int index); /** * Returns the number of values in the specified Attribute * * Returns an error if the index is out of bounds * * @param index The index to the attribute * * @return The number of values contained in the specified attribute */ int retrieveAttributeSize(const int index); /** * Returns the type of the specified attribute as an integer. * * Returns an error if the index is out of bounds * * @param index The index to the attribute * * @return The type of the specified attribute as an integer, * EX: XDMF_ATTRIBUTE_TYPE_SCALAR */ int retrieveAttributeType(const int index); /** * Returns the center of the specified attribute as an integer. * * Returns an error if the index is out of bounds * * @param index The index to the attribute * * @return The center of the specified attribute as an integer, * EX: XDMF_ATTRIBUTE_CENTER_NODE */ int retrieveAttributeCenter(const int index); /** * Clears mPreviousAttributes. Use to reduce memory load. */ void clearPreviousAttributes(); /** * Overwrites a section of the specified attribute using the provided values. * * Returns an error if the index is out of range * * @param index The index of the attribute to be modified * @param values A pointer to the values to be written. * @param numValues The number of values to be pulled from the pointer. * @param arrayType The data type of the values to be inserted. * @param startIndex The point in the array for editing to start. * @param arrayStride The increment between value placements on the attribute. * @param valueStride The increment between value pulls from the pointer written from. */ void modifyAttributeValues(const int index, void * values, const int arrayType, const int numValues, const int startIndex, const int arrayStride, const int valueStride); /** * Returns the number of properties currently stored in the specified attribute. * * Returns an error if the index is out of bounds * * @param index The index of the attribute whose number of properties is being retrieved * * @return The number of properties associated with the specified attribute */ int retrieveAttributeNumProperties(const int index); /** * Retrieves the key and value of the property at the specifed index * of the specified attribute and modifies the values at the provided pointers * * Returns an error if the index is out of bounds * * @param attributeIndex The index of the attribute that is being retrieved * @param index The index of the property that is being retrieved * @param key A pointer to the location where the key value * will be stored * @param keyLength The size of the key variable * @param value A pointer to the location where the value * of the property will be stored * @param valueLength The size of the value variable */ void retrieveAttributeProperty(const int attributeIndex, const int index, char * key, const int keyLength, char * value, const int valueLength); /** * Retrieves the value of a property of a specified attribute when given its key. * * Returns an error if the index is out of bounds * Returns an error if the key has no matching value * * @param index The index of the attribute whose property * is being retrieved * @param key A pointer to the value of the key that is * being searched for * @param value A pointer to the location where the value * of the property will be stored * @param valueLength The size of the value variable */ void retrieveAttributePropertyByKey(const int index, char * key, char * value, const int valueLength); /** * Sets the specified attribute as an array variable associated with a specific name. * Used in conjuction with Functions. * * @param varname The variable to accociate with the attribute. * @param index The index of the attribute to be associated. */ void setAttributeAsVariable(char * varname, int index); /** * Sets the specified attribute as the current subset reference. * * @param index The index of the attribute to be used. */ void setAttributeAsSubsetReference(int index); /** * Returns the number of coordinates currently loaded. * * @return The number of coordinates in mCoordinates */ int retrieveNumCoordinates(); /** * Removes the coordinate at the supplied index from mCoordinates * * Returns an error if the index is out of bounds * * @param index The index of the Coordinate to be removed */ void removeCoordinate(const int index); /** * Add an coordinate that will be inserted into the next grid or grid * collection. * * @param name Name of the coordinate. * @param numValues Number of coordinate values to copy. * @param arrayType Type of coordinate values. * @param values Array of coordinate values. * * @return int providing id to fortran if reusing. */ int addCoordinate(char * name, const int numValues, const int arrayType, void * values); /** * Adds a specified coordinate from mPreviousCoordinates to mCoordinates * * @param index The index of the specified coordinate */ void addPreviousCoordinate(const int index); /** * Clears mPreviousCoordinates. Use to reduce memory load. */ void clearPreviousCoordinates(); /** * Remove heavy data linkage from the specified coordinate. * * @param index Index of the Coordinate which will have its heavydata linkage removed. */ void clearCoordinateHeavyData(const int index); /** * Set HDF5 linkage for the specified coordinate. * * @param index Index of the Coordinate which will have its hdf5 linkage set. * @param hdf5File Filename for the hdf5 linkage * @param hdf5Dataset Dataset name for the hdf5 linkage * @param start Starting index in the hdf5 dataset * @param stride Distance between values in the hdf5 dataset * @param numValues Number of values in the hdf5 dataset * @param dataspace Total size of the hdf5 dataset. */ void setCoordinateHDF5(const int index, const char * hdf5File, const char * hdf5Dataset, const unsigned int start, const unsigned int stride, const unsigned int numValues, const unsigned int dataspace); /** * Set Binary linkage for the specified coordinate. * * @param index Index of the Coordinate which will have its binary linkage set. * @param binFile Filename for the binary linkage * @param endian Endianness of the dataset * @param seek Offset of the dataset in the binary file * @param start Starting index in the binary dataset * @param stride Distance between values in the binary dataset * @param numValues Number of values in the binary dataset * @param dataspace Total size of the binary dataset. */ void setCoordinateBinary(const int index, const char * binFile, const int endian, const unsigned int seek, const unsigned int start, const unsigned int stride, const unsigned int numValues, const unsigned int dataspace); /** * Replaces the specified coordinate in mCoordinates with one made using * the supplied components * * Returns an error if the index is out of bounds * * @param index The index of the coordinate to be replaced * @param name A pointer to the name of the new coordinate * @param numValues The number of values contained at the array * located at the supplied void pointer * @param arrayType An integer representation of the type of data * contained within the array Ex:XDMF_ARRAY_TYPE_INT32 * @param values A pointer to the location of the values that * will be used to fill the new coordinate */ void replaceCoordinate(const int index, char * name, const int numValues, const int arrayType, void * values); /** * Retrieves the specified Coordinate's tag and stores it into the provided pointer * * Returns an error if the index is out of bounds * * @param index The index of the coordinate whose tag is being retrieved * @param tag The location where the tag will be stored * @param tagLength The size fo the array at the provided pointer */ void retrieveCoordinateTag(const int index, char * tag, const int tagLength); /** * Retrieves the specified Coordinate's name and stores it into the provided pointer * * Returns an error if the index is out of bounds * * @param index The index of the coordinate whose name is being retrieved * @param name The location where the name will be stored * @param nameLength The size fo the array at the provided pointer */ void retrieveCoordinateName(const int index, char * name, const int nameLength); /** * Returns a pointer the values of a specified coordinate * * Returns an error if the index is out of bounds * * @param index The index that the specified coordinate exists at * @param values A void pointer to the array to recieve the * coordinate's values * @param dataType An integer corresponding to the datatype that * the data will be stored in * @param numberRead The number of values read into the values array * @param startIndex The place to start reading from the coordinate's array * @param arrayStride The distance between values read * (1 reads all values, 2 reads every other, ect..) * @param valueStride The distance between the places that the * read values are placed in the supplied array */ void retrieveCoordinateValues(const int index, void * values, const int dataType, const int numberRead, const int startIndex, const int arrayStride, const int valueStride); /** * Returns the datatype of the specified coordinate as an integer. * * Returns an error if the index is out of bounds * * @param index The index to the coordinate * * @return The type of the specified coordinate as an integer, * EX: XDMF_ARRAY_TYPE_INT8 */ int retrieveCoordinateValueType(const int index); /** * Returns the number of values in the specified coordinate * * Returns an error if the index is out of bounds * * @param index The index to the coordinate * * @return The number of values contained in the specified coordinate */ int retrieveCoordinateSize(const int index); /** * Clears mCoordinates of all added coordiantes. */ void clearCoordinates(); /** * Overwrites a section of the specified coordinate using the provided values. * * Returns an error if the index is out of range * * @param index The index of the coordinate to be modified * @param values A pointer to the values to be written. * @param numValues The number of values to be pulled from the pointer. * @param arrayType The data type of the values to be inserted. * @param startIndex The point in the array for editing to start. * @param arrayStride The increment between value placements on the coordinate. * @param valueStride The increment between value pulls from the * pointer written from. */ void modifyCoordinateValues(const int index, void * values, const int arrayType, const int numValues, const int startIndex, const int arrayStride, const int valueStride); /** * Returns the number of properties currently stored in the specified coordinate. * * Returns an error if the index is out of bounds * * @param index The index of the coordinate whose number of properties * is being retrieved * * @return The number of properties associated with the specified * coordinate */ int retrieveCoordinateNumProperties(const int index); /** * Retrieves the key and value of the property at the specifed index of * the specified coordinate and modifies the values at the provided pointers * * Returns an error if the index is out of bounds * * @param coordinateIndex The index of the coordinate that is * being retrieved * @param index The index of the property that is * being retrieved * @param key A pointer to the location where the * key value will be stored * @param keyLength The size of the key variable * @param value A pointer to the location where the * value of the property will be stored * @param valueLength The size of the value variable */ void retrieveCoordinateProperty(const int coordinateIndex, const int index, char * key, const int keyLength, char * value, const int valueLength); /** * Retrieves the value of a property of a specified coordinate when given its key. * * Returns an error if the index is out of bounds * Returns an error if the key has no matching value * * @param index The index of the coordinate whose property is * being retrieved * @param key A pointer to the value of the key that is * being searched for * @param value A pointer to the location where the value of * the property will be stored * @param valueLength The size of the value variable */ void retrieveCoordinatePropertyByKey(const int index, char * key, char * value, const int valueLength); /** * Sets the specified coordinate as an array variable associated with a specific name. * Used in conjuction with Functions. * * @param varname The variable to accociate with the coordinate. * @param index The index of the coordinate to be associated. */ void setCoordinateAsVariable(char * varname, int index); /** * Sets the specified coordinate as the current subset reference. * * @param index The index of the coordinate to be associated. */ void setCoordinateAsSubsetReference(int index); /** * Retrieves the specified set's tag and stores it into the provided pointer * * Returns an error if the index is out of bounds * * @param index The index of the set whose tag is being retrieved * @param tag The location where the tag will be stored * @param tagLength The size fo the array at the provided pointer */ void retrieveSetTag(const int index, char * tag, const int tagLength); /** * Retrieves the specified set's name and stores it into the provided pointer * * Returns an error if the index is out of bounds * * @param index The index of the set whose name is being retrieved * @param name The location where the name will be stored * @param nameLength The size fo the array at the provided pointer */ void retrieveSetName(const int index, char * name, const int nameLength); /** * Retrievest the type of the specified set * * Returns an error if the index is out of bounds * * @param index The index of the specified set * * @return The set's type as an integer Ex. XDMF_SET_TYPE_NODE */ int retrieveSetType(const int index); /** * Adds a set to mSets that contains the current contents to mInformations * and mAttributes. * Then the top of parentAttributes and parentInformations * are placed in mAttributes and mInformations * * @param name A pointer to the location of the name for the set * @param newSetType The integer equivalent to the set type of the * added set Ex: XDMF_SET_TYPE_NODE * @param values A pointer to the location where the values to be * placed in the set will are stored * @param numValues The amount of values in the array at the provided pointer * @param arrayType The integer representation of the datatype of the values * Ex: XDMF_ARRAY_TYPE_INT32 * * @return An ID that can be used to recall the set from mPreviousSets */ int addSet(char * name, const int newSetType, void * values, const int numValues, const int arrayType); /** * Remove heavy data linkage from the specified set. */ void clearSetHeavyData(const int index); /** * Set HDF5 linkage for the specified set. * * @param index Index of the Set which will have its hdf5 linkage set. * @param hdf5File Filename for the hdf5 linkage * @param hdf5Dataset Dataset name for the hdf5 linkage * @param start Starting index in the hdf5 dataset * @param stride Distance between values in the hdf5 dataset * @param numValues Number of values in the hdf5 dataset * @param dataspace Total size of the hdf5 dataset. */ void setSetHDF5(const int index, const char * hdf5File, const char * hdf5Dataset, const unsigned int start, const unsigned int stride, const unsigned int numValues, const unsigned int dataspace); /** * Set Binary linkage for the specified set. * * @param index Index of the Set which will have its binary linkage set. * @param binFile Filename for the binary linkage * @param endian Endianness of the dataset * @param seek Offset of the dataset in the binary file * @param start Starting index in the binary dataset * @param stride Distance between values in the binary dataset * @param numValues Number of values in the binary dataset * @param dataspace Total size of the binary dataset. */ void setSetBinary(const int index, const char * binFile, const int endian, const unsigned int seek, const unsigned int start, const unsigned int stride, const unsigned int numValues, const unsigned int dataspace); /** * Adds the specifed set from mPreviousSets into mSets. * * @param index The index of the set in mPreviousSets to be added */ void addPreviousSet(const int index); /** * Clears mPreviousSets. Use to reduce memory load. */ void clearPreviousSets(); /** * Clears mSets of all added Sets */ void clearSets(); /** * Overwrites a section of the specified set using the provided values. * * Returns an error if the index is out of range * * @param index The index of the set to be modified * @param values A pointer to the values to be written. * @param numValues The number of values to be pulled from the pointer. * @param arrayType The data type of the values to be inserted. * @param startIndex The point in the array for editing to start. * @param arrayStride The increment between value placements on the set. * @param valueStride The increment between value pulls from the * pointer written from. */ void modifySetValues(const int index, void * values, const int arrayType, const int numValues, const int startIndex, const int arrayStride, const int valueStride); /** * Returns the number of sets in mSets * * @return The number of sets */ int retrieveNumSets(); /** * Returns the number of values in the specified set * * Returns an error if the index is out of bounds * * @param index The index to the set * * @return The number of values contained in the specified set */ int retrieveSetSize(const int index); /** * Returns a pointer the values of a specified set * * Returns an error if the index is out of bounds * * @param index The index that the specified set exists at * @param values A void pointer to the array to recieve the * set's values * @param dataType An integer corresponding to the datatype that * the data will be stored in * @param numberRead The number of values read into the values array * @param startIndex The place to start reading from the set's array * @param arrayStride The distance between values read * (1 reads all values, 2 reads every other, ect..) * @param valueStride The distance between the places that the * read values are placed in the supplied array */ void retrieveSetValues(const int index, void * values, const int dataType, const int numberRead, const int startIndex, const int arrayStride, const int valueStride); /** * Returns the datatype of the specified set as an integer. * * Returns an error if the index is out of bounds * * @param index the index of the Set * * @return The type of the specified Set's values as an integer, * EX: XDMF_ARRAY_TYPE_INT8 */ int retrieveSetValueType(const int index); /** * Opens the set at the specified index by placing its attributes and * information in mAttributes and mInformations. Pushes the previous * contents of those two containers into parentAttributes and parentInformations. * * Returns an error if the index is out of bounds * * @param index The index of the specified set * @param openAttributes Set to 1 to open attributes * @param openInformation Set to 1 to open information */ void openSet(const int index, const int openAttributes, const int openInformation); /** * Removes the specified set from mSets. * * Returns an error if the index is out of bounds * * @param index The index of the set to be removed */ void removeSet(const int index); /** * Replaces a specified set in mSets with a set that contains * the current contents to mInformations and mAttributes. * Then the top of parentAttributes and parentInformations * are placed in mAttributes and mInformations * * Returns an error if the index is out of bounds * * @param index The index of the set to be replaced * @param name A pointer to the location of the name for the set * @param newSetType The integer equivalent to the set type of the * added set Ex: XDMF_SET_TYPE_NODE * @param values A pointer to the location where the values to be * placed in the set will are stored * @param numValues The amount of values in the array at the provided pointer * @param arrayType The integer representation of the datatype * of the values Ex: XDMF_ARRAY_TYPE_INT32 */ void replaceSet(const int index, char * name, const int newSetType, void * values, const int numValues, const int arrayType); /** * Returns the number of properties currently stored in the specified set. * * Returns an error if the index is out of bounds * * @param index The index of the set whose number of properties is being retrieved * * @return The number of properties associated with the specified set */ int retrieveSetNumProperties(const int index); /** * Retrieves the key and value of the property at the specifed index of * the specified set and modifies the values at the provided pointers * * Returns an error if the index is out of bounds * * @param setIndex The index of the set that is being retrieved * @param index The index of the property that is being retrieved * @param key A pointer to the location where the key value * will be stored * @param keyLength The size of the key variable * @param value A pointer to the location where the value of * the property will be stored * @param valueLength The size of the value variable */ void retrieveSetProperty(const int setIndex, const int index, char * key, const int keyLength, char * value, const int valueLength); /** * Retrieves the value of a property of a specified set when given its key. * * Returns an error if the index is out of bounds * Returns an error if the key has no matching value * * @param index The index of the set whose property is being * retrieved * @param key A pointer to the value of the key that is being * searched for * @param value A pointer to the location where the value of * the property will be stored * @param valueLength The size of the value variable */ void retrieveSetPropertyByKey(const int index, char * key, char * value, const int valueLength); /** * Sets the specified set as an array variable associated with a specific name. * Used in conjuction with Functions. * * @param varname The variable to accociate with the set. * @param index The index of the set. */ void setSetAsVariable(char * varname, int index); /** * Sets the specified set as the current subset reference. * * @param index The index of the set. */ void setSetAsSubsetReference(int index); /** * Returns the number of information currently stored in mInformations. * * @return the number of information contained within mInformations */ int retrieveNumInformation(); /** * Retrieves the specified information's tag and stores it into the provided pointer * * Returns an error if the index is out of bounds * * @param index The index of the information whose tag is being retrieved * @param tag The location where the tag will be stored * @param tagLength The size fo the array at the provided pointer */ void retrieveInformationTag(const int index, char * tag, const int tagLength); /** * Retrieves the key and value of the Information at the specifed index * and modifies the values at the provided pointers * * Returns an error if the index is out of bounds * * @param index The index of the property that is being * retrieved * @param key A pointer to the location where the * key value will be stored * @param keyLength The size of the key variable * @param value A pointer to the location where the * value of the information will be stored * @param valueLength The size of the value variable */ void retrieveInformation(const int index, char * key, const int keyLength, char * value, const int valueLength); /** * Removes the information at the specified index. * * Returns an error if the index is out of bounds * * @param index The index of the information to be removed */ void removeInformation(const int index); /** * Replaces the key and value of the information at the specified index * * Returns an error if the index is out of bounds * * @param index The index of the information to be changed * @param key A pointer to the new key * @param value A pointer to the new value */ void replaceInformation(const int index, char * key, char * value); /** * Opens the specified information by placing the information it contains * in mInformations * * @param index The index of the information to be opened */ void openInformation(const int index); /** * Retrieves the value of a specified information when given its key. * * Returns an error if the key has no matching value * * @param key A pointer to the value of the key that is * being searched for * @param value A pointer to the location where the value * of the information will be stored * @param valueLength The size of the value variable */ void retrieveInformationByKey(char * key, char * value, const int valueLength); /** * Removes the information with the specified key * * Returns an error if the key does not match an information * * @param key A pointer to the value of the key being searched for */ void removeInformationByKey(char * key); /** * Replaces the value of the information with the specified key * * Returns an error if the key does not match a value * * @param key A pointer to the value of the key being searched for * @param value A pointer to the value that will be placed into the information */ void replaceInformationByKey(char * key, char * value); /** * Clears mPreviousInformations. Use to reduce memory load. */ void clearPreviousInformation(); /** * Clears mInformations of all added information. */ void clearInformations(); /** * Returns the number of properties currently stored in the specified information. * * Returns an error if the index is out of bounds * * @param index The index of the information whose number of properties * is being retrieved * * @return The number of properties associated with the specified * information */ int retrieveInformationNumProperties(const int index); /** * Retrieves the key and value of the property at the specifed index of the * specified information and modifies the values at the provided pointers * * Returns an error if the index is out of bounds * * @param informationIndex The index of the information that is * being retrieved * @param index The index of the property that is being * retrieved * @param key A pointer to the location where the * key value will be stored * @param keyLength The size of the key variable * @param value A pointer to the location where the * value of the property will be stored * @param valueLength The size of the value variable */ void retrieveInformationProperty(const int informationIndex, const int index, char * key, const int keyLength, char * value, const int valueLength); /** * Retrieves the value of a property of a specified information when given its key. * * Returns an error if the index is out of bounds * Returns an error if the key has no matching value * * @param index The index of the information whose property is * being retrieved * @param key A pointer to the value of the key that is being * searched for * @param value A pointer to the location where the value of the * property will be stored * @param valueLength The size of the value variable */ void retrieveInformationPropertyByKey(const int index, char * key, char * value, const int valueLength); /** * Adds an array containing the provided values into the specified information. * * Returns an error if the index is out of bounds * * @param index The index of the information that the array * will be added into. * @param values A pointer to the values to be contained in * the added array. * @param numValues The number of values to be pulled from the pointer. * @param arrayType The data type that the array will consist of. */ void addInformationArray(const int index, char * name, void * values, const int numValues, const int arrayType); /** * Remove heavy data linkage from the specified Information Array. * * @param index Index of the Information holding the array which * will have its heavydata linkage removed. * @param arrayIndex Index of the array in the specified information */ void clearInformationArrayHeavyData(const int index, const int arrayIndex); /** * Set HDF5 linkage for the specified Information Array. * * @param index Index of the Information holding the array which will have its hdf5 linkage set. * @param arrayIndex Index of the array in the specified information * @param hdf5File Filename for the hdf5 linkage * @param hdf5Dataset Dataset name for the hdf5 linkage * @param start Starting index in the hdf5 dataset * @param stride Distance between values in the hdf5 dataset * @param numValues Number of values in the hdf5 dataset * @param dataspace Total size of the hdf5 dataset. */ void setInformationArrayHDF5(const int index, const int arrayIndex, const char * hdf5File, const char * hdf5Dataset, const unsigned int start, const unsigned int stride, const unsigned int numValues, const unsigned int dataspace); /** * Set Binary linkage for the specified Information Array. * * @param index Index of the Information holding the array which will have its binary linkage set. * @param arrayIndex Index of the array in the specified information * @param binFile Filename for the binary linkage * @param endian Endianness of the dataset * @param seek Offset of the dataset in the binary file * @param start Starting index in the binary dataset * @param stride Distance between values in the binary dataset * @param numValues Number of values in the binary dataset * @param dataspace Total size of the binary dataset. */ void setInformationArrayBinary(const int index, const int arrayIndex, const char * binFile, const int endian, const unsigned int seek, const unsigned int start, const unsigned int stride, const unsigned int numValues, const unsigned int dataspace); /** * Makes an information a child of another information. * Has an option to remove the Information from mInformation. * * Returns an error if either index is out of range * Returns an error if the index are the same * * @param toIndex The index of the parent information. * @param fromIndex The index of the child information. * @param removeFromArray Whether to remove the information at * fromIndex from mInformation */ void insertInformationIntoInformation(const int toIndex, const int fromIndex, const bool removeFromArray); /** * Overwrites a section of the specified array using the provided values. * * Returns an error if the index is out of bounds * Returns an error if the array index is out of bounds * * @param index The index of the information that controls * the array to be modified. * @param arrayIndex The index of the array in the information. * @param values A pointer to the values to be written. * @param arrayType The data type of the values to be inserted. * @param numValues The number of values to be pulled from the pointer. * @param insertStart The point in the array for editing to start. * @param arrayStride The increment between value placements on the * array being written to. * @param valueStride The increment between value pulls from the * pointer written from. */ void modifyInformationArray(const int index, const int arrayIndex, void * values, const int arrayType, const int numValues, const int insertStart, const int arrayStride, const int valueStride); /** * Removes an array from an information. * * Returns an error if the index is out of bounds * Returns an error if the array index is out of bounds * * @param index The index of the information that controls the * array to be removed. * @param arrayIndex The index of the array in the information. */ void removeInformationArray(const int index, const int arrayIndex); /** * Gets the amount of values stored in the specified array. * * Returns an error if the index is out of bounds * Returns an error if the array index is out of bounds * * @param index The index of the information that controls the * array to be removed. * @param arrayIndex The index of the array in the information. */ int retrieveInformationArraySize(const int index, const int arrayIndex); /** * Gets the array type of the specified array. * * Returns an error if the index is out of bounds * Returns an error if the array index is out of bounds * * @param index The index of the information that controls the * array whose type is being retrieved. * @param arrayIndex The index of the array in the information. */ int retrieveInformationArrayValueType(const int index, const int arrayIndex); /** * Retrieves the values contained in the specified array. * * Returns an error if the index is out of bounds * Returns an error if the array index is out of bounds * * @param index The index of the information that controls the * array whose data is being retrieved. * @param arrayIndex The index of the array in the information. * @param values A pointer that the read values will be placed in. * @param dataType The type that the read data will be read in as. * @param numberRead The number of data items read from the array. * @param startIndex The index of the first value to be read. * @param arrayStride The increment beteween read values in the array. * @param valueStride The increment betweeen written values in the pointer. */ void retrieveInformationArrayValues(const int index, const int arrayIndex, void * values, const int dataType, const int numberRead, const int startIndex, const int arrayStride, const int valueStride); /** * Sets the specified information array as an array variable associated with a specific name. * Used in conjuction with Functions. * * @param varname The variable to accociate with the array. * @param infoindex The index of the information holding the array * @param index The index of the array. */ void setInformationArrayAsVariable(char * varname, int infoindex, int index); /** * Sets the specified information array as the current subset reference. * * @param infoindex The index of the information holding the array * @param index The index of the array. */ void setInformationArrayAsSubsetReference(int infoindex, int index); /** * Creates an attribute that is a function of other arrays. * Interacts with setXXXXAsVariable * * @param expression The function that will be processed when creating the array. * @param name The name of the array. * @param attributeCenter The center of the attribute being created. * @param attributeType The attribute type of the attribute being created. */ int addFunctionAsAttribute(char * expression, const char * const name, const int attributeCenter, const int attributeType); /** * Creates a coordinate that is a function of other arrays. * Interacts with setXXXXAsVariable * * @param expression The function that will be processed when creating the array. * @param name The name of the array. */ int addFunctionAsCoordinate(char * expression, char * name); /** * Creates a set that is a function of other arrays. * Interacts with setXXXXAsVariable * * @param expression The function that will be processed when creating the array. * @param name The name of the array. * @param newSetType The set type of the set being created. */ int addFunctionAsSet(char * expression, char * name, const int newSetType); /** * Creates a information array that is a function of other arrays. * Interacts with setXXXXAsVariable * * @param expression The function that will be processed when creating the array. * @param index The index of the information that the array will be added to. * @param name The name of the array. */ void addFunctionAsInformationArray(char * expression, const int index, char * name); /** * Creates a topology that is a function of other arrays. * Interacts with setXXXXAsVariable * * @param expression The function that will be processed when creating the array. * @param topologyType The set type of the set being created. * @param numNodes The number of nodes in the new topology. */ int setFunctionAsTopology(char * expression, const int topologyType, const int numNodes); /** * Creates a geometry that is a function of other arrays. * Interacts with setXXXXAsVariable * * @param expression The function that will be processed when creating the array. * @param geometryType The set type of the set being created. */ int setFunctionAsGeometry(char * expression, const int geometryType); /** * Creates an attribute that is a subset of another array. * Interacts with setXXXXAsSubsetReference * * @param start The starting index of the subset within the reference. * @param stride The distance between values taken from the reference * @param dimensions The total number of values taken from the reference. * @param name The name of the array. * @param attributeCenter The center of the attribute being created. * @param attributeType The attribute type of the attribute being created. */ int addSubsetAsAttribute(int start, int stride, int dimensions, const char * const name, const int attributeCenter, const int attributeType); /** * Creates a coordinate that is a subset of another array. * Interacts with setXXXXAsSubsetReference * * @param start The starting index of the subset within the reference. * @param stride The distance between values taken from the reference * @param dimensions The total number of values taken from the reference. * @param name The name of the array. */ int addSubsetAsCoordinate(int start, int stride, int dimensions, char * name); /** * Creates a set that is a subset of another array. * Interacts with setXXXXAsSubsetReference * * @param start The starting index of the subset within the reference. * @param stride The distance between values taken from the reference * @param dimensions The total number of values taken from the reference. * @param name The name of the array. * @param newSetType The set type of the set being created. */ int addSubsetAsSet(int start, int stride, int dimensions, char * name, const int newSetType); /** * Creates a information array that is a subset of another array. * Interacts with setXXXXAsSubsetReference * * @param start The starting index of the subset within the reference. * @param stride The distance between values taken from the reference * @param dimensions The total number of values taken from the reference. * @param index The index of the information that the array will be added to. * @param name The name of the array. */ void addSubsetAsInformationArray(int start, int stride, int dimensions, const int index, char * name); /** * Creates a topology that is a subset of another array. * Interacts with setXXXXAsSubsetReference * * @param start The starting index of the subset within the reference. * @param stride The distance between values taken from the reference * @param dimensions The total number of values taken from the reference. * @param topologyType The set type of the set being created. * @param numNodes The number of nodes in the new topology. */ int setSubsetAsTopology(int start, int stride, int dimensions, const int topologyType, const int numNodes); /** * Creates a geometry that is a subset of another array. * Interacts with setXXXXAsSubsetReference * * @param start The starting index of the subset within the reference. * @param stride The distance between values taken from the reference * @param dimensions The total number of values taken from the reference. * @param geometryType The set type of the set being created. */ int setSubsetAsGeometry(int start, int stride, int dimensions, const int geometryType); /** * Clears all variables from the variable list. */ void clearFunctionVariables(); /** * Removes the variable with the specified name from the variable list. * */ void removeFunctionVariable(char * varname); /** * clears all of the mPrevious vectors. Used to reduce memory load. */ void clearPrevious(); /** * Sets whether to allow the hdf5 writer to split large data sets across multiple files. * Setting to true removes compatibiliity with previous versions. * When off it will write sets that will not fit into a file to the current file * before moving to the next should file splitting be enabled. * Default is off (false). * * @param newAllow Whether to allow splitting or not */ void setAllowSetSplitting(bool newAllow); /** * Sets the file size at which the hdf5 writer will move to a new file. * Default is no splitting (value=0) * * @param newSize New maximum file size before moving */ void setMaxFileSize(int newSize); /** * Write constructed file to disk. * * @param xmlFilePath The path to the xml file to write to. * @param release Whether the HDF5 writer will release data after finishing */ void write(const char * const xmlFilePath, const int dataLimit, const bool release); /** * Write HDF5 heavy data to disk and release * * @param xmlFilePath The path to the xml file to write to. * @param release Whether or not to release data after a write */ void writeHDF5(const char * const xmlFilePath, const bool release); #ifdef XDMF_BUILD_DSM /** * Starts up a dsm server on cores from the start index to the end index. * The server cores are blocked and will not proceed past this point * until the dsm is stopped. * * @param filePath A string denoting the file path to the virtual file. * @param comm The Communicator between all cores, * worker and server. * @param bufferSize The size of the memory buffer allocated per core. * @param startCoreIndex The core index on which the dsm section begins. * @param endCoreIndex The core index on which the dsm section ends. */ void initDSMServer(const char * const filePath, MPI_Comm comm, int bufferSize, int startCoreIndex, int endCoreIndex); /** * Accepts new connections into an initialized dsm server. * * @param numConnections The number of incoming connections to accept. */ void acceptDSM(int numConnections); /** * Closes the currently open port to the comm. */ void closeDSMPort(); /** * Connects to an initialized dsm server. * * @param filePath The file path that the DSMWriter will be writing to, * should be the same as on the server side. * @param comm The local communicator to be connected to the * server communicator. */ void connectDSM(const char * const filePath, MPI_Comm comm); /** * Gets the communicator across the entire dsm and all connected to it. * * @return The overarching communicator. */ MPI_Comm getDSMInterComm(); /** * Gets the local communicator that the worker cores share. * * @return The communicator for the local worker group */ MPI_Comm getDSMIntraComm(); /** * Stops the currently running dsm server. */ void stopDSM(); /** * Writes the provided values to the DSM using at the location generated by * the provided start, stride, dimensions, and dataspace. * * @param dsmDataSetPath The path to the dataset being written to. * Will overwrite current dsm if different. * @param arrayType The data type of the data to be written to the set. * @param values A pointer to the values to be written. * @param start The starting index to write to. * @param stride The increment between writing data. * @param dimensions The number of data items written. * @param dataspace The total number of data items in the dataset. */ void writeToDSM(const char * const dsmDataSetPath, const int arrayType, void * values, const int start, const int stride, const int dimensions, const int dataspace); /** * Reads the data in the dsm at the location generated from the * start, stride, dimensions, and dataspace and places it into the * provided pointer. * * @param dsmDataSetPath The path to the dataset being read. * @param arrayType The data type of the data being read. * @param values A pointer to the location that the data * will be stored at. * @param start The starting index of the read. * @param stride The increment between read values. * @param dimensions The amount of value to be read. * @param dataspace The total number of data items in the dataset. */ void readFromDSM(const char * const dsmDataSetPath, const int arrayType, void * values, const int start, const int stride, const int dimensions, const int dataspace); #endif /** * Generate the persistant hdf5 writer so it doesn't need to be generated later * * @param xmlFilePath The path to the xml file to write to. * @param release Whether or not to release data after a write */ void initHDF5(const char * const xmlFilePath, const bool release); /** * Read xml file and make it the domain. Replaces current domain. * * @param xmlFilePath The path to the xml file to read. */ void read(const char * const xmlFilePath); /** * Set the topology (connectivity data) for a polyline that will be * added to the next grid. * * @param nodesPerElement Number of nodes in the polyline. * @param numValues Number of connectivity values to copy. * @param arrayType Type of connectivity values. * @param connectivityValues Array of connectivity values. * * @return int providing id to fortran if reusing. */ int setTopologyPolyline(const unsigned int nodesPerElement, const unsigned int numValues, const int arrayType, const void * const connectivityValues); /** * Set the topology (connectivity data) for a polygon that will be * added to the next grid. * * @param nodesPerElement Number of nodes in the polygon. * @param numValues Number of connectivity values to copy. * @param arrayType Type of connectivity values. * @param connectivityValues Array of connectivity values. * * @return int providing id to fortran if reusing. */ int setTopologyPolygon(const unsigned int nodesPerElement, const unsigned int numValues, const int arrayType, const void * const connectivityValues); private: template void insertElements(const T grid, std::vector > & mAttributes, std::vector > & mInformations, std::vector > & mSets, std::vector > & mMaps, shared_ptr mTime, shared_ptr mDomain, std::stack > & mGridCollections); void readFromArray(shared_ptr array, const int arrayType, void * const values, const unsigned int numValues, const unsigned int startIndex, const unsigned int arrayStride, const unsigned int valuesStride); void writeToArray(shared_ptr array, const unsigned int numValues, const int arrayType, const void * const values, const unsigned int offset = 0, const unsigned int arrayStride = 1, const unsigned int valueStride = 1); shared_ptr mDomain; shared_ptr mGeometry; shared_ptr mTime; shared_ptr mTopology; shared_ptr mBrick; shared_ptr mOrigin; shared_ptr mDimensions; shared_ptr mHeavyDataWriter; shared_ptr mDSMWriter; std::vector > mAttributes; std::vector > mCoordinates; std::stack > mGridCollections; std::vector > mInformations; std::vector > mSets; std::vector > mMaps; std::map > mVariableSet; shared_ptr mSubsetReference; std::vector > mPreviousAttributes; std::vector > mPreviousGeometries; std::vector > mPreviousInformations; std::vector > mPreviousSets; std::vector > mPreviousTopologies; std::vector > mPreviousDimensions; std::vector > mPreviousOrigins; std::vector > mPreviousBricks; std::vector > mPreviousCoordinates; std::vector > mPreviousMaps; std::vector > mPreviousFunctions; std::vector > mPreviousSubsets; unsigned int mMaxFileSize; bool mAllowSetSplitting; }; #endif /* XDMFFORTRAN_HPP_ */ xdmf-3.0+git20160803/utils/XdmfPartitioner.cpp0000640000175000017500000014401313003006557021060 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfPartitioner.cpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef BUILD_EXE extern "C" { #include } #include #include #include "XdmfAttribute.hpp" #include "XdmfAttributeCenter.hpp" #include "XdmfAttributeType.hpp" #include "XdmfError.hpp" #include "XdmfGeometry.hpp" #include "XdmfGeometryType.hpp" #include "XdmfGraph.hpp" #include "XdmfGridCollection.hpp" #include "XdmfGridCollectionType.hpp" #include "XdmfHeavyDataWriter.hpp" #include "XdmfMap.hpp" #include "XdmfPartitioner.hpp" #include "XdmfSet.hpp" #include "XdmfSetType.hpp" #include "XdmfTopology.hpp" #include "XdmfTopologyType.hpp" #include "XdmfUnstructuredGrid.hpp" // // local methods // namespace { shared_ptr addSymmetricEntries(const shared_ptr graph) { const shared_ptr rowPointer = graph->getRowPointer(); const shared_ptr columnIndex = graph->getColumnIndex(); const unsigned int numberRows = graph->getNumberRows(); std::set > entrySet; for(unsigned int i=0; igetValue(i); jgetValue(i+1); ++j) { const unsigned int k = columnIndex->getValue(j); entrySet.insert(std::make_pair(i, k)); entrySet.insert(std::make_pair(k, i)); } } shared_ptr toReturn = XdmfGraph::New(numberRows); shared_ptr toReturnRowPointer = toReturn->getRowPointer(); shared_ptr toReturnColumnIndex = toReturn->getColumnIndex(); shared_ptr toReturnValues = toReturn->getValues(); unsigned int currentRow = 1; for(std::set >::const_iterator iter = entrySet.begin(); iter != entrySet.end(); ++iter) { const std::pair & entry = *iter; const unsigned int row = entry.first; const unsigned int column = entry.second; for(unsigned int j = currentRow; jinsert(j, toReturnColumnIndex->getSize()); } currentRow = row + 1; toReturnColumnIndex->pushBack(column); toReturnValues->pushBack(1.0); toReturnRowPointer->insert(row+1, toReturnColumnIndex->getSize()); } return toReturn; } } shared_ptr XdmfPartitioner::New() { shared_ptr p(new XdmfPartitioner()); return p; } XdmfPartitioner::XdmfPartitioner() { } XdmfPartitioner::XdmfPartitioner(const XdmfPartitioner & partitioner) : mIgnoredSets(partitioner.mIgnoredSets) { } XdmfPartitioner::~XdmfPartitioner() { } void XdmfPartitioner::ignore(const shared_ptr set) { mIgnoredSets.insert(set.get()); } void XdmfPartitioner::ignore(const XdmfSet * set) { mIgnoredSets.insert(set); } void XdmfPartitioner::partition(const shared_ptr graphToPartition, const unsigned int numberOfPartitions) const { // Make sure row pointer and column index are non null if(!(graphToPartition->getRowPointer() && graphToPartition->getColumnIndex())) { XdmfError::message(XdmfError::FATAL, "Current graph's row pointer or column index is null " "in XdmfPartitioner::partition"); } graphToPartition->removeAttribute("Partition"); shared_ptr attribute = XdmfAttribute::New(); attribute->setName("Partition"); attribute->setCenter(XdmfAttributeCenter::Node()); attribute->setType(XdmfAttributeType::Scalar()); graphToPartition->insert(attribute); idx_t numberVertices = graphToPartition->getNumberNodes(); // Handle case where we partition onto 1 processor. Metis for some reason // handles this incorrectly (indices are 1 instead of zero even though // correct numbering option is supplied to metis) if(numberOfPartitions == 1) { attribute->resize(numberVertices, 0); return; } shared_ptr rowPointer = graphToPartition->getRowPointer(); shared_ptr columnIndex = graphToPartition->getColumnIndex(); idx_t numberConstraints = 1; bool releaseRowPointer = false; if(!rowPointer->isInitialized()) { rowPointer->read(); releaseRowPointer = true; } bool releaseColumnIndex = false; if(!columnIndex->isInitialized()) { columnIndex->read(); releaseColumnIndex = true; } shared_ptr graph = graphToPartition; // Check whether graph is directed, if so we need to make it undirected // in order to partition with metis. From metis FAQ: // // The partitioning routines in METIS can only partition undirected graphs // (i.e., graphs in which for each edge (v,u) there is also an edge (u,v)). // For partitioning purposes, the directionality of an edge does not play // any role because if edge (u,v) is cut so will the edge (v,u). For this // reason, a directed graph can be easily partitioned by METIS by first // converting it into the corresponding undirected graph. That is, create // a graph for each directed edge (u,v) also contains the (v,u) edge as // well. const unsigned int numberRows = graphToPartition->getNumberRows(); for(unsigned int i=0; igetValue(i); jgetValue(i+1); ++j) { const unsigned int k = columnIndex->getValue(j); bool symmetric = false; for(unsigned int l=rowPointer->getValue(k); lgetValue(k+1); ++l) { const unsigned int m = columnIndex->getValue(l); if(i == m) { symmetric = true; break; } } if(!symmetric) { graph = addSymmetricEntries(graphToPartition); if(releaseRowPointer) { rowPointer->release(); } if(releaseColumnIndex) { columnIndex->release(); } rowPointer = graph->getRowPointer(); columnIndex = graph->getColumnIndex(); break; } } } // copy into metis data structures idx_t * xadj = new idx_t[rowPointer->getSize()]; rowPointer->getValues(0, xadj, rowPointer->getSize()); if(releaseRowPointer) { rowPointer->release(); } idx_t * adjncy = new idx_t[columnIndex->getSize()]; columnIndex->getValues(0, adjncy, columnIndex->getSize()); if(releaseColumnIndex) { columnIndex->release(); } idx_t * vwgt = NULL; // equal vertex weights idx_t * vsize = NULL; // equal vertex sizes idx_t * adjwgt = NULL; // equal edge weights idx_t numParts = numberOfPartitions; real_t * tpwgts = NULL; // equal constraints and partition weights real_t * ubvec = NULL; // default load imbalance tolerance idx_t * options = NULL; // default options idx_t objval; idx_t * part = new idx_t[numberVertices]; METIS_PartGraphRecursive(&numberVertices, &numberConstraints, xadj, adjncy, vwgt, vsize, adjwgt, &numParts, tpwgts, ubvec, options, &objval, part); delete [] xadj; delete [] adjncy; attribute->insert(0, part, numberVertices); delete [] part; return; } shared_ptr XdmfPartitioner::partition(const shared_ptr gridToPartition, const unsigned int numberOfPartitions, const MetisScheme metisScheme, const shared_ptr heavyDataWriter) const { if(heavyDataWriter) { heavyDataWriter->openFile(); } // Make sure geometry and topology are non null if(!(gridToPartition->getGeometry() && gridToPartition->getTopology())) { XdmfError::message(XdmfError::FATAL, "Current grid's geometry or topology is null in " "XdmfPartitioner::partition"); } const shared_ptr geometry = gridToPartition->getGeometry(); const shared_ptr geometryType = geometry->getType(); const unsigned int geometryDimensions = geometryType->getDimensions(); const shared_ptr topology = gridToPartition->getTopology(); const shared_ptr topologyType = topology->getType(); const unsigned int nodesPerElement = topologyType->getNodesPerElement(); bool releaseTopology = false; if(!topology->isInitialized()) { topology->read(); releaseTopology = true; } idx_t numElements = topology->getNumberElements(); idx_t numNodes = geometry->getNumberPoints(); // allocate metisConnectivity arrays idx_t * metisConnectivityEptr = new idx_t[numElements + 1]; idx_t * metisConnectivityEind = new idx_t[nodesPerElement * numElements]; metisConnectivityEptr[0] = 0; unsigned int metisConnectivityEptrValue = 0; unsigned int connectivityOffset = 0; idx_t * metisConnectivityPtr = metisConnectivityEind; for(int i=0; igetValues(connectivityOffset, metisConnectivityPtr, nodesPerElement); connectivityOffset += topologyType->getNodesPerElement(); metisConnectivityPtr += nodesPerElement; } idx_t * vwgt = NULL; // equal weight idx_t * vsize = NULL; // equal size idx_t ncommon = 1; // FIXME idx_t nparts = numberOfPartitions; real_t * tpwgts = NULL; idx_t * options = NULL; idx_t objval; idx_t * elementsPartition = new idx_t[numElements]; idx_t * nodesPartition = new idx_t[numNodes]; if(metisScheme == DUAL_GRAPH) { METIS_PartMeshDual(&numElements, &numNodes, metisConnectivityEptr, metisConnectivityEind, vwgt, vsize, &ncommon, &nparts, tpwgts, options, &objval, elementsPartition, nodesPartition); } else if(metisScheme == NODAL_GRAPH) { METIS_PartMeshNodal(&numElements, &numNodes, metisConnectivityEptr, metisConnectivityEind, vwgt, vsize, &nparts, tpwgts, options, &objval, elementsPartition, nodesPartition); } else { XdmfError::message(XdmfError::FATAL, "Invalid metis partitioning scheme selected in " "XdmfPartitioner::partition"); } delete [] metisConnectivityEptr; delete [] metisConnectivityEind; delete [] nodesPartition; // map of global node ids to pair of partition id and local node id std::vector > nodeIdMap(numNodes); // map of global element ids to pair of partition id and local element id std::vector > elementIdMap(numElements); // keep count of number of nodes and element per partition, needed to // generate local node and element ids std::vector localNodeCounts(numberOfPartitions, 0); std::vector localElementCounts(numberOfPartitions, 0); // fill maps unsigned int totalIndex = 0; for(int i=0; igetValue(totalIndex++); std::map & localNodeIds = nodeIdMap[globalNodeId]; std::map::const_iterator iter = localNodeIds.find(partitionId); if(iter == localNodeIds.end()) { localNodeIds[partitionId] = localNodeCounts[partitionId]; localNodeCounts[partitionId]++; } else { localNodeIds[partitionId] = iter->second; } } elementIdMap[i] = std::make_pair(partitionId, localElementCounts[partitionId]); localElementCounts[partitionId]++; } delete [] elementsPartition; // create returned partitioned grid shared_ptr partitionedGrid = XdmfGridCollection::New(); partitionedGrid->setType(XdmfGridCollectionType::Spatial()); // add unstructured grids to partitionedGrid and initialize topology // and geometry in each for(unsigned int i=0; igetName() << "_" << i; const shared_ptr grid = XdmfUnstructuredGrid::New(); grid->setName(name.str()); partitionedGrid->insert(grid); shared_ptr localGeometry = grid->getGeometry(); localGeometry->setType(geometryType); localGeometry->initialize(geometry->getArrayType(), localNodeCount * geometryDimensions); shared_ptr localTopology = grid->getTopology(); localTopology->setType(topologyType); localTopology->initialize(topology->getArrayType(), localElementCount * nodesPerElement); } bool releaseGeometry = false; if(!geometry->isInitialized()) { geometry->read(); releaseGeometry = true; } // fill geometry for each partition for(int i=0; i & localNodeIds = nodeIdMap[i]; for(std::map::const_iterator iter = localNodeIds.begin(); iter != localNodeIds.end(); ++iter) { const unsigned int partitionId = iter->first; const unsigned int localNodeId = iter->second; const shared_ptr grid = partitionedGrid->getUnstructuredGrid(partitionId); const shared_ptr localGeometry = grid->getGeometry(); localGeometry->insert(localNodeId * geometryDimensions, geometry, i * geometryDimensions, geometryDimensions); } } if(releaseGeometry) { geometry->release(); } // write geometries to disk if possible if(heavyDataWriter) { for(unsigned int i=0; i grid = partitionedGrid->getUnstructuredGrid(i); const shared_ptr localGeometry = grid->getGeometry(); if(localGeometry->getSize() > 0) { localGeometry->accept(heavyDataWriter); localGeometry->release(); } } } // fill topology for each partition for(int i=0; i & partitionElementPair = elementIdMap[i]; const unsigned int partitionId = partitionElementPair.first; const unsigned int localElementId = partitionElementPair.second; const shared_ptr grid = partitionedGrid->getUnstructuredGrid(partitionId); const shared_ptr localTopology = grid->getTopology(); for(unsigned int j=0; jgetValue(i*nodesPerElement + j); const unsigned int localNodeId = nodeIdMap[globalNodeId][partitionId]; localTopology->insert(localElementId*nodesPerElement + j, localNodeId); } } if(releaseTopology) { topology->release(); } // write topology to disk if possible if(heavyDataWriter) { for(unsigned int i=0; i grid = partitionedGrid->getUnstructuredGrid(i); const shared_ptr localTopology = grid->getTopology(); if(localTopology->getSize() > 0) { localTopology->accept(heavyDataWriter); localTopology->release(); } } } // split attributes const unsigned int numberAttributes = gridToPartition->getNumberAttributes(); for(unsigned int i=0; i attribute = gridToPartition->getAttribute(i); bool releaseAttribute = false; if(!attribute->isInitialized()) { attribute->read(); releaseAttribute = true; } const shared_ptr attributeCenter = attribute->getCenter(); std::vector > localAttributes; localAttributes.reserve(numberOfPartitions); if(attributeCenter == XdmfAttributeCenter::Grid()) { // insert into each partition for(unsigned int j=0; jgetUnstructuredGrid(j)->insert(attribute); } localAttributes.push_back(attribute); } else if(attributeCenter == XdmfAttributeCenter::Cell()) { const unsigned int numberComponents = attribute->getSize() / numElements; for(unsigned int j=0; j localAttribute = XdmfAttribute::New(); localAttribute->setName(attribute->getName()); localAttribute->setCenter(attribute->getCenter()); localAttribute->setType(attribute->getType()); localAttribute->initialize(attribute->getArrayType(), localElementCounts[j] * numberComponents); partitionedGrid->getUnstructuredGrid(j)->insert(localAttribute); localAttributes.push_back(localAttribute); } for(int j=0; j & partitionElementPair = elementIdMap[j]; const unsigned int partitionId = partitionElementPair.first; const unsigned int localElementId = partitionElementPair.second; const shared_ptr localAttribute = localAttributes[partitionId]; localAttribute->insert(localElementId * numberComponents, attribute, j * numberComponents, numberComponents); } } else if(attributeCenter == XdmfAttributeCenter::Node()) { const unsigned int numberComponents = attribute->getSize() / numNodes; for(unsigned int j=0; j localAttribute = XdmfAttribute::New(); localAttribute->setName(attribute->getName()); localAttribute->setCenter(attribute->getCenter()); localAttribute->setType(attribute->getType()); localAttribute->initialize(attribute->getArrayType(), localNodeCounts[j] * numberComponents); partitionedGrid->getUnstructuredGrid(j)->insert(localAttribute); localAttributes.push_back(localAttribute); } for(int j=0; j & localNodeIds = nodeIdMap[j]; for(std::map::const_iterator iter = localNodeIds.begin(); iter != localNodeIds.end(); ++iter) { const unsigned int partitionId = iter->first; const unsigned int localNodeId = iter->second; const shared_ptr localAttribute = localAttributes[partitionId]; localAttribute->insert(localNodeId * numberComponents, attribute, j * numberComponents, numberComponents); } } } if(heavyDataWriter) { for(std::vector >::const_iterator iter = localAttributes.begin(); iter != localAttributes.end(); ++iter) { const shared_ptr localAttribute = *iter; if(!localAttribute->isInitialized()) { localAttribute->read(); } if(localAttribute->getSize() > 0) { localAttribute->accept(heavyDataWriter); localAttribute->release(); } } } if(releaseAttribute) { attribute->release(); } } // create globalnodeid if required bool generateGlobalNodeIds = !gridToPartition->getAttribute("GlobalNodeId"); std::vector > globalNodeIds; globalNodeIds.reserve(numberOfPartitions); if(generateGlobalNodeIds) { for(unsigned int i=0; i globalNodeId = XdmfAttribute::New(); globalNodeId->setName("GlobalNodeId"); globalNodeId->setCenter(XdmfAttributeCenter::Node()); globalNodeId->setType(XdmfAttributeType::GlobalId()); globalNodeId->initialize(XdmfArrayType::UInt32(), localNodeCounts[i]); partitionedGrid->getUnstructuredGrid(i)->insert(globalNodeId); globalNodeIds.push_back(globalNodeId); } for(int i=0; i & localNodeIds = nodeIdMap[i]; for(std::map::const_iterator iter = localNodeIds.begin(); iter != localNodeIds.end(); ++iter) { const unsigned int partitionId = iter->first; const unsigned int localNodeId = iter->second; const shared_ptr globalNodeId = globalNodeIds[partitionId]; globalNodeId->insert(localNodeId, i); } } if(heavyDataWriter) { for(std::vector >::const_iterator iter = globalNodeIds.begin(); iter != globalNodeIds.end(); ++iter) { const shared_ptr globalNodeId = *iter; if(globalNodeId->getSize() > 0) { globalNodeId->accept(heavyDataWriter); globalNodeId->release(); } } } } else { for(unsigned int i=0; i grid = partitionedGrid->getUnstructuredGrid(i); globalNodeIds.push_back(grid->getAttribute("GlobalNodeId")); } } // split sets const unsigned int numberSets = gridToPartition->getNumberSets(); for(unsigned int i=0; i set = gridToPartition->getSet(i); if(mIgnoredSets.find(set.get()) == mIgnoredSets.end()) { bool releaseSet = false; if(!set->isInitialized()) { set->read(); releaseSet = true; } const shared_ptr setType = set->getType(); const unsigned int setSize = set->getSize(); std::vector > localSets; localSets.reserve(numberOfPartitions); if(setType == XdmfSetType::Cell()) { for(unsigned int j=0; j localSet = XdmfSet::New(); localSets.push_back(localSet); } for(unsigned int j=0; jgetValue(j); const std::pair & partitionElementPair = elementIdMap[globalElementId]; const unsigned int partitionId = partitionElementPair.first; const unsigned int localElementId = partitionElementPair.second; const shared_ptr localSet = localSets[partitionId]; localSet->pushBack(localElementId); } } else if(setType == XdmfSetType::Node()) { for(unsigned int j=0; j localSet = XdmfSet::New(); localSets.push_back(localSet); } for(unsigned int j=0; jgetValue(j); const std::map & localNodeIds = nodeIdMap[globalNodeId]; for(std::map::const_iterator iter = localNodeIds.begin(); iter != localNodeIds.end(); ++iter) { const unsigned int partitionId = iter->first; const unsigned int localNodeId = iter->second; const shared_ptr localSet = localSets[partitionId]; localSet->pushBack(localNodeId); } } } for(std::vector >::size_type j=0; j localSet = localSets[j]; if(localSet->getSize() > 0) { partitionedGrid->getUnstructuredGrid(j)->insert(localSet); localSet->setName(set->getName()); localSet->setType(set->getType()); if(heavyDataWriter) { localSet->accept(heavyDataWriter); localSet->release(); } } } const unsigned int numberAttributes = set->getNumberAttributes(); for(unsigned int j=0; j attribute = set->getAttribute(j); bool releaseAttribute = false; if(!attribute->isInitialized()) { attribute->read(); releaseAttribute = true; } const shared_ptr attributeCenter = attribute->getCenter(); const unsigned int attributeSize = attribute->getSize(); const unsigned int numberComponents = attributeSize / setSize; std::vector > localAttributes; localAttributes.reserve(numberOfPartitions); if(attributeCenter == XdmfAttributeCenter::Cell()) { for(unsigned int k=0; k localSet = localSets[k]; const shared_ptr localAttribute = XdmfAttribute::New(); localAttribute->reserve(numberComponents * localSet->getSize()); localAttributes.push_back(localAttribute); } for(unsigned int k=0; kgetValue(k); const std::pair & partitionElementPair = elementIdMap[globalElementId]; const unsigned int partitionId = partitionElementPair.first; const shared_ptr localAttribute = localAttributes[partitionId]; localAttribute->insert(localAttribute->getSize(), attribute, k * numberComponents, numberComponents); } } else if(attributeCenter == XdmfAttributeCenter::Node()) { for(unsigned int k=0; k localSet = localSets[k]; const shared_ptr localAttribute = XdmfAttribute::New(); localAttribute->reserve(numberComponents * localSet->getSize()); localAttributes.push_back(localAttribute); } for(unsigned int k=0; kgetValue(k); const std::map & localNodeIds = nodeIdMap[globalNodeId]; for(std::map::const_iterator iter = localNodeIds.begin(); iter != localNodeIds.end(); ++iter) { const unsigned int partitionId = iter->first; const shared_ptr localAttribute = localAttributes[partitionId]; localAttribute->insert(localAttribute->getSize(), attribute, k * numberComponents, numberComponents); } } } if(releaseAttribute) { attribute->release(); } for(std::vector >::size_type k=0; k localAttribute = localAttributes[k]; if(localAttribute->getSize() > 0) { localSets[k]->insert(localAttribute); localAttribute->setName(attribute->getName()); localAttribute->setCenter(attribute->getCenter()); localAttribute->setType(attribute->getType()); if(heavyDataWriter) { localAttribute->accept(heavyDataWriter); localAttribute->release(); } } } } if(releaseSet) { set->release(); } } } // add XdmfMap to map boundary nodes between partitions std::vector > maps = XdmfMap::New(globalNodeIds); for(unsigned int i=0; i map = maps[i]; map->setName("Subdomain Boundary"); partitionedGrid->getUnstructuredGrid(i)->insert(map); if(heavyDataWriter) { map->accept(heavyDataWriter); map->release(); } } return partitionedGrid; } shared_ptr XdmfPartitioner::unpartition(const shared_ptr gridToUnPartition) const { const shared_ptr returnValue = XdmfUnstructuredGrid::New(); const shared_ptr returnValueTopology = returnValue->getTopology(); const shared_ptr returnValueGeometry = returnValue->getGeometry(); const unsigned int numberUnstructuredGrids = gridToUnPartition->getNumberUnstructuredGrids(); unsigned int elementOffset = 0; for(unsigned int i=0; i grid = gridToUnPartition->getUnstructuredGrid(i); const shared_ptr globalNodeIds = grid->getAttribute("GlobalNodeId"); if(!globalNodeIds) { XdmfError::message(XdmfError::FATAL, "Cannot find GlobalNodeId attribute in " "XdmfPartitioner::unpartition"); } bool releaseGlobalNodeIds = false; if(!globalNodeIds->isInitialized()) { globalNodeIds->read(); releaseGlobalNodeIds = true; } // handle topology const shared_ptr topology = grid->getTopology(); if(i==0) { returnValueTopology->setType(topology->getType()); returnValueTopology->initialize(topology->getArrayType()); } returnValueTopology->reserve(returnValueTopology->getSize() + topology->getSize()); bool releaseTopology = false; if(!topology->isInitialized()) { topology->read(); releaseTopology = true; } for(unsigned int j=0; jgetSize(); ++j) { const unsigned int localNodeId = topology->getValue(j); const unsigned int globalNodeId = globalNodeIds->getValue(localNodeId); returnValueTopology->pushBack(globalNodeId); } if(releaseTopology) { topology->release(); } // handle geometry const shared_ptr geometry = grid->getGeometry(); const shared_ptr geometryType = geometry->getType(); const unsigned int geometryDimension = geometryType->getDimensions(); if(i==0) { returnValueGeometry->setType(geometryType); returnValueGeometry->initialize(geometry->getArrayType()); } bool releaseGeometry = false; if(!geometry->isInitialized()) { geometry->read(); releaseGeometry = true; } for(unsigned int j=0; jgetSize(); ++j) { const unsigned int globalNodeId = globalNodeIds->getValue(j); returnValueGeometry->insert(globalNodeId * geometryDimension, geometry, j * geometryDimension, geometryDimension); } if(releaseGeometry) { geometry->release(); } // handle attributes for(unsigned int j=0; jgetNumberAttributes(); ++j) { const shared_ptr attribute = grid->getAttribute(j); const shared_ptr attributeCenter = attribute->getCenter(); bool releaseAttribute = false; if(!attribute->isInitialized()) { attribute->read(); releaseAttribute = true; } shared_ptr returnValueAttribute; if(i==0) { returnValueAttribute = XdmfAttribute::New(); returnValueAttribute->setName(attribute->getName()); returnValueAttribute->setCenter(attributeCenter); returnValueAttribute->setType(attribute->getType()); returnValueAttribute->initialize(attribute->getArrayType()); returnValue->insert(returnValueAttribute); } else { returnValueAttribute = returnValue->getAttribute(attribute->getName()); } if(attributeCenter == XdmfAttributeCenter::Grid()) { returnValueAttribute->insert(0, attribute, 0, attribute->getSize()); } else if(attributeCenter == XdmfAttributeCenter::Cell()) { returnValueAttribute->insert(returnValueAttribute->getSize(), attribute, 0, attribute->getSize()); } else if(attributeCenter == XdmfAttributeCenter::Node()) { const unsigned int numberComponents = attribute->getSize() / geometry->getNumberPoints(); for(unsigned int k=0; kgetSize(); ++k) { const unsigned int globalNodeId = globalNodeIds->getValue(k); returnValueAttribute->insert(globalNodeId * numberComponents, attribute, k * numberComponents, numberComponents); } } if(releaseAttribute) { attribute->release(); } } // handle sets for(unsigned int j=0; jgetNumberSets(); ++j) { const shared_ptr set = grid->getSet(j); const shared_ptr setType = set->getType(); bool releaseSet = false; if(!set->isInitialized()) { set->read(); releaseSet = true; } shared_ptr returnValueSet = returnValue->getSet(set->getName()); if(!returnValueSet) { returnValueSet = XdmfSet::New(); returnValueSet->setName(set->getName()); returnValueSet->setType(setType); returnValue->insert(returnValueSet); } if(setType == XdmfSetType::Cell()) { for(unsigned int k=0; kgetSize(); ++k) { const unsigned int localCellId = set->getValue(k); returnValueSet->pushBack(localCellId + elementOffset); } } else if(setType == XdmfSetType::Node()) { for(unsigned int k=0; kgetSize(); ++k){ const unsigned int localNodeId = set->getValue(k); const unsigned int globalNodeId = globalNodeIds->getValue(localNodeId); returnValueSet->pushBack(globalNodeId); } } for(unsigned int k=0; kgetNumberAttributes(); ++k) { const shared_ptr attribute = set->getAttribute(k); bool releaseAttribute = false; if(!attribute->isInitialized()) { attribute->read(); releaseAttribute = true; } const shared_ptr attributeCenter = attribute->getCenter(); const shared_ptr attributeType = attribute->getType(); shared_ptr returnValueAttribute = returnValueSet->getAttribute(attribute->getName()); if(!returnValueAttribute) { returnValueAttribute = XdmfAttribute::New(); returnValueAttribute->setName(attribute->getName()); returnValueAttribute->setCenter(attributeCenter); returnValueAttribute->setType(attributeType); returnValueSet->insert(returnValueAttribute); } if(attributeCenter == XdmfAttributeCenter::Cell() || attributeCenter == XdmfAttributeCenter::Node()) { returnValueAttribute->insert(returnValueAttribute->getSize(), attribute, 0, attribute->getSize()); } if(releaseAttribute) { attribute->release(); } } } elementOffset += topology->getNumberElements(); if(releaseGlobalNodeIds) { globalNodeIds->release(); } } return returnValue; } // C Wrappers XDMFPARTITIONER * XdmfPartitionerNew() { shared_ptr generatedPartitioner = XdmfPartitioner::New(); return (XDMFPARTITIONER *)((void *)(new XdmfPartitioner(*generatedPartitioner.get()))); } void XdmfPartitionerIgnore(XDMFPARTITIONER * partitioner, XDMFSET * set) { ((XdmfPartitioner *)partitioner)->ignore((XdmfSet *)set); } void XdmfPartitionerPartitionGraph(XDMFPARTITIONER * partitioner, XDMFGRAPH * graphToPartition, unsigned int numberOfPartitions) { shared_ptr tempGraph = shared_ptr((XdmfGraph *) graphToPartition, XdmfNullDeleter()); ((XdmfPartitioner *)partitioner)->partition(tempGraph, numberOfPartitions); } XDMFGRIDCOLLECTION * XdmfPartitionerPartitionUnstructuredGrid(XDMFPARTITIONER * partitioner, XDMFUNSTRUCTUREDGRID * gridToPartition, unsigned int numberOfPartitions, int metisScheme, XDMFHEAVYDATAWRITER * heavyDataWriter) { XdmfPartitioner::MetisScheme passedScheme = XdmfPartitioner::DUAL_GRAPH; switch (metisScheme) { case XDMF_PARTITIONER_SCHEME_DUAL_GRAPH: passedScheme = XdmfPartitioner::DUAL_GRAPH; break; case XDMF_PARTITIONER_SCHEME_NODAL_GRAPH: passedScheme = XdmfPartitioner::NODAL_GRAPH; break; default: break; } shared_ptr tempGrid = shared_ptr((XdmfUnstructuredGrid *) gridToPartition, XdmfNullDeleter()); if (heavyDataWriter) { shared_ptr tempwriter = shared_ptr((XdmfHeavyDataWriter *) heavyDataWriter, XdmfNullDeleter()); return (XDMFGRIDCOLLECTION *)((void *)(new XdmfGridCollection(*((((XdmfPartitioner *)partitioner)->partition(tempGrid, numberOfPartitions, passedScheme, tempwriter)).get())))); } else { return (XDMFGRIDCOLLECTION *)((void *)(new XdmfGridCollection(*((((XdmfPartitioner *)partitioner)->partition(tempGrid, numberOfPartitions, passedScheme)).get())))); } } XDMFUNSTRUCTUREDGRID * XdmfPartitionerUnpartition(XDMFPARTITIONER * partitioner, XDMFGRIDCOLLECTION * gridToUnPartition) { shared_ptr tempGrid = shared_ptr((XdmfGridCollection *) gridToUnPartition, XdmfNullDeleter()); return (XDMFUNSTRUCTUREDGRID *)((void *)(new XdmfUnstructuredGrid(*((((XdmfPartitioner *)partitioner)->unpartition(tempGrid)).get())))); } void XdmfPartitionerFree(XDMFPARTITIONER * partitioner) { if (partitioner != NULL) { delete ((XdmfPartitioner *)partitioner); partitioner = NULL; } } #else #include #include #include #include "XdmfDomain.hpp" #include "XdmfGraph.hpp" #include "XdmfGridCollection.hpp" #include "XdmfGridCollectionType.hpp" #include "XdmfHDF5Writer.hpp" #include "XdmfPartitioner.hpp" #include "XdmfReader.hpp" #include "XdmfUnstructuredGrid.hpp" #include "XdmfWriter.hpp" namespace { // // print usage // inline void printUsage(const char * programName) { std::cerr << "usage: " << programName << " " << "[-s metis_scheme] [-r] [-u]" << " [output file]" << std::endl; std::cerr << "\t-s metis_scheme: 1 - Dual Graph" << std::endl; std::cerr << "\t-s metis_scheme: 2 - Node Graph" << std::endl; std::cerr << "\t-u unpartition file" << std::endl; // // // return; } // // process command line // void processCommandLine(std::string & inputFileName, std::string & outputFileName, unsigned int & numberOfPartitions, XdmfPartitioner::MetisScheme & metisScheme, bool & unpartition, int ac, char * av[]) { int c; bool errorFlag = false; while( (c=getopt(ac, av, "s:ur")) != -1 ) switch(c){ case 's': { const int value = std::atoi(optarg); if(value == 1) { metisScheme = XdmfPartitioner::DUAL_GRAPH; } else if(value == 2) { metisScheme = XdmfPartitioner::NODAL_GRAPH; } else { errorFlag = true; } break; } case 'u': unpartition = true; break; case '?': errorFlag = true; break; } if (optind >= ac) errorFlag = true; else { inputFileName = av[optind]; ++optind; } if(!unpartition) { if (optind >= ac) errorFlag = true; else { numberOfPartitions = atoi(av[optind]); ++optind; } } if (optind < ac) { outputFileName = av[optind]; ++optind; } // // check errorFlag // if (errorFlag == true) { printUsage(av[0]); std::exit(EXIT_FAILURE); } } } /** * XdmfPartitioner is a command line utility for partitioning Xdmf grids. * The XdmfPartitioner uses the metis library to partition Triangular, * Quadrilateral, Tetrahedral, and Hexahedral XdmfGridUnstructureds. * * Usage: * XdmfPartitioner * (Optional: ) * */ int main(int argc, char* argv[]) { std::string inputFileName = ""; std::string outputFileName = ""; unsigned int numberOfPartitions = 0; XdmfPartitioner::MetisScheme metisScheme = XdmfPartitioner::DUAL_GRAPH; bool unpartition = false; processCommandLine(inputFileName, outputFileName, numberOfPartitions, metisScheme, unpartition, argc, argv); std::cout << inputFileName << std::endl; FILE * refFile = fopen(inputFileName.c_str(), "r"); if (refFile) { // Success fclose(refFile); } else { std::cout << "Cannot open file: " << argv[1] << std::endl; return 1; } std::string meshName; if(outputFileName.compare("") == 0) { meshName = inputFileName; } else { meshName = outputFileName; } if(meshName.find_last_of("/\\") != std::string::npos) { meshName = meshName.substr(meshName.find_last_of("/\\") + 1, meshName.length()); } if (meshName.rfind(".") != std::string::npos) { meshName = meshName.substr(0, meshName.rfind(".")); } if(outputFileName.compare("") == 0) { std::stringstream newMeshName; if(unpartition) { newMeshName << meshName << "_unpartitioned"; } else { newMeshName << meshName << "_p" << numberOfPartitions; } meshName = newMeshName.str(); } shared_ptr reader = XdmfReader::New(); shared_ptr domain = shared_dynamic_cast(reader->read(inputFileName)); if(unpartition) { if(domain->getNumberGridCollections() == 0) { std::cout << "No grid collections to unpartition" << std::endl; return 1; } } else { if(domain->getNumberUnstructuredGrids() == 0 && domain->getNumberGridCollections() == 0 && domain->getNumberGraphs() == 0) { std::cout << "No grids or graphs to partition" << std::endl; return 1; } } std::stringstream heavyFileName; heavyFileName << meshName << ".h5"; shared_ptr heavyDataWriter = XdmfHDF5Writer::New(heavyFileName.str()); heavyDataWriter->setReleaseData(true); shared_ptr newDomain = XdmfDomain::New(); shared_ptr partitioner = XdmfPartitioner::New(); if(unpartition) { shared_ptr gridCollection = domain->getGridCollection(0); const shared_ptr collectionType = gridCollection->getType(); if(collectionType == XdmfGridCollectionType::Spatial()) { shared_ptr toWrite = partitioner->unpartition(gridCollection); newDomain->insert(toWrite); } else if(collectionType == XdmfGridCollectionType::Temporal()) { const unsigned int numberTimesteps = gridCollection->getNumberGridCollections(); if(numberTimesteps == 0) { std::cout << "No grid collections to unpartition" << std::endl; return 1; } shared_ptr newCollection = XdmfGridCollection::New(); newCollection->setType(XdmfGridCollectionType::Temporal()); for(unsigned int i=0; i spatialCollection = gridCollection->getGridCollection(i); const shared_ptr time = spatialCollection->getTime(); assert(spatialCollection->getType() == XdmfGridCollectionType::Spatial()); const shared_ptr toWrite = partitioner->unpartition(spatialCollection); toWrite->accept(heavyDataWriter); toWrite->setTime(time); newCollection->insert(toWrite); } newDomain->insert(newCollection); } } else { if(domain->getNumberGraphs() == 0) { shared_ptr gridToPartition; if(domain->getNumberUnstructuredGrids() == 0) { // repartition gridToPartition = partitioner->unpartition(domain->getGridCollection(0)); } else { gridToPartition = domain->getUnstructuredGrid(0); } shared_ptr toWrite = partitioner->partition(gridToPartition, numberOfPartitions, metisScheme, heavyDataWriter); newDomain->insert(toWrite); } else { shared_ptr graphToPartition = domain->getGraph(0); partitioner->partition(graphToPartition, numberOfPartitions); newDomain->insert(graphToPartition); } } std::stringstream xmlFileName; xmlFileName << meshName << ".xmf"; shared_ptr writer = XdmfWriter::New(xmlFileName.str(), heavyDataWriter); newDomain->accept(writer); std::cout << "Wrote: " << xmlFileName.str() << std::endl; } #endif // BUILD_EXE xdmf-3.0+git20160803/utils/XdmfUtils.i0000640000175000017500000002053013003006557017323 0ustar alastairalastair/* XdmfUtilsPython.cpp: swig -v -c++ -python -o XdmfUtilsPython.cpp XdmfUtils.i */ #ifdef XDMF_BUILD_DSM %module XdmfUtils %{ // MPI includes #include // XdmfCore Includes #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // Xdmf Includes #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // XdmfUtils Includes #include #include #include #include #include #include #include %} #else %module XdmfUtils %{ // XdmfCore Includes #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // Xdmf Includes #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // XdmfUtils Includes #include #include #include #include #include #include #include %} #endif %import Xdmf.i // Ignoring C Wrappers // XdmfDiff %ignore XdmfDiffNew(); %ignore XdmfDiffCompare(XDMFDIFF * diff, XDMFITEM * item1, XDMFITEM * item2); %ignore XdmfDiffGetAbsoluteTolerance(XDMFDIFF * diff); %ignore XdmfDiffSetAbsoluteTolerance(XDMFDIFF * diff, double tolerance); %ignore XdmfDiffFree(XDMFDIFF * diff); // XdmfExodusReader %ignore XdmfExodusReaderNew(); %ignore XdmfExodusReaderRead(XDMFEXODUSREADER * reader, char * fileName, XDMFHEAVYDATAWRITER * heavyDataWriter); %ignore XdmfExodusReaderFree(XDMFEXODUSREADER * reader); // XdmfExodusWriter %ignore XdmfExodusWriterNew(); %ignore XdmfExodusWriterWriteGrid(XDMFEXODUSWRITER * writer, char * filePath, XDMFUNSTRUCTUREDGRID * grid, int * status); %ignore XdmfExodusWriterWriteGridCollection(XDMFEXODUSWRITER * writer, char * filePath, XDMFGRIDCOLLECTION * grid, int * status); %ignore XdmfExodusWriterFree(XDMFEXODUSWRITER * writer); // XdmfGeometryConverter %ignore XdmfGeometryConverterNew(); %ignore XdmfGeometryConverterConvertToCartesian(XDMFGEOMETRYCONVERTER * converter, XDMFGEOMETRY * geometryToConvert); %ignore XdmfGeometryConverterConvertToSpherical(XDMFGEOMETRYCONVERTER * converter, XDMFGEOMETRY * geometryToConvert); %ignore XdmfGeometryConverterConvertToCartesianOverwrite(XDMFGEOMETRYCONVERTER * converter, XDMFGEOMETRY * geometryToConvert); %ignore XdmfGeometryConverterConvertToSphericalOverwrite(XDMFGEOMETRYCONVERTER * converter, XDMFGEOMETRY * geometryToConvert); %ignore XdmfGeometryConverterZeroOrigin(XDMFGEOMETRYCONVERTER * converter, XDMFGEOMETRY * geometryToConvert); %ignore XdmfGeometryConverterZeroOriginOverwrite(XDMFGEOMETRYCONVERTER * converter, XDMFGEOMETRY * geometryToConvert); %ignore XdmfGeometryConverterFree(XDMFGEOMETRYCONVERTER * converter); // XdmfPartitioner %ignore XdmfPartitionerNew(); %ignore XdmfPartitionerIgnore(XDMFPARTITIONER * partitioner, XDMFSET * set); %ignore XdmfPartitionerPartitionGraph(XDMFPARTITIONER * partitioner, XDMFGRAPH * graphToPartition, unsigned int numberOfPartitions); %ignore XdmfPartitionerPartitionUnstructuredGrid(XDMFPARTITIONER * partitioner, XDMFUNSTRUCTUREDGRID * gridToPartition, unsigned int numberOfPartitions, int metisScheme, XDMFHEAVYDATAWRITER * heavyDataWriter); %ignore XdmfPartitionerUnpartition(XDMFPARTITIONER * partitioner, XDMFGRIDCOLLECTION * gridToUnPartition); %ignore XdmfPartitionerFree(XDMFPARTITIONER * partitioner); // XdmfTopologyConverter %ignore XdmfTopologyConverterNew(); %ignore XdmfTopologyConverterConvert(XDMFTOPOLOGYCONVERTER * converter, XDMFUNSTRUCTUREDGRID * gridToConvert, int topologytype, XDMFHEAVYDATAWRITER * heavyDataWriter); %ignore XdmfTopologyConverterGetExternalFaces(XDMFTOPOLOGYCONVERTER * converter, XDMFTOPOLOGY * convertedTopology); %ignore XdmfTopologyConverterFree(XDMFTOPOLOGYCONVERTER * converter); #ifdef SWIGPYTHON %pythoncode { from Xdmf import * } #endif /* SWIGPYTHON */ // Shared Pointer Templates %shared_ptr(XdmfDiff) #ifdef XDMF_BUILD_EXODUS_IO %shared_ptr(XdmfExodusReader) %shared_ptr(XdmfExodusWriter) #endif #ifdef XDMF_BUILD_PARTITIONER %shared_ptr(XdmfPartitioner) #endif %shared_ptr(XdmfGeometryConverter) %shared_ptr(XdmfTopologyConverter) %include XdmfUtils.hpp %include XdmfDiff.hpp #ifdef XDMF_BUILD_EXODUS_IO %include XdmfExodusReader.hpp %include XdmfExodusWriter.hpp #endif #ifdef XDMF_BUILD_PARTITIONER %include XdmfPartitioner.hpp #endif %include XdmfGeometryConverter.hpp %include XdmfTopologyConverter.hpp xdmf-3.0+git20160803/utils/XdmfExodusWriter.cpp0000640000175000017500000007322513003006557021232 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfExodusWriter.cpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #include #include #include #include #include "XdmfArrayType.hpp" #include "XdmfAttribute.hpp" #include "XdmfAttributeCenter.hpp" #include "XdmfExodusWriter.hpp" #include "XdmfGeometry.hpp" #include "XdmfGeometryType.hpp" #include "XdmfGridCollection.hpp" #include "XdmfGridCollectionType.hpp" #include "XdmfPartitioner.hpp" #include "XdmfSet.hpp" #include "XdmfSetType.hpp" #include "XdmfTopology.hpp" #include "XdmfTopologyType.hpp" #include "XdmfUnstructuredGrid.hpp" #include "XdmfError.hpp" #include // // local methods // namespace { /** * Constructs attribute names for ExodusII files since exodus cannot * store vectors. Also handles the exodus MAX_STR_LENGTH limitation. * * @param attributeName the attribute name in Xdmf. * @param names a vector of names to add the constructed attribute names to. * @param numComponents the number of components in the attribute * (e.g. for an xyz vector this is 3) */ void constructAttributeNames(std::string attributeName, std::vector & names, const int numComponents) { if(numComponents == 1) { if(attributeName.length() > MAX_STR_LENGTH) { attributeName = attributeName.substr(0, MAX_STR_LENGTH); } names.push_back(attributeName); } else if(numComponents > 1) { int numComponentDigits = int(numComponents / 10); if(attributeName.length() + numComponentDigits > MAX_STR_LENGTH) { attributeName = attributeName.substr(0, MAX_STR_LENGTH - numComponentDigits); } for(int i=0; i topologyType) { if(topologyType == XdmfTopologyType::Polyvertex()) { return "SUP"; } else if(topologyType == XdmfTopologyType::Triangle() || topologyType == XdmfTopologyType::Triangle_6()) { return "TRIANGLE"; } else if(topologyType == XdmfTopologyType::Quadrilateral() || topologyType == XdmfTopologyType::Quadrilateral_8() || topologyType == XdmfTopologyType::Quadrilateral_9()) { return "QUAD"; } else if(topologyType == XdmfTopologyType::Tetrahedron() || topologyType == XdmfTopologyType::Tetrahedron_10()) { return "TETRA"; } else if(topologyType == XdmfTopologyType::Pyramid() || topologyType == XdmfTopologyType::Pyramid_13()) { return "PYRAMID"; } else if(topologyType == XdmfTopologyType::Wedge() || topologyType == XdmfTopologyType::Wedge_15() || topologyType == XdmfTopologyType::Wedge_18()) { return "WEDGE"; } else if(topologyType == XdmfTopologyType::Hexahedron() || topologyType == XdmfTopologyType::Hexahedron_20() || topologyType == XdmfTopologyType::Hexahedron_24() || topologyType == XdmfTopologyType::Hexahedron_27()) { return "HEX"; } else if(topologyType == XdmfTopologyType::Edge_3()) { return "EDGE"; } XdmfError::message(XdmfError::FATAL, "Topology type not supported by ExodusII"); return ""; } /** * Pull general information from grid in order to initialize exodus * file. */ void getGridInformation(const shared_ptr grid, int & num_dim, int & num_nodes, int & num_elem, int & num_elem_blk, std::vector & elem_blk_ids, std::vector & elem_type, std::vector & num_elem_this_blk, std::vector & num_nodes_per_elem, std::vector & num_attr, int & num_node_sets, std::vector > & blocks) { // get topology const shared_ptr topology = grid->getTopology(); const shared_ptr topologyType = topology->getType(); const int numberElements = topology->getNumberElements(); const int nodesPerElement = topologyType->getNodesPerElement(); // get geometry const shared_ptr geometry = grid->getGeometry(); const shared_ptr geometryType = geometry->getType(); const int numberNodes = geometry->getNumberPoints(); num_dim = geometryType->getDimensions(); num_nodes = numberNodes; num_elem = numberElements; std::cout << num_dim << std::endl; // get exodus topology type const std::string exodusTopologyType = xdmfToExodusTopologyType(topologyType); // search for blocks in file int elementBlockId = 10; for(unsigned int i=0; igetNumberSets(); ++i) { shared_ptr set = grid->getSet(i); if(set->getType() == XdmfSetType::Cell()) { if(set->getName().find("Block") == 0) { ++num_elem_blk; blocks.push_back(set); elem_blk_ids.push_back(elementBlockId++); char * cellTypeCStr = new char[exodusTopologyType.size() + 1]; strcpy(cellTypeCStr, exodusTopologyType.c_str()); elem_type.push_back(cellTypeCStr); num_elem_this_blk.push_back(set->getSize()); num_nodes_per_elem.push_back(nodesPerElement); num_attr.push_back(0); } } else if(set->getType() == XdmfSetType::Node()) { ++num_node_sets; } } // adjust for case where there are no blocks found in the xdmf file if(blocks.size() == 0) { num_elem_blk = 1; elem_blk_ids.push_back(elementBlockId); elem_blk_ids.push_back(elementBlockId++); char * cellTypeCStr = new char[exodusTopologyType.size() + 1]; strcpy(cellTypeCStr, exodusTopologyType.c_str()); elem_type.push_back(cellTypeCStr); num_elem_this_blk.push_back(numberElements); num_nodes_per_elem.push_back(nodesPerElement); num_attr.push_back(0); } } /** * Convert between Xdmf and Exodus topology numberings */ void convertXdmfToExodusTopology(int * elem_connectivity, const shared_ptr topType, int num_elem) { if(topType == XdmfTopologyType::Hexahedron_20() || topType == XdmfTopologyType::Hexahedron_27()) { int * ptr = elem_connectivity; int itmp[4]; for(int i=0; i grid) { const unsigned int numberSets = grid->getNumberSets(); const int setId = 20; std::vector values; for(unsigned int i=0; i set = grid->getSet(i); if(set->getType() == XdmfSetType::Node()) { bool releaseSet = false; if(!set->isInitialized()) { set->read(); releaseSet = true; } std::string name = set->getName(); if(name.size() > MAX_STR_LENGTH) { name = name.substr(0, MAX_STR_LENGTH); } const unsigned int setSize = set->getSize(); values.resize(setSize); for(unsigned int k=0; kgetValue(k) + 1; } /* if(set->getType() == XdmfSetType::Cell()) { ex_put_side_set_param(exodusHandle, setId + i, setSize, 0); ex_put_side_set(exodusHandle, setId + i, &(values[0]), NULL); ex_put_name(exodusHandle, EX_SIDE_SET, setId + i, name.c_str()); } */ ex_put_node_set_param(exodusHandle, setId + i, setSize, 0); ex_put_node_set(exodusHandle, setId + i, &(values[0])); ex_put_name(exodusHandle, EX_NODE_SET, setId + i, name.c_str()); if(releaseSet) { set->release(); } } } } } shared_ptr XdmfExodusWriter::New() { shared_ptr p(new XdmfExodusWriter()); return p; } XdmfExodusWriter::XdmfExodusWriter() { } XdmfExodusWriter::~XdmfExodusWriter() { } void XdmfExodusWriter::write(const std::string & filePath, const shared_ptr gridToWrite) const { // add this grid to a simple grid collection and write shared_ptr collection = XdmfGridCollection::New(); collection->setName(gridToWrite->getName()); collection->setType(XdmfGridCollectionType::Temporal()); collection->insert(gridToWrite); return write(filePath, collection); } void XdmfExodusWriter::write(const std::string & filePath, const shared_ptr grid) const { int error; ex_opts(EX_VERBOSE); // open exodus file int wordSize = 8; int storeSize = 8; int exodusHandle = ex_create(filePath.c_str(), EX_CLOBBER, &wordSize, &storeSize); // initialize exodus file std::string title = grid->getName(); if(title.size() > MAX_STR_LENGTH) { title = title.substr(0, MAX_STR_LENGTH); } // determine type of collections present bool isSpatial = false; bool isTemporal = false; shared_ptr gridCollection = grid; if(grid->getType() == XdmfGridCollectionType::Temporal()) { isTemporal = true; if(grid->getNumberGridCollections() != 0) { gridCollection = grid->getGridCollection(0); if(gridCollection->getType() == XdmfGridCollectionType::Spatial()) { isSpatial = true; } } } else if(grid->getType() == XdmfGridCollectionType::Spatial()) { isSpatial = true; } int num_dim = 0; int num_nodes = 0; int num_elem = 0; int num_elem_blk = 0; int num_node_sets = 0; int num_side_sets = 0; std::vector elem_blk_ids; std::vector elem_type; std::vector num_elem_this_blk; std::vector num_nodes_per_elem; std::vector num_attr; std::vector > globalNodeIds; // initialize file shared_ptr unstructuredGrid; if(isSpatial) { // unpartition grid as exodus does not store partitioning information shared_ptr partitioner = XdmfPartitioner::New(); unstructuredGrid = partitioner->unpartition(gridCollection); } else { // get first unstructured grid from temporal collection unstructuredGrid = gridCollection->getUnstructuredGrid(0); } std::vector > blocks; getGridInformation(unstructuredGrid, num_dim, num_nodes, num_elem, num_elem_blk, elem_blk_ids, elem_type, num_elem_this_blk, num_nodes_per_elem, num_attr, num_node_sets, blocks); /* std::cout << "num_dim: " << num_dim << std::endl; std::cout << "num_nodes: " << num_nodes << std::endl; std::cout << "num_elem: " << num_elem << std::endl; std::cout << "num_elem_blk: " << num_elem_blk << std::endl; std::cout << "num_node_sets: " << num_node_sets << std::endl; std::cout << "num_side_sets: " << num_side_sets << std::endl; */ error = ex_put_init(exodusHandle, title.c_str(), num_dim, num_nodes, num_elem, num_elem_blk, num_node_sets, num_side_sets); if(error != 0) { XdmfError::message(XdmfError::FATAL, "Error initializing exodus file."); } const int define_maps = 0; error = ex_put_concat_elem_block(exodusHandle, &(elem_blk_ids[0]), &(elem_type[0]), &(num_elem_this_blk[0]), &(num_nodes_per_elem[0]), &(num_attr[0]), define_maps); if(error != 0) { XdmfError::message(XdmfError::FATAL, "Error initializing element blocks in exodus file"); return; } for(int i=0; i geometry = unstructuredGrid->getGeometry(); bool releaseGeometry = false; if(!geometry->isInitialized()) { geometry->read(); releaseGeometry = true; } // read nodal positions geometry->getValues(0, x, num_nodes, num_dim); geometry->getValues(1, y, num_nodes, num_dim); if(num_dim == 3) { geometry->getValues(2, z, num_nodes, num_dim); } // release data if(releaseGeometry) { geometry->release(); } error = ex_put_coord(exodusHandle, x ,y ,z); delete [] x; delete [] y; delete [] z; /* std::cout << "End Geometry" << std::endl; */ // write topology shared_ptr topology = unstructuredGrid->getTopology(); shared_ptr topologyType = topology->getType(); const int nodesPerElement = topologyType->getNodesPerElement(); bool releaseTopology = false; if(!topology->isInitialized()) { topology->read(); releaseTopology = true; } if(blocks.size() > 0) { // if blocks, write topology to blocks for(unsigned int i=0; i & set = blocks[i]; bool releaseSet = false; if(!set->isInitialized()) { set->read(); releaseSet = true; } const unsigned int connectivitySize = set->getSize() * nodesPerElement; int * elem_connectivity = new int[connectivitySize]; int offset = 0; for(unsigned int j=0; jgetSize(); ++j) { const int elementId = set->getValue(j); const int topologyOffset = elementId * nodesPerElement; for(int k=0; kgetValue(topologyOffset + k) + 1; ++offset; } } if(releaseSet) { set->release(); } convertXdmfToExodusTopology(elem_connectivity, topologyType, num_elem); ex_put_elem_conn(exodusHandle, elem_blk_ids[i], elem_connectivity); delete [] elem_connectivity; } } else { // write to single block const unsigned int connectivitySize = topology->getSize(); int * elem_connectivity = new int[connectivitySize]; for(unsigned int i=0; igetValue(i) + 1; } if(releaseTopology) { topology->release(); } convertXdmfToExodusTopology(elem_connectivity, topologyType, num_elem); ex_put_elem_conn(exodusHandle, elem_blk_ids[0], elem_connectivity); delete [] elem_connectivity; } if(releaseTopology) { topology->release(); } /* std::cout << "End Topology" << std::endl; */ // write attributes int numGlobalAttributes = 0; int numNodalAttributes = 0; int numElementAttributes = 0; std::vector globalComponents; std::vector nodalComponents; std::vector elementComponents; std::vector globalAttributeNames; std::vector nodalAttributeNames; std::vector elementAttributeNames; const unsigned int numberAttributes = unstructuredGrid->getNumberAttributes(); for(unsigned int i=0; i attribute = unstructuredGrid->getAttribute(i); const unsigned int numberElements = unstructuredGrid->getTopology()->getNumberElements(); const unsigned int numberPoints = unstructuredGrid->getGeometry()->getNumberPoints(); const shared_ptr attributeCenter = attribute->getCenter(); if(attributeCenter == XdmfAttributeCenter::Grid()) { const int numComponents = attribute->getSize(); globalComponents.push_back(numComponents); numGlobalAttributes += numComponents; constructAttributeNames(attribute->getName(), globalAttributeNames, numComponents); } else if(attributeCenter == XdmfAttributeCenter::Node()) { const int numComponents = attribute->getSize() / numberPoints; nodalComponents.push_back(numComponents); numNodalAttributes += numComponents; constructAttributeNames(attribute->getName(), nodalAttributeNames, numComponents); } else if(attributeCenter == XdmfAttributeCenter::Cell()) { const int numComponents = attribute->getSize() / numberElements; elementComponents.push_back(numComponents); numElementAttributes += numComponents; constructAttributeNames(attribute->getName(), elementAttributeNames, numComponents); } } if(numGlobalAttributes > 0) { ex_put_var_param(exodusHandle, "g", numGlobalAttributes); } if(numNodalAttributes > 0) { ex_put_var_param(exodusHandle, "n", numNodalAttributes); } if(numElementAttributes > 0) { ex_put_var_param(exodusHandle, "e", numElementAttributes); } /* std::cout << "Done attribute params" << std::endl; */ char ** globalNames = new char*[numGlobalAttributes]; char ** nodalNames = new char*[numNodalAttributes]; char ** elementNames = new char*[numElementAttributes]; for(int i=0; i 0) { ex_put_var_names(exodusHandle, "g", numGlobalAttributes, globalNames); } if(numNodalAttributes > 0) { ex_put_var_names(exodusHandle, "n", numNodalAttributes, nodalNames); } if(numElementAttributes > 0) { ex_put_var_names(exodusHandle, "e", numElementAttributes, elementNames); } delete [] globalNames; delete [] nodalNames; delete [] elementNames; /* std::cout << "Done attribute names" << std::endl; */ if(numElementAttributes > 0) { const int numTruthTableValues = num_elem_blk * numElementAttributes; int * truthTable = new int[numTruthTableValues]; for(int i=0; igetNumberUnstructuredGrids() == 0) { numTemporalGrids = grid->getNumberGridCollections(); } else { numTemporalGrids = grid->getNumberUnstructuredGrids(); } } // only write for first timestep writeSets(exodusHandle, unstructuredGrid); /* std::cout << "Done Sets" << std::endl; */ for(unsigned int i=0; igetGridCollection(i); shared_ptr partitioner = XdmfPartitioner::New(); unstructuredGrid = partitioner->unpartition(gridCollection); } } else { unstructuredGrid = grid->getUnstructuredGrid(i); } } double * globalAttributeVals = new double[numGlobalAttributes]; unsigned int globalIndex = 0; unsigned int globalComponentIndex = 0; unsigned int nodalIndex = 0; unsigned int nodalComponentIndex = 0; unsigned int elementIndex = 0; unsigned int elementComponentIndex = 0; std::vector elementArray; for(unsigned int j=0; j attribute = unstructuredGrid->getAttribute(j); shared_ptr attributeCenter = attribute->getCenter(); /* std::cout << attribute->getName() << std::endl; */ bool releaseAttribute = false; if(!attribute->isInitialized()) { attribute->read(); releaseAttribute = true; } if(attribute->getCenter() == XdmfAttributeCenter::Grid()) { for(unsigned int k=0; kgetValues(k, globalAttributeVals + globalIndex, 1); globalIndex++; } globalComponentIndex++; } else if(attribute->getCenter() == XdmfAttributeCenter::Node()) { for(unsigned int k=0; kgetValues(k, nodalValues, num_nodes, nodalComponents[nodalComponentIndex]); ex_put_nodal_var(exodusHandle, i+1, nodalIndex+1, num_nodes, nodalValues); ex_update(exodusHandle); delete [] nodalValues; nodalIndex++; } nodalComponentIndex++; } else if(attribute->getCenter() == XdmfAttributeCenter::Cell()) { if(blocks.size() > 0) { for(unsigned int k=0; k & set = blocks[k]; const int num_elem_in_blk = set->getSize(); bool releaseSet = false; if(!set->isInitialized()) { set->read(); releaseSet = true; } double * elementValues = new double[num_elem_in_blk]; // loop over components const int numberComponents = elementComponents[elementComponentIndex]; for(int l=0; lgetValue(m); elementValues[m] = attribute->getValue(numberComponents*elementId + l); } ex_put_elem_var(exodusHandle, i+1, elementIndex+l+1, elem_blk_ids[k], num_elem_in_blk, elementValues); ex_update(exodusHandle); } delete [] elementValues; if(releaseSet) { set->release(); } } elementIndex += elementComponents[elementComponentIndex]; elementComponentIndex++; } else { for(unsigned int k=0; kgetValues(k, elementValues, num_elem, elementComponents[elementComponentIndex]); ex_put_elem_var(exodusHandle, i+1, elementIndex+1, elem_blk_ids[0], num_elem, elementValues); ex_update(exodusHandle); delete [] elementValues; elementIndex++; } elementComponentIndex++; } } if(releaseAttribute) { attribute->release(); } } if(numGlobalAttributes > 0) { ex_put_glob_vars(exodusHandle, i+1, numGlobalAttributes, globalAttributeVals); } ex_update(exodusHandle); delete [] globalAttributeVals; } /* std::cout << "Done Attributes" << std::endl; */ // close exodus file ex_close(exodusHandle); } // C Wrappers XDMFEXODUSWRITER * XdmfExodusWriterNew() { shared_ptr generatedWriter = XdmfExodusWriter::New(); return (XDMFEXODUSWRITER *)((void *)(new XdmfExodusWriter(*generatedWriter.get()))); } void XdmfExodusWriterWriteGrid(XDMFEXODUSWRITER * writer, char * filePath, XDMFUNSTRUCTUREDGRID * grid, int * status) { XDMF_ERROR_WRAP_START(status) shared_ptr tempGrid = shared_ptr((XdmfUnstructuredGrid *)grid, XdmfNullDeleter()); ((XdmfExodusWriter *)writer)->write(std::string(filePath), tempGrid); XDMF_ERROR_WRAP_END(status) } void XdmfExodusWriterWriteGridCollection(XDMFEXODUSWRITER * writer, char * filePath, XDMFGRIDCOLLECTION * grid, int * status) { XDMF_ERROR_WRAP_START(status) shared_ptr tempGrid = shared_ptr((XdmfGridCollection *)grid, XdmfNullDeleter()); ((XdmfExodusWriter *)writer)->write(std::string(filePath), tempGrid); XDMF_ERROR_WRAP_END(status) } void XdmfExodusWriterFree(XDMFEXODUSWRITER * writer) { if (writer != NULL) { delete ((XdmfExodusWriter *)writer); writer = NULL; } } xdmf-3.0+git20160803/utils/XdmfExodusConverter.cpp0000640000175000017500000001124513003006557021717 0ustar alastairalastair#include #include #include #include #include "XdmfDomain.hpp" #include "XdmfError.hpp" #include "XdmfExodusReader.hpp" #include "XdmfExodusWriter.hpp" #include "XdmfGridCollection.hpp" #include "XdmfHDF5Writer.hpp" #include "XdmfReader.hpp" #include "XdmfWriter.hpp" namespace { // // print usage // inline void printUsage(const char * programName) { std::cerr << "usage: " << programName << " " << " [output file]" << std::endl; // // // return; } // // process command line // void processCommandLine(std::string & inputFileName, std::string & outputFileName, int ac, char * av[]) { int c; bool errorFlag = false; while( (c=getopt(ac, av, "")) != -1 ) switch(c){ case '?': errorFlag = true; break; } if (optind >= ac) errorFlag = true; else { inputFileName = av[optind]; ++optind; } if (optind < ac) { outputFileName = av[optind]; ++optind; } // // check errorFlag // if (errorFlag == true) { printUsage(av[0]); std::exit(EXIT_FAILURE); } } } /** * XdmfExodusConverter is a command line utility for converting * between Xdmf and Exodus files. If given an Xdmf file, the tool * converts the file to Exodus and if given a path to an Exodus file, * the tool converts the file to Xdmf. * * Usage: * XdmfExodusConverter * (Optional: ) * */ int main(int argc, char* argv[]) { std::string inputFileName = ""; std::string outputFileName = ""; processCommandLine(inputFileName, outputFileName, argc, argv); FILE * refFile = fopen(inputFileName.c_str(), "r"); if (refFile) { // Success fclose(refFile); } else { std::cout << "Cannot open file: " << argv[1] << std::endl; return 1; } std::string meshName; if(outputFileName.compare("") == 0) { meshName = inputFileName; } else { meshName = outputFileName; } if(meshName.find_last_of("/\\") != std::string::npos) { meshName = meshName.substr(meshName.find_last_of("/\\") + 1, meshName.length()); } if (meshName.rfind(".") != std::string::npos) { meshName = meshName.substr(0, meshName.rfind(".")); } int CPU_word_size = sizeof(double); int IO_word_size = 0; // Get from file float version; const int exodusHandle = ex_open(argv[1], EX_READ, &CPU_word_size, &IO_word_size, &version); if(exodusHandle < 0) { // Xdmf to Exodus shared_ptr reader = XdmfReader::New(); shared_ptr domain = shared_dynamic_cast(reader->read(inputFileName)); std::stringstream exodusFileName; exodusFileName << meshName << ".exo"; shared_ptr writer = XdmfExodusWriter::New(); if(domain->getNumberUnstructuredGrids() == 1) { const shared_ptr grid = domain->getUnstructuredGrid(0); writer->write(exodusFileName.str(), grid); std::cout << "Wrote: " << exodusFileName.str() << std::endl; } else if(domain->getNumberGridCollections() == 1) { const shared_ptr grid = domain->getGridCollection(0); writer->write(exodusFileName.str(), grid); std::cout << "Wrote: " << exodusFileName.str() << std::endl; } else { XdmfError::message(XdmfError::FATAL, "Cannot find grid in Xdmf file to convert to " "exodus."); } } else { // Exodus to Xdmf std::stringstream heavyFileName; heavyFileName << meshName << ".h5"; shared_ptr heavyDataWriter = XdmfHDF5Writer::New(heavyFileName.str()); heavyDataWriter->setReleaseData(true); shared_ptr exodusReader = XdmfExodusReader::New(); shared_ptr readGrid = exodusReader->read(inputFileName, heavyDataWriter); shared_ptr newDomain = XdmfDomain::New(); newDomain->insert(readGrid); std::stringstream xmlFileName; xmlFileName << meshName << ".xmf"; shared_ptr writer = XdmfWriter::New(xmlFileName.str(), heavyDataWriter); newDomain->accept(writer); std::cout << "Wrote: " << xmlFileName.str() << std::endl; } } xdmf-3.0+git20160803/utils/XdmfExodusReader.cpp0000640000175000017500000005660413003006557021162 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfExodusReader.cpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #include #include #include "XdmfArrayType.hpp" #include "XdmfAttribute.hpp" #include "XdmfAttributeCenter.hpp" #include "XdmfAttributeType.hpp" #include "XdmfExodusReader.hpp" #include "XdmfGeometry.hpp" #include "XdmfGeometryType.hpp" #include "XdmfHeavyDataWriter.hpp" #include "XdmfSet.hpp" #include "XdmfSetType.hpp" #include "XdmfTopology.hpp" #include "XdmfTopologyType.hpp" #include "XdmfUnstructuredGrid.hpp" #include "XdmfError.hpp" // // local methods // namespace { /** * Convert exodus topology type to xdmf topology type. * * @param exodusTopologyType a string containing the name of the exodus * topology type. * @param pointsPerCell the number of points per cell for the exodus * topology type. * * @return the equivalent XdmfTopologyType. If no equivalent is found, * XdmfTopologyType::NoTopologyType() is returned. */ shared_ptr exodusToXdmfTopologyType(std::string exodusTopologyType, const int pointsPerCell) { // Convert exodusTopologyType to uppercase std::transform(exodusTopologyType.begin(), exodusTopologyType.end(), exodusTopologyType.begin(), toupper); // First check for quadratic elements then look for linear elements if (exodusTopologyType.substr(0,3).compare("TRI") == 0 && pointsPerCell == 6) { return XdmfTopologyType::Triangle_6(); } else if (exodusTopologyType.substr(0,3).compare("SHE") == 0 && pointsPerCell == 8) { return XdmfTopologyType::Quadrilateral_8(); } else if (exodusTopologyType.substr(0,3).compare("SHE") == 0 && pointsPerCell == 9) { return XdmfTopologyType::Quadrilateral_9(); } else if (exodusTopologyType.substr(0,3).compare("TET") == 0 && pointsPerCell == 10) { return XdmfTopologyType::Tetrahedron_10(); } else if (exodusTopologyType.substr(0,3).compare("TET") == 0 && pointsPerCell == 11) { // VTK_QUADRATIC_TETRA with 11 points // Currently unsupported in Xdmf return XdmfTopologyType::NoTopologyType(); } else if (exodusTopologyType.substr(0,3).compare("WED") == 0 && pointsPerCell == 15) { return XdmfTopologyType::Wedge_15(); } else if (exodusTopologyType.substr(0,3).compare("WED") == 0 && pointsPerCell == 18) { return XdmfTopologyType::Wedge_18(); } else if (exodusTopologyType.substr(0,3).compare("HEX") == 0 && pointsPerCell == 20) { return XdmfTopologyType::Hexahedron_20(); } else if (exodusTopologyType.substr(0,3).compare("HEX") == 0 && pointsPerCell == 21) { // VTK_QUADRATIC_HEXAHEDRON with 21 points // Currently unsupported in Xdmf return XdmfTopologyType::NoTopologyType(); } else if (exodusTopologyType.substr(0,3).compare("HEX") == 0 && pointsPerCell == 27) { return XdmfTopologyType::Hexahedron_27(); } else if (exodusTopologyType.substr(0,3).compare("QUA") == 0 && pointsPerCell == 8) { return XdmfTopologyType::Quadrilateral_8(); } else if (exodusTopologyType.substr(0,3).compare("QUA") == 0 && pointsPerCell == 9) { return XdmfTopologyType::Quadrilateral_9(); } else if (exodusTopologyType.substr(0,3).compare("TRU") == 0 && pointsPerCell == 3) { return XdmfTopologyType::Edge_3(); } else if (exodusTopologyType.substr(0,3).compare("BEA") == 0 && pointsPerCell == 3) { return XdmfTopologyType::Edge_3(); } else if (exodusTopologyType.substr(0,3).compare("BAR") == 0 && pointsPerCell == 3) { return XdmfTopologyType::Edge_3(); } else if (exodusTopologyType.substr(0,3).compare("EDG") == 0 && pointsPerCell == 3) { return XdmfTopologyType::Edge_3(); } else if (exodusTopologyType.substr(0,3).compare("CIR") == 0) { // VTK_VERTEX; // Currently unsupported in Xdmf return XdmfTopologyType::NoTopologyType(); } else if (exodusTopologyType.substr(0,3).compare("SPH") == 0) { // VTK_VERTEX; // Currently unsupported in Xdmf return XdmfTopologyType::NoTopologyType(); } else if (exodusTopologyType.substr(0,3).compare("BAR") == 0) { // VTK_LINE; // Currently unsupported in Xdmf return XdmfTopologyType::NoTopologyType(); } else if (exodusTopologyType.substr(0,3).compare("TRU") == 0) { // VTK_LINE; // Currently unsupported in Xdmf return XdmfTopologyType::NoTopologyType(); } else if (exodusTopologyType.substr(0,3).compare("BEA") == 0) { // VTK_LINE; // Currently unsupported in Xdmf return XdmfTopologyType::NoTopologyType(); } else if (exodusTopologyType.substr(0,3).compare("EDG") == 0) { // VTK_LINE; // Currently unsupported in Xdmf return XdmfTopologyType::NoTopologyType(); } else if (exodusTopologyType.substr(0,3).compare("TRI") == 0) { return XdmfTopologyType::Triangle(); } else if (exodusTopologyType.substr(0,3).compare("QUA") == 0) { return XdmfTopologyType::Quadrilateral(); } else if (exodusTopologyType.substr(0,3).compare("TET") == 0) { return XdmfTopologyType::Tetrahedron(); } else if (exodusTopologyType.substr(0,3).compare("PYR") == 0) { return XdmfTopologyType::Pyramid(); } else if (exodusTopologyType.substr(0,3).compare("WED") == 0) { return XdmfTopologyType::Wedge(); } else if (exodusTopologyType.substr(0,3).compare("HEX") == 0) { return XdmfTopologyType::Hexahedron(); } else if (exodusTopologyType.substr(0,3).compare("SHE") == 0 && pointsPerCell == 3) { return XdmfTopologyType::Triangle(); } else if (exodusTopologyType.substr(0,3).compare("SHE") == 0 && pointsPerCell == 4) { return XdmfTopologyType::Quadrilateral(); } else if (exodusTopologyType.substr(0,8).compare("STRAIGHT") == 0 && pointsPerCell == 2) { // VTK_LINE; // Currently unsupported in Xdmf return XdmfTopologyType::NoTopologyType(); } else if (exodusTopologyType.substr(0,3).compare("SUP") == 0) { return XdmfTopologyType::Polyvertex(); } return XdmfTopologyType::NoTopologyType(); } } shared_ptr XdmfExodusReader::New() { shared_ptr p(new XdmfExodusReader()); return p; } XdmfExodusReader::XdmfExodusReader() { } XdmfExodusReader::~XdmfExodusReader() { } shared_ptr XdmfExodusReader::read(const std::string & fileName, const shared_ptr heavyDataWriter) const { if(heavyDataWriter) { heavyDataWriter->openFile(); } shared_ptr toReturn = XdmfUnstructuredGrid::New(); // Read Exodus II file to XdmfGridUnstructured via Exodus II API float version; int CPU_word_size = sizeof(double); int IO_word_size = 0; // Get from file int exodusHandle = ex_open(fileName.c_str(), EX_READ, &CPU_word_size, &IO_word_size, &version); if(exodusHandle < 0) { // Invalid fileName XdmfError::message(XdmfError::FATAL, "Invalid fileName: " + fileName + " in XdmfExodusReader::read"); } char * title = new char[MAX_LINE_LENGTH+1]; int num_dim, num_nodes, num_elem, num_elem_blk, num_node_sets, num_side_sets; ex_get_init (exodusHandle, title, &num_dim, &num_nodes, &num_elem, &num_elem_blk, &num_node_sets, &num_side_sets); toReturn->setName(title); delete [] title; /* cout << "Title: " << title << "\nNum Dim: " << num_dim << "\nNum Nodes: " << num_nodes << "\nNum Elem: " << num_elem << "\nNum Elem Blk: " << num_elem_blk << "\nNum Node Sets: " << num_node_sets << "\nNum Side Sets: " << num_side_sets << endl; */ // Read geometry values double * x = new double[num_nodes]; double * y = new double[num_nodes]; double * z = new double[num_nodes]; ex_get_coord(exodusHandle, x, y, z); // In the future we may want to do XDMF_GEOMETRY_X_Y_Z? if(num_dim == 3) { toReturn->getGeometry()->setType(XdmfGeometryType::XYZ()); } else if(num_dim == 2) { toReturn->getGeometry()->setType(XdmfGeometryType::XY()); } else { // Xdmf does not support geometries with less than 2 dimensions std::ostringstream oss; oss << "Xdmf does not support geometries with less than 2 dimensions -- num_dim: " << num_dim << "-- in XdmfExodusReader::read"; XdmfError::message(XdmfError::FATAL, oss.str()); } toReturn->getGeometry()->initialize(XdmfArrayType::Float64()); toReturn->getGeometry()->reserve(num_nodes * num_dim); for(int i=0; igetGeometry()->pushBack(x[i]); toReturn->getGeometry()->pushBack(y[i]); if(num_dim == 3) { toReturn->getGeometry()->pushBack(z[i]); } } delete [] x; delete [] y; delete [] z; if(heavyDataWriter) { toReturn->getGeometry()->accept(heavyDataWriter); toReturn->getGeometry()->release(); } int * blockIds = new int[num_elem_blk]; ex_get_elem_blk_ids(exodusHandle, blockIds); int * numElemsInBlock = new int[num_elem_blk]; int * numNodesPerElemInBlock = new int[num_elem_blk]; int * numElemAttrInBlock = new int[num_elem_blk]; std::vector > topologyTypes; topologyTypes.reserve(num_elem_blk); int totalNumElem = 0; int totalConns = 0; for(int i=0; i topologyType = exodusToXdmfTopologyType(elem_type, num_nodes_per_elem); topologyTypes.push_back(topologyType); totalNumElem += num_elem_this_blk; totalConns += num_elem_this_blk * num_nodes_per_elem; delete [] elem_type; } if(topologyTypes.size() > 0) { toReturn->getTopology()->setType(topologyTypes[0]); if(topologyTypes.size() > 1) { for(std::vector >::const_iterator iter = topologyTypes.begin() + 1; iter != topologyTypes.end(); ++iter) { // Cannot be mixed topology! if(toReturn->getTopology()->getType() != *iter) { XdmfError::message(XdmfError::FATAL, "Requested mix of topology types -- "+ toReturn->getTopology()->getType()->getName() + " and " + (*iter)->getName() + " in XdmfExodusReader::read"); } } } } topologyTypes.clear(); toReturn->getTopology()->initialize(XdmfArrayType::Int32(), totalConns); int * connectivityPointer = (int *)toReturn->getTopology()->getValuesInternal(); // Read connectivity from element blocks int elemIndex = 0; for(int i=0; igetTopology()->getType() == XdmfTopologyType::Hexahedron_20() || toReturn->getTopology()->getType() == XdmfTopologyType::Hexahedron_27()) { int * ptr = connectivityPointer; int itmp[4]; // Exodus Node ordering does not match Xdmf, we must convert. for(int i=0; igetTopology()->getType() == XdmfTopologyType::Hexahedron_27()) { for(unsigned int j=0; j<4; ++j, ++ptr) { itmp[j] = *ptr; *ptr = ptr[3]; } *(ptr++) = itmp[1]; *(ptr++) = itmp[2]; *(ptr++) = itmp[0]; } } } else if(toReturn->getTopology()->getType() == XdmfTopologyType::Wedge_15() || toReturn->getTopology()->getType() == XdmfTopologyType::Wedge_18()) { int * ptr = connectivityPointer; int itmp[3]; // Exodus Node ordering does not match Xdmf, we must convert. for (int i=0; igetTopology()->getType() == XdmfTopologyType::Wedge_18()) { itmp[0] = *(ptr); itmp[1] = *(ptr+1); itmp[2] = *(ptr+2); *(ptr++) = itmp[1]; *(ptr++) = itmp[2]; *(ptr++) = itmp[0]; } } } // Subtract all node ids by 1 since exodus indices start at 1 for(int i=0; igetTopology()->accept(heavyDataWriter); toReturn->getTopology()->release(); } shared_ptr globalIds = XdmfAttribute::New(); globalIds->setName("GlobalNodeId"); globalIds->setCenter(XdmfAttributeCenter::Node()); globalIds->setType(XdmfAttributeType::GlobalId()); globalIds->initialize(XdmfArrayType::Int32(), num_nodes); int * globalIdsPointer = (int*)globalIds->getValuesInternal(); ex_get_node_num_map(exodusHandle, globalIdsPointer); // Subtract all node ids by 1 since exodus indices start at 1 for(int i=0; iinsert(globalIds); if(heavyDataWriter) { globalIds->accept(heavyDataWriter); globalIds->release(); } // Read node sets int * nodeSetIds = new int[num_node_sets]; ex_get_node_set_ids(exodusHandle, nodeSetIds); char * node_set_names[num_node_sets]; for (int i=0; i 0) { shared_ptr set = XdmfSet::New(); set->setName(node_set_names[i]); set->setType(XdmfSetType::Node()); set->initialize(XdmfArrayType::Int32(), num_nodes_in_set); int * setPointer = (int*)set->getValuesInternal(); ex_get_node_set(exodusHandle, nodeSetIds[i], setPointer); // Subtract all node ids by 1 since exodus indices start at 1 for(int j=0; jinsert(set); if(heavyDataWriter) { set->accept(heavyDataWriter); set->release(); } } delete [] node_set_names[i]; } delete [] nodeSetIds; // Read result variables (attributes) int num_global_vars, num_nodal_vars, num_elem_vars; ex_get_var_param(exodusHandle, "g", &num_global_vars); ex_get_var_param(exodusHandle, "n", &num_nodal_vars); ex_get_var_param(exodusHandle, "e", &num_elem_vars); /* cout << "Num Global Vars: " << num_global_vars << "\nNum Nodal Vars: " << num_nodal_vars << "\nNum Elem Vars: " << num_elem_vars << endl; */ char * global_var_names[num_global_vars]; char * nodal_var_names[num_nodal_vars]; char * elem_var_names[num_elem_vars]; for (int j=0; j attribute = XdmfAttribute::New(); attribute->setName(global_var_names[i]); attribute->setCenter(XdmfAttributeCenter::Grid()); attribute->setType(XdmfAttributeType::Scalar()); attribute->initialize(XdmfArrayType::Float64()); attribute->pushBack(global_var_vals[i]); toReturn->insert(attribute); if(heavyDataWriter) { attribute->accept(heavyDataWriter); attribute->release(); } delete [] global_var_names[i]; } delete [] global_var_vals; // Nodal variable data for (int i=0; i attribute = XdmfAttribute::New(); attribute->setName(nodal_var_names[i]); attribute->setCenter(XdmfAttributeCenter::Node()); attribute->setType(XdmfAttributeType::Scalar()); attribute->initialize(XdmfArrayType::Float64(), num_nodes); ex_get_nodal_var(exodusHandle, 1, i+1, num_nodes, (double*)attribute->getValuesInternal()); toReturn->insert(attribute); if(heavyDataWriter) { attribute->accept(heavyDataWriter); attribute->release(); } delete [] nodal_var_names[i]; } } // Element variable data for (int i=0; i attribute = XdmfAttribute::New(); attribute->setName(elem_var_names[i]); attribute->setCenter(XdmfAttributeCenter::Cell()); attribute->setType(XdmfAttributeType::Scalar()); attribute->initialize(XdmfArrayType::Float64(), totalNumElem); elemIndex = 0; for (int j=0; jgetValuesInternal() + elemIndex); elemIndex += numElemsInBlock[j]; } toReturn->insert(attribute); if(heavyDataWriter) { attribute->accept(heavyDataWriter); attribute->release(); } delete [] elem_var_names[i]; } ex_close(exodusHandle); // add block information as sets unsigned int elementId = 0; for(int i=0; i set = XdmfSet::New(); std::stringstream setName; setName << "Block " << i; set->setName(setName.str()); set->setType(XdmfSetType::Cell()); set->initialize(XdmfArrayType::Int32(), numberElementsInBlock); for(int j=0; jinsert(j, elementId++); } toReturn->insert(set); if(heavyDataWriter) { set->accept(heavyDataWriter); set->release(); } } delete [] blockIds; delete [] numElemsInBlock; delete [] numNodesPerElemInBlock; delete [] numElemAttrInBlock; if(heavyDataWriter) { heavyDataWriter->closeFile(); } return toReturn; } // C Wrappers XDMFEXODUSREADER * XdmfExodusReaderNew() { shared_ptr generatedReader = XdmfExodusReader::New(); return (XDMFEXODUSREADER *)((void *)(new XdmfExodusReader(*generatedReader.get()))); } XDMFUNSTRUCTUREDGRID * XdmfExodusReaderRead(XDMFEXODUSREADER * reader, char * fileName, XDMFHEAVYDATAWRITER * heavyDataWriter) { shared_ptr tempWriter = shared_ptr((XdmfHeavyDataWriter *)heavyDataWriter, XdmfNullDeleter()); return (XDMFUNSTRUCTUREDGRID)((void *)(new XdmfUnstructuredGrid(*((((XdmfExodusReader *)reader)->read(fileName, tempWriter)).get())))); } void XdmfExodusReaderFree(XDMFEXODUSREADER * reader) { if (reader != NULL) { delete ((XdmfExodusReader *)reader); reader = NULL; } } xdmf-3.0+git20160803/utils/XdmfTopologyConverter.hpp0000640000175000017500000001513213003006557022270 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfTopologyConverter.hpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef XDMFTOPOLOGYCONVERTER_HPP_ #define XDMFTOPOLOGYCONVERTER_HPP_ // C Compatible Includes #include "XdmfUtils.hpp" #include "XdmfUnstructuredGrid.hpp" #include "XdmfHeavyDataWriter.hpp" #ifdef __cplusplus // Forward Declarations //class XdmfHeavyDataWriter; class XdmfTopologyType; //class XdmfUnstructuredGrid; // Includes #include "XdmfSharedPtr.hpp" /** * @brief Converts an unstructured grid to different topology types. * * Attributes and sets attached to the grid are adjusted to remain * valid for the new topology type. * * When converting from a lower order topology to a higher order * topology type (e.g. Hexahedron to Hexahedron_64) additional points * are added to the mesh, no additional elements are added. When * converting from a higher order topology to a lower order topology * type (e.h. Hexahedron_64 to Hexahedron) elements are tesselated to * form the new topology, no additional points are added. * * Currently supported conversions: * Hexahedron to Hexahedron_27 * Hexahedron to Hexahedron_64 * Hexahedron to Hexahedron_125 * Hexahedron to Hexahedron_216 * Hexahedron to Hexahedron_343 * Hexahedron to Hexahedron_512 * Hexahedron to Hexahedron_729 * Hexahedron to Hexahedron_1000 * Hexahedron to Hexahedron_1331 * Hexahedron to Hexahedron_Spectral_64 * Hexahedron to Hexahedron_Spectral_125 * Hexahedron to Hexahedron_Spectral_216 * Hexahedron to Hexahedron_Spectral_343 * Hexahedron to Hexahedron_Spectral_512 * Hexahedron to Hexahedron_Spectral_729 * Hexahedron to Hexahedron_Spectral_1000 * Hexahedron to Hexahedron_Spectral_1331 * Hexahedron_64 to Hexahedron * Hexahedron_125 to Hexahedron * Hexahedron_216 to Hexahedron * Hexahedron_343 to Hexahedron * Hexahedron_512 to Hexahedron * Hexahedron_729 to Hexahedron * Hexahedron_1000 to Hexahedron * Hexahedron_1331 to Hexahedron * Hexahedron_Spectral_64 to Hexahedron * Hexahedron_Spectral_125 to Hexahedron * Hexahedron_Spectral_216 to Hexahedron * Hexahedron_Spectral_343 to Hexahedron * Hexahedron_Spectral_512 to Hexahedron * Hexahedron_Spectral_729 to Hexahedron * Hexahedron_Spectral_1000 to Hexahedron * Hexahedron_Spectral_1331 to Hexahedron */ class XDMFUTILS_EXPORT XdmfTopologyConverter { public: /** * Create a new XdmfTopologyConverter. * * @return constructed XdmfTopologyConverter. */ static shared_ptr New(); virtual ~XdmfTopologyConverter(); /** * Converts an unstructured grid to a different topology type * * @param gridToConvert the unstructured grid to convert to a different * topology * @param topologyType the topology type to convert to. * @param heavyDataWriter an heavy data writer to write the converted mesh * to. If no heavyDataWriter is specified, all mesh data will remain in * memory. * * @return the converted unstructured grid. */ shared_ptr convert(const shared_ptr gridToConvert, const shared_ptr topologyType, const shared_ptr heavyDataWriter = shared_ptr()) const; /** * Gets all faces within the given topology. Removing duplicates. * * @param convertedTopology The topology to be deconstructed * @return A topology containing the faces from the deconstructed topology */ shared_ptr getExternalFaces(const shared_ptr convertedTopology); XdmfTopologyConverter(const XdmfTopologyConverter &); protected: XdmfTopologyConverter(); private: void insertInHash(std::vector nodes, std::vector > > & hash, unsigned int numCornerNodes); void operator=(const XdmfTopologyConverter &); // Not implemented. }; #endif #ifdef __cplusplus extern "C" { #endif // C wrappers go here struct XDMFTOPOLOGYCONVERTER; // Simply as a typedef to ensure correct typing typedef struct XDMFTOPOLOGYCONVERTER XDMFTOPOLOGYCONVERTER; XDMFUTILS_EXPORT XDMFTOPOLOGYCONVERTER * XdmfTopologyConverterNew(); XDMFUTILS_EXPORT XDMFUNSTRUCTUREDGRID * XdmfTopologyConverterConvert(XDMFTOPOLOGYCONVERTER * converter, XDMFUNSTRUCTUREDGRID * gridToConvert, int topologytype, XDMFHEAVYDATAWRITER * heavyDataWriter); XDMFUTILS_EXPORT XDMFTOPOLOGY * XdmfTopologyConverterGetExternalFaces(XDMFTOPOLOGYCONVERTER * converter, XDMFTOPOLOGY * convertedTopology); XDMFUTILS_EXPORT void XdmfTopologyConverterFree(XDMFTOPOLOGYCONVERTER * converter); #ifdef __cplusplus } #endif #endif /* XDMFTOPOLOGYCONVERTER_HPP_ */ xdmf-3.0+git20160803/utils/XdmfDiff.cpp0000640000175000017500000002414313003006557017431 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfDiff.cpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #include #include #include #include "XdmfArray.hpp" #include "XdmfArrayType.hpp" #include "XdmfDiff.hpp" #include "XdmfError.hpp" #include "XdmfVisitor.hpp" // // local methods // namespace { /** * @brief Internal class that traverses all items in xdmf hierarchy and * adds them to mItems. */ class XdmfDiffVisitor : public XdmfVisitor { public: static shared_ptr New() { shared_ptr p(new XdmfDiffVisitor()); return p; }; ~XdmfDiffVisitor() { }; void visit(XdmfItem & item, const shared_ptr visitor) { mItems.push_back(&item); item.traverse(visitor); } std::vector mItems; protected: XdmfDiffVisitor() { } }; template void diffArrays(XdmfArray * array1, XdmfArray * array2, const double absoluteTolerance, bool & returnValue) { bool releaseArray1 = false; if(!array1->isInitialized()) { array1->read(); releaseArray1 = true; } bool releaseArray2 = false; if(!array2->isInitialized()) { array2->read(); releaseArray2 = true; } const unsigned int size = array1->getSize(); for(unsigned int i=0; igetValue(i); const T array2Value = array2->getValue(i); const T difference = static_cast(array1Value > array2Value ? array1Value-array2Value : array2Value-array1Value); if(difference > absoluteTolerance) { std::cout << "At Index " << i << " | Expected: " << array1Value << " | Got: " << array2Value << std::endl; returnValue = false; } } if(releaseArray1) { array1->release(); } if(releaseArray2) { array2->release(); } } } shared_ptr XdmfDiff::New() { shared_ptr p(new XdmfDiff()); return p; } XdmfDiff::XdmfDiff() : mAbsoluteTolerance(0.0) { } XdmfDiff::XdmfDiff(const XdmfDiff &diffRef) : mAbsoluteTolerance(diffRef.mAbsoluteTolerance) { } XdmfDiff::~XdmfDiff() { } bool XdmfDiff::compare(const shared_ptr item1, const shared_ptr item2) const { bool returnValue = true; shared_ptr diffVisitor1 = XdmfDiffVisitor::New(); shared_ptr diffVisitor2 = XdmfDiffVisitor::New(); item1->accept(diffVisitor1); item2->accept(diffVisitor2); assert(diffVisitor1->mItems.size() == diffVisitor2->mItems.size()); for(std::vector::size_type i=0; imItems.size(); ++i) { XdmfItem * item1 = diffVisitor1->mItems[i]; XdmfItem * item2 = diffVisitor2->mItems[i]; // compare item tags const std::string itemTag1 = item1->getItemTag(); const std::string itemTag2 = item2->getItemTag(); if(itemTag1.compare(itemTag2) != 0) { std::cout << "Error: Expected " << itemTag1 << " and got " << itemTag2 << ". The files are not structured the same" << std::endl; return false; } // compare item properties const std::map itemProperties1 = item1->getItemProperties(); const std::map itemProperties2 = item2->getItemProperties(); assert(itemProperties1.size() == itemProperties2.size()); for(std::map::const_iterator iter1 = itemProperties1.begin(); iter1 != itemProperties1.end(); ++iter1) { const std::string & key = iter1->first; const std::map::const_iterator iter2 = itemProperties2.find(key); if(iter2 == itemProperties2.end()) { std::cout << "Error: Expected " << key << " and did not find corresponding key " << "files are not structured the same" << std::endl; assert(false); } const std::string & value1 = iter1->second; const std::string & value2 = iter2->second; if(value1.compare(value2) != 0) { std::cout << "Error: For: " << itemTag1 << " | Key: " << key << "Expected: " << value1 << " | Got: " << value2 << std::endl; returnValue = false; } } // compare array values XdmfArray * array1 = dynamic_cast(item1); if(array1) { XdmfArray * array2 = dynamic_cast(item2); if(array1->getSize() != array2->getSize()) { std::cout << "Error: For: " << itemTag1 << " Different number of values stored. Expected: " << array1->getSize() << " | Got: " << array2->getSize() << std::endl; returnValue = false; } const shared_ptr arrayType = array1->getArrayType(); if(arrayType != array2->getArrayType()) { std::cout << "Error: For: " << itemTag1 << " Different type of values stored. Expected: " << arrayType->getName() << " | Got: " << array2->getArrayType()->getName() << std::endl; returnValue = false; } if(arrayType == XdmfArrayType::Int8()) { diffArrays(array1, array2, mAbsoluteTolerance, returnValue); } else if(arrayType == XdmfArrayType::Int16()) { diffArrays(array1, array2, mAbsoluteTolerance, returnValue); } else if(arrayType == XdmfArrayType::Int32()) { diffArrays(array1, array2, mAbsoluteTolerance, returnValue); } else if(arrayType == XdmfArrayType::Int64()) { diffArrays(array1, array2, mAbsoluteTolerance, returnValue); } else if(arrayType == XdmfArrayType::UInt8()) { diffArrays(array1, array2, mAbsoluteTolerance, returnValue); } else if(arrayType == XdmfArrayType::UInt16()) { diffArrays(array1, array2, mAbsoluteTolerance, returnValue); } else if(arrayType == XdmfArrayType::UInt32()) { diffArrays(array1, array2, mAbsoluteTolerance, returnValue); } else if(arrayType == XdmfArrayType::Float32()) { diffArrays(array1, array2, mAbsoluteTolerance, returnValue); } else if(arrayType == XdmfArrayType::Float64()) { std::cout << std::setprecision(15); diffArrays(array1, array2, mAbsoluteTolerance, returnValue); } else { XdmfError::message(XdmfError::FATAL, "Error: Array Types match, but type is not supported."); } } } return returnValue; } double XdmfDiff::getAbsoluteTolerance() const { return mAbsoluteTolerance; } void XdmfDiff::setAbsoluteTolerance(const double absoluteTolerance) { mAbsoluteTolerance = absoluteTolerance; } // C Wrappers XDMFDIFF * XdmfDiffNew() { shared_ptr generatedDiff = XdmfDiff::New(); return (XDMFDIFF *)((void *)(new XdmfDiff(*generatedDiff.get()))); } int XdmfDiffCompare(XDMFDIFF * diff, XDMFITEM * item1, XDMFITEM * item2) { shared_ptr tempItem1 = shared_ptr((XdmfItem *)item1, XdmfNullDeleter()); shared_ptr tempItem2 = shared_ptr((XdmfItem *)item2, XdmfNullDeleter()); return ((XdmfDiff *)diff)->compare(tempItem1, tempItem2); } double XdmfDiffGetAbsoluteTolerance(XDMFDIFF * diff) { return ((XdmfDiff *)diff)->getAbsoluteTolerance(); } void XdmfDiffSetAbsoluteTolerance(XDMFDIFF * diff, double tolerance) { ((XdmfDiff *)diff)->setAbsoluteTolerance(tolerance); } void XdmfDiffFree(XDMFDIFF * diff) { if (diff != NULL) { delete ((XdmfDiff *)diff); diff = NULL; } } xdmf-3.0+git20160803/utils/XdmfExodusWriter.hpp0000640000175000017500000001002113003006557021220 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfExodusWriter.hpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef XDMFEXODUSWRITER_HPP_ #define XDMFEXODUSWRITER_HPP_ #ifdef __cplusplus // Forward Declarations class XdmfGridCollection; class XdmfUnstructuredGrid; // Includes #include #include "XdmfUtils.hpp" #include "XdmfSharedPtr.hpp" /** * @brief Writes an Xdmf structure in memory to an ExodusII file on * disk. */ class XDMFUTILS_EXPORT XdmfExodusWriter { public: /** * Create a new XdmfExodusReader. * * @return constructed XdmfExodusReader. */ static shared_ptr New(); virtual ~XdmfExodusWriter(); /** * Write an XdmfUnstructuredGrid to an ExodusII file. * * @param filePath of the ExodusII file to write. * @param grid an XdmfUnstructuredGrid to write to ExodusII file * format. */ void write(const std::string & filePath, const shared_ptr grid) const; /** * Write an XdmfGridCollection to an ExodusII file. * * @param filePath of the ExodusII file to write. * @param grid an XdmfGridCollection to write to ExodusII file * format. */ void write(const std::string & filePath, const shared_ptr grid) const; protected: XdmfExodusWriter(); private: XdmfExodusWriter(const XdmfExodusWriter &); // Not implemented. void operator=(const XdmfExodusWriter &); // Not implemented. }; #endif #ifdef __cplusplus extern "C" { #endif // C wrappers go here struct XDMFEXODUSWRITER; // Simply as a typedef to ensure correct typing typedef struct XDMFEXODUSWRITER XDMFEXODUSWRITER; XDMFUTILS_EXPORT XDMFEXODUSWRITER * XdmfExodusWriterNew(); XDMFUTILS_EXPORT void XdmfExodusWriterWriteGrid(XDMFEXODUSWRITER * writer, char * filePath, XDMFUNSTRUCTUREDGRID * grid, int * status); XDMFUTILS_EXPORT void XdmfExodusWriterWriteGridCollection(XDMFEXODUSWRITER * writer, char * filePath, XDMFGRIDCOLLECTION * grid, int * status); XDMFUTILS_EXPORT void XdmfExodusWriterFree(XDMFEXODUSWRITER * writer); #ifdef __cplusplus } #endif #endif /* XDMFEXODUSWRITER_HPP_ */ xdmf-3.0+git20160803/utils/Xdmf.f0000640000175000017500000002160013003006557016276 0ustar alastairalastair! Function Return Types integer xdmfaddattribute integer xdmfaddinformation integer xdmfsetgeometry integer xdmfsettopology integer xdmfsetdimensions integer xdmfsetorigin integer xdmfsetbrick integer xdmfstoremap integer xdmfaddcoordinate integer xdmfaddset integer xdmfgetmaxopenedfiles integer xdmfaddfunctionasattribute integer xdmfsetfunctionasgeometry integer xdmfsetfunctionastopology integer xdmfaddfunctionascoordinate integer xdmfaddfunctionasset integer xdmfaddsubsetasattribute integer xdmfsetsubsetasgeometry integer xdmfsetsubsetastopology integer xdmfaddsubsetascoordinate integer xdmfaddsubsetasset ! Array Type integer XDMF_ARRAY_TYPE_INT8 integer XDMF_ARRAY_TYPE_INT16 integer XDMF_ARRAY_TYPE_INT32 integer XDMF_ARRAY_TYPE_INT64 integer XDMF_ARRAY_TYPE_UINT8 integer XDMF_ARRAY_TYPE_UINT16 integer XDMF_ARRAY_TYPE_UINT32 integer XDMF_ARRAY_TYPE_FLOAT32 integer XDMF_ARRAY_TYPE_FLOAT64 ! Attribute Center integer XDMF_ATTRIBUTE_CENTER_GRID integer XDMF_ATTRIBUTE_CENTER_CELL integer XDMF_ATTRIBUTE_CENTER_FACE integer XDMF_ATTRIBUTE_CENTER_EDGE integer XDMF_ATTRIBUTE_CENTER_NODE ! Attribute Type integer XDMF_ATTRIBUTE_TYPE_SCALAR integer XDMF_ATTRIBUTE_TYPE_VECTOR integer XDMF_ATTRIBUTE_TYPE_TENSOR integer XDMF_ATTRIBUTE_TYPE_MATRIX integer XDMF_ATTRIBUTE_TYPE_TENSOR6 integer XDMF_ATTRIBUTE_TYPE_GLOBALID integer XDMF_ATTRIBUTE_TYPE_NOTYPE ! Geometry Type integer XDMF_GEOMETRY_TYPE_XYZ integer XDMF_GEOMETRY_TYPE_XY integer XDMF_GEOMETRY_TYPE_POLAR integer XDMF_GEOMETRY_TYPE_SPHERICAL ! Grid Collection Type integer XDMF_GRID_COLLECTION_TYPE_SPATIAL integer XDMF_GRID_COLLECTION_TYPE_TEMPORAL ! Topology Type integer XDMF_TOPOLOGY_TYPE_POLYVERTEX integer XDMF_TOPOLOGY_TYPE_POLYLINE integer XDMF_TOPOLOGY_TYPE_POLYGON integer XDMF_TOPOLOGY_TYPE_POLYHEDRON integer XDMF_TOPOLOGY_TYPE_TRIANGLE integer XDMF_TOPOLOGY_TYPE_QUADRILATERAL integer XDMF_TOPOLOGY_TYPE_TETRAHEDRON integer XDMF_TOPOLOGY_TYPE_PYRAMID integer XDMF_TOPOLOGY_TYPE_WEDGE integer XDMF_TOPOLOGY_TYPE_HEXAHEDRON integer XDMF_TOPOLOGY_TYPE_EDGE_3 integer XDMF_TOPOLOGY_TYPE_TRIANGLE_6 integer XDMF_TOPOLOGY_TYPE_QUADRILATERAL_8 integer XDMF_TOPOLOGY_TYPE_QUADRILATERAL_9 integer XDMF_TOPOLOGY_TYPE_TETRAHEDRON_10 integer XDMF_TOPOLOGY_TYPE_PYRAMID_13 integer XDMF_TOPOLOGY_TYPE_WEDGE_15 integer XDMF_TOPOLOGY_TYPE_WEDGE_18 integer XDMF_TOPOLOGY_TYPE_HEXAHEDRON_20 integer XDMF_TOPOLOGY_TYPE_HEXAHEDRON_24 integer XDMF_TOPOLOGY_TYPE_HEXAHEDRON_27 integer XDMF_TOPOLOGY_TYPE_HEXAHEDRON_64 integer XDMF_TOPOLOGY_TYPE_HEXAHEDRON_125 integer XDMF_TOPOLOGY_TYPE_HEXAHEDRON_216 integer XDMF_TOPOLOGY_TYPE_HEXAHEDRON_343 integer XDMF_TOPOLOGY_TYPE_HEXAHEDRON_512 integer XDMF_TOPOLOGY_TYPE_HEXAHEDRON_729 integer XDMF_TOPOLOGY_TYPE_HEXAHEDRON_1000 integer XDMF_TOPOLOGY_TYPE_HEXAHEDRON_1331 integer XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_64 integer XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_125 integer XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_216 integer XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_343 integer XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_512 integer XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_729 integer XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_1000 integer XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_1331 integer XDMF_TOPOLOGY_TYPE_MIXED ! Set Type integer XDMF_SET_TYPE_NODE integer XDMF_SET_TYPE_CELL integer XDMF_SET_TYPE_FACE integer XDMF_SET_TYPE_EDGE ! Grid Type integer XDMF_GRID_TYPE_CURVILINEAR integer XDMF_GRID_TYPE_RECTILINEAR integer XDMF_GRID_TYPE_REGULAR integer XDMF_GRID_TYPE_UNSTRUCTURED ! Binary Endian integer XDMF_BINARY_ENDIAN_NATIVE integer XDMF_BINARY_ENDIAN_LITTLE integer XDMF_BINARY_ENDIAN_BIG !------------------------------------------------------ parameter (XDMF_ARRAY_TYPE_INT8 = 0) parameter (XDMF_ARRAY_TYPE_INT16 = 1) parameter (XDMF_ARRAY_TYPE_INT32 = 2) parameter (XDMF_ARRAY_TYPE_INT64 = 3) parameter (XDMF_ARRAY_TYPE_UINT8 = 4) parameter (XDMF_ARRAY_TYPE_UINT16 = 5) parameter (XDMF_ARRAY_TYPE_UINT32 = 6) parameter (XDMF_ARRAY_TYPE_FLOAT32 = 7) parameter (XDMF_ARRAY_TYPE_FLOAT64 = 8) parameter (XDMF_ATTRIBUTE_CENTER_GRID = 100) parameter (XDMF_ATTRIBUTE_CENTER_CELL = 101) parameter (XDMF_ATTRIBUTE_CENTER_FACE = 102) parameter (XDMF_ATTRIBUTE_CENTER_EDGE = 103) parameter (XDMF_ATTRIBUTE_CENTER_NODE = 104) parameter (XDMF_ATTRIBUTE_TYPE_SCALAR = 200) parameter (XDMF_ATTRIBUTE_TYPE_VECTOR = 201) parameter (XDMF_ATTRIBUTE_TYPE_TENSOR = 202) parameter (XDMF_ATTRIBUTE_TYPE_MATRIX = 203) parameter (XDMF_ATTRIBUTE_TYPE_TENSOR6 = 204) parameter (XDMF_ATTRIBUTE_TYPE_GLOBALID = 205) parameter (XDMF_ATTRIBUTE_TYPE_NOTYPE = 206) parameter (XDMF_GEOMETRY_TYPE_XYZ = 301) parameter (XDMF_GEOMETRY_TYPE_XY = 302) parameter (XDMF_GEOMETRY_TYPE_POLAR = 303) parameter (XDMF_GEOMETRY_TYPE_SPHERICAL = 304) parameter (XDMF_GRID_COLLECTION_TYPE_SPATIAL = 400) parameter (XDMF_GRID_COLLECTION_TYPE_TEMPORAL = 401) parameter (XDMF_TOPOLOGY_TYPE_POLYVERTEX = 500) parameter (XDMF_TOPOLOGY_TYPE_POLYLINE = 501) parameter (XDMF_TOPOLOGY_TYPE_POLYGON = 502) parameter (XDMF_TOPOLOGY_TYPE_POLYHEDRON = 503) parameter (XDMF_TOPOLOGY_TYPE_TRIANGLE = 504) parameter (XDMF_TOPOLOGY_TYPE_QUADRILATERAL = 505) parameter (XDMF_TOPOLOGY_TYPE_TETRAHEDRON = 506) parameter (XDMF_TOPOLOGY_TYPE_PYRAMID = 507) parameter (XDMF_TOPOLOGY_TYPE_WEDGE = 508) parameter (XDMF_TOPOLOGY_TYPE_HEXAHEDRON = 509) parameter (XDMF_TOPOLOGY_TYPE_EDGE_3 = 510) parameter (XDMF_TOPOLOGY_TYPE_TRIANGLE_6 = 511) parameter (XDMF_TOPOLOGY_TYPE_QUADRILATERAL_8 = 512) parameter (XDMF_TOPOLOGY_TYPE_QUADRILATERAL_9 = 513) parameter (XDMF_TOPOLOGY_TYPE_TETRAHEDRON_10 = 514) parameter (XDMF_TOPOLOGY_TYPE_PYRAMID_13 = 515) parameter (XDMF_TOPOLOGY_TYPE_WEDGE_15 = 516) parameter (XDMF_TOPOLOGY_TYPE_WEDGE_18 = 517) parameter (XDMF_TOPOLOGY_TYPE_HEXAHEDRON_20 = 518) parameter (XDMF_TOPOLOGY_TYPE_HEXAHEDRON_24 = 519) parameter (XDMF_TOPOLOGY_TYPE_HEXAHEDRON_27 = 520) parameter (XDMF_TOPOLOGY_TYPE_HEXAHEDRON_64 = 521) parameter (XDMF_TOPOLOGY_TYPE_HEXAHEDRON_125 = 522) parameter (XDMF_TOPOLOGY_TYPE_HEXAHEDRON_216 = 523) parameter (XDMF_TOPOLOGY_TYPE_HEXAHEDRON_343 = 524) parameter (XDMF_TOPOLOGY_TYPE_HEXAHEDRON_512 = 525) parameter (XDMF_TOPOLOGY_TYPE_HEXAHEDRON_729 = 526) parameter (XDMF_TOPOLOGY_TYPE_HEXAHEDRON_1000 = 527) parameter (XDMF_TOPOLOGY_TYPE_HEXAHEDRON_1331 = 528) parameter (XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_64 = 529) parameter (XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_125 = 530) parameter (XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_216 = 531) parameter (XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_343 = 532) parameter (XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_512 = 533) parameter (XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_729 = 534) parameter (XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_1000 = 535) parameter (XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_1331 = 536) parameter (XDMF_TOPOLOGY_TYPE_MIXED = 537) parameter (XDMF_SET_TYPE_NODE = 601) parameter (XDMF_SET_TYPE_CELL = 602) parameter (XDMF_SET_TYPE_FACE = 603) parameter (XDMF_SET_TYPE_EDGE = 604) parameter (XDMF_GRID_TYPE_CURVILINEAR = 701) parameter (XDMF_GRID_TYPE_RECTILINEAR = 702) parameter (XDMF_GRID_TYPE_REGULAR = 703) parameter (XDMF_GRID_TYPE_UNSTRUCTURED = 704) parameter (XDMF_BINARY_ENDIAN_NATIVE = 801) parameter (XDMF_BINARY_ENDIAN_LITTLE = 802) parameter (XDMF_BINARY_ENDIAN_BIG = 803) xdmf-3.0+git20160803/utils/XdmfGeometryConverter.hpp0000640000175000017500000001354513003006557022255 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfGeometryConverter.hpp */ /* */ /* Author: */ /* Andrew Burns */ /* andrew.j.burns2@us.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2014 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef XDMFGEOMETRYCONVERTER_HPP_ #define XDMFGEOMETRYCONVERTER_HPP_ // C Compatible Includes #include "XdmfUtils.hpp" #include "XdmfGeometry.hpp" #ifdef __cplusplus // Forward Declarations //class XdmfGeometry; // Includes #include "XdmfSharedPtr.hpp" /** * @brief Converts an geometry to a different coordinate system. * * Converts between the Cartesian and Spherical coordinate systems. * Maintains number of dimensions, datatype converted to double * precision floating point (XdmfArrayType::Float64()). * * The cmath library is used for the conversions so angles * are treated as radians. */ class XDMFUTILS_EXPORT XdmfGeometryConverter { public: /** * Create a new XdmfGeometryConverter. * * @return constructed XdmfGeometryConverter. */ static shared_ptr New(); virtual ~XdmfGeometryConverter(); /** * Converts the provided geometry to Cartesian coordinates. * * @param geometryToConvert The geometry to be converted * to Cartesian coordinates. * * @return The geometry equivalent for * the Cartesian Coordinate system. */ shared_ptr convertToCartesian(const shared_ptr & geometryToConvert) const; /** * Converts the provided geometry to spherical coordinates. * * @param geometryToConvert The geometry to be converted * to spherical coordinates. * * @return The geometry equivalent for * the Spherical Coordinate system. */ shared_ptr convertToSpherical(const shared_ptr & geometryToConvert) const; /** * Converts the provided geometry to Cartesian coordinates. This version * overwrites the data in the geometry provided instead of returning a new one. * * @param geometryToConvert The geometry to be converted * to Cartesian coordinates. */ void convertToCartesianOverwrite(shared_ptr & geometryToConvert) const; /** * Converts the provided geometry to spherical coordinates. This version * overwrites the data in the geometry provided instead of returning a new one. * * @param geometryToConvert The geometry to be converted * to spherical coordinates. */ void convertToSphericalOverwrite(shared_ptr & geometryToConvert) const; shared_ptr zeroOrigin(const shared_ptr & geometryToConvert); void zeroOriginOverwrite(shared_ptr & geometryToConvert); XdmfGeometryConverter(const XdmfGeometryConverter &); protected: XdmfGeometryConverter(); private: void operator=(const XdmfGeometryConverter &); // Not implemented. }; #endif #ifdef __cplusplus extern "C" { #endif // C wrappers go here struct XDMFGEOMETRYCONVERTER; // Simply as a typedef to ensure correct typing typedef struct XDMFGEOMETRYCONVERTER XDMFGEOMETRYCONVERTER; XDMFUTILS_EXPORT XDMFGEOMETRYCONVERTER * XdmfGeometryConverterNew(); XDMFUTILS_EXPORT XDMFGEOMETRY * XdmfGeometryConverterConvertToCartesian(XDMFGEOMETRYCONVERTER * converter, XDMFGEOMETRY * geometryToConvert); XDMFUTILS_EXPORT XDMFGEOMETRY * XdmfGeometryConverterConvertToSpherical(XDMFGEOMETRYCONVERTER * converter, XDMFGEOMETRY * geometryToConvert); XDMFUTILS_EXPORT void XdmfGeometryConverterConvertToCartesianOverwrite(XDMFGEOMETRYCONVERTER * converter, XDMFGEOMETRY * geometryToConvert); XDMFUTILS_EXPORT void XdmfGeometryConverterConvertToSphericalOverwrite(XDMFGEOMETRYCONVERTER * converter, XDMFGEOMETRY * geometryToConvert); XDMFUTILS_EXPORT XDMFGEOMETRY * XdmfGeometryConverterZeroOrigin(XDMFGEOMETRYCONVERTER * converter, XDMFGEOMETRY * geometryToConvert); XDMFUTILS_EXPORT void XdmfGeometryConverterZeroOriginOverwrite(XDMFGEOMETRYCONVERTER * converter, XDMFGEOMETRY * geometryToConvert); XDMFUTILS_EXPORT void XdmfGeometryConverterFree(XDMFGEOMETRYCONVERTER * converter); #ifdef __cplusplus } #endif #endif /* XDMFTOPOLOGYCONVERTER_HPP_ */ xdmf-3.0+git20160803/utils/XdmfDiff.hpp0000640000175000017500000000725413003006557017442 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfDiff.hpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef XDMFDIFF_HPP_ #define XDMFDIFF_HPP_ // C Compatible Includes #include "XdmfUtils.hpp" #ifdef __cplusplus // Forward Declarations class XdmfItem; // Includes #include #include "XdmfUtils.hpp" #include "XdmfSharedPtr.hpp" /** * @brief Compare differences between data stored in two Xdmf * structures. */ class XDMFUTILS_EXPORT XdmfDiff { public: /** * Create a new XdmfDiff. * * @return constructed XdmfDiff. */ static shared_ptr New(); virtual ~XdmfDiff(); /** * Compare the contents of two Xdmf structures. * * @param item1 an Xdmf structure to compare. * @param item2 an Xdmf structure to compare. * * @return true if the Xdmf structures are equivalent. */ bool compare(const shared_ptr item1, const shared_ptr item2) const; /** * Get the absolute tolerance used for comparing values between Xdmf * structures. * * @return double the absolute tolerance. */ double getAbsoluteTolerance() const; /** * Set the absolute tolerance for comparing values between Xdmf * structures. * * @param absoluteTolerance the absolute tolerance to set. */ void setAbsoluteTolerance(const double absoluteTolerance); XdmfDiff(const XdmfDiff &); protected: XdmfDiff(); private: void operator=(const XdmfDiff &); // Not implemented. double mAbsoluteTolerance; }; #endif #ifdef __cplusplus extern "C" { #endif // C wrappers go here struct XDMFDIFF; // Simply as a typedef to ensure correct typing typedef struct XDMFDIFF XDMFDIFF; XDMFUTILS_EXPORT XDMFDIFF * XdmfDiffNew(); XDMFUTILS_EXPORT int XdmfDiffCompare(XDMFDIFF * diff, XDMFITEM * item1, XDMFITEM * item2); XDMFUTILS_EXPORT double XdmfDiffGetAbsoluteTolerance(XDMFDIFF * diff); XDMFUTILS_EXPORT void XdmfDiffSetAbsoluteTolerance(XDMFDIFF * diff, double tolerance); XDMFUTILS_EXPORT void XdmfDiffFree(XDMFDIFF * diff); #ifdef __cplusplus } #endif #endif /* XDMFDIFF_HPP_ */ xdmf-3.0+git20160803/utils/tests/0000740000175000017500000000000013003006557016372 5ustar alastairalastairxdmf-3.0+git20160803/utils/tests/Fortran/0000740000175000017500000000000013003006557020005 5ustar alastairalastairxdmf-3.0+git20160803/utils/tests/Fortran/AcceptDSMFortran.f900000640000175000017500000000265013003006557023431 0ustar alastairalastair!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! !! AUTHOR: Andrew Burns (andrew.j.burns2@us.army.mil) !! !! A test of the XdmfDSM capabilities using the fortran interface. !! This part of the program sets up the server to be used by the DSM. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! PROGRAM XdmfFortranExample Implicit none INCLUDE 'Xdmf.f' INCLUDE 'mpif.h' INTEGER*8 obj character*256 filename INTEGER id, commsize, buffersize INTEGER intraID, intraSize INTEGER ierr INTEGER interComm filename = 'nested_output.xmf'//CHAR(0) if (buffersize < 1) then buffersize = 1 endif CALL MPI_INIT (ierr) CALL XDMFINIT(obj, filename) CALL MPI_COMM_RANK(MPI_COMM_WORLD, id, ierr) CALL MPI_COMM_SIZE(MPI_COMM_WORLD, commsize, ierr) buffersize = 16/commsize !! Cores 1 to size-1 are blocked by the initialization of the server. !! When the server finishes they are released and allowed to progress. CALL XDMFINITDSMSERVER(obj, "dsm"//CHAR(0), MPI_COMM_WORLD, bufferSize, 1, commsize-1) if (id == 0) then CALL XDMFACCEPTDSM(obj, 2) endif CALL XDMFGETDSMINTERCOMM(obj, interComm) !! Wait for other processes to finish before closing CALL MPI_BARRIER(interComm, ierr) if (id == 0) then CALL XDMFCLOSEDSMPORT(obj) endif CALL XDMFCLOSE(obj) CALL MPI_FINALIZE(ierr) END PROGRAM XdmfFortranExample xdmf-3.0+git20160803/utils/tests/Fortran/FunctionTestXdmfFortran.f900000640000175000017500000001122313003006557025126 0ustar alastairalastair!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! !! AUTHOR: Kenneth Leiter (kenneth.leiter@arl.army.mil) !! !! Use the Xdmf Fortran Bindings to write out a simple mesh consisting of !! two hexahedrons. Link against the XdmfUtils library to compile. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! PROGRAM XdmfFortranExample Implicit none INCLUDE 'Xdmf.f' INTEGER*8 obj character*256 filename REAL*4 myPoints(3,3,4) INTEGER myConnections(8,2) REAL*8 myCellAttribute(2), myNodeAttribute(3,4), mySmallerNode(3,2), myTime INTEGER nodeAttributeId, nodeSmallAttributeId, cellAttributeId, testSetID, tempID, variableID(3) filename = 'function_output.xmf'//CHAR(0) myPoints(1,1,1) = 0 myPoints(2,1,1) = 0 myPoints(3,1,1) = 1 myPoints(1,2,1) = 1 myPoints(2,2,1) = 0 myPoints(3,2,1) = 1 myPoints(1,3,1) = 3 myPoints(2,3,1) = 0 myPoints(3,3,1) = 2 myPoints(1,1,2) = 0 myPoints(2,1,2) = 1 myPoints(3,1,2) = 1 myPoints(1,2,2) = 1 myPoints(2,2,2) = 1 myPoints(3,2,2) = 1 myPoints(1,3,2) = 3 myPoints(2,3,2) = 2 myPoints(3,3,2) = 2 myPoints(1,1,3) = 0 myPoints(2,1,3) = 0 myPoints(3,1,3) = -1 myPoints(1,2,3) = 1 myPoints(2,2,3) = 0 myPoints(3,2,3) = -1 myPoints(1,3,3) = 3 myPoints(2,3,3) = 0 myPoints(3,3,3) = -2 myPoints(1,1,4) = 0 myPoints(2,1,4) = 1 myPoints(3,1,4) = -1 myPoints(1,2,4) = 1 myPoints(2,2,4) = 1 myPoints(3,2,4) = -1 myPoints(1,3,4) = 3 myPoints(2,3,4) = 2 myPoints(3,3,4) = -2 myConnections(1,1) = 0 myConnections(2,1) = 1 myConnections(3,1) = 7 myConnections(4,1) = 6 myConnections(5,1) = 3 myConnections(6,1) = 4 myConnections(7,1) = 10 myConnections(8,1) = 9 myConnections(1,2) = 1 myConnections(2,2) = 2 myConnections(3,2) = 8 myConnections(4,2) = 7 myConnections(5,2) = 4 myConnections(6,2) = 5 myConnections(7,2) = 11 myConnections(8,2) = 10 myNodeAttribute(1,1) = 100 myNodeAttribute(1,2) = 300 myNodeAttribute(1,3) = 300 myNodeAttribute(1,4) = 500 myNodeAttribute(2,1) = 200 myNodeAttribute(2,2) = 400 myNodeAttribute(2,3) = 400 myNodeAttribute(2,4) = 600 myNodeAttribute(3,1) = 300 myNodeAttribute(3,2) = 500 myNodeAttribute(3,3) = 500 myNodeAttribute(3,4) = 700 myCellAttribute(1) = 100 myCellAttribute(2) = 200 myTime = 1.0 CALL XDMFINIT(obj, filename) CALL XDMFADDGRIDCOLLECTION(obj, "Temporal"//CHAR(0), & XDMF_GRID_COLLECTION_TYPE_TEMPORAL) CALL XDMFSETTIME(obj, myTime) !! Create an InformationArrays to serve as a variable variableID(1) = XDMFADDINFORMATION(obj, 'Variable A'//CHAR(0), 'Initializes Variable A'//CHAR(0)) CALL XDMFADDINFORMATIONARRAY(obj, 0, 'Variable Definition A'//CHAR(0), myPoints, 36, XDMF_ARRAY_TYPE_FLOAT64) CALL XDMFSETINFORMATIONARRAYASVARIABLE(obj, 'A'//CHAR(0), 0, 0) variableID(2) = XDMFADDINFORMATION(obj, 'Variable B'//CHAR(0), 'Initializes Variable B'//CHAR(0)) CALL XDMFADDINFORMATIONARRAY(obj, 1, 'Variable Definition B'//CHAR(0), myConnections, 16, XDMF_ARRAY_TYPE_INT32) CALL XDMFSETINFORMATIONARRAYASVARIABLE(obj, 'B'//CHAR(0), 1, 0) variableID(3) = XDMFADDINFORMATION(obj, 'Variable C'//CHAR(0), 'Initializes Variable C'//CHAR(0)) CALL XDMFADDINFORMATIONARRAY(obj, 2, 'Variable Definition C'//CHAR(0), myNodeAttribute, 12, XDMF_ARRAY_TYPE_FLOAT64) CALL XDMFSETINFORMATIONARRAYASVARIABLE(obj, 'C'//CHAR(0), 2, 0) CALL XdmfClearInformations(obj) tempID = XDMFSETFUNCTIONASTOPOLOGY(obj, "B", XDMF_TOPOLOGY_TYPE_HEXAHEDRON, 0) tempID = XDMFSETFUNCTIONASGEOMETRY(obj, 'A+1'//CHAR(0), XDMF_GEOMETRY_TYPE_XYZ) testSetID = XDMFADDFUNCTIONASSET(obj, 'C+5'//CHAR(0), 'TestSet'//CHAR(0), XDMF_SET_TYPE_NODE) tempID = XDMFADDINFORMATION(obj, 'Attrib1'//CHAR(0), 'This is Attribute 1'//CHAR(0)) nodeAttributeId = XDMFADDFUNCTIONASATTRIBUTE(obj, 'C+3'//CHAR(0), 'NodeValues'//CHAR(0), & XDMF_ATTRIBUTE_CENTER_NODE, XDMF_ATTRIBUTE_TYPE_SCALAR) PRINT *, 'Node Attribute ID: ', nodeAttributeId tempID = XDMFADDINFORMATION(obj, 'Grid1'//CHAR(0), 'This is Grid 1'//CHAR(0)) tempID = XDMFADDINFORMATION(obj, 'SubInformation'//CHAR(0), 'This is an information inside an information'//CHAR(0)) CALL XDMFADDFUNCTIONASINFORMATIONARRAY(obj, 'A|A'//CHAR(0), 1, 'Array'//CHAR(0)) CALL XDMFINSERTINFORMATIONINTOINFORMATION(obj, 0, 1, .TRUE.) CALL XDMFADDPREVIOUSINFORMATION(obj, variableID(1)) CALL XDMFADDPREVIOUSINFORMATION(obj, variableID(2)) CALL XDMFADDPREVIOUSINFORMATION(obj, variableID(3)) CALL XDMFADDGRID(obj, 'TestGrid'//CHAR(0), .FALSE.) CALL XDMFCLOSEGRIDCOLLECTION(obj, .TRUE.) CALL XDMFWRITE(obj, filename, 10, .TRUE.) CALL XDMFCLOSE(obj) END PROGRAM XdmfFortranExample xdmf-3.0+git20160803/utils/tests/Fortran/TestXdmfFortran.f900000640000175000017500000003515413003006557023431 0ustar alastairalastair!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! !! AUTHOR: Andrew Burns (andrew.j.burns2@us.army.mil) !! !! Read the first hexahedron from the file generated by the !! OutputTestXdmfFortran program, then print the results for comparison. !! !! Link against the XdmfUtils library to compile. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! PROGRAM XdmfFortranExample IMPLICIT NONE INCLUDE 'Xdmf.f' INTEGER*8 obj character*256 infilename, itemName, itemKey, itemValue, itemTag REAL*4 myPointsOutput(36) INTEGER myConnectionsOutput(16) INTEGER myMappedNodes(3), myDimensions(3) REAL*8 myCellAttributeOutput(4), myNodeAttributeOutput(12), mySetOutput(12), myTestTime, myBrick(3), myOrigin(3) INTEGER numContained, typeHolder infilename = 'my_output.xmf'//CHAR(0) CALL XDMFINIT(obj) CALL XDMFREAD(obj, infilename) PRINT *, 'Load From: ', TRIM(infilename) PRINT *, 'Domain Properties' CALL XDMFRETRIEVEDOMAINNUMPROPERTIES(obj, numContained) PRINT *, 'number of Properties: ', numContained CALL XDMFRETRIEVEDOMAINTAG(obj, itemTag, 256) PRINT *, 'Domain Tag: ', itemTag CALL XDMFRETRIEVENUMDOMAINGRIDCOLLECTIONS(obj, numContained) PRINT *, 'Number of Grid Collections: ', numContained CALL XDMFOPENDOMAINGRIDCOLLECTION(obj, 0, 1, 1, 1, 1) CALL XDMFRETRIEVENUMINFORMATION(obj, numContained) PRINT *, 'Number of Information for Grid: ', numContained PRINT *, 'Information 0' CALL XDMFRETRIEVEINFORMATIONNUMPROPERTIES(obj, 0, numContained) PRINT *, "Number of Properties: ", numContained CALL XDMFRETRIEVEINFORMATIONPROPERTY(obj, 0, 0, itemKey, 256, itemValue, 256) PRINT *, "Key: ", itemKey PRINT *, "Value: ", itemValue CALL XDMFRETRIEVEINFORMATIONPROPERTYBYKEY(obj, 0, itemKey, itemValue, 256) PRINT *, "Value: ", itemValue CALL XDMFRETRIEVEINFORMATIONTAG(obj, 0, itemTag, 256) PRINT *, 'Information Tag: ', itemTag CALL XDMFRETRIEVEINFORMATION(obj, 0, itemKey, 256, itemValue, 256) PRINT *, 'Key: ', itemKey PRINT *, 'Value: ', itemValue CALL XDMFRETRIEVEINFORMATIONBYKEY(obj, itemKey, itemValue, 256) PRINT *, 'Value: ', itemValue CALL XDMFRETRIEVEGRIDCOLLECTIONNUMGRIDS(obj, XDMF_GRID_TYPE_UNSTRUCTURED, numContained) PRINT *, 'Number of Grids contained in the Grid Collection: ', numContained CALL XDMFOPENGRIDCOLLECTIONGRID(obj, XDMF_GRID_TYPE_UNSTRUCTURED, 0, 1, 1, 1, 1) CALL XDMFRETRIEVEGRIDCOLLECTIONGRIDNAME(obj, XDMF_GRID_TYPE_UNSTRUCTURED, 0, itemName, 256) PRINT *, "Grid Name: ", itemName CALL XDMFRETRIEVEGRIDCOLLECTIONGRIDTAG(obj, XDMF_GRID_TYPE_UNSTRUCTURED, 0, itemTag, 256) PRINT *, "Grid Tag: ", itemTag CALL XDMFRETRIEVEGRIDCOLLECTIONGRIDNUMPROPERTIES(obj, XDMF_GRID_TYPE_UNSTRUCTURED, 0, numContained) PRINT *, "Number of Properties: ", numContained PRINT *, "Grid Properties: " CALL XDMFRETRIEVEGRIDCOLLECTIONGRIDPROPERTY(obj, XDMF_GRID_TYPE_UNSTRUCTURED, 0, 0, itemKey, 256, itemValue, 256) PRINT *, "Key: ", itemKey PRINT *, "Value: ", itemValue CALL XDMFRETRIEVEGRIDCOLLECTIONGRIDPROPERTYBYKEY(obj, XDMF_GRID_TYPE_UNSTRUCTURED, 0, itemKey, itemValue, 256) PRINT *, "Value: ", itemValue CALL XDMFRETRIEVETIME(obj, myTestTime) PRINT *, 'Grid Time: ', myTestTime CALL XDMFRETRIEVEGRIDCOLLECTIONTYPE(obj, typeHolder) PRINT *, 'Grid Collection Type: ', typeHolder CALL XDMFRETRIEVENUMATTRIBUTES(obj, numContained) PRINT *, 'Number of Grid Attributes: ', numContained PRINT *, 'Map' CALL XDMFRETRIEVEMAPNUMPROPERTIES(obj, 0, numContained) PRINT *, 'Number of Properties: ', numContained CALL XDMFRETRIEVEMAPPROPERTY(obj, 0, 0, itemKey, 256, itemValue, 256) PRINT *, "Key: ", itemKey PRINT *, "Value: ", itemValue CALL XDMFRETRIEVEMAPPROPERTYBYKEY(obj, 0, itemKey, itemValue, 256) PRINT *, "Value: ", itemValue CALL XDMFRETRIEVEREMOTENODEIDS(obj, 0, 1, 3, myMappedNodes) PRINT *, 'Nodes: ', myMappedNodes !!!! Unstructured and Curvilinear only PRINT *, 'Geometry' CALL XDMFRETRIEVEGEOMETRYNUMPROPERTIES(obj, numContained) PRINT *, "Number of Properties: ", numContained CALL XDMFRETRIEVEGEOMETRYPROPERTY(obj, 0, itemKey, 256, itemValue, 256) PRINT *, "Key: ", itemKey PRINT *, "Value: ", itemValue CALL XDMFRETRIEVEGEOMETRYPROPERTYBYKEY(obj, itemKey, itemValue, 256) PRINT *, "Value: ", itemValue CALL XDMFRETRIEVEGEOMETRYTAG(obj, itemTag, 256) PRINT *, 'Geometry Tag: ', itemTag CALL XDMFRETRIEVEGEOMETRYTYPE(obj, typeHolder) PRINT *, 'Geometry Type: ', typeHolder CALL XDMFRETRIEVEGEOMETRYVALUETYPE(obj, typeHolder) PRINT *, 'Geometry Value Type: ', typeHolder CALL XDMFRETRIEVEGEOMETRYSIZE(obj, numContained) PRINT *, 'Number of Values: ', numContained CALL XDMFRETRIEVEGEOMETRYNUMPOINTS(obj, numContained) PRINT *, 'Geometry Number of Points: ', numContained CALL XDMFRETRIEVEGEOMETRYVALUES(obj, myPointsOutput, XDMF_ARRAY_TYPE_FLOAT32, 36, 0, 1, 1) PRINT 1, myPointsOutput 1 FORMAT (' ', 3F5.1, '\n ', 3F5.1, '\n ', 3F5.1, '\n') !!!! / Unstructured and Curvilinear Grid only !!!! Unstructured Grid only PRINT *, 'Topology' CALL XDMFRETRIEVETOPOLOGYNUMPROPERTIES(obj, numContained) PRINT *, "Number of Properties: ", numContained CALL XDMFRETRIEVETOPOLOGYPROPERTY(obj, 0, itemKey, 256, itemValue, 256) PRINT *, "Key: ", itemKey PRINT *, "Value: ", itemValue CALL XDMFRETRIEVETOPOLOGYPROPERTYBYKEY(obj, itemKey, itemValue, 256) PRINT *, "Value: ", itemValue CALL XDMFRETRIEVETOPOLOGYTAG(obj, itemTag, 256) PRINT *, 'Topology Tag: ', itemTag CALL XDMFRETRIEVETOPOLOGYTYPE(obj, typeHolder) PRINT *, 'Topology Type: ', typeHolder CALL XDMFRETRIEVETOPOLOGYVALUETYPE(obj, typeHolder) PRINT *, 'Topology Value Type: ', typeHolder CALL XDMFRETRIEVETOPOLOGYSIZE(obj, numContained) PRINT *, 'Number of Values: ', numContained CALL XDMFRETRIEVETOPOLOGYNUMELEMENTS(obj, numContained) PRINT *, 'Topology Number of elements: ', numContained CALL XDMFRETRIEVETOPOLOGYVALUES(obj, myConnectionsOutput, XDMF_ARRAY_TYPE_INT32, 16, 0, 1, 1) PRINT 2, myConnectionsOutput 2 FORMAT (' ', 8I3) !!!! /Unstructured Grid Only !!!! Curvilinear and Regular only !! PRINT *, 'Dimensions' !! CALL XDMFRETRIEVEDIMENSIONSNUMPROPERTIES(obj, numContained) !! PRINT *, 'Number of Properties: ', numContained !! CALL XDMFRETRIEVEDIMENSIONSPROPERTY(obj, 0, itemKey, 256, itemValue, 256) !! PRINT *, "Key: ", itemKey !! PRINT *, "Value: ", itemValue !! CALL XDMFRETRIEVEDIMENSIONSPROPERTYBYKEY(obj, itemKey, itemValue, 256) !! PRINT *, "Value: ", itemValue !! CALL XDMFRETRIEVEDIMENSIONSTAG(obj, itemTag, 256) !! PRINT *, "Dimension Tag: ", itemTag !! CALL XDMFRETRIEVEDIMENSIONSVALUETYPE(obj, typeHolder) !! PRINT *, "Dimension Value Type: ", typeHolder !! CALL XDMFRETRIEVEDIMENSIONSSIZE(obj, numContained) !! PRINT *, "Number of Values: ", numContained !! CALL XDMFRETRIEVEDIMENSIONSVALUES(obj, myDimensions, XDMF_ARRAY_TYPE_INT32, 3, 0, 1, 1) !! PRINT *, myDimensions !!!! /Curvilinear and Regular only !!!! Rectilinear Only !! PRINT *, 'Coordinates' !! CALL XDMFRETRIEVENUMCOORDINATES(obj, numContained) !! PRINT *, 'Number of Coordinates: ', numContained !! CALL XDMFRETRIEVECOORDINATEVALUETYPE(obj, 0, typeHolder) !! PRINT *, 'Coordinate Value Type', typeHolder !! CALL XDMFRETRIEVECOORDINATENUMPROPERTIES(obj, 0, numContained) !! PRINT *, 'Number of Properties', numContained !! CALL XDMFRETRIEVECOORDINATEPROPERTY(obj, 0, 0, itemKey, 256, itemValue, 256) !! PRINT *, 'Key: ', itemKey !! PRINT *, 'Value: ', itemValue !! CALL XDMFRETRIEVECOORDINATEPROPERTYBYKEY(obj, 0, itemKey, itemValue, 256) !! PRINT *, 'Value: ', itemValue !! CALL XDMFRETRIEVECOORDINATESIZE(obj, 0, numContained) !! PRINT *, 'Size of Coordinate 0', numContained !! CALL XDMFRETRIEVECOORDINATESIZE(obj, 1, numContained) !! PRINT *, 'Size of Coordinate 1', numContained !! CALL XDMFRETRIEVECOORDINATESIZE(obj, 2, numContained) !! PRINT *, 'Size of Coordinate 2', numContained !! CALL XDMFRETRIEVECOORDINATEVALUES(obj, 0, myPointsOutput(1), XDMF_ARRAY_TYPE_FLOAT32, 12, 0, 1, 1) !! CALL XDMFRETRIEVECOORDINATEVALUES(obj, 0, myPointsOutput(13), XDMF_ARRAY_TYPE_FLOAT32, 12, 0, 1, 1) !! CALL XDMFRETRIEVECOORDINATEVALUES(obj, 0, myPointsOutput(25), XDMF_ARRAY_TYPE_FLOAT32, 12, 0, 1, 1) !! PRINT 1, myPointsOutput !!!! /Rectilinear Only !!!! Regular Grid Only !! Brick and Origin !! PRINT *, 'Brick' !! CALL XDMFRETRIEVEBRICKNUMPROPERTIES(obj, numContained) !! PRINT *, 'Number of Properties: ', numContained !! CALL XDMFRETRIEVEBRICKPROPERTY(obj, 0, itemKey, 256, itemValue, 256) !! PRINT *, "Key: ", itemKey !! PRINT *, "Value: ", itemValue !! CALL XDMFRETRIEVEBRICKPROPERTYBYKEY(obj, itemKey, itemValue, 256) !! PRINT *, "Value: ", itemValue !! CALL XDMFRETRIEVEBRICKTAG(obj, itemTag, 256) !! PRINT *, "Brick Tag: ", itemTag !! CALL XDMFRETRIEVEBRICKVALUETYPE(obj, typeHolder) !! PRINT *, "Brick Value Type: ", typeHolder !! CALL XDMFRETRIEVEBRICKSIZE(obj, numContained) !! PRINT *, "Number of Values: ", numContained !! CALL XDMFRETRIEVEBRICKVALUES(obj, myBrick, XDMF_ARRAY_TYPE_FLOAT64, 3, 0, 1, 1) !! PRINT *, myBrick !! PRINT *, 'Origin' !! CALL XDMFRETRIEVEORIGINNUMPROPERTIES(obj, numContained) !! PRINT *, 'Number of Properties: ', numContained !! CALL XDMFRETRIEVEORIGINPROPERTY(obj, 0, itemKey, 256, itemValue, 256) !! PRINT *, "Key: ", itemKey !! PRINT *, "Value: ", itemValue !! CALL XDMFRETRIEVEORIGINPROPERTYBYKEY(obj, itemKey, itemValue, 256) !! PRINT *, "Value: ", itemValue !! CALL XDMFRETRIEVEORIGINTAG(obj, itemTag, 256) !! PRINT *, "Origin Tag: ", itemTag !! CALL XDMFRETRIEVEORIGINVALUETYPE(obj, typeHolder) !! PRINT *, "Origin Value Type: ", typeHolder !! CALL XDMFRETRIEVEORIGINSIZE(obj, numContained) !! PRINT *, "Number of Values: ", numContained !! CALL XDMFRETRIEVEORIGINVALUES(obj, myOrigin, XDMF_ARRAY_TYPE_FLOAT64, 3, 0, 1, 1) !! PRINT *, myOrigin !!!! /Regular Grid Only CALL XDMFRETRIEVENUMSETS(obj, numContained) PRINT *, '\nNumber of Sets:', numContained PRINT *, '\nSet 0' CALL XDMFRETRIEVESETNUMPROPERTIES(obj, 0, numContained) PRINT *, 'Number of Properties: ', numContained CALL XDMFRETRIEVESETPROPERTY(obj, 0, 0, itemKey, 256, itemValue, 256) PRINT *, "Key: ", itemKey PRINT *, "Value: ", itemValue CALL XDMFRETRIEVESETPROPERTYBYKEY(obj, 0, itemKey, itemValue, 256) PRINT *, "Value: ", itemValue CALL XDMFRETRIEVESETTYPE(obj, 0, typeHolder) PRINT *, 'Set Type: ', typeHolder CALL XDMFRETRIEVESETVALUETYPE(obj, 0, typeHolder) PRINT *, 'Set Value Type: ', typeHolder CALL XDMFRETRIEVESETNAME(obj, 0, itemName, 256) PRINT *, 'Set Name: ', itemName CALL XDMFRETRIEVESETTAG(obj, 0, itemTag, 256) PRINT *, 'Set Tag: ', itemTag CALL XDMFRETRIEVESETVALUES(obj, 0, mySetOutput, XDMF_ARRAY_TYPE_FLOAT64, 12, 0, 1, 1) PRINT 3, mySetOutput PRINT *, '\nAttribute 0' CALL XDMFRETRIEVEATTRIBUTENAME(obj, 0, itemName, 256) PRINT *, 'Attribute Name: ', itemName CALL XDMFRETRIEVEATTRIBUTENUMPROPERTIES(obj, 0, numContained) PRINT *, "Number of Properties: ", numContained CALL XDMFRETRIEVEATTRIBUTEPROPERTY(obj, 0, 0, itemKey, 256, itemValue, 256) PRINT *, "Key: ", itemKey PRINT *, "Value: ", itemValue CALL XDMFRETRIEVEATTRIBUTEPROPERTYBYKEY(obj, 0, itemKey, itemValue, 256) PRINT *, "Value: ", itemValue CALL XDMFRETRIEVEATTRIBUTETAG(obj, 0, itemTag, 256) PRINT *, 'Attribute Tag: ', itemTag CALL XDMFRETRIEVEATTRIBUTETYPE(obj, 0, typeHolder) PRINT *, 'Attribute Type: ', typeHolder CALL XDMFRETRIEVEATTRIBUTECENTER(obj, 0, typeHolder) PRINT *, 'Attribute Center: ', typeHolder CALL XDMFRETRIEVEATTRIBUTEVALUETYPE(obj, 0, typeHolder) PRINT *, 'Attribute Value Type: ', typeHolder CALL XDMFRETRIEVEATTRIBUTESIZE(obj, 0, numContained) PRINT *, 'Number of Values: ', numContained CALL XDMFRETRIEVEATTRIBUTEVALUES(obj, 0, myNodeAttributeOutput, XDMF_ARRAY_TYPE_FLOAT64, 12, 0, 1, 1) PRINT 3, myNodeAttributeOutput 3 FORMAT (' ', 3F6.1) CALL XDMFOPENATTRIBUTE(obj, 0) CALL XDMFRETRIEVENUMINFORMATION(obj, numContained) PRINT *, 'Number of Information for Grid and Attribute 0: ', numContained PRINT *, 'Information 0' CALL XDMFRETRIEVEINFORMATIONNUMPROPERTIES(obj, 0, numContained) PRINT *, "Number of Properties: ", numContained CALL XDMFRETRIEVEINFORMATIONPROPERTY(obj, 0, 0, itemKey, 256, itemValue, 256) PRINT *, "Key: ", itemKey PRINT *, "Value: ", itemValue CALL XDMFRETRIEVEINFORMATIONPROPERTYBYKEY(obj, 0, itemKey, itemValue, 256) PRINT *, "Value: ", itemValue CALL XDMFRETRIEVEINFORMATIONTAG(obj, 0, itemTag, 256) PRINT *, 'Information Tag: ', itemTag CALL XDMFRETRIEVEINFORMATION(obj, 1, itemKey, 256, itemValue, 256) PRINT *, 'Key: ', itemKey PRINT *, 'Value: ', itemValue CALL XDMFRETRIEVEINFORMATIONBYKEY(obj, itemKey, itemValue, 256) PRINT *, 'Value: ', itemValue PRINT *, '\nAttribute 1' CALL XDMFRETRIEVEATTRIBUTENUMPROPERTIES(obj, 1, numContained) PRINT *, "Number of Properties: ", numContained CALL XDMFRETRIEVEATTRIBUTEPROPERTY(obj, 1, 0, itemKey, 256, itemValue, 256) PRINT *, "Key: ", itemKey PRINT *, "Value: ", itemValue CALL XDMFRETRIEVEATTRIBUTEPROPERTYBYKEY(obj, 1, itemKey, itemValue, 256) PRINT *, "Value: ", itemValue CALL XDMFRETRIEVEATTRIBUTENAME(obj, 1, itemName, 256) PRINT *, 'Attribute Name: ', itemName CALL XDMFRETRIEVEATTRIBUTETAG(obj, 1, itemTag, 256) PRINT *, 'Attribute Tag: ', itemTag CALL XDMFRETRIEVEATTRIBUTETYPE(obj, 1, typeHolder) PRINT *, 'Attribute Type: ', typeHolder CALL XDMFRETRIEVEATTRIBUTECENTER(obj, 1, typeHolder) PRINT *, 'Attribute Center: ', typeHolder CALL XDMFRETRIEVEATTRIBUTEVALUETYPE(obj, 1, typeHolder) PRINT *, 'Attribute Value Type: ', typeHolder CALL XDMFRETRIEVEATTRIBUTESIZE(obj, 1, numContained) PRINT *, 'Number of Values: ', numContained CALL XDMFRETRIEVEATTRIBUTEVALUES(obj, 1, myCellAttributeOutput, XDMF_ARRAY_TYPE_FLOAT64, 4, 0, 1, 1) PRINT 4, myCellAttributeOutput 4 FORMAT (' ', F6.1) CALL XDMFOPENATTRIBUTE(obj, 1) CALL XDMFRETRIEVENUMINFORMATION(obj, numContained) PRINT *, 'Number of Information for Grid and Attribute 0: ', numContained PRINT *, 'Information 0' CALL XDMFRETRIEVEINFORMATIONNUMPROPERTIES(obj, 0, numContained) PRINT *, "Number of Properties: ", numContained CALL XDMFRETRIEVEINFORMATIONPROPERTY(obj, 0, 0, itemKey, 256, itemValue, 256) PRINT *, "Key: ", itemKey PRINT *, "Value: ", itemValue CALL XDMFRETRIEVEINFORMATIONPROPERTYBYKEY(obj, 0, itemKey, itemValue, 256) PRINT *, "Value: ", itemValue CALL XDMFRETRIEVEINFORMATIONTAG(obj, 0, itemTag, 256) PRINT *, 'Information Tag: ', itemTag CALL XDMFRETRIEVEINFORMATION(obj, 0, itemKey, 256, itemValue, 256) PRINT *, 'Key: ', itemKey PRINT *, 'Value: ', itemValue CALL XDMFRETRIEVEINFORMATIONBYKEY(obj, itemKey, itemValue, 256) PRINT *, 'Key: ', itemKey PRINT *, 'Value: ', itemValue CALL XDMFCLOSE(obj) END PROGRAM XdmfFortranExample xdmf-3.0+git20160803/utils/tests/Fortran/ConnectDSMFortran.sh0000740000175000017500000000026513003006557023640 0ustar alastairalastair# Intel MPI requires a minimum of 2 cores per process $MPIEXEC -n 2 ./AcceptDSMFortran & sleep 5 $MPIEXEC -n 2 ./ConnectDSMFortran & sleep 5 $MPIEXEC -n 2 ./ConnectDSMFortran2 xdmf-3.0+git20160803/utils/tests/Fortran/FixedOutputTestXdmfFortran.f900000640000175000017500000001671513003006557025634 0ustar alastairalastair!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! !! AUTHOR: Kenneth Leiter (kenneth.leiter@arl.army.mil) !! !! Use the Xdmf Fortran Bindings to write out a simple mesh consisting of !! two hexahedrons. Link against the XdmfUtils library to compile. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! PROGRAM XdmfFortranExample Implicit none INCLUDE 'Xdmf.f' INTEGER*8 obj character*256 filename REAL*4 myPoints(3,3,4) INTEGER myConnections(8,2), myDimensions(3) REAL*8 myCellAttribute(2), myNodeAttribute(3,4), & & mySmallerNode(3,2), myTime, myOrigin(3), myBrick(3) INTEGER nodeAttributeId, nodeSmallAttributeId, cellAttributeId, & & testSetID, testMapID, tempID filename = 'my_fixed_form_output.xmf'//CHAR(0) myPoints(1,1,1) = 0 myPoints(2,1,1) = 0 myPoints(3,1,1) = 1 myPoints(1,2,1) = 1 myPoints(2,2,1) = 0 myPoints(3,2,1) = 1 myPoints(1,3,1) = 3 myPoints(2,3,1) = 0 myPoints(3,3,1) = 2 myPoints(1,1,2) = 0 myPoints(2,1,2) = 1 myPoints(3,1,2) = 1 myPoints(1,2,2) = 1 myPoints(2,2,2) = 1 myPoints(3,2,2) = 1 myPoints(1,3,2) = 3 myPoints(2,3,2) = 2 myPoints(3,3,2) = 2 myPoints(1,1,3) = 0 myPoints(2,1,3) = 0 myPoints(3,1,3) = -1 myPoints(1,2,3) = 1 myPoints(2,2,3) = 0 myPoints(3,2,3) = -1 myPoints(1,3,3) = 3 myPoints(2,3,3) = 0 myPoints(3,3,3) = -2 myPoints(1,1,4) = 0 myPoints(2,1,4) = 1 myPoints(3,1,4) = -1 myPoints(1,2,4) = 1 myPoints(2,2,4) = 1 myPoints(3,2,4) = -1 myPoints(1,3,4) = 3 myPoints(2,3,4) = 2 myPoints(3,3,4) = -2 myConnections(1,1) = 0 myConnections(2,1) = 1 myConnections(3,1) = 7 myConnections(4,1) = 6 myConnections(5,1) = 3 myConnections(6,1) = 4 myConnections(7,1) = 10 myConnections(8,1) = 9 myConnections(1,2) = 1 myConnections(2,2) = 2 myConnections(3,2) = 8 myConnections(4,2) = 7 myConnections(5,2) = 4 myConnections(6,2) = 5 myConnections(7,2) = 11 myConnections(8,2) = 10 myNodeAttribute(1,1) = 100 myNodeAttribute(1,2) = 300 myNodeAttribute(1,3) = 300 myNodeAttribute(1,4) = 500 myNodeAttribute(2,1) = 200 myNodeAttribute(2,2) = 400 myNodeAttribute(2,3) = 400 myNodeAttribute(2,4) = 600 myNodeAttribute(3,1) = 300 myNodeAttribute(3,2) = 500 myNodeAttribute(3,3) = 500 myNodeAttribute(3,4) = 700 myCellAttribute(1) = 100 myCellAttribute(2) = 200 myDimensions(1) = 12 myDimensions(2) = 12 myDimensions(3) = 12 myOrigin(1) = 0 myOrigin(2) = 0 myOrigin(3) = 0 myBrick(1) = 12 myBrick(2) = 12 myBrick(3) = 12 myTime = 1.0 CALL XDMFINIT(obj, filename) CALL XDMFSETMAXFILESIZE(obj, 1) CALL XDMFSETALLOWSETSPLITTING(obj, .TRUE.) CALL XDMFINITHDF5(obj, 'my_output.h5'//CHAR(0), .TRUE.) tempID = XDMFADDINFORMATION(obj, 'GridCollection1'//CHAR(0), & & 'This is Grid collection 1'//CHAR(0)) CALL XDMFADDGRIDCOLLECTION(obj, "Temporal"//CHAR(0), & & XDMF_GRID_COLLECTION_TYPE_TEMPORAL) CALL XDMFADDMAP(obj, "TestMap"//CHAR(0)) CALL XDMFADDREMOTENODEID(obj, 0, 1, 2, 3) CALL XDMFADDREMOTENODEID(obj, 0, 1, 2, 4) CALL XDMFADDREMOTENODEID(obj, 0, 1, 3, 3) CALL XDMFADDREMOTENODEID(obj, 0, 1, 3, 5) testMapID = XDMFSTOREMAP(obj, 0) CALL XDMFADDREMOTENODEID(obj, 0, 1, 3, 8) CALL XDMFSETTIME(obj, myTime) !! Unstructured Only tempID = XDMFSETTOPOLOGY(obj, XDMF_TOPOLOGY_TYPE_HEXAHEDRON, 16,& & XDMF_ARRAY_TYPE_INT32, myConnections, 0) !! /Unstructured Only !! Curvilinear and Rectilinear Only tempID = XDMFSETDIMENSIONS(obj, 3, XDMF_ARRAY_TYPE_INT32, & & myDimensions) !! /Curvilinear and Rectilinear Only !! Unstructured and Curvilinear Only tempID = XDMFSETGEOMETRY(obj, XDMF_GEOMETRY_TYPE_XYZ, 36, & & XDMF_ARRAY_TYPE_FLOAT32, myPoints) !! /Unstructured and Curvilinear Only !! Rectilinear Only tempID = XDMFADDCOORDINATE(obj, "XCoordinates"//CHAR(0), 12, & & XDMF_ARRAY_TYPE_FLOAT32, myPoints(1,1,1)) tempID = XDMFADDCOORDINATE(obj, "YCoordinates"//CHAR(0), 12, & & XDMF_ARRAY_TYPE_FLOAT32, myPoints(1,2,2)) tempID = XDMFADDCOORDINATE(obj, "ZCoordinates"//CHAR(0), 12, & & XDMF_ARRAY_TYPE_FLOAT32, myPoints(1,3,3)) !! /Rectilinear Only !! Regular Only tempID = XDMFSETORIGIN(obj, 3, XDMF_ARRAY_TYPE_FLOAT64, & & myOrigin) tempID = XDMFSETBRICK(obj, 3, XDMF_ARRAY_TYPE_FLOAT64, myBrick) !! /Regular Only testSetID = XDMFADDSET(obj, 'TestSet'//CHAR(0), & & XDMF_SET_TYPE_NODE, myNodeAttribute, 12, & & XDMF_ARRAY_TYPE_FLOAT64) tempID = XDMFADDINFORMATION(obj, 'Attrib1'//CHAR(0), & & 'This is Attribute 1'//CHAR(0)) nodeAttributeId = XDMFADDATTRIBUTE(obj, 'NodeValues'//CHAR(0), & & XDMF_ATTRIBUTE_CENTER_NODE, XDMF_ATTRIBUTE_TYPE_SCALAR, 12,& & XDMF_ARRAY_TYPE_FLOAT64, myNodeAttribute) PRINT *, 'Node Attribute ID: ', nodeAttributeId CALL XDMFRETRIEVEATTRIBUTEVALUES(obj, 0, mySmallerNode, & & XDMF_ARRAY_TYPE_FLOAT64, 6, 0, 1, 1) tempID = XDMFADDINFORMATION(obj, 'Attrib2'//CHAR(0), & & 'This is Attribute 2'//CHAR(0)) cellAttributeId = XDMFADDATTRIBUTE(obj, 'CellValues'//CHAR(0), & & XDMF_ATTRIBUTE_CENTER_CELL, XDMF_ATTRIBUTE_TYPE_SCALAR, 2, & & XDMF_ARRAY_TYPE_FLOAT64, myCellAttribute) PRINT *, 'Cell Attribute ID: ', cellAttributeId nodeSmallAttributeId = XDMFADDATTRIBUTE(obj, & & 'SmallNodeValues'//CHAR(0), XDMF_ATTRIBUTE_CENTER_NODE, & & XDMF_ATTRIBUTE_TYPE_SCALAR, 6, XDMF_ARRAY_TYPE_FLOAT64, & & mySmallerNode) PRINT *, 'Node Attribute ID: ', nodeSmallAttributeId tempID = XDMFADDINFORMATION(obj, 'Grid1'//CHAR(0), & & 'This is Grid 1'//CHAR(0)) tempID = XDMFADDINFORMATION(obj, 'SubInformation'//CHAR(0), & & 'This is an information inside an information'//CHAR(0)) CALL XDMFADDINFORMATIONARRAY(obj, 1, "Array"//CHAR(0), myBrick, & & 3, XDMF_ARRAY_TYPE_FLOAT64) CALL XDMFMODIFYINFORMATIONARRAY(obj, 1, 0, myBrick, & & XDMF_ARRAY_TYPE_FLOAT64, 3, 3, 1, 1) CALL XDMFINSERTINFORMATIONINTOINFORMATION(obj, 0, 1, .TRUE.) CALL XDMFADDGRID(obj, 'TestGrid'//CHAR(0), .FALSE.) myTime = 2.0 CALL XDMFSETTIME(obj, myTime) CALL XDMFADDPREVIOUSATTRIBUTE(obj, cellAttributeId) CALL XDMFADDPREVIOUSMAP(obj, testMapID) CALL XDMFADDPREVIOUSSET(obj, testSetID) CALL XDMFADDPREVIOUSATTRIBUTE(obj, nodeAttributeId) CALL XDMFADDGRID(obj, 'Identical'//CHAR(0), .FALSE.) CALL XDMFCLOSEGRIDCOLLECTION(obj, .TRUE.) !! CALL XDMFWRITEHDF5(obj, 'my_output.h5'//CHAR(0), .TRUE.) CALL XDMFWRITE(obj, filename, 30, .TRUE.) CALL XDMFCLOSE(obj) END PROGRAM XdmfFortranExample xdmf-3.0+git20160803/utils/tests/Fortran/CMakeLists.txt0000640000175000017500000000530313003006557022550 0ustar alastairalastair# Add any dependencies that the cxx tests may need # Note: The tests already depend on their own file SET_PROPERTY(GLOBAL APPEND PROPERTY FORTRAN_TEST_DEPENDENCIES "XdmfUtils") # Include XdmfTestDataGenerator from non-util tests include_directories(${CMAKE_SOURCE_DIR}/tests/Fortran/) # Include our test macros include(AddTestsFortran) # Add any cxx tests here: # Note: We don't want to use a foreach loop to test the files incase we # have extra arguments (id: ADD_TEST_CXX(testname inputfile)) # Read UseCxxTest.cmake for more information # --------------------------------------- if ("${XDMF_DSM_IS_CRAY}" STREQUAL "") if (MPIEXEC_MAX_NUMPROCS STRGREATER 5) EXECUTE_PROCESS( COMMAND ${MPIEXEC} --version OUTPUT_VARIABLE MPI_TYPE_OUTPUT ERROR_VARIABLE MPI_TYPE_ERROR ) STRING(REGEX MATCH "Open" IS_OPENMPI "${MPI_TYPE_ERROR}") IF ("${IS_OPENMPI}" STREQUAL "") ADD_MPI_TEST_FORTRAN(ConnectDSMFortran.sh AcceptDSMFortran,ConnectDSMFortran2,ConnectDSMFortran) ENDIF ("${IS_OPENMPI}" STREQUAL "") endif(MPIEXEC_MAX_NUMPROCS STRGREATER 5) endif ("${XDMF_DSM_IS_CRAY}" STREQUAL "") SET_SOURCE_FILES_PROPERTIES(BinaryFortran.f90 PROPERTIES COMPILE_FLAGS -fno-range-check) ADD_TEST_FORTRAN(OutputTestXdmfFortran) ADD_TEST_FORTRAN(EditTestXdmfFortran) ADD_TEST_FORTRAN(TestXdmfFortran) ADD_TEST_FORTRAN(NestedInfoFortran) #if GCC STRING(REGEX MATCH "gfortran" IS_GCC "${CMAKE_Fortran_COMPILER}") IF ("${IS_GCC}" STREQUAL "gfortran") SET_SOURCE_FILES_PROPERTIES(FixedOutputTestXdmfFortran.f90 PROPERTIES COMPILE_FLAGS "-ffixed-form") ENDIF ("${IS_GCC}" STREQUAL "gfortran") #if Intel STRING(REGEX MATCH "ifort" IS_INTEL "${CMAKE_Fortran_COMPILER}") IF ("${IS_INTEL}" STREQUAL "ifort") SET_SOURCE_FILES_PROPERTIES(FixedOutputTestXdmfFortran.f90 PROPERTIES COMPILE_FLAGS "-fixed") ENDIF ("${IS_INTEL}" STREQUAL "ifort") ADD_TEST_FORTRAN(FixedOutputTestXdmfFortran) ADD_TEST_FORTRAN(FunctionTestXdmfFortran) ADD_TEST_FORTRAN(SubsetTestXdmfFortran) # Add any cxx cleanup here: # Note: We don't want to use a foreach loop to test the files incase we # have multiple files (ie: CLEAN_TEST_CXX(testname outputfile1 ...)) # Read UseCxxTest.cmake for more information # --------------------------------------- CLEAN_TEST_FORTRAN(OutputTestXdmfFortran) CLEAN_TEST_FORTRAN(TestXdmfFortran my_output.h5 my_output.xmf) CLEAN_TEST_FORTRAN(NestedInfoFortran nested_output.xmf nested_output.h5) CLEAN_TEST_FORTRAN(EditTestXdmfFortran edited_output.xmf edited_output.h5) CLEAN_TEST_FORTRAN(FixedOutputTestXdmfFortran) CLEAN_TEST_FORTRAN(FunctionTestXdmfFortran function_output.h5 function_output.xmf) CLEAN_TEST_FORTRAN(SubsetTestXdmfFortran subset_output.h5 subset_output.xmf) xdmf-3.0+git20160803/utils/tests/Fortran/ConnectDSMFortran.f900000640000175000017500000000532613003006557023626 0ustar alastairalastair!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! !! AUTHOR: Andrew Burns (andrew.j.burns2@us.army.mil) !! !! A test of the XdmfDSM capabilities using the fortran interface. !! This part of the program sets up the server to be used by the DSM. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! PROGRAM XdmfFortranExample Implicit none INCLUDE 'Xdmf.f' INCLUDE 'mpif.h' INTEGER*8 obj character*256 filename INTEGER i INTEGER id, commsize, buffersize, statusval(MPI_STATUS_SIZE) INTEGER intraID, intraSize INTEGER interID, interSize INTEGER ierr INTEGER writeloopcontrol INTEGER interComm, intraComm REAL*8 dataArray(4) filename = 'nested_output.xmf'//CHAR(0) writeloopcontrol = 0 CALL MPI_INIT (ierr) CALL XDMFINIT(obj, filename) CALL MPI_COMM_RANK(MPI_COMM_WORLD, id, ierr) CALL MPI_COMM_SIZE(MPI_COMM_WORLD, commsize, ierr) i = 1 do while (i <= 4) dataArray(i) = (id + 1) * i i = i + 1 enddo CALL XDMFCONNECTDSM(obj, "dsm"//CHAR(0), MPI_COMM_WORLD) CALL XDMFGETDSMINTRACOMM(obj, intraComm) CALL MPI_COMM_RANK(intraComm, intraID, ierr) CALL MPI_COMM_SIZE(intraComm, intraSize, ierr) CALL XDMFGETDSMINTERCOMM(obj, interComm) CALL MPI_COMM_RANK(interComm, interID, ierr) CALL MPI_COMM_SIZE(interComm, interSize, ierr) i = 0 do while (i < commsize) if (i == id) then print *, "core " , id, "array = ", dataArray endif i = i + 1 CALL MPI_BARRIER(intraComm, ierr) enddo if (id == 0) then print *, "" endif !! Work section goes here do while (writeloopcontrol < 3) CALL MPI_BARRIER(intraComm, ierr) CALL XDMFWRITETODSM(obj, "Data"//CHAR(0), XDMF_ARRAY_TYPE_FLOAT64, dataArray, id*4, 1, 4, 4*commsize) if (id == commsize - 1) then CALL MPI_SEND(writeloopcontrol, 1, MPI_INT, interID + 1, 0, interComm, ierr) CALL MPI_RECV(writeloopcontrol, 1, MPI_INT, interID + 1, 0, interComm, statusval, ierr) endif CALL MPI_BARRIER(intraComm, ierr) CALL XDMFREADFROMDSM(obj, "Data"//CHAR(0), XDMF_ARRAY_TYPE_FLOAT64, dataArray, (commsize - id - 1)*4, 1, 4, 4*commsize) i = 0 do while (i < commsize) if (i == id) then print *, "core " , id, "array = ", dataArray endif i = i + 1 CALL MPI_BARRIER(intraComm, ierr) enddo if (id == 0) then print *, "" endif writeloopcontrol = writeloopcontrol + 1 enddo CALL MPI_BARRIER(intraComm, ierr) if (id == 0) then CALL XDMFSTOPDSM(obj) endif !!/Work section !! Wait for other processes to finish before closing CALL MPI_BARRIER(interComm, ierr) CALL XDMFCLOSE(obj) CALL MPI_FINALIZE(ierr) END PROGRAM XdmfFortranExample xdmf-3.0+git20160803/utils/tests/Fortran/ConnectDSMFortran2.f900000640000175000017500000000416013003006557023703 0ustar alastairalastair!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! !! AUTHOR: Andrew Burns (andrew.j.burns2@us.army.mil) !! !! A test of the XdmfDSM capabilities using the fortran interface. !! This part of the program sets up the server to be used by the DSM. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! PROGRAM XdmfFortranExample Implicit none INCLUDE 'Xdmf.f' INCLUDE 'mpif.h' INTEGER*8 obj character*256 filename INTEGER id, commsize, buffersize, statusval(MPI_STATUS_SIZE) INTEGER intraID, intraSize INTEGER interID, interSize INTEGER ierr INTEGER writeloopcontrol, i REAL*8 dataArray(4) INTEGER interComm, intraComm filename = 'nested_output.xmf'//CHAR(0) writeloopcontrol = 0 CALL MPI_INIT (ierr) CALL XDMFINIT(obj, filename) CALL MPI_COMM_RANK(MPI_COMM_WORLD, id, ierr) CALL MPI_COMM_SIZE(MPI_COMM_WORLD, commsize, ierr) CALL XDMFCONNECTDSM(obj, "dsm"//CHAR(0), MPI_COMM_WORLD) CALL XDMFGETDSMINTRACOMM(obj, intraComm) CALL MPI_COMM_RANK(intraComm, intraID, ierr) CALL MPI_COMM_SIZE(intraComm, intraSize, ierr) CALL MPI_BARRIER(intraComm, ierr) CALL XDMFGETDSMINTERCOMM(obj, interComm) CALL MPI_COMM_RANK(interComm, interID, ierr) CALL MPI_COMM_SIZE(interComm, interSize, ierr) !! Work is done here do while (writeloopcontrol < 3) if (id == 0) then CALL MPI_RECV(writeloopcontrol, 1, MPI_INT, interID - 1, 0, interComm, statusval, ierr) endif CALL XDMFREADFROMDSM(obj, "Data"//CHAR(0), XDMF_ARRAY_TYPE_FLOAT64, dataArray, id*4, 1, 4, 4*commsize) i = 1 do while (i <= 4) dataArray(i) = dataArray(i) * 2 i = i + 1 enddo CALL XDMFWRITETODSM(obj, "Data"//CHAR(0), XDMF_ARRAY_TYPE_FLOAT64, dataArray, id*4, 1, 4, 4*commsize) if (id == 0) then CALL MPI_SEND(writeloopcontrol, 1, MPI_INT, interID - 1, 0, interComm, ierr) endif writeloopcontrol = writeloopcontrol + 1 enddo !! Wait for other processes to finish before closing CALL MPI_BARRIER(interComm, ierr) CALL XDMFCLOSE(obj) CALL MPI_FINALIZE(ierr) END PROGRAM XdmfFortranExample xdmf-3.0+git20160803/utils/tests/Fortran/EditTestXdmfFortran.f900000640000175000017500000003672113003006557024240 0ustar alastairalastair!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! !! AUTHOR: Andrew Burns (andrew.j.burns2@us.army.mil) !! !! Read the first hexahedron from the file generated by the !! OutputTestXdmfFortran program, then print the results for comparison. !! !! Link against the XdmfUtils library to compile. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! PROGRAM XdmfFortranExample IMPLICIT NONE INCLUDE 'Xdmf.f' INTEGER*8 obj character*256 infilename, outfilename, itemName, itemKey, itemValue, itemTag REAL*4 myPointsOutput(36) INTEGER myConnectionsOutput(16) INTEGER myMappedNodes(3), myDimensions(3) REAL*8 myCellAttributeOutput(4), myNodeAttributeOutput(12), mySetOutput(12), myTestTime, myBrick(3), myOrigin(3) INTEGER numContained, typeHolder infilename = 'my_output.xmf'//CHAR(0) outfilename = 'edited_output.xmf'//CHAR(0) CALL XDMFINIT(obj) CALL XDMFREAD(obj, infilename) PRINT *, 'Load From: ', TRIM(infilename) PRINT *, 'Domain Properties' CALL XDMFRETRIEVEDOMAINNUMPROPERTIES(obj, numContained) PRINT *, 'number of Properties: ', numContained CALL XDMFRETRIEVEDOMAINTAG(obj, itemTag, 256) PRINT *, 'Domain Tag: ', itemTag CALL XDMFRETRIEVENUMDOMAINGRIDCOLLECTIONS(obj, numContained) PRINT *, 'Number of Grid Collections: ', numContained CALL XDMFOPENDOMAINGRIDCOLLECTION(obj, 0, 1, 1, 1, 1) CALL XDMFRETRIEVENUMINFORMATION(obj, numContained) PRINT *, 'Number of Information for Grid: ', numContained PRINT *, 'Information 0' CALL XDMFRETRIEVEINFORMATIONNUMPROPERTIES(obj, 0, numContained) PRINT *, "Number of Properties: ", numContained CALL XDMFRETRIEVEINFORMATIONPROPERTY(obj, 0, 0, itemKey, 256, itemValue, 256) PRINT *, "Key: ", itemKey PRINT *, "Value: ", itemValue CALL XDMFRETRIEVEINFORMATIONPROPERTYBYKEY(obj, 0, itemKey, itemValue, 256) PRINT *, "Value: ", itemValue CALL XDMFRETRIEVEINFORMATIONTAG(obj, 0, itemTag, 256) PRINT *, 'Information Tag: ', itemTag CALL XDMFRETRIEVEINFORMATION(obj, 0, itemKey, 256, itemValue, 256) PRINT *, 'Key: ', itemKey PRINT *, 'Value: ', itemValue CALL XDMFRETRIEVEINFORMATIONBYKEY(obj, itemKey, itemValue, 256) PRINT *, 'Value: ', itemValue CALL XDMFRETRIEVEGRIDCOLLECTIONNUMGRIDS(obj, XDMF_GRID_TYPE_UNSTRUCTURED, numContained) PRINT *, 'Number of Grids contained in the Grid Collection: ', numContained CALL XDMFOPENGRIDCOLLECTIONGRID(obj, XDMF_GRID_TYPE_UNSTRUCTURED, 0, 1, 1, 1, 1) CALL XDMFRETRIEVEGRIDCOLLECTIONGRIDNAME(obj, XDMF_GRID_TYPE_UNSTRUCTURED, 0, itemName, 256) PRINT *, "Grid Name: ", itemName CALL XDMFRETRIEVEGRIDCOLLECTIONGRIDTAG(obj, XDMF_GRID_TYPE_UNSTRUCTURED, 0, itemTag, 256) PRINT *, "Grid Tag: ", itemTag CALL XDMFRETRIEVEGRIDCOLLECTIONGRIDNUMPROPERTIES(obj, XDMF_GRID_TYPE_UNSTRUCTURED, 0, numContained) PRINT *, "Number of Properties: ", numContained PRINT *, "Grid Properties: " CALL XDMFRETRIEVEGRIDCOLLECTIONGRIDPROPERTY(obj, XDMF_GRID_TYPE_UNSTRUCTURED, 0, 0, itemKey, 256, itemValue, 256) PRINT *, "Key: ", itemKey PRINT *, "Value: ", itemValue CALL XDMFRETRIEVEGRIDCOLLECTIONGRIDPROPERTYBYKEY(obj, XDMF_GRID_TYPE_UNSTRUCTURED, 0, itemKey, itemValue, 256) PRINT *, "Value: ", itemValue CALL XDMFRETRIEVETIME(obj, myTestTime) PRINT *, 'Grid Time: ', myTestTime CALL XDMFRETRIEVEGRIDCOLLECTIONTYPE(obj, typeHolder) PRINT *, 'Grid Collection Type: ', typeHolder CALL XDMFRETRIEVENUMATTRIBUTES(obj, numContained) PRINT *, 'Number of Grid Attributes: ', numContained PRINT *, 'Map' CALL XDMFRETRIEVEMAPNUMPROPERTIES(obj, 0, numContained) PRINT *, 'Number of Properties: ', numContained CALL XDMFRETRIEVEMAPPROPERTY(obj, 0, 0, itemKey, 256, itemValue, 256) PRINT *, "Key: ", itemKey PRINT *, "Value: ", itemValue CALL XDMFRETRIEVEMAPPROPERTYBYKEY(obj, 0, itemKey, itemValue, 256) PRINT *, "Value: ", itemValue CALL XDMFRETRIEVEREMOTENODEIDS(obj, 0, 1, 3, myMappedNodes) PRINT *, 'Nodes: ', myMappedNodes !!!! Unstructured and Curvilinear only PRINT *, 'Geometry' CALL XDMFRETRIEVEGEOMETRYNUMPROPERTIES(obj, numContained) PRINT *, "Number of Properties: ", numContained CALL XDMFRETRIEVEGEOMETRYPROPERTY(obj, 0, itemKey, 256, itemValue, 256) PRINT *, "Key: ", itemKey PRINT *, "Value: ", itemValue CALL XDMFRETRIEVEGEOMETRYPROPERTYBYKEY(obj, itemKey, itemValue, 256) PRINT *, "Value: ", itemValue CALL XDMFRETRIEVEGEOMETRYTAG(obj, itemTag, 256) PRINT *, 'Geometry Tag: ', itemTag CALL XDMFRETRIEVEGEOMETRYTYPE(obj, typeHolder) PRINT *, 'Geometry Type: ', typeHolder CALL XDMFRETRIEVEGEOMETRYVALUETYPE(obj, typeHolder) PRINT *, 'Geometry Value Type: ', typeHolder CALL XDMFRETRIEVEGEOMETRYSIZE(obj, numContained) PRINT *, 'Number of Values: ', numContained CALL XDMFRETRIEVEGEOMETRYNUMPOINTS(obj, numContained) PRINT *, 'Geometry Number of Points: ', numContained CALL XDMFRETRIEVEGEOMETRYVALUES(obj, myPointsOutput, XDMF_ARRAY_TYPE_FLOAT32, 36, 0, 1, 1) PRINT 1, myPointsOutput 1 FORMAT (' ', 3F5.1, '\n ', 3F5.1, '\n ', 3F5.1, '\n') !!!! / Unstructured and Curvilinear Grid only !!!! Unstructured Grid only PRINT *, 'Topology' CALL XDMFRETRIEVETOPOLOGYNUMPROPERTIES(obj, numContained) PRINT *, "Number of Properties: ", numContained CALL XDMFRETRIEVETOPOLOGYPROPERTY(obj, 0, itemKey, 256, itemValue, 256) PRINT *, "Key: ", itemKey PRINT *, "Value: ", itemValue CALL XDMFRETRIEVETOPOLOGYPROPERTYBYKEY(obj, itemKey, itemValue, 256) PRINT *, "Value: ", itemValue CALL XDMFRETRIEVETOPOLOGYTAG(obj, itemTag, 256) PRINT *, 'Topology Tag: ', itemTag CALL XDMFRETRIEVETOPOLOGYTYPE(obj, typeHolder) PRINT *, 'Topology Type: ', typeHolder CALL XDMFRETRIEVETOPOLOGYVALUETYPE(obj, typeHolder) PRINT *, 'Topology Value Type: ', typeHolder CALL XDMFRETRIEVETOPOLOGYSIZE(obj, numContained) PRINT *, 'Number of Values: ', numContained CALL XDMFRETRIEVETOPOLOGYNUMELEMENTS(obj, numContained) PRINT *, 'Topology Number of elements: ', numContained CALL XDMFRETRIEVETOPOLOGYVALUES(obj, myConnectionsOutput, XDMF_ARRAY_TYPE_INT32, 16, 0, 1, 1) PRINT 2, myConnectionsOutput 2 FORMAT (' ', 8I3) !!!! /Unstructured Grid Only !!!! Curvilinear and Regular only !! PRINT *, 'Dimensions' !! CALL XDMFRETRIEVEDIMENSIONSNUMPROPERTIES(obj, numContained) !! PRINT *, 'Number of Properties: ', numContained !! CALL XDMFRETRIEVEDIMENSIONSPROPERTY(obj, 0, itemKey, 256, itemValue, 256) !! PRINT *, "Key: ", itemKey !! PRINT *, "Value: ", itemValue !! CALL XDMFRETRIEVEDIMENSIONSPROPERTYBYKEY(obj, itemKey, itemValue, 256) !! PRINT *, "Value: ", itemValue !! CALL XDMFRETRIEVEDIMENSIONSTAG(obj, itemTag, 256) !! PRINT *, "Dimension Tag: ", itemTag !! CALL XDMFRETRIEVEDIMENSIONSVALUETYPE(obj, typeHolder) !! PRINT *, "Dimension Value Type: ", typeHolder !! CALL XDMFRETRIEVEDIMENSIONSSIZE(obj, numContained) !! PRINT *, "Number of Values: ", numContained !! CALL XDMFRETRIEVEDIMENSIONSVALUES(obj, myDimensions, XDMF_ARRAY_TYPE_INT32, 3, 0, 1, 1) !! PRINT *, myDimensions !!!! /Curvilinear and Regular only !!!! Rectilinear Only !! PRINT *, 'Coordinates' !! CALL XDMFRETRIEVENUMCOORDINATES(obj, numContained) !! PRINT *, 'Number of Coordinates: ', numContained !! CALL XDMFRETRIEVECOORDINATEVALUETYPE(obj, 0, typeHolder) !! PRINT *, 'Coordinate Value Type', typeHolder !! CALL XDMFRETRIEVECOORDINATENUMPROPERTIES(obj, 0, numContained) !! PRINT *, 'Number of Properties', numContained !! CALL XDMFRETRIEVECOORDINATEPROPERTY(obj, 0, 0, itemKey, 256, itemValue, 256) !! PRINT *, 'Key: ', itemKey !! PRINT *, 'Value: ', itemValue !! CALL XDMFRETRIEVECOORDINATEPROPERTYBYKEY(obj, 0, itemKey, itemValue, 256) !! PRINT *, 'Value: ', itemValue !! CALL XDMFRETRIEVECOORDINATESIZE(obj, 0, numContained) !! PRINT *, 'Size of Coordinate 0', numContained !! CALL XDMFRETRIEVECOORDINATESIZE(obj, 1, numContained) !! PRINT *, 'Size of Coordinate 1', numContained !! CALL XDMFRETRIEVECOORDINATESIZE(obj, 2, numContained) !! PRINT *, 'Size of Coordinate 2', numContained !! CALL XDMFRETRIEVECOORDINATEVALUES(obj, 0, myPointsOutput(1), XDMF_ARRAY_TYPE_FLOAT32, 12, 0, 1, 1) !! CALL XDMFRETRIEVECOORDINATEVALUES(obj, 0, myPointsOutput(13), XDMF_ARRAY_TYPE_FLOAT32, 12, 0, 1, 1) !! CALL XDMFRETRIEVECOORDINATEVALUES(obj, 0, myPointsOutput(25), XDMF_ARRAY_TYPE_FLOAT32, 12, 0, 1, 1) !! PRINT 1, myPointsOutput !!!! /Rectilinear Only !!!! Regular Grid Only !! Brick and Origin !! PRINT *, 'Brick' !! CALL XDMFRETRIEVEBRICKNUMPROPERTIES(obj, numContained) !! PRINT *, 'Number of Properties: ', numContained !! CALL XDMFRETRIEVEBRICKPROPERTY(obj, 0, itemKey, 256, itemValue, 256) !! PRINT *, "Key: ", itemKey !! PRINT *, "Value: ", itemValue !! CALL XDMFRETRIEVEBRICKPROPERTYBYKEY(obj, itemKey, itemValue, 256) !! PRINT *, "Value: ", itemValue !! CALL XDMFRETRIEVEBRICKTAG(obj, itemTag, 256) !! PRINT *, "Brick Tag: ", itemTag !! CALL XDMFRETRIEVEBRICKVALUETYPE(obj, typeHolder) !! PRINT *, "Brick Value Type: ", typeHolder !! CALL XDMFRETRIEVEBRICKSIZE(obj, numContained) !! PRINT *, "Number of Values: ", numContained !! CALL XDMFRETRIEVEBRICKVALUES(obj, myBrick, XDMF_ARRAY_TYPE_FLOAT64, 3, 0, 1, 1) !! PRINT *, myBrick !! PRINT *, 'Origin' !! CALL XDMFRETRIEVEORIGINNUMPROPERTIES(obj, numContained) !! PRINT *, 'Number of Properties: ', numContained !! CALL XDMFRETRIEVEORIGINPROPERTY(obj, 0, itemKey, 256, itemValue, 256) !! PRINT *, "Key: ", itemKey !! PRINT *, "Value: ", itemValue !! CALL XDMFRETRIEVEORIGINPROPERTYBYKEY(obj, itemKey, itemValue, 256) !! PRINT *, "Value: ", itemValue !! CALL XDMFRETRIEVEORIGINTAG(obj, itemTag, 256) !! PRINT *, "Origin Tag: ", itemTag !! CALL XDMFRETRIEVEORIGINVALUETYPE(obj, typeHolder) !! PRINT *, "Origin Value Type: ", typeHolder !! CALL XDMFRETRIEVEORIGINSIZE(obj, numContained) !! PRINT *, "Number of Values: ", numContained !! CALL XDMFRETRIEVEORIGINVALUES(obj, myOrigin, XDMF_ARRAY_TYPE_FLOAT64, 3, 0, 1, 1) !! PRINT *, myOrigin !!!! /Regular Grid Only CALL XDMFRETRIEVENUMSETS(obj, numContained) PRINT *, '\nNumber of Sets:', numContained PRINT *, '\nSet 0' CALL XDMFRETRIEVESETNUMPROPERTIES(obj, 0, numContained) PRINT *, 'Number of Properties: ', numContained CALL XDMFRETRIEVESETPROPERTY(obj, 0, 0, itemKey, 256, itemValue, 256) PRINT *, "Key: ", itemKey PRINT *, "Value: ", itemValue CALL XDMFRETRIEVESETPROPERTYBYKEY(obj, 0, itemKey, itemValue, 256) PRINT *, "Value: ", itemValue CALL XDMFRETRIEVESETTYPE(obj, 0, typeHolder) PRINT *, 'Set Type: ', typeHolder CALL XDMFRETRIEVESETVALUETYPE(obj, 0, typeHolder) PRINT *, 'Set Value Type: ', typeHolder CALL XDMFRETRIEVESETNAME(obj, 0, itemName, 256) PRINT *, 'Set Name: ', itemName CALL XDMFRETRIEVESETTAG(obj, 0, itemTag, 256) PRINT *, 'Set Tag: ', itemTag CALL XDMFRETRIEVESETVALUES(obj, 0, mySetOutput, XDMF_ARRAY_TYPE_FLOAT64, 12, 0, 1, 1) PRINT 3, mySetOutput PRINT *, '\nAttribute 0' CALL XDMFRETRIEVEATTRIBUTENAME(obj, 0, itemName, 256) PRINT *, 'Attribute Name: ', itemName CALL XDMFRETRIEVEATTRIBUTENUMPROPERTIES(obj, 0, numContained) PRINT *, "Number of Properties: ", numContained CALL XDMFRETRIEVEATTRIBUTEPROPERTY(obj, 0, 0, itemKey, 256, itemValue, 256) PRINT *, "Key: ", itemKey PRINT *, "Value: ", itemValue CALL XDMFRETRIEVEATTRIBUTEPROPERTYBYKEY(obj, 0, itemKey, itemValue, 256) PRINT *, "Value: ", itemValue CALL XDMFRETRIEVEATTRIBUTETAG(obj, 0, itemTag, 256) PRINT *, 'Attribute Tag: ', itemTag CALL XDMFRETRIEVEATTRIBUTETYPE(obj, 0, typeHolder) PRINT *, 'Attribute Type: ', typeHolder CALL XDMFRETRIEVEATTRIBUTECENTER(obj, 0, typeHolder) PRINT *, 'Attribute Center: ', typeHolder CALL XDMFRETRIEVEATTRIBUTEVALUETYPE(obj, 0, typeHolder) PRINT *, 'Attribute Value Type: ', typeHolder CALL XDMFRETRIEVEATTRIBUTESIZE(obj, 0, numContained) PRINT *, 'Number of Values: ', numContained CALL XDMFRETRIEVEATTRIBUTEVALUES(obj, 0, myNodeAttributeOutput, XDMF_ARRAY_TYPE_FLOAT64, 12, 0, 1, 1) PRINT 3, myNodeAttributeOutput 3 FORMAT (' ', 3F6.1) CALL XDMFOPENATTRIBUTE(obj, 0) CALL XDMFRETRIEVENUMINFORMATION(obj, numContained) PRINT *, 'Number of Information for Grid and Attribute 0: ', numContained PRINT *, 'Information 0' CALL XDMFRETRIEVEINFORMATIONNUMPROPERTIES(obj, 0, numContained) PRINT *, "Number of Properties: ", numContained CALL XDMFRETRIEVEINFORMATIONPROPERTY(obj, 0, 0, itemKey, 256, itemValue, 256) PRINT *, "Key: ", itemKey PRINT *, "Value: ", itemValue CALL XDMFRETRIEVEINFORMATIONPROPERTYBYKEY(obj, 0, itemKey, itemValue, 256) PRINT *, "Value: ", itemValue CALL XDMFRETRIEVEINFORMATIONTAG(obj, 0, itemTag, 256) PRINT *, 'Information Tag: ', itemTag CALL XDMFRETRIEVEINFORMATION(obj, 1, itemKey, 256, itemValue, 256) PRINT *, 'Key: ', itemKey PRINT *, 'Value: ', itemValue CALL XDMFRETRIEVEINFORMATIONBYKEY(obj, itemKey, itemValue, 256) PRINT *, 'Value: ', itemValue PRINT *, '\nAttribute 1' CALL XDMFRETRIEVEATTRIBUTENUMPROPERTIES(obj, 1, numContained) PRINT *, "Number of Properties: ", numContained CALL XDMFRETRIEVEATTRIBUTEPROPERTY(obj, 1, 0, itemKey, 256, itemValue, 256) PRINT *, "Key: ", itemKey PRINT *, "Value: ", itemValue CALL XDMFRETRIEVEATTRIBUTEPROPERTYBYKEY(obj, 1, itemKey, itemValue, 256) PRINT *, "Value: ", itemValue CALL XDMFRETRIEVEATTRIBUTENAME(obj, 1, itemName, 256) PRINT *, 'Attribute Name: ', itemName CALL XDMFRETRIEVEATTRIBUTETAG(obj, 1, itemTag, 256) PRINT *, 'Attribute Tag: ', itemTag CALL XDMFRETRIEVEATTRIBUTETYPE(obj, 1, typeHolder) PRINT *, 'Attribute Type: ', typeHolder CALL XDMFRETRIEVEATTRIBUTECENTER(obj, 1, typeHolder) PRINT *, 'Attribute Center: ', typeHolder CALL XDMFRETRIEVEATTRIBUTEVALUETYPE(obj, 1, typeHolder) PRINT *, 'Attribute Value Type: ', typeHolder CALL XDMFRETRIEVEATTRIBUTESIZE(obj, 1, numContained) PRINT *, 'Number of Values: ', numContained CALL XDMFRETRIEVEATTRIBUTEVALUES(obj, 1, myCellAttributeOutput, XDMF_ARRAY_TYPE_FLOAT64, 4, 0, 1, 1) PRINT 4, myCellAttributeOutput 4 FORMAT (' ', F6.1) CALL XDMFOPENATTRIBUTE(obj, 1) CALL XDMFRETRIEVENUMINFORMATION(obj, numContained) PRINT *, 'Number of Information for Grid and Attribute 0: ', numContained PRINT *, 'Information 0' CALL XDMFRETRIEVEINFORMATIONNUMPROPERTIES(obj, 0, numContained) PRINT *, "Number of Properties: ", numContained CALL XDMFRETRIEVEINFORMATIONPROPERTY(obj, 0, 0, itemKey, 256, itemValue, 256) PRINT *, "Key: ", itemKey PRINT *, "Value: ", itemValue CALL XDMFRETRIEVEINFORMATIONPROPERTYBYKEY(obj, 0, itemKey, itemValue, 256) PRINT *, "Value: ", itemValue CALL XDMFRETRIEVEINFORMATIONTAG(obj, 0, itemTag, 256) PRINT *, 'Information Tag: ', itemTag CALL XDMFRETRIEVEINFORMATION(obj, 0, itemKey, 256, itemValue, 256) PRINT *, 'Key: ', itemKey PRINT *, 'Value: ', itemValue CALL XDMFRETRIEVEINFORMATIONBYKEY(obj, itemKey, itemValue, 256) PRINT *, 'Key: ', itemKey PRINT *, 'Value: ', itemValue CALL XDMFCLEARINFORMATIONS(obj) CALL XDMFCLEARATTRIBUTES(obj) CALL XDMFREPLACESET(obj, 0, 'EditedSet'//CHAR(0), XDMF_SET_TYPE_NODE, mySetOutput, 12, XDMF_ARRAY_TYPE_FLOAT64) PRINT *, 'Set Edited' CALL XDMFOPENGRIDCOLLECTIONGRID(obj, XDMF_GRID_TYPE_UNSTRUCTURED, 0, 0, 1, 0, 0) CALL XDMFREPLACEATTRIBUTE(obj, 1, 'Edited Attribute'//CHAR(0), XDMF_ATTRIBUTE_CENTER_NODE, XDMF_ATTRIBUTE_TYPE_SCALAR, & 4, XDMF_ARRAY_TYPE_FLOAT64, myNodeAttributeOutput) CALL XDMFOPENGRIDCOLLECTIONGRID(obj, XDMF_GRID_TYPE_UNSTRUCTURED, 0, 0, 0, 1, 0) CALL XDMFREPLACEINFORMATION(obj, 0, 'Edited Key'//CHAR(0), 'Edited Value'//CHAR(0)) CALL XDMFREPLACEGRIDCOLLECTIONGRID(obj, XDMF_GRID_TYPE_UNSTRUCTURED, 0, 'Edited Grid'//CHAR(0)) PRINT *, 'Grid Replaced' CALL XDMFWRITE(obj, outfilename, 10, .TRUE.) CALL XDMFCLOSE(obj) END PROGRAM XdmfFortranExample xdmf-3.0+git20160803/utils/tests/Fortran/OutputTestXdmfFortran.f900000640000175000017500000001661213003006557024650 0ustar alastairalastair!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! !! AUTHOR: Kenneth Leiter (kenneth.leiter@arl.army.mil) !! !! Use the Xdmf Fortran Bindings to write out a simple mesh consisting of !! two hexahedrons. Link against the XdmfUtils library to compile. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! PROGRAM XdmfFortranExample Implicit none INCLUDE 'Xdmf.f' INTEGER*8 obj character*256 filename REAL*4 myPoints(3,3,4) INTEGER myConnections(8,2), myDimensions(3) REAL*8 myCellAttribute(2), myNodeAttribute(3,4), mySmallerNode(3,2), myTime, myOrigin(3), myBrick(3) INTEGER nodeAttributeId, nodeSmallAttributeId, cellAttributeId, testSetID, testMapID, tempID filename = 'my_output.xmf'//CHAR(0) myPoints(1,1,1) = 0 myPoints(2,1,1) = 0 myPoints(3,1,1) = 1 myPoints(1,2,1) = 1 myPoints(2,2,1) = 0 myPoints(3,2,1) = 1 myPoints(1,3,1) = 3 myPoints(2,3,1) = 0 myPoints(3,3,1) = 2 myPoints(1,1,2) = 0 myPoints(2,1,2) = 1 myPoints(3,1,2) = 1 myPoints(1,2,2) = 1 myPoints(2,2,2) = 1 myPoints(3,2,2) = 1 myPoints(1,3,2) = 3 myPoints(2,3,2) = 2 myPoints(3,3,2) = 2 myPoints(1,1,3) = 0 myPoints(2,1,3) = 0 myPoints(3,1,3) = -1 myPoints(1,2,3) = 1 myPoints(2,2,3) = 0 myPoints(3,2,3) = -1 myPoints(1,3,3) = 3 myPoints(2,3,3) = 0 myPoints(3,3,3) = -2 myPoints(1,1,4) = 0 myPoints(2,1,4) = 1 myPoints(3,1,4) = -1 myPoints(1,2,4) = 1 myPoints(2,2,4) = 1 myPoints(3,2,4) = -1 myPoints(1,3,4) = 3 myPoints(2,3,4) = 2 myPoints(3,3,4) = -2 myConnections(1,1) = 0 myConnections(2,1) = 1 myConnections(3,1) = 7 myConnections(4,1) = 6 myConnections(5,1) = 3 myConnections(6,1) = 4 myConnections(7,1) = 10 myConnections(8,1) = 9 myConnections(1,2) = 1 myConnections(2,2) = 2 myConnections(3,2) = 8 myConnections(4,2) = 7 myConnections(5,2) = 4 myConnections(6,2) = 5 myConnections(7,2) = 11 myConnections(8,2) = 10 myNodeAttribute(1,1) = 100 myNodeAttribute(1,2) = 300 myNodeAttribute(1,3) = 300 myNodeAttribute(1,4) = 500 myNodeAttribute(2,1) = 200 myNodeAttribute(2,2) = 400 myNodeAttribute(2,3) = 400 myNodeAttribute(2,4) = 600 myNodeAttribute(3,1) = 300 myNodeAttribute(3,2) = 500 myNodeAttribute(3,3) = 500 myNodeAttribute(3,4) = 700 myCellAttribute(1) = 100 myCellAttribute(2) = 200 myDimensions(1) = 12 myDimensions(2) = 12 myDimensions(3) = 12 myOrigin(1) = 0 myOrigin(2) = 0 myOrigin(3) = 0 myBrick(1) = 12 myBrick(2) = 12 myBrick(3) = 12 myTime = 1.0 CALL XDMFINIT(obj, filename) CALL XDMFSETMAXFILESIZE(obj, 1) CALL XDMFSETALLOWSETSPLITTING(obj, .TRUE.) CALL XDMFINITHDF5(obj, 'my_output.h5'//CHAR(0), .TRUE.) tempID = XDMFADDINFORMATION(obj, 'GridCollection1'//CHAR(0), 'This is Grid collection 1'//CHAR(0)) CALL XDMFADDGRIDCOLLECTION(obj, "Temporal"//CHAR(0), & XDMF_GRID_COLLECTION_TYPE_TEMPORAL) CALL XDMFADDMAP(obj, "TestMap"//CHAR(0)) CALL XDMFADDREMOTENODEID(obj, 0, 1, 2, 3) CALL XDMFADDREMOTENODEID(obj, 0, 1, 2, 4) CALL XDMFADDREMOTENODEID(obj, 0, 1, 3, 3) CALL XDMFADDREMOTENODEID(obj, 0, 1, 3, 5) testMapID = XDMFSTOREMAP(obj, 0) CALL XDMFADDREMOTENODEID(obj, 0, 1, 3, 8) CALL XDMFSETTIME(obj, myTime) !! Unstructured Only tempID = XDMFSETTOPOLOGY(obj, XDMF_TOPOLOGY_TYPE_HEXAHEDRON, 16, & XDMF_ARRAY_TYPE_INT32, myConnections, 0) CALL XDMFSETTOPOLOGYHDF5(obj, 'my_output.h5'//CHAR(0), 'Topology'//CHAR(0), 0, 1, 16, 16) !! /Unstructured Only !! Curvilinear and Rectilinear Only tempID = XDMFSETDIMENSIONS(obj, 3, XDMF_ARRAY_TYPE_INT32, myDimensions) CALL XDMFSETDIMENSIONSHDF5(obj, 'my_output.h5'//CHAR(0), 'Dimensions'//CHAR(0), 0, 1, 3, 3) !! /Curvilinear and Rectilinear Only !! Unstructured and Curvilinear Only tempID = XDMFSETGEOMETRY(obj, XDMF_GEOMETRY_TYPE_XYZ, 36, & XDMF_ARRAY_TYPE_FLOAT32, myPoints) CALL XDMFSETGEOMETRYHDF5(obj, 'my_output.h5'//CHAR(0), 'Geometry'//CHAR(0), 0, 1, 36, 36) !! /Unstructured and Curvilinear Only !! Rectilinear Only tempID = XDMFADDCOORDINATE(obj, "XCoordinates"//CHAR(0), 12, XDMF_ARRAY_TYPE_FLOAT32, myPoints(1,1,1)) tempID = XDMFADDCOORDINATE(obj, "YCoordinates"//CHAR(0), 12, XDMF_ARRAY_TYPE_FLOAT32, myPoints(1,2,2)) tempID = XDMFADDCOORDINATE(obj, "ZCoordinates"//CHAR(0), 12, XDMF_ARRAY_TYPE_FLOAT32, myPoints(1,3,3)) CALL XDMFSETCOORDINATEHDF5(obj, 0, 'my_output.h5'//CHAR(0), 'XCoordinate'//CHAR(0), 0, 1, 12, 12) CALL XDMFSETCOORDINATEHDF5(obj, 1, 'my_output.h5'//CHAR(0), 'YCoordinate'//CHAR(0), 0, 1, 12, 12) CALL XDMFSETCOORDINATEHDF5(obj, 2, 'my_output.h5'//CHAR(0), 'ZCoordinate'//CHAR(0), 0, 1, 12, 12) !! /Rectilinear Only !! Regular Only tempID = XDMFSETORIGIN(obj, 3, XDMF_ARRAY_TYPE_FLOAT64, myOrigin) CALL XDMFSETORIGINHDF5(obj, 'my_output.h5'//CHAR(0), 'Origin'//CHAR(0), 0, 1, 3, 3) tempID = XDMFSETBRICK(obj, 3, XDMF_ARRAY_TYPE_FLOAT64, myBrick) CALL XDMFSETBRICKHDF5(obj, 'my_output.h5'//CHAR(0), 'Brick'//CHAR(0), 0, 1, 3, 3) !! /Regular Only testSetID = XDMFADDSET(obj, 'TestSet'//CHAR(0), XDMF_SET_TYPE_NODE, myNodeAttribute, 12, XDMF_ARRAY_TYPE_FLOAT64) tempID = XDMFADDINFORMATION(obj, 'Attrib1'//CHAR(0), 'This is Attribute 1'//CHAR(0)) nodeAttributeId = XDMFADDATTRIBUTE(obj, 'NodeValues'//CHAR(0), & XDMF_ATTRIBUTE_CENTER_NODE, XDMF_ATTRIBUTE_TYPE_SCALAR, 12, & XDMF_ARRAY_TYPE_FLOAT64, myNodeAttribute) CALL XDMFSETATTRIBUTEHDF5(obj, 0, 'my_output.h5'//CHAR(0), 'NodeAttr'//CHAR(0), 0, 1, 12, 12) PRINT *, 'Node Attribute ID: ', nodeAttributeId CALL XDMFRETRIEVEATTRIBUTEVALUES(obj, 0, mySmallerNode, XDMF_ARRAY_TYPE_FLOAT64, 6, 0, 1, 1) tempID = XDMFADDINFORMATION(obj, 'Attrib2'//CHAR(0), 'This is Attribute 2'//CHAR(0)) cellAttributeId = XDMFADDATTRIBUTE(obj, 'CellValues'//CHAR(0), & XDMF_ATTRIBUTE_CENTER_CELL, XDMF_ATTRIBUTE_TYPE_SCALAR, 2, & XDMF_ARRAY_TYPE_FLOAT64, myCellAttribute) CALL XDMFSETATTRIBUTEHDF5(obj, 1, 'my_output.h5'//CHAR(0), 'CellAttr'//CHAR(0), 0, 1, 2, 2) PRINT *, 'Cell Attribute ID: ', cellAttributeId nodeSmallAttributeId = XDMFADDATTRIBUTE(obj, 'SmallNodeValues'//CHAR(0), & XDMF_ATTRIBUTE_CENTER_NODE, XDMF_ATTRIBUTE_TYPE_SCALAR, 6, & XDMF_ARRAY_TYPE_FLOAT64, mySmallerNode) CALL XDMFSETATTRIBUTEHDF5(obj, 2, 'my_output.h5'//CHAR(0), 'SmallNodeAttr'//CHAR(0), 0, 1, 6, 6) PRINT *, 'Node Attribute ID: ', nodeSmallAttributeId tempID = XDMFADDINFORMATION(obj, 'Grid1'//CHAR(0), 'This is Grid 1'//CHAR(0)) tempID = XDMFADDINFORMATION(obj, 'SubInformation'//CHAR(0), 'This is an information inside an information'//CHAR(0)) CALL XDMFADDINFORMATIONARRAY(obj, 1, 'Array'//CHAR(0), myBrick, 3, XDMF_ARRAY_TYPE_FLOAT64) CALL XDMFMODIFYINFORMATIONARRAY(obj, 1, 0, myBrick, XDMF_ARRAY_TYPE_FLOAT64, 3, 3, 1, 1) CALL XDMFSETINFORMATIONARRAYHDF5(obj, 1, 0, 'my_output.h5'//CHAR(0), 'Info Array'//CHAR(0), 0, 1, 3, 3) CALL XDMFINSERTINFORMATIONINTOINFORMATION(obj, 0, 1, .TRUE.) CALL XDMFADDGRID(obj, 'TestGrid'//CHAR(0), .FALSE.) myTime = 2.0 CALL XDMFSETTIME(obj, myTime) CALL XDMFADDPREVIOUSATTRIBUTE(obj, cellAttributeId) CALL XDMFADDPREVIOUSMAP(obj, testMapID) CALL XDMFADDPREVIOUSSET(obj, testSetID) CALL XDMFADDPREVIOUSATTRIBUTE(obj, nodeAttributeId) CALL XDMFADDGRID(obj, 'Identical'//CHAR(0), .FALSE.) CALL XDMFCLOSEGRIDCOLLECTION(obj, .TRUE.) !! CALL XDMFWRITEHDF5(obj, 'my_output.h5'//CHAR(0), .TRUE.) CALL XDMFWRITE(obj, filename, 10, .TRUE.) CALL XDMFCLOSE(obj) END PROGRAM XdmfFortranExample xdmf-3.0+git20160803/utils/tests/Fortran/NestedInfoFortran.f900000640000175000017500000000265713003006557023733 0ustar alastairalastair!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! !! AUTHOR: Andrew Burns (andrew.j.burns2@us.army.mil) !! !! Use the Xdmf Fortran Bindings to write out several links to !! data structures in different files. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! PROGRAM XdmfFortranExample Implicit none INCLUDE 'Xdmf.f' INTEGER*8 obj character*256 filename INTEGER tempID; filename = 'nested_output.xmf'//CHAR(0) CALL XDMFINIT(obj, filename) tempID = XDMFADDINFORMATION(obj, 'XIncludes'//CHAR(0), '3'//CHAR(0)) tempID = XDMFADDINFORMATION(obj, "testoutput.xmf"//CHAR(0), "xpointer(//Xdmf/Domain/Grid[1])"//CHAR(0)) tempID = XDMFADDINFORMATION(obj, "testoutput2.xmf"//CHAR(0), "xpointer(//Xdmf/Domain/Grid[1])"//CHAR(0)) tempID = XDMFADDINFORMATION(obj, "editedtestoutput.xmf"//CHAR(0), "xpointer(//Xdmf/Domain/Grid[1])"//CHAR(0)) CALL XDMFINSERTINFORMATIONINTOINFORMATION(obj, 0, 1, .TRUE.) CALL XDMFINSERTINFORMATIONINTOINFORMATION(obj, 0, 1, .TRUE.) CALL XDMFINSERTINFORMATIONINTOINFORMATION(obj, 0, 1, .TRUE.) !! The Information will be added to the Grid Collection CALL XDMFADDGRIDCOLLECTION(obj, "MultiFile Reference"//CHAR(0), & XDMF_GRID_COLLECTION_TYPE_TEMPORAL) CALL XDMFCLOSEGRIDCOLLECTION(obj, .TRUE.) CALL XDMFWRITE(obj, filename, 10, .TRUE.) CALL XDMFCLOSE(obj) END PROGRAM XdmfFortranExample xdmf-3.0+git20160803/utils/tests/Fortran/SubsetTestXdmfFortran.f900000640000175000017500000001231513003006557024611 0ustar alastairalastair!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! !! AUTHOR: Kenneth Leiter (kenneth.leiter@arl.army.mil) !! !! Use the Xdmf Fortran Bindings to write out a simple mesh consisting of !! two hexahedrons. Link against the XdmfUtils library to compile. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! PROGRAM XdmfFortranExample Implicit none INCLUDE 'Xdmf.f' INTEGER*8 obj character*256 filename REAL*4 myPoints(3,3,4) INTEGER myConnections(8,2) REAL*8 myCellAttribute(2), myNodeAttribute(3,4), mySmallerNode(3,2), myTime INTEGER nodeAttributeId, nodeSmallAttributeId, cellAttributeId, testSetID, tempID, variableID(3) filename = 'subset_output.xmf'//CHAR(0) myPoints(1,1,1) = 0 myPoints(2,1,1) = 0 myPoints(3,1,1) = 1 myPoints(1,2,1) = 1 myPoints(2,2,1) = 0 myPoints(3,2,1) = 1 myPoints(1,3,1) = 3 myPoints(2,3,1) = 0 myPoints(3,3,1) = 2 myPoints(1,1,2) = 0 myPoints(2,1,2) = 1 myPoints(3,1,2) = 1 myPoints(1,2,2) = 1 myPoints(2,2,2) = 1 myPoints(3,2,2) = 1 myPoints(1,3,2) = 3 myPoints(2,3,2) = 2 myPoints(3,3,2) = 2 myPoints(1,1,3) = 0 myPoints(2,1,3) = 0 myPoints(3,1,3) = -1 myPoints(1,2,3) = 1 myPoints(2,2,3) = 0 myPoints(3,2,3) = -1 myPoints(1,3,3) = 3 myPoints(2,3,3) = 0 myPoints(3,3,3) = -2 myPoints(1,1,4) = 0 myPoints(2,1,4) = 1 myPoints(3,1,4) = -1 myPoints(1,2,4) = 1 myPoints(2,2,4) = 1 myPoints(3,2,4) = -1 myPoints(1,3,4) = 3 myPoints(2,3,4) = 2 myPoints(3,3,4) = -2 myConnections(1,1) = 0 myConnections(2,1) = 1 myConnections(3,1) = 7 myConnections(4,1) = 6 myConnections(5,1) = 3 myConnections(6,1) = 4 myConnections(7,1) = 10 myConnections(8,1) = 9 myConnections(1,2) = 1 myConnections(2,2) = 2 myConnections(3,2) = 8 myConnections(4,2) = 7 myConnections(5,2) = 4 myConnections(6,2) = 5 myConnections(7,2) = 11 myConnections(8,2) = 10 myNodeAttribute(1,1) = 100 myNodeAttribute(1,2) = 300 myNodeAttribute(1,3) = 300 myNodeAttribute(1,4) = 500 myNodeAttribute(2,1) = 200 myNodeAttribute(2,2) = 400 myNodeAttribute(2,3) = 400 myNodeAttribute(2,4) = 600 myNodeAttribute(3,1) = 300 myNodeAttribute(3,2) = 500 myNodeAttribute(3,3) = 500 myNodeAttribute(3,4) = 700 myCellAttribute(1) = 100 myCellAttribute(2) = 200 myTime = 1.0 CALL XDMFINIT(obj, filename) CALL XDMFADDGRIDCOLLECTION(obj, "Temporal"//CHAR(0), & XDMF_GRID_COLLECTION_TYPE_TEMPORAL) CALL XDMFSETTIME(obj, myTime) !! Create an InformationArrays to serve as a variable variableID(1) = XDMFADDINFORMATION(obj, 'Variable A'//CHAR(0), 'Initializes Variable A'//CHAR(0)) CALL XDMFADDINFORMATIONARRAY(obj, 0, 'Variable Definition A'//CHAR(0), myPoints, 36, XDMF_ARRAY_TYPE_FLOAT64) CALL XDMFSETINFORMATIONARRAYASVARIABLE(obj, 'A'//CHAR(0), 0, 0) variableID(2) = XDMFADDINFORMATION(obj, 'Variable B'//CHAR(0), 'Initializes Variable B'//CHAR(0)) CALL XDMFADDINFORMATIONARRAY(obj, 1, 'Variable Definition B'//CHAR(0), myConnections, 16, XDMF_ARRAY_TYPE_INT32) CALL XDMFSETINFORMATIONARRAYASVARIABLE(obj, 'B'//CHAR(0), 1, 0) variableID(3) = XDMFADDINFORMATION(obj, 'Variable C'//CHAR(0), 'Initializes Variable C'//CHAR(0)) CALL XDMFADDINFORMATIONARRAY(obj, 2, 'Variable Definition C'//CHAR(0), myNodeAttribute, 12, XDMF_ARRAY_TYPE_FLOAT64) CALL XDMFSETINFORMATIONARRAYASVARIABLE(obj, 'C'//CHAR(0), 2, 0) CALL XdmfClearInformations(obj) CALL XDMFADDPREVIOUSINFORMATION(obj, variableID(2)) CALL XDMFSETINFORMATIONARRAYASSUBSETREFERENCE(obj, 0, 0) CALL XdmfClearInformations(obj) tempID = XDMFSETSUBSETASTOPOLOGY(obj, 0, 1, 12, XDMF_TOPOLOGY_TYPE_HEXAHEDRON, 0) CALL XDMFADDPREVIOUSINFORMATION(obj, variableID(1)) CALL XDMFSETINFORMATIONARRAYASSUBSETREFERENCE(obj, 0, 0) CALL XdmfClearInformations(obj) tempID = XDMFSETSUBSETASGEOMETRY(obj, 0, 1, 36, XDMF_GEOMETRY_TYPE_XYZ) CALL XDMFADDPREVIOUSINFORMATION(obj, variableID(3)) CALL XDMFSETINFORMATIONARRAYASSUBSETREFERENCE(obj, 0, 0) CALL XdmfClearInformations(obj) testSetID = XDMFADDSUBSETASSET(obj, 0, 1, 12, 'TestSet'//CHAR(0), XDMF_SET_TYPE_NODE) tempID = XDMFADDINFORMATION(obj, 'Attrib1'//CHAR(0), 'This is Attribute 1'//CHAR(0)) nodeAttributeId = XDMFADDSUBSETASATTRIBUTE(obj, 0, 1, 12, 'NodeValues'//CHAR(0), & XDMF_ATTRIBUTE_CENTER_NODE, XDMF_ATTRIBUTE_TYPE_SCALAR) CALL XDMFADDPREVIOUSINFORMATION(obj, variableID(1)) CALL XDMFSETINFORMATIONARRAYASSUBSETREFERENCE(obj, 0, 0) CALL XdmfClearInformations(obj) PRINT *, 'Node Attribute ID: ', nodeAttributeId tempID = XDMFADDINFORMATION(obj, 'Grid1'//CHAR(0), 'This is Grid 1'//CHAR(0)) tempID = XDMFADDINFORMATION(obj, 'SubInformation'//CHAR(0), 'This is an information inside an information'//CHAR(0)) CALL XDMFADDSUBSETASINFORMATIONARRAY(obj, 0, 1, 36, 1, 'Array'//CHAR(0)) CALL XDMFINSERTINFORMATIONINTOINFORMATION(obj, 0, 1, .TRUE.) CALL XDMFADDPREVIOUSINFORMATION(obj, variableID(1)) CALL XDMFADDPREVIOUSINFORMATION(obj, variableID(2)) CALL XDMFADDPREVIOUSINFORMATION(obj, variableID(3)) CALL XDMFADDGRID(obj, 'TestGrid'//CHAR(0), .FALSE.) CALL XDMFCLOSEGRIDCOLLECTION(obj, .TRUE.) CALL XDMFWRITE(obj, filename, 10, .TRUE.) CALL XDMFCLOSE(obj) END PROGRAM XdmfFortranExample xdmf-3.0+git20160803/utils/tests/Cxx/0000740000175000017500000000000013003006557017134 5ustar alastairalastairxdmf-3.0+git20160803/utils/tests/Cxx/TestXdmfDiff.cpp0000640000175000017500000001044713003006557022177 0ustar alastairalastair#include #include #include "XdmfArray.hpp" #include "XdmfArrayType.hpp" #include "XdmfAttribute.hpp" #include "XdmfAttributeCenter.hpp" #include "XdmfAttributeType.hpp" #include "XdmfDiff.hpp" #include "XdmfGeometry.hpp" #include "XdmfGeometryType.hpp" #include "XdmfGridCollection.hpp" #include "XdmfTopology.hpp" #include "XdmfTopologyConverter.hpp" #include "XdmfTopologyType.hpp" #include "XdmfUnstructuredGrid.hpp" #include "XdmfWriter.hpp" int main(int, char **) { shared_ptr grid1 = XdmfUnstructuredGrid::New(); shared_ptr topology1 = XdmfTopology::New(); int connectivity[] = {0, 1, 7, 6, 3, 4, 10, 9, 1, 2, 8, 7, 4, 5, 11, 10}; topology1->setType(XdmfTopologyType::Hexahedron()); topology1->insert(0, &connectivity[0], 16); grid1->setTopology(topology1); shared_ptr geometry1 = XdmfGeometry::New(); double points[] = {0.1, 0.1, 1.1, 1.1, 0.1, 1.1, 3.1, 0.1, 2.1, 0.1, 1.1, 1.1, 1.1, 1.1, 1.1, 3.1, 2.1, 2.1, 0.1, 0.1, -1.1, 1.1, 0.1, -1.1, 3.1, 0.1, -2.1, 0.1, 1.1, -1.1, 1.1, 1.1, -1.1, 3.1, 2.1, -2.1}; geometry1->setType(XdmfGeometryType::XYZ()); geometry1->insert(0, &points[0], 36); grid1->setGeometry(geometry1); shared_ptr attr1 = XdmfAttribute::New(); int nodeValues[] = {100, 200, 300, 300, 400, 500, 300, 400, 500, 500, 600, 700}; attr1->setName("Nodal Attribute"); attr1->setType(XdmfAttributeType::Scalar()); attr1->setCenter(XdmfAttributeCenter::Node()); attr1->insert(0, &nodeValues[0], 12); grid1->insert(attr1); // Grid with the same structure shared_ptr grid2 = XdmfUnstructuredGrid::New(); shared_ptr topology2 = XdmfTopology::New(); topology2->setType(XdmfTopologyType::Hexahedron()); topology2->insert(0, &connectivity[0], 16); grid2->setTopology(topology2); shared_ptr geometry2 = XdmfGeometry::New(); geometry2->setType(XdmfGeometryType::XYZ()); geometry2->insert(0, &points[0], 36); grid2->setGeometry(geometry2); shared_ptr attr2 = XdmfAttribute::New(); attr2->setName("Nodal Attribute"); attr2->setType(XdmfAttributeType::Scalar()); attr2->setCenter(XdmfAttributeCenter::Node()); attr2->insert(0, &nodeValues[0], 12); grid2->insert(attr2); // Grid with structure partially off, difference of 5. shared_ptr grid3 = XdmfUnstructuredGrid::New(); shared_ptr topology3 = XdmfTopology::New(); topology3->setType(XdmfTopologyType::Hexahedron()); topology3->insert(0, &connectivity[0], 16); grid3->setTopology(topology3); shared_ptr geometry3 = XdmfGeometry::New(); double pointsdiff[] = {4.1, 0.1, 1.1, 1.1, 0.1, 3.1, 3.1, 0.1, 2.1, 0.1, 1.1, 1.1, 1.1, 1.1, 1.1, 6.1, 2.1, 2.1, 0.1, 0.1, -1.1, 1.1, 0.1, -1.1, 3.1, 3.1, -4.1, 0.1, 1.1, -1.1, 1.1, 1.1, -1.1, 3.1, 2.1, -2.1}; geometry3->setType(XdmfGeometryType::XYZ()); geometry3->insert(0, &pointsdiff[0], 36); grid3->setGeometry(geometry3); shared_ptr attr3 = XdmfAttribute::New(); attr3->setName("Nodal Attribute"); attr3->setType(XdmfAttributeType::Scalar()); attr3->setCenter(XdmfAttributeCenter::Node()); attr3->insert(0, &nodeValues[0], 12); grid3->insert(attr3); // Make diff checks shared_ptr diff = XdmfDiff::New(); if (!diff->compare(grid1, grid2)) { std::cout << "equivalent grids are not compared correctly" << std::endl; } else { std::cout << "equivalent grids are compared correctly" << std::endl; } assert(diff->compare(grid1, grid2)); if (diff->compare(grid1, grid3)) { std::cout << "dissimilar grids are not compared correctly" << std::endl; } else { std::cout << "dissimilar grids are compared correctly" << std::endl; } assert(!diff->compare(grid1, grid3)); std::cout << "default tolerance = " << diff->getAbsoluteTolerance() << std::endl; diff->setAbsoluteTolerance(6); if (!diff->compare(grid1, grid3)) { std::cout << "tolerance is not applied correctly" << std::endl; } else { std::cout << "tolerance is applied correctly" << std::endl; } assert(diff->compare(grid1, grid3)); return 0; } xdmf-3.0+git20160803/utils/tests/Cxx/CMakeLists.txt0000640000175000017500000000254513003006557021704 0ustar alastairalastair# Add any dependencies that the cxx tests may need # Note: The tests already depend on their own file SET_PROPERTY(GLOBAL APPEND PROPERTY CXX_TEST_DEPENDENCIES "XdmfUtils") # Include XdmfTestDataGenerator from non-util tests include_directories(${CMAKE_SOURCE_DIR}/tests/Cxx/) # Include XdmfTestDataGenerator from non-util tests include_directories(${CMAKE_SOURCE_DIR}/tests/Cxx/) # Include our test macros include(AddTestsCxx) # Add any cxx tests here: # Note: We don't want to use a foreach loop to test the files incase we # have extra arguments (id: ADD_TEST_CXX(testname inputfile)) # Read UseCxxTest.cmake for more information # --------------------------------------- ADD_TEST_CXX(TestXdmfDiff) ADD_TEST_CXX(TestXdmfGeometryConverter) ADD_TEST_CXX(TestXdmfTopologyConverter) if(XDMF_BUILD_EXODUS_IO) ADD_TEST_CXX(TestXdmfExodusIO) endif(XDMF_BUILD_EXODUS_IO) # Add any cxx cleanup here: # Note: We don't want to use a foreach loop to test the files incase we # have multiple files (ie: CLEAN_TEST_CXX(testname outputfile1 ...)) # Read UseCxxTest.cmake for more information # --------------------------------------- CLEAN_TEST_CXX(TestXdmfDiff) CLEAN_TEST_CXX(TestXdmfGeometryConverter) CLEAN_TEST_CXX(TestXdmfTopologyConverter) if(XDMF_BUILD_EXODUS_IO) CLEAN_TEST_CXX(TestXdmfExodusIO TestXdmfExodusIO.exo) endif(XDMF_BUILD_EXODUS_IO) xdmf-3.0+git20160803/utils/tests/Cxx/TestXdmfTopologyConverter.cpp0000640000175000017500000001635513003006557025037 0ustar alastairalastair#include #include #include "XdmfArray.hpp" #include "XdmfArrayType.hpp" #include "XdmfGeometry.hpp" #include "XdmfGeometryType.hpp" #include "XdmfTopology.hpp" #include "XdmfTopologyConverter.hpp" #include "XdmfTopologyType.hpp" #include "XdmfUnstructuredGrid.hpp" #include "XdmfWriter.hpp" int main(int, char **) { shared_ptr converter = XdmfTopologyConverter::New(); // Create Hexahedron Grid shared_ptr hexGrid = XdmfUnstructuredGrid::New(); double hexPoints[24] = {0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1}; hexGrid->getGeometry()->setType(XdmfGeometryType::XYZ()); hexGrid->getGeometry()->resize(24, 0); hexGrid->getGeometry()->insert(0, hexPoints, 24); unsigned int hexConn[8] = {0, 1, 2, 3, 4, 5, 6, 7}; hexGrid->getTopology()->setType(XdmfTopologyType::Hexahedron()); hexGrid->getTopology()->resize(8, 0); hexGrid->getTopology()->insert(0, hexConn, 8); /* * Hexahedron to Hexahedron_64 */ shared_ptr hex64Grid = converter->convert(hexGrid, XdmfTopologyType::Hexahedron_64()); assert(hex64Grid->getGeometry()->getType() == XdmfGeometryType::XYZ()); assert(hex64Grid->getGeometry()->getNumberPoints() == 64); assert(hex64Grid->getTopology()->getType() == XdmfTopologyType::Hexahedron_64()); assert(hex64Grid->getTopology()->getNumberElements() == 1); for(unsigned int i=0; i<64; ++i) { assert(i == hex64Grid->getTopology()->getValue(i)); } /* * Hexahedron to Hexahedron_125 */ shared_ptr hex125Grid = converter->convert(hexGrid, XdmfTopologyType::Hexahedron_125()); assert(hex125Grid->getGeometry()->getType() == XdmfGeometryType::XYZ()); assert(hex125Grid->getGeometry()->getNumberPoints() == 125); assert(hex125Grid->getTopology()->getType() == XdmfTopologyType::Hexahedron_125()); assert(hex125Grid->getTopology()->getNumberElements() == 1); for(unsigned int i=0; i<125; ++i) { assert(i == hex125Grid->getTopology()->getValue(i)); } /* * Hexahedron_64 to Hexahedron */ shared_ptr newHexGrid = converter->convert(hex64Grid, XdmfTopologyType::Hexahedron()); assert(newHexGrid->getGeometry()->getType() == XdmfGeometryType::XYZ()); assert(newHexGrid->getGeometry()->getNumberPoints() == 64); assert(newHexGrid->getTopology()->getType() == XdmfTopologyType::Hexahedron()); assert(newHexGrid->getTopology()->getNumberElements() == 27); shared_ptr faceTopology; /** * Tetrahedron to Triangle */ shared_ptr tetTopology = XdmfTopology::New(); tetTopology->setType(XdmfTopologyType::Tetrahedron()); long tetValues[8] = {0, 1, 2, 3, 0, 1, 2, 4};// temporary tetTopology->insert(0, tetValues, 8); std::cout << "tetrahedrons prior to splitting into faces " << std::endl << tetTopology->getValuesString() << std::endl; faceTopology = converter->getExternalFaces(tetTopology); std::cout << "after splitting into faces" << std::endl << faceTopology->getValuesString() << std::endl; assert(faceTopology->getValuesString().compare("0 1 3 " "0 3 2 " "0 1 4 " "0 4 2 " "1 2 3 " "1 2 4") == 0); /** * Tetrahedron_10 to Triangle_6 */ shared_ptr tet10Topology = XdmfTopology::New(); tet10Topology->setType(XdmfTopologyType::Tetrahedron_10()); long tet10Values[20] = {0, 1, 2, 3, 5, 6, 7, 8, 9, 10, 0, 1, 2, 4, 9, 10, 11, 12, 13, 14};// temporary tet10Topology->insert(0, tet10Values, 20); std::cout << "tetrahedron_10s prior to splitting into faces " << std::endl << tet10Topology->getValuesString() << std::endl; faceTopology = converter->getExternalFaces(tet10Topology); std::cout << "after splitting into faces" << std::endl << faceTopology->getValuesString() << std::endl; assert(faceTopology->getValuesString().compare("0 1 3 5 9 8 " "0 3 2 8 10 7 " "0 1 4 9 13 12 " "0 4 2 12 14 11 " "1 2 3 6 10 9 " "1 2 4 10 14 13") == 0); /** * Hexahedron to Quadrilateral */ shared_ptr hexTopology = XdmfTopology::New(); hexTopology->setType(XdmfTopologyType::Hexahedron()); long hexValues[16] = {0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 8, 9, 10, 11};// temporary hexTopology->insert(0, hexValues, 16); std::cout << "Hexahedrons prior to splitting into faces " << std::endl << hexTopology->getValuesString() << std::endl; faceTopology = converter->getExternalFaces(hexTopology); std::cout << "after splitting into faces" << std::endl << faceTopology->getValuesString() << std::endl; assert(faceTopology->getValuesString().compare("0 1 5 4 " "0 4 7 3 " "0 1 9 8 " "0 8 11 3 " "1 2 6 5 " "1 2 10 9 " "2 3 7 6 " "2 3 11 10 " "4 5 6 7 " "8 9 10 11") == 0); /** * Hexahedron_20 to Quadrilateral_8 */ shared_ptr hex20Topology = XdmfTopology::New(); hex20Topology->setType(XdmfTopologyType::Hexahedron_20()); long hex20Values[40] = {0, 1, 2, 3, 4, 5, 6, 7, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 0, 1, 2, 3, 8, 9, 10, 11, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35};// temporary hex20Topology->insert(0, hex20Values, 40); std::cout << "Hexahedron_20s prior to splitting into faces " << std::endl << hex20Topology->getValuesString() << std::endl; faceTopology = converter->getExternalFaces(hex20Topology); std::cout << "after splitting into faces" << std::endl << faceTopology->getValuesString() << std::endl; assert(faceTopology->getValuesString().compare("0 1 5 4 12 21 16 20 " "0 4 7 3 20 19 23 15 " "0 1 9 8 24 33 28 32 " "0 8 11 3 32 31 35 27 " "1 2 6 5 13 22 17 21 " "1 2 10 9 25 34 29 33 " "2 3 7 6 14 23 18 22 " "2 3 11 10 26 35 30 34 " "4 5 6 7 16 17 18 19 " "8 9 10 11 28 29 30 31") == 0); return 0; } xdmf-3.0+git20160803/utils/tests/Cxx/TestXdmfExodusIO.cpp0000640000175000017500000000415313003006557023023 0ustar alastairalastair#include "XdmfDomain.hpp" #include "XdmfExodusReader.hpp" #include "XdmfExodusWriter.hpp" #include "XdmfHDF5Writer.hpp" #include "XdmfWriter.hpp" #include "XdmfTestDataGenerator.hpp" int main(int, char **) { shared_ptr exodusWriter = XdmfExodusWriter::New(); shared_ptr hexahedron = XdmfTestDataGenerator::createHexahedron(); exodusWriter->write("TestXdmfExodusIO.exo", hexahedron); shared_ptr reader = XdmfExodusReader::New(); shared_ptr grid = reader->read("TestXdmfExodusIO.exo"); assert(grid->getName() == hexahedron->getName()); assert(grid->getGeometry()->getType() == hexahedron->getGeometry()->getType()); assert(grid->getGeometry()->getNumberPoints() == hexahedron->getGeometry()->getNumberPoints()); for(unsigned int i=0; igetGeometry()->getSize(); ++i) { assert(grid->getGeometry()->getValue(i) == hexahedron->getGeometry()->getValue(i)); } assert(grid->getTopology()->getType() == hexahedron->getTopology()->getType()); assert(grid->getTopology()->getNumberElements() == hexahedron->getTopology()->getNumberElements()); for(unsigned int i=0; igetTopology()->getSize(); ++i) { assert(grid->getTopology()->getValue(i) == hexahedron->getTopology()->getValue(i)); } assert(hexahedron->getNumberAttributes() + 2 == grid->getNumberAttributes()); for(unsigned int i=0; igetNumberAttributes(); ++i) { shared_ptr attribute1 = hexahedron->getAttribute(i); if(attribute1->getCenter() != XdmfAttributeCenter::Grid()) { shared_ptr attribute2 = grid->getAttribute(attribute1->getName()); assert(attribute1->getCenter() == attribute2->getCenter()); assert(attribute1->getType() == attribute2->getType()); assert(attribute1->getSize() == attribute2->getSize()); for(unsigned int j=0; jgetSize(); ++j) { assert(attribute1->getValue(i) == attribute2->getValue(i)); } } } } xdmf-3.0+git20160803/utils/tests/Cxx/TestXdmfGeometryConverter.cpp0000640000175000017500000001074313003006557025011 0ustar alastairalastair#include #include #include #include "XdmfArray.hpp" #include "XdmfArrayType.hpp" #include "XdmfGeometry.hpp" #include "XdmfGeometryType.hpp" #include "XdmfGeometryConverter.hpp" #include "XdmfUnstructuredGrid.hpp" #include "XdmfWriter.hpp" double Pi = 3.1415926535897932384626433832795; int main(int, char **) { shared_ptr converter = XdmfGeometryConverter::New(); shared_ptr cartesianGeo = XdmfGeometry::New(); cartesianGeo->setType(XdmfGeometryType::XYZ()); for (unsigned int i = 0; i < 3; ++i) { cartesianGeo->pushBack(1); } shared_ptr resultSphericalGeo = converter->convertToSpherical(cartesianGeo); shared_ptr sphericalGeo = XdmfGeometry::New(); sphericalGeo->setType(XdmfGeometryType::Spherical()); sphericalGeo->pushBack(std::sqrt(3)); sphericalGeo->pushBack(std::asin(std::sqrt((double)2/3))); // should be equal to std::acos(1/std::sqrt(3)) // sphericalGeo->pushBack(std::acos(1/std::sqrt(3))); // should be equal to std::asin(std::sqrt((double)2/3)) sphericalGeo->pushBack(Pi/4); std::cout << "Tolerance 10^-15\nresult\n" << resultSphericalGeo->getValuesString() << "\n?=\ncompare to\n" << sphericalGeo->getValuesString() << std::endl; for (unsigned int i = 0; i < sphericalGeo->getSize(); ++i) { double val1 = resultSphericalGeo->getValue(i); double val2 = sphericalGeo->getValue(i); val1 = std::floor(val1 * std::pow((double)10, (double)15) + 0.5) / std::pow((double)10, (double)15); val2 = std::floor(val2 * std::pow((double)10, (double)15) + 0.5) / std::pow((double)10, (double)15); std::cout << std::fixed << std::setprecision(15) << val1 << " ?= " << std::fixed << std::setprecision(15) << val2 << std::endl; assert(val1 == val2); } shared_ptr resultCartesianGeo = converter->convertToCartesian(sphericalGeo); std::cout << resultCartesianGeo->getValuesString() << "\n?=\n" << cartesianGeo->getValuesString() << std::endl; for (unsigned int i = 0; i < cartesianGeo->getSize(); ++i) { double val1 = resultCartesianGeo->getValue(i); double val2 = cartesianGeo->getValue(i); val1 = std::floor(val1 * std::pow((double)10, (double)15) + 0.5) / std::pow((double)10, (double)15); val2 = std::floor(val2 * std::pow((double)10, (double)15) + 0.5) / std::pow((double)10, (double)15); std::cout << std::fixed << std::setprecision(15) << val1 << " ?= " << std::fixed << std::setprecision(15) << val2 << std::endl; assert(val1 == val2); } // Convert in place for geometries with a lot of references shared_ptr convertedToSpherical = XdmfGeometry::New(); convertedToSpherical->setType(XdmfGeometryType::XYZ()); for (unsigned int i = 0; i < 3; ++i) { convertedToSpherical->pushBack(1); } converter->convertToSphericalOverwrite(convertedToSpherical); for (unsigned int i = 0; i < sphericalGeo->getSize(); ++i) { double val1 = convertedToSpherical->getValue(i); double val2 = sphericalGeo->getValue(i); val1 = std::floor(val1 * std::pow((double)10, (double)15) + 0.5) / std::pow((double)10, (double)15); val2 = std::floor(val2 * std::pow((double)10, (double)15) + 0.5) / std::pow((double)10, (double)15); std::cout << std::fixed << std::setprecision(15) << val1 << " ?= " << std::fixed << std::setprecision(15) << val2 << std::endl; assert(val1 == val2); } shared_ptr convertedToCartesian = XdmfGeometry::New(); convertedToCartesian->setType(XdmfGeometryType::Spherical()); convertedToCartesian->pushBack(std::sqrt(3)); convertedToCartesian->pushBack(std::asin(std::sqrt((double)2/3))); // should be equal to std::acos(1/std::sqrt(3)) // sphericalGeo->pushBack(std::acos(1/std::sqrt(3))); // should be equal to std::asin(std::sqrt((double)2/3)) convertedToCartesian->pushBack(Pi/4); converter->convertToCartesianOverwrite(convertedToCartesian); for (unsigned int i = 0; i < cartesianGeo->getSize(); ++i) { double val1 = convertedToCartesian->getValue(i); double val2 = cartesianGeo->getValue(i); val1 = std::floor(val1 * std::pow((double)10, (double)15) + 0.5) / std::pow((double)10, (double)15); val2 = std::floor(val2 * std::pow((double)10, (double)15) + 0.5) / std::pow((double)10, (double)15); std::cout << std::fixed << std::setprecision(15) << val1 << " ?= " << std::fixed << std::setprecision(15) << val2 << std::endl; assert(val1 == val2); } return 0; } xdmf-3.0+git20160803/utils/tests/Python/0000740000175000017500000000000013003006557017653 5ustar alastairalastairxdmf-3.0+git20160803/utils/tests/Python/CMakeLists.txt0000640000175000017500000000226513003006557022422 0ustar alastairalastairinclude(AddTestsPython) # Add any dependencies that the python tests may need # Note: The tests already depend on their own file # PYTHON_TEST_DEPENDENCIES is also set in core ADD_TEST_PYTHON_DEPENDENCIES("") # Add any pythonpath directories that the python tests may need # Note: PYTHON_TEST_PYTHONPATH is also set in core ADD_TEST_PYTHON_PYTHONPATH("${PYTHON_INCLUDE_MPI4PY_DIR}/../..") # Add any python tests here: # Note: We don't want to use a foreach loop to test the files incase we # have extra arguments (ie: ADD_TEST_PYTHON(testname inputfile)) # Read UsePythonTest.cmake for more information # ----------------------- ADD_TEST_PYTHON(XdmfTestDiff) ADD_TEST_PYTHON(XdmfTestGeometryConverter) ADD_TEST_PYTHON(XdmfTestTopologyConverter) # Add any python cleanup here: # Note: We don't want to use a foreach loop to test the files incase we # have multiple files (ie: CLEAN_TEST_PYTHON(testname outputfile1 ...)) # Read UseCxxTest.cmake for more information # --------------------------------------- CLEAN_TEST_PYTHON(XdmfTestDiff) CLEAN_TEST_PYTHON(XdmfTestGeometryConverter) CLEAN_TEST_PYTHON(XdmfTestTopologyConverter) # Add a custom target for all python tests CREATE_TARGET_TEST_PYTHON() xdmf-3.0+git20160803/utils/tests/Python/XdmfTestDiff.py0000640000175000017500000000640613003006557022564 0ustar alastairalastairfrom Xdmf import * from XdmfUtils import * if __name__ == "__main__": grid1 = XdmfUnstructuredGrid.New() topology1 = XdmfTopology.New() connectivity = [0, 1, 7, 6, 3, 4, 10, 9, 1, 2, 8, 7, 4, 5, 11, 10] topology1.setType(XdmfTopologyType.Hexahedron()) topology1.insertAsInt32(0, connectivity, 0, 16, 1, 1) grid1.setTopology(topology1) geometry1 = XdmfGeometry.New(); points = [0.1, 0.1, 1.1, 1.1, 0.1, 1.1, 3.1, 0.1, 2.1, 0.1, 1.1, 1.1, 1.1, 1.1, 1.1, 3.1, 2.1, 2.1, 0.1, 0.1, -1.1, 1.1, 0.1, -1.1, 3.1, 0.1, -2.1, 0.1, 1.1, -1.1, 1.1, 1.1, -1.1, 3.1, 2.1, -2.1] geometry1.setType(XdmfGeometryType.XYZ()) geometry1.insertAsFloat64(0, points, 0, 36, 1, 1) grid1.setGeometry(geometry1) attr1 = XdmfAttribute.New() nodeValues = [100, 200, 300, 300, 400, 500, 300, 400, 500, 500, 600, 700] attr1.setName("Nodal Attribute") attr1.setType(XdmfAttributeType.Scalar()) attr1.setCenter(XdmfAttributeCenter.Node()) attr1.insertAsInt32(0, nodeValues, 0, 12, 1, 1) grid1.insert(attr1) # Grid with the same structure grid2 = XdmfUnstructuredGrid.New() topology2 = XdmfTopology.New() topology2.setType(XdmfTopologyType.Hexahedron()) topology2.insertAsInt32(0, connectivity, 0, 16, 1, 1) grid2.setTopology(topology2) geometry2 = XdmfGeometry.New() geometry2.setType(XdmfGeometryType.XYZ()) geometry2.insertAsFloat64(0, points, 0, 36, 1, 1) grid2.setGeometry(geometry2) attr2 = XdmfAttribute.New() attr2.setName("Nodal Attribute") attr2.setType(XdmfAttributeType.Scalar()) attr2.setCenter(XdmfAttributeCenter.Node()) attr2.insertAsInt32(0, nodeValues, 0, 12, 1, 1) grid2.insert(attr2) # Grid with structure partially off, difference of 5. grid3 = XdmfUnstructuredGrid.New() topology3 = XdmfTopology.New() topology3.setType(XdmfTopologyType.Hexahedron()); topology3.insertAsInt32(0, connectivity, 0, 16, 1, 1) grid3.setTopology(topology3) geometry3 = XdmfGeometry.New(); pointsdiff = [4.1, 0.1, 1.1, 1.1, 0.1, 3.1, 3.1, 0.1, 2.1, 0.1, 1.1, 1.1, 1.1, 1.1, 1.1, 6.1, 2.1, 2.1, 0.1, 0.1, -1.1, 1.1, 0.1, -1.1, 3.1, 3.1, -4.1, 0.1, 1.1, -1.1, 1.1, 1.1, -1.1, 3.1, 2.1, -2.1] geometry3.setType(XdmfGeometryType.XYZ()); geometry3.insertAsFloat64(0, pointsdiff, 0, 36, 1, 1); grid3.setGeometry(geometry3) attr3 = XdmfAttribute.New() attr3.setName("Nodal Attribute") attr3.setType(XdmfAttributeType.Scalar()) attr3.setCenter(XdmfAttributeCenter.Node()) attr3.insertAsInt32(0, nodeValues, 0, 12, 1, 1) grid3.insert(attr3) # Make diff checks diff = XdmfDiff.New() if not diff.compare(grid1, grid2): print "equivalent grids are not compared correctly" else: print "equivalent grids are compared correctly" assert(diff.compare(grid1, grid2)) if diff.compare(grid1, grid3): print "dissimilar grids are not compared correctly" else: print "dissimilar grids are compared correctly" assert(not diff.compare(grid1, grid3)) print "default tolerance = " , str(diff.getAbsoluteTolerance()) diff.setAbsoluteTolerance(6) if not diff.compare(grid1, grid3): print "tolerance is not applied correctly" else: print "tolerance is applied correctly" assert(diff.compare(grid1, grid3)) xdmf-3.0+git20160803/utils/tests/Python/XdmfTestGeometryConverter.py0000640000175000017500000000552213003006557025375 0ustar alastairalastairfrom Xdmf import * from XdmfUtils import * from math import * if __name__ == "__main__": Pi = 3.1415926535897932384626433832795 converter = XdmfGeometryConverter.New() cartesianGeo = XdmfGeometry.New() cartesianGeo.setType(XdmfGeometryType.XYZ()) for i in range(3): cartesianGeo.pushBackAsFloat64(1) resultSphericalGeo = converter.convertToSpherical(cartesianGeo) sphericalGeo = XdmfGeometry.New() sphericalGeo.setType(XdmfGeometryType.Spherical()) sphericalGeo.pushBackAsFloat64(sqrt(3)); sphericalGeo.pushBackAsFloat64(asin(sqrt(2.0/3.0))); # should be equal to acos(1/sqrt(3)) sphericalGeo.pushBackAsFloat64(Pi/4); print "Tolerance 10^-15\nresult\n" , resultSphericalGeo.getValuesString(), "\n?=\ncompare to\n", sphericalGeo.getValuesString() for i in range(sphericalGeo.getSize()): val1 = resultSphericalGeo.getValueAsFloat64(i) val2 = sphericalGeo.getValueAsFloat64(i) val1 = floor(val1 * pow(10.0, 15.0) + 0.5) / pow(10.0, 15.0); val2 = floor(val2 * pow(10.0, 15.0) + 0.5) / pow(10.0, 15.0); print val1, " ?= ", val2 assert(val1 == val2) resultCartesianGeo = converter.convertToCartesian(sphericalGeo) print resultCartesianGeo.getValuesString(), "\n?=\n", cartesianGeo.getValuesString() for i in range(cartesianGeo.getSize()): val1 = resultCartesianGeo.getValueAsFloat64(i); val2 = cartesianGeo.getValueAsFloat64(i); val1 = floor(val1 * pow(10.0, 15.0) + 0.5) / pow(10.0, 15.0) val2 = floor(val2 * pow(10.0, 15.0) + 0.5) / pow(10.0, 15.0) print val1, " ?= ", val2 assert(val1 == val2) # Convert in place for geometries with a lot of references convertedToSpherical = XdmfGeometry.New() convertedToSpherical.setType(XdmfGeometryType.XYZ()) for i in range(3): convertedToSpherical.pushBackAsFloat64(1) converter.convertToSphericalOverwrite(convertedToSpherical) for i in range(sphericalGeo.getSize()): val1 = convertedToSpherical.getValueAsFloat64(i) val2 = sphericalGeo.getValueAsFloat64(i) val1 = floor(val1 * pow(10.0, 15.0) + 0.5) / pow(10.0, 15.0) val2 = floor(val2 * pow(10.0, 15.0) + 0.5) / pow(10.0, 15.0) print val1, " ?= ", val2 assert(val1 == val2) convertedToCartesian = XdmfGeometry.New() convertedToCartesian.setType(XdmfGeometryType.Spherical()) convertedToCartesian.pushBackAsFloat64(sqrt(3)) convertedToCartesian.pushBackAsFloat64(asin(sqrt(2.0/3))) # should be equal to acos(1/sqrt(3)) convertedToCartesian.pushBackAsFloat64(Pi/4) converter.convertToCartesianOverwrite(convertedToCartesian) for i in range(cartesianGeo.getSize()): val1 = convertedToCartesian.getValueAsFloat64(i) val2 = cartesianGeo.getValueAsFloat64(i) val1 = floor(val1 * pow(10.0, 15.0) + 0.5) / pow(10.0, 15.0) val2 = floor(val2 * pow(10.0, 15.0) + 0.5) / pow(10.0, 15.0) print val1, " ?= ", val2 assert(val1 == val2) xdmf-3.0+git20160803/utils/tests/Python/XdmfTestTopologyConverter.py0000640000175000017500000001350413003006557025415 0ustar alastairalastairfrom Xdmf import * from XdmfUtils import * if __name__ == "__main__": converter = XdmfTopologyConverter.New() # Create Hexahedron Grid hexGrid = XdmfUnstructuredGrid.New(); hexPoints = [0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1] hexGrid.getGeometry().setType(XdmfGeometryType.XYZ()) hexGrid.getGeometry().resizeAsFloat64(24, 0) hexGrid.getGeometry().insertAsFloat64(0, hexPoints) hexConn = [0, 1, 2, 3, 4, 5, 6, 7] hexGrid.getTopology().setType(XdmfTopologyType.Hexahedron()) hexGrid.getTopology().resizeAsUInt32(8, 0) hexGrid.getTopology().insertAsUInt32(0, hexConn) # # Hexahedron to Hexahedron_64 # hex64Grid = converter.convert(hexGrid, XdmfTopologyType.Hexahedron_64()) assert(hex64Grid.getGeometry().getType() == XdmfGeometryType.XYZ()) assert(hex64Grid.getGeometry().getNumberPoints() == 64) assert(hex64Grid.getTopology().getType() == XdmfTopologyType.Hexahedron_64()) assert(hex64Grid.getTopology().getNumberElements() == 1) for i in range(64): assert(i == hex64Grid.getTopology().getValueAsUInt32(i)) # # Hexahedron to Hexahedron_125 # hex125Grid = converter.convert(hexGrid, XdmfTopologyType.Hexahedron_125()) assert(hex125Grid.getGeometry().getType() == XdmfGeometryType.XYZ()) assert(hex125Grid.getGeometry().getNumberPoints() == 125) assert(hex125Grid.getTopology().getType() == XdmfTopologyType.Hexahedron_125()) assert(hex125Grid.getTopology().getNumberElements() == 1) for i in range(125): assert(i == hex125Grid.getTopology().getValueAsUInt32(i)) # # Hexahedron_64 to Hexahedron # newHexGrid = converter.convert(hex64Grid, XdmfTopologyType.Hexahedron()) assert(newHexGrid.getGeometry().getType() == XdmfGeometryType.XYZ()); assert(newHexGrid.getGeometry().getNumberPoints() == 64); assert(newHexGrid.getTopology().getType() == XdmfTopologyType.Hexahedron()); assert(newHexGrid.getTopology().getNumberElements() == 27); # # Tetrahedron to Triangle # tetTopology = XdmfTopology.New() tetTopology.setType(XdmfTopologyType.Tetrahedron()) tetValues = [0, 1, 2, 3, 0, 1, 2, 4] # temporary tetTopology.insertAsInt64(0, tetValues) print "tetrahedrons prior to splitting into faces" print tetTopology.getValuesString() faceTopology = converter.getExternalFaces(tetTopology) print "after splitting into faces" print faceTopology.getValuesString() assert(faceTopology.getValuesString() == "0 1 3 " "0 3 2 " "0 1 4 " "0 4 2 " "1 2 3 " "1 2 4"); # # Tetrahedron_10 to Triangle_6 # tet10Topology = XdmfTopology.New() tet10Topology.setType(XdmfTopologyType.Tetrahedron_10()) tet10Values = [0, 1, 2, 3, 5, 6, 7, 8, 9, 10, 0, 1, 2, 4, 9, 10, 11, 12, 13, 14] # temporary tet10Topology.insertAsInt64(0, tet10Values); print "tetrahedron_10s prior to splitting into faces " print tet10Topology.getValuesString() faceTopology = converter.getExternalFaces(tet10Topology) print "after splitting into faces" print faceTopology.getValuesString() assert(faceTopology.getValuesString() == "0 1 3 5 9 8 " "0 3 2 8 10 7 " "0 1 4 9 13 12 " "0 4 2 12 14 11 " "1 2 3 6 10 9 " "1 2 4 10 14 13"); # # Hexahedron to Quadrilateral # hexTopology = XdmfTopology.New() hexTopology.setType(XdmfTopologyType.Hexahedron()) hexValues = [0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 8, 9, 10, 11] # temporary hexTopology.insertAsInt64(0, hexValues) print "Hexahedrons prior to splitting into faces" print hexTopology.getValuesString() faceTopology = converter.getExternalFaces(hexTopology) print "after splitting into faces" print faceTopology.getValuesString() assert(faceTopology.getValuesString() == "0 1 5 4 " "0 4 7 3 " "0 1 9 8 " "0 8 11 3 " "1 2 6 5 " "1 2 10 9 " "2 3 7 6 " "2 3 11 10 " "4 5 6 7 " "8 9 10 11") # # Hexahedron_20 to Quadrilateral_8 # hex20Topology = XdmfTopology.New() hex20Topology.setType(XdmfTopologyType.Hexahedron_20()) hex20Values = [0, 1, 2, 3, 4, 5, 6, 7, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 0, 1, 2, 3, 8, 9, 10, 11, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35] # temporary hex20Topology.insertAsInt64(0, hex20Values) print "Hexahedron_20s prior to splitting into faces" print hex20Topology.getValuesString() faceTopology = converter.getExternalFaces(hex20Topology) print "after splitting into faces" print faceTopology.getValuesString() assert(faceTopology.getValuesString() == "0 1 5 4 12 21 16 20 " "0 4 7 3 20 19 23 15 " "0 1 9 8 24 33 28 32 " "0 8 11 3 32 31 35 27 " "1 2 6 5 13 22 17 21 " "1 2 10 9 25 34 29 33 " "2 3 7 6 14 23 18 22 " "2 3 11 10 26 35 30 34 " "4 5 6 7 16 17 18 19 " "8 9 10 11 28 29 30 31") xdmf-3.0+git20160803/utils/tests/CMakeLists.txt0000640000175000017500000000047713003006557021144 0ustar alastairalastairadd_subdirectory(C) add_subdirectory(Cxx) if(XDMF_WRAP_PYTHON) add_subdirectory(Python) endif(XDMF_WRAP_PYTHON) # Fortran detection doesn't work properly for CMake # When BUILD_SHARED_LIBS is off if(XDMF_BUILD_FORTRAN AND BUILD_SHARED_LIBS) add_subdirectory(Fortran) endif(XDMF_BUILD_FORTRAN AND BUILD_SHARED_LIBS) xdmf-3.0+git20160803/utils/tests/C/0000740000175000017500000000000013003006557016554 5ustar alastairalastairxdmf-3.0+git20160803/utils/tests/C/CTestXdmfDiff.c0000640000175000017500000001221513003006557021355 0ustar alastairalastair#include #include "stdio.h" #include "string.h" #include "assert.h" #include "XdmfArray.hpp" #include "XdmfArrayType.hpp" #include "XdmfAttribute.hpp" #include "XdmfAttributeCenter.hpp" #include "XdmfAttributeType.hpp" #include "XdmfDiff.hpp" #include "XdmfGeometry.hpp" #include "XdmfGeometryType.hpp" #include "XdmfTopology.hpp" #include "XdmfTopologyConverter.hpp" #include "XdmfTopologyType.hpp" #include "XdmfUnstructuredGrid.hpp" #include "XdmfWriter.hpp" int main() { int status = 0; XDMFUNSTRUCTUREDGRID * grid1 = XdmfUnstructuredGridNew(); XDMFTOPOLOGY * topology1 = XdmfTopologyNew(); int connectivity[16] = {0, 1, 7, 6, 3, 4, 10, 9, 1, 2, 8, 7, 4, 5, 11, 10}; XdmfTopologySetType(topology1, XDMF_TOPOLOGY_TYPE_HEXAHEDRON, &status); XdmfTopologyInsertDataFromPointer(topology1, connectivity, XDMF_ARRAY_TYPE_INT32, 0, 16, 1, 1, &status); XdmfUnstructuredGridSetTopology(grid1, topology1, 1); XDMFGEOMETRY * geometry1 = XdmfGeometryNew(); double points[36] = {0.1, 0.1, 1.1, 1.1, 0.1, 1.1, 3.1, 0.1, 2.1, 0.1, 1.1, 1.1, 1.1, 1.1, 1.1, 3.1, 2.1, 2.1, 0.1, 0.1, -1.1, 1.1, 0.1, -1.1, 3.1, 0.1, -2.1, 0.1, 1.1, -1.1, 1.1, 1.1, -1.1, 3.1, 2.1, -2.1}; XdmfGeometrySetType(geometry1, XDMF_GEOMETRY_TYPE_XYZ, &status); XdmfGeometryInsertDataFromPointer(geometry1, points, XDMF_ARRAY_TYPE_FLOAT64, 0, 36, 1, 1, &status); XdmfUnstructuredGridSetGeometry(grid1, geometry1, 1); XDMFATTRIBUTE * attr1 = XdmfAttributeNew(); int nodeValues[12] = {100, 200, 300, 300, 400, 500, 300, 400, 500, 500, 600, 700}; XdmfAttributeSetName(attr1, "Nodal Attribute", &status); XdmfAttributeSetType(attr1, XDMF_ATTRIBUTE_TYPE_SCALAR, &status); XdmfAttributeSetCenter(attr1, XDMF_ATTRIBUTE_CENTER_NODE, &status); XdmfAttributeInsertDataFromPointer(attr1, nodeValues, XDMF_ARRAY_TYPE_INT32, 0, 12, 1, 1, &status); XdmfUnstructuredGridInsertAttribute(grid1, attr1, 1); // Grid with the same structure XDMFUNSTRUCTUREDGRID * grid2 = XdmfUnstructuredGridNew(); XDMFTOPOLOGY * topology2 = XdmfTopologyNew(); XdmfTopologySetType(topology2, XDMF_TOPOLOGY_TYPE_HEXAHEDRON, &status); XdmfTopologyInsertDataFromPointer(topology2, connectivity, XDMF_ARRAY_TYPE_INT32, 0, 16, 1, 1, &status); XdmfUnstructuredGridSetTopology(grid2, topology2, 1); XDMFGEOMETRY * geometry2 = XdmfGeometryNew(); XdmfGeometrySetType(geometry2, XDMF_GEOMETRY_TYPE_XYZ, &status); XdmfGeometryInsertDataFromPointer(geometry2, points, XDMF_ARRAY_TYPE_FLOAT64, 0, 36, 1, 1, &status); XdmfUnstructuredGridSetGeometry(grid2, geometry2, 1); XDMFATTRIBUTE * attr2 = XdmfAttributeNew(); XdmfAttributeSetName(attr2, "Nodal Attribute", &status); XdmfAttributeSetType(attr2, XDMF_ATTRIBUTE_TYPE_SCALAR, &status); XdmfAttributeSetCenter(attr2, XDMF_ATTRIBUTE_CENTER_NODE, &status); XdmfAttributeInsertDataFromPointer(attr2, nodeValues, XDMF_ARRAY_TYPE_INT32, 0, 12, 1, 1, &status); XdmfUnstructuredGridInsertAttribute(grid2, attr2, 1); // Grid with structure partially off, difference of 5. XDMFUNSTRUCTUREDGRID * grid3 = XdmfUnstructuredGridNew(); XDMFTOPOLOGY * topology3 = XdmfTopologyNew(); XdmfTopologySetType(topology3, XDMF_TOPOLOGY_TYPE_HEXAHEDRON, &status); XdmfTopologyInsertDataFromPointer(topology3, connectivity, XDMF_ARRAY_TYPE_INT32, 0, 16, 1, 1, &status); XdmfUnstructuredGridSetTopology(grid3, topology3, 1); XDMFGEOMETRY * geometry3 = XdmfGeometryNew(); double pointsdiff[36] = {4.1, 0.1, 1.1, 1.1, 0.1, 3.1, 3.1, 0.1, 2.1, 0.1, 1.1, 1.1, 1.1, 1.1, 1.1, 6.1, 2.1, 2.1, 0.1, 0.1, -1.1, 1.1, 0.1, -1.1, 3.1, 3.1, -4.1, 0.1, 1.1, -1.1, 1.1, 1.1, -1.1, 3.1, 2.1, -2.1}; XdmfGeometrySetType(geometry3, XDMF_GEOMETRY_TYPE_XYZ, &status); XdmfGeometryInsertDataFromPointer(geometry3, pointsdiff, XDMF_ARRAY_TYPE_FLOAT64, 0, 36, 1, 1, &status); XdmfUnstructuredGridSetGeometry(grid3, geometry3, 1); XDMFATTRIBUTE * attr3 = XdmfAttributeNew(); XdmfAttributeSetName(attr3, "Nodal Attribute", &status); XdmfAttributeSetType(attr3, XDMF_ATTRIBUTE_TYPE_SCALAR, &status); XdmfAttributeSetCenter(attr3, XDMF_ATTRIBUTE_CENTER_NODE, &status); XdmfAttributeInsertDataFromPointer(attr3, nodeValues, XDMF_ARRAY_TYPE_INT32, 0, 12, 1, 1, &status); XdmfUnstructuredGridInsertAttribute(grid3, attr3, 1); // Make diff checks XDMFDIFF * diff = XdmfDiffNew(); if (!XdmfDiffCompare(diff, (XDMFITEM *)grid1, (XDMFITEM *)grid2)) { printf("equivalent grids are not compared correctly\n"); } assert(XdmfDiffCompare(diff, (XDMFITEM *)grid1, (XDMFITEM *)grid2)); if (XdmfDiffCompare(diff, (XDMFITEM *)grid1, (XDMFITEM *)grid3)) { printf("dissimilar grids are not compared correctly\n"); } assert(!XdmfDiffCompare(diff, (XDMFITEM *)grid1, (XDMFITEM *)grid3)); printf("default tolerance = %lf\n", XdmfDiffGetAbsoluteTolerance(diff)); XdmfDiffSetAbsoluteTolerance(diff, 6); if (!XdmfDiffCompare(diff, (XDMFITEM *)grid1, (XDMFITEM *)grid3)) { printf("tolerance is not applied correctly\n"); } assert(XdmfDiffCompare(diff, (XDMFITEM *)grid1, (XDMFITEM *)grid3)); return 0; } xdmf-3.0+git20160803/utils/tests/C/CMakeLists.txt0000640000175000017500000000263013003006557021317 0ustar alastairalastair# Include our test macros include(AddTestsC) # Add any dependencies that the c core tests may need # Note: The tests already depend on their own file ADD_TEST_C_DEPENDENCIES("Xdmf") ADD_TEST_C_DEPENDENCIES("XdmfUtils") # Add any ldpath directories that the cxx tests may need ADD_TEST_C_LDPATH("${CMAKE_BINARY_DIR}") ADD_TEST_C_LDPATH("${XDMF_LIBRARY_DIRS}") # Add any path directoreis that the Cxx tests may need ADD_TEST_C_PATH("${CMAKE_BINARY_DIR}") ADD_TEST_C_PATH("${XDMF_BINARIES}") # Add any cxx tests here: # Note: We don't want to use a foreach loop to test the files incase we # have extra arguments (ie: ADD_TEST_C(testname inputfile)) # Read UseCxxTest.cmake for more information # --------------------------------------- if (XDMF_BUILD_EXODUS_IO) ADD_TEST_C(CTestXdmfExodusIO) endif (XDMF_BUILD_EXODUS_IO) ADD_TEST_C(CTestXdmfDiff) ADD_TEST_C(CTestXdmfGeometryConverter) ADD_TEST_C(CTestXdmfTopologyConverter) # Add any cxx cleanup here: # Note: We don't want to use a foreach loop to test the files incase we # have multiple files (ie: CLEAN_TEST_C(testname outputfile1 ...)) # Read UseCxxTest.cmake for more information # --------------------------------------- if (XDMF_BUILD_EXODUS_IO) CLEAN_TEST_C(CTestXdmfExodusIO TestXdmfExodusIO.exo) endif (XDMF_BUILD_EXODUS_IO) CLEAN_TEST_C(CTestXdmfDiff) CLEAN_TEST_C(CTestXdmfGeometryConverter) CLEAN_TEST_C(CTestXdmfTopologyConverter) xdmf-3.0+git20160803/utils/tests/C/CTestXdmfGeometryConverter.c0000640000175000017500000001146513003006557024176 0ustar alastairalastair#include "XdmfArray.hpp" #include "XdmfArrayType.hpp" #include "XdmfGeometry.hpp" #include "XdmfGeometryType.hpp" #include "XdmfGeometryConverter.hpp" #include "XdmfUnstructuredGrid.hpp" #include "XdmfWriter.hpp" #include "stdio.h" #include "math.h" #include "assert.h" double Pi = 3.1415926535897932384626433832795; int main() { int status = 0; unsigned int i = 0; XDMFGEOMETRYCONVERTER * converter = XdmfGeometryConverterNew(); XDMFGEOMETRY * cartesianGeo = XdmfGeometryNew(); XdmfGeometrySetType(cartesianGeo, XDMF_GEOMETRY_TYPE_XYZ, &status); for (i = 0; i < 3; ++i) { double pushval = 1; XdmfGeometryPushBack(cartesianGeo, &pushval, XDMF_ARRAY_TYPE_FLOAT64, &status); } XDMFGEOMETRY * resultSphericalGeo = XdmfGeometryConverterConvertToSpherical(converter, cartesianGeo); XDMFGEOMETRY * sphericalGeo = XdmfGeometryNew(); XdmfGeometrySetType(sphericalGeo, XDMF_GEOMETRY_TYPE_SPHERICAL, &status); double value = sqrt(3); XdmfGeometryPushBack(sphericalGeo, &value, XDMF_ARRAY_TYPE_FLOAT64, &status); value = asin(sqrt((double)2/3)); XdmfGeometryPushBack(sphericalGeo, &value, XDMF_ARRAY_TYPE_FLOAT64, &status); // should be equal to std::acos(1/std::sqrt(3)) value = Pi/4; XdmfGeometryPushBack(sphericalGeo, &value, XDMF_ARRAY_TYPE_FLOAT64, &status); printf("Tolerance 10^-15\nresult\n%s\n?=\ncompare to\n%s\n", XdmfGeometryGetValuesString(resultSphericalGeo), XdmfGeometryGetValuesString(sphericalGeo)); for (i = 0; i < XdmfGeometryGetSize(sphericalGeo); ++i) { double val1 = ((double *)XdmfGeometryGetValue(resultSphericalGeo, i, XDMF_ARRAY_TYPE_FLOAT64, &status))[0]; double val2 = ((double *)XdmfGeometryGetValue(sphericalGeo, i, XDMF_ARRAY_TYPE_FLOAT64, &status))[0]; val1 = floor(val1 * pow((double)10, (double)15) + 0.5) / pow((double)10, (double)15); val2 = floor(val2 * pow((double)10, (double)15) + 0.5) / pow((double)10, (double)15); printf("%4.15f ?= %4.15f\n", val1, val2); assert(val1 == val2); } XDMFGEOMETRY * resultCartesianGeo = XdmfGeometryConverterConvertToCartesian(converter, sphericalGeo); printf("%s\n?=\n%s\n", XdmfGeometryGetValuesString(resultCartesianGeo), XdmfGeometryGetValuesString(cartesianGeo)); for (i = 0; i < XdmfGeometryGetSize(cartesianGeo); ++i) { double val1 = ((double *)XdmfGeometryGetValue(resultCartesianGeo, i, XDMF_ARRAY_TYPE_FLOAT64, &status))[0]; double val2 = ((double *)XdmfGeometryGetValue(cartesianGeo, i, XDMF_ARRAY_TYPE_FLOAT64, &status))[0]; val1 = floor(val1 * pow((double)10, (double)15) + 0.5) / pow((double)10, (double)15); val2 = floor(val2 * pow((double)10, (double)15) + 0.5) / pow((double)10, (double)15); printf("%4.15f ?= %4.15f\n", val1, val2); assert(val1 == val2); } // Convert in place for geometries with a lot of references XDMFGEOMETRY * convertedToSpherical = XdmfGeometryNew(); XdmfGeometrySetType(convertedToSpherical, XDMF_GEOMETRY_TYPE_XYZ, &status); for (i = 0; i < 3; ++i) { double pushval = 1; XdmfGeometryPushBack(convertedToSpherical, &pushval, XDMF_ARRAY_TYPE_FLOAT64, &status); } XdmfGeometryConverterConvertToSphericalOverwrite(converter, convertedToSpherical); for (i = 0; i < XdmfGeometryGetSize(sphericalGeo); ++i) { double val1 = ((double *)XdmfGeometryGetValue(convertedToSpherical, i, XDMF_ARRAY_TYPE_FLOAT64, &status))[0]; double val2 = ((double *)XdmfGeometryGetValue(sphericalGeo, i, XDMF_ARRAY_TYPE_FLOAT64, &status))[0]; val1 = floor(val1 * pow((double)10, (double)15) + 0.5) / pow((double)10, (double)15); val2 = floor(val2 * pow((double)10, (double)15) + 0.5) / pow((double)10, (double)15); printf("%4.15f ?= %4.15f\n", val1, val2); assert(val1 == val2); } XDMFGEOMETRY * convertedToCartesian = XdmfGeometryNew(); XdmfGeometrySetType(convertedToCartesian, XDMF_GEOMETRY_TYPE_SPHERICAL, &status); value = sqrt(3); XdmfGeometryPushBack(convertedToCartesian, &value, XDMF_ARRAY_TYPE_FLOAT64, &status); value = asin(sqrt((double)2/3)); XdmfGeometryPushBack(convertedToCartesian, &value, XDMF_ARRAY_TYPE_FLOAT64, &status); // should be equal to std::acos(1/std::sqrt(3)) value = Pi/4; XdmfGeometryPushBack(convertedToCartesian, &value, XDMF_ARRAY_TYPE_FLOAT64, &status); XdmfGeometryConverterConvertToCartesianOverwrite(converter, convertedToCartesian); for (i = 0; i < XdmfGeometryGetSize(cartesianGeo); ++i) { double val1 = ((double *)XdmfGeometryGetValue(convertedToCartesian, i, XDMF_ARRAY_TYPE_FLOAT64, &status))[0]; double val2 = ((double *)XdmfGeometryGetValue(cartesianGeo, i, XDMF_ARRAY_TYPE_FLOAT64, &status))[0]; val1 = floor(val1 * pow((double)10, (double)15) + 0.5) / pow((double)10, (double)15); val2 = floor(val2 * pow((double)10, (double)15) + 0.5) / pow((double)10, (double)15); printf("%4.15f ?= %4.15f\n", val1, val2); assert(val1 == val2); } return 0; } xdmf-3.0+git20160803/utils/tests/C/CTestXdmfTopologyConverter.c0000640000175000017500000002150213003006557024210 0ustar alastairalastair#include #include "stdio.h" #include "string.h" #include "assert.h" #include "XdmfArray.hpp" #include "XdmfArrayType.hpp" #include "XdmfGeometry.hpp" #include "XdmfGeometryType.hpp" #include "XdmfTopology.hpp" #include "XdmfTopologyConverter.hpp" #include "XdmfTopologyType.hpp" #include "XdmfUnstructuredGrid.hpp" #include "XdmfWriter.hpp" int main() { int status = 0; unsigned int i = 0; XDMFTOPOLOGYCONVERTER * converter = XdmfTopologyConverterNew(); // Create Hexahedron Grid XDMFUNSTRUCTUREDGRID * hexGrid = XdmfUnstructuredGridNew(); double hexPoints[24] = {0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1}; int hexdims[1] = {24}; XDMFGEOMETRY * hexGeometry = XdmfUnstructuredGridGetGeometry(hexGrid); XdmfGeometrySetType(hexGeometry, XDMF_GEOMETRY_TYPE_XYZ, &status); XdmfGeometryResize(hexGeometry, hexdims, 1, XDMF_ARRAY_TYPE_FLOAT64, &status); XdmfGeometryInsertDataFromPointer(hexGeometry, hexPoints, XDMF_ARRAY_TYPE_FLOAT64, 0, 24, 1, 1, &status); XDMFTOPOLOGY * hexTopology = XdmfUnstructuredGridGetTopology(hexGrid); unsigned int hexConn[8] = {0, 1, 2, 3, 4, 5, 6, 7}; hexdims[0] = 8; XdmfTopologySetType(hexTopology, XDMF_TOPOLOGY_TYPE_HEXAHEDRON, &status); XdmfTopologyResize(hexTopology, hexdims, 1, XDMF_ARRAY_TYPE_UINT32, &status); XdmfTopologyInsertDataFromPointer(hexTopology, hexConn, XDMF_ARRAY_TYPE_UINT32, 0, 8, 1, 1, &status); /* * Hexahedron to Hexahedron_64 */ XDMFUNSTRUCTUREDGRID * hex64Grid = XdmfTopologyConverterConvert(converter, hexGrid, XDMF_TOPOLOGY_TYPE_HEXAHEDRON_64, NULL); XDMFGEOMETRY * hex64Geometry = XdmfUnstructuredGridGetGeometry(hex64Grid); assert(XdmfGeometryGetType(hex64Geometry) == XDMF_GEOMETRY_TYPE_XYZ); assert(XdmfGeometryGetNumberPoints(hex64Geometry) == 64); XDMFTOPOLOGY * hex64Topology = XdmfUnstructuredGridGetTopology(hex64Grid); assert(XdmfTopologyGetType(hex64Topology) == XDMF_TOPOLOGY_TYPE_HEXAHEDRON_64); assert(XdmfTopologyGetNumberElements(hex64Topology, &status) == 1); for(i = 0; i < 64; ++i) { assert(i == ((unsigned int *)XdmfTopologyGetValue(hex64Topology, i, XDMF_ARRAY_TYPE_UINT32, &status))[0]); } /* * Hexahedron to Hexahedron_125 */ XDMFUNSTRUCTUREDGRID * hex125Grid = XdmfTopologyConverterConvert(converter, hexGrid, XDMF_TOPOLOGY_TYPE_HEXAHEDRON_125, NULL); XDMFGEOMETRY * hex125Geometry = XdmfUnstructuredGridGetGeometry(hex125Grid); assert(XdmfGeometryGetType(hex125Geometry) == XDMF_GEOMETRY_TYPE_XYZ); assert(XdmfGeometryGetNumberPoints(hex125Geometry) == 125); XDMFTOPOLOGY * hex125Topology = XdmfUnstructuredGridGetTopology(hex125Grid); assert(XdmfTopologyGetType(hex125Topology) == XDMF_TOPOLOGY_TYPE_HEXAHEDRON_125); assert(XdmfTopologyGetNumberElements(hex125Topology, &status) == 1); for(i=0; i<125; ++i) { assert(i == ((unsigned int *)XdmfTopologyGetValue(hex125Topology, i, XDMF_ARRAY_TYPE_UINT32, &status))[0]); } /* * Hexahedron_64 to Hexahedron */ XDMFUNSTRUCTUREDGRID * newHexGrid = XdmfTopologyConverterConvert(converter, hex64Grid, XDMF_TOPOLOGY_TYPE_HEXAHEDRON, NULL); XDMFGEOMETRY * newHexGeometry = XdmfUnstructuredGridGetGeometry(newHexGrid); assert(XdmfGeometryGetType(newHexGeometry) == XDMF_GEOMETRY_TYPE_XYZ); assert(XdmfGeometryGetNumberPoints(newHexGeometry) == 64); XDMFTOPOLOGY * newHexTopology = XdmfUnstructuredGridGetTopology(newHexGrid); assert(XdmfTopologyGetType(newHexTopology) == XDMF_TOPOLOGY_TYPE_HEXAHEDRON); assert(XdmfTopologyGetNumberElements(newHexTopology, &status) == 27); XDMFTOPOLOGY * faceTopology; /** * Tetrahedron to Triangle */ XDMFTOPOLOGY * tetTopology = XdmfTopologyNew(); XdmfTopologySetType(tetTopology, XDMF_TOPOLOGY_TYPE_TETRAHEDRON, &status); long tetValues[8] = {0, 1, 2, 3, 0, 1, 2, 4};// temporary XdmfTopologyInsertDataFromPointer(tetTopology, tetValues, XDMF_ARRAY_TYPE_INT64, 0, 8, 1, 1, &status); printf("tetrahedrons prior to splitting into faces \n%s\n", XdmfTopologyGetValuesString(tetTopology)); faceTopology = XdmfTopologyConverterGetExternalFaces(converter, tetTopology); printf("after splitting into faces\n%s\n", XdmfTopologyGetValuesString(faceTopology)); assert(strcmp(XdmfTopologyGetValuesString(faceTopology), "0 1 3 " "0 3 2 " "0 1 4 " "0 4 2 " "1 2 3 " "1 2 4") == 0); XdmfTopologyFree(faceTopology); /** * Tetrahedron_10 to Triangle_6 */ XDMFTOPOLOGY * tet10Topology = XdmfTopologyNew(); XdmfTopologySetType(tet10Topology, XDMF_TOPOLOGY_TYPE_TETRAHEDRON_10, &status); long tet10Values[20] = {0, 1, 2, 3, 5, 6, 7, 8, 9, 10, 0, 1, 2, 4, 9, 10, 11, 12, 13, 14};// temporary XdmfTopologyInsertDataFromPointer(tet10Topology, tet10Values, XDMF_ARRAY_TYPE_INT64, 0, 20, 1, 1, &status); printf("tetrahedron_10s prior to splitting into faces \n%s\n", XdmfTopologyGetValuesString(tetTopology)); faceTopology = XdmfTopologyConverterGetExternalFaces(converter, tet10Topology); printf("after splitting into faces\n%s\n", XdmfTopologyGetValuesString(faceTopology)); assert(strcmp(XdmfTopologyGetValuesString(faceTopology), "0 1 3 5 9 8 " "0 3 2 8 10 7 " "0 1 4 9 13 12 " "0 4 2 12 14 11 " "1 2 3 6 10 9 " "1 2 4 10 14 13") == 0); XdmfTopologyFree(faceTopology); /** * Hexahedron to Quadrilateral */ XDMFTOPOLOGY * baseHexTopology = XdmfTopologyNew(); XdmfTopologySetType(baseHexTopology, XDMF_TOPOLOGY_TYPE_HEXAHEDRON, &status); long hexValues[16] = {0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 8, 9, 10, 11};// temporary XdmfTopologyInsertDataFromPointer(baseHexTopology, hexValues, XDMF_ARRAY_TYPE_INT64, 0, 16, 1, 1, &status); printf("Hexahedrons prior to splitting into faces \n%s\n", XdmfTopologyGetValuesString(baseHexTopology)); faceTopology = XdmfTopologyConverterGetExternalFaces(converter, baseHexTopology); printf("after splitting into faces\n%s\n", XdmfTopologyGetValuesString(faceTopology)); assert(strcmp(XdmfTopologyGetValuesString(faceTopology), "0 1 5 4 " "0 4 7 3 " "0 1 9 8 " "0 8 11 3 " "1 2 6 5 " "1 2 10 9 " "2 3 7 6 " "2 3 11 10 " "4 5 6 7 " "8 9 10 11") == 0); XdmfTopologyFree(faceTopology); /** * Hexahedron_20 to Quadrilateral_8 */ XDMFTOPOLOGY * hex20Topology = XdmfTopologyNew(); XdmfTopologySetType(hex20Topology, XDMF_TOPOLOGY_TYPE_HEXAHEDRON_20, &status); long hex20Values[40] = {0, 1, 2, 3, 4, 5, 6, 7, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 0, 1, 2, 3, 8, 9, 10, 11, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35};// temporary XdmfTopologyInsertDataFromPointer(hex20Topology, hex20Values, XDMF_ARRAY_TYPE_INT64, 0, 40, 1, 1, &status); printf("Hexahedron_20s prior to splitting into faces \n%s\n", XdmfTopologyGetValuesString(hex20Topology)); faceTopology = XdmfTopologyConverterGetExternalFaces(converter, hex20Topology); printf("after splitting into faces\n%s\n", XdmfTopologyGetValuesString(faceTopology)); assert(strcmp(XdmfTopologyGetValuesString(faceTopology), "0 1 5 4 12 21 16 20 " "0 4 7 3 20 19 23 15 " "0 1 9 8 24 33 28 32 " "0 8 11 3 32 31 35 27 " "1 2 6 5 13 22 17 21 " "1 2 10 9 25 34 29 33 " "2 3 7 6 14 23 18 22 " "2 3 11 10 26 35 30 34 " "4 5 6 7 16 17 18 19 " "8 9 10 11 28 29 30 31") == 0); XdmfTopologyFree(faceTopology); return 0; } xdmf-3.0+git20160803/utils/tests/C/CTestXdmfExodusIO.c0000640000175000017500000001452113003006557022206 0ustar alastairalastair#include "XdmfDomain.hpp" #include "XdmfExodusReader.hpp" #include "XdmfExodusWriter.hpp" #include "XdmfHDF5Writer.hpp" #include "XdmfWriter.hpp" #include "string.h" int main() { int status = 0; XDMFEXODUSWRITER * exodusWriter = XdmfExodusWriterNew(); XDMFUNSTRUCTUREDGRID * hexahedron = XdmfUnstructuredGridNew(); XdmfUnstructuredGridSetName(hexahedron, "Hexahedron"); // Set Geometry double points[36] = {0.1, 0.1, 1.1, 1.1, 0.1, 1.1, 3.1, 0.1, 2.1, 0.1, 1.1, 1.1, 1.1, 1.1, 1.1, 3.1, 2.1, 2.1, 0.1, 0.1, -1.1, 1.1, 0.1, -1.1, 3.1, 0.1, -2.1, 0.1, 1.1, -1.1, 1.1, 1.1, -1.1, 3.1, 2.1, -2.1}; XDMFGEOMTERY * hexGeometry = XdmfUnstructuredGridGetGeometry(hexahedron); XdmfGeometrySetType(hexGeometry, XDMF_GEOMETRY_TYPE_XYZ); XdmfGeometryInsertDataFromPointer(hexGeometry, &points[0], XDMF_ARRAY_TYPE_FLOAT64, 0, 36, 1, 1 &status); // Set Topology int connectivity[16] = {0, 1, 7, 6, 3, 4, 10, 9, 1, 2, 8, 7, 4, 5, 11, 10}; XDMFTOPOLOGY * hexTopology = XdmfUnstructuredGridGetTopology(hexahedron); XdmfTopologySetType(hexTopology, XDMF_TOPOLOGY_TYPE_HEXAHEDRON); XdmfTopologyInsertDataFromPointer(hexTopology, &connectivity[0], XDMF_ARRAY_TYPE_INT32, 0, 16, 1, 1 &status); // Add Node Attribute XDMFATTRIBUTE * nodalAttribute = XdmfAttributeNew(); int nodeValues[12] = {100, 200, 300, 300, 400, 500, 300, 400, 500, 500, 600, 700}; XdmfAttributeSetName(nodalAttribute, "Nodal Attribute"); XdmfAttributeSetType(nodalAttribute, XDMF_ATTRIBUTE_TYPE_SCALAR); XdmfAttributeSetCenter(nodalAttribute, XDMF_ATTRIBUTE_CENTER_NODE); XdmfAttributeInsertDataFromPointer(nodalAttribute, &nodeValues[0], XDMF_ARRAY_TYPE_INT32, 0, 12, 1, 1 &status); // Add Cell Attribute XDMFATTRIBUTE * cellAttribute = XdmfAttributeNew(); int cellValues[2] = {100, 200}; XdmfAttributeSetName(cellAttribute, "Cell Attribute"); XdmfAttributeSetType(cellAttribute, XDMF_ATTRIBUTE_TYPE_SCALAR); XdmfAttributeSetCenter(cellAttribute, XDMF_ATTRIBUTE_CENTER_CELL); XdmfAttributeInsertDataFromPointer(cellAttribute, &cellValues[0], XDMF_ARRAY_TYPE_INT32, 0, 2, 1, 1 &status); // Add Grid Attribute XDMFATTRIBUTE * gridAttribute = XdmfAttributeNew(); int gridValues[2] = {1, 2}; XdmfAttributeSetName(gridAttribute, "Grid Attribute"); XdmfAttributeSetType(gridAttribute, XDMF_ATTRIBUTE_TYPE_VECTOR); XdmfAttributeSetCenter(gridAttribute, XDMF_ATTRIBUTE_CENTER_GRID); XdmfAttributeInsertDataFromPointer(gridAttribute, &gridValues[0], XDMF_ARRAY_TYPE_INT32, 0, 2, 1, 1 &status); // Add Node Set XDMFSET * nodeSet = XdmfSetNew(); int nodeIds[3] = {0, 1, 2}; XdmfSetSetName(nodeSet, "Node Set"); XdmfSetSetType(nodeSet, XDMF_SET_TYPE_NODE); XdmfSetInsertDataFromPointer(nodeSet, &nodeIds[0], XDMF_ARRAY_TYPE_INT32, 0, 3, 1, 1, &status); // Add Node Set Attribute double nodeSetAttributeValues[3] = {10, 11, 12}; XDMFATTRIBUTE * nodeSetAttribute = XdmfAttributeNew(); XdmfAttributeSetName(nodeSetAttribute, "Node Set Attribute"); XdmfAttributeSetType(nodeSetAttribute, XDMF_ATTRIBUTE_TYPE_SCALAR); XdmfAttributeSetCenter(nodeSetAttribute, XDMF_ATTRIBUTE_CENTER_NODE); XdmfAttributeInsertDataFromPointer(nodeSetAttribute, &nodeSetAttributeValues[0], XDMF_ARRAY_TYPE_FLOAT64, 0, 3, 1, 1 &status); XdmfSetInsertAttribute(nodeSet, nodeSetAttribute); // Add Time XDMFTIME * time = XdmfTimeNew(100); XdmfUnstructuredGridSetTime(hexahedron, time); XdmfUnstructuredGridInsertAttribute(hexahedron, nodalAttribute); XdmfUnstructuredGridInsertAttribute(hexahedron, cellAttribute); XdmfUnstructuredGridInsertAttribute(hexahedron, gridAttribute); XdmfUnstructuredGridInsertAttribute(hexahedron, nodeSet); XdmfExodusWriterWrite(exodusWriter, "TestXdmfExodusIO.exo", hexahedron); XDMFEXODUSREADER * reader = XdmfExodusReaderNew(); XDMFUNSTRUCTUREDGRID * grid = (XDMFUNSTRUCTUREDGRID *)XdmfExodusReaderRead(reader, "TestXdmfExodusIO.exo"); XDMFGEOMETRY * readGeometry = XdmfUnstructuredGridGetGeometry(grid); XDMFTOPOLOGY * readTopology = XdmfUnstructuredGridGetTopology(grid); assert(strcmp(XdmfUnstructuredGridGetName(grid) == XdmfUnstructuredGridGetName(hexahedron))); assert(XdmfGeometryGetType(XdmfUnstructuredGridGetGeometry(grid)) == XdmfGeometryGetType(hexGeometry)); assert(XdmfGeometryGetNumberPoints(XdmfUnstructuredGridGetGeometry(grid)) == XdmfGeometryGetNumberPoints(hexGeometry)); unsigned int i = 0; unsigned int j = 0; unsigned int geoSize = XdmfGeometryGetSize(hexGeometry); for(i = 0; i < geoSize; ++i) {//TODO assert(((double *)XdmfArrayGetValue(hexGeometry, i, XDMF_ARRAY_TYPE_FLOAT64, &status))[0] == ((double *)XdmfArrayGetValue(readGeometry, i, XDMF_ARRAY_TYPE_FLOAT64, &status))[0]); } assert(XdmfTopologyGetType(XdmfUnstructuredGridGetTopology(grid)) == XdmfTopologyGetType(hexTopology)); assert(XdmfTopologyGetNumberElements(XdmfUnstructuredGridGetTopology(grid)) == XdmfTopologyGetNumberElements(hexTopology)); unsigned int toposize = XdmfTopologyGetSize(hexTopology); for(i = 0; i < toposize; ++i) {//TODO assert(((double *)XdmfArrayGetValue(hexTopology, i, XDMF_ARRAY_TYPE_FLOAT64, &status))[0] == ((double *)XdmfArrayGetValue(readTopology, i, XDMF_ARRAY_TYPE_FLOAT64, &status))[0]); } assert(XdmfUnstructuredGridGetNumberAttributes(hexahedron) + 2 == XdmfUnstructuredGridGetNumberAttributes(grid)); unsigned int numAttr = XdmfUnstructuredGridGetNumberAttributes(hexahedron); for(i = 0; i < numAttr; ++i) {//TODO XDMFATTRIBUTE * attribute1 = XdmfUnstructuredGridGetAttribute(hexahedron, i); if(attribute1->getCenter() != XdmfAttributeCenter::Grid()) { XDMFATTRIBUTE * attribute2 = XdmfUnstructuredGridGetAttributeByName(grid, XdmfAttributeGetName(attribute1)); assert(XdmfAttributeGetCenter(attribute1, &status) == XdmfAttributeGetCenter(attribute2, &status)); assert(XdmfAttributeGetType(attribute1, &status) == XdmfAttributeGetType(attribute2, &status)); assert(XdmfAttributeGetSize(attribute1) == XdmfAttributeGetSize(attribute2)); unsigned int attrSize = XdmfAttributeGetSize(attribute1); for (j = 0; j < attrSize; ++j) { assert(((double *)XdmfArrayGetValue(attribute1, i, XDMF_ARRAY_TYPE_FLOAT64, &status))[0] == ((double *)XdmfArrayGetValue(attribute2, i, XDMF_ARRAY_TYPE_FLOAT64, &status))[0]); } } } } xdmf-3.0+git20160803/utils/XdmfPartitioner.hpp0000640000175000017500000001505713003006557021072 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfPartitioner.hpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef XDMFPARTITIONER_HPP_ #define XDMFPARTITIONER_HPP_ #ifdef __cplusplus // Forward Declarations class XdmfGraph; class XdmfGridCollection; class XdmfHeavyDataWriter; class XdmfSet; class XdmfUnstructuredGrid; // Includes #include #include "XdmfUtils.hpp" #include "XdmfSharedPtr.hpp" /** * @brief XdmfPartitioner partitions an XdmfGrid using the metis * library. * * XdmfPartitioner uses the metis library to partition XdmfGrids. */ class XDMFUTILS_EXPORT XdmfPartitioner { public: enum MetisScheme { DUAL_GRAPH = 0, NODAL_GRAPH = 1 }; /** * Create a new XdmfPartitioner. * * @return constructed XdmfPartitioner. */ static shared_ptr New(); virtual ~XdmfPartitioner(); /** * Ignore set when partitioning. Set is not partitioned or added to * resulting grid. * * @param set the set to ignore when partitioning. */ void ignore(const shared_ptr set); void ignore(const XdmfSet *); /** * Partitions an XdmfGraph using the metis library. An attribute * named "Partition" is added to the XdmfGraph that contains * partition numbers for each graph vertex. * * @param graphToPartition an XdmfGraph to partition. * @param numberOfPartitions the number of pieces to partition the * graph into. */ void partition(const shared_ptr graphToPartition, const unsigned int numberOfPartitions) const; /** * Partitions an XdmfUnstructuredGrid using the metis library. * * The partitioner splits the XdmfGridUnstructured and all attached * XdmfAttributes and XdmfSets into their proper partition. An * XdmfAttribute named "GlobalNodeId" is added to each partitioned * grid to map partitioned node ids to their original unpartitioned * id. An XdmfMap is added to each partitioned grid mapping shared * nodes to other processors. All arrays attached to the passed * gridToPartition are read from disk if not initialized. * * @param gridToPartition an XdmfGridUnstructured to partition. * @param numberOfPartitions the number of pieces to partition the grid into. * @param heavyDataWriter an XdmfHDF5Writer to write the partitioned mesh to. * If no heavyDataWriter is specified, all partitioned data will remain in * memory. * * @return a spatial collection containing partitioned grids. */ shared_ptr partition(const shared_ptr gridToPartition, const unsigned int numberOfPartitions, const MetisScheme metisScheme = DUAL_GRAPH, const shared_ptr heavyDataWriter = shared_ptr()) const; /** * Unpartitions an XdmfGridCollection of unstructured grids into a single * XdmfUnstructuredGrid. * * @param gridToPartition an XdmfGridUnstructured to partition. * * @return a unstructured grid containing the unpartitioned grid. */ shared_ptr unpartition(const shared_ptr gridToUnPartition) const; XdmfPartitioner(const XdmfPartitioner & partitioner); protected: XdmfPartitioner(); private: void operator=(const XdmfPartitioner & partitioner); // Not implemented. std::set mIgnoredSets; }; #endif #ifdef __cplusplus extern "C" { #endif #define XDMF_PARTITIONER_SCHEME_DUAL_GRAPH 500 #define XDMF_PARTITIONER_SCHEME_NODAL_GRAPH 501 // C wrappers go here struct XDMFPARTITIONER; // Simply as a typedef to ensure correct typing typedef struct XDMFPARTITIONER XDMFPARTITIONER; XDMFUTILS_EXPORT XDMFPARTITIONER * XdmfPartitionerNew(); XDMFUTILS_EXPORT void XdmfPartitionerIgnore(XDMFPARTITIONER * partitioner, XDMFSET * set); XDMFUTILS_EXPORT void XdmfPartitionerPartitionGraph(XDMFPARTITIONER * partitioner, XDMFGRAPH * graphToPartition, unsigned int numberOfPartitions); XDMFUTILS_EXPORT XDMFGRIDCOLLECTION * XdmfPartitionerPartitionUnstructuredGrid(XDMFPARTITIONER * partitioner, XDMFUNSTRUCTUREDGRID * gridToPartition, unsigned int numberOfPartitions, int metisScheme, XDMFHEAVYDATAWRITER * heavyDataWriter); XDMFUTILS_EXPORT XDMFUNSTRUCTUREDGRID * XdmfPartitionerUnpartition(XDMFPARTITIONER * partitioner, XDMFGRIDCOLLECTION * gridToUnPartition); XDMFUTILS_EXPORT void XdmfPartitionerFree(XDMFPARTITIONER * partitioner); #ifdef __cplusplus } #endif #endif /* XDMFPARTITIONER_HPP_ */ xdmf-3.0+git20160803/XdmfTopologyType.hpp0000640000175000017500000004367113003006557020113 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfTopologyType.hpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef XDMFTOPOLOGYTYPE_HPP_ #define XDMFTOPOLOGYTYPE_HPP_ // C Compatible Includes #include "Xdmf.hpp" #ifdef __cplusplus // Includes #include "XdmfItemProperty.hpp" #include #include /** * @brief Property describing the types of elements stored in an * XdmfTopology. * * XdmfTopologyType is a property used by XdmfTopology to specify the * element types stored. A specific XdmfTopologyType can be created by * calling one of the static methods in the class, * i.e. XdmfTopologyType::Tetrahedron(). * * Example of use: * * C++ * * @dontinclude ExampleXdmfTopologyType.cpp * @skipline //#getType * @until //#getType * * Python * * @dontinclude XdmfExampleTopologyType.py * @skipline #//getType * @until #//getType * * Xdmf supports the following topology types: * NoTopologyType * Polyvertex - Unconnected Points * Polyline - Line Segments * Polygon - N Edge Polygon * Triangle - 3 Edge Polygon * Quadrilateral - 4 Edge Polygon * Tetrahedron - 4 Triangular Faces * Wedge - 4 Triangular Faces, Quadrilateral Base * Hexahedron - 6 Quadrilateral Faces * Polyhedron - N Face Cell, where each Face is a M Edge Polygon * Edge_3 - 3 Node Quadratic Line * Triangle_6 - 6 Node Quadratic Triangle * Quadrilateral_8 - 8 Node Quadratic Quadrilateral * Quadrilateral_9 - 9 Node Bi-Quadratic Quadrilateral * Tetrahedron_10 - 10 Node Quadratic Tetrahedron * Pyramid_13 - 13 Node Quadratic Pyramid * Wedge_15 - 15 Node Quadratic Wedge * Wedge_18 - 18 Node Bi-Quadratic Wedge * Hexahedron_20 - 20 Node Quadratic Hexahedron * Hexahedron_24 - 24 Node Bi-Quadratic Hexahedron * Hexahedron_27 - 27 Node Tri-Quadratic Hexahedron * Hexahedron_64 - 64 Node Tri-Cubic Hexahedron * Hexahedron_125 - 125 Node Tri-Quartic Hexahedron * Hexahedron_216 - 216 Node Tri-Quintic Hexahedron * Hexahedron_343 - 343 Node Tri-Hexic Hexahedron * Hexahedron_512 - 512 Node Tri-Septic Hexahedron * Hexahedron_729 - 729 Node Tri-Octic Hexahedron * Hexahedron_1000 - 1000 Node Tri-Nonic Hexahedron * Hexahedron_1331 - 1331 Node Tri-Decic Hexahedron * Hexahedron_Spectral_64 - 64 Node Spectral Tri-Cubic Hexahedron * Hexahedron_Spectral_125 - 125 Node Spectral Tri-Quartic Hexahedron * Hexahedron_Spectral_216 - 216 Node Spectral Tri-Quintic Hexahedron * Hexahedron_Spectral_343 - 343 Node Spectral Tri-Hexic Hexahedron * Hexahedron_Spectral_512 - 512 Node Spectral Tri-Septic Hexahedron * Hexahedron_Spectral_729 - 729 Node Spectral Tri-Octic Hexahedron * Hexahedron_Spectral_1000 - 1000 Node Spectral Tri-Nonic Hexahedron * Hexahedron_Spectral_1331 - 1331 Node Spectral Tri-Decic Hexahedron * Mixed - Mixture of Unstructured Topologies */ class XDMF_EXPORT XdmfTopologyType : public XdmfItemProperty { public: virtual ~XdmfTopologyType(); friend class XdmfTopology; enum CellType { NoCellType = 0, Linear = 1, Quadratic = 2, Cubic = 3, Quartic = 4, Quintic = 5, Sextic = 6, Septic = 7, Octic = 8, Nonic = 9, Decic = 10, Arbitrary = 100, Structured = 101 }; /** * Supported Xdmf Topology Types */ static shared_ptr NoTopologyType(); static shared_ptr Polyvertex(); static shared_ptr Polyline(const unsigned int nodesPerElement); static shared_ptr Polygon(const unsigned int nodesPerElement); static shared_ptr Triangle(); static shared_ptr Quadrilateral(); static shared_ptr Tetrahedron(); static shared_ptr Pyramid(); static shared_ptr Wedge(); static shared_ptr Hexahedron(); static shared_ptr Polyhedron(); static shared_ptr Edge_3(); static shared_ptr Triangle_6(); static shared_ptr Quadrilateral_8(); static shared_ptr Quadrilateral_9(); static shared_ptr Tetrahedron_10(); static shared_ptr Pyramid_13(); static shared_ptr Wedge_15(); static shared_ptr Wedge_18(); static shared_ptr Hexahedron_20(); static shared_ptr Hexahedron_24(); static shared_ptr Hexahedron_27(); static shared_ptr Hexahedron_64(); static shared_ptr Hexahedron_125(); static shared_ptr Hexahedron_216(); static shared_ptr Hexahedron_343(); static shared_ptr Hexahedron_512(); static shared_ptr Hexahedron_729(); static shared_ptr Hexahedron_1000(); static shared_ptr Hexahedron_1331(); static shared_ptr Hexahedron_Spectral_64(); static shared_ptr Hexahedron_Spectral_125(); static shared_ptr Hexahedron_Spectral_216(); static shared_ptr Hexahedron_Spectral_343(); static shared_ptr Hexahedron_Spectral_512(); static shared_ptr Hexahedron_Spectral_729(); static shared_ptr Hexahedron_Spectral_1000(); static shared_ptr Hexahedron_Spectral_1331(); static shared_ptr Mixed(); /** * Get a topology type from id. * * Example of use: * * C++ * * @dontinclude ExampleXdmfTopologyType.cpp * @skipline //#initialization * @until //#initialization * * Python * * @dontinclude XdmfExampleTopologyType.py * @skipline #//initialization * @until #//initialization * * @param id of the topology type. * * @return Topology type corresponding to id - if no topology type is found * an NULL pointer is returned. */ static shared_ptr New(const unsigned int id); /** * Get the cell type associated with this topology type. * * Example of use: * * C++ * * @dontinclude ExampleXdmfTopologyType.cpp * @skipline //#getCellType * @until //#getCellType * * Python * * @dontinclude XdmfExampleTopologyType.py * @skipline #//getCellType * @until #//getCellType * * @return A CellType containing the cell type. */ CellType getCellType() const; /** * Get the number of edges per element associated with this topology type. * * Example of use: * * C++ * * @dontinclude ExampleXdmfTopologyType.cpp * @skipline //#getEdgesPerElement * @until //#getEdgesPerElement * * Python * * @dontinclude XdmfExampleTopologyType.py * @skipline #//getEdgesPerElement * @until #//getEdgesPerElement * * @return An unsigned int containing the number of edges per element. */ virtual unsigned int getEdgesPerElement() const; /** * Get the number of faces per element associated with this topology type. * * Example of use: * * C++ * * @dontinclude ExampleXdmfTopologyType.cpp * @skipline //#getFacesPerElement * @until //#getFacesPerElement * * Python * * @dontinclude XdmfExampleTopologyType.py * @skipline #//getFacesPerElement * @until #//getFacesPerElement * * @return An unsigned int containing the number of faces per element. */ virtual unsigned int getFacesPerElement() const; /** * Gets the type of the faces of the topology. * * Example of use: * * C++ * * @dontinclude ExampleXdmfTopologyType.cpp * @skipline //#getFaceType * @until //#getFaceType * * Python * * @dontinclude XdmfExampleTopologyType.py * @skipline #//getFaceType * @until #//getFaceType * * @return The face's topology type */ shared_ptr getFaceType() const; /** * Get the id of this cell type, necessary in order to create grids * containing mixed cells. * * Example of use: * * C++ * * @dontinclude ExampleXdmfTopologyType.cpp * @skipline //#getID * @until //#getID * * Python * * @dontinclude XdmfExampleTopologyType.py * @skipline //#getID * @until //#getID * * @return The ID of the topology type. */ virtual unsigned int getID() const; /** * Get the name of this topology type. * * Example of use: * * C++ * * @dontinclude ExampleXdmfTopologyType.cpp * @skipline //#getName * @until //#getName * * Python * * @dontinclude XdmfExampleTopologyType.py * @skipline #//getName * @until #//getName * * @return The name of this topology type. */ virtual std::string getName() const; /** * Get the number of nodes per element associated with this topology * type. * * Example of use: * * C++ * * @dontinclude ExampleXdmfTopologyType.cpp * @skipline //#getNodesPerElement * @until //#getNodesPerElement * * Python * * @dontinclude XdmfExampleTopologyType.py * @skipline #//getNodesPerElement * @until #//getNodesPerElement * * @return An unsigned int containing number of nodes per element. */ virtual unsigned int getNodesPerElement() const; void getProperties(std::map & collectedProperties) const; protected: /** * Protected constructor for XdmfTopologyType. The constructor is * protected because all topology types supported by Xdmf should be * accessed through more specific static methods that construct * XdmfTopologyType - i.e. XdmfTopologyType::Tetrahedron() */ XdmfTopologyType(const unsigned int nodesPerElement, const unsigned int facesPerElement, const std::vector > & faces, const unsigned int edgesPerElement, const std::string & name, const CellType cellType, const unsigned int id); unsigned int calculateHypercubeNumElements(unsigned int numDims, unsigned int elementNumDims) const; static std::map(*)()> mTopologyDefinitions; static void InitTypes(); private: XdmfTopologyType(const XdmfTopologyType &); // Not implemented. void operator=(const XdmfTopologyType &); // Not implemented. static shared_ptr New(const std::map & itemProperties); const CellType mCellType; const unsigned int mEdgesPerElement; const unsigned int mFacesPerElement; std::vector > mFaces; const unsigned int mID; const std::string mName; const unsigned int mNodesPerElement; }; #endif #ifdef __cplusplus extern "C" { #endif // C wrappers go here #ifndef XDMF_C_TOPOLOGY_TYPES #define XDMF_C_TOPOLOGY_TYPES #define XDMF_TOPOLOGY_TYPE_POLYVERTEX 500 #define XDMF_TOPOLOGY_TYPE_POLYLINE 501 #define XDMF_TOPOLOGY_TYPE_POLYGON 502 #define XDMF_TOPOLOGY_TYPE_POLYHEDRON 503 #define XDMF_TOPOLOGY_TYPE_TRIANGLE 504 #define XDMF_TOPOLOGY_TYPE_QUADRILATERAL 505 #define XDMF_TOPOLOGY_TYPE_TETRAHEDRON 506 #define XDMF_TOPOLOGY_TYPE_PYRAMID 507 #define XDMF_TOPOLOGY_TYPE_WEDGE 508 #define XDMF_TOPOLOGY_TYPE_HEXAHEDRON 509 #define XDMF_TOPOLOGY_TYPE_EDGE_3 510 #define XDMF_TOPOLOGY_TYPE_TRIANGLE_6 511 #define XDMF_TOPOLOGY_TYPE_QUADRILATERAL_8 512 #define XDMF_TOPOLOGY_TYPE_QUADRILATERAL_9 513 #define XDMF_TOPOLOGY_TYPE_TETRAHEDRON_10 514 #define XDMF_TOPOLOGY_TYPE_PYRAMID_13 515 #define XDMF_TOPOLOGY_TYPE_WEDGE_15 516 #define XDMF_TOPOLOGY_TYPE_WEDGE_18 517 #define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_20 518 #define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_24 519 #define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_27 520 #define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_64 521 #define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_125 522 #define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_216 523 #define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_343 524 #define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_512 525 #define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_729 526 #define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_1000 527 #define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_1331 528 #define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_64 529 #define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_125 530 #define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_216 531 #define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_343 532 #define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_512 533 #define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_729 534 #define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_1000 535 #define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_1331 536 #define XDMF_TOPOLOGY_TYPE_MIXED 537 #endif #define XDMF_TOPOLOGY_CELL_TYPE_NO_CELL_TYPE 0 #define XDMF_TOPOLOGY_CELL_TYPE_LINEAR 1 #define XDMF_TOPOLOGY_CELL_TYPE_QUADRATIC 2 #define XDMF_TOPOLOGY_CELL_TYPE_CUBIC 3 #define XDMF_TOPOLOGY_CELL_TYPE_QUARTIC 4 #define XDMF_TOPOLOGY_CELL_TYPE_QUINTIC 5 #define XDMF_TOPOLOGY_CELL_TYPE_SEXTIC 6 #define XDMF_TOPOLOGY_CELL_TYPE_SEPTIC 7 #define XDMF_TOPOLOGY_CELL_TYPE_OCTIC 8 #define XDMF_TOPOLOGY_CELL_TYPE_NONIC 9 #define XDMF_TOPOLOGY_CELL_TYPE_DECIC 10 #define XDMF_TOPOLOGY_CELL_TYPE_ARBITRARY 100 #define XDMF_TOPOLOGY_CELL_TYPE_STRUCTURED 101 XDMF_EXPORT int XdmfTopologyTypePolyvertex(); XDMF_EXPORT int XdmfTopologyTypePolyline(); XDMF_EXPORT int XdmfTopologyTypePolygon(); XDMF_EXPORT int XdmfTopologyTypeTriangle(); XDMF_EXPORT int XdmfTopologyTypeQuadrilateral(); XDMF_EXPORT int XdmfTopologyTypeTetrahedron(); XDMF_EXPORT int XdmfTopologyTypePyramid(); XDMF_EXPORT int XdmfTopologyTypeWedge(); XDMF_EXPORT int XdmfTopologyTypeHexahedron(); XDMF_EXPORT int XdmfTopologyTypeEdge_3(); XDMF_EXPORT int XdmfTopologyTypeTriangle_6(); XDMF_EXPORT int XdmfTopologyTypeQuadrilateral_8(); XDMF_EXPORT int XdmfTopologyTypeQuadrilateral_9(); XDMF_EXPORT int XdmfTopologyTypeTetrahedron_10(); XDMF_EXPORT int XdmfTopologyTypePyramid_13(); XDMF_EXPORT int XdmfTopologyTypeWedge_15(); XDMF_EXPORT int XdmfTopologyTypeWedge_18(); XDMF_EXPORT int XdmfTopologyTypeHexahedron_20(); XDMF_EXPORT int XdmfTopologyTypeHexahedron_24(); XDMF_EXPORT int XdmfTopologyTypeHexahedron_27(); XDMF_EXPORT int XdmfTopologyTypeHexahedron_64(); XDMF_EXPORT int XdmfTopologyTypeHexahedron_125(); XDMF_EXPORT int XdmfTopologyTypeHexahedron_216(); XDMF_EXPORT int XdmfTopologyTypeHexahedron_343(); XDMF_EXPORT int XdmfTopologyTypeHexahedron_512(); XDMF_EXPORT int XdmfTopologyTypeHexahedron_729(); XDMF_EXPORT int XdmfTopologyTypeHexahedron_1000(); XDMF_EXPORT int XdmfTopologyTypeHexahedron_1331(); XDMF_EXPORT int XdmfTopologyTypeHexahedron_Spectral_64(); XDMF_EXPORT int XdmfTopologyTypeHexahedron_Spectral_125(); XDMF_EXPORT int XdmfTopologyTypeHexahedron_Spectral_216(); XDMF_EXPORT int XdmfTopologyTypeHexahedron_Spectral_343(); XDMF_EXPORT int XdmfTopologyTypeHexahedron_Spectral_512(); XDMF_EXPORT int XdmfTopologyTypeHexahedron_Spectral_729(); XDMF_EXPORT int XdmfTopologyTypeHexahedron_Spectral_1000(); XDMF_EXPORT int XdmfTopologyTypeHexahedron_Spectral_1331(); XDMF_EXPORT int XdmfTopologyTypeMixed(); XDMF_EXPORT int XdmfTopologyTypeGetCellType(int type); XDMF_EXPORT unsigned int XdmfTopologyTypeGetEdgesPerElement(int type, int * status); XDMF_EXPORT unsigned int XdmfTopologyTypeGetFacesPerElement(int type, int * status); XDMF_EXPORT int XdmfTopologyTypeGetFaceType(int type); XDMF_EXPORT unsigned int XdmfTopologyTypeGetID(int type); XDMF_EXPORT char * XdmfTopologyTypeGetName(int type); XDMF_EXPORT unsigned int XdmfTopologyTypeGetNodesPerElement(int type); #ifdef __cplusplus } #endif #endif /* XDMFTOPOLOGYTYPE_HPP_ */ xdmf-3.0+git20160803/vtk/0000740000175000017500000000000013003006557014674 5ustar alastairalastairxdmf-3.0+git20160803/vtk/vtkXdmfWriter.cxx0000640000175000017500000015464113003006557020255 0ustar alastairalastair/*========================================================================= Program: Visualization Toolkit Module: $RCSfile: vtkXdmfWriter.cxx,v $ Language: C++ Date: $Date: 2009-03-13 20:01:09 $ Version: $Revision: 1.7 $ Copyright (c) 1993-2001 Ken Martin, Will Schroeder, Bill Lorensen All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither name of Ken Martin, Will Schroeder, or Bill Lorensen nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission. * Modified source versions must be plainly marked as such, and must not be misrepresented as being the original software. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "vtkXdmfWriter.h" #include "vtkGenericCell.h" #include "vtkCell.h" #include "vtkCellArray.h" #include "vtkCellData.h" #include "vtkCellTypes.h" #include "vtkCommand.h" #include "vtkImageData.h" #include "vtkObjectFactory.h" #include "vtkPointData.h" #include "vtkPoints.h" #include "vtkPolyData.h" #include "vtkRectilinearGrid.h" #include "vtkStructuredGrid.h" #include "vtkUnstructuredGrid.h" #include "vtkUniformGrid.h" #include "vtkDataSetCollection.h" #include "vtkSmartPointer.h" #include "vtkCharArray.h" #include "vtkFloatArray.h" #include "vtkDoubleArray.h" #include "vtkIntArray.h" #include "vtkLongArray.h" #include "vtkShortArray.h" #include "vtkUnsignedCharArray.h" #include "vtkUnsignedShortArray.h" #include "vtkUnsignedIntArray.h" #include "XdmfHDF.h" #include "XdmfArray.h" #include "XdmfAttribute.h" #include "XdmfDOM.h" #include "H5Spublic.h" #include #include #define vtkMAX(x, y) (((x)>(y))?(x):(y)) //---------------------------------------------------------------------------- #define OUTPUTTEXT(a) vtkOutputWindowDisplayText(a); #define vtkGenericDebugMacro(a) \ { \ vtkOStreamWrapper::EndlType endl; \ vtkOStreamWrapper::UseEndl(endl); \ vtkOStrStreamWrapper vtkmsg; \ vtkmsg << " vtkXdmfWriter " a << "\n"; \ OUTPUTTEXT(vtkmsg.str()); \ vtkmsg.rdbuf()->freeze(0); \ } //--------------------------------------------------------------------------- struct vtkXdmfWriterInternal { class CellType { public: CellType() : VTKType(0), NumPoints(0) {} CellType(const CellType& ct) : VTKType(ct.VTKType), NumPoints(ct.NumPoints) {} vtkIdType VTKType; vtkIdType NumPoints; vtkstd_bool operator<(const CellType& ct) const { return this->VTKType < ct.VTKType || this->VTKType == ct.VTKType && this->NumPoints < ct.NumPoints; } vtkstd_bool operator==(const CellType& ct) const { return this->VTKType == ct.VTKType && this->NumPoints == ct.NumPoints; } CellType& operator=(const CellType& ct) { this->VTKType = ct.VTKType; this->NumPoints = ct.NumPoints; return *this; } }; typedef vtkstd::map > MapOfCellTypes; static void DetermineCellTypes(vtkPointSet *t, MapOfCellTypes& vec); }; //---------------------------------------------------------------------------- vtkStandardNewMacro(vtkXdmfWriter); vtkCxxRevisionMacro(vtkXdmfWriter, "$Revision: 1.7 $"); //---------------------------------------------------------------------------- vtkXdmfWriter::vtkXdmfWriter() { this->FileNameString = 0; this->HeavyDataSetNameString = 0; this->GridName = 0; this->DomainName = 0; this->CollectionName = 0; this->SetHeavyDataSetName( "XdmfData.h5" ); this->SetGridName( "Unnamed" ); this->CollectionType = XDMF_GRID_COLLECTION_UNSET; this->AllLight = 0; this->AllHeavy = 0; this->CurrIndent = 0; this->InputList = 0; this->HDF5ArrayName = 0; this->GridOnly = 0; this->InputsArePieces = 0; this->FullGridSize[0] = 0; this->FullGridSize[1] = 0; this->FullGridSize[2] = 0; this->TimeValue = -1E99; this->DocString = NULL; this->AppendGridsToDomain = 0; this->DOM = NULL; } //---------------------------------------------------------------------------- vtkXdmfWriter::~vtkXdmfWriter() { this->SetHeavyDataSetName(0); this->SetFileNameString(0); if (this->InputList != NULL) { this->InputList->Delete(); this->InputList = NULL; } this->SetHDF5ArrayName(0); this->SetDomainName(0); this->SetGridName(0); if (this->DocString) { delete []this->DocString; } } //---------------------------------------------------------------------------- void vtkXdmfWriter::SetFileName(const char* fname) { if ( fname ) { char* hname = new char [ strlen(fname) + 10 ]; // space for extension strcpy(hname, fname); size_t cc; for ( cc = strlen(hname); cc > 0; cc -- ) { if ( hname[cc] == '.' ) { break; } } if ( hname[cc] == '.' ) { cc--; } if ( cc > 0 ) { hname[cc+1] = 0; } strcat(hname, ".h5"); this->SetHeavyDataSetName(hname); vtkDebugMacro(<< "Set Heavy Data Set Name: " << hname); } this->SetFileNameString(fname); } //---------------------------------------------------------------------------- const char* vtkXdmfWriter::GetFileName() { return this->FileNameString; } //---------------------------------------------------------------------------- void vtkXdmfWriter::SetHeavyDataSetName( const char *name) { this->SetHeavyDataSetNameString(name); if ( name ) { this->AllLight = 0; } else { this->AllLight = 1; this->AllHeavy = 0; } this->Modified(); } //---------------------------------------------------------------------------- const char* vtkXdmfWriter::GetHeavyDataSetName() { return this->HeavyDataSetNameString; } //---------------------------------------------------------------------------- int vtkXdmfWriter::ParseExistingFile(const char* filename) { XdmfConstString CurrentFileName; vtkstd::string directory; if (!filename) { vtkErrorMacro("File name not set"); return 1; } // First make sure the file exists. This prevents an empty file // from being created on older compilers. if (!vtksys::SystemTools::FileExists(filename)) { vtkErrorMacro("Error opening file " << filename); return 1; } if ( !this->DOM ) { this->DOM = new XdmfDOM(); } //Tell the parser what the working directory is. directory = vtksys::SystemTools::GetFilenamePath(filename) + "/"; if (directory == "") { directory = vtksys::SystemTools::GetCurrentWorkingDirectory() + "/"; } directory = vtksys::SystemTools::ConvertToOutputPath(directory.c_str()); this->DOM->SetWorkingDirectory(directory.c_str()); /* if ( !this->Internals->DataItem ) { this->Internals->DataItem = new XdmfDataItem(); this->Internals->DataItem->SetDOM(this->DOM); } */ CurrentFileName = this->DOM->GetInputFileName(); // Only re-parse when necessary. Reparsing can be slow and can reset // parameters and stride that we read from file but then allow user to // modify. this->DOM->SetInputFileName(filename); vtkDebugMacro(".!!............Preparing to Parse " << filename); this->DOM->Parse(filename); return 1; } //---------------------------------------------------------------------------- int vtkXdmfWriter::WriteHead( ostream& ost ) { ost << "" << "\n" << "HeavyDataSetNameString << "\">" <<"\n" << "]>" << "\n" << "\n" << "\n"; this->Indent(ost); ost << ""; this->IncrementIndent(); this->Indent(ost); return 1; } //---------------------------------------------------------------------------- int vtkXdmfWriter::WriteTail( ostream& ost ) { this->DecrementIndent(); this->Indent(ost); ost << ""; this->Indent(ost); return 0; } //---------------------------------------------------------------------------- int vtkXdmfWriter::WriteCellArray( ostream& ost, vtkDataSet *ds, const char* gridName, void* mapofcell, const void* celltype ) { vtkIdType PointsInPoly; vtkIdType i, j; vtkXdmfWriterInternal::CellType* ct = (vtkXdmfWriterInternal::CellType*)celltype; vtkXdmfWriterInternal::MapOfCellTypes* mc = (vtkXdmfWriterInternal::MapOfCellTypes*)mapofcell; PointsInPoly = ct->NumPoints; vtkIdList* il = (*mc)[*ct].GetPointer(); ost << "IncrementIndent(); this->Indent(ost); ost << " NumberType=\"Int\""; this->Indent(ost); ost << " Dimensions=\"" << il->GetNumberOfIds() << " " << PointsInPoly << "\""; this->Indent(ost); vtkIdList* cellPoints = vtkIdList::New(); if( this->AllLight ) { ost << " Format=\"XML\">"; for( i = 0 ; i < il->GetNumberOfIds(); i++ ) { this->Indent(ost); ds->GetCellPoints(il->GetId(i), cellPoints); if ( ct->VTKType == VTK_VOXEL ) { // Hack for VTK_VOXEL ost << " " << cellPoints->GetId(0); ost << " " << cellPoints->GetId(1); ost << " " << cellPoints->GetId(3); ost << " " << cellPoints->GetId(2); ost << " " << cellPoints->GetId(4); ost << " " << cellPoints->GetId(5); ost << " " << cellPoints->GetId(7); ost << " " << cellPoints->GetId(6); } else if ( ct->VTKType == VTK_PIXEL ) { // Hack for VTK_PIXEL ost << " " << cellPoints->GetId(0); ost << " " << cellPoints->GetId(1); ost << " " << cellPoints->GetId(3); ost << " " << cellPoints->GetId(2); } else { for( j = 0 ; j < PointsInPoly ; j++ ) { ost << " " << cellPoints->GetId(j); } } } } else { // Create HDF File XdmfArray Conns; XdmfHDF H5; XdmfInt64 Dims[2]; XdmfInt32 *Dp; const char* DataSetName = this->GenerateHDF5ArrayName(gridName, "Connections"); ost << " Format=\"HDF\">"; this->IncrementIndent(); this->Indent(ost); ost << " " << DataSetName; this->DecrementIndent(); Conns.SetNumberType( XDMF_INT32_TYPE ); Dims[0] = il->GetNumberOfIds(); Dims[1] = PointsInPoly; Conns.SetShape( 2, Dims ); Dp = (XdmfInt32 *)Conns.GetDataPointer(); for( i = 0 ; i < il->GetNumberOfIds(); i++ ) { vtkIdType cid = il->GetId(i); ds->GetCellPoints(cid, cellPoints); if ( ct->VTKType == VTK_VOXEL ) { // Hack for VTK_VOXEL *Dp++ = cellPoints->GetId(0); *Dp++ = cellPoints->GetId(1); *Dp++ = cellPoints->GetId(3); *Dp++ = cellPoints->GetId(2); *Dp++ = cellPoints->GetId(4); *Dp++ = cellPoints->GetId(5); *Dp++ = cellPoints->GetId(7); *Dp++ = cellPoints->GetId(6); } else if ( ct->VTKType == VTK_PIXEL ) { // Hack for VTK_PIXEL *Dp++ = cellPoints->GetId(0); *Dp++ = cellPoints->GetId(1); *Dp++ = cellPoints->GetId(3); *Dp++ = cellPoints->GetId(2); } else { for( j = 0 ; j < PointsInPoly ; j++ ) { *Dp++ = cellPoints->GetId(j); } } } H5.CopyType( &Conns ); H5.CopyShape( &Conns ); if( H5.Open( DataSetName, "rw" ) == XDMF_FAIL ) { if( H5.CreateDataset( DataSetName ) == XDMF_FAIL ) { vtkErrorMacro( "Can't Create Heavy Dataset " << DataSetName ); return( -1 ); } } H5.Write( &Conns ); H5.Close(); } cellPoints->Delete(); this->DecrementIndent(); this->Indent(ost); ost << ""; return( il->GetNumberOfIds() ); } //---------------------------------------------------------------------------- int vtkXdmfWriter::WritePoints( ostream& ost, vtkPoints *Points, vtkDataSet* dataSet, const char* gridName ) { int dims[3] = { -10, -10, -10 }; return this->WriteVTKArray( ost, Points->GetData(), dataSet, 0, dims, "XYZ", 0, gridName, this->AllLight ); } //---------------------------------------------------------------------------- void vtkXdmfWriter::EndTopology( ostream& ost ) { this->DecrementIndent(); this->Indent(ost); ost << ""; } //---------------------------------------------------------------------------- void vtkXdmfWriter::StartTopology( ostream& ost, const char* toptype, int rank, int *dims) { ost << "IncrementIndent(); this->Indent(ost); ost << " TopologyType=\"" << toptype << "\""; ost << " Dimensions=\""; int cc; for ( cc = rank-1; cc >= 0; cc -- ) { if ( cc < rank - 1 ) { ost << " "; } ost << dims[cc]; } ost << "\">"; //this->Indent(ost); } //---------------------------------------------------------------------------- void vtkXdmfWriter::StartTopology( ostream& ost, int cellType, vtkIdType numVert, vtkIdType numCells ) { ost << "IncrementIndent(); switch( cellType ) { case VTK_EMPTY_CELL : vtkDebugMacro(<< "Start Empty Cell"); case VTK_VERTEX : vtkDebugMacro(<< "Start " << " VERTEX"); ost << " TopologyType=\"POLYVERTEX\""; this->Indent(ost); break; case VTK_POLY_VERTEX : vtkDebugMacro(<< "Start " << " POLY_VERTEX"); ost << " TopologyType=\"POLYVERTEX\""; this->Indent(ost); break; case VTK_LINE : vtkDebugMacro(<< "Start " << " LINE"); ost << " TopologyType=\"POLYLINE\""; this->Indent(ost); ost << " NodesPerElement=\"" << numVert << "\""; this->Indent(ost); break; case VTK_POLY_LINE : vtkDebugMacro(<< "Start " << " POLY_LINE"); ost << " TopologyType=\"POLYLINE\""; this->Indent(ost); ost << " NodesPerElement=\"" << numVert << "\""; this->Indent(ost); break; case VTK_TRIANGLE : vtkDebugMacro(<< "Start " << " TRIANGLE"); ost << " TopologyType=\"TRIANGLE\""; this->Indent(ost); break; case VTK_TRIANGLE_STRIP : vtkDebugMacro(<< "Start " << " TRIANGLE_STRIP"); ost << " TopologyType=\"TRIANGLE\""; this->Indent(ost); break; case VTK_POLYGON : vtkDebugMacro(<< "Start " << " POLYGON"); ost << " TopologyType=\"POLYGON\""; this->Indent(ost); ost << " NodesPerElement=\"" << numVert << "\""; this->Indent(ost); break; case VTK_PIXEL : vtkDebugMacro(<< "Start " << " PIXEL"); ost << " TopologyType=\"QUADRILATERAL\""; this->Indent(ost); break; case VTK_QUAD : vtkDebugMacro(<< "Start " << " QUAD"); ost << " TopologyType=\"QUADRILATERAL\""; this->Indent(ost); break; case VTK_TETRA : vtkDebugMacro(<< "Start " << " TETRA"); ost << " TopologyType=\"TETRAHEDRON\""; this->Indent(ost); break; case VTK_VOXEL : vtkDebugMacro(<< "Start " << " VOXEL"); ost << " TopologyType=\"HEXAHEDRON\""; this->Indent(ost); break; case VTK_HEXAHEDRON : vtkDebugMacro(<< "Start " << " HEXAHEDRON"); ost << " TopologyType=\"HEXAHEDRON\""; this->Indent(ost); break; case VTK_WEDGE : vtkDebugMacro(<< "Start " << " WEDGE"); ost << " TopologyType=\"WEDGE\""; this->Indent(ost); break; case VTK_PYRAMID : vtkDebugMacro(<< "Start " << " PYRAMID"); ost << " TopologyType=\"PYRAMID\""; this->Indent(ost); break; default : vtkErrorMacro("Unknown Topology Type"); break; } ost << " Dimensions=\"" << numCells << "\">"; this->Indent(ost); } //---------------------------------------------------------------------------- template vtkIdType vtkXdmfWriterWriteXMLScalar(vtkXdmfWriter* self, ostream& ost, AType* array, vtkDataSet* dataSet, int* scaledExtent, const char* dataName, const char* arrayName, const char* gridName, const char* scalar_type, NType value, int allLight, int type, int dims[3], int cellData) { if ( !array ) { vtkErrorWithObjectMacro(self, "No array specified. Should be " << scalar_type << " array"); return -2; } int updateExtent[6]; int extent[6]; int useExtents = 0; int scaledDims[3] = { -1, -1, -1 }; // vtkGenericDebugMacro(<< "Dataset: " << arrayName << "\n"); int cc; if ( scaledExtent ) { for ( cc = 0; cc < 3; cc ++ ) { updateExtent[cc*2] = scaledExtent[cc*2]; updateExtent[cc*2+1] = scaledExtent[cc*2+1]; extent[cc*2] = scaledExtent[cc*2]; extent[cc*2+1] = scaledExtent[cc*2+1]; scaledDims[cc] = scaledExtent[cc*2+1] - scaledExtent[cc*2] + 1; } if ( array->GetNumberOfComponents() == 1 ) { extent[0] = 0; extent[1] = array->GetNumberOfTuples()+1; } useExtents = 1; } else { switch ( dataSet->GetDataObjectType() ) { case VTK_STRUCTURED_GRID: { vtkStructuredGrid* grid = vtkStructuredGrid::SafeDownCast(dataSet); grid->GetUpdateExtent(updateExtent); grid->GetExtent(extent); if ( cellData ) { for ( cc = 0; cc < 3; cc ++ ) { updateExtent[cc*2+1] -= 1; extent[cc*2+1] -= 1; updateExtent[cc*2+1] = vtkMAX(0, updateExtent[cc*2+1]); extent[cc*2+1] = vtkMAX(0, extent[cc*2+1]); } } useExtents = 1; } break; case VTK_RECTILINEAR_GRID: { vtkRectilinearGrid* grid = vtkRectilinearGrid::SafeDownCast(dataSet); grid->GetUpdateExtent(updateExtent); grid->GetExtent(extent); if ( cellData ) { // vtkGenericDebugMacro(<< "Fix for cell arrays" << "\n"); // vtkGenericDebugMacro(<< "Extent: " << extent[0] << " " << extent[1] << " " << extent[2] << " " << extent[3] << " " << extent[4] << " " << extent[5] << "\n"); // vtkGenericDebugMacro(<< "updateExtent: " << updateExtent[0] << " " << updateExtent[1] << " " << updateExtent[2] << " " << updateExtent[3] << " " << updateExtent[4] << " " << updateExtent[5] << "\n"); for ( cc = 0; cc < 3; cc ++ ) { updateExtent[cc*2+1] -= 1; extent[cc*2+1] -= 1; updateExtent[cc*2+1] = vtkMAX(0, updateExtent[cc*2+1]); extent[cc*2+1] = vtkMAX(0, extent[cc*2+1]); } } useExtents = 1; } break; case VTK_UNIFORM_GRID: { vtkUniformGrid* grid = vtkUniformGrid::SafeDownCast(dataSet); grid->GetUpdateExtent(updateExtent); grid->GetExtent(extent); useExtents = 1; for ( cc = 0; cc < 6; cc ++ ) { updateExtent[cc*2+1] -= cellData; extent[cc*2+1] -= cellData; updateExtent[cc*2+1] = vtkMAX(0, updateExtent[cc*2+1]); extent[cc*2+1] = vtkMAX(0, extent[cc*2+1]); } } break; case VTK_IMAGE_DATA: case VTK_STRUCTURED_POINTS: { vtkImageData* grid = vtkImageData::SafeDownCast(dataSet); grid->GetUpdateExtent(updateExtent); grid->GetExtent(extent); for ( cc = 0; cc < 3; cc ++ ) { updateExtent[cc*2+1] -= cellData; extent[cc*2+1] -= cellData; updateExtent[cc*2+1] = vtkMAX(0, updateExtent[cc*2+1]); extent[cc*2+1] = vtkMAX(0, extent[cc*2+1]); } useExtents = 1; } break; } } if ( useExtents ) { for ( cc = 0; cc < 3; cc ++ ) { // vtkGenericDebugMacro(<< "Dims[" << cc << "]: " << dims[cc] << "\n"); // cout << "Dims[" << cc << "]: " << dims[cc] << endl; } for ( cc = 0; cc < 3; cc ++ ) { // vtkGenericDebugMacro(<< "UExt[" << cc << "]: " << updateExtent[cc*2] << " - " << updateExtent[cc*2+1] << "\n"); // cout << "UExt[" << cc << "]: " << updateExtent[cc*2] << " - " << updateExtent[cc*2+1] << endl; } for ( cc = 0; cc < 3; cc ++ ) { // vtkGenericDebugMacro(<< "RExt[" << cc << "]: " << extent[cc*2] << " - " << extent[cc*2+1] << "\n"); // cout << "RExt[" << cc << "]: " << extent[cc*2] << " - " << extent[cc*2+1] << endl; } } if (!self->GetInputsArePieces() || (self->GetInputsArePieces() && self->CurrentInputNumber==0)) { ost << "IncrementIndent(); if ( dataName ) { self->Indent(ost); ost << " Name=\"" << dataName << "\""; } self->Indent(ost); ost << " NumberType=\"" << scalar_type << "\""; self->Indent(ost); int precision = 1; switch ( type ) { case XDMF_FLOAT64_TYPE: case XDMF_INT64_TYPE: precision = 8; break; case XDMF_FLOAT32_TYPE: case XDMF_INT32_TYPE: case XDMF_UINT32_TYPE: precision = 4; break; case XDMF_INT16_TYPE: case XDMF_UINT16_TYPE: precision = 2; break; } if ( precision > 1 ) { ost << " Precision=\"" << precision << "\""; self->Indent(ost); } else if ( type == XDMF_FLOAT32_TYPE ) { ost << " Precision=\"4\""; self->Indent(ost); } ost << " Dimensions=\""; // WritePoints sets dims to -10 as a signal // But a single plane can set dims to -1 if(dims[0] > -2){ // cout << "Fixing Dims" << endl; dims[0] = vtkMAX(1, dims[0]); dims[1] = vtkMAX(1, dims[1]); dims[2] = vtkMAX(1, dims[2]); // cout << "New Dims = " << dims[0] << ", " << dims[1] << ", " << dims[2] << endl; } if ( dims[0] < 1 ) { if ( scaledDims[0] < 1 ) { ost << array->GetNumberOfTuples(); } else { ost << scaledDims[0]; } } else { if (self->GetInputsArePieces()) { // vtkGenericDebugMacro(<< "Using Custom Disk Shape " << self->GetFullGridSize()[0] << " " << self->GetFullGridSize()[1] << " " << self->GetFullGridSize()[2] << "\n"); ost << self->GetFullGridSize()[0] << " " << self->GetFullGridSize()[1] << " " << self->GetFullGridSize()[2]; } else { ost << dims[2] << " " << dims[1] << " " << dims[0]; } } if ( array->GetNumberOfComponents() > 1 ) { ost << " " << array->GetNumberOfComponents(); } ost << "\""; self->Indent(ost); } // if all light, piece writing is knackered NType val = value; if ( allLight ) { ost << " Format=\"XML\">"; vtkIdType jj, kk; vtkIdType xx, yy, zz; if ( useExtents ) { int printOne = 0; // vtkGenericDebugMacro(<< "Use Extent" << "\n"); jj = 0; vtkIdType idx = 0; vtkIdType size = (updateExtent[1]-updateExtent[0] + 1) * (updateExtent[3]-updateExtent[2] + 1) * (updateExtent[5]-updateExtent[4] + 1); // vtkGenericDebugMacro(<< "Size: " << size << " " << array->GetNumberOfComponents() << "\n"); if ( size != array->GetNumberOfTuples() ) { // Error vtkErrorWithObjectMacro(self, "Wrong number of tuples in the dataset. Found " << array->GetNumberOfTuples() << " expected: " << size); } for ( zz = extent[4]; zz <= extent[5]; ++ zz) { for ( yy = extent[2]; yy <= extent[3]; ++ yy) { for ( xx = extent[0]; xx <= extent[1]; ++ xx) { if ( xx >= updateExtent[0] && xx <= updateExtent[1] && yy >= updateExtent[2] && yy <= updateExtent[3] && zz >= updateExtent[4] && zz <= updateExtent[5]) { if ( jj % 3 == 0 ) { self->Indent(ost); } for ( kk = 0; kk < array->GetNumberOfComponents(); kk ++ ) { val = array->GetValue(idx * array->GetNumberOfComponents() + kk); ost << " " << val; printOne ++; } jj ++; } idx ++; } } } if ( !printOne ) { abort(); } } else { for ( jj = 0; jj < array->GetNumberOfTuples(); jj ++ ) { if ( jj % 3 == 0 ) { self->Indent(ost); } for ( kk = 0; kk < array->GetNumberOfComponents(); kk ++ ) { val = array->GetValue(jj * array->GetNumberOfComponents() + kk); ost << " " << val; } } } } else { const char *DataSetName; XdmfHDF H5; XdmfArray Data; XdmfInt64 h5dims[5]; int nh5dims = 0; // Jerry // return( array->GetNumberOfTuples() ); DataSetName = self->GenerateHDF5ArrayName(gridName, arrayName); if (!self->GetInputsArePieces() || (self->GetInputsArePieces() && self->CurrentInputNumber==0)) { ost << " Format=\"HDF\">"; self->Indent(ost); ost << " " << DataSetName; // self->Indent(ost); } if ( dims[0] < 1 ) { h5dims[0] = array->GetNumberOfTuples(); h5dims[1] = array->GetNumberOfComponents(); nh5dims = 2; } else { h5dims[0] = dims[2]; h5dims[1] = dims[1]; h5dims[2] = dims[0]; h5dims[3] = array->GetNumberOfComponents(); nh5dims = 4; if ( h5dims[3] <= 1 ) { nh5dims = 3; } //vtkDebugMacro(<< "Use dims: " << h5dims[0] << " " << h5dims[1] << " " << h5dims[2]<< " " << h5dims[3] << " (" << nh5dims << ")" << "\n"); } Data.SetNumberType(type); //vtkDebugMacro(<< "Data type: " << type << "\n"); Data.SetShape(nh5dims, h5dims); /* This is too slow vtkIdType jj, kk; vtkIdType pos = 0; for ( jj = 0; jj < array->GetNumberOfTuples(); jj ++ ) { for ( kk = 0; kk < array->GetNumberOfComponents(); kk ++ ) { Data.SetValue(pos, array->GetValue(pos)); pos ++; } } */ // vtkGenericDebugMacro(<< "Required: " << array->GetNumberOfTuples() << " * " << array->GetNumberOfComponents() << " =" << (array->GetNumberOfTuples() * array->GetNumberOfComponents()) << "\n"); if ( useExtents ) { vtkIdType jj = 0; vtkIdType idx = 0; vtkIdType kk; vtkIdType xx, yy, zz; vtkIdType size = (updateExtent[1]-updateExtent[0] + 1) * (updateExtent[3]-updateExtent[2] + 1) * (updateExtent[5]-updateExtent[4] + 1); // vtkGenericDebugMacro(<< "Size: " << size << " " << array->GetNumberOfComponents() << "\n"); if ( size != array->GetNumberOfTuples() ) { // Error vtkErrorWithObjectMacro(self, "Wrong number of tuples in the dataset. Found " << array->GetNumberOfTuples() << " expected: " << size); } for ( zz = extent[4]; zz <= extent[5]; ++ zz) { for ( yy = extent[2]; yy <= extent[3]; ++ yy) { for ( xx = extent[0]; xx <= extent[1]; ++ xx) { if ( xx >= updateExtent[0] && xx <= updateExtent[1] && yy >= updateExtent[2] && yy <= updateExtent[3] && zz >= updateExtent[4] && zz <= updateExtent[5]) { for ( kk = 0; kk < array->GetNumberOfComponents(); kk ++ ) { val = array->GetValue(idx * array->GetNumberOfComponents() + kk); Data.SetValue(jj++, val); } } idx ++; } } } } else { Data.SetValues(0, array->GetPointer(0), array->GetNumberOfTuples() * array->GetNumberOfComponents()); } H5.CopyType( &Data ); int src_npts=-1; if (self->GetInputsArePieces()) { // Set the Full Array Shape // vtkGenericDebugMacro(<< "Using Custom Disk Shape " << "\n"); h5dims[0] = self->GetFullGridSize()[2]; h5dims[1] = self->GetFullGridSize()[1]; h5dims[2] = self->GetFullGridSize()[0]; H5.SetShape(nh5dims, h5dims); // Set a hyperslab to define only our piece XdmfInt64 start[4] = {extent[4], extent[2], extent[0], 0}; XdmfInt64 stride[4] = {1,1,1,1}; XdmfInt64 count[4] = {dims[2], dims[1], dims[0], h5dims[3]}; H5.SelectHyperSlab(start, stride, count); src_npts = H5Sget_select_npoints( H5.GetDataSpace() ); } else { H5.CopyShape( &Data ); } if( H5.Open( DataSetName, "rw" ) == XDMF_FAIL ) { if( H5.CreateDataset( DataSetName ) == XDMF_FAIL ) { vtkErrorWithObjectMacro(self, "Can't Create Heavy Dataset " << DataSetName); return( -1 ); } } // Set the DataSpace again as it may have been reset in Open Call H5.CopyType( &Data ); src_npts=-1; if (self->GetInputsArePieces()) { // Set the Full Array Shape // vtkGenericDebugMacro(<< "Using Custom Disk Shape " << "\n"); h5dims[0] = self->GetFullGridSize()[2]; h5dims[1] = self->GetFullGridSize()[1]; h5dims[2] = self->GetFullGridSize()[0]; H5.SetShape(nh5dims, h5dims); // Set a hyperslab to define only our piece XdmfInt64 start[4] = { static_cast(extent[4]), static_cast(extent[2]), static_cast(extent[0]), 0}; XdmfInt64 stride[4] = {1,1,1,1}; XdmfInt64 count[4] = {dims[2], dims[1], dims[0], h5dims[3]}; H5.SelectHyperSlab(start, stride, count); src_npts = H5Sget_select_npoints( H5.GetDataSpace() ); } else { H5.CopyShape( &Data ); } // vtkGenericDebugMacro(<< "Writing Disk Shape (offset) " << extent[4] << " " << extent[2] << " " << extent[0] << "\n"); H5.Write( &Data ); H5.Close(); } if (!self->GetInputsArePieces() || (self->GetInputsArePieces() && self->CurrentInputNumber==0)) { self->DecrementIndent(); self->Indent( ost ); ost << ""; } return( array->GetNumberOfTuples() ); } //---------------------------------------------------------------------------- int vtkXdmfWriter::WriteDataArray( ostream& ost, vtkDataArray* array, vtkDataSet* dataSet, int dims[3], const char* Name, const char* Center, int type, const char* gridName, int active, int cellData ) { const char* arrayName = Name; if ( array->GetName() ) { arrayName = array->GetName(); } if (!this->InputsArePieces || (this->InputsArePieces && this->CurrentInputNumber==0)) { ost << "IncrementIndent(); this->Indent(ost); if ( active ) { ost << " Active=\"1\""; this->Indent(ost); } switch ( type ) { case XDMF_ATTRIBUTE_TYPE_SCALAR: ost << " AttributeType=\"Scalar\""; break; case XDMF_ATTRIBUTE_TYPE_VECTOR: ost << " AttributeType=\"Vector\""; break; case XDMF_ATTRIBUTE_TYPE_TENSOR: ost << " AttributeType=\"Tensor\""; break; case XDMF_ATTRIBUTE_TYPE_MATRIX: ost << " AttributeType=\"Matrix\""; break; default: ost << " AttributeType=\"Unknown\""; } this->Indent(ost); ost << " Center=\"" << Center << "\""; this->Indent(ost); ost << " Name=\"" << arrayName << "\">"; this->Indent(ost); } vtkIdType res = this->WriteVTKArray( ost, array, dataSet, 0, dims, arrayName, 0, gridName, this->AllLight, cellData ); if (!this->InputsArePieces || (this->InputsArePieces && this->CurrentInputNumber==0)) { this->DecrementIndent(); this->Indent(ost); ost << ""; this->Indent(ost); } return res; } //---------------------------------------------------------------------------- int vtkXdmfWriter::WriteVTKArray( ostream& ost, vtkDataArray* array, vtkDataSet* dataSet, int *scaledExtent, int dims[3], const char* Name, const char* dataName, const char* gridName, int alllight, int cellData ) { vtkIdType res = -1; switch ( array->GetDataType() ) { case VTK_UNSIGNED_CHAR: res = vtkXdmfWriterWriteXMLScalar(this, ost, vtkUnsignedCharArray::SafeDownCast(array), dataSet, scaledExtent, dataName, Name, gridName, "UChar", static_cast(0), alllight, XDMF_UINT8_TYPE, dims, cellData); break; case VTK_UNSIGNED_SHORT: res = vtkXdmfWriterWriteXMLScalar(this, ost, vtkUnsignedShortArray::SafeDownCast(array), dataSet, scaledExtent, dataName, Name, gridName, "UInt", static_cast(0), alllight, XDMF_UINT16_TYPE, dims, cellData); break; case VTK_UNSIGNED_INT: res = vtkXdmfWriterWriteXMLScalar(this, ost, vtkUnsignedIntArray::SafeDownCast(array), dataSet, scaledExtent, dataName, Name, gridName, "UInt", static_cast(0), alllight, XDMF_UINT32_TYPE, dims, cellData); break; case VTK_CHAR: res = vtkXdmfWriterWriteXMLScalar(this, ost, vtkCharArray::SafeDownCast(array), dataSet, scaledExtent, dataName, Name, gridName, "Char", static_cast(0), alllight, XDMF_INT8_TYPE, dims, cellData); break; case VTK_SHORT: res = vtkXdmfWriterWriteXMLScalar(this, ost, vtkShortArray::SafeDownCast(array), dataSet, scaledExtent, dataName, Name, gridName, "Int", static_cast(0), alllight, XDMF_INT16_TYPE, dims, cellData); break; case VTK_INT: res = vtkXdmfWriterWriteXMLScalar(this, ost, vtkIntArray::SafeDownCast(array), dataSet, scaledExtent, dataName, Name, gridName, "Int", static_cast(0), alllight, XDMF_INT32_TYPE, dims, cellData); break; case VTK_FLOAT: res = vtkXdmfWriterWriteXMLScalar(this, ost, vtkFloatArray::SafeDownCast(array), dataSet, scaledExtent, dataName, Name, gridName, "Float", static_cast(0), alllight, XDMF_FLOAT32_TYPE, dims, cellData); break; case VTK_DOUBLE: res = vtkXdmfWriterWriteXMLScalar(this, ost, vtkDoubleArray::SafeDownCast(array), dataSet, scaledExtent, dataName, Name, gridName, "Float", static_cast(0), alllight, XDMF_FLOAT64_TYPE, dims, cellData); break; case VTK_ID_TYPE: res = vtkXdmfWriterWriteXMLScalar(this, ost, vtkIdTypeArray::SafeDownCast(array), dataSet, scaledExtent, dataName, Name, gridName, "Int", static_cast(0), alllight, sizeof(vtkIdType) == sizeof(int) ? XDMF_INT32_TYPE : XDMF_INT64_TYPE, dims, cellData); break; default: vtkErrorMacro("Unknown scalar type: " << array->GetDataType()); } if ( res == -2 ) { vtkErrorMacro("Cannot convert array to specified type"); } return res; } //---------------------------------------------------------------------------- void vtkXdmfWriter::WriteAttributes( ostream& ost, vtkDataSet* ds, const char* gridName ) { int extent[6]; int cdims[3] = { -1, -1, -1 }; int pdims[3] = { -1, -1, -1 }; ds->GetUpdateExtent(extent); //vtkDebugMacro(<< "Extent: " << extent[0] << " "<< extent[1] << " "<< extent[2] << " "<< extent[3] << " "<< extent[4] << " " << extent[5] << "\n"); if ( extent[1] >= extent[0] && extent[3] >= extent[2] && extent[5] >= extent[4] ) { cdims[0] = pdims[0] = extent[1] - extent[0] +1; cdims[1] = pdims[1] = extent[3] - extent[2] +1; cdims[2] = pdims[2] = extent[5] - extent[4] +1; cdims[0] --; cdims[1] --; cdims[2] --; //vtkDebugMacro(<< "pDims: " << pdims[0] << " " << pdims[1] << " " << pdims[2] << "\n"); //vtkDebugMacro(<< "CDims: " << cdims[0] << " " << cdims[1] << " " << cdims[2] << "\n"); if ( cdims[0] <= 0 && cdims[1] <= 0 && cdims[2] <= 0 ) { // Bogus dimensions. pdims[0] = pdims[1] = pdims[2] = -1; cdims[0] = cdims[1] = cdims[2] = -1; } } vtkCellData *CellData = ds->GetCellData(); vtkPointData *PointData = ds->GetPointData(); int cc; if( CellData ) { for (cc=0; ccGetNumberOfArrays(); cc++) { vtkDataArray* array = CellData->GetArray(cc); int type = XDMF_ATTRIBUTE_TYPE_NONE; if ( array == CellData->GetScalars() || array->GetNumberOfComponents() == 1 ) { type = XDMF_ATTRIBUTE_TYPE_SCALAR; } else if ( array == CellData->GetVectors() || array->GetNumberOfComponents() == 3 ) { type = XDMF_ATTRIBUTE_TYPE_VECTOR; } else if ( array == CellData->GetTensors() || array->GetNumberOfComponents() == 6 ) { type = XDMF_ATTRIBUTE_TYPE_TENSOR; } int active = 0; if ( array == CellData->GetScalars() || array == CellData->GetVectors() || array == CellData->GetTensors() ) { active = 1; } char buffer[100]; sprintf(buffer, "UnnamedCellArray%d", cc); this->WriteDataArray( ost, array, ds, cdims, buffer, "Cell", type, gridName, active, 1 ); } } if( PointData ) { for (cc=0; ccGetNumberOfArrays(); cc++) { vtkDataArray* array = PointData->GetArray(cc); int type = XDMF_ATTRIBUTE_TYPE_NONE; if ( array == PointData->GetScalars() || array->GetNumberOfComponents() == 1 ) { type = XDMF_ATTRIBUTE_TYPE_SCALAR; } else if ( array == PointData->GetVectors() || array->GetNumberOfComponents() == 3 ) { type = XDMF_ATTRIBUTE_TYPE_VECTOR; } else if ( array == PointData->GetTensors() || array->GetNumberOfComponents() == 6 ) { type = XDMF_ATTRIBUTE_TYPE_TENSOR; } int active = 0; if ( array == PointData->GetScalars() || array == PointData->GetVectors() || array == PointData->GetTensors() ) { active = 1; } char buffer[100]; sprintf(buffer, "UnnamedNodeArray%d", cc); this->WriteDataArray( ost, array, ds, pdims, buffer, "Node", type, gridName, active, 0 ); } } } //---------------------------------------------------------------------------- int vtkXdmfWriter::WriteGrid( ostream& ost, const char* gridName, vtkDataSet* ds, void* mapofcell, const void* celltype /* = 0 */) { int type; if( !ds) { vtkErrorMacro("No Input Data Set"); return( -1 ); } // Only do XMl for the first piece if these are pieces of data if (!this->InputsArePieces || (this->InputsArePieces && this->CurrentInputNumber==0)) { ost << "CollectionName ) { ost << " Collection=\"" << this->CollectionName << "\""; } ost << ">"; this->IncrementIndent(); this->Indent(ost); type = ds->GetDataObjectType(); if ( type == VTK_POLY_DATA || type == VTK_UNSTRUCTURED_GRID ) { vtkPointSet *Polys = vtkPointSet::SafeDownCast(ds); const vtkXdmfWriterInternal::CellType* ct = (vtkXdmfWriterInternal::CellType*)celltype; vtkXdmfWriterInternal::MapOfCellTypes* mc = (vtkXdmfWriterInternal::MapOfCellTypes*)mapofcell; if ( ct == 0 ) { ct = &mc->begin()->first; } this->StartTopology( ost, ct->VTKType, ct->NumPoints, (*mc)[*ct]->GetNumberOfIds() ); this->WriteCellArray( ost, ds, gridName, mapofcell, ct ); this->EndTopology( ost ); this->Indent(ost); this->StartGeometry( ost, "XYZ" ); this->WritePoints( ost, Polys->GetPoints(), ds, gridName); this->EndGeometry( ost ); } else if ( type == VTK_STRUCTURED_POINTS || type == VTK_IMAGE_DATA || type == VTK_UNIFORM_GRID ) { double Origin[3], Spacing[3]; //int Extent[6]; int updateExtent[6], wholeextent[6]; vtkImageData *SGrid = static_cast(ds); //SGrid->GetDimensions( Dims ); SGrid->GetOrigin( Origin ); SGrid->GetSpacing( Spacing ); SGrid->GetWholeExtent(wholeextent); //SGrid->GetExtent( Extent ); SGrid->GetUpdateExtent( updateExtent ); if (this->InputsArePieces) { this->StartTopology(ost, "3DCORECTMESH", 3, this->FullGridSize); } else { int Dims[3]; Dims[0] = updateExtent[1] - updateExtent[0] + 1; Dims[1] = updateExtent[3] - updateExtent[2] + 1; Dims[2] = updateExtent[5] - updateExtent[4] + 1; this->StartTopology(ost, "3DCORECTMESH", 3, Dims); } this->EndTopology(ost); this->Indent(ost); this->StartGeometry( ost, "ORIGIN_DXDYDZ" ); this->Indent(ost); int cc; for ( cc = 0; cc < 3; cc ++ ) { Origin[cc] = Origin[cc] + Spacing[cc] * updateExtent[cc * 2]; } // Origin ost << "IncrementIndent(); this->Indent(ost); ost << " Name=\"Origin\""; this->Indent(ost); ost << " NumberType=\"Float\""; this->Indent(ost); ost << " Dimensions=\"3\""; this->Indent(ost); ost << " Format=\"XML\">"; this->Indent(ost); ost << Origin[2] << " " << Origin[1] << " " << Origin[0]; vtkDebugMacro(<< "-- Origin: " << Origin[2] << " " << Origin[1] << " " << Origin[0] << "\n"); this->DecrementIndent(); this->Indent(ost); ost << ""; this->Indent(ost); // DX DY DZ ost << "IncrementIndent(); this->Indent(ost); ost << " Name=\"Spacing\""; this->Indent(ost); ost << " NumberType=\"Float\""; this->Indent(ost); ost << " Dimensions=\"3\""; this->Indent(ost); ost << " Format=\"XML\">"; this->Indent(ost); ost << Spacing[2] << " " << Spacing[1] << " " << Spacing[0]; this->DecrementIndent(); this->Indent(ost); ost << ""; this->EndGeometry( ost ); } else if ( type == VTK_STRUCTURED_GRID ) { int Dims[3]; vtkStructuredGrid *SGrid = static_cast(ds); SGrid->GetDimensions( Dims ); this->StartTopology(ost, "3DSMESH", 3, Dims); this->EndTopology(ost); this->Indent(ost); this->StartGeometry(ost, "XYZ"); this->WritePoints( ost, SGrid->GetPoints(), ds, gridName ); this->EndGeometry(ost); } else if ( type == VTK_RECTILINEAR_GRID ) { int Dims[3]; int updateExtent[6]; vtkDataArray *Coord; vtkRectilinearGrid *RGrid = static_cast(ds); RGrid->GetDimensions( Dims ); RGrid->GetUpdateExtent( updateExtent ); Dims[0] = updateExtent[1] - updateExtent[0] + 1; Dims[1] = updateExtent[3] - updateExtent[2] + 1; Dims[2] = updateExtent[5] - updateExtent[4] + 1; this->StartTopology(ost, "3DRECTMESH", 3, Dims); this->EndTopology( ost ); this->Indent(ost); this->StartGeometry(ost, "VXVYVZ"); int dummydims[3]; dummydims[0] = dummydims[1] = dummydims[2] = -1; // X Coordinated int scaledExtent[6]; int extent[6]; scaledExtent[2] = scaledExtent[4] = 0; scaledExtent[3] = scaledExtent[5] = 0; RGrid->GetExtent(extent); vtkDebugMacro(<< "Update extent: " << updateExtent[0] << " " << updateExtent[1] << " " << updateExtent[2] << " " << updateExtent[3] << " " << updateExtent[4] << " " << updateExtent[5] << "\n"); vtkDebugMacro(<< "Extent: " << extent[0] << " " << extent[1] << " " << extent[2] << " " << extent[3] << " " << extent[4] << " " << extent[5] << "\n"); Coord = RGrid->GetXCoordinates(); // Coord->Print(co ut); scaledExtent[0] = updateExtent[0] - extent[0]; scaledExtent[1] = updateExtent[1] - extent[0]; vtkDebugMacro(<< "Scaled Extent: " << scaledExtent[0] << " " << scaledExtent[1] << "\n"); this->WriteVTKArray( ost, Coord, ds, scaledExtent, dummydims, "X Coordinates", "X", gridName, !this->AllHeavy); this->Indent(ost); // Y Coordinated Coord = RGrid->GetYCoordinates(); scaledExtent[0] = updateExtent[2] - extent[2]; scaledExtent[1] = updateExtent[3] - extent[2]; this->WriteVTKArray( ost, Coord, ds, scaledExtent, dummydims, "Y Coordinates", "Y", gridName, !this->AllHeavy); this->Indent(ost); // Z Coordinated Coord = RGrid->GetZCoordinates(); scaledExtent[0] = updateExtent[4] - extent[4]; scaledExtent[1] = updateExtent[5] - extent[4]; this->WriteVTKArray( ost, Coord, ds, scaledExtent, dummydims, "Z Coordinates", "Z", gridName, !this->AllHeavy); this->EndGeometry(ost); } this->Indent(ost); } if (!this->InputsArePieces || (this->InputsArePieces && this->CurrentInputNumber==0)) { if (this->TimeValue!=-1E99) { ost << ""; } return( 1 ); } //---------------------------------------------------------------------------- void vtkXdmfWriter::Write() { if ( this->AllLight && this->AllHeavy ) { vtkErrorMacro("AllLight and AllHeavy are mutually exclusive. Please only select one."); return; } if ( !this->FileNameString ) { vtkErrorMacro("No file name specified"); return; } int numberOfInputs = this->GetNumberOfInputs(); if ( numberOfInputs <= 0 ) { vtkErrorMacro("No input or input of the wrong type"); return; } bool exists = vtksys::SystemTools::FileExists(this->FileNameString); bool readHeader = false; if (this->AppendGridsToDomain && exists) { /* this->ParseExistingFile(this->FileNameString); XdmfConstString test = this->DOM->Serialize(this->DOM->GetTree()); if (test) { ofstream dummy("c:/xdmftest.xml"); dummy << test; } */ readHeader = this->ReadDocument(this->FileNameString); } ofstream ofs(this->FileNameString); if ( !ofs ) { vtkErrorMacro("Cannot open file: " << this->FileNameString); return; } vtkDebugMacro(<< "Write to file: " << this->FileNameString << "\n"); // // Write header or copy existing file contents // if (readHeader) { ofs << this->DocString; this->IncrementIndent(); if (this->CollectionType != XDMF_GRID_COLLECTION_UNSET) { this->IncrementIndent(); } } else { if ( !this->GridOnly ) { this->WriteHead(ofs); ofs << "DomainName ) { ofs << " Name=\"" << this->DomainName << "\""; } ofs << ">"; } if (this->CollectionType != XDMF_GRID_COLLECTION_UNSET) { this->IncrementIndent(); this->Indent(ofs); ofs << "CollectionType) { case XDMF_GRID_COLLECTION_TEMPORAL: ofs << "Temporal\">"; break; case XDMF_GRID_COLLECTION_SPATIAL: ofs << "Spatial\">"; break; case XDMF_GRID_COLLECTION_UNSET: ofs << "Unset\">"; break; } } } // // Write out grids // this->IncrementIndent(); for (this->CurrentInputNumber=0; this->CurrentInputNumberCurrentInputNumber++) { // vtkDataSet* ds = vtkDataSet::SafeDownCast(this->Inputs[this->CurrentInputNumber]); ds->Update(); vtkstd::string arrayName; vtkDataArray* da = ds->GetFieldData()->GetArray("Name"); if ( da ) { vtkCharArray* nameArray = vtkCharArray::SafeDownCast(da); if ( nameArray ) { arrayName = static_cast(nameArray->GetVoidPointer(0)); } } if ( arrayName.empty() ) { if ( this->GridName ) { arrayName = this->GridName; } else { arrayName = "Unnamed"; } } if ( numberOfInputs>1 && !this->InputsArePieces) { char buffer[100]; sprintf(buffer, "%d", this->CurrentInputNumber); arrayName += buffer; } vtkXdmfWriterInternal::MapOfCellTypes cellTypes; vtkXdmfWriterInternal::DetermineCellTypes(vtkPointSet::SafeDownCast(ds), cellTypes); if ( cellTypes.size() > 1 ) { vtkErrorMacro("Xdmf Writer only supports unstructured data of single cell type"); continue; } if (!this->InputsArePieces || (this->InputsArePieces && this->CurrentInputNumber==0)) { this->Indent(ofs); } if ( cellTypes.size() > 1 ) { vtkXdmfWriterInternal::MapOfCellTypes::iterator it; int ct = 0; for ( it = cellTypes.begin(); it != cellTypes.end(); ++it ) { ostrstream str; str << arrayName.c_str() << "_" << ct << ends; this->WriteGrid(ofs, str.str(), ds, &cellTypes, &(*it)); str.rdbuf()->freeze(2); ct ++; } } else { this->WriteGrid(ofs, arrayName.c_str(), ds, &cellTypes, 0); } } this->DecrementIndent(); if ( !this->GridOnly ) { this->Indent( ofs ); ofs << "" << "\n"; this->WriteTail(ofs); } } //---------------------------------------------------------------------------- void vtkXdmfWriter::CloseCollection() { bool exists = vtksys::SystemTools::FileExists(this->FileNameString); if (this->AppendGridsToDomain && exists) { this->ReadDocument(this->FileNameString); ofstream ofs(this->FileNameString); if ( !ofs ) { vtkErrorMacro("Cannot open file: " << this->FileNameString); return; } ofs << this->DocString; this->IncrementIndent(); this->Indent( ofs ); ofs << "" << "\n"; this->DecrementIndent(); if ( !this->GridOnly ) { this->Indent( ofs ); ofs << "" << "\n"; this->WriteTail(ofs); } } } //---------------------------------------------------------------------------- void vtkXdmfWriter::SetInput(vtkDataSet* ds) { this->SetNthInput(0, ds); } //---------------------------------------------------------------------------- // Add a dataset to the list of data to append. void vtkXdmfWriter::AddInput(vtkDataObject *ds) { this->vtkProcessObject::AddInput(ds); } //---------------------------------------------------------------------------- vtkDataObject *vtkXdmfWriter::GetInput(int idx) { if (idx >= this->NumberOfInputs || idx < 0) { return NULL; } return (vtkDataObject *)(this->Inputs[idx]); } //---------------------------------------------------------------------------- // Remove a dataset from the list of data to append. void vtkXdmfWriter::RemoveInput(vtkDataObject *ds) { this->vtkProcessObject::RemoveInput(ds); } //---------------------------------------------------------------------------- vtkDataSetCollection *vtkXdmfWriter::GetInputList() { int idx; if (this->InputList) { this->InputList->Delete(); } this->InputList = vtkDataSetCollection::New(); for (idx = 0; idx < this->NumberOfInputs; ++idx) { if (this->Inputs[idx] != NULL) { this->InputList->AddItem(static_cast((this->Inputs[idx]))); } } return this->InputList; } //---------------------------------------------------------------------------- void vtkXdmfWriter::StartGeometry( ostream& ost, const char* type ) { ost << ""; this->IncrementIndent(); this->Indent(ost); } //---------------------------------------------------------------------------- void vtkXdmfWriter::EndGeometry( ostream& ost ) { this->DecrementIndent(); this->Indent(ost); ost << ""; } //---------------------------------------------------------------------------- void vtkXdmfWriter::Indent(ostream& os) { int cc; os << "\n"; for ( cc = 0; cc < this->CurrIndent; cc ++ ) { os << " "; } } //---------------------------------------------------------------------------- const char* vtkXdmfWriter::GenerateHDF5ArrayName(const char* gridName, const char* array) { if ( !this->HeavyDataSetNameString ) { vtkErrorMacro("HeavyDataSetName is not yet specified"); return 0; } size_t namelen = strlen(this->HeavyDataSetNameString) + strlen(array); if ( gridName ) { namelen += strlen(gridName); } char *name = new char [ namelen + 10 ]; // Should Use the ENTITY HeavyData if ( gridName ) { sprintf(name, "%s:/%s/%s", this->HeavyDataSetNameString, gridName, array); //sprintf(name, "&HeavyData;:/%s/%s", gridName, array); } else { sprintf(name, "%s:/%s", this->HeavyDataSetNameString, array); //sprintf(name, "&HeavyData;:/%s", array); } this->SetHDF5ArrayName(name); delete [] name; return this->HDF5ArrayName; } //---------------------------------------------------------------------------- bool vtkXdmfWriter::ReadDocument(const char* filename) { if (!vtksys::SystemTools::FileExists(filename)) { return false; } ostrstream temp; ifstream infile(filename); char linebuffer[512]; while (infile.good()) { infile.getline(linebuffer,512); if (vtksys::SystemTools::StringEndsWith(linebuffer, "")) break; temp << linebuffer << "\n"; } temp << ends; if (this->DocString) { delete []this->DocString; } this->DocString = strdup(temp.str()); return true; } //---------------------------------------------------------------------------- void vtkXdmfWriter::PrintSelf(ostream& os, vtkIndent indent) { this->Superclass::PrintSelf(os,indent); } //---------------------------------------------------------------------------- void vtkXdmfWriterInternal::DetermineCellTypes(vtkPointSet * t, vtkXdmfWriterInternal::MapOfCellTypes& vec) { if ( !t ) { return; } vtkIdType cc; vtkGenericCell* cell = vtkGenericCell::New(); for ( cc = 0; cc < t->GetNumberOfCells(); cc ++ ) { vtkXdmfWriterInternal::CellType ct; t->GetCell(cc, cell); ct.VTKType = cell->GetCellType(); ct.NumPoints = cell->GetNumberOfPoints(); vtkXdmfWriterInternal::MapOfCellTypes::iterator it = vec.find(ct); if ( it == vec.end() ) { vtkIdList *l = vtkIdList::New(); it = vec.insert(vtkXdmfWriterInternal::MapOfCellTypes::value_type(ct, vtkSmartPointer(l))).first; l->Delete(); } // it->second->InsertUniqueId(cc);; it->second->InsertNextId(cc);; } cell->Delete(); } xdmf-3.0+git20160803/vtk/Testing/0000740000175000017500000000000013003006557016311 5ustar alastairalastairxdmf-3.0+git20160803/vtk/Testing/Cxx/0000740000175000017500000000000013003006557017053 5ustar alastairalastairxdmf-3.0+git20160803/vtk/Testing/Cxx/CVS/0000740000175000017500000000000013003006557017506 5ustar alastairalastairxdmf-3.0+git20160803/vtk/Testing/Cxx/CVS/Repository0000640000175000017500000000002513003006557021607 0ustar alastairalastairXdmf/vtk/Testing/Cxx xdmf-3.0+git20160803/vtk/Testing/Cxx/CVS/Root0000640000175000017500000000006413003006557020356 0ustar alastairalastair:pserver:anonymous@public.kitware.com:/cvsroot/Xdmf xdmf-3.0+git20160803/vtk/Testing/Cxx/CVS/Entries0000640000175000017500000000014313003006557021042 0ustar alastairalastair/CMakeLists.txt/1.2/Thu Sep 24 14:05:46 2009// /XdmfTestVTKIO.cxx/1.4/Fri Feb 26 15:24:18 2010// D xdmf-3.0+git20160803/vtk/Testing/Cxx/CMakeLists.txt0000640000175000017500000000031013003006557021607 0ustar alastairalastairADD_EXECUTABLE(XdmfTestVTKIO XdmfTestVTKIO.cxx) TARGET_LINK_LIBRARIES(XdmfTestVTKIO vtkIO vtkCommon vtkFiltering vtkGraphics vtkXdmf) ADD_TEST(XdmfTestVTKIO ${EXECUTABLE_OUTPUT_PATH}/XdmfTestVTKIO) xdmf-3.0+git20160803/vtk/Testing/Cxx/XdmfTestVTKIO.cxx0000640000175000017500000001663713003006557022171 0ustar alastairalastair/*========================================================================= Program: Visualization Toolkit Module: $RCSfile: XdmfTestVTKIO.cxx,v $ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen All rights reserved. See Copyright.txt or http://www.kitware.com/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ //Description: //This tests vtkXdmfWriter2 and vtkXdmfReader //It manufactures/reads a bunch of test data objects, writes them to disk //via the xdmfwriter, reads the files back in with the xdmfreader, and //compares the output of the reader against the input to the reader. If //differences are found it fails and stops immediately, leaving any failed //files around for inspection. Otherwise it deletes the temporary files it //creates and returns success. #include "vtkXdmfWriter2.h" #include "vtkCellData.h" #include "vtkDataObject.h" #include "vtkDataObjectGenerator.h" #include "vtkDataSet.h" #include "vtkDataSetWriter.h" #include "vtkFieldData.h" #include "vtkPointData.h" #include "vtkDataSetReader.h" #include "vtksys/SystemTools.hxx" //#include "vtkTemporalFractal.h" //#include "vtkTestUtilities.h" #include "vtkTimeSourceExample.h" #include "vtkXdmfReader.h" #define NUMTESTS 20 const char testobject[NUMTESTS][40] = { "ID1", "ID2", "UF1", "RG1", "SG1", "PD1", "PD2", "UG1", "UG2", "UG3", "UG4", "MB{}", "MB{ID1}", "MB{UF1}", "MB{RG1}", "MB{SG1}", "MB{PD1}", "MB{UG1}", "MB{ ID1 UF1 RG1 SG1 PD1 UG1 }", "HB[ (UF1)(UF1)(UF1) ]", }; bool CleanUpGood = true; bool DoFilesExist(const char*xdmffile, const char*hdf5file, bool deleteIfSo) { bool xexists = (xdmffile?vtksys::SystemTools::FileExists(xdmffile):true); bool hexists = (hdf5file?vtksys::SystemTools::FileExists(hdf5file):true); bool xlenOK = (xdmffile?vtksys::SystemTools::FileLength(xdmffile)!=0:true); bool hlenOK = (hdf5file?vtksys::SystemTools::FileLength(hdf5file)!=0:true); bool theyDo = xexists && xlenOK && hexists && hlenOK; if (theyDo && deleteIfSo && CleanUpGood) { unlink(xdmffile); unlink(hdf5file); } return theyDo; } bool DoDataObjectsDiffer(vtkDataObject *dobj1, vtkDataObject *dobj2) { if (strcmp(dobj1->GetClassName(), dobj2->GetClassName())) { cerr << "Class name test failed " << dobj1->GetClassName() << " != " << dobj2->GetClassName() << endl; //return true; //disable for now } if (dobj1->GetFieldData()->GetNumberOfArrays() != dobj2->GetFieldData()->GetNumberOfArrays()) { cerr << "Number of field arrays test failed" << endl; return true; } if (dobj1->GetEstimatedMemorySize()!=dobj2->GetEstimatedMemorySize()) { cerr << "Mem size test failed" << endl; return true; } vtkDataSet *ds1 = vtkDataSet::SafeDownCast(dobj1); vtkDataSet *ds2 = vtkDataSet::SafeDownCast(dobj2); if (ds1 && ds2) { if ((ds1->GetNumberOfCells() != ds2->GetNumberOfCells()) || (ds1->GetNumberOfPoints() != ds2->GetNumberOfPoints())) { cerr << "Number of Cells/Points test failed" << endl; return true; } double *bds1 = ds1->GetBounds(); double *bds2 = ds2->GetBounds(); if ((bds1[0]!=bds2[0]) || (bds1[1]!=bds2[1]) || (bds1[2]!=bds2[2]) || (bds1[3]!=bds2[3]) || (bds1[4]!=bds2[4]) || (bds1[5]!=bds2[5])) { cerr << "Bounds test failed" << endl; return true; } if ((ds1->GetPointData()->GetNumberOfArrays() != ds2->GetPointData()->GetNumberOfArrays()) || (ds1->GetCellData()->GetNumberOfArrays() != ds2->GetCellData()->GetNumberOfArrays())) { cerr << "Number of data arrays test failed" << endl; return true; } //TODO:Check array names, types, widths and ranges } return false; } bool TestXDMFConversion(vtkDataObject*input, char *prefix) { char xdmffile[256]; char hdf5file[256]; char vtkfile[256]; sprintf(xdmffile, "%s.xmf", prefix); sprintf(hdf5file, "%s.h5", prefix); sprintf(vtkfile, "%s.vtk", prefix); vtkXdmfWriter2 *xwriter = vtkXdmfWriter2::New(); xwriter->SetLightDataLimit(10000); xwriter->WriteAllTimeStepsOn(); xwriter->SetFileName(xdmffile); xwriter->SetInput(input); xwriter->Write(); xwriter->Delete(); vtkDataSet *ds = vtkDataSet::SafeDownCast(input); if (ds) { vtkDataSetWriter *dsw = vtkDataSetWriter::New(); dsw->SetFileName(vtkfile); dsw->SetInput(ds); dsw->Write(); dsw->Delete(); } if (!DoFilesExist(xdmffile, NULL, false)) { cerr << "Writer did not create " << xdmffile << endl; return true; } //TODO: Once it works, enable this vtkXdmfReader *xreader = vtkXdmfReader::New(); xreader->SetFileName(xdmffile); xreader->Update(); vtkDataObject *rOutput = xreader->GetOutputDataObject(0); bool fail = DoDataObjectsDiffer(input, rOutput); if (!fail && CleanUpGood) { //test passed! unlink(xdmffile); unlink(hdf5file); unlink(vtkfile); } xreader->Delete(); return fail; } int main (int ac, char **av) { for (int i = 1; i < ac; i++) { if (!strcmp(av[i], "--dont-clean")) { CleanUpGood = false; } } bool fail = false; //TEST SET 1 vtkDataObjectGenerator *dog = vtkDataObjectGenerator::New(); int i = 0; while (!fail && iSetProgram(testobject[i]); dog->Update(); fail = TestXDMFConversion(dog->GetOutput(), filename); i++; } dog->Delete(); if (fail) { return VTK_ERROR; } //TEST SET 2 cerr << "Test temporal data" << endl; vtkTimeSourceExample *tsrc = vtkTimeSourceExample::New(); tsrc->GrowingOn(); tsrc->SetXAmplitude(2.0); vtkXdmfWriter2 *xwriter = vtkXdmfWriter2::New(); xwriter->SetLightDataLimit(10000); xwriter->WriteAllTimeStepsOn(); xwriter->SetFileName("xdmfIOtest_temporal_1.xmf"); xwriter->SetInputConnection(0,tsrc->GetOutputPort(0)); xwriter->Write(); xwriter->Delete(); tsrc->Delete(); fail = !DoFilesExist("xdmfIOtest_temporal_1.xmf", NULL, true); if (fail) { cerr << "Failed Temporal Test 1" << endl; return VTK_ERROR; } #if 0 if (!vtkTestUtilities::GetDataRoot(ac,av)) { cerr << "NO DATA ROOT" << endl; return 0; } //TEST SET 3 char* fname = vtkTestUtilities::ExpandDataFileName( ac, av, "Data/RectGrid2.vtk"); if (DoFilesExist(fname, NULL, false)) { vtkDataSetReader *dsr = vtkDataSetReader::New(); dsr->SetFileName(fname); dsr->Update(); fail = TestXDMFConversion(dsr->GetOutput(), "xdmfIOtest_DSR_1"); dsr->Delete(); delete[] fname; if (fail) { cerr << "Failed DataSetReader Test 1" << endl; return VTK_ERROR; } dsr = vtkDataSetReader::New(); fname = vtkTestUtilities::ExpandDataFileName( ac, av, "Data/uGridEx.vtk"); dsr->SetFileName(fname); dsr->Update(); fail = TestXDMFConversion(dsr->GetOutput(), "xdmfIOtest_DSR_2"); dsr->Delete(); delete[] fname; if (fail) { cerr << "Failed DataSetReader Test 2" << endl; return VTK_ERROR; } } else { delete[] fname; } #endif //ETC. return 0; } xdmf-3.0+git20160803/vtk/Testing/Tcl/0000740000175000017500000000000013003006557017033 5ustar alastairalastairxdmf-3.0+git20160803/vtk/Testing/Tcl/CVS/0000740000175000017500000000000013003006557017466 5ustar alastairalastairxdmf-3.0+git20160803/vtk/Testing/Tcl/CVS/Repository0000640000175000017500000000002513003006557021567 0ustar alastairalastairXdmf/vtk/Testing/Tcl xdmf-3.0+git20160803/vtk/Testing/Tcl/CVS/Root0000640000175000017500000000006413003006557020336 0ustar alastairalastair:pserver:anonymous@public.kitware.com:/cvsroot/Xdmf xdmf-3.0+git20160803/vtk/Testing/Tcl/CVS/Entries0000640000175000017500000000000213003006557021014 0ustar alastairalastairD xdmf-3.0+git20160803/vtk/Testing/CVS/0000740000175000017500000000000013003006557016744 5ustar alastairalastairxdmf-3.0+git20160803/vtk/Testing/CVS/Repository0000640000175000017500000000002113003006557021041 0ustar alastairalastairXdmf/vtk/Testing xdmf-3.0+git20160803/vtk/Testing/CVS/Root0000640000175000017500000000006413003006557017614 0ustar alastairalastair:pserver:anonymous@public.kitware.com:/cvsroot/Xdmf xdmf-3.0+git20160803/vtk/Testing/CVS/Entries0000640000175000017500000000012013003006557020273 0ustar alastairalastair/CMakeLists.txt/1.2/Fri Aug 21 14:29:32 2009// D/Cxx//// D/Python//// D/Tcl//// xdmf-3.0+git20160803/vtk/Testing/Python/0000740000175000017500000000000013003006557017572 5ustar alastairalastairxdmf-3.0+git20160803/vtk/Testing/Python/CVS/0000740000175000017500000000000013003006557020225 5ustar alastairalastairxdmf-3.0+git20160803/vtk/Testing/Python/CVS/Repository0000640000175000017500000000003013003006557022322 0ustar alastairalastairXdmf/vtk/Testing/Python xdmf-3.0+git20160803/vtk/Testing/Python/CVS/Root0000640000175000017500000000006413003006557021075 0ustar alastairalastair:pserver:anonymous@public.kitware.com:/cvsroot/Xdmf xdmf-3.0+git20160803/vtk/Testing/Python/CVS/Entries0000640000175000017500000000000213003006557021553 0ustar alastairalastairD xdmf-3.0+git20160803/vtk/Testing/CMakeLists.txt0000640000175000017500000000014213003006557021050 0ustar alastairalastair#IF (VTK_WRAP_PYTHON) # ADD_SUBDIRECTORY(Python) #ENDIF (VTK_WRAP_PYTHON) ADD_SUBDIRECTORY(Cxx) xdmf-3.0+git20160803/vtk/vtkSILBuilder.h0000640000175000017500000000436513003006557017542 0ustar alastairalastair/*========================================================================= Program: Visualization Toolkit Module: $RCSfile: vtkSILBuilder.h,v $ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen All rights reserved. See Copyright.txt or http://www.kitware.com/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ // .NAME vtkSILBuilder - helper class to build a SIL i.e. a directed graph used // by reader producing composite datasets to describes the relationships among // the blocks. // .SECTION Description // vtkSILBuilder is a helper class to build a SIL i.e. a directed graph used // by reader producing composite datasets to describes the relationships among // the blocks. // Refer to http://www.paraview.org/Wiki/Block_Hierarchy_Meta_Data for details. #ifndef __vtkSILBuilder_h #define __vtkSILBuilder_h #include "vtkObject.h" class vtkUnsignedCharArray; class vtkStringArray; class vtkMutableDirectedGraph; class VTK_EXPORT vtkSILBuilder : public vtkObject { public: static vtkSILBuilder* New(); vtkTypeRevisionMacro(vtkSILBuilder, vtkObject); void PrintSelf(ostream& os, vtkIndent indent); // Description // Get/Set the graph to populate. void SetSIL(vtkMutableDirectedGraph*); vtkGetObjectMacro(SIL, vtkMutableDirectedGraph); // Description: // Initializes the data-structures. void Initialize(); // Description: // Add vertex, child-edge or cross-edge to the graph. vtkIdType AddVertex(const char* name); vtkIdType AddChildEdge(vtkIdType parent, vtkIdType child); vtkIdType AddCrossEdge(vtkIdType src, vtkIdType dst); // Description: // Returns the vertex id for the root vertex. vtkGetMacro(RootVertex, vtkIdType); //BTX protected: vtkSILBuilder(); ~vtkSILBuilder(); vtkStringArray* NamesArray; vtkUnsignedCharArray* CrossEdgesArray; vtkMutableDirectedGraph* SIL; vtkIdType RootVertex; private: vtkSILBuilder(const vtkSILBuilder&); // Not implemented. void operator=(const vtkSILBuilder&); // Not implemented. //ETX }; #endif xdmf-3.0+git20160803/vtk/vtkXdmfReader.h0000640000175000017500000001615013003006557017620 0ustar alastairalastair/*========================================================================= Program: Visualization Toolkit Module: $RCSfile: vtkXdmfReader.h,v $ Language: C++ Date: $Date: 2010-03-08 15:56:05 $ Version: $Revision: 1.15 $ Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen All rights reserved. See Copyright.txt or http://www.kitware.com/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ // .NAME vtkXdmfReader - Reads eXtensible Data Model and Format files // .SECTION Description // vtkXdmfReader reads XDMF data files so that they can be visualized using // VTK. The output data produced by this reader depends on the number of grids // in the data file. If the data file has a single domain with a single grid, // then the output type is a vtkDataSet subclass of the appropriate type, // otherwise it's a vtkMultiBlockDataSet. // // Refer to vtkDataReader which provides many methods for controlling the // reading of the data file. // .SECTION Caveats // Uses the XDMF API (http://www.xdmf.org) // .SECTION See Also // vtkDataReader #ifndef __vtkXdmfReader_h #define __vtkXdmfReader_h #include "vtkDataReader.h" class vtkXdmfArraySelection; class vtkXdmfDocument; class VTK_EXPORT vtkXdmfReader : public vtkDataReader { public: static vtkXdmfReader* New(); vtkTypeRevisionMacro(vtkXdmfReader, vtkDataReader); void PrintSelf(ostream& os, vtkIndent indent); // Until needed, multiple domains are not supported. //// Description: //// Returns the number of domains present in the data file. This in valid after //// the filename has been set and UpdateInformation() has been called .i.e. the //// RequestInformation pipeline pass has happened. //unsigned int GetNumberOfDomains(); // Description: // Set the active domain. Only one domain can be selected at a time. By // default the first domain in the datafile is chosen. Setting this to null // results in the domain being automatically chosen. Note that if the domain // name is changed, you should explicitly call UpdateInformation() before // accessing information about grids, data arrays etc. vtkSetStringMacro(DomainName); vtkGetStringMacro(DomainName); //// Description: //// Returns the name for the active domain. Note that this may be different //// from what GetDomainName() returns if DomainName is NULL or invalid. // vtkGetStringMacro(ActiveDomainName); // Description: // Get information about point-based arrays. As is typical with readers this // in only valid after the filename is set and UpdateInformation() has been // called. int GetNumberOfPointArrays(); // Description: // Returns the name of point array at the give index. Returns NULL if index is // invalid. const char* GetPointArrayName(int index); // Description: // Get/Set the point array status. int GetPointArrayStatus(const char* name); void SetPointArrayStatus(const char* name, int status); // Description: // Get information about cell-based arrays. As is typical with readers this // in only valid after the filename is set and UpdateInformation() has been // called. int GetNumberOfCellArrays(); const char* GetCellArrayName(int index); void SetCellArrayStatus(const char* name, int status); int GetCellArrayStatus(const char* name); // Description: // Get/Set information about grids. As is typical with readers this is valid // only after the filename as been set and UpdateInformation() has been // called. int GetNumberOfGrids(); const char* GetGridName(int index); void SetGridStatus(const char* gridname, int status); int GetGridStatus(const char* gridname); // Description: // Get/Set information about sets. As is typical with readers this is valid // only after the filename as been set and UpdateInformation() has been // called. Note that sets with non-zero Ghost value are not treated as sets // that the user can select using this API. int GetNumberOfSets(); const char* GetSetName(int index); void SetSetStatus(const char* gridname, int status); int GetSetStatus(const char* gridname); // Description: // These methods are provided to make it easier to use the Sets in ParaView. int GetNumberOfSetArrays() { return this->GetNumberOfSets(); } const char* GetSetArrayName(int index) { return this->GetSetName(index); } int GetSetArrayStatus(const char* name) { return this->GetSetStatus(name); } // Description: // Get/Set the stride used to skip points when reading structured datasets. // This affects all grids being read. vtkSetVector3Macro(Stride, int); vtkGetVector3Macro(Stride, int); // Description: // Determine if the file can be read with this reader. virtual int CanReadFile(const char* filename); // Description: // Every time the SIL is updated a this will return a different value. vtkGetMacro(SILUpdateStamp, int); //BTX protected: vtkXdmfReader(); ~vtkXdmfReader(); virtual int ProcessRequest(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector); virtual int RequestDataObject(vtkInformationVector *outputVector); virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); virtual int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *); virtual int FillOutputPortInformation(int port, vtkInformation *info); vtkXdmfArraySelection* GetPointArraySelection(); vtkXdmfArraySelection* GetCellArraySelection(); vtkXdmfArraySelection* GetGridSelection(); vtkXdmfArraySelection* GetSetsSelection(); void PassCachedSelections(); char* DomainName; // char* ActiveDomainName; int Stride[3]; unsigned int LastTimeIndex; vtkXdmfDocument* XdmfDocument; // Until RequestInformation() is called, the active domain is not set // correctly. If SetGridStatus() etc. are called before that happens, then we // have no place to save the user choices. So we cache them in these temporary // caches. These are passed on to the actual vtkXdmfArraySelection instances // used by the active vtkXdmfDomain in RequestInformation(). // Note that these are only used until the first domain is setup, once that // happens, the information set in these is passed to the domain and these // are cleared an no longer used, until the active domain becomes invalid // again. vtkXdmfArraySelection* PointArraysCache; vtkXdmfArraySelection* CellArraysCache; vtkXdmfArraySelection* GridsCache; vtkXdmfArraySelection* SetsCache; int SILUpdateStamp; private: // Description: // Prepares the XdmfDocument. bool PrepareDocument(); // Description: // Returns the time-step index requested using the UPDATE_TIME_STEPS from the // information. int ChooseTimeStep(vtkInformation* outInfo); private: vtkXdmfReader(const vtkXdmfReader&); // Not implemented void operator=(const vtkXdmfReader&); // Not implemented //ETX }; #endif xdmf-3.0+git20160803/vtk/vtkXdmfWriter2.h0000640000175000017500000001330713003006557017755 0ustar alastairalastair/*========================================================================= Program: Visualization Toolkit Module: $RCSfile: vtkXdmfWriter2.h,v $ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen All rights reserved. See Copyright.txt or http://www.kitware.com/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ // .NAME vtkXdmfWriter2 - write eXtensible Data Model and Format files // .SECTION Description // vtkXdmfWriter2 converts vtkDataObjects to XDMF format. This is intended to // replace vtkXdmfWriter, which is not up to date with the capabilities of the // newer XDMF2 library. This writer understands VTK's composite data types and // produces full trees in the output XDMF files. #ifndef _vtkXdmfWriter2_h #define _vtkXdmfWriter2_h #include "vtkDataObjectAlgorithm.h" #include class vtkExecutive; class vtkCompositeDataSet; class vtkDataSet; class vtkDataObject; class vtkFieldData; class vtkDataArray; class vtkInformation; class vtkInformationVector; class vtkXdmfWriter2DomainMemoryHandler; //BTX class XdmfDOM; class XdmfGrid; class XdmfArray; struct _xmlNode; typedef _xmlNode *XdmfXmlNode; struct vtkXW2NodeHelp { XdmfDOM *DOM; XdmfXmlNode node; bool staticFlag; vtkXW2NodeHelp(XdmfDOM *d, XdmfXmlNode n, bool f) : DOM(d), node(n), staticFlag(f) {}; }; //ETX class VTK_EXPORT vtkXdmfWriter2 : public vtkDataObjectAlgorithm { public: static vtkXdmfWriter2 *New(); vtkTypeRevisionMacro(vtkXdmfWriter2,vtkDataObjectAlgorithm); void PrintSelf(ostream& os, vtkIndent indent); // Description: // Set the input data set. virtual void SetInput(vtkDataObject* dobj); // Description: // Set or get the file name of the xdmf file. vtkSetStringMacro(FileName); vtkGetStringMacro(FileName); // Description: // Set or get the file name of the hdf5 file. // Note that if the File name is not specified, then the group name is ignore vtkSetStringMacro(HeavyDataFileName); vtkGetStringMacro(HeavyDataFileName); // Description: // Set or get the group name into which data will be written // it may contain nested groups as in "/Proc0/Block0" vtkSetStringMacro(HeavyDataGroupName); vtkGetStringMacro(HeavyDataGroupName); // Description: // Write data to output. Method executes subclasses WriteData() method, as // well as StartMethod() and EndMethod() methods. // Returns 1 on success and 0 on failure. virtual int Write(); // Description: // Topology Geometry and Attribute arrays smaller than this are written in line into the XML. // Default is 100. vtkSetMacro(LightDataLimit, int); vtkGetMacro(LightDataLimit, int); //Description: //Controls whether writer automatically writes all input time steps, or //just the timestep that is currently on the input. //Default is OFF. vtkSetMacro(WriteAllTimeSteps, int); vtkGetMacro(WriteAllTimeSteps, int); vtkBooleanMacro(WriteAllTimeSteps, int); // Description: // Called in parallel runs to identify the portion this process is responsible for // TODO: respect this vtkSetMacro(Piece, int); vtkSetMacro(NumberOfPieces, int); //TODO: control choice of heavy data format (xml, hdf5, sql, raw) //TODO: These controls are available in vtkXdmfWriter, but are not used here. //GridsOnly //Append to Domain protected: vtkXdmfWriter2(); ~vtkXdmfWriter2(); //Choose composite executive by default for time. virtual vtkExecutive* CreateDefaultExecutive(); //Can take any one data object virtual int FillInputPortInformation(int port, vtkInformation *info); //Overridden to ... virtual int RequestInformation(vtkInformation*, vtkInformationVector**, vtkInformationVector*); //Overridden to ... virtual int RequestUpdateExtent(vtkInformation*, vtkInformationVector**, vtkInformationVector*); //Overridden to ... virtual int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*); //These do the work: recursively parse down input's structure all the way to arrays, //use XDMF lib to dump everything to file. virtual void CreateTopology(vtkDataSet *ds, XdmfGrid *grid, vtkIdType PDims[3], vtkIdType CDims[3], vtkIdType &PRank, vtkIdType &CRank, void *staticdata); virtual void CreateGeometry(vtkDataSet *ds, XdmfGrid *grid, void *staticdata); virtual void WriteDataSet(vtkDataObject *dobj, XdmfGrid *grid); virtual void WriteCompositeDataSet(vtkCompositeDataSet *dobj, XdmfGrid *grid); virtual void WriteAtomicDataSet(vtkDataObject *dobj, XdmfGrid *grid); virtual void WriteArrays(vtkFieldData* dsa, XdmfGrid *grid, int association, vtkIdType rank, vtkIdType *dims, const char *name); virtual void ConvertVToXArray(vtkDataArray *vda, XdmfArray *xda, vtkIdType rank, vtkIdType *dims, int AllocStrategy, const char *heavyprefix); char *FileName; char *HeavyDataFileName; char *HeavyDataGroupName; int LightDataLimit; int WriteAllTimeSteps; int NumberOfTimeSteps; int CurrentTimeIndex; int Piece; int NumberOfPieces; XdmfDOM *DOM; XdmfGrid *TopTemporalGrid; vtkXdmfWriter2DomainMemoryHandler *DomainMemoryHandler; private: vtkXdmfWriter2(const vtkXdmfWriter2&); // Not implemented void operator=(const vtkXdmfWriter2&); // Not implemented }; #endif /* _vtkXdmfWriter2_h */ xdmf-3.0+git20160803/vtk/vtkXdmfRenderWindowInteractor.cxx.in0000640000175000017500000000531613003006557024042 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : $Id: vtkXdmfRenderWindowInteractor.cxx.in,v 1.2 2007-02-22 13:36:39 clarke Exp $ */ /* Date : $Date: 2007-02-22 13:36:39 $ */ /* Version : $Revision: 1.2 $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2002 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #include #include #include //---------------------------------------------------------------------------- vtkStandardNewMacro(vtkXdmfRenderWindowInteractor); void vtkXdmfRenderWindowInteractor::Start( int Block ) { if ( Block ) { // Check for WIN32 but without Cygwin with X11 #if defined(_WIN32) && !defined(VTK_USE_OGLR) vtkWin32RenderWindowInteractor::Start(); #else vtkXRenderWindowInteractor::Start(); #endif } else { this->LoopOnce(); } } void vtkXdmfRenderWindowInteractor::LoopOnce( ) { // Check for WIN32 but without Cygwin with X11 #if defined(_WIN32) && !defined(VTK_USE_OGLR) MSG msg; while (PeekMessage ( &msg, NULL, 0, 0, PM_NOREMOVE)) { if(GetMessage(&msg, NULL, 0, 0)){ TranslateMessage(&msg); DispatchMessage(&msg); } } #else XEvent event; if (!this->Initialized) { this->Initialize(); } if (! this->Initialized ) { return; } this->BreakLoopFlag = 0; while( XtAppPending( this->App )) { XtAppNextEvent(this->App, &event); XtDispatchEvent(&event); } #endif } xdmf-3.0+git20160803/vtk/vtkXdmfWriter.h0000640000175000017500000001701413003006557017672 0ustar alastairalastair/*========================================================================= Program: Visualization Toolkit Module: $RCSfile: vtkXdmfWriter.h,v $ Language: C++ Date: $Date: 2008-04-16 08:34:55 $ Version: $Revision: 1.2 $ Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen All rights reserved. See Copyright.txt or http://www.kitware.com/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ // .NAME vtkXdmfWriter - write eXtensible Data Model and Format files // .SECTION Description // vtkXdmfWriter is a process object that writes XDMF data. The input to this // writer is a single vtkDataSet object. // .SECTION Caveats // used the XDMF API // .SECTION See Also // vtkDataReader #ifndef _vtkXdmfWriter_h #define _vtkXdmfWriter_h #include "vtkProcessObject.h" // from "XdmfGrid.h" #define XDMF_GRID_COLLECTION_TEMPORAL 0x0001 #define XDMF_GRID_COLLECTION_SPATIAL 0x0002 #define XDMF_GRID_COLLECTION_UNSET 0x0FFFF class vtkDataSet; class vtkPoints; class vtkCellArray; class vtkDataArray; class vtkDataSetCollection; //BTX class XdmfDOM; //ETX class VTK_EXPORT vtkXdmfWriter : public vtkProcessObject { public: static vtkXdmfWriter *New(); vtkTypeRevisionMacro(vtkXdmfWriter,vtkProcessObject); void PrintSelf(ostream& os, vtkIndent indent); // Description: // Set or get the AllLight flag. If set, all data will be written as light // data (inlined). vtkSetClampMacro(AllLight, int, 0, 1); vtkBooleanMacro(AllLight, int); vtkGetMacro(AllLight, int); // Description: // Make all data heavy, including rectilinear grid arrays. vtkSetClampMacro(AllHeavy, int, 0, 1); vtkBooleanMacro(AllHeavy, int); vtkGetMacro(AllHeavy, int); // Description: // Set or get the file name of the xdmf file. virtual void SetFileName(const char* fname); virtual const char* GetFileName(); // Description: // Set or get the grid name of the dataset. vtkSetStringMacro(GridName); vtkGetStringMacro(GridName); // Description: // Set or ger the domain name. vtkSetStringMacro(DomainName); vtkGetStringMacro(DomainName); // Description: // Collection name defines collection grids belong to vtkSetStringMacro(CollectionName); vtkGetStringMacro(CollectionName); // Description: // If GridOnly is set, only the grid will be written and all the header // information will be ignored vtkSetClampMacro(GridOnly, int, 0, 1); vtkBooleanMacro(GridOnly, int); vtkGetMacro(GridOnly, int); // Description: // Set or get the name of the heavy data file name. virtual void SetHeavyDataSetName( const char *name); virtual const char* GetHeavyDataSetName(); // Description: // Set the input data set. virtual void SetInput(vtkDataSet* ds); // Description: // If InputsArePieces is set, the onpuits are considered to be parts/pieces // of a larger grid and are joined together inside the hdf5 file vtkSetClampMacro(InputsArePieces, int, 0, 1); vtkBooleanMacro(InputsArePieces, int); vtkGetMacro(InputsArePieces, int); // Description: // When InputsArePieces is set, this is the true size of the data vtkSetVector3Macro(FullGridSize, int); vtkGetVectorMacro(FullGridSize, int, 3); // Description: // If appending many time steps together into a single file // you should set CollectionType to "Temporal", // when appending grids into a multi-block type structure // use collection type is "Spatial". By default, Collection type is Unset vtkSetMacro(CollectionType, int); vtkGetMacro(CollectionType, int); void SetCollectionTypeToTemporal() { this->SetCollectionType(XDMF_GRID_COLLECTION_TEMPORAL); } void SetCollectionTypeToSpatial() { this->SetCollectionType(XDMF_GRID_COLLECTION_SPATIAL); } void CloseCollection(); // Description: // Set the time value of this data vtkSetMacro(TimeValue, double); vtkGetMacro(TimeValue, double); // Description: // If AppendGridsToDomain is set, the existing xdmf xml file is opeded // and new grid are added to the existing domain inside it. // No checking is performed on the structuire of the file. vtkSetClampMacro(AppendGridsToDomain, int, 0, 1); vtkBooleanMacro(AppendGridsToDomain, int); vtkGetMacro(AppendGridsToDomain, int); // Description: // Write the XDMF file. void Write(); // Description: // Add a dataset to the list of data to append. void AddInput(vtkDataObject *in); // Description: // Get any input of this filter. vtkDataObject *GetInput(int idx); vtkDataObject *GetInput() {return this->GetInput( 0 );} // Description: // Remove a dataset from the list of data to append. void RemoveInput(vtkDataObject *in); // Description: // Returns a copy of the input array. Modifications to this list // will not be reflected in the actual inputs. vtkDataSetCollection *GetInputList(); // Description: // Indent xml void Indent(ostream& ost); void IncrementIndent() { this->CurrIndent ++; } void DecrementIndent() { this->CurrIndent --; } // Description: // Generate hdf5 name for array const char* GenerateHDF5ArrayName(const char* gridName, const char* arrayName); protected: vtkXdmfWriter(); ~vtkXdmfWriter(); void WriteAttributes( ostream& ost, vtkDataSet* ds, const char* gridName ); void StartTopology( ostream& ost, int cellType, vtkIdType numVert, vtkIdType numCells ); void StartTopology( ostream& ost, const char* toptype, int rank, int *dims ); void EndTopology( ostream& ost ); void StartGeometry( ostream& ost, const char* type ); void EndGeometry( ostream& ost ); virtual int WriteHead( ostream& ost ); virtual int WriteTail( ostream& ost ); virtual int WriteGrid( ostream& ost, const char* name, vtkDataSet* ds, void* mapofcells = 0, const void *celltype = 0 ); virtual int WriteCellArray( ostream& ost, vtkDataSet* Cells, const char* gridName, void* mapofcells, const void *celltype ); virtual int WritePoints( ostream& ost, vtkPoints *Points, vtkDataSet* dataSet, const char* gridName ); virtual int WriteDataArray( ostream& ost, vtkDataArray* array, vtkDataSet* ds, int dims[3], const char* Name, const char* Center, int type, const char* gridName, int active, int cellData = 0 ); virtual int WriteVTKArray( ostream& ost, vtkDataArray* array, vtkDataSet* dataSet, int dims[3], int *extents, const char* name, const char* dataName, const char* gridName, int alllight, int cellData = 0); virtual bool ReadDocument(const char* filename); virtual int ParseExistingFile(const char* filename); vtkSetStringMacro(HeavyDataSetNameString); char *HeavyDataSetNameString; vtkSetStringMacro(FileNameString); char *FileNameString; char *GridName; char *DomainName; char *CollectionName; int AllLight; int AllHeavy; int CurrIndent; int GridOnly; int AppendGridsToDomain; int InputsArePieces; int FullGridSize[3]; double TimeValue; vtkSetStringMacro(HDF5ArrayName); char* HDF5ArrayName; // list of data sets to append together. // Here as a convenience. It is a copy of the input array. vtkDataSetCollection *InputList; char *DocString; int CollectionType; XdmfDOM *DOM; public: int CurrentInputNumber; private: vtkXdmfWriter(const vtkXdmfWriter&); // Not implemented void operator=(const vtkXdmfWriter&); // Not implemented }; #endif /* _vtkXdmfWriter_h */ xdmf-3.0+git20160803/vtk/CVS/0000740000175000017500000000000013003006557015327 5ustar alastairalastairxdmf-3.0+git20160803/vtk/CVS/Repository0000640000175000017500000000001113003006557017423 0ustar alastairalastairXdmf/vtk xdmf-3.0+git20160803/vtk/CVS/Root0000640000175000017500000000006413003006557016177 0ustar alastairalastair:pserver:anonymous@public.kitware.com:/cvsroot/Xdmf xdmf-3.0+git20160803/vtk/CVS/Entries0000640000175000017500000000162713003006557016673 0ustar alastairalastair/CMakeLists.txt/1.25/Fri Feb 26 15:23:57 2010// /vtkSILBuilder.cxx/1.1/Fri Aug 21 18:45:35 2009// /vtkSILBuilder.h/1.2/Wed Sep 2 14:36:07 2009// /vtkXdmfDataArray.cxx/1.9/Thu Jul 23 21:23:22 2009// /vtkXdmfDataArray.h/1.3/Tue Sep 16 12:52:12 2008// /vtkXdmfHeavyData.cxx/1.18/Thu Mar 11 19:58:03 2010// /vtkXdmfHeavyData.h/1.6/Fri Feb 26 15:23:58 2010// /vtkXdmfReader.cxx/1.74/Mon Mar 8 15:56:05 2010// /vtkXdmfReader.h/1.15/Mon Mar 8 15:56:05 2010// /vtkXdmfReaderInternal.cxx/1.2/Thu Mar 11 19:24:27 2010// /vtkXdmfReaderInternal.h/1.2/Mon Mar 8 15:56:05 2010// /vtkXdmfRenderWindowInteractor.cxx.in/1.2/Thu Feb 22 13:36:39 2007// /vtkXdmfRenderWindowInteractor.h.in/1.2/Thu Feb 22 13:36:39 2007// /vtkXdmfWriter.cxx/1.7/Fri Mar 13 20:01:09 2009// /vtkXdmfWriter.h/1.2/Wed Apr 16 08:34:55 2008// /vtkXdmfWriter2.cxx/1.25/Tue Mar 16 17:33:39 2010// /vtkXdmfWriter2.h/1.10/Tue Mar 16 17:33:39 2010// D/Testing//// xdmf-3.0+git20160803/vtk/CMakeLists.txt0000640000175000017500000001536013003006557017443 0ustar alastairalastairIF(NOT XDMF_INSTALL_INCLUDE_VTK_DIR) SET(XDMF_INSTALL_INCLUDE_VTK_DIR ${XDMF_INSTALL_INCLUDE_DIR}) ENDIF(NOT XDMF_INSTALL_INCLUDE_VTK_DIR) IF(PV_INSTALL_BIN_DIR) SET(XDMF_INSTALL_BIN_DIR ${PV_INSTALL_BIN_DIR}) ENDIF(PV_INSTALL_BIN_DIR) IF(PV_INSTALL_LIB_DIR) SET(XDMF_INSTALL_LIB_DIR ${PV_INSTALL_LIB_DIR}) ENDIF(PV_INSTALL_LIB_DIR) IF(PV_INSTALL_INCLUDE_DIR) SET(XDMF_INSTALL_INCLUDE_DIR ${PV_INSTALL_INCLUDE_DIR}) ENDIF(PV_INSTALL_INCLUDE_DIR) # This Needs to be done since Xdmf/CMakeLists.txt != # PV/Utils/Xdmf2/CMakeLists.txt # Because INSTALL_* commands require a leading / and because INSTALL (cmake # 2.4 # and newer) requires no leading / to install under INSTALL_PREFIX, we # are stripping the leading /. In the future, there should be no leading # / in any install directory variables STRING(REGEX REPLACE "^/" "" XDMF_INSTALL_LIB_DIR_CM24 "${XDMF_INSTALL_LIB_DIR}") STRING(REGEX REPLACE "^/" "" XDMF_INSTALL_BIN_DIR_CM24 "${XDMF_INSTALL_BIN_DIR}") STRING(REGEX REPLACE "^/" "" XDMF_INSTALL_INCLUDE_DIR_CM24 "${XDMF_INSTALL_INCLUDE_DIR}") STRING(REGEX REPLACE "^/" "" XDMF_INSTALL_INCLUDE_VTK_DIR_CM24 "${XDMF_INSTALL_INCLUDE_VTK_DIR}") SET( Xdmf_SRCS vtkSILBuilder.cxx vtkXdmfDataArray.cxx vtkXdmfHeavyData.cxx #vtkXdmfOpenGLCamera.cxx vtkXdmfReader.cxx vtkXdmfReaderInternal.cxx vtkXdmfWriter2.cxx vtkXdmfWriter.cxx #${Xdmf_BINARY_DIR}/vtk/vtkXdmfRenderWindowInteractor.cxx #vtkXdmfDataSetWriter.cxx ) SET_SOURCE_FILES_PROPERTIES( vtkXdmfReaderInternal vtkXdmfHeavyData WRAP_EXCLUDE ) SET(USE_RENDER_WINDOW_INTERACTOR 1) IF (OSMESA_LIBRARY AND NOT OPENGL_gl_LIBRARY) SET(USE_RENDER_WINDOW_INTERACTOR 0) ENDIF (OSMESA_LIBRARY AND NOT OPENGL_gl_LIBRARY) IF(APPLE) SET(USE_RENDER_WINDOW_INTERACTOR 0) ENDIF(APPLE) IF(USE_RENDER_WINDOW_INTERACTOR) # Build vtkXdmf*RenderWindowInteractor.h IF(WIN32) SET(XDMF_WINDOWINTERACTOR vtkWin32RenderWindowInteractor) CONFIGURE_FILE(${Xdmf_SOURCE_DIR}/vtk/vtkXdmfRenderWindowInteractor.h.in ${Xdmf_BINARY_DIR}/vtk/vtkXdmfRenderWindowInteractor.h @ONLY IMMEDIATE) CONFIGURE_FILE(${Xdmf_SOURCE_DIR}/vtk/vtkXdmfRenderWindowInteractor.cxx.in ${Xdmf_BINARY_DIR}/vtk/vtkXdmfRenderWindowInteractor.cxx @ONLY IMMEDIATE) ELSE(WIN32) IF(VTK_USE_X) INCLUDE_DIRECTORIES(${X11_X11_INCLUDE_PATH}) ENDIF(VTK_USE_X) SET(XDMF_WINDOWINTERACTOR vtkXRenderWindowInteractor) CONFIGURE_FILE(${Xdmf_SOURCE_DIR}/vtk/vtkXdmfRenderWindowInteractor.h.in ${Xdmf_BINARY_DIR}/vtk/vtkXdmfRenderWindowInteractor.h @ONLY IMMEDIATE) CONFIGURE_FILE(${Xdmf_SOURCE_DIR}/vtk/vtkXdmfRenderWindowInteractor.cxx.in ${Xdmf_BINARY_DIR}/vtk/vtkXdmfRenderWindowInteractor.cxx @ONLY IMMEDIATE) ENDIF(WIN32) SET(Xdmf_SRCS ${Xdmf_SRCS} ${Xdmf_BINARY_DIR}/vtk/vtkXdmfRenderWindowInteractor.cxx ) ENDIF(USE_RENDER_WINDOW_INTERACTOR) SET_SOURCE_FILES_PROPERTIES( vtkXdmfDataArray WRAP_EXCLUDE ) SET(VTK_BINARY_DIR "${Xdmf_BINARY_DIR}/vtk") INCLUDE(${VTK_CMAKE_DIR}/vtkExportKit.cmake) VTK_EXPORT_KIT("Xdmf" "XDMF" "${Xdmf_SRCS}") SET(VTK_BINARY_DIR "${Xdmf_BINARY_DIR}/vtk") # if vtk was found include the use vtk file IF (VTK_FOUND) IF(VTK_BUILD_SHARED_LIBS OR BUILD_SHARED_LIBS) SET(LIBTYPE SHARED) ELSE(VTK_BUILD_SHARED_LIBS OR BUILD_SHARED_LIBS) SET(LIBTYPE STATIC) ENDIF(VTK_BUILD_SHARED_LIBS OR BUILD_SHARED_LIBS) ADD_LIBRARY(vtkXdmf ${LIBTYPE} ${Xdmf_SRCS}) TARGET_LINK_LIBRARIES(vtkXdmf vtkIO Xdmf vtkRendering vtkParallel) IF (VTK_USE_MPI) # Needed for mpich 2 ADD_DEFINITIONS("-DMPICH_IGNORE_CXX_SEEK") ENDIF (VTK_USE_MPI) IF(XDMF_BUILD_MPI) # Building MPI ELSE(XDMF_BUILD_MPI) ADD_DEFINITIONS("-DXDMF_NO_MPI") ENDIF(XDMF_BUILD_MPI) # Create Tcl wrappers if VTK is wrapped in Tcl. IF(VTK_WRAP_TCL) INCLUDE(${VTK_CMAKE_DIR}/vtkWrapTcl.cmake OPTIONAL) VTK_WRAP_TCL2(vtk${PROJECT_NAME}TCL XdmfTCL_SRCS ${Xdmf_SRCS}) ADD_LIBRARY(vtk${PROJECT_NAME}TCL ${LIBTYPE} ${XdmfTCL_SRCS} ${Xdmf_SRCS}) TARGET_LINK_LIBRARIES(vtk${PROJECT_NAME}TCL vtkIOTCL vtkRenderingTCL vtkParallelTCL Xdmf) ADD_DEPENDENCIES(vtk${PROJECT_NAME}TCL vtk${PROJECT_NAME}) ENDIF(VTK_WRAP_TCL) # Create Python wrappers if VTK is wrapped in Python. IF(VTK_WRAP_PYTHON) INCLUDE(${VTK_CMAKE_DIR}/vtkWrapPython.cmake OPTIONAL) VTK_WRAP_PYTHON2(vtk${PROJECT_NAME}Python XdmfPython_SRCS ${Xdmf_SRCS}) ADD_LIBRARY(vtk${PROJECT_NAME}Python MODULE ${XdmfPython_SRCS} ${Xdmf_SRCS}) TARGET_LINK_LIBRARIES(vtk${PROJECT_NAME}Python vtkIOPythonD vtkRenderingPythonD vtkParallelPythonD Xdmf) ADD_DEPENDENCIES(vtk${PROJECT_NAME}Python vtk${PROJECT_NAME}) ENDIF(VTK_WRAP_PYTHON) ELSE(VTK_FOUND) MESSAGE(STATUS "Can't find VTK ... no vtkXdmf interface can be built") ENDIF (VTK_FOUND) IF(NOT XDMF_INSTALL_NO_DEVELOPMENT) FILE(GLOB dotHFiles RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*.h") FILE(GLOB binDotHFiles RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${Xdmf_BINARY_DIR}/vtk/*.h") SET(devFiles "${dotHFiles};${binDotHFiles}") INSTALL( FILES ${devFiles} DESTINATION ${XDMF_INSTALL_INCLUDE_VTK_DIR_CM24}) ENDIF(NOT XDMF_INSTALL_NO_DEVELOPMENT) IF (VTK_FOUND) IF(NOT XDMF_INSTALL_NO_LIBRARIES) INSTALL(TARGETS vtkXdmf RUNTIME DESTINATION ${XDMF_INSTALL_BIN_DIR_CM24} COMPONENT Runtime LIBRARY DESTINATION ${XDMF_INSTALL_LIB_DIR_CM24} COMPONENT Runtime ARCHIVE DESTINATION ${XDMF_INSTALL_LIB_DIR_CM24} COMPONENT Development) IF(VTK_WRAP_TCL) INSTALL( TARGETS vtk${PROJECT_NAME}TCL DESTINATION ${XDMF_INSTALL_LIB_DIR_CM24}) # INSTALL_TARGETS(${XDMF_INSTALL_LIB_DIR} vtk${PROJECT_NAME}TCL) ENDIF(VTK_WRAP_TCL) IF(VTK_WRAP_PYTHON) # Get the install path for python modules EXEC_PROGRAM("${PYTHON_EXECUTABLE}" "${Xdmf_SOURCE_DIR}/CMake/" ARGS "setup_install_paths.py" "purelib" --prefix="" OUTPUT_VARIABLE XDMF_WRAP_PYTHON_INSTALL_DIR) SET(XDMF_WRAP_PYTHON_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}${XDMF_WRAP_PYTHON_INSTALL_DIR}/Xdmf) # Replace backslashes with forward slashes IF(WIN32) STRING(REGEX REPLACE "\\\\" "/" XDMF_WRAP_PYTHON_INSTALL_DIR "${XDMF_WRAP_PYTHON_INSTALL_DIR}") ENDIF(WIN32) IF(NOT PYTHON_INCLUDE_PATH) SET(PYTHON_INCLUDE_PATH ${XDMF_INSTALL_INCLUDE_VTK_DIR_CM24}) ENDIF(NOT PYTHON_INCLUDE_PATH) INSTALL( TARGETS vtk${PROJECT_NAME}Python DESTINATION ${XDMF_WRAP_PYTHON_INSTALL_DIR}) # INSTALL( # TARGETS vtk${PROJECT_NAME}Python # DESTINATION ${XDMF_INSTALL_LIB_DIR_CM24}) # INSTALL_TARGETS(${XDMF_INSTALL_LIB_DIR} vtk${PROJECT_NAME}Python) ENDIF(VTK_WRAP_PYTHON) ENDIF(NOT XDMF_INSTALL_NO_LIBRARIES) IF(BUILD_TESTING) ADD_SUBDIRECTORY(Testing) ENDIF(BUILD_TESTING) ENDIF (VTK_FOUND) xdmf-3.0+git20160803/vtk/vtkXdmfDataArray.cxx0000640000175000017500000002772013003006557020646 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : $Id: vtkXdmfDataArray.cxx,v 1.9 2009-07-23 21:23:22 kwleiter Exp $ */ /* Date : $Date: 2009-07-23 21:23:22 $ */ /* Version : $Revision: 1.9 $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2002 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #include #include #include #include #include #include #include #include #include #include #include "vtkShortArray.h" #include "vtkUnsignedShortArray.h" #include //---------------------------------------------------------------------------- vtkStandardNewMacro(vtkXdmfDataArray); //---------------------------------------------------------------------------- vtkXdmfDataArray::vtkXdmfDataArray() { this->Array = NULL; this->vtkArray = NULL; } //---------------------------------------------------------------------------- vtkDataArray *vtkXdmfDataArray::FromXdmfArray( char *ArrayName, int CopyShape, int rank, int Components, int MakeCopy ){ XdmfArray *array = this->Array; XdmfInt64 components = 1; XdmfInt64 tuples = 0; if ( ArrayName != NULL ) { array = TagNameToArray( ArrayName ); } if( array == NULL ){ XdmfErrorMessage("Array is NULL"); return(NULL); } if ( this->vtkArray ) { this->vtkArray->Delete(); this->vtkArray = 0; } switch( array->GetNumberType() ){ case XDMF_INT8_TYPE : if( this->vtkArray == NULL ) { this->vtkArray = vtkCharArray::New(); } break; case XDMF_UINT8_TYPE : if( this->vtkArray == NULL ) { this->vtkArray = vtkUnsignedCharArray::New(); } break; case XDMF_INT16_TYPE : if( this->vtkArray == NULL ) { this->vtkArray = vtkShortArray::New(); } break; case XDMF_UINT16_TYPE : if( this->vtkArray == NULL ) { this->vtkArray = vtkUnsignedShortArray::New(); } break; case XDMF_UINT32_TYPE : if( this->vtkArray == NULL ) { this->vtkArray = vtkUnsignedIntArray::New(); } break; case XDMF_INT32_TYPE : if( this->vtkArray == NULL ) { this->vtkArray = vtkIntArray::New(); } break; case XDMF_INT64_TYPE : if( this->vtkArray == NULL ) { this->vtkArray = vtkLongArray::New(); } break; case XDMF_FLOAT32_TYPE : if( this->vtkArray == NULL ) { this->vtkArray = vtkFloatArray::New(); } break; case XDMF_FLOAT64_TYPE : if( this->vtkArray == NULL ) { this->vtkArray = vtkDoubleArray::New(); } break; default: vtkErrorMacro("Cannot create VTK data array: " << array->GetNumberType()); return 0; } if ( CopyShape ) { if ( array->GetRank() > rank + 1 ) { this->vtkArray->Delete(); this->vtkArray = 0; vtkErrorMacro("Rank of Xdmf array is more than 1 + rank of dataset"); return 0; } if ( array->GetRank() > rank ) { components = array->GetDimension( rank ); } tuples = array->GetNumberOfElements() / components; /// this breaks components = Components; tuples = array->GetNumberOfElements() / components; //cout << "Tuples: " << tuples << " components: " << components << endl; //cout << "Rank: " << rank << endl; this->vtkArray->SetNumberOfComponents( components ); if(MakeCopy) this->vtkArray->SetNumberOfTuples( tuples ); } else { this->vtkArray->SetNumberOfComponents( 1 ); if(MakeCopy) this->vtkArray->SetNumberOfTuples( array->GetNumberOfElements() ); } //cout << "Number type: " << array->GetNumberType() << endl; if(MakeCopy){ switch( array->GetNumberType() ){ case XDMF_INT8_TYPE : array->GetValues( 0, ( XDMF_8_INT*)this->vtkArray->GetVoidPointer( 0 ), array->GetNumberOfElements() ); break; case XDMF_UINT8_TYPE : array->GetValues( 0, ( XDMF_8_U_INT*)this->vtkArray->GetVoidPointer( 0 ), array->GetNumberOfElements() ); break; case XDMF_INT16_TYPE : array->GetValues( 0, ( XDMF_16_INT*)this->vtkArray->GetVoidPointer( 0 ), array->GetNumberOfElements() ); break; case XDMF_UINT16_TYPE : array->GetValues( 0, ( XDMF_16_U_INT*)this->vtkArray->GetVoidPointer( 0 ), array->GetNumberOfElements() ); break; case XDMF_INT32_TYPE : array->GetValues( 0, (XDMF_32_INT *)this->vtkArray->GetVoidPointer( 0 ), array->GetNumberOfElements() ); break; case XDMF_UINT32_TYPE : array->GetValues( 0, (XDMF_32_U_INT *)this->vtkArray->GetVoidPointer( 0 ), array->GetNumberOfElements() ); break; case XDMF_INT64_TYPE : array->GetValues( 0, (XDMF_64_INT *)this->vtkArray->GetVoidPointer( 0 ), array->GetNumberOfElements() ); break; case XDMF_FLOAT32_TYPE : array->GetValues( 0, ( float *)this->vtkArray->GetVoidPointer( 0 ), array->GetNumberOfElements() ); break; case XDMF_FLOAT64_TYPE : array->GetValues( 0, ( double *)this->vtkArray->GetVoidPointer( 0 ), array->GetNumberOfElements() ); break; default : if ( array->GetNumberOfElements() > 0 ) { //cout << "Manual idx" << endl; //cout << "Tuples: " << vtkArray->GetNumberOfTuples() << endl; //cout << "Components: " << vtkArray->GetNumberOfComponents() << endl; //cout << "Elements: " << array->GetNumberOfElements() << endl; vtkIdType jj, kk; vtkIdType idx = 0; for ( jj = 0; jj < vtkArray->GetNumberOfTuples(); jj ++ ) { for ( kk = 0; kk < vtkArray->GetNumberOfComponents(); kk ++ ) { double val = array->GetValueAsFloat64(idx); //cout << "Value: " << val << endl; vtkArray->SetComponent(jj, kk, val); idx ++; } } } break; } }else{ switch( array->GetNumberType() ){ case XDMF_INT8_TYPE : { vtkCharArray *chara = vtkCharArray::SafeDownCast(this->vtkArray); if(!chara){ XdmfErrorMessage("Cannot downcast data array"); return(0); } chara->SetArray((char *)array->GetDataPointer(), components * tuples, 0); } break; case XDMF_UINT8_TYPE : { vtkUnsignedCharArray *uchara = vtkUnsignedCharArray::SafeDownCast(this->vtkArray); if(!uchara){ XdmfErrorMessage("Cannot downcast ucharata array"); return(0); } uchara->SetArray((unsigned char *)array->GetDataPointer(), components * tuples, 0); } break; case XDMF_INT16_TYPE : { vtkShortArray *shorta = vtkShortArray::SafeDownCast(this->vtkArray); if(!shorta){ XdmfErrorMessage("Cannot downcast data array"); return(0); } shorta->SetArray((short *)array->GetDataPointer(), components * tuples, 0); } break; case XDMF_UINT16_TYPE : { vtkUnsignedShortArray *ushorta = vtkUnsignedShortArray::SafeDownCast(this->vtkArray); if(!ushorta){ XdmfErrorMessage("Cannot downcast ushortata array"); return(0); } ushorta->SetArray((unsigned short *)array->GetDataPointer(), components * tuples, 0); } break; case XDMF_INT32_TYPE : { vtkIntArray *inta = vtkIntArray::SafeDownCast(this->vtkArray); if(!inta){ XdmfErrorMessage("Cannot downcast intata array"); return(0); } inta->SetArray((int *)array->GetDataPointer(), components * tuples, 0); } break; case XDMF_UINT32_TYPE : { vtkUnsignedIntArray *uinta = vtkUnsignedIntArray::SafeDownCast(this->vtkArray); if(!uinta){ XdmfErrorMessage("Cannot downcast uintata array"); return(0); } uinta->SetArray((unsigned int *)array->GetDataPointer(), components * tuples, 0); } break; case XDMF_INT64_TYPE : { vtkLongArray *longa = vtkLongArray::SafeDownCast(this->vtkArray); if(!longa){ XdmfErrorMessage("Cannot downcast longa array"); return(0); } longa->SetArray((long *)array->GetDataPointer(), components * tuples, 0); } break; case XDMF_FLOAT32_TYPE : { vtkFloatArray *floata = vtkFloatArray::SafeDownCast(this->vtkArray); if(!floata){ XdmfErrorMessage("Cannot downcast floatata array"); return(0); } floata->SetArray((float *)array->GetDataPointer(), components * tuples, 0); } break; case XDMF_FLOAT64_TYPE : { vtkDoubleArray *doublea = vtkDoubleArray::SafeDownCast(this->vtkArray); if(!doublea){ XdmfErrorMessage("Cannot downcast doubleata array"); return(0); } doublea->SetArray((double *)array->GetDataPointer(), components * tuples, 0); } break; default : XdmfErrorMessage("Can't handle number type"); return(0); break; } array->Reset(); } return( this->vtkArray ); } //---------------------------------------------------------------------------- char *vtkXdmfDataArray::ToXdmfArray( vtkDataArray *DataArray, int CopyShape ){ XdmfArray *array; if ( DataArray == NULL ) { DataArray = this->vtkArray; } if ( DataArray == NULL ) { vtkDebugMacro(<< "Array is NULL"); return(NULL); } if ( this->Array == NULL ){ this->Array = new XdmfArray(); switch( DataArray->GetDataType() ){ case VTK_CHAR : case VTK_UNSIGNED_CHAR : this->Array->SetNumberType( XDMF_INT8_TYPE ); break; case VTK_SHORT : case VTK_UNSIGNED_SHORT : case VTK_INT : case VTK_UNSIGNED_INT : case VTK_LONG : case VTK_UNSIGNED_LONG : this->Array->SetNumberType( XDMF_INT32_TYPE ); break; case VTK_FLOAT : this->Array->SetNumberType( XDMF_FLOAT32_TYPE ); break; case VTK_DOUBLE : this->Array->SetNumberType( XDMF_FLOAT64_TYPE ); break; default : XdmfErrorMessage("Can't handle Data Type"); return( NULL ); } } array = this->Array; if( CopyShape ) { XdmfInt64 Shape[3]; Shape[0] = DataArray->GetNumberOfTuples(); Shape[1] = DataArray->GetNumberOfComponents(); if( Shape[1] == 1 ) { array->SetShape( 1, Shape ); } else { array->SetShape( 2, Shape ); } } switch( array->GetNumberType() ){ case XDMF_INT8_TYPE : array->SetValues( 0, ( unsigned char *)DataArray->GetVoidPointer( 0 ), array->GetNumberOfElements() ); break; case XDMF_INT32_TYPE : case XDMF_INT64_TYPE : array->SetValues( 0, ( int *)DataArray->GetVoidPointer( 0 ), array->GetNumberOfElements() ); break; case XDMF_FLOAT32_TYPE : array->SetValues( 0, ( float *)DataArray->GetVoidPointer( 0 ), array->GetNumberOfElements() ); break; default : array->SetValues( 0, ( double *)DataArray->GetVoidPointer( 0 ), array->GetNumberOfElements() ); break; } return( array->GetTagName() ); } xdmf-3.0+git20160803/vtk/vtkXdmfReader.cxx0000640000175000017500000004423213003006557020175 0ustar alastairalastair/*========================================================================= Program: Visualization Toolkit Module: $RCSfile: vtkXdmfReader.cxx,v $ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen All rights reserved. See Copyright.txt or http://www.kitware.com/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ #include "vtkXdmfReader.h" #include "vtkXdmfReaderInternal.h" #include "vtkXdmfHeavyData.h" #include "vtkCharArray.h" #include "vtkCompositeDataPipeline.h" #include "vtkDataObjectTypes.h" #include "vtkInformation.h" #include "vtkInformationVector.h" #include "vtkMultiBlockDataSet.h" #include "vtkObjectFactory.h" #include "vtkXMLParser.h" //============================================================================ class vtkXdmfReaderTester : public vtkXMLParser { public: vtkTypeMacro(vtkXdmfReaderTester, vtkXMLParser); static vtkXdmfReaderTester* New(); int TestReadFile() { this->Valid = 0; if(!this->FileName) { return 0; } ifstream inFile(this->FileName); if(!inFile) { return 0; } this->SetStream(&inFile); this->Done = 0; this->Parse(); if(this->Done && this->Valid ) { return 1; } return 0; } void StartElement(const char* name, const char**) { this->Done = 1; if(strcmp(name, "Xdmf") == 0) { this->Valid = 1; } } protected: vtkXdmfReaderTester() { this->Valid = 0; this->Done = 0; } private: void ReportStrayAttribute(const char*, const char*, const char*) {} void ReportMissingAttribute(const char*, const char*) {} void ReportBadAttribute(const char*, const char*, const char*) {} void ReportUnknownElement(const char*) {} void ReportXmlParseError() {} int ParsingComplete() { return this->Done; } int Valid; int Done; vtkXdmfReaderTester(const vtkXdmfReaderTester&); // Not implemented void operator=(const vtkXdmfReaderTester&); // Not implemented }; vtkStandardNewMacro(vtkXdmfReaderTester); vtkStandardNewMacro(vtkXdmfReader); vtkCxxRevisionMacro(vtkXdmfReader, "$Revision: 1.74 $"); //---------------------------------------------------------------------------- vtkXdmfReader::vtkXdmfReader() { this->DomainName = 0; this->Stride[0] = this->Stride[1] = this->Stride[2] = 1; this->XdmfDocument = new vtkXdmfDocument(); this->LastTimeIndex = 0; this->SILUpdateStamp = 0; this->PointArraysCache = new vtkXdmfArraySelection; this->CellArraysCache = new vtkXdmfArraySelection; this->GridsCache = new vtkXdmfArraySelection; this->SetsCache = new vtkXdmfArraySelection; } //---------------------------------------------------------------------------- vtkXdmfReader::~vtkXdmfReader() { this->SetDomainName(0); delete this->XdmfDocument; this->XdmfDocument = 0; delete this->PointArraysCache; delete this->CellArraysCache; delete this->GridsCache; delete this->SetsCache; } //---------------------------------------------------------------------------- int vtkXdmfReader::CanReadFile(const char* filename) { vtkXdmfReaderTester* tester = vtkXdmfReaderTester::New(); tester->SetFileName(filename); int res = tester->TestReadFile(); tester->Delete(); return res; } //---------------------------------------------------------------------------- int vtkXdmfReader::FillOutputPortInformation(int, vtkInformation *info) { info->Set(vtkDataObject::DATA_TYPE_NAME(), "vtkDataObject"); return 1; } //---------------------------------------------------------------------------- int vtkXdmfReader::ProcessRequest(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) { // create the output if (request->Has(vtkDemandDrivenPipeline::REQUEST_DATA_OBJECT())) { return this->RequestDataObject(outputVector); } return this->Superclass::ProcessRequest(request, inputVector, outputVector); } //---------------------------------------------------------------------------- bool vtkXdmfReader::PrepareDocument() { // Calling this method repeatedly is okay. It does work only when something // has changed. if (this->GetReadFromInputString()) { const char* data=0; unsigned int data_length=0; if (this->InputArray) { data = this->InputArray->GetPointer(0); data_length = static_cast( this->InputArray->GetNumberOfTuples()* this->InputArray->GetNumberOfComponents()); } else if (this->InputString) { data = this->InputString; data_length = this->InputStringLength; } else { vtkErrorMacro("No input string specified"); return false; } if (!this->XdmfDocument->ParseString(data, data_length)) { vtkErrorMacro("Failed to parse xmf."); return false; } } else { // Parse the file... if (!this->FileName ) { vtkErrorMacro("File name not set"); return false; } // First make sure the file exists. This prevents an empty file // from being created on older compilers. if (!vtksys::SystemTools::FileExists(this->FileName)) { vtkErrorMacro("Error opening file " << this->FileName); return false; } if (!this->XdmfDocument->Parse(this->FileName)) { vtkErrorMacro("Failed to parse xmf file: " << this->FileName); return false; } } if (this->DomainName) { if (!this->XdmfDocument->SetActiveDomain(this->DomainName)) { vtkErrorMacro("Invalid domain: " << this->DomainName); return false; } } else { this->XdmfDocument->SetActiveDomain(static_cast(0)); } if (this->XdmfDocument->GetActiveDomain() && this->XdmfDocument->GetActiveDomain()->GetSIL()->GetMTime() > this->GetMTime()) { this->SILUpdateStamp++; } this->LastTimeIndex = 0; // reset time index when the file changes. return (this->XdmfDocument->GetActiveDomain() != 0); } //---------------------------------------------------------------------------- int vtkXdmfReader::RequestDataObject(vtkInformationVector *outputVector) { if (!this->PrepareDocument()) { return 0; } int vtk_type = this->XdmfDocument->GetActiveDomain()->GetVTKDataType(); if (this->XdmfDocument->GetActiveDomain()->GetSetsSelection()-> GetNumberOfArrays() > 0) { // if the data has any sets, then we are forced to using multiblock. vtk_type = VTK_MULTIBLOCK_DATA_SET; } vtkDataObject* output = vtkDataObject::GetData(outputVector, 0); if (!output || output->GetDataObjectType() != vtk_type) { output = vtkDataObjectTypes::NewDataObject(vtk_type); output->SetPipelineInformation(outputVector->GetInformationObject(0)); this->GetOutputPortInformation(0)->Set( vtkDataObject::DATA_EXTENT_TYPE(), output->GetExtentType()); output->Delete(); } return 1; } //---------------------------------------------------------------------------- int vtkXdmfReader::RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *outputVector) { if (!this->PrepareDocument()) { return 0; } // Pass any cached user-selections to the active domain. this->PassCachedSelections(); vtkInformation* outInfo = outputVector->GetInformationObject(0); vtkXdmfDomain* domain = this->XdmfDocument->GetActiveDomain(); // * Publish the fact that this reader can satisfy any piece request. outInfo->Set(vtkStreamingDemandDrivenPipeline::MAXIMUM_NUMBER_OF_PIECES(), -1); this->LastTimeIndex = this->ChooseTimeStep(outInfo); // Set the requested time-step on the domain. Thus, now when we go to get // information, we can (ideally) get information about that time-step. // this->XdmfDocument->GetActiveDomain()->SetTimeStep(this->LastTimeIndex); // * If producing structured dataset put information about whole extents etc. if (domain->GetNumberOfGrids() == 1 && domain->IsStructured(domain->GetGrid(0)) && domain->GetSetsSelection()->GetNumberOfArrays() == 0) { XdmfGrid* xmfGrid = domain->GetGrid(0); // just in the case the top-level grid is a temporal collection, then pick // the sub-grid to fetch the extents etc. xmfGrid = domain->GetGrid(xmfGrid, domain->GetTimeForIndex(this->LastTimeIndex)); int whole_extent[6]; if (domain->GetWholeExtent(xmfGrid, whole_extent)) { // re-scale the whole_extent using the stride. whole_extent[1] /= this->Stride[0]; whole_extent[3] /= this->Stride[1]; whole_extent[5] /= this->Stride[2]; outInfo->Set(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(), whole_extent, 6); } double origin[3]; double spacing[3]; if (domain->GetOriginAndSpacing(xmfGrid, origin, spacing)) { spacing[0] *= this->Stride[0]; spacing[1] *= this->Stride[1]; spacing[2] *= this->Stride[2]; outInfo->Set(vtkDataObject::ORIGIN(), origin, 3); outInfo->Set(vtkDataObject::SPACING(), spacing, 3); } } // * Publish the SIL which provides information about the grid hierarchy. outInfo->Set(vtkDataObject::SIL(), domain->GetSIL()); // * Publish time information. vtkstd::vector time_steps(domain->GetTimeSteps().begin(), domain->GetTimeSteps().end()); if (time_steps.size() > 0) { outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_STEPS(), &time_steps[0], static_cast(time_steps.size())); double timeRange[2]; timeRange[0] = time_steps.front(); timeRange[1] = time_steps.back(); outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_RANGE(), timeRange, 2); } return 1; } //---------------------------------------------------------------------------- int vtkXdmfReader::RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *outputVector) { if (!this->PrepareDocument()) { return 0; } vtkInformation* outInfo = outputVector->GetInformationObject(0); // * Collect information about what part of the data is requested. unsigned int updatePiece = 0; unsigned int updateNumPieces = 1; int ghost_levels = 0; if (outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER()) && outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_NUMBER_OF_PIECES())) { updatePiece = static_cast( outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER())); updateNumPieces = static_cast( outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_NUMBER_OF_PIECES())); } if (outInfo->Has( vtkStreamingDemandDrivenPipeline::UPDATE_NUMBER_OF_GHOST_LEVELS())) { ghost_levels = outInfo->Get( vtkStreamingDemandDrivenPipeline::UPDATE_NUMBER_OF_GHOST_LEVELS()); } // will be set for structured datasets only. int update_extent[6] = {0, -1, 0, -1, 0, -1}; if (outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_EXTENT())) { outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_EXTENT(), update_extent); } this->LastTimeIndex = this->ChooseTimeStep(outInfo); vtkXdmfHeavyData dataReader(this->XdmfDocument->GetActiveDomain(), this); dataReader.Piece = updatePiece; dataReader.NumberOfPieces = updateNumPieces; dataReader.GhostLevels = ghost_levels; dataReader.Extents[0] = update_extent[0]*this->Stride[0]; dataReader.Extents[1] = update_extent[1]*this->Stride[0]; dataReader.Extents[2] = update_extent[2]*this->Stride[1]; dataReader.Extents[3] = update_extent[3]*this->Stride[1]; dataReader.Extents[4] = update_extent[4]*this->Stride[2]; dataReader.Extents[5] = update_extent[5]*this->Stride[2]; dataReader.Stride[0] = this->Stride[0]; dataReader.Stride[1] = this->Stride[1]; dataReader.Stride[2] = this->Stride[2]; dataReader.Time = this->XdmfDocument->GetActiveDomain()->GetTimeForIndex( this->LastTimeIndex); vtkDataObject* data = dataReader.ReadData(); if (!data) { vtkErrorMacro("Failed to read data."); return 0; } vtkDataObject* output = vtkDataObject::GetData(outInfo); output->ShallowCopy(data); data->Delete(); if (this->LastTimeIndex < this->XdmfDocument->GetActiveDomain()->GetTimeSteps().size()) { double time = this->XdmfDocument->GetActiveDomain()->GetTimeForIndex(this->LastTimeIndex); output->GetInformation()->Set(vtkDataObject::DATA_TIME_STEPS(), &time, 1); } return 1; } //---------------------------------------------------------------------------- int vtkXdmfReader::ChooseTimeStep(vtkInformation* outInfo) { if (outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS())) { // we do not support multiple timestep requests. double time = outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS())[0]; return this->XdmfDocument->GetActiveDomain()->GetIndexForTime(time); } // if no timestep was requested, just return what we read last. return this->LastTimeIndex; } //---------------------------------------------------------------------------- vtkXdmfArraySelection* vtkXdmfReader::GetPointArraySelection() { return this->XdmfDocument->GetActiveDomain()? this->XdmfDocument->GetActiveDomain()->GetPointArraySelection() : this->PointArraysCache; } //---------------------------------------------------------------------------- vtkXdmfArraySelection* vtkXdmfReader::GetCellArraySelection() { return this->XdmfDocument->GetActiveDomain()? this->XdmfDocument->GetActiveDomain()->GetCellArraySelection() : this->CellArraysCache; } //---------------------------------------------------------------------------- vtkXdmfArraySelection* vtkXdmfReader::GetGridSelection() { return this->XdmfDocument->GetActiveDomain()? this->XdmfDocument->GetActiveDomain()->GetGridSelection() : this->GridsCache; } //---------------------------------------------------------------------------- vtkXdmfArraySelection* vtkXdmfReader::GetSetsSelection() { return this->XdmfDocument->GetActiveDomain()? this->XdmfDocument->GetActiveDomain()->GetSetsSelection() : this->SetsCache; } //---------------------------------------------------------------------------- int vtkXdmfReader::GetNumberOfGrids() { return this->GetGridSelection()->GetNumberOfArrays(); } //---------------------------------------------------------------------------- void vtkXdmfReader::SetGridStatus(const char* gridname, int status) { this->GetGridSelection()->SetArrayStatus(gridname, status !=0); this->Modified(); } //---------------------------------------------------------------------------- int vtkXdmfReader::GetGridStatus(const char* arrayname) { return this->GetGridSelection()->GetArraySetting(arrayname); } //---------------------------------------------------------------------------- const char* vtkXdmfReader::GetGridName(int index) { return this->GetGridSelection()->GetArrayName(index); } //---------------------------------------------------------------------------- int vtkXdmfReader::GetNumberOfPointArrays() { return this->GetPointArraySelection()->GetNumberOfArrays(); } //---------------------------------------------------------------------------- void vtkXdmfReader::SetPointArrayStatus(const char* arrayname, int status) { this->GetPointArraySelection()->SetArrayStatus(arrayname, status != 0); this->Modified(); } //---------------------------------------------------------------------------- int vtkXdmfReader::GetPointArrayStatus(const char* arrayname) { return this->GetPointArraySelection()->GetArraySetting(arrayname); } //---------------------------------------------------------------------------- const char* vtkXdmfReader::GetPointArrayName(int index) { return this->GetPointArraySelection()->GetArrayName(index); } //---------------------------------------------------------------------------- int vtkXdmfReader::GetNumberOfCellArrays() { return this->GetCellArraySelection()->GetNumberOfArrays(); } //---------------------------------------------------------------------------- void vtkXdmfReader::SetCellArrayStatus(const char* arrayname, int status) { this->GetCellArraySelection()->SetArrayStatus(arrayname, status != 0); this->Modified(); } //---------------------------------------------------------------------------- int vtkXdmfReader::GetCellArrayStatus(const char* arrayname) { return this->GetCellArraySelection()->GetArraySetting(arrayname); } //---------------------------------------------------------------------------- const char* vtkXdmfReader::GetCellArrayName(int index) { return this->GetCellArraySelection()->GetArrayName(index); } //---------------------------------------------------------------------------- int vtkXdmfReader::GetNumberOfSets() { return this->GetSetsSelection()->GetNumberOfArrays(); } //---------------------------------------------------------------------------- void vtkXdmfReader::SetSetStatus(const char* arrayname, int status) { this->GetSetsSelection()->SetArrayStatus(arrayname, status != 0); this->Modified(); } //---------------------------------------------------------------------------- int vtkXdmfReader::GetSetStatus(const char* arrayname) { return this->GetSetsSelection()->GetArraySetting(arrayname); } //---------------------------------------------------------------------------- const char* vtkXdmfReader::GetSetName(int index) { return this->GetSetsSelection()->GetArrayName(index); } //---------------------------------------------------------------------------- void vtkXdmfReader::PassCachedSelections() { if (!this->XdmfDocument->GetActiveDomain()) { return; } this->GetPointArraySelection()->Merge(*this->PointArraysCache); this->GetCellArraySelection()->Merge(*this->CellArraysCache); this->GetGridSelection()->Merge(*this->GridsCache); this->GetSetsSelection()->Merge(*this->SetsCache); // Clear the cache. this->PointArraysCache->clear(); this->CellArraysCache->clear(); this->GridsCache->clear(); this->SetsCache->clear(); } //---------------------------------------------------------------------------- void vtkXdmfReader::PrintSelf(ostream& os, vtkIndent indent) { this->Superclass::PrintSelf(os, indent); } xdmf-3.0+git20160803/vtk/vtkXdmfWriter2.cxx0000640000175000017500000010747013003006557020335 0ustar alastairalastair/*========================================================================= Program: Visualization Toolkit Module: $RCSfile: vtkXdmfWriter2.cxx,v $ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen All rights reserved. See Copyright.txt or http://www.kitware.com/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ #include "vtkXdmfWriter2.h" #include "vtkObjectFactory.h" #include "vtkDataObject.h" #include "vtkCompositeDataPipeline.h" #include "vtkCompositeDataSet.h" #include "vtkCompositeDataIterator.h" #include "vtkInformation.h" #include "vtkInformationVector.h" #include "vtkFieldData.h" #include "vtkDataSet.h" #include "vtkPointSet.h" #include "vtkPoints.h" #include "vtkImageData.h" #include "vtkRectilinearGrid.h" #include "vtkStructuredGrid.h" #include "vtkSmartPointer.h" #include "vtkCellType.h" #include "vtkIdList.h" #include "vtkUnstructuredGrid.h" #include "vtkPolyData.h" #include "vtkGenericCell.h" #include "vtkCellArray.h" #include "vtkDataSetAttributes.h" #include "vtkPointData.h" #include "vtkCellData.h" #include "vtkTypeTraits.h" #include "XdmfArray.h" #include "XdmfAttribute.h" #include "XdmfDataDesc.h" #include "XdmfDomain.h" #include "XdmfDOM.h" #include "XdmfGeometry.h" #include "XdmfGrid.h" #include "XdmfRoot.h" #include "XdmfTime.h" #include "XdmfTopology.h" #include #include #include #include #include // always after vtkstd::blah stuff #if defined(_WIN32) && !defined(__CYGWIN__) # define SNPRINTF _snprintf #else # define SNPRINTF snprintf #endif class vtkXdmfWriter2DomainMemoryHandler { public: vtkXdmfWriter2DomainMemoryHandler() { domain = new XdmfDomain(); } ~vtkXdmfWriter2DomainMemoryHandler() { for(vtkstd::vector::iterator iter = domainGrids.begin(); iter != domainGrids.end(); ++iter) { delete *iter; } delete domain; } void InsertGrid(XdmfGrid* grid) { domain->Insert(grid); domainGrids.push_back(grid); } void InsertIntoRoot(XdmfRoot& root) { root.Insert(domain); } private: XdmfDomain* domain; vtkstd::vector domainGrids; }; //============================================================================== struct vtkXdmfWriter2Internal { class CellType { public: CellType() : VTKType(0), NumPoints(0) {} CellType(const CellType& ct) : VTKType(ct.VTKType), NumPoints(ct.NumPoints) {} vtkIdType VTKType; vtkIdType NumPoints; vtkstd_bool operator<(const CellType& ct) const { return this->VTKType < ct.VTKType || this->VTKType == ct.VTKType && this->NumPoints < ct.NumPoints; } vtkstd_bool operator==(const CellType& ct) const { return this->VTKType == ct.VTKType && this->NumPoints == ct.NumPoints; } CellType& operator=(const CellType& ct) { this->VTKType = ct.VTKType; this->NumPoints = ct.NumPoints; return *this; } }; typedef vtkstd::map > MapOfCellTypes; static void DetermineCellTypes(vtkPointSet *t, MapOfCellTypes& vec); }; //---------------------------------------------------------------------------- void vtkXdmfWriter2Internal::DetermineCellTypes(vtkPointSet * t, vtkXdmfWriter2Internal::MapOfCellTypes& vec) { if ( !t ) { return; } vtkIdType cc; vtkGenericCell* cell = vtkGenericCell::New(); for ( cc = 0; cc < t->GetNumberOfCells(); cc ++ ) { vtkXdmfWriter2Internal::CellType ct; t->GetCell(cc, cell); ct.VTKType = cell->GetCellType(); ct.NumPoints = cell->GetNumberOfPoints(); vtkXdmfWriter2Internal::MapOfCellTypes::iterator it = vec.find(ct); if ( it == vec.end() ) { vtkIdList *l = vtkIdList::New(); it = vec.insert(vtkXdmfWriter2Internal::MapOfCellTypes::value_type(ct, vtkSmartPointer(l))).first; l->Delete(); } // it->second->InsertUniqueId(cc);; it->second->InsertNextId(cc);; } cell->Delete(); } //============================================================================== vtkStandardNewMacro(vtkXdmfWriter2); vtkCxxRevisionMacro(vtkXdmfWriter2, "$Revision: 1.25 $"); //---------------------------------------------------------------------------- vtkXdmfWriter2::vtkXdmfWriter2() { this->FileName = NULL; this->HeavyDataFileName = NULL; this->HeavyDataGroupName = NULL; this->DOM = NULL; this->Piece = 0; //for parallel this->NumberOfPieces = 1; this->LightDataLimit = 100; this->WriteAllTimeSteps = 0; this->NumberOfTimeSteps = 1; this->CurrentTimeIndex = 0; this->TopTemporalGrid = NULL; this->DomainMemoryHandler = NULL; } //---------------------------------------------------------------------------- vtkXdmfWriter2::~vtkXdmfWriter2() { this->SetFileName(NULL); this->SetHeavyDataFileName(NULL); this->SetHeavyDataGroupName(NULL); if (this->DOM) { delete this->DOM; this->DOM = NULL; } if (this->DomainMemoryHandler) { delete this->DomainMemoryHandler; } if (this->TopTemporalGrid) { delete this->TopTemporalGrid; this->TopTemporalGrid = NULL; } delete this->DomainMemoryHandler; //TODO: Verify memory isn't leaking } //----------------------------------------------------------------------------- vtkExecutive* vtkXdmfWriter2::CreateDefaultExecutive() { return vtkCompositeDataPipeline::New(); } //---------------------------------------------------------------------------- void vtkXdmfWriter2::PrintSelf(ostream& os, vtkIndent indent) { this->Superclass::PrintSelf(os,indent); os << indent << "FileName: " << (this->FileName ? this->FileName : "(none)") << endl; os << indent << "LightDataLimit: " << this->LightDataLimit << endl; os << indent << "WriteAllTimeSteps: " << (this->WriteAllTimeSteps?"ON":"OFF") << endl; } //------------------------------------------------------------------------------ void vtkXdmfWriter2::SetInput(vtkDataObject *input) { if (input) { this->SetInputConnection(0, input->GetProducerPort()); } else { // Setting a NULL input remove the connection. this->SetInputConnection(0, NULL); } } //------------------------------------------------------------------------------ int vtkXdmfWriter2::FillInputPortInformation(int, vtkInformation *info) { info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkDataObject"); return 1; } //------------------------------------------------------------------------------ int vtkXdmfWriter2::Write() { // Make sure we have input. if (this->GetNumberOfInputConnections(0) < 1) { vtkErrorMacro("No input provided!"); return 0; } // always write even if the data hasn't changed this->Modified(); //TODO: Specify name of heavy data companion file? if (!this->DOM) { this->DOM = new XdmfDOM(); } this->DOM->SetOutputFileName(this->FileName); XdmfRoot root; root.SetDOM(this->DOM); root.SetVersion(2.2); root.Build(); if (this->DomainMemoryHandler) { delete this->DomainMemoryHandler; } this->DomainMemoryHandler = new vtkXdmfWriter2DomainMemoryHandler(); this->DomainMemoryHandler->InsertIntoRoot(root); this->Update(); root.Build(); this->DOM->Write(); delete this->DomainMemoryHandler; this->DomainMemoryHandler = NULL; return 1; } //---------------------------------------------------------------------------- int vtkXdmfWriter2::RequestInformation( vtkInformation* vtkNotUsed(request), vtkInformationVector** inputVector, vtkInformationVector* vtkNotUsed(outputVector)) { // Does the input have timesteps? vtkInformation *inInfo = inputVector[0]->GetInformationObject(0); if ( inInfo->Has(vtkStreamingDemandDrivenPipeline::TIME_STEPS()) ) { this->NumberOfTimeSteps = inInfo->Length( vtkStreamingDemandDrivenPipeline::TIME_STEPS() ); } else { this->NumberOfTimeSteps = 1; } return 1; } //---------------------------------------------------------------------------- int vtkXdmfWriter2::RequestUpdateExtent( vtkInformation* vtkNotUsed(request), vtkInformationVector** inputVector, vtkInformationVector* vtkNotUsed(outputVector)) { double *inTimes = inputVector[0]->GetInformationObject(0)->Get( vtkStreamingDemandDrivenPipeline::TIME_STEPS()); if (inTimes && this->WriteAllTimeSteps) { //TODO:? Add a user ivar to specify a particular time, //which is different from current time. Can do it by updating //to a particular time then writing without writealltimesteps, //but that is annoying. double timeReq = inTimes[this->CurrentTimeIndex]; inputVector[0]->GetInformationObject(0)->Set( vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS(), &timeReq, 1); } return 1; } //---------------------------------------------------------------------------- int vtkXdmfWriter2::RequestData( vtkInformation* request, vtkInformationVector** inputVector, vtkInformationVector* vtkNotUsed(outputVector)) { if (!this->DomainMemoryHandler) { //call Write instead of this directly. That does setup first, then calls this. return 1; } if (this->CurrentTimeIndex == 0 && this->WriteAllTimeSteps && this->NumberOfTimeSteps > 1) { // Tell the pipeline to start looping. request->Set(vtkStreamingDemandDrivenPipeline::CONTINUE_EXECUTING(), 1); // make a top level temporal grid just under domain if (this->TopTemporalGrid) { delete this->TopTemporalGrid; this->TopTemporalGrid = NULL; } XdmfGrid *tgrid = new XdmfGrid(); tgrid->SetDeleteOnGridDelete(true); tgrid->SetGridType(XDMF_GRID_COLLECTION); tgrid->SetCollectionType(XDMF_GRID_COLLECTION_TEMPORAL); XdmfTopology *t = tgrid->GetTopology(); t->SetTopologyType(XDMF_NOTOPOLOGY); XdmfGeometry *geo = tgrid->GetGeometry(); geo->SetGeometryType(XDMF_GEOMETRY_NONE); this->DomainMemoryHandler->InsertGrid(tgrid); this->TopTemporalGrid = tgrid; } XdmfGrid *grid = new XdmfGrid(); grid->SetDeleteOnGridDelete(true); if (this->TopTemporalGrid) { this->TopTemporalGrid->Insert(grid); } else { this->DomainMemoryHandler->InsertGrid(grid); } vtkInformation* inInfo = inputVector[0]->GetInformationObject(0); vtkDataObject* input = inInfo->Get(vtkDataObject::DATA_OBJECT()); vtkInformation *inDataInfo = input->GetInformation(); if (inDataInfo->Has(vtkDataObject::DATA_TIME_STEPS())) { //I am assuming we are not given a temporal data object and getting just one time. double *dataT = input->GetInformation()->Get(vtkDataObject::DATA_TIME_STEPS()); //cerr << "Writing " << this->CurrentTimeIndex << " " << *dataT << endl; XdmfTime *xT = grid->GetTime(); xT->SetDeleteOnGridDelete(true); xT->SetTimeType(XDMF_TIME_SINGLE); xT->SetValue(*dataT); grid->Insert(xT); } this->WriteDataSet(input, grid); //delete grid; //domain takes care of it? this->CurrentTimeIndex++; if (this->CurrentTimeIndex >= this->NumberOfTimeSteps && this->WriteAllTimeSteps) { // Tell the pipeline to stop looping. request->Remove(vtkStreamingDemandDrivenPipeline::CONTINUE_EXECUTING()); this->CurrentTimeIndex = 0; //delete this->TopTemporalGrid; //domain takes care of it? this->TopTemporalGrid = NULL; } return 1; } //------------------------------------------------------------------------------ void vtkXdmfWriter2::WriteDataSet(vtkDataObject *dobj, XdmfGrid *grid) { //TODO: // respect parallelism if (!dobj) { //cerr << "Null DS, someone else will take care of it" << endl; return; } if (!grid) { cerr << "Something is wrong, grid should have already been created for " << dobj << endl; return; } vtkCompositeDataSet *cdobj = vtkCompositeDataSet::SafeDownCast(dobj); if (cdobj)//!dobj->IsTypeOf("vtkCompositeDataSet")) //TODO: Why doesn't IsTypeOf work? { this->WriteCompositeDataSet(cdobj, grid); return; } this->WriteAtomicDataSet(dobj, grid); } //------------------------------------------------------------------------------ void vtkXdmfWriter2::WriteCompositeDataSet(vtkCompositeDataSet *dobj, XdmfGrid *grid) { //cerr << "internal node " << dobj << " is a " << dobj->GetClassName() << endl; if (dobj->IsA("vtkMultiPieceDataSet")) { grid->SetGridType(XDMF_GRID_COLLECTION); grid->SetCollectionType(XDMF_GRID_COLLECTION_SPATIAL); } else { //fine for vtkMultiBlockDataSet //vtkHierarchicalBoxDataSet would be better served by a different xdmf tree type //vtkTemporalDataSet is internal to the VTK pipeline so I am ingnoring it grid->SetGridType(XDMF_GRID_TREE); } XdmfTopology *t = grid->GetTopology(); t->SetTopologyType(XDMF_NOTOPOLOGY); XdmfGeometry *geo = grid->GetGeometry(); geo->SetGeometryType(XDMF_GEOMETRY_NONE); vtkCompositeDataIterator* iter = dobj->NewIterator(); iter->VisitOnlyLeavesOff(); iter->TraverseSubTreeOff(); iter->GoToFirstItem(); while (!iter->IsDoneWithTraversal()) { XdmfGrid *childsGrid = new XdmfGrid(); childsGrid->SetDeleteOnGridDelete(true); grid->Insert(childsGrid); vtkDataObject* ds = iter->GetCurrentDataObject(); this->WriteDataSet(ds, childsGrid); //delete childsGrid; //parent deletes children in Xdmf iter->GoToNextItem(); } iter->Delete(); return; } //------------------------------------------------------------------------------ void vtkXdmfWriter2::CreateTopology(vtkDataSet *ds, XdmfGrid *grid, vtkIdType PDims[3], vtkIdType CDims[3], vtkIdType &PRank, vtkIdType &CRank, void *staticdata) { //cerr << "Writing " << dobj << " a " << dobj->GetClassName() << endl; grid->SetGridType(XDMF_GRID_UNIFORM); const char *heavyName = NULL; vtkstd::string heavyDataSetName; if (this->HeavyDataFileName) { heavyDataSetName = vtkstd::string(this->HeavyDataFileName) + ":"; if (this->HeavyDataGroupName) { heavyDataSetName = heavyDataSetName + HeavyDataGroupName + "/Topology"; } heavyName = heavyDataSetName.c_str(); } XdmfTopology *t = grid->GetTopology(); // // If the topology is unchanged from last grid written, we can reuse the XML // and avoid writing any heavy data. We must still compute dimensions etc // otherwise the attribute arrays don't get initialized properly // bool reusing_topology = false; vtkXW2NodeHelp *staticnode = (vtkXW2NodeHelp*)staticdata; if (staticnode) { if (staticnode->staticFlag) { grid->Set("TopologyConstant", "True"); } if (staticnode->DOM && staticnode->node) { XdmfXmlNode staticTopo = staticnode->DOM->FindElement("Topology", 0, staticnode->node); XdmfConstString xmltext = staticnode->DOM->Serialize(staticTopo->children); XdmfConstString dimensions = staticnode->DOM->Get(staticTopo, "Dimensions"); XdmfConstString topologyType = staticnode->DOM->Get(staticTopo, "TopologyType"); // t->SetTopologyTypeFromString(topologyType); t->SetNumberOfElements(atoi(dimensions)); t->SetDataXml(xmltext); reusing_topology = true; // @TODO : t->SetNodesPerElement(ppCell); } } //Topology switch (ds->GetDataObjectType()) { case VTK_STRUCTURED_POINTS: case VTK_IMAGE_DATA: case VTK_UNIFORM_GRID: { t->SetTopologyType(XDMF_3DCORECTMESH); t->SetLightDataLimit(this->LightDataLimit); vtkImageData *id = vtkImageData::SafeDownCast(ds); int wExtent[6]; id->GetExtent(wExtent); XdmfInt64 Dims[3]; Dims[2] = wExtent[1] - wExtent[0] + 1; Dims[1] = wExtent[3] - wExtent[2] + 1; Dims[0] = wExtent[5] - wExtent[4] + 1; XdmfDataDesc *dd = t->GetShapeDesc(); dd->SetShape(3, Dims); //TODO: verify row/column major ordering PDims[0] = Dims[0]; PDims[1] = Dims[1]; PDims[2] = Dims[2]; CDims[0] = Dims[0] - 1; CDims[1] = Dims[1] - 1; CDims[2] = Dims[2] - 1; } break; case VTK_RECTILINEAR_GRID: { t->SetTopologyType(XDMF_3DRECTMESH); vtkRectilinearGrid *rgrid = vtkRectilinearGrid::SafeDownCast(ds); int wExtent[6]; rgrid->GetExtent(wExtent); XdmfInt64 Dims[3]; Dims[2] = wExtent[1] - wExtent[0] + 1; Dims[1] = wExtent[3] - wExtent[2] + 1; Dims[0] = wExtent[5] - wExtent[4] + 1; XdmfDataDesc *dd = t->GetShapeDesc(); dd->SetShape(3, Dims); //TODO: verify row/column major ordering PDims[0] = Dims[0]; PDims[1] = Dims[1]; PDims[2] = Dims[2]; CDims[0] = Dims[0] - 1; CDims[1] = Dims[1] - 1; CDims[2] = Dims[2] - 1; } break; case VTK_STRUCTURED_GRID: { t->SetTopologyType(XDMF_3DSMESH); vtkStructuredGrid *sgrid = vtkStructuredGrid::SafeDownCast(ds); int wExtent[6]; sgrid->GetExtent(wExtent); XdmfInt64 Dims[3]; Dims[2] = wExtent[1] - wExtent[0] + 1; Dims[1] = wExtent[3] - wExtent[2] + 1; Dims[0] = wExtent[5] - wExtent[4] + 1; XdmfDataDesc *dd = t->GetShapeDesc(); dd->SetShape(3, Dims); //TODO: verify row/column major ordering PDims[0] = Dims[0]; PDims[1] = Dims[1]; PDims[2] = Dims[2]; CDims[0] = Dims[0] - 1; CDims[1] = Dims[1] - 1; CDims[2] = Dims[2] - 1; } break; case VTK_POLY_DATA: case VTK_UNSTRUCTURED_GRID: { PRank = 1; PDims[0] = ds->GetNumberOfPoints(); CRank = 1; CDims[0] = ds->GetNumberOfCells(); if (reusing_topology) { // don't need to do all this again // @TODO : t->SetNodesPerElement(ppCell); break; } vtkXdmfWriter2Internal::MapOfCellTypes cellTypes; vtkXdmfWriter2Internal::DetermineCellTypes(vtkPointSet::SafeDownCast(ds), cellTypes); //TODO: When is it beneficial to take advantage of a homogenous topology? //If no compelling reason not to used MIXED, then this should go away. //This special case code requires an in memory copy just to get rid of //each cell's preceeding number of points int. //If don't have to do that, could use pointer sharing, //and the extra code path is bound to cause problems eventually. if ( cellTypes.size() == 1 ) { //cerr << "Homogeneous topology" << endl; t->SetNumberOfElements(ds->GetNumberOfCells()); const vtkXdmfWriter2Internal::CellType* ct = &cellTypes.begin()->first; vtkIdType ppCell = ct->NumPoints; switch(ct->VTKType) { case VTK_VERTEX : case VTK_POLY_VERTEX : t->SetTopologyType(XDMF_POLYVERTEX); break; case VTK_LINE : case VTK_POLY_LINE : t->SetTopologyType(XDMF_POLYLINE); t->SetNodesPerElement(ppCell); break; case VTK_TRIANGLE : case VTK_TRIANGLE_STRIP : t->SetTopologyType(XDMF_TRI); break; case VTK_POLYGON : t->SetTopologyType(XDMF_POLYGON); t->SetNodesPerElement(ppCell); break; case VTK_PIXEL : case VTK_QUAD : t->SetTopologyType(XDMF_QUAD); break; case VTK_TETRA : t->SetTopologyType(XDMF_TET); break; case VTK_VOXEL : case VTK_HEXAHEDRON : t->SetTopologyType(XDMF_HEX); break; case VTK_WEDGE : t->SetTopologyType(XDMF_WEDGE); break; case VTK_PYRAMID : t->SetTopologyType(XDMF_PYRAMID); break; case VTK_EMPTY_CELL : default : t->SetTopologyType(XDMF_NOTOPOLOGY); break; } XdmfArray *di = t->GetConnectivity(); di->SetHeavyDataSetName(heavyName); if (VTK_SIZEOF_ID_TYPE==sizeof(XDMF_64_INT)) { di->SetNumberType(XDMF_INT64_TYPE); } else { di->SetNumberType(XDMF_INT32_TYPE); } XdmfInt64 hDim[2]; hDim[0] = ds->GetNumberOfCells(); hDim[1] = ppCell; di->SetShape(2, hDim); vtkIdList* il = cellTypes[*ct].GetPointer(); vtkIdList* cellPoints = vtkIdList::New(); vtkIdType cvnt=0; for(vtkIdType i = 0 ; i < ds->GetNumberOfCells(); i++ ) { ds->GetCellPoints(il->GetId(i), cellPoints); if ( ct->VTKType == VTK_VOXEL ) { // Hack for VTK_VOXEL di->SetValue(cvnt++, cellPoints->GetId(0)); di->SetValue(cvnt++, cellPoints->GetId(1)); di->SetValue(cvnt++, cellPoints->GetId(3)); di->SetValue(cvnt++, cellPoints->GetId(2)); di->SetValue(cvnt++, cellPoints->GetId(4)); di->SetValue(cvnt++, cellPoints->GetId(5)); di->SetValue(cvnt++, cellPoints->GetId(7)); di->SetValue(cvnt++, cellPoints->GetId(6)); } else if ( ct->VTKType == VTK_PIXEL ) { // Hack for VTK_PIXEL di->SetValue(cvnt++, cellPoints->GetId(0)); di->SetValue(cvnt++, cellPoints->GetId(1)); di->SetValue(cvnt++, cellPoints->GetId(3)); di->SetValue(cvnt++, cellPoints->GetId(2)); } else { for( vtkIdType j = 0 ; j < ppCell ; j++ ) { di->SetValue(cvnt++, cellPoints->GetId(j)); } }//pd has 4 arrays, so it is rarely homogeoneous } cellPoints->Delete(); } //homogenous else { //cerr << "Nonhomogeneous topology" << endl; //Non Homogeneous, used mixed topology type to dump them all t->SetTopologyType(XDMF_MIXED); vtkIdType numCells = ds->GetNumberOfCells(); t->SetNumberOfElements(numCells); XdmfArray *di = t->GetConnectivity(); di->SetHeavyDataSetName(heavyName); if (VTK_SIZEOF_ID_TYPE==sizeof(XDMF_64_INT)) { di->SetNumberType(XDMF_INT64_TYPE); } else { di->SetNumberType(XDMF_INT32_TYPE); } vtkIdTypeArray *da = vtkIdTypeArray::New(); da->SetNumberOfComponents(1); vtkUnstructuredGrid *ugrid = vtkUnstructuredGrid::SafeDownCast(ds); const int ESTIMATE=4; /*celltype+numids+id0+id1 or celtype+id0+id1+id2*/ if (ugrid) { da->Allocate(ugrid->GetCells()->GetSize()*ESTIMATE); } else { vtkPolyData *pd = vtkPolyData::SafeDownCast(ds); vtkIdType sizev = pd->GetVerts()->GetSize(); vtkIdType sizel = pd->GetLines()->GetSize(); vtkIdType sizep = pd->GetPolys()->GetSize(); vtkIdType sizes = pd->GetStrips()->GetSize(); vtkIdType rtotal = sizev+sizel+sizep+sizes; da->Allocate(rtotal*ESTIMATE); } vtkIdType cntr = 0; for (vtkIdType cid=0 ; cid < numCells; cid++) { vtkCell *cell = ds->GetCell(cid); vtkIdType cellType = ds->GetCellType(cid); vtkIdType numPts = cell->GetNumberOfPoints(); switch(cellType) { case VTK_VERTEX : case VTK_POLY_VERTEX : da->InsertValue(cntr++, XDMF_POLYVERTEX); da->InsertValue(cntr++, numPts); break; case VTK_LINE : case VTK_POLY_LINE : da->InsertValue(cntr++, XDMF_POLYLINE); da->InsertValue(cntr++, cell->GetNumberOfPoints()); break; //case VTK_TRIANGLE_STRIP : //TODO: Split tri strips into triangles //t->SetTopologyType(XDMF_TRI); //break; case VTK_TRIANGLE : da->InsertValue(cntr++, XDMF_TRI); break; case VTK_POLYGON : da->InsertValue(cntr++, XDMF_POLYGON); da->InsertValue(cntr++, cell->GetNumberOfPoints()); break; case VTK_PIXEL : case VTK_QUAD : da->InsertValue(cntr++, XDMF_POLYGON); break; case VTK_TETRA : da->InsertValue(cntr++, XDMF_TET); break; case VTK_VOXEL : da->InsertValue(cntr++, XDMF_HEX); break; case VTK_HEXAHEDRON : da->InsertValue(cntr++, XDMF_HEX); break; case VTK_WEDGE : da->InsertValue(cntr++, XDMF_WEDGE); break; case VTK_PYRAMID : da->InsertValue(cntr++, XDMF_PYRAMID); break; default : da->InsertValue(cntr++,XDMF_NOTOPOLOGY); break; } if ( cellType == VTK_VOXEL ) { // Hack for VTK_VOXEL da->InsertValue(cntr++, cell->GetPointId(0)); da->InsertValue(cntr++, cell->GetPointId(1)); da->InsertValue(cntr++, cell->GetPointId(3)); da->InsertValue(cntr++, cell->GetPointId(2)); da->InsertValue(cntr++, cell->GetPointId(4)); da->InsertValue(cntr++, cell->GetPointId(5)); da->InsertValue(cntr++, cell->GetPointId(7)); da->InsertValue(cntr++, cell->GetPointId(6)); } else if ( cellType == VTK_PIXEL ) { // Hack for VTK_PIXEL da->InsertValue(cntr++, cell->GetPointId(0)); da->InsertValue(cntr++, cell->GetPointId(1)); da->InsertValue(cntr++, cell->GetPointId(3)); da->InsertValue(cntr++, cell->GetPointId(2)); } for (vtkIdType pid=0; pid < numPts; pid++) { da->InsertValue(cntr++, cell->GetPointId(pid)); } } this->ConvertVToXArray(da, di, 1, &cntr, 2, heavyName); da->Delete(); } } break; default: t->SetTopologyType(XDMF_NOTOPOLOGY); cerr << "Unrecognized dataset type" << endl; } } //---------------------------------------------------------------------------- void vtkXdmfWriter2::CreateGeometry(vtkDataSet *ds, XdmfGrid *grid, void *staticdata) { //Geometry XdmfGeometry *geo = grid->GetGeometry(); geo->SetLightDataLimit(this->LightDataLimit); const char *heavyName = NULL; vtkstd::string heavyDataSetName; if (this->HeavyDataFileName) { heavyDataSetName = vtkstd::string(this->HeavyDataFileName) + ":"; if (this->HeavyDataGroupName) { heavyDataSetName = heavyDataSetName + HeavyDataGroupName + "/Geometry"; } heavyName = heavyDataSetName.c_str(); } vtkXW2NodeHelp *staticnode = (vtkXW2NodeHelp*)staticdata; if (staticnode) { if (staticnode->staticFlag) { grid->Set("GeometryConstant", "True"); } if (staticnode->DOM && staticnode->node) { XdmfXmlNode staticGeom = staticnode->DOM->FindElement("Geometry", 0, staticnode->node); XdmfConstString text = staticnode->DOM->Serialize(staticGeom->children); geo->SetDataXml(text); return; } } switch (ds->GetDataObjectType()) { case VTK_STRUCTURED_POINTS: case VTK_IMAGE_DATA: case VTK_UNIFORM_GRID: { geo->SetGeometryType(XDMF_GEOMETRY_ORIGIN_DXDYDZ); vtkImageData *id = vtkImageData::SafeDownCast(ds); double orig[3], spacing[3]; id->GetOrigin(orig); double tmp = orig[2]; orig[2] = orig[0]; orig[0] = tmp; id->GetSpacing(spacing); tmp = spacing[2]; spacing[2] = spacing[0]; spacing[0] = tmp; geo->SetOrigin(orig); geo->SetDxDyDz(spacing); } break; case VTK_RECTILINEAR_GRID: { vtkIdType len; geo->SetGeometryType(XDMF_GEOMETRY_VXVYVZ); vtkRectilinearGrid *rgrid = vtkRectilinearGrid::SafeDownCast(ds); vtkDataArray *da; da = rgrid->GetXCoordinates(); len = da->GetNumberOfTuples(); XdmfArray *xdax = new XdmfArray; this->ConvertVToXArray(da, xdax, 1, &len, 0, heavyName); geo->SetVectorX(xdax, 1); da = rgrid->GetYCoordinates(); len = da->GetNumberOfTuples(); XdmfArray *xday = new XdmfArray; this->ConvertVToXArray(da, xday, 1, &len, 0, heavyName); geo->SetVectorY(xday, 1); da = rgrid->GetZCoordinates(); len = da->GetNumberOfTuples(); XdmfArray *xdaz = new XdmfArray; this->ConvertVToXArray(da, xdaz, 1, &len, 0, heavyName); geo->SetVectorZ(xdaz, 1); } break; case VTK_STRUCTURED_GRID: case VTK_POLY_DATA: case VTK_UNSTRUCTURED_GRID: { geo->SetGeometryType(XDMF_GEOMETRY_XYZ); vtkPointSet *pset = vtkPointSet::SafeDownCast(ds); vtkPoints *pts = pset->GetPoints(); vtkDataArray *da = pts->GetData(); XdmfArray *xda = geo->GetPoints(); vtkIdType shape[2]; shape[0] = da->GetNumberOfTuples(); this->ConvertVToXArray(da, xda, 1, shape, 0, heavyName); geo->SetPoints(xda); } break; default: geo->SetGeometryType(XDMF_GEOMETRY_NONE); //TODO: Support non-canonical vtkDataSets (via a callout for extensibility) cerr << "Unrecognized dataset type" << endl; } } //------------------------------------------------------------------------------ void vtkXdmfWriter2::WriteAtomicDataSet(vtkDataObject *dobj, XdmfGrid *grid) { cerr << "Writing " << dobj << " a " << dobj->GetClassName() << endl; vtkDataSet *ds = vtkDataSet::SafeDownCast(dobj); if (!ds) { //TODO: Fill in non Vis data types cerr << "Can not convert " << dobj->GetClassName() << " to XDMF yet." << endl; return; } //Attributes vtkIdType FRank = 1; vtkIdType FDims[1]; vtkIdType CRank = 3; vtkIdType CDims[3]; vtkIdType PRank = 3; vtkIdType PDims[3]; this->CreateTopology(ds, grid, PDims, CDims, PRank, CRank, NULL); this->CreateGeometry(ds, grid, NULL); FDims[0] = ds->GetFieldData()->GetNumberOfTuples(); this->WriteArrays(ds->GetFieldData(),grid,XDMF_ATTRIBUTE_CENTER_GRID, FRank, FDims, "Field"); this->WriteArrays(ds->GetCellData(), grid,XDMF_ATTRIBUTE_CENTER_CELL, CRank, CDims, "Cell"); this->WriteArrays(ds->GetPointData(),grid,XDMF_ATTRIBUTE_CENTER_NODE, PRank, PDims, "Node"); } //---------------------------------------------------------------------------- void vtkXdmfWriter2::WriteArrays(vtkFieldData* fd, XdmfGrid *grid, int association, vtkIdType rank, vtkIdType *dims, const char *name) { if (fd) { vtkDataSetAttributes *dsa = vtkDataSetAttributes::SafeDownCast(fd); const char *heavyName = NULL; vtkstd::string heavyDataSetName; if (this->HeavyDataFileName) { heavyDataSetName = vtkstd::string(this->HeavyDataFileName) + ":"; if (this->HeavyDataGroupName) { heavyDataSetName = heavyDataSetName + vtkstd::string(HeavyDataGroupName) + "/" + name; } heavyName = heavyDataSetName.c_str(); } // // Sort alphabetically to avoid potential bad ordering problems // vtkstd::vector AttributeNames; for (int i=0; iGetNumberOfArrays(); i++) { vtkDataArray *scalars = fd->GetArray(i); AttributeNames.push_back(scalars->GetName()); } vtkstd::sort(AttributeNames.begin(), AttributeNames.end()); for (unsigned int i = 0; i < AttributeNames.size(); i++) { vtkDataArray *da = fd->GetArray(AttributeNames[i].c_str()); if (!da) { //TODO: Dump non numeric arrays too cerr << "xdmfwriter can not convert non-numeric arrays yet." << endl; continue; } XdmfAttribute *attr = new XdmfAttribute; attr->SetLightDataLimit(this->LightDataLimit); attr->SetDeleteOnGridDelete(true); if (da->GetName()) { attr->SetName(da->GetName()); } else { attr->SetName("ANONYMOUS"); } attr->SetAttributeCenter(association); int attributeType = 0; if (dsa) { attributeType = dsa->IsArrayAnAttribute(i); switch (attributeType) { case vtkDataSetAttributes::SCALARS: attributeType = XDMF_ATTRIBUTE_TYPE_SCALAR; //TODO: Is XDMF ok with 3 component(RGB) active scalars? break; case vtkDataSetAttributes::VECTORS: attributeType = XDMF_ATTRIBUTE_TYPE_VECTOR; break; case vtkDataSetAttributes::GLOBALIDS: attributeType = XDMF_ATTRIBUTE_TYPE_GLOBALID; break; case vtkDataSetAttributes::TENSORS: //TODO: vtk tensors are 9 component, xdmf tensors are 6? case vtkDataSetAttributes::NORMALS: //TODO: mark as vectors? case vtkDataSetAttributes::TCOORDS: //TODO: mark as vectors? case vtkDataSetAttributes::PEDIGREEIDS: //TODO: ? type is variable default: attributeType = 0; break; } } if (attributeType != 0) { attr->SetActive(1); attr->SetAttributeType(attributeType); } else { //vtk doesn't mark it as a special array, use width to tell xdmf what to call it if ( da->GetNumberOfComponents() == 1 ) { attr->SetAttributeType(XDMF_ATTRIBUTE_TYPE_SCALAR); } else if ( da->GetNumberOfComponents() == 3 ) { attr->SetAttributeType(XDMF_ATTRIBUTE_TYPE_VECTOR); } else if ( da->GetNumberOfComponents() == 6 ) { attr->SetAttributeType(XDMF_ATTRIBUTE_TYPE_TENSOR); } } XdmfArray *xda = attr->GetValues(); this->ConvertVToXArray(da, xda, rank, dims, 0, heavyName); attr->SetValues(xda); grid->Insert(attr); } } } //------------------------------------------------------------------------------ void vtkXdmfWriter2::ConvertVToXArray(vtkDataArray *vda, XdmfArray *xda, vtkIdType rank, vtkIdType *dims, int allocStrategy, const char *heavyprefix) { XdmfInt32 lRank = rank; XdmfInt64 *lDims = new XdmfInt64[rank+1]; for (vtkIdType i = 0; i < rank; i++) { lDims[i] = dims[i]; } vtkIdType nc = vda->GetNumberOfComponents(); //add additional dimension to the xdmf array to match the vtk arrays width, //ex coordinate arrays have xyz, so add [3] if (nc != 1) { lDims[rank]=nc; lRank+=1; } switch (vda->GetDataType()) { case VTK_DOUBLE: xda->SetNumberType(XDMF_FLOAT64_TYPE); break; case VTK_FLOAT: xda->SetNumberType(XDMF_FLOAT32_TYPE); break; case VTK_ID_TYPE: xda->SetNumberType((VTK_SIZEOF_ID_TYPE==sizeof(XDMF_64_INT)?XDMF_INT64_TYPE:XDMF_INT32_TYPE)); break; case VTK_LONG: xda->SetNumberType(XDMF_INT64_TYPE); break; case VTK_INT: xda->SetNumberType(XDMF_INT32_TYPE); break; case VTK_UNSIGNED_INT: xda->SetNumberType(XDMF_UINT32_TYPE); break; case VTK_SHORT: xda->SetNumberType(XDMF_INT16_TYPE); break; case VTK_UNSIGNED_SHORT: xda->SetNumberType(XDMF_INT16_TYPE); break; case VTK_CHAR: case VTK_SIGNED_CHAR: xda->SetNumberType(XDMF_INT8_TYPE); //TODO: Do we ever want unicode? break; case VTK_UNSIGNED_CHAR: xda->SetNumberType(XDMF_UINT8_TYPE); break; case VTK_LONG_LONG: case VTK_UNSIGNED_LONG_LONG: case VTK___INT64: case VTK_UNSIGNED___INT64: case VTK_UNSIGNED_LONG: case VTK_STRING: { xda->SetNumberType(XDMF_UNKNOWN_TYPE); break; } } if (heavyprefix) { vtkstd::string dsname = vtkstd::string(heavyprefix) + "/" + vtkstd::string(vda->GetName()); xda->SetHeavyDataSetName(dsname.c_str()); } //TODO: if we can make xdmf write out immediately, then wouldn't have to keep around //arrays when working with temporal data if ((allocStrategy==0 && !this->TopTemporalGrid) || allocStrategy==1) { //Do not let xdmf allocate its own buffer. xdmf just borrows vtk's and doesn't double mem size. xda->SetAllowAllocate(0); xda->SetShape(lRank, lDims); xda->SetDataPointer(vda->GetVoidPointer(0)); } else //(allocStrategy==0 && this->TopTemporalGrid) || allocStrategy==2) { //Unfortunately data doesn't stick around with temporal updates, which is exactly when you want it most. xda->SetAllowAllocate(1); xda->SetShape(lRank, lDims); memcpy(xda->GetDataPointer(), vda->GetVoidPointer(0), vda->GetNumberOfTuples()* vda->GetNumberOfComponents()* vda->GetElementComponentSize()); } delete[] lDims; } xdmf-3.0+git20160803/vtk/vtkXdmfReaderInternal.h0000640000175000017500000002557013003006557021323 0ustar alastairalastair/*========================================================================= Program: Visualization Toolkit Module: $RCSfile: vtkXdmfReaderInternal.h,v $ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen All rights reserved. See Copyright.txt or http://www.kitware.com/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ // .NAME vtkXdmfReaderInternal -- private class(es) used by vtkXdmfReader // .SECTION Description #ifndef __vtkXdmfReaderInternal_h #define __vtkXdmfReaderInternal_h // NAMING CONVENTION ********************************************************* // * all member variables of the type XdmfXml* begin with XML eg. XMLNode // * all non-member variables of the type XdmfXml* begin with xml eg. xmlNode // * all member variables of the type XdmfElement (and subclasses) begin with // XMF eg. XMFGrid // * all non-member variables of the type XdmfElement (and subclasses) begin // with xmf eg. xmfGrid // *************************************************************************** #include "vtkMutableDirectedGraph.h" #include "vtkSILBuilder.h" #include "XdmfArray.h" #include "XdmfAttribute.h" #include "XdmfDOM.h" #include "XdmfDataDesc.h" #include "XdmfDataItem.h" #include "XdmfGrid.h" #include "XdmfTopology.h" #include "XdmfGeometry.h" #include "XdmfTime.h" #include "XdmfSet.h" #include #include #include #include #include #include #include #include #include class vtkXdmfDomain; class vtkXdmfDocument { public: //--------------------------------------------------------------------------- // Description: // Parse an xmf file (or string). Both these methods use caching hence calling // these methods repeatedly with the same argument will NOT result in // re-parsing of the xmf. bool Parse(const char*xmffilename); bool ParseString(const char* xmfdata, size_t length); //--------------------------------------------------------------------------- // Description: // Returns the names for available domains. const vtkstd::vector& GetDomains() { return this->Domains; } //--------------------------------------------------------------------------- // Description: // Set the active domain. This will result in processing of the domain xmf if // the selected domain is different from the active one. bool SetActiveDomain(const char* domainname); bool SetActiveDomain(int index); //--------------------------------------------------------------------------- // Description: // Returns the active domain. vtkXdmfDomain* GetActiveDomain() { return this->ActiveDomain; } //--------------------------------------------------------------------------- // Description: // Constructor/Destructor vtkXdmfDocument(); ~vtkXdmfDocument(); private: // Populates the list of domains. void UpdateDomains(); private: int ActiveDomainIndex; XdmfDOM XMLDOM; vtkXdmfDomain* ActiveDomain; vtkstd::vector Domains; char* LastReadContents; size_t LastReadContentsLength; vtkstd::string LastReadFilename; }; // I don't use vtkDataArraySelection since it's very slow when it comes to large // number of arrays. class vtkXdmfArraySelection : public vtkstd::map { public: void Merge(const vtkXdmfArraySelection& other) { vtkXdmfArraySelection::const_iterator iter = other.begin(); for (; iter != other.end(); ++iter) { (*this)[iter->first] = iter->second; } } void AddArray(const char* name, bool status=true) { (*this)[name] = status; } bool ArrayIsEnabled(const char* name) { vtkXdmfArraySelection::iterator iter = this->find(name); if (iter != this->end()) { return iter->second; } // don't know anything about this array, enable it by default. return true; } bool HasArray(const char* name) { vtkXdmfArraySelection::iterator iter = this->find(name); return (iter != this->end()); } int GetArraySetting(const char* name) { return this->ArrayIsEnabled(name)? 1 : 0; } void SetArrayStatus(const char* name, bool status) { this->AddArray(name, status); } const char* GetArrayName(int index) { int cc=0; for (vtkXdmfArraySelection::iterator iter = this->begin(); iter != this->end(); ++iter) { if (cc==index) { return iter->first.c_str(); } cc++; } return NULL; } int GetNumberOfArrays() { return static_cast(this->size()); } }; //*************************************************************************** class vtkXdmfDomain { private: XdmfInt64 NumberOfGrids; XdmfGrid* XMFGrids; XdmfXmlNode XMLDomain; XdmfDOM* XMLDOM; unsigned int GridsOverflowCounter; // these are node indices used when building the SIL. vtkIdType SILBlocksRoot; vtkstd::map GridCenteredAttrbuteRoots; vtkstd::map > GridCenteredAttrbuteValues; vtkSILBuilder* SILBuilder; vtkMutableDirectedGraph* SIL; vtkXdmfArraySelection* PointArrays; vtkXdmfArraySelection* CellArrays; vtkXdmfArraySelection* Grids; vtkXdmfArraySelection* Sets; vtkstd::set TimeSteps; //< Only discrete timesteps are currently // supported. public: //--------------------------------------------------------------------------- // does not take ownership of the DOM, however the xmlDom must exist as long // as the instance is in use. vtkXdmfDomain(XdmfDOM* xmlDom, int domain_index); //--------------------------------------------------------------------------- // Description: // After instantiating, check that the domain is valid. If this returns false, // it means that the specified domain could not be located. bool IsValid() { return (this->XMLDomain != 0); } //--------------------------------------------------------------------------- vtkGraph* GetSIL() { return this->SIL; } //--------------------------------------------------------------------------- // Description: // Returns the number of top-level grids present in this domain. XdmfInt64 GetNumberOfGrids() { return this->NumberOfGrids; } //--------------------------------------------------------------------------- // Description: // Provides access to a top-level grid from this domain. XdmfGrid* GetGrid(XdmfInt64 cc); //--------------------------------------------------------------------------- // Description: // Returns the VTK data type need for this domain. If the domain has only 1 // grid, then a vtkDataSet-type is returned, otherwise a vtkMultiBlockDataSet // is required. // Returns -1 on error. int GetVTKDataType(); //--------------------------------------------------------------------------- // Description: // Returns the timesteps. const vtkstd::set& GetTimeSteps() { return this->TimeSteps; } //--------------------------------------------------------------------------- // Description: // Given a time value, returns the index. int GetIndexForTime(double time); //--------------------------------------------------------------------------- // Description: // Returns the time value at the given index. XdmfFloat64 GetTimeForIndex(int index) { vtkstd::set::iterator iter; int cc=0; for (iter = this->TimeSteps.begin(); iter != this->TimeSteps.end(); iter++, cc++) { if (cc == index) { return *iter; } } // invalid index. return 0.0; } //--------------------------------------------------------------------------- // Description: // If xmfGrid is a temporal collection, returns the child-grid matching the // requested time. XdmfGrid* GetGrid(XdmfGrid* xmfGrid, double time); //--------------------------------------------------------------------------- // Description: // Returns true if the grids is a structured dataset. bool IsStructured(XdmfGrid*); //--------------------------------------------------------------------------- // Description: // Returns the whole extents for the dataset if the grid if IsStructured() // returns true for the given grid. Returns true if the extents are valid. // NOTE: returned extents are always (0, dimx-1, 0, dimy-1, 0, dimz-1). bool GetWholeExtent(XdmfGrid*, int extents[6]); //--------------------------------------------------------------------------- // Description: // Returns the spacing and origin for the grid if the grid topology == // XDMF_2DCORECTMESH or XDMF_3DCORECTMESH i.e. image data. Returns true if // the extents are valid. bool GetOriginAndSpacing(XdmfGrid*, double origin[3], double spacing[3]); //--------------------------------------------------------------------------- ~vtkXdmfDomain(); // Returns VTK data type based on grid type and topology. // Returns -1 on error. int GetVTKDataType(XdmfGrid* xmfGrid); // Returns the dimensionality (or rank) of the topology for the given grid. // Returns -1 is the xmfGrid is not a uniform i.e. is a collection or a tree. static int GetDataDimensionality(XdmfGrid* xmfGrid); vtkXdmfArraySelection* GetPointArraySelection() { return this->PointArrays; } vtkXdmfArraySelection* GetCellArraySelection() { return this->CellArrays; } vtkXdmfArraySelection* GetGridSelection() { return this->Grids; } vtkXdmfArraySelection* GetSetsSelection() { return this->Sets; } private: // Description: // There are a few meta-information that we need to collect from the domain // * number of data-arrays so that the user can choose which to load. // * grid-structure so that the user can choose the hierarchy // * time information so that reader can report the number of timesteps // available. // This does another book-keeping task of ensuring that all grids have valid // names. If a grid is not named, then we make up a name. // TODO: We can use GRID centered attributes to create hierarchies in the SIL. void CollectMetaData(); // Used by CollectMetaData(). void CollectMetaData(XdmfGrid* xmfGrid, vtkIdType silParent); // Used by CollectMetaData(). void CollectNonLeafMetaData(XdmfGrid* xmfGrid, vtkIdType silParent); // Used by CollectMetaData(). void CollectLeafMetaData(XdmfGrid* xmfGrid, vtkIdType silParent); // Description: // Use this to add an association with the grid attribute with the node for // the grid in the SIL if applicable. Returns true if the attribute was added. bool UpdateGridAttributeInSIL( XdmfAttribute* xmfAttribute, vtkIdType gridSILId); }; #endif xdmf-3.0+git20160803/vtk/vtkXdmfHeavyData.cxx0000640000175000017500000013600713003006557020643 0ustar alastairalastair/*========================================================================= Program: Visualization Toolkit Module: $RCSfile: vtkXdmfHeavyData.cxx,v $ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen All rights reserved. See Copyright.txt or http://www.kitware.com/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ #include "vtkXdmfHeavyData.h" #include "vtkCellArray.h" #include "vtkCellData.h" #include "vtkCellTypes.h" #include "vtkDataObjectTypes.h" #include "vtkDoubleArray.h" #include "vtkExtractSelectedIds.h" #include "vtkFloatArray.h" #include "vtkInformation.h" #include "vtkMergePoints.h" #include "vtkMultiBlockDataSet.h" #include "vtkObjectFactory.h" #include "vtkPointData.h" #include "vtkPolyData.h" #include "vtkRectilinearGrid.h" #include "vtkSelection.h" #include "vtkSelectionNode.h" #include "vtkSmartPointer.h" #include "vtkStructuredData.h" #include "vtkStructuredGrid.h" #include "vtkUniformGrid.h" #include "vtkUnstructuredGrid.h" #include "vtkXdmfDataArray.h" #include "vtkXdmfReader.h" #include "vtkXdmfReaderInternal.h" #include #include static void vtkScaleExtents(int in_exts[6], int out_exts[6], int stride[3]) { out_exts[0] = in_exts[0] / stride[0]; out_exts[1] = in_exts[1] / stride[0]; out_exts[2] = in_exts[2] / stride[1]; out_exts[3] = in_exts[3] / stride[1]; out_exts[4] = in_exts[4] / stride[2]; out_exts[5] = in_exts[5] / stride[2]; } static void vtkGetDims(int exts[6], int dims[3]) { dims[0] = exts[1] - exts[0] + 1; dims[1] = exts[3] - exts[2] + 1; dims[2] = exts[5] - exts[4] + 1; } //---------------------------------------------------------------------------- vtkXdmfHeavyData::vtkXdmfHeavyData(vtkXdmfDomain* domain, vtkXdmfReader* reader) { this->Reader = reader; this->Piece = 0; this->NumberOfPieces = 0; this->GhostLevels = 0; this->Extents[0] = this->Extents[2] = this->Extents[4] = 0; this->Extents[1] = this->Extents[3] = this->Extents[5] = -1; this->Domain = domain; this->Stride[0] = this->Stride[1] = this->Stride[2] = 1; } //---------------------------------------------------------------------------- vtkXdmfHeavyData::~vtkXdmfHeavyData() { } //---------------------------------------------------------------------------- vtkDataObject* vtkXdmfHeavyData::ReadData() { if (this->Domain->GetNumberOfGrids() == 1) { return this->ReadData(this->Domain->GetGrid(0)); } // this code is similar to ReadComposite() however we cannot use the same code // since the API for getting the children differs on the domain and the grid. bool distribute_leaf_nodes = this->NumberOfPieces > 1; XdmfInt32 numChildren = this->Domain->GetNumberOfGrids(); int number_of_leaf_nodes = 0; vtkMultiBlockDataSet* mb = vtkMultiBlockDataSet::New(); mb->SetNumberOfBlocks(numChildren); for (XdmfInt32 cc=0; cc < numChildren; cc++) { XdmfGrid* xmfChild = this->Domain->GetGrid(cc); mb->GetMetaData(cc)->Set(vtkCompositeDataSet::NAME(), xmfChild->GetName()); bool child_is_leaf = (xmfChild->IsUniform() != 0); if (!child_is_leaf || !distribute_leaf_nodes || (number_of_leaf_nodes % this->NumberOfPieces) == this->Piece) { // it's possible that the data has way too many blocks, in which case the // reader didn't present the user with capabilities to select the actual // leaf node blocks as is the norm, instead only top-level grids were // shown. In that case we need to ensure that we skip grids the user // wanted us to skip explicitly. if (!this->Domain->GetGridSelection()->ArrayIsEnabled(xmfChild->GetName())) { continue; } vtkDataObject* childDO = this->ReadData(xmfChild); if (childDO) { mb->SetBlock(cc, childDO); childDO->Delete(); } } number_of_leaf_nodes += child_is_leaf? 1 : 0; } return mb; } //---------------------------------------------------------------------------- vtkDataObject* vtkXdmfHeavyData::ReadData(XdmfGrid* xmfGrid) { if (!xmfGrid || xmfGrid->GetGridType() == XDMF_GRID_UNSET) { // sanity check-ensure that the xmfGrid is valid. return 0; } XdmfInt32 gridType = (xmfGrid->GetGridType() & XDMF_GRID_MASK); if (gridType == XDMF_GRID_COLLECTION && xmfGrid->GetCollectionType() == XDMF_GRID_COLLECTION_TEMPORAL) { // grid is a temporal collection, pick the sub-grid with matching time and // process that. return this->ReadTemporalCollection(xmfGrid); } else if (gridType == XDMF_GRID_COLLECTION || gridType == XDMF_GRID_TREE) { return this->ReadComposite(xmfGrid); } // grid is a primitive grid, so read the data. return this->ReadUniformData(xmfGrid); } //---------------------------------------------------------------------------- vtkDataObject* vtkXdmfHeavyData::ReadComposite(XdmfGrid* xmfComposite) { assert(( (xmfComposite->GetGridType() & XDMF_GRID_COLLECTION && xmfComposite->GetCollectionType() != XDMF_GRID_COLLECTION_TEMPORAL) || (xmfComposite->GetGridType() & XDMF_GRID_TREE)) && "Input must be a spatial collection or a tree"); vtkMultiBlockDataSet* multiBlock = vtkMultiBlockDataSet::New(); XdmfInt32 numChildren = xmfComposite->GetNumberOfChildren(); multiBlock->SetNumberOfBlocks(numChildren); bool distribute_leaf_nodes = (xmfComposite->GetGridType() & XDMF_GRID_COLLECTION && this->NumberOfPieces > 1); int number_of_leaf_nodes = 0; for (XdmfInt32 cc=0; cc < numChildren; cc++) { XdmfGrid* xmfChild = xmfComposite->GetChild(cc); multiBlock->GetMetaData(cc)->Set(vtkCompositeDataSet::NAME(), xmfChild->GetName()); bool child_is_leaf = (xmfChild->IsUniform() != 0); if (!child_is_leaf || !distribute_leaf_nodes || (number_of_leaf_nodes % this->NumberOfPieces) == this->Piece) { vtkDataObject* childDO = this->ReadData(xmfChild); if (childDO) { multiBlock->SetBlock(cc, childDO); childDO->Delete(); } } number_of_leaf_nodes += child_is_leaf? 1 : 0; } return multiBlock; } //---------------------------------------------------------------------------- vtkDataObject* vtkXdmfHeavyData::ReadTemporalCollection( XdmfGrid* xmfTemporalCollection) { assert(xmfTemporalCollection->GetGridType() & XDMF_GRID_COLLECTION && xmfTemporalCollection->GetCollectionType() == XDMF_GRID_COLLECTION_TEMPORAL && "Input must be a temporal collection"); // Find the children that are valid for the requested time (this->Time) and // read only those. // FIXME: I am tempted to remove support for supporting multiple matching // sub-grids for a time-step since that changes the composite data hierarchy // over time which makes it hard to use filters such as vtkExtractBlock etc. vtkstd::deque valid_children; for (XdmfInt32 cc=0; cc < xmfTemporalCollection->GetNumberOfChildren(); cc++) { XdmfGrid* child = xmfTemporalCollection->GetChild(cc); if (child && child->GetTime()->IsValid(this->Time, this->Time)) { valid_children.push_back(child); } } if (valid_children.size() == 0) { return 0; } vtkstd::deque > child_data_objects; vtkstd::deque::iterator iter; for (iter = valid_children.begin(); iter != valid_children.end(); ++iter) { vtkDataObject* childDO = this->ReadData(*iter); if (childDO) { child_data_objects.push_back(childDO); childDO->Delete(); } } if (child_data_objects.size() == 1) { vtkDataObject* dataObject = child_data_objects[0]; dataObject->Register(NULL); return dataObject; } else if (child_data_objects.size() > 1) { vtkMultiBlockDataSet* mb = vtkMultiBlockDataSet::New(); mb->SetNumberOfBlocks(static_cast(child_data_objects.size())); for (unsigned int cc=0; cc < static_cast(child_data_objects.size()); cc++) { mb->SetBlock(cc, child_data_objects[cc]); } return mb; } return 0; } //---------------------------------------------------------------------------- // Read a non-composite grid. Note here uniform has nothing to do with // vtkUniformGrid but to what Xdmf's GridType="Uniform". vtkDataObject* vtkXdmfHeavyData::ReadUniformData(XdmfGrid* xmfGrid) { assert(xmfGrid->IsUniform() && "Input must be a uniform xdmf grid."); int vtk_data_type = this->Domain->GetVTKDataType(xmfGrid); if (!this->Domain->GetGridSelection()->ArrayIsEnabled(xmfGrid->GetName())) { // simply create an empty data-object of the correct type and return it. return vtkDataObjectTypes::NewDataObject(vtk_data_type); } // Read heavy data for grid geometry/topology. This does not read any // data-arrays. They are read explicitly. xmfGrid->Update(); vtkDataObject* dataObject = 0; switch (vtk_data_type) { case VTK_UNIFORM_GRID: dataObject = this->RequestImageData(xmfGrid, true); break; case VTK_IMAGE_DATA: dataObject = this->RequestImageData(xmfGrid, false); break; case VTK_STRUCTURED_GRID: dataObject = this->RequestStructuredGrid(xmfGrid); break; case VTK_RECTILINEAR_GRID: dataObject = this->RequestRectilinearGrid(xmfGrid); break; case VTK_UNSTRUCTURED_GRID: dataObject = this->ReadUnstructuredGrid(xmfGrid); break; default: // un-handled case. return 0; } return dataObject; } //---------------------------------------------------------------------------- int vtkXdmfHeavyData::GetNumberOfPointsPerCell(int vtk_cell_type) { switch (vtk_cell_type) { case VTK_POLY_VERTEX: return 0; case VTK_POLY_LINE: return 0; case VTK_POLYGON: return 0; case VTK_TRIANGLE: return 3; case VTK_QUAD: return 4; case VTK_TETRA: return 4; case VTK_PYRAMID: return 5; case VTK_WEDGE: return 6; case VTK_HEXAHEDRON: return 8; case VTK_QUADRATIC_EDGE: return 3; case VTK_QUADRATIC_TRIANGLE: return 6; case VTK_QUADRATIC_QUAD: return 8; case VTK_QUADRATIC_TETRA: return 10; case VTK_QUADRATIC_PYRAMID: return 13; case VTK_QUADRATIC_WEDGE: return 15; case VTK_BIQUADRATIC_QUADRATIC_WEDGE: return 18; case VTK_QUADRATIC_HEXAHEDRON: return 20; case VTK_BIQUADRATIC_QUADRATIC_HEXAHEDRON: return 24; case VTK_TRIQUADRATIC_HEXAHEDRON: return 24; } return -1; } //---------------------------------------------------------------------------- int vtkXdmfHeavyData::GetVTKCellType(XdmfInt32 topologyType) { switch (topologyType) { case XDMF_POLYVERTEX : return VTK_POLY_VERTEX; case XDMF_POLYLINE : return VTK_POLY_LINE; case XDMF_POLYGON : return VTK_POLYGON; // FIXME: should this not be treated as mixed? case XDMF_TRI : return VTK_TRIANGLE; case XDMF_QUAD : return VTK_QUAD; case XDMF_TET : return VTK_TETRA; case XDMF_PYRAMID : return VTK_PYRAMID; case XDMF_WEDGE : return VTK_WEDGE; case XDMF_HEX : return VTK_HEXAHEDRON; case XDMF_EDGE_3 : return VTK_QUADRATIC_EDGE ; case XDMF_TRI_6 : return VTK_QUADRATIC_TRIANGLE ; case XDMF_QUAD_8 : return VTK_QUADRATIC_QUAD ; case XDMF_TET_10 : return VTK_QUADRATIC_TETRA ; case XDMF_PYRAMID_13 : return VTK_QUADRATIC_PYRAMID ; case XDMF_WEDGE_15 : return VTK_QUADRATIC_WEDGE ; case XDMF_WEDGE_18 : return VTK_BIQUADRATIC_QUADRATIC_WEDGE ; case XDMF_HEX_20 : return VTK_QUADRATIC_HEXAHEDRON ; case XDMF_HEX_24 : return VTK_BIQUADRATIC_QUADRATIC_HEXAHEDRON ; case XDMF_HEX_27 : return VTK_TRIQUADRATIC_HEXAHEDRON ; case XDMF_MIXED : return VTK_NUMBER_OF_CELL_TYPES; } // XdmfErrorMessage("Unknown Topology Type = " // << xmfGrid->GetTopology()->GetTopologyType()); return VTK_EMPTY_CELL; } //---------------------------------------------------------------------------- vtkDataObject* vtkXdmfHeavyData::ReadUnstructuredGrid(XdmfGrid* xmfGrid) { vtkSmartPointer ugData = vtkSmartPointer::New(); XdmfTopology* xmfTopology = xmfGrid->GetTopology(); XdmfArray* xmfConnectivity = xmfTopology->GetConnectivity(); int vtk_cell_type = vtkXdmfHeavyData::GetVTKCellType( xmfTopology->GetTopologyType()); if (vtk_cell_type == VTK_EMPTY_CELL) { // invalid topology. return NULL; } if (vtk_cell_type != VTK_NUMBER_OF_CELL_TYPES) // i.e. topologyType != XDMF_MIXED { // all cells are of the same type. XdmfInt32 numPointsPerCell= xmfTopology->GetNodesPerElement(); // FIXME: is this needed, shouldn't xmfTopology->GetNodesPerElement() // return the correct value always? if (xmfConnectivity->GetRank() == 2) { numPointsPerCell = xmfConnectivity->GetDimension(1); } /* Create Cell Type Array */ XdmfInt64 conn_length = xmfConnectivity->GetNumberOfElements(); XdmfInt64* xmfConnections = new XdmfInt64[conn_length]; xmfConnectivity->GetValues(0, xmfConnections, conn_length); vtkIdType numCells = xmfTopology->GetShapeDesc()->GetNumberOfElements(); int *cell_types = new int[numCells]; /* Create Cell Array */ vtkCellArray* cells = vtkCellArray::New(); /* Get the pointer */ vtkIdType* cells_ptr = cells->WritePointer( numCells, numCells * (1 + numPointsPerCell)); /* xmfConnections: N p1 p2 ... pN */ /* i.e. Triangles : 3 0 1 2 3 3 4 5 3 6 7 8 */ vtkIdType index = 0; for(vtkIdType cc = 0 ; cc < numCells; cc++ ) { cell_types[cc] = vtk_cell_type; *cells_ptr++ = numPointsPerCell; for (vtkIdType i = 0 ; i < numPointsPerCell; i++ ) { *cells_ptr++ = xmfConnections[index++]; } } ugData->SetCells(cell_types, cells); cells->Delete(); delete [] xmfConnections; delete [] cell_types; } else { // We have cells with mixed types. XdmfInt64 conn_length = xmfGrid->GetTopology()->GetConnectivity()->GetNumberOfElements(); XdmfInt64* xmfConnections = new XdmfInt64[conn_length]; xmfConnectivity->GetValues(0, xmfConnections, conn_length); vtkIdType numCells = xmfTopology->GetShapeDesc()->GetNumberOfElements(); int *cell_types = new int[numCells]; /* Create Cell Array */ vtkCellArray* cells = vtkCellArray::New(); /* Get the pointer. Make it Big enough ... too big for now */ vtkIdType* cells_ptr = cells->WritePointer(numCells, conn_length); /* xmfConnections : N p1 p2 ... pN */ /* i.e. Triangles : 3 0 1 2 3 3 4 5 3 6 7 8 */ vtkIdType index = 0; int sub = 0; for(vtkIdType cc = 0 ; cc < numCells; cc++ ) { int vtk_cell_typeI = this->GetVTKCellType(xmfConnections[index++]); XdmfInt32 numPointsPerCell = this->GetNumberOfPointsPerCell(vtk_cell_typeI); if (numPointsPerCell==-1) { // encountered an unknown cell. cells->Delete(); delete [] cell_types; delete [] xmfConnections; return NULL; } if (numPointsPerCell==0) { // cell type does not have a fixed number of points in which case the // next entry in xmfConnections tells us the number of points. numPointsPerCell = xmfConnections[index++]; sub++; // used to shrink the cells array at the end. } cell_types[cc] = vtk_cell_typeI; *cells_ptr++ = numPointsPerCell; for(vtkIdType i = 0 ; i < numPointsPerCell; i++ ) { *cells_ptr++ = xmfConnections[index++]; } } // Resize the Array to the Proper Size cells->GetData()->Resize(index-sub); ugData->SetCells(cell_types, cells); cells->Delete(); delete [] cell_types; delete [] xmfConnections; } // Read the geometry. vtkPoints* points = this->ReadPoints(xmfGrid->GetGeometry()); if (!points) { // failed to read points. return NULL; } ugData->SetPoints(points); points->Delete(); this->ReadAttributes(ugData, xmfGrid); // Read ghost cell/point information. this->ReadGhostSets(ugData, xmfGrid); // If this grid has sets defined on it, then we need to read those as well vtkMultiBlockDataSet* sets = this->ReadSets(ugData, xmfGrid); if (sets) { return sets; } ugData->Register(NULL); return ugData; } inline bool vtkExtentsAreValid(int exts[6]) { return exts[1] >= exts[0] && exts[3] >= exts[2] && exts[5] >= exts[4]; } inline bool vtkExtentsAreEqual(int *exts1, int *exts2) { if (!exts1 && !exts2) { return true; } if (!exts1 || !exts2) { return false; } return (exts1[0] == exts2[0] && exts1[1] == exts2[1] && exts1[2] == exts2[2] && exts1[3] == exts2[3] && exts1[4] == exts2[4] && exts1[5] == exts2[5]); } //----------------------------------------------------------------------------- vtkRectilinearGrid* vtkXdmfHeavyData::RequestRectilinearGrid(XdmfGrid* xmfGrid) { vtkSmartPointer rg = vtkSmartPointer::New(); int whole_extents[6]; int update_extents[6]; this->Domain->GetWholeExtent(xmfGrid, whole_extents); if (!vtkExtentsAreValid(this->Extents)) { // if this->Extents are not valid, then simply read the whole image. memcpy(update_extents, whole_extents, sizeof(int)*6); } else { memcpy(update_extents, this->Extents, sizeof(int)*6); } // convert to stridden update extents. int scaled_extents[6]; vtkScaleExtents(update_extents, scaled_extents, this->Stride); int scaled_dims[3]; vtkGetDims(scaled_extents, scaled_dims); rg->SetExtent(scaled_extents); // Now read rectilinear geometry. XdmfGeometry* xmfGeometry = xmfGrid->GetGeometry(); vtkSmartPointer xarray = vtkSmartPointer::New(); xarray->SetNumberOfTuples(scaled_dims[0]); vtkSmartPointer yarray = vtkSmartPointer::New(); yarray->SetNumberOfTuples(scaled_dims[1]); vtkSmartPointer zarray = vtkSmartPointer::New(); zarray->SetNumberOfTuples(scaled_dims[2]); rg->SetXCoordinates(xarray); rg->SetYCoordinates(yarray); rg->SetZCoordinates(zarray); switch (xmfGeometry->GetGeometryType()) { case XDMF_GEOMETRY_ORIGIN_DXDY: case XDMF_GEOMETRY_ORIGIN_DXDYDZ: { XdmfFloat64* origin = xmfGeometry->GetOrigin(); XdmfFloat64* dxdydz = xmfGeometry->GetDxDyDz(); for (int cc= scaled_extents[0]; cc <= scaled_extents[1]; cc++) { xarray->GetPointer(0)[cc - scaled_extents[0]] = origin[0] + (dxdydz[0] * cc * this->Stride[0]); } for (int cc= scaled_extents[2]; cc <= scaled_extents[3]; cc++) { yarray->GetPointer(0)[cc - scaled_extents[2]] = origin[1] + (dxdydz[1] * cc * this->Stride[1]); } for (int cc= scaled_extents[4]; cc <= scaled_extents[5]; cc++) { zarray->GetPointer(0)[cc - scaled_extents[4]] = origin[2] + (dxdydz[2] * cc * this->Stride[2]); } } break; case XDMF_GEOMETRY_VXVY: { xarray->FillComponent(0, 0); xmfGeometry->GetVectorY()->GetValues(update_extents[2], yarray->GetPointer(0), scaled_dims[1], this->Stride[1]); xmfGeometry->GetVectorX()->GetValues(update_extents[4], zarray->GetPointer(0), scaled_dims[2], this->Stride[2]); } break; case XDMF_GEOMETRY_VXVYVZ: { xmfGeometry->GetVectorX()->GetValues(update_extents[0], xarray->GetPointer(0), scaled_dims[0], this->Stride[0]); xmfGeometry->GetVectorY()->GetValues(update_extents[2], yarray->GetPointer(0), scaled_dims[1], this->Stride[1]); xmfGeometry->GetVectorZ()->GetValues(update_extents[4], zarray->GetPointer(0), scaled_dims[2], this->Stride[2]); } break; default: vtkErrorWithObjectMacro(this->Reader, "Geometry type : " << xmfGeometry->GetGeometryTypeAsString() << " is not supported for " << xmfGrid->GetTopology()->GetTopologyTypeAsString()); return NULL; } this->ReadAttributes(rg, xmfGrid, update_extents); rg->Register(NULL); return rg; } //----------------------------------------------------------------------------- vtkStructuredGrid* vtkXdmfHeavyData::RequestStructuredGrid(XdmfGrid* xmfGrid) { vtkStructuredGrid* sg = vtkStructuredGrid::New(); int whole_extents[6]; int update_extents[6]; this->Domain->GetWholeExtent(xmfGrid, whole_extents); if (!vtkExtentsAreValid(this->Extents)) { // if this->Extents are not valid, then simply read the whole image. memcpy(update_extents, whole_extents, sizeof(int)*6); } else { memcpy(update_extents, this->Extents, sizeof(int)*6); } int scaled_extents[6]; vtkScaleExtents(update_extents, scaled_extents, this->Stride); sg->SetExtent(scaled_extents); vtkPoints* points = this->ReadPoints(xmfGrid->GetGeometry(), update_extents, whole_extents); sg->SetPoints(points); points->Delete(); this->ReadAttributes(sg, xmfGrid, update_extents); return sg; } //----------------------------------------------------------------------------- vtkImageData* vtkXdmfHeavyData::RequestImageData(XdmfGrid* xmfGrid, bool use_uniform_grid) { vtkImageData* imageData = use_uniform_grid? static_cast(vtkUniformGrid::New()) : vtkImageData::New(); int whole_extents[6]; this->Domain->GetWholeExtent(xmfGrid, whole_extents); int update_extents[6]; if (!vtkExtentsAreValid(this->Extents)) { // if this->Extents are not valid, then simply read the whole image. memcpy(update_extents, whole_extents, sizeof(int)*6); } else { memcpy(update_extents, this->Extents, sizeof(int)*6); } int scaled_extents[6]; vtkScaleExtents(update_extents, scaled_extents, this->Stride); imageData->SetExtent(scaled_extents); double origin[3], spacing[3]; if (!this->Domain->GetOriginAndSpacing(xmfGrid, origin, spacing)) { vtkErrorWithObjectMacro(this->Reader, "Could not determine image-data origin and spacing. " "Required geometry type is ORIGIN_DXDY or ORIGIN_DXDYDZ. " "The specified geometry type is : " << xmfGrid->GetGeometry()->GetGeometryTypeAsString()); // release image data. imageData->Delete(); return NULL; } imageData->SetOrigin(origin); imageData->SetSpacing( spacing[0] * this->Stride[0], spacing[1] * this->Stride[1], spacing[2] * this->Stride[2]); this->ReadAttributes(imageData, xmfGrid, update_extents); return imageData; } //----------------------------------------------------------------------------- vtkPoints* vtkXdmfHeavyData::ReadPoints(XdmfGeometry* xmfGeometry, int *update_extents /*=NULL*/, int *whole_extents /*=NULL*/) { XdmfInt32 geomType = xmfGeometry->GetGeometryType(); if (geomType != XDMF_GEOMETRY_X_Y_Z && geomType != XDMF_GEOMETRY_XYZ && geomType != XDMF_GEOMETRY_X_Y && geomType != XDMF_GEOMETRY_XY) { return NULL; } XdmfArray* xmfPoints = xmfGeometry->GetPoints(); if (!xmfPoints) { XdmfErrorMessage("No Points to Set"); return NULL; } vtkSmartPointer points = vtkSmartPointer::New(); if (xmfPoints->GetNumberType() == XDMF_FLOAT32_TYPE) { vtkFloatArray* da = vtkFloatArray::New(); da->SetNumberOfComponents(3); points->SetData(da); da->Delete(); } else // means == XDMF_FLOAT64_TYPE { vtkDoubleArray* da = vtkDoubleArray::New(); da->SetNumberOfComponents(3); points->SetData(da); da->Delete(); } XdmfInt64 numGeometryPoints = xmfGeometry->GetNumberOfPoints(); vtkIdType numPoints = numGeometryPoints; bool structured_data = false; if (update_extents && whole_extents) { // we are reading a sub-extent. structured_data = true; int scaled_extents[6]; int scaled_dims[3]; vtkScaleExtents(update_extents, scaled_extents, this->Stride); vtkGetDims(scaled_extents, scaled_dims); numPoints = (scaled_dims[0] * scaled_dims[1] * scaled_dims[2]); } points->SetNumberOfPoints(numPoints); if (!structured_data) { // read all the points. switch (points->GetData()->GetDataType()) { case VTK_DOUBLE: xmfPoints->GetValues(0, reinterpret_cast( points->GetVoidPointer(0)), numPoints*3); break; case VTK_FLOAT: xmfPoints->GetValues(0, reinterpret_cast( points->GetVoidPointer(0)), numPoints*3); break; default: return NULL; } } else { // treating the points as structured points XdmfFloat64* tempPoints = new XdmfFloat64[numGeometryPoints*3]; xmfPoints->GetValues(0, tempPoints, numGeometryPoints*3); vtkIdType pointId=0; int xdmf_dims[3]; vtkGetDims(whole_extents, xdmf_dims); for (int z = update_extents[4]; z <= update_extents[5]; z++) { if ((z-update_extents[4]) % this->Stride[2]) { continue; } for (int y = update_extents[2]; y <= update_extents[3]; y++) { if ((y-update_extents[2]) % this->Stride[1]) { continue; } for (int x = update_extents[0]; x <= update_extents[1]; x++) { if ((x-update_extents[0]) % this->Stride[0]) { continue; } int xdmf_index[3] = {x,y,z}; XdmfInt64 offset = vtkStructuredData::ComputePointId(xdmf_dims, xdmf_index); points->SetPoint(pointId, tempPoints[3*offset], tempPoints[3*offset+1], tempPoints[3*offset+2]); pointId++; } } } delete [] tempPoints; } points->Register(0); return points; } //----------------------------------------------------------------------------- bool vtkXdmfHeavyData::ReadAttributes( vtkDataSet* dataSet, XdmfGrid* xmfGrid, int* update_extents) { int data_dimensionality = this->Domain->GetDataDimensionality(xmfGrid); int numAttributes = xmfGrid->GetNumberOfAttributes(); for (int cc=0; cc < numAttributes; cc++) { XdmfAttribute* xmfAttribute = xmfGrid->GetAttribute(cc); const char* attrName = xmfAttribute->GetName(); int attrCenter = xmfAttribute->GetAttributeCenter(); if (!attrName) { vtkWarningWithObjectMacro(this->Reader, "Skipping unnamed attributes."); continue; } vtkFieldData * fieldData = 0; // skip disabled arrays. switch (attrCenter) { case XDMF_ATTRIBUTE_CENTER_GRID: fieldData = dataSet->GetFieldData(); break; case XDMF_ATTRIBUTE_CENTER_CELL: if (!this->Domain->GetCellArraySelection()->ArrayIsEnabled(attrName)) { continue; } fieldData = dataSet->GetCellData(); break; case XDMF_ATTRIBUTE_CENTER_NODE: if (!this->Domain->GetPointArraySelection()->ArrayIsEnabled(attrName)) { continue; } fieldData = dataSet->GetPointData(); break; case XDMF_ATTRIBUTE_CENTER_FACE: case XDMF_ATTRIBUTE_CENTER_EDGE: default: vtkWarningWithObjectMacro(this->Reader, "Skipping attribute " << attrName << " at " << xmfAttribute->GetAttributeCenterAsString()); continue; // unhandled. } vtkDataArray* array = this->ReadAttribute(xmfAttribute, data_dimensionality, update_extents); if (array) { array->SetName(attrName); fieldData->AddArray(array); bool is_active = xmfAttribute->GetActive() != 0; vtkDataSetAttributes* attributes = vtkDataSetAttributes::SafeDownCast(fieldData); if (attributes) { // make attribute active. switch (xmfAttribute->GetAttributeType()) { case XDMF_ATTRIBUTE_TYPE_SCALAR: if (is_active || attributes->GetScalars() == NULL) { attributes->SetActiveScalars(attrName); } break; case XDMF_ATTRIBUTE_TYPE_VECTOR: if (is_active || attributes->GetVectors() == NULL) { attributes->SetActiveVectors(attrName); } break; case XDMF_ATTRIBUTE_TYPE_TENSOR: case XDMF_ATTRIBUTE_TYPE_TENSOR6: if (is_active || attributes->GetTensors() == NULL) { attributes->SetActiveTensors(attrName); } break; case XDMF_ATTRIBUTE_TYPE_GLOBALID: if (is_active || attributes->GetGlobalIds() == NULL) { attributes->SetActiveGlobalIds(attrName); } } } array->Delete(); } } return true; } // used to convert a symmetric tensor to a regular tensor. template void vtkConvertTensor6(T* source, T* dest, vtkIdType numTensors) { for (vtkIdType cc=0; cc < numTensors; cc++) { dest[cc*9 + 0] = source[cc*6 + 0]; dest[cc*9 + 1] = source[cc*6 + 1]; dest[cc*9 + 2] = source[cc*6 + 2]; dest[cc*9 + 3] = source[cc*6 + 1]; dest[cc*9 + 4] = source[cc*6 + 3]; dest[cc*9 + 5] = source[cc*6 + 4]; dest[cc*9 + 6] = source[cc*6 + 2]; dest[cc*9 + 7] = source[cc*6 + 4]; dest[cc*9 + 8] = source[cc*6 + 5]; } } //----------------------------------------------------------------------------- vtkDataArray* vtkXdmfHeavyData::ReadAttribute(XdmfAttribute* xmfAttribute, int data_dimensionality, int* update_extents/*=0*/) { if (!xmfAttribute) { return NULL; } int attrType = xmfAttribute->GetAttributeType(); int attrCenter = xmfAttribute->GetAttributeCenter(); int numComponents = 1; switch (attrType) { case XDMF_ATTRIBUTE_TYPE_TENSOR : numComponents = 9; break; case XDMF_ATTRIBUTE_TYPE_TENSOR6: numComponents = 6; break; case XDMF_ATTRIBUTE_TYPE_VECTOR: numComponents = 3; break; default : numComponents = 1; break; } XdmfDataItem xmfDataItem; xmfDataItem.SetDOM(xmfAttribute->GetDOM()); xmfDataItem.SetElement(xmfAttribute->GetDOM()->FindDataElement(0, xmfAttribute->GetElement())); xmfDataItem.UpdateInformation(); XdmfInt64 data_dims[XDMF_MAX_DIMENSION]; int data_rank = xmfDataItem.GetDataDesc()->GetShape(data_dims); if (update_extents && attrCenter != XDMF_ATTRIBUTE_CENTER_GRID) { // for hyperslab selection to work, the data shape must match the topology // shape. if (data_rank < 0) { vtkErrorWithObjectMacro(this->Reader, "Unsupported attribute rank: " << data_rank); return NULL; } if (data_rank > (data_dimensionality + 1)) { vtkErrorWithObjectMacro(this->Reader, "The data_dimensionality and topology dimensionality mismatch"); return NULL; } XdmfInt64 start[4] = { update_extents[4], update_extents[2], update_extents[0], 0 }; XdmfInt64 stride[4] = {this->Stride[2], this->Stride[1], this->Stride[0], 1}; XdmfInt64 count[4] = {0, 0, 0, 0}; int scaled_dims[3]; int scaled_extents[6]; vtkScaleExtents(update_extents, scaled_extents, this->Stride); vtkGetDims(scaled_extents, scaled_dims); count[0] = (scaled_dims[2]-1); count[1] = (scaled_dims[1]-1); count[2] = (scaled_dims[0]-1); if (data_rank == (data_dimensionality+1)) { // this refers the number of components in the attribute. count[data_dimensionality] = data_dims[data_dimensionality]; } if (attrCenter == XDMF_ATTRIBUTE_CENTER_NODE) { // Point count is 1 + cell extent if not a single layer count[0] += (update_extents[5] - update_extents[4] > 0)? 1 : 1; count[1] += (update_extents[3] - update_extents[2] > 0)? 1 : 1; count[2] += (update_extents[1] - update_extents[0] > 0)? 1 : 1; } xmfDataItem.GetDataDesc()->SelectHyperSlab(start, stride, count); } if (xmfDataItem.Update()==XDMF_FAIL) { vtkErrorWithObjectMacro(this->Reader, "Failed to read attribute data"); return 0; } vtkXdmfDataArray* xmfConvertor = vtkXdmfDataArray::New(); vtkDataArray* dataArray = xmfConvertor->FromXdmfArray( xmfDataItem.GetArray()->GetTagName(), 1, data_rank, numComponents, 0); xmfConvertor->Delete(); if (attrType == XDMF_ATTRIBUTE_TYPE_TENSOR6) { // convert Tensor6 to Tensor. vtkDataArray* tensor = dataArray->NewInstance(); vtkIdType numTensors = dataArray->GetNumberOfTuples(); tensor->SetNumberOfComponents(9); tensor->SetNumberOfTuples(numTensors); // Copy Symmetrical Tensor Values to Correct Positions in 3x3 matrix void* source = dataArray->GetVoidPointer(0); void* dest = tensor->GetVoidPointer(0); switch (tensor->GetDataType()) { vtkTemplateMacro( vtkConvertTensor6(reinterpret_cast(source), reinterpret_cast(dest), numTensors) ); } dataArray->Delete(); return tensor; } return dataArray; } //----------------------------------------------------------------------------- // Read ghost cell/point information. This is simply loaded info a // vtkGhostLevels attribute array. bool vtkXdmfHeavyData::ReadGhostSets(vtkDataSet* dataSet, XdmfGrid* xmfGrid, int *vtkNotUsed(update_extents)/*=0*/) { //int data_dimensionality = this->Domain->GetDataDimensionality(xmfGrid); for (int cc=0; cc < xmfGrid->GetNumberOfSets(); cc++) { XdmfSet *xmfSet = xmfGrid->GetSets(cc); int ghost_value = xmfSet->GetGhost(); if (ghost_value <= 0) { // not a ghost-set, simply continue. continue; } XdmfInt32 setCenter = xmfSet->GetSetType(); vtkIdType numElems = 0; vtkDataSetAttributes* dsa = 0; switch (setCenter) { case XDMF_SET_TYPE_NODE: dsa = dataSet->GetPointData(); numElems = dataSet->GetNumberOfPoints(); break; case XDMF_SET_TYPE_CELL: dsa = dataSet->GetCellData(); numElems = dataSet->GetNumberOfCells(); break; default: vtkWarningWithObjectMacro(this->Reader, "Only ghost-cells and ghost-nodes are currently supported."); continue; } vtkUnsignedCharArray* ghostLevels = vtkUnsignedCharArray::SafeDownCast( dsa->GetArray("vtkGhostLevels")); if (!ghostLevels) { ghostLevels = vtkUnsignedCharArray::New(); ghostLevels->SetName("vtkGhostLevels"); ghostLevels->SetNumberOfComponents(1); ghostLevels->SetNumberOfTuples(numElems); ghostLevels->FillComponent(0, 0); dsa->AddArray(ghostLevels); ghostLevels->Delete(); } unsigned char* ptrGhostLevels = ghostLevels->GetPointer(0); // Read heavy data. We cannot do anything smart if update_extents or stride // is specified here. We have to read the entire set and then prune it. xmfSet->Update(); XdmfArray* xmfIds = xmfSet->GetIds(); XdmfInt64 numIds = xmfIds->GetNumberOfElements(); XdmfInt64 *ids = new XdmfInt64[numIds+1]; xmfIds->GetValues(0, ids, numIds); // release the heavy data that was read. xmfSet->Release(); for (vtkIdType kk=0; kk < numIds; kk++) { if (ids[kk] < 0 || ids[kk] > numElems) { vtkWarningWithObjectMacro(this->Reader, "No such cell or point exists: " << ids[kk]); continue; } ptrGhostLevels[ids[kk]] = ghost_value; } delete []ids; } return true; } //----------------------------------------------------------------------------- vtkMultiBlockDataSet* vtkXdmfHeavyData::ReadSets( vtkDataSet* dataSet, XdmfGrid* xmfGrid, int *vtkNotUsed(update_extents)/*=0*/) { unsigned int number_of_sets = 0; for (int cc=0; cc < xmfGrid->GetNumberOfSets(); cc++) { XdmfSet *xmfSet = xmfGrid->GetSets(cc); int ghost_value = xmfSet->GetGhost(); if (ghost_value != 0) { // skip ghost-sets. continue; } number_of_sets++; } if (number_of_sets == 0) { return NULL; } vtkMultiBlockDataSet* mb = vtkMultiBlockDataSet::New(); mb->SetNumberOfBlocks(1+number_of_sets); mb->SetBlock(0, dataSet); mb->GetMetaData(static_cast(0))->Set(vtkCompositeDataSet::NAME(), "Data"); unsigned int current_set_index = 1; for (int cc=0; cc < xmfGrid->GetNumberOfSets(); cc++) { XdmfSet *xmfSet = xmfGrid->GetSets(cc); int ghost_value = xmfSet->GetGhost(); if (ghost_value != 0) { // skip ghost-sets. continue; } const char* setName = xmfSet->GetName(); mb->GetMetaData(current_set_index)->Set(vtkCompositeDataSet::NAME(), setName); if (!this->Domain->GetSetsSelection()->ArrayIsEnabled(setName)) { continue; } // Okay now we have an enabled set. Create a new dataset for it vtkDataSet* set = 0; XdmfInt32 setType = xmfSet->GetSetType(); switch (setType) { case XDMF_SET_TYPE_NODE: set = this->ExtractPoints(xmfSet, dataSet); break; case XDMF_SET_TYPE_CELL: set = this->ExtractCells(xmfSet, dataSet); break; case XDMF_SET_TYPE_FACE: set = this->ExtractFaces(xmfSet, dataSet); break; case XDMF_SET_TYPE_EDGE: set = this->ExtractEdges(xmfSet, dataSet); break; } if (set) { mb->SetBlock(current_set_index, set); set->Delete(); } current_set_index++; } return mb; } //----------------------------------------------------------------------------- vtkDataSet* vtkXdmfHeavyData::ExtractPoints(XdmfSet* xmfSet, vtkDataSet* dataSet) { // TODO: How to handle structured datasets with update_extents/strides etc. // Do they too always produce vtkUniformGrid or do we want to produce // structured dataset // Read heavy data. We cannot do anything smart if update_extents or stride // is specified here. We have to read the entire set and then prune it. xmfSet->Update(); XdmfArray* xmfIds = xmfSet->GetIds(); XdmfInt64 numIds = xmfIds->GetNumberOfElements(); XdmfInt64 *ids = new XdmfInt64[numIds+1]; xmfIds->GetValues(0, ids, numIds); // release heavy data. xmfSet->Release(); vtkUnstructuredGrid* output = vtkUnstructuredGrid::New(); vtkPoints* outputPoints = vtkPoints::New(); outputPoints->SetNumberOfPoints(numIds); output->SetPoints(outputPoints); outputPoints->Delete(); vtkIdType numInPoints = dataSet->GetNumberOfPoints(); for (vtkIdType kk=0; kk < numIds; kk++) { if (ids[kk] < 0 || ids[kk] > numInPoints) { vtkWarningWithObjectMacro(this->Reader, "No such cell or point exists: " << ids[kk]); continue; } double point_location[3]; dataSet->GetPoint(ids[kk], point_location); outputPoints->SetPoint(kk, point_location); } delete []ids; ids = NULL; // Read node-centered attributes that may be defined on this set. int numAttributes = xmfSet->GetNumberOfAttributes(); for (int cc=0; cc < numAttributes; cc++) { XdmfAttribute* xmfAttribute = xmfSet->GetAttribute(cc); const char* attrName = xmfAttribute->GetName(); int attrCenter = xmfAttribute->GetAttributeCenter(); if (attrCenter != XDMF_ATTRIBUTE_CENTER_NODE) { continue; } vtkDataArray* array = this->ReadAttribute(xmfAttribute, 1, NULL); if (array) { array->SetName(attrName); output->GetPointData()->AddArray(array); array->Delete(); } } vtkIdType *vtk_cell_ids = new vtkIdType[numIds]; for (vtkIdType cc=0; cc < numIds; cc++) { vtk_cell_ids[cc] = cc; } output->InsertNextCell(VTK_POLY_VERTEX, numIds, vtk_cell_ids); delete []vtk_cell_ids; vtk_cell_ids = NULL; return output; } //----------------------------------------------------------------------------- vtkDataSet* vtkXdmfHeavyData::ExtractCells(XdmfSet* xmfSet, vtkDataSet* dataSet) { // TODO: How to handle structured datasets with update_extents/strides etc. // Do they too always produce vtkUniformGrid or do we want to produce // structured dataset // Read heavy data. xmfSet->Update(); XdmfArray* xmfIds = xmfSet->GetIds(); XdmfInt64 numIds = xmfIds->GetNumberOfElements(); vtkIdTypeArray* ids = vtkIdTypeArray::New(); ids->SetNumberOfComponents(1); ids->SetNumberOfTuples(numIds); xmfIds->GetValues(0, ids->GetPointer(0), numIds); // release heavy data. xmfSet->Release(); // We directly use vtkExtractSelectedIds for extract cells since the logic to // extract cells it no trivial (like extracting points). vtkSelectionNode* selNode = vtkSelectionNode::New(); selNode->SetContentType(vtkSelectionNode::INDICES); selNode->SetFieldType(vtkSelectionNode::CELL); selNode->SetSelectionList(ids); vtkSelection* sel = vtkSelection::New(); sel->AddNode(selNode); selNode->Delete(); vtkExtractSelectedIds* extractCells = vtkExtractSelectedIds::New(); extractCells->SetInputConnection(0, dataSet->GetProducerPort()); extractCells->SetInputConnection(1, sel->GetProducerPort()); extractCells->Update(); vtkDataSet* output = vtkDataSet::SafeDownCast( extractCells->GetOutput()->NewInstance()); output->CopyStructure(vtkDataSet::SafeDownCast(extractCells->GetOutput())); sel->Delete(); extractCells->Delete(); ids->Delete(); // Read cell-centered attributes that may be defined on this set. int numAttributes = xmfSet->GetNumberOfAttributes(); for (int cc=0; cc < numAttributes; cc++) { XdmfAttribute* xmfAttribute = xmfSet->GetAttribute(cc); const char* attrName = xmfAttribute->GetName(); int attrCenter = xmfAttribute->GetAttributeCenter(); if (attrCenter != XDMF_ATTRIBUTE_CENTER_CELL) { continue; } vtkDataArray* array = this->ReadAttribute(xmfAttribute, 1, NULL); if (array) { array->SetName(attrName); output->GetCellData()->AddArray(array); array->Delete(); } } return output; } //----------------------------------------------------------------------------- vtkDataSet* vtkXdmfHeavyData::ExtractFaces(XdmfSet* xmfSet, vtkDataSet* dataSet) { xmfSet->Update(); XdmfArray* xmfIds = xmfSet->GetIds(); XdmfArray* xmfCellIds = xmfSet->GetCellIds(); XdmfInt64 numFaces = xmfIds->GetNumberOfElements(); // ids is a 2 component array were each tuple is (cell-id, face-id). vtkIdTypeArray* ids = vtkIdTypeArray::New(); ids->SetNumberOfComponents(2); ids->SetNumberOfTuples(numFaces); xmfCellIds->GetValues(0, ids->GetPointer(0), numFaces, 1, 2); xmfIds->GetValues(0, ids->GetPointer(1), numFaces, 1, 2); vtkPolyData* output = vtkPolyData::New(); vtkCellArray* polys = vtkCellArray::New(); output->SetPolys(polys); polys->Delete(); vtkPoints* outPoints = vtkPoints::New(); output->SetPoints(outPoints); outPoints->Delete(); vtkMergePoints* mergePoints = vtkMergePoints::New(); mergePoints->InitPointInsertion(outPoints, dataSet->GetBounds()); for (vtkIdType cc=0; cc < numFaces; cc++) { vtkIdType cellId = ids->GetValue(cc*2); vtkIdType faceId = ids->GetValue(cc*2+1); vtkCell* cell = dataSet->GetCell(cellId); if (!cell) { vtkWarningWithObjectMacro( this->Reader, "Invalid cellId: " << cellId) continue; } vtkCell* face = cell->GetFace(faceId); if (!face) { vtkWarningWithObjectMacro(this->Reader, "Invalid faceId " << faceId << " on cell " << cellId); continue; } // Now insert this face a new cell in the output dataset. vtkIdType numPoints = face->GetNumberOfPoints(); vtkPoints* facePoints = face->GetPoints(); vtkIdType* outputPts = new vtkIdType[numPoints+1]; for (vtkIdType kk=0; kk < numPoints; kk++) { mergePoints->InsertUniquePoint( facePoints->GetPoint(kk), outputPts[kk]); } polys->InsertNextCell(numPoints, outputPts); delete [] outputPts; } ids->Delete(); xmfSet->Release(); mergePoints->Delete(); // Read face-centered attributes that may be defined on this set. int numAttributes = xmfSet->GetNumberOfAttributes(); for (int cc=0; cc < numAttributes; cc++) { XdmfAttribute* xmfAttribute = xmfSet->GetAttribute(cc); const char* attrName = xmfAttribute->GetName(); int attrCenter = xmfAttribute->GetAttributeCenter(); if (attrCenter != XDMF_ATTRIBUTE_CENTER_FACE) { continue; } vtkDataArray* array = this->ReadAttribute(xmfAttribute, 1, NULL); if (array) { array->SetName(attrName); output->GetCellData()->AddArray(array); array->Delete(); } } return output; } //----------------------------------------------------------------------------- vtkDataSet* vtkXdmfHeavyData::ExtractEdges(XdmfSet* xmfSet, vtkDataSet* dataSet) { xmfSet->Update(); XdmfArray* xmfIds = xmfSet->GetIds(); XdmfArray* xmfCellIds = xmfSet->GetCellIds(); XdmfArray* xmfFaceIds = xmfSet->GetFaceIds(); XdmfInt64 numEdges = xmfIds->GetNumberOfElements(); // ids is a 3 component array were each tuple is (cell-id, face-id, edge-id). vtkIdTypeArray* ids = vtkIdTypeArray::New(); ids->SetNumberOfComponents(3); ids->SetNumberOfTuples(numEdges); xmfCellIds->GetValues(0, ids->GetPointer(0), numEdges, 1, 3); xmfFaceIds->GetValues(0, ids->GetPointer(1), numEdges, 1, 3); xmfIds->GetValues(0, ids->GetPointer(2), numEdges, 1, 3); vtkPolyData* output = vtkPolyData::New(); vtkCellArray* lines = vtkCellArray::New(); output->SetLines(lines); lines->Delete(); vtkPoints* outPoints = vtkPoints::New(); output->SetPoints(outPoints); outPoints->Delete(); vtkMergePoints* mergePoints = vtkMergePoints::New(); mergePoints->InitPointInsertion(outPoints, dataSet->GetBounds()); for (vtkIdType cc=0; cc < numEdges; cc++) { vtkIdType cellId = ids->GetValue(cc*3); vtkIdType faceId = ids->GetValue(cc*3+1); vtkIdType edgeId = ids->GetValue(cc*3+2); vtkCell* cell = dataSet->GetCell(cellId); if (!cell) { vtkWarningWithObjectMacro(this->Reader, "Invalid cellId: " << cellId); continue; } vtkCell* face = cell->GetFace(faceId); if (!face) { vtkWarningWithObjectMacro(this->Reader, "Invalid faceId " << faceId << " on cell " << cellId); continue; } vtkCell* edge = cell->GetEdge(edgeId); if (!edge) { vtkWarningWithObjectMacro(this->Reader, "Invalid edgeId " << edgeId << " on face " << faceId << " on cell " << cellId); continue; } // Now insert this edge as a new cell in the output dataset. vtkIdType numPoints = edge->GetNumberOfPoints(); vtkPoints* edgePoints = edge->GetPoints(); vtkIdType* outputPts = new vtkIdType[numPoints+1]; for (vtkIdType kk=0; kk < numPoints; kk++) { mergePoints->InsertUniquePoint( edgePoints->GetPoint(kk), outputPts[kk]); } lines->InsertNextCell(numPoints, outputPts); delete [] outputPts; } ids->Delete(); xmfSet->Release(); mergePoints->Delete(); // Read edge-centered attributes that may be defined on this set. int numAttributes = xmfSet->GetNumberOfAttributes(); for (int cc=0; cc < numAttributes; cc++) { XdmfAttribute* xmfAttribute = xmfSet->GetAttribute(cc); const char* attrName = xmfAttribute->GetName(); int attrCenter = xmfAttribute->GetAttributeCenter(); if (attrCenter != XDMF_ATTRIBUTE_CENTER_EDGE) { continue; } vtkDataArray* array = this->ReadAttribute(xmfAttribute, 1, NULL); if (array) { array->SetName(attrName); output->GetCellData()->AddArray(array); array->Delete(); } } return output; } xdmf-3.0+git20160803/vtk/vtkXdmfRenderWindowInteractor.h.in0000640000175000017500000000436613003006557023473 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : $Id: vtkXdmfRenderWindowInteractor.h.in,v 1.2 2007-02-22 13:36:39 clarke Exp $ */ /* Date : $Date: 2007-02-22 13:36:39 $ */ /* Version : $Revision: 1.2 $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2002 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #ifndef _@XDMF_WINDOWINTERACTOR@_h #define _@XDMF_WINDOWINTERACTOR@_h #include "@XDMF_WINDOWINTERACTOR@.h" class VTK_EXPORT vtkXdmfRenderWindowInteractor : public @XDMF_WINDOWINTERACTOR@ { public: static vtkXdmfRenderWindowInteractor *New(); vtkTypeMacro(vtkXdmfRenderWindowInteractor,@XDMF_WINDOWINTERACTOR@); virtual void LoopOnce(); virtual void Start( int Block ); virtual void Start( ) { this->Start(0); } protected: vtkXdmfRenderWindowInteractor() {} private: vtkXdmfRenderWindowInteractor(const vtkXdmfRenderWindowInteractor&); // Not implemented void operator=(const vtkXdmfRenderWindowInteractor&); // Not implemented }; #endif xdmf-3.0+git20160803/vtk/vtkXdmfReaderInternal.cxx0000640000175000017500000005714613003006557021702 0ustar alastairalastair/*========================================================================= Program: Visualization Toolkit Module: $RCSfile: vtkXdmfReaderInternal.cxx,v $ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen All rights reserved. See Copyright.txt or http://www.kitware.com/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ #include "vtkXdmfReaderInternal.h" #include "vtkDataArray.h" #include "vtkSmartPointer.h" #include "vtkVariant.h" #include "vtkXdmfDataArray.h" #define USE_IMAGE_DATA // otherwise uniformgrid // As soon as num-grids (sub-grids and all) grows beyond this number, we assume // that the grids are way too numerous for the user to select individually and // hence only the top-level grids are made accessible. #define MAX_COLLECTABLE_NUMBER_OF_GRIDS 1000 template T vtkMAX(T a, T b) { return (a>b? a : b); } //---------------------------------------------------------------------------- vtkXdmfDocument::vtkXdmfDocument() { this->ActiveDomain = 0; this->ActiveDomainIndex = -1; this->LastReadContents = 0; this->LastReadContentsLength = 0; } //---------------------------------------------------------------------------- vtkXdmfDocument::~vtkXdmfDocument() { delete this->ActiveDomain; delete [] this->LastReadContents; } //---------------------------------------------------------------------------- bool vtkXdmfDocument::Parse(const char* xmffilename) { if (!xmffilename) { return false; } if (this->LastReadFilename == xmffilename) { return true; } this->ActiveDomainIndex = -1; delete this->ActiveDomain; this->ActiveDomain = 0; delete [] this->LastReadContents; this->LastReadContents = 0; this->LastReadContentsLength = 0; this->LastReadFilename = vtkstd::string(); this->XMLDOM.SetInputFileName(xmffilename); if (!this->XMLDOM.Parse()) { return false; } //Tell the parser what the working directory is. vtkstd::string directory = vtksys::SystemTools::GetFilenamePath(xmffilename) + "/"; if (directory == "/") { directory = vtksys::SystemTools::GetCurrentWorkingDirectory() + "/"; } this->XMLDOM.SetWorkingDirectory(directory.c_str()); this->LastReadFilename = xmffilename; this->UpdateDomains(); return true; } //---------------------------------------------------------------------------- bool vtkXdmfDocument::ParseString(const char* xmfdata, size_t length) { if (!xmfdata || !length) { return false; } if (this->LastReadContents && this->LastReadContentsLength == length && STRNCASECMP(xmfdata, this->LastReadContents, length) == 0) { return true; } this->ActiveDomainIndex = -1; delete this->ActiveDomain; this->ActiveDomain = 0; delete this->LastReadContents; this->LastReadContentsLength = 0; this->LastReadFilename = vtkstd::string(); this->LastReadContents = new char[length+1]; this->LastReadContentsLength = length; memcpy(this->LastReadContents, xmfdata, length); this->LastReadContents[length]=0; this->XMLDOM.SetInputFileName(0); if (!this->XMLDOM.Parse(this->LastReadContents)) { delete this->LastReadContents; this->LastReadContents = 0; this->LastReadContentsLength = 0; return false; } this->UpdateDomains(); return true; } //---------------------------------------------------------------------------- void vtkXdmfDocument::UpdateDomains() { this->Domains.clear(); XdmfXmlNode domain = this->XMLDOM.FindElement("Domain", 0); while (domain) { XdmfConstString domainName = this->XMLDOM.Get(domain, "Name"); if (domainName) { this->Domains.push_back(domainName); } else { vtksys_ios::ostringstream str; str << "Domain" << this->Domains.size() << ends; this->Domains.push_back(str.str()); } domain = this->XMLDOM.FindNextElement("Domain", domain); } } //---------------------------------------------------------------------------- bool vtkXdmfDocument::SetActiveDomain(const char* domainname) { for (int cc=0; cc < static_cast(this->Domains.size()); cc++) { if (this->Domains[cc] == domainname) { return this->SetActiveDomain(cc); } } return false; } //---------------------------------------------------------------------------- bool vtkXdmfDocument::SetActiveDomain(int index) { if (this->ActiveDomainIndex == index) { return true; } this->ActiveDomainIndex = -1; delete this->ActiveDomain; this->ActiveDomain = 0; vtkXdmfDomain *domain = new vtkXdmfDomain(&this->XMLDOM, index); if (!domain->IsValid()) { delete domain; return false; } this->ActiveDomain = domain; this->ActiveDomainIndex = index; return true; } //***************************************************************************** // vtkXdmfDomain //---------------------------------------------------------------------------- vtkXdmfDomain::vtkXdmfDomain(XdmfDOM* xmlDom, int domain_index) { this->XMLDOM = 0; this->XMFGrids = NULL; this->NumberOfGrids = 0; this->SIL = vtkMutableDirectedGraph::New(); this->SILBuilder = vtkSILBuilder::New(); this->SILBuilder->SetSIL(this->SIL); this->PointArrays = new vtkXdmfArraySelection; this->CellArrays = new vtkXdmfArraySelection; this->Grids = new vtkXdmfArraySelection; this->Sets = new vtkXdmfArraySelection; this->XMLDomain = xmlDom->FindElement("Domain", domain_index); if (!this->XMLDomain) { // no such domain exists!!! return; } this->XMLDOM = xmlDom; // Allocate XdmfGrid instances for each of the grids in this domain. this->NumberOfGrids = this->XMLDOM->FindNumberOfElements("Grid", this->XMLDomain); this->XMFGrids = new XdmfGrid[this->NumberOfGrids+1]; XdmfXmlNode xmlGrid = this->XMLDOM->FindElement("Grid", 0, this->XMLDomain); XdmfInt64 cc=0; while (xmlGrid) { this->XMFGrids[cc].SetDOM(this->XMLDOM); this->XMFGrids[cc].SetElement(xmlGrid); // Read the light data for this grid (and all its sub-grids, if // applicable). this->XMFGrids[cc].UpdateInformation(); xmlGrid = this->XMLDOM->FindNextElement("Grid", xmlGrid); cc++; } // There are a few meta-information that we need to collect from the domain // * number of data-arrays so that the user can choose which to load. // * grid-structure so that the user can choose the hierarchy // * time information so that reader can report the number of timesteps // available. this->CollectMetaData(); } //---------------------------------------------------------------------------- vtkXdmfDomain::~vtkXdmfDomain() { // free the XdmfGrid allocated. delete [] this->XMFGrids; this->XMFGrids = NULL; this->SIL->Delete(); this->SIL = 0; this->SILBuilder->Delete(); this->SILBuilder = 0; delete this->PointArrays; delete this->CellArrays; delete this->Grids; delete this->Sets;; } //---------------------------------------------------------------------------- XdmfGrid* vtkXdmfDomain::GetGrid(XdmfInt64 cc) { if (cc >= 0 && cc < this->NumberOfGrids) { return &this->XMFGrids[cc]; } return NULL; } //---------------------------------------------------------------------------- int vtkXdmfDomain::GetVTKDataType() { if (this->NumberOfGrids > 1) { return VTK_MULTIBLOCK_DATA_SET; } if (this->NumberOfGrids == 1) { return this->GetVTKDataType(&this->XMFGrids[0]); } return -1; } //---------------------------------------------------------------------------- int vtkXdmfDomain::GetVTKDataType(XdmfGrid* xmfGrid) { XdmfInt32 gridType = xmfGrid->GetGridType(); if ((gridType & XDMF_GRID_COLLECTION) && xmfGrid->GetCollectionType() == XDMF_GRID_COLLECTION_TEMPORAL) { // this is a temporal collection, the type depends on the child with // correct time-stamp. But since we assume that all items in a temporal // collection must be of the same type, we simply use the first child. return this->GetVTKDataType(xmfGrid->GetChild(0)); } if ( (gridType & XDMF_GRID_COLLECTION) || (gridType & XDMF_GRID_TREE) ) { return VTK_MULTIBLOCK_DATA_SET; } if (xmfGrid->GetTopology()->GetClass() == XDMF_UNSTRUCTURED ) { return VTK_UNSTRUCTURED_GRID; } XdmfInt32 topologyType = xmfGrid->GetTopology()->GetTopologyType(); if (topologyType == XDMF_2DSMESH || topologyType == XDMF_3DSMESH ) { return VTK_STRUCTURED_GRID; } else if (topologyType == XDMF_2DCORECTMESH || topologyType == XDMF_3DCORECTMESH) { #ifdef USE_IMAGE_DATA return VTK_IMAGE_DATA; #else return VTK_UNIFORM_GRID; #endif } else if (topologyType == XDMF_2DRECTMESH || topologyType == XDMF_3DRECTMESH) { return VTK_RECTILINEAR_GRID; } return -1; } //---------------------------------------------------------------------------- int vtkXdmfDomain::GetIndexForTime(double time) { vtkstd::set::iterator iter = this->TimeSteps.upper_bound(time); if (iter == this->TimeSteps.begin()) { // The requested time step is before any available time. We will use it by // doing nothing here. } else { // Back up one to the item we really want. iter--; } vtkstd::set::iterator iter2 = this->TimeSteps.begin(); int counter = 0; while (iter2 != iter) { iter2++; counter++; } return counter; } //---------------------------------------------------------------------------- XdmfGrid* vtkXdmfDomain::GetGrid(XdmfGrid* xmfGrid, double time) { XdmfInt32 gridType = xmfGrid->GetGridType(); if ((gridType & XDMF_GRID_COLLECTION) && xmfGrid->GetCollectionType() == XDMF_GRID_COLLECTION_TEMPORAL) { for (XdmfInt32 cc=0; cc < xmfGrid->GetNumberOfChildren(); cc++) { XdmfGrid* child = xmfGrid->GetChild(cc); if (child && child->GetTime()->IsValid(time, time)) { return child; } } // not sure what to do if no sub-grid matches the requested time. return NULL; } return xmfGrid; } //---------------------------------------------------------------------------- bool vtkXdmfDomain::IsStructured(XdmfGrid* xmfGrid) { switch (this->GetVTKDataType(xmfGrid)) { case VTK_IMAGE_DATA: case VTK_UNIFORM_GRID: case VTK_RECTILINEAR_GRID: case VTK_STRUCTURED_GRID: return true; } return false; } //---------------------------------------------------------------------------- bool vtkXdmfDomain::GetWholeExtent(XdmfGrid* xmfGrid, int extents[6]) { extents[0] = extents[2] = extents[4] = 0; extents[1] = extents[3] = extents[5] = -1; if (!this->IsStructured(xmfGrid)) { return false; } XdmfInt64 dimensions[XDMF_MAX_DIMENSION]; XdmfDataDesc* xmfDataDesc = xmfGrid->GetTopology()->GetShapeDesc(); XdmfInt32 num_of_dims = xmfDataDesc->GetShape(dimensions); // clear out un-filled dimensions. for (int cc=num_of_dims; cc < 3; cc++) // only need to until the 3rd dimension // since we don't care about any higher // dimensions yet. { dimensions[cc] = 1; } // vtk Dims are i,j,k XDMF are k,j,i extents[5] = vtkMAX(static_cast(0), dimensions[0] - 1); extents[3] = vtkMAX(static_cast(0), dimensions[1] - 1); extents[1] = vtkMAX(static_cast(0), dimensions[2] - 1); return true; } //---------------------------------------------------------------------------- bool vtkXdmfDomain::GetOriginAndSpacing(XdmfGrid* xmfGrid, double origin[3], double spacing[3]) { if (xmfGrid->GetTopology()->GetTopologyType() != XDMF_2DCORECTMESH && xmfGrid->GetTopology()->GetTopologyType() != XDMF_3DCORECTMESH) { return false; } XdmfGeometry *xmfGeometry = xmfGrid->GetGeometry(); if (xmfGeometry->GetGeometryType() == XDMF_GEOMETRY_ORIGIN_DXDYDZ ) { // Update geometry so that origin and spacing are read xmfGeometry->Update(); // read heavy-data for the geometry. XdmfFloat64 *xmfOrigin = xmfGeometry->GetOrigin(); XdmfFloat64 *xmfSpacing = xmfGeometry->GetDxDyDz(); origin[0] = xmfOrigin[2]; origin[1] = xmfOrigin[1]; origin[2] = xmfOrigin[0]; spacing[0] = xmfSpacing[2]; spacing[1] = xmfSpacing[1]; spacing[2] = xmfSpacing[0]; return true; } else if (xmfGeometry->GetGeometryType() == XDMF_GEOMETRY_ORIGIN_DXDY) { // Update geometry so that origin and spacing are read xmfGeometry->Update(); // read heavy-data for the geometry. XdmfFloat64 *xmfOrigin = xmfGeometry->GetOrigin(); XdmfFloat64 *xmfSpacing = xmfGeometry->GetDxDyDz(); origin[0] = 0.0; origin[1] = xmfOrigin[1]; origin[2] = xmfOrigin[0]; spacing[0] = 1.0; spacing[1] = xmfSpacing[1]; spacing[2] = xmfSpacing[0]; return true; } origin[0] = origin[1] = origin[2] = 0.0; spacing[0] = spacing[1] = spacing[2] = 1.0; return false; } //---------------------------------------------------------------------------- int vtkXdmfDomain::GetDataDimensionality(XdmfGrid* xmfGrid) { if (!xmfGrid || !xmfGrid->IsUniform()) { return -1; } switch (xmfGrid->GetTopology()->GetTopologyType()) { case XDMF_NOTOPOLOGY : case XDMF_POLYVERTEX : case XDMF_POLYLINE : case XDMF_POLYGON : case XDMF_TRI : case XDMF_QUAD : case XDMF_TET : case XDMF_PYRAMID : case XDMF_WEDGE : case XDMF_HEX : case XDMF_EDGE_3 : case XDMF_TRI_6 : case XDMF_QUAD_8 : case XDMF_TET_10 : case XDMF_PYRAMID_13 : case XDMF_WEDGE_15 : case XDMF_WEDGE_18 : case XDMF_HEX_20 : case XDMF_HEX_24 : case XDMF_HEX_27 : case XDMF_MIXED : return 1; // unstructured data-sets have no inherent dimensionality. case XDMF_2DSMESH : case XDMF_2DRECTMESH : case XDMF_2DCORECTMESH: return 2; case XDMF_3DSMESH : case XDMF_3DRECTMESH : case XDMF_3DCORECTMESH: return 3; } return -1; } //---------------------------------------------------------------------------- void vtkXdmfDomain::CollectMetaData() { this->SILBuilder->Initialize(); this->GridsOverflowCounter = 0; vtkIdType blocksRoot = this->SILBuilder->AddVertex("Blocks"); vtkIdType hierarchyRoot = this->SILBuilder->AddVertex("Hierarchy"); this->SILBuilder->AddChildEdge(this->SILBuilder->GetRootVertex(), blocksRoot); this->SILBuilder->AddChildEdge(this->SILBuilder->GetRootVertex(), hierarchyRoot); this->SILBlocksRoot = blocksRoot; for (XdmfInt64 cc=0; cc < this->NumberOfGrids; cc++) { this->CollectMetaData(&this->XMFGrids[cc], hierarchyRoot); } if (this->GridsOverflowCounter >= MAX_COLLECTABLE_NUMBER_OF_GRIDS) { this->Grids->clear(); // We have aborted collecting grids information since it was too numerous to // be of any use to the user. this->SILBuilder->Initialize(); blocksRoot = this->SILBuilder->AddVertex("Blocks"); hierarchyRoot = this->SILBuilder->AddVertex("Hierarchy"); this->SILBuilder->AddChildEdge(this->SILBuilder->GetRootVertex(), blocksRoot); this->SILBuilder->AddChildEdge(this->SILBuilder->GetRootVertex(), hierarchyRoot); this->SILBlocksRoot = blocksRoot; // add only the top-level grids. for (XdmfInt64 cc=0; cc < this->NumberOfGrids; cc++) { XdmfGrid * xmfGrid = &this->XMFGrids[cc]; vtkstd::string originalGridName = xmfGrid->GetName(); vtkstd::string gridName = xmfGrid->GetName(); unsigned int count=1; while (this->Grids->HasArray(gridName.c_str())) { vtksys_ios::ostringstream str; str << xmfGrid->GetName() << "[" << count << "]"; gridName = str.str(); count++; } xmfGrid->SetName(gridName.c_str()); this->Grids->AddArray(gridName.c_str()); vtkIdType silVertex = this->SILBuilder->AddVertex(xmfGrid->GetName()); this->SILBuilder->AddChildEdge(this->SILBlocksRoot, silVertex); vtkIdType hierarchyVertex = this->SILBuilder->AddVertex(originalGridName.c_str()); this->SILBuilder->AddChildEdge(hierarchyRoot, hierarchyVertex); this->SILBuilder->AddCrossEdge(hierarchyVertex, silVertex); } } } //---------------------------------------------------------------------------- void vtkXdmfDomain::CollectMetaData(XdmfGrid* xmfGrid, vtkIdType silParent) { if (!xmfGrid) { return; } // All grids need to be named. If a grid doesn't have a name, we make one // up. if (xmfGrid->GetName() == NULL) { xmfGrid->SetName(this->XMLDOM->GetUniqueName("Grid")); } if (xmfGrid->IsUniform()) { this->CollectLeafMetaData(xmfGrid, silParent); } else { this->CollectNonLeafMetaData(xmfGrid, silParent); } } //---------------------------------------------------------------------------- void vtkXdmfDomain::CollectNonLeafMetaData(XdmfGrid* xmfGrid, vtkIdType silParent) { vtkIdType silVertex = -1; if (silParent != -1 && this->GridsOverflowCounter < MAX_COLLECTABLE_NUMBER_OF_GRIDS) { // stop building SIL as soon as we have too many blocks--not worth it. this->GridsOverflowCounter++; // FIXME: how to reflect temporal collections in the SIL? silVertex = this->SILBuilder->AddVertex(xmfGrid->GetName()); this->SILBuilder->AddChildEdge(silParent, silVertex); } XdmfInt32 numChildren = xmfGrid->GetNumberOfChildren(); for (XdmfInt32 cc=0; cc < numChildren; cc++) { XdmfGrid* xmfChild = xmfGrid->GetChild(cc); this->CollectMetaData(xmfChild, silVertex); } // Collect time information // If a non-leaf node is a temporal collection then it may have a For Mixed Topologies the DataItem for Connections defines a list that has the cell types mixed in with the connectivity. Cell types POLYVERTEX, POLYLINE, and POLYGON are followed by the number of entries. For example, the connectivity for a TETRAHEDRON (cell type = 6) followed by a POLYGON (cell type = 3) with 5 points might look like this : 6 20 25 100 200 3 5 300 301 302 303 304 The Tet uses point index 20, 25, 100, and 200 while the polygon uses 300 - 304. XML Element : Topology XML Attribute : Name = Any String XML Attribute : TopologyType = Polyvertex | Polyline | Polygon | Triangle | Quadrilateral | Tetrahedron | Pyramid| Wedge | Hexahedron | Edge_3 | Triangle_6 | Quadrilateral_8 | Tetrahedron_10 | Pyramid_13 | Wedge_15 | Wedge_18 | Hexahedron_20 | Hexahedron_24 | Hexahedron_27 | Mixed | 2DSMesh | 2DRectMesh | 2DCoRectMesh | 3DSMesh | 3DRectMesh | 3DCoRectMesh XML Attribute : NumberOfElements = Number of Cells XML Attribute : NodesPerElement = # (Only Important for Polyvertex, Polygon and Polyline) XML Attribute : Order = Order of Nodes if not Default XML BaseOffset: Offset if not 0 \endverbatim */ class XDMF_EXPORT XdmfTopology : public XdmfElement { public: XdmfTopology(); ~XdmfTopology(); XdmfConstString GetClassName() { return ( "XdmfTopology" ) ; }; //! Build the XML (Output) XdmfInt32 Build(); //! Insert an Element XdmfInt32 Insert(XdmfElement *Child); //! Get General Class /*! GetClass returns XDMF_UNSTRUCTURED or XDMF_STRUCTURED. 2DXXXMESH and 3DXXXMESH return XDMF_STRUCTURED, everything else returns XDMF_UNSTRUCTURED. */ XdmfInt32 GetClass ( void ) { if( ( this->TopologyType & 0x100 ) == 0 ) { return( XDMF_UNSTRUCTURED ); } return( XDMF_STRUCTURED ); }; //! Get the General TopologyType as a String XdmfConstString GetClassAsString( void ) { if( this->GetClass() == XDMF_STRUCTURED ){ return( "XDMF_STRUCTURED" ); } return( "XDMF_UNSTRUCTURED" ); }; //! Set the base topology type XdmfInt32 SetTopologyType( XdmfInt32 TopologyType ); //! Set the base topology type from a string /*! This is needed for some scripting languages. \param TopologyType String defining the type of topology. This is case insensative. (i.e. TetraHedron or tetrahedron ) but the entire word must be specified (i.e. Tet will be ignored) */ XdmfInt32 SetTopologyTypeFromString( XdmfConstString TopologyType ); //! Get the base topology type XdmfGetValueMacro( TopologyType, XdmfInt32 ); //! Returns Topology Type as a String /*! Returns Topology Type as a String with the first letter capitalized (i.e. Hexahedron). */ XdmfConstString GetTopologyTypeAsString( void ); //! Set Node Ordering /*! For all unstructured topologies there is a default node ordering. For example a \b HEXAHEDRON is ordered : \verbatim 7 --------- 6 / /| 4 --------- 5 2 | 3 | / | / |/ 0 --------- 1 \endverbatim That is the first node index listed specified the index of the first node of the hex. Setting the \b Order re-sets this mapping. To use the following \b Order : \verbatim 1 --------- 0 / /| 3 --------- 2 5 | 4 | / | / |/ 7 --------- 6 \endverbatim Set the \b Order to 7, 6, 5, 4, 3, 2, 0, 1 Order is defined for all elements. This is for Hexahedron there are 8 values, for triangles 3, etc. */ XdmfInt32 *GetOrder( void ); //! Return the Order as a SPACE separated string XdmfConstString GetOrderAsString( void ); //! Set the Order from a SPACE separated String XdmfInt32 SetOrderFromString( XdmfConstString Order ); //! Set the Order from Integers /*! Set the Order from Integers. Since the number of nodes in a cell for some topologies is not defined, \b Length must be specified. \param Length The Number of Values Pointed to by Order \param Order Zero based list of Nodal Indecies */ XdmfInt32 SetOrder( XdmfInt32 Length, XdmfInt32 *Order ); //! Set the number of values to be written to Light Data before switching to Heavy Data XdmfSetValueMacro(LightDataLimit, XdmfInt32) //! Gets the number of values to be written to Light Data before switching to Heavy Data XdmfGetValueMacro(LightDataLimit, XdmfInt32) //! Set the number of Nodes in a Cell /*! Some topologies like tetrahedron and hexahedron have a defined number of nodes in a cell. But a Polygon, for example, may have a variable number of nodes. */ XdmfSetValueMacro( NodesPerElement, XdmfInt32 ); //! Get the number of nodes in a Cell XdmfGetValueMacro( NodesPerElement, XdmfInt32 ); /*! Get the number of edges per element for this particular topology type */ XdmfInt32 GetEdgesPerElement(); /*! Get the number of faces per element for this particular topology type */ XdmfInt32 GetFacesPerElement(); //! Specify Base offset other than zero for connectivity /*! Sometimes it is convenient to specify connectivity based on something other than zero. For example, many FORTRAN based codes use 1 as the first index. This allows for the connectivity to index the nodal array in any convenient manner. */ XdmfSetValueMacro( BaseOffset, XdmfInt32 ); //! Get the Base Offset of the connectivity XdmfGetValueMacro( BaseOffset, XdmfInt32 ); //! Return the SHAPE of the Topology /*! Sometimes it is convenient to specify a \b SHAPE other than linear. For example, a block of hexahedron might be stacked 10x20x30. This could be specified described as 6000 hexahedron, or 10 layers of 20 columns of 10 rows. */ XdmfDataDesc * GetShapeDesc( void ) { return( this->Shape ); } //! Set the total number of cells XdmfInt32 SetNumberOfElements(XdmfInt64 NumberOfElements); //! Return the total number of Cells XdmfInt64 GetNumberOfElements( void ); //! Returns an XdmfArray of Connectivity /*! Returns the connectivity as an XdmfArray. No matter what Base Offset has been specified, this array is zero based. */ XdmfArray *GetConnectivity( XdmfArray *Array = NULL, XdmfInt32 Create=1 ); //! Set the connectivity XdmfInt32 SetConnectivity( XdmfArray *Array ); //! Get the Offsets of each cell in the Connectivity Array XdmfArray *GetCellOffsets(XdmfArray *Array = NULL); //! Update the Heavy Data /*! If the Heavy Data is dynamic (i.e. stored in NDGM) or if only InitTopologyFromElement() has been called, Update() will (Re)Read the Heavy Data. */ XdmfInt32 Update( void ); //! Intiailize the Topology but do not access the Heavy Data XdmfInt32 UpdateInformation(void); //! Release Big Data XdmfInt32 Release(); #ifndef DOXYGEN_SKIP // XdmfInt32 SetBaseConnectivity( XdmfPointer Grid ); #endif /* XdmfXNode *SetElementFromTopology( XdmfXNode *Element = NULL ); */ protected: XdmfDataItem *GetDataItem(); XdmfInt32 TopologyType; XdmfInt32 Order[ XDMF_MAX_ORDER ]; XdmfInt32 NodesPerElement; XdmfArray *Connectivity; XdmfArray *CellOffsets; XdmfInt32 OrderIsDefault; XdmfInt32 ConnectivityIsMine; XdmfInt32 BaseOffset; XdmfDataDesc *Shape; XdmfInt32 LightDataLimit; }; extern XDMF_EXPORT XdmfTopology *HandleToXdmfTopology( XdmfString Source ); #endif // __XdmfTopology_h xdmf-3.0+git20160803/libsrc/XdmfRegion.cxx0000640000175000017500000001333113003006557020137 0ustar alastairalastair#include "XdmfRegion.h" #include "XdmfDataItem.h" #include "XdmfDataDesc.h" #include "XdmfArray.h" #include "XdmfDOM.h" XdmfRegion::XdmfRegion() { this->SetElementName("Region"); this->ValuesAreMine = 1; this->RegionType = XDMF_REGION_TYPE_UNSET; this->Values = NULL; this->ShapeDesc = new XdmfDataDesc(); this->Active = 0; } XdmfRegion::~XdmfRegion() { if( this->ValuesAreMine && this->Values ) delete this->Values; delete this->ShapeDesc; } XdmfInt32 XdmfRegion::Release(){ if( this->ValuesAreMine && this->Values ) delete this->Values; this->Values = NULL; return(XDMF_SUCCESS); } XdmfInt32 XdmfRegion::Insert( XdmfElement *Child){ if(Child && ( XDMF_WORD_CMP(Child->GetElementName(), "Attribute") || XDMF_WORD_CMP(Child->GetElementName(), "DataItem") || XDMF_WORD_CMP(Child->GetElementName(), "Information") )){ return(XdmfElement::Insert(Child)); }else{ XdmfErrorMessage("Region can only Insert Attribute, DataItem or Information elements"); } return(XDMF_FAIL); } XdmfInt32 XdmfRegion::Build(){ if(XdmfElement::Build() != XDMF_SUCCESS) return(XDMF_FAIL); this->Set("RegionType", this->GetRegionTypeAsString()); if(this->Values){ XdmfDataItem *di = NULL; XdmfXmlNode node; //! Is there already a DataItem node = this->DOM->FindDataElement(0, this->GetElement()); if(node) { di = (XdmfDataItem *)this->GetCurrentXdmfElement(node); } if(!di){ di = new XdmfDataItem; node = this->DOM->InsertNew(this->GetElement(), "DataItem"); di->SetDOM(this->DOM); di->SetElement(node); } di->SetArray(this->Values); if(this->Values->GetNumberOfElements() > 100) di->SetFormat(XDMF_FORMAT_HDF); di->Build(); } return(XDMF_SUCCESS); } XdmfConstString XdmfRegion::GetRegionTypeAsString( void ){ switch ( this->RegionType ){ case XDMF_REGION_TYPE_CELL : return( "Cell" ); case XDMF_REGION_TYPE_FACE : return( "Face" ); case XDMF_REGION_TYPE_EDGE : return( "Edge" ); case XDMF_REGION_TYPE_NODE : return( "Node" ); case XDMF_REGION_TYPE_UNSET : return( "Unset" ); default : break; } XdmfErrorMessage("Unknown RegionType = " << this->RegionType); return(0); } XdmfInt32 XdmfRegion::SetRegionTypeFromString( XdmfConstString regionType ){ if( XDMF_WORD_CMP( regionType, "Cell" ) ) { this->RegionType = XDMF_REGION_TYPE_CELL; } else if( XDMF_WORD_CMP( regionType, "Face" ) ) { this->RegionType = XDMF_REGION_TYPE_FACE; } else if( XDMF_WORD_CMP( regionType, "Edge" ) ) { this->RegionType = XDMF_REGION_TYPE_EDGE; } else if( XDMF_WORD_CMP( regionType, "Node" ) ) { this->RegionType = XDMF_REGION_TYPE_NODE; } else { XdmfErrorMessage("Unknown Region Type " << regionType ); return( XDMF_FAIL ); } return( XDMF_SUCCESS ); } XdmfInt32 XdmfRegion::SetValues(XdmfArray *someValues){ if(someValues == this->Values) return(XDMF_SUCCESS); if(this->ValuesAreMine && this->Values) delete this->Values; this->ValuesAreMine = 0; this->Values = someValues; return(XDMF_SUCCESS); } XdmfArray * XdmfRegion::GetValues(XdmfInt32 Create){ if(!this->Values && Create){ this->Values = new XdmfArray; this->ValuesAreMine = 1; } return(this->Values); } XdmfInt32 XdmfRegion::UpdateInformation() { XdmfConstString Region; if(XdmfElement::UpdateInformation() != XDMF_SUCCESS) return(XDMF_FAIL); if( XDMF_WORD_CMP(this->GetElementType(), "Region") == 0){ XdmfErrorMessage("Element type" << this->GetElementType() << " is not of type 'Region'"); return(XDMF_FAIL); } Region = this->Get( "Active" ); this->Active = 0; if ( Region ){ if( XDMF_WORD_CMP( Region, "1" ) ) { this->Active = 1; } } Region = this->Get( "RegionType" ); if( Region ){ this->SetRegionTypeFromString( Region ); } else { this->RegionType = XDMF_REGION_TYPE_NODE; } Region= this->Get( "Dimensions" ); if( Region ){ this->ShapeDesc->SetShapeFromString( Region ); }else{ XdmfXmlNode ValuesNode; ValuesNode = this->DOM->FindDataElement( 0, Element ); if(!ValuesNode){ XdmfErrorMessage("Dimensions of Region not set in XML and no DataItem found"); } Region = this->DOM->Get( ValuesNode, "Dimensions" ); if(!Region){ XdmfErrorMessage("Dimensions of Region not set in XML or DataItem"); return(XDMF_FAIL); }else{ this->ShapeDesc->SetShapeFromString( Region ); } } if(!this->Name) this->SetName(GetUnique("Region_")); return( XDMF_SUCCESS ); } XdmfInt32 XdmfRegion::Update() { XdmfInt32 Status; XdmfXmlNode ValuesNode; XdmfDataItem ValueReader; // check this out if(XdmfElement::Update() != XDMF_SUCCESS) return(XDMF_FAIL); if( this->RegionType == XDMF_REGION_TYPE_UNSET ){ Status = this->UpdateInformation(); if( Status == XDMF_FAIL ) { XdmfErrorMessage("Can't Initialize"); return( XDMF_FAIL ); } } ValuesNode = this->DOM->FindDataElement( 0, Element ); if( ValuesNode ){ ValueReader.SetDOM( this->DOM ); ValueReader.SetDsmBuffer(this->DsmBuffer); if( this->ValuesAreMine && this->Values ){ delete this->Values; this->Values = NULL; } else { } if(ValueReader.SetElement(ValuesNode) == XDMF_FAIL) return(XDMF_FAIL); if(ValueReader.UpdateInformation() == XDMF_FAIL) return(XDMF_FAIL); if(ValueReader.Update() == XDMF_FAIL) return(XDMF_FAIL); // Steal the array this->Values = ValueReader.GetArray(); ValueReader.SetArrayIsMine(0); this->ValuesAreMine = 1; if( !this->Values ) { XdmfErrorMessage("Error Retrieving Data Values"); return( XDMF_FAIL ); } } else { XdmfErrorMessage("Element has no Data"); return( XDMF_FAIL ); } return( XDMF_SUCCESS ); } xdmf-3.0+git20160803/libsrc/XdmfInformation.cxx0000640000175000017500000000545713003006557021213 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : $Id: XdmfInformation.cxx,v 1.10 2009-01-23 20:31:39 clarke Exp $ */ /* Date : $Date: 2009-01-23 20:31:39 $ */ /* Version : $Revision: 1.10 $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2002 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #include "XdmfInformation.h" XdmfInformation::XdmfInformation() { this->SetElementName("Information"); this->Value = NULL; } XdmfInformation::~XdmfInformation() { } XdmfInt32 XdmfInformation::Insert( XdmfElement *Child){ if(Child && XDMF_WORD_CMP(Child->GetElementName(), "Information")){ return(XdmfElement::Insert(Child)); }else{ XdmfErrorMessage("Information can only Insert Information elements"); } return(XDMF_FAIL); } XdmfInt32 XdmfInformation::UpdateInformation(){ XdmfConstString aValue; if(XdmfElement::UpdateInformation() != XDMF_SUCCESS) return(XDMF_FAIL); aValue = this->Get("Name"); if(aValue) this->SetName(aValue); aValue = this->Get("Value"); if(!aValue) aValue = this->Get("CDATA"); if(aValue) this->SetValue(aValue); return(XDMF_SUCCESS); } XdmfInt32 XdmfInformation::Build(){ if(XdmfElement::Build() != XDMF_SUCCESS) return(XDMF_FAIL); // If Value isn't already an XML Attribute and // the value is > 10 chars, put it in the CDATA if((this->Get("Value") == NULL) && (strlen(this->Value) > 10)){ this->Set("CDATA", this->Value); }else{ this->Set("Value", this->Value); } return(XDMF_SUCCESS); } xdmf-3.0+git20160803/libsrc/XdmfTime.cxx0000640000175000017500000003360213003006557017615 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : $Id: XdmfTime.cxx,v 1.9 2010-03-29 17:21:09 kwleiter Exp $ */ /* Date : $Date: 2010-03-29 17:21:09 $ */ /* Version : $Revision: 1.9 $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2002 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #include "XdmfTime.h" #include "XdmfDOM.h" #include "XdmfArray.h" #include "XdmfDataItem.h" #include "XdmfGrid.h" XdmfTime::XdmfTime() { this->SetElementName("Time"); this->Value = 0.0; this->Array = NULL; this->Epsilon = 1e-7; this->DataItem = new XdmfDataItem; this->TimeType = XDMF_TIME_UNSET; this->Function = NULL; } XdmfTime::~XdmfTime() { if(this->DataItem) delete this->DataItem; } XdmfInt32 XdmfTime::Insert( XdmfElement *Child){ if(Child && XDMF_WORD_CMP(Child->GetElementName(), "Time")){ return(XdmfElement::Insert(Child)); }else{ XdmfErrorMessage("Time can only Insert Time elements"); } return(XDMF_FAIL); } XdmfInt32 XdmfTime::UpdateInformation(){ XdmfConstString attribute; XdmfFloat64 dValue; if(XdmfElement::UpdateInformation() != XDMF_SUCCESS) return(XDMF_FAIL); attribute = this->Get("TimeType"); if(!attribute) attribute = this->Get("Type"); if( XDMF_WORD_CMP(attribute, "Single") ){ this->TimeType = XDMF_TIME_SINGLE; }else if( XDMF_WORD_CMP(attribute, "List") ){ this->TimeType = XDMF_TIME_LIST; }else if( XDMF_WORD_CMP(attribute, "Range") ){ this->TimeType = XDMF_TIME_RANGE; }else if( XDMF_WORD_CMP(attribute, "HyperSlab") ){ this->TimeType = XDMF_TIME_HYPERSLAB; }else if( XDMF_WORD_CMP(attribute, "Function") ){ this->TimeType = XDMF_TIME_FUNCTION; }else{ if(attribute){ XdmfErrorMessage("Unknown Time Type : " << attribute); return(XDMF_FAIL); } // Default this->TimeType = XDMF_TIME_SINGLE; } // Type == Function ? attribute = this->Get("Function"); if(attribute){ this->TimeType = XDMF_TIME_FUNCTION; this->SetFunction(attribute); return(XDMF_SUCCESS); } attribute = this->Get("Value"); if(attribute){ istrstream Value_ist(const_cast(attribute), strlen(attribute) ); Value_ist >> dValue; this->SetValue(dValue); }else{ XdmfXmlNode node; if(this->TimeType == XDMF_TIME_SINGLE){ XdmfErrorMessage("TimeType is Single but there is no Value Attribute"); return(XDMF_FAIL); } node = this->DOM->FindDataElement(0, this->GetElement()); if(!node){ XdmfErrorMessage("No Time Value is set and there is no DataItem"); return(XDMF_FAIL); } if(this->DataItem->SetDOM(this->DOM) == XDMF_FAIL) return(XDMF_FAIL); if(this->DataItem->SetElement(node) == XDMF_FAIL) return(XDMF_FAIL); if(this->DataItem->UpdateInformation() == XDMF_FAIL) return(XDMF_FAIL); if(this->DataItem->Update() == XDMF_FAIL) return(XDMF_FAIL); this->Array = this->DataItem->GetArray(); } return(XDMF_SUCCESS); } XdmfInt32 XdmfTime::Build(){ if(this->TimeType == XDMF_TIME_UNSET) return(XDMF_SUCCESS); if(XdmfElement::Build() != XDMF_SUCCESS) return(XDMF_FAIL); this->Set("TimeType", this->GetTimeTypeAsString()); if(this->TimeType == XDMF_TIME_FUNCTION){ this->Set("Function", this->Function); return(XDMF_SUCCESS); } if(this->Array){ XdmfDataItem *di = NULL; XdmfXmlNode node; XdmfDebug("Build for XdmfTime = " << this); //! Is there already a DataItem node = this->DOM->FindDataElement(0, this->GetElement()); if(node) { di = (XdmfDataItem *)this->GetCurrentXdmfElement(node); XdmfDebug("DataItem = " << di); } if(!di){ di = new XdmfDataItem; node = this->DOM->InsertNew(this->GetElement(), "DataItem"); di->SetDOM(this->DOM); di->SetElement(node); if(this->Array->GetNumberOfElements() > 100) di->SetFormat(XDMF_FORMAT_HDF); } if(this->Array != di->GetArray()){ XdmfDebug("Setting Array since " << this->Array << " != " << di->GetArray()); di->SetArray(this->Array); } XdmfDebug("Building DataItem"); di->Build(); this->SetCurrentXdmfElement(di->GetElement(), NULL); delete di; }else{ ostrstream StringOutput; StringOutput << this->Value << ends; this->Set("Value", StringOutput.str()); StringOutput.rdbuf()->freeze(0); } return(XDMF_SUCCESS); } XdmfInt32 XdmfTime::Evaluate(XdmfGrid *Grid, XdmfArray *ArrayToFill, XdmfInt32 Descend, XdmfInt32 Append){ XdmfInt64 i, n, nelements; XdmfTime *gt; if(!ArrayToFill){ XdmfErrorMessage("Array to fill is NULL"); return(XDMF_FAIL); } if(Append){ nelements = ArrayToFill->GetNumberOfElements(); }else{ ArrayToFill->SetNumberType(XDMF_FLOAT64_TYPE); nelements = 0; } gt = Grid->GetTime(); if(gt){ switch(gt->GetTimeType()){ case XDMF_TIME_SINGLE : nelements += 1; ArrayToFill->SetNumberOfElements(nelements); ArrayToFill->SetValueFromFloat64(nelements - 1, gt->GetValue()); break; case XDMF_TIME_RANGE : case XDMF_TIME_LIST : // cout << "Adding " << gt->GetArray()->GetValues() << endl; n = gt->GetArray()->GetNumberOfElements(); nelements += n; ArrayToFill->SetNumberOfElements(nelements); for(i=0 ; i < n ; i++){ ArrayToFill->SetValueFromFloat64(nelements - n + i, gt->GetArray()->GetValueAsFloat64(i)); } // cout << "Array = " << ArrayToFill->GetValues() << endl; break; case XDMF_TIME_HYPERSLAB : n = gt->GetArray()->GetValueAsInt64(2); nelements += n; ArrayToFill->SetNumberOfElements(nelements); for(i=0 ; i < n ; i++){ ArrayToFill->SetValueFromFloat64(nelements - n + i, gt->GetArray()->GetValueAsFloat64(0) + (gt->GetArray()->GetValueAsFloat64(1) * i)); } // cout << "Array = " << ArrayToFill->GetValues() << endl; break; default : if(!Descend) return(XDMF_FAIL); break; } }else{ XdmfErrorMessage("Grid has no XdmfTime"); } if(Descend){ for(i=0 ; i < Grid->GetNumberOfChildren() ; i++){ // Append children's times if(this->Evaluate(Grid->GetChild(i), ArrayToFill, Descend, 1) != XDMF_SUCCESS) return(XDMF_FAIL); } } if(this->TimeType == XDMF_TIME_RANGE) { XdmfFloat64 minval, maxval; minval = ArrayToFill->GetMinAsFloat64(); maxval = ArrayToFill->GetMaxAsFloat64(); ArrayToFill->SetNumberOfElements(2); ArrayToFill->SetValueFromFloat64(0, minval); ArrayToFill->SetValueFromFloat64(1, maxval); } return(XDMF_SUCCESS); } XdmfInt32 XdmfTime::SetTimeFromParent(XdmfTime *ParentTime, XdmfInt64 Index){ XdmfArray *TimeArray; if(!ParentTime || (Index < 0)) return(XDMF_FAIL); // this->DebugOn(); XdmfDebug("Setting Time from Type " << ParentTime->GetTimeTypeAsString() << " Index = " << Index); switch(ParentTime->GetTimeType()){ case XDMF_TIME_SINGLE: this->TimeType = XDMF_TIME_SINGLE; this->Value = ParentTime->GetValue(); XdmfDebug("Setting Time Value to " << this->Value); break; case XDMF_TIME_HYPERSLAB : TimeArray = ParentTime->GetArray(); if(!TimeArray){ XdmfErrorMessage("TimeType is HyperSlab but there is no array"); return(XDMF_FAIL); } this->TimeType = XDMF_TIME_SINGLE; this->Value = TimeArray->GetValueAsFloat64(0) + (TimeArray->GetValueAsFloat64(1) * Index); XdmfDebug("Setting Time Value to " << this->Value); break; case XDMF_TIME_LIST : TimeArray = ParentTime->GetArray(); if(!TimeArray){ XdmfErrorMessage("TimeType is List but there is no array"); return(XDMF_FAIL); } this->TimeType = XDMF_TIME_SINGLE; this->SetValue(TimeArray->GetValueAsFloat64(Index)); XdmfDebug("Setting Time Value to " << this->GetValue()); break; case XDMF_TIME_RANGE : this->TimeType = XDMF_TIME_RANGE; this->Array = ParentTime->GetArray(); break; default : XdmfErrorMessage("Unknown or Invalid TimeType"); return(XDMF_FAIL); } return(XDMF_SUCCESS); } XdmfConstString XdmfTime::GetTimeTypeAsString(void){ switch(this->TimeType){ case XDMF_TIME_UNSET: return("Unset"); case XDMF_TIME_LIST: return("List"); case XDMF_TIME_RANGE: return("Range"); case XDMF_TIME_HYPERSLAB: return("HyperSlab"); case XDMF_TIME_FUNCTION: return("Function"); default : return("Single"); } } XdmfInt32 XdmfTime::IsValid(XdmfTime *TimeSpec){ XdmfFloat64 minval, maxval; // cout << "this->TimeType = " << this->GetTimeTypeAsString() << endl; // cout << "TimeSpec->TimeType = " << TimeSpec->GetTimeTypeAsString() << endl; switch(TimeSpec->TimeType){ case XDMF_TIME_SINGLE : minval = TimeSpec->GetValue(); maxval = TimeSpec->GetValue(); break; case XDMF_TIME_LIST : if(!TimeSpec->Array){ XdmfErrorMessage("XdmfTime has no Array"); return(XDMF_FALSE); } minval = TimeSpec->Array->GetMinAsFloat64(); maxval = TimeSpec->Array->GetMaxAsFloat64(); break; case XDMF_TIME_RANGE : if(!TimeSpec->Array){ XdmfErrorMessage("XdmfTime has no Array"); return(XDMF_FALSE); } minval = TimeSpec->Array->GetValueAsFloat64(0); maxval = TimeSpec->Array->GetValueAsFloat64(1); break; case XDMF_TIME_HYPERSLAB : if(!TimeSpec->Array){ XdmfErrorMessage("XdmfTime has no Array"); return(XDMF_FALSE); } minval = TimeSpec->Array->GetValueAsFloat64(0); maxval = (TimeSpec->Array->GetValueAsFloat64(1) * (TimeSpec->Array->GetValueAsFloat64(2) - 1)); break; default : return(XDMF_FALSE); } return(this->IsValid(minval, maxval)); } XdmfInt32 XdmfTime::IsValid(XdmfFloat64 TimeMin, XdmfFloat64 TimeMax){ TimeMin -= this->Epsilon; TimeMax += this->Epsilon; switch(this->TimeType){ case XDMF_TIME_SINGLE : // cout << "TimeMin, TimeMax, this->GetValue() = " << TimeMin << "," << TimeMax << "," << this->GetValue() << endl; if((this->GetValue() >= TimeMin) && (this->GetValue() <= TimeMax)){ // cout << "Time Test Passed" << endl; return(XDMF_TRUE); }else{ // cout << "Time Test Failed" << endl; } break; case XDMF_TIME_LIST : if(!this->Array){ XdmfErrorMessage("XdmfTime has no Array"); return(XDMF_FALSE); } if((this->Array->GetMinAsFloat64() >= TimeMin) && (this->Array->GetMaxAsFloat64() <= TimeMax)) return(XDMF_TRUE); break; case XDMF_TIME_RANGE : // cout << "TimeMin, TimeMax, minmaxrange = " << TimeMin << "," << TimeMax << // "," << this->Array->GetValueAsFloat64(0) << // "," << this->Array->GetValueAsFloat64(1) << // endl; if(!this->Array){ XdmfErrorMessage("XdmfTime has no Array"); return(XDMF_FALSE); } if((this->Array->GetValueAsFloat64(0) >= TimeMin) && (this->Array->GetValueAsFloat64(1) <= TimeMax)) return(XDMF_TRUE); break; case XDMF_TIME_HYPERSLAB : if(!this->Array){ XdmfErrorMessage("XdmfTime has no Array"); return(XDMF_FALSE); } if((this->Array->GetValueAsFloat64(0) >= TimeMin) && ((this->Array->GetValueAsFloat64(1) * (this->Array->GetValueAsFloat64(2) - 1)) <= TimeMax)) return(XDMF_TRUE); break; default : return(XDMF_FALSE); } return(XDMF_FALSE); } xdmf-3.0+git20160803/libsrc/XdmfExpression.h0000640000175000017500000000346313003006557020505 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : $Id $ */ /* Date : $Date: 2009-01-23 20:31:39 $ */ /* Version : $Revision: 1.2 $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2002 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #include "XdmfArray.h" XDMF_EXPORT void XdmfArrayExpr( XdmfArray *Array, XdmfString Operation, XdmfArray *Values ); XDMF_EXPORT void XdmfScalarExpr( XdmfArray *Array, XdmfString Operation, XdmfFloat64 Value); XDMF_EXPORT XdmfArray *XdmfExpr( XdmfString Statement ); xdmf-3.0+git20160803/libsrc/XdmfDsm.h0000640000175000017500000001051213003006557017062 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : $Id: XdmfDsm.h,v 1.8 2008-04-04 19:30:21 clarke Exp $ */ /* Date : $Date: 2008-04-04 19:30:21 $ */ /* Version : $Revision: 1.8 $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2007 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #ifndef __XdmfDsm_h #define __XdmfDsm_h #include "XdmfObject.h" #define XDMF_DSM_OPCODE_DONE 0xFF //! Base comm object for Distributed Shared Memory implementation /*! */ class XdmfDsmMsg; class XdmfDsmComm; class XdmfDsm; class XdmfArray; #define XDMF_DSM_TYPE_UNIFORM 0 #define XDMF_DSM_TYPE_UNIFORM_RANGE 1 #define XDMF_DSM_TYPE_MIXED 2 #define XDMF_DSM_DEFAULT_LENGTH 10000 class XDMF_EXPORT XdmfDsm : public XdmfObject { public: XdmfDsm(); virtual ~XdmfDsm(); XdmfConstString GetClassName() { return ( "XdmfDsm" ) ; }; //! Type XdmfGetValueMacro(DsmType, XdmfInt32); XdmfSetValueMacro(DsmType, XdmfInt32); //! End Address XdmfGetValueMacro(EndAddress, XdmfInt64); XdmfSetValueMacro(EndAddress, XdmfInt64); //! Start Address XdmfGetValueMacro(StartAddress, XdmfInt64); XdmfSetValueMacro(StartAddress, XdmfInt64); //! Start Id XdmfGetValueMacro(StartServerId, XdmfInt32); XdmfSetValueMacro(StartServerId, XdmfInt32); //! End Id XdmfGetValueMacro(EndServerId, XdmfInt32); XdmfSetValueMacro(EndServerId, XdmfInt32); //! Length XdmfGetValueMacro(Length, XdmfInt64); XdmfInt32 SetLength(XdmfInt64 Length); //! totalLength XdmfGetValueMacro(TotalLength, XdmfInt64); XdmfSetValueMacro(TotalLength, XdmfInt64); //! Storage XdmfGetValueMacro(Storage, XdmfArray *); XdmfInt32 SetStorage(XdmfArray *Storage); //! Comm XdmfGetValueMacro(Comm, XdmfDsmComm *); XdmfSetValueMacro(Comm, XdmfDsmComm *); //! Msg XdmfGetValueMacro(Msg, XdmfDsmMsg *); XdmfSetValueMacro(Msg, XdmfDsmMsg *); //! Address Range XdmfInt32 GetAddressRangeForId(XdmfInt32 Id, XdmfInt64 *Start, XdmfInt64 *End); //! Configure the system. Set the Comm and ServerIds XdmfInt32 ConfigureUniform(XdmfDsmComm *Comm, XdmfInt64 Length, XdmfInt32 StartId=-1, XdmfInt32 EndId=-1); XdmfInt32 AddressToId(XdmfInt64 Address); XdmfInt32 SendCommandHeader(XdmfInt32 Opcode, XdmfInt32 Dest, XdmfInt64 Address, XdmfInt64 Length); XdmfInt32 ReceiveCommandHeader(XdmfInt32 *Opcode, XdmfInt32 *Source, XdmfInt64 *Address, XdmfInt64 *Length, XdmfInt32 Block=1); XdmfInt32 SendData(XdmfInt32 Dest, void *Data, XdmfInt64 Length); XdmfInt32 ReceiveData(XdmfInt32 Source, void *Data, XdmfInt64 Length, XdmfInt32 Block=1); virtual XdmfInt32 Copy(XdmfDsm *Source); XdmfInt32 SendDone(); protected: XdmfInt32 DsmType; XdmfInt32 StartServerId; XdmfInt32 EndServerId; XdmfInt32 StorageIsMine; XdmfInt64 StartAddress; XdmfInt64 EndAddress; XdmfInt64 Length; XdmfInt64 TotalLength; XdmfInt64 *Locks; XdmfArray *Storage; XdmfDsmComm *Comm; XdmfDsmMsg *Msg; XdmfByte *DataPointer; }; #endif // __XdmfDsm_h xdmf-3.0+git20160803/libsrc/XdmfExpr.y0000740000175000017500000005601613003006557017310 0ustar alastairalastair%{ /* Force the definition for Linux */ /* Possible bug in older Linux yacc */ #ifndef NOBISON extern int yylex(); extern "C" { void yyerror( const char *); int yyparse( void ); } #endif #include #include #include #include static XdmfArray *XdmfExprReturnValue; XdmfExprSymbol *XdmfExprItemsTable = NULL; class XdmfInt64Array : public XdmfArray { public : XdmfInt64Array( XdmfInt64 Length ) { this->SetNumberType( XDMF_INT64_TYPE ); this->SetNumberOfElements( Length ); } XdmfInt64Array() { this->SetNumberType( XDMF_INT64_TYPE ); this->SetNumberOfElements( 10 ); }; }; #define ADD_XDMF_tokARRAY_TO_SYMBOL( a ) \ { \ char name[80]; \ XdmfExprSymbol *sp; \ sprintf( name, "XdmfArray_%X", ( XdmfLength)(a) ); \ sp = XdmfExprSymbolLookup( name ); \ sp->ClientData = (a); \ } %} %union { double DoubleValue; long IntegerValue; void *ArrayPointer; XdmfExprSymbol *Symbol; } %token lFLOAT %token tokINTEGER %token tokARRAY %token NAME %token SIN COS TAN ACOS ASIN ATAN LOG EXP ABS_TOKEN SQRT WHERE INDEX %token EQEQ LT LE GT GE NE LTLT GTGT JOIN %left '-' '+' %left '*' '/' %left ',' ';' %type ScalarExpression %type ArrayExpression %% /* Comments */ statemant_list : statement { /* printf("Complete\n"); printf("XdmfExprReturnValue Nelms = %d\n", XdmfExprReturnValue->GetNumberOfElements()); */ } ; statement: tokARRAY '=' ArrayExpression { XdmfArray *TempArray = ( XdmfArray *)$3; /* printf("Setting %s from ArrayExpression\n", $1); */ XdmfExprReturnValue = (XdmfArray *)$1; *XdmfExprReturnValue = *TempArray; delete TempArray; } | tokARRAY '=' ScalarExpression { /* printf("Setting %s from ScalarExpression\n", $1); */ XdmfExprReturnValue = (XdmfArray *)$1; *XdmfExprReturnValue = $3; } | tokARRAY '[' ArrayExpression ']' '=' ScalarExpression { XdmfArray *Array1 = ( XdmfArray *)$3; XdmfArray *Result = ( XdmfArray *)$1; XdmfLength i, index, Length = Array1->GetNumberOfElements(); for( i = 0 ; i < Length ; i++ ){ index = (XdmfLength)Array1->GetValueAsFloat64( i ); Result->SetValueFromFloat64( index, $6 ); } delete Array1; XdmfExprReturnValue = Result; } | tokARRAY '[' ArrayExpression ']' '=' ArrayExpression { XdmfArray *Array1 = ( XdmfArray *)$3; XdmfArray *Array2 = ( XdmfArray *)$6; XdmfArray *Result = ( XdmfArray *)$1; XdmfFloat64 Value; XdmfLength i, index, Length = Array1->GetNumberOfElements(); for( i = 0 ; i < Length ; i++ ){ index = (XdmfLength)Array1->GetValueAsFloat64( i ); Value = Array2->GetValueAsFloat64( i ); Result->SetValueFromFloat64( index, Value ); } delete Array1; delete Array2; XdmfExprReturnValue = Result; } | tokARRAY '[' tokINTEGER ':' tokINTEGER ']' '=' ScalarExpression { XdmfArray *Range; /* printf("Array Range %d:%d = ScalarExpression \n", $3, $5); */ Range = (XdmfArray *)$1; XdmfExprReturnValue = Range->Reference( $3, $5 ); /* This is a Reference */ *XdmfExprReturnValue = $8; /* Now Point to the Entire Array */ XdmfExprReturnValue = (XdmfArray *)$1; } | tokARRAY '[' tokINTEGER ':' tokINTEGER ']' '=' ArrayExpression { XdmfArray *TempArray = ( XdmfArray *)$8; XdmfArray *Range; /* printf("Array Range %d:%d = ArrayExpression \n", $3, $5); */ Range = (XdmfArray *)$1; XdmfExprReturnValue = Range->Reference( $3, $5 ); /* This is a Reference */ *XdmfExprReturnValue = *TempArray; /* Now Point to the Entire Array */ XdmfExprReturnValue = (XdmfArray *)$1; delete TempArray; } | ArrayExpression { XdmfArray *TempArray = ( XdmfArray *)$1; /* printf("Clone from ArrayExpression\n"); */ XdmfExprReturnValue = TempArray; /* printf("XdmfExprReturnValue Nelms = %d\n", XdmfExprReturnValue->GetNumberOfElements()); */ } | ScalarExpression { printf("Pointless !! Scalar = %g\n", $1); } ; ArrayExpression: ArrayExpression '+' ArrayExpression { XdmfArray *Array1 = ( XdmfArray *)$1; XdmfArray *Array2 = ( XdmfArray *)$3; /* printf("Array 0x%X + 0x%X\n", Array1, Array2); */ *Array1 += *Array2; $$ = Array1; delete Array2; } | ArrayExpression ',' ArrayExpression { /* Interlace */ XdmfArray *Array1 = ( XdmfArray *)$1; XdmfArray *Array2 = ( XdmfArray *)$3; XdmfArray *NewArray = new XdmfArray(); XdmfInt32 i, Rank1, Rank2; XdmfInt64 NewLength, Length1, Length2, IFactor, Lcd; XdmfInt64 Dimension1[ XDMF_MAX_DIMENSION ]; XdmfInt64 Dimension2[ XDMF_MAX_DIMENSION ]; XdmfInt64 Start[ XDMF_MAX_DIMENSION ]; XdmfInt64 Stride[ XDMF_MAX_DIMENSION ]; XdmfInt64 Count[ XDMF_MAX_DIMENSION ]; XdmfInt64 NewDimension[ XDMF_MAX_DIMENSION ]; /* printf("Array 0x%X , 0x%X\n", Array1, Array2); */ Rank1 = Array1->GetShape( Dimension1 ); Rank2 = Array2->GetShape( Dimension2 ); if( Rank1 != Rank2 ){ printf(" Interlace : Rank Mismatch !!\n"); } NewArray->CopyType( Array1 ); Length1 = Array1->GetNumberOfElements(); Length2 = Array2->GetNumberOfElements(); NewLength = Length1 + Length2; IFactor = Length1 / Length2; Lcd = Length1; if( Length2 < Length1 ){ Lcd = Length2; } NewDimension[0] = Lcd; NewDimension[1] = NewLength / Lcd; NewArray->SetShape( 2, NewDimension ); /* printf("Rank1 = %d Rank2 = %d\n", Rank1, Rank2 ); printf("Array1 Size = %d\n", Array1->GetNumberOfElements() ); printf("Array2 Size = %d\n", Array2->GetNumberOfElements() ); printf("NewLength = %d\n", NewLength ); printf("Lcd = %d\n", Lcd ); printf("IFactor = %d\n", IFactor ); printf("New Dims = %s\n", NewArray->GetShapeAsString() ); */ /* NewArray->Generate( -55.0, -55.0 ); */ /* Copy in Array 1 */ Start[0] = 0; Start[1] = 0; Stride[0] = 1; Stride[1] = 1; Count[0] = Lcd; Count[1] = Length1 / Lcd; NewArray->SelectHyperSlab( Start, Stride, Count ); Array1->SelectAll(); /* printf("Copy in Array1 = %s\n", NewArray->GetHyperSlabAsString() ); */ CopyArray( Array1, NewArray ); /* Copy in Array 2 */ Start[0] = 0; Start[1] = Length1 / Lcd; Stride[0] = 1; Stride[1] = 1; Count[0] = Lcd; Count[1] = Length2 / Lcd; NewArray->SelectHyperSlab( Start, Stride, Count ); Array2->SelectAll(); /* printf("Copy in Array2 = %s\n", NewArray->GetHyperSlabAsString() ); */ CopyArray( Array2, NewArray ); NewDimension[0] = Dimension1[0] + Dimension2[0]; for( i = 1 ; i < Rank1 ; i++ ){ NewDimension[i] = Dimension1[i]; } NewArray->Reform( Rank1, NewDimension ); /* printf("Result(%s) = %s\n", NewArray->GetShapeAsString(), NewArray->GetValues() ); */ $$ = NewArray; delete Array1; delete Array2; } | ArrayExpression ';' ArrayExpression { /* Interlace */ XdmfArray *Array1 = ( XdmfArray *)$1; XdmfArray *Array2 = ( XdmfArray *)$3; XdmfArray *NewArray = new XdmfArray(); XdmfInt32 i, Rank1, Rank2; XdmfInt64 Dimension1[ XDMF_MAX_DIMENSION ]; XdmfInt64 Dimension2[ XDMF_MAX_DIMENSION ]; XdmfInt64 Start[ XDMF_MAX_DIMENSION ]; XdmfInt64 Stride[ XDMF_MAX_DIMENSION ]; XdmfInt64 Count[ XDMF_MAX_DIMENSION ]; XdmfInt64 NewDimension[ XDMF_MAX_DIMENSION ]; /* printf("Array 0x%X << 0x%X\n", Array1, Array2); */ Rank1 = Array1->GetShape( Dimension1 ); Rank2 = Array2->GetShape( Dimension2 ); if( Rank1 != Rank2 ){ printf(" Cat : Rank Mismatch !!\n"); } NewDimension[0] = Dimension1[0] + Dimension2[0]; for( i = 1 ; i < Rank1 ; i++ ){ NewDimension[i] = Dimension1[i]; } NewArray->CopyType( Array1 ); NewArray->SetShape( Rank1, NewDimension ); /* NewArray->Generate( -55.0, -55.0 ); */ /* Copy in Array 1 */ for( i = 0 ; i < Rank1 ; i++ ){ Start[i] = 0; Stride[i] = 1; Count[i] = Dimension1[i]; } NewArray->SelectHyperSlab( Start, Stride, Count ); Array1->SelectAll(); /* printf("Copy in Array1 = %s\n", NewArray->GetHyperSlabAsString() ); */ CopyArray( Array1, NewArray ); /* Copy in Array 2 */ Start[0] = Dimension1[0]; Stride[0] = 1; Count[0] = Dimension2[0]; for( i = 1 ; i < Rank1 ; i++ ){ Start[i] = 0; Stride[i] = 1; Count[i] = Dimension1[i]; } NewArray->SelectHyperSlab( Start, Stride, Count ); Array2->SelectAll(); /* printf("Copy in Array2 = %s\n", NewArray->GetHyperSlabAsString() ); */ CopyArray( Array2, NewArray ); /* printf("Result(%s) = %s\n", NewArray->GetShapeAsString(), NewArray->GetValues() ); */ $$ = NewArray; delete Array1; delete Array2; } | ArrayExpression '-' ArrayExpression { XdmfArray *Array1 = ( XdmfArray *)$1; XdmfArray *Array2 = ( XdmfArray *)$3; /* printf("Array 0x%X + 0x%X\n", Array1, Array2); */ *Array1 -= *Array2; $$ = Array1; delete Array2; } | ArrayExpression '*' ArrayExpression { XdmfArray *Array1 = ( XdmfArray *)$1; XdmfArray *Array2 = ( XdmfArray *)$3; /* printf("Array 0x%X * 0x%X\n", Array1, Array2); */ *Array1 *= *Array2; $$ = Array1; delete Array2; /* printf("Array1 Nelms = %d\n", Array1->GetNumberOfElements()); */ } | ArrayExpression '/' ArrayExpression { XdmfArray *Array1 = ( XdmfArray *)$1; XdmfArray *Array2 = ( XdmfArray *)$3; /* printf("Array 0x%X + 0x%X\n", Array1, Array2); */ *Array1 /= *Array2; $$ = Array1; delete Array2; } | ArrayExpression '+' ScalarExpression { XdmfArray *Array1 = ( XdmfArray *)$1; XdmfArray *Result; /* printf("Array + %g\n", $3); */ Result = Array1; *Result += $3; $$ = Result; } | ArrayExpression '-' ScalarExpression { XdmfArray *Array1 = ( XdmfArray *)$1; XdmfArray *Result; /* printf("Array - %g\n", $3); */ Result = Array1; *Result -= $3; $$ = Result; } | ArrayExpression '*' ScalarExpression { XdmfArray *Array1 = ( XdmfArray *)$1; XdmfArray *Result; /* printf("Array * %g\n", $3); */ Result = Array1; *Result *= $3; $$ = Result; } | ArrayExpression '/' ScalarExpression { XdmfArray *Array1 = ( XdmfArray *)$1; XdmfArray *Result; /* printf("Array / %g\n", $3); */ Result = Array1; *Result /= $3; $$ = Result; } | ScalarExpression '+' ArrayExpression { XdmfArray *Array1 = ( XdmfArray *)$3; XdmfArray *Result; /* printf("Array + %g\n", $1); */ Result = Array1; *Result += $1; $$ = Result; } | ScalarExpression '-' ArrayExpression { XdmfArray *Array1 = ( XdmfArray *)$3; XdmfArray *Result; /* printf("Array - %g\n", $1); */ Result = Array1; *Result -= $1; $$ = Result; } | ScalarExpression '*' ArrayExpression { XdmfArray *Array1 = ( XdmfArray *)$3; XdmfArray *Result; /* printf("Array * %g\n", $1); */ Result = Array1; *Result *= $1; $$ = Result; } | ScalarExpression '/' ArrayExpression { XdmfArray *Array1 = ( XdmfArray *)$3; XdmfArray *Result; /* printf("Array / %g\n", $1); */ Result = Array1; *Result /= $1; $$ = Result; } | tokARRAY '[' ArrayExpression ']' { XdmfArray *Array1 = ( XdmfArray *)$1; XdmfArray *Array2 = ( XdmfArray *)$3; XdmfArray *Result; /* printf("ArrayExpression From Indexes\n"); */ Result = Array1->Clone( Array2 ); delete Array2; $$ = Result; } | tokARRAY '[' tokINTEGER ':' tokINTEGER ']' { XdmfArray *Array1 = ( XdmfArray *)$1; XdmfArray *Range, *Result; /* printf("ArrayExpression From Array Range %d:%d\n", $3, $5); */ Range = Array1->Reference( $3, $5 ); /* This not a copy */ Result = Range->Clone(); /* So Copy It */ /* This is a passed in array ... don't delete delete Array1; */ $$ = Result; } | INDEX'(' ArrayExpression EQEQ ArrayExpression ')' { XdmfArray *Array1 = ( XdmfArray *)$3; XdmfArray *Array2 = ( XdmfArray *)$5; XdmfLength i, howmany = 0, cntr = 0; XdmfLength Length1 = Array1->GetNumberOfElements(), Length2; XdmfInt64Array *Index = new XdmfInt64Array( Length1 ); XdmfInt64 A1Value, A2Value; XdmfInt64 *A1Values, *A2Values; float Percent; if(Array1->GetNumberType() != XDMF_INT64_TYPE){ yyerror("INDEX operator only uses XdmfInt64 Arrays"); return( 0 ); } if(Array2->GetNumberType() != XDMF_INT64_TYPE){ yyerror("INDEX operator only uses XdmfInt64 Arrays"); return( 0 ); } Length2 = Array2->GetNumberOfElements(); A1Values = (XdmfInt64 *)Array1->GetDataPointer(); A2Values = (XdmfInt64 *)Array2->GetDataPointer(); for( i = 0 ; i < Length1 ; i++ ){ /* A1Value = Array1->GetValueAsFloat64( i ); */ A1Value = *A1Values++; cntr = 0; A2Value = A1Value + 1; while((cntr < Length2) && (A2Value != A1Value)) { /* A2Value = Array2->GetValueAsFloat64(cntr); */ A2Value = A2Values[cntr]; cntr++; } howmany++; if(howmany > 5000){ Percent = 100.0 * i / Length1; printf("%5.2f %% Done\n", Percent); howmany = 0; } if( A1Value == A2Value ) { Index->SetValue( i, cntr - 1 ); }else{ Index->SetValue( i, -1); } } $$ = ( XdmfArray *)Index; } | WHERE '(' ArrayExpression EQEQ ArrayExpression ')' { XdmfArray *Array1 = ( XdmfArray *)$3; /* XdmfLength howmany = 0; */ XdmfLength i, cntr = 0; XdmfLength Length1 = Array1->GetNumberOfElements(), Length2; XdmfInt64Array *Index = new XdmfInt64Array( Length1 ); XdmfArray *Array2 = ( XdmfArray *)$5; XdmfFloat64 A1Value, A2Value; Length2 = Array2->GetNumberOfElements(); for( i = 0 ; i < Length1 ; i++ ){ A1Value = Array1->GetValueAsFloat64( i ); cntr = 0; A2Value = A1Value + 1; while((cntr < Length2) && (A2Value != A1Value)) { A2Value = Array2->GetValueAsFloat64(cntr); cntr++; } /* howmany++; if(howmany > 1000){ cout << "Checked " << i << " of " << Length1 << endl; howmany = 0; } */ if( A1Value == A2Value ) { Index->SetValue( i, cntr - 1 ); }else{ Index->SetValue( i, -1); } } $$ = ( XdmfArray *)Index; } | WHERE '(' ArrayExpression EQEQ ScalarExpression ')' { XdmfArray *Array1 = ( XdmfArray *)$3; XdmfLength i, cntr = 0; XdmfLength Length = Array1->GetNumberOfElements(); XdmfInt64Array *Index = new XdmfInt64Array( Length ); XdmfFloat64 Value, SValue = $5; for( i = 0 ; i < Length ; i++ ){ Value = Array1->GetValueAsFloat64( i ); if( Value == SValue ) { Index->SetValue( cntr++, i ); } } /* printf("Found %d Wheres\n", cntr ); */ if( cntr == 0 ){ yyerror("WHERE Function Length == 0"); return( 0 ); } Index->SetNumberOfElements( cntr ); $$ = ( XdmfArray *)Index; } | WHERE '(' ArrayExpression LT ScalarExpression ')' { XdmfArray *Array1 = ( XdmfArray *)$3; XdmfLength i, cntr = 0; XdmfLength Length = Array1->GetNumberOfElements(); XdmfInt64Array *Index = new XdmfInt64Array( Length ); XdmfFloat64 Value, SValue = $5; for( i = 0 ; i < Length ; i++ ){ Value = Array1->GetValueAsFloat64( i ); if( Value < SValue ) { Index->SetValue( cntr++, i ); } } /* printf("Found %d Wheres\n", cntr ); */ if( cntr == 0 ){ yyerror("WHERE Function Length == 0"); return( 0 ); } Index->SetNumberOfElements( cntr ); $$ = ( XdmfArray *)Index; } | WHERE '(' ArrayExpression LE ScalarExpression ')' { XdmfArray *Array1 = ( XdmfArray *)$3; XdmfLength i, cntr = 0; XdmfLength Length = Array1->GetNumberOfElements(); XdmfInt64Array *Index = new XdmfInt64Array( Length ); XdmfFloat64 Value, SValue = $5; for( i = 0 ; i < Length ; i++ ){ Value = Array1->GetValueAsFloat64( i ); if( Value <= SValue ) { Index->SetValue( cntr++, i ); } } /* printf("Found %d Wheres\n", cntr ); */ if( cntr == 0 ){ yyerror("WHERE Function Length == 0"); return( 0 ); } Index->SetNumberOfElements( cntr ); $$ = ( XdmfArray *)Index; } | WHERE '(' ArrayExpression GT ScalarExpression ')' { XdmfArray *Array1 = ( XdmfArray *)$3; XdmfLength i, cntr = 0; XdmfLength Length = Array1->GetNumberOfElements(); XdmfInt64Array *Index = new XdmfInt64Array( Length ); XdmfFloat64 Value, SValue = $5; for( i = 0 ; i < Length ; i++ ){ Value = Array1->GetValueAsFloat64( i ); if( Value > SValue ) { Index->SetValue( cntr++, i ); } } /* printf("Found %d Wheres\n", cntr ); */ if( cntr == 0 ){ yyerror("WHERE Function Length == 0"); return( 0 ); } Index->SetNumberOfElements( cntr ); $$ = ( XdmfArray *)Index; } | WHERE '(' ArrayExpression GE ScalarExpression ')' { XdmfArray *Array1 = ( XdmfArray *)$3; XdmfLength i, cntr = 0; XdmfLength Length = Array1->GetNumberOfElements(); XdmfInt64Array *Index = new XdmfInt64Array( Length ); XdmfFloat64 Value, SValue = $5; for( i = 0 ; i < Length ; i++ ){ Value = Array1->GetValueAsFloat64( i ); if( Value >= SValue ) { Index->SetValue( cntr++, i ); } } /* printf("Found %d Wheres\n", cntr ); */ if( cntr == 0 ){ yyerror("WHERE Function Length == 0"); return( 0 ); } Index->SetNumberOfElements( cntr ); $$ = ( XdmfArray *)Index; } | WHERE '(' ArrayExpression NE ScalarExpression ')' { XdmfArray *Array1 = ( XdmfArray *)$3; XdmfLength i, cntr = 0; XdmfLength Length = Array1->GetNumberOfElements(); XdmfInt64Array *Index = new XdmfInt64Array( Length ); XdmfFloat64 Value, SValue = $5; for( i = 0 ; i < Length ; i++ ){ Value = Array1->GetValueAsFloat64( i ); if( Value != SValue ) { Index->SetValue( cntr++, i ); } } /* printf("Found %d Wheres\n", cntr ); */ if( cntr == 0 ){ yyerror("WHERE Function Length == 0"); return( 0 ); } Index->SetNumberOfElements( cntr ); $$ = ( XdmfArray *)Index; } | NAME '(' ArrayExpression ')' { if( $1->DoubleFunctionPtr == NULL ){ /* printf("Bad Function Ptr for %s\n", $1->Name ); */ $$ = $3; } else { XdmfArray *Array1 = ( XdmfArray *)$3; XdmfFloat64 Value; XdmfLength i, Length = Array1->GetNumberOfElements(); /* printf("Function Call %s\n", $1->Name ); */ for( i = 0 ; i < Length ; i++ ){ Value = Array1->GetValueAsFloat64( i ); Array1->SetValueFromFloat64( i, ($1->DoubleFunctionPtr)( Value ) ); } $$ = Array1; } } | '(' ArrayExpression ')' { /* printf("( ArrayExpression )\n"); */ $$ = $2; } | JOIN '(' ArrayExpression ')' { /* printf("( ArrayExpression )\n"); */ $$ = $3; } | tokARRAY { XdmfArray *Array1 = ( XdmfArray *)$1; XdmfArray *Result; /* printf("ArrayExpression From Array\n"); */ if ( Array1 == NULL ){ /* Bomb */ yyerror("NULL Array Pointer"); return( 0 ); } else { Result = Array1->Clone(); $$ = Result; } } ; ScalarExpression: ScalarExpression '+' ScalarExpression { /* printf("Scalar +\n"); */ $$ = $1 + $3; } | ScalarExpression '-' ScalarExpression { /* printf("Scalar -\n"); */ $$ = $1 - $3; } | ScalarExpression '*' ScalarExpression { /* printf("Scalar *\n"); */ $$ = $1 * $3; } | ScalarExpression '/' ScalarExpression { /* printf("Scalar /\n"); */ $$ = $1 / $3; } | NAME '(' ScalarExpression ')' { if( $1->DoubleFunctionPtr == NULL ){ /* printf("Bad Function Ptr for %s\n", $1->Name ); */ $$ = 0.0; } else { $$ = ($1->DoubleFunctionPtr)( $3 ); } } | '(' ScalarExpression ')' { /* printf ("( ScalarExpression )\n"); */ $$ = $2; } | tokINTEGER { /* printf ("ScalarExpression from tokINTEGER\n"); */ $$ = $1; } | lFLOAT { /* printf ("ScalarExpression from FLOAT\n"); */ $$ = $1; } ; %% /* extern FILE *yyin, *yyout; */ #ifdef __cplusplus /**/ extern "C" { /**/ #endif char InputBuffer[ 512 ]; size_t InputBufferPtr = 0, InputBufferEnd = 0; char OutputBuffer[ 512 ]; size_t OutputBufferPtr = 0; /* static int OutputBufferEnd = 511; */ int dice_yywrap( void ) { return 1; } void dice_yyerror( const char *string ) { fprintf(stderr, "XdmfExpr : %s \n", string); } int XdmfExprFlexInput( char *buf, int maxlen ) { (void)maxlen; if ( InputBufferPtr < InputBufferEnd ){ buf[0] = InputBuffer[ InputBufferPtr++ ]; return(1); } else { buf[0] = '\n'; return( 0 ); } } int XdmfExprInput( void ){ if ( InputBufferPtr < InputBufferEnd ){ return( InputBuffer[ InputBufferPtr++ ] ); } else { return '\n'; } } void XdmfExprUnput( int c ) { if( InputBufferPtr > 0 ){ InputBufferPtr--; InputBuffer[ InputBufferPtr ] = c; } } void XdmfExprOutput( int c ) { /* printf("XdmfExprOutput Called\n"); */ OutputBuffer[ OutputBufferPtr++ ] = c; OutputBuffer[ OutputBufferPtr ] = '\0'; } XdmfExprSymbol *XdmfExprSymbolLookup( const char *Name ){ XdmfExprSymbol *Last = NULL, *Item = XdmfExprItemsTable; if( Name == NULL ) { /* Table Check */ return( XdmfExprItemsTable ); } while( Item != NULL ) { if( strcmp( Item->Name, Name ) == 0 ) { /* printf("Found Symbol %s\n", Name ); */ return( Item ); } Last = Item; Item = Item->Next; } /* Not Found : Create New One */ Item = ( XdmfExprSymbol *)calloc( 1, sizeof( XdmfExprSymbol )); Item->Next = NULL; Item->Name = strdup( Name ); Item->ClientData = NULL; Item->DoubleValue = 0; Item->DoubleFunctionPtr = NULL; if( XdmfExprItemsTable == NULL ) { XdmfExprItemsTable = Item; } if( Last != NULL ){ Last->Next = Item; } /* printf("New Symbol for %s\n", Name ); */ return( Item ); } #ifdef __cplusplus /**/ } /**/ #endif XdmfArray * XdmfExprParse( char *string ){ XdmfExprSymbol *Item; XdmfLength CurrentTime; XdmfLength TimeOfCreation; XdmfArray *ap; /* Build the Symbol Table if Necessary */ Item = XdmfExprSymbolLookup( NULL ); if( Item == NULL ){ /* printf("Creating Symbol Table\n"); */ Item = XdmfExprSymbolLookup( "cos" ); Item->DoubleFunctionPtr = cos; Item = XdmfExprSymbolLookup( "sin" ); Item->DoubleFunctionPtr = sin; Item = XdmfExprSymbolLookup( "exp" ); Item->DoubleFunctionPtr = exp; Item = XdmfExprSymbolLookup( "tan" ); Item->DoubleFunctionPtr = tan; Item = XdmfExprSymbolLookup( "acos" ); Item->DoubleFunctionPtr = acos; Item = XdmfExprSymbolLookup( "asin" ); Item->DoubleFunctionPtr = asin; Item = XdmfExprSymbolLookup( "atan" ); Item->DoubleFunctionPtr = atan; Item = XdmfExprSymbolLookup( "log" ); Item->DoubleFunctionPtr = log; Item = XdmfExprSymbolLookup( "sqrt" ); Item->DoubleFunctionPtr = sqrt; } /* Print Symbol Table */ Item = XdmfExprSymbolLookup( NULL ); while( Item != NULL ) { if( Item->ClientData != NULL ){ /* printf("Found Symbol %s\n", Item->Name ); */ } Item = Item->Next; } strcpy( InputBuffer, string ); InputBufferEnd = strlen( InputBuffer ); InputBufferPtr = OutputBufferPtr = 0; XdmfExprReturnValue = NULL; /* printf("XdmfExprParse Scanning <%s>\n", InputBuffer); */ CurrentTime = GetCurrentArrayTime(); if ( yyparse() != 0 ){ /* Error */ XdmfExprReturnValue = NULL; } Item = XdmfExprSymbolLookup( NULL ); while( Item != NULL ) { XdmfExprSymbol *next = Item->Next; if ( Item->Name ) { free(Item->Name); } free(Item); Item = next; } XdmfExprItemsTable = NULL; /* Remove All Arrays Older than when we started */ /* printf("Cleaning up Temparary Arrays\n"); */ while( ( ap = GetNextOlderArray( CurrentTime, &TimeOfCreation ) ) != NULL ){ /* Don't remove the return value */ if( ap != XdmfExprReturnValue ){ /* printf("Removing Temporary Array\n"); */ delete ap; } CurrentTime = TimeOfCreation; } return( XdmfExprReturnValue ); } xdmf-3.0+git20160803/libsrc/Xdmf.py0000640000175000017500000025173313003006557016633 0ustar alastairalastair# This file was automatically generated by SWIG (http://www.swig.org). # Version 1.3.37 # # Do not make changes to this file unless you know what you are doing--modify # the SWIG interface file instead. # This file is compatible with both classic and new-style classes. from sys import version_info if version_info >= (2,6,0): def swig_import_helper(): from os.path import dirname import imp try: fp, pathname, description = imp.find_module('_Xdmf', [dirname(__file__)]) _mod = imp.load_module('_Xdmf', fp, pathname, description) finally: if fp is not None: fp.close() return _mod _Xdmf = swig_import_helper() del swig_import_helper else: import _Xdmf del version_info try: _swig_property = property except NameError: pass # Python < 2.2 doesn't have 'property'. def _swig_setattr_nondynamic(self,class_type,name,value,static=1): if (name == "thisown"): return self.this.own(value) if (name == "this"): if type(value).__name__ == 'SwigPyObject': self.__dict__[name] = value return method = class_type.__swig_setmethods__.get(name,None) if method: return method(self,value) if (not static) or hasattr(self,name): self.__dict__[name] = value else: raise AttributeError("You cannot add attributes to %s" % self) def _swig_setattr(self,class_type,name,value): return _swig_setattr_nondynamic(self,class_type,name,value,0) def _swig_getattr(self,class_type,name): if (name == "thisown"): return self.this.own() method = class_type.__swig_getmethods__.get(name,None) if method: return method(self) raise AttributeError(name) def _swig_repr(self): try: strthis = "proxy of " + self.this.__repr__() except: strthis = "" return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) try: _object = object _newclass = 1 except AttributeError: class _object : pass _newclass = 0 _FILE_OFFSET_BITS = _Xdmf._FILE_OFFSET_BITS SIZEOF_LONG_LONG = _Xdmf.SIZEOF_LONG_LONG XDMF_VERSION = _Xdmf.XDMF_VERSION XDMF_VERSION_STRING = _Xdmf.XDMF_VERSION_STRING XDMF_SUCCESS = _Xdmf.XDMF_SUCCESS XDMF_FAIL = _Xdmf.XDMF_FAIL XDMF_TRUE = _Xdmf.XDMF_TRUE XDMF_FALSE = _Xdmf.XDMF_FALSE XDMF_MAX_DIMENSION = _Xdmf.XDMF_MAX_DIMENSION XDMF_MAX_STRING_LENGTH = _Xdmf.XDMF_MAX_STRING_LENGTH XDMF_DEFAULT_INDEX = _Xdmf.XDMF_DEFAULT_INDEX XDMF_SELECT_SLAB = _Xdmf.XDMF_SELECT_SLAB XDMF_SELECT_INDEX = _Xdmf.XDMF_SELECT_INDEX XDMF_UNKNOWN_TYPE = _Xdmf.XDMF_UNKNOWN_TYPE XDMF_INT8_TYPE = _Xdmf.XDMF_INT8_TYPE XDMF_INT16_TYPE = _Xdmf.XDMF_INT16_TYPE XDMF_INT32_TYPE = _Xdmf.XDMF_INT32_TYPE XDMF_INT64_TYPE = _Xdmf.XDMF_INT64_TYPE XDMF_FLOAT32_TYPE = _Xdmf.XDMF_FLOAT32_TYPE XDMF_FLOAT64_TYPE = _Xdmf.XDMF_FLOAT64_TYPE XDMF_UINT8_TYPE = _Xdmf.XDMF_UINT8_TYPE XDMF_UINT16_TYPE = _Xdmf.XDMF_UINT16_TYPE XDMF_UINT32_TYPE = _Xdmf.XDMF_UINT32_TYPE XDMF_COMPOUND_TYPE = _Xdmf.XDMF_COMPOUND_TYPE class XdmfObject(_object): __swig_setmethods__ = {} __setattr__ = lambda self, name, value: _swig_setattr(self, XdmfObject, name, value) __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, XdmfObject, name) __repr__ = _swig_repr def __init__(self): this = _Xdmf.new_XdmfObject() try: self.this.append(this) except: self.this = this __swig_destroy__ = _Xdmf.delete_XdmfObject __del__ = lambda self : None; def GetClassName(self): return _Xdmf.XdmfObject_GetClassName(self) def SetDebug(self, *args): return _Xdmf.XdmfObject_SetDebug(self, *args) def GetDebug(self): return _Xdmf.XdmfObject_GetDebug(self) def GetGlobalDebug(self): return _Xdmf.XdmfObject_GetGlobalDebug(self) def SetGlobalDebug(self, *args): return _Xdmf.XdmfObject_SetGlobalDebug(self, *args) def DebugOn(self): return _Xdmf.XdmfObject_DebugOn(self) def DebugOff(self): return _Xdmf.XdmfObject_DebugOff(self) def GlobalDebugOn(self): return _Xdmf.XdmfObject_GlobalDebugOn(self) def GlobalDebugOff(self): return _Xdmf.XdmfObject_GlobalDebugOff(self) def GetUniqueName(self, NameBase = None): return _Xdmf.XdmfObject_GetUniqueName(self, NameBase) XdmfObject_swigregister = _Xdmf.XdmfObject_swigregister XdmfObject_swigregister(XdmfObject) def SetGlobalDebugOn(): return _Xdmf.SetGlobalDebugOn() SetGlobalDebugOn = _Xdmf.SetGlobalDebugOn def SetGlobalDebugOff(): return _Xdmf.SetGlobalDebugOff() SetGlobalDebugOff = _Xdmf.SetGlobalDebugOff def GetGlobalDebug(): return _Xdmf.GetGlobalDebug() GetGlobalDebug = _Xdmf.GetGlobalDebug def SetGlobalDebug(*args): return _Xdmf.SetGlobalDebug(*args) SetGlobalDebug = _Xdmf.SetGlobalDebug def XdmfObjectToHandle(*args): return _Xdmf.XdmfObjectToHandle(*args) XdmfObjectToHandle = _Xdmf.XdmfObjectToHandle def HandleToXdmfObject(*args): return _Xdmf.HandleToXdmfObject(*args) HandleToXdmfObject = _Xdmf.HandleToXdmfObject def VoidPointerHandleToXdmfPointer(*args): return _Xdmf.VoidPointerHandleToXdmfPointer(*args) VoidPointerHandleToXdmfPointer = _Xdmf.VoidPointerHandleToXdmfPointer class XdmfLightData(XdmfObject): __swig_setmethods__ = {} for _s in [XdmfObject]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) __setattr__ = lambda self, name, value: _swig_setattr(self, XdmfLightData, name, value) __swig_getmethods__ = {} for _s in [XdmfObject]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) __getattr__ = lambda self, name: _swig_getattr(self, XdmfLightData, name) __repr__ = _swig_repr def __init__(self): this = _Xdmf.new_XdmfLightData() try: self.this.append(this) except: self.this = this __swig_destroy__ = _Xdmf.delete_XdmfLightData __del__ = lambda self : None; def GetClassName(self): return _Xdmf.XdmfLightData_GetClassName(self) def SetName(self, *args): return _Xdmf.XdmfLightData_SetName(self, *args) def GetName(self): return _Xdmf.XdmfLightData_GetName(self) def SetFileName(self, *args): return _Xdmf.XdmfLightData_SetFileName(self, *args) def GetFileName(self): return _Xdmf.XdmfLightData_GetFileName(self) def SetWorkingDirectory(self, *args): return _Xdmf.XdmfLightData_SetWorkingDirectory(self, *args) def GetWorkingDirectory(self): return _Xdmf.XdmfLightData_GetWorkingDirectory(self) def GetInitialized(self): return _Xdmf.XdmfLightData_GetInitialized(self) def SetInitialized(self, *args): return _Xdmf.XdmfLightData_SetInitialized(self, *args) def GetReturnBuffer(self): return _Xdmf.XdmfLightData_GetReturnBuffer(self) XdmfLightData_swigregister = _Xdmf.XdmfLightData_swigregister XdmfLightData_swigregister(XdmfLightData) def GetUnique(Pattern = None): return _Xdmf.GetUnique(Pattern) GetUnique = _Xdmf.GetUnique XDMF_ELEMENT_STATE_UNINITIALIZED = _Xdmf.XDMF_ELEMENT_STATE_UNINITIALIZED XDMF_ELEMENT_STATE_LIGHT_PARSED = _Xdmf.XDMF_ELEMENT_STATE_LIGHT_PARSED XDMF_ELEMENT_STATE_HEAVY_READ = _Xdmf.XDMF_ELEMENT_STATE_HEAVY_READ class XdmfElement(XdmfLightData): __swig_setmethods__ = {} for _s in [XdmfLightData]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) __setattr__ = lambda self, name, value: _swig_setattr(self, XdmfElement, name, value) __swig_getmethods__ = {} for _s in [XdmfLightData]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) __getattr__ = lambda self, name: _swig_getattr(self, XdmfElement, name) __repr__ = _swig_repr def __init__(self): this = _Xdmf.new_XdmfElement() try: self.this.append(this) except: self.this = this __swig_destroy__ = _Xdmf.delete_XdmfElement __del__ = lambda self : None; def GetClassName(self): return _Xdmf.XdmfElement_GetClassName(self) def SetDOM(self, *args): return _Xdmf.XdmfElement_SetDOM(self, *args) def GetDOM(self): return _Xdmf.XdmfElement_GetDOM(self) def SetState(self, *args): return _Xdmf.XdmfElement_SetState(self, *args) def GetState(self): return _Xdmf.XdmfElement_GetState(self) def SetIsReference(self, *args): return _Xdmf.XdmfElement_SetIsReference(self, *args) def GetIsReference(self): return _Xdmf.XdmfElement_GetIsReference(self) def CheckForReference(self, *args): return _Xdmf.XdmfElement_CheckForReference(self, *args) def InsertChildElement(self, *args): return _Xdmf.XdmfElement_InsertChildElement(self, *args) def Serialize(self): return _Xdmf.XdmfElement_Serialize(self) def SetElement(self, *args): return _Xdmf.XdmfElement_SetElement(self, *args) def GetElement(self): return _Xdmf.XdmfElement_GetElement(self) def SetCopyReferenceData(self, *args): return _Xdmf.XdmfElement_SetCopyReferenceData(self, *args) def GetCopyReferenceData(self): return _Xdmf.XdmfElement_GetCopyReferenceData(self) def GetElementName(self): return _Xdmf.XdmfElement_GetElementName(self) def SetElementName(self, *args): return _Xdmf.XdmfElement_SetElementName(self, *args) def GetDataXml(self): return _Xdmf.XdmfElement_GetDataXml(self) def SetDataXml(self, *args): return _Xdmf.XdmfElement_SetDataXml(self, *args) def GetInsertedDataXml(self): return _Xdmf.XdmfElement_GetInsertedDataXml(self) def SetInsertedDataXml(self, *args): return _Xdmf.XdmfElement_SetInsertedDataXml(self, *args) def BuildFromDataXml(self, AllowCData = 0): return _Xdmf.XdmfElement_BuildFromDataXml(self, AllowCData) def GetElementType(self): return _Xdmf.XdmfElement_GetElementType(self) def UpdateInformation(self): return _Xdmf.XdmfElement_UpdateInformation(self) def Update(self): return _Xdmf.XdmfElement_Update(self) def Build(self): return _Xdmf.XdmfElement_Build(self) def Set(self, *args): return _Xdmf.XdmfElement_Set(self, *args) def Get(self, *args): return _Xdmf.XdmfElement_Get(self, *args) def Copy(self, *args): return _Xdmf.XdmfElement_Copy(self, *args) def Insert(self, Child = None): return _Xdmf.XdmfElement_Insert(self, Child) def FollowReference(self, *args): return _Xdmf.XdmfElement_FollowReference(self, *args) def GetDsmBuffer(self): return _Xdmf.XdmfElement_GetDsmBuffer(self) def SetDsmBuffer(self, *args): return _Xdmf.XdmfElement_SetDsmBuffer(self, *args) def SetDeleteOnGridDelete(self, *args): return _Xdmf.XdmfElement_SetDeleteOnGridDelete(self, *args) def GetDeleteOnGridDelete(self): return _Xdmf.XdmfElement_GetDeleteOnGridDelete(self) XdmfElement_swigregister = _Xdmf.XdmfElement_swigregister XdmfElement_swigregister(XdmfElement) class XdmfElementData(XdmfObject): __swig_setmethods__ = {} for _s in [XdmfObject]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) __setattr__ = lambda self, name, value: _swig_setattr(self, XdmfElementData, name, value) __swig_getmethods__ = {} for _s in [XdmfObject]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) __getattr__ = lambda self, name: _swig_getattr(self, XdmfElementData, name) __repr__ = _swig_repr def __init__(self): this = _Xdmf.new_XdmfElementData() try: self.this.append(this) except: self.this = this __swig_destroy__ = _Xdmf.delete_XdmfElementData __del__ = lambda self : None; def SetReferenceElement(self, *args): return _Xdmf.XdmfElementData_SetReferenceElement(self, *args) def GetReferenceElement(self): return _Xdmf.XdmfElementData_GetReferenceElement(self) def SetCurrentXdmfElement(self, *args): return _Xdmf.XdmfElementData_SetCurrentXdmfElement(self, *args) def GetCurrentXdmfElement(self): return _Xdmf.XdmfElementData_GetCurrentXdmfElement(self) XdmfElementData_swigregister = _Xdmf.XdmfElementData_swigregister XdmfElementData_swigregister(XdmfElementData) XDMF_ATTRIBUTE_TYPE_NONE = _Xdmf.XDMF_ATTRIBUTE_TYPE_NONE XDMF_ATTRIBUTE_TYPE_SCALAR = _Xdmf.XDMF_ATTRIBUTE_TYPE_SCALAR XDMF_ATTRIBUTE_TYPE_VECTOR = _Xdmf.XDMF_ATTRIBUTE_TYPE_VECTOR XDMF_ATTRIBUTE_TYPE_TENSOR = _Xdmf.XDMF_ATTRIBUTE_TYPE_TENSOR XDMF_ATTRIBUTE_TYPE_MATRIX = _Xdmf.XDMF_ATTRIBUTE_TYPE_MATRIX XDMF_ATTRIBUTE_TYPE_TENSOR6 = _Xdmf.XDMF_ATTRIBUTE_TYPE_TENSOR6 XDMF_ATTRIBUTE_TYPE_GLOBALID = _Xdmf.XDMF_ATTRIBUTE_TYPE_GLOBALID XDMF_ATTRIBUTE_CENTER_GRID = _Xdmf.XDMF_ATTRIBUTE_CENTER_GRID XDMF_ATTRIBUTE_CENTER_CELL = _Xdmf.XDMF_ATTRIBUTE_CENTER_CELL XDMF_ATTRIBUTE_CENTER_FACE = _Xdmf.XDMF_ATTRIBUTE_CENTER_FACE XDMF_ATTRIBUTE_CENTER_EDGE = _Xdmf.XDMF_ATTRIBUTE_CENTER_EDGE XDMF_ATTRIBUTE_CENTER_NODE = _Xdmf.XDMF_ATTRIBUTE_CENTER_NODE class XdmfAttribute(XdmfElement): __swig_setmethods__ = {} for _s in [XdmfElement]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) __setattr__ = lambda self, name, value: _swig_setattr(self, XdmfAttribute, name, value) __swig_getmethods__ = {} for _s in [XdmfElement]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) __getattr__ = lambda self, name: _swig_getattr(self, XdmfAttribute, name) __repr__ = _swig_repr def __init__(self): this = _Xdmf.new_XdmfAttribute() try: self.this.append(this) except: self.this = this __swig_destroy__ = _Xdmf.delete_XdmfAttribute __del__ = lambda self : None; def GetClassName(self): return _Xdmf.XdmfAttribute_GetClassName(self) def SetAttributeType(self, *args): return _Xdmf.XdmfAttribute_SetAttributeType(self, *args) def GetAttributeType(self): return _Xdmf.XdmfAttribute_GetAttributeType(self) def SetLightDataLimit(self, *args): return _Xdmf.XdmfAttribute_SetLightDataLimit(self, *args) def GetLightDataLimit(self): return _Xdmf.XdmfAttribute_GetLightDataLimit(self) def SetActive(self, *args): return _Xdmf.XdmfAttribute_SetActive(self, *args) def GetActive(self): return _Xdmf.XdmfAttribute_GetActive(self) def Insert(self, *args): return _Xdmf.XdmfAttribute_Insert(self, *args) def SetAttributeTypeFromString(self, *args): return _Xdmf.XdmfAttribute_SetAttributeTypeFromString(self, *args) def GetAttributeTypeAsString(self): return _Xdmf.XdmfAttribute_GetAttributeTypeAsString(self) def SetAttributeCenterFromString(self, *args): return _Xdmf.XdmfAttribute_SetAttributeCenterFromString(self, *args) def GetAttributeCenterAsString(self): return _Xdmf.XdmfAttribute_GetAttributeCenterAsString(self) def SetAttributeCenter(self, *args): return _Xdmf.XdmfAttribute_SetAttributeCenter(self, *args) def GetAttributeCenter(self): return _Xdmf.XdmfAttribute_GetAttributeCenter(self) def GetUnits(self): return _Xdmf.XdmfAttribute_GetUnits(self) def SetUnits(self, *args): return _Xdmf.XdmfAttribute_SetUnits(self, *args) def GetShapeDesc(self): return _Xdmf.XdmfAttribute_GetShapeDesc(self) def SetValues(self, *args): return _Xdmf.XdmfAttribute_SetValues(self, *args) def GetValues(self, Create = 1): return _Xdmf.XdmfAttribute_GetValues(self, Create) def UpdateInformation(self): return _Xdmf.XdmfAttribute_UpdateInformation(self) def Update(self): return _Xdmf.XdmfAttribute_Update(self) def Build(self): return _Xdmf.XdmfAttribute_Build(self) def Release(self): return _Xdmf.XdmfAttribute_Release(self) XdmfAttribute_swigregister = _Xdmf.XdmfAttribute_swigregister XdmfAttribute_swigregister(XdmfAttribute) def XdmfTypeToHDF5Type(*args): return _Xdmf.XdmfTypeToHDF5Type(*args) XdmfTypeToHDF5Type = _Xdmf.XdmfTypeToHDF5Type def HDF5TypeToXdmfType(*args): return _Xdmf.HDF5TypeToXdmfType(*args) HDF5TypeToXdmfType = _Xdmf.HDF5TypeToXdmfType def XdmfTypeToString(*args): return _Xdmf.XdmfTypeToString(*args) XdmfTypeToString = _Xdmf.XdmfTypeToString def StringToXdmfType(*args): return _Xdmf.StringToXdmfType(*args) StringToXdmfType = _Xdmf.StringToXdmfType def XdmfTypeToClassString(*args): return _Xdmf.XdmfTypeToClassString(*args) XdmfTypeToClassString = _Xdmf.XdmfTypeToClassString XDMF_SELECTALL = _Xdmf.XDMF_SELECTALL XDMF_HYPERSLAB = _Xdmf.XDMF_HYPERSLAB XDMF_COORDINATES = _Xdmf.XDMF_COORDINATES class XdmfDataDesc(XdmfObject): __swig_setmethods__ = {} for _s in [XdmfObject]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) __setattr__ = lambda self, name, value: _swig_setattr(self, XdmfDataDesc, name, value) __swig_getmethods__ = {} for _s in [XdmfObject]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) __getattr__ = lambda self, name: _swig_getattr(self, XdmfDataDesc, name) __repr__ = _swig_repr def __init__(self): this = _Xdmf.new_XdmfDataDesc() try: self.this.append(this) except: self.this = this __swig_destroy__ = _Xdmf.delete_XdmfDataDesc __del__ = lambda self : None; def Print(self): return _Xdmf.XdmfDataDesc_Print(self) def SetNumberType(self, *args): return _Xdmf.XdmfDataDesc_SetNumberType(self, *args) def SetNumberTypeFromString(self, *args): return _Xdmf.XdmfDataDesc_SetNumberTypeFromString(self, *args) def GetNumberType(self): return _Xdmf.XdmfDataDesc_GetNumberType(self) def GetNumberTypeAsString(self): return _Xdmf.XdmfDataDesc_GetNumberTypeAsString(self) def SetShape(self, *args): return _Xdmf.XdmfDataDesc_SetShape(self, *args) def GetShape(self, *args): return _Xdmf.XdmfDataDesc_GetShape(self, *args) def GetShapeAsString(self): return _Xdmf.XdmfDataDesc_GetShapeAsString(self) def CopySelection(self, *args): return _Xdmf.XdmfDataDesc_CopySelection(self, *args) def CopyShape(self, *args): return _Xdmf.XdmfDataDesc_CopyShape(self, *args) def CopyType(self, *args): return _Xdmf.XdmfDataDesc_CopyType(self, *args) def SetNumberOfElements(self, *args): return _Xdmf.XdmfDataDesc_SetNumberOfElements(self, *args) def SetShapeFromString(self, *args): return _Xdmf.XdmfDataDesc_SetShapeFromString(self, *args) def SelectAll(self): return _Xdmf.XdmfDataDesc_SelectAll(self) def SelectHyperSlab(self, *args): return _Xdmf.XdmfDataDesc_SelectHyperSlab(self, *args) def SelectHyperSlabFromString(self, *args): return _Xdmf.XdmfDataDesc_SelectHyperSlabFromString(self, *args) def GetHyperSlab(self, *args): return _Xdmf.XdmfDataDesc_GetHyperSlab(self, *args) def GetHyperSlabAsString(self): return _Xdmf.XdmfDataDesc_GetHyperSlabAsString(self) def SelectCoordinates(self, *args): return _Xdmf.XdmfDataDesc_SelectCoordinates(self, *args) def SelectCoordinatesFromString(self, *args): return _Xdmf.XdmfDataDesc_SelectCoordinatesFromString(self, *args) def GetCoordinates(self, Start = 0, Nelements = 0): return _Xdmf.XdmfDataDesc_GetCoordinates(self, Start, Nelements) def GetCoordinatesAsString(self, Start = 0, Nelements = 0): return _Xdmf.XdmfDataDesc_GetCoordinatesAsString(self, Start, Nelements) def GetSelectionSize(self): return _Xdmf.XdmfDataDesc_GetSelectionSize(self) def GetNumberOfElements(self): return _Xdmf.XdmfDataDesc_GetNumberOfElements(self) def GetCompression(self): return _Xdmf.XdmfDataDesc_GetCompression(self) def SetCompression(self, *args): return _Xdmf.XdmfDataDesc_SetCompression(self, *args) def GetRank(self): return _Xdmf.XdmfDataDesc_GetRank(self) def GetDimension(self, *args): return _Xdmf.XdmfDataDesc_GetDimension(self, *args) def GetStart(self, *args): return _Xdmf.XdmfDataDesc_GetStart(self, *args) def GetStride(self, *args): return _Xdmf.XdmfDataDesc_GetStride(self, *args) def GetCount(self, *args): return _Xdmf.XdmfDataDesc_GetCount(self, *args) def GetSelectionType(self): return _Xdmf.XdmfDataDesc_GetSelectionType(self) def GetSelectionTypeAsString(self): return _Xdmf.XdmfDataDesc_GetSelectionTypeAsString(self) def GetDataType(self): return _Xdmf.XdmfDataDesc_GetDataType(self) def GetDataSpace(self): return _Xdmf.XdmfDataDesc_GetDataSpace(self) def GetElementSize(self): return _Xdmf.XdmfDataDesc_GetElementSize(self) def AddCompoundMemberFromString(self, *args): return _Xdmf.XdmfDataDesc_AddCompoundMemberFromString(self, *args) def GetNumberOfMembers(self): return _Xdmf.XdmfDataDesc_GetNumberOfMembers(self) def GetMemberName(self, *args): return _Xdmf.XdmfDataDesc_GetMemberName(self, *args) def GetMemberLength(self, *args): return _Xdmf.XdmfDataDesc_GetMemberLength(self, *args) def GetMemberSize(self, *args): return _Xdmf.XdmfDataDesc_GetMemberSize(self, *args) def GetMemberShape(self, *args): return _Xdmf.XdmfDataDesc_GetMemberShape(self, *args) def GetMemberShapeAsString(self, *args): return _Xdmf.XdmfDataDesc_GetMemberShapeAsString(self, *args) def GetMemberType(self, *args): return _Xdmf.XdmfDataDesc_GetMemberType(self, *args) def GetMemberTypeAsString(self, *args): return _Xdmf.XdmfDataDesc_GetMemberTypeAsString(self, *args) def GetMemberOffset(self, *args): return _Xdmf.XdmfDataDesc_GetMemberOffset(self, *args) def SetHeavyDataSetName(self, *args): return _Xdmf.XdmfDataDesc_SetHeavyDataSetName(self, *args) def GetHeavyDataSetName(self): return _Xdmf.XdmfDataDesc_GetHeavyDataSetName(self) def GetDsmBuffer(self): return _Xdmf.XdmfDataDesc_GetDsmBuffer(self) def SetDsmBuffer(self, *args): return _Xdmf.XdmfDataDesc_SetDsmBuffer(self, *args) XdmfDataDesc_swigregister = _Xdmf.XdmfDataDesc_swigregister XdmfDataDesc_swigregister(XdmfDataDesc) XDMF_ARRAY_TAG_LENGTH = _Xdmf.XDMF_ARRAY_TAG_LENGTH class XdmfArray(XdmfDataDesc): __swig_setmethods__ = {} for _s in [XdmfDataDesc]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) __setattr__ = lambda self, name, value: _swig_setattr(self, XdmfArray, name, value) __swig_getmethods__ = {} for _s in [XdmfDataDesc]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) __getattr__ = lambda self, name: _swig_getattr(self, XdmfArray, name) __repr__ = _swig_repr def __init__(self): this = _Xdmf.new_XdmfArray() try: self.this.append(this) except: self.this = this __swig_destroy__ = _Xdmf.delete_XdmfArray __del__ = lambda self : None; def GetClassName(self): return _Xdmf.XdmfArray_GetClassName(self) def GetTagName(self): return _Xdmf.XdmfArray_GetTagName(self) def GetCoreLength(self): return _Xdmf.XdmfArray_GetCoreLength(self) def Allocate(self): return _Xdmf.XdmfArray_Allocate(self) def SetAllowAllocate(self, *args): return _Xdmf.XdmfArray_SetAllowAllocate(self, *args) def GetAllowAllocate(self): return _Xdmf.XdmfArray_GetAllowAllocate(self) def SetShape(self, *args): return _Xdmf.XdmfArray_SetShape(self, *args) def SetShapeFromString(self, *args): return _Xdmf.XdmfArray_SetShapeFromString(self, *args) def SetShapeFromSelection(self, *args): return _Xdmf.XdmfArray_SetShapeFromSelection(self, *args) def SetNumberOfElements(self, *args): return _Xdmf.XdmfArray_SetNumberOfElements(self, *args) def ReformFromString(self, *args): return _Xdmf.XdmfArray_ReformFromString(self, *args) def ReformFromSelection(self, *args): return _Xdmf.XdmfArray_ReformFromSelection(self, *args) def CopyShape(self, *args): return _Xdmf.XdmfArray_CopyShape(self, *args) def GetDataPointer(self, Index = 0): return _Xdmf.XdmfArray_GetDataPointer(self, Index) def SetDataPointer(self, *args): return _Xdmf.XdmfArray_SetDataPointer(self, *args) def Reset(self, Free = 0): return _Xdmf.XdmfArray_Reset(self, Free) def SetValueFromFloat64(self, *args): return _Xdmf.XdmfArray_SetValueFromFloat64(self, *args) def SetValueFromInt64(self, *args): return _Xdmf.XdmfArray_SetValueFromInt64(self, *args) def SetValues(self, *args): return _Xdmf.XdmfArray_SetValues(self, *args) def GetValuesAsInt8(self, *args): return _Xdmf.XdmfArray_GetValuesAsInt8(self, *args) def SetValuesFromInt8(self, *args): return _Xdmf.XdmfArray_SetValuesFromInt8(self, *args) def GetValuesAsInt32(self, *args): return _Xdmf.XdmfArray_GetValuesAsInt32(self, *args) def SetValuesFromInt32(self, *args): return _Xdmf.XdmfArray_SetValuesFromInt32(self, *args) def GetValuesAsInt64(self, *args): return _Xdmf.XdmfArray_GetValuesAsInt64(self, *args) def SetValuesFromInt64(self, *args): return _Xdmf.XdmfArray_SetValuesFromInt64(self, *args) def GetValuesAsFloat32(self, *args): return _Xdmf.XdmfArray_GetValuesAsFloat32(self, *args) def SetValuesFromFloat32(self, *args): return _Xdmf.XdmfArray_SetValuesFromFloat32(self, *args) def GetValuesAsFloat64(self, *args): return _Xdmf.XdmfArray_GetValuesAsFloat64(self, *args) def SetValuesFromFloat64(self, *args): return _Xdmf.XdmfArray_SetValuesFromFloat64(self, *args) def GetValueAsFloat64(self, *args): return _Xdmf.XdmfArray_GetValueAsFloat64(self, *args) def GetValueAsFloat32(self, *args): return _Xdmf.XdmfArray_GetValueAsFloat32(self, *args) def GetValueAsInt64(self, *args): return _Xdmf.XdmfArray_GetValueAsInt64(self, *args) def GetValueAsInt32(self, *args): return _Xdmf.XdmfArray_GetValueAsInt32(self, *args) def GetValueAsInt16(self, *args): return _Xdmf.XdmfArray_GetValueAsInt16(self, *args) def GetValueAsInt8(self, *args): return _Xdmf.XdmfArray_GetValueAsInt8(self, *args) def GetValues(self, Index = 0, NumberOfValues = 0, ArrayStride = 1): return _Xdmf.XdmfArray_GetValues(self, Index, NumberOfValues, ArrayStride) def Generate(self, *args): return _Xdmf.XdmfArray_Generate(self, *args) def Clone(self, Start = 0, End = 0): return _Xdmf.XdmfArray_Clone(self, Start, End) def Reference(self, Start = 0, End = 0): return _Xdmf.XdmfArray_Reference(self, Start, End) def GetMaxAsFloat64(self): return _Xdmf.XdmfArray_GetMaxAsFloat64(self) def GetMinAsFloat64(self): return _Xdmf.XdmfArray_GetMinAsFloat64(self) def GetMaxAsInt64(self): return _Xdmf.XdmfArray_GetMaxAsInt64(self) def GetMinAsInt64(self): return _Xdmf.XdmfArray_GetMinAsInt64(self) def GetMean(self): return _Xdmf.XdmfArray_GetMean(self) def SetDataFromChars(self, *args): return _Xdmf.XdmfArray_SetDataFromChars(self, *args) def GetDataPointerAsCharPointer(self): return _Xdmf.XdmfArray_GetDataPointerAsCharPointer(self) XdmfArray_swigregister = _Xdmf.XdmfArray_swigregister XdmfArray_swigregister(XdmfArray) class XdmfArrayList(_object): __swig_setmethods__ = {} __setattr__ = lambda self, name, value: _swig_setattr(self, XdmfArrayList, name, value) __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, XdmfArrayList, name) __repr__ = _swig_repr __swig_setmethods__["name"] = _Xdmf.XdmfArrayList_name_set __swig_getmethods__["name"] = _Xdmf.XdmfArrayList_name_get if _newclass:name = _swig_property(_Xdmf.XdmfArrayList_name_get, _Xdmf.XdmfArrayList_name_set) __swig_setmethods__["timecntr"] = _Xdmf.XdmfArrayList_timecntr_set __swig_getmethods__["timecntr"] = _Xdmf.XdmfArrayList_timecntr_get if _newclass:timecntr = _swig_property(_Xdmf.XdmfArrayList_timecntr_get, _Xdmf.XdmfArrayList_timecntr_set) __swig_setmethods__["Array"] = _Xdmf.XdmfArrayList_Array_set __swig_getmethods__["Array"] = _Xdmf.XdmfArrayList_Array_get if _newclass:Array = _swig_property(_Xdmf.XdmfArrayList_Array_get, _Xdmf.XdmfArrayList_Array_set) def __init__(self): this = _Xdmf.new_XdmfArrayList() try: self.this.append(this) except: self.this = this __swig_destroy__ = _Xdmf.delete_XdmfArrayList __del__ = lambda self : None; XdmfArrayList_swigregister = _Xdmf.XdmfArrayList_swigregister XdmfArrayList_swigregister(XdmfArrayList) def TagNameToArray(*args): return _Xdmf.TagNameToArray(*args) TagNameToArray = _Xdmf.TagNameToArray def PrintAllXdmfArrays(): return _Xdmf.PrintAllXdmfArrays() PrintAllXdmfArrays = _Xdmf.PrintAllXdmfArrays def GetCurrentArrayTime(): return _Xdmf.GetCurrentArrayTime() GetCurrentArrayTime = _Xdmf.GetCurrentArrayTime class XdmfDOM(XdmfLightData): __swig_setmethods__ = {} for _s in [XdmfLightData]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) __setattr__ = lambda self, name, value: _swig_setattr(self, XdmfDOM, name, value) __swig_getmethods__ = {} for _s in [XdmfLightData]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) __getattr__ = lambda self, name: _swig_getattr(self, XdmfDOM, name) __repr__ = _swig_repr def __init__(self): this = _Xdmf.new_XdmfDOM() try: self.this.append(this) except: self.this = this __swig_destroy__ = _Xdmf.delete_XdmfDOM __del__ = lambda self : None; def GetClassName(self): return _Xdmf.XdmfDOM_GetClassName(self) def SetInputFileName(self, *args): return _Xdmf.XdmfDOM_SetInputFileName(self, *args) def SetOutputFileName(self, *args): return _Xdmf.XdmfDOM_SetOutputFileName(self, *args) def GetInputFileName(self): return _Xdmf.XdmfDOM_GetInputFileName(self) def GetOutputFileName(self): return _Xdmf.XdmfDOM_GetOutputFileName(self) def SetParserOptions(self, *args): return _Xdmf.XdmfDOM_SetParserOptions(self, *args) def GetOutput(self): return _Xdmf.XdmfDOM_GetOutput(self) def SetOutput(self, *args): return _Xdmf.XdmfDOM_SetOutput(self, *args) def GetInput(self): return _Xdmf.XdmfDOM_GetInput(self) def SetInput(self, *args): return _Xdmf.XdmfDOM_SetInput(self, *args) def GenerateHead(self): return _Xdmf.XdmfDOM_GenerateHead(self) def GetDTD(self): return _Xdmf.XdmfDOM_GetDTD(self) def SetDTD(self, *args): return _Xdmf.XdmfDOM_SetDTD(self, *args) def Puts(self, *args): return _Xdmf.XdmfDOM_Puts(self, *args) def GenerateTail(self): return _Xdmf.XdmfDOM_GenerateTail(self) def GetTree(self): return _Xdmf.XdmfDOM_GetTree(self) def __Parse(self, *args): return _Xdmf.XdmfDOM___Parse(self, *args) def Parse(self, xml = None): return _Xdmf.XdmfDOM_Parse(self, xml) def GetRoot(self): return _Xdmf.XdmfDOM_GetRoot(self) def GetNumberOfChildren(self, node = None): return _Xdmf.XdmfDOM_GetNumberOfChildren(self, node) def GetChild(self, *args): return _Xdmf.XdmfDOM_GetChild(self, *args) def GetNumberOfAttributes(self, *args): return _Xdmf.XdmfDOM_GetNumberOfAttributes(self, *args) def GetAttributeName(self, *args): return _Xdmf.XdmfDOM_GetAttributeName(self, *args) def IsChild(self, *args): return _Xdmf.XdmfDOM_IsChild(self, *args) def Serialize(self, node = None): return _Xdmf.XdmfDOM_Serialize(self, node) def Write(self, Output = None): return _Xdmf.XdmfDOM_Write(self, Output) def Insert(self, *args): return _Xdmf.XdmfDOM_Insert(self, *args) def InsertFromString(self, *args): return _Xdmf.XdmfDOM_InsertFromString(self, *args) def Create(self, RootElementName = "Xdmf", Version = "2.0"): return _Xdmf.XdmfDOM_Create(self, RootElementName, Version) def InsertNew(self, *args): return _Xdmf.XdmfDOM_InsertNew(self, *args) def DeleteNode(self, *args): return _Xdmf.XdmfDOM_DeleteNode(self, *args) def FindElement(self, *args): return _Xdmf.XdmfDOM_FindElement(self, *args) def FindNextElement(self, *args): return _Xdmf.XdmfDOM_FindNextElement(self, *args) def FindDataElement(self, Index = 0, Node = None, IgnoreInfo = 1): return _Xdmf.XdmfDOM_FindDataElement(self, Index, Node, IgnoreInfo) def FindElementByAttribute(self, *args): return _Xdmf.XdmfDOM_FindElementByAttribute(self, *args) def FindElementByPath(self, *args): return _Xdmf.XdmfDOM_FindElementByPath(self, *args) def FindNumberOfElements(self, *args): return _Xdmf.XdmfDOM_FindNumberOfElements(self, *args) def FindNumberOfElementsByAttribute(self, *args): return _Xdmf.XdmfDOM_FindNumberOfElementsByAttribute(self, *args) def GetPath(self, *args): return _Xdmf.XdmfDOM_GetPath(self, *args) def GetNdgmHost(self): return _Xdmf.XdmfDOM_GetNdgmHost(self) def SetNdgmHost(self, *args): return _Xdmf.XdmfDOM_SetNdgmHost(self, *args) def Get(self, *args): return _Xdmf.XdmfDOM_Get(self, *args) def GetAttribute(self, *args): return _Xdmf.XdmfDOM_GetAttribute(self, *args) def GetCData(self, *args): return _Xdmf.XdmfDOM_GetCData(self, *args) def Set(self, *args): return _Xdmf.XdmfDOM_Set(self, *args) XdmfDOM_swigregister = _Xdmf.XdmfDOM_swigregister XdmfDOM_swigregister(XdmfDOM) def GetNextOlderArray(*args): return _Xdmf.GetNextOlderArray(*args) GetNextOlderArray = _Xdmf.GetNextOlderArray def HandleToXdmfDOM(*args): return _Xdmf.HandleToXdmfDOM(*args) HandleToXdmfDOM = _Xdmf.HandleToXdmfDOM class XdmfInformation(XdmfElement): __swig_setmethods__ = {} for _s in [XdmfElement]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) __setattr__ = lambda self, name, value: _swig_setattr(self, XdmfInformation, name, value) __swig_getmethods__ = {} for _s in [XdmfElement]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) __getattr__ = lambda self, name: _swig_getattr(self, XdmfInformation, name) __repr__ = _swig_repr def __init__(self): this = _Xdmf.new_XdmfInformation() try: self.this.append(this) except: self.this = this __swig_destroy__ = _Xdmf.delete_XdmfInformation __del__ = lambda self : None; def GetClassName(self): return _Xdmf.XdmfInformation_GetClassName(self) def Insert(self, *args): return _Xdmf.XdmfInformation_Insert(self, *args) def UpdateInformation(self): return _Xdmf.XdmfInformation_UpdateInformation(self) def SetValue(self, *args): return _Xdmf.XdmfInformation_SetValue(self, *args) def Build(self): return _Xdmf.XdmfInformation_Build(self) def GetValue(self): return _Xdmf.XdmfInformation_GetValue(self) XdmfInformation_swigregister = _Xdmf.XdmfInformation_swigregister XdmfInformation_swigregister(XdmfInformation) XDMF_FORMAT_XML = _Xdmf.XDMF_FORMAT_XML XDMF_FORMAT_HDF = _Xdmf.XDMF_FORMAT_HDF XDMF_FORMAT_MYSQL = _Xdmf.XDMF_FORMAT_MYSQL XDMF_FORMAT_BINARY = _Xdmf.XDMF_FORMAT_BINARY XDMF_ITEM_UNIFORM = _Xdmf.XDMF_ITEM_UNIFORM XDMF_ITEM_HYPERSLAB = _Xdmf.XDMF_ITEM_HYPERSLAB XDMF_ITEM_COORDINATES = _Xdmf.XDMF_ITEM_COORDINATES XDMF_ITEM_FUNCTION = _Xdmf.XDMF_ITEM_FUNCTION XDMF_ITEM_COLLECTION = _Xdmf.XDMF_ITEM_COLLECTION XDMF_ITEM_TREE = _Xdmf.XDMF_ITEM_TREE XDMF_ITEM_MASK = _Xdmf.XDMF_ITEM_MASK class XdmfDataItem(XdmfElement): __swig_setmethods__ = {} for _s in [XdmfElement]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) __setattr__ = lambda self, name, value: _swig_setattr(self, XdmfDataItem, name, value) __swig_getmethods__ = {} for _s in [XdmfElement]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) __getattr__ = lambda self, name: _swig_getattr(self, XdmfDataItem, name) __repr__ = _swig_repr def __init__(self): this = _Xdmf.new_XdmfDataItem() try: self.this.append(this) except: self.this = this __swig_destroy__ = _Xdmf.delete_XdmfDataItem __del__ = lambda self : None; def GetClassName(self): return _Xdmf.XdmfDataItem_GetClassName(self) def GetValues(self): return _Xdmf.XdmfDataItem_GetValues(self) def GetFormat(self): return _Xdmf.XdmfDataItem_GetFormat(self) def SetFormat(self, *args): return _Xdmf.XdmfDataItem_SetFormat(self, *args) def Insert(self, *args): return _Xdmf.XdmfDataItem_Insert(self, *args) def SetArrayIsMine(self, *args): return _Xdmf.XdmfDataItem_SetArrayIsMine(self, *args) def GetArrayIsMine(self): return _Xdmf.XdmfDataItem_GetArrayIsMine(self) def UpdateInformation(self): return _Xdmf.XdmfDataItem_UpdateInformation(self) def Update(self): return _Xdmf.XdmfDataItem_Update(self) def Build(self): return _Xdmf.XdmfDataItem_Build(self) def GetDataDesc(self): return _Xdmf.XdmfDataItem_GetDataDesc(self) def SetDataDesc(self, *args): return _Xdmf.XdmfDataItem_SetDataDesc(self, *args) def GetArray(self, Create = 1): return _Xdmf.XdmfDataItem_GetArray(self, Create) def SetArray(self, *args): return _Xdmf.XdmfDataItem_SetArray(self, *args) def GetDataValues(self, Index = 0, NumberOfValues = 0, ArrayStride = 1): return _Xdmf.XdmfDataItem_GetDataValues(self, Index, NumberOfValues, ArrayStride) def SetDataValues(self, *args): return _Xdmf.XdmfDataItem_SetDataValues(self, *args) def GetRank(self): return _Xdmf.XdmfDataItem_GetRank(self) def SetShape(self, *args): return _Xdmf.XdmfDataItem_SetShape(self, *args) def GetShape(self, *args): return _Xdmf.XdmfDataItem_GetShape(self, *args) def GetShapeAsString(self): return _Xdmf.XdmfDataItem_GetShapeAsString(self) def GetDimensions(self): return _Xdmf.XdmfDataItem_GetDimensions(self) def SetDimensions(self, *args): return _Xdmf.XdmfDataItem_SetDimensions(self, *args) def SetDimensionsFromString(self, *args): return _Xdmf.XdmfDataItem_SetDimensionsFromString(self, *args) def SetHeavyDataSetName(self, *args): return _Xdmf.XdmfDataItem_SetHeavyDataSetName(self, *args) def GetHeavyDataSetName(self): return _Xdmf.XdmfDataItem_GetHeavyDataSetName(self) def Copy(self, *args): return _Xdmf.XdmfDataItem_Copy(self, *args) def SetItemType(self, *args): return _Xdmf.XdmfDataItem_SetItemType(self, *args) def GetItemType(self): return _Xdmf.XdmfDataItem_GetItemType(self) def GetIsMultiple(self): return _Xdmf.XdmfDataItem_GetIsMultiple(self) def SetFunction(self, *args): return _Xdmf.XdmfDataItem_SetFunction(self, *args) def GetFunction(self): return _Xdmf.XdmfDataItem_GetFunction(self) def Release(self): return _Xdmf.XdmfDataItem_Release(self) def GetColumnMajor(self): return _Xdmf.XdmfDataItem_GetColumnMajor(self) def SetColumnMajor(self, *args): return _Xdmf.XdmfDataItem_SetColumnMajor(self, *args) def GetTransposeInMemory(self): return _Xdmf.XdmfDataItem_GetTransposeInMemory(self) def SetTransposeInMemory(self, *args): return _Xdmf.XdmfDataItem_SetTransposeInMemory(self, *args) XdmfDataItem_swigregister = _Xdmf.XdmfDataItem_swigregister XdmfDataItem_swigregister(XdmfDataItem) class XdmfDataStructure(XdmfDataItem): __swig_setmethods__ = {} for _s in [XdmfDataItem]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) __setattr__ = lambda self, name, value: _swig_setattr(self, XdmfDataStructure, name, value) __swig_getmethods__ = {} for _s in [XdmfDataItem]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) __getattr__ = lambda self, name: _swig_getattr(self, XdmfDataStructure, name) __repr__ = _swig_repr def __init__(self): this = _Xdmf.new_XdmfDataStructure() try: self.this.append(this) except: self.this = this __swig_destroy__ = _Xdmf.delete_XdmfDataStructure __del__ = lambda self : None; def GetClassName(self): return _Xdmf.XdmfDataStructure_GetClassName(self) def UpdateInformation(self): return _Xdmf.XdmfDataStructure_UpdateInformation(self) XdmfDataStructure_swigregister = _Xdmf.XdmfDataStructure_swigregister XdmfDataStructure_swigregister(XdmfDataStructure) class XdmfValues(XdmfDataItem): __swig_setmethods__ = {} for _s in [XdmfDataItem]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) __setattr__ = lambda self, name, value: _swig_setattr(self, XdmfValues, name, value) __swig_getmethods__ = {} for _s in [XdmfDataItem]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) __getattr__ = lambda self, name: _swig_getattr(self, XdmfValues, name) __repr__ = _swig_repr def __init__(self): this = _Xdmf.new_XdmfValues() try: self.this.append(this) except: self.this = this __swig_destroy__ = _Xdmf.delete_XdmfValues __del__ = lambda self : None; def GetClassName(self): return _Xdmf.XdmfValues_GetClassName(self) def Inherit(self, *args): return _Xdmf.XdmfValues_Inherit(self, *args) def Read(self, Array = None): return _Xdmf.XdmfValues_Read(self, Array) def Write(self, *args): return _Xdmf.XdmfValues_Write(self, *args) XdmfValues_swigregister = _Xdmf.XdmfValues_swigregister XdmfValues_swigregister(XdmfValues) class XdmfValuesXML(XdmfValues): __swig_setmethods__ = {} for _s in [XdmfValues]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) __setattr__ = lambda self, name, value: _swig_setattr(self, XdmfValuesXML, name, value) __swig_getmethods__ = {} for _s in [XdmfValues]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) __getattr__ = lambda self, name: _swig_getattr(self, XdmfValuesXML, name) __repr__ = _swig_repr def __init__(self): this = _Xdmf.new_XdmfValuesXML() try: self.this.append(this) except: self.this = this __swig_destroy__ = _Xdmf.delete_XdmfValuesXML __del__ = lambda self : None; def GetClassName(self): return _Xdmf.XdmfValuesXML_GetClassName(self) def Read(self, Array = None): return _Xdmf.XdmfValuesXML_Read(self, Array) def Write(self, *args): return _Xdmf.XdmfValuesXML_Write(self, *args) XdmfValuesXML_swigregister = _Xdmf.XdmfValuesXML_swigregister XdmfValuesXML_swigregister(XdmfValuesXML) class XdmfValuesHDF(XdmfValues): __swig_setmethods__ = {} for _s in [XdmfValues]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) __setattr__ = lambda self, name, value: _swig_setattr(self, XdmfValuesHDF, name, value) __swig_getmethods__ = {} for _s in [XdmfValues]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) __getattr__ = lambda self, name: _swig_getattr(self, XdmfValuesHDF, name) __repr__ = _swig_repr def __init__(self): this = _Xdmf.new_XdmfValuesHDF() try: self.this.append(this) except: self.this = this __swig_destroy__ = _Xdmf.delete_XdmfValuesHDF __del__ = lambda self : None; def GetClassName(self): return _Xdmf.XdmfValuesHDF_GetClassName(self) def Read(self, Array = None): return _Xdmf.XdmfValuesHDF_Read(self, Array) def Write(self, *args): return _Xdmf.XdmfValuesHDF_Write(self, *args) def DataItemFromHDF(self, *args): return _Xdmf.XdmfValuesHDF_DataItemFromHDF(self, *args) XdmfValuesHDF_swigregister = _Xdmf.XdmfValuesHDF_swigregister XdmfValuesHDF_swigregister(XdmfValuesHDF) def XdmfArrayExpr(*args): return _Xdmf.XdmfArrayExpr(*args) XdmfArrayExpr = _Xdmf.XdmfArrayExpr def XdmfScalarExpr(*args): return _Xdmf.XdmfScalarExpr(*args) XdmfScalarExpr = _Xdmf.XdmfScalarExpr def XdmfExpr(*args): return _Xdmf.XdmfExpr(*args) XdmfExpr = _Xdmf.XdmfExpr class XdmfHeavyData(XdmfDataDesc): __swig_setmethods__ = {} for _s in [XdmfDataDesc]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) __setattr__ = lambda self, name, value: _swig_setattr(self, XdmfHeavyData, name, value) __swig_getmethods__ = {} for _s in [XdmfDataDesc]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) __getattr__ = lambda self, name: _swig_getattr(self, XdmfHeavyData, name) __repr__ = _swig_repr def __init__(self): this = _Xdmf.new_XdmfHeavyData() try: self.this.append(this) except: self.this = this __swig_destroy__ = _Xdmf.delete_XdmfHeavyData __del__ = lambda self : None; def GetClassName(self): return _Xdmf.XdmfHeavyData_GetClassName(self) def GetNdgmHost(self): return _Xdmf.XdmfHeavyData_GetNdgmHost(self) def SetNdgmHost(self, *args): return _Xdmf.XdmfHeavyData_SetNdgmHost(self, *args) def GetWorkingDirectory(self): return _Xdmf.XdmfHeavyData_GetWorkingDirectory(self) def SetWorkingDirectory(self, *args): return _Xdmf.XdmfHeavyData_SetWorkingDirectory(self, *args) def GetDomain(self): return _Xdmf.XdmfHeavyData_GetDomain(self) def SetDomain(self, *args): return _Xdmf.XdmfHeavyData_SetDomain(self, *args) def GetFileName(self): return _Xdmf.XdmfHeavyData_GetFileName(self) def SetFileName(self, *args): return _Xdmf.XdmfHeavyData_SetFileName(self, *args) def GetPath(self): return _Xdmf.XdmfHeavyData_GetPath(self) def SetPath(self, *args): return _Xdmf.XdmfHeavyData_SetPath(self, *args) def GetAccess(self): return _Xdmf.XdmfHeavyData_GetAccess(self) def SetAccess(self, *args): return _Xdmf.XdmfHeavyData_SetAccess(self, *args) def Open(self, name = None, access = None): return _Xdmf.XdmfHeavyData_Open(self, name, access) def Read(self, array = None): return _Xdmf.XdmfHeavyData_Read(self, array) def Write(self, *args): return _Xdmf.XdmfHeavyData_Write(self, *args) def Close(self): return _Xdmf.XdmfHeavyData_Close(self) def DoOpen(self, *args): return _Xdmf.XdmfHeavyData_DoOpen(self, *args) def DoRead(self, *args): return _Xdmf.XdmfHeavyData_DoRead(self, *args) def DoWrite(self, *args): return _Xdmf.XdmfHeavyData_DoWrite(self, *args) def DoClose(self): return _Xdmf.XdmfHeavyData_DoClose(self) def setOpenCallback(self, *args): return _Xdmf.XdmfHeavyData_setOpenCallback(self, *args) def setReadCallback(self, *args): return _Xdmf.XdmfHeavyData_setReadCallback(self, *args) def setWriteCallback(self, *args): return _Xdmf.XdmfHeavyData_setWriteCallback(self, *args) def setCloseCallback(self, *args): return _Xdmf.XdmfHeavyData_setCloseCallback(self, *args) XdmfHeavyData_swigregister = _Xdmf.XdmfHeavyData_swigregister XdmfHeavyData_swigregister(XdmfHeavyData) class XdmfOpenCallback(_object): __swig_setmethods__ = {} __setattr__ = lambda self, name, value: _swig_setattr(self, XdmfOpenCallback, name, value) __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, XdmfOpenCallback, name) __repr__ = _swig_repr def DoOpen(self, *args): return _Xdmf.XdmfOpenCallback_DoOpen(self, *args) def __init__(self): this = _Xdmf.new_XdmfOpenCallback() try: self.this.append(this) except: self.this = this __swig_destroy__ = _Xdmf.delete_XdmfOpenCallback __del__ = lambda self : None; XdmfOpenCallback_swigregister = _Xdmf.XdmfOpenCallback_swigregister XdmfOpenCallback_swigregister(XdmfOpenCallback) class XdmfReadCallback(_object): __swig_setmethods__ = {} __setattr__ = lambda self, name, value: _swig_setattr(self, XdmfReadCallback, name, value) __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, XdmfReadCallback, name) __repr__ = _swig_repr def DoRead(self, *args): return _Xdmf.XdmfReadCallback_DoRead(self, *args) def __init__(self): this = _Xdmf.new_XdmfReadCallback() try: self.this.append(this) except: self.this = this __swig_destroy__ = _Xdmf.delete_XdmfReadCallback __del__ = lambda self : None; XdmfReadCallback_swigregister = _Xdmf.XdmfReadCallback_swigregister XdmfReadCallback_swigregister(XdmfReadCallback) class XdmfWriteCallback(_object): __swig_setmethods__ = {} __setattr__ = lambda self, name, value: _swig_setattr(self, XdmfWriteCallback, name, value) __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, XdmfWriteCallback, name) __repr__ = _swig_repr def DoWrite(self, *args): return _Xdmf.XdmfWriteCallback_DoWrite(self, *args) def __init__(self): this = _Xdmf.new_XdmfWriteCallback() try: self.this.append(this) except: self.this = this __swig_destroy__ = _Xdmf.delete_XdmfWriteCallback __del__ = lambda self : None; XdmfWriteCallback_swigregister = _Xdmf.XdmfWriteCallback_swigregister XdmfWriteCallback_swigregister(XdmfWriteCallback) class XdmfCloseCallback(_object): __swig_setmethods__ = {} __setattr__ = lambda self, name, value: _swig_setattr(self, XdmfCloseCallback, name, value) __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, XdmfCloseCallback, name) __repr__ = _swig_repr def DoClose(self, *args): return _Xdmf.XdmfCloseCallback_DoClose(self, *args) def __init__(self): this = _Xdmf.new_XdmfCloseCallback() try: self.this.append(this) except: self.this = this __swig_destroy__ = _Xdmf.delete_XdmfCloseCallback __del__ = lambda self : None; XdmfCloseCallback_swigregister = _Xdmf.XdmfCloseCallback_swigregister XdmfCloseCallback_swigregister(XdmfCloseCallback) XDMF_H5_OTHER = _Xdmf.XDMF_H5_OTHER class XdmfHDF(XdmfHeavyData): __swig_setmethods__ = {} for _s in [XdmfHeavyData]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) __setattr__ = lambda self, name, value: _swig_setattr(self, XdmfHDF, name, value) __swig_getmethods__ = {} for _s in [XdmfHeavyData]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) __getattr__ = lambda self, name: _swig_getattr(self, XdmfHDF, name) __repr__ = _swig_repr def __init__(self): this = _Xdmf.new_XdmfHDF() try: self.this.append(this) except: self.this = this __swig_destroy__ = _Xdmf.delete_XdmfHDF __del__ = lambda self : None; def GetClassName(self): return _Xdmf.XdmfHDF_GetClassName(self) def SetCompression(self, *args): return _Xdmf.XdmfHDF_SetCompression(self, *args) def GetCompression(self): return _Xdmf.XdmfHDF_GetCompression(self) def SetUseSerialFile(self, *args): return _Xdmf.XdmfHDF_SetUseSerialFile(self, *args) def GetUseSerialFile(self): return _Xdmf.XdmfHDF_GetUseSerialFile(self) def SetCwdName(self, *args): return _Xdmf.XdmfHDF_SetCwdName(self, *args) def GetCwdName(self): return _Xdmf.XdmfHDF_GetCwdName(self) def Cd(self, Directory = "/"): return _Xdmf.XdmfHDF_Cd(self, Directory) def Mkdir(self, *args): return _Xdmf.XdmfHDF_Mkdir(self, *args) def GetNumberOfChildren(self): return _Xdmf.XdmfHDF_GetNumberOfChildren(self) def GetHDFVersion(self): return _Xdmf.XdmfHDF_GetHDFVersion(self) def GetChild(self, *args): return _Xdmf.XdmfHDF_GetChild(self, *args) def SetNextChild(self, *args): return _Xdmf.XdmfHDF_SetNextChild(self, *args) def Info(self, *args): return _Xdmf.XdmfHDF_Info(self, *args) def GetChildType(self, *args): return _Xdmf.XdmfHDF_GetChildType(self, *args) def GetChildTypeAsString(self, *args): return _Xdmf.XdmfHDF_GetChildTypeAsString(self, *args) def CreateDataset(self, Path = None): return _Xdmf.XdmfHDF_CreateDataset(self, Path) def OpenDataset(self): return _Xdmf.XdmfHDF_OpenDataset(self) def DoOpen(self, *args): return _Xdmf.XdmfHDF_DoOpen(self, *args) def DoRead(self, *args): return _Xdmf.XdmfHDF_DoRead(self, *args) def DoWrite(self, *args): return _Xdmf.XdmfHDF_DoWrite(self, *args) def DoClose(self): return _Xdmf.XdmfHDF_DoClose(self) XdmfHDF_swigregister = _Xdmf.XdmfHDF_swigregister XdmfHDF_swigregister(XdmfHDF) class XdmfDomain(XdmfElement): __swig_setmethods__ = {} for _s in [XdmfElement]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) __setattr__ = lambda self, name, value: _swig_setattr(self, XdmfDomain, name, value) __swig_getmethods__ = {} for _s in [XdmfElement]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) __getattr__ = lambda self, name: _swig_getattr(self, XdmfDomain, name) __repr__ = _swig_repr def __init__(self): this = _Xdmf.new_XdmfDomain() try: self.this.append(this) except: self.this = this __swig_destroy__ = _Xdmf.delete_XdmfDomain __del__ = lambda self : None; def GetClassName(self): return _Xdmf.XdmfDomain_GetClassName(self) def UpdateInformation(self): return _Xdmf.XdmfDomain_UpdateInformation(self) def Insert(self, *args): return _Xdmf.XdmfDomain_Insert(self, *args) def Build(self): return _Xdmf.XdmfDomain_Build(self) XdmfDomain_swigregister = _Xdmf.XdmfDomain_swigregister XdmfDomain_swigregister(XdmfDomain) def CopyArray(*args): return _Xdmf.CopyArray(*args) CopyArray = _Xdmf.CopyArray class XdmfRoot(XdmfElement): __swig_setmethods__ = {} for _s in [XdmfElement]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) __setattr__ = lambda self, name, value: _swig_setattr(self, XdmfRoot, name, value) __swig_getmethods__ = {} for _s in [XdmfElement]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) __getattr__ = lambda self, name: _swig_getattr(self, XdmfRoot, name) __repr__ = _swig_repr def __init__(self): this = _Xdmf.new_XdmfRoot() try: self.this.append(this) except: self.this = this __swig_destroy__ = _Xdmf.delete_XdmfRoot __del__ = lambda self : None; def GetClassName(self): return _Xdmf.XdmfRoot_GetClassName(self) def UpdateInformation(self): return _Xdmf.XdmfRoot_UpdateInformation(self) def Insert(self, *args): return _Xdmf.XdmfRoot_Insert(self, *args) def SetVersion(self, *args): return _Xdmf.XdmfRoot_SetVersion(self, *args) def SetXInclude(self, *args): return _Xdmf.XdmfRoot_SetXInclude(self, *args) def Build(self): return _Xdmf.XdmfRoot_Build(self) def GetXInclude(self): return _Xdmf.XdmfRoot_GetXInclude(self) def GetVersion(self): return _Xdmf.XdmfRoot_GetVersion(self) XdmfRoot_swigregister = _Xdmf.XdmfRoot_swigregister XdmfRoot_swigregister(XdmfRoot) XDMF_MAX_ORDER = _Xdmf.XDMF_MAX_ORDER XDMF_STRUCTURED = _Xdmf.XDMF_STRUCTURED XDMF_UNSTRUCTURED = _Xdmf.XDMF_UNSTRUCTURED XDMF_NOTOPOLOGY = _Xdmf.XDMF_NOTOPOLOGY XDMF_POLYVERTEX = _Xdmf.XDMF_POLYVERTEX XDMF_POLYLINE = _Xdmf.XDMF_POLYLINE XDMF_POLYGON = _Xdmf.XDMF_POLYGON XDMF_TRI = _Xdmf.XDMF_TRI XDMF_QUAD = _Xdmf.XDMF_QUAD XDMF_TET = _Xdmf.XDMF_TET XDMF_PYRAMID = _Xdmf.XDMF_PYRAMID XDMF_WEDGE = _Xdmf.XDMF_WEDGE XDMF_HEX = _Xdmf.XDMF_HEX XDMF_EDGE_3 = _Xdmf.XDMF_EDGE_3 XDMF_TRI_6 = _Xdmf.XDMF_TRI_6 XDMF_QUAD_8 = _Xdmf.XDMF_QUAD_8 XDMF_TET_10 = _Xdmf.XDMF_TET_10 XDMF_PYRAMID_13 = _Xdmf.XDMF_PYRAMID_13 XDMF_WEDGE_15 = _Xdmf.XDMF_WEDGE_15 XDMF_WEDGE_18 = _Xdmf.XDMF_WEDGE_18 XDMF_HEX_20 = _Xdmf.XDMF_HEX_20 XDMF_HEX_24 = _Xdmf.XDMF_HEX_24 XDMF_HEX_27 = _Xdmf.XDMF_HEX_27 XDMF_MIXED = _Xdmf.XDMF_MIXED XDMF_2DSMESH = _Xdmf.XDMF_2DSMESH XDMF_2DRECTMESH = _Xdmf.XDMF_2DRECTMESH XDMF_2DCORECTMESH = _Xdmf.XDMF_2DCORECTMESH XDMF_3DSMESH = _Xdmf.XDMF_3DSMESH XDMF_3DRECTMESH = _Xdmf.XDMF_3DRECTMESH XDMF_3DCORECTMESH = _Xdmf.XDMF_3DCORECTMESH class XdmfTopology(XdmfElement): __swig_setmethods__ = {} for _s in [XdmfElement]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) __setattr__ = lambda self, name, value: _swig_setattr(self, XdmfTopology, name, value) __swig_getmethods__ = {} for _s in [XdmfElement]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) __getattr__ = lambda self, name: _swig_getattr(self, XdmfTopology, name) __repr__ = _swig_repr def __init__(self): this = _Xdmf.new_XdmfTopology() try: self.this.append(this) except: self.this = this __swig_destroy__ = _Xdmf.delete_XdmfTopology __del__ = lambda self : None; def GetClassName(self): return _Xdmf.XdmfTopology_GetClassName(self) def Build(self): return _Xdmf.XdmfTopology_Build(self) def Insert(self, *args): return _Xdmf.XdmfTopology_Insert(self, *args) def GetClass(self): return _Xdmf.XdmfTopology_GetClass(self) def GetClassAsString(self): return _Xdmf.XdmfTopology_GetClassAsString(self) def SetTopologyType(self, *args): return _Xdmf.XdmfTopology_SetTopologyType(self, *args) def SetTopologyTypeFromString(self, *args): return _Xdmf.XdmfTopology_SetTopologyTypeFromString(self, *args) def GetTopologyType(self): return _Xdmf.XdmfTopology_GetTopologyType(self) def GetTopologyTypeAsString(self): return _Xdmf.XdmfTopology_GetTopologyTypeAsString(self) def GetOrder(self): return _Xdmf.XdmfTopology_GetOrder(self) def GetOrderAsString(self): return _Xdmf.XdmfTopology_GetOrderAsString(self) def SetOrderFromString(self, *args): return _Xdmf.XdmfTopology_SetOrderFromString(self, *args) def SetOrder(self, *args): return _Xdmf.XdmfTopology_SetOrder(self, *args) def SetLightDataLimit(self, *args): return _Xdmf.XdmfTopology_SetLightDataLimit(self, *args) def GetLightDataLimit(self): return _Xdmf.XdmfTopology_GetLightDataLimit(self) def SetNodesPerElement(self, *args): return _Xdmf.XdmfTopology_SetNodesPerElement(self, *args) def GetNodesPerElement(self): return _Xdmf.XdmfTopology_GetNodesPerElement(self) def GetEdgesPerElement(self): return _Xdmf.XdmfTopology_GetEdgesPerElement(self) def GetFacesPerElement(self): return _Xdmf.XdmfTopology_GetFacesPerElement(self) def SetBaseOffset(self, *args): return _Xdmf.XdmfTopology_SetBaseOffset(self, *args) def GetBaseOffset(self): return _Xdmf.XdmfTopology_GetBaseOffset(self) def GetShapeDesc(self): return _Xdmf.XdmfTopology_GetShapeDesc(self) def SetNumberOfElements(self, *args): return _Xdmf.XdmfTopology_SetNumberOfElements(self, *args) def GetNumberOfElements(self): return _Xdmf.XdmfTopology_GetNumberOfElements(self) def GetConnectivity(self, Array = None, Create = 1): return _Xdmf.XdmfTopology_GetConnectivity(self, Array, Create) def SetConnectivity(self, *args): return _Xdmf.XdmfTopology_SetConnectivity(self, *args) def GetCellOffsets(self, Array = None): return _Xdmf.XdmfTopology_GetCellOffsets(self, Array) def Update(self): return _Xdmf.XdmfTopology_Update(self) def UpdateInformation(self): return _Xdmf.XdmfTopology_UpdateInformation(self) def Release(self): return _Xdmf.XdmfTopology_Release(self) XdmfTopology_swigregister = _Xdmf.XdmfTopology_swigregister XdmfTopology_swigregister(XdmfTopology) def HandleToXdmfTopology(*args): return _Xdmf.HandleToXdmfTopology(*args) HandleToXdmfTopology = _Xdmf.HandleToXdmfTopology XDMF_GEOMETRY_NONE = _Xdmf.XDMF_GEOMETRY_NONE XDMF_GEOMETRY_XYZ = _Xdmf.XDMF_GEOMETRY_XYZ XDMF_GEOMETRY_XY = _Xdmf.XDMF_GEOMETRY_XY XDMF_GEOMETRY_X_Y_Z = _Xdmf.XDMF_GEOMETRY_X_Y_Z XDMF_GEOMETRY_X_Y = _Xdmf.XDMF_GEOMETRY_X_Y XDMF_GEOMETRY_VXVYVZ = _Xdmf.XDMF_GEOMETRY_VXVYVZ XDMF_GEOMETRY_ORIGIN_DXDYDZ = _Xdmf.XDMF_GEOMETRY_ORIGIN_DXDYDZ XDMF_GEOMETRY_VXVY = _Xdmf.XDMF_GEOMETRY_VXVY XDMF_GEOMETRY_ORIGIN_DXDY = _Xdmf.XDMF_GEOMETRY_ORIGIN_DXDY class XdmfGeometry(XdmfElement): __swig_setmethods__ = {} for _s in [XdmfElement]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) __setattr__ = lambda self, name, value: _swig_setattr(self, XdmfGeometry, name, value) __swig_getmethods__ = {} for _s in [XdmfElement]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) __getattr__ = lambda self, name: _swig_getattr(self, XdmfGeometry, name) __repr__ = _swig_repr def __init__(self): this = _Xdmf.new_XdmfGeometry() try: self.this.append(this) except: self.this = this __swig_destroy__ = _Xdmf.delete_XdmfGeometry __del__ = lambda self : None; def GetClassName(self): return _Xdmf.XdmfGeometry_GetClassName(self) def SetNumberOfPoints(self, *args): return _Xdmf.XdmfGeometry_SetNumberOfPoints(self, *args) def GetNumberOfPoints(self): return _Xdmf.XdmfGeometry_GetNumberOfPoints(self) def SetGeometryType(self, *args): return _Xdmf.XdmfGeometry_SetGeometryType(self, *args) def GetGeometryType(self): return _Xdmf.XdmfGeometry_GetGeometryType(self) def SetLightDataLimit(self, *args): return _Xdmf.XdmfGeometry_SetLightDataLimit(self, *args) def GetLightDataLimit(self): return _Xdmf.XdmfGeometry_GetLightDataLimit(self) def GetUnits(self): return _Xdmf.XdmfGeometry_GetUnits(self) def SetUnits(self, *args): return _Xdmf.XdmfGeometry_SetUnits(self, *args) def GetGeometryTypeAsString(self): return _Xdmf.XdmfGeometry_GetGeometryTypeAsString(self) def SetGeometryTypeFromString(self, *args): return _Xdmf.XdmfGeometry_SetGeometryTypeFromString(self, *args) def Build(self): return _Xdmf.XdmfGeometry_Build(self) def Insert(self, *args): return _Xdmf.XdmfGeometry_Insert(self, *args) def Update(self): return _Xdmf.XdmfGeometry_Update(self) def UpdateInformation(self): return _Xdmf.XdmfGeometry_UpdateInformation(self) def SetPoints(self, *args): return _Xdmf.XdmfGeometry_SetPoints(self, *args) def GetPoints(self, Create = 1): return _Xdmf.XdmfGeometry_GetPoints(self, Create) def Release(self): return _Xdmf.XdmfGeometry_Release(self) def GetOrigin(self): return _Xdmf.XdmfGeometry_GetOrigin(self) def GetOriginX(self): return _Xdmf.XdmfGeometry_GetOriginX(self) def GetOriginY(self): return _Xdmf.XdmfGeometry_GetOriginY(self) def GetOriginZ(self): return _Xdmf.XdmfGeometry_GetOriginZ(self) def SetOrigin(self, *args): return _Xdmf.XdmfGeometry_SetOrigin(self, *args) def SetDxDyDz(self, *args): return _Xdmf.XdmfGeometry_SetDxDyDz(self, *args) def GetDx(self): return _Xdmf.XdmfGeometry_GetDx(self) def GetDy(self): return _Xdmf.XdmfGeometry_GetDy(self) def GetDz(self): return _Xdmf.XdmfGeometry_GetDz(self) def GetDxDyDz(self): return _Xdmf.XdmfGeometry_GetDxDyDz(self) def GetVectorX(self): return _Xdmf.XdmfGeometry_GetVectorX(self) def GetVectorY(self): return _Xdmf.XdmfGeometry_GetVectorY(self) def GetVectorZ(self): return _Xdmf.XdmfGeometry_GetVectorZ(self) def SetVectorX(self, *args): return _Xdmf.XdmfGeometry_SetVectorX(self, *args) def SetVectorY(self, *args): return _Xdmf.XdmfGeometry_SetVectorY(self, *args) def SetVectorZ(self, *args): return _Xdmf.XdmfGeometry_SetVectorZ(self, *args) def HasData(self): return _Xdmf.XdmfGeometry_HasData(self) XdmfGeometry_swigregister = _Xdmf.XdmfGeometry_swigregister XdmfGeometry_swigregister(XdmfGeometry) def GetXdmfGeometryHandle(*args): return _Xdmf.GetXdmfGeometryHandle(*args) GetXdmfGeometryHandle = _Xdmf.GetXdmfGeometryHandle XDMF_GRID_UNIFORM = _Xdmf.XDMF_GRID_UNIFORM XDMF_GRID_COLLECTION = _Xdmf.XDMF_GRID_COLLECTION XDMF_GRID_TREE = _Xdmf.XDMF_GRID_TREE XDMF_GRID_SUBSET = _Xdmf.XDMF_GRID_SUBSET XDMF_GRID_UNSET = _Xdmf.XDMF_GRID_UNSET XDMF_GRID_MASK = _Xdmf.XDMF_GRID_MASK XDMF_GRID_SECTION_ALL = _Xdmf.XDMF_GRID_SECTION_ALL XDMF_GRID_SECTION_DATA_ITEM = _Xdmf.XDMF_GRID_SECTION_DATA_ITEM XDMF_GRID_SECTION_MASK = _Xdmf.XDMF_GRID_SECTION_MASK XDMF_GRID_COLLECTION_TEMPORAL = _Xdmf.XDMF_GRID_COLLECTION_TEMPORAL XDMF_GRID_COLLECTION_SPATIAL = _Xdmf.XDMF_GRID_COLLECTION_SPATIAL XDMF_GRID_COLLECTION_UNSET = _Xdmf.XDMF_GRID_COLLECTION_UNSET class XdmfGrid(XdmfElement): __swig_setmethods__ = {} for _s in [XdmfElement]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) __setattr__ = lambda self, name, value: _swig_setattr(self, XdmfGrid, name, value) __swig_getmethods__ = {} for _s in [XdmfElement]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) __getattr__ = lambda self, name: _swig_getattr(self, XdmfGrid, name) __repr__ = _swig_repr def __init__(self): this = _Xdmf.new_XdmfGrid() try: self.this.append(this) except: self.this = this __swig_destroy__ = _Xdmf.delete_XdmfGrid __del__ = lambda self : None; def GetClassName(self): return _Xdmf.XdmfGrid_GetClassName(self) def SetGeometry(self, *args): return _Xdmf.XdmfGrid_SetGeometry(self, *args) def GetGeometry(self): return _Xdmf.XdmfGrid_GetGeometry(self) def SetTopology(self, *args): return _Xdmf.XdmfGrid_SetTopology(self, *args) def GetTopology(self): return _Xdmf.XdmfGrid_GetTopology(self) def SetTime(self, *args): return _Xdmf.XdmfGrid_SetTime(self, *args) def GetTime(self): return _Xdmf.XdmfGrid_GetTime(self) def GetGridTypeAsString(self): return _Xdmf.XdmfGrid_GetGridTypeAsString(self) def SetGridTypeFromString(self, *args): return _Xdmf.XdmfGrid_SetGridTypeFromString(self, *args) def GetCollectionTypeAsString(self): return _Xdmf.XdmfGrid_GetCollectionTypeAsString(self) def SetCollectionTypeFromString(self, *args): return _Xdmf.XdmfGrid_SetCollectionTypeFromString(self, *args) def Build(self): return _Xdmf.XdmfGrid_Build(self) def InsertTopology(self): return _Xdmf.XdmfGrid_InsertTopology(self) def InsertGeometry(self): return _Xdmf.XdmfGrid_InsertGeometry(self) def Insert(self, *args): return _Xdmf.XdmfGrid_Insert(self, *args) def GetGridType(self): return _Xdmf.XdmfGrid_GetGridType(self) def SetGridType(self, *args): return _Xdmf.XdmfGrid_SetGridType(self, *args) def GetCollectionType(self): return _Xdmf.XdmfGrid_GetCollectionType(self) def SetCollectionType(self, *args): return _Xdmf.XdmfGrid_SetCollectionType(self, *args) def GetBuildTime(self): return _Xdmf.XdmfGrid_GetBuildTime(self) def SetBuildTime(self, *args): return _Xdmf.XdmfGrid_SetBuildTime(self, *args) def Copy(self, *args): return _Xdmf.XdmfGrid_Copy(self, *args) def GetNumberOfChildren(self): return _Xdmf.XdmfGrid_GetNumberOfChildren(self) def SetNumberOfChildren(self, *args): return _Xdmf.XdmfGrid_SetNumberOfChildren(self, *args) def IsUniform(self): return _Xdmf.XdmfGrid_IsUniform(self) def GetNumberOfAttributes(self): return _Xdmf.XdmfGrid_GetNumberOfAttributes(self) def GetNumberOfSets(self): return _Xdmf.XdmfGrid_GetNumberOfSets(self) def GetNumberOfInformations(self): return _Xdmf.XdmfGrid_GetNumberOfInformations(self) def GetAttribute(self, *args): return _Xdmf.XdmfGrid_GetAttribute(self, *args) def GetSets(self, *args): return _Xdmf.XdmfGrid_GetSets(self, *args) def AssignAttribute(self, *args): return _Xdmf.XdmfGrid_AssignAttribute(self, *args) def AssignAttributeByIndex(self, *args): return _Xdmf.XdmfGrid_AssignAttributeByIndex(self, *args) def AssignAttributeByName(self, *args): return _Xdmf.XdmfGrid_AssignAttributeByName(self, *args) def GetAssignedAttribute(self): return _Xdmf.XdmfGrid_GetAssignedAttribute(self) def GetAssignedAttributeIndex(self): return _Xdmf.XdmfGrid_GetAssignedAttributeIndex(self) def UpdateInformation(self): return _Xdmf.XdmfGrid_UpdateInformation(self) def Update(self): return _Xdmf.XdmfGrid_Update(self) def GetChild(self, *args): return _Xdmf.XdmfGrid_GetChild(self, *args) def GetInformation(self, *args): return _Xdmf.XdmfGrid_GetInformation(self, *args) def FindGridsInTimeRange(self, *args): return _Xdmf.XdmfGrid_FindGridsInTimeRange(self, *args) def FindGridsAtTime(self, *args): return _Xdmf.XdmfGrid_FindGridsAtTime(self, *args) def Release(self): return _Xdmf.XdmfGrid_Release(self) XdmfGrid_swigregister = _Xdmf.XdmfGrid_swigregister XdmfGrid_swigregister(XdmfGrid) def HandleToXdmfGrid(*args): return _Xdmf.HandleToXdmfGrid(*args) HandleToXdmfGrid = _Xdmf.HandleToXdmfGrid XDMF_TIME_SINGLE = _Xdmf.XDMF_TIME_SINGLE XDMF_TIME_LIST = _Xdmf.XDMF_TIME_LIST XDMF_TIME_HYPERSLAB = _Xdmf.XDMF_TIME_HYPERSLAB XDMF_TIME_RANGE = _Xdmf.XDMF_TIME_RANGE XDMF_TIME_FUNCTION = _Xdmf.XDMF_TIME_FUNCTION XDMF_TIME_UNSET = _Xdmf.XDMF_TIME_UNSET class XdmfTime(XdmfElement): __swig_setmethods__ = {} for _s in [XdmfElement]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) __setattr__ = lambda self, name, value: _swig_setattr(self, XdmfTime, name, value) __swig_getmethods__ = {} for _s in [XdmfElement]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) __getattr__ = lambda self, name: _swig_getattr(self, XdmfTime, name) __repr__ = _swig_repr def __init__(self): this = _Xdmf.new_XdmfTime() try: self.this.append(this) except: self.this = this __swig_destroy__ = _Xdmf.delete_XdmfTime __del__ = lambda self : None; def GetClassName(self): return _Xdmf.XdmfTime_GetClassName(self) def Insert(self, *args): return _Xdmf.XdmfTime_Insert(self, *args) def UpdateInformation(self): return _Xdmf.XdmfTime_UpdateInformation(self) def SetValue(self, *args): return _Xdmf.XdmfTime_SetValue(self, *args) def Build(self): return _Xdmf.XdmfTime_Build(self) def GetValue(self): return _Xdmf.XdmfTime_GetValue(self) def GetArray(self): return _Xdmf.XdmfTime_GetArray(self) def SetArray(self, *args): return _Xdmf.XdmfTime_SetArray(self, *args) def GetDataItem(self): return _Xdmf.XdmfTime_GetDataItem(self) def SetDataItem(self, *args): return _Xdmf.XdmfTime_SetDataItem(self, *args) def GetTimeType(self): return _Xdmf.XdmfTime_GetTimeType(self) def GetTimeTypeAsString(self): return _Xdmf.XdmfTime_GetTimeTypeAsString(self) def SetTimeType(self, *args): return _Xdmf.XdmfTime_SetTimeType(self, *args) def GetFunction(self): return _Xdmf.XdmfTime_GetFunction(self) def SetFunction(self, *args): return _Xdmf.XdmfTime_SetFunction(self, *args) def SetTimeFromParent(self, *args): return _Xdmf.XdmfTime_SetTimeFromParent(self, *args) def Evaluate(self, *args): return _Xdmf.XdmfTime_Evaluate(self, *args) def IsValid(self, *args): return _Xdmf.XdmfTime_IsValid(self, *args) def SetEpsilon(self, *args): return _Xdmf.XdmfTime_SetEpsilon(self, *args) def GetEpsilon(self): return _Xdmf.XdmfTime_GetEpsilon(self) XdmfTime_swigregister = _Xdmf.XdmfTime_swigregister XdmfTime_swigregister(XdmfTime) XDMF_REGION_TYPE_UNSET = _Xdmf.XDMF_REGION_TYPE_UNSET XDMF_REGION_TYPE_CELL = _Xdmf.XDMF_REGION_TYPE_CELL XDMF_REGION_TYPE_FACE = _Xdmf.XDMF_REGION_TYPE_FACE XDMF_REGION_TYPE_EDGE = _Xdmf.XDMF_REGION_TYPE_EDGE XDMF_REGION_TYPE_NODE = _Xdmf.XDMF_REGION_TYPE_NODE class XdmfRegion(XdmfElement): __swig_setmethods__ = {} for _s in [XdmfElement]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) __setattr__ = lambda self, name, value: _swig_setattr(self, XdmfRegion, name, value) __swig_getmethods__ = {} for _s in [XdmfElement]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) __getattr__ = lambda self, name: _swig_getattr(self, XdmfRegion, name) __repr__ = _swig_repr def __init__(self): this = _Xdmf.new_XdmfRegion() try: self.this.append(this) except: self.this = this __swig_destroy__ = _Xdmf.delete_XdmfRegion __del__ = lambda self : None; def GetClassName(self): return _Xdmf.XdmfRegion_GetClassName(self) def SetRegionTypeFromString(self, *args): return _Xdmf.XdmfRegion_SetRegionTypeFromString(self, *args) def GetRegionTypeAsString(self): return _Xdmf.XdmfRegion_GetRegionTypeAsString(self) def SetRegionType(self, *args): return _Xdmf.XdmfRegion_SetRegionType(self, *args) def GetRegionType(self): return _Xdmf.XdmfRegion_GetRegionType(self) def GetShapeDesc(self): return _Xdmf.XdmfRegion_GetShapeDesc(self) def Insert(self, *args): return _Xdmf.XdmfRegion_Insert(self, *args) def SetValues(self, *args): return _Xdmf.XdmfRegion_SetValues(self, *args) def GetValues(self, Create = 1): return _Xdmf.XdmfRegion_GetValues(self, Create) def UpdateInformation(self): return _Xdmf.XdmfRegion_UpdateInformation(self) def Update(self): return _Xdmf.XdmfRegion_Update(self) def Build(self): return _Xdmf.XdmfRegion_Build(self) def Release(self): return _Xdmf.XdmfRegion_Release(self) XdmfRegion_swigregister = _Xdmf.XdmfRegion_swigregister XdmfRegion_swigregister(XdmfRegion) XDMF_SET_MAX_ORDER = _Xdmf.XDMF_SET_MAX_ORDER XDMF_SET_TYPE_UNSET = _Xdmf.XDMF_SET_TYPE_UNSET XDMF_SET_TYPE_NODE = _Xdmf.XDMF_SET_TYPE_NODE XDMF_SET_TYPE_CELL = _Xdmf.XDMF_SET_TYPE_CELL XDMF_SET_TYPE_FACE = _Xdmf.XDMF_SET_TYPE_FACE XDMF_SET_TYPE_EDGE = _Xdmf.XDMF_SET_TYPE_EDGE class XdmfSet(XdmfElement): __swig_setmethods__ = {} for _s in [XdmfElement]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) __setattr__ = lambda self, name, value: _swig_setattr(self, XdmfSet, name, value) __swig_getmethods__ = {} for _s in [XdmfElement]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) __getattr__ = lambda self, name: _swig_getattr(self, XdmfSet, name) __repr__ = _swig_repr def __init__(self): this = _Xdmf.new_XdmfSet() try: self.this.append(this) except: self.this = this __swig_destroy__ = _Xdmf.delete_XdmfSet __del__ = lambda self : None; def GetClassName(self): return _Xdmf.XdmfSet_GetClassName(self) def SetSetTypeFromString(self, *args): return _Xdmf.XdmfSet_SetSetTypeFromString(self, *args) def GetSetTypeAsString(self): return _Xdmf.XdmfSet_GetSetTypeAsString(self) def SetSetType(self, *args): return _Xdmf.XdmfSet_SetSetType(self, *args) def GetSetType(self): return _Xdmf.XdmfSet_GetSetType(self) def GetSize(self): return _Xdmf.XdmfSet_GetSize(self) def SetSize(self, *args): return _Xdmf.XdmfSet_SetSize(self, *args) def GetGhost(self): return _Xdmf.XdmfSet_GetGhost(self) def SetGhost(self, *args): return _Xdmf.XdmfSet_SetGhost(self, *args) def GetShapeDesc(self): return _Xdmf.XdmfSet_GetShapeDesc(self) def Insert(self, *args): return _Xdmf.XdmfSet_Insert(self, *args) def SetIds(self, *args): return _Xdmf.XdmfSet_SetIds(self, *args) def GetIds(self, Create = 1): return _Xdmf.XdmfSet_GetIds(self, Create) def SetCellIds(self, *args): return _Xdmf.XdmfSet_SetCellIds(self, *args) def GetCellIds(self, Create = 1): return _Xdmf.XdmfSet_GetCellIds(self, Create) def SetFaceIds(self, *args): return _Xdmf.XdmfSet_SetFaceIds(self, *args) def GetFaceIds(self, Create = 1): return _Xdmf.XdmfSet_GetFaceIds(self, Create) def GetNumberOfMaps(self): return _Xdmf.XdmfSet_GetNumberOfMaps(self) def GetMap(self, *args): return _Xdmf.XdmfSet_GetMap(self, *args) def GetNumberOfAttributes(self): return _Xdmf.XdmfSet_GetNumberOfAttributes(self) def GetAttribute(self, *args): return _Xdmf.XdmfSet_GetAttribute(self, *args) def UpdateInformation(self): return _Xdmf.XdmfSet_UpdateInformation(self) def Update(self): return _Xdmf.XdmfSet_Update(self) def Build(self): return _Xdmf.XdmfSet_Build(self) def Release(self): return _Xdmf.XdmfSet_Release(self) XdmfSet_swigregister = _Xdmf.XdmfSet_swigregister XdmfSet_swigregister(XdmfSet) XDMF_MAP_MAX_ORDER = _Xdmf.XDMF_MAP_MAX_ORDER XDMF_MAP_TYPE_UNSET = _Xdmf.XDMF_MAP_TYPE_UNSET XDMF_MAP_TYPE_NODE = _Xdmf.XDMF_MAP_TYPE_NODE XDMF_MAP_TYPE_CELL = _Xdmf.XDMF_MAP_TYPE_CELL XDMF_MAP_TYPE_FACE = _Xdmf.XDMF_MAP_TYPE_FACE XDMF_MAP_TYPE_EDGE = _Xdmf.XDMF_MAP_TYPE_EDGE class XdmfMap(XdmfElement): __swig_setmethods__ = {} for _s in [XdmfElement]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) __setattr__ = lambda self, name, value: _swig_setattr(self, XdmfMap, name, value) __swig_getmethods__ = {} for _s in [XdmfElement]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) __getattr__ = lambda self, name: _swig_getattr(self, XdmfMap, name) __repr__ = _swig_repr def __init__(self): this = _Xdmf.new_XdmfMap() try: self.this.append(this) except: self.this = this __swig_destroy__ = _Xdmf.delete_XdmfMap __del__ = lambda self : None; def GetClassName(self): return _Xdmf.XdmfMap_GetClassName(self) def SetMapTypeFromString(self, *args): return _Xdmf.XdmfMap_SetMapTypeFromString(self, *args) def GetMapTypeAsString(self): return _Xdmf.XdmfMap_GetMapTypeAsString(self) def SetMapType(self, *args): return _Xdmf.XdmfMap_SetMapType(self, *args) def GetMapType(self): return _Xdmf.XdmfMap_GetMapType(self) def GetItemLength(self): return _Xdmf.XdmfMap_GetItemLength(self) def SetItemLength(self, *args): return _Xdmf.XdmfMap_SetItemLength(self, *args) def GetMapLength(self): return _Xdmf.XdmfMap_GetMapLength(self) def SetMapLength(self, *args): return _Xdmf.XdmfMap_SetMapLength(self, *args) def Insert(self, *args): return _Xdmf.XdmfMap_Insert(self, *args) def SetIds(self, *args): return _Xdmf.XdmfMap_SetIds(self, *args) def GetIds(self, Create = 1): return _Xdmf.XdmfMap_GetIds(self, Create) def SetMapIndex(self, *args): return _Xdmf.XdmfMap_SetMapIndex(self, *args) def GetMapIndex(self, Create = 1): return _Xdmf.XdmfMap_GetMapIndex(self, Create) def SetMapData(self, *args): return _Xdmf.XdmfMap_SetMapData(self, *args) def GetMapData(self, Create = 1): return _Xdmf.XdmfMap_GetMapData(self, Create) def UpdateInformation(self): return _Xdmf.XdmfMap_UpdateInformation(self) def Update(self): return _Xdmf.XdmfMap_Update(self) def Build(self): return _Xdmf.XdmfMap_Build(self) def Release(self): return _Xdmf.XdmfMap_Release(self) XdmfMap_swigregister = _Xdmf.XdmfMap_swigregister XdmfMap_swigregister(XdmfMap) XDMF_DSM_OPCODE_DONE = _Xdmf.XDMF_DSM_OPCODE_DONE XDMF_DSM_TYPE_UNIFORM = _Xdmf.XDMF_DSM_TYPE_UNIFORM XDMF_DSM_TYPE_UNIFORM_RANGE = _Xdmf.XDMF_DSM_TYPE_UNIFORM_RANGE XDMF_DSM_TYPE_MIXED = _Xdmf.XDMF_DSM_TYPE_MIXED XDMF_DSM_DEFAULT_LENGTH = _Xdmf.XDMF_DSM_DEFAULT_LENGTH class XdmfDsm(XdmfObject): __swig_setmethods__ = {} for _s in [XdmfObject]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) __setattr__ = lambda self, name, value: _swig_setattr(self, XdmfDsm, name, value) __swig_getmethods__ = {} for _s in [XdmfObject]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) __getattr__ = lambda self, name: _swig_getattr(self, XdmfDsm, name) __repr__ = _swig_repr def __init__(self): this = _Xdmf.new_XdmfDsm() try: self.this.append(this) except: self.this = this __swig_destroy__ = _Xdmf.delete_XdmfDsm __del__ = lambda self : None; def GetClassName(self): return _Xdmf.XdmfDsm_GetClassName(self) def GetDsmType(self): return _Xdmf.XdmfDsm_GetDsmType(self) def SetDsmType(self, *args): return _Xdmf.XdmfDsm_SetDsmType(self, *args) def GetEndAddress(self): return _Xdmf.XdmfDsm_GetEndAddress(self) def SetEndAddress(self, *args): return _Xdmf.XdmfDsm_SetEndAddress(self, *args) def GetStartAddress(self): return _Xdmf.XdmfDsm_GetStartAddress(self) def SetStartAddress(self, *args): return _Xdmf.XdmfDsm_SetStartAddress(self, *args) def GetStartServerId(self): return _Xdmf.XdmfDsm_GetStartServerId(self) def SetStartServerId(self, *args): return _Xdmf.XdmfDsm_SetStartServerId(self, *args) def GetEndServerId(self): return _Xdmf.XdmfDsm_GetEndServerId(self) def SetEndServerId(self, *args): return _Xdmf.XdmfDsm_SetEndServerId(self, *args) def GetLength(self): return _Xdmf.XdmfDsm_GetLength(self) def SetLength(self, *args): return _Xdmf.XdmfDsm_SetLength(self, *args) def GetTotalLength(self): return _Xdmf.XdmfDsm_GetTotalLength(self) def SetTotalLength(self, *args): return _Xdmf.XdmfDsm_SetTotalLength(self, *args) def GetStorage(self): return _Xdmf.XdmfDsm_GetStorage(self) def SetStorage(self, *args): return _Xdmf.XdmfDsm_SetStorage(self, *args) def GetComm(self): return _Xdmf.XdmfDsm_GetComm(self) def SetComm(self, *args): return _Xdmf.XdmfDsm_SetComm(self, *args) def GetMsg(self): return _Xdmf.XdmfDsm_GetMsg(self) def SetMsg(self, *args): return _Xdmf.XdmfDsm_SetMsg(self, *args) def GetAddressRangeForId(self, *args): return _Xdmf.XdmfDsm_GetAddressRangeForId(self, *args) def ConfigureUniform(self, *args): return _Xdmf.XdmfDsm_ConfigureUniform(self, *args) def AddressToId(self, *args): return _Xdmf.XdmfDsm_AddressToId(self, *args) def SendCommandHeader(self, *args): return _Xdmf.XdmfDsm_SendCommandHeader(self, *args) def ReceiveCommandHeader(self, *args): return _Xdmf.XdmfDsm_ReceiveCommandHeader(self, *args) def SendData(self, *args): return _Xdmf.XdmfDsm_SendData(self, *args) def ReceiveData(self, *args): return _Xdmf.XdmfDsm_ReceiveData(self, *args) def Copy(self, *args): return _Xdmf.XdmfDsm_Copy(self, *args) def SendDone(self): return _Xdmf.XdmfDsm_SendDone(self) XdmfDsm_swigregister = _Xdmf.XdmfDsm_swigregister XdmfDsm_swigregister(XdmfDsm) XDMF_DSM_DEFAULT_TAG = _Xdmf.XDMF_DSM_DEFAULT_TAG XDMF_DSM_COMMAND_TAG = _Xdmf.XDMF_DSM_COMMAND_TAG XDMF_DSM_RESPONSE_TAG = _Xdmf.XDMF_DSM_RESPONSE_TAG XDMF_DSM_ANY_SOURCE = _Xdmf.XDMF_DSM_ANY_SOURCE class XdmfDsmMsg(XdmfObject): __swig_setmethods__ = {} for _s in [XdmfObject]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) __setattr__ = lambda self, name, value: _swig_setattr(self, XdmfDsmMsg, name, value) __swig_getmethods__ = {} for _s in [XdmfObject]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) __getattr__ = lambda self, name: _swig_getattr(self, XdmfDsmMsg, name) __repr__ = _swig_repr def __init__(self): this = _Xdmf.new_XdmfDsmMsg() try: self.this.append(this) except: self.this = this __swig_destroy__ = _Xdmf.delete_XdmfDsmMsg __del__ = lambda self : None; def SetSource(self, *args): return _Xdmf.XdmfDsmMsg_SetSource(self, *args) def GetSource(self): return _Xdmf.XdmfDsmMsg_GetSource(self) def SetDest(self, *args): return _Xdmf.XdmfDsmMsg_SetDest(self, *args) def GetDest(self): return _Xdmf.XdmfDsmMsg_GetDest(self) def SetTag(self, *args): return _Xdmf.XdmfDsmMsg_SetTag(self, *args) def GetTag(self): return _Xdmf.XdmfDsmMsg_GetTag(self) def SetLength(self, *args): return _Xdmf.XdmfDsmMsg_SetLength(self, *args) def GetLength(self): return _Xdmf.XdmfDsmMsg_GetLength(self) def SetData(self, *args): return _Xdmf.XdmfDsmMsg_SetData(self, *args) def GetData(self): return _Xdmf.XdmfDsmMsg_GetData(self) __swig_setmethods__["Source"] = _Xdmf.XdmfDsmMsg_Source_set __swig_getmethods__["Source"] = _Xdmf.XdmfDsmMsg_Source_get if _newclass:Source = _swig_property(_Xdmf.XdmfDsmMsg_Source_get, _Xdmf.XdmfDsmMsg_Source_set) __swig_setmethods__["Dest"] = _Xdmf.XdmfDsmMsg_Dest_set __swig_getmethods__["Dest"] = _Xdmf.XdmfDsmMsg_Dest_get if _newclass:Dest = _swig_property(_Xdmf.XdmfDsmMsg_Dest_get, _Xdmf.XdmfDsmMsg_Dest_set) __swig_setmethods__["Tag"] = _Xdmf.XdmfDsmMsg_Tag_set __swig_getmethods__["Tag"] = _Xdmf.XdmfDsmMsg_Tag_get if _newclass:Tag = _swig_property(_Xdmf.XdmfDsmMsg_Tag_get, _Xdmf.XdmfDsmMsg_Tag_set) __swig_setmethods__["Length"] = _Xdmf.XdmfDsmMsg_Length_set __swig_getmethods__["Length"] = _Xdmf.XdmfDsmMsg_Length_get if _newclass:Length = _swig_property(_Xdmf.XdmfDsmMsg_Length_get, _Xdmf.XdmfDsmMsg_Length_set) __swig_setmethods__["Data"] = _Xdmf.XdmfDsmMsg_Data_set __swig_getmethods__["Data"] = _Xdmf.XdmfDsmMsg_Data_get if _newclass:Data = _swig_property(_Xdmf.XdmfDsmMsg_Data_get, _Xdmf.XdmfDsmMsg_Data_set) XdmfDsmMsg_swigregister = _Xdmf.XdmfDsmMsg_swigregister XdmfDsmMsg_swigregister(XdmfDsmMsg) XDMF_DSM_MAX_LOCKS = _Xdmf.XDMF_DSM_MAX_LOCKS def XdmfDsmBufferServiceThread(*args): return _Xdmf.XdmfDsmBufferServiceThread(*args) XdmfDsmBufferServiceThread = _Xdmf.XdmfDsmBufferServiceThread class XdmfDsmBuffer(XdmfDsm): __swig_setmethods__ = {} for _s in [XdmfDsm]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) __setattr__ = lambda self, name, value: _swig_setattr(self, XdmfDsmBuffer, name, value) __swig_getmethods__ = {} for _s in [XdmfDsm]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) __getattr__ = lambda self, name: _swig_getattr(self, XdmfDsmBuffer, name) __repr__ = _swig_repr def __init__(self): this = _Xdmf.new_XdmfDsmBuffer() try: self.this.append(this) except: self.this = this __swig_destroy__ = _Xdmf.delete_XdmfDsmBuffer __del__ = lambda self : None; def GetClassName(self): return _Xdmf.XdmfDsmBuffer_GetClassName(self) def GetThreadDsmReady(self): return _Xdmf.XdmfDsmBuffer_GetThreadDsmReady(self) def SetThreadDsmReady(self, *args): return _Xdmf.XdmfDsmBuffer_SetThreadDsmReady(self, *args) def Put(self, *args): return _Xdmf.XdmfDsmBuffer_Put(self, *args) def Get(self, *args): return _Xdmf.XdmfDsmBuffer_Get(self, *args) def Aquire(self, *args): return _Xdmf.XdmfDsmBuffer_Aquire(self, *args) def Release(self, *args): return _Xdmf.XdmfDsmBuffer_Release(self, *args) def ServiceInit(self): return _Xdmf.XdmfDsmBuffer_ServiceInit(self) def ServiceOnce(self, ReturnOpcode = None): return _Xdmf.XdmfDsmBuffer_ServiceOnce(self, ReturnOpcode) def ServiceUntilIdle(self, ReturnOpcode = None): return _Xdmf.XdmfDsmBuffer_ServiceUntilIdle(self, ReturnOpcode) def ServiceLoop(self, ReturnOpcode = None): return _Xdmf.XdmfDsmBuffer_ServiceLoop(self, ReturnOpcode) def Service(self, ReturnOpcode = None): return _Xdmf.XdmfDsmBuffer_Service(self, ReturnOpcode) def ServiceThread(self): return _Xdmf.XdmfDsmBuffer_ServiceThread(self) XdmfDsmBuffer_swigregister = _Xdmf.XdmfDsmBuffer_swigregister XdmfDsmBuffer_swigregister(XdmfDsmBuffer) class XdmfDsmComm(XdmfObject): __swig_setmethods__ = {} for _s in [XdmfObject]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) __setattr__ = lambda self, name, value: _swig_setattr(self, XdmfDsmComm, name, value) __swig_getmethods__ = {} for _s in [XdmfObject]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) __getattr__ = lambda self, name: _swig_getattr(self, XdmfDsmComm, name) __repr__ = _swig_repr def __init__(self): this = _Xdmf.new_XdmfDsmComm() try: self.this.append(this) except: self.this = this __swig_destroy__ = _Xdmf.delete_XdmfDsmComm __del__ = lambda self : None; def GetClassName(self): return _Xdmf.XdmfDsmComm_GetClassName(self) def GetId(self): return _Xdmf.XdmfDsmComm_GetId(self) def SetId(self, *args): return _Xdmf.XdmfDsmComm_SetId(self, *args) def GetTotalSize(self): return _Xdmf.XdmfDsmComm_GetTotalSize(self) def SetTotalSize(self, *args): return _Xdmf.XdmfDsmComm_SetTotalSize(self, *args) def Init(self): return _Xdmf.XdmfDsmComm_Init(self) def Send(self, *args): return _Xdmf.XdmfDsmComm_Send(self, *args) def Receive(self, *args): return _Xdmf.XdmfDsmComm_Receive(self, *args) def Check(self, *args): return _Xdmf.XdmfDsmComm_Check(self, *args) def Barrier(self): return _Xdmf.XdmfDsmComm_Barrier(self) XdmfDsmComm_swigregister = _Xdmf.XdmfDsmComm_swigregister XdmfDsmComm_swigregister(XdmfDsmComm) class XdmfDsmCommMpi(XdmfDsmComm): __swig_setmethods__ = {} for _s in [XdmfDsmComm]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) __setattr__ = lambda self, name, value: _swig_setattr(self, XdmfDsmCommMpi, name, value) __swig_getmethods__ = {} for _s in [XdmfDsmComm]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) __getattr__ = lambda self, name: _swig_getattr(self, XdmfDsmCommMpi, name) __repr__ = _swig_repr def __init__(self): this = _Xdmf.new_XdmfDsmCommMpi() try: self.this.append(this) except: self.this = this __swig_destroy__ = _Xdmf.delete_XdmfDsmCommMpi __del__ = lambda self : None; def GetClassName(self): return _Xdmf.XdmfDsmCommMpi_GetClassName(self) def Init(self): return _Xdmf.XdmfDsmCommMpi_Init(self) def Send(self, *args): return _Xdmf.XdmfDsmCommMpi_Send(self, *args) def Receive(self, *args): return _Xdmf.XdmfDsmCommMpi_Receive(self, *args) def Check(self, *args): return _Xdmf.XdmfDsmCommMpi_Check(self, *args) def Barrier(self): return _Xdmf.XdmfDsmCommMpi_Barrier(self) XdmfDsmCommMpi_swigregister = _Xdmf.XdmfDsmCommMpi_swigregister XdmfDsmCommMpi_swigregister(XdmfDsmCommMpi) xdmf-3.0+git20160803/libsrc/XdmfGrid.cxx0000640000175000017500000007156013003006557017611 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : $Id: XdmfGrid.cxx,v 1.38 2010-03-18 15:24:25 kwleiter Exp $ */ /* Date : $Date: 2010-03-18 15:24:25 $ */ /* Version : $Revision: 1.38 $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2002 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #include "XdmfGrid.h" #include "XdmfDOM.h" #include "XdmfDataItem.h" #include "XdmfArray.h" #include "XdmfTopology.h" #include "XdmfGeometry.h" #include "XdmfInformation.h" #include "XdmfAttribute.h" #include "XdmfTime.h" #include "XdmfSet.h" XdmfGrid *HandleToXdmfGrid( XdmfString Source ){ XdmfObject *TempObj; XdmfGrid *Grid; TempObj = HandleToXdmfObject( Source ); Grid = (XdmfGrid *)TempObj; // XdmfErrorMessage("Pointer = " << Source); // XdmfErrorMessage("Grid = " << Grid ); // XdmfErrorMessage("Name " << Grid->GetClassName() ); // XdmfErrorMessage("Type " << Grid->GetTopologyTypeAsString() ); return( Grid ); } XdmfGrid::XdmfGrid() { this->SetElementName("Grid"); this->Geometry = new XdmfGeometry; this->GeometryIsMine = 1; this->Topology = new XdmfTopology; this->TopologyIsMine = 1; this->Time = new XdmfTime; this->TimeIsMine = 1; this->Sets = (XdmfSet **)calloc(1, sizeof( XdmfSet * )); this->Attribute = (XdmfAttribute **)calloc(1, sizeof( XdmfAttribute * )); this->Children = (XdmfGrid **)calloc(1, sizeof( XdmfGrid * )); this->Informations = (XdmfInformation **)calloc(1, sizeof( XdmfInformation * )); this->AssignedAttribute = NULL; this->NumberOfSets = 0; this->NumberOfAttributes = 0; this->NumberOfInformations = 0; this->GridType = XDMF_GRID_UNSET; this->CollectionType = XDMF_GRID_COLLECTION_UNSET; this->NumberOfChildren = 0; this->Debug = 0; this->BuildTime = 0; } XdmfGrid::~XdmfGrid() { XdmfInt32 Index; if( this->GeometryIsMine && this->Geometry ) delete this->Geometry; if( this->TopologyIsMine && this->Topology ) delete this->Topology; if( this->TimeIsMine && this->Time ) delete this->Time; for ( Index = 0; Index < this->NumberOfAttributes; Index ++ ){ if (this->Attribute[Index]->GetDeleteOnGridDelete()){ delete this->Attribute[Index]; } } free(this->Attribute); for ( Index = 0; Index < this->NumberOfChildren; Index ++ ){ if (this->Children[Index]->GetDeleteOnGridDelete()){ delete this->Children[Index]; } } free(this->Children); for ( Index = 0; Index < this->NumberOfSets; Index ++ ){ if (this->Sets[Index]->GetDeleteOnGridDelete()){ delete this->Sets[Index]; } } free(this->Sets); free(this->Informations); } XdmfInt32 XdmfGrid::Release(){ XdmfInt32 Index; if( this->GeometryIsMine && this->Geometry ) this->Geometry->Release(); if( this->TopologyIsMine && this->Topology ) this->Topology->Release(); for ( Index = 0; Index < this->NumberOfAttributes; Index ++ ) { this->Attribute[Index]->Release(); } return(XDMF_SUCCESS); } XdmfInt32 XdmfGrid::InsertTopology(){ if(!this->Topology->GetElement()){ XdmfXmlNode node; node = this->GetDOM()->InsertNew(this->GetElement(), "Topology"); if(!node) return(XDMF_FAIL); this->Topology->SetDOM(this->GetDOM()); if(this->Topology->SetElement(node) != XDMF_SUCCESS) return(XDMF_FAIL); } return(XDMF_SUCCESS); } XdmfInt32 XdmfGrid::InsertGeometry(){ if(!this->Geometry->GetElement()){ XdmfXmlNode node; node = this->GetDOM()->InsertNew(this->GetElement(), "Geometry"); if(!node) return(XDMF_FAIL); this->Geometry->SetDOM(this->GetDOM()); if(this->Geometry->SetElement(node) != XDMF_SUCCESS) return(XDMF_FAIL); } return(XDMF_SUCCESS); } XdmfInt32 XdmfGrid::Insert( XdmfElement *Child){ if(Child && ( XDMF_WORD_CMP(Child->GetElementName(), "Grid") || XDMF_WORD_CMP(Child->GetElementName(), "Geometry") || XDMF_WORD_CMP(Child->GetElementName(), "Topology") || XDMF_WORD_CMP(Child->GetElementName(), "Attribute") || XDMF_WORD_CMP(Child->GetElementName(), "Region") || XDMF_WORD_CMP(Child->GetElementName(), "Set") || XDMF_WORD_CMP(Child->GetElementName(), "DataItem") || XDMF_WORD_CMP(Child->GetElementName(), "Time") || XDMF_WORD_CMP(Child->GetElementName(), "Information") )){ XdmfInt32 status = XdmfElement::Insert(Child); if((status == XDMF_SUCCESS) && XDMF_WORD_CMP(Child->GetElementName(), "Set")){ XdmfSet *ChildSet = (XdmfSet *)Child; this->NumberOfSets++; this->Sets = ( XdmfSet **)realloc( this->Sets, this->NumberOfSets * sizeof( XdmfSet * )); if(!this->Sets) { XdmfErrorMessage("Realloc of Set List Failed"); return(XDMF_FAIL); } this->Sets[this->NumberOfSets - 1] = ChildSet; } if((status == XDMF_SUCCESS) && XDMF_WORD_CMP(Child->GetElementName(), "Information")){ XdmfInformation *ChildInfo = (XdmfInformation *)Child; this->NumberOfInformations++; this->Informations = ( XdmfInformation **)realloc( this->Informations, this->NumberOfInformations * sizeof( XdmfInformation * )); if(!this->Informations) { XdmfErrorMessage("Realloc of Information List Failed"); return(XDMF_FAIL); } this->Informations[this->NumberOfInformations - 1] = ChildInfo; } if((status == XDMF_SUCCESS) && XDMF_WORD_CMP(Child->GetElementName(), "Attribute")){ XdmfAttribute *ChildAttr = (XdmfAttribute *)Child; this->NumberOfAttributes++; this->Attribute = ( XdmfAttribute **)realloc( this->Attribute, this->NumberOfAttributes * sizeof( XdmfAttribute * )); if(!this->Attribute) { XdmfErrorMessage("Realloc of Attribute List Failed"); return(XDMF_FAIL); } this->Attribute[this->NumberOfAttributes - 1] = ChildAttr; } if((status == XDMF_SUCCESS) && XDMF_WORD_CMP(Child->GetElementName(), "Grid")){ XdmfGrid *ChildGrid = (XdmfGrid *)Child; XdmfInt32 nchild = this->NumberOfChildren + 1; this->Children = (XdmfGrid **)realloc(this->Children, nchild * sizeof(XdmfGrid *)); this->Children[this->NumberOfChildren] = ChildGrid; this->NumberOfChildren = nchild; if((ChildGrid->GridType & XDMF_GRID_MASK) == XDMF_GRID_UNIFORM){ if(ChildGrid->InsertTopology() != XDMF_SUCCESS) return(XDMF_FAIL); if(ChildGrid->InsertGeometry() != XDMF_SUCCESS) return(XDMF_FAIL); } return(XDMF_SUCCESS); } if (status == XDMF_SUCCESS) return(XDMF_SUCCESS); }else{ XdmfErrorMessage("Grid can only Insert Grid | Geometry | Topology | Attribute | Set | Region | DataItem | Information elements, not a " << Child->GetElementName()); } return(XDMF_FAIL); } XdmfInt32 XdmfGrid::Build(){ if(XdmfElement::Build() != XDMF_SUCCESS) return(XDMF_FAIL); this->Set("GridType", this->GetGridTypeAsString()); if(this->GridType == XDMF_GRID_COLLECTION){ this->Set("CollectionType", this->GetCollectionTypeAsString()); } /* if((this->GridType & XDMF_GRID_MASK) == XDMF_GRID_UNIFORM){ if(this->InsertTopology() != XDMF_SUCCESS) return(XDMF_FAIL); this->Topology->Build(); if(this->InsertGeometry() != XDMF_SUCCESS) return(XDMF_FAIL); this->Geometry->Build(); }else{ } */ if(this->BuildTime && this->Time){ if(!this->Time->GetDOM()){ if(this->Insert(this->Time) != XDMF_SUCCESS){ XdmfErrorMessage("Grid Cannot Insert current XdmfTime"); return(XDMF_FAIL); } } if(this->Time->Build() != XDMF_SUCCESS) return(XDMF_FAIL); } return(XDMF_SUCCESS); } XdmfInt32 XdmfGrid::SetCollectionTypeFromString(XdmfConstString aCollectionType){ if(XDMF_WORD_CMP(aCollectionType, "Temporal")){ this->SetCollectionType(XDMF_GRID_COLLECTION_TEMPORAL); }else if(XDMF_WORD_CMP(aCollectionType, "Spatial")){ this->SetCollectionType(XDMF_GRID_COLLECTION_SPATIAL); }else{ XdmfErrorMessage("Unknown Collection Type : " << aCollectionType); return(XDMF_FAIL); } return(XDMF_SUCCESS); } XdmfInt32 XdmfGrid::SetGridTypeFromString(XdmfConstString aGridType){ if(XDMF_WORD_CMP(aGridType, "Uniform")){ this->SetGridType(XDMF_GRID_UNIFORM); }else if(XDMF_WORD_CMP(aGridType, "Tree")){ this->SetGridType(XDMF_GRID_TREE); }else if(XDMF_WORD_CMP(aGridType, "Collection")){ this->SetGridType(XDMF_GRID_COLLECTION); }else if(XDMF_WORD_CMP(aGridType, "Subset")){ this->SetGridType(XDMF_GRID_SUBSET); }else{ XdmfErrorMessage("Unknown Grid Type : " << aGridType); return(XDMF_FAIL); } return(XDMF_SUCCESS); } XdmfConstString XdmfGrid::GetCollectionTypeAsString(){ if((this->GridType & XDMF_GRID_MASK) == XDMF_GRID_COLLECTION){ switch(this->CollectionType){ case XDMF_GRID_COLLECTION_TEMPORAL : return("Temporal"); case XDMF_GRID_COLLECTION_SPATIAL : return("Spatial"); default : return("Unset"); } } return(0); } XdmfConstString XdmfGrid::GetGridTypeAsString(){ if(this->GridType & XDMF_GRID_MASK){ switch(this->GridType & XDMF_GRID_MASK) { case XDMF_GRID_UNIFORM : return("Uniform"); case XDMF_GRID_COLLECTION : return("Collection"); case XDMF_GRID_TREE : return("Tree"); case XDMF_GRID_SUBSET : return("Subset"); default : XdmfErrorMessage("Unknown Grid Type"); return(0); } }else{ return("Uniform"); } } // Derived Version XdmfInt32 XdmfGrid::Copy(XdmfElement *Source){ XdmfGrid *g; XdmfDebug("XdmfGrid::Copy(XdmfElement *Source)"); g = (XdmfGrid *)Source; // cout << "Copy Grid Information from " << g << endl; this->Topology = g->GetTopology(); this->TopologyIsMine = 0; if( this->GeometryIsMine && this->Geometry ) delete this->Geometry; this->Geometry = g->GetGeometry(); this->GeometryIsMine = 0; return(XDMF_SUCCESS); } XdmfInt32 XdmfGrid::AssignAttribute( XdmfAttribute *attribute ){ XdmfInt32 Status = 0; if( attribute ){ if(!attribute->GetDsmBuffer()) attribute->SetDsmBuffer(this->DsmBuffer); attribute->Update(); // Status = attribute->SetBaseAttribute( this, this->BaseGrid ); this->AssignedAttribute = attribute; } else { XdmfErrorMessage("Attribute is NULL"); return( XDMF_FAIL ); } return( Status ); } XdmfInt32 XdmfGrid::AssignAttribute( XdmfInt64 Index ){ XdmfInt32 Status; Status = this->AssignAttribute( this->Attribute[ Index ] ); return( Status ); } XdmfInt32 XdmfGrid::AssignAttributeByIndex( XdmfInt64 Index ){ XdmfInt32 Status; Status = this->AssignAttribute( this->Attribute[ Index ] ); return( Status ); } XdmfInt32 XdmfGrid::AssignAttributeByName( XdmfString name ){ XdmfInt64 i; XdmfInt32 Status = XDMF_FAIL; for( i = 0 ; i < this->NumberOfAttributes ; i++ ){ if( XDMF_WORD_CMP( this->Attribute[i]->GetName(), name ) ){ Status = this->AssignAttribute( this->Attribute[ i ] ); break; } } return( Status ); } XdmfInt64 XdmfGrid::GetAssignedAttributeIndex( void ){ XdmfInt64 i; for( i = 0 ; i < this->NumberOfAttributes ; i++ ){ if( this->AssignedAttribute == this->Attribute[ i ] ){ return( i ); } } return(0); } XdmfInt32 XdmfGrid::UpdateInformation() { XdmfXmlNode anElement; XdmfInt32 Status = XDMF_FAIL; XdmfConstString attribute; if(XdmfElement::UpdateInformation() != XDMF_SUCCESS) return(XDMF_FAIL); if( XDMF_WORD_CMP(this->GetElementType(), "Grid") == 0){ XdmfErrorMessage("Element type" << this->GetElementType() << " is not of type 'Grid'"); return(XDMF_FAIL); } // Allow for "GridType" or "Type" attribute = this->Get("GridType"); if(!attribute) attribute = this->Get("Type"); if( XDMF_WORD_CMP(attribute, "Collection") ){ free((void*)attribute); this->GridType = XDMF_GRID_COLLECTION; attribute = this->Get("CollectionType"); if(attribute){ if( XDMF_WORD_CMP(attribute, "Temporal") ){ this->SetCollectionType(XDMF_GRID_COLLECTION_TEMPORAL); }else if( XDMF_WORD_CMP(attribute, "Spatial") ){ this->SetCollectionType(XDMF_GRID_COLLECTION_SPATIAL); } } }else if( XDMF_WORD_CMP(attribute, "Subset") ){ this->GridType = XDMF_GRID_SUBSET; }else if( XDMF_WORD_CMP(attribute, "Tree") ){ this->GridType = XDMF_GRID_TREE; }else if( XDMF_WORD_CMP(attribute, "Uniform") ){ this->GridType = XDMF_GRID_UNIFORM; }else{ if(attribute){ XdmfErrorMessage("Unknown Grid Type " << attribute); free((void*)attribute); return(XDMF_FAIL); } // If Type is NULL use default this->GridType = XDMF_GRID_UNIFORM; } free((void*)attribute); if( this->GridType & XDMF_GRID_MASK){ // SubSet Tree or Collection XdmfInt32 i, nchild; XdmfXmlNode node; nchild = this->NumberOfChildren; if (this->Children && nchild){ for(i=0 ; i < nchild ; i++){ delete this->Children[i]; } } nchild = this->DOM->FindNumberOfElements("Grid", this->Element); this->NumberOfChildren = nchild; this->Children = (XdmfGrid **)realloc(this->Children, nchild * sizeof(XdmfGrid *)); anElement = this->DOM->FindElement("Time", 0, this->Element); if(anElement){ if(this->Time->SetDOM( this->DOM ) == XDMF_FAIL) return(XDMF_FAIL); if(this->Time->SetElement(anElement) == XDMF_FAIL) return(XDMF_FAIL); Status = this->Time->UpdateInformation(); if( Status == XDMF_FAIL ){ XdmfErrorMessage("Error Reading Time"); return( XDMF_FAIL ); } } anElement = this->DOM->FindElement("Geometry", 0, this->Element); for(i=0 ; i < nchild ; i++){ if (i==0) { node = this->DOM->FindElement("Grid", i, this->Element); } else { node = this->DOM->FindNextElement("Grid", node); } if(!node) { XdmfErrorMessage("Can't find Child Grid #" << i); return(XDMF_FAIL); } this->Children[i] = new XdmfGrid; this->Children[i]->SetDeleteOnGridDelete(true); if(this->Children[i]->SetDOM(this->DOM) == XDMF_FAIL) { delete this->Children[i]; return(XDMF_FAIL); } if(this->Children[i]->SetElement(node) == XDMF_FAIL) { delete this->Children[i]; return(XDMF_FAIL); } // cout << "Calling update info for child " << i << endl; if(this->Children[i]->UpdateInformation() == XDMF_FAIL) { delete this->Children[i]; return(XDMF_FAIL); } if(this->Time->GetTimeType() != XDMF_TIME_UNSET) { if(this->Children[i]->GetTime()->SetTimeFromParent(this->Time, i) != XDMF_SUCCESS) { delete this->Children[i]; return(XDMF_FAIL); } } } if((this->GridType & XDMF_GRID_MASK) == XDMF_GRID_SUBSET){ // Selection is the First Element Under Grid XdmfXmlNode select = 0; XdmfGrid *target; XdmfDataDesc *shape; // cout << "Getting SubGrid Selection " << endl; attribute = this->Get("Section"); if( XDMF_WORD_CMP(attribute, "All") ){ // cout << ":::: Selecting ALL" << endl; this->GridType |= XDMF_GRID_SECTION_ALL; }else if( XDMF_WORD_CMP(attribute, "DataItem") ){ // cout << ":::: Selecting DataItem 1" << endl; this->GridType |= XDMF_GRID_SECTION_DATA_ITEM; select = this->DOM->FindElement("DataItem", 0, this->Element); if(!select){ XdmfErrorMessage("Section = DataItem but DataItem == 0"); free((void*)attribute); return(XDMF_FAIL); } }else{ // default // cout << ":::: Selecting DataItem 2" << endl; select = this->DOM->FindElement("DataItem", 0, this->Element); if(select){ this->GridType |= XDMF_GRID_SECTION_DATA_ITEM; }else{ this->GridType |= XDMF_GRID_SECTION_ALL; } } free((void*)attribute); target = this->Children[0]; if(!target){ XdmfErrorMessage("No Target Grid Spceified for Subset"); return(XDMF_FAIL); } if(this->GridType & XDMF_GRID_SECTION_ALL) { /* shape = this->Topology->GetShapeDesc(); shape->CopyShape(target->GetTopology()->GetShapeDesc()); */ if(this->TopologyIsMine && this->Topology) delete this->Topology; this->Topology = target->GetTopology(); this->TopologyIsMine = 0; }else if(select){ XdmfDataItem *di = new XdmfDataItem; di->SetDOM(this->DOM); di->SetElement(select); di->UpdateInformation(); di->Update(); // cout << "UpdateInfo - Select Cells : " << di->GetArray()->GetValues() << endl; shape = this->Topology->GetShapeDesc(); shape->CopyShape(di->GetDataDesc()); delete di; this->Topology->SetTopologyType(target->GetTopology()->GetTopologyType()); this->Topology->SetNodesPerElement(target->GetTopology()->GetNodesPerElement()); } } // return(XDMF_SUCCESS); }else{ // Handle Uniform Grid // cout << "Update Uniform Grid" << endl; anElement = this->DOM->FindElement("Time", 0, this->Element); if(anElement){ if(this->Time->SetDOM( this->DOM ) == XDMF_FAIL) return(XDMF_FAIL); if(this->Time->SetElement(anElement) == XDMF_FAIL) return(XDMF_FAIL); Status = this->Time->UpdateInformation(); if( Status == XDMF_FAIL ){ XdmfErrorMessage("Error Reading Time"); return( XDMF_FAIL ); } } anElement = this->DOM->FindElement("Topology", 0, this->Element); if(anElement){ if(this->Topology->SetDOM( this->DOM ) == XDMF_FAIL) return(XDMF_FAIL); if(this->Topology->SetElement(anElement) == XDMF_FAIL) return(XDMF_FAIL); Status = this->Topology->UpdateInformation(); if( Status == XDMF_FAIL ){ XdmfErrorMessage("Error Reading Topology"); return( XDMF_FAIL ); } } anElement = this->DOM->FindElement("Geometry", 0, this->Element); if(anElement){ if(this->Geometry->SetDOM( this->DOM ) == XDMF_FAIL) return(XDMF_FAIL); if(this->Geometry->SetElement(anElement) == XDMF_FAIL) return(XDMF_FAIL); Status = this->Geometry->UpdateInformation(); if( Status == XDMF_FAIL ){ XdmfErrorMessage("Error Reading Geometry"); return( XDMF_FAIL ); } } } if(!this->Name) this->SetName( GetUnique("Grid_" ) ); // Get Attributes XdmfInt32 OldNumberOfAttributes = this->NumberOfAttributes; this->NumberOfAttributes = this->DOM->FindNumberOfElements("Attribute", this->Element ); if( this->NumberOfAttributes > 0 ){ XdmfInt32 Index; XdmfAttribute *iattribute; XdmfXmlNode AttributeElement; for ( Index = 0; Index < OldNumberOfAttributes; Index ++ ) { delete this->Attribute[Index]; } this->Attribute = ( XdmfAttribute **)realloc( this->Attribute, this->NumberOfAttributes * sizeof( XdmfAttribute * )); for( Index = 0 ; Index < this->NumberOfAttributes ; Index++ ){ iattribute = new XdmfAttribute; iattribute->SetDeleteOnGridDelete(true); this->Attribute[Index] = iattribute; if (Index == 0) { AttributeElement = this->DOM->FindElement( "Attribute", Index, this->Element ); } else { AttributeElement = this->DOM->FindNextElement( "Attribute", AttributeElement); } iattribute->SetDOM( this->DOM ); iattribute->SetElement( AttributeElement ); iattribute->UpdateInformation(); } } // Get Sets XdmfInt32 OldNumberOfSets = this->NumberOfSets; this->NumberOfSets = this->DOM->FindNumberOfElements("Set", this->Element ); if( this->NumberOfSets > 0 ){ XdmfInt32 Index; XdmfSet *iSet; XdmfXmlNode lSetElement; for ( Index = 0; Index < OldNumberOfSets; Index ++ ) { delete this->Sets[Index]; } this->Sets = ( XdmfSet **)realloc( this->Sets, this->NumberOfSets * sizeof( XdmfSet * )); for( Index = 0 ; Index < this->NumberOfSets ; Index++ ){ iSet = new XdmfSet; iSet->SetDeleteOnGridDelete(true); this->Sets[Index] = iSet; if (Index==0) { lSetElement = this->DOM->FindElement( "Set", Index, this->Element ); } else { lSetElement = this->DOM->FindNextElement( "Set", lSetElement); } iSet->SetDOM( this->DOM ); iSet->SetElement( lSetElement ); iSet->UpdateInformation(); } } return( XDMF_SUCCESS ); } XdmfInt32 XdmfGrid::Update() { //cout << " In Update" << endl; if(XdmfElement::Update() != XDMF_SUCCESS) return(XDMF_FAIL); if(this->GridType == XDMF_GRID_UNSET) { if(this->UpdateInformation() == XDMF_FAIL){ XdmfErrorMessage("Error Initializing Grid"); return(XDMF_FAIL); } } if((this->GridType & XDMF_GRID_MASK) != XDMF_GRID_UNIFORM){ XdmfInt32 i; // SubSet, Tree or Collection for(i=0; i < this->NumberOfChildren ; i++){ if(!this->Children[i]->GetDsmBuffer()) this->Children[i]->SetDsmBuffer(this->DsmBuffer); if(this->Children[i]->Update() == XDMF_FAIL){ XdmfErrorMessage("Error in Update() of Child Grid " << i); return(XDMF_FAIL); } } if((this->GridType & XDMF_GRID_MASK) == XDMF_GRID_SUBSET){ // Selection is the First Element Under Grid XdmfXmlNode select; XdmfGrid *target; // cout << " Getting SubSet" << endl; target = this->Children[0]; if( this->GeometryIsMine && this->Geometry ) delete this->Geometry; this->Geometry = target->GetGeometry(); this->GeometryIsMine = 0; if((this->GridType & XDMF_GRID_SECTION_MASK) == XDMF_GRID_SECTION_ALL){ // cout << " Getting SubSet all" << endl; if(this->TopologyIsMine && this->Topology) delete this->Topology; this->Topology = target->GetTopology(); this->TopologyIsMine = 0; // cout << "Conns = " << this->Topology->GetConnectivity()->GetValues() << endl; // cout << " Done Getting SubSet all" << endl; }else if((this->GridType & XDMF_GRID_SECTION_MASK) == XDMF_GRID_SECTION_DATA_ITEM){ // cout << "Getting SubGrid Selection " << endl; select = this->DOM->FindDataElement(0, this->Element); if(select){ XdmfDataItem *di = new XdmfDataItem; XdmfArray *celloff, *newconn; XdmfInt64 i1, o, o1, len, total; XdmfInt64 *cell, cellsize = 100; cell = new XdmfInt64[ cellsize ]; di->SetDOM(this->DOM); di->SetElement(select); di->UpdateInformation(); di->Update(); // cout << "Update - Select Cells : " << di->GetArray()->GetValues() << endl; celloff = target->GetTopology()->GetCellOffsets(); newconn = new XdmfArray; newconn->SetNumberOfElements(target->GetTopology()->GetConnectivity()->GetNumberOfElements()); total = 0; for(i1=0; i1< di->GetArray()->GetNumberOfElements() ; i1++){ o = celloff->GetValueAsInt64(di->GetArray()->GetValueAsInt64(i1)); o1 = celloff->GetValueAsInt64(di->GetArray()->GetValueAsInt64(i1) + 1); // cout << " Getting " << o << " thru " << o1 << endl; len = o1 - o; if(len > cellsize){ cellsize = len + 1; delete [] cell; cell = new XdmfInt64[ cellsize ]; } // cout << " Conns = " << target->GetTopology()->GetConnectivity()->GetValues(o, len) << endl; if(target->GetTopology()->GetConnectivity()->GetValues(o, cell, len) != XDMF_SUCCESS){ XdmfErrorMessage("Error Getting Cell Connectivity " << o << " to " << o1 ); return(XDMF_FAIL); } newconn->SetValues(total, cell, len); // cout << " Offset " << i1 << " = " << o << " len = " << len << " total " << total << endl; total += len; } newconn->SetNumberOfElements(total); this->Topology->SetConnectivity(newconn); delete [] cell; } } } return(XDMF_SUCCESS); } if(!this->Topology->GetDsmBuffer()) this->Topology->SetDsmBuffer(this->DsmBuffer); if(this->Topology->Update() == XDMF_FAIL){ XdmfErrorMessage("Error in Update() of Topology"); return(XDMF_FAIL); } if(!this->Geometry->GetDsmBuffer()) this->Geometry->SetDsmBuffer(this->DsmBuffer); if(this->Geometry->Update() == XDMF_FAIL){ XdmfErrorMessage("Error in Update() of Geometry"); return(XDMF_FAIL); } return( XDMF_SUCCESS ); } XdmfGrid * XdmfGrid::GetChild(XdmfInt32 Index){ if(this->GridType & XDMF_GRID_MASK){ if(Index < this->NumberOfChildren){ return(this->Children[Index]); }else{ XdmfErrorMessage("Grid has " << this->NumberOfChildren << " children. Index " << Index << " is out of range"); } }else{ XdmfErrorMessage("Grid is Uniform so it has no children"); } return(NULL); } XdmfInformation * XdmfGrid::GetInformation(XdmfInt32 Index){ if(Index < this->NumberOfInformations){ return(this->Informations[Index]); }else{ XdmfErrorMessage("Grid has " << this->NumberOfInformations << " children. Index " << Index << " is out of range"); } return(NULL); } XdmfInt32 XdmfGrid::IsUniform(){ if(this->GridType & XDMF_GRID_MASK) return(XDMF_FALSE); return(XDMF_TRUE); } XdmfInt32 XdmfGrid::FindGridsAtTime(XdmfTime *theTime, XdmfArray *ArrayToFill, XdmfFloat64 Epsilon, XdmfInt32 Append){ XdmfInt64 i, index = 0, nchild; nchild = this->GetNumberOfChildren(); if(!nchild) return(XDMF_FALSE); if(Append){ index = ArrayToFill->GetNumberOfElements(); ArrayToFill->SetNumberOfElements(index + nchild); }else{ index = 0; ArrayToFill->SetNumberOfElements(nchild); } for(i=0 ; i < this->GetNumberOfChildren() ; i++){ // cout << "IsValid(" << i << ") = " << this->GetChild(i)->GetTime()->IsValid(Time) << endl; if(this->GetChild(i)->GetTime()->IsValid(theTime)){ ArrayToFill->SetValueFromInt64(index, i); index++; } } if(index){ // Squeeze ArrayToFill->SetNumberOfElements(index); }else{ return(XDMF_FAIL); } return(XDMF_SUCCESS); } XdmfInt32 XdmfGrid::FindGridsInTimeRange(XdmfFloat64 TimeMin, XdmfFloat64 TimeMax, XdmfArray *ArrayToFill){ XdmfInt64 i, index = 0, nchild; nchild = this->GetNumberOfChildren(); if(!nchild) return(XDMF_FALSE); ArrayToFill->SetNumberType(XDMF_INT64_TYPE); ArrayToFill->SetNumberOfElements(nchild); for(i=0 ; i < nchild ; i++){ // cout << "IsValid(" << i << ") = " << this->GetChild(i)->GetTime()->IsValid(TimeMin, TimeMax) << endl; if(this->GetChild(i)->GetTime()->IsValid(TimeMin, TimeMax)){ ArrayToFill->SetValueFromInt64(index, i); index++; } } if(index){ // Squeeze ArrayToFill->SetNumberOfElements(index); }else{ return(XDMF_FAIL); } return(XDMF_SUCCESS); } xdmf-3.0+git20160803/libsrc/XdmfDomain.h0000640000175000017500000000442513003006557017554 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : $Id: XdmfDomain.h,v 1.3 2009-01-23 20:31:39 clarke Exp $ */ /* Date : $Date: 2009-01-23 20:31:39 $ */ /* Version : $Revision: 1.3 $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2002 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #ifndef __XdmfDomain_h #define __XdmfDomain_h #include "XdmfElement.h" /*! XdmfDomain represents the Domain Element in Xdmf. In XML it is the Element : \verbatim The Xdmf element may have Information and DataItem Elements as children XML Element : Domain XML Attribute : Name = Any String \endverbatim */ class XDMF_EXPORT XdmfDomain : public XdmfElement { public: XdmfDomain(); ~XdmfDomain(); XdmfConstString GetClassName() { return ( "XdmfDomain" ) ; }; //! Update From XML XdmfInt32 UpdateInformation(); //! Insert an Element XdmfInt32 Insert (XdmfElement *Child); //! Update the DOM XdmfInt32 Build(); protected: }; #endif // __XdmfDomain_h xdmf-3.0+git20160803/libsrc/Xdmf.i0000640000175000017500000000611513003006557016423 0ustar alastairalastair/* To create C++ files: ICE_INCLUDES="-I${Xdmf_SOURCE_DIR} -I${Xdmf_SOURCE_DIR}/libsrc -I${Xdmf_BINARY_DIR}/libsrc -I${Xdmf_BINARY_DIR}/Ice/libsrc" XdmfTcl.cxx: swig -v -c++ -make_default -includeall -tcl -prefix Xdmf -namespace ${ICE_INCLUDES} -o XdmfTcl.cxx Xdmf.i XdmfPython.cxx: swig -v -c++ -make_default -includeall -python -shadow $(ICE_INCLUDES) -o XdmfPython.cxx ${srcdir}/Xdmf.i XdmfJava.cxx: swig -v -c++ -make_default -includeall -shadow -java $(ICE_INCLUDES) -o XdmfJava.cxx ${srcdir}/Xdmf.i; */ %module Xdmf %{ /* #include */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* #include #include #include #include */ #include #include #include #include #include #include #include #include #include #include /* #include #include #include #include */ #include #include #include #include #ifndef XDMF_NO_MPI #include #endif #ifndef HAVE_STRTOLL # define strtoll XDMF_strtoll inline XDMF_LONG64 XDMF_strtoll(char *str, void*, int) { XDMF_LONG64 result = 0; int negative=0; while (*str == ' ' || *str == '\t') { str++; } if (*str == '+') { str++; } else if (*str == '-') { negative = 1; str++; } while (*str >= '0' && *str <= '9') { result = (result*10)-(*str++ - '0'); } return negative ? result : -result; } #else # define XDMF_strtoll strtoll #endif %} %include std_string.i /* %include XdmfCharArray.h */ %include XdmfAttribute.h %include XdmfArray.h %include XdmfDOM.h %include XdmfLightData.h %include XdmfInformation.h %include XdmfElement.h %include XdmfDataDesc.h %include XdmfDataStructure.h %include XdmfValues.h %include XdmfValuesXML.h %include XdmfValuesHDF.h %include XdmfExpression.h /* %include XdmfFormat.h %include XdmfFormatHDF.h %include XdmfFormatMulti.h %include XdmfFormatXML.h %include XdmfHDFSupport.h */ %include XdmfHeavyData.h %include XdmfHDF.h %include XdmfObject.h %include XdmfDomain.h %include XdmfRoot.h %include XdmfTopology.h %include XdmfGeometry.h %include XdmfGrid.h %include XdmfTime.h %include XdmfRegion.h %include XdmfSet.h %include XdmfMap.h /* %include XdmfParameter.h %include XdmfTransform.h %include XdmfXNode.h %include XdmfNDGM.h */ %include XdmfDsm.h %include XdmfDsmMsg.h %include XdmfDsmBuffer.h %include XdmfDsmComm.h #ifndef XDMF_NO_MPI %include XdmfDsmCommMpi.h #endif #ifdef SWIGPYTHON %{ void XdmfSwigException(int code, const char* msg) { /* SWIG_exception(code, msg); */ } %} #endif xdmf-3.0+git20160803/libsrc/XdmfRegion.h0000640000175000017500000000423613003006557017570 0ustar alastairalastair#ifndef __XdmfRegion_h #define __XdmfRegion_h #include "XdmfElement.h" // Where Values are Assigned #define XDMF_REGION_TYPE_UNSET -1 #define XDMF_REGION_TYPE_CELL 1 #define XDMF_REGION_TYPE_FACE 2 #define XDMF_REGION_TYPE_EDGE 3 #define XDMF_REGION_TYPE_NODE 4 // Forward declaration of Xdmf classes class XdmfTopology; class XdmfDataDesc; class XdmfArray; //! Class to support data side Regions. /*! XdmfRegion is a Class that handles sets of nodes,cells on an XdmfGrid. They may be centered on the Node, Edge, Face, Cell, or Grid. \verbatim XML Element Name : Region XML Region : Name XML Region : Center = Node* | Cell | Grid | Face | Edge Example : 1 2 3 4 \endverbatim */ class XDMF_EXPORT XdmfRegion : public XdmfElement{ public: XdmfRegion(); ~XdmfRegion(); XdmfConstString GetClassName() { return ( "XdmfRegion" ) ; }; XdmfInt32 SetRegionTypeFromString( XdmfConstString RegionType ); XdmfConstString GetRegionTypeAsString( void ); //! Set the Center /*! Set where the Group is centered \param Value XDMF_REGION_TYPE_CELL | XDMF_REGION_TYPE_FACE | XDMF_REGION_TYPE_EDGE | XDMF_REGION_TYPE_NODE */ XdmfSetValueMacro( RegionType, XdmfInt32 ); //! Returns the Center of the Attribute XdmfGetValueMacro( RegionType, XdmfInt32 ); //! Returns the Shape of the attribute XdmfDataDesc *GetShapeDesc( void ) { return( this->ShapeDesc ); }; //! Insert an Element XdmfInt32 Insert(XdmfElement *Child); //! Sets the values for the Attribute XdmfInt32 SetValues(XdmfArray *Values); //! Retrieves the Values of the Attribute, create one by default XdmfArray *GetValues(XdmfInt32 Create=1); //! Initialize but don't read the Heavy Data XdmfInt32 UpdateInformation(); //! Initialize and Read the Heavy Data XdmfInt32 Update(); //! Build XML (output) XdmfInt32 Build(); //! Release Big Data XdmfInt32 Release(); protected: XdmfInt32 RegionType; XdmfDataDesc *ShapeDesc; XdmfInt32 ValuesAreMine; XdmfArray *Values; XdmfInt32 Active; }; #endif // __XdmfGroup_h xdmf-3.0+git20160803/libsrc/vtkRequireLargeFilesSupport.cxx0000640000175000017500000000117313003006557023572 0ustar alastairalastair#define _LARGEFILE_SOURCE #define _LARGE_FILES #define _FILE_OFFSET_BITS 64 #include #include #include #include int main( int, char **argv ) { // check that off_t can hold 2^63 - 1 and perform basic operations... #define OFF_T_64 (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) if (OFF_T_64 % 2147483647 != 1) return 1; // stat breaks on SCO OpenServer struct stat buf; stat( argv[0], &buf ); if (!S_ISREG(buf.st_mode)) return 2; FILE *file = fopen( argv[0], "r" ); off_t offset = ftello( file ); fseek( file, offset, SEEK_CUR ); fclose( file ); return 0; } xdmf-3.0+git20160803/libsrc/XdmfRoot.h0000640000175000017500000000534213003006557017267 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : $Id: XdmfRoot.h,v 1.5 2009-01-23 20:31:39 clarke Exp $ */ /* Date : $Date: 2009-01-23 20:31:39 $ */ /* Version : $Revision: 1.5 $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2002 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #ifndef __XdmfRoot_h #define __XdmfRoot_h #include "XdmfElement.h" /*! XdmfRoot represents the Root Element in Xdmf. In XML it is the Element : The Xdmf element may have Domain and DataItem Elements as children The NameSpace "http://www.w3.org/2003/XInclude" is defined in a macro in libxml2, so it can change. XML Element : Xdmf XML Attribute : Version = Version # */ class XDMF_EXPORT XdmfRoot : public XdmfElement { public: XdmfRoot(); ~XdmfRoot(); XdmfConstString GetClassName() { return ( "XdmfRoot" ) ; }; //! Update From XML XdmfInt32 UpdateInformation(); //! Insert an Element XdmfInt32 Insert(XdmfElement *Child); /*! Set the Xdmf Version Until Build() is called. */ XdmfSetValueMacro(Version, XdmfFloat32); //! Turn XInclude On/Off XdmfSetValueMacro(XInclude, XdmfInt32); //! Update the DOM XdmfInt32 Build(); //! Get the Value of XInclude XdmfGetValueMacro(XInclude, XdmfInt32); /*! Get the Xdmf Version */ XdmfGetValueMacro(Version, XdmfFloat32); protected: XdmfFloat32 Version; XdmfInt32 XInclude; }; #endif // __XdmfRoot_h xdmf-3.0+git20160803/libsrc/XdmfExprYacc.tab.h0000640000175000017500000000510013003006557020617 0ustar alastairalastair/* A Bison parser, made by GNU Bison 1.875a. */ /* Skeleton parser for Yacc-like parsing with Bison, Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* As a special exception, when this file is copied by Bison into a Bison output file, you may use that output file without restriction. This special exception was added by the Free Software Foundation in version 1.24 of Bison. */ /* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE /* Put the tokens into the symbol table, so that GDB and other debuggers know about them. */ enum yytokentype { lFLOAT = 258, tokINTEGER = 259, tokARRAY = 260, NAME = 261, SIN = 262, COS = 263, TAN = 264, ACOS = 265, ASIN = 266, ATAN = 267, LOG = 268, EXP = 269, ABS_TOKEN = 270, SQRT = 271, WHERE = 272, INDEX = 273, EQEQ = 274, LT = 275, LE = 276, GT = 277, GE = 278, NE = 279, LTLT = 280, GTGT = 281, JOIN = 282 }; #endif #define lFLOAT 258 #define tokINTEGER 259 #define tokARRAY 260 #define NAME 261 #define SIN 262 #define COS 263 #define TAN 264 #define ACOS 265 #define ASIN 266 #define ATAN 267 #define LOG 268 #define EXP 269 #define ABS_TOKEN 270 #define SQRT 271 #define WHERE 272 #define INDEX 273 #define EQEQ 274 #define LT 275 #define LE 276 #define GT 277 #define GE 278 #define NE 279 #define LTLT 280 #define GTGT 281 #define JOIN 282 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) typedef union YYSTYPE { double DoubleValue; long IntegerValue; void *ArrayPointer; XdmfExprSymbol *Symbol; } YYSTYPE; /* Line 1240 of yacc.c. */ # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_TRIVIAL 1 #endif extern YYSTYPE dice_yylval; xdmf-3.0+git20160803/libsrc/XdmfElement.cxx0000640000175000017500000004201413003006557020305 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : $Id: XdmfElement.cxx,v 1.34 2010-04-01 16:58:35 kwleiter Exp $ */ /* Date : $Date: 2010-04-01 16:58:35 $ */ /* Version : $Revision: 1.34 $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2002 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #include "XdmfElement.h" #include "XdmfDOM.h" #include #include #define XDMF_EMPTY_REFERENCE 0x00 #define XDMF_ERROR_REFERENCE -1 #define XDMF_XML_PRIVATE_DATA(e) e->_private XdmfElementData::XdmfElementData(){ this->ReferenceElement = NULL; this->CurrentXdmfElement = NULL; } XdmfElementData::~XdmfElementData() { } XdmfElement::XdmfElement() { this->DOM = NULL; this->Element = NULL; this->ElementName = NULL; this->IsReference = 0; this->ReferenceElement = NULL; this->State = XDMF_ELEMENT_STATE_UNINITIALIZED; this->CopyReferenceData = 1; this->RootWhenParsed = 0; this->DsmBuffer = NULL; this->DataXml = 0; this->InsertedDataXml = 0; this->DeleteOnGridDelete = 0; } XdmfElement::~XdmfElement() { if(this->DOM && (this->DOM->GetTree() == this->RootWhenParsed)){ if(this->ReferenceElement){ if(this->GetReferenceObject(this->ReferenceElement) == this){ this->SetReferenceObject(this->ReferenceElement, XDMF_ELEMENT_STATE_UNINITIALIZED); } } this->ReferenceElement = NULL; if(this->Element){ if(this->GetReferenceObject(this->Element) == this){ this->SetReferenceObject(this->Element, XDMF_ELEMENT_STATE_UNINITIALIZED); } } } this->Element = NULL; if(this->ElementName) delete [] this->ElementName; if(this->DataXml) delete [] this->DataXml; } void XdmfElement::SetReferenceObject(XdmfXmlNode anElement, void *p){ XdmfElementData *PrivateData; if(!anElement){ XdmfErrorMessage("Element is NULL"); return; } if(XDMF_XML_PRIVATE_DATA(anElement)){ PrivateData = (XdmfElementData *)XDMF_XML_PRIVATE_DATA(anElement); }else{ PrivateData = new XdmfElementData; XDMF_XML_PRIVATE_DATA(anElement) = (void *)PrivateData; } // XdmfDebug("Old Ref = " << ElementPrivateData->GetReferenceElement()); // XdmfDebug("New Ref = " << p); PrivateData->SetReferenceElement((XdmfElement *)p); } void * XdmfElement::GetReferenceObject(XdmfXmlNode anElement){ XdmfElementData *ElementPrivateData; if(!anElement){ XdmfErrorMessage("NULL Reference Element"); return(NULL); } if(XDMF_XML_PRIVATE_DATA(anElement) == XDMF_EMPTY_REFERENCE){ XdmfDebug("XML Node contains no initialized object"); return(NULL); } ElementPrivateData = (XdmfElementData *)XDMF_XML_PRIVATE_DATA(anElement); if(ElementPrivateData->GetReferenceElement() == XDMF_EMPTY_REFERENCE){ XdmfDebug("XML Node contains no initialized object"); return(NULL); } return(ElementPrivateData->GetReferenceElement()); } void XdmfElement::SetCurrentXdmfElement(XdmfXmlNode anElement, void *p){ XdmfElementData *PrivateData; if(!anElement){ XdmfErrorMessage("Element is NULL"); return; } if(XDMF_XML_PRIVATE_DATA(anElement)){ PrivateData = (XdmfElementData *)XDMF_XML_PRIVATE_DATA(anElement); }else{ PrivateData = new XdmfElementData; XDMF_XML_PRIVATE_DATA(anElement) = (void *)PrivateData; } PrivateData->SetCurrentXdmfElement((XdmfElement *)p); } void * XdmfElement::GetCurrentXdmfElement(XdmfXmlNode anElement){ XdmfElementData *ElementPrivateData; if(!anElement){ XdmfErrorMessage("NULL Reference Element"); return(NULL); } ElementPrivateData = (XdmfElementData *)XDMF_XML_PRIVATE_DATA(anElement); if(!ElementPrivateData){ return(NULL); } if(ElementPrivateData->GetCurrentXdmfElement() == XDMF_EMPTY_REFERENCE){ XdmfDebug("XML Node contains no initialized object"); return(NULL); } return(ElementPrivateData->GetCurrentXdmfElement()); } XdmfInt32 XdmfElement::SetElement(XdmfXmlNode anElement, XdmfInt32 AssociateElement){ if(!anElement) { XdmfErrorMessage("Element is NULL"); return(XDMF_FAIL); } // Clear the ReferenceObject underlying node. This will also create ElementPrivateData if necessary XdmfDebug("Clearing ReferenceObject of XML node"); this->SetReferenceObject(anElement, XDMF_EMPTY_REFERENCE); if(AssociateElement) this->SetCurrentXdmfElement(anElement, this); this->Element = anElement; if(this->DOM){ this->RootWhenParsed = this->DOM->GetTree(); } return(XDMF_SUCCESS); } XdmfInt32 XdmfElement::InsertChildElement(XdmfXmlNode Child){ if(!this->DOM) { XdmfErrorMessage("No DOM has been set"); return(XDMF_FAIL); } if(!this->Element) { XdmfErrorMessage("Current Element is empty"); return(XDMF_FAIL); } if(this->DOM->Insert(this->Element, Child)){ return(XDMF_SUCCESS); } return(XDMF_FAIL); } XdmfInt32 XdmfElement::Insert(XdmfElement *Child){ XdmfXmlNode element; if(!this->DOM) { XdmfErrorMessage("No DOM has not been set : Parent must have a DOM and Element before insertion makes sense"); return(XDMF_FAIL); } if(!this->GetElement()) { XdmfErrorMessage("No Element has not been set : Parent must have a DOM and Element before insertion makes sense"); return(XDMF_FAIL); } if(!Child){ XdmfErrorMessage("Child Element is NULL"); return(XDMF_FAIL); } if(!Child->GetElementName()) { XdmfErrorMessage("Child Element has no ElementName"); return(XDMF_FAIL); } Child->SetDOM(this->DOM); element = this->GetDOM()->InsertNew(this->Element, Child->GetElementName()); if(!element){ XdmfErrorMessage("Failed to Insert New Child XML Node"); return(XDMF_FAIL); } if(Child->SetElement(element) != XDMF_SUCCESS){ XdmfErrorMessage("Failed to set child XML node"); return(XDMF_FAIL); } return(XDMF_SUCCESS); } XdmfInt32 XdmfElement::Copy(XdmfElement *){ return(XDMF_SUCCESS); } XdmfInt32 XdmfElement::UpdateInformation(){ XdmfConstString Value; XdmfElement *e; XdmfXmlNode ref; XdmfDebug("XdmfElement::UpdateInformation()"); if(!this->DOM) { XdmfErrorMessage("No DOM has been set"); return(XDMF_FAIL); } if(!this->Element){ XdmfErrorMessage("No XML Node has been set"); return(XDMF_FAIL); } Value = this->Get("Name"); if(Value) this->SetName(Value); ref = this->CheckForReference(this->Element); if(ref == (XdmfXmlNode)XDMF_ERROR_REFERENCE){ XdmfErrorMessage("Error Checking Reference"); free((void*)Value); return(XDMF_FAIL); } if(ref){ XdmfXmlNode node; // "this" is now the ReferenceObject for this->ReferenceElement XdmfDebug("Setting ReferenceObject and Following Chain"); this->SetReferenceObject(this->ReferenceElement, this); while(ref){ e = (XdmfElement *)this->GetReferenceObject(ref); if(e && (e != this)){ XdmfDebug("Updating Information from another Object"); // XdmfDebug(e->Serialize()); // There if an Object associated with this node. UpdateInformation()? if(e->GetState() < XDMF_ELEMENT_STATE_LIGHT_PARSED){ // Could cause a chain of UpdateInformation() XdmfDebug("Call UpdateInformation on ReferenceObject"); e->UpdateInformation(); } // Copy out appropriate information and return XdmfDebug("Copying Information from Reference Object"); this->Element = e->Element; free((void*)Value); return(this->Copy(e)); } // No ReferenceObject Set. Is this a Reference as well? node = this->FollowReference(ref); if(node){ ref = node; }else{ // Not a Reference. Is it the right Type ? if(STRCMP((const char *)ref->name, (const char *)this->ReferenceElement->name) != 0){ XdmfErrorMessage("Reference node " << Value << " is a " << ref->name << " not " << ReferenceElement->name); delete [] Value; return(XDMF_FAIL); } // If this is a derived Class, UpdateInformation will act on this target. this->SetElement(ref); // This is the end of the chain and there is no ReferenceObject for the XML node. XdmfDebug("Setting Reference Object"); this->SetReferenceObject(ref, this); ref = NULL; } } }else{ XdmfDebug("Setting Reference Object"); this->SetReferenceObject(this->Element, this); } free((void*)Value); this->State = XDMF_ELEMENT_STATE_LIGHT_PARSED; return(XDMF_SUCCESS); } XdmfInt32 XdmfElement::Update(){ XdmfXmlNode node, ref; XdmfElement *e; if(!this->DOM) { XdmfErrorMessage("No DOM has been set"); return(XDMF_FAIL); } if(!this->Element){ XdmfErrorMessage("No XML Node has been set"); return(XDMF_FAIL); } if(this->GetIsReference()){ // Don't assume that state has not changed since last UpdateInformation() ref = this->FollowReference(this->ReferenceElement); while(ref){ e = (XdmfElement *)this->GetReferenceObject(ref); if(e && (e != this)){ // Does it need Updating ? if(e->GetState() < XDMF_ELEMENT_STATE_LIGHT_PARSED) e->UpdateInformation(); if(e->GetState() < XDMF_ELEMENT_STATE_HEAVY_READ) e->Update(); this->Element = e->Element; return(this->Copy(e)); } // No External Reference Object node = this->FollowReference(ref); if(node){ ref = node; }else{ // No Reference Object and this is the end of the chain // If this is a derived Class, Update will act on this target. this->SetElement(ref); // This is the end of the chain and there is no ReferenceObject for the XML node. XdmfDebug("Setting Reference Object"); this->SetReferenceObject(ref, this); ref = NULL; } } } this->State = XDMF_ELEMENT_STATE_HEAVY_READ; return(XDMF_SUCCESS); } XdmfXmlNode XdmfElement::FollowReference(XdmfXmlNode anElement){ XdmfConstString Value; XdmfXmlNode ref = NULL; if(!anElement){ XdmfErrorMessage("Element is NULL"); return((XdmfXmlNode)XDMF_ERROR_REFERENCE); } Value = this->DOM->Get(anElement, "Reference"); if(Value){ if(STRCASECMP(Value, "XML") == 0){ Value = this->DOM->GetCData(anElement); if(!Value){ XdmfErrorMessage("Reference to CDATA is NULL"); return((XdmfXmlNode)XDMF_ERROR_REFERENCE); } } XdmfDebug("Following Reference to " << Value); ref = this->DOM->FindElementByPath(Value); if(!ref){ XdmfErrorMessage("Can't Find Node of Path " << Value); return((XdmfXmlNode)XDMF_ERROR_REFERENCE); } } return(ref); } XdmfXmlNode XdmfElement::CheckForReference(XdmfXmlNode anElement){ XdmfXmlNode node; XdmfDebug("XdmfElement::CheckForReference(XdmfXmlNode Element)"); if(!anElement) return((XdmfXmlNode)XDMF_ERROR_REFERENCE); // Does the Referenced Node Exist and is it of the Same Type node = this->FollowReference(anElement); if(node == (XdmfXmlNode)XDMF_ERROR_REFERENCE){ XdmfErrorMessage("Error Following Reference"); return((XdmfXmlNode)XDMF_ERROR_REFERENCE); } if(node){ XdmfDebug("Element is a Reference"); // Check Type (low level XML "name") against this->Element if(STRCMP((const char *)node->name, (const char *)anElement->name) != 0){ XdmfErrorMessage("Reference node is a " << node->name << " not " << anElement->name); return((XdmfXmlNode)XDMF_ERROR_REFERENCE); } }else{ // This is not a Reference Node return((XdmfXmlNode)XDMF_EMPTY_REFERENCE); } XdmfDebug("Setting ReferenceElement"); this->ReferenceElement = anElement; this->SetIsReference(1); return(node); } XdmfConstString XdmfElement::Serialize(){ if(!this->DOM) { XdmfErrorMessage("No DOM has been set"); return(NULL); } if(!this->Element){ XdmfErrorMessage("No XML Node has been set"); return(NULL); } if(this->GetIsReference()){ return(this->DOM->Serialize(this->ReferenceElement)); } return(this->DOM->Serialize(this->Element)); } XdmfConstString XdmfElement::GetElementType(){ if(!this->DOM) { XdmfErrorMessage("No DOM has been set"); return(NULL); } if(!this->Element){ XdmfErrorMessage("No XML Node has been set"); return(NULL); } return((XdmfConstString)this->Element->name); } XdmfInt32 XdmfElement::BuildFromDataXml(XdmfInt32 AllowCData){ if(this->DataXml){ if(AllowCData){ char first = 0; XdmfInt64 i = 0; while((first <= ' ') && (i < strlen(this->DataXml))){ first = this->DataXml[i++]; if((first > ' ') && (first != '<')){ this->Set("CData", this->DataXml); return(XDMF_SUCCESS); } } } if(this->DOM){ if(this->InsertedDataXml == this->DataXml){ // Already done return(XDMF_SUCCESS); } if(this->DOM->InsertFromString(this->GetElement(), this->DataXml)){ this->SetInsertedDataXml(this->DataXml); return(XDMF_SUCCESS); }else{ XdmfErrorMessage("Error Inserting Raw XML : " << endl << this->DataXml); return(XDMF_FAIL); } }else{ XdmfErrorMessage("Can't insert raw XML sine DOM is not set"); return(XDMF_FAIL); } } return(XDMF_FAIL); } XdmfInt32 XdmfElement::Build(){ XdmfConstString name; XdmfInt32 i; name = this->GetName(); if(name && (strlen(name) > 0)){ this->Set("Name", name); } if(this->DOM){ XdmfXmlNode myelement = this->GetElement(); if(myelement){ XdmfXmlNode childnode; XdmfElement *childelement; for(i=0;iDOM->GetNumberOfChildren(myelement);i++){ childnode = this->DOM->GetChild(i, myelement); childelement = (XdmfElement *)this->GetCurrentXdmfElement(childnode); if(childelement){ // cout << "Child Element Type of " << childelement << " = " << childelement->GetElementType() << endl; childelement->Build(); } } } } return(XDMF_SUCCESS); } XdmfInt32 XdmfElement::Set(XdmfConstString aName, XdmfConstString Value){ if(!this->DOM) { XdmfErrorMessage("No DOM has been set"); return(XDMF_FAIL); } if(!this->Element){ XdmfErrorMessage("No XML Node has been set"); return(XDMF_FAIL); } this->DOM->Set(this->Element, aName, Value); return(XDMF_SUCCESS); } XdmfConstString XdmfElement::Get(XdmfConstString aName){ if(!this->DOM) { XdmfErrorMessage("No DOM has been set"); return(NULL); } if(!this->Element){ XdmfErrorMessage("No XML Node has been set"); return(NULL); } return(this->DOM->Get(this->Element, aName)); } xdmf-3.0+git20160803/libsrc/XdmfValuesMySQL.cxx0000640000175000017500000001576013003006557021051 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : $Id: XdmfValuesMySQL.cxx,v 1.2 2008-05-09 16:39:41 clarke Exp $ */ /* Date : $Date: 2008-05-09 16:39:41 $ */ /* Version : $Revision: 1.2 $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2008 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #include "XdmfValuesMySQL.h" #include "XdmfDataStructure.h" #include "XdmfArray.h" #include "XdmfHDF.h" #include "mysql.h" XdmfValuesMySQL::XdmfValuesMySQL() { this->Password = 0; this->DataBase = 0; this->Query = 0; this->Server = 0; this->User = 0; this->SetFormat(XDMF_FORMAT_MYSQL); this->SetServer("localhost"); this->SetUser("root"); } XdmfValuesMySQL::~XdmfValuesMySQL() { } XdmfArray * XdmfValuesMySQL::Read(XdmfArray *anArray){ XdmfArray *RetArray = anArray; XdmfInt64 ResultLength, Fields, Rows, Index, NValues; XdmfInt32 FieldIndex; XdmfConstString Value; MYSQL *Connection; MYSQL_RES *Result; MYSQL_FIELD *Field; MYSQL_ROW Row; if(!this->DataDesc){ XdmfErrorMessage("DataDesc has not been set"); return(NULL); } // Allocate anArray if Necessary if(!RetArray){ RetArray = new XdmfArray(); RetArray->CopyType(this->DataDesc); RetArray->CopyShape(this->DataDesc); // RetArray->CopySelection(this->DataDesc); } XdmfDebug("Accessing MySQL CDATA"); Value = this->Get("Query"); if(Value){ this->SetQuery(Value); }else{ this->SetQuery(this->Get("CDATA")); } Value = this->Get("Server"); if(Value){ this->SetServer(Value); }else{ this->SetServer("localhost"); } Value = this->Get("User"); if(Value){ this->SetUser(Value); }else{ this->SetUser("root"); } Value = this->Get("Password"); if(Value){ this->SetPassword(Value); }else{ this->Password = NULL; } Value = this->Get("DataBase"); if(Value){ this->SetDataBase(Value); }else{ this->SetDataBase("Xdmf"); } if(!(Connection = mysql_init(NULL))){ XdmfErrorMessage("Cannot Initialize MySQL"); return(NULL); } if(!mysql_real_connect(Connection, this->Server, this->User, this->Password, this->DataBase, 0, NULL, 0)){ XdmfErrorMessage("Error Making MySQL Connection : " << mysql_error(Connection)); mysql_close(Connection); return(NULL); } if(mysql_query(Connection, this->Query)){ XdmfErrorMessage("Using Query : " << this->Query); XdmfErrorMessage("Error Making MySQL Query : " << mysql_error(Connection)); mysql_close(Connection); return(NULL); } Result = mysql_use_result(Connection); // Result = mysql_store_result(Connection); Fields = mysql_num_fields(Result); Rows = mysql_num_rows(Result); XdmfDebug("Query " << this->Query << " Returned " << Fields << " Fields"); XdmfDebug("Query " << this->Query << " Returned " << Rows << " Rows"); NValues = this->DataDesc->GetSelectionSize(); // RetArray->SetNumberOfElements(Fields * Rows); Index = 0; while((Row = mysql_fetch_row(Result)) && (Index < NValues)){ for(FieldIndex = 0 ; FieldIndex < Fields ; FieldIndex++){ RetArray->SetValues(Index++, Row[FieldIndex]); } } if(this->DataDesc->GetSelectionSize() != RetArray->GetNumberOfElements() ){ // Only Want Portion of anArray XdmfArray *SrcArray; XdmfInt64 SelectionSize = this->DataDesc->GetSelectionSize(); XdmfDebug("Selecting " << SelectionSize << " elements of XML CDATA"); SrcArray = RetArray->Clone(); RetArray->SetShape(1, &SelectionSize); RetArray->SelectAll(); SrcArray->CopySelection(this->DataDesc); XdmfDebug("Original Values = " << SrcArray->GetValues()); CopyArray(SrcArray, RetArray); XdmfDebug("New Values = " << RetArray->GetValues()); delete SrcArray; } mysql_free_result(Result); mysql_close(Connection); return(RetArray); } XdmfInt32 XdmfValuesMySQL::Write(XdmfArray *anArray, XdmfConstString /*HeavyDataSetName*/){ XdmfConstString DataValues; ostrstream StringOutput; XdmfInt32 rank, r; XdmfInt64 i, index, nelements, len, idims[XDMF_MAX_DIMENSION], dims[XDMF_MAX_DIMENSION]; if(!this->DataDesc ){ XdmfErrorMessage("DataDesc has not been set"); return(XDMF_FAIL); } if(!anArray){ XdmfErrorMessage("Array to Write is NULL"); return(XDMF_FAIL); } rank = this->DataDesc->GetShape(dims); for(i = 0 ; i < rank ; i++){ idims[i] = dims[i]; } // At most 10 values per line len = MIN(dims[rank - 1], 10); nelements = this->DataDesc->GetNumberOfElements(); index = 0; StringOutput << endl; while(nelements){ r = rank - 1; len = MIN(len, nelements); DataValues = anArray->GetValues(index, len); StringOutput << DataValues << endl; index += len; nelements -= len; dims[r] -= len; // End of Smallest dimension ? if(nelements && r && (dims[r] <= 0)){ // Reset dims[r] = idims[r]; // Go Backwards thru dimensions while(r){ r--; dims[r]--; // Is dim now 0 if(dims[r] <= 0){ // Add an Endl and keep going StringOutput << endl; dims[r] = idims[r]; }else{ // Still some left break; } } } } StringOutput << ends; return(this->Set("CDATA", StringOutput.str())); } xdmf-3.0+git20160803/libsrc/XdmfElement.h0000640000175000017500000002321413003006557017733 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : $Id: XdmfElement.h,v 1.25 2010-03-16 17:33:38 kwleiter Exp $ */ /* Date : $Date: 2010-03-16 17:33:38 $ */ /* Version : $Revision: 1.25 $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2006 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #ifndef __XdmfElement_h #define __XdmfElement_h #include "XdmfLightData.h" #define XDMF_ELEMENT_STATE_UNINITIALIZED 0 #define XDMF_ELEMENT_STATE_LIGHT_PARSED 1 #define XDMF_ELEMENT_STATE_HEAVY_READ 2 class XdmfDOM; class XdmfDsmBuffer; //! Basic XML Based Element /*! XdmfElement represents an Element in the LightData. For example, XdmfInformation, XdmfGrid, XdmfTopology etc. are all elements. Elements have "Attributes" which are the Name=Value pairs in the XML. Elements can also have children elements and CDATA which is the Character Data of the Element. Consider : \verbatim November 28, 1962 \endverbatim In the first Element, Name is the one and only Attribute. The second Element is a child of the first and has the Attributes : Name and Value. November 28, 1962 is the CDATA of the first Element. Elements can also reference other elements. This is particularly useful for "DataStructure" elements to minimize the amount of I/O that is performed. References are accomplished via the XML facility known as XPath. Consider : \verbatim OR /Xdmf/Domain/Grid[@Name="Shot Points"]/Geometry/DataStructure[2] \endverbatim This says that this DataStructure information can be found in the 2nd DataStructure (1 based) under the "Geometry" element, under the "Grid" element who's Name='Shot Points', under "Domain" under "Xdmf", in the current file. There are many expressions in XPath, see XPath documentation and Web pages for more. If an XDMF Object has already the target node via UpdateInformation() / Update(), a Reference node will point to the data of the original object. So each XML node that is Parsed will be owned by some object. References can point to other references to form a chain. */ class XDMF_EXPORT XdmfElement : public XdmfLightData { public: XdmfElement(); virtual ~XdmfElement(); virtual XdmfConstString GetClassName() { return("XdmfElement"); } ; //! Set the DOM to use XdmfSetValueMacro(DOM, XdmfDOM *); //! Get the current DOM XdmfGetValueMacro(DOM, XdmfDOM *); //! Set the current State XdmfSetValueMacro(State, XdmfInt32 ); //! Get the current State XdmfGetValueMacro(State, XdmfInt32 ); //! Does this Element Reference Some Other Element XdmfSetValueMacro(IsReference, XdmfInt32); //! Does this Element Reference Some Other Element XdmfGetValueMacro(IsReference, XdmfInt32); //! Check to see if Element references another XML node (which will then be returned) /*! \param Element is the head XML node of a potential reference chain */ virtual XdmfXmlNode CheckForReference(XdmfXmlNode Element); //! Add a child Node XdmfInt32 InsertChildElement(XdmfXmlNode Child); //! Return the XML representation XdmfConstString Serialize(); //! Set the XML Node from which to parse /*! \param Element is the low level node returned from XdmfDOM->FindElement() etc. \param AssociateElement Should the node in the DOM be associated with the XdmfElement (1) */ XdmfInt32 SetElement(XdmfXmlNode Element, XdmfInt32 AssociateElement=1); //! Get the XML Node XdmfGetValueMacro(Element, XdmfXmlNode); //! Tells the Element if data is to be copied out of a reference. /*! If an element is a reference and another element has already accessed the data there are two choices. First, copy the data out of the element that contains the data. This is the default and the safest, but leads to additional memory requirements. The second option is to just point to the original data. For this to work in the general caes, a refernce counting / garbage collection scheme needs to be used. Otherwise, the destruction of the original element will leave an invalid reference in the new element. In short, setting CopyReferenceData to 0 should be done with care. */ XdmfSetValueMacro(CopyReferenceData, XdmfInt32); //! Get the flag if data is to be copied out of a reference. XdmfGetValueMacro(CopyReferenceData, XdmfInt32); //! Get the ElementName. i.e. ElementName for InsertedDataXml = Inserted; return(XDMF_SUCCESS);}; //! Build XML from user supplied DataXml XdmfInt32 BuildFromDataXml(XdmfInt32 AllowCData = 0); //! Get the Element type : Grid, Topology, etc. XdmfConstString GetElementType(); //! Initialize basic structure from XML (INPUT) virtual XdmfInt32 UpdateInformation(); //! Initialize all information. Possibly acessing Heavy Data. (INPUT) virtual XdmfInt32 Update(); //! Update the DOM from the Basic Structure virtual XdmfInt32 Build(); //! Set the Value of an Attribute (OUTPUT) XdmfInt32 Set(XdmfConstString Name, XdmfConstString Value); //! Get the Value of An Attribute (INPUT) XdmfConstString Get(XdmfConstString Name); //! Copy Information from Another Element. Overridden in Child Class virtual XdmfInt32 Copy(XdmfElement *Source); //! Insert a child Element. Overridden in child Class to check ElementName virtual XdmfInt32 Insert(XdmfElement *Child = 0); //! Follow a Refernce Chain one step, if it exists XdmfXmlNode FollowReference(XdmfXmlNode Element); //! Get DSM Buffer XdmfGetValueMacro(DsmBuffer, XdmfDsmBuffer *); //! Set DSM Buffer XdmfSetValueMacro(DsmBuffer, XdmfDsmBuffer *); //! Delete the Element when the XdmfGrid container is deleted. Default = 0 XdmfSetValueMacro(DeleteOnGridDelete, XdmfInt32); //! Delete the Element when the XdmfGrid container is deleted. Default = 0 XdmfGetValueMacro(DeleteOnGridDelete, XdmfInt32); protected: void SetReferenceObject(XdmfXmlNode Element, void *p); void *GetReferenceObject(XdmfXmlNode Element); //! Set the XdmfElement Object Assigned to the XML Element in the DOM void SetCurrentXdmfElement(XdmfXmlNode Element, void *p); //! Get the XdmfElement Object Assigned to the XML Element in the DOM void *GetCurrentXdmfElement(XdmfXmlNode Element); XdmfDOM *DOM; XdmfInt32 State; XdmfString ElementName; XdmfString DataXml; XdmfString InsertedDataXml; //! Target XML That Represents this. In the case of a reference, this is the target XML not the Reference="XX" node. XdmfXmlNode Element; //! If this is a Reference XML, this is the head of the Reference chain (the Original XML node). XdmfXmlNode ReferenceElement; XdmfInt32 IsReference; // Copy, don't copy data out of reference element. Default is to copy. XdmfInt32 CopyReferenceData; XdmfDsmBuffer *DsmBuffer; XdmfXmlNode RootWhenParsed; XdmfInt32 DeleteOnGridDelete; }; class XDMF_EXPORT XdmfElementData : public XdmfObject { public : XdmfElementData(); ~XdmfElementData(); XdmfSetValueMacro(ReferenceElement, XdmfElement *); XdmfGetValueMacro(ReferenceElement, XdmfElement *); XdmfSetValueMacro(CurrentXdmfElement, XdmfElement *); XdmfGetValueMacro(CurrentXdmfElement, XdmfElement *); protected : XdmfElement *ReferenceElement; XdmfElement *CurrentXdmfElement; }; #endif // __XdmfElement_h xdmf-3.0+git20160803/libsrc/XdmfValues.cxx0000640000175000017500000000611113003006557020151 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Values */ /* */ /* Id : $Id: XdmfValues.cxx,v 1.10 2010-03-12 20:26:05 kwleiter Exp $ */ /* Date : $Date: 2010-03-12 20:26:05 $ */ /* Version : $Revision: 1.10 $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2002 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #include "XdmfValues.h" #include "XdmfDataItem.h" #include "XdmfArray.h" XdmfValues::XdmfValues() { this->Format = -1; } XdmfValues::~XdmfValues() { } XdmfInt32 XdmfValues::Inherit(XdmfDataItem *DataItem) { if(!DataItem){ XdmfErrorMessage("DataItem to copy is NULL"); return(XDMF_FAIL); } if(this->SetDOM(DataItem->GetDOM()) != XDMF_SUCCESS){ XdmfErrorMessage("Error Setting DOM"); return(XDMF_FAIL); } // if(this->SetElement(DataItem->GetElement()) != XDMF_SUCCESS){ // XdmfErrorMessage("Error Setting Element"); // return(XDMF_FAIL); // } // Do it by hand so the _private member of the structure is maintained. if(!DataItem->GetElement()){ XdmfErrorMessage("Element is NULL"); return(XDMF_FAIL); } this->Element = DataItem->GetElement(); if(this->SetFormat(DataItem->GetFormat()) != XDMF_SUCCESS){ XdmfErrorMessage("Error Setting Element"); return(XDMF_FAIL); } //if(this->DataDesc && this->DataDescIsMine){ // delete this->DataDesc; //} //this->DataDescIsMine = 0; if(this->SetDataDesc(DataItem->GetDataDesc()) != XDMF_SUCCESS){ XdmfErrorMessage("Error Setting DataDesc"); return(XDMF_FAIL); } //this->DataDescIsMine = 0; return(XDMF_SUCCESS); } // Override this XdmfArray * XdmfValues::Read(XdmfArray *){ return(NULL); } // Override this XdmfInt32 XdmfValues::Write(XdmfArray *, XdmfConstString ){ return(XDMF_FAIL); } xdmf-3.0+git20160803/libsrc/XdmfValuesBinary.h0000640000175000017500000000605213003006557020747 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : $Id: XdmfValuesBinary.h,v 1.4 2009-08-31 14:46:54 clarke Exp $ */ /* Date : $Date: 2009-08-31 14:46:54 $ */ /* Version : $Revision: 1.4 $ */ /* */ /* Author:Kenji Takizawa (Team for Advanced Flow Simulation and Modeling) */ /* */ /* Copyright @ 2008 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #ifndef __XdmfValuesBinaryL_h #define __XdmfValuesBinaryL_h #include "XdmfValues.h" //! Parent Class for handeling I/O of actual data for an XdmfDataItem /*! This is the class for access of values from a raw binary. A Binary XdmfDataItem Node Looks like : \verbatim \endverbatim Endian: Little, Big, otherwise Native Seak: unit is byte Putting "<" in the CDATA, it may cause an error in the XML parser. Here's an example of using "<" in the CDATA : \verbatim \endverbatim That is you have ti start the CDATA with "". */ class XDMF_EXPORT XdmfValuesBinary : public XdmfValues { public : XdmfValuesBinary(); virtual ~XdmfValuesBinary(); XdmfConstString GetClassName() { return("XdmfValuesBinary"); } ; //! Read the Array from the External Representation XdmfArray *Read(XdmfArray *Array=NULL); //! Write the Array to the External Representation XdmfInt32 Write(XdmfArray *Array, XdmfConstString HeavyDataSetName=NULL); //! Get Endian Name XdmfGetStringMacro(Endian); //! Set Endian Name XdmfSetStringMacro(Endian); //! Get Seek XdmfGetStringMacro(Seek); //! Set Seek XdmfSetStringMacro(Seek); //! Get Compression XdmfGetStringMacro(Compression); //! Set Compression XdmfSetStringMacro(Compression); protected : bool needByteSwap(); XdmfString Endian; XdmfString Seek; XdmfString Compression; private: void byteSwap(XdmfArray * RetArray); size_t getSeek(); enum CompressionType {Raw, Zlib, BZip2}; enum CompressionType getCompressionType(); }; #endif xdmf-3.0+git20160803/libsrc/XdmfDataStructure.cxx0000640000175000017500000000366113003006557021513 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Values */ /* */ /* Id : $Id: XdmfDataStructure.cxx,v 1.14 2009-01-23 20:31:39 clarke Exp $ */ /* Date : $Date: 2009-01-23 20:31:39 $ */ /* Version : $Revision: 1.14 $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2002 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #include "XdmfDataStructure.h" #include "XdmfArray.h" XdmfDataStructure::XdmfDataStructure() { this->ItemType = XDMF_ITEM_UNIFORM; } XdmfDataStructure::~XdmfDataStructure() { } XdmfInt32 XdmfDataStructure::UpdateInformation(){ if(XdmfDataItem::UpdateInformation() != XDMF_SUCCESS) return(XDMF_FAIL); return(XDMF_SUCCESS); } xdmf-3.0+git20160803/libsrc/XdmfLightData.h0000640000175000017500000000760113003006557020205 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : $Id: XdmfLightData.h,v 1.8 2008-12-30 20:47:33 clarke Exp $ */ /* Date : $Date: 2008-12-30 20:47:33 $ */ /* Version : $Revision: 1.8 $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2002 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #ifndef __XdmfLightData_h #define __XdmfLightData_h #include "XdmfObject.h" #ifndef SWIG #include // strcmp, strlen, strcpy #endif // typedef XdmfPointer XdmfXmlNode; struct _xmlNode; typedef _xmlNode *XdmfXmlNode; struct _xmlDoc; typedef _xmlDoc *XdmfXmlDoc; //! Base object for Light Data (XML) /*! This is an abstract convenience object for reading and writing LightData Files. LightData "points" to HeavyData ; the giga-terabytes of HPC simulations. A XdmfLightData Object is not used by itself. Rather one of the derived classes like XdmfGrid or XdmfFormatMulti is used and these derived methods are used from that class. */ class XDMF_EXPORT XdmfLightData : public XdmfObject { public: XdmfLightData(); ~XdmfLightData(); XdmfConstString GetClassName() { return ( "XdmfLightData" ) ; }; //! Set the current name XdmfSetStringMacro(Name); //! Get the current name XdmfGetValueMacro(Name, XdmfConstString); //! Set the current filename XdmfSetStringMacro(FileName); //! Get the current filename XdmfGetValueMacro(FileName, XdmfConstString); /*! Set the current WorkingDirectory This alleviates the need to hard code pathnames in the light data. i.e. the heavy and light data can be in one directory and accessed from another. */ XdmfSetStringMacro(WorkingDirectory); //! Get the current WorkingDirectory XdmfGetValueMacro(WorkingDirectory, XdmfConstString); //! Has Object been properly initialized XdmfGetValueMacro(Initialized, XdmfInt32); XdmfSetValueMacro(Initialized, XdmfInt32); /*! To avoid memory leaks, string return values from methods point to a static buffer. If the calling function wishes to retain this value, it must be copied. This method copies the value into the static return buffer, allocating space if necessary. \param ReturnValue A zero terminated string */ /*! Get the char * to the string portion of the return buffer. */ XdmfConstString GetReturnBuffer() {return(this->StaticReturnBuffer);}; protected: XdmfConstString DupChars(XdmfPointer Chars); XdmfConstString DupBuffer(XdmfPointer Buffer); XdmfString WorkingDirectory; XdmfString FileName; XdmfString Name; XdmfString StaticReturnBuffer; XdmfInt32 Initialized; }; #endif // __XdmfLightData_h xdmf-3.0+git20160803/libsrc/XdmfGeometry.cxx0000640000175000017500000005676313003006557020527 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : $Id: XdmfGeometry.cxx,v 1.28 2010-03-29 17:21:08 kwleiter Exp $ */ /* Date : $Date: 2010-03-29 17:21:08 $ */ /* Version : $Revision: 1.28 $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2007 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #include "XdmfGeometry.h" #include "XdmfTopology.h" #include "XdmfDataItem.h" #include "XdmfArray.h" #include "XdmfDOM.h" #include "XdmfHDF.h" XdmfGeometry *GetXdmfGeometryHandle( void *Pointer ){ //XdmfGeometry *tmp = (XdmfGeometry *)Pointer; return((XdmfGeometry *)Pointer); } XdmfGeometry::XdmfGeometry() { this->SetElementName("Geometry"); this->GeometryType = XDMF_GEOMETRY_NONE; this->Points = NULL; this->PointsAreMine = 1; this->VectorX = NULL; this->VectorY = NULL; this->VectorZ = NULL; this->SetOrigin( 0, 0, 0 ); this->SetDxDyDz( 0, 0, 0 ); this->LightDataLimit = 100; this->Units = NULL; // Ian Curington, HR Wallingford Ltd. this->VectorXIsMine = 0; this->VectorYIsMine = 0; this->VectorZIsMine = 0; } XdmfGeometry::~XdmfGeometry() { if( this->PointsAreMine && this->Points ) delete this->Points; if(this->Units) delete [] this->Units; // Ian Curington, HR Wallingford Ltd. if(this->VectorX && this->VectorXIsMine) delete this->VectorX; if(this->VectorY && this->VectorYIsMine) delete this->VectorY; if(this->VectorZ && this->VectorZIsMine) delete this->VectorZ; } XdmfInt32 XdmfGeometry::Release() { XdmfXmlNode node; XdmfInt32 Index = 0; XdmfXmlNode Node; if( this->PointsAreMine && this->Points ){ delete this->Points; this->Points = NULL; } // this->NumberOfPoints = 0; Node = this->GetElement(); node = this->DOM->FindDataElement(Index++, Node); // No Need to Release DataItems() since Data has been read // and Stored in Internal Points return(XDMF_SUCCESS); } // Returns an existing DataItem or build a new one XdmfDataItem * XdmfGeometry::GetDataItem(XdmfInt32 Index, XdmfXmlNode Node){ XdmfDataItem *di = NULL; XdmfXmlNode node; node = this->DOM->FindDataElement(Index, Node); if(node) { di = (XdmfDataItem *)this->GetCurrentXdmfElement(node); } if(!di){ di = new XdmfDataItem; node = this->DOM->InsertNew(this->GetElement(), "DataItem"); di->SetDOM(this->DOM); di->SetElement(node); } return(di); } XdmfInt32 XdmfGeometry::Build(){ XdmfDataItem *di = NULL; XdmfArray *array; //cout << "Building Geometry" << endl; if(XdmfElement::Build() != XDMF_SUCCESS) return(XDMF_FAIL); this->Set("GeometryType", this->GetGeometryTypeAsString()); // Build Children from String , if provided if(this->BuildFromDataXml() == XDMF_SUCCESS) return(XDMF_SUCCESS); switch( this->GeometryType ){ case XDMF_GEOMETRY_VXVYVZ: if(!this->VectorX || !this->VectorY || !this->VectorZ){ XdmfErrorMessage("Vx Vy and Vz must be set"); return(XDMF_FAIL); } // Vx di = this->GetDataItem(0, this->GetElement()); di->SetArray(this->VectorX); if(this->VectorX->GetNumberOfElements() > this->LightDataLimit) di->SetFormat(XDMF_FORMAT_HDF); di->Build(); this->SetCurrentXdmfElement(di->GetElement(), NULL); delete di; // Vy di = this->GetDataItem(1, this->GetElement()); di->SetArray(this->VectorY); if(this->VectorY->GetNumberOfElements() > this->LightDataLimit) di->SetFormat(XDMF_FORMAT_HDF); di->Build(); this->SetCurrentXdmfElement(di->GetElement(), NULL); delete di; // Vx di = this->GetDataItem(2, this->GetElement()); di->SetArray(this->VectorZ); if(this->VectorZ->GetNumberOfElements() > this->LightDataLimit) di->SetFormat(XDMF_FORMAT_HDF); di->Build(); this->SetCurrentXdmfElement(di->GetElement(), NULL); delete di; break; case XDMF_GEOMETRY_VXVY: if(!this->VectorX || !this->VectorY){ XdmfErrorMessage("Vx and Vy must be set"); return(XDMF_FAIL); } // Vx di = this->GetDataItem(0, this->GetElement()); di->SetArray(this->VectorX); if(this->VectorX->GetNumberOfElements() > this->LightDataLimit) di->SetFormat(XDMF_FORMAT_HDF); di->Build(); this->SetCurrentXdmfElement(di->GetElement(), NULL); delete di; // Vy di = this->GetDataItem(1, this->GetElement()); di->SetArray(this->VectorY); if(this->VectorY->GetNumberOfElements() > this->LightDataLimit) di->SetFormat(XDMF_FORMAT_HDF); di->Build(); this->SetCurrentXdmfElement(di->GetElement(), NULL); delete di; break; case XDMF_GEOMETRY_ORIGIN_DXDYDZ: // Origin di = this->GetDataItem(0, this->GetElement()); di->SetFormat(XDMF_FORMAT_XML); di->SetName("Origin"); array = di->GetArray(); array->SetNumberOfElements(3); array->SetValues(0, this->Origin, 3); di->Build(); this->SetCurrentXdmfElement(di->GetElement(), NULL); delete di; // DxDyDz di = this->GetDataItem(1, this->GetElement()); di->SetFormat(XDMF_FORMAT_XML); di->SetName("Spacing"); array = di->GetArray(); array->SetNumberOfElements(3); array->SetValues(0, this->DxDyDz, 3); di->Build(); this->SetCurrentXdmfElement(di->GetElement(), NULL); delete di; break; case XDMF_GEOMETRY_ORIGIN_DXDY: // Origin di = this->GetDataItem(0, this->GetElement()); di->SetFormat(XDMF_FORMAT_XML); di->SetName("Origin"); array = di->GetArray(); array->SetNumberOfElements(2); array->SetValues(0, this->Origin, 2); di->Build(); this->SetCurrentXdmfElement(di->GetElement(), NULL); delete di; // DxDy di = this->GetDataItem(1, this->GetElement()); di->SetFormat(XDMF_FORMAT_XML); di->SetName("Spacing"); array = di->GetArray(); array->SetNumberOfElements(2); array->SetValues(0, this->DxDyDz, 2); di->Build(); this->SetCurrentXdmfElement(di->GetElement(), NULL); delete di; break; case XDMF_GEOMETRY_NONE: break; default : if(this->Points){ di = this->GetDataItem(0, this->GetElement()); di->SetArray(this->Points); if(this->Points->GetNumberOfElements() > this->LightDataLimit) di->SetFormat(XDMF_FORMAT_HDF); di->Build(); this->SetCurrentXdmfElement(di->GetElement(), NULL); delete di; }else{ XdmfErrorMessage("XdmfGeometry->Points must be set for Geometry Type " << this->GetGeometryTypeAsString()); return(XDMF_FAIL); } break; } // PATCH September 09, Ian Curington, HR Wallingford Ltd. if(this->Units) { this->Set("Units", this->GetUnits()); } // end patch return(XDMF_SUCCESS); } XdmfInt32 XdmfGeometry::Insert( XdmfElement *Child){ if(Child && ( XDMF_WORD_CMP(Child->GetElementName(), "DataItem") || XDMF_WORD_CMP(Child->GetElementName(), "Information") )){ return(XdmfElement::Insert(Child)); }else{ XdmfErrorMessage("Geometry can only Insert DataItem or Information elements"); } return(XDMF_FAIL); } XdmfInt32 XdmfGeometry::SetOrigin( XdmfFloat64 X, XdmfFloat64 Y, XdmfFloat64 Z ){ this->Origin[0] = X; this->Origin[1] = Y; this->Origin[2] = Z; return( XDMF_SUCCESS ); } XdmfInt32 XdmfGeometry::SetOrigin( XdmfFloat64 *origin ){ return( this->SetOrigin( origin[0], origin[1], origin[2] ) ); } XdmfInt32 XdmfGeometry::SetDxDyDz( XdmfFloat64 Dx, XdmfFloat64 Dy, XdmfFloat64 Dz ){ this->DxDyDz[0] = Dx; this->DxDyDz[1] = Dy; this->DxDyDz[2] = Dz; return( XDMF_SUCCESS ); } XdmfInt32 XdmfGeometry::SetDxDyDz( XdmfFloat64 *dxDyDz ){ return( this->SetDxDyDz( dxDyDz[0], dxDyDz[1], dxDyDz[2] ) ); } XdmfArray * XdmfGeometry::GetPoints(XdmfInt32 Create){ if(!this->Points && Create){ this->Points = new XdmfArray; this->PointsAreMine = 1; } return(this->Points); } XdmfInt32 XdmfGeometry::SetPoints( XdmfArray *points ){ if(this->Points == points) return(XDMF_SUCCESS); if( this->PointsAreMine && this->Points ) delete this->Points; this->PointsAreMine = 0; this->Points = points; return( XDMF_SUCCESS ); } XdmfInt32 XdmfGeometry::SetGeometryTypeFromString( XdmfConstString geometryType ){ if( XDMF_WORD_CMP( geometryType, "X_Y_Z" ) ){ this->GeometryType = XDMF_GEOMETRY_X_Y_Z; return(XDMF_SUCCESS); } if( XDMF_WORD_CMP( geometryType, "X_Y" ) ){ this->GeometryType = XDMF_GEOMETRY_X_Y; return(XDMF_SUCCESS); } if( XDMF_WORD_CMP( geometryType, "XY" ) ){ this->GeometryType = XDMF_GEOMETRY_XY; return(XDMF_SUCCESS); } if( XDMF_WORD_CMP( geometryType, "XYZ" ) ){ this->GeometryType = XDMF_GEOMETRY_XYZ; return(XDMF_SUCCESS); } if( XDMF_WORD_CMP( geometryType, "ORIGIN_DXDYDZ" ) ){ this->GeometryType = XDMF_GEOMETRY_ORIGIN_DXDYDZ; return(XDMF_SUCCESS); } if( XDMF_WORD_CMP( geometryType, "ORIGIN_DXDY" ) ){ this->GeometryType = XDMF_GEOMETRY_ORIGIN_DXDY; return(XDMF_SUCCESS); } if( XDMF_WORD_CMP( geometryType, "VXVYVZ" ) ){ this->GeometryType = XDMF_GEOMETRY_VXVYVZ; return(XDMF_SUCCESS); } if( XDMF_WORD_CMP( geometryType, "VXVY" ) ){ this->GeometryType = XDMF_GEOMETRY_VXVY; return(XDMF_SUCCESS); } if( XDMF_WORD_CMP( geometryType, "NONE" ) ){ this->GeometryType = XDMF_GEOMETRY_NONE; return(XDMF_SUCCESS); } return( XDMF_FAIL ); } XdmfString XdmfGeometry::GetGeometryTypeAsString( void ){ static char Value[80]; switch( this->GeometryType ){ case XDMF_GEOMETRY_VXVYVZ: strcpy( Value, "VXVYVZ" ); break; case XDMF_GEOMETRY_VXVY: strcpy( Value, "VXVY" ); break; case XDMF_GEOMETRY_ORIGIN_DXDYDZ: strcpy( Value, "ORIGIN_DXDYDZ" ); break; case XDMF_GEOMETRY_ORIGIN_DXDY: strcpy( Value, "ORIGIN_DXDY" ); break; case XDMF_GEOMETRY_X_Y_Z : strcpy( Value, "X_Y_Z" ); break; case XDMF_GEOMETRY_X_Y : strcpy( Value, "X_Y" ); break; case XDMF_GEOMETRY_XY : strcpy( Value, "XY" ); break; case XDMF_GEOMETRY_NONE : strcpy( Value, "NONE"); break; default : strcpy( Value, "XYZ" ); break; } return( Value ); } XdmfInt32 XdmfGeometry::UpdateInformation() { XdmfConstString Attribute; if(XdmfElement::UpdateInformation() != XDMF_SUCCESS) return(XDMF_FAIL); if( XDMF_WORD_CMP(this->GetElementType(), "Geometry") == 0){ XdmfErrorMessage("Element type" << this->GetElementType() << " is not of type 'Geometry'"); return(XDMF_FAIL); } // PATCH September 09, Ian Curington, HR Wallingford Ltd. Attribute = this->Get( "Units" ); if( Attribute ){ this->SetUnits( Attribute ); } else { if(this->Units) delete [] this->Units; this->Units = NULL; } // end patch free((void*)Attribute); Attribute = this->Get( "GeometryType" ); if(!Attribute){ Attribute = this->Get( "Type" ); } if( Attribute ){ if(this->SetGeometryTypeFromString( Attribute ) != XDMF_SUCCESS){ XdmfErrorMessage("No such Geometry Type : " << Attribute); free((void*)Attribute); return(XDMF_FAIL); } } else { this->GeometryType = XDMF_GEOMETRY_XYZ; } if(!this->Name) this->SetName(GetUnique("Geometry_")); free((void*)Attribute); return( XDMF_SUCCESS ); } XdmfInt32 XdmfGeometry::Update() { XdmfInt32 ArrayIndex; XdmfInt64 Start[ XDMF_MAX_DIMENSION ]; XdmfInt64 Stride[ XDMF_MAX_DIMENSION ]; XdmfInt64 Count[ XDMF_MAX_DIMENSION ]; XdmfXmlNode PointsElement; XdmfArray *points = NULL; XdmfArray *TmpArray; if( this->GeometryType == XDMF_GEOMETRY_NONE ){ if( this->UpdateInformation() == XDMF_FAIL ){ XdmfErrorMessage("Can't Initialize From Element"); return( XDMF_FAIL ); } } if(XdmfElement::Update() != XDMF_SUCCESS) return(XDMF_FAIL); for(ArrayIndex = 0 ; ArrayIndex < XDMF_MAX_DIMENSION ; ArrayIndex++){ Start[ArrayIndex] = 0; Stride[ArrayIndex] = 1; Count[ArrayIndex] = 0; } ArrayIndex = 0; if( ( this->GeometryType == XDMF_GEOMETRY_X_Y_Z ) || ( this->GeometryType == XDMF_GEOMETRY_X_Y ) || ( this->GeometryType == XDMF_GEOMETRY_XYZ ) || ( this->GeometryType == XDMF_GEOMETRY_XY ) ){ do { // Read the Data XdmfDebug("Reading Points ( SubElement #" << ArrayIndex + 1 << " )" ); PointsElement = this->DOM->FindDataElement( ArrayIndex, Element ); if( PointsElement ){ XdmfDataItem PointsItem; if(PointsItem.SetDOM( this->DOM ) == XDMF_FAIL) return(XDMF_FAIL); if(PointsItem.SetElement(PointsElement, 0) == XDMF_FAIL) return(XDMF_FAIL); if(PointsItem.UpdateInformation() == XDMF_FAIL) return(XDMF_FAIL); PointsItem.SetDsmBuffer(this->DsmBuffer); if(PointsItem.Update() == XDMF_FAIL) return(XDMF_FAIL); TmpArray = PointsItem.GetArray(); if( TmpArray ){ if( !points ){ switch( this->GeometryType ){ case XDMF_GEOMETRY_X_Y_Z : points = new XdmfArray; points->CopyType( TmpArray ); points->SetNumberOfElements( TmpArray->GetNumberOfElements() * 3 ); break; case XDMF_GEOMETRY_XY : points = new XdmfArray; points->CopyType( TmpArray ); // points->SetNumberOfElements( TmpArray->GetNumberOfElements() / 2 * 3 ); Start[0] = TmpArray->GetNumberOfElements() / 2; Start[1] = 3; points->SetShape( 2 , Start ); // operator '=' is overloaded *points = 0; break; case XDMF_GEOMETRY_X_Y : points = new XdmfArray; points->CopyType( TmpArray ); points->SetNumberOfElements( TmpArray->GetNumberOfElements() * 3 ); // operator '=' is overloaded *points = 0; break; default : points = TmpArray; // Assure DataItem Destructor does not delete XdmfArray PointsItem.SetArrayIsMine(0); break; } } // We Have made Points Rank = 1 if not XYZ switch( this->GeometryType ){ case XDMF_GEOMETRY_X_Y_Z : Start[0] = ArrayIndex; Stride[0] = 3; points->SelectHyperSlab( Start, Stride, NULL ); CopyArray( TmpArray, points); this->NumberOfPoints = TmpArray->GetNumberOfElements(); break; case XDMF_GEOMETRY_XY : Stride[0] = 1; Stride[1] = 1; Count[0] = TmpArray->GetNumberOfElements() / 2; Count[1] = 2; points->SelectHyperSlab( NULL, Stride, Count); CopyArray( TmpArray, points); this->NumberOfPoints = TmpArray->GetNumberOfElements() / 2 ; break; case XDMF_GEOMETRY_X_Y : Start[0] = ArrayIndex; Stride[0] = 3; points->SelectHyperSlab( Start, Stride, NULL ); CopyArray( TmpArray, points); this->NumberOfPoints = TmpArray->GetNumberOfElements(); break; default : // points = TmpArray so do nothing this->NumberOfPoints = TmpArray->GetNumberOfElements() / 3; break; } } } ArrayIndex++; } while( ( ArrayIndex < 3 ) && ( PointsElement != NULL ) ); } else { if( this->GeometryType == XDMF_GEOMETRY_ORIGIN_DXDYDZ ) { XdmfDataItem PointsItem; PointsItem.SetDOM(this->DOM); PointsItem.SetDsmBuffer(this->DsmBuffer); XdmfDebug("Reading Origin and Dx, Dy, Dz" ); PointsElement = this->DOM->FindDataElement(0, this->Element ); if( PointsElement ){ if(PointsItem.SetElement(PointsElement, 0) == XDMF_FAIL) return(XDMF_FAIL); if(PointsItem.UpdateInformation() == XDMF_FAIL) return(XDMF_FAIL); if(PointsItem.Update() == XDMF_FAIL) return(XDMF_FAIL); TmpArray = PointsItem.GetArray(); if( TmpArray ){ TmpArray->GetValues( 0, this->Origin, 3 ); } PointsElement = this->DOM->FindDataElement(1, this->Element ); if( PointsElement ){ if(PointsItem.SetElement(PointsElement, 0) == XDMF_FAIL) return(XDMF_FAIL); if(PointsItem.UpdateInformation() == XDMF_FAIL) return(XDMF_FAIL); if(PointsItem.Update() == XDMF_FAIL) return(XDMF_FAIL); TmpArray = PointsItem.GetArray(); if( TmpArray ){ TmpArray->GetValues( 0, this->DxDyDz, 3 ); } } else { XdmfErrorMessage("No Dx, Dy, Dz Specified"); return( XDMF_FAIL ); } } else { XdmfErrorMessage("No Origin Specified"); return( XDMF_FAIL ); } } else if( this->GeometryType == XDMF_GEOMETRY_ORIGIN_DXDY ) { XdmfDataItem PointsItem; PointsItem.SetDOM(this->DOM); PointsItem.SetDsmBuffer(this->DsmBuffer); XdmfDebug("Reading Origin and Dx, Dy" ); PointsElement = this->DOM->FindDataElement(0, this->Element ); if( PointsElement ){ if(PointsItem.SetElement(PointsElement, 0) == XDMF_FAIL) return(XDMF_FAIL); if(PointsItem.UpdateInformation() == XDMF_FAIL) return(XDMF_FAIL); if(PointsItem.Update() == XDMF_FAIL) return(XDMF_FAIL); TmpArray = PointsItem.GetArray(); if( TmpArray ){ TmpArray->GetValues( 0, this->Origin, 2 ); } PointsElement = this->DOM->FindDataElement(1, this->Element ); if( PointsElement ){ if(PointsItem.SetElement(PointsElement, 0) == XDMF_FAIL) return(XDMF_FAIL); if(PointsItem.UpdateInformation() == XDMF_FAIL) return(XDMF_FAIL); if(PointsItem.Update() == XDMF_FAIL) return(XDMF_FAIL); TmpArray = PointsItem.GetArray(); if( TmpArray ){ TmpArray->GetValues( 0, this->DxDyDz, 2 ); } } else { XdmfErrorMessage("No Dx, Dy Specified"); return( XDMF_FAIL ); } } else { XdmfErrorMessage("No Origin Specified"); return( XDMF_FAIL ); } } else if( this->GeometryType == XDMF_GEOMETRY_VXVYVZ ) { XdmfDebug("Reading VectorX, VectorY, VectorZ" ); PointsElement = this->DOM->FindDataElement(0, this->Element ); if( PointsElement ){ XdmfDataItem PointsItem; PointsItem.SetDOM(this->DOM); if(PointsItem.SetElement(PointsElement, 0) == XDMF_FAIL) return(XDMF_FAIL); if(PointsItem.UpdateInformation() == XDMF_FAIL) return(XDMF_FAIL); if(PointsItem.Update() == XDMF_FAIL) return(XDMF_FAIL); TmpArray = PointsItem.GetArray(); if(!TmpArray){ XdmfErrorMessage("Error Reading Points X Vector"); return(XDMF_FAIL); } this->VectorX = TmpArray; this->VectorXIsMine = 1; PointsItem.SetArrayIsMine(0); } else { XdmfErrorMessage("No VectorX Specified"); return( XDMF_FAIL ); } PointsElement = this->DOM->FindDataElement(1, this->Element ); if( PointsElement ){ XdmfDataItem PointsItem; PointsItem.SetDOM(this->DOM); if(PointsItem.SetElement(PointsElement, 0) == XDMF_FAIL) return(XDMF_FAIL); if(PointsItem.UpdateInformation() == XDMF_FAIL) return(XDMF_FAIL); if(PointsItem.Update() == XDMF_FAIL) return(XDMF_FAIL); TmpArray = PointsItem.GetArray(); if(!TmpArray){ XdmfErrorMessage("Error Reading Points Y Vector"); return(XDMF_FAIL); } this->VectorY = TmpArray; this->VectorYIsMine = 1; PointsItem.SetArrayIsMine(0); } else { XdmfErrorMessage("No VectorY Specified"); return( XDMF_FAIL ); } PointsElement = this->DOM->FindDataElement(2, this->Element ); if( PointsElement ){ XdmfDataItem PointsItem; PointsItem.SetDOM(this->DOM); if(PointsItem.SetElement(PointsElement, 0) == XDMF_FAIL) return(XDMF_FAIL); if(PointsItem.UpdateInformation() == XDMF_FAIL) return(XDMF_FAIL); if(PointsItem.Update() == XDMF_FAIL) return(XDMF_FAIL); TmpArray = PointsItem.GetArray(); if(!TmpArray){ XdmfErrorMessage("Error Reading Points Z Vector"); return(XDMF_FAIL); } this->VectorZ = TmpArray; this->VectorZIsMine = 1; PointsItem.SetArrayIsMine(0); } else { XdmfErrorMessage("No VectorZ Specified"); return( XDMF_FAIL ); } } else if( this->GeometryType == XDMF_GEOMETRY_VXVY) { XdmfDebug("Reading VectorX, VectorY" ); PointsElement = this->DOM->FindDataElement(0, this->Element ); if( PointsElement ){ XdmfDataItem PointsItem; PointsItem.SetDOM(this->DOM); if(PointsItem.SetElement(PointsElement, 0) == XDMF_FAIL) return(XDMF_FAIL); if(PointsItem.UpdateInformation() == XDMF_FAIL) return(XDMF_FAIL); if(PointsItem.Update() == XDMF_FAIL) return(XDMF_FAIL); TmpArray = PointsItem.GetArray(); if(!TmpArray){ XdmfErrorMessage("Error Reading Points X Vector"); return(XDMF_FAIL); } this->VectorX = TmpArray; this->VectorXIsMine = 1; PointsItem.SetArrayIsMine(0); } else { XdmfErrorMessage("No VectorX Specified"); return( XDMF_FAIL ); } PointsElement = this->DOM->FindDataElement(1, this->Element ); if( PointsElement ){ XdmfDataItem PointsItem; PointsItem.SetDOM(this->DOM); if(PointsItem.SetElement(PointsElement, 0) == XDMF_FAIL) return(XDMF_FAIL); if(PointsItem.UpdateInformation() == XDMF_FAIL) return(XDMF_FAIL); if(PointsItem.Update() == XDMF_FAIL) return(XDMF_FAIL); TmpArray = PointsItem.GetArray(); if(!TmpArray){ XdmfErrorMessage("Error Reading Points Y Vector"); return(XDMF_FAIL); } this->VectorY = TmpArray; this->VectorYIsMine = 1; PointsItem.SetArrayIsMine(0); } else { XdmfErrorMessage("No VectorY Specified"); return( XDMF_FAIL ); } } } if( points ){ this->SetPoints( points ); this->PointsAreMine = 1; } return( XDMF_SUCCESS ); } xdmf-3.0+git20160803/libsrc/XdmfSet.h0000640000175000017500000001047613003006557017103 0ustar alastairalastair#ifndef __XdmfSet_h #define __XdmfSet_h #include "XdmfElement.h" // Maximum number of faces or edges in a cell #define XDMF_SET_MAX_ORDER 50 // Where Ids are Assigned #define XDMF_SET_TYPE_UNSET -1 #define XDMF_SET_TYPE_NODE 1 #define XDMF_SET_TYPE_CELL 2 #define XDMF_SET_TYPE_FACE 3 #define XDMF_SET_TYPE_EDGE 4 // Forward declaration of Xdmf classes class XdmfTopology; class XdmfDataDesc; class XdmfArray; class XdmfAttribute; class XdmfMap; //! Class to support data side Sets. /*! XdmfSet is a Class that handles sets of nodes,cells,faces, and edges on an XdmfGrid. They may be centered on the Node, Edge, Face, Cell. An XdmfSet can have from 1 to 3 DataItems. The last DataItem is always the "Ids" or the indexes into Nodes, Cells, etc. If SetType is "Face" or "Edge", the First DataItem defines the CellIds. If SetType is "Edge" second DataItem defines FaceIds \verbatim XML Element Name : Set XML Set : Name XML Set : SetType = Node* | Cell | Grid | Face | Edge XML Set : Ghost = # Ghost node/cell owner if > 0 ; usually 1 XML Set : FaceOrder = "0 1 ..." Mapping to Default Order XML Set : EdgeOrder = "0 1 ..." Mapping to Default Order Example : 1 2 3 4 100.0 110.0 100.0 200.0 Or for Ghosr Cells 3 40 \endverbatim */ class XDMF_EXPORT XdmfSet : public XdmfElement{ public: XdmfSet(); ~XdmfSet(); XdmfConstString GetClassName() { return ( "XdmfSet" ) ; }; XdmfInt32 SetSetTypeFromString( XdmfConstString SetType ); XdmfConstString GetSetTypeAsString( void ); //! Set the Center /*! Set Type \param Value XDMF_SET_TYPE_CELL | XDMF_SET_TYPE_FACE | XDMF_SET_TYPE_EDGE | XDMF_SET_TYPE_NODE */ XdmfSetValueMacro( SetType, XdmfInt32 ); //! Returns the Set Type XdmfGetValueMacro( SetType, XdmfInt32 ); //! Get the Size (Length) of the Set XdmfGetValueMacro( Size, XdmfInt64 ); //! Set the Size (Length) of the Set XdmfSetValueMacro( Size, XdmfInt64 ); //! Get the Ghost Value of the Set XdmfGetValueMacro( Ghost, XdmfInt64 ); //! Set the Ghost Value of the Set XdmfSetValueMacro( Ghost, XdmfInt64 ); //! Returns the Shape of the attribute XdmfDataDesc *GetShapeDesc( void ) { return( this->ShapeDesc ); }; //! Insert an Element XdmfInt32 Insert(XdmfElement *Child); //! Sets the values for the Set XdmfInt32 SetIds(XdmfArray *Ids); //! Retrieves the Ids of the Set, create one by default XdmfArray *GetIds(XdmfInt32 Create=1); //! Sets the Ids for the Set XdmfInt32 SetCellIds(XdmfArray *Ids); //! Retrieves the Ids of the Set, create one by default XdmfArray *GetCellIds(XdmfInt32 Create=1); //! Sets the values for the Set XdmfInt32 SetFaceIds(XdmfArray *Ids); //! Retrieves the Ids of the Set, create one by default XdmfArray *GetFaceIds(XdmfInt32 Create=1); //! Get the NumberOfMaps XdmfGetValueMacro( NumberOfMaps, XdmfInt32 ); //! Get Particular Map XdmfGetIndexValueMacro( Map, XdmfMap * ); //! Get the NumberOfAttributes XdmfGetValueMacro( NumberOfAttributes, XdmfInt32 ); //! Get Particular Attribute XdmfGetIndexValueMacro( Attribute, XdmfAttribute * ); //! Initialize but don't read the Heavy Data XdmfInt32 UpdateInformation(); //! Initialize and Read the Heavy Data XdmfInt32 Update(); //! Build XML (output) XdmfInt32 Build(); //! Release Big Data XdmfInt32 Release(); protected: XdmfInt32 SetType; XdmfInt32 FaceOrder[XDMF_SET_MAX_ORDER]; XdmfInt32 EdgeOrder[XDMF_SET_MAX_ORDER]; XdmfDataDesc *ShapeDesc; XdmfInt32 IdsAreMine; XdmfInt32 NumberOfMaps; XdmfMap **Map; XdmfInt32 NumberOfAttributes; XdmfAttribute **Attribute; XdmfArray *Ids; XdmfInt32 CellIdsAreMine; XdmfArray *CellIds; XdmfInt32 FaceIdsAreMine; XdmfArray *FaceIds; XdmfInt32 Active; XdmfInt64 Size; XdmfInt64 Ghost; }; #endif // __XdmfSet_h xdmf-3.0+git20160803/libsrc/XdmfExpr.h0000640000175000017500000000464513003006557017267 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : $Id: XdmfExpr.h,v 1.2 2009-01-23 20:31:39 clarke Exp $ */ /* Date : $Date: 2009-01-23 20:31:39 $ */ /* Version : $Revision: 1.2 $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2002 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #include "XdmfConfig.h" #include #include #include /* Symbol Table */ #ifdef __cplusplus extern "C" { #endif typedef struct XdmfExprSymbolStruct { struct XdmfExprSymbolStruct *Next; char *Name; void *ClientData; double DoubleValue; double (*DoubleFunctionPtr)( double Argument ); } XdmfExprSymbol; extern int XdmfExprInput( void ); extern int XdmfExprFlexInput( char *buf, int maxlen ); extern void XdmfExprUnput( int c ); extern void XdmfExprOutput( int c ); /* #define input() XdmfExprInput() #define unput(c) XdmfExprUnput((c)) #define output(c) XdmfExprOutput( ( c ) ) */ /** Using Bison **/ #define YY_INPUT(buf, result, maxlen) { result = XdmfExprFlexInput( (buf), (maxlen)); } extern XdmfExprSymbol *XdmfExprSymbolLookup( const char *Name ); #ifdef __cplusplus } #endif xdmf-3.0+git20160803/libsrc/XdmfDataTransform.cxx0000640000175000017500000000366013003006557021465 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Values */ /* */ /* Id : $Id: XdmfDataTransform.cxx,v 1.2 2009-01-23 20:31:39 clarke Exp $ */ /* Date : $Date: 2009-01-23 20:31:39 $ */ /* Version : $Revision: 1.2 $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2002 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #include "XdmfDataTransform.h" #include "XdmfArray.h" XdmfDataTransform::XdmfDataTransform() { this->ItemType = XDMF_ITEM_FUNCTION; } XdmfDataTransform::~XdmfDataTransform() { } XdmfInt32 XdmfDataTransform::UpdateInformation(){ if(XdmfDataItem::UpdateInformation() != XDMF_SUCCESS) return(XDMF_FAIL); return(XDMF_SUCCESS); } xdmf-3.0+git20160803/libsrc/XdmfDomain.cxx0000640000175000017500000000561713003006557020133 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : $Id: XdmfDomain.cxx,v 1.3 2009-05-26 15:18:57 clarke Exp $ */ /* Date : $Date: 2009-05-26 15:18:57 $ */ /* Version : $Revision: 1.3 $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2002 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #include "XdmfDomain.h" #include "XdmfGrid.h" XdmfDomain::XdmfDomain() { this->SetElementName("Domain"); } XdmfDomain::~XdmfDomain() { } XdmfInt32 XdmfDomain::UpdateInformation(){ if(XdmfElement::UpdateInformation() != XDMF_SUCCESS) return(XDMF_FAIL); return(XDMF_SUCCESS); } XdmfInt32 XdmfDomain::Insert( XdmfElement *Child){ if(Child && ( XDMF_WORD_CMP(Child->GetElementName(), "DataItem") || XDMF_WORD_CMP(Child->GetElementName(), "Grid") || XDMF_WORD_CMP(Child->GetElementName(), "Information") )){ XdmfInt32 status = XdmfElement::Insert(Child); if((status == XDMF_SUCCESS) && XDMF_WORD_CMP(Child->GetElementName(), "Grid")){ XdmfGrid *ChildGrid = (XdmfGrid *)Child; if((ChildGrid->GetGridType() & XDMF_GRID_MASK) == XDMF_GRID_UNIFORM){ if(ChildGrid->InsertTopology() != XDMF_SUCCESS) return(XDMF_FAIL); if(ChildGrid->InsertGeometry() != XDMF_SUCCESS) return(XDMF_FAIL); } } return(status); }else{ XdmfErrorMessage("Domain can only Insert Grid | DataItem | Information elements, not a " << Child->GetElementName()); } return(XDMF_FAIL); } XdmfInt32 XdmfDomain::Build(){ if(XdmfElement::Build() != XDMF_SUCCESS) return(XDMF_FAIL); return(XDMF_SUCCESS); } xdmf-3.0+git20160803/libsrc/XdmfHeavyData.h0000640000175000017500000001412513003006557020211 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : $Id: XdmfHeavyData.h,v 1.4 2009-06-23 15:33:50 clarke Exp $ */ /* Date : $Date: 2009-06-23 15:33:50 $ */ /* Version : $Revision: 1.4 $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2002 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #ifndef __XdmfHeavyData_h #define __XdmfHeavyData_h #include "XdmfArray.h" class XdmfOpenCallback; class XdmfReadCallback; class XdmfWriteCallback; class XdmfCloseCallback; //! Container class for Heavy Data Access /*! This is an abstract convenience object for reading and writing HeavyData Files. Datasets in HeavyDat are specified by : \verbatim Domain:Filename:Pathname where Domain = NDGM | FILE | CORE | GASS if Domain is not specified, FILE is assumed Filename = UNIX style Pathname of HeavyDat file Pathname = HeavyData Pathname inside HeavyData File \endverbatim */ class XDMF_EXPORT XdmfHeavyData : public XdmfDataDesc { public: XdmfHeavyData(); ~XdmfHeavyData(); XdmfConstString GetClassName() { return ( "XdmfHeavyData" ) ; }; //! Get the default NDGM Host for NDGM:File:/Dataset XdmfGetValueMacro(NdgmHost, XdmfConstString); //! Set the default NDGM Host for NDGM:File:/Dataset void SetNdgmHost( XdmfConstString String ) { strcpy( this->NdgmHost, String ); } //! Get the default Pathname for File:/Dataset XdmfGetValueMacro(WorkingDirectory, XdmfConstString); //! Set the default Pathname for File:/Dataset void SetWorkingDirectory( XdmfConstString String ); //! Get the current domain XdmfGetValueMacro(Domain, XdmfConstString); //! Set the current domain void SetDomain( XdmfConstString domain ) { strcpy( this->Domain, domain ); } ; //! Get the current filename XdmfGetValueMacro(FileName, XdmfConstString); //! Set the current filename void SetFileName( XdmfConstString File ); //! Get the current HeavyData Dataset path XdmfGetValueMacro(Path, XdmfConstString); //! Set the current HeavyData Dataset path void SetPath( XdmfConstString path ) { strcpy( this->Path, path ); } ; /*! Get the current read/write access values can be : "r" "w" "rw" */ XdmfGetValueMacro(Access, XdmfConstString); //! Set the access permissions void SetAccess( XdmfConstString access ) { strcpy( this->Access, access ); } ; //-- public interface functions for manipulating heavy data --// /// Open a heavy dataset for reading or writing. XdmfInt32 Open( XdmfConstString name = NULL, XdmfConstString access = NULL ); /// Read an array from a heavy dataset. XdmfArray* Read( XdmfArray* array = NULL ); /// Write to the heavy dataset that is currently open. XdmfInt32 Write( XdmfArray* array ); /// Close a heavy dataset. XdmfInt32 Close(); //-- Implementation Functions for manipulating heavy data --// /// Virtual function to define the implementation of Open. virtual XdmfInt32 DoOpen( XdmfConstString name, XdmfConstString access ); /// Virtual function to define the implementation of Read. virtual XdmfArray* DoRead( XdmfArray* array ); /// Virtual function to define the implementation of Write. virtual XdmfInt32 DoWrite( XdmfArray* array ); /// Virtual function to define the implementation of Close virtual XdmfInt32 DoClose(); void setOpenCallback( XdmfOpenCallback* cb ); void setReadCallback( XdmfReadCallback* cb ); void setWriteCallback( XdmfWriteCallback* cb ); void setCloseCallback( XdmfCloseCallback* cb ); protected: char NdgmHost[XDMF_MAX_STRING_LENGTH]; XdmfString WorkingDirectory; char Access[XDMF_MAX_STRING_LENGTH]; char Domain[XDMF_MAX_STRING_LENGTH]; XdmfString FileName; char Path[XDMF_MAX_STRING_LENGTH]; XdmfOpenCallback* mOpenCB; XdmfReadCallback* mReadCB; XdmfWriteCallback* mWriteCB; XdmfCloseCallback* mCloseCB; }; /// Callback function to decorate opening a heavy dataset. class XdmfOpenCallback { public : virtual XdmfInt32 DoOpen( XdmfHeavyData* ds, XdmfConstString name, XdmfConstString access ) { return ds->DoOpen( name, access ); } }; /// Callback function to decorate reading a heavy dataset. class XdmfReadCallback { public : virtual XdmfArray* DoRead( XdmfHeavyData* ds, XdmfArray* array ) { return ds->DoRead( array ); } }; /// Callback function to decorate writing a heavy dataset. class XdmfWriteCallback { public : virtual XdmfInt32 DoWrite( XdmfHeavyData* ds, XdmfArray* array ) { return ds->DoWrite( array ); } }; /// Callback function to decorate closing a heavy dataset. class XdmfCloseCallback { public : virtual XdmfInt32 DoClose( XdmfHeavyData* ds ) { return ds->DoClose(); } }; /* extern "C" { extern XdmfString XdmfGetNdgmEntries( void ); extern void XdmfDeleteAllNdgmEntries( void ); extern XdmfInt64 XdmfAddNdgmEntry( XdmfString Name, XdmfInt64 Length ); } */ #endif // __XdmfHeavyData_h xdmf-3.0+git20160803/libsrc/XdmfMap.cxx0000640000175000017500000002243313003006557017434 0ustar alastairalastair#include "XdmfMap.h" #include "XdmfDataItem.h" #include "XdmfDataDesc.h" #include "XdmfArray.h" #include "XdmfDOM.h" XdmfMap::XdmfMap() { this->SetElementName("Map"); this->IdsAreMine = 1; this->MapIndexAreMine = 1; this->MapDataAreMine = 1; this->MapType = XDMF_MAP_TYPE_UNSET; this->Ids = NULL; this->MapIndex = NULL; this->MapData = NULL; this->ItemLength = 0; this->MapLength = 0; } XdmfMap::~XdmfMap() { if( this->IdsAreMine && this->Ids ) delete this->Ids; if( this->MapIndexAreMine && this->MapIndex ) delete this->MapIndex; if( this->MapDataAreMine && this->MapData ) delete this->MapData; } XdmfInt32 XdmfMap::Release(){ if( this->IdsAreMine && this->Ids ) delete this->Ids; this->Ids = NULL; if( this->MapIndexAreMine && this->Ids ) delete this->MapIndex; this->MapIndex = NULL; if( this->MapDataAreMine && this->Ids ) delete this->MapData; this->MapData = NULL; return(XDMF_SUCCESS); } XdmfInt32 XdmfMap::Insert( XdmfElement *Child){ if(Child && ( XDMF_WORD_CMP(Child->GetElementName(), "DataItem") || XDMF_WORD_CMP(Child->GetElementName(), "Information") )){ return(XdmfElement::Insert(Child)); }else{ XdmfErrorMessage("Map can only Insert DataItem or Information elements"); } return(XDMF_FAIL); } XdmfInt32 XdmfMap::Build(){ if(XdmfElement::Build() != XDMF_SUCCESS) return(XDMF_FAIL); this->Set("MapType", this->GetMapTypeAsString()); if(this->ItemLength > 0){ ostrstream StringOutput; StringOutput << this->ItemLength << ends; this->Set("ItemLength", StringOutput.str()); } if(this->MapLength > 0){ ostrstream StringOutput; StringOutput << this->MapLength << ends; this->Set("MapLength", StringOutput.str()); } if(this->Ids){ XdmfDataItem *di = NULL; XdmfXmlNode node; //! Is there already a DataItem node = this->DOM->FindDataElement(0, this->GetElement()); if(node) { di = (XdmfDataItem *)this->GetCurrentXdmfElement(node); } if(!di){ di = new XdmfDataItem; node = this->DOM->InsertNew(this->GetElement(), "DataItem"); di->SetDOM(this->DOM); di->SetElement(node); } di->SetArray(this->Ids); if(this->Ids->GetNumberOfElements() > 100) di->SetFormat(XDMF_FORMAT_HDF); di->Build(); } if(this->MapIndex){ XdmfDataItem *di = NULL; XdmfXmlNode node; //! Is there already a DataItem node = this->DOM->FindDataElement(0, this->GetElement()); if(node) { di = (XdmfDataItem *)this->GetCurrentXdmfElement(node); } if(!di){ di = new XdmfDataItem; node = this->DOM->InsertNew(this->GetElement(), "DataItem"); di->SetDOM(this->DOM); di->SetElement(node); } di->SetArray(this->MapIndex); if(this->MapIndex->GetNumberOfElements() > 100) di->SetFormat(XDMF_FORMAT_HDF); di->Build(); } if(this->MapData){ XdmfDataItem *di = NULL; XdmfXmlNode node; //! Is there already a DataItem node = this->DOM->FindDataElement(0, this->GetElement()); if(node) { di = (XdmfDataItem *)this->GetCurrentXdmfElement(node); } if(!di){ di = new XdmfDataItem; node = this->DOM->InsertNew(this->GetElement(), "DataItem"); di->SetDOM(this->DOM); di->SetElement(node); } di->SetArray(this->MapData); if(this->MapData->GetNumberOfElements() > 100) di->SetFormat(XDMF_FORMAT_HDF); di->Build(); } return(XDMF_SUCCESS); } XdmfConstString XdmfMap::GetMapTypeAsString( void ){ switch ( this->MapType ){ case XDMF_MAP_TYPE_CELL : return( "Cell" ); case XDMF_MAP_TYPE_FACE : return( "Face" ); case XDMF_MAP_TYPE_EDGE : return( "Edge" ); case XDMF_MAP_TYPE_NODE : return( "Node" ); case XDMF_MAP_TYPE_UNSET : return( "Unset" ); default : break; } XdmfErrorMessage("Unknown MapType = " << this->MapType); return(0); } XdmfInt32 XdmfMap::SetMapTypeFromString( XdmfConstString regionType ){ if( XDMF_WORD_CMP( regionType, "Cell" ) ) { this->MapType = XDMF_MAP_TYPE_CELL; } else if( XDMF_WORD_CMP( regionType, "Face" ) ) { this->MapType = XDMF_MAP_TYPE_FACE; } else if( XDMF_WORD_CMP( regionType, "Edge" ) ) { this->MapType = XDMF_MAP_TYPE_EDGE; } else if( XDMF_WORD_CMP( regionType, "Node" ) ) { this->MapType = XDMF_MAP_TYPE_NODE; } else { XdmfErrorMessage("Unknown Set Type " << regionType ); return( XDMF_FAIL ); } return( XDMF_SUCCESS ); } // Ids XdmfInt32 XdmfMap::SetIds(XdmfArray *someIds){ if(someIds == this->Ids) return(XDMF_SUCCESS); if(this->IdsAreMine && this->Ids) delete this->Ids; this->IdsAreMine = 0; this->Ids = someIds; return(XDMF_SUCCESS); } XdmfArray * XdmfMap::GetIds(XdmfInt32 Create){ if(!this->Ids && Create){ this->Ids = new XdmfArray; this->IdsAreMine = 1; } return(this->Ids); } // MapIndex XdmfInt32 XdmfMap::SetMapIndex(XdmfArray *someMapIndex){ if(someMapIndex == this->MapIndex) return(XDMF_SUCCESS); if(this->MapIndexAreMine && this->MapIndex) delete this->MapIndex; this->MapIndexAreMine = 0; this->MapIndex = someMapIndex; return(XDMF_SUCCESS); } XdmfArray * XdmfMap::GetMapIndex(XdmfInt32 Create){ if(!this->MapIndex && Create){ this->MapIndex = new XdmfArray; this->MapIndexAreMine = 1; } return(this->MapIndex); } // MapData XdmfInt32 XdmfMap::SetMapData(XdmfArray *someMapData){ if(someMapData == this->MapData) return(XDMF_SUCCESS); if(this->MapDataAreMine && this->MapData) delete this->MapData; this->MapDataAreMine = 0; this->MapData = someMapData; return(XDMF_SUCCESS); } XdmfArray * XdmfMap::GetMapData(XdmfInt32 Create){ if(!this->MapData && Create){ this->MapData = new XdmfArray; this->MapDataAreMine = 1; } return(this->MapData); } XdmfInt32 XdmfMap::UpdateInformation() { XdmfConstString Value; if(XdmfElement::UpdateInformation() != XDMF_SUCCESS) return(XDMF_FAIL); if( XDMF_WORD_CMP(this->GetElementType(), "Map") == 0){ XdmfErrorMessage("Element type" << this->GetElementType() << " is not of type 'Map'"); return(XDMF_FAIL); } Value = this->Get( "MapType" ); if( Value ){ this->SetMapTypeFromString( Value ); } else { this->MapType = XDMF_MAP_TYPE_NODE; } Value = this->Get("ItemLength"); if(Value){ XdmfInt32 iValue = 0; istrstream Value_ist(const_cast(Value), strlen(Value) ); Value_ist >> iValue; this->SetItemLength(iValue); } Value = this->Get("MapLength"); if(Value){ XdmfInt64 iValue = 0; istrstream Value_ist(const_cast(Value), strlen(Value) ); Value_ist >> iValue; this->SetMapLength(iValue); } if(!this->Name) this->SetName(GetUnique("Map_")); return( XDMF_SUCCESS ); } XdmfInt32 XdmfMap::Update() { XdmfInt32 Status; XdmfInt32 NumberOfDataItems = 1; XdmfInt32 i; // check this out if(XdmfElement::Update() != XDMF_SUCCESS) return(XDMF_FAIL); if( this->MapType == XDMF_MAP_TYPE_UNSET ){ Status = this->UpdateInformation(); if( Status == XDMF_FAIL ) { XdmfErrorMessage("Can't Initialize"); return( XDMF_FAIL ); } } NumberOfDataItems = this->DOM->FindNumberOfElements("DataItem", this->Element); if(NumberOfDataItems < 2){ XdmfErrorMessage("Map must have at least 2 DataItems"); return(XDMF_FAIL); } for(i=0 ; i < NumberOfDataItems ; i++){ XdmfXmlNode IdsNode; XdmfInt32 *Mine; XdmfArray **Array; if(NumberOfDataItems == 2){ switch (i){ case 0 : Mine = &this->MapIndexAreMine; Array = &this->MapIndex; break; default : Mine = &this->MapDataAreMine; Array = &this->MapData; break; } }else{ // NumberOfDataItems == 3 switch (i){ case 0 : Mine = &this->IdsAreMine; Array = &this->Ids; break; case 1 : Mine = &this->MapIndexAreMine; Array = &this->MapIndex; break; default : Mine = &this->MapDataAreMine; Array = &this->MapData; break; } } IdsNode = this->DOM->FindDataElement(i, Element ); if( IdsNode ){ XdmfDataItem ValueReader; ValueReader.SetDOM( this->DOM ); ValueReader.SetDsmBuffer(this->DsmBuffer); if(ValueReader.SetElement(IdsNode) == XDMF_FAIL) return(XDMF_FAIL); if(ValueReader.UpdateInformation() == XDMF_FAIL) return(XDMF_FAIL); if(ValueReader.Update() == XDMF_FAIL) return(XDMF_FAIL); if( *Mine && *Array){ delete *Array; *Mine = 0; } // Steal the array *Array = ValueReader.GetArray(); if( *Array == 0 ) { XdmfErrorMessage("Error Retrieving Data Ids"); return( XDMF_FAIL ); } ValueReader.SetArrayIsMine(0); *Mine = 1; } else { XdmfErrorMessage("Map does not have enough DataItems. Error reading DataItem #" << i); return( XDMF_FAIL ); } } return( XDMF_SUCCESS ); } xdmf-3.0+git20160803/libsrc/XdmfRoot.cxx0000640000175000017500000000612713003006557017644 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : $Id: XdmfRoot.cxx,v 1.7 2009-01-30 17:30:06 clarke Exp $ */ /* Date : $Date: 2009-01-30 17:30:06 $ */ /* Version : $Revision: 1.7 $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2002 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #include "XdmfRoot.h" #include "XdmfDOM.h" #include XdmfRoot::XdmfRoot() { this->SetElementName("Xdmf"); this->Version = (XdmfFloat32)XDMF_VERSION; this->XInclude = 1; } XdmfRoot::~XdmfRoot() { } XdmfInt32 XdmfRoot::UpdateInformation(){ XdmfConstString Value; XdmfElement::UpdateInformation(); Value = this->Get("Version"); if(Value) this->SetVersion((XdmfFloat32)atof(Value)); Value = this->Get("XInclude"); if(!Value) this->SetXInclude(atoi(Value)); return(XDMF_SUCCESS); } XdmfInt32 XdmfRoot::Insert( XdmfElement *Child){ if(Child && ( XDMF_WORD_CMP(Child->GetElementName(), "Domain") || XDMF_WORD_CMP(Child->GetElementName(), "DataItem") || XDMF_WORD_CMP(Child->GetElementName(), "Information") )){ return(XdmfElement::Insert(Child)); }else{ XdmfErrorMessage("Xdmf Root can only Insert Domain | DataItem | Information elements, not a " << Child->GetElementName()); } return(XDMF_FAIL); } XdmfInt32 XdmfRoot::Build(){ static char VersionBuf[80]; ostrstream aVersion(VersionBuf,80); if(!this->GetElement()){ if(this->GetDOM()){ XdmfXmlNode node; node = this->GetDOM()->Create(this->GetElementName()); this->SetElement(node); } } if(XdmfElement::Build() != XDMF_SUCCESS) return(XDMF_FAIL); // Version and XInclude aVersion << this->Version << ends; this->Set("Version", (XdmfConstString)aVersion.str()); return(XDMF_SUCCESS); } xdmf-3.0+git20160803/libsrc/XdmfValuesHDF.h0000640000175000017500000000507413003006557020127 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and ValuesHDF */ /* */ /* Id : $Id: XdmfValuesHDF.h,v 1.4 2009-01-26 21:15:21 clarke Exp $ */ /* Date : $Date: 2009-01-26 21:15:21 $ */ /* Version : $Revision: 1.4 $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2002 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #ifndef __XdmfValuesHDF_h #define __XdmfValuesHDF_h #include "XdmfValues.h" //! Parent Class for handeling I/O of actual data for an XdmfDataItem /*! An HDF XdmfDataItem Node Looks like : \verbatim MyData.h5:/AllValuesHDF/ThisArray \endverbatim XdmfValuesHDF is used to access the "MyData.h5:/AllValuesHDF/ThisArray" part wheather it's in the HDF. */ class XDMF_EXPORT XdmfValuesHDF : public XdmfValues { public : XdmfValuesHDF(); virtual ~XdmfValuesHDF(); XdmfConstString GetClassName() { return("XdmfValuesHDF"); } ; //! Read the Array from the External Representation XdmfArray *Read(XdmfArray *Array=NULL); //! Write the Array to the External Representation XdmfInt32 Write(XdmfArray *Array, XdmfConstString HeavyDataSetName=NULL); //! Produce Xml for an existing HDF5 Dataset XdmfString DataItemFromHDF(XdmfConstString H5DataSet); protected : }; #endif xdmf-3.0+git20160803/libsrc/XdmfDsmComm.cxx0000640000175000017500000000540313003006557020254 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : $Id: XdmfDsmComm.cxx,v 1.6 2009-09-07 14:46:07 biddisco Exp $ */ /* Date : $Date: 2009-09-07 14:46:07 $ */ /* Version : $Revision: 1.6 $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2007 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #include "XdmfDsmComm.h" #include "XdmfDsmMsg.h" XdmfDsmComm::XdmfDsmComm() { } XdmfDsmComm::~XdmfDsmComm() { } XdmfInt32 XdmfDsmComm::Init(){ return(XDMF_SUCCESS); } XdmfInt32 XdmfDsmComm::Check(XdmfDsmMsg *Msg){ if(Msg->Tag <= 0) Msg->Tag = XDMF_DSM_DEFAULT_TAG; return(XDMF_SUCCESS); } XdmfInt32 XdmfDsmComm::Receive(XdmfDsmMsg *Msg){ if(Msg->Tag <= 0) Msg->Tag = XDMF_DSM_DEFAULT_TAG; if(Msg->Length <= 0 ){ XdmfErrorMessage("Cannot Receive Message of Length = " << Msg->Length); return(XDMF_FAIL); } if(Msg->Data <= 0 ){ XdmfErrorMessage("Cannot Receive Message into Data Buffer = " << Msg->Length); return(XDMF_FAIL); } return(XDMF_SUCCESS); } XdmfInt32 XdmfDsmComm::Send(XdmfDsmMsg *Msg){ if(Msg->Tag <= 0) Msg->Tag = XDMF_DSM_DEFAULT_TAG; if(Msg->Length <= 0 ){ XdmfErrorMessage("Cannot Send Message of Length = " << Msg->Length); return(XDMF_FAIL); } if(Msg->Data <= 0 ){ XdmfErrorMessage("Cannot Send Message from Data Buffer = " << Msg->Length); return(XDMF_FAIL); } return(XDMF_SUCCESS); } XdmfInt32 XdmfDsmComm::Barrier(){ return(XDMF_SUCCESS); } xdmf-3.0+git20160803/libsrc/XdmfArray.h0000640000175000017500000003774513003006557017436 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : $Id: XdmfArray.h,v 1.8 2010-03-24 20:03:48 kwleiter Exp $ */ /* Date : $Date: 2010-03-24 20:03:48 $ */ /* Version : $Revision: 1.8 $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2002 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #ifndef __XdmfArray_h #define __XdmfArray_h #include "XdmfDataDesc.h" #define XDMF_LONGEST_LENGTH (XdmfInt64)~0 #define XDMF_ARRAY_TAG_LENGTH 80 //! Self Describing Data Structure /*! This is the SuperClass for All XDMF Arrays. XDMF Arrays allow the user to set and query the number of elements and will automatically re-allocate enough space. You can also set the pointer directly. XdmfArray is a self-describing data structure. It is derived from XdmfDataDesc so it understands the number type and the \b SHAPE of the data. An XdmfArray is a homogeneous array (each element of the array is the same type). Access to HDF5 files is accomplished directly thru XdmfArrays by the XdmfHDF class. */ #ifndef SWIG #include #endif class XDMF_EXPORT XdmfArray : public XdmfDataDesc { public: XdmfArray(); #ifndef SWIG XdmfArray( XdmfInt32 NumberType ); XdmfArray( XdmfInt32 NumberType, XdmfLength Length ); #endif ~XdmfArray(); XdmfConstString GetClassName( void ) { return ( "XdmfArray" ) ; }; //! Get the \b NAME of the array XdmfString GetTagName( void ); //! Get the length ( in bytes ) of the current data array XdmfLength GetCoreLength( ) { return ( this->GetElementSize() * this->GetNumberOfElements() ) ; } ; XdmfInt32 Allocate( void ); //! Allow for automatic allocation of data buffer XdmfSetValueMacro(AllowAllocate, XdmfBoolean); XdmfGetValueMacro(AllowAllocate, XdmfBoolean); //! Overloaded SetShape to Allocate space XdmfInt32 SetShape( XdmfInt32 Rank, XdmfInt64 *Dimensions ); XdmfInt32 SetShapeFromString( XdmfConstString Dimensions ); XdmfInt32 SetShapeFromSelection( XdmfDataDesc *DataDesc); XdmfInt32 SetNumberOfElements( XdmfInt64 Length ) { return( this->SetShape( 1, &Length ) ); }; //! Reshape without changing (allocating) number of elements XdmfInt32 ReformFromString( XdmfConstString Dimensions ); XdmfInt32 ReformFromSelection( XdmfDataDesc *DataDesc); #ifndef SWIG XdmfInt32 Reform( XdmfInt32 Rank, XdmfInt64 *Dimensions ); XdmfInt32 Reform( XdmfDataDesc *DataDesc ); XdmfInt32 CopyShape( hid_t DataSpace ); #endif XdmfInt32 CopyShape( XdmfDataDesc *DataDesc ); //! Get the undelying data for fast access \b CAUTION !! XdmfPointer GetDataPointer( XdmfInt64 Index = 0 ); void SetDataPointer( XdmfPointer Pointer ){ if( this->DataIsMine && this->DataPointer ){ free( this->DataPointer ); } this->DataPointer = Pointer; this->DataIsMine = 0; } void Reset( XdmfInt32 Free=0 ){ // XdmfInt64 Length = 1; if( Free && this->DataIsMine && this->DataPointer ){ free( this->DataPointer ); } this->DataPointer = 0; this->DataIsMine = 1; // this->Reform(1, &Length); } /*! Methods to Set Values of Elements */ XdmfInt32 SetValueFromFloat64( XdmfInt64 Index, XdmfFloat64 Value ); XdmfInt32 SetValueFromInt64( XdmfInt64 Index, XdmfInt64 Value ); XdmfInt32 SetValues( XdmfInt64 Index, XdmfArray *Values, XdmfInt64 NumberOfValues, XdmfInt64 ValuesStart = 0, XdmfInt64 ArrayStride = 1, XdmfInt64 ValuesStride = 1 ); #ifndef SWIG /*! The Following Methods are NOT directly available via SWIG */ XdmfInt32 SetValue( XdmfInt64 Index, XdmfUInt8 Value ); XdmfInt32 SetValue( XdmfInt64 Index, XdmfUInt16 Value ); XdmfInt32 SetValue( XdmfInt64 Index, XdmfUInt32 Value ); XdmfInt32 SetValue( XdmfInt64 Index, XdmfInt8 Value ); XdmfInt32 SetValue( XdmfInt64 Index, XdmfInt16 Value ); XdmfInt32 SetValue( XdmfInt64 Index, XdmfInt32 Value ); XdmfInt32 SetValue( XdmfInt64 Index, XdmfInt64 Value ); XdmfInt32 SetValue( XdmfInt64 Index, XdmfFloat32 Value ); XdmfInt32 SetValue( XdmfInt64 Index, XdmfFloat64 Value ); XdmfInt32 SetValues( XdmfInt64 Index, XdmfUInt8 *Values, XdmfInt64 NumberOfValues, XdmfInt64 ArrayStride = 1, XdmfInt64 ValuesStride = 1 ); XdmfInt32 SetValues( XdmfInt64 Index, XdmfUInt16 *Values, XdmfInt64 NumberOfValues, XdmfInt64 ArrayStride = 1, XdmfInt64 ValuesStride = 1 ); XdmfInt32 SetValues( XdmfInt64 Index, XdmfUInt32 *Values, XdmfInt64 NumberOfValues, XdmfInt64 ArrayStride = 1, XdmfInt64 ValuesStride = 1 ); XdmfInt32 SetValues( XdmfInt64 Index, XdmfInt8 *Values, XdmfInt64 NumberOfValues, XdmfInt64 ArrayStride = 1, XdmfInt64 ValuesStride = 1 ); XdmfInt32 SetValues( XdmfInt64 Index, XdmfInt16 *Values, XdmfInt64 NumberOfValues, XdmfInt64 ArrayStride = 1, XdmfInt64 ValuesStride = 1 ); XdmfInt32 SetValues( XdmfInt64 Index, XdmfInt32 *Values, XdmfInt64 NumberOfValues, XdmfInt64 ArrayStride = 1, XdmfInt64 ValuesStride = 1 ); XdmfInt32 SetValues( XdmfInt64 Index, XdmfInt64 *Values, XdmfInt64 NumberOfValues, XdmfInt64 ArrayStride = 1, XdmfInt64 ValuesStride = 1 ); XdmfInt32 SetValues( XdmfInt64 Index, XdmfFloat32 *Values, XdmfInt64 NumberOfValues, XdmfInt64 ArrayStride = 1, XdmfInt64 ValuesStride = 1 ); XdmfInt32 SetValues( XdmfInt64 Index, XdmfFloat64 *Values, XdmfInt64 NumberOfValues, XdmfInt64 ArrayStride = 1, XdmfInt64 ValuesStride = 1 ); XdmfInt32 GetValues( XdmfInt64 Index, XdmfUInt8 *Values, XdmfInt64 NumberOfValues, XdmfInt64 ArrayStride = 1, XdmfInt64 ValuesStride = 1 ); XdmfInt32 GetValues( XdmfInt64 Index, XdmfUInt16 *Values, XdmfInt64 NumberOfValues, XdmfInt64 ArrayStride = 1, XdmfInt64 ValuesStride = 1 ); XdmfInt32 GetValues( XdmfInt64 Index, XdmfUInt32 *Values, XdmfInt64 NumberOfValues, XdmfInt64 ArrayStride = 1, XdmfInt64 ValuesStride = 1 ); XdmfInt32 GetValues( XdmfInt64 Index, XdmfInt8 *Values, XdmfInt64 NumberOfValues, XdmfInt64 ArrayStride = 1, XdmfInt64 ValuesStride = 1 ); XdmfInt32 GetValues( XdmfInt64 Index, XdmfInt16 *Values, XdmfInt64 NumberOfValues, XdmfInt64 ArrayStride = 1, XdmfInt64 ValuesStride = 1 ); XdmfInt32 GetValues( XdmfInt64 Index, XdmfInt32 *Values, XdmfInt64 NumberOfValues, XdmfInt64 ArrayStride = 1, XdmfInt64 ValuesStride = 1 ); XdmfInt32 GetValues( XdmfInt64 Index, XdmfInt64 *Values, XdmfInt64 NumberOfValues, XdmfInt64 ArrayStride = 1, XdmfInt64 ValuesStride = 1 ); XdmfInt32 GetValues( XdmfInt64 Index, XdmfFloat32 *Values, XdmfInt64 NumberOfValues, XdmfInt64 ArrayStride = 1, XdmfInt64 ValuesStride = 1 ); XdmfInt32 GetValues( XdmfInt64 Index, XdmfFloat64 *Values, XdmfInt64 NumberOfValues, XdmfInt64 ArrayStride = 1, XdmfInt64 ValuesStride = 1 ); #endif XdmfInt32 SetValues( XdmfInt64 Index, XdmfConstString Values, XdmfInt64 ArrayStride = 1, XdmfInt64 ValuesStride = 1 ); /*! Convenience Functions so they're "wrapped" properly */ XdmfInt32 GetValuesAsInt8( XdmfInt64 Index, XdmfInt8 *Values, XdmfInt64 NumberOfValues, XdmfInt64 ArrayStride = 1, XdmfInt64 ValuesStride = 1 ) { return ( GetValues( Index, Values, NumberOfValues, ArrayStride, ValuesStride)); }; XdmfInt32 SetValuesFromInt8( XdmfInt64 Index, XdmfInt8 *Values, XdmfInt64 NumberOfValues, XdmfInt64 ArrayStride = 1, XdmfInt64 ValuesStride = 1 ) { return( SetValues( Index, Values, NumberOfValues, ArrayStride, ValuesStride)); }; XdmfInt32 GetValuesAsInt32( XdmfInt64 Index, XdmfInt32 *Values, XdmfInt64 NumberOfValues, XdmfInt64 ArrayStride = 1, XdmfInt64 ValuesStride = 1 ) { return ( GetValues( Index, Values, NumberOfValues, ArrayStride, ValuesStride)); }; XdmfInt32 SetValuesFromInt32( XdmfInt64 Index, XdmfInt32 *Values, XdmfInt64 NumberOfValues, XdmfInt64 ArrayStride = 1, XdmfInt64 ValuesStride = 1 ) { return( SetValues( Index, Values, NumberOfValues, ArrayStride, ValuesStride)); }; XdmfInt32 GetValuesAsInt64( XdmfInt64 Index, XdmfInt64 *Values, XdmfInt64 NumberOfValues, XdmfInt64 ArrayStride = 1, XdmfInt64 ValuesStride = 1 ) { return ( GetValues( Index, Values, NumberOfValues, ArrayStride, ValuesStride)); }; XdmfInt32 SetValuesFromInt64( XdmfInt64 Index, XdmfInt64 *Values, XdmfInt64 NumberOfValues, XdmfInt64 ArrayStride = 1, XdmfInt64 ValuesStride = 1 ) { return( SetValues( Index, Values, NumberOfValues, ArrayStride, ValuesStride)); }; XdmfInt32 GetValuesAsFloat32( XdmfInt64 Index, XdmfFloat32 *Values, XdmfInt64 NumberOfValues, XdmfInt64 ArrayStride = 1, XdmfInt64 ValuesStride = 1 ) { return ( GetValues( Index, Values, NumberOfValues, ArrayStride, ValuesStride)); }; XdmfInt32 SetValuesFromFloat32( XdmfInt64 Index, XdmfFloat32 *Values, XdmfInt64 NumberOfValues, XdmfInt64 ArrayStride = 1, XdmfInt64 ValuesStride = 1 ) { return( SetValues( Index, Values, NumberOfValues, ArrayStride, ValuesStride)); }; XdmfInt32 GetValuesAsFloat64( XdmfInt64 Index, XdmfFloat64 *Values, XdmfInt64 NumberOfValues, XdmfInt64 ArrayStride = 1, XdmfInt64 ValuesStride = 1 ) { return ( GetValues( Index, Values, NumberOfValues, ArrayStride, ValuesStride)); }; XdmfInt32 SetValuesFromFloat64( XdmfInt64 Index, XdmfFloat64 *Values, XdmfInt64 NumberOfValues, XdmfInt64 ArrayStride = 1, XdmfInt64 ValuesStride = 1 ) { return( SetValues( Index, Values, NumberOfValues, ArrayStride, ValuesStride)); }; #ifndef SWIG XdmfArray & operator=( XdmfArray &Array ); XdmfArray & operator=( XdmfFloat64 Value ); XdmfArray & operator+( XdmfArray &Array ); XdmfArray & operator+( XdmfFloat64 Value ); XdmfArray & operator-( XdmfArray &Array ); XdmfArray & operator-( XdmfFloat64 Value ); XdmfArray & operator*( XdmfArray &Array ); XdmfArray & operator*( XdmfFloat64 Value ); XdmfArray & operator/( XdmfArray &Array ); XdmfArray & operator/( XdmfFloat64 Value ); XdmfArray & operator+=( XdmfArray &Array ){ *this = *this + Array; return( *this ); }; XdmfArray & operator+=( XdmfFloat64 Value ){ *this = *this + Value; return( *this ); }; XdmfArray & operator-=( XdmfArray &Array ){ *this = *this - Array; return( *this ); }; XdmfArray & operator-=( XdmfFloat64 Value ){ *this = *this - Value; return( *this ); }; XdmfArray & operator*=( XdmfArray &Array ){ *this = *this * Array; return( *this ); }; XdmfArray & operator*=( XdmfFloat64 Value ){ *this = *this * Value; return( *this ); }; XdmfArray & operator/=( XdmfArray &Array ){ *this = *this / Array; return( *this ); }; XdmfArray & operator/=( XdmfFloat64 Value ){ *this = *this / Value; return( *this ); }; XdmfInt32 CopyCompound( XdmfPointer ArrayPointer, XdmfInt32 ArrayType, XdmfInt64 ArrayStride, XdmfPointer ValuePointer, XdmfInt32 ValueType, XdmfInt64 ValueStride, XdmfInt32 Direction, XdmfInt64 NumberOfValues ); #endif /*! Methods to Get Values of Elements */ XdmfFloat64 GetValueAsFloat64( XdmfInt64 Index ); XdmfFloat32 GetValueAsFloat32( XdmfInt64 Index ); XdmfInt64 GetValueAsInt64( XdmfInt64 Index ); XdmfInt32 GetValueAsInt32( XdmfInt64 Index ); XdmfInt16 GetValueAsInt16( XdmfInt64 Index ); XdmfInt8 GetValueAsInt8( XdmfInt64 Index ); XdmfString GetValues( XdmfInt64 Index = 0, XdmfInt64 NumberOfValues = 0, XdmfInt64 ArrayStride = 1); XdmfInt32 Generate( XdmfFloat64 StartValue, XdmfFloat64 EndValue, XdmfInt64 StartIndex = 0, XdmfInt64 EndIndex = 0 ); //! Make Exact Copy of Existing Array #ifndef SWIG XdmfArray *Clone( XdmfArray *Indexes ); #endif //! Make Exact Copy of Existing Array XdmfArray *Clone( XdmfLength Start = 0, XdmfLength End = 0); //! Get Reference to Section of Array XdmfArray *Reference( XdmfLength Start = 0 , XdmfLength End = 0); //! Get Max as a Float XdmfFloat64 GetMaxAsFloat64( void ); //! Get Min as a Float XdmfFloat64 GetMinAsFloat64( void ); //! Get Max as a Int XdmfInt64 GetMaxAsInt64( void ); //! Get Min as a Int XdmfInt64 GetMinAsInt64( void ); //! Get Mean XdmfFloat64 GetMean( void ); //! Blindly copy in chars void SetDataFromChars( XdmfString String ) { this->SetNumberOfElements( strlen( String ) + 1 ); strcpy((XdmfString)this->GetDataPointer(), String ); }; //! Return as if its a XdmfString XdmfString GetDataPointerAsCharPointer( void ) { return( (XdmfString)this->GetDataPointer() ); }; //! Copy Data From One Array to Another // XdmfPointer MemCopy( XdmfLength StartOffset, // XdmfLength NumberOfElemnts, // XdmfPointer DataPointer, // XdmfLength Stride = 1 ); //! Copy Data From a Scripting Variable // XdmfInt32 CopyFromScriptVariable( XdmfScriptVariablePointer Pointer, // XdmfLength StartOffset, // XdmfLength NumberOfElements ) { // // XdmfDebug("Copy " << NumberOfElements << // " to " << this->GetVoidPointer( StartOffset ) << // " from " << Pointer ); // memcpy( this->GetVoidPointer( StartOffset ), // Pointer, // this->Precision * NumberOfElements ); // return ( XDMF_SUCCESS ); // }; //! Copy Data To a Scripting Variable // XdmfInt32 CopyToScriptVariable( XdmfScriptVariablePointer Pointer, // XdmfLength StartOffset, // XdmfLength NumberOfElements ) { // // XdmfDebug("Copy " << NumberOfElements << // " from " << this->GetVoidPointer( StartOffset ) << // " to " << Pointer ); // memcpy( Pointer, this->GetVoidPointer( StartOffset ), // this->Precision * NumberOfElements ); // return ( XDMF_SUCCESS ); // }; protected: XdmfPointer DataPointer; XdmfBoolean AllowAllocate; XdmfBoolean DataIsMine; char TagName[XDMF_ARRAY_TAG_LENGTH]; void AddArrayToList( void ); }; #ifndef DOXYGEN_SKIP typedef struct { char *name; XdmfLength timecntr; XdmfArray *Array; } XdmfArrayList; XDMF_EXPORT XdmfArray *TagNameToArray( XdmfString TagName ); XDMF_EXPORT void PrintAllXdmfArrays( void ); XDMF_EXPORT XdmfArray *GetNextOlderArray( XdmfLength Age, XdmfLength *AgeOfArray = NULL ); XDMF_EXPORT XdmfLength GetCurrentArrayTime( void ); #endif /* DOXYGEN_SKIP */ #endif // __XdmfArray_h xdmf-3.0+git20160803/libsrc/XdmfExpression.cxx0000640000175000017500000000455113003006557021057 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : $Id: XdmfExpression.cxx,v 1.2 2009-01-23 20:31:39 clarke Exp $ */ /* Date : $Date: 2009-01-23 20:31:39 $ */ /* Version : $Revision $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2002 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #include #include "XdmfExpression.h" extern XdmfArray *XdmfExprParse( XdmfString string ); XdmfArray * XdmfExpr( XdmfString Statement ) { // cerr << "In XdmfExpr : " << Statement << '\n'; return ( XdmfExprParse( Statement )); } void XdmfArrayExpr( XdmfArray *Array, XdmfString Operation, XdmfArray *Values ){ if( strcmp( Operation, "=" ) == 0 ){ *Array = *Values; } else if( strcmp( Operation, "*=" ) == 0 ){ *Array *= *Values; } else if( strcmp( Operation, "+=" ) == 0 ){ *Array += *Values; } } void XdmfScalarExpr( XdmfArray *Array, XdmfString Operation, XdmfFloat64 Value){ if( strcmp( Operation, "=" ) == 0 ){ *Array = Value; } else if( strcmp( Operation, "*=" ) == 0 ){ *Array *= Value; } else if( strcmp( Operation, "+=" ) == 0 ){ *Array += Value; } } xdmf-3.0+git20160803/libsrc/XdmfExprYacc.cxx0000640000175000017500000024450513003006557020443 0ustar alastairalastair/* A Bison parser, made by GNU Bison 1.875a. */ /* Skeleton parser for Yacc-like parsing with Bison, Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* As a special exception, when this file is copied by Bison into a Bison output file, you may use that output file without restriction. This special exception was added by the Free Software Foundation in version 1.24 of Bison. */ /* Written by Richard Stallman by simplifying the original so called ``semantic'' parser. */ /* All symbols defined below should begin with yy or YY, to avoid infringing on user name space. This should be done even for local variables, as they might otherwise be expanded by user macros. There are some unavoidable exceptions within include files to define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ /* Identify Bison output. */ #define YYBISON 1 /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" /* Pure parsers. */ #define YYPURE 0 /* Using locations. */ #define YYLSP_NEEDED 0 /* If NAME_PREFIX is specified substitute the variables and functions names. */ #define yyparse dice_yyparse #define yylex dice_yylex #define yyerror dice_yyerror #define yylval dice_yylval #define yychar dice_yychar #define yydebug dice_yydebug #define yynerrs dice_yynerrs /* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE /* Put the tokens into the symbol table, so that GDB and other debuggers know about them. */ enum yytokentype { lFLOAT = 258, tokINTEGER = 259, tokARRAY = 260, NAME = 261, SIN = 262, COS = 263, TAN = 264, ACOS = 265, ASIN = 266, ATAN = 267, LOG = 268, EXP = 269, ABS_TOKEN = 270, SQRT = 271, WHERE = 272, INDEX = 273, EQEQ = 274, LT = 275, LE = 276, GT = 277, GE = 278, NE = 279, LTLT = 280, GTGT = 281, JOIN = 282 }; #endif #define lFLOAT 258 #define tokINTEGER 259 #define tokARRAY 260 #define NAME 261 #define SIN 262 #define COS 263 #define TAN 264 #define ACOS 265 #define ASIN 266 #define ATAN 267 #define LOG 268 #define EXP 269 #define ABS_TOKEN 270 #define SQRT 271 #define WHERE 272 #define INDEX 273 #define EQEQ 274 #define LT 275 #define LE 276 #define GT 277 #define GE 278 #define NE 279 #define LTLT 280 #define GTGT 281 #define JOIN 282 /* Copy the first part of user declarations. */ #line 1 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" /* Force the definition for Linux */ /* Possible bug in older Linux yacc */ #ifndef NOBISON extern int yylex(); extern "C" { void yyerror( const char *); int yyparse( void ); } #endif #include #include #include #include static XdmfArray *XdmfExprReturnValue; XdmfExprSymbol *XdmfExprItemsTable = NULL; class XdmfInt64Array : public XdmfArray { public : XdmfInt64Array( XdmfInt64 Length ) { this->SetNumberType( XDMF_INT64_TYPE ); this->SetNumberOfElements( Length ); } XdmfInt64Array() { this->SetNumberType( XDMF_INT64_TYPE ); this->SetNumberOfElements( 10 ); }; }; #define ADD_XDMF_tokARRAY_TO_SYMBOL( a ) \ { \ char name[80]; \ XdmfExprSymbol *sp; \ sprintf( name, "XdmfArray_%X", ( XdmfLength)(a) ); \ sp = XdmfExprSymbolLookup( name ); \ sp->ClientData = (a); \ } /* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 0 #endif /* Enabling verbose error messages. */ #ifdef YYERROR_VERBOSE # undef YYERROR_VERBOSE # define YYERROR_VERBOSE 1 #else # define YYERROR_VERBOSE 0 #endif #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) #line 44 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" typedef union YYSTYPE { double DoubleValue; long IntegerValue; void *ArrayPointer; XdmfExprSymbol *Symbol; } YYSTYPE; /* Line 191 of yacc.c. */ # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_TRIVIAL 1 #endif /* Copy the second part of user declarations. */ /* Line 214 of yacc.c. */ #line 201 "/home/andy/vtk/Xdmf-bin/libsrc/XdmfExprYacc.tab.c" #if ! defined (yyoverflow) || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ # if YYSTACK_USE_ALLOCA # define YYSTACK_ALLOC alloca # else # ifndef YYSTACK_USE_ALLOCA # if defined (alloca) || defined (_ALLOCA_H) # define YYSTACK_ALLOC alloca # else # ifdef __GNUC__ # define YYSTACK_ALLOC __builtin_alloca # endif # endif # endif # endif # ifdef YYSTACK_ALLOC /* Pacify GCC's `empty if-body' warning. */ # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) # else # if defined (__STDC__) || defined (__cplusplus) # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # endif # define YYSTACK_ALLOC malloc # define YYSTACK_FREE free # endif #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ #if (! defined (yyoverflow) \ && (! defined (__cplusplus) \ || (YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc { short yyss; YYSTYPE yyvs; }; /* The size of the maximum gap between one aligned stack and the next. */ # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) /* The size of an array large to enough to hold all stacks, each with N elements. */ # define YYSTACK_BYTES(N) \ ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM) /* Copy COUNT objects from FROM to TO. The source and destination do not overlap. */ # ifndef YYCOPY # if 1 < __GNUC__ # define YYCOPY(To, From, Count) \ __builtin_memcpy (To, From, (Count) * sizeof (*(From))) # else # define YYCOPY(To, From, Count) \ do \ { \ register YYSIZE_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) \ (To)[yyi] = (From)[yyi]; \ } \ while (0) # endif # endif /* Relocate STACK from its old location to the new one. The local variables YYSIZE and YYSTACKSIZE give the old and new number of elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ # define YYSTACK_RELOCATE(Stack) \ do \ { \ YYSIZE_T yynewbytes; \ YYCOPY (&yyptr->Stack, Stack, yysize); \ Stack = &yyptr->Stack; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ while (0) #endif #if defined (__STDC__) || defined (__cplusplus) typedef signed char yysigned_char; #else typedef short yysigned_char; #endif /* YYFINAL -- State number of the termination state. */ #define YYFINAL 22 /* YYLAST -- Last index in YYTABLE. */ #define YYLAST 278 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 40 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 5 /* YYNRULES -- Number of rules. */ #define YYNRULES 46 /* YYNRULES -- Number of states. */ #define YYNSTATES 119 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 #define YYMAXUTOK 282 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ static const unsigned char yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 38, 39, 30, 29, 32, 28, 2, 31, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 37, 33, 2, 34, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 35, 2, 36, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27 }; #if YYDEBUG /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in YYRHS. */ static const unsigned char yyprhs[] = { 0, 0, 3, 5, 9, 13, 20, 27, 36, 45, 47, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97, 101, 105, 110, 117, 124, 131, 138, 145, 152, 159, 166, 173, 178, 182, 187, 189, 193, 197, 201, 205, 210, 214, 216 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yysigned_char yyrhs[] = { 41, 0, -1, 42, -1, 5, 34, 43, -1, 5, 34, 44, -1, 5, 35, 43, 36, 34, 44, -1, 5, 35, 43, 36, 34, 43, -1, 5, 35, 4, 37, 4, 36, 34, 44, -1, 5, 35, 4, 37, 4, 36, 34, 43, -1, 43, -1, 44, -1, 43, 29, 43, -1, 43, 32, 43, -1, 43, 33, 43, -1, 43, 28, 43, -1, 43, 30, 43, -1, 43, 31, 43, -1, 43, 29, 44, -1, 43, 28, 44, -1, 43, 30, 44, -1, 43, 31, 44, -1, 44, 29, 43, -1, 44, 28, 43, -1, 44, 30, 43, -1, 44, 31, 43, -1, 5, 35, 43, 36, -1, 5, 35, 4, 37, 4, 36, -1, 18, 38, 43, 19, 43, 39, -1, 17, 38, 43, 19, 43, 39, -1, 17, 38, 43, 19, 44, 39, -1, 17, 38, 43, 20, 44, 39, -1, 17, 38, 43, 21, 44, 39, -1, 17, 38, 43, 22, 44, 39, -1, 17, 38, 43, 23, 44, 39, -1, 17, 38, 43, 24, 44, 39, -1, 6, 38, 43, 39, -1, 38, 43, 39, -1, 27, 38, 43, 39, -1, 5, -1, 44, 29, 44, -1, 44, 28, 44, -1, 44, 30, 44, -1, 44, 31, 44, -1, 6, 38, 44, 39, -1, 38, 44, 39, -1, 4, -1, 3, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const unsigned short yyrline[] = { 0, 68, 68, 76, 84, 89, 101, 117, 128, 141, 148, 153, 162, 239, 303, 312, 322, 331, 340, 349, 358, 367, 376, 385, 394, 403, 413, 424, 469, 502, 523, 544, 565, 586, 607, 628, 646, 650, 654, 671, 675, 679, 683, 687, 695, 699, 703 }; #endif #if YYDEBUG || YYERROR_VERBOSE /* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { "$end", "error", "$undefined", "lFLOAT", "tokINTEGER", "tokARRAY", "NAME", "SIN", "COS", "TAN", "ACOS", "ASIN", "ATAN", "LOG", "EXP", "ABS_TOKEN", "SQRT", "WHERE", "INDEX", "EQEQ", "LT", "LE", "GT", "GE", "NE", "LTLT", "GTGT", "JOIN", "'-'", "'+'", "'*'", "'/'", "','", "';'", "'='", "'['", "']'", "':'", "'('", "')'", "$accept", "statemant_list", "statement", "ArrayExpression", "ScalarExpression", 0 }; #endif # ifdef YYPRINT /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to token YYLEX-NUM. */ static const unsigned short yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 45, 43, 42, 47, 44, 59, 61, 91, 93, 58, 40, 41 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const unsigned char yyr1[] = { 0, 40, 41, 42, 42, 42, 42, 42, 42, 42, 42, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 44, 44, 44, 44, 44, 44, 44, 44 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ static const unsigned char yyr2[] = { 0, 2, 1, 3, 3, 6, 6, 8, 8, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 6, 6, 6, 6, 6, 6, 6, 6, 6, 4, 3, 4, 1, 3, 3, 3, 3, 4, 3, 1, 1 }; /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state STATE-NUM when YYTABLE doesn't specify something else to do. Zero means the default is an error. */ static const unsigned char yydefact[] = { 0, 46, 45, 38, 0, 0, 0, 0, 0, 0, 2, 9, 10, 0, 0, 0, 0, 0, 0, 38, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 4, 45, 0, 0, 0, 0, 0, 0, 0, 0, 36, 44, 14, 18, 11, 17, 15, 19, 16, 20, 12, 13, 22, 40, 21, 39, 23, 41, 24, 42, 0, 25, 35, 43, 0, 0, 0, 0, 0, 0, 0, 37, 45, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, 26, 6, 5, 28, 29, 0, 0, 0, 0, 0, 0, 30, 31, 32, 33, 34, 27, 0, 0, 0, 40, 39, 41, 42, 26, 8, 7 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yysigned_char yydefgoto[] = { -1, 9, 10, 11, 37 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ #define YYPACT_NINF -36 static const short yypact[] = { 1, -36, -36, -33, -35, -27, -24, -16, 88, 27, -36, 245, 26, 88, 113, 88, 88, 88, 88, 5, 143, 7, -36, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 245, 26, 4, 227, 26, 155, 108, 137, 56, 167, 117, -36, -36, 220, -14, 220, -14, -12, -36, -12, -36, -36, -36, 220, -14, 220, -14, -12, -36, -12, -36, 38, 11, -36, -36, 88, 6, 6, 6, 6, 6, 88, -36, 10, 236, 40, 88, 179, 150, 36, 6, 162, 174, 186, 198, 203, 191, 73, -36, 46, 245, 26, -36, -36, 6, 210, 6, 6, 6, 6, -36, -36, -36, -36, -36, -36, 45, 88, 215, 3, 3, -36, -36, -36, 245, 26 }; /* YYPGOTO[NTERM-NUM]. */ static const yysigned_char yypgoto[] = { -36, -36, -36, 35, 0 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which number is the opposite. If zero, do what YYDEFACT says. If YYTABLE_NINF, syntax error. */ #define YYTABLE_NINF -1 static const unsigned char yytable[] = { 12, 13, 14, 15, 1, 2, 3, 4, 21, 1, 2, 16, 82, 34, 17, 39, 31, 32, 5, 6, 27, 28, 18, 47, 49, 51, 53, 22, 7, 57, 59, 61, 63, 101, 102, 29, 30, 31, 32, 8, 43, 64, 78, 20, 83, 79, 45, 90, 33, 36, 38, 40, 41, 42, 29, 30, 31, 32, 46, 48, 50, 52, 54, 55, 56, 58, 60, 62, 81, 84, 85, 86, 87, 88, 97, 74, 92, 109, 77, 94, 110, 116, 0, 98, 23, 24, 25, 26, 27, 28, 0, 1, 2, 19, 4, 0, 0, 111, 0, 112, 113, 114, 115, 80, 0, 5, 6, 0, 0, 89, 118, 0, 0, 0, 93, 7, 1, 35, 19, 4, 1, 76, 19, 4, 0, 0, 8, 0, 0, 0, 5, 6, 0, 0, 5, 6, 29, 30, 31, 32, 7, 0, 0, 0, 7, 117, 0, 67, 0, 0, 0, 8, 0, 0, 0, 8, 68, 69, 70, 71, 72, 73, 0, 0, 0, 23, 24, 25, 26, 27, 28, 23, 24, 25, 26, 27, 28, 0, 29, 30, 31, 32, 44, 23, 24, 25, 26, 27, 28, 96, 99, 100, 101, 102, 66, 23, 24, 25, 26, 27, 28, 103, 99, 100, 101, 102, 75, 23, 24, 25, 26, 27, 28, 104, 99, 100, 101, 102, 95, 23, 24, 25, 26, 27, 28, 105, 99, 100, 101, 102, 108, 99, 100, 101, 102, 0, 0, 106, 99, 100, 101, 102, 107, 99, 100, 101, 102, 0, 0, 45, 25, 26, 27, 28, 67, 23, 24, 25, 26, 27, 28, 0, 0, 65, 23, 24, 25, 26, 27, 28, 0, 0, 91, 23, 24, 25, 26, 27, 28 }; static const yysigned_char yycheck[] = { 0, 34, 35, 38, 3, 4, 5, 6, 8, 3, 4, 38, 6, 13, 38, 15, 30, 31, 17, 18, 32, 33, 38, 23, 24, 25, 26, 0, 27, 29, 30, 31, 32, 30, 31, 28, 29, 30, 31, 38, 35, 37, 4, 8, 38, 34, 39, 37, 13, 14, 15, 16, 17, 18, 28, 29, 30, 31, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 68, 69, 70, 71, 72, 73, 38, 19, 36, 4, 43, 79, 34, 36, -1, 83, 28, 29, 30, 31, 32, 33, -1, 3, 4, 5, 6, -1, -1, 97, -1, 99, 100, 101, 102, 68, -1, 17, 18, -1, -1, 74, 110, -1, -1, -1, 79, 27, 3, 4, 5, 6, 3, 4, 5, 6, -1, -1, 38, -1, -1, -1, 17, 18, -1, -1, 17, 18, 28, 29, 30, 31, 27, -1, -1, -1, 27, 110, -1, 39, -1, -1, -1, 38, -1, -1, -1, 38, 19, 20, 21, 22, 23, 24, -1, -1, -1, 28, 29, 30, 31, 32, 33, 28, 29, 30, 31, 32, 33, -1, 28, 29, 30, 31, 39, 28, 29, 30, 31, 32, 33, 39, 28, 29, 30, 31, 39, 28, 29, 30, 31, 32, 33, 39, 28, 29, 30, 31, 39, 28, 29, 30, 31, 32, 33, 39, 28, 29, 30, 31, 39, 28, 29, 30, 31, 32, 33, 39, 28, 29, 30, 31, 39, 28, 29, 30, 31, -1, -1, 39, 28, 29, 30, 31, 39, 28, 29, 30, 31, -1, -1, 39, 30, 31, 32, 33, 39, 28, 29, 30, 31, 32, 33, -1, -1, 36, 28, 29, 30, 31, 32, 33, -1, -1, 36, 28, 29, 30, 31, 32, 33 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const unsigned char yystos[] = { 0, 3, 4, 5, 6, 17, 18, 27, 38, 41, 42, 43, 44, 34, 35, 38, 38, 38, 38, 5, 43, 44, 0, 28, 29, 30, 31, 32, 33, 28, 29, 30, 31, 43, 44, 4, 43, 44, 43, 44, 43, 43, 43, 35, 39, 39, 43, 44, 43, 44, 43, 44, 43, 44, 43, 43, 43, 44, 43, 44, 43, 44, 43, 44, 37, 36, 39, 39, 19, 20, 21, 22, 23, 24, 19, 39, 4, 43, 4, 34, 43, 44, 6, 38, 44, 44, 44, 44, 44, 43, 37, 36, 36, 43, 44, 39, 39, 38, 44, 28, 29, 30, 31, 39, 39, 39, 39, 39, 39, 4, 34, 44, 44, 44, 44, 44, 36, 43, 44 }; #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) # define YYSIZE_T __SIZE_TYPE__ #endif #if ! defined (YYSIZE_T) && defined (size_t) # define YYSIZE_T size_t #endif #if ! defined (YYSIZE_T) # if defined (__STDC__) || defined (__cplusplus) # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # endif #endif #if ! defined (YYSIZE_T) # define YYSIZE_T unsigned int #endif #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) #define YYEMPTY (-2) #define YYEOF 0 #define YYACCEPT goto yyacceptlab #define YYABORT goto yyabortlab #define YYERROR goto yyerrlab1 /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. Once GCC version 2 has supplanted version 1, this can go. */ #define YYFAIL goto yyerrlab #define YYRECOVERING() (!!yyerrstatus) #define YYBACKUP(Token, Value) \ do \ if (yychar == YYEMPTY && yylen == 1) \ { \ yychar = (Token); \ yylval = (Value); \ yytoken = YYTRANSLATE (yychar); \ YYPOPSTACK; \ goto yybackup; \ } \ else \ { \ yyerror ("syntax error: cannot back up");\ YYERROR; \ } \ while (0) #define YYTERROR 1 #define YYERRCODE 256 /* YYLLOC_DEFAULT -- Compute the default location (before the actions are run). */ #ifndef YYLLOC_DEFAULT # define YYLLOC_DEFAULT(Current, Rhs, N) \ Current.first_line = Rhs[1].first_line; \ Current.first_column = Rhs[1].first_column; \ Current.last_line = Rhs[N].last_line; \ Current.last_column = Rhs[N].last_column; #endif /* YYLEX -- calling `yylex' with the right arguments. */ #ifdef YYLEX_PARAM # define YYLEX yylex (YYLEX_PARAM) #else # define YYLEX yylex () #endif /* Enable debugging if requested. */ #if YYDEBUG # ifndef YYFPRINTF # include /* INFRINGES ON USER NAME SPACE */ # define YYFPRINTF fprintf # endif # define YYDPRINTF(Args) \ do { \ if (yydebug) \ YYFPRINTF Args; \ } while (0) # define YYDSYMPRINT(Args) \ do { \ if (yydebug) \ yysymprint Args; \ } while (0) # define YYDSYMPRINTF(Title, Token, Value, Location) \ do { \ if (yydebug) \ { \ YYFPRINTF (stderr, "%s ", Title); \ yysymprint (stderr, \ Token, Value); \ YYFPRINTF (stderr, "\n"); \ } \ } while (0) /*------------------------------------------------------------------. | yy_stack_print -- Print the state stack from its BOTTOM up to its | | TOP (cinluded). | `------------------------------------------------------------------*/ #if defined (__STDC__) || defined (__cplusplus) static void yy_stack_print (short *bottom, short *top) #else static void yy_stack_print (bottom, top) short *bottom; short *top; #endif { YYFPRINTF (stderr, "Stack now"); for (/* Nothing. */; bottom <= top; ++bottom) YYFPRINTF (stderr, " %d", *bottom); YYFPRINTF (stderr, "\n"); } # define YY_STACK_PRINT(Bottom, Top) \ do { \ if (yydebug) \ yy_stack_print ((Bottom), (Top)); \ } while (0) /*------------------------------------------------. | Report that the YYRULE is going to be reduced. | `------------------------------------------------*/ #if defined (__STDC__) || defined (__cplusplus) static void yy_reduce_print (int yyrule) #else static void yy_reduce_print (yyrule) int yyrule; #endif { int yyi; unsigned int yylineno = yyrline[yyrule]; YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", yyrule - 1, yylineno); /* Print the symbols being reduced, and their result. */ for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); } # define YY_REDUCE_PRINT(Rule) \ do { \ if (yydebug) \ yy_reduce_print (Rule); \ } while (0) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ int yydebug; #else /* !YYDEBUG */ # define YYDPRINTF(Args) # define YYDSYMPRINT(Args) # define YYDSYMPRINTF(Title, Token, Value, Location) # define YY_STACK_PRINT(Bottom, Top) # define YY_REDUCE_PRINT(Rule) #endif /* !YYDEBUG */ /* YYINITDEPTH -- initial size of the parser's stacks. */ #ifndef YYINITDEPTH # define YYINITDEPTH 200 #endif /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only if the built-in stack extension method is used). Do not make this value too large; the results are undefined if SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) evaluated with infinite-precision integer arithmetic. */ #if YYMAXDEPTH == 0 # undef YYMAXDEPTH #endif #ifndef YYMAXDEPTH # define YYMAXDEPTH 10000 #endif #if YYERROR_VERBOSE # ifndef yystrlen # if defined (__GLIBC__) && defined (_STRING_H) # define yystrlen strlen # else /* Return the length of YYSTR. */ static YYSIZE_T # if defined (__STDC__) || defined (__cplusplus) yystrlen (const char *yystr) # else yystrlen (yystr) const char *yystr; # endif { register const char *yys = yystr; while (*yys++ != '\0') continue; return yys - yystr - 1; } # endif # endif # ifndef yystpcpy # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) # define yystpcpy stpcpy # else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ static char * # if defined (__STDC__) || defined (__cplusplus) yystpcpy (char *yydest, const char *yysrc) # else yystpcpy (yydest, yysrc) char *yydest; const char *yysrc; # endif { register char *yyd = yydest; register const char *yys = yysrc; while ((*yyd++ = *yys++) != '\0') continue; return yyd - 1; } # endif # endif #endif /* !YYERROR_VERBOSE */ #if YYDEBUG /*--------------------------------. | Print this symbol on YYOUTPUT. | `--------------------------------*/ #if defined (__STDC__) || defined (__cplusplus) static void yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) #else static void yysymprint (yyoutput, yytype, yyvaluep) FILE *yyoutput; int yytype; YYSTYPE *yyvaluep; #endif { /* Pacify ``unused variable'' warnings. */ (void) yyvaluep; if (yytype < YYNTOKENS) { YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); # ifdef YYPRINT YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); # endif } else YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); YYFPRINTF (yyoutput, ")"); } #endif /* ! YYDEBUG */ /*-----------------------------------------------. | Release the memory associated to this symbol. | `-----------------------------------------------*/ #if defined (__STDC__) || defined (__cplusplus) static void yydestruct (int yytype, YYSTYPE *yyvaluep) #else static void yydestruct (yytype, yyvaluep) int yytype; YYSTYPE *yyvaluep; #endif { /* Pacify ``unused variable'' warnings. */ (void) yyvaluep; (void) yytype; } /* Prevent warnings from -Wmissing-prototypes. */ #ifdef YYPARSE_PARAM # if defined (__STDC__) || defined (__cplusplus) int yyparse (void *YYPARSE_PARAM); # else int yyparse (); # endif #else /* ! YYPARSE_PARAM */ #if defined (__STDC__) || defined (__cplusplus) int yyparse (void); #else int yyparse (); #endif #endif /* ! YYPARSE_PARAM */ /* The lookahead symbol. */ int yychar; /* The semantic value of the lookahead symbol. */ YYSTYPE yylval; /* Number of syntax errors so far. */ int yynerrs; /*----------. | yyparse. | `----------*/ #ifdef YYPARSE_PARAM # if defined (__STDC__) || defined (__cplusplus) int yyparse (void *YYPARSE_PARAM) # else int yyparse (YYPARSE_PARAM) void *YYPARSE_PARAM; # endif #else /* ! YYPARSE_PARAM */ #if defined (__STDC__) || defined (__cplusplus) int yyparse (void) #else int yyparse () #endif #endif { register int yystate; register int yyn; int yyresult; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; /* Lookahead token as an internal (translated) token number. */ int yytoken = 0; /* Three stacks and their tools: `yyss': related to states, `yyvs': related to semantic values, `yyls': related to locations. Refer to the stacks thru separate pointers, to allow yyoverflow to reallocate them elsewhere. */ /* The state stack. */ short yyssa[YYINITDEPTH]; short *yyss = yyssa; register short *yyssp; /* The semantic value stack. */ YYSTYPE yyvsa[YYINITDEPTH]; YYSTYPE *yyvs = yyvsa; register YYSTYPE *yyvsp; #define YYPOPSTACK (yyvsp--, yyssp--) YYSIZE_T yystacksize = YYINITDEPTH; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; /* When reducing, the number of symbols on the RHS of the reduced rule. */ int yylen; YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ yyssp = yyss; yyvsp = yyvs; goto yysetstate; /*------------------------------------------------------------. | yynewstate -- Push a new state, which is found in yystate. | `------------------------------------------------------------*/ yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. so pushing a state here evens the stacks. */ yyssp++; yysetstate: *yyssp = yystate; if (yyss + yystacksize - 1 <= yyssp) { /* Get the current used size of the three stacks, in elements. */ YYSIZE_T yysize = yyssp - yyss + 1; #ifdef yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into memory. */ YYSTYPE *yyvs1 = yyvs; short *yyss1 = yyss; /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow ("parser stack overflow", &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), &yystacksize); yyss = yyss1; yyvs = yyvs1; } #else /* no yyoverflow */ # ifndef YYSTACK_RELOCATE goto yyoverflowlab; # else /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) goto yyoverflowlab; yystacksize *= 2; if (YYMAXDEPTH < yystacksize) yystacksize = YYMAXDEPTH; { short *yyss1 = yyss; union yyalloc *yyptr = (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyoverflowlab; YYSTACK_RELOCATE (yyss); YYSTACK_RELOCATE (yyvs); # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } # endif #endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) YYABORT; } YYDPRINTF ((stderr, "Entering state %d\n", yystate)); goto yybackup; /*-----------. | yybackup. | `-----------*/ yybackup: /* Do appropriate processing given the current state. */ /* Read a lookahead token if we need one and don't already have one. */ /* yyresume: */ /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yyn == YYPACT_NINF) goto yydefault; /* Not known => get a lookahead token if don't already have one. */ /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); yychar = YYLEX; } if (yychar <= YYEOF) { yychar = yytoken = YYEOF; YYDPRINTF ((stderr, "Now at end of input.\n")); } else { yytoken = YYTRANSLATE (yychar); YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc); } /* If the proper action on seeing token YYTOKEN is to reduce or to detect an error, take that action. */ yyn += yytoken; if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) goto yydefault; yyn = yytable[yyn]; if (yyn <= 0) { if (yyn == 0 || yyn == YYTABLE_NINF) goto yyerrlab; yyn = -yyn; goto yyreduce; } if (yyn == YYFINAL) YYACCEPT; /* Shift the lookahead token. */ YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken])); /* Discard the token being shifted unless it is eof. */ if (yychar != YYEOF) yychar = YYEMPTY; *++yyvsp = yylval; /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; yystate = yyn; goto yynewstate; /*-----------------------------------------------------------. | yydefault -- do the default action for the current state. | `-----------------------------------------------------------*/ yydefault: yyn = yydefact[yystate]; if (yyn == 0) goto yyerrlab; goto yyreduce; /*-----------------------------. | yyreduce -- Do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ yylen = yyr2[yyn]; /* If YYLEN is nonzero, implement the default value of the action: `$$ = $1'. Otherwise, the following line sets YYVAL to garbage. This behavior is undocumented and Bison users should not rely upon it. Assigning to YYVAL unconditionally makes the parser a bit smaller, and it avoids a GCC warning that YYVAL may be used uninitialized. */ yyval = yyvsp[1-yylen]; YY_REDUCE_PRINT (yyn); switch (yyn) { case 2: #line 68 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { /* printf("Complete\n"); printf("XdmfExprReturnValue Nelms = %d\n", XdmfExprReturnValue->GetNumberOfElements()); */ } break; case 3: #line 76 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { XdmfArray *TempArray = ( XdmfArray *)yyvsp[0].ArrayPointer; /* printf("Setting %s from ArrayExpression\n", $1); */ XdmfExprReturnValue = (XdmfArray *)yyvsp[-2].ArrayPointer; *XdmfExprReturnValue = *TempArray; delete TempArray; } break; case 4: #line 84 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { /* printf("Setting %s from ScalarExpression\n", $1); */ XdmfExprReturnValue = (XdmfArray *)yyvsp[-2].ArrayPointer; *XdmfExprReturnValue = yyvsp[0].DoubleValue; } break; case 5: #line 89 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { XdmfArray *Array1 = ( XdmfArray *)yyvsp[-3].ArrayPointer; XdmfArray *Result = ( XdmfArray *)yyvsp[-5].ArrayPointer; XdmfLength i, index, Length = Array1->GetNumberOfElements(); for( i = 0 ; i < Length ; i++ ){ index = (XdmfLength)Array1->GetValueAsFloat64( i ); Result->SetValueFromFloat64( index, yyvsp[0].DoubleValue ); } delete Array1; XdmfExprReturnValue = Result; } break; case 6: #line 101 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { XdmfArray *Array1 = ( XdmfArray *)yyvsp[-3].ArrayPointer; XdmfArray *Array2 = ( XdmfArray *)yyvsp[0].ArrayPointer; XdmfArray *Result = ( XdmfArray *)yyvsp[-5].ArrayPointer; XdmfFloat64 Value; XdmfLength i, index, Length = Array1->GetNumberOfElements(); for( i = 0 ; i < Length ; i++ ){ index = (XdmfLength)Array1->GetValueAsFloat64( i ); Value = Array2->GetValueAsFloat64( i ); Result->SetValueFromFloat64( index, Value ); } delete Array1; delete Array2; XdmfExprReturnValue = Result; } break; case 7: #line 117 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { XdmfArray *Range; /* printf("Array Range %d:%d = ScalarExpression \n", $3, $5); */ Range = (XdmfArray *)yyvsp[-7].ArrayPointer; XdmfExprReturnValue = Range->Reference( yyvsp[-5].IntegerValue, yyvsp[-3].IntegerValue ); /* This is a Reference */ *XdmfExprReturnValue = yyvsp[0].DoubleValue; /* Now Point to the Entire Array */ XdmfExprReturnValue = (XdmfArray *)yyvsp[-7].ArrayPointer; } break; case 8: #line 128 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { XdmfArray *TempArray = ( XdmfArray *)yyvsp[0].ArrayPointer; XdmfArray *Range; /* printf("Array Range %d:%d = ArrayExpression \n", $3, $5); */ Range = (XdmfArray *)yyvsp[-7].ArrayPointer; XdmfExprReturnValue = Range->Reference( yyvsp[-5].IntegerValue, yyvsp[-3].IntegerValue ); /* This is a Reference */ *XdmfExprReturnValue = *TempArray; /* Now Point to the Entire Array */ XdmfExprReturnValue = (XdmfArray *)yyvsp[-7].ArrayPointer; delete TempArray; } break; case 9: #line 141 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { XdmfArray *TempArray = ( XdmfArray *)yyvsp[0].ArrayPointer; /* printf("Clone from ArrayExpression\n"); */ XdmfExprReturnValue = TempArray; /* printf("XdmfExprReturnValue Nelms = %d\n", XdmfExprReturnValue->GetNumberOfElements()); */ } break; case 10: #line 148 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { printf("Pointless !! Scalar = %g\n", yyvsp[0].DoubleValue); } break; case 11: #line 153 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { XdmfArray *Array1 = ( XdmfArray *)yyvsp[-2].ArrayPointer; XdmfArray *Array2 = ( XdmfArray *)yyvsp[0].ArrayPointer; /* printf("Array 0x%X + 0x%X\n", Array1, Array2); */ *Array1 += *Array2; yyval.ArrayPointer = Array1; delete Array2; } break; case 12: #line 162 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { /* Interlace */ XdmfArray *Array1 = ( XdmfArray *)yyvsp[-2].ArrayPointer; XdmfArray *Array2 = ( XdmfArray *)yyvsp[0].ArrayPointer; XdmfArray *NewArray = new XdmfArray(); XdmfInt32 i, Rank1, Rank2; XdmfInt64 NewLength, Length1, Length2, IFactor, Lcd; XdmfInt64 Dimension1[ XDMF_MAX_DIMENSION ]; XdmfInt64 Dimension2[ XDMF_MAX_DIMENSION ]; XdmfInt64 Start[ XDMF_MAX_DIMENSION ]; XdmfInt64 Stride[ XDMF_MAX_DIMENSION ]; XdmfInt64 Count[ XDMF_MAX_DIMENSION ]; XdmfInt64 NewDimension[ XDMF_MAX_DIMENSION ]; /* printf("Array 0x%X , 0x%X\n", Array1, Array2); */ Rank1 = Array1->GetShape( Dimension1 ); Rank2 = Array2->GetShape( Dimension2 ); if( Rank1 != Rank2 ){ printf(" Interlace : Rank Mismatch !!\n"); } NewArray->CopyType( Array1 ); Length1 = Array1->GetNumberOfElements(); Length2 = Array2->GetNumberOfElements(); NewLength = Length1 + Length2; IFactor = Length1 / Length2; Lcd = Length1; if( Length2 < Length1 ){ Lcd = Length2; } NewDimension[0] = Lcd; NewDimension[1] = NewLength / Lcd; NewArray->SetShape( 2, NewDimension ); /* printf("Rank1 = %d Rank2 = %d\n", Rank1, Rank2 ); printf("Array1 Size = %d\n", Array1->GetNumberOfElements() ); printf("Array2 Size = %d\n", Array2->GetNumberOfElements() ); printf("NewLength = %d\n", NewLength ); printf("Lcd = %d\n", Lcd ); printf("IFactor = %d\n", IFactor ); printf("New Dims = %s\n", NewArray->GetShapeAsString() ); */ /* NewArray->Generate( -55.0, -55.0 ); */ /* Copy in Array 1 */ Start[0] = 0; Start[1] = 0; Stride[0] = 1; Stride[1] = 1; Count[0] = Lcd; Count[1] = Length1 / Lcd; NewArray->SelectHyperSlab( Start, Stride, Count ); Array1->SelectAll(); /* printf("Copy in Array1 = %s\n", NewArray->GetHyperSlabAsString() ); */ CopyArray( Array1, NewArray ); /* Copy in Array 2 */ Start[0] = 0; Start[1] = Length1 / Lcd; Stride[0] = 1; Stride[1] = 1; Count[0] = Lcd; Count[1] = Length2 / Lcd; NewArray->SelectHyperSlab( Start, Stride, Count ); Array2->SelectAll(); /* printf("Copy in Array2 = %s\n", NewArray->GetHyperSlabAsString() ); */ CopyArray( Array2, NewArray ); NewDimension[0] = Dimension1[0] + Dimension2[0]; for( i = 1 ; i < Rank1 ; i++ ){ NewDimension[i] = Dimension1[i]; } NewArray->Reform( Rank1, NewDimension ); /* printf("Result(%s) = %s\n", NewArray->GetShapeAsString(), NewArray->GetValues() ); */ yyval.ArrayPointer = NewArray; delete Array1; delete Array2; } break; case 13: #line 239 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { /* Interlace */ XdmfArray *Array1 = ( XdmfArray *)yyvsp[-2].ArrayPointer; XdmfArray *Array2 = ( XdmfArray *)yyvsp[0].ArrayPointer; XdmfArray *NewArray = new XdmfArray(); XdmfInt32 i, Rank1, Rank2; XdmfInt64 Dimension1[ XDMF_MAX_DIMENSION ]; XdmfInt64 Dimension2[ XDMF_MAX_DIMENSION ]; XdmfInt64 Start[ XDMF_MAX_DIMENSION ]; XdmfInt64 Stride[ XDMF_MAX_DIMENSION ]; XdmfInt64 Count[ XDMF_MAX_DIMENSION ]; XdmfInt64 NewDimension[ XDMF_MAX_DIMENSION ]; /* printf("Array 0x%X << 0x%X\n", Array1, Array2); */ Rank1 = Array1->GetShape( Dimension1 ); Rank2 = Array2->GetShape( Dimension2 ); if( Rank1 != Rank2 ){ printf(" Cat : Rank Mismatch !!\n"); } NewDimension[0] = Dimension1[0] + Dimension2[0]; for( i = 1 ; i < Rank1 ; i++ ){ NewDimension[i] = Dimension1[i]; } NewArray->CopyType( Array1 ); NewArray->SetShape( Rank1, NewDimension ); /* NewArray->Generate( -55.0, -55.0 ); */ /* Copy in Array 1 */ for( i = 0 ; i < Rank1 ; i++ ){ Start[i] = 0; Stride[i] = 1; Count[i] = Dimension1[i]; } NewArray->SelectHyperSlab( Start, Stride, Count ); Array1->SelectAll(); /* printf("Copy in Array1 = %s\n", NewArray->GetHyperSlabAsString() ); */ CopyArray( Array1, NewArray ); /* Copy in Array 2 */ Start[0] = Dimension1[0]; Stride[0] = 1; Count[0] = Dimension2[0]; for( i = 1 ; i < Rank1 ; i++ ){ Start[i] = 0; Stride[i] = 1; Count[i] = Dimension1[i]; } NewArray->SelectHyperSlab( Start, Stride, Count ); Array2->SelectAll(); /* printf("Copy in Array2 = %s\n", NewArray->GetHyperSlabAsString() ); */ CopyArray( Array2, NewArray ); /* printf("Result(%s) = %s\n", NewArray->GetShapeAsString(), NewArray->GetValues() ); */ yyval.ArrayPointer = NewArray; delete Array1; delete Array2; } break; case 14: #line 303 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { XdmfArray *Array1 = ( XdmfArray *)yyvsp[-2].ArrayPointer; XdmfArray *Array2 = ( XdmfArray *)yyvsp[0].ArrayPointer; /* printf("Array 0x%X + 0x%X\n", Array1, Array2); */ *Array1 -= *Array2; yyval.ArrayPointer = Array1; delete Array2; } break; case 15: #line 312 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { XdmfArray *Array1 = ( XdmfArray *)yyvsp[-2].ArrayPointer; XdmfArray *Array2 = ( XdmfArray *)yyvsp[0].ArrayPointer; /* printf("Array 0x%X * 0x%X\n", Array1, Array2); */ *Array1 *= *Array2; yyval.ArrayPointer = Array1; delete Array2; /* printf("Array1 Nelms = %d\n", Array1->GetNumberOfElements()); */ } break; case 16: #line 322 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { XdmfArray *Array1 = ( XdmfArray *)yyvsp[-2].ArrayPointer; XdmfArray *Array2 = ( XdmfArray *)yyvsp[0].ArrayPointer; /* printf("Array 0x%X + 0x%X\n", Array1, Array2); */ *Array1 /= *Array2; yyval.ArrayPointer = Array1; delete Array2; } break; case 17: #line 331 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { XdmfArray *Array1 = ( XdmfArray *)yyvsp[-2].ArrayPointer; XdmfArray *Result; /* printf("Array + %g\n", $3); */ Result = Array1; *Result += yyvsp[0].DoubleValue; yyval.ArrayPointer = Result; } break; case 18: #line 340 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { XdmfArray *Array1 = ( XdmfArray *)yyvsp[-2].ArrayPointer; XdmfArray *Result; /* printf("Array - %g\n", $3); */ Result = Array1; *Result -= yyvsp[0].DoubleValue; yyval.ArrayPointer = Result; } break; case 19: #line 349 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { XdmfArray *Array1 = ( XdmfArray *)yyvsp[-2].ArrayPointer; XdmfArray *Result; /* printf("Array * %g\n", $3); */ Result = Array1; *Result *= yyvsp[0].DoubleValue; yyval.ArrayPointer = Result; } break; case 20: #line 358 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { XdmfArray *Array1 = ( XdmfArray *)yyvsp[-2].ArrayPointer; XdmfArray *Result; /* printf("Array / %g\n", $3); */ Result = Array1; *Result /= yyvsp[0].DoubleValue; yyval.ArrayPointer = Result; } break; case 21: #line 367 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { XdmfArray *Array1 = ( XdmfArray *)yyvsp[0].ArrayPointer; XdmfArray *Result; /* printf("Array + %g\n", $1); */ Result = Array1; *Result += yyvsp[-2].DoubleValue; yyval.ArrayPointer = Result; } break; case 22: #line 376 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { XdmfArray *Array1 = ( XdmfArray *)yyvsp[0].ArrayPointer; XdmfArray *Result; /* printf("Array - %g\n", $1); */ Result = Array1; *Result -= yyvsp[-2].DoubleValue; yyval.ArrayPointer = Result; } break; case 23: #line 385 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { XdmfArray *Array1 = ( XdmfArray *)yyvsp[0].ArrayPointer; XdmfArray *Result; /* printf("Array * %g\n", $1); */ Result = Array1; *Result *= yyvsp[-2].DoubleValue; yyval.ArrayPointer = Result; } break; case 24: #line 394 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { XdmfArray *Array1 = ( XdmfArray *)yyvsp[0].ArrayPointer; XdmfArray *Result; /* printf("Array / %g\n", $1); */ Result = Array1; *Result /= yyvsp[-2].DoubleValue; yyval.ArrayPointer = Result; } break; case 25: #line 403 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { XdmfArray *Array1 = ( XdmfArray *)yyvsp[-3].ArrayPointer; XdmfArray *Array2 = ( XdmfArray *)yyvsp[-1].ArrayPointer; XdmfArray *Result; /* printf("ArrayExpression From Indexes\n"); */ Result = Array1->Clone( Array2 ); delete Array2; yyval.ArrayPointer = Result; } break; case 26: #line 413 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { XdmfArray *Array1 = ( XdmfArray *)yyvsp[-5].ArrayPointer; XdmfArray *Range, *Result; /* printf("ArrayExpression From Array Range %d:%d\n", $3, $5); */ Range = Array1->Reference( yyvsp[-3].IntegerValue, yyvsp[-1].IntegerValue ); /* This not a copy */ Result = Range->Clone(); /* So Copy It */ delete Array1; yyval.ArrayPointer = Result; } break; case 27: #line 424 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { XdmfArray *Array1 = ( XdmfArray *)yyvsp[-3].ArrayPointer; XdmfArray *Array2 = ( XdmfArray *)yyvsp[-1].ArrayPointer; XdmfLength i, howmany = 0, cntr = 0; XdmfLength Length1 = Array1->GetNumberOfElements(), Length2; XdmfInt64Array *Index = new XdmfInt64Array( Length1 ); XdmfInt64 A1Value, A2Value; XdmfInt64 *A1Values, *A2Values; float Percent; if(Array1->GetNumberType() != XDMF_INT64_TYPE){ yyerror("INDEX operator only uses XdmfInt64 Arrays"); return( 0 ); } if(Array2->GetNumberType() != XDMF_INT64_TYPE){ yyerror("INDEX operator only uses XdmfInt64 Arrays"); return( 0 ); } Length2 = Array2->GetNumberOfElements(); A1Values = (XdmfInt64 *)Array1->GetDataPointer(); A2Values = (XdmfInt64 *)Array2->GetDataPointer(); for( i = 0 ; i < Length1 ; i++ ){ /* A1Value = Array1->GetValueAsFloat64( i ); */ A1Value = *A1Values++; cntr = 0; A2Value = A1Value + 1; while((cntr < Length2) && (A2Value != A1Value)) { /* A2Value = Array2->GetValueAsFloat64(cntr); */ A2Value = A2Values[cntr]; cntr++; } howmany++; if(howmany > 5000){ Percent = 100.0 * i / Length1; printf("%5.2f %% Done\n", Percent); howmany = 0; } if( A1Value == A2Value ) { Index->SetValue( i, cntr - 1 ); }else{ Index->SetValue( i, -1); } } yyval.ArrayPointer = ( XdmfArray *)Index; } break; case 28: #line 469 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { XdmfArray *Array1 = ( XdmfArray *)yyvsp[-3].ArrayPointer; /* XdmfLength howmany = 0; */ XdmfLength i, cntr = 0; XdmfLength Length1 = Array1->GetNumberOfElements(), Length2; XdmfInt64Array *Index = new XdmfInt64Array( Length1 ); XdmfArray *Array2 = ( XdmfArray *)yyvsp[-1].ArrayPointer; XdmfFloat64 A1Value, A2Value; Length2 = Array2->GetNumberOfElements(); for( i = 0 ; i < Length1 ; i++ ){ A1Value = Array1->GetValueAsFloat64( i ); cntr = 0; A2Value = A1Value + 1; while((cntr < Length2) && (A2Value != A1Value)) { A2Value = Array2->GetValueAsFloat64(cntr); cntr++; } /* howmany++; if(howmany > 1000){ cout << "Checked " << i << " of " << Length1 << endl; howmany = 0; } */ if( A1Value == A2Value ) { Index->SetValue( i, cntr - 1 ); }else{ Index->SetValue( i, -1); } } yyval.ArrayPointer = ( XdmfArray *)Index; } break; case 29: #line 502 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { XdmfArray *Array1 = ( XdmfArray *)yyvsp[-3].ArrayPointer; XdmfLength i, cntr = 0; XdmfLength Length = Array1->GetNumberOfElements(); XdmfInt64Array *Index = new XdmfInt64Array( Length ); XdmfFloat64 Value, SValue = yyvsp[-1].DoubleValue; for( i = 0 ; i < Length ; i++ ){ Value = Array1->GetValueAsFloat64( i ); if( Value == SValue ) { Index->SetValue( cntr++, i ); } } /* printf("Found %d Wheres\n", cntr ); */ if( cntr == 0 ){ yyerror("WHERE Function Length == 0"); return( 0 ); } Index->SetNumberOfElements( cntr ); yyval.ArrayPointer = ( XdmfArray *)Index; } break; case 30: #line 523 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { XdmfArray *Array1 = ( XdmfArray *)yyvsp[-3].ArrayPointer; XdmfLength i, cntr = 0; XdmfLength Length = Array1->GetNumberOfElements(); XdmfInt64Array *Index = new XdmfInt64Array( Length ); XdmfFloat64 Value, SValue = yyvsp[-1].DoubleValue; for( i = 0 ; i < Length ; i++ ){ Value = Array1->GetValueAsFloat64( i ); if( Value < SValue ) { Index->SetValue( cntr++, i ); } } /* printf("Found %d Wheres\n", cntr ); */ if( cntr == 0 ){ yyerror("WHERE Function Length == 0"); return( 0 ); } Index->SetNumberOfElements( cntr ); yyval.ArrayPointer = ( XdmfArray *)Index; } break; case 31: #line 544 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { XdmfArray *Array1 = ( XdmfArray *)yyvsp[-3].ArrayPointer; XdmfLength i, cntr = 0; XdmfLength Length = Array1->GetNumberOfElements(); XdmfInt64Array *Index = new XdmfInt64Array( Length ); XdmfFloat64 Value, SValue = yyvsp[-1].DoubleValue; for( i = 0 ; i < Length ; i++ ){ Value = Array1->GetValueAsFloat64( i ); if( Value <= SValue ) { Index->SetValue( cntr++, i ); } } /* printf("Found %d Wheres\n", cntr ); */ if( cntr == 0 ){ yyerror("WHERE Function Length == 0"); return( 0 ); } Index->SetNumberOfElements( cntr ); yyval.ArrayPointer = ( XdmfArray *)Index; } break; case 32: #line 565 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { XdmfArray *Array1 = ( XdmfArray *)yyvsp[-3].ArrayPointer; XdmfLength i, cntr = 0; XdmfLength Length = Array1->GetNumberOfElements(); XdmfInt64Array *Index = new XdmfInt64Array( Length ); XdmfFloat64 Value, SValue = yyvsp[-1].DoubleValue; for( i = 0 ; i < Length ; i++ ){ Value = Array1->GetValueAsFloat64( i ); if( Value > SValue ) { Index->SetValue( cntr++, i ); } } /* printf("Found %d Wheres\n", cntr ); */ if( cntr == 0 ){ yyerror("WHERE Function Length == 0"); return( 0 ); } Index->SetNumberOfElements( cntr ); yyval.ArrayPointer = ( XdmfArray *)Index; } break; case 33: #line 586 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { XdmfArray *Array1 = ( XdmfArray *)yyvsp[-3].ArrayPointer; XdmfLength i, cntr = 0; XdmfLength Length = Array1->GetNumberOfElements(); XdmfInt64Array *Index = new XdmfInt64Array( Length ); XdmfFloat64 Value, SValue = yyvsp[-1].DoubleValue; for( i = 0 ; i < Length ; i++ ){ Value = Array1->GetValueAsFloat64( i ); if( Value >= SValue ) { Index->SetValue( cntr++, i ); } } /* printf("Found %d Wheres\n", cntr ); */ if( cntr == 0 ){ yyerror("WHERE Function Length == 0"); return( 0 ); } Index->SetNumberOfElements( cntr ); yyval.ArrayPointer = ( XdmfArray *)Index; } break; case 34: #line 607 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { XdmfArray *Array1 = ( XdmfArray *)yyvsp[-3].ArrayPointer; XdmfLength i, cntr = 0; XdmfLength Length = Array1->GetNumberOfElements(); XdmfInt64Array *Index = new XdmfInt64Array( Length ); XdmfFloat64 Value, SValue = yyvsp[-1].DoubleValue; for( i = 0 ; i < Length ; i++ ){ Value = Array1->GetValueAsFloat64( i ); if( Value != SValue ) { Index->SetValue( cntr++, i ); } } /* printf("Found %d Wheres\n", cntr ); */ if( cntr == 0 ){ yyerror("WHERE Function Length == 0"); return( 0 ); } Index->SetNumberOfElements( cntr ); yyval.ArrayPointer = ( XdmfArray *)Index; } break; case 35: #line 628 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { if( yyvsp[-3].Symbol->DoubleFunctionPtr == NULL ){ /* printf("Bad Function Ptr for %s\n", $1->Name ); */ yyval.ArrayPointer = yyvsp[-1].ArrayPointer; } else { XdmfArray *Array1 = ( XdmfArray *)yyvsp[-1].ArrayPointer; XdmfFloat64 Value; XdmfLength i, Length = Array1->GetNumberOfElements(); /* printf("Function Call %s\n", $1->Name ); */ for( i = 0 ; i < Length ; i++ ){ Value = Array1->GetValueAsFloat64( i ); Array1->SetValueFromFloat64( i, (yyvsp[-3].Symbol->DoubleFunctionPtr)( Value ) ); } yyval.ArrayPointer = Array1; } } break; case 36: #line 646 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { /* printf("( ArrayExpression )\n"); */ yyval.ArrayPointer = yyvsp[-1].ArrayPointer; } break; case 37: #line 650 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { /* printf("( ArrayExpression )\n"); */ yyval.ArrayPointer = yyvsp[-1].ArrayPointer; } break; case 38: #line 654 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { XdmfArray *Array1 = ( XdmfArray *)yyvsp[0].ArrayPointer; XdmfArray *Result; /* printf("ArrayExpression From Array\n"); */ if ( Array1 == NULL ){ /* Bomb */ yyerror("NULL Array Pointer"); return( 0 ); } else { Result = Array1->Clone(); yyval.ArrayPointer = Result; } } break; case 39: #line 671 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { /* printf("Scalar +\n"); */ yyval.DoubleValue = yyvsp[-2].DoubleValue + yyvsp[0].DoubleValue; } break; case 40: #line 675 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { /* printf("Scalar -\n"); */ yyval.DoubleValue = yyvsp[-2].DoubleValue - yyvsp[0].DoubleValue; } break; case 41: #line 679 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { /* printf("Scalar *\n"); */ yyval.DoubleValue = yyvsp[-2].DoubleValue * yyvsp[0].DoubleValue; } break; case 42: #line 683 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { /* printf("Scalar /\n"); */ yyval.DoubleValue = yyvsp[-2].DoubleValue / yyvsp[0].DoubleValue; } break; case 43: #line 687 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { if( yyvsp[-3].Symbol->DoubleFunctionPtr == NULL ){ /* printf("Bad Function Ptr for %s\n", $1->Name ); */ yyval.DoubleValue = 0.0; } else { yyval.DoubleValue = (yyvsp[-3].Symbol->DoubleFunctionPtr)( yyvsp[-1].DoubleValue ); } } break; case 44: #line 695 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { /* printf ("( ScalarExpression )\n"); */ yyval.DoubleValue = yyvsp[-1].DoubleValue; } break; case 45: #line 699 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { /* printf ("ScalarExpression from tokINTEGER\n"); */ yyval.DoubleValue = yyvsp[0].IntegerValue; } break; case 46: #line 703 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" { /* printf ("ScalarExpression from FLOAT\n"); */ yyval.DoubleValue = yyvsp[0].DoubleValue; } break; } /* Line 999 of yacc.c. */ #line 2008 "/home/andy/vtk/Xdmf-bin/libsrc/XdmfExprYacc.tab.c" yyvsp -= yylen; yyssp -= yylen; YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ yyn = yyr1[yyn]; yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else yystate = yydefgoto[yyn - YYNTOKENS]; goto yynewstate; /*------------------------------------. | yyerrlab -- here on detecting error | `------------------------------------*/ yyerrlab: /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { ++yynerrs; #if YYERROR_VERBOSE yyn = yypact[yystate]; if (YYPACT_NINF < yyn && yyn < YYLAST) { YYSIZE_T yysize = 0; int yytype = YYTRANSLATE (yychar); char *yymsg; int yyx, yycount; yycount = 0; /* Start YYX at -YYN if negative to avoid negative indexes in YYCHECK. */ for (yyx = yyn < 0 ? -yyn : 0; yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) yysize += yystrlen (yytname[yyx]) + 15, yycount++; yysize += yystrlen ("syntax error, unexpected ") + 1; yysize += yystrlen (yytname[yytype]); yymsg = (char *) YYSTACK_ALLOC (yysize); if (yymsg != 0) { char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); yyp = yystpcpy (yyp, yytname[yytype]); if (yycount < 5) { yycount = 0; for (yyx = yyn < 0 ? -yyn : 0; yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) { const char *yyq = ! yycount ? ", expecting " : " or "; yyp = yystpcpy (yyp, yyq); yyp = yystpcpy (yyp, yytname[yyx]); yycount++; } } yyerror (yymsg); YYSTACK_FREE (yymsg); } else yyerror ("syntax error; also virtual memory exhausted"); } else #endif /* YYERROR_VERBOSE */ yyerror ("syntax error"); } if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an error, discard it. */ /* Return failure if at end of input. */ if (yychar == YYEOF) { /* Pop the error token. */ YYPOPSTACK; /* Pop the rest of the stack. */ while (yyss < yyssp) { YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); yydestruct (yystos[*yyssp], yyvsp); YYPOPSTACK; } YYABORT; } YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); yydestruct (yytoken, &yylval); yychar = YYEMPTY; } /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1; /*----------------------------------------------------. | yyerrlab1 -- error raised explicitly by an action. | `----------------------------------------------------*/ yyerrlab1: yyerrstatus = 3; /* Each real token shifted decrements this. */ for (;;) { yyn = yypact[yystate]; if (yyn != YYPACT_NINF) { yyn += YYTERROR; if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) { yyn = yytable[yyn]; if (0 < yyn) break; } } /* Pop the current state because it cannot handle the error token. */ if (yyssp == yyss) YYABORT; YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); yydestruct (yystos[yystate], yyvsp); yyvsp--; yystate = *--yyssp; YY_STACK_PRINT (yyss, yyssp); } if (yyn == YYFINAL) YYACCEPT; YYDPRINTF ((stderr, "Shifting error token, ")); *++yyvsp = yylval; yystate = yyn; goto yynewstate; /*-------------------------------------. | yyacceptlab -- YYACCEPT comes here. | `-------------------------------------*/ yyacceptlab: yyresult = 0; goto yyreturn; /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ yyabortlab: yyresult = 1; goto yyreturn; #ifndef yyoverflow /*----------------------------------------------. | yyoverflowlab -- parser overflow comes here. | `----------------------------------------------*/ yyoverflowlab: yyerror ("parser stack overflow"); yyresult = 2; /* Fall through. */ #endif yyreturn: #ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss); #endif return yyresult; } #line 710 "/home/andy/vtk/Xdmf/libsrc/XdmfExpr.y" /* extern FILE *yyin, *yyout; */ #ifdef __cplusplus /**/ extern "C" { /**/ #endif char InputBuffer[ 512 ]; int InputBufferPtr = 0, InputBufferEnd = 0; char OutputBuffer[ 512 ]; int OutputBufferPtr = 0; /* static int OutputBufferEnd = 511; */ int dice_yywrap( void ) { return 1; } void dice_yyerror( const char *string ) { fprintf(stderr, "XdmfExpr : %s \n", string); } int XdmfExprFlexInput( char *buf, int maxlen ) { (void)maxlen; if ( InputBufferPtr < InputBufferEnd ){ buf[0] = InputBuffer[ InputBufferPtr++ ]; return(1); } else { buf[0] = '\n'; return( 0 ); } } int XdmfExprInput( void ){ if ( InputBufferPtr < InputBufferEnd ){ return( InputBuffer[ InputBufferPtr++ ] ); } else { return '\n'; } } void XdmfExprUnput( int c ) { if( InputBufferPtr > 0 ){ InputBufferPtr--; InputBuffer[ InputBufferPtr ] = c; } } void XdmfExprOutput( int c ) { /* printf("XdmfExprOutput Called\n"); */ OutputBuffer[ OutputBufferPtr++ ] = c; OutputBuffer[ OutputBufferPtr ] = '\0'; } XdmfExprSymbol *XdmfExprSymbolLookup( const char *Name ){ XdmfExprSymbol *Last = NULL, *Item = XdmfExprItemsTable; if( Name == NULL ) { /* Table Check */ return( XdmfExprItemsTable ); } while( Item != NULL ) { if( strcmp( Item->Name, Name ) == 0 ) { /* printf("Found Symbol %s\n", Name ); */ return( Item ); } Last = Item; Item = Item->Next; } /* Not Found : Create New One */ Item = ( XdmfExprSymbol *)calloc( 1, sizeof( XdmfExprSymbol )); Item->Next = NULL; Item->Name = strdup( Name ); Item->ClientData = NULL; Item->DoubleValue = 0; Item->DoubleFunctionPtr = NULL; if( XdmfExprItemsTable == NULL ) { XdmfExprItemsTable = Item; } if( Last != NULL ){ Last->Next = Item; } /* printf("New Symbol for %s\n", Name ); */ return( Item ); } #ifdef __cplusplus /**/ } /**/ #endif XdmfArray * XdmfExprParse( char *string ){ XdmfExprSymbol *Item; XdmfLength CurrentTime; XdmfLength TimeOfCreation; XdmfArray *ap; /* Build the Symbol Table if Necessary */ Item = XdmfExprSymbolLookup( NULL ); if( Item == NULL ){ /* printf("Creating Symbol Table\n"); */ Item = XdmfExprSymbolLookup( "cos" ); Item->DoubleFunctionPtr = cos; Item = XdmfExprSymbolLookup( "sin" ); Item->DoubleFunctionPtr = sin; Item = XdmfExprSymbolLookup( "exp" ); Item->DoubleFunctionPtr = exp; Item = XdmfExprSymbolLookup( "tan" ); Item->DoubleFunctionPtr = tan; Item = XdmfExprSymbolLookup( "acos" ); Item->DoubleFunctionPtr = acos; Item = XdmfExprSymbolLookup( "asin" ); Item->DoubleFunctionPtr = asin; Item = XdmfExprSymbolLookup( "atan" ); Item->DoubleFunctionPtr = atan; Item = XdmfExprSymbolLookup( "log" ); Item->DoubleFunctionPtr = log; Item = XdmfExprSymbolLookup( "sqrt" ); Item->DoubleFunctionPtr = sqrt; } /* Print Symbol Table */ Item = XdmfExprSymbolLookup( NULL ); while( Item != NULL ) { if( Item->ClientData != NULL ){ /* printf("Found Symbol %s\n", Item->Name ); */ } Item = Item->Next; } strcpy( InputBuffer, string ); InputBufferEnd = strlen( InputBuffer ); InputBufferPtr = OutputBufferPtr = 0; XdmfExprReturnValue = NULL; /* printf("XdmfExprParse Scanning <%s>\n", InputBuffer); */ CurrentTime = GetCurrentArrayTime(); if ( yyparse() != 0 ){ /* Error */ XdmfExprReturnValue = NULL; } Item = XdmfExprSymbolLookup( NULL ); while( Item != NULL ) { XdmfExprSymbol *next = Item->Next; if ( Item->Name ) { free(Item->Name); } free(Item); Item = next; } XdmfExprItemsTable = NULL; /* Remove All Arrays Older than when we started */ /* printf("Cleaning up Temparary Arrays\n"); */ while( ( ap = GetNextOlderArray( CurrentTime, &TimeOfCreation ) ) != NULL ){ /* Don't remove the return value */ if( ap != XdmfExprReturnValue ){ /* printf("Removing Temporary Array\n"); */ delete ap; } CurrentTime = TimeOfCreation; } return( XdmfExprReturnValue ); } xdmf-3.0+git20160803/libsrc/XdmfDOM.h0000640000175000017500000002303113003006557016756 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : $Id: XdmfDOM.h,v 1.19 2010-03-16 17:33:38 kwleiter Exp $ */ /* Date : $Date: 2010-03-16 17:33:38 $ */ /* Version : $Revision: 1.19 $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2002 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #ifndef __XdmfDOM_h #define __XdmfDOM_h #include "XdmfLightData.h" //! Class for XML Parsing using the Document Object Model /*! This is the Base XML Parsing Object. A XdmfDOM will read the XML and build an internal tree structure. The tree can then be walked and queried. Any node can be "serialized". This generates an XML string that implements the node and all of its' children. Many other Xdmf Classes (XdmfGrid, XdmfTopology, etc.) use this class to parse and generate XML. The DOM can accept XML from a String or from a File. Once \b PARSED the resulting tree can be modified by adding or deleting nodes and then "serialized" to produce XML. For example, the following XML might be in MyFile.xml : \verbatim Text for Second Child \endverbatim The DOM might manipulate the XML with : \code XdmfDOM *DOM = new XdmfDOM(); XdmfXmlNode *Parent, *FirstChild, *SecondChild; // Parse the XML File DOM->SetInputFileName("MyFile.xml"); DOM->Parse(); // Find the first element with TAG = Tag1 Parent = DOM->FindElement("Tag1"); // Find the first (zero based) Tag2 below Parent FirstChild = DOM->FindElement("Tag2", 0, Parent); cout << "The Name of the First Child is <" << DOM->Get(FirstChild, "Name") << ">" << endl; // Find the second (zero based) Tag2 below Parent SecondChild = DOM->FindElement("Tag2", 1, Parent); DOM->Set(SecondChild, "Age", "10"); DOM->DeleteNode(FirstChild); cout << endl << "XML = " << endl << DOM->Serialize(Parent) << endl; \endcode Would Procude the following Output: \verbatim The Name of the First Child is XML = Text for Second Child \endverbatim */ class XDMF_EXPORT XdmfDOM : public XdmfLightData { public : XdmfDOM(); ~XdmfDOM(); XdmfConstString GetClassName() { return("XdmfDOM"); } ; //! Set the FileName of the XML Description : stdin or Filename XdmfInt32 SetInputFileName( XdmfConstString Filename ); //! Set the FileName of the XML Description : stderr or Filename XdmfInt32 SetOutputFileName( XdmfConstString Filename ); //! Get the FileName of the XML Description XdmfConstString GetInputFileName() { return(this->GetFileName()); }; //! Get the FileName of the XML Description XdmfGetStringMacro( OutputFileName ); /*! Set Parser Options. See libxml documentation for values Default = XML_PARSE_NONET | XML_PARSE_XINCLUDE */ XdmfSetValueMacro(ParserOptions, XdmfInt32); //! Get the XML destination XdmfGetValueMacro( Output, ostream *); //! Set the XML destination XdmfSetValueMacro( Output, ostream *); //! Get the XML destination XdmfGetValueMacro( Input, istream *); //! Set the XML destination XdmfSetValueMacro( Input, istream *); //! Generate a Standard XDMF Header XdmfInt32 GenerateHead( void ); //! Check status of Xdmf.dtd inclusion in the XML header XdmfGetValueMacro( DTD, XdmfInt32 ); //! Set the status of the Xdmf.dtd inclusion in the XML header XdmfSetValueMacro( DTD, XdmfInt32 ); //! Output a String to the XML document XdmfInt32 Puts( XdmfConstString String ); //! Generate a Standard XDMF Tail XdmfInt32 GenerateTail( void ); //! Return the Low Level root of the tree XdmfXmlNode GetTree( void ) {return(this->Tree);} ; //! Parse XML without re-initializing entire DOM XdmfXmlNode __Parse(XdmfConstString xml, XdmfXmlDoc *Doc=NULL); //! Re-Initialize and Parse XdmfInt32 Parse(XdmfConstString xml = NULL ); //! Get the Root Node XdmfXmlNode GetRoot( void ); //! Get the Number of immediate Children XdmfInt64 GetNumberOfChildren( XdmfXmlNode node = NULL); //! Get The N'th Child XdmfXmlNode GetChild( XdmfInt64 Index , XdmfXmlNode Node ); //! Get Number of Attribute in a Node XdmfInt32 GetNumberOfAttributes( XdmfXmlNode Node ); //! Get Attribute Name by Index XdmfConstString GetAttributeName( XdmfXmlNode Node, XdmfInt32 Index ); //! Is the XdmfXmlNode a child of "Start" in this DOM XdmfInt32 IsChild( XdmfXmlNode ChildToCheck, XdmfXmlNode Node = NULL ); //! Convert DOM to XML String XdmfConstString Serialize(XdmfXmlNode node = NULL); /*! Dump the XML contents \param Output FileName of Output. Default is to use current OutputFileName */ XdmfInt32 Write(XdmfConstString Output = NULL); //! Insert a node into a DOM XdmfXmlNode Insert(XdmfXmlNode parent, XdmfXmlNode node); //! Create a node from an XML string and insert it in the DOM XdmfXmlNode InsertFromString(XdmfXmlNode parent, XdmfConstString xml ); //! Create a new document XdmfXmlNode Create(XdmfConstString RootElementName="Xdmf", XdmfConstString Version="2.0"); //! Create a new node under an existing one XdmfXmlNode InsertNew(XdmfXmlNode Parent, XdmfConstString Type); //! Delete a node XdmfInt32 DeleteNode(XdmfXmlNode node); //! Find the n'th occurance of a certain node type /*! Walk the tree and find the first element that is of a certain type. Index ( 0 based ) can be used to find the n'th node that satisfies the criteria. The search can also tree starting at a particular node. IgnoreInfo allows the "Information" Elements not to be counted against Index. */ XdmfXmlNode FindElement(XdmfConstString TagName, XdmfInt32 Index= 0, XdmfXmlNode Node = NULL, XdmfInt32 IgnoreInfo=1); /*! Find the next sibling for the node that is of a certain type. IgnoreInfo allows the "Information" elements to be skipped. */ XdmfXmlNode FindNextElement(XdmfConstString TagName, XdmfXmlNode Node, XdmfInt32 IgnoreInfo=1); /*! Find DataItem, DataStructure, or DataTransform This is needed for backward compatibility but will be removed in the future and XML will be forced to use file.h5 \endverbatim \code Dom->Get(Node, "Name") // will return "Test" Dom->Get(Node, "Type") // will return "Data" Dom->Get(Node, "Other") // will return NULL ; there is none Dom->Get(Node, "CData") // will return "file.h5" ; the Character Data \endcode */ XdmfConstString Get(XdmfXmlNode Node, XdmfConstString Attribute); //! Get an Attribute. Does not check for CDATA so it's faster XdmfConstString GetAttribute(XdmfXmlNode Node, XdmfConstString Attribute); //! Get the CDATA of a Node XdmfConstString GetCData(XdmfXmlNode Node); //! Set a new Attribute=Value in a Node void Set( XdmfXmlNode Node, XdmfConstString Attribute, XdmfConstString Value ); protected : XdmfString NdgmHost; XdmfString OutputFileName; ostream *Output; istream *Input; XdmfXmlDoc Doc; XdmfXmlNode Tree; XdmfInt32 ParserOptions; XdmfInt32 DTD; void FreePrivateData(XdmfXmlNode node); void FreeDoc(XdmfXmlDoc doc); }; extern XDMF_EXPORT XdmfDOM *HandleToXdmfDOM( XdmfConstString Source ); #endif xdmf-3.0+git20160803/libsrc/test/0000740000175000017500000000000013003006557016325 5ustar alastairalastairxdmf-3.0+git20160803/libsrc/test/CVS/0000740000175000017500000000000013003006557016760 5ustar alastairalastairxdmf-3.0+git20160803/libsrc/test/CVS/Repository0000640000175000017500000000002113003006557021055 0ustar alastairalastairXdmf/libsrc/test xdmf-3.0+git20160803/libsrc/test/CVS/Root0000640000175000017500000000006413003006557017630 0ustar alastairalastair:pserver:anonymous@public.kitware.com:/cvsroot/Xdmf xdmf-3.0+git20160803/libsrc/test/CVS/Entries0000640000175000017500000000064513003006557020323 0ustar alastairalastair/CMakeLists.txt/1.14/Fri Mar 19 22:24:03 2010// /PythonTestDriver.cmake.in/1.1/Wed Jan 6 16:34:08 2010// /TestXdmfArray.cc/1.1/Thu Aug 6 16:09:57 2009// /TestXdmfArrayPython.py/1.1/Thu Aug 6 16:09:14 2009// /TestXdmfDiff.cc/1.2/Wed Aug 19 20:07:45 2009// /TestXdmfHDF.cxx/1.2/Thu Aug 6 16:04:59 2009// /TestXdmfWriteGridsToFilePython.py/1.1/Thu Aug 6 16:07:17 2009// /XdmfHDFMPI.cxx/1.6/Mon Mar 22 18:19:04 2010// D xdmf-3.0+git20160803/libsrc/test/CMakeLists.txt0000640000175000017500000000553613003006557021100 0ustar alastairalastair# In CMake version 2.8 we can used a much nicer $ arguments for specifying # the configuration type of the build For now I have added this new functionality to these # batch tests but it will only work on dashboards using 2.8. This check can be removed when # ParaView officially requires CMake 2.8." SET(GENERATOR_EXPRESSIONS_SUPPORTED) IF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.8) SET(GENERATOR_EXPRESSIONS_SUPPORTED OFF) ELSE("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.8) SET(GENERATOR_EXPRESSIONS_SUPPORTED ON) ENDIF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.8) SET(TEST_EXECUTABLE_PATH ${EXECUTABLE_OUTPUT_PATH}) # We don't want the as part of the path on non windows systems. IF(WIN32 AND GENERATOR_EXPRESSIONS_SUPPORTED) SET(TEST_EXECUTABLE_PATH ${EXECUTABLE_OUTPUT_PATH}/\$) ENDIF(WIN32 AND GENERATOR_EXPRESSIONS_SUPPORTED) macro( XdmfSerialTest testname ) add_executable( ${testname} ${ARGN} ) target_link_libraries( ${testname} Xdmf ) add_test( ${testname} ${EXECUTABLE_OUTPUT_PATH}/${testname} ) endmacro() macro( XdmfMPITest testname num_procs ) find_package( MPI ) if( MPI_FOUND AND GENERATOR_EXPRESSIONS_SUPPORTED) include_directories( MPI_INCLUDE_PATH ) add_executable( ${testname} ${ARGN} ) target_link_libraries( ${testname} Xdmf ${MPI_LIBRARIES} ) add_test(NAME ${testname} COMMAND ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${num_procs} ${MPIEXEC_PREFLAGS} ${TEST_EXECUTABLE_PATH}/${testname} ${MPI_EXEC_POSTFLAGS} ) endif( MPI_FOUND AND GENERATOR_EXPRESSIONS_SUPPORTED) endmacro( XdmfMPITest ) macro( XdmfUtilsTest testname ) add_executable (${testname} ${ARGN} ) target_link_libraries( ${testname} XdmfUtils ) add_test( ${testname} ${EXECUTABLE_OUTPUT_PATH}/${testname} ) endmacro() XdmfSerialTest( XdmfTestHDFRoundtrip TestXdmfHDF.cxx ) #XdmfSerialTest( XdmfTestArray TestXdmfArray.cc) if(XDMF_BUILD_MPI) XdmfMPITest( XdmfTestHDFMPI 4 XdmfHDFMPI.cxx ) endif(XDMF_BUILD_MPI) if(XDMF_WRAP_PYTHON) if(PYTHON_EXECUTABLE) CONFIGURE_FILE(PythonTestDriver.cmake.in PythonTestDriver.cmake @ONLY) SET(PYTHON_TESTS TestXdmfArrayPython TestXdmfWriteGridsToFilePython ) FOREACH(PYTHON_TEST ${PYTHON_TESTS}) CONFIGURE_FILE(${PYTHON_TEST}.py ${PYTHON_TEST}.py COPYONLY) # Run all python tests by calling a cmake script that sets correct # environment variables --- python script to run and appropraite arguments # are set in ARGV and passed to the cmake script SET(ARGV ${CMAKE_CURRENT_BINARY_DIR}/${PYTHON_TEST}.py) ADD_TEST("${PYTHON_TEST}" ${CMAKE_COMMAND} "-D" ARGV=${ARGV} "-P" ${CMAKE_CURRENT_BINARY_DIR}/PythonTestDriver.cmake) ENDFOREACH(PYTHON_TEST) endif(PYTHON_EXECUTABLE) endif(XDMF_WRAP_PYTHON) xdmf-3.0+git20160803/libsrc/test/PythonTestDriver.cmake.in0000640000175000017500000000072313003006557023235 0ustar alastairalastairSET(ENV{PYTHONPATH} $ENV{PYTHONPATH}:@LIBRARY_OUTPUT_PATH@:@Xdmf_BINARY_DIR@/libsrc) SET(ENV{LD_LIBRARY_PATH} $ENV{LD_LIBRARY_PATH}:@LIBRARY_OUTPUT_PATH@:@Xdmf_BINARY_DIR@/libsrc) MESSAGE("CALLING: " ${ARGV}) EXECUTE_PROCESS( COMMAND "@PYTHON_EXECUTABLE@" ${ARGV} RESULT_VARIABLE import_res OUTPUT_VARIABLE import_output ERROR_VARIABLE import_output ) MESSAGE("${import_output}") IF(import_res) MESSAGE(SEND_ERROR "${import_res}") ENDIF(import_res) xdmf-3.0+git20160803/libsrc/test/TestXdmfDiff.cc0000640000175000017500000000666513003006557021202 0ustar alastairalastair#include #include XdmfDOM * createGrid(int * connections, double * points, double * nodeValues, double * cellValues) { XdmfRoot * myRoot = new XdmfRoot(); XdmfDomain * myDomain = new XdmfDomain(); XdmfDOM * myDOM = new XdmfDOM(); myRoot->SetDOM(myDOM); myRoot->Build(); myRoot->Insert(myDomain); XdmfGrid * myGrid = new XdmfGrid(); myGrid->SetName("test"); // Write Topology XdmfTopology * myTopology = myGrid->GetTopology(); myTopology->SetTopologyType(XDMF_HEX); myTopology->SetNumberOfElements(2); XdmfArray * myConnections = myTopology->GetConnectivity(); myConnections->SetHeavyDataSetName("output.h5:/Connections"); myConnections->SetNumberType(XDMF_INT32_TYPE); myConnections->SetNumberOfElements(16); myConnections->SetValues(0, connections, 16); // Write Geometry XdmfGeometry * myGeometry = myGrid->GetGeometry(); myGeometry->SetGeometryType(XDMF_GEOMETRY_XYZ); myGeometry->SetNumberOfPoints(12); XdmfArray * myPoints = myGeometry->GetPoints(); myPoints->SetHeavyDataSetName("output.h5:/XYZ"); myPoints->SetNumberType(XDMF_FLOAT64_TYPE); myPoints->SetNumberOfElements(36); myPoints->SetValues(0, points, 36); myDomain->Insert(myGrid); XdmfAttribute * currAttribute = new XdmfAttribute(); currAttribute->SetName("NodeValues"); currAttribute->SetAttributeCenter(XDMF_ATTRIBUTE_CENTER_NODE); currAttribute->SetAttributeType(XDMF_ATTRIBUTE_TYPE_SCALAR); currAttribute->SetDeleteOnGridDelete(true); XdmfArray * array = currAttribute->GetValues(); array->SetHeavyDataSetName("output.h5:/NodeValues"); // For now only support the data we know we are writing array->SetNumberType(XDMF_FLOAT64_TYPE); array->SetNumberOfElements(12); array->SetValues(0,nodeValues,12); myGrid->Insert(currAttribute); XdmfAttribute * cellAttribute = new XdmfAttribute(); cellAttribute->SetName("CellValues"); cellAttribute->SetAttributeCenter(XDMF_ATTRIBUTE_CENTER_CELL); cellAttribute->SetAttributeType(XDMF_ATTRIBUTE_TYPE_SCALAR); cellAttribute->SetDeleteOnGridDelete(true); XdmfArray * cellArray = cellAttribute->GetValues(); cellArray->SetHeavyDataSetName("output.h5:/CellValues"); // For now only support the data we know we are writing cellArray->SetNumberType(XDMF_FLOAT64_TYPE); cellArray->SetNumberOfElements(2); cellArray->SetValues(0,cellValues,2); myGrid->Insert(cellAttribute); myGrid->Build(); delete myGrid; delete myDomain; delete myRoot; return myDOM; } int main() { int connections[16] = {0,1,7,6,3,4,10,9,1,2,8,7,4,5,11,10}; double points[36] = {0,0,1,1,0,1,3,0,2,0,1,1,1,1,1,3,2,2,0,0,-1,1,0,-1,3,0,-2,0,1,-1,1,1,-1,3,2,-2}; double nodeValues[12] = {100, 200, 300, 300, 400, 500, 300, 400, 500, 500, 600, 700}; double cellValues[2] = {100, 200}; XdmfDOM * myDOM1 = createGrid(connections, points, nodeValues, cellValues); nodeValues[0] = 110; XdmfDOM * myDOM2 = createGrid(connections, points, nodeValues, cellValues); XdmfDiff * myDiff = new XdmfDiff(myDOM1, myDOM2); if (myDiff->AreEquivalent()) { return -1; } myDiff->SetAbsoluteError(5); if (myDiff->AreEquivalent()) { return -1; } myDiff->SetAbsoluteError(11); if (!myDiff->AreEquivalent()) { return -1; } myDiff->SetRelativeError(.05); if (myDiff->AreEquivalent()) { return -1; } myDiff->SetRelativeError(.1); if (!myDiff->AreEquivalent()) { return -1; } myDiff->SetRelativeError(0); myDiff->SetIgnoreAllAttributes(true); if (!myDiff->AreEquivalent()) { return -1; } delete myDiff; return 0; } xdmf-3.0+git20160803/libsrc/test/TestXdmfHDF.cxx0000640000175000017500000000162213003006557021134 0ustar alastairalastair#include #include char const * const kDatasetName = "FILE:TestFile.h5:/XdmfHDFSerial"; int main( int argc, char* argv[] ) { XdmfHDF* H5 = new XdmfHDF(); XdmfArray* MyData = new XdmfArray(); MyData->SetNumberType( XDMF_FLOAT32_TYPE ); MyData->SetNumberOfElements( 100 ); MyData->Generate( 0, 99 ); H5->CopyType( MyData ); H5->CopyShape( MyData ); H5->Open( kDatasetName, "w" ); H5->Write( MyData ); H5->Close(); XdmfHDF* H5In = new XdmfHDF(); H5In->Open( kDatasetName, "r" ); XdmfArray* result = H5In->Read(); H5In->Close(); bool failure = false; for ( size_t i = 0; i < 100; ++i ) { float value = result->GetValueAsFloat32( i ); std::cout << i << " " << value << std::endl; failure = ( value != i ); } delete result; delete MyData; delete H5; delete H5In; if ( failure ) { return -1; } else { return 0; } }; xdmf-3.0+git20160803/libsrc/test/XdmfHDFMPI.cxx0000640000175000017500000001363213003006557020646 0ustar alastairalastair#include #include #include /// Simple memory buffer implementation that keeps track of it's stream pointer. class Buffer { private: std::size_t m_size; char* m_data; char* m_put; char* m_tell; public: Buffer( std::size_t lsize ) : m_size( lsize ), m_data( new char[lsize] ), m_put( m_data ), m_tell( m_data ) {} ~Buffer() { delete [] m_data; } /// put a single value into the buffer template< typename T > void put( const T& t ) { std::size_t lsize = sizeof( T ); memcpy( m_put, &t, lsize ); m_put += lsize; } /// copy a contiguous block into the buffer void put( void* data, std::size_t lsize ) { memcpy( m_put, data, lsize ); m_put += lsize; } /// Copy a single value into the buffer. template< typename T > T tell() { std::size_t tsize = sizeof( T ); T tmp; memcpy( &tmp, m_tell, tsize ); m_tell += tsize; return tmp; } /// copy a contiguous block of data from the buffer to an already allocated /// location void tell( void* out, std::size_t lsize ) { memcpy( out, m_tell, lsize ); m_tell += lsize; } std::size_t size() const { return m_size; } char* pointer() { return m_data; } void reset() { m_put = m_data; m_tell = m_data; } }; /// Callback implements parallel IO by communicating to rank 0 in MPI_COMM_WORLD. class CommunicationCallback : public XdmfOpenCallback, public XdmfWriteCallback, public XdmfCloseCallback, public XdmfReadCallback { private: int mCommRank; int mCommSize; public: CommunicationCallback() { MPI_Comm_size( MPI_COMM_WORLD, &mCommSize ); MPI_Comm_rank( MPI_COMM_WORLD, &mCommRank ); } XdmfInt32 DoOpen( XdmfHeavyData* ds, XdmfConstString name, XdmfConstString access ) { // If HDF5 is compiled with Parallel IO, we must use collective open #ifndef H5_HAVE_PARALLEL if ( mCommRank == 0 ) { return ds->DoOpen( name, access ); } else { return XDMF_SUCCESS; } #else return ds->DoOpen( name, access ); #endif } XdmfInt32 DoClose( XdmfHeavyData* ds ) { #ifndef H5_HAVE_PARALLEL if ( mCommRank == 0 ) { return ds->DoClose(); } else { return XDMF_SUCCESS; } #else return ds->DoClose(); #endif } XdmfInt32 DoWrite( XdmfHeavyData* ds, XdmfArray* array ) { MPI_Status stat; // this is a really bad implementation that assumes rank 0 has the same data // size as everyone else, but we're really just going for a simple // example here. The real coalescing implementation will require a few more // classes to handle buffering the data cleanly and robustly. XdmfInt64 start[1], stride[1], count[1]; XdmfInt32 slab_rank = ds->GetHyperSlab( start, stride, count ); std::size_t slab_info_size = sizeof( XdmfInt32 ) // slab rank + slab_rank * sizeof( XdmfInt64 ) * 3; // start, stride, and count Buffer buf( slab_info_size + array->GetCoreLength() ); if ( mCommRank != 0 ) { // copy local data to the buffer for sending buf.put( slab_rank ); for ( int i = 0; i < slab_rank; ++i ) { buf.put( start[i] ); buf.put( stride[i] ); buf.put( count[i] ); } buf.put( array->GetDataPointer(), array->GetCoreLength() ); MPI_Send( buf.pointer(), buf.size(), MPI_BYTE, 0, 0, MPI_COMM_WORLD ); } else { // first, it's easy to write my own data ds->DoWrite( array ); int processes_received = 1; // I've written local data while ( processes_received < mCommSize ) { MPI_Recv( buf.pointer(), buf.size(), MPI_BYTE, MPI_ANY_SOURCE, 0, MPI_COMM_WORLD, &stat ); processes_received++; // pull the information from the buffer buf.reset(); slab_rank = buf.tell< XdmfInt32 >(); for( int i = 0; i < slab_rank; ++i ) { start[i] = buf.tell< XdmfInt64 >(); stride[i] = buf.tell< XdmfInt64 >(); count[i] = buf.tell< XdmfInt64 >(); } ds->SelectHyperSlab( start, stride, count ); XdmfArray* recv = new XdmfArray; recv->CopyShape( array ); buf.tell( recv->GetDataPointer(), recv->GetCoreLength() ); ds->DoWrite( recv ); delete recv; } } return XDMF_SUCCESS; } XdmfArray* DoRead( XdmfHeavyData* ds, XdmfArray* array ) { if ( mCommRank == 0 ) { return ds->DoRead( array ); } else { return NULL; } } }; char const * const kDatasetName = "FILE:TestFile.h5:/XdmfHDFMPI"; int main( int argc, char* argv[] ) { MPI_Init( &argc, &argv ); int rank; MPI_Comm_rank( MPI_COMM_WORLD, &rank ); XdmfHDF* H5 = new XdmfHDF(); CommunicationCallback* cb = new CommunicationCallback; H5->setOpenCallback( cb ); H5->setWriteCallback( cb ); H5->setCloseCallback(cb ); XdmfArray* MyData = new XdmfArray(); MyData->SetNumberType( XDMF_FLOAT32_TYPE ); MyData->SetNumberOfElements( 25 ); MyData->Generate( rank * 25, rank*25 + 24 ); H5->CopyType( MyData ); XdmfInt64 dims[1], start[1], stride[1], count[1]; dims[0] = 100; H5->SetShape( 1, dims ); start[0] = rank * 25; stride[0] = 1; count[0] = 25; H5->SelectHyperSlab( start, stride, count ); H5->Open( kDatasetName, "w" ); H5->Write( MyData ); H5->Close(); bool failure = false; XdmfHDF* H5In = new XdmfHDF(); H5In->setReadCallback( cb ); H5In->setOpenCallback( cb ); H5In->Open( kDatasetName, "r" ); XdmfArray* result = H5In->Read(); if ( result ) { for ( size_t i = 0; i < 100; ++i ) { float value = result->GetValueAsFloat32( i ); std::cout << i << " " << value << std::endl; failure = ( value != i ); } } delete H5; delete cb; delete MyData; delete H5In; delete result; MPI_Finalize(); if ( failure ) { return -1; } else { return 0; } }; xdmf-3.0+git20160803/libsrc/test/TestXdmfArrayPython.py0000640000175000017500000000344613003006557022647 0ustar alastairalastair### Author: Kenneth Leiter ### E-mail: kenneth.leiter@us.army.mil ### ### A simple python test that writes ints and floats to XdmfArrays and then tries to read them. Compares the ### values for equality and tests the accuracy of some convenience functions import Xdmf from Xdmf import * if __name__ == '__main__': ## ## First Part = XDMF_INT64_TYPE Array ## intArray = Xdmf.XdmfArray() intArray.SetNumberType(Xdmf.XDMF_INT64_TYPE) assert(intArray.GetNumberType() == Xdmf.XDMF_INT64_TYPE) intArray.SetShapeFromString("3 3") assert(intArray.GetShapeAsString() == "3 3") assert(intArray.GetNumberOfElements() == 9) toWrite = [0, 1, 3, 4, 500, -5000, 500000, 9223372036854775807, -9223372036854775807] i = 0; for element in toWrite: intArray.SetValueFromInt64(i,element) i += 1 i = 0; for element in toWrite: assert(intArray.GetValueAsInt64(i) == element) i += 1 assert (intArray.GetMaxAsInt64() == 9223372036854775807) assert (intArray.GetMinAsInt64() == -9223372036854775807) ## ## Second Part = XDMF_FLOAT64_TYPE Array ## floatArray = Xdmf.XdmfArray() floatArray.SetNumberType(Xdmf.XDMF_FLOAT64_TYPE) assert(floatArray.GetNumberType() == Xdmf.XDMF_FLOAT64_TYPE) floatArray.SetShapeFromString("2 2 2") assert(floatArray.GetShapeAsString() == "2 2 2") assert(floatArray.GetNumberOfElements() == 8) toWrite = [0, -1, 1100.256, 1.1, 1000.50 , 5.6234567, -60.2, 60.25659] i = 0; for element in toWrite: floatArray.SetValueFromFloat64(i,element) i += 1 i = 0; for element in toWrite: assert(floatArray.GetValueAsFloat64(i) == element) i += 1 assert (floatArray.GetMaxAsFloat64() == 1100.256) assert (floatArray.GetMinAsFloat64() == -60.2)xdmf-3.0+git20160803/libsrc/test/TestXdmfWriteGridsToFilePython.py0000640000175000017500000002513113003006557024752 0ustar alastairalastair### Author: Kenneth Leiter ### E-mail: kenneth.leiter@us.army.mil ### ### A python test that writes out a test python file... TestVTKXdmfReader attempts to read in the file generated ### here. import sys import Xdmf from Xdmf import * if __name__ == '__main__': heavyDataSetName = 'testFile.h5' outputName = 'testFile.xmf' root = XdmfRoot() dom = XdmfDOM() domain = XdmfDomain() root.SetDOM(dom); root.Build(); root.Insert(domain); grid = XdmfGrid() grid.SetName("INT64 Polyvertex") assert(grid.GetName() == "INT64 Polyvertex") geom = grid.GetGeometry() geom.SetLightDataLimit(0) assert(geom.GetLightDataLimit() == 0) geom.SetGeometryType(XDMF_GEOMETRY_XYZ) assert(geom.GetGeometryType() == Xdmf.XDMF_GEOMETRY_XYZ) geom.SetNumberOfPoints(3) assert(geom.GetNumberOfPoints() == 3) points = geom.GetPoints() points.SetHeavyDataSetName(heavyDataSetName + ":/" + grid.GetName() + "/XYZ") assert(points.GetHeavyDataSetName() == (heavyDataSetName + ":/" + grid.GetName() + "/XYZ")) points.SetNumberType(XDMF_INT64_TYPE) assert(points.GetNumberType() == Xdmf.XDMF_INT64_TYPE) points.SetNumberOfElements(9) assert(points.GetNumberOfElements() == 9) points.SetValueFromInt64(0, 9223372036854775807) points.SetValueFromInt64(1, 9223372036854775807) points.SetValueFromInt64(2, 9223372036854775807) points.SetValueFromInt64(3, -9223372036854775808) points.SetValueFromInt64(4, -9223372036854775808) points.SetValueFromInt64(5, -9223372036854775808) points.SetValueFromInt64(6, 0) points.SetValueFromInt64(7, 0) points.SetValueFromInt64(8, 0) assert(points.GetValueAsInt64(0) == 9223372036854775807) assert(points.GetValueAsInt64(3) == -9223372036854775808) assert(points.GetValueAsInt64(6) == 0) top = grid.GetTopology() top.SetTopologyType(XDMF_POLYVERTEX) assert(top.GetTopologyType() == Xdmf.XDMF_POLYVERTEX) top.SetNumberOfElements(3) assert(top.GetNumberOfElements() == 3) domain.Insert(grid) grid.Build() attr1 = XdmfAttribute() attr1.SetName("Scalar UINT8") attr1.SetAttributeCenter(XDMF_ATTRIBUTE_CENTER_NODE) attr1.SetAttributeType(XDMF_ATTRIBUTE_TYPE_SCALAR) attr1.SetLightDataLimit(0) attr1.GetValues().SetHeavyDataSetName(heavyDataSetName + ":/" + grid.GetName() + "/" + attr1.GetName()) attr1.GetValues().SetNumberType(XDMF_UINT8_TYPE) attr1.GetValues().SetNumberOfElements(3) attr1.GetValues().SetValueFromInt64(0, 255) attr1.GetValues().SetValueFromInt64(1, 0) attr1.GetValues().SetValueFromInt64(2, 50) attr2 = XdmfAttribute() attr2.SetName("Vector UINT16") attr2.SetAttributeCenter(XDMF_ATTRIBUTE_CENTER_NODE) attr2.SetAttributeType(XDMF_ATTRIBUTE_TYPE_VECTOR) attr2.SetLightDataLimit(0) attr2.GetValues().SetHeavyDataSetName(heavyDataSetName + ":/" + grid.GetName() + "/" + attr2.GetName()) attr2.GetValues().SetNumberType(XDMF_UINT16_TYPE) attr2.GetValues().SetNumberOfElements(9) attr2.GetValues().SetValueFromInt64(0, 65535) attr2.GetValues().SetValueFromInt64(1, 65535) attr2.GetValues().SetValueFromInt64(2, 65535) attr2.GetValues().SetValueFromInt64(3, 0) attr2.GetValues().SetValueFromInt64(4, 0) attr2.GetValues().SetValueFromInt64(5, 0) attr2.GetValues().SetValueFromInt64(6, 100) attr2.GetValues().SetValueFromInt64(7, 100) attr2.GetValues().SetValueFromInt64(8, 100) attr3 = XdmfAttribute() attr3.SetName("Tensor UINT32") attr3.SetAttributeCenter(XDMF_ATTRIBUTE_CENTER_NODE) attr3.SetAttributeType(XDMF_ATTRIBUTE_TYPE_TENSOR) attr3.SetLightDataLimit(0) attr3.GetValues().SetHeavyDataSetName(heavyDataSetName + ":/" + grid.GetName() + "/" + attr3.GetName()) attr3.GetValues().SetNumberType(XDMF_UINT32_TYPE) attr3.GetValues().SetNumberOfElements(27) attr3.GetValues().SetValueFromInt64(0, 4294967295) attr3.GetValues().SetValueFromInt64(1, 4294967295) attr3.GetValues().SetValueFromInt64(2, 0) attr3.GetValues().SetValueFromInt64(3, 50) attr3.GetValues().SetValueFromInt64(4, 100) attr3.GetValues().SetValueFromInt64(5, 200) attr3.GetValues().SetValueFromInt64(6, 500) attr3.GetValues().SetValueFromInt64(7, 1000) attr3.GetValues().SetValueFromInt64(8, 1000) attr3.GetValues().SetValueFromInt64(9, 1000) attr3.GetValues().SetValueFromInt64(10, 1000) attr3.GetValues().SetValueFromInt64(11, 500) attr3.GetValues().SetValueFromInt64(12, 200) attr3.GetValues().SetValueFromInt64(13, 100) attr3.GetValues().SetValueFromInt64(14, 50) attr3.GetValues().SetValueFromInt64(15, 0) attr3.GetValues().SetValueFromInt64(16, 4294967295) attr3.GetValues().SetValueFromInt64(17, 4294967295) attr3.GetValues().SetValueFromInt64(18, 4294967295) attr3.GetValues().SetValueFromInt64(19, 4294967295) attr3.GetValues().SetValueFromInt64(20, 0) attr3.GetValues().SetValueFromInt64(21, 50) attr3.GetValues().SetValueFromInt64(22, 100) attr3.GetValues().SetValueFromInt64(23, 200) attr3.GetValues().SetValueFromInt64(24, 500) attr3.GetValues().SetValueFromInt64(25, 1000) attr3.GetValues().SetValueFromInt64(26, 1000) attr4 = XdmfAttribute() attr4.SetName("Scalar INT8") attr4.SetAttributeCenter(XDMF_ATTRIBUTE_CENTER_GRID) attr4.SetAttributeType(XDMF_ATTRIBUTE_TYPE_SCALAR) attr4.SetLightDataLimit(0) attr4.GetValues().SetHeavyDataSetName(heavyDataSetName + ":/" + grid.GetName() + "/" + attr4.GetName()) attr4.GetValues().SetNumberType(XDMF_INT8_TYPE) attr4.GetValues().SetNumberOfElements(1) attr4.GetValues().SetValueFromInt64(0, 127) grid.Insert(attr1) grid.Insert(attr2) grid.Insert(attr3) grid.Insert(attr4) grid.Build() assert(grid.GetAttribute(0).GetName() == attr1.GetName()) assert(grid.GetAttribute(0).GetValues().GetValueAsInt64(2) == 50) grid2 = XdmfGrid() grid2.SetName("FLOAT64 Quadrilateral") geom = grid2.GetGeometry() geom.SetGeometryType(XDMF_GEOMETRY_XY) geom.SetNumberOfPoints(4) geom.SetLightDataLimit(0) points = geom.GetPoints() points.SetHeavyDataSetName(heavyDataSetName + ":/" + grid2.GetName() + "/XYZ") points.SetNumberType(XDMF_FLOAT64_TYPE) points.SetNumberOfElements(8) points.SetValueFromFloat64(0, -1000.5) points.SetValueFromFloat64(1, 0) points.SetValueFromFloat64(2, 0) points.SetValueFromFloat64(3, -500.25) points.SetValueFromFloat64(4, 1000.5) points.SetValueFromFloat64(5, 0) points.SetValueFromFloat64(6, 0) points.SetValueFromFloat64(7, 2196.99) top = grid2.GetTopology() top.SetTopologyType(XDMF_QUAD) top.SetNumberOfElements(1) top.SetLightDataLimit(0) top.GetConnectivity().SetHeavyDataSetName(heavyDataSetName + ":/" + grid2.GetName() + "/Connections") top.GetConnectivity().SetNumberType(XDMF_INT32_TYPE) top.GetConnectivity().SetNumberOfElements(4) top.GetConnectivity().SetValueFromInt64(0, 0) top.GetConnectivity().SetValueFromInt64(1, 1) top.GetConnectivity().SetValueFromInt64(2, 2) top.GetConnectivity().SetValueFromInt64(3, 3) domain.Insert(grid2) grid2.Build() attr5 = XdmfAttribute() attr5.SetName("Vector INT16") attr5.SetAttributeCenter(XDMF_ATTRIBUTE_CENTER_GRID) attr5.SetAttributeType(XDMF_ATTRIBUTE_TYPE_VECTOR) attr5.SetLightDataLimit(0) attr5.GetValues().SetHeavyDataSetName(heavyDataSetName + ":/" + grid2.GetName() + "/" + attr5.GetName()) attr5.GetValues().SetNumberType(XDMF_INT16_TYPE) attr5.GetValues().SetNumberOfElements(3) attr5.GetValues().SetValueFromInt64(0, 32767) attr5.GetValues().SetValueFromInt64(1, -32768) attr5.GetValues().SetValueFromInt64(2, 0) attr6 = XdmfAttribute() attr6.SetName("Tensor INT32") attr6.SetAttributeCenter(XDMF_ATTRIBUTE_CENTER_GRID) attr6.SetAttributeType(XDMF_ATTRIBUTE_TYPE_TENSOR) attr6.SetLightDataLimit(0) attr6.GetValues().SetHeavyDataSetName(heavyDataSetName + ":/" + grid2.GetName() + "/" + attr6.GetName()) attr6.GetValues().SetNumberType(XDMF_INT32_TYPE) attr6.GetValues().SetNumberOfElements(9) attr6.GetValues().SetValueFromInt64(0, 2147483647) attr6.GetValues().SetValueFromInt64(1, 2147483647) attr6.GetValues().SetValueFromInt64(2, 2147483647) attr6.GetValues().SetValueFromInt64(3, -2147483648) attr6.GetValues().SetValueFromInt64(4, -2147483648) attr6.GetValues().SetValueFromInt64(5, -2147483648) attr6.GetValues().SetValueFromInt64(6, 0) attr6.GetValues().SetValueFromInt64(7, 0) attr6.GetValues().SetValueFromInt64(8, 0) attr7 = XdmfAttribute() attr7.SetName("Scalar INT64") attr7.SetAttributeCenter(XDMF_ATTRIBUTE_CENTER_CELL) attr7.SetAttributeType(XDMF_ATTRIBUTE_TYPE_SCALAR) attr7.SetLightDataLimit(0) attr7.GetValues().SetHeavyDataSetName(heavyDataSetName + ":/" + grid2.GetName() + "/" + attr7.GetName()) attr7.GetValues().SetNumberType(XDMF_INT64_TYPE) attr7.GetValues().SetNumberOfElements(1) attr7.GetValues().SetValueFromInt64(0, 9223372036854775807) attr8 = XdmfAttribute() attr8.SetName("Vector FLOAT32") attr8.SetAttributeCenter(XDMF_ATTRIBUTE_CENTER_CELL) attr8.SetAttributeType(XDMF_ATTRIBUTE_TYPE_VECTOR) attr8.SetLightDataLimit(0) attr8.GetValues().SetHeavyDataSetName(heavyDataSetName + ":/" + grid2.GetName() + "/" + attr8.GetName()) attr8.GetValues().SetNumberType(XDMF_FLOAT32_TYPE) attr8.GetValues().SetNumberOfElements(3) attr8.GetValues().SetValueFromFloat64(0, 0) attr8.GetValues().SetValueFromFloat64(1, -100.525) attr8.GetValues().SetValueFromFloat64(2, 1000.69) attr9 = XdmfAttribute() attr9.SetName("Tensor FLOAT64") attr9.SetAttributeCenter(XDMF_ATTRIBUTE_CENTER_CELL) attr9.SetAttributeType(XDMF_ATTRIBUTE_TYPE_TENSOR) attr9.SetLightDataLimit(0) attr9.GetValues().SetHeavyDataSetName(heavyDataSetName + ":/" + grid2.GetName() + "/" + attr9.GetName()) attr9.GetValues().SetNumberType(XDMF_FLOAT64_TYPE) attr9.GetValues().SetNumberOfElements(9) attr9.GetValues().SetValueFromFloat64(0, 0) attr9.GetValues().SetValueFromFloat64(1, -1000) attr9.GetValues().SetValueFromFloat64(2, 1000) attr9.GetValues().SetValueFromFloat64(3, .005) attr9.GetValues().SetValueFromFloat64(4, -.005) attr9.GetValues().SetValueFromFloat64(5, .5) attr9.GetValues().SetValueFromFloat64(6, 100.99) attr9.GetValues().SetValueFromFloat64(7, 1000.9) attr9.GetValues().SetValueFromFloat64(8, -1000.9) grid2.Insert(attr5) grid2.Insert(attr6) grid2.Insert(attr7) grid2.Insert(attr8) grid2.Insert(attr9) grid2.Build() dom.Write(outputName)xdmf-3.0+git20160803/libsrc/test/TestXdmfArray.cc0000640000175000017500000000426113003006557021376 0ustar alastairalastair/* Author: Kenneth Leiter E-mail: kenneth.leiter@us.army.mil Writes values to XdmfArrays and then tries to read them. Compares the values for equality and tests the accuracy of some convenience functions. */ #include #include int main( int argc, const char* argv[] ) { XdmfArray * intArray = new XdmfArray(); intArray->SetNumberType(XDMF_INT64_TYPE); if (strcmp(intArray->GetNumberTypeAsString(), "XDMF_INT64_TYPE") != 0) return -1; intArray->SetShapeFromString("3 3"); if (strcmp(intArray->GetShapeAsString(), "3 3") != 0) return -1; if (intArray->GetNumberOfElements() != 9) return -1; long toWrite [9] = {0, 1, 3, 4, 500, -5000, 500000, 9223372036854775807, -9223372036854775807}; for (int i=0; i<9; i++) { intArray->SetValueFromInt64(i,toWrite[i]); } for (int i=0; i<9; i++) { if(intArray->GetValueAsInt64(i) != toWrite[i]) return -1; } if (intArray->GetMaxAsInt64() != 9223372036854775807) return -1; if (intArray->GetMinAsInt64() != -9223372036854775807) return -1; delete intArray; XdmfArray * floatArray = new XdmfArray(); floatArray->SetNumberType(XDMF_FLOAT64_TYPE); if (floatArray->GetNumberType() != XDMF_FLOAT64_TYPE) return -1; floatArray->SetShapeFromString("2 2 2"); if (strcmp(floatArray->GetShapeAsString(), "2 2 2") != 0) return -1; if (floatArray->GetNumberOfElements() != 8) return -1; double floatToWrite [8] = {0, -1, 1100.256, 1.1, 1000.50 , 5.6234567, -60.2, 60.25659}; floatArray->SetValues(0, floatToWrite, 8, 1, 1); for (int i=0; i<8; i++) { if(floatArray->GetValueAsFloat64(i) != floatToWrite[i]) return -1; } if (floatArray->GetMaxAsFloat64() != 1100.256) return -1; if (floatArray->GetMinAsFloat64() != -60.2) return -1; delete floatArray; XdmfArray * opArray = new XdmfArray(); opArray->SetNumberType(XDMF_INT32_TYPE); if (strcmp(opArray->GetNumberTypeAsString(), "XDMF_INT32_TYPE") != 0) return -1; opArray->SetNumberOfElements(10); if (strcmp(opArray->GetShapeAsString(), "10") != 0) return -1; if (opArray->GetNumberOfElements() != 10) return -1; opArray->Generate(0, 9); for (int i=0; iGetNumberOfElements(); i++) { if(opArray->GetValueAsInt32(i) != i) return -1; } delete opArray; return 0; } xdmf-3.0+git20160803/libsrc/DocFooter.html0000740000175000017500000000056113003006557020125 0ustar alastairalastair
eXtensible Data Model and Format xdmf-3.0+git20160803/libsrc/XdmfDsmMsg.h0000640000175000017500000000504113003006557017532 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : $Id: XdmfDsmMsg.h,v 1.5 2009-09-17 14:12:11 clarke Exp $ */ /* Date : $Date $ */ /* Version : $Revision $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2007 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #ifndef __XdmfDsmMsg_h #define __XdmfDsmMsg_h #include "XdmfObject.h" //! Base comm message object for Distributed Shared Memory implementation /*! */ #define XDMF_DSM_DEFAULT_TAG 0x80 #define XDMF_DSM_COMMAND_TAG 0x81 #define XDMF_DSM_RESPONSE_TAG 0x82 #define XDMF_DSM_ANY_SOURCE -1 class XDMF_EXPORT XdmfDsmMsg : public XdmfObject { public : XdmfDsmMsg(); ~XdmfDsmMsg(); XdmfSetValueMacro(Source, XdmfInt32); XdmfGetValueMacro(Source, XdmfInt32); XdmfSetValueMacro(Dest, XdmfInt32); XdmfGetValueMacro(Dest, XdmfInt32); XdmfSetValueMacro(Tag, XdmfInt32); XdmfGetValueMacro(Tag, XdmfInt32); XdmfSetValueMacro(Length, XdmfInt64); XdmfGetValueMacro(Length, XdmfInt64); XdmfSetValueMacro(Data, void *); XdmfGetValueMacro(Data, void *); XdmfInt32 Source; XdmfInt32 Dest; XdmfInt32 Tag; XdmfInt64 Length; void *Data; }; #endif // __XdmfDsmMsg_h xdmf-3.0+git20160803/libsrc/XdmfConfig.h.in0000740000175000017500000000707113003006557020160 0ustar alastairalastair#ifndef __XdmfConfig_h #define __XdmfConfig_h /* * This is a support for files on the disk that are larger than 2GB. * Since this is the first place that any include should happen, do this here. */ #cmakedefine XDMF_REQUIRE_LARGE_FILE_SUPPORT #ifdef XDMF_REQUIRE_LARGE_FILE_SUPPORT # ifndef _LARGEFILE_SOURCE # define _LARGEFILE_SOURCE # endif # ifndef _LARGEFILE64_SOURCE # define _LARGEFILE64_SOURCE # endif # ifndef _LARGE_FILES # define _LARGE_FILES # endif # ifndef _FILE_OFFSET_BITS # define _FILE_OFFSET_BITS 64 # endif #endif /* Eliminate IceConfig.h. Create Definitions Here */ #cmakedefine CMAKE_WORDS_BIGENDIAN #ifdef CMAKE_WORDS_BIGENDIAN #define XDMF_WORDS_BIGENDIAN #define XDMF_BYTE_ORDER_BIG #else #define XDMF_WORDS_LITTLEENDIAN #define XDMF_BYTE_ORDER_LITTLE #endif #define XDMF_SYSTEM ${CMAKE_SYSTEM} #cmakedefine XDMF_VOID_VALID #ifndef XDMF_VOID_VALID /* Force an Error */ #error XDMF_VOID not defined #endif #define XDMF_VOID @XDMF_VOID@ #cmakedefine XDMF_PTR_VALID #ifndef XDMF_PTR_VALID /* Force an Error */ #error XDMF_PTR not defined #endif #define XDMF_PTR @XDMF_PTR@ #cmakedefine XDMF_CHAR_VALID #ifndef XDMF_CHAR_VALID /* Force an Error */ #error XDMF_CHAR not defined #endif #define XDMF_CHAR @XDMF_CHAR@ #cmakedefine XDMF_8_INT_VALID #ifndef XDMF_8_INT_VALID /* Force an Error */ #error XDMF_8_INT not defined #endif #define XDMF_8_INT @XDMF_8_INT@ #define XDMF_8_U_INT @XDMF_8_U_INT@ #cmakedefine XDMF_16_INT_VALID #ifndef XDMF_16_INT_VALID /* Force an Error */ #error XDMF_16_INT not defined #endif #define XDMF_16_INT @XDMF_16_INT@ #define XDMF_16_U_INT @XDMF_16_U_INT@ #cmakedefine XDMF_32_INT_VALID #ifndef XDMF_32_INT_VALID /* Force an Error */ #error XDMF_32_INT not defined #endif #define XDMF_32_INT @XDMF_32_INT@ #define XDMF_32_U_INT @XDMF_32_U_INT@ #define XDMF_32_S_INT @XDMF_32_S_INT@ #cmakedefine XDMF_32_FLOAT_VALID #ifndef XDMF_32_FLOAT_VALID /* Force an Error */ #error XDMF_32_FLOAT not defined #endif #define XDMF_32_FLOAT @XDMF_32_FLOAT@ #define XDMF_FLOAT @XDMF_32_FLOAT@ #cmakedefine XDMF_64_FLOAT_VALID #ifndef XDMF_64_FLOAT_VALID /* Force an Error */ #error XDMF_64_FLOAT not defined #endif #define XDMF_64_FLOAT @XDMF_64_FLOAT@ #define XDMF_DOUBLE @XDMF_64_FLOAT@ #ifndef SIZEOF___INT64 #cmakedefine SIZEOF___INT64 #endif #cmakedefine HAVE_STRTOLL #ifndef SIZEOF_LONG_LONG #cmakedefine SIZEOF_LONG_LONG @SIZEOF_LONG_LONG@ #endif #if defined( SIZEOF_LONG_LONG ) # define XDMF_64_INT long long # define HAVE_64_INT # define XDMF_have_64_bit_int #elif defined( SIZEOF___INT64 ) # define XDMF_64_INT __int64 # define HAVE_64_INT #else # error "64 bit long not defined" #endif #cmakedefine XDMF_HAVE_64BIT_STREAMS #ifdef XDMF_HAVE_64BIT_STREAMS #define XDMF_64BIT_CAST #else #define XDMF_64BIT_CAST (long) #endif #cmakedefine XDMF_HAVE_FCNTL #cmakedefine XDMF_HAVE_NETINET #cmakedefine XDMF_HAVE_MMAN #cmakedefine XDMF_USE_ANSI_STDLIB #cmakedefine XDMF_NO_STD_NAMESPACE #cmakedefine XDMF_SYSTEM_HDF5 #ifndef SIZEOF___INT64 #cmakedefine SIZEOF___INT64 #endif #if defined( SIZEOF___INT64 ) # define XDMF_LONG64 __int64 #elif defined( SIZEOF_LONG_LONG ) # define XDMF_LONG64 long long #else # error "64 bit long not defined" #endif #cmakedefine BUILD_SHARED_LIBS #ifndef BUILD_SHARED_LIBS # define XDMFSTATIC #endif #cmakedefine HAVE_NDGM #cmakedefine XDMF_HAVE_MALLOC_H #cmakedefine XDMF_BUILD_MPI #ifndef XDMF_BUILD_MPI #ifndef XDMF_NO_MPI #define XDMF_NO_MPI #endif #endif #cmakedefine Xdmf_EXPORTS #ifndef Xdmf_EXPORTS # define Xdmf_EXPORTS #endif #endif /* __XdmfConfig_h */ xdmf-3.0+git20160803/libsrc/Xdmf.dtd0000640000175000017500000000463313003006557016751 0ustar alastairalastair xdmf-3.0+git20160803/libsrc/XdmfDsmCommMpi.cxx0000640000175000017500000001213413003006557020721 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : $Id: XdmfDsmCommMpi.cxx,v 1.9 2009-09-07 14:46:08 biddisco Exp $ */ /* Date : $Date: 2009-09-07 14:46:08 $ */ /* Version : $Revision: 1.9 $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2007 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #include "XdmfDsmCommMpi.h" #include "XdmfDsmMsg.h" XdmfDsmCommMpi::XdmfDsmCommMpi() { this->Comm = MPI_COMM_WORLD; } XdmfDsmCommMpi::~XdmfDsmCommMpi() { } XdmfInt32 XdmfDsmCommMpi::DupComm(MPI_Comm Source){ MPI_Comm NewComm; MPI_Comm_dup(Source, &NewComm); return(this->SetComm(NewComm)); } XdmfInt32 XdmfDsmCommMpi::Init(){ int size, rank; if(MPI_Comm_size(this->Comm, &size) != MPI_SUCCESS) return(XDMF_FAIL); if(MPI_Comm_rank(this->Comm, &rank) != MPI_SUCCESS) return(XDMF_FAIL); this->SetId(rank); this->SetTotalSize(size); return(XDMF_SUCCESS); } XdmfInt32 XdmfDsmCommMpi::Check(XdmfDsmMsg *Msg){ int nid, flag=0; MPI_Status Status; if(XdmfDsmComm::Check(Msg) != XDMF_SUCCESS) return(XDMF_FAIL); MPI_Iprobe(MPI_ANY_SOURCE, Msg->Tag, this->Comm, &flag, &Status); // cout << "MPI_Iprobe " << Msg->Tag << ", " << this->Comm << endl; if(flag){ nid = Status.MPI_SOURCE; Msg->SetSource(nid); return(XDMF_SUCCESS); } return(XDMF_FAIL); } XdmfInt32 XdmfDsmCommMpi::Receive(XdmfDsmMsg *Msg){ int MessageLength; XdmfInt32 status; XdmfInt32 source = MPI_ANY_SOURCE; MPI_Status SendRecvStatus; if(XdmfDsmComm::Receive(Msg) != XDMF_SUCCESS) return(XDMF_FAIL); if(Msg->Source >= 0) source = Msg->Source; XdmfDebug("::::: (" << this->Id << ") Receiving " << Msg->Length << " bytes from " << source << " Tag = " << Msg->Tag); status = MPI_Recv(Msg->Data, Msg->Length, MPI_UNSIGNED_CHAR, source, Msg->Tag, this->Comm, &SendRecvStatus); if(status != MPI_SUCCESS){ XdmfErrorMessage("Id = " << this->Id << " MPI_Recv failed to receive " << Msg->Length << " Bytes from " << Msg->Source); XdmfErrorMessage("MPI Error Code = " << SendRecvStatus.MPI_ERROR); return(XDMF_FAIL); } status = MPI_Get_count(&SendRecvStatus, MPI_UNSIGNED_CHAR, &MessageLength); XdmfDebug("::::: (" << this->Id << ") Received " << MessageLength << " bytes from " << SendRecvStatus.MPI_SOURCE); /* if(this->Id == 0){ cout << "::::: (" << this->Id << ") Received " << MessageLength << " bytes from " << SendRecvStatus.MPI_SOURCE << endl; cout << "::::: (" << this->Id << ") Expected Length = " << Msg->Length << endl; } */ Msg->SetSource(SendRecvStatus.MPI_SOURCE); Msg->SetLength(MessageLength); if(status != MPI_SUCCESS){ XdmfErrorMessage("MPI_Get_count failed "); return(XDMF_FAIL); } return(XDMF_SUCCESS); } XdmfInt32 XdmfDsmCommMpi::Send(XdmfDsmMsg *Msg){ XdmfInt32 status; if(XdmfDsmComm::Send(Msg) != XDMF_SUCCESS) return(XDMF_FAIL); XdmfDebug("::::: (" << this->Id << ") Sending " << Msg->Length << " bytes to " << Msg->Dest << " Tag = " << Msg->Tag); /* if(this->Id == 1){ cout << "::::: (" << this->Id << ") Sending " << Msg->Length << " bytes to " << Msg->Dest << " Tag = " << Msg->Tag << endl; } */ status = MPI_Send(Msg->Data, Msg->Length, MPI_UNSIGNED_CHAR, Msg->Dest, Msg->Tag, this->Comm); // status = MPI_Ssend(Msg->Data, Msg->Length, MPI_UNSIGNED_CHAR, Msg->Dest, Msg->Tag, this->Comm); if(status != MPI_SUCCESS){ XdmfErrorMessage("Id = " << this->Id << " MPI_Send failed to send " << Msg->Length << " Bytes to " << Msg->Dest); return(XDMF_FAIL); } XdmfDebug("::::: (" << this->Id << ") Sent " << Msg->Length << " bytes to " << Msg->Dest); return(XDMF_SUCCESS); } XdmfInt32 XdmfDsmCommMpi::Barrier() { MPI_Barrier(this->Comm); return XDMF_SUCCESS; } xdmf-3.0+git20160803/libsrc/XdmfValues.h0000640000175000017500000000574013003006557017605 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Values */ /* */ /* Id : $Id: XdmfValues.h,v 1.6 2009-01-23 20:31:39 clarke Exp $ */ /* Date : $Date: 2009-01-23 20:31:39 $ */ /* Version : $Revision: 1.6 $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2002 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #ifndef __XdmfValues_h #define __XdmfValues_h #include "XdmfDataItem.h" class XdmfArray; //! Parent Class for handeling I/O of actual data for an XdmfDataItem /*! This is the base class for access of values. By default, the Values are in XML and handled XdmfValuesXML. Otherwise they're handled by XdmfValuesXXX (where XXX is the format). An XdmfDataItem Node Looks like : \verbatim 1.1 3.3 5.5 7.7 9.9 11 13.1 15 OR MyData.h5:/AllValues/ThisArray \endverbatim XdmfValues is used to access the "1.1 3.3 5.5 7.7 9.9 11 13.1 15" part wheather it's in the XML or in a file described in the XML. This class is overreidden for various formats supported by Xdmf (i.e. XML, HDF5, etc.) */ class XDMF_EXPORT XdmfValues : public XdmfDataItem{ public : XdmfValues(); virtual ~XdmfValues(); XdmfConstString GetClassName() { return("XdmfValues"); } ; //! Set DOM and Element from another XdmfDataItem XdmfInt32 Inherit(XdmfDataItem *DataItem); //! Read the Array from the External Representation virtual XdmfArray *Read(XdmfArray *Array=NULL); //! Write the Array to the External Representation virtual XdmfInt32 Write(XdmfArray *Array, XdmfConstString HeavyDataSetName=NULL); protected : }; #endif xdmf-3.0+git20160803/libsrc/gzstream.h0000640000175000017500000001153613003006557017363 0ustar alastairalastair// ============================================================================ // gzstream, C++ iostream classes wrapping the zlib compression library. // Copyright (C) 2001 Deepak Bandyopadhyay, Lutz Kettner // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // ============================================================================ // // File : gzstream.h // Revision : $Revision: 1.2 $ // Revision_date : $Date: 2009-09-03 18:28:38 $ // Author(s) : Deepak Bandyopadhyay, Lutz Kettner // // Standard streambuf implementation following Nicolai Josuttis, "The // Standard C++ Library". // // ============================================================================ // Modifications: Dominik Szczerba 2006 // added is_open() to igzstream and ogzstream // ============================================================================ #ifndef GZSTREAM_H #define GZSTREAM_H 1 // standard C++ with new header file names and std:: namespace #include #include #ifdef XDMF_USE_VTK_ZLIB #include "vtkzlib/zlib.h" #else #include #endif #ifdef GZSTREAM_NAMESPACE namespace GZSTREAM_NAMESPACE { #endif // ---------------------------------------------------------------------------- // Internal classes to implement gzstream. See below for user classes. // ---------------------------------------------------------------------------- class gzstreambuf : public std::streambuf { private: static const int bufferSize = 47+256; // size of data buff // totals 512 bytes under g++ for igzstream at the end. gzFile file; // file handle for compressed file char buffer[bufferSize]; // data buffer char opened; // open/close state of stream int mode; // I/O mode int flush_buffer(); public: gzstreambuf() : opened(0) { setp( buffer, buffer + (bufferSize-1)); setg( buffer + 4, // beginning of putback area buffer + 4, // read position buffer + 4); // end position // ASSERT: both input & output capabilities will not be used together } int is_open() { return opened; } gzstreambuf* open( const char* name, int open_mode); gzstreambuf* close(); ~gzstreambuf() { close(); } virtual int overflow( int c = EOF); virtual int underflow(); virtual int sync(); }; class gzstreambase : virtual public std::ios { protected: gzstreambuf buf; public: gzstreambase() { init(&buf); } gzstreambase( const char* name, int open_mode); ~gzstreambase(); void open( const char* name, int open_mode); void close(); gzstreambuf* rdbuf() { return &buf; } }; // ---------------------------------------------------------------------------- // User classes. Use igzstream and ogzstream analogously to ifstream and // ofstream respectively. They read and write files based on the gz* // function interface of the zlib. Files are compatible with gzip compression. // ---------------------------------------------------------------------------- class igzstream : public gzstreambase, public std::istream { public: igzstream() : std::istream( &buf) {} igzstream( const char* name, int open_mode = std::ios::in) : gzstreambase( name, open_mode), std::istream( &buf) {} gzstreambuf* rdbuf() { return gzstreambase::rdbuf(); } void open( const char* name, int open_mode = std::ios::in) { gzstreambase::open( name, open_mode); } bool is_open(){return buf.is_open();}; }; class ogzstream : public gzstreambase, public std::ostream { public: ogzstream() : std::ostream( &buf) {} ogzstream( const char* name, int mode = std::ios::out) : gzstreambase( name, mode), std::ostream( &buf) {} gzstreambuf* rdbuf() { return gzstreambase::rdbuf(); } void open( const char* name, int open_mode = std::ios::out) { gzstreambase::open( name, open_mode); } bool is_open(){return buf.is_open();}; }; #ifdef GZSTREAM_NAMESPACE } // namespace GZSTREAM_NAMESPACE #endif #endif // GZSTREAM_H // ============================================================================ // EOF // xdmf-3.0+git20160803/libsrc/CMakeEmptyInputFile.in0000640000175000017500000000004113003006557021512 0ustar alastairalastair@CMAKE_EMPTY_INPUT_FILE_CONTENT@ xdmf-3.0+git20160803/libsrc/DocHeader.html0000740000175000017500000000113713003006557020057 0ustar alastairalastair eXtensible Data Model and Format xdmf-3.0+git20160803/libsrc/Xdmf.h0000640000175000017500000000473313003006557016426 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : $Id: Xdmf.h,v 1.6 2010-01-06 16:34:07 kwleiter Exp $ */ /* Date : $Date: 2010-01-06 16:34:07 $ */ /* Version : $Revision: 1.6 $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2007 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #include "XdmfArray.h" #include "XdmfAttribute.h" #include "XdmfDataDesc.h" #include "XdmfDataItem.h" #include "XdmfDataStructure.h" #include "XdmfDataTransform.h" #include "XdmfDomain.h" #include "XdmfDOM.h" #include "XdmfDsm.h" #include "XdmfDsmBuffer.h" #include "XdmfDsmComm.h" #include "XdmfDsmMsg.h" #ifndef XDMF_NO_MPI #include "XdmfDsmCommMpi.h" #endif /* XDMF_NO_MPI */ #include "XdmfElement.h" #include "XdmfExpression.h" #include "XdmfGeometry.h" #include "XdmfGrid.h" #include "XdmfTime.h" #include "XdmfHDF.h" #include "XdmfHeavyData.h" #include "XdmfInformation.h" #include "XdmfLightData.h" #include "XdmfMap.h" #include "XdmfObject.h" #include "XdmfRegion.h" #include "XdmfRoot.h" #include "XdmfSet.h" #include "XdmfTopology.h" #include "XdmfValues.h" #include "XdmfValuesBinary.h" #include "XdmfValuesHDF.h" #ifdef XDMF_USE_MYSQL #include "XdmfValuesMySQL.h" #endif #include "XdmfValuesXML.h" xdmf-3.0+git20160803/libsrc/XdmfDsmCommMpi.h0000640000175000017500000000474413003006557020356 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : $Id: XdmfDsmCommMpi.h,v 1.5 2009-09-07 14:46:08 biddisco Exp $ */ /* Date : $Date: 2009-09-07 14:46:08 $ */ /* Version : $Revision: 1.5 $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2007 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #ifndef __XdmfDsmCommMpi_h #define __XdmfDsmCommMpi_h #include "XdmfDsmComm.h" #ifndef XDMF_NO_MPI #ifndef SWIG #include #endif // SWIG #else // XDMF_NO_MPI typedef int MPI_Comm; #endif // XDMF_NO_MPI //! Base comm object for Distributed Shared Memory implementation /*! */ class XDMF_EXPORT XdmfDsmCommMpi : public XdmfDsmComm { public: XdmfDsmCommMpi(); ~XdmfDsmCommMpi(); XdmfConstString GetClassName() { return ( "XdmfDsmCommMpi" ) ; }; #ifndef SWIG //! Set the MPI Communicator XdmfSetValueMacro(Comm, MPI_Comm); //! Get the MPI Communicator XdmfGetValueMacro(Comm, MPI_Comm); XdmfInt32 DupComm(MPI_Comm Source); #endif XdmfInt32 Init(); XdmfInt32 Send(XdmfDsmMsg *Msg); XdmfInt32 Receive(XdmfDsmMsg *Msg); XdmfInt32 Check(XdmfDsmMsg *Msg); XdmfInt32 Barrier(); protected: MPI_Comm Comm; }; #endif // __XdmfDsmCommMpi_h xdmf-3.0+git20160803/libsrc/XdmfDsmBuffer.h0000640000175000017500000000542713003006557020225 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : $Id: XdmfDsmBuffer.h,v 1.11 2009-09-17 14:12:11 clarke Exp $ */ /* Date : $Date: 2009-09-17 14:12:11 $ */ /* Version : $Revision: 1.11 $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2007 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #ifndef __XdmfDsmBuffer_h #define __XdmfDsmBuffer_h #include "XdmfDsm.h" #define XDMF_DSM_MAX_LOCKS 32 //! Helper for pthread_create() extern "C" { XDMF_EXPORT void * XdmfDsmBufferServiceThread(void *DsmObj); } //! Base comm object for Distributed Shared Memory implementation /*! */ class XDMF_EXPORT XdmfDsmBuffer : public XdmfDsm { public: XdmfDsmBuffer(); virtual ~XdmfDsmBuffer(); XdmfConstString GetClassName() { return ( "XdmfDsmBuffer" ) ; }; XdmfGetValueMacro(ThreadDsmReady, XdmfInt32); XdmfSetValueMacro(ThreadDsmReady, XdmfInt32); XdmfInt32 Put(XdmfInt64 Address, XdmfInt64 Length, void *Data); XdmfInt32 Get(XdmfInt64 Address, XdmfInt64 Length, void *Data); XdmfInt32 Aquire(XdmfInt64 Index); XdmfInt32 Release(XdmfInt64 Index); /* XdmfInt32 Copy(XdmfDsmBuffer *Source); */ XdmfInt32 ServiceInit(); XdmfInt32 ServiceOnce(XdmfInt32 *ReturnOpcode=0); XdmfInt32 ServiceUntilIdle(XdmfInt32 *ReturnOpcode=0); XdmfInt32 ServiceLoop(XdmfInt32 *ReturnOpcode=0); XdmfInt32 Service(XdmfInt32 *ReturnOpcode=0); void * ServiceThread(); protected: XdmfInt32 ThreadDsmReady; }; #endif // __XdmfDsmBuffer_h xdmf-3.0+git20160803/libsrc/XdmfDataTransform.h0000640000175000017500000000515713003006557021115 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Values */ /* */ /* Id : $Id: XdmfDataTransform.h,v 1.2 2009-01-23 20:31:39 clarke Exp $ */ /* Date : $Date: 2009-01-23 20:31:39 $ */ /* Version : $Revision: 1.2 $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2002 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #ifndef __XdmfDataTransform_h #define __XdmfDataTransform_h #include "XdmfDataItem.h" class XdmfArray; //! Data Container Object. /*! XdmfDataTransform is being deprecated !! Use XdmfDataItem !! SELECT * FROM Locations WHERE Time > 0.11
\endverbatim Putting "<" in the CDATA, it may cause an error in the XML parser. Here's an example of using "<" in the CDATA : \verbatim \endverbatim That is you have ti start the CDATA with "". */ class XDMF_EXPORT XdmfValuesMySQL : public XdmfValues { public : XdmfValuesMySQL(); virtual ~XdmfValuesMySQL(); XdmfConstString GetClassName() { return("XdmfValuesMySQL"); } ; //! Read the Array from the External Representation XdmfArray *Read(XdmfArray *Array=NULL); //! Write the Array to the External Representation XdmfInt32 Write(XdmfArray *Array, XdmfConstString HeavyDataSetName=NULL); //! Get the Hostname of the MySQL Server XdmfGetStringMacro(Server); //! Get the Hostname of the MySQL Server XdmfSetStringMacro(Server); //! Get the User Name XdmfGetStringMacro(User); //! Get the User Name XdmfSetStringMacro(User); //! Get the Password XdmfGetStringMacro(Password); //! Get the Password XdmfSetStringMacro(Password); //! Get the DataBase Name XdmfGetStringMacro(DataBase); //! Get the DataBase Name XdmfSetStringMacro(DataBase); //! Get the Query XdmfGetStringMacro(Query); //! Get the Query XdmfSetStringMacro(Query); protected : XdmfString Server; XdmfString User; XdmfString Password; XdmfString DataBase; XdmfString Query; }; #endif xdmf-3.0+git20160803/libsrc/XdmfHDFSupport.cxx0000640000175000017500000001277013003006557020720 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : $Id: XdmfHDFSupport.cxx,v 1.3 2009-05-27 16:52:28 clarke Exp $ */ /* Date : $Date: 2009-05-27 16:52:28 $ */ /* Version : $Revision: 1.3 $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2002 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #include "XdmfHDFSupport.h" XdmfConstString XdmfTypeToClassString( XdmfInt32 XdmfType ) { switch( XdmfType ){ case XDMF_INT8_TYPE : return( "Char"); case XDMF_UINT8_TYPE : return( "UChar"); case XDMF_INT16_TYPE : return( "Short"); case XDMF_UINT16_TYPE : return( "UShort"); case XDMF_UINT32_TYPE : return "UInt"; case XDMF_INT32_TYPE : case XDMF_INT64_TYPE : return( "Int"); case XDMF_FLOAT32_TYPE : case XDMF_FLOAT64_TYPE : return( "Float" ); default : break; } return( "Compound" ); } XdmfInt32 StringToXdmfType( XdmfConstString TypeName ) { if( STRCASECMP( TypeName, "XDMF_UINT8_TYPE" ) == 0 ) return( XDMF_UINT8_TYPE ); if( STRCASECMP( TypeName, "XDMF_UINT16_TYPE" ) == 0 ) return( XDMF_UINT16_TYPE ); if( STRCASECMP( TypeName, "XDMF_UINT32_TYPE" ) == 0 ) return( XDMF_UINT32_TYPE ); if( STRCASECMP( TypeName, "XDMF_INT8_TYPE" ) == 0 ) return( XDMF_INT8_TYPE ); if( STRCASECMP( TypeName, "XDMF_INT16_TYPE" ) == 0 ) return( XDMF_INT16_TYPE ); if( STRCASECMP( TypeName, "XDMF_INT32_TYPE" ) == 0 ) return( XDMF_INT32_TYPE ); if( STRCASECMP( TypeName, "XDMF_INT64_TYPE" ) == 0 ) return( XDMF_INT64_TYPE ); if( STRCASECMP( TypeName, "XDMF_FLOAT32_TYPE" ) == 0 ) return( XDMF_FLOAT32_TYPE ); if( STRCASECMP( TypeName, "XDMF_FLOAT64_TYPE" ) == 0 ) return( XDMF_FLOAT64_TYPE ); if( STRCASECMP( TypeName, "XDMF_COMPOUND_TYPE" ) == 0 ) return( XDMF_COMPOUND_TYPE ); return( XDMF_FAIL ); } XdmfConstString XdmfTypeToString( XdmfInt32 XdmfType ) { switch( XdmfType ){ case XDMF_UINT8_TYPE : return( "XDMF_UINT8_TYPE" ); case XDMF_UINT16_TYPE : return( "XDMF_UINT16_TYPE" ); case XDMF_UINT32_TYPE : return( "XDMF_UINT32_TYPE" ); case XDMF_INT8_TYPE : return( "XDMF_INT8_TYPE" ); case XDMF_INT16_TYPE : return( "XDMF_INT16_TYPE" ); case XDMF_INT32_TYPE : return( "XDMF_INT32_TYPE" ); case XDMF_INT64_TYPE : return( "XDMF_INT64_TYPE"); case XDMF_FLOAT32_TYPE : return( "XDMF_FLOAT32_TYPE" ); case XDMF_FLOAT64_TYPE : return( "XDMF_FLOAT64_TYPE" ); default : break; } return( "XDMF_COMPOUND_TYPE" ); } hid_t XdmfTypeToHDF5Type( XdmfInt32 XdmfType ) { switch( XdmfType ){ case XDMF_UINT8_TYPE : return( H5T_NATIVE_UINT8 ); case XDMF_UINT16_TYPE : return( H5T_NATIVE_UINT16 ); case XDMF_UINT32_TYPE : return( H5T_NATIVE_UINT32 ); case XDMF_INT8_TYPE : return( H5T_NATIVE_INT8 ); case XDMF_INT16_TYPE : return( H5T_NATIVE_INT16 ); case XDMF_INT32_TYPE : return( H5T_NATIVE_INT32 ); case XDMF_INT64_TYPE : return( H5T_NATIVE_INT64 ); case XDMF_FLOAT32_TYPE : return( H5T_NATIVE_FLOAT ); case XDMF_FLOAT64_TYPE : return( H5T_NATIVE_DOUBLE ); default : break; } return( H5T_COMPOUND ); } XdmfInt32 HDF5TypeToXdmfType( hid_t HDF5Type ) { switch( H5Tget_class( HDF5Type ) ) { case H5T_INTEGER : if ( H5Tget_sign(HDF5Type) ) { switch( H5Tget_size( HDF5Type ) ) { case 1 : return( XDMF_INT8_TYPE ); case 2 : return( XDMF_INT16_TYPE ); case 4 : return( XDMF_INT32_TYPE ); case 8 : return( XDMF_INT64_TYPE ); default : break; } } else { switch( H5Tget_size( HDF5Type ) ) { case 1 : return( XDMF_UINT8_TYPE ); case 2 : return( XDMF_UINT16_TYPE ); case 4 : return( XDMF_UINT32_TYPE ); default : break; } } break; case H5T_FLOAT : switch( H5Tget_size( HDF5Type ) ) { case 4 : return( XDMF_FLOAT32_TYPE ); case 8 : return( XDMF_FLOAT64_TYPE ); default : break; } break; default : return( XDMF_COMPOUND_TYPE ); break; } return( XDMF_FAIL ); } xdmf-3.0+git20160803/libsrc/XdmfInformation.h0000640000175000017500000000550313003006557020630 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : $Id: XdmfInformation.h,v 1.10 2009-01-23 20:31:39 clarke Exp $ */ /* Date : $Date: 2009-01-23 20:31:39 $ */ /* Version : $Revision: 1.10 $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2002 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #ifndef __XdmfInformation_h #define __XdmfInformation_h #include "XdmfElement.h" /*! XdmfInformation represents a free form element in XML. It's used to represent Name = Value pairs. Applications that understand the Name can use the Value. Those that don't can ignore the element. Example : \verbatim 0.0 10.0 100.0 110.0 200.0 210.0 XML Element : Information XML Attribute : Name = Any String XML Attribute : Value = Any String \endverbatim If there is a Value= Attribute in the XML it is used. Otherwise the CDATA is used. */ class XDMF_EXPORT XdmfInformation : public XdmfElement { public: XdmfInformation(); virtual ~XdmfInformation(); XdmfConstString GetClassName() { return ( "XdmfInformation" ) ; }; //! Insert an Element XdmfInt32 Insert (XdmfElement *Child); //! Update From XML XdmfInt32 UpdateInformation(); /*! Set the internal value. This is not reflected in the DOM Until Build() is called. */ XdmfSetStringMacro(Value); //! Update the DOM XdmfInt32 Build(); /*! Get the internal Value. */ XdmfGetStringMacro(Value); protected: XdmfString Value; }; #endif // __XdmfInformation_h xdmf-3.0+git20160803/libsrc/CheckCXXSourceRuns.cmake0000640000175000017500000000527113003006557022010 0ustar alastairalastair# - Check if the source code provided in the SOURCE argument compiles. # CHECK_CXX_SOURCE_COMPILES(SOURCE VAR) # - macro which checks if the source code compiles\ # SOURCE - source code to try to compile # VAR - variable to store size if the type exists. # # The following variables may be set before calling this macro to # modify the way the check is run: # # CMAKE_REQUIRED_FLAGS = string of compile command line flags # CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) # CMAKE_REQUIRED_INCLUDES = list of include directories # CMAKE_REQUIRED_LIBRARIES = list of libraries to link MACRO(CHECK_CXX_SOURCE_RUNS SOURCE VAR COMMENT) IF("HAVE_${VAR}" MATCHES "^HAVE_${VAR}$") SET(MACRO_CHECK_FUNCTION_DEFINITIONS "-D${VAR} ${CMAKE_REQUIRED_FLAGS}") IF(CMAKE_REQUIRED_LIBRARIES) SET(CHECK_CXX_SOURCE_COMPILES_ADD_LIBRARIES "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") ELSE(CMAKE_REQUIRED_LIBRARIES) SET(CHECK_CXX_SOURCE_COMPILES_ADD_LIBRARIES) ENDIF(CMAKE_REQUIRED_LIBRARIES) IF(CMAKE_REQUIRED_INCLUDES) SET(CHECK_CXX_SOURCE_COMPILES_ADD_INCLUDES "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}") ELSE(CMAKE_REQUIRED_INCLUDES) SET(CHECK_CXX_SOURCE_COMPILES_ADD_INCLUDES) ENDIF(CMAKE_REQUIRED_INCLUDES) SET(CMAKE_EMPTY_INPUT_FILE_CONTENT "${SOURCE}") CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/CMakeEmptyInputFile.in" "${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/src.cxx") MESSAGE(STATUS "Performing Test ${COMMENT}") TRY_RUN(${VAR} HAVE_${VAR} ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/src.cxx COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} "${CHECK_CXX_SOURCE_COMPILES_ADD_LIBRARIES}" "${CHECK_CXX_SOURCE_COMPILES_ADD_INCLUDES}" OUTPUT_VARIABLE OUTPUT) IF(HAVE_${VAR}) SET(${VAR} 1 CACHE INTERNAL "Test ${COMMENT}") MESSAGE(STATUS "Performing Test ${COMMENT} - Success") FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeOutput.log "Performing C++ SOURCE FILE Test ${COMMENT} succeded with the following output:\n" "${OUTPUT}\n" "Source file was:\n${SOURCE}\n") ELSE(HAVE_${VAR}) MESSAGE(STATUS "Performing Test ${COMMENT} - Failed") SET(${VAR} "" CACHE INTERNAL "Test ${COMMENT}") FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log "Performing C++ SOURCE FILE Test ${COMMENT} failed with the following output:\n" "${OUTPUT}\n" "Source file was:\n${SOURCE}\n") ENDIF(HAVE_${VAR}) ENDIF("HAVE_${VAR}" MATCHES "^HAVE_${VAR}$") ENDMACRO(CHECK_CXX_SOURCE_RUNS) xdmf-3.0+git20160803/libsrc/XdmfHDF.h0000640000175000017500000001631013003006557016742 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : $Id: XdmfHDF.h,v 1.7 2009-06-23 13:41:05 clarke Exp $ */ /* Date : $Date: 2009-06-23 13:41:05 $ */ /* Version : $Revision: 1.7 $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2002 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #ifndef __XdmfHDF_h #define __XdmfHDF_h #include "XdmfHeavyData.h" #define XDMF_H5_DIRECTORY H5G_GROUP #define XDMF_H5_DATASET H5G_DATASET #define XDMF_H5_UNKNOWN H5G_UNKNOWN #define XDMF_H5_OTHER 0xFF class XdmfArray; //! Class for Accessing HDF5 Data /*! This is a convenience object for reading and writing HDF5 Files. Use this to remain XDMF compliant. Datasets in HDF5 are specified by : Domain:Filename:Pathname where Domain = NDGM | FILE | CORE | GASS if Domain is not specified, FILE is assumed Filename = UNIX style Pathname of HDF5 file Pathname = HDF5 Pathname inside HDF5 File XdmfHDF confines HDF5 to using only HDF5 Groups and HDF5 Datasets. HDF5 Attributes (Name=Value pairs) are not used (that function is served by XML). HDF5 Groups are treated like "Directories" on a UNIX filesystem. HDF5 Datasets are treated like "Files" on a UNIX Filesystem. Example of Createing an HDF5 File : \code XdmfHDF *H5 = new XdmfHDF(); XdmfArray *MyData = new XdmfArray(); XdmfConstString DataSetNameConst; MyData->SetNumberType(XDMF_FLOAT32_TYPE); MyData->SetNumberOfElements(100); MyData->Generate(0, 99); DataSetNameConst = "FILE:TestFile.h5:/TestDataSets/Values1"; H5->CopyType( MyData ); H5->CopyShape( MyData ); H5->Open( DataSetName, "rw" ); H5->Write( MyData ); H5->Close(); \endcode This would create an HDF5 file with one Group (TestDataSets) and one Dataset in that Group (Values1). The Dataset would be 100 32 bit floating point values ranging from 0-99. */ class XDMF_EXPORT XdmfHDF : public XdmfHeavyData { public: XdmfHDF(); ~XdmfHDF(); XdmfConstString GetClassName() { return ( "XdmfHDF" ) ; }; //! Set Compression Level to 0 - 9 . Level <= 0 is Off /*! Compression level refers to the next dataset that is created. Once a dataset is created, the compression level does not change. Compression Levels 1-9 are progressively slower but result in much smaller HDF5 files. Compression uses the libz compression and "CHUNKS" the HDF5 file in the major dimension. */ XdmfSetValueMacro(Compression, XdmfInt32); //! Get Compression Level XdmfGetValueMacro(Compression, XdmfInt32); //! Use Serial File Interface even if Parallel is Available XdmfSetValueMacro(UseSerialFile, XdmfInt32); //! Get Value of Use Serial XdmfGetValueMacro(UseSerialFile, XdmfInt32); //! Set the current internal HDF "Group" for creation XdmfInt32 SetCwdName( XdmfConstString Directory ); //! Get the current internal HDF "Group" XdmfGetValueMacro(CwdName, XdmfString ); //! Go to another HDF5 "Group" XdmfInt32 Cd( XdmfConstString Directory = "/" ) { return( this->SetCwdName( Directory ) ); }; //! Create an HDF5 Gourp XdmfInt32 Mkdir( XdmfString Name ); //! Get the number of members in the current HDF5 Group XdmfGetValueMacro( NumberOfChildren, XdmfInt64); //! Get the HDF5 Library Version as Major.Minor.Release XdmfConstString GetHDFVersion(void); //! Get the n'th child in the current group XdmfConstString GetChild( XdmfInt64 Index ) { if ( Index >= this->NumberOfChildren ) { return( "" ); } return( this->Child[ Index ] ); }; //! Internal Call to set the name of the next child in the list void SetNextChild( XdmfConstString Name ); //! Internal HDF5 info XdmfInt32 Info( hid_t Group, XdmfConstString Name ); //! Get The Type of the Child : Directory, Dataset, ot Other XdmfInt32 GetChildType( XdmfInt64 Index ) { switch( this->Info( this->Cwd, this->GetChild( Index ) ) ) { case H5G_GROUP : return ( XDMF_H5_DIRECTORY ); case H5G_DATASET : return ( XDMF_H5_DATASET ); case XDMF_FAIL : return( XDMF_H5_UNKNOWN ); default : break; } return( XDMF_H5_OTHER ); }; //! Get The Type of the Child as a String XdmfConstString GetChildTypeAsString( XdmfInt64 Index ) { switch( this->GetChildType( Index ) ) { case XDMF_H5_DIRECTORY : return("XDMF_H5_DIRECTORY"); case XDMF_H5_DATASET : return("XDMF_H5_DATASET"); case XDMF_H5_UNKNOWN : return("XDMF_H5_UNKNOWN"); } return("XDMF_H5_OTHER"); }; //! Create a new dataset in the current Group XdmfInt32 CreateDataset( XdmfConstString Path = NULL ); //! Open an existing Dataset in a currently open HDF5 file XdmfInt32 OpenDataset(); //! Open an HDF5 file and OpenDataset = DataSetName /*! \verbatim Access is one of : "rw" | "wr" - Open for reading and writing. Create if necessary. "r+" - Open for reading and writing. "w" - Open for Writing. Create if necessary. This will truncate the file. "w+" - Open for Writing. This will truncate the file. "r" - Open for Read Only. \endverbatim */ virtual XdmfInt32 DoOpen( XdmfConstString DataSetName, XdmfConstString Access ); /*! Read the curently open dataset into and Array. */ virtual XdmfArray* DoRead( XdmfArray *Array ); /*! Write to the curently open dataset from and Array. */ virtual XdmfInt32 DoWrite( XdmfArray *Array ); //! Close the HDF5 File virtual XdmfInt32 DoClose(); protected: hid_t File; hid_t Cwd; hid_t Dataset; hid_t CreatePlist; hid_t AccessPlist; char CwdName[XDMF_MAX_STRING_LENGTH]; XdmfInt32 Compression; XdmfInt32 UseSerialFile; XdmfInt64 NumberOfChildren; XdmfString Child[1024]; }; /* extern XdmfArray *CreateArrayFromType( XdmfType *Type, XdmfInt64 NumberOfElements = 10 ); */ extern XDMF_EXPORT XdmfArray *CopyArray( XdmfArray *Source, XdmfArray *Target = NULL ); #endif // __XdmfHDF_h xdmf-3.0+git20160803/libsrc/XdmfPythonNoMpi.cxx0000640000175000017500000453044613003006557021157 0ustar alastairalastair/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 1.3.39 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make * changes to this file unless you know what you are doing--modify the SWIG * interface file instead. * ----------------------------------------------------------------------------- */ #define SWIGPYTHON #define SWIG_PYTHON_DIRECTOR_NO_VTABLE #ifdef __cplusplus /* SwigValueWrapper is described in swig.swg */ template class SwigValueWrapper { struct SwigMovePointer { T *ptr; SwigMovePointer(T *p) : ptr(p) { } ~SwigMovePointer() { delete ptr; } SwigMovePointer& operator=(SwigMovePointer& rhs) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = rhs.ptr; rhs.ptr = 0; return *this; } } pointer; SwigValueWrapper& operator=(const SwigValueWrapper& rhs); SwigValueWrapper(const SwigValueWrapper& rhs); public: SwigValueWrapper() : pointer(0) { } SwigValueWrapper& operator=(const T& t) { SwigMovePointer tmp(new T(t)); pointer = tmp; return *this; } operator T&() const { return *pointer.ptr; } T *operator&() { return pointer.ptr; } }; template T SwigValueInit() { return T(); } #endif /* ----------------------------------------------------------------------------- * This section contains generic SWIG labels for method/variable * declarations/attributes, and other compiler dependent labels. * ----------------------------------------------------------------------------- */ /* template workaround for compilers that cannot correctly implement the C++ standard */ #ifndef SWIGTEMPLATEDISAMBIGUATOR # if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) # define SWIGTEMPLATEDISAMBIGUATOR template # elif defined(__HP_aCC) /* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ /* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ # define SWIGTEMPLATEDISAMBIGUATOR template # else # define SWIGTEMPLATEDISAMBIGUATOR # endif #endif /* inline attribute */ #ifndef SWIGINLINE # if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) # define SWIGINLINE inline # else # define SWIGINLINE # endif #endif /* attribute recognised by some compilers to avoid 'unused' warnings */ #ifndef SWIGUNUSED # if defined(__GNUC__) # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) # define SWIGUNUSED __attribute__ ((__unused__)) # else # define SWIGUNUSED # endif # elif defined(__ICC) # define SWIGUNUSED __attribute__ ((__unused__)) # else # define SWIGUNUSED # endif #endif #ifndef SWIG_MSC_UNSUPPRESS_4505 # if defined(_MSC_VER) # pragma warning(disable : 4505) /* unreferenced local function has been removed */ # endif #endif #ifndef SWIGUNUSEDPARM # ifdef __cplusplus # define SWIGUNUSEDPARM(p) # else # define SWIGUNUSEDPARM(p) p SWIGUNUSED # endif #endif /* internal SWIG method */ #ifndef SWIGINTERN # define SWIGINTERN static SWIGUNUSED #endif /* internal inline SWIG method */ #ifndef SWIGINTERNINLINE # define SWIGINTERNINLINE SWIGINTERN SWIGINLINE #endif /* exporting methods */ #if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) # ifndef GCC_HASCLASSVISIBILITY # define GCC_HASCLASSVISIBILITY # endif #endif #ifndef SWIGEXPORT # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) # if defined(STATIC_LINKED) # define SWIGEXPORT # else # define SWIGEXPORT __declspec(dllexport) # endif # else # if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) # define SWIGEXPORT __attribute__ ((visibility("default"))) # else # define SWIGEXPORT # endif # endif #endif /* calling conventions for Windows */ #ifndef SWIGSTDCALL # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) # define SWIGSTDCALL __stdcall # else # define SWIGSTDCALL # endif #endif /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) # define _CRT_SECURE_NO_DEPRECATE #endif /* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ #if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) # define _SCL_SECURE_NO_DEPRECATE #endif /* Python.h has to appear first */ #include /* ----------------------------------------------------------------------------- * swigrun.swg * * This file contains generic C API SWIG runtime support for pointer * type checking. * ----------------------------------------------------------------------------- */ /* This should only be incremented when either the layout of swig_type_info changes, or for whatever reason, the runtime changes incompatibly */ #define SWIG_RUNTIME_VERSION "4" /* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ #ifdef SWIG_TYPE_TABLE # define SWIG_QUOTE_STRING(x) #x # define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) # define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) #else # define SWIG_TYPE_TABLE_NAME #endif /* You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for creating a static or dynamic library from the SWIG runtime code. In 99.9% of the cases, SWIG just needs to declare them as 'static'. But only do this if strictly necessary, ie, if you have problems with your compiler or suchlike. */ #ifndef SWIGRUNTIME # define SWIGRUNTIME SWIGINTERN #endif #ifndef SWIGRUNTIMEINLINE # define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE #endif /* Generic buffer size */ #ifndef SWIG_BUFFER_SIZE # define SWIG_BUFFER_SIZE 1024 #endif /* Flags for pointer conversions */ #define SWIG_POINTER_DISOWN 0x1 #define SWIG_CAST_NEW_MEMORY 0x2 /* Flags for new pointer objects */ #define SWIG_POINTER_OWN 0x1 /* Flags/methods for returning states. The SWIG conversion methods, as ConvertPtr, return and integer that tells if the conversion was successful or not. And if not, an error code can be returned (see swigerrors.swg for the codes). Use the following macros/flags to set or process the returning states. In old versions of SWIG, code such as the following was usually written: if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { // success code } else { //fail code } Now you can be more explicit: int res = SWIG_ConvertPtr(obj,vptr,ty.flags); if (SWIG_IsOK(res)) { // success code } else { // fail code } which is the same really, but now you can also do Type *ptr; int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags); if (SWIG_IsOK(res)) { // success code if (SWIG_IsNewObj(res) { ... delete *ptr; } else { ... } } else { // fail code } I.e., now SWIG_ConvertPtr can return new objects and you can identify the case and take care of the deallocation. Of course that also requires SWIG_ConvertPtr to return new result values, such as int SWIG_ConvertPtr(obj, ptr,...) { if () { if () { *ptr = ; return SWIG_NEWOBJ; } else { *ptr = ; return SWIG_OLDOBJ; } } else { return SWIG_BADOBJ; } } Of course, returning the plain '0(success)/-1(fail)' still works, but you can be more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the SWIG errors code. Finally, if the SWIG_CASTRANK_MODE is enabled, the result code allows to return the 'cast rank', for example, if you have this int food(double) int fooi(int); and you call food(1) // cast rank '1' (1 -> 1.0) fooi(1) // cast rank '0' just use the SWIG_AddCast()/SWIG_CheckState() */ #define SWIG_OK (0) #define SWIG_ERROR (-1) #define SWIG_IsOK(r) (r >= 0) #define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) /* The CastRankLimit says how many bits are used for the cast rank */ #define SWIG_CASTRANKLIMIT (1 << 8) /* The NewMask denotes the object was created (using new/malloc) */ #define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1) /* The TmpMask is for in/out typemaps that use temporal objects */ #define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1) /* Simple returning values */ #define SWIG_BADOBJ (SWIG_ERROR) #define SWIG_OLDOBJ (SWIG_OK) #define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK) #define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK) /* Check, add and del mask methods */ #define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r) #define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r) #define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK)) #define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r) #define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r) #define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK)) /* Cast-Rank Mode */ #if defined(SWIG_CASTRANK_MODE) # ifndef SWIG_TypeRank # define SWIG_TypeRank unsigned long # endif # ifndef SWIG_MAXCASTRANK /* Default cast allowed */ # define SWIG_MAXCASTRANK (2) # endif # define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) # define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) SWIGINTERNINLINE int SWIG_AddCast(int r) { return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; } SWIGINTERNINLINE int SWIG_CheckState(int r) { return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; } #else /* no cast-rank mode */ # define SWIG_AddCast # define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) #endif #include #ifdef __cplusplus extern "C" { #endif typedef void *(*swig_converter_func)(void *, int *); typedef struct swig_type_info *(*swig_dycast_func)(void **); /* Structure to store information on one type */ typedef struct swig_type_info { const char *name; /* mangled name of this type */ const char *str; /* human readable name of this type */ swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ struct swig_cast_info *cast; /* linked list of types that can cast into this type */ void *clientdata; /* language specific type data */ int owndata; /* flag if the structure owns the clientdata */ } swig_type_info; /* Structure to store a type and conversion function used for casting */ typedef struct swig_cast_info { swig_type_info *type; /* pointer to type that is equivalent to this type */ swig_converter_func converter; /* function to cast the void pointers */ struct swig_cast_info *next; /* pointer to next cast in linked list */ struct swig_cast_info *prev; /* pointer to the previous cast */ } swig_cast_info; /* Structure used to store module information * Each module generates one structure like this, and the runtime collects * all of these structures and stores them in a circularly linked list.*/ typedef struct swig_module_info { swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ size_t size; /* Number of types in this module */ struct swig_module_info *next; /* Pointer to next element in circularly linked list */ swig_type_info **type_initial; /* Array of initially generated type structures */ swig_cast_info **cast_initial; /* Array of initially generated casting structures */ void *clientdata; /* Language specific module data */ } swig_module_info; /* Compare two type names skipping the space characters, therefore "char*" == "char *" and "Class" == "Class", etc. Return 0 when the two name types are equivalent, as in strncmp, but skipping ' '. */ SWIGRUNTIME int SWIG_TypeNameComp(const char *f1, const char *l1, const char *f2, const char *l2) { for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { while ((*f1 == ' ') && (f1 != l1)) ++f1; while ((*f2 == ' ') && (f2 != l2)) ++f2; if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; } return (int)((l1 - f1) - (l2 - f2)); } /* Check type equivalence in a name list like ||... Return 0 if not equal, 1 if equal */ SWIGRUNTIME int SWIG_TypeEquiv(const char *nb, const char *tb) { int equiv = 0; const char* te = tb + strlen(tb); const char* ne = nb; while (!equiv && *ne) { for (nb = ne; *ne; ++ne) { if (*ne == '|') break; } equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; if (*ne) ++ne; } return equiv; } /* Check type equivalence in a name list like ||... Return 0 if equal, -1 if nb < tb, 1 if nb > tb */ SWIGRUNTIME int SWIG_TypeCompare(const char *nb, const char *tb) { int equiv = 0; const char* te = tb + strlen(tb); const char* ne = nb; while (!equiv && *ne) { for (nb = ne; *ne; ++ne) { if (*ne == '|') break; } equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; if (*ne) ++ne; } return equiv; } /* Check the typename */ SWIGRUNTIME swig_cast_info * SWIG_TypeCheck(const char *c, swig_type_info *ty) { if (ty) { swig_cast_info *iter = ty->cast; while (iter) { if (strcmp(iter->type->name, c) == 0) { if (iter == ty->cast) return iter; /* Move iter to the top of the linked list */ iter->prev->next = iter->next; if (iter->next) iter->next->prev = iter->prev; iter->next = ty->cast; iter->prev = 0; if (ty->cast) ty->cast->prev = iter; ty->cast = iter; return iter; } iter = iter->next; } } return 0; } /* Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison */ SWIGRUNTIME swig_cast_info * SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) { if (ty) { swig_cast_info *iter = ty->cast; while (iter) { if (iter->type == from) { if (iter == ty->cast) return iter; /* Move iter to the top of the linked list */ iter->prev->next = iter->next; if (iter->next) iter->next->prev = iter->prev; iter->next = ty->cast; iter->prev = 0; if (ty->cast) ty->cast->prev = iter; ty->cast = iter; return iter; } iter = iter->next; } } return 0; } /* Cast a pointer up an inheritance hierarchy */ SWIGRUNTIMEINLINE void * SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) { return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory); } /* Dynamic pointer casting. Down an inheritance hierarchy */ SWIGRUNTIME swig_type_info * SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { swig_type_info *lastty = ty; if (!ty || !ty->dcast) return ty; while (ty && (ty->dcast)) { ty = (*ty->dcast)(ptr); if (ty) lastty = ty; } return lastty; } /* Return the name associated with this type */ SWIGRUNTIMEINLINE const char * SWIG_TypeName(const swig_type_info *ty) { return ty->name; } /* Return the pretty name associated with this type, that is an unmangled type name in a form presentable to the user. */ SWIGRUNTIME const char * SWIG_TypePrettyName(const swig_type_info *type) { /* The "str" field contains the equivalent pretty names of the type, separated by vertical-bar characters. We choose to print the last name, as it is often (?) the most specific. */ if (!type) return NULL; if (type->str != NULL) { const char *last_name = type->str; const char *s; for (s = type->str; *s; s++) if (*s == '|') last_name = s+1; return last_name; } else return type->name; } /* Set the clientdata field for a type */ SWIGRUNTIME void SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { swig_cast_info *cast = ti->cast; /* if (ti->clientdata == clientdata) return; */ ti->clientdata = clientdata; while (cast) { if (!cast->converter) { swig_type_info *tc = cast->type; if (!tc->clientdata) { SWIG_TypeClientData(tc, clientdata); } } cast = cast->next; } } SWIGRUNTIME void SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { SWIG_TypeClientData(ti, clientdata); ti->owndata = 1; } /* Search for a swig_type_info structure only by mangled name Search is a O(log #types) We start searching at module start, and finish searching when start == end. Note: if start == end at the beginning of the function, we go all the way around the circular list. */ SWIGRUNTIME swig_type_info * SWIG_MangledTypeQueryModule(swig_module_info *start, swig_module_info *end, const char *name) { swig_module_info *iter = start; do { if (iter->size) { register size_t l = 0; register size_t r = iter->size - 1; do { /* since l+r >= 0, we can (>> 1) instead (/ 2) */ register size_t i = (l + r) >> 1; const char *iname = iter->types[i]->name; if (iname) { register int compare = strcmp(name, iname); if (compare == 0) { return iter->types[i]; } else if (compare < 0) { if (i) { r = i - 1; } else { break; } } else if (compare > 0) { l = i + 1; } } else { break; /* should never happen */ } } while (l <= r); } iter = iter->next; } while (iter != end); return 0; } /* Search for a swig_type_info structure for either a mangled name or a human readable name. It first searches the mangled names of the types, which is a O(log #types) If a type is not found it then searches the human readable names, which is O(#types). We start searching at module start, and finish searching when start == end. Note: if start == end at the beginning of the function, we go all the way around the circular list. */ SWIGRUNTIME swig_type_info * SWIG_TypeQueryModule(swig_module_info *start, swig_module_info *end, const char *name) { /* STEP 1: Search the name field using binary search */ swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); if (ret) { return ret; } else { /* STEP 2: If the type hasn't been found, do a complete search of the str field (the human readable name) */ swig_module_info *iter = start; do { register size_t i = 0; for (; i < iter->size; ++i) { if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) return iter->types[i]; } iter = iter->next; } while (iter != end); } /* neither found a match */ return 0; } /* Pack binary data into a string */ SWIGRUNTIME char * SWIG_PackData(char *c, void *ptr, size_t sz) { static const char hex[17] = "0123456789abcdef"; register const unsigned char *u = (unsigned char *) ptr; register const unsigned char *eu = u + sz; for (; u != eu; ++u) { register unsigned char uu = *u; *(c++) = hex[(uu & 0xf0) >> 4]; *(c++) = hex[uu & 0xf]; } return c; } /* Unpack binary data from a string */ SWIGRUNTIME const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) { register unsigned char *u = (unsigned char *) ptr; register const unsigned char *eu = u + sz; for (; u != eu; ++u) { register char d = *(c++); register unsigned char uu; if ((d >= '0') && (d <= '9')) uu = ((d - '0') << 4); else if ((d >= 'a') && (d <= 'f')) uu = ((d - ('a'-10)) << 4); else return (char *) 0; d = *(c++); if ((d >= '0') && (d <= '9')) uu |= (d - '0'); else if ((d >= 'a') && (d <= 'f')) uu |= (d - ('a'-10)); else return (char *) 0; *u = uu; } return c; } /* Pack 'void *' into a string buffer. */ SWIGRUNTIME char * SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { char *r = buff; if ((2*sizeof(void *) + 2) > bsz) return 0; *(r++) = '_'; r = SWIG_PackData(r,&ptr,sizeof(void *)); if (strlen(name) + 1 > (bsz - (r - buff))) return 0; strcpy(r,name); return buff; } SWIGRUNTIME const char * SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { if (*c != '_') { if (strcmp(c,"NULL") == 0) { *ptr = (void *) 0; return name; } else { return 0; } } return SWIG_UnpackData(++c,ptr,sizeof(void *)); } SWIGRUNTIME char * SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { char *r = buff; size_t lname = (name ? strlen(name) : 0); if ((2*sz + 2 + lname) > bsz) return 0; *(r++) = '_'; r = SWIG_PackData(r,ptr,sz); if (lname) { strncpy(r,name,lname+1); } else { *r = 0; } return buff; } SWIGRUNTIME const char * SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { if (*c != '_') { if (strcmp(c,"NULL") == 0) { memset(ptr,0,sz); return name; } else { return 0; } } return SWIG_UnpackData(++c,ptr,sz); } #ifdef __cplusplus } #endif /* Errors in SWIG */ #define SWIG_UnknownError -1 #define SWIG_IOError -2 #define SWIG_RuntimeError -3 #define SWIG_IndexError -4 #define SWIG_TypeError -5 #define SWIG_DivisionByZero -6 #define SWIG_OverflowError -7 #define SWIG_SyntaxError -8 #define SWIG_ValueError -9 #define SWIG_SystemError -10 #define SWIG_AttributeError -11 #define SWIG_MemoryError -12 #define SWIG_NullReferenceError -13 /* Compatibility marcos for Python 3 */ #if PY_VERSION_HEX >= 0x03000000 #define PyClass_Check(obj) PyObject_IsInstance(obj, (PyObject *)&PyType_Type) #define PyInt_Check(x) PyLong_Check(x) #define PyInt_AsLong(x) PyLong_AsLong(x) #define PyInt_FromLong(x) PyLong_FromLong(x) #define PyString_Format(fmt, args) PyUnicode_Format(fmt, args) #endif #ifndef Py_TYPE # define Py_TYPE(op) ((op)->ob_type) #endif /* SWIG APIs for compatibility of both Python 2 & 3 */ #if PY_VERSION_HEX >= 0x03000000 # define SWIG_Python_str_FromFormat PyUnicode_FromFormat #else # define SWIG_Python_str_FromFormat PyString_FromFormat #endif /* Warning: This function will allocate a new string in Python 3, * so please call SWIG_Python_str_DelForPy3(x) to free the space. */ SWIGINTERN char* SWIG_Python_str_AsChar(PyObject *str) { #if PY_VERSION_HEX >= 0x03000000 char *cstr; char *newstr; int len; str = PyUnicode_AsUTF8String(str); PyBytes_AsStringAndSize(str, &cstr, &len); newstr = (char *) malloc(len+1); memcpy(newstr, cstr, len+1); Py_XDECREF(str); return newstr; #else return PyString_AsString(str); #endif } #if PY_VERSION_HEX >= 0x03000000 # define SWIG_Python_str_DelForPy3(x) free( (void*) (x) ) #else # define SWIG_Python_str_DelForPy3(x) #endif SWIGINTERN PyObject* SWIG_Python_str_FromChar(const char *c) { #if PY_VERSION_HEX >= 0x03000000 return PyUnicode_FromString(c); #else return PyString_FromString(c); #endif } /* Add PyOS_snprintf for old Pythons */ #if PY_VERSION_HEX < 0x02020000 # if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # define PyOS_snprintf _snprintf # else # define PyOS_snprintf snprintf # endif #endif /* A crude PyString_FromFormat implementation for old Pythons */ #if PY_VERSION_HEX < 0x02020000 #ifndef SWIG_PYBUFFER_SIZE # define SWIG_PYBUFFER_SIZE 1024 #endif static PyObject * PyString_FromFormat(const char *fmt, ...) { va_list ap; char buf[SWIG_PYBUFFER_SIZE * 2]; int res; va_start(ap, fmt); res = vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); return (res < 0 || res >= (int)sizeof(buf)) ? 0 : PyString_FromString(buf); } #endif /* Add PyObject_Del for old Pythons */ #if PY_VERSION_HEX < 0x01060000 # define PyObject_Del(op) PyMem_DEL((op)) #endif #ifndef PyObject_DEL # define PyObject_DEL PyObject_Del #endif /* A crude PyExc_StopIteration exception for old Pythons */ #if PY_VERSION_HEX < 0x02020000 # ifndef PyExc_StopIteration # define PyExc_StopIteration PyExc_RuntimeError # endif # ifndef PyObject_GenericGetAttr # define PyObject_GenericGetAttr 0 # endif #endif /* Py_NotImplemented is defined in 2.1 and up. */ #if PY_VERSION_HEX < 0x02010000 # ifndef Py_NotImplemented # define Py_NotImplemented PyExc_RuntimeError # endif #endif /* A crude PyString_AsStringAndSize implementation for old Pythons */ #if PY_VERSION_HEX < 0x02010000 # ifndef PyString_AsStringAndSize # define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;} # endif #endif /* PySequence_Size for old Pythons */ #if PY_VERSION_HEX < 0x02000000 # ifndef PySequence_Size # define PySequence_Size PySequence_Length # endif #endif /* PyBool_FromLong for old Pythons */ #if PY_VERSION_HEX < 0x02030000 static PyObject *PyBool_FromLong(long ok) { PyObject *result = ok ? Py_True : Py_False; Py_INCREF(result); return result; } #endif /* Py_ssize_t for old Pythons */ /* This code is as recommended by: */ /* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */ #if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN) typedef int Py_ssize_t; # define PY_SSIZE_T_MAX INT_MAX # define PY_SSIZE_T_MIN INT_MIN #endif /* ----------------------------------------------------------------------------- * error manipulation * ----------------------------------------------------------------------------- */ SWIGRUNTIME PyObject* SWIG_Python_ErrorType(int code) { PyObject* type = 0; switch(code) { case SWIG_MemoryError: type = PyExc_MemoryError; break; case SWIG_IOError: type = PyExc_IOError; break; case SWIG_RuntimeError: type = PyExc_RuntimeError; break; case SWIG_IndexError: type = PyExc_IndexError; break; case SWIG_TypeError: type = PyExc_TypeError; break; case SWIG_DivisionByZero: type = PyExc_ZeroDivisionError; break; case SWIG_OverflowError: type = PyExc_OverflowError; break; case SWIG_SyntaxError: type = PyExc_SyntaxError; break; case SWIG_ValueError: type = PyExc_ValueError; break; case SWIG_SystemError: type = PyExc_SystemError; break; case SWIG_AttributeError: type = PyExc_AttributeError; break; default: type = PyExc_RuntimeError; } return type; } SWIGRUNTIME void SWIG_Python_AddErrorMsg(const char* mesg) { PyObject *type = 0; PyObject *value = 0; PyObject *traceback = 0; if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback); if (value) { char *tmp; PyObject *old_str = PyObject_Str(value); PyErr_Clear(); Py_XINCREF(type); PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg); SWIG_Python_str_DelForPy3(tmp); Py_DECREF(old_str); Py_DECREF(value); } else { PyErr_SetString(PyExc_RuntimeError, mesg); } } #if defined(SWIG_PYTHON_NO_THREADS) # if defined(SWIG_PYTHON_THREADS) # undef SWIG_PYTHON_THREADS # endif #endif #if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */ # if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL) # if (PY_VERSION_HEX >= 0x02030000) /* For 2.3 or later, use the PyGILState calls */ # define SWIG_PYTHON_USE_GIL # endif # endif # if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */ # ifndef SWIG_PYTHON_INITIALIZE_THREADS # define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads() # endif # ifdef __cplusplus /* C++ code */ class SWIG_Python_Thread_Block { bool status; PyGILState_STATE state; public: void end() { if (status) { PyGILState_Release(state); status = false;} } SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {} ~SWIG_Python_Thread_Block() { end(); } }; class SWIG_Python_Thread_Allow { bool status; PyThreadState *save; public: void end() { if (status) { PyEval_RestoreThread(save); status = false; }} SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {} ~SWIG_Python_Thread_Allow() { end(); } }; # define SWIG_PYTHON_THREAD_BEGIN_BLOCK SWIG_Python_Thread_Block _swig_thread_block # define SWIG_PYTHON_THREAD_END_BLOCK _swig_thread_block.end() # define SWIG_PYTHON_THREAD_BEGIN_ALLOW SWIG_Python_Thread_Allow _swig_thread_allow # define SWIG_PYTHON_THREAD_END_ALLOW _swig_thread_allow.end() # else /* C code */ # define SWIG_PYTHON_THREAD_BEGIN_BLOCK PyGILState_STATE _swig_thread_block = PyGILState_Ensure() # define SWIG_PYTHON_THREAD_END_BLOCK PyGILState_Release(_swig_thread_block) # define SWIG_PYTHON_THREAD_BEGIN_ALLOW PyThreadState *_swig_thread_allow = PyEval_SaveThread() # define SWIG_PYTHON_THREAD_END_ALLOW PyEval_RestoreThread(_swig_thread_allow) # endif # else /* Old thread way, not implemented, user must provide it */ # if !defined(SWIG_PYTHON_INITIALIZE_THREADS) # define SWIG_PYTHON_INITIALIZE_THREADS # endif # if !defined(SWIG_PYTHON_THREAD_BEGIN_BLOCK) # define SWIG_PYTHON_THREAD_BEGIN_BLOCK # endif # if !defined(SWIG_PYTHON_THREAD_END_BLOCK) # define SWIG_PYTHON_THREAD_END_BLOCK # endif # if !defined(SWIG_PYTHON_THREAD_BEGIN_ALLOW) # define SWIG_PYTHON_THREAD_BEGIN_ALLOW # endif # if !defined(SWIG_PYTHON_THREAD_END_ALLOW) # define SWIG_PYTHON_THREAD_END_ALLOW # endif # endif #else /* No thread support */ # define SWIG_PYTHON_INITIALIZE_THREADS # define SWIG_PYTHON_THREAD_BEGIN_BLOCK # define SWIG_PYTHON_THREAD_END_BLOCK # define SWIG_PYTHON_THREAD_BEGIN_ALLOW # define SWIG_PYTHON_THREAD_END_ALLOW #endif /* ----------------------------------------------------------------------------- * Python API portion that goes into the runtime * ----------------------------------------------------------------------------- */ #ifdef __cplusplus extern "C" { #if 0 } /* cc-mode */ #endif #endif /* ----------------------------------------------------------------------------- * Constant declarations * ----------------------------------------------------------------------------- */ /* Constant Types */ #define SWIG_PY_POINTER 4 #define SWIG_PY_BINARY 5 /* Constant information structure */ typedef struct swig_const_info { int type; char *name; long lvalue; double dvalue; void *pvalue; swig_type_info **ptype; } swig_const_info; /* ----------------------------------------------------------------------------- * Wrapper of PyInstanceMethod_New() used in Python 3 * It is exported to the generated module, used for -fastproxy * ----------------------------------------------------------------------------- */ SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *self, PyObject *func) { #if PY_VERSION_HEX >= 0x03000000 return PyInstanceMethod_New(func); #else return NULL; #endif } #ifdef __cplusplus #if 0 { /* cc-mode */ #endif } #endif /* ----------------------------------------------------------------------------- * See the LICENSE file for information on copyright, usage and redistribution * of SWIG, and the README file for authors - http://www.swig.org/release.html. * * pyrun.swg * * This file contains the runtime support for Python modules * and includes code for managing global variables and pointer * type checking. * * ----------------------------------------------------------------------------- */ /* Common SWIG API */ /* for raw pointers */ #define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0) #define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags) #define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own) #define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(ptr, type, flags) #define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty) #define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src) #define swig_owntype int /* for raw packed data */ #define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) #define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) /* for class or struct pointers */ #define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) #define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) /* for C or C++ function pointers */ #define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Python_ConvertFunctionPtr(obj, pptr, type) #define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(ptr, type, 0) /* for C++ member pointers, ie, member methods */ #define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) #define SWIG_NewMemberObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) /* Runtime API */ #define SWIG_GetModule(clientdata) SWIG_Python_GetModule() #define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer) #define SWIG_NewClientData(obj) SwigPyClientData_New(obj) #define SWIG_SetErrorObj SWIG_Python_SetErrorObj #define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg #define SWIG_ErrorType(code) SWIG_Python_ErrorType(code) #define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg) #define SWIG_fail goto fail /* Runtime API implementation */ /* Error manipulation */ SWIGINTERN void SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetObject(errtype, obj); Py_DECREF(obj); SWIG_PYTHON_THREAD_END_BLOCK; } SWIGINTERN void SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetString(errtype, (char *) msg); SWIG_PYTHON_THREAD_END_BLOCK; } #define SWIG_Python_Raise(obj, type, desc) SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj) /* Set a constant value */ SWIGINTERN void SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { PyDict_SetItemString(d, (char*) name, obj); Py_DECREF(obj); } /* Append a value to the result obj */ SWIGINTERN PyObject* SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) { #if !defined(SWIG_PYTHON_OUTPUT_TUPLE) if (!result) { result = obj; } else if (result == Py_None) { Py_DECREF(result); result = obj; } else { if (!PyList_Check(result)) { PyObject *o2 = result; result = PyList_New(1); PyList_SetItem(result, 0, o2); } PyList_Append(result,obj); Py_DECREF(obj); } return result; #else PyObject* o2; PyObject* o3; if (!result) { result = obj; } else if (result == Py_None) { Py_DECREF(result); result = obj; } else { if (!PyTuple_Check(result)) { o2 = result; result = PyTuple_New(1); PyTuple_SET_ITEM(result, 0, o2); } o3 = PyTuple_New(1); PyTuple_SET_ITEM(o3, 0, obj); o2 = result; result = PySequence_Concat(o2, o3); Py_DECREF(o2); Py_DECREF(o3); } return result; #endif } /* Unpack the argument tuple */ SWIGINTERN int SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs) { if (!args) { if (!min && !max) { return 1; } else { PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none", name, (min == max ? "" : "at least "), (int)min); return 0; } } if (!PyTuple_Check(args)) { PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple"); return 0; } else { register Py_ssize_t l = PyTuple_GET_SIZE(args); if (l < min) { PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", name, (min == max ? "" : "at least "), (int)min, (int)l); return 0; } else if (l > max) { PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", name, (min == max ? "" : "at most "), (int)max, (int)l); return 0; } else { register int i; for (i = 0; i < l; ++i) { objs[i] = PyTuple_GET_ITEM(args, i); } for (; l < max; ++l) { objs[l] = 0; } return i + 1; } } } /* A functor is a function object with one single object argument */ #if PY_VERSION_HEX >= 0x02020000 #define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL); #else #define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, "O", obj); #endif /* Helper for static pointer initialization for both C and C++ code, for example static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...); */ #ifdef __cplusplus #define SWIG_STATIC_POINTER(var) var #else #define SWIG_STATIC_POINTER(var) var = 0; if (!var) var #endif /* ----------------------------------------------------------------------------- * Pointer declarations * ----------------------------------------------------------------------------- */ /* Flags for new pointer objects */ #define SWIG_POINTER_NOSHADOW (SWIG_POINTER_OWN << 1) #define SWIG_POINTER_NEW (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN) #define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1) #ifdef __cplusplus extern "C" { #if 0 } /* cc-mode */ #endif #endif /* How to access Py_None */ #if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) # ifndef SWIG_PYTHON_NO_BUILD_NONE # ifndef SWIG_PYTHON_BUILD_NONE # define SWIG_PYTHON_BUILD_NONE # endif # endif #endif #ifdef SWIG_PYTHON_BUILD_NONE # ifdef Py_None # undef Py_None # define Py_None SWIG_Py_None() # endif SWIGRUNTIMEINLINE PyObject * _SWIG_Py_None(void) { PyObject *none = Py_BuildValue((char*)""); Py_DECREF(none); return none; } SWIGRUNTIME PyObject * SWIG_Py_None(void) { static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None(); return none; } #endif /* The python void return value */ SWIGRUNTIMEINLINE PyObject * SWIG_Py_Void(void) { PyObject *none = Py_None; Py_INCREF(none); return none; } /* SwigPyClientData */ typedef struct { PyObject *klass; PyObject *newraw; PyObject *newargs; PyObject *destroy; int delargs; int implicitconv; } SwigPyClientData; SWIGRUNTIMEINLINE int SWIG_Python_CheckImplicit(swig_type_info *ty) { SwigPyClientData *data = (SwigPyClientData *)ty->clientdata; return data ? data->implicitconv : 0; } SWIGRUNTIMEINLINE PyObject * SWIG_Python_ExceptionType(swig_type_info *desc) { SwigPyClientData *data = desc ? (SwigPyClientData *) desc->clientdata : 0; PyObject *klass = data ? data->klass : 0; return (klass ? klass : PyExc_RuntimeError); } SWIGRUNTIME SwigPyClientData * SwigPyClientData_New(PyObject* obj) { if (!obj) { return 0; } else { SwigPyClientData *data = (SwigPyClientData *)malloc(sizeof(SwigPyClientData)); /* the klass element */ data->klass = obj; Py_INCREF(data->klass); /* the newraw method and newargs arguments used to create a new raw instance */ if (PyClass_Check(obj)) { data->newraw = 0; data->newargs = obj; Py_INCREF(obj); } else { #if (PY_VERSION_HEX < 0x02020000) data->newraw = 0; #else data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__"); #endif if (data->newraw) { Py_INCREF(data->newraw); data->newargs = PyTuple_New(1); PyTuple_SetItem(data->newargs, 0, obj); } else { data->newargs = obj; } Py_INCREF(data->newargs); } /* the destroy method, aka as the C++ delete method */ data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__"); if (PyErr_Occurred()) { PyErr_Clear(); data->destroy = 0; } if (data->destroy) { int flags; Py_INCREF(data->destroy); flags = PyCFunction_GET_FLAGS(data->destroy); #ifdef METH_O data->delargs = !(flags & (METH_O)); #else data->delargs = 0; #endif } else { data->delargs = 0; } data->implicitconv = 0; return data; } } SWIGRUNTIME void SwigPyClientData_Del(SwigPyClientData* data) { Py_XDECREF(data->newraw); Py_XDECREF(data->newargs); Py_XDECREF(data->destroy); } /* =============== SwigPyObject =====================*/ typedef struct { PyObject_HEAD void *ptr; swig_type_info *ty; int own; PyObject *next; } SwigPyObject; SWIGRUNTIME PyObject * SwigPyObject_long(SwigPyObject *v) { return PyLong_FromVoidPtr(v->ptr); } SWIGRUNTIME PyObject * SwigPyObject_format(const char* fmt, SwigPyObject *v) { PyObject *res = NULL; PyObject *args = PyTuple_New(1); if (args) { if (PyTuple_SetItem(args, 0, SwigPyObject_long(v)) == 0) { PyObject *ofmt = SWIG_Python_str_FromChar(fmt); if (ofmt) { #if PY_VERSION_HEX >= 0x03000000 res = PyUnicode_Format(ofmt,args); #else res = PyString_Format(ofmt,args); #endif Py_DECREF(ofmt); } Py_DECREF(args); } } return res; } SWIGRUNTIME PyObject * SwigPyObject_oct(SwigPyObject *v) { return SwigPyObject_format("%o",v); } SWIGRUNTIME PyObject * SwigPyObject_hex(SwigPyObject *v) { return SwigPyObject_format("%x",v); } SWIGRUNTIME PyObject * #ifdef METH_NOARGS SwigPyObject_repr(SwigPyObject *v) #else SwigPyObject_repr(SwigPyObject *v, PyObject *args) #endif { const char *name = SWIG_TypePrettyName(v->ty); PyObject *hex = SwigPyObject_hex(v); PyObject *repr = SWIG_Python_str_FromFormat("", name, hex); Py_DECREF(hex); if (v->next) { #ifdef METH_NOARGS PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next); #else PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next, args); #endif #if PY_VERSION_HEX >= 0x03000000 PyObject *joined = PyUnicode_Concat(repr, nrep); Py_DecRef(repr); Py_DecRef(nrep); repr = joined; #else PyString_ConcatAndDel(&repr,nrep); #endif } return repr; } SWIGRUNTIME int SwigPyObject_print(SwigPyObject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) { char *str; #ifdef METH_NOARGS PyObject *repr = SwigPyObject_repr(v); #else PyObject *repr = SwigPyObject_repr(v, NULL); #endif if (repr) { str = SWIG_Python_str_AsChar(repr); fputs(str, fp); SWIG_Python_str_DelForPy3(str); Py_DECREF(repr); return 0; } else { return 1; } } SWIGRUNTIME PyObject * SwigPyObject_str(SwigPyObject *v) { char result[SWIG_BUFFER_SIZE]; return SWIG_PackVoidPtr(result, v->ptr, v->ty->name, sizeof(result)) ? SWIG_Python_str_FromChar(result) : 0; } SWIGRUNTIME int SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w) { void *i = v->ptr; void *j = w->ptr; return (i < j) ? -1 : ((i > j) ? 1 : 0); } /* Added for Python 3.x, whould it also useful for Python 2.x? */ SWIGRUNTIME PyObject* SwigPyObject_richcompare(SwigPyObject *v, SwigPyObject *w, int op) { PyObject* res; if( op != Py_EQ && op != Py_NE ) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; } if( (SwigPyObject_compare(v, w)==0) == (op == Py_EQ) ) res = Py_True; else res = Py_False; Py_INCREF(res); return res; } SWIGRUNTIME PyTypeObject* _PySwigObject_type(void); SWIGRUNTIME PyTypeObject* SwigPyObject_type(void) { static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigObject_type(); return type; } SWIGRUNTIMEINLINE int SwigPyObject_Check(PyObject *op) { return (Py_TYPE(op) == SwigPyObject_type()) || (strcmp(Py_TYPE(op)->tp_name,"SwigPyObject") == 0); } SWIGRUNTIME PyObject * SwigPyObject_New(void *ptr, swig_type_info *ty, int own); SWIGRUNTIME void SwigPyObject_dealloc(PyObject *v) { SwigPyObject *sobj = (SwigPyObject *) v; PyObject *next = sobj->next; if (sobj->own == SWIG_POINTER_OWN) { swig_type_info *ty = sobj->ty; SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; PyObject *destroy = data ? data->destroy : 0; if (destroy) { /* destroy is always a VARARGS method */ PyObject *res; if (data->delargs) { /* we need to create a temporal object to carry the destroy operation */ PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0); res = SWIG_Python_CallFunctor(destroy, tmp); Py_DECREF(tmp); } else { PyCFunction meth = PyCFunction_GET_FUNCTION(destroy); PyObject *mself = PyCFunction_GET_SELF(destroy); res = ((*meth)(mself, v)); } Py_XDECREF(res); } #if !defined(SWIG_PYTHON_SILENT_MEMLEAK) else { const char *name = SWIG_TypePrettyName(ty); printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown")); } #endif } Py_XDECREF(next); PyObject_DEL(v); } SWIGRUNTIME PyObject* SwigPyObject_append(PyObject* v, PyObject* next) { SwigPyObject *sobj = (SwigPyObject *) v; #ifndef METH_O PyObject *tmp = 0; if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL; next = tmp; #endif if (!SwigPyObject_Check(next)) { return NULL; } sobj->next = next; Py_INCREF(next); return SWIG_Py_Void(); } SWIGRUNTIME PyObject* #ifdef METH_NOARGS SwigPyObject_next(PyObject* v) #else SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) #endif { SwigPyObject *sobj = (SwigPyObject *) v; if (sobj->next) { Py_INCREF(sobj->next); return sobj->next; } else { return SWIG_Py_Void(); } } SWIGINTERN PyObject* #ifdef METH_NOARGS SwigPyObject_disown(PyObject *v) #else SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) #endif { SwigPyObject *sobj = (SwigPyObject *)v; sobj->own = 0; return SWIG_Py_Void(); } SWIGINTERN PyObject* #ifdef METH_NOARGS SwigPyObject_acquire(PyObject *v) #else SwigPyObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) #endif { SwigPyObject *sobj = (SwigPyObject *)v; sobj->own = SWIG_POINTER_OWN; return SWIG_Py_Void(); } SWIGINTERN PyObject* SwigPyObject_own(PyObject *v, PyObject *args) { PyObject *val = 0; #if (PY_VERSION_HEX < 0x02020000) if (!PyArg_ParseTuple(args,(char *)"|O:own",&val)) #else if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val)) #endif { return NULL; } else { SwigPyObject *sobj = (SwigPyObject *)v; PyObject *obj = PyBool_FromLong(sobj->own); if (val) { #ifdef METH_NOARGS if (PyObject_IsTrue(val)) { SwigPyObject_acquire(v); } else { SwigPyObject_disown(v); } #else if (PyObject_IsTrue(val)) { SwigPyObject_acquire(v,args); } else { SwigPyObject_disown(v,args); } #endif } return obj; } } #ifdef METH_O static PyMethodDef swigobject_methods[] = { {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"}, {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_NOARGS, (char *)"aquires ownership of the pointer"}, {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, {(char *)"append", (PyCFunction)SwigPyObject_append, METH_O, (char *)"appends another 'this' object"}, {(char *)"next", (PyCFunction)SwigPyObject_next, METH_NOARGS, (char *)"returns the next 'this' object"}, {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_NOARGS, (char *)"returns object representation"}, {0, 0, 0, 0} }; #else static PyMethodDef swigobject_methods[] = { {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"}, {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_VARARGS, (char *)"aquires ownership of the pointer"}, {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, {(char *)"append", (PyCFunction)SwigPyObject_append, METH_VARARGS, (char *)"appends another 'this' object"}, {(char *)"next", (PyCFunction)SwigPyObject_next, METH_VARARGS, (char *)"returns the next 'this' object"}, {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_VARARGS, (char *)"returns object representation"}, {0, 0, 0, 0} }; #endif #if PY_VERSION_HEX < 0x02020000 SWIGINTERN PyObject * SwigPyObject_getattr(SwigPyObject *sobj,char *name) { return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name); } #endif SWIGRUNTIME PyTypeObject* _PySwigObject_type(void) { static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer"; static PyNumberMethods SwigPyObject_as_number = { (binaryfunc)0, /*nb_add*/ (binaryfunc)0, /*nb_subtract*/ (binaryfunc)0, /*nb_multiply*/ /* nb_divide removed in Python 3 */ #if PY_VERSION_HEX < 0x03000000 (binaryfunc)0, /*nb_divide*/ #endif (binaryfunc)0, /*nb_remainder*/ (binaryfunc)0, /*nb_divmod*/ (ternaryfunc)0,/*nb_power*/ (unaryfunc)0, /*nb_negative*/ (unaryfunc)0, /*nb_positive*/ (unaryfunc)0, /*nb_absolute*/ (inquiry)0, /*nb_nonzero*/ 0, /*nb_invert*/ 0, /*nb_lshift*/ 0, /*nb_rshift*/ 0, /*nb_and*/ 0, /*nb_xor*/ 0, /*nb_or*/ #if PY_VERSION_HEX < 0x03000000 0, /*nb_coerce*/ #endif (unaryfunc)SwigPyObject_long, /*nb_int*/ #if PY_VERSION_HEX < 0x03000000 (unaryfunc)SwigPyObject_long, /*nb_long*/ #else 0, /*nb_reserved*/ #endif (unaryfunc)0, /*nb_float*/ #if PY_VERSION_HEX < 0x03000000 (unaryfunc)SwigPyObject_oct, /*nb_oct*/ (unaryfunc)SwigPyObject_hex, /*nb_hex*/ #endif #if PY_VERSION_HEX >= 0x03000000 /* 3.0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */ #elif PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */ #elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */ #elif PY_VERSION_HEX >= 0x02000000 /* 2.0.0 */ 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */ #endif }; static PyTypeObject swigpyobject_type; static int type_init = 0; if (!type_init) { const PyTypeObject tmp = { /* PyOjbect header changed in Python 3 */ #if PY_VERSION_HEX >= 0x03000000 PyVarObject_HEAD_INIT(&PyType_Type, 0) #else PyObject_HEAD_INIT(NULL) 0, /* ob_size */ #endif (char *)"SwigPyObject", /* tp_name */ sizeof(SwigPyObject), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor)SwigPyObject_dealloc, /* tp_dealloc */ (printfunc)SwigPyObject_print, /* tp_print */ #if PY_VERSION_HEX < 0x02020000 (getattrfunc)SwigPyObject_getattr, /* tp_getattr */ #else (getattrfunc)0, /* tp_getattr */ #endif (setattrfunc)0, /* tp_setattr */ #if PY_VERSION_HEX >= 0x03000000 0, /* tp_reserved in 3.0.1 */ #else (cmpfunc)SwigPyObject_compare, /* tp_compare */ #endif (reprfunc)SwigPyObject_repr, /* tp_repr */ &SwigPyObject_as_number, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ (hashfunc)0, /* tp_hash */ (ternaryfunc)0, /* tp_call */ (reprfunc)SwigPyObject_str, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT, /* tp_flags */ swigobject_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ (richcmpfunc)SwigPyObject_richcompare, /* tp_richcompare */ 0, /* tp_weaklistoffset */ #if PY_VERSION_HEX >= 0x02020000 0, /* tp_iter */ 0, /* tp_iternext */ swigobject_methods, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ 0, /* tp_new */ 0, /* tp_free */ 0, /* tp_is_gc */ 0, /* tp_bases */ 0, /* tp_mro */ 0, /* tp_cache */ 0, /* tp_subclasses */ 0, /* tp_weaklist */ #endif #if PY_VERSION_HEX >= 0x02030000 0, /* tp_del */ #endif #ifdef COUNT_ALLOCS 0,0,0,0 /* tp_alloc -> tp_next */ #endif }; swigpyobject_type = tmp; /* for Python 3 we already assigned the ob_type in PyVarObject_HEAD_INIT() */ #if PY_VERSION_HEX < 0x03000000 swigpyobject_type.ob_type = &PyType_Type; #endif type_init = 1; } return &swigpyobject_type; } SWIGRUNTIME PyObject * SwigPyObject_New(void *ptr, swig_type_info *ty, int own) { SwigPyObject *sobj = PyObject_NEW(SwigPyObject, SwigPyObject_type()); if (sobj) { sobj->ptr = ptr; sobj->ty = ty; sobj->own = own; sobj->next = 0; } return (PyObject *)sobj; } /* ----------------------------------------------------------------------------- * Implements a simple Swig Packed type, and use it instead of string * ----------------------------------------------------------------------------- */ typedef struct { PyObject_HEAD void *pack; swig_type_info *ty; size_t size; } SwigPyPacked; SWIGRUNTIME int SwigPyPacked_print(SwigPyPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags)) { char result[SWIG_BUFFER_SIZE]; fputs("pack, v->size, 0, sizeof(result))) { fputs("at ", fp); fputs(result, fp); } fputs(v->ty->name,fp); fputs(">", fp); return 0; } SWIGRUNTIME PyObject * SwigPyPacked_repr(SwigPyPacked *v) { char result[SWIG_BUFFER_SIZE]; if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { return SWIG_Python_str_FromFormat("", result, v->ty->name); } else { return SWIG_Python_str_FromFormat("", v->ty->name); } } SWIGRUNTIME PyObject * SwigPyPacked_str(SwigPyPacked *v) { char result[SWIG_BUFFER_SIZE]; if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){ return SWIG_Python_str_FromFormat("%s%s", result, v->ty->name); } else { return SWIG_Python_str_FromChar(v->ty->name); } } SWIGRUNTIME int SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w) { size_t i = v->size; size_t j = w->size; int s = (i < j) ? -1 : ((i > j) ? 1 : 0); return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size); } SWIGRUNTIME PyTypeObject* _PySwigPacked_type(void); SWIGRUNTIME PyTypeObject* SwigPyPacked_type(void) { static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigPacked_type(); return type; } SWIGRUNTIMEINLINE int SwigPyPacked_Check(PyObject *op) { return ((op)->ob_type == _PySwigPacked_type()) || (strcmp((op)->ob_type->tp_name,"SwigPyPacked") == 0); } SWIGRUNTIME void SwigPyPacked_dealloc(PyObject *v) { if (SwigPyPacked_Check(v)) { SwigPyPacked *sobj = (SwigPyPacked *) v; free(sobj->pack); } PyObject_DEL(v); } SWIGRUNTIME PyTypeObject* _PySwigPacked_type(void) { static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer"; static PyTypeObject swigpypacked_type; static int type_init = 0; if (!type_init) { const PyTypeObject tmp = { /* PyObject header changed in Python 3 */ #if PY_VERSION_HEX>=0x03000000 PyVarObject_HEAD_INIT(&PyType_Type, 0) #else PyObject_HEAD_INIT(NULL) 0, /* ob_size */ #endif (char *)"SwigPyPacked", /* tp_name */ sizeof(SwigPyPacked), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor)SwigPyPacked_dealloc, /* tp_dealloc */ (printfunc)SwigPyPacked_print, /* tp_print */ (getattrfunc)0, /* tp_getattr */ (setattrfunc)0, /* tp_setattr */ #if PY_VERSION_HEX>=0x03000000 0, /* tp_reserved in 3.0.1 */ #else (cmpfunc)SwigPyPacked_compare, /* tp_compare */ #endif (reprfunc)SwigPyPacked_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ (hashfunc)0, /* tp_hash */ (ternaryfunc)0, /* tp_call */ (reprfunc)SwigPyPacked_str, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT, /* tp_flags */ swigpacked_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ #if PY_VERSION_HEX >= 0x02020000 0, /* tp_iter */ 0, /* tp_iternext */ 0, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ 0, /* tp_new */ 0, /* tp_free */ 0, /* tp_is_gc */ 0, /* tp_bases */ 0, /* tp_mro */ 0, /* tp_cache */ 0, /* tp_subclasses */ 0, /* tp_weaklist */ #endif #if PY_VERSION_HEX >= 0x02030000 0, /* tp_del */ #endif #ifdef COUNT_ALLOCS 0,0,0,0 /* tp_alloc -> tp_next */ #endif }; swigpypacked_type = tmp; /* for Python 3 the ob_type already assigned in PyVarObject_HEAD_INIT() */ #if PY_VERSION_HEX < 0x03000000 swigpypacked_type.ob_type = &PyType_Type; #endif type_init = 1; } return &swigpypacked_type; } SWIGRUNTIME PyObject * SwigPyPacked_New(void *ptr, size_t size, swig_type_info *ty) { SwigPyPacked *sobj = PyObject_NEW(SwigPyPacked, SwigPyPacked_type()); if (sobj) { void *pack = malloc(size); if (pack) { memcpy(pack, ptr, size); sobj->pack = pack; sobj->ty = ty; sobj->size = size; } else { PyObject_DEL((PyObject *) sobj); sobj = 0; } } return (PyObject *) sobj; } SWIGRUNTIME swig_type_info * SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size) { if (SwigPyPacked_Check(obj)) { SwigPyPacked *sobj = (SwigPyPacked *)obj; if (sobj->size != size) return 0; memcpy(ptr, sobj->pack, size); return sobj->ty; } else { return 0; } } /* ----------------------------------------------------------------------------- * pointers/data manipulation * ----------------------------------------------------------------------------- */ SWIGRUNTIMEINLINE PyObject * _SWIG_This(void) { return SWIG_Python_str_FromChar("this"); } SWIGRUNTIME PyObject * SWIG_This(void) { static PyObject *SWIG_STATIC_POINTER(swig_this) = _SWIG_This(); return swig_this; } /* #define SWIG_PYTHON_SLOW_GETSET_THIS */ /* TODO: I don't know how to implement the fast getset in Python 3 right now */ #if PY_VERSION_HEX>=0x03000000 #define SWIG_PYTHON_SLOW_GETSET_THIS #endif SWIGRUNTIME SwigPyObject * SWIG_Python_GetSwigThis(PyObject *pyobj) { if (SwigPyObject_Check(pyobj)) { return (SwigPyObject *) pyobj; } else { PyObject *obj = 0; #if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000)) if (PyInstance_Check(pyobj)) { obj = _PyInstance_Lookup(pyobj, SWIG_This()); } else { PyObject **dictptr = _PyObject_GetDictPtr(pyobj); if (dictptr != NULL) { PyObject *dict = *dictptr; obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0; } else { #ifdef PyWeakref_CheckProxy if (PyWeakref_CheckProxy(pyobj)) { PyObject *wobj = PyWeakref_GET_OBJECT(pyobj); return wobj ? SWIG_Python_GetSwigThis(wobj) : 0; } #endif obj = PyObject_GetAttr(pyobj,SWIG_This()); if (obj) { Py_DECREF(obj); } else { if (PyErr_Occurred()) PyErr_Clear(); return 0; } } } #else obj = PyObject_GetAttr(pyobj,SWIG_This()); if (obj) { Py_DECREF(obj); } else { if (PyErr_Occurred()) PyErr_Clear(); return 0; } #endif if (obj && !SwigPyObject_Check(obj)) { /* a PyObject is called 'this', try to get the 'real this' SwigPyObject from it */ return SWIG_Python_GetSwigThis(obj); } return (SwigPyObject *)obj; } } /* Acquire a pointer value */ SWIGRUNTIME int SWIG_Python_AcquirePtr(PyObject *obj, int own) { if (own == SWIG_POINTER_OWN) { SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj); if (sobj) { int oldown = sobj->own; sobj->own = own; return oldown; } } return 0; } /* Convert a pointer value */ SWIGRUNTIME int SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) { if (!obj) return SWIG_ERROR; if (obj == Py_None) { if (ptr) *ptr = 0; return SWIG_OK; } else { SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj); if (own) *own = 0; while (sobj) { void *vptr = sobj->ptr; if (ty) { swig_type_info *to = sobj->ty; if (to == ty) { /* no type cast needed */ if (ptr) *ptr = vptr; break; } else { swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); if (!tc) { sobj = (SwigPyObject *)sobj->next; } else { if (ptr) { int newmemory = 0; *ptr = SWIG_TypeCast(tc,vptr,&newmemory); if (newmemory == SWIG_CAST_NEW_MEMORY) { assert(own); if (own) *own = *own | SWIG_CAST_NEW_MEMORY; } } break; } } } else { if (ptr) *ptr = vptr; break; } } if (sobj) { if (own) *own = *own | sobj->own; if (flags & SWIG_POINTER_DISOWN) { sobj->own = 0; } return SWIG_OK; } else { int res = SWIG_ERROR; if (flags & SWIG_POINTER_IMPLICIT_CONV) { SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; if (data && !data->implicitconv) { PyObject *klass = data->klass; if (klass) { PyObject *impconv; data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/ impconv = SWIG_Python_CallFunctor(klass, obj); data->implicitconv = 0; if (PyErr_Occurred()) { PyErr_Clear(); impconv = 0; } if (impconv) { SwigPyObject *iobj = SWIG_Python_GetSwigThis(impconv); if (iobj) { void *vptr; res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0); if (SWIG_IsOK(res)) { if (ptr) { *ptr = vptr; /* transfer the ownership to 'ptr' */ iobj->own = 0; res = SWIG_AddCast(res); res = SWIG_AddNewMask(res); } else { res = SWIG_AddCast(res); } } } Py_DECREF(impconv); } } } } return res; } } } /* Convert a function ptr value */ SWIGRUNTIME int SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) { if (!PyCFunction_Check(obj)) { return SWIG_ConvertPtr(obj, ptr, ty, 0); } else { void *vptr = 0; /* here we get the method pointer for callbacks */ const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0; if (desc) { desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0; if (!desc) return SWIG_ERROR; } if (ty) { swig_cast_info *tc = SWIG_TypeCheck(desc,ty); if (tc) { int newmemory = 0; *ptr = SWIG_TypeCast(tc,vptr,&newmemory); assert(!newmemory); /* newmemory handling not yet implemented */ } else { return SWIG_ERROR; } } else { *ptr = vptr; } return SWIG_OK; } } /* Convert a packed value value */ SWIGRUNTIME int SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) { swig_type_info *to = SwigPyPacked_UnpackData(obj, ptr, sz); if (!to) return SWIG_ERROR; if (ty) { if (to != ty) { /* check type cast? */ swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); if (!tc) return SWIG_ERROR; } } return SWIG_OK; } /* ----------------------------------------------------------------------------- * Create a new pointer object * ----------------------------------------------------------------------------- */ /* Create a new instance object, whitout calling __init__, and set the 'this' attribute. */ SWIGRUNTIME PyObject* SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) { #if (PY_VERSION_HEX >= 0x02020000) PyObject *inst = 0; PyObject *newraw = data->newraw; if (newraw) { inst = PyObject_Call(newraw, data->newargs, NULL); if (inst) { #if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) PyObject **dictptr = _PyObject_GetDictPtr(inst); if (dictptr != NULL) { PyObject *dict = *dictptr; if (dict == NULL) { dict = PyDict_New(); *dictptr = dict; PyDict_SetItem(dict, SWIG_This(), swig_this); } } #else PyObject *key = SWIG_This(); PyObject_SetAttr(inst, key, swig_this); #endif } } else { #if PY_VERSION_HEX >= 0x03000000 inst = PyBaseObject_Type.tp_new((PyTypeObject*) data->newargs, Py_None, Py_None); PyObject_SetAttr(inst, SWIG_This(), swig_this); Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG; #else PyObject *dict = PyDict_New(); PyDict_SetItem(dict, SWIG_This(), swig_this); inst = PyInstance_NewRaw(data->newargs, dict); Py_DECREF(dict); #endif } return inst; #else #if (PY_VERSION_HEX >= 0x02010000) PyObject *inst; PyObject *dict = PyDict_New(); PyDict_SetItem(dict, SWIG_This(), swig_this); inst = PyInstance_NewRaw(data->newargs, dict); Py_DECREF(dict); return (PyObject *) inst; #else PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type); if (inst == NULL) { return NULL; } inst->in_class = (PyClassObject *)data->newargs; Py_INCREF(inst->in_class); inst->in_dict = PyDict_New(); if (inst->in_dict == NULL) { Py_DECREF(inst); return NULL; } #ifdef Py_TPFLAGS_HAVE_WEAKREFS inst->in_weakreflist = NULL; #endif #ifdef Py_TPFLAGS_GC PyObject_GC_Init(inst); #endif PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this); return (PyObject *) inst; #endif #endif } SWIGRUNTIME void SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) { PyObject *dict; #if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS) PyObject **dictptr = _PyObject_GetDictPtr(inst); if (dictptr != NULL) { dict = *dictptr; if (dict == NULL) { dict = PyDict_New(); *dictptr = dict; } PyDict_SetItem(dict, SWIG_This(), swig_this); return; } #endif dict = PyObject_GetAttrString(inst, (char*)"__dict__"); PyDict_SetItem(dict, SWIG_This(), swig_this); Py_DECREF(dict); } SWIGINTERN PyObject * SWIG_Python_InitShadowInstance(PyObject *args) { PyObject *obj[2]; if (!SWIG_Python_UnpackTuple(args,(char*)"swiginit", 2, 2, obj)) { return NULL; } else { SwigPyObject *sthis = SWIG_Python_GetSwigThis(obj[0]); if (sthis) { SwigPyObject_append((PyObject*) sthis, obj[1]); } else { SWIG_Python_SetSwigThis(obj[0], obj[1]); } return SWIG_Py_Void(); } } /* Create a new pointer object */ SWIGRUNTIME PyObject * SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int flags) { if (!ptr) { return SWIG_Py_Void(); } else { int own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0; PyObject *robj = SwigPyObject_New(ptr, type, own); SwigPyClientData *clientdata = type ? (SwigPyClientData *)(type->clientdata) : 0; if (clientdata && !(flags & SWIG_POINTER_NOSHADOW)) { PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj); if (inst) { Py_DECREF(robj); robj = inst; } } return robj; } } /* Create a new packed object */ SWIGRUNTIMEINLINE PyObject * SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { return ptr ? SwigPyPacked_New((void *) ptr, sz, type) : SWIG_Py_Void(); } /* -----------------------------------------------------------------------------* * Get type list * -----------------------------------------------------------------------------*/ #ifdef SWIG_LINK_RUNTIME void *SWIG_ReturnGlobalTypeList(void *); #endif SWIGRUNTIME swig_module_info * SWIG_Python_GetModule(void) { static void *type_pointer = (void *)0; /* first check if module already created */ if (!type_pointer) { #ifdef SWIG_LINK_RUNTIME type_pointer = SWIG_ReturnGlobalTypeList((void *)0); #else type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME); if (PyErr_Occurred()) { PyErr_Clear(); type_pointer = (void *)0; } #endif } return (swig_module_info *) type_pointer; } #if PY_MAJOR_VERSION < 2 /* PyModule_AddObject function was introduced in Python 2.0. The following function is copied out of Python/modsupport.c in python version 2.3.4 */ SWIGINTERN int PyModule_AddObject(PyObject *m, char *name, PyObject *o) { PyObject *dict; if (!PyModule_Check(m)) { PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs module as first arg"); return SWIG_ERROR; } if (!o) { PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs non-NULL value"); return SWIG_ERROR; } dict = PyModule_GetDict(m); if (dict == NULL) { /* Internal error -- modules must have a dict! */ PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__", PyModule_GetName(m)); return SWIG_ERROR; } if (PyDict_SetItemString(dict, name, o)) return SWIG_ERROR; Py_DECREF(o); return SWIG_OK; } #endif SWIGRUNTIME void SWIG_Python_DestroyModule(void *vptr) { swig_module_info *swig_module = (swig_module_info *) vptr; swig_type_info **types = swig_module->types; size_t i; for (i =0; i < swig_module->size; ++i) { swig_type_info *ty = types[i]; if (ty->owndata) { SwigPyClientData *data = (SwigPyClientData *) ty->clientdata; if (data) SwigPyClientData_Del(data); } } Py_DECREF(SWIG_This()); } SWIGRUNTIME void SWIG_Python_SetModule(swig_module_info *swig_module) { static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} };/* Sentinel */ #if PY_VERSION_HEX >= 0x03000000 /* Add a dummy module object into sys.modules */ PyObject *module = PyImport_AddModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION); #else PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table); #endif PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule); if (pointer && module) { PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer); } else { Py_XDECREF(pointer); } } /* The python cached type query */ SWIGRUNTIME PyObject * SWIG_Python_TypeCache(void) { static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New(); return cache; } SWIGRUNTIME swig_type_info * SWIG_Python_TypeQuery(const char *type) { PyObject *cache = SWIG_Python_TypeCache(); PyObject *key = SWIG_Python_str_FromChar(type); PyObject *obj = PyDict_GetItem(cache, key); swig_type_info *descriptor; if (obj) { descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj); } else { swig_module_info *swig_module = SWIG_Python_GetModule(); descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type); if (descriptor) { obj = PyCObject_FromVoidPtr(descriptor, NULL); PyDict_SetItem(cache, key, obj); Py_DECREF(obj); } } Py_DECREF(key); return descriptor; } /* For backward compatibility only */ #define SWIG_POINTER_EXCEPTION 0 #define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg) #define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags) SWIGRUNTIME int SWIG_Python_AddErrMesg(const char* mesg, int infront) { if (PyErr_Occurred()) { PyObject *type = 0; PyObject *value = 0; PyObject *traceback = 0; PyErr_Fetch(&type, &value, &traceback); if (value) { char *tmp; PyObject *old_str = PyObject_Str(value); Py_XINCREF(type); PyErr_Clear(); if (infront) { PyErr_Format(type, "%s %s", mesg, tmp = SWIG_Python_str_AsChar(old_str)); } else { PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg); } SWIG_Python_str_DelForPy3(tmp); Py_DECREF(old_str); } return 1; } else { return 0; } } SWIGRUNTIME int SWIG_Python_ArgFail(int argnum) { if (PyErr_Occurred()) { /* add information about failing argument */ char mesg[256]; PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum); return SWIG_Python_AddErrMesg(mesg, 1); } else { return 0; } } SWIGRUNTIMEINLINE const char * SwigPyObject_GetDesc(PyObject *self) { SwigPyObject *v = (SwigPyObject *)self; swig_type_info *ty = v ? v->ty : 0; return ty ? ty->str : (char*)""; } SWIGRUNTIME void SWIG_Python_TypeError(const char *type, PyObject *obj) { if (type) { #if defined(SWIG_COBJECT_TYPES) if (obj && SwigPyObject_Check(obj)) { const char *otype = (const char *) SwigPyObject_GetDesc(obj); if (otype) { PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'SwigPyObject(%s)' is received", type, otype); return; } } else #endif { const char *otype = (obj ? obj->ob_type->tp_name : 0); if (otype) { PyObject *str = PyObject_Str(obj); const char *cstr = str ? SWIG_Python_str_AsChar(str) : 0; if (cstr) { PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", type, otype, cstr); SWIG_Python_str_DelForPy3(cstr); } else { PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", type, otype); } Py_XDECREF(str); return; } } PyErr_Format(PyExc_TypeError, "a '%s' is expected", type); } else { PyErr_Format(PyExc_TypeError, "unexpected type is received"); } } /* Convert a pointer value, signal an exception on a type mismatch */ SWIGRUNTIME void * SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) { void *result; if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) { PyErr_Clear(); #if SWIG_POINTER_EXCEPTION if (flags) { SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); SWIG_Python_ArgFail(argnum); } #endif } return result; } #ifdef __cplusplus #if 0 { /* cc-mode */ #endif } #endif #define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0) #define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else /* -------- TYPES TABLE (BEGIN) -------- */ #define SWIGTYPE_p_XdmfArray swig_types[0] #define SWIGTYPE_p_XdmfArrayList swig_types[1] #define SWIGTYPE_p_XdmfAttribute swig_types[2] #define SWIGTYPE_p_XdmfCloseCallback swig_types[3] #define SWIGTYPE_p_XdmfDOM swig_types[4] #define SWIGTYPE_p_XdmfDataDesc swig_types[5] #define SWIGTYPE_p_XdmfDataItem swig_types[6] #define SWIGTYPE_p_XdmfDataStructure swig_types[7] #define SWIGTYPE_p_XdmfDomain swig_types[8] #define SWIGTYPE_p_XdmfDsm swig_types[9] #define SWIGTYPE_p_XdmfDsmBuffer swig_types[10] #define SWIGTYPE_p_XdmfDsmComm swig_types[11] #define SWIGTYPE_p_XdmfDsmMsg swig_types[12] #define SWIGTYPE_p_XdmfElement swig_types[13] #define SWIGTYPE_p_XdmfGeometry swig_types[14] #define SWIGTYPE_p_XdmfGrid swig_types[15] #define SWIGTYPE_p_XdmfHDF swig_types[16] #define SWIGTYPE_p_XdmfHeavyData swig_types[17] #define SWIGTYPE_p_XdmfInformation swig_types[18] #define SWIGTYPE_p_XdmfLightData swig_types[19] #define SWIGTYPE_p_XdmfMap swig_types[20] #define SWIGTYPE_p_XdmfObject swig_types[21] #define SWIGTYPE_p_XdmfOpenCallback swig_types[22] #define SWIGTYPE_p_XdmfReadCallback swig_types[23] #define SWIGTYPE_p_XdmfRegion swig_types[24] #define SWIGTYPE_p_XdmfRoot swig_types[25] #define SWIGTYPE_p_XdmfSet swig_types[26] #define SWIGTYPE_p_XdmfTime swig_types[27] #define SWIGTYPE_p_XdmfTopology swig_types[28] #define SWIGTYPE_p_XdmfValues swig_types[29] #define SWIGTYPE_p_XdmfValuesHDF swig_types[30] #define SWIGTYPE_p_XdmfValuesXML swig_types[31] #define SWIGTYPE_p_XdmfWriteCallback swig_types[32] #define SWIGTYPE_p__xmlNode swig_types[33] #define SWIGTYPE_p_char swig_types[34] #define SWIGTYPE_p_double swig_types[35] #define SWIGTYPE_p_float swig_types[36] #define SWIGTYPE_p_hid_t swig_types[37] #define SWIGTYPE_p_int swig_types[38] #define SWIGTYPE_p_istream swig_types[39] #define SWIGTYPE_p_long_long swig_types[40] #define SWIGTYPE_p_ostream swig_types[41] #define SWIGTYPE_p_p__xmlDoc swig_types[42] #define SWIGTYPE_p_short swig_types[43] #define SWIGTYPE_p_unsigned_char swig_types[44] #define SWIGTYPE_p_unsigned_int swig_types[45] #define SWIGTYPE_p_unsigned_short swig_types[46] #define SWIGTYPE_p_void swig_types[47] static swig_type_info *swig_types[49]; static swig_module_info swig_module = {swig_types, 48, 0, 0, 0, 0}; #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) /* -------- TYPES TABLE (END) -------- */ #if (PY_VERSION_HEX <= 0x02000000) # if !defined(SWIG_PYTHON_CLASSIC) # error "This python version requires swig to be run with the '-classic' option" # endif #endif /*----------------------------------------------- @(target):= _Xdmf.so ------------------------------------------------*/ #if PY_VERSION_HEX >= 0x03000000 # define SWIG_init PyInit__Xdmf #else # define SWIG_init init_Xdmf #endif #define SWIG_name "_Xdmf" #define SWIGVERSION 0x010339 #define SWIG_VERSION SWIGVERSION #define SWIG_as_voidptr(a) const_cast< void * >(static_cast< const void * >(a)) #define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),reinterpret_cast< void** >(a)) #include namespace swig { class SwigPtr_PyObject { protected: PyObject *_obj; public: SwigPtr_PyObject() :_obj(0) { } SwigPtr_PyObject(const SwigPtr_PyObject& item) : _obj(item._obj) { Py_XINCREF(_obj); } SwigPtr_PyObject(PyObject *obj, bool initial_ref = true) :_obj(obj) { if (initial_ref) { Py_XINCREF(_obj); } } SwigPtr_PyObject & operator=(const SwigPtr_PyObject& item) { Py_XINCREF(item._obj); Py_XDECREF(_obj); _obj = item._obj; return *this; } ~SwigPtr_PyObject() { Py_XDECREF(_obj); } operator PyObject *() const { return _obj; } PyObject *operator->() const { return _obj; } }; } namespace swig { struct SwigVar_PyObject : SwigPtr_PyObject { SwigVar_PyObject(PyObject* obj = 0) : SwigPtr_PyObject(obj, false) { } SwigVar_PyObject & operator = (PyObject* obj) { Py_XDECREF(_obj); _obj = obj; return *this; } }; } /* #include */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* #include #include #include #include */ #include #include #include #include #include #include #include #include #include #include /* #include #include #include #include */ #include #include #include #include #ifndef XDMF_NO_MPI #include #endif #ifndef HAVE_STRTOLL # define strtoll XDMF_strtoll inline XDMF_LONG64 XDMF_strtoll(char *str, void*, int) { XDMF_LONG64 result = 0; int negative=0; while (*str == ' ' || *str == '\t') { str++; } if (*str == '+') { str++; } else if (*str == '-') { negative = 1; str++; } while (*str >= '0' && *str <= '9') { result = (result*10)-(*str++ - '0'); } return negative ? result : -result; } #else # define XDMF_strtoll strtoll #endif #include #define SWIG_From_long PyInt_FromLong SWIGINTERNINLINE PyObject * SWIG_From_int (int value) { return SWIG_From_long (value); } #define SWIG_From_double PyFloat_FromDouble SWIGINTERN swig_type_info* SWIG_pchar_descriptor(void) { static int init = 0; static swig_type_info* info = 0; if (!init) { info = SWIG_TypeQuery("_p_char"); init = 1; } return info; } SWIGINTERNINLINE PyObject * SWIG_FromCharPtrAndSize(const char* carray, size_t size) { if (carray) { if (size > INT_MAX) { swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); return pchar_descriptor ? SWIG_NewPointerObj(const_cast< char * >(carray), pchar_descriptor, 0) : SWIG_Py_Void(); } else { #if PY_VERSION_HEX >= 0x03000000 return PyUnicode_FromStringAndSize(carray, static_cast< int >(size)); #else return PyString_FromStringAndSize(carray, static_cast< int >(size)); #endif } } else { return SWIG_Py_Void(); } } SWIGINTERNINLINE PyObject * SWIG_FromCharPtr(const char *cptr) { return SWIG_FromCharPtrAndSize(cptr, (cptr ? strlen(cptr) : 0)); } #include #if !defined(SWIG_NO_LLONG_MAX) # if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__) # define LLONG_MAX __LONG_LONG_MAX__ # define LLONG_MIN (-LLONG_MAX - 1LL) # define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL) # endif #endif SWIGINTERN int SWIG_AsVal_double (PyObject *obj, double *val) { int res = SWIG_TypeError; if (PyFloat_Check(obj)) { if (val) *val = PyFloat_AsDouble(obj); return SWIG_OK; } else if (PyInt_Check(obj)) { if (val) *val = PyInt_AsLong(obj); return SWIG_OK; } else if (PyLong_Check(obj)) { double v = PyLong_AsDouble(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_OK; } else { PyErr_Clear(); } } #ifdef SWIG_PYTHON_CAST_MODE { int dispatch = 0; double d = PyFloat_AsDouble(obj); if (!PyErr_Occurred()) { if (val) *val = d; return SWIG_AddCast(SWIG_OK); } else { PyErr_Clear(); } if (!dispatch) { long v = PyLong_AsLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_AddCast(SWIG_AddCast(SWIG_OK)); } else { PyErr_Clear(); } } } #endif return res; } #include #include SWIGINTERNINLINE int SWIG_CanCastAsInteger(double *d, double min, double max) { double x = *d; if ((min <= x && x <= max)) { double fx = floor(x); double cx = ceil(x); double rd = ((x - fx) < 0.5) ? fx : cx; /* simple rint */ if ((errno == EDOM) || (errno == ERANGE)) { errno = 0; } else { double summ, reps, diff; if (rd < x) { diff = x - rd; } else if (rd > x) { diff = rd - x; } else { return 1; } summ = rd + x; reps = diff/summ; if (reps < 8*DBL_EPSILON) { *d = rd; return 1; } } } return 0; } SWIGINTERN int SWIG_AsVal_long (PyObject *obj, long* val) { if (PyInt_Check(obj)) { if (val) *val = PyInt_AsLong(obj); return SWIG_OK; } else if (PyLong_Check(obj)) { long v = PyLong_AsLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_OK; } else { PyErr_Clear(); } } #ifdef SWIG_PYTHON_CAST_MODE { int dispatch = 0; long v = PyInt_AsLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_AddCast(SWIG_OK); } else { PyErr_Clear(); } if (!dispatch) { double d; int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d)); if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) { if (val) *val = (long)(d); return res; } } } #endif return SWIG_TypeError; } SWIGINTERN int SWIG_AsVal_int (PyObject * obj, int *val) { long v; int res = SWIG_AsVal_long (obj, &v); if (SWIG_IsOK(res)) { if ((v < INT_MIN || v > INT_MAX)) { return SWIG_OverflowError; } else { if (val) *val = static_cast< int >(v); } } return res; } SWIGINTERN int SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) { #if PY_VERSION_HEX>=0x03000000 if (PyUnicode_Check(obj)) #else if (PyString_Check(obj)) #endif { char *cstr; Py_ssize_t len; #if PY_VERSION_HEX>=0x03000000 if (!alloc && cptr) { /* We can't allow converting without allocation, since the internal representation of string in Python 3 is UCS-2/UCS-4 but we require a UTF-8 representation. TODO(bhy) More detailed explanation */ return SWIG_RuntimeError; } obj = PyUnicode_AsUTF8String(obj); PyBytes_AsStringAndSize(obj, &cstr, &len); if(alloc) *alloc = SWIG_NEWOBJ; #else PyString_AsStringAndSize(obj, &cstr, &len); #endif if (cptr) { if (alloc) { /* In python the user should not be able to modify the inner string representation. To warranty that, if you define SWIG_PYTHON_SAFE_CSTRINGS, a new/copy of the python string buffer is always returned. The default behavior is just to return the pointer value, so, be careful. */ #if defined(SWIG_PYTHON_SAFE_CSTRINGS) if (*alloc != SWIG_OLDOBJ) #else if (*alloc == SWIG_NEWOBJ) #endif { *cptr = reinterpret_cast< char* >(memcpy((new char[len + 1]), cstr, sizeof(char)*(len + 1))); *alloc = SWIG_NEWOBJ; } else { *cptr = cstr; *alloc = SWIG_OLDOBJ; } } else { #if PY_VERSION_HEX>=0x03000000 assert(0); /* Should never reach here in Python 3 */ #endif *cptr = SWIG_Python_str_AsChar(obj); } } if (psize) *psize = len + 1; #if PY_VERSION_HEX>=0x03000000 Py_XDECREF(obj); #endif return SWIG_OK; } else { swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); if (pchar_descriptor) { void* vptr = 0; if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) { if (cptr) *cptr = (char *) vptr; if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0; if (alloc) *alloc = SWIG_OLDOBJ; return SWIG_OK; } } } return SWIG_TypeError; } SWIGINTERN int SWIG_AsVal_long_SS_long (PyObject *obj, long long *val) { int res = SWIG_TypeError; if (PyLong_Check(obj)) { long long v = PyLong_AsLongLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_OK; } else { PyErr_Clear(); } } else { long v; res = SWIG_AsVal_long (obj,&v); if (SWIG_IsOK(res)) { if (val) *val = v; return res; } } #ifdef SWIG_PYTHON_CAST_MODE { const double mant_max = 1LL << DBL_MANT_DIG; const double mant_min = -mant_max; double d; res = SWIG_AsVal_double (obj,&d); if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, mant_min, mant_max)) { if (val) *val = (long long)(d); return SWIG_AddCast(res); } res = SWIG_TypeError; } #endif return res; } SWIGINTERNINLINE PyObject* SWIG_From_long_SS_long (long long value) { return ((value < LONG_MIN) || (value > LONG_MAX)) ? PyLong_FromLongLong(value) : PyInt_FromLong(static_cast< long >(value)); } SWIGINTERNINLINE PyObject * SWIG_From_float (float value) { return SWIG_From_double (value); } SWIGINTERNINLINE PyObject * SWIG_From_short (short value) { return SWIG_From_long (value); } SWIGINTERNINLINE PyObject * SWIG_From_char (char c) { return SWIG_FromCharPtrAndSize(&c,1); } SWIGINTERN int SWIG_AsVal_float (PyObject * obj, float *val) { double v; int res = SWIG_AsVal_double (obj, &v); if (SWIG_IsOK(res)) { if ((v < -FLT_MAX || v > FLT_MAX)) { return SWIG_OverflowError; } else { if (val) *val = static_cast< float >(v); } } return res; } void XdmfSwigException(int code, const char* msg) { /* SWIG_exception(code, msg); */ } #ifdef __cplusplus extern "C" { #endif SWIGINTERN PyObject *_wrap_new_XdmfObject(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfObject *result = 0 ; if (!PyArg_ParseTuple(args,(char *)":new_XdmfObject")) SWIG_fail; result = (XdmfObject *)new XdmfObject(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfObject, SWIG_POINTER_NEW | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_delete_XdmfObject(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfObject *arg1 = (XdmfObject *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:delete_XdmfObject",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfObject, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_XdmfObject" "', argument " "1"" of type '" "XdmfObject *""'"); } arg1 = reinterpret_cast< XdmfObject * >(argp1); delete arg1; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfObject_GetClassName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfObject *arg1 = (XdmfObject *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfObject_GetClassName",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfObject, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfObject_GetClassName" "', argument " "1"" of type '" "XdmfObject *""'"); } arg1 = reinterpret_cast< XdmfObject * >(argp1); result = (XdmfConstString)(arg1)->GetClassName(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfObject_SetDebug(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfObject *arg1 = (XdmfObject *) 0 ; XdmfBoolean arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfObject_SetDebug",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfObject, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfObject_SetDebug" "', argument " "1"" of type '" "XdmfObject *""'"); } arg1 = reinterpret_cast< XdmfObject * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfObject_SetDebug" "', argument " "2"" of type '" "XdmfBoolean""'"); } arg2 = static_cast< XdmfBoolean >(val2); result = (XdmfInt32)(arg1)->SetDebug(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfObject_GetDebug(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfObject *arg1 = (XdmfObject *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfBoolean result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfObject_GetDebug",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfObject, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfObject_GetDebug" "', argument " "1"" of type '" "XdmfObject *""'"); } arg1 = reinterpret_cast< XdmfObject * >(argp1); result = (XdmfBoolean)(arg1)->GetDebug(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfObject_GetGlobalDebug(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfObject *arg1 = (XdmfObject *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfBoolean result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfObject_GetGlobalDebug",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfObject, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfObject_GetGlobalDebug" "', argument " "1"" of type '" "XdmfObject *""'"); } arg1 = reinterpret_cast< XdmfObject * >(argp1); result = (XdmfBoolean)(arg1)->GetGlobalDebug(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfObject_SetGlobalDebug(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfObject *arg1 = (XdmfObject *) 0 ; XdmfBoolean arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfObject_SetGlobalDebug",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfObject, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfObject_SetGlobalDebug" "', argument " "1"" of type '" "XdmfObject *""'"); } arg1 = reinterpret_cast< XdmfObject * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfObject_SetGlobalDebug" "', argument " "2"" of type '" "XdmfBoolean""'"); } arg2 = static_cast< XdmfBoolean >(val2); (arg1)->SetGlobalDebug(arg2); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfObject_DebugOn(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfObject *arg1 = (XdmfObject *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfObject_DebugOn",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfObject, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfObject_DebugOn" "', argument " "1"" of type '" "XdmfObject *""'"); } arg1 = reinterpret_cast< XdmfObject * >(argp1); (arg1)->DebugOn(); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfObject_DebugOff(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfObject *arg1 = (XdmfObject *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfObject_DebugOff",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfObject, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfObject_DebugOff" "', argument " "1"" of type '" "XdmfObject *""'"); } arg1 = reinterpret_cast< XdmfObject * >(argp1); (arg1)->DebugOff(); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfObject_GlobalDebugOn(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfObject *arg1 = (XdmfObject *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfObject_GlobalDebugOn",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfObject, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfObject_GlobalDebugOn" "', argument " "1"" of type '" "XdmfObject *""'"); } arg1 = reinterpret_cast< XdmfObject * >(argp1); (arg1)->GlobalDebugOn(); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfObject_GlobalDebugOff(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfObject *arg1 = (XdmfObject *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfObject_GlobalDebugOff",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfObject, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfObject_GlobalDebugOff" "', argument " "1"" of type '" "XdmfObject *""'"); } arg1 = reinterpret_cast< XdmfObject * >(argp1); (arg1)->GlobalDebugOff(); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfObject_GetUniqueName__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfObject *arg1 = (XdmfObject *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfObject_GetUniqueName",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfObject, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfObject_GetUniqueName" "', argument " "1"" of type '" "XdmfObject *""'"); } arg1 = reinterpret_cast< XdmfObject * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfObject_GetUniqueName" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfConstString)(arg1)->GetUniqueName(arg2); resultobj = SWIG_FromCharPtr((const char *)result); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfObject_GetUniqueName__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfObject *arg1 = (XdmfObject *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfObject_GetUniqueName",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfObject, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfObject_GetUniqueName" "', argument " "1"" of type '" "XdmfObject *""'"); } arg1 = reinterpret_cast< XdmfObject * >(argp1); result = (XdmfConstString)(arg1)->GetUniqueName(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfObject_GetUniqueName(PyObject *self, PyObject *args) { int argc; PyObject *argv[3]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 2); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfObject, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfObject_GetUniqueName__SWIG_1(self, args); } } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfObject, 0); _v = SWIG_CheckState(res); if (_v) { int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfObject_GetUniqueName__SWIG_0(self, args); } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfObject_GetUniqueName'.\n" " Possible C/C++ prototypes are:\n" " GetUniqueName(XdmfObject *,XdmfConstString)\n" " GetUniqueName(XdmfObject *)\n"); return NULL; } SWIGINTERN PyObject *XdmfObject_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; SWIG_TypeNewClientData(SWIGTYPE_p_XdmfObject, SWIG_NewClientData(obj)); return SWIG_Py_Void(); } SWIGINTERN PyObject *_wrap_SetGlobalDebugOn(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; if (!PyArg_ParseTuple(args,(char *)":SetGlobalDebugOn")) SWIG_fail; SetGlobalDebugOn(); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_SetGlobalDebugOff(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; if (!PyArg_ParseTuple(args,(char *)":SetGlobalDebugOff")) SWIG_fail; SetGlobalDebugOff(); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_GetGlobalDebug(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)":GetGlobalDebug")) SWIG_fail; result = (XdmfInt32)GetGlobalDebug(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_SetGlobalDebug(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfInt32 arg1 ; int val1 ; int ecode1 = 0 ; PyObject * obj0 = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:SetGlobalDebug",&obj0)) SWIG_fail; ecode1 = SWIG_AsVal_int(obj0, &val1); if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "SetGlobalDebug" "', argument " "1"" of type '" "XdmfInt32""'"); } arg1 = static_cast< XdmfInt32 >(val1); SetGlobalDebug(arg1); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_GetUnique__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfConstString arg1 = (XdmfConstString) 0 ; int res1 ; char *buf1 = 0 ; int alloc1 = 0 ; PyObject * obj0 = 0 ; XdmfString result; if (!PyArg_ParseTuple(args,(char *)"O:GetUnique",&obj0)) SWIG_fail; res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GetUnique" "', argument " "1"" of type '" "XdmfConstString""'"); } arg1 = reinterpret_cast< XdmfConstString >(buf1); result = (XdmfString)GetUnique((char const *)arg1); resultobj = SWIG_FromCharPtr((const char *)result); if (alloc1 == SWIG_NEWOBJ) delete[] buf1; return resultobj; fail: if (alloc1 == SWIG_NEWOBJ) delete[] buf1; return NULL; } SWIGINTERN PyObject *_wrap_GetUnique__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfString result; if (!PyArg_ParseTuple(args,(char *)":GetUnique")) SWIG_fail; result = (XdmfString)GetUnique(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_GetUnique(PyObject *self, PyObject *args) { int argc; PyObject *argv[2]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 1); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 0) { return _wrap_GetUnique__SWIG_1(self, args); } if (argc == 1) { int _v; int res = SWIG_AsCharPtrAndSize(argv[0], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_GetUnique__SWIG_0(self, args); } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'GetUnique'.\n" " Possible C/C++ prototypes are:\n" " GetUnique(XdmfConstString)\n" " GetUnique()\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfObjectToHandle(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfObject *arg1 = (XdmfObject *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfObjectToHandle",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfObject, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfObjectToHandle" "', argument " "1"" of type '" "XdmfObject *""'"); } arg1 = reinterpret_cast< XdmfObject * >(argp1); result = (XdmfString)XdmfObjectToHandle(arg1); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_HandleToXdmfObject(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfConstString arg1 = (XdmfConstString) 0 ; int res1 ; char *buf1 = 0 ; int alloc1 = 0 ; PyObject * obj0 = 0 ; XdmfObject *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:HandleToXdmfObject",&obj0)) SWIG_fail; res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "HandleToXdmfObject" "', argument " "1"" of type '" "XdmfConstString""'"); } arg1 = reinterpret_cast< XdmfConstString >(buf1); result = (XdmfObject *)HandleToXdmfObject((char const *)arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfObject, 0 | 0 ); if (alloc1 == SWIG_NEWOBJ) delete[] buf1; return resultobj; fail: if (alloc1 == SWIG_NEWOBJ) delete[] buf1; return NULL; } SWIGINTERN PyObject *_wrap_VoidPointerHandleToXdmfPointer(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfConstString arg1 = (XdmfConstString) 0 ; int res1 ; char *buf1 = 0 ; int alloc1 = 0 ; PyObject * obj0 = 0 ; XdmfPointer result; if (!PyArg_ParseTuple(args,(char *)"O:VoidPointerHandleToXdmfPointer",&obj0)) SWIG_fail; res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VoidPointerHandleToXdmfPointer" "', argument " "1"" of type '" "XdmfConstString""'"); } arg1 = reinterpret_cast< XdmfConstString >(buf1); result = (XdmfPointer)VoidPointerHandleToXdmfPointer((char const *)arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_void, 0 | 0 ); if (alloc1 == SWIG_NEWOBJ) delete[] buf1; return resultobj; fail: if (alloc1 == SWIG_NEWOBJ) delete[] buf1; return NULL; } SWIGINTERN PyObject *_wrap_new_XdmfLightData(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfLightData *result = 0 ; if (!PyArg_ParseTuple(args,(char *)":new_XdmfLightData")) SWIG_fail; result = (XdmfLightData *)new XdmfLightData(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfLightData, SWIG_POINTER_NEW | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_delete_XdmfLightData(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfLightData *arg1 = (XdmfLightData *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:delete_XdmfLightData",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfLightData, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_XdmfLightData" "', argument " "1"" of type '" "XdmfLightData *""'"); } arg1 = reinterpret_cast< XdmfLightData * >(argp1); delete arg1; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfLightData_GetClassName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfLightData *arg1 = (XdmfLightData *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfLightData_GetClassName",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfLightData, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfLightData_GetClassName" "', argument " "1"" of type '" "XdmfLightData *""'"); } arg1 = reinterpret_cast< XdmfLightData * >(argp1); result = (XdmfConstString)(arg1)->GetClassName(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfLightData_SetName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfLightData *arg1 = (XdmfLightData *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfLightData_SetName",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfLightData, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfLightData_SetName" "', argument " "1"" of type '" "XdmfLightData *""'"); } arg1 = reinterpret_cast< XdmfLightData * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfLightData_SetName" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfInt32)(arg1)->SetName(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfLightData_GetName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfLightData *arg1 = (XdmfLightData *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfLightData_GetName",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfLightData, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfLightData_GetName" "', argument " "1"" of type '" "XdmfLightData *""'"); } arg1 = reinterpret_cast< XdmfLightData * >(argp1); result = (XdmfConstString)(arg1)->GetName(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfLightData_SetFileName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfLightData *arg1 = (XdmfLightData *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfLightData_SetFileName",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfLightData, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfLightData_SetFileName" "', argument " "1"" of type '" "XdmfLightData *""'"); } arg1 = reinterpret_cast< XdmfLightData * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfLightData_SetFileName" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfInt32)(arg1)->SetFileName(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfLightData_GetFileName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfLightData *arg1 = (XdmfLightData *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfLightData_GetFileName",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfLightData, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfLightData_GetFileName" "', argument " "1"" of type '" "XdmfLightData *""'"); } arg1 = reinterpret_cast< XdmfLightData * >(argp1); result = (XdmfConstString)(arg1)->GetFileName(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfLightData_SetWorkingDirectory(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfLightData *arg1 = (XdmfLightData *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfLightData_SetWorkingDirectory",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfLightData, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfLightData_SetWorkingDirectory" "', argument " "1"" of type '" "XdmfLightData *""'"); } arg1 = reinterpret_cast< XdmfLightData * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfLightData_SetWorkingDirectory" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfInt32)(arg1)->SetWorkingDirectory(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfLightData_GetWorkingDirectory(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfLightData *arg1 = (XdmfLightData *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfLightData_GetWorkingDirectory",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfLightData, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfLightData_GetWorkingDirectory" "', argument " "1"" of type '" "XdmfLightData *""'"); } arg1 = reinterpret_cast< XdmfLightData * >(argp1); result = (XdmfConstString)(arg1)->GetWorkingDirectory(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfLightData_GetInitialized(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfLightData *arg1 = (XdmfLightData *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfLightData_GetInitialized",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfLightData, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfLightData_GetInitialized" "', argument " "1"" of type '" "XdmfLightData *""'"); } arg1 = reinterpret_cast< XdmfLightData * >(argp1); result = (XdmfInt32)(arg1)->GetInitialized(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfLightData_SetInitialized(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfLightData *arg1 = (XdmfLightData *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfLightData_SetInitialized",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfLightData, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfLightData_SetInitialized" "', argument " "1"" of type '" "XdmfLightData *""'"); } arg1 = reinterpret_cast< XdmfLightData * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfLightData_SetInitialized" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetInitialized(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfLightData_GetReturnBuffer(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfLightData *arg1 = (XdmfLightData *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfLightData_GetReturnBuffer",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfLightData, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfLightData_GetReturnBuffer" "', argument " "1"" of type '" "XdmfLightData *""'"); } arg1 = reinterpret_cast< XdmfLightData * >(argp1); result = (XdmfConstString)(arg1)->GetReturnBuffer(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *XdmfLightData_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; SWIG_TypeNewClientData(SWIGTYPE_p_XdmfLightData, SWIG_NewClientData(obj)); return SWIG_Py_Void(); } SWIGINTERN PyObject *_wrap_new_XdmfElement(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfElement *result = 0 ; if (!PyArg_ParseTuple(args,(char *)":new_XdmfElement")) SWIG_fail; result = (XdmfElement *)new XdmfElement(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfElement, SWIG_POINTER_NEW | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_delete_XdmfElement(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfElement *arg1 = (XdmfElement *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:delete_XdmfElement",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfElement, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_XdmfElement" "', argument " "1"" of type '" "XdmfElement *""'"); } arg1 = reinterpret_cast< XdmfElement * >(argp1); delete arg1; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfElement_GetClassName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfElement *arg1 = (XdmfElement *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfElement_GetClassName",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfElement_GetClassName" "', argument " "1"" of type '" "XdmfElement *""'"); } arg1 = reinterpret_cast< XdmfElement * >(argp1); result = (XdmfConstString)(arg1)->GetClassName(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfElement_SetDOM(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfElement *arg1 = (XdmfElement *) 0 ; XdmfDOM *arg2 = (XdmfDOM *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfElement_SetDOM",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfElement_SetDOM" "', argument " "1"" of type '" "XdmfElement *""'"); } arg1 = reinterpret_cast< XdmfElement * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfElement_SetDOM" "', argument " "2"" of type '" "XdmfDOM *""'"); } arg2 = reinterpret_cast< XdmfDOM * >(argp2); result = (XdmfInt32)(arg1)->SetDOM(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfElement_GetDOM(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfElement *arg1 = (XdmfElement *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfDOM *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfElement_GetDOM",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfElement_GetDOM" "', argument " "1"" of type '" "XdmfElement *""'"); } arg1 = reinterpret_cast< XdmfElement * >(argp1); result = (XdmfDOM *)(arg1)->GetDOM(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfDOM, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfElement_SetState(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfElement *arg1 = (XdmfElement *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfElement_SetState",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfElement_SetState" "', argument " "1"" of type '" "XdmfElement *""'"); } arg1 = reinterpret_cast< XdmfElement * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfElement_SetState" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetState(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfElement_GetState(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfElement *arg1 = (XdmfElement *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfElement_GetState",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfElement_GetState" "', argument " "1"" of type '" "XdmfElement *""'"); } arg1 = reinterpret_cast< XdmfElement * >(argp1); result = (XdmfInt32)(arg1)->GetState(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfElement_SetIsReference(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfElement *arg1 = (XdmfElement *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfElement_SetIsReference",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfElement_SetIsReference" "', argument " "1"" of type '" "XdmfElement *""'"); } arg1 = reinterpret_cast< XdmfElement * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfElement_SetIsReference" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetIsReference(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfElement_GetIsReference(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfElement *arg1 = (XdmfElement *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfElement_GetIsReference",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfElement_GetIsReference" "', argument " "1"" of type '" "XdmfElement *""'"); } arg1 = reinterpret_cast< XdmfElement * >(argp1); result = (XdmfInt32)(arg1)->GetIsReference(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfElement_CheckForReference(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfElement *arg1 = (XdmfElement *) 0 ; XdmfXmlNode arg2 = (XdmfXmlNode) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfXmlNode result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfElement_CheckForReference",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfElement_CheckForReference" "', argument " "1"" of type '" "XdmfElement *""'"); } arg1 = reinterpret_cast< XdmfElement * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p__xmlNode, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfElement_CheckForReference" "', argument " "2"" of type '" "XdmfXmlNode""'"); } arg2 = reinterpret_cast< XdmfXmlNode >(argp2); result = (XdmfXmlNode)(arg1)->CheckForReference(arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__xmlNode, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfElement_InsertChildElement(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfElement *arg1 = (XdmfElement *) 0 ; XdmfXmlNode arg2 = (XdmfXmlNode) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfElement_InsertChildElement",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfElement_InsertChildElement" "', argument " "1"" of type '" "XdmfElement *""'"); } arg1 = reinterpret_cast< XdmfElement * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p__xmlNode, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfElement_InsertChildElement" "', argument " "2"" of type '" "XdmfXmlNode""'"); } arg2 = reinterpret_cast< XdmfXmlNode >(argp2); result = (XdmfInt32)(arg1)->InsertChildElement(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfElement_Serialize(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfElement *arg1 = (XdmfElement *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfElement_Serialize",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfElement_Serialize" "', argument " "1"" of type '" "XdmfElement *""'"); } arg1 = reinterpret_cast< XdmfElement * >(argp1); result = (XdmfConstString)(arg1)->Serialize(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfElement_SetElement__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfElement *arg1 = (XdmfElement *) 0 ; XdmfXmlNode arg2 = (XdmfXmlNode) 0 ; XdmfInt32 arg3 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; int val3 ; int ecode3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfElement_SetElement",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfElement_SetElement" "', argument " "1"" of type '" "XdmfElement *""'"); } arg1 = reinterpret_cast< XdmfElement * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p__xmlNode, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfElement_SetElement" "', argument " "2"" of type '" "XdmfXmlNode""'"); } arg2 = reinterpret_cast< XdmfXmlNode >(argp2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "XdmfElement_SetElement" "', argument " "3"" of type '" "XdmfInt32""'"); } arg3 = static_cast< XdmfInt32 >(val3); result = (XdmfInt32)(arg1)->SetElement(arg2,arg3); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfElement_SetElement__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfElement *arg1 = (XdmfElement *) 0 ; XdmfXmlNode arg2 = (XdmfXmlNode) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfElement_SetElement",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfElement_SetElement" "', argument " "1"" of type '" "XdmfElement *""'"); } arg1 = reinterpret_cast< XdmfElement * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p__xmlNode, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfElement_SetElement" "', argument " "2"" of type '" "XdmfXmlNode""'"); } arg2 = reinterpret_cast< XdmfXmlNode >(argp2); result = (XdmfInt32)(arg1)->SetElement(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfElement_SetElement(PyObject *self, PyObject *args) { int argc; PyObject *argv[4]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 3); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfElement, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p__xmlNode, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfElement_SetElement__SWIG_1(self, args); } } } if (argc == 3) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfElement, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p__xmlNode, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_int(argv[2], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfElement_SetElement__SWIG_0(self, args); } } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfElement_SetElement'.\n" " Possible C/C++ prototypes are:\n" " SetElement(XdmfElement *,XdmfXmlNode,XdmfInt32)\n" " SetElement(XdmfElement *,XdmfXmlNode)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfElement_GetElement(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfElement *arg1 = (XdmfElement *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfXmlNode result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfElement_GetElement",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfElement_GetElement" "', argument " "1"" of type '" "XdmfElement *""'"); } arg1 = reinterpret_cast< XdmfElement * >(argp1); result = (XdmfXmlNode)(arg1)->GetElement(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__xmlNode, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfElement_SetCopyReferenceData(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfElement *arg1 = (XdmfElement *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfElement_SetCopyReferenceData",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfElement_SetCopyReferenceData" "', argument " "1"" of type '" "XdmfElement *""'"); } arg1 = reinterpret_cast< XdmfElement * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfElement_SetCopyReferenceData" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetCopyReferenceData(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfElement_GetCopyReferenceData(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfElement *arg1 = (XdmfElement *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfElement_GetCopyReferenceData",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfElement_GetCopyReferenceData" "', argument " "1"" of type '" "XdmfElement *""'"); } arg1 = reinterpret_cast< XdmfElement * >(argp1); result = (XdmfInt32)(arg1)->GetCopyReferenceData(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfElement_GetElementName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfElement *arg1 = (XdmfElement *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfElement_GetElementName",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfElement_GetElementName" "', argument " "1"" of type '" "XdmfElement *""'"); } arg1 = reinterpret_cast< XdmfElement * >(argp1); result = (XdmfConstString)(arg1)->GetElementName(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfElement_SetElementName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfElement *arg1 = (XdmfElement *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfElement_SetElementName",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfElement_SetElementName" "', argument " "1"" of type '" "XdmfElement *""'"); } arg1 = reinterpret_cast< XdmfElement * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfElement_SetElementName" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfInt32)(arg1)->SetElementName(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfElement_GetDataXml(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfElement *arg1 = (XdmfElement *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfElement_GetDataXml",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfElement_GetDataXml" "', argument " "1"" of type '" "XdmfElement *""'"); } arg1 = reinterpret_cast< XdmfElement * >(argp1); result = (XdmfConstString)(arg1)->GetDataXml(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfElement_SetDataXml(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfElement *arg1 = (XdmfElement *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfElement_SetDataXml",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfElement_SetDataXml" "', argument " "1"" of type '" "XdmfElement *""'"); } arg1 = reinterpret_cast< XdmfElement * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfElement_SetDataXml" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfInt32)(arg1)->SetDataXml(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfElement_GetInsertedDataXml(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfElement *arg1 = (XdmfElement *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfElement_GetInsertedDataXml",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfElement_GetInsertedDataXml" "', argument " "1"" of type '" "XdmfElement *""'"); } arg1 = reinterpret_cast< XdmfElement * >(argp1); result = (XdmfConstString)(arg1)->GetInsertedDataXml(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfElement_SetInsertedDataXml(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfElement *arg1 = (XdmfElement *) 0 ; XdmfString arg2 = (XdmfString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfElement_SetInsertedDataXml",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfElement_SetInsertedDataXml" "', argument " "1"" of type '" "XdmfElement *""'"); } arg1 = reinterpret_cast< XdmfElement * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfElement_SetInsertedDataXml" "', argument " "2"" of type '" "XdmfString""'"); } arg2 = reinterpret_cast< XdmfString >(buf2); result = (XdmfInt32)(arg1)->SetInsertedDataXml(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfElement_BuildFromDataXml__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfElement *arg1 = (XdmfElement *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfElement_BuildFromDataXml",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfElement_BuildFromDataXml" "', argument " "1"" of type '" "XdmfElement *""'"); } arg1 = reinterpret_cast< XdmfElement * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfElement_BuildFromDataXml" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->BuildFromDataXml(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfElement_BuildFromDataXml__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfElement *arg1 = (XdmfElement *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfElement_BuildFromDataXml",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfElement_BuildFromDataXml" "', argument " "1"" of type '" "XdmfElement *""'"); } arg1 = reinterpret_cast< XdmfElement * >(argp1); result = (XdmfInt32)(arg1)->BuildFromDataXml(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfElement_BuildFromDataXml(PyObject *self, PyObject *args) { int argc; PyObject *argv[3]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 2); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfElement, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfElement_BuildFromDataXml__SWIG_1(self, args); } } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfElement, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_int(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfElement_BuildFromDataXml__SWIG_0(self, args); } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfElement_BuildFromDataXml'.\n" " Possible C/C++ prototypes are:\n" " BuildFromDataXml(XdmfElement *,XdmfInt32)\n" " BuildFromDataXml(XdmfElement *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfElement_GetElementType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfElement *arg1 = (XdmfElement *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfElement_GetElementType",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfElement_GetElementType" "', argument " "1"" of type '" "XdmfElement *""'"); } arg1 = reinterpret_cast< XdmfElement * >(argp1); result = (XdmfConstString)(arg1)->GetElementType(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfElement_UpdateInformation(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfElement *arg1 = (XdmfElement *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfElement_UpdateInformation",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfElement_UpdateInformation" "', argument " "1"" of type '" "XdmfElement *""'"); } arg1 = reinterpret_cast< XdmfElement * >(argp1); result = (XdmfInt32)(arg1)->UpdateInformation(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfElement_Update(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfElement *arg1 = (XdmfElement *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfElement_Update",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfElement_Update" "', argument " "1"" of type '" "XdmfElement *""'"); } arg1 = reinterpret_cast< XdmfElement * >(argp1); result = (XdmfInt32)(arg1)->Update(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfElement_Build(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfElement *arg1 = (XdmfElement *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfElement_Build",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfElement_Build" "', argument " "1"" of type '" "XdmfElement *""'"); } arg1 = reinterpret_cast< XdmfElement * >(argp1); result = (XdmfInt32)(arg1)->Build(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfElement_Set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfElement *arg1 = (XdmfElement *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; XdmfConstString arg3 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfElement_Set",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfElement_Set" "', argument " "1"" of type '" "XdmfElement *""'"); } arg1 = reinterpret_cast< XdmfElement * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfElement_Set" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfElement_Set" "', argument " "3"" of type '" "XdmfConstString""'"); } arg3 = reinterpret_cast< XdmfConstString >(buf3); result = (XdmfInt32)(arg1)->Set(arg2,arg3); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return NULL; } SWIGINTERN PyObject *_wrap_XdmfElement_Get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfElement *arg1 = (XdmfElement *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfElement_Get",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfElement_Get" "', argument " "1"" of type '" "XdmfElement *""'"); } arg1 = reinterpret_cast< XdmfElement * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfElement_Get" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfConstString)(arg1)->Get(arg2); resultobj = SWIG_FromCharPtr((const char *)result); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfElement_Copy(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfElement *arg1 = (XdmfElement *) 0 ; XdmfElement *arg2 = (XdmfElement *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfElement_Copy",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfElement_Copy" "', argument " "1"" of type '" "XdmfElement *""'"); } arg1 = reinterpret_cast< XdmfElement * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfElement_Copy" "', argument " "2"" of type '" "XdmfElement *""'"); } arg2 = reinterpret_cast< XdmfElement * >(argp2); result = (XdmfInt32)(arg1)->Copy(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfElement_Insert__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfElement *arg1 = (XdmfElement *) 0 ; XdmfElement *arg2 = (XdmfElement *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfElement_Insert",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfElement_Insert" "', argument " "1"" of type '" "XdmfElement *""'"); } arg1 = reinterpret_cast< XdmfElement * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfElement_Insert" "', argument " "2"" of type '" "XdmfElement *""'"); } arg2 = reinterpret_cast< XdmfElement * >(argp2); result = (XdmfInt32)(arg1)->Insert(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfElement_Insert__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfElement *arg1 = (XdmfElement *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfElement_Insert",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfElement_Insert" "', argument " "1"" of type '" "XdmfElement *""'"); } arg1 = reinterpret_cast< XdmfElement * >(argp1); result = (XdmfInt32)(arg1)->Insert(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfElement_Insert(PyObject *self, PyObject *args) { int argc; PyObject *argv[3]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 2); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfElement, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfElement_Insert__SWIG_1(self, args); } } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfElement, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_XdmfElement, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfElement_Insert__SWIG_0(self, args); } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfElement_Insert'.\n" " Possible C/C++ prototypes are:\n" " Insert(XdmfElement *,XdmfElement *)\n" " Insert(XdmfElement *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfElement_FollowReference(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfElement *arg1 = (XdmfElement *) 0 ; XdmfXmlNode arg2 = (XdmfXmlNode) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfXmlNode result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfElement_FollowReference",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfElement_FollowReference" "', argument " "1"" of type '" "XdmfElement *""'"); } arg1 = reinterpret_cast< XdmfElement * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p__xmlNode, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfElement_FollowReference" "', argument " "2"" of type '" "XdmfXmlNode""'"); } arg2 = reinterpret_cast< XdmfXmlNode >(argp2); result = (XdmfXmlNode)(arg1)->FollowReference(arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__xmlNode, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfElement_GetDsmBuffer(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfElement *arg1 = (XdmfElement *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfDsmBuffer *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfElement_GetDsmBuffer",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfElement_GetDsmBuffer" "', argument " "1"" of type '" "XdmfElement *""'"); } arg1 = reinterpret_cast< XdmfElement * >(argp1); result = (XdmfDsmBuffer *)(arg1)->GetDsmBuffer(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfDsmBuffer, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfElement_SetDsmBuffer(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfElement *arg1 = (XdmfElement *) 0 ; XdmfDsmBuffer *arg2 = (XdmfDsmBuffer *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfElement_SetDsmBuffer",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfElement_SetDsmBuffer" "', argument " "1"" of type '" "XdmfElement *""'"); } arg1 = reinterpret_cast< XdmfElement * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfDsmBuffer, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfElement_SetDsmBuffer" "', argument " "2"" of type '" "XdmfDsmBuffer *""'"); } arg2 = reinterpret_cast< XdmfDsmBuffer * >(argp2); result = (XdmfInt32)(arg1)->SetDsmBuffer(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfElement_SetDeleteOnGridDelete(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfElement *arg1 = (XdmfElement *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfElement_SetDeleteOnGridDelete",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfElement_SetDeleteOnGridDelete" "', argument " "1"" of type '" "XdmfElement *""'"); } arg1 = reinterpret_cast< XdmfElement * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfElement_SetDeleteOnGridDelete" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetDeleteOnGridDelete(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfElement_GetDeleteOnGridDelete(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfElement *arg1 = (XdmfElement *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfElement_GetDeleteOnGridDelete",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfElement_GetDeleteOnGridDelete" "', argument " "1"" of type '" "XdmfElement *""'"); } arg1 = reinterpret_cast< XdmfElement * >(argp1); result = (XdmfInt32)(arg1)->GetDeleteOnGridDelete(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *XdmfElement_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; SWIG_TypeNewClientData(SWIGTYPE_p_XdmfElement, SWIG_NewClientData(obj)); return SWIG_Py_Void(); } SWIGINTERN PyObject *_wrap_new_XdmfAttribute(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfAttribute *result = 0 ; if (!PyArg_ParseTuple(args,(char *)":new_XdmfAttribute")) SWIG_fail; result = (XdmfAttribute *)new XdmfAttribute(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfAttribute, SWIG_POINTER_NEW | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_delete_XdmfAttribute(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfAttribute *arg1 = (XdmfAttribute *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:delete_XdmfAttribute",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfAttribute, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_XdmfAttribute" "', argument " "1"" of type '" "XdmfAttribute *""'"); } arg1 = reinterpret_cast< XdmfAttribute * >(argp1); delete arg1; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfAttribute_GetClassName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfAttribute *arg1 = (XdmfAttribute *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfAttribute_GetClassName",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfAttribute, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfAttribute_GetClassName" "', argument " "1"" of type '" "XdmfAttribute *""'"); } arg1 = reinterpret_cast< XdmfAttribute * >(argp1); result = (XdmfConstString)(arg1)->GetClassName(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfAttribute_SetAttributeType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfAttribute *arg1 = (XdmfAttribute *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfAttribute_SetAttributeType",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfAttribute, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfAttribute_SetAttributeType" "', argument " "1"" of type '" "XdmfAttribute *""'"); } arg1 = reinterpret_cast< XdmfAttribute * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfAttribute_SetAttributeType" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetAttributeType(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfAttribute_GetAttributeType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfAttribute *arg1 = (XdmfAttribute *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfAttribute_GetAttributeType",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfAttribute, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfAttribute_GetAttributeType" "', argument " "1"" of type '" "XdmfAttribute *""'"); } arg1 = reinterpret_cast< XdmfAttribute * >(argp1); result = (XdmfInt32)(arg1)->GetAttributeType(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfAttribute_SetLightDataLimit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfAttribute *arg1 = (XdmfAttribute *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfAttribute_SetLightDataLimit",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfAttribute, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfAttribute_SetLightDataLimit" "', argument " "1"" of type '" "XdmfAttribute *""'"); } arg1 = reinterpret_cast< XdmfAttribute * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfAttribute_SetLightDataLimit" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetLightDataLimit(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfAttribute_GetLightDataLimit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfAttribute *arg1 = (XdmfAttribute *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfAttribute_GetLightDataLimit",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfAttribute, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfAttribute_GetLightDataLimit" "', argument " "1"" of type '" "XdmfAttribute *""'"); } arg1 = reinterpret_cast< XdmfAttribute * >(argp1); result = (XdmfInt32)(arg1)->GetLightDataLimit(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfAttribute_SetActive(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfAttribute *arg1 = (XdmfAttribute *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfAttribute_SetActive",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfAttribute, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfAttribute_SetActive" "', argument " "1"" of type '" "XdmfAttribute *""'"); } arg1 = reinterpret_cast< XdmfAttribute * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfAttribute_SetActive" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetActive(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfAttribute_GetActive(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfAttribute *arg1 = (XdmfAttribute *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfAttribute_GetActive",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfAttribute, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfAttribute_GetActive" "', argument " "1"" of type '" "XdmfAttribute *""'"); } arg1 = reinterpret_cast< XdmfAttribute * >(argp1); result = (XdmfInt32)(arg1)->GetActive(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfAttribute_Insert(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfAttribute *arg1 = (XdmfAttribute *) 0 ; XdmfElement *arg2 = (XdmfElement *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfAttribute_Insert",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfAttribute, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfAttribute_Insert" "', argument " "1"" of type '" "XdmfAttribute *""'"); } arg1 = reinterpret_cast< XdmfAttribute * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfAttribute_Insert" "', argument " "2"" of type '" "XdmfElement *""'"); } arg2 = reinterpret_cast< XdmfElement * >(argp2); result = (XdmfInt32)(arg1)->Insert(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfAttribute_SetAttributeTypeFromString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfAttribute *arg1 = (XdmfAttribute *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfAttribute_SetAttributeTypeFromString",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfAttribute, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfAttribute_SetAttributeTypeFromString" "', argument " "1"" of type '" "XdmfAttribute *""'"); } arg1 = reinterpret_cast< XdmfAttribute * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfAttribute_SetAttributeTypeFromString" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfInt32)(arg1)->SetAttributeTypeFromString(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfAttribute_GetAttributeTypeAsString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfAttribute *arg1 = (XdmfAttribute *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfAttribute_GetAttributeTypeAsString",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfAttribute, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfAttribute_GetAttributeTypeAsString" "', argument " "1"" of type '" "XdmfAttribute *""'"); } arg1 = reinterpret_cast< XdmfAttribute * >(argp1); result = (XdmfConstString)(arg1)->GetAttributeTypeAsString(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfAttribute_SetAttributeCenterFromString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfAttribute *arg1 = (XdmfAttribute *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfAttribute_SetAttributeCenterFromString",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfAttribute, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfAttribute_SetAttributeCenterFromString" "', argument " "1"" of type '" "XdmfAttribute *""'"); } arg1 = reinterpret_cast< XdmfAttribute * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfAttribute_SetAttributeCenterFromString" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfInt32)(arg1)->SetAttributeCenterFromString(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfAttribute_GetAttributeCenterAsString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfAttribute *arg1 = (XdmfAttribute *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfAttribute_GetAttributeCenterAsString",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfAttribute, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfAttribute_GetAttributeCenterAsString" "', argument " "1"" of type '" "XdmfAttribute *""'"); } arg1 = reinterpret_cast< XdmfAttribute * >(argp1); result = (XdmfConstString)(arg1)->GetAttributeCenterAsString(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfAttribute_SetAttributeCenter(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfAttribute *arg1 = (XdmfAttribute *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfAttribute_SetAttributeCenter",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfAttribute, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfAttribute_SetAttributeCenter" "', argument " "1"" of type '" "XdmfAttribute *""'"); } arg1 = reinterpret_cast< XdmfAttribute * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfAttribute_SetAttributeCenter" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetAttributeCenter(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfAttribute_GetAttributeCenter(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfAttribute *arg1 = (XdmfAttribute *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfAttribute_GetAttributeCenter",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfAttribute, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfAttribute_GetAttributeCenter" "', argument " "1"" of type '" "XdmfAttribute *""'"); } arg1 = reinterpret_cast< XdmfAttribute * >(argp1); result = (XdmfInt32)(arg1)->GetAttributeCenter(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfAttribute_GetUnits(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfAttribute *arg1 = (XdmfAttribute *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfAttribute_GetUnits",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfAttribute, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfAttribute_GetUnits" "', argument " "1"" of type '" "XdmfAttribute *""'"); } arg1 = reinterpret_cast< XdmfAttribute * >(argp1); result = (XdmfConstString)(arg1)->GetUnits(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfAttribute_SetUnits(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfAttribute *arg1 = (XdmfAttribute *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfAttribute_SetUnits",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfAttribute, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfAttribute_SetUnits" "', argument " "1"" of type '" "XdmfAttribute *""'"); } arg1 = reinterpret_cast< XdmfAttribute * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfAttribute_SetUnits" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfInt32)(arg1)->SetUnits(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfAttribute_GetShapeDesc(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfAttribute *arg1 = (XdmfAttribute *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfDataDesc *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfAttribute_GetShapeDesc",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfAttribute, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfAttribute_GetShapeDesc" "', argument " "1"" of type '" "XdmfAttribute *""'"); } arg1 = reinterpret_cast< XdmfAttribute * >(argp1); result = (XdmfDataDesc *)(arg1)->GetShapeDesc(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfAttribute_SetValues(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfAttribute *arg1 = (XdmfAttribute *) 0 ; XdmfArray *arg2 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfAttribute_SetValues",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfAttribute, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfAttribute_SetValues" "', argument " "1"" of type '" "XdmfAttribute *""'"); } arg1 = reinterpret_cast< XdmfAttribute * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfAttribute_SetValues" "', argument " "2"" of type '" "XdmfArray *""'"); } arg2 = reinterpret_cast< XdmfArray * >(argp2); result = (XdmfInt32)(arg1)->SetValues(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfAttribute_GetValues__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfAttribute *arg1 = (XdmfAttribute *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfAttribute_GetValues",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfAttribute, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfAttribute_GetValues" "', argument " "1"" of type '" "XdmfAttribute *""'"); } arg1 = reinterpret_cast< XdmfAttribute * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfAttribute_GetValues" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfArray *)(arg1)->GetValues(arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfAttribute_GetValues__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfAttribute *arg1 = (XdmfAttribute *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfAttribute_GetValues",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfAttribute, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfAttribute_GetValues" "', argument " "1"" of type '" "XdmfAttribute *""'"); } arg1 = reinterpret_cast< XdmfAttribute * >(argp1); result = (XdmfArray *)(arg1)->GetValues(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfAttribute_GetValues(PyObject *self, PyObject *args) { int argc; PyObject *argv[3]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 2); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfAttribute, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfAttribute_GetValues__SWIG_1(self, args); } } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfAttribute, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_int(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfAttribute_GetValues__SWIG_0(self, args); } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfAttribute_GetValues'.\n" " Possible C/C++ prototypes are:\n" " GetValues(XdmfAttribute *,XdmfInt32)\n" " GetValues(XdmfAttribute *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfAttribute_UpdateInformation(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfAttribute *arg1 = (XdmfAttribute *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfAttribute_UpdateInformation",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfAttribute, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfAttribute_UpdateInformation" "', argument " "1"" of type '" "XdmfAttribute *""'"); } arg1 = reinterpret_cast< XdmfAttribute * >(argp1); result = (XdmfInt32)(arg1)->UpdateInformation(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfAttribute_Update(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfAttribute *arg1 = (XdmfAttribute *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfAttribute_Update",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfAttribute, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfAttribute_Update" "', argument " "1"" of type '" "XdmfAttribute *""'"); } arg1 = reinterpret_cast< XdmfAttribute * >(argp1); result = (XdmfInt32)(arg1)->Update(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfAttribute_Build(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfAttribute *arg1 = (XdmfAttribute *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfAttribute_Build",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfAttribute, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfAttribute_Build" "', argument " "1"" of type '" "XdmfAttribute *""'"); } arg1 = reinterpret_cast< XdmfAttribute * >(argp1); result = (XdmfInt32)(arg1)->Build(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfAttribute_Release(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfAttribute *arg1 = (XdmfAttribute *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfAttribute_Release",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfAttribute, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfAttribute_Release" "', argument " "1"" of type '" "XdmfAttribute *""'"); } arg1 = reinterpret_cast< XdmfAttribute * >(argp1); result = (XdmfInt32)(arg1)->Release(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *XdmfAttribute_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; SWIG_TypeNewClientData(SWIGTYPE_p_XdmfAttribute, SWIG_NewClientData(obj)); return SWIG_Py_Void(); } SWIGINTERN PyObject *_wrap_XdmfTypeToHDF5Type(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfInt32 arg1 ; int val1 ; int ecode1 = 0 ; PyObject * obj0 = 0 ; hid_t result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfTypeToHDF5Type",&obj0)) SWIG_fail; ecode1 = SWIG_AsVal_int(obj0, &val1); if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "XdmfTypeToHDF5Type" "', argument " "1"" of type '" "XdmfInt32""'"); } arg1 = static_cast< XdmfInt32 >(val1); result = XdmfTypeToHDF5Type(arg1); resultobj = SWIG_NewPointerObj((new hid_t(static_cast< const hid_t& >(result))), SWIGTYPE_p_hid_t, SWIG_POINTER_OWN | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_HDF5TypeToXdmfType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; hid_t arg1 ; void *argp1 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:HDF5TypeToXdmfType",&obj0)) SWIG_fail; { res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_hid_t, 0 | 0); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "HDF5TypeToXdmfType" "', argument " "1"" of type '" "hid_t""'"); } if (!argp1) { SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "HDF5TypeToXdmfType" "', argument " "1"" of type '" "hid_t""'"); } else { hid_t * temp = reinterpret_cast< hid_t * >(argp1); arg1 = *temp; if (SWIG_IsNewObj(res1)) delete temp; } } result = (XdmfInt32)HDF5TypeToXdmfType(arg1); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTypeToString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfInt32 arg1 ; int val1 ; int ecode1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfTypeToString",&obj0)) SWIG_fail; ecode1 = SWIG_AsVal_int(obj0, &val1); if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "XdmfTypeToString" "', argument " "1"" of type '" "XdmfInt32""'"); } arg1 = static_cast< XdmfInt32 >(val1); result = (XdmfConstString)XdmfTypeToString(arg1); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_StringToXdmfType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfConstString arg1 = (XdmfConstString) 0 ; int res1 ; char *buf1 = 0 ; int alloc1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:StringToXdmfType",&obj0)) SWIG_fail; res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringToXdmfType" "', argument " "1"" of type '" "XdmfConstString""'"); } arg1 = reinterpret_cast< XdmfConstString >(buf1); result = (XdmfInt32)StringToXdmfType((char const *)arg1); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc1 == SWIG_NEWOBJ) delete[] buf1; return resultobj; fail: if (alloc1 == SWIG_NEWOBJ) delete[] buf1; return NULL; } SWIGINTERN PyObject *_wrap_XdmfTypeToClassString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfInt32 arg1 ; int val1 ; int ecode1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfTypeToClassString",&obj0)) SWIG_fail; ecode1 = SWIG_AsVal_int(obj0, &val1); if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "XdmfTypeToClassString" "', argument " "1"" of type '" "XdmfInt32""'"); } arg1 = static_cast< XdmfInt32 >(val1); result = (XdmfConstString)XdmfTypeToClassString(arg1); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_new_XdmfDataDesc(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *result = 0 ; if (!PyArg_ParseTuple(args,(char *)":new_XdmfDataDesc")) SWIG_fail; result = (XdmfDataDesc *)new XdmfDataDesc(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfDataDesc, SWIG_POINTER_NEW | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_delete_XdmfDataDesc(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:delete_XdmfDataDesc",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_XdmfDataDesc" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); delete arg1; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_Print(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDataDesc_Print",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_Print" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); (arg1)->Print(); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_SetNumberType__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; XdmfInt32 arg2 ; XdmfInt64 arg3 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; long long val3 ; int ecode3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfDataDesc_SetNumberType",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_SetNumberType" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDataDesc_SetNumberType" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); ecode3 = SWIG_AsVal_long_SS_long(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "XdmfDataDesc_SetNumberType" "', argument " "3"" of type '" "XdmfInt64""'"); } arg3 = static_cast< XdmfInt64 >(val3); result = (XdmfInt32)(arg1)->SetNumberType(arg2,arg3); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_SetNumberType__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDataDesc_SetNumberType",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_SetNumberType" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDataDesc_SetNumberType" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetNumberType(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_SetNumberType(PyObject *self, PyObject *args) { int argc; PyObject *argv[4]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 3); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDataDesc, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_int(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfDataDesc_SetNumberType__SWIG_1(self, args); } } } if (argc == 3) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDataDesc, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_int(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[2], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfDataDesc_SetNumberType__SWIG_0(self, args); } } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfDataDesc_SetNumberType'.\n" " Possible C/C++ prototypes are:\n" " SetNumberType(XdmfDataDesc *,XdmfInt32,XdmfInt64)\n" " SetNumberType(XdmfDataDesc *,XdmfInt32)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_SetNumberTypeFromString__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; XdmfInt64 arg3 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; long long val3 ; int ecode3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfDataDesc_SetNumberTypeFromString",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_SetNumberTypeFromString" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDataDesc_SetNumberTypeFromString" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); ecode3 = SWIG_AsVal_long_SS_long(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "XdmfDataDesc_SetNumberTypeFromString" "', argument " "3"" of type '" "XdmfInt64""'"); } arg3 = static_cast< XdmfInt64 >(val3); result = (XdmfInt32)(arg1)->SetNumberTypeFromString(arg2,arg3); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_SetNumberTypeFromString__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDataDesc_SetNumberTypeFromString",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_SetNumberTypeFromString" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDataDesc_SetNumberTypeFromString" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfInt32)(arg1)->SetNumberTypeFromString(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_SetNumberTypeFromString(PyObject *self, PyObject *args) { int argc; PyObject *argv[4]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 3); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDataDesc, 0); _v = SWIG_CheckState(res); if (_v) { int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfDataDesc_SetNumberTypeFromString__SWIG_1(self, args); } } } if (argc == 3) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDataDesc, 0); _v = SWIG_CheckState(res); if (_v) { int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[2], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfDataDesc_SetNumberTypeFromString__SWIG_0(self, args); } } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfDataDesc_SetNumberTypeFromString'.\n" " Possible C/C++ prototypes are:\n" " SetNumberTypeFromString(XdmfDataDesc *,XdmfConstString,XdmfInt64)\n" " SetNumberTypeFromString(XdmfDataDesc *,XdmfConstString)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_GetNumberType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDataDesc_GetNumberType",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_GetNumberType" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); result = (XdmfInt32)(arg1)->GetNumberType(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_GetNumberTypeAsString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDataDesc_GetNumberTypeAsString",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_GetNumberTypeAsString" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); result = (XdmfConstString)(arg1)->GetNumberTypeAsString(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_SetShape(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; XdmfInt32 arg2 ; XdmfInt64 *arg3 = (XdmfInt64 *) 0 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfDataDesc_SetShape",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_SetShape" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDataDesc_SetShape" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_long_long, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfDataDesc_SetShape" "', argument " "3"" of type '" "XdmfInt64 *""'"); } arg3 = reinterpret_cast< XdmfInt64 * >(argp3); result = (XdmfInt32)(arg1)->SetShape(arg2,arg3); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_GetShape(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; XdmfInt64 *arg2 = (XdmfInt64 *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDataDesc_GetShape",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_GetShape" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_long_long, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDataDesc_GetShape" "', argument " "2"" of type '" "XdmfInt64 *""'"); } arg2 = reinterpret_cast< XdmfInt64 * >(argp2); result = (XdmfInt32)(arg1)->GetShape(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_GetShapeAsString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDataDesc_GetShapeAsString",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_GetShapeAsString" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); result = (XdmfConstString)(arg1)->GetShapeAsString(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_CopySelection(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; XdmfDataDesc *arg2 = (XdmfDataDesc *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDataDesc_CopySelection",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_CopySelection" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDataDesc_CopySelection" "', argument " "2"" of type '" "XdmfDataDesc *""'"); } arg2 = reinterpret_cast< XdmfDataDesc * >(argp2); result = (XdmfInt32)(arg1)->CopySelection(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_CopyShape(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; XdmfDataDesc *arg2 = (XdmfDataDesc *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDataDesc_CopyShape",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_CopyShape" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDataDesc_CopyShape" "', argument " "2"" of type '" "XdmfDataDesc *""'"); } arg2 = reinterpret_cast< XdmfDataDesc * >(argp2); result = (XdmfInt32)(arg1)->CopyShape(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_CopyType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; XdmfDataDesc *arg2 = (XdmfDataDesc *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDataDesc_CopyType",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_CopyType" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDataDesc_CopyType" "', argument " "2"" of type '" "XdmfDataDesc *""'"); } arg2 = reinterpret_cast< XdmfDataDesc * >(argp2); result = (XdmfInt32)(arg1)->CopyType(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_SetNumberOfElements(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDataDesc_SetNumberOfElements",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_SetNumberOfElements" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDataDesc_SetNumberOfElements" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfInt32)(arg1)->SetNumberOfElements(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_SetShapeFromString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDataDesc_SetShapeFromString",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_SetShapeFromString" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDataDesc_SetShapeFromString" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfInt32)(arg1)->SetShapeFromString(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_SelectAll(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDataDesc_SelectAll",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_SelectAll" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); result = (XdmfInt32)(arg1)->SelectAll(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_SelectHyperSlab(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; XdmfInt64 *arg2 = (XdmfInt64 *) 0 ; XdmfInt64 *arg3 = (XdmfInt64 *) 0 ; XdmfInt64 *arg4 = (XdmfInt64 *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; void *argp4 = 0 ; int res4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOO:XdmfDataDesc_SelectHyperSlab",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_SelectHyperSlab" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_long_long, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDataDesc_SelectHyperSlab" "', argument " "2"" of type '" "XdmfInt64 *""'"); } arg2 = reinterpret_cast< XdmfInt64 * >(argp2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_long_long, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfDataDesc_SelectHyperSlab" "', argument " "3"" of type '" "XdmfInt64 *""'"); } arg3 = reinterpret_cast< XdmfInt64 * >(argp3); res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_long_long, 0 | 0 ); if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "XdmfDataDesc_SelectHyperSlab" "', argument " "4"" of type '" "XdmfInt64 *""'"); } arg4 = reinterpret_cast< XdmfInt64 * >(argp4); result = (XdmfInt32)(arg1)->SelectHyperSlab(arg2,arg3,arg4); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_SelectHyperSlabFromString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; XdmfConstString arg3 = (XdmfConstString) 0 ; XdmfConstString arg4 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; int res4 ; char *buf4 = 0 ; int alloc4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOO:XdmfDataDesc_SelectHyperSlabFromString",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_SelectHyperSlabFromString" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDataDesc_SelectHyperSlabFromString" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfDataDesc_SelectHyperSlabFromString" "', argument " "3"" of type '" "XdmfConstString""'"); } arg3 = reinterpret_cast< XdmfConstString >(buf3); res4 = SWIG_AsCharPtrAndSize(obj3, &buf4, NULL, &alloc4); if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "XdmfDataDesc_SelectHyperSlabFromString" "', argument " "4"" of type '" "XdmfConstString""'"); } arg4 = reinterpret_cast< XdmfConstString >(buf4); result = (XdmfInt32)(arg1)->SelectHyperSlabFromString(arg2,arg3,arg4); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; if (alloc3 == SWIG_NEWOBJ) delete[] buf3; if (alloc4 == SWIG_NEWOBJ) delete[] buf4; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; if (alloc3 == SWIG_NEWOBJ) delete[] buf3; if (alloc4 == SWIG_NEWOBJ) delete[] buf4; return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_GetHyperSlab(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; XdmfInt64 *arg2 = (XdmfInt64 *) 0 ; XdmfInt64 *arg3 = (XdmfInt64 *) 0 ; XdmfInt64 *arg4 = (XdmfInt64 *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; void *argp4 = 0 ; int res4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOO:XdmfDataDesc_GetHyperSlab",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_GetHyperSlab" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_long_long, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDataDesc_GetHyperSlab" "', argument " "2"" of type '" "XdmfInt64 *""'"); } arg2 = reinterpret_cast< XdmfInt64 * >(argp2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_long_long, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfDataDesc_GetHyperSlab" "', argument " "3"" of type '" "XdmfInt64 *""'"); } arg3 = reinterpret_cast< XdmfInt64 * >(argp3); res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_long_long, 0 | 0 ); if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "XdmfDataDesc_GetHyperSlab" "', argument " "4"" of type '" "XdmfInt64 *""'"); } arg4 = reinterpret_cast< XdmfInt64 * >(argp4); result = (XdmfInt32)(arg1)->GetHyperSlab(arg2,arg3,arg4); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_GetHyperSlabAsString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDataDesc_GetHyperSlabAsString",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_GetHyperSlabAsString" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); result = (XdmfConstString)(arg1)->GetHyperSlabAsString(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_SelectCoordinates(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; XdmfInt64 arg2 ; XdmfInt64 *arg3 = (XdmfInt64 *) 0 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfDataDesc_SelectCoordinates",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_SelectCoordinates" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDataDesc_SelectCoordinates" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_long_long, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfDataDesc_SelectCoordinates" "', argument " "3"" of type '" "XdmfInt64 *""'"); } arg3 = reinterpret_cast< XdmfInt64 * >(argp3); result = (XdmfInt32)(arg1)->SelectCoordinates(arg2,arg3); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_SelectCoordinatesFromString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDataDesc_SelectCoordinatesFromString",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_SelectCoordinatesFromString" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDataDesc_SelectCoordinatesFromString" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfInt32)(arg1)->SelectCoordinatesFromString(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_GetCoordinates__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; XdmfInt64 arg2 ; XdmfInt64 arg3 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; long long val3 ; int ecode3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfInt64 *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfDataDesc_GetCoordinates",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_GetCoordinates" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDataDesc_GetCoordinates" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); ecode3 = SWIG_AsVal_long_SS_long(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "XdmfDataDesc_GetCoordinates" "', argument " "3"" of type '" "XdmfInt64""'"); } arg3 = static_cast< XdmfInt64 >(val3); result = (XdmfInt64 *)(arg1)->GetCoordinates(arg2,arg3); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_long_long, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_GetCoordinates__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt64 *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDataDesc_GetCoordinates",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_GetCoordinates" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDataDesc_GetCoordinates" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfInt64 *)(arg1)->GetCoordinates(arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_long_long, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_GetCoordinates__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt64 *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDataDesc_GetCoordinates",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_GetCoordinates" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); result = (XdmfInt64 *)(arg1)->GetCoordinates(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_long_long, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_GetCoordinates(PyObject *self, PyObject *args) { int argc; PyObject *argv[4]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 3); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDataDesc, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfDataDesc_GetCoordinates__SWIG_2(self, args); } } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDataDesc, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfDataDesc_GetCoordinates__SWIG_1(self, args); } } } if (argc == 3) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDataDesc, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[2], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfDataDesc_GetCoordinates__SWIG_0(self, args); } } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfDataDesc_GetCoordinates'.\n" " Possible C/C++ prototypes are:\n" " GetCoordinates(XdmfDataDesc *,XdmfInt64,XdmfInt64)\n" " GetCoordinates(XdmfDataDesc *,XdmfInt64)\n" " GetCoordinates(XdmfDataDesc *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_GetCoordinatesAsString__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; XdmfInt64 arg2 ; XdmfInt64 arg3 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; long long val3 ; int ecode3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfDataDesc_GetCoordinatesAsString",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_GetCoordinatesAsString" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDataDesc_GetCoordinatesAsString" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); ecode3 = SWIG_AsVal_long_SS_long(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "XdmfDataDesc_GetCoordinatesAsString" "', argument " "3"" of type '" "XdmfInt64""'"); } arg3 = static_cast< XdmfInt64 >(val3); result = (XdmfConstString)(arg1)->GetCoordinatesAsString(arg2,arg3); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_GetCoordinatesAsString__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDataDesc_GetCoordinatesAsString",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_GetCoordinatesAsString" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDataDesc_GetCoordinatesAsString" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfConstString)(arg1)->GetCoordinatesAsString(arg2); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_GetCoordinatesAsString__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDataDesc_GetCoordinatesAsString",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_GetCoordinatesAsString" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); result = (XdmfConstString)(arg1)->GetCoordinatesAsString(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_GetCoordinatesAsString(PyObject *self, PyObject *args) { int argc; PyObject *argv[4]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 3); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDataDesc, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfDataDesc_GetCoordinatesAsString__SWIG_2(self, args); } } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDataDesc, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfDataDesc_GetCoordinatesAsString__SWIG_1(self, args); } } } if (argc == 3) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDataDesc, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[2], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfDataDesc_GetCoordinatesAsString__SWIG_0(self, args); } } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfDataDesc_GetCoordinatesAsString'.\n" " Possible C/C++ prototypes are:\n" " GetCoordinatesAsString(XdmfDataDesc *,XdmfInt64,XdmfInt64)\n" " GetCoordinatesAsString(XdmfDataDesc *,XdmfInt64)\n" " GetCoordinatesAsString(XdmfDataDesc *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_GetSelectionSize(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt64 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDataDesc_GetSelectionSize",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_GetSelectionSize" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); result = (XdmfInt64)(arg1)->GetSelectionSize(); resultobj = SWIG_From_long_SS_long(static_cast< long long >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_GetNumberOfElements(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt64 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDataDesc_GetNumberOfElements",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_GetNumberOfElements" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); result = (XdmfInt64)(arg1)->GetNumberOfElements(); resultobj = SWIG_From_long_SS_long(static_cast< long long >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_GetCompression(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDataDesc_GetCompression",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_GetCompression" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); result = (XdmfInt32)(arg1)->GetCompression(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_SetCompression__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDataDesc_SetCompression",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_SetCompression" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDataDesc_SetCompression" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetCompression(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_SetCompression__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDataDesc_SetCompression",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_SetCompression" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); result = (XdmfInt32)(arg1)->SetCompression(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_SetCompression(PyObject *self, PyObject *args) { int argc; PyObject *argv[3]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 2); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDataDesc, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfDataDesc_SetCompression__SWIG_1(self, args); } } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDataDesc, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_int(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfDataDesc_SetCompression__SWIG_0(self, args); } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfDataDesc_SetCompression'.\n" " Possible C/C++ prototypes are:\n" " SetCompression(XdmfDataDesc *,XdmfInt32)\n" " SetCompression(XdmfDataDesc *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_GetRank(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDataDesc_GetRank",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_GetRank" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); result = (XdmfInt32)(arg1)->GetRank(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_GetDimension(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt64 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDataDesc_GetDimension",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_GetDimension" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDataDesc_GetDimension" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfInt64)(arg1)->GetDimension(arg2); resultobj = SWIG_From_long_SS_long(static_cast< long long >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_GetStart(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt64 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDataDesc_GetStart",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_GetStart" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDataDesc_GetStart" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfInt64)(arg1)->GetStart(arg2); resultobj = SWIG_From_long_SS_long(static_cast< long long >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_GetStride(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt64 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDataDesc_GetStride",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_GetStride" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDataDesc_GetStride" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfInt64)(arg1)->GetStride(arg2); resultobj = SWIG_From_long_SS_long(static_cast< long long >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_GetCount(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt64 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDataDesc_GetCount",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_GetCount" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDataDesc_GetCount" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfInt64)(arg1)->GetCount(arg2); resultobj = SWIG_From_long_SS_long(static_cast< long long >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_GetSelectionType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDataDesc_GetSelectionType",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_GetSelectionType" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); result = (XdmfInt32)(arg1)->GetSelectionType(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_GetSelectionTypeAsString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDataDesc_GetSelectionTypeAsString",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_GetSelectionTypeAsString" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); result = (XdmfConstString)(arg1)->GetSelectionTypeAsString(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_GetDataType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; hid_t result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDataDesc_GetDataType",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_GetDataType" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); result = (arg1)->GetDataType(); resultobj = SWIG_NewPointerObj((new hid_t(static_cast< const hid_t& >(result))), SWIGTYPE_p_hid_t, SWIG_POINTER_OWN | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_GetDataSpace(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; hid_t result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDataDesc_GetDataSpace",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_GetDataSpace" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); result = (arg1)->GetDataSpace(); resultobj = SWIG_NewPointerObj((new hid_t(static_cast< const hid_t& >(result))), SWIGTYPE_p_hid_t, SWIG_POINTER_OWN | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_GetElementSize(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt64 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDataDesc_GetElementSize",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_GetElementSize" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); result = (XdmfInt64)(arg1)->GetElementSize(); resultobj = SWIG_From_long_SS_long(static_cast< long long >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_AddCompoundMemberFromString__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; XdmfConstString arg3 = (XdmfConstString) 0 ; XdmfConstString arg4 = (XdmfConstString) 0 ; XdmfInt64 arg5 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; int res4 ; char *buf4 = 0 ; int alloc4 = 0 ; long long val5 ; int ecode5 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOOO:XdmfDataDesc_AddCompoundMemberFromString",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_AddCompoundMemberFromString" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDataDesc_AddCompoundMemberFromString" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfDataDesc_AddCompoundMemberFromString" "', argument " "3"" of type '" "XdmfConstString""'"); } arg3 = reinterpret_cast< XdmfConstString >(buf3); res4 = SWIG_AsCharPtrAndSize(obj3, &buf4, NULL, &alloc4); if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "XdmfDataDesc_AddCompoundMemberFromString" "', argument " "4"" of type '" "XdmfConstString""'"); } arg4 = reinterpret_cast< XdmfConstString >(buf4); ecode5 = SWIG_AsVal_long_SS_long(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "XdmfDataDesc_AddCompoundMemberFromString" "', argument " "5"" of type '" "XdmfInt64""'"); } arg5 = static_cast< XdmfInt64 >(val5); result = (XdmfInt32)(arg1)->AddCompoundMemberFromString(arg2,arg3,arg4,arg5); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; if (alloc3 == SWIG_NEWOBJ) delete[] buf3; if (alloc4 == SWIG_NEWOBJ) delete[] buf4; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; if (alloc3 == SWIG_NEWOBJ) delete[] buf3; if (alloc4 == SWIG_NEWOBJ) delete[] buf4; return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_AddCompoundMemberFromString__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; XdmfConstString arg3 = (XdmfConstString) 0 ; XdmfConstString arg4 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; int res4 ; char *buf4 = 0 ; int alloc4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOO:XdmfDataDesc_AddCompoundMemberFromString",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_AddCompoundMemberFromString" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDataDesc_AddCompoundMemberFromString" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfDataDesc_AddCompoundMemberFromString" "', argument " "3"" of type '" "XdmfConstString""'"); } arg3 = reinterpret_cast< XdmfConstString >(buf3); res4 = SWIG_AsCharPtrAndSize(obj3, &buf4, NULL, &alloc4); if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "XdmfDataDesc_AddCompoundMemberFromString" "', argument " "4"" of type '" "XdmfConstString""'"); } arg4 = reinterpret_cast< XdmfConstString >(buf4); result = (XdmfInt32)(arg1)->AddCompoundMemberFromString(arg2,arg3,arg4); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; if (alloc3 == SWIG_NEWOBJ) delete[] buf3; if (alloc4 == SWIG_NEWOBJ) delete[] buf4; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; if (alloc3 == SWIG_NEWOBJ) delete[] buf3; if (alloc4 == SWIG_NEWOBJ) delete[] buf4; return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_AddCompoundMemberFromString(PyObject *self, PyObject *args) { int argc; PyObject *argv[6]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 5); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 4) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDataDesc, 0); _v = SWIG_CheckState(res); if (_v) { int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { int res = SWIG_AsCharPtrAndSize(argv[3], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfDataDesc_AddCompoundMemberFromString__SWIG_1(self, args); } } } } } if (argc == 5) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDataDesc, 0); _v = SWIG_CheckState(res); if (_v) { int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { int res = SWIG_AsCharPtrAndSize(argv[3], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[4], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfDataDesc_AddCompoundMemberFromString__SWIG_0(self, args); } } } } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfDataDesc_AddCompoundMemberFromString'.\n" " Possible C/C++ prototypes are:\n" " AddCompoundMemberFromString(XdmfDataDesc *,XdmfConstString,XdmfConstString,XdmfConstString,XdmfInt64)\n" " AddCompoundMemberFromString(XdmfDataDesc *,XdmfConstString,XdmfConstString,XdmfConstString)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_GetNumberOfMembers(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt64 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDataDesc_GetNumberOfMembers",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_GetNumberOfMembers" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); result = (XdmfInt64)(arg1)->GetNumberOfMembers(); resultobj = SWIG_From_long_SS_long(static_cast< long long >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_GetMemberName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDataDesc_GetMemberName",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_GetMemberName" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDataDesc_GetMemberName" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfConstString)(arg1)->GetMemberName(arg2); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_GetMemberLength(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt64 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDataDesc_GetMemberLength",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_GetMemberLength" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDataDesc_GetMemberLength" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfInt64)(arg1)->GetMemberLength(arg2); resultobj = SWIG_From_long_SS_long(static_cast< long long >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_GetMemberSize(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt64 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDataDesc_GetMemberSize",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_GetMemberSize" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDataDesc_GetMemberSize" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfInt64)(arg1)->GetMemberSize(arg2); resultobj = SWIG_From_long_SS_long(static_cast< long long >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_GetMemberShape(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; XdmfInt64 arg2 ; XdmfInt64 *arg3 = (XdmfInt64 *) 0 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfDataDesc_GetMemberShape",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_GetMemberShape" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDataDesc_GetMemberShape" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_long_long, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfDataDesc_GetMemberShape" "', argument " "3"" of type '" "XdmfInt64 *""'"); } arg3 = reinterpret_cast< XdmfInt64 * >(argp3); result = (XdmfInt32)(arg1)->GetMemberShape(arg2,arg3); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_GetMemberShapeAsString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDataDesc_GetMemberShapeAsString",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_GetMemberShapeAsString" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDataDesc_GetMemberShapeAsString" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfConstString)(arg1)->GetMemberShapeAsString(arg2); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_GetMemberType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDataDesc_GetMemberType",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_GetMemberType" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDataDesc_GetMemberType" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfInt32)(arg1)->GetMemberType(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_GetMemberTypeAsString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDataDesc_GetMemberTypeAsString",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_GetMemberTypeAsString" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDataDesc_GetMemberTypeAsString" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfConstString)(arg1)->GetMemberTypeAsString(arg2); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_GetMemberOffset(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt64 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDataDesc_GetMemberOffset",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_GetMemberOffset" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDataDesc_GetMemberOffset" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfInt64)(arg1)->GetMemberOffset(arg2); resultobj = SWIG_From_long_SS_long(static_cast< long long >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_SetHeavyDataSetName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDataDesc_SetHeavyDataSetName",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_SetHeavyDataSetName" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDataDesc_SetHeavyDataSetName" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfInt32)(arg1)->SetHeavyDataSetName(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_GetHeavyDataSetName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDataDesc_GetHeavyDataSetName",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_GetHeavyDataSetName" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); result = (XdmfConstString)(arg1)->GetHeavyDataSetName(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_GetDsmBuffer(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfDsmBuffer *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDataDesc_GetDsmBuffer",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_GetDsmBuffer" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); result = (XdmfDsmBuffer *)(arg1)->GetDsmBuffer(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfDsmBuffer, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataDesc_SetDsmBuffer(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataDesc *arg1 = (XdmfDataDesc *) 0 ; XdmfDsmBuffer *arg2 = (XdmfDsmBuffer *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDataDesc_SetDsmBuffer",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataDesc_SetDsmBuffer" "', argument " "1"" of type '" "XdmfDataDesc *""'"); } arg1 = reinterpret_cast< XdmfDataDesc * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfDsmBuffer, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDataDesc_SetDsmBuffer" "', argument " "2"" of type '" "XdmfDsmBuffer *""'"); } arg2 = reinterpret_cast< XdmfDsmBuffer * >(argp2); result = (XdmfInt32)(arg1)->SetDsmBuffer(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *XdmfDataDesc_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; SWIG_TypeNewClientData(SWIGTYPE_p_XdmfDataDesc, SWIG_NewClientData(obj)); return SWIG_Py_Void(); } SWIGINTERN PyObject *_wrap_new_XdmfArray(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)":new_XdmfArray")) SWIG_fail; result = (XdmfArray *)new XdmfArray(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, SWIG_POINTER_NEW | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_delete_XdmfArray(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:delete_XdmfArray",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_XdmfArray" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); delete arg1; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_GetClassName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfArray_GetClassName",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_GetClassName" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); result = (XdmfConstString)(arg1)->GetClassName(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_GetTagName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfArray_GetTagName",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_GetTagName" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); result = (XdmfString)(arg1)->GetTagName(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_GetCoreLength(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfLength result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfArray_GetCoreLength",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_GetCoreLength" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); result = (XdmfLength)(arg1)->GetCoreLength(); resultobj = SWIG_From_long_SS_long(static_cast< long long >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_Allocate(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfArray_Allocate",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_Allocate" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); result = (XdmfInt32)(arg1)->Allocate(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_SetAllowAllocate(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfBoolean arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfArray_SetAllowAllocate",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_SetAllowAllocate" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_SetAllowAllocate" "', argument " "2"" of type '" "XdmfBoolean""'"); } arg2 = static_cast< XdmfBoolean >(val2); result = (XdmfInt32)(arg1)->SetAllowAllocate(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_GetAllowAllocate(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfBoolean result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfArray_GetAllowAllocate",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_GetAllowAllocate" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); result = (XdmfBoolean)(arg1)->GetAllowAllocate(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_SetShape(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt32 arg2 ; XdmfInt64 *arg3 = (XdmfInt64 *) 0 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfArray_SetShape",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_SetShape" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_SetShape" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_long_long, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfArray_SetShape" "', argument " "3"" of type '" "XdmfInt64 *""'"); } arg3 = reinterpret_cast< XdmfInt64 * >(argp3); result = (XdmfInt32)(arg1)->SetShape(arg2,arg3); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_SetShapeFromString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfArray_SetShapeFromString",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_SetShapeFromString" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfArray_SetShapeFromString" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfInt32)(arg1)->SetShapeFromString(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_SetShapeFromSelection(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfDataDesc *arg2 = (XdmfDataDesc *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfArray_SetShapeFromSelection",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_SetShapeFromSelection" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfArray_SetShapeFromSelection" "', argument " "2"" of type '" "XdmfDataDesc *""'"); } arg2 = reinterpret_cast< XdmfDataDesc * >(argp2); result = (XdmfInt32)(arg1)->SetShapeFromSelection(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_SetNumberOfElements(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfArray_SetNumberOfElements",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_SetNumberOfElements" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_SetNumberOfElements" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfInt32)(arg1)->SetNumberOfElements(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_ReformFromString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfArray_ReformFromString",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_ReformFromString" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfArray_ReformFromString" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfInt32)(arg1)->ReformFromString(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_ReformFromSelection(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfDataDesc *arg2 = (XdmfDataDesc *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfArray_ReformFromSelection",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_ReformFromSelection" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfArray_ReformFromSelection" "', argument " "2"" of type '" "XdmfDataDesc *""'"); } arg2 = reinterpret_cast< XdmfDataDesc * >(argp2); result = (XdmfInt32)(arg1)->ReformFromSelection(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_CopyShape(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfDataDesc *arg2 = (XdmfDataDesc *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfArray_CopyShape",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_CopyShape" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfArray_CopyShape" "', argument " "2"" of type '" "XdmfDataDesc *""'"); } arg2 = reinterpret_cast< XdmfDataDesc * >(argp2); result = (XdmfInt32)(arg1)->CopyShape(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_GetDataPointer__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfPointer result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfArray_GetDataPointer",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_GetDataPointer" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_GetDataPointer" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfPointer)(arg1)->GetDataPointer(arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_void, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_GetDataPointer__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfPointer result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfArray_GetDataPointer",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_GetDataPointer" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); result = (XdmfPointer)(arg1)->GetDataPointer(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_void, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_GetDataPointer(PyObject *self, PyObject *args) { int argc; PyObject *argv[3]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 2); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfArray_GetDataPointer__SWIG_1(self, args); } } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfArray_GetDataPointer__SWIG_0(self, args); } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfArray_GetDataPointer'.\n" " Possible C/C++ prototypes are:\n" " GetDataPointer(XdmfArray *,XdmfInt64)\n" " GetDataPointer(XdmfArray *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_SetDataPointer(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfPointer arg2 = (XdmfPointer) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfArray_SetDataPointer",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_SetDataPointer" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); res2 = SWIG_ConvertPtr(obj1,SWIG_as_voidptrptr(&arg2), 0, 0); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfArray_SetDataPointer" "', argument " "2"" of type '" "XdmfPointer""'"); } (arg1)->SetDataPointer(arg2); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_Reset__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfArray_Reset",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_Reset" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_Reset" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); (arg1)->Reset(arg2); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_Reset__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfArray_Reset",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_Reset" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); (arg1)->Reset(); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_Reset(PyObject *self, PyObject *args) { int argc; PyObject *argv[3]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 2); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfArray_Reset__SWIG_1(self, args); } } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_int(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfArray_Reset__SWIG_0(self, args); } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfArray_Reset'.\n" " Possible C/C++ prototypes are:\n" " Reset(XdmfArray *,XdmfInt32)\n" " Reset(XdmfArray *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_SetValueFromFloat64(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; XdmfFloat64 arg3 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; double val3 ; int ecode3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfArray_SetValueFromFloat64",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_SetValueFromFloat64" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_SetValueFromFloat64" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); ecode3 = SWIG_AsVal_double(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "XdmfArray_SetValueFromFloat64" "', argument " "3"" of type '" "XdmfFloat64""'"); } arg3 = static_cast< XdmfFloat64 >(val3); result = (XdmfInt32)(arg1)->SetValueFromFloat64(arg2,arg3); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_SetValueFromInt64(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; XdmfInt64 arg3 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; long long val3 ; int ecode3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfArray_SetValueFromInt64",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_SetValueFromInt64" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_SetValueFromInt64" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); ecode3 = SWIG_AsVal_long_SS_long(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "XdmfArray_SetValueFromInt64" "', argument " "3"" of type '" "XdmfInt64""'"); } arg3 = static_cast< XdmfInt64 >(val3); result = (XdmfInt32)(arg1)->SetValueFromInt64(arg2,arg3); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_SetValues__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; XdmfConstString arg3 = (XdmfConstString) 0 ; XdmfInt64 arg4 ; XdmfInt64 arg5 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; long long val4 ; int ecode4 = 0 ; long long val5 ; int ecode5 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOOO:XdmfArray_SetValues",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_SetValues" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_SetValues" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfArray_SetValues" "', argument " "3"" of type '" "XdmfConstString""'"); } arg3 = reinterpret_cast< XdmfConstString >(buf3); ecode4 = SWIG_AsVal_long_SS_long(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfArray_SetValues" "', argument " "4"" of type '" "XdmfInt64""'"); } arg4 = static_cast< XdmfInt64 >(val4); ecode5 = SWIG_AsVal_long_SS_long(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "XdmfArray_SetValues" "', argument " "5"" of type '" "XdmfInt64""'"); } arg5 = static_cast< XdmfInt64 >(val5); result = (XdmfInt32)(arg1)->SetValues(arg2,arg3,arg4,arg5); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return resultobj; fail: if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_SetValues__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; XdmfConstString arg3 = (XdmfConstString) 0 ; XdmfInt64 arg4 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; long long val4 ; int ecode4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOO:XdmfArray_SetValues",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_SetValues" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_SetValues" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfArray_SetValues" "', argument " "3"" of type '" "XdmfConstString""'"); } arg3 = reinterpret_cast< XdmfConstString >(buf3); ecode4 = SWIG_AsVal_long_SS_long(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfArray_SetValues" "', argument " "4"" of type '" "XdmfInt64""'"); } arg4 = static_cast< XdmfInt64 >(val4); result = (XdmfInt32)(arg1)->SetValues(arg2,arg3,arg4); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return resultobj; fail: if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_SetValues__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; XdmfConstString arg3 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfArray_SetValues",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_SetValues" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_SetValues" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfArray_SetValues" "', argument " "3"" of type '" "XdmfConstString""'"); } arg3 = reinterpret_cast< XdmfConstString >(buf3); result = (XdmfInt32)(arg1)->SetValues(arg2,arg3); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return resultobj; fail: if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_SetValues(PyObject *self, PyObject *args) { int argc; PyObject *argv[6]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 5); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 3) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfArray_SetValues__SWIG_2(self, args); } } } } if (argc == 4) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfArray_SetValues__SWIG_1(self, args); } } } } } if (argc == 5) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[4], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfArray_SetValues__SWIG_0(self, args); } } } } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfArray_SetValues'.\n" " Possible C/C++ prototypes are:\n" " SetValues(XdmfArray *,XdmfInt64,XdmfConstString,XdmfInt64,XdmfInt64)\n" " SetValues(XdmfArray *,XdmfInt64,XdmfConstString,XdmfInt64)\n" " SetValues(XdmfArray *,XdmfInt64,XdmfConstString)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_GetValuesAsInt8__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; XdmfInt8 *arg3 = (XdmfInt8 *) 0 ; XdmfInt64 arg4 ; XdmfInt64 arg5 ; XdmfInt64 arg6 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; long long val4 ; int ecode4 = 0 ; long long val5 ; int ecode5 = 0 ; long long val6 ; int ecode6 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; PyObject * obj5 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOOOO:XdmfArray_GetValuesAsInt8",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_GetValuesAsInt8" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_GetValuesAsInt8" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfArray_GetValuesAsInt8" "', argument " "3"" of type '" "XdmfInt8 *""'"); } arg3 = reinterpret_cast< XdmfInt8 * >(buf3); ecode4 = SWIG_AsVal_long_SS_long(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfArray_GetValuesAsInt8" "', argument " "4"" of type '" "XdmfInt64""'"); } arg4 = static_cast< XdmfInt64 >(val4); ecode5 = SWIG_AsVal_long_SS_long(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "XdmfArray_GetValuesAsInt8" "', argument " "5"" of type '" "XdmfInt64""'"); } arg5 = static_cast< XdmfInt64 >(val5); ecode6 = SWIG_AsVal_long_SS_long(obj5, &val6); if (!SWIG_IsOK(ecode6)) { SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "XdmfArray_GetValuesAsInt8" "', argument " "6"" of type '" "XdmfInt64""'"); } arg6 = static_cast< XdmfInt64 >(val6); result = (XdmfInt32)(arg1)->GetValuesAsInt8(arg2,arg3,arg4,arg5,arg6); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return resultobj; fail: if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_GetValuesAsInt8__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; XdmfInt8 *arg3 = (XdmfInt8 *) 0 ; XdmfInt64 arg4 ; XdmfInt64 arg5 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; long long val4 ; int ecode4 = 0 ; long long val5 ; int ecode5 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOOO:XdmfArray_GetValuesAsInt8",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_GetValuesAsInt8" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_GetValuesAsInt8" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfArray_GetValuesAsInt8" "', argument " "3"" of type '" "XdmfInt8 *""'"); } arg3 = reinterpret_cast< XdmfInt8 * >(buf3); ecode4 = SWIG_AsVal_long_SS_long(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfArray_GetValuesAsInt8" "', argument " "4"" of type '" "XdmfInt64""'"); } arg4 = static_cast< XdmfInt64 >(val4); ecode5 = SWIG_AsVal_long_SS_long(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "XdmfArray_GetValuesAsInt8" "', argument " "5"" of type '" "XdmfInt64""'"); } arg5 = static_cast< XdmfInt64 >(val5); result = (XdmfInt32)(arg1)->GetValuesAsInt8(arg2,arg3,arg4,arg5); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return resultobj; fail: if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_GetValuesAsInt8__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; XdmfInt8 *arg3 = (XdmfInt8 *) 0 ; XdmfInt64 arg4 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; long long val4 ; int ecode4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOO:XdmfArray_GetValuesAsInt8",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_GetValuesAsInt8" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_GetValuesAsInt8" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfArray_GetValuesAsInt8" "', argument " "3"" of type '" "XdmfInt8 *""'"); } arg3 = reinterpret_cast< XdmfInt8 * >(buf3); ecode4 = SWIG_AsVal_long_SS_long(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfArray_GetValuesAsInt8" "', argument " "4"" of type '" "XdmfInt64""'"); } arg4 = static_cast< XdmfInt64 >(val4); result = (XdmfInt32)(arg1)->GetValuesAsInt8(arg2,arg3,arg4); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return resultobj; fail: if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_GetValuesAsInt8(PyObject *self, PyObject *args) { int argc; PyObject *argv[7]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 6); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 4) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfArray_GetValuesAsInt8__SWIG_2(self, args); } } } } } if (argc == 5) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[4], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfArray_GetValuesAsInt8__SWIG_1(self, args); } } } } } } if (argc == 6) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[4], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[5], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfArray_GetValuesAsInt8__SWIG_0(self, args); } } } } } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfArray_GetValuesAsInt8'.\n" " Possible C/C++ prototypes are:\n" " GetValuesAsInt8(XdmfArray *,XdmfInt64,XdmfInt8 *,XdmfInt64,XdmfInt64,XdmfInt64)\n" " GetValuesAsInt8(XdmfArray *,XdmfInt64,XdmfInt8 *,XdmfInt64,XdmfInt64)\n" " GetValuesAsInt8(XdmfArray *,XdmfInt64,XdmfInt8 *,XdmfInt64)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_SetValuesFromInt8__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; XdmfInt8 *arg3 = (XdmfInt8 *) 0 ; XdmfInt64 arg4 ; XdmfInt64 arg5 ; XdmfInt64 arg6 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; long long val4 ; int ecode4 = 0 ; long long val5 ; int ecode5 = 0 ; long long val6 ; int ecode6 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; PyObject * obj5 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOOOO:XdmfArray_SetValuesFromInt8",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_SetValuesFromInt8" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_SetValuesFromInt8" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfArray_SetValuesFromInt8" "', argument " "3"" of type '" "XdmfInt8 *""'"); } arg3 = reinterpret_cast< XdmfInt8 * >(buf3); ecode4 = SWIG_AsVal_long_SS_long(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfArray_SetValuesFromInt8" "', argument " "4"" of type '" "XdmfInt64""'"); } arg4 = static_cast< XdmfInt64 >(val4); ecode5 = SWIG_AsVal_long_SS_long(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "XdmfArray_SetValuesFromInt8" "', argument " "5"" of type '" "XdmfInt64""'"); } arg5 = static_cast< XdmfInt64 >(val5); ecode6 = SWIG_AsVal_long_SS_long(obj5, &val6); if (!SWIG_IsOK(ecode6)) { SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "XdmfArray_SetValuesFromInt8" "', argument " "6"" of type '" "XdmfInt64""'"); } arg6 = static_cast< XdmfInt64 >(val6); result = (XdmfInt32)(arg1)->SetValuesFromInt8(arg2,arg3,arg4,arg5,arg6); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return resultobj; fail: if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_SetValuesFromInt8__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; XdmfInt8 *arg3 = (XdmfInt8 *) 0 ; XdmfInt64 arg4 ; XdmfInt64 arg5 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; long long val4 ; int ecode4 = 0 ; long long val5 ; int ecode5 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOOO:XdmfArray_SetValuesFromInt8",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_SetValuesFromInt8" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_SetValuesFromInt8" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfArray_SetValuesFromInt8" "', argument " "3"" of type '" "XdmfInt8 *""'"); } arg3 = reinterpret_cast< XdmfInt8 * >(buf3); ecode4 = SWIG_AsVal_long_SS_long(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfArray_SetValuesFromInt8" "', argument " "4"" of type '" "XdmfInt64""'"); } arg4 = static_cast< XdmfInt64 >(val4); ecode5 = SWIG_AsVal_long_SS_long(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "XdmfArray_SetValuesFromInt8" "', argument " "5"" of type '" "XdmfInt64""'"); } arg5 = static_cast< XdmfInt64 >(val5); result = (XdmfInt32)(arg1)->SetValuesFromInt8(arg2,arg3,arg4,arg5); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return resultobj; fail: if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_SetValuesFromInt8__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; XdmfInt8 *arg3 = (XdmfInt8 *) 0 ; XdmfInt64 arg4 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; long long val4 ; int ecode4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOO:XdmfArray_SetValuesFromInt8",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_SetValuesFromInt8" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_SetValuesFromInt8" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfArray_SetValuesFromInt8" "', argument " "3"" of type '" "XdmfInt8 *""'"); } arg3 = reinterpret_cast< XdmfInt8 * >(buf3); ecode4 = SWIG_AsVal_long_SS_long(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfArray_SetValuesFromInt8" "', argument " "4"" of type '" "XdmfInt64""'"); } arg4 = static_cast< XdmfInt64 >(val4); result = (XdmfInt32)(arg1)->SetValuesFromInt8(arg2,arg3,arg4); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return resultobj; fail: if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_SetValuesFromInt8(PyObject *self, PyObject *args) { int argc; PyObject *argv[7]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 6); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 4) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfArray_SetValuesFromInt8__SWIG_2(self, args); } } } } } if (argc == 5) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[4], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfArray_SetValuesFromInt8__SWIG_1(self, args); } } } } } } if (argc == 6) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[4], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[5], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfArray_SetValuesFromInt8__SWIG_0(self, args); } } } } } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfArray_SetValuesFromInt8'.\n" " Possible C/C++ prototypes are:\n" " SetValuesFromInt8(XdmfArray *,XdmfInt64,XdmfInt8 *,XdmfInt64,XdmfInt64,XdmfInt64)\n" " SetValuesFromInt8(XdmfArray *,XdmfInt64,XdmfInt8 *,XdmfInt64,XdmfInt64)\n" " SetValuesFromInt8(XdmfArray *,XdmfInt64,XdmfInt8 *,XdmfInt64)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_GetValuesAsInt32__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; XdmfInt32 *arg3 = (XdmfInt32 *) 0 ; XdmfInt64 arg4 ; XdmfInt64 arg5 ; XdmfInt64 arg6 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; long long val4 ; int ecode4 = 0 ; long long val5 ; int ecode5 = 0 ; long long val6 ; int ecode6 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; PyObject * obj5 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOOOO:XdmfArray_GetValuesAsInt32",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_GetValuesAsInt32" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_GetValuesAsInt32" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_int, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfArray_GetValuesAsInt32" "', argument " "3"" of type '" "XdmfInt32 *""'"); } arg3 = reinterpret_cast< XdmfInt32 * >(argp3); ecode4 = SWIG_AsVal_long_SS_long(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfArray_GetValuesAsInt32" "', argument " "4"" of type '" "XdmfInt64""'"); } arg4 = static_cast< XdmfInt64 >(val4); ecode5 = SWIG_AsVal_long_SS_long(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "XdmfArray_GetValuesAsInt32" "', argument " "5"" of type '" "XdmfInt64""'"); } arg5 = static_cast< XdmfInt64 >(val5); ecode6 = SWIG_AsVal_long_SS_long(obj5, &val6); if (!SWIG_IsOK(ecode6)) { SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "XdmfArray_GetValuesAsInt32" "', argument " "6"" of type '" "XdmfInt64""'"); } arg6 = static_cast< XdmfInt64 >(val6); result = (XdmfInt32)(arg1)->GetValuesAsInt32(arg2,arg3,arg4,arg5,arg6); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_GetValuesAsInt32__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; XdmfInt32 *arg3 = (XdmfInt32 *) 0 ; XdmfInt64 arg4 ; XdmfInt64 arg5 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; long long val4 ; int ecode4 = 0 ; long long val5 ; int ecode5 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOOO:XdmfArray_GetValuesAsInt32",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_GetValuesAsInt32" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_GetValuesAsInt32" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_int, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfArray_GetValuesAsInt32" "', argument " "3"" of type '" "XdmfInt32 *""'"); } arg3 = reinterpret_cast< XdmfInt32 * >(argp3); ecode4 = SWIG_AsVal_long_SS_long(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfArray_GetValuesAsInt32" "', argument " "4"" of type '" "XdmfInt64""'"); } arg4 = static_cast< XdmfInt64 >(val4); ecode5 = SWIG_AsVal_long_SS_long(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "XdmfArray_GetValuesAsInt32" "', argument " "5"" of type '" "XdmfInt64""'"); } arg5 = static_cast< XdmfInt64 >(val5); result = (XdmfInt32)(arg1)->GetValuesAsInt32(arg2,arg3,arg4,arg5); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_GetValuesAsInt32__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; XdmfInt32 *arg3 = (XdmfInt32 *) 0 ; XdmfInt64 arg4 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; long long val4 ; int ecode4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOO:XdmfArray_GetValuesAsInt32",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_GetValuesAsInt32" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_GetValuesAsInt32" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_int, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfArray_GetValuesAsInt32" "', argument " "3"" of type '" "XdmfInt32 *""'"); } arg3 = reinterpret_cast< XdmfInt32 * >(argp3); ecode4 = SWIG_AsVal_long_SS_long(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfArray_GetValuesAsInt32" "', argument " "4"" of type '" "XdmfInt64""'"); } arg4 = static_cast< XdmfInt64 >(val4); result = (XdmfInt32)(arg1)->GetValuesAsInt32(arg2,arg3,arg4); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_GetValuesAsInt32(PyObject *self, PyObject *args) { int argc; PyObject *argv[7]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 6); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 4) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_int, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfArray_GetValuesAsInt32__SWIG_2(self, args); } } } } } if (argc == 5) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_int, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[4], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfArray_GetValuesAsInt32__SWIG_1(self, args); } } } } } } if (argc == 6) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_int, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[4], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[5], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfArray_GetValuesAsInt32__SWIG_0(self, args); } } } } } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfArray_GetValuesAsInt32'.\n" " Possible C/C++ prototypes are:\n" " GetValuesAsInt32(XdmfArray *,XdmfInt64,XdmfInt32 *,XdmfInt64,XdmfInt64,XdmfInt64)\n" " GetValuesAsInt32(XdmfArray *,XdmfInt64,XdmfInt32 *,XdmfInt64,XdmfInt64)\n" " GetValuesAsInt32(XdmfArray *,XdmfInt64,XdmfInt32 *,XdmfInt64)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_SetValuesFromInt32__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; XdmfInt32 *arg3 = (XdmfInt32 *) 0 ; XdmfInt64 arg4 ; XdmfInt64 arg5 ; XdmfInt64 arg6 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; long long val4 ; int ecode4 = 0 ; long long val5 ; int ecode5 = 0 ; long long val6 ; int ecode6 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; PyObject * obj5 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOOOO:XdmfArray_SetValuesFromInt32",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_SetValuesFromInt32" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_SetValuesFromInt32" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_int, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfArray_SetValuesFromInt32" "', argument " "3"" of type '" "XdmfInt32 *""'"); } arg3 = reinterpret_cast< XdmfInt32 * >(argp3); ecode4 = SWIG_AsVal_long_SS_long(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfArray_SetValuesFromInt32" "', argument " "4"" of type '" "XdmfInt64""'"); } arg4 = static_cast< XdmfInt64 >(val4); ecode5 = SWIG_AsVal_long_SS_long(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "XdmfArray_SetValuesFromInt32" "', argument " "5"" of type '" "XdmfInt64""'"); } arg5 = static_cast< XdmfInt64 >(val5); ecode6 = SWIG_AsVal_long_SS_long(obj5, &val6); if (!SWIG_IsOK(ecode6)) { SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "XdmfArray_SetValuesFromInt32" "', argument " "6"" of type '" "XdmfInt64""'"); } arg6 = static_cast< XdmfInt64 >(val6); result = (XdmfInt32)(arg1)->SetValuesFromInt32(arg2,arg3,arg4,arg5,arg6); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_SetValuesFromInt32__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; XdmfInt32 *arg3 = (XdmfInt32 *) 0 ; XdmfInt64 arg4 ; XdmfInt64 arg5 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; long long val4 ; int ecode4 = 0 ; long long val5 ; int ecode5 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOOO:XdmfArray_SetValuesFromInt32",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_SetValuesFromInt32" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_SetValuesFromInt32" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_int, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfArray_SetValuesFromInt32" "', argument " "3"" of type '" "XdmfInt32 *""'"); } arg3 = reinterpret_cast< XdmfInt32 * >(argp3); ecode4 = SWIG_AsVal_long_SS_long(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfArray_SetValuesFromInt32" "', argument " "4"" of type '" "XdmfInt64""'"); } arg4 = static_cast< XdmfInt64 >(val4); ecode5 = SWIG_AsVal_long_SS_long(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "XdmfArray_SetValuesFromInt32" "', argument " "5"" of type '" "XdmfInt64""'"); } arg5 = static_cast< XdmfInt64 >(val5); result = (XdmfInt32)(arg1)->SetValuesFromInt32(arg2,arg3,arg4,arg5); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_SetValuesFromInt32__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; XdmfInt32 *arg3 = (XdmfInt32 *) 0 ; XdmfInt64 arg4 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; long long val4 ; int ecode4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOO:XdmfArray_SetValuesFromInt32",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_SetValuesFromInt32" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_SetValuesFromInt32" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_int, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfArray_SetValuesFromInt32" "', argument " "3"" of type '" "XdmfInt32 *""'"); } arg3 = reinterpret_cast< XdmfInt32 * >(argp3); ecode4 = SWIG_AsVal_long_SS_long(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfArray_SetValuesFromInt32" "', argument " "4"" of type '" "XdmfInt64""'"); } arg4 = static_cast< XdmfInt64 >(val4); result = (XdmfInt32)(arg1)->SetValuesFromInt32(arg2,arg3,arg4); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_SetValuesFromInt32(PyObject *self, PyObject *args) { int argc; PyObject *argv[7]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 6); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 4) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_int, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfArray_SetValuesFromInt32__SWIG_2(self, args); } } } } } if (argc == 5) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_int, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[4], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfArray_SetValuesFromInt32__SWIG_1(self, args); } } } } } } if (argc == 6) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_int, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[4], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[5], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfArray_SetValuesFromInt32__SWIG_0(self, args); } } } } } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfArray_SetValuesFromInt32'.\n" " Possible C/C++ prototypes are:\n" " SetValuesFromInt32(XdmfArray *,XdmfInt64,XdmfInt32 *,XdmfInt64,XdmfInt64,XdmfInt64)\n" " SetValuesFromInt32(XdmfArray *,XdmfInt64,XdmfInt32 *,XdmfInt64,XdmfInt64)\n" " SetValuesFromInt32(XdmfArray *,XdmfInt64,XdmfInt32 *,XdmfInt64)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_GetValuesAsInt64__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; XdmfInt64 *arg3 = (XdmfInt64 *) 0 ; XdmfInt64 arg4 ; XdmfInt64 arg5 ; XdmfInt64 arg6 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; long long val4 ; int ecode4 = 0 ; long long val5 ; int ecode5 = 0 ; long long val6 ; int ecode6 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; PyObject * obj5 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOOOO:XdmfArray_GetValuesAsInt64",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_GetValuesAsInt64" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_GetValuesAsInt64" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_long_long, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfArray_GetValuesAsInt64" "', argument " "3"" of type '" "XdmfInt64 *""'"); } arg3 = reinterpret_cast< XdmfInt64 * >(argp3); ecode4 = SWIG_AsVal_long_SS_long(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfArray_GetValuesAsInt64" "', argument " "4"" of type '" "XdmfInt64""'"); } arg4 = static_cast< XdmfInt64 >(val4); ecode5 = SWIG_AsVal_long_SS_long(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "XdmfArray_GetValuesAsInt64" "', argument " "5"" of type '" "XdmfInt64""'"); } arg5 = static_cast< XdmfInt64 >(val5); ecode6 = SWIG_AsVal_long_SS_long(obj5, &val6); if (!SWIG_IsOK(ecode6)) { SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "XdmfArray_GetValuesAsInt64" "', argument " "6"" of type '" "XdmfInt64""'"); } arg6 = static_cast< XdmfInt64 >(val6); result = (XdmfInt32)(arg1)->GetValuesAsInt64(arg2,arg3,arg4,arg5,arg6); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_GetValuesAsInt64__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; XdmfInt64 *arg3 = (XdmfInt64 *) 0 ; XdmfInt64 arg4 ; XdmfInt64 arg5 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; long long val4 ; int ecode4 = 0 ; long long val5 ; int ecode5 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOOO:XdmfArray_GetValuesAsInt64",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_GetValuesAsInt64" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_GetValuesAsInt64" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_long_long, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfArray_GetValuesAsInt64" "', argument " "3"" of type '" "XdmfInt64 *""'"); } arg3 = reinterpret_cast< XdmfInt64 * >(argp3); ecode4 = SWIG_AsVal_long_SS_long(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfArray_GetValuesAsInt64" "', argument " "4"" of type '" "XdmfInt64""'"); } arg4 = static_cast< XdmfInt64 >(val4); ecode5 = SWIG_AsVal_long_SS_long(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "XdmfArray_GetValuesAsInt64" "', argument " "5"" of type '" "XdmfInt64""'"); } arg5 = static_cast< XdmfInt64 >(val5); result = (XdmfInt32)(arg1)->GetValuesAsInt64(arg2,arg3,arg4,arg5); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_GetValuesAsInt64__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; XdmfInt64 *arg3 = (XdmfInt64 *) 0 ; XdmfInt64 arg4 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; long long val4 ; int ecode4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOO:XdmfArray_GetValuesAsInt64",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_GetValuesAsInt64" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_GetValuesAsInt64" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_long_long, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfArray_GetValuesAsInt64" "', argument " "3"" of type '" "XdmfInt64 *""'"); } arg3 = reinterpret_cast< XdmfInt64 * >(argp3); ecode4 = SWIG_AsVal_long_SS_long(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfArray_GetValuesAsInt64" "', argument " "4"" of type '" "XdmfInt64""'"); } arg4 = static_cast< XdmfInt64 >(val4); result = (XdmfInt32)(arg1)->GetValuesAsInt64(arg2,arg3,arg4); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_GetValuesAsInt64(PyObject *self, PyObject *args) { int argc; PyObject *argv[7]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 6); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 4) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_long_long, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfArray_GetValuesAsInt64__SWIG_2(self, args); } } } } } if (argc == 5) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_long_long, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[4], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfArray_GetValuesAsInt64__SWIG_1(self, args); } } } } } } if (argc == 6) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_long_long, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[4], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[5], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfArray_GetValuesAsInt64__SWIG_0(self, args); } } } } } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfArray_GetValuesAsInt64'.\n" " Possible C/C++ prototypes are:\n" " GetValuesAsInt64(XdmfArray *,XdmfInt64,XdmfInt64 *,XdmfInt64,XdmfInt64,XdmfInt64)\n" " GetValuesAsInt64(XdmfArray *,XdmfInt64,XdmfInt64 *,XdmfInt64,XdmfInt64)\n" " GetValuesAsInt64(XdmfArray *,XdmfInt64,XdmfInt64 *,XdmfInt64)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_SetValuesFromInt64__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; XdmfInt64 *arg3 = (XdmfInt64 *) 0 ; XdmfInt64 arg4 ; XdmfInt64 arg5 ; XdmfInt64 arg6 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; long long val4 ; int ecode4 = 0 ; long long val5 ; int ecode5 = 0 ; long long val6 ; int ecode6 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; PyObject * obj5 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOOOO:XdmfArray_SetValuesFromInt64",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_SetValuesFromInt64" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_SetValuesFromInt64" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_long_long, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfArray_SetValuesFromInt64" "', argument " "3"" of type '" "XdmfInt64 *""'"); } arg3 = reinterpret_cast< XdmfInt64 * >(argp3); ecode4 = SWIG_AsVal_long_SS_long(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfArray_SetValuesFromInt64" "', argument " "4"" of type '" "XdmfInt64""'"); } arg4 = static_cast< XdmfInt64 >(val4); ecode5 = SWIG_AsVal_long_SS_long(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "XdmfArray_SetValuesFromInt64" "', argument " "5"" of type '" "XdmfInt64""'"); } arg5 = static_cast< XdmfInt64 >(val5); ecode6 = SWIG_AsVal_long_SS_long(obj5, &val6); if (!SWIG_IsOK(ecode6)) { SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "XdmfArray_SetValuesFromInt64" "', argument " "6"" of type '" "XdmfInt64""'"); } arg6 = static_cast< XdmfInt64 >(val6); result = (XdmfInt32)(arg1)->SetValuesFromInt64(arg2,arg3,arg4,arg5,arg6); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_SetValuesFromInt64__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; XdmfInt64 *arg3 = (XdmfInt64 *) 0 ; XdmfInt64 arg4 ; XdmfInt64 arg5 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; long long val4 ; int ecode4 = 0 ; long long val5 ; int ecode5 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOOO:XdmfArray_SetValuesFromInt64",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_SetValuesFromInt64" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_SetValuesFromInt64" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_long_long, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfArray_SetValuesFromInt64" "', argument " "3"" of type '" "XdmfInt64 *""'"); } arg3 = reinterpret_cast< XdmfInt64 * >(argp3); ecode4 = SWIG_AsVal_long_SS_long(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfArray_SetValuesFromInt64" "', argument " "4"" of type '" "XdmfInt64""'"); } arg4 = static_cast< XdmfInt64 >(val4); ecode5 = SWIG_AsVal_long_SS_long(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "XdmfArray_SetValuesFromInt64" "', argument " "5"" of type '" "XdmfInt64""'"); } arg5 = static_cast< XdmfInt64 >(val5); result = (XdmfInt32)(arg1)->SetValuesFromInt64(arg2,arg3,arg4,arg5); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_SetValuesFromInt64__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; XdmfInt64 *arg3 = (XdmfInt64 *) 0 ; XdmfInt64 arg4 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; long long val4 ; int ecode4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOO:XdmfArray_SetValuesFromInt64",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_SetValuesFromInt64" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_SetValuesFromInt64" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_long_long, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfArray_SetValuesFromInt64" "', argument " "3"" of type '" "XdmfInt64 *""'"); } arg3 = reinterpret_cast< XdmfInt64 * >(argp3); ecode4 = SWIG_AsVal_long_SS_long(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfArray_SetValuesFromInt64" "', argument " "4"" of type '" "XdmfInt64""'"); } arg4 = static_cast< XdmfInt64 >(val4); result = (XdmfInt32)(arg1)->SetValuesFromInt64(arg2,arg3,arg4); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_SetValuesFromInt64(PyObject *self, PyObject *args) { int argc; PyObject *argv[7]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 6); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 4) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_long_long, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfArray_SetValuesFromInt64__SWIG_2(self, args); } } } } } if (argc == 5) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_long_long, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[4], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfArray_SetValuesFromInt64__SWIG_1(self, args); } } } } } } if (argc == 6) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_long_long, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[4], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[5], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfArray_SetValuesFromInt64__SWIG_0(self, args); } } } } } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfArray_SetValuesFromInt64'.\n" " Possible C/C++ prototypes are:\n" " SetValuesFromInt64(XdmfArray *,XdmfInt64,XdmfInt64 *,XdmfInt64,XdmfInt64,XdmfInt64)\n" " SetValuesFromInt64(XdmfArray *,XdmfInt64,XdmfInt64 *,XdmfInt64,XdmfInt64)\n" " SetValuesFromInt64(XdmfArray *,XdmfInt64,XdmfInt64 *,XdmfInt64)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_GetValuesAsFloat32__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; XdmfFloat32 *arg3 = (XdmfFloat32 *) 0 ; XdmfInt64 arg4 ; XdmfInt64 arg5 ; XdmfInt64 arg6 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; long long val4 ; int ecode4 = 0 ; long long val5 ; int ecode5 = 0 ; long long val6 ; int ecode6 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; PyObject * obj5 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOOOO:XdmfArray_GetValuesAsFloat32",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_GetValuesAsFloat32" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_GetValuesAsFloat32" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_float, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfArray_GetValuesAsFloat32" "', argument " "3"" of type '" "XdmfFloat32 *""'"); } arg3 = reinterpret_cast< XdmfFloat32 * >(argp3); ecode4 = SWIG_AsVal_long_SS_long(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfArray_GetValuesAsFloat32" "', argument " "4"" of type '" "XdmfInt64""'"); } arg4 = static_cast< XdmfInt64 >(val4); ecode5 = SWIG_AsVal_long_SS_long(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "XdmfArray_GetValuesAsFloat32" "', argument " "5"" of type '" "XdmfInt64""'"); } arg5 = static_cast< XdmfInt64 >(val5); ecode6 = SWIG_AsVal_long_SS_long(obj5, &val6); if (!SWIG_IsOK(ecode6)) { SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "XdmfArray_GetValuesAsFloat32" "', argument " "6"" of type '" "XdmfInt64""'"); } arg6 = static_cast< XdmfInt64 >(val6); result = (XdmfInt32)(arg1)->GetValuesAsFloat32(arg2,arg3,arg4,arg5,arg6); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_GetValuesAsFloat32__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; XdmfFloat32 *arg3 = (XdmfFloat32 *) 0 ; XdmfInt64 arg4 ; XdmfInt64 arg5 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; long long val4 ; int ecode4 = 0 ; long long val5 ; int ecode5 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOOO:XdmfArray_GetValuesAsFloat32",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_GetValuesAsFloat32" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_GetValuesAsFloat32" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_float, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfArray_GetValuesAsFloat32" "', argument " "3"" of type '" "XdmfFloat32 *""'"); } arg3 = reinterpret_cast< XdmfFloat32 * >(argp3); ecode4 = SWIG_AsVal_long_SS_long(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfArray_GetValuesAsFloat32" "', argument " "4"" of type '" "XdmfInt64""'"); } arg4 = static_cast< XdmfInt64 >(val4); ecode5 = SWIG_AsVal_long_SS_long(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "XdmfArray_GetValuesAsFloat32" "', argument " "5"" of type '" "XdmfInt64""'"); } arg5 = static_cast< XdmfInt64 >(val5); result = (XdmfInt32)(arg1)->GetValuesAsFloat32(arg2,arg3,arg4,arg5); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_GetValuesAsFloat32__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; XdmfFloat32 *arg3 = (XdmfFloat32 *) 0 ; XdmfInt64 arg4 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; long long val4 ; int ecode4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOO:XdmfArray_GetValuesAsFloat32",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_GetValuesAsFloat32" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_GetValuesAsFloat32" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_float, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfArray_GetValuesAsFloat32" "', argument " "3"" of type '" "XdmfFloat32 *""'"); } arg3 = reinterpret_cast< XdmfFloat32 * >(argp3); ecode4 = SWIG_AsVal_long_SS_long(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfArray_GetValuesAsFloat32" "', argument " "4"" of type '" "XdmfInt64""'"); } arg4 = static_cast< XdmfInt64 >(val4); result = (XdmfInt32)(arg1)->GetValuesAsFloat32(arg2,arg3,arg4); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_GetValuesAsFloat32(PyObject *self, PyObject *args) { int argc; PyObject *argv[7]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 6); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 4) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_float, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfArray_GetValuesAsFloat32__SWIG_2(self, args); } } } } } if (argc == 5) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_float, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[4], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfArray_GetValuesAsFloat32__SWIG_1(self, args); } } } } } } if (argc == 6) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_float, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[4], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[5], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfArray_GetValuesAsFloat32__SWIG_0(self, args); } } } } } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfArray_GetValuesAsFloat32'.\n" " Possible C/C++ prototypes are:\n" " GetValuesAsFloat32(XdmfArray *,XdmfInt64,XdmfFloat32 *,XdmfInt64,XdmfInt64,XdmfInt64)\n" " GetValuesAsFloat32(XdmfArray *,XdmfInt64,XdmfFloat32 *,XdmfInt64,XdmfInt64)\n" " GetValuesAsFloat32(XdmfArray *,XdmfInt64,XdmfFloat32 *,XdmfInt64)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_SetValuesFromFloat32__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; XdmfFloat32 *arg3 = (XdmfFloat32 *) 0 ; XdmfInt64 arg4 ; XdmfInt64 arg5 ; XdmfInt64 arg6 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; long long val4 ; int ecode4 = 0 ; long long val5 ; int ecode5 = 0 ; long long val6 ; int ecode6 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; PyObject * obj5 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOOOO:XdmfArray_SetValuesFromFloat32",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_SetValuesFromFloat32" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_SetValuesFromFloat32" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_float, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfArray_SetValuesFromFloat32" "', argument " "3"" of type '" "XdmfFloat32 *""'"); } arg3 = reinterpret_cast< XdmfFloat32 * >(argp3); ecode4 = SWIG_AsVal_long_SS_long(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfArray_SetValuesFromFloat32" "', argument " "4"" of type '" "XdmfInt64""'"); } arg4 = static_cast< XdmfInt64 >(val4); ecode5 = SWIG_AsVal_long_SS_long(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "XdmfArray_SetValuesFromFloat32" "', argument " "5"" of type '" "XdmfInt64""'"); } arg5 = static_cast< XdmfInt64 >(val5); ecode6 = SWIG_AsVal_long_SS_long(obj5, &val6); if (!SWIG_IsOK(ecode6)) { SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "XdmfArray_SetValuesFromFloat32" "', argument " "6"" of type '" "XdmfInt64""'"); } arg6 = static_cast< XdmfInt64 >(val6); result = (XdmfInt32)(arg1)->SetValuesFromFloat32(arg2,arg3,arg4,arg5,arg6); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_SetValuesFromFloat32__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; XdmfFloat32 *arg3 = (XdmfFloat32 *) 0 ; XdmfInt64 arg4 ; XdmfInt64 arg5 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; long long val4 ; int ecode4 = 0 ; long long val5 ; int ecode5 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOOO:XdmfArray_SetValuesFromFloat32",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_SetValuesFromFloat32" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_SetValuesFromFloat32" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_float, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfArray_SetValuesFromFloat32" "', argument " "3"" of type '" "XdmfFloat32 *""'"); } arg3 = reinterpret_cast< XdmfFloat32 * >(argp3); ecode4 = SWIG_AsVal_long_SS_long(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfArray_SetValuesFromFloat32" "', argument " "4"" of type '" "XdmfInt64""'"); } arg4 = static_cast< XdmfInt64 >(val4); ecode5 = SWIG_AsVal_long_SS_long(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "XdmfArray_SetValuesFromFloat32" "', argument " "5"" of type '" "XdmfInt64""'"); } arg5 = static_cast< XdmfInt64 >(val5); result = (XdmfInt32)(arg1)->SetValuesFromFloat32(arg2,arg3,arg4,arg5); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_SetValuesFromFloat32__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; XdmfFloat32 *arg3 = (XdmfFloat32 *) 0 ; XdmfInt64 arg4 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; long long val4 ; int ecode4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOO:XdmfArray_SetValuesFromFloat32",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_SetValuesFromFloat32" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_SetValuesFromFloat32" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_float, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfArray_SetValuesFromFloat32" "', argument " "3"" of type '" "XdmfFloat32 *""'"); } arg3 = reinterpret_cast< XdmfFloat32 * >(argp3); ecode4 = SWIG_AsVal_long_SS_long(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfArray_SetValuesFromFloat32" "', argument " "4"" of type '" "XdmfInt64""'"); } arg4 = static_cast< XdmfInt64 >(val4); result = (XdmfInt32)(arg1)->SetValuesFromFloat32(arg2,arg3,arg4); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_SetValuesFromFloat32(PyObject *self, PyObject *args) { int argc; PyObject *argv[7]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 6); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 4) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_float, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfArray_SetValuesFromFloat32__SWIG_2(self, args); } } } } } if (argc == 5) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_float, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[4], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfArray_SetValuesFromFloat32__SWIG_1(self, args); } } } } } } if (argc == 6) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_float, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[4], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[5], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfArray_SetValuesFromFloat32__SWIG_0(self, args); } } } } } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfArray_SetValuesFromFloat32'.\n" " Possible C/C++ prototypes are:\n" " SetValuesFromFloat32(XdmfArray *,XdmfInt64,XdmfFloat32 *,XdmfInt64,XdmfInt64,XdmfInt64)\n" " SetValuesFromFloat32(XdmfArray *,XdmfInt64,XdmfFloat32 *,XdmfInt64,XdmfInt64)\n" " SetValuesFromFloat32(XdmfArray *,XdmfInt64,XdmfFloat32 *,XdmfInt64)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_GetValuesAsFloat64__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; XdmfFloat64 *arg3 = (XdmfFloat64 *) 0 ; XdmfInt64 arg4 ; XdmfInt64 arg5 ; XdmfInt64 arg6 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; long long val4 ; int ecode4 = 0 ; long long val5 ; int ecode5 = 0 ; long long val6 ; int ecode6 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; PyObject * obj5 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOOOO:XdmfArray_GetValuesAsFloat64",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_GetValuesAsFloat64" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_GetValuesAsFloat64" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_double, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfArray_GetValuesAsFloat64" "', argument " "3"" of type '" "XdmfFloat64 *""'"); } arg3 = reinterpret_cast< XdmfFloat64 * >(argp3); ecode4 = SWIG_AsVal_long_SS_long(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfArray_GetValuesAsFloat64" "', argument " "4"" of type '" "XdmfInt64""'"); } arg4 = static_cast< XdmfInt64 >(val4); ecode5 = SWIG_AsVal_long_SS_long(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "XdmfArray_GetValuesAsFloat64" "', argument " "5"" of type '" "XdmfInt64""'"); } arg5 = static_cast< XdmfInt64 >(val5); ecode6 = SWIG_AsVal_long_SS_long(obj5, &val6); if (!SWIG_IsOK(ecode6)) { SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "XdmfArray_GetValuesAsFloat64" "', argument " "6"" of type '" "XdmfInt64""'"); } arg6 = static_cast< XdmfInt64 >(val6); result = (XdmfInt32)(arg1)->GetValuesAsFloat64(arg2,arg3,arg4,arg5,arg6); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_GetValuesAsFloat64__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; XdmfFloat64 *arg3 = (XdmfFloat64 *) 0 ; XdmfInt64 arg4 ; XdmfInt64 arg5 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; long long val4 ; int ecode4 = 0 ; long long val5 ; int ecode5 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOOO:XdmfArray_GetValuesAsFloat64",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_GetValuesAsFloat64" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_GetValuesAsFloat64" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_double, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfArray_GetValuesAsFloat64" "', argument " "3"" of type '" "XdmfFloat64 *""'"); } arg3 = reinterpret_cast< XdmfFloat64 * >(argp3); ecode4 = SWIG_AsVal_long_SS_long(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfArray_GetValuesAsFloat64" "', argument " "4"" of type '" "XdmfInt64""'"); } arg4 = static_cast< XdmfInt64 >(val4); ecode5 = SWIG_AsVal_long_SS_long(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "XdmfArray_GetValuesAsFloat64" "', argument " "5"" of type '" "XdmfInt64""'"); } arg5 = static_cast< XdmfInt64 >(val5); result = (XdmfInt32)(arg1)->GetValuesAsFloat64(arg2,arg3,arg4,arg5); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_GetValuesAsFloat64__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; XdmfFloat64 *arg3 = (XdmfFloat64 *) 0 ; XdmfInt64 arg4 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; long long val4 ; int ecode4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOO:XdmfArray_GetValuesAsFloat64",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_GetValuesAsFloat64" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_GetValuesAsFloat64" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_double, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfArray_GetValuesAsFloat64" "', argument " "3"" of type '" "XdmfFloat64 *""'"); } arg3 = reinterpret_cast< XdmfFloat64 * >(argp3); ecode4 = SWIG_AsVal_long_SS_long(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfArray_GetValuesAsFloat64" "', argument " "4"" of type '" "XdmfInt64""'"); } arg4 = static_cast< XdmfInt64 >(val4); result = (XdmfInt32)(arg1)->GetValuesAsFloat64(arg2,arg3,arg4); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_GetValuesAsFloat64(PyObject *self, PyObject *args) { int argc; PyObject *argv[7]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 6); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 4) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_double, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfArray_GetValuesAsFloat64__SWIG_2(self, args); } } } } } if (argc == 5) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_double, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[4], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfArray_GetValuesAsFloat64__SWIG_1(self, args); } } } } } } if (argc == 6) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_double, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[4], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[5], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfArray_GetValuesAsFloat64__SWIG_0(self, args); } } } } } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfArray_GetValuesAsFloat64'.\n" " Possible C/C++ prototypes are:\n" " GetValuesAsFloat64(XdmfArray *,XdmfInt64,XdmfFloat64 *,XdmfInt64,XdmfInt64,XdmfInt64)\n" " GetValuesAsFloat64(XdmfArray *,XdmfInt64,XdmfFloat64 *,XdmfInt64,XdmfInt64)\n" " GetValuesAsFloat64(XdmfArray *,XdmfInt64,XdmfFloat64 *,XdmfInt64)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_SetValuesFromFloat64__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; XdmfFloat64 *arg3 = (XdmfFloat64 *) 0 ; XdmfInt64 arg4 ; XdmfInt64 arg5 ; XdmfInt64 arg6 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; long long val4 ; int ecode4 = 0 ; long long val5 ; int ecode5 = 0 ; long long val6 ; int ecode6 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; PyObject * obj5 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOOOO:XdmfArray_SetValuesFromFloat64",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_SetValuesFromFloat64" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_SetValuesFromFloat64" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_double, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfArray_SetValuesFromFloat64" "', argument " "3"" of type '" "XdmfFloat64 *""'"); } arg3 = reinterpret_cast< XdmfFloat64 * >(argp3); ecode4 = SWIG_AsVal_long_SS_long(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfArray_SetValuesFromFloat64" "', argument " "4"" of type '" "XdmfInt64""'"); } arg4 = static_cast< XdmfInt64 >(val4); ecode5 = SWIG_AsVal_long_SS_long(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "XdmfArray_SetValuesFromFloat64" "', argument " "5"" of type '" "XdmfInt64""'"); } arg5 = static_cast< XdmfInt64 >(val5); ecode6 = SWIG_AsVal_long_SS_long(obj5, &val6); if (!SWIG_IsOK(ecode6)) { SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "XdmfArray_SetValuesFromFloat64" "', argument " "6"" of type '" "XdmfInt64""'"); } arg6 = static_cast< XdmfInt64 >(val6); result = (XdmfInt32)(arg1)->SetValuesFromFloat64(arg2,arg3,arg4,arg5,arg6); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_SetValuesFromFloat64__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; XdmfFloat64 *arg3 = (XdmfFloat64 *) 0 ; XdmfInt64 arg4 ; XdmfInt64 arg5 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; long long val4 ; int ecode4 = 0 ; long long val5 ; int ecode5 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOOO:XdmfArray_SetValuesFromFloat64",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_SetValuesFromFloat64" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_SetValuesFromFloat64" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_double, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfArray_SetValuesFromFloat64" "', argument " "3"" of type '" "XdmfFloat64 *""'"); } arg3 = reinterpret_cast< XdmfFloat64 * >(argp3); ecode4 = SWIG_AsVal_long_SS_long(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfArray_SetValuesFromFloat64" "', argument " "4"" of type '" "XdmfInt64""'"); } arg4 = static_cast< XdmfInt64 >(val4); ecode5 = SWIG_AsVal_long_SS_long(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "XdmfArray_SetValuesFromFloat64" "', argument " "5"" of type '" "XdmfInt64""'"); } arg5 = static_cast< XdmfInt64 >(val5); result = (XdmfInt32)(arg1)->SetValuesFromFloat64(arg2,arg3,arg4,arg5); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_SetValuesFromFloat64__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; XdmfFloat64 *arg3 = (XdmfFloat64 *) 0 ; XdmfInt64 arg4 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; long long val4 ; int ecode4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOO:XdmfArray_SetValuesFromFloat64",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_SetValuesFromFloat64" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_SetValuesFromFloat64" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_double, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfArray_SetValuesFromFloat64" "', argument " "3"" of type '" "XdmfFloat64 *""'"); } arg3 = reinterpret_cast< XdmfFloat64 * >(argp3); ecode4 = SWIG_AsVal_long_SS_long(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfArray_SetValuesFromFloat64" "', argument " "4"" of type '" "XdmfInt64""'"); } arg4 = static_cast< XdmfInt64 >(val4); result = (XdmfInt32)(arg1)->SetValuesFromFloat64(arg2,arg3,arg4); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_SetValuesFromFloat64(PyObject *self, PyObject *args) { int argc; PyObject *argv[7]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 6); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 4) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_double, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfArray_SetValuesFromFloat64__SWIG_2(self, args); } } } } } if (argc == 5) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_double, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[4], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfArray_SetValuesFromFloat64__SWIG_1(self, args); } } } } } } if (argc == 6) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_double, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[4], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[5], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfArray_SetValuesFromFloat64__SWIG_0(self, args); } } } } } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfArray_SetValuesFromFloat64'.\n" " Possible C/C++ prototypes are:\n" " SetValuesFromFloat64(XdmfArray *,XdmfInt64,XdmfFloat64 *,XdmfInt64,XdmfInt64,XdmfInt64)\n" " SetValuesFromFloat64(XdmfArray *,XdmfInt64,XdmfFloat64 *,XdmfInt64,XdmfInt64)\n" " SetValuesFromFloat64(XdmfArray *,XdmfInt64,XdmfFloat64 *,XdmfInt64)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_GetValueAsFloat64(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfFloat64 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfArray_GetValueAsFloat64",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_GetValueAsFloat64" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_GetValueAsFloat64" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfFloat64)(arg1)->GetValueAsFloat64(arg2); resultobj = SWIG_From_double(static_cast< double >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_GetValueAsFloat32(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfFloat32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfArray_GetValueAsFloat32",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_GetValueAsFloat32" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_GetValueAsFloat32" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfFloat32)(arg1)->GetValueAsFloat32(arg2); resultobj = SWIG_From_float(static_cast< float >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_GetValueAsInt64(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt64 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfArray_GetValueAsInt64",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_GetValueAsInt64" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_GetValueAsInt64" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfInt64)(arg1)->GetValueAsInt64(arg2); resultobj = SWIG_From_long_SS_long(static_cast< long long >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_GetValueAsInt32(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfArray_GetValueAsInt32",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_GetValueAsInt32" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_GetValueAsInt32" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfInt32)(arg1)->GetValueAsInt32(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_GetValueAsInt16(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt16 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfArray_GetValueAsInt16",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_GetValueAsInt16" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_GetValueAsInt16" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfInt16)(arg1)->GetValueAsInt16(arg2); resultobj = SWIG_From_short(static_cast< short >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_GetValueAsInt8(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt8 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfArray_GetValueAsInt8",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_GetValueAsInt8" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_GetValueAsInt8" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfInt8)(arg1)->GetValueAsInt8(arg2); resultobj = SWIG_From_char(static_cast< char >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_GetValues__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; XdmfInt64 arg3 ; XdmfInt64 arg4 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; long long val3 ; int ecode3 = 0 ; long long val4 ; int ecode4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; XdmfString result; if (!PyArg_ParseTuple(args,(char *)"OOOO:XdmfArray_GetValues",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_GetValues" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_GetValues" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); ecode3 = SWIG_AsVal_long_SS_long(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "XdmfArray_GetValues" "', argument " "3"" of type '" "XdmfInt64""'"); } arg3 = static_cast< XdmfInt64 >(val3); ecode4 = SWIG_AsVal_long_SS_long(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfArray_GetValues" "', argument " "4"" of type '" "XdmfInt64""'"); } arg4 = static_cast< XdmfInt64 >(val4); result = (XdmfString)(arg1)->GetValues(arg2,arg3,arg4); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_GetValues__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; XdmfInt64 arg3 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; long long val3 ; int ecode3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfString result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfArray_GetValues",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_GetValues" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_GetValues" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); ecode3 = SWIG_AsVal_long_SS_long(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "XdmfArray_GetValues" "', argument " "3"" of type '" "XdmfInt64""'"); } arg3 = static_cast< XdmfInt64 >(val3); result = (XdmfString)(arg1)->GetValues(arg2,arg3); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_GetValues__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfString result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfArray_GetValues",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_GetValues" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_GetValues" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfString)(arg1)->GetValues(arg2); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_GetValues__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfArray_GetValues",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_GetValues" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); result = (XdmfString)(arg1)->GetValues(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_GetValues(PyObject *self, PyObject *args) { int argc; PyObject *argv[5]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 4); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfArray_GetValues__SWIG_3(self, args); } } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfArray_GetValues__SWIG_2(self, args); } } } if (argc == 3) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[2], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfArray_GetValues__SWIG_1(self, args); } } } } if (argc == 4) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[2], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfArray_GetValues__SWIG_0(self, args); } } } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfArray_GetValues'.\n" " Possible C/C++ prototypes are:\n" " GetValues(XdmfArray *,XdmfInt64,XdmfInt64,XdmfInt64)\n" " GetValues(XdmfArray *,XdmfInt64,XdmfInt64)\n" " GetValues(XdmfArray *,XdmfInt64)\n" " GetValues(XdmfArray *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_Generate__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfFloat64 arg2 ; XdmfFloat64 arg3 ; XdmfInt64 arg4 ; XdmfInt64 arg5 ; void *argp1 = 0 ; int res1 = 0 ; double val2 ; int ecode2 = 0 ; double val3 ; int ecode3 = 0 ; long long val4 ; int ecode4 = 0 ; long long val5 ; int ecode5 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOOO:XdmfArray_Generate",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_Generate" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_Generate" "', argument " "2"" of type '" "XdmfFloat64""'"); } arg2 = static_cast< XdmfFloat64 >(val2); ecode3 = SWIG_AsVal_double(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "XdmfArray_Generate" "', argument " "3"" of type '" "XdmfFloat64""'"); } arg3 = static_cast< XdmfFloat64 >(val3); ecode4 = SWIG_AsVal_long_SS_long(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfArray_Generate" "', argument " "4"" of type '" "XdmfInt64""'"); } arg4 = static_cast< XdmfInt64 >(val4); ecode5 = SWIG_AsVal_long_SS_long(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "XdmfArray_Generate" "', argument " "5"" of type '" "XdmfInt64""'"); } arg5 = static_cast< XdmfInt64 >(val5); result = (XdmfInt32)(arg1)->Generate(arg2,arg3,arg4,arg5); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_Generate__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfFloat64 arg2 ; XdmfFloat64 arg3 ; XdmfInt64 arg4 ; void *argp1 = 0 ; int res1 = 0 ; double val2 ; int ecode2 = 0 ; double val3 ; int ecode3 = 0 ; long long val4 ; int ecode4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOO:XdmfArray_Generate",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_Generate" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_Generate" "', argument " "2"" of type '" "XdmfFloat64""'"); } arg2 = static_cast< XdmfFloat64 >(val2); ecode3 = SWIG_AsVal_double(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "XdmfArray_Generate" "', argument " "3"" of type '" "XdmfFloat64""'"); } arg3 = static_cast< XdmfFloat64 >(val3); ecode4 = SWIG_AsVal_long_SS_long(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfArray_Generate" "', argument " "4"" of type '" "XdmfInt64""'"); } arg4 = static_cast< XdmfInt64 >(val4); result = (XdmfInt32)(arg1)->Generate(arg2,arg3,arg4); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_Generate__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfFloat64 arg2 ; XdmfFloat64 arg3 ; void *argp1 = 0 ; int res1 = 0 ; double val2 ; int ecode2 = 0 ; double val3 ; int ecode3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfArray_Generate",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_Generate" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_Generate" "', argument " "2"" of type '" "XdmfFloat64""'"); } arg2 = static_cast< XdmfFloat64 >(val2); ecode3 = SWIG_AsVal_double(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "XdmfArray_Generate" "', argument " "3"" of type '" "XdmfFloat64""'"); } arg3 = static_cast< XdmfFloat64 >(val3); result = (XdmfInt32)(arg1)->Generate(arg2,arg3); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_Generate(PyObject *self, PyObject *args) { int argc; PyObject *argv[6]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 5); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 3) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_double(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_double(argv[2], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfArray_Generate__SWIG_2(self, args); } } } } if (argc == 4) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_double(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_double(argv[2], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfArray_Generate__SWIG_1(self, args); } } } } } if (argc == 5) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_double(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_double(argv[2], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[4], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfArray_Generate__SWIG_0(self, args); } } } } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfArray_Generate'.\n" " Possible C/C++ prototypes are:\n" " Generate(XdmfArray *,XdmfFloat64,XdmfFloat64,XdmfInt64,XdmfInt64)\n" " Generate(XdmfArray *,XdmfFloat64,XdmfFloat64,XdmfInt64)\n" " Generate(XdmfArray *,XdmfFloat64,XdmfFloat64)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_Clone__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfLength arg2 ; XdmfLength arg3 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; long long val3 ; int ecode3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfArray_Clone",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_Clone" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_Clone" "', argument " "2"" of type '" "XdmfLength""'"); } arg2 = static_cast< XdmfLength >(val2); ecode3 = SWIG_AsVal_long_SS_long(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "XdmfArray_Clone" "', argument " "3"" of type '" "XdmfLength""'"); } arg3 = static_cast< XdmfLength >(val3); result = (XdmfArray *)(arg1)->Clone(arg2,arg3); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_Clone__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfLength arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfArray_Clone",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_Clone" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_Clone" "', argument " "2"" of type '" "XdmfLength""'"); } arg2 = static_cast< XdmfLength >(val2); result = (XdmfArray *)(arg1)->Clone(arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_Clone__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfArray_Clone",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_Clone" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); result = (XdmfArray *)(arg1)->Clone(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_Clone(PyObject *self, PyObject *args) { int argc; PyObject *argv[4]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 3); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfArray_Clone__SWIG_2(self, args); } } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfArray_Clone__SWIG_1(self, args); } } } if (argc == 3) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[2], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfArray_Clone__SWIG_0(self, args); } } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfArray_Clone'.\n" " Possible C/C++ prototypes are:\n" " Clone(XdmfArray *,XdmfLength,XdmfLength)\n" " Clone(XdmfArray *,XdmfLength)\n" " Clone(XdmfArray *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_Reference__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfLength arg2 ; XdmfLength arg3 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; long long val3 ; int ecode3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfArray_Reference",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_Reference" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_Reference" "', argument " "2"" of type '" "XdmfLength""'"); } arg2 = static_cast< XdmfLength >(val2); ecode3 = SWIG_AsVal_long_SS_long(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "XdmfArray_Reference" "', argument " "3"" of type '" "XdmfLength""'"); } arg3 = static_cast< XdmfLength >(val3); result = (XdmfArray *)(arg1)->Reference(arg2,arg3); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_Reference__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfLength arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfArray_Reference",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_Reference" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArray_Reference" "', argument " "2"" of type '" "XdmfLength""'"); } arg2 = static_cast< XdmfLength >(val2); result = (XdmfArray *)(arg1)->Reference(arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_Reference__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfArray_Reference",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_Reference" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); result = (XdmfArray *)(arg1)->Reference(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_Reference(PyObject *self, PyObject *args) { int argc; PyObject *argv[4]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 3); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfArray_Reference__SWIG_2(self, args); } } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfArray_Reference__SWIG_1(self, args); } } } if (argc == 3) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[2], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfArray_Reference__SWIG_0(self, args); } } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfArray_Reference'.\n" " Possible C/C++ prototypes are:\n" " Reference(XdmfArray *,XdmfLength,XdmfLength)\n" " Reference(XdmfArray *,XdmfLength)\n" " Reference(XdmfArray *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_GetMaxAsFloat64(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfFloat64 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfArray_GetMaxAsFloat64",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_GetMaxAsFloat64" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); result = (XdmfFloat64)(arg1)->GetMaxAsFloat64(); resultobj = SWIG_From_double(static_cast< double >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_GetMinAsFloat64(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfFloat64 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfArray_GetMinAsFloat64",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_GetMinAsFloat64" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); result = (XdmfFloat64)(arg1)->GetMinAsFloat64(); resultobj = SWIG_From_double(static_cast< double >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_GetMaxAsInt64(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt64 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfArray_GetMaxAsInt64",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_GetMaxAsInt64" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); result = (XdmfInt64)(arg1)->GetMaxAsInt64(); resultobj = SWIG_From_long_SS_long(static_cast< long long >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_GetMinAsInt64(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt64 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfArray_GetMinAsInt64",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_GetMinAsInt64" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); result = (XdmfInt64)(arg1)->GetMinAsInt64(); resultobj = SWIG_From_long_SS_long(static_cast< long long >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_GetMean(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfFloat64 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfArray_GetMean",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_GetMean" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); result = (XdmfFloat64)(arg1)->GetMean(); resultobj = SWIG_From_double(static_cast< double >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_SetDataFromChars(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfString arg2 = (XdmfString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfArray_SetDataFromChars",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_SetDataFromChars" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfArray_SetDataFromChars" "', argument " "2"" of type '" "XdmfString""'"); } arg2 = reinterpret_cast< XdmfString >(buf2); (arg1)->SetDataFromChars(arg2); resultobj = SWIG_Py_Void(); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfArray_GetDataPointerAsCharPointer(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfArray_GetDataPointerAsCharPointer",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArray_GetDataPointerAsCharPointer" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); result = (XdmfString)(arg1)->GetDataPointerAsCharPointer(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *XdmfArray_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; SWIG_TypeNewClientData(SWIGTYPE_p_XdmfArray, SWIG_NewClientData(obj)); return SWIG_Py_Void(); } SWIGINTERN PyObject *_wrap_XdmfArrayList_name_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArrayList *arg1 = (XdmfArrayList *) 0 ; char *arg2 = (char *) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfArrayList_name_set",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArrayList, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArrayList_name_set" "', argument " "1"" of type '" "XdmfArrayList *""'"); } arg1 = reinterpret_cast< XdmfArrayList * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfArrayList_name_set" "', argument " "2"" of type '" "char *""'"); } arg2 = reinterpret_cast< char * >(buf2); if (arg1->name) delete[] arg1->name; if (arg2) { size_t size = strlen(reinterpret_cast< const char * >(arg2)) + 1; arg1->name = (char *)reinterpret_cast< char* >(memcpy((new char[size]), reinterpret_cast< const char * >(arg2), sizeof(char)*(size))); } else { arg1->name = 0; } resultobj = SWIG_Py_Void(); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfArrayList_name_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArrayList *arg1 = (XdmfArrayList *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfArrayList_name_get",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArrayList, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArrayList_name_get" "', argument " "1"" of type '" "XdmfArrayList *""'"); } arg1 = reinterpret_cast< XdmfArrayList * >(argp1); result = (char *) ((arg1)->name); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArrayList_timecntr_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArrayList *arg1 = (XdmfArrayList *) 0 ; XdmfLength arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfArrayList_timecntr_set",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArrayList, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArrayList_timecntr_set" "', argument " "1"" of type '" "XdmfArrayList *""'"); } arg1 = reinterpret_cast< XdmfArrayList * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfArrayList_timecntr_set" "', argument " "2"" of type '" "XdmfLength""'"); } arg2 = static_cast< XdmfLength >(val2); if (arg1) (arg1)->timecntr = arg2; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArrayList_timecntr_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArrayList *arg1 = (XdmfArrayList *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfLength result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfArrayList_timecntr_get",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArrayList, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArrayList_timecntr_get" "', argument " "1"" of type '" "XdmfArrayList *""'"); } arg1 = reinterpret_cast< XdmfArrayList * >(argp1); result = (XdmfLength) ((arg1)->timecntr); resultobj = SWIG_From_long_SS_long(static_cast< long long >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArrayList_Array_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArrayList *arg1 = (XdmfArrayList *) 0 ; XdmfArray *arg2 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfArrayList_Array_set",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArrayList, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArrayList_Array_set" "', argument " "1"" of type '" "XdmfArrayList *""'"); } arg1 = reinterpret_cast< XdmfArrayList * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfArray, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfArrayList_Array_set" "', argument " "2"" of type '" "XdmfArray *""'"); } arg2 = reinterpret_cast< XdmfArray * >(argp2); if (arg1) (arg1)->Array = arg2; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfArrayList_Array_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArrayList *arg1 = (XdmfArrayList *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfArrayList_Array_get",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArrayList, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArrayList_Array_get" "', argument " "1"" of type '" "XdmfArrayList *""'"); } arg1 = reinterpret_cast< XdmfArrayList * >(argp1); result = (XdmfArray *) ((arg1)->Array); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_new_XdmfArrayList(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArrayList *result = 0 ; if (!PyArg_ParseTuple(args,(char *)":new_XdmfArrayList")) SWIG_fail; result = (XdmfArrayList *)new XdmfArrayList(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArrayList, SWIG_POINTER_NEW | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_delete_XdmfArrayList(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArrayList *arg1 = (XdmfArrayList *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:delete_XdmfArrayList",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArrayList, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_XdmfArrayList" "', argument " "1"" of type '" "XdmfArrayList *""'"); } arg1 = reinterpret_cast< XdmfArrayList * >(argp1); delete arg1; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *XdmfArrayList_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; SWIG_TypeNewClientData(SWIGTYPE_p_XdmfArrayList, SWIG_NewClientData(obj)); return SWIG_Py_Void(); } SWIGINTERN PyObject *_wrap_TagNameToArray(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfString arg1 = (XdmfString) 0 ; int res1 ; char *buf1 = 0 ; int alloc1 = 0 ; PyObject * obj0 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:TagNameToArray",&obj0)) SWIG_fail; res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TagNameToArray" "', argument " "1"" of type '" "XdmfString""'"); } arg1 = reinterpret_cast< XdmfString >(buf1); result = (XdmfArray *)TagNameToArray(arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); if (alloc1 == SWIG_NEWOBJ) delete[] buf1; return resultobj; fail: if (alloc1 == SWIG_NEWOBJ) delete[] buf1; return NULL; } SWIGINTERN PyObject *_wrap_PrintAllXdmfArrays(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; if (!PyArg_ParseTuple(args,(char *)":PrintAllXdmfArrays")) SWIG_fail; PrintAllXdmfArrays(); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_GetNextOlderArray__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfLength arg1 ; XdmfLength *arg2 = (XdmfLength *) 0 ; long long val1 ; int ecode1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:GetNextOlderArray",&obj0,&obj1)) SWIG_fail; ecode1 = SWIG_AsVal_long_SS_long(obj0, &val1); if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "GetNextOlderArray" "', argument " "1"" of type '" "XdmfLength""'"); } arg1 = static_cast< XdmfLength >(val1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_long_long, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "GetNextOlderArray" "', argument " "2"" of type '" "XdmfLength *""'"); } arg2 = reinterpret_cast< XdmfLength * >(argp2); result = (XdmfArray *)GetNextOlderArray(arg1,arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_GetNextOlderArray__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfLength arg1 ; long long val1 ; int ecode1 = 0 ; PyObject * obj0 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:GetNextOlderArray",&obj0)) SWIG_fail; ecode1 = SWIG_AsVal_long_SS_long(obj0, &val1); if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "GetNextOlderArray" "', argument " "1"" of type '" "XdmfLength""'"); } arg1 = static_cast< XdmfLength >(val1); result = (XdmfArray *)GetNextOlderArray(arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_GetNextOlderArray(PyObject *self, PyObject *args) { int argc; PyObject *argv[3]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 2); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 1) { int _v; { int res = SWIG_AsVal_long_SS_long(argv[0], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_GetNextOlderArray__SWIG_1(self, args); } } if (argc == 2) { int _v; { int res = SWIG_AsVal_long_SS_long(argv[0], NULL); _v = SWIG_CheckState(res); } if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_long_long, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_GetNextOlderArray__SWIG_0(self, args); } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'GetNextOlderArray'.\n" " Possible C/C++ prototypes are:\n" " GetNextOlderArray(XdmfLength,XdmfLength *)\n" " GetNextOlderArray(XdmfLength)\n"); return NULL; } SWIGINTERN PyObject *_wrap_GetCurrentArrayTime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfLength result; if (!PyArg_ParseTuple(args,(char *)":GetCurrentArrayTime")) SWIG_fail; result = (XdmfLength)GetCurrentArrayTime(); resultobj = SWIG_From_long_SS_long(static_cast< long long >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_new_XdmfDOM(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *result = 0 ; if (!PyArg_ParseTuple(args,(char *)":new_XdmfDOM")) SWIG_fail; result = (XdmfDOM *)new XdmfDOM(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfDOM, SWIG_POINTER_NEW | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_delete_XdmfDOM(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:delete_XdmfDOM",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_XdmfDOM" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); delete arg1; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_GetClassName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDOM_GetClassName",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_GetClassName" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); result = (XdmfConstString)(arg1)->GetClassName(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_SetInputFileName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDOM_SetInputFileName",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_SetInputFileName" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDOM_SetInputFileName" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfInt32)(arg1)->SetInputFileName(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_SetOutputFileName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDOM_SetOutputFileName",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_SetOutputFileName" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDOM_SetOutputFileName" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfInt32)(arg1)->SetOutputFileName(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_GetInputFileName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDOM_GetInputFileName",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_GetInputFileName" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); result = (XdmfConstString)(arg1)->GetInputFileName(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_GetOutputFileName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDOM_GetOutputFileName",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_GetOutputFileName" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); result = (XdmfConstString)(arg1)->GetOutputFileName(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_SetParserOptions(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDOM_SetParserOptions",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_SetParserOptions" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDOM_SetParserOptions" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetParserOptions(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_GetOutput(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; ostream *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDOM_GetOutput",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_GetOutput" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); result = (ostream *)(arg1)->GetOutput(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ostream, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_SetOutput(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; ostream *arg2 = (ostream *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDOM_SetOutput",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_SetOutput" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_ostream, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDOM_SetOutput" "', argument " "2"" of type '" "ostream *""'"); } arg2 = reinterpret_cast< ostream * >(argp2); result = (XdmfInt32)(arg1)->SetOutput(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_GetInput(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; istream *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDOM_GetInput",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_GetInput" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); result = (istream *)(arg1)->GetInput(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_istream, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_SetInput(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; istream *arg2 = (istream *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDOM_SetInput",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_SetInput" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_istream, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDOM_SetInput" "', argument " "2"" of type '" "istream *""'"); } arg2 = reinterpret_cast< istream * >(argp2); result = (XdmfInt32)(arg1)->SetInput(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_GenerateHead(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDOM_GenerateHead",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_GenerateHead" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); result = (XdmfInt32)(arg1)->GenerateHead(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_GetDTD(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDOM_GetDTD",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_GetDTD" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); result = (XdmfInt32)(arg1)->GetDTD(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_SetDTD(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDOM_SetDTD",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_SetDTD" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDOM_SetDTD" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetDTD(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_Puts(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDOM_Puts",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_Puts" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDOM_Puts" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfInt32)(arg1)->Puts(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_GenerateTail(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDOM_GenerateTail",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_GenerateTail" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); result = (XdmfInt32)(arg1)->GenerateTail(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_GetTree(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfXmlNode result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDOM_GetTree",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_GetTree" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); result = (XdmfXmlNode)(arg1)->GetTree(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__xmlNode, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM___Parse__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; XdmfXmlDoc *arg3 = (XdmfXmlDoc *) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfXmlNode result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfDOM___Parse",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM___Parse" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDOM___Parse" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_p__xmlDoc, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfDOM___Parse" "', argument " "3"" of type '" "XdmfXmlDoc *""'"); } arg3 = reinterpret_cast< XdmfXmlDoc * >(argp3); result = (XdmfXmlNode)(arg1)->__Parse(arg2,arg3); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__xmlNode, 0 | 0 ); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM___Parse__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfXmlNode result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDOM___Parse",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM___Parse" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDOM___Parse" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfXmlNode)(arg1)->__Parse(arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__xmlNode, 0 | 0 ); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM___Parse(PyObject *self, PyObject *args) { int argc; PyObject *argv[4]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 3); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDOM, 0); _v = SWIG_CheckState(res); if (_v) { int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfDOM___Parse__SWIG_1(self, args); } } } if (argc == 3) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDOM, 0); _v = SWIG_CheckState(res); if (_v) { int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_p__xmlDoc, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfDOM___Parse__SWIG_0(self, args); } } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfDOM___Parse'.\n" " Possible C/C++ prototypes are:\n" " __Parse(XdmfDOM *,XdmfConstString,XdmfXmlDoc *)\n" " __Parse(XdmfDOM *,XdmfConstString)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_Parse__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDOM_Parse",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_Parse" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDOM_Parse" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfInt32)(arg1)->Parse(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_Parse__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDOM_Parse",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_Parse" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); result = (XdmfInt32)(arg1)->Parse(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_Parse(PyObject *self, PyObject *args) { int argc; PyObject *argv[3]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 2); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDOM, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfDOM_Parse__SWIG_1(self, args); } } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDOM, 0); _v = SWIG_CheckState(res); if (_v) { int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfDOM_Parse__SWIG_0(self, args); } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfDOM_Parse'.\n" " Possible C/C++ prototypes are:\n" " Parse(XdmfDOM *,XdmfConstString)\n" " Parse(XdmfDOM *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_GetRoot(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfXmlNode result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDOM_GetRoot",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_GetRoot" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); result = (XdmfXmlNode)(arg1)->GetRoot(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__xmlNode, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_GetNumberOfChildren__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfXmlNode arg2 = (XdmfXmlNode) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt64 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDOM_GetNumberOfChildren",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_GetNumberOfChildren" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p__xmlNode, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDOM_GetNumberOfChildren" "', argument " "2"" of type '" "XdmfXmlNode""'"); } arg2 = reinterpret_cast< XdmfXmlNode >(argp2); result = (XdmfInt64)(arg1)->GetNumberOfChildren(arg2); resultobj = SWIG_From_long_SS_long(static_cast< long long >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_GetNumberOfChildren__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt64 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDOM_GetNumberOfChildren",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_GetNumberOfChildren" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); result = (XdmfInt64)(arg1)->GetNumberOfChildren(); resultobj = SWIG_From_long_SS_long(static_cast< long long >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_GetNumberOfChildren(PyObject *self, PyObject *args) { int argc; PyObject *argv[3]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 2); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDOM, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfDOM_GetNumberOfChildren__SWIG_1(self, args); } } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDOM, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p__xmlNode, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfDOM_GetNumberOfChildren__SWIG_0(self, args); } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfDOM_GetNumberOfChildren'.\n" " Possible C/C++ prototypes are:\n" " GetNumberOfChildren(XdmfDOM *,XdmfXmlNode)\n" " GetNumberOfChildren(XdmfDOM *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_GetChild(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfInt64 arg2 ; XdmfXmlNode arg3 = (XdmfXmlNode) 0 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfXmlNode result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfDOM_GetChild",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_GetChild" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDOM_GetChild" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p__xmlNode, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfDOM_GetChild" "', argument " "3"" of type '" "XdmfXmlNode""'"); } arg3 = reinterpret_cast< XdmfXmlNode >(argp3); result = (XdmfXmlNode)(arg1)->GetChild(arg2,arg3); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__xmlNode, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_GetNumberOfAttributes(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfXmlNode arg2 = (XdmfXmlNode) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDOM_GetNumberOfAttributes",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_GetNumberOfAttributes" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p__xmlNode, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDOM_GetNumberOfAttributes" "', argument " "2"" of type '" "XdmfXmlNode""'"); } arg2 = reinterpret_cast< XdmfXmlNode >(argp2); result = (XdmfInt32)(arg1)->GetNumberOfAttributes(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_GetAttributeName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfXmlNode arg2 = (XdmfXmlNode) 0 ; XdmfInt32 arg3 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; int val3 ; int ecode3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfDOM_GetAttributeName",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_GetAttributeName" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p__xmlNode, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDOM_GetAttributeName" "', argument " "2"" of type '" "XdmfXmlNode""'"); } arg2 = reinterpret_cast< XdmfXmlNode >(argp2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "XdmfDOM_GetAttributeName" "', argument " "3"" of type '" "XdmfInt32""'"); } arg3 = static_cast< XdmfInt32 >(val3); result = (XdmfConstString)(arg1)->GetAttributeName(arg2,arg3); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_IsChild__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfXmlNode arg2 = (XdmfXmlNode) 0 ; XdmfXmlNode arg3 = (XdmfXmlNode) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfDOM_IsChild",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_IsChild" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p__xmlNode, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDOM_IsChild" "', argument " "2"" of type '" "XdmfXmlNode""'"); } arg2 = reinterpret_cast< XdmfXmlNode >(argp2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p__xmlNode, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfDOM_IsChild" "', argument " "3"" of type '" "XdmfXmlNode""'"); } arg3 = reinterpret_cast< XdmfXmlNode >(argp3); result = (XdmfInt32)(arg1)->IsChild(arg2,arg3); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_IsChild__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfXmlNode arg2 = (XdmfXmlNode) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDOM_IsChild",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_IsChild" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p__xmlNode, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDOM_IsChild" "', argument " "2"" of type '" "XdmfXmlNode""'"); } arg2 = reinterpret_cast< XdmfXmlNode >(argp2); result = (XdmfInt32)(arg1)->IsChild(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_IsChild(PyObject *self, PyObject *args) { int argc; PyObject *argv[4]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 3); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDOM, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p__xmlNode, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfDOM_IsChild__SWIG_1(self, args); } } } if (argc == 3) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDOM, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p__xmlNode, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p__xmlNode, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfDOM_IsChild__SWIG_0(self, args); } } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfDOM_IsChild'.\n" " Possible C/C++ prototypes are:\n" " IsChild(XdmfDOM *,XdmfXmlNode,XdmfXmlNode)\n" " IsChild(XdmfDOM *,XdmfXmlNode)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_Serialize__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfXmlNode arg2 = (XdmfXmlNode) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDOM_Serialize",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_Serialize" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p__xmlNode, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDOM_Serialize" "', argument " "2"" of type '" "XdmfXmlNode""'"); } arg2 = reinterpret_cast< XdmfXmlNode >(argp2); result = (XdmfConstString)(arg1)->Serialize(arg2); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_Serialize__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDOM_Serialize",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_Serialize" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); result = (XdmfConstString)(arg1)->Serialize(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_Serialize(PyObject *self, PyObject *args) { int argc; PyObject *argv[3]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 2); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDOM, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfDOM_Serialize__SWIG_1(self, args); } } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDOM, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p__xmlNode, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfDOM_Serialize__SWIG_0(self, args); } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfDOM_Serialize'.\n" " Possible C/C++ prototypes are:\n" " Serialize(XdmfDOM *,XdmfXmlNode)\n" " Serialize(XdmfDOM *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_Write__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDOM_Write",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_Write" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDOM_Write" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfInt32)(arg1)->Write(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_Write__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDOM_Write",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_Write" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); result = (XdmfInt32)(arg1)->Write(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_Write(PyObject *self, PyObject *args) { int argc; PyObject *argv[3]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 2); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDOM, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfDOM_Write__SWIG_1(self, args); } } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDOM, 0); _v = SWIG_CheckState(res); if (_v) { int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfDOM_Write__SWIG_0(self, args); } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfDOM_Write'.\n" " Possible C/C++ prototypes are:\n" " Write(XdmfDOM *,XdmfConstString)\n" " Write(XdmfDOM *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_Insert(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfXmlNode arg2 = (XdmfXmlNode) 0 ; XdmfXmlNode arg3 = (XdmfXmlNode) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfXmlNode result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfDOM_Insert",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_Insert" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p__xmlNode, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDOM_Insert" "', argument " "2"" of type '" "XdmfXmlNode""'"); } arg2 = reinterpret_cast< XdmfXmlNode >(argp2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p__xmlNode, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfDOM_Insert" "', argument " "3"" of type '" "XdmfXmlNode""'"); } arg3 = reinterpret_cast< XdmfXmlNode >(argp3); result = (XdmfXmlNode)(arg1)->Insert(arg2,arg3); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__xmlNode, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_InsertFromString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfXmlNode arg2 = (XdmfXmlNode) 0 ; XdmfConstString arg3 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfXmlNode result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfDOM_InsertFromString",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_InsertFromString" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p__xmlNode, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDOM_InsertFromString" "', argument " "2"" of type '" "XdmfXmlNode""'"); } arg2 = reinterpret_cast< XdmfXmlNode >(argp2); res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfDOM_InsertFromString" "', argument " "3"" of type '" "XdmfConstString""'"); } arg3 = reinterpret_cast< XdmfConstString >(buf3); result = (XdmfXmlNode)(arg1)->InsertFromString(arg2,arg3); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__xmlNode, 0 | 0 ); if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return resultobj; fail: if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_Create__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; XdmfConstString arg3 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfXmlNode result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfDOM_Create",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_Create" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDOM_Create" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfDOM_Create" "', argument " "3"" of type '" "XdmfConstString""'"); } arg3 = reinterpret_cast< XdmfConstString >(buf3); result = (XdmfXmlNode)(arg1)->Create(arg2,arg3); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__xmlNode, 0 | 0 ); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_Create__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfXmlNode result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDOM_Create",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_Create" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDOM_Create" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfXmlNode)(arg1)->Create(arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__xmlNode, 0 | 0 ); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_Create__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfXmlNode result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDOM_Create",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_Create" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); result = (XdmfXmlNode)(arg1)->Create(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__xmlNode, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_Create(PyObject *self, PyObject *args) { int argc; PyObject *argv[4]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 3); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDOM, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfDOM_Create__SWIG_2(self, args); } } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDOM, 0); _v = SWIG_CheckState(res); if (_v) { int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfDOM_Create__SWIG_1(self, args); } } } if (argc == 3) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDOM, 0); _v = SWIG_CheckState(res); if (_v) { int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfDOM_Create__SWIG_0(self, args); } } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfDOM_Create'.\n" " Possible C/C++ prototypes are:\n" " Create(XdmfDOM *,XdmfConstString,XdmfConstString)\n" " Create(XdmfDOM *,XdmfConstString)\n" " Create(XdmfDOM *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_InsertNew(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfXmlNode arg2 = (XdmfXmlNode) 0 ; XdmfConstString arg3 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfXmlNode result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfDOM_InsertNew",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_InsertNew" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p__xmlNode, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDOM_InsertNew" "', argument " "2"" of type '" "XdmfXmlNode""'"); } arg2 = reinterpret_cast< XdmfXmlNode >(argp2); res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfDOM_InsertNew" "', argument " "3"" of type '" "XdmfConstString""'"); } arg3 = reinterpret_cast< XdmfConstString >(buf3); result = (XdmfXmlNode)(arg1)->InsertNew(arg2,arg3); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__xmlNode, 0 | 0 ); if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return resultobj; fail: if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_DeleteNode(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfXmlNode arg2 = (XdmfXmlNode) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDOM_DeleteNode",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_DeleteNode" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p__xmlNode, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDOM_DeleteNode" "', argument " "2"" of type '" "XdmfXmlNode""'"); } arg2 = reinterpret_cast< XdmfXmlNode >(argp2); result = (XdmfInt32)(arg1)->DeleteNode(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_FindElement__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; XdmfInt32 arg3 ; XdmfXmlNode arg4 = (XdmfXmlNode) 0 ; XdmfInt32 arg5 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; int val3 ; int ecode3 = 0 ; void *argp4 = 0 ; int res4 = 0 ; int val5 ; int ecode5 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; XdmfXmlNode result; if (!PyArg_ParseTuple(args,(char *)"OOOOO:XdmfDOM_FindElement",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_FindElement" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDOM_FindElement" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "XdmfDOM_FindElement" "', argument " "3"" of type '" "XdmfInt32""'"); } arg3 = static_cast< XdmfInt32 >(val3); res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p__xmlNode, 0 | 0 ); if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "XdmfDOM_FindElement" "', argument " "4"" of type '" "XdmfXmlNode""'"); } arg4 = reinterpret_cast< XdmfXmlNode >(argp4); ecode5 = SWIG_AsVal_int(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "XdmfDOM_FindElement" "', argument " "5"" of type '" "XdmfInt32""'"); } arg5 = static_cast< XdmfInt32 >(val5); result = (XdmfXmlNode)(arg1)->FindElement(arg2,arg3,arg4,arg5); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__xmlNode, 0 | 0 ); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_FindElement__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; XdmfInt32 arg3 ; XdmfXmlNode arg4 = (XdmfXmlNode) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; int val3 ; int ecode3 = 0 ; void *argp4 = 0 ; int res4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; XdmfXmlNode result; if (!PyArg_ParseTuple(args,(char *)"OOOO:XdmfDOM_FindElement",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_FindElement" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDOM_FindElement" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "XdmfDOM_FindElement" "', argument " "3"" of type '" "XdmfInt32""'"); } arg3 = static_cast< XdmfInt32 >(val3); res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p__xmlNode, 0 | 0 ); if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "XdmfDOM_FindElement" "', argument " "4"" of type '" "XdmfXmlNode""'"); } arg4 = reinterpret_cast< XdmfXmlNode >(argp4); result = (XdmfXmlNode)(arg1)->FindElement(arg2,arg3,arg4); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__xmlNode, 0 | 0 ); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_FindElement__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; XdmfInt32 arg3 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; int val3 ; int ecode3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfXmlNode result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfDOM_FindElement",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_FindElement" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDOM_FindElement" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "XdmfDOM_FindElement" "', argument " "3"" of type '" "XdmfInt32""'"); } arg3 = static_cast< XdmfInt32 >(val3); result = (XdmfXmlNode)(arg1)->FindElement(arg2,arg3); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__xmlNode, 0 | 0 ); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_FindElement__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfXmlNode result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDOM_FindElement",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_FindElement" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDOM_FindElement" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfXmlNode)(arg1)->FindElement(arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__xmlNode, 0 | 0 ); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_FindElement(PyObject *self, PyObject *args) { int argc; PyObject *argv[6]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 5); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDOM, 0); _v = SWIG_CheckState(res); if (_v) { int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfDOM_FindElement__SWIG_3(self, args); } } } if (argc == 3) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDOM, 0); _v = SWIG_CheckState(res); if (_v) { int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_int(argv[2], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfDOM_FindElement__SWIG_2(self, args); } } } } if (argc == 4) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDOM, 0); _v = SWIG_CheckState(res); if (_v) { int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_int(argv[2], NULL); _v = SWIG_CheckState(res); } if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[3], &vptr, SWIGTYPE_p__xmlNode, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfDOM_FindElement__SWIG_1(self, args); } } } } } if (argc == 5) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDOM, 0); _v = SWIG_CheckState(res); if (_v) { int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_int(argv[2], NULL); _v = SWIG_CheckState(res); } if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[3], &vptr, SWIGTYPE_p__xmlNode, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_int(argv[4], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfDOM_FindElement__SWIG_0(self, args); } } } } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfDOM_FindElement'.\n" " Possible C/C++ prototypes are:\n" " FindElement(XdmfDOM *,XdmfConstString,XdmfInt32,XdmfXmlNode,XdmfInt32)\n" " FindElement(XdmfDOM *,XdmfConstString,XdmfInt32,XdmfXmlNode)\n" " FindElement(XdmfDOM *,XdmfConstString,XdmfInt32)\n" " FindElement(XdmfDOM *,XdmfConstString)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_FindNextElement__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; XdmfXmlNode arg3 = (XdmfXmlNode) 0 ; XdmfInt32 arg4 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; int val4 ; int ecode4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; XdmfXmlNode result; if (!PyArg_ParseTuple(args,(char *)"OOOO:XdmfDOM_FindNextElement",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_FindNextElement" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDOM_FindNextElement" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p__xmlNode, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfDOM_FindNextElement" "', argument " "3"" of type '" "XdmfXmlNode""'"); } arg3 = reinterpret_cast< XdmfXmlNode >(argp3); ecode4 = SWIG_AsVal_int(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfDOM_FindNextElement" "', argument " "4"" of type '" "XdmfInt32""'"); } arg4 = static_cast< XdmfInt32 >(val4); result = (XdmfXmlNode)(arg1)->FindNextElement(arg2,arg3,arg4); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__xmlNode, 0 | 0 ); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_FindNextElement__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; XdmfXmlNode arg3 = (XdmfXmlNode) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfXmlNode result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfDOM_FindNextElement",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_FindNextElement" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDOM_FindNextElement" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p__xmlNode, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfDOM_FindNextElement" "', argument " "3"" of type '" "XdmfXmlNode""'"); } arg3 = reinterpret_cast< XdmfXmlNode >(argp3); result = (XdmfXmlNode)(arg1)->FindNextElement(arg2,arg3); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__xmlNode, 0 | 0 ); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_FindNextElement(PyObject *self, PyObject *args) { int argc; PyObject *argv[5]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 4); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 3) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDOM, 0); _v = SWIG_CheckState(res); if (_v) { int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p__xmlNode, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfDOM_FindNextElement__SWIG_1(self, args); } } } } if (argc == 4) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDOM, 0); _v = SWIG_CheckState(res); if (_v) { int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p__xmlNode, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_int(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfDOM_FindNextElement__SWIG_0(self, args); } } } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfDOM_FindNextElement'.\n" " Possible C/C++ prototypes are:\n" " FindNextElement(XdmfDOM *,XdmfConstString,XdmfXmlNode,XdmfInt32)\n" " FindNextElement(XdmfDOM *,XdmfConstString,XdmfXmlNode)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_FindDataElement__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfInt32 arg2 ; XdmfXmlNode arg3 = (XdmfXmlNode) 0 ; XdmfInt32 arg4 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; int val4 ; int ecode4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; XdmfXmlNode result; if (!PyArg_ParseTuple(args,(char *)"OOOO:XdmfDOM_FindDataElement",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_FindDataElement" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDOM_FindDataElement" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p__xmlNode, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfDOM_FindDataElement" "', argument " "3"" of type '" "XdmfXmlNode""'"); } arg3 = reinterpret_cast< XdmfXmlNode >(argp3); ecode4 = SWIG_AsVal_int(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfDOM_FindDataElement" "', argument " "4"" of type '" "XdmfInt32""'"); } arg4 = static_cast< XdmfInt32 >(val4); result = (XdmfXmlNode)(arg1)->FindDataElement(arg2,arg3,arg4); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__xmlNode, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_FindDataElement__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfInt32 arg2 ; XdmfXmlNode arg3 = (XdmfXmlNode) 0 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfXmlNode result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfDOM_FindDataElement",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_FindDataElement" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDOM_FindDataElement" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p__xmlNode, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfDOM_FindDataElement" "', argument " "3"" of type '" "XdmfXmlNode""'"); } arg3 = reinterpret_cast< XdmfXmlNode >(argp3); result = (XdmfXmlNode)(arg1)->FindDataElement(arg2,arg3); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__xmlNode, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_FindDataElement__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfXmlNode result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDOM_FindDataElement",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_FindDataElement" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDOM_FindDataElement" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfXmlNode)(arg1)->FindDataElement(arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__xmlNode, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_FindDataElement__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfXmlNode result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDOM_FindDataElement",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_FindDataElement" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); result = (XdmfXmlNode)(arg1)->FindDataElement(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__xmlNode, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_FindDataElement(PyObject *self, PyObject *args) { int argc; PyObject *argv[5]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 4); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDOM, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfDOM_FindDataElement__SWIG_3(self, args); } } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDOM, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_int(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfDOM_FindDataElement__SWIG_2(self, args); } } } if (argc == 3) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDOM, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_int(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p__xmlNode, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfDOM_FindDataElement__SWIG_1(self, args); } } } } if (argc == 4) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDOM, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_int(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p__xmlNode, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_int(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfDOM_FindDataElement__SWIG_0(self, args); } } } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfDOM_FindDataElement'.\n" " Possible C/C++ prototypes are:\n" " FindDataElement(XdmfDOM *,XdmfInt32,XdmfXmlNode,XdmfInt32)\n" " FindDataElement(XdmfDOM *,XdmfInt32,XdmfXmlNode)\n" " FindDataElement(XdmfDOM *,XdmfInt32)\n" " FindDataElement(XdmfDOM *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_FindElementByAttribute__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; XdmfConstString arg3 = (XdmfConstString) 0 ; XdmfInt32 arg4 ; XdmfXmlNode arg5 = (XdmfXmlNode) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; int val4 ; int ecode4 = 0 ; void *argp5 = 0 ; int res5 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; XdmfXmlNode result; if (!PyArg_ParseTuple(args,(char *)"OOOOO:XdmfDOM_FindElementByAttribute",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_FindElementByAttribute" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDOM_FindElementByAttribute" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfDOM_FindElementByAttribute" "', argument " "3"" of type '" "XdmfConstString""'"); } arg3 = reinterpret_cast< XdmfConstString >(buf3); ecode4 = SWIG_AsVal_int(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfDOM_FindElementByAttribute" "', argument " "4"" of type '" "XdmfInt32""'"); } arg4 = static_cast< XdmfInt32 >(val4); res5 = SWIG_ConvertPtr(obj4, &argp5,SWIGTYPE_p__xmlNode, 0 | 0 ); if (!SWIG_IsOK(res5)) { SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "XdmfDOM_FindElementByAttribute" "', argument " "5"" of type '" "XdmfXmlNode""'"); } arg5 = reinterpret_cast< XdmfXmlNode >(argp5); result = (XdmfXmlNode)(arg1)->FindElementByAttribute(arg2,arg3,arg4,arg5); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__xmlNode, 0 | 0 ); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_FindElementByAttribute__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; XdmfConstString arg3 = (XdmfConstString) 0 ; XdmfInt32 arg4 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; int val4 ; int ecode4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; XdmfXmlNode result; if (!PyArg_ParseTuple(args,(char *)"OOOO:XdmfDOM_FindElementByAttribute",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_FindElementByAttribute" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDOM_FindElementByAttribute" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfDOM_FindElementByAttribute" "', argument " "3"" of type '" "XdmfConstString""'"); } arg3 = reinterpret_cast< XdmfConstString >(buf3); ecode4 = SWIG_AsVal_int(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfDOM_FindElementByAttribute" "', argument " "4"" of type '" "XdmfInt32""'"); } arg4 = static_cast< XdmfInt32 >(val4); result = (XdmfXmlNode)(arg1)->FindElementByAttribute(arg2,arg3,arg4); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__xmlNode, 0 | 0 ); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_FindElementByAttribute__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; XdmfConstString arg3 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfXmlNode result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfDOM_FindElementByAttribute",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_FindElementByAttribute" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDOM_FindElementByAttribute" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfDOM_FindElementByAttribute" "', argument " "3"" of type '" "XdmfConstString""'"); } arg3 = reinterpret_cast< XdmfConstString >(buf3); result = (XdmfXmlNode)(arg1)->FindElementByAttribute(arg2,arg3); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__xmlNode, 0 | 0 ); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_FindElementByAttribute(PyObject *self, PyObject *args) { int argc; PyObject *argv[6]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 5); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 3) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDOM, 0); _v = SWIG_CheckState(res); if (_v) { int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfDOM_FindElementByAttribute__SWIG_2(self, args); } } } } if (argc == 4) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDOM, 0); _v = SWIG_CheckState(res); if (_v) { int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_int(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfDOM_FindElementByAttribute__SWIG_1(self, args); } } } } } if (argc == 5) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDOM, 0); _v = SWIG_CheckState(res); if (_v) { int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_int(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[4], &vptr, SWIGTYPE_p__xmlNode, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfDOM_FindElementByAttribute__SWIG_0(self, args); } } } } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfDOM_FindElementByAttribute'.\n" " Possible C/C++ prototypes are:\n" " FindElementByAttribute(XdmfDOM *,XdmfConstString,XdmfConstString,XdmfInt32,XdmfXmlNode)\n" " FindElementByAttribute(XdmfDOM *,XdmfConstString,XdmfConstString,XdmfInt32)\n" " FindElementByAttribute(XdmfDOM *,XdmfConstString,XdmfConstString)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_FindElementByPath(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfXmlNode result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDOM_FindElementByPath",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_FindElementByPath" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDOM_FindElementByPath" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfXmlNode)(arg1)->FindElementByPath(arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__xmlNode, 0 | 0 ); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_FindNumberOfElements__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; XdmfXmlNode arg3 = (XdmfXmlNode) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfDOM_FindNumberOfElements",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_FindNumberOfElements" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDOM_FindNumberOfElements" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p__xmlNode, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfDOM_FindNumberOfElements" "', argument " "3"" of type '" "XdmfXmlNode""'"); } arg3 = reinterpret_cast< XdmfXmlNode >(argp3); result = (XdmfInt32)(arg1)->FindNumberOfElements(arg2,arg3); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_FindNumberOfElements__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDOM_FindNumberOfElements",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_FindNumberOfElements" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDOM_FindNumberOfElements" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfInt32)(arg1)->FindNumberOfElements(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_FindNumberOfElements(PyObject *self, PyObject *args) { int argc; PyObject *argv[4]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 3); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDOM, 0); _v = SWIG_CheckState(res); if (_v) { int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfDOM_FindNumberOfElements__SWIG_1(self, args); } } } if (argc == 3) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDOM, 0); _v = SWIG_CheckState(res); if (_v) { int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p__xmlNode, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfDOM_FindNumberOfElements__SWIG_0(self, args); } } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfDOM_FindNumberOfElements'.\n" " Possible C/C++ prototypes are:\n" " FindNumberOfElements(XdmfDOM *,XdmfConstString,XdmfXmlNode)\n" " FindNumberOfElements(XdmfDOM *,XdmfConstString)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_FindNumberOfElementsByAttribute__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; XdmfConstString arg3 = (XdmfConstString) 0 ; XdmfXmlNode arg4 = (XdmfXmlNode) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; void *argp4 = 0 ; int res4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOO:XdmfDOM_FindNumberOfElementsByAttribute",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_FindNumberOfElementsByAttribute" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDOM_FindNumberOfElementsByAttribute" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfDOM_FindNumberOfElementsByAttribute" "', argument " "3"" of type '" "XdmfConstString""'"); } arg3 = reinterpret_cast< XdmfConstString >(buf3); res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p__xmlNode, 0 | 0 ); if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "XdmfDOM_FindNumberOfElementsByAttribute" "', argument " "4"" of type '" "XdmfXmlNode""'"); } arg4 = reinterpret_cast< XdmfXmlNode >(argp4); result = (XdmfInt32)(arg1)->FindNumberOfElementsByAttribute(arg2,arg3,arg4); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_FindNumberOfElementsByAttribute__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; XdmfConstString arg3 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfDOM_FindNumberOfElementsByAttribute",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_FindNumberOfElementsByAttribute" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDOM_FindNumberOfElementsByAttribute" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfDOM_FindNumberOfElementsByAttribute" "', argument " "3"" of type '" "XdmfConstString""'"); } arg3 = reinterpret_cast< XdmfConstString >(buf3); result = (XdmfInt32)(arg1)->FindNumberOfElementsByAttribute(arg2,arg3); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_FindNumberOfElementsByAttribute(PyObject *self, PyObject *args) { int argc; PyObject *argv[5]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 4); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 3) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDOM, 0); _v = SWIG_CheckState(res); if (_v) { int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfDOM_FindNumberOfElementsByAttribute__SWIG_1(self, args); } } } } if (argc == 4) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDOM, 0); _v = SWIG_CheckState(res); if (_v) { int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[3], &vptr, SWIGTYPE_p__xmlNode, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfDOM_FindNumberOfElementsByAttribute__SWIG_0(self, args); } } } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfDOM_FindNumberOfElementsByAttribute'.\n" " Possible C/C++ prototypes are:\n" " FindNumberOfElementsByAttribute(XdmfDOM *,XdmfConstString,XdmfConstString,XdmfXmlNode)\n" " FindNumberOfElementsByAttribute(XdmfDOM *,XdmfConstString,XdmfConstString)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_GetPath(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfXmlNode arg2 = (XdmfXmlNode) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDOM_GetPath",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_GetPath" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p__xmlNode, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDOM_GetPath" "', argument " "2"" of type '" "XdmfXmlNode""'"); } arg2 = reinterpret_cast< XdmfXmlNode >(argp2); result = (XdmfConstString)(arg1)->GetPath(arg2); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_GetNdgmHost(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDOM_GetNdgmHost",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_GetNdgmHost" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); result = (XdmfConstString)(arg1)->GetNdgmHost(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_SetNdgmHost(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDOM_SetNdgmHost",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_SetNdgmHost" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDOM_SetNdgmHost" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfInt32)(arg1)->SetNdgmHost(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_Get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfXmlNode arg2 = (XdmfXmlNode) 0 ; XdmfConstString arg3 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfDOM_Get",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_Get" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p__xmlNode, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDOM_Get" "', argument " "2"" of type '" "XdmfXmlNode""'"); } arg2 = reinterpret_cast< XdmfXmlNode >(argp2); res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfDOM_Get" "', argument " "3"" of type '" "XdmfConstString""'"); } arg3 = reinterpret_cast< XdmfConstString >(buf3); result = (XdmfConstString)(arg1)->Get(arg2,arg3); resultobj = SWIG_FromCharPtr((const char *)result); if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return resultobj; fail: if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_GetAttribute(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfXmlNode arg2 = (XdmfXmlNode) 0 ; XdmfConstString arg3 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfDOM_GetAttribute",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_GetAttribute" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p__xmlNode, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDOM_GetAttribute" "', argument " "2"" of type '" "XdmfXmlNode""'"); } arg2 = reinterpret_cast< XdmfXmlNode >(argp2); res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfDOM_GetAttribute" "', argument " "3"" of type '" "XdmfConstString""'"); } arg3 = reinterpret_cast< XdmfConstString >(buf3); result = (XdmfConstString)(arg1)->GetAttribute(arg2,arg3); resultobj = SWIG_FromCharPtr((const char *)result); if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return resultobj; fail: if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_GetCData(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfXmlNode arg2 = (XdmfXmlNode) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDOM_GetCData",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_GetCData" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p__xmlNode, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDOM_GetCData" "', argument " "2"" of type '" "XdmfXmlNode""'"); } arg2 = reinterpret_cast< XdmfXmlNode >(argp2); result = (XdmfConstString)(arg1)->GetCData(arg2); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDOM_Set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDOM *arg1 = (XdmfDOM *) 0 ; XdmfXmlNode arg2 = (XdmfXmlNode) 0 ; XdmfConstString arg3 = (XdmfConstString) 0 ; XdmfConstString arg4 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; int res4 ; char *buf4 = 0 ; int alloc4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; if (!PyArg_ParseTuple(args,(char *)"OOOO:XdmfDOM_Set",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDOM_Set" "', argument " "1"" of type '" "XdmfDOM *""'"); } arg1 = reinterpret_cast< XdmfDOM * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p__xmlNode, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDOM_Set" "', argument " "2"" of type '" "XdmfXmlNode""'"); } arg2 = reinterpret_cast< XdmfXmlNode >(argp2); res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfDOM_Set" "', argument " "3"" of type '" "XdmfConstString""'"); } arg3 = reinterpret_cast< XdmfConstString >(buf3); res4 = SWIG_AsCharPtrAndSize(obj3, &buf4, NULL, &alloc4); if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "XdmfDOM_Set" "', argument " "4"" of type '" "XdmfConstString""'"); } arg4 = reinterpret_cast< XdmfConstString >(buf4); (arg1)->Set(arg2,arg3,arg4); resultobj = SWIG_Py_Void(); if (alloc3 == SWIG_NEWOBJ) delete[] buf3; if (alloc4 == SWIG_NEWOBJ) delete[] buf4; return resultobj; fail: if (alloc3 == SWIG_NEWOBJ) delete[] buf3; if (alloc4 == SWIG_NEWOBJ) delete[] buf4; return NULL; } SWIGINTERN PyObject *XdmfDOM_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; SWIG_TypeNewClientData(SWIGTYPE_p_XdmfDOM, SWIG_NewClientData(obj)); return SWIG_Py_Void(); } SWIGINTERN PyObject *_wrap_HandleToXdmfDOM(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfConstString arg1 = (XdmfConstString) 0 ; int res1 ; char *buf1 = 0 ; int alloc1 = 0 ; PyObject * obj0 = 0 ; XdmfDOM *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:HandleToXdmfDOM",&obj0)) SWIG_fail; res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "HandleToXdmfDOM" "', argument " "1"" of type '" "XdmfConstString""'"); } arg1 = reinterpret_cast< XdmfConstString >(buf1); result = (XdmfDOM *)HandleToXdmfDOM((char const *)arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfDOM, 0 | 0 ); if (alloc1 == SWIG_NEWOBJ) delete[] buf1; return resultobj; fail: if (alloc1 == SWIG_NEWOBJ) delete[] buf1; return NULL; } SWIGINTERN PyObject *_wrap_new_XdmfInformation(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfInformation *result = 0 ; if (!PyArg_ParseTuple(args,(char *)":new_XdmfInformation")) SWIG_fail; result = (XdmfInformation *)new XdmfInformation(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfInformation, SWIG_POINTER_NEW | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_delete_XdmfInformation(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfInformation *arg1 = (XdmfInformation *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:delete_XdmfInformation",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfInformation, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_XdmfInformation" "', argument " "1"" of type '" "XdmfInformation *""'"); } arg1 = reinterpret_cast< XdmfInformation * >(argp1); delete arg1; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfInformation_GetClassName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfInformation *arg1 = (XdmfInformation *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfInformation_GetClassName",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfInformation, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfInformation_GetClassName" "', argument " "1"" of type '" "XdmfInformation *""'"); } arg1 = reinterpret_cast< XdmfInformation * >(argp1); result = (XdmfConstString)(arg1)->GetClassName(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfInformation_Insert(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfInformation *arg1 = (XdmfInformation *) 0 ; XdmfElement *arg2 = (XdmfElement *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfInformation_Insert",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfInformation, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfInformation_Insert" "', argument " "1"" of type '" "XdmfInformation *""'"); } arg1 = reinterpret_cast< XdmfInformation * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfInformation_Insert" "', argument " "2"" of type '" "XdmfElement *""'"); } arg2 = reinterpret_cast< XdmfElement * >(argp2); result = (XdmfInt32)(arg1)->Insert(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfInformation_UpdateInformation(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfInformation *arg1 = (XdmfInformation *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfInformation_UpdateInformation",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfInformation, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfInformation_UpdateInformation" "', argument " "1"" of type '" "XdmfInformation *""'"); } arg1 = reinterpret_cast< XdmfInformation * >(argp1); result = (XdmfInt32)(arg1)->UpdateInformation(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfInformation_SetValue(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfInformation *arg1 = (XdmfInformation *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfInformation_SetValue",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfInformation, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfInformation_SetValue" "', argument " "1"" of type '" "XdmfInformation *""'"); } arg1 = reinterpret_cast< XdmfInformation * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfInformation_SetValue" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfInt32)(arg1)->SetValue(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfInformation_Build(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfInformation *arg1 = (XdmfInformation *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfInformation_Build",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfInformation, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfInformation_Build" "', argument " "1"" of type '" "XdmfInformation *""'"); } arg1 = reinterpret_cast< XdmfInformation * >(argp1); result = (XdmfInt32)(arg1)->Build(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfInformation_GetValue(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfInformation *arg1 = (XdmfInformation *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfInformation_GetValue",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfInformation, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfInformation_GetValue" "', argument " "1"" of type '" "XdmfInformation *""'"); } arg1 = reinterpret_cast< XdmfInformation * >(argp1); result = (XdmfConstString)(arg1)->GetValue(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *XdmfInformation_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; SWIG_TypeNewClientData(SWIGTYPE_p_XdmfInformation, SWIG_NewClientData(obj)); return SWIG_Py_Void(); } SWIGINTERN PyObject *_wrap_new_XdmfDataItem(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataItem *result = 0 ; if (!PyArg_ParseTuple(args,(char *)":new_XdmfDataItem")) SWIG_fail; result = (XdmfDataItem *)new XdmfDataItem(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfDataItem, SWIG_POINTER_NEW | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_delete_XdmfDataItem(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataItem *arg1 = (XdmfDataItem *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:delete_XdmfDataItem",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataItem, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_XdmfDataItem" "', argument " "1"" of type '" "XdmfDataItem *""'"); } arg1 = reinterpret_cast< XdmfDataItem * >(argp1); delete arg1; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_GetClassName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataItem *arg1 = (XdmfDataItem *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDataItem_GetClassName",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataItem, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataItem_GetClassName" "', argument " "1"" of type '" "XdmfDataItem *""'"); } arg1 = reinterpret_cast< XdmfDataItem * >(argp1); result = (XdmfConstString)(arg1)->GetClassName(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_GetValues(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataItem *arg1 = (XdmfDataItem *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfValues *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDataItem_GetValues",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataItem, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataItem_GetValues" "', argument " "1"" of type '" "XdmfDataItem *""'"); } arg1 = reinterpret_cast< XdmfDataItem * >(argp1); result = (XdmfValues *)(arg1)->GetValues(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfValues, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_GetFormat(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataItem *arg1 = (XdmfDataItem *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDataItem_GetFormat",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataItem, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataItem_GetFormat" "', argument " "1"" of type '" "XdmfDataItem *""'"); } arg1 = reinterpret_cast< XdmfDataItem * >(argp1); result = (XdmfInt32)(arg1)->GetFormat(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_SetFormat(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataItem *arg1 = (XdmfDataItem *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDataItem_SetFormat",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataItem, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataItem_SetFormat" "', argument " "1"" of type '" "XdmfDataItem *""'"); } arg1 = reinterpret_cast< XdmfDataItem * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDataItem_SetFormat" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetFormat(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_Insert(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataItem *arg1 = (XdmfDataItem *) 0 ; XdmfElement *arg2 = (XdmfElement *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDataItem_Insert",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataItem, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataItem_Insert" "', argument " "1"" of type '" "XdmfDataItem *""'"); } arg1 = reinterpret_cast< XdmfDataItem * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDataItem_Insert" "', argument " "2"" of type '" "XdmfElement *""'"); } arg2 = reinterpret_cast< XdmfElement * >(argp2); result = (XdmfInt32)(arg1)->Insert(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_SetArrayIsMine(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataItem *arg1 = (XdmfDataItem *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDataItem_SetArrayIsMine",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataItem, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataItem_SetArrayIsMine" "', argument " "1"" of type '" "XdmfDataItem *""'"); } arg1 = reinterpret_cast< XdmfDataItem * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDataItem_SetArrayIsMine" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetArrayIsMine(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_GetArrayIsMine(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataItem *arg1 = (XdmfDataItem *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDataItem_GetArrayIsMine",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataItem, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataItem_GetArrayIsMine" "', argument " "1"" of type '" "XdmfDataItem *""'"); } arg1 = reinterpret_cast< XdmfDataItem * >(argp1); result = (XdmfInt32)(arg1)->GetArrayIsMine(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_UpdateInformation(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataItem *arg1 = (XdmfDataItem *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDataItem_UpdateInformation",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataItem, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataItem_UpdateInformation" "', argument " "1"" of type '" "XdmfDataItem *""'"); } arg1 = reinterpret_cast< XdmfDataItem * >(argp1); result = (XdmfInt32)(arg1)->UpdateInformation(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_Update(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataItem *arg1 = (XdmfDataItem *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDataItem_Update",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataItem, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataItem_Update" "', argument " "1"" of type '" "XdmfDataItem *""'"); } arg1 = reinterpret_cast< XdmfDataItem * >(argp1); result = (XdmfInt32)(arg1)->Update(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_Build(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataItem *arg1 = (XdmfDataItem *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDataItem_Build",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataItem, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataItem_Build" "', argument " "1"" of type '" "XdmfDataItem *""'"); } arg1 = reinterpret_cast< XdmfDataItem * >(argp1); result = (XdmfInt32)(arg1)->Build(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_GetDataDesc(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataItem *arg1 = (XdmfDataItem *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfDataDesc *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDataItem_GetDataDesc",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataItem, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataItem_GetDataDesc" "', argument " "1"" of type '" "XdmfDataItem *""'"); } arg1 = reinterpret_cast< XdmfDataItem * >(argp1); result = (XdmfDataDesc *)(arg1)->GetDataDesc(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_SetDataDesc(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataItem *arg1 = (XdmfDataItem *) 0 ; XdmfDataDesc *arg2 = (XdmfDataDesc *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDataItem_SetDataDesc",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataItem, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataItem_SetDataDesc" "', argument " "1"" of type '" "XdmfDataItem *""'"); } arg1 = reinterpret_cast< XdmfDataItem * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDataItem_SetDataDesc" "', argument " "2"" of type '" "XdmfDataDesc *""'"); } arg2 = reinterpret_cast< XdmfDataDesc * >(argp2); result = (XdmfInt32)(arg1)->SetDataDesc(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_GetArray__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataItem *arg1 = (XdmfDataItem *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDataItem_GetArray",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataItem, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataItem_GetArray" "', argument " "1"" of type '" "XdmfDataItem *""'"); } arg1 = reinterpret_cast< XdmfDataItem * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDataItem_GetArray" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfArray *)(arg1)->GetArray(arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_GetArray__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataItem *arg1 = (XdmfDataItem *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDataItem_GetArray",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataItem, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataItem_GetArray" "', argument " "1"" of type '" "XdmfDataItem *""'"); } arg1 = reinterpret_cast< XdmfDataItem * >(argp1); result = (XdmfArray *)(arg1)->GetArray(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_GetArray(PyObject *self, PyObject *args) { int argc; PyObject *argv[3]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 2); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDataItem, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfDataItem_GetArray__SWIG_1(self, args); } } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDataItem, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_int(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfDataItem_GetArray__SWIG_0(self, args); } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfDataItem_GetArray'.\n" " Possible C/C++ prototypes are:\n" " GetArray(XdmfDataItem *,XdmfInt32)\n" " GetArray(XdmfDataItem *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_SetArray(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataItem *arg1 = (XdmfDataItem *) 0 ; XdmfArray *arg2 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDataItem_SetArray",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataItem, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataItem_SetArray" "', argument " "1"" of type '" "XdmfDataItem *""'"); } arg1 = reinterpret_cast< XdmfDataItem * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDataItem_SetArray" "', argument " "2"" of type '" "XdmfArray *""'"); } arg2 = reinterpret_cast< XdmfArray * >(argp2); result = (XdmfInt32)(arg1)->SetArray(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_GetDataValues__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataItem *arg1 = (XdmfDataItem *) 0 ; XdmfInt64 arg2 ; XdmfInt64 arg3 ; XdmfInt64 arg4 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; long long val3 ; int ecode3 = 0 ; long long val4 ; int ecode4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; XdmfString result; if (!PyArg_ParseTuple(args,(char *)"OOOO:XdmfDataItem_GetDataValues",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataItem, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataItem_GetDataValues" "', argument " "1"" of type '" "XdmfDataItem *""'"); } arg1 = reinterpret_cast< XdmfDataItem * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDataItem_GetDataValues" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); ecode3 = SWIG_AsVal_long_SS_long(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "XdmfDataItem_GetDataValues" "', argument " "3"" of type '" "XdmfInt64""'"); } arg3 = static_cast< XdmfInt64 >(val3); ecode4 = SWIG_AsVal_long_SS_long(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfDataItem_GetDataValues" "', argument " "4"" of type '" "XdmfInt64""'"); } arg4 = static_cast< XdmfInt64 >(val4); result = (XdmfString)(arg1)->GetDataValues(arg2,arg3,arg4); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_GetDataValues__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataItem *arg1 = (XdmfDataItem *) 0 ; XdmfInt64 arg2 ; XdmfInt64 arg3 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; long long val3 ; int ecode3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfString result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfDataItem_GetDataValues",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataItem, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataItem_GetDataValues" "', argument " "1"" of type '" "XdmfDataItem *""'"); } arg1 = reinterpret_cast< XdmfDataItem * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDataItem_GetDataValues" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); ecode3 = SWIG_AsVal_long_SS_long(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "XdmfDataItem_GetDataValues" "', argument " "3"" of type '" "XdmfInt64""'"); } arg3 = static_cast< XdmfInt64 >(val3); result = (XdmfString)(arg1)->GetDataValues(arg2,arg3); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_GetDataValues__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataItem *arg1 = (XdmfDataItem *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfString result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDataItem_GetDataValues",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataItem, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataItem_GetDataValues" "', argument " "1"" of type '" "XdmfDataItem *""'"); } arg1 = reinterpret_cast< XdmfDataItem * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDataItem_GetDataValues" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfString)(arg1)->GetDataValues(arg2); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_GetDataValues__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataItem *arg1 = (XdmfDataItem *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDataItem_GetDataValues",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataItem, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataItem_GetDataValues" "', argument " "1"" of type '" "XdmfDataItem *""'"); } arg1 = reinterpret_cast< XdmfDataItem * >(argp1); result = (XdmfString)(arg1)->GetDataValues(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_GetDataValues(PyObject *self, PyObject *args) { int argc; PyObject *argv[5]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 4); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDataItem, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfDataItem_GetDataValues__SWIG_3(self, args); } } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDataItem, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfDataItem_GetDataValues__SWIG_2(self, args); } } } if (argc == 3) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDataItem, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[2], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfDataItem_GetDataValues__SWIG_1(self, args); } } } } if (argc == 4) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDataItem, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[2], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfDataItem_GetDataValues__SWIG_0(self, args); } } } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfDataItem_GetDataValues'.\n" " Possible C/C++ prototypes are:\n" " GetDataValues(XdmfDataItem *,XdmfInt64,XdmfInt64,XdmfInt64)\n" " GetDataValues(XdmfDataItem *,XdmfInt64,XdmfInt64)\n" " GetDataValues(XdmfDataItem *,XdmfInt64)\n" " GetDataValues(XdmfDataItem *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_SetDataValues__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataItem *arg1 = (XdmfDataItem *) 0 ; XdmfInt64 arg2 ; XdmfConstString arg3 = (XdmfConstString) 0 ; XdmfInt64 arg4 ; XdmfInt64 arg5 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; long long val4 ; int ecode4 = 0 ; long long val5 ; int ecode5 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOOO:XdmfDataItem_SetDataValues",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataItem, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataItem_SetDataValues" "', argument " "1"" of type '" "XdmfDataItem *""'"); } arg1 = reinterpret_cast< XdmfDataItem * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDataItem_SetDataValues" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfDataItem_SetDataValues" "', argument " "3"" of type '" "XdmfConstString""'"); } arg3 = reinterpret_cast< XdmfConstString >(buf3); ecode4 = SWIG_AsVal_long_SS_long(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfDataItem_SetDataValues" "', argument " "4"" of type '" "XdmfInt64""'"); } arg4 = static_cast< XdmfInt64 >(val4); ecode5 = SWIG_AsVal_long_SS_long(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "XdmfDataItem_SetDataValues" "', argument " "5"" of type '" "XdmfInt64""'"); } arg5 = static_cast< XdmfInt64 >(val5); result = (XdmfInt32)(arg1)->SetDataValues(arg2,arg3,arg4,arg5); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return resultobj; fail: if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_SetDataValues__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataItem *arg1 = (XdmfDataItem *) 0 ; XdmfInt64 arg2 ; XdmfConstString arg3 = (XdmfConstString) 0 ; XdmfInt64 arg4 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; long long val4 ; int ecode4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOO:XdmfDataItem_SetDataValues",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataItem, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataItem_SetDataValues" "', argument " "1"" of type '" "XdmfDataItem *""'"); } arg1 = reinterpret_cast< XdmfDataItem * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDataItem_SetDataValues" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfDataItem_SetDataValues" "', argument " "3"" of type '" "XdmfConstString""'"); } arg3 = reinterpret_cast< XdmfConstString >(buf3); ecode4 = SWIG_AsVal_long_SS_long(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfDataItem_SetDataValues" "', argument " "4"" of type '" "XdmfInt64""'"); } arg4 = static_cast< XdmfInt64 >(val4); result = (XdmfInt32)(arg1)->SetDataValues(arg2,arg3,arg4); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return resultobj; fail: if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_SetDataValues__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataItem *arg1 = (XdmfDataItem *) 0 ; XdmfInt64 arg2 ; XdmfConstString arg3 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfDataItem_SetDataValues",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataItem, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataItem_SetDataValues" "', argument " "1"" of type '" "XdmfDataItem *""'"); } arg1 = reinterpret_cast< XdmfDataItem * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDataItem_SetDataValues" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfDataItem_SetDataValues" "', argument " "3"" of type '" "XdmfConstString""'"); } arg3 = reinterpret_cast< XdmfConstString >(buf3); result = (XdmfInt32)(arg1)->SetDataValues(arg2,arg3); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return resultobj; fail: if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_SetDataValues(PyObject *self, PyObject *args) { int argc; PyObject *argv[6]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 5); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 3) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDataItem, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfDataItem_SetDataValues__SWIG_2(self, args); } } } } if (argc == 4) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDataItem, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfDataItem_SetDataValues__SWIG_1(self, args); } } } } } if (argc == 5) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDataItem, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[4], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfDataItem_SetDataValues__SWIG_0(self, args); } } } } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfDataItem_SetDataValues'.\n" " Possible C/C++ prototypes are:\n" " SetDataValues(XdmfDataItem *,XdmfInt64,XdmfConstString,XdmfInt64,XdmfInt64)\n" " SetDataValues(XdmfDataItem *,XdmfInt64,XdmfConstString,XdmfInt64)\n" " SetDataValues(XdmfDataItem *,XdmfInt64,XdmfConstString)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_GetRank(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataItem *arg1 = (XdmfDataItem *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDataItem_GetRank",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataItem, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataItem_GetRank" "', argument " "1"" of type '" "XdmfDataItem *""'"); } arg1 = reinterpret_cast< XdmfDataItem * >(argp1); result = (XdmfInt32)(arg1)->GetRank(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_SetShape(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataItem *arg1 = (XdmfDataItem *) 0 ; XdmfInt32 arg2 ; XdmfInt64 *arg3 = (XdmfInt64 *) 0 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfDataItem_SetShape",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataItem, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataItem_SetShape" "', argument " "1"" of type '" "XdmfDataItem *""'"); } arg1 = reinterpret_cast< XdmfDataItem * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDataItem_SetShape" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_long_long, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfDataItem_SetShape" "', argument " "3"" of type '" "XdmfInt64 *""'"); } arg3 = reinterpret_cast< XdmfInt64 * >(argp3); result = (XdmfInt32)(arg1)->SetShape(arg2,arg3); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_GetShape(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataItem *arg1 = (XdmfDataItem *) 0 ; XdmfInt64 *arg2 = (XdmfInt64 *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDataItem_GetShape",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataItem, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataItem_GetShape" "', argument " "1"" of type '" "XdmfDataItem *""'"); } arg1 = reinterpret_cast< XdmfDataItem * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_long_long, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDataItem_GetShape" "', argument " "2"" of type '" "XdmfInt64 *""'"); } arg2 = reinterpret_cast< XdmfInt64 * >(argp2); result = (XdmfInt32)(arg1)->GetShape(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_GetShapeAsString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataItem *arg1 = (XdmfDataItem *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDataItem_GetShapeAsString",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataItem, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataItem_GetShapeAsString" "', argument " "1"" of type '" "XdmfDataItem *""'"); } arg1 = reinterpret_cast< XdmfDataItem * >(argp1); result = (XdmfConstString)(arg1)->GetShapeAsString(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_GetDimensions(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataItem *arg1 = (XdmfDataItem *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDataItem_GetDimensions",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataItem, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataItem_GetDimensions" "', argument " "1"" of type '" "XdmfDataItem *""'"); } arg1 = reinterpret_cast< XdmfDataItem * >(argp1); result = (XdmfConstString)(arg1)->GetDimensions(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_SetDimensions(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataItem *arg1 = (XdmfDataItem *) 0 ; XdmfInt32 arg2 ; XdmfInt64 *arg3 = (XdmfInt64 *) 0 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfDataItem_SetDimensions",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataItem, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataItem_SetDimensions" "', argument " "1"" of type '" "XdmfDataItem *""'"); } arg1 = reinterpret_cast< XdmfDataItem * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDataItem_SetDimensions" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_long_long, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfDataItem_SetDimensions" "', argument " "3"" of type '" "XdmfInt64 *""'"); } arg3 = reinterpret_cast< XdmfInt64 * >(argp3); result = (XdmfInt32)(arg1)->SetDimensions(arg2,arg3); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_SetDimensionsFromString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataItem *arg1 = (XdmfDataItem *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDataItem_SetDimensionsFromString",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataItem, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataItem_SetDimensionsFromString" "', argument " "1"" of type '" "XdmfDataItem *""'"); } arg1 = reinterpret_cast< XdmfDataItem * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDataItem_SetDimensionsFromString" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfInt32)(arg1)->SetDimensionsFromString(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_SetHeavyDataSetName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataItem *arg1 = (XdmfDataItem *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDataItem_SetHeavyDataSetName",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataItem, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataItem_SetHeavyDataSetName" "', argument " "1"" of type '" "XdmfDataItem *""'"); } arg1 = reinterpret_cast< XdmfDataItem * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDataItem_SetHeavyDataSetName" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfInt32)(arg1)->SetHeavyDataSetName(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_GetHeavyDataSetName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataItem *arg1 = (XdmfDataItem *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDataItem_GetHeavyDataSetName",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataItem, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataItem_GetHeavyDataSetName" "', argument " "1"" of type '" "XdmfDataItem *""'"); } arg1 = reinterpret_cast< XdmfDataItem * >(argp1); result = (XdmfConstString)(arg1)->GetHeavyDataSetName(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_Copy(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataItem *arg1 = (XdmfDataItem *) 0 ; XdmfElement *arg2 = (XdmfElement *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDataItem_Copy",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataItem, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataItem_Copy" "', argument " "1"" of type '" "XdmfDataItem *""'"); } arg1 = reinterpret_cast< XdmfDataItem * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDataItem_Copy" "', argument " "2"" of type '" "XdmfElement *""'"); } arg2 = reinterpret_cast< XdmfElement * >(argp2); result = (XdmfInt32)(arg1)->Copy(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_SetItemType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataItem *arg1 = (XdmfDataItem *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDataItem_SetItemType",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataItem, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataItem_SetItemType" "', argument " "1"" of type '" "XdmfDataItem *""'"); } arg1 = reinterpret_cast< XdmfDataItem * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDataItem_SetItemType" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetItemType(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_GetItemType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataItem *arg1 = (XdmfDataItem *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDataItem_GetItemType",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataItem, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataItem_GetItemType" "', argument " "1"" of type '" "XdmfDataItem *""'"); } arg1 = reinterpret_cast< XdmfDataItem * >(argp1); result = (XdmfInt32)(arg1)->GetItemType(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_GetIsMultiple(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataItem *arg1 = (XdmfDataItem *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDataItem_GetIsMultiple",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataItem, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataItem_GetIsMultiple" "', argument " "1"" of type '" "XdmfDataItem *""'"); } arg1 = reinterpret_cast< XdmfDataItem * >(argp1); result = (XdmfInt32)(arg1)->GetIsMultiple(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_SetFunction(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataItem *arg1 = (XdmfDataItem *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDataItem_SetFunction",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataItem, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataItem_SetFunction" "', argument " "1"" of type '" "XdmfDataItem *""'"); } arg1 = reinterpret_cast< XdmfDataItem * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDataItem_SetFunction" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfInt32)(arg1)->SetFunction(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_GetFunction(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataItem *arg1 = (XdmfDataItem *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDataItem_GetFunction",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataItem, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataItem_GetFunction" "', argument " "1"" of type '" "XdmfDataItem *""'"); } arg1 = reinterpret_cast< XdmfDataItem * >(argp1); result = (XdmfConstString)(arg1)->GetFunction(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_Release(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataItem *arg1 = (XdmfDataItem *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDataItem_Release",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataItem, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataItem_Release" "', argument " "1"" of type '" "XdmfDataItem *""'"); } arg1 = reinterpret_cast< XdmfDataItem * >(argp1); result = (XdmfInt32)(arg1)->Release(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_GetColumnMajor(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataItem *arg1 = (XdmfDataItem *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDataItem_GetColumnMajor",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataItem, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataItem_GetColumnMajor" "', argument " "1"" of type '" "XdmfDataItem *""'"); } arg1 = reinterpret_cast< XdmfDataItem * >(argp1); result = (XdmfInt32)(arg1)->GetColumnMajor(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_SetColumnMajor(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataItem *arg1 = (XdmfDataItem *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDataItem_SetColumnMajor",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataItem, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataItem_SetColumnMajor" "', argument " "1"" of type '" "XdmfDataItem *""'"); } arg1 = reinterpret_cast< XdmfDataItem * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDataItem_SetColumnMajor" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetColumnMajor(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_GetTransposeInMemory(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataItem *arg1 = (XdmfDataItem *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDataItem_GetTransposeInMemory",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataItem, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataItem_GetTransposeInMemory" "', argument " "1"" of type '" "XdmfDataItem *""'"); } arg1 = reinterpret_cast< XdmfDataItem * >(argp1); result = (XdmfInt32)(arg1)->GetTransposeInMemory(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataItem_SetTransposeInMemory(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataItem *arg1 = (XdmfDataItem *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDataItem_SetTransposeInMemory",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataItem, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataItem_SetTransposeInMemory" "', argument " "1"" of type '" "XdmfDataItem *""'"); } arg1 = reinterpret_cast< XdmfDataItem * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDataItem_SetTransposeInMemory" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetTransposeInMemory(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *XdmfDataItem_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; SWIG_TypeNewClientData(SWIGTYPE_p_XdmfDataItem, SWIG_NewClientData(obj)); return SWIG_Py_Void(); } SWIGINTERN PyObject *_wrap_new_XdmfDataStructure(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataStructure *result = 0 ; if (!PyArg_ParseTuple(args,(char *)":new_XdmfDataStructure")) SWIG_fail; result = (XdmfDataStructure *)new XdmfDataStructure(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfDataStructure, SWIG_POINTER_NEW | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_delete_XdmfDataStructure(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataStructure *arg1 = (XdmfDataStructure *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:delete_XdmfDataStructure",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataStructure, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_XdmfDataStructure" "', argument " "1"" of type '" "XdmfDataStructure *""'"); } arg1 = reinterpret_cast< XdmfDataStructure * >(argp1); delete arg1; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataStructure_GetClassName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataStructure *arg1 = (XdmfDataStructure *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDataStructure_GetClassName",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataStructure, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataStructure_GetClassName" "', argument " "1"" of type '" "XdmfDataStructure *""'"); } arg1 = reinterpret_cast< XdmfDataStructure * >(argp1); result = (XdmfConstString)(arg1)->GetClassName(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDataStructure_UpdateInformation(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDataStructure *arg1 = (XdmfDataStructure *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDataStructure_UpdateInformation",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataStructure, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataStructure_UpdateInformation" "', argument " "1"" of type '" "XdmfDataStructure *""'"); } arg1 = reinterpret_cast< XdmfDataStructure * >(argp1); result = (XdmfInt32)(arg1)->UpdateInformation(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *XdmfDataStructure_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; SWIG_TypeNewClientData(SWIGTYPE_p_XdmfDataStructure, SWIG_NewClientData(obj)); return SWIG_Py_Void(); } SWIGINTERN PyObject *_wrap_new_XdmfValues(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfValues *result = 0 ; if (!PyArg_ParseTuple(args,(char *)":new_XdmfValues")) SWIG_fail; result = (XdmfValues *)new XdmfValues(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfValues, SWIG_POINTER_NEW | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_delete_XdmfValues(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfValues *arg1 = (XdmfValues *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:delete_XdmfValues",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfValues, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_XdmfValues" "', argument " "1"" of type '" "XdmfValues *""'"); } arg1 = reinterpret_cast< XdmfValues * >(argp1); delete arg1; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfValues_GetClassName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfValues *arg1 = (XdmfValues *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfValues_GetClassName",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfValues, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfValues_GetClassName" "', argument " "1"" of type '" "XdmfValues *""'"); } arg1 = reinterpret_cast< XdmfValues * >(argp1); result = (XdmfConstString)(arg1)->GetClassName(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfValues_Inherit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfValues *arg1 = (XdmfValues *) 0 ; XdmfDataItem *arg2 = (XdmfDataItem *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfValues_Inherit",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfValues, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfValues_Inherit" "', argument " "1"" of type '" "XdmfValues *""'"); } arg1 = reinterpret_cast< XdmfValues * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfDataItem, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfValues_Inherit" "', argument " "2"" of type '" "XdmfDataItem *""'"); } arg2 = reinterpret_cast< XdmfDataItem * >(argp2); result = (XdmfInt32)(arg1)->Inherit(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfValues_Read__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfValues *arg1 = (XdmfValues *) 0 ; XdmfArray *arg2 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfValues_Read",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfValues, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfValues_Read" "', argument " "1"" of type '" "XdmfValues *""'"); } arg1 = reinterpret_cast< XdmfValues * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfValues_Read" "', argument " "2"" of type '" "XdmfArray *""'"); } arg2 = reinterpret_cast< XdmfArray * >(argp2); result = (XdmfArray *)(arg1)->Read(arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfValues_Read__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfValues *arg1 = (XdmfValues *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfValues_Read",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfValues, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfValues_Read" "', argument " "1"" of type '" "XdmfValues *""'"); } arg1 = reinterpret_cast< XdmfValues * >(argp1); result = (XdmfArray *)(arg1)->Read(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfValues_Read(PyObject *self, PyObject *args) { int argc; PyObject *argv[3]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 2); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfValues, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfValues_Read__SWIG_1(self, args); } } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfValues, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfValues_Read__SWIG_0(self, args); } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfValues_Read'.\n" " Possible C/C++ prototypes are:\n" " Read(XdmfValues *,XdmfArray *)\n" " Read(XdmfValues *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfValues_Write__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfValues *arg1 = (XdmfValues *) 0 ; XdmfArray *arg2 = (XdmfArray *) 0 ; XdmfConstString arg3 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfValues_Write",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfValues, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfValues_Write" "', argument " "1"" of type '" "XdmfValues *""'"); } arg1 = reinterpret_cast< XdmfValues * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfValues_Write" "', argument " "2"" of type '" "XdmfArray *""'"); } arg2 = reinterpret_cast< XdmfArray * >(argp2); res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfValues_Write" "', argument " "3"" of type '" "XdmfConstString""'"); } arg3 = reinterpret_cast< XdmfConstString >(buf3); result = (XdmfInt32)(arg1)->Write(arg2,arg3); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return resultobj; fail: if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return NULL; } SWIGINTERN PyObject *_wrap_XdmfValues_Write__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfValues *arg1 = (XdmfValues *) 0 ; XdmfArray *arg2 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfValues_Write",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfValues, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfValues_Write" "', argument " "1"" of type '" "XdmfValues *""'"); } arg1 = reinterpret_cast< XdmfValues * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfValues_Write" "', argument " "2"" of type '" "XdmfArray *""'"); } arg2 = reinterpret_cast< XdmfArray * >(argp2); result = (XdmfInt32)(arg1)->Write(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfValues_Write(PyObject *self, PyObject *args) { int argc; PyObject *argv[4]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 3); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfValues, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfValues_Write__SWIG_1(self, args); } } } if (argc == 3) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfValues, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfValues_Write__SWIG_0(self, args); } } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfValues_Write'.\n" " Possible C/C++ prototypes are:\n" " Write(XdmfValues *,XdmfArray *,XdmfConstString)\n" " Write(XdmfValues *,XdmfArray *)\n"); return NULL; } SWIGINTERN PyObject *XdmfValues_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; SWIG_TypeNewClientData(SWIGTYPE_p_XdmfValues, SWIG_NewClientData(obj)); return SWIG_Py_Void(); } SWIGINTERN PyObject *_wrap_new_XdmfValuesXML(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfValuesXML *result = 0 ; if (!PyArg_ParseTuple(args,(char *)":new_XdmfValuesXML")) SWIG_fail; result = (XdmfValuesXML *)new XdmfValuesXML(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfValuesXML, SWIG_POINTER_NEW | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_delete_XdmfValuesXML(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfValuesXML *arg1 = (XdmfValuesXML *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:delete_XdmfValuesXML",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfValuesXML, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_XdmfValuesXML" "', argument " "1"" of type '" "XdmfValuesXML *""'"); } arg1 = reinterpret_cast< XdmfValuesXML * >(argp1); delete arg1; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfValuesXML_GetClassName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfValuesXML *arg1 = (XdmfValuesXML *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfValuesXML_GetClassName",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfValuesXML, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfValuesXML_GetClassName" "', argument " "1"" of type '" "XdmfValuesXML *""'"); } arg1 = reinterpret_cast< XdmfValuesXML * >(argp1); result = (XdmfConstString)(arg1)->GetClassName(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfValuesXML_Read__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfValuesXML *arg1 = (XdmfValuesXML *) 0 ; XdmfArray *arg2 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfValuesXML_Read",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfValuesXML, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfValuesXML_Read" "', argument " "1"" of type '" "XdmfValuesXML *""'"); } arg1 = reinterpret_cast< XdmfValuesXML * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfValuesXML_Read" "', argument " "2"" of type '" "XdmfArray *""'"); } arg2 = reinterpret_cast< XdmfArray * >(argp2); result = (XdmfArray *)(arg1)->Read(arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfValuesXML_Read__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfValuesXML *arg1 = (XdmfValuesXML *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfValuesXML_Read",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfValuesXML, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfValuesXML_Read" "', argument " "1"" of type '" "XdmfValuesXML *""'"); } arg1 = reinterpret_cast< XdmfValuesXML * >(argp1); result = (XdmfArray *)(arg1)->Read(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfValuesXML_Read(PyObject *self, PyObject *args) { int argc; PyObject *argv[3]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 2); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfValuesXML, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfValuesXML_Read__SWIG_1(self, args); } } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfValuesXML, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfValuesXML_Read__SWIG_0(self, args); } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfValuesXML_Read'.\n" " Possible C/C++ prototypes are:\n" " Read(XdmfValuesXML *,XdmfArray *)\n" " Read(XdmfValuesXML *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfValuesXML_Write__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfValuesXML *arg1 = (XdmfValuesXML *) 0 ; XdmfArray *arg2 = (XdmfArray *) 0 ; XdmfConstString arg3 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfValuesXML_Write",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfValuesXML, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfValuesXML_Write" "', argument " "1"" of type '" "XdmfValuesXML *""'"); } arg1 = reinterpret_cast< XdmfValuesXML * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfValuesXML_Write" "', argument " "2"" of type '" "XdmfArray *""'"); } arg2 = reinterpret_cast< XdmfArray * >(argp2); res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfValuesXML_Write" "', argument " "3"" of type '" "XdmfConstString""'"); } arg3 = reinterpret_cast< XdmfConstString >(buf3); result = (XdmfInt32)(arg1)->Write(arg2,arg3); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return resultobj; fail: if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return NULL; } SWIGINTERN PyObject *_wrap_XdmfValuesXML_Write__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfValuesXML *arg1 = (XdmfValuesXML *) 0 ; XdmfArray *arg2 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfValuesXML_Write",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfValuesXML, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfValuesXML_Write" "', argument " "1"" of type '" "XdmfValuesXML *""'"); } arg1 = reinterpret_cast< XdmfValuesXML * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfValuesXML_Write" "', argument " "2"" of type '" "XdmfArray *""'"); } arg2 = reinterpret_cast< XdmfArray * >(argp2); result = (XdmfInt32)(arg1)->Write(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfValuesXML_Write(PyObject *self, PyObject *args) { int argc; PyObject *argv[4]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 3); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfValuesXML, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfValuesXML_Write__SWIG_1(self, args); } } } if (argc == 3) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfValuesXML, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfValuesXML_Write__SWIG_0(self, args); } } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfValuesXML_Write'.\n" " Possible C/C++ prototypes are:\n" " Write(XdmfValuesXML *,XdmfArray *,XdmfConstString)\n" " Write(XdmfValuesXML *,XdmfArray *)\n"); return NULL; } SWIGINTERN PyObject *XdmfValuesXML_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; SWIG_TypeNewClientData(SWIGTYPE_p_XdmfValuesXML, SWIG_NewClientData(obj)); return SWIG_Py_Void(); } SWIGINTERN PyObject *_wrap_new_XdmfValuesHDF(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfValuesHDF *result = 0 ; if (!PyArg_ParseTuple(args,(char *)":new_XdmfValuesHDF")) SWIG_fail; result = (XdmfValuesHDF *)new XdmfValuesHDF(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfValuesHDF, SWIG_POINTER_NEW | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_delete_XdmfValuesHDF(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfValuesHDF *arg1 = (XdmfValuesHDF *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:delete_XdmfValuesHDF",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfValuesHDF, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_XdmfValuesHDF" "', argument " "1"" of type '" "XdmfValuesHDF *""'"); } arg1 = reinterpret_cast< XdmfValuesHDF * >(argp1); delete arg1; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfValuesHDF_GetClassName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfValuesHDF *arg1 = (XdmfValuesHDF *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfValuesHDF_GetClassName",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfValuesHDF, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfValuesHDF_GetClassName" "', argument " "1"" of type '" "XdmfValuesHDF *""'"); } arg1 = reinterpret_cast< XdmfValuesHDF * >(argp1); result = (XdmfConstString)(arg1)->GetClassName(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfValuesHDF_Read__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfValuesHDF *arg1 = (XdmfValuesHDF *) 0 ; XdmfArray *arg2 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfValuesHDF_Read",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfValuesHDF, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfValuesHDF_Read" "', argument " "1"" of type '" "XdmfValuesHDF *""'"); } arg1 = reinterpret_cast< XdmfValuesHDF * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfValuesHDF_Read" "', argument " "2"" of type '" "XdmfArray *""'"); } arg2 = reinterpret_cast< XdmfArray * >(argp2); result = (XdmfArray *)(arg1)->Read(arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfValuesHDF_Read__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfValuesHDF *arg1 = (XdmfValuesHDF *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfValuesHDF_Read",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfValuesHDF, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfValuesHDF_Read" "', argument " "1"" of type '" "XdmfValuesHDF *""'"); } arg1 = reinterpret_cast< XdmfValuesHDF * >(argp1); result = (XdmfArray *)(arg1)->Read(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfValuesHDF_Read(PyObject *self, PyObject *args) { int argc; PyObject *argv[3]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 2); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfValuesHDF, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfValuesHDF_Read__SWIG_1(self, args); } } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfValuesHDF, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfValuesHDF_Read__SWIG_0(self, args); } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfValuesHDF_Read'.\n" " Possible C/C++ prototypes are:\n" " Read(XdmfValuesHDF *,XdmfArray *)\n" " Read(XdmfValuesHDF *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfValuesHDF_Write__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfValuesHDF *arg1 = (XdmfValuesHDF *) 0 ; XdmfArray *arg2 = (XdmfArray *) 0 ; XdmfConstString arg3 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfValuesHDF_Write",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfValuesHDF, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfValuesHDF_Write" "', argument " "1"" of type '" "XdmfValuesHDF *""'"); } arg1 = reinterpret_cast< XdmfValuesHDF * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfValuesHDF_Write" "', argument " "2"" of type '" "XdmfArray *""'"); } arg2 = reinterpret_cast< XdmfArray * >(argp2); res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfValuesHDF_Write" "', argument " "3"" of type '" "XdmfConstString""'"); } arg3 = reinterpret_cast< XdmfConstString >(buf3); result = (XdmfInt32)(arg1)->Write(arg2,arg3); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return resultobj; fail: if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return NULL; } SWIGINTERN PyObject *_wrap_XdmfValuesHDF_Write__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfValuesHDF *arg1 = (XdmfValuesHDF *) 0 ; XdmfArray *arg2 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfValuesHDF_Write",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfValuesHDF, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfValuesHDF_Write" "', argument " "1"" of type '" "XdmfValuesHDF *""'"); } arg1 = reinterpret_cast< XdmfValuesHDF * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfValuesHDF_Write" "', argument " "2"" of type '" "XdmfArray *""'"); } arg2 = reinterpret_cast< XdmfArray * >(argp2); result = (XdmfInt32)(arg1)->Write(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfValuesHDF_Write(PyObject *self, PyObject *args) { int argc; PyObject *argv[4]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 3); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfValuesHDF, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfValuesHDF_Write__SWIG_1(self, args); } } } if (argc == 3) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfValuesHDF, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfValuesHDF_Write__SWIG_0(self, args); } } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfValuesHDF_Write'.\n" " Possible C/C++ prototypes are:\n" " Write(XdmfValuesHDF *,XdmfArray *,XdmfConstString)\n" " Write(XdmfValuesHDF *,XdmfArray *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfValuesHDF_DataItemFromHDF(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfValuesHDF *arg1 = (XdmfValuesHDF *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfString result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfValuesHDF_DataItemFromHDF",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfValuesHDF, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfValuesHDF_DataItemFromHDF" "', argument " "1"" of type '" "XdmfValuesHDF *""'"); } arg1 = reinterpret_cast< XdmfValuesHDF * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfValuesHDF_DataItemFromHDF" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfString)(arg1)->DataItemFromHDF(arg2); resultobj = SWIG_FromCharPtr((const char *)result); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *XdmfValuesHDF_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; SWIG_TypeNewClientData(SWIGTYPE_p_XdmfValuesHDF, SWIG_NewClientData(obj)); return SWIG_Py_Void(); } SWIGINTERN PyObject *_wrap_XdmfArrayExpr(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfString arg2 = (XdmfString) 0 ; XdmfArray *arg3 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfArrayExpr",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfArrayExpr" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfArrayExpr" "', argument " "2"" of type '" "XdmfString""'"); } arg2 = reinterpret_cast< XdmfString >(buf2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfArrayExpr" "', argument " "3"" of type '" "XdmfArray *""'"); } arg3 = reinterpret_cast< XdmfArray * >(argp3); XdmfArrayExpr(arg1,arg2,arg3); resultobj = SWIG_Py_Void(); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfScalarExpr(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfString arg2 = (XdmfString) 0 ; XdmfFloat64 arg3 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; double val3 ; int ecode3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfScalarExpr",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfScalarExpr" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfScalarExpr" "', argument " "2"" of type '" "XdmfString""'"); } arg2 = reinterpret_cast< XdmfString >(buf2); ecode3 = SWIG_AsVal_double(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "XdmfScalarExpr" "', argument " "3"" of type '" "XdmfFloat64""'"); } arg3 = static_cast< XdmfFloat64 >(val3); XdmfScalarExpr(arg1,arg2,arg3); resultobj = SWIG_Py_Void(); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfExpr(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfString arg1 = (XdmfString) 0 ; int res1 ; char *buf1 = 0 ; int alloc1 = 0 ; PyObject * obj0 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfExpr",&obj0)) SWIG_fail; res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfExpr" "', argument " "1"" of type '" "XdmfString""'"); } arg1 = reinterpret_cast< XdmfString >(buf1); result = (XdmfArray *)XdmfExpr(arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); if (alloc1 == SWIG_NEWOBJ) delete[] buf1; return resultobj; fail: if (alloc1 == SWIG_NEWOBJ) delete[] buf1; return NULL; } SWIGINTERN PyObject *_wrap_new_XdmfHeavyData(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHeavyData *result = 0 ; if (!PyArg_ParseTuple(args,(char *)":new_XdmfHeavyData")) SWIG_fail; result = (XdmfHeavyData *)new XdmfHeavyData(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfHeavyData, SWIG_POINTER_NEW | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_delete_XdmfHeavyData(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHeavyData *arg1 = (XdmfHeavyData *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:delete_XdmfHeavyData",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHeavyData, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_XdmfHeavyData" "', argument " "1"" of type '" "XdmfHeavyData *""'"); } arg1 = reinterpret_cast< XdmfHeavyData * >(argp1); delete arg1; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfHeavyData_GetClassName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHeavyData *arg1 = (XdmfHeavyData *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfHeavyData_GetClassName",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHeavyData, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHeavyData_GetClassName" "', argument " "1"" of type '" "XdmfHeavyData *""'"); } arg1 = reinterpret_cast< XdmfHeavyData * >(argp1); result = (XdmfConstString)(arg1)->GetClassName(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfHeavyData_GetNdgmHost(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHeavyData *arg1 = (XdmfHeavyData *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfHeavyData_GetNdgmHost",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHeavyData, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHeavyData_GetNdgmHost" "', argument " "1"" of type '" "XdmfHeavyData *""'"); } arg1 = reinterpret_cast< XdmfHeavyData * >(argp1); result = (XdmfConstString)(arg1)->GetNdgmHost(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfHeavyData_SetNdgmHost(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHeavyData *arg1 = (XdmfHeavyData *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfHeavyData_SetNdgmHost",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHeavyData, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHeavyData_SetNdgmHost" "', argument " "1"" of type '" "XdmfHeavyData *""'"); } arg1 = reinterpret_cast< XdmfHeavyData * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfHeavyData_SetNdgmHost" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); (arg1)->SetNdgmHost(arg2); resultobj = SWIG_Py_Void(); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfHeavyData_GetWorkingDirectory(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHeavyData *arg1 = (XdmfHeavyData *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfHeavyData_GetWorkingDirectory",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHeavyData, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHeavyData_GetWorkingDirectory" "', argument " "1"" of type '" "XdmfHeavyData *""'"); } arg1 = reinterpret_cast< XdmfHeavyData * >(argp1); result = (XdmfConstString)(arg1)->GetWorkingDirectory(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfHeavyData_SetWorkingDirectory(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHeavyData *arg1 = (XdmfHeavyData *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfHeavyData_SetWorkingDirectory",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHeavyData, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHeavyData_SetWorkingDirectory" "', argument " "1"" of type '" "XdmfHeavyData *""'"); } arg1 = reinterpret_cast< XdmfHeavyData * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfHeavyData_SetWorkingDirectory" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); (arg1)->SetWorkingDirectory(arg2); resultobj = SWIG_Py_Void(); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfHeavyData_GetDomain(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHeavyData *arg1 = (XdmfHeavyData *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfHeavyData_GetDomain",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHeavyData, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHeavyData_GetDomain" "', argument " "1"" of type '" "XdmfHeavyData *""'"); } arg1 = reinterpret_cast< XdmfHeavyData * >(argp1); result = (XdmfConstString)(arg1)->GetDomain(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfHeavyData_SetDomain(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHeavyData *arg1 = (XdmfHeavyData *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfHeavyData_SetDomain",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHeavyData, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHeavyData_SetDomain" "', argument " "1"" of type '" "XdmfHeavyData *""'"); } arg1 = reinterpret_cast< XdmfHeavyData * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfHeavyData_SetDomain" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); (arg1)->SetDomain(arg2); resultobj = SWIG_Py_Void(); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfHeavyData_GetFileName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHeavyData *arg1 = (XdmfHeavyData *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfHeavyData_GetFileName",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHeavyData, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHeavyData_GetFileName" "', argument " "1"" of type '" "XdmfHeavyData *""'"); } arg1 = reinterpret_cast< XdmfHeavyData * >(argp1); result = (XdmfConstString)(arg1)->GetFileName(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfHeavyData_SetFileName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHeavyData *arg1 = (XdmfHeavyData *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfHeavyData_SetFileName",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHeavyData, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHeavyData_SetFileName" "', argument " "1"" of type '" "XdmfHeavyData *""'"); } arg1 = reinterpret_cast< XdmfHeavyData * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfHeavyData_SetFileName" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); (arg1)->SetFileName(arg2); resultobj = SWIG_Py_Void(); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfHeavyData_GetPath(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHeavyData *arg1 = (XdmfHeavyData *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfHeavyData_GetPath",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHeavyData, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHeavyData_GetPath" "', argument " "1"" of type '" "XdmfHeavyData *""'"); } arg1 = reinterpret_cast< XdmfHeavyData * >(argp1); result = (XdmfConstString)(arg1)->GetPath(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfHeavyData_SetPath(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHeavyData *arg1 = (XdmfHeavyData *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfHeavyData_SetPath",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHeavyData, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHeavyData_SetPath" "', argument " "1"" of type '" "XdmfHeavyData *""'"); } arg1 = reinterpret_cast< XdmfHeavyData * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfHeavyData_SetPath" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); (arg1)->SetPath(arg2); resultobj = SWIG_Py_Void(); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfHeavyData_GetAccess(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHeavyData *arg1 = (XdmfHeavyData *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfHeavyData_GetAccess",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHeavyData, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHeavyData_GetAccess" "', argument " "1"" of type '" "XdmfHeavyData *""'"); } arg1 = reinterpret_cast< XdmfHeavyData * >(argp1); result = (XdmfConstString)(arg1)->GetAccess(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfHeavyData_SetAccess(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHeavyData *arg1 = (XdmfHeavyData *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfHeavyData_SetAccess",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHeavyData, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHeavyData_SetAccess" "', argument " "1"" of type '" "XdmfHeavyData *""'"); } arg1 = reinterpret_cast< XdmfHeavyData * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfHeavyData_SetAccess" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); (arg1)->SetAccess(arg2); resultobj = SWIG_Py_Void(); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfHeavyData_Open__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHeavyData *arg1 = (XdmfHeavyData *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; XdmfConstString arg3 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfHeavyData_Open",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHeavyData, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHeavyData_Open" "', argument " "1"" of type '" "XdmfHeavyData *""'"); } arg1 = reinterpret_cast< XdmfHeavyData * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfHeavyData_Open" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfHeavyData_Open" "', argument " "3"" of type '" "XdmfConstString""'"); } arg3 = reinterpret_cast< XdmfConstString >(buf3); result = (XdmfInt32)(arg1)->Open(arg2,arg3); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return NULL; } SWIGINTERN PyObject *_wrap_XdmfHeavyData_Open__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHeavyData *arg1 = (XdmfHeavyData *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfHeavyData_Open",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHeavyData, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHeavyData_Open" "', argument " "1"" of type '" "XdmfHeavyData *""'"); } arg1 = reinterpret_cast< XdmfHeavyData * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfHeavyData_Open" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfInt32)(arg1)->Open(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfHeavyData_Open__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHeavyData *arg1 = (XdmfHeavyData *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfHeavyData_Open",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHeavyData, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHeavyData_Open" "', argument " "1"" of type '" "XdmfHeavyData *""'"); } arg1 = reinterpret_cast< XdmfHeavyData * >(argp1); result = (XdmfInt32)(arg1)->Open(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfHeavyData_Open(PyObject *self, PyObject *args) { int argc; PyObject *argv[4]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 3); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfHeavyData, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfHeavyData_Open__SWIG_2(self, args); } } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfHeavyData, 0); _v = SWIG_CheckState(res); if (_v) { int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfHeavyData_Open__SWIG_1(self, args); } } } if (argc == 3) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfHeavyData, 0); _v = SWIG_CheckState(res); if (_v) { int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfHeavyData_Open__SWIG_0(self, args); } } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfHeavyData_Open'.\n" " Possible C/C++ prototypes are:\n" " Open(XdmfHeavyData *,XdmfConstString,XdmfConstString)\n" " Open(XdmfHeavyData *,XdmfConstString)\n" " Open(XdmfHeavyData *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfHeavyData_Read__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHeavyData *arg1 = (XdmfHeavyData *) 0 ; XdmfArray *arg2 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfHeavyData_Read",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHeavyData, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHeavyData_Read" "', argument " "1"" of type '" "XdmfHeavyData *""'"); } arg1 = reinterpret_cast< XdmfHeavyData * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfHeavyData_Read" "', argument " "2"" of type '" "XdmfArray *""'"); } arg2 = reinterpret_cast< XdmfArray * >(argp2); result = (XdmfArray *)(arg1)->Read(arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfHeavyData_Read__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHeavyData *arg1 = (XdmfHeavyData *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfHeavyData_Read",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHeavyData, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHeavyData_Read" "', argument " "1"" of type '" "XdmfHeavyData *""'"); } arg1 = reinterpret_cast< XdmfHeavyData * >(argp1); result = (XdmfArray *)(arg1)->Read(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfHeavyData_Read(PyObject *self, PyObject *args) { int argc; PyObject *argv[3]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 2); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfHeavyData, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfHeavyData_Read__SWIG_1(self, args); } } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfHeavyData, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfHeavyData_Read__SWIG_0(self, args); } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfHeavyData_Read'.\n" " Possible C/C++ prototypes are:\n" " Read(XdmfHeavyData *,XdmfArray *)\n" " Read(XdmfHeavyData *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfHeavyData_Write(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHeavyData *arg1 = (XdmfHeavyData *) 0 ; XdmfArray *arg2 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfHeavyData_Write",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHeavyData, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHeavyData_Write" "', argument " "1"" of type '" "XdmfHeavyData *""'"); } arg1 = reinterpret_cast< XdmfHeavyData * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfHeavyData_Write" "', argument " "2"" of type '" "XdmfArray *""'"); } arg2 = reinterpret_cast< XdmfArray * >(argp2); result = (XdmfInt32)(arg1)->Write(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfHeavyData_Close(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHeavyData *arg1 = (XdmfHeavyData *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfHeavyData_Close",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHeavyData, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHeavyData_Close" "', argument " "1"" of type '" "XdmfHeavyData *""'"); } arg1 = reinterpret_cast< XdmfHeavyData * >(argp1); result = (XdmfInt32)(arg1)->Close(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfHeavyData_DoOpen(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHeavyData *arg1 = (XdmfHeavyData *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; XdmfConstString arg3 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfHeavyData_DoOpen",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHeavyData, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHeavyData_DoOpen" "', argument " "1"" of type '" "XdmfHeavyData *""'"); } arg1 = reinterpret_cast< XdmfHeavyData * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfHeavyData_DoOpen" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfHeavyData_DoOpen" "', argument " "3"" of type '" "XdmfConstString""'"); } arg3 = reinterpret_cast< XdmfConstString >(buf3); result = (XdmfInt32)(arg1)->DoOpen(arg2,arg3); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return NULL; } SWIGINTERN PyObject *_wrap_XdmfHeavyData_DoRead(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHeavyData *arg1 = (XdmfHeavyData *) 0 ; XdmfArray *arg2 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfHeavyData_DoRead",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHeavyData, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHeavyData_DoRead" "', argument " "1"" of type '" "XdmfHeavyData *""'"); } arg1 = reinterpret_cast< XdmfHeavyData * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfHeavyData_DoRead" "', argument " "2"" of type '" "XdmfArray *""'"); } arg2 = reinterpret_cast< XdmfArray * >(argp2); result = (XdmfArray *)(arg1)->DoRead(arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfHeavyData_DoWrite(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHeavyData *arg1 = (XdmfHeavyData *) 0 ; XdmfArray *arg2 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfHeavyData_DoWrite",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHeavyData, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHeavyData_DoWrite" "', argument " "1"" of type '" "XdmfHeavyData *""'"); } arg1 = reinterpret_cast< XdmfHeavyData * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfHeavyData_DoWrite" "', argument " "2"" of type '" "XdmfArray *""'"); } arg2 = reinterpret_cast< XdmfArray * >(argp2); result = (XdmfInt32)(arg1)->DoWrite(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfHeavyData_DoClose(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHeavyData *arg1 = (XdmfHeavyData *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfHeavyData_DoClose",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHeavyData, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHeavyData_DoClose" "', argument " "1"" of type '" "XdmfHeavyData *""'"); } arg1 = reinterpret_cast< XdmfHeavyData * >(argp1); result = (XdmfInt32)(arg1)->DoClose(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfHeavyData_setOpenCallback(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHeavyData *arg1 = (XdmfHeavyData *) 0 ; XdmfOpenCallback *arg2 = (XdmfOpenCallback *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfHeavyData_setOpenCallback",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHeavyData, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHeavyData_setOpenCallback" "', argument " "1"" of type '" "XdmfHeavyData *""'"); } arg1 = reinterpret_cast< XdmfHeavyData * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfOpenCallback, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfHeavyData_setOpenCallback" "', argument " "2"" of type '" "XdmfOpenCallback *""'"); } arg2 = reinterpret_cast< XdmfOpenCallback * >(argp2); (arg1)->setOpenCallback(arg2); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfHeavyData_setReadCallback(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHeavyData *arg1 = (XdmfHeavyData *) 0 ; XdmfReadCallback *arg2 = (XdmfReadCallback *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfHeavyData_setReadCallback",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHeavyData, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHeavyData_setReadCallback" "', argument " "1"" of type '" "XdmfHeavyData *""'"); } arg1 = reinterpret_cast< XdmfHeavyData * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfReadCallback, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfHeavyData_setReadCallback" "', argument " "2"" of type '" "XdmfReadCallback *""'"); } arg2 = reinterpret_cast< XdmfReadCallback * >(argp2); (arg1)->setReadCallback(arg2); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfHeavyData_setWriteCallback(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHeavyData *arg1 = (XdmfHeavyData *) 0 ; XdmfWriteCallback *arg2 = (XdmfWriteCallback *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfHeavyData_setWriteCallback",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHeavyData, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHeavyData_setWriteCallback" "', argument " "1"" of type '" "XdmfHeavyData *""'"); } arg1 = reinterpret_cast< XdmfHeavyData * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfWriteCallback, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfHeavyData_setWriteCallback" "', argument " "2"" of type '" "XdmfWriteCallback *""'"); } arg2 = reinterpret_cast< XdmfWriteCallback * >(argp2); (arg1)->setWriteCallback(arg2); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfHeavyData_setCloseCallback(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHeavyData *arg1 = (XdmfHeavyData *) 0 ; XdmfCloseCallback *arg2 = (XdmfCloseCallback *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfHeavyData_setCloseCallback",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHeavyData, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHeavyData_setCloseCallback" "', argument " "1"" of type '" "XdmfHeavyData *""'"); } arg1 = reinterpret_cast< XdmfHeavyData * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfCloseCallback, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfHeavyData_setCloseCallback" "', argument " "2"" of type '" "XdmfCloseCallback *""'"); } arg2 = reinterpret_cast< XdmfCloseCallback * >(argp2); (arg1)->setCloseCallback(arg2); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *XdmfHeavyData_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; SWIG_TypeNewClientData(SWIGTYPE_p_XdmfHeavyData, SWIG_NewClientData(obj)); return SWIG_Py_Void(); } SWIGINTERN PyObject *_wrap_XdmfOpenCallback_DoOpen(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfOpenCallback *arg1 = (XdmfOpenCallback *) 0 ; XdmfHeavyData *arg2 = (XdmfHeavyData *) 0 ; XdmfConstString arg3 = (XdmfConstString) 0 ; XdmfConstString arg4 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; int res4 ; char *buf4 = 0 ; int alloc4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOO:XdmfOpenCallback_DoOpen",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfOpenCallback, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfOpenCallback_DoOpen" "', argument " "1"" of type '" "XdmfOpenCallback *""'"); } arg1 = reinterpret_cast< XdmfOpenCallback * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfHeavyData, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfOpenCallback_DoOpen" "', argument " "2"" of type '" "XdmfHeavyData *""'"); } arg2 = reinterpret_cast< XdmfHeavyData * >(argp2); res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfOpenCallback_DoOpen" "', argument " "3"" of type '" "XdmfConstString""'"); } arg3 = reinterpret_cast< XdmfConstString >(buf3); res4 = SWIG_AsCharPtrAndSize(obj3, &buf4, NULL, &alloc4); if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "XdmfOpenCallback_DoOpen" "', argument " "4"" of type '" "XdmfConstString""'"); } arg4 = reinterpret_cast< XdmfConstString >(buf4); result = (XdmfInt32)(arg1)->DoOpen(arg2,arg3,arg4); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc3 == SWIG_NEWOBJ) delete[] buf3; if (alloc4 == SWIG_NEWOBJ) delete[] buf4; return resultobj; fail: if (alloc3 == SWIG_NEWOBJ) delete[] buf3; if (alloc4 == SWIG_NEWOBJ) delete[] buf4; return NULL; } SWIGINTERN PyObject *_wrap_new_XdmfOpenCallback(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfOpenCallback *result = 0 ; if (!PyArg_ParseTuple(args,(char *)":new_XdmfOpenCallback")) SWIG_fail; result = (XdmfOpenCallback *)new XdmfOpenCallback(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfOpenCallback, SWIG_POINTER_NEW | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_delete_XdmfOpenCallback(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfOpenCallback *arg1 = (XdmfOpenCallback *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:delete_XdmfOpenCallback",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfOpenCallback, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_XdmfOpenCallback" "', argument " "1"" of type '" "XdmfOpenCallback *""'"); } arg1 = reinterpret_cast< XdmfOpenCallback * >(argp1); delete arg1; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *XdmfOpenCallback_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; SWIG_TypeNewClientData(SWIGTYPE_p_XdmfOpenCallback, SWIG_NewClientData(obj)); return SWIG_Py_Void(); } SWIGINTERN PyObject *_wrap_XdmfReadCallback_DoRead(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfReadCallback *arg1 = (XdmfReadCallback *) 0 ; XdmfHeavyData *arg2 = (XdmfHeavyData *) 0 ; XdmfArray *arg3 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfReadCallback_DoRead",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfReadCallback, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfReadCallback_DoRead" "', argument " "1"" of type '" "XdmfReadCallback *""'"); } arg1 = reinterpret_cast< XdmfReadCallback * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfHeavyData, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfReadCallback_DoRead" "', argument " "2"" of type '" "XdmfHeavyData *""'"); } arg2 = reinterpret_cast< XdmfHeavyData * >(argp2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfReadCallback_DoRead" "', argument " "3"" of type '" "XdmfArray *""'"); } arg3 = reinterpret_cast< XdmfArray * >(argp3); result = (XdmfArray *)(arg1)->DoRead(arg2,arg3); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_new_XdmfReadCallback(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfReadCallback *result = 0 ; if (!PyArg_ParseTuple(args,(char *)":new_XdmfReadCallback")) SWIG_fail; result = (XdmfReadCallback *)new XdmfReadCallback(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfReadCallback, SWIG_POINTER_NEW | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_delete_XdmfReadCallback(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfReadCallback *arg1 = (XdmfReadCallback *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:delete_XdmfReadCallback",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfReadCallback, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_XdmfReadCallback" "', argument " "1"" of type '" "XdmfReadCallback *""'"); } arg1 = reinterpret_cast< XdmfReadCallback * >(argp1); delete arg1; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *XdmfReadCallback_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; SWIG_TypeNewClientData(SWIGTYPE_p_XdmfReadCallback, SWIG_NewClientData(obj)); return SWIG_Py_Void(); } SWIGINTERN PyObject *_wrap_XdmfWriteCallback_DoWrite(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfWriteCallback *arg1 = (XdmfWriteCallback *) 0 ; XdmfHeavyData *arg2 = (XdmfHeavyData *) 0 ; XdmfArray *arg3 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfWriteCallback_DoWrite",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfWriteCallback, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfWriteCallback_DoWrite" "', argument " "1"" of type '" "XdmfWriteCallback *""'"); } arg1 = reinterpret_cast< XdmfWriteCallback * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfHeavyData, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfWriteCallback_DoWrite" "', argument " "2"" of type '" "XdmfHeavyData *""'"); } arg2 = reinterpret_cast< XdmfHeavyData * >(argp2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfWriteCallback_DoWrite" "', argument " "3"" of type '" "XdmfArray *""'"); } arg3 = reinterpret_cast< XdmfArray * >(argp3); result = (XdmfInt32)(arg1)->DoWrite(arg2,arg3); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_new_XdmfWriteCallback(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfWriteCallback *result = 0 ; if (!PyArg_ParseTuple(args,(char *)":new_XdmfWriteCallback")) SWIG_fail; result = (XdmfWriteCallback *)new XdmfWriteCallback(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfWriteCallback, SWIG_POINTER_NEW | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_delete_XdmfWriteCallback(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfWriteCallback *arg1 = (XdmfWriteCallback *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:delete_XdmfWriteCallback",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfWriteCallback, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_XdmfWriteCallback" "', argument " "1"" of type '" "XdmfWriteCallback *""'"); } arg1 = reinterpret_cast< XdmfWriteCallback * >(argp1); delete arg1; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *XdmfWriteCallback_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; SWIG_TypeNewClientData(SWIGTYPE_p_XdmfWriteCallback, SWIG_NewClientData(obj)); return SWIG_Py_Void(); } SWIGINTERN PyObject *_wrap_XdmfCloseCallback_DoClose(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfCloseCallback *arg1 = (XdmfCloseCallback *) 0 ; XdmfHeavyData *arg2 = (XdmfHeavyData *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfCloseCallback_DoClose",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfCloseCallback, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfCloseCallback_DoClose" "', argument " "1"" of type '" "XdmfCloseCallback *""'"); } arg1 = reinterpret_cast< XdmfCloseCallback * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfHeavyData, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfCloseCallback_DoClose" "', argument " "2"" of type '" "XdmfHeavyData *""'"); } arg2 = reinterpret_cast< XdmfHeavyData * >(argp2); result = (XdmfInt32)(arg1)->DoClose(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_new_XdmfCloseCallback(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfCloseCallback *result = 0 ; if (!PyArg_ParseTuple(args,(char *)":new_XdmfCloseCallback")) SWIG_fail; result = (XdmfCloseCallback *)new XdmfCloseCallback(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfCloseCallback, SWIG_POINTER_NEW | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_delete_XdmfCloseCallback(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfCloseCallback *arg1 = (XdmfCloseCallback *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:delete_XdmfCloseCallback",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfCloseCallback, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_XdmfCloseCallback" "', argument " "1"" of type '" "XdmfCloseCallback *""'"); } arg1 = reinterpret_cast< XdmfCloseCallback * >(argp1); delete arg1; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *XdmfCloseCallback_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; SWIG_TypeNewClientData(SWIGTYPE_p_XdmfCloseCallback, SWIG_NewClientData(obj)); return SWIG_Py_Void(); } SWIGINTERN PyObject *_wrap_new_XdmfHDF(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHDF *result = 0 ; if (!PyArg_ParseTuple(args,(char *)":new_XdmfHDF")) SWIG_fail; result = (XdmfHDF *)new XdmfHDF(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfHDF, SWIG_POINTER_NEW | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_delete_XdmfHDF(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHDF *arg1 = (XdmfHDF *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:delete_XdmfHDF",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHDF, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_XdmfHDF" "', argument " "1"" of type '" "XdmfHDF *""'"); } arg1 = reinterpret_cast< XdmfHDF * >(argp1); delete arg1; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfHDF_GetClassName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHDF *arg1 = (XdmfHDF *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfHDF_GetClassName",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHDF, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHDF_GetClassName" "', argument " "1"" of type '" "XdmfHDF *""'"); } arg1 = reinterpret_cast< XdmfHDF * >(argp1); result = (XdmfConstString)(arg1)->GetClassName(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfHDF_SetCompression(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHDF *arg1 = (XdmfHDF *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfHDF_SetCompression",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHDF, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHDF_SetCompression" "', argument " "1"" of type '" "XdmfHDF *""'"); } arg1 = reinterpret_cast< XdmfHDF * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfHDF_SetCompression" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetCompression(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfHDF_GetCompression(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHDF *arg1 = (XdmfHDF *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfHDF_GetCompression",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHDF, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHDF_GetCompression" "', argument " "1"" of type '" "XdmfHDF *""'"); } arg1 = reinterpret_cast< XdmfHDF * >(argp1); result = (XdmfInt32)(arg1)->GetCompression(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfHDF_SetUseSerialFile(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHDF *arg1 = (XdmfHDF *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfHDF_SetUseSerialFile",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHDF, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHDF_SetUseSerialFile" "', argument " "1"" of type '" "XdmfHDF *""'"); } arg1 = reinterpret_cast< XdmfHDF * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfHDF_SetUseSerialFile" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetUseSerialFile(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfHDF_GetUseSerialFile(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHDF *arg1 = (XdmfHDF *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfHDF_GetUseSerialFile",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHDF, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHDF_GetUseSerialFile" "', argument " "1"" of type '" "XdmfHDF *""'"); } arg1 = reinterpret_cast< XdmfHDF * >(argp1); result = (XdmfInt32)(arg1)->GetUseSerialFile(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfHDF_SetCwdName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHDF *arg1 = (XdmfHDF *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfHDF_SetCwdName",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHDF, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHDF_SetCwdName" "', argument " "1"" of type '" "XdmfHDF *""'"); } arg1 = reinterpret_cast< XdmfHDF * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfHDF_SetCwdName" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfInt32)(arg1)->SetCwdName(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfHDF_GetCwdName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHDF *arg1 = (XdmfHDF *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfHDF_GetCwdName",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHDF, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHDF_GetCwdName" "', argument " "1"" of type '" "XdmfHDF *""'"); } arg1 = reinterpret_cast< XdmfHDF * >(argp1); result = (XdmfString)(arg1)->GetCwdName(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfHDF_Cd__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHDF *arg1 = (XdmfHDF *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfHDF_Cd",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHDF, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHDF_Cd" "', argument " "1"" of type '" "XdmfHDF *""'"); } arg1 = reinterpret_cast< XdmfHDF * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfHDF_Cd" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfInt32)(arg1)->Cd(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfHDF_Cd__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHDF *arg1 = (XdmfHDF *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfHDF_Cd",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHDF, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHDF_Cd" "', argument " "1"" of type '" "XdmfHDF *""'"); } arg1 = reinterpret_cast< XdmfHDF * >(argp1); result = (XdmfInt32)(arg1)->Cd(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfHDF_Cd(PyObject *self, PyObject *args) { int argc; PyObject *argv[3]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 2); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfHDF, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfHDF_Cd__SWIG_1(self, args); } } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfHDF, 0); _v = SWIG_CheckState(res); if (_v) { int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfHDF_Cd__SWIG_0(self, args); } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfHDF_Cd'.\n" " Possible C/C++ prototypes are:\n" " Cd(XdmfHDF *,XdmfConstString)\n" " Cd(XdmfHDF *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfHDF_Mkdir(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHDF *arg1 = (XdmfHDF *) 0 ; XdmfString arg2 = (XdmfString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfHDF_Mkdir",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHDF, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHDF_Mkdir" "', argument " "1"" of type '" "XdmfHDF *""'"); } arg1 = reinterpret_cast< XdmfHDF * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfHDF_Mkdir" "', argument " "2"" of type '" "XdmfString""'"); } arg2 = reinterpret_cast< XdmfString >(buf2); result = (XdmfInt32)(arg1)->Mkdir(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfHDF_GetNumberOfChildren(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHDF *arg1 = (XdmfHDF *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt64 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfHDF_GetNumberOfChildren",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHDF, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHDF_GetNumberOfChildren" "', argument " "1"" of type '" "XdmfHDF *""'"); } arg1 = reinterpret_cast< XdmfHDF * >(argp1); result = (XdmfInt64)(arg1)->GetNumberOfChildren(); resultobj = SWIG_From_long_SS_long(static_cast< long long >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfHDF_GetHDFVersion(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHDF *arg1 = (XdmfHDF *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfHDF_GetHDFVersion",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHDF, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHDF_GetHDFVersion" "', argument " "1"" of type '" "XdmfHDF *""'"); } arg1 = reinterpret_cast< XdmfHDF * >(argp1); result = (XdmfConstString)(arg1)->GetHDFVersion(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfHDF_GetChild(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHDF *arg1 = (XdmfHDF *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfHDF_GetChild",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHDF, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHDF_GetChild" "', argument " "1"" of type '" "XdmfHDF *""'"); } arg1 = reinterpret_cast< XdmfHDF * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfHDF_GetChild" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfConstString)(arg1)->GetChild(arg2); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfHDF_SetNextChild(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHDF *arg1 = (XdmfHDF *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfHDF_SetNextChild",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHDF, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHDF_SetNextChild" "', argument " "1"" of type '" "XdmfHDF *""'"); } arg1 = reinterpret_cast< XdmfHDF * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfHDF_SetNextChild" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); (arg1)->SetNextChild(arg2); resultobj = SWIG_Py_Void(); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfHDF_Info(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHDF *arg1 = (XdmfHDF *) 0 ; hid_t arg2 ; XdmfConstString arg3 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 ; int res2 = 0 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfHDF_Info",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHDF, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHDF_Info" "', argument " "1"" of type '" "XdmfHDF *""'"); } arg1 = reinterpret_cast< XdmfHDF * >(argp1); { res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_hid_t, 0 | 0); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfHDF_Info" "', argument " "2"" of type '" "hid_t""'"); } if (!argp2) { SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "XdmfHDF_Info" "', argument " "2"" of type '" "hid_t""'"); } else { hid_t * temp = reinterpret_cast< hid_t * >(argp2); arg2 = *temp; if (SWIG_IsNewObj(res2)) delete temp; } } res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfHDF_Info" "', argument " "3"" of type '" "XdmfConstString""'"); } arg3 = reinterpret_cast< XdmfConstString >(buf3); result = (XdmfInt32)(arg1)->Info(arg2,arg3); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return resultobj; fail: if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return NULL; } SWIGINTERN PyObject *_wrap_XdmfHDF_GetChildType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHDF *arg1 = (XdmfHDF *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfHDF_GetChildType",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHDF, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHDF_GetChildType" "', argument " "1"" of type '" "XdmfHDF *""'"); } arg1 = reinterpret_cast< XdmfHDF * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfHDF_GetChildType" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfInt32)(arg1)->GetChildType(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfHDF_GetChildTypeAsString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHDF *arg1 = (XdmfHDF *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfHDF_GetChildTypeAsString",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHDF, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHDF_GetChildTypeAsString" "', argument " "1"" of type '" "XdmfHDF *""'"); } arg1 = reinterpret_cast< XdmfHDF * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfHDF_GetChildTypeAsString" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfConstString)(arg1)->GetChildTypeAsString(arg2); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfHDF_CreateDataset__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHDF *arg1 = (XdmfHDF *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfHDF_CreateDataset",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHDF, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHDF_CreateDataset" "', argument " "1"" of type '" "XdmfHDF *""'"); } arg1 = reinterpret_cast< XdmfHDF * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfHDF_CreateDataset" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfInt32)(arg1)->CreateDataset(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfHDF_CreateDataset__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHDF *arg1 = (XdmfHDF *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfHDF_CreateDataset",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHDF, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHDF_CreateDataset" "', argument " "1"" of type '" "XdmfHDF *""'"); } arg1 = reinterpret_cast< XdmfHDF * >(argp1); result = (XdmfInt32)(arg1)->CreateDataset(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfHDF_CreateDataset(PyObject *self, PyObject *args) { int argc; PyObject *argv[3]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 2); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfHDF, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfHDF_CreateDataset__SWIG_1(self, args); } } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfHDF, 0); _v = SWIG_CheckState(res); if (_v) { int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfHDF_CreateDataset__SWIG_0(self, args); } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfHDF_CreateDataset'.\n" " Possible C/C++ prototypes are:\n" " CreateDataset(XdmfHDF *,XdmfConstString)\n" " CreateDataset(XdmfHDF *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfHDF_OpenDataset(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHDF *arg1 = (XdmfHDF *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfHDF_OpenDataset",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHDF, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHDF_OpenDataset" "', argument " "1"" of type '" "XdmfHDF *""'"); } arg1 = reinterpret_cast< XdmfHDF * >(argp1); result = (XdmfInt32)(arg1)->OpenDataset(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfHDF_DoOpen(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHDF *arg1 = (XdmfHDF *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; XdmfConstString arg3 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfHDF_DoOpen",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHDF, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHDF_DoOpen" "', argument " "1"" of type '" "XdmfHDF *""'"); } arg1 = reinterpret_cast< XdmfHDF * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfHDF_DoOpen" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfHDF_DoOpen" "', argument " "3"" of type '" "XdmfConstString""'"); } arg3 = reinterpret_cast< XdmfConstString >(buf3); result = (XdmfInt32)(arg1)->DoOpen(arg2,arg3); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return NULL; } SWIGINTERN PyObject *_wrap_XdmfHDF_DoRead(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHDF *arg1 = (XdmfHDF *) 0 ; XdmfArray *arg2 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfHDF_DoRead",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHDF, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHDF_DoRead" "', argument " "1"" of type '" "XdmfHDF *""'"); } arg1 = reinterpret_cast< XdmfHDF * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfHDF_DoRead" "', argument " "2"" of type '" "XdmfArray *""'"); } arg2 = reinterpret_cast< XdmfArray * >(argp2); result = (XdmfArray *)(arg1)->DoRead(arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfHDF_DoWrite(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHDF *arg1 = (XdmfHDF *) 0 ; XdmfArray *arg2 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfHDF_DoWrite",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHDF, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHDF_DoWrite" "', argument " "1"" of type '" "XdmfHDF *""'"); } arg1 = reinterpret_cast< XdmfHDF * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfHDF_DoWrite" "', argument " "2"" of type '" "XdmfArray *""'"); } arg2 = reinterpret_cast< XdmfArray * >(argp2); result = (XdmfInt32)(arg1)->DoWrite(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfHDF_DoClose(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfHDF *arg1 = (XdmfHDF *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfHDF_DoClose",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfHDF, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfHDF_DoClose" "', argument " "1"" of type '" "XdmfHDF *""'"); } arg1 = reinterpret_cast< XdmfHDF * >(argp1); result = (XdmfInt32)(arg1)->DoClose(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *XdmfHDF_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; SWIG_TypeNewClientData(SWIGTYPE_p_XdmfHDF, SWIG_NewClientData(obj)); return SWIG_Py_Void(); } SWIGINTERN PyObject *_wrap_CopyArray__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; XdmfArray *arg2 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:CopyArray",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CopyArray" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CopyArray" "', argument " "2"" of type '" "XdmfArray *""'"); } arg2 = reinterpret_cast< XdmfArray * >(argp2); result = (XdmfArray *)CopyArray(arg1,arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_CopyArray__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfArray *arg1 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:CopyArray",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CopyArray" "', argument " "1"" of type '" "XdmfArray *""'"); } arg1 = reinterpret_cast< XdmfArray * >(argp1); result = (XdmfArray *)CopyArray(arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_CopyArray(PyObject *self, PyObject *args) { int argc; PyObject *argv[3]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 2); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_CopyArray__SWIG_1(self, args); } } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_CopyArray__SWIG_0(self, args); } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'CopyArray'.\n" " Possible C/C++ prototypes are:\n" " CopyArray(XdmfArray *,XdmfArray *)\n" " CopyArray(XdmfArray *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_new_XdmfDomain(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDomain *result = 0 ; if (!PyArg_ParseTuple(args,(char *)":new_XdmfDomain")) SWIG_fail; result = (XdmfDomain *)new XdmfDomain(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfDomain, SWIG_POINTER_NEW | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_delete_XdmfDomain(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDomain *arg1 = (XdmfDomain *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:delete_XdmfDomain",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDomain, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_XdmfDomain" "', argument " "1"" of type '" "XdmfDomain *""'"); } arg1 = reinterpret_cast< XdmfDomain * >(argp1); delete arg1; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDomain_GetClassName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDomain *arg1 = (XdmfDomain *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDomain_GetClassName",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDomain, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDomain_GetClassName" "', argument " "1"" of type '" "XdmfDomain *""'"); } arg1 = reinterpret_cast< XdmfDomain * >(argp1); result = (XdmfConstString)(arg1)->GetClassName(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDomain_UpdateInformation(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDomain *arg1 = (XdmfDomain *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDomain_UpdateInformation",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDomain, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDomain_UpdateInformation" "', argument " "1"" of type '" "XdmfDomain *""'"); } arg1 = reinterpret_cast< XdmfDomain * >(argp1); result = (XdmfInt32)(arg1)->UpdateInformation(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDomain_Insert(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDomain *arg1 = (XdmfDomain *) 0 ; XdmfElement *arg2 = (XdmfElement *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDomain_Insert",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDomain, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDomain_Insert" "', argument " "1"" of type '" "XdmfDomain *""'"); } arg1 = reinterpret_cast< XdmfDomain * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDomain_Insert" "', argument " "2"" of type '" "XdmfElement *""'"); } arg2 = reinterpret_cast< XdmfElement * >(argp2); result = (XdmfInt32)(arg1)->Insert(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDomain_Build(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDomain *arg1 = (XdmfDomain *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDomain_Build",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDomain, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDomain_Build" "', argument " "1"" of type '" "XdmfDomain *""'"); } arg1 = reinterpret_cast< XdmfDomain * >(argp1); result = (XdmfInt32)(arg1)->Build(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *XdmfDomain_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; SWIG_TypeNewClientData(SWIGTYPE_p_XdmfDomain, SWIG_NewClientData(obj)); return SWIG_Py_Void(); } SWIGINTERN PyObject *_wrap_new_XdmfRoot(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfRoot *result = 0 ; if (!PyArg_ParseTuple(args,(char *)":new_XdmfRoot")) SWIG_fail; result = (XdmfRoot *)new XdmfRoot(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfRoot, SWIG_POINTER_NEW | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_delete_XdmfRoot(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfRoot *arg1 = (XdmfRoot *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:delete_XdmfRoot",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfRoot, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_XdmfRoot" "', argument " "1"" of type '" "XdmfRoot *""'"); } arg1 = reinterpret_cast< XdmfRoot * >(argp1); delete arg1; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfRoot_GetClassName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfRoot *arg1 = (XdmfRoot *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfRoot_GetClassName",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfRoot, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfRoot_GetClassName" "', argument " "1"" of type '" "XdmfRoot *""'"); } arg1 = reinterpret_cast< XdmfRoot * >(argp1); result = (XdmfConstString)(arg1)->GetClassName(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfRoot_UpdateInformation(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfRoot *arg1 = (XdmfRoot *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfRoot_UpdateInformation",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfRoot, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfRoot_UpdateInformation" "', argument " "1"" of type '" "XdmfRoot *""'"); } arg1 = reinterpret_cast< XdmfRoot * >(argp1); result = (XdmfInt32)(arg1)->UpdateInformation(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfRoot_Insert(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfRoot *arg1 = (XdmfRoot *) 0 ; XdmfElement *arg2 = (XdmfElement *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfRoot_Insert",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfRoot, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfRoot_Insert" "', argument " "1"" of type '" "XdmfRoot *""'"); } arg1 = reinterpret_cast< XdmfRoot * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfRoot_Insert" "', argument " "2"" of type '" "XdmfElement *""'"); } arg2 = reinterpret_cast< XdmfElement * >(argp2); result = (XdmfInt32)(arg1)->Insert(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfRoot_SetVersion(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfRoot *arg1 = (XdmfRoot *) 0 ; XdmfFloat32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; float val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfRoot_SetVersion",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfRoot, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfRoot_SetVersion" "', argument " "1"" of type '" "XdmfRoot *""'"); } arg1 = reinterpret_cast< XdmfRoot * >(argp1); ecode2 = SWIG_AsVal_float(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfRoot_SetVersion" "', argument " "2"" of type '" "XdmfFloat32""'"); } arg2 = static_cast< XdmfFloat32 >(val2); result = (XdmfInt32)(arg1)->SetVersion(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfRoot_SetXInclude(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfRoot *arg1 = (XdmfRoot *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfRoot_SetXInclude",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfRoot, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfRoot_SetXInclude" "', argument " "1"" of type '" "XdmfRoot *""'"); } arg1 = reinterpret_cast< XdmfRoot * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfRoot_SetXInclude" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetXInclude(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfRoot_Build(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfRoot *arg1 = (XdmfRoot *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfRoot_Build",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfRoot, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfRoot_Build" "', argument " "1"" of type '" "XdmfRoot *""'"); } arg1 = reinterpret_cast< XdmfRoot * >(argp1); result = (XdmfInt32)(arg1)->Build(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfRoot_GetXInclude(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfRoot *arg1 = (XdmfRoot *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfRoot_GetXInclude",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfRoot, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfRoot_GetXInclude" "', argument " "1"" of type '" "XdmfRoot *""'"); } arg1 = reinterpret_cast< XdmfRoot * >(argp1); result = (XdmfInt32)(arg1)->GetXInclude(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfRoot_GetVersion(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfRoot *arg1 = (XdmfRoot *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfFloat32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfRoot_GetVersion",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfRoot, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfRoot_GetVersion" "', argument " "1"" of type '" "XdmfRoot *""'"); } arg1 = reinterpret_cast< XdmfRoot * >(argp1); result = (XdmfFloat32)(arg1)->GetVersion(); resultobj = SWIG_From_float(static_cast< float >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *XdmfRoot_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; SWIG_TypeNewClientData(SWIGTYPE_p_XdmfRoot, SWIG_NewClientData(obj)); return SWIG_Py_Void(); } SWIGINTERN PyObject *_wrap_new_XdmfTopology(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTopology *result = 0 ; if (!PyArg_ParseTuple(args,(char *)":new_XdmfTopology")) SWIG_fail; result = (XdmfTopology *)new XdmfTopology(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfTopology, SWIG_POINTER_NEW | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_delete_XdmfTopology(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTopology *arg1 = (XdmfTopology *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:delete_XdmfTopology",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTopology, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_XdmfTopology" "', argument " "1"" of type '" "XdmfTopology *""'"); } arg1 = reinterpret_cast< XdmfTopology * >(argp1); delete arg1; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTopology_GetClassName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTopology *arg1 = (XdmfTopology *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfTopology_GetClassName",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTopology, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTopology_GetClassName" "', argument " "1"" of type '" "XdmfTopology *""'"); } arg1 = reinterpret_cast< XdmfTopology * >(argp1); result = (XdmfConstString)(arg1)->GetClassName(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTopology_Build(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTopology *arg1 = (XdmfTopology *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfTopology_Build",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTopology, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTopology_Build" "', argument " "1"" of type '" "XdmfTopology *""'"); } arg1 = reinterpret_cast< XdmfTopology * >(argp1); result = (XdmfInt32)(arg1)->Build(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTopology_Insert(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTopology *arg1 = (XdmfTopology *) 0 ; XdmfElement *arg2 = (XdmfElement *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfTopology_Insert",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTopology, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTopology_Insert" "', argument " "1"" of type '" "XdmfTopology *""'"); } arg1 = reinterpret_cast< XdmfTopology * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfTopology_Insert" "', argument " "2"" of type '" "XdmfElement *""'"); } arg2 = reinterpret_cast< XdmfElement * >(argp2); result = (XdmfInt32)(arg1)->Insert(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTopology_GetClass(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTopology *arg1 = (XdmfTopology *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfTopology_GetClass",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTopology, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTopology_GetClass" "', argument " "1"" of type '" "XdmfTopology *""'"); } arg1 = reinterpret_cast< XdmfTopology * >(argp1); result = (XdmfInt32)(arg1)->GetClass(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTopology_GetClassAsString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTopology *arg1 = (XdmfTopology *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfTopology_GetClassAsString",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTopology, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTopology_GetClassAsString" "', argument " "1"" of type '" "XdmfTopology *""'"); } arg1 = reinterpret_cast< XdmfTopology * >(argp1); result = (XdmfConstString)(arg1)->GetClassAsString(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTopology_SetTopologyType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTopology *arg1 = (XdmfTopology *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfTopology_SetTopologyType",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTopology, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTopology_SetTopologyType" "', argument " "1"" of type '" "XdmfTopology *""'"); } arg1 = reinterpret_cast< XdmfTopology * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfTopology_SetTopologyType" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetTopologyType(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTopology_SetTopologyTypeFromString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTopology *arg1 = (XdmfTopology *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfTopology_SetTopologyTypeFromString",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTopology, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTopology_SetTopologyTypeFromString" "', argument " "1"" of type '" "XdmfTopology *""'"); } arg1 = reinterpret_cast< XdmfTopology * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfTopology_SetTopologyTypeFromString" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfInt32)(arg1)->SetTopologyTypeFromString(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfTopology_GetTopologyType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTopology *arg1 = (XdmfTopology *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfTopology_GetTopologyType",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTopology, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTopology_GetTopologyType" "', argument " "1"" of type '" "XdmfTopology *""'"); } arg1 = reinterpret_cast< XdmfTopology * >(argp1); result = (XdmfInt32)(arg1)->GetTopologyType(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTopology_GetTopologyTypeAsString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTopology *arg1 = (XdmfTopology *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfTopology_GetTopologyTypeAsString",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTopology, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTopology_GetTopologyTypeAsString" "', argument " "1"" of type '" "XdmfTopology *""'"); } arg1 = reinterpret_cast< XdmfTopology * >(argp1); result = (XdmfConstString)(arg1)->GetTopologyTypeAsString(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTopology_GetOrder(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTopology *arg1 = (XdmfTopology *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfTopology_GetOrder",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTopology, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTopology_GetOrder" "', argument " "1"" of type '" "XdmfTopology *""'"); } arg1 = reinterpret_cast< XdmfTopology * >(argp1); result = (XdmfInt32 *)(arg1)->GetOrder(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_int, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTopology_GetOrderAsString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTopology *arg1 = (XdmfTopology *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfTopology_GetOrderAsString",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTopology, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTopology_GetOrderAsString" "', argument " "1"" of type '" "XdmfTopology *""'"); } arg1 = reinterpret_cast< XdmfTopology * >(argp1); result = (XdmfConstString)(arg1)->GetOrderAsString(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTopology_SetOrderFromString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTopology *arg1 = (XdmfTopology *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfTopology_SetOrderFromString",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTopology, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTopology_SetOrderFromString" "', argument " "1"" of type '" "XdmfTopology *""'"); } arg1 = reinterpret_cast< XdmfTopology * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfTopology_SetOrderFromString" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfInt32)(arg1)->SetOrderFromString(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfTopology_SetOrder(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTopology *arg1 = (XdmfTopology *) 0 ; XdmfInt32 arg2 ; XdmfInt32 *arg3 = (XdmfInt32 *) 0 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfTopology_SetOrder",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTopology, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTopology_SetOrder" "', argument " "1"" of type '" "XdmfTopology *""'"); } arg1 = reinterpret_cast< XdmfTopology * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfTopology_SetOrder" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_int, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfTopology_SetOrder" "', argument " "3"" of type '" "XdmfInt32 *""'"); } arg3 = reinterpret_cast< XdmfInt32 * >(argp3); result = (XdmfInt32)(arg1)->SetOrder(arg2,arg3); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTopology_SetLightDataLimit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTopology *arg1 = (XdmfTopology *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfTopology_SetLightDataLimit",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTopology, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTopology_SetLightDataLimit" "', argument " "1"" of type '" "XdmfTopology *""'"); } arg1 = reinterpret_cast< XdmfTopology * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfTopology_SetLightDataLimit" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetLightDataLimit(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTopology_GetLightDataLimit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTopology *arg1 = (XdmfTopology *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfTopology_GetLightDataLimit",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTopology, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTopology_GetLightDataLimit" "', argument " "1"" of type '" "XdmfTopology *""'"); } arg1 = reinterpret_cast< XdmfTopology * >(argp1); result = (XdmfInt32)(arg1)->GetLightDataLimit(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTopology_SetNodesPerElement(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTopology *arg1 = (XdmfTopology *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfTopology_SetNodesPerElement",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTopology, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTopology_SetNodesPerElement" "', argument " "1"" of type '" "XdmfTopology *""'"); } arg1 = reinterpret_cast< XdmfTopology * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfTopology_SetNodesPerElement" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetNodesPerElement(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTopology_GetNodesPerElement(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTopology *arg1 = (XdmfTopology *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfTopology_GetNodesPerElement",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTopology, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTopology_GetNodesPerElement" "', argument " "1"" of type '" "XdmfTopology *""'"); } arg1 = reinterpret_cast< XdmfTopology * >(argp1); result = (XdmfInt32)(arg1)->GetNodesPerElement(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTopology_SetBaseOffset(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTopology *arg1 = (XdmfTopology *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfTopology_SetBaseOffset",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTopology, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTopology_SetBaseOffset" "', argument " "1"" of type '" "XdmfTopology *""'"); } arg1 = reinterpret_cast< XdmfTopology * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfTopology_SetBaseOffset" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetBaseOffset(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTopology_GetBaseOffset(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTopology *arg1 = (XdmfTopology *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfTopology_GetBaseOffset",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTopology, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTopology_GetBaseOffset" "', argument " "1"" of type '" "XdmfTopology *""'"); } arg1 = reinterpret_cast< XdmfTopology * >(argp1); result = (XdmfInt32)(arg1)->GetBaseOffset(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTopology_GetShapeDesc(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTopology *arg1 = (XdmfTopology *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfDataDesc *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfTopology_GetShapeDesc",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTopology, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTopology_GetShapeDesc" "', argument " "1"" of type '" "XdmfTopology *""'"); } arg1 = reinterpret_cast< XdmfTopology * >(argp1); result = (XdmfDataDesc *)(arg1)->GetShapeDesc(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTopology_SetNumberOfElements(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTopology *arg1 = (XdmfTopology *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfTopology_SetNumberOfElements",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTopology, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTopology_SetNumberOfElements" "', argument " "1"" of type '" "XdmfTopology *""'"); } arg1 = reinterpret_cast< XdmfTopology * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfTopology_SetNumberOfElements" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfInt32)(arg1)->SetNumberOfElements(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTopology_GetNumberOfElements(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTopology *arg1 = (XdmfTopology *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt64 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfTopology_GetNumberOfElements",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTopology, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTopology_GetNumberOfElements" "', argument " "1"" of type '" "XdmfTopology *""'"); } arg1 = reinterpret_cast< XdmfTopology * >(argp1); result = (XdmfInt64)(arg1)->GetNumberOfElements(); resultobj = SWIG_From_long_SS_long(static_cast< long long >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTopology_GetConnectivity__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTopology *arg1 = (XdmfTopology *) 0 ; XdmfArray *arg2 = (XdmfArray *) 0 ; XdmfInt32 arg3 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; int val3 ; int ecode3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfTopology_GetConnectivity",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTopology, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTopology_GetConnectivity" "', argument " "1"" of type '" "XdmfTopology *""'"); } arg1 = reinterpret_cast< XdmfTopology * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfTopology_GetConnectivity" "', argument " "2"" of type '" "XdmfArray *""'"); } arg2 = reinterpret_cast< XdmfArray * >(argp2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "XdmfTopology_GetConnectivity" "', argument " "3"" of type '" "XdmfInt32""'"); } arg3 = static_cast< XdmfInt32 >(val3); result = (XdmfArray *)(arg1)->GetConnectivity(arg2,arg3); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTopology_GetConnectivity__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTopology *arg1 = (XdmfTopology *) 0 ; XdmfArray *arg2 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfTopology_GetConnectivity",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTopology, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTopology_GetConnectivity" "', argument " "1"" of type '" "XdmfTopology *""'"); } arg1 = reinterpret_cast< XdmfTopology * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfTopology_GetConnectivity" "', argument " "2"" of type '" "XdmfArray *""'"); } arg2 = reinterpret_cast< XdmfArray * >(argp2); result = (XdmfArray *)(arg1)->GetConnectivity(arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTopology_GetConnectivity__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTopology *arg1 = (XdmfTopology *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfTopology_GetConnectivity",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTopology, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTopology_GetConnectivity" "', argument " "1"" of type '" "XdmfTopology *""'"); } arg1 = reinterpret_cast< XdmfTopology * >(argp1); result = (XdmfArray *)(arg1)->GetConnectivity(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTopology_GetConnectivity(PyObject *self, PyObject *args) { int argc; PyObject *argv[4]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 3); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfTopology, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfTopology_GetConnectivity__SWIG_2(self, args); } } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfTopology, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfTopology_GetConnectivity__SWIG_1(self, args); } } } if (argc == 3) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfTopology, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_int(argv[2], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfTopology_GetConnectivity__SWIG_0(self, args); } } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfTopology_GetConnectivity'.\n" " Possible C/C++ prototypes are:\n" " GetConnectivity(XdmfTopology *,XdmfArray *,XdmfInt32)\n" " GetConnectivity(XdmfTopology *,XdmfArray *)\n" " GetConnectivity(XdmfTopology *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfTopology_SetConnectivity(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTopology *arg1 = (XdmfTopology *) 0 ; XdmfArray *arg2 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfTopology_SetConnectivity",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTopology, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTopology_SetConnectivity" "', argument " "1"" of type '" "XdmfTopology *""'"); } arg1 = reinterpret_cast< XdmfTopology * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfTopology_SetConnectivity" "', argument " "2"" of type '" "XdmfArray *""'"); } arg2 = reinterpret_cast< XdmfArray * >(argp2); result = (XdmfInt32)(arg1)->SetConnectivity(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTopology_GetCellOffsets__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTopology *arg1 = (XdmfTopology *) 0 ; XdmfArray *arg2 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfTopology_GetCellOffsets",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTopology, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTopology_GetCellOffsets" "', argument " "1"" of type '" "XdmfTopology *""'"); } arg1 = reinterpret_cast< XdmfTopology * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfTopology_GetCellOffsets" "', argument " "2"" of type '" "XdmfArray *""'"); } arg2 = reinterpret_cast< XdmfArray * >(argp2); result = (XdmfArray *)(arg1)->GetCellOffsets(arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTopology_GetCellOffsets__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTopology *arg1 = (XdmfTopology *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfTopology_GetCellOffsets",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTopology, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTopology_GetCellOffsets" "', argument " "1"" of type '" "XdmfTopology *""'"); } arg1 = reinterpret_cast< XdmfTopology * >(argp1); result = (XdmfArray *)(arg1)->GetCellOffsets(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTopology_GetCellOffsets(PyObject *self, PyObject *args) { int argc; PyObject *argv[3]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 2); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfTopology, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfTopology_GetCellOffsets__SWIG_1(self, args); } } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfTopology, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfTopology_GetCellOffsets__SWIG_0(self, args); } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfTopology_GetCellOffsets'.\n" " Possible C/C++ prototypes are:\n" " GetCellOffsets(XdmfTopology *,XdmfArray *)\n" " GetCellOffsets(XdmfTopology *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfTopology_Update(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTopology *arg1 = (XdmfTopology *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfTopology_Update",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTopology, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTopology_Update" "', argument " "1"" of type '" "XdmfTopology *""'"); } arg1 = reinterpret_cast< XdmfTopology * >(argp1); result = (XdmfInt32)(arg1)->Update(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTopology_UpdateInformation(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTopology *arg1 = (XdmfTopology *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfTopology_UpdateInformation",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTopology, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTopology_UpdateInformation" "', argument " "1"" of type '" "XdmfTopology *""'"); } arg1 = reinterpret_cast< XdmfTopology * >(argp1); result = (XdmfInt32)(arg1)->UpdateInformation(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTopology_Release(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTopology *arg1 = (XdmfTopology *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfTopology_Release",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTopology, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTopology_Release" "', argument " "1"" of type '" "XdmfTopology *""'"); } arg1 = reinterpret_cast< XdmfTopology * >(argp1); result = (XdmfInt32)(arg1)->Release(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *XdmfTopology_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; SWIG_TypeNewClientData(SWIGTYPE_p_XdmfTopology, SWIG_NewClientData(obj)); return SWIG_Py_Void(); } SWIGINTERN PyObject *_wrap_HandleToXdmfTopology(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfString arg1 = (XdmfString) 0 ; int res1 ; char *buf1 = 0 ; int alloc1 = 0 ; PyObject * obj0 = 0 ; XdmfTopology *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:HandleToXdmfTopology",&obj0)) SWIG_fail; res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "HandleToXdmfTopology" "', argument " "1"" of type '" "XdmfString""'"); } arg1 = reinterpret_cast< XdmfString >(buf1); result = (XdmfTopology *)HandleToXdmfTopology(arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfTopology, 0 | 0 ); if (alloc1 == SWIG_NEWOBJ) delete[] buf1; return resultobj; fail: if (alloc1 == SWIG_NEWOBJ) delete[] buf1; return NULL; } SWIGINTERN PyObject *_wrap_new_XdmfGeometry(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGeometry *result = 0 ; if (!PyArg_ParseTuple(args,(char *)":new_XdmfGeometry")) SWIG_fail; result = (XdmfGeometry *)new XdmfGeometry(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfGeometry, SWIG_POINTER_NEW | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_delete_XdmfGeometry(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGeometry *arg1 = (XdmfGeometry *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:delete_XdmfGeometry",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGeometry, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_XdmfGeometry" "', argument " "1"" of type '" "XdmfGeometry *""'"); } arg1 = reinterpret_cast< XdmfGeometry * >(argp1); delete arg1; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGeometry_GetClassName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGeometry *arg1 = (XdmfGeometry *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGeometry_GetClassName",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGeometry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGeometry_GetClassName" "', argument " "1"" of type '" "XdmfGeometry *""'"); } arg1 = reinterpret_cast< XdmfGeometry * >(argp1); result = (XdmfConstString)(arg1)->GetClassName(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGeometry_SetNumberOfPoints(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGeometry *arg1 = (XdmfGeometry *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfGeometry_SetNumberOfPoints",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGeometry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGeometry_SetNumberOfPoints" "', argument " "1"" of type '" "XdmfGeometry *""'"); } arg1 = reinterpret_cast< XdmfGeometry * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfGeometry_SetNumberOfPoints" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfInt32)(arg1)->SetNumberOfPoints(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGeometry_GetNumberOfPoints(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGeometry *arg1 = (XdmfGeometry *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt64 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGeometry_GetNumberOfPoints",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGeometry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGeometry_GetNumberOfPoints" "', argument " "1"" of type '" "XdmfGeometry *""'"); } arg1 = reinterpret_cast< XdmfGeometry * >(argp1); result = (XdmfInt64)(arg1)->GetNumberOfPoints(); resultobj = SWIG_From_long_SS_long(static_cast< long long >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGeometry_SetGeometryType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGeometry *arg1 = (XdmfGeometry *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfGeometry_SetGeometryType",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGeometry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGeometry_SetGeometryType" "', argument " "1"" of type '" "XdmfGeometry *""'"); } arg1 = reinterpret_cast< XdmfGeometry * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfGeometry_SetGeometryType" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetGeometryType(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGeometry_GetGeometryType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGeometry *arg1 = (XdmfGeometry *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGeometry_GetGeometryType",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGeometry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGeometry_GetGeometryType" "', argument " "1"" of type '" "XdmfGeometry *""'"); } arg1 = reinterpret_cast< XdmfGeometry * >(argp1); result = (XdmfInt32)(arg1)->GetGeometryType(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGeometry_SetLightDataLimit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGeometry *arg1 = (XdmfGeometry *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfGeometry_SetLightDataLimit",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGeometry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGeometry_SetLightDataLimit" "', argument " "1"" of type '" "XdmfGeometry *""'"); } arg1 = reinterpret_cast< XdmfGeometry * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfGeometry_SetLightDataLimit" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetLightDataLimit(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGeometry_GetLightDataLimit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGeometry *arg1 = (XdmfGeometry *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGeometry_GetLightDataLimit",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGeometry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGeometry_GetLightDataLimit" "', argument " "1"" of type '" "XdmfGeometry *""'"); } arg1 = reinterpret_cast< XdmfGeometry * >(argp1); result = (XdmfInt32)(arg1)->GetLightDataLimit(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGeometry_GetUnits(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGeometry *arg1 = (XdmfGeometry *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGeometry_GetUnits",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGeometry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGeometry_GetUnits" "', argument " "1"" of type '" "XdmfGeometry *""'"); } arg1 = reinterpret_cast< XdmfGeometry * >(argp1); result = (XdmfConstString)(arg1)->GetUnits(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGeometry_SetUnits(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGeometry *arg1 = (XdmfGeometry *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfGeometry_SetUnits",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGeometry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGeometry_SetUnits" "', argument " "1"" of type '" "XdmfGeometry *""'"); } arg1 = reinterpret_cast< XdmfGeometry * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfGeometry_SetUnits" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfInt32)(arg1)->SetUnits(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfGeometry_GetGeometryTypeAsString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGeometry *arg1 = (XdmfGeometry *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGeometry_GetGeometryTypeAsString",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGeometry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGeometry_GetGeometryTypeAsString" "', argument " "1"" of type '" "XdmfGeometry *""'"); } arg1 = reinterpret_cast< XdmfGeometry * >(argp1); result = (XdmfString)(arg1)->GetGeometryTypeAsString(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGeometry_SetGeometryTypeFromString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGeometry *arg1 = (XdmfGeometry *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfGeometry_SetGeometryTypeFromString",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGeometry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGeometry_SetGeometryTypeFromString" "', argument " "1"" of type '" "XdmfGeometry *""'"); } arg1 = reinterpret_cast< XdmfGeometry * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfGeometry_SetGeometryTypeFromString" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfInt32)(arg1)->SetGeometryTypeFromString(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfGeometry_Build(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGeometry *arg1 = (XdmfGeometry *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGeometry_Build",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGeometry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGeometry_Build" "', argument " "1"" of type '" "XdmfGeometry *""'"); } arg1 = reinterpret_cast< XdmfGeometry * >(argp1); result = (XdmfInt32)(arg1)->Build(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGeometry_Insert(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGeometry *arg1 = (XdmfGeometry *) 0 ; XdmfElement *arg2 = (XdmfElement *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfGeometry_Insert",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGeometry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGeometry_Insert" "', argument " "1"" of type '" "XdmfGeometry *""'"); } arg1 = reinterpret_cast< XdmfGeometry * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfGeometry_Insert" "', argument " "2"" of type '" "XdmfElement *""'"); } arg2 = reinterpret_cast< XdmfElement * >(argp2); result = (XdmfInt32)(arg1)->Insert(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGeometry_Update(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGeometry *arg1 = (XdmfGeometry *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGeometry_Update",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGeometry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGeometry_Update" "', argument " "1"" of type '" "XdmfGeometry *""'"); } arg1 = reinterpret_cast< XdmfGeometry * >(argp1); result = (XdmfInt32)(arg1)->Update(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGeometry_UpdateInformation(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGeometry *arg1 = (XdmfGeometry *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGeometry_UpdateInformation",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGeometry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGeometry_UpdateInformation" "', argument " "1"" of type '" "XdmfGeometry *""'"); } arg1 = reinterpret_cast< XdmfGeometry * >(argp1); result = (XdmfInt32)(arg1)->UpdateInformation(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGeometry_SetPoints(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGeometry *arg1 = (XdmfGeometry *) 0 ; XdmfArray *arg2 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfGeometry_SetPoints",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGeometry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGeometry_SetPoints" "', argument " "1"" of type '" "XdmfGeometry *""'"); } arg1 = reinterpret_cast< XdmfGeometry * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfGeometry_SetPoints" "', argument " "2"" of type '" "XdmfArray *""'"); } arg2 = reinterpret_cast< XdmfArray * >(argp2); result = (XdmfInt32)(arg1)->SetPoints(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGeometry_GetPoints__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGeometry *arg1 = (XdmfGeometry *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfGeometry_GetPoints",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGeometry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGeometry_GetPoints" "', argument " "1"" of type '" "XdmfGeometry *""'"); } arg1 = reinterpret_cast< XdmfGeometry * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfGeometry_GetPoints" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfArray *)(arg1)->GetPoints(arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGeometry_GetPoints__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGeometry *arg1 = (XdmfGeometry *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGeometry_GetPoints",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGeometry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGeometry_GetPoints" "', argument " "1"" of type '" "XdmfGeometry *""'"); } arg1 = reinterpret_cast< XdmfGeometry * >(argp1); result = (XdmfArray *)(arg1)->GetPoints(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGeometry_GetPoints(PyObject *self, PyObject *args) { int argc; PyObject *argv[3]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 2); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfGeometry, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfGeometry_GetPoints__SWIG_1(self, args); } } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfGeometry, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_int(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfGeometry_GetPoints__SWIG_0(self, args); } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfGeometry_GetPoints'.\n" " Possible C/C++ prototypes are:\n" " GetPoints(XdmfGeometry *,XdmfInt32)\n" " GetPoints(XdmfGeometry *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfGeometry_Release(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGeometry *arg1 = (XdmfGeometry *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGeometry_Release",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGeometry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGeometry_Release" "', argument " "1"" of type '" "XdmfGeometry *""'"); } arg1 = reinterpret_cast< XdmfGeometry * >(argp1); result = (XdmfInt32)(arg1)->Release(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGeometry_GetOrigin(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGeometry *arg1 = (XdmfGeometry *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfFloat64 *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGeometry_GetOrigin",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGeometry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGeometry_GetOrigin" "', argument " "1"" of type '" "XdmfGeometry *""'"); } arg1 = reinterpret_cast< XdmfGeometry * >(argp1); result = (XdmfFloat64 *)(arg1)->GetOrigin(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_double, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGeometry_GetOriginX(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGeometry *arg1 = (XdmfGeometry *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfFloat64 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGeometry_GetOriginX",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGeometry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGeometry_GetOriginX" "', argument " "1"" of type '" "XdmfGeometry *""'"); } arg1 = reinterpret_cast< XdmfGeometry * >(argp1); result = (XdmfFloat64)(arg1)->GetOriginX(); resultobj = SWIG_From_double(static_cast< double >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGeometry_GetOriginY(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGeometry *arg1 = (XdmfGeometry *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfFloat64 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGeometry_GetOriginY",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGeometry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGeometry_GetOriginY" "', argument " "1"" of type '" "XdmfGeometry *""'"); } arg1 = reinterpret_cast< XdmfGeometry * >(argp1); result = (XdmfFloat64)(arg1)->GetOriginY(); resultobj = SWIG_From_double(static_cast< double >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGeometry_GetOriginZ(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGeometry *arg1 = (XdmfGeometry *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfFloat64 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGeometry_GetOriginZ",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGeometry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGeometry_GetOriginZ" "', argument " "1"" of type '" "XdmfGeometry *""'"); } arg1 = reinterpret_cast< XdmfGeometry * >(argp1); result = (XdmfFloat64)(arg1)->GetOriginZ(); resultobj = SWIG_From_double(static_cast< double >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGeometry_SetOrigin(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGeometry *arg1 = (XdmfGeometry *) 0 ; XdmfFloat64 arg2 ; XdmfFloat64 arg3 ; XdmfFloat64 arg4 ; void *argp1 = 0 ; int res1 = 0 ; double val2 ; int ecode2 = 0 ; double val3 ; int ecode3 = 0 ; double val4 ; int ecode4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOO:XdmfGeometry_SetOrigin",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGeometry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGeometry_SetOrigin" "', argument " "1"" of type '" "XdmfGeometry *""'"); } arg1 = reinterpret_cast< XdmfGeometry * >(argp1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfGeometry_SetOrigin" "', argument " "2"" of type '" "XdmfFloat64""'"); } arg2 = static_cast< XdmfFloat64 >(val2); ecode3 = SWIG_AsVal_double(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "XdmfGeometry_SetOrigin" "', argument " "3"" of type '" "XdmfFloat64""'"); } arg3 = static_cast< XdmfFloat64 >(val3); ecode4 = SWIG_AsVal_double(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfGeometry_SetOrigin" "', argument " "4"" of type '" "XdmfFloat64""'"); } arg4 = static_cast< XdmfFloat64 >(val4); result = (XdmfInt32)(arg1)->SetOrigin(arg2,arg3,arg4); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGeometry_SetDxDyDz(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGeometry *arg1 = (XdmfGeometry *) 0 ; XdmfFloat64 arg2 ; XdmfFloat64 arg3 ; XdmfFloat64 arg4 ; void *argp1 = 0 ; int res1 = 0 ; double val2 ; int ecode2 = 0 ; double val3 ; int ecode3 = 0 ; double val4 ; int ecode4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOO:XdmfGeometry_SetDxDyDz",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGeometry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGeometry_SetDxDyDz" "', argument " "1"" of type '" "XdmfGeometry *""'"); } arg1 = reinterpret_cast< XdmfGeometry * >(argp1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfGeometry_SetDxDyDz" "', argument " "2"" of type '" "XdmfFloat64""'"); } arg2 = static_cast< XdmfFloat64 >(val2); ecode3 = SWIG_AsVal_double(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "XdmfGeometry_SetDxDyDz" "', argument " "3"" of type '" "XdmfFloat64""'"); } arg3 = static_cast< XdmfFloat64 >(val3); ecode4 = SWIG_AsVal_double(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfGeometry_SetDxDyDz" "', argument " "4"" of type '" "XdmfFloat64""'"); } arg4 = static_cast< XdmfFloat64 >(val4); result = (XdmfInt32)(arg1)->SetDxDyDz(arg2,arg3,arg4); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGeometry_GetDx(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGeometry *arg1 = (XdmfGeometry *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfFloat64 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGeometry_GetDx",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGeometry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGeometry_GetDx" "', argument " "1"" of type '" "XdmfGeometry *""'"); } arg1 = reinterpret_cast< XdmfGeometry * >(argp1); result = (XdmfFloat64)(arg1)->GetDx(); resultobj = SWIG_From_double(static_cast< double >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGeometry_GetDy(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGeometry *arg1 = (XdmfGeometry *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfFloat64 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGeometry_GetDy",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGeometry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGeometry_GetDy" "', argument " "1"" of type '" "XdmfGeometry *""'"); } arg1 = reinterpret_cast< XdmfGeometry * >(argp1); result = (XdmfFloat64)(arg1)->GetDy(); resultobj = SWIG_From_double(static_cast< double >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGeometry_GetDz(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGeometry *arg1 = (XdmfGeometry *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfFloat64 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGeometry_GetDz",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGeometry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGeometry_GetDz" "', argument " "1"" of type '" "XdmfGeometry *""'"); } arg1 = reinterpret_cast< XdmfGeometry * >(argp1); result = (XdmfFloat64)(arg1)->GetDz(); resultobj = SWIG_From_double(static_cast< double >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGeometry_GetDxDyDz(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGeometry *arg1 = (XdmfGeometry *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfFloat64 *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGeometry_GetDxDyDz",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGeometry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGeometry_GetDxDyDz" "', argument " "1"" of type '" "XdmfGeometry *""'"); } arg1 = reinterpret_cast< XdmfGeometry * >(argp1); result = (XdmfFloat64 *)(arg1)->GetDxDyDz(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_double, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGeometry_GetVectorX(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGeometry *arg1 = (XdmfGeometry *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGeometry_GetVectorX",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGeometry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGeometry_GetVectorX" "', argument " "1"" of type '" "XdmfGeometry *""'"); } arg1 = reinterpret_cast< XdmfGeometry * >(argp1); result = (XdmfArray *)(arg1)->GetVectorX(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGeometry_GetVectorY(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGeometry *arg1 = (XdmfGeometry *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGeometry_GetVectorY",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGeometry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGeometry_GetVectorY" "', argument " "1"" of type '" "XdmfGeometry *""'"); } arg1 = reinterpret_cast< XdmfGeometry * >(argp1); result = (XdmfArray *)(arg1)->GetVectorY(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGeometry_GetVectorZ(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGeometry *arg1 = (XdmfGeometry *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGeometry_GetVectorZ",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGeometry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGeometry_GetVectorZ" "', argument " "1"" of type '" "XdmfGeometry *""'"); } arg1 = reinterpret_cast< XdmfGeometry * >(argp1); result = (XdmfArray *)(arg1)->GetVectorZ(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGeometry_SetVectorX(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGeometry *arg1 = (XdmfGeometry *) 0 ; XdmfArray *arg2 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfGeometry_SetVectorX",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGeometry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGeometry_SetVectorX" "', argument " "1"" of type '" "XdmfGeometry *""'"); } arg1 = reinterpret_cast< XdmfGeometry * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfGeometry_SetVectorX" "', argument " "2"" of type '" "XdmfArray *""'"); } arg2 = reinterpret_cast< XdmfArray * >(argp2); (arg1)->SetVectorX(arg2); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGeometry_SetVectorY(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGeometry *arg1 = (XdmfGeometry *) 0 ; XdmfArray *arg2 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfGeometry_SetVectorY",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGeometry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGeometry_SetVectorY" "', argument " "1"" of type '" "XdmfGeometry *""'"); } arg1 = reinterpret_cast< XdmfGeometry * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfGeometry_SetVectorY" "', argument " "2"" of type '" "XdmfArray *""'"); } arg2 = reinterpret_cast< XdmfArray * >(argp2); (arg1)->SetVectorY(arg2); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGeometry_SetVectorZ(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGeometry *arg1 = (XdmfGeometry *) 0 ; XdmfArray *arg2 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfGeometry_SetVectorZ",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGeometry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGeometry_SetVectorZ" "', argument " "1"" of type '" "XdmfGeometry *""'"); } arg1 = reinterpret_cast< XdmfGeometry * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfGeometry_SetVectorZ" "', argument " "2"" of type '" "XdmfArray *""'"); } arg2 = reinterpret_cast< XdmfArray * >(argp2); (arg1)->SetVectorZ(arg2); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGeometry_HasData(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGeometry *arg1 = (XdmfGeometry *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGeometry_HasData",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGeometry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGeometry_HasData" "', argument " "1"" of type '" "XdmfGeometry *""'"); } arg1 = reinterpret_cast< XdmfGeometry * >(argp1); result = (XdmfInt32)(arg1)->HasData(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *XdmfGeometry_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; SWIG_TypeNewClientData(SWIGTYPE_p_XdmfGeometry, SWIG_NewClientData(obj)); return SWIG_Py_Void(); } SWIGINTERN PyObject *_wrap_GetXdmfGeometryHandle(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; void *arg1 = (void *) 0 ; int res1 ; PyObject * obj0 = 0 ; XdmfGeometry *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:GetXdmfGeometryHandle",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0,SWIG_as_voidptrptr(&arg1), 0, 0); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GetXdmfGeometryHandle" "', argument " "1"" of type '" "void *""'"); } result = (XdmfGeometry *)GetXdmfGeometryHandle(arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfGeometry, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_new_XdmfGrid(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *result = 0 ; if (!PyArg_ParseTuple(args,(char *)":new_XdmfGrid")) SWIG_fail; result = (XdmfGrid *)new XdmfGrid(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfGrid, SWIG_POINTER_NEW | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_delete_XdmfGrid(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:delete_XdmfGrid",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_XdmfGrid" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); delete arg1; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_GetClassName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGrid_GetClassName",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_GetClassName" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); result = (XdmfConstString)(arg1)->GetClassName(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_SetGeometry(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; XdmfGeometry *arg2 = (XdmfGeometry *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfGrid_SetGeometry",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_SetGeometry" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfGeometry, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfGrid_SetGeometry" "', argument " "2"" of type '" "XdmfGeometry *""'"); } arg2 = reinterpret_cast< XdmfGeometry * >(argp2); result = (XdmfInt32)(arg1)->SetGeometry(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_GetGeometry(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfGeometry *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGrid_GetGeometry",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_GetGeometry" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); result = (XdmfGeometry *)(arg1)->GetGeometry(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfGeometry, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_SetTopology(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; XdmfTopology *arg2 = (XdmfTopology *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfGrid_SetTopology",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_SetTopology" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfTopology, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfGrid_SetTopology" "', argument " "2"" of type '" "XdmfTopology *""'"); } arg2 = reinterpret_cast< XdmfTopology * >(argp2); result = (XdmfInt32)(arg1)->SetTopology(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_GetTopology(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfTopology *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGrid_GetTopology",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_GetTopology" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); result = (XdmfTopology *)(arg1)->GetTopology(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfTopology, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_SetTime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; XdmfTime *arg2 = (XdmfTime *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfGrid_SetTime",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_SetTime" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfTime, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfGrid_SetTime" "', argument " "2"" of type '" "XdmfTime *""'"); } arg2 = reinterpret_cast< XdmfTime * >(argp2); result = (XdmfInt32)(arg1)->SetTime(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_GetTime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfTime *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGrid_GetTime",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_GetTime" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); result = (XdmfTime *)(arg1)->GetTime(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfTime, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_GetGridTypeAsString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGrid_GetGridTypeAsString",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_GetGridTypeAsString" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); result = (XdmfConstString)(arg1)->GetGridTypeAsString(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_SetGridTypeFromString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfGrid_SetGridTypeFromString",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_SetGridTypeFromString" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfGrid_SetGridTypeFromString" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfInt32)(arg1)->SetGridTypeFromString(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_GetCollectionTypeAsString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGrid_GetCollectionTypeAsString",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_GetCollectionTypeAsString" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); result = (XdmfConstString)(arg1)->GetCollectionTypeAsString(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_SetCollectionTypeFromString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfGrid_SetCollectionTypeFromString",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_SetCollectionTypeFromString" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfGrid_SetCollectionTypeFromString" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfInt32)(arg1)->SetCollectionTypeFromString(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_Build(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGrid_Build",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_Build" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); result = (XdmfInt32)(arg1)->Build(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_InsertTopology(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGrid_InsertTopology",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_InsertTopology" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); result = (XdmfInt32)(arg1)->InsertTopology(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_InsertGeometry(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGrid_InsertGeometry",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_InsertGeometry" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); result = (XdmfInt32)(arg1)->InsertGeometry(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_Insert(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; XdmfElement *arg2 = (XdmfElement *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfGrid_Insert",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_Insert" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfGrid_Insert" "', argument " "2"" of type '" "XdmfElement *""'"); } arg2 = reinterpret_cast< XdmfElement * >(argp2); result = (XdmfInt32)(arg1)->Insert(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_GetGridType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGrid_GetGridType",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_GetGridType" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); result = (XdmfInt32)(arg1)->GetGridType(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_SetGridType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfGrid_SetGridType",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_SetGridType" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfGrid_SetGridType" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetGridType(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_GetCollectionType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGrid_GetCollectionType",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_GetCollectionType" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); result = (XdmfInt32)(arg1)->GetCollectionType(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_SetCollectionType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfGrid_SetCollectionType",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_SetCollectionType" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfGrid_SetCollectionType" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetCollectionType(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_GetBuildTime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGrid_GetBuildTime",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_GetBuildTime" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); result = (XdmfInt32)(arg1)->GetBuildTime(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_SetBuildTime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfGrid_SetBuildTime",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_SetBuildTime" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfGrid_SetBuildTime" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetBuildTime(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_Copy(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; XdmfElement *arg2 = (XdmfElement *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfGrid_Copy",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_Copy" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfGrid_Copy" "', argument " "2"" of type '" "XdmfElement *""'"); } arg2 = reinterpret_cast< XdmfElement * >(argp2); result = (XdmfInt32)(arg1)->Copy(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_GetNumberOfChildren(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGrid_GetNumberOfChildren",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_GetNumberOfChildren" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); result = (XdmfInt32)(arg1)->GetNumberOfChildren(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_SetNumberOfChildren(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfGrid_SetNumberOfChildren",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_SetNumberOfChildren" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfGrid_SetNumberOfChildren" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetNumberOfChildren(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_IsUniform(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGrid_IsUniform",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_IsUniform" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); result = (XdmfInt32)(arg1)->IsUniform(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_GetNumberOfAttributes(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGrid_GetNumberOfAttributes",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_GetNumberOfAttributes" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); result = (XdmfInt32)(arg1)->GetNumberOfAttributes(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_GetNumberOfSets(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGrid_GetNumberOfSets",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_GetNumberOfSets" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); result = (XdmfInt32)(arg1)->GetNumberOfSets(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_GetNumberOfInformations(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGrid_GetNumberOfInformations",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_GetNumberOfInformations" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); result = (XdmfInt32)(arg1)->GetNumberOfInformations(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_GetAttribute(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfAttribute *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfGrid_GetAttribute",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_GetAttribute" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfGrid_GetAttribute" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfAttribute *)(arg1)->GetAttribute(arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfAttribute, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_GetSets(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfSet *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfGrid_GetSets",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_GetSets" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfGrid_GetSets" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfSet *)(arg1)->GetSets(arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfSet, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_AssignAttribute(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfGrid_AssignAttribute",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_AssignAttribute" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfGrid_AssignAttribute" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfInt32)(arg1)->AssignAttribute(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_AssignAttributeByIndex(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfGrid_AssignAttributeByIndex",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_AssignAttributeByIndex" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfGrid_AssignAttributeByIndex" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfInt32)(arg1)->AssignAttributeByIndex(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_AssignAttributeByName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; XdmfString arg2 = (XdmfString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfGrid_AssignAttributeByName",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_AssignAttributeByName" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfGrid_AssignAttributeByName" "', argument " "2"" of type '" "XdmfString""'"); } arg2 = reinterpret_cast< XdmfString >(buf2); result = (XdmfInt32)(arg1)->AssignAttributeByName(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_GetAssignedAttribute(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfAttribute *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGrid_GetAssignedAttribute",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_GetAssignedAttribute" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); result = (XdmfAttribute *)(arg1)->GetAssignedAttribute(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfAttribute, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_GetAssignedAttributeIndex(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt64 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGrid_GetAssignedAttributeIndex",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_GetAssignedAttributeIndex" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); result = (XdmfInt64)(arg1)->GetAssignedAttributeIndex(); resultobj = SWIG_From_long_SS_long(static_cast< long long >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_UpdateInformation(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGrid_UpdateInformation",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_UpdateInformation" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); result = (XdmfInt32)(arg1)->UpdateInformation(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_Update(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGrid_Update",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_Update" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); result = (XdmfInt32)(arg1)->Update(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_GetChild(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfGrid *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfGrid_GetChild",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_GetChild" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfGrid_GetChild" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfGrid *)(arg1)->GetChild(arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfGrid, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_GetInformation(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInformation *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfGrid_GetInformation",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_GetInformation" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfGrid_GetInformation" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInformation *)(arg1)->GetInformation(arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfInformation, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_FindGridsInTimeRange(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; XdmfFloat64 arg2 ; XdmfFloat64 arg3 ; XdmfArray *arg4 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; double val2 ; int ecode2 = 0 ; double val3 ; int ecode3 = 0 ; void *argp4 = 0 ; int res4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOO:XdmfGrid_FindGridsInTimeRange",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_FindGridsInTimeRange" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfGrid_FindGridsInTimeRange" "', argument " "2"" of type '" "XdmfFloat64""'"); } arg2 = static_cast< XdmfFloat64 >(val2); ecode3 = SWIG_AsVal_double(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "XdmfGrid_FindGridsInTimeRange" "', argument " "3"" of type '" "XdmfFloat64""'"); } arg3 = static_cast< XdmfFloat64 >(val3); res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "XdmfGrid_FindGridsInTimeRange" "', argument " "4"" of type '" "XdmfArray *""'"); } arg4 = reinterpret_cast< XdmfArray * >(argp4); result = (XdmfInt32)(arg1)->FindGridsInTimeRange(arg2,arg3,arg4); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_FindGridsAtTime__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; XdmfTime *arg2 = (XdmfTime *) 0 ; XdmfArray *arg3 = (XdmfArray *) 0 ; XdmfFloat64 arg4 ; XdmfInt32 arg5 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; double val4 ; int ecode4 = 0 ; int val5 ; int ecode5 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOOO:XdmfGrid_FindGridsAtTime",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_FindGridsAtTime" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfTime, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfGrid_FindGridsAtTime" "', argument " "2"" of type '" "XdmfTime *""'"); } arg2 = reinterpret_cast< XdmfTime * >(argp2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfGrid_FindGridsAtTime" "', argument " "3"" of type '" "XdmfArray *""'"); } arg3 = reinterpret_cast< XdmfArray * >(argp3); ecode4 = SWIG_AsVal_double(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfGrid_FindGridsAtTime" "', argument " "4"" of type '" "XdmfFloat64""'"); } arg4 = static_cast< XdmfFloat64 >(val4); ecode5 = SWIG_AsVal_int(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "XdmfGrid_FindGridsAtTime" "', argument " "5"" of type '" "XdmfInt32""'"); } arg5 = static_cast< XdmfInt32 >(val5); result = (XdmfInt32)(arg1)->FindGridsAtTime(arg2,arg3,arg4,arg5); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_FindGridsAtTime__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; XdmfTime *arg2 = (XdmfTime *) 0 ; XdmfArray *arg3 = (XdmfArray *) 0 ; XdmfFloat64 arg4 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; double val4 ; int ecode4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOO:XdmfGrid_FindGridsAtTime",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_FindGridsAtTime" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfTime, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfGrid_FindGridsAtTime" "', argument " "2"" of type '" "XdmfTime *""'"); } arg2 = reinterpret_cast< XdmfTime * >(argp2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfGrid_FindGridsAtTime" "', argument " "3"" of type '" "XdmfArray *""'"); } arg3 = reinterpret_cast< XdmfArray * >(argp3); ecode4 = SWIG_AsVal_double(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfGrid_FindGridsAtTime" "', argument " "4"" of type '" "XdmfFloat64""'"); } arg4 = static_cast< XdmfFloat64 >(val4); result = (XdmfInt32)(arg1)->FindGridsAtTime(arg2,arg3,arg4); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_FindGridsAtTime__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; XdmfTime *arg2 = (XdmfTime *) 0 ; XdmfArray *arg3 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfGrid_FindGridsAtTime",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_FindGridsAtTime" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfTime, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfGrid_FindGridsAtTime" "', argument " "2"" of type '" "XdmfTime *""'"); } arg2 = reinterpret_cast< XdmfTime * >(argp2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfGrid_FindGridsAtTime" "', argument " "3"" of type '" "XdmfArray *""'"); } arg3 = reinterpret_cast< XdmfArray * >(argp3); result = (XdmfInt32)(arg1)->FindGridsAtTime(arg2,arg3); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_FindGridsAtTime(PyObject *self, PyObject *args) { int argc; PyObject *argv[6]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 5); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 3) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfGrid, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_XdmfTime, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfGrid_FindGridsAtTime__SWIG_2(self, args); } } } } if (argc == 4) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfGrid, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_XdmfTime, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_double(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfGrid_FindGridsAtTime__SWIG_1(self, args); } } } } } if (argc == 5) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfGrid, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_XdmfTime, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_double(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_int(argv[4], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfGrid_FindGridsAtTime__SWIG_0(self, args); } } } } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfGrid_FindGridsAtTime'.\n" " Possible C/C++ prototypes are:\n" " FindGridsAtTime(XdmfGrid *,XdmfTime *,XdmfArray *,XdmfFloat64,XdmfInt32)\n" " FindGridsAtTime(XdmfGrid *,XdmfTime *,XdmfArray *,XdmfFloat64)\n" " FindGridsAtTime(XdmfGrid *,XdmfTime *,XdmfArray *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfGrid_Release(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfGrid *arg1 = (XdmfGrid *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfGrid_Release",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_Release" "', argument " "1"" of type '" "XdmfGrid *""'"); } arg1 = reinterpret_cast< XdmfGrid * >(argp1); result = (XdmfInt32)(arg1)->Release(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *XdmfGrid_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; SWIG_TypeNewClientData(SWIGTYPE_p_XdmfGrid, SWIG_NewClientData(obj)); return SWIG_Py_Void(); } SWIGINTERN PyObject *_wrap_HandleToXdmfGrid(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfString arg1 = (XdmfString) 0 ; int res1 ; char *buf1 = 0 ; int alloc1 = 0 ; PyObject * obj0 = 0 ; XdmfGrid *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:HandleToXdmfGrid",&obj0)) SWIG_fail; res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "HandleToXdmfGrid" "', argument " "1"" of type '" "XdmfString""'"); } arg1 = reinterpret_cast< XdmfString >(buf1); result = (XdmfGrid *)HandleToXdmfGrid(arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (alloc1 == SWIG_NEWOBJ) delete[] buf1; return resultobj; fail: if (alloc1 == SWIG_NEWOBJ) delete[] buf1; return NULL; } SWIGINTERN PyObject *_wrap_new_XdmfTime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTime *result = 0 ; if (!PyArg_ParseTuple(args,(char *)":new_XdmfTime")) SWIG_fail; result = (XdmfTime *)new XdmfTime(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfTime, SWIG_POINTER_NEW | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_delete_XdmfTime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTime *arg1 = (XdmfTime *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:delete_XdmfTime",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTime, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_XdmfTime" "', argument " "1"" of type '" "XdmfTime *""'"); } arg1 = reinterpret_cast< XdmfTime * >(argp1); delete arg1; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTime_GetClassName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTime *arg1 = (XdmfTime *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfTime_GetClassName",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTime, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTime_GetClassName" "', argument " "1"" of type '" "XdmfTime *""'"); } arg1 = reinterpret_cast< XdmfTime * >(argp1); result = (XdmfConstString)(arg1)->GetClassName(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTime_Insert(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTime *arg1 = (XdmfTime *) 0 ; XdmfElement *arg2 = (XdmfElement *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfTime_Insert",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTime, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTime_Insert" "', argument " "1"" of type '" "XdmfTime *""'"); } arg1 = reinterpret_cast< XdmfTime * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfTime_Insert" "', argument " "2"" of type '" "XdmfElement *""'"); } arg2 = reinterpret_cast< XdmfElement * >(argp2); result = (XdmfInt32)(arg1)->Insert(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTime_UpdateInformation(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTime *arg1 = (XdmfTime *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfTime_UpdateInformation",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTime, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTime_UpdateInformation" "', argument " "1"" of type '" "XdmfTime *""'"); } arg1 = reinterpret_cast< XdmfTime * >(argp1); result = (XdmfInt32)(arg1)->UpdateInformation(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTime_SetValue(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTime *arg1 = (XdmfTime *) 0 ; XdmfFloat64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; double val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfTime_SetValue",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTime, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTime_SetValue" "', argument " "1"" of type '" "XdmfTime *""'"); } arg1 = reinterpret_cast< XdmfTime * >(argp1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfTime_SetValue" "', argument " "2"" of type '" "XdmfFloat64""'"); } arg2 = static_cast< XdmfFloat64 >(val2); result = (XdmfInt32)(arg1)->SetValue(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTime_Build(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTime *arg1 = (XdmfTime *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfTime_Build",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTime, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTime_Build" "', argument " "1"" of type '" "XdmfTime *""'"); } arg1 = reinterpret_cast< XdmfTime * >(argp1); result = (XdmfInt32)(arg1)->Build(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTime_GetValue(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTime *arg1 = (XdmfTime *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfFloat64 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfTime_GetValue",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTime, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTime_GetValue" "', argument " "1"" of type '" "XdmfTime *""'"); } arg1 = reinterpret_cast< XdmfTime * >(argp1); result = (XdmfFloat64)(arg1)->GetValue(); resultobj = SWIG_From_double(static_cast< double >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTime_GetArray(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTime *arg1 = (XdmfTime *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfTime_GetArray",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTime, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTime_GetArray" "', argument " "1"" of type '" "XdmfTime *""'"); } arg1 = reinterpret_cast< XdmfTime * >(argp1); result = (XdmfArray *)(arg1)->GetArray(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTime_SetArray(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTime *arg1 = (XdmfTime *) 0 ; XdmfArray *arg2 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfTime_SetArray",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTime, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTime_SetArray" "', argument " "1"" of type '" "XdmfTime *""'"); } arg1 = reinterpret_cast< XdmfTime * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfTime_SetArray" "', argument " "2"" of type '" "XdmfArray *""'"); } arg2 = reinterpret_cast< XdmfArray * >(argp2); result = (XdmfInt32)(arg1)->SetArray(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTime_GetDataItem(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTime *arg1 = (XdmfTime *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfDataItem *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfTime_GetDataItem",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTime, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTime_GetDataItem" "', argument " "1"" of type '" "XdmfTime *""'"); } arg1 = reinterpret_cast< XdmfTime * >(argp1); result = (XdmfDataItem *)(arg1)->GetDataItem(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfDataItem, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTime_SetDataItem(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTime *arg1 = (XdmfTime *) 0 ; XdmfDataItem *arg2 = (XdmfDataItem *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfTime_SetDataItem",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTime, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTime_SetDataItem" "', argument " "1"" of type '" "XdmfTime *""'"); } arg1 = reinterpret_cast< XdmfTime * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfDataItem, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfTime_SetDataItem" "', argument " "2"" of type '" "XdmfDataItem *""'"); } arg2 = reinterpret_cast< XdmfDataItem * >(argp2); result = (XdmfInt32)(arg1)->SetDataItem(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTime_GetTimeType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTime *arg1 = (XdmfTime *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfTime_GetTimeType",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTime, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTime_GetTimeType" "', argument " "1"" of type '" "XdmfTime *""'"); } arg1 = reinterpret_cast< XdmfTime * >(argp1); result = (XdmfInt32)(arg1)->GetTimeType(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTime_GetTimeTypeAsString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTime *arg1 = (XdmfTime *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfTime_GetTimeTypeAsString",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTime, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTime_GetTimeTypeAsString" "', argument " "1"" of type '" "XdmfTime *""'"); } arg1 = reinterpret_cast< XdmfTime * >(argp1); result = (XdmfConstString)(arg1)->GetTimeTypeAsString(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTime_SetTimeType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTime *arg1 = (XdmfTime *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfTime_SetTimeType",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTime, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTime_SetTimeType" "', argument " "1"" of type '" "XdmfTime *""'"); } arg1 = reinterpret_cast< XdmfTime * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfTime_SetTimeType" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetTimeType(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTime_GetFunction(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTime *arg1 = (XdmfTime *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfTime_GetFunction",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTime, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTime_GetFunction" "', argument " "1"" of type '" "XdmfTime *""'"); } arg1 = reinterpret_cast< XdmfTime * >(argp1); result = (XdmfConstString)(arg1)->GetFunction(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTime_SetFunction(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTime *arg1 = (XdmfTime *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfTime_SetFunction",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTime, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTime_SetFunction" "', argument " "1"" of type '" "XdmfTime *""'"); } arg1 = reinterpret_cast< XdmfTime * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfTime_SetFunction" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfInt32)(arg1)->SetFunction(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfTime_SetTimeFromParent(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTime *arg1 = (XdmfTime *) 0 ; XdmfTime *arg2 = (XdmfTime *) 0 ; XdmfInt64 arg3 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; long long val3 ; int ecode3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfTime_SetTimeFromParent",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTime, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTime_SetTimeFromParent" "', argument " "1"" of type '" "XdmfTime *""'"); } arg1 = reinterpret_cast< XdmfTime * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfTime, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfTime_SetTimeFromParent" "', argument " "2"" of type '" "XdmfTime *""'"); } arg2 = reinterpret_cast< XdmfTime * >(argp2); ecode3 = SWIG_AsVal_long_SS_long(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "XdmfTime_SetTimeFromParent" "', argument " "3"" of type '" "XdmfInt64""'"); } arg3 = static_cast< XdmfInt64 >(val3); result = (XdmfInt32)(arg1)->SetTimeFromParent(arg2,arg3); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTime_Evaluate__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTime *arg1 = (XdmfTime *) 0 ; XdmfGrid *arg2 = (XdmfGrid *) 0 ; XdmfArray *arg3 = (XdmfArray *) 0 ; XdmfInt32 arg4 ; XdmfInt32 arg5 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; int val4 ; int ecode4 = 0 ; int val5 ; int ecode5 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOOO:XdmfTime_Evaluate",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTime, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTime_Evaluate" "', argument " "1"" of type '" "XdmfTime *""'"); } arg1 = reinterpret_cast< XdmfTime * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfTime_Evaluate" "', argument " "2"" of type '" "XdmfGrid *""'"); } arg2 = reinterpret_cast< XdmfGrid * >(argp2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfTime_Evaluate" "', argument " "3"" of type '" "XdmfArray *""'"); } arg3 = reinterpret_cast< XdmfArray * >(argp3); ecode4 = SWIG_AsVal_int(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfTime_Evaluate" "', argument " "4"" of type '" "XdmfInt32""'"); } arg4 = static_cast< XdmfInt32 >(val4); ecode5 = SWIG_AsVal_int(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "XdmfTime_Evaluate" "', argument " "5"" of type '" "XdmfInt32""'"); } arg5 = static_cast< XdmfInt32 >(val5); result = (XdmfInt32)(arg1)->Evaluate(arg2,arg3,arg4,arg5); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTime_Evaluate__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTime *arg1 = (XdmfTime *) 0 ; XdmfGrid *arg2 = (XdmfGrid *) 0 ; XdmfArray *arg3 = (XdmfArray *) 0 ; XdmfInt32 arg4 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; int val4 ; int ecode4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOO:XdmfTime_Evaluate",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTime, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTime_Evaluate" "', argument " "1"" of type '" "XdmfTime *""'"); } arg1 = reinterpret_cast< XdmfTime * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfTime_Evaluate" "', argument " "2"" of type '" "XdmfGrid *""'"); } arg2 = reinterpret_cast< XdmfGrid * >(argp2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfTime_Evaluate" "', argument " "3"" of type '" "XdmfArray *""'"); } arg3 = reinterpret_cast< XdmfArray * >(argp3); ecode4 = SWIG_AsVal_int(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfTime_Evaluate" "', argument " "4"" of type '" "XdmfInt32""'"); } arg4 = static_cast< XdmfInt32 >(val4); result = (XdmfInt32)(arg1)->Evaluate(arg2,arg3,arg4); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTime_Evaluate__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTime *arg1 = (XdmfTime *) 0 ; XdmfGrid *arg2 = (XdmfGrid *) 0 ; XdmfArray *arg3 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfTime_Evaluate",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTime, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTime_Evaluate" "', argument " "1"" of type '" "XdmfTime *""'"); } arg1 = reinterpret_cast< XdmfTime * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfTime_Evaluate" "', argument " "2"" of type '" "XdmfGrid *""'"); } arg2 = reinterpret_cast< XdmfGrid * >(argp2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfTime_Evaluate" "', argument " "3"" of type '" "XdmfArray *""'"); } arg3 = reinterpret_cast< XdmfArray * >(argp3); result = (XdmfInt32)(arg1)->Evaluate(arg2,arg3); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTime_Evaluate__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTime *arg1 = (XdmfTime *) 0 ; XdmfGrid *arg2 = (XdmfGrid *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfTime_Evaluate",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTime, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTime_Evaluate" "', argument " "1"" of type '" "XdmfTime *""'"); } arg1 = reinterpret_cast< XdmfTime * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfGrid, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfTime_Evaluate" "', argument " "2"" of type '" "XdmfGrid *""'"); } arg2 = reinterpret_cast< XdmfGrid * >(argp2); result = (XdmfInt32)(arg1)->Evaluate(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTime_Evaluate(PyObject *self, PyObject *args) { int argc; PyObject *argv[6]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 5); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfTime, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_XdmfGrid, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfTime_Evaluate__SWIG_3(self, args); } } } if (argc == 3) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfTime, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_XdmfGrid, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfTime_Evaluate__SWIG_2(self, args); } } } } if (argc == 4) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfTime, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_XdmfGrid, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_int(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfTime_Evaluate__SWIG_1(self, args); } } } } } if (argc == 5) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfTime, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_XdmfGrid, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_XdmfArray, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_int(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_int(argv[4], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfTime_Evaluate__SWIG_0(self, args); } } } } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfTime_Evaluate'.\n" " Possible C/C++ prototypes are:\n" " Evaluate(XdmfTime *,XdmfGrid *,XdmfArray *,XdmfInt32,XdmfInt32)\n" " Evaluate(XdmfTime *,XdmfGrid *,XdmfArray *,XdmfInt32)\n" " Evaluate(XdmfTime *,XdmfGrid *,XdmfArray *)\n" " Evaluate(XdmfTime *,XdmfGrid *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfTime_IsValid__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTime *arg1 = (XdmfTime *) 0 ; XdmfTime *arg2 = (XdmfTime *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfTime_IsValid",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTime, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTime_IsValid" "', argument " "1"" of type '" "XdmfTime *""'"); } arg1 = reinterpret_cast< XdmfTime * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfTime, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfTime_IsValid" "', argument " "2"" of type '" "XdmfTime *""'"); } arg2 = reinterpret_cast< XdmfTime * >(argp2); result = (XdmfInt32)(arg1)->IsValid(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTime_IsValid__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTime *arg1 = (XdmfTime *) 0 ; XdmfFloat64 arg2 ; XdmfFloat64 arg3 ; void *argp1 = 0 ; int res1 = 0 ; double val2 ; int ecode2 = 0 ; double val3 ; int ecode3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfTime_IsValid",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTime, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTime_IsValid" "', argument " "1"" of type '" "XdmfTime *""'"); } arg1 = reinterpret_cast< XdmfTime * >(argp1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfTime_IsValid" "', argument " "2"" of type '" "XdmfFloat64""'"); } arg2 = static_cast< XdmfFloat64 >(val2); ecode3 = SWIG_AsVal_double(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "XdmfTime_IsValid" "', argument " "3"" of type '" "XdmfFloat64""'"); } arg3 = static_cast< XdmfFloat64 >(val3); result = (XdmfInt32)(arg1)->IsValid(arg2,arg3); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTime_IsValid(PyObject *self, PyObject *args) { int argc; PyObject *argv[4]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 3); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfTime, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_XdmfTime, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfTime_IsValid__SWIG_0(self, args); } } } if (argc == 3) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfTime, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_double(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_double(argv[2], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfTime_IsValid__SWIG_1(self, args); } } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfTime_IsValid'.\n" " Possible C/C++ prototypes are:\n" " IsValid(XdmfTime *,XdmfTime *)\n" " IsValid(XdmfTime *,XdmfFloat64,XdmfFloat64)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfTime_SetEpsilon(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTime *arg1 = (XdmfTime *) 0 ; XdmfFloat64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; double val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfTime_SetEpsilon",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTime, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTime_SetEpsilon" "', argument " "1"" of type '" "XdmfTime *""'"); } arg1 = reinterpret_cast< XdmfTime * >(argp1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfTime_SetEpsilon" "', argument " "2"" of type '" "XdmfFloat64""'"); } arg2 = static_cast< XdmfFloat64 >(val2); result = (XdmfInt32)(arg1)->SetEpsilon(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfTime_GetEpsilon(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfTime *arg1 = (XdmfTime *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfFloat64 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfTime_GetEpsilon",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTime, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTime_GetEpsilon" "', argument " "1"" of type '" "XdmfTime *""'"); } arg1 = reinterpret_cast< XdmfTime * >(argp1); result = (XdmfFloat64)(arg1)->GetEpsilon(); resultobj = SWIG_From_double(static_cast< double >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *XdmfTime_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; SWIG_TypeNewClientData(SWIGTYPE_p_XdmfTime, SWIG_NewClientData(obj)); return SWIG_Py_Void(); } SWIGINTERN PyObject *_wrap_new_XdmfRegion(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfRegion *result = 0 ; if (!PyArg_ParseTuple(args,(char *)":new_XdmfRegion")) SWIG_fail; result = (XdmfRegion *)new XdmfRegion(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfRegion, SWIG_POINTER_NEW | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_delete_XdmfRegion(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfRegion *arg1 = (XdmfRegion *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:delete_XdmfRegion",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfRegion, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_XdmfRegion" "', argument " "1"" of type '" "XdmfRegion *""'"); } arg1 = reinterpret_cast< XdmfRegion * >(argp1); delete arg1; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfRegion_GetClassName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfRegion *arg1 = (XdmfRegion *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfRegion_GetClassName",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfRegion, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfRegion_GetClassName" "', argument " "1"" of type '" "XdmfRegion *""'"); } arg1 = reinterpret_cast< XdmfRegion * >(argp1); result = (XdmfConstString)(arg1)->GetClassName(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfRegion_SetRegionTypeFromString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfRegion *arg1 = (XdmfRegion *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfRegion_SetRegionTypeFromString",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfRegion, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfRegion_SetRegionTypeFromString" "', argument " "1"" of type '" "XdmfRegion *""'"); } arg1 = reinterpret_cast< XdmfRegion * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfRegion_SetRegionTypeFromString" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfInt32)(arg1)->SetRegionTypeFromString(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfRegion_GetRegionTypeAsString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfRegion *arg1 = (XdmfRegion *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfRegion_GetRegionTypeAsString",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfRegion, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfRegion_GetRegionTypeAsString" "', argument " "1"" of type '" "XdmfRegion *""'"); } arg1 = reinterpret_cast< XdmfRegion * >(argp1); result = (XdmfConstString)(arg1)->GetRegionTypeAsString(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfRegion_SetRegionType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfRegion *arg1 = (XdmfRegion *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfRegion_SetRegionType",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfRegion, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfRegion_SetRegionType" "', argument " "1"" of type '" "XdmfRegion *""'"); } arg1 = reinterpret_cast< XdmfRegion * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfRegion_SetRegionType" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetRegionType(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfRegion_GetRegionType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfRegion *arg1 = (XdmfRegion *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfRegion_GetRegionType",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfRegion, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfRegion_GetRegionType" "', argument " "1"" of type '" "XdmfRegion *""'"); } arg1 = reinterpret_cast< XdmfRegion * >(argp1); result = (XdmfInt32)(arg1)->GetRegionType(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfRegion_GetShapeDesc(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfRegion *arg1 = (XdmfRegion *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfDataDesc *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfRegion_GetShapeDesc",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfRegion, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfRegion_GetShapeDesc" "', argument " "1"" of type '" "XdmfRegion *""'"); } arg1 = reinterpret_cast< XdmfRegion * >(argp1); result = (XdmfDataDesc *)(arg1)->GetShapeDesc(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfRegion_Insert(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfRegion *arg1 = (XdmfRegion *) 0 ; XdmfElement *arg2 = (XdmfElement *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfRegion_Insert",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfRegion, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfRegion_Insert" "', argument " "1"" of type '" "XdmfRegion *""'"); } arg1 = reinterpret_cast< XdmfRegion * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfRegion_Insert" "', argument " "2"" of type '" "XdmfElement *""'"); } arg2 = reinterpret_cast< XdmfElement * >(argp2); result = (XdmfInt32)(arg1)->Insert(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfRegion_SetValues(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfRegion *arg1 = (XdmfRegion *) 0 ; XdmfArray *arg2 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfRegion_SetValues",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfRegion, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfRegion_SetValues" "', argument " "1"" of type '" "XdmfRegion *""'"); } arg1 = reinterpret_cast< XdmfRegion * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfRegion_SetValues" "', argument " "2"" of type '" "XdmfArray *""'"); } arg2 = reinterpret_cast< XdmfArray * >(argp2); result = (XdmfInt32)(arg1)->SetValues(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfRegion_GetValues__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfRegion *arg1 = (XdmfRegion *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfRegion_GetValues",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfRegion, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfRegion_GetValues" "', argument " "1"" of type '" "XdmfRegion *""'"); } arg1 = reinterpret_cast< XdmfRegion * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfRegion_GetValues" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfArray *)(arg1)->GetValues(arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfRegion_GetValues__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfRegion *arg1 = (XdmfRegion *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfRegion_GetValues",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfRegion, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfRegion_GetValues" "', argument " "1"" of type '" "XdmfRegion *""'"); } arg1 = reinterpret_cast< XdmfRegion * >(argp1); result = (XdmfArray *)(arg1)->GetValues(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfRegion_GetValues(PyObject *self, PyObject *args) { int argc; PyObject *argv[3]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 2); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfRegion, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfRegion_GetValues__SWIG_1(self, args); } } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfRegion, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_int(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfRegion_GetValues__SWIG_0(self, args); } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfRegion_GetValues'.\n" " Possible C/C++ prototypes are:\n" " GetValues(XdmfRegion *,XdmfInt32)\n" " GetValues(XdmfRegion *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfRegion_UpdateInformation(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfRegion *arg1 = (XdmfRegion *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfRegion_UpdateInformation",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfRegion, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfRegion_UpdateInformation" "', argument " "1"" of type '" "XdmfRegion *""'"); } arg1 = reinterpret_cast< XdmfRegion * >(argp1); result = (XdmfInt32)(arg1)->UpdateInformation(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfRegion_Update(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfRegion *arg1 = (XdmfRegion *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfRegion_Update",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfRegion, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfRegion_Update" "', argument " "1"" of type '" "XdmfRegion *""'"); } arg1 = reinterpret_cast< XdmfRegion * >(argp1); result = (XdmfInt32)(arg1)->Update(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfRegion_Build(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfRegion *arg1 = (XdmfRegion *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfRegion_Build",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfRegion, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfRegion_Build" "', argument " "1"" of type '" "XdmfRegion *""'"); } arg1 = reinterpret_cast< XdmfRegion * >(argp1); result = (XdmfInt32)(arg1)->Build(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfRegion_Release(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfRegion *arg1 = (XdmfRegion *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfRegion_Release",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfRegion, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfRegion_Release" "', argument " "1"" of type '" "XdmfRegion *""'"); } arg1 = reinterpret_cast< XdmfRegion * >(argp1); result = (XdmfInt32)(arg1)->Release(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *XdmfRegion_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; SWIG_TypeNewClientData(SWIGTYPE_p_XdmfRegion, SWIG_NewClientData(obj)); return SWIG_Py_Void(); } SWIGINTERN PyObject *_wrap_new_XdmfSet(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfSet *result = 0 ; if (!PyArg_ParseTuple(args,(char *)":new_XdmfSet")) SWIG_fail; result = (XdmfSet *)new XdmfSet(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfSet, SWIG_POINTER_NEW | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_delete_XdmfSet(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfSet *arg1 = (XdmfSet *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:delete_XdmfSet",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfSet, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_XdmfSet" "', argument " "1"" of type '" "XdmfSet *""'"); } arg1 = reinterpret_cast< XdmfSet * >(argp1); delete arg1; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfSet_GetClassName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfSet *arg1 = (XdmfSet *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfSet_GetClassName",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfSet, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfSet_GetClassName" "', argument " "1"" of type '" "XdmfSet *""'"); } arg1 = reinterpret_cast< XdmfSet * >(argp1); result = (XdmfConstString)(arg1)->GetClassName(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfSet_SetSetTypeFromString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfSet *arg1 = (XdmfSet *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfSet_SetSetTypeFromString",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfSet, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfSet_SetSetTypeFromString" "', argument " "1"" of type '" "XdmfSet *""'"); } arg1 = reinterpret_cast< XdmfSet * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfSet_SetSetTypeFromString" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfInt32)(arg1)->SetSetTypeFromString(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfSet_GetSetTypeAsString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfSet *arg1 = (XdmfSet *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfSet_GetSetTypeAsString",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfSet, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfSet_GetSetTypeAsString" "', argument " "1"" of type '" "XdmfSet *""'"); } arg1 = reinterpret_cast< XdmfSet * >(argp1); result = (XdmfConstString)(arg1)->GetSetTypeAsString(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfSet_SetSetType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfSet *arg1 = (XdmfSet *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfSet_SetSetType",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfSet, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfSet_SetSetType" "', argument " "1"" of type '" "XdmfSet *""'"); } arg1 = reinterpret_cast< XdmfSet * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfSet_SetSetType" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetSetType(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfSet_GetSetType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfSet *arg1 = (XdmfSet *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfSet_GetSetType",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfSet, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfSet_GetSetType" "', argument " "1"" of type '" "XdmfSet *""'"); } arg1 = reinterpret_cast< XdmfSet * >(argp1); result = (XdmfInt32)(arg1)->GetSetType(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfSet_GetSize(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfSet *arg1 = (XdmfSet *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt64 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfSet_GetSize",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfSet, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfSet_GetSize" "', argument " "1"" of type '" "XdmfSet *""'"); } arg1 = reinterpret_cast< XdmfSet * >(argp1); result = (XdmfInt64)(arg1)->GetSize(); resultobj = SWIG_From_long_SS_long(static_cast< long long >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfSet_SetSize(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfSet *arg1 = (XdmfSet *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfSet_SetSize",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfSet, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfSet_SetSize" "', argument " "1"" of type '" "XdmfSet *""'"); } arg1 = reinterpret_cast< XdmfSet * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfSet_SetSize" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfInt32)(arg1)->SetSize(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfSet_GetGhost(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfSet *arg1 = (XdmfSet *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt64 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfSet_GetGhost",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfSet, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfSet_GetGhost" "', argument " "1"" of type '" "XdmfSet *""'"); } arg1 = reinterpret_cast< XdmfSet * >(argp1); result = (XdmfInt64)(arg1)->GetGhost(); resultobj = SWIG_From_long_SS_long(static_cast< long long >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfSet_SetGhost(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfSet *arg1 = (XdmfSet *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfSet_SetGhost",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfSet, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfSet_SetGhost" "', argument " "1"" of type '" "XdmfSet *""'"); } arg1 = reinterpret_cast< XdmfSet * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfSet_SetGhost" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfInt32)(arg1)->SetGhost(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfSet_GetShapeDesc(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfSet *arg1 = (XdmfSet *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfDataDesc *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfSet_GetShapeDesc",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfSet, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfSet_GetShapeDesc" "', argument " "1"" of type '" "XdmfSet *""'"); } arg1 = reinterpret_cast< XdmfSet * >(argp1); result = (XdmfDataDesc *)(arg1)->GetShapeDesc(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfDataDesc, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfSet_Insert(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfSet *arg1 = (XdmfSet *) 0 ; XdmfElement *arg2 = (XdmfElement *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfSet_Insert",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfSet, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfSet_Insert" "', argument " "1"" of type '" "XdmfSet *""'"); } arg1 = reinterpret_cast< XdmfSet * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfSet_Insert" "', argument " "2"" of type '" "XdmfElement *""'"); } arg2 = reinterpret_cast< XdmfElement * >(argp2); result = (XdmfInt32)(arg1)->Insert(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfSet_SetIds(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfSet *arg1 = (XdmfSet *) 0 ; XdmfArray *arg2 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfSet_SetIds",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfSet, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfSet_SetIds" "', argument " "1"" of type '" "XdmfSet *""'"); } arg1 = reinterpret_cast< XdmfSet * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfSet_SetIds" "', argument " "2"" of type '" "XdmfArray *""'"); } arg2 = reinterpret_cast< XdmfArray * >(argp2); result = (XdmfInt32)(arg1)->SetIds(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfSet_GetIds__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfSet *arg1 = (XdmfSet *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfSet_GetIds",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfSet, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfSet_GetIds" "', argument " "1"" of type '" "XdmfSet *""'"); } arg1 = reinterpret_cast< XdmfSet * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfSet_GetIds" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfArray *)(arg1)->GetIds(arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfSet_GetIds__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfSet *arg1 = (XdmfSet *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfSet_GetIds",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfSet, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfSet_GetIds" "', argument " "1"" of type '" "XdmfSet *""'"); } arg1 = reinterpret_cast< XdmfSet * >(argp1); result = (XdmfArray *)(arg1)->GetIds(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfSet_GetIds(PyObject *self, PyObject *args) { int argc; PyObject *argv[3]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 2); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfSet, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfSet_GetIds__SWIG_1(self, args); } } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfSet, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_int(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfSet_GetIds__SWIG_0(self, args); } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfSet_GetIds'.\n" " Possible C/C++ prototypes are:\n" " GetIds(XdmfSet *,XdmfInt32)\n" " GetIds(XdmfSet *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfSet_SetCellIds(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfSet *arg1 = (XdmfSet *) 0 ; XdmfArray *arg2 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfSet_SetCellIds",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfSet, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfSet_SetCellIds" "', argument " "1"" of type '" "XdmfSet *""'"); } arg1 = reinterpret_cast< XdmfSet * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfSet_SetCellIds" "', argument " "2"" of type '" "XdmfArray *""'"); } arg2 = reinterpret_cast< XdmfArray * >(argp2); result = (XdmfInt32)(arg1)->SetCellIds(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfSet_GetCellIds__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfSet *arg1 = (XdmfSet *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfSet_GetCellIds",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfSet, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfSet_GetCellIds" "', argument " "1"" of type '" "XdmfSet *""'"); } arg1 = reinterpret_cast< XdmfSet * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfSet_GetCellIds" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfArray *)(arg1)->GetCellIds(arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfSet_GetCellIds__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfSet *arg1 = (XdmfSet *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfSet_GetCellIds",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfSet, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfSet_GetCellIds" "', argument " "1"" of type '" "XdmfSet *""'"); } arg1 = reinterpret_cast< XdmfSet * >(argp1); result = (XdmfArray *)(arg1)->GetCellIds(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfSet_GetCellIds(PyObject *self, PyObject *args) { int argc; PyObject *argv[3]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 2); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfSet, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfSet_GetCellIds__SWIG_1(self, args); } } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfSet, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_int(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfSet_GetCellIds__SWIG_0(self, args); } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfSet_GetCellIds'.\n" " Possible C/C++ prototypes are:\n" " GetCellIds(XdmfSet *,XdmfInt32)\n" " GetCellIds(XdmfSet *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfSet_SetFaceIds(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfSet *arg1 = (XdmfSet *) 0 ; XdmfArray *arg2 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfSet_SetFaceIds",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfSet, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfSet_SetFaceIds" "', argument " "1"" of type '" "XdmfSet *""'"); } arg1 = reinterpret_cast< XdmfSet * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfSet_SetFaceIds" "', argument " "2"" of type '" "XdmfArray *""'"); } arg2 = reinterpret_cast< XdmfArray * >(argp2); result = (XdmfInt32)(arg1)->SetFaceIds(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfSet_GetFaceIds__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfSet *arg1 = (XdmfSet *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfSet_GetFaceIds",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfSet, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfSet_GetFaceIds" "', argument " "1"" of type '" "XdmfSet *""'"); } arg1 = reinterpret_cast< XdmfSet * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfSet_GetFaceIds" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfArray *)(arg1)->GetFaceIds(arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfSet_GetFaceIds__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfSet *arg1 = (XdmfSet *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfSet_GetFaceIds",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfSet, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfSet_GetFaceIds" "', argument " "1"" of type '" "XdmfSet *""'"); } arg1 = reinterpret_cast< XdmfSet * >(argp1); result = (XdmfArray *)(arg1)->GetFaceIds(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfSet_GetFaceIds(PyObject *self, PyObject *args) { int argc; PyObject *argv[3]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 2); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfSet, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfSet_GetFaceIds__SWIG_1(self, args); } } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfSet, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_int(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfSet_GetFaceIds__SWIG_0(self, args); } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfSet_GetFaceIds'.\n" " Possible C/C++ prototypes are:\n" " GetFaceIds(XdmfSet *,XdmfInt32)\n" " GetFaceIds(XdmfSet *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfSet_GetNumberOfMaps(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfSet *arg1 = (XdmfSet *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfSet_GetNumberOfMaps",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfSet, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfSet_GetNumberOfMaps" "', argument " "1"" of type '" "XdmfSet *""'"); } arg1 = reinterpret_cast< XdmfSet * >(argp1); result = (XdmfInt32)(arg1)->GetNumberOfMaps(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfSet_GetMap(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfSet *arg1 = (XdmfSet *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfMap *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfSet_GetMap",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfSet, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfSet_GetMap" "', argument " "1"" of type '" "XdmfSet *""'"); } arg1 = reinterpret_cast< XdmfSet * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfSet_GetMap" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfMap *)(arg1)->GetMap(arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfMap, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfSet_GetNumberOfAttributes(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfSet *arg1 = (XdmfSet *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfSet_GetNumberOfAttributes",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfSet, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfSet_GetNumberOfAttributes" "', argument " "1"" of type '" "XdmfSet *""'"); } arg1 = reinterpret_cast< XdmfSet * >(argp1); result = (XdmfInt32)(arg1)->GetNumberOfAttributes(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfSet_GetAttribute(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfSet *arg1 = (XdmfSet *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfAttribute *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfSet_GetAttribute",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfSet, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfSet_GetAttribute" "', argument " "1"" of type '" "XdmfSet *""'"); } arg1 = reinterpret_cast< XdmfSet * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfSet_GetAttribute" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfAttribute *)(arg1)->GetAttribute(arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfAttribute, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfSet_UpdateInformation(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfSet *arg1 = (XdmfSet *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfSet_UpdateInformation",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfSet, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfSet_UpdateInformation" "', argument " "1"" of type '" "XdmfSet *""'"); } arg1 = reinterpret_cast< XdmfSet * >(argp1); result = (XdmfInt32)(arg1)->UpdateInformation(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfSet_Update(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfSet *arg1 = (XdmfSet *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfSet_Update",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfSet, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfSet_Update" "', argument " "1"" of type '" "XdmfSet *""'"); } arg1 = reinterpret_cast< XdmfSet * >(argp1); result = (XdmfInt32)(arg1)->Update(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfSet_Build(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfSet *arg1 = (XdmfSet *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfSet_Build",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfSet, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfSet_Build" "', argument " "1"" of type '" "XdmfSet *""'"); } arg1 = reinterpret_cast< XdmfSet * >(argp1); result = (XdmfInt32)(arg1)->Build(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfSet_Release(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfSet *arg1 = (XdmfSet *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfSet_Release",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfSet, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfSet_Release" "', argument " "1"" of type '" "XdmfSet *""'"); } arg1 = reinterpret_cast< XdmfSet * >(argp1); result = (XdmfInt32)(arg1)->Release(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *XdmfSet_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; SWIG_TypeNewClientData(SWIGTYPE_p_XdmfSet, SWIG_NewClientData(obj)); return SWIG_Py_Void(); } SWIGINTERN PyObject *_wrap_new_XdmfMap(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfMap *result = 0 ; if (!PyArg_ParseTuple(args,(char *)":new_XdmfMap")) SWIG_fail; result = (XdmfMap *)new XdmfMap(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfMap, SWIG_POINTER_NEW | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_delete_XdmfMap(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfMap *arg1 = (XdmfMap *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:delete_XdmfMap",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfMap, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_XdmfMap" "', argument " "1"" of type '" "XdmfMap *""'"); } arg1 = reinterpret_cast< XdmfMap * >(argp1); delete arg1; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfMap_GetClassName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfMap *arg1 = (XdmfMap *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfMap_GetClassName",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfMap, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfMap_GetClassName" "', argument " "1"" of type '" "XdmfMap *""'"); } arg1 = reinterpret_cast< XdmfMap * >(argp1); result = (XdmfConstString)(arg1)->GetClassName(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfMap_SetMapTypeFromString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfMap *arg1 = (XdmfMap *) 0 ; XdmfConstString arg2 = (XdmfConstString) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfMap_SetMapTypeFromString",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfMap, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfMap_SetMapTypeFromString" "', argument " "1"" of type '" "XdmfMap *""'"); } arg1 = reinterpret_cast< XdmfMap * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfMap_SetMapTypeFromString" "', argument " "2"" of type '" "XdmfConstString""'"); } arg2 = reinterpret_cast< XdmfConstString >(buf2); result = (XdmfInt32)(arg1)->SetMapTypeFromString(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return NULL; } SWIGINTERN PyObject *_wrap_XdmfMap_GetMapTypeAsString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfMap *arg1 = (XdmfMap *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfMap_GetMapTypeAsString",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfMap, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfMap_GetMapTypeAsString" "', argument " "1"" of type '" "XdmfMap *""'"); } arg1 = reinterpret_cast< XdmfMap * >(argp1); result = (XdmfConstString)(arg1)->GetMapTypeAsString(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfMap_SetMapType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfMap *arg1 = (XdmfMap *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfMap_SetMapType",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfMap, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfMap_SetMapType" "', argument " "1"" of type '" "XdmfMap *""'"); } arg1 = reinterpret_cast< XdmfMap * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfMap_SetMapType" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetMapType(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfMap_GetMapType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfMap *arg1 = (XdmfMap *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfMap_GetMapType",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfMap, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfMap_GetMapType" "', argument " "1"" of type '" "XdmfMap *""'"); } arg1 = reinterpret_cast< XdmfMap * >(argp1); result = (XdmfInt32)(arg1)->GetMapType(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfMap_GetItemLength(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfMap *arg1 = (XdmfMap *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfMap_GetItemLength",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfMap, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfMap_GetItemLength" "', argument " "1"" of type '" "XdmfMap *""'"); } arg1 = reinterpret_cast< XdmfMap * >(argp1); result = (XdmfInt32)(arg1)->GetItemLength(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfMap_SetItemLength(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfMap *arg1 = (XdmfMap *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfMap_SetItemLength",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfMap, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfMap_SetItemLength" "', argument " "1"" of type '" "XdmfMap *""'"); } arg1 = reinterpret_cast< XdmfMap * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfMap_SetItemLength" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetItemLength(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfMap_GetMapLength(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfMap *arg1 = (XdmfMap *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt64 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfMap_GetMapLength",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfMap, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfMap_GetMapLength" "', argument " "1"" of type '" "XdmfMap *""'"); } arg1 = reinterpret_cast< XdmfMap * >(argp1); result = (XdmfInt64)(arg1)->GetMapLength(); resultobj = SWIG_From_long_SS_long(static_cast< long long >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfMap_SetMapLength(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfMap *arg1 = (XdmfMap *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfMap_SetMapLength",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfMap, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfMap_SetMapLength" "', argument " "1"" of type '" "XdmfMap *""'"); } arg1 = reinterpret_cast< XdmfMap * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfMap_SetMapLength" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfInt32)(arg1)->SetMapLength(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfMap_Insert(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfMap *arg1 = (XdmfMap *) 0 ; XdmfElement *arg2 = (XdmfElement *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfMap_Insert",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfMap, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfMap_Insert" "', argument " "1"" of type '" "XdmfMap *""'"); } arg1 = reinterpret_cast< XdmfMap * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfElement, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfMap_Insert" "', argument " "2"" of type '" "XdmfElement *""'"); } arg2 = reinterpret_cast< XdmfElement * >(argp2); result = (XdmfInt32)(arg1)->Insert(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfMap_SetIds(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfMap *arg1 = (XdmfMap *) 0 ; XdmfArray *arg2 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfMap_SetIds",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfMap, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfMap_SetIds" "', argument " "1"" of type '" "XdmfMap *""'"); } arg1 = reinterpret_cast< XdmfMap * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfMap_SetIds" "', argument " "2"" of type '" "XdmfArray *""'"); } arg2 = reinterpret_cast< XdmfArray * >(argp2); result = (XdmfInt32)(arg1)->SetIds(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfMap_GetIds__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfMap *arg1 = (XdmfMap *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfMap_GetIds",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfMap, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfMap_GetIds" "', argument " "1"" of type '" "XdmfMap *""'"); } arg1 = reinterpret_cast< XdmfMap * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfMap_GetIds" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfArray *)(arg1)->GetIds(arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfMap_GetIds__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfMap *arg1 = (XdmfMap *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfMap_GetIds",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfMap, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfMap_GetIds" "', argument " "1"" of type '" "XdmfMap *""'"); } arg1 = reinterpret_cast< XdmfMap * >(argp1); result = (XdmfArray *)(arg1)->GetIds(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfMap_GetIds(PyObject *self, PyObject *args) { int argc; PyObject *argv[3]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 2); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfMap, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfMap_GetIds__SWIG_1(self, args); } } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfMap, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_int(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfMap_GetIds__SWIG_0(self, args); } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfMap_GetIds'.\n" " Possible C/C++ prototypes are:\n" " GetIds(XdmfMap *,XdmfInt32)\n" " GetIds(XdmfMap *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfMap_SetMapIndex(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfMap *arg1 = (XdmfMap *) 0 ; XdmfArray *arg2 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfMap_SetMapIndex",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfMap, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfMap_SetMapIndex" "', argument " "1"" of type '" "XdmfMap *""'"); } arg1 = reinterpret_cast< XdmfMap * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfMap_SetMapIndex" "', argument " "2"" of type '" "XdmfArray *""'"); } arg2 = reinterpret_cast< XdmfArray * >(argp2); result = (XdmfInt32)(arg1)->SetMapIndex(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfMap_GetMapIndex__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfMap *arg1 = (XdmfMap *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfMap_GetMapIndex",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfMap, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfMap_GetMapIndex" "', argument " "1"" of type '" "XdmfMap *""'"); } arg1 = reinterpret_cast< XdmfMap * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfMap_GetMapIndex" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfArray *)(arg1)->GetMapIndex(arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfMap_GetMapIndex__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfMap *arg1 = (XdmfMap *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfMap_GetMapIndex",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfMap, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfMap_GetMapIndex" "', argument " "1"" of type '" "XdmfMap *""'"); } arg1 = reinterpret_cast< XdmfMap * >(argp1); result = (XdmfArray *)(arg1)->GetMapIndex(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfMap_GetMapIndex(PyObject *self, PyObject *args) { int argc; PyObject *argv[3]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 2); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfMap, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfMap_GetMapIndex__SWIG_1(self, args); } } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfMap, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_int(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfMap_GetMapIndex__SWIG_0(self, args); } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfMap_GetMapIndex'.\n" " Possible C/C++ prototypes are:\n" " GetMapIndex(XdmfMap *,XdmfInt32)\n" " GetMapIndex(XdmfMap *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfMap_SetMapData(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfMap *arg1 = (XdmfMap *) 0 ; XdmfArray *arg2 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfMap_SetMapData",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfMap, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfMap_SetMapData" "', argument " "1"" of type '" "XdmfMap *""'"); } arg1 = reinterpret_cast< XdmfMap * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfMap_SetMapData" "', argument " "2"" of type '" "XdmfArray *""'"); } arg2 = reinterpret_cast< XdmfArray * >(argp2); result = (XdmfInt32)(arg1)->SetMapData(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfMap_GetMapData__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfMap *arg1 = (XdmfMap *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfMap_GetMapData",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfMap, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfMap_GetMapData" "', argument " "1"" of type '" "XdmfMap *""'"); } arg1 = reinterpret_cast< XdmfMap * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfMap_GetMapData" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfArray *)(arg1)->GetMapData(arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfMap_GetMapData__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfMap *arg1 = (XdmfMap *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfMap_GetMapData",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfMap, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfMap_GetMapData" "', argument " "1"" of type '" "XdmfMap *""'"); } arg1 = reinterpret_cast< XdmfMap * >(argp1); result = (XdmfArray *)(arg1)->GetMapData(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfMap_GetMapData(PyObject *self, PyObject *args) { int argc; PyObject *argv[3]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 2); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfMap, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfMap_GetMapData__SWIG_1(self, args); } } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfMap, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_int(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfMap_GetMapData__SWIG_0(self, args); } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfMap_GetMapData'.\n" " Possible C/C++ prototypes are:\n" " GetMapData(XdmfMap *,XdmfInt32)\n" " GetMapData(XdmfMap *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfMap_UpdateInformation(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfMap *arg1 = (XdmfMap *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfMap_UpdateInformation",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfMap, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfMap_UpdateInformation" "', argument " "1"" of type '" "XdmfMap *""'"); } arg1 = reinterpret_cast< XdmfMap * >(argp1); result = (XdmfInt32)(arg1)->UpdateInformation(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfMap_Update(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfMap *arg1 = (XdmfMap *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfMap_Update",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfMap, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfMap_Update" "', argument " "1"" of type '" "XdmfMap *""'"); } arg1 = reinterpret_cast< XdmfMap * >(argp1); result = (XdmfInt32)(arg1)->Update(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfMap_Build(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfMap *arg1 = (XdmfMap *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfMap_Build",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfMap, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfMap_Build" "', argument " "1"" of type '" "XdmfMap *""'"); } arg1 = reinterpret_cast< XdmfMap * >(argp1); result = (XdmfInt32)(arg1)->Build(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfMap_Release(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfMap *arg1 = (XdmfMap *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfMap_Release",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfMap, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfMap_Release" "', argument " "1"" of type '" "XdmfMap *""'"); } arg1 = reinterpret_cast< XdmfMap * >(argp1); result = (XdmfInt32)(arg1)->Release(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *XdmfMap_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; SWIG_TypeNewClientData(SWIGTYPE_p_XdmfMap, SWIG_NewClientData(obj)); return SWIG_Py_Void(); } SWIGINTERN PyObject *_wrap_new_XdmfDsm(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsm *result = 0 ; if (!PyArg_ParseTuple(args,(char *)":new_XdmfDsm")) SWIG_fail; result = (XdmfDsm *)new XdmfDsm(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfDsm, SWIG_POINTER_NEW | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_delete_XdmfDsm(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsm *arg1 = (XdmfDsm *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:delete_XdmfDsm",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsm, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_XdmfDsm" "', argument " "1"" of type '" "XdmfDsm *""'"); } arg1 = reinterpret_cast< XdmfDsm * >(argp1); delete arg1; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsm_GetClassName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsm *arg1 = (XdmfDsm *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDsm_GetClassName",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsm_GetClassName" "', argument " "1"" of type '" "XdmfDsm *""'"); } arg1 = reinterpret_cast< XdmfDsm * >(argp1); result = (XdmfConstString)(arg1)->GetClassName(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsm_GetDsmType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsm *arg1 = (XdmfDsm *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDsm_GetDsmType",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsm_GetDsmType" "', argument " "1"" of type '" "XdmfDsm *""'"); } arg1 = reinterpret_cast< XdmfDsm * >(argp1); result = (XdmfInt32)(arg1)->GetDsmType(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsm_SetDsmType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsm *arg1 = (XdmfDsm *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDsm_SetDsmType",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsm_SetDsmType" "', argument " "1"" of type '" "XdmfDsm *""'"); } arg1 = reinterpret_cast< XdmfDsm * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDsm_SetDsmType" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetDsmType(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsm_GetEndAddress(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsm *arg1 = (XdmfDsm *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt64 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDsm_GetEndAddress",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsm_GetEndAddress" "', argument " "1"" of type '" "XdmfDsm *""'"); } arg1 = reinterpret_cast< XdmfDsm * >(argp1); result = (XdmfInt64)(arg1)->GetEndAddress(); resultobj = SWIG_From_long_SS_long(static_cast< long long >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsm_SetEndAddress(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsm *arg1 = (XdmfDsm *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDsm_SetEndAddress",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsm_SetEndAddress" "', argument " "1"" of type '" "XdmfDsm *""'"); } arg1 = reinterpret_cast< XdmfDsm * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDsm_SetEndAddress" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfInt32)(arg1)->SetEndAddress(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsm_GetStartAddress(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsm *arg1 = (XdmfDsm *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt64 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDsm_GetStartAddress",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsm_GetStartAddress" "', argument " "1"" of type '" "XdmfDsm *""'"); } arg1 = reinterpret_cast< XdmfDsm * >(argp1); result = (XdmfInt64)(arg1)->GetStartAddress(); resultobj = SWIG_From_long_SS_long(static_cast< long long >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsm_SetStartAddress(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsm *arg1 = (XdmfDsm *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDsm_SetStartAddress",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsm_SetStartAddress" "', argument " "1"" of type '" "XdmfDsm *""'"); } arg1 = reinterpret_cast< XdmfDsm * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDsm_SetStartAddress" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfInt32)(arg1)->SetStartAddress(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsm_GetStartServerId(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsm *arg1 = (XdmfDsm *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDsm_GetStartServerId",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsm_GetStartServerId" "', argument " "1"" of type '" "XdmfDsm *""'"); } arg1 = reinterpret_cast< XdmfDsm * >(argp1); result = (XdmfInt32)(arg1)->GetStartServerId(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsm_SetStartServerId(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsm *arg1 = (XdmfDsm *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDsm_SetStartServerId",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsm_SetStartServerId" "', argument " "1"" of type '" "XdmfDsm *""'"); } arg1 = reinterpret_cast< XdmfDsm * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDsm_SetStartServerId" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetStartServerId(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsm_GetEndServerId(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsm *arg1 = (XdmfDsm *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDsm_GetEndServerId",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsm_GetEndServerId" "', argument " "1"" of type '" "XdmfDsm *""'"); } arg1 = reinterpret_cast< XdmfDsm * >(argp1); result = (XdmfInt32)(arg1)->GetEndServerId(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsm_SetEndServerId(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsm *arg1 = (XdmfDsm *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDsm_SetEndServerId",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsm_SetEndServerId" "', argument " "1"" of type '" "XdmfDsm *""'"); } arg1 = reinterpret_cast< XdmfDsm * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDsm_SetEndServerId" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetEndServerId(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsm_GetLength(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsm *arg1 = (XdmfDsm *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt64 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDsm_GetLength",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsm_GetLength" "', argument " "1"" of type '" "XdmfDsm *""'"); } arg1 = reinterpret_cast< XdmfDsm * >(argp1); result = (XdmfInt64)(arg1)->GetLength(); resultobj = SWIG_From_long_SS_long(static_cast< long long >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsm_SetLength(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsm *arg1 = (XdmfDsm *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDsm_SetLength",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsm_SetLength" "', argument " "1"" of type '" "XdmfDsm *""'"); } arg1 = reinterpret_cast< XdmfDsm * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDsm_SetLength" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfInt32)(arg1)->SetLength(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsm_GetTotalLength(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsm *arg1 = (XdmfDsm *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt64 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDsm_GetTotalLength",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsm_GetTotalLength" "', argument " "1"" of type '" "XdmfDsm *""'"); } arg1 = reinterpret_cast< XdmfDsm * >(argp1); result = (XdmfInt64)(arg1)->GetTotalLength(); resultobj = SWIG_From_long_SS_long(static_cast< long long >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsm_SetTotalLength(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsm *arg1 = (XdmfDsm *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDsm_SetTotalLength",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsm_SetTotalLength" "', argument " "1"" of type '" "XdmfDsm *""'"); } arg1 = reinterpret_cast< XdmfDsm * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDsm_SetTotalLength" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfInt32)(arg1)->SetTotalLength(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsm_GetStorage(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsm *arg1 = (XdmfDsm *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfArray *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDsm_GetStorage",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsm_GetStorage" "', argument " "1"" of type '" "XdmfDsm *""'"); } arg1 = reinterpret_cast< XdmfDsm * >(argp1); result = (XdmfArray *)(arg1)->GetStorage(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfArray, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsm_SetStorage(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsm *arg1 = (XdmfDsm *) 0 ; XdmfArray *arg2 = (XdmfArray *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDsm_SetStorage",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsm_SetStorage" "', argument " "1"" of type '" "XdmfDsm *""'"); } arg1 = reinterpret_cast< XdmfDsm * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfArray, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDsm_SetStorage" "', argument " "2"" of type '" "XdmfArray *""'"); } arg2 = reinterpret_cast< XdmfArray * >(argp2); result = (XdmfInt32)(arg1)->SetStorage(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsm_GetComm(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsm *arg1 = (XdmfDsm *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfDsmComm *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDsm_GetComm",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsm_GetComm" "', argument " "1"" of type '" "XdmfDsm *""'"); } arg1 = reinterpret_cast< XdmfDsm * >(argp1); result = (XdmfDsmComm *)(arg1)->GetComm(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfDsmComm, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsm_SetComm(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsm *arg1 = (XdmfDsm *) 0 ; XdmfDsmComm *arg2 = (XdmfDsmComm *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDsm_SetComm",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsm_SetComm" "', argument " "1"" of type '" "XdmfDsm *""'"); } arg1 = reinterpret_cast< XdmfDsm * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfDsmComm, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDsm_SetComm" "', argument " "2"" of type '" "XdmfDsmComm *""'"); } arg2 = reinterpret_cast< XdmfDsmComm * >(argp2); result = (XdmfInt32)(arg1)->SetComm(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsm_GetMsg(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsm *arg1 = (XdmfDsm *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfDsmMsg *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDsm_GetMsg",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsm_GetMsg" "', argument " "1"" of type '" "XdmfDsm *""'"); } arg1 = reinterpret_cast< XdmfDsm * >(argp1); result = (XdmfDsmMsg *)(arg1)->GetMsg(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfDsmMsg, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsm_SetMsg(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsm *arg1 = (XdmfDsm *) 0 ; XdmfDsmMsg *arg2 = (XdmfDsmMsg *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDsm_SetMsg",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsm_SetMsg" "', argument " "1"" of type '" "XdmfDsm *""'"); } arg1 = reinterpret_cast< XdmfDsm * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfDsmMsg, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDsm_SetMsg" "', argument " "2"" of type '" "XdmfDsmMsg *""'"); } arg2 = reinterpret_cast< XdmfDsmMsg * >(argp2); result = (XdmfInt32)(arg1)->SetMsg(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsm_GetAddressRangeForId(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsm *arg1 = (XdmfDsm *) 0 ; XdmfInt32 arg2 ; XdmfInt64 *arg3 = (XdmfInt64 *) 0 ; XdmfInt64 *arg4 = (XdmfInt64 *) 0 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; void *argp4 = 0 ; int res4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOO:XdmfDsm_GetAddressRangeForId",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsm_GetAddressRangeForId" "', argument " "1"" of type '" "XdmfDsm *""'"); } arg1 = reinterpret_cast< XdmfDsm * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDsm_GetAddressRangeForId" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_long_long, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfDsm_GetAddressRangeForId" "', argument " "3"" of type '" "XdmfInt64 *""'"); } arg3 = reinterpret_cast< XdmfInt64 * >(argp3); res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_long_long, 0 | 0 ); if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "XdmfDsm_GetAddressRangeForId" "', argument " "4"" of type '" "XdmfInt64 *""'"); } arg4 = reinterpret_cast< XdmfInt64 * >(argp4); result = (XdmfInt32)(arg1)->GetAddressRangeForId(arg2,arg3,arg4); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsm_ConfigureUniform__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsm *arg1 = (XdmfDsm *) 0 ; XdmfDsmComm *arg2 = (XdmfDsmComm *) 0 ; XdmfInt64 arg3 ; XdmfInt32 arg4 ; XdmfInt32 arg5 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; long long val3 ; int ecode3 = 0 ; int val4 ; int ecode4 = 0 ; int val5 ; int ecode5 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOOO:XdmfDsm_ConfigureUniform",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsm_ConfigureUniform" "', argument " "1"" of type '" "XdmfDsm *""'"); } arg1 = reinterpret_cast< XdmfDsm * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfDsmComm, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDsm_ConfigureUniform" "', argument " "2"" of type '" "XdmfDsmComm *""'"); } arg2 = reinterpret_cast< XdmfDsmComm * >(argp2); ecode3 = SWIG_AsVal_long_SS_long(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "XdmfDsm_ConfigureUniform" "', argument " "3"" of type '" "XdmfInt64""'"); } arg3 = static_cast< XdmfInt64 >(val3); ecode4 = SWIG_AsVal_int(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfDsm_ConfigureUniform" "', argument " "4"" of type '" "XdmfInt32""'"); } arg4 = static_cast< XdmfInt32 >(val4); ecode5 = SWIG_AsVal_int(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "XdmfDsm_ConfigureUniform" "', argument " "5"" of type '" "XdmfInt32""'"); } arg5 = static_cast< XdmfInt32 >(val5); result = (XdmfInt32)(arg1)->ConfigureUniform(arg2,arg3,arg4,arg5); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsm_ConfigureUniform__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsm *arg1 = (XdmfDsm *) 0 ; XdmfDsmComm *arg2 = (XdmfDsmComm *) 0 ; XdmfInt64 arg3 ; XdmfInt32 arg4 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; long long val3 ; int ecode3 = 0 ; int val4 ; int ecode4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOO:XdmfDsm_ConfigureUniform",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsm_ConfigureUniform" "', argument " "1"" of type '" "XdmfDsm *""'"); } arg1 = reinterpret_cast< XdmfDsm * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfDsmComm, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDsm_ConfigureUniform" "', argument " "2"" of type '" "XdmfDsmComm *""'"); } arg2 = reinterpret_cast< XdmfDsmComm * >(argp2); ecode3 = SWIG_AsVal_long_SS_long(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "XdmfDsm_ConfigureUniform" "', argument " "3"" of type '" "XdmfInt64""'"); } arg3 = static_cast< XdmfInt64 >(val3); ecode4 = SWIG_AsVal_int(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfDsm_ConfigureUniform" "', argument " "4"" of type '" "XdmfInt32""'"); } arg4 = static_cast< XdmfInt32 >(val4); result = (XdmfInt32)(arg1)->ConfigureUniform(arg2,arg3,arg4); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsm_ConfigureUniform__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsm *arg1 = (XdmfDsm *) 0 ; XdmfDsmComm *arg2 = (XdmfDsmComm *) 0 ; XdmfInt64 arg3 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; long long val3 ; int ecode3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfDsm_ConfigureUniform",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsm_ConfigureUniform" "', argument " "1"" of type '" "XdmfDsm *""'"); } arg1 = reinterpret_cast< XdmfDsm * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfDsmComm, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDsm_ConfigureUniform" "', argument " "2"" of type '" "XdmfDsmComm *""'"); } arg2 = reinterpret_cast< XdmfDsmComm * >(argp2); ecode3 = SWIG_AsVal_long_SS_long(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "XdmfDsm_ConfigureUniform" "', argument " "3"" of type '" "XdmfInt64""'"); } arg3 = static_cast< XdmfInt64 >(val3); result = (XdmfInt32)(arg1)->ConfigureUniform(arg2,arg3); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsm_ConfigureUniform(PyObject *self, PyObject *args) { int argc; PyObject *argv[6]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 5); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 3) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDsm, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_XdmfDsmComm, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[2], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfDsm_ConfigureUniform__SWIG_2(self, args); } } } } if (argc == 4) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDsm, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_XdmfDsmComm, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[2], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_int(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfDsm_ConfigureUniform__SWIG_1(self, args); } } } } } if (argc == 5) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDsm, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_XdmfDsmComm, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[2], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_int(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_int(argv[4], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfDsm_ConfigureUniform__SWIG_0(self, args); } } } } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfDsm_ConfigureUniform'.\n" " Possible C/C++ prototypes are:\n" " ConfigureUniform(XdmfDsm *,XdmfDsmComm *,XdmfInt64,XdmfInt32,XdmfInt32)\n" " ConfigureUniform(XdmfDsm *,XdmfDsmComm *,XdmfInt64,XdmfInt32)\n" " ConfigureUniform(XdmfDsm *,XdmfDsmComm *,XdmfInt64)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsm_AddressToId(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsm *arg1 = (XdmfDsm *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDsm_AddressToId",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsm_AddressToId" "', argument " "1"" of type '" "XdmfDsm *""'"); } arg1 = reinterpret_cast< XdmfDsm * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDsm_AddressToId" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfInt32)(arg1)->AddressToId(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsm_SendCommandHeader(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsm *arg1 = (XdmfDsm *) 0 ; XdmfInt32 arg2 ; XdmfInt32 arg3 ; XdmfInt64 arg4 ; XdmfInt64 arg5 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; int val3 ; int ecode3 = 0 ; long long val4 ; int ecode4 = 0 ; long long val5 ; int ecode5 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOOO:XdmfDsm_SendCommandHeader",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsm_SendCommandHeader" "', argument " "1"" of type '" "XdmfDsm *""'"); } arg1 = reinterpret_cast< XdmfDsm * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDsm_SendCommandHeader" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "XdmfDsm_SendCommandHeader" "', argument " "3"" of type '" "XdmfInt32""'"); } arg3 = static_cast< XdmfInt32 >(val3); ecode4 = SWIG_AsVal_long_SS_long(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfDsm_SendCommandHeader" "', argument " "4"" of type '" "XdmfInt64""'"); } arg4 = static_cast< XdmfInt64 >(val4); ecode5 = SWIG_AsVal_long_SS_long(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "XdmfDsm_SendCommandHeader" "', argument " "5"" of type '" "XdmfInt64""'"); } arg5 = static_cast< XdmfInt64 >(val5); result = (XdmfInt32)(arg1)->SendCommandHeader(arg2,arg3,arg4,arg5); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsm_ReceiveCommandHeader__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsm *arg1 = (XdmfDsm *) 0 ; XdmfInt32 *arg2 = (XdmfInt32 *) 0 ; XdmfInt32 *arg3 = (XdmfInt32 *) 0 ; XdmfInt64 *arg4 = (XdmfInt64 *) 0 ; XdmfInt64 *arg5 = (XdmfInt64 *) 0 ; XdmfInt32 arg6 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; void *argp4 = 0 ; int res4 = 0 ; void *argp5 = 0 ; int res5 = 0 ; int val6 ; int ecode6 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; PyObject * obj5 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOOOO:XdmfDsm_ReceiveCommandHeader",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsm_ReceiveCommandHeader" "', argument " "1"" of type '" "XdmfDsm *""'"); } arg1 = reinterpret_cast< XdmfDsm * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_int, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDsm_ReceiveCommandHeader" "', argument " "2"" of type '" "XdmfInt32 *""'"); } arg2 = reinterpret_cast< XdmfInt32 * >(argp2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_int, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfDsm_ReceiveCommandHeader" "', argument " "3"" of type '" "XdmfInt32 *""'"); } arg3 = reinterpret_cast< XdmfInt32 * >(argp3); res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_long_long, 0 | 0 ); if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "XdmfDsm_ReceiveCommandHeader" "', argument " "4"" of type '" "XdmfInt64 *""'"); } arg4 = reinterpret_cast< XdmfInt64 * >(argp4); res5 = SWIG_ConvertPtr(obj4, &argp5,SWIGTYPE_p_long_long, 0 | 0 ); if (!SWIG_IsOK(res5)) { SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "XdmfDsm_ReceiveCommandHeader" "', argument " "5"" of type '" "XdmfInt64 *""'"); } arg5 = reinterpret_cast< XdmfInt64 * >(argp5); ecode6 = SWIG_AsVal_int(obj5, &val6); if (!SWIG_IsOK(ecode6)) { SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "XdmfDsm_ReceiveCommandHeader" "', argument " "6"" of type '" "XdmfInt32""'"); } arg6 = static_cast< XdmfInt32 >(val6); result = (XdmfInt32)(arg1)->ReceiveCommandHeader(arg2,arg3,arg4,arg5,arg6); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsm_ReceiveCommandHeader__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsm *arg1 = (XdmfDsm *) 0 ; XdmfInt32 *arg2 = (XdmfInt32 *) 0 ; XdmfInt32 *arg3 = (XdmfInt32 *) 0 ; XdmfInt64 *arg4 = (XdmfInt64 *) 0 ; XdmfInt64 *arg5 = (XdmfInt64 *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; void *argp4 = 0 ; int res4 = 0 ; void *argp5 = 0 ; int res5 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOOO:XdmfDsm_ReceiveCommandHeader",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsm_ReceiveCommandHeader" "', argument " "1"" of type '" "XdmfDsm *""'"); } arg1 = reinterpret_cast< XdmfDsm * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_int, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDsm_ReceiveCommandHeader" "', argument " "2"" of type '" "XdmfInt32 *""'"); } arg2 = reinterpret_cast< XdmfInt32 * >(argp2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_int, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfDsm_ReceiveCommandHeader" "', argument " "3"" of type '" "XdmfInt32 *""'"); } arg3 = reinterpret_cast< XdmfInt32 * >(argp3); res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_long_long, 0 | 0 ); if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "XdmfDsm_ReceiveCommandHeader" "', argument " "4"" of type '" "XdmfInt64 *""'"); } arg4 = reinterpret_cast< XdmfInt64 * >(argp4); res5 = SWIG_ConvertPtr(obj4, &argp5,SWIGTYPE_p_long_long, 0 | 0 ); if (!SWIG_IsOK(res5)) { SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "XdmfDsm_ReceiveCommandHeader" "', argument " "5"" of type '" "XdmfInt64 *""'"); } arg5 = reinterpret_cast< XdmfInt64 * >(argp5); result = (XdmfInt32)(arg1)->ReceiveCommandHeader(arg2,arg3,arg4,arg5); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsm_ReceiveCommandHeader(PyObject *self, PyObject *args) { int argc; PyObject *argv[7]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 6); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 5) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDsm, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_int, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_int, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[3], &vptr, SWIGTYPE_p_long_long, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[4], &vptr, SWIGTYPE_p_long_long, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfDsm_ReceiveCommandHeader__SWIG_1(self, args); } } } } } } if (argc == 6) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDsm, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_int, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_int, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[3], &vptr, SWIGTYPE_p_long_long, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[4], &vptr, SWIGTYPE_p_long_long, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_int(argv[5], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfDsm_ReceiveCommandHeader__SWIG_0(self, args); } } } } } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfDsm_ReceiveCommandHeader'.\n" " Possible C/C++ prototypes are:\n" " ReceiveCommandHeader(XdmfDsm *,XdmfInt32 *,XdmfInt32 *,XdmfInt64 *,XdmfInt64 *,XdmfInt32)\n" " ReceiveCommandHeader(XdmfDsm *,XdmfInt32 *,XdmfInt32 *,XdmfInt64 *,XdmfInt64 *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsm_SendData(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsm *arg1 = (XdmfDsm *) 0 ; XdmfInt32 arg2 ; void *arg3 = (void *) 0 ; XdmfInt64 arg4 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; int res3 ; long long val4 ; int ecode4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOO:XdmfDsm_SendData",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsm_SendData" "', argument " "1"" of type '" "XdmfDsm *""'"); } arg1 = reinterpret_cast< XdmfDsm * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDsm_SendData" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); res3 = SWIG_ConvertPtr(obj2,SWIG_as_voidptrptr(&arg3), 0, 0); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfDsm_SendData" "', argument " "3"" of type '" "void *""'"); } ecode4 = SWIG_AsVal_long_SS_long(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfDsm_SendData" "', argument " "4"" of type '" "XdmfInt64""'"); } arg4 = static_cast< XdmfInt64 >(val4); result = (XdmfInt32)(arg1)->SendData(arg2,arg3,arg4); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsm_ReceiveData__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsm *arg1 = (XdmfDsm *) 0 ; XdmfInt32 arg2 ; void *arg3 = (void *) 0 ; XdmfInt64 arg4 ; XdmfInt32 arg5 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; int res3 ; long long val4 ; int ecode4 = 0 ; int val5 ; int ecode5 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOOO:XdmfDsm_ReceiveData",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsm_ReceiveData" "', argument " "1"" of type '" "XdmfDsm *""'"); } arg1 = reinterpret_cast< XdmfDsm * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDsm_ReceiveData" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); res3 = SWIG_ConvertPtr(obj2,SWIG_as_voidptrptr(&arg3), 0, 0); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfDsm_ReceiveData" "', argument " "3"" of type '" "void *""'"); } ecode4 = SWIG_AsVal_long_SS_long(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfDsm_ReceiveData" "', argument " "4"" of type '" "XdmfInt64""'"); } arg4 = static_cast< XdmfInt64 >(val4); ecode5 = SWIG_AsVal_int(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "XdmfDsm_ReceiveData" "', argument " "5"" of type '" "XdmfInt32""'"); } arg5 = static_cast< XdmfInt32 >(val5); result = (XdmfInt32)(arg1)->ReceiveData(arg2,arg3,arg4,arg5); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsm_ReceiveData__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsm *arg1 = (XdmfDsm *) 0 ; XdmfInt32 arg2 ; void *arg3 = (void *) 0 ; XdmfInt64 arg4 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; int res3 ; long long val4 ; int ecode4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOO:XdmfDsm_ReceiveData",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsm_ReceiveData" "', argument " "1"" of type '" "XdmfDsm *""'"); } arg1 = reinterpret_cast< XdmfDsm * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDsm_ReceiveData" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); res3 = SWIG_ConvertPtr(obj2,SWIG_as_voidptrptr(&arg3), 0, 0); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfDsm_ReceiveData" "', argument " "3"" of type '" "void *""'"); } ecode4 = SWIG_AsVal_long_SS_long(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfDsm_ReceiveData" "', argument " "4"" of type '" "XdmfInt64""'"); } arg4 = static_cast< XdmfInt64 >(val4); result = (XdmfInt32)(arg1)->ReceiveData(arg2,arg3,arg4); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsm_ReceiveData(PyObject *self, PyObject *args) { int argc; PyObject *argv[6]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 5); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 4) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDsm, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_int(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { void *ptr = 0; int res = SWIG_ConvertPtr(argv[2], &ptr, 0, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfDsm_ReceiveData__SWIG_1(self, args); } } } } } if (argc == 5) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDsm, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_int(argv[1], NULL); _v = SWIG_CheckState(res); } if (_v) { void *ptr = 0; int res = SWIG_ConvertPtr(argv[2], &ptr, 0, 0); _v = SWIG_CheckState(res); if (_v) { { int res = SWIG_AsVal_long_SS_long(argv[3], NULL); _v = SWIG_CheckState(res); } if (_v) { { int res = SWIG_AsVal_int(argv[4], NULL); _v = SWIG_CheckState(res); } if (_v) { return _wrap_XdmfDsm_ReceiveData__SWIG_0(self, args); } } } } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfDsm_ReceiveData'.\n" " Possible C/C++ prototypes are:\n" " ReceiveData(XdmfDsm *,XdmfInt32,void *,XdmfInt64,XdmfInt32)\n" " ReceiveData(XdmfDsm *,XdmfInt32,void *,XdmfInt64)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsm_Copy(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsm *arg1 = (XdmfDsm *) 0 ; XdmfDsm *arg2 = (XdmfDsm *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDsm_Copy",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsm_Copy" "', argument " "1"" of type '" "XdmfDsm *""'"); } arg1 = reinterpret_cast< XdmfDsm * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfDsm, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDsm_Copy" "', argument " "2"" of type '" "XdmfDsm *""'"); } arg2 = reinterpret_cast< XdmfDsm * >(argp2); result = (XdmfInt32)(arg1)->Copy(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsm_SendDone(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsm *arg1 = (XdmfDsm *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDsm_SendDone",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsm_SendDone" "', argument " "1"" of type '" "XdmfDsm *""'"); } arg1 = reinterpret_cast< XdmfDsm * >(argp1); result = (XdmfInt32)(arg1)->SendDone(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *XdmfDsm_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; SWIG_TypeNewClientData(SWIGTYPE_p_XdmfDsm, SWIG_NewClientData(obj)); return SWIG_Py_Void(); } SWIGINTERN PyObject *_wrap_new_XdmfDsmMsg(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmMsg *result = 0 ; if (!PyArg_ParseTuple(args,(char *)":new_XdmfDsmMsg")) SWIG_fail; result = (XdmfDsmMsg *)new XdmfDsmMsg(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfDsmMsg, SWIG_POINTER_NEW | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_delete_XdmfDsmMsg(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmMsg *arg1 = (XdmfDsmMsg *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:delete_XdmfDsmMsg",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmMsg, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_XdmfDsmMsg" "', argument " "1"" of type '" "XdmfDsmMsg *""'"); } arg1 = reinterpret_cast< XdmfDsmMsg * >(argp1); delete arg1; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmMsg_SetSource(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmMsg *arg1 = (XdmfDsmMsg *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDsmMsg_SetSource",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmMsg, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmMsg_SetSource" "', argument " "1"" of type '" "XdmfDsmMsg *""'"); } arg1 = reinterpret_cast< XdmfDsmMsg * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDsmMsg_SetSource" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetSource(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmMsg_GetSource(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmMsg *arg1 = (XdmfDsmMsg *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDsmMsg_GetSource",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmMsg, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmMsg_GetSource" "', argument " "1"" of type '" "XdmfDsmMsg *""'"); } arg1 = reinterpret_cast< XdmfDsmMsg * >(argp1); result = (XdmfInt32)(arg1)->GetSource(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmMsg_SetDest(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmMsg *arg1 = (XdmfDsmMsg *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDsmMsg_SetDest",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmMsg, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmMsg_SetDest" "', argument " "1"" of type '" "XdmfDsmMsg *""'"); } arg1 = reinterpret_cast< XdmfDsmMsg * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDsmMsg_SetDest" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetDest(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmMsg_GetDest(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmMsg *arg1 = (XdmfDsmMsg *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDsmMsg_GetDest",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmMsg, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmMsg_GetDest" "', argument " "1"" of type '" "XdmfDsmMsg *""'"); } arg1 = reinterpret_cast< XdmfDsmMsg * >(argp1); result = (XdmfInt32)(arg1)->GetDest(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmMsg_SetTag(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmMsg *arg1 = (XdmfDsmMsg *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDsmMsg_SetTag",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmMsg, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmMsg_SetTag" "', argument " "1"" of type '" "XdmfDsmMsg *""'"); } arg1 = reinterpret_cast< XdmfDsmMsg * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDsmMsg_SetTag" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetTag(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmMsg_GetTag(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmMsg *arg1 = (XdmfDsmMsg *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDsmMsg_GetTag",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmMsg, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmMsg_GetTag" "', argument " "1"" of type '" "XdmfDsmMsg *""'"); } arg1 = reinterpret_cast< XdmfDsmMsg * >(argp1); result = (XdmfInt32)(arg1)->GetTag(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmMsg_SetLength(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmMsg *arg1 = (XdmfDsmMsg *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDsmMsg_SetLength",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmMsg, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmMsg_SetLength" "', argument " "1"" of type '" "XdmfDsmMsg *""'"); } arg1 = reinterpret_cast< XdmfDsmMsg * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDsmMsg_SetLength" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfInt32)(arg1)->SetLength(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmMsg_GetLength(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmMsg *arg1 = (XdmfDsmMsg *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt64 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDsmMsg_GetLength",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmMsg, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmMsg_GetLength" "', argument " "1"" of type '" "XdmfDsmMsg *""'"); } arg1 = reinterpret_cast< XdmfDsmMsg * >(argp1); result = (XdmfInt64)(arg1)->GetLength(); resultobj = SWIG_From_long_SS_long(static_cast< long long >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmMsg_SetData(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmMsg *arg1 = (XdmfDsmMsg *) 0 ; void *arg2 = (void *) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDsmMsg_SetData",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmMsg, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmMsg_SetData" "', argument " "1"" of type '" "XdmfDsmMsg *""'"); } arg1 = reinterpret_cast< XdmfDsmMsg * >(argp1); res2 = SWIG_ConvertPtr(obj1,SWIG_as_voidptrptr(&arg2), 0, 0); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDsmMsg_SetData" "', argument " "2"" of type '" "void *""'"); } result = (XdmfInt32)(arg1)->SetData(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmMsg_GetData(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmMsg *arg1 = (XdmfDsmMsg *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; void *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDsmMsg_GetData",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmMsg, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmMsg_GetData" "', argument " "1"" of type '" "XdmfDsmMsg *""'"); } arg1 = reinterpret_cast< XdmfDsmMsg * >(argp1); result = (void *)(arg1)->GetData(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_void, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmMsg_Source_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmMsg *arg1 = (XdmfDsmMsg *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDsmMsg_Source_set",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmMsg, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmMsg_Source_set" "', argument " "1"" of type '" "XdmfDsmMsg *""'"); } arg1 = reinterpret_cast< XdmfDsmMsg * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDsmMsg_Source_set" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); if (arg1) (arg1)->Source = arg2; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmMsg_Source_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmMsg *arg1 = (XdmfDsmMsg *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDsmMsg_Source_get",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmMsg, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmMsg_Source_get" "', argument " "1"" of type '" "XdmfDsmMsg *""'"); } arg1 = reinterpret_cast< XdmfDsmMsg * >(argp1); result = (XdmfInt32) ((arg1)->Source); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmMsg_Dest_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmMsg *arg1 = (XdmfDsmMsg *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDsmMsg_Dest_set",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmMsg, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmMsg_Dest_set" "', argument " "1"" of type '" "XdmfDsmMsg *""'"); } arg1 = reinterpret_cast< XdmfDsmMsg * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDsmMsg_Dest_set" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); if (arg1) (arg1)->Dest = arg2; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmMsg_Dest_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmMsg *arg1 = (XdmfDsmMsg *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDsmMsg_Dest_get",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmMsg, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmMsg_Dest_get" "', argument " "1"" of type '" "XdmfDsmMsg *""'"); } arg1 = reinterpret_cast< XdmfDsmMsg * >(argp1); result = (XdmfInt32) ((arg1)->Dest); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmMsg_Tag_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmMsg *arg1 = (XdmfDsmMsg *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDsmMsg_Tag_set",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmMsg, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmMsg_Tag_set" "', argument " "1"" of type '" "XdmfDsmMsg *""'"); } arg1 = reinterpret_cast< XdmfDsmMsg * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDsmMsg_Tag_set" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); if (arg1) (arg1)->Tag = arg2; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmMsg_Tag_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmMsg *arg1 = (XdmfDsmMsg *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDsmMsg_Tag_get",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmMsg, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmMsg_Tag_get" "', argument " "1"" of type '" "XdmfDsmMsg *""'"); } arg1 = reinterpret_cast< XdmfDsmMsg * >(argp1); result = (XdmfInt32) ((arg1)->Tag); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmMsg_Length_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmMsg *arg1 = (XdmfDsmMsg *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDsmMsg_Length_set",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmMsg, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmMsg_Length_set" "', argument " "1"" of type '" "XdmfDsmMsg *""'"); } arg1 = reinterpret_cast< XdmfDsmMsg * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDsmMsg_Length_set" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); if (arg1) (arg1)->Length = arg2; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmMsg_Length_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmMsg *arg1 = (XdmfDsmMsg *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt64 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDsmMsg_Length_get",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmMsg, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmMsg_Length_get" "', argument " "1"" of type '" "XdmfDsmMsg *""'"); } arg1 = reinterpret_cast< XdmfDsmMsg * >(argp1); result = (XdmfInt64) ((arg1)->Length); resultobj = SWIG_From_long_SS_long(static_cast< long long >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmMsg_Data_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmMsg *arg1 = (XdmfDsmMsg *) 0 ; void *arg2 = (void *) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDsmMsg_Data_set",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmMsg, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmMsg_Data_set" "', argument " "1"" of type '" "XdmfDsmMsg *""'"); } arg1 = reinterpret_cast< XdmfDsmMsg * >(argp1); res2 = SWIG_ConvertPtr(obj1,SWIG_as_voidptrptr(&arg2), 0, SWIG_POINTER_DISOWN); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDsmMsg_Data_set" "', argument " "2"" of type '" "void *""'"); } if (arg1) (arg1)->Data = arg2; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmMsg_Data_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmMsg *arg1 = (XdmfDsmMsg *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; void *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDsmMsg_Data_get",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmMsg, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmMsg_Data_get" "', argument " "1"" of type '" "XdmfDsmMsg *""'"); } arg1 = reinterpret_cast< XdmfDsmMsg * >(argp1); result = (void *) ((arg1)->Data); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_void, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *XdmfDsmMsg_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; SWIG_TypeNewClientData(SWIGTYPE_p_XdmfDsmMsg, SWIG_NewClientData(obj)); return SWIG_Py_Void(); } SWIGINTERN PyObject *_wrap_XdmfDsmBufferServiceThread(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; void *arg1 = (void *) 0 ; int res1 ; PyObject * obj0 = 0 ; void *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDsmBufferServiceThread",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0,SWIG_as_voidptrptr(&arg1), 0, 0); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmBufferServiceThread" "', argument " "1"" of type '" "void *""'"); } result = (void *)XdmfDsmBufferServiceThread(arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_void, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_new_XdmfDsmBuffer(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmBuffer *result = 0 ; if (!PyArg_ParseTuple(args,(char *)":new_XdmfDsmBuffer")) SWIG_fail; result = (XdmfDsmBuffer *)new XdmfDsmBuffer(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfDsmBuffer, SWIG_POINTER_NEW | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_delete_XdmfDsmBuffer(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmBuffer *arg1 = (XdmfDsmBuffer *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:delete_XdmfDsmBuffer",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmBuffer, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_XdmfDsmBuffer" "', argument " "1"" of type '" "XdmfDsmBuffer *""'"); } arg1 = reinterpret_cast< XdmfDsmBuffer * >(argp1); delete arg1; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmBuffer_GetClassName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmBuffer *arg1 = (XdmfDsmBuffer *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDsmBuffer_GetClassName",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmBuffer, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmBuffer_GetClassName" "', argument " "1"" of type '" "XdmfDsmBuffer *""'"); } arg1 = reinterpret_cast< XdmfDsmBuffer * >(argp1); result = (XdmfConstString)(arg1)->GetClassName(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmBuffer_GetThreadDsmReady(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmBuffer *arg1 = (XdmfDsmBuffer *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDsmBuffer_GetThreadDsmReady",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmBuffer, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmBuffer_GetThreadDsmReady" "', argument " "1"" of type '" "XdmfDsmBuffer *""'"); } arg1 = reinterpret_cast< XdmfDsmBuffer * >(argp1); result = (XdmfInt32)(arg1)->GetThreadDsmReady(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmBuffer_SetThreadDsmReady(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmBuffer *arg1 = (XdmfDsmBuffer *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDsmBuffer_SetThreadDsmReady",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmBuffer, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmBuffer_SetThreadDsmReady" "', argument " "1"" of type '" "XdmfDsmBuffer *""'"); } arg1 = reinterpret_cast< XdmfDsmBuffer * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDsmBuffer_SetThreadDsmReady" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetThreadDsmReady(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmBuffer_Put(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmBuffer *arg1 = (XdmfDsmBuffer *) 0 ; XdmfInt64 arg2 ; XdmfInt64 arg3 ; void *arg4 = (void *) 0 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; long long val3 ; int ecode3 = 0 ; int res4 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOO:XdmfDsmBuffer_Put",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmBuffer, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmBuffer_Put" "', argument " "1"" of type '" "XdmfDsmBuffer *""'"); } arg1 = reinterpret_cast< XdmfDsmBuffer * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDsmBuffer_Put" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); ecode3 = SWIG_AsVal_long_SS_long(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "XdmfDsmBuffer_Put" "', argument " "3"" of type '" "XdmfInt64""'"); } arg3 = static_cast< XdmfInt64 >(val3); res4 = SWIG_ConvertPtr(obj3,SWIG_as_voidptrptr(&arg4), 0, 0); if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "XdmfDsmBuffer_Put" "', argument " "4"" of type '" "void *""'"); } result = (XdmfInt32)(arg1)->Put(arg2,arg3,arg4); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmBuffer_Get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmBuffer *arg1 = (XdmfDsmBuffer *) 0 ; XdmfInt64 arg2 ; XdmfInt64 arg3 ; void *arg4 = (void *) 0 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; long long val3 ; int ecode3 = 0 ; int res4 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OOOO:XdmfDsmBuffer_Get",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmBuffer, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmBuffer_Get" "', argument " "1"" of type '" "XdmfDsmBuffer *""'"); } arg1 = reinterpret_cast< XdmfDsmBuffer * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDsmBuffer_Get" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); ecode3 = SWIG_AsVal_long_SS_long(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "XdmfDsmBuffer_Get" "', argument " "3"" of type '" "XdmfInt64""'"); } arg3 = static_cast< XdmfInt64 >(val3); res4 = SWIG_ConvertPtr(obj3,SWIG_as_voidptrptr(&arg4), 0, 0); if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "XdmfDsmBuffer_Get" "', argument " "4"" of type '" "void *""'"); } result = (XdmfInt32)(arg1)->Get(arg2,arg3,arg4); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmBuffer_Aquire(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmBuffer *arg1 = (XdmfDsmBuffer *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDsmBuffer_Aquire",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmBuffer, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmBuffer_Aquire" "', argument " "1"" of type '" "XdmfDsmBuffer *""'"); } arg1 = reinterpret_cast< XdmfDsmBuffer * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDsmBuffer_Aquire" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfInt32)(arg1)->Aquire(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmBuffer_Release(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmBuffer *arg1 = (XdmfDsmBuffer *) 0 ; XdmfInt64 arg2 ; void *argp1 = 0 ; int res1 = 0 ; long long val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDsmBuffer_Release",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmBuffer, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmBuffer_Release" "', argument " "1"" of type '" "XdmfDsmBuffer *""'"); } arg1 = reinterpret_cast< XdmfDsmBuffer * >(argp1); ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDsmBuffer_Release" "', argument " "2"" of type '" "XdmfInt64""'"); } arg2 = static_cast< XdmfInt64 >(val2); result = (XdmfInt32)(arg1)->Release(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmBuffer_ServiceInit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmBuffer *arg1 = (XdmfDsmBuffer *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDsmBuffer_ServiceInit",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmBuffer, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmBuffer_ServiceInit" "', argument " "1"" of type '" "XdmfDsmBuffer *""'"); } arg1 = reinterpret_cast< XdmfDsmBuffer * >(argp1); result = (XdmfInt32)(arg1)->ServiceInit(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmBuffer_ServiceOnce__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmBuffer *arg1 = (XdmfDsmBuffer *) 0 ; XdmfInt32 *arg2 = (XdmfInt32 *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDsmBuffer_ServiceOnce",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmBuffer, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmBuffer_ServiceOnce" "', argument " "1"" of type '" "XdmfDsmBuffer *""'"); } arg1 = reinterpret_cast< XdmfDsmBuffer * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_int, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDsmBuffer_ServiceOnce" "', argument " "2"" of type '" "XdmfInt32 *""'"); } arg2 = reinterpret_cast< XdmfInt32 * >(argp2); result = (XdmfInt32)(arg1)->ServiceOnce(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmBuffer_ServiceOnce__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmBuffer *arg1 = (XdmfDsmBuffer *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDsmBuffer_ServiceOnce",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmBuffer, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmBuffer_ServiceOnce" "', argument " "1"" of type '" "XdmfDsmBuffer *""'"); } arg1 = reinterpret_cast< XdmfDsmBuffer * >(argp1); result = (XdmfInt32)(arg1)->ServiceOnce(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmBuffer_ServiceOnce(PyObject *self, PyObject *args) { int argc; PyObject *argv[3]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 2); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDsmBuffer, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfDsmBuffer_ServiceOnce__SWIG_1(self, args); } } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDsmBuffer, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_int, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfDsmBuffer_ServiceOnce__SWIG_0(self, args); } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfDsmBuffer_ServiceOnce'.\n" " Possible C/C++ prototypes are:\n" " ServiceOnce(XdmfDsmBuffer *,XdmfInt32 *)\n" " ServiceOnce(XdmfDsmBuffer *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmBuffer_ServiceUntilIdle__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmBuffer *arg1 = (XdmfDsmBuffer *) 0 ; XdmfInt32 *arg2 = (XdmfInt32 *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDsmBuffer_ServiceUntilIdle",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmBuffer, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmBuffer_ServiceUntilIdle" "', argument " "1"" of type '" "XdmfDsmBuffer *""'"); } arg1 = reinterpret_cast< XdmfDsmBuffer * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_int, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDsmBuffer_ServiceUntilIdle" "', argument " "2"" of type '" "XdmfInt32 *""'"); } arg2 = reinterpret_cast< XdmfInt32 * >(argp2); result = (XdmfInt32)(arg1)->ServiceUntilIdle(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmBuffer_ServiceUntilIdle__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmBuffer *arg1 = (XdmfDsmBuffer *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDsmBuffer_ServiceUntilIdle",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmBuffer, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmBuffer_ServiceUntilIdle" "', argument " "1"" of type '" "XdmfDsmBuffer *""'"); } arg1 = reinterpret_cast< XdmfDsmBuffer * >(argp1); result = (XdmfInt32)(arg1)->ServiceUntilIdle(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmBuffer_ServiceUntilIdle(PyObject *self, PyObject *args) { int argc; PyObject *argv[3]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 2); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDsmBuffer, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfDsmBuffer_ServiceUntilIdle__SWIG_1(self, args); } } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDsmBuffer, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_int, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfDsmBuffer_ServiceUntilIdle__SWIG_0(self, args); } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfDsmBuffer_ServiceUntilIdle'.\n" " Possible C/C++ prototypes are:\n" " ServiceUntilIdle(XdmfDsmBuffer *,XdmfInt32 *)\n" " ServiceUntilIdle(XdmfDsmBuffer *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmBuffer_ServiceLoop__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmBuffer *arg1 = (XdmfDsmBuffer *) 0 ; XdmfInt32 *arg2 = (XdmfInt32 *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDsmBuffer_ServiceLoop",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmBuffer, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmBuffer_ServiceLoop" "', argument " "1"" of type '" "XdmfDsmBuffer *""'"); } arg1 = reinterpret_cast< XdmfDsmBuffer * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_int, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDsmBuffer_ServiceLoop" "', argument " "2"" of type '" "XdmfInt32 *""'"); } arg2 = reinterpret_cast< XdmfInt32 * >(argp2); result = (XdmfInt32)(arg1)->ServiceLoop(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmBuffer_ServiceLoop__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmBuffer *arg1 = (XdmfDsmBuffer *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDsmBuffer_ServiceLoop",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmBuffer, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmBuffer_ServiceLoop" "', argument " "1"" of type '" "XdmfDsmBuffer *""'"); } arg1 = reinterpret_cast< XdmfDsmBuffer * >(argp1); result = (XdmfInt32)(arg1)->ServiceLoop(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmBuffer_ServiceLoop(PyObject *self, PyObject *args) { int argc; PyObject *argv[3]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 2); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDsmBuffer, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfDsmBuffer_ServiceLoop__SWIG_1(self, args); } } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDsmBuffer, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_int, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfDsmBuffer_ServiceLoop__SWIG_0(self, args); } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfDsmBuffer_ServiceLoop'.\n" " Possible C/C++ prototypes are:\n" " ServiceLoop(XdmfDsmBuffer *,XdmfInt32 *)\n" " ServiceLoop(XdmfDsmBuffer *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmBuffer_Service__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmBuffer *arg1 = (XdmfDsmBuffer *) 0 ; XdmfInt32 *arg2 = (XdmfInt32 *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDsmBuffer_Service",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmBuffer, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmBuffer_Service" "', argument " "1"" of type '" "XdmfDsmBuffer *""'"); } arg1 = reinterpret_cast< XdmfDsmBuffer * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_int, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDsmBuffer_Service" "', argument " "2"" of type '" "XdmfInt32 *""'"); } arg2 = reinterpret_cast< XdmfInt32 * >(argp2); result = (XdmfInt32)(arg1)->Service(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmBuffer_Service__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmBuffer *arg1 = (XdmfDsmBuffer *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDsmBuffer_Service",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmBuffer, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmBuffer_Service" "', argument " "1"" of type '" "XdmfDsmBuffer *""'"); } arg1 = reinterpret_cast< XdmfDsmBuffer * >(argp1); result = (XdmfInt32)(arg1)->Service(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmBuffer_Service(PyObject *self, PyObject *args) { int argc; PyObject *argv[3]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 2); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDsmBuffer, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfDsmBuffer_Service__SWIG_1(self, args); } } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfDsmBuffer, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_int, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_XdmfDsmBuffer_Service__SWIG_0(self, args); } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfDsmBuffer_Service'.\n" " Possible C/C++ prototypes are:\n" " Service(XdmfDsmBuffer *,XdmfInt32 *)\n" " Service(XdmfDsmBuffer *)\n"); return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmBuffer_ServiceThread(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmBuffer *arg1 = (XdmfDsmBuffer *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; void *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDsmBuffer_ServiceThread",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmBuffer, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmBuffer_ServiceThread" "', argument " "1"" of type '" "XdmfDsmBuffer *""'"); } arg1 = reinterpret_cast< XdmfDsmBuffer * >(argp1); result = (void *)(arg1)->ServiceThread(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_void, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *XdmfDsmBuffer_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; SWIG_TypeNewClientData(SWIGTYPE_p_XdmfDsmBuffer, SWIG_NewClientData(obj)); return SWIG_Py_Void(); } SWIGINTERN PyObject *_wrap_new_XdmfDsmComm(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmComm *result = 0 ; if (!PyArg_ParseTuple(args,(char *)":new_XdmfDsmComm")) SWIG_fail; result = (XdmfDsmComm *)new XdmfDsmComm(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_XdmfDsmComm, SWIG_POINTER_NEW | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_delete_XdmfDsmComm(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmComm *arg1 = (XdmfDsmComm *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:delete_XdmfDsmComm",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmComm, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_XdmfDsmComm" "', argument " "1"" of type '" "XdmfDsmComm *""'"); } arg1 = reinterpret_cast< XdmfDsmComm * >(argp1); delete arg1; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmComm_GetClassName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmComm *arg1 = (XdmfDsmComm *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfConstString result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDsmComm_GetClassName",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmComm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmComm_GetClassName" "', argument " "1"" of type '" "XdmfDsmComm *""'"); } arg1 = reinterpret_cast< XdmfDsmComm * >(argp1); result = (XdmfConstString)(arg1)->GetClassName(); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmComm_GetId(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmComm *arg1 = (XdmfDsmComm *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDsmComm_GetId",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmComm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmComm_GetId" "', argument " "1"" of type '" "XdmfDsmComm *""'"); } arg1 = reinterpret_cast< XdmfDsmComm * >(argp1); result = (XdmfInt32)(arg1)->GetId(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmComm_SetId(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmComm *arg1 = (XdmfDsmComm *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDsmComm_SetId",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmComm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmComm_SetId" "', argument " "1"" of type '" "XdmfDsmComm *""'"); } arg1 = reinterpret_cast< XdmfDsmComm * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDsmComm_SetId" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetId(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmComm_GetTotalSize(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmComm *arg1 = (XdmfDsmComm *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDsmComm_GetTotalSize",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmComm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmComm_GetTotalSize" "', argument " "1"" of type '" "XdmfDsmComm *""'"); } arg1 = reinterpret_cast< XdmfDsmComm * >(argp1); result = (XdmfInt32)(arg1)->GetTotalSize(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmComm_SetTotalSize(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmComm *arg1 = (XdmfDsmComm *) 0 ; XdmfInt32 arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDsmComm_SetTotalSize",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmComm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmComm_SetTotalSize" "', argument " "1"" of type '" "XdmfDsmComm *""'"); } arg1 = reinterpret_cast< XdmfDsmComm * >(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "XdmfDsmComm_SetTotalSize" "', argument " "2"" of type '" "XdmfInt32""'"); } arg2 = static_cast< XdmfInt32 >(val2); result = (XdmfInt32)(arg1)->SetTotalSize(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmComm_Init(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmComm *arg1 = (XdmfDsmComm *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDsmComm_Init",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmComm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmComm_Init" "', argument " "1"" of type '" "XdmfDsmComm *""'"); } arg1 = reinterpret_cast< XdmfDsmComm * >(argp1); result = (XdmfInt32)(arg1)->Init(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmComm_Send(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmComm *arg1 = (XdmfDsmComm *) 0 ; XdmfDsmMsg *arg2 = (XdmfDsmMsg *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDsmComm_Send",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmComm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmComm_Send" "', argument " "1"" of type '" "XdmfDsmComm *""'"); } arg1 = reinterpret_cast< XdmfDsmComm * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfDsmMsg, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDsmComm_Send" "', argument " "2"" of type '" "XdmfDsmMsg *""'"); } arg2 = reinterpret_cast< XdmfDsmMsg * >(argp2); result = (XdmfInt32)(arg1)->Send(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmComm_Receive(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmComm *arg1 = (XdmfDsmComm *) 0 ; XdmfDsmMsg *arg2 = (XdmfDsmMsg *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDsmComm_Receive",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmComm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmComm_Receive" "', argument " "1"" of type '" "XdmfDsmComm *""'"); } arg1 = reinterpret_cast< XdmfDsmComm * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfDsmMsg, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDsmComm_Receive" "', argument " "2"" of type '" "XdmfDsmMsg *""'"); } arg2 = reinterpret_cast< XdmfDsmMsg * >(argp2); result = (XdmfInt32)(arg1)->Receive(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmComm_Check(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmComm *arg1 = (XdmfDsmComm *) 0 ; XdmfDsmMsg *arg2 = (XdmfDsmMsg *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"OO:XdmfDsmComm_Check",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmComm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmComm_Check" "', argument " "1"" of type '" "XdmfDsmComm *""'"); } arg1 = reinterpret_cast< XdmfDsmComm * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfDsmMsg, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfDsmComm_Check" "', argument " "2"" of type '" "XdmfDsmMsg *""'"); } arg2 = reinterpret_cast< XdmfDsmMsg * >(argp2); result = (XdmfInt32)(arg1)->Check(arg2); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_XdmfDsmComm_Barrier(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; XdmfDsmComm *arg1 = (XdmfDsmComm *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; XdmfInt32 result; if (!PyArg_ParseTuple(args,(char *)"O:XdmfDsmComm_Barrier",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDsmComm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDsmComm_Barrier" "', argument " "1"" of type '" "XdmfDsmComm *""'"); } arg1 = reinterpret_cast< XdmfDsmComm * >(argp1); result = (XdmfInt32)(arg1)->Barrier(); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *XdmfDsmComm_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; SWIG_TypeNewClientData(SWIGTYPE_p_XdmfDsmComm, SWIG_NewClientData(obj)); return SWIG_Py_Void(); } static PyMethodDef SwigMethods[] = { { (char *)"SWIG_PyInstanceMethod_New", (PyCFunction)SWIG_PyInstanceMethod_New, METH_O, NULL}, { (char *)"new_XdmfObject", _wrap_new_XdmfObject, METH_VARARGS, NULL}, { (char *)"delete_XdmfObject", _wrap_delete_XdmfObject, METH_VARARGS, NULL}, { (char *)"XdmfObject_GetClassName", _wrap_XdmfObject_GetClassName, METH_VARARGS, NULL}, { (char *)"XdmfObject_SetDebug", _wrap_XdmfObject_SetDebug, METH_VARARGS, NULL}, { (char *)"XdmfObject_GetDebug", _wrap_XdmfObject_GetDebug, METH_VARARGS, NULL}, { (char *)"XdmfObject_GetGlobalDebug", _wrap_XdmfObject_GetGlobalDebug, METH_VARARGS, NULL}, { (char *)"XdmfObject_SetGlobalDebug", _wrap_XdmfObject_SetGlobalDebug, METH_VARARGS, NULL}, { (char *)"XdmfObject_DebugOn", _wrap_XdmfObject_DebugOn, METH_VARARGS, NULL}, { (char *)"XdmfObject_DebugOff", _wrap_XdmfObject_DebugOff, METH_VARARGS, NULL}, { (char *)"XdmfObject_GlobalDebugOn", _wrap_XdmfObject_GlobalDebugOn, METH_VARARGS, NULL}, { (char *)"XdmfObject_GlobalDebugOff", _wrap_XdmfObject_GlobalDebugOff, METH_VARARGS, NULL}, { (char *)"XdmfObject_GetUniqueName", _wrap_XdmfObject_GetUniqueName, METH_VARARGS, NULL}, { (char *)"XdmfObject_swigregister", XdmfObject_swigregister, METH_VARARGS, NULL}, { (char *)"SetGlobalDebugOn", _wrap_SetGlobalDebugOn, METH_VARARGS, NULL}, { (char *)"SetGlobalDebugOff", _wrap_SetGlobalDebugOff, METH_VARARGS, NULL}, { (char *)"GetGlobalDebug", _wrap_GetGlobalDebug, METH_VARARGS, NULL}, { (char *)"SetGlobalDebug", _wrap_SetGlobalDebug, METH_VARARGS, NULL}, { (char *)"GetUnique", _wrap_GetUnique, METH_VARARGS, NULL}, { (char *)"XdmfObjectToHandle", _wrap_XdmfObjectToHandle, METH_VARARGS, NULL}, { (char *)"HandleToXdmfObject", _wrap_HandleToXdmfObject, METH_VARARGS, NULL}, { (char *)"VoidPointerHandleToXdmfPointer", _wrap_VoidPointerHandleToXdmfPointer, METH_VARARGS, NULL}, { (char *)"new_XdmfLightData", _wrap_new_XdmfLightData, METH_VARARGS, NULL}, { (char *)"delete_XdmfLightData", _wrap_delete_XdmfLightData, METH_VARARGS, NULL}, { (char *)"XdmfLightData_GetClassName", _wrap_XdmfLightData_GetClassName, METH_VARARGS, NULL}, { (char *)"XdmfLightData_SetName", _wrap_XdmfLightData_SetName, METH_VARARGS, NULL}, { (char *)"XdmfLightData_GetName", _wrap_XdmfLightData_GetName, METH_VARARGS, NULL}, { (char *)"XdmfLightData_SetFileName", _wrap_XdmfLightData_SetFileName, METH_VARARGS, NULL}, { (char *)"XdmfLightData_GetFileName", _wrap_XdmfLightData_GetFileName, METH_VARARGS, NULL}, { (char *)"XdmfLightData_SetWorkingDirectory", _wrap_XdmfLightData_SetWorkingDirectory, METH_VARARGS, NULL}, { (char *)"XdmfLightData_GetWorkingDirectory", _wrap_XdmfLightData_GetWorkingDirectory, METH_VARARGS, NULL}, { (char *)"XdmfLightData_GetInitialized", _wrap_XdmfLightData_GetInitialized, METH_VARARGS, NULL}, { (char *)"XdmfLightData_SetInitialized", _wrap_XdmfLightData_SetInitialized, METH_VARARGS, NULL}, { (char *)"XdmfLightData_GetReturnBuffer", _wrap_XdmfLightData_GetReturnBuffer, METH_VARARGS, NULL}, { (char *)"XdmfLightData_swigregister", XdmfLightData_swigregister, METH_VARARGS, NULL}, { (char *)"new_XdmfElement", _wrap_new_XdmfElement, METH_VARARGS, NULL}, { (char *)"delete_XdmfElement", _wrap_delete_XdmfElement, METH_VARARGS, NULL}, { (char *)"XdmfElement_GetClassName", _wrap_XdmfElement_GetClassName, METH_VARARGS, NULL}, { (char *)"XdmfElement_SetDOM", _wrap_XdmfElement_SetDOM, METH_VARARGS, NULL}, { (char *)"XdmfElement_GetDOM", _wrap_XdmfElement_GetDOM, METH_VARARGS, NULL}, { (char *)"XdmfElement_SetState", _wrap_XdmfElement_SetState, METH_VARARGS, NULL}, { (char *)"XdmfElement_GetState", _wrap_XdmfElement_GetState, METH_VARARGS, NULL}, { (char *)"XdmfElement_SetIsReference", _wrap_XdmfElement_SetIsReference, METH_VARARGS, NULL}, { (char *)"XdmfElement_GetIsReference", _wrap_XdmfElement_GetIsReference, METH_VARARGS, NULL}, { (char *)"XdmfElement_CheckForReference", _wrap_XdmfElement_CheckForReference, METH_VARARGS, NULL}, { (char *)"XdmfElement_InsertChildElement", _wrap_XdmfElement_InsertChildElement, METH_VARARGS, NULL}, { (char *)"XdmfElement_Serialize", _wrap_XdmfElement_Serialize, METH_VARARGS, NULL}, { (char *)"XdmfElement_SetElement", _wrap_XdmfElement_SetElement, METH_VARARGS, NULL}, { (char *)"XdmfElement_GetElement", _wrap_XdmfElement_GetElement, METH_VARARGS, NULL}, { (char *)"XdmfElement_SetCopyReferenceData", _wrap_XdmfElement_SetCopyReferenceData, METH_VARARGS, NULL}, { (char *)"XdmfElement_GetCopyReferenceData", _wrap_XdmfElement_GetCopyReferenceData, METH_VARARGS, NULL}, { (char *)"XdmfElement_GetElementName", _wrap_XdmfElement_GetElementName, METH_VARARGS, NULL}, { (char *)"XdmfElement_SetElementName", _wrap_XdmfElement_SetElementName, METH_VARARGS, NULL}, { (char *)"XdmfElement_GetDataXml", _wrap_XdmfElement_GetDataXml, METH_VARARGS, NULL}, { (char *)"XdmfElement_SetDataXml", _wrap_XdmfElement_SetDataXml, METH_VARARGS, NULL}, { (char *)"XdmfElement_GetInsertedDataXml", _wrap_XdmfElement_GetInsertedDataXml, METH_VARARGS, NULL}, { (char *)"XdmfElement_SetInsertedDataXml", _wrap_XdmfElement_SetInsertedDataXml, METH_VARARGS, NULL}, { (char *)"XdmfElement_BuildFromDataXml", _wrap_XdmfElement_BuildFromDataXml, METH_VARARGS, NULL}, { (char *)"XdmfElement_GetElementType", _wrap_XdmfElement_GetElementType, METH_VARARGS, NULL}, { (char *)"XdmfElement_UpdateInformation", _wrap_XdmfElement_UpdateInformation, METH_VARARGS, NULL}, { (char *)"XdmfElement_Update", _wrap_XdmfElement_Update, METH_VARARGS, NULL}, { (char *)"XdmfElement_Build", _wrap_XdmfElement_Build, METH_VARARGS, NULL}, { (char *)"XdmfElement_Set", _wrap_XdmfElement_Set, METH_VARARGS, NULL}, { (char *)"XdmfElement_Get", _wrap_XdmfElement_Get, METH_VARARGS, NULL}, { (char *)"XdmfElement_Copy", _wrap_XdmfElement_Copy, METH_VARARGS, NULL}, { (char *)"XdmfElement_Insert", _wrap_XdmfElement_Insert, METH_VARARGS, NULL}, { (char *)"XdmfElement_FollowReference", _wrap_XdmfElement_FollowReference, METH_VARARGS, NULL}, { (char *)"XdmfElement_GetDsmBuffer", _wrap_XdmfElement_GetDsmBuffer, METH_VARARGS, NULL}, { (char *)"XdmfElement_SetDsmBuffer", _wrap_XdmfElement_SetDsmBuffer, METH_VARARGS, NULL}, { (char *)"XdmfElement_SetDeleteOnGridDelete", _wrap_XdmfElement_SetDeleteOnGridDelete, METH_VARARGS, NULL}, { (char *)"XdmfElement_GetDeleteOnGridDelete", _wrap_XdmfElement_GetDeleteOnGridDelete, METH_VARARGS, NULL}, { (char *)"XdmfElement_swigregister", XdmfElement_swigregister, METH_VARARGS, NULL}, { (char *)"new_XdmfAttribute", _wrap_new_XdmfAttribute, METH_VARARGS, NULL}, { (char *)"delete_XdmfAttribute", _wrap_delete_XdmfAttribute, METH_VARARGS, NULL}, { (char *)"XdmfAttribute_GetClassName", _wrap_XdmfAttribute_GetClassName, METH_VARARGS, NULL}, { (char *)"XdmfAttribute_SetAttributeType", _wrap_XdmfAttribute_SetAttributeType, METH_VARARGS, NULL}, { (char *)"XdmfAttribute_GetAttributeType", _wrap_XdmfAttribute_GetAttributeType, METH_VARARGS, NULL}, { (char *)"XdmfAttribute_SetLightDataLimit", _wrap_XdmfAttribute_SetLightDataLimit, METH_VARARGS, NULL}, { (char *)"XdmfAttribute_GetLightDataLimit", _wrap_XdmfAttribute_GetLightDataLimit, METH_VARARGS, NULL}, { (char *)"XdmfAttribute_SetActive", _wrap_XdmfAttribute_SetActive, METH_VARARGS, NULL}, { (char *)"XdmfAttribute_GetActive", _wrap_XdmfAttribute_GetActive, METH_VARARGS, NULL}, { (char *)"XdmfAttribute_Insert", _wrap_XdmfAttribute_Insert, METH_VARARGS, NULL}, { (char *)"XdmfAttribute_SetAttributeTypeFromString", _wrap_XdmfAttribute_SetAttributeTypeFromString, METH_VARARGS, NULL}, { (char *)"XdmfAttribute_GetAttributeTypeAsString", _wrap_XdmfAttribute_GetAttributeTypeAsString, METH_VARARGS, NULL}, { (char *)"XdmfAttribute_SetAttributeCenterFromString", _wrap_XdmfAttribute_SetAttributeCenterFromString, METH_VARARGS, NULL}, { (char *)"XdmfAttribute_GetAttributeCenterAsString", _wrap_XdmfAttribute_GetAttributeCenterAsString, METH_VARARGS, NULL}, { (char *)"XdmfAttribute_SetAttributeCenter", _wrap_XdmfAttribute_SetAttributeCenter, METH_VARARGS, NULL}, { (char *)"XdmfAttribute_GetAttributeCenter", _wrap_XdmfAttribute_GetAttributeCenter, METH_VARARGS, NULL}, { (char *)"XdmfAttribute_GetUnits", _wrap_XdmfAttribute_GetUnits, METH_VARARGS, NULL}, { (char *)"XdmfAttribute_SetUnits", _wrap_XdmfAttribute_SetUnits, METH_VARARGS, NULL}, { (char *)"XdmfAttribute_GetShapeDesc", _wrap_XdmfAttribute_GetShapeDesc, METH_VARARGS, NULL}, { (char *)"XdmfAttribute_SetValues", _wrap_XdmfAttribute_SetValues, METH_VARARGS, NULL}, { (char *)"XdmfAttribute_GetValues", _wrap_XdmfAttribute_GetValues, METH_VARARGS, NULL}, { (char *)"XdmfAttribute_UpdateInformation", _wrap_XdmfAttribute_UpdateInformation, METH_VARARGS, NULL}, { (char *)"XdmfAttribute_Update", _wrap_XdmfAttribute_Update, METH_VARARGS, NULL}, { (char *)"XdmfAttribute_Build", _wrap_XdmfAttribute_Build, METH_VARARGS, NULL}, { (char *)"XdmfAttribute_Release", _wrap_XdmfAttribute_Release, METH_VARARGS, NULL}, { (char *)"XdmfAttribute_swigregister", XdmfAttribute_swigregister, METH_VARARGS, NULL}, { (char *)"XdmfTypeToHDF5Type", _wrap_XdmfTypeToHDF5Type, METH_VARARGS, NULL}, { (char *)"HDF5TypeToXdmfType", _wrap_HDF5TypeToXdmfType, METH_VARARGS, NULL}, { (char *)"XdmfTypeToString", _wrap_XdmfTypeToString, METH_VARARGS, NULL}, { (char *)"StringToXdmfType", _wrap_StringToXdmfType, METH_VARARGS, NULL}, { (char *)"XdmfTypeToClassString", _wrap_XdmfTypeToClassString, METH_VARARGS, NULL}, { (char *)"new_XdmfDataDesc", _wrap_new_XdmfDataDesc, METH_VARARGS, NULL}, { (char *)"delete_XdmfDataDesc", _wrap_delete_XdmfDataDesc, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_Print", _wrap_XdmfDataDesc_Print, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_SetNumberType", _wrap_XdmfDataDesc_SetNumberType, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_SetNumberTypeFromString", _wrap_XdmfDataDesc_SetNumberTypeFromString, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_GetNumberType", _wrap_XdmfDataDesc_GetNumberType, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_GetNumberTypeAsString", _wrap_XdmfDataDesc_GetNumberTypeAsString, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_SetShape", _wrap_XdmfDataDesc_SetShape, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_GetShape", _wrap_XdmfDataDesc_GetShape, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_GetShapeAsString", _wrap_XdmfDataDesc_GetShapeAsString, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_CopySelection", _wrap_XdmfDataDesc_CopySelection, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_CopyShape", _wrap_XdmfDataDesc_CopyShape, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_CopyType", _wrap_XdmfDataDesc_CopyType, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_SetNumberOfElements", _wrap_XdmfDataDesc_SetNumberOfElements, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_SetShapeFromString", _wrap_XdmfDataDesc_SetShapeFromString, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_SelectAll", _wrap_XdmfDataDesc_SelectAll, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_SelectHyperSlab", _wrap_XdmfDataDesc_SelectHyperSlab, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_SelectHyperSlabFromString", _wrap_XdmfDataDesc_SelectHyperSlabFromString, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_GetHyperSlab", _wrap_XdmfDataDesc_GetHyperSlab, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_GetHyperSlabAsString", _wrap_XdmfDataDesc_GetHyperSlabAsString, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_SelectCoordinates", _wrap_XdmfDataDesc_SelectCoordinates, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_SelectCoordinatesFromString", _wrap_XdmfDataDesc_SelectCoordinatesFromString, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_GetCoordinates", _wrap_XdmfDataDesc_GetCoordinates, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_GetCoordinatesAsString", _wrap_XdmfDataDesc_GetCoordinatesAsString, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_GetSelectionSize", _wrap_XdmfDataDesc_GetSelectionSize, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_GetNumberOfElements", _wrap_XdmfDataDesc_GetNumberOfElements, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_GetCompression", _wrap_XdmfDataDesc_GetCompression, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_SetCompression", _wrap_XdmfDataDesc_SetCompression, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_GetRank", _wrap_XdmfDataDesc_GetRank, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_GetDimension", _wrap_XdmfDataDesc_GetDimension, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_GetStart", _wrap_XdmfDataDesc_GetStart, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_GetStride", _wrap_XdmfDataDesc_GetStride, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_GetCount", _wrap_XdmfDataDesc_GetCount, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_GetSelectionType", _wrap_XdmfDataDesc_GetSelectionType, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_GetSelectionTypeAsString", _wrap_XdmfDataDesc_GetSelectionTypeAsString, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_GetDataType", _wrap_XdmfDataDesc_GetDataType, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_GetDataSpace", _wrap_XdmfDataDesc_GetDataSpace, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_GetElementSize", _wrap_XdmfDataDesc_GetElementSize, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_AddCompoundMemberFromString", _wrap_XdmfDataDesc_AddCompoundMemberFromString, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_GetNumberOfMembers", _wrap_XdmfDataDesc_GetNumberOfMembers, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_GetMemberName", _wrap_XdmfDataDesc_GetMemberName, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_GetMemberLength", _wrap_XdmfDataDesc_GetMemberLength, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_GetMemberSize", _wrap_XdmfDataDesc_GetMemberSize, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_GetMemberShape", _wrap_XdmfDataDesc_GetMemberShape, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_GetMemberShapeAsString", _wrap_XdmfDataDesc_GetMemberShapeAsString, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_GetMemberType", _wrap_XdmfDataDesc_GetMemberType, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_GetMemberTypeAsString", _wrap_XdmfDataDesc_GetMemberTypeAsString, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_GetMemberOffset", _wrap_XdmfDataDesc_GetMemberOffset, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_SetHeavyDataSetName", _wrap_XdmfDataDesc_SetHeavyDataSetName, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_GetHeavyDataSetName", _wrap_XdmfDataDesc_GetHeavyDataSetName, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_GetDsmBuffer", _wrap_XdmfDataDesc_GetDsmBuffer, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_SetDsmBuffer", _wrap_XdmfDataDesc_SetDsmBuffer, METH_VARARGS, NULL}, { (char *)"XdmfDataDesc_swigregister", XdmfDataDesc_swigregister, METH_VARARGS, NULL}, { (char *)"new_XdmfArray", _wrap_new_XdmfArray, METH_VARARGS, NULL}, { (char *)"delete_XdmfArray", _wrap_delete_XdmfArray, METH_VARARGS, NULL}, { (char *)"XdmfArray_GetClassName", _wrap_XdmfArray_GetClassName, METH_VARARGS, NULL}, { (char *)"XdmfArray_GetTagName", _wrap_XdmfArray_GetTagName, METH_VARARGS, NULL}, { (char *)"XdmfArray_GetCoreLength", _wrap_XdmfArray_GetCoreLength, METH_VARARGS, NULL}, { (char *)"XdmfArray_Allocate", _wrap_XdmfArray_Allocate, METH_VARARGS, NULL}, { (char *)"XdmfArray_SetAllowAllocate", _wrap_XdmfArray_SetAllowAllocate, METH_VARARGS, NULL}, { (char *)"XdmfArray_GetAllowAllocate", _wrap_XdmfArray_GetAllowAllocate, METH_VARARGS, NULL}, { (char *)"XdmfArray_SetShape", _wrap_XdmfArray_SetShape, METH_VARARGS, NULL}, { (char *)"XdmfArray_SetShapeFromString", _wrap_XdmfArray_SetShapeFromString, METH_VARARGS, NULL}, { (char *)"XdmfArray_SetShapeFromSelection", _wrap_XdmfArray_SetShapeFromSelection, METH_VARARGS, NULL}, { (char *)"XdmfArray_SetNumberOfElements", _wrap_XdmfArray_SetNumberOfElements, METH_VARARGS, NULL}, { (char *)"XdmfArray_ReformFromString", _wrap_XdmfArray_ReformFromString, METH_VARARGS, NULL}, { (char *)"XdmfArray_ReformFromSelection", _wrap_XdmfArray_ReformFromSelection, METH_VARARGS, NULL}, { (char *)"XdmfArray_CopyShape", _wrap_XdmfArray_CopyShape, METH_VARARGS, NULL}, { (char *)"XdmfArray_GetDataPointer", _wrap_XdmfArray_GetDataPointer, METH_VARARGS, NULL}, { (char *)"XdmfArray_SetDataPointer", _wrap_XdmfArray_SetDataPointer, METH_VARARGS, NULL}, { (char *)"XdmfArray_Reset", _wrap_XdmfArray_Reset, METH_VARARGS, NULL}, { (char *)"XdmfArray_SetValueFromFloat64", _wrap_XdmfArray_SetValueFromFloat64, METH_VARARGS, NULL}, { (char *)"XdmfArray_SetValueFromInt64", _wrap_XdmfArray_SetValueFromInt64, METH_VARARGS, NULL}, { (char *)"XdmfArray_SetValues", _wrap_XdmfArray_SetValues, METH_VARARGS, NULL}, { (char *)"XdmfArray_GetValuesAsInt8", _wrap_XdmfArray_GetValuesAsInt8, METH_VARARGS, NULL}, { (char *)"XdmfArray_SetValuesFromInt8", _wrap_XdmfArray_SetValuesFromInt8, METH_VARARGS, NULL}, { (char *)"XdmfArray_GetValuesAsInt32", _wrap_XdmfArray_GetValuesAsInt32, METH_VARARGS, NULL}, { (char *)"XdmfArray_SetValuesFromInt32", _wrap_XdmfArray_SetValuesFromInt32, METH_VARARGS, NULL}, { (char *)"XdmfArray_GetValuesAsInt64", _wrap_XdmfArray_GetValuesAsInt64, METH_VARARGS, NULL}, { (char *)"XdmfArray_SetValuesFromInt64", _wrap_XdmfArray_SetValuesFromInt64, METH_VARARGS, NULL}, { (char *)"XdmfArray_GetValuesAsFloat32", _wrap_XdmfArray_GetValuesAsFloat32, METH_VARARGS, NULL}, { (char *)"XdmfArray_SetValuesFromFloat32", _wrap_XdmfArray_SetValuesFromFloat32, METH_VARARGS, NULL}, { (char *)"XdmfArray_GetValuesAsFloat64", _wrap_XdmfArray_GetValuesAsFloat64, METH_VARARGS, NULL}, { (char *)"XdmfArray_SetValuesFromFloat64", _wrap_XdmfArray_SetValuesFromFloat64, METH_VARARGS, NULL}, { (char *)"XdmfArray_GetValueAsFloat64", _wrap_XdmfArray_GetValueAsFloat64, METH_VARARGS, NULL}, { (char *)"XdmfArray_GetValueAsFloat32", _wrap_XdmfArray_GetValueAsFloat32, METH_VARARGS, NULL}, { (char *)"XdmfArray_GetValueAsInt64", _wrap_XdmfArray_GetValueAsInt64, METH_VARARGS, NULL}, { (char *)"XdmfArray_GetValueAsInt32", _wrap_XdmfArray_GetValueAsInt32, METH_VARARGS, NULL}, { (char *)"XdmfArray_GetValueAsInt16", _wrap_XdmfArray_GetValueAsInt16, METH_VARARGS, NULL}, { (char *)"XdmfArray_GetValueAsInt8", _wrap_XdmfArray_GetValueAsInt8, METH_VARARGS, NULL}, { (char *)"XdmfArray_GetValues", _wrap_XdmfArray_GetValues, METH_VARARGS, NULL}, { (char *)"XdmfArray_Generate", _wrap_XdmfArray_Generate, METH_VARARGS, NULL}, { (char *)"XdmfArray_Clone", _wrap_XdmfArray_Clone, METH_VARARGS, NULL}, { (char *)"XdmfArray_Reference", _wrap_XdmfArray_Reference, METH_VARARGS, NULL}, { (char *)"XdmfArray_GetMaxAsFloat64", _wrap_XdmfArray_GetMaxAsFloat64, METH_VARARGS, NULL}, { (char *)"XdmfArray_GetMinAsFloat64", _wrap_XdmfArray_GetMinAsFloat64, METH_VARARGS, NULL}, { (char *)"XdmfArray_GetMaxAsInt64", _wrap_XdmfArray_GetMaxAsInt64, METH_VARARGS, NULL}, { (char *)"XdmfArray_GetMinAsInt64", _wrap_XdmfArray_GetMinAsInt64, METH_VARARGS, NULL}, { (char *)"XdmfArray_GetMean", _wrap_XdmfArray_GetMean, METH_VARARGS, NULL}, { (char *)"XdmfArray_SetDataFromChars", _wrap_XdmfArray_SetDataFromChars, METH_VARARGS, NULL}, { (char *)"XdmfArray_GetDataPointerAsCharPointer", _wrap_XdmfArray_GetDataPointerAsCharPointer, METH_VARARGS, NULL}, { (char *)"XdmfArray_swigregister", XdmfArray_swigregister, METH_VARARGS, NULL}, { (char *)"XdmfArrayList_name_set", _wrap_XdmfArrayList_name_set, METH_VARARGS, NULL}, { (char *)"XdmfArrayList_name_get", _wrap_XdmfArrayList_name_get, METH_VARARGS, NULL}, { (char *)"XdmfArrayList_timecntr_set", _wrap_XdmfArrayList_timecntr_set, METH_VARARGS, NULL}, { (char *)"XdmfArrayList_timecntr_get", _wrap_XdmfArrayList_timecntr_get, METH_VARARGS, NULL}, { (char *)"XdmfArrayList_Array_set", _wrap_XdmfArrayList_Array_set, METH_VARARGS, NULL}, { (char *)"XdmfArrayList_Array_get", _wrap_XdmfArrayList_Array_get, METH_VARARGS, NULL}, { (char *)"new_XdmfArrayList", _wrap_new_XdmfArrayList, METH_VARARGS, NULL}, { (char *)"delete_XdmfArrayList", _wrap_delete_XdmfArrayList, METH_VARARGS, NULL}, { (char *)"XdmfArrayList_swigregister", XdmfArrayList_swigregister, METH_VARARGS, NULL}, { (char *)"TagNameToArray", _wrap_TagNameToArray, METH_VARARGS, NULL}, { (char *)"PrintAllXdmfArrays", _wrap_PrintAllXdmfArrays, METH_VARARGS, NULL}, { (char *)"GetNextOlderArray", _wrap_GetNextOlderArray, METH_VARARGS, NULL}, { (char *)"GetCurrentArrayTime", _wrap_GetCurrentArrayTime, METH_VARARGS, NULL}, { (char *)"new_XdmfDOM", _wrap_new_XdmfDOM, METH_VARARGS, NULL}, { (char *)"delete_XdmfDOM", _wrap_delete_XdmfDOM, METH_VARARGS, NULL}, { (char *)"XdmfDOM_GetClassName", _wrap_XdmfDOM_GetClassName, METH_VARARGS, NULL}, { (char *)"XdmfDOM_SetInputFileName", _wrap_XdmfDOM_SetInputFileName, METH_VARARGS, NULL}, { (char *)"XdmfDOM_SetOutputFileName", _wrap_XdmfDOM_SetOutputFileName, METH_VARARGS, NULL}, { (char *)"XdmfDOM_GetInputFileName", _wrap_XdmfDOM_GetInputFileName, METH_VARARGS, NULL}, { (char *)"XdmfDOM_GetOutputFileName", _wrap_XdmfDOM_GetOutputFileName, METH_VARARGS, NULL}, { (char *)"XdmfDOM_SetParserOptions", _wrap_XdmfDOM_SetParserOptions, METH_VARARGS, NULL}, { (char *)"XdmfDOM_GetOutput", _wrap_XdmfDOM_GetOutput, METH_VARARGS, NULL}, { (char *)"XdmfDOM_SetOutput", _wrap_XdmfDOM_SetOutput, METH_VARARGS, NULL}, { (char *)"XdmfDOM_GetInput", _wrap_XdmfDOM_GetInput, METH_VARARGS, NULL}, { (char *)"XdmfDOM_SetInput", _wrap_XdmfDOM_SetInput, METH_VARARGS, NULL}, { (char *)"XdmfDOM_GenerateHead", _wrap_XdmfDOM_GenerateHead, METH_VARARGS, NULL}, { (char *)"XdmfDOM_GetDTD", _wrap_XdmfDOM_GetDTD, METH_VARARGS, NULL}, { (char *)"XdmfDOM_SetDTD", _wrap_XdmfDOM_SetDTD, METH_VARARGS, NULL}, { (char *)"XdmfDOM_Puts", _wrap_XdmfDOM_Puts, METH_VARARGS, NULL}, { (char *)"XdmfDOM_GenerateTail", _wrap_XdmfDOM_GenerateTail, METH_VARARGS, NULL}, { (char *)"XdmfDOM_GetTree", _wrap_XdmfDOM_GetTree, METH_VARARGS, NULL}, { (char *)"XdmfDOM___Parse", _wrap_XdmfDOM___Parse, METH_VARARGS, NULL}, { (char *)"XdmfDOM_Parse", _wrap_XdmfDOM_Parse, METH_VARARGS, NULL}, { (char *)"XdmfDOM_GetRoot", _wrap_XdmfDOM_GetRoot, METH_VARARGS, NULL}, { (char *)"XdmfDOM_GetNumberOfChildren", _wrap_XdmfDOM_GetNumberOfChildren, METH_VARARGS, NULL}, { (char *)"XdmfDOM_GetChild", _wrap_XdmfDOM_GetChild, METH_VARARGS, NULL}, { (char *)"XdmfDOM_GetNumberOfAttributes", _wrap_XdmfDOM_GetNumberOfAttributes, METH_VARARGS, NULL}, { (char *)"XdmfDOM_GetAttributeName", _wrap_XdmfDOM_GetAttributeName, METH_VARARGS, NULL}, { (char *)"XdmfDOM_IsChild", _wrap_XdmfDOM_IsChild, METH_VARARGS, NULL}, { (char *)"XdmfDOM_Serialize", _wrap_XdmfDOM_Serialize, METH_VARARGS, NULL}, { (char *)"XdmfDOM_Write", _wrap_XdmfDOM_Write, METH_VARARGS, NULL}, { (char *)"XdmfDOM_Insert", _wrap_XdmfDOM_Insert, METH_VARARGS, NULL}, { (char *)"XdmfDOM_InsertFromString", _wrap_XdmfDOM_InsertFromString, METH_VARARGS, NULL}, { (char *)"XdmfDOM_Create", _wrap_XdmfDOM_Create, METH_VARARGS, NULL}, { (char *)"XdmfDOM_InsertNew", _wrap_XdmfDOM_InsertNew, METH_VARARGS, NULL}, { (char *)"XdmfDOM_DeleteNode", _wrap_XdmfDOM_DeleteNode, METH_VARARGS, NULL}, { (char *)"XdmfDOM_FindElement", _wrap_XdmfDOM_FindElement, METH_VARARGS, NULL}, { (char *)"XdmfDOM_FindNextElement", _wrap_XdmfDOM_FindNextElement, METH_VARARGS, NULL}, { (char *)"XdmfDOM_FindDataElement", _wrap_XdmfDOM_FindDataElement, METH_VARARGS, NULL}, { (char *)"XdmfDOM_FindElementByAttribute", _wrap_XdmfDOM_FindElementByAttribute, METH_VARARGS, NULL}, { (char *)"XdmfDOM_FindElementByPath", _wrap_XdmfDOM_FindElementByPath, METH_VARARGS, NULL}, { (char *)"XdmfDOM_FindNumberOfElements", _wrap_XdmfDOM_FindNumberOfElements, METH_VARARGS, NULL}, { (char *)"XdmfDOM_FindNumberOfElementsByAttribute", _wrap_XdmfDOM_FindNumberOfElementsByAttribute, METH_VARARGS, NULL}, { (char *)"XdmfDOM_GetPath", _wrap_XdmfDOM_GetPath, METH_VARARGS, NULL}, { (char *)"XdmfDOM_GetNdgmHost", _wrap_XdmfDOM_GetNdgmHost, METH_VARARGS, NULL}, { (char *)"XdmfDOM_SetNdgmHost", _wrap_XdmfDOM_SetNdgmHost, METH_VARARGS, NULL}, { (char *)"XdmfDOM_Get", _wrap_XdmfDOM_Get, METH_VARARGS, NULL}, { (char *)"XdmfDOM_GetAttribute", _wrap_XdmfDOM_GetAttribute, METH_VARARGS, NULL}, { (char *)"XdmfDOM_GetCData", _wrap_XdmfDOM_GetCData, METH_VARARGS, NULL}, { (char *)"XdmfDOM_Set", _wrap_XdmfDOM_Set, METH_VARARGS, NULL}, { (char *)"XdmfDOM_swigregister", XdmfDOM_swigregister, METH_VARARGS, NULL}, { (char *)"HandleToXdmfDOM", _wrap_HandleToXdmfDOM, METH_VARARGS, NULL}, { (char *)"new_XdmfInformation", _wrap_new_XdmfInformation, METH_VARARGS, NULL}, { (char *)"delete_XdmfInformation", _wrap_delete_XdmfInformation, METH_VARARGS, NULL}, { (char *)"XdmfInformation_GetClassName", _wrap_XdmfInformation_GetClassName, METH_VARARGS, NULL}, { (char *)"XdmfInformation_Insert", _wrap_XdmfInformation_Insert, METH_VARARGS, NULL}, { (char *)"XdmfInformation_UpdateInformation", _wrap_XdmfInformation_UpdateInformation, METH_VARARGS, NULL}, { (char *)"XdmfInformation_SetValue", _wrap_XdmfInformation_SetValue, METH_VARARGS, NULL}, { (char *)"XdmfInformation_Build", _wrap_XdmfInformation_Build, METH_VARARGS, NULL}, { (char *)"XdmfInformation_GetValue", _wrap_XdmfInformation_GetValue, METH_VARARGS, NULL}, { (char *)"XdmfInformation_swigregister", XdmfInformation_swigregister, METH_VARARGS, NULL}, { (char *)"new_XdmfDataItem", _wrap_new_XdmfDataItem, METH_VARARGS, NULL}, { (char *)"delete_XdmfDataItem", _wrap_delete_XdmfDataItem, METH_VARARGS, NULL}, { (char *)"XdmfDataItem_GetClassName", _wrap_XdmfDataItem_GetClassName, METH_VARARGS, NULL}, { (char *)"XdmfDataItem_GetValues", _wrap_XdmfDataItem_GetValues, METH_VARARGS, NULL}, { (char *)"XdmfDataItem_GetFormat", _wrap_XdmfDataItem_GetFormat, METH_VARARGS, NULL}, { (char *)"XdmfDataItem_SetFormat", _wrap_XdmfDataItem_SetFormat, METH_VARARGS, NULL}, { (char *)"XdmfDataItem_Insert", _wrap_XdmfDataItem_Insert, METH_VARARGS, NULL}, { (char *)"XdmfDataItem_SetArrayIsMine", _wrap_XdmfDataItem_SetArrayIsMine, METH_VARARGS, NULL}, { (char *)"XdmfDataItem_GetArrayIsMine", _wrap_XdmfDataItem_GetArrayIsMine, METH_VARARGS, NULL}, { (char *)"XdmfDataItem_UpdateInformation", _wrap_XdmfDataItem_UpdateInformation, METH_VARARGS, NULL}, { (char *)"XdmfDataItem_Update", _wrap_XdmfDataItem_Update, METH_VARARGS, NULL}, { (char *)"XdmfDataItem_Build", _wrap_XdmfDataItem_Build, METH_VARARGS, NULL}, { (char *)"XdmfDataItem_GetDataDesc", _wrap_XdmfDataItem_GetDataDesc, METH_VARARGS, NULL}, { (char *)"XdmfDataItem_SetDataDesc", _wrap_XdmfDataItem_SetDataDesc, METH_VARARGS, NULL}, { (char *)"XdmfDataItem_GetArray", _wrap_XdmfDataItem_GetArray, METH_VARARGS, NULL}, { (char *)"XdmfDataItem_SetArray", _wrap_XdmfDataItem_SetArray, METH_VARARGS, NULL}, { (char *)"XdmfDataItem_GetDataValues", _wrap_XdmfDataItem_GetDataValues, METH_VARARGS, NULL}, { (char *)"XdmfDataItem_SetDataValues", _wrap_XdmfDataItem_SetDataValues, METH_VARARGS, NULL}, { (char *)"XdmfDataItem_GetRank", _wrap_XdmfDataItem_GetRank, METH_VARARGS, NULL}, { (char *)"XdmfDataItem_SetShape", _wrap_XdmfDataItem_SetShape, METH_VARARGS, NULL}, { (char *)"XdmfDataItem_GetShape", _wrap_XdmfDataItem_GetShape, METH_VARARGS, NULL}, { (char *)"XdmfDataItem_GetShapeAsString", _wrap_XdmfDataItem_GetShapeAsString, METH_VARARGS, NULL}, { (char *)"XdmfDataItem_GetDimensions", _wrap_XdmfDataItem_GetDimensions, METH_VARARGS, NULL}, { (char *)"XdmfDataItem_SetDimensions", _wrap_XdmfDataItem_SetDimensions, METH_VARARGS, NULL}, { (char *)"XdmfDataItem_SetDimensionsFromString", _wrap_XdmfDataItem_SetDimensionsFromString, METH_VARARGS, NULL}, { (char *)"XdmfDataItem_SetHeavyDataSetName", _wrap_XdmfDataItem_SetHeavyDataSetName, METH_VARARGS, NULL}, { (char *)"XdmfDataItem_GetHeavyDataSetName", _wrap_XdmfDataItem_GetHeavyDataSetName, METH_VARARGS, NULL}, { (char *)"XdmfDataItem_Copy", _wrap_XdmfDataItem_Copy, METH_VARARGS, NULL}, { (char *)"XdmfDataItem_SetItemType", _wrap_XdmfDataItem_SetItemType, METH_VARARGS, NULL}, { (char *)"XdmfDataItem_GetItemType", _wrap_XdmfDataItem_GetItemType, METH_VARARGS, NULL}, { (char *)"XdmfDataItem_GetIsMultiple", _wrap_XdmfDataItem_GetIsMultiple, METH_VARARGS, NULL}, { (char *)"XdmfDataItem_SetFunction", _wrap_XdmfDataItem_SetFunction, METH_VARARGS, NULL}, { (char *)"XdmfDataItem_GetFunction", _wrap_XdmfDataItem_GetFunction, METH_VARARGS, NULL}, { (char *)"XdmfDataItem_Release", _wrap_XdmfDataItem_Release, METH_VARARGS, NULL}, { (char *)"XdmfDataItem_GetColumnMajor", _wrap_XdmfDataItem_GetColumnMajor, METH_VARARGS, NULL}, { (char *)"XdmfDataItem_SetColumnMajor", _wrap_XdmfDataItem_SetColumnMajor, METH_VARARGS, NULL}, { (char *)"XdmfDataItem_GetTransposeInMemory", _wrap_XdmfDataItem_GetTransposeInMemory, METH_VARARGS, NULL}, { (char *)"XdmfDataItem_SetTransposeInMemory", _wrap_XdmfDataItem_SetTransposeInMemory, METH_VARARGS, NULL}, { (char *)"XdmfDataItem_swigregister", XdmfDataItem_swigregister, METH_VARARGS, NULL}, { (char *)"new_XdmfDataStructure", _wrap_new_XdmfDataStructure, METH_VARARGS, NULL}, { (char *)"delete_XdmfDataStructure", _wrap_delete_XdmfDataStructure, METH_VARARGS, NULL}, { (char *)"XdmfDataStructure_GetClassName", _wrap_XdmfDataStructure_GetClassName, METH_VARARGS, NULL}, { (char *)"XdmfDataStructure_UpdateInformation", _wrap_XdmfDataStructure_UpdateInformation, METH_VARARGS, NULL}, { (char *)"XdmfDataStructure_swigregister", XdmfDataStructure_swigregister, METH_VARARGS, NULL}, { (char *)"new_XdmfValues", _wrap_new_XdmfValues, METH_VARARGS, NULL}, { (char *)"delete_XdmfValues", _wrap_delete_XdmfValues, METH_VARARGS, NULL}, { (char *)"XdmfValues_GetClassName", _wrap_XdmfValues_GetClassName, METH_VARARGS, NULL}, { (char *)"XdmfValues_Inherit", _wrap_XdmfValues_Inherit, METH_VARARGS, NULL}, { (char *)"XdmfValues_Read", _wrap_XdmfValues_Read, METH_VARARGS, NULL}, { (char *)"XdmfValues_Write", _wrap_XdmfValues_Write, METH_VARARGS, NULL}, { (char *)"XdmfValues_swigregister", XdmfValues_swigregister, METH_VARARGS, NULL}, { (char *)"new_XdmfValuesXML", _wrap_new_XdmfValuesXML, METH_VARARGS, NULL}, { (char *)"delete_XdmfValuesXML", _wrap_delete_XdmfValuesXML, METH_VARARGS, NULL}, { (char *)"XdmfValuesXML_GetClassName", _wrap_XdmfValuesXML_GetClassName, METH_VARARGS, NULL}, { (char *)"XdmfValuesXML_Read", _wrap_XdmfValuesXML_Read, METH_VARARGS, NULL}, { (char *)"XdmfValuesXML_Write", _wrap_XdmfValuesXML_Write, METH_VARARGS, NULL}, { (char *)"XdmfValuesXML_swigregister", XdmfValuesXML_swigregister, METH_VARARGS, NULL}, { (char *)"new_XdmfValuesHDF", _wrap_new_XdmfValuesHDF, METH_VARARGS, NULL}, { (char *)"delete_XdmfValuesHDF", _wrap_delete_XdmfValuesHDF, METH_VARARGS, NULL}, { (char *)"XdmfValuesHDF_GetClassName", _wrap_XdmfValuesHDF_GetClassName, METH_VARARGS, NULL}, { (char *)"XdmfValuesHDF_Read", _wrap_XdmfValuesHDF_Read, METH_VARARGS, NULL}, { (char *)"XdmfValuesHDF_Write", _wrap_XdmfValuesHDF_Write, METH_VARARGS, NULL}, { (char *)"XdmfValuesHDF_DataItemFromHDF", _wrap_XdmfValuesHDF_DataItemFromHDF, METH_VARARGS, NULL}, { (char *)"XdmfValuesHDF_swigregister", XdmfValuesHDF_swigregister, METH_VARARGS, NULL}, { (char *)"XdmfArrayExpr", _wrap_XdmfArrayExpr, METH_VARARGS, NULL}, { (char *)"XdmfScalarExpr", _wrap_XdmfScalarExpr, METH_VARARGS, NULL}, { (char *)"XdmfExpr", _wrap_XdmfExpr, METH_VARARGS, NULL}, { (char *)"new_XdmfHeavyData", _wrap_new_XdmfHeavyData, METH_VARARGS, NULL}, { (char *)"delete_XdmfHeavyData", _wrap_delete_XdmfHeavyData, METH_VARARGS, NULL}, { (char *)"XdmfHeavyData_GetClassName", _wrap_XdmfHeavyData_GetClassName, METH_VARARGS, NULL}, { (char *)"XdmfHeavyData_GetNdgmHost", _wrap_XdmfHeavyData_GetNdgmHost, METH_VARARGS, NULL}, { (char *)"XdmfHeavyData_SetNdgmHost", _wrap_XdmfHeavyData_SetNdgmHost, METH_VARARGS, NULL}, { (char *)"XdmfHeavyData_GetWorkingDirectory", _wrap_XdmfHeavyData_GetWorkingDirectory, METH_VARARGS, NULL}, { (char *)"XdmfHeavyData_SetWorkingDirectory", _wrap_XdmfHeavyData_SetWorkingDirectory, METH_VARARGS, NULL}, { (char *)"XdmfHeavyData_GetDomain", _wrap_XdmfHeavyData_GetDomain, METH_VARARGS, NULL}, { (char *)"XdmfHeavyData_SetDomain", _wrap_XdmfHeavyData_SetDomain, METH_VARARGS, NULL}, { (char *)"XdmfHeavyData_GetFileName", _wrap_XdmfHeavyData_GetFileName, METH_VARARGS, NULL}, { (char *)"XdmfHeavyData_SetFileName", _wrap_XdmfHeavyData_SetFileName, METH_VARARGS, NULL}, { (char *)"XdmfHeavyData_GetPath", _wrap_XdmfHeavyData_GetPath, METH_VARARGS, NULL}, { (char *)"XdmfHeavyData_SetPath", _wrap_XdmfHeavyData_SetPath, METH_VARARGS, NULL}, { (char *)"XdmfHeavyData_GetAccess", _wrap_XdmfHeavyData_GetAccess, METH_VARARGS, NULL}, { (char *)"XdmfHeavyData_SetAccess", _wrap_XdmfHeavyData_SetAccess, METH_VARARGS, NULL}, { (char *)"XdmfHeavyData_Open", _wrap_XdmfHeavyData_Open, METH_VARARGS, NULL}, { (char *)"XdmfHeavyData_Read", _wrap_XdmfHeavyData_Read, METH_VARARGS, NULL}, { (char *)"XdmfHeavyData_Write", _wrap_XdmfHeavyData_Write, METH_VARARGS, NULL}, { (char *)"XdmfHeavyData_Close", _wrap_XdmfHeavyData_Close, METH_VARARGS, NULL}, { (char *)"XdmfHeavyData_DoOpen", _wrap_XdmfHeavyData_DoOpen, METH_VARARGS, NULL}, { (char *)"XdmfHeavyData_DoRead", _wrap_XdmfHeavyData_DoRead, METH_VARARGS, NULL}, { (char *)"XdmfHeavyData_DoWrite", _wrap_XdmfHeavyData_DoWrite, METH_VARARGS, NULL}, { (char *)"XdmfHeavyData_DoClose", _wrap_XdmfHeavyData_DoClose, METH_VARARGS, NULL}, { (char *)"XdmfHeavyData_setOpenCallback", _wrap_XdmfHeavyData_setOpenCallback, METH_VARARGS, NULL}, { (char *)"XdmfHeavyData_setReadCallback", _wrap_XdmfHeavyData_setReadCallback, METH_VARARGS, NULL}, { (char *)"XdmfHeavyData_setWriteCallback", _wrap_XdmfHeavyData_setWriteCallback, METH_VARARGS, NULL}, { (char *)"XdmfHeavyData_setCloseCallback", _wrap_XdmfHeavyData_setCloseCallback, METH_VARARGS, NULL}, { (char *)"XdmfHeavyData_swigregister", XdmfHeavyData_swigregister, METH_VARARGS, NULL}, { (char *)"XdmfOpenCallback_DoOpen", _wrap_XdmfOpenCallback_DoOpen, METH_VARARGS, NULL}, { (char *)"new_XdmfOpenCallback", _wrap_new_XdmfOpenCallback, METH_VARARGS, NULL}, { (char *)"delete_XdmfOpenCallback", _wrap_delete_XdmfOpenCallback, METH_VARARGS, NULL}, { (char *)"XdmfOpenCallback_swigregister", XdmfOpenCallback_swigregister, METH_VARARGS, NULL}, { (char *)"XdmfReadCallback_DoRead", _wrap_XdmfReadCallback_DoRead, METH_VARARGS, NULL}, { (char *)"new_XdmfReadCallback", _wrap_new_XdmfReadCallback, METH_VARARGS, NULL}, { (char *)"delete_XdmfReadCallback", _wrap_delete_XdmfReadCallback, METH_VARARGS, NULL}, { (char *)"XdmfReadCallback_swigregister", XdmfReadCallback_swigregister, METH_VARARGS, NULL}, { (char *)"XdmfWriteCallback_DoWrite", _wrap_XdmfWriteCallback_DoWrite, METH_VARARGS, NULL}, { (char *)"new_XdmfWriteCallback", _wrap_new_XdmfWriteCallback, METH_VARARGS, NULL}, { (char *)"delete_XdmfWriteCallback", _wrap_delete_XdmfWriteCallback, METH_VARARGS, NULL}, { (char *)"XdmfWriteCallback_swigregister", XdmfWriteCallback_swigregister, METH_VARARGS, NULL}, { (char *)"XdmfCloseCallback_DoClose", _wrap_XdmfCloseCallback_DoClose, METH_VARARGS, NULL}, { (char *)"new_XdmfCloseCallback", _wrap_new_XdmfCloseCallback, METH_VARARGS, NULL}, { (char *)"delete_XdmfCloseCallback", _wrap_delete_XdmfCloseCallback, METH_VARARGS, NULL}, { (char *)"XdmfCloseCallback_swigregister", XdmfCloseCallback_swigregister, METH_VARARGS, NULL}, { (char *)"new_XdmfHDF", _wrap_new_XdmfHDF, METH_VARARGS, NULL}, { (char *)"delete_XdmfHDF", _wrap_delete_XdmfHDF, METH_VARARGS, NULL}, { (char *)"XdmfHDF_GetClassName", _wrap_XdmfHDF_GetClassName, METH_VARARGS, NULL}, { (char *)"XdmfHDF_SetCompression", _wrap_XdmfHDF_SetCompression, METH_VARARGS, NULL}, { (char *)"XdmfHDF_GetCompression", _wrap_XdmfHDF_GetCompression, METH_VARARGS, NULL}, { (char *)"XdmfHDF_SetUseSerialFile", _wrap_XdmfHDF_SetUseSerialFile, METH_VARARGS, NULL}, { (char *)"XdmfHDF_GetUseSerialFile", _wrap_XdmfHDF_GetUseSerialFile, METH_VARARGS, NULL}, { (char *)"XdmfHDF_SetCwdName", _wrap_XdmfHDF_SetCwdName, METH_VARARGS, NULL}, { (char *)"XdmfHDF_GetCwdName", _wrap_XdmfHDF_GetCwdName, METH_VARARGS, NULL}, { (char *)"XdmfHDF_Cd", _wrap_XdmfHDF_Cd, METH_VARARGS, NULL}, { (char *)"XdmfHDF_Mkdir", _wrap_XdmfHDF_Mkdir, METH_VARARGS, NULL}, { (char *)"XdmfHDF_GetNumberOfChildren", _wrap_XdmfHDF_GetNumberOfChildren, METH_VARARGS, NULL}, { (char *)"XdmfHDF_GetHDFVersion", _wrap_XdmfHDF_GetHDFVersion, METH_VARARGS, NULL}, { (char *)"XdmfHDF_GetChild", _wrap_XdmfHDF_GetChild, METH_VARARGS, NULL}, { (char *)"XdmfHDF_SetNextChild", _wrap_XdmfHDF_SetNextChild, METH_VARARGS, NULL}, { (char *)"XdmfHDF_Info", _wrap_XdmfHDF_Info, METH_VARARGS, NULL}, { (char *)"XdmfHDF_GetChildType", _wrap_XdmfHDF_GetChildType, METH_VARARGS, NULL}, { (char *)"XdmfHDF_GetChildTypeAsString", _wrap_XdmfHDF_GetChildTypeAsString, METH_VARARGS, NULL}, { (char *)"XdmfHDF_CreateDataset", _wrap_XdmfHDF_CreateDataset, METH_VARARGS, NULL}, { (char *)"XdmfHDF_OpenDataset", _wrap_XdmfHDF_OpenDataset, METH_VARARGS, NULL}, { (char *)"XdmfHDF_DoOpen", _wrap_XdmfHDF_DoOpen, METH_VARARGS, NULL}, { (char *)"XdmfHDF_DoRead", _wrap_XdmfHDF_DoRead, METH_VARARGS, NULL}, { (char *)"XdmfHDF_DoWrite", _wrap_XdmfHDF_DoWrite, METH_VARARGS, NULL}, { (char *)"XdmfHDF_DoClose", _wrap_XdmfHDF_DoClose, METH_VARARGS, NULL}, { (char *)"XdmfHDF_swigregister", XdmfHDF_swigregister, METH_VARARGS, NULL}, { (char *)"CopyArray", _wrap_CopyArray, METH_VARARGS, NULL}, { (char *)"new_XdmfDomain", _wrap_new_XdmfDomain, METH_VARARGS, NULL}, { (char *)"delete_XdmfDomain", _wrap_delete_XdmfDomain, METH_VARARGS, NULL}, { (char *)"XdmfDomain_GetClassName", _wrap_XdmfDomain_GetClassName, METH_VARARGS, NULL}, { (char *)"XdmfDomain_UpdateInformation", _wrap_XdmfDomain_UpdateInformation, METH_VARARGS, NULL}, { (char *)"XdmfDomain_Insert", _wrap_XdmfDomain_Insert, METH_VARARGS, NULL}, { (char *)"XdmfDomain_Build", _wrap_XdmfDomain_Build, METH_VARARGS, NULL}, { (char *)"XdmfDomain_swigregister", XdmfDomain_swigregister, METH_VARARGS, NULL}, { (char *)"new_XdmfRoot", _wrap_new_XdmfRoot, METH_VARARGS, NULL}, { (char *)"delete_XdmfRoot", _wrap_delete_XdmfRoot, METH_VARARGS, NULL}, { (char *)"XdmfRoot_GetClassName", _wrap_XdmfRoot_GetClassName, METH_VARARGS, NULL}, { (char *)"XdmfRoot_UpdateInformation", _wrap_XdmfRoot_UpdateInformation, METH_VARARGS, NULL}, { (char *)"XdmfRoot_Insert", _wrap_XdmfRoot_Insert, METH_VARARGS, NULL}, { (char *)"XdmfRoot_SetVersion", _wrap_XdmfRoot_SetVersion, METH_VARARGS, NULL}, { (char *)"XdmfRoot_SetXInclude", _wrap_XdmfRoot_SetXInclude, METH_VARARGS, NULL}, { (char *)"XdmfRoot_Build", _wrap_XdmfRoot_Build, METH_VARARGS, NULL}, { (char *)"XdmfRoot_GetXInclude", _wrap_XdmfRoot_GetXInclude, METH_VARARGS, NULL}, { (char *)"XdmfRoot_GetVersion", _wrap_XdmfRoot_GetVersion, METH_VARARGS, NULL}, { (char *)"XdmfRoot_swigregister", XdmfRoot_swigregister, METH_VARARGS, NULL}, { (char *)"new_XdmfTopology", _wrap_new_XdmfTopology, METH_VARARGS, NULL}, { (char *)"delete_XdmfTopology", _wrap_delete_XdmfTopology, METH_VARARGS, NULL}, { (char *)"XdmfTopology_GetClassName", _wrap_XdmfTopology_GetClassName, METH_VARARGS, NULL}, { (char *)"XdmfTopology_Build", _wrap_XdmfTopology_Build, METH_VARARGS, NULL}, { (char *)"XdmfTopology_Insert", _wrap_XdmfTopology_Insert, METH_VARARGS, NULL}, { (char *)"XdmfTopology_GetClass", _wrap_XdmfTopology_GetClass, METH_VARARGS, NULL}, { (char *)"XdmfTopology_GetClassAsString", _wrap_XdmfTopology_GetClassAsString, METH_VARARGS, NULL}, { (char *)"XdmfTopology_SetTopologyType", _wrap_XdmfTopology_SetTopologyType, METH_VARARGS, NULL}, { (char *)"XdmfTopology_SetTopologyTypeFromString", _wrap_XdmfTopology_SetTopologyTypeFromString, METH_VARARGS, NULL}, { (char *)"XdmfTopology_GetTopologyType", _wrap_XdmfTopology_GetTopologyType, METH_VARARGS, NULL}, { (char *)"XdmfTopology_GetTopologyTypeAsString", _wrap_XdmfTopology_GetTopologyTypeAsString, METH_VARARGS, NULL}, { (char *)"XdmfTopology_GetOrder", _wrap_XdmfTopology_GetOrder, METH_VARARGS, NULL}, { (char *)"XdmfTopology_GetOrderAsString", _wrap_XdmfTopology_GetOrderAsString, METH_VARARGS, NULL}, { (char *)"XdmfTopology_SetOrderFromString", _wrap_XdmfTopology_SetOrderFromString, METH_VARARGS, NULL}, { (char *)"XdmfTopology_SetOrder", _wrap_XdmfTopology_SetOrder, METH_VARARGS, NULL}, { (char *)"XdmfTopology_SetLightDataLimit", _wrap_XdmfTopology_SetLightDataLimit, METH_VARARGS, NULL}, { (char *)"XdmfTopology_GetLightDataLimit", _wrap_XdmfTopology_GetLightDataLimit, METH_VARARGS, NULL}, { (char *)"XdmfTopology_SetNodesPerElement", _wrap_XdmfTopology_SetNodesPerElement, METH_VARARGS, NULL}, { (char *)"XdmfTopology_GetNodesPerElement", _wrap_XdmfTopology_GetNodesPerElement, METH_VARARGS, NULL}, { (char *)"XdmfTopology_SetBaseOffset", _wrap_XdmfTopology_SetBaseOffset, METH_VARARGS, NULL}, { (char *)"XdmfTopology_GetBaseOffset", _wrap_XdmfTopology_GetBaseOffset, METH_VARARGS, NULL}, { (char *)"XdmfTopology_GetShapeDesc", _wrap_XdmfTopology_GetShapeDesc, METH_VARARGS, NULL}, { (char *)"XdmfTopology_SetNumberOfElements", _wrap_XdmfTopology_SetNumberOfElements, METH_VARARGS, NULL}, { (char *)"XdmfTopology_GetNumberOfElements", _wrap_XdmfTopology_GetNumberOfElements, METH_VARARGS, NULL}, { (char *)"XdmfTopology_GetConnectivity", _wrap_XdmfTopology_GetConnectivity, METH_VARARGS, NULL}, { (char *)"XdmfTopology_SetConnectivity", _wrap_XdmfTopology_SetConnectivity, METH_VARARGS, NULL}, { (char *)"XdmfTopology_GetCellOffsets", _wrap_XdmfTopology_GetCellOffsets, METH_VARARGS, NULL}, { (char *)"XdmfTopology_Update", _wrap_XdmfTopology_Update, METH_VARARGS, NULL}, { (char *)"XdmfTopology_UpdateInformation", _wrap_XdmfTopology_UpdateInformation, METH_VARARGS, NULL}, { (char *)"XdmfTopology_Release", _wrap_XdmfTopology_Release, METH_VARARGS, NULL}, { (char *)"XdmfTopology_swigregister", XdmfTopology_swigregister, METH_VARARGS, NULL}, { (char *)"HandleToXdmfTopology", _wrap_HandleToXdmfTopology, METH_VARARGS, NULL}, { (char *)"new_XdmfGeometry", _wrap_new_XdmfGeometry, METH_VARARGS, NULL}, { (char *)"delete_XdmfGeometry", _wrap_delete_XdmfGeometry, METH_VARARGS, NULL}, { (char *)"XdmfGeometry_GetClassName", _wrap_XdmfGeometry_GetClassName, METH_VARARGS, NULL}, { (char *)"XdmfGeometry_SetNumberOfPoints", _wrap_XdmfGeometry_SetNumberOfPoints, METH_VARARGS, NULL}, { (char *)"XdmfGeometry_GetNumberOfPoints", _wrap_XdmfGeometry_GetNumberOfPoints, METH_VARARGS, NULL}, { (char *)"XdmfGeometry_SetGeometryType", _wrap_XdmfGeometry_SetGeometryType, METH_VARARGS, NULL}, { (char *)"XdmfGeometry_GetGeometryType", _wrap_XdmfGeometry_GetGeometryType, METH_VARARGS, NULL}, { (char *)"XdmfGeometry_SetLightDataLimit", _wrap_XdmfGeometry_SetLightDataLimit, METH_VARARGS, NULL}, { (char *)"XdmfGeometry_GetLightDataLimit", _wrap_XdmfGeometry_GetLightDataLimit, METH_VARARGS, NULL}, { (char *)"XdmfGeometry_GetUnits", _wrap_XdmfGeometry_GetUnits, METH_VARARGS, NULL}, { (char *)"XdmfGeometry_SetUnits", _wrap_XdmfGeometry_SetUnits, METH_VARARGS, NULL}, { (char *)"XdmfGeometry_GetGeometryTypeAsString", _wrap_XdmfGeometry_GetGeometryTypeAsString, METH_VARARGS, NULL}, { (char *)"XdmfGeometry_SetGeometryTypeFromString", _wrap_XdmfGeometry_SetGeometryTypeFromString, METH_VARARGS, NULL}, { (char *)"XdmfGeometry_Build", _wrap_XdmfGeometry_Build, METH_VARARGS, NULL}, { (char *)"XdmfGeometry_Insert", _wrap_XdmfGeometry_Insert, METH_VARARGS, NULL}, { (char *)"XdmfGeometry_Update", _wrap_XdmfGeometry_Update, METH_VARARGS, NULL}, { (char *)"XdmfGeometry_UpdateInformation", _wrap_XdmfGeometry_UpdateInformation, METH_VARARGS, NULL}, { (char *)"XdmfGeometry_SetPoints", _wrap_XdmfGeometry_SetPoints, METH_VARARGS, NULL}, { (char *)"XdmfGeometry_GetPoints", _wrap_XdmfGeometry_GetPoints, METH_VARARGS, NULL}, { (char *)"XdmfGeometry_Release", _wrap_XdmfGeometry_Release, METH_VARARGS, NULL}, { (char *)"XdmfGeometry_GetOrigin", _wrap_XdmfGeometry_GetOrigin, METH_VARARGS, NULL}, { (char *)"XdmfGeometry_GetOriginX", _wrap_XdmfGeometry_GetOriginX, METH_VARARGS, NULL}, { (char *)"XdmfGeometry_GetOriginY", _wrap_XdmfGeometry_GetOriginY, METH_VARARGS, NULL}, { (char *)"XdmfGeometry_GetOriginZ", _wrap_XdmfGeometry_GetOriginZ, METH_VARARGS, NULL}, { (char *)"XdmfGeometry_SetOrigin", _wrap_XdmfGeometry_SetOrigin, METH_VARARGS, NULL}, { (char *)"XdmfGeometry_SetDxDyDz", _wrap_XdmfGeometry_SetDxDyDz, METH_VARARGS, NULL}, { (char *)"XdmfGeometry_GetDx", _wrap_XdmfGeometry_GetDx, METH_VARARGS, NULL}, { (char *)"XdmfGeometry_GetDy", _wrap_XdmfGeometry_GetDy, METH_VARARGS, NULL}, { (char *)"XdmfGeometry_GetDz", _wrap_XdmfGeometry_GetDz, METH_VARARGS, NULL}, { (char *)"XdmfGeometry_GetDxDyDz", _wrap_XdmfGeometry_GetDxDyDz, METH_VARARGS, NULL}, { (char *)"XdmfGeometry_GetVectorX", _wrap_XdmfGeometry_GetVectorX, METH_VARARGS, NULL}, { (char *)"XdmfGeometry_GetVectorY", _wrap_XdmfGeometry_GetVectorY, METH_VARARGS, NULL}, { (char *)"XdmfGeometry_GetVectorZ", _wrap_XdmfGeometry_GetVectorZ, METH_VARARGS, NULL}, { (char *)"XdmfGeometry_SetVectorX", _wrap_XdmfGeometry_SetVectorX, METH_VARARGS, NULL}, { (char *)"XdmfGeometry_SetVectorY", _wrap_XdmfGeometry_SetVectorY, METH_VARARGS, NULL}, { (char *)"XdmfGeometry_SetVectorZ", _wrap_XdmfGeometry_SetVectorZ, METH_VARARGS, NULL}, { (char *)"XdmfGeometry_HasData", _wrap_XdmfGeometry_HasData, METH_VARARGS, NULL}, { (char *)"XdmfGeometry_swigregister", XdmfGeometry_swigregister, METH_VARARGS, NULL}, { (char *)"GetXdmfGeometryHandle", _wrap_GetXdmfGeometryHandle, METH_VARARGS, NULL}, { (char *)"new_XdmfGrid", _wrap_new_XdmfGrid, METH_VARARGS, NULL}, { (char *)"delete_XdmfGrid", _wrap_delete_XdmfGrid, METH_VARARGS, NULL}, { (char *)"XdmfGrid_GetClassName", _wrap_XdmfGrid_GetClassName, METH_VARARGS, NULL}, { (char *)"XdmfGrid_SetGeometry", _wrap_XdmfGrid_SetGeometry, METH_VARARGS, NULL}, { (char *)"XdmfGrid_GetGeometry", _wrap_XdmfGrid_GetGeometry, METH_VARARGS, NULL}, { (char *)"XdmfGrid_SetTopology", _wrap_XdmfGrid_SetTopology, METH_VARARGS, NULL}, { (char *)"XdmfGrid_GetTopology", _wrap_XdmfGrid_GetTopology, METH_VARARGS, NULL}, { (char *)"XdmfGrid_SetTime", _wrap_XdmfGrid_SetTime, METH_VARARGS, NULL}, { (char *)"XdmfGrid_GetTime", _wrap_XdmfGrid_GetTime, METH_VARARGS, NULL}, { (char *)"XdmfGrid_GetGridTypeAsString", _wrap_XdmfGrid_GetGridTypeAsString, METH_VARARGS, NULL}, { (char *)"XdmfGrid_SetGridTypeFromString", _wrap_XdmfGrid_SetGridTypeFromString, METH_VARARGS, NULL}, { (char *)"XdmfGrid_GetCollectionTypeAsString", _wrap_XdmfGrid_GetCollectionTypeAsString, METH_VARARGS, NULL}, { (char *)"XdmfGrid_SetCollectionTypeFromString", _wrap_XdmfGrid_SetCollectionTypeFromString, METH_VARARGS, NULL}, { (char *)"XdmfGrid_Build", _wrap_XdmfGrid_Build, METH_VARARGS, NULL}, { (char *)"XdmfGrid_InsertTopology", _wrap_XdmfGrid_InsertTopology, METH_VARARGS, NULL}, { (char *)"XdmfGrid_InsertGeometry", _wrap_XdmfGrid_InsertGeometry, METH_VARARGS, NULL}, { (char *)"XdmfGrid_Insert", _wrap_XdmfGrid_Insert, METH_VARARGS, NULL}, { (char *)"XdmfGrid_GetGridType", _wrap_XdmfGrid_GetGridType, METH_VARARGS, NULL}, { (char *)"XdmfGrid_SetGridType", _wrap_XdmfGrid_SetGridType, METH_VARARGS, NULL}, { (char *)"XdmfGrid_GetCollectionType", _wrap_XdmfGrid_GetCollectionType, METH_VARARGS, NULL}, { (char *)"XdmfGrid_SetCollectionType", _wrap_XdmfGrid_SetCollectionType, METH_VARARGS, NULL}, { (char *)"XdmfGrid_GetBuildTime", _wrap_XdmfGrid_GetBuildTime, METH_VARARGS, NULL}, { (char *)"XdmfGrid_SetBuildTime", _wrap_XdmfGrid_SetBuildTime, METH_VARARGS, NULL}, { (char *)"XdmfGrid_Copy", _wrap_XdmfGrid_Copy, METH_VARARGS, NULL}, { (char *)"XdmfGrid_GetNumberOfChildren", _wrap_XdmfGrid_GetNumberOfChildren, METH_VARARGS, NULL}, { (char *)"XdmfGrid_SetNumberOfChildren", _wrap_XdmfGrid_SetNumberOfChildren, METH_VARARGS, NULL}, { (char *)"XdmfGrid_IsUniform", _wrap_XdmfGrid_IsUniform, METH_VARARGS, NULL}, { (char *)"XdmfGrid_GetNumberOfAttributes", _wrap_XdmfGrid_GetNumberOfAttributes, METH_VARARGS, NULL}, { (char *)"XdmfGrid_GetNumberOfSets", _wrap_XdmfGrid_GetNumberOfSets, METH_VARARGS, NULL}, { (char *)"XdmfGrid_GetNumberOfInformations", _wrap_XdmfGrid_GetNumberOfInformations, METH_VARARGS, NULL}, { (char *)"XdmfGrid_GetAttribute", _wrap_XdmfGrid_GetAttribute, METH_VARARGS, NULL}, { (char *)"XdmfGrid_GetSets", _wrap_XdmfGrid_GetSets, METH_VARARGS, NULL}, { (char *)"XdmfGrid_AssignAttribute", _wrap_XdmfGrid_AssignAttribute, METH_VARARGS, NULL}, { (char *)"XdmfGrid_AssignAttributeByIndex", _wrap_XdmfGrid_AssignAttributeByIndex, METH_VARARGS, NULL}, { (char *)"XdmfGrid_AssignAttributeByName", _wrap_XdmfGrid_AssignAttributeByName, METH_VARARGS, NULL}, { (char *)"XdmfGrid_GetAssignedAttribute", _wrap_XdmfGrid_GetAssignedAttribute, METH_VARARGS, NULL}, { (char *)"XdmfGrid_GetAssignedAttributeIndex", _wrap_XdmfGrid_GetAssignedAttributeIndex, METH_VARARGS, NULL}, { (char *)"XdmfGrid_UpdateInformation", _wrap_XdmfGrid_UpdateInformation, METH_VARARGS, NULL}, { (char *)"XdmfGrid_Update", _wrap_XdmfGrid_Update, METH_VARARGS, NULL}, { (char *)"XdmfGrid_GetChild", _wrap_XdmfGrid_GetChild, METH_VARARGS, NULL}, { (char *)"XdmfGrid_GetInformation", _wrap_XdmfGrid_GetInformation, METH_VARARGS, NULL}, { (char *)"XdmfGrid_FindGridsInTimeRange", _wrap_XdmfGrid_FindGridsInTimeRange, METH_VARARGS, NULL}, { (char *)"XdmfGrid_FindGridsAtTime", _wrap_XdmfGrid_FindGridsAtTime, METH_VARARGS, NULL}, { (char *)"XdmfGrid_Release", _wrap_XdmfGrid_Release, METH_VARARGS, NULL}, { (char *)"XdmfGrid_swigregister", XdmfGrid_swigregister, METH_VARARGS, NULL}, { (char *)"HandleToXdmfGrid", _wrap_HandleToXdmfGrid, METH_VARARGS, NULL}, { (char *)"new_XdmfTime", _wrap_new_XdmfTime, METH_VARARGS, NULL}, { (char *)"delete_XdmfTime", _wrap_delete_XdmfTime, METH_VARARGS, NULL}, { (char *)"XdmfTime_GetClassName", _wrap_XdmfTime_GetClassName, METH_VARARGS, NULL}, { (char *)"XdmfTime_Insert", _wrap_XdmfTime_Insert, METH_VARARGS, NULL}, { (char *)"XdmfTime_UpdateInformation", _wrap_XdmfTime_UpdateInformation, METH_VARARGS, NULL}, { (char *)"XdmfTime_SetValue", _wrap_XdmfTime_SetValue, METH_VARARGS, NULL}, { (char *)"XdmfTime_Build", _wrap_XdmfTime_Build, METH_VARARGS, NULL}, { (char *)"XdmfTime_GetValue", _wrap_XdmfTime_GetValue, METH_VARARGS, NULL}, { (char *)"XdmfTime_GetArray", _wrap_XdmfTime_GetArray, METH_VARARGS, NULL}, { (char *)"XdmfTime_SetArray", _wrap_XdmfTime_SetArray, METH_VARARGS, NULL}, { (char *)"XdmfTime_GetDataItem", _wrap_XdmfTime_GetDataItem, METH_VARARGS, NULL}, { (char *)"XdmfTime_SetDataItem", _wrap_XdmfTime_SetDataItem, METH_VARARGS, NULL}, { (char *)"XdmfTime_GetTimeType", _wrap_XdmfTime_GetTimeType, METH_VARARGS, NULL}, { (char *)"XdmfTime_GetTimeTypeAsString", _wrap_XdmfTime_GetTimeTypeAsString, METH_VARARGS, NULL}, { (char *)"XdmfTime_SetTimeType", _wrap_XdmfTime_SetTimeType, METH_VARARGS, NULL}, { (char *)"XdmfTime_GetFunction", _wrap_XdmfTime_GetFunction, METH_VARARGS, NULL}, { (char *)"XdmfTime_SetFunction", _wrap_XdmfTime_SetFunction, METH_VARARGS, NULL}, { (char *)"XdmfTime_SetTimeFromParent", _wrap_XdmfTime_SetTimeFromParent, METH_VARARGS, NULL}, { (char *)"XdmfTime_Evaluate", _wrap_XdmfTime_Evaluate, METH_VARARGS, NULL}, { (char *)"XdmfTime_IsValid", _wrap_XdmfTime_IsValid, METH_VARARGS, NULL}, { (char *)"XdmfTime_SetEpsilon", _wrap_XdmfTime_SetEpsilon, METH_VARARGS, NULL}, { (char *)"XdmfTime_GetEpsilon", _wrap_XdmfTime_GetEpsilon, METH_VARARGS, NULL}, { (char *)"XdmfTime_swigregister", XdmfTime_swigregister, METH_VARARGS, NULL}, { (char *)"new_XdmfRegion", _wrap_new_XdmfRegion, METH_VARARGS, NULL}, { (char *)"delete_XdmfRegion", _wrap_delete_XdmfRegion, METH_VARARGS, NULL}, { (char *)"XdmfRegion_GetClassName", _wrap_XdmfRegion_GetClassName, METH_VARARGS, NULL}, { (char *)"XdmfRegion_SetRegionTypeFromString", _wrap_XdmfRegion_SetRegionTypeFromString, METH_VARARGS, NULL}, { (char *)"XdmfRegion_GetRegionTypeAsString", _wrap_XdmfRegion_GetRegionTypeAsString, METH_VARARGS, NULL}, { (char *)"XdmfRegion_SetRegionType", _wrap_XdmfRegion_SetRegionType, METH_VARARGS, NULL}, { (char *)"XdmfRegion_GetRegionType", _wrap_XdmfRegion_GetRegionType, METH_VARARGS, NULL}, { (char *)"XdmfRegion_GetShapeDesc", _wrap_XdmfRegion_GetShapeDesc, METH_VARARGS, NULL}, { (char *)"XdmfRegion_Insert", _wrap_XdmfRegion_Insert, METH_VARARGS, NULL}, { (char *)"XdmfRegion_SetValues", _wrap_XdmfRegion_SetValues, METH_VARARGS, NULL}, { (char *)"XdmfRegion_GetValues", _wrap_XdmfRegion_GetValues, METH_VARARGS, NULL}, { (char *)"XdmfRegion_UpdateInformation", _wrap_XdmfRegion_UpdateInformation, METH_VARARGS, NULL}, { (char *)"XdmfRegion_Update", _wrap_XdmfRegion_Update, METH_VARARGS, NULL}, { (char *)"XdmfRegion_Build", _wrap_XdmfRegion_Build, METH_VARARGS, NULL}, { (char *)"XdmfRegion_Release", _wrap_XdmfRegion_Release, METH_VARARGS, NULL}, { (char *)"XdmfRegion_swigregister", XdmfRegion_swigregister, METH_VARARGS, NULL}, { (char *)"new_XdmfSet", _wrap_new_XdmfSet, METH_VARARGS, NULL}, { (char *)"delete_XdmfSet", _wrap_delete_XdmfSet, METH_VARARGS, NULL}, { (char *)"XdmfSet_GetClassName", _wrap_XdmfSet_GetClassName, METH_VARARGS, NULL}, { (char *)"XdmfSet_SetSetTypeFromString", _wrap_XdmfSet_SetSetTypeFromString, METH_VARARGS, NULL}, { (char *)"XdmfSet_GetSetTypeAsString", _wrap_XdmfSet_GetSetTypeAsString, METH_VARARGS, NULL}, { (char *)"XdmfSet_SetSetType", _wrap_XdmfSet_SetSetType, METH_VARARGS, NULL}, { (char *)"XdmfSet_GetSetType", _wrap_XdmfSet_GetSetType, METH_VARARGS, NULL}, { (char *)"XdmfSet_GetSize", _wrap_XdmfSet_GetSize, METH_VARARGS, NULL}, { (char *)"XdmfSet_SetSize", _wrap_XdmfSet_SetSize, METH_VARARGS, NULL}, { (char *)"XdmfSet_GetGhost", _wrap_XdmfSet_GetGhost, METH_VARARGS, NULL}, { (char *)"XdmfSet_SetGhost", _wrap_XdmfSet_SetGhost, METH_VARARGS, NULL}, { (char *)"XdmfSet_GetShapeDesc", _wrap_XdmfSet_GetShapeDesc, METH_VARARGS, NULL}, { (char *)"XdmfSet_Insert", _wrap_XdmfSet_Insert, METH_VARARGS, NULL}, { (char *)"XdmfSet_SetIds", _wrap_XdmfSet_SetIds, METH_VARARGS, NULL}, { (char *)"XdmfSet_GetIds", _wrap_XdmfSet_GetIds, METH_VARARGS, NULL}, { (char *)"XdmfSet_SetCellIds", _wrap_XdmfSet_SetCellIds, METH_VARARGS, NULL}, { (char *)"XdmfSet_GetCellIds", _wrap_XdmfSet_GetCellIds, METH_VARARGS, NULL}, { (char *)"XdmfSet_SetFaceIds", _wrap_XdmfSet_SetFaceIds, METH_VARARGS, NULL}, { (char *)"XdmfSet_GetFaceIds", _wrap_XdmfSet_GetFaceIds, METH_VARARGS, NULL}, { (char *)"XdmfSet_GetNumberOfMaps", _wrap_XdmfSet_GetNumberOfMaps, METH_VARARGS, NULL}, { (char *)"XdmfSet_GetMap", _wrap_XdmfSet_GetMap, METH_VARARGS, NULL}, { (char *)"XdmfSet_GetNumberOfAttributes", _wrap_XdmfSet_GetNumberOfAttributes, METH_VARARGS, NULL}, { (char *)"XdmfSet_GetAttribute", _wrap_XdmfSet_GetAttribute, METH_VARARGS, NULL}, { (char *)"XdmfSet_UpdateInformation", _wrap_XdmfSet_UpdateInformation, METH_VARARGS, NULL}, { (char *)"XdmfSet_Update", _wrap_XdmfSet_Update, METH_VARARGS, NULL}, { (char *)"XdmfSet_Build", _wrap_XdmfSet_Build, METH_VARARGS, NULL}, { (char *)"XdmfSet_Release", _wrap_XdmfSet_Release, METH_VARARGS, NULL}, { (char *)"XdmfSet_swigregister", XdmfSet_swigregister, METH_VARARGS, NULL}, { (char *)"new_XdmfMap", _wrap_new_XdmfMap, METH_VARARGS, NULL}, { (char *)"delete_XdmfMap", _wrap_delete_XdmfMap, METH_VARARGS, NULL}, { (char *)"XdmfMap_GetClassName", _wrap_XdmfMap_GetClassName, METH_VARARGS, NULL}, { (char *)"XdmfMap_SetMapTypeFromString", _wrap_XdmfMap_SetMapTypeFromString, METH_VARARGS, NULL}, { (char *)"XdmfMap_GetMapTypeAsString", _wrap_XdmfMap_GetMapTypeAsString, METH_VARARGS, NULL}, { (char *)"XdmfMap_SetMapType", _wrap_XdmfMap_SetMapType, METH_VARARGS, NULL}, { (char *)"XdmfMap_GetMapType", _wrap_XdmfMap_GetMapType, METH_VARARGS, NULL}, { (char *)"XdmfMap_GetItemLength", _wrap_XdmfMap_GetItemLength, METH_VARARGS, NULL}, { (char *)"XdmfMap_SetItemLength", _wrap_XdmfMap_SetItemLength, METH_VARARGS, NULL}, { (char *)"XdmfMap_GetMapLength", _wrap_XdmfMap_GetMapLength, METH_VARARGS, NULL}, { (char *)"XdmfMap_SetMapLength", _wrap_XdmfMap_SetMapLength, METH_VARARGS, NULL}, { (char *)"XdmfMap_Insert", _wrap_XdmfMap_Insert, METH_VARARGS, NULL}, { (char *)"XdmfMap_SetIds", _wrap_XdmfMap_SetIds, METH_VARARGS, NULL}, { (char *)"XdmfMap_GetIds", _wrap_XdmfMap_GetIds, METH_VARARGS, NULL}, { (char *)"XdmfMap_SetMapIndex", _wrap_XdmfMap_SetMapIndex, METH_VARARGS, NULL}, { (char *)"XdmfMap_GetMapIndex", _wrap_XdmfMap_GetMapIndex, METH_VARARGS, NULL}, { (char *)"XdmfMap_SetMapData", _wrap_XdmfMap_SetMapData, METH_VARARGS, NULL}, { (char *)"XdmfMap_GetMapData", _wrap_XdmfMap_GetMapData, METH_VARARGS, NULL}, { (char *)"XdmfMap_UpdateInformation", _wrap_XdmfMap_UpdateInformation, METH_VARARGS, NULL}, { (char *)"XdmfMap_Update", _wrap_XdmfMap_Update, METH_VARARGS, NULL}, { (char *)"XdmfMap_Build", _wrap_XdmfMap_Build, METH_VARARGS, NULL}, { (char *)"XdmfMap_Release", _wrap_XdmfMap_Release, METH_VARARGS, NULL}, { (char *)"XdmfMap_swigregister", XdmfMap_swigregister, METH_VARARGS, NULL}, { (char *)"new_XdmfDsm", _wrap_new_XdmfDsm, METH_VARARGS, NULL}, { (char *)"delete_XdmfDsm", _wrap_delete_XdmfDsm, METH_VARARGS, NULL}, { (char *)"XdmfDsm_GetClassName", _wrap_XdmfDsm_GetClassName, METH_VARARGS, NULL}, { (char *)"XdmfDsm_GetDsmType", _wrap_XdmfDsm_GetDsmType, METH_VARARGS, NULL}, { (char *)"XdmfDsm_SetDsmType", _wrap_XdmfDsm_SetDsmType, METH_VARARGS, NULL}, { (char *)"XdmfDsm_GetEndAddress", _wrap_XdmfDsm_GetEndAddress, METH_VARARGS, NULL}, { (char *)"XdmfDsm_SetEndAddress", _wrap_XdmfDsm_SetEndAddress, METH_VARARGS, NULL}, { (char *)"XdmfDsm_GetStartAddress", _wrap_XdmfDsm_GetStartAddress, METH_VARARGS, NULL}, { (char *)"XdmfDsm_SetStartAddress", _wrap_XdmfDsm_SetStartAddress, METH_VARARGS, NULL}, { (char *)"XdmfDsm_GetStartServerId", _wrap_XdmfDsm_GetStartServerId, METH_VARARGS, NULL}, { (char *)"XdmfDsm_SetStartServerId", _wrap_XdmfDsm_SetStartServerId, METH_VARARGS, NULL}, { (char *)"XdmfDsm_GetEndServerId", _wrap_XdmfDsm_GetEndServerId, METH_VARARGS, NULL}, { (char *)"XdmfDsm_SetEndServerId", _wrap_XdmfDsm_SetEndServerId, METH_VARARGS, NULL}, { (char *)"XdmfDsm_GetLength", _wrap_XdmfDsm_GetLength, METH_VARARGS, NULL}, { (char *)"XdmfDsm_SetLength", _wrap_XdmfDsm_SetLength, METH_VARARGS, NULL}, { (char *)"XdmfDsm_GetTotalLength", _wrap_XdmfDsm_GetTotalLength, METH_VARARGS, NULL}, { (char *)"XdmfDsm_SetTotalLength", _wrap_XdmfDsm_SetTotalLength, METH_VARARGS, NULL}, { (char *)"XdmfDsm_GetStorage", _wrap_XdmfDsm_GetStorage, METH_VARARGS, NULL}, { (char *)"XdmfDsm_SetStorage", _wrap_XdmfDsm_SetStorage, METH_VARARGS, NULL}, { (char *)"XdmfDsm_GetComm", _wrap_XdmfDsm_GetComm, METH_VARARGS, NULL}, { (char *)"XdmfDsm_SetComm", _wrap_XdmfDsm_SetComm, METH_VARARGS, NULL}, { (char *)"XdmfDsm_GetMsg", _wrap_XdmfDsm_GetMsg, METH_VARARGS, NULL}, { (char *)"XdmfDsm_SetMsg", _wrap_XdmfDsm_SetMsg, METH_VARARGS, NULL}, { (char *)"XdmfDsm_GetAddressRangeForId", _wrap_XdmfDsm_GetAddressRangeForId, METH_VARARGS, NULL}, { (char *)"XdmfDsm_ConfigureUniform", _wrap_XdmfDsm_ConfigureUniform, METH_VARARGS, NULL}, { (char *)"XdmfDsm_AddressToId", _wrap_XdmfDsm_AddressToId, METH_VARARGS, NULL}, { (char *)"XdmfDsm_SendCommandHeader", _wrap_XdmfDsm_SendCommandHeader, METH_VARARGS, NULL}, { (char *)"XdmfDsm_ReceiveCommandHeader", _wrap_XdmfDsm_ReceiveCommandHeader, METH_VARARGS, NULL}, { (char *)"XdmfDsm_SendData", _wrap_XdmfDsm_SendData, METH_VARARGS, NULL}, { (char *)"XdmfDsm_ReceiveData", _wrap_XdmfDsm_ReceiveData, METH_VARARGS, NULL}, { (char *)"XdmfDsm_Copy", _wrap_XdmfDsm_Copy, METH_VARARGS, NULL}, { (char *)"XdmfDsm_SendDone", _wrap_XdmfDsm_SendDone, METH_VARARGS, NULL}, { (char *)"XdmfDsm_swigregister", XdmfDsm_swigregister, METH_VARARGS, NULL}, { (char *)"new_XdmfDsmMsg", _wrap_new_XdmfDsmMsg, METH_VARARGS, NULL}, { (char *)"delete_XdmfDsmMsg", _wrap_delete_XdmfDsmMsg, METH_VARARGS, NULL}, { (char *)"XdmfDsmMsg_SetSource", _wrap_XdmfDsmMsg_SetSource, METH_VARARGS, NULL}, { (char *)"XdmfDsmMsg_GetSource", _wrap_XdmfDsmMsg_GetSource, METH_VARARGS, NULL}, { (char *)"XdmfDsmMsg_SetDest", _wrap_XdmfDsmMsg_SetDest, METH_VARARGS, NULL}, { (char *)"XdmfDsmMsg_GetDest", _wrap_XdmfDsmMsg_GetDest, METH_VARARGS, NULL}, { (char *)"XdmfDsmMsg_SetTag", _wrap_XdmfDsmMsg_SetTag, METH_VARARGS, NULL}, { (char *)"XdmfDsmMsg_GetTag", _wrap_XdmfDsmMsg_GetTag, METH_VARARGS, NULL}, { (char *)"XdmfDsmMsg_SetLength", _wrap_XdmfDsmMsg_SetLength, METH_VARARGS, NULL}, { (char *)"XdmfDsmMsg_GetLength", _wrap_XdmfDsmMsg_GetLength, METH_VARARGS, NULL}, { (char *)"XdmfDsmMsg_SetData", _wrap_XdmfDsmMsg_SetData, METH_VARARGS, NULL}, { (char *)"XdmfDsmMsg_GetData", _wrap_XdmfDsmMsg_GetData, METH_VARARGS, NULL}, { (char *)"XdmfDsmMsg_Source_set", _wrap_XdmfDsmMsg_Source_set, METH_VARARGS, NULL}, { (char *)"XdmfDsmMsg_Source_get", _wrap_XdmfDsmMsg_Source_get, METH_VARARGS, NULL}, { (char *)"XdmfDsmMsg_Dest_set", _wrap_XdmfDsmMsg_Dest_set, METH_VARARGS, NULL}, { (char *)"XdmfDsmMsg_Dest_get", _wrap_XdmfDsmMsg_Dest_get, METH_VARARGS, NULL}, { (char *)"XdmfDsmMsg_Tag_set", _wrap_XdmfDsmMsg_Tag_set, METH_VARARGS, NULL}, { (char *)"XdmfDsmMsg_Tag_get", _wrap_XdmfDsmMsg_Tag_get, METH_VARARGS, NULL}, { (char *)"XdmfDsmMsg_Length_set", _wrap_XdmfDsmMsg_Length_set, METH_VARARGS, NULL}, { (char *)"XdmfDsmMsg_Length_get", _wrap_XdmfDsmMsg_Length_get, METH_VARARGS, NULL}, { (char *)"XdmfDsmMsg_Data_set", _wrap_XdmfDsmMsg_Data_set, METH_VARARGS, NULL}, { (char *)"XdmfDsmMsg_Data_get", _wrap_XdmfDsmMsg_Data_get, METH_VARARGS, NULL}, { (char *)"XdmfDsmMsg_swigregister", XdmfDsmMsg_swigregister, METH_VARARGS, NULL}, { (char *)"XdmfDsmBufferServiceThread", _wrap_XdmfDsmBufferServiceThread, METH_VARARGS, NULL}, { (char *)"new_XdmfDsmBuffer", _wrap_new_XdmfDsmBuffer, METH_VARARGS, NULL}, { (char *)"delete_XdmfDsmBuffer", _wrap_delete_XdmfDsmBuffer, METH_VARARGS, NULL}, { (char *)"XdmfDsmBuffer_GetClassName", _wrap_XdmfDsmBuffer_GetClassName, METH_VARARGS, NULL}, { (char *)"XdmfDsmBuffer_GetThreadDsmReady", _wrap_XdmfDsmBuffer_GetThreadDsmReady, METH_VARARGS, NULL}, { (char *)"XdmfDsmBuffer_SetThreadDsmReady", _wrap_XdmfDsmBuffer_SetThreadDsmReady, METH_VARARGS, NULL}, { (char *)"XdmfDsmBuffer_Put", _wrap_XdmfDsmBuffer_Put, METH_VARARGS, NULL}, { (char *)"XdmfDsmBuffer_Get", _wrap_XdmfDsmBuffer_Get, METH_VARARGS, NULL}, { (char *)"XdmfDsmBuffer_Aquire", _wrap_XdmfDsmBuffer_Aquire, METH_VARARGS, NULL}, { (char *)"XdmfDsmBuffer_Release", _wrap_XdmfDsmBuffer_Release, METH_VARARGS, NULL}, { (char *)"XdmfDsmBuffer_ServiceInit", _wrap_XdmfDsmBuffer_ServiceInit, METH_VARARGS, NULL}, { (char *)"XdmfDsmBuffer_ServiceOnce", _wrap_XdmfDsmBuffer_ServiceOnce, METH_VARARGS, NULL}, { (char *)"XdmfDsmBuffer_ServiceUntilIdle", _wrap_XdmfDsmBuffer_ServiceUntilIdle, METH_VARARGS, NULL}, { (char *)"XdmfDsmBuffer_ServiceLoop", _wrap_XdmfDsmBuffer_ServiceLoop, METH_VARARGS, NULL}, { (char *)"XdmfDsmBuffer_Service", _wrap_XdmfDsmBuffer_Service, METH_VARARGS, NULL}, { (char *)"XdmfDsmBuffer_ServiceThread", _wrap_XdmfDsmBuffer_ServiceThread, METH_VARARGS, NULL}, { (char *)"XdmfDsmBuffer_swigregister", XdmfDsmBuffer_swigregister, METH_VARARGS, NULL}, { (char *)"new_XdmfDsmComm", _wrap_new_XdmfDsmComm, METH_VARARGS, NULL}, { (char *)"delete_XdmfDsmComm", _wrap_delete_XdmfDsmComm, METH_VARARGS, NULL}, { (char *)"XdmfDsmComm_GetClassName", _wrap_XdmfDsmComm_GetClassName, METH_VARARGS, NULL}, { (char *)"XdmfDsmComm_GetId", _wrap_XdmfDsmComm_GetId, METH_VARARGS, NULL}, { (char *)"XdmfDsmComm_SetId", _wrap_XdmfDsmComm_SetId, METH_VARARGS, NULL}, { (char *)"XdmfDsmComm_GetTotalSize", _wrap_XdmfDsmComm_GetTotalSize, METH_VARARGS, NULL}, { (char *)"XdmfDsmComm_SetTotalSize", _wrap_XdmfDsmComm_SetTotalSize, METH_VARARGS, NULL}, { (char *)"XdmfDsmComm_Init", _wrap_XdmfDsmComm_Init, METH_VARARGS, NULL}, { (char *)"XdmfDsmComm_Send", _wrap_XdmfDsmComm_Send, METH_VARARGS, NULL}, { (char *)"XdmfDsmComm_Receive", _wrap_XdmfDsmComm_Receive, METH_VARARGS, NULL}, { (char *)"XdmfDsmComm_Check", _wrap_XdmfDsmComm_Check, METH_VARARGS, NULL}, { (char *)"XdmfDsmComm_Barrier", _wrap_XdmfDsmComm_Barrier, METH_VARARGS, NULL}, { (char *)"XdmfDsmComm_swigregister", XdmfDsmComm_swigregister, METH_VARARGS, NULL}, { NULL, NULL, 0, NULL } }; /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ static void *_p_XdmfValuesXMLTo_p_XdmfValues(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfValues *) ((XdmfValuesXML *) x)); } static void *_p_XdmfValuesHDFTo_p_XdmfValues(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfValues *) ((XdmfValuesHDF *) x)); } static void *_p_XdmfDataStructureTo_p_XdmfDataItem(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfDataItem *) ((XdmfDataStructure *) x)); } static void *_p_XdmfValuesXMLTo_p_XdmfDataItem(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfDataItem *) (XdmfValues *) ((XdmfValuesXML *) x)); } static void *_p_XdmfValuesTo_p_XdmfDataItem(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfDataItem *) ((XdmfValues *) x)); } static void *_p_XdmfValuesHDFTo_p_XdmfDataItem(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfDataItem *) (XdmfValues *) ((XdmfValuesHDF *) x)); } static void *_p_XdmfLightDataTo_p_XdmfObject(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfObject *) ((XdmfLightData *) x)); } static void *_p_XdmfDOMTo_p_XdmfObject(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfObject *) (XdmfLightData *) ((XdmfDOM *) x)); } static void *_p_XdmfDsmMsgTo_p_XdmfObject(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfObject *) ((XdmfDsmMsg *) x)); } static void *_p_XdmfDataItemTo_p_XdmfObject(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfObject *) (XdmfLightData *)(XdmfElement *) ((XdmfDataItem *) x)); } static void *_p_XdmfInformationTo_p_XdmfObject(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfObject *) (XdmfLightData *)(XdmfElement *) ((XdmfInformation *) x)); } static void *_p_XdmfMapTo_p_XdmfObject(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfObject *) (XdmfLightData *)(XdmfElement *) ((XdmfMap *) x)); } static void *_p_XdmfValuesHDFTo_p_XdmfObject(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfObject *) (XdmfLightData *)(XdmfElement *)(XdmfDataItem *)(XdmfValues *) ((XdmfValuesHDF *) x)); } static void *_p_XdmfGridTo_p_XdmfObject(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfObject *) (XdmfLightData *)(XdmfElement *) ((XdmfGrid *) x)); } static void *_p_XdmfValuesXMLTo_p_XdmfObject(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfObject *) (XdmfLightData *)(XdmfElement *)(XdmfDataItem *)(XdmfValues *) ((XdmfValuesXML *) x)); } static void *_p_XdmfSetTo_p_XdmfObject(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfObject *) (XdmfLightData *)(XdmfElement *) ((XdmfSet *) x)); } static void *_p_XdmfHeavyDataTo_p_XdmfObject(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfObject *) (XdmfDataDesc *) ((XdmfHeavyData *) x)); } static void *_p_XdmfAttributeTo_p_XdmfObject(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfObject *) (XdmfLightData *)(XdmfElement *) ((XdmfAttribute *) x)); } static void *_p_XdmfValuesTo_p_XdmfObject(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfObject *) (XdmfLightData *)(XdmfElement *)(XdmfDataItem *) ((XdmfValues *) x)); } static void *_p_XdmfDomainTo_p_XdmfObject(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfObject *) (XdmfLightData *)(XdmfElement *) ((XdmfDomain *) x)); } static void *_p_XdmfRootTo_p_XdmfObject(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfObject *) (XdmfLightData *)(XdmfElement *) ((XdmfRoot *) x)); } static void *_p_XdmfTimeTo_p_XdmfObject(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfObject *) (XdmfLightData *)(XdmfElement *) ((XdmfTime *) x)); } static void *_p_XdmfTopologyTo_p_XdmfObject(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfObject *) (XdmfLightData *)(XdmfElement *) ((XdmfTopology *) x)); } static void *_p_XdmfDataDescTo_p_XdmfObject(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfObject *) ((XdmfDataDesc *) x)); } static void *_p_XdmfDsmTo_p_XdmfObject(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfObject *) ((XdmfDsm *) x)); } static void *_p_XdmfArrayTo_p_XdmfObject(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfObject *) (XdmfDataDesc *) ((XdmfArray *) x)); } static void *_p_XdmfDsmCommTo_p_XdmfObject(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfObject *) ((XdmfDsmComm *) x)); } static void *_p_XdmfElementTo_p_XdmfObject(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfObject *) (XdmfLightData *) ((XdmfElement *) x)); } static void *_p_XdmfGeometryTo_p_XdmfObject(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfObject *) (XdmfLightData *)(XdmfElement *) ((XdmfGeometry *) x)); } static void *_p_XdmfRegionTo_p_XdmfObject(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfObject *) (XdmfLightData *)(XdmfElement *) ((XdmfRegion *) x)); } static void *_p_XdmfHDFTo_p_XdmfObject(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfObject *) (XdmfDataDesc *)(XdmfHeavyData *) ((XdmfHDF *) x)); } static void *_p_XdmfDataStructureTo_p_XdmfObject(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfObject *) (XdmfLightData *)(XdmfElement *)(XdmfDataItem *) ((XdmfDataStructure *) x)); } static void *_p_XdmfDsmBufferTo_p_XdmfObject(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfObject *) (XdmfDsm *) ((XdmfDsmBuffer *) x)); } static void *_p_XdmfDsmBufferTo_p_XdmfDsm(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfDsm *) ((XdmfDsmBuffer *) x)); } static void *_p_XdmfDOMTo_p_XdmfLightData(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfLightData *) ((XdmfDOM *) x)); } static void *_p_XdmfDataItemTo_p_XdmfLightData(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfLightData *) (XdmfElement *) ((XdmfDataItem *) x)); } static void *_p_XdmfInformationTo_p_XdmfLightData(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfLightData *) (XdmfElement *) ((XdmfInformation *) x)); } static void *_p_XdmfMapTo_p_XdmfLightData(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfLightData *) (XdmfElement *) ((XdmfMap *) x)); } static void *_p_XdmfValuesHDFTo_p_XdmfLightData(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfLightData *) (XdmfElement *)(XdmfDataItem *)(XdmfValues *) ((XdmfValuesHDF *) x)); } static void *_p_XdmfGridTo_p_XdmfLightData(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfLightData *) (XdmfElement *) ((XdmfGrid *) x)); } static void *_p_XdmfValuesXMLTo_p_XdmfLightData(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfLightData *) (XdmfElement *)(XdmfDataItem *)(XdmfValues *) ((XdmfValuesXML *) x)); } static void *_p_XdmfSetTo_p_XdmfLightData(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfLightData *) (XdmfElement *) ((XdmfSet *) x)); } static void *_p_XdmfAttributeTo_p_XdmfLightData(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfLightData *) (XdmfElement *) ((XdmfAttribute *) x)); } static void *_p_XdmfValuesTo_p_XdmfLightData(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfLightData *) (XdmfElement *)(XdmfDataItem *) ((XdmfValues *) x)); } static void *_p_XdmfRootTo_p_XdmfLightData(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfLightData *) (XdmfElement *) ((XdmfRoot *) x)); } static void *_p_XdmfDomainTo_p_XdmfLightData(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfLightData *) (XdmfElement *) ((XdmfDomain *) x)); } static void *_p_XdmfTimeTo_p_XdmfLightData(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfLightData *) (XdmfElement *) ((XdmfTime *) x)); } static void *_p_XdmfTopologyTo_p_XdmfLightData(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfLightData *) (XdmfElement *) ((XdmfTopology *) x)); } static void *_p_XdmfGeometryTo_p_XdmfLightData(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfLightData *) (XdmfElement *) ((XdmfGeometry *) x)); } static void *_p_XdmfElementTo_p_XdmfLightData(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfLightData *) ((XdmfElement *) x)); } static void *_p_XdmfRegionTo_p_XdmfLightData(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfLightData *) (XdmfElement *) ((XdmfRegion *) x)); } static void *_p_XdmfDataStructureTo_p_XdmfLightData(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfLightData *) (XdmfElement *)(XdmfDataItem *) ((XdmfDataStructure *) x)); } static void *_p_XdmfHDFTo_p_XdmfHeavyData(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfHeavyData *) ((XdmfHDF *) x)); } static void *_p_XdmfDataItemTo_p_XdmfElement(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfElement *) ((XdmfDataItem *) x)); } static void *_p_XdmfInformationTo_p_XdmfElement(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfElement *) ((XdmfInformation *) x)); } static void *_p_XdmfMapTo_p_XdmfElement(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfElement *) ((XdmfMap *) x)); } static void *_p_XdmfValuesHDFTo_p_XdmfElement(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfElement *) (XdmfDataItem *)(XdmfValues *) ((XdmfValuesHDF *) x)); } static void *_p_XdmfGridTo_p_XdmfElement(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfElement *) ((XdmfGrid *) x)); } static void *_p_XdmfValuesXMLTo_p_XdmfElement(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfElement *) (XdmfDataItem *)(XdmfValues *) ((XdmfValuesXML *) x)); } static void *_p_XdmfSetTo_p_XdmfElement(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfElement *) ((XdmfSet *) x)); } static void *_p_XdmfAttributeTo_p_XdmfElement(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfElement *) ((XdmfAttribute *) x)); } static void *_p_XdmfValuesTo_p_XdmfElement(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfElement *) (XdmfDataItem *) ((XdmfValues *) x)); } static void *_p_XdmfTimeTo_p_XdmfElement(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfElement *) ((XdmfTime *) x)); } static void *_p_XdmfRootTo_p_XdmfElement(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfElement *) ((XdmfRoot *) x)); } static void *_p_XdmfDomainTo_p_XdmfElement(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfElement *) ((XdmfDomain *) x)); } static void *_p_XdmfTopologyTo_p_XdmfElement(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfElement *) ((XdmfTopology *) x)); } static void *_p_XdmfRegionTo_p_XdmfElement(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfElement *) ((XdmfRegion *) x)); } static void *_p_XdmfGeometryTo_p_XdmfElement(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfElement *) ((XdmfGeometry *) x)); } static void *_p_XdmfDataStructureTo_p_XdmfElement(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfElement *) (XdmfDataItem *) ((XdmfDataStructure *) x)); } static void *_p_XdmfHeavyDataTo_p_XdmfDataDesc(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfDataDesc *) ((XdmfHeavyData *) x)); } static void *_p_XdmfArrayTo_p_XdmfDataDesc(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfDataDesc *) ((XdmfArray *) x)); } static void *_p_XdmfHDFTo_p_XdmfDataDesc(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((XdmfDataDesc *) (XdmfHeavyData *) ((XdmfHDF *) x)); } static swig_type_info _swigt__p_XdmfArray = {"_p_XdmfArray", "XdmfArray *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_XdmfArrayList = {"_p_XdmfArrayList", "XdmfArrayList *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_XdmfAttribute = {"_p_XdmfAttribute", "XdmfAttribute *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_XdmfCloseCallback = {"_p_XdmfCloseCallback", "XdmfCloseCallback *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_XdmfDOM = {"_p_XdmfDOM", "XdmfDOM *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_XdmfDataDesc = {"_p_XdmfDataDesc", "XdmfDataDesc *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_XdmfDataItem = {"_p_XdmfDataItem", "XdmfDataItem *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_XdmfDataStructure = {"_p_XdmfDataStructure", "XdmfDataStructure *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_XdmfDomain = {"_p_XdmfDomain", "XdmfDomain *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_XdmfDsm = {"_p_XdmfDsm", "XdmfDsm *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_XdmfDsmBuffer = {"_p_XdmfDsmBuffer", "XdmfDsmBuffer *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_XdmfDsmComm = {"_p_XdmfDsmComm", "XdmfDsmComm *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_XdmfDsmMsg = {"_p_XdmfDsmMsg", "XdmfDsmMsg *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_XdmfElement = {"_p_XdmfElement", "XdmfElement *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_XdmfGeometry = {"_p_XdmfGeometry", "XdmfGeometry *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_XdmfGrid = {"_p_XdmfGrid", "XdmfGrid *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_XdmfHDF = {"_p_XdmfHDF", "XdmfHDF *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_XdmfHeavyData = {"_p_XdmfHeavyData", "XdmfHeavyData *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_XdmfInformation = {"_p_XdmfInformation", "XdmfInformation *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_XdmfLightData = {"_p_XdmfLightData", "XdmfLightData *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_XdmfMap = {"_p_XdmfMap", "XdmfMap *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_XdmfObject = {"_p_XdmfObject", "XdmfObject *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_XdmfOpenCallback = {"_p_XdmfOpenCallback", "XdmfOpenCallback *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_XdmfReadCallback = {"_p_XdmfReadCallback", "XdmfReadCallback *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_XdmfRegion = {"_p_XdmfRegion", "XdmfRegion *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_XdmfRoot = {"_p_XdmfRoot", "XdmfRoot *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_XdmfSet = {"_p_XdmfSet", "XdmfSet *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_XdmfTime = {"_p_XdmfTime", "XdmfTime *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_XdmfTopology = {"_p_XdmfTopology", "XdmfTopology *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_XdmfValues = {"_p_XdmfValues", "XdmfValues *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_XdmfValuesHDF = {"_p_XdmfValuesHDF", "XdmfValuesHDF *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_XdmfValuesXML = {"_p_XdmfValuesXML", "XdmfValuesXML *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_XdmfWriteCallback = {"_p_XdmfWriteCallback", "XdmfWriteCallback *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p__xmlNode = {"_p__xmlNode", "XdmfXmlNode|_xmlNode *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_char = {"_p_char", "char *|XdmfInt8 *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_double = {"_p_double", "XdmfFloat64 *|double *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_float = {"_p_float", "float *|XdmfFloat32 *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_hid_t = {"_p_hid_t", "hid_t *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_int = {"_p_int", "int *|XdmfInt32 *|XdmfBoolean *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_istream = {"_p_istream", "istream *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_long_long = {"_p_long_long", "XdmfInt64 *|long long *|XdmfLength *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_ostream = {"_p_ostream", "ostream *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_p__xmlDoc = {"_p_p__xmlDoc", "XdmfXmlDoc *|_xmlDoc **", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_short = {"_p_short", "XdmfInt16 *|short *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_unsigned_char = {"_p_unsigned_char", "unsigned char *|XdmfUInt8 *|XdmfByte *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_unsigned_int = {"_p_unsigned_int", "XdmfUInt32 *|unsigned int *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_unsigned_short = {"_p_unsigned_short", "XdmfUInt16 *|unsigned short *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_void = {"_p_void", "XdmfPointer|void *", 0, 0, (void*)0, 0}; static swig_type_info *swig_type_initial[] = { &_swigt__p_XdmfArray, &_swigt__p_XdmfArrayList, &_swigt__p_XdmfAttribute, &_swigt__p_XdmfCloseCallback, &_swigt__p_XdmfDOM, &_swigt__p_XdmfDataDesc, &_swigt__p_XdmfDataItem, &_swigt__p_XdmfDataStructure, &_swigt__p_XdmfDomain, &_swigt__p_XdmfDsm, &_swigt__p_XdmfDsmBuffer, &_swigt__p_XdmfDsmComm, &_swigt__p_XdmfDsmMsg, &_swigt__p_XdmfElement, &_swigt__p_XdmfGeometry, &_swigt__p_XdmfGrid, &_swigt__p_XdmfHDF, &_swigt__p_XdmfHeavyData, &_swigt__p_XdmfInformation, &_swigt__p_XdmfLightData, &_swigt__p_XdmfMap, &_swigt__p_XdmfObject, &_swigt__p_XdmfOpenCallback, &_swigt__p_XdmfReadCallback, &_swigt__p_XdmfRegion, &_swigt__p_XdmfRoot, &_swigt__p_XdmfSet, &_swigt__p_XdmfTime, &_swigt__p_XdmfTopology, &_swigt__p_XdmfValues, &_swigt__p_XdmfValuesHDF, &_swigt__p_XdmfValuesXML, &_swigt__p_XdmfWriteCallback, &_swigt__p__xmlNode, &_swigt__p_char, &_swigt__p_double, &_swigt__p_float, &_swigt__p_hid_t, &_swigt__p_int, &_swigt__p_istream, &_swigt__p_long_long, &_swigt__p_ostream, &_swigt__p_p__xmlDoc, &_swigt__p_short, &_swigt__p_unsigned_char, &_swigt__p_unsigned_int, &_swigt__p_unsigned_short, &_swigt__p_void, }; static swig_cast_info _swigc__p_XdmfArray[] = { {&_swigt__p_XdmfArray, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_XdmfArrayList[] = { {&_swigt__p_XdmfArrayList, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_XdmfAttribute[] = { {&_swigt__p_XdmfAttribute, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_XdmfCloseCallback[] = { {&_swigt__p_XdmfCloseCallback, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_XdmfDOM[] = { {&_swigt__p_XdmfDOM, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_XdmfDataDesc[] = { {&_swigt__p_XdmfHeavyData, _p_XdmfHeavyDataTo_p_XdmfDataDesc, 0, 0}, {&_swigt__p_XdmfArray, _p_XdmfArrayTo_p_XdmfDataDesc, 0, 0}, {&_swigt__p_XdmfDataDesc, 0, 0, 0}, {&_swigt__p_XdmfHDF, _p_XdmfHDFTo_p_XdmfDataDesc, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_XdmfDataItem[] = { {&_swigt__p_XdmfDataItem, 0, 0, 0}, {&_swigt__p_XdmfDataStructure, _p_XdmfDataStructureTo_p_XdmfDataItem, 0, 0}, {&_swigt__p_XdmfValuesXML, _p_XdmfValuesXMLTo_p_XdmfDataItem, 0, 0}, {&_swigt__p_XdmfValues, _p_XdmfValuesTo_p_XdmfDataItem, 0, 0}, {&_swigt__p_XdmfValuesHDF, _p_XdmfValuesHDFTo_p_XdmfDataItem, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_XdmfDataStructure[] = { {&_swigt__p_XdmfDataStructure, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_XdmfDomain[] = { {&_swigt__p_XdmfDomain, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_XdmfDsm[] = { {&_swigt__p_XdmfDsmBuffer, _p_XdmfDsmBufferTo_p_XdmfDsm, 0, 0}, {&_swigt__p_XdmfDsm, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_XdmfDsmBuffer[] = { {&_swigt__p_XdmfDsmBuffer, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_XdmfDsmComm[] = { {&_swigt__p_XdmfDsmComm, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_XdmfDsmMsg[] = { {&_swigt__p_XdmfDsmMsg, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_XdmfElement[] = { {&_swigt__p_XdmfMap, _p_XdmfMapTo_p_XdmfElement, 0, 0}, {&_swigt__p_XdmfDataItem, _p_XdmfDataItemTo_p_XdmfElement, 0, 0}, {&_swigt__p_XdmfInformation, _p_XdmfInformationTo_p_XdmfElement, 0, 0}, {&_swigt__p_XdmfValuesHDF, _p_XdmfValuesHDFTo_p_XdmfElement, 0, 0}, {&_swigt__p_XdmfGrid, _p_XdmfGridTo_p_XdmfElement, 0, 0}, {&_swigt__p_XdmfValuesXML, _p_XdmfValuesXMLTo_p_XdmfElement, 0, 0}, {&_swigt__p_XdmfSet, _p_XdmfSetTo_p_XdmfElement, 0, 0}, {&_swigt__p_XdmfAttribute, _p_XdmfAttributeTo_p_XdmfElement, 0, 0}, {&_swigt__p_XdmfValues, _p_XdmfValuesTo_p_XdmfElement, 0, 0}, {&_swigt__p_XdmfTime, _p_XdmfTimeTo_p_XdmfElement, 0, 0}, {&_swigt__p_XdmfRoot, _p_XdmfRootTo_p_XdmfElement, 0, 0}, {&_swigt__p_XdmfDomain, _p_XdmfDomainTo_p_XdmfElement, 0, 0}, {&_swigt__p_XdmfTopology, _p_XdmfTopologyTo_p_XdmfElement, 0, 0}, {&_swigt__p_XdmfElement, 0, 0, 0}, {&_swigt__p_XdmfRegion, _p_XdmfRegionTo_p_XdmfElement, 0, 0}, {&_swigt__p_XdmfGeometry, _p_XdmfGeometryTo_p_XdmfElement, 0, 0}, {&_swigt__p_XdmfDataStructure, _p_XdmfDataStructureTo_p_XdmfElement, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_XdmfGeometry[] = { {&_swigt__p_XdmfGeometry, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_XdmfGrid[] = { {&_swigt__p_XdmfGrid, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_XdmfHDF[] = { {&_swigt__p_XdmfHDF, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_XdmfHeavyData[] = { {&_swigt__p_XdmfHeavyData, 0, 0, 0}, {&_swigt__p_XdmfHDF, _p_XdmfHDFTo_p_XdmfHeavyData, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_XdmfInformation[] = { {&_swigt__p_XdmfInformation, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_XdmfLightData[] = { {&_swigt__p_XdmfLightData, 0, 0, 0}, {&_swigt__p_XdmfDOM, _p_XdmfDOMTo_p_XdmfLightData, 0, 0}, {&_swigt__p_XdmfMap, _p_XdmfMapTo_p_XdmfLightData, 0, 0}, {&_swigt__p_XdmfDataItem, _p_XdmfDataItemTo_p_XdmfLightData, 0, 0}, {&_swigt__p_XdmfInformation, _p_XdmfInformationTo_p_XdmfLightData, 0, 0}, {&_swigt__p_XdmfValuesHDF, _p_XdmfValuesHDFTo_p_XdmfLightData, 0, 0}, {&_swigt__p_XdmfGrid, _p_XdmfGridTo_p_XdmfLightData, 0, 0}, {&_swigt__p_XdmfValuesXML, _p_XdmfValuesXMLTo_p_XdmfLightData, 0, 0}, {&_swigt__p_XdmfSet, _p_XdmfSetTo_p_XdmfLightData, 0, 0}, {&_swigt__p_XdmfAttribute, _p_XdmfAttributeTo_p_XdmfLightData, 0, 0}, {&_swigt__p_XdmfValues, _p_XdmfValuesTo_p_XdmfLightData, 0, 0}, {&_swigt__p_XdmfTime, _p_XdmfTimeTo_p_XdmfLightData, 0, 0}, {&_swigt__p_XdmfDomain, _p_XdmfDomainTo_p_XdmfLightData, 0, 0}, {&_swigt__p_XdmfRoot, _p_XdmfRootTo_p_XdmfLightData, 0, 0}, {&_swigt__p_XdmfTopology, _p_XdmfTopologyTo_p_XdmfLightData, 0, 0}, {&_swigt__p_XdmfGeometry, _p_XdmfGeometryTo_p_XdmfLightData, 0, 0}, {&_swigt__p_XdmfElement, _p_XdmfElementTo_p_XdmfLightData, 0, 0}, {&_swigt__p_XdmfRegion, _p_XdmfRegionTo_p_XdmfLightData, 0, 0}, {&_swigt__p_XdmfDataStructure, _p_XdmfDataStructureTo_p_XdmfLightData, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_XdmfMap[] = { {&_swigt__p_XdmfMap, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_XdmfObject[] = { {&_swigt__p_XdmfLightData, _p_XdmfLightDataTo_p_XdmfObject, 0, 0}, {&_swigt__p_XdmfDOM, _p_XdmfDOMTo_p_XdmfObject, 0, 0}, {&_swigt__p_XdmfObject, 0, 0, 0}, {&_swigt__p_XdmfDsmMsg, _p_XdmfDsmMsgTo_p_XdmfObject, 0, 0}, {&_swigt__p_XdmfMap, _p_XdmfMapTo_p_XdmfObject, 0, 0}, {&_swigt__p_XdmfDataItem, _p_XdmfDataItemTo_p_XdmfObject, 0, 0}, {&_swigt__p_XdmfInformation, _p_XdmfInformationTo_p_XdmfObject, 0, 0}, {&_swigt__p_XdmfValuesHDF, _p_XdmfValuesHDFTo_p_XdmfObject, 0, 0}, {&_swigt__p_XdmfGrid, _p_XdmfGridTo_p_XdmfObject, 0, 0}, {&_swigt__p_XdmfValuesXML, _p_XdmfValuesXMLTo_p_XdmfObject, 0, 0}, {&_swigt__p_XdmfSet, _p_XdmfSetTo_p_XdmfObject, 0, 0}, {&_swigt__p_XdmfHeavyData, _p_XdmfHeavyDataTo_p_XdmfObject, 0, 0}, {&_swigt__p_XdmfAttribute, _p_XdmfAttributeTo_p_XdmfObject, 0, 0}, {&_swigt__p_XdmfValues, _p_XdmfValuesTo_p_XdmfObject, 0, 0}, {&_swigt__p_XdmfTime, _p_XdmfTimeTo_p_XdmfObject, 0, 0}, {&_swigt__p_XdmfDomain, _p_XdmfDomainTo_p_XdmfObject, 0, 0}, {&_swigt__p_XdmfRoot, _p_XdmfRootTo_p_XdmfObject, 0, 0}, {&_swigt__p_XdmfTopology, _p_XdmfTopologyTo_p_XdmfObject, 0, 0}, {&_swigt__p_XdmfDataDesc, _p_XdmfDataDescTo_p_XdmfObject, 0, 0}, {&_swigt__p_XdmfDsm, _p_XdmfDsmTo_p_XdmfObject, 0, 0}, {&_swigt__p_XdmfArray, _p_XdmfArrayTo_p_XdmfObject, 0, 0}, {&_swigt__p_XdmfDsmComm, _p_XdmfDsmCommTo_p_XdmfObject, 0, 0}, {&_swigt__p_XdmfGeometry, _p_XdmfGeometryTo_p_XdmfObject, 0, 0}, {&_swigt__p_XdmfElement, _p_XdmfElementTo_p_XdmfObject, 0, 0}, {&_swigt__p_XdmfRegion, _p_XdmfRegionTo_p_XdmfObject, 0, 0}, {&_swigt__p_XdmfDataStructure, _p_XdmfDataStructureTo_p_XdmfObject, 0, 0}, {&_swigt__p_XdmfHDF, _p_XdmfHDFTo_p_XdmfObject, 0, 0}, {&_swigt__p_XdmfDsmBuffer, _p_XdmfDsmBufferTo_p_XdmfObject, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_XdmfOpenCallback[] = { {&_swigt__p_XdmfOpenCallback, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_XdmfReadCallback[] = { {&_swigt__p_XdmfReadCallback, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_XdmfRegion[] = { {&_swigt__p_XdmfRegion, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_XdmfRoot[] = { {&_swigt__p_XdmfRoot, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_XdmfSet[] = { {&_swigt__p_XdmfSet, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_XdmfTime[] = { {&_swigt__p_XdmfTime, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_XdmfTopology[] = { {&_swigt__p_XdmfTopology, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_XdmfValues[] = { {&_swigt__p_XdmfValuesXML, _p_XdmfValuesXMLTo_p_XdmfValues, 0, 0}, {&_swigt__p_XdmfValues, 0, 0, 0}, {&_swigt__p_XdmfValuesHDF, _p_XdmfValuesHDFTo_p_XdmfValues, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_XdmfValuesHDF[] = { {&_swigt__p_XdmfValuesHDF, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_XdmfValuesXML[] = { {&_swigt__p_XdmfValuesXML, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_XdmfWriteCallback[] = { {&_swigt__p_XdmfWriteCallback, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p__xmlNode[] = { {&_swigt__p__xmlNode, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_double[] = { {&_swigt__p_double, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_float[] = { {&_swigt__p_float, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_hid_t[] = { {&_swigt__p_hid_t, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_int[] = { {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_istream[] = { {&_swigt__p_istream, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_long_long[] = { {&_swigt__p_long_long, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_ostream[] = { {&_swigt__p_ostream, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_p__xmlDoc[] = { {&_swigt__p_p__xmlDoc, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_short[] = { {&_swigt__p_short, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_unsigned_char[] = { {&_swigt__p_unsigned_char, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_unsigned_int[] = { {&_swigt__p_unsigned_int, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_unsigned_short[] = { {&_swigt__p_unsigned_short, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_void[] = { {&_swigt__p_void, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info *swig_cast_initial[] = { _swigc__p_XdmfArray, _swigc__p_XdmfArrayList, _swigc__p_XdmfAttribute, _swigc__p_XdmfCloseCallback, _swigc__p_XdmfDOM, _swigc__p_XdmfDataDesc, _swigc__p_XdmfDataItem, _swigc__p_XdmfDataStructure, _swigc__p_XdmfDomain, _swigc__p_XdmfDsm, _swigc__p_XdmfDsmBuffer, _swigc__p_XdmfDsmComm, _swigc__p_XdmfDsmMsg, _swigc__p_XdmfElement, _swigc__p_XdmfGeometry, _swigc__p_XdmfGrid, _swigc__p_XdmfHDF, _swigc__p_XdmfHeavyData, _swigc__p_XdmfInformation, _swigc__p_XdmfLightData, _swigc__p_XdmfMap, _swigc__p_XdmfObject, _swigc__p_XdmfOpenCallback, _swigc__p_XdmfReadCallback, _swigc__p_XdmfRegion, _swigc__p_XdmfRoot, _swigc__p_XdmfSet, _swigc__p_XdmfTime, _swigc__p_XdmfTopology, _swigc__p_XdmfValues, _swigc__p_XdmfValuesHDF, _swigc__p_XdmfValuesXML, _swigc__p_XdmfWriteCallback, _swigc__p__xmlNode, _swigc__p_char, _swigc__p_double, _swigc__p_float, _swigc__p_hid_t, _swigc__p_int, _swigc__p_istream, _swigc__p_long_long, _swigc__p_ostream, _swigc__p_p__xmlDoc, _swigc__p_short, _swigc__p_unsigned_char, _swigc__p_unsigned_int, _swigc__p_unsigned_short, _swigc__p_void, }; /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */ static swig_const_info swig_const_table[] = { {0, 0, 0, 0.0, 0, 0}}; #ifdef __cplusplus } #endif /* ----------------------------------------------------------------------------- * Type initialization: * This problem is tough by the requirement that no dynamic * memory is used. Also, since swig_type_info structures store pointers to * swig_cast_info structures and swig_cast_info structures store pointers back * to swig_type_info structures, we need some lookup code at initialization. * The idea is that swig generates all the structures that are needed. * The runtime then collects these partially filled structures. * The SWIG_InitializeModule function takes these initial arrays out of * swig_module, and does all the lookup, filling in the swig_module.types * array with the correct data and linking the correct swig_cast_info * structures together. * * The generated swig_type_info structures are assigned staticly to an initial * array. We just loop through that array, and handle each type individually. * First we lookup if this type has been already loaded, and if so, use the * loaded structure instead of the generated one. Then we have to fill in the * cast linked list. The cast data is initially stored in something like a * two-dimensional array. Each row corresponds to a type (there are the same * number of rows as there are in the swig_type_initial array). Each entry in * a column is one of the swig_cast_info structures for that type. * The cast_initial array is actually an array of arrays, because each row has * a variable number of columns. So to actually build the cast linked list, * we find the array of casts associated with the type, and loop through it * adding the casts to the list. The one last trick we need to do is making * sure the type pointer in the swig_cast_info struct is correct. * * First off, we lookup the cast->type name to see if it is already loaded. * There are three cases to handle: * 1) If the cast->type has already been loaded AND the type we are adding * casting info to has not been loaded (it is in this module), THEN we * replace the cast->type pointer with the type pointer that has already * been loaded. * 2) If BOTH types (the one we are adding casting info to, and the * cast->type) are loaded, THEN the cast info has already been loaded by * the previous module so we just ignore it. * 3) Finally, if cast->type has not already been loaded, then we add that * swig_cast_info to the linked list (because the cast->type) pointer will * be correct. * ----------------------------------------------------------------------------- */ #ifdef __cplusplus extern "C" { #if 0 } /* c-mode */ #endif #endif #if 0 #define SWIGRUNTIME_DEBUG #endif SWIGRUNTIME void SWIG_InitializeModule(void *clientdata) { size_t i; swig_module_info *module_head, *iter; int found, init; clientdata = clientdata; /* check to see if the circular list has been setup, if not, set it up */ if (swig_module.next==0) { /* Initialize the swig_module */ swig_module.type_initial = swig_type_initial; swig_module.cast_initial = swig_cast_initial; swig_module.next = &swig_module; init = 1; } else { init = 0; } /* Try and load any already created modules */ module_head = SWIG_GetModule(clientdata); if (!module_head) { /* This is the first module loaded for this interpreter */ /* so set the swig module into the interpreter */ SWIG_SetModule(clientdata, &swig_module); module_head = &swig_module; } else { /* the interpreter has loaded a SWIG module, but has it loaded this one? */ found=0; iter=module_head; do { if (iter==&swig_module) { found=1; break; } iter=iter->next; } while (iter!= module_head); /* if the is found in the list, then all is done and we may leave */ if (found) return; /* otherwise we must add out module into the list */ swig_module.next = module_head->next; module_head->next = &swig_module; } /* When multiple interpeters are used, a module could have already been initialized in a different interpreter, but not yet have a pointer in this interpreter. In this case, we do not want to continue adding types... everything should be set up already */ if (init == 0) return; /* Now work on filling in swig_module.types */ #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: size %d\n", swig_module.size); #endif for (i = 0; i < swig_module.size; ++i) { swig_type_info *type = 0; swig_type_info *ret; swig_cast_info *cast; #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); #endif /* if there is another module already loaded */ if (swig_module.next != &swig_module) { type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); } if (type) { /* Overwrite clientdata field */ #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: found type %s\n", type->name); #endif if (swig_module.type_initial[i]->clientdata) { type->clientdata = swig_module.type_initial[i]->clientdata; #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name); #endif } } else { type = swig_module.type_initial[i]; } /* Insert casting types */ cast = swig_module.cast_initial[i]; while (cast->type) { /* Don't need to add information already in the list */ ret = 0; #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: look cast %s\n", cast->type->name); #endif if (swig_module.next != &swig_module) { ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); #ifdef SWIGRUNTIME_DEBUG if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name); #endif } if (ret) { if (type == swig_module.type_initial[i]) { #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: skip old type %s\n", ret->name); #endif cast->type = ret; ret = 0; } else { /* Check for casting already in the list */ swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type); #ifdef SWIGRUNTIME_DEBUG if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name); #endif if (!ocast) ret = 0; } } if (!ret) { #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name); #endif if (type->cast) { type->cast->prev = cast; cast->next = type->cast; } type->cast = cast; } cast++; } /* Set entry in modules->types array equal to the type */ swig_module.types[i] = type; } swig_module.types[i] = 0; #ifdef SWIGRUNTIME_DEBUG printf("**** SWIG_InitializeModule: Cast List ******\n"); for (i = 0; i < swig_module.size; ++i) { int j = 0; swig_cast_info *cast = swig_module.cast_initial[i]; printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); while (cast->type) { printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); cast++; ++j; } printf("---- Total casts: %d\n",j); } printf("**** SWIG_InitializeModule: Cast List ******\n"); #endif } /* This function will propagate the clientdata field of type to * any new swig_type_info structures that have been added into the list * of equivalent types. It is like calling * SWIG_TypeClientData(type, clientdata) a second time. */ SWIGRUNTIME void SWIG_PropagateClientData(void) { size_t i; swig_cast_info *equiv; static int init_run = 0; if (init_run) return; init_run = 1; for (i = 0; i < swig_module.size; i++) { if (swig_module.types[i]->clientdata) { equiv = swig_module.types[i]->cast; while (equiv) { if (!equiv->converter) { if (equiv->type && !equiv->type->clientdata) SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata); } equiv = equiv->next; } } } } #ifdef __cplusplus #if 0 { /* c-mode */ #endif } #endif #ifdef __cplusplus extern "C" { #endif /* Python-specific SWIG API */ #define SWIG_newvarlink() SWIG_Python_newvarlink() #define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr) #define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants) /* ----------------------------------------------------------------------------- * global variable support code. * ----------------------------------------------------------------------------- */ typedef struct swig_globalvar { char *name; /* Name of global variable */ PyObject *(*get_attr)(void); /* Return the current value */ int (*set_attr)(PyObject *); /* Set the value */ struct swig_globalvar *next; } swig_globalvar; typedef struct swig_varlinkobject { PyObject_HEAD swig_globalvar *vars; } swig_varlinkobject; SWIGINTERN PyObject * swig_varlink_repr(swig_varlinkobject *SWIGUNUSEDPARM(v)) { #if PY_VERSION_HEX >= 0x03000000 return PyUnicode_InternFromString(""); #else return PyString_FromString(""); #endif } SWIGINTERN PyObject * swig_varlink_str(swig_varlinkobject *v) { #if PY_VERSION_HEX >= 0x03000000 PyObject *str = PyUnicode_InternFromString("("); PyObject *tail; PyObject *joined; swig_globalvar *var; for (var = v->vars; var; var=var->next) { tail = PyUnicode_FromString(var->name); joined = PyUnicode_Concat(str, tail); Py_DecRef(str); Py_DecRef(tail); str = joined; if (var->next) { tail = PyUnicode_InternFromString(", "); joined = PyUnicode_Concat(str, tail); Py_DecRef(str); Py_DecRef(tail); str = joined; } } tail = PyUnicode_InternFromString(")"); joined = PyUnicode_Concat(str, tail); Py_DecRef(str); Py_DecRef(tail); str = joined; #else PyObject *str = PyString_FromString("("); swig_globalvar *var; for (var = v->vars; var; var=var->next) { PyString_ConcatAndDel(&str,PyString_FromString(var->name)); if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(", ")); } PyString_ConcatAndDel(&str,PyString_FromString(")")); #endif return str; } SWIGINTERN int swig_varlink_print(swig_varlinkobject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) { char *tmp; PyObject *str = swig_varlink_str(v); fprintf(fp,"Swig global variables "); fprintf(fp,"%s\n", tmp = SWIG_Python_str_AsChar(str)); SWIG_Python_str_DelForPy3(tmp); Py_DECREF(str); return 0; } SWIGINTERN void swig_varlink_dealloc(swig_varlinkobject *v) { swig_globalvar *var = v->vars; while (var) { swig_globalvar *n = var->next; free(var->name); free(var); var = n; } } SWIGINTERN PyObject * swig_varlink_getattr(swig_varlinkobject *v, char *n) { PyObject *res = NULL; swig_globalvar *var = v->vars; while (var) { if (strcmp(var->name,n) == 0) { res = (*var->get_attr)(); break; } var = var->next; } if (res == NULL && !PyErr_Occurred()) { PyErr_SetString(PyExc_NameError,"Unknown C global variable"); } return res; } SWIGINTERN int swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) { int res = 1; swig_globalvar *var = v->vars; while (var) { if (strcmp(var->name,n) == 0) { res = (*var->set_attr)(p); break; } var = var->next; } if (res == 1 && !PyErr_Occurred()) { PyErr_SetString(PyExc_NameError,"Unknown C global variable"); } return res; } SWIGINTERN PyTypeObject* swig_varlink_type(void) { static char varlink__doc__[] = "Swig var link object"; static PyTypeObject varlink_type; static int type_init = 0; if (!type_init) { const PyTypeObject tmp = { /* PyObject header changed in Python 3 */ #if PY_VERSION_HEX >= 0x03000000 PyVarObject_HEAD_INIT(&PyType_Type, 0) #else PyObject_HEAD_INIT(NULL) 0, /* Number of items in variable part (ob_size) */ #endif (char *)"swigvarlink", /* Type name (tp_name) */ sizeof(swig_varlinkobject), /* Basic size (tp_basicsize) */ 0, /* Itemsize (tp_itemsize) */ (destructor) swig_varlink_dealloc, /* Deallocator (tp_dealloc) */ (printfunc) swig_varlink_print, /* Print (tp_print) */ (getattrfunc) swig_varlink_getattr, /* get attr (tp_getattr) */ (setattrfunc) swig_varlink_setattr, /* Set attr (tp_setattr) */ 0, /* tp_compare */ (reprfunc) swig_varlink_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ 0, /* tp_call */ (reprfunc)swig_varlink_str, /* tp_str */ 0, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ 0, /* tp_flags */ varlink__doc__, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ #if PY_VERSION_HEX >= 0x02020000 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */ #endif #if PY_VERSION_HEX >= 0x02030000 0, /* tp_del */ #endif #ifdef COUNT_ALLOCS 0,0,0,0 /* tp_alloc -> tp_next */ #endif }; varlink_type = tmp; /* for Python 3 we already assigned the ob_type in PyVarObject_HEAD_INIT() */ #if PY_VERSION_HEX < 0x03000000 varlink_type.ob_type = &PyType_Type; #endif type_init = 1; } return &varlink_type; } /* Create a variable linking object for use later */ SWIGINTERN PyObject * SWIG_Python_newvarlink(void) { swig_varlinkobject *result = PyObject_NEW(swig_varlinkobject, swig_varlink_type()); if (result) { result->vars = 0; } return ((PyObject*) result); } SWIGINTERN void SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) { swig_varlinkobject *v = (swig_varlinkobject *) p; swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar)); if (gv) { size_t size = strlen(name)+1; gv->name = (char *)malloc(size); if (gv->name) { strncpy(gv->name,name,size); gv->get_attr = get_attr; gv->set_attr = set_attr; gv->next = v->vars; } } v->vars = gv; } SWIGINTERN PyObject * SWIG_globals(void) { static PyObject *_SWIG_globals = 0; if (!_SWIG_globals) _SWIG_globals = SWIG_newvarlink(); return _SWIG_globals; } /* ----------------------------------------------------------------------------- * constants/methods manipulation * ----------------------------------------------------------------------------- */ /* Install Constants */ SWIGINTERN void SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) { PyObject *obj = 0; size_t i; for (i = 0; constants[i].type; ++i) { switch(constants[i].type) { case SWIG_PY_POINTER: obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0); break; case SWIG_PY_BINARY: obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype)); break; default: obj = 0; break; } if (obj) { PyDict_SetItemString(d, constants[i].name, obj); Py_DECREF(obj); } } } /* -----------------------------------------------------------------------------*/ /* Fix SwigMethods to carry the callback ptrs when needed */ /* -----------------------------------------------------------------------------*/ SWIGINTERN void SWIG_Python_FixMethods(PyMethodDef *methods, swig_const_info *const_table, swig_type_info **types, swig_type_info **types_initial) { size_t i; for (i = 0; methods[i].ml_name; ++i) { const char *c = methods[i].ml_doc; if (c && (c = strstr(c, "swig_ptr: "))) { int j; swig_const_info *ci = 0; const char *name = c + 10; for (j = 0; const_table[j].type; ++j) { if (strncmp(const_table[j].name, name, strlen(const_table[j].name)) == 0) { ci = &(const_table[j]); break; } } if (ci) { size_t shift = (ci->ptype) - types; swig_type_info *ty = types_initial[shift]; size_t ldoc = (c - methods[i].ml_doc); size_t lptr = strlen(ty->name)+2*sizeof(void*)+2; char *ndoc = (char*)malloc(ldoc + lptr + 10); if (ndoc) { char *buff = ndoc; void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0; if (ptr) { strncpy(buff, methods[i].ml_doc, ldoc); buff += ldoc; strncpy(buff, "swig_ptr: ", 10); buff += 10; SWIG_PackVoidPtr(buff, ptr, ty->name, lptr); methods[i].ml_doc = ndoc; } } } } } } #ifdef __cplusplus } #endif /* -----------------------------------------------------------------------------* * Partial Init method * -----------------------------------------------------------------------------*/ #ifdef __cplusplus extern "C" #endif SWIGEXPORT #if PY_VERSION_HEX >= 0x03000000 PyObject* #else void #endif SWIG_init(void) { PyObject *m, *d; #if PY_VERSION_HEX >= 0x03000000 static struct PyModuleDef SWIG_module = { PyModuleDef_HEAD_INIT, (char *) SWIG_name, NULL, -1, SwigMethods, NULL, NULL, NULL, NULL }; #endif /* Fix SwigMethods to carry the callback ptrs when needed */ SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial); #if PY_VERSION_HEX >= 0x03000000 m = PyModule_Create(&SWIG_module); #else m = Py_InitModule((char *) SWIG_name, SwigMethods); #endif d = PyModule_GetDict(m); SWIG_InitializeModule(0); SWIG_InstallConstants(d,swig_const_table); SWIG_Python_SetConstant(d, "_FILE_OFFSET_BITS",SWIG_From_int(static_cast< int >(64))); SWIG_Python_SetConstant(d, "SIZEOF_LONG_LONG",SWIG_From_int(static_cast< int >(8))); SWIG_Python_SetConstant(d, "XDMF_VERSION",SWIG_From_double(static_cast< double >(2.1))); SWIG_Python_SetConstant(d, "XDMF_VERSION_STRING",SWIG_FromCharPtr("2.1")); SWIG_Python_SetConstant(d, "XDMF_SUCCESS",SWIG_From_int(static_cast< int >(1))); SWIG_Python_SetConstant(d, "XDMF_FAIL",SWIG_From_int(static_cast< int >(-1))); SWIG_Python_SetConstant(d, "XDMF_TRUE",SWIG_From_int(static_cast< int >(1))); SWIG_Python_SetConstant(d, "XDMF_FALSE",SWIG_From_int(static_cast< int >(0))); SWIG_Python_SetConstant(d, "XDMF_MAX_DIMENSION",SWIG_From_int(static_cast< int >(10))); SWIG_Python_SetConstant(d, "XDMF_MAX_STRING_LENGTH",SWIG_From_int(static_cast< int >(1024))); SWIG_Python_SetConstant(d, "XDMF_DEFAULT_INDEX",SWIG_From_int(static_cast< int >(-1))); SWIG_Python_SetConstant(d, "XDMF_SELECT_SLAB",SWIG_From_int(static_cast< int >(1))); SWIG_Python_SetConstant(d, "XDMF_SELECT_INDEX",SWIG_From_int(static_cast< int >(2))); SWIG_Python_SetConstant(d, "XDMF_UNKNOWN_TYPE",SWIG_From_int(static_cast< int >(-1))); SWIG_Python_SetConstant(d, "XDMF_INT8_TYPE",SWIG_From_int(static_cast< int >(1))); SWIG_Python_SetConstant(d, "XDMF_INT16_TYPE",SWIG_From_int(static_cast< int >(6))); SWIG_Python_SetConstant(d, "XDMF_INT32_TYPE",SWIG_From_int(static_cast< int >(2))); SWIG_Python_SetConstant(d, "XDMF_INT64_TYPE",SWIG_From_int(static_cast< int >(3))); SWIG_Python_SetConstant(d, "XDMF_FLOAT32_TYPE",SWIG_From_int(static_cast< int >(4))); SWIG_Python_SetConstant(d, "XDMF_FLOAT64_TYPE",SWIG_From_int(static_cast< int >(5))); SWIG_Python_SetConstant(d, "XDMF_UINT8_TYPE",SWIG_From_int(static_cast< int >(7))); SWIG_Python_SetConstant(d, "XDMF_UINT16_TYPE",SWIG_From_int(static_cast< int >(8))); SWIG_Python_SetConstant(d, "XDMF_UINT32_TYPE",SWIG_From_int(static_cast< int >(9))); SWIG_Python_SetConstant(d, "XDMF_COMPOUND_TYPE",SWIG_From_int(static_cast< int >(0x10))); SWIG_Python_SetConstant(d, "XDMF_ELEMENT_STATE_UNINITIALIZED",SWIG_From_int(static_cast< int >(0))); SWIG_Python_SetConstant(d, "XDMF_ELEMENT_STATE_LIGHT_PARSED",SWIG_From_int(static_cast< int >(1))); SWIG_Python_SetConstant(d, "XDMF_ELEMENT_STATE_HEAVY_READ",SWIG_From_int(static_cast< int >(2))); SWIG_Python_SetConstant(d, "XDMF_ATTRIBUTE_TYPE_NONE",SWIG_From_int(static_cast< int >(0))); SWIG_Python_SetConstant(d, "XDMF_ATTRIBUTE_TYPE_SCALAR",SWIG_From_int(static_cast< int >(1))); SWIG_Python_SetConstant(d, "XDMF_ATTRIBUTE_TYPE_VECTOR",SWIG_From_int(static_cast< int >(2))); SWIG_Python_SetConstant(d, "XDMF_ATTRIBUTE_TYPE_TENSOR",SWIG_From_int(static_cast< int >(3))); SWIG_Python_SetConstant(d, "XDMF_ATTRIBUTE_TYPE_MATRIX",SWIG_From_int(static_cast< int >(4))); SWIG_Python_SetConstant(d, "XDMF_ATTRIBUTE_TYPE_TENSOR6",SWIG_From_int(static_cast< int >(5))); SWIG_Python_SetConstant(d, "XDMF_ATTRIBUTE_TYPE_GLOBALID",SWIG_From_int(static_cast< int >(6))); SWIG_Python_SetConstant(d, "XDMF_ATTRIBUTE_CENTER_GRID",SWIG_From_int(static_cast< int >(0))); SWIG_Python_SetConstant(d, "XDMF_ATTRIBUTE_CENTER_CELL",SWIG_From_int(static_cast< int >(1))); SWIG_Python_SetConstant(d, "XDMF_ATTRIBUTE_CENTER_FACE",SWIG_From_int(static_cast< int >(2))); SWIG_Python_SetConstant(d, "XDMF_ATTRIBUTE_CENTER_EDGE",SWIG_From_int(static_cast< int >(3))); SWIG_Python_SetConstant(d, "XDMF_ATTRIBUTE_CENTER_NODE",SWIG_From_int(static_cast< int >(4))); SWIG_Python_SetConstant(d, "XDMF_SELECTALL",SWIG_From_int(static_cast< int >(0))); SWIG_Python_SetConstant(d, "XDMF_HYPERSLAB",SWIG_From_int(static_cast< int >(1))); SWIG_Python_SetConstant(d, "XDMF_COORDINATES",SWIG_From_int(static_cast< int >(2))); SWIG_Python_SetConstant(d, "XDMF_ARRAY_TAG_LENGTH",SWIG_From_int(static_cast< int >(80))); SWIG_Python_SetConstant(d, "XDMF_FORMAT_XML",SWIG_From_int(static_cast< int >(0))); SWIG_Python_SetConstant(d, "XDMF_FORMAT_HDF",SWIG_From_int(static_cast< int >(1))); SWIG_Python_SetConstant(d, "XDMF_FORMAT_MYSQL",SWIG_From_int(static_cast< int >(2))); SWIG_Python_SetConstant(d, "XDMF_FORMAT_BINARY",SWIG_From_int(static_cast< int >(3))); SWIG_Python_SetConstant(d, "XDMF_ITEM_UNIFORM",SWIG_From_int(static_cast< int >(0x00))); SWIG_Python_SetConstant(d, "XDMF_ITEM_HYPERSLAB",SWIG_From_int(static_cast< int >(0x01))); SWIG_Python_SetConstant(d, "XDMF_ITEM_COORDINATES",SWIG_From_int(static_cast< int >(0x02))); SWIG_Python_SetConstant(d, "XDMF_ITEM_FUNCTION",SWIG_From_int(static_cast< int >(0x03))); SWIG_Python_SetConstant(d, "XDMF_ITEM_COLLECTION",SWIG_From_int(static_cast< int >(0x14))); SWIG_Python_SetConstant(d, "XDMF_ITEM_TREE",SWIG_From_int(static_cast< int >(0x15))); SWIG_Python_SetConstant(d, "XDMF_ITEM_MASK",SWIG_From_int(static_cast< int >(0xF0))); SWIG_Python_SetConstant(d, "XDMF_H5_OTHER",SWIG_From_int(static_cast< int >(0xFF))); SWIG_Python_SetConstant(d, "XDMF_MAX_ORDER",SWIG_From_int(static_cast< int >(10))); SWIG_Python_SetConstant(d, "XDMF_STRUCTURED",SWIG_From_int(static_cast< int >(0))); SWIG_Python_SetConstant(d, "XDMF_UNSTRUCTURED",SWIG_From_int(static_cast< int >(1))); SWIG_Python_SetConstant(d, "XDMF_NOTOPOLOGY",SWIG_From_int(static_cast< int >(0x0))); SWIG_Python_SetConstant(d, "XDMF_POLYVERTEX",SWIG_From_int(static_cast< int >(0x1))); SWIG_Python_SetConstant(d, "XDMF_POLYLINE",SWIG_From_int(static_cast< int >(0x2))); SWIG_Python_SetConstant(d, "XDMF_POLYGON",SWIG_From_int(static_cast< int >(0x3))); SWIG_Python_SetConstant(d, "XDMF_TRI",SWIG_From_int(static_cast< int >(0x4))); SWIG_Python_SetConstant(d, "XDMF_QUAD",SWIG_From_int(static_cast< int >(0x5))); SWIG_Python_SetConstant(d, "XDMF_TET",SWIG_From_int(static_cast< int >(0x6))); SWIG_Python_SetConstant(d, "XDMF_PYRAMID",SWIG_From_int(static_cast< int >(0x7))); SWIG_Python_SetConstant(d, "XDMF_WEDGE",SWIG_From_int(static_cast< int >(0x8))); SWIG_Python_SetConstant(d, "XDMF_HEX",SWIG_From_int(static_cast< int >(0x9))); SWIG_Python_SetConstant(d, "XDMF_EDGE_3",SWIG_From_int(static_cast< int >(0x0022))); SWIG_Python_SetConstant(d, "XDMF_TRI_6",SWIG_From_int(static_cast< int >(0x0024))); SWIG_Python_SetConstant(d, "XDMF_QUAD_8",SWIG_From_int(static_cast< int >(0x0025))); SWIG_Python_SetConstant(d, "XDMF_TET_10",SWIG_From_int(static_cast< int >(0x0026))); SWIG_Python_SetConstant(d, "XDMF_PYRAMID_13",SWIG_From_int(static_cast< int >(0x0027))); SWIG_Python_SetConstant(d, "XDMF_WEDGE_15",SWIG_From_int(static_cast< int >(0x0028))); SWIG_Python_SetConstant(d, "XDMF_HEX_20",SWIG_From_int(static_cast< int >(0x0029))); SWIG_Python_SetConstant(d, "XDMF_MIXED",SWIG_From_int(static_cast< int >(0x0070))); SWIG_Python_SetConstant(d, "XDMF_2DSMESH",SWIG_From_int(static_cast< int >(0x0100))); SWIG_Python_SetConstant(d, "XDMF_2DRECTMESH",SWIG_From_int(static_cast< int >(0x0101))); SWIG_Python_SetConstant(d, "XDMF_2DCORECTMESH",SWIG_From_int(static_cast< int >(0x0102))); SWIG_Python_SetConstant(d, "XDMF_3DSMESH",SWIG_From_int(static_cast< int >(0x1100))); SWIG_Python_SetConstant(d, "XDMF_3DRECTMESH",SWIG_From_int(static_cast< int >(0x1101))); SWIG_Python_SetConstant(d, "XDMF_3DCORECTMESH",SWIG_From_int(static_cast< int >(0x1102))); SWIG_Python_SetConstant(d, "XDMF_GEOMETRY_NONE",SWIG_From_int(static_cast< int >(0))); SWIG_Python_SetConstant(d, "XDMF_GEOMETRY_XYZ",SWIG_From_int(static_cast< int >(1))); SWIG_Python_SetConstant(d, "XDMF_GEOMETRY_XY",SWIG_From_int(static_cast< int >(2))); SWIG_Python_SetConstant(d, "XDMF_GEOMETRY_X_Y_Z",SWIG_From_int(static_cast< int >(3))); SWIG_Python_SetConstant(d, "XDMF_GEOMETRY_X_Y",SWIG_From_int(static_cast< int >(4))); SWIG_Python_SetConstant(d, "XDMF_GEOMETRY_VXVYVZ",SWIG_From_int(static_cast< int >(5))); SWIG_Python_SetConstant(d, "XDMF_GEOMETRY_ORIGIN_DXDYDZ",SWIG_From_int(static_cast< int >(6))); SWIG_Python_SetConstant(d, "XDMF_GEOMETRY_VXVY",SWIG_From_int(static_cast< int >(7))); SWIG_Python_SetConstant(d, "XDMF_GEOMETRY_ORIGIN_DXDY",SWIG_From_int(static_cast< int >(8))); SWIG_Python_SetConstant(d, "XDMF_GRID_UNIFORM",SWIG_From_int(static_cast< int >(0x00000))); SWIG_Python_SetConstant(d, "XDMF_GRID_COLLECTION",SWIG_From_int(static_cast< int >(0x10000))); SWIG_Python_SetConstant(d, "XDMF_GRID_TREE",SWIG_From_int(static_cast< int >(0x20000))); SWIG_Python_SetConstant(d, "XDMF_GRID_SUBSET",SWIG_From_int(static_cast< int >(0x40000))); SWIG_Python_SetConstant(d, "XDMF_GRID_UNSET",SWIG_From_int(static_cast< int >(0x0FFFF))); SWIG_Python_SetConstant(d, "XDMF_GRID_MASK",SWIG_From_int(static_cast< int >(0xF0000))); SWIG_Python_SetConstant(d, "XDMF_GRID_SECTION_ALL",SWIG_From_int(static_cast< int >(0x100000))); SWIG_Python_SetConstant(d, "XDMF_GRID_SECTION_DATA_ITEM",SWIG_From_int(static_cast< int >(0x200000))); SWIG_Python_SetConstant(d, "XDMF_GRID_SECTION_MASK",SWIG_From_int(static_cast< int >(0xF00000))); SWIG_Python_SetConstant(d, "XDMF_GRID_COLLECTION_TEMPORAL",SWIG_From_int(static_cast< int >(0x0001))); SWIG_Python_SetConstant(d, "XDMF_GRID_COLLECTION_SPATIAL",SWIG_From_int(static_cast< int >(0x0002))); SWIG_Python_SetConstant(d, "XDMF_GRID_COLLECTION_UNSET",SWIG_From_int(static_cast< int >(0x0FFFF))); SWIG_Python_SetConstant(d, "XDMF_TIME_SINGLE",SWIG_From_int(static_cast< int >(0x00))); SWIG_Python_SetConstant(d, "XDMF_TIME_LIST",SWIG_From_int(static_cast< int >(0x01))); SWIG_Python_SetConstant(d, "XDMF_TIME_HYPERSLAB",SWIG_From_int(static_cast< int >(0x02))); SWIG_Python_SetConstant(d, "XDMF_TIME_RANGE",SWIG_From_int(static_cast< int >(0x03))); SWIG_Python_SetConstant(d, "XDMF_TIME_FUNCTION",SWIG_From_int(static_cast< int >(0x04))); SWIG_Python_SetConstant(d, "XDMF_TIME_UNSET",SWIG_From_int(static_cast< int >(0x0FF))); SWIG_Python_SetConstant(d, "XDMF_REGION_TYPE_UNSET",SWIG_From_int(static_cast< int >(-1))); SWIG_Python_SetConstant(d, "XDMF_REGION_TYPE_CELL",SWIG_From_int(static_cast< int >(1))); SWIG_Python_SetConstant(d, "XDMF_REGION_TYPE_FACE",SWIG_From_int(static_cast< int >(2))); SWIG_Python_SetConstant(d, "XDMF_REGION_TYPE_EDGE",SWIG_From_int(static_cast< int >(3))); SWIG_Python_SetConstant(d, "XDMF_REGION_TYPE_NODE",SWIG_From_int(static_cast< int >(4))); SWIG_Python_SetConstant(d, "XDMF_SET_MAX_ORDER",SWIG_From_int(static_cast< int >(50))); SWIG_Python_SetConstant(d, "XDMF_SET_TYPE_UNSET",SWIG_From_int(static_cast< int >(-1))); SWIG_Python_SetConstant(d, "XDMF_SET_TYPE_NODE",SWIG_From_int(static_cast< int >(1))); SWIG_Python_SetConstant(d, "XDMF_SET_TYPE_CELL",SWIG_From_int(static_cast< int >(2))); SWIG_Python_SetConstant(d, "XDMF_SET_TYPE_FACE",SWIG_From_int(static_cast< int >(3))); SWIG_Python_SetConstant(d, "XDMF_SET_TYPE_EDGE",SWIG_From_int(static_cast< int >(4))); SWIG_Python_SetConstant(d, "XDMF_MAP_MAX_ORDER",SWIG_From_int(static_cast< int >(50))); SWIG_Python_SetConstant(d, "XDMF_MAP_TYPE_UNSET",SWIG_From_int(static_cast< int >(-1))); SWIG_Python_SetConstant(d, "XDMF_MAP_TYPE_NODE",SWIG_From_int(static_cast< int >(1))); SWIG_Python_SetConstant(d, "XDMF_MAP_TYPE_CELL",SWIG_From_int(static_cast< int >(2))); SWIG_Python_SetConstant(d, "XDMF_MAP_TYPE_FACE",SWIG_From_int(static_cast< int >(3))); SWIG_Python_SetConstant(d, "XDMF_MAP_TYPE_EDGE",SWIG_From_int(static_cast< int >(4))); SWIG_Python_SetConstant(d, "XDMF_DSM_OPCODE_DONE",SWIG_From_int(static_cast< int >(0xFF))); SWIG_Python_SetConstant(d, "XDMF_DSM_TYPE_UNIFORM",SWIG_From_int(static_cast< int >(0))); SWIG_Python_SetConstant(d, "XDMF_DSM_TYPE_UNIFORM_RANGE",SWIG_From_int(static_cast< int >(1))); SWIG_Python_SetConstant(d, "XDMF_DSM_TYPE_MIXED",SWIG_From_int(static_cast< int >(2))); SWIG_Python_SetConstant(d, "XDMF_DSM_DEFAULT_LENGTH",SWIG_From_int(static_cast< int >(10000))); SWIG_Python_SetConstant(d, "XDMF_DSM_DEFAULT_TAG",SWIG_From_int(static_cast< int >(0x80))); SWIG_Python_SetConstant(d, "XDMF_DSM_COMMAND_TAG",SWIG_From_int(static_cast< int >(0x81))); SWIG_Python_SetConstant(d, "XDMF_DSM_RESPONSE_TAG",SWIG_From_int(static_cast< int >(0x82))); SWIG_Python_SetConstant(d, "XDMF_DSM_ANY_SOURCE",SWIG_From_int(static_cast< int >(-1))); SWIG_Python_SetConstant(d, "XDMF_DSM_MAX_LOCKS",SWIG_From_int(static_cast< int >(32))); #if PY_VERSION_HEX >= 0x03000000 return m; #else return; #endif } xdmf-3.0+git20160803/libsrc/XdmfDsmMsg.cxx0000640000175000017500000000331713003006557020111 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : $Id: XdmfDsmMsg.cxx,v 1.3 2009-01-23 20:31:39 clarke Exp $ */ /* Date : $Date: 2009-01-23 20:31:39 $ */ /* Version : $Revision: 1.3 $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2007 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #include "XdmfDsmMsg.h" XdmfDsmMsg::XdmfDsmMsg() { this->Tag = XDMF_DSM_DEFAULT_TAG; } XdmfDsmMsg::~XdmfDsmMsg() { } xdmf-3.0+git20160803/libsrc/XdmfExport.h0000740000175000017500000000055513003006557017627 0ustar alastairalastair#ifndef __xdmf_export_h #define __xdmf_export_h #include "XdmfConfig.h" #if defined(_WIN32) && !defined(WIN32) # define WIN32 #endif #if defined(WIN32) && !defined(XDMFSTATIC) # if defined(Xdmf_EXPORTS) # define XDMF_EXPORT __declspec( dllexport ) # else # define XDMF_EXPORT __declspec( dllimport ) # endif #else # define XDMF_EXPORT #endif #endif xdmf-3.0+git20160803/libsrc/XdmfH5Driver.h0000640000175000017500000000414013003006557017767 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : $Id: XdmfH5Driver.h,v 1.2 2009-01-23 20:31:39 clarke Exp $ */ /* Date : $Date: 2009-01-23 20:31:39 $ */ /* Version : $Revision: 1.2 $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2007 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #ifndef H5FDdsm_H #define H5FDdsm_H #include "XdmfDsmBuffer.h" #include "H5Ipublic.h" #include "H5pubconf.h" #include "XdmfExport.h" #define H5FD_DSM (H5FD_dsm_init()) /* Allocate memory in multiples of this size by default */ #define H5FD_DSM_INCREMENT 1000000 extern "C" { XDMF_EXPORT hid_t H5FD_dsm_init(void); } XDMF_EXPORT herr_t H5Pset_fapl_dsm(hid_t fapl_id, size_t increment, XdmfDsmBuffer *buffer); XDMF_EXPORT herr_t H5Pget_fapl_dsm(hid_t fapl_id, size_t *increment/*out*/, XdmfDsmBuffer **buffer); #endif xdmf-3.0+git20160803/libsrc/XdmfObject.cxx0000640000175000017500000001132113003006557020117 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : $Id: XdmfObject.cxx,v 1.4 2008-06-26 19:00:46 fbertel Exp $ */ /* Date : $Date: 2008-06-26 19:00:46 $ */ /* Version : $Revision: 1.4 $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2002 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #include "XdmfObject.h" #include static XdmfInt32 GlobalDebugFlag = 0; static XdmfInt64 NameCntr = 0; istrstream& XDMF_READ_STREAM64(istrstream& istr, XDMF_64_INT& i) { #if defined( XDMF_HAVE_64BIT_STREAMS ) istr >>i; #else // a double here seems to not work // for hex characters so use an int. // since XDMF_HAVE_64BIT_STREAMS is unset // we don't have a long long. // double d = 0; unsigned int d = 0; istr >> d; i = (XDMF_64_INT)d; #endif return istr; } // This is a comment XdmfObject::XdmfObject() { this->Debug = 0; } XdmfObject::~XdmfObject() { } XdmfInt32 XdmfObject::GetGlobalDebug(){ return GlobalDebugFlag; } void XdmfObject::SetGlobalDebug( XdmfInt32 Value ){ GlobalDebugFlag = Value; } XdmfConstString XdmfObject::GetUniqueName(XdmfConstString NameBase){ return(GetUnique(NameBase)); } XdmfInt32 GetGlobalDebug(){ return GlobalDebugFlag; } void SetGlobalDebug( XdmfInt32 Value ){ GlobalDebugFlag = Value; } void SetGlobalDebugOn(){ GlobalDebugFlag = 1; } void SetGlobalDebugOff(){ GlobalDebugFlag = 0; } XdmfString GetUnique( XdmfConstString Pattern ) { static char ReturnName[80]; ostrstream String(ReturnName,80); if( Pattern == NULL ) Pattern = "Xdmf_"; String << Pattern << XDMF_64BIT_CAST(NameCntr++) << ends; return( ReturnName ); } XdmfString XdmfObjectToHandle( XdmfObject *Source ){ ostrstream Handle; XDMF_64_INT RealObjectPointer; XdmfObject **Rpt = &Source; RealObjectPointer = reinterpret_cast(*Rpt); Handle << "_"; Handle.setf(ios::hex,ios::basefield); Handle << XDMF_64BIT_CAST(RealObjectPointer) << "_" << Source->GetClassName() << ends; // cout << "XdmfObjectToHandle : Source = " << Source << endl; // cout << "Handle = " << (XdmfString)Handle.str() << endl; return( (XdmfString)Handle.str() ); } XdmfObject * HandleToXdmfObject( XdmfConstString Source ){ XdmfString src = new char[ strlen(Source) + 1 ]; strcpy(src, Source); istrstream Handle( src, strlen(src)); char c; XDMF_64_INT RealObjectPointer; XdmfObject *RealObject = NULL, **Rpt = &RealObject; Handle >> c; if( c != '_' ) { XdmfErrorMessage("Bad Handle " << Source ); delete [] src; return( NULL ); } Handle.setf(ios::hex,ios::basefield); XDMF_READ_STREAM64(Handle, RealObjectPointer); // cout << "Source = " << Source << endl; // cout << "RealObjectPointer = " << RealObjectPointer << endl; *Rpt = reinterpret_cast(RealObjectPointer); delete [] src; return( RealObject ); } XdmfPointer VoidPointerHandleToXdmfPointer( XdmfConstString Source ){ XdmfString src = new char[ strlen(Source) + 1 ]; strcpy(src, Source); istrstream Handle( src, strlen(src)); char c; XDMF_64_INT RealObjectPointer; XdmfPointer RealObject = NULL, *Rpt = &RealObject; Handle >> c; if( c != '_' ) { XdmfErrorMessage("Bad Handle " << Source ); delete [] src; return( NULL ); } Handle.setf(ios::hex,ios::basefield); XDMF_READ_STREAM64(Handle, RealObjectPointer); // Handle >> RealObjectPointer; // cout << "Source = " << Source << endl; // cout << "RealObjectPointer = " << RealObjectPointer << endl; *Rpt = reinterpret_cast(RealObjectPointer); delete [] src; return( RealObject ); } xdmf-3.0+git20160803/libsrc/bz2stream.h0000640000175000017500000003541113003006557017436 0ustar alastairalastair/* Created (x) 2003, by Sandor Fazekas. For public domain. */ /* Last modified: $Date: 2009-08-31 14:46:54 $ $Revision: 1.1 $ */ #ifndef BZ2STREAM_H #define BZ2STREAM_H /* C++ stream classes for the bzip2 compression library. This is a */ /* lightweight C++ class library built on top of the excelent bzip2 */ /* compression library. Please note that the files handled by this */ /* library are opened in binary mode, which means that what you write */ /* is what you get, and there are no character substitutions (see e.g. */ /* Win32's two-character new-line). */ /* This code was inspired by Aaron Isotton's implementation of */ /* C++ Stream Classes for the bzip2 compression library. */ /* Modifications: 2009, Dominik Szczerba */ /* added multiple instances of std:: prefixes */ /* INCLUDE */ #include #include #include #include #include #include /* INCLUDE */ #include /* DEFINE */ /* These define some default values. */ #define BZ2S_BLOCK_SIZE_100_K 9 /* 1..9 */ #define BZ2S_WORK_FACTOR 0 /* 0..255 */ #define BZ2S_SMALL 0 /* TRUE or FALSE */ #define BZ2S_IN_BUF_LEN 1024 /* > 0 */ #define BZ2S_OUT_BUF_LEN 1024 /* > 0 */ #define BZ2S_OUT_BACK_LEN 256 /* >= 0 */ /* USE NAMESPACE */ //using namespace std; /* CLASS DECLARATION */ class obz2buf : public std::streambuf { private: int bzBlockSize100K; int bzWorkFactor; private: int bzInBufLen; int bzOutBufLen; private: FILE* file; private: bz_stream bzStrm; private: char* bzInBuf; char* bzOutBuf; public: inline obz2buf( int blockSize100K = BZ2S_BLOCK_SIZE_100_K, int workFactor = BZ2S_WORK_FACTOR, int inBufLen = BZ2S_IN_BUF_LEN, int outBufLen = BZ2S_OUT_BUF_LEN ) : bzBlockSize100K ( blockSize100K ), bzWorkFactor ( workFactor ), bzInBufLen ( inBufLen ), bzOutBufLen ( outBufLen ) { reset(); /* initialize class */ } public: virtual ~obz2buf() { close(); /* ignore error */ } public: inline bool is_open() const { return file != NULL; } public: obz2buf* open( const char* fileName ) { if( ! isParmOk() || is_open() ) return NULL; if( ! fileOpen( fileName ) ) return NULL; /* open file */ if( ! bzInit() ) return NULL; /* initialize the BZ stream */ return this; } obz2buf* open( const std::string& fileName ) { if( ! isParmOk() || is_open() ) return NULL; if( ! fileOpen( fileName.c_str() ) ) return NULL; /* open file */ if( ! bzInit() ) return NULL; /* initialize the BZ stream */ return this; } obz2buf* open( int fileDesc ) { if( ! isParmOk() || is_open() ) return NULL; if( ! fileOpen( fileDesc ) ) return NULL; /* open file */ if( ! bzInit() ) return NULL; /* initialize the BZ stream */ return this; } public: obz2buf* close() { if( ! is_open() ) return NULL; bool done = bzProcess() && bzFinish(); bzEnd(); /* close BZ stream */ bool closed = fileClose(); /* close file */ reset(); /* reinitialize class */ return ( done && closed ) ? this : NULL; } protected: virtual int overflow( int c ) { if( c != EOF ) { /* we allocated place for one more element! */ *pptr() = c; pbump( 1 ); /* add one more element */ } /* process buffered elements */ return bzProcess() ? ( c != EOF ? c : !EOF ) : EOF; } protected: virtual int sync() { /* process buffered elements and flush the BZ stream */ return ( bzProcess() && bzFlush() ) ? 0 : -1; } private: inline bool bzInit() { bzInBuf = ( char* ) malloc( bzInBufLen ); if( bzInBuf == NULL ) return false; bzOutBuf = ( char* ) malloc( bzOutBufLen ); if( bzOutBuf == NULL ) return false; memset( bzInBuf, 0, bzInBufLen ); memset( bzOutBuf, 0, bzOutBufLen ); { int retVal = BZ2_bzCompressInit( &bzStrm, bzBlockSize100K, 0, bzWorkFactor ); if( retVal != BZ_OK ) return false; } /* position streambuf's put positions */ setp( bzInBuf, bzInBuf + bzInBufLen - 1 ); return true; } private: inline void bzEnd() { BZ2_bzCompressEnd( &bzStrm ); if( bzInBuf != NULL ) free( bzInBuf ); if( bzOutBuf != NULL ) free( bzOutBuf ); } private: inline bool bzProcess() { int inLen = pptr() - pbase(); bzStrm.next_in = pbase(); bzStrm.avail_in = inLen; while( bzStrm.avail_in > 0 ) { bzStrm.next_out = bzOutBuf; bzStrm.avail_out = bzOutBufLen; BZ2_bzCompress( &bzStrm, BZ_RUN ); if( ! fileWrite() ) return false; } pbump( - inLen ); return true; } private: inline bool bzFlush() { bool flushed = false; bzStrm.next_in = NULL; bzStrm.avail_in = 0; while( ! flushed ) { bzStrm.next_out = bzOutBuf; bzStrm.avail_out = bzOutBufLen; { int retVal = BZ2_bzCompress( &bzStrm, BZ_FLUSH ); flushed = ( retVal == BZ_RUN_OK ); } if( ! fileWrite() || ! fileFlush() ) return false; } return true; } private: inline bool bzFinish() { bool finished = false; bzStrm.next_in = NULL; bzStrm.avail_in = 0; while( ! finished ) { bzStrm.next_out = bzOutBuf; bzStrm.avail_out = bzOutBufLen; { int retVal = BZ2_bzCompress( &bzStrm, BZ_FINISH ); finished = ( retVal == BZ_STREAM_END ); } if( ! fileWrite() ) return false; } return true; } private: inline bool fileOpen( const char* fileName ) { file = fopen( fileName, "wb" ); return file != NULL; } inline bool fileOpen( int fileDesc ) { file = fdopen( fileDesc, "wb" ); return file != NULL; } private: inline bool fileClose() { return fclose( file ) == 0; } private: inline bool fileWrite() { int outLen = bzOutBufLen - bzStrm.avail_out; int retVal = fwrite( bzOutBuf, 1, outLen, file ); return retVal == outLen; } private: inline bool fileFlush() { return fflush( file ) == 0; } private: inline bool isParmOk() const { if( bzBlockSize100K < 1 || bzBlockSize100K > 9 ) return false; if( bzWorkFactor < 0 || bzWorkFactor > 250 ) return false; if( bzInBufLen <= 0 ) return false; if( bzOutBufLen <= 0 ) return false; return true; } private: inline void reset() { file = NULL; memset( &bzStrm, 0, sizeof( bz_stream ) ); bzInBuf = bzOutBuf = NULL; setp( NULL, NULL ); } }; /* CLASS DECLARATION */ class ibz2buf : public std::streambuf { private: int bzSmall; private: int bzInBufLen; int bzOutBufLen; private: int bzOutBackLen; private: FILE* file; bool isBadType; private: bz_stream bzStrm; private: char* bzInBuf; char* bzOutBuf; private: char* bzInBegin; char* bzInEnd; private: char* bzOutBasePos; int bzOutBaseLen; public: inline ibz2buf( int small = BZ2S_SMALL, int inBufLen = BZ2S_IN_BUF_LEN, int outBufLen = BZ2S_OUT_BUF_LEN + BZ2S_OUT_BACK_LEN, int outBufBackLen = BZ2S_OUT_BACK_LEN ) : bzSmall ( small ), bzInBufLen ( inBufLen ), bzOutBufLen ( outBufLen ), bzOutBackLen ( outBufBackLen ) { reset(); /* initialize class */ } public: virtual ~ibz2buf() { close(); /* ignore error */ } public: inline bool is_open() const { return file != NULL; } inline bool is_bad_type() const { return isBadType; } public: ibz2buf* open( const char* fileName ) { if( ! isParmOk() || is_open() ) return NULL; if( ! fileOpen( fileName ) ) return NULL; /* open file */ if( ! bzInit() ) return NULL; /* initialize the BZ stream */ return this; } ibz2buf* open( const std::string& fileName ) { if( ! isParmOk() || is_open() ) return NULL; if( ! fileOpen( fileName.c_str() ) ) return NULL; /* open file */ if( ! bzInit() ) return NULL; /* initialize the BZ stream */ return this; } ibz2buf* open( int fileDesc ) { if( ! isParmOk() || is_open() ) return NULL; if( ! fileOpen( fileDesc ) ) return NULL; /* open file */ if( ! bzInit() ) return NULL; /* initialize the BZ stream */ return this; } public: ibz2buf* close() { if( ! is_open() ) return NULL; bzEnd(); /* close BZ stream */ bool closed = fileClose(); /* close file */ reset(); /* reinitialize class */ return closed ? this : NULL; } protected: virtual int underflow() { bool empty = true; int outLen = gptr() - eback(); /* calc size of putback area */ int backLen = ( outLen < bzOutBackLen ) ? outLen : bzOutBackLen; if( backLen > 0 ) /* prepare putback area */ memcpy( bzOutBasePos - backLen, gptr() - backLen, backLen ); while( empty ) { if( ( bzInBegin == bzInEnd ) && ! fileRead() ) return EOF; bzStrm.next_in = bzInBegin; bzStrm.avail_in = bzInEnd - bzInBegin; bzStrm.next_out = bzOutBasePos; bzStrm.avail_out = bzOutBaseLen; { int retVal = BZ2_bzDecompress( &bzStrm ); empty = ( bzStrm.avail_out == ( unsigned ) bzOutBaseLen ); isBadType = ( retVal == BZ_DATA_ERROR_MAGIC ) || ( retVal == BZ_DATA_ERROR ); if( retVal == BZ_STREAM_END ) { if( empty ) return EOF; } else if( retVal != BZ_OK ) { return EOF; } } bzInBegin = bzInEnd - bzStrm.avail_in; } setg( bzOutBasePos - backLen, bzOutBasePos, bzOutBasePos + bzOutBaseLen - bzStrm.avail_out ); return *( ( unsigned char* ) gptr() ); } private: inline bool bzInit() { bzInBuf = ( char* ) malloc( bzInBufLen ); if( bzInBuf == NULL ) return false; bzOutBuf = ( char* ) malloc( bzOutBufLen ); if( bzOutBuf == NULL ) return false; memset( bzInBuf, 0, bzInBufLen ); memset( bzOutBuf, 0, bzOutBufLen ); { int retVal = BZ2_bzDecompressInit( &bzStrm, 0, bzSmall ); if( retVal != BZ_OK ) return false; } bzInBegin = bzInEnd = bzInBuf; bzOutBasePos = bzOutBuf + bzOutBackLen; bzOutBaseLen = bzOutBufLen - bzOutBackLen; setg( bzOutBasePos, bzOutBasePos, bzOutBasePos ); return true; } private: inline void bzEnd() { BZ2_bzDecompressEnd( &bzStrm ); if( bzInBuf != NULL ) free( bzInBuf ); if( bzOutBuf != NULL ) free( bzOutBuf ); } private: inline bool fileOpen( const char* fileName ) { file = fopen( fileName, "rb" ); return file != NULL; } inline bool fileOpen( int fileDesc ) { file = fdopen( fileDesc, "rb" ); return file != NULL; } private: inline bool fileClose() { return fclose( file ) == 0; } private: inline bool fileRead() { int inLen = fread( bzInBuf, 1, bzInBufLen, file ); bzInBegin = bzInBuf; bzInEnd = bzInBegin + inLen; return inLen > 0; } private: inline bool isParmOk() const { if( bzInBufLen <= 0 ) return false; if( bzOutBufLen <= 0 ) return false; if( bzOutBackLen < 0 ) return false; if( bzOutBackLen >= bzOutBufLen ) return false; return true; } private: inline void reset() { file = NULL; isBadType = false; memset( &bzStrm, 0, sizeof( bz_stream ) ); bzInBuf = bzOutBuf = NULL; bzInBegin = bzInEnd = NULL; bzOutBasePos = NULL; bzOutBaseLen = 0; setg( NULL, NULL, NULL ); } }; /* CLASS DECLARATION */ class obz2stream : public std::ostream { private: obz2buf buf; public: inline explicit obz2stream( int blockSize100K = BZ2S_BLOCK_SIZE_100_K, int workFactor = BZ2S_WORK_FACTOR, int inBufLen = BZ2S_IN_BUF_LEN, int outBufLen = BZ2S_OUT_BUF_LEN ) : std::ostream( &buf ), buf( blockSize100K, workFactor, inBufLen, outBufLen ) {} inline explicit obz2stream( const char* fileName, int blockSize100K = BZ2S_BLOCK_SIZE_100_K, int workFactor = BZ2S_WORK_FACTOR, int inBufLen = BZ2S_IN_BUF_LEN, int outBufLen = BZ2S_OUT_BUF_LEN ) : std::ostream( &buf ), buf( blockSize100K, workFactor, inBufLen, outBufLen ) { open( fileName ); } inline explicit obz2stream( const std::string& fileName, int blockSize100K = BZ2S_BLOCK_SIZE_100_K, int workFactor = BZ2S_WORK_FACTOR, int inBufLen = BZ2S_IN_BUF_LEN, int outBufLen = BZ2S_OUT_BUF_LEN ) : std::ostream( &buf ), buf( blockSize100K, workFactor, inBufLen, outBufLen ) { open( fileName ); } public: virtual ~obz2stream() {} public: inline obz2buf* rdbuf() const { return ( obz2buf* ) &buf; } public: inline bool is_open() const { return buf.is_open(); } public: inline void open( const char* fileName ) { if( buf.open( fileName ) == NULL ) setstate( failbit ); } inline void open( const std::string& fileName ) { if( buf.open( fileName ) == NULL ) setstate( failbit ); } inline void open( int fileDesc ) { if( buf.open( fileDesc ) == NULL ) setstate( failbit ); } public: inline void close() { if( buf.close() == NULL ) setstate( failbit ); } }; /* CLASS DECLARATION */ class ibz2stream : public std::istream { private: ibz2buf buf; public: inline explicit ibz2stream( int small = BZ2S_SMALL, int inBufLen = BZ2S_IN_BUF_LEN, int outBufLen = BZ2S_OUT_BUF_LEN + BZ2S_OUT_BACK_LEN, int outBufBackLen = BZ2S_OUT_BACK_LEN ) : std::istream( &buf ), buf( small, inBufLen, outBufLen, outBufBackLen ) {} inline explicit ibz2stream( const char* fileName, int small = BZ2S_SMALL, int inBufLen = BZ2S_IN_BUF_LEN, int outBufLen = BZ2S_OUT_BUF_LEN + BZ2S_OUT_BACK_LEN, int outBufBackLen = BZ2S_OUT_BACK_LEN ) : std::istream( &buf ), buf( small, inBufLen, outBufLen, outBufBackLen ) { open( fileName ); } inline explicit ibz2stream( const std::string& fileName, int small = BZ2S_SMALL, int inBufLen = BZ2S_IN_BUF_LEN, int outBufLen = BZ2S_OUT_BUF_LEN + BZ2S_OUT_BACK_LEN, int outBufBackLen = BZ2S_OUT_BACK_LEN ) : std::istream( &buf ), buf( small, inBufLen, outBufLen, outBufBackLen ) { open( fileName ); } public: virtual ~ibz2stream() {} public: inline ibz2buf* rdbuf() const { return ( ibz2buf* ) &buf; } public: inline bool is_open() const { return buf.is_open(); } inline bool is_bad_type() const { return buf.is_bad_type(); } public: inline void open( const char* fileName ) { if( buf.open( fileName ) == NULL ) setstate( failbit ); } inline void open( const std::string& fileName ) { if( buf.open( fileName ) == NULL ) setstate( failbit ); } inline void open( int fileDesc ) { if( buf.open( fileDesc ) == NULL ) setstate( failbit ); } public: inline void close() { if( buf.close() == NULL ) setstate( failbit ); } }; #endif /* BZ2STREAM_H */ /* End of File */ xdmf-3.0+git20160803/XdmfTopologyType.cpp0000640000175000017500000011642113003006557020100 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfTopologyType.cpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #include #include #include #include #include #include "string.h" #include "XdmfError.hpp" #include "XdmfTopologyType.hpp" std::map(*)()> XdmfTopologyType::mTopologyDefinitions; // Supported XdmfTopologyTypes shared_ptr XdmfTopologyType::NoTopologyType() { std::vector > faces; static shared_ptr p(new XdmfTopologyType(0, 0, faces, 0, "NoTopology", NoCellType, 0x0)); return p; } shared_ptr XdmfTopologyType::Polyvertex() { std::vector > faces; faces.push_back(XdmfTopologyType::NoTopologyType()); static shared_ptr p(new XdmfTopologyType(1, 0, faces, 0, "Polyvertex", Linear, 0x1)); return p; } shared_ptr XdmfTopologyType::Polyline(const unsigned int nodesPerElement) { std::vector > faces; faces.push_back(XdmfTopologyType::NoTopologyType()); static std::map > previousTypes; std::map >::const_iterator type = previousTypes.find(nodesPerElement); if(type != previousTypes.end()) { return type->second; } shared_ptr p(new XdmfTopologyType(nodesPerElement, 0, faces, nodesPerElement - 1, "Polyline", Linear, 0x2)); previousTypes[nodesPerElement] = p; return p; } shared_ptr XdmfTopologyType::Polygon(const unsigned int nodesPerElement) { std::vector > faces; faces.push_back(XdmfTopologyType::NoTopologyType()); static std::map > previousTypes; std::map >::const_iterator type = previousTypes.find(nodesPerElement); if(type != previousTypes.end()) { return type->second; } shared_ptr p(new XdmfTopologyType(nodesPerElement, 1, faces, nodesPerElement, "Polygon", Linear, 0x3)); previousTypes[nodesPerElement] = p; return p; } shared_ptr XdmfTopologyType::Triangle() { std::vector > faces; faces.push_back(XdmfTopologyType::NoTopologyType()); static shared_ptr p(new XdmfTopologyType(3, 1, faces, 3, "Triangle", Linear, 0x4)); return p; } shared_ptr XdmfTopologyType::Quadrilateral() { std::vector > faces; faces.push_back(XdmfTopologyType::NoTopologyType()); static shared_ptr p(new XdmfTopologyType(4, 1, faces, 4, "Quadrilateral", Linear, 0x5)); return p; } shared_ptr XdmfTopologyType::Tetrahedron() { std::vector > faces; faces.push_back(XdmfTopologyType::Triangle()); static shared_ptr p(new XdmfTopologyType(4, 4, faces, 6, "Tetrahedron", Linear, 0x6)); return p; } shared_ptr XdmfTopologyType::Pyramid() { std::vector > faces; faces.push_back(XdmfTopologyType::NoTopologyType()); static shared_ptr p(new XdmfTopologyType(5, 5, faces, 8, "Pyramid", Linear, 0x7)); return p; } shared_ptr XdmfTopologyType::Wedge() { std::vector > faces; faces.push_back(XdmfTopologyType::NoTopologyType()); static shared_ptr p(new XdmfTopologyType(6, 5, faces, 9, "Wedge", Linear, 0x8)); return p; } shared_ptr XdmfTopologyType::Hexahedron() { std::vector > faces; faces.push_back(XdmfTopologyType::Quadrilateral()); static shared_ptr p(new XdmfTopologyType(8, 6, faces, 12, "Hexahedron", Linear, 0x9)); return p; } shared_ptr XdmfTopologyType::Polyhedron() { std::vector > faces; static shared_ptr p(new XdmfTopologyType(0, 0, faces, 0, "Polyhedron", Linear, 0x10)); return p; } shared_ptr XdmfTopologyType::Edge_3() { std::vector > faces; faces.push_back(XdmfTopologyType::NoTopologyType()); static shared_ptr p(new XdmfTopologyType(3, 0, faces, 1, "Edge_3", Quadratic, 0x22)); return p; } shared_ptr XdmfTopologyType::Triangle_6() { std::vector > faces; faces.push_back(XdmfTopologyType::NoTopologyType()); static shared_ptr p(new XdmfTopologyType(6, 1, faces, 3, "Triangle_6", Quadratic, 0x24)); return p; } shared_ptr XdmfTopologyType::Quadrilateral_8() { std::vector > faces; faces.push_back(XdmfTopologyType::NoTopologyType()); static shared_ptr p(new XdmfTopologyType(8, 1, faces, 4, "Quadrilateral_8", Quadratic, 0x25)); return p; } shared_ptr XdmfTopologyType::Quadrilateral_9() { std::vector > faces; faces.push_back(XdmfTopologyType::NoTopologyType()); static shared_ptr p(new XdmfTopologyType(9, 1, faces, 4, "Quadrilateral_9", Quadratic, 0x23)); return p; } shared_ptr XdmfTopologyType::Tetrahedron_10() { std::vector > faces; faces.push_back(XdmfTopologyType::NoTopologyType()); faces.push_back(XdmfTopologyType::Triangle_6()); static shared_ptr p(new XdmfTopologyType(10, 4, faces, 6, "Tetrahedron_10", Quadratic, 0x26)); return p; } shared_ptr XdmfTopologyType::Pyramid_13() { std::vector > faces; faces.push_back(XdmfTopologyType::NoTopologyType()); static shared_ptr p(new XdmfTopologyType(13, 5, faces, 8, "Pyramid_13", Quadratic, 0x27)); return p; } shared_ptr XdmfTopologyType::Wedge_15() { std::vector > faces; faces.push_back(XdmfTopologyType::NoTopologyType()); static shared_ptr p(new XdmfTopologyType(15, 5, faces, 9, "Wedge_15", Quadratic, 0x28)); return p; } shared_ptr XdmfTopologyType::Wedge_18() { std::vector > faces; faces.push_back(XdmfTopologyType::NoTopologyType()); static shared_ptr p(new XdmfTopologyType(18, 5, faces, 9, "Wedge_18", Quadratic, 0x29)); return p; } shared_ptr XdmfTopologyType::Hexahedron_20() { std::vector > faces; faces.push_back(XdmfTopologyType::Quadrilateral_8()); static shared_ptr p(new XdmfTopologyType(20, 6, faces, 12, "Hexahedron_20", Quadratic, 0x30)); return p; } shared_ptr XdmfTopologyType::Hexahedron_24() { std::vector > faces; faces.push_back(XdmfTopologyType::NoTopologyType()); static shared_ptr p(new XdmfTopologyType(24, 6, faces, 12, "Hexahedron_24", Quadratic, 0x31)); return p; } shared_ptr XdmfTopologyType::Hexahedron_27() { std::vector > faces; faces.push_back(XdmfTopologyType::Quadrilateral_9()); static shared_ptr p(new XdmfTopologyType(27, 6, faces, 12, "Hexahedron_27", Quadratic, 0x32)); return p; } shared_ptr XdmfTopologyType::Hexahedron_64() { std::vector > faces; faces.push_back(XdmfTopologyType::NoTopologyType()); static shared_ptr p(new XdmfTopologyType(64, 6, faces, 12, "Hexahedron_64", Cubic, 0x33)); return p; } shared_ptr XdmfTopologyType::Hexahedron_125() { std::vector > faces; faces.push_back(XdmfTopologyType::NoTopologyType()); static shared_ptr p(new XdmfTopologyType(125, 6, faces, 12, "Hexahedron_125", Quartic, 0x34)); return p; } shared_ptr XdmfTopologyType::Hexahedron_216() { std::vector > faces; faces.push_back(XdmfTopologyType::NoTopologyType()); static shared_ptr p(new XdmfTopologyType(216, 6, faces, 12, "Hexahedron_216", Quintic, 0x35)); return p; } shared_ptr XdmfTopologyType::Hexahedron_343() { std::vector > faces; faces.push_back(XdmfTopologyType::NoTopologyType()); static shared_ptr p(new XdmfTopologyType(343, 6, faces, 12, "Hexahedron_343", Sextic, 0x36)); return p; } shared_ptr XdmfTopologyType::Hexahedron_512() { std::vector > faces; faces.push_back(XdmfTopologyType::NoTopologyType()); static shared_ptr p(new XdmfTopologyType(512, 6, faces, 12, "Hexahedron_512", Septic, 0x37)); return p; } shared_ptr XdmfTopologyType::Hexahedron_729() { std::vector > faces; faces.push_back(XdmfTopologyType::NoTopologyType()); static shared_ptr p(new XdmfTopologyType(729, 6, faces, 12, "Hexahedron_729", Octic, 0x38)); return p; } shared_ptr XdmfTopologyType::Hexahedron_1000() { std::vector > faces; faces.push_back(XdmfTopologyType::NoTopologyType()); static shared_ptr p(new XdmfTopologyType(1000, 6, faces, 12, "Hexahedron_1000", Nonic, 0x39)); return p; } shared_ptr XdmfTopologyType::Hexahedron_1331() { std::vector > faces; faces.push_back(XdmfTopologyType::NoTopologyType()); static shared_ptr p(new XdmfTopologyType(1331, 6, faces, 12, "Hexahedron_1331", Decic, 0x40)); return p; } shared_ptr XdmfTopologyType::Hexahedron_Spectral_64() { std::vector > faces; faces.push_back(XdmfTopologyType::NoTopologyType()); static shared_ptr p(new XdmfTopologyType(64, 6, faces, 12, "Hexahedron_Spectral_64", Cubic, 0x41)); return p; } shared_ptr XdmfTopologyType::Hexahedron_Spectral_125() { std::vector > faces; faces.push_back(XdmfTopologyType::NoTopologyType()); static shared_ptr p(new XdmfTopologyType(125, 6, faces, 12, "Hexahedron_Spectral_125", Quartic, 0x42)); return p; } shared_ptr XdmfTopologyType::Hexahedron_Spectral_216() { std::vector > faces; faces.push_back(XdmfTopologyType::NoTopologyType()); static shared_ptr p(new XdmfTopologyType(216, 6, faces, 12, "Hexahedron_Spectral_216", Quintic, 0x43)); return p; } shared_ptr XdmfTopologyType::Hexahedron_Spectral_343() { std::vector > faces; faces.push_back(XdmfTopologyType::NoTopologyType()); static shared_ptr p(new XdmfTopologyType(343, 6, faces, 12, "Hexahedron_Spectral_343", Sextic, 0x44)); return p; } shared_ptr XdmfTopologyType::Hexahedron_Spectral_512() { std::vector > faces; faces.push_back(XdmfTopologyType::NoTopologyType()); static shared_ptr p(new XdmfTopologyType(512, 6, faces, 12, "Hexahedron_Spectral_512", Septic, 0x45)); return p; } shared_ptr XdmfTopologyType::Hexahedron_Spectral_729() { std::vector > faces; faces.push_back(XdmfTopologyType::NoTopologyType()); static shared_ptr p(new XdmfTopologyType(729, 6, faces, 12, "Hexahedron_Spectral_729", Octic, 0x46)); return p; } shared_ptr XdmfTopologyType::Hexahedron_Spectral_1000() { std::vector > faces; faces.push_back(XdmfTopologyType::NoTopologyType()); static shared_ptr p(new XdmfTopologyType(1000, 6, faces, 12, "Hexahedron_Spectral_1000", Nonic, 0x47)); return p; } shared_ptr XdmfTopologyType::Hexahedron_Spectral_1331() { std::vector > faces; faces.push_back(XdmfTopologyType::NoTopologyType()); static shared_ptr p(new XdmfTopologyType(1331, 6, faces, 12, "Hexahedron_Spectral_1331", Decic, 0x48)); return p; } shared_ptr XdmfTopologyType::Mixed() { std::vector > faces; static shared_ptr p(new XdmfTopologyType(0, 0, faces, 0, "Mixed", Arbitrary, 0x70)); return p; } void XdmfTopologyType::InitTypes() { mTopologyDefinitions["NOTOPOLOGY"] = NoTopologyType; mTopologyDefinitions["POLYVERTEX"] = Polyvertex; mTopologyDefinitions["TRIANGLE"] = Triangle; mTopologyDefinitions["QUADRILATERAL"] = Quadrilateral; mTopologyDefinitions["TETRAHEDRON"] = Tetrahedron; mTopologyDefinitions["PYRAMID"] = Pyramid; mTopologyDefinitions["WEDGE"] = Wedge; mTopologyDefinitions["HEXAHEDRON"] = Hexahedron; mTopologyDefinitions["POLYHEDRON"] = Polyhedron; mTopologyDefinitions["EDGE_3"] = Edge_3; mTopologyDefinitions["TRIANGLE_6"] = Triangle_6; mTopologyDefinitions["QUADRILATERAL_8"] = Quadrilateral_8; mTopologyDefinitions["QUADRILATERAL_9"] = Quadrilateral_9; mTopologyDefinitions["TETRAHEDRON_10"] = Tetrahedron_10; mTopologyDefinitions["PYRAMID_13"] = Pyramid_13; mTopologyDefinitions["WEDGE_15"] = Wedge_15; mTopologyDefinitions["WEDGE_18"] = Wedge_18; mTopologyDefinitions["HEXAHEDRON_20"] = Hexahedron_20; mTopologyDefinitions["HEXAHEDRON_24"] = Hexahedron_24; mTopologyDefinitions["HEXAHEDRON_27"] = Hexahedron_27; mTopologyDefinitions["HEXAHEDRON_64"] = Hexahedron_64; mTopologyDefinitions["HEXAHEDRON_125"] = Hexahedron_125; mTopologyDefinitions["HEXAHEDRON_216"] = Hexahedron_216; mTopologyDefinitions["HEXAHEDRON_343"] = Hexahedron_343; mTopologyDefinitions["HEXAHEDRON_512"] = Hexahedron_512; mTopologyDefinitions["HEXAHEDRON_729"] = Hexahedron_729; mTopologyDefinitions["HEXAHEDRON_1000"] = Hexahedron_1000; mTopologyDefinitions["HEXAHEDRON_1331"] = Hexahedron_1331; mTopologyDefinitions["HEXAHEDRON_SPECTRAL_64"] = Hexahedron_Spectral_64; mTopologyDefinitions["HEXAHEDRON_SPECTRAL_125"] = Hexahedron_Spectral_125; mTopologyDefinitions["HEXAHEDRON_SPECTRAL_216"] = Hexahedron_Spectral_216; mTopologyDefinitions["HEXAHEDRON_SPECTRAL_343"] = Hexahedron_Spectral_343; mTopologyDefinitions["HEXAHEDRON_SPECTRAL_512"] = Hexahedron_Spectral_512; mTopologyDefinitions["HEXAHEDRON_SPECTRAL_729"] = Hexahedron_Spectral_729; mTopologyDefinitions["HEXAHEDRON_SPECTRAL_1000"] = Hexahedron_Spectral_1000; mTopologyDefinitions["HEXAHEDRON_SPECTRAL_1331"] = Hexahedron_Spectral_1331; mTopologyDefinitions["MIXED"] = Mixed; } unsigned int XdmfTopologyType::calculateHypercubeNumElements(unsigned int numDims, unsigned int elementNumDims) const { if (elementNumDims > numDims) { return 0; } else if (elementNumDims == numDims) { return 1; } else { // The calculation has 3 parts // First is the 2 taken to the power of // the object's dimensionality minus the element's dimensionality. unsigned int part1 = std::pow((double)2, (double)(numDims - elementNumDims)); // The second part is numDims!/(numDims-elementdims)! unsigned int part2 = 1; for (unsigned int i = numDims; i > (numDims - elementNumDims); --i) { part2 *= i; } // The third part is elementDims! unsigned int part3 = 1; for (unsigned int i = 1; i <= elementNumDims; ++i) { part3 *= i; } return part1 * (part2 / part3); } } shared_ptr XdmfTopologyType::New(const unsigned int id) { if(id == XdmfTopologyType::NoTopologyType()->getID()) { return XdmfTopologyType::NoTopologyType(); } else if(id == XdmfTopologyType::Polyvertex()->getID()) { return XdmfTopologyType::Polyvertex(); } else if(id == XdmfTopologyType::Polyline(0)->getID()) { return XdmfTopologyType::Polyline(0); } else if(id == XdmfTopologyType::Polygon(0)->getID()) { return XdmfTopologyType::Polygon(0); } else if(id == XdmfTopologyType::Triangle()->getID()) { return XdmfTopologyType::Triangle(); } else if(id == XdmfTopologyType::Quadrilateral()->getID()) { return XdmfTopologyType::Quadrilateral(); } else if(id == XdmfTopologyType::Tetrahedron()->getID()) { return XdmfTopologyType::Tetrahedron(); } else if(id == XdmfTopologyType::Pyramid()->getID()) { return XdmfTopologyType::Pyramid(); } else if(id == XdmfTopologyType::Wedge()->getID()) { return XdmfTopologyType::Wedge(); } else if(id == XdmfTopologyType::Hexahedron()->getID()) { return XdmfTopologyType::Hexahedron(); } else if(id == XdmfTopologyType::Polyhedron()->getID()) { return XdmfTopologyType::Polyhedron(); } else if(id == XdmfTopologyType::Edge_3()->getID()) { return XdmfTopologyType::Edge_3(); } else if(id == XdmfTopologyType::Triangle_6()->getID()) { return XdmfTopologyType::Triangle_6(); } else if(id == XdmfTopologyType::Quadrilateral_8()->getID()) { return XdmfTopologyType::Quadrilateral_8(); } else if(id == XdmfTopologyType::Quadrilateral_9()->getID()) { return XdmfTopologyType::Quadrilateral_9(); } else if(id == XdmfTopologyType::Tetrahedron_10()->getID()) { return XdmfTopologyType::Tetrahedron_10(); } else if(id == XdmfTopologyType::Pyramid_13()->getID()) { return XdmfTopologyType::Pyramid_13(); } else if(id == XdmfTopologyType::Wedge_15()->getID()) { return XdmfTopologyType::Wedge_15(); } else if(id == XdmfTopologyType::Wedge_18()->getID()) { return XdmfTopologyType::Wedge_18(); } else if(id == XdmfTopologyType::Hexahedron_20()->getID()) { return XdmfTopologyType::Hexahedron_20(); } else if(id == XdmfTopologyType::Hexahedron_24()->getID()) { return XdmfTopologyType::Hexahedron_24(); } else if(id == XdmfTopologyType::Hexahedron_27()->getID()) { return XdmfTopologyType::Hexahedron_27(); } else if(id == XdmfTopologyType::Hexahedron_64()->getID()) { return XdmfTopologyType::Hexahedron_64(); } else if(id == XdmfTopologyType::Hexahedron_125()->getID()) { return XdmfTopologyType::Hexahedron_125(); } else if(id == XdmfTopologyType::Hexahedron_216()->getID()) { return XdmfTopologyType::Hexahedron_216(); } else if(id == XdmfTopologyType::Hexahedron_343()->getID()) { return XdmfTopologyType::Hexahedron_343(); } else if(id == XdmfTopologyType::Hexahedron_512()->getID()) { return XdmfTopologyType::Hexahedron_512(); } else if(id == XdmfTopologyType::Hexahedron_729()->getID()) { return XdmfTopologyType::Hexahedron_729(); } else if(id == XdmfTopologyType::Hexahedron_1000()->getID()) { return XdmfTopologyType::Hexahedron_1000(); } else if(id == XdmfTopologyType::Hexahedron_1331()->getID()) { return XdmfTopologyType::Hexahedron_1331(); } else if(id == XdmfTopologyType::Hexahedron_Spectral_64()->getID()) { return XdmfTopologyType::Hexahedron_Spectral_64(); } else if(id == XdmfTopologyType::Hexahedron_Spectral_125()->getID()) { return XdmfTopologyType::Hexahedron_Spectral_125(); } else if(id == XdmfTopologyType::Hexahedron_Spectral_216()->getID()) { return XdmfTopologyType::Hexahedron_Spectral_216(); } else if(id == XdmfTopologyType::Hexahedron_Spectral_343()->getID()) { return XdmfTopologyType::Hexahedron_Spectral_343(); } else if(id == XdmfTopologyType::Hexahedron_Spectral_512()->getID()) { return XdmfTopologyType::Hexahedron_Spectral_512(); } else if(id == XdmfTopologyType::Hexahedron_Spectral_729()->getID()) { return XdmfTopologyType::Hexahedron_Spectral_729(); } else if(id == XdmfTopologyType::Hexahedron_Spectral_1000()->getID()) { return XdmfTopologyType::Hexahedron_Spectral_1000(); } else if(id == XdmfTopologyType::Hexahedron_Spectral_1331()->getID()) { return XdmfTopologyType::Hexahedron_Spectral_1331(); } else if(id == XdmfTopologyType::Mixed()->getID()) { return XdmfTopologyType::Mixed(); } return shared_ptr(); } XdmfTopologyType::XdmfTopologyType(const unsigned int nodesPerElement, const unsigned int facesPerElement, const std::vector > & faces, const unsigned int edgesPerElement, const std::string & name, const CellType cellType, const unsigned int id) : mCellType(cellType), mEdgesPerElement(edgesPerElement), mFacesPerElement(facesPerElement), mFaces(faces), mID(id), mName(name), mNodesPerElement(nodesPerElement) { } XdmfTopologyType::~XdmfTopologyType() { } shared_ptr XdmfTopologyType::New(const std::map & itemProperties) { InitTypes(); std::map::const_iterator type = itemProperties.find("Type"); if(type == itemProperties.end()) { type = itemProperties.find("TopologyType"); } if(type == itemProperties.end()) { XdmfError::message(XdmfError::FATAL, "Neither 'Type' nor 'TopologyType' found in " "itemProperties in XdmfTopologyType::New"); } std::string typeVal = ConvertToUpper(type->second); std::map::const_iterator nodesPerElement = itemProperties.find("NodesPerElement"); std::map(*)()>::const_iterator returnType = mTopologyDefinitions.find(typeVal); if (returnType == mTopologyDefinitions.end()) { if(typeVal.compare("POLYLINE") == 0) { if(nodesPerElement != itemProperties.end()) { return Polyline(atoi(nodesPerElement->second.c_str())); } XdmfError::message(XdmfError::FATAL, "'NodesPerElement' not in itemProperties and type " "'POLYLINE' selected in XdmfTopologyType::New"); } else if(typeVal.compare("POLYGON") == 0) { if(nodesPerElement != itemProperties.end()) { return Polygon(atoi(nodesPerElement->second.c_str())); } XdmfError::message(XdmfError::FATAL, "'NodesPerElement' not in itemProperties and type " "'POLYGON' selected in XdmfTopologyType::New"); } else { XdmfError::message(XdmfError::FATAL, "Invalid Type selected in XdmfTopologyType::New"); } } else { return (*(returnType->second))(); } XdmfError::message(XdmfError::FATAL, "Invalid Type selected in XdmfTopologyType::New"); // unreachable return shared_ptr(); } XdmfTopologyType::CellType XdmfTopologyType::getCellType() const { return mCellType; } unsigned int XdmfTopologyType::getEdgesPerElement() const { return mEdgesPerElement; } shared_ptr XdmfTopologyType::getFaceType() const { if (mFaces.size() == 0) { return XdmfTopologyType::NoTopologyType(); } else { return mFaces[0]; } } unsigned int XdmfTopologyType::getFacesPerElement() const { return mFacesPerElement; } unsigned int XdmfTopologyType::getID() const { return mID; } std::string XdmfTopologyType::getName() const { return mName; } unsigned int XdmfTopologyType::getNodesPerElement() const { return mNodesPerElement; } void XdmfTopologyType::getProperties(std::map & collectedProperties) const { collectedProperties.insert(std::make_pair("Type", this->getName())); if(mName.compare("Polygon") == 0 || mName.compare("Polyline") == 0) { std::stringstream nodesPerElement; nodesPerElement << mNodesPerElement; collectedProperties.insert(std::make_pair("NodesPerElement", nodesPerElement.str())); } } // C Wrappers int XdmfTopologyTypePolyvertex() { return XDMF_TOPOLOGY_TYPE_POLYVERTEX; } int XdmfTopologyTypePolyline() { return XDMF_TOPOLOGY_TYPE_POLYLINE; } int XdmfTopologyTypePolygon() { return XDMF_TOPOLOGY_TYPE_POLYGON; } int XdmfTopologyTypeTriangle() { return XDMF_TOPOLOGY_TYPE_TRIANGLE; } int XdmfTopologyTypeQuadrilateral() { return XDMF_TOPOLOGY_TYPE_QUADRILATERAL; } int XdmfTopologyTypeTetrahedron() { return XDMF_TOPOLOGY_TYPE_TETRAHEDRON; } int XdmfTopologyTypePyramid() { return XDMF_TOPOLOGY_TYPE_PYRAMID; } int XdmfTopologyTypeWedge() { return XDMF_TOPOLOGY_TYPE_WEDGE; } int XdmfTopologyTypeHexahedron() { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON; } int XdmfTopologyTypePolyhedron() { return XDMF_TOPOLOGY_TYPE_POLYHEDRON; } int XdmfTopologyTypeEdge_3() { return XDMF_TOPOLOGY_TYPE_EDGE_3; } int XdmfTopologyTypeTriangle_6() { return XDMF_TOPOLOGY_TYPE_TRIANGLE_6; } int XdmfTopologyTypeQuadrilateral_8() { return XDMF_TOPOLOGY_TYPE_QUADRILATERAL_8; } int XdmfTopologyTypeQuadrilateral_9() { return XDMF_TOPOLOGY_TYPE_QUADRILATERAL_9; } int XdmfTopologyTypeTetrahedron_10() { return XDMF_TOPOLOGY_TYPE_TETRAHEDRON_10; } int XdmfTopologyTypePyramid_13() { return XDMF_TOPOLOGY_TYPE_PYRAMID_13; } int XdmfTopologyTypeWedge_15() { return XDMF_TOPOLOGY_TYPE_WEDGE_15; } int XdmfTopologyTypeWedge_18() { return XDMF_TOPOLOGY_TYPE_WEDGE_18; } int XdmfTopologyTypeHexahedron_20() { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_20; } int XdmfTopologyTypeHexahedron_24() { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_24; } int XdmfTopologyTypeHexahedron_27() { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_27; } int XdmfTopologyTypeHexahedron_64() { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_64; } int XdmfTopologyTypeHexahedron_125() { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_125; } int XdmfTopologyTypeHexahedron_216() { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_216; } int XdmfTopologyTypeHexahedron_343() { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_343; } int XdmfTopologyTypeHexahedron_512() { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_512; } int XdmfTopologyTypeHexahedron_729() { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_729; } int XdmfTopologyTypeHexahedron_1000() { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_1000; } int XdmfTopologyTypeHexahedron_1331() { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_1331; } int XdmfTopologyTypeHexahedron_Spectral_64() { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_64; } int XdmfTopologyTypeHexahedron_Spectral_125() { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_125; } int XdmfTopologyTypeHexahedron_Spectral_216() { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_216; } int XdmfTopologyTypeHexahedron_Spectral_343() { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_343; } int XdmfTopologyTypeHexahedron_Spectral_512() { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_512; } int XdmfTopologyTypeHexahedron_Spectral_729() { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_729; } int XdmfTopologyTypeHexahedron_Spectral_1000() { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_1000; } int XdmfTopologyTypeHexahedron_Spectral_1331() { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_1331; } int XdmfTopologyTypeMixed() { return XDMF_TOPOLOGY_TYPE_MIXED; } shared_ptr intToType(int type, int nodes = 0) { switch (type) { case XDMF_TOPOLOGY_TYPE_POLYVERTEX: return XdmfTopologyType::Polyvertex(); break; case XDMF_TOPOLOGY_TYPE_POLYLINE: return XdmfTopologyType::Polyline(nodes); break; case XDMF_TOPOLOGY_TYPE_POLYGON: return XdmfTopologyType::Polygon(nodes); break; case XDMF_TOPOLOGY_TYPE_TRIANGLE: return XdmfTopologyType::Triangle(); break; case XDMF_TOPOLOGY_TYPE_QUADRILATERAL: return XdmfTopologyType::Quadrilateral(); break; case XDMF_TOPOLOGY_TYPE_TETRAHEDRON: return XdmfTopologyType::Tetrahedron(); break; case XDMF_TOPOLOGY_TYPE_PYRAMID: return XdmfTopologyType::Pyramid(); break; case XDMF_TOPOLOGY_TYPE_WEDGE: return XdmfTopologyType::Wedge(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON: return XdmfTopologyType::Hexahedron(); break; case XDMF_TOPOLOGY_TYPE_POLYHEDRON: return XdmfTopologyType::Polyhedron(); break; case XDMF_TOPOLOGY_TYPE_EDGE_3: return XdmfTopologyType::Edge_3(); break; case XDMF_TOPOLOGY_TYPE_TRIANGLE_6: return XdmfTopologyType::Triangle_6(); break; case XDMF_TOPOLOGY_TYPE_QUADRILATERAL_8: return XdmfTopologyType::Quadrilateral_8(); break; case XDMF_TOPOLOGY_TYPE_QUADRILATERAL_9: return XdmfTopologyType::Quadrilateral_9(); break; case XDMF_TOPOLOGY_TYPE_TETRAHEDRON_10: return XdmfTopologyType::Tetrahedron_10(); break; case XDMF_TOPOLOGY_TYPE_PYRAMID_13: return XdmfTopologyType::Pyramid_13(); break; case XDMF_TOPOLOGY_TYPE_WEDGE_15: return XdmfTopologyType::Wedge_15(); break; case XDMF_TOPOLOGY_TYPE_WEDGE_18: return XdmfTopologyType::Wedge_18(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_20: return XdmfTopologyType::Hexahedron_20(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_24: return XdmfTopologyType::Hexahedron_24(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_27: return XdmfTopologyType::Hexahedron_27(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_64: return XdmfTopologyType::Hexahedron_64(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_125: return XdmfTopologyType::Hexahedron_125(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_216: return XdmfTopologyType::Hexahedron_216(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_343: return XdmfTopologyType::Hexahedron_343(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_512: return XdmfTopologyType::Hexahedron_512(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_729: return XdmfTopologyType::Hexahedron_729(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_1000: return XdmfTopologyType::Hexahedron_1000(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_1331: return XdmfTopologyType::Hexahedron_1331(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_64: return XdmfTopologyType::Hexahedron_Spectral_64(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_125: return XdmfTopologyType::Hexahedron_Spectral_125(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_216: return XdmfTopologyType::Hexahedron_Spectral_216(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_343: return XdmfTopologyType::Hexahedron_Spectral_343(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_512: return XdmfTopologyType::Hexahedron_Spectral_512(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_729: return XdmfTopologyType::Hexahedron_Spectral_729(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_1000: return XdmfTopologyType::Hexahedron_Spectral_1000(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_1331: return XdmfTopologyType::Hexahedron_Spectral_1331(); break; case XDMF_TOPOLOGY_TYPE_MIXED: return XdmfTopologyType::Mixed(); break; default: return shared_ptr(); break; } } int typeToInt(shared_ptr type) { if (type->getID() == XdmfTopologyType::Polyvertex()->getID()) { return XDMF_TOPOLOGY_TYPE_POLYVERTEX; } else if (type->getID() == XdmfTopologyType::Polyline(0)->getID()) { return XDMF_TOPOLOGY_TYPE_POLYLINE; } else if (type->getID() == XdmfTopologyType::Polygon(0)->getID()) { return XDMF_TOPOLOGY_TYPE_POLYGON; } else if (type->getID() == XdmfTopologyType::Triangle()->getID()) { return XDMF_TOPOLOGY_TYPE_TRIANGLE; } else if (type->getID() == XdmfTopologyType::Quadrilateral()->getID()) { return XDMF_TOPOLOGY_TYPE_QUADRILATERAL; } else if (type->getID() == XdmfTopologyType::Tetrahedron()->getID()) { return XDMF_TOPOLOGY_TYPE_TETRAHEDRON; } else if (type->getID() == XdmfTopologyType::Pyramid()->getID()) { return XDMF_TOPOLOGY_TYPE_PYRAMID; } else if (type->getID() == XdmfTopologyType::Wedge()->getID()) { return XDMF_TOPOLOGY_TYPE_WEDGE; } else if (type->getID() == XdmfTopologyType::Hexahedron()->getID()) { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON; } else if (type->getID() == XdmfTopologyType::Polyhedron()->getID()) { return XDMF_TOPOLOGY_TYPE_POLYHEDRON; } else if (type->getID() == XdmfTopologyType::Edge_3()->getID()) { return XDMF_TOPOLOGY_TYPE_EDGE_3; } else if (type->getID() == XdmfTopologyType::Triangle_6()->getID()) { return XDMF_TOPOLOGY_TYPE_TRIANGLE_6; } else if (type->getID() == XdmfTopologyType::Quadrilateral_8()->getID()) { return XDMF_TOPOLOGY_TYPE_QUADRILATERAL_8; } else if (type->getID() == XdmfTopologyType::Quadrilateral_9()->getID()) { return XDMF_TOPOLOGY_TYPE_QUADRILATERAL_9; } else if (type->getID() == XdmfTopologyType::Tetrahedron_10()->getID()) { return XDMF_TOPOLOGY_TYPE_TETRAHEDRON_10; } else if (type->getID() == XdmfTopologyType::Pyramid_13()->getID()) { return XDMF_TOPOLOGY_TYPE_PYRAMID_13; } else if (type->getID() == XdmfTopologyType::Wedge_15()->getID()) { return XDMF_TOPOLOGY_TYPE_WEDGE_15; } else if (type->getID() == XdmfTopologyType::Wedge_18()->getID()) { return XDMF_TOPOLOGY_TYPE_WEDGE_18; } else if (type->getID() == XdmfTopologyType::Hexahedron_20()->getID()) { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_20; } else if (type->getID() == XdmfTopologyType::Hexahedron_24()->getID()) { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_24; } else if (type->getID() == XdmfTopologyType::Hexahedron_27()->getID()) { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_27; } else if (type->getID() == XdmfTopologyType::Hexahedron_64()->getID()) { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_64; } else if (type->getID() == XdmfTopologyType::Hexahedron_125()->getID()) { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_125; } else if (type->getID() == XdmfTopologyType::Hexahedron_216()->getID()) { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_216; } else if (type->getID() == XdmfTopologyType::Hexahedron_343()->getID()) { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_343; } else if (type->getID() == XdmfTopologyType::Hexahedron_512()->getID()) { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_512; } else if (type->getID() == XdmfTopologyType::Hexahedron_729()->getID()) { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_729; } else if (type->getID() == XdmfTopologyType::Hexahedron_1000()->getID()) { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_1000; } else if (type->getID() == XdmfTopologyType::Hexahedron_1331()->getID()) { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_1331; } else if (type->getID() == XdmfTopologyType::Hexahedron_Spectral_64()->getID()) { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_64; } else if (type->getID() == XdmfTopologyType::Hexahedron_Spectral_125()->getID()) { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_125; } else if (type->getID() == XdmfTopologyType::Hexahedron_Spectral_216()->getID()) { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_216; } else if (type->getID() == XdmfTopologyType::Hexahedron_Spectral_343()->getID()) { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_343; } else if (type->getID() == XdmfTopologyType::Hexahedron_Spectral_512()->getID()) { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_512; } else if (type->getID() == XdmfTopologyType::Hexahedron_Spectral_729()->getID()) { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_729; } else if (type->getID() == XdmfTopologyType::Hexahedron_Spectral_1000()->getID()) { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_1000; } else if (type->getID() == XdmfTopologyType::Hexahedron_Spectral_1331()->getID()) { return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_1331; } else if (type->getID() == XdmfTopologyType::Mixed()->getID()) { return XDMF_TOPOLOGY_TYPE_MIXED; } else { return -1; } } int XdmfTopologyTypeGetCellType(int type) { return intToType(type)->getCellType(); } unsigned int XdmfTopologyTypeGetEdgesPerElement(int type, int * status) { XDMF_ERROR_WRAP_START(status) return intToType(type)->getEdgesPerElement(); XDMF_ERROR_WRAP_END(status) return 0; } unsigned int XdmfTopologyTypeGetFacesPerElement(int type, int * status) { XDMF_ERROR_WRAP_START(status) return intToType(type)->getFacesPerElement(); XDMF_ERROR_WRAP_END(status) return 0; } int XdmfTopologyTypeGetFaceType(int type) { return typeToInt(intToType(type)->getFaceType()); } unsigned int XdmfTopologyTypeGetID(int type) { return intToType(type)->getID(); } char * XdmfTopologyTypeGetName(int type) { char * returnPointer = strdup(intToType(type)->getName().c_str()); return returnPointer; } unsigned int XdmfTopologyTypeGetNodesPerElement(int type) { return intToType(type)->getNodesPerElement(); } xdmf-3.0+git20160803/XdmfAttributeCenter.cpp0000640000175000017500000001155213003006557020525 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfAttributeCenter.cpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #include #include "XdmfAttributeCenter.hpp" #include "XdmfError.hpp" std::map(*)()> XdmfAttributeCenter::mAttributeCenterDefinitions; // Supported XdmfAttributeCenters shared_ptr XdmfAttributeCenter::Grid() { static shared_ptr p(new XdmfAttributeCenter("Grid")); return p; } shared_ptr XdmfAttributeCenter::Cell() { static shared_ptr p(new XdmfAttributeCenter("Cell")); return p; } shared_ptr XdmfAttributeCenter::Face() { static shared_ptr p(new XdmfAttributeCenter("Face")); return p; } shared_ptr XdmfAttributeCenter::Edge() { static shared_ptr p(new XdmfAttributeCenter("Edge")); return p; } shared_ptr XdmfAttributeCenter::Node() { static shared_ptr p(new XdmfAttributeCenter("Node")); return p; } void XdmfAttributeCenter::InitTypes() { mAttributeCenterDefinitions["GRID"] = Grid; mAttributeCenterDefinitions["CELL"] = Cell; mAttributeCenterDefinitions["FACE"] = Face; mAttributeCenterDefinitions["EDGE"] = Edge; mAttributeCenterDefinitions["NODE"] = Node; } XdmfAttributeCenter::XdmfAttributeCenter(const std::string & name) : mName(name) { } XdmfAttributeCenter::~XdmfAttributeCenter() { } shared_ptr XdmfAttributeCenter::New(const std::map & itemProperties) { InitTypes(); std::map::const_iterator center = itemProperties.find("Center"); if(center == itemProperties.end()) { XdmfError::message(XdmfError::FATAL, "'Center' not found in itemProperties in " "XdmfAttributeCenter::New"); } const std::string & centerVal = ConvertToUpper(center->second); std::map(*)()>::const_iterator returnType = mAttributeCenterDefinitions.find(centerVal); if (returnType == mAttributeCenterDefinitions.end()) { XdmfError::message(XdmfError::FATAL, "Center not of 'Grid','Cell','Face','Edge','Node' " "in XdmfAttributeCenter::New"); } else { return (*(returnType->second))(); } XdmfError::message(XdmfError::FATAL, "Center not of 'Grid','Cell','Face','Edge','Node' " "in XdmfAttributeCenter::New"); // unreachable return shared_ptr(); } void XdmfAttributeCenter::getProperties(std::map & collectedProperties) const { collectedProperties.insert(std::make_pair("Center", mName)); } // C Wrappers int XdmfAttributeCenterGrid() { return XDMF_ATTRIBUTE_CENTER_GRID; } int XdmfAttributeCenterCell() { return XDMF_ATTRIBUTE_CENTER_CELL; } int XdmfAttributeCenterFace() { return XDMF_ATTRIBUTE_CENTER_FACE; } int XdmfAttributeCenterEdge() { return XDMF_ATTRIBUTE_CENTER_EDGE; } int XdmfAttributeCenterNode() { return XDMF_ATTRIBUTE_CENTER_NODE; } xdmf-3.0+git20160803/XdmfCurvilinearGrid.cpp0000640000175000017500000003546013003006557020516 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfCurviliniearGrid.cpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #include #include "XdmfArray.hpp" #include "XdmfCurvilinearGrid.hpp" #include "XdmfGeometry.hpp" #include "XdmfTopology.hpp" #include "XdmfTopologyType.hpp" #include "XdmfError.hpp" /** * PIMPL */ class XdmfCurvilinearGrid::XdmfCurvilinearGridImpl : public XdmfGridImpl { public: class XdmfTopologyCurvilinear : public XdmfTopology { public: static shared_ptr New(const XdmfCurvilinearGrid * const curvilinearGrid) { shared_ptr p(new XdmfTopologyCurvilinear(curvilinearGrid)); return p; } bool isInitialized() const { return true; } unsigned int getNumberElements() const { const shared_ptr dimensions = mCurvilinearGrid->getDimensions(); if(dimensions->getSize() == 0) { return 0; } unsigned int toReturn = 1; for(unsigned int i=0; igetSize(); ++i) { toReturn *= (dimensions->getValue(i) - 1); } return toReturn; } private: XdmfTopologyCurvilinear(const XdmfCurvilinearGrid * const curvilinearGrid) : mCurvilinearGrid(curvilinearGrid) { this->setType(XdmfTopologyTypeCurvilinear::New(curvilinearGrid)); } const XdmfCurvilinearGrid * const mCurvilinearGrid; }; class XdmfTopologyTypeCurvilinear : public XdmfTopologyType { public: static shared_ptr New(const XdmfCurvilinearGrid * const curvilinearGrid) { shared_ptr p(new XdmfTopologyTypeCurvilinear(curvilinearGrid)); return p; } unsigned int getEdgesPerElement() const { return calculateHypercubeNumElements(mCurvilinearGrid->getDimensions()->getSize(), 1); /* const unsigned int dimensions = mCurvilinearGrid->getDimensions()->getSize(); if (dimensions == 1) { return 1; } if(dimensions == 2) { return 4; } else if(dimensions >= 3) { return 12; } else { XdmfError::message(XdmfError::FATAL, "Grid dimensions not 2 or 3 in " "XdmfTopologyTypeCurvilinear::getEdgesPerElement"); } return 0; */ } unsigned int getFacesPerElement() const { return calculateHypercubeNumElements(mCurvilinearGrid->getDimensions()->getSize(), 2); /* const unsigned int dimensions = mCurvilinearGrid->getDimensions()->getSize(); if (dimensions == 1) { return 0; } else if(dimensions == 2) { return 1; } else if(dimensions == 3) { return 6; } else { XdmfError::message(XdmfError::FATAL, "Grid dimensions not 2 or 3 in " "XdmfTopologyTypeCurvilinear::getFacesPerElement"); } return 0; */ } unsigned int getNodesPerElement() const { return calculateHypercubeNumElements(mCurvilinearGrid->getDimensions()->getSize(), 0); // 2^Dimensions // e.g. 1D = 2 nodes per element and 2D = 4 nodes per element. // return (unsigned int) // std::pow(2, (double)mCurvilinearGrid->getDimensions()->getSize()); } void getProperties(std::map & collectedProperties) const { shared_ptr dimensions = mCurvilinearGrid->getDimensions(); if(dimensions->getSize() == 3) { collectedProperties["Type"] = "3DSMesh"; } else if(dimensions->getSize() == 2) { collectedProperties["Type"] = "2DSMesh"; } else { collectedProperties["Type"] = "SMesh"; // XdmfError::message(XdmfError::FATAL, // "Grid dimensions not 2 or 3 in " // "XdmfTopologyTypeCurvilinear::getProperties"); } collectedProperties["Dimensions"] = dimensions->getValuesString(); } private: XdmfTopologyTypeCurvilinear(const XdmfCurvilinearGrid * const curvilinearGrid) : XdmfTopologyType(0, 0, std::vector >(), 0, "foo", XdmfTopologyType::Structured, 0x1110), mCurvilinearGrid(curvilinearGrid) { } const XdmfCurvilinearGrid * const mCurvilinearGrid; }; XdmfCurvilinearGridImpl(const shared_ptr numPoints) : mDimensions(numPoints) { mGridType ="Curvilinear"; } XdmfGridImpl * duplicate() { return new XdmfCurvilinearGridImpl(mDimensions); } shared_ptr mDimensions; }; shared_ptr XdmfCurvilinearGrid::New(const unsigned int xNumPoints, const unsigned int yNumPoints) { shared_ptr numPoints = XdmfArray::New(); numPoints->initialize(2); numPoints->insert(0, xNumPoints); numPoints->insert(1, yNumPoints); shared_ptr p(new XdmfCurvilinearGrid(numPoints)); return p; } shared_ptr XdmfCurvilinearGrid::New(const unsigned int xNumPoints, const unsigned int yNumPoints, const unsigned int zNumPoints) { shared_ptr numPoints = XdmfArray::New(); numPoints->initialize(3); numPoints->insert(0, xNumPoints); numPoints->insert(1, yNumPoints); numPoints->insert(2, zNumPoints); shared_ptr p(new XdmfCurvilinearGrid(numPoints)); return p; } shared_ptr XdmfCurvilinearGrid::New(const shared_ptr numPoints) { shared_ptr p(new XdmfCurvilinearGrid(numPoints)); return p; } XdmfCurvilinearGrid::XdmfCurvilinearGrid(const shared_ptr numPoints) : XdmfGrid(XdmfGeometry::New(), XdmfCurvilinearGridImpl::XdmfTopologyCurvilinear::New(this)) { mImpl = new XdmfCurvilinearGridImpl(numPoints); } XdmfCurvilinearGrid::XdmfCurvilinearGrid(XdmfCurvilinearGrid & refGrid) : XdmfGrid(refGrid) { mTopology = XdmfCurvilinearGridImpl::XdmfTopologyCurvilinear::New(this); } XdmfCurvilinearGrid::~XdmfCurvilinearGrid() { if (mImpl) { delete mImpl; } mImpl = NULL; } const std::string XdmfCurvilinearGrid::ItemTag = "Grid"; void XdmfCurvilinearGrid::copyGrid(shared_ptr sourceGrid) { XdmfGrid::copyGrid(sourceGrid); if (shared_ptr classedGrid = shared_dynamic_cast(sourceGrid)) { // Copy stucture from read grid to this grid this->setGeometry(classedGrid->getGeometry()); this->setDimensions(classedGrid->getDimensions()); } } shared_ptr XdmfCurvilinearGrid::getDimensions() { return boost::const_pointer_cast (static_cast(*this).getDimensions()); } shared_ptr XdmfCurvilinearGrid::getDimensions() const { return ((XdmfCurvilinearGridImpl *)mImpl)->mDimensions; } shared_ptr XdmfCurvilinearGrid::getGeometry() { return boost::const_pointer_cast (static_cast(*this).getGeometry()); } void XdmfCurvilinearGrid::populateItem(const std::map & itemProperties, const std::vector > & childItems, const XdmfCoreReader * const reader) { XdmfGrid::populateItem(itemProperties, childItems, reader); for(std::vector >::const_iterator iter = childItems.begin(); iter != childItems.end(); ++iter) { if(shared_ptr curvilinearGrid = shared_dynamic_cast(*iter)) { ((XdmfCurvilinearGridImpl *)mImpl)->mDimensions = curvilinearGrid->getDimensions(); } } } void XdmfCurvilinearGrid::read() { if (mGridController) { if (shared_ptr grid = shared_dynamic_cast(mGridController->read())) { // Copy stucture from read grid to this grid copyGrid(grid); } else if (shared_ptr grid = shared_dynamic_cast(mGridController->read())) { XdmfError::message(XdmfError::FATAL, "Error: Grid Type Mismatch"); } else { XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Reference"); } } } void XdmfCurvilinearGrid::release() { XdmfGrid::release(); this->setGeometry(shared_ptr()); this->setDimensions(shared_ptr()); } void XdmfCurvilinearGrid::setDimensions(const shared_ptr dimensions) { ((XdmfCurvilinearGridImpl *)mImpl)->mDimensions = dimensions; this->setIsChanged(true); } void XdmfCurvilinearGrid::setGeometry(const shared_ptr geometry) { mGeometry = geometry; this->setIsChanged(true); } // C Wrappers XDMFCURVILINEARGRID * XdmfCurvilinearGridNew2D(unsigned int xNumPoints, unsigned int yNumPoints) { try { shared_ptr generatedGrid = XdmfCurvilinearGrid::New(xNumPoints, yNumPoints); return (XDMFCURVILINEARGRID *)((void *)((XdmfItem *)(new XdmfCurvilinearGrid(*generatedGrid.get())))); } catch (...) { shared_ptr generatedGrid = XdmfCurvilinearGrid::New(xNumPoints, yNumPoints); return (XDMFCURVILINEARGRID *)((void *)((XdmfItem *)(new XdmfCurvilinearGrid(*generatedGrid.get())))); } } XDMFCURVILINEARGRID * XdmfCurvilinearGridNew3D(unsigned int xNumPoints, unsigned int yNumPoints, unsigned int zNumPoints) { try { shared_ptr generatedGrid = XdmfCurvilinearGrid::New(xNumPoints, yNumPoints, zNumPoints); return (XDMFCURVILINEARGRID *)((void *)((XdmfItem *)(new XdmfCurvilinearGrid(*generatedGrid.get())))); } catch (...) { shared_ptr generatedGrid = XdmfCurvilinearGrid::New(xNumPoints, yNumPoints, zNumPoints); return (XDMFCURVILINEARGRID *)((void *)((XdmfItem *)(new XdmfCurvilinearGrid(*generatedGrid.get())))); } } XDMFCURVILINEARGRID * XdmfCurvilinearGridNew(XDMFARRAY * numPoints, int * status) { XDMF_ERROR_WRAP_START(status) try { shared_ptr tempArray = shared_ptr((XdmfArray *)numPoints, XdmfNullDeleter()); shared_ptr generatedGrid = XdmfCurvilinearGrid::New(tempArray); return (XDMFCURVILINEARGRID *)((void *)((XdmfItem *)(new XdmfCurvilinearGrid(*generatedGrid.get())))); } catch (...) { shared_ptr tempArray = shared_ptr((XdmfArray *)numPoints, XdmfNullDeleter()); shared_ptr generatedGrid = XdmfCurvilinearGrid::New(tempArray); return (XDMFCURVILINEARGRID *)((void *)((XdmfItem *)(new XdmfCurvilinearGrid(*generatedGrid.get())))); } XDMF_ERROR_WRAP_END(status) return NULL; } XDMFARRAY * XdmfCurvilinearGridGetDimensions(XDMFCURVILINEARGRID * grid, int * status) { XDMF_ERROR_WRAP_START(status) try { XdmfItem * classedPointer = (XdmfItem *)grid; XdmfCurvilinearGrid * gridPointer = dynamic_cast(classedPointer); shared_ptr generatedArray = gridPointer->getDimensions(); return (XDMFARRAY *)((void *)generatedArray.get()); } catch (...) { XdmfItem * classedPointer = (XdmfItem *)grid; XdmfCurvilinearGrid * gridPointer = dynamic_cast(classedPointer); shared_ptr generatedArray = gridPointer->getDimensions(); return (XDMFARRAY *)((void *)generatedArray.get()); } XDMF_ERROR_WRAP_END(status) return NULL; } XDMFGEOMETRY * XdmfCurvilinearGridGetGeometry(XDMFCURVILINEARGRID * grid) { XdmfItem * classedPointer = (XdmfItem *)grid; XdmfCurvilinearGrid * gridPointer = dynamic_cast(classedPointer); shared_ptr generatedGeometry = gridPointer->getGeometry(); return (XDMFGEOMETRY *)((void *)generatedGeometry.get()); } void XdmfCurvilinearGridSetDimensions(XDMFCURVILINEARGRID * grid, XDMFARRAY * dimensions, int passControl, int * status) { XDMF_ERROR_WRAP_START(status) XdmfItem * classedPointer = (XdmfItem *)grid; XdmfCurvilinearGrid * gridPointer = dynamic_cast(classedPointer); if (passControl) { gridPointer->setDimensions(shared_ptr((XdmfArray *)dimensions)); } else { gridPointer->setDimensions(shared_ptr((XdmfArray *)dimensions, XdmfNullDeleter())); } XDMF_ERROR_WRAP_END(status) } void XdmfCurvilinearGridSetGeometry(XDMFCURVILINEARGRID * grid, XDMFGEOMETRY * geometry, int passControl) { XdmfItem * classedPointer = (XdmfItem *)grid; XdmfCurvilinearGrid * gridPointer = dynamic_cast(classedPointer); if (passControl) { gridPointer->setGeometry(shared_ptr((XdmfGeometry *)geometry)); } else { gridPointer->setGeometry(shared_ptr((XdmfGeometry *)geometry, XdmfNullDeleter())); } } XDMF_ITEM_C_CHILD_WRAPPER(XdmfCurvilinearGrid, XDMFCURVILINEARGRID) XDMF_GRID_C_CHILD_WRAPPER(XdmfCurvilinearGrid, XDMFCURVILINEARGRID) xdmf-3.0+git20160803/XdmfTemplate.cpp0000640000175000017500000014346413003006557017204 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfTemplate.cpp */ /* */ /* Author: */ /* Andrew Burns */ /* andrew.j.burns2@us.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2013 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #include #include #include #include #include "XdmfArray.hpp" #include "XdmfHDF5Controller.hpp" #include "XdmfBinaryController.hpp" #include "XdmfItem.hpp" #include "XdmfItemFactory.hpp" #include "XdmfReader.hpp" #include "XdmfTemplate.hpp" #include "XdmfError.hpp" #include "XdmfVisitor.hpp" #include "XdmfWriter.hpp" #include "XdmfSystemUtils.hpp" #include #include std::vector > getStepControllers(unsigned int stepId, std::vector stepDims, std::vector > datasetControllers) { std::vector > returnVector; if (datasetControllers.size() > 0) { unsigned int sizePerStep = 1; for (unsigned int i = 0; i < stepDims.size(); ++i) { sizePerStep *= stepDims[i]; } // unsigned int offset = (sizePerStep * stepId); // unsigned int offsetStepsRemaining = 0; unsigned int offset = 0; unsigned int offsetStepsRemaining = stepId; // grabbing the subset is a little different for each type // Right now we assume controllers are of the same type unsigned int controllerIndex = 0; unsigned int sizeRemaining = sizePerStep; unsigned int arrayoffset = 0; while (sizeRemaining > 0) { //printf("sizeRemaining = %u\n", sizeRemaining); // We don't reset the controller index between runs of the while loop // On iterations after the first it should only execute the loop once // because offset is set to 0 while (controllerIndex < datasetControllers.size()) { //printf("offset = %u\n", offset); //printf("%u >= %u\n", offset, datasetControllers[controllerIndex]->getSize()); //Iterate until we find the controller that the step starts in if (offset >= datasetControllers[controllerIndex]->getSize()) { offset -= datasetControllers[controllerIndex]->getSize(); ++controllerIndex; } else { if (offsetStepsRemaining == 0) { // offset is within the current controller break; } else { // There are steps left to offset //printf("accounting for step %d\n", offsetStepsRemaining); offset += sizePerStep; --offsetStepsRemaining; } } } //printf("final offset = %u\n", offset); std::vector newDimVector; std::vector newStarts; //printf("after creating dim vector but before filling it\n"); //printf("%d < %d\n", controllerIndex, datasetControllers.size()); //printf("size left %d\n", sizeRemaining); if (offset + sizeRemaining <= datasetControllers[controllerIndex]->getSize()) { //printf("step is entirely in the controller\n"); // step is entirely within this controller newStarts.push_back(offset + datasetControllers[controllerIndex]->getStart()[0]); // TODO multidim version newDimVector.push_back(sizeRemaining); sizeRemaining = 0; } else { //printf("step is partially in the controller\n"); if (controllerIndex + 1 >= datasetControllers.size()) { // Error, step doesn't fit in the data set provided XdmfError::message(XdmfError::FATAL, "Error: Step does not fit in data step provided"); } // step is partially in this controller newDimVector.push_back(sizeRemaining - (sizeRemaining - (datasetControllers[controllerIndex]->getSize() - offset))); newStarts.push_back(offset+datasetControllers[controllerIndex]->getStart()[0]); // TODO multidim version sizeRemaining -= newDimVector[0]; } //printf("size for other controllers %d\n", sizeRemaining); //printf("before creating the new controller\n"); // Using the remaining space in the controller // Slightly differen creation method for each controller if (datasetControllers[0]->getName().compare("Binary") == 0) { shared_ptr createdController = XdmfBinaryController::New(datasetControllers[0]->getFilePath(), datasetControllers[0]->getType(), shared_dynamic_cast( datasetControllers[0])->getEndian(), newStarts[0], newDimVector); returnVector.push_back(createdController); } else if (datasetControllers[0]->getName().compare("HDF") == 0) { // TODO // The writer should only write to contiguous sets when in this mode. // A user would need to do something custom to foul this up. std::vector newStrides; newStrides.push_back(1); shared_ptr createdController = XdmfHDF5Controller::New(datasetControllers[controllerIndex]->getFilePath(), shared_dynamic_cast( datasetControllers[controllerIndex])->getDataSetPath(), datasetControllers[0]->getType(), newStarts, newStrides, newDimVector, shared_dynamic_cast( datasetControllers[controllerIndex])->getDataspaceDimensions()); returnVector.push_back(createdController); } //printf("after creating the new controller\n"); returnVector[returnVector.size()-1]->setArrayOffset(arrayoffset); arrayoffset += returnVector[returnVector.size()-1]->getSize(); offset = 0; ++controllerIndex; // Starts at the beggining of the next controller } } /* printf("size of return vector = %d\n", returnVector.size()); for (unsigned int i = 0; i < returnVector.size(); ++i) { shared_ptr currentController = shared_dynamic_cast(returnVector[i]); assert(currentController); printf("file = %s\n", currentController->getFilePath().c_str()); printf("dataset = %s\n", currentController->getDataSetPath().c_str()); printf("start = %u\n", currentController->getStart()[0]); printf("dimension = %u\n", currentController->getDimensions()[0]); printf("dataspace = %u\n", currentController->getDataspaceDimensions()[0]); } */ return returnVector; } std::vector > getControllersExcludingStep(unsigned int stepId, std::vector stepDims, std::vector > datasetControllers) { std::vector > returnVector; if (datasetControllers.size() > 0) { unsigned int sizePerStep = 1; for (unsigned int i = 0; i < stepDims.size(); ++i) { sizePerStep *= stepDims[i]; } unsigned int offset = sizePerStep * stepId; unsigned int sizeRemaining = sizePerStep; //printf("base offset = %u\nstarting size remaining = %u\ncutting from %u controllers\n", offset, sizeRemaining, datasetControllers.size()); // grabbing the subset is a little different for each type // Right now we assume controllers are of the same type for (unsigned int controllerIndex = 0; controllerIndex < datasetControllers.size(); ++controllerIndex) { //printf("offset = %u out of controller size %u\n", offset, datasetControllers[controllerIndex]->getSize()); if (offset >= datasetControllers[controllerIndex]->getSize()) { // The removed step isn't in the controller provided // Simply add it back into the return set returnVector.push_back(datasetControllers[controllerIndex]); // then subtract the size from the offset offset -= datasetControllers[controllerIndex]->getSize(); } else { // The removed step is inside the controller provided if (offset > 0) { //printf("removed step is inside this controller\n"); // If offset is greater than zero the controller has a section chopped off the front std::vector newDim; newDim.push_back(offset); // Dataspace is the same // stride is the same // start is the same // TODO dims is reduced to just cover the offset size if (datasetControllers[controllerIndex]->getName().compare("Binary") == 0) { shared_ptr createdController = XdmfBinaryController::New(datasetControllers[controllerIndex]->getFilePath(), datasetControllers[controllerIndex]->getType(), shared_dynamic_cast( datasetControllers[controllerIndex])->getEndian(), shared_dynamic_cast( datasetControllers[controllerIndex])->getSeek(), datasetControllers[controllerIndex]->getStart(), datasetControllers[controllerIndex]->getStride(), newDim, datasetControllers[controllerIndex]->getDataspaceDimensions()); returnVector.push_back(createdController); } else if (datasetControllers[controllerIndex]->getName().compare("HDF") == 0) { // TODO // The writer should only write to contiguous sets when in this mode. // A user would need to do something custom to foul this up. shared_ptr createdController = XdmfHDF5Controller::New(datasetControllers[controllerIndex]->getFilePath(), shared_dynamic_cast( datasetControllers[controllerIndex])->getDataSetPath(), datasetControllers[controllerIndex]->getType(), datasetControllers[controllerIndex]->getStart(), datasetControllers[controllerIndex]->getStride(), newDim, shared_dynamic_cast( datasetControllers[controllerIndex])->getDataspaceDimensions()); returnVector.push_back(createdController); } // These are the stats for the first half of the dataset if (sizeRemaining <= datasetControllers[controllerIndex]->getSize() - offset) { // The controller is large enough to need to be split into two controllers std::vector newStart; //TODO we're assuming one dim for now newStart.push_back(datasetControllers[controllerIndex]->getStart()[0] +sizeRemaining + offset); std::vector newDim; newDim.push_back(datasetControllers[controllerIndex]->getSize() - (sizeRemaining + offset)); // These are the stats of the second controller sizeRemaining = 0; if (datasetControllers[controllerIndex]->getName().compare("Binary") == 0) { shared_ptr createdController = XdmfBinaryController::New(datasetControllers[controllerIndex]->getFilePath(), datasetControllers[controllerIndex]->getType(), shared_dynamic_cast( datasetControllers[controllerIndex])->getEndian(), shared_dynamic_cast( datasetControllers[controllerIndex])->getSeek(), newStart, datasetControllers[controllerIndex]->getStride(), newDim, datasetControllers[controllerIndex]->getDataspaceDimensions()); returnVector.push_back(createdController); } else if (datasetControllers[controllerIndex]->getName().compare("HDF") == 0) { // TODO // The writer should only write to contiguous sets when in this mode. // A user would need to do something custom to foul this up. shared_ptr createdController = XdmfHDF5Controller::New(datasetControllers[controllerIndex]->getFilePath(), shared_dynamic_cast( datasetControllers[controllerIndex])->getDataSetPath(), datasetControllers[controllerIndex]->getType(), newStart, datasetControllers[controllerIndex]->getStride(), newDim, shared_dynamic_cast( datasetControllers[controllerIndex])->getDataspaceDimensions()); returnVector.push_back(createdController); } } else { // The controller only contains part of the dataset sizeRemaining -= (datasetControllers[controllerIndex]->getSize() - offset); } offset = 0; } else { // in the case of 0 offset, we either need to trim from the front or just use the whole controller if (sizeRemaining > 0) { if (sizeRemaining < datasetControllers[controllerIndex]->getSize()) { std::vector newStart; newStart.push_back(sizeRemaining); std::vector newDim; newDim.push_back(datasetControllers[controllerIndex]->getSize() - sizeRemaining); sizeRemaining = 0; if (datasetControllers[controllerIndex]->getName().compare("Binary") == 0) { shared_ptr createdController = XdmfBinaryController::New(datasetControllers[controllerIndex]->getFilePath(), datasetControllers[controllerIndex]->getType(), shared_dynamic_cast( datasetControllers[controllerIndex])->getEndian(), shared_dynamic_cast( datasetControllers[controllerIndex])->getSeek(), newStart, datasetControllers[controllerIndex]->getStride(), newDim, datasetControllers[controllerIndex]->getDataspaceDimensions()); returnVector.push_back(createdController); } else if (datasetControllers[controllerIndex]->getName().compare("HDF") == 0) { // TODO // The writer should only write to contiguous sets when in this mode. // A user would need to do something custom to foul this up. shared_ptr createdController = XdmfHDF5Controller::New(datasetControllers[controllerIndex]->getFilePath(), shared_dynamic_cast( datasetControllers[controllerIndex])->getDataSetPath(), datasetControllers[controllerIndex]->getType(), newStart, datasetControllers[controllerIndex]->getStride(), newDim, shared_dynamic_cast( datasetControllers[controllerIndex])->getDataspaceDimensions()); returnVector.push_back(createdController); } } else { sizeRemaining -= datasetControllers[controllerIndex]->getSize(); } } else { // Just use the current controller returnVector.push_back(datasetControllers[controllerIndex]); } } } } } return returnVector; } class XdmfArrayGatherer : public XdmfVisitor, public Loki::Visitor { public: static shared_ptr New(std::vector * storageVector) { shared_ptr p(new XdmfArrayGatherer(storageVector)); return p; } ~XdmfArrayGatherer() { } virtual void visit(XdmfArray & array, const shared_ptr visitor) { ++mDepth; if (!array.isInitialized()) { // mStorage->push_back(&array); mArrayCollection.insert(&array); } array.traverse(visitor); --mDepth; if (mDepth == 0) { moveToStorage(); } } virtual void visit(XdmfItem & item, const shared_ptr visitor) { ++mDepth; item.traverse(visitor); --mDepth; if (mDepth == 0) { moveToStorage(); } } void moveToStorage() { for (std::set::iterator iter = mArrayCollection.begin(); iter != mArrayCollection.end(); ++iter) { mStorage->push_back(*iter); } } private: XdmfArrayGatherer(std::vector * storageVector) : mDepth(0), mStorage(storageVector) { } unsigned int mDepth; std::set mArrayCollection; std::vector * mStorage; }; shared_ptr XdmfTemplate::New() { shared_ptr p(new XdmfTemplate()); return p; } XdmfTemplate::XdmfTemplate() : mHeavyWriter(shared_ptr()), mBase(shared_ptr()), mCurrentStep(-1), mNumSteps(0), mItemFactory(shared_ptr()) { } XdmfTemplate::XdmfTemplate(XdmfTemplate & refTemplate) : XdmfItem(refTemplate), mBase(refTemplate.mBase), mCurrentStep(refTemplate.mCurrentStep), mNumSteps(refTemplate.mNumSteps), mItemFactory(refTemplate.mItemFactory) { } XdmfTemplate::~XdmfTemplate() { } const std::string XdmfTemplate::ItemTag = "Template"; unsigned int XdmfTemplate::addStep() { mCurrentStep = this->getNumberSteps(); std::stringstream datastream; if (mTrackedArrays.size() < 1) { XdmfError::message(XdmfError::FATAL, "Error: XdmfTemplate attempting to add a step when no arrays are tracked"); } for (unsigned int arrayIndex = 0; arrayIndex < mTrackedArrays.size(); ++arrayIndex) { if (mTrackedArrayTypes.size() < mTrackedArrays.size()){ mTrackedArrayTypes.resize(mTrackedArrays.size()); } if (mTrackedArrayDims.size() < mTrackedArrays.size()){ mTrackedArrayDims.resize(mTrackedArrays.size()); } if (!mTrackedArrayTypes[arrayIndex]) { mTrackedArrayTypes[arrayIndex] = mTrackedArrays[arrayIndex]->getArrayType(); } if (mTrackedArrayDims[arrayIndex].size() == 0) { mTrackedArrayDims[arrayIndex] = mTrackedArrays[arrayIndex]->getDimensions(); } // Write the tracked arrays to heavy data if they aren't already if (mHeavyWriter) { bool revertToAppend = false; if (mHeavyWriter->getMode() == XdmfHeavyDataWriter::Append) { // Set to original heavy data controllers for append if (mDataControllers.size() > arrayIndex) { if (mDataControllers[arrayIndex].size() > 0) { while (mTrackedArrays[arrayIndex]->getNumberHeavyDataControllers() > 0) { mTrackedArrays[arrayIndex]->removeHeavyDataController(0); } for (unsigned int i = 0; i < mDataControllers[arrayIndex].size(); ++i) { mTrackedArrays[arrayIndex]->insert(mDataControllers[arrayIndex][i]); } } } else { // Creating new Dataset // Set to default mode so that it doesn't overlap mHeavyWriter->setMode(XdmfHeavyDataWriter::Default); revertToAppend = true; } } else if (mHeavyWriter->getMode() == XdmfHeavyDataWriter::Hyperslab) { // Use the controller that references the subset that will be overwritten if (!(arrayIndex < mDataControllers.size())) { // When in overwrite mode the dataset must be preallocated XdmfError::message(XdmfError::FATAL, "Error: Heavy Data dataset must be preallocated " "to use Hyperslab mode Templates"); } std::vector > overwriteControllers = getStepControllers(mCurrentStep, mTrackedArrayDims[arrayIndex], mDataControllers[arrayIndex]); mTrackedArrays[arrayIndex]->setHeavyDataController(overwriteControllers); } mTrackedArrays[arrayIndex]->accept(mHeavyWriter); if (revertToAppend) { mHeavyWriter->setMode(XdmfHeavyDataWriter::Append); } } datastream.str(std::string()); for (unsigned int controllerIndex = 0; controllerIndex < mTrackedArrays[arrayIndex]->getNumberHeavyDataControllers(); ++controllerIndex) { // TODO throw error if controller types don't match // For each heavy data controller std::string writerPath = XdmfSystemUtils::getRealPath(mHeavyWriter->getFilePath()); std::string heavyDataPath = mTrackedArrays[arrayIndex]->getHeavyDataController(controllerIndex)->getFilePath(); size_t index = heavyDataPath.find_last_of("/\\"); if(index != std::string::npos) { // If path is not a folder // put the directory path into this variable const std::string heavyDataDir = heavyDataPath.substr(0, index + 1); // If the directory is in the XML File Path if(writerPath.find(heavyDataDir) == 0) { heavyDataPath = heavyDataPath.substr(heavyDataDir.size(), heavyDataPath.size() - heavyDataDir.size()); // Pull the file off of the end and place it in the DataPath } // Otherwise the full path is required } datastream << heavyDataPath; datastream << mTrackedArrays[arrayIndex]->getHeavyDataController(controllerIndex)->getDescriptor(); datastream << "|"; for (unsigned int i = 0; i < mTrackedArrays[arrayIndex]->getHeavyDataController(controllerIndex)->getDimensions().size(); ++i) { datastream << mTrackedArrays[arrayIndex]->getHeavyDataController(controllerIndex)->getDimensions()[i]; if (i < mTrackedArrays[arrayIndex]->getHeavyDataController(controllerIndex)->getDimensions().size() - 1) { datastream << " "; } } if (controllerIndex + 1 < mTrackedArrays[arrayIndex]->getNumberHeavyDataControllers()) { datastream << "|"; } } if (mHeavyWriter) { if (mHeavyWriter->getMode() == XdmfHeavyDataWriter::Append) { if (mDataControllers.size() > arrayIndex) { // If controllers already exist // Store the overarching controllers again mDataControllers[arrayIndex].clear(); for (unsigned int i = 0; i < mTrackedArrays[arrayIndex]->getNumberHeavyDataControllers(); ++i) { mDataControllers[arrayIndex].push_back(mTrackedArrays[arrayIndex]->getHeavyDataController(i)); } // Clear controllers from the array while (mTrackedArrays[arrayIndex]->getNumberHeavyDataControllers() > 0) { mTrackedArrays[arrayIndex]->removeHeavyDataController(0); } // If append set controller to the correct subsection of the whole std::vector > readControllers = getStepControllers(mCurrentStep, mTrackedArrayDims[arrayIndex], mDataControllers[arrayIndex]); mTrackedArrays[arrayIndex]->setHeavyDataController(readControllers); // Replace with updated description mDataDescriptions[arrayIndex] = datastream.str(); } else { // If a new dataset, as normal mDataControllers.push_back(std::vector >()); for (unsigned int i = 0; i < mTrackedArrays[arrayIndex]->getNumberHeavyDataControllers(); ++i) { mDataControllers[mDataControllers.size()-1].push_back((mTrackedArrays[arrayIndex]->getHeavyDataController(i))); } if (mTrackedArrays[arrayIndex]->getNumberHeavyDataControllers() > 0) { mDataTypes.push_back(mTrackedArrays[arrayIndex]->getHeavyDataController(0)->getName()); mDataDescriptions.push_back(datastream.str()); } } } else if (mHeavyWriter->getMode() == XdmfHeavyDataWriter::Hyperslab) { // Hyperslab is already storing the base controller // So nothing is done here, the controller should already be pointing to the correct location // TODO, to what the file index was before the add, as opposed to 0 mHeavyWriter->setFileIndex(0); } else { mDataControllers.push_back(std::vector >()); for (unsigned int i = 0; i < mTrackedArrays[arrayIndex]->getNumberHeavyDataControllers(); ++i) { mDataControllers[mDataControllers.size()-1].push_back((mTrackedArrays[arrayIndex]->getHeavyDataController(i))); } if (mTrackedArrays[arrayIndex]->getNumberHeavyDataControllers() > 0) { mDataTypes.push_back(mTrackedArrays[arrayIndex]->getHeavyDataController(0)->getName()); mDataDescriptions.push_back(datastream.str()); } } } else { mDataControllers.push_back(std::vector >()); mDataTypes.push_back("XML"); mDataDescriptions.push_back(mTrackedArrays[arrayIndex]->getValuesString()); } } ++mNumSteps; this->setIsChanged(true); return mCurrentStep; } void XdmfTemplate::clearStep() { for (unsigned int i = 0; i < mTrackedArrays.size(); ++i) { mTrackedArrays[i]->release(); while (mTrackedArrays[i]->getNumberHeavyDataControllers() > 0) { mTrackedArrays[i]->removeHeavyDataController(0); } } mCurrentStep = -1; } shared_ptr XdmfTemplate::getBase() { return mBase; } shared_ptr XdmfTemplate::getHeavyDataWriter() { return mHeavyWriter; } std::map XdmfTemplate::getItemProperties() const { std::map templateProperties; /* std::stringstream value; value << mValue; timeProperties.insert(std::make_pair("Value", value.str())); */ return templateProperties; } std::string XdmfTemplate::getItemTag() const { return ItemTag; } unsigned int XdmfTemplate::getNumberSteps() const { return mNumSteps; } unsigned int XdmfTemplate::getNumberTrackedArrays() const { return mTrackedArrays.size(); } XdmfArray * XdmfTemplate::getTrackedArray(unsigned int index) { return mTrackedArrays[index]; } void XdmfTemplate::populateItem(const std::map & itemProperties, const std::vector > & childItems, const XdmfCoreReader * const reader) { XdmfItem::populateItem(itemProperties, childItems, reader); // The first child item is the base mBase = childItems[0]; mCurrentStep = 0; std::string referenceHDF5File = ""; if (childItems.size() > 1) { for(std::vector >::const_iterator iter = childItems.begin() + 1; iter != childItems.end(); ++iter) { if(shared_ptr array = shared_dynamic_cast(*iter)) { // Pull hdf5 reference data from the first provided array if (array->getNumberHeavyDataControllers() > 0 & !mHeavyWriter) { mHeavyWriter = reader->generateHeavyDataWriter(array->getHeavyDataController(0)->getName(), array->getHeavyDataController(0)->getFilePath()); } if (array->getName().compare("Data Description") == 0) { // Split description into substrings based on the " character array->read(); std::string descriptionString; if (array->getArrayType() == XdmfArrayType::Int8()) { descriptionString = std::string((char *)array->getValuesInternal()); } else if (array->getArrayType() == XdmfArrayType::String()) { std::stringstream descriptionstream; for (unsigned int i = 0; i < array->getSize(); ++i) { descriptionstream << array->getValue(i); if (i < array->getSize() - 1) { descriptionstream << '|'; } } descriptionString = descriptionstream.str(); } size_t index = descriptionString.find_first_of("\""); size_t previousIndex = 0; if (index != std::string::npos) { // Removing the prepended " previousIndex = index + 1; index = descriptionString.find_first_of("\"", previousIndex); } while (index != std::string::npos) { std::string type = descriptionString.substr(previousIndex, index - previousIndex); mDataTypes.push_back(type); previousIndex = index + 1; index = descriptionString.find_first_of("\"", previousIndex); if (index - previousIndex > 0) { std::string description; description = descriptionString.substr(previousIndex, index - previousIndex); mDataDescriptions.push_back(description); // create controllers here based on the type/description? // Is array type already filled? // Potentially call "fillControllers" after populating? if (index != std::string::npos) { previousIndex = index + 1; index = descriptionString.find_first_of("\"", previousIndex); } } else { XdmfError::message(XdmfError::FATAL, "Error: Type without a description in XdmfTemplate::populateItem"); } } } else { mTrackedArrays.push_back(array.get()); mTrackedArrayDims.push_back(array->getDimensions()); mTrackedArrayTypes.push_back(array->getArrayType()); } } } } for (unsigned int i = 0; i < mDataTypes.size(); ++i) { mDataControllers.push_back(std::vector >()); } mDataControllers.resize(mDataTypes.size()); if (!mItemFactory) { mItemFactory = XdmfItemFactory::New(); } std::map populateProperties; if (mHeavyWriter) { // The heavy writer provides the XMLDir, which is used to get full paths for the controllers // It is assumed that the files that the controllers reference are in the same directory // as the file that the writer references std::string filepath = XdmfSystemUtils::getRealPath(mHeavyWriter->getFilePath()); size_t index = filepath.find_last_of("/\\"); filepath = filepath.substr(0, index + 1); populateProperties["XMLDir"] = filepath; } else { // Error because a writer is required? TODO } for (unsigned int i = 0; i < mDataDescriptions.size(); ++i) { populateProperties["Content"] = mDataDescriptions[i]; std::vector > readControllers = reader->generateHeavyDataControllers(populateProperties, mTrackedArrayDims[i % mTrackedArrays.size()], mTrackedArrayTypes[i % mTrackedArrays.size()], mDataTypes[i]); if (readControllers.size() > 0) { // Heavy data controllers reference the data for (unsigned int j = 0; j < readControllers.size(); ++j) { mDataControllers[i].push_back(readControllers[j]); } } } // Compare the first set of controllers to the size of the first array unsigned int controllerTotal = 0; for (unsigned int i = 0; i < mDataControllers[0].size(); ++i) { unsigned int previousTotal = controllerTotal; controllerTotal += mDataControllers[0][i]->getSize(); if (previousTotal != controllerTotal - mDataControllers[0][i]->getSize()) { controllerTotal = UINT_MAX; break; } } // If the array is smaller, set the writer to append. if (controllerTotal > mTrackedArrays[0]->getSize()) { mHeavyWriter->setMode(XdmfHeavyDataWriter::Append); mNumSteps = 0; unsigned int currentTotal = 0; for (unsigned int controllerIndex = 0; controllerIndex < mDataControllers[0].size(); ++controllerIndex) { currentTotal += mDataControllers[0][controllerIndex]->getSize(); while (currentTotal >= mTrackedArrays[0]->getSize()) { currentTotal -= mTrackedArrays[0]->getSize(); ++mNumSteps; } } // mNumSteps = controllerTotal / mTrackedArrays[0]->getSize(); } else { mNumSteps = mDataControllers.size() / mTrackedArrays.size(); } this->setStep(0); } void XdmfTemplate::preallocateSteps(unsigned int numSteps) { // Preallocate steps based on the current size of the arrays // Use a temporary array to write data to hdf5 shared_ptr tempArray = XdmfArray::New(); // Set to Default mode so that the new allocations are in new locations mHeavyWriter->setMode(XdmfHeavyDataWriter::Default); int preallocatedSize = 0; int numberSetsPreallocated = 0; std::stringstream datastream; for (unsigned int i = 0; i < mTrackedArrays.size(); ++i) { preallocatedSize = mTrackedArrays[i]->getSize() * numSteps; ///* numberSetsPreallocated = 1; int adjustment = 1; while (preallocatedSize / (numSteps/adjustment) != mTrackedArrays[i]->getSize() || 0 > (int)preallocatedSize) { // XdmfError::message(XdmfError::WARNING, "Overflow error"); ++adjustment; while (numSteps % adjustment != 0) { //printf("%d / %d remainder %d\n", numSteps, adjustment, (numSteps % adjustment)); ++adjustment; } numberSetsPreallocated = numberSetsPreallocated * adjustment; preallocatedSize = mTrackedArrays[i]->getSize() * (numSteps / adjustment); //printf("%d / %d = %d ?= %d\n", preallocatedSize , (numSteps/adjustment), preallocatedSize / (numSteps/adjustment), mTrackedArrays[i]->getSize()); } // If adjusted, split one more time, to ensure that the dataset fits. if (adjustment > 1) { ++adjustment; while (numSteps % adjustment != 0) { ++adjustment; } numberSetsPreallocated = numberSetsPreallocated * adjustment; preallocatedSize = mTrackedArrays[i]->getSize() * (numSteps / adjustment); } bool allocateSucceeded = false; while (!allocateSucceeded) { try { mHeavyWriter->openFile(); //printf("now size %d allocated %d times\n", preallocatedSize, numberSetsPreallocated); for (unsigned int allocateIteration = 0; allocateIteration < numberSetsPreallocated; ++allocateIteration) { //printf("allocating subsection %u\n", allocateIteration); //*/ //printf("initializing base array\n"); tempArray->initialize(mTrackedArrays[i]->getArrayType(), preallocatedSize); //printf("writing subsection"); tempArray->accept(mHeavyWriter); //printf("subsection written\n"); // mHeavyWriter->clearCache(); ///* if (mDataControllers.size() <= i) { mDataControllers.push_back(std::vector >()); } // Clean Array for the next iteration while (tempArray->getNumberHeavyDataControllers() > 0) { mDataControllers[i].push_back(tempArray->getHeavyDataController(0)); if (mDataTypes.size() <= i) { mDataTypes.push_back(tempArray->getHeavyDataController(0)->getName()); } tempArray->removeHeavyDataController(0); } tempArray->release(); //*/ ///* //printf("moving to next allocation\n"); } mHeavyWriter->closeFile(); allocateSucceeded = true; //*/ //TODO catch the controllers created by this. ///* } catch (...) { while (tempArray->getNumberHeavyDataControllers() > 0) { tempArray->removeHeavyDataController(0); } tempArray->release(); // XdmfError::message(XdmfError::WARNING, "Array Allocation failed"); int factor = 2; while (preallocatedSize % factor != 0) { //printf("%d / %d remainder %d\n", preallocatedSize, factor, (preallocatedSize % factor)); factor = factor + 1; } //printf("adjusted factor %d\n", factor); numberSetsPreallocated = numberSetsPreallocated * factor; preallocatedSize = (preallocatedSize) / factor; //printf("now size %d allocated %d times\n", preallocatedSize, numberSetsPreallocated); } } //printf("Done writing to hdf5\n"); //*/ /* // Transfer controllers to the appropriate slot before clearing them if (mDataControllers.size() <= i) { mDataControllers.push_back(std::vector >()); } // Clean Array for the next iteration while (tempArray->getNumberHeavyDataControllers() > 0) { mDataControllers[i].push_back(tempArray->getHeavyDataController(0)); if (mDataTypes.size() <= i) { mDataTypes.push_back(tempArray->getHeavyDataController(0)->getName()); } tempArray->removeHeavyDataController(0); } tempArray->release(); */ datastream.str(std::string()); for (unsigned int controllerIndex = 0; controllerIndex < mDataControllers[i].size(); ++controllerIndex) { // TODO throw error if controller types don't match // For each heavy data controller std::string writerPath = XdmfSystemUtils::getRealPath(mHeavyWriter->getFilePath()); std::string heavyDataPath = mDataControllers[i][controllerIndex]->getFilePath(); size_t index = heavyDataPath.find_last_of("/\\"); if(index != std::string::npos) { // If path is not a folder // put the directory path into this variable const std::string heavyDataDir = heavyDataPath.substr(0, index + 1); // If the directory is in the XML File Path if(writerPath.find(heavyDataDir) == 0) { heavyDataPath = heavyDataPath.substr(heavyDataDir.size(), heavyDataPath.size() - heavyDataDir.size()); // Pull the file off of the end and place it in the DataPath } // Otherwise the full path is required } datastream << heavyDataPath; datastream << mDataControllers[i][controllerIndex]->getDescriptor(); datastream << "|"; for (unsigned int j = 0; j < mDataControllers[i][controllerIndex]->getDimensions().size(); ++j) { datastream << mDataControllers[i][controllerIndex]->getDimensions()[j]; if (j < mDataControllers[i][controllerIndex]->getDimensions().size() - 1) { datastream << " "; } } if (controllerIndex + 1 < mDataControllers[i].size()) { datastream << "|"; } } mDataDescriptions.push_back(datastream.str()); } // To end set the heavy writer to overwrite mode mHeavyWriter->setMode(XdmfHeavyDataWriter::Hyperslab); } void XdmfTemplate::removeStep(unsigned int stepId) { if (stepId < this->getNumberSteps()) { for (unsigned int i = 0; i < mTrackedArrays.size(); ++i) { if (mHeavyWriter->getMode() == XdmfHeavyDataWriter::Append || mHeavyWriter->getMode() == XdmfHeavyDataWriter::Hyperslab) { std::vector > replacementControllers = getControllersExcludingStep(stepId, mTrackedArrayDims[i], mDataControllers[i]); for (unsigned int j = 0; j < replacementControllers.size(); ++j) { if (mDataControllers[i].size() > j) { mDataControllers[i][j] = replacementControllers[j]; } else { mDataControllers[i].push_back(replacementControllers[j]); } } } else { mDataTypes.erase(mDataTypes.begin() + (stepId*mTrackedArrays.size())); mDataDescriptions.erase(mDataDescriptions.begin() + (stepId*mTrackedArrays.size())); mDataControllers.erase(mDataControllers.begin() + (stepId*mTrackedArrays.size())); } } --mNumSteps; } mCurrentStep = -1; this->setIsChanged(true); } void XdmfTemplate::setBase(shared_ptr newBase) { shared_ptr accumulator = XdmfArrayGatherer::New(&mTrackedArrays); newBase->accept(accumulator); mBase = newBase; this->setIsChanged(true); } void XdmfTemplate::setHeavyDataWriter(shared_ptr writer) { mHeavyWriter = writer; } void XdmfTemplate::setStep(unsigned int stepId) { if (stepId != mCurrentStep) { if (!mItemFactory) { mItemFactory = XdmfItemFactory::New(); } if (stepId < this->getNumberSteps()) { for (unsigned int i = 0; i < mTrackedArrays.size(); ++i) { unsigned int arrayIndex = 0; if (mHeavyWriter) { if (mHeavyWriter->getMode() == XdmfHeavyDataWriter::Append || mHeavyWriter->getMode() == XdmfHeavyDataWriter::Hyperslab) { arrayIndex = i; } else { arrayIndex = i+(stepId*mTrackedArrays.size()); } } else { arrayIndex = i+(stepId*mTrackedArrays.size()); } if (mDataControllers[arrayIndex].size() > 0) { if(mHeavyWriter) { if (mHeavyWriter->getMode() == XdmfHeavyDataWriter::Append || mHeavyWriter->getMode() == XdmfHeavyDataWriter::Hyperslab) { std::vector > insertVector = getStepControllers(stepId, mTrackedArrayDims[i], mDataControllers[i]); mTrackedArrays[i]->setHeavyDataController(insertVector); } else { mTrackedArrays[i]->setHeavyDataController(mDataControllers[i+(stepId*mTrackedArrays.size())]); } } else { mTrackedArrays[i]->setHeavyDataController(mDataControllers[i+(stepId*mTrackedArrays.size())]); } } else { std::map populateProperties; if (mHeavyWriter) { // The heavy writer provides the XMLDir, which is used to get full paths for the controllers // It is assumed that the files that the controllers reference are in the same directory // as the file that the writer references std::string filepath = XdmfSystemUtils::getRealPath(mHeavyWriter->getFilePath()); size_t index = filepath.find_last_of("/\\"); filepath = filepath.substr(0, index + 1); populateProperties["XMLDir"] = filepath; } populateProperties["Content"] = mDataDescriptions[arrayIndex]; std::vector > readControllers; if (mHeavyWriter) { if (mHeavyWriter->getMode() == XdmfHeavyDataWriter::Append || mHeavyWriter->getMode() == XdmfHeavyDataWriter::Hyperslab) { std::vector > totalControllers = mItemFactory->generateHeavyDataControllers(populateProperties, mTrackedArrayDims[i], mTrackedArrayTypes[i], mDataTypes[i+(stepId*mTrackedArrays.size())]); readControllers = getStepControllers(stepId, mTrackedArrayDims[i], totalControllers); } else { readControllers = mItemFactory->generateHeavyDataControllers(populateProperties, mTrackedArrayDims[i], mTrackedArrayTypes[i], mDataTypes[i+(stepId*mTrackedArrays.size())]); } } else { readControllers = mItemFactory->generateHeavyDataControllers(populateProperties, mTrackedArrayDims[i], mTrackedArrayTypes[i], mDataTypes[i+(stepId*mTrackedArrays.size())]); } if (readControllers.size() > 0) { // Heavy data controllers reference the data mTrackedArrays[i]->setHeavyDataController(readControllers); mDataControllers[arrayIndex] = readControllers; } else { // Data is contained in the content std::string content = mDataDescriptions[i+(stepId*mTrackedArrays.size())]; mTrackedArrays[i]->initialize(mTrackedArrayTypes[i], mTrackedArrayDims[i]); unsigned int index = 0; boost::char_separator sep(" \t\n"); boost::tokenizer > valtokens(content, sep); if(mTrackedArrayTypes[i] == XdmfArrayType::String()) { for(boost::tokenizer >::const_iterator iter = valtokens.begin(); iter != valtokens.end(); ++iter, ++index) { mTrackedArrays[i]->insert(index, *iter); } } else { for(boost::tokenizer >::const_iterator iter = valtokens.begin(); iter != valtokens.end(); ++iter, ++index) { mTrackedArrays[i]->insert(index, atof((*iter).c_str())); } } } } } } else { XdmfError::message(XdmfError::FATAL, "Error: Template attempting to load invalid step"); } mCurrentStep = stepId; } } void XdmfTemplate::trackArray(shared_ptr newArray) { bool found = false; for (unsigned int i = 0; i < mTrackedArrays.size() && !found; ++i) { if (mTrackedArrays[i] == newArray.get()) { found = true; } } if (!found) { mTrackedArrays.push_back(newArray.get()); } this->setIsChanged(true); } void XdmfTemplate::traverse(const shared_ptr visitor) { // Set to the first step when writing, as the first step is the model for the rest of the template // Will fail if there are no steps if (this->getNumberSteps() == 0) { XdmfError::message(XdmfError::FATAL, "Error: No steps in template in XdmfTemplate::traverse"); } this->clearStep(); unsigned int arraysize = 1; for (unsigned int i = 0; i < mTrackedArrayDims[0].size(); ++i) { arraysize *= mTrackedArrayDims[0][i]; } unsigned int controllersize = 0; for (unsigned int i = 0; i < mDataControllers[0].size(); ++i) { controllersize += mDataControllers[0][i]->getSize(); } XdmfHeavyDataWriter::Mode originalMode; if (mHeavyWriter) { originalMode = mHeavyWriter->getMode(); if (controllersize > arraysize) { mHeavyWriter->setMode(XdmfHeavyDataWriter::Append); } } this->setStep(0); if (mHeavyWriter) { mHeavyWriter->setMode(originalMode); } // Sending visitor to the base first so that it appears first when reading. mBase->accept(visitor); for (unsigned int i = 0; i < mTrackedArrays.size(); ++i) { mTrackedArrays[i]->release(); mTrackedArrays[i]->accept(visitor); } // Create an array to hold all of the data information strings bool originalXPath; if (shared_ptr writer = shared_dynamic_cast(visitor)) { originalXPath = writer->getWriteXPaths(); writer->setWriteXPaths(false); } shared_ptr dataInfoArray = XdmfArray::New(); dataInfoArray->setName("Data Description"); unsigned int i = 0; std::stringstream arrayInfo; while (i < mDataTypes.size()) { arrayInfo << "\"" << mDataTypes[i] << "\"" << mDataDescriptions[i]; ++i; } dataInfoArray->insert(0, arrayInfo.str().c_str(), arrayInfo.str().length()); dataInfoArray->insert(dataInfoArray->getSize(), 0); dataInfoArray->accept(visitor); if (shared_ptr writer = shared_dynamic_cast(visitor)) { writer->setWriteXPaths(originalXPath); } XdmfItem::traverse(visitor); } XDMF_ITEM_C_CHILD_WRAPPER(XdmfTemplate, XDMFTEMPLATE) xdmf-3.0+git20160803/XdmfAttributeType.cpp0000640000175000017500000001240513003006557020224 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfAttributeType.cpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #include #include "XdmfAttributeType.hpp" #include "XdmfError.hpp" std::map(*)()> XdmfAttributeType::mAttributeDefinitions; // Supported XdmfAttributeTypes shared_ptr XdmfAttributeType::NoAttributeType() { static shared_ptr p(new XdmfAttributeType("None")); return p; } shared_ptr XdmfAttributeType::Scalar() { static shared_ptr p(new XdmfAttributeType("Scalar")); return p; } shared_ptr XdmfAttributeType::Vector() { static shared_ptr p(new XdmfAttributeType("Vector")); return p; } shared_ptr XdmfAttributeType::Tensor() { static shared_ptr p(new XdmfAttributeType("Tensor")); return p; } shared_ptr XdmfAttributeType::Matrix() { static shared_ptr p(new XdmfAttributeType("Matrix")); return p; } shared_ptr XdmfAttributeType::Tensor6() { static shared_ptr p(new XdmfAttributeType("Tensor6")); return p; } shared_ptr XdmfAttributeType::GlobalId() { static shared_ptr p(new XdmfAttributeType("GlobalId")); return p; } void XdmfAttributeType::InitTypes() { mAttributeDefinitions["NONE"] = NoAttributeType; mAttributeDefinitions["SCALAR"] = Scalar; mAttributeDefinitions["VECTOR"] = Vector; mAttributeDefinitions["TENSOR"] = Tensor; mAttributeDefinitions["MATRIX"] = Matrix; mAttributeDefinitions["TENSOR6"] = Tensor6; mAttributeDefinitions["GLOBALID"] = GlobalId; } XdmfAttributeType::XdmfAttributeType(const std::string & name) : mName(name) { } XdmfAttributeType::~XdmfAttributeType() { } shared_ptr XdmfAttributeType::New(const std::map & itemProperties) { InitTypes(); std::map::const_iterator type = itemProperties.find("Type"); if(type == itemProperties.end()) { type = itemProperties.find("AttributeType"); } if(type == itemProperties.end()) { // to support old xdmf defaults, return Scalar() return Scalar(); } const std::string & typeVal = ConvertToUpper(type->second); std::map(*)()>::const_iterator returnType = mAttributeDefinitions.find(typeVal); if (returnType == mAttributeDefinitions.end()) { XdmfError::message(XdmfError::FATAL, "Type not of 'None','Scalar','Vector','Tensor', " "'Matrix','Tensor6', or 'GlobalId' in " "XdmfAttributeType::New"); } else { return (*(returnType->second))(); } // unreachable return shared_ptr(); } void XdmfAttributeType::getProperties(std::map & collectedProperties) const { collectedProperties.insert(std::make_pair("Type", mName)); } // C Wrappers int XdmfAttributeTypeScalar() { return XDMF_ATTRIBUTE_TYPE_SCALAR; } int XdmfAttributeTypeVector() { return XDMF_ATTRIBUTE_TYPE_VECTOR; } int XdmfAttributeTypeTensor() { return XDMF_ATTRIBUTE_TYPE_TENSOR; } int XdmfAttributeTypeMatrix() { return XDMF_ATTRIBUTE_TYPE_MATRIX; } int XdmfAttributeTypeTensor6() { return XDMF_ATTRIBUTE_TYPE_TENSOR6; } int XdmfAttributeTypeGlobalId() { return XDMF_ATTRIBUTE_TYPE_GLOBALID; } int XdmfAttributeTypeNoAttributeType() { return XDMF_ATTRIBUTE_TYPE_NOTYPE; } xdmf-3.0+git20160803/XdmfConfig.cmake.in0000640000175000017500000000004413003006557017523 0ustar alastairalastair# # XdmfConfig.cmake # @XDMF_VARS@ xdmf-3.0+git20160803/XdmfGridController.hpp0000640000175000017500000001455213003006557020362 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfGridController.hpp */ /* */ /* Author: */ /* Andrew Burns */ /* andrew.j.burns2@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2015 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef XDMFGRIDCONTROLLER_HPP_ #define XDMFGRIDCONTROLLER_HPP_ // C Compatible Includes #include "Xdmf.hpp" #ifdef __cplusplus // Forward Declarations class XdmfGrid; // Includes #include #include "XdmfSharedPtr.hpp" /** * @brief Couples an XdmfGrid with a grid on a different XML file. * * Serves as an method to reduce memory usage by leaving part of * the xdmf tree in file. */ class XDMF_EXPORT XdmfGridController : public virtual XdmfItem { public: /** * Creates a link to an xdmf tree in another file. * * Example of use: * * C++ * * @dontinclude ExampleXdmfGrid.cpp * @skipline //#initialization * @until //#initialization * @skipline //#setGridController * @until //#setGridController * * Python * * @dontinclude XdmfExampleGrid.py * @skipline #//initialization * @until #//initialization * @skipline #//setGridController * @until #//setGridController * * @param filePath * @param xmlPath * * @return A reference to the external xdmf tree */ static shared_ptr New(const std::string & filePath, const std::string & xmlPath); friend class XdmfWriter; friend class XdmfGrid; virtual ~XdmfGridController(); static const std::string ItemTag; /** * Gets the file path of the grid that this reference reads from. * * Example of use: * * C++ * * @dontinclude ExampleXdmfGrid.cpp * @skipline //#initialization * @until //#initialization * @skipline //#setGridController * @until //#setGridController * @skipline //#getFilePath * @until //#getFilePath * * Python * * @dontinclude XdmfExampleGrid.py * @skipline #//initialization * @until #//initialization * @skipline #//setGridController * @until #//setGridController * @skipline #//getFilePath * @until #//getFilePath * * @return The file path. */ std::string getFilePath() const; std::map getItemProperties() const; virtual std::string getItemTag() const; /** * Gets the XML path that refers to the base node in the reference file. * * Example of use: * * C++ * * @dontinclude ExampleXdmfGrid.cpp * @skipline //#initialization * @until //#initialization * @skipline //#setGridController * @until //#setGridController * @skipline //#getXMLPath * @until //#getXMLPath * * Python * * @dontinclude XdmfExampleGrid.py * @skipline #//initialization * @until #//initialization * @skipline #//setGridController * @until #//setGridController * @skipline #//getXMLPath * @until #//getXMLPath * * @return The XML path. */ std::string getXMLPath() const; /** * Reads the grid that his controller references. * * Example of use: * * C++ * * @dontinclude ExampleXdmfGrid.cpp * @skipline //#initialization * @until //#initialization * @skipline //#setGridController * @until //#setGridController * @skipline //#controllerRead * @until //#controllerRead * * Python * * @dontinclude XdmfExampleGrid.py * @skipline #//initialization * @until #//initialization * @skipline #//setGridController * @until #//setGridController * @skipline #//controllerRead * @until #//controllerRead * * @return The grid read from the controller's stored location */ virtual shared_ptr read(); XdmfGridController(const XdmfGridController&); protected: XdmfGridController(const std::string & filePath, const std::string & xmlPath); const std::string mFilePath; const std::string mXMLPath; private: // XdmfGridController(const XdmfGridController&); // Not implemented. void operator=(const XdmfGridController &); // Not implemented. }; #endif #ifdef __cplusplus extern "C" { #endif // C wrappers go here #ifndef XDMFGRIDCDEFINE #define XDMFGRIDCDEFINE struct XDMFGRID; // Simply as a typedef to ensure correct typing typedef struct XDMFGRID XDMFGRID; #endif struct XDMFGRIDCONTROLLER; // Simply as a typedef to ensure correct typing typedef struct XDMFGRIDCONTROLLER XDMFGRIDCONTROLLER; XDMF_EXPORT XDMFGRIDCONTROLLER * XdmfGridControllerNew(char * filePath, char * xmlPath); XDMF_EXPORT char * XdmfGridControllerGetFilePath(XDMFGRIDCONTROLLER * controller); XDMF_EXPORT char * XdmfGridControllerGetXMLPath(XDMFGRIDCONTROLLER * controller); XDMF_EXPORT XDMFGRID * XdmfGridControllerRead(XDMFGRIDCONTROLLER * controller); XDMF_ITEM_C_CHILD_DECLARE(XdmfGridController, XDMFGRIDCONTROLLER, XDMF) #ifdef __cplusplus } #endif #endif /* XDMFGRIDCONTROLLER_HPP_ */ xdmf-3.0+git20160803/XdmfRectilinearGrid.cpp0000640000175000017500000005712313003006557020474 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfRectilinearGrid.cpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #include #include "XdmfArray.hpp" #include "XdmfGeometry.hpp" #include "XdmfGeometryType.hpp" #include "XdmfRectilinearGrid.hpp" #include "XdmfTopology.hpp" #include "XdmfTopologyType.hpp" #include "XdmfError.hpp" /** * PIMPL */ class XdmfRectilinearGrid::XdmfRectilinearGridImpl : public XdmfGridImpl { public: class XdmfGeometryRectilinear : public XdmfGeometry { public: static shared_ptr New(XdmfRectilinearGrid * const rectilinearGrid) { shared_ptr p(new XdmfGeometryRectilinear(rectilinearGrid)); return p; } unsigned int getNumberPoints() const { const shared_ptr dimensions = mRectilinearGrid->getDimensions(); if(dimensions->getSize() == 0) { return 0; } unsigned int toReturn = 1; for(unsigned int i=0; igetSize(); ++i) { toReturn *= dimensions->getValue(i); } return toReturn; } bool isInitialized() const { return true; } void traverse(const shared_ptr visitor) { const std::vector > & coordinates = mRectilinearGrid->getCoordinates(); for (unsigned int i = 0; i < coordinates.size(); ++i) { coordinates[i]->accept(visitor); } } private: XdmfGeometryRectilinear(XdmfRectilinearGrid * const rectilinearGrid) : mRectilinearGrid(rectilinearGrid) { this->setType(XdmfGeometryTypeRectilinear::New(mRectilinearGrid)); } const XdmfRectilinearGrid * const mRectilinearGrid; }; class XdmfGeometryTypeRectilinear : public XdmfGeometryType { public: static shared_ptr New(const XdmfRectilinearGrid * const rectilinearGrid) { shared_ptr p(new XdmfGeometryTypeRectilinear(rectilinearGrid)); return p; } unsigned int getDimensions() const { return mRectilinearGrid->getDimensions()->getSize(); } void getProperties(std::map & collectedProperties) const { const unsigned int dimensions = this->getDimensions(); if(dimensions == 3) { collectedProperties["Type"] = "VXVYVZ"; } else if(dimensions == 2) { collectedProperties["Type"] = "VXVY"; } else { collectedProperties["Type"] = "VECTORED"; } } private: XdmfGeometryTypeRectilinear(const XdmfRectilinearGrid * const rectilinearGrid) : XdmfGeometryType("", 0), mRectilinearGrid(rectilinearGrid) { } const XdmfRectilinearGrid * const mRectilinearGrid; }; class XdmfTopologyRectilinear : public XdmfTopology { public: static shared_ptr New(const XdmfRectilinearGrid * const rectilinearGrid) { shared_ptr p(new XdmfTopologyRectilinear(rectilinearGrid)); return p; } bool isInitialized() const { return true; } unsigned int getNumberElements() const { const shared_ptr dimensions = mRectilinearGrid->getDimensions(); if(dimensions->getSize() == 0) { return 0; } unsigned int toReturn = 1; for(unsigned int i=0; igetSize(); ++i) { toReturn *= (dimensions->getValue(i) - 1); } return toReturn; } private: XdmfTopologyRectilinear(const XdmfRectilinearGrid * const rectilinearGrid) : mRectilinearGrid(rectilinearGrid) { this->setType(XdmfTopologyTypeRectilinear::New(rectilinearGrid)); } const XdmfRectilinearGrid * const mRectilinearGrid; }; class XdmfTopologyTypeRectilinear : public XdmfTopologyType { public: static shared_ptr New(const XdmfRectilinearGrid * const rectilinearGrid) { shared_ptr p(new XdmfTopologyTypeRectilinear(rectilinearGrid)); return p; } unsigned int getEdgesPerElement() const { return calculateHypercubeNumElements(mRectilinearGrid->getDimensions()->getSize(), 1); } unsigned int getFacesPerElement() const { return calculateHypercubeNumElements(mRectilinearGrid->getDimensions()->getSize(), 2); } unsigned int getNodesPerElement() const { return calculateHypercubeNumElements(mRectilinearGrid->getDimensions()->getSize(), 0); } void getProperties(std::map & collectedProperties) const { shared_ptr dimensions = mRectilinearGrid->getDimensions(); if(dimensions->getSize() == 3) { collectedProperties["Type"] = "3DRectMesh"; } else if(dimensions->getSize() == 2) { collectedProperties["Type"] = "2DRectMesh"; } else { collectedProperties["Type"] = "RectMesh"; } collectedProperties["Dimensions"] = dimensions->getValuesString(); } private: XdmfTopologyTypeRectilinear(const XdmfRectilinearGrid * const rectilinearGrid) : XdmfTopologyType(0, 0, std::vector >(), 0, "foo", XdmfTopologyType::Structured, 0x1101), mRectilinearGrid(rectilinearGrid) { } const XdmfRectilinearGrid * const mRectilinearGrid; }; XdmfRectilinearGridImpl(const std::vector > & coordinates) : mCoordinates(coordinates.begin(), coordinates.end()) { mGridType = "Rectilinear"; } XdmfGridImpl * duplicate() { return new XdmfRectilinearGridImpl(mCoordinates); } std::vector > mCoordinates; }; shared_ptr XdmfRectilinearGrid::New(const shared_ptr xCoordinates, const shared_ptr yCoordinates) { std::vector > axesCoordinates; axesCoordinates.resize(2); axesCoordinates[0] = xCoordinates; axesCoordinates[1] = yCoordinates; shared_ptr p(new XdmfRectilinearGrid(axesCoordinates)); return p; } shared_ptr XdmfRectilinearGrid::New(const shared_ptr xCoordinates, const shared_ptr yCoordinates, const shared_ptr zCoordinates) { std::vector > axesCoordinates; axesCoordinates.resize(3); axesCoordinates[0] = xCoordinates; axesCoordinates[1] = yCoordinates; axesCoordinates[2] = zCoordinates; shared_ptr p(new XdmfRectilinearGrid(axesCoordinates)); return p; } shared_ptr XdmfRectilinearGrid::New(const std::vector > & axesCoordinates) { shared_ptr p(new XdmfRectilinearGrid(axesCoordinates)); return p; } XdmfRectilinearGrid::XdmfRectilinearGrid(const std::vector > & axesCoordinates) : XdmfGrid(XdmfRectilinearGridImpl::XdmfGeometryRectilinear::New(this), XdmfRectilinearGridImpl::XdmfTopologyRectilinear::New(this)) { mImpl = new XdmfRectilinearGridImpl(axesCoordinates); } XdmfRectilinearGrid::XdmfRectilinearGrid(XdmfRectilinearGrid & refGrid): XdmfGrid(refGrid) { mTopology = XdmfRectilinearGridImpl::XdmfTopologyRectilinear::New(this); mGeometry = XdmfRectilinearGridImpl::XdmfGeometryRectilinear::New(this); } XdmfRectilinearGrid::~XdmfRectilinearGrid() { if (mImpl) { delete mImpl; } mImpl = NULL; } const std::string XdmfRectilinearGrid::ItemTag = "Grid"; void XdmfRectilinearGrid::copyGrid(shared_ptr sourceGrid) { XdmfGrid::copyGrid(sourceGrid); if (shared_ptr classedGrid = shared_dynamic_cast(sourceGrid)) { // Copy stucture from read grid to this grid this->setCoordinates(classedGrid->getCoordinates()); } } shared_ptr XdmfRectilinearGrid::getCoordinates(const unsigned int axisIndex) { return boost::const_pointer_cast (static_cast (*this).getCoordinates(axisIndex)); } shared_ptr XdmfRectilinearGrid::getCoordinates(const unsigned int axisIndex) const { if(axisIndex < ((XdmfRectilinearGridImpl *)mImpl)->mCoordinates.size()) { return ((XdmfRectilinearGridImpl *)mImpl)->mCoordinates[axisIndex]; } return shared_ptr(); } std::vector > XdmfRectilinearGrid::getCoordinates() { return static_cast(*this).getCoordinates(); } const std::vector > XdmfRectilinearGrid::getCoordinates() const { return ((XdmfRectilinearGridImpl *)mImpl)->mCoordinates; } shared_ptr XdmfRectilinearGrid::getDimensions() { return boost::const_pointer_cast (static_cast(*this).getDimensions()); } shared_ptr XdmfRectilinearGrid::getDimensions() const { shared_ptr dimensions = XdmfArray::New(); std::vector > heldCoordinates = ((XdmfRectilinearGridImpl*)mImpl)->mCoordinates; dimensions->reserve(heldCoordinates.size()); for (unsigned int i = 0; i < heldCoordinates.size(); ++i) { dimensions->pushBack(heldCoordinates[i]->getSize()); } return dimensions; } void XdmfRectilinearGrid::populateItem(const std::map & itemProperties, const std::vector > & childItems, const XdmfCoreReader * const reader) { XdmfGrid::populateItem(itemProperties, childItems, reader); for(std::vector >::const_iterator iter = childItems.begin(); iter != childItems.end(); ++iter) { if(shared_ptr rectilinearGrid = shared_dynamic_cast(*iter)) { if(rectilinearGrid->getGeometry()->getType()->getDimensions() > 0) { this->setCoordinates(rectilinearGrid->getCoordinates()); break; } } } } void XdmfRectilinearGrid::read() { if (mGridController) { if (shared_ptr grid = shared_dynamic_cast(mGridController->read())) { // Copy stucture from read grid to this grid copyGrid(grid); } else if (shared_ptr grid = shared_dynamic_cast(mGridController->read())) { XdmfError::message(XdmfError::FATAL, "Error: Grid Type Mismatch"); } else { XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Reference"); } } } void XdmfRectilinearGrid::release() { XdmfGrid::release(); ((XdmfRectilinearGridImpl*)mImpl)->mCoordinates.clear(); } void XdmfRectilinearGrid::setCoordinates(const unsigned int axisIndex, const shared_ptr axisCoordinates) { if(((XdmfRectilinearGridImpl *)mImpl)->mCoordinates.size() <= axisIndex) { ((XdmfRectilinearGridImpl *)mImpl)->mCoordinates.reserve(axisIndex + 1); unsigned int numArraysToInsert = axisIndex - ((XdmfRectilinearGridImpl *)mImpl)->mCoordinates.size() + 1; for(unsigned int i=0; imCoordinates.push_back(XdmfArray::New()); } } ((XdmfRectilinearGridImpl *)mImpl)->mCoordinates[axisIndex] = axisCoordinates; this->setIsChanged(true); } void XdmfRectilinearGrid::setCoordinates(const std::vector > axesCoordinates) { ((XdmfRectilinearGridImpl *)mImpl)->mCoordinates = axesCoordinates; this->setIsChanged(true); } // C Wrappers XDMFRECTILINEARGRID * XdmfRectilinearGridNew(XDMFARRAY ** axesCoordinates, unsigned int numCoordinates, int passControl) { try { std::vector > holderVector; for (unsigned int i = 0; i < numCoordinates; ++i) { if (passControl) { holderVector.push_back(shared_ptr((XdmfArray *)axesCoordinates[i])); } else { holderVector.push_back(shared_ptr((XdmfArray *)axesCoordinates[i], XdmfNullDeleter())); } } shared_ptr generatedGrid = XdmfRectilinearGrid::New(holderVector); return (XDMFRECTILINEARGRID *)((void *)((XdmfItem *)(new XdmfRectilinearGrid(*generatedGrid.get())))); } catch (...) { std::vector > holderVector; for (unsigned int i = 0; i < numCoordinates; ++i) { if (passControl) { holderVector.push_back(shared_ptr((XdmfArray *)axesCoordinates[i])); } else { holderVector.push_back(shared_ptr((XdmfArray *)axesCoordinates[i], XdmfNullDeleter())); } } shared_ptr generatedGrid = XdmfRectilinearGrid::New(holderVector); return (XDMFRECTILINEARGRID *)((void *)((XdmfItem *)(new XdmfRectilinearGrid(*generatedGrid.get())))); } } XDMFRECTILINEARGRID * XdmfRectilinearGridNew2D(XDMFARRAY * xCoordinates, XDMFARRAY * yCoordinates, int passControl) { try { if (passControl) { shared_ptr generatedGrid = XdmfRectilinearGrid::New(shared_ptr((XdmfArray *)xCoordinates), shared_ptr((XdmfArray *)yCoordinates)); return (XDMFRECTILINEARGRID *)((void *)((XdmfItem *)(new XdmfRectilinearGrid(*generatedGrid.get())))); } else { shared_ptr generatedGrid = XdmfRectilinearGrid::New(shared_ptr((XdmfArray *)xCoordinates, XdmfNullDeleter()), shared_ptr((XdmfArray *)yCoordinates, XdmfNullDeleter())); return (XDMFRECTILINEARGRID *)((void *)((XdmfItem *)(new XdmfRectilinearGrid(*generatedGrid.get())))); } } catch (...) { if (passControl) { shared_ptr generatedGrid = XdmfRectilinearGrid::New(shared_ptr((XdmfArray *)xCoordinates), shared_ptr((XdmfArray *)yCoordinates)); return (XDMFRECTILINEARGRID *)((void *)((XdmfItem *)(new XdmfRectilinearGrid(*generatedGrid.get())))); } else { shared_ptr generatedGrid = XdmfRectilinearGrid::New(shared_ptr((XdmfArray *)xCoordinates, XdmfNullDeleter()), shared_ptr((XdmfArray *)yCoordinates, XdmfNullDeleter())); return (XDMFRECTILINEARGRID *)((void *)((XdmfItem *)(new XdmfRectilinearGrid(*generatedGrid.get())))); } } } XDMFRECTILINEARGRID * XdmfRectilinearGridNew3D(XDMFARRAY * xCoordinates, XDMFARRAY * yCoordinates, XDMFARRAY * zCoordinates, int passControl) { try { if (passControl) { shared_ptr generatedGrid = XdmfRectilinearGrid::New(shared_ptr((XdmfArray *)xCoordinates), shared_ptr((XdmfArray *)yCoordinates), shared_ptr((XdmfArray *)zCoordinates)); return (XDMFRECTILINEARGRID *)((void *)((XdmfItem *)(new XdmfRectilinearGrid(*generatedGrid.get())))); } else { shared_ptr generatedGrid = XdmfRectilinearGrid::New(shared_ptr((XdmfArray *)xCoordinates, XdmfNullDeleter()), shared_ptr((XdmfArray *)yCoordinates, XdmfNullDeleter()), shared_ptr((XdmfArray *)zCoordinates, XdmfNullDeleter())); return (XDMFRECTILINEARGRID *)((void *)((XdmfItem *)(new XdmfRectilinearGrid(*generatedGrid.get())))); } } catch (...) { if (passControl) { shared_ptr generatedGrid = XdmfRectilinearGrid::New(shared_ptr((XdmfArray *)xCoordinates), shared_ptr((XdmfArray *)yCoordinates), shared_ptr((XdmfArray *)zCoordinates)); return (XDMFRECTILINEARGRID *)((void *)((XdmfItem *)(new XdmfRectilinearGrid(*generatedGrid.get())))); } else { shared_ptr generatedGrid = XdmfRectilinearGrid::New(shared_ptr((XdmfArray *)xCoordinates, XdmfNullDeleter()), shared_ptr((XdmfArray *)yCoordinates, XdmfNullDeleter()), shared_ptr((XdmfArray *)zCoordinates, XdmfNullDeleter())); return (XDMFRECTILINEARGRID *)((void *)((XdmfItem *)(new XdmfRectilinearGrid(*generatedGrid.get())))); } } } XDMFARRAY * XdmfRectilinearGridGetCoordinatesByIndex(XDMFRECTILINEARGRID * grid, unsigned int axisIndex, int * status) { XDMF_ERROR_WRAP_START(status) XdmfItem * classedPointer = (XdmfItem *)grid; XdmfRectilinearGrid * gridPointer = dynamic_cast(classedPointer); return (XDMFARRAY *)((void *)(gridPointer->getCoordinates(axisIndex).get())); XDMF_ERROR_WRAP_END(status) return NULL; } XDMFARRAY ** XdmfRectilinearGridGetCoordinates(XDMFRECTILINEARGRID * grid, int * status) { XDMF_ERROR_WRAP_START(status) try { XDMFARRAY ** returnPointer; XdmfItem * classedPointer = (XdmfItem *)grid; XdmfRectilinearGrid * gridPointer = dynamic_cast(classedPointer); std::vector > heldCoordinates = gridPointer->getCoordinates(); returnPointer = new XDMFARRAY *[heldCoordinates.size()](); for (unsigned int i = 0; i < heldCoordinates.size(); ++i) { XDMFARRAY * insertArray = (XDMFARRAY *)((void *)(new XdmfArray(*(heldCoordinates[i].get())))); returnPointer[i] = insertArray; } return returnPointer; } catch (...) { XDMFARRAY ** returnPointer; XdmfItem * classedPointer = (XdmfItem *)grid; XdmfRectilinearGrid * gridPointer = dynamic_cast(classedPointer); std::vector > heldCoordinates = gridPointer->getCoordinates(); returnPointer = new XDMFARRAY *[heldCoordinates.size()](); for (unsigned int i = 0; i < heldCoordinates.size(); ++i) { XDMFARRAY * insertArray = (XDMFARRAY *)((void *)(new XdmfArray(*(heldCoordinates[i].get())))); returnPointer[i] = insertArray; } return returnPointer; } XDMF_ERROR_WRAP_END(status) return NULL; } int XdmfRectilinearGridGetNumberCoordinates(XDMFRECTILINEARGRID * grid, int * status) { XDMF_ERROR_WRAP_START(status) XdmfItem * classedPointer = (XdmfItem *)grid; XdmfRectilinearGrid * gridPointer = dynamic_cast(classedPointer); std::vector > heldCoordinates = gridPointer->getCoordinates(); return heldCoordinates.size(); XDMF_ERROR_WRAP_END(status) return 0; } XDMFARRAY * XdmfRectilinearGridGetDimensions(XDMFRECTILINEARGRID * grid, int * status) { XDMF_ERROR_WRAP_START(status) try { XdmfArray * copyArray; shared_ptr returnDimensions; XdmfItem * classedPointer = (XdmfItem *)grid; XdmfGrid * classedGrid = dynamic_cast(classedPointer); XdmfRectilinearGrid * gridPointer = dynamic_cast(classedGrid); XDMFARRAY * returnArray; returnDimensions = gridPointer->getDimensions(); copyArray = new XdmfArray(*(returnDimensions.get())); void * copyVoid = (void *)copyArray; returnArray = (XDMFARRAY *) copyVoid; returnDimensions.reset(); return returnArray; } catch (...) { XdmfArray * copyArray; shared_ptr returnDimensions; XdmfItem * classedPointer = (XdmfItem *)grid; XdmfGrid * classedGrid = dynamic_cast(classedPointer); XdmfRectilinearGrid * gridPointer = dynamic_cast(classedGrid); XDMFARRAY * returnArray; returnDimensions = gridPointer->getDimensions(); copyArray = new XdmfArray(*(returnDimensions.get())); void * copyVoid = (void *)copyArray; returnArray = (XDMFARRAY *) copyVoid; returnDimensions.reset(); return returnArray; } XDMF_ERROR_WRAP_END(status) return NULL; } void XdmfRectilinearGridSetCoordinates(XDMFRECTILINEARGRID * grid, XDMFARRAY ** axesCoordinates, unsigned int numCoordinates, int passControl, int * status) { XDMF_ERROR_WRAP_START(status) XdmfItem * classedPointer = (XdmfItem *)grid; XdmfRectilinearGrid * gridPointer = dynamic_cast(classedPointer); std::vector > holderVector; for (unsigned int i = 0; i < numCoordinates; ++i) { if (passControl) { holderVector.push_back(shared_ptr((XdmfArray *)axesCoordinates[i])); } else { holderVector.push_back(shared_ptr((XdmfArray *)axesCoordinates[i], XdmfNullDeleter())); } } gridPointer->setCoordinates(holderVector); XDMF_ERROR_WRAP_END(status) } void XdmfRectilinearGridSetCoordinatesByIndex(XDMFRECTILINEARGRID * grid, unsigned int index, XDMFARRAY * coordinates, int passControl, int * status) { XDMF_ERROR_WRAP_START(status) XdmfItem * classedPointer = (XdmfItem *)grid; XdmfRectilinearGrid * gridPointer = dynamic_cast(classedPointer); if (passControl) { gridPointer->setCoordinates(index, shared_ptr((XdmfArray *)coordinates)); } else { gridPointer->setCoordinates(index, shared_ptr((XdmfArray *)coordinates, XdmfNullDeleter())); } XDMF_ERROR_WRAP_END(status) } XDMF_ITEM_C_CHILD_WRAPPER(XdmfRectilinearGrid, XDMFRECTILINEARGRID) XDMF_GRID_C_CHILD_WRAPPER(XdmfRectilinearGrid, XDMFRECTILINEARGRID) xdmf-3.0+git20160803/CVS/0000740000175000017500000000000013003006557014523 5ustar alastairalastairxdmf-3.0+git20160803/CVS/Repository0000640000175000017500000000000513003006557016622 0ustar alastairalastairXdmf xdmf-3.0+git20160803/CVS/Root0000640000175000017500000000006413003006557015373 0ustar alastairalastair:pserver:anonymous@public.kitware.com:/cvsroot/Xdmf xdmf-3.0+git20160803/CVS/Entries0000640000175000017500000000047513003006557016067 0ustar alastairalastair/CMakeLists.txt/1.29/Mon Apr 5 19:24:41 2010// /CTestConfig.cmake/1.3/Wed May 20 15:17:33 2009// /CTestCustom.cmake.in/1.4/Thu Jun 4 16:06:48 2009// /XDMFConfig.cmake.in/1.10/Wed Mar 24 20:03:47 2010// D/CMake//// D/Data//// D/Examples//// D/Ice//// D/Utilities//// D/binsrc//// D/libsrc//// D/python//// D/vtk//// xdmf-3.0+git20160803/XdmfGridController.cpp0000640000175000017500000001543513003006557020356 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfGridController.cpp */ /* */ /* Author: */ /* Andrew Burns */ /* andrew.j.burns2@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2015 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #include "XdmfCurvilinearGrid.hpp" #include "XdmfError.hpp" #include "XdmfGrid.hpp" #include "XdmfGridCollection.hpp" #include "XdmfGridController.hpp" #include "XdmfReader.hpp" #include "XdmfRectilinearGrid.hpp" #include "XdmfRegularGrid.hpp" #include "XdmfUnstructuredGrid.hpp" #include "string.h" #include shared_ptr XdmfGridController::New(const std::string & filePath, const std::string & xmlPath) { shared_ptr p(new XdmfGridController(filePath, xmlPath)); return p; } XdmfGridController::XdmfGridController(const std::string & filePath, const std::string & xmlPath) : mFilePath(filePath), mXMLPath(xmlPath) { } XdmfGridController::XdmfGridController(const XdmfGridController& refController): mFilePath(refController.getFilePath()), mXMLPath(refController.getXMLPath()) { } XdmfGridController::~XdmfGridController() { } const std::string XdmfGridController::ItemTag = "XGrid"; std::string XdmfGridController::getFilePath() const { return mFilePath; } std::string XdmfGridController::getItemTag() const { return ItemTag; } std::map XdmfGridController::getItemProperties() const { std::map gridProperties; gridProperties.insert(std::make_pair("File", mFilePath)); gridProperties.insert(std::make_pair("XPath", mXMLPath)); return gridProperties; } std::string XdmfGridController::getXMLPath() const { return mXMLPath; } shared_ptr XdmfGridController::read() { shared_ptr gridReader = XdmfReader::New(); return shared_dynamic_cast(gridReader->read(mFilePath, mXMLPath)[0]); } // C Wrappers XDMFGRIDCONTROLLER * XdmfGridControllerNew(char * filePath, char * xmlPath) { try { XDMFGRIDCONTROLLER * returnController = NULL; shared_ptr generatedController = XdmfGridController::New(std::string(filePath), std::string(xmlPath)); returnController = (XDMFGRIDCONTROLLER *)((void *)((XdmfItem *)(new XdmfGridController(*generatedController.get())))); generatedController.reset(); return returnController; } catch (...) { XDMFGRIDCONTROLLER * returnController = NULL; shared_ptr generatedController = XdmfGridController::New(std::string(filePath), std::string(xmlPath)); returnController = (XDMFGRIDCONTROLLER *)((void *)((XdmfItem *)(new XdmfGridController(*generatedController.get())))); generatedController.reset(); return returnController; } } char * XdmfGridControllerGetFilePath(XDMFGRIDCONTROLLER * controller) { try { XdmfGridController referenceController = *(XdmfGridController *)(controller); char * returnPointer = strdup(referenceController.getFilePath().c_str()); return returnPointer; } catch (...) { XdmfGridController referenceController = *(XdmfGridController *)(controller); char * returnPointer = strdup(referenceController.getFilePath().c_str()); return returnPointer; } } char * XdmfGridControllerGetXMLPath(XDMFGRIDCONTROLLER * controller) { try { XdmfGridController referenceController = *(XdmfGridController *)(controller); char * returnPointer = strdup(referenceController.getXMLPath().c_str()); return returnPointer; } catch (...) { XdmfGridController referenceController = *(XdmfGridController *)(controller); char * returnPointer = strdup(referenceController.getXMLPath().c_str()); return returnPointer; } } XDMFGRID * XdmfGridControllerRead(XDMFGRIDCONTROLLER * controller) { try { XdmfGridController referenceController = *(XdmfGridController *)(controller); shared_ptr returnGrid = referenceController.read(); XDMFGRID * returnPointer; if (shared_ptr curvilinearGrid = shared_dynamic_cast(returnGrid)) { returnPointer = (XDMFGRID *)((void *)((XdmfItem *)(new XdmfCurvilinearGrid(*curvilinearGrid.get())))); } else if (shared_ptr rectilinearGrid = shared_dynamic_cast(returnGrid)) { returnPointer = (XDMFGRID *)((void *)((XdmfItem *)(new XdmfRectilinearGrid(*rectilinearGrid.get())))); } else if (shared_ptr regularGrid = shared_dynamic_cast(returnGrid)) { returnPointer = (XDMFGRID *)((void *)((XdmfItem *)(new XdmfRegularGrid(*regularGrid.get())))); } else if (shared_ptr collectionGrid = shared_dynamic_cast(returnGrid)) { returnPointer = (XDMFGRID *)((void *)((XdmfItem *)(new XdmfGridCollection(*collectionGrid.get())))); } else if (shared_ptr unstructuredGrid = shared_dynamic_cast(returnGrid)) { returnPointer = (XDMFGRID *)((void *)((XdmfItem *)(new XdmfUnstructuredGrid(*unstructuredGrid.get())))); } return returnPointer; } catch (...) { } } XDMF_ITEM_C_CHILD_WRAPPER(XdmfGridController, XDMFGRIDCONTROLLER) xdmf-3.0+git20160803/XdmfUnstructuredGrid.cpp0000640000175000017500000003230313003006557020733 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfUnstructuredGrid.cpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #include "XdmfError.hpp" #include "XdmfGeometry.hpp" #include "XdmfGeometryType.hpp" #include "XdmfRegularGrid.hpp" #include "XdmfTopology.hpp" #include "XdmfTopologyType.hpp" #include "XdmfUnstructuredGrid.hpp" /** * local functions */ namespace { void convertRegularGeometry(unsigned int index, shared_ptr point, shared_ptr dimensions, shared_ptr brickSize, shared_ptr mGeometry) { const unsigned int nDim = dimensions->getValue(index); const double nBrickSize = brickSize->getValue(index); const double originalPoint = point->getValue(index); for(unsigned int i=0; iinsert(mGeometry->getSize(), point, 0, point->getSize()); } else { convertRegularGeometry(index - 1, point, dimensions, brickSize, mGeometry); } const double currPoint = point->getValue(index); point->insert(index, currPoint + nBrickSize); } point->insert(index, originalPoint); } void convertRegularTopology(shared_ptr dimensions, shared_ptr mTopology) { if(dimensions->getSize() == 2) { const unsigned int nx = dimensions->getValue(0); const unsigned int ny = dimensions->getValue(1); unsigned int offset = 0; for(unsigned int i=1; ipushBack(offset); mTopology->pushBack(offset + 1); mTopology->pushBack(offset + nx + 1); mTopology->pushBack(offset + nx); ++offset; } ++offset; } } else if(dimensions->getSize() == 3) { const unsigned int nx = dimensions->getValue(0); const unsigned int ny = dimensions->getValue(1); const unsigned int nz = dimensions->getValue(2); const unsigned int zOffset = nx * ny; unsigned int offset = 0; for(unsigned int i=1; ipushBack(offset); mTopology->pushBack(offset + 1); mTopology->pushBack(offset + nx + 1); mTopology->pushBack(offset + nx); mTopology->pushBack(offset + zOffset); mTopology->pushBack(offset + zOffset + 1); mTopology->pushBack(offset + zOffset + nx + 1); mTopology->pushBack(offset + zOffset + nx); ++offset; } ++offset; } offset += nx; } } } } class XdmfUnstructuredGrid::XdmfUnstructuredGridImpl : public XdmfGridImpl { public: XdmfUnstructuredGridImpl() { mGridType = "Unstructured"; } ~XdmfUnstructuredGridImpl() { } XdmfGridImpl * duplicate() { return new XdmfUnstructuredGridImpl(); } std::string getGridType() const { return mGridType; } }; shared_ptr XdmfUnstructuredGrid::New() { shared_ptr p(new XdmfUnstructuredGrid()); return p; } shared_ptr XdmfUnstructuredGrid::New(const shared_ptr regularGrid) { shared_ptr p(new XdmfUnstructuredGrid(regularGrid)); return p; } XdmfUnstructuredGrid::XdmfUnstructuredGrid() : XdmfGrid(XdmfGeometry::New(), XdmfTopology::New()) { mImpl = new XdmfUnstructuredGridImpl(); } XdmfUnstructuredGrid::XdmfUnstructuredGrid(const shared_ptr regularGrid) : XdmfGrid(XdmfGeometry::New(), XdmfTopology::New()) { mImpl = new XdmfUnstructuredGridImpl(); const shared_ptr origin = regularGrid->getOrigin(); shared_ptr brickSize = regularGrid->getBrickSize(); shared_ptr dimensions = regularGrid->getDimensions(); if(dimensions->getSize() != brickSize->getSize() || dimensions->getSize() != origin->getSize()) { XdmfError::message(XdmfError::FATAL, "Inconsistent brick, dimension, and origin sizes when" "converting regular grid to unstructured grid in " "XdmfUnstructuredGrid constructor"); } bool releaseOrigin = false; bool releaseBrickSize = false; bool releaseDimensions = false; if(!origin->isInitialized()) { origin->read(); releaseOrigin = true; } if(!brickSize->isInitialized()) { brickSize->read(); releaseBrickSize = true; } if(!dimensions->isInitialized()) { dimensions->read(); releaseDimensions = true; } shared_ptr geometryType; shared_ptr topologyType; if(origin->getSize() == 2) { geometryType = XdmfGeometryType::XY(); topologyType = XdmfTopologyType::Quadrilateral(); } else if(origin->getSize() == 3) { geometryType = XdmfGeometryType::XYZ(); topologyType = XdmfTopologyType::Hexahedron(); } else { XdmfError::message(XdmfError::FATAL, "Cannot convert regular grid of dimensions not 2 or 3 " "to XdmfUnstructuredGrid in XdmfUnstructuredGrid " "constructor"); } mGeometry->setType(geometryType); mTopology->setType(topologyType); shared_ptr point = XdmfArray::New(); point->insert(0, origin, 0, origin->getSize()); convertRegularGeometry(dimensions->getSize() - 1, point, dimensions, brickSize, mGeometry); convertRegularTopology(dimensions, mTopology); if(releaseOrigin) { origin->release(); } if(releaseBrickSize) { brickSize->release(); } if(releaseDimensions) { dimensions->release(); } } XdmfUnstructuredGrid::XdmfUnstructuredGrid(XdmfUnstructuredGrid & refGrid) : XdmfGrid(refGrid) { } XdmfUnstructuredGrid::~XdmfUnstructuredGrid() { if (mImpl) { delete mImpl; } mImpl = NULL; } const std::string XdmfUnstructuredGrid::ItemTag = "Grid"; void XdmfUnstructuredGrid::copyGrid(shared_ptr sourceGrid) { XdmfGrid::copyGrid(sourceGrid); if (shared_ptr classedGrid = shared_dynamic_cast(sourceGrid)) { this->setGeometry(classedGrid->getGeometry()); this->setTopology(classedGrid->getTopology()); } } shared_ptr XdmfUnstructuredGrid::getGeometry() { return boost::const_pointer_cast (static_cast(*this).getGeometry()); } std::string XdmfUnstructuredGrid::getItemTag() const { return ItemTag; } shared_ptr XdmfUnstructuredGrid::getTopology() { return boost::const_pointer_cast (static_cast(*this).getTopology()); } void XdmfUnstructuredGrid::read() { if (mGridController) { if (shared_ptr grid = shared_dynamic_cast(mGridController->read())) { copyGrid(grid); } else if (shared_ptr grid = shared_dynamic_cast(mGridController->read())) { XdmfError::message(XdmfError::FATAL, "Error: Grid Type Mismatch"); } else { XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Reference"); } } } void XdmfUnstructuredGrid::release() { XdmfGrid::release(); this->setGeometry(shared_ptr()); this->setTopology(shared_ptr()); } void XdmfUnstructuredGrid::setGeometry(const shared_ptr geometry) { mGeometry = geometry; } void XdmfUnstructuredGrid::setTopology(const shared_ptr topology) { mTopology = topology; } // C Wrappers XDMFUNSTRUCTUREDGRID * XdmfUnstructuredGridNew() { try { shared_ptr generatedGrid = XdmfUnstructuredGrid::New(); return (XDMFUNSTRUCTUREDGRID *)((void *)((XdmfItem *)(new XdmfUnstructuredGrid(*generatedGrid.get())))); } catch (...) { shared_ptr generatedGrid = XdmfUnstructuredGrid::New(); return (XDMFUNSTRUCTUREDGRID *)((void *)((XdmfItem *)(new XdmfUnstructuredGrid(*generatedGrid.get())))); } } XDMFUNSTRUCTUREDGRID * XdmfUnstructuredGridNewFromRegularGrid(XDMFREGULARGRID * regularGrid, int * status) { XDMF_ERROR_WRAP_START(status) try { // Here it works when classed directly to the grid type, // in other cases this may not work. XdmfItem * tempPointer = (XdmfItem *)regularGrid; XdmfRegularGrid * classedPointer = dynamic_cast(tempPointer); shared_ptr originGrid = shared_ptr(classedPointer, XdmfNullDeleter()); shared_ptr generatedGrid = XdmfUnstructuredGrid::New(originGrid); return (XDMFUNSTRUCTUREDGRID *)((void *)((XdmfItem *)(new XdmfUnstructuredGrid(*generatedGrid.get())))); } catch (...) { // Here it works when classed directly to the grid type, // in other cases this may not work. XdmfItem * tempPointer = (XdmfItem *)regularGrid; XdmfRegularGrid * classedPointer = dynamic_cast(tempPointer); shared_ptr originGrid = shared_ptr(classedPointer, XdmfNullDeleter()); shared_ptr generatedGrid = XdmfUnstructuredGrid::New(originGrid); return (XDMFUNSTRUCTUREDGRID *)((void *)((XdmfItem *)(new XdmfUnstructuredGrid(*generatedGrid.get())))); } XDMF_ERROR_WRAP_END(status) return NULL; } XDMFGEOMETRY * XdmfUnstructuredGridGetGeometry(XDMFUNSTRUCTUREDGRID * grid) { XdmfItem * tempPointer = (XdmfItem *)grid; XdmfUnstructuredGrid * classedPointer = dynamic_cast(tempPointer); return (XDMFGEOMETRY *)((void *)(classedPointer->getGeometry().get())); } XDMFTOPOLOGY * XdmfUnstructuredGridGetTopology(XDMFUNSTRUCTUREDGRID * grid) { XdmfItem * tempPointer = (XdmfItem *)grid; XdmfUnstructuredGrid * classedPointer = dynamic_cast(tempPointer); return (XDMFTOPOLOGY *)((void *)(classedPointer->getTopology().get())); } void XdmfUnstructuredGridSetGeometry(XDMFUNSTRUCTUREDGRID * grid, XDMFGEOMETRY * geometry, int passControl) { XdmfItem * tempPointer = (XdmfItem *)grid; XdmfUnstructuredGrid * classedPointer = dynamic_cast(tempPointer); if (passControl) { classedPointer->setGeometry(shared_ptr((XdmfGeometry *)geometry)); } else { classedPointer->setGeometry(shared_ptr((XdmfGeometry *)geometry, XdmfNullDeleter())); } } void XdmfUnstructuredGridSetTopology(XDMFUNSTRUCTUREDGRID * grid, XDMFTOPOLOGY * topology, int passControl) { XdmfItem * tempPointer = (XdmfItem *)grid; XdmfUnstructuredGrid * classedPointer = dynamic_cast(tempPointer); if (passControl) { classedPointer->setTopology(shared_ptr((XdmfTopology *)topology)); } else { classedPointer->setTopology(shared_ptr((XdmfTopology *)topology, XdmfNullDeleter())); } } XDMF_ITEM_C_CHILD_WRAPPER(XdmfUnstructuredGrid, XDMFUNSTRUCTUREDGRID) XDMF_GRID_C_CHILD_WRAPPER(XdmfUnstructuredGrid, XDMFUNSTRUCTUREDGRID) xdmf-3.0+git20160803/XdmfGeometryType.hpp0000640000175000017500000001350213003006557020060 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfGeometryType.hpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef XDMFGEOMETRYTYPE_HPP_ #define XDMFGEOMETRYTYPE_HPP_ // C Compatible Includes #include "Xdmf.hpp" #ifdef __cplusplus // Includes #include "XdmfItemProperty.hpp" #include /** * @brief Property describing the types of coordinate values stored in * an XdmfGeometry. * * XdmfGeometryType is a property used by XdmfGeometry to specify the * type of coordinate values stored in the XdmfGeometry. A specific * XdmfGeometryType can be created by calling one of the static * methods in the class, i.e. XdmfAttributeType::XYZ(). * * Example of use: * * C++ * * @dontinclude ExampleXdmfGeometryType.cpp * @skipline //#initialization * @until //#initialization * @skipline //#getType * @until //#getType * * Python * * @dontinclude XdmfExampleGeometryType.py * @skipline #//getType * @until #//getType * * Xdmf supports the following geometry types: * NoGeometryType * XYZ * XY * Polar * Spherical * * The Polar and Spherical types consist of a series of coordinates. * These coordinates are in order of: radius, polar, azimuthal. * In accordance with the ISO standard. * */ class XDMF_EXPORT XdmfGeometryType : public XdmfItemProperty { public: virtual ~XdmfGeometryType(); friend class XdmfGeometry; // Supported Xdmf Geometry Types static shared_ptr NoGeometryType(); static shared_ptr XYZ(); static shared_ptr XY(); static shared_ptr Polar(); static shared_ptr Spherical(); /** * Get the dimensions of this geometry type - i.e. XYZ = 3. * * Example of use: * * C++ * * @dontinclude ExampleXdmfGeometryType.cpp * @skipline //#getDimensions * @until //#getDimensions * * Python * * @dontinclude XdmfExampleGeometryType.py * @skipline #//getDimensions * @until #//getDimensions * * @return An int containing number of dimensions. */ virtual unsigned int getDimensions() const; /** * Get the name of this geometry type. * * Example of use: * * C++ * * @dontinclude ExampleXdmfGeometryType.cpp * @skipline //#getName * @until //#getName * * Python * * @dontinclude XdmfExampleGeometryType.py * @skipline #//getName * @until #//getName * * @return The name of this geometry type. */ std::string getName() const; virtual void getProperties(std::map & collectedProperties) const; protected: /** * Protected constructor for XdmfGeometryType. The constructor is * protected because all geometry types supported by Xdmf should be * accessed through more specific static methods that construct * XdmfGeometryTypes - i.e. XdmfGeometryType::XYZ(). * * @param name a std::string containing the name of the geometry type.. * @param dimensions an int containing the dimensions of the geometry type. */ XdmfGeometryType(const std::string & name, const int & dimensions); static std::map(*)()> mGeometryDefinitions; static void InitTypes(); private: XdmfGeometryType(const XdmfGeometryType &); // Not implemented. void operator=(const XdmfGeometryType &); // Not implemented. static shared_ptr New(const std::map & itemProperties); unsigned int mDimensions; std::string mName; }; #endif #ifdef __cplusplus extern "C" { #endif // C wrappers go here #define XDMF_GEOMETRY_TYPE_NO_GEOMETRY_TYPE 300 #define XDMF_GEOMETRY_TYPE_XYZ 301 #define XDMF_GEOMETRY_TYPE_XY 302 #define XDMF_GEOMETRY_TYPE_POLAR 303 #define XDMF_GEOMETRY_TYPE_SPHERICAL 304 XDMF_EXPORT int XdmfGeometryTypeNoGeometryType(); XDMF_EXPORT int XdmfGeometryTypeXYZ(); XDMF_EXPORT int XdmfGeometryTypeXY(); XDMF_EXPORT int XdmfGeometryTypePolar(); XDMF_EXPORT int XdmfGeometryTypeSpherical(); XDMF_EXPORT unsigned int XdmfGeometryTypeGetDimensions(int type, int * status); XDMF_EXPORT char * XdmfGeometryTypeGetName(int type); #ifdef __cplusplus } #endif #endif /* XDMFGEOMETRYTYPE_HPP_ */ xdmf-3.0+git20160803/CMakeLists.txt0000640000175000017500000003520113003006557016633 0ustar alastairalastairproject(Xdmf) cmake_minimum_required(VERSION 2.6) #Needed to build DSM because relative paths are used to add its libraries if (POLICY CMP0015) cmake_policy(SET CMP0015 NEW) endif () if(MSVC10) SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}) SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}) SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}) endif() set(XDMF_LIBNAME "Xdmf" CACHE STRING "Name for this xdmf library to avoid collision") option(BUILD_SHARED_LIBS "Build Shared Libraries" OFF) if(BUILD_SHARED_LIBS) set(LIBTYPE SHARED) set(BUILD_SHARED 1) else() set(LIBTYPE STATIC) endif() configure_file(${CMAKE_CURRENT_SOURCE_DIR}/XdmfConfig.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/XdmfConfig.hpp) if (WIN32) set(XDMF_STATIC_AND_SHARED OFF) else() option(XDMF_STATIC_AND_SHARED "Build both static and shared libraries" ON) mark_as_advanced(FORCE XDMF_STATIC_AND_SHARED) endif() # Enable CMake testing option(XDMF_BUILD_TESTING "Build Tests" OFF) if(XDMF_BUILD_TESTING) enable_testing() include(CTest) endif() if (XDMF_STATIC_AND_SHARED) add_definitions(-DXDMFSTATIC) endif () include_directories(${CMAKE_CURRENT_SOURCE_DIR}) include_directories(${CMAKE_CURRENT_BINARY_DIR}) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/CMake ${CMAKE_CURRENT_SOURCE_DIR}/CMake/VersionSuite) if(XDMF_BUILD_TESTING) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/CMake/TestingSuite) endif() include(XdmfFunctions) # Converting Install Prefix to an absolute path get_filename_component(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" ABSOLUTE) # RPath #set(CMAKE_SKIP_BUILD_RPATH FALSE) #set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) #set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib) #set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) # Should we build with documentation option(XDMF_BUILD_DOCUMENTATION OFF) if(XDMF_BUILD_DOCUMENTATION) add_subdirectory(doc) endif() # Wrapper Setup option(XDMF_WRAP_PYTHON OFF) option(XDMF_WRAP_JAVA OFF) #check for TIFF find_package(TIFF) if (TIFF_FOUND) add_definitions(-DXDMF_BUILD_TIFF) mark_as_advanced(FORCE TIFF_INCLUDE_DIR) mark_as_advanced(FORCE TIFF_LIBRARIES) mark_as_advanced(FORCE TIFF_LIBRARY) include_directories(${TIFF_INCLUDE_DIR}) get_filename_component(TIFF_LIBRARY_DIR "${TIFF_LIBRARY}" PATH) set(XDMF_LIBRARY_DIRS ${XDMF_LIBRARY_DIRS} ${TIFF_LIBRARY_DIR}) set(XDMF_LIBRARIES ${XDMF_LIBRARIES} ${TIFF_LIBRARIES}) endif (TIFF_FOUND) # Test for DSM option(XDMF_BUILD_DSM OFF) mark_as_advanced(XDMF_BUILD_DSM) if(XDMF_BUILD_DSM) find_package(MPI REQUIRED) if(MPI_FOUND) include_directories(${MPI_INCLUDE_PATH}) set(XDMF_LIBRARIES ${XDMF_LIBRARIES} ${MPI_LIBRARY} ${MPI_EXTRA_LIBRARY}) get_filename_component(MPI_LIBRARY_DIR ${MPI_LIBRARY} PATH) set(XDMF_LIBRARY_DIRS ${XDMF_LIBRARY_DIRS} ${MPI_LIBRARY_DIR}) # intel compiler requires an extra tag for CXX_FLAGS in order to properly build STRING(REGEX MATCH "icpc" IS_INTEL "${CMAKE_CXX_COMPILER}") if (NOT "${IS_INTEL}" STREQUAL "") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMPICH_IGNORE_CXX_SEEK") endif () endif() option(XDMF_BUILD_DSM_THREADS ON) if (XDMF_WRAP_PYTHON) mark_as_advanced(FORCE PYTHON_INCLUDE_MPI4PY_DIR) set(PYTHON_INCLUDE_MPI4PY_DIR "" CACHE STRING "Directory containing mpi4py/mpi4py.i") endif () add_definitions(-DXDMF_BUILD_DSM) endif() # If we are wrapping either, we need swig if(XDMF_WRAP_PYTHON OR XDMF_WRAP_JAVA) find_package(SWIG REQUIRED) include(${SWIG_USE_FILE}) if(${SWIG_VERSION} LESS 2.0.0) message(SEND_ERROR "Swig must be version 2.0.0 or greater") endif() endif() # If we are wrapping python, let's include it in the top level if(XDMF_WRAP_PYTHON) find_package(PythonInterp ${REQUESTED_PYTHON_VERSION} REQUIRED) find_package(PythonLibs ${REQUESTED_PYTHON_VERSION} REQUIRED) if (XDMF_BUILD_DSM) find_package (MPI4PY REQUIRED) if (MPI4PY_FOUND) if ("${PYTHON_INCLUDE_MPI4PY_DIR}" STREQUAL "") set(PYTHON_INCLUDE_MPI4PY_DIR ${MPI4PY_INCLUDE_DIR}) endif () endif () include_directories(${PYTHON_INCLUDE_DIRS} ${MPI_CXX_INCLUDE_PATH} ${PYTHON_INCLUDE_MPI4PY_DIR}) else () include_directories(${PYTHON_INCLUDE_DIRS}) endif () # A macro to swig and create the python files # Since we essentually do the same thing inside and outside core, it # would be easier as a macro # Parameters: # python_name = the name of the intended target to be wrapped # ${ARGN} = any dependencies needed by the target # Output: # Target Name = the output target name will have ${python_name} as its name macro(XDMF_SWIG_PYTHON python_name) set(CMAKE_SWIG_OUTDIR ${CMAKE_BINARY_DIR}) # optimize swig generation --- these are all flags corresponding to -O # except -fvirtual which breaks visitor operation set(CMAKE_SWIG_FLAGS ${XDMF_SWIG_FLAGS} -modern -fastdispatch -nosafecstrings -noproxydel -fastproxy -fastinit -fastunpack -fastquery -modernargs -nobuildnone) #Enables DSM if (XDMF_BUILD_DSM) set(CMAKE_SWIG_FLAGS ${CMAKE_SWIG_FLAGS} -DXDMF_BUILD_DSM) if (XDMF_BUILD_DSM_THREADS) set(CMAKE_SWIG_FLAGS ${CMAKE_SWIG_FLAGS} -DXDMF_BUILD_DSM_THREADS) endif () endif () set_source_files_properties(${python_name}.i PROPERTIES CPLUSPLUS ON) set(swig_extra_generated_files "") swig_add_module(${python_name}Python python ${python_name}.i) swig_link_libraries(${python_name}Python ${python_name} ${PYTHON_LIBRARIES}) set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_CURRENT_BINARY_DIR}/${python_name}.pyc ) if("${ARGN}" STRGREATER "") add_dependencies(${python_name} "${ARGN}") endif() if(WIN32) if(NOT MSVC10) set_target_properties(${SWIG_MODULE_${python_name}Python_REAL_NAME} PROPERTIES PREFIX ../ IMPORT_PREFIX ../ RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) endif() endif() set_target_properties(${SWIG_MODULE_${python_name}Python_REAL_NAME} PROPERTIES OUTPUT_NAME "_${python_name}") string(TOUPPER ${python_name} python_name_upper) set(${python_name_upper}_PYTHON ${CMAKE_INSTALL_PREFIX}/lib/python/${python_name}.py) get_directory_property(${python_name}Parent PARENT_DIRECTORY) if(NOT "${${python_name}Parent}" STREQUAL "") set(${python_name_upper}_PYTHON ${${python_name_upper}_PYTHON} PARENT_SCOPE) endif() install(FILES ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${python_name}.py DESTINATION lib/python) install(TARGETS ${SWIG_MODULE_${python_name}Python_REAL_NAME} DESTINATION lib/python) endmacro() endif() # If we are wrapping java, let's include it in the top level if(XDMF_WRAP_JAVA) find_package(Java REQUIRED) find_package(JNI REQUIRED) include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2}) # A macro to swig and create the jar files # Since we essentually do the same thing inside and outside core, it # would be easier as a macro # Parameters: # java_name = the name of the intended target to be wrapped # ${ARGN} = any dependencies needed by the target # Output: # Target Name = the output target name will have ${java_name}Java as its name # Target Jar = the output target jar will have ${java_name}Java.jar as its name macro(XDMF_SWIG_JAVA java_name) set(${java_name}_JAVA_JAR ${CMAKE_BINARY_DIR}/${java_name}.jar) set(XDMF_JAVA_PACKAGE_DIR mil/army/arl/xdmf) set(XDMF_JAVA_DIR ${CMAKE_BINARY_DIR}/${XDMF_JAVA_PACKAGE_DIR}) set(CMAKE_SWIG_OUTDIR ${XDMF_JAVA_DIR}) set(CMAKE_SWIG_FLAGS ${XDMF_SWIG_FLAGS} -v -make_default -package mil.army.arl.xdmf) set_source_files_properties(${java_name}.i PROPERTIES CPLUSPLUS ON) set(swig_extra_generated_files "") swig_add_module(${java_name}Java java ${java_name}.i) swig_link_libraries(${java_name}Java ${java_name}) if(WIN32) if(NOT MSVC10) set_target_properties(${SWIG_MODULE_${java_name}Java_REAL_NAME} PROPERTIES PREFIX ../ IMPORT_PREFIX ../ RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) endif() set(java_files *.java) set(java_dest "bin") set(separator "\;") else() set(java_files ${XDMF_JAVA_DIR}/*.java) set(java_dest "lib/java") set(separator ":") endif() add_custom_target(${java_name}_Java_Dir ALL DEPENDS ${XDMF_JAVA_DIR}) add_custom_command(OUTPUT ${XDMF_JAVA_DIR} COMMAND ${CMAKE_COMMAND} -E make_directory ${XDMF_JAVA_DIR}) add_custom_target(Compiled_${java_name}_Jar ALL DEPENDS ${${java_name}_JAVA_JAR}) add_custom_command(OUTPUT ${${java_name}_JAVA_JAR} COMMAND ${CMAKE_COMMAND} -E chdir ${XDMF_JAVA_PACKAGE_DIR} ${JAVA_COMPILE} -cp \".${java_cp_jars}\" ${java_files} COMMAND ${JAVA_ARCHIVE} -cvf ${${java_name}_JAVA_JAR} "${XDMF_JAVA_PACKAGE_DIR}/*.class") add_dependencies(${java_name}Java ${java_name}_Java_Dir) add_dependencies(Compiled_${java_name}_Jar ${java_name}Java) if(NOT ${ARGN} EQUAL "") add_dependencies(Compiled_${java_name}_Jar "${ARGN}") endif() set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_CURRENT_BINARY_DIR}/${java_name}.jar ${XDMF_JAVA_DIR}) set(java_cp_jars "${java_cp_jars}${separator}${${java_name}_JAVA_JAR}") string(TOUPPER ${java_name} java_name_upper) set(${java_name_upper}_JAVA_JAR ${CMAKE_INSTALL_PREFIX}/lib/java/${java_name}.jar) get_directory_property(${java_name}Parent PARENT_DIRECTORY) if(NOT "${${java_name}Parent}" STREQUAL "") set(${java_name_upper}_JAVA_JAR ${${java_name_upper}_JAVA_JAR} PARENT_SCOPE) set(java_cp_jars "${java_cp_jars}" PARENT_SCOPE) endif() install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${java_name}.jar DESTINATION lib/java) install(TARGETS ${SWIG_MODULE_${java_name}Java_REAL_NAME} DESTINATION ${java_dest}) endmacro() endif() add_subdirectory(core) include_directories(${XdmfCore_INCLUDE_DIRS} ${XdmfDSM_INCLUDE_DIRS}) link_directories(${XDMF_LIBRARY_DIRS}) option(XDMF_BUILD_CORE_ONLY OFF) if(NOT XDMF_BUILD_CORE_ONLY) set(XdmfSources XdmfAggregate XdmfAttribute XdmfAttributeCenter XdmfAttributeType XdmfCurvilinearGrid XdmfDomain XdmfGeometry XdmfGeometryType XdmfGraph XdmfGrid XdmfGridCollection XdmfGridCollectionType XdmfGridController XdmfGridTemplate XdmfItemFactory XdmfMap XdmfReader XdmfRectilinearGrid XdmfRegularGrid XdmfSet XdmfSetType XdmfTemplate XdmfTime XdmfTopology XdmfTopologyType XdmfUnstructuredGrid) if(XDMF_STATIC_AND_SHARED) add_library(XdmfObjects OBJECT ${XdmfSources}) set_target_properties(XdmfObjects PROPERTIES POSITION_INDEPENDENT_CODE True) add_library(${XDMF_LIBNAME} $) if (BUILD_SHARED_LIBS) add_library(Xdmf_Static STATIC $) set_target_properties(Xdmf_Static PROPERTIES OUTPUT_NAME "Xdmf") endif (BUILD_SHARED_LIBS) else() add_library(${XDMF_LIBNAME} ${LIBTYPE} ${XdmfSources}) endif() if(XDMF_BUILD_DSM) target_link_libraries(${XDMF_LIBNAME} XdmfCore XdmfDSM) if(XDMF_STATIC_AND_SHARED AND BUILD_SHARED_LIBS) target_link_libraries(Xdmf_Static XdmfCore_Static XdmfDSM_Static) endif() else(XDMF_BUILD_DSM) target_link_libraries(${XDMF_LIBNAME} XdmfCore) if(XDMF_STATIC_AND_SHARED AND BUILD_SHARED_LIBS) target_link_libraries(Xdmf_Static XdmfCore_Static) endif () endif(XDMF_BUILD_DSM) if (COMMAND vtk_target_install) vtk_target_install(${XDMF_LIBNAME}) endif() if(WIN32) if (BUILD_SHARED_LIBS) set_target_properties(${XDMF_LIBNAME} PROPERTIES DEFINE_SYMBOL XDMF_EXPORTS) if(XDMF_STATIC_AND_SHARED) set_target_properties(Xdmf_Static PROPERTIES DEFINE_SYMBOL Xdmf_EXPORTS) endif() endif () if(NOT MSVC10) set_target_properties(${XDMF_LIBNAME} PROPERTIES PREFIX ../ IMPORT_PREFIX ../ RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) if(XDMF_STATIC_AND_SHARED AND BUILD_SHARED_LIBS) set_target_properties(Xdmf_Static PROPERTIES PREFIX ../ IMPORT_PREFIX ../ RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) endif () endif() endif() if(XDMF_WRAP_JAVA) XDMF_SWIG_JAVA(${XDMF_LIBNAME} Compiled_XdmfCore_Jar) endif() if(XDMF_WRAP_PYTHON) if (NOT BUILD_SHARED_LIBS) message(FATAL_ERROR "Python Wrappers do not function" " properly without shared libraries") endif (NOT BUILD_SHARED_LIBS) if (XDMF_BUILD_DSM) XDMF_SWIG_PYTHON(${XDMF_LIBNAME} XdmfCore XdmfDSM) else() XDMF_SWIG_PYTHON(${XDMF_LIBNAME} XdmfCore) endif() set(XDMF_PYTHON_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib/python/) endif() if(XDMF_BUILD_TESTING) add_subdirectory(tests) endif() option(XDMF_BUILD_UTILS OFF) if(XDMF_BUILD_UTILS) add_subdirectory(utils) endif() if(WIN32) set(XDMF_LIBRARY ${CMAKE_INSTALL_PREFIX}/lib/${XDMF_LIBNAME}.lib) endif() if(UNIX) if (BUILD_SHARED_LIBS) set(XDMF_LIBRARY ${CMAKE_INSTALL_PREFIX}/lib/lib${XDMF_LIBNAME}.so) else (BUILD_SHARED_LIBS) set(XDMF_LIBRARY ${CMAKE_INSTALL_PREFIX}/lib/lib${XDMF_LIBNAME}.a) endif (BUILD_SHARED_LIBS) endif(UNIX) if(APPLE) set(XDMF_LIBRARY ${CMAKE_INSTALL_PREFIX}/lib/lib${XDMF_LIBNAME}.dylib) endif() file(GLOB XdmfHeaders "*.hpp" "*.tpp" "*.i" "CMake/VersionSuite/*.hpp" "${CMAKE_CURRENT_BINARY_DIR}/*.hpp" ) install(FILES ${XdmfHeaders} DESTINATION include) install(TARGETS ${XDMF_LIBNAME} RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) if (XDMF_STATIC_AND_SHARED AND BUILD_SHARED_LIBS) install(TARGETS Xdmf_Static RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) endif() endif() xdmf_create_config_file(${PROJECT_NAME}) install(FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" DESTINATION ${CMAKE_INSTALL_PREFIX}) xdmf-3.0+git20160803/Xdmf.hpp0000640000175000017500000001607613003006557015513 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : Xdmf.hpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef _XDMF_HPP #define _XDMF_HPP /*! \mainpage XDMF API * * \section intro Introduction * * The eXtensible Data Model and Format (XDMF) is a distributed data * hub for accessing scientific data in High Performance Computing * (HPC) applications. XDMF defines a data model and format as well as * facilities for accessing the data in a distributed environment. * * XDMF differs from other data model and format efforts in that the * "light data" is logically (and possibly physically) separated from * the "heavy data". Light data is considered to be both "data about * the data" such as dimensions and name, as well as small quantities * of computed data. Heavy data is considered to be large amounts of * data. For example, in a three dimensional structural mechanics * calculation, the size and dimensions of the computational grid are * light data while the actual X, Y, and Z values for the grid are * heavy data. Calculated values like "Pressure at a node" are heavy, * while "Total Residual Mass" for the entire calculation is light. * Light data is stored on disk in a machine parsable language like * XML. Heavy data is stored in a format suitable for large amounts of * data like HDF5. * * While use of the XDMF API is not necessary to produce or consume * valid datasets, it is extremely useful for handling the wide variety * of files that are possible and its use is highly recommended. The * XDMF API is written in C++ and is wrapped for access from other * languages including Python and Java. * * XDMF utilizes reference counting shared pointers to handle ownership * of XDMF objects. This allows multiple objects to reference a single * XDMF object. An object is deleted and memory is reclaimed when no * other XDMF objects hold a reference to the object. This allows * flexibility in constructing XDMF structures, as simple structures * can be shared instead of copied. * * All XDMF objects are constructed by calling New(), which returns a * shared pointer to a newly constructed object. All default * constructors in the XDMF API are protected, ensuring that only * shared pointers can be created. These pointers are freed * automatically by the shared pointer reference counting mechanism. * * * Structure: * * Xdmf2 is structured in a tree format with an XdmfDomain serving * as the base. The Domain contains multiple grid collections or * grids; each with their own geometries, topologies, attributes, * and/or sets. With the inclusion of shared pointers in Xdmf2 * a topology could be shared across multiple grids or a grid * could be included in multiple grid collections and/or the domain. * * Comparing objects is done by comparing pointer addresses, * a deep copy will not produce an equivalent object. * * * C++ Examples: * * \subpage cppwrite "C++ Example of Xdmf Creation" * * \subpage cppread "C++ Example of Reading Xdmf" * * \subpage cppedit "C++ Example of Reading and Modifying Xdmf" * * Python Examples: * * \subpage pywrite "Python Example of Xdmf Creation" * * \subpage pyread "Python Example of Reading Xdmf" * * \subpage pyedit "Python Example of Reading and Modifying Xdmf" * */ /*! * \page cppwrite Example of Xdmf Creation * \include ExampleXdmfWrite.cpp */ /*! * \page cppread Example of Reading Xdmf * \include ExampleXdmfRead.cpp */ /*! * \page cppedit Example of Reading and Modifying * \include ExampleXdmfEdit.cpp */ /*! * \page pywrite Example of Xdmf Creation * \include XdmfExampleWrite.py */ /*! * \page pyread Example of Reading Xdmf * \include XdmfExampleRead.py */ /*! * \page pyedit Example of Reading and Modifying * \include XdmfExampleEdit.py */ #include "XdmfConfig.hpp" /* Keep all our Win32 Conversions here */ #ifdef _WIN32 #ifdef XDMFSTATIC # define XDMFCORE_EXPORT # define XDMFDSM_EXPORT # define XDMF_EXPORT # define XDMFCORE_TEMPLATE # define XDMFDSM_TEMPLATE # define XDMF_TEMPLATE #else /* Used to export/import from the dlls */ # undef XDMFCORE_EXPORT # define XDMFCORE_EXPORT __declspec(dllimport) # undef XDMFCORE_TEMPLATE # define XDMFCORE_TEMPLATE extern # undef XDMFDSM_EXPORT # define XDMFDSM_EXPORT __declspec(dllimport) # undef XDMFDSM_TEMPLATE # define XDMFDSM_TEMPLATE extern # ifdef XDMF_EXPORTS # define XDMF_EXPORT __declspec(dllexport) # define XDMF_TEMPLATE # else /* XDMF_EXPORTS */ # define XDMF_EXPORT __declspec(dllimport) # define XDMF_TEMPLATE extern # endif /* XDMF_EXPORTS */ #endif /* Compiler Warnings */ #ifndef XDMF_DEBUG #pragma warning( disable : 4231 ) /* nonstandard extension used : 'extern' before template explicit instantiation */ #pragma warning( disable : 4251 ) /* needs to have dll-interface to be used by clients (Most of these guys are in private */ #pragma warning( disable : 4275 ) /* non dll-interface class 'std::_Container_base_aux' used as base for dll-interface class */ #pragma warning( disable : 4373 ) /* virtual function overrides, parameters only differed by const/volatile qualifiers */ #pragma warning( disable : 4748 ) /* /GS can not protect parameters and local variables from local buffer overrun (turned off op)*/ #endif /* XDMF_DEBUG */ /* Compiler Optimizations will result in an 'internal compiler error', so turn them off */ #pragma optimize("g", off) #else /* _WIN32 */ /* We don't need to export/import since there are no dlls */ #define XDMFCORE_EXPORT #define XDMFDSM_EXPORT #define XDMF_EXPORT #define XDMFCORE_TEMPLATE #define XDMFDSM_TEMPLATE #define XDMF_TEMPLATE #endif /* _WIN32 */ #endif /* _XDMF_HPP */ xdmf-3.0+git20160803/binsrc/0000740000175000017500000000000013003006557015350 5ustar alastairalastairxdmf-3.0+git20160803/binsrc/CVS/0000740000175000017500000000000013003006557016003 5ustar alastairalastairxdmf-3.0+git20160803/binsrc/CVS/Repository0000640000175000017500000000001413003006557020102 0ustar alastairalastairXdmf/binsrc xdmf-3.0+git20160803/binsrc/CVS/Root0000640000175000017500000000006413003006557016653 0ustar alastairalastair:pserver:anonymous@public.kitware.com:/cvsroot/Xdmf xdmf-3.0+git20160803/binsrc/CVS/Entries0000640000175000017500000000000213003006557017331 0ustar alastairalastairD xdmf-3.0+git20160803/XdmfGridCollection.hpp0000640000175000017500000001456213003006557020333 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfGridCollection.hpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef XDMFGRIDCOLLECTION_HPP_ #define XDMFGRIDCOLLECTION_HPP_ // C Compatible Includes #include "Xdmf.hpp" #include "XdmfDomain.hpp" #include "XdmfGrid.hpp" #include "XdmfGridCollectionType.hpp" #ifdef __cplusplus /** * @brief A spatial or temporal collection of XdmfGrids. * * A temporal collection is timestep data. Each child grid represents * the state at a single timestep. A spatial collection consists of * XdmfGrids that are arranged together in space. E.g. a partitioned * mesh. * * It is valid to nest collections. A spatial collection inside a * temporal collection is commonly used. */ class XDMF_EXPORT XdmfGridCollection : public virtual XdmfDomain, public XdmfGrid { public: /** * Create a new XdmfGridCollection. * * Example of use: * * C++ * * @dontinclude ExampleXdmfGridCollection.cpp * @skipline //#initalization * @until //#initalization * * Python * * @dontinclude XdmfExampleGridCollection.py * @skipline #//initalization * @until #//initalization * * @return Constructed XdmfGridCollection. */ static shared_ptr New(); virtual ~XdmfGridCollection(); LOKI_DEFINE_VISITABLE(XdmfGridCollection, XdmfGrid) static const std::string ItemTag; std::map getItemProperties() const; std::string getItemTag() const; /** * Get the XdmfGridCollectionType associated with this grid collection. * * Example of use: * * C++ * * @dontinclude ExampleXdmfGridCollection.cpp * @skipline //#initalization * @until //#initalization * @skipline //#getType * @until //#getType * * Python * * @dontinclude XdmfExampleGridCollection.py * @skipline #//initalization * @until #//initalization * @skipline #//getType * @until #//getType * * @return XdmfGridCollectionType of this collection. */ shared_ptr getType() const; using XdmfDomain::insert; using XdmfGrid::insert; /** * Insert an information into the grid collection. * * Example of use: * * C++ * * @dontinclude ExampleXdmfGridCollection.cpp * @skipline //#initalization * @until //#initalization * @skipline //#insert * @until //#insert * * Python * * @dontinclude XdmfExampleGridCollection.py * @skipline #//initalization * @until #//initalization * @skipline #//insert * @until #//insert * * @param information An XdmfInformation to attach to this item. */ void insert(const shared_ptr information); void read(); void release(); /** * Set the XdmfGridCollectionType associated with this grid * collection. * * Example of use: * * C++ * * @dontinclude ExampleXdmfGridCollection.cpp * @skipline //#initalization * @until //#initalization * @skipline //#setType * @until //#setType * * Python * * @dontinclude XdmfExampleGridCollection.py * @skipline #//initalization * @until #//initalization * @skipline #//setType * @until #//setType * * @param type The XdmfGridCollectionType to set. */ void setType(const shared_ptr type); void traverse(const shared_ptr visitor); XdmfGridCollection(XdmfGridCollection &); protected: XdmfGridCollection(); virtual void populateItem(const std::map & itemProperties, const std::vector > & childItems, const XdmfCoreReader * const reader); void copyGrid(shared_ptr sourceGrid); private: /** * PIMPL */ class XdmfGridCollectionImpl; XdmfGridCollection(const XdmfGridCollection &); // Not implemented. void operator=(const XdmfGridCollection &); // Not implemented. shared_ptr mType; }; #endif #ifdef __cplusplus extern "C" { #endif // C wrappers go here #ifndef XDMFGRIDCOLLECTIONCDEFINE #define XDMFGRIDCOLLECTIONCDEFINE struct XDMFGRIDCOLLECTION; // Simply as a typedef to ensure correct typing typedef struct XDMFGRIDCOLLECTION XDMFGRIDCOLLECTION; #endif XDMF_EXPORT XDMFGRIDCOLLECTION * XdmfGridCollectionNew(); XDMF_EXPORT int XdmfGridCollectionGetType(XDMFGRIDCOLLECTION * collection, int * status); XDMF_EXPORT void XdmfGridCollectionSetType(XDMFGRIDCOLLECTION * collection, int type, int * status); XDMF_DOMAIN_C_CHILD_DECLARE(XdmfGridCollection, XDMFGRIDCOLLECTION, XDMF) XDMF_GRID_C_CHILD_DECLARE(XdmfGridCollection, XDMFGRIDCOLLECTION, XDMF) XDMF_ITEM_C_CHILD_DECLARE(XdmfGridCollection, XDMFGRIDCOLLECTION, XDMF) #ifdef __cplusplus } #endif #endif /* XDMFGRID_HPP_ */ xdmf-3.0+git20160803/XdmfConfig.hpp.in0000640000175000017500000000354513003006557017243 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfConfig.hpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef XDMFCONFIG_HPP_ #define XDMFCONFIG_HPP_ #cmakedefine BUILD_SHARED #ifndef BUILD_SHARED # define XDMFSTATIC #endif #endif xdmf-3.0+git20160803/XdmfGraph.hpp0000640000175000017500000001101413003006557016460 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfGraph.hpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef XDMFGRAPH_HPP_ #define XDMFGRAPH_HPP_ // C Compatible Includes #include "Xdmf.hpp" #include "XdmfAttribute.hpp" #include "XdmfTime.hpp" #include "XdmfSparseMatrix.hpp" #ifdef __cplusplus /** * @brief Graph stored in sparse matrix form. * * Stores graph information in sparse matrix form. Attributes defining * node and edge information can be inserted. */ class XDMF_EXPORT XdmfGraph : public XdmfSparseMatrix { public: /** * Create a new XdmfGraph. * * Example of use: * * C++ * * @dontinclude ExampleXdmfGraph.cpp * @skipline //#initialization * @until //#initialization * * Python * * @dontinclude XdmfExampleGraph.py * @skipline #//initialization * @until #//initialization * * @param numberNodes number of nodes in graph. * * @return Constructed XdmfGraph. */ static shared_ptr New(const unsigned int numberNodes); virtual ~XdmfGraph(); LOKI_DEFINE_VISITABLE(XdmfGraph, XdmfSparseMatrix) XDMF_CHILDREN(XdmfGraph, XdmfAttribute, Attribute, Name) static const std::string ItemTag; std::string getItemTag() const; shared_ptr getTime(); shared_ptr getTime() const; unsigned int getNumberNodes() const; using XdmfSparseMatrix::insert; void setTime(const shared_ptr time); void traverse(const shared_ptr visitor); XdmfGraph(XdmfGraph &); protected: XdmfGraph(const unsigned int numberNodes); virtual void populateItem(const std::map & itemProperties, const std::vector > & childItems, const XdmfCoreReader * const reader); private: XdmfGraph(const XdmfGraph &); // Not implemented. void operator=(const XdmfGraph &); // Not implemented. shared_ptr mTime; }; #endif #ifdef __cplusplus extern "C" { #endif // C wrappers go here struct XDMFGRAPH; // Simply as a typedef to ensure correct typing typedef struct XDMFGRAPH XDMFGRAPH; XDMF_EXPORT XDMFGRAPH * XdmfGraphNew(unsigned int numberNodes); XDMF_EXPORT XDMFATTRIBUTE * XdmfGraphGetAttribute(XDMFGRAPH * graph, unsigned int index); XDMF_EXPORT XDMFATTRIBUTE * XdmfGraphGetAttributeByName(XDMFGRAPH * graph, char * Name); XDMF_EXPORT unsigned int XdmfGraphGetNumberAttributes(XDMFGRAPH * graph); XDMF_EXPORT void XdmfGraphInsertAttribute(XDMFGRAPH * graph, XDMFATTRIBUTE * Attribute, int passControl); XDMF_EXPORT void XdmfGraphRemoveAttribute(XDMFGRAPH * graph, unsigned int index); XDMF_EXPORT void XdmfGraphRemoveAttributeByName(XDMFGRAPH * graph, char * Name); XDMF_EXPORT unsigned int XdmfGraphGetNumberNodes(XDMFGRAPH * graph); XDMF_ITEM_C_CHILD_DECLARE(XdmfGraph, XDMFGRAPH, XDMF) XDMF_SPARSEMATRIX_C_CHILD_DECLARE(XdmfGraph, XDMFGRAPH, XDMF) #ifdef __cplusplus } #endif #endif /* XDMFGRAPH_HPP_ */ xdmf-3.0+git20160803/XdmfTopology.cpp0000640000175000017500000005244713003006557017245 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfTopology.cpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #include #include #include "XdmfError.hpp" #include "XdmfFunction.hpp" #include "XdmfTopology.hpp" #include "XdmfTopologyType.hpp" shared_ptr XdmfTopology::New() { shared_ptr p(new XdmfTopology()); return p; } XdmfTopology::XdmfTopology() : mType(XdmfTopologyType::NoTopologyType()), mBaseOffset(0) { } XdmfTopology::XdmfTopology(XdmfTopology & refTopo) : XdmfArray(refTopo), mType(refTopo.mType) { } XdmfTopology::~XdmfTopology() { } const std::string XdmfTopology::ItemTag = "Topology"; int XdmfTopology::getBaseOffset() const { return mBaseOffset; } std::string XdmfTopology::getItemTag() const { return ItemTag; } std::map XdmfTopology::getItemProperties() const { std::map topologyProperties; mType->getProperties(topologyProperties); if(mType->getCellType() != XdmfTopologyType::Structured) { std::stringstream numElements; numElements << this->getNumberElements(); topologyProperties.insert(std::make_pair("Dimensions", numElements.str())); } if (mBaseOffset != 0) { std::stringstream offsetString; offsetString << mBaseOffset; topologyProperties.insert(std::make_pair("BaseOffset", offsetString.str())); } return topologyProperties; } unsigned int XdmfTopology::getNumberElements() const { // deal with special cases first (mixed / no topology) if(mType->getNodesPerElement() == 0) { if(mType == XdmfTopologyType::Mixed()) { unsigned int index = 0; unsigned int numberElements = 0; // iterate over all values in connectivity, pulling topology type ids // and counting number of elements while(index < this->getSize()) { const unsigned int id = this->getValue(index); const shared_ptr topologyType = XdmfTopologyType::New(id); if(topologyType == NULL) { XdmfError::message(XdmfError::FATAL, "Invalid topology type id found in connectivity " "when parsing mixed topology."); } if(topologyType == XdmfTopologyType::Polyvertex()) { const unsigned int numberPolyvertexElements = this->getValue(index + 1); numberElements += numberPolyvertexElements; index += numberPolyvertexElements + 2; } else if(topologyType == XdmfTopologyType::Polyline(0) || topologyType == XdmfTopologyType::Polygon(0)) { const unsigned int numberNodes = this->getValue(index + 1); numberElements += 1; index += numberNodes + 2; } else if(topologyType == XdmfTopologyType::Polyhedron()) { // get number of face const unsigned int numberFaces = this->getValue(index + 1); // skip to first face index += 2; // iterate over all faces and add number of nodes per face to index for(unsigned int i=0; igetValue(index) + 1; } numberElements += 1; } else { // add 1 to element count and move to next element id numberElements += 1; index += topologyType->getNodesPerElement() + 1; } } return numberElements; } return 0; } return this->getSize() / mType->getNodesPerElement(); } shared_ptr XdmfTopology::getType() const { return mType; } void XdmfTopology::populateItem(const std::map & itemProperties, const std::vector > & childItems, const XdmfCoreReader * const reader) { XdmfItem::populateItem(itemProperties, childItems, reader); mType = XdmfTopologyType::New(itemProperties); for(std::vector >::const_iterator iter = childItems.begin(); iter != childItems.end(); ++iter) { if(shared_ptr array = shared_dynamic_cast(*iter)) { this->swap(array); if (array->getReference()) { this->setReference(array->getReference()); this->setReadMode(XdmfArray::Reference); } break; } } std::map::const_iterator type = itemProperties.find("Offset"); if (type != itemProperties.end()) { std::map::const_iterator type = itemProperties.find("BaseOffset"); } if (type != itemProperties.end()) { // Convert to double double offset = atof(type->second.c_str()); std::stringstream expressionStream; expressionStream << offset << "+X"; std::map > offsetMap; shared_ptr offsetBase = XdmfArray::New(); this->swap(offsetBase); offsetMap["X"] = offsetBase; shared_ptr offsetFunction = XdmfFunction::New(expressionStream.str(), offsetMap); this->setReference(offsetFunction); this->setReadMode(XdmfArray::Reference); } } void XdmfTopology::setBaseOffset(int offset) { mBaseOffset = offset; } void XdmfTopology::setType(const shared_ptr type) { mType = type; this->setIsChanged(true); } // C Wrappers XDMFTOPOLOGY * XdmfTopologyNew() { try { shared_ptr generatedTopology = XdmfTopology::New(); return (XDMFTOPOLOGY *)((void *)(new XdmfTopology(*generatedTopology.get()))); } catch (...) { shared_ptr generatedTopology = XdmfTopology::New(); return (XDMFTOPOLOGY *)((void *)(new XdmfTopology(*generatedTopology.get()))); } } unsigned int XdmfTopologyGetNumberElements(XDMFTOPOLOGY * topology, int * status) { XDMF_ERROR_WRAP_START(status) return ((XdmfTopology *)topology)->getNumberElements(); XDMF_ERROR_WRAP_END(status) return 0; } int XdmfTopologyGetType(XDMFTOPOLOGY * topology) { shared_ptr type = ((XdmfTopology *)topology)->getType(); int returnType = -1; if (type->getID() == XdmfTopologyType::Polyvertex()->getID()) { returnType = XDMF_TOPOLOGY_TYPE_POLYVERTEX; } else if (type->getID() == XdmfTopologyType::Polyline(0)->getID()) { returnType = XDMF_TOPOLOGY_TYPE_POLYLINE; } else if (type->getID() == XdmfTopologyType::Polygon(0)->getID()) { returnType = XDMF_TOPOLOGY_TYPE_POLYGON; } else if (type->getID() == XdmfTopologyType::Triangle()->getID()) { returnType = XDMF_TOPOLOGY_TYPE_TRIANGLE; } else if (type->getID() == XdmfTopologyType::Quadrilateral()->getID()) { returnType = XDMF_TOPOLOGY_TYPE_QUADRILATERAL; } else if (type->getID() == XdmfTopologyType::Tetrahedron()->getID()) { returnType = XDMF_TOPOLOGY_TYPE_TETRAHEDRON; } else if (type->getID() == XdmfTopologyType::Pyramid()->getID()) { returnType = XDMF_TOPOLOGY_TYPE_PYRAMID; } else if (type->getID() == XdmfTopologyType::Wedge()->getID()) { returnType = XDMF_TOPOLOGY_TYPE_WEDGE; } else if (type->getID() == XdmfTopologyType::Hexahedron()->getID()) { returnType = XDMF_TOPOLOGY_TYPE_HEXAHEDRON; } else if (type->getID() == XdmfTopologyType::Edge_3()->getID()) { returnType = XDMF_TOPOLOGY_TYPE_EDGE_3; } else if (type->getID() == XdmfTopologyType::Triangle_6()->getID()) { returnType = XDMF_TOPOLOGY_TYPE_TRIANGLE_6; } else if (type->getID() == XdmfTopologyType::Quadrilateral_8()->getID()) { returnType = XDMF_TOPOLOGY_TYPE_QUADRILATERAL_8; } else if (type->getID() == XdmfTopologyType::Quadrilateral_9()->getID()) { returnType = XDMF_TOPOLOGY_TYPE_QUADRILATERAL_9; } else if (type->getID() == XdmfTopologyType::Tetrahedron_10()->getID()) { returnType = XDMF_TOPOLOGY_TYPE_TETRAHEDRON_10; } else if (type->getID() == XdmfTopologyType::Pyramid_13()->getID()) { returnType = XDMF_TOPOLOGY_TYPE_PYRAMID_13; } else if (type->getID() == XdmfTopologyType::Wedge_15()->getID()) { returnType = XDMF_TOPOLOGY_TYPE_WEDGE_15; } else if (type->getID() == XdmfTopologyType::Wedge_18()->getID()) { returnType = XDMF_TOPOLOGY_TYPE_WEDGE_18; } else if (type->getID() == XdmfTopologyType::Hexahedron_20()->getID()) { returnType = XDMF_TOPOLOGY_TYPE_HEXAHEDRON_20; } else if (type->getID() == XdmfTopologyType::Hexahedron_24()->getID()) { returnType = XDMF_TOPOLOGY_TYPE_HEXAHEDRON_24; } else if (type->getID() == XdmfTopologyType::Hexahedron_27()->getID()) { returnType = XDMF_TOPOLOGY_TYPE_HEXAHEDRON_27; } else if (type->getID() == XdmfTopologyType::Hexahedron_64()->getID()) { returnType = XDMF_TOPOLOGY_TYPE_HEXAHEDRON_64; } else if (type->getID() == XdmfTopologyType::Hexahedron_125()->getID()) { returnType = XDMF_TOPOLOGY_TYPE_HEXAHEDRON_125; } else if (type->getID() == XdmfTopologyType::Hexahedron_216()->getID()) { returnType = XDMF_TOPOLOGY_TYPE_HEXAHEDRON_216; } else if (type->getID() == XdmfTopologyType::Hexahedron_343()->getID()) { returnType = XDMF_TOPOLOGY_TYPE_HEXAHEDRON_343; } else if (type->getID() == XdmfTopologyType::Hexahedron_512()->getID()) { returnType = XDMF_TOPOLOGY_TYPE_HEXAHEDRON_512; } else if (type->getID() == XdmfTopologyType::Hexahedron_729()->getID()) { returnType = XDMF_TOPOLOGY_TYPE_HEXAHEDRON_729; } else if (type->getID() == XdmfTopologyType::Hexahedron_1000()->getID()) { returnType = XDMF_TOPOLOGY_TYPE_HEXAHEDRON_1000; } else if (type->getID() == XdmfTopologyType::Hexahedron_1331()->getID()) { returnType = XDMF_TOPOLOGY_TYPE_HEXAHEDRON_1331; } else if (type->getID() == XdmfTopologyType::Hexahedron_Spectral_64()->getID()) { returnType = XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_64; } else if (type->getID() == XdmfTopologyType::Hexahedron_Spectral_125()->getID()) { returnType = XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_125; } else if (type->getID() == XdmfTopologyType::Hexahedron_Spectral_216()->getID()) { returnType = XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_216; } else if (type->getID() == XdmfTopologyType::Hexahedron_Spectral_343()->getID()) { returnType = XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_343; } else if (type->getID() == XdmfTopologyType::Hexahedron_Spectral_512()->getID()) { returnType = XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_512; } else if (type->getID() == XdmfTopologyType::Hexahedron_Spectral_729()->getID()) { returnType = XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_729; } else if (type->getID() == XdmfTopologyType::Hexahedron_Spectral_1000()->getID()) { returnType = XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_1000; } else if (type->getID() == XdmfTopologyType::Hexahedron_Spectral_1331()->getID()) { returnType = XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_1331; } else if (type->getID() == XdmfTopologyType::Mixed()->getID()) { returnType = XDMF_TOPOLOGY_TYPE_MIXED; } else { returnType = -1; } return returnType; } void XdmfTopologySetType(XDMFTOPOLOGY * topology, int type, int * status) { XDMF_ERROR_WRAP_START(status) shared_ptr newType = shared_ptr(); switch (type) { case XDMF_TOPOLOGY_TYPE_POLYVERTEX: newType = XdmfTopologyType::Polyvertex(); break; case XDMF_TOPOLOGY_TYPE_POLYLINE: newType = XdmfTopologyType::Polyline(0); break; case XDMF_TOPOLOGY_TYPE_POLYGON: newType = XdmfTopologyType::Polygon(0); break; case XDMF_TOPOLOGY_TYPE_TRIANGLE: newType = XdmfTopologyType::Triangle(); break; case XDMF_TOPOLOGY_TYPE_QUADRILATERAL: newType = XdmfTopologyType::Quadrilateral(); break; case XDMF_TOPOLOGY_TYPE_TETRAHEDRON: newType = XdmfTopologyType::Tetrahedron(); break; case XDMF_TOPOLOGY_TYPE_PYRAMID: newType = XdmfTopologyType::Pyramid(); break; case XDMF_TOPOLOGY_TYPE_WEDGE: newType = XdmfTopologyType::Wedge(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON: newType = XdmfTopologyType::Hexahedron(); break; case XDMF_TOPOLOGY_TYPE_EDGE_3: newType = XdmfTopologyType::Edge_3(); break; case XDMF_TOPOLOGY_TYPE_TRIANGLE_6: newType = XdmfTopologyType::Triangle_6(); break; case XDMF_TOPOLOGY_TYPE_QUADRILATERAL_8: newType = XdmfTopologyType::Quadrilateral_8(); break; case XDMF_TOPOLOGY_TYPE_QUADRILATERAL_9: newType = XdmfTopologyType::Quadrilateral_9(); break; case XDMF_TOPOLOGY_TYPE_TETRAHEDRON_10: newType = XdmfTopologyType::Tetrahedron_10(); break; case XDMF_TOPOLOGY_TYPE_PYRAMID_13: newType = XdmfTopologyType::Pyramid_13(); break; case XDMF_TOPOLOGY_TYPE_WEDGE_15: newType = XdmfTopologyType::Wedge_15(); break; case XDMF_TOPOLOGY_TYPE_WEDGE_18: newType = XdmfTopologyType::Wedge_18(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_20: newType = XdmfTopologyType::Hexahedron_20(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_24: newType = XdmfTopologyType::Hexahedron_24(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_27: newType = XdmfTopologyType::Hexahedron_27(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_64: newType = XdmfTopologyType::Hexahedron_64(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_125: newType = XdmfTopologyType::Hexahedron_125(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_216: newType = XdmfTopologyType::Hexahedron_216(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_343: newType = XdmfTopologyType::Hexahedron_343(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_512: newType = XdmfTopologyType::Hexahedron_512(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_729: newType = XdmfTopologyType::Hexahedron_729(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_1000: newType = XdmfTopologyType::Hexahedron_1000(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_1331: newType = XdmfTopologyType::Hexahedron_1331(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_64: newType = XdmfTopologyType::Hexahedron_Spectral_64(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_125: newType = XdmfTopologyType::Hexahedron_Spectral_125(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_216: newType = XdmfTopologyType::Hexahedron_Spectral_216(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_343: newType = XdmfTopologyType::Hexahedron_Spectral_343(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_512: newType = XdmfTopologyType::Hexahedron_Spectral_512(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_729: newType = XdmfTopologyType::Hexahedron_Spectral_729(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_1000: newType = XdmfTopologyType::Hexahedron_Spectral_1000(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_1331: newType = XdmfTopologyType::Hexahedron_Spectral_1331(); break; case XDMF_TOPOLOGY_TYPE_MIXED: newType = XdmfTopologyType::Mixed(); break; default: XdmfError::message(XdmfError::FATAL, "Error: Invalid Topology Type: Code " + type); break; } ((XdmfTopology *)topology)->setType(newType); XDMF_ERROR_WRAP_END(status) } void XdmfTopologySetPolyType(XDMFTOPOLOGY * topology, int type, int nodes, int * status) { XDMF_ERROR_WRAP_START(status) shared_ptr newType = shared_ptr(); switch (type) { case XDMF_TOPOLOGY_TYPE_POLYVERTEX: newType = XdmfTopologyType::Polyvertex(); break; case XDMF_TOPOLOGY_TYPE_POLYLINE: newType = XdmfTopologyType::Polyline(nodes); break; case XDMF_TOPOLOGY_TYPE_POLYGON: newType = XdmfTopologyType::Polygon(nodes); break; case XDMF_TOPOLOGY_TYPE_TRIANGLE: newType = XdmfTopologyType::Triangle(); break; case XDMF_TOPOLOGY_TYPE_QUADRILATERAL: newType = XdmfTopologyType::Quadrilateral(); break; case XDMF_TOPOLOGY_TYPE_TETRAHEDRON: newType = XdmfTopologyType::Tetrahedron(); break; case XDMF_TOPOLOGY_TYPE_PYRAMID: newType = XdmfTopologyType::Pyramid(); break; case XDMF_TOPOLOGY_TYPE_WEDGE: newType = XdmfTopologyType::Wedge(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON: newType = XdmfTopologyType::Hexahedron(); break; case XDMF_TOPOLOGY_TYPE_EDGE_3: newType = XdmfTopologyType::Edge_3(); break; case XDMF_TOPOLOGY_TYPE_TRIANGLE_6: newType = XdmfTopologyType::Triangle_6(); break; case XDMF_TOPOLOGY_TYPE_QUADRILATERAL_8: newType = XdmfTopologyType::Quadrilateral_8(); break; case XDMF_TOPOLOGY_TYPE_QUADRILATERAL_9: newType = XdmfTopologyType::Quadrilateral_9(); break; case XDMF_TOPOLOGY_TYPE_TETRAHEDRON_10: newType = XdmfTopologyType::Tetrahedron_10(); break; case XDMF_TOPOLOGY_TYPE_PYRAMID_13: newType = XdmfTopologyType::Pyramid_13(); break; case XDMF_TOPOLOGY_TYPE_WEDGE_15: newType = XdmfTopologyType::Wedge_15(); break; case XDMF_TOPOLOGY_TYPE_WEDGE_18: newType = XdmfTopologyType::Wedge_18(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_20: newType = XdmfTopologyType::Hexahedron_20(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_24: newType = XdmfTopologyType::Hexahedron_24(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_27: newType = XdmfTopologyType::Hexahedron_27(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_64: newType = XdmfTopologyType::Hexahedron_64(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_125: newType = XdmfTopologyType::Hexahedron_125(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_216: newType = XdmfTopologyType::Hexahedron_216(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_343: newType = XdmfTopologyType::Hexahedron_343(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_512: newType = XdmfTopologyType::Hexahedron_512(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_729: newType = XdmfTopologyType::Hexahedron_729(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_1000: newType = XdmfTopologyType::Hexahedron_1000(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_1331: newType = XdmfTopologyType::Hexahedron_1331(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_64: newType = XdmfTopologyType::Hexahedron_Spectral_64(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_125: newType = XdmfTopologyType::Hexahedron_Spectral_125(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_216: newType = XdmfTopologyType::Hexahedron_Spectral_216(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_343: newType = XdmfTopologyType::Hexahedron_Spectral_343(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_512: newType = XdmfTopologyType::Hexahedron_Spectral_512(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_729: newType = XdmfTopologyType::Hexahedron_Spectral_729(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_1000: newType = XdmfTopologyType::Hexahedron_Spectral_1000(); break; case XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_1331: newType = XdmfTopologyType::Hexahedron_Spectral_1331(); break; case XDMF_TOPOLOGY_TYPE_MIXED: newType = XdmfTopologyType::Mixed(); break; default: XdmfError::message(XdmfError::FATAL, "Error: Invalid Topology Type: Code " + type); break; } ((XdmfTopology *)topology)->setType(newType); XDMF_ERROR_WRAP_END(status) } XDMF_ITEM_C_CHILD_WRAPPER(XdmfTopology, XDMFTOPOLOGY) XDMF_ARRAY_C_CHILD_WRAPPER(XdmfTopology, XDMFTOPOLOGY) xdmf-3.0+git20160803/Xdmf.i0000640000175000017500000021361013003006557015145 0ustar alastairalastair/* XdmfPython.cpp: swig -v -c++ -python -o XdmfPython.cpp Xdmf.i */ %{ #include #include #if PY_VERSION_HEX >= 0x03020000 #define SWIGPY_SLICE_ARG(obj) ((PyObject*) (obj)) #else #define SWIGPY_SLICE_ARG(obj) ((PySliceObject*) (obj)) #endif %} #ifdef XDMF_BUILD_DSM %module Xdmf %{ // MPI Includes #include // XdmfCore Includes #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // Xdmf Includes #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include %} #else %module Xdmf %{ // XdmfCore Includes #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // Xdmf Includes #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include %} #endif %import XdmfCore.i // Ignoring C Wrappers // XdmfAggregate %ignore XdmfAggregateNew(); %ignore XdmfAggregateGetArray(XDMFAGGREGATE * aggregate, unsigned int index); %ignore XdmfAggregateGetArrayByName(XDMFAGGREGATE * aggregate, char * name); %ignore XdmfAggregateGetNumberArrays(XDMFAGGREGATE * aggregate); %ignore XdmfAggregateInsertArray(XDMFAGGREGATE * aggregate, XDMFARRAY * array, int transferOwnership); %ignore XdmfAggregateRemoveArray(XDMFAGGREGATE * aggregate, unsigned int index); %ignore XdmfAggregateRemoveArrayByName(XDMFAGGREGATE * aggregate, char * name); // XdmfAttributeCenter %ignore XdmfAttributeCenterGrid(); %ignore XdmfAttributeCenterCell(); %ignore XdmfAttributeCenterFace(); %ignore XdmfAttributeCenterEdge(); %ignore XdmfAttributeCenterNode(); // XdmfAttribute %ignore XdmfAttributeNew(); %ignore XdmfAttributeGetCenter(XDMFATTRIBUTE * attribute); %ignore XdmfAttributeGetType(XDMFATTRIBUTE * attribute); %ignore XdmfAttributeSetCenter(XDMFATTRIBUTE * attribute, int center, int * status); %ignore XdmfAttributeSetType(XDMFATTRIBUTE * attribute, int type, int * status); // XdmfAttribute inherited from XdmfArray %ignore XdmfAttributeNew(); %ignore XdmfAttributeClear(XDMFATTRIBUTE * array); %ignore XdmfAttributeErase(XDMFATTRIBUTE * array, unsigned int index); %ignore XdmfAttributeGetArrayType(XDMFATTRIBUTE * array, int * status); %ignore XdmfAttributeGetCapacity(XDMFATTRIBUTE * array); %ignore XdmfAttributeGetDimensions(XDMFATTRIBUTE * array); %ignore XdmfAttributeGetDimensionsString(XDMFATTRIBUTE * array); %ignore XdmfAttributeGetHeavyDataController(XDMFATTRIBUTE * array, unsigned int index); %ignore XdmfAttributeGetReadMode(XDMFATTRIBUTE * array, int * status); %ignore XdmfAttributeGetName(XDMFATTRIBUTE * array); %ignore XdmfAttributeGetNumberDimensions(XDMFATTRIBUTE * array); %ignore XdmfAttributeGetNumberHeavyDataControllers(XDMFATTRIBUTE * array); %ignore XdmfAttributeGetSize(XDMFATTRIBUTE * array); %ignore XdmfAttributeGetReference(XDMFATTRIBUTE * array); %ignore XdmfAttributeGetValue(XDMFATTRIBUTE * array, unsigned int index, int arrayType, int * status); %ignore XdmfAttributeGetValues(XDMFATTRIBUTE * array, unsigned int startIndex, int arrayType, unsigned int numValues, unsigned int arrayStride, unsigned int valueStride, int * status); %ignore XdmfAttributeGetValuesInternal(XDMFATTRIBUTE * array); %ignore XdmfAttributeGetValuesString(XDMFATTRIBUTE * array); %ignore XdmfAttributeInitialize(XDMFATTRIBUTE * array, int * dims, int numDims, int arrayType, int * status); %ignore XdmfAttributeInsertDataFromPointer(XDMFATTRIBUTE * array, void * values, int arrayType, unsigned int startIndex, unsigned int numVals, unsigned int arrayStride, unsigned int valueStride, int * status); %ignore XdmfAttributeInsertDataFromXdmfArray(XDMFATTRIBUTE * array, XDMFARRAY * valArray, int * arrayStarts, int * valueStarts, int * arrayCounts, int * valueCounts, int * arrayStrides, int * valueStrides, int * status); %ignore XdmfAttributeInsertHeavyDataController(XDMFATTRIBUTE * array, XDMFHEAVYDATACONTROLLER * controller, int passControl); %ignore XdmfAttributeInsertValue(XDMFATTRIBUTE * array, unsigned int index, void * value, int arrayType, int * status); %ignore XdmfAttributeIsInitialized(XDMFATTRIBUTE * array); %ignore XdmfAttributePushBack(XDMFATTRIBUTE * array, void * value, int arrayType, int * status); %ignore XdmfAttributeRead(XDMFATTRIBUTE * array, int * status); %ignore XdmfAttributeReadController(XDMFATTRIBUTE * array, int * status); %ignore XdmfAttributeReadReference(XDMFATTRIBUTE * array, int * status); %ignore XdmfAttributeRelease(XDMFATTRIBUTE * array); %ignore XdmfAttributeRemoveHeavyDataController(XDMFATTRIBUTE * array, unsigned int index); %ignore XdmfAttributeReserve(XDMFATTRIBUTE * array, int size); %ignore XdmfAttributeResize(XDMFATTRIBUTE * array, int * dims, int numDims, int arrayType, int * status); %ignore XdmfAttributeSetReadMode(XDMFATTRIBUTE * array, int readMode, int * status); %ignore XdmfAttributeSetReference(XDMFATTRIBUTE * array, XDMFARRAYREFERENCE * reference, int passControl); %ignore XdmfAttributeSetName(XDMFATTRIBUTE * array, char * name, int * status); %ignore XdmfAttributeSetValuesInternal(XDMFATTRIBUTE * array, void * pointer, unsigned int numValues, int arrayType, int transferOwnership, int * status); %ignore XdmfAttributeSwapWithXdmfArray(XDMFATTRIBUTE * array, XDMFARRAY * swapArray); %ignore XdmfAttributeSwapWithArray(XDMFATTRIBUTE * array, void ** pointer, int numValues, int arrayType, int * status); // XdmfAttribute inherited from XdmfItem %ignore XdmfAttributeAccept(XDMFATTRIBUTE * item, XDMFVISITOR * visitor, int * status); %ignore XdmfAttributeFree(void * item); %ignore XdmfAttributeGetInformation(XDMFATTRIBUTE * item, unsigned int index); %ignore XdmfAttributeGetInformationByKey(XDMFATTRIBUTE * item, char * key); %ignore XdmfAttributeGetNumberInformations(XDMFATTRIBUTE * item); %ignore XdmfAttributeInsertInformation(XDMFATTRIBUTE * item, XDMFINFORMATION * information, int passControl); %ignore XdmfAttributeRemoveInformation(XDMFATTRIBUTE * item, unsigned int index); %ignore XdmfAttributeRemoveInformationByKey(XDMFATTRIBUTE * item, char * key); %ignore XdmfAttributeGetItemTag(XDMFATTRIBUTE * item); // XdmfAttributeType %ignore XdmfAttributeTypeScalar(); %ignore XdmfAttributeTypeVector(); %ignore XdmfAttributeTypeTensor(); %ignore XdmfAttributeTypeMatrix(); %ignore XdmfAttributeTypeTensor6(); %ignore XdmfAttributeTypeGlobalId(); %ignore XdmfAttributeTypeNoAttributeType(); // XdmfCurvilinearGrid %ignore XdmfCurvilinearGridNew2D(unsigned int xNumPoints, unsigned int yNumPoints); %ignore XdmfCurvilinearGridNew3D(unsigned int xNumPoints, unsigned int yNumPoints, unsigned int zNumPoints); %ignore XdmfCurvilinearGridNew(XDMFARRAY * numPoints, int * status); %ignore XdmfCurvilinearGridGetDimensions(XDMFCURVILINEARGRID * grid, int * status); %ignore XdmfCurvilinearGridGetGeometry(XDMFCURVILINEARGRID * grid); %ignore XdmfCurvilinearGridSetDimensions(XDMFCURVILINEARGRID * grid, XDMFARRAY * dimensions, int passControl, int * status); %ignore XdmfCurvilinearGridSetGeometry(XDMFCURVILINEARGRID * grid, XDMFGEOMETRY * geometry, int passControl); // XdmfCurvilinearGrid inherited from XdmfItem %ignore XdmfCurvilinearGridAccept(XDMFCURVILINEARGRID * item, XDMFVISITOR * visitor, int * status); %ignore XdmfCurvilinearGridFree(void * item); %ignore XdmfCurvilinearGridGetInformation(XDMFCURVILINEARGRID * item, unsigned int index); %ignore XdmfCurvilinearGridGetInformationByKey(XDMFCURVILINEARGRID * item, char * key); %ignore XdmfCurvilinearGridGetNumberInformations(XDMFCURVILINEARGRID * item); %ignore XdmfCurvilinearGridInsertInformation(XDMFCURVILINEARGRID * item, XDMFINFORMATION * information, int passControl); %ignore XdmfCurvilinearGridRemoveInformation(XDMFCURVILINEARGRID * item, unsigned int index); %ignore XdmfCurvilinearGridRemoveInformationByKey(XDMFCURVILINEARGRID * item, char * key); %ignore XdmfCurvilinearGridGetItemTag(XDMFCURVILINEARGRID * item); // XdmfCurvilinearGrid inherited from XdmfGrid %ignore XdmfCurvilinearGridGetAttribute(XDMFCURVILINEARGRID * grid, unsigned int index); %ignore XdmfCurvilinearGridGetAttributeByName(XDMFCURVILINEARGRID * grid, char * Name); %ignore XdmfCurvilinearGridGetNumberAttributes(XDMFCURVILINEARGRID * grid); %ignore XdmfCurvilinearGridInsertAttribute(XDMFCURVILINEARGRID * grid, XDMFATTRIBUTE * Attribute, int passControl); %ignore XdmfCurvilinearGridRemoveAttribute(XDMFCURVILINEARGRID * grid, unsigned int index); %ignore XdmfCurvilinearGridRemoveAttributeByName(XDMFCURVILINEARGRID * grid, char * Name); %ignore XdmfCurvilinearGridGetSet(XDMFCURVILINEARGRID * grid, unsigned int index); %ignore XdmfCurvilinearGridGetSetByName(XDMFCURVILINEARGRID * grid, char * Name); %ignore XdmfCurvilinearGridGetNumberSets(XDMFCURVILINEARGRID * grid); %ignore XdmfCurvilinearGridInsertSet(XDMFCURVILINEARGRID * grid, XDMFSET * Set, int passControl); %ignore XdmfCurvilinearGridRemoveSet(XDMFCURVILINEARGRID * grid, unsigned int index); %ignore XdmfCurvilinearGridRemoveSetByName(XDMFCURVILINEARGRID * grid, char * Name); %ignore XdmfCurvilinearGridGetMap(XDMFCURVILINEARGRID * grid, unsigned int index); %ignore XdmfCurvilinearGridGetMapByName(XDMFCURVILINEARGRID * grid, char * Name); %ignore XdmfCurvilinearGridGetNumberMaps(XDMFCURVILINEARGRID * grid); %ignore XdmfCurvilinearGridInsertMap(XDMFCURVILINEARGRID * grid, XDMFMAP * Map, int passControl); %ignore XdmfCurvilinearGridRemoveMap(XDMFCURVILINEARGRID * grid, unsigned int index); %ignore XdmfCurvilinearGridRemoveMapByName(XDMFCURVILINEARGRID * grid, char * Name); %ignore XdmfCurvilinearGridGetName(XDMFCURVILINEARGRID * grid); %ignore XdmfCurvilinearGridGetTime(XDMFCURVILINEARGRID * grid); %ignore XdmfCurvilinearGridSetName(XDMFCURVILINEARGRID * grid, char * name, int * status); %ignore XdmfCurvilinearGridSetTime(XDMFCURVILINEARGRID * grid, XDMFTIME * time, int passControl); // XdmfDomain %ignore XdmfDomainNew(); %ignore XdmfDomainGetGridCollection(XDMFDOMAIN * domain, unsigned int index); %ignore XdmfDomainGetGridCollectionByName(XDMFDOMAIN * domain, char * Name); %ignore XdmfDomainGetNumberGridCollections(XDMFDOMAIN * domain); %ignore XdmfDomainInsertGridCollection(XDMFDOMAIN * domain, XDMFGRIDCOLLECTION * GridCollection, int passControl); %ignore XdmfDomainRemoveGridCollection(XDMFDOMAIN * domain, unsigned int index); %ignore XdmfDomainRemoveGridCollectionByName(XDMFDOMAIN * domain, char * Name); %ignore XdmfDomainGetGraph(XDMFDOMAIN * domain, unsigned int index); %ignore XdmfDomainGetGraphByName(XDMFDOMAIN * domain, char * Name); %ignore XdmfDomainGetNumberGraphs(XDMFDOMAIN * domain); %ignore XdmfDomainInsertGraph(XDMFDOMAIN * domain, XDMFGRAPH * graph, int passControl); %ignore XdmfDomainRemoveGraph(XDMFDOMAIN * domain, unsigned int index); %ignore XdmfDomainRemoveGraphByName(XDMFDOMAIN * domain, char * Name); %ignore XdmfDomainGetCurvilinearGrid(XDMFDOMAIN * domain, unsigned int index); %ignore XdmfDomainGetCurvilinearGridByName(XDMFDOMAIN * domain, char * Name); %ignore XdmfDomainGetNumberCurvilinearGrids(XDMFDOMAIN * domain); %ignore XdmfDomainInsertCurvilinearGrid(XDMFDOMAIN * domain, XDMFCURVILINEARGRID * CurvilinearGrid, int passControl); %ignore XdmfDomainRemoveCurvilinearGrid(XDMFDOMAIN * domain, unsigned int index); %ignore XdmfDomainRemoveCurvilinearGridByName(XDMFDOMAIN * domain, char * Name); %ignore XdmfDomainGetRectilinearGrid(XDMFDOMAIN * domain, unsigned int index); %ignore XdmfDomainGetRectilinearGridByName(XDMFDOMAIN * domain, char * Name); %ignore XdmfDomainGetNumberRectilinearGrids(XDMFDOMAIN * domain); %ignore XdmfDomainInsertRectilinearGrid(XDMFDOMAIN * domain, XDMFRECTILINEARGRID * RectilinearGrid, int passControl); %ignore XdmfDomainRemoveRectilinearGrid(XDMFDOMAIN * domain, unsigned int index); %ignore XdmfDomainRemoveRectilinearGridByName(XDMFDOMAIN * domain, char * Name); %ignore XdmfDomainGetRegularGrid(XDMFDOMAIN * domain, unsigned int index); %ignore XdmfDomainGetRegularGridByName(XDMFDOMAIN * domain, char * Name); %ignore XdmfDomainGetNumberRegularGrids(XDMFDOMAIN * domain); %ignore XdmfDomainInsertRegularGrid(XDMFDOMAIN * domain, XDMFREGULARGRID * RegularGrid, int passControl); %ignore XdmfDomainRemoveRegularGrid(XDMFDOMAIN * domain, unsigned int index); %ignore XdmfDomainRemoveRegularGridByName(XDMFDOMAIN * domain, char * Name); %ignore XdmfDomainGetUnstructuredGrid(XDMFDOMAIN * domain, unsigned int index); %ignore XdmfDomainGetUnstructuredGridByName(XDMFDOMAIN * domain, char * Name); %ignore XdmfDomainGetNumberUnstructuredGrids(XDMFDOMAIN * domain); %ignore XdmfDomainInsertUnstructuredGrid(XDMFDOMAIN * domain, XDMFUNSTRUCTUREDGRID * UnstructuredGrid, int passControl); %ignore XdmfDomainRemoveUnstructuredGrid(XDMFDOMAIN * domain, unsigned int index); %ignore XdmfDomainRemoveUnstructuredGridByName(XDMFDOMAIN * domain, char * Name); // XdmfDomain inherited from XdmfItem %ignore XdmfDomainAccept(XDMFDOMAIN * item, XDMFVISITOR * visitor, int * status); %ignore XdmfDomainFree(void * item); %ignore XdmfDomainGetInformation(XDMFDOMAIN * item, unsigned int index); %ignore XdmfDomainGetInformationByKey(XDMFDOMAIN * item, char * key); %ignore XdmfDomainGetNumberInformations(XDMFDOMAIN * item); %ignore XdmfDomainInsertInformation(XDMFDOMAIN * item, XDMFINFORMATION * information, int passControl); %ignore XdmfDomainRemoveInformation(XDMFDOMAIN * item, unsigned int index); %ignore XdmfDomainRemoveInformationByKey(XDMFDOMAIN * item, char * key); %ignore XdmfDomainGetItemTag(XDMFDOMAIN * item); // XdmfGeometry %ignore XdmfGeometryNew(); %ignore XdmfGeometryGetNumberPoints(XDMFGEOMETRY * geometry); %ignore XdmfGeometryGetOrigin(XDMFGEOMETRY * geometry); %ignore XdmfGeometryGetOriginSize(XDMFGEOMETRY * geometry); %ignore XdmfGeometryGetType(XDMFGEOMETRY * geometry); %ignore XdmfGeometrySetOrigin(XDMFGEOMETRY * geometry, double newX, double newY, double newZ); %ignore XdmfGeometrySetOriginArray(XDMFGEOMETRY * geometry, double * originVals, unsigned int numDims); %ignore XdmfGeometrySetType(XDMFGEOMETRY * geometry, int type, int * status); // XdmfGeometry inherited from XdmfArray %ignore XdmfGeometryNew(); %ignore XdmfGeometryClear(XDMFGEOMETRY * array); %ignore XdmfGeometryErase(XDMFGEOMETRY * array, unsigned int index); %ignore XdmfGeometryGetArrayType(XDMFGEOMETRY * array, int * status); %ignore XdmfGeometryGetCapacity(XDMFGEOMETRY * array); %ignore XdmfGeometryGetDimensions(XDMFGEOMETRY * array); %ignore XdmfGeometryGetDimensionsString(XDMFGEOMETRY * array); %ignore XdmfGeometryGetHeavyDataController(XDMFGEOMETRY * array, unsigned int index); %ignore XdmfGeometryGetReadMode(XDMFGEOMETRY * array, int * status); %ignore XdmfGeometryGetName(XDMFGEOMETRY * array); %ignore XdmfGeometryGetNumberDimensions(XDMFGEOMETRY * array); %ignore XdmfGeometryGetNumberHeavyDataControllers(XDMFGEOMETRY * array); %ignore XdmfGeometryGetSize(XDMFGEOMETRY * array); %ignore XdmfGeometryGetReference(XDMFGEOMETRY * array); %ignore XdmfGeometryGetValue(XDMFGEOMETRY * array, unsigned int index, int arrayType, int * status); %ignore XdmfGeometryGetValues(XDMFGEOMETRY * array, unsigned int startIndex, int arrayType, unsigned int numValues, unsigned int arrayStride, unsigned int valueStride, int * status); %ignore XdmfGeometryGetValuesInternal(XDMFGEOMETRY * array); %ignore XdmfGeometryGetValuesString(XDMFGEOMETRY * array); %ignore XdmfGeometryInitialize(XDMFGEOMETRY * array, int * dims, int numDims, int arrayType, int * status); %ignore XdmfGeometryInsertDataFromPointer(XDMFGEOMETRY * array, void * values, int arrayType, unsigned int startIndex, unsigned int numVals, unsigned int arrayStride, unsigned int valueStride, int * status); %ignore XdmfGeometryInsertDataFromXdmfArray(XDMFGEOMETRY * array, XDMFARRAY * valArray, int * arrayStarts, int * valueStarts, int * arrayCounts, int * valueCounts, int * arrayStrides, int * valueStrides, int * status); %ignore XdmfGeometryInsertHeavyDataController(XDMFGEOMETRY * array, XDMFHEAVYDATACONTROLLER * controller, int passControl); %ignore XdmfGeometryInsertValue(XDMFGEOMETRY * array, unsigned int index, void * value, int arrayType, int * status); %ignore XdmfGeometryIsInitialized(XDMFGEOMETRY * array); %ignore XdmfGeometryPushBack(XDMFGEOMETRY * array, void * value, int arrayType, int * status); %ignore XdmfGeometryRead(XDMFGEOMETRY * array, int * status); %ignore XdmfGeometryReadController(XDMFGEOMETRY * array, int * status); %ignore XdmfGeometryReadReference(XDMFGEOMETRY * array, int * status); %ignore XdmfGeometryRelease(XDMFGEOMETRY * array); %ignore XdmfGeometryRemoveHeavyDataController(XDMFGEOMETRY * array, unsigned int index); %ignore XdmfGeometryReserve(XDMFGEOMETRY * array, int size); %ignore XdmfGeometryResize(XDMFGEOMETRY * array, int * dims, int numDims, int arrayType, int * status); %ignore XdmfGeometrySetReadMode(XDMFGEOMETRY * array, int readMode, int * status); %ignore XdmfGeometrySetReference(XDMFGEOMETRY * array, XDMFARRAYREFERENCE * reference, int passControl); %ignore XdmfGeometrySetName(XDMFGEOMETRY * array, char * name, int * status); %ignore XdmfGeometrySetValuesInternal(XDMFGEOMETRY * array, void * pointer, unsigned int numValues, int arrayType, int transferOwnership, int * status); %ignore XdmfGeometrySwapWithXdmfArray(XDMFGEOMETRY * array, XDMFARRAY * swapArray); %ignore XdmfGeometrySwapWithArray(XDMFGEOMETRY * array, void ** pointer, int numValues, int arrayType, int * status); // XdmfGeometry inherited from XdmfItem %ignore XdmfGeometryAccept(XDMFGEOMETRY * item, XDMFVISITOR * visitor, int * status); %ignore XdmfGeometryFree(void * item); %ignore XdmfGeometryGetInformation(XDMFGEOMETRY * item, unsigned int index); %ignore XdmfGeometryGetInformationByKey(XDMFGEOMETRY * item, char * key); %ignore XdmfGeometryGetNumberInformations(XDMFGEOMETRY * item); %ignore XdmfGeometryInsertInformation(XDMFGEOMETRY * item, XDMFINFORMATION * information, int passControl); %ignore XdmfGeometryRemoveInformation(XDMFGEOMETRY * item, unsigned int index); %ignore XdmfGeometryRemoveInformationByKey(XDMFGEOMETRY * item, char * key); %ignore XdmfGeometryGetItemTag(XDMFGEOMETRY * item); // XdmfGeometryType %ignore XdmfGeometryTypeNoGeometryType(); %ignore XdmfGeometryTypeXYZ(); %ignore XdmfGeometryTypeXY(); %ignore XdmfGeometryTypeGetDimensions(int type, int * status); %ignore XdmfGeometryTypeGetName(int type); // XdmfGraph %ignore XdmfGraphNew(unsigned int numberNodes); %ignore XdmfGraphGetAttribute(XDMFGRAPH * graph, unsigned int index); %ignore XdmfGraphGetAttributeByName(XDMFGRAPH * graph, char * Name); %ignore XdmfGraphGetNumberAttributes(XDMFGRAPH * graph); %ignore XdmfGraphInsertAttribute(XDMFGRAPH * graph, XDMFATTRIBUTE * Attribute, int passControl); %ignore XdmfGraphRemoveAttribute(XDMFGRAPH * graph, unsigned int index); %ignore XdmfGraphRemoveAttributeByName(XDMFGRAPH * graph, char * Name); %ignore XdmfGraphGetNumberNodes(XDMFGRAPH * graph); // XdmfGraph inherited from XdmfSparseMatrix %ignore XdmfGraphNew(unsigned int numberRows, unsigned int numberColumns); %ignore XdmfGraphGetColumnIndex(XDMFGRAPH * matrix, int * status); %ignore XdmfGraphGetName(XDMFGRAPH * matrix); %ignore XdmfGraphGetNumberColumns(XDMFGRAPH * matrix); %ignore XdmfGraphGetNumberRows(XDMFGRAPH * matrix); %ignore XdmfGraphGetRowPointer(XDMFGRAPH * matrix, int * status); %ignore XdmfGraphGetValues(XDMFGRAPH * matrix, int * status); %ignore XdmfGraphGetValuesString(XDMFGRAPH * matrix, int * status); %ignore XdmfGraphSetColumnIndex(XDMFGRAPH * matrix, XDMFARRAY * columnIndex, int passControl, int * status); %ignore XdmfGraphSetName(XDMFGRAPH * matrix, char * name, int * status); %ignore XdmfGraphSetRowPointer(XDMFGRAPH * matrix, XDMFARRAY * rowPointer, int passControl, int * status); %ignore XdmfGraphSetValues(XDMFGRAPH * matrix, XDMFARRAY * values, int passControl, int * status); // XdmfGraph inherited from XdmfItem %ignore XdmfGraphAccept(XDMFGRAPH * item, XDMFVISITOR * visitor, int * status); %ignore XdmfGraphFree(void * item); %ignore XdmfGraphGetInformation(XDMFGRAPH * item, unsigned int index); %ignore XdmfGraphGetInformationByKey(XDMFGRAPH * item, char * key); %ignore XdmfGraphGetNumberInformations(XDMFGRAPH * item); %ignore XdmfGraphInsertInformation(XDMFGRAPH * item, XDMFINFORMATION * information, int passControl); %ignore XdmfGraphRemoveInformation(XDMFGRAPH * item, unsigned int index); %ignore XdmfGraphRemoveInformationByKey(XDMFGRAPH * item, char * key); %ignore XdmfGraphGetItemTag(XDMFGRAPH * item); // XdmfGridCollection %ignore XdmfGridCollectionNew(); %ignore XdmfGridCollectionGetType(XDMFGRIDCOLLECTION * collection, int * status); %ignore XdmfGridCollectionSetType(XDMFGRIDCOLLECTION * collection, int type, int * status); // XdmfGridCollection inherited from XdmfDomain %ignore XdmfGridCollectionGetGridCollection(XDMFGRIDCOLLECTION * domain, unsigned int index); %ignore XdmfGridCollectionGetGridCollectionByName(XDMFGRIDCOLLECTION * domain, char * Name); %ignore XdmfGridCollectionGetNumberGridCollections(XDMFGRIDCOLLECTION * domain); %ignore XdmfGridCollectionInsertGridCollection(XDMFGRIDCOLLECTION * domain, XDMFGRIDCOLLECTION * GridCollection, int passControl); %ignore XdmfGridCollectionRemoveGridCollection(XDMFGRIDCOLLECTION * domain, unsigned int index); %ignore XdmfGridCollectionRemoveGridCollectionByName(XDMFGRIDCOLLECTION * domain, char * Name); %ignore XdmfGridCollectionGetGraph(XDMFGRIDCOLLECTION * domain, unsigned int index); %ignore XdmfGridCollectionGetGraphByName(XDMFGRIDCOLLECTION * domain, char * Name); %ignore XdmfGridCollectionGetNumberGraphs(XDMFGRIDCOLLECTION * domain); %ignore XdmfGridCollectionInsertGraph(XDMFGRIDCOLLECTION * domain, XDMFGRAPH * graph, int passControl); %ignore XdmfGridCollectionRemoveGraph(XDMFGRIDCOLLECTION * domain, unsigned int index); %ignore XdmfGridCollectionRemoveGraphByName(XDMFGRIDCOLLECTION * domain, char * Name); %ignore XdmfGridCollectionGetCurvilinearGrid(XDMFGRIDCOLLECTION * domain, unsigned int index); %ignore XdmfGridCollectionGetCurvilinearGridByName(XDMFGRIDCOLLECTION * domain, char * Name); %ignore XdmfGridCollectionGetNumberCurvilinearGrids(XDMFGRIDCOLLECTION * domain); %ignore XdmfGridCollectionInsertCurvilinearGrid(XDMFGRIDCOLLECTION * domain, XDMFCURVILINEARGRID * CurvilinearGrid, int passControl); %ignore XdmfGridCollectionRemoveCurvilinearGrid(XDMFGRIDCOLLECTION * domain, unsigned int index); %ignore XdmfGridCollectionRemoveCurvilinearGridByName(XDMFGRIDCOLLECTION * domain, char * Name); %ignore XdmfGridCollectionGetRectilinearGrid(XDMFGRIDCOLLECTION * domain, unsigned int index); %ignore XdmfGridCollectionGetRectilinearGridByName(XDMFGRIDCOLLECTION * domain, char * Name); %ignore XdmfGridCollectionGetNumberRectilinearGrids(XDMFGRIDCOLLECTION * domain); %ignore XdmfGridCollectionInsertRectilinearGrid(XDMFGRIDCOLLECTION * domain, XDMFRECTILINEARGRID * RectilinearGrid, int passControl); %ignore XdmfGridCollectionRemoveRectilinearGrid(XDMFGRIDCOLLECTION * domain, unsigned int index); %ignore XdmfGridCollectionRemoveRectilinearGridByName(XDMFGRIDCOLLECTION * domain, char * Name); %ignore XdmfGridCollectionGetRegularGrid(XDMFGRIDCOLLECTION * domain, unsigned int index); %ignore XdmfGridCollectionGetRegularGridByName(XDMFGRIDCOLLECTION * domain, char * Name); %ignore XdmfGridCollectionGetNumberRegularGrids(XDMFGRIDCOLLECTION * domain); %ignore XdmfGridCollectionInsertRegularGrid(XDMFGRIDCOLLECTION * domain, XDMFREGULARGRID * RegularGrid, int passControl); %ignore XdmfGridCollectionRemoveRegularGrid(XDMFGRIDCOLLECTION * domain, unsigned int index); %ignore XdmfGridCollectionRemoveRegularGridByName(XDMFGRIDCOLLECTION * domain, char * Name); %ignore XdmfGridCollectionGetUnstructuredGrid(XDMFGRIDCOLLECTION * domain, unsigned int index); %ignore XdmfGridCollectionGetUnstructuredGridByName(XDMFGRIDCOLLECTION * domain, char * Name); %ignore XdmfGridCollectionGetNumberUnstructuredGrids(XDMFGRIDCOLLECTION * domain); %ignore XdmfGridCollectionInsertUnstructuredGrid(XDMFGRIDCOLLECTION * domain, XDMFUNSTRUCTUREDGRID * UnstructuredGrid, int passControl); %ignore XdmfGridCollectionRemoveUnstructuredGrid(XDMFGRIDCOLLECTION * domain, unsigned int index); %ignore XdmfGridCollectionRemoveUnstructuredGridByName(XDMFGRIDCOLLECTION * domain, char * Name); // XdmfGridCollection inherited from XdmfGrid %ignore XdmfGridCollectionGetAttribute(XDMFGRIDCOLLECTION * grid, unsigned int index); %ignore XdmfGridCollectionGetAttributeByName(XDMFGRIDCOLLECTION * grid, char * Name); %ignore XdmfGridCollectionGetNumberAttributes(XDMFGRIDCOLLECTION * grid); %ignore XdmfGridCollectionInsertAttribute(XDMFGRIDCOLLECTION * grid, XDMFATTRIBUTE * Attribute, int passControl); %ignore XdmfGridCollectionRemoveAttribute(XDMFGRIDCOLLECTION * grid, unsigned int index); %ignore XdmfGridCollectionRemoveAttributeByName(XDMFGRIDCOLLECTION * grid, char * Name); %ignore XdmfGridCollectionGetSet(XDMFGRIDCOLLECTION * grid, unsigned int index); %ignore XdmfGridCollectionGetSetByName(XDMFGRIDCOLLECTION * grid, char * Name); %ignore XdmfGridCollectionGetNumberSets(XDMFGRIDCOLLECTION * grid); %ignore XdmfGridCollectionInsertSet(XDMFGRIDCOLLECTION * grid, XDMFSET * Set, int passControl); %ignore XdmfGridCollectionRemoveSet(XDMFGRIDCOLLECTION * grid, unsigned int index); %ignore XdmfGridCollectionRemoveSetByName(XDMFGRIDCOLLECTION * grid, char * Name); %ignore XdmfGridCollectionGetMap(XDMFGRIDCOLLECTION * grid, unsigned int index); %ignore XdmfGridCollectionGetMapByName(XDMFGRIDCOLLECTION * grid, char * Name); %ignore XdmfGridCollectionGetNumberMaps(XDMFGRIDCOLLECTION * grid); %ignore XdmfGridCollectionInsertMap(XDMFGRIDCOLLECTION * grid, XDMFMAP * Map, int passControl); %ignore XdmfGridCollectionRemoveMap(XDMFGRIDCOLLECTION * grid, unsigned int index); %ignore XdmfGridCollectionRemoveMapByName(XDMFGRIDCOLLECTION * grid, char * Name); %ignore XdmfGridCollectionGetName(XDMFGRIDCOLLECTION * grid); %ignore XdmfGridCollectionGetTime(XDMFGRIDCOLLECTION * grid); %ignore XdmfGridCollectionSetName(XDMFGRIDCOLLECTION * grid, char * name, int * status); %ignore XdmfGridCollectionSetTime(XDMFGRIDCOLLECTION * grid, XDMFTIME * time, int passControl); // XdmfGridCollection inherited from XdmfItem %ignore XdmfGridCollectionAccept(XDMFGRIDCOLLECTION * item, XDMFVISITOR * visitor, int * status); %ignore XdmfGridCollectionFree(void * item); %ignore XdmfGridCollectionGetInformation(XDMFGRIDCOLLECTION * item, unsigned int index); %ignore XdmfGridCollectionGetInformationByKey(XDMFGRIDCOLLECTION * item, char * key); %ignore XdmfGridCollectionGetNumberInformations(XDMFGRIDCOLLECTION * item); %ignore XdmfGridCollectionInsertInformation(XDMFGRIDCOLLECTION * item, XDMFINFORMATION * information, int passControl); %ignore XdmfGridCollectionRemoveInformation(XDMFGRIDCOLLECTION * item, unsigned int index); %ignore XdmfGridCollectionRemoveInformationByKey(XDMFGRIDCOLLECTION * item, char * key); %ignore XdmfGridCollectionGetItemTag(XDMFGRIDCOLLECTION * item); // XdmfGrid // XdmfGrid inherited from XdmfGrid %ignore XdmfGridGetAttribute(XDMFGRID * grid, unsigned int index); %ignore XdmfGridGetAttributeByName(XDMFGRID * grid, char * Name); %ignore XdmfGridGetNumberAttributes(XDMFGRID * grid); %ignore XdmfGridInsertAttribute(XDMFGRID * grid, XDMFATTRIBUTE * Attribute, int passControl); %ignore XdmfGridRemoveAttribute(XDMFGRID * grid, unsigned int index); %ignore XdmfGridRemoveAttributeByName(XDMFGRID * grid, char * Name); %ignore XdmfGridGetSet(XDMFGRID * grid, unsigned int index); %ignore XdmfGridGetSetByName(XDMFGRID * grid, char * Name); %ignore XdmfGridGetNumberSets(XDMFGRID * grid); %ignore XdmfGridInsertSet(XDMFGRID * grid, XDMFSET * Set, int passControl); %ignore XdmfGridRemoveSet(XDMFGRID * grid, unsigned int index); %ignore XdmfGridRemoveSetByName(XDMFGRID * grid, char * Name); %ignore XdmfGridGetMap(XDMFGRID * grid, unsigned int index); %ignore XdmfGridGetMapByName(XDMFGRID * grid, char * Name); %ignore XdmfGridGetNumberMaps(XDMFGRID * grid); %ignore XdmfGridInsertMap(XDMFGRID * grid, XDMFMAP * Map, int passControl); %ignore XdmfGridRemoveMap(XDMFGRID * grid, unsigned int index); %ignore XdmfGridRemoveMapByName(XDMFGRID * grid, char * Name); %ignore XdmfGridGetName(XDMFGRID * grid); %ignore XdmfGridGetTime(XDMFGRID * grid); %ignore XdmfGridSetName(XDMFGRID * grid, char * name, int * status); %ignore XdmfGridSetTime(XDMFGRID * grid, XDMFTIME * time, int passControl); // XdmfGrid inherited from XdmfItem %ignore XdmfGridAccept(XDMFGRID * item, XDMFVISITOR * visitor, int * status); %ignore XdmfGridFree(void * item); %ignore XdmfGridGetInformation(XDMFGRID * item, unsigned int index); %ignore XdmfGridGetInformationByKey(XDMFGRID * item, char * key); %ignore XdmfGridGetNumberInformations(XDMFGRID * item); %ignore XdmfGridInsertInformation(XDMFGRID * item, XDMFINFORMATION * information, int passControl); %ignore XdmfGridRemoveInformation(XDMFGRID * item, unsigned int index); %ignore XdmfGridRemoveInformationByKey(XDMFGRID * item, char * key); %ignore XdmfGridGetItemTag(XDMFGRID * item); // XdmfMap %ignore XdmfMapNew(); %ignore XdmfMapNewFromIdVector(int ** globalNodeIds, int * numIdsOnNode, int numIds); %ignore XdmfMapGetName(XDMFMAP * map); %ignore XdmfMapInsert(XDMFMAP * map, int remoteTaskId, int localNodeId, int remoteLocalNodeId); %ignore XdmfMapIsInitialized(XDMFMAP * map); %ignore XdmfMapRead(XDMFMAP * map, int * status); %ignore XdmfMapRelease(XDMFMAP * map); %ignore XdmfMapRetrieveLocalNodeIds(XDMFMAP * map, int remoteTaskId); %ignore XdmfMapRetrieveNumberLocalNodeIds(XDMFMAP * map, int remoteTaskId); %ignore XdmfMapRetrieveNumberRemoteTaskIds(XDMFMAP * map); %ignore XdmfMapRetrieveNumberRemoteNodeIds(XDMFMAP * map, int remoteTaskId, int localNodeId); %ignore XdmfMapRetrieveRemoteTaskIds(XDMFMAP * map); %ignore XdmfMapRetrieveRemoteNodeIds(XDMFMAP * map, int remoteTaskId, int localNodeId); %ignore XdmfMapSetHeavyDataControllers(XDMFMAP * map, XDMFHEAVYDATACONTROLLER ** remoteTaskControllers, int numRemoteTaskControllers, XDMFHEAVYDATACONTROLLER ** localNodeControllers, int numberLocalNodeControllers, XDMFHEAVYDATACONTROLLER ** remoteLocalNodeControllers, int numRemoteLocalNodeControllers, int passControl, int * status); %ignore XdmfMapSetName(XDMFMAP * map, char * newName); // XdmfMap inherited from XdmfItem %ignore XdmfMapAccept(XDMFMAP * item, XDMFVISITOR * visitor, int * status); %ignore XdmfMapFree(void * item); %ignore XdmfMapGetInformation(XDMFMAP * item, unsigned int index); %ignore XdmfMapGetInformationByKey(XDMFMAP * item, char * key); %ignore XdmfMapGetNumberInformations(XDMFMAP * item); %ignore XdmfMapInsertInformation(XDMFMAP * item, XDMFINFORMATION * information, int passControl); %ignore XdmfMapRemoveInformation(XDMFMAP * item, unsigned int index); %ignore XdmfMapRemoveInformationByKey(XDMFMAP * item, char * key); %ignore XdmfMapGetItemTag(XDMFMAP * item); // XdmfReader %ignore XdmfReaderNew(); %ignore XdmfReaderFree(XDMFREADER * item); // XdmfReader inherited from XdmfCoreReader %ignore XdmfReaderRead(XDMFREADER * reader, char * filePath, int * status); // XdmfRectilinearGrid %ignore XdmfRectilinearGridNew(XDMFARRAY ** axesCoordinates, unsigned int numCoordinates, int passControl); %ignore XdmfRectilinearGridNew2D(XDMFARRAY * xCoordinates, XDMFARRAY * yCoordinates, int passControl); %ignore XdmfRectilinearGridNew3D(XDMFARRAY * xCoordinates, XDMFARRAY * yCoordinates, XDMFARRAY * zCoordinates, int passControl); %ignore XdmfRectilinearGridGetCoordinatesByIndex(XDMFRECTILINEARGRID * grid, unsigned int axisIndex, int * status); %ignore XdmfRectilinearGridGetCoordinates(XDMFRECTILINEARGRID * grid, int * status); %ignore XdmfRectilinearGridGetNumberCoordinates(XDMFRECTILINEARGRID * grid, int * status); %ignore XdmfRectilinearGridGetDimensions(XDMFRECTILINEARGRID * grid, int * status); %ignore XdmfRectilinearGridSetCoordinates(XDMFRECTILINEARGRID * grid, XDMFARRAY ** axesCoordinates, unsigned int numCoordinates, int passControl, int * status); %ignore XdmfRectilinearGridSetCoordinatesByIndex(XDMFRECTILINEARGRID * grid, unsigned int index, XDMFARRAY * coordinates, int passControl, int * status); // XdmfRectilinearGrid inherited from XdmfItem %ignore XdmfRectilinearGridAccept(XDMFRECTILINEARGRID * item, XDMFVISITOR * visitor, int * status); %ignore XdmfRectilinearGridFree(void * item); %ignore XdmfRectilinearGridGetInformation(XDMFRECTILINEARGRID * item, unsigned int index); %ignore XdmfRectilinearGridGetInformationByKey(XDMFRECTILINEARGRID * item, char * key); %ignore XdmfRectilinearGridGetNumberInformations(XDMFRECTILINEARGRID * item); %ignore XdmfRectilinearGridInsertInformation(XDMFRECTILINEARGRID * item, XDMFINFORMATION * information, int passControl); %ignore XdmfRectilinearGridRemoveInformation(XDMFRECTILINEARGRID * item, unsigned int index); %ignore XdmfRectilinearGridRemoveInformationByKey(XDMFRECTILINEARGRID * item, char * key); %ignore XdmfRectilinearGridGetItemTag(XDMFRECTILINEARGRID * item); // XdmfRectilinearGrid inherited from XdmfGrid %ignore XdmfRectilinearGridGetAttribute(XDMFRECTILINEARGRID * grid, unsigned int index); %ignore XdmfRectilinearGridGetAttributeByName(XDMFRECTILINEARGRID * grid, char * Name); %ignore XdmfRectilinearGridGetNumberAttributes(XDMFRECTILINEARGRID * grid); %ignore XdmfRectilinearGridInsertAttribute(XDMFRECTILINEARGRID * grid, XDMFATTRIBUTE * Attribute, int passControl); %ignore XdmfRectilinearGridRemoveAttribute(XDMFRECTILINEARGRID * grid, unsigned int index); %ignore XdmfRectilinearGridRemoveAttributeByName(XDMFRECTILINEARGRID * grid, char * Name); %ignore XdmfRectilinearGridGetSet(XDMFRECTILINEARGRID * grid, unsigned int index); %ignore XdmfRectilinearGridGetSetByName(XDMFRECTILINEARGRID * grid, char * Name); %ignore XdmfRectilinearGridGetNumberSets(XDMFRECTILINEARGRID * grid); %ignore XdmfRectilinearGridInsertSet(XDMFRECTILINEARGRID * grid, XDMFSET * Set, int passControl); %ignore XdmfRectilinearGridRemoveSet(XDMFRECTILINEARGRID * grid, unsigned int index); %ignore XdmfRectilinearGridRemoveSetByName(XDMFRECTILINEARGRID * grid, char * Name); %ignore XdmfRectilinearGridGetMap(XDMFRECTILINEARGRID * grid, unsigned int index); %ignore XdmfRectilinearGridGetMapByName(XDMFRECTILINEARGRID * grid, char * Name); %ignore XdmfRectilinearGridGetNumberMaps(XDMFRECTILINEARGRID * grid); %ignore XdmfRectilinearGridInsertMap(XDMFRECTILINEARGRID * grid, XDMFMAP * Map, int passControl); %ignore XdmfRectilinearGridRemoveMap(XDMFRECTILINEARGRID * grid, unsigned int index); %ignore XdmfRectilinearGridRemoveMapByName(XDMFRECTILINEARGRID * grid, char * Name); %ignore XdmfRectilinearGridGetName(XDMFRECTILINEARGRID * grid); %ignore XdmfRectilinearGridGetTime(XDMFRECTILINEARGRID * grid); %ignore XdmfRectilinearGridSetName(XDMFRECTILINEARGRID * grid, char * name, int * status); %ignore XdmfRectilinearGridSetTime(XDMFRECTILINEARGRID * grid, XDMFTIME * time, int passControl); // XdmfRegularGrid %ignore XdmfRegularGridNew2D(double xBrickSize, double yBrickSize, unsigned int xNumPoints, unsigned int yNumPoints, double xOrigin, double yOrigin); %ignore XdmfRegularGridNew3D(double xBrickSize, double yBrickSize, double zBrickSize, unsigned int xNumPoints, unsigned int yNumPoints, unsigned int zNumPoints, double xOrigin, double yOrigin, double zOrigin); %ignore XdmfRegularGridNew(XDMFARRAY * brickSize, XDMFARRAY * numPoints, XDMFARRAY * origin, int passControl); %ignore XdmfRegularGridGetBrickSize(XDMFREGULARGRID * grid, int * status); %ignore XdmfRegularGridGetDimensions(XDMFREGULARGRID * grid, int * status); %ignore XdmfRegularGridGetOrigin(XDMFREGULARGRID * grid, int * status); %ignore XdmfRegularGridSetBrickSize(XDMFREGULARGRID * grid, XDMFARRAY * brickSize, int passControl, int * status); %ignore XdmfRegularGridSetDimensions(XDMFREGULARGRID * grid, XDMFARRAY * dimensions, int passControl, int * status); %ignore XdmfRegularGridSetOrigin(XDMFREGULARGRID * grid, XDMFARRAY * origin, int passControl, int * status); // XdmfRegularGrid inherited from XdmfItem %ignore XdmfRegularGridAccept(XDMFREGULARGRID * item, XDMFVISITOR * visitor, int * status); %ignore XdmfRegularGridFree(void * item); %ignore XdmfRegularGridGetInformation(XDMFREGULARGRID * item, unsigned int index); %ignore XdmfRegularGridGetInformationByKey(XDMFREGULARGRID * item, char * key); %ignore XdmfRegularGridGetNumberInformations(XDMFREGULARGRID * item); %ignore XdmfRegularGridInsertInformation(XDMFREGULARGRID * item, XDMFINFORMATION * information, int passControl); %ignore XdmfRegularGridRemoveInformation(XDMFREGULARGRID * item, unsigned int index); %ignore XdmfRegularGridRemoveInformationByKey(XDMFREGULARGRID * item, char * key); %ignore XdmfRegularGridGetItemTag(XDMFREGULARGRID * item); // XdmfRegularGrid inherited from XdmfGrid %ignore XdmfRegularGridGetAttribute(XDMFREGULARGRID * grid, unsigned int index); %ignore XdmfRegularGridGetAttributeByName(XDMFREGULARGRID * grid, char * Name); %ignore XdmfRegularGridGetNumberAttributes(XDMFREGULARGRID * grid); %ignore XdmfRegularGridInsertAttribute(XDMFREGULARGRID * grid, XDMFATTRIBUTE * Attribute, int passControl); %ignore XdmfRegularGridRemoveAttribute(XDMFREGULARGRID * grid, unsigned int index); %ignore XdmfRegularGridRemoveAttributeByName(XDMFREGULARGRID * grid, char * Name); %ignore XdmfRegularGridGetSet(XDMFREGULARGRID * grid, unsigned int index); %ignore XdmfRegularGridGetSetByName(XDMFREGULARGRID * grid, char * Name); %ignore XdmfRegularGridGetNumberSets(XDMFREGULARGRID * grid); %ignore XdmfRegularGridInsertSet(XDMFREGULARGRID * grid, XDMFSET * Set, int passControl); %ignore XdmfRegularGridRemoveSet(XDMFREGULARGRID * grid, unsigned int index); %ignore XdmfRegularGridRemoveSetByName(XDMFREGULARGRID * grid, char * Name); %ignore XdmfRegularGridGetMap(XDMFREGULARGRID * grid, unsigned int index); %ignore XdmfRegularGridGetMapByName(XDMFREGULARGRID * grid, char * Name); %ignore XdmfRegularGridGetNumberMaps(XDMFREGULARGRID * grid); %ignore XdmfRegularGridInsertMap(XDMFREGULARGRID * grid, XDMFMAP * Map, int passControl); %ignore XdmfRegularGridRemoveMap(XDMFREGULARGRID * grid, unsigned int index); %ignore XdmfRegularGridRemoveMapByName(XDMFREGULARGRID * grid, char * Name); %ignore XdmfRegularGridGetName(XDMFREGULARGRID * grid); %ignore XdmfRegularGridGetTime(XDMFREGULARGRID * grid); %ignore XdmfRegularGridSetName(XDMFREGULARGRID * grid, char * name, int * status); %ignore XdmfRegularGridSetTime(XDMFREGULARGRID * grid, XDMFTIME * time, int passControl); // XdmfSet %ignore XdmfSetNew(); %ignore XdmfSetGetAttribute(XDMFSET * set, unsigned int index); %ignore XdmfSetGetAttributeByName(XDMFSET * set, char * Name); %ignore XdmfSetGetNumberAttributes(XDMFSET * set); %ignore XdmfSetGetType(XDMFSET * set); %ignore XdmfSetInsertAttribute(XDMFSET * set, XDMFATTRIBUTE * Attribute, int passControl); vXdmfSetRemoveAttribute(XDMFSET * set, unsigned int index); %ignore XdmfSetRemoveAttributeByName(XDMFSET * set, char * Name); %ignore XdmfSetSetType(XDMFSET * set, int type, int * status); // XdmfSet inherited from XdmfArray %ignore XdmfSetNew(); %ignore XdmfSetClear(XDMFSET * array); %ignore XdmfSetErase(XDMFSET * array, unsigned int index); %ignore XdmfSetGetArrayType(XDMFSET * array, int * status); %ignore XdmfSetGetCapacity(XDMFSET * array); %ignore XdmfSetGetDimensions(XDMFSET * array); %ignore XdmfSetGetDimensionsString(XDMFSET * array); %ignore XdmfSetGetHeavyDataController(XDMFSET * array, unsigned int index); %ignore XdmfSetGetReadMode(XDMFSET * array, int * status); %ignore XdmfSetGetName(XDMFSET * array); %ignore XdmfSetGetNumberDimensions(XDMFSET * array); %ignore XdmfSetGetNumberHeavyDataControllers(XDMFSET * array); %ignore XdmfSetGetSize(XDMFSET * array); %ignore XdmfSetGetReference(XDMFSET * array); %ignore XdmfSetGetValue(XDMFSET * array, unsigned int index, int arrayType, int * status); %ignore XdmfSetGetValues(XDMFSET * array, unsigned int startIndex, int arrayType, unsigned int numValues, unsigned int arrayStride, unsigned int valueStride, int * status); %ignore XdmfSetGetValuesInternal(XDMFSET * array); %ignore XdmfSetGetValuesString(XDMFSET * array); %ignore XdmfSetInitialize(XDMFSET * array, int * dims, int numDims, int arrayType, int * status); %ignore XdmfSetInsertDataFromPointer(XDMFSET * array, void * values, int arrayType, unsigned int startIndex, unsigned int numVals, unsigned int arrayStride, unsigned int valueStride, int * status); %ignore XdmfSetInsertDataFromXdmfArray(XDMFSET * array, XDMFARRAY * valArray, int * arrayStarts, int * valueStarts, int * arrayCounts, int * valueCounts, int * arrayStrides, int * valueStrides, int * status); %ignore XdmfSetInsertHeavyDataController(XDMFSET * array, XDMFHEAVYDATACONTROLLER * controller, int passControl); %ignore XdmfSetInsertValue(XDMFSET * array, unsigned int index, void * value, int arrayType, int * status); %ignore XdmfSetIsInitialized(XDMFSET * array); %ignore XdmfSetPushBack(XDMFSET * array, void * value, int arrayType, int * status); %ignore XdmfSetRead(XDMFSET * array, int * status); %ignore XdmfSetReadController(XDMFSET * array, int * status); %ignore XdmfSetReadReference(XDMFSET * array, int * status); %ignore XdmfSetRelease(XDMFSET * array); %ignore XdmfSetRemoveHeavyDataController(XDMFSET * array, unsigned int index); %ignore XdmfSetReserve(XDMFSET * array, int size); %ignore XdmfSetResize(XDMFSET * array, int * dims, int numDims, int arrayType, int * status); %ignore XdmfSetSetReadMode(XDMFSET * array, int readMode, int * status); %ignore XdmfSetSetReference(XDMFSET * array, XDMFARRAYREFERENCE * reference, int passControl); %ignore XdmfSetSetName(XDMFSET * array, char * name, int * status); %ignore XdmfSetSetValuesInternal(XDMFSET * array, void * pointer, unsigned int numValues, int arrayType, int transferOwnership, int * status); %ignore XdmfSetSwapWithXdmfArray(XDMFSET * array, XDMFARRAY * swapArray); %ignore XdmfSetSwapWithArray(XDMFSET * array, void ** pointer, int numValues, int arrayType, int * status); // XdmfSet inherited from XdmfItem %ignore XdmfSetAccept(XDMFSET * item, XDMFVISITOR * visitor, int * status); %ignore XdmfSetFree(void * item); %ignore XdmfSetGetInformation(XDMFSET * item, unsigned int index); %ignore XdmfSetGetInformationByKey(XDMFSET * item, char * key); %ignore XdmfSetGetNumberInformations(XDMFSET * item); %ignore XdmfSetInsertInformation(XDMFSET * item, XDMFINFORMATION * information, int passControl); %ignore XdmfSetRemoveInformation(XDMFSET * item, unsigned int index); %ignore XdmfSetRemoveInformationByKey(XDMFSET * item, char * key); %ignore XdmfSetGetItemTag(XDMFSET * item); // XdmfSetType %ignore XdmfSetTypeNoSetType(); %ignore XdmfSetTypeNode(); %ignore XdmfSetTypeCell(); %ignore XdmfSetTypeFace(); %ignore XdmfSetTypeEdge(); // XdmfTime %ignore XdmfTimeNew(double value); %ignore XdmfTimeGetValue(XDMFTIME * timePointer); %ignore XdmfTimeSetValue(XDMFTIME * timePointer, double time); // XdmfTime inherited from XdmfItem %ignore XdmfTimeAccept(XDMFTIME * item, XDMFVISITOR * visitor, int * status); %ignore XdmfTimeFree(void * item); %ignore XdmfTimeGetInformation(XDMFTIME * item, unsigned int index); %ignore XdmfTimeGetInformationByKey(XDMFTIME * item, char * key); %ignore XdmfTimeGetNumberInformations(XDMFTIME * item); %ignore XdmfTimeInsertInformation(XDMFTIME * item, XDMFINFORMATION * information, int passControl); %ignore XdmfTimeRemoveInformation(XDMFTIME * item, unsigned int index); %ignore XdmfTimeRemoveInformationByKey(XDMFTIME * item, char * key); %ignore XdmfTimeGetItemTag(XDMFTIME * item); // XdmfTopology %ignore XdmfTopologyNew(); %ignore XdmfTopologyGetNumberElements(XDMFTOPOLOGY * topology, int * status); %ignore XdmfTopologyGetType(XDMFTOPOLOGY * topology); %ignore XdmfTopologySetType(XDMFTOPOLOGY * topology, int type, int * status); %ignore XdmfTopologySetPolyType(XDMFTOPOLOGY * topology, int type, int nodes, int * status); // XdmfTopology inherited from XdmfArray %ignore XdmfTopologyNew(); %ignore XdmfTopologyClear(XDMFTOPOLOGY * array); %ignore XdmfTopologyErase(XDMFTOPOLOGY * array, unsigned int index); %ignore XdmfTopologyGetArrayType(XDMFTOPOLOGY * array, int * status); %ignore XdmfTopologyGetCapacity(XDMFTOPOLOGY * array); %ignore XdmfTopologyGetDimensions(XDMFTOPOLOGY * array); %ignore XdmfTopologyGetDimensionsString(XDMFTOPOLOGY * array); %ignore XdmfTopologyGetHeavyDataController(XDMFTOPOLOGY * array, unsigned int index); %ignore XdmfTopologyGetReadMode(XDMFTOPOLOGY * array, int * status); %ignore XdmfTopologyGetName(XDMFTOPOLOGY * array); %ignore XdmfTopologyGetNumberDimensions(XDMFTOPOLOGY * array); %ignore XdmfTopologyGetNumberHeavyDataControllers(XDMFTOPOLOGY * array); %ignore XdmfTopologyGetSize(XDMFTOPOLOGY * array); %ignore XdmfTopologyGetReference(XDMFTOPOLOGY * array); %ignore XdmfTopologyGetValue(XDMFTOPOLOGY * array, unsigned int index, int arrayType, int * status); %ignore XdmfTopologyGetValues(XDMFTOPOLOGY * array, unsigned int startIndex, int arrayType, unsigned int numValues, unsigned int arrayStride, unsigned int valueStride, int * status); %ignore XdmfTopologyGetValuesInternal(XDMFTOPOLOGY * array); %ignore XdmfTopologyGetValuesString(XDMFTOPOLOGY * array); %ignore XdmfTopologyInitialize(XDMFTOPOLOGY * array, int * dims, int numDims, int arrayType, int * status); %ignore XdmfTopologyInsertDataFromPointer(XDMFTOPOLOGY * array, void * values, int arrayType, unsigned int startIndex, unsigned int numVals, unsigned int arrayStride, unsigned int valueStride, int * status); %ignore XdmfTopologyInsertDataFromXdmfArray(XDMFTOPOLOGY * array, XDMFARRAY * valArray, int * arrayStarts, int * valueStarts, int * arrayCounts, int * valueCounts, int * arrayStrides, int * valueStrides, int * status); %ignore XdmfTopologyInsertHeavyDataController(XDMFTOPOLOGY * array, XDMFHEAVYDATACONTROLLER * controller, int passControl); %ignore XdmfTopologyInsertValue(XDMFTOPOLOGY * array, unsigned int index, void * value, int arrayType, int * status); %ignore XdmfTopologyIsInitialized(XDMFTOPOLOGY * array); %ignore XdmfTopologyPushBack(XDMFTOPOLOGY * array, void * value, int arrayType, int * status); %ignore XdmfTopologyRead(XDMFTOPOLOGY * array, int * status); %ignore XdmfTopologyReadController(XDMFTOPOLOGY * array, int * status); %ignore XdmfTopologyReadReference(XDMFTOPOLOGY * array, int * status); %ignore XdmfTopologyRelease(XDMFTOPOLOGY * array); %ignore XdmfTopologyRemoveHeavyDataController(XDMFTOPOLOGY * array, unsigned int index); %ignore XdmfTopologyReserve(XDMFTOPOLOGY * array, int size); %ignore XdmfTopologyResize(XDMFTOPOLOGY * array, int * dims, int numDims, int arrayType, int * status); %ignore XdmfTopologySetReadMode(XDMFTOPOLOGY * array, int readMode, int * status); %ignore XdmfTopologySetReference(XDMFTOPOLOGY * array, XDMFARRAYREFERENCE * reference, int passControl); %ignore XdmfTopologySetName(XDMFTOPOLOGY * array, char * name, int * status); %ignore XdmfTopologySetValuesInternal(XDMFTOPOLOGY * array, void * pointer, unsigned int numValues, int arrayType, int transferOwnership, int * status); %ignore XdmfTopologySwapWithXdmfArray(XDMFTOPOLOGY * array, XDMFARRAY * swapArray); %ignore XdmfTopologySwapWithArray(XDMFTOPOLOGY * array, void ** pointer, int numValues, int arrayType, int * status); // XdmfTopology inherited from XdmfItem %ignore XdmfTopologyAccept(XDMFTOPOLOGY * item, XDMFVISITOR * visitor, int * status); %ignore XdmfTopologyFree(void * item); %ignore XdmfTopologyGetInformation(XDMFTOPOLOGY * item, unsigned int index); %ignore XdmfTopologyGetInformationByKey(XDMFTOPOLOGY * item, char * key); %ignore XdmfTopologyGetNumberInformations(XDMFTOPOLOGY * item); %ignore XdmfTopologyInsertInformation(XDMFTOPOLOGY * item, XDMFINFORMATION * information, int passControl); %ignore XdmfTopologyRemoveInformation(XDMFTOPOLOGY * item, unsigned int index); %ignore XdmfTopologyRemoveInformationByKey(XDMFTOPOLOGY * item, char * key); %ignore XdmfTopologyGetItemTag(XDMFTOPOLOGY * item); // XdmfTopologyType %ignore XdmfTopologyTypePolyvertex(); %ignore XdmfTopologyTypePolyline(); %ignore XdmfTopologyTypePolygon(); %ignore XdmfTopologyTypeTriangle(); %ignore XdmfTopologyTypeQuadrilateral(); %ignore XdmfTopologyTypeTetrahedron(); %ignore XdmfTopologyTypePyramid(); %ignore XdmfTopologyTypeWedge(); %ignore XdmfTopologyTypeHexahedron(); %ignore XdmfTopologyTypeEdge_3(); %ignore XdmfTopologyTypeTriangle_6(); %ignore XdmfTopologyTypeQuadrilateral_8(); %ignore XdmfTopologyTypeQuadrilateral_9(); %ignore XdmfTopologyTypeTetrahedron_10(); %ignore XdmfTopologyTypePyramid_13(); %ignore XdmfTopologyTypeWedge_15(); %ignore XdmfTopologyTypeWedge_18(); %ignore XdmfTopologyTypeHexahedron_20(); %ignore XdmfTopologyTypeHexahedron_24(); %ignore XdmfTopologyTypeHexahedron_27(); %ignore XdmfTopologyTypeHexahedron_64(); %ignore XdmfTopologyTypeHexahedron_125(); %ignore XdmfTopologyTypeHexahedron_216(); %ignore XdmfTopologyTypeHexahedron_343(); %ignore XdmfTopologyTypeHexahedron_512(); %ignore XdmfTopologyTypeHexahedron_729(); %ignore XdmfTopologyTypeHexahedron_1000(); %ignore XdmfTopologyTypeHexahedron_1331(); %ignore XdmfTopologyTypeHexahedron_Spectral_64(); %ignore XdmfTopologyTypeHexahedron_Spectral_125(); %ignore XdmfTopologyTypeHexahedron_Spectral_216(); %ignore XdmfTopologyTypeHexahedron_Spectral_343(); %ignore XdmfTopologyTypeHexahedron_Spectral_512(); %ignore XdmfTopologyTypeHexahedron_Spectral_729(); %ignore XdmfTopologyTypeHexahedron_Spectral_1000(); %ignore XdmfTopologyTypeHexahedron_Spectral_1331(); %ignore XdmfTopologyTypeMixed(); %ignore XdmfTopologyTypeGetCellType(int type); %ignore XdmfTopologyTypeGetEdgesPerElement(int type, int * status); %ignore XdmfTopologyTypeGetFacesPerElement(int type, int * status); %ignore XdmfTopologyTypeGetFaceType(int type); %ignore XdmfTopologyTypeGetID(int type); %ignore XdmfTopologyTypeGetName(int type); %ignore XdmfTopologyTypeGetNodesPerElement(int type); // XdmfUnstructuredGrid %ignore XdmfUnstructuredGridNew(); %ignore XdmfUnstructuredGridNewFromRegularGrid(XDMFREGULARGRID * regularGrid, int * status); %ignore XdmfUnstructuredGridGetGeometry(XDMFUNSTRUCTUREDGRID * grid); %ignore XdmfUnstructuredGridGetTopology(XDMFUNSTRUCTUREDGRID * grid); %ignore XdmfUnstructuredGridSetGeometry(XDMFUNSTRUCTUREDGRID * grid, XDMFGEOMETRY * geometry, int passControl); %ignore XdmfUnstructuredGridSetTopology(XDMFUNSTRUCTUREDGRID * grid, XDMFTOPOLOGY * topology, int passControl); // XdmfUnstructuredGrid inherited from XdmfItem %ignore XdmfUnstructuredGridAccept(XDMFUNSTRUCTUREDGRID * item, XDMFVISITOR * visitor, int * status); %ignore XdmfUnstructuredGridFree(void * item); %ignore XdmfUnstructuredGridGetInformation(XDMFUNSTRUCTUREDGRID * item, unsigned int index); %ignore XdmfUnstructuredGridGetInformationByKey(XDMFUNSTRUCTUREDGRID * item, char * key); %ignore XdmfUnstructuredGridGetNumberInformations(XDMFUNSTRUCTUREDGRID * item); %ignore XdmfUnstructuredGridInsertInformation(XDMFUNSTRUCTUREDGRID * item, XDMFINFORMATION * information, int passControl); %ignore XdmfUnstructuredGridRemoveInformation(XDMFUNSTRUCTUREDGRID * item, unsigned int index); %ignore XdmfUnstructuredGridRemoveInformationByKey(XDMFUNSTRUCTUREDGRID * item, char * key); %ignore XdmfUnstructuredGridGetItemTag(XDMFUNSTRUCTUREDGRID * item); // XdmfUnstructuredGrid inherited from XdmfGrid %ignore XdmfUnstructuredGridGetAttribute(XDMFUNSTRUCTUREDGRID * grid, unsigned int index); %ignore XdmfUnstructuredGridGetAttributeByName(XDMFUNSTRUCTUREDGRID * grid, char * Name); %ignore XdmfUnstructuredGridGetNumberAttributes(XDMFUNSTRUCTUREDGRID * grid); %ignore XdmfUnstructuredGridInsertAttribute(XDMFUNSTRUCTUREDGRID * grid, XDMFATTRIBUTE * Attribute, int passControl); %ignore XdmfUnstructuredGridRemoveAttribute(XDMFUNSTRUCTUREDGRID * grid, unsigned int index); %ignore XdmfUnstructuredGridRemoveAttributeByName(XDMFUNSTRUCTUREDGRID * grid, char * Name); %ignore XdmfUnstructuredGridGetSet(XDMFUNSTRUCTUREDGRID * grid, unsigned int index); %ignore XdmfUnstructuredGridGetSetByName(XDMFUNSTRUCTUREDGRID * grid, char * Name); %ignore XdmfUnstructuredGridGetNumberSets(XDMFUNSTRUCTUREDGRID * grid); %ignore XdmfUnstructuredGridInsertSet(XDMFUNSTRUCTUREDGRID * grid, XDMFSET * Set, int passControl); %ignore XdmfUnstructuredGridRemoveSet(XDMFUNSTRUCTUREDGRID * grid, unsigned int index); %ignore XdmfUnstructuredGridRemoveSetByName(XDMFUNSTRUCTUREDGRID * grid, char * Name); %ignore XdmfUnstructuredGridGetMap(XDMFUNSTRUCTUREDGRID * grid, unsigned int index); %ignore XdmfUnstructuredGridGetMapByName(XDMFUNSTRUCTUREDGRID * grid, char * Name); %ignore XdmfUnstructuredGridGetNumberMaps(XDMFUNSTRUCTUREDGRID * grid); %ignore XdmfUnstructuredGridInsertMap(XDMFUNSTRUCTUREDGRID * grid, XDMFMAP * Map, int passControl); %ignore XdmfUnstructuredGridRemoveMap(XDMFUNSTRUCTUREDGRID * grid, unsigned int index); %ignore XdmfUnstructuredGridRemoveMapByName(XDMFUNSTRUCTUREDGRID * grid, char * Name); %ignore XdmfUnstructuredGridGetName(XDMFUNSTRUCTUREDGRID * grid); %ignore XdmfUnstructuredGridGetTime(XDMFUNSTRUCTUREDGRID * grid); %ignore XdmfUnstructuredGridSetName(XDMFUNSTRUCTUREDGRID * grid, char * name, int * status); %ignore XdmfUnstructuredGridSetTime(XDMFUNSTRUCTUREDGRID * grid, XDMFTIME * time, int passControl); #ifdef SWIGJAVA // Typemaps that work for Java %typemap(out) shared_ptr { if(shared_ptr value = shared_dynamic_cast($1)) { *(shared_ptr< XdmfAttribute > **)&($result) = value ? new shared_ptr< XdmfAttribute >(value) : 0; } else if(shared_ptr value = shared_dynamic_cast($1)) { *(shared_ptr< XdmfCurvilinearGrid > **)&($result) = value ? new shared_ptr< XdmfCurvilinearGrid >(value) : 0; } else if(shared_ptr value = shared_dynamic_cast($1)) { *(shared_ptr< XdmfGridCollection > **)&($result) = value ? new shared_ptr< XdmfGridCollection >(value) : 0; } else if(shared_ptr value = shared_dynamic_cast($1)) { *(shared_ptr< XdmfDomain > **)&($result) = value ? new shared_ptr< XdmfDomain >(value) : 0; } else if(shared_ptr value = shared_dynamic_cast($1)) { *(shared_ptr< XdmfGeometry > **)&($result) = value ? new shared_ptr< XdmfGeometry >(value) : 0; } else if(shared_ptr value = shared_dynamic_cast($1)) { *(shared_ptr< XdmfInformation > **)&($result) = value ? new shared_ptr< XdmfInformation >(value) : 0; } else if(shared_ptr value = shared_dynamic_cast($1)) { *(shared_ptr< XdmfRectilinearGrid > **)&($result) = value ? new shared_ptr< XdmfRectilinearGrid >(value) : 0; } else if(shared_ptr value = shared_dynamic_cast($1)) { *(shared_ptr< XdmfRegularGrid > **)&($result) = value ? new shared_ptr< XdmfRegularGrid >(value) : 0; } else if(shared_ptr value = shared_dynamic_cast($1)) { *(shared_ptr< XdmfSet > **)&($result) = value ? new shared_ptr< XdmfSet >(value) : 0; } else if(shared_ptr value = shared_dynamic_cast($1)) { *(shared_ptr< XdmfTime > **)&($result) = value ? new shared_ptr< XdmfTime >(value) : 0; } else if(shared_ptr value = shared_dynamic_cast($1)) { *(shared_ptr< XdmfTopology > **)&($result) = value ? new shared_ptr< XdmfTopology >(value) : 0; } else if(shared_ptr value = shared_dynamic_cast($1)) { *(shared_ptr< XdmfUnstructuredGrid > **)&($result) = value ? new shared_ptr< XdmfUnstructuredGrid >(value) : 0; } else { *(shared_ptr< XdmfItem > **)&($result) = &($1); } } // Ignore multiple inheritance warning #pragma SWIG nowarn=813 // Ignore const overloaded methods %ignore XdmfCurvilinearGrid::getDimensions() const; %ignore XdmfDomain::getCurvilinearGrid(const unsigned int) const; %ignore XdmfDomain::getCurvilinearGrid(const std::string &) const; %ignore XdmfDomain::getGridCollection(const unsigned int) const; %ignore XdmfDomain::getGridCollection(const std::string &) const; %ignore XdmfDomain::getRectilinearGrid(const unsigned int) const; %ignore XdmfDomain::getRectilinearGrid(const std::string &) const; %ignore XdmfDomain::getRegularGrid(const unsigned int) const; %ignore XdmfDomain::getRegularGrid(const std::string &) const; %ignore XdmfDomain::getUnstructuredGrid(const unsigned int) const; %ignore XdmfDomain::getUnstructuredGrid(const std::string &) const; %ignore XdmfGrid::getAttribute(const unsigned int) const; %ignore XdmfGrid::getAttribute(const std::string &) const; %ignore XdmfGrid::getMap() const; %ignore XdmfGrid::getMap(unsigned int const) const; %ignore XdmfGrid::getMap(unsigned int const &) const; %ignore XdmfGrid::getMap(std::string const &) const; %ignore XdmfGrid::getSet(const unsigned int) const; %ignore XdmfGrid::getSet(const std::string &) const; %ignore XdmfGrid::getTime() const; %ignore XdmfRectilinearGrid::getCoordinates(const unsigned int) const; %ignore XdmfRectilinearGrid::getCoordinates() const; %ignore XdmfRectilinearGrid::getDimensions() const; %ignore XdmfRegularGrid::getBrickSize() const; %ignore XdmfRegularGrid::getDimensions() const; %ignore XdmfRegularGrid::getOrigin() const; %ignore XdmfSet::getAttribute(const unsigned int) const; %ignore XdmfSet::getAttribute(const std::string &) const; // Ignore ItemTags %ignore XdmfAttribute::ItemTag; %ignore XdmfCurvilinearGrid::ItemTag; %ignore XdmfDomain::ItemTag; %ignore XdmfGeometry::ItemTag; %ignore XdmfGraph::ItemTag; %ignore XdmfGrid::ItemTag; %ignore XdmfGridCollection::ItemTag; %ignore XdmfMap::ItemTag; %ignore XdmfRectilinearGrid::ItemTag; %ignore XdmfRegularGrid::ItemTag; %ignore XdmfSet::ItemTag; %ignore XdmfTime::ItemTag; %ignore XdmfTopology::ItemTag; %ignore XdmfUnstructuredGrid::ItemTag; %pragma(java) jniclasscode=%{ static { try { System.loadLibrary("XdmfJava"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load for" + "XdmfJava\n" + e); System.exit(1); } } %} #endif /* SWIGJAVA */ #ifdef SWIGPYTHON %include std_set.i %include std_map.i %include std_vector.i %template(XdmfMapNodeIdSet) std::set; %template(XdmfMapNodeIdMap) std::map >; %template(XdmfMapMap) std::map > >; %template(AttributeVector) std::vector >; %template(MapVector) std::vector >; %template(ArrayVector) std::vector >; #ifdef XDMF_BUILD_DSM %pythoncode { import sys from XdmfCore import * if 'mpi4py' in sys.modules.keys(): from XdmfDSM import * } #else %pythoncode { from XdmfCore import * } #endif /* XDMF_BUILD_DSM */ %fragment("XdmfItemCast", "header") { #include PyObject * XdmfItemCast(shared_ptr obj) { PyObject * result; if(shared_ptr attribute = shared_dynamic_cast(obj)) { result = SWIG_NewPointerObj(SWIG_as_voidptr(new shared_ptr(attribute)), SWIGTYPE_p_boost__shared_ptrT_XdmfAttribute_t, SWIG_POINTER_OWN); } else if(shared_ptr gridCurvilinear = shared_dynamic_cast(obj)) { result = SWIG_NewPointerObj(SWIG_as_voidptr(new shared_ptr(gridCurvilinear)), SWIGTYPE_p_boost__shared_ptrT_XdmfCurvilinearGrid_t, SWIG_POINTER_OWN); } else if(shared_ptr gridCollection = shared_dynamic_cast(obj)) { result = SWIG_NewPointerObj(SWIG_as_voidptr(new shared_ptr(gridCollection)), SWIGTYPE_p_boost__shared_ptrT_XdmfGridCollection_t, SWIG_POINTER_OWN); } else if(shared_ptr domain = shared_dynamic_cast(obj)) { result = SWIG_NewPointerObj(SWIG_as_voidptr(new shared_ptr(domain)), SWIGTYPE_p_boost__shared_ptrT_XdmfDomain_t, SWIG_POINTER_OWN); } else if(shared_ptr geometry = shared_dynamic_cast(obj)) { result = SWIG_NewPointerObj(SWIG_as_voidptr(new shared_ptr(geometry)), SWIGTYPE_p_boost__shared_ptrT_XdmfGeometry_t, SWIG_POINTER_OWN); } else if(shared_ptr graph = shared_dynamic_cast(obj)) { result = SWIG_NewPointerObj(SWIG_as_voidptr(new shared_ptr(graph)), SWIGTYPE_p_boost__shared_ptrT_XdmfGraph_t, SWIG_POINTER_OWN); } else if(shared_ptr information = shared_dynamic_cast(obj)) { result = SWIG_NewPointerObj(SWIG_as_voidptr(new shared_ptr(information)), SWIGTYPE_p_boost__shared_ptrT_XdmfInformation_t, SWIG_POINTER_OWN); } else if(shared_ptr map = shared_dynamic_cast(obj)) { result = SWIG_NewPointerObj(SWIG_as_voidptr(new shared_ptr(map)), SWIGTYPE_p_boost__shared_ptrT_XdmfMap_t, SWIG_POINTER_OWN); } else if(shared_ptr gridRectilinear = shared_dynamic_cast(obj)) { result = SWIG_NewPointerObj(SWIG_as_voidptr(new shared_ptr(gridRectilinear)), SWIGTYPE_p_boost__shared_ptrT_XdmfRectilinearGrid_t, SWIG_POINTER_OWN); } else if(shared_ptr gridRegular = shared_dynamic_cast(obj)) { result = SWIG_NewPointerObj(SWIG_as_voidptr(new shared_ptr(gridRegular)), SWIGTYPE_p_boost__shared_ptrT_XdmfRegularGrid_t, SWIG_POINTER_OWN); } else if(shared_ptr set = shared_dynamic_cast(obj)) { result = SWIG_NewPointerObj(SWIG_as_voidptr(new shared_ptr(set)), SWIGTYPE_p_boost__shared_ptrT_XdmfSet_t, SWIG_POINTER_OWN); } else if(shared_ptr time = shared_dynamic_cast(obj)) { result = SWIG_NewPointerObj(SWIG_as_voidptr(new shared_ptr(time)), SWIGTYPE_p_boost__shared_ptrT_XdmfTime_t, SWIG_POINTER_OWN); } else if(shared_ptr topology = shared_dynamic_cast(obj)) { result = SWIG_NewPointerObj(SWIG_as_voidptr(new shared_ptr(topology)), SWIGTYPE_p_boost__shared_ptrT_XdmfTopology_t, SWIG_POINTER_OWN); } else if(shared_ptr gridUnstructured = shared_dynamic_cast(obj)) { result = SWIG_NewPointerObj(SWIG_as_voidptr(new shared_ptr(gridUnstructured)), SWIGTYPE_p_boost__shared_ptrT_XdmfUnstructuredGrid_t, SWIG_POINTER_OWN); } else { result = SWIG_NewPointerObj(SWIG_as_voidptr(new shared_ptr(obj)), SWIGTYPE_p_boost__shared_ptrT_XdmfItem_t, SWIG_POINTER_OWN); } return result; } } %typemap(out, fragment="XdmfItemCast") shared_ptr { $result = XdmfItemCast($1); } %typemap(out, fragment="XdmfItemCast") std::vector > { $result = PyList_New($1.size()); for(std::vector >::size_type i = 0; i < $1.size(); ++i) { PyList_SetItem($result, i, XdmfItemCast($1[i])); } } %extend XdmfAttributeCenter { bool __eq__(const XdmfAttributeCenter * attributeCenter) { return $self == attributeCenter; } } %extend XdmfAttributeType { bool __eq__(const XdmfAttributeType * attributeType) { return $self == attributeType; } } %extend XdmfGeometryType { bool __eq__(const XdmfGeometryType * geometryType) { return $self == geometryType; } } %extend XdmfGridCollectionType { bool __eq__(const XdmfGridCollectionType * gridCollectionType) { return $self == gridCollectionType; } } %extend XdmfSetType { bool __eq__(const XdmfSetType * setType) { return $self == setType; } } %extend XdmfTopologyType { bool __eq__(const XdmfTopologyType * topologyType) { return $self == topologyType; } } #endif /* SWIGPYTHON */ // Shared Pointer Templates %shared_ptr(XdmfAggregate) %shared_ptr(XdmfAttribute) %shared_ptr(XdmfAttributeCenter) %shared_ptr(XdmfAttributeType) %shared_ptr(XdmfCurvilinearGrid) %shared_ptr(XdmfDomain) %shared_ptr(XdmfGeometry) %shared_ptr(XdmfGeometryType) %shared_ptr(XdmfGraph) %shared_ptr(XdmfGrid) %shared_ptr(XdmfGridCollection) %shared_ptr(XdmfGridCollectionType) %shared_ptr(XdmfItemFactory) %shared_ptr(XdmfMap) %shared_ptr(XdmfReader) %shared_ptr(XdmfRectilinearGrid) %shared_ptr(XdmfRegularGrid) %shared_ptr(XdmfSet) %shared_ptr(XdmfSetType) %shared_ptr(XdmfTime) %shared_ptr(XdmfTopology) %shared_ptr(XdmfTopologyType) %shared_ptr(XdmfUnstructuredGrid) %include Xdmf.hpp %include XdmfGrid.hpp %include XdmfAggregate.hpp %include XdmfAttribute.hpp %include XdmfAttributeCenter.hpp %include XdmfAttributeType.hpp %include XdmfCurvilinearGrid.hpp %include XdmfDomain.hpp %include XdmfGeometry.hpp %include XdmfGeometryType.hpp %include XdmfGraph.hpp %include XdmfGridCollection.hpp %include XdmfGridCollectionType.hpp %include XdmfItemFactory.hpp %include XdmfMap.hpp %include XdmfReader.hpp %include XdmfRectilinearGrid.hpp %include XdmfRegularGrid.hpp %include XdmfSet.hpp %include XdmfSetType.hpp %include XdmfTime.hpp %include XdmfTopology.hpp %include XdmfTopologyType.hpp %include XdmfUnstructuredGrid.hpp xdmf-3.0+git20160803/README.md0000640000175000017500000000145613003006557015357 0ustar alastairalastairInstalling XDMF =============== Brief instructions for building XDMF from source code: * Clone the git repository: ```sh git clone git://xdmf.org/Xdmf.git ``` * Create a directory for building the code: ```sh cd Xdmf mkdir build cd build ``` * Prepare the CMake-based build. There are two options: 1. Use the following command and select options using a menu. ```sh ccmake .. ``` 2. Set options on the command line. A typical command line for building XDMF with Python bindings may look like the following: ```sh export XDMF_INSTALL_DIR=/opt/Xdmf/ cmake .. -DCMAKE_INSTALL_PREFIX=${XDMF_INSTALL_DIR} \ -DBUILD_SHARED_LIBS=1 -DXDMF_WRAP_PYTHON=1 -Wno-dev ``` * Build and install XDMF: ```sh make make install ``` xdmf-3.0+git20160803/XdmfTemplate.hpp0000640000175000017500000001532113003006557017177 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfTemplate.hpp */ /* */ /* Author: */ /* Andrew Burns */ /* andrew.j.burns2@us.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2013 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef XDMFTEMPLATE_HPP_ #define XDMFTEMPLATE_HPP_ // C Compatible Includes #include "Xdmf.hpp" #include "XdmfItem.hpp" #include "XdmfItemFactory.hpp" #include "XdmfArray.hpp" #include "XdmfHeavyDataWriter.hpp" #ifdef __cplusplus // Includes /** * @brief Defines a template that can be filled with multiple sets of data. * * An XdmfTemplate defines a structure. The arrays within that structure * are stored if they are not initialized when the structure is first set. * Steps can then be added and references to heavy data are produced and * stored for later retrieval. * * This effectively lets an object have several variations with different * contained data. */ class XDMF_EXPORT XdmfTemplate : public virtual XdmfItem { public: /** * Creates a new instance of the XdmfTemplate object * * @return A constructed XdmfTemplate object. */ static shared_ptr New(); virtual ~XdmfTemplate(); LOKI_DEFINE_VISITABLE(XdmfTemplate, XdmfItem); static const std::string ItemTag; /** * Writes all tracked arrays to heavy data via the provided * heavy data writer then stores the heavy data descriptions. * * @return The ID of the step that was added */ virtual unsigned int addStep(); /** * Clears the current data from the tracked arrays. */ virtual void clearStep(); /** * Gets the XdmfItem that serves as the structure for the template. * * @return The XdmfItem that serves as the structure for the template. */ virtual shared_ptr getBase(); /** * Gets the heavy data writer that is used to write step data to heavy data. * * @return The heavy data writer */ shared_ptr getHeavyDataWriter(); std::map getItemProperties() const; std::string getItemTag() const; /** * Gets the number of steps currently contained within the template. * * @return The number of steps contained within the template. */ unsigned int getNumberSteps() const; /** * Gets the number of arrays tracked across timesteps. * * @return The numer of tracked arrays. */ unsigned int getNumberTrackedArrays() const; /** * Gets the tracked array at the specified index. The index of the array * depends on when the internal visitor encountered the array in question. * * @return The requested array. */ XdmfArray * getTrackedArray(unsigned int index); using XdmfItem::insert; /* * */ virtual void preallocateSteps(unsigned int numSteps); /** * */ virtual void removeStep(unsigned int stepId); /** * Sets the item to define the structure for each step of the template. * * When the base is set all uninitialized arrays are added to * the list of tracked arrays. * * @param newBase The item to serve as the structure. */ virtual void setBase(shared_ptr newBase); /** * Sets the heavy data writer with which the template will write * to heavy data when adding a step. * * @param writer The writer to be used to write to heavy data. */ void setHeavyDataWriter(shared_ptr writer); /** * Reads in the heavy data associated with the provided step id. * * @param stepId The id of the step whose heavy data * is to be read in from file */ virtual void setStep(unsigned int stepId); /** * Adds an array to the list of tracked arrays if that array * is not already there. * * The setBase method automatically sets uninitialized arrays * to be tracked, this can be used to add any missed by setBase. * * @param newArray The array to be tracked. */ virtual void trackArray(shared_ptr newArray); virtual void traverse(const shared_ptr visitor); XdmfTemplate(XdmfTemplate &); protected: XdmfTemplate(); virtual void populateItem(const std::map & itemProperties, const std::vector > & childItems, const XdmfCoreReader * const reader); shared_ptr mHeavyWriter; shared_ptr mBase; std::vector mTrackedArrays; std::vector mDataTypes; std::vector mDataDescriptions; std::vector > > mDataControllers; std::vector > mTrackedArrayTypes; std::vector > mTrackedArrayDims; int mCurrentStep; unsigned int mNumSteps; shared_ptr mItemFactory; private: XdmfTemplate(const XdmfTemplate &); // Not implemented. void operator=(const XdmfTemplate &); // Not implemented. }; #endif #ifdef __cplusplus extern "C" { #endif // C wrappers go here struct XDMFTEMPLATE; // Simply as a typedef to ensure correct typing typedef struct XDMFTEMPLATE XDMFTEMPLATE; XDMF_ITEM_C_CHILD_DECLARE(XdmfTemplate, XDMFTEMPLATE, XDMF) #ifdef __cplusplus } #endif #endif /* XDMFTEMPLATE_HPP_ */ xdmf-3.0+git20160803/XdmfGridCollectionType.hpp0000640000175000017500000001100413003006557021161 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfGridCollectionType.hpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef XDMFGRIDCOLLECTIONTYPE_HPP_ #define XDMFGRIDCOLLECTIONTYPE_HPP_ // C Compatible Includes #include "Xdmf.hpp" #ifdef __cplusplus // Includes #include "XdmfItemProperty.hpp" /** * @brief Property describing the type of an XdmfGridCollection. * * XdmfGridCollectionType is a property used by XdmfGridCollection to * specify what type of collection the XdmfGridCollection contains. A * specific XdmfGridCollectionType can be created by calling one of * the static methods in the class, * i.e. XdmfGridCollectionType::Temporal(). * * Example of use: * * C++ * * @dontinclude ExampleXdmfGridCollection.cpp * @skipline //#initalization * @until //#initalization * @skipline //#getType * @until //#getType * * Python * * @dontinclude XdmfExampleGridCollection.py * @skipline #//initalization * @until #//initalization * @skipline #//getType * @until #//getType * * Xdmf supports the following collection types: * NoCollectionType * Spatial * Temporal */ class XDMF_EXPORT XdmfGridCollectionType : public XdmfItemProperty { public: virtual ~XdmfGridCollectionType(); friend class XdmfGridCollection; friend class XdmfGridTemplate; // Supported XdmfGridCollectionTypes static shared_ptr NoCollectionType(); static shared_ptr Spatial(); static shared_ptr Temporal(); void getProperties(std::map & collectedProperties) const; protected: /** * Protected constructor for XdmfGridCollectionType. The constructor * is protected because all collection types supported by Xdmf * should be accessed through more specific static methods that * construct XdmfGridCollectionType - * i.e. XdmfGridCollectionType::Temporal(). * * @param name the name of the XdmfGridCollectionType to construct. */ XdmfGridCollectionType(const std::string & name); static std::map(*)()> mGridCollectionDefinitions; static void InitTypes(); private: XdmfGridCollectionType(const XdmfGridCollectionType &); // Not implemented. void operator=(const XdmfGridCollectionType &); // Not implemented. static shared_ptr New(const std::map & itemProperties); std::string mName; }; #endif #ifdef __cplusplus extern "C" { #endif // C wrappers go here #define XDMF_GRID_COLLECTION_TYPE_SPATIAL 400 #define XDMF_GRID_COLLECTION_TYPE_TEMPORAL 401 #define XDMF_GRID_COLLECTION_TYPE_NO_COLLECTION_TYPE 402 XDMF_EXPORT int XdmfGridCollectionTypeNoCollectionType(); XDMF_EXPORT int XdmfGridCollectionTypeSpatial(); XDMF_EXPORT int XdmfGridCollectionTypeTemporal(); #ifdef __cplusplus } #endif #endif /* XDMFGRIDCOLLECTIONTYPE_HPP_ */ xdmf-3.0+git20160803/Utilities/0000740000175000017500000000000013003006557016043 5ustar alastairalastairxdmf-3.0+git20160803/Utilities/hdf5/0000740000175000017500000000000013003006557016671 5ustar alastairalastairxdmf-3.0+git20160803/Utilities/hdf5/H5Rprivate.h0000640000175000017500000000250713003006557021041 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * This file contains private information about the H5S module */ #ifndef _H5Rprivate_H #define _H5Rprivate_H #include "H5Rpublic.h" /* Private headers needed by this file */ #include "H5private.h" #define H5R_RESERVED_ATOMS 0 /* Internal data structures */ /* Private functions */ #endif /* _H5Rprivate_H */ xdmf-3.0+git20160803/Utilities/hdf5/H5R.c0000640000175000017500000007716313003006557017453 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #define H5F_PACKAGE /*suppress error about including H5Fpkg */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5R_init_interface #include "H5private.h" /* Generic Functions */ #include "H5Iprivate.h" /* ID Functions */ #include "H5Dprivate.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* Files */ #include "H5Gprivate.h" /* Groups */ #include "H5HGprivate.h" /* Global Heaps */ #include "H5MMprivate.h" /* Memory Management */ #include "H5Rprivate.h" /* References */ #include "H5Sprivate.h" /* Dataspace functions */ #include "H5Tprivate.h" /* Datatypes */ /* Static functions */ static herr_t H5R_create(void *ref, H5G_entry_t *loc, const char *name, H5R_type_t ref_type, H5S_t *space, hid_t dxpl_id); static hid_t H5R_dereference(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, void *_ref); static H5S_t * H5R_get_region(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, void *_ref); static int H5R_get_obj_type(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, void *_ref); /*-------------------------------------------------------------------------- NAME H5R_init_interface -- Initialize interface-specific information USAGE herr_t H5R_init_interface() RETURNS Non-negative on success/Negative on failure DESCRIPTION Initializes any interface-specific data or routines. --------------------------------------------------------------------------*/ static herr_t H5R_init_interface(void) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5R_init_interface); /* Initialize the atom group for the file IDs */ if (H5I_init_group(H5I_REFERENCE, H5I_REFID_HASHSIZE, H5R_RESERVED_ATOMS, (H5I_free_t)NULL)<0) HGOTO_ERROR (H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable to initialize interface"); done: FUNC_LEAVE_NOAPI(ret_value); } /*-------------------------------------------------------------------------- NAME H5R_term_interface PURPOSE Terminate various H5R objects USAGE void H5R_term_interface() RETURNS void DESCRIPTION Release the atom group and any other resources allocated. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS Can't report errors... EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ int H5R_term_interface(void) { int n=0; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5R_term_interface); if (H5_interface_initialize_g) { if ((n=H5I_nmembers(H5I_REFERENCE))) { H5I_clear_group(H5I_REFERENCE, FALSE); } else { H5I_destroy_group(H5I_REFERENCE); H5_interface_initialize_g = 0; n = 1; /*H5I*/ } } FUNC_LEAVE_NOAPI(n); } /*-------------------------------------------------------------------------- NAME H5R_create PURPOSE Creates a particular kind of reference for the user USAGE herr_t H5R_create(ref, loc, name, ref_type, space) void *ref; OUT: Reference created H5G_entry_t *loc; IN: File location used to locate object pointed to const char *name; IN: Name of object at location LOC_ID of object pointed to H5R_type_t ref_type; IN: Type of reference to create H5S_t *space; IN: Dataspace ID with selection, used for Dataset Region references. RETURNS Non-negative on success/Negative on failure DESCRIPTION Creates a particular type of reference specified with REF_TYPE, in the space pointed to by REF. The LOC_ID and NAME are used to locate the object pointed to and the SPACE_ID is used to choose the region pointed to (for Dataset Region references). GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5R_create(void *_ref, H5G_entry_t *loc, const char *name, H5R_type_t ref_type, H5S_t *space, hid_t dxpl_id) { H5G_stat_t sb; /* Stat buffer for retrieving OID */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5R_create); assert(_ref); assert(loc); assert(name); assert(ref_type>H5R_BADTYPE || ref_typefile,&addr,&sb.objno[0]); H5F_addr_encode(loc->file,&p,addr); break; } case H5R_DATASET_REGION: { haddr_t addr; H5HG_t hobjid; /* Heap object ID */ hdset_reg_ref_t *ref=(hdset_reg_ref_t *)_ref; /* Get pointer to correct type of reference struct */ hssize_t buf_size; /* Size of buffer needed to serialize selection */ uint8_t *p; /* Pointer to OID to store */ uint8_t *buf; /* Buffer to store serialized selection in */ unsigned heapid_found; /* Flag for non-zero heap ID found */ unsigned u; /* local index */ /* Set up information for dataset region */ /* Return any previous heap block to the free list if we are garbage collecting */ if(loc->file->shared->gc_ref) { /* Check for an existing heap ID in the reference */ for(u=0, heapid_found=0, p=(uint8_t *)ref; ufile,&addr,&sb.objno[0]); H5F_addr_encode(loc->file,&p,addr); /* Serialize the selection */ if (H5S_SELECT_SERIALIZE(space,p) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "Unable to serialize selection"); /* Save the serialized buffer for later */ H5_CHECK_OVERFLOW(buf_size,hssize_t,size_t); if(H5HG_insert(loc->file,dxpl_id,(size_t)buf_size,buf,&hobjid)<0) HGOTO_ERROR(H5E_REFERENCE, H5E_WRITEERROR, FAIL, "Unable to serialize selection"); /* Serialize the heap ID and index for storage in the file */ p=(uint8_t *)ref; H5F_addr_encode(loc->file,&p,hobjid.addr); INT32ENCODE(p,hobjid.idx); /* Free the buffer we serialized data in */ H5MM_xfree(buf); break; } case H5R_INTERNAL: HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "Internal references are not yet supported"); case H5R_BADTYPE: case H5R_MAXTYPE: default: assert("unknown reference type" && 0); HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "internal error (unknown reference type)"); } /* end switch */ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5R_create() */ /*-------------------------------------------------------------------------- NAME H5Rcreate PURPOSE Creates a particular kind of reference for the user USAGE herr_t H5Rcreate(ref, loc_id, name, ref_type, space_id) void *ref; OUT: Reference created hid_t loc_id; IN: Location ID used to locate object pointed to const char *name; IN: Name of object at location LOC_ID of object pointed to H5R_type_t ref_type; IN: Type of reference to create hid_t space_id; IN: Dataspace ID with selection, used for Dataset Region references. RETURNS Non-negative on success/Negative on failure DESCRIPTION Creates a particular type of reference specified with REF_TYPE, in the space pointed to by REF. The LOC_ID and NAME are used to locate the object pointed to and the SPACE_ID is used to choose the region pointed to (for Dataset Region references). GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t space_id) { H5G_entry_t *loc = NULL; /* File location */ H5S_t *space = NULL; /* Pointer to dataspace containing region */ herr_t ret_value; /* Return value */ FUNC_ENTER_API(H5Rcreate, FAIL); H5TRACE5("e","xisRti",ref,loc_id,name,ref_type,space_id); /* Check args */ if(ref==NULL) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer"); if (NULL==(loc=H5G_loc (loc_id))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location"); if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name given"); if(ref_type<=H5R_BADTYPE || ref_type>=H5R_MAXTYPE) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type"); if(ref_type!=H5R_OBJECT && ref_type!=H5R_DATASET_REGION) HGOTO_ERROR (H5E_ARGS, H5E_UNSUPPORTED, FAIL, "reference type not supported"); if (space_id!=(-1) && (NULL==(space=H5I_object_verify(space_id,H5I_DATASPACE)))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace"); /* Create reference */ if ((ret_value=H5R_create(ref,loc,name,ref_type,space, H5AC_dxpl_id))<0) HGOTO_ERROR (H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable to create reference"); done: FUNC_LEAVE_API(ret_value); } /* end H5Rcreate() */ /*-------------------------------------------------------------------------- NAME H5R_dereference PURPOSE Opens the HDF5 object referenced. USAGE hid_t H5R_dereference(ref) H5F_t *file; IN: File the object being dereferenced is within H5R_type_t ref_type; IN: Type of reference void *ref; IN: Reference to open. RETURNS Valid ID on success, Negative on failure DESCRIPTION Given a reference to some object, open that object and return an ID for that object. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS Currently only set up to work with references to datasets EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static hid_t H5R_dereference(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, void *_ref) { H5D_t *dset; /* Pointer to dataset to open */ H5T_t *type; /* Pointer to datatype to open */ H5G_t *group; /* Pointer to group to open */ H5G_entry_t ent; /* Symbol table entry */ uint8_t *p; /* Pointer to OID to store */ int oid_type; /* type of object being dereferenced */ hid_t ret_value; FUNC_ENTER_NOAPI_NOINIT(H5R_dereference); assert(_ref); assert(ref_type>H5R_BADTYPE || ref_type=H5R_MAXTYPE) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type"); if(_ref==NULL) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer"); /* Get the file pointer from the entry */ file=loc->file; /* Create reference */ if ((ret_value=H5R_dereference(file, H5AC_dxpl_id, ref_type, _ref))<0) HGOTO_ERROR (H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable dereference object"); done: FUNC_LEAVE_API(ret_value); } /* end H5Rdereference() */ /*-------------------------------------------------------------------------- NAME H5R_get_region PURPOSE Retrieves a dataspace with the region pointed to selected. USAGE H5S_t *H5R_get_region(file, ref_type, ref) H5F_t *file; IN: File the object being dereferenced is within H5R_type_t ref_type; UNUSED void *ref; IN: Reference to open. RETURNS Pointer to the dataspace on success, NULL on failure DESCRIPTION Given a reference to some object, creates a copy of the dataset pointed to's dataspace and defines a selection in the copy which is the region pointed to. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static H5S_t * H5R_get_region(H5F_t *file, hid_t dxpl_id, H5R_type_t UNUSED ref_type, void *_ref) { H5G_entry_t ent; /* Symbol table entry */ uint8_t *p; /* Pointer to OID to store */ hdset_reg_ref_t *ref=(hdset_reg_ref_t *)_ref; /* Get pointer to correct type of reference struct */ H5HG_t hobjid; /* Heap object ID */ uint8_t *buf; /* Buffer to store serialized selection in */ H5S_t *ret_value; FUNC_ENTER_NOAPI_NOINIT(H5R_get_region); assert(_ref); assert(ref_type==H5R_DATASET_REGION); assert(file); /* Initialize the symbol table entry */ H5G_ent_reset(&ent); ent.type=H5G_NOTHING_CACHED; ent.file=file; /* Get the heap ID for the dataset region */ p=(uint8_t *)ref; H5F_addr_decode(ent.file,(const uint8_t **)&p,&(hobjid.addr)); INT32DECODE(p,hobjid.idx); /* Get the dataset region from the heap (allocate inside routine) */ if((buf=H5HG_read(ent.file,dxpl_id,&hobjid,NULL))==NULL) HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, NULL, "Unable to read dataset region information"); /* Get the object oid for the dataset */ p=(uint8_t *)buf; H5F_addr_decode(ent.file,(const uint8_t **)&p,&(ent.header)); /* Open and copy the dataset's dataspace */ if ((ret_value=H5S_read(&ent, dxpl_id)) == NULL) HGOTO_ERROR(H5E_DATASPACE, H5E_NOTFOUND, NULL, "not found"); /* Unserialize the selection */ if (H5S_select_deserialize(ret_value,p) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, NULL, "can't deserialize selection"); /* Free the buffer allocated in H5HG_read() */ H5MM_xfree(buf); done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5R_get_region() */ /*-------------------------------------------------------------------------- NAME H5Rget_region PURPOSE Retrieves a dataspace with the region pointed to selected. USAGE hid_t H5Rget_region(id, ref_type, ref) hid_t id; IN: Dataset reference object is in or location ID of object that the dataset is located within. H5R_type_t ref_type; IN: Type of reference to get region of void *ref; IN: Reference to open. RETURNS Valid ID on success, Negative on failure DESCRIPTION Given a reference to some object, creates a copy of the dataset pointed to's dataspace and defines a selection in the copy which is the region pointed to. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ hid_t H5Rget_region(hid_t id, H5R_type_t ref_type, void *_ref) { H5G_entry_t *loc = NULL; /* Symbol table entry */ H5S_t *space = NULL; /* dataspace object */ H5F_t *file=NULL; /* File object */ hid_t ret_value; FUNC_ENTER_API(H5Rget_region, FAIL); H5TRACE3("i","iRtx",id,ref_type,_ref); /* Check args */ if (NULL == (loc = H5G_loc(id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location"); if(ref_type!=H5R_DATASET_REGION) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type"); if(_ref==NULL) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer"); /* Get the file pointer from the entry */ file=loc->file; /* Get the dataspace with the correct region selected */ if ((space=H5R_get_region(file,H5AC_ind_dxpl_id,ref_type,_ref))==NULL) HGOTO_ERROR (H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create dataspace"); /* Atomize */ if ((ret_value=H5I_register (H5I_DATASPACE, space))<0) HGOTO_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace atom"); done: FUNC_LEAVE_API(ret_value); } /* end H5Rget_region() */ #ifdef H5_WANT_H5_V1_4_COMPAT /*-------------------------------------------------------------------------- NAME H5R_get_object_type PURPOSE Retrieves the type of object that an object reference points to USAGE int H5R_get_object_type(file, ref) H5F_t *file; IN: File the object being dereferenced is within void *ref; IN: Reference to query. RETURNS Success: An object type defined in H5Gpublic.h Failure: H5G_UNKNOWN DESCRIPTION Given a reference to some object, this function returns the type of object pointed to. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static int H5R_get_object_type(H5F_t *file, hid_t dxpl_id, void *_ref) { H5G_entry_t ent; /* Symbol table entry */ hobj_ref_t *ref=(hobj_ref_t *)_ref; /* Only object references currently supported */ uint8_t *p; /* Pointer to OID to store */ int ret_value; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5R_get_object_type); assert(ref); assert(file); /* Initialize the symbol table entry */ H5G_ent_reset(&ent); ent.type=H5G_NOTHING_CACHED; ent.file=file; /* Get the object oid */ p=(uint8_t *)ref; H5F_addr_decode(ent.file,(const uint8_t **)&p,&(ent.header)); /* Get the OID type */ ret_value=H5G_get_type(&ent, dxpl_id); #ifdef LATER done: #endif /* LATER */ FUNC_LEAVE_NOAPI(ret_value); } /* end H5R_get_object_type() */ /*-------------------------------------------------------------------------- NAME H5Rget_object_type PURPOSE Retrieves the type of object that an object reference points to USAGE int H5Rget_object_type(id, ref) hid_t id; IN: Dataset reference object is in or location ID of object that the dataset is located within. void *ref; IN: Reference to query. RETURNS Success: An object type defined in H5Gpublic.h Failure: H5G_UNKNOWN DESCRIPTION Given a reference to some object, this function returns the type of object pointed to. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ int H5Rget_object_type(hid_t id, void *_ref) { H5G_entry_t *loc = NULL; /* Symbol table entry */ H5F_t *file=NULL; /* File object */ hid_t ret_value; FUNC_ENTER_API(H5Rget_object_type, H5G_UNKNOWN); H5TRACE2("Is","ix",id,_ref); /* Check args */ if (NULL == (loc = H5G_loc(id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location"); if(_ref==NULL) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, H5G_UNKNOWN, "invalid reference pointer"); /* Get the file pointer from the entry */ file=loc->file; /* Get the object information */ if ((ret_value=H5R_get_object_type(file,H5AC_ind_dxpl_id,_ref))<0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, H5G_UNKNOWN, "unable to determine object type"); done: FUNC_LEAVE_API(ret_value); } /* end H5Rget_object_type() */ #endif /* H5_WANT_H5_V1_4_COMPAT */ /*-------------------------------------------------------------------------- NAME H5R_get_obj_type PURPOSE Retrieves the type of object that an object reference points to USAGE int H5R_get_obj_type(file, ref_type, ref) H5F_t *file; IN: File the object being dereferenced is within H5R_type_t ref_type; IN: Type of reference to query void *ref; IN: Reference to query. RETURNS Success: An object type defined in H5Gpublic.h Failure: H5G_UNKNOWN DESCRIPTION Given a reference to some object, this function returns the type of object pointed to. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static int H5R_get_obj_type(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, void *_ref) { H5G_entry_t ent; /* Symbol table entry */ uint8_t *p; /* Pointer to OID to store */ int ret_value; FUNC_ENTER_NOAPI_NOINIT(H5R_get_obj_type); assert(file); assert(_ref); /* Initialize the symbol table entry */ H5G_ent_reset(&ent); ent.type=H5G_NOTHING_CACHED; ent.file=file; switch(ref_type) { case H5R_OBJECT: { hobj_ref_t *ref=(hobj_ref_t *)_ref; /* Only object references currently supported */ /* Get the object oid */ p=(uint8_t *)ref; H5F_addr_decode(ent.file,(const uint8_t **)&p,&(ent.header)); } /* end case */ break; case H5R_DATASET_REGION: { hdset_reg_ref_t *ref=(hdset_reg_ref_t *)_ref; /* Get pointer to correct type of reference struct */ H5HG_t hobjid; /* Heap object ID */ uint8_t *buf; /* Buffer to store serialized selection in */ /* Get the heap ID for the dataset region */ p=(uint8_t *)ref; H5F_addr_decode(ent.file,(const uint8_t **)&p,&(hobjid.addr)); INT32DECODE(p,hobjid.idx); /* Get the dataset region from the heap (allocate inside routine) */ if((buf=H5HG_read(ent.file,dxpl_id,&hobjid,NULL))==NULL) HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, H5G_UNKNOWN, "Unable to read dataset region information"); /* Get the object oid for the dataset */ p=(uint8_t *)buf; H5F_addr_decode(ent.file,(const uint8_t **)&p,&(ent.header)); /* Free the buffer allocated in H5HG_read() */ H5MM_xfree(buf); } /* end case */ break; case H5R_INTERNAL: HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, H5G_UNKNOWN, "Internal references are not yet supported"); case H5R_BADTYPE: case H5R_MAXTYPE: default: assert("unknown reference type" && 0); HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, H5G_UNKNOWN, "internal error (unknown reference type)"); } /* end switch */ /* Check to make certain that this object hasn't been deleted since the reference was created */ if(H5O_link(&ent,0,dxpl_id)<=0) HGOTO_ERROR(H5E_REFERENCE, H5E_LINKCOUNT, H5G_UNKNOWN, "dereferencing deleted object"); /* Get the OID type */ ret_value=H5G_get_type(&ent,dxpl_id); done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5R_get_obj_type() */ /*-------------------------------------------------------------------------- NAME H5Rget_obj_type PURPOSE Retrieves the type of object that an object reference points to USAGE int H5Rget_obj_type(id, ref_type, ref) hid_t id; IN: Dataset reference object is in or location ID of object that the dataset is located within. H5R_type_t ref_type; IN: Type of reference to query void *ref; IN: Reference to query. RETURNS Success: An object type defined in H5Gpublic.h Failure: H5G_UNKNOWN DESCRIPTION Given a reference to some object, this function returns the type of object pointed to. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ #ifdef H5_WANT_H5_V1_4_COMPAT int H5Rget_obj_type(hid_t id, H5R_type_t ref_type, void *_ref) #else /* H5_WANT_H5_V1_4_COMPAT */ H5G_obj_t H5Rget_obj_type(hid_t id, H5R_type_t ref_type, void *_ref) #endif /* H5_WANT_H5_V1_4_COMPAT */ { H5G_entry_t *loc = NULL; /* Symbol table entry */ H5F_t *file=NULL; /* File object */ #ifdef H5_WANT_H5_V1_4_COMPAT int ret_value; #else /* H5_WANT_H5_V1_4_COMPAT */ H5G_obj_t ret_value; #endif /* H5_WANT_H5_V1_4_COMPAT */ FUNC_ENTER_API(H5Rget_obj_type, H5G_UNKNOWN); H5TRACE3("Is","iRtx",id,ref_type,_ref); /* Check args */ if (NULL == (loc = H5G_loc(id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "not a location"); if(ref_type<=H5R_BADTYPE || ref_type>=H5R_MAXTYPE) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, H5G_UNKNOWN, "invalid reference type"); if(_ref==NULL) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, H5G_UNKNOWN, "invalid reference pointer"); /* Get the file pointer from the entry */ file=loc->file; /* Get the object information */ if ((ret_value= #ifndef H5_WANT_H5_V1_4_COMPAT (H5G_obj_t) #endif /* H5_WANT_H5_V1_4_COMPAT */ H5R_get_obj_type(file,H5AC_ind_dxpl_id,ref_type,_ref))<0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, H5G_UNKNOWN, "unable to determine object type"); done: FUNC_LEAVE_API(ret_value); } /* end H5Rget_obj_type() */ xdmf-3.0+git20160803/Utilities/hdf5/H5Tarray.c0000640000175000017500000002633213003006557020504 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Module Info: This module contains the functionality for array datatypes in * the H5T interface. */ #define H5T_PACKAGE /*suppress error about including H5Tpkg */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5T_init_array_interface #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free Lists */ #include "H5Iprivate.h" /* IDs */ #include "H5Tpkg.h" /* Datatypes */ /* Declare extern the free list for H5T_t's */ H5FL_EXTERN(H5T_t); H5FL_EXTERN(H5T_shared_t); /*-------------------------------------------------------------------------- NAME H5T_init_array_interface -- Initialize interface-specific information USAGE herr_t H5T_init_array_interface() RETURNS Non-negative on success/Negative on failure DESCRIPTION Initializes any interface-specific data or routines. (Just calls H5T_init_iterface currently). --------------------------------------------------------------------------*/ static herr_t H5T_init_array_interface(void) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_init_array_interface); FUNC_LEAVE_NOAPI(H5T_init()); } /* H5T_init_array_interface() */ /*------------------------------------------------------------------------- * Function: H5Tarray_create * * Purpose: Create a new array data type based on the specified BASE_TYPE. * The type is an array with NDIMS dimensionality and the size of the * array is DIMS. The total member size should be relatively small. * PERM is currently unimplemented and unused, but is designed to contain * the dimension permutation from C order. * Array datatypes are currently limited to H5S_MAX_RANK number of * dimensions and must have the number of dimensions set greater than * 0. (i.e. 0 > ndims <= H5S_MAX_RANK) All dimensions sizes must be greater * than 0 also. * * Return: Success: ID of new array data type * * Failure: Negative * * Programmer: Quincey Koziol * Thursday, Oct 26, 2000 * * Modifications: * *------------------------------------------------------------------------- */ hid_t H5Tarray_create(hid_t base_id, int ndims, const hsize_t dim[/* ndims */], const int perm[/* ndims */]) { H5T_t *base = NULL; /* base data type */ H5T_t *dt = NULL; /* new array data type */ int i; /* local index variable */ hid_t ret_value; /* return value */ FUNC_ENTER_API(H5Tarray_create, FAIL); H5TRACE4("i","iIs*h*Is",base_id,ndims,dim,perm); /* Check args */ if (ndims<1 || ndims>H5S_MAX_RANK) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid dimensionality"); if (ndims>0 && !dim) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no dimensions specified"); for(i=0; i0)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "zero-sized dimension specified"); if (NULL==(base=H5I_object_verify(base_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an valid base datatype"); /* Create the actual array datatype */ if ((dt=H5T_array_create(base,ndims,dim,perm))==NULL) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to create datatype"); /* Atomize the type */ if ((ret_value=H5I_register(H5I_DATATYPE, dt))<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype"); done: FUNC_LEAVE_API(ret_value); } /* end H5Tarray_create */ /*------------------------------------------------------------------------- * Function: H5T_array_create * * Purpose: Internal routine to create a new array data type based on the * specified BASE_TYPE. The type is an array with NDIMS dimensionality * and the size of the array is DIMS. PERM is currently unimplemented * and unused, but is designed to contain the dimension permutation from * C order. Array datatypes are currently limited to H5S_MAX_RANK number * of * dimensions. * * Return: Success: ID of new array data type * * Failure: Negative * * Programmer: Quincey Koziol * Thursday, Oct 26, 2000 * * Modifications: * *------------------------------------------------------------------------- */ H5T_t * H5T_array_create(H5T_t *base, int ndims, const hsize_t dim[/* ndims */], const int perm[/* ndims */]) { H5T_t *ret_value = NULL; /*new array data type */ int i; /* local index variable */ FUNC_ENTER_NOAPI(H5T_array_create, NULL); assert(base); assert(ndims>0 && ndims<=H5S_MAX_RANK); assert(dim); /* Build new type */ if(NULL == (ret_value = H5T_alloc())) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") ret_value->shared->type = H5T_ARRAY; /* Copy the base type of the array */ ret_value->shared->parent = H5T_copy(base, H5T_COPY_ALL); /* Set the array parameters */ ret_value->shared->u.array.ndims = ndims; /* Copy the array dimensions & compute the # of elements in the array */ for(i=0, ret_value->shared->u.array.nelem=1; ishared->u.array.dim[i],dim[i],hsize_t,size_t); ret_value->shared->u.array.nelem *= (size_t)dim[i]; } /* end for */ /* Copy the dimension permutations */ for(i=0; ishared->u.array.perm[i] = perm ? perm[i] : i; /* Set the array's size (number of elements * element datatype's size) */ ret_value->shared->size = ret_value->shared->parent->shared->size * ret_value->shared->u.array.nelem; /* * Set the "force conversion" flag if the base datatype indicates */ if(base->shared->force_conv==TRUE) ret_value->shared->force_conv=TRUE; done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5T_array_create */ /*------------------------------------------------------------------------- * Function: H5Tget_array_ndims * * Purpose: Query the number of dimensions for an array datatype. * * Return: Success: Number of dimensions of the array datatype * Failure: Negative * * Programmer: Quincey Koziol * Monday, November 6, 2000 * * Modifications: * *------------------------------------------------------------------------- */ int H5Tget_array_ndims(hid_t type_id) { H5T_t *dt = NULL; /* pointer to array data type */ int ret_value; /* return value */ FUNC_ENTER_API(H5Tget_array_ndims, FAIL); H5TRACE1("Is","i",type_id); /* Check args */ if (NULL==(dt=H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object"); if(dt->shared->type!=H5T_ARRAY) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an array datatype"); /* Retrieve the number of dimensions */ ret_value = H5T_get_array_ndims(dt); done: FUNC_LEAVE_API(ret_value); } /* end H5Tget_array_ndims */ /*------------------------------------------------------------------------- * Function: H5T_get_array_ndims * * Purpose: Private function for H5T_get_array_ndims. Query the number * of dimensions for an array datatype. * * Return: Success: Number of dimensions of the array datatype * Failure: Negative * * Programmer: Raymond Lu * October 10, 2002 * * Modifications: * *------------------------------------------------------------------------- */ int H5T_get_array_ndims(H5T_t *dt) { int ret_value; /* return value */ FUNC_ENTER_NOAPI(H5T_get_array_ndims, FAIL); assert(dt); assert(dt->shared->type==H5T_ARRAY); /* Retrieve the number of dimensions */ ret_value=dt->shared->u.array.ndims; done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5T_get_array_ndims */ /*------------------------------------------------------------------------- * Function: H5Tget_array_dims * * Purpose: Query the sizes of dimensions for an array datatype. * * Return: Success: Number of dimensions of the array type * Failure: Negative * * Programmer: Quincey Koziol * Monday, November 6, 2000 * * Modifications: * *------------------------------------------------------------------------- */ int H5Tget_array_dims(hid_t type_id, hsize_t dims[], int perm[]) { H5T_t *dt = NULL; /* pointer to array data type */ int ret_value; /* return value */ FUNC_ENTER_API(H5Tget_array_dims, FAIL); H5TRACE3("Is","i*h*Is",type_id,dims,perm); /* Check args */ if (NULL==(dt=H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object"); if(dt->shared->type!=H5T_ARRAY) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an array datatype"); /* Retrieve the sizes of the dimensions */ if((ret_value=H5T_get_array_dims(dt, dims, perm))<0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unable to get dimension sizes"); done: FUNC_LEAVE_API(ret_value); } /* end H5Tget_array_dims */ /*------------------------------------------------------------------------- * Function: H5T_get_array_dims * * Purpose: Private function for H5T_get_array_dims. Query the sizes * of dimensions for an array datatype. * * Return: Success: Number of dimensions of the array type * Failure: Negative * * Programmer: Raymond Lu * October 10, 2002 * * Modifications: * *------------------------------------------------------------------------- */ int H5T_get_array_dims(H5T_t *dt, hsize_t dims[], int perm[]) { int ret_value; /* return value */ int i; /* Local index variable */ FUNC_ENTER_NOAPI(H5T_get_array_dims, FAIL); assert(dt); assert(dt->shared->type==H5T_ARRAY); /* Retrieve the sizes of the dimensions */ if(dims) for(i=0; ishared->u.array.ndims; i++) dims[i]=dt->shared->u.array.dim[i]; /* Retrieve the dimension permutations */ if(perm) for(i=0; ishared->u.array.ndims; i++) perm[i]=dt->shared->u.array.perm[i]; /* Pass along the array rank as the return value */ ret_value=dt->shared->u.array.ndims; done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5T_get_array_dims */ xdmf-3.0+git20160803/Utilities/hdf5/H5Zprivate.h0000640000175000017500000000614213003006557021050 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* Programmer: Robb Matzke * Thursday, April 16, 1998 */ #ifndef _H5Zprivate_H #define _H5Zprivate_H /* Include package's public header */ #include "H5Zpublic.h" /* Structure to store information about each filter's parameters */ typedef struct { H5Z_filter_t id; /*filter identification number */ unsigned flags; /*defn and invocation flags */ char *name; /*optional filter name */ size_t cd_nelmts; /*number of elements in cd_values[] */ unsigned *cd_values; /*client data values */ } H5Z_filter_info_t; /* Special parameters for szip compression */ /* [These are aliases for the similar definitions in szlib.h, which we can't * include directly due to the duplication of various symbols with the zlib.h * header file] */ #define H5_SZIP_LSB_OPTION_MASK 8 #define H5_SZIP_MSB_OPTION_MASK 16 #define H5_SZIP_RAW_OPTION_MASK 128 struct H5O_pline_t; /*forward decl*/ /* Internal API routines */ H5_DLL herr_t H5Z_register(const H5Z_class_t *cls); H5_DLL herr_t H5Z_unregister(H5Z_filter_t id); H5_DLL herr_t H5Z_append(struct H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, size_t cd_nelmts, const unsigned int cd_values[]); H5_DLL herr_t H5Z_modify(const struct H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, size_t cd_nelmts, const unsigned int cd_values[]); H5_DLL herr_t H5Z_pipeline(const struct H5O_pline_t *pline, unsigned flags, unsigned *filter_mask/*in,out*/, H5Z_EDC_t edc_read, H5Z_cb_t cb_struct, size_t *nbytes/*in,out*/, size_t *buf_size/*in,out*/, void **buf/*in,out*/); H5_DLL H5Z_class_t *H5Z_find(H5Z_filter_t id); H5_DLL herr_t H5Z_can_apply(hid_t dcpl_id, hid_t type_id); H5_DLL herr_t H5Z_set_local(hid_t dcpl_id, hid_t type_id); H5_DLL H5Z_filter_info_t *H5Z_filter_info(const struct H5O_pline_t *pline, H5Z_filter_t filter); H5_DLL htri_t H5Z_all_filters_avail(const struct H5O_pline_t *pline); H5_DLL herr_t H5Z_delete(struct H5O_pline_t *pline, H5Z_filter_t filter); #endif xdmf-3.0+git20160803/Utilities/hdf5/H5Eprivate.h0000640000175000017500000001323613003006557021025 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Header file for error values, etc. */ #ifndef _H5Eprivate_H #define _H5Eprivate_H #include "H5Epublic.h" /* Private headers needed by this file */ #include "H5private.h" #define H5E_NSLOTS 32 /*number of slots in an error stack */ /* * The list of error messages in the system is kept as an array of * error_code/message pairs, one for major error numbers and another for * minor error numbers. */ typedef struct H5E_major_mesg_t { H5E_major_t error_code; const char *str; } H5E_major_mesg_t; typedef struct H5E_minor_mesg_t { H5E_minor_t error_code; const char *str; } H5E_minor_mesg_t; /* An error stack */ typedef struct H5E_t { int nused; /*num slots currently used in stack */ H5E_error_t slot[H5E_NSLOTS]; /*array of error records */ H5E_auto_t auto_func; /* Function for 'automatic' error reporting */ void *auto_data; /* Callback data for 'automatic' error reporting */ } H5E_t; /* * HERROR macro, used to facilitate error reporting between a FUNC_ENTER() * and a FUNC_LEAVE() within a function body. The arguments are the major * error number, the minor error number, and a description of the error. */ #define HERROR(maj, min, str) H5E_push(maj, min, FUNC, __FILE__, __LINE__, str) /* * HCOMMON_ERROR macro, used by HDONE_ERROR and HGOTO_ERROR * (Shouldn't need to be used outside this header file) */ #define HCOMMON_ERROR(maj, min, str) \ HERROR (maj, min, str); \ (void)H5E_dump_api_stack((int)H5_IS_API(FUNC)); /* * HDONE_ERROR macro, used to facilitate error reporting between a * FUNC_ENTER() and a FUNC_LEAVE() within a function body, but _AFTER_ the * "done:" label. The arguments are * the major error number, the minor error number, a return value, and a * description of the error. * (This macro can also be used to push an error and set the return value * without jumping to any labels) */ #define HDONE_ERROR(maj, min, ret_val, str) { \ HCOMMON_ERROR (maj, min, str); \ ret_value = ret_val; \ } /* * HGOTO_ERROR macro, used to facilitate error reporting between a * FUNC_ENTER() and a FUNC_LEAVE() within a function body. The arguments are * the major error number, the minor error number, the return value, and an * error string. The return value is assigned to a variable `ret_value' and * control branches to the `done' label. */ #define HGOTO_ERROR(maj, min, ret_val, str) { \ HCOMMON_ERROR (maj, min, str); \ HGOTO_DONE (ret_val) \ } /* * HGOTO_DONE macro, used to facilitate normal return between a FUNC_ENTER() * and a FUNC_LEAVE() within a function body. The argument is the return * value which is assigned to the `ret_value' variable. Control branches to * the `done' label. */ #define HGOTO_DONE(ret_val) {ret_value = ret_val; goto done;} /* Library-private functions defined in H5E package */ H5_DLL herr_t H5E_push (H5E_major_t maj_num, H5E_minor_t min_num, const char *func_name, const char *file_name, unsigned line, const char *desc); H5_DLL herr_t H5E_clear (void); H5_DLL herr_t H5E_dump_api_stack (int is_api); /* * Macros handling system error messages as described in C standard. * These macros assume errnum is a valid system error code. */ /* Retrieve the error code description string and push it onto the error * stack. */ #define HSYS_ERROR(errnum){ \ HERROR(H5E_INTERNAL, H5E_SYSERRSTR, HDstrerror(errnum)); \ } #define HSYS_DONE_ERROR(majorcode, minorcode, retcode, str){ \ HSYS_ERROR(errno); \ HDONE_ERROR(majorcode, minorcode, retcode, str); \ } #define HSYS_GOTO_ERROR(majorcode, minorcode, retcode, str){ \ HSYS_ERROR(errno); \ HGOTO_ERROR(majorcode, minorcode, retcode, str); \ } #ifdef H5_HAVE_PARALLEL /* * MPI error handling macros. */ extern char H5E_mpi_error_str[MPI_MAX_ERROR_STRING]; extern int H5E_mpi_error_str_len; #define HMPI_ERROR(mpierr){ \ MPI_Error_string(mpierr, H5E_mpi_error_str, &H5E_mpi_error_str_len); \ HERROR(H5E_INTERNAL, H5E_MPIERRSTR, H5E_mpi_error_str); \ } #define HMPI_DONE_ERROR(retcode, str, mpierr){ \ HMPI_ERROR(mpierr); \ HDONE_ERROR(H5E_INTERNAL, H5E_MPI, retcode, str); \ } #define HMPI_GOTO_ERROR(retcode, str, mpierr){ \ HMPI_ERROR(mpierr); \ HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, retcode, str); \ } #endif #endif xdmf-3.0+git20160803/Utilities/hdf5/H5FDstdio.c0000640000175000017500000007120213003006557020572 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Robb Matzke * Wednesday, October 22, 1997 * * Purpose: This is the Posix stdio.h I/O subclass of H5Flow. * It also serves as an example of coding a simple file driver, * therefore, it should not use any non-public definitions. * * Notes: Ported to the new H5FD architecture on 10/18/99 - QAK * */ #include #include #include /* Disable certain warnings in PC-Lint: */ /*lint --emacro( {534, 830}, H5P_FILE_ACCESS) */ /*lint --emacro( {534, 830}, H5F_ACC_RDWR, H5F_ACC_EXCL) */ /*lint -esym( 534, H5Eclear, H5Epush) */ #include "hdf5.h" #ifdef H5_HAVE_STDIO_H #include #endif #ifdef H5_HAVE_UNISTD_H #include #endif #ifdef WIN32 #include #include /* This is not defined in the Windows header files */ #ifndef F_OK #define F_OK 00 #endif #endif #ifdef MAX #undef MAX #endif /* MAX */ #define MAX(X,Y) ((X)>(Y)?(X):(Y)) /* The driver identification number, initialized at runtime */ static hid_t H5FD_STDIO_g = 0; /* File operations */ typedef enum { H5FD_STDIO_OP_UNKNOWN=0, H5FD_STDIO_OP_READ=1, H5FD_STDIO_OP_WRITE=2, H5FD_STDIO_OP_SEEK=3 } H5FD_stdio_file_op; /* * The description of a file belonging to this driver. The `eoa' and `eof' * determine the amount of hdf5 address space in use and the high-water mark * of the file (the current size of the underlying Unix file). The `pos' * value is used to eliminate file position updates when they would be a * no-op. Unfortunately we've found systems that use separate file position * indicators for reading and writing so the lseek can only be eliminated if * the current operation is the same as the previous operation. When opening * a file the `eof' will be set to the current file size, `eoa' will be set * to zero, `pos' will be set to H5F_ADDR_UNDEF (as it is when an error * occurs), and `op' will be set to H5F_OP_UNKNOWN. */ typedef struct H5FD_stdio_t { H5FD_t pub; /*public stuff, must be first */ FILE * fp; /*the file handle */ haddr_t eoa; /*end of allocated region */ haddr_t eof; /*end of file; current file size*/ haddr_t pos; /*current file I/O position */ H5FD_stdio_file_op op; /*last operation */ unsigned write_access; /* Flag to indicate the file was opened with write access */ #ifndef WIN32 /* * On most systems the combination of device and i-node number uniquely * identify a file. */ dev_t device; /*file device number */ ino_t inode; /*file i-node number */ #else /* * On WIN32 the low-order word of a unique identifier associated with the * file and the volume serial number uniquely identify a file. This number * (which, both? -rpm) may change when the system is restarted or when the * file is opened. After a process opens a file, the identifier is * constant until the file is closed. An application can use this * identifier and the volume serial number to determine whether two * handles refer to the same file. */ DWORD fileindexlo; DWORD fileindexhi; #endif } H5FD_stdio_t; /* * These macros check for overflow of various quantities. These macros * assume that file_offset_t is signed and haddr_t and size_t are unsigned. * * ADDR_OVERFLOW: Checks whether a file address of type `haddr_t' * is too large to be represented by the second argument * of the file seek function. * * SIZE_OVERFLOW: Checks whether a buffer size of type `hsize_t' is too * large to be represented by the `size_t' type. * * REGION_OVERFLOW: Checks whether an address and size pair describe data * which can be addressed entirely by the second * argument of the file seek function. */ /* adding for windows NT filesystem support. */ #define MAXADDR (((haddr_t)1<<(8*sizeof(file_offset_t)-1))-1) #define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || ((A) & ~(haddr_t)MAXADDR)) #define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) #define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ HADDR_UNDEF==(A)+(Z) || (file_offset_t)((A)+(Z))<(file_offset_t)(A)) #ifdef H5_HAVE_LSEEK64 # define file_offset_t off64_t # define file_truncate ftruncate64 #elif defined (WIN32) && !defined(__MWERKS__) # /*MSVC*/ # define file_offset_t __int64 # define file_truncate _chsize #else # define file_offset_t off_t # define file_truncate ftruncate #endif /* Prototypes */ static H5FD_t *H5FD_stdio_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); static herr_t H5FD_stdio_close(H5FD_t *lf); static int H5FD_stdio_cmp(const H5FD_t *_f1, const H5FD_t *_f2); static herr_t H5FD_stdio_query(const H5FD_t *_f1, unsigned long *flags); static haddr_t H5FD_stdio_get_eoa(H5FD_t *_file); static herr_t H5FD_stdio_set_eoa(H5FD_t *_file, haddr_t addr); static haddr_t H5FD_stdio_get_eof(H5FD_t *_file); static herr_t H5FD_stdio_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle); static herr_t H5FD_stdio_read(H5FD_t *lf, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, void *buf); static herr_t H5FD_stdio_write(H5FD_t *lf, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, const void *buf); static herr_t H5FD_stdio_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing); static const H5FD_class_t H5FD_stdio_g = { "stdio", /*name */ MAXADDR, /*maxaddr */ H5F_CLOSE_WEAK, /* fc_degree */ NULL, /*sb_size */ NULL, /*sb_encode */ NULL, /*sb_decode */ 0, /*fapl_size */ NULL, /*fapl_get */ NULL, /*fapl_copy */ NULL, /*fapl_free */ 0, /*dxpl_size */ NULL, /*dxpl_copy */ NULL, /*dxpl_free */ H5FD_stdio_open, /*open */ H5FD_stdio_close, /*close */ H5FD_stdio_cmp, /*cmp */ H5FD_stdio_query, /*query */ NULL, /*alloc */ NULL, /*free */ H5FD_stdio_get_eoa, /*get_eoa */ H5FD_stdio_set_eoa, /*set_eoa */ H5FD_stdio_get_eof, /*get_eof */ H5FD_stdio_get_handle, /*get_handle */ H5FD_stdio_read, /*read */ H5FD_stdio_write, /*write */ H5FD_stdio_flush, /*flush */ NULL, /*lock */ NULL, /*unlock */ H5FD_FLMAP_SINGLE /*fl_map */ }; /*------------------------------------------------------------------------- * Function: H5FD_stdio_init * * Purpose: Initialize this driver by registering the driver with the * library. * * Return: Success: The driver ID for the stdio driver. * * Failure: Negative. * * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: * Stolen from the sec2 driver - QAK, 10/18/99 * *------------------------------------------------------------------------- */ hid_t H5FD_stdio_init(void) { /* Clear the error stack */ H5Eclear(); if (H5I_VFL!=H5Iget_type(H5FD_STDIO_g)) H5FD_STDIO_g = H5FDregister(&H5FD_stdio_g); return(H5FD_STDIO_g); } /*--------------------------------------------------------------------------- * Function: H5FD_stdio_term * * Purpose: Shut down the VFD * * Return: * * Programmer: Quincey Koziol * Friday, Jan 30, 2004 * * Modification: * *--------------------------------------------------------------------------- */ void H5FD_stdio_term(void) { /* Reset VFL ID */ H5FD_STDIO_g=0; } /* end H5FD_stdio_term() */ /*------------------------------------------------------------------------- * Function: H5Pset_fapl_stdio * * Purpose: Modify the file access property list to use the H5FD_STDIO * driver defined in this source file. There are no driver * specific properties. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Thursday, February 19, 1998 * * Modifications: * Stolen from the sec2 driver - QAK, 10/18/99 * *------------------------------------------------------------------------- */ herr_t H5Pset_fapl_stdio(hid_t fapl_id) { static const char *func="H5FDset_fapl_stdio"; /*for error reporting*/ /*NO TRACE*/ /* Clear the error stack */ H5Eclear(); if(0 == H5Pisa_class(fapl_id, H5P_FILE_ACCESS)) H5Epush_ret(func, H5E_PLIST, H5E_BADTYPE, "not a file access property list", -1) return H5Pset_driver(fapl_id, H5FD_STDIO, NULL); } /*------------------------------------------------------------------------- * Function: H5FD_stdio_open * * Purpose: Create and/or opens a Standard C file as an HDF5 file. * * Bugs: H5F_ACC_EXCL has a race condition. (? -QAK) * * Errors: * IO CANTOPENFILE File doesn't exist and CREAT wasn't * specified. * IO CANTOPENFILE Fopen failed. * IO FILEEXISTS File exists but CREAT and EXCL were * specified. * * Return: Success: A pointer to a new file data structure. The * public fields will be initialized by the * caller, which is always H5FD_open(). * * Failure: NULL * * Programmer: Robb Matzke * Wednesday, October 22, 1997 * * Modifications: * Ported to VFL/H5FD layer - QAK, 10/18/99 * *------------------------------------------------------------------------- */ static H5FD_t * H5FD_stdio_open( const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { FILE *f = NULL; unsigned write_access=0; /* File opened with write access? */ H5FD_stdio_t *file=NULL; static const char *func="H5FD_stdio_open"; /* Function Name for error reporting */ #ifdef WIN32 HFILE filehandle; struct _BY_HANDLE_FILE_INFORMATION fileinfo; int fd; #else /* WIN32 */ struct stat sb; #endif /* WIN32 */ /* Sanity check on file offsets */ assert(sizeof(file_offset_t)>=sizeof(size_t)); /* Shut compiler up */ fapl_id=fapl_id; /* Clear the error stack */ H5Eclear(); /* Check arguments */ if (!name || !*name) H5Epush_ret(func, H5E_ARGS, H5E_BADVALUE, "invalid file name", NULL) if (0==maxaddr || HADDR_UNDEF==maxaddr) H5Epush_ret(func, H5E_ARGS, H5E_BADRANGE, "bogus maxaddr", NULL) if (ADDR_OVERFLOW(maxaddr)) H5Epush_ret(func, H5E_ARGS, H5E_OVERFLOW, "maxaddr too large", NULL) if (access(name, F_OK) < 0) { if ((flags & H5F_ACC_CREAT) && (flags & H5F_ACC_RDWR)) { f = fopen(name, "wb+"); write_access=1; /* Note the write access */ } else H5Epush_ret(func, H5E_IO, H5E_CANTOPENFILE, "file doesn't exist and CREAT wasn't specified", NULL) } else if ((flags & H5F_ACC_CREAT) && (flags & H5F_ACC_EXCL)) { H5Epush_ret(func, H5E_IO, H5E_FILEEXISTS, "file exists but CREAT and EXCL were specified", NULL) } else if (flags & H5F_ACC_RDWR) { if (flags & H5F_ACC_TRUNC) f = fopen(name, "wb+"); else f = fopen(name, "rb+"); write_access=1; /* Note the write access */ } else { f = fopen(name, "rb"); } if (!f) H5Epush_ret(func, H5E_IO, H5E_CANTOPENFILE, "fopen failed", NULL) /* Build the return value */ if (NULL==(file = calloc(1,sizeof(H5FD_stdio_t)))) H5Epush_ret(func, H5E_RESOURCE, H5E_NOSPACE, "memory allocation failed", NULL) file->fp = f; file->op = H5FD_STDIO_OP_SEEK; file->pos = HADDR_UNDEF; file->write_access=write_access; /* Note the write_access for later */ if (fseek(file->fp, 0, SEEK_END) < 0) { file->op = H5FD_STDIO_OP_UNKNOWN; } else { long x = ftell (file->fp); assert (x>=0); file->eof = (haddr_t)x; } /* The unique key */ #ifdef WIN32 /*#error "Needs correct fileindexhi & fileindexlo, code below is from sec2 driver"*/ fd = _fileno(f); filehandle = _get_osfhandle(fd); (void)GetFileInformationByHandle((HANDLE)filehandle, &fileinfo); file->fileindexhi = fileinfo.nFileIndexHigh; file->fileindexlo = fileinfo.nFileIndexLow; #else fstat(fileno(file->fp), &sb); file->device = sb.st_dev; file->inode = sb.st_ino; #endif return((H5FD_t*)file); } /* end H5FD_stdio_open() */ /*------------------------------------------------------------------------- * Function: H5F_stdio_close * * Purpose: Closes a file. * * Errors: * IO CLOSEERROR Fclose failed. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Wednesday, October 22, 1997 * * Modifications: * Ported to VFL/H5FD layer - QAK, 10/18/99 * *------------------------------------------------------------------------- */ static herr_t H5FD_stdio_close(H5FD_t *_file) { H5FD_stdio_t *file = (H5FD_stdio_t*)_file; static const char *func="H5FD_stdio_close"; /* Function Name for error reporting */ /* Clear the error stack */ H5Eclear(); if (fclose(file->fp) < 0) H5Epush_ret(func, H5E_IO, H5E_CLOSEERROR, "fclose failed", -1) free(file); return(0); } /*------------------------------------------------------------------------- * Function: H5FD_stdio_cmp * * Purpose: Compares two files belonging to this driver using an * arbitrary (but consistent) ordering. * * Return: Success: A value like strcmp() * * Failure: never fails (arguments were checked by the * caller). * * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: * Stolen from the sec2 driver - QAK, 10/18/99 * *------------------------------------------------------------------------- */ static int H5FD_stdio_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { const H5FD_stdio_t *f1 = (const H5FD_stdio_t*)_f1; const H5FD_stdio_t *f2 = (const H5FD_stdio_t*)_f2; /* Clear the error stack */ H5Eclear(); #ifdef WIN32 if (f1->fileindexhi < f2->fileindexhi) return -1; if (f1->fileindexhi > f2->fileindexhi) return 1; if (f1->fileindexlo < f2->fileindexlo) return -1; if (f1->fileindexlo > f2->fileindexlo) return 1; #else #ifdef H5_DEV_T_IS_SCALAR if (f1->device < f2->device) return -1; if (f1->device > f2->device) return 1; #else /* H5_DEV_T_IS_SCALAR */ /* If dev_t isn't a scalar value on this system, just use memcmp to * determine if the values are the same or not. The actual return value * shouldn't really matter... */ if(memcmp(&(f1->device),&(f2->device),sizeof(dev_t))<0) return -1; if(memcmp(&(f1->device),&(f2->device),sizeof(dev_t))>0) return 1; #endif /* H5_DEV_T_IS_SCALAR */ if (f1->inode < f2->inode) return -1; if (f1->inode > f2->inode) return 1; #endif return 0; } /*------------------------------------------------------------------------- * Function: H5FD_stdio_query * * Purpose: Set the flags that this VFL driver is capable of supporting. * (listed in H5FDpublic.h) * * Return: Success: non-negative * * Failure: negative * * Programmer: Quincey Koziol * Friday, August 25, 2000 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_stdio_query(const H5FD_t *_f, unsigned long *flags /* out */) { /* Shut compiler up */ _f=_f; /* Set the VFL feature flags that this driver supports */ if(flags) { *flags = 0; *flags|=H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ *flags|=H5FD_FEAT_ACCUMULATE_METADATA; /* OK to accumulate metadata for faster writes */ *flags|=H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ *flags|=H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ } return(0); } /*------------------------------------------------------------------------- * Function: H5FD_stdio_get_eoa * * Purpose: Gets the end-of-address marker for the file. The EOA marker * is the first address past the last byte allocated in the * format address space. * * Return: Success: The end-of-address marker. * * Failure: HADDR_UNDEF * * Programmer: Robb Matzke * Monday, August 2, 1999 * * Modifications: * Stolen from the sec2 driver - QAK, 10/18/99 * *------------------------------------------------------------------------- */ static haddr_t H5FD_stdio_get_eoa(H5FD_t *_file) { H5FD_stdio_t *file = (H5FD_stdio_t*)_file; /* Clear the error stack */ H5Eclear(); return(file->eoa); } /*------------------------------------------------------------------------- * Function: H5FD_stdio_set_eoa * * Purpose: Set the end-of-address marker for the file. This function is * called shortly after an existing HDF5 file is opened in order * to tell the driver where the end of the HDF5 data is located. * * Return: Success: 0 * * Failure: -1 * * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: * Stolen from the sec2 driver - QAK, 10/18/99 * *------------------------------------------------------------------------- */ static herr_t H5FD_stdio_set_eoa(H5FD_t *_file, haddr_t addr) { H5FD_stdio_t *file = (H5FD_stdio_t*)_file; /* Clear the error stack */ H5Eclear(); file->eoa = addr; return(0); } /*------------------------------------------------------------------------- * Function: H5FD_stdio_get_eof * * Purpose: Returns the end-of-file marker, which is the greater of * either the Unix end-of-file or the HDF5 end-of-address * markers. * * Return: Success: End of file address, the first address past * the end of the "file", either the Unix file * or the HDF5 file. * * Failure: HADDR_UNDEF * * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: * Stolen from the sec2 driver - QAK, 10/18/99 * *------------------------------------------------------------------------- */ static haddr_t H5FD_stdio_get_eof(H5FD_t *_file) { H5FD_stdio_t *file = (H5FD_stdio_t*)_file; /* Clear the error stack */ H5Eclear(); return(MAX(file->eof, file->eoa)); } /*------------------------------------------------------------------------- * Function: H5FD_stdio_get_handle * * Purpose: Returns the file handle of stdio file driver. * * Returns: Non-negative if succeed or negative if fails. * * Programmer: Raymond Lu * Sept. 16, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_stdio_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle) { H5FD_stdio_t *file = (H5FD_stdio_t *)_file; static const char *func="H5FD_stdio_get_handle"; /* Function Name for error reporting */ /* Shut compiler up */ fapl=fapl; /* Clear the error stack */ H5Eclear(); *file_handle = &(file->fp); if(*file_handle==NULL) H5Epush_ret(func, H5E_IO, H5E_WRITEERROR, "get handle failed", -1) return(0); } /*------------------------------------------------------------------------- * Function: H5F_stdio_read * * Purpose: Reads SIZE bytes beginning at address ADDR in file LF and * places them in buffer BUF. Reading past the logical or * physical end of file returns zeros instead of failing. * * Errors: * IO READERROR Fread failed. * IO SEEKERROR Fseek failed. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Wednesday, October 22, 1997 * * Modifications: * June 2, 1998 Albert Cheng * Added xfer_mode argument * * Ported to VFL/H5FD layer - QAK, 10/18/99 * *------------------------------------------------------------------------- */ static herr_t H5FD_stdio_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, void *buf/*out*/) { size_t n; H5FD_stdio_t *file = (H5FD_stdio_t*)_file; static const char *func="H5FD_stdio_read"; /* Function Name for error reporting */ /* Shut compiler up */ type=type; dxpl_id=dxpl_id; /* Clear the error stack */ H5Eclear(); /* Check for overflow */ if (HADDR_UNDEF==addr) H5Epush_ret (func, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1) if (REGION_OVERFLOW(addr, size)) H5Epush_ret (func, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1) if (addr+size>file->eoa) H5Epush_ret (func, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1) /* Check easy cases */ if (0 == size) return(0); if ((haddr_t)addr >= file->eof) { memset(buf, 0, size); return(0); } /* * Seek to the correct file position. */ if (!(file->op == H5FD_STDIO_OP_READ || file->op==H5FD_STDIO_OP_SEEK) || file->pos != addr) { if (fseek(file->fp, (long)addr, SEEK_SET) < 0) { file->op = H5FD_STDIO_OP_UNKNOWN; file->pos = HADDR_UNDEF; H5Epush_ret(func, H5E_IO, H5E_SEEKERROR, "fseek failed", -1) } file->pos = addr; } /* * Read zeros past the logical end of file (physical is handled below) */ if (addr + size > file->eof) { size_t nbytes = (size_t) (addr + size - file->eof); memset((unsigned char *)buf + size - nbytes, 0, nbytes); size -= nbytes; } /* * Read the data. Since we're reading single-byte values, a partial read * will advance the file position by N. If N is zero or an error * occurs then the file position is undefined. */ n = fread(buf, 1, size, file->fp); if (n == 0 && ferror(file->fp)) { file->op = H5FD_STDIO_OP_UNKNOWN; file->pos = HADDR_UNDEF; H5Epush_ret(func, H5E_IO, H5E_READERROR, "fread failed", -1) } else if (n < size) { memset((unsigned char *)buf + n, 0, (size - n)); } /* * Update the file position data. */ file->op = H5FD_STDIO_OP_READ; file->pos = addr+n; /*checked for overflow above*/ return(0); } /*------------------------------------------------------------------------- * Function: H5F_stdio_write * * Purpose: Writes SIZE bytes from the beginning of BUF into file LF at * file address ADDR. * * Errors: * IO SEEKERROR Fseek failed. * IO WRITEERROR Fwrite failed. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Wednesday, October 22, 1997 * * Modifications: * June 2, 1998 Albert Cheng * Added xfer_mode argument * * Ported to VFL/H5FD layer - QAK, 10/18/99 * *------------------------------------------------------------------------- */ static herr_t H5FD_stdio_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, const void *buf) { H5FD_stdio_t *file = (H5FD_stdio_t*)_file; static const char *func="H5FD_stdio_write"; /* Function Name for error reporting */ /* Shut compiler up */ dxpl_id=dxpl_id; type=type; /* Clear the error stack */ H5Eclear(); /* Check for overflow conditions */ if (HADDR_UNDEF==addr) H5Epush_ret (func, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1) if (REGION_OVERFLOW(addr, size)) H5Epush_ret (func, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1) if (addr+size>file->eoa) H5Epush_ret (func, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1) /* * Seek to the correct file position. */ if ((file->op != H5FD_STDIO_OP_WRITE && file->op != H5FD_STDIO_OP_SEEK) || file->pos != addr) { if (fseek(file->fp, (long)addr, SEEK_SET) < 0) { file->op = H5FD_STDIO_OP_UNKNOWN; file->pos = HADDR_UNDEF; H5Epush_ret(func, H5E_IO, H5E_SEEKERROR, "fseek failed", -1) } file->pos = addr; } /* * Write the buffer. On successful return, the file position will be * advanced by the number of bytes read. Otherwise nobody knows where it * is. */ if (size != fwrite(buf, 1, size, file->fp)) { file->op = H5FD_STDIO_OP_UNKNOWN; file->pos = HADDR_UNDEF; H5Epush_ret(func, H5E_IO, H5E_WRITEERROR, "fwrite failed", -1) } /* * Update seek optimizing data. */ file->op = H5FD_STDIO_OP_WRITE; file->pos = addr + size; /* Update EOF if necessary */ if (file->pos>file->eof) file->eof = file->pos; return(0); } /*------------------------------------------------------------------------- * Function: H5F_stdio_flush * * Purpose: Makes sure that all data is on disk. * * Errors: * IO SEEKERROR fseek failed. * IO WRITEERROR fflush or fwrite failed. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Wednesday, October 22, 1997 * * Modifications: * Ported to VFL/H5FD layer - QAK, 10/18/99 * *------------------------------------------------------------------------- */ static herr_t H5FD_stdio_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing) { H5FD_stdio_t *file = (H5FD_stdio_t*)_file; static const char *func="H5FD_stdio_flush"; /* Function Name for error reporting */ /* Shut compiler up */ dxpl_id=dxpl_id; /* Clear the error stack */ H5Eclear(); /* Only try to flush the file if we have write access */ if(file->write_access) { /* Makes sure that the true file size is the same as the end-of-address. */ if (file->eoa!=file->eof) { #ifdef WIN32 int fd=_fileno(file->fp); /* File descriptor for HDF5 file */ HFILE filehandle; /* Windows file handle */ LARGE_INTEGER li; /* 64-bit integer for SetFilePointer() call */ /* Map the posix file handle to a Windows file handle */ filehandle = _get_osfhandle(fd); /* Translate 64-bit integers into form Windows wants */ /* [This algorithm is from the Windows documentation for SetFilePointer()] */ li.QuadPart = (LONGLONG)file->eoa; (void)SetFilePointer((HANDLE)filehandle,li.LowPart,&li.HighPart,FILE_BEGIN); if(SetEndOfFile((HANDLE)filehandle)==0) H5Epush_ret(func, H5E_IO, H5E_SEEKERROR, "unable to extend file properly", -1) #else /* WIN32 */ int fd=fileno(file->fp); /* File descriptor for HDF5 file */ if (-1==file_truncate(fd, (file_offset_t)file->eoa)) H5Epush_ret(func, H5E_IO, H5E_SEEKERROR, "unable to extend file properly", -1) #endif /* WIN32 */ /* Update the eof value */ file->eof = file->eoa; /* Reset last file I/O information */ file->pos = HADDR_UNDEF; file->op = H5FD_STDIO_OP_UNKNOWN; } /* end if */ /* * Flush */ if(!closing) { if (fflush(file->fp) < 0) H5Epush_ret(func, H5E_IO, H5E_WRITEERROR, "fflush failed", -1) } /* end if */ } /* end if */ else { /* Double-check for problems */ if (file->eoa>file->eof) H5Epush_ret(func, H5E_IO, H5E_TRUNCATED, "eoa>eof!", -1) } /* end else */ return(0); } #ifdef _H5private_H /* * This is not related to the functionality of the driver code. * It is added here to trigger warning if HDF5 private definitions are included * by mistake. The code should use only HDF5 public API and definitions. */ #error "Do not use HDF5 private definitions" #endif xdmf-3.0+git20160803/Utilities/hdf5/H5Sall.c0000640000175000017500000006400213003006557020131 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Quincey Koziol * Tuesday, June 16, 1998 * * Purpose: "All" selection data space I/O functions. */ #define H5S_PACKAGE /*suppress error about including H5Spkg */ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Iprivate.h" /* ID Functions */ #include "H5Spkg.h" /* Dataspace functions */ #include "H5Vprivate.h" /* Vector functions */ /* Static function prototypes */ /* Selection callbacks */ static herr_t H5S_all_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection); static herr_t H5S_all_get_seq_list(const H5S_t *space, unsigned flags, H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes, size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len); static herr_t H5S_all_release(H5S_t *space); static htri_t H5S_all_is_valid(const H5S_t *space); static hssize_t H5S_all_serial_size(const H5S_t *space); static herr_t H5S_all_serialize(const H5S_t *space, uint8_t *buf); static herr_t H5S_all_deserialize(H5S_t *space, const uint8_t *buf); static herr_t H5S_all_bounds(const H5S_t *space, hsize_t *start, hsize_t *end); static htri_t H5S_all_is_contiguous(const H5S_t *space); static htri_t H5S_all_is_single(const H5S_t *space); static htri_t H5S_all_is_regular(const H5S_t *space); static herr_t H5S_all_iter_init(H5S_sel_iter_t *iter, const H5S_t *space); /* Selection iteration callbacks */ static herr_t H5S_all_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords); static herr_t H5S_all_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end); static hsize_t H5S_all_iter_nelmts(const H5S_sel_iter_t *iter); static htri_t H5S_all_iter_has_next_block(const H5S_sel_iter_t *iter); static herr_t H5S_all_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem); static herr_t H5S_all_iter_next_block(H5S_sel_iter_t *sel_iter); static herr_t H5S_all_iter_release(H5S_sel_iter_t *sel_iter); /* Selection properties for "all" selections */ const H5S_select_class_t H5S_sel_all[1] = {{ H5S_SEL_ALL, /* Methods on selection */ H5S_all_copy, H5S_all_get_seq_list, H5S_all_release, H5S_all_is_valid, H5S_all_serial_size, H5S_all_serialize, H5S_all_deserialize, H5S_all_bounds, H5S_all_is_contiguous, H5S_all_is_single, H5S_all_is_regular, H5S_all_iter_init, }}; /* Iteration properties for "all" selections */ static const H5S_sel_iter_class_t H5S_sel_iter_all[1] = {{ H5S_SEL_ALL, /* Methods on selection iterator */ H5S_all_iter_coords, H5S_all_iter_block, H5S_all_iter_nelmts, H5S_all_iter_has_next_block, H5S_all_iter_next, H5S_all_iter_next_block, H5S_all_iter_release, }}; /*------------------------------------------------------------------------- * Function: H5S_all_iter_init * * Purpose: Initializes iteration information for "all" selection. * * Return: non-negative on success, negative on failure. * * Programmer: Quincey Koziol * Tuesday, June 16, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5S_all_iter_init (H5S_sel_iter_t *iter, const H5S_t *space) { FUNC_ENTER_NOAPI_NOFUNC(H5S_all_iter_init); /* Check args */ assert (space && H5S_SEL_ALL==H5S_GET_SELECT_TYPE(space)); assert (iter); /* Initialize the number of elements to iterate over */ iter->elmt_left=H5S_GET_SELECT_NPOINTS(space); /* Start at the upper left location */ iter->u.all.elmt_offset=0; iter->u.all.byte_offset=0; /* Initialize type of selection iterator */ iter->type=H5S_sel_iter_all; FUNC_LEAVE_NOAPI(SUCCEED); } /* H5S_all_iter_init() */ /*------------------------------------------------------------------------- * Function: H5S_all_iter_coords * * Purpose: Retrieve the current coordinates of iterator for current * selection * * Return: non-negative on success, negative on failure * * Programmer: Quincey Koziol * Tuesday, April 22, 2003 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5S_all_iter_coords (const H5S_sel_iter_t *iter, hsize_t *coords) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5S_all_iter_coords); /* Check args */ assert (iter); assert (coords); /* Calculate the coordinates for the current iterator offset */ if(H5V_array_calc(iter->u.all.elmt_offset,iter->rank,iter->dims,coords)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't retrieve coordinates"); done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_all_iter_coords() */ /*------------------------------------------------------------------------- * Function: H5S_all_iter_block * * Purpose: Retrieve the current block of iterator for current * selection * * Return: non-negative on success, negative on failure * * Programmer: Quincey Koziol * Monday, June 2, 2003 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5S_all_iter_block (const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end) { unsigned u; /* Local index variable */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_all_iter_block); /* Check args */ assert (iter); assert (start); assert (end); for(u=0; urank; u++) { /* Set the start of the 'all' block */ /* (Always '0' coordinates for now) */ start[u]=0; /* Compute the end of the 'all' block */ /* (Always size of the extent for now) */ end[u]=iter->dims[u]-1; } /* end for */ FUNC_LEAVE_NOAPI(SUCCEED); } /* H5S_all_iter_coords() */ /*------------------------------------------------------------------------- * Function: H5S_all_iter_nelmts * * Purpose: Return number of elements left to process in iterator * * Return: non-negative number of elements on success, zero on failure * * Programmer: Quincey Koziol * Tuesday, June 16, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static hsize_t H5S_all_iter_nelmts (const H5S_sel_iter_t *iter) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_all_iter_nelmts); /* Check args */ assert (iter); FUNC_LEAVE_NOAPI(iter->elmt_left); } /* H5S_all_iter_nelmts() */ /*-------------------------------------------------------------------------- NAME H5S_all_iter_next PURPOSE Check if there is another block left in the current iterator USAGE htri_t H5S_all_iter_has_next_block(iter) const H5S_sel_iter_t *iter; IN: Pointer to selection iterator RETURNS Non-negative (TRUE/FALSE) on success/Negative on failure DESCRIPTION Check if there is another block available in the selection iterator. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static htri_t H5S_all_iter_has_next_block (const H5S_sel_iter_t UNUSED *iter) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_all_iter_has_next_block); /* Check args */ assert (iter); FUNC_LEAVE_NOAPI(FALSE); } /* H5S_all_iter_has_next_block() */ /*-------------------------------------------------------------------------- NAME H5S_all_iter_next PURPOSE Increment selection iterator USAGE herr_t H5S_all_iter_next(iter, nelem) H5S_sel_iter_t *iter; IN: Pointer to selection iterator size_t nelem; IN: Number of elements to advance by RETURNS Non-negative on success/Negative on failure DESCRIPTION Advance selection iterator to the NELEM'th next element in the selection. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_all_iter_next(H5S_sel_iter_t *iter, size_t nelem) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_all_iter_next); /* Check args */ assert (iter); assert (nelem>0); /* Increment the iterator */ iter->u.all.elmt_offset+=nelem; iter->u.all.byte_offset+=(nelem*iter->elmt_size); FUNC_LEAVE_NOAPI(SUCCEED); } /* H5S_all_iter_next() */ /*-------------------------------------------------------------------------- NAME H5S_all_iter_next_block PURPOSE Increment selection iterator to next block USAGE herr_t H5S_all_iter_next_block(iter) H5S_sel_iter_t *iter; IN: Pointer to selection iterator RETURNS Non-negative on success/Negative on failure DESCRIPTION Advance selection iterator to the next block in the selection. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_all_iter_next_block(H5S_sel_iter_t UNUSED *iter) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_all_iter_next_block); /* Check args */ assert (iter); FUNC_LEAVE_NOAPI(FAIL); } /* H5S_all_iter_next_block() */ /*-------------------------------------------------------------------------- NAME H5S_all_iter_release PURPOSE Release "all" selection iterator information for a dataspace USAGE herr_t H5S_all_iter_release(iter) H5S_sel_iter_t *iter; IN: Pointer to selection iterator RETURNS Non-negative on success/Negative on failure DESCRIPTION Releases all information for a dataspace "all" selection iterator GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_all_iter_release (H5S_sel_iter_t UNUSED * iter) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_all_iter_release); /* Check args */ assert (iter); FUNC_LEAVE_NOAPI(SUCCEED); } /* H5S_all_iter_release() */ /*-------------------------------------------------------------------------- NAME H5S_all_release PURPOSE Release all selection information for a dataspace USAGE herr_t H5S_all_release(space) H5S_t *space; IN: Pointer to dataspace RETURNS Non-negative on success/Negative on failure DESCRIPTION Releases "all" selection information for a dataspace GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5S_all_release (H5S_t UNUSED * space) { FUNC_ENTER_NOAPI_NOFUNC(H5S_all_release); /* Check args */ assert (space); /* Reset the number of elements in the selection */ space->select.num_elem=0; FUNC_LEAVE_NOAPI(SUCCEED); } /* H5S_all_release() */ /*-------------------------------------------------------------------------- NAME H5S_all_copy PURPOSE Copy a selection from one dataspace to another USAGE herr_t H5S_all_copy(dst, src) H5S_t *dst; OUT: Pointer to the destination dataspace H5S_t *src; IN: Pointer to the source dataspace RETURNS Non-negative on success/Negative on failure DESCRIPTION Copies the 'all' selection information from the source dataspace to the destination dataspace. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5S_all_copy(H5S_t *dst, const H5S_t UNUSED *src, hbool_t UNUSED share_selection) { FUNC_ENTER_NOAPI_NOFUNC(H5S_all_copy); assert(src); assert(dst); /* Set number of elements in selection */ dst->select.num_elem=(hsize_t)H5S_GET_EXTENT_NPOINTS(dst); FUNC_LEAVE_NOAPI(SUCCEED); } /* end H5S_all_copy() */ /*-------------------------------------------------------------------------- NAME H5S_all_is_valid PURPOSE Check whether the selection fits within the extent, with the current offset defined. USAGE htri_t H5S_all_is_valid(space); H5S_t *space; IN: Dataspace pointer to query RETURNS TRUE if the selection fits within the extent, FALSE if it does not and Negative on an error. DESCRIPTION Determines if the current selection at the current offet fits within the extent for the dataspace. Offset is irrelevant for this type of selection. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ htri_t H5S_all_is_valid (const H5S_t UNUSED *space) { FUNC_ENTER_NOAPI_NOFUNC(H5S_all_is_valid); assert(space); FUNC_LEAVE_NOAPI(TRUE); } /* end H5S_all_is_valid() */ /*-------------------------------------------------------------------------- NAME H5S_all_serial_size PURPOSE Determine the number of bytes needed to store the serialized "all" selection information. USAGE hssize_t H5S_all_serial_size(space) H5S_t *space; IN: Dataspace pointer to query RETURNS The number of bytes required on success, negative on an error. DESCRIPTION Determines the number of bytes required to serialize an "all" selection for storage on disk. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ hssize_t H5S_all_serial_size (const H5S_t UNUSED *space) { FUNC_ENTER_NOAPI_NOFUNC(H5S_all_serial_size); assert(space); /* Basic number of bytes required to serialize point selection: * + + + * = 16 bytes */ FUNC_LEAVE_NOAPI(16); } /* end H5S_all_serial_size() */ /*-------------------------------------------------------------------------- NAME H5S_all_serialize PURPOSE Serialize the current selection into a user-provided buffer. USAGE herr_t H5S_all_serialize(space, buf) H5S_t *space; IN: Dataspace pointer of selection to serialize uint8 *buf; OUT: Buffer to put serialized selection into RETURNS Non-negative on success/Negative on failure DESCRIPTION Serializes the current element selection into a buffer. (Primarily for storing on disk). GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5S_all_serialize (const H5S_t *space, uint8_t *buf) { FUNC_ENTER_NOAPI_NOFUNC(H5S_all_serialize); assert(space); /* Store the preamble information */ UINT32ENCODE(buf, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */ UINT32ENCODE(buf, (uint32_t)1); /* Store the version number */ UINT32ENCODE(buf, (uint32_t)0); /* Store the un-used padding */ UINT32ENCODE(buf, (uint32_t)0); /* Store the additional information length */ FUNC_LEAVE_NOAPI(SUCCEED); } /* H5S_all_serialize() */ /*-------------------------------------------------------------------------- NAME H5S_all_deserialize PURPOSE Deserialize the current selection from a user-provided buffer. USAGE herr_t H5S_all_deserialize(space, buf) H5S_t *space; IN/OUT: Dataspace pointer to place selection into uint8 *buf; IN: Buffer to retrieve serialized selection from RETURNS Non-negative on success/Negative on failure DESCRIPTION Deserializes the current selection into a buffer. (Primarily for retrieving from disk). GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5S_all_deserialize (H5S_t *space, const uint8_t UNUSED *buf) { herr_t ret_value; /* return value */ FUNC_ENTER_NOAPI(H5S_all_deserialize, FAIL); assert(space); /* Change to "all" selection */ if((ret_value=H5S_select_all(space,1))<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection"); done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_all_deserialize() */ /*-------------------------------------------------------------------------- NAME H5S_all_bounds PURPOSE Gets the bounding box containing the selection. USAGE herr_t H5S_all_bounds(space, start, end) H5S_t *space; IN: Dataspace pointer of selection to query hsize_t *start; OUT: Starting coordinate of bounding box hsize_t *end; OUT: Opposite coordinate of bounding box RETURNS Non-negative on success, negative on failure DESCRIPTION Retrieves the bounding box containing the current selection and places it into the user's buffers. The start and end buffers must be large enough to hold the dataspace rank number of coordinates. The bounding box exactly contains the selection, ie. if a 2-D element selection is currently defined with the following points: (4,5), (6,8) (10,7), the bounding box with be (4, 5), (10, 8). Calling this function on a "none" selection returns fail. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5S_all_bounds(const H5S_t *space, hsize_t *start, hsize_t *end) { int rank; /* Dataspace rank */ int i; /* index variable */ FUNC_ENTER_NOAPI_NOFUNC(H5S_all_bounds); assert(space); assert(start); assert(end); /* Get the dataspace extent rank */ rank=space->extent.rank; /* Just copy over the complete extent */ for(i=0; iextent.size[i]-1; } /* end for */ FUNC_LEAVE_NOAPI(SUCCEED); } /* H5Sget_all_bounds() */ /*-------------------------------------------------------------------------- NAME H5S_all_is_contiguous PURPOSE Check if a "all" selection is contiguous within the dataspace extent. USAGE htri_t H5S_all_is_contiguous(space) H5S_t *space; IN: Dataspace pointer to check RETURNS TRUE/FALSE/FAIL DESCRIPTION Checks to see if the current selection in the dataspace is contiguous. This is primarily used for reading the entire selection in one swoop. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ htri_t H5S_all_is_contiguous(const H5S_t UNUSED *space) { FUNC_ENTER_NOAPI_NOFUNC(H5S_all_is_contiguous); assert(space); FUNC_LEAVE_NOAPI(TRUE); } /* H5S_all_is_contiguous() */ /*-------------------------------------------------------------------------- NAME H5S_all_is_single PURPOSE Check if a "all" selection is a single block within the dataspace extent. USAGE htri_t H5S_all_is_single(space) H5S_t *space; IN: Dataspace pointer to check RETURNS TRUE/FALSE/FAIL DESCRIPTION Checks to see if the current selection in the dataspace is a single block. This is primarily used for reading the entire selection in one swoop. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ htri_t H5S_all_is_single(const H5S_t UNUSED *space) { FUNC_ENTER_NOAPI_NOFUNC(H5S_all_is_single); assert(space); FUNC_LEAVE_NOAPI(TRUE); } /* H5S_all_is_single() */ /*-------------------------------------------------------------------------- NAME H5S_all_is_regular PURPOSE Check if a "all" selection is "regular" USAGE htri_t H5S_all_is_regular(space) const H5S_t *space; IN: Dataspace pointer to check RETURNS TRUE/FALSE/FAIL DESCRIPTION Checks to see if the current selection in a dataspace is the a regular pattern. This is primarily used for reading the entire selection in one swoop. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ htri_t H5S_all_is_regular(const H5S_t UNUSED *space) { FUNC_ENTER_NOAPI_NOFUNC(H5S_all_is_regular); /* Check args */ assert(space); FUNC_LEAVE_NOAPI(TRUE); } /* H5S_all_is_regular() */ /*-------------------------------------------------------------------------- NAME H5S_select_all PURPOSE Specify the the entire extent is selected USAGE herr_t H5S_select_all(dsid) hid_t dsid; IN: Dataspace ID of selection to modify unsigned rel_prev; IN: Flag whether to release previous selection or not RETURNS Non-negative on success/Negative on failure DESCRIPTION This function selects the entire extent for a dataspace. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5S_select_all (H5S_t *space, unsigned rel_prev) { herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_NOAPI(H5S_select_all, FAIL); /* Check args */ assert(space); /* Remove current selection first */ if(rel_prev) if(H5S_SELECT_RELEASE(space)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release selection"); /* Set number of elements in selection */ space->select.num_elem=(hsize_t)H5S_GET_EXTENT_NPOINTS(space); /* Set selection type */ space->select.type=H5S_sel_all; done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_select_all() */ /*-------------------------------------------------------------------------- NAME H5Sselect_all PURPOSE Specify the the entire extent is selected USAGE herr_t H5Sselect_all(dsid) hid_t dsid; IN: Dataspace ID of selection to modify RETURNS Non-negative on success/Negative on failure DESCRIPTION This function selects the entire extent for a dataspace. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5Sselect_all (hid_t spaceid) { H5S_t *space = NULL; /* Dataspace to modify selection of */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Sselect_all, FAIL); /* Check args */ if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); /* Call internal routine to do the work */ if((ret_value=H5S_select_all(space,1))<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection"); done: FUNC_LEAVE_API(ret_value); } /* H5Sselect_all() */ /*-------------------------------------------------------------------------- NAME H5S_all_get_seq_list PURPOSE Create a list of offsets & lengths for a selection USAGE herr_t H5S_all_get_seq_list(space,flags,iter,maxseq,maxelem,nseq,nelem,off,len) H5S_t *space; IN: Dataspace containing selection to use. unsigned flags; IN: Flags for extra information about operation H5S_sel_iter_t *iter; IN/OUT: Selection iterator describing last position of interest in selection. size_t maxseq; IN: Maximum number of sequences to generate size_t maxelem; IN: Maximum number of elements to include in the generated sequences size_t *nseq; OUT: Actual number of sequences generated size_t *nelem; OUT: Actual number of elements in sequences generated hsize_t *off; OUT: Array of offsets size_t *len; OUT: Array of lengths RETURNS Non-negative on success/Negative on failure. DESCRIPTION Use the selection in the dataspace to generate a list of byte offsets and lengths for the region(s) selected. Start/Restart from the position in the ITER parameter. The number of sequences generated is limited by the MAXSEQ parameter and the number of sequences actually generated is stored in the NSEQ parameter. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5S_all_get_seq_list(const H5S_t UNUSED *space, unsigned UNUSED flags, H5S_sel_iter_t *iter, size_t UNUSED maxseq, size_t maxelem, size_t *nseq, size_t *nelem, hsize_t *off, size_t *len) { size_t elem_used; /* The number of elements used */ FUNC_ENTER_NOAPI_NOFUNC(H5S_all_get_seq_list); /* Check args */ assert(space); assert(iter); assert(maxseq>0); assert(maxelem>0); assert(nseq); assert(nelem); assert(off); assert(len); /* Determine the actual number of elements to use */ H5_CHECK_OVERFLOW(iter->elmt_left,hsize_t,size_t); elem_used=MIN(maxelem,(size_t)iter->elmt_left); /* Compute the offset in the dataset */ off[0]=iter->u.all.byte_offset; len[0]=elem_used*iter->elmt_size; /* Should only need one sequence for 'all' selections */ *nseq=1; /* Set the number of elements used */ *nelem=elem_used; /* Update the iterator */ iter->elmt_left-=elem_used; iter->u.all.elmt_offset+=elem_used; iter->u.all.byte_offset+=len[0]; FUNC_LEAVE_NOAPI(SUCCEED); } /* end H5S_all_get_seq_list() */ xdmf-3.0+git20160803/Utilities/hdf5/H5SLprivate.h0000640000175000017500000000654713003006557021166 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * This file contains private information about the H5SL module */ #ifndef _H5SLprivate_H #define _H5SLprivate_H /**************************************/ /* Public headers needed by this file */ /**************************************/ #ifdef LATER #include "H5SLpublic.h" #endif /* LATER */ /***************************************/ /* Private headers needed by this file */ /***************************************/ #include "H5private.h" /************/ /* Typedefs */ /************/ /* Typedefs for skip list struct (defined in H5SL.c) */ typedef struct H5SL_t H5SL_t; typedef struct H5SL_node_t H5SL_node_t; /* Typedef for kinds of skip lists supported */ typedef enum { H5SL_TYPE_INT, /* Skip list keys are 'int's */ H5SL_TYPE_HADDR, /* Skip list keys are 'haddr_t's */ H5SL_TYPE_STR, /* Skip list keys are 'char *'s (ie. strings) */ H5SL_TYPE_HSIZE, /* Skip list keys are 'hsize_t's */ H5SL_TYPE_UNSIGNED /* Skip list keys are 'unsigned's */ } H5SL_type_t; /**********/ /* Macros */ /**********/ #define H5SL_LEVEL_MAX 32 /* (for now) */ /* Typedef for iteration operations */ typedef herr_t (*H5SL_operator_t)(void *item, void *key, void *operator_data/*in,out*/); /********************/ /* Private routines */ /********************/ H5_DLL H5SL_t *H5SL_create(H5SL_type_t type, double p, size_t max_level); H5_DLL size_t H5SL_count(H5SL_t *slist); H5_DLL herr_t H5SL_insert(H5SL_t *slist, void *item, const void *key); H5_DLL H5SL_node_t *H5SL_add(H5SL_t *slist, void *item, const void *key); H5_DLL void *H5SL_remove(H5SL_t *slist, const void *key); H5_DLL void *H5SL_search(H5SL_t *slist, const void *key); H5_DLL void *H5SL_less(H5SL_t *slist, const void *key); H5_DLL H5SL_node_t *H5SL_find(H5SL_t *slist, const void *key); H5_DLL H5SL_node_t *H5SL_first(H5SL_t *slist); H5_DLL H5SL_node_t *H5SL_next(H5SL_node_t *slist_node); H5_DLL H5SL_node_t *H5SL_prev(H5SL_node_t *slist_node); H5_DLL H5SL_node_t *H5SL_last(H5SL_t *slist); H5_DLL void *H5SL_item(H5SL_node_t *slist_node); H5_DLL herr_t H5SL_iterate(H5SL_t *slist, H5SL_operator_t op, void *op_data); H5_DLL herr_t H5SL_release(H5SL_t *slist); H5_DLL herr_t H5SL_free(H5SL_t *slist, H5SL_operator_t op, void *op_data); H5_DLL herr_t H5SL_close(H5SL_t *slist); H5_DLL herr_t H5SL_destroy(H5SL_t *slist, H5SL_operator_t op, void *op_data); #endif /* _H5SLprivate_H */ xdmf-3.0+git20160803/Utilities/hdf5/H5Fsfile.c0000640000175000017500000001546513003006557020457 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #define H5F_PACKAGE /*suppress error about including H5Fpkg */ /* Packages needed by this file... */ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* File access */ #include "H5FDprivate.h" /* File drivers */ #include "H5FLprivate.h" /* Free lists */ /* PRIVATE TYPEDEFS */ /* Struct for tracking "shared" file structs */ typedef struct H5F_sfile_node_t { H5F_file_t *shared; /* Pointer to "shared" file struct */ struct H5F_sfile_node_t *next; /* Pointer to next node */ } H5F_sfile_node_t; /* PRIVATE PROTOTYPES */ /* PRIVATE VARIABLES */ /* Declare a free list to manage the H5F_sfile_node_t struct */ H5FL_DEFINE_STATIC(H5F_sfile_node_t); /* Declare a local variable to track the shared file information */ H5F_sfile_node_t *H5F_sfile_head_g = NULL; /*------------------------------------------------------------------------- * Function: H5F_sfile_assert_empty * * Purpose: Sanity checking that shared file list is empty * * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Monday, July 25, 2005 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5F_sfile_assert_num(unsigned n) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_sfile_assert_num) if(n == 0) { /* Sanity checking */ HDassert(H5F_sfile_head_g == NULL); } /* end if */ else { unsigned count; /* Number of open shared files */ H5F_sfile_node_t *curr; /* Current shared file node */ /* Iterate through low-level files for matching low-level file info */ curr = H5F_sfile_head_g; count = 0; while(curr) { /* Increment # of open shared file structs */ count++; /* Advance to next shared file node */ curr = curr->next; } /* end while */ /* Sanity checking */ HDassert(count == n); } /* end else */ FUNC_LEAVE_NOAPI(SUCCEED); } /* H5F_sfile_assert_num() */ /*------------------------------------------------------------------------- * Function: H5F_sfile_add * * Purpose: Add a "shared" file struct to the list of open files * * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Monday, July 18, 2005 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5F_sfile_add(H5F_file_t *shared) { H5F_sfile_node_t *new_shared; /* New shared file node */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5F_sfile_add) /* Sanity check */ HDassert(shared); /* Allocate new shared file node */ if (NULL == (new_shared = H5FL_CALLOC(H5F_sfile_node_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Set shared file value */ new_shared->shared = shared; /* Prepend to list of shared files open */ new_shared->next = H5F_sfile_head_g; H5F_sfile_head_g = new_shared; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_sfile_add() */ /*------------------------------------------------------------------------- * Function: H5F_sfile_search * * Purpose: Search for a "shared" file with low-level file info that * matches * * Return: Non-NULL on success / NULL on failure * * Programmer: Quincey Koziol * Monday, July 18, 2005 * * Modifications: * *------------------------------------------------------------------------- */ H5F_file_t * H5F_sfile_search(H5FD_t *lf) { H5F_sfile_node_t *curr; /* Current shared file node */ H5F_file_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_sfile_search) /* Sanity check */ HDassert(lf); /* Iterate through low-level files for matching low-level file info */ curr = H5F_sfile_head_g; while(curr) { /* Check for match */ if(0==H5FD_cmp(curr->shared->lf, lf)) HGOTO_DONE(curr->shared) /* Advance to next shared file node */ curr = curr->next; } /* end while */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_sfile_search() */ /*------------------------------------------------------------------------- * Function: H5F_sfile_remove * * Purpose: Remove a "shared" file struct from the list of open files * * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Monday, July 18, 2005 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5F_sfile_remove(H5F_file_t *shared) { H5F_sfile_node_t *curr; /* Current shared file node */ H5F_sfile_node_t *last; /* Last shared file node */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5F_sfile_remove) /* Sanity check */ HDassert(shared); /* Locate shared file node with correct shared file */ last = NULL; curr = H5F_sfile_head_g; while(curr && curr->shared != shared) { /* Advance to next node */ last = curr; curr = curr->next; } /* end while */ /* Indicate error if the node wasn't found */ if(curr == NULL) HGOTO_ERROR(H5E_FILE, H5E_NOTFOUND, FAIL, "can't find shared file info") /* Remove node found from list */ if(last != NULL) /* Removing middle or tail node in list */ last->next = curr->next; else /* Removing head node in list */ H5F_sfile_head_g = curr->next; /* Release the shared file node struct */ /* (the shared file info itself is freed elsewhere) */ H5FL_FREE(H5F_sfile_node_t, curr); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_sfile_remove() */ xdmf-3.0+git20160803/Utilities/hdf5/H5HGpkg.h0000640000175000017500000000740413003006557020246 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Quincey Koziol * Wednesday, July 9, 2003 * * Purpose: This file contains declarations which are visible * only within the H5HG package. Source files outside the * H5HG package should include H5HGprivate.h instead. */ #ifndef H5HG_PACKAGE #error "Do not include this file outside the H5HG package!" #endif #ifndef _H5HGpkg_H #define _H5HGpkg_H /* Get package's private header */ #include "H5HGprivate.h" /* Other private headers needed by this file */ /*****************************/ /* Package Private Variables */ /*****************************/ /* The cache subclass */ H5_DLLVAR const H5AC_class_t H5AC_GHEAP[1]; /**************************/ /* Package Private Macros */ /**************************/ /* * Pad all global heap messages to a multiple of eight bytes so we can load * the entire collection into memory and operate on it there. Eight should * be sufficient for machines that have alignment constraints because our * largest data type is eight bytes. */ #define H5HG_ALIGNMENT 8 #define H5HG_ALIGN(X) (H5HG_ALIGNMENT*(((X)+H5HG_ALIGNMENT-1)/ \ H5HG_ALIGNMENT)) #define H5HG_ISALIGNED(X) ((X)==H5HG_ALIGN(X)) /* * The overhead associated with each object in the heap, always a multiple of * the alignment so that the stuff that follows the header is aligned. */ #define H5HG_SIZEOF_OBJHDR(f) \ H5HG_ALIGN(2 + /*object id number */ \ 2 + /*reference count */ \ 4 + /*reserved */ \ H5F_SIZEOF_SIZE(f)) /*object data size */ /****************************/ /* Package Private Typedefs */ /****************************/ typedef struct H5HG_obj_t { int nrefs; /*reference count */ size_t size; /*total size of object */ uint8_t *begin; /*ptr to object into heap->chunk*/ } H5HG_obj_t; struct H5HG_heap_t { H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */ /* first field in structure */ haddr_t addr; /*collection address */ size_t size; /*total size of collection */ uint8_t *chunk; /*the collection, incl. header */ size_t nalloc; /*numb object slots allocated */ size_t nused; /*number of slots used */ /* If this value is >65535 then all indices */ /* have been used at some time and the */ /* correct new index should be searched for */ H5HG_obj_t *obj; /*array of object descriptions */ }; /******************************/ /* Package Private Prototypes */ /******************************/ #endif xdmf-3.0+git20160803/Utilities/hdf5/H5FDgass.h0000640000175000017500000000407613003006557020417 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Saurabh Bagchi * Tuesday, August 17, 1999 * * Purpose: The public header file for the gass driver. */ #ifndef H5FDgass_H #define H5FDgass_H #include "H5FDpublic.h" #include "H5Ipublic.h" #include #ifdef H5_HAVE_GASS #define H5FD_GASS (H5FD_gass_init()) #else #define H5FD_GASS (-1) #endif #ifdef H5_HAVE_GASS /* Define the GASS info object. (Will be added to later as more GASS functionality is sought to be exposed. */ typedef struct GASS_Info { unsigned long block_size; unsigned long max_length; } GASS_Info; #define GASS_INFO_NULL(v) memset((void *)&v, 0, sizeof(GASS_Info)); /* GASS_Info zzGassInfo = {0L,0L}; #define GASS_INFO_NULL zzGassInfo */ #endif /* Function prototypes */ #ifdef H5_HAVE_GASS #ifdef __cplusplus extern "C" { #endif hid_t H5FD_gass_init(void); void H5FD_gass_term(void); herr_t H5Pset_fapl_gass(hid_t fapl_id, GASS_Info info); herr_t H5Pget_fapl_gass(hid_t fapl_id, GASS_Info *info/*out*/); #ifdef __cplusplus } #endif #endif #endif /* H5FDgass_H */ xdmf-3.0+git20160803/Utilities/hdf5/H5Omtime.c0000640000175000017500000003755213003006557020502 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* Programmer: Robb Matzke * Friday, July 24, 1998 * * Purpose: The object modification time message. */ #define H5O_PACKAGE /*suppress error about including H5Opkg */ #include "H5private.h" #include "H5Eprivate.h" #include "H5FLprivate.h" /*Free Lists */ #include "H5MMprivate.h" #include "H5Opkg.h" /* Object header functions */ #if defined (WIN32) && !defined (__MWERKS__) #include #include #endif static void *H5O_mtime_new_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t *sh); static herr_t H5O_mtime_new_encode(H5F_t *f, uint8_t *p, const void *_mesg); static size_t H5O_mtime_new_size(const H5F_t *f, const void *_mesg); static void *H5O_mtime_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t *sh); static herr_t H5O_mtime_encode(H5F_t *f, uint8_t *p, const void *_mesg); static void *H5O_mtime_copy(const void *_mesg, void *_dest, unsigned update_flags); static size_t H5O_mtime_size(const H5F_t *f, const void *_mesg); static herr_t H5O_mtime_reset(void *_mesg); static herr_t H5O_mtime_free(void *_mesg); static herr_t H5O_mtime_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE *stream, int indent, int fwidth); /* This message derives from H5O */ const H5O_class_t H5O_MTIME[1] = {{ H5O_MTIME_ID, /*message id number */ "mtime", /*message name for debugging */ sizeof(time_t), /*native message size */ H5O_mtime_decode, /*decode message */ H5O_mtime_encode, /*encode message */ H5O_mtime_copy, /*copy the native value */ H5O_mtime_size, /*raw message size */ H5O_mtime_reset, /* reset method */ H5O_mtime_free, /* free method */ NULL, /* file delete method */ NULL, /* link method */ NULL, /*get share method */ NULL, /*set share method */ H5O_mtime_debug, /*debug the message */ }}; /* This message derives from H5O */ /* (Only encode, decode & size routines are different from old mtime routines) */ const H5O_class_t H5O_MTIME_NEW[1] = {{ H5O_MTIME_NEW_ID, /*message id number */ "mtime_new", /*message name for debugging */ sizeof(time_t), /*native message size */ H5O_mtime_new_decode, /*decode message */ H5O_mtime_new_encode, /*encode message */ H5O_mtime_copy, /*copy the native value */ H5O_mtime_new_size, /*raw message size */ H5O_mtime_reset, /* reset method */ H5O_mtime_free, /* free method */ NULL, /* file delete method */ NULL, /* link method */ NULL, /*get share method */ NULL, /*set share method */ H5O_mtime_debug, /*debug the message */ }}; /* Current version of new mtime information */ #define H5O_MTIME_VERSION 1 /* Track whether tzset routine was called */ static int ntzset=0; /* Declare a free list to manage the time_t struct */ H5FL_DEFINE(time_t); /*------------------------------------------------------------------------- * Function: H5O_mtime_new_decode * * Purpose: Decode a new modification time message and return a pointer to a * new time_t value. * * Return: Success: Ptr to new message in native struct. * * Failure: NULL * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * Jan 3 2002 * * Modifications: * *------------------------------------------------------------------------- */ static void * H5O_mtime_new_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const uint8_t *p, H5O_shared_t UNUSED *sh) { time_t *mesg; uint32_t tmp_time; /* Temporary copy of the time */ void *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_mtime_new_decode); /* check args */ assert(f); assert(p); assert (!sh); /* decode */ if(*p++ != H5O_MTIME_VERSION) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for mtime message"); /* Skip reserved bytes */ p+=3; /* Get the time_t from the file */ UINT32DECODE(p, tmp_time); /* The return value */ if (NULL==(mesg = H5FL_MALLOC(time_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); *mesg = (time_t)tmp_time; /* Set return value */ ret_value=mesg; done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5O_mtime_new_decode() */ /*------------------------------------------------------------------------- * Function: H5O_mtime_decode * * Purpose: Decode a modification time message and return a pointer to a * new time_t value. * * Return: Success: Ptr to new message in native struct. * * Failure: NULL * * Programmer: Robb Matzke * matzke@llnl.gov * Jul 24 1998 * * Modifications: * *------------------------------------------------------------------------- */ static void * H5O_mtime_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const uint8_t *p, H5O_shared_t UNUSED *sh) { time_t *mesg, the_time; int i; struct tm tm; void *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_mtime_decode); /* check args */ assert(f); assert(p); assert (!sh); /* Initialize time zone information */ if (!ntzset) { HDtzset(); ntzset=1; } /* end if */ /* decode */ for (i=0; i<14; i++) { if (!HDisdigit(p[i])) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "badly formatted modification time message"); } /* * Convert YYYYMMDDhhmmss UTC to a time_t. This is a little problematic * because mktime() operates on local times. We convert to local time * and then figure out the adjustment based on the local time zone and * daylight savings setting. */ HDmemset(&tm, 0, sizeof tm); tm.tm_year = (p[0]-'0')*1000 + (p[1]-'0')*100 + (p[2]-'0')*10 + (p[3]-'0') - 1900; tm.tm_mon = (p[4]-'0')*10 + (p[5]-'0') - 1; tm.tm_mday = (p[6]-'0')*10 + (p[7]-'0'); tm.tm_hour = (p[8]-'0')*10 + (p[9]-'0'); tm.tm_min = (p[10]-'0')*10 + (p[11]-'0'); tm.tm_sec = (p[12]-'0')*10 + (p[13]-'0'); tm.tm_isdst = -1; /*figure it out*/ if ((time_t)-1==(the_time=HDmktime(&tm))) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "badly formatted modification time message"); #if defined(H5_HAVE_TM_GMTOFF) /* FreeBSD, OSF 4.0 */ the_time += tm.tm_gmtoff; #elif defined(H5_HAVE___TM_GMTOFF) /* Linux libc-4 */ the_time += tm.__tm_gmtoff; #elif defined(H5_HAVE_TIMEZONE) /* Linux libc-5 */ the_time -= timezone - (tm.tm_isdst?3600:0); #elif defined(H5_HAVE_BSDGETTIMEOFDAY) && defined(H5_HAVE_STRUCT_TIMEZONE) /* Irix5.3 */ { struct timezone tz; if (HDBSDgettimeofday(NULL, &tz)<0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to obtain local timezone information"); the_time -= tz.tz_minuteswest * 60 - (tm.tm_isdst ? 3600 : 0); } #elif defined(H5_HAVE_GETTIMEOFDAY) && defined(H5_HAVE_STRUCT_TIMEZONE) && defined(H5_GETTIMEOFDAY_GIVES_TZ) { struct timezone tz; struct timeval tv; /* Used as a placebo; some systems don't like NULL */ if (HDgettimeofday(&tv, &tz) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to obtain local timezone information"); the_time -= tz.tz_minuteswest * 60 - (tm.tm_isdst ? 3600 : 0); } #elif defined (WIN32) #if !defined (__MWERKS__) /* MSVC */ { struct timeb timebuffer; long tz; ftime(&timebuffer); tz = timebuffer.timezone; /* daylight is not handled properly. Currently we just hard-code the problem. */ the_time -= tz * 60 - 3600; } #else /*__MWERKS__*/ ; #endif /*__MWERKS__*/ #else /* WIN32 */ /* * The catch-all. If we can't convert a character string universal * coordinated time to a time_t value reliably then we can't decode the * modification time message. This really isn't as bad as it sounds -- the * only way a user can get the modification time is from H5Gget_objinfo() * and H5G_get_objinfo() can gracefully recover. */ /* Irix64 */ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to obtain local timezone information"); #endif /* The return value */ if (NULL==(mesg = H5FL_MALLOC(time_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); *mesg = the_time; /* Set return value */ ret_value=mesg; done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_mtime_new_encode * * Purpose: Encodes a new modification time message. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * Jan 3 2002 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_mtime_new_encode(H5F_t UNUSED *f, uint8_t *p, const void *_mesg) { const time_t *mesg = (const time_t *) _mesg; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_mtime_new_encode); /* check args */ assert(f); assert(p); assert(mesg); /* Version */ *p++ = H5O_MTIME_VERSION; /* Reserved bytes */ *p++ = 0; *p++ = 0; *p++ = 0; /* Encode time */ UINT32ENCODE(p, *mesg); FUNC_LEAVE_NOAPI(SUCCEED); } /* end H5O_mtime_new_encode() */ /*------------------------------------------------------------------------- * Function: H5O_mtime_encode * * Purpose: Encodes a modification time message. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Jul 24 1998 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_mtime_encode(H5F_t UNUSED *f, uint8_t *p, const void *_mesg) { const time_t *mesg = (const time_t *) _mesg; struct tm *tm; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_mtime_encode); /* check args */ assert(f); assert(p); assert(mesg); /* encode */ tm = HDgmtime(mesg); sprintf((char*)p, "%04d%02d%02d%02d%02d%02d", 1900+tm->tm_year, 1+tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); FUNC_LEAVE_NOAPI(SUCCEED); } /*------------------------------------------------------------------------- * Function: H5O_mtime_copy * * Purpose: Copies a message from _MESG to _DEST, allocating _DEST if * necessary. * * Return: Success: Ptr to _DEST * * Failure: NULL * * Programmer: Robb Matzke * matzke@llnl.gov * Jul 24 1998 * * Modifications: * *------------------------------------------------------------------------- */ static void * H5O_mtime_copy(const void *_mesg, void *_dest, unsigned UNUSED update_flags) { const time_t *mesg = (const time_t *) _mesg; time_t *dest = (time_t *) _dest; void *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_mtime_copy); /* check args */ assert(mesg); if (!dest && NULL==(dest = H5FL_MALLOC(time_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); /* copy */ *dest = *mesg; /* Set return value */ ret_value=dest; done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_mtime_new_size * * Purpose: Returns the size of the raw message in bytes not * counting the message type or size fields, but only the data * fields. This function doesn't take into account * alignment. * * Return: Success: Message data size in bytes w/o alignment. * * Failure: 0 * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * Jan 3 2002 * * Modifications: * *------------------------------------------------------------------------- */ static size_t H5O_mtime_new_size(const H5F_t UNUSED * f, const void UNUSED * mesg) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_mtime_new_size); /* check args */ assert(f); assert(mesg); FUNC_LEAVE_NOAPI(8); } /* end H5O_mtime_new_size() */ /*------------------------------------------------------------------------- * Function: H5O_mtime_size * * Purpose: Returns the size of the raw message in bytes not * counting the message type or size fields, but only the data * fields. This function doesn't take into account * alignment. * * Return: Success: Message data size in bytes w/o alignment. * * Failure: 0 * * Programmer: Robb Matzke * matzke@llnl.gov * Jul 14 1998 * * Modifications: * *------------------------------------------------------------------------- */ static size_t H5O_mtime_size(const H5F_t UNUSED * f, const void UNUSED * mesg) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_mtime_size); /* check args */ assert(f); assert(mesg); FUNC_LEAVE_NOAPI(16); } /*------------------------------------------------------------------------- * Function: H5O_mtime_reset * * Purpose: Frees resources within a modification time message, but doesn't free * the message itself. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Mondey, December 23, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_mtime_reset(void UNUSED *_mesg) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_mtime_reset); FUNC_LEAVE_NOAPI(SUCCEED); } /*------------------------------------------------------------------------- * Function: H5O_mtime_free * * Purpose: Free's the message * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Thursday, March 30, 2000 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_mtime_free (void *mesg) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_mtime_free); assert (mesg); H5FL_FREE(time_t,mesg); FUNC_LEAVE_NOAPI(SUCCEED); } /*------------------------------------------------------------------------- * Function: H5O_mtime_debug * * Purpose: Prints debugging info for the message. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Jul 24 1998 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_mtime_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg, FILE *stream, int indent, int fwidth) { const time_t *mesg = (const time_t *)_mesg; struct tm *tm; char buf[128]; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_mtime_debug); /* check args */ assert(f); assert(mesg); assert(stream); assert(indent >= 0); assert(fwidth >= 0); /* debug */ tm = HDlocaltime(mesg); HDstrftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %Z", tm); fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Time:", buf); FUNC_LEAVE_NOAPI(SUCCEED); } xdmf-3.0+git20160803/Utilities/hdf5/H5HL.c0000640000175000017500000012700513003006557017544 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*------------------------------------------------------------------------- * * Created: H5HL.c * Jul 16 1997 * Robb Matzke * * Purpose: Heap functions for the local heaps used by symbol * tables to store names (among other things). * * Modifications: * * Robb Matzke, 5 Aug 1997 * Added calls to H5E. * *------------------------------------------------------------------------- */ #define H5F_PACKAGE /* Suppress error about including H5Fpkg */ #define H5HL_PACKAGE /* Suppress error about including H5HLpkg */ #include "H5private.h" /* Generic Functions */ #include "H5ACprivate.h" /* Metadata cache */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* File access */ #include "H5FLprivate.h" /* Free lists */ #include "H5HLpkg.h" /* Local Heaps */ #include "H5MFprivate.h" /* File memory management */ /* Private macros */ #define H5HL_FREE_NULL 1 /*end of free list on disk */ #define H5HL_MIN_HEAP 256 /* Minimum size to reduce heap buffer to */ /* * Local heap collection version. */ #define H5HL_VERSION 0 /* Private typedefs */ /* PRIVATE PROTOTYPES */ #ifdef NOT_YET static void *H5HL_read(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t offset, size_t size, void *buf); static herr_t H5HL_write(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t offset, size_t size, const void *buf); #endif /* NOT_YET */ static herr_t H5HL_serialize(H5F_t *f, H5HL_t *heap, uint8_t *buf); static H5HL_free_t *H5HL_remove_free(H5HL_t *heap, H5HL_free_t *fl); static herr_t H5HL_minimize_heap_space(H5F_t *f, hid_t dxpl_id, H5HL_t *heap); /* Metadata cache callbacks */ static H5HL_t *H5HL_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *udata1, void *udata2); static herr_t H5HL_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest, haddr_t addr, H5HL_t *heap); static herr_t H5HL_dest(H5F_t *f, H5HL_t *heap); static herr_t H5HL_clear(H5F_t *f, H5HL_t *heap, hbool_t destroy); static herr_t H5HL_compute_size(const H5F_t *f, const H5HL_t *heap, size_t *size_ptr); /* * H5HL inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_LHEAP[1] = {{ H5AC_LHEAP_ID, (H5AC_load_func_t)H5HL_load, (H5AC_flush_func_t)H5HL_flush, (H5AC_dest_func_t)H5HL_dest, (H5AC_clear_func_t)H5HL_clear, (H5AC_size_func_t)H5HL_compute_size, }}; /* Declare a free list to manage the H5HL_free_t struct */ H5FL_DEFINE_STATIC(H5HL_free_t); /* Declare a free list to manage the H5HL_t struct */ H5FL_DEFINE_STATIC(H5HL_t); /* Declare a PQ free list to manage the heap chunk information */ H5FL_BLK_DEFINE_STATIC(heap_chunk); /*------------------------------------------------------------------------- * Function: H5HL_create * * Purpose: Creates a new heap data structure on disk and caches it * in memory. SIZE_HINT is a hint for the initial size of the * data area of the heap. If size hint is invalid then a * reasonable (but probably not optimal) size will be chosen. * If the heap ever has to grow, then REALLOC_HINT is the * minimum amount by which the heap will grow. * * Return: Success: Non-negative. The file address of new heap is * returned through the ADDR argument. * * Failure: Negative * * Programmer: Robb Matzke * matzke@llnl.gov * Jul 16 1997 * * Modifications: * * Robb Matzke, 5 Aug 1997 * Takes a flag that determines the type of heap that is * created. * *------------------------------------------------------------------------- */ herr_t H5HL_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, haddr_t *addr_p/*out*/) { H5HL_t *heap = NULL; hsize_t total_size; /*total heap size on disk */ size_t sizeof_hdr; /* Cache H5HL header size for file */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5HL_create, FAIL); /* check arguments */ assert(f); assert(addr_p); if (size_hint && size_hint < H5HL_SIZEOF_FREE(f)) size_hint = H5HL_SIZEOF_FREE(f); size_hint = H5HL_ALIGN(size_hint); /* Cache this for later */ sizeof_hdr= H5HL_SIZEOF_HDR(f); /* allocate file version */ total_size = sizeof_hdr + size_hint; if (HADDR_UNDEF==(*addr_p=H5MF_alloc(f, H5FD_MEM_LHEAP, dxpl_id, total_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate file memory"); /* allocate memory version */ if (NULL==(heap = H5FL_CALLOC(H5HL_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); heap->addr = *addr_p + (hsize_t)sizeof_hdr; heap->disk_alloc = size_hint; heap->mem_alloc = size_hint; heap->disk_resrv = 0; if (NULL==(heap->chunk = H5FL_BLK_CALLOC(heap_chunk,(sizeof_hdr + size_hint)))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); /* free list */ if (size_hint) { if (NULL==(heap->freelist = H5FL_MALLOC(H5HL_free_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); heap->freelist->offset = 0; heap->freelist->size = size_hint; heap->freelist->prev = heap->freelist->next = NULL; } else { heap->freelist = NULL; } /* add to cache */ heap->cache_info.is_dirty = TRUE; if (H5AC_set(f, dxpl_id, H5AC_LHEAP, *addr_p, heap) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "unable to cache heap"); done: if (ret_value<0) { if (H5F_addr_defined(*addr_p)) H5MF_xfree(f, H5FD_MEM_LHEAP, dxpl_id, *addr_p, total_size); if (heap) { if(H5HL_dest(f,heap)<0) HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy local heap collection"); } } FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5HL_load * * Purpose: Loads a heap from disk. * * Return: Success: Ptr to a local heap memory data structure. * * Failure: NULL * * Programmer: Robb Matzke * matzke@llnl.gov * Jul 17 1997 * * Modifications: * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. * * Quincey Koziol, 2002-7-180 * Added dxpl parameter to allow more control over I/O from metadata * cache. *------------------------------------------------------------------------- */ static H5HL_t * H5HL_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * udata1, void UNUSED * udata2) { uint8_t hdr[52]; size_t sizeof_hdr; /* Cache H5HL header size for file */ const uint8_t *p = NULL; H5HL_t *heap = NULL; H5HL_free_t *fl = NULL, *tail = NULL; size_t free_block = H5HL_FREE_NULL; H5HL_t *ret_value; FUNC_ENTER_NOAPI(H5HL_load, NULL); /* check arguments */ assert(f); assert(H5F_addr_defined(addr)); assert(!udata1); assert(!udata2); /* Cache this for later */ sizeof_hdr= H5HL_SIZEOF_HDR(f); assert(sizeof_hdr <= sizeof(hdr)); /* Get the local heap's header */ if (H5F_block_read(f, H5FD_MEM_LHEAP, addr, sizeof_hdr, dxpl_id, hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_READERROR, NULL, "unable to read heap header"); p = hdr; /* Check magic number */ if (HDmemcmp(hdr, H5HL_MAGIC, H5HL_SIZEOF_MAGIC)) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "bad heap signature"); p += H5HL_SIZEOF_MAGIC; /* Version */ if (H5HL_VERSION!=*p++) HGOTO_ERROR (H5E_HEAP, H5E_CANTLOAD, NULL, "wrong version number in global heap"); /* Reserved */ p += 3; /* Allocate space in memory for the heap */ if (NULL==(heap = H5FL_CALLOC(H5HL_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); /* heap data size */ H5F_DECODE_LENGTH(f, p, heap->disk_alloc); heap->mem_alloc = heap->disk_alloc; /* free list head */ H5F_DECODE_LENGTH(f, p, free_block); if (free_block != H5HL_FREE_NULL && free_block >= heap->disk_alloc) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "bad heap free list"); /* data */ H5F_addr_decode(f, &p, &(heap->addr)); if (NULL==(heap->chunk = H5FL_BLK_CALLOC(heap_chunk,(sizeof_hdr + heap->mem_alloc)))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); if (heap->disk_alloc && H5F_block_read(f, H5FD_MEM_LHEAP, heap->addr, heap->disk_alloc, dxpl_id, heap->chunk + sizeof_hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "unable to read heap data"); /* Build free list */ while (H5HL_FREE_NULL != free_block) { if (free_block >= heap->disk_alloc) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "bad heap free list"); if (NULL==(fl = H5FL_MALLOC(H5HL_free_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); fl->offset = free_block; fl->prev = tail; fl->next = NULL; if (tail) tail->next = fl; tail = fl; if (!heap->freelist) heap->freelist = fl; p = heap->chunk + sizeof_hdr + free_block; H5F_DECODE_LENGTH(f, p, free_block); H5F_DECODE_LENGTH(f, p, fl->size); if (fl->offset + fl->size > heap->disk_alloc) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "bad heap free list"); } /* Set return value */ ret_value = heap; done: if (!ret_value && heap) { if(H5HL_dest(f,heap)<0) HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, NULL, "unable to destroy local heap collection"); } FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5HL_minimize_heap_space * * Purpose: Go through the heap's freelist and determine if we can * eliminate the free blocks at the tail of the buffer. * * Return: Success: SUCCEED * Failure: FAIL * * Programmer: Bill Wendling * wendling@ncsa.uiuc.edu * Sept. 16, 2003 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5HL_minimize_heap_space(H5F_t *f, hid_t dxpl_id, H5HL_t *heap) { herr_t ret_value = SUCCEED; size_t sizeof_hdr; FUNC_ENTER_NOAPI(H5HL_minimize_heap_space, FAIL) /* check args */ assert(f); assert(heap); sizeof_hdr = H5HL_SIZEOF_HDR(f); /* cache H5HL header size for file */ /* * When the heap is being flushed to disk, release the file space reserved * for it. */ H5MF_free_reserved(f, (hsize_t)heap->disk_resrv); heap->disk_resrv = 0; /* * Check to see if we can reduce the size of the heap in memory by * eliminating free blocks at the tail of the buffer before flushing the * buffer out. */ if (heap->freelist) { H5HL_free_t *tmp_fl; H5HL_free_t *last_fl = NULL; /* Search for a free block at the end of the buffer */ for (tmp_fl = heap->freelist; tmp_fl; tmp_fl = tmp_fl->next) /* Check if the end of this free block is at the end of the buffer */ if (tmp_fl->offset + tmp_fl->size == heap->mem_alloc) { last_fl = tmp_fl; break; } /* * Found free block at the end of the buffer, decide what to do * about it */ if (last_fl) { size_t new_mem_size = heap->mem_alloc; /* New size of memory buffer */ /* * If the last free block's size is more than half the memory * buffer size (and the memory buffer is larger than the * minimum size), reduce or eliminate it. */ if (last_fl->size >= (heap->mem_alloc / 2) && heap->mem_alloc > H5HL_MIN_HEAP) { /* * Reduce size of buffer until it's too small or would * eliminate the free block */ while (new_mem_size > H5HL_MIN_HEAP && new_mem_size >= (last_fl->offset + H5HL_SIZEOF_FREE(f))) new_mem_size /= 2; /* * Check if reducing the memory buffer size would * eliminate the free list */ if (new_mem_size < (last_fl->offset + H5HL_SIZEOF_FREE(f))) { /* Check if this is the only block on the free list */ if (last_fl->prev == NULL && last_fl->next == NULL) { /* Double the new memory size */ new_mem_size *= 2; /* Truncate the free block */ last_fl->size = H5HL_ALIGN(new_mem_size - last_fl->offset); new_mem_size = last_fl->offset + last_fl->size; assert(last_fl->size >= H5HL_SIZEOF_FREE(f)); } else { /* * Set the size of the memory buffer to the start * of the free list */ new_mem_size = last_fl->offset; /* Eliminate the free block from the list */ last_fl = H5HL_remove_free(heap, last_fl); } } else { /* Truncate the free block */ last_fl->size = H5HL_ALIGN(new_mem_size - last_fl->offset); new_mem_size = last_fl->offset + last_fl->size; assert(last_fl->size >= H5HL_SIZEOF_FREE(f)); assert(last_fl->size == H5HL_ALIGN(last_fl->size)); } /* Resize the memory buffer and reserved space in file */ if (new_mem_size != heap->mem_alloc) { heap->mem_alloc = new_mem_size; heap->chunk = H5FL_BLK_REALLOC(heap_chunk, heap->chunk, (sizeof_hdr + new_mem_size)); if (!heap->chunk) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") } } } } /* * If the heap grew larger or smaller than disk storage then move the * data segment of the heap to another contiguous block of disk * storage. */ if (heap->mem_alloc != heap->disk_alloc) { haddr_t old_addr = heap->addr, new_addr; /* Release old space on disk */ H5_CHECK_OVERFLOW(heap->disk_alloc, size_t, hsize_t); H5MF_xfree(f, H5FD_MEM_LHEAP, dxpl_id, old_addr, (hsize_t)heap->disk_alloc); H5E_clear(); /* don't really care if the free failed */ /* Allocate new space on disk */ H5_CHECK_OVERFLOW(heap->mem_alloc, size_t, hsize_t); if (HADDR_UNDEF == (new_addr = H5MF_alloc(f, H5FD_MEM_LHEAP, dxpl_id, (hsize_t)heap->mem_alloc))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate file space for heap") heap->addr = new_addr; /* Set new size of block on disk */ heap->disk_alloc = heap->mem_alloc; } done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5HL_serialize * * Purpose: Serialize the heap. This function will eliminate free * blocks at the tail of the heap and also split the block * if it needs to be split for the file. This is so that we * can serialize it correctly. * * Return: Non-negative on success/Negative on failure * * Programmer: Bill Wendling * wendling@ncsa.uiuc.edu * Sept. 16, 2003 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5HL_serialize(H5F_t *f, H5HL_t *heap, uint8_t *buf) { H5HL_free_t *fl; uint8_t *p; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HL_serialize) /* check args */ assert(buf); assert(heap); /* serialize the header */ p = buf; fl = heap->freelist; HDmemcpy(p, H5HL_MAGIC, H5HL_SIZEOF_MAGIC); p += H5HL_SIZEOF_MAGIC; *p++ = H5HL_VERSION; *p++ = 0; /*reserved*/ *p++ = 0; /*reserved*/ *p++ = 0; /*reserved*/ H5F_ENCODE_LENGTH(f, p, heap->mem_alloc); H5F_ENCODE_LENGTH(f, p, fl ? fl->offset : H5HL_FREE_NULL); H5F_addr_encode(f, &p, heap->addr); /* serialize the free list */ for (; fl; fl = fl->next) { assert (fl->offset == H5HL_ALIGN (fl->offset)); p = heap->chunk + H5HL_SIZEOF_HDR(f) + fl->offset; if (fl->next) { H5F_ENCODE_LENGTH(f, p, fl->next->offset); } else { H5F_ENCODE_LENGTH(f, p, H5HL_FREE_NULL); } H5F_ENCODE_LENGTH(f, p, fl->size); } FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5HL_flush * * Purpose: Flushes a heap from memory to disk if it's dirty. Optionally * deletes the heap from memory. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Jul 17 1997 * * Modifications: * rky, 1998-08-28 * Only p0 writes metadata to disk. * * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. * * Quincey Koziol, 2002-7-180 * Added dxpl parameter to allow more control over I/O from metadata * cache. * * Bill Wendling, 2003-09-16 * Separated out the bit that serializes the heap. *------------------------------------------------------------------------- */ static herr_t H5HL_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5HL_t *heap) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5HL_flush, FAIL); /* check arguments */ assert(f); assert(H5F_addr_defined(addr)); assert(heap); if (heap->cache_info.is_dirty) { haddr_t hdr_end_addr; size_t sizeof_hdr = H5HL_SIZEOF_HDR(f); /* cache H5HL header size for file */ /* Minimize the heap space size if possible */ if (H5HL_minimize_heap_space(f, dxpl_id, heap) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to minimize local heap space") /* Write the header */ if (H5HL_serialize(f, heap, heap->chunk) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSERIALIZE, FAIL, "unable to serialize local heap") /* Copy buffer to disk */ hdr_end_addr = addr + (hsize_t)sizeof_hdr; if (H5F_addr_eq(heap->addr, hdr_end_addr)) { /* The header and data are contiguous */ if (H5F_block_write(f, H5FD_MEM_LHEAP, addr, (sizeof_hdr + heap->disk_alloc), dxpl_id, heap->chunk) < 0) HGOTO_ERROR(H5E_HEAP, H5E_WRITEERROR, FAIL, "unable to write heap header and data to file") } else { if (H5F_block_write(f, H5FD_MEM_LHEAP, addr, sizeof_hdr, dxpl_id, heap->chunk) < 0) HGOTO_ERROR(H5E_HEAP, H5E_WRITEERROR, FAIL, "unable to write heap header to file") if (H5F_block_write(f, H5FD_MEM_LHEAP, heap->addr, heap->disk_alloc, dxpl_id, heap->chunk + sizeof_hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_WRITEERROR, FAIL, "unable to write heap data to file") } heap->cache_info.is_dirty = FALSE; } /* Should we destroy the memory version? */ if (destroy) { if (H5HL_dest(f,heap) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy local heap collection") } done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5HL_dest * * Purpose: Destroys a heap in memory. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * Jan 15 2003 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5HL_dest(H5F_t UNUSED *f, H5HL_t *heap) { H5HL_free_t *fl; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HL_dest); /* check arguments */ assert(heap); /* Verify that node is clean */ assert (heap->cache_info.is_dirty==FALSE); if(heap->chunk) heap->chunk = H5FL_BLK_FREE(heap_chunk,heap->chunk); while (heap->freelist) { fl = heap->freelist; heap->freelist = fl->next; H5FL_FREE(H5HL_free_t,fl); } H5FL_FREE(H5HL_t,heap); FUNC_LEAVE_NOAPI(SUCCEED); } /* end H5HL_dest() */ /*------------------------------------------------------------------------- * Function: H5HL_clear * * Purpose: Mark a local heap in memory as non-dirty. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * Mar 20 2003 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5HL_clear(H5F_t *f, H5HL_t *heap, hbool_t destroy) { herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT(H5HL_clear); /* check arguments */ assert(heap); /* Mark heap as clean */ heap->cache_info.is_dirty = FALSE; if (destroy) if (H5HL_dest(f, heap) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy local heap collection"); done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5HL_clear() */ /*------------------------------------------------------------------------- * Function: H5HL_compute_size * * Purpose: Compute the size in bytes of the specified instance of * H5HL_t on disk, and return it in *len_ptr. On failure, * the value of *len_ptr is undefined. * * Return: Non-negative on success/Negative on failure * * Programmer: John Mainzer * 5/13/04 * * Modifications: *------------------------------------------------------------------------- */ static herr_t H5HL_compute_size(const H5F_t *f, const H5HL_t *heap, size_t *size_ptr) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HL_compute_size); /* check arguments */ HDassert(f); HDassert(heap); HDassert(size_ptr); *size_ptr = H5HL_SIZEOF_HDR(f) + heap->disk_alloc; FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HL_compute_size() */ /*------------------------------------------------------------------------- * Function: H5HL_read * * Purpose: Reads some object (or part of an object) from the heap * whose address is ADDR in file F. OFFSET is the byte offset * from the beginning of the heap at which to begin reading * and SIZE is the number of bytes to read. * * If BUF is the null pointer then a buffer is allocated by * this function. * * Attempting to read past the end of an object may cause this * function to fail. * * Return: Success: BUF (or the allocated buffer) * * Failure: NULL * * Programmer: Robb Matzke * matzke@llnl.gov * Jul 16 1997 * * Modifications: * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. *------------------------------------------------------------------------- */ #ifdef NOT_YET static void * H5HL_read(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t offset, size_t size, void *buf) { H5HL_t *heap = NULL; void *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5HL_read, NULL); /* check arguments */ assert(f); assert (H5F_addr_defined(addr)); if (NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL, H5AC_READ))) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "unable to load heap"); assert(offset < heap->mem_alloc); assert(offset + size <= heap->mem_alloc); if (!buf && NULL==(buf = H5MM_malloc(size))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); HDmemcpy(buf, heap->chunk + H5HL_SIZEOF_HDR(f) + offset, size); /* Set return value */ ret_value=buf; done: if (heap && H5AC_unprotect(f, dxpl_id, H5AC_LHEAP, addr, heap, FALSE) != SUCCEED) HDONE_ERROR(H5E_HEAP, H5E_PROTECT, NULL, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value); } #endif /* NOT_YET */ /*------------------------------------------------------------------------- * Function: H5HL_protect * * Purpose: This function is a wrapper for the H5AC_protect call. The * old H5HL_peek call (which this once was) wasn't "safe" * for FPHDF5. (It'd get a read lock on an object but once * it got that object, it'd release it keeping the old * pointer value, which is no longer valid. This won't work * since the pointer into some metdata block can become * invalid.) * * N.B.: This function is always called in conjunction with * the H5HL_offset_into function. The return from that * function is the proper pointer to the heap's object. This * is done so that the return from this function can be sent * to H5HL_unprotect. * * Return: Success: Ptr to the object. The pointer points to a * chunk of memory large enough to hold the * object from the specified offset (usually the * beginning of the object) to the end of the * object. Do not attempt to read past the end * of the object. * Failure: NULL * * Programmer: Bill Wendling * wendling@ncsa.uiuc.edu * Sept. 17, 2003 * * Modifications: * *------------------------------------------------------------------------- */ const H5HL_t * H5HL_protect(H5F_t *f, hid_t dxpl_id, haddr_t addr) { H5HL_t *ret_value = NULL; FUNC_ENTER_NOAPI(H5HL_protect, NULL); /* check arguments */ assert(f); assert(H5F_addr_defined(addr)); if (NULL == (ret_value = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL, H5AC_READ))) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "unable to load heap"); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5HL_offset_into * * Purpose: Called directly after the call to H5HL_protect so that * a pointer to the object in the heap can be got. * * Return: Success: Valid pointer. * Failure: NULL * * Programmer: Bill Wendling * wendling@ncsa.uiuc.edu * Sept. 17, 2003 * * Modifications: * *------------------------------------------------------------------------- */ void * H5HL_offset_into(H5F_t *f, const H5HL_t *heap, size_t offset) { /* * We need to have called some other function before this to get a * valid heap pointer. So, this can remain "FUNC_ENTER_NOAPI_NOINIT" */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HL_offset_into) assert(f); assert(heap); assert(offset < heap->mem_alloc); FUNC_LEAVE_NOAPI(heap->chunk + H5HL_SIZEOF_HDR(f) + offset) } /*------------------------------------------------------------------------- * Function: H5HL_unprotect * * Purpose: Unprotect the data retrieved by the H5HL_protect call. * * Return: Success: SUCCEED * Failure: FAIL * * Programmer: Bill Wendling * wendling@ncsa.uiuc.edu * Sept. 17, 2003 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5HL_unprotect(H5F_t *f, hid_t dxpl_id, const H5HL_t *heap, haddr_t addr) { herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5HL_unprotect, FAIL); /* check arguments */ assert(f); assert(heap); assert(H5F_addr_defined(addr)); if (H5AC_unprotect(f, dxpl_id, H5AC_LHEAP, addr, (void *)heap, FALSE) != SUCCEED) HGOTO_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release object header"); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5HL_remove_free * * Purpose: Removes free list element FL from the specified heap and * frees it. * * Return: NULL * * Programmer: Robb Matzke * matzke@llnl.gov * Jul 17 1997 * * Modifications: * *------------------------------------------------------------------------- */ static H5HL_free_t * H5HL_remove_free(H5HL_t *heap, H5HL_free_t *fl) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HL_remove_free); if (fl->prev) fl->prev->next = fl->next; if (fl->next) fl->next->prev = fl->prev; if (!fl->prev) heap->freelist = fl->next; FUNC_LEAVE_NOAPI(H5FL_FREE(H5HL_free_t,fl)); } /*------------------------------------------------------------------------- * Function: H5HL_insert * * Purpose: Inserts a new item into the heap. * * Return: Success: Offset of new item within heap. * * Failure: (size_t)(-1) * * Programmer: Robb Matzke * matzke@llnl.gov * Jul 17 1997 * * Modifications: * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. *------------------------------------------------------------------------- */ size_t H5HL_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t buf_size, const void *buf) { H5HL_t *heap = NULL; H5HL_free_t *fl = NULL, *max_fl = NULL; size_t offset = 0; size_t need_size, old_size, need_more; hbool_t found; size_t disk_resrv; /* Amount of additional space to reserve in file */ size_t sizeof_hdr; /* Cache H5HL header size for file */ size_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5HL_insert, (size_t)(-1)); /* check arguments */ assert(f); assert(H5F_addr_defined(addr)); assert(buf_size > 0); assert(buf); if (0==(f->intent & H5F_ACC_RDWR)) HGOTO_ERROR (H5E_HEAP, H5E_WRITEERROR, (size_t)(-1), "no write intent on file"); if (NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL, H5AC_WRITE))) HGOTO_ERROR(H5E_HEAP, H5E_PROTECT, (size_t)(-1), "unable to load heap"); heap->cache_info.is_dirty=TRUE; /* Cache this for later */ sizeof_hdr= H5HL_SIZEOF_HDR(f); /* * In order to keep the free list descriptors aligned on word boundaries, * whatever that might mean, we round the size up to the next multiple of * a word. */ need_size = H5HL_ALIGN(buf_size); /* * Look for a free slot large enough for this object and which would * leave zero or at least H5G_SIZEOF_FREE bytes left over. */ for (fl=heap->freelist, found=FALSE; fl; fl=fl->next) { if (fl->size > need_size && fl->size - need_size >= H5HL_SIZEOF_FREE(f)) { /* a bigger free block was found */ offset = fl->offset; fl->offset += need_size; fl->size -= need_size; assert (fl->offset==H5HL_ALIGN (fl->offset)); assert (fl->size==H5HL_ALIGN (fl->size)); found = TRUE; break; } else if (fl->size == need_size) { /* free block of exact size found */ offset = fl->offset; fl = H5HL_remove_free(heap, fl); found = TRUE; break; } else if (!max_fl || max_fl->offset < fl->offset) { /* use worst fit */ max_fl = fl; } } /* * If no free chunk was large enough, then allocate more space and * add it to the free list. If the heap ends with a free chunk, we * can extend that free chunk. Otherwise we'll have to make another * free chunk. If the heap must expand, we double its size. */ if (found==FALSE) { need_more = MAX3(need_size, heap->mem_alloc, H5HL_SIZEOF_FREE(f)); /* Reserve space in the file to hold the increased heap size */ if( heap->disk_resrv == heap->mem_alloc) disk_resrv = need_more; else disk_resrv = heap->mem_alloc + need_more - heap->disk_resrv; if( H5MF_reserve(f, (hsize_t)disk_resrv) < 0 ) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, (size_t)(-1), "unable to reserve space in file"); /* Update heap's record of how much space it has reserved */ heap->disk_resrv += disk_resrv; if (max_fl && max_fl->offset + max_fl->size == heap->mem_alloc) { /* * Increase the size of the maximum free block. */ offset = max_fl->offset; max_fl->offset += need_size; max_fl->size += need_more - need_size; assert (max_fl->offset==H5HL_ALIGN (max_fl->offset)); assert (max_fl->size==H5HL_ALIGN (max_fl->size)); if (max_fl->size < H5HL_SIZEOF_FREE(f)) { #ifdef H5HL_DEBUG if (H5DEBUG(HL) && max_fl->size) { fprintf(H5DEBUG(HL), "H5HL: lost %lu bytes at line %d\n", (unsigned long)(max_fl->size), __LINE__); } #endif max_fl = H5HL_remove_free(heap, max_fl); } } else { /* * Create a new free list element large enough that we can * take some space out of it right away. */ offset = heap->mem_alloc; if (need_more - need_size >= H5HL_SIZEOF_FREE(f)) { if (NULL==(fl = H5FL_MALLOC(H5HL_free_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, (size_t)(-1), "memory allocation failed"); fl->offset = heap->mem_alloc + need_size; fl->size = need_more - need_size; assert (fl->offset==H5HL_ALIGN (fl->offset)); assert (fl->size==H5HL_ALIGN (fl->size)); fl->prev = NULL; fl->next = heap->freelist; if (heap->freelist) heap->freelist->prev = fl; heap->freelist = fl; #ifdef H5HL_DEBUG } else if (H5DEBUG(HL) && need_more > need_size) { fprintf(H5DEBUG(HL), "H5HL_insert: lost %lu bytes at line %d\n", (unsigned long)(need_more - need_size), __LINE__); #endif } } #ifdef H5HL_DEBUG if (H5DEBUG(HL)) { fprintf(H5DEBUG(HL), "H5HL: resize mem buf from %lu to %lu bytes\n", (unsigned long)(heap->mem_alloc), (unsigned long)(heap->mem_alloc + need_more)); } #endif old_size = heap->mem_alloc; heap->mem_alloc += need_more; heap->chunk = H5FL_BLK_REALLOC(heap_chunk,heap->chunk, (sizeof_hdr + heap->mem_alloc)); if (NULL==heap->chunk) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, (size_t)(-1), "memory allocation failed"); /* clear new section so junk doesn't appear in the file */ HDmemset(heap->chunk + sizeof_hdr + old_size, 0, need_more); } /* * Copy the data into the heap */ HDmemcpy(heap->chunk + sizeof_hdr + offset, buf, buf_size); /* Set return value */ ret_value=offset; done: if (heap && H5AC_unprotect(f, dxpl_id, H5AC_LHEAP, addr, heap, FALSE) != SUCCEED) HDONE_ERROR(H5E_HEAP, H5E_PROTECT, (size_t)(-1), "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value); } #ifdef NOT_YET /*------------------------------------------------------------------------- * Function: H5HL_write * * Purpose: Writes (overwrites) the object (or part of object) stored * in BUF to the heap at file address ADDR in file F. The * writing begins at byte offset OFFSET from the beginning of * the heap and continues for SIZE bytes. * * Do not partially write an object to create it; the first * write for an object must be for the entire object. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Jul 16 1997 * * Modifications: * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. *------------------------------------------------------------------------- */ static herr_t H5HL_write(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t offset, size_t size, const void *buf) { H5HL_t *heap = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5HL_write, FAIL); /* check arguments */ assert(f); assert(H5F_addr_defined(addr)); assert(buf); assert (offset==H5HL_ALIGN (offset)); if (0==(f->intent & H5F_ACC_RDWR)) HGOTO_ERROR (H5E_HEAP, H5E_WRITEERROR, FAIL, "no write intent on file"); if (NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL, H5AC_WRITE))) HGOTO_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to load heap"); assert(offset < heap->mem_alloc); assert(offset + size <= heap->mem_alloc); heap->cache_info.is_dirty=TRUE; HDmemcpy(heap->chunk + H5HL_SIZEOF_HDR(f) + offset, buf, size); done: if (heap && H5AC_unprotect(f, dxpl_id, H5AC_LHEAP, addr, heap, FALSE) != SUCCEED && ret_value != FAIL) HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value); } #endif /* NOT_YET */ /*------------------------------------------------------------------------- * Function: H5HL_remove * * Purpose: Removes an object or part of an object from the heap at * address ADDR of file F. The object (or part) to remove * begins at byte OFFSET from the beginning of the heap and * continues for SIZE bytes. * * Once part of an object is removed, one must not attempt * to access that part. Removing the beginning of an object * results in the object OFFSET increasing by the amount * truncated. Removing the end of an object results in * object truncation. Removing the middle of an object results * in two separate objects, one at the original offset and * one at the first offset past the removed portion. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Jul 16 1997 * * Modifications: * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. *------------------------------------------------------------------------- */ herr_t H5HL_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t offset, size_t size) { H5HL_t *heap = NULL; H5HL_free_t *fl = NULL, *fl2 = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5HL_remove, FAIL); /* check arguments */ assert(f); assert(H5F_addr_defined(addr)); assert(size > 0); assert (offset==H5HL_ALIGN (offset)); if (0==(f->intent & H5F_ACC_RDWR)) HGOTO_ERROR (H5E_HEAP, H5E_WRITEERROR, FAIL, "no write intent on file"); size = H5HL_ALIGN (size); if (NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL, H5AC_WRITE))) HGOTO_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to load heap"); assert(offset < heap->mem_alloc); assert(offset + size <= heap->mem_alloc); fl = heap->freelist; heap->cache_info.is_dirty=TRUE; /* * Check if this chunk can be prepended or appended to an already * free chunk. It might also fall between two chunks in such a way * that all three chunks can be combined into one. */ while (fl) { if (offset + size == fl->offset) { fl->offset = offset; fl->size += size; assert (fl->offset==H5HL_ALIGN (fl->offset)); assert (fl->size==H5HL_ALIGN (fl->size)); fl2 = fl->next; while (fl2) { if (fl2->offset + fl2->size == fl->offset) { fl->offset = fl2->offset; fl->size += fl2->size; assert (fl->offset==H5HL_ALIGN (fl->offset)); assert (fl->size==H5HL_ALIGN (fl->size)); fl2 = H5HL_remove_free(heap, fl2); HGOTO_DONE(SUCCEED); } fl2 = fl2->next; } HGOTO_DONE(SUCCEED); } else if (fl->offset + fl->size == offset) { fl->size += size; fl2 = fl->next; assert (fl->size==H5HL_ALIGN (fl->size)); while (fl2) { if (fl->offset + fl->size == fl2->offset) { fl->size += fl2->size; assert (fl->size==H5HL_ALIGN (fl->size)); fl2 = H5HL_remove_free(heap, fl2); HGOTO_DONE(SUCCEED); } fl2 = fl2->next; } HGOTO_DONE(SUCCEED); } fl = fl->next; } /* * The amount which is being removed must be large enough to * hold the free list data. If not, the freed chunk is forever * lost. */ if (size < H5HL_SIZEOF_FREE(f)) { #ifdef H5HL_DEBUG if (H5DEBUG(HL)) { fprintf(H5DEBUG(HL), "H5HL: lost %lu bytes\n", (unsigned long) size); } #endif HGOTO_DONE(SUCCEED); } /* * Add an entry to the free list. */ if (NULL==(fl = H5FL_MALLOC(H5HL_free_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); fl->offset = offset; fl->size = size; assert (fl->offset==H5HL_ALIGN (fl->offset)); assert (fl->size==H5HL_ALIGN (fl->size)); fl->prev = NULL; fl->next = heap->freelist; if (heap->freelist) heap->freelist->prev = fl; heap->freelist = fl; done: if (heap && H5AC_unprotect(f, dxpl_id, H5AC_LHEAP, addr, heap, FALSE) != SUCCEED) HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5HL_delete * * Purpose: Deletes a local heap from disk, freeing disk space used. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * Mar 22 2003 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5HL_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr) { H5HL_t *heap = NULL; size_t sizeof_hdr; /* Cache H5HL header size for file */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5HL_delete, FAIL); /* check arguments */ assert(f); assert(H5F_addr_defined(addr)); /* Check for write access */ if (0==(f->intent & H5F_ACC_RDWR)) HGOTO_ERROR (H5E_HEAP, H5E_WRITEERROR, FAIL, "no write intent on file"); /* Cache this for later */ sizeof_hdr= H5HL_SIZEOF_HDR(f); /* Get heap pointer */ if (NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL, H5AC_WRITE))) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap"); /* Check if the heap is contiguous on disk */ assert(!H5F_addr_overflow(addr,sizeof_hdr)); if(H5F_addr_eq(heap->addr,addr+sizeof_hdr)) { /* Free the contiguous local heap in one call */ H5_CHECK_OVERFLOW(sizeof_hdr+heap->disk_alloc,size_t,hsize_t); if (H5MF_xfree(f, H5FD_MEM_LHEAP, dxpl_id, addr, (hsize_t)(sizeof_hdr+heap->disk_alloc))<0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free contiguous local heap"); } /* end if */ else { /* Free the local heap's header */ H5_CHECK_OVERFLOW(sizeof_hdr,size_t,hsize_t); if (H5MF_xfree(f, H5FD_MEM_LHEAP, dxpl_id, addr, (hsize_t)sizeof_hdr)<0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free local heap header"); /* Free the local heap's data */ H5_CHECK_OVERFLOW(heap->disk_alloc,size_t,hsize_t); if (H5MF_xfree(f, H5FD_MEM_LHEAP, dxpl_id, heap->addr, (hsize_t)heap->disk_alloc)<0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free local heap data"); } /* end else */ /* Release the local heap metadata from the cache */ if (H5AC_unprotect(f, dxpl_id, H5AC_LHEAP, addr, heap, TRUE)<0) { heap = NULL; HGOTO_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release local heap"); } heap = NULL; done: if (heap && H5AC_unprotect(f, dxpl_id, H5AC_LHEAP, addr, heap, FALSE)<0) HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release local heap"); FUNC_LEAVE_NOAPI(ret_value); } /* end H5HL_delete() */ xdmf-3.0+git20160803/Utilities/hdf5/HDF5Tests/0000740000175000017500000000000013003006557020402 5ustar alastairalastairxdmf-3.0+git20160803/Utilities/hdf5/HDF5Tests/CVS/0000740000175000017500000000000013003006557021035 5ustar alastairalastairxdmf-3.0+git20160803/Utilities/hdf5/HDF5Tests/CVS/Repository0000640000175000017500000000003613003006557023140 0ustar alastairalastairXdmf/Utilities/hdf5/HDF5Tests xdmf-3.0+git20160803/Utilities/hdf5/HDF5Tests/CVS/Root0000640000175000017500000000006413003006557021705 0ustar alastairalastair:pserver:anonymous@public.kitware.com:/cvsroot/Xdmf xdmf-3.0+git20160803/Utilities/hdf5/HDF5Tests/CVS/Entries0000640000175000017500000000000213003006557022363 0ustar alastairalastairD xdmf-3.0+git20160803/Utilities/hdf5/H5Toffset.c0000640000175000017500000002250513003006557020652 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Module Info: This module contains the functionality for setting & querying * the datatype offset for the H5T interface. */ #define H5T_PACKAGE /*suppress error about including H5Tpkg */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5T_init_offset_interface #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Iprivate.h" /* IDs */ #include "H5Tpkg.h" /* Datatypes */ /* Static local functions */ static herr_t H5T_set_offset(const H5T_t *dt, size_t offset); /*-------------------------------------------------------------------------- NAME H5T_init_offset_interface -- Initialize interface-specific information USAGE herr_t H5T_init_offset_interface() RETURNS Non-negative on success/Negative on failure DESCRIPTION Initializes any interface-specific data or routines. (Just calls H5T_init_iterface currently). --------------------------------------------------------------------------*/ static herr_t H5T_init_offset_interface(void) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_init_offset_interface) FUNC_LEAVE_NOAPI(H5T_init()) } /* H5T_init_offset_interface() */ /*------------------------------------------------------------------------- * Function: H5Tget_offset * * Purpose: Retrieves the bit offset of the first significant bit. The * signficant bits of an atomic datum can be offset from the * beginning of the memory for that datum by an amount of * padding. The `offset' property specifies the number of bits * of padding that appear to the "right of" the value. That is, * if we have a 32-bit datum with 16-bits of precision having * the value 0x1122 then it will be layed out in memory as (from * small byte address toward larger byte addresses): * * Big Big Little Little * Endian Endian Endian Endian * offset=0 offset=16 offset=0 offset=16 * * 0: [ pad] [0x11] [0x22] [ pad] * 1: [ pad] [0x22] [0x11] [ pad] * 2: [0x11] [ pad] [ pad] [0x22] * 3: [0x22] [ pad] [ pad] [0x11] * * Return: Success: The offset (non-negative) * * Failure: Negative * * Programmer: Robb Matzke * Wednesday, January 7, 1998 * * Modifications: * Robb Matzke, 22 Dec 1998 * Also works for derived data types. * *------------------------------------------------------------------------- */ int H5Tget_offset(hid_t type_id) { H5T_t *dt = NULL; int ret_value; FUNC_ENTER_API(H5Tget_offset, -1) H5TRACE1("Is","i",type_id); /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an atomic data type") while (dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ if (!H5T_IS_ATOMIC(dt->shared)) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "operation not defined for specified data type") /* Offset */ ret_value = (int)dt->shared->u.atomic.offset; done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5Tset_offset * * Purpose: Sets the bit offset of the first significant bit. The * signficant bits of an atomic datum can be offset from the * beginning of the memory for that datum by an amount of * padding. The `offset' property specifies the number of bits * of padding that appear to the "right of" the value. That is, * if we have a 32-bit datum with 16-bits of precision having * the value 0x1122 then it will be layed out in memory as (from * small byte address toward larger byte addresses): * * Big Big Little Little * Endian Endian Endian Endian * offset=0 offset=16 offset=0 offset=16 * * 0: [ pad] [0x11] [0x22] [ pad] * 1: [ pad] [0x22] [0x11] [ pad] * 2: [0x11] [ pad] [ pad] [0x22] * 3: [0x22] [ pad] [ pad] [0x11] * * If the offset is incremented then the total size is * incremented also if necessary to prevent significant bits of * the value from hanging over the edge of the data type. * * The offset of an H5T_STRING cannot be set to anything but * zero. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Wednesday, January 7, 1998 * * Modifications: * Robb Matzke, 22 Dec 1998 * Moved real work to a private function. * *------------------------------------------------------------------------- */ herr_t H5Tset_offset(hid_t type_id, size_t offset) { H5T_t *dt = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Tset_offset, FAIL) H5TRACE2("e","iz",type_id,offset); /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an atomic data type") if (H5T_STATE_TRANSIENT!=dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only") if (H5T_STRING == dt->shared->type && offset != 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "offset must be zero for this type") if (H5T_ENUM==dt->shared->type && dt->shared->u.enumer.nmembs>0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not allowed after members are defined") if (H5T_COMPOUND==dt->shared->type || H5T_REFERENCE==dt->shared->type || H5T_OPAQUE==dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "operation not defined for this datatype") /* Do the real work */ if (H5T_set_offset(dt, offset)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to set offset") done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5T_set_offset * * Purpose: Sets the bit offset of the first significant bit. The * signficant bits of an atomic datum can be offset from the * beginning of the memory for that datum by an amount of * padding. The `offset' property specifies the number of bits * of padding that appear to the "right of" the value. That is, * if we have a 32-bit datum with 16-bits of precision having * the value 0x1122 then it will be layed out in memory as (from * small byte address toward larger byte addresses): * * Big Big Little Little * Endian Endian Endian Endian * offset=0 offset=16 offset=0 offset=16 * * 0: [ pad] [0x11] [0x22] [ pad] * 1: [ pad] [0x22] [0x11] [ pad] * 2: [0x11] [ pad] [ pad] [0x22] * 3: [0x22] [ pad] [ pad] [0x11] * * If the offset is incremented then the total size is * incremented also if necessary to prevent significant bits of * the value from hanging over the edge of the data type. * * The offset of an H5T_STRING cannot be set to anything but * zero. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Wednesday, January 7, 1998 * * Modifications: * Robb Matzke, 22 Dec 1998 * Also works for derived data types. * *------------------------------------------------------------------------- */ static herr_t H5T_set_offset(const H5T_t *dt, size_t offset) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_set_offset, FAIL) /* Check args */ assert(dt); assert(H5T_STRING!=dt->shared->type || 0==offset); assert(H5T_REFERENCE!=dt->shared->type); assert(H5T_OPAQUE!=dt->shared->type); assert(H5T_COMPOUND!=dt->shared->type); assert(!(H5T_ENUM==dt->shared->type && 0==dt->shared->u.enumer.nmembs)); if (dt->shared->parent) { if (H5T_set_offset(dt->shared->parent, offset)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to set offset for base type") /* Adjust size of datatype appropriately */ if(dt->shared->type==H5T_ARRAY) dt->shared->size = dt->shared->parent->shared->size * dt->shared->u.array.nelem; else if(dt->shared->type!=H5T_VLEN) dt->shared->size = dt->shared->parent->shared->size; } else { if (offset+dt->shared->u.atomic.prec > 8*dt->shared->size) dt->shared->size = (offset + dt->shared->u.atomic.prec + 7) / 8; dt->shared->u.atomic.offset = offset; } done: FUNC_LEAVE_NOAPI(ret_value) } xdmf-3.0+git20160803/Utilities/hdf5/H5Fprivate.h0000640000175000017500000005034613003006557021031 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * This file contains macros & information for file access */ #ifndef _H5Fprivate_H #define _H5Fprivate_H /* Include package's public header */ #include "H5Fpublic.h" /* Public headers needed by this file */ #include "H5FDpublic.h" /* File drivers */ /* Private headers needed by this file */ /****************************/ /* Library Private Typedefs */ /****************************/ /* Main file structure */ typedef struct H5F_t H5F_t; /*===----------------------------------------------------------------------=== * Flush Flags *===----------------------------------------------------------------------=== * * Flags passed into the flush routines which indicate what type of * flush we want to do. They can be ORed together. */ #define H5F_FLUSH_NONE (0U) /* No flags specified */ #define H5F_FLUSH_INVALIDATE (1U << 0) /* Invalidate cached data */ #define H5F_FLUSH_CLOSING (1U << 1) /* Closing the file */ #define H5F_FLUSH_CLEAR_ONLY (1U << 2) /* Don't write, just clear dirty flags */ /* * Encode and decode macros for file meta-data. * Currently, all file meta-data is little-endian. */ # define INT16ENCODE(p, i) { \ *(p) = (uint8_t)( (unsigned)(i) & 0xff); (p)++; \ *(p) = (uint8_t)(((unsigned)(i) >> 8) & 0xff); (p)++; \ } # define UINT16ENCODE(p, i) { \ *(p) = (uint8_t)( (unsigned)(i) & 0xff); (p)++; \ *(p) = (uint8_t)(((unsigned)(i) >> 8) & 0xff); (p)++; \ } # define INT32ENCODE(p, i) { \ *(p) = (uint8_t)( (uint32_t)(i) & 0xff); (p)++; \ *(p) = (uint8_t)(((uint32_t)(i) >> 8) & 0xff); (p)++; \ *(p) = (uint8_t)(((uint32_t)(i) >> 16) & 0xff); (p)++; \ *(p) = (uint8_t)(((uint32_t)(i) >> 24) & 0xff); (p)++; \ } # define UINT32ENCODE(p, i) { \ *(p) = (uint8_t)( (i) & 0xff); (p)++; \ *(p) = (uint8_t)(((i) >> 8) & 0xff); (p)++; \ *(p) = (uint8_t)(((i) >> 16) & 0xff); (p)++; \ *(p) = (uint8_t)(((i) >> 24) & 0xff); (p)++; \ } # define INT64ENCODE(p, n) { \ int64_t _n = (n); \ size_t _i; \ uint8_t *_p = (uint8_t*)(p); \ for (_i=0; _i>=8) { \ *_p++ = (uint8_t)(_n & 0xff); \ } \ for (/*void*/; _i<8; _i++) { \ *_p++ = (n)<0 ? 0xff : 0; \ } \ (p) = (uint8_t*)(p)+8; \ } # define UINT64ENCODE(p, n) { \ uint64_t _n = (n); \ size_t _i; \ uint8_t *_p = (uint8_t*)(p); \ for (_i=0; _i>=8) { \ *_p++ = (uint8_t)(_n & 0xff); \ } \ for (/*void*/; _i<8; _i++) { \ *_p++ = 0; \ } \ (p) = (uint8_t*)(p)+8; \ } /* DECODE converts little endian bytes pointed by p to integer values and store * it in i. For signed values, need to do sign-extension when converting * the last byte which carries the sign bit. * The macros does not require i be of a certain byte sizes. It just requires * i be big enough to hold the intended value range. E.g. INT16DECODE works * correctly even if i is actually a 64bit int like in a Cray. */ # define INT16DECODE(p, i) { \ (i) = (int16_t)((*(p) & 0xff)); (p)++; \ (i) |= (int16_t)(((*(p) & 0xff) << 8) | \ ((*(p) & 0x80) ? ~0xffff : 0x0)); (p)++; \ } # define UINT16DECODE(p, i) { \ (i) = (uint16_t) (*(p) & 0xff); (p)++; \ (i) |= (uint16_t)((*(p) & 0xff) << 8); (p)++; \ } # define INT32DECODE(p, i) { \ (i) = ( *(p) & 0xff); (p)++; \ (i) |= ((int32_t)(*(p) & 0xff) << 8); (p)++; \ (i) |= ((int32_t)(*(p) & 0xff) << 16); (p)++; \ (i) |= ((int32_t)(((*(p) & 0xff) << 24) | \ ((*(p) & 0x80) ? ~0xffffffff : 0x0))); (p)++; \ } # define UINT32DECODE(p, i) { \ (i) = (uint32_t)(*(p) & 0xff); (p)++; \ (i) |= ((uint32_t)(*(p) & 0xff) << 8); (p)++; \ (i) |= ((uint32_t)(*(p) & 0xff) << 16); (p)++; \ (i) |= ((uint32_t)(*(p) & 0xff) << 24); (p)++; \ } # define INT64DECODE(p, n) { \ /* WE DON'T CHECK FOR OVERFLOW! */ \ size_t _i; \ n = 0; \ (p) += 8; \ for (_i=0; _i(Y)) #define H5F_addr_ge(X,Y) ((X)!=HADDR_UNDEF && \ (Y)!=HADDR_UNDEF && \ (X)>=(Y)) #define H5F_addr_cmp(X,Y) (H5F_addr_eq(X,Y)?0: \ (H5F_addr_lt(X, Y)?-1:1)) #define H5F_addr_pow2(N) ((haddr_t)1<<(N)) #define H5F_addr_overlap(O1,L1,O2,L2) ((O1O2) || \ (O1>=O2 && O1<(O2+L2))) /* If the module using this macro is allowed access to the private variables, access them directly */ #ifdef H5F_PACKAGE /* size of size_t and off_t as they exist on disk */ #define H5F_SIZEOF_ADDR(F) ((F)->shared->sizeof_addr) #define H5F_SIZEOF_SIZE(F) ((F)->shared->sizeof_size) /* Size of symbol table leafs */ #define H5F_SYM_LEAF_K(F) ((F)->shared->sym_leaf_k) /* B-tree key value size */ #define H5F_KVALUE(F,T) ((F)->shared->btree_k[(T)->id]) /* Raw data cache values */ #define H5F_RDCC_NELMTS(F) ((F)->shared->rdcc_nelmts) #define H5F_RDCC_NBYTES(F) ((F)->shared->rdcc_nbytes) #define H5F_RDCC_W0(F) ((F)->shared->rdcc_w0) /* Check for file driver feature enabled */ #define H5F_HAS_FEATURE(F,FL) ((F)->shared->lf->feature_flags&(FL)) /* B-tree node raw page */ #define H5F_GRP_BTREE_SHARED(F) ((F)->shared->grp_btree_shared) /* Base address of file */ #define H5F_BASE_ADDR(F) ((F)->shared->base_addr) /* Sieve buffer size for datasets */ #define H5F_SIEVE_BUF_SIZE(F) ((F)->shared->sieve_buf_size) #else /* H5F_PACKAGE */ #define H5F_SIZEOF_ADDR(F) (H5F_sizeof_addr(F)) #define H5F_SIZEOF_SIZE(F) (H5F_sizeof_size(F)) #define H5F_SYM_LEAF_K(F) (H5F_sym_leaf_k(F)) #define H5F_KVALUE(F,T) (H5F_Kvalue(F,T)) #define H5F_RDCC_NELMTS(F) (H5F_rdcc_nelmts(F)) #define H5F_RDCC_NBYTES(F) (H5F_rdcc_nbytes(F)) #define H5F_RDCC_W0(F) (H5F_rdcc_w0(F)) #define H5F_HAS_FEATURE(F,FL) (H5F_has_feature(F,FL)) #define H5F_GRP_BTREE_SHARED(F) (H5F_grp_btree_shared(F)) #define H5F_BASE_ADDR(F) (H5F_get_base_addr(F)) #define H5F_SIEVE_BUF_SIZE(F) (H5F_sieve_buf_size(F)) #endif /* H5F_PACKAGE */ /* Macros to encode/decode offset/length's for storing in the file */ #ifdef NOT_YET #define H5F_ENCODE_OFFSET(f,p,o) (H5F_SIZEOF_ADDR(f)==4 ? UINT32ENCODE(p,o) \ : H5F_SIZEOF_ADDR(f)==8 ? UINT64ENCODE(p,o) \ : H5F_SIZEOF_ADDR(f)==2 ? UINT16ENCODE(p,o) \ : H5FPencode_unusual_offset(f,&(p),(uint8_t*)&(o))) #else /* NOT_YET */ #define H5F_ENCODE_OFFSET(f,p,o) switch(H5F_SIZEOF_ADDR(f)) { \ case 4: UINT32ENCODE(p,o); break; \ case 8: UINT64ENCODE(p,o); break; \ case 2: UINT16ENCODE(p,o); break; \ } #endif /* NOT_YET */ #define H5F_DECODE_OFFSET(f,p,o) switch (H5F_SIZEOF_ADDR (f)) { \ case 4: UINT32DECODE (p, o); break; \ case 8: UINT64DECODE (p, o); break; \ case 2: UINT16DECODE (p, o); break; \ } #define H5F_ENCODE_LENGTH(f,p,l) switch(H5F_SIZEOF_SIZE(f)) { \ case 4: UINT32ENCODE(p,l); break; \ case 8: UINT64ENCODE(p,l); break; \ case 2: UINT16ENCODE(p,l); break; \ } #define H5F_DECODE_LENGTH(f,p,l) switch(H5F_SIZEOF_SIZE(f)) { \ case 4: UINT32DECODE(p,l); break; \ case 8: UINT64DECODE(p,l); break; \ case 2: UINT16DECODE(p,l); break; \ } /* * Macros that check for overflows. These are somewhat dangerous to fiddle * with. */ #if (H5_SIZEOF_SIZE_T >= H5_SIZEOF_OFF_T) # define H5F_OVERFLOW_SIZET2OFFT(X) \ ((size_t)(X)>=(size_t)((size_t)1<<(8*sizeof(off_t)-1))) #else # define H5F_OVERFLOW_SIZET2OFFT(X) 0 #endif #if (H5_SIZEOF_HSIZE_T >= H5_SIZEOF_OFF_T) # define H5F_OVERFLOW_HSIZET2OFFT(X) \ ((hsize_t)(X)>=(hsize_t)((hsize_t)1<<(8*sizeof(off_t)-1))) #else # define H5F_OVERFLOW_HSIZET2OFFT(X) 0 #endif /* ========= File Creation properties ============ */ /* Definitions for the size of the file user block in bytes */ #define H5F_CRT_USER_BLOCK_NAME "block_size" #define H5F_CRT_USER_BLOCK_SIZE sizeof(hsize_t) #define H5F_CRT_USER_BLOCK_DEF 0 /* Definitions for the 1/2 rank for symbol table leaf nodes */ #define H5F_CRT_SYM_LEAF_NAME "symbol_leaf" #define H5F_CRT_SYM_LEAF_SIZE sizeof(unsigned) #define H5F_CRT_SYM_LEAF_DEF 4 /* Definitions for the 1/2 rank for btree internal nodes */ #define H5F_CRT_BTREE_RANK_NAME "btree_rank" #define H5F_CRT_BTREE_RANK_SIZE sizeof(unsigned[H5B_NUM_BTREE_ID]) #define H5F_CRT_BTREE_RANK_DEF {HDF5_BTREE_SNODE_IK_DEF,HDF5_BTREE_ISTORE_IK_DEF} /* Definitions for byte number in an address */ #define H5F_CRT_ADDR_BYTE_NUM_NAME "addr_byte_num" #define H5F_CRT_ADDR_BYTE_NUM_SIZE sizeof(size_t) #define H5F_CRT_ADDR_BYTE_NUM_DEF sizeof(haddr_t) /* Definitions for byte number for object size */ #define H5F_CRT_OBJ_BYTE_NUM_NAME "obj_byte_num" #define H5F_CRT_OBJ_BYTE_NUM_SIZE sizeof(size_t) #define H5F_CRT_OBJ_BYTE_NUM_DEF sizeof(hsize_t) /* Definitions for version number of the superblock */ #define H5F_CRT_SUPER_VERS_NAME "super_version" #define H5F_CRT_SUPER_VERS_SIZE sizeof(unsigned) #define H5F_CRT_SUPER_VERS_DEF HDF5_SUPERBLOCK_VERSION_DEF /* Definitions for free-space version number */ #define H5F_CRT_FREESPACE_VERS_NAME "free_space_version" #define H5F_CRT_FREESPACE_VERS_SIZE sizeof(unsigned) #define H5F_CRT_FREESPACE_VERS_DEF HDF5_FREESPACE_VERSION /* Definitions for object directory version number */ #define H5F_CRT_OBJ_DIR_VERS_NAME "obj_dir_version" #define H5F_CRT_OBJ_DIR_VERS_SIZE sizeof(unsigned) #define H5F_CRT_OBJ_DIR_VERS_DEF HDF5_OBJECTDIR_VERSION /* Definitions for shared-header format version */ #define H5F_CRT_SHARE_HEAD_VERS_NAME "share_head_version" #define H5F_CRT_SHARE_HEAD_VERS_SIZE sizeof(unsigned) #define H5F_CRT_SHARE_HEAD_VERS_DEF HDF5_SHAREDHEADER_VERSION /* ========= File Access properties ============ */ /* Definitions for size of meta data cache(elements) */ #define H5F_ACS_META_CACHE_SIZE_NAME "mdc_nelmts" #define H5F_ACS_META_CACHE_SIZE_SIZE sizeof(int) #define H5F_ACS_META_CACHE_SIZE_DEF H5AC_NSLOTS /* Definitions for size of raw data chunk cache(elements) */ #define H5F_ACS_DATA_CACHE_ELMT_SIZE_NAME "rdcc_nelmts" #define H5F_ACS_DATA_CACHE_ELMT_SIZE_SIZE sizeof(size_t) #define H5F_ACS_DATA_CACHE_ELMT_SIZE_DEF 521 /* Definition for size of raw data chunk cache(bytes) */ #define H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME "rdcc_nbytes" #define H5F_ACS_DATA_CACHE_BYTE_SIZE_SIZE sizeof(size_t) #define H5F_ACS_DATA_CACHE_BYTE_SIZE_DEF (1024*1024) /* Definition for preemption read chunks first */ #define H5F_ACS_PREEMPT_READ_CHUNKS_NAME "rdcc_w0" #define H5F_ACS_PREEMPT_READ_CHUNKS_SIZE sizeof(double) #define H5F_ACS_PREEMPT_READ_CHUNKS_DEF 0.75 /* Definition for threshold for alignment */ #define H5F_ACS_ALIGN_THRHD_NAME "threshold" #define H5F_ACS_ALIGN_THRHD_SIZE sizeof(hsize_t) #define H5F_ACS_ALIGN_THRHD_DEF 1 /* Definition for alignment */ #define H5F_ACS_ALIGN_NAME "align" #define H5F_ACS_ALIGN_SIZE sizeof(hsize_t) #define H5F_ACS_ALIGN_DEF 1 /* Definition for minimum metadata allocation block size (when aggregating metadata allocations. */ #define H5F_ACS_META_BLOCK_SIZE_NAME "meta_block_size" #define H5F_ACS_META_BLOCK_SIZE_SIZE sizeof(hsize_t) #define H5F_ACS_META_BLOCK_SIZE_DEF 2048 /* Definition for maximum sieve buffer size (when data sieving is allowed by file driver */ #define H5F_ACS_SIEVE_BUF_SIZE_NAME "sieve_buf_size" #define H5F_ACS_SIEVE_BUF_SIZE_SIZE sizeof(size_t) #define H5F_ACS_SIEVE_BUF_SIZE_DEF (64*1024) /* Definition for minimum "small data" allocation block size (when aggregating "small" raw data allocations. */ #define H5F_ACS_SDATA_BLOCK_SIZE_NAME "sdata_block_size" #define H5F_ACS_SDATA_BLOCK_SIZE_SIZE sizeof(hsize_t) #define H5F_ACS_SDATA_BLOCK_SIZE_DEF 2048 /* Definition for garbage-collect references */ #define H5F_ACS_GARBG_COLCT_REF_NAME "gc_ref" #define H5F_ACS_GARBG_COLCT_REF_SIZE sizeof(unsigned) #define H5F_ACS_GARBG_COLCT_REF_DEF 0 /* Definition for file driver ID */ #define H5F_ACS_FILE_DRV_ID_NAME "driver_id" #define H5F_ACS_FILE_DRV_ID_SIZE sizeof(hid_t) #define H5F_ACS_FILE_DRV_ID_DEF H5FD_SEC2 /* Definition for file driver info */ #define H5F_ACS_FILE_DRV_INFO_NAME "driver_info" #define H5F_ACS_FILE_DRV_INFO_SIZE sizeof(void*) #define H5F_ACS_FILE_DRV_INFO_DEF NULL /* Definition for file close degree */ #define H5F_CLOSE_DEGREE_NAME "close_degree" #define H5F_CLOSE_DEGREE_SIZE sizeof(H5F_close_degree_t) #define H5F_CLOSE_DEGREE_DEF H5F_CLOSE_DEFAULT /* Definition for offset position in file for family file driver */ #define H5F_ACS_FAMILY_OFFSET_NAME "family_offset" #define H5F_ACS_FAMILY_OFFSET_SIZE sizeof(hsize_t) #define H5F_ACS_FAMILY_OFFSET_DEF 0 /* Definition for data type in multi file driver */ #define H5F_ACS_MULTI_TYPE_NAME "multi_type" #define H5F_ACS_MULTI_TYPE_SIZE sizeof(H5FD_mem_t) #define H5F_ACS_MULTI_TYPE_DEF H5FD_MEM_DEFAULT /* ======================== File Mount properties ====================*/ /* Definition for whether absolute symlinks local to file. */ #define H5F_MNT_SYM_LOCAL_NAME "local" #define H5F_MNT_SYM_LOCAL_SIZE sizeof(hbool_t) #define H5F_MNT_SYM_LOCAL_DEF FALSE #ifdef H5_HAVE_PARALLEL /* Which process writes metadata */ #define H5_PAR_META_WRITE 0 #endif /* H5_HAVE_PARALLEL */ /* Forward declarations for prototype arguments */ struct H5B_class_t; struct H5RC_t; /* Private functions, not part of the publicly documented API */ H5_DLL herr_t H5F_init(void); #ifdef NOT_YET H5_DLL herr_t H5F_flush_all(hbool_t invalidate); #endif /* NOT_YET */ /* Functions than retrieve values from the file struct */ H5_DLL hid_t H5F_get_driver_id(const H5F_t *f); H5_DLL unsigned H5F_get_intent(const H5F_t *f); H5_DLL herr_t H5F_get_fileno(const H5F_t *f, unsigned long *filenum); H5_DLL hid_t H5F_get_id(H5F_t *file); H5_DLL unsigned H5F_get_obj_count(const H5F_t *f, unsigned types); H5_DLL unsigned H5F_get_obj_ids(const H5F_t *f, unsigned types, int max_objs, hid_t *obj_id_list); H5_DLL haddr_t H5F_get_base_addr(const H5F_t *f); H5_DLL haddr_t H5F_get_eoa(const H5F_t *f); #ifdef H5_HAVE_PARALLEL H5_DLL int H5F_mpi_get_rank(const H5F_t *f); H5_DLL MPI_Comm H5F_mpi_get_comm(const H5F_t *f); #endif /* H5_HAVE_PARALLEL */ /* Functions than check file mounting information */ H5_DLL htri_t H5F_is_mount(const H5F_t *file); H5_DLL htri_t H5F_has_mount(const H5F_t *file); /* Functions than retrieve values set from the FCPL */ H5_DLL size_t H5F_sizeof_addr(const H5F_t *f); H5_DLL size_t H5F_sizeof_size(const H5F_t *f); H5_DLL unsigned H5F_sym_leaf_k(const H5F_t *f); H5_DLL unsigned H5F_Kvalue(const H5F_t *f, const struct H5B_class_t *type); H5_DLL hbool_t H5F_has_feature(const H5F_t *f, unsigned feature); H5_DLL size_t H5F_rdcc_nbytes(const H5F_t *f); H5_DLL size_t H5F_rdcc_nelmts(const H5F_t *f); H5_DLL double H5F_rdcc_w0(const H5F_t *f); H5_DLL struct H5RC_t *H5F_grp_btree_shared(const H5F_t *f); H5_DLL size_t H5F_sieve_buf_size(const H5F_t *f); /* Functions that operate on blocks of bytes wrt super block */ H5_DLL herr_t H5F_block_read(const H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, hid_t dxpl_id, void *buf/*out*/); H5_DLL herr_t H5F_block_write(const H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, hid_t dxpl_id, const void *buf); /* Address-related functions */ H5_DLL void H5F_addr_encode(const H5F_t *, uint8_t** /*in,out*/, haddr_t); H5_DLL void H5F_addr_decode(const H5F_t *, const uint8_t** /*in,out*/, haddr_t* /*out*/); H5_DLL herr_t H5F_addr_pack(H5F_t *f, haddr_t *addr_p /*out*/, const unsigned long objno[2]); /* Callback functions for file access class */ H5_DLL herr_t H5F_acs_create(hid_t fapl_id, void *close_data); H5_DLL herr_t H5F_acs_close(hid_t fapl_id, void *close_data); H5_DLL herr_t H5F_acs_copy(hid_t new_fapl_id, hid_t old_fapl_id, void *close_data); /* Shared file list related routines */ H5_DLL herr_t H5F_sfile_assert_num(unsigned n); /* Debugging functions */ H5_DLL herr_t H5F_debug(H5F_t *f, hid_t dxpl_id, FILE * stream, int indent, int fwidth); #endif xdmf-3.0+git20160803/Utilities/hdf5/H5Aprivate.h0000640000175000017500000000267113003006557021022 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * This file contains private information about the H5D module */ #ifndef _H5Aprivate_H #define _H5Aprivate_H /* Include package's public header */ #include "H5Apublic.h" /* Private headers needed by this file */ #include "H5Gprivate.h" /* Groups */ /* Forward references of package typedefs */ typedef struct H5A_t H5A_t; /* Library private functions in package */ H5_DLL H5G_entry_t *H5A_entof(H5A_t *attr); #endif xdmf-3.0+git20160803/Utilities/hdf5/H5Tprecis.c0000640000175000017500000002264613003006557020657 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Module Info: This module contains the functionality for setting & querying * the datatype precision for the H5T interface. */ #define H5T_PACKAGE /*suppress error about including H5Tpkg */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5T_init_precis_interface #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Iprivate.h" /* IDs */ #include "H5Tpkg.h" /* Datatypes */ /* Static local functions */ static herr_t H5T_set_precision(const H5T_t *dt, size_t prec); /*-------------------------------------------------------------------------- NAME H5T_init_precis_interface -- Initialize interface-specific information USAGE herr_t H5T_init_precis_interface() RETURNS Non-negative on success/Negative on failure DESCRIPTION Initializes any interface-specific data or routines. (Just calls H5T_init_iterface currently). --------------------------------------------------------------------------*/ static herr_t H5T_init_precis_interface(void) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_init_precis_interface) FUNC_LEAVE_NOAPI(H5T_init()) } /* H5T_init_precis_interface() */ /*------------------------------------------------------------------------- * Function: H5Tget_precision * * Purpose: Gets the precision of a datatype. The precision is * the number of significant bits which, unless padding is * present, is 8 times larger than the value returned by * H5Tget_size(). * * Return: Success: Number of significant bits * * Failure: 0 (all atomic types have at least one * significant bit) * * Programmer: Robb Matzke * Wednesday, January 7, 1998 * * Modifications: * Robb Matzke, 22 Dec 1998 * Also works for derived datatypes. * *------------------------------------------------------------------------- */ size_t H5Tget_precision(hid_t type_id) { H5T_t *dt = NULL; size_t ret_value; FUNC_ENTER_API(H5Tget_precision, 0) H5TRACE1("z","i",type_id); /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a datatype") while (dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ if (!H5T_IS_ATOMIC(dt->shared)) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, 0, "operation not defined for specified datatype") /* Precision */ ret_value = dt->shared->u.atomic.prec; done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5Tset_precision * * Purpose: Sets the precision of a datatype. The precision is * the number of significant bits which, unless padding is * present, is 8 times larger than the value returned by * H5Tget_size(). * * If the precision is increased then the offset is decreased * and then the size is increased to insure that significant * bits do not "hang over" the edge of the datatype. * * The precision property of strings is read-only. * * When decreasing the precision of a floating point type, set * the locations and sizes of the sign, mantissa, and exponent * fields first. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Wednesday, January 7, 1998 * * Modifications: * Robb Matzke, 22 Dec 1998 * Moved real work to a private function. * *------------------------------------------------------------------------- */ herr_t H5Tset_precision(hid_t type_id, size_t prec) { H5T_t *dt = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Tset_precision, FAIL) H5TRACE2("e","iz",type_id,prec); /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") if (H5T_STATE_TRANSIENT!=dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is read-only") if (prec == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "precision must be positive") if (H5T_ENUM==dt->shared->type && dt->shared->u.enumer.nmembs>0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "operation not allowed after members are defined") if (H5T_STRING==dt->shared->type) HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "precision for this type is read-only") if (H5T_COMPOUND==dt->shared->type || H5T_OPAQUE==dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "operation not defined for specified datatype") /* Do the work */ if (H5T_set_precision(dt, prec)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "unable to set precision") done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5T_set_precision * * Purpose: Sets the precision of a datatype. The precision is * the number of significant bits which, unless padding is * present, is 8 times larger than the value returned by * H5Tget_size(). * * If the precision is increased then the offset is decreased * and then the size is increased to insure that significant * bits do not "hang over" the edge of the datatype. * * The precision property of strings is read-only. * * When decreasing the precision of a floating point type, set * the locations and sizes of the sign, mantissa, and exponent * fields first. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Wednesday, January 7, 1998 * * Modifications: * Robb Matzke, 22 Dec 1998 * Also works for derived datatypes. * *------------------------------------------------------------------------- */ static herr_t H5T_set_precision(const H5T_t *dt, size_t prec) { size_t offset, size; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_set_precision, FAIL) /* Check args */ assert(dt); assert(prec>0); assert(H5T_OPAQUE!=dt->shared->type); assert(H5T_COMPOUND!=dt->shared->type); assert(H5T_STRING!=dt->shared->type); assert(!(H5T_ENUM==dt->shared->type && 0==dt->shared->u.enumer.nmembs)); if (dt->shared->parent) { if (H5T_set_precision(dt->shared->parent, prec)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "unable to set precision for base type") /* Adjust size of datatype appropriately */ if(dt->shared->type==H5T_ARRAY) dt->shared->size = dt->shared->parent->shared->size * dt->shared->u.array.nelem; else if(dt->shared->type!=H5T_VLEN) dt->shared->size = dt->shared->parent->shared->size; } else { if (H5T_IS_ATOMIC(dt->shared)) { /* Adjust the offset and size */ offset = dt->shared->u.atomic.offset; size = dt->shared->size; if (prec > 8*size) offset = 0; else if (offset+prec > 8 * size) offset = 8 * size - prec; if (prec > 8*size) size = (prec+7) / 8; /* Check that things are still kosher */ switch (dt->shared->type) { case H5T_INTEGER: case H5T_TIME: case H5T_BITFIELD: /* nothing to check */ break; case H5T_FLOAT: /* * The sign, mantissa, and exponent fields should be adjusted * first when decreasing the precision of a floating point * type. */ if (dt->shared->u.atomic.u.f.sign >= prec+offset || dt->shared->u.atomic.u.f.epos + dt->shared->u.atomic.u.f.esize > prec+offset || dt->shared->u.atomic.u.f.mpos + dt->shared->u.atomic.u.f.msize > prec+offset) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "adjust sign, mantissa, and exponent fields first") break; default: HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "operation not defined for datatype class") } /* end switch */ /*lint !e788 All appropriate cases are covered */ /* Commit */ dt->shared->size = size; dt->shared->u.atomic.offset = offset; dt->shared->u.atomic.prec = prec; } /* end if */ else HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for specified datatype") } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } xdmf-3.0+git20160803/Utilities/hdf5/H5FL.c0000640000175000017500000016764613003006557017561 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Quincey Koziol * Thursday, March 23, 2000 * * Purpose: Manage priority queues of free-lists (of blocks of bytes). * These are used in various places in the library which allocate and * free differently blocks of bytes repeatedly. Usually the same size * of block is allocated and freed repeatly in a loop, while writing out * chunked data for example, but the blocks may also be of different sizes * from different datasets and an attempt is made to optimize access to * the proper free list of blocks by using these priority queues to * move frequently accessed free lists to the head of the queue. */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5FL_init_interface /* #define H5FL_DEBUG */ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free Lists */ #include "H5MMprivate.h" /* Memory management */ /* * Private type definitions */ /* Default limits on how much memory can accumulate on each free list before it is garbage collected. */ static size_t H5FL_reg_glb_mem_lim=1*1024*1024; /* Default to 1MB limit on all regular free lists */ static size_t H5FL_reg_lst_mem_lim=1*65536; /* Default to 64KB limit on each regular free list */ static size_t H5FL_arr_glb_mem_lim=4*1024*1024; /* Default to 4MB limit on all array free lists */ static size_t H5FL_arr_lst_mem_lim=4*65536; /* Default to 256KB limit on each array free list */ static size_t H5FL_blk_glb_mem_lim=16*1024*1024; /* Default to 16MB limit on all block free lists */ static size_t H5FL_blk_lst_mem_lim=1024*1024; /* Default to 1024KB (1MB) limit on each block free list */ /* A garbage collection node for regular free lists */ typedef struct H5FL_reg_gc_node_t { H5FL_reg_head_t *list; /* Pointer to the head of the list to garbage collect */ struct H5FL_reg_gc_node_t *next; /* Pointer to the next node in the list of things to garbage collect */ } H5FL_reg_gc_node_t; /* The garbage collection head for regular free lists */ typedef struct H5FL_reg_gc_list_t { size_t mem_freed; /* Amount of free memory on list */ struct H5FL_reg_gc_node_t *first; /* Pointer to the first node in the list of things to garbage collect */ } H5FL_reg_gc_list_t; /* The head of the list of things to garbage collect */ static H5FL_reg_gc_list_t H5FL_reg_gc_head={0,NULL}; /* A garbage collection node for array free lists */ typedef struct H5FL_gc_arr_node_t { H5FL_arr_head_t *list; /* Pointer to the head of the list to garbage collect */ struct H5FL_gc_arr_node_t *next; /* Pointer to the next node in the list of things to garbage collect */ } H5FL_gc_arr_node_t; /* The garbage collection head for array free lists */ typedef struct H5FL_gc_arr_list_t { size_t mem_freed; /* Amount of free memory on list */ struct H5FL_gc_arr_node_t *first; /* Pointer to the first node in the list of things to garbage collect */ } H5FL_gc_arr_list_t; /* The head of the list of array things to garbage collect */ static H5FL_gc_arr_list_t H5FL_arr_gc_head={0,NULL}; /* A garbage collection node for blocks */ typedef struct H5FL_blk_gc_node_t { H5FL_blk_head_t *pq; /* Pointer to the head of the PQ to garbage collect */ struct H5FL_blk_gc_node_t *next; /* Pointer to the next node in the list of things to garbage collect */ } H5FL_blk_gc_node_t; /* The garbage collection head for blocks */ typedef struct H5FL_blk_gc_list_t { size_t mem_freed; /* Amount of free memory on list */ struct H5FL_blk_gc_node_t *first; /* Pointer to the first node in the list of things to garbage collect */ } H5FL_blk_gc_list_t; /* The head of the list of PQs to garbage collect */ static H5FL_blk_gc_list_t H5FL_blk_gc_head={0,NULL}; /* Forward declarations of local static functions */ static herr_t H5FL_reg_gc(void); static herr_t H5FL_reg_gc_list(H5FL_reg_head_t *head); static herr_t H5FL_arr_gc(void); static herr_t H5FL_arr_gc_list(H5FL_arr_head_t *head); static herr_t H5FL_blk_gc(void); static herr_t H5FL_blk_gc_list(H5FL_blk_head_t *head); /* Declare a free list to manage the H5FL_blk_node_t struct */ H5FL_DEFINE(H5FL_blk_node_t); /*-------------------------------------------------------------------------- NAME H5FL_init_interface -- Initialize interface-specific information USAGE herr_t H5FL_init_interface() RETURNS Non-negative on success/Negative on failure DESCRIPTION Initializes any interface-specific data or routines. --------------------------------------------------------------------------*/ static herr_t H5FL_init_interface(void) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FL_init_interface) /* Nothing currently... */ FUNC_LEAVE_NOAPI(ret_value) } /* H5FL_init_interface() */ /*------------------------------------------------------------------------- * Function: H5FL_malloc * * Purpose: Attempt to allocate space using malloc. If malloc fails, garbage * collect and try again. If malloc fails again, then return NULL. * * Return: Success: non-NULL * Failure: NULL * * Programmer: Quincey Koziol * Tuesday, August 1, 2000 * * Modifications: * *------------------------------------------------------------------------- */ static void * H5FL_malloc(size_t mem_size) { void *ret_value=NULL; /* return value*/ FUNC_ENTER_NOAPI(H5FL_malloc, NULL) /* Attempt to allocate the memory requested */ if(NULL==(ret_value=H5MM_malloc(mem_size))) { /* If we can't allocate the memory now, try garbage collecting first */ if(H5FL_garbage_coll()<0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, NULL, "garbage collection failed during allocation") /* Now try allocating the memory again */ if(NULL==(ret_value=H5MM_malloc(mem_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for chunk") } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_malloc() */ /*------------------------------------------------------------------------- * Function: H5FL_reg_init * * Purpose: Initialize a free list for a certain type. Right now, this just * adds the free list to the list of things to garbage collect. * * Return: Success: Non-negative * Failure: Negative * * Programmer: Quincey Koziol * Friday, March 24, 2000 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FL_reg_init(H5FL_reg_head_t *head) { H5FL_reg_gc_node_t *new_node; /* Pointer to the node for the new list to garbage collect */ herr_t ret_value=SUCCEED; /* return value*/ FUNC_ENTER_NOAPI_NOINIT(H5FL_reg_init) /* Allocate a new garbage collection node */ if (NULL==(new_node = H5MM_malloc(sizeof(H5FL_reg_gc_node_t)))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Initialize the new garbage collection node */ new_node->list=head; /* Link in to the garbage collection list */ new_node->next=H5FL_reg_gc_head.first; H5FL_reg_gc_head.first=new_node; /* Indicate that the free list is initialized */ head->init=1; /* Make certain that the space allocated is large enough to store a free list pointer (eventually) */ if(head->sizesize=sizeof(void *); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_reg_init() */ /*------------------------------------------------------------------------- * Function: H5FL_reg_free * * Purpose: Release an object & put on free list * * Return: Success: Non-negative * Failure: Negative * * Programmer: Quincey Koziol * Friday, March 24, 2000 * * Modifications: * *------------------------------------------------------------------------- */ void * H5FL_reg_free(H5FL_reg_head_t *head, void *obj) { H5FL_reg_node_t *temp; /* Temp. ptr to the new free list node allocated */ void *ret_value=NULL; /* Return value */ FUNC_ENTER_NOAPI(H5FL_reg_free, NULL) /* Double check parameters */ assert(head); assert(obj); #ifdef H5FL_DEBUG HDmemset(obj,255,head->size); #endif /* H5FL_DEBUG */ /* Make certain that the free list is initialized */ assert(head->init); /* Alias the pointer to the block to free into a H5FL_reg_node_t node */ temp=(H5FL_reg_node_t *)obj; /* Link into the free list */ temp->next=head->list; /* Point free list at the node freed */ head->list=temp; /* Increment the number of blocks & memory on free list */ head->onlist++; head->list_mem+=head->size; /* Increment the amount of "regular" freed memory globally */ H5FL_reg_gc_head.mem_freed+=head->size; /* Check for exceeding free list memory use limits */ /* First check this particular list */ if(head->list_mem>H5FL_reg_lst_mem_lim) if(H5FL_reg_gc_list(head)<0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, NULL, "garbage collection failed during free") /* Then check the global amount memory on regular free lists */ if(H5FL_reg_gc_head.mem_freed>H5FL_reg_glb_mem_lim) if(H5FL_reg_gc()<0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, NULL, "garbage collection failed during free") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_reg_free() */ /*------------------------------------------------------------------------- * Function: H5FL_reg_malloc * * Purpose: Allocate a block on a free list * * Return: Success: Pointer to a valid object * Failure: NULL * * Programmer: Quincey Koziol * Friday, March 24, 2000 * * Modifications: * *------------------------------------------------------------------------- */ void * H5FL_reg_malloc(H5FL_reg_head_t *head) { void *ret_value; /* Pointer to object to return */ FUNC_ENTER_NOAPI(H5FL_reg_malloc, NULL) /* Double check parameters */ assert(head); /* Make certain the list is initialized first */ if(!head->init) if(H5FL_reg_init(head)<0) HGOTO_ERROR (H5E_RESOURCE, H5E_CANTINIT, NULL, "can't initialize 'regular' blocks") /* Check for nodes available on the free list first */ if(head->list!=NULL) { /* Get a pointer to the block on the free list */ ret_value=(void *)(head->list); /* Remove node from free list */ head->list=head->list->next; /* Decrement the number of blocks & memory on free list */ head->onlist--; head->list_mem-=head->size; /* Decrement the amount of global "regular" free list memory in use */ H5FL_reg_gc_head.mem_freed-=(head->size); } /* end if */ /* Otherwise allocate a node */ else { if (NULL==(ret_value = H5FL_malloc(head->size))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Increment the number of blocks allocated in list */ head->allocated++; } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_reg_malloc() */ /*------------------------------------------------------------------------- * Function: H5FL_reg_calloc * * Purpose: Allocate a block on a free list and clear it to zeros * * Return: Success: Pointer to a valid object * Failure: NULL * * Programmer: Quincey Koziol * Monday, December 23, 2002 * * Modifications: * *------------------------------------------------------------------------- */ void * H5FL_reg_calloc(H5FL_reg_head_t *head) { void *ret_value; /* Pointer to object to return */ FUNC_ENTER_NOAPI(H5FL_reg_calloc, NULL) /* Double check parameters */ assert(head); /* Allocate the block */ if (NULL==(ret_value = H5FL_reg_malloc(head))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Clear to zeros */ HDmemset(ret_value,0,head->size); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_reg_calloc() */ /*------------------------------------------------------------------------- * Function: H5FL_reg_gc_list * * Purpose: Garbage collect on a particular object free list * * Return: Success: Non-negative * Failure: Negative * * Programmer: Quincey Koziol * Tuesday, July 25, 2000 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FL_reg_gc_list(H5FL_reg_head_t *head) { H5FL_reg_node_t *free_list; /* Pointer to nodes in free list being garbage collected */ void *tmp; /* Temporary node pointer */ size_t total_mem; /* Total memory used on list */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FL_reg_gc_list) /* Calculate the total memory used on this list */ total_mem=head->onlist*head->size; /* For each free list being garbage collected, walk through the nodes and free them */ free_list=head->list; while(free_list!=NULL) { tmp=free_list->next; /* Decrement the count of nodes allocated and free the node */ head->allocated--; /* Decrement count of free memory on this list */ head->list_mem-=head->size; H5MM_xfree(free_list); free_list=tmp; } /* end while */ /* Double check that all the memory on this list is recycled */ assert(head->list_mem==0); /* Indicate no free nodes on the free list */ head->list=NULL; head->onlist=0; /* Decrement global count of free memory on "regular" lists */ H5FL_reg_gc_head.mem_freed-=total_mem; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FL_reg_gc_list() */ /*------------------------------------------------------------------------- * Function: H5FL_reg_gc * * Purpose: Garbage collect on all the object free lists * * Return: Success: Non-negative * Failure: Negative * * Programmer: Quincey Koziol * Friday, March 24, 2000 * * Modifications: * Broke into two parts, one for looping over all the free lists and * another for freeing each list - QAK 7/25/00 * *------------------------------------------------------------------------- */ static herr_t H5FL_reg_gc(void) { H5FL_reg_gc_node_t *gc_node; /* Pointer into the list of things to garbage collect */ herr_t ret_value=SUCCEED; /* return value*/ FUNC_ENTER_NOAPI_NOINIT(H5FL_reg_gc) /* Walk through all the free lists, free()'ing the nodes */ gc_node=H5FL_reg_gc_head.first; while(gc_node!=NULL) { /* Release the free nodes on the list */ if(H5FL_reg_gc_list(gc_node->list)<0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "garbage collection of list failed") /* Go on to the next free list to garbage collect */ gc_node=gc_node->next; } /* end while */ /* Double check that all the memory on the free lists is recycled */ assert(H5FL_reg_gc_head.mem_freed==0); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_reg_gc() */ /*-------------------------------------------------------------------------- NAME H5FL_reg_term PURPOSE Terminate various H5FL object free lists USAGE int H5FL_term() RETURNS Success: Positive if any action might have caused a change in some other interface; zero otherwise. Failure: Negative DESCRIPTION Release any resources allocated. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS Can't report errors... EXAMPLES REVISION LOG Robb Matzke, 2000-04-25 If a list cannot be freed because something is using it then return zero (failure to free a list doesn't affect any other part of the library). If some other layer frees something during its termination it will return non-zero, which will cause this function to get called again to reclaim this layer's memory. --------------------------------------------------------------------------*/ static int H5FL_reg_term(void) { H5FL_reg_gc_node_t *left; /* pointer to garbage collection lists with work left */ H5FL_reg_gc_node_t *tmp; /* Temporary pointer to a garbage collection node */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FL_reg_term) if (H5_interface_initialize_g) { /* Free the nodes on the garbage collection list, keeping nodes with allocations outstanding */ left=NULL; while(H5FL_reg_gc_head.first!=NULL) { tmp=H5FL_reg_gc_head.first->next; #ifdef H5FL_DEBUG printf("H5FL_reg_term: head->name=%s, head->allocated=%d\n", H5FL_reg_gc_head.first->list->name,(int)H5FL_reg_gc_head.first->list->allocated); #endif /* H5FL_DEBUG */ /* Check if the list has allocations outstanding */ if(H5FL_reg_gc_head.first->list->allocated>0) { /* Add free list to the list of nodes with allocations open still */ H5FL_reg_gc_head.first->next=left; left=H5FL_reg_gc_head.first; } /* end if */ /* No allocations left open for list, get rid of it */ else { /* Reset the "initialized" flag, in case we restart this list somehow (I don't know how..) */ H5FL_reg_gc_head.first->list->init=0; /* Free the node from the garbage collection list */ H5MM_xfree(H5FL_reg_gc_head.first); } /* end else */ H5FL_reg_gc_head.first=tmp; } /* end while */ /* Point to the list of nodes left with allocations open, if any */ H5FL_reg_gc_head.first=left; if (!left) H5_interface_initialize_g = 0; /*this layer has reached its initial state*/ } /* Terminating this layer never affects other layers; rather, other layers affect * the termination of this layer. */ FUNC_LEAVE_NOAPI(0) } /* end H5FL_reg_term() */ /*------------------------------------------------------------------------- * Function: H5FL_blk_find_list * * Purpose: Finds the free list for blocks of a given size. Also moves that * free list node to the head of the priority queue (if it isn't there * already). This routine does not manage the actual free list, it just * works with the priority queue. * * Return: Success: valid pointer to the free list node * * Failure: NULL * * Programmer: Quincey Koziol * Thursday, March 23, 2000 * * Modifications: * *------------------------------------------------------------------------- */ static H5FL_blk_node_t * H5FL_blk_find_list(H5FL_blk_node_t **head, size_t size) { H5FL_blk_node_t *temp; /* Temp. pointer to node in the native list */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FL_blk_find_list) /* Find the correct free list */ temp=*head; /* Check if the node is at the head of the list */ if(temp && temp->size!=size) { temp=temp->next; while(temp!=NULL) { /* Check if we found the correct node */ if(temp->size==size) { /* Take the node found out of it's current position */ if(temp->next==NULL) { temp->prev->next=NULL; } /* end if */ else { temp->prev->next=temp->next; temp->next->prev=temp->prev; } /* end else */ /* Move the found node to the head of the list */ temp->prev=NULL; temp->next=*head; (*head)->prev=temp; *head=temp; /* Get out */ break; } /* end if */ temp=temp->next; } /* end while */ } /* end if */ FUNC_LEAVE_NOAPI(temp) } /* end H5FL_blk_find_list() */ /*------------------------------------------------------------------------- * Function: H5FL_blk_create_list * * Purpose: Creates a new free list for blocks of the given size at the * head of the priority queue. * * Return: Success: valid pointer to the free list node * * Failure: NULL * * Programmer: Quincey Koziol * Thursday, March 23, 2000 * * Modifications: * *------------------------------------------------------------------------- */ static H5FL_blk_node_t * H5FL_blk_create_list(H5FL_blk_node_t **head, size_t size) { H5FL_blk_node_t *temp; /* Temp. pointer to node in the list */ H5FL_blk_node_t *ret_value; FUNC_ENTER_NOAPI_NOINIT(H5FL_blk_create_list) /* Allocate room for the new free list node */ if(NULL==(temp=H5FL_MALLOC(H5FL_blk_node_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for chunk info") /* Set the correct values for the new free list */ temp->size=size; temp->list=NULL; /* Attach to head of priority queue */ if(*head==NULL) { *head=temp; temp->next=temp->prev=NULL; } /* end if */ else { temp->next=*head; (*head)->prev=temp; temp->prev=NULL; *head=temp; } /* end else */ ret_value=temp; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_blk_create_list() */ /*------------------------------------------------------------------------- * Function: H5FL_blk_init * * Purpose: Initialize a priority queue of a certain type. Right now, this just * adds the PQ to the list of things to garbage collect. * * Return: Success: Non-negative * Failure: Negative * * Programmer: Quincey Koziol * Saturday, March 25, 2000 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FL_blk_init(H5FL_blk_head_t *head) { H5FL_blk_gc_node_t *new_node; /* Pointer to the node for the new list to garbage collect */ herr_t ret_value=SUCCEED; /* return value*/ FUNC_ENTER_NOAPI_NOINIT(H5FL_blk_init) /* Allocate a new garbage collection node */ if (NULL==(new_node = H5MM_malloc(sizeof(H5FL_blk_gc_node_t)))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Initialize the new garbage collection node */ new_node->pq=head; /* Link in to the garbage collection list */ new_node->next=H5FL_blk_gc_head.first; H5FL_blk_gc_head.first=new_node; /* Indicate that the PQ is initialized */ head->init=1; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_blk_init() */ /*------------------------------------------------------------------------- * Function: H5FL_blk_free_block_avail * * Purpose: Checks if a free block of the appropriate size is available * for a given list. * * Return: Success: non-negative * Failure: negative * * Programmer: Quincey Koziol * Monday, December 16, 2002 * * Modifications: * *------------------------------------------------------------------------- */ htri_t H5FL_blk_free_block_avail(H5FL_blk_head_t *head, size_t size) { H5FL_blk_node_t *free_list; /* The free list of nodes of correct size */ htri_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FL_blk_free_block_avail, FAIL) /* Double check parameters */ assert(head); /* check if there is a free list for blocks of this size */ /* and if there are any blocks available on the list */ if((free_list=H5FL_blk_find_list(&(head->head),size))!=NULL && free_list->list!=NULL) ret_value=TRUE; else ret_value=FALSE; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_blk_free_block_avail() */ /*------------------------------------------------------------------------- * Function: H5FL_blk_malloc * * Purpose: Allocates memory for a block. This routine is used * instead of malloc because the block can be kept on a free list so * they don't thrash malloc/free as much. * * Return: Success: valid pointer to the block * * Failure: NULL * * Programmer: Quincey Koziol * Thursday, March 23, 2000 * * Modifications: * *------------------------------------------------------------------------- */ void * H5FL_blk_malloc(H5FL_blk_head_t *head, size_t size) { H5FL_blk_node_t *free_list; /* The free list of nodes of correct size */ H5FL_blk_list_t *temp; /* Temp. ptr to the new native list allocated */ void *ret_value; /* Pointer to the block to return to the user */ FUNC_ENTER_NOAPI(H5FL_blk_malloc, NULL) /* Double check parameters */ assert(head); assert(size); /* Make certain the list is initialized first */ if(!head->init) if(H5FL_blk_init(head)<0) HGOTO_ERROR (H5E_RESOURCE, H5E_CANTINIT, NULL, "can't initialize 'block' list") /* check if there is a free list for blocks of this size */ /* and if there are any blocks available on the list */ if((free_list=H5FL_blk_find_list(&(head->head),size))!=NULL && free_list->list!=NULL) { /* Remove the first node from the free list */ temp=free_list->list; free_list->list=free_list->list->next; /* Restore the size of the block */ temp->size=size; /* Overwrites the 'next' field */ /* Return the pointer to the data portion */ ret_value=((char *)temp)+sizeof(H5FL_blk_list_t); /* Decrement the number of blocks & memory used on free list */ head->onlist--; head->list_mem-=size; /* Decrement the amount of global "block" free list memory in use */ H5FL_blk_gc_head.mem_freed-=size; } /* end if */ /* No free list available, or there are no nodes on the list, allocate a new node to give to the user */ else { /* Allocate new node, with room for the page info header and the actual page data */ if(NULL==(temp=H5FL_malloc(sizeof(H5FL_blk_list_t)+size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for chunk") /* Increment the number of blocks allocated */ head->allocated++; /* Initialize the block allocated */ temp->size=size; /* Set the return value to the block itself */ ret_value=((char *)temp)+sizeof(H5FL_blk_list_t); } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_blk_malloc() */ /*------------------------------------------------------------------------- * Function: H5FL_blk_calloc * * Purpose: Allocates memory for a block and clear it to zeros. * This routine is used * instead of malloc because the block can be kept on a free list so * they don't thrash malloc/free as much. * * Return: Success: valid pointer to the block * * Failure: NULL * * Programmer: Quincey Koziol * Monday, December 23, 2002 * * Modifications: * *------------------------------------------------------------------------- */ void * H5FL_blk_calloc(H5FL_blk_head_t *head, size_t size) { void *ret_value; /* Pointer to the block to return to the user */ FUNC_ENTER_NOAPI(H5FL_blk_calloc, NULL) /* Double check parameters */ assert(head); assert(size); /* Allocate the block */ if (NULL==(ret_value = H5FL_blk_malloc(head,size))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Clear the block to zeros */ HDmemset(ret_value,0,size); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_blk_calloc() */ /*------------------------------------------------------------------------- * Function: H5FL_blk_free * * Purpose: Releases memory for a block. This routine is used * instead of free because the blocks can be kept on a free list so * they don't thrash malloc/free as much. * * Return: Success: NULL * * Failure: never fails * * Programmer: Quincey Koziol * Thursday, March 23, 2000 * * Modifications: * *------------------------------------------------------------------------- */ void * H5FL_blk_free(H5FL_blk_head_t *head, void *block) { H5FL_blk_node_t *free_list; /* The free list of nodes of correct size */ H5FL_blk_list_t *temp; /* Temp. ptr to the new free list node allocated */ size_t free_size; /* Size of the block freed */ void *ret_value=NULL; /* Return value */ FUNC_ENTER_NOAPI(H5FL_blk_free, NULL) /* Double check parameters */ assert(head); assert(block); /* Get the pointer to the native block info header in front of the native block to free */ temp=(H5FL_blk_list_t *)((unsigned char *)block-sizeof(H5FL_blk_list_t)); /*lint !e826 Pointer-to-pointer cast is appropriate here */ /* Save the block's size for later */ free_size=temp->size; /* check if there is a free list for native blocks of this size */ if((free_list=H5FL_blk_find_list(&(head->head),temp->size))==NULL) { /* No free list available, create a new list node and insert it to the queue */ free_list=H5FL_blk_create_list(&(head->head),temp->size); } /* end if */ /* Prepend the free'd native block to the front of the free list */ if(free_list!=NULL) { temp->next=free_list->list; /* Overwrites the size field in union */ free_list->list=temp; } /* end if */ /* Increment the number of blocks on free list */ head->onlist++; head->list_mem+=free_size; /* Increment the amount of "block" freed memory globally */ H5FL_blk_gc_head.mem_freed+=free_size; /* Check for exceeding free list memory use limits */ /* First check this particular list */ if(head->list_mem>H5FL_blk_lst_mem_lim) if(H5FL_blk_gc_list(head)<0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, NULL, "garbage collection failed during free") /* Then check the global amount memory on block free lists */ if(H5FL_blk_gc_head.mem_freed>H5FL_blk_glb_mem_lim) if(H5FL_blk_gc()<0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, NULL, "garbage collection failed during free") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_blk_free() */ /*------------------------------------------------------------------------- * Function: H5FL_blk_realloc * * Purpose: Resizes a block. This does things the straightforward, simple way, * not actually using realloc. * * Return: Success: NULL * * Failure: never fails * * Programmer: Quincey Koziol * Thursday, March 23, 2000 * * Modifications: * *------------------------------------------------------------------------- */ void * H5FL_blk_realloc(H5FL_blk_head_t *head, void *block, size_t new_size) { void *ret_value=NULL; /* Return value */ FUNC_ENTER_NOAPI(H5FL_blk_realloc, NULL) /* Double check parameters */ assert(head); assert(new_size); /* Check if we are actually re-allocating a block */ if(block!=NULL) { H5FL_blk_list_t *temp; /* Temp. ptr to the new block node allocated */ /* Get the pointer to the chunk info header in front of the chunk to free */ temp=(H5FL_blk_list_t *)((unsigned char *)block-sizeof(H5FL_blk_list_t)); /*lint !e826 Pointer-to-pointer cast is appropriate here */ /* check if we are actually changing the size of the buffer */ if(new_size!=temp->size) { size_t blk_size; /* Temporary block size */ if((ret_value=H5FL_blk_malloc(head,new_size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for block") blk_size=MIN(new_size,temp->size); HDmemcpy(ret_value,block,blk_size); H5FL_blk_free(head,block); } /* end if */ else ret_value=block; } /* end if */ /* Not re-allocating, just allocate a fresh block */ else ret_value=H5FL_blk_malloc(head,new_size); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_blk_realloc() */ /*------------------------------------------------------------------------- * Function: H5FL_blk_gc_list * * Purpose: Garbage collect a priority queue * * Return: Success: Non-negative * Failure: Negative * * Programmer: Quincey Koziol * Thursday, March 23, 2000 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FL_blk_gc_list(H5FL_blk_head_t *head) { H5FL_blk_list_t *list; /* The free list of native nodes of a particular size */ void *next; /* Temp. ptr to the free list list node */ void *temp; /* Temp. ptr to the free list page node */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FL_blk_gc_list) /* Loop through all the nodes in the block free list queue */ while(head->head!=NULL) { temp=head->head->next; /* Loop through all the blocks in the free list, freeing them */ list=head->head->list; while(list!=NULL) { next=list->next; /* Decrement the number of blocks & memory allocated from this PQ */ head->allocated--; head->list_mem-=head->head->size; /* Decrement global count of free memory on "block" lists */ H5FL_blk_gc_head.mem_freed-=head->head->size; /* Free the block */ H5MM_xfree(list); list=next; } /* end while */ /* Free the free list node */ H5FL_FREE(H5FL_blk_node_t,head->head); /* Advance to the next free list */ head->head=temp; } /* end while */ /* Indicate no free nodes on the free list */ head->head=NULL; head->onlist=0; /* Double check that all the memory on this list is recycled */ assert(head->list_mem==0); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FL_blk_gc_list() */ /*------------------------------------------------------------------------- * Function: H5FL_blk_gc * * Purpose: Garbage collect on all the priority queues * * Return: Success: Non-negative * Failure: Negative * * Programmer: Quincey Koziol * Saturday, March 25, 2000 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FL_blk_gc(void) { H5FL_blk_gc_node_t *gc_node; /* Pointer into the list of things to garbage collect */ herr_t ret_value=SUCCEED; /* return value*/ FUNC_ENTER_NOAPI_NOINIT(H5FL_blk_gc) /* Walk through all the free lists, free()'ing the nodes */ gc_node=H5FL_blk_gc_head.first; while(gc_node!=NULL) { /* For each free list being garbage collected, walk through the nodes and free them */ if(H5FL_blk_gc_list(gc_node->pq)<0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "garbage collection of list failed") /* Go on to the next free list to garbage collect */ gc_node=gc_node->next; } /* end while */ /* Double check that all the memory on the free lists are recycled */ assert(H5FL_blk_gc_head.mem_freed==0); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_blk_gc() */ /*-------------------------------------------------------------------------- NAME H5FL_blk_term PURPOSE Terminate various H5FL_blk objects USAGE void H5FL_blk_term() RETURNS Success: Positive if any action might have caused a change in some other interface; zero otherwise. Failure: Negative DESCRIPTION Release any resources allocated. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS Can't report errors... EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static int H5FL_blk_term(void) { H5FL_blk_gc_node_t *left; /* pointer to garbage collection lists with work left */ H5FL_blk_gc_node_t *tmp; /* Temporary pointer to a garbage collection node */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FL_blk_term) /* Free the nodes on the garbage collection list, keeping nodes with allocations outstanding */ left=NULL; while(H5FL_blk_gc_head.first!=NULL) { tmp=H5FL_blk_gc_head.first->next; #ifdef H5FL_DEBUG printf("H5FL_blk_term: head->name=%s, head->allocated=%d\n", H5FL_blk_gc_head.first->pq->name,(int)H5FL_blk_gc_head.first->pq->allocated); #endif /* H5FL_DEBUG */ /* Check if the list has allocations outstanding */ if(H5FL_blk_gc_head.first->pq->allocated>0) { /* Add free list to the list of nodes with allocations open still */ H5FL_blk_gc_head.first->next=left; left=H5FL_blk_gc_head.first; } /* end if */ /* No allocations left open for list, get rid of it */ else { /* Reset the "initialized" flag, in case we restart this list somehow (I don't know how..) */ H5FL_blk_gc_head.first->pq->init=0; /* Free the node from the garbage collection list */ H5MM_xfree(H5FL_blk_gc_head.first); } /* end else */ H5FL_blk_gc_head.first=tmp; } /* end while */ /* Point to the list of nodes left with allocations open, if any */ H5FL_blk_gc_head.first=left; FUNC_LEAVE_NOAPI(H5FL_blk_gc_head.first!=NULL ? 1 : 0) } /* end H5FL_blk_term() */ /*------------------------------------------------------------------------- * Function: H5FL_arr_init * * Purpose: Initialize a free list for a arrays of certain type. Right now, * this just adds the free list to the list of things to garbage collect. * * Return: Success: Non-negative * Failure: Negative * * Programmer: Quincey Koziol * Saturday, March 25, 2000 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FL_arr_init(H5FL_arr_head_t *head) { H5FL_gc_arr_node_t *new_node; /* Pointer to the node for the new list to garbage collect */ size_t u; /* Local index variable */ herr_t ret_value=SUCCEED; /* return value*/ FUNC_ENTER_NOAPI_NOINIT(H5FL_arr_init) /* Allocate a new garbage collection node */ if (NULL==(new_node = H5MM_malloc(sizeof(H5FL_gc_arr_node_t)))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Initialize the new garbage collection node */ new_node->list=head; /* Link in to the garbage collection list */ new_node->next=H5FL_arr_gc_head.first; H5FL_arr_gc_head.first=new_node; /* Allocate room for the free lists */ if (NULL==(head->list_arr = H5MM_calloc((size_t)head->maxelem*sizeof(H5FL_arr_node_t)))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Initialize the size of each array */ for(u = 0; u<(size_t)head->maxelem; u++) head->list_arr[u].size = head->base_size + (head->elem_size * u); /* Indicate that the free list is initialized */ head->init=1; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_arr_init() */ /*------------------------------------------------------------------------- * Function: H5FL_arr_free * * Purpose: Release an array of objects & put on free list * * Return: Success: Non-negative * Failure: Negative * * Programmer: Quincey Koziol * Friday, March 24, 2000 * * Modifications: * *------------------------------------------------------------------------- */ void * H5FL_arr_free(H5FL_arr_head_t *head, void *obj) { H5FL_arr_list_t *temp; /* Temp. ptr to the new free list node allocated */ size_t mem_size; /* Size of memory being freed */ size_t free_nelem; /* Number of elements in node being free'd */ void *ret_value=NULL; /* Return value */ FUNC_ENTER_NOAPI(H5FL_arr_free, NULL) /* The H5MM_xfree code allows obj to null */ if (!obj) HGOTO_DONE (NULL) /* Double check parameters */ assert(head); /* Make certain that the free list is initialized */ assert(head->init); /* Get the pointer to the info header in front of the block to free */ temp=(H5FL_arr_list_t *)((unsigned char *)obj-sizeof(H5FL_arr_list_t)); /*lint !e826 Pointer-to-pointer cast is appropriate here */ /* Get the number of elements */ free_nelem=temp->nelem; /* Double-check that there is enough room for arrays of this size */ assert((int)free_nelem<=head->maxelem); /* Link into the free list */ temp->next=head->list_arr[free_nelem].list; /* Point free list at the node freed */ head->list_arr[free_nelem].list=temp; /* Get the size of arrays with this many elements */ mem_size=head->list_arr[free_nelem].size; /* Increment the number of blocks & memory used on free list */ head->list_arr[free_nelem].onlist++; head->list_mem+=mem_size; /* Increment the amount of "array" freed memory globally */ H5FL_arr_gc_head.mem_freed+=mem_size; /* Check for exceeding free list memory use limits */ /* First check this particular list */ if(head->list_mem>H5FL_arr_lst_mem_lim) if(H5FL_arr_gc_list(head)<0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, NULL, "garbage collection failed during free") /* Then check the global amount memory on array free lists */ if(H5FL_arr_gc_head.mem_freed>H5FL_arr_glb_mem_lim) if(H5FL_arr_gc()<0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, NULL, "garbage collection failed during free") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_arr_free() */ /*------------------------------------------------------------------------- * Function: H5FL_arr_malloc * * Purpose: Allocate an array of objects * * Return: Success: Pointer to a valid array object * Failure: NULL * * Programmer: Quincey Koziol * Saturday, March 25, 2000 * * Modifications: * *------------------------------------------------------------------------- */ void * H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem) { H5FL_arr_list_t *new_obj; /* Pointer to the new free list node allocated */ void *ret_value; /* Pointer to object to return */ size_t mem_size; /* Size of memory block being recycled */ FUNC_ENTER_NOAPI(H5FL_arr_malloc, NULL) /* Double check parameters */ assert(head); assert(elem); /* Make certain the list is initialized first */ if(!head->init) if(H5FL_arr_init(head)<0) HGOTO_ERROR (H5E_RESOURCE, H5E_CANTINIT, NULL, "can't initialize 'array' blocks") /* Get the set of the memory block */ mem_size=head->list_arr[elem].size; /* Sanity check that the number of elements is supported */ assert((int)elem<=head->maxelem); /* Check for nodes available on the free list first */ if(head->list_arr[elem].list!=NULL) { /* Get a pointer to the block on the free list */ new_obj=head->list_arr[elem].list; /* Remove node from free list */ head->list_arr[elem].list=head->list_arr[elem].list->next; /* Decrement the number of blocks & memory used on free list */ head->list_arr[elem].onlist--; head->list_mem-=mem_size; /* Decrement the amount of global "array" free list memory in use */ H5FL_arr_gc_head.mem_freed-=mem_size; } /* end if */ /* Otherwise allocate a node */ else { if (NULL==(new_obj = H5FL_malloc(sizeof(H5FL_arr_list_t)+mem_size))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Increment the number of blocks allocated in list */ head->allocated++; } /* end else */ /* Initialize the new object */ new_obj->nelem=elem; /* Get a pointer to the new block */ ret_value=((char *)new_obj)+sizeof(H5FL_arr_list_t); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_arr_malloc() */ /*------------------------------------------------------------------------- * Function: H5FL_arr_calloc * * Purpose: Allocate an array of objects and clear it to zeros * * Return: Success: Pointer to a valid array object * Failure: NULL * * Programmer: Quincey Koziol * Monday, December 23, 2002 * * Modifications: * *------------------------------------------------------------------------- */ void * H5FL_arr_calloc(H5FL_arr_head_t *head, size_t elem) { void *ret_value; /* Pointer to object to return */ FUNC_ENTER_NOAPI(H5FL_arr_calloc, NULL) /* Double check parameters */ assert(head); assert(elem); /* Allocate the array */ if (NULL==(ret_value = H5FL_arr_malloc(head,elem))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Clear to zeros */ HDmemset(ret_value,0,head->list_arr[elem].size); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_arr_calloc() */ /*------------------------------------------------------------------------- * Function: H5FL_arr_realloc * * Purpose: Reallocate an array of objects * * Return: Success: Pointer to a valid array object * Failure: NULL * * Programmer: Quincey Koziol * Saturday, March 25, 2000 * * Modifications: * *------------------------------------------------------------------------- */ void * H5FL_arr_realloc(H5FL_arr_head_t *head, void * obj, size_t new_elem) { void *ret_value; /* Pointer to object to return */ FUNC_ENTER_NOAPI(H5FL_arr_realloc, NULL) /* Double check parameters */ assert(head); assert(new_elem); /* Check if we are really allocating the object */ if(obj==NULL) ret_value=H5FL_arr_malloc(head,new_elem); else { H5FL_arr_list_t *temp; /* Temp. ptr to the new free list node allocated */ /* Sanity check that the number of elements is supported */ assert((int)new_elem<=head->maxelem); /* Get the pointer to the info header in front of the block to free */ temp=(H5FL_arr_list_t *)((unsigned char *)obj-sizeof(H5FL_arr_list_t)); /*lint !e826 Pointer-to-pointer cast is appropriate here */ /* Check if the size is really changing */ if(temp->nelem!=new_elem) { size_t blk_size; /* Size of block */ /* Get the new array of objects */ ret_value=H5FL_arr_malloc(head,new_elem); /* Copy the appropriate amount of elements */ blk_size = head->list_arr[ MIN(temp->nelem, new_elem) ].size; HDmemcpy(ret_value,obj,blk_size); /* Free the old block */ H5FL_arr_free(head,obj); } /* end if */ else ret_value=obj; } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_arr_realloc() */ /*------------------------------------------------------------------------- * Function: H5FL_arr_gc_list * * Purpose: Garbage collect on an array object free list * * Return: Success: Non-negative * Failure: Negative * * Programmer: Quincey Koziol * Tuesday, July 25, 2000 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FL_arr_gc_list(H5FL_arr_head_t *head) { H5FL_arr_list_t *arr_free_list; /* Pointer to nodes in free list being garbage collected */ void *tmp; /* Temporary node pointer */ unsigned u; /* Counter for array of free lists */ size_t total_mem; /* Total memory used on list */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FL_arr_gc_list) /* Walk through the array of free lists */ for(u=0; u<(unsigned)head->maxelem; u++) { if(head->list_arr[u].onlist>0) { /* Calculate the total memory used on this list */ total_mem=head->list_arr[u].onlist*head->list_arr[u].size; /* For each free list being garbage collected, walk through the nodes and free them */ arr_free_list=head->list_arr[u].list; while(arr_free_list!=NULL) { tmp=arr_free_list->next; /* Decrement the count of nodes allocated and free the node */ head->allocated--; H5MM_xfree(arr_free_list); arr_free_list=tmp; } /* end while */ /* Indicate no free nodes on the free list */ head->list_arr[u].list=NULL; head->list_arr[u].onlist=0; /* Decrement count of free memory on this "array" list */ head->list_mem-=total_mem; /* Decrement global count of free memory on "array" lists */ H5FL_arr_gc_head.mem_freed-=total_mem; } /* end if */ } /* end for */ /* Double check that all the memory on this list is recycled */ assert(head->list_mem==0); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FL_arr_gc_list() */ /*------------------------------------------------------------------------- * Function: H5FL_arr_gc * * Purpose: Garbage collect on all the array object free lists * * Return: Success: Non-negative * Failure: Negative * * Programmer: Quincey Koziol * Saturday, March 25, 2000 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FL_arr_gc(void) { H5FL_gc_arr_node_t *gc_arr_node; /* Pointer into the list of things to garbage collect */ herr_t ret_value=SUCCEED; /* return value*/ FUNC_ENTER_NOAPI_NOINIT(H5FL_arr_gc) /* Walk through all the free lists, free()'ing the nodes */ gc_arr_node=H5FL_arr_gc_head.first; while(gc_arr_node!=NULL) { /* Release the free nodes on the list */ if(H5FL_arr_gc_list(gc_arr_node->list)<0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "garbage collection of list failed") /* Go on to the next free list to garbage collect */ gc_arr_node=gc_arr_node->next; } /* end while */ /* Double check that all the memory on the free lists are recycled */ assert(H5FL_arr_gc_head.mem_freed==0); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_arr_gc() */ /*-------------------------------------------------------------------------- NAME H5FL_arr_term PURPOSE Terminate various H5FL array object free lists USAGE int H5FL_arr_term() RETURNS Success: Positive if any action might have caused a change in some other interface; zero otherwise. Failure: Negative DESCRIPTION Release any resources allocated. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS Can't report errors... EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static int H5FL_arr_term(void) { H5FL_gc_arr_node_t *left; /* pointer to garbage collection lists with work left */ H5FL_gc_arr_node_t *tmp; /* Temporary pointer to a garbage collection node */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FL_arr_term) /* Free the nodes on the garbage collection list, keeping nodes with allocations outstanding */ left=NULL; while(H5FL_arr_gc_head.first!=NULL) { tmp=H5FL_arr_gc_head.first->next; /* Check if the list has allocations outstanding */ #ifdef H5FL_DEBUG printf("H5FL_arr_term: head->name=%s, head->allocated=%d\n", H5FL_arr_gc_head.first->list->name,(int)H5FL_arr_gc_head.first->list->allocated); #endif /* H5FL_DEBUG */ if(H5FL_arr_gc_head.first->list->allocated>0) { /* Add free list to the list of nodes with allocations open still */ H5FL_arr_gc_head.first->next=left; left=H5FL_arr_gc_head.first; } /* end if */ /* No allocations left open for list, get rid of it */ else { /* Free the array of free lists */ H5MM_xfree(H5FL_arr_gc_head.first->list->list_arr); /* Reset the "initialized" flag, in case we restart this list somehow (I don't know how..) */ H5FL_arr_gc_head.first->list->init=0; /* Free the node from the garbage collection list */ H5MM_xfree(H5FL_arr_gc_head.first); } /* end else */ H5FL_arr_gc_head.first=tmp; } /* end while */ /* Point to the list of nodes left with allocations open, if any */ H5FL_arr_gc_head.first=left; FUNC_LEAVE_NOAPI(H5FL_arr_gc_head.first!=NULL ? 1 : 0) } /* end H5FL_arr_term() */ /*------------------------------------------------------------------------- * Function: H5FL_seq_free * * Purpose: Release a sequence of objects & put on free list * * Return: Success: Non-negative * Failure: Negative * * Programmer: Quincey Koziol * Saturday, April 3, 2004 * * Modifications: * *------------------------------------------------------------------------- */ void * H5FL_seq_free(H5FL_seq_head_t *head, void *obj) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FL_seq_free) /* Double check parameters */ assert(head); assert(obj); /* Make certain that the free list is initialized */ assert(head->queue.init); /* Use block routine */ H5FL_blk_free(&(head->queue),obj); FUNC_LEAVE_NOAPI(NULL) } /* end H5FL_seq_free() */ /*------------------------------------------------------------------------- * Function: H5FL_seq_malloc * * Purpose: Allocate a sequence of objects * * Return: Success: Pointer to a valid sequence object * Failure: NULL * * Programmer: Quincey Koziol * Saturday, April 3, 2004 * * Modifications: * *------------------------------------------------------------------------- */ void * H5FL_seq_malloc(H5FL_seq_head_t *head, size_t elem) { void *ret_value; /* Pointer to object to return */ FUNC_ENTER_NOAPI(H5FL_seq_malloc, NULL) /* Double check parameters */ assert(head); assert(elem); /* Use block routine */ ret_value=H5FL_blk_malloc(&(head->queue),head->size*elem); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_seq_malloc() */ /*------------------------------------------------------------------------- * Function: H5FL_seq_calloc * * Purpose: Allocate a sequence of objects and clear it to zeros * * Return: Success: Pointer to a valid array object * Failure: NULL * * Programmer: Quincey Koziol * Saturday, April 3, 2004 * * Modifications: * *------------------------------------------------------------------------- */ void * H5FL_seq_calloc(H5FL_seq_head_t *head, size_t elem) { void *ret_value; /* Pointer to object to return */ FUNC_ENTER_NOAPI(H5FL_seq_calloc, NULL) /* Double check parameters */ assert(head); assert(elem); /* Use block routine */ ret_value=H5FL_blk_calloc(&(head->queue),head->size*elem); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_seq_calloc() */ /*------------------------------------------------------------------------- * Function: H5FL_seq_realloc * * Purpose: Reallocate a sequence of objects * * Return: Success: Pointer to a valid sequence object * Failure: NULL * * Programmer: Quincey Koziol * Saturday, April 3, 2004 * * Modifications: * *------------------------------------------------------------------------- */ void * H5FL_seq_realloc(H5FL_seq_head_t *head, void * obj, size_t new_elem) { void *ret_value; /* Pointer to object to return */ FUNC_ENTER_NOAPI(H5FL_seq_realloc, NULL) /* Double check parameters */ assert(head); assert(new_elem); /* Use block routine */ ret_value=H5FL_blk_realloc(&(head->queue),obj,head->size*new_elem); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_seq_realloc() */ /*------------------------------------------------------------------------- * Function: H5FL_garbage_coll * * Purpose: Garbage collect on all the free lists * * Return: Success: Non-negative * Failure: Negative * * Programmer: Quincey Koziol * Friday, March 24, 2000 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5FL_garbage_coll(void) { herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT(H5FL_garbage_coll) /* Garbage collect the free lists for array objects */ if(H5FL_arr_gc()<0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "can't garbage collect array objects") /* Garbage collect free lists for blocks */ if(H5FL_blk_gc()<0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "can't garbage collect block objects") /* Garbage collect the free lists for regular objects */ if(H5FL_reg_gc()<0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "can't garbage collect regular objects") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_garbage_coll() */ /*------------------------------------------------------------------------- * Function: H5FL_set_free_list_limits * * Purpose: Sets limits on the different kinds of free lists. Setting a value * of -1 for a limit means no limit of that type. These limits are global * for the entire library. Each "global" limit only applies to free lists * of that type, so if an application sets a limit of 1 MB on each of the * global lists, up to 3 MB of total storage might be allocated (1MB on * each of regular, array and block type lists). * * Parameters: * int reg_global_lim; IN: The limit on all "regular" free list memory used * int reg_list_lim; IN: The limit on memory used in each "regular" free list * int arr_global_lim; IN: The limit on all "array" free list memory used * int arr_list_lim; IN: The limit on memory used in each "array" free list * int blk_global_lim; IN: The limit on all "block" free list memory used * int blk_list_lim; IN: The limit on memory used in each "block" free list * * Return: Success: non-negative * * Failure: negative * * Programmer: Quincey Koziol * Wednesday, August 2, 2000 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5FL_set_free_list_limits(int reg_global_lim, int reg_list_lim, int arr_global_lim, int arr_list_lim, int blk_global_lim, int blk_list_lim) { herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5FL_set_free_list_limits, FAIL) /* Set the limit variables */ /* limit on all regular free lists */ H5FL_reg_glb_mem_lim=(reg_global_lim==-1 ? UINT_MAX : (size_t)reg_global_lim); /* limit on each regular free list */ H5FL_reg_lst_mem_lim=(reg_list_lim==-1 ? UINT_MAX : (size_t)reg_list_lim); /* limit on all array free lists */ H5FL_arr_glb_mem_lim=(arr_global_lim==-1 ? UINT_MAX : (size_t)arr_global_lim); /* limit on each array free list */ H5FL_arr_lst_mem_lim=(arr_list_lim==-1 ? UINT_MAX : (size_t)arr_list_lim); /* limit on all block free lists */ H5FL_blk_glb_mem_lim=(blk_global_lim==-1 ? UINT_MAX : (size_t)blk_global_lim); /* limit on each block free list */ H5FL_blk_lst_mem_lim=(blk_list_lim==-1 ? UINT_MAX : (size_t)blk_list_lim); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_set_free_list_limits() */ /*-------------------------------------------------------------------------- NAME H5FL_term_interface PURPOSE Terminate various H5FL objects USAGE void H5FL_term_interface() RETURNS Success: Positive if any action might have caused a change in some other interface; zero otherwise. Failure: Negative DESCRIPTION Release any resources allocated. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS Can't report errors... EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ int H5FL_term_interface(void) { int ret_value=0; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FL_term_interface) /* Garbage collect any nodes on the free lists */ (void)H5FL_garbage_coll(); ret_value=H5FL_reg_term()+H5FL_arr_term()+H5FL_blk_term(); FUNC_LEAVE_NOAPI(ret_value) } xdmf-3.0+git20160803/Utilities/hdf5/H5Fpublic.h0000640000175000017500000001271213003006557020630 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * This file contains public declarations for the H5F module. */ #ifndef _H5Fpublic_H #define _H5Fpublic_H /* Public header files needed by this file */ #include "H5public.h" #include "H5Ipublic.h" /* * These are the bits that can be passed to the `flags' argument of * H5Fcreate() and H5Fopen(). Use the bit-wise OR operator (|) to combine * them as needed. As a side effect, they call H5check_version() to make sure * that the application is compiled with a version of the hdf5 header files * which are compatible with the library to which the application is linked. * We're assuming that these constants are used rather early in the hdf5 * session. * * NOTE: When adding H5F_ACC_* macros, remember to redefine them in H5Fprivate.h * */ /* When this header is included from a private header, don't make calls to H5check() */ #undef H5CHECK #ifndef _H5private_H #define H5CHECK H5check(), #else /* _H5private_H */ #define H5CHECK #endif /* _H5private_H */ #define H5F_ACC_RDONLY (H5CHECK 0x0000u) /*absence of rdwr => rd-only */ #define H5F_ACC_RDWR (H5CHECK 0x0001u) /*open for read and write */ #define H5F_ACC_TRUNC (H5CHECK 0x0002u) /*overwrite existing files */ #define H5F_ACC_EXCL (H5CHECK 0x0004u) /*fail if file already exists*/ #define H5F_ACC_DEBUG (H5CHECK 0x0008u) /*print debug info */ #define H5F_ACC_CREAT (H5CHECK 0x0010u) /*create non-existing files */ /* Flags for H5Fget_obj_count() & H5Fget_obj_ids() calls */ #define H5F_OBJ_FILE (0x0001u) /* File objects */ #define H5F_OBJ_DATASET (0x0002u) /* Dataset objects */ #define H5F_OBJ_GROUP (0x0004u) /* Group objects */ #define H5F_OBJ_DATATYPE (0x0008u) /* Named datatype objects */ #define H5F_OBJ_ATTR (0x0010u) /* Attribute objects */ #define H5F_OBJ_ALL (H5F_OBJ_FILE|H5F_OBJ_DATASET|H5F_OBJ_GROUP|H5F_OBJ_DATATYPE|H5F_OBJ_ATTR) #define H5F_OBJ_LOCAL (0x0020u) /* Restrict search to objects opened through current file ID */ /* (as opposed to objects opened through any file ID accessing this file) */ #ifdef H5_HAVE_PARALLEL /* * Use this constant string as the MPI_Info key to set H5Fmpio debug flags. * To turn on H5Fmpio debug flags, set the MPI_Info value with this key to * have the value of a string consisting of the characters that turn on the * desired flags. */ #define H5F_MPIO_DEBUG_KEY "H5F_mpio_debug_key" #endif /* H5_HAVE_PARALLEL */ /* The difference between a single file and a set of mounted files */ typedef enum H5F_scope_t { H5F_SCOPE_LOCAL = 0, /*specified file handle only */ H5F_SCOPE_GLOBAL = 1, /*entire virtual file */ H5F_SCOPE_DOWN = 2 /*for internal use only */ } H5F_scope_t; /* Unlimited file size for H5Pset_external() */ #define H5F_UNLIMITED ((hsize_t)(-1L)) /* How does file close behave? * H5F_CLOSE_DEFAULT - Use the degree pre-defined by underlining VFL * H5F_CLOSE_WEAK - file closes only after all opened objects are closed * H5F_CLOSE_SEMI - if no opened objects, file is close; otherwise, file close fails * H5F_CLOSE_STRONG - if there are opened objects, close them first, then close file */ typedef enum H5F_close_degree_t { H5F_CLOSE_DEFAULT = 0, H5F_CLOSE_WEAK = 1, H5F_CLOSE_SEMI = 2, H5F_CLOSE_STRONG = 3 } H5F_close_degree_t; #ifdef __cplusplus extern "C" { #endif /* Functions in H5F.c */ H5_DLL htri_t H5Fis_hdf5 (const char *filename); H5_DLL hid_t H5Fcreate (const char *filename, unsigned flags, hid_t create_plist, hid_t access_plist); H5_DLL hid_t H5Fopen (const char *filename, unsigned flags, hid_t access_plist); H5_DLL hid_t H5Freopen(hid_t file_id); H5_DLL herr_t H5Fflush(hid_t object_id, H5F_scope_t scope); H5_DLL herr_t H5Fclose (hid_t file_id); H5_DLL hid_t H5Fget_create_plist (hid_t file_id); H5_DLL hid_t H5Fget_access_plist (hid_t file_id); H5_DLL int H5Fget_obj_count(hid_t file_id, unsigned types); H5_DLL int H5Fget_obj_ids(hid_t file_id, unsigned types, int max_objs, hid_t *obj_id_list); H5_DLL herr_t H5Fget_vfd_handle(hid_t file_id, hid_t fapl, void** file_handle); H5_DLL herr_t H5Fmount(hid_t loc, const char *name, hid_t child, hid_t plist); H5_DLL herr_t H5Funmount(hid_t loc, const char *name); H5_DLL hssize_t H5Fget_freespace(hid_t file_id); H5_DLL herr_t H5Fget_filesize(hid_t file_id, hsize_t *size); H5_DLL ssize_t H5Fget_name(hid_t obj_id, char *name, size_t size); #ifdef __cplusplus } #endif #endif xdmf-3.0+git20160803/Utilities/hdf5/H5Tpkg.h0000640000175000017500000013004713003006557020153 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Robb Matzke * Monday, December 8, 1997 * * Purpose: This file contains declarations which are visible only within * the H5T package. Source files outside the H5T package should * include H5Tprivate.h instead. */ #ifndef H5T_PACKAGE #error "Do not include this file outside the H5T package!" #endif #ifndef _H5Tpkg_H #define _H5Tpkg_H /* * Define this to enable debugging. */ #ifdef NDEBUG # undef H5T_DEBUG #endif /* Get package's private header */ #include "H5Tprivate.h" /* Other private headers needed by this file */ #include "H5Fprivate.h" /* Files */ /* Other public headers needed by this file */ #include "H5Spublic.h" /* Dataspace functions */ /* Number of reserved IDs in ID group */ #define H5T_RESERVED_ATOMS 8 /* Length of debugging name buffer */ #define H5T_NAMELEN 32 /* Macro to ease detecting "complex" datatypes (i.e. those with base types or fields) */ #define H5T_IS_COMPLEX(t) ((t)==H5T_COMPOUND || (t)==H5T_ENUM || (t)==H5T_VLEN || (t)==H5T_ARRAY) /* Macro to ease detecting fixed "string" datatypes */ #define H5T_IS_FIXED_STRING(dt) (H5T_STRING == (dt)->type) /* Macro to ease detecting variable-length "string" datatypes */ #define H5T_IS_VL_STRING(dt) (H5T_VLEN == (dt)->type && H5T_VLEN_STRING == (dt)->u.vlen.type) /* Macro to ease detecting fixed or variable-length "string" datatypes */ #define H5T_IS_STRING(dt) (H5T_IS_FIXED_STRING(dt) || H5T_IS_VL_STRING(dt)) /* Macro to ease detecting atomic datatypes */ #define H5T_IS_ATOMIC(dt) (!(H5T_IS_COMPLEX((dt)->type) || (dt)->type==H5T_OPAQUE)) /* Statistics about a conversion function */ struct H5T_stats_t { unsigned ncalls; /*num calls to conversion function */ hsize_t nelmts; /*total data points converted */ H5_timer_t timer; /*total time for conversion */ }; /* The datatype conversion database */ struct H5T_path_t { char name[H5T_NAMELEN]; /*name for debugging only */ H5T_t *src; /*source datatype ID */ H5T_t *dst; /*destination datatype ID */ H5T_conv_t func; /*data conversion function */ hbool_t is_hard; /*is it a hard function? */ hbool_t is_noop; /*is it the noop conversion? */ H5T_stats_t stats; /*statistics for the conversion */ H5T_cdata_t cdata; /*data for this function */ }; typedef struct H5T_atomic_t { H5T_order_t order; /*byte order */ size_t prec; /*precision in bits */ size_t offset; /*bit position of lsb of value */ H5T_pad_t lsb_pad;/*type of lsb padding */ H5T_pad_t msb_pad;/*type of msb padding */ union { struct { H5T_sign_t sign; /*type of integer sign */ } i; /*integer; integer types */ struct { size_t sign; /*bit position of sign bit */ size_t epos; /*position of lsb of exponent */ size_t esize; /*size of exponent in bits */ uint64_t ebias; /*exponent bias */ size_t mpos; /*position of lsb of mantissa */ size_t msize; /*size of mantissa */ H5T_norm_t norm; /*normalization */ H5T_pad_t pad; /*type of padding for internal bits */ } f; /*floating-point types */ struct { H5T_cset_t cset; /*character set */ H5T_str_t pad; /*space or null padding of extra bytes */ } s; /*string types */ struct { H5R_type_t rtype; /*type of reference stored */ } r; /*reference types */ } u; } H5T_atomic_t; /* How members are sorted for compound or enum datatypes */ typedef enum H5T_sort_t { H5T_SORT_NONE = 0, /*not sorted */ H5T_SORT_NAME = 1, /*sorted by member name */ H5T_SORT_VALUE = 2 /*sorted by memb offset or enum value*/ } H5T_sort_t; /* A compound datatype */ typedef struct H5T_compnd_t { unsigned nalloc; /*num entries allocated in MEMB array*/ unsigned nmembs; /*number of members defined in struct*/ H5T_sort_t sorted; /*how are members sorted? */ hbool_t packed; /*are members packed together? */ struct H5T_cmemb_t *memb; /*array of struct members */ } H5T_compnd_t; /* An enumeration datatype */ typedef struct H5T_enum_t { unsigned nalloc; /*num entries allocated */ unsigned nmembs; /*number of members defined in enum */ H5T_sort_t sorted; /*how are members sorted? */ uint8_t *value; /*array of values */ char **name; /*array of symbol names */ } H5T_enum_t; /* VL function pointers */ typedef ssize_t (*H5T_vlen_getlenfunc_t)(const void *vl_addr); typedef void * (*H5T_vlen_getptrfunc_t)(void *vl_addr); typedef htri_t (*H5T_vlen_isnullfunc_t)(const H5F_t *f, void *vl_addr); typedef herr_t (*H5T_vlen_readfunc_t)(H5F_t *f, hid_t dxpl_id, void *_vl, void *buf, size_t len); typedef herr_t (*H5T_vlen_writefunc_t)(H5F_t *f, hid_t dxpl_id, const H5T_vlen_alloc_info_t *vl_alloc_info, void *_vl, void *buf, void *_bg, size_t seq_len, size_t base_size); typedef herr_t (*H5T_vlen_setnullfunc_t)(H5F_t *f, hid_t dxpl_id, void *_vl, void *_bg); /* VL types */ typedef enum { H5T_VLEN_BADTYPE = -1, /* invalid VL Type */ H5T_VLEN_SEQUENCE=0, /* VL sequence */ H5T_VLEN_STRING, /* VL string */ H5T_VLEN_MAXTYPE /* highest type (Invalid as true type) */ } H5T_vlen_type_t; /* A VL datatype */ typedef struct H5T_vlen_t { H5T_vlen_type_t type; /* Type of VL data in buffer */ H5T_vlen_loc_t loc; /* Location of VL data in buffer */ H5T_cset_t cset; /* For VL string. character set */ H5T_str_t pad; /* For VL string. space or null padding of * extra bytes */ H5F_t *f; /* File ID (if VL data is on disk) */ H5T_vlen_getptrfunc_t getptr; /* Function to get VL sequence pointer */ H5T_vlen_getlenfunc_t getlen; /* Function to get VL sequence size (in element units, not bytes) */ H5T_vlen_isnullfunc_t isnull; /* Function to check if VL value is NIL */ H5T_vlen_readfunc_t read; /* Function to read VL sequence into buffer */ H5T_vlen_writefunc_t write; /* Function to write VL sequence from buffer */ H5T_vlen_setnullfunc_t setnull; /* Function to set a VL value to NIL */ } H5T_vlen_t; /* An opaque datatype */ typedef struct H5T_opaque_t { char *tag; /*short type description string */ } H5T_opaque_t; /* An array datatype */ typedef struct H5T_array_t { size_t nelem; /* total number of elements in array */ int ndims; /* member dimensionality */ size_t dim[H5S_MAX_RANK]; /* size in each dimension */ int perm[H5S_MAX_RANK]; /* index permutation */ } H5T_array_t; typedef enum H5T_state_t { H5T_STATE_TRANSIENT, /*type is a modifiable transient */ H5T_STATE_RDONLY, /*transient, not modifiable, closable*/ H5T_STATE_IMMUTABLE, /*constant, not closable */ H5T_STATE_NAMED, /*named constant, not open */ H5T_STATE_OPEN /*named constant, open object header */ } H5T_state_t; /* This struct is shared between all occurances of an open named type */ typedef struct H5T_shared_t { hsize_t fo_count; /* number of references to this file object */ H5T_state_t state; /*current state of the type */ H5T_class_t type; /*which class of type is this? */ H5F_t *sh_file;/*file pointer if this is a shared type */ size_t size; /*total size of an instance of this type */ hbool_t force_conv;/* Set if this type always needs to be converted and H5T_conv_noop cannot be called */ struct H5T_t *parent;/*parent type for derived datatypes */ union { H5T_atomic_t atomic; /* an atomic datatype */ H5T_compnd_t compnd; /* a compound datatype (struct) */ H5T_enum_t enumer; /* an enumeration type (enum) */ H5T_vlen_t vlen; /* a variable-length datatype */ H5T_opaque_t opaque; /* an opaque datatype */ H5T_array_t array; /* an array datatype */ } u; } H5T_shared_t; struct H5T_t { H5G_entry_t ent; /* entry information if the type is a named type */ H5T_shared_t *shared; /* all other information */ }; /* A compound datatype member */ typedef struct H5T_cmemb_t { char *name; /*name of this member */ size_t offset; /*offset from beginning of struct */ size_t size; /*total size: dims * type_size */ struct H5T_t *type; /*type of this member */ } H5T_cmemb_t; /* The master list of soft conversion functions */ typedef struct H5T_soft_t { char name[H5T_NAMELEN]; /*name for debugging only */ H5T_class_t src; /*source datatype class */ H5T_class_t dst; /*destination datatype class */ H5T_conv_t func; /*the conversion function */ } H5T_soft_t; /* Bit search direction */ typedef enum H5T_sdir_t { H5T_BIT_LSB, /*search lsb toward msb */ H5T_BIT_MSB /*search msb toward lsb */ } H5T_sdir_t; /* The overflow handler */ H5_DLLVAR H5T_overflow_t H5T_overflow_g; /* The native endianess of the platform */ H5_DLLVAR H5T_order_t H5T_native_order_g; /* * Alignment information for native types. A value of N indicates that the * data must be aligned on an address ADDR such that 0 == ADDR mod N. When * N=1 no alignment is required; N=0 implies that alignment constraints were * not calculated. These alignment info is only for H5Tget_native_type. * These values are used for structure alignment. */ H5_DLLVAR size_t H5T_NATIVE_SCHAR_COMP_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_SHORT_COMP_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_INT_COMP_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_LONG_COMP_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_LLONG_COMP_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_FLOAT_COMP_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_DOUBLE_COMP_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_LDOUBLE_COMP_ALIGN_g; H5_DLLVAR size_t H5T_POINTER_COMP_ALIGN_g; H5_DLLVAR size_t H5T_HVL_COMP_ALIGN_g; H5_DLLVAR size_t H5T_HOBJREF_COMP_ALIGN_g; H5_DLLVAR size_t H5T_HDSETREGREF_COMP_ALIGN_g; /* * Alignment information for native types. A value of N indicates that the * data must be aligned on an address ADDR such that 0 == ADDR mod N. When * N=1 no alignment is required; N=0 implies that alignment constraints were * not calculated. */ H5_DLLVAR size_t H5T_NATIVE_SCHAR_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_UCHAR_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_SHORT_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_USHORT_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_INT_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_UINT_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_LONG_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_ULONG_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_LLONG_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_ULLONG_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_FLOAT_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_DOUBLE_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_LDOUBLE_ALIGN_g; /* C9x alignment constraints */ H5_DLLVAR size_t H5T_NATIVE_INT8_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_UINT8_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_INT_LEAST8_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_UINT_LEAST8_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_INT_FAST8_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_UINT_FAST8_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_INT16_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_UINT16_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_INT_LEAST16_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_UINT_LEAST16_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_INT_FAST16_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_UINT_FAST16_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_INT32_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_UINT32_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_INT_LEAST32_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_UINT_LEAST32_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_INT_FAST32_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_UINT_FAST32_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_INT64_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_UINT64_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_INT_LEAST64_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_UINT_LEAST64_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_INT_FAST64_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_UINT_FAST64_ALIGN_g; /* Useful floating-point values for conversion routines */ /* (+/- Inf for all floating-point types) */ H5_DLLVAR float H5T_NATIVE_FLOAT_POS_INF_g; H5_DLLVAR float H5T_NATIVE_FLOAT_NEG_INF_g; H5_DLLVAR double H5T_NATIVE_DOUBLE_POS_INF_g; H5_DLLVAR double H5T_NATIVE_DOUBLE_NEG_INF_g; /* Common functions */ H5_DLL H5T_t *H5T_create(H5T_class_t type, size_t size); H5_DLL H5T_t *H5T_alloc(void); H5_DLL herr_t H5T_free(H5T_t *dt); H5_DLL H5T_sign_t H5T_get_sign(H5T_t const *dt); H5_DLL H5T_t *H5T_get_super(H5T_t *dt); H5_DLL char *H5T_get_member_name(H5T_t const *dt, unsigned membno); H5_DLL herr_t H5T_get_member_value(const H5T_t *dt, unsigned membno, void *value); H5_DLL int H5T_get_nmembers(const H5T_t *dt); H5_DLL herr_t H5T_insert(const H5T_t *parent, const char *name, size_t offset, const H5T_t *member); H5_DLL H5T_t *H5T_enum_create(const H5T_t *parent); H5_DLL herr_t H5T_enum_insert(const H5T_t *dt, const char *name, const void *value); H5_DLL int H5T_get_array_ndims(H5T_t *dt); H5_DLL int H5T_get_array_dims(H5T_t *dt, hsize_t dims[], int perm[]); H5_DLL herr_t H5T_sort_value(const H5T_t *dt, int *map); H5_DLL herr_t H5T_sort_name(const H5T_t *dt, int *map); H5_DLL herr_t H5T_set_size(H5T_t *dt, size_t size); /* Conversion functions */ H5_DLL herr_t H5T_conv_noop(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_order(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *_buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_order_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *_buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *_buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *_buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_i_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *_buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *_buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *_buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_i_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *_buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_s_s(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *_buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *_buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_schar_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_uchar_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_schar_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_schar_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_uchar_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_uchar_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_schar_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_schar_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_uchar_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_uchar_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_schar_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_schar_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_uchar_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_uchar_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_schar_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_schar_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_uchar_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_uchar_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_short_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_short_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_ushort_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_ushort_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_short_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_ushort_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_short_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_short_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_ushort_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_ushort_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_short_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_short_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_ushort_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_ushort_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_short_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_short_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_ushort_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_ushort_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_int_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_int_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_uint_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_uint_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_int_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_int_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_uint_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_uint_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_int_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_uint_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_int_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_int_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_uint_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_uint_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_int_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_int_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_uint_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_uint_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_long_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_long_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_ulong_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_ulong_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_long_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_long_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_ulong_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_ulong_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_long_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_long_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_ulong_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_ulong_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_long_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_ulong_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_long_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_long_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_ulong_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_ulong_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_llong_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_llong_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_ullong_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_ullong_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_llong_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_llong_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_ullong_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_ullong_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_llong_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_llong_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_ullong_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_ullong_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_llong_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_llong_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_ullong_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_ullong_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_llong_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_ullong_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_float_double(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_double_float(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_i32le_f64le(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *_buf, void *bkg, hid_t dset_xfer_plist); /* Bit twiddling functions */ H5_DLL void H5T_bit_copy(uint8_t *dst, size_t dst_offset, const uint8_t *src, size_t src_offset, size_t size); H5_DLL void H5T_bit_set(uint8_t *buf, size_t offset, size_t size, hbool_t value); H5_DLL hsize_t H5T_bit_get_d(uint8_t *buf, size_t offset, size_t size); H5_DLL void H5T_bit_set_d(uint8_t *buf, size_t offset, size_t size, hsize_t val); H5_DLL ssize_t H5T_bit_find(uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction, hbool_t value); H5_DLL htri_t H5T_bit_inc(uint8_t *buf, size_t start, size_t size); /* VL functions */ H5_DLL H5T_t * H5T_vlen_create(const H5T_t *base); /* Array functions */ H5_DLL H5T_t * H5T_array_create(H5T_t *base, int ndims, const hsize_t dim[/* ndims */], const int perm[/* ndims */]); /* Compound functions */ H5_DLL H5T_t *H5T_get_member_type(const H5T_t *dt, unsigned membno); H5_DLL size_t H5T_get_member_offset(const H5T_t *dt, unsigned membno); H5_DLL size_t H5T_get_member_size(const H5T_t *dt, unsigned membno); H5_DLL htri_t H5T_is_packed(const H5T_t *dt); #endif xdmf-3.0+git20160803/Utilities/hdf5/H5Pfcpl.c0000640000175000017500000004763213003006557020314 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #define H5P_PACKAGE /*suppress error about including H5Ppkg */ /* Private header files */ #include "H5private.h" /* Generic Functions */ #include "H5Bprivate.h" /* B-tree subclass names */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fprivate.h" /* Files */ #include "H5Ppkg.h" /* Property lists */ /* Local datatypes */ /* Static function prototypes */ /*------------------------------------------------------------------------- * Function: H5Pget_version * * Purpose: Retrieves version information for various parts of a file. * * SUPER: The file super block. * HEAP: The global heap. * FREELIST: The global free list. * STAB: The root symbol table entry. * SHHDR: Shared object headers. * * Any (or even all) of the output arguments can be null * pointers. * * Return: Success: Non-negative, version information is returned * through the arguments. * * Failure: Negative * * Programmer: Robb Matzke * Wednesday, January 7, 1998 * * Modifications: * * Raymond Lu, Oct 14, 2001 * Change to the new generic property list. * *------------------------------------------------------------------------- */ herr_t H5Pget_version(hid_t plist_id, unsigned *super/*out*/, unsigned *freelist/*out*/, unsigned *stab/*out*/, unsigned *shhdr/*out*/) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Pget_version, FAIL); H5TRACE5("e","ixxxx",plist_id,super,freelist,stab,shhdr); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Get values */ if (super) if(H5P_get(plist, H5F_CRT_SUPER_VERS_NAME, super) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get superblock version"); if (freelist) if(H5P_get(plist, H5F_CRT_FREESPACE_VERS_NAME, freelist) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get free-space version"); if (stab) if(H5P_get(plist, H5F_CRT_OBJ_DIR_VERS_NAME, stab) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object directory version"); if (shhdr) if(H5P_get(plist, H5F_CRT_SHARE_HEAD_VERS_NAME, shhdr) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get shared-header version"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Pset_userblock * * Purpose: Sets the userblock size field of a file creation property * list. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Tuesday, January 6, 1998 * * Modifications: * * Raymond Lu, Oct 14, 2001 * Changed to the new generic property list. * *------------------------------------------------------------------------- */ herr_t H5Pset_userblock(hid_t plist_id, hsize_t size) { unsigned i; H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pset_userblock, FAIL); H5TRACE2("e","ih",plist_id,size); /* Check that the userblock size is a power of two */ for (i=8; i<8*sizeof(hsize_t); i++) { hsize_t p2 = 8==i ? 0 : ((hsize_t)1<=8*sizeof(hsize_t)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "userblock size is not valid"); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Set value */ if(H5P_set(plist, H5F_CRT_USER_BLOCK_NAME, &size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set user block"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Pget_userblock * * Purpose: Queries the size of a user block in a file creation property * list. * * Return: Success: Non-negative, size returned through SIZE argument. * * Failure: Negative * * Programmer: Robb Matzke * Wednesday, January 7, 1998 * * Modifications: * * Raymond Lu, Oct 14, 2001 * Changed to the new generic property list. * *------------------------------------------------------------------------- */ herr_t H5Pget_userblock(hid_t plist_id, hsize_t *size) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pget_userblock, FAIL); H5TRACE2("e","i*h",plist_id,size); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Get value */ if (size) if(H5P_get(plist, H5F_CRT_USER_BLOCK_NAME, size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL,"can't get user block"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Pset_sizes * * Purpose: Sets file size-of addresses and sizes. PLIST_ID should be a * file creation property list. A value of zero causes the * property to not change. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Tuesday, January 6, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Pset_sizes(hid_t plist_id, size_t sizeof_addr, size_t sizeof_size) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pset_sizes, FAIL); H5TRACE3("e","izz",plist_id,sizeof_addr,sizeof_size); /* Check arguments */ if (sizeof_addr) { if (sizeof_addr != 2 && sizeof_addr != 4 && sizeof_addr != 8 && sizeof_addr != 16) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file haddr_t size is not valid"); } if (sizeof_size) { if (sizeof_size != 2 && sizeof_size != 4 && sizeof_size != 8 && sizeof_size != 16) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file size_t size is not valid"); } /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Set value */ if (sizeof_addr) if(H5P_set(plist, H5F_CRT_ADDR_BYTE_NUM_NAME, &sizeof_addr) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set byte number for an address"); if (sizeof_size) if(H5P_set(plist, H5F_CRT_OBJ_BYTE_NUM_NAME, &sizeof_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set byte number for object "); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Pget_sizes * * Purpose: Returns the size of address and size quantities stored in a * file according to a file creation property list. Either (or * even both) SIZEOF_ADDR and SIZEOF_SIZE may be null pointers. * * Return: Success: Non-negative, sizes returned through arguments. * * Failure: Negative * * Programmer: Robb Matzke * Wednesday, January 7, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Pget_sizes(hid_t plist_id, size_t *sizeof_addr /*out */ , size_t *sizeof_size /*out */ ) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pget_sizes, FAIL); H5TRACE3("e","ixx",plist_id,sizeof_addr,sizeof_size); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Get values */ if (sizeof_addr) if(H5P_get(plist, H5F_CRT_ADDR_BYTE_NUM_NAME, sizeof_addr) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get byte number for an address"); if (sizeof_size) if(H5P_get(plist, H5F_CRT_OBJ_BYTE_NUM_NAME, sizeof_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get byte number for object "); done: FUNC_LEAVE_API(ret_value); } #ifdef H5_WANT_H5_V1_4_COMPAT /*------------------------------------------------------------------------- * Function: H5Pset_sym_k * * Purpose: IK is one half the rank of a tree that stores a symbol * table for a group. Internal nodes of the symbol table are on * average 75% full. That is, the average rank of the tree is * 1.5 times the value of IK. * * LK is one half of the number of symbols that can be stored in * a symbol table node. A symbol table node is the leaf of a * symbol table tree which is used to store a group. When * symbols are inserted randomly into a group, the group's * symbol table nodes are 75% full on average. That is, they * contain 1.5 times the number of symbols specified by LK. * * Either (or even both) of IK and LK can be zero in which case * that value is left unchanged. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Tuesday, January 6, 1998 * * Modifications: * * Raymond Lu, Oct 14, 2001 * Changed to the new generic property list. * *------------------------------------------------------------------------- */ herr_t H5Pset_sym_k(hid_t plist_id, int ik, int lk) { int btree_k[H5B_NUM_BTREE_ID]; H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Pset_sym_k, FAIL); H5TRACE3("e","iIsIs",plist_id,ik,lk); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Set values */ if (ik > 0) { if(H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get rank for btree interanl nodes"); btree_k[H5B_SNODE_ID] = ik; if(H5P_set(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set rank for btree nodes"); } if (lk > 0) if(H5P_set(plist, H5F_CRT_SYM_LEAF_NAME, &lk) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set rank for symbol table leaf nodes"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Pget_sym_k * * Purpose: Retrieves the symbol table B-tree 1/2 rank (IK) and the * symbol table leaf node 1/2 size (LK). See H5Pset_sym_k() for * details. Either (or even both) IK and LK may be null * pointers. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Wednesday, January 7, 1998 * * Modifications: * * Raymond Lu * Changed to the new generic property list. * *------------------------------------------------------------------------- */ herr_t H5Pget_sym_k(hid_t plist_id, int *ik /*out */ , int *lk /*out */ ) { int btree_k[H5B_NUM_BTREE_ID]; H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Pget_sym_k, FAIL); H5TRACE3("e","ixx",plist_id,ik,lk); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Get values */ if (ik) { if(H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get rank for btree nodes"); *ik = btree_k[H5B_SNODE_ID]; } if (lk) if(H5P_get(plist, H5F_CRT_SYM_LEAF_NAME, lk) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get rank for symbol table leaf nodes"); done: FUNC_LEAVE_API(ret_value); } #else /* H5_WANT_H5_V1_4_COMPAT */ /*------------------------------------------------------------------------- * Function: H5Pset_sym_k * * Purpose: IK is one half the rank of a tree that stores a symbol * table for a group. Internal nodes of the symbol table are on * average 75% full. That is, the average rank of the tree is * 1.5 times the value of IK. * * LK is one half of the number of symbols that can be stored in * a symbol table node. A symbol table node is the leaf of a * symbol table tree which is used to store a group. When * symbols are inserted randomly into a group, the group's * symbol table nodes are 75% full on average. That is, they * contain 1.5 times the number of symbols specified by LK. * * Either (or even both) of IK and LK can be zero in which case * that value is left unchanged. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Tuesday, January 6, 1998 * * Modifications: * * Raymond Lu, Oct 14, 2001 * Changed to the new generic property list. * *------------------------------------------------------------------------- */ herr_t H5Pset_sym_k(hid_t plist_id, unsigned ik, unsigned lk) { unsigned btree_k[H5B_NUM_BTREE_ID]; H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Pset_sym_k, FAIL); H5TRACE3("e","iIuIu",plist_id,ik,lk); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Set values */ if (ik > 0) { if(H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get rank for btree interanl nodes"); btree_k[H5B_SNODE_ID] = ik; if(H5P_set(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set rank for btree nodes"); } if (lk > 0) if(H5P_set(plist, H5F_CRT_SYM_LEAF_NAME, &lk) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set rank for symbol table leaf nodes"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Pget_sym_k * * Purpose: Retrieves the symbol table B-tree 1/2 rank (IK) and the * symbol table leaf node 1/2 size (LK). See H5Pset_sym_k() for * details. Either (or even both) IK and LK may be null * pointers. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Wednesday, January 7, 1998 * * Modifications: * * Raymond Lu * Changed to the new generic property list. * *------------------------------------------------------------------------- */ herr_t H5Pget_sym_k(hid_t plist_id, unsigned *ik /*out */ , unsigned *lk /*out */ ) { unsigned btree_k[H5B_NUM_BTREE_ID]; H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Pget_sym_k, FAIL); H5TRACE3("e","ixx",plist_id,ik,lk); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Get values */ if (ik) { if(H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get rank for btree nodes"); *ik = btree_k[H5B_SNODE_ID]; } if (lk) if(H5P_get(plist, H5F_CRT_SYM_LEAF_NAME, lk) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get rank for symbol table leaf nodes"); done: FUNC_LEAVE_API(ret_value); } #endif /* H5_WANT_H5_V1_4_COMPAT */ /*------------------------------------------------------------------------- * Function: H5Pset_istore_k * * Purpose: IK is one half the rank of a tree that stores chunked raw * data. On average, such a tree will be 75% full, or have an * average rank of 1.5 times the value of IK. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Tuesday, January 6, 1998 * * Modifications: * * Raymond Lu, Oct 14, 2001 * Changed to the new generic property list. * *------------------------------------------------------------------------- */ herr_t H5Pset_istore_k(hid_t plist_id, unsigned ik) { unsigned btree_k[H5B_NUM_BTREE_ID]; H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Pset_istore_k, FAIL); H5TRACE2("e","iIu",plist_id,ik); /* Check arguments */ if (ik == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "istore IK value must be positive"); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Set value */ if(H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get rank for btree interanl nodes"); btree_k[H5B_ISTORE_ID] = ik; if(H5P_set(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set rank for btree interanl nodes"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Pget_istore_k * * Purpose: Queries the 1/2 rank of an indexed storage B-tree. See * H5Pset_istore_k() for details. The argument IK may be the * null pointer. * * Return: Success: Non-negative, size returned through IK * * Failure: Negative * * Programmer: Robb Matzke * Wednesday, January 7, 1998 * * Modifications: * * Raymond Lu, Oct 14, 2001 * Changed to the new generic property list. * *------------------------------------------------------------------------- */ herr_t H5Pget_istore_k(hid_t plist_id, unsigned *ik /*out */ ) { unsigned btree_k[H5B_NUM_BTREE_ID]; H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pget_istore_k, FAIL); H5TRACE2("e","ix",plist_id,ik); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Get value */ if (ik) { if(H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get rank for btree interanl nodes"); *ik = btree_k[H5B_ISTORE_ID]; } done: FUNC_LEAVE_API(ret_value); } xdmf-3.0+git20160803/Utilities/hdf5/CTestCustom.ctest.in0000640000175000017500000000016413003006557022562 0ustar alastairalastairSET(CTEST_CUSTOM_WARNING_EXCEPTION ${CTEST_CUSTOM_WARNING_EXCEPTION} "/Utilities/hdf5/H5[^/\".]*\\.c[:\"]" ) xdmf-3.0+git20160803/Utilities/hdf5/H5Dtest.c0000640000175000017500000000777713003006557020341 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* Programmer: Quincey Koziol * Thusdayr, May 27, 2004 * * Purpose: Dataset testing functions. */ #define H5D_PACKAGE /*suppress error about including H5Dpkg */ #define H5D_TESTING /*suppress warning about H5D testing funcs*/ #include "H5private.h" /* Generic Functions */ #include "H5Dpkg.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5Iprivate.h" /* ID Functions */ /*-------------------------------------------------------------------------- NAME H5D_layout_version_test PURPOSE Determine the storage layout version for a dataset's layout information USAGE herr_t H5D_layout_version_test(did, version) hid_t did; IN: Dataset to query unsigned *version; OUT: Pointer to location to place version info RETURNS Non-negative on success, negative on failure DESCRIPTION Checks the version of the storage layout information for a dataset. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS DO NOT USE THIS FUNCTION FOR ANYTHING EXCEPT TESTING EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5D_layout_version_test(hid_t did, unsigned *version) { H5D_t *dset; /* Pointer to dataset to query */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_NOAPI(H5D_layout_version_test, FAIL); /* Check args */ if (NULL==(dset=H5I_object_verify(did, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") if(version) *version=dset->shared->layout.version; done: FUNC_LEAVE_NOAPI(ret_value); } /* H5D_layout_version_test() */ /*-------------------------------------------------------------------------- NAME H5D_layout_contig_size_test PURPOSE Determine the size of a contiguous layout for a dataset's layout information USAGE herr_t H5D_layout_contig_size_test(did, size) hid_t did; IN: Dataset to query hsize_t *size; OUT: Pointer to location to place size info RETURNS Non-negative on success, negative on failure DESCRIPTION Checks the size of a contiguous dataset's storage. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS DO NOT USE THIS FUNCTION FOR ANYTHING EXCEPT TESTING EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5D_layout_contig_size_test(hid_t did, hsize_t *size) { H5D_t *dset; /* Pointer to dataset to query */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_NOAPI(H5D_layout_contig_size_test, FAIL); /* Check args */ if (NULL==(dset=H5I_object_verify(did, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") if(size) { assert(dset->shared->layout.type==H5D_CONTIGUOUS); *size=dset->shared->layout.u.contig.size; } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value); } /* H5D_layout_contig_size_test() */ xdmf-3.0+git20160803/Utilities/hdf5/H5FOprivate.h0000640000175000017500000000435213003006557021144 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * This file contains library private information about the H5FO module */ #ifndef _H5FOprivate_H #define _H5FOprivate_H #ifdef LATER #include "H5FOpublic.h" #endif /* LATER */ /* Private headers needed by this file */ #include "H5private.h" /* Generic Functions */ #include "H5Fprivate.h" /* File access */ #include "H5SLprivate.h" /* Skip lists */ /* Typedefs */ /* Typedef for open object cache */ typedef H5SL_t H5FO_t; /* Currently, all open objects are stored in skip list */ /* Macros */ /* Private routines */ H5_DLL herr_t H5FO_create(const H5F_t *f); H5_DLL void *H5FO_opened(const H5F_t *f, haddr_t addr); H5_DLL herr_t H5FO_insert(const H5F_t *f, haddr_t addr, void *obj); H5_DLL herr_t H5FO_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr); H5_DLL herr_t H5FO_mark(const H5F_t *f, haddr_t addr, hbool_t deleted); H5_DLL htri_t H5FO_marked(const H5F_t *f, haddr_t addr); H5_DLL herr_t H5FO_dest(const H5F_t *f); H5_DLL herr_t H5FO_top_create(H5F_t *f); H5_DLL herr_t H5FO_top_incr(const H5F_t *f, haddr_t addr); H5_DLL herr_t H5FO_top_decr(const H5F_t *f, haddr_t addr); H5_DLL hsize_t H5FO_top_count(const H5F_t *f, haddr_t addr); H5_DLL herr_t H5FO_top_dest(H5F_t *f); #endif /* _H5FOprivate_H */ xdmf-3.0+git20160803/Utilities/hdf5/H5HLdbg.c0000640000175000017500000001340113003006557020213 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* Programmer: Quincey Koziol * Wednesday, July 9, 2003 * * Purpose: Local Heap object debugging functions. */ #define H5HL_PACKAGE /* Suppress error about including H5HLpkg */ #include "H5private.h" /* Generic Functions */ #include "H5ACprivate.h" /* Metadata cache */ #include "H5Eprivate.h" /* Error handling */ #include "H5HLpkg.h" /* Local heaps */ #include "H5Iprivate.h" /* ID Functions */ #include "H5MMprivate.h" /* Memory management */ /*------------------------------------------------------------------------- * Function: H5HL_debug * * Purpose: Prints debugging information about a heap. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 1 1997 * * Modifications: * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. *------------------------------------------------------------------------- */ herr_t H5HL_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, int fwidth) { H5HL_t *h = NULL; int i, j, overlap, free_block; uint8_t c; H5HL_free_t *freelist = NULL; uint8_t *marker = NULL; size_t amount_free = 0; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5HL_debug, FAIL); /* check arguments */ assert(f); assert(H5F_addr_defined(addr)); assert(stream); assert(indent >= 0); assert(fwidth >= 0); if (NULL == (h = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL, H5AC_READ))) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap"); fprintf(stream, "%*sLocal Heap...\n", indent, ""); fprintf(stream, "%*s%-*s %d\n", indent, "", fwidth, "Dirty:", (int) (h->cache_info.is_dirty)); fprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, "Header size (in bytes):", (unsigned long) H5HL_SIZEOF_HDR(f)); HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "Address of heap data:", h->addr); HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, "Data bytes allocated on disk:", h->disk_alloc); HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, "Data bytes allocated in core:", h->mem_alloc); /* * Traverse the free list and check that all free blocks fall within * the heap and that no two free blocks point to the same region of * the heap. */ if (NULL==(marker = H5MM_calloc(h->mem_alloc))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); fprintf(stream, "%*sFree Blocks (offset, size):\n", indent, ""); for (free_block=0, freelist = h->freelist; freelist; freelist = freelist->next, free_block++) { char temp_str[32]; sprintf(temp_str,"Block #%d:",free_block); HDfprintf(stream, "%*s%-*s %8Zu, %8Zu\n", indent+3, "", MAX(0,fwidth-9), temp_str, freelist->offset, freelist->size); if (freelist->offset + freelist->size > h->mem_alloc) { fprintf(stream, "***THAT FREE BLOCK IS OUT OF BOUNDS!\n"); } else { for (i=overlap=0; i<(int)(freelist->size); i++) { if (marker[freelist->offset + i]) overlap++; marker[freelist->offset + i] = 1; } if (overlap) { fprintf(stream, "***THAT FREE BLOCK OVERLAPPED A PREVIOUS " "ONE!\n"); } else { amount_free += freelist->size; } } } if (h->mem_alloc) { fprintf(stream, "%*s%-*s %.2f%%\n", indent, "", fwidth, "Percent of heap used:", (100.0 * (double)(h->mem_alloc - amount_free) / (double)h->mem_alloc)); } /* * Print the data in a VMS-style octal dump. */ fprintf(stream, "%*sData follows (`__' indicates free region)...\n", indent, ""); for (i=0; i<(int)(h->disk_alloc); i+=16) { fprintf(stream, "%*s %8d: ", indent, "", i); for (j = 0; j < 16; j++) { if (i+j<(int)(h->disk_alloc)) { if (marker[i + j]) { fprintf(stream, "__ "); } else { c = h->chunk[H5HL_SIZEOF_HDR(f) + i + j]; fprintf(stream, "%02x ", c); } } else { fprintf(stream, " "); } if (7 == j) HDfputc(' ', stream); } for (j = 0; j < 16; j++) { if (i+j < (int)(h->disk_alloc)) { if (marker[i + j]) { HDfputc(' ', stream); } else { c = h->chunk[H5HL_SIZEOF_HDR(f) + i + j]; if (c > ' ' && c < '~') HDfputc(c, stream); else HDfputc('.', stream); } } } HDfputc('\n', stream); } done: if (h && H5AC_unprotect(f, dxpl_id, H5AC_LHEAP, addr, h, FALSE) != SUCCEED) HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header"); H5MM_xfree(marker); FUNC_LEAVE_NOAPI(ret_value); } xdmf-3.0+git20160803/Utilities/hdf5/H5private.h0000640000175000017500000013720313003006557020721 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* Programmer: Robb Matzke * Friday, October 30, 1998 * * Purpose: This file is included by all HDF5 library source files to * define common things which are not defined in the HDF5 API. * The configuration constants like H5_HAVE_UNISTD_H etc. are * defined in H5config.h which is included by H5public.h. * */ #ifndef _H5private_H #define _H5private_H #include "H5public.h" /* Include Public Definitions */ /* include the pthread header */ #ifdef H5_HAVE_THREADSAFE #include #endif /* * Include ANSI-C header files. */ #ifdef H5_STDC_HEADERS # include # include # include # include # include # include # include # include # include # include # include # include #endif /* * If _POSIX_VERSION is defined in unistd.h then this system is Posix.1 * compliant. Otherwise all bets are off. */ #ifdef H5_HAVE_UNISTD_H # include # include #endif #ifdef _POSIX_VERSION # include # include #endif /* * C9x integer types */ #ifndef __cplusplus #ifdef H5_HAVE_STDINT_H # include #endif #endif /* * The `struct stat' data type for stat() and fstat(). This is a Posix file * but often apears on non-Posix systems also. The `struct stat' is required * for hdf5 to compile, although only a few fields are actually used. */ #ifdef H5_HAVE_SYS_STAT_H # include #endif /* * If a program may include both `time.h' and `sys/time.h' then * TIME_WITH_SYS_TIME is defined (see AC_HEADER_TIME in configure.in). * On some older systems, `sys/time.h' includes `time.h' but `time.h' is not * protected against multiple inclusion, so programs should not explicitly * include both files. This macro is useful in programs that use, for example, * `struct timeval' or `struct timezone' as well as `struct tm'. It is best * used in conjunction with `HAVE_SYS_TIME_H', whose existence is checked * by `AC_CHECK_HEADERS(sys/time.h)' in configure.in. */ #if defined(H5_TIME_WITH_SYS_TIME) # include # include #elif defined(H5_HAVE_SYS_TIME_H) # include #else # include #endif /* * Longjumps are used to detect alignment constrants */ #ifdef H5_HAVE_SETJMP_H # include #endif /* * Resource usage is not Posix.1 but HDF5 uses it anyway for some performance * and debugging code if available. */ #ifdef H5_HAVE_SYS_RESOURCE_H # include #endif /* * Unix ioctls. These are used by h5ls (and perhaps others) to determine a * resonable output width. */ #ifdef H5_HAVE_SYS_IOCTL_H # include #endif /* * System information. These are needed on the DEC Alpha to turn off fixing * of unaligned accesses by the operating system during detection of * alignment constraints in H5detect.c:main(). */ #ifdef H5_HAVE_SYS_SYSINFO_H # include #endif #ifdef H5_HAVE_SYS_PROC_H # include #endif #ifdef H5_HAVE_IO_H # include #endif #ifdef WIN32 #define VC_EXTRALEAN /*Exclude rarely-used stuff from Windows headers */ #include #endif /*WIN32*/ /* H5_inline */ #ifndef H5_inline #define H5_inline #endif /* H5_inline */ #ifndef F_OK # define F_OK 00 # define W_OK 02 # define R_OK 04 #endif /* * MPE Instrumentation support * Do not #if the following header file because it contains * the needed null definitions for the H5-MPE macros when MPE * support is not configured. * */ #include "H5MPprivate.h" /* * dmalloc (debugging malloc) support */ #ifdef H5_HAVE_DMALLOC_H #include "dmalloc.h" #endif /* H5_HAVE_DMALLOC_H */ /* * NT doesn't define SIGBUS, but since NT only runs on processors * that do not have alignment constraints a SIGBUS would never be * raised, so we just replace it with SIGILL (which also should * never be raised by the hdf5 library). */ #ifndef SIGBUS # define SIGBUS SIGILL #endif /* * Does the compiler support the __attribute__(()) syntax? This is how gcc * suppresses warnings about unused function arguments. It's no big deal if * we don't. */ #ifdef __cplusplus # define __attribute__(X) /*void*/ # define UNUSED /*void*/ #else /* __cplusplus */ #ifdef H5_HAVE_ATTRIBUTE # define UNUSED __attribute__((unused)) #else # define __attribute__(X) /*void*/ # define UNUSED /*void*/ #endif #endif /* __cplusplus */ /* * Does the compiler expand __FUNCTION__ to be the name of the function * currently being defined? If not then define it to be some constant * string. */ #ifndef H5_HAVE_FUNCTION # define __FUNCTION__ "NoFunctionName" #endif /* Version #'s of the major components of the file format */ #define HDF5_SUPERBLOCK_VERSION_DEF 0 /* The default super block format */ #define HDF5_SUPERBLOCK_VERSION_MAX 1 /* The maximum super block format */ #define HDF5_FREESPACE_VERSION 0 /* of the Free-Space Info */ #define HDF5_OBJECTDIR_VERSION 0 /* of the Object Directory format */ #define HDF5_SHAREDHEADER_VERSION 0 /* of the Shared-Header Info */ #define HDF5_DRIVERINFO_VERSION 0 /* of the Driver Information Block*/ /* B-tree internal 'K' values */ #define HDF5_BTREE_SNODE_IK_DEF 16 #define HDF5_BTREE_ISTORE_IK_DEF 32 /* Note! this value is assumed to be 32 for older versions of the superblock (<1) and if it is changed, the code must compensate. -QAK */ /* * Status return values for the `herr_t' type. * Since some unix/c routines use 0 and -1 (or more precisely, non-negative * vs. negative) as their return code, and some assumption had been made in * the code about that, it is important to keep these constants the same * values. When checking the success or failure of an integer-valued * function, remember to compare against zero and not one of these two * values. */ #define SUCCEED 0 #define FAIL (-1) #define UFAIL (unsigned)(-1) /* number of members in an array */ #ifndef NELMTS # define NELMTS(X) (sizeof(X)/sizeof(X[0])) #endif /* minimum of two, three, or four values */ #undef MIN #define MIN(a,b) (((a)<(b)) ? (a) : (b)) #define MIN2(a,b) MIN(a,b) #define MIN3(a,b,c) MIN(a,MIN(b,c)) #define MIN4(a,b,c,d) MIN(MIN(a,b),MIN(c,d)) /* maximum of two, three, or four values */ #undef MAX #define MAX(a,b) (((a)>(b)) ? (a) : (b)) #define MAX2(a,b) MAX(a,b) #define MAX3(a,b,c) MAX(a,MAX(b,c)) #define MAX4(a,b,c,d) MAX(MAX(a,b),MAX(c,d)) /* limit the middle value to be within a range (inclusive) */ #define RANGE(LO,X,HI) MAX(LO,MIN(X,HI)) /* absolute value */ #ifndef ABS # define ABS(a) (((a)>=0) ? (a) : -(a)) #endif /* sign of argument */ #ifndef SIGN # define SIGN(a) ((a)>0 ? 1 : (a)<0 ? -1 : 0) #endif /* * HDF Boolean type. */ #ifndef FALSE # define FALSE 0 #endif #ifndef TRUE # define TRUE 1 #endif /* * Although `long long' is part of the revised ANSI-C some compilers don't * support it yet. We define `long_long' as the longest integral integer type * supported by the compiler, usually 64 bits. It must be legal to qualify * `long_long' with `unsigned'. */ #if H5_SIZEOF_LONG_LONG>0 # define long_long long long #elif H5_SIZEOF___INT64>0 # define long_long __int64 /*Win32*/ # undef H5_SIZEOF_LONG_LONG # define H5_SIZEOF_LONG_LONG H5_SIZEOF___INT64 #else # define long_long long int # undef H5_SIZEOF_LONG_LONG # define H5_SIZEOF_LONG_LONG H5_SIZEOF_LONG #endif /* * Numeric data types. Some of these might be defined in Posix.1g, otherwise * we define them with the closest available type which is at least as large * as the number of bits indicated in the type name. The `int8' types *must* * be exactly one byte wide because we use it for pointer calculations to * void* memory. */ #if H5_SIZEOF_INT8_T==0 typedef signed char int8_t; # undef H5_SIZEOF_INT8_T # define H5_SIZEOF_INT8_T H5_SIZEOF_CHAR #elif H5_SIZEOF_INT8_T==1 #else # error "the int8_t type must be 1 byte wide" #endif #if H5_SIZEOF_UINT8_T==0 typedef unsigned char uint8_t; # undef H5_SIZEOF_UINT8_T # define H5_SIZEOF_UINT8_T H5_SIZEOF_CHAR #elif H5_SIZEOF_UINT8_T==1 #else # error "the uint8_t type must be 1 byte wide" #endif #if H5_SIZEOF_INT16_T>=2 #elif H5_SIZEOF_SHORT>=2 typedef short int16_t; # undef H5_SIZEOF_INT16_T # define H5_SIZEOF_INT16_T H5_SIZEOF_SHORT #elif H5_SIZEOF_INT>=2 typedef int int16_t; # undef H5_SIZEOF_INT16_T # define H5_SIZEOF_INT16_T H5_SIZEOF_INT #else # error "nothing appropriate for int16_t" #endif #if H5_SIZEOF_UINT16_T>=2 #elif H5_SIZEOF_SHORT>=2 typedef unsigned short uint16_t; # undef H5_SIZEOF_UINT16_T # define H5_SIZEOF_UINT16_T H5_SIZEOF_SHORT #elif H5_SIZEOF_INT>=2 typedef unsigned uint16_t; # undef H5_SIZEOF_UINT16_T # define H5_SIZEOF_UINT16_T H5_SIZEOF_INT #else # error "nothing appropriate for uint16_t" #endif #if H5_SIZEOF_INT32_T>=4 #elif H5_SIZEOF_SHORT>=4 typedef short int32_t; # undef H5_SIZEOF_INT32_T # define H5_SIZEOF_INT32_T H5_SIZEOF_SHORT #elif H5_SIZEOF_INT>=4 typedef int int32_t; # undef H5_SIZEOF_INT32_T # define H5_SIZEOF_INT32_T H5_SIZEOF_INT #elif H5_SIZEOF_LONG>=4 typedef long int32_t; # undef H5_SIZEOF_INT32_T # define H5_SIZEOF_INT32_T H5_SIZEOF_LONG #else # error "nothing appropriate for int32_t" #endif #if H5_SIZEOF_UINT32_T>=4 #elif H5_SIZEOF_SHORT>=4 typedef short uint32_t; # undef H5_SIZEOF_UINT32_T # define H5_SIZEOF_UINT32_T H5_SIZEOF_SHORT #elif H5_SIZEOF_INT>=4 typedef unsigned int uint32_t; # undef H5_SIZEOF_UINT32_T # define H5_SIZEOF_UINT32_T H5_SIZEOF_INT #elif H5_SIZEOF_LONG>=4 typedef unsigned long uint32_t; # undef H5_SIZEOF_UINT32_T # define H5_SIZEOF_UINT32_T H5_SIZEOF_LONG #else # error "nothing appropriate for uint32_t" #endif #if H5_SIZEOF_INT64_T>=8 #elif H5_SIZEOF_INT>=8 typedef int int64_t; # undef H5_SIZEOF_INT64_T # define H5_SIZEOF_INT64_T H5_SIZEOF_INT #elif H5_SIZEOF_LONG>=8 typedef long int64_t; # undef H5_SIZEOF_INT64_T # define H5_SIZEOF_INT64_T H5_SIZEOF_LONG #elif H5_SIZEOF_LONG_LONG>=8 typedef long_long int64_t; # undef H5_SIZEOF_INT64_T # define H5_SIZEOF_INT64_T H5_SIZEOF_LONG_LONG #else # error "nothing appropriate for int64_t" #endif #if H5_SIZEOF_UINT64_T>=8 #elif H5_SIZEOF_INT>=8 typedef unsigned uint64_t; # undef H5_SIZEOF_UINT64_T # define H5_SIZEOF_UINT64_T H5_SIZEOF_INT #elif H5_SIZEOF_LONG>=8 typedef unsigned long uint64_t; # undef H5_SIZEOF_UINT64_T # define H5_SIZEOF_UINT64_T H5_SIZEOF_LONG #elif H5_SIZEOF_LONG_LONG>=8 typedef unsigned long_long uint64_t; # undef H5_SIZEOF_UINT64_T # define H5_SIZEOF_UINT64_T H5_SIZEOF_LONG_LONG #else # error "nothing appropriate for uint64_t" #endif /* * Maximum and minimum values. These should be defined in for the * most part. */ #ifndef LLONG_MAX # define LLONG_MAX ((long_long)(((unsigned long_long)1 \ <<(8*sizeof(long_long)-1))-1)) # define LLONG_MIN ((long_long)(-LLONG_MAX)-1) #endif #ifndef ULLONG_MAX # define ULLONG_MAX ((unsigned long_long)((long_long)(-1))) #endif #ifndef SIZET_MAX # define SIZET_MAX ((size_t)(ssize_t)(-1)) # define SSIZET_MAX ((ssize_t)(((size_t)1<<(8*sizeof(ssize_t)-1))-1)) #endif #ifdef H5_HAVE_LARGE_HSIZET #define HSIZET_MAX ((hsize_t)ULLONG_MAX) #define HSSIZET_MAX ((hssize_t)LLONG_MAX) #else /* H5_HAVE_LARGE_HSIZET */ #define HSIZET_MAX ((hsize_t)SIZET_MAX) #define HSSIZET_MAX ((hssize_t)SSIZET_MAX) #endif /* H5_HAVE_LARGE_HSIZET */ #define HSSIZET_MIN (~(HSSIZET_MAX)) /* * A macro to portably increment enumerated types. */ #ifndef H5_INC_ENUM # define H5_INC_ENUM(TYPE,VAR) (VAR)=((TYPE)((VAR)+1)) #endif /* * A macro to portably decrement enumerated types. */ #ifndef H5_DEC_ENUM # define H5_DEC_ENUM(TYPE,VAR) (VAR)=((TYPE)((VAR)-1)) #endif /* * A macro for detecting over/under-flow when casting between types */ #ifndef NDEBUG #define H5_CHECK_OVERFLOW(var,vartype,casttype) \ { \ casttype _tmp_overflow=(casttype)(var); \ assert((var)==(vartype)_tmp_overflow); \ } #else /* NDEBUG */ #define H5_CHECK_OVERFLOW(var,vartype,casttype) #endif /* NDEBUG */ /* * A macro for detecting over/under-flow when assigning between types */ #ifndef NDEBUG #define H5_ASSIGN_OVERFLOW(var,expr,exprtype,vartype) \ { \ exprtype _tmp_overflow=(exprtype)(expr); \ vartype _tmp_overflow2=(vartype)(_tmp_overflow); \ assert((vartype)_tmp_overflow==_tmp_overflow2); \ (var)=_tmp_overflow2; \ } #else /* NDEBUG */ #define H5_ASSIGN_OVERFLOW(var,expr,exprtype,vartype) \ (var)=(vartype)(expr); #endif /* NDEBUG */ /* * Data types and functions for timing certain parts of the library. */ typedef struct { double utime; /*user time */ double stime; /*system time */ double etime; /*elapsed wall-clock time */ } H5_timer_t; H5_DLL void H5_timer_reset (H5_timer_t *timer); H5_DLL void H5_timer_begin (H5_timer_t *timer); H5_DLL void H5_timer_end (H5_timer_t *sum/*in,out*/, H5_timer_t *timer/*in,out*/); H5_DLL void H5_bandwidth(char *buf/*out*/, double nbytes, double nseconds); /* * Redefine all the POSIX functions. We should never see a POSIX * function (or any other non-HDF5 function) in the source! */ #define HDabort() abort() #define HDabs(X) abs(X) #define HDaccess(F,M) access(F, M) #define HDacos(X) acos(X) #ifdef H5_HAVE_ALARM #define HDalarm(N) alarm(N) #else /* H5_HAVE_ALARM */ #define HDalarm(N) (0) #endif /* H5_HAVE_ALARM */ #define HDasctime(T) asctime(T) #define HDasin(X) asin(X) #define HDassert(X) assert(X) #define HDatan(X) atan(X) #define HDatan2(X,Y) atan2(X,Y) #define HDatexit(F) atexit(F) #define HDatof(S) atof(S) #define HDatoi(S) atoi(S) #define HDatol(S) atol(S) #define HDBSDgettimeofday(S,P) BSDgettimeofday(S,P) #define HDbsearch(K,B,N,Z,F) bsearch(K,B,N,Z,F) #define HDcalloc(N,Z) calloc(N,Z) #define HDceil(X) ceil(X) #define HDcfgetispeed(T) cfgetispeed(T) #define HDcfgetospeed(T) cfgetospeed(T) #define HDcfsetispeed(T,S) cfsetispeed(T,S) #define HDcfsetospeed(T,S) cfsetospeed(T,S) #define HDchdir(S) chdir(S) #define HDchmod(S,M) chmod(S,M) #define HDchown(S,O,G) chown(S,O,G) #define HDclearerr(F) clearerr(F) #define HDclock() clock() #define HDclose(F) close(F) #define HDclosedir(D) closedir(D) #define HDcos(X) cos(X) #define HDcosh(X) cosh(X) #define HDcreat(S,M) creat(S,M) #define HDctermid(S) ctermid(S) #define HDctime(T) ctime(T) #define HDcuserid(S) cuserid(S) #ifdef H5_HAVE_DIFFTIME #define HDdifftime(X,Y) difftime(X,Y) #else #define HDdifftime(X,Y) ((double)(X)-(double)(Y)) #endif #define HDdiv(X,Y) div(X,Y) #define HDdup(F) dup(F) #define HDdup2(F,I) dup2(F,I) /* execl() variable arguments */ /* execle() variable arguments */ /* execlp() variable arguments */ #define HDexecv(S,AV) execv(S,AV) #define HDexecve(S,AV,E) execve(S,AV,E) #define HDexecvp(S,AV) execvp(S,AV) #define HDexit(N) exit(N) #if defined __MWERKS__ #include #define HD_exit(N) __exit(N) #else /* __MWERKS __ */ #define HD_exit(N) _exit(N) #endif /* __MWERKS __ */ #define HDexp(X) exp(X) #define HDfabs(X) fabs(X) /* use ABS() because fabsf() fabsl() are not common yet. */ #define HDfabsf(X) ABS(X) #define HDfabsl(X) ABS(X) #define HDfclose(F) fclose(F) /* fcntl() variable arguments */ #define HDfdopen(N,S) fdopen(N,S) #define HDfeof(F) feof(F) #define HDferror(F) ferror(F) #define HDfflush(F) fflush(F) #define HDfgetc(F) fgetc(F) #define HDfgetpos(F,P) fgetpos(F,P) #define HDfgets(S,N,F) fgets(S,N,F) #ifdef WIN32 #define HDfileno(F) _fileno(F) #else /* WIN32 */ #define HDfileno(F) fileno(F) #endif /* WIN32 */ #define HDfloor(X) floor(X) #define HDfmod(X,Y) fmod(X,Y) #define HDfopen(S,M) fopen(S,M) #define HDfork() fork() #define HDfpathconf(F,N) fpathconf(F,N) H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...); #define HDfputc(C,F) fputc(C,F) #define HDfputs(S,F) fputs(S,F) #define HDfread(M,Z,N,F) fread(M,Z,N,F) #define HDfree(M) free(M) #define HDfreopen(S,M,F) freopen(S,M,F) #define HDfrexp(X,N) frexp(X,N) /* Check for Cray-specific 'frexpf()' and 'frexpl()' routines */ #ifdef H5_HAVE_FREXPF #define HDfrexpf(X,N) frexpf(X,N) #else /* H5_HAVE_FREXPF */ #define HDfrexpf(X,N) frexp(X,N) #endif /* H5_HAVE_FREXPF */ #ifdef H5_HAVE_FREXPL #define HDfrexpl(X,N) frexpl(X,N) #else /* H5_HAVE_FREXPL */ #define HDfrexpl(X,N) frexp(X,N) #endif /* H5_HAVE_FREXPL */ /* fscanf() variable arguments */ #define HDfseek(F,O,W) fseek(F,O,W) #define HDfsetpos(F,P) fsetpos(F,P) /* definitions related to the file stat utilities */ #ifdef WIN32 #ifdef __MWERKS__ #define HDfstat(F,B) fstat(F,B) typedef struct stat h5_stat_t; typedef off_t h5_stat_size_t; #else /*MSVC*/ #define HDfstat(F,B) _fstati64(F,B) typedef struct _stati64 h5_stat_t; typedef __int64 h5_stat_size_t; #endif #else #define HDfstat(F,B) fstat(F,B) typedef struct stat h5_stat_t; typedef off_t h5_stat_size_t; #endif #define HDftell(F) ftell(F) #define HDftruncate(F,L) ftruncate(F,L) #define HDfwrite(M,Z,N,F) fwrite(M,Z,N,F) #define HDgetc(F) getc(F) #define HDgetchar() getchar() #define HDgetcwd(S,Z) getcwd(S,Z) #define HDgetegid() getegid() #define HDgetenv(S) getenv(S) #define HDgeteuid() geteuid() #define HDgetgid() getgid() #define HDgetgrgid(G) getgrgid(G) #define HDgetgrnam(S) getgrnam(S) #define HDgetgroups(Z,G) getgroups(Z,G) #define HDgetlogin() getlogin() #define HDgetpgrp() getpgrp() #define HDgetpid() getpid() #define HDgetppid() getppid() #define HDgetpwnam(S) getpwnam(S) #define HDgetpwuid(U) getpwuid(U) #define HDgetrusage(X,S) getrusage(X,S) #define HDgets(S) gets(S) #define HDgettimeofday(S,P) gettimeofday(S,P) #define HDgetuid() getuid() #define HDgmtime(T) gmtime(T) #define HDisalnum(C) isalnum((int)(C)) /*cast for solaris warning*/ #define HDisalpha(C) isalpha((int)(C)) /*cast for solaris warning*/ #define HDisatty(F) isatty(F) #define HDiscntrl(C) iscntrl((int)(C)) /*cast for solaris warning*/ #define HDisdigit(C) isdigit((int)(C)) /*cast for solaris warning*/ #define HDisgraph(C) isgraph((int)(C)) /*cast for solaris warning*/ #define HDislower(C) islower((int)(C)) /*cast for solaris warning*/ #define HDisprint(C) isprint((int)(C)) /*cast for solaris warning*/ #define HDispunct(C) ispunct((int)(C)) /*cast for solaris warning*/ #define HDisspace(C) isspace((int)(C)) /*cast for solaris warning*/ #define HDisupper(C) isupper((int)(C)) /*cast for solaris warning*/ #define HDisxdigit(C) isxdigit((int)(C)) /*cast for solaris warning*/ #define HDkill(P,S) kill(P,S) #define HDlabs(X) labs(X) #define HDldexp(X,N) ldexp(X,N) #define HDldiv(X,Y) ldiv(X,Y) #define HDlink(OLD,NEW) link(OLD,NEW) #define HDlocaleconv() localeconv() #define HDlocaltime(T) localtime(T) #define HDlog(X) log(X) #define HDlog10(X) log10(X) #define HDlongjmp(J,N) longjmp(J,N) #ifdef WIN32 #ifdef __MWERKS__ #define HDlseek(F,O,W) lseek(F,O,W) #else /*MSVS */ #define HDlseek(F,O,W) _lseeki64(F,O,W) #endif #else #define HDlseek(F,O,W) lseek(F,O,W) #endif #define HDmalloc(Z) malloc(Z) #define HDmblen(S,N) mblen(S,N) #define HDmbstowcs(P,S,Z) mbstowcs(P,S,Z) #define HDmbtowc(P,S,Z) mbtowc(P,S,Z) #define HDmemchr(S,C,Z) memchr(S,C,Z) #define HDmemcmp(X,Y,Z) memcmp(X,Y,Z) /* * The (char*) casts are required for the DEC when optimizations are turned * on and the source and/or destination are not aligned. */ #define HDmemcpy(X,Y,Z) memcpy((char*)(X),(const char*)(Y),Z) #define HDmemmove(X,Y,Z) memmove((char*)(X),(const char*)(Y),Z) /* * The (void*) cast just avoids a compiler warning in WIN32 */ #ifdef WIN32 #define HDmemset(X,C,Z) memset((void*)(X),C,Z) #else /* WIN32 */ #define HDmemset(X,C,Z) memset(X,C,Z) #endif /* WIN32 */ #ifdef WIN32 #define HDmkdir(S,M) _mkdir(S) #else /* WIN32 */ #define HDmkdir(S,M) mkdir(S,M) #endif /* WIN32 */ #define HDmkfifo(S,M) mkfifo(S,M) #define HDmktime(T) mktime(T) #define HDmodf(X,Y) modf(X,Y) #ifdef _O_BINARY #define HDopen(S,F,M) open(S,F|_O_BINARY,M) #else #define HDopen(S,F,M) open(S,F,M) #endif #define HDopendir(S) opendir(S) #define HDpathconf(S,N) pathconf(S,N) #define HDpause() pause() #define HDperror(S) perror(S) #define HDpipe(F) pipe(F) #define HDpow(X,Y) pow(X,Y) /* printf() variable arguments */ #define HDputc(C,F) putc(C,F) #define HDputchar(C) putchar(C) #define HDputs(S) puts(S) #define HDqsort(M,N,Z,F) qsort(M,N,Z,F) #define HDraise(N) raise(N) #define HDrand() rand() #ifdef WIN32 #define HDrandom() rand() #else #define HDrandom() random() #endif #define HDread(F,M,Z) read(F,M,Z) #define HDreaddir(D) readdir(D) #define HDrealloc(M,Z) realloc(M,Z) #define HDremove(S) remove(S) #define HDrename(OLD,NEW) rename(OLD,NEW) #define HDrewind(F) rewind(F) #define HDrewinddir(D) rewinddir(D) #define HDrmdir(S) rmdir(S) /* scanf() variable arguments */ #define HDsetbuf(F,S) setbuf(F,S) #define HDsetgid(G) setgid(G) #define HDsetjmp(J) setjmp(J) #define HDsetlocale(N,S) setlocale(N,S) #define HDsetpgid(P,PG) setpgid(P,PG) #define HDsetsid() setsid() #define HDsetuid(U) setuid(U) #define HDsetvbuf(F,S,M,Z) setvbuf(F,S,M,Z) #define HDsigaction(N,A) sigaction(N,A) #define HDsigaddset(S,N) sigaddset(S,N) #define HDsigdelset(S,N) sigdelset(S,N) #define HDsigemptyset(S) sigemptyset(S) #define HDsigfillset(S) sigfillset(S) #define HDsigismember(S,N) sigismember(S,N) #define HDsiglongjmp(J,N) siglongjmp(J,N) #define HDsignal(N,F) signal(N,F) #define HDsigpending(S) sigpending(S) #define HDsigprocmask(H,S,O) sigprocmask(H,S,O) #define HDsigsetjmp(J,N) sigsetjmp(J,N) #define HDsigsuspend(S) sigsuspend(S) #define HDsin(X) sin(X) #define HDsinh(X) sinh(X) #define HDsleep(N) sleep(N) #ifdef H5_HAVE_SNPRINTF # define HDsnprintf snprintf /*varargs*/ #endif /* sprintf() variable arguments */ #define HDsqrt(X) sqrt(X) #define HDsrand(N) srand(N) #ifdef WIN32 #define HDsrandom(N) srand(N) #else #define HDsrandom(N) srandom(N) #endif /* sscanf() variable arguments */ #ifdef WIN32 #ifdef __MWERKS__ #define HDstat(S,B) stat(S,B) #else /*MSVC*/ #define HDstat(S,B) _stati64(S,B) #endif #else #define HDstat(S,B) stat(S,B) #endif #define HDstrcat(X,Y) strcat(X,Y) #define HDstrchr(S,C) strchr(S,C) #define HDstrcmp(X,Y) strcmp(X,Y) #define HDstrcoll(X,Y) strcoll(X,Y) #define HDstrcpy(X,Y) strcpy(X,Y) #define HDstrcspn(X,Y) strcspn(X,Y) #define HDstrerror(N) strerror(N) #define HDstrftime(S,Z,F,T) strftime(S,Z,F,T) #define HDstrlen(S) strlen(S) #define HDstrncat(X,Y,Z) strncat(X,Y,Z) #define HDstrncmp(X,Y,Z) strncmp(X,Y,Z) #define HDstrncpy(X,Y,Z) strncpy(X,Y,Z) #define HDstrpbrk(X,Y) strpbrk(X,Y) #define HDstrrchr(S,C) strrchr(S,C) #define HDstrspn(X,Y) strspn(X,Y) #define HDstrstr(X,Y) strstr(X,Y) #define HDstrtod(S,R) strtod(S,R) #define HDstrtok(X,Y) strtok(X,Y) #define HDstrtol(S,R,N) strtol(S,R,N) H5_DLL int64_t HDstrtoll (const char *s, const char **rest, int base); #define HDstrtoul(S,R,N) strtoul(S,R,N) #define HDstrxfrm(X,Y,Z) strxfrm(X,Y,Z) #define HDsysconf(N) sysconf(N) #define HDsystem(S) system(S) #define HDtan(X) tan(X) #define HDtanh(X) tanh(X) #define HDtcdrain(F) tcdrain(F) #define HDtcflow(F,A) tcflow(F,A) #define HDtcflush(F,N) tcflush(F,N) #define HDtcgetattr(F,T) tcgetattr(F,T) #define HDtcgetpgrp(F) tcgetpgrp(F) #define HDtcsendbreak(F,N) tcsendbreak(F,N) #define HDtcsetattr(F,O,T) tcsetattr(F,O,T) #define HDtcsetpgrp(F,N) tcsetpgrp(F,N) #define HDtime(T) time(T) #define HDtimes(T) times(T) #define HDtmpfile() tmpfile() #define HDtmpnam(S) tmpnam(S) #define HDtolower(C) tolower(C) #define HDtoupper(C) toupper(C) #define HDttyname(F) ttyname(F) #define HDtzset() tzset() #define HDumask(N) umask(N) #define HDuname(S) uname(S) #define HDungetc(C,F) ungetc(C,F) #ifdef WIN32 #define HDunlink(S) _unlink(S) #else #define HDunlink(S) unlink(S) #endif #define HDutime(S,T) utime(S,T) #define HDva_arg(A,T) va_arg(A,T) #define HDva_end(A) va_end(A) #define HDva_start(A,P) va_start(A,P) #define HDvfprintf(F,FMT,A) vfprintf(F,FMT,A) #define HDvprintf(FMT,A) vprintf(FMT,A) #define HDvsprintf(S,FMT,A) vsprintf(S,FMT,A) #ifdef H5_HAVE_VSNPRINTF # define HDvsnprintf(S,N,FMT,A) vsnprintf(S,N,FMT,A) #endif #define HDwait(W) wait(W) #define HDwaitpid(P,W,O) waitpid(P,W,O) #define HDwcstombs(S,P,Z) wcstombs(S,P,Z) #define HDwctomb(S,C) wctomb(S,C) #if defined (__MWERKS__) /* workaround for a bug in the Metrowerks version 6.0 header file for write which is not defined as const void* */ #define HDwrite(F,M,Z) write(F,(void*)M,Z) #else #define HDwrite(F,M,Z) write(F,M,Z) #endif /* * And now for a couple non-Posix functions... Watch out for systems that * define these in terms of macros. */ #ifdef WIN32 #define HDstrdup(S) _strdup(S) #else /* WIN32 */ #if !defined strdup && !defined H5_HAVE_STRDUP extern char *strdup(const char *s); #endif #define HDstrdup(S) strdup(S) #endif /* WIN32 */ #ifndef H5_HAVE_SNPRINTF H5_DLL int HDsnprintf(char *buf, size_t size, const char *fmt, ...); #endif #ifndef H5_HAVE_VSNPRINTF H5_DLL int HDvsnprintf(char *buf, size_t size, const char *fmt, va_list ap); #endif /* * These macros check whether debugging has been requested for a certain * package at run-time. Code for debugging is conditionally compiled by * defining constants like `H5X_DEBUG'. In order to see the output though * the code must be enabled at run-time with an environment variable * HDF5_DEBUG which is a list of packages to debug. * * Note: If you add/remove items from this enum then be sure to update the * information about the package in H5_init_library(). */ typedef enum { H5_PKG_A, /*Attributes */ H5_PKG_AC, /*Meta data cache */ H5_PKG_B, /*B-trees */ H5_PKG_D, /*Datasets */ H5_PKG_E, /*Error handling */ H5_PKG_F, /*Files */ H5_PKG_G, /*Groups */ H5_PKG_HG, /*Global heap */ H5_PKG_HL, /*Local heap */ H5_PKG_I, /*Interface */ H5_PKG_MF, /*File memory management */ H5_PKG_MM, /*Core memory management */ H5_PKG_O, /*Object headers */ H5_PKG_P, /*Property lists */ H5_PKG_S, /*Data spaces */ H5_PKG_T, /*Data types */ H5_PKG_V, /*Vector functions */ H5_PKG_Z, /*Raw data filters */ H5_NPKGS /*Must be last */ } H5_pkg_t; typedef struct H5_debug_t { FILE *trace; /*API trace output stream */ hbool_t ttop; /*Show only top-level calls? */ hbool_t ttimes; /*Show trace event times? */ struct { const char *name; /*package name */ FILE *stream; /*output stream or NULL */ } pkg[H5_NPKGS]; } H5_debug_t; extern H5_debug_t H5_debug_g; #define H5DEBUG(X) (H5_debug_g.pkg[H5_PKG_##X].stream) /*------------------------------------------------------------------------- * Purpose: These macros are inserted automatically just after the * FUNC_ENTER() macro of API functions and are used to trace * application program execution. Unless H5_DEBUG_API has been * defined they are no-ops. * * Arguments: R - Return type encoded as a string * T - Argument types encoded as a string * A0-An - Arguments. The number at the end of the macro name * indicates the number of arguments. * * Programmer: Robb Matzke * * Modifications: *------------------------------------------------------------------------- */ #ifdef H5_DEBUG_API #define H5TRACE_DECL const char *RTYPE=NULL; \ double CALLTIME; #define H5TRACE0(R,T) RTYPE=R; \ CALLTIME=H5_trace(NULL,FUNC,T) #define H5TRACE1(R,T,A0) RTYPE=R; \ CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0) #define H5TRACE2(R,T,A0,A1) RTYPE=R; \ CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1) #define H5TRACE3(R,T,A0,A1,A2) RTYPE=R; \ CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2) #define H5TRACE4(R,T,A0,A1,A2,A3) RTYPE=R; \ CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3) #define H5TRACE5(R,T,A0,A1,A2,A3,A4) RTYPE=R; \ CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3, \ #A4,A4) #define H5TRACE6(R,T,A0,A1,A2,A3,A4,A5) RTYPE=R; \ CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3, \ #A4,A4,#A5,A5) #define H5TRACE7(R,T,A0,A1,A2,A3,A4,A5,A6) RTYPE=R; \ CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3, \ #A4,A4,#A5,A5,#A6,A6) #define H5TRACE8(R,T,A0,A1,A2,A3,A4,A5,A6,A7) RTYPE=R; \ CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3, \ #A4,A4,#A5,A5,#A6,A6,#A7,A7) #define H5TRACE9(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8) RTYPE=R; \ CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3, \ #A4,A4,#A5,A5,#A6,A6,#A7,A7,#A8,A8) #define H5TRACE10(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8,A9) RTYPE=R; \ CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3, \ #A4,A4,#A5,A5,#A6,A6,#A7,A7,#A8,A8,#A9,A9) #define H5TRACE11(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10) RTYPE=R; \ CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3, \ #A4,A4,#A5,A5,#A6,A6,#A7,A7,#A8,A8,#A9,A9, \ #A10,A10) #define H5TRACE_RETURN(V) if (RTYPE) { \ H5_trace(&CALLTIME,FUNC,RTYPE,NULL,V); \ RTYPE=NULL; \ } #else #define H5TRACE_DECL /*void*/ #define H5TRACE0(R,T) /*void*/ #define H5TRACE1(R,T,A0) /*void*/ #define H5TRACE2(R,T,A0,A1) /*void*/ #define H5TRACE3(R,T,A0,A1,A2) /*void*/ #define H5TRACE4(R,T,A0,A1,A2,A3) /*void*/ #define H5TRACE5(R,T,A0,A1,A2,A3,A4) /*void*/ #define H5TRACE6(R,T,A0,A1,A2,A3,A4,A5) /*void*/ #define H5TRACE7(R,T,A0,A1,A2,A3,A4,A5,A6) /*void*/ #define H5TRACE8(R,T,A0,A1,A2,A3,A4,A5,A6,A7) /*void*/ #define H5TRACE9(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8) /*void*/ #define H5TRACE10(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8,A9) /*void*/ #define H5TRACE11(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10) /*void*/ #define H5TRACE_RETURN(V) /*void*/ #endif H5_DLL double H5_trace(const double *calltime, const char *func, const char *type, ...); /*------------------------------------------------------------------------- * Purpose: Register function entry for library initialization and code * profiling. * * Notes: Every file must have a file-scope variable called * `initialize_interface_g' of type hbool_t which is initialized * to FALSE. * * Don't use local variable initializers which contain * calls to other library functions since the initializer * would happen before the FUNC_ENTER() gets called. Don't * use initializers that require special cleanup code to * execute if FUNC_ENTER() fails since a failing FUNC_ENTER() * returns immediately without branching to the `done' label. * * Programmer: Quincey Koziol * * Modifications: * *------------------------------------------------------------------------- */ /* `S' is the name of a function which is being tested to check if its */ /* an API function */ #define H5_IS_API(S) ('_'!=S[2] && '_'!=S[3] && (!S[4] || '_'!=S[4])) /* global library version information string */ extern char H5_lib_vers_info_g[]; /* Lock headers */ #ifdef H5_HAVE_THREADSAFE /* Include required thread-safety header */ #include "H5TSprivate.h" /* replacement structure for original global variable */ typedef struct H5_api_struct { H5TS_mutex_t init_lock; /* API entrance mutex */ hbool_t H5_libinit_g; /* Has the library been initialized? */ } H5_api_t; /* Macros for accessing the global variables */ #define H5_INIT_GLOBAL H5_g.H5_libinit_g /* Macro for first thread initialization */ #define H5_FIRST_THREAD_INIT \ pthread_once(&H5TS_first_init_g, H5TS_first_thread_init); /* Macros for threadsafe HDF-5 Phase I locks */ #define H5_API_LOCK \ H5TS_mutex_lock(&H5_g.init_lock); #define H5_API_UNLOCK \ H5TS_mutex_unlock(&H5_g.init_lock); /* Macros for thread cancellation-safe mechanism */ #define H5_API_UNSET_CANCEL \ H5TS_cancel_count_inc(); #define H5_API_SET_CANCEL \ H5TS_cancel_count_dec(); extern H5_api_t H5_g; #else /* H5_HAVE_THREADSAFE */ /* disable any first thread init mechanism */ #define H5_FIRST_THREAD_INIT /* disable locks (sequential version) */ #define H5_API_LOCK #define H5_API_UNLOCK /* disable cancelability (sequential version) */ #define H5_API_UNSET_CANCEL #define H5_API_SET_CANCEL /* extern global variables */ extern hbool_t H5_libinit_g; /* Has the library been initialized? */ /* Macros for accessing the global variables */ #define H5_INIT_GLOBAL H5_libinit_g #endif /* H5_HAVE_THREADSAFE */ #ifdef H5_HAVE_FUNCSTACK /* Include required function stack header */ #include "H5FSprivate.h" #define H5_PUSH_FUNC(func_name) H5FS_push(#func_name) #define H5_POP_FUNC H5FS_pop() #else /* H5_HAVE_FUNCSTACK */ #define H5_PUSH_FUNC(func_name) /* void */ #define H5_POP_FUNC /* void */ #endif /* H5_HAVE_FUNCSTACK */ #ifdef H5_HAVE_MPE extern hbool_t H5_MPEinit_g; /* Has the MPE Library been initialized? */ #endif /* Check if the function name is correct (if the compiler supports __FUNCTION__) */ #ifdef H5_HAVE_FUNCTION #define H5_CHECK_FUNCNAME(func_name) \ assert(!HDstrcmp(#func_name, __FUNCTION__)) #else /* H5_HAVE_FUNCTION */ #define H5_CHECK_FUNCNAME(func_name) \ assert(func_name) #endif /* H5_HAVE_FUNCTION */ /* Macros for defining interface initialization routines */ #ifdef H5_INTERFACE_INIT_FUNC static int H5_interface_initialize_g = 0; static herr_t H5_INTERFACE_INIT_FUNC(void); #define H5_INTERFACE_INIT(err) \ /* Initialize this interface or bust */ \ if (!H5_interface_initialize_g) { \ H5_interface_initialize_g = 1; \ if (H5_INTERFACE_INIT_FUNC()<0) { \ H5_interface_initialize_g = 0; \ HGOTO_ERROR (H5E_FUNC, H5E_CANTINIT, err, \ "interface initialization failed") \ } \ } #else /* H5_INTERFACE_INIT_FUNC */ #define H5_INTERFACE_INIT(err) #endif /* H5_INTERFACE_INIT_FUNC */ #define FUNC_ENTER_COMMON_NOFUNC(func_name,asrt) \ /* Check API status */ \ assert(asrt); \ \ /* Check function name */ \ H5_CHECK_FUNCNAME(func_name); #define FUNC_ENTER_COMMON(func_name,asrt) \ static const char FUNC[]=#func_name; \ FUNC_ENTER_COMMON_NOFUNC(func_name,asrt); /* Threadsafety initialization code for API routines */ #define FUNC_ENTER_API_THREADSAFE \ /* Initialize the thread-safe code */ \ H5_FIRST_THREAD_INIT \ \ /* Grab the mutex for the library */ \ H5_API_UNSET_CANCEL \ H5_API_LOCK /* Threadsafety termination code for API routines */ #define FUNC_LEAVE_API_THREADSAFE \ H5_API_UNLOCK \ H5_API_SET_CANCEL /* Local variables for API routines */ #define FUNC_ENTER_API_VARS(func_name) \ MPE_LOG_VARS(func_name) \ H5TRACE_DECL /* Use this macro for all "normal" API functions */ #define FUNC_ENTER_API(func_name,err) {{ \ FUNC_ENTER_API_VARS(func_name) \ FUNC_ENTER_COMMON(func_name,H5_IS_API(#func_name)); \ FUNC_ENTER_API_THREADSAFE; \ FUNC_ENTER_API_COMMON(func_name,err); \ /* Clear thread error stack entering public functions */ \ H5E_clear(); \ { /* * Use this macro for API functions that shouldn't clear the error stack * like H5Eprint and H5Ewalk. */ #define FUNC_ENTER_API_NOCLEAR(func_name,err) {{ \ FUNC_ENTER_API_VARS(func_name) \ FUNC_ENTER_COMMON(func_name,H5_IS_API(#func_name)); \ FUNC_ENTER_API_THREADSAFE; \ FUNC_ENTER_API_COMMON(func_name,err); \ { /* * Use this macro for API functions that shouldn't perform _any_ initialization * of the library or an interface, just perform tracing, etc. Examples * are: H5close, H5check_version, H5Eget_major, H5Eget_minor. * */ #define FUNC_ENTER_API_NOINIT(func_name) {{ \ FUNC_ENTER_API_VARS(func_name) \ FUNC_ENTER_COMMON(func_name,H5_IS_API(#func_name)); \ FUNC_ENTER_API_THREADSAFE; \ H5_PUSH_FUNC(func_name); \ BEGIN_MPE_LOG(func_name); \ { /* Use this macro for all "normal" non-API functions */ #define FUNC_ENTER_NOAPI(func_name,err) { \ FUNC_ENTER_COMMON(func_name,!H5_IS_API(#func_name)); \ FUNC_ENTER_NOAPI_INIT(func_name,err) \ { /* Use this macro for all non-API functions which don't issue errors */ #define FUNC_ENTER_NOAPI_NOFUNC(func_name) { \ FUNC_ENTER_COMMON_NOFUNC(func_name,!H5_IS_API(#func_name)); \ FUNC_ENTER_NOAPI_INIT(func_name,err) \ { /* * Use this macro for non-API functions which fall into these categories: * - static functions, since they must be called from a function in the * interface, the library and interface must already be * initialized. * - functions which are called during library shutdown, since we don't * want to re-initialize the library. */ #define FUNC_ENTER_NOAPI_NOINIT(func_name) { \ FUNC_ENTER_COMMON(func_name,!H5_IS_API(#func_name)); \ H5_PUSH_FUNC(func_name); \ { /* * Use this macro for non-API functions which fall into these categories: * - static functions, since they must be called from a function in the * interface, the library and interface must already be * initialized. * - functions which are called during library shutdown, since we don't * want to re-initialize the library. * * This macro is used for functions which fit the above categories _and_ * also don't use the 'FUNC' variable (i.e. don't push errors on the error stack) * */ #define FUNC_ENTER_NOAPI_NOINIT_NOFUNC(func_name) { \ FUNC_ENTER_COMMON_NOFUNC(func_name,!H5_IS_API(#func_name)); \ H5_PUSH_FUNC(func_name); \ { /* * Use this macro for non-API functions which fall into these categories: * - functions which shouldn't push their name on the function stack * (so far, just the H5FS routines themselves) * * This macro is used for functions which fit the above categories _and_ * also don't use the 'FUNC' variable (i.e. don't push errors on the error stack) * */ #define FUNC_ENTER_NOAPI_NOFUNC_NOFS(func_name) { \ FUNC_ENTER_COMMON_NOFUNC(func_name,!H5_IS_API(#func_name)); \ { #define FUNC_ENTER_API_COMMON(func_name,err) \ /* Initialize the library */ \ if (!(H5_INIT_GLOBAL)) { \ H5_INIT_GLOBAL = TRUE; \ if (H5_init_library()<0) \ HGOTO_ERROR (H5E_FUNC, H5E_CANTINIT, err, \ "library initialization failed") \ } \ \ /* Initialize the interface, if appropriate */ \ H5_INTERFACE_INIT(err) \ \ /* Push the name of this function on the function stack */ \ H5_PUSH_FUNC(func_name); \ \ BEGIN_MPE_LOG(func_name) #define FUNC_ENTER_NOAPI_INIT(func_name,err) \ /* Initialize the interface, if appropriate */ \ H5_INTERFACE_INIT(err) \ \ /* Push the name of this function on the function stack */ \ H5_PUSH_FUNC(func_name); /*------------------------------------------------------------------------- * Purpose: Register function exit for code profiling. This should be * the last statement executed by a function. * * Programmer: Quincey Koziol * * Modifications: * * Robb Matzke, 4 Aug 1997 * The pablo mask comes from the constant PABLO_MASK defined on a * per-file basis. The pablo_func_id comes from an auto variable * defined by FUNC_ENTER. * PABLO was removed on January 20, 2005 EIP * *------------------------------------------------------------------------- */ #define FUNC_LEAVE_API(ret_value) \ FINISH_MPE_LOG; \ H5TRACE_RETURN(ret_value); \ H5_POP_FUNC; \ FUNC_LEAVE_API_THREADSAFE \ return (ret_value); \ } /*end scope from end of FUNC_ENTER*/ \ }} /*end scope from beginning of FUNC_ENTER*/ #define FUNC_LEAVE_NOAPI(ret_value) \ H5_POP_FUNC; \ return (ret_value); \ } /*end scope from end of FUNC_ENTER*/ \ } /*end scope from beginning of FUNC_ENTER*/ #define FUNC_LEAVE_NOAPI_VOID \ H5_POP_FUNC; \ return; \ } /*end scope from end of FUNC_ENTER*/ \ } /*end scope from beginning of FUNC_ENTER*/ /* * Use this macro for non-API functions which fall into these categories: * - functions which didn't push their name on the function stack * (so far, just the H5FS routines themselves) */ #define FUNC_LEAVE_NOAPI_NOFS(ret_value) \ return (ret_value); \ } /*end scope from end of FUNC_ENTER*/ \ } /*end scope from beginning of FUNC_ENTER*/ /* Macro for "glueing" together items, for re-scanning macros */ #define H5_GLUE(x,y) x##y #define H5_GLUE3(x,y,z) x##y##z /* Private functions, not part of the publicly documented API */ H5_DLL herr_t H5_init_library(void); H5_DLL void H5_term_library(void); /* Functions to terminate interfaces */ H5_DLL int H5A_term_interface(void); H5_DLL int H5AC_term_interface(void); H5_DLL int H5D_term_interface(void); H5_DLL int H5F_term_interface(void); H5_DLL int H5G_term_interface(void); H5_DLL int H5I_term_interface(void); H5_DLL int H5P_term_interface(void); H5_DLL int H5R_term_interface(void); H5_DLL int H5S_term_interface(void); H5_DLL int H5T_term_interface(void); H5_DLL int H5Z_term_interface(void); #endif xdmf-3.0+git20160803/Utilities/hdf5/H5HG.c0000640000175000017500000012350213003006557017535 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Robb Matzke * Friday, March 27, 1998 * * Purpose: Operations on the global heap. The global heap is the set of * all collections and each collection contains one or more * global heap objects. An object belongs to exactly one * collection. A collection is treated as an atomic entity for * the purposes of I/O and caching. * * Each file has a small cache of global heap collections called * the CWFS list and recently accessed collections with free * space appear on this list. As collections are accessed the * collection is moved toward the front of the list. New * collections are added to the front of the list while old * collections are added to the end of the list. * * The collection model reduces the overhead which would be * incurred if the global heap were a single object, and the * CWFS list allows the library to cheaply choose a collection * for a new object based on object size, amount of free space * in the collection, and temporal locality. */ #define H5F_PACKAGE /*suppress error about including H5Fpkg */ #define H5HG_PACKAGE /*suppress error about including H5HGpkg */ #include "H5private.h" /* Generic Functions */ #include "H5ACprivate.h" /* Metadata cache */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* File access */ #include "H5FLprivate.h" /* Free lists */ #include "H5HGpkg.h" /* Global heaps */ #include "H5MFprivate.h" /* File memory management */ #include "H5MMprivate.h" /* Memory management */ /* Private macros */ /* * Global heap collection version. */ #define H5HG_VERSION 1 /* * All global heap collections are at least this big. This allows us to read * most collections with a single read() since we don't have to read a few * bytes of header to figure out the size. If the heap is larger than this * then a second read gets the rest after we've decoded the header. */ #define H5HG_MINSIZE 4096 /* * Limit global heap collections to the some reasonable size. This is * fairly arbitrary, but needs to be small enough that no more than H5HG_MAXIDX * objects will be allocated from a single heap. */ #define H5HG_MAXSIZE 65536 /* * Maximum length of the CWFS list, the list of remembered collections that * have free space. */ #define H5HG_NCWFS 16 /* * The maximum number of links allowed to a global heap object. */ #define H5HG_MAXLINK 65535 /* * The maximum number of indices allowed in a global heap object. */ #define H5HG_MAXIDX 65535 /* * The size of the collection header, always a multiple of the alignment so * that the stuff that follows the header is aligned. */ #define H5HG_SIZEOF_HDR(f) \ H5HG_ALIGN(4 + /*magic number */ \ 1 + /*version number */ \ 3 + /*reserved */ \ H5F_SIZEOF_SIZE(f)) /*collection size */ /* * The initial guess for the number of messages in a collection. We assume * that all objects in that collection are zero length, giving the maximum * possible number of objects in the collection. The collection itself has * some overhead and each message has some overhead. The `+2' accounts for * rounding and for the free space object. */ #define H5HG_NOBJS(f,z) (int)((((z)-H5HG_SIZEOF_HDR(f))/ \ H5HG_SIZEOF_OBJHDR(f)+2)) /* * Makes a global heap object pointer undefined, or checks whether one is * defined. */ #define H5HG_undef(HGP) ((HGP)->idx=0) #define H5HG_defined(HGP) ((HGP)->idx!=0) /* Private typedefs */ /* PRIVATE PROTOTYPES */ static haddr_t H5HG_create(H5F_t *f, hid_t dxpl_id, size_t size); #ifdef NOT_YET static void *H5HG_peek(H5F_t *f, hid_t dxpl_id, H5HG_t *hobj); #endif /* NOT_YET */ /* Metadata cache callbacks */ static H5HG_heap_t *H5HG_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *udata1, void *udata2); static herr_t H5HG_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest, haddr_t addr, H5HG_heap_t *heap); static herr_t H5HG_dest(H5F_t *f, H5HG_heap_t *heap); static herr_t H5HG_clear(H5F_t *f, H5HG_heap_t *heap, hbool_t destroy); static herr_t H5HG_compute_size(const H5F_t *f, const H5HG_heap_t *heap, size_t *size_ptr); /* * H5HG inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_GHEAP[1] = {{ H5AC_GHEAP_ID, (H5AC_load_func_t)H5HG_load, (H5AC_flush_func_t)H5HG_flush, (H5AC_dest_func_t)H5HG_dest, (H5AC_clear_func_t)H5HG_clear, (H5AC_size_func_t)H5HG_compute_size, }}; /* Declare a free list to manage the H5HG_t struct */ H5FL_DEFINE_STATIC(H5HG_heap_t); /* Declare a free list to manage sequences of H5HG_obj_t's */ H5FL_SEQ_DEFINE_STATIC(H5HG_obj_t); /* Declare a PQ free list to manage heap chunks */ H5FL_BLK_DEFINE_STATIC(heap_chunk); /*------------------------------------------------------------------------- * Function: H5HG_create * * Purpose: Creates a global heap collection of the specified size. If * SIZE is less than some minimum it will be readjusted. The * new collection is allocated in the file and added to the * beginning of the CWFS list. * * Return: Success: Ptr to a cached heap. The pointer is valid * only until some other hdf5 library function * is called. * * Failure: NULL * * Programmer: Robb Matzke * Friday, March 27, 1998 * * Modifications: * * John Mainzer 5/26/04 * Modified function to return the disk address of the new * global heap collection, or HADDR_UNDEF on failure. This * is necessary, as in some cases (i.e. flexible parallel) * H5AC_set() will imediately flush and destroy the in memory * version of the new collection. For the same reason, I * moved the code which places the new collection on the cwfs * list to just before the call to H5AC_set(). * *------------------------------------------------------------------------- */ static haddr_t H5HG_create (H5F_t *f, hid_t dxpl_id, size_t size) { H5HG_heap_t *heap = NULL; haddr_t ret_value = HADDR_UNDEF; uint8_t *p = NULL; haddr_t addr; size_t n; FUNC_ENTER_NOAPI(H5HG_create, HADDR_UNDEF); /* Check args */ assert (f); if (sizeaddr = addr; heap->size = size; heap->cache_info.is_dirty = TRUE; if (NULL==(heap->chunk = H5FL_BLK_MALLOC (heap_chunk,size))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, \ "memory allocation failed"); #ifdef H5_USING_PURIFY HDmemset(heap->chunk,0,size); #endif /* H5_USING_PURIFY */ heap->nalloc = H5HG_NOBJS (f, size); heap->nused = 1; /* account for index 0, which is used for the free object */ if (NULL==(heap->obj = H5FL_SEQ_MALLOC (H5HG_obj_t,heap->nalloc))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, \ "memory allocation failed"); /* Initialize the header */ HDmemcpy (heap->chunk, H5HG_MAGIC, H5HG_SIZEOF_MAGIC); p = heap->chunk + H5HG_SIZEOF_MAGIC; *p++ = H5HG_VERSION; *p++ = 0; /*reserved*/ *p++ = 0; /*reserved*/ *p++ = 0; /*reserved*/ H5F_ENCODE_LENGTH (f, p, size); /* * Padding so free space object is aligned. If malloc returned memory * which was always at least H5HG_ALIGNMENT aligned then we could just * align the pointer, but this might not be the case. */ n = H5HG_ALIGN(p-heap->chunk) - (p-heap->chunk); #ifdef OLD_WAY /* Don't bother zeroing out the rest of the info in the heap -QAK */ HDmemset(p, 0, n); #endif /* OLD_WAY */ p += n; /* The freespace object */ heap->obj[0].size = size - H5HG_SIZEOF_HDR(f); assert(H5HG_ISALIGNED(heap->obj[0].size)); heap->obj[0].nrefs = 0; heap->obj[0].begin = p; UINT16ENCODE(p, 0); /*object ID*/ UINT16ENCODE(p, 0); /*reference count*/ UINT32ENCODE(p, 0); /*reserved*/ H5F_ENCODE_LENGTH (f, p, heap->obj[0].size); #ifdef OLD_WAY /* Don't bother zeroing out the rest of the info in the heap -QAK */ HDmemset (p, 0, (size_t)((heap->chunk+heap->size) - p)); #endif /* OLD_WAY */ /* Add this heap to the beginning of the CWFS list */ if (NULL==f->shared->cwfs) { f->shared->cwfs = H5MM_malloc (H5HG_NCWFS * sizeof(H5HG_heap_t*)); if (NULL==(f->shared->cwfs)) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, \ "memory allocation failed"); f->shared->cwfs[0] = heap; f->shared->ncwfs = 1; } else { HDmemmove (f->shared->cwfs+1, f->shared->cwfs, MIN (f->shared->ncwfs, H5HG_NCWFS-1)*sizeof(H5HG_heap_t*)); f->shared->cwfs[0] = heap; f->shared->ncwfs = MIN (H5HG_NCWFS, f->shared->ncwfs+1); } /* Add the heap to the cache */ if (H5AC_set (f, dxpl_id, H5AC_GHEAP, addr, heap)<0) HGOTO_ERROR (H5E_HEAP, H5E_CANTINIT, HADDR_UNDEF, \ "unable to cache global heap collection"); ret_value = addr; done: if ( ! ( H5F_addr_defined(addr) ) && heap) { if ( H5HG_dest(f,heap) < 0 ) HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, HADDR_UNDEF, \ "unable to destroy global heap collection"); } FUNC_LEAVE_NOAPI(ret_value); } /* H5HG_create() */ /*------------------------------------------------------------------------- * Function: H5HG_load * * Purpose: Loads a global heap collection from disk. * * Return: Success: Ptr to a global heap collection. * * Failure: NULL * * Programmer: Robb Matzke * Friday, March 27, 1998 * * Modifications: * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. * * Quincey Koziol, 2002-7-180 * Added dxpl parameter to allow more control over I/O from metadata * cache. *------------------------------------------------------------------------- */ static H5HG_heap_t * H5HG_load (H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * udata1, void UNUSED * udata2) { H5HG_heap_t *heap = NULL; uint8_t *p = NULL; int i; size_t nalloc, need; size_t max_idx=0; /* The maximum index seen */ H5HG_heap_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(H5HG_load, NULL); /* check arguments */ assert (f); assert (H5F_addr_defined (addr)); assert (!udata1); assert (!udata2); /* Read the initial 4k page */ if (NULL==(heap = H5FL_CALLOC (H5HG_heap_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); heap->addr = addr; if (NULL==(heap->chunk = H5FL_BLK_MALLOC (heap_chunk,H5HG_MINSIZE))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); if (H5F_block_read(f, H5FD_MEM_GHEAP, addr, H5HG_MINSIZE, dxpl_id, heap->chunk)<0) HGOTO_ERROR (H5E_HEAP, H5E_READERROR, NULL, "unable to read global heap collection"); /* Magic number */ if (HDmemcmp (heap->chunk, H5HG_MAGIC, H5HG_SIZEOF_MAGIC)) HGOTO_ERROR (H5E_HEAP, H5E_CANTLOAD, NULL, "bad global heap collection signature"); p = heap->chunk + H5HG_SIZEOF_MAGIC; /* Version */ if (H5HG_VERSION!=*p++) HGOTO_ERROR (H5E_HEAP, H5E_CANTLOAD, NULL, "wrong version number in global heap"); /* Reserved */ p += 3; /* Size */ H5F_DECODE_LENGTH (f, p, heap->size); assert (heap->size>=H5HG_MINSIZE); /* * If we didn't read enough in the first try, then read the rest of the * collection now. */ if (heap->size > H5HG_MINSIZE) { haddr_t next_addr = addr + (hsize_t)H5HG_MINSIZE; if (NULL==(heap->chunk = H5FL_BLK_REALLOC (heap_chunk, heap->chunk, heap->size))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); if (H5F_block_read (f, H5FD_MEM_GHEAP, next_addr, (heap->size-H5HG_MINSIZE), dxpl_id, heap->chunk+H5HG_MINSIZE)<0) HGOTO_ERROR (H5E_HEAP, H5E_READERROR, NULL, "unable to read global heap collection"); } /* Decode each object */ p = heap->chunk + H5HG_SIZEOF_HDR (f); nalloc = H5HG_NOBJS (f, heap->size); if (NULL==(heap->obj = H5FL_SEQ_MALLOC (H5HG_obj_t,nalloc))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); heap->obj[0].size=heap->obj[0].nrefs=0; heap->obj[0].begin=NULL; heap->nalloc = nalloc; while (pchunk+heap->size) { if (p+H5HG_SIZEOF_OBJHDR(f)>heap->chunk+heap->size) { /* * The last bit of space is too tiny for an object header, so we * assume that it's free space. */ assert (NULL==heap->obj[0].begin); heap->obj[0].size = (heap->chunk+heap->size) - p; heap->obj[0].begin = p; p += heap->obj[0].size; } else { unsigned idx; uint8_t *begin = p; UINT16DECODE (p, idx); /* Check if we need more room to store heap objects */ if(idx>=heap->nalloc) { size_t new_alloc; /* New allocation number */ H5HG_obj_t *new_obj; /* New array of object descriptions */ /* Determine the new number of objects to index */ new_alloc=MAX(heap->nalloc*2,(idx+1)); /* Reallocate array of objects */ if (NULL==(new_obj = H5FL_SEQ_REALLOC (H5HG_obj_t, heap->obj, new_alloc))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); /* Update heap information */ heap->nalloc=new_alloc; heap->obj=new_obj; } /* end if */ UINT16DECODE (p, heap->obj[idx].nrefs); p += 4; /*reserved*/ H5F_DECODE_LENGTH (f, p, heap->obj[idx].size); heap->obj[idx].begin = begin; /* * The total storage size includes the size of the object header * and is zero padded so the next object header is properly * aligned. The last bit of space is the free space object whose * size is never padded and already includes the object header. */ if (idx>0) { need = H5HG_SIZEOF_OBJHDR(f) + H5HG_ALIGN(heap->obj[idx].size); /* Check for "gap" in index numbers (caused by deletions) and fill in heap object values */ if(idx>(max_idx+1)) HDmemset(&heap->obj[max_idx+1],0,sizeof(H5HG_obj_t)*(idx-(max_idx+1))); max_idx=idx; } else { need = heap->obj[idx].size; } p = begin + need; } } assert(p==heap->chunk+heap->size); assert(H5HG_ISALIGNED(heap->obj[0].size)); /* Set the next index value to use */ if(max_idx>0) heap->nused=max_idx+1; else heap->nused=1; /* * Add the new heap to the CWFS list, removing some other entry if * necessary to make room. We remove the right-most entry that has less * free space than this heap. */ if (heap->obj[0].size>0) { if (!f->shared->cwfs) { f->shared->cwfs = H5MM_malloc (H5HG_NCWFS*sizeof(H5HG_heap_t*)); if (NULL==f->shared->cwfs) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); f->shared->ncwfs = 1; f->shared->cwfs[0] = heap; } else if (H5HG_NCWFS==f->shared->ncwfs) { for (i=H5HG_NCWFS-1; i>=0; --i) { if (f->shared->cwfs[i]->obj[0].size < heap->obj[0].size) { HDmemmove (f->shared->cwfs+1, f->shared->cwfs, i * sizeof(H5HG_heap_t*)); f->shared->cwfs[0] = heap; break; } } } else { HDmemmove (f->shared->cwfs+1, f->shared->cwfs, f->shared->ncwfs*sizeof(H5HG_heap_t*)); f->shared->ncwfs += 1; f->shared->cwfs[0] = heap; } } ret_value = heap; done: if (!ret_value && heap) { if(H5HG_dest(f,heap)<0) HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, NULL, "unable to destroy global heap collection"); } FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5HG_flush * * Purpose: Flushes a global heap collection from memory to disk if it's * dirty. Optionally deletes teh heap from memory. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Friday, March 27, 1998 * * Modifications: * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. * * Quincey Koziol, 2002-7-180 * Added dxpl parameter to allow more control over I/O from metadata * cache. *------------------------------------------------------------------------- */ static herr_t H5HG_flush (H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5HG_heap_t *heap) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5HG_flush, FAIL); /* Check arguments */ assert (f); assert (H5F_addr_defined (addr)); assert (H5F_addr_eq (addr, heap->addr)); assert (heap); if (heap->cache_info.is_dirty) { if (H5F_block_write (f, H5FD_MEM_GHEAP, addr, heap->size, dxpl_id, heap->chunk)<0) HGOTO_ERROR (H5E_HEAP, H5E_WRITEERROR, FAIL, "unable to write global heap collection to file"); heap->cache_info.is_dirty = FALSE; } if (destroy) { if(H5HG_dest(f,heap)<0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy global heap collection"); } done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5HG_dest * * Purpose: Destroys a global heap collection in memory * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Wednesday, January 15, 2003 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5HG_dest (H5F_t *f, H5HG_heap_t *heap) { int i; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HG_dest); /* Check arguments */ assert (heap); /* Verify that node is clean */ assert (heap->cache_info.is_dirty==FALSE); for (i=0; ishared->ncwfs; i++) { if (f->shared->cwfs[i]==heap) { f->shared->ncwfs -= 1; HDmemmove (f->shared->cwfs+i, f->shared->cwfs+i+1, (f->shared->ncwfs-i) * sizeof(H5HG_heap_t*)); break; } } heap->chunk = H5FL_BLK_FREE(heap_chunk,heap->chunk); heap->obj = H5FL_SEQ_FREE(H5HG_obj_t,heap->obj); H5FL_FREE (H5HG_heap_t,heap); FUNC_LEAVE_NOAPI(SUCCEED); } /* H5HG_dest() */ /*------------------------------------------------------------------------- * Function: H5HG_clear * * Purpose: Mark a global heap in memory as non-dirty. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Thursday, March 20, 2003 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5HG_clear(H5F_t *f, H5HG_heap_t *heap, hbool_t destroy) { herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT(H5HG_clear); /* Check arguments */ assert (heap); /* Mark heap as clean */ heap->cache_info.is_dirty = FALSE; if (destroy) if (H5HG_dest(f, heap) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy global heap collection"); done: FUNC_LEAVE_NOAPI(ret_value); } /* H5HG_clear() */ /*------------------------------------------------------------------------- * Function: H5HG_compute_size * * Purpose: Compute the size in bytes of the specified instance of * H5HG_heap_t on disk, and return it in *len_ptr. On failure, * the value of *len_ptr is undefined. * * Return: Non-negative on success/Negative on failure * * Programmer: John Mainzer * 5/13/04 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5HG_compute_size(const H5F_t UNUSED *f, const H5HG_heap_t *heap, size_t *size_ptr) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HG_compute_size); /* Check arguments */ HDassert(heap); HDassert(size_ptr); *size_ptr = heap->size; FUNC_LEAVE_NOAPI(SUCCEED); } /* H5HG_compute_size() */ /*------------------------------------------------------------------------- * Function: H5HG_alloc * * Purpose: Given a heap with enough free space, this function will split * the free space to make a new empty heap object and initialize * the header. SIZE is the exact size of the object data to be * stored. It will be increased to make room for the object * header and then rounded up for alignment. * * Return: Success: The heap object ID of the new object. * * Failure: 0 * * Programmer: Robb Matzke * Friday, March 27, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static size_t H5HG_alloc (H5F_t *f, H5HG_heap_t *heap, size_t size) { size_t idx; uint8_t *p = NULL; size_t need = H5HG_SIZEOF_OBJHDR(f) + H5HG_ALIGN(size); size_t ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5HG_alloc); /* Check args */ assert (heap); assert (heap->obj[0].size>=need); /* * Find an ID for the new object. ID zero is reserved for the free space * object. */ if(heap->nusednused++; else { for (idx=1; idxnused; idx++) if (NULL==heap->obj[idx].begin) break; } /* end else */ /* Check if we need more room to store heap objects */ if(idx>=heap->nalloc) { size_t new_alloc; /* New allocation number */ H5HG_obj_t *new_obj; /* New array of object descriptions */ /* Determine the new number of objects to index */ new_alloc=MAX(heap->nalloc*2,(idx+1)); assert(new_alloc<=(H5HG_MAXIDX+1)); /* Reallocate array of objects */ if (NULL==(new_obj = H5FL_SEQ_REALLOC (H5HG_obj_t, heap->obj, new_alloc))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed"); /* Update heap information */ heap->nalloc=new_alloc; heap->obj=new_obj; assert(heap->nalloc>heap->nused); } /* end if */ /* Initialize the new object */ heap->obj[idx].nrefs = 0; heap->obj[idx].size = size; heap->obj[idx].begin = heap->obj[0].begin; p = heap->obj[idx].begin; UINT16ENCODE(p, idx); UINT16ENCODE(p, 0); /*nrefs*/ UINT32ENCODE(p, 0); /*reserved*/ H5F_ENCODE_LENGTH (f, p, size); /* Fix the free space object */ if (need==heap->obj[0].size) { /* * All free space has been exhausted from this collection. */ heap->obj[0].size = 0; heap->obj[0].begin = NULL; } else if (heap->obj[0].size-need >= H5HG_SIZEOF_OBJHDR (f)) { /* * Some free space remains and it's larger than a heap object header, * so write the new free heap object header to the heap. */ heap->obj[0].size -= need; heap->obj[0].begin += need; p = heap->obj[0].begin; UINT16ENCODE(p, 0); /*id*/ UINT16ENCODE(p, 0); /*nrefs*/ UINT32ENCODE(p, 0); /*reserved*/ H5F_ENCODE_LENGTH (f, p, heap->obj[0].size); assert(H5HG_ISALIGNED(heap->obj[0].size)); } else { /* * Some free space remains but it's smaller than a heap object header, * so we don't write the header. */ heap->obj[0].size -= need; heap->obj[0].begin += need; assert(H5HG_ISALIGNED(heap->obj[0].size)); } /* Mark the heap as dirty */ heap->cache_info.is_dirty = TRUE; /* Set the return value */ ret_value=idx; done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5HG_extend * * Purpose: Extend a heap to hold an object of SIZE bytes. * SIZE is the exact size of the object data to be * stored. It will be increased to make room for the object * header and then rounded up for alignment. * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Quincey Koziol * Saturday, June 12, 2004 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5HG_extend (H5F_t *f, H5HG_heap_t *heap, size_t size) { size_t need; /* Actual space needed to store object */ size_t old_size; /* Previous size of the heap's chunk */ uint8_t *new_chunk=NULL; /* Pointer to new chunk information */ uint8_t *p = NULL; /* Pointer to raw heap info */ unsigned u; /* Local index variable */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5HG_extend); /* Check args */ assert (f); assert (heap); /* Compute total space need to add to this heap */ need = H5HG_SIZEOF_OBJHDR(f) + H5HG_ALIGN(size); /* Decrement the amount needed in the heap by the amount of free space available */ assert(need>heap->obj[0].size); need -= heap->obj[0].size; /* Don't do anything less than double the size of the heap */ need = MAX(heap->size,need); /* Extend the space allocated for this heap on disk */ if(H5MF_extend(f,H5FD_MEM_GHEAP,heap->addr,(hsize_t)heap->size,(hsize_t)need)<0) HGOTO_ERROR (H5E_HEAP, H5E_NOSPACE, FAIL, "can't extend heap on disk"); /* Re-allocate the heap information in memory */ if (NULL==(new_chunk = H5FL_BLK_REALLOC (heap_chunk, heap->chunk, heap->size+need))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "new heap allocation failed"); #ifdef H5_USING_PURIFY HDmemset(new_chunk+heap->size,0,need); #endif /* H5_USING_PURIFY */ /* Adjust the size of the heap */ old_size=heap->size; heap->size+=need; /* Encode the new size of the heap */ p = new_chunk + H5HG_SIZEOF_MAGIC + 1 /* version */ + 3 /* reserved */; H5F_ENCODE_LENGTH (f, p, heap->size); /* Move the pointers to the existing objects to their new locations */ for (u=0; unused; u++) if(heap->obj[u].begin) heap->obj[u].begin = new_chunk + (heap->obj[u].begin - heap->chunk); /* Update the heap chunk pointer now */ heap->chunk=new_chunk; /* Update the free space information for the heap */ heap->obj[0].size+=need; if(heap->obj[0].begin==NULL) heap->obj[0].begin=heap->chunk+old_size; p = heap->obj[0].begin; UINT16ENCODE(p, 0); /*id*/ UINT16ENCODE(p, 0); /*nrefs*/ UINT32ENCODE(p, 0); /*reserved*/ H5F_ENCODE_LENGTH (f, p, heap->obj[0].size); assert(H5HG_ISALIGNED(heap->obj[0].size)); /* Mark the heap as dirty */ heap->cache_info.is_dirty = TRUE; done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5HG_extend() */ /*------------------------------------------------------------------------- * Function: H5HG_insert * * Purpose: A new object is inserted into the global heap. It will be * placed in the first collection on the CWFS list which has * enough free space and that collection will be advanced one * position in the list. If no collection on the CWFS list has * enough space then a new collection will be created. * * It is legal to push a zero-byte object onto the heap to get * the reference count features of heap objects. * * Return: Success: Non-negative, and a heap object handle returned * through the HOBJ pointer. * * Failure: Negative * * Programmer: Robb Matzke * Friday, March 27, 1998 * * Modifications: * * John Mainzer -- 5/24/04 * The function used to modify the heap without protecting * the relevant collection first. I did a half assed job * of fixing the problem, which should hold until we try to * support multi-threading. At that point it will have to * be done right. * * See in line comment of this date for more details. * * John Mainzer - 5/26/04 * Modified H5HG_create() to return the disk address of the * new collection, instead of the address of its * representation in core. This was necessary as in FP * mode, the cache will immediately flush and destroy any * entry inserted in it via H5AC_set(). I then modified * this function to account for the change in H5HG_create(). * *------------------------------------------------------------------------- */ herr_t H5HG_insert (H5F_t *f, hid_t dxpl_id, size_t size, void *obj, H5HG_t *hobj/*out*/) { size_t need; /*total space needed for object */ int cwfsno; size_t idx; haddr_t addr = HADDR_UNDEF; H5HG_heap_t *heap = NULL; hbool_t found=0; /* Flag to indicate a heap with enough space was found */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5HG_insert, FAIL); /* Check args */ assert (f); assert (0==size || obj); assert (hobj); if (0==(f->intent & H5F_ACC_RDWR)) HGOTO_ERROR (H5E_HEAP, H5E_WRITEERROR, FAIL, "no write intent on file"); /* Find a large enough collection on the CWFS list */ need = H5HG_SIZEOF_OBJHDR(f) + H5HG_ALIGN(size); /* Note that we don't have metadata cache locks on the entries in * f->shared->cwfs. * * In the current situation, this doesn't matter, as we are single * threaded, and as best I can tell, entries are added to and deleted * from f->shared->cwfs as they are added to and deleted from the * metadata cache. * * To be proper, we should either lock each entry in f->shared->cwfs * as we examine it, or lock the whole array. However, at present * I don't see the point as there will be significant overhead, * and protecting and unprotecting all the collections in the global * heap on a regular basis will skew the replacement policy. * * However, there is a bigger issue -- as best I can tell, we only look * for free space in global heap chunks that are in cache. If we can't * find any, we allocate a new chunk. This may be a problem in FP mode, * as the metadata cache is disabled. Do we allocate a new heap * collection for every entry in this case? * * Note that all this comes from a cursory read of the source. Don't * take any of it as gospel. * JRM - 5/24/04 */ for (cwfsno=0; cwfsnoshared->ncwfs; cwfsno++) { if (f->shared->cwfs[cwfsno]->obj[0].size>=need) { addr = f->shared->cwfs[cwfsno]->addr; found=1; break; } /* end if */ } /* end for */ /* * If we didn't find any collection with enough free space the check if * we can extend any of the collections to make enough room. */ if (!found) { size_t new_need; for (cwfsno=0; cwfsnoshared->ncwfs; cwfsno++) { new_need = need; new_need -= f->shared->cwfs[cwfsno]->obj[0].size; new_need = MAX(f->shared->cwfs[cwfsno]->size, new_need); if((f->shared->cwfs[cwfsno]->size+new_need)<=H5HG_MAXSIZE && H5MF_can_extend(f,H5FD_MEM_GHEAP,f->shared->cwfs[cwfsno]->addr,(hsize_t)f->shared->cwfs[cwfsno]->size,(hsize_t)new_need)) { if(H5HG_extend(f,f->shared->cwfs[cwfsno],size)<0) HGOTO_ERROR (H5E_HEAP, H5E_CANTINIT, FAIL, "unable to extend global heap collection"); addr = f->shared->cwfs[cwfsno]->addr; found=1; break; } /* end if */ } /* end for */ } /* end if */ /* * If we didn't find any collection with enough free space then allocate a * new collection large enough for the message plus the collection header. */ if (!found) { addr = H5HG_create(f, dxpl_id, need+H5HG_SIZEOF_HDR (f)); if ( ! H5F_addr_defined(addr) ) HGOTO_ERROR (H5E_HEAP, H5E_CANTINIT, FAIL, \ "unable to allocate a global heap collection"); cwfsno = 0; } /* end if */ else { /* Move the collection forward in the CWFS list, if it's not * already at the front */ if (cwfsno>0) { H5HG_heap_t *tmp = f->shared->cwfs[cwfsno]; f->shared->cwfs[cwfsno] = f->shared->cwfs[cwfsno-1]; f->shared->cwfs[cwfsno-1] = tmp; --cwfsno; } /* end if */ } /* end else */ HDassert(H5F_addr_defined(addr)); if ( NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_GHEAP, addr, NULL, NULL, H5AC_WRITE)) ) HGOTO_ERROR (H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap"); /* Split the free space to make room for the new object */ idx = H5HG_alloc (f, heap, size); /* Copy data into the heap */ if(size>0) { HDmemcpy(heap->obj[idx].begin+H5HG_SIZEOF_OBJHDR(f), obj, size); #ifdef OLD_WAY /* Don't bother zeroing out the rest of the info in the heap -QAK */ HDmemset(heap->obj[idx].begin+H5HG_SIZEOF_OBJHDR(f)+size, 0, need-(H5HG_SIZEOF_OBJHDR(f)+size)); #endif /* OLD_WAY */ } /* end if */ heap->cache_info.is_dirty = TRUE; /* Return value */ hobj->addr = heap->addr; hobj->idx = idx; done: if ( heap && H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, heap->addr, heap, FALSE) < 0 ) HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to unprotect heap."); FUNC_LEAVE_NOAPI(ret_value); } /* H5HG_insert() */ /*------------------------------------------------------------------------- * Function: H5HG_read * * Purpose: Reads the specified global heap object into the buffer OBJECT * supplied by the caller. If the caller doesn't supply a * buffer then one will be allocated. The buffer should be * large enough to hold the result. * * Return: Success: The buffer containing the result. * * Failure: NULL * * Programmer: Robb Matzke * Monday, March 30, 1998 * * Modifications: * *------------------------------------------------------------------------- */ void * H5HG_read (H5F_t *f, hid_t dxpl_id, H5HG_t *hobj, void *object/*out*/) { H5HG_heap_t *heap = NULL; int i; size_t size; uint8_t *p = NULL; void *ret_value; FUNC_ENTER_NOAPI(H5HG_read, NULL); /* Check args */ assert (f); assert (hobj); /* Load the heap */ if (NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_GHEAP, hobj->addr, NULL, NULL, H5AC_READ))) HGOTO_ERROR (H5E_HEAP, H5E_CANTLOAD, NULL, "unable to load heap"); assert (hobj->idxnused); assert (heap->obj[hobj->idx].begin); size = heap->obj[hobj->idx].size; p = heap->obj[hobj->idx].begin + H5HG_SIZEOF_OBJHDR (f); if (!object && NULL==(object = H5MM_malloc (size))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); HDmemcpy (object, p, size); /* * Advance the heap in the CWFS list. We might have done this already * with the H5AC_protect(), but it won't hurt to do it twice. */ if (heap->obj[0].begin) { for (i=0; ishared->ncwfs; i++) { if (f->shared->cwfs[i]==heap) { if (i) { f->shared->cwfs[i] = f->shared->cwfs[i-1]; f->shared->cwfs[i-1] = heap; } break; } } } /* Set return value */ ret_value=object; done: if (heap && H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, hobj->addr, heap, FALSE)<0) HDONE_ERROR(H5E_HEAP, H5E_PROTECT, NULL, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5HG_link * * Purpose: Adjusts the link count for a global heap object by adding * ADJUST to the current value. This function will fail if the * new link count would overflow. Nothing special happens when * the link count reaches zero; in order for a heap object to be * removed one must call H5HG_remove(). * * Return: Success: Number of links present after the adjustment. * * Failure: Negative * * Programmer: Robb Matzke * Monday, March 30, 1998 * * Modifications: * *------------------------------------------------------------------------- */ int H5HG_link (H5F_t *f, hid_t dxpl_id, const H5HG_t *hobj, int adjust) { H5HG_heap_t *heap = NULL; int ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5HG_link, FAIL); /* Check args */ assert (f); assert (hobj); if (0==(f->intent & H5F_ACC_RDWR)) HGOTO_ERROR (H5E_HEAP, H5E_WRITEERROR, FAIL, "no write intent on file"); if(adjust!=0) { /* Load the heap */ if (NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_GHEAP, hobj->addr, NULL, NULL, H5AC_WRITE))) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap"); assert (hobj->idxnused); assert (heap->obj[hobj->idx].begin); if (heap->obj[hobj->idx].nrefs+adjust<0) HGOTO_ERROR (H5E_HEAP, H5E_BADRANGE, FAIL, "new link count would be out of range"); if (heap->obj[hobj->idx].nrefs+adjust>H5HG_MAXLINK) HGOTO_ERROR (H5E_HEAP, H5E_BADVALUE, FAIL, "new link count would be out of range"); heap->obj[hobj->idx].nrefs += adjust; heap->cache_info.is_dirty = TRUE; } /* end if */ /* Set return value */ ret_value=heap->obj[hobj->idx].nrefs; done: if (heap && H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, hobj->addr, heap, FALSE)<0) HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5HG_remove * * Purpose: Removes the specified object from the global heap. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Monday, March 30, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5HG_remove (H5F_t *f, hid_t dxpl_id, H5HG_t *hobj) { uint8_t *p=NULL, *obj_start=NULL; H5HG_heap_t *heap = NULL; size_t need; int i; unsigned u; hbool_t deleted=FALSE; /* Whether the heap gets deleted */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5HG_remove, FAIL); /* Check args */ assert (f); assert (hobj); if (0==(f->intent & H5F_ACC_RDWR)) HGOTO_ERROR (H5E_HEAP, H5E_WRITEERROR, FAIL, "no write intent on file"); /* Load the heap */ if (NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_GHEAP, hobj->addr, NULL, NULL, H5AC_WRITE))) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap"); assert (hobj->idxnused); assert (heap->obj[hobj->idx].begin); obj_start = heap->obj[hobj->idx].begin; /* Include object header size */ need = H5HG_ALIGN(heap->obj[hobj->idx].size)+H5HG_SIZEOF_OBJHDR(f); /* Move the new free space to the end of the heap */ for (u=0; unused; u++) { if (heap->obj[u].begin > heap->obj[hobj->idx].begin) heap->obj[u].begin -= need; } if (NULL==heap->obj[0].begin) { heap->obj[0].begin = heap->chunk + (heap->size-need); heap->obj[0].size = need; heap->obj[0].nrefs = 0; } else { heap->obj[0].size += need; } HDmemmove (obj_start, obj_start+need, heap->size-((obj_start+need)-heap->chunk)); if (heap->obj[0].size>=H5HG_SIZEOF_OBJHDR (f)) { p = heap->obj[0].begin; UINT16ENCODE(p, 0); /*id*/ UINT16ENCODE(p, 0); /*nrefs*/ UINT32ENCODE(p, 0); /*reserved*/ H5F_ENCODE_LENGTH (f, p, heap->obj[0].size); } HDmemset (heap->obj+hobj->idx, 0, sizeof(H5HG_obj_t)); heap->cache_info.is_dirty = TRUE; if (heap->obj[0].size+H5HG_SIZEOF_HDR(f)==heap->size) { /* * The collection is empty. Remove it from the CWFS list and return it * to the file free list. */ heap->cache_info.is_dirty = FALSE; H5_CHECK_OVERFLOW(heap->size,size_t,hsize_t); H5MF_xfree(f, H5FD_MEM_GHEAP, dxpl_id, heap->addr, (hsize_t)heap->size); deleted=TRUE; /* Indicate that the object was deleted, for the unprotect call */ } else { /* * If the heap is in the CWFS list then advance it one position. The * H5AC_protect() might have done that too, but that's okay. If the * heap isn't on the CWFS list then add it to the end. */ for (i=0; ishared->ncwfs; i++) { if (f->shared->cwfs[i]==heap) { if (i) { f->shared->cwfs[i] = f->shared->cwfs[i-1]; f->shared->cwfs[i-1] = heap; } break; } } if (i>=f->shared->ncwfs) { f->shared->ncwfs = MIN (f->shared->ncwfs+1, H5HG_NCWFS); f->shared->cwfs[f->shared->ncwfs-1] = heap; } } done: if (heap && H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, hobj->addr, heap, deleted) != SUCCEED) HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value); } xdmf-3.0+git20160803/Utilities/hdf5/H5ACprivate.h0000640000175000017500000001577013003006557021131 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*------------------------------------------------------------------------- * * Created: H5ACprivate.h * Jul 9 1997 * Robb Matzke * * Purpose: Constants and typedefs available to the rest of the * library. * * Modifications: JRM - 6/4/04 * Complete re-write for a new caching algorithm * located in H5C.c * *------------------------------------------------------------------------- */ #ifndef _H5ACprivate_H #define _H5ACprivate_H #include "H5ACpublic.h" /*public prototypes */ /* Pivate headers needed by this header */ #include "H5private.h" /* Generic Functions */ #include "H5Fprivate.h" /* File access */ #include "H5Cprivate.h" /* cache */ #define H5AC_BT_ID 0 /*B-tree nodes */ #define H5AC_SNODE_ID 1 /*symbol table nodes */ #define H5AC_LHEAP_ID 2 /*local heap */ #define H5AC_GHEAP_ID 3 /*global heap */ #define H5AC_OHDR_ID 4 /*object header */ #define H5AC_NTYPES 5 /* H5AC_DUMP_STATS_ON_CLOSE should always be FALSE when * H5C_COLLECT_CACHE_STATS is FALSE. * * When H5C_COLLECT_CACHE_STATS is TRUE, H5AC_DUMP_STATS_ON_CLOSE must * be FALSE for "make check" to succeed, but may be set to TRUE at other * times for debugging purposes. * * Hence the following, somewhat odd set of #defines. */ #if H5C_COLLECT_CACHE_STATS #define H5AC_DUMP_STATS_ON_CLOSE 0 #else /* H5C_COLLECT_CACHE_STATS */ #define H5AC_DUMP_STATS_ON_CLOSE 0 #endif /* H5C_COLLECT_CACHE_STATS */ /* * Class methods pertaining to caching. Each type of cached object will * have a constant variable with permanent life-span that describes how * to cache the object. That variable will be of type H5AC_class_t and * have the following required fields... * * LOAD: Loads an object from disk to memory. The function * should allocate some data structure and return it. * * FLUSH: Writes some data structure back to disk. It would be * wise for the data structure to include dirty flags to * indicate whether it really needs to be written. This * function is also responsible for freeing memory allocated * by the LOAD method if the DEST argument is non-zero (by * calling the DEST method). * * DEST: Just frees memory allocated by the LOAD method. * * CLEAR: Just marks object as non-dirty. * * SIZE: Report the size (on disk) of the specified cache object. * Note that the space allocated on disk may not be contiguous. */ typedef H5C_load_func_t H5AC_load_func_t; typedef H5C_flush_func_t H5AC_flush_func_t; typedef H5C_dest_func_t H5AC_dest_func_t; typedef H5C_clear_func_t H5AC_clear_func_t; typedef H5C_size_func_t H5AC_size_func_t; typedef H5C_class_t H5AC_class_t; /* The H5AC_NSLOTS #define is now obsolete, as the metadata cache no longer * uses slots. However I am leaving it in for now to avoid modifying the * interface between the metadata cache and the rest of HDF. It should * be removed when we get to dealing with the size_hint parameter in * H5AC_create(). * JRM - 5/20/04 * * Old comment on H5AC_NSLOTS follows: * * A cache has a certain number of entries. Objects are mapped into a * cache entry by hashing the object's file address. Each file has its * own cache, an array of slots. */ #define H5AC_NSLOTS 10330 /* The library "likes" this number... */ typedef H5C_cache_entry_t H5AC_info_t; /*===----------------------------------------------------------------------=== * Protect Types *===----------------------------------------------------------------------=== * * These are for the wrapper functions to H5AC_protect. They specify what * type of operation you're planning on doing to the metadata. The * Flexible Parallel HDF5 locking can then act accordingly. */ typedef enum H5AC_protect_t { H5AC_WRITE, /* Protect object for writing */ H5AC_READ /* Protect object for reading */ } H5AC_protect_t; /* Typedef for metadata cache (defined in H5C.c) */ typedef H5C_t H5AC_t; /* Metadata specific properties for FAPL */ /* (Only used for parallel I/O) */ #ifdef H5_HAVE_PARALLEL /* Definitions for "block before metadata write" property */ #define H5AC_BLOCK_BEFORE_META_WRITE_NAME "H5AC_block_before_meta_write" #define H5AC_BLOCK_BEFORE_META_WRITE_SIZE sizeof(unsigned) #define H5AC_BLOCK_BEFORE_META_WRITE_DEF 0 /* Definitions for "library internal" property */ #define H5AC_LIBRARY_INTERNAL_NAME "H5AC_library_internal" #define H5AC_LIBRARY_INTERNAL_SIZE sizeof(unsigned) #define H5AC_LIBRARY_INTERNAL_DEF 0 #endif /* H5_HAVE_PARALLEL */ /* Dataset transfer property list for flush calls */ /* (Collective set, "block before metadata write" set and "library internal" set) */ /* (Global variable declaration, definition is in H5AC.c) */ extern hid_t H5AC_dxpl_id; /* Dataset transfer property list for independent metadata I/O calls */ /* (just "library internal" set - i.e. independent transfer mode) */ /* (Global variable declaration, definition is in H5AC.c) */ extern hid_t H5AC_ind_dxpl_id; /* * Library prototypes. */ H5_DLL herr_t H5AC_init(void); H5_DLL herr_t H5AC_create(const H5F_t *f, int size_hint); H5_DLL herr_t H5AC_set(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, void *thing); H5_DLL void *H5AC_protect(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, const void *udata1, void *udata2, H5AC_protect_t rw); H5_DLL herr_t H5AC_unprotect(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, void *thing, hbool_t deleted); H5_DLL herr_t H5AC_flush(H5F_t *f, hid_t dxpl_id, unsigned flags); H5_DLL herr_t H5AC_rename(H5F_t *f, const H5AC_class_t *type, haddr_t old_addr, haddr_t new_addr); H5_DLL herr_t H5AC_dest(H5F_t *f, hid_t dxpl_id); H5_DLL herr_t H5AC_stats(const H5F_t *f); #endif /* !_H5ACprivate_H */ xdmf-3.0+git20160803/Utilities/hdf5/H5Opkg.h0000640000175000017500000001612513003006557020146 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #ifndef H5O_PACKAGE #error "Do not include this file outside the H5O package!" #endif #ifndef _H5Opkg_H #define _H5Opkg_H /* Include private header file */ #include "H5Oprivate.h" /* Object header functions */ /* * Align messages on 8-byte boundaries because we would like to copy the * object header chunks directly into memory and operate on them there, even * on 64-bit architectures. This allows us to reduce the number of disk I/O * requests with a minimum amount of mem-to-mem copies. */ #define H5O_ALIGN(X) (8*(((X)+8-1)/8)) /* Object header macros */ #define H5O_NMESGS 32 /*initial number of messages */ #define H5O_NCHUNKS 8 /*initial number of chunks */ /* Version of object header structure */ #define H5O_VERSION 1 /* * Size of object header header. */ #define H5O_SIZEOF_HDR(F) \ H5O_ALIGN(1 + /*version number */ \ 1 + /*alignment */ \ 2 + /*number of messages */ \ 4 + /*reference count */ \ 4) /*header data size */ /* * Size of message header */ #define H5O_SIZEOF_MSGHDR(F) \ H5O_ALIGN(2 + /*message type */ \ 2 + /*sizeof message data */ \ 4) /*reserved */ typedef struct H5O_class_t { int id; /*message type ID on disk */ const char *name; /*for debugging */ size_t native_size; /*size of native message */ void *(*decode)(H5F_t*, hid_t, const uint8_t*, struct H5O_shared_t*); herr_t (*encode)(H5F_t*, uint8_t*, const void*); void *(*copy)(const void*, void*, unsigned); /*copy native value */ size_t (*raw_size)(const H5F_t*, const void*);/*sizeof raw val */ herr_t (*reset)(void *); /*free nested data structs */ herr_t (*free)(void *); /*free main data struct */ herr_t (*del)(H5F_t *, hid_t, const void *, hbool_t); /* Delete space in file referenced by this message */ herr_t (*link)(H5F_t *, hid_t, const void *); /* Increment any links in file reference by this message */ herr_t (*get_share)(H5F_t*, const void*, struct H5O_shared_t*); /* Get shared information */ herr_t (*set_share)(H5F_t*, void*, const struct H5O_shared_t*); /* Set shared information */ herr_t (*debug)(H5F_t*, hid_t, const void*, FILE*, int, int); } H5O_class_t; typedef struct H5O_mesg_t { const H5O_class_t *type; /*type of message */ hbool_t dirty; /*raw out of date wrt native */ uint8_t flags; /*message flags */ unsigned chunkno; /*chunk number for this mesg */ void *native; /*native format message */ uint8_t *raw; /*ptr to raw data */ size_t raw_size; /*size with alignment */ } H5O_mesg_t; typedef struct H5O_chunk_t { hbool_t dirty; /*dirty flag */ haddr_t addr; /*chunk file address */ size_t size; /*chunk size */ uint8_t *image; /*image of file */ } H5O_chunk_t; typedef struct H5O_t { H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */ /* first field in structure */ int version; /*version number */ int nlink; /*link count */ unsigned nmesgs; /*number of messages */ unsigned alloc_nmesgs; /*number of message slots */ H5O_mesg_t *mesg; /*array of messages */ unsigned nchunks; /*number of chunks */ unsigned alloc_nchunks; /*chunks allocated */ H5O_chunk_t *chunk; /*array of chunks */ } H5O_t; /* * Null Message. (0x0000) */ H5_DLLVAR const H5O_class_t H5O_NULL[1]; /* * Simple Dataspace Message. (0x0001) */ H5_DLLVAR const H5O_class_t H5O_SDSPACE[1]; /* * Datatype Message. (0x0003) */ H5_DLLVAR const H5O_class_t H5O_DTYPE[1]; /* * Old Fill Value Message. (0x0004) */ H5_DLLVAR const H5O_class_t H5O_FILL[1]; /* * New Fill Value Message. (0x0005) * * The new fill value message is fill value plus * space allocation time and fill value writing time and whether fill * value is defined. */ H5_DLLVAR const H5O_class_t H5O_FILL_NEW[1]; /* * External File List Message. (0x0007) */ H5_DLLVAR const H5O_class_t H5O_EFL[1]; /* * Data Layout Message. (0x0008) */ H5_DLLVAR const H5O_class_t H5O_LAYOUT[1]; #ifdef H5O_ENABLE_BOGUS /* * "Bogus" Message. (0x0009) */ H5_DLLVAR const H5O_class_t H5O_BOGUS[1]; #endif /* H5O_ENABLE_BOGUS */ /* * Filter pipeline message. (0x000b) */ H5_DLLVAR const H5O_class_t H5O_PLINE[1]; /* * Attribute Message. (0x000c) */ H5_DLLVAR const H5O_class_t H5O_ATTR[1]; /* * Object name message. (0x000d) */ H5_DLLVAR const H5O_class_t H5O_NAME[1]; /* * Modification Time Message. (0x000e) * * The message is just a `time_t'. * (See also the "new" modification time message) */ H5_DLLVAR const H5O_class_t H5O_MTIME[1]; /* * Shared Object Message. (0x000f) * * This message ID never really appears in an object * header. Instead, bit 2 of the `Flags' field will be set and the ID field * will be the ID of the pointed-to message. */ H5_DLLVAR const H5O_class_t H5O_SHARED[1]; /* * Object Header Continuation Message. (0x0010) */ H5_DLLVAR const H5O_class_t H5O_CONT[1]; /* * Symbol Table Message. (0x0011) */ H5_DLLVAR const H5O_class_t H5O_STAB[1]; /* * New Modification Time Message. (0x0012) * * The message is just a `time_t'. */ H5_DLLVAR const H5O_class_t H5O_MTIME_NEW[1]; /* Package-local function prototypes */ H5_DLL void * H5O_read_real(const H5G_entry_t *ent, const H5O_class_t *type, int sequence, void *mesg, hid_t dxpl_id); H5_DLL void * H5O_free_real(const H5O_class_t *type, void *mesg); /* Shared object operators */ H5_DLL void * H5O_shared_read(H5F_t *f, hid_t dxpl_id, H5O_shared_t *shared, const H5O_class_t *type, void *mesg); /* Symbol table operators */ H5_DLL void *H5O_stab_fast(const H5G_cache_t *cache, const struct H5O_class_t *type, void *_mesg); #endif /* _H5Opkg_H */ xdmf-3.0+git20160803/Utilities/hdf5/H5HP.c0000640000175000017500000007266013003006557017556 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Purpose: Provides a heap abstract data type. * * (See chapter 11 - "Priority Queues" of _Algorithms_, by * Sedgewick for additional information) * */ /* Private headers needed */ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5HPprivate.h" /* Heap routines */ #include "H5FLprivate.h" /* Memory management functions */ /* Local Macros */ #define H5HP_START_SIZE 16 /* Initial number of entries for heaps */ /* Private typedefs & structs */ /* Data structure for entries in the internal heap array */ typedef struct { int val; /* Value to be used for heap condition */ H5HP_info_t *obj; /* Pointer to object stored in heap */ }H5HP_ent_t; /* Main heap data structure */ struct H5HP_t { H5HP_type_t type; /* Type of heap (minimum or maximum value at "top") */ size_t nobjs; /* Number of active objects in heap array */ size_t nalloc; /* Number of allocated locations in heap array */ H5HP_ent_t *heap; /* Pointer to array containing heap entries */ }; /* Static functions */ static herr_t H5HP_swim_max(H5HP_t *heap, size_t loc); static herr_t H5HP_swim_min(H5HP_t *heap, size_t loc); static herr_t H5HP_sink_max(H5HP_t *heap, size_t loc); static herr_t H5HP_sink_min(H5HP_t *heap, size_t loc); /* Declare a free list to manage the H5HP_t struct */ H5FL_DEFINE_STATIC(H5HP_t); /* Declare a free list to manage sequences of H5HP_ent_t */ H5FL_SEQ_DEFINE_STATIC(H5HP_ent_t); /*-------------------------------------------------------------------------- NAME H5HP_swim_max PURPOSE Restore heap condition by moving an object upward USAGE herr_t H5HP_swim_max(heap, loc) H5HP_t *heap; IN/OUT: Pointer to heap to modify size_t loc; IN: Location to start from RETURNS Returns non-negative on success, negative on failure. DESCRIPTION Restore the heap condition for the heap's array by "swimming" the object at a location upward. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS This routine is for "maximum" value heaps. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5HP_swim_max(H5HP_t *heap, size_t loc) { int val; /* Temporary copy value of object to move in heap */ H5HP_info_t *obj; /* Temporary pointer to object to move in heap */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HP_swim_max); /* Get copies of the information about the object to move in the heap */ val=heap->heap[loc].val; obj=heap->heap[loc].obj; /* Move object up in heap until it's reached the maximum location possible */ while(heap->heap[loc/2].val < val) { /* Move object "above" current location in heap down */ heap->heap[loc].val=heap->heap[loc/2].val; heap->heap[loc].obj=heap->heap[loc/2].obj; /* Update heap location for object which moved */ heap->heap[loc].obj->heap_loc=loc; /* Move to location "above" current location */ loc=loc/2; } /* end while */ /* Put object into heap at correct location */ heap->heap[loc].val=val; heap->heap[loc].obj=obj; /* Update heap location for object */ heap->heap[loc].obj->heap_loc=loc; FUNC_LEAVE_NOAPI(ret_value); } /* end H5HP_swim_max() */ /*-------------------------------------------------------------------------- NAME H5HP_swim_min PURPOSE Restore heap condition by moving an object upward USAGE herr_t H5HP_swim_min(heap, loc) H5HP_t *heap; IN/OUT: Pointer to heap to modify size_t loc; IN: Location to start from RETURNS Returns non-negative on success, negative on failure. DESCRIPTION Restore the heap condition for the heap's array by "swimming" the object at a location upward. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS This routine is for "minimum" value heaps. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5HP_swim_min(H5HP_t *heap, size_t loc) { int val; /* Temporary copy value of object to move in heap */ H5HP_info_t *obj; /* Temporary pointer to object to move in heap */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HP_swim_min); /* Get copies of the information about the object to move in the heap */ val=heap->heap[loc].val; obj=heap->heap[loc].obj; /* Move object up in heap until it's reached the minimum location possible */ while(heap->heap[loc/2].val > val) { /* Move object "above" current location in heap down */ heap->heap[loc].val=heap->heap[loc/2].val; heap->heap[loc].obj=heap->heap[loc/2].obj; /* Update heap location for object which moved */ heap->heap[loc].obj->heap_loc=loc; /* Move to location "above" current location */ loc=loc/2; } /* end while */ /* Put object into heap at correct location */ heap->heap[loc].val=val; heap->heap[loc].obj=obj; /* Update heap location for object */ heap->heap[loc].obj->heap_loc=loc; FUNC_LEAVE_NOAPI(ret_value); } /* end H5HP_swim_min() */ /*-------------------------------------------------------------------------- NAME H5HP_sink_max PURPOSE Restore heap condition by moving an object downward USAGE herr_t H5HP_sink_max(heap, loc) H5HP_t *heap; IN/OUT: Pointer to heap to modify size_t loc; IN: Location to start from RETURNS Returns non-negative on success, negative on failure. DESCRIPTION Restore the heap condition for the heap's array by "sinking" the object at a location downward. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS This routine is for "maximum" value heaps. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5HP_sink_max(H5HP_t *heap, size_t loc) { int val; /* Temporary copy value of object to move in heap */ void *obj; /* Temporary pointer to object to move in heap */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HP_sink_max); /* Get copies of the information about the object to move in the heap */ val=heap->heap[loc].val; obj=heap->heap[loc].obj; /* Move object up in heap until it's reached the maximum location possible */ while((2*loc)<=heap->nobjs) { size_t new_loc=loc*2; /* New object's potential location area */ /* Get the greater of the two objects below the location in heap */ if(new_locnobjs && (heap->heap[new_loc].val < heap->heap[new_loc+1].val)) new_loc++; /* Check if the object is smaller than the larger of the objects below it */ /* If so, its in the correct location now, and we can get out */ if(val >= heap->heap[new_loc].val) break; /* Move the greater of the two objects below the current location up */ heap->heap[loc].val=heap->heap[new_loc].val; heap->heap[loc].obj=heap->heap[new_loc].obj; /* Update heap location for object which moved */ heap->heap[loc].obj->heap_loc=loc; /* Move to location "below" current location */ loc=new_loc; } /* end while */ /* Put object into heap at correct location */ heap->heap[loc].val=val; heap->heap[loc].obj=obj; /* Update heap location for object */ heap->heap[loc].obj->heap_loc=loc; FUNC_LEAVE_NOAPI(ret_value); } /* end H5HP_sink_max() */ /*-------------------------------------------------------------------------- NAME H5HP_sink_min PURPOSE Restore heap condition by moving an object downward USAGE herr_t H5HP_sink_min(heap, loc) H5HP_t *heap; IN/OUT: Pointer to heap to modify size_t loc; IN: Location to start from RETURNS Returns non-negative on success, negative on failure. DESCRIPTION Restore the heap condition for the heap's array by "sinking" the object at a location downward. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS This routine is for "minimum" value heaps. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5HP_sink_min(H5HP_t *heap, size_t loc) { int val; /* Temporary copy value of object to move in heap */ void *obj; /* Temporary pointer to object to move in heap */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HP_sink_min); /* Get copies of the information about the object to move in the heap */ val=heap->heap[loc].val; obj=heap->heap[loc].obj; /* Move object up in heap until it's reached the maximum location possible */ while((2*loc)<=heap->nobjs) { size_t new_loc=loc*2; /* New object's potential location area */ /* Get the lesser of the two objects below the location in heap */ if(new_locnobjs && (heap->heap[new_loc].val > heap->heap[new_loc+1].val)) new_loc++; /* Check if the object is greater than the larger of the objects below it */ /* If so, its in the correct location now, and we can get out */ if(val <= heap->heap[new_loc].val) break; /* Move the greater of the two objects below the current location up */ heap->heap[loc].val=heap->heap[new_loc].val; heap->heap[loc].obj=heap->heap[new_loc].obj; /* Update heap location for object which moved */ heap->heap[loc].obj->heap_loc=loc; /* Move to location "below" current location */ loc=new_loc; } /* end while */ /* Put object into heap at correct location */ heap->heap[loc].val=val; heap->heap[loc].obj=obj; /* Update heap location for object */ heap->heap[loc].obj->heap_loc=loc; FUNC_LEAVE_NOAPI(ret_value); } /* end H5HP_sink_min() */ /*-------------------------------------------------------------------------- NAME H5HP_create PURPOSE Create a heap USAGE H5HP_t *H5HP_create(heap_type) H5HP_type_t heap_type; IN: Type of heap to create RETURNS Returns a pointer to a heap on success, NULL on failure. DESCRIPTION Create a priority queue. The SIZE is used to set the initial number of entries allocated. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ H5HP_t * H5HP_create(H5HP_type_t heap_type) { H5HP_t *new_heap=NULL; /* Pointer to new heap object created */ H5HP_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5HP_create,NULL); /* Check args */ assert(heap_type==H5HP_MIN_HEAP || heap_type==H5HP_MAX_HEAP); /* Allocate ref-counted string structure */ if((new_heap=H5FL_MALLOC(H5HP_t))==NULL) HGOTO_ERROR(H5E_HEAP,H5E_NOSPACE,NULL,"memory allocation failed"); /* Allocate the array to store the heap entries */ if((new_heap->heap=H5FL_SEQ_MALLOC(H5HP_ent_t, H5HP_START_SIZE+1))==NULL) HGOTO_ERROR(H5E_HEAP,H5E_NOSPACE,NULL,"memory allocation failed"); /* Set the internal fields */ new_heap->type=heap_type; new_heap->nobjs=0; new_heap->nalloc=H5HP_START_SIZE+1; /* Set the information in the 0'th location based on the type of heap */ if(heap_type==H5HP_MIN_HEAP) { /* Set the value in the '0' location to be the minimum value, to * simplify the algorithms */ new_heap->heap[0].val=INT_MIN; new_heap->heap[0].obj=NULL; } /* end if */ else { /* Set the value in the '0' location to be the maximum value, to * simplify the algorithms */ new_heap->heap[0].val=INT_MAX; new_heap->heap[0].obj=NULL; } /* end else */ /* Set the return value */ ret_value=new_heap; done: /* Error cleanup */ if(ret_value==NULL) { if(new_heap!=NULL) { if(new_heap->heap!=NULL) H5FL_SEQ_FREE(H5HP_ent_t,new_heap->heap); H5FL_FREE(H5HP_t,new_heap); } /* end if */ } /* end if */ FUNC_LEAVE_NOAPI(ret_value); } /* end H5HP_create() */ /*-------------------------------------------------------------------------- NAME H5HP_count PURPOSE Check the number of elements in a heap USAGE ssize_t H5HP_count(heap) const H5HP_t *heap; IN: Pointer to heap to query RETURNS Returns non-negative on success, negative on failure. DESCRIPTION Checks the number of elements in heap GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ ssize_t H5HP_count(const H5HP_t *heap) { ssize_t ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOFUNC(H5HP_count); /* Check args */ assert(heap); /* Check internal consistency */ /* (Pre-condition) */ assert(heap->nobjsnalloc); assert(heap->heap); assert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || (heap->type==H5HP_MIN_HEAP && heap->heap[0].val==INT_MIN)); assert(heap->heap[0].obj==NULL); /* Return the number of objects in the heap */ H5_CHECK_OVERFLOW(heap->nobjs,size_t,ssize_t); ret_value=(ssize_t)heap->nobjs; /* No post-condition check necessary, since heap is constant */ FUNC_LEAVE_NOAPI(ret_value); } /* end H5HP_count() */ /*-------------------------------------------------------------------------- NAME H5HP_insert PURPOSE Insert an object into a heap, with an initial value USAGE herr_t H5HP_insert(heap, val, obj) H5HP_t *heap; IN/OUT: Pointer to heap to modify int val; IN: Initial value for object in heap void *obj; IN: Pointer to object to insert into heap RETURNS Returns non-negative on success, negative on failure. DESCRIPTION Inserts a OBJ into a HEAP, with an initial VALue. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5HP_insert(H5HP_t *heap, int val, void *obj) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5HP_insert,FAIL); /* Check args */ assert(heap); assert(obj); /* Check internal consistency */ /* (Pre-condition) */ assert(heap->nobjsnalloc); assert(heap->heap); assert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || (heap->type==H5HP_MIN_HEAP && heap->heap[0].val==INT_MIN)); assert(heap->heap[0].obj==NULL); /* Increment number of objects in heap */ heap->nobjs++; /* Check if we need to allocate more room for heap array */ if(heap->nobjs>=heap->nalloc) { size_t n = MAX(H5HP_START_SIZE, 2*(heap->nalloc-1)) + 1; H5HP_ent_t *new_heap = H5FL_SEQ_REALLOC(H5HP_ent_t,heap->heap, n); if (!new_heap) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to extend heap array"); heap->heap = new_heap; heap->nalloc = n; } /* end if */ /* Insert new object at end of heap */ heap->heap[heap->nobjs].val=val; heap->heap[heap->nobjs].obj=obj; heap->heap[heap->nobjs].obj->heap_loc=heap->nobjs; /* Restore heap condition */ if(heap->type==H5HP_MAX_HEAP) { if(H5HP_swim_max(heap,heap->nobjs)<0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, FAIL, "unable to restore heap condition"); } /* end if */ else { if(H5HP_swim_min(heap,heap->nobjs)<0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, FAIL, "unable to restore heap condition"); } /* end else */ done: /* Check internal consistency */ /* (Post-condition) */ assert(heap->nobjsnalloc); assert(heap->heap); assert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || (heap->type==H5HP_MIN_HEAP && heap->heap[0].val==INT_MIN)); assert(heap->heap[0].obj==NULL); FUNC_LEAVE_NOAPI(ret_value); } /* end H5HP_insert() */ /*-------------------------------------------------------------------------- NAME H5HP_top PURPOSE Check the value of the top object in the heap USAGE herr_t H5HP_top(heap, val) const H5HP_t *heap; IN: Pointer to heap to modify int val; IN/OUT: Initial value for object in heap RETURNS Returns non-negative on success, negative on failure. DESCRIPTION Checks the value of the top object in a heap GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5HP_top(const H5HP_t *heap, int *val) { FUNC_ENTER_NOAPI_NOFUNC(H5HP_top); /* Check args */ assert(heap); assert(val); /* Check internal consistency */ /* (Pre-condition) */ assert(heap->nobjsnalloc); assert(heap->heap); assert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || (heap->type==H5HP_MIN_HEAP && heap->heap[0].val==INT_MIN)); assert(heap->heap[0].obj==NULL); /* Get value of the top object in the heap */ *val=heap->heap[1].val; /* No post-condition check necessary, since heap is constant */ FUNC_LEAVE_NOAPI(SUCCEED); } /* end H5HP_top() */ /*-------------------------------------------------------------------------- NAME H5HP_remove PURPOSE Remove an object into a heap USAGE herr_t H5HP_remove(heap, val, obj) H5HP_t *heap; IN/OUT: Pointer to heap to modify int *val; OUT: Pointer to value of object removed from heap void **obj; OUT: Pointer to object removed from heap RETURNS Returns non-negative on success, negative on failure. DESCRIPTION Removes the top object on a heap, returning its value and object pointer GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5HP_remove(H5HP_t *heap, int *val, void **obj) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5HP_remove,FAIL); /* Check args */ assert(heap); assert(val); assert(obj); /* Check internal consistency */ /* (Pre-condition) */ assert(heap->nobjsnalloc); assert(heap->heap); assert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || (heap->type==H5HP_MIN_HEAP && heap->heap[0].val==INT_MIN)); assert(heap->heap[0].obj==NULL); /* Check if there are any objects on the heap to remove */ if(heap->nobjs==0) HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "heap is empty"); /* Get the information for the top object on the heap */ assert(heap->heap[1].obj->heap_loc==1); *val=heap->heap[1].val; *obj=heap->heap[1].obj; /* Move the last element in the heap to the top */ heap->heap[1].val=heap->heap[heap->nobjs].val; heap->heap[1].obj=heap->heap[heap->nobjs].obj; heap->heap[1].obj->heap_loc=1; /* Decrement number of objects in heap */ heap->nobjs--; /* Restore heap condition, if there are objects on the heap */ if(heap->nobjs>0) { if(heap->type==H5HP_MAX_HEAP) { if(H5HP_sink_max(heap,1)<0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDELETE, FAIL, "unable to restore heap condition"); } /* end if */ else { if(H5HP_sink_min(heap,1)<0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDELETE, FAIL, "unable to restore heap condition"); } /* end else */ } /* end if */ done: /* Check internal consistency */ /* (Post-condition) */ assert(heap->nobjsnalloc); assert(heap->heap); assert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || (heap->type==H5HP_MIN_HEAP && heap->heap[0].val==INT_MIN)); assert(heap->heap[0].obj==NULL); FUNC_LEAVE_NOAPI(ret_value); } /* end H5HP_remove() */ /*-------------------------------------------------------------------------- NAME H5HP_change PURPOSE Change the priority of an object on a heap USAGE herr_t H5HP_change(heap, val, obj) H5HP_t *heap; IN/OUT: Pointer to heap to modify int val; IN: New priority value for object void *obj; IN: Pointer to object to modify RETURNS Returns non-negative on success, negative on failure. DESCRIPTION Changes the priority of an object on a heap. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5HP_change(H5HP_t *heap, int val, void *_obj) { H5HP_info_t *obj=(H5HP_info_t *)_obj; /* Alias for object */ size_t obj_loc; /* Location of object in heap */ int old_val; /* Object's old priority value */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5HP_change,FAIL); /* Check args */ assert(heap); assert(obj); /* Check internal consistency */ /* (Pre-condition) */ assert(heap->nobjsnalloc); assert(heap->heap); assert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || (heap->type==H5HP_MIN_HEAP && heap->heap[0].val==INT_MIN)); assert(heap->heap[0].obj==NULL); /* Get the location of the object in the heap */ obj_loc=obj->heap_loc; assert(obj_loc>0 && obj_loc<=heap->nobjs); /* Change the heap object's priority */ old_val=heap->heap[obj_loc].val; heap->heap[obj_loc].val=val; /* Restore heap condition */ if(valtype==H5HP_MAX_HEAP) { if(H5HP_sink_max(heap,obj_loc)<0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition"); } /* end if */ else { if(H5HP_swim_min(heap,obj_loc)<0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition"); } /* end else */ } /* end if */ else { if(heap->type==H5HP_MAX_HEAP) { if(H5HP_swim_max(heap,obj_loc)<0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition"); } /* end if */ else { if(H5HP_sink_min(heap,obj_loc)<0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition"); } /* end else */ } /* end else */ done: /* Check internal consistency */ /* (Post-condition) */ assert(heap->nobjsnalloc); assert(heap->heap); assert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || (heap->type==H5HP_MIN_HEAP && heap->heap[0].val==INT_MIN)); assert(heap->heap[0].obj==NULL); FUNC_LEAVE_NOAPI(ret_value); } /* end H5HP_change() */ /*-------------------------------------------------------------------------- NAME H5HP_incr PURPOSE Increment the priority of an object on a heap USAGE herr_t H5HP_incr(heap, amt, obj) H5HP_t *heap; IN/OUT: Pointer to heap to modify unsigned amt; IN: Amount to increase priority by void *obj; IN: Pointer to object to modify RETURNS Returns non-negative on success, negative on failure. DESCRIPTION Increments the priority of an object on a heap by one. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5HP_incr(H5HP_t *heap, unsigned amt, void *_obj) { H5HP_info_t *obj=(H5HP_info_t *)_obj; /* Alias for object */ size_t obj_loc; /* Location of object in heap */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5HP_incr,FAIL); /* Check args */ assert(heap); assert(obj); /* Check internal consistency */ /* (Pre-condition) */ assert(heap->nobjsnalloc); assert(heap->heap); assert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || (heap->type==H5HP_MIN_HEAP && heap->heap[0].val==INT_MIN)); assert(heap->heap[0].obj==NULL); /* Get the location of the object in the heap */ obj_loc=obj->heap_loc; assert(obj_loc>0 && obj_loc<=heap->nobjs); /* Change the heap object's priority */ heap->heap[obj_loc].val+=amt; /* Restore heap condition */ if(heap->type==H5HP_MAX_HEAP) { if(H5HP_swim_max(heap,obj_loc)<0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition"); } /* end if */ else { if(H5HP_sink_min(heap,obj_loc)<0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition"); } /* end else */ done: /* Check internal consistency */ /* (Post-condition) */ assert(heap->nobjsnalloc); assert(heap->heap); assert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || (heap->type==H5HP_MIN_HEAP && heap->heap[0].val==INT_MIN)); assert(heap->heap[0].obj==NULL); FUNC_LEAVE_NOAPI(ret_value); } /* end H5HP_incr() */ /*-------------------------------------------------------------------------- NAME H5HP_decr PURPOSE Decrement the priority of an object on a heap USAGE herr_t H5HP_dec(heap, amt, obj) H5HP_t *heap; IN/OUT: Pointer to heap to modify unsigned amt; IN: Amount to decrease priority by void *obj; IN: Pointer to object to modify RETURNS Returns non-negative on success, negative on failure. DESCRIPTION Decrements the priority of an object on a heap by one. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5HP_decr(H5HP_t *heap, unsigned amt, void *_obj) { H5HP_info_t *obj=(H5HP_info_t *)_obj; /* Alias for object */ size_t obj_loc; /* Location of object in heap */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5HP_decr,FAIL); /* Check args */ assert(heap); assert(obj); /* Check internal consistency */ /* (Pre-condition) */ assert(heap->nobjsnalloc); assert(heap->heap); assert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || (heap->type==H5HP_MIN_HEAP && heap->heap[0].val==INT_MIN)); assert(heap->heap[0].obj==NULL); /* Get the location of the object in the heap */ obj_loc=obj->heap_loc; assert(obj_loc>0 && obj_loc<=heap->nobjs); /* Change the heap object's priority */ heap->heap[obj_loc].val-=amt; /* Restore heap condition */ if(heap->type==H5HP_MAX_HEAP) { if(H5HP_sink_max(heap,obj_loc)<0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition"); } /* end if */ else { if(H5HP_swim_min(heap,obj_loc)<0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition"); } /* end else */ done: /* Check internal consistency */ /* (Post-condition) */ assert(heap->nobjsnalloc); assert(heap->heap); assert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || (heap->type==H5HP_MIN_HEAP && heap->heap[0].val==INT_MIN)); assert(heap->heap[0].obj==NULL); FUNC_LEAVE_NOAPI(ret_value); } /* end H5HP_decr() */ /*-------------------------------------------------------------------------- NAME H5HP_close PURPOSE Close a heap, deallocating it. USAGE herr_t H5HP_close(heap) H5HP_t *heap; IN/OUT: Pointer to heap to close RETURNS Returns non-negative on success, negative on failure. DESCRIPTION Close a heap, freeing all internal information. Any objects left in the heap are not deallocated. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5HP_close(H5HP_t *heap) { FUNC_ENTER_NOAPI_NOFUNC(H5HP_close); /* Check args */ assert(heap); /* Check internal consistency */ /* (Pre-condition) */ assert(heap->nobjsnalloc); assert(heap->heap); assert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || (heap->type==H5HP_MIN_HEAP && heap->heap[0].val==INT_MIN)); assert(heap->heap[0].obj==NULL); /* Free internal structures for heap */ H5FL_SEQ_FREE(H5HP_ent_t,heap->heap); /* Free actual heap object */ H5FL_FREE(H5HP_t,heap); FUNC_LEAVE_NOAPI(SUCCEED); } /* end H5HP_close() */ xdmf-3.0+git20160803/Utilities/hdf5/README.txt0000640000175000017500000000340713003006557020375 0ustar alastairalastairHDF5 version 1.6.2 released on Thu Feb 12 14:18:13 CST 2004 Please refer to the release_docs/INSTALL file for installation instructions. ------------------------------------------------------------------------------ This release is almost fully functional for the entire API defined in the documentation, see the RELEASE.txt file in this directory for information specific to this release of the library. The INSTALL file contains instructions on compiling and installing the library. The INSTALL_parallel file contains instructions on installing the parallel version of the library. The INSTALL* files can be found in the release_docs/ directory. Documentation for this release is in the html directory. Start with the "index.html" in that directory. Four mailing lists are currently set up for use with the HDF5 library. hdf5 - For general discussion of the HDF5 library with other users. hdf5dev - For discussion of the HDF5 library development with developers and other interested parties. hdf5announce - For announcements of HDF5 related developments, not a discussion list. hdf5cvs - For checkin notices of code development on the library, not a discussion list. To subscribe to a list, send mail to "majordomo@ncsa.uiuc.edu", with "subscribe " in the _body_, not the Subject, of the message. E.g., subscribe hdf5 Messages to be sent to the list should be sent to "@ncsa.uiuc.edu". Nearly daily code snapshots are now being provided at the following URL: ftp://hdf.ncsa.uiuc.edu/pub/outgoing/hdf5/snapshots Please read the readme file in that directory before working with a library snapshot. The HDF5 website is located at http://hdf.ncsa.uiuc.edu/HDF5/ Bugs should be reported to hdfhelp@ncsa.uiuc.edu. xdmf-3.0+git20160803/Utilities/hdf5/H5detect.c0000640000175000017500000013423213003006557020511 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*keep this declaration near the top of this file -RPM*/ static const char *FileHeader = "\n\ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n\ * Copyright by the Board of Trustees of the University of Illinois. *\n\ * All rights reserved. *\n\ * *\n\ * This file is part of HDF5. The full HDF5 copyright notice, including *\n\ * terms governing use, modification, and redistribution, is contained in *\n\ * the files COPYING and Copyright.html. COPYING can be found at the root *\n\ * of the source code distribution tree; Copyright.html can be found at the *\n\ * root level of an installed copy of the electronic HDF5 document set and *\n\ * is linked from the top-level documents page. It can also be found at *\n\ * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *\n\ * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *\n\ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *"; /* * * Created: H5detect.c * 10 Aug 1997 * Robb Matzke * * Purpose: This code was borrowed heavily from the `detect.c' * program in the AIO distribution from Lawrence * Livermore National Laboratory. * * Detects machine byte order and floating point * format and generates a C source file (native.c) * to describe those paramters. * * Assumptions: We have an ANSI compiler. We're on a Unix like * system or configure has detected those Unix * features which aren't available. We're not * running on a Vax or other machine with mixed * endianess. * * Modifications: * *------------------------------------------------------------------------- */ #undef NDEBUG #include "H5private.h" #include "H5Tpublic.h" #include "H5Rpublic.h" #define MAXDETECT 64 /* * This structure holds information about a type that * was detected. */ typedef struct detected_t { const char *varname; int size; /*total byte size */ int precision; /*meaningful bits */ int offset; /*bit offset to meaningful bits */ int perm[32]; /*byte order */ int sign; /*location of sign bit */ int mpos, msize, imp;/*information about mantissa */ int epos, esize; /*information about exponent */ unsigned long bias; /*exponent bias for floating pt.*/ size_t align; /*required byte alignment */ size_t comp_align; /*alignment for structure */ } detected_t; /* This structure holds structure alignment for pointers, hvl_t, hobj_ref_t, * hdset_reg_ref_t */ typedef struct malign_t { const char *name; size_t comp_align; /*alignment for structure */ } malign_t; /* global variables types detection code */ static detected_t d_g[MAXDETECT]; static malign_t m_g[MAXDETECT]; static volatile int nd_g = 0, na_g = 0; static void print_results(int nd, detected_t *d, int na, malign_t *m); static void iprint(detected_t *); static int byte_cmp(int, void *, void *); static int bit_cmp(int, int *, void *, void *); static void fix_order(int, int, int, int *, const char **); static int imp_bit(int, int *, void *, void *); static unsigned long find_bias(int, int, int *, void *); static void precision (detected_t*); static void print_header(void); static void detect_C89_integers(void); static void detect_C89_floats(void); static void detect_C99_integers(void); static void detect_C99_floats(void); static void detect_C99_integers8(void); static void detect_C99_integers16(void); static void detect_C99_integers32(void); static void detect_C99_integers64(void); static void detect_alignments(void); static size_t align_g[] = {1, 2, 4, 8, 16}; static jmp_buf jbuf_g; /*------------------------------------------------------------------------- * Function: precision * * Purpose: Determine the precision and offset. * * Return: void * * Programmer: Robb Matzke * Thursday, June 18, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static void precision (detected_t *d) { int n; if (0==d->msize) { /* * An integer. The permutation can have negative values at the * beginning or end which represent padding of bytes. We must adjust * the precision and offset accordingly. */ if (d->perm[0] < 0) { /* * Lower addresses are padded. */ for (n=0; nsize && d->perm[n]<0; n++) /*void*/; d->precision = 8*(d->size-n); d->offset = 0; } else if (d->perm[d->size - 1] < 0) { /* * Higher addresses are padded. */ for (n=0; nsize && d->perm[d->size-(n+1)]; n++) /*void*/; d->precision = 8*(d->size-n); d->offset = 8*n; } else { /* * No padding. */ d->precision = 8*d->size; d->offset = 0; } } else { /* A floating point */ d->offset = MIN3 (d->mpos, d->epos, d->sign); d->precision = d->msize + d->esize + 1; } } /*------------------------------------------------------------------------- * Function: DETECT_I * * Purpose: This macro takes a type like `int' and a base name like * `nati' and detects the byte order. The VAR is used to * construct the names of the C variables defined. * * Return: void * * Programmer: Robb Matzke * matzke@llnl.gov * Jun 12 1996 * * Modifications: * * Robb Matzke, 4 Nov 1996 * The INFO.perm now contains `-1' for bytes that aren't used and * are always zero. This happens on the Cray for `short' where * sizeof(short) is 8, but only the low-order 4 bytes are ever used. * * Robb Matzke, 4 Nov 1996 * Added a `padding' field to indicate how many zero bytes appear to * the left (N) or right (-N) of the value. * * Robb Matzke, 5 Nov 1996 * Removed HFILE and CFILE arguments. * *------------------------------------------------------------------------- */ #define DETECT_I(TYPE,VAR,INFO) { \ TYPE _v; \ int _int_v; \ int _i, _j; \ unsigned char *_x; \ \ memset (&INFO, 0, sizeof(INFO)); \ INFO.varname = #VAR; \ INFO.size = sizeof(TYPE); \ \ if(sizeof(TYPE)!=1) { \ for (_i=sizeof(TYPE),_v=0; _i>0; --_i) _v = (_v<<8) + _i; \ for (_i=0,_x=(unsigned char *)&_v; _i<(signed)sizeof(TYPE); _i++) { \ _j = (*_x++)-1; \ assert (_j<(signed)sizeof(TYPE)); \ INFO.perm[_i] = _j; \ } \ } else { /*Not able to detect order if type size is 1 byte. Use native int \ *instead. No effect on data, just make it look correct. */ \ for (_i=sizeof(int),_int_v=0; _i>0; --_i) _int_v = (_int_v<<8) + _i; \ for (_i=0,_x=(unsigned char *)&_int_v; _i<(signed)sizeof(int); _i++) { \ _j = (*_x++)-1; \ assert (_j<(signed)sizeof(int)); \ INFO.perm[_i] = _j; \ } \ } \ \ INFO.sign = ('U'!=*(#VAR)); \ precision (&(INFO)); \ ALIGNMENT(TYPE, INFO); \ if(!strcmp(INFO.varname, "SCHAR") || !strcmp(INFO.varname, "SHORT") || \ !strcmp(INFO.varname, "INT") || !strcmp(INFO.varname, "LONG") || \ !strcmp(INFO.varname, "LLONG")) { \ COMP_ALIGNMENT(TYPE,INFO.comp_align); \ } \ } /*------------------------------------------------------------------------- * Function: DETECT_F * * Purpose: This macro takes a floating point type like `double' and * a base name like `natd' and detects byte order, mantissa * location, exponent location, sign bit location, presence or * absence of implicit mantissa bit, and exponent bias and * initializes a detected_t structure with those properties. * * Return: void * * Programmer: Robb Matzke * matzke@llnl.gov * Jun 12 1996 * * Modifications: * * Robb Matzke, 14 Aug 1996 * The byte order detection has been changed because on the Cray * the last pass causes a rounding to occur that causes the least * significant mantissa byte to change unexpectedly. * * Robb Matzke, 5 Nov 1996 * Removed HFILE and CFILE arguments. *------------------------------------------------------------------------- */ #define DETECT_F(TYPE,VAR,INFO) { \ TYPE _v1, _v2, _v3; \ int _i, _j, _first=(-1), _last=(-1); \ char *_mesg; \ \ memset (&INFO, 0, sizeof(INFO)); \ INFO.varname = #VAR; \ INFO.size = sizeof(TYPE); \ \ /* Completely initialize temporary variables, in case the bits used in */ \ /* the type take less space than the number of bits used to store the type */ \ memset(&_v3,0,sizeof(TYPE)); \ memset(&_v2,0,sizeof(TYPE)); \ memset(&_v1,0,sizeof(TYPE)); \ \ /* Byte Order */ \ for (_i=0,_v1=0.0,_v2=1.0; _i<(signed)sizeof(TYPE); _i++) { \ _v3 = _v1; _v1 += _v2; _v2 /= 256.0; \ if ((_j=byte_cmp(sizeof(TYPE), &_v3, &_v1))>=0) { \ if (0==_i || INFO.perm[_i-1]!=_j) { \ INFO.perm[_i] = _j; \ _last = _i; \ if (_first<0) _first = _i; \ } \ } \ } \ fix_order (sizeof(TYPE), _first, _last, INFO.perm, (const char**)&_mesg); \ \ /* Implicit mantissa bit */ \ _v1 = 0.5; \ _v2 = 1.0; \ INFO.imp = imp_bit (sizeof(TYPE), INFO.perm, &_v1, &_v2); \ \ /* Sign bit */ \ _v1 = 1.0; \ _v2 = -1.0; \ INFO.sign = bit_cmp (sizeof(TYPE), INFO.perm, &_v1, &_v2); \ \ /* Mantissa */ \ INFO.mpos = 0; \ \ _v1 = 1.0; \ _v2 = 1.5; \ INFO.msize = bit_cmp (sizeof(TYPE), INFO.perm, &_v1, &_v2); \ INFO.msize += 1 + (INFO.imp?0:1) - INFO.mpos; \ \ /* Exponent */ \ INFO.epos = INFO.mpos + INFO.msize; \ \ INFO.esize = INFO.sign - INFO.epos; \ \ _v1 = 1.0; \ INFO.bias = find_bias (INFO.epos, INFO.esize, INFO.perm, &_v1); \ precision (&(INFO)); \ ALIGNMENT(TYPE, INFO); \ if(!strcmp(INFO.varname, "FLOAT") || !strcmp(INFO.varname, "DOUBLE") || \ !strcmp(INFO.varname, "LDOUBLE")) { \ COMP_ALIGNMENT(TYPE,INFO.comp_align); \ } \ } /*------------------------------------------------------------------------- * Function: DETECT_M * * Purpose: This macro takes only miscellaneous structures or pointer * (pointer, hvl_t, hobj_ref_t, hdset_reg_ref_t). It * constructs the names and decides the alignment in structure. * * Return: void * * Programmer: Raymond Lu * slu@ncsa.uiuc.edu * Dec 9, 2002 * * Modifications: * *------------------------------------------------------------------------- */ #define DETECT_M(TYPE,VAR,INFO) { \ INFO.name = #VAR; \ COMP_ALIGNMENT(TYPE, INFO.comp_align); \ } /* Detect alignment for C structure */ #define COMP_ALIGNMENT(TYPE,COMP_ALIGN) { \ struct { \ char c; \ TYPE x; \ } s; \ \ COMP_ALIGN = (size_t)((char*)(&(s.x)) - (char*)(&s)); \ } #if defined(H5_HAVE_LONGJMP) && defined(H5_HAVE_SIGNAL) #define ALIGNMENT(TYPE,INFO) { \ char *volatile _buf=NULL; \ volatile TYPE _val=1; \ volatile TYPE _val2; \ volatile size_t _ano=0; \ void (*_handler)(int) = signal(SIGBUS, sigbus_handler); \ void (*_handler2)(int) = signal(SIGSEGV, sigsegv_handler); \ \ _buf = (char*)malloc(sizeof(TYPE)+align_g[NELMTS(align_g)-1]); \ if (setjmp(jbuf_g)) _ano++; \ if (_ano=NELMTS(align_g)) { \ INFO.align=0; \ fprintf(stderr, "unable to calculate alignment for %s\n", #TYPE); \ } \ } #else #define ALIGNMENT(TYPE,INFO) (INFO.align)=0 #endif #endif /*------------------------------------------------------------------------- * Function: sigsegv_handler * * Purpose: Handler for SIGSEGV. We use signal() instead of sigaction() * because it's more portable to non-Posix systems. Although * it's not nearly as nice to work with, it does the job for * this simple stuff. * * Return: Returns via longjmp to jbuf_g. * * Programmer: Robb Matzke * Thursday, March 18, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static void sigsegv_handler(int UNUSED signo) { signal(SIGSEGV, sigsegv_handler); longjmp(jbuf_g, 1); } /*------------------------------------------------------------------------- * Function: sigbus_handler * * Purpose: Handler for SIGBUS. We use signal() instead of sigaction() * because it's more portable to non-Posix systems. Although * it's not nearly as nice to work with, it does the job for * this simple stuff. * * Return: Returns via longjmp to jbuf_g. * * Programmer: Robb Matzke * Thursday, March 18, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static void sigbus_handler(int UNUSED signo) { signal(SIGBUS, sigbus_handler); longjmp(jbuf_g, 1); } /*------------------------------------------------------------------------- * Function: print_results * * Purpose: Prints information about the detected data types. * * Return: void * * Programmer: Robb Matzke * matzke@llnl.gov * Jun 14, 1996 * * Modifications: * *------------------------------------------------------------------------- */ static void print_results(int nd, detected_t *d, int na, malign_t *misc_align) { int byte_order=0; int i, j; /* Include files */ printf("\ #define H5T_PACKAGE /*suppress error about including H5Tpkg.h*/\n\ \n\ #include \"H5private.h\"\n\ #include \"H5Iprivate.h\"\n\ #include \"H5Eprivate.h\"\n\ #include \"H5FLprivate.h\"\n\ #include \"H5Tpkg.h\"\n\ \n\ /* Declare external the free lists for H5T_t's and H5T_shared_t's */\n\ H5FL_EXTERN(H5T_t);\n\ H5FL_EXTERN(H5T_shared_t);\n\ \n\ \n"); /* The interface initialization function */ printf("\n\ herr_t\n\ H5TN_init_interface(void)\n\ {\n\ H5T_t *dt = NULL;\n\ herr_t ret_value = SUCCEED;\n\ \n\ FUNC_ENTER_NOAPI(H5TN_init_interface, FAIL);\n"); for (i = 0; i < nd; i++) { /* The native endianess of this machine */ /* The INFO.perm now contains `-1' for bytes that aren't used and * are always zero. This happens on the Cray for `short' where * sizeof(short) is 8, but only the low-order 4 bytes are ever used. */ for(j=0; j<32; j++) { /*Find the 1st containing valid data*/ if(d[i].perm[j]>-1) { byte_order=d[i].perm[j]; break; } } /* Print a comment to describe this section of definitions. */ printf("\n /*\n"); iprint(d+i); printf(" */\n"); /* The part common to fixed and floating types */ printf("\ if(NULL == (dt = H5T_alloc()))\n\ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,\"memory allocation failed\")\n\ dt->shared->state = H5T_STATE_IMMUTABLE;\n\ dt->shared->type = H5T_%s;\n\ dt->shared->size = %d;\n\ dt->shared->u.atomic.order = H5T_ORDER_%s;\n\ dt->shared->u.atomic.offset = %d;\n\ dt->shared->u.atomic.prec = %d;\n\ dt->shared->u.atomic.lsb_pad = H5T_PAD_ZERO;\n\ dt->shared->u.atomic.msb_pad = H5T_PAD_ZERO;\n", d[i].msize ? "FLOAT" : "INTEGER",/*class */ d[i].size, /*size */ byte_order ? "BE" : "LE", /*byte order */ d[i].offset, /*offset */ d[i].precision); /*precision */ assert((d[i].perm[0]>0)==(byte_order>0)); /* Double-check that byte-order doesn't change */ if (0 == d[i].msize) { /* The part unique to fixed point types */ printf("\ dt->shared->u.atomic.u.i.sign = H5T_SGN_%s;\n", d[i].sign ? "2" : "NONE"); } else { /* The part unique to floating point types */ printf("\ dt->shared->u.atomic.u.f.sign = %d;\n\ dt->shared->u.atomic.u.f.epos = %d;\n\ dt->shared->u.atomic.u.f.esize = %d;\n\ dt->shared->u.atomic.u.f.ebias = 0x%08lx;\n\ dt->shared->u.atomic.u.f.mpos = %d;\n\ dt->shared->u.atomic.u.f.msize = %d;\n\ dt->shared->u.atomic.u.f.norm = H5T_NORM_%s;\n\ dt->shared->u.atomic.u.f.pad = H5T_PAD_ZERO;\n", d[i].sign, /*sign location */ d[i].epos, /*exponent loc */ d[i].esize, /*exponent size */ (unsigned long)(d[i].bias), /*exponent bias */ d[i].mpos, /*mantissa loc */ d[i].msize, /*mantissa size */ d[i].imp ? "IMPLIED" : "NONE"); /*normalization */ } /* Atomize the type */ printf("\ if ((H5T_NATIVE_%s_g = H5I_register (H5I_DATATYPE, dt))<0)\n\ HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,\"can't initialize type system (atom registration failure\");\n", d[i].varname); printf(" H5T_NATIVE_%s_ALIGN_g = %lu;\n", d[i].varname, (unsigned long)(d[i].align)); /* Variables for alignment of compound datatype */ if(!strcmp(d[i].varname, "SCHAR") || !strcmp(d[i].varname, "SHORT") || !strcmp(d[i].varname, "INT") || !strcmp(d[i].varname, "LONG") || !strcmp(d[i].varname, "LLONG") || !strcmp(d[i].varname, "FLOAT") || !strcmp(d[i].varname, "DOUBLE") || !strcmp(d[i].varname, "LDOUBLE")) { printf(" H5T_NATIVE_%s_COMP_ALIGN_g = %lu;\n", d[i].varname, (unsigned long)(d[i].comp_align)); } } printf("\n\ /* Set the native order for this machine */\n\ H5T_native_order_g = H5T_ORDER_%s;\n", byte_order ? "BE" : "LE"); /*byte order */ /* Structure alignment for pointers, hvl_t, hobj_ref_t, hdset_reg_ref_t */ printf("\n /* Structure alignment for pointers, hvl_t, hobj_ref_t, hdset_reg_ref_t */\n"); for(j=0; jshared != NULL)\n\ H5FL_FREE(H5T_shared_t, dt->shared);\n\ H5FL_FREE(H5T_t, dt);\n\ } /* end if */\n\ }\n\ \n\ FUNC_LEAVE_NOAPI(ret_value);\n}\n"); } /*------------------------------------------------------------------------- * Function: iprint * * Purpose: Prints information about the fields of a floating point * format. * * Return: void * * Programmer: Robb Matzke * matzke@llnl.gov * Jun 13, 1996 * * Modifications: * *------------------------------------------------------------------------- */ static void iprint(detected_t *d) { int i, j, k, pass; for (pass=(d->size-1)/4; pass>=0; --pass) { /* * Print the byte ordering above the bit fields. */ printf(" * "); for (i=MIN(pass*4+3,d->size-1); i>=pass*4; --i) { printf ("%4d", d->perm[i]); if (i>pass*4) fputs (" ", stdout); } /* * Print the bit fields */ printf("\n * "); for (i=MIN(pass*4+3,d->size-1), k=MIN(pass*32+31,8*d->size-1); i>=pass*4; --i) { for (j=7; j>=0; --j) { if (k==d->sign && d->msize) { putchar('S'); } else if (k>=d->epos && kepos+d->esize) { putchar('E'); } else if (k>=d->mpos && kmpos+d->msize) { putchar('M'); } else if (d->msize) { putchar('?'); /*unknown floating point bit */ } else if (d->sign) { putchar('I'); } else { putchar('U'); } --k; } if (i>pass*4) putchar(' '); } putchar('\n'); } /* * Is there an implicit bit in the mantissa. */ if (d->msize) { printf(" * Implicit bit? %s\n", d->imp ? "yes" : "no"); } /* * Alignment */ if (0==d->align) { printf(" * Alignment: NOT CALCULATED\n"); } else if (1==d->align) { printf(" * Alignment: none\n"); } else { printf(" * Alignment: %lu\n", (unsigned long)(d->align)); } } /*------------------------------------------------------------------------- * Function: byte_cmp * * Purpose: Compares two chunks of memory A and B and returns the * byte index into those arrays of the first byte that * differs between A and B. * * Return: Success: Index of differing byte. * * Failure: -1 if all bytes are the same. * * Programmer: Robb Matzke * matzke@llnl.gov * Jun 12, 1996 * * Modifications: * *------------------------------------------------------------------------- */ static int byte_cmp(int n, void *_a, void *_b) { register int i; unsigned char *a = (unsigned char *) _a; unsigned char *b = (unsigned char *) _b; for (i = 0; i < n; i++) if (a[i] != b[i]) return i; return -1; } /*------------------------------------------------------------------------- * Function: bit_cmp * * Purpose: Compares two bit vectors and returns the index for the * first bit that differs between the two vectors. The * size of the vector is NBYTES. PERM is a mapping from * actual order to little endian. * * Return: Success: Index of first differing bit. * * Failure: -1 * * Programmer: Robb Matzke * matzke@llnl.gov * Jun 13, 1996 * * Modifications: * *------------------------------------------------------------------------- */ static int bit_cmp(int nbytes, int *perm, void *_a, void *_b) { int i, j; unsigned char *a = (unsigned char *) _a; unsigned char *b = (unsigned char *) _b; unsigned char aa, bb; for (i = 0; i < nbytes; i++) { assert(perm[i] < nbytes); if ((aa = a[perm[i]]) != (bb = b[perm[i]])) { for (j = 0; j < 8; j++, aa >>= 1, bb >>= 1) { if ((aa & 1) != (bb & 1)) return i * 8 + j; } assert("INTERNAL ERROR" && 0); abort(); } } return -1; } /*------------------------------------------------------------------------- * Function: fix_order * * Purpose: Given an array PERM with elements FIRST through LAST * initialized with zero origin byte numbers, this function * creates a permutation vector that maps the actual order * of a floating point number to little-endian. * * This function assumes that the mantissa byte ordering * implies the total ordering. * * Return: void * * Programmer: Robb Matzke * matzke@llnl.gov * Jun 13, 1996 * * Modifications: * *------------------------------------------------------------------------- */ static void fix_order(int n, int first, int last, int *perm, const char **mesg) { int i; if (first + 1 < last) { /* * We have at least three points to consider. */ if (perm[last] < perm[last - 1] && perm[last - 1] < perm[last - 2]) { /* * Little endian. */ if (mesg) *mesg = "Little-endian"; for (i = 0; i < n; i++) perm[i] = i; } else if (perm[last] > perm[last-1] && perm[last-1] > perm[last-2]) { /* * Big endian. */ if (mesg) *mesg = "Big-endian"; for (i = 0; i < n; i++) perm[i] = (n - 1) - i; } else { /* * Bi-endian machines like VAX. */ assert(0 == n % 2); if (mesg) *mesg = "VAX"; for (i = 0; i < n; i += 2) { perm[i] = (n - 2) - i; perm[i + 1] = (n - 1) - i; } } } else { fprintf(stderr, "Failed to detect byte order of %d-byte floating point.\n", n); exit(1); } } /*------------------------------------------------------------------------- * Function: imp_bit * * Purpose: Looks for an implicit bit in the mantissa. The value * of _A should be 1.0 and the value of _B should be 0.5. * Some floating-point formats discard the most significant * bit of the mantissa after normalizing since it will always * be a one (except for 0.0). If this is true for the native * floating point values stored in _A and _B then the function * returns non-zero. * * This function assumes that the exponent occupies higher * order bits than the mantissa and that the most significant * bit of the mantissa is next to the least signficant bit * of the exponent. * * * Return: Success: Non-zero if the most significant bit * of the mantissa is discarded (ie, the * mantissa has an implicit `one' as the * most significant bit). Otherwise, * returns zero. * * Failure: exit(1) * * Programmer: Robb Matzke * matzke@llnl.gov * Jun 13, 1996 * * Modifications: * * Robb Matzke, 6 Nov 1996 * Fixed a bug that occurs with non-implicit architectures. * *------------------------------------------------------------------------- */ static int imp_bit(int n, int *perm, void *_a, void *_b) { unsigned char *a = (unsigned char *) _a; unsigned char *b = (unsigned char *) _b; int changed, major, minor; int msmb; /*most significant mantissa bit */ /* * Look for the least significant bit that has changed between * A and B. This is the least significant bit of the exponent. */ changed = bit_cmp(n, perm, a, b); assert(changed >= 0); /* * The bit to the right (less significant) of the changed bit should * be the most significant bit of the mantissa. If it is non-zero * then the format does not remove the leading `1' of the mantissa. */ msmb = changed - 1; major = msmb / 8; minor = msmb % 8; return (a[perm[major]] >> minor) & 0x01 ? 0 : 1; } /*------------------------------------------------------------------------- * Function: find_bias * * Purpose: Determines the bias of the exponent. This function should * be called with _A having a value of `1'. * * Return: Success: The exponent bias. * * Failure: * * Programmer: Robb Matzke * matzke@llnl.gov * Jun 13, 1996 * * Modifications: * * Robb Matzke, 6 Nov 1996 * Fixed a bug with non-implicit architectures returning the * wrong exponent bias. * *------------------------------------------------------------------------- */ static unsigned long find_bias(int epos, int esize, int *perm, void *_a) { unsigned char *a = (unsigned char *) _a; unsigned char mask; unsigned long b, shift = 0, nbits, bias = 0; while (esize > 0) { nbits = MIN(esize, (8 - epos % 8)); mask = (1 << nbits) - 1; b = (a[perm[epos / 8]] >> (epos % 8)) & mask; bias |= b << shift; shift += nbits; esize -= nbits; epos += nbits; } return bias; } /*------------------------------------------------------------------------- * Function: print_header * * Purpose: Prints the C file header for the generated file. * * Return: void * * Programmer: Robb Matzke * matzke@llnl.gov * Mar 12 1997 * * Modifications: * *------------------------------------------------------------------------- */ static void print_header(void) { time_t now = time(NULL); struct tm *tm = localtime(&now); char real_name[30]; char host_name[256]; int i; const char *s; #ifdef H5_HAVE_GETPWUID struct passwd *pwd = NULL; #else int pwd = 1; #endif static const char *month_name[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; static const char *purpose = "\ This machine-generated source code contains\n\ information about the various integer and\n\ floating point numeric formats found on this\n\ architecture. The parameters below should be\n\ checked carefully and errors reported to the\n\ HDF5 maintainer.\n\ \n\ Each of the numeric formats listed below are\n\ printed from most significant bit to least\n\ significant bit even though the actual bytes\n\ might be stored in a different order in\n\ memory. The integers above each binary byte\n\ indicate the relative order of the bytes in\n\ memory; little-endian machines have\n\ decreasing numbers while big-endian machines\n\ have increasing numbers.\n\ \n\ The fields of the numbers are printed as\n\ letters with `S' for the mantissa sign bit,\n\ `M' for the mantissa magnitude, and `E' for\n\ the exponent. The exponent has an associated\n\ bias which can be subtracted to find the\n\ true exponent. The radix point is assumed\n\ to be before the first `M' bit. Any bit\n\ of a floating-point value not falling into one\n\ of these categories is printed as a question\n\ mark. Bits of integer types are printed as\n\ `I' for 2's complement and `U' for magnitude.\n\ \n\ If the most significant bit of the normalized\n\ mantissa (always a `1' except for `0.0') is\n\ not stored then an `implicit=yes' appears\n\ under the field description. In thie case,\n\ the radix point is still assumed to be\n\ before the first `M' but after the implicit\n\ bit.\n"; /* * The real name is the first item from the passwd gecos field. */ #ifdef H5_HAVE_GETPWUID { size_t n; char *comma; if ((pwd = getpwuid(getuid()))) { if ((comma = strchr(pwd->pw_gecos, ','))) { n = MIN(sizeof(real_name)-1, (unsigned)(comma-pwd->pw_gecos)); strncpy(real_name, pwd->pw_gecos, n); real_name[n] = '\0'; } else { strncpy(real_name, pwd->pw_gecos, sizeof(real_name)); real_name[sizeof(real_name) - 1] = '\0'; } } else { real_name[0] = '\0'; } } #else real_name[0] = '\0'; #endif /* * The FQDM of this host or the empty string. */ #ifdef H5_HAVE_GETHOSTNAME #ifdef WIN32 /* windows DLL cannot recognize gethostname, so turn off on windows for the time being! KY, 2003-1-14 */ host_name[0] = '\0'; #else if (gethostname(host_name, sizeof(host_name)) < 0) { host_name[0] = '\0'; } #endif #else host_name[0] = '\0'; #endif /* * The file header: warning, copyright notice, build information. */ printf("/* Generated automatically by H5detect -- do not edit */\n\n\n"); puts(FileHeader); /*the copyright notice--see top of this file */ printf(" *\n * Created:\t\t%s %2d, %4d\n", month_name[tm->tm_mon], tm->tm_mday, 1900 + tm->tm_year); if (pwd || real_name[0] || host_name[0]) { printf(" *\t\t\t"); if (real_name[0]) printf("%s <", real_name); #ifdef H5_HAVE_GETPWUID if (pwd) fputs(pwd->pw_name, stdout); #endif if (host_name[0]) printf("@%s", host_name); if (real_name[0]) printf(">"); putchar('\n'); } printf(" *\n * Purpose:\t\t"); for (s = purpose; *s; s++) { putchar(*s); if ('\n' == *s && s[1]) printf(" *\t\t\t"); } printf(" *\n * Modifications:\n *\n"); printf(" *\tDO NOT MAKE MODIFICATIONS TO THIS FILE!\n"); printf(" *\tIt was generated by code in `H5detect.c'.\n"); printf(" *\n *"); for (i = 0; i < 73; i++) putchar('-'); printf("\n */\n\n"); } /*------------------------------------------------------------------------- * Function: detect_C89_integers * * Purpose: Detect C89 integer types * * Return: void * * Programmer: Albert Cheng * 2004/05/20 * * Modifications: * *------------------------------------------------------------------------- */ static void detect_C89_integers(void) { DETECT_I(signed char, SCHAR, d_g[nd_g]); nd_g++; DETECT_I(unsigned char, UCHAR, d_g[nd_g]); nd_g++; DETECT_I(short, SHORT, d_g[nd_g]); nd_g++; DETECT_I(unsigned short, USHORT, d_g[nd_g]); nd_g++; DETECT_I(int, INT, d_g[nd_g]); nd_g++; DETECT_I(unsigned int, UINT, d_g[nd_g]); nd_g++; DETECT_I(long, LONG, d_g[nd_g]); nd_g++; DETECT_I(unsigned long, ULONG, d_g[nd_g]); nd_g++; } /*------------------------------------------------------------------------- * Function: detect_C89_floats * * Purpose: Detect C89 floating point types * * Return: void * * Programmer: Albert Cheng * 2004/05/20 * * Modifications: * *------------------------------------------------------------------------- */ static void detect_C89_floats(void) { DETECT_F(float, FLOAT, d_g[nd_g]); nd_g++; DETECT_F(double, DOUBLE, d_g[nd_g]); nd_g++; } /*------------------------------------------------------------------------- * Function: detect_C99_integers8 * * Purpose: Detect C99 8 bit integer types * * Return: void * * Programmer: Albert Cheng * 2004/05/20 * * Modifications: * *------------------------------------------------------------------------- */ static void detect_C99_integers8(void) { #if H5_SIZEOF_INT8_T>0 DETECT_I(int8_t, INT8, d_g[nd_g]); nd_g++; #endif #if H5_SIZEOF_UINT8_T>0 DETECT_I(uint8_t, UINT8, d_g[nd_g]); nd_g++; #endif #if H5_SIZEOF_INT_LEAST8_T>0 DETECT_I(int_least8_t, INT_LEAST8, d_g[nd_g]); nd_g++; #endif #if H5_SIZEOF_UINT_LEAST8_T>0 DETECT_I(uint_least8_t, UINT_LEAST8, d_g[nd_g]); nd_g++; #endif #if H5_SIZEOF_INT_FAST8_T>0 DETECT_I(int_fast8_t, INT_FAST8, d_g[nd_g]); nd_g++; #endif #if H5_SIZEOF_UINT_FAST8_T>0 DETECT_I(uint_fast8_t, UINT_FAST8, d_g[nd_g]); nd_g++; #endif } /*------------------------------------------------------------------------- * Function: detect_C99_integers16 * * Purpose: Detect C99 16 bit integer types * * Return: void * * Programmer: Albert Cheng * 2004/05/20 * * Modifications: * *------------------------------------------------------------------------- */ static void detect_C99_integers16(void) { #if H5_SIZEOF_INT16_T>0 DETECT_I(int16_t, INT16, d_g[nd_g]); nd_g++; #endif #if H5_SIZEOF_UINT16_T>0 DETECT_I(uint16_t, UINT16, d_g[nd_g]); nd_g++; #endif #if H5_SIZEOF_INT_LEAST16_T>0 DETECT_I(int_least16_t, INT_LEAST16, d_g[nd_g]); nd_g++; #endif #if H5_SIZEOF_UINT_LEAST16_T>0 DETECT_I(uint_least16_t, UINT_LEAST16, d_g[nd_g]); nd_g++; #endif #if H5_SIZEOF_INT_FAST16_T>0 DETECT_I(int_fast16_t, INT_FAST16, d_g[nd_g]); nd_g++; #endif #if H5_SIZEOF_UINT_FAST16_T>0 DETECT_I(uint_fast16_t, UINT_FAST16, d_g[nd_g]); nd_g++; #endif } /*------------------------------------------------------------------------- * Function: detect_C99_integers32 * * Purpose: Detect C99 32 bit integer types * * Return: void * * Programmer: Albert Cheng * 2004/05/20 * * Modifications: * *------------------------------------------------------------------------- */ static void detect_C99_integers32(void) { #if H5_SIZEOF_INT32_T>0 DETECT_I(int32_t, INT32, d_g[nd_g]); nd_g++; #endif #if H5_SIZEOF_UINT32_T>0 DETECT_I(uint32_t, UINT32, d_g[nd_g]); nd_g++; #endif #if H5_SIZEOF_INT_LEAST32_T>0 DETECT_I(int_least32_t, INT_LEAST32, d_g[nd_g]); nd_g++; #endif #if H5_SIZEOF_UINT_LEAST32_T>0 DETECT_I(uint_least32_t, UINT_LEAST32, d_g[nd_g]); nd_g++; #endif #if H5_SIZEOF_INT_FAST32_T>0 DETECT_I(int_fast32_t, INT_FAST32, d_g[nd_g]); nd_g++; #endif #if H5_SIZEOF_UINT_FAST32_T>0 DETECT_I(uint_fast32_t, UINT_FAST32, d_g[nd_g]); nd_g++; #endif } /*------------------------------------------------------------------------- * Function: detect_C99_integers64 * * Purpose: Detect C99 64 bit integer types * * Return: void * * Programmer: Albert Cheng * 2004/05/20 * * Modifications: * *------------------------------------------------------------------------- */ static void detect_C99_integers64(void) { #if H5_SIZEOF_INT64_T>0 DETECT_I(int64_t, INT64, d_g[nd_g]); nd_g++; #endif #if H5_SIZEOF_UINT64_T>0 DETECT_I(uint64_t, UINT64, d_g[nd_g]); nd_g++; #endif #if H5_SIZEOF_INT_LEAST64_T>0 DETECT_I(int_least64_t, INT_LEAST64, d_g[nd_g]); nd_g++; #endif #if H5_SIZEOF_UINT_LEAST64_T>0 DETECT_I(uint_least64_t, UINT_LEAST64, d_g[nd_g]); nd_g++; #endif #if H5_SIZEOF_INT_FAST64_T>0 DETECT_I(int_fast64_t, INT_FAST64, d_g[nd_g]); nd_g++; #endif #if H5_SIZEOF_UINT_FAST64_T>0 DETECT_I(uint_fast64_t, UINT_FAST64, d_g[nd_g]); nd_g++; #endif #if H5_SIZEOF_LONG_LONG>0 DETECT_I(long_long, LLONG, d_g[nd_g]); nd_g++; DETECT_I(unsigned long_long, ULLONG, d_g[nd_g]); nd_g++; #else /* * This architecture doesn't support an integer type larger than `long' * so we'll just make H5T_NATIVE_LLONG the same as H5T_NATIVE_LONG since * `long long' is probably equivalent to `long' here anyway. */ DETECT_I(long, LLONG, d_g[nd_g]); nd_g++; DETECT_I(unsigned long, ULLONG, d_g[nd_g]); nd_g++; #endif } /*------------------------------------------------------------------------- * Function: detect_C99_integers * * Purpose: Detect C99 integer types * * Return: void * * Programmer: Albert Cheng * 2004/05/20 * * Modifications: * *------------------------------------------------------------------------- */ static void detect_C99_integers(void) { /* break it down to more subroutines so that each module subroutine */ /* is smaller and takes less time to compile with optimization on. */ detect_C99_integers8(); detect_C99_integers16(); detect_C99_integers32(); detect_C99_integers64(); } /*------------------------------------------------------------------------- * Function: detect_C99_floats * * Purpose: Detect C99 floating point types * * Return: void * * Programmer: Albert Cheng * 2004/05/20 * * Modifications: * *------------------------------------------------------------------------- */ static void detect_C99_floats(void) { #if H5_SIZEOF_DOUBLE == H5_SIZEOF_LONG_DOUBLE /* * If sizeof(double)==sizeof(long double) then assume that `long double' * isn't supported and use `double' instead. This suppresses warnings on * some systems and `long double' is probably the same as `double' here * anyway. */ DETECT_F(double, LDOUBLE, d_g[nd_g]); nd_g++; #elif H5_SIZEOF_LONG_DOUBLE !=0 DETECT_F(long double, LDOUBLE, d_g[nd_g]); nd_g++; #endif } /*------------------------------------------------------------------------- * Function: detect_alignments * * Purpose: Detect structure alignments * * Return: void * * Programmer: Albert Cheng * 2004/05/20 * * Modifications: * *------------------------------------------------------------------------- */ static void detect_alignments(void) { /* Detect structure alignment for pointers, hvl_t, hobj_ref_t, hdset_reg_ref_t */ DETECT_M(void *, POINTER, m_g[na_g]); na_g++; DETECT_M(hvl_t, HVL, m_g[na_g]); na_g++; DETECT_M(hobj_ref_t, HOBJREF, m_g[na_g]); na_g++; DETECT_M(hdset_reg_ref_t, HDSETREGREF, m_g[na_g]); na_g++; } /*------------------------------------------------------------------------- * Function: main * * Purpose: Main entry point. * * Return: Success: exit(0) * * Failure: exit(1) * * Programmer: Robb Matzke * matzke@llnl.gov * Jun 12, 1996 * * Modifications: * Albert Cheng, 2004/05/20 * Some compilers, e.g., Intel C v7.0, took a long time to compile * with optimization when a module routine contains many code lines. * Divide up all those types detections macros into subroutines, both * to avoid the compiler optimization error and cleaner codes. * *------------------------------------------------------------------------- */ int main(void) { #if defined(H5_HAVE_SETSYSINFO) && defined(SSI_NVPAIRS) #if defined(UAC_NOPRINT) && defined(UAC_SIGBUS) /* * Make sure unaligned access generates SIGBUS and doesn't print warning * messages so that we can detect alignment constraints on the DEC Alpha. */ int nvpairs[2]; nvpairs[0] = SSIN_UACPROC; nvpairs[1] = UAC_NOPRINT | UAC_SIGBUS; if (setsysinfo(SSI_NVPAIRS, nvpairs, 1, 0, 0)<0) { fprintf(stderr, "H5detect: unable to turn off UAC handling: %s\n", strerror(errno)); } #endif #endif print_header(); /* C89 integer types */ detect_C89_integers(); /* C99 integer types */ detect_C99_integers(); /* C89 floating point types */ detect_C89_floats(); /* C99 floating point types */ detect_C99_floats(); /* Detect structure alignment */ detect_alignments(); print_results (nd_g, d_g, na_g, m_g); return 0; } xdmf-3.0+git20160803/Utilities/hdf5/H5RS.c0000640000175000017500000003127013003006557017563 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Reference counted string algorithms. * * These are used for various internal strings which get copied multiple times. * */ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free lists */ #include "H5RSprivate.h" /* Reference-counted strings */ /* Private typedefs & structs */ struct H5RS_str_t { char *s; /* String to be reference counted */ unsigned wrapped; /* Indicates that the string to be ref-counted is not copied */ unsigned n; /* Reference count of number of pointers sharing string */ }; /* Declare a free list to manage the H5RS_str_t struct */ H5FL_DEFINE_STATIC(H5RS_str_t); /* Declare the PQ free list for the wrapped strings */ H5FL_BLK_DEFINE(str_buf); /*-------------------------------------------------------------------------- NAME H5RS_xstrdup PURPOSE Duplicate the string being reference counted USAGE char *H5RS_xstrdup(s) const char *s; IN: String to duplicate RETURNS Returns a pointer to a new string on success, NULL on failure. DESCRIPTION Duplicate a string buffer being reference counted. Use this instead of [H5MM_][x]strdup, in order to use the free-list memory routines. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static char * H5RS_xstrdup(const char *s) { char *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5RS_xstrdup); if (s) { ret_value = H5FL_BLK_MALLOC(str_buf,HDstrlen(s) + 1); assert (ret_value); HDstrcpy(ret_value, s); } /* end if */ else ret_value=NULL; FUNC_LEAVE_NOAPI(ret_value); } /* end H5RS_xstrdup() */ /*-------------------------------------------------------------------------- NAME H5RS_create PURPOSE Create a reference counted string USAGE H5RS_str_t *H5RS_create(s) const char *s; IN: String to initialize ref-counted string with RETURNS Returns a pointer to a new ref-counted string on success, NULL on failure. DESCRIPTION Create a reference counted string. The string passed in is copied into an internal buffer. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ H5RS_str_t * H5RS_create(const char *s) { H5RS_str_t *ret_value=NULL; /* Return value */ FUNC_ENTER_NOAPI(H5RS_create,NULL); /* Allocate ref-counted string structure */ if((ret_value=H5FL_MALLOC(H5RS_str_t))==NULL) HGOTO_ERROR(H5E_RS,H5E_NOSPACE,NULL,"memory allocation failed"); /* Set the internal fields */ ret_value->s=H5RS_xstrdup(s); ret_value->wrapped=0; ret_value->n=1; done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5RS_create() */ /*-------------------------------------------------------------------------- NAME H5RS_wrap PURPOSE "Wrap" a reference counted string around an existing string USAGE H5RS_str_t *H5RS_wrap(s) const char *s; IN: String to wrap ref-counted string around RETURNS Returns a pointer to a new ref-counted string on success, NULL on failure. DESCRIPTION Wrap a reference counted string around an existing string, which is not duplicated, unless its reference count gets incremented. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ H5RS_str_t * H5RS_wrap(const char *s) { H5RS_str_t *ret_value=NULL; /* Return value */ FUNC_ENTER_NOAPI(H5RS_wrap,NULL); /* Allocate ref-counted string structure */ if((ret_value=H5FL_MALLOC(H5RS_str_t))==NULL) HGOTO_ERROR(H5E_RS,H5E_NOSPACE,NULL,"memory allocation failed"); /* Set the internal fields */ ret_value->s=(char*)s; ret_value->wrapped=1; ret_value->n=1; done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5RS_wrap() */ /*-------------------------------------------------------------------------- NAME H5RS_own PURPOSE Transfer ownership of a regular string to a reference counted string USAGE H5RS_str_t *H5RS_own(s) const char *s; IN: String to transfer ownership of RETURNS Returns a pointer to a new ref-counted string on success, NULL on failure. DESCRIPTION Transfer ownership of a dynamically allocated string to a reference counted string. The routine which passed in the string should not attempt to free it, the reference counting string routines will do that when the reference count drops to zero. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ H5RS_str_t * H5RS_own(char *s) { H5RS_str_t *ret_value=NULL; /* Return value */ FUNC_ENTER_NOAPI(H5RS_own,NULL); /* Allocate ref-counted string structure */ if((ret_value=H5FL_MALLOC(H5RS_str_t))==NULL) HGOTO_ERROR(H5E_RS,H5E_NOSPACE,NULL,"memory allocation failed"); /* Set the internal fields */ ret_value->s=s; ret_value->wrapped=0; ret_value->n=1; done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5RS_own() */ /*-------------------------------------------------------------------------- NAME H5RS_decr PURPOSE Decrement the reference count for a ref-counted string USAGE herr_t H5RS_decr(rs) H5RS_str_t *rs; IN/OUT: Ref-counted string to decrement count of RETURNS Non-negative on success/Negative on failure DESCRIPTION Decrement the reference count for a reference counted string. If the reference count drops to zero, the reference counted string is deleted. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5RS_decr(H5RS_str_t *rs) { FUNC_ENTER_NOAPI_NOFUNC(H5RS_decr); /* Sanity check */ assert(rs); assert(rs->n > 0); /* Decrement reference count for string */ if((--rs->n)==0) { if(!rs->wrapped) H5FL_BLK_FREE(str_buf,rs->s); H5FL_FREE(H5RS_str_t,rs); } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED); } /* end H5RS_decr() */ /*-------------------------------------------------------------------------- NAME H5RS_incr PURPOSE Increment the reference count for a ref-counted string USAGE herr_t H5RS_incr(rs) H5RS_str_t *rs; IN/OUT: Ref-counted string to increment count of RETURNS Non-negative on success/Negative on failure DESCRIPTION Increment the reference count for a reference counted string. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5RS_incr(H5RS_str_t *rs) { FUNC_ENTER_NOAPI_NOFUNC(H5RS_incr); /* Sanity check */ assert(rs); assert(rs->n > 0); /* If the ref-counted string started life as a wrapper around an existing * string, duplicate the string now, so that the wrapped string can go out * scope appropriately. */ if(rs->wrapped) { rs->s=H5RS_xstrdup(rs->s); rs->wrapped=0; } /* end if */ /* Increment reference count for string */ rs->n++; FUNC_LEAVE_NOAPI(SUCCEED); } /* end H5RS_incr() */ /*-------------------------------------------------------------------------- NAME H5RS_dup PURPOSE "Duplicate" a ref-counted string USAGE H5RS_str_t H5RS_incr(rs) H5RS_str_t *rs; IN/OUT: Ref-counted string to "duplicate" RETURNS Returns a pointer to ref-counted string on success, NULL on failure. DESCRIPTION Increment the reference count for the reference counted string and return a pointer to it. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ H5RS_str_t * H5RS_dup(H5RS_str_t *ret_value) { FUNC_ENTER_NOAPI_NOFUNC(H5RS_dup); /* Check for valid reference counted string */ if(ret_value!=NULL) /* Increment reference count for string */ ret_value->n++; FUNC_LEAVE_NOAPI(ret_value); } /* end H5RS_dup() */ /*-------------------------------------------------------------------------- NAME H5RS_cmp PURPOSE Compare two ref-counted strings USAGE int H5RS_cmp(rs1,rs2) const H5RS_str_t *rs1; IN: First Ref-counted string to compare const H5RS_str_t *rs2; IN: Second Ref-counted string to compare RETURNS Returns positive, negative or 0 for comparison of two r-strings [same as strcmp()] DESCRIPTION Compare two ref-counted strings and return a value indicating their sort order [same as strcmp()] GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ int H5RS_cmp(const H5RS_str_t *rs1, const H5RS_str_t *rs2) { /* Can't return invalid value from this function */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5RS_cmp); /* Sanity check */ assert(rs1); assert(rs1->s); assert(rs2); assert(rs2->s); FUNC_LEAVE_NOAPI(HDstrcmp(rs1->s,rs2->s)); } /* end H5RS_cmp() */ /*-------------------------------------------------------------------------- NAME H5RS_len PURPOSE Compute the length of a ref-counted string USAGE ssize_t H5RS_cmp(rs) const H5RS_str_t *rs; IN: Ref-counted string to compute length of RETURNS Returns non-negative value on success, negative value on failure DESCRIPTION Compute the length of a ref-counted string. [same as strlen()] GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ ssize_t H5RS_len(const H5RS_str_t *rs) { FUNC_ENTER_NOAPI_NOFUNC(H5RS_len); /* Sanity check */ assert(rs); assert(rs->s); FUNC_LEAVE_NOAPI((ssize_t)HDstrlen(rs->s)); } /* end H5RS_len() */ /*-------------------------------------------------------------------------- NAME H5RS_get_str PURPOSE Get a pointer to the internal string contained in a ref-counted string USAGE char *H5RS_get_str(rs) const H5RS_str_t *rs; IN: Ref-counted string to get internal string from RETURNS Returns a pointer to the internal string being ref-counted on success, NULL on failure. DESCRIPTION Gets a pointer to the internal string being reference counted. This pointer is volatile and might be invalid is further calls to the H5RS API are made. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ char * H5RS_get_str(const H5RS_str_t *rs) { FUNC_ENTER_NOAPI_NOFUNC(H5RS_get_str); /* Sanity check */ assert(rs); assert(rs->s); FUNC_LEAVE_NOAPI(rs->s); } /* end H5RS_get_str() */ /*-------------------------------------------------------------------------- NAME H5RS_get_count PURPOSE Get the reference count for a ref-counted string USAGE unsigned H5RS_get_count(rs) const H5RS_str_t *rs; IN: Ref-counted string to get internal count from RETURNS Returns the number of references to the internal string being ref-counted on success, 0 on failure. DESCRIPTION Gets the count of references to the reference counted string. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ unsigned H5RS_get_count(const H5RS_str_t *rs) { FUNC_ENTER_NOAPI_NOFUNC(H5RS_get_count); /* Sanity check */ assert(rs); assert(rs->n>0); FUNC_LEAVE_NOAPI(rs->n); } /* end H5RS_get_count() */ xdmf-3.0+git20160803/Utilities/hdf5/H5api_adpt.h0000640000175000017500000000640313003006557021025 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * H5api_adpt.h * Used for the HDF5 dll project * Created by Patrick Lu on 1/12/99 */ #ifndef H5API_ADPT_H #define H5API_ADPT_H #if defined(WIN32) #if defined(_HDF5DLL_) #pragma warning(disable: 4273) /* Disable the dll linkage warnings */ #define H5_DLL __declspec(dllexport) #define H5_DLLVAR extern __declspec(dllexport) #elif defined(_HDF5USEDLL_) #define H5_DLL __declspec(dllimport) #define H5_DLLVAR __declspec(dllimport) #else #define H5_DLL #define H5_DLLVAR extern #endif /* _HDF5DLL_ */ #if defined(_HDF5TESTDLL_) #pragma warning(disable: 4273) /* Disable the dll linkage warnings */ #define H5TEST_DLL __declspec(dllexport) #define H5TEST_DLLVAR extern __declspec(dllexport) #elif defined(_HDF5TESTUSEDLL_) #define H5TEST_DLL __declspec(dllimport) #define H5TEST_DLLVAR __declspec(dllimport) #else #define H5TEST_DLL #define H5TEST_DLLVAR extern #endif /* _HDF5TESTDLL_ */ #if defined(HDF5FORT_CSTUB_DLL_EXPORTS) #pragma warning(disable: 4273) /* Disable the dll linkage warnings */ #define H5_FCDLL __declspec(dllexport) #define H5_FCDLLVAR extern __declspec(dllexport) #elif defined(HDF5FORT_CSTUB_USEDLL) #define H5_FCDLL __declspec(dllimport) #define H5_FCDLLVAR __declspec(dllimport) #else #define H5_FCDLL #define H5_FCDLLVAR extern #endif /* _HDF5_FORTRANDLL_EXPORTS_ */ #if defined(HDF5FORTTEST_CSTUB_DLL_EXPORTS) #pragma warning(disable: 4273) /* Disable the dll linkage warnings */ #define H5_FCTESTDLL __declspec(dllexport) #define H5_FCTESTDLLVAR extern __declspec(dllexport) #elif defined(HDF5FORTTEST_CSTUB_USEDLL) #define H5_FCTESTDLL __declspec(dllimport) #define H5_FCTESTDLLVAR __declspec(dllimport) #else #define H5_FCTESTDLL #define H5_FCTESTDLLVAR extern #endif /* _HDF5_FORTRANDLL_EXPORTS_ */ /* Added to export or to import C++ APIs - BMR (02-15-2002) */ #if defined(HDF5_CPPDLL_EXPORTS) /* this name is generated at creation */ #define H5_DLLCPP __declspec(dllexport) #elif defined(HDF5CPP_USEDLL) #define H5_DLLCPP __declspec(dllimport) #else #define H5_DLLCPP #endif /* HDF5_CPPDLL_EXPORTS */ #else /*WIN32*/ #define H5_DLL #define H5_DLLVAR extern #define H5_DLLCPP #define H5TEST_DLL #define H5TEST_DLLVAR extern #define H5_FCDLL #define H5_FCDLLVAR extern #define H5_FCTESTDLL #define H5_FCTESTDLLVAR extern #endif #endif /* H5API_ADPT_H */ xdmf-3.0+git20160803/Utilities/hdf5/H5FDpublic.h0000640000175000017500000002733013003006557020736 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Robb Matzke * Monday, July 26, 1999 */ #ifndef _H5FDpublic_H #define _H5FDpublic_H #include "H5public.h" #include "H5Fpublic.h" /*for H5F_close_degree_t */ #define H5_HAVE_VFL 1 /*define a convenient app feature test*/ #define H5FD_VFD_DEFAULT 0 /* Default VFL driver value */ /* * Types of allocation requests. The values larger than H5FD_MEM_DEFAULT * should not change other than adding new types to the end. These numbers * might appear in files. */ typedef enum H5FD_mem_t { H5FD_MEM_NOLIST = -1, /*must be negative*/ H5FD_MEM_DEFAULT = 0, /*must be zero*/ H5FD_MEM_SUPER = 1, H5FD_MEM_BTREE = 2, H5FD_MEM_DRAW = 3, H5FD_MEM_GHEAP = 4, H5FD_MEM_LHEAP = 5, H5FD_MEM_OHDR = 6, H5FD_MEM_NTYPES /*must be last*/ } H5FD_mem_t; /* * A free-list map which maps all types of allocation requests to a single * free list. This is useful for drivers that don't really care about * keeping different requests segregated in the underlying file and which * want to make most efficient reuse of freed memory. The use of the * H5FD_MEM_SUPER free list is arbitrary. */ #define H5FD_FLMAP_SINGLE { \ H5FD_MEM_SUPER, /*default*/ \ H5FD_MEM_SUPER, /*super*/ \ H5FD_MEM_SUPER, /*btree*/ \ H5FD_MEM_SUPER, /*draw*/ \ H5FD_MEM_SUPER, /*gheap*/ \ H5FD_MEM_SUPER, /*lheap*/ \ H5FD_MEM_SUPER /*ohdr*/ \ } /* * A free-list map which segregates requests into `raw' or `meta' data * pools. */ #define H5FD_FLMAP_DICHOTOMY { \ H5FD_MEM_SUPER, /*default*/ \ H5FD_MEM_SUPER, /*super*/ \ H5FD_MEM_SUPER, /*btree*/ \ H5FD_MEM_DRAW, /*draw*/ \ H5FD_MEM_SUPER, /*gheap*/ \ H5FD_MEM_SUPER, /*lheap*/ \ H5FD_MEM_SUPER /*ohdr*/ \ } /* * The default free list map which causes each request type to use it's own * free-list. */ #define H5FD_FLMAP_DEFAULT { \ H5FD_MEM_DEFAULT, /*default*/ \ H5FD_MEM_DEFAULT, /*super*/ \ H5FD_MEM_DEFAULT, /*btree*/ \ H5FD_MEM_DEFAULT, /*draw*/ \ H5FD_MEM_DEFAULT, /*gheap*/ \ H5FD_MEM_DEFAULT, /*lheap*/ \ H5FD_MEM_DEFAULT /*ohdr*/ \ } /* Define VFL driver features that can be enabled on a per-driver basis */ /* These are returned with the 'query' function pointer in H5FD_class_t */ /* * Defining the H5FD_FEAT_AGGREGATE_METADATA for a VFL driver means that * the library will attempt to allocate a larger block for metadata and * then sub-allocate each metadata request from that larger block. */ #define H5FD_FEAT_AGGREGATE_METADATA 0x00000001 /* * Defining the H5FD_FEAT_ACCUMULATE_METADATA for a VFL driver means that * the library will attempt to cache metadata as it is written to the file * and build up a larger block of metadata to eventually pass to the VFL * 'write' routine. * * Distinguish between updating the metadata accumulator on writes and * reads. This is particularly (perhaps only, even) important for MPI-I/O * where we guarantee that writes are collective, but reads may not be. * If we were to allow the metadata accumulator to be written during a * read operation, the application would hang. */ #define H5FD_FEAT_ACCUMULATE_METADATA_WRITE 0x00000002 #define H5FD_FEAT_ACCUMULATE_METADATA_READ 0x00000004 #define H5FD_FEAT_ACCUMULATE_METADATA (H5FD_FEAT_ACCUMULATE_METADATA_WRITE|H5FD_FEAT_ACCUMULATE_METADATA_READ) /* * Defining the H5FD_FEAT_DATA_SIEVE for a VFL driver means that * the library will attempt to cache raw data as it is read from/written to * a file in a "data seive" buffer. See Rajeev Thakur's papers: * http://www.mcs.anl.gov/~thakur/papers/romio-coll.ps.gz * http://www.mcs.anl.gov/~thakur/papers/mpio-high-perf.ps.gz */ #define H5FD_FEAT_DATA_SIEVE 0x00000008 /* * Defining the H5FD_FEAT_AGGREGATE_SMALLDATA for a VFL driver means that * the library will attempt to allocate a larger block for "small" raw data * and then sub-allocate "small" raw data requests from that larger block. */ #define H5FD_FEAT_AGGREGATE_SMALLDATA 0x00000010 /* Forward declaration */ typedef struct H5FD_t H5FD_t; /* Class information for each file driver */ typedef struct H5FD_class_t { const char *name; haddr_t maxaddr; H5F_close_degree_t fc_degree; hsize_t (*sb_size)(H5FD_t *file); herr_t (*sb_encode)(H5FD_t *file, char *name/*out*/, unsigned char *p/*out*/); herr_t (*sb_decode)(H5FD_t *f, const char *name, const unsigned char *p); size_t fapl_size; void * (*fapl_get)(H5FD_t *file); void * (*fapl_copy)(const void *fapl); herr_t (*fapl_free)(void *fapl); size_t dxpl_size; void * (*dxpl_copy)(const void *dxpl); herr_t (*dxpl_free)(void *dxpl); H5FD_t *(*open)(const char *name, unsigned flags, hid_t fapl, haddr_t maxaddr); herr_t (*close)(H5FD_t *file); int (*cmp)(const H5FD_t *f1, const H5FD_t *f2); herr_t (*query)(const H5FD_t *f1, unsigned long *flags); haddr_t (*alloc)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size); herr_t (*free)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size); haddr_t (*get_eoa)(H5FD_t *file); herr_t (*set_eoa)(H5FD_t *file, haddr_t addr); haddr_t (*get_eof)(H5FD_t *file); herr_t (*get_handle)(H5FD_t *file, hid_t fapl, void**file_handle); herr_t (*read)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl, haddr_t addr, size_t size, void *buffer); herr_t (*write)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl, haddr_t addr, size_t size, const void *buffer); herr_t (*flush)(H5FD_t *file, hid_t dxpl_id, unsigned closing); herr_t (*lock)(H5FD_t *file, unsigned char *oid, unsigned lock_type, hbool_t last); herr_t (*unlock)(H5FD_t *file, unsigned char *oid, hbool_t last); H5FD_mem_t fl_map[H5FD_MEM_NTYPES]; } H5FD_class_t; /* A free list is a singly-linked list of address/size pairs. */ typedef struct H5FD_free_t { haddr_t addr; hsize_t size; struct H5FD_free_t *next; } H5FD_free_t; /* * The main datatype for each driver. Public fields common to all drivers * are declared here and the driver appends private fields in memory. */ struct H5FD_t { hid_t driver_id; /*driver ID for this file */ const H5FD_class_t *cls; /*constant class info */ unsigned long fileno[2]; /* File serial number */ unsigned long feature_flags; /* VFL Driver feature Flags */ hsize_t threshold; /* Threshold for alignment */ hsize_t alignment; /* Allocation alignment */ hsize_t reserved_alloc; /* Space reserved for later alloc calls */ /* Metadata aggregation fields */ hsize_t def_meta_block_size; /* Metadata allocation * block size (if * aggregating metadata) */ hsize_t cur_meta_block_size; /* Current size of metadata * allocation region left */ haddr_t eoma; /* End of metadata * allocated region */ /* "Small data" aggregation fields */ hsize_t def_sdata_block_size; /* "Small data" * allocation block size * (if aggregating "small * data") */ hsize_t cur_sdata_block_size; /* Current size of "small * data" allocation * region left */ haddr_t eosda; /* End of "small data" * allocated region */ /* Metadata accumulator fields */ unsigned char *meta_accum; /* Buffer to hold the accumulated metadata */ haddr_t accum_loc; /* File location (offset) of the * accumulated metadata */ size_t accum_size; /* Size of the accumulated * metadata buffer used (in * bytes) */ size_t accum_buf_size; /* Size of the accumulated * metadata buffer allocated (in * bytes) */ unsigned accum_dirty; /* Flag to indicate that the * accumulated metadata is dirty */ haddr_t maxaddr; /* For this file, overrides class */ H5FD_free_t *fl[H5FD_MEM_NTYPES]; /* Freelist per allocation type */ hsize_t maxsize; /* Largest object on FL, or zero */ }; #ifdef __cplusplus extern "C" { #endif /* Function prototypes */ H5_DLL hid_t H5FDregister(const H5FD_class_t *cls); H5_DLL herr_t H5FDunregister(hid_t driver_id); H5_DLL H5FD_t *H5FDopen(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); H5_DLL herr_t H5FDclose(H5FD_t *file); H5_DLL int H5FDcmp(const H5FD_t *f1, const H5FD_t *f2); H5_DLL int H5FDquery(const H5FD_t *f, unsigned long *flags); H5_DLL haddr_t H5FDalloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size); H5_DLL herr_t H5FDfree(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size); H5_DLL haddr_t H5FDrealloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t old_size, hsize_t new_size); H5_DLL haddr_t H5FDget_eoa(H5FD_t *file); H5_DLL herr_t H5FDset_eoa(H5FD_t *file, haddr_t eof); H5_DLL haddr_t H5FDget_eof(H5FD_t *file); H5_DLL herr_t H5FDget_vfd_handle(H5FD_t *file, hid_t fapl, void**file_handle); H5_DLL herr_t H5FDread(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, void *buf/*out*/); H5_DLL herr_t H5FDwrite(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, const void *buf); H5_DLL herr_t H5FDflush(H5FD_t *file, hid_t dxpl_id, unsigned closing); #ifdef __cplusplus } #endif #endif xdmf-3.0+git20160803/Utilities/hdf5/H5Pfapl.c0000640000175000017500000015172213003006557020306 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #define H5P_PACKAGE /*suppress error about including H5Ppkg */ /* Private header files */ #include "H5private.h" /* Generic Functions */ #include "H5Dprivate.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fprivate.h" /* Files */ #include "H5FDprivate.h" /* File drivers */ #include "H5Iprivate.h" /* IDs */ #include "H5Ppkg.h" /* Property lists */ /* Default file driver - see H5Pget_driver() */ #include "H5FDsec2.h" /* Posix unbuffered I/O file driver */ /* Local datatypes */ /* Static function prototypes */ static herr_t H5P_set_family_offset(H5P_genplist_t *plist, hsize_t offset); static herr_t H5P_get_family_offset(H5P_genplist_t *plist, hsize_t *offset); static herr_t H5P_set_multi_type(H5P_genplist_t *plist, H5FD_mem_t type); static herr_t H5P_get_multi_type(H5P_genplist_t *plist, H5FD_mem_t *type); /*------------------------------------------------------------------------- * Function: H5Pset_alignment * * Purpose: Sets the alignment properties of a file access property list * so that any file object >= THRESHOLD bytes will be aligned on * an address which is a multiple of ALIGNMENT. The addresses * are relative to the end of the user block; the alignment is * calculated by subtracting the user block size from the * absolute file address and then adjusting the address to be a * multiple of ALIGNMENT. * * Default values for THRESHOLD and ALIGNMENT are one, implying * no alignment. Generally the default values will result in * the best performance for single-process access to the file. * For MPI-IO and other parallel systems, choose an alignment * which is a multiple of the disk block size. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Tuesday, June 9, 1998 * * Modifications: * * Raymond Lu * Tuesday, Oct 23, 2001 * Changed file access property list mechanism to the new * generic property list. *------------------------------------------------------------------------- */ herr_t H5Pset_alignment(hid_t fapl_id, hsize_t threshold, hsize_t alignment) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pset_alignment, FAIL); H5TRACE3("e","ihh",fapl_id,threshold,alignment); /* Check args */ if (alignment<1) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "alignment must be positive"); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Set values */ if(H5P_set(plist, H5F_ACS_ALIGN_THRHD_NAME, &threshold) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set threshold"); if(H5P_set(plist, H5F_ACS_ALIGN_NAME, &alignment) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set alignment"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Pget_alignment * * Purpose: Returns the current settings for alignment properties from a * file access property list. The THRESHOLD and/or ALIGNMENT * pointers may be null pointers. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Tuesday, June 9, 1998 * * Modifications: * * Raymond Lu * Tuesday, Oct 23, 2001 * Changed the file access list design to the new generic * property list. * *------------------------------------------------------------------------- */ herr_t H5Pget_alignment(hid_t fapl_id, hsize_t *threshold/*out*/, hsize_t *alignment/*out*/) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Pget_alignment, FAIL); H5TRACE3("e","ixx",fapl_id,threshold,alignment); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Get values */ if (threshold) if(H5P_get(plist, H5F_ACS_ALIGN_THRHD_NAME, threshold) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get threshold"); if (alignment) if(H5P_get(plist, H5F_ACS_ALIGN_NAME, alignment) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get alignment"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5P_set_driver * * Purpose: Set the file driver (DRIVER_ID) for a file access or data * transfer property list (PLIST_ID) and supply an optional * struct containing the driver-specific properites * (DRIVER_INFO). The driver properties will be copied into the * property list and the reference count on the driver will be * incremented, allowing the caller to close the driver ID but * still use the property list. * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Tuesday, August 3, 1999 * * Modifications: * * Raymond Lu * Tuesday, Oct 23, 2001 * Changed the file access list design to the new generic * property list. * *------------------------------------------------------------------------- */ herr_t H5P_set_driver(H5P_genplist_t *plist, hid_t new_driver_id, const void *new_driver_info) { hid_t driver_id; /* VFL driver ID */ void *driver_info; /* VFL driver info */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5P_set_driver, FAIL); if (NULL==H5I_object_verify(new_driver_id, H5I_VFL)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file driver ID"); if( TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS) ) { /* Get the current driver information */ if(H5P_get(plist, H5F_ACS_FILE_DRV_ID_NAME, &driver_id) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get driver ID"); if(H5P_get(plist, H5F_ACS_FILE_DRV_INFO_NAME, &driver_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL,"can't get driver info"); /* Close the driver for the property list */ if(H5FD_fapl_close(driver_id, driver_info)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't reset driver") /* Set the driver for the property list */ if(H5FD_fapl_open(plist, new_driver_id, new_driver_info)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set driver") } else if( TRUE == H5P_isa_class(plist->plist_id, H5P_DATASET_XFER) ) { /* Get the current driver information */ if(H5P_get(plist, H5D_XFER_VFL_ID_NAME, &driver_id)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve VFL driver ID"); if(H5P_get(plist, H5D_XFER_VFL_INFO_NAME, &driver_info)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve VFL driver info"); /* Close the driver for the property list */ if(H5FD_dxpl_close(driver_id, driver_info)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't reset driver") /* Set the driver for the property list */ if(H5FD_dxpl_open(plist, new_driver_id, new_driver_info)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set driver") } else { HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access or data transfer property list"); } done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5P_set_driver() */ /*------------------------------------------------------------------------- * Function: H5Pset_driver * * Purpose: Set the file driver (DRIVER_ID) for a file access or data * transfer property list (PLIST_ID) and supply an optional * struct containing the driver-specific properites * (DRIVER_INFO). The driver properties will be copied into the * property list and the reference count on the driver will be * incremented, allowing the caller to close the driver ID but * still use the property list. * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Tuesday, August 3, 1999 * * Modifications: * * Raymond Lu * Tuesday, Oct 23, 2001 * Changed the file access list design to the new generic * property list. * *------------------------------------------------------------------------- */ herr_t H5Pset_driver(hid_t plist_id, hid_t new_driver_id, const void *new_driver_info) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Pset_driver, FAIL); H5TRACE3("e","iix",plist_id,new_driver_id,new_driver_info); /* Check arguments */ if(NULL == (plist = H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); if (NULL==H5I_object_verify(new_driver_id, H5I_VFL)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file driver ID"); /* Set the driver */ if(H5P_set_driver(plist,new_driver_id,new_driver_info)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set driver info"); done: FUNC_LEAVE_API(ret_value); } /* end H5Pset_driver() */ /*------------------------------------------------------------------------- * Function: H5P_get_driver * * Purpose: Return the ID of the low-level file driver. PLIST_ID should * be a file access property list or data transfer propert list. * * Return: Success: A low-level driver ID which is the same ID * used when the driver was set for the property * list. The driver ID is only valid as long as * the file driver remains registered. * * Failure: Negative * * Programmer: Robb Matzke * Thursday, February 26, 1998 * * Modifications: * Robb Matzke, 1999-08-03 * Rewritten to use the virtual file layer. * * Robb Matzke, 1999-08-05 * If the driver ID is H5FD_VFD_DEFAULT then substitute the * current value of H5FD_SEC2. * * Quincey Koziol 2000-11-28 * Added internal function.. * * Raymond Lu, 2001-10-23 * Changed the file access list design to the new generic * property list. * *------------------------------------------------------------------------- */ hid_t H5P_get_driver(H5P_genplist_t *plist) { hid_t ret_value=FAIL; /* Return value */ FUNC_ENTER_NOAPI(H5P_get_driver, FAIL); /* Get the current driver ID */ if(TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS) ) { if(H5P_get(plist, H5F_ACS_FILE_DRV_ID_NAME, &ret_value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get driver ID"); } else if( TRUE == H5P_isa_class(plist->plist_id, H5P_DATASET_XFER) ) { if(H5P_get(plist, H5D_XFER_VFL_ID_NAME, &ret_value)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTGET, FAIL, "Can't retrieve VFL driver ID"); } else { HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access or data transfer property list"); } if (H5FD_VFD_DEFAULT==ret_value) ret_value = H5FD_SEC2; done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5Pget_driver * * Purpose: Return the ID of the low-level file driver. PLIST_ID should * be a file access property list or data transfer propert list. * * Return: Success: A low-level driver ID which is the same ID * used when the driver was set for the property * list. The driver ID is only valid as long as * the file driver remains registered. * * Failure: Negative * * Programmer: Robb Matzke * Thursday, February 26, 1998 * * Modifications: * Robb Matzke, 1999-08-03 * Rewritten to use the virtual file layer. * * Robb Matzke, 1999-08-05 * If the driver ID is H5FD_VFD_DEFAULT then substitute the current value of * H5FD_SEC2. * * Quincey Koziol 2000-11-28 * Added internal function.. *------------------------------------------------------------------------- */ hid_t H5Pget_driver(hid_t plist_id) { H5P_genplist_t *plist; /* Property list pointer */ hid_t ret_value; /* Return value */ FUNC_ENTER_API(H5Pget_driver, FAIL); H5TRACE1("i","i",plist_id); if(NULL == (plist = H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); ret_value = H5P_get_driver(plist); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5P_get_driver_info * * Purpose: Returns a pointer directly to the file driver-specific * information of a file access or data transfer property list. * * Return: Success: Ptr to *uncopied* driver specific data * structure if any. * * Failure: NULL. Null is also returned if the driver has * not registered any driver-specific properties * although no error is pushed on the stack in * this case. * * Programmer: Robb Matzke * Wednesday, August 4, 1999 * * Modifications: * * Raymond Lu * Tuesday, Oct 23, 2001 * Changed the file access list design to the new generic * property list. * *------------------------------------------------------------------------- */ void * H5P_get_driver_info(H5P_genplist_t *plist) { void *ret_value=NULL; FUNC_ENTER_NOAPI(H5P_get_driver_info, NULL); /* Get the current driver info */ if( TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS) ) { if(H5P_get(plist, H5F_ACS_FILE_DRV_INFO_NAME, &ret_value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,NULL,"can't get driver info"); } else if( TRUE == H5P_isa_class(plist->plist_id, H5P_DATASET_XFER) ) { if(H5P_get(plist, H5D_XFER_VFL_INFO_NAME, &ret_value)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTGET, NULL, "Can't retrieve VFL driver ID"); } else { HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access or data transfer property list"); } done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5P_get_driver_info() */ /*------------------------------------------------------------------------- * Function: H5Pget_driver_info * * Purpose: Returns a pointer directly to the file driver-specific * information of a file access or data transfer property list. * * Return: Success: Ptr to *uncopied* driver specific data * structure if any. * * Failure: NULL. Null is also returned if the driver has * not registered any driver-specific properties * although no error is pushed on the stack in * this case. * * Programmer: Robb Matzke * Wednesday, August 4, 1999 * * Modifications: * * Raymond Lu * Tuesday, Oct 23, 2001 * Changed the file access list design to the new generic * property list. * *------------------------------------------------------------------------- */ void * H5Pget_driver_info(hid_t plist_id) { H5P_genplist_t *plist; /* Property list pointer */ void *ret_value; /* Return value */ FUNC_ENTER_API(H5Pget_driver_info, NULL); if(NULL == (plist = H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a property list"); if((ret_value=H5P_get_driver_info(plist))==NULL) HGOTO_ERROR(H5E_PLIST,H5E_CANTGET,NULL,"can't get driver info"); done: FUNC_LEAVE_API(ret_value); } /* end H5Pget_driver_info() */ /*------------------------------------------------------------------------- * Function: H5Pset_family_offset * * Purpose: Set offset for family driver. This file access property * list will be passed to H5Fget_vfd_handle or H5FDget_vfd_handle * to retrieve VFD file handle. * * Return: Success: Non-negative value. * * Failure: Negative value. * * Programmer: Raymond Lu * Sep 17, 2002 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Pset_family_offset(hid_t fapl_id, hsize_t offset) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pset_family_offset, FAIL); H5TRACE2("e","ih",fapl_id,offset); /* Get the plist structure */ if(H5P_DEFAULT == fapl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't modify default property list"); if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Set values */ if((ret_value=H5P_set_family_offset(plist, offset)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set family offset"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5P_set_family_offset * * Purpose: Set offset for family driver. Private function for * H5Pset_family_offset * * Return: Success: Non-negative value. * * Failure: Negative value. * * Programmer: Raymond Lu * Sep 17, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5P_set_family_offset(H5P_genplist_t *plist, hsize_t offset) { herr_t ret_value=SUCCEED; FUNC_ENTER_NOAPI(H5P_set_family_offset, FAIL); if( TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS) ) { if(H5P_set(plist, H5F_ACS_FAMILY_OFFSET_NAME, &offset) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL,"can't set offset for family file"); } else { HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access or data transfer property list"); } done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5Pget_family_offset * * Purpose: Get offset for family driver. This file access property * list will be passed to H5Fget_vfd_handle or H5FDget_vfd_handle * to retrieve VFD file handle. * * Return: Success: Non-negative value. * * Failure: Negative value. * * Programmer: Raymond Lu * Sep 17, 2002 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Pget_family_offset(hid_t fapl_id, hsize_t *offset) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pget_family_offset, FAIL); H5TRACE2("e","i*h",fapl_id,offset); /* Get the plist structure */ if(H5P_DEFAULT == fapl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't modify default property list"); if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Set values */ if((ret_value=H5P_get_family_offset(plist, offset)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't get family offset"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5P_get_family_offset * * Purpose: Get offset for family driver. Private function for * H5Pget_family_offset * * Return: Success: Non-negative value. * * Failure: Negative value. * * Programmer: Raymond Lu * Sep 17, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5P_get_family_offset(H5P_genplist_t *plist, hsize_t *offset) { herr_t ret_value=SUCCEED; FUNC_ENTER_NOAPI(H5P_get_family_offset, FAIL); if( TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS) ) { if(H5P_get(plist, H5F_ACS_FAMILY_OFFSET_NAME, offset) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL,"can't set offset for family file"); } else { HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access or data transfer property list"); } done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5Pset_multi_type * * Purpose: Set data type for multi driver. This file access property * list will be passed to H5Fget_vfd_handle or H5FDget_vfd_handle * to retrieve VFD file handle. * * Return: Success: Non-negative value. * * Failure: Negative value. * * Programmer: Raymond Lu * Sep 17, 2002 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Pset_multi_type(hid_t fapl_id, H5FD_mem_t type) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pset_multi_type, FAIL); H5TRACE2("e","iMt",fapl_id,type); /* Get the plist structure */ if(H5P_DEFAULT == fapl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't modify default property list"); if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Set values */ if((ret_value=H5P_set_multi_type(plist, type)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set data type for multi driver"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5P_set_multi_type * * Purpose: Set data type for multi file driver. Private function for * H5Pset_multi_type. * * Return: Success: Non-negative value. * * Failure: Negative value. * * Programmer: Raymond Lu * Sep 17, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5P_set_multi_type(H5P_genplist_t *plist, H5FD_mem_t type) { herr_t ret_value=SUCCEED; FUNC_ENTER_NOAPI(H5P_set_multi_type, FAIL); if( TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS) ) { if(H5P_set(plist, H5F_ACS_MULTI_TYPE_NAME, &type) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL,"can't set type for multi driver"); } else { HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access or data transfer property list"); } done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5Pget_multi_type * * Purpose: Get data type for multi driver. This file access property * list will be passed to H5Fget_vfd_handle or H5FDget_vfd_handle * to retrieve VFD file handle. * * Return: Success: Non-negative value. * * Failure: Negative value. * * Programmer: Raymond Lu * Sep 17, 2002 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Pget_multi_type(hid_t fapl_id, H5FD_mem_t *type) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pget_multi_type, FAIL); H5TRACE2("e","i*Mt",fapl_id,type); /* Get the plist structure */ if(H5P_DEFAULT == fapl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't modify default property list"); if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Set values */ if((ret_value=H5P_get_multi_type(plist, type)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't get data type for multi driver"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5P_get_multi_type * * Purpose: Get data type for multi file driver. Private function for * H5Pget_multi_type. * * Return: Success: Non-negative value. * * Failure: Negative value. * * Programmer: Raymond Lu * Sep 17, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5P_get_multi_type(H5P_genplist_t *plist, H5FD_mem_t *type) { herr_t ret_value=SUCCEED; FUNC_ENTER_NOAPI(H5P_get_multi_type, FAIL); if( TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS) ) { if(H5P_get(plist, H5F_ACS_MULTI_TYPE_NAME, type) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL,"can't get type for multi driver"); } else { HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list"); } done: FUNC_LEAVE_NOAPI(ret_value); } #ifdef H5_WANT_H5_V1_4_COMPAT /*------------------------------------------------------------------------- * Function: H5Pset_cache * * Purpose: Set the number of objects in the meta data cache and the * maximum number of chunks and bytes in the raw data chunk * cache. * * The RDCC_W0 value should be between 0 and 1 inclusive and * indicates how much chunks that have been fully read or fully * written are favored for preemption. A value of zero means * fully read or written chunks are treated no differently than * other chunks (the preemption is strictly LRU) while a value * of one means fully read chunks are always preempted before * other chunks. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Tuesday, May 19, 1998 * * Modifications: * * Raymond Lu * Tuesday, Oct 23, 2001 * Changed the file access list to the new generic property list. * *------------------------------------------------------------------------- */ herr_t H5Pset_cache(hid_t plist_id, int mdc_nelmts, int _rdcc_nelmts, size_t rdcc_nbytes, double rdcc_w0) { H5P_genplist_t *plist; /* Property list pointer */ size_t rdcc_nelmts=(size_t)_rdcc_nelmts; /* Work around variable changing size */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pset_cache, FAIL); H5TRACE5("e","iIsIszd",plist_id,mdc_nelmts,_rdcc_nelmts,rdcc_nbytes, rdcc_w0); /* Check arguments */ if (mdc_nelmts<0) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "meta data cache size must be non-negative"); if (rdcc_w0<0.0 || rdcc_w0>1.0) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "raw data cache w0 value must be between 0.0 and 1.0 inclusive"); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Set sizes */ if(H5P_set(plist, H5F_ACS_META_CACHE_SIZE_NAME, &mdc_nelmts) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set meta data cache size"); if(H5P_set(plist, H5F_ACS_DATA_CACHE_ELMT_SIZE_NAME, &rdcc_nelmts) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set data cache element size"); if(H5P_set(plist, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, &rdcc_nbytes) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set data cache byte size"); if(H5P_set(plist, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, &rdcc_w0) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set preempt read chunks"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Pget_cache * * Purpose: Retrieves the maximum possible number of elements in the meta * data cache and the maximum possible number of elements and * bytes and the RDCC_W0 value in the raw data chunk cache. Any * (or all) arguments may be null pointers in which case the * corresponding datum is not returned. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Tuesday, May 19, 1998 * * Modifications: * * Raymond Lu * Tuesday, Oct 23, 2001 * Changed the file access list to the new generic property * list. * *------------------------------------------------------------------------- */ herr_t H5Pget_cache(hid_t plist_id, int *mdc_nelmts, int *_rdcc_nelmts, size_t *rdcc_nbytes, double *rdcc_w0) { H5P_genplist_t *plist; /* Property list pointer */ size_t rdcc_nelmts; /* Work around variable changing size */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pget_cache, FAIL); H5TRACE5("e","i*Is*Is*z*d",plist_id,mdc_nelmts,_rdcc_nelmts,rdcc_nbytes, rdcc_w0); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Get sizes */ if (mdc_nelmts) if(H5P_get(plist, H5F_ACS_META_CACHE_SIZE_NAME, mdc_nelmts) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get meta data cache size"); if (_rdcc_nelmts) { if(H5P_get(plist, H5F_ACS_DATA_CACHE_ELMT_SIZE_NAME, &rdcc_nelmts) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get data cache element size"); *_rdcc_nelmts=rdcc_nelmts; } /* end if */ if (rdcc_nbytes) if(H5P_get(plist, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, rdcc_nbytes) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get data cache byte size"); if (rdcc_w0) if(H5P_get(plist, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, rdcc_w0) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get preempt read chunks"); done: FUNC_LEAVE_API(ret_value); } #else /* H5_WANT_H5_V1_4_COMPAT */ /*------------------------------------------------------------------------- * Function: H5Pset_cache * * Purpose: Set the number of objects in the meta data cache and the * maximum number of chunks and bytes in the raw data chunk * cache. * * The RDCC_W0 value should be between 0 and 1 inclusive and * indicates how much chunks that have been fully read or fully * written are favored for preemption. A value of zero means * fully read or written chunks are treated no differently than * other chunks (the preemption is strictly LRU) while a value * of one means fully read chunks are always preempted before * other chunks. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Tuesday, May 19, 1998 * * Modifications: * * Raymond Lu * Tuesday, Oct 23, 2001 * Changed the file access list to the new generic property list. * *------------------------------------------------------------------------- */ herr_t H5Pset_cache(hid_t plist_id, int mdc_nelmts, size_t rdcc_nelmts, size_t rdcc_nbytes, double rdcc_w0) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pset_cache, FAIL); H5TRACE5("e","iIszzd",plist_id,mdc_nelmts,rdcc_nelmts,rdcc_nbytes,rdcc_w0); /* Check arguments */ if (mdc_nelmts<0) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "meta data cache size must be non-negative"); if (rdcc_w0<0.0 || rdcc_w0>1.0) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "raw data cache w0 value must be between 0.0 and 1.0 inclusive"); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Set sizes */ if(H5P_set(plist, H5F_ACS_META_CACHE_SIZE_NAME, &mdc_nelmts) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set meta data cache size"); if(H5P_set(plist, H5F_ACS_DATA_CACHE_ELMT_SIZE_NAME, &rdcc_nelmts) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set data cache element size"); if(H5P_set(plist, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, &rdcc_nbytes) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set data cache byte size"); if(H5P_set(plist, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, &rdcc_w0) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set preempt read chunks"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Pget_cache * * Purpose: Retrieves the maximum possible number of elements in the meta * data cache and the maximum possible number of elements and * bytes and the RDCC_W0 value in the raw data chunk cache. Any * (or all) arguments may be null pointers in which case the * corresponding datum is not returned. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Tuesday, May 19, 1998 * * Modifications: * * Raymond Lu * Tuesday, Oct 23, 2001 * Changed the file access list to the new generic property * list. * *------------------------------------------------------------------------- */ herr_t H5Pget_cache(hid_t plist_id, int *mdc_nelmts, size_t *rdcc_nelmts, size_t *rdcc_nbytes, double *rdcc_w0) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pget_cache, FAIL); H5TRACE5("e","i*Is*z*z*d",plist_id,mdc_nelmts,rdcc_nelmts,rdcc_nbytes, rdcc_w0); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Get sizes */ if (mdc_nelmts) if(H5P_get(plist, H5F_ACS_META_CACHE_SIZE_NAME, mdc_nelmts) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get meta data cache size"); if (rdcc_nelmts) if(H5P_get(plist, H5F_ACS_DATA_CACHE_ELMT_SIZE_NAME, rdcc_nelmts) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get data cache element size"); if (rdcc_nbytes) if(H5P_get(plist, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, rdcc_nbytes) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get data cache byte size"); if (rdcc_w0) if(H5P_get(plist, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, rdcc_w0) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get preempt read chunks"); done: FUNC_LEAVE_API(ret_value); } #endif /* H5_WANT_H5_V1_4_COMPAT */ /*------------------------------------------------------------------------- * Function: H5Pset_gc_references * * Purpose: Sets the flag for garbage collecting references for the file. * Dataset region references (and other reference types * probably) use space in the file heap. If garbage collection * is on and the user passes in an uninitialized value in a * reference structure, the heap might get corrupted. When * garbage collection is off however and the user re-uses a * reference, the previous heap block will be orphaned and not * returned to the free heap space. When garbage collection is * on, the user must initialize the reference structures to 0 or * risk heap corruption. * * Default value for garbage collecting references is off, just * to be on the safe side. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * June, 1999 * * Modifications: * * Raymond Lu * Tuesday, Oct 23, 2001 * Changed the file access list to the new generic property * list. * *------------------------------------------------------------------------- */ herr_t H5Pset_gc_references(hid_t plist_id, unsigned gc_ref) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pset_gc_references, FAIL); H5TRACE2("e","iIu",plist_id,gc_ref); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Set values */ if(H5P_set(plist, H5F_ACS_GARBG_COLCT_REF_NAME, &gc_ref) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set garbage collect reference"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Pget_gc_references * * Purpose: Returns the current setting for the garbage collection * references property from a file access property list. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * June, 1999 * * Modifications: * * Raymond Lu * Tuesday, Oct 23, 2001 * Changed the file access list to the new generic property * list. * *------------------------------------------------------------------------- */ herr_t H5Pget_gc_references(hid_t plist_id, unsigned *gc_ref/*out*/) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pget_gc_references, FAIL); H5TRACE2("e","ix",plist_id,gc_ref); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Get values */ if (gc_ref) if(H5P_get(plist, H5F_ACS_GARBG_COLCT_REF_NAME, gc_ref) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get garbage collect reference"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Pset_fclose_degree * * Purpose: Sets the degree for the file close behavior. * * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu * November, 2001 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Pset_fclose_degree(hid_t plist_id, H5F_close_degree_t degree) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pset_fclose_degree, FAIL); H5TRACE2("e","iFd",plist_id,degree); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Set values */ if(H5P_set(plist, H5F_CLOSE_DEGREE_NAME, °ree) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file close degree"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Pget_fclose_degree * * Purpose: Returns the degree for the file close behavior. * * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu * November, 2001 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Pget_fclose_degree(hid_t plist_id, H5F_close_degree_t *degree) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pget_fclose_degree, FAIL); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); if( degree && (H5P_get(plist, H5F_CLOSE_DEGREE_NAME, degree) < 0) ) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file close degree"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Pset_meta_block_size * * Purpose: Sets the minimum size of metadata block allocations when * the H5FD_FEAT_AGGREGATE_METADATA is set by a VFL driver. * Each "raw" metadata block is allocated to be this size and then * specific pieces of metadata (object headers, local heaps, B-trees, etc) * are sub-allocated from this block. * * The default value is set to 2048 (bytes), indicating that metadata * will be attempted to be bunched together in (at least) 2K blocks in * the file. Setting the value to 0 with this API function will * turn off the metadata aggregation, even if the VFL driver attempts to * use that strategy. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Friday, August 25, 2000 * * Modifications: * * Raymond Lu * Tuesday, Oct 23, 2001 * Changed the file access list to the new generic property * list. * *------------------------------------------------------------------------- */ herr_t H5Pset_meta_block_size(hid_t plist_id, hsize_t size) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pset_meta_block_size, FAIL); H5TRACE2("e","ih",plist_id,size); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Set values */ if(H5P_set(plist, H5F_ACS_META_BLOCK_SIZE_NAME, &size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set meta data block size"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Pget_meta_block_size * * Purpose: Returns the current settings for the metadata block allocation * property from a file access property list. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Friday, August 29, 2000 * * Modifications: * * Raymond Lu * Tuesday, Oct 23, 2001 * Changed the file access list to the new generic property * list. * *------------------------------------------------------------------------- */ herr_t H5Pget_meta_block_size(hid_t plist_id, hsize_t *size/*out*/) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pget_meta_block_size, FAIL); H5TRACE2("e","ix",plist_id,size); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Get values */ if (size) { if(H5P_get(plist, H5F_ACS_META_BLOCK_SIZE_NAME, size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get meta data block size"); } /* end if */ done: FUNC_LEAVE_API(ret_value); } #ifdef H5_WANT_H5_V1_4_COMPAT /*------------------------------------------------------------------------- * Function: H5Pset_sieve_buf_size * * Purpose: Sets the maximum size of the data seive buffer used for file * drivers which are capable of using data sieving. The data sieve * buffer is used when performing I/O on datasets in the file. Using a * buffer which is large anough to hold several pieces of the dataset * being read in for hyperslab selections boosts performance by quite a * bit. * * The default value is set to 64KB, indicating that file I/O for raw data * reads and writes will occur in at least 64KB blocks. * Setting the value to 0 with this API function will turn off the * data sieving, even if the VFL driver attempts to use that strategy. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Thursday, September 21, 2000 * * Modifications: * * Raymond Lu * Tuesday, Oct 23, 2001 * Changed the file access list to the new generic property * list. * *------------------------------------------------------------------------- */ herr_t H5Pset_sieve_buf_size(hid_t plist_id, hsize_t _size) { H5P_genplist_t *plist; /* Property list pointer */ size_t size=(size_t)_size; /* Work around size difference */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pset_sieve_buf_size, FAIL); H5TRACE2("e","ih",plist_id,_size); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Set values */ if(H5P_set(plist, H5F_ACS_SIEVE_BUF_SIZE_NAME, &size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set sieve buffer size"); done: FUNC_LEAVE_API(ret_value); } /* end H5Pset_sieve_buf_size() */ /*------------------------------------------------------------------------- * Function: H5Pget_sieve_buf_size * * Purpose: Returns the current settings for the data sieve buffer size * property from a file access property list. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Thursday, September 21, 2000 * * Modifications: * * Raymond Lu * Tuesday, Oct 23, 2001 * Changed the file access list to the new generic property * list. * *------------------------------------------------------------------------- */ herr_t H5Pget_sieve_buf_size(hid_t plist_id, hsize_t *_size/*out*/) { H5P_genplist_t *plist; /* Property list pointer */ size_t size; /* Work around size difference */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pget_sieve_buf_size, FAIL); H5TRACE2("e","ix",plist_id,_size); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Get values */ if (_size) { if(H5P_get(plist, H5F_ACS_SIEVE_BUF_SIZE_NAME, &size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get sieve buffer size"); *_size=size; } /* end if */ done: FUNC_LEAVE_API(ret_value); } /* end H5Pget_sieve_buf_size() */ #else /* H5_WANT_H5_V1_4_COMPAT */ /*------------------------------------------------------------------------- * Function: H5Pset_sieve_buf_size * * Purpose: Sets the maximum size of the data seive buffer used for file * drivers which are capable of using data sieving. The data sieve * buffer is used when performing I/O on datasets in the file. Using a * buffer which is large anough to hold several pieces of the dataset * being read in for hyperslab selections boosts performance by quite a * bit. * * The default value is set to 64KB, indicating that file I/O for raw data * reads and writes will occur in at least 64KB blocks. * Setting the value to 0 with this API function will turn off the * data sieving, even if the VFL driver attempts to use that strategy. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Thursday, September 21, 2000 * * Modifications: * * Raymond Lu * Tuesday, Oct 23, 2001 * Changed the file access list to the new generic property * list. * *------------------------------------------------------------------------- */ herr_t H5Pset_sieve_buf_size(hid_t plist_id, size_t size) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pset_sieve_buf_size, FAIL); H5TRACE2("e","iz",plist_id,size); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Set values */ if(H5P_set(plist, H5F_ACS_SIEVE_BUF_SIZE_NAME, &size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set sieve buffer size"); done: FUNC_LEAVE_API(ret_value); } /* end H5Pset_sieve_buf_size() */ /*------------------------------------------------------------------------- * Function: H5Pget_sieve_buf_size * * Purpose: Returns the current settings for the data sieve buffer size * property from a file access property list. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Thursday, September 21, 2000 * * Modifications: * * Raymond Lu * Tuesday, Oct 23, 2001 * Changed the file access list to the new generic property * list. * *------------------------------------------------------------------------- */ herr_t H5Pget_sieve_buf_size(hid_t plist_id, size_t *size/*out*/) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pget_sieve_buf_size, FAIL); H5TRACE2("e","ix",plist_id,size); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Get values */ if (size) if(H5P_get(plist, H5F_ACS_SIEVE_BUF_SIZE_NAME, size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get sieve buffer size"); done: FUNC_LEAVE_API(ret_value); } /* end H5Pget_sieve_buf_size() */ #endif /* H5_WANT_H5_V1_4_COMPAT */ /*------------------------------------------------------------------------- * Function: H5Pset_small_data_block_size * * Purpose: Sets the minimum size of "small" raw data block allocations * when the H5FD_FEAT_AGGREGATE_SMALLDATA is set by a VFL driver. * Each "small" raw data block is allocated to be this size and then * pieces of raw data which are small enough to fit are sub-allocated from * this block. * * The default value is set to 2048 (bytes), indicating that raw data * smaller than this value will be attempted to be bunched together in (at * least) 2K blocks in the file. Setting the value to 0 with this API * function will turn off the "small" raw data aggregation, even if the * VFL driver attempts to use that strategy. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Wednesday, June 5, 2002 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Pset_small_data_block_size(hid_t plist_id, hsize_t size) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pset_small_data_block_size, FAIL); H5TRACE2("e","ih",plist_id,size); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Set values */ if(H5P_set(plist, H5F_ACS_SDATA_BLOCK_SIZE_NAME, &size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set 'small data' block size"); done: FUNC_LEAVE_API(ret_value); } /* end H5Pset_small_data_block_size() */ /*------------------------------------------------------------------------- * Function: H5Pget_small_data_block_size * * Purpose: Returns the current settings for the "small" raw data block * allocation property from a file access property list. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Wednesday, June 5, 2002 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Pget_small_data_block_size(hid_t plist_id, hsize_t *size/*out*/) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pget_small_data_block_size, FAIL); H5TRACE2("e","ix",plist_id,size); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Get values */ if (size) { if(H5P_get(plist, H5F_ACS_META_BLOCK_SIZE_NAME, size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get 'small data' block size"); } /* end if */ done: FUNC_LEAVE_API(ret_value); } /* end H5Pget_small_data_block_size() */ xdmf-3.0+git20160803/Utilities/hdf5/H5Gstab.c0000640000175000017500000002500413003006557020275 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* Programmer: Robb Matzke * Friday, September 19, 1997 * */ #define H5F_PACKAGE /*suppress error about including H5Fpkg */ #define H5G_PACKAGE /*suppress error about including H5Gpkg */ /* Packages needed by this file... */ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* File access */ #include "H5Gpkg.h" /* Groups */ #include "H5HLprivate.h" /* Local Heaps */ #include "H5MMprivate.h" /* Memory management */ /* Private prototypes */ /*------------------------------------------------------------------------- * Function: H5G_stab_create * * Purpose: Creates a new empty symbol table (object header, name heap, * and B-tree). The caller can specify an initial size for the * name heap. The object header of the group is opened for * write access. * * In order for the B-tree to operate correctly, the first * item in the heap is the empty string, and must appear at * heap offset zero. * * Errors: * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 1 1997 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5G_stab_create(H5F_t *f, hid_t dxpl_id, size_t init, H5G_entry_t *self/*out*/) { size_t name; /*offset of "" name */ H5O_stab_t stab; /*symbol table message */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5G_stab_create, FAIL) /* * Check arguments. */ HDassert(f); HDassert(self); init = MAX(init, H5HL_SIZEOF_FREE(f) + 2); /* Create symbol table private heap */ if (H5HL_create(f, dxpl_id, init, &(stab.heap_addr)/*out*/)<0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create heap") name = H5HL_insert(f, dxpl_id, stab.heap_addr, 1, ""); if ((size_t)(-1)==name) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't initialize heap") /* * B-tree's won't work if the first name isn't at the beginning * of the heap. */ assert(0 == name); /* Create the B-tree */ if (H5B_create(f, dxpl_id, H5B_SNODE, NULL, &(stab.btree_addr)/*out*/) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create B-tree") /* * Create symbol table object header. It has a zero link count * since nothing refers to it yet. The link count will be * incremented if the object is added to the group directed graph. */ if (H5O_create(f, dxpl_id, 4 + 2 * H5F_SIZEOF_ADDR(f), self/*out*/) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create header") /* * Insert the symbol table message into the object header and the symbol * table entry. */ if (H5O_modify(self, H5O_STAB_ID, H5O_NEW_MESG, H5O_FLAG_CONSTANT, H5O_UPDATE_TIME, &stab, dxpl_id)<0) { H5O_close(self); HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create message") } self->cache.stab.btree_addr = stab.btree_addr; self->cache.stab.heap_addr = stab.heap_addr; self->type = H5G_CACHED_STAB; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_stab_create() */ /*------------------------------------------------------------------------- * Function: H5G_stab_find * * Purpose: Finds a symbol named NAME in the symbol table whose * description is stored in GRP_ENT in file F and returns its * symbol table entry through OBJ_ENT (which is optional). * * Errors: * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 1 1997 * * Modifications: * * Pedro Vicente, 22 Aug 2002 * Added `id to name' support. * Added a deep copy of the symbol table entry * *------------------------------------------------------------------------- */ herr_t H5G_stab_find(H5G_entry_t *grp_ent, const char *name, H5G_entry_t *obj_ent/*out*/, hid_t dxpl_id) { H5G_bt_ud1_t udata; /*data to pass through B-tree */ H5O_stab_t stab; /*symbol table message */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5G_stab_find, FAIL) /* Check arguments */ assert(grp_ent); assert(grp_ent->file); assert(obj_ent); assert(name && *name); /* set up the udata */ if (NULL == H5O_read(grp_ent, H5O_STAB_ID, 0, &stab, dxpl_id)) HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't read message") udata.common.name = name; udata.common.heap_addr = stab.heap_addr; udata.ent = obj_ent; /* search the B-tree */ if (H5B_find(grp_ent->file, dxpl_id, H5B_SNODE, stab.btree_addr, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "not found") /* Set the name for the symbol entry OBJ_ENT */ if (H5G_ent_set_name( grp_ent, obj_ent, name ) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "cannot insert name") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_stab_find() */ /*------------------------------------------------------------------------- * Function: H5G_stab_insert * * Purpose: Insert a new symbol into the table described by GRP_ENT in * file F. The name of the new symbol is NAME and its symbol * table entry is OBJ_ENT. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 1 1997 * *------------------------------------------------------------------------- */ herr_t H5G_stab_insert(H5G_entry_t *grp_ent, const char *name, H5G_entry_t *obj_ent, hbool_t inc_link, hid_t dxpl_id) { H5O_stab_t stab; /*symbol table message */ H5G_bt_ud1_t udata; /*data to pass through B-tree */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5G_stab_insert, FAIL) /* check arguments */ assert(grp_ent && grp_ent->file); assert(name && *name); assert(obj_ent && obj_ent->file); if (grp_ent->file->shared != obj_ent->file->shared) HGOTO_ERROR(H5E_SYM, H5E_LINK, FAIL, "interfile hard links are not allowed") /* Set the name for the symbol entry OBJ_ENT */ if (H5G_ent_set_name( grp_ent, obj_ent, name ) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "cannot insert name") /* initialize data to pass through B-tree */ if (NULL == H5O_read(grp_ent, H5O_STAB_ID, 0, &stab, dxpl_id)) HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "not a symbol table") udata.common.name = name; udata.common.heap_addr = stab.heap_addr; udata.ent = obj_ent; /* insert */ if (H5B_insert(grp_ent->file, dxpl_id, H5B_SNODE, stab.btree_addr, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert entry") /* Increment link count on object, if appropriate */ if(inc_link) if (H5O_link(obj_ent, 1, dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_LINK, FAIL, "unable to increment hard link count") done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_stab_remove * * Purpose: Remove NAME from a symbol table. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Thursday, September 17, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5G_stab_remove(H5G_entry_t *grp_ent, const char *name, hid_t dxpl_id) { H5O_stab_t stab; /*symbol table message */ H5G_bt_ud2_t udata; /*data to pass through B-tree */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5G_stab_remove, FAIL) assert(grp_ent && grp_ent->file); assert(name && *name); /* initialize data to pass through B-tree */ if (NULL==H5O_read(grp_ent, H5O_STAB_ID, 0, &stab, dxpl_id)) HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "not a symbol table") udata.common.name = name; udata.common.heap_addr = stab.heap_addr; udata.adj_link = TRUE; /* remove */ if (H5B_remove(grp_ent->file, dxpl_id, H5B_SNODE, stab.btree_addr, &udata)<0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to remove entry") done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5G_stab_delete * * Purpose: Delete entire symbol table information from file * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Thursday, March 20, 2003 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5G_stab_delete(H5F_t *f, hid_t dxpl_id, const H5O_stab_t *stab, hbool_t adj_link) { H5G_bt_ud2_t udata; /*data to pass through B-tree */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5G_stab_delete, FAIL); assert(f); assert(stab); assert(H5F_addr_defined(stab->btree_addr)); assert(H5F_addr_defined(stab->heap_addr)); /* Set up user data for B-tree deletion */ udata.common.name = NULL; udata.common.heap_addr = stab->heap_addr; udata.adj_link = adj_link; /* Delete entire B-tree */ if(H5B_delete(f, dxpl_id, H5B_SNODE, stab->btree_addr, &udata)<0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete symbol table B-tree"); /* Delete local heap for names */ if(H5HL_delete(f, dxpl_id, stab->heap_addr)<0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete symbol table heap"); done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5G_stab_delete() */ xdmf-3.0+git20160803/Utilities/hdf5/.NoDartCoverage0000640000175000017500000000000013003006557021525 0ustar alastairalastairxdmf-3.0+git20160803/Utilities/hdf5/H5FDsec2.c0000640000175000017500000006642713003006557020321 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Purpose: The POSIX unbuffered file driver using only the HDF5 public * API and with a few optimizations: the lseek() call is made * only when the current file position is unknown or needs to be * changed based on previous I/O through this driver (don't mix * I/O from this driver with I/O from other parts of the * application to the same file). */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5FD_sec2_init_interface #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fprivate.h" /* File access */ #include "H5FDprivate.h" /* File drivers */ #include "H5FDsec2.h" /* Sec2 file driver */ #include "H5FLprivate.h" /* Free Lists */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Pprivate.h" /* Property lists */ /* The driver identification number, initialized at runtime */ static hid_t H5FD_SEC2_g = 0; /* File operations */ #define OP_UNKNOWN 0 #define OP_READ 1 #define OP_WRITE 2 /* * The description of a file belonging to this driver. The `eoa' and `eof' * determine the amount of hdf5 address space in use and the high-water mark * of the file (the current size of the underlying Unix file). The `pos' * value is used to eliminate file position updates when they would be a * no-op. Unfortunately we've found systems that use separate file position * indicators for reading and writing so the lseek can only be eliminated if * the current operation is the same as the previous operation. When opening * a file the `eof' will be set to the current file size, `eoa' will be set * to zero, `pos' will be set to H5F_ADDR_UNDEF (as it is when an error * occurs), and `op' will be set to H5F_OP_UNKNOWN. */ typedef struct H5FD_sec2_t { H5FD_t pub; /*public stuff, must be first */ int fd; /*the unix file */ haddr_t eoa; /*end of allocated region */ haddr_t eof; /*end of file; current file size*/ haddr_t pos; /*current file I/O position */ int op; /*last operation */ #ifndef WIN32 /* * On most systems the combination of device and i-node number uniquely * identify a file. */ dev_t device; /*file device number */ ino_t inode; /*file i-node number */ #else /* * On WIN32 the low-order word of a unique identifier associated with the * file and the volume serial number uniquely identify a file. This number * (which, both? -rpm) may change when the system is restarted or when the * file is opened. After a process opens a file, the identifier is * constant until the file is closed. An application can use this * identifier and the volume serial number to determine whether two * handles refer to the same file. */ DWORD fileindexlo; DWORD fileindexhi; #endif } H5FD_sec2_t; /* * This driver supports systems that have the lseek64() function by defining * some macros here so we don't have to have conditional compilations later * throughout the code. * * file_offset_t: The datatype for file offsets, the second argument of * the lseek() or lseek64() call. * * file_seek: The function which adjusts the current file position, * either lseek() or lseek64(). */ /* adding for windows NT file system support. */ #ifdef H5_HAVE_LSEEK64 # define file_offset_t off64_t # define file_seek lseek64 # define file_truncate ftruncate64 #elif defined (WIN32) && !defined(__MWERKS__) # /*MSVC*/ # define file_offset_t __int64 # define file_seek _lseeki64 # define file_truncate _chsize #else # define file_offset_t off_t # define file_seek lseek # define file_truncate HDftruncate #endif /* * These macros check for overflow of various quantities. These macros * assume that file_offset_t is signed and haddr_t and size_t are unsigned. * * ADDR_OVERFLOW: Checks whether a file address of type `haddr_t' * is too large to be represented by the second argument * of the file seek function. * * SIZE_OVERFLOW: Checks whether a buffer size of type `hsize_t' is too * large to be represented by the `size_t' type. * * REGION_OVERFLOW: Checks whether an address and size pair describe data * which can be addressed entirely by the second * argument of the file seek function. */ #define MAXADDR (((haddr_t)1<<(8*sizeof(file_offset_t)-1))-1) #define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || \ ((A) & ~(haddr_t)MAXADDR)) #define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) #define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ HADDR_UNDEF==(A)+(Z) || \ (file_offset_t)((A)+(Z))<(file_offset_t)(A)) /* Prototypes */ static H5FD_t *H5FD_sec2_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); static herr_t H5FD_sec2_close(H5FD_t *_file); static int H5FD_sec2_cmp(const H5FD_t *_f1, const H5FD_t *_f2); static herr_t H5FD_sec2_query(const H5FD_t *_f1, unsigned long *flags); static haddr_t H5FD_sec2_get_eoa(H5FD_t *_file); static herr_t H5FD_sec2_set_eoa(H5FD_t *_file, haddr_t addr); static haddr_t H5FD_sec2_get_eof(H5FD_t *_file); static herr_t H5FD_sec2_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle); static herr_t H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, void *buf); static herr_t H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, const void *buf); static herr_t H5FD_sec2_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing); static const H5FD_class_t H5FD_sec2_g = { "sec2", /*name */ MAXADDR, /*maxaddr */ H5F_CLOSE_WEAK, /* fc_degree */ NULL, /*sb_size */ NULL, /*sb_encode */ NULL, /*sb_decode */ 0, /*fapl_size */ NULL, /*fapl_get */ NULL, /*fapl_copy */ NULL, /*fapl_free */ 0, /*dxpl_size */ NULL, /*dxpl_copy */ NULL, /*dxpl_free */ H5FD_sec2_open, /*open */ H5FD_sec2_close, /*close */ H5FD_sec2_cmp, /*cmp */ H5FD_sec2_query, /*query */ NULL, /*alloc */ NULL, /*free */ H5FD_sec2_get_eoa, /*get_eoa */ H5FD_sec2_set_eoa, /*set_eoa */ H5FD_sec2_get_eof, /*get_eof */ H5FD_sec2_get_handle, /*get_handle */ H5FD_sec2_read, /*read */ H5FD_sec2_write, /*write */ H5FD_sec2_flush, /*flush */ NULL, /*lock */ NULL, /*unlock */ H5FD_FLMAP_SINGLE /*fl_map */ }; /* Declare a free list to manage the H5FD_sec2_t struct */ H5FL_DEFINE_STATIC(H5FD_sec2_t); /*-------------------------------------------------------------------------- NAME H5FD_sec2_init_interface -- Initialize interface-specific information USAGE herr_t H5FD_sec2_init_interface() RETURNS Non-negative on success/Negative on failure DESCRIPTION Initializes any interface-specific data or routines. (Just calls H5FD_sec2_init currently). --------------------------------------------------------------------------*/ static herr_t H5FD_sec2_init_interface(void) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_sec2_init_interface) FUNC_LEAVE_NOAPI(H5FD_sec2_init()) } /* H5FD_sec2_init_interface() */ /*------------------------------------------------------------------------- * Function: H5FD_sec2_init * * Purpose: Initialize this driver by registering the driver with the * library. * * Return: Success: The driver ID for the sec2 driver. * * Failure: Negative. * * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: * *------------------------------------------------------------------------- */ hid_t H5FD_sec2_init(void) { hid_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_sec2_init, FAIL) if (H5I_VFL!=H5I_get_type(H5FD_SEC2_g)) H5FD_SEC2_g = H5FD_register(&H5FD_sec2_g,sizeof(H5FD_class_t)); /* Set return value */ ret_value=H5FD_SEC2_g; done: FUNC_LEAVE_NOAPI(ret_value) } /*--------------------------------------------------------------------------- * Function: H5FD_sec2_term * * Purpose: Shut down the VFD * * Return: * * Programmer: Quincey Koziol * Friday, Jan 30, 2004 * * Modification: * *--------------------------------------------------------------------------- */ void H5FD_sec2_term(void) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_sec2_term) /* Reset VFL ID */ H5FD_SEC2_g=0; FUNC_LEAVE_NOAPI_VOID } /* end H5FD_sec2_term() */ /*------------------------------------------------------------------------- * Function: H5Pset_fapl_sec2 * * Purpose: Modify the file access property list to use the H5FD_SEC2 * driver defined in this source file. There are no driver * specific properties. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Thursday, February 19, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Pset_fapl_sec2(hid_t fapl_id) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value; FUNC_ENTER_API(H5Pset_fapl_sec2, FAIL) H5TRACE1("e","i",fapl_id); if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") ret_value= H5P_set_driver(plist, H5FD_SEC2, NULL); done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_sec2_open * * Purpose: Create and/or opens a Unix file as an HDF5 file. * * Return: Success: A pointer to a new file data structure. The * public fields will be initialized by the * caller, which is always H5FD_open(). * * Failure: NULL * * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: * *------------------------------------------------------------------------- */ /* ARGSUSED */ static H5FD_t * H5FD_sec2_open(const char *name, unsigned flags, hid_t UNUSED fapl_id, haddr_t maxaddr) { int o_flags; int fd=(-1); H5FD_sec2_t *file=NULL; #ifdef WIN32 HFILE filehandle; struct _BY_HANDLE_FILE_INFORMATION fileinfo; #endif h5_stat_t sb; H5FD_t *ret_value; FUNC_ENTER_NOAPI(H5FD_sec2_open, NULL) /* Sanity check on file offsets */ assert(sizeof(file_offset_t)>=sizeof(size_t)); /* Check arguments */ if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name") if (0==maxaddr || HADDR_UNDEF==maxaddr) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr") if (ADDR_OVERFLOW(maxaddr)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "bogus maxaddr") /* Build the open flags */ o_flags = (H5F_ACC_RDWR & flags) ? O_RDWR : O_RDONLY; if (H5F_ACC_TRUNC & flags) o_flags |= O_TRUNC; if (H5F_ACC_CREAT & flags) o_flags |= O_CREAT; if (H5F_ACC_EXCL & flags) o_flags |= O_EXCL; /* Open the file */ if ((fd=HDopen(name, o_flags, 0666))<0) HSYS_GOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file") if (HDfstat(fd, &sb)<0) HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, NULL, "unable to fstat file") /* Create the new file struct */ if (NULL==(file=H5FL_CALLOC(H5FD_sec2_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate file struct") file->fd = fd; H5_ASSIGN_OVERFLOW(file->eof,sb.st_size,h5_stat_size_t,haddr_t); file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; #ifdef WIN32 filehandle = _get_osfhandle(fd); (void)GetFileInformationByHandle((HANDLE)filehandle, &fileinfo); file->fileindexhi = fileinfo.nFileIndexHigh; file->fileindexlo = fileinfo.nFileIndexLow; #else file->device = sb.st_dev; file->inode = sb.st_ino; #endif /* Set return value */ ret_value=(H5FD_t*)file; done: if(ret_value==NULL) { if(fd>=0) HDclose(fd); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_sec2_close * * Purpose: Closes a Unix file. * * Return: Success: 0 * * Failure: -1, file not closed. * * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_sec2_close(H5FD_t *_file) { H5FD_sec2_t *file = (H5FD_sec2_t*)_file; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_sec2_close, FAIL) if (HDclose(file->fd)<0) HSYS_GOTO_ERROR(H5E_IO, H5E_CANTCLOSEFILE, FAIL, "unable to close file") H5FL_FREE(H5FD_sec2_t,file); done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_sec2_cmp * * Purpose: Compares two files belonging to this driver using an * arbitrary (but consistent) ordering. * * Return: Success: A value like strcmp() * * Failure: never fails (arguments were checked by the * caller). * * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static int H5FD_sec2_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { const H5FD_sec2_t *f1 = (const H5FD_sec2_t*)_f1; const H5FD_sec2_t *f2 = (const H5FD_sec2_t*)_f2; int ret_value=0; FUNC_ENTER_NOAPI(H5FD_sec2_cmp, H5FD_VFD_DEFAULT) #ifdef WIN32 if (f1->fileindexhi < f2->fileindexhi) HGOTO_DONE(-1) if (f1->fileindexhi > f2->fileindexhi) HGOTO_DONE(1) if (f1->fileindexlo < f2->fileindexlo) HGOTO_DONE(-1) if (f1->fileindexlo > f2->fileindexlo) HGOTO_DONE(1) #else #ifdef H5_DEV_T_IS_SCALAR if (f1->device < f2->device) HGOTO_DONE(-1) if (f1->device > f2->device) HGOTO_DONE(1) #else /* H5_DEV_T_IS_SCALAR */ /* If dev_t isn't a scalar value on this system, just use memcmp to * determine if the values are the same or not. The actual return value * shouldn't really matter... */ if(HDmemcmp(&(f1->device),&(f2->device),sizeof(dev_t))<0) HGOTO_DONE(-1) if(HDmemcmp(&(f1->device),&(f2->device),sizeof(dev_t))>0) HGOTO_DONE(1) #endif /* H5_DEV_T_IS_SCALAR */ if (f1->inode < f2->inode) HGOTO_DONE(-1) if (f1->inode > f2->inode) HGOTO_DONE(1) #endif done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_sec2_query * * Purpose: Set the flags that this VFL driver is capable of supporting. * (listed in H5FDpublic.h) * * Return: Success: non-negative * * Failure: negative * * Programmer: Quincey Koziol * Friday, August 25, 2000 * * Modifications: * *------------------------------------------------------------------------- */ /* ARGSUSED */ static herr_t H5FD_sec2_query(const H5FD_t UNUSED * _f, unsigned long *flags /* out */) { herr_t ret_value=SUCCEED; FUNC_ENTER_NOAPI(H5FD_sec2_query, FAIL) /* Set the VFL feature flags that this driver supports */ if(flags) { *flags = 0; *flags|=H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ *flags|=H5FD_FEAT_ACCUMULATE_METADATA; /* OK to accumulate metadata for faster writes */ *flags|=H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ *flags|=H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ } done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_sec2_get_eoa * * Purpose: Gets the end-of-address marker for the file. The EOA marker * is the first address past the last byte allocated in the * format address space. * * Return: Success: The end-of-address marker. * * Failure: HADDR_UNDEF * * Programmer: Robb Matzke * Monday, August 2, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static haddr_t H5FD_sec2_get_eoa(H5FD_t *_file) { H5FD_sec2_t *file = (H5FD_sec2_t*)_file; haddr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_sec2_get_eoa, HADDR_UNDEF) /* Set return value */ ret_value=file->eoa; done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_sec2_set_eoa * * Purpose: Set the end-of-address marker for the file. This function is * called shortly after an existing HDF5 file is opened in order * to tell the driver where the end of the HDF5 data is located. * * Return: Success: 0 * * Failure: -1 * * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_sec2_set_eoa(H5FD_t *_file, haddr_t addr) { H5FD_sec2_t *file = (H5FD_sec2_t*)_file; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_sec2_set_eoa, FAIL) file->eoa = addr; done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_sec2_get_eof * * Purpose: Returns the end-of-file marker, which is the greater of * either the Unix end-of-file or the HDF5 end-of-address * markers. * * Return: Success: End of file address, the first address past * the end of the "file", either the Unix file * or the HDF5 file. * * Failure: HADDR_UNDEF * * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static haddr_t H5FD_sec2_get_eof(H5FD_t *_file) { H5FD_sec2_t *file = (H5FD_sec2_t*)_file; haddr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_sec2_get_eof, HADDR_UNDEF) /* Set return value */ ret_value=MAX(file->eof, file->eoa); done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_sec2_get_handle * * Purpose: Returns the file handle of sec2 file driver. * * Returns: Non-negative if succeed or negative if fails. * * Programmer: Raymond Lu * Sept. 16, 2002 * * Modifications: * *------------------------------------------------------------------------- */ /* ARGSUSED */ static herr_t H5FD_sec2_get_handle(H5FD_t *_file, hid_t UNUSED fapl, void** file_handle) { H5FD_sec2_t *file = (H5FD_sec2_t *)_file; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5FD_sec2_get_handle, FAIL) if(!file_handle) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file handle not valid") *file_handle = &(file->fd); done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_sec2_read * * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR * into buffer BUF according to data transfer properties in * DXPL_ID. * * Return: Success: Zero. Result is stored in caller-supplied * buffer BUF. * * Failure: -1, Contents of buffer BUF are undefined. * * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: * *------------------------------------------------------------------------- */ /* ARGSUSED */ static herr_t H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, haddr_t addr, size_t size, void *buf/*out*/) { H5FD_sec2_t *file = (H5FD_sec2_t*)_file; ssize_t nbytes; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_sec2_read, FAIL) assert(file && file->pub.cls); assert(buf); /* Check for overflow conditions */ if (HADDR_UNDEF==addr) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined") if (REGION_OVERFLOW(addr, size)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow") if (addr+size>file->eoa) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow") /* Seek to the correct location */ if ((addr!=file->pos || OP_READ!=file->op) && file_seek(file->fd, (file_offset_t)addr, SEEK_SET)<0) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") /* * Read data, being careful of interrupted system calls, partial results, * and the end of the file. */ while (size>0) { do { nbytes = HDread(file->fd, buf, size); } while (-1==nbytes && EINTR==errno); if (-1==nbytes) /* error */ HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed") if (0==nbytes) { /* end of file but not end of format address space */ HDmemset(buf, 0, size); break; } assert(nbytes>=0); assert((size_t)nbytes<=size); H5_CHECK_OVERFLOW(nbytes,ssize_t,size_t); size -= (size_t)nbytes; H5_CHECK_OVERFLOW(nbytes,ssize_t,haddr_t); addr += (haddr_t)nbytes; buf = (char*)buf + nbytes; } /* Update current position */ file->pos = addr; file->op = OP_READ; done: if(ret_value<0) { /* Reset last file I/O information */ file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_sec2_write * * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR * from buffer BUF according to data transfer properties in * DXPL_ID. * * Return: Success: Zero * * Failure: -1 * * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: * *------------------------------------------------------------------------- */ /* ARGSUSED */ static herr_t H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, haddr_t addr, size_t size, const void *buf) { H5FD_sec2_t *file = (H5FD_sec2_t*)_file; ssize_t nbytes; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_sec2_write, FAIL) assert(file && file->pub.cls); assert(buf); /* Check for overflow conditions */ if (HADDR_UNDEF==addr) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined") if (REGION_OVERFLOW(addr, size)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow") if (addr+size>file->eoa) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow") /* Seek to the correct location */ if ((addr!=file->pos || OP_WRITE!=file->op) && file_seek(file->fd, (file_offset_t)addr, SEEK_SET)<0) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") /* * Write the data, being careful of interrupted system calls and partial * results */ while (size>0) { do { nbytes = HDwrite(file->fd, buf, size); } while (-1==nbytes && EINTR==errno); if (-1==nbytes) /* error */ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") assert(nbytes>0); assert((size_t)nbytes<=size); H5_CHECK_OVERFLOW(nbytes,ssize_t,size_t); size -= (size_t)nbytes; H5_CHECK_OVERFLOW(nbytes,ssize_t,haddr_t); addr += (haddr_t)nbytes; buf = (const char*)buf + nbytes; } /* Update current position and eof */ file->pos = addr; file->op = OP_WRITE; if (file->pos>file->eof) file->eof = file->pos; done: if(ret_value<0) { /* Reset last file I/O information */ file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_sec2_flush * * Purpose: Makes sure that the true file size is the same (or larger) * than the end-of-address. * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Wednesday, August 4, 1999 * * Modifications: * *------------------------------------------------------------------------- */ /* ARGSUSED */ static herr_t H5FD_sec2_flush(H5FD_t *_file, hid_t UNUSED dxpl_id, unsigned UNUSED closing) { H5FD_sec2_t *file = (H5FD_sec2_t*)_file; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_sec2_flush, FAIL) assert(file); /* Extend the file to make sure it's large enough */ if (file->eoa!=file->eof) { #ifdef WIN32 HFILE filehandle; /* Windows file handle */ LARGE_INTEGER li; /* 64-bit integer for SetFilePointer() call */ /* Map the posix file handle to a Windows file handle */ filehandle = _get_osfhandle(file->fd); /* Translate 64-bit integers into form Windows wants */ /* [This algorithm is from the Windows documentation for SetFilePointer()] */ li.QuadPart = (LONGLONG)file->eoa; (void)SetFilePointer((HANDLE)filehandle,li.LowPart,&li.HighPart,FILE_BEGIN); if(SetEndOfFile((HANDLE)filehandle)==0) HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") #else /* WIN32 */ if (-1==file_truncate(file->fd, (file_offset_t)file->eoa)) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") #endif /* WIN32 */ /* Update the eof value */ file->eof = file->eoa; /* Reset last file I/O information */ file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; } done: FUNC_LEAVE_NOAPI(ret_value) } xdmf-3.0+git20160803/Utilities/hdf5/H5Bprivate.h0000640000175000017500000001502113003006557021014 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*------------------------------------------------------------------------- * * Created: H5Bprivate.h * Jul 10 1997 * Robb Matzke * * Purpose: Private non-prototype header. * * Modifications: * *------------------------------------------------------------------------- */ #ifndef _H5Bprivate_H #define _H5Bprivate_H #include "H5Bpublic.h" /*API prototypes */ /* Private headers needed by this file */ #include "H5private.h" /* Generic Functions */ #include "H5ACprivate.h" /* Metadata cache */ #include "H5Fprivate.h" /* File access */ #include "H5RCprivate.h" /* Reference counted object functions */ /* * Feature: Define this constant if you want to check B-tree consistency * after each B-tree operation. Note that this slows down the * library considerably! Debugging the B-tree depends on assert() * being enabled. */ #ifdef NDEBUG # undef H5B_DEBUG #endif #define H5B_MAGIC "TREE" /*tree node magic number */ #define H5B_SIZEOF_MAGIC 4 /*size of magic number */ typedef enum H5B_ins_t { H5B_INS_ERROR = -1, /*error return value */ H5B_INS_NOOP = 0, /*insert made no changes */ H5B_INS_LEFT = 1, /*insert new node to left of cur node */ H5B_INS_RIGHT = 2, /*insert new node to right of cur node */ H5B_INS_CHANGE = 3, /*change child address for cur node */ H5B_INS_FIRST = 4, /*insert first node in (sub)tree */ H5B_INS_REMOVE = 5 /*remove current node */ } H5B_ins_t; /* Define return values from operator callback function for H5B_iterate */ /* (Actually, any postive value will cause the iterator to stop and pass back * that positive value to the function that called the iterator) */ #define H5B_ITER_ERROR (-1) #define H5B_ITER_CONT (0) #define H5B_ITER_STOP (1) /* Define the operator callback function pointer for H5B_iterate() */ typedef int (*H5B_operator_t)(H5F_t *f, hid_t dxpl_id, const void *_lt_key, haddr_t addr, const void *_rt_key, void *_udata); /* Typedef for B-tree in memory (defined in H5Bpkg.h) */ typedef struct H5B_t H5B_t; /* Each B-tree has certain information that can be shared across all * the instances of nodes in that B-tree. */ typedef struct H5B_shared_t { const struct H5B_class_t *type; /* Type of tree */ unsigned two_k; /* 2*"K" value for tree's nodes */ size_t sizeof_rkey; /* Size of raw (disk) key */ size_t sizeof_rnode; /* Size of raw (disk) node */ size_t sizeof_keys; /* Size of native (memory) key node */ uint8_t *page; /* Disk page */ size_t *nkey; /* Offsets of each native key in native key buffer */ } H5B_shared_t; /* * Each class of object that can be pointed to by a B-link tree has a * variable of this type that contains class variables and methods. Each * tree has a K (1/2 rank) value on a per-file basis. The file_create_parms * has an array of K values indexed by the `id' class field below. The * array is initialized with the HDF5_BTREE_K_DEFAULT macro. */ typedef struct H5B_class_t { H5B_subid_t id; /*id as found in file*/ size_t sizeof_nkey; /*size of native (memory) key*/ size_t (*get_sizeof_rkey)(const H5F_t*, const void*); /*raw key size */ H5RC_t * (*get_shared)(const H5F_t*, const void*); /*shared info for node */ herr_t (*new_node)(H5F_t*, hid_t, H5B_ins_t, void*, void*, void*, haddr_t*); int (*cmp2)(H5F_t*, hid_t, void*, void*, void*); /*compare 2 keys */ int (*cmp3)(H5F_t*, hid_t, void*, void*, void*); /*compare 3 keys */ herr_t (*found)(H5F_t*, hid_t, haddr_t, const void*, void*); /* insert new data */ H5B_ins_t (*insert)(H5F_t*, hid_t, haddr_t, void*, hbool_t*, void*, void*, void*, hbool_t*, haddr_t*); /* min insert uses min leaf, not new(), similarily for max insert */ hbool_t follow_min; hbool_t follow_max; /* remove existing data */ H5B_ins_t (*remove)(H5F_t*, hid_t, haddr_t, void*, hbool_t*, void*, void*, hbool_t*); /* encode, decode, debug key values */ herr_t (*decode)(const H5F_t*, const struct H5B_t*, const uint8_t*, void*); herr_t (*encode)(const H5F_t*, const struct H5B_t*, uint8_t*, void*); herr_t (*debug_key)(FILE*, H5F_t*, hid_t, int, int, const void*, const void*); } H5B_class_t; /* * Library prototypes. */ H5_DLL size_t H5B_nodesize(const H5F_t *f, const H5B_shared_t *shared, size_t *total_nkey_size); H5_DLL herr_t H5B_create (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, void *udata, haddr_t *addr_p/*out*/); H5_DLL herr_t H5B_find (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void *udata); H5_DLL herr_t H5B_insert (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void *udata); H5_DLL herr_t H5B_iterate (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t op, haddr_t addr, void *udata); H5_DLL herr_t H5B_remove(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void *udata); H5_DLL herr_t H5B_delete(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void *udata); H5_DLL herr_t H5B_debug (H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, int fwidth, const H5B_class_t *type, void *udata); #endif xdmf-3.0+git20160803/Utilities/hdf5/H5Z.c0000640000175000017500000012353713003006557017460 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #define H5Z_PACKAGE /*suppress error about including H5Zpkg */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5Z_init_interface #include "H5private.h" /* Generic Functions */ #include "H5Dprivate.h" /* Dataset functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Oprivate.h" /* Object headers */ #include "H5Pprivate.h" /* Property lists */ #include "H5Sprivate.h" /* Dataspace functions */ #include "H5Zpkg.h" /* Data filters */ #ifdef H5_HAVE_SZLIB_H # include "szlib.h" #endif /* Local typedefs */ #ifdef H5Z_DEBUG typedef struct H5Z_stats_t { struct { hsize_t total; /*total number of bytes processed */ hsize_t errors; /*bytes of total attributable to errors */ H5_timer_t timer; /*execution time including errors */ } stats[2]; /*0=output, 1=input */ } H5Z_stats_t; #endif /* H5Z_DEBUG */ /* Enumerated type for dataset creation prelude callbacks */ typedef enum { H5Z_PRELUDE_CAN_APPLY, /* Call "can apply" callback */ H5Z_PRELUDE_SET_LOCAL /* Call "set local" callback */ } H5Z_prelude_type_t; /* Local variables */ static size_t H5Z_table_alloc_g = 0; static size_t H5Z_table_used_g = 0; static H5Z_class_t *H5Z_table_g = NULL; #ifdef H5Z_DEBUG static H5Z_stats_t *H5Z_stat_table_g = NULL; #endif /* H5Z_DEBUG */ /* Local functions */ static int H5Z_find_idx(H5Z_filter_t id); /*------------------------------------------------------------------------- * Function: H5Z_init_interface * * Purpose: Initializes the data filter layer. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Thursday, April 16, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5Z_init_interface (void) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5Z_init_interface) #ifdef H5_HAVE_FILTER_DEFLATE if (H5Z_register (H5Z_DEFLATE)<0) HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register deflate filter") #endif /* H5_HAVE_FILTER_DEFLATE */ #ifdef H5_HAVE_FILTER_SHUFFLE if (H5Z_register (H5Z_SHUFFLE)<0) HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register shuffle filter") #endif /* H5_HAVE_FILTER_SHUFFLE */ #ifdef H5_HAVE_FILTER_FLETCHER32 if (H5Z_register (H5Z_FLETCHER32)<0) HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register fletcher32 filter") #endif /* H5_HAVE_FILTER_FLETCHER32 */ #ifdef H5_HAVE_FILTER_SZIP if (H5Z_register (H5Z_SZIP)<0) HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register szip filter") #endif /* H5_HAVE_FILTER_SZIP */ #if (defined H5_HAVE_FILTER_DEFLATE | defined H5_HAVE_FILTER_FLETCHER32 | defined H5_HAVE_FILTER_SHUFFLE | defined H5_HAVE_FILTER_SZIP) done: #endif /* (defined H5_HAVE_FILTER_DEFLATE | defined H5_HAVE_FILTER_FLETCHER32 | defined H5_HAVE_FILTER_SHUFFLE | defined H5_HAVE_FILTER_SZIP) */ FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5Z_term_interface * * Purpose: Terminate the H5Z layer. * * Return: void * * Programmer: Robb Matzke * Thursday, April 16, 1998 * * Modifications: * *------------------------------------------------------------------------- */ int H5Z_term_interface (void) { #ifdef H5Z_DEBUG size_t i; int dir, nprint=0; char comment[16], bandwidth[32]; #endif if (H5_interface_initialize_g) { #ifdef H5Z_DEBUG if (H5DEBUG(Z)) { for (i=0; i", comment, H5Z_stat_table_g[i].stats[dir].total, H5Z_stat_table_g[i].stats[dir].errors, H5Z_stat_table_g[i].stats[dir].timer.utime, H5Z_stat_table_g[i].stats[dir].timer.stime, H5Z_stat_table_g[i].stats[dir].timer.etime, bandwidth); } } } #endif /* H5Z_DEBUG */ /* Free the table of filters */ H5Z_table_g = H5MM_xfree(H5Z_table_g); #ifdef H5Z_DEBUG H5Z_stat_table_g = H5MM_xfree(H5Z_stat_table_g); #endif /* H5Z_DEBUG */ H5Z_table_used_g = H5Z_table_alloc_g = 0; H5_interface_initialize_g = 0; } return 0; } #ifdef H5_WANT_H5_V1_4_COMPAT /*------------------------------------------------------------------------- * Function: H5Zregister * * Purpose: This function registers new filter. The COMMENT argument is * used for debugging and may be the null pointer. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Thursday, April 16, 1998 * * Modifications: * Changed to pass H5Z_class_t struct to H5Z_register * Quincey Koziol, April 5, 2003 * *------------------------------------------------------------------------- */ herr_t H5Zregister(H5Z_filter_t id, const char *comment, H5Z_func_t func) { H5Z_class_t cls; /* Filter class used to bundle parameters */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Zregister, FAIL); H5TRACE3("e","Zfsx",id,comment,func); /* Check args */ if (id<0 || id>H5Z_FILTER_MAX) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter identification number"); if (idid<0 || cls->id>H5Z_FILTER_MAX) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter identification number") if (cls->idfilter==NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no filter function specified") /* Do it */ if (H5Z_register (cls)<0) HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register filter") done: FUNC_LEAVE_API(ret_value) } #endif /* H5_WANT_H5_V1_4_COMPAT */ /*------------------------------------------------------------------------- * Function: H5Z_register * * Purpose: Same as the public version except this one allows filters * to be set for predefined method numbers id>=0 && cls->id<=H5Z_FILTER_MAX); /* Is the filter already registered? */ for (i=0; iid) break; /* Filter not already registered */ if (i>=H5Z_table_used_g) { if (H5Z_table_used_g>=H5Z_table_alloc_g) { size_t n = MAX(H5Z_MAX_NFILTERS, 2*H5Z_table_alloc_g); H5Z_class_t *table = H5MM_realloc(H5Z_table_g, n*sizeof(H5Z_class_t)); #ifdef H5Z_DEBUG H5Z_stats_t *stat_table = H5MM_realloc(H5Z_stat_table_g, n*sizeof(H5Z_stats_t)); #endif /* H5Z_DEBUG */ if (!table) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to extend filter table") H5Z_table_g = table; #ifdef H5Z_DEBUG if (!stat_table) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to extend filter statistics table") H5Z_stat_table_g = stat_table; #endif /* H5Z_DEBUG */ H5Z_table_alloc_g = n; } /* end if */ /* Initialize */ i = H5Z_table_used_g++; HDmemcpy(H5Z_table_g+i, cls, sizeof(H5Z_class_t)); #ifdef H5Z_DEBUG HDmemset(H5Z_stat_table_g+i, 0, sizeof(H5Z_stats_t)); #endif /* H5Z_DEBUG */ } /* end if */ /* Filter already registered */ else { /* Replace old contents */ HDmemcpy(H5Z_table_g+i, cls, sizeof(H5Z_class_t)); } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5Zunregister * * Purpose: This function unregisters a filter. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Thursday, November 14, 2002 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Zunregister(H5Z_filter_t id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Zunregister, FAIL) H5TRACE1("e","Zf",id); /* Check args */ if (id<0 || id>H5Z_FILTER_MAX) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter identification number") if (id=0 && id<=H5Z_FILTER_MAX); /* Is the filter already registered? */ for (i=0; i=H5Z_table_used_g) HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, FAIL, "filter is not registered") /* Remove filter from table */ /* Don't worry about shrinking table size (for now) */ HDmemmove(&H5Z_table_g[i],&H5Z_table_g[i+1],sizeof(H5Z_class_t)*((H5Z_table_used_g-1)-i)); #ifdef H5Z_DEBUG HDmemmove(&H5Z_stat_table_g[i],&H5Z_stat_table_g[i+1],sizeof(H5Z_stats_t)*((H5Z_table_used_g-1)-i)); #endif /* H5Z_DEBUG */ H5Z_table_used_g--; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_unregister() */ /*------------------------------------------------------------------------- * Function: H5Zfilter_avail * * Purpose: Check if a filter is available * * Return: Non-negative (TRUE/FALSE) on success/Negative on failure * * Programmer: Quincey Koziol * Thursday, November 14, 2002 * * Modifications: * *------------------------------------------------------------------------- */ htri_t H5Zfilter_avail(H5Z_filter_t id) { size_t i; /* Local index variable */ htri_t ret_value=FALSE; /* Return value */ FUNC_ENTER_API(H5Zfilter_avail, FAIL) H5TRACE1("t","Zf",id); /* Check args */ if(id<0 || id>H5Z_FILTER_MAX) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter identification number") /* Is the filter already registered? */ for(i=0; i 0) { unsigned chunk_ndims; /* # of chunk dimensions */ size_t chunk_size[H5O_LAYOUT_NDIMS]; /* Size of chunk dimensions */ hsize_t chunk_dims[H5O_LAYOUT_NDIMS]; /* Size of chunk dimensions */ H5S_t *space; /* Dataspace describing chunk */ hid_t space_id; /* ID for dataspace describing chunk */ size_t u; /* Local index variable */ /* Get chunk information */ if(H5P_get(dc_plist, H5D_CRT_CHUNK_DIM_NAME, &chunk_ndims) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve chunk dimensions") if(H5P_get(dc_plist, H5D_CRT_CHUNK_SIZE_NAME, chunk_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve chunk size") /* Create a data space for a chunk & set the extent */ for(u=0; ucan_apply) { herr_t status; /* Make callback to filter's "can apply" function */ status=(fclass->can_apply)(dcpl_id, type_id, space_id); /* Check return value */ if(status<=0) { /* We're leaving, so close dataspace */ if(H5I_dec_ref(space_id)<0) HGOTO_ERROR (H5E_PLINE, H5E_CANTRELEASE, FAIL, "unable to close dataspace") /* Indicate filter can't apply to this combination of parameters */ if(status==0) { HGOTO_ERROR(H5E_PLINE, H5E_CANAPPLY, FAIL, "filter parameters not appropriate") } /* end if */ /* Indicate error during filter callback */ else { HGOTO_ERROR(H5E_PLINE, H5E_CANAPPLY, FAIL, "error during user callback") } /* end if */ } /* end if */ } /* end if */ break; case H5Z_PRELUDE_SET_LOCAL: /* Check if there is a "set local" callback */ if(fclass->set_local) { /* Make callback to filter's "set local" function */ if((fclass->set_local)(dcpl_id, type_id, space_id)<0) { /* We're leaving, so close dataspace */ if(H5I_dec_ref(space_id)<0) HGOTO_ERROR (H5E_PLINE, H5E_CANTRELEASE, FAIL, "unable to close dataspace") /* Indicate error during filter callback */ HGOTO_ERROR(H5E_PLINE, H5E_SETLOCAL, FAIL, "error during user callback") } /* end if */ } /* end if */ break; default: assert("invalid prelude type" && 0); } /* end switch */ } /* end else */ } /* end for */ /* Close dataspace */ if(H5I_dec_ref(space_id)<0) HGOTO_ERROR (H5E_PLINE, H5E_CANTRELEASE, FAIL, "unable to close dataspace") } /* end if */ } /* end if */ } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_prelude_callback() */ /*------------------------------------------------------------------------- * Function: H5Z_can_apply * * Purpose: Checks if all the filters defined in the dataset creation * property list can be applied to a particular combination of * datatype and dataspace for a dataset. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Thursday, April 3, 2003 * * Notes: * The chunk dimensions are used to create a dataspace, instead * of passing in the dataset's dataspace, since the chunk * dimensions are what the I/O filter will actually see * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Z_can_apply (hid_t dcpl_id, hid_t type_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5Z_can_apply,FAIL) assert (H5I_GENPROP_LST==H5I_get_type(dcpl_id)); assert (H5I_DATATYPE==H5I_get_type(type_id)); /* Make "can apply" callbacks for filters in pipeline */ if(H5Z_prelude_callback(dcpl_id, type_id, H5Z_PRELUDE_CAN_APPLY)<0) HGOTO_ERROR(H5E_PLINE, H5E_CANAPPLY, FAIL, "unable to apply filter") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_can_apply() */ /*------------------------------------------------------------------------- * Function: H5Z_set_local * * Purpose: Makes callbacks to modify dataset creation list property * settings for filters on a new dataset, based on the datatype * and dataspace of that dataset (chunk). * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Friday, April 4, 2003 * * Notes: * The chunk dimensions are used to create a dataspace, instead * of passing in the dataset's dataspace, since the chunk * dimensions are what the I/O filter will actually see * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Z_set_local (hid_t dcpl_id, hid_t type_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5Z_set_local,FAIL) assert (H5I_GENPROP_LST==H5I_get_type(dcpl_id)); assert (H5I_DATATYPE==H5I_get_type(type_id)); /* Make "set local" callbacks for filters in pipeline */ if(H5Z_prelude_callback(dcpl_id, type_id, H5Z_PRELUDE_SET_LOCAL)<0) HGOTO_ERROR(H5E_PLINE, H5E_SETLOCAL, FAIL, "local filter parameters not set") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_set_local() */ /*------------------------------------------------------------------------- * Function: H5Z_modify * * Purpose: Modify filter parameters for specified pipeline. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Friday, April 5, 2003 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Z_modify(const H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, size_t cd_nelmts, const unsigned int cd_values[/*cd_nelmts*/]) { size_t idx; /* Index of filter in pipeline */ size_t i; /* Local index variable */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5Z_modify, FAIL) assert(pline); assert(filter>=0 && filter<=H5Z_FILTER_MAX); assert(0==(flags & ~((unsigned)H5Z_FLAG_DEFMASK))); assert(0==cd_nelmts || cd_values); /* Locate the filter in the pipeline */ for(idx=0; idxnused; idx++) if(pline->filter[idx].id==filter) break; /* Check if the filter was not already in the pipeline */ if(idx>pline->nused) HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, FAIL, "filter not in pipeline") /* Change parameters for filter */ pline->filter[idx].flags = flags; pline->filter[idx].cd_nelmts = cd_nelmts; /* Free any existing parameters */ if(pline->filter[idx].cd_values!=NULL) H5MM_xfree(pline->filter[idx].cd_values); /* Set parameters */ if (cd_nelmts>0) { pline->filter[idx].cd_values = H5MM_malloc(cd_nelmts*sizeof(unsigned)); if (NULL==pline->filter[idx].cd_values) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for filter parameters") for (i=0; ifilter[idx].cd_values[i] = cd_values[i]; } /* end if */ else pline->filter[idx].cd_values = NULL; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_modify() */ /*------------------------------------------------------------------------- * Function: H5Z_append * * Purpose: Append another filter to the specified pipeline. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Tuesday, August 4, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Z_append(H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, size_t cd_nelmts, const unsigned int cd_values[/*cd_nelmts*/]) { size_t idx, i; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5Z_append, FAIL) assert(pline); assert(filter>=0 && filter<=H5Z_FILTER_MAX); assert(0==(flags & ~((unsigned)H5Z_FLAG_DEFMASK))); assert(0==cd_nelmts || cd_values); /* * Check filter limit. We do it here for early warnings although we may * decide to relax this restriction in the future. */ if (pline->nused>=H5Z_MAX_NFILTERS) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "too many filters in pipeline") /* Allocate additional space in the pipeline if it's full */ if (pline->nused>=pline->nalloc) { H5O_pline_t x; x.nalloc = MAX(H5Z_MAX_NFILTERS, 2*pline->nalloc); x.filter = H5MM_realloc(pline->filter, x.nalloc*sizeof(x.filter[0])); if (NULL==x.filter) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for filter pipeline") pline->nalloc = x.nalloc; pline->filter = x.filter; } /* Add the new filter to the pipeline */ idx = pline->nused; pline->filter[idx].id = filter; pline->filter[idx].flags = flags; pline->filter[idx].name = NULL; /*we'll pick it up later*/ pline->filter[idx].cd_nelmts = cd_nelmts; if (cd_nelmts>0) { pline->filter[idx].cd_values = H5MM_malloc(cd_nelmts*sizeof(unsigned)); if (NULL==pline->filter[idx].cd_values) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for filter") for (i=0; ifilter[idx].cd_values[i] = cd_values[i]; } else { pline->filter[idx].cd_values = NULL; } pline->nused++; done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5Z_find_idx * * Purpose: Given a filter ID return the offset in the global array * that holds all the registered filters. * * Return: Success: Non-negative index of entry in global filter table. * Failure: Negative * * Programmer: Quincey Koziol * Friday, April 5, 2003 * * Modifications: * *------------------------------------------------------------------------- */ static int H5Z_find_idx(H5Z_filter_t id) { size_t i; /* Local index variable */ int ret_value=FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5Z_find_idx) for (i=0; ifilter[].flags). The filters are processed in * definition order unless the H5Z_FLAG_REVERSE is set. The * FILTER_MASK is a bit-mask to indicate which filters to skip * and on exit will indicate which filters failed. Each * filter has an index number in the pipeline and that index * number is the filter's bit in the FILTER_MASK. NBYTES is the * number of bytes of data to filter and on exit should be the * number of resulting bytes while BUF_SIZE holds the total * allocated size of the buffer, which is pointed to BUF. * * If the buffer must grow during processing of the pipeline * then the pipeline function should free the original buffer * and return a fresh buffer, adjusting BUF_SIZE accordingly. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Tuesday, August 4, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, unsigned *filter_mask/*in,out*/, H5Z_EDC_t edc_read, H5Z_cb_t cb_struct, size_t *nbytes/*in,out*/, size_t *buf_size/*in,out*/, void **buf/*in,out*/) { size_t i, idx, new_nbytes; int fclass_idx; /* Index of filter class in global table */ H5Z_class_t *fclass=NULL; /* Filter class pointer */ #ifdef H5Z_DEBUG H5Z_stats_t *fstats=NULL; /* Filter stats pointer */ H5_timer_t timer; #endif unsigned failed = 0; unsigned tmp_flags; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5Z_pipeline, FAIL) assert(0==(flags & ~((unsigned)H5Z_FLAG_INVMASK))); assert(filter_mask); assert(nbytes && *nbytes>0); assert(buf_size && *buf_size>0); assert(buf && *buf); assert(!pline || pline->nusednused; i>0; --i) { idx = i-1; if (*filter_mask & ((unsigned)1<filter[idx].id))<0) { HGOTO_ERROR(H5E_PLINE, H5E_READERROR, FAIL, "required filter is not registered") } fclass=&H5Z_table_g[fclass_idx]; #ifdef H5Z_DEBUG fstats=&H5Z_stat_table_g[fclass_idx]; H5_timer_begin(&timer); #endif tmp_flags=flags|(pline->filter[idx].flags); tmp_flags|=(edc_read== H5Z_DISABLE_EDC) ? H5Z_FLAG_SKIP_EDC : 0; new_nbytes = (fclass->filter)(tmp_flags, pline->filter[idx].cd_nelmts, pline->filter[idx].cd_values, *nbytes, buf_size, buf); #ifdef H5Z_DEBUG H5_timer_end(&(fstats->stats[1].timer), &timer); fstats->stats[1].total += MAX(*nbytes, new_nbytes); if (0==new_nbytes) fstats->stats[1].errors += *nbytes; #endif if(0==new_nbytes) { if((cb_struct.func && (H5Z_CB_FAIL==cb_struct.func(pline->filter[idx].id, *buf, *buf_size, cb_struct.op_data))) || !cb_struct.func) HGOTO_ERROR(H5E_PLINE, H5E_READERROR, FAIL, "filter returned failure during read") *nbytes = *buf_size; failed |= (unsigned)1 << idx; H5E_clear(); } else { *nbytes = new_nbytes; } } } else if (pline) { /* Write */ for (idx=0; idxnused; idx++) { if (*filter_mask & ((unsigned)1<filter[idx].id))<0) { /* Check if filter is optional -- If it isn't, then error */ if ((pline->filter[idx].flags & H5Z_FLAG_OPTIONAL) == 0) HGOTO_ERROR(H5E_PLINE, H5E_WRITEERROR, FAIL, "required filter is not registered") failed |= (unsigned)1 << idx; H5E_clear(); continue; /*filter excluded*/ } fclass=&H5Z_table_g[fclass_idx]; #ifdef H5Z_DEBUG fstats=&H5Z_stat_table_g[fclass_idx]; H5_timer_begin(&timer); #endif new_nbytes = (fclass->filter)(flags|(pline->filter[idx].flags), pline->filter[idx].cd_nelmts, pline->filter[idx].cd_values, *nbytes, buf_size, buf); #ifdef H5Z_DEBUG H5_timer_end(&(fstats->stats[0].timer), &timer); fstats->stats[0].total += MAX(*nbytes, new_nbytes); if (0==new_nbytes) fstats->stats[0].errors += *nbytes; #endif if(0==new_nbytes) { if (0==(pline->filter[idx].flags & H5Z_FLAG_OPTIONAL)) { if((cb_struct.func && (H5Z_CB_FAIL==cb_struct.func(pline->filter[idx].id, *buf, *nbytes, cb_struct.op_data))) || !cb_struct.func) HGOTO_ERROR(H5E_PLINE, H5E_WRITEERROR, FAIL, "filter returned failure") *nbytes = *buf_size; } failed |= (unsigned)1 << idx; H5E_clear(); } else { *nbytes = new_nbytes; } } } *filter_mask = failed; done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5Z_filter_info * * Purpose: Get pointer to filter info for pipeline * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Friday, April 5, 2003 * * Modifications: * *------------------------------------------------------------------------- */ H5Z_filter_info_t * H5Z_filter_info(const H5O_pline_t *pline, H5Z_filter_t filter) { size_t idx; /* Index of filter in pipeline */ H5Z_filter_info_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5Z_filter_info, NULL) assert(pline); assert(filter>=0 && filter<=H5Z_FILTER_MAX); /* Locate the filter in the pipeline */ for(idx=0; idxnused; idx++) if(pline->filter[idx].id==filter) break; /* Check if the filter was not already in the pipeline */ if(idx>pline->nused) HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, NULL, "filter not in pipeline") /* Set return value */ ret_value=&pline->filter[idx]; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_filter_info() */ /*------------------------------------------------------------------------- * Function: H5Z_all_filters_avail * * Purpose: Verify that all the filters in a pipeline are currently * available (i.e. registered) * * Return: Non-negative (TRUE/FALSE) on success/Negative on failure * * Programmer: Quincey Koziol * Tuesday, April 8, 2003 * * Modifications: * *------------------------------------------------------------------------- */ htri_t H5Z_all_filters_avail(const H5O_pline_t *pline) { size_t i,j; /* Local index variable */ htri_t ret_value=TRUE; /* Return value */ FUNC_ENTER_NOAPI(H5Z_all_filters_avail, FAIL) /* Check args */ assert(pline); /* Iterate through all the filters in pipeline */ for(i=0; inused; i++) { /* Look for each filter in the list of registered filters */ for(j=0; jfilter[i].id) break; /* Check if we didn't find the filter */ if(j==H5Z_table_used_g) HGOTO_DONE(FALSE) } /* end for */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_all_filters_avail() */ /*------------------------------------------------------------------------- * Function: H5Z_delete * * Purpose: Delete filter FILTER from pipeline PLINE; * deletes all filters if FILTER is H5Z_FILTER_NONE * * Return: Non-negative on success/Negative on failure * * Programmer: Pedro Vicente * Monday, January 26, 2004 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Z_delete(H5O_pline_t *pline, H5Z_filter_t filter) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5Z_delete, FAIL) /* Check args */ assert(pline); assert(filter>=0 && filter<=H5Z_FILTER_MAX); /* if the pipeline has no filters, just return */ if(pline->nused==0) HGOTO_DONE(SUCCEED) /* Delete all filters */ if (H5Z_FILTER_ALL==filter) { if(H5O_reset(H5O_PLINE_ID, pline)<0) HGOTO_ERROR(H5E_PLINE, H5E_CANTFREE, FAIL, "can't release pipeline info") } /* end if */ /* Delete filter */ else { size_t idx; /* Index of filter in pipeline */ unsigned found=0; /* Indicate filter was found in pipeline */ /* Locate the filter in the pipeline */ for(idx=0; idxnused; idx++) if(pline->filter[idx].id==filter) { found=1; break; } /* filter was not found in the pipeline */ if (!found) HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, FAIL, "filter not in pipeline") /* Free information for deleted filter */ H5MM_xfree(pline->filter[idx].name); H5MM_xfree(pline->filter[idx].cd_values); /* Remove filter from pipeline array */ if((idx+1)nused) HDmemcpy(&pline->filter[idx], &pline->filter[idx+1], sizeof (H5Z_filter_info_t)*(pline->nused-(idx+1))); /* Decrement number of used filters */ pline->nused--; /* Reset information for previous last filter in pipeline */ HDmemset(&pline->filter[pline->nused], 0, sizeof (H5Z_filter_info_t)); } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5Zget_filter_info * * Purpose: Gets information about a pipeline data filter and stores it * in filter_config_flags. * * Return: zero on success / negative on failure * * Programmer: James Laird and Nat Furrer * Monday, June 7, 2004 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Zget_filter_info(H5Z_filter_t filter, unsigned int *filter_config_flags) { herr_t ret_value = SUCCEED; FUNC_ENTER_API(H5Zget_filter_info, FAIL) if (filter_config_flags != NULL) { if (filter == H5Z_FILTER_SZIP) { *filter_config_flags = 0; #ifdef H5_HAVE_FILTER_SZIP if(SZ_encoder_enabled()>0) *filter_config_flags |= H5Z_FILTER_CONFIG_ENCODE_ENABLED; #endif /* H5_HAVE_FILTER_SZIP */ *filter_config_flags |= H5Z_FILTER_CONFIG_DECODE_ENABLED; } else *filter_config_flags = H5Z_FILTER_CONFIG_DECODE_ENABLED | H5Z_FILTER_CONFIG_ENCODE_ENABLED; /* Make sure the filter exists */ if (H5Z_find(filter) == NULL) *filter_config_flags = 0; } done: FUNC_LEAVE_API(ret_value) } xdmf-3.0+git20160803/Utilities/hdf5/H5P.c0000640000175000017500000066621313003006557017451 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* Programmer: Quincey Koziol * * Purpose: Generic Property Functions */ #define H5P_PACKAGE /*suppress error about including H5Ppkg */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5P_init_interface /* Private header files */ #include "H5private.h" /* Generic Functions */ #include "H5Dprivate.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fprivate.h" /* Files */ #include "H5FLprivate.h" /* Free lists */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Ppkg.h" /* Property lists */ /* Local macros */ #define H5P_DEFAULT_SKIPLIST_HEIGHT 8 /* Local variables */ /* * Predefined property list classes. These are initialized at runtime by * H5P_init_interface() in this source file. */ hid_t H5P_CLS_NO_CLASS_g = FAIL; hid_t H5P_CLS_FILE_CREATE_g = FAIL; hid_t H5P_CLS_FILE_ACCESS_g = FAIL; hid_t H5P_CLS_DATASET_CREATE_g = FAIL; hid_t H5P_CLS_DATASET_XFER_g = FAIL; hid_t H5P_CLS_MOUNT_g = FAIL; /* * Predefined property lists for each predefined class. These are initialized * at runtime by H5P_init_interface() in this source file. */ hid_t H5P_LST_NO_CLASS_g = FAIL; hid_t H5P_LST_FILE_CREATE_g = FAIL; hid_t H5P_LST_FILE_ACCESS_g = FAIL; hid_t H5P_LST_DATASET_CREATE_g = FAIL; hid_t H5P_LST_DATASET_XFER_g = FAIL; hid_t H5P_LST_MOUNT_g = FAIL; /* Track the revision count of a class, to make comparisons faster */ static unsigned H5P_next_rev=0; #define H5P_GET_NEXT_REV (H5P_next_rev++) /* Declare a free list to manage the H5P_genprop_t struct */ H5FL_DEFINE(H5P_genprop_t); /* Declare a free list to manage the H5P_genplist_t struct */ H5FL_DEFINE(H5P_genplist_t); /* Declare a free list to manage the H5P_genclass_t struct */ H5FL_DEFINE_STATIC(H5P_genclass_t); /* Local typedefs */ /* Typedef for checking for duplicate class names in parent class */ typedef struct { const H5P_genclass_t *parent; /* Pointer to parent class */ const char *name; /* Pointer to name to check */ } H5P_check_class_t; /* Local static functions */ static H5P_genclass_t *H5P_create_class(H5P_genclass_t *par_class, const char *name, unsigned internal, H5P_cls_create_func_t cls_create, void *create_data, H5P_cls_copy_func_t cls_copy, void *copy_data, H5P_cls_close_func_t cls_close, void *close_data); static herr_t H5P_unregister(H5P_genclass_t *pclass, const char *name); static H5P_genprop_t *H5P_dup_prop(H5P_genprop_t *oprop, H5P_prop_within_t type); static herr_t H5P_free_prop(H5P_genprop_t *prop); /*-------------------------------------------------------------------------- NAME H5P_do_prop_cb1 PURPOSE Internal routine to call a property list callback routine and update the property list accordingly. USAGE herr_t H5P_do_prop_cb1(slist,prop,cb) H5SL_t *slist; IN/OUT: Skip list to hold changed properties H5P_genprop_t *prop; IN: Property to call callback for H5P_prp_cb1_t *cb; IN: Callback routine to call RETURNS Returns non-negative on success, negative on failure. DESCRIPTION Calls the callback routine passed in. If the callback routine changes the property value, then the property is duplicated and added to skip list. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5P_do_prop_cb1(H5SL_t *slist, H5P_genprop_t *prop, H5P_prp_cb1_t cb) { void *tmp_value=NULL; /* Temporary value buffer */ H5P_genprop_t *pcopy=NULL; /* Copy of property to insert into skip list */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5P_do_prop_cb1); /* Allocate space for a temporary copy of the property value */ if (NULL==(tmp_value=H5MM_malloc(prop->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for temporary property value"); HDmemcpy(tmp_value,prop->value,prop->size); /* Call "type 1" callback ('create', 'copy' or 'close') */ if(cb(prop->name,prop->size,tmp_value)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTINIT, FAIL,"Property callback failed"); /* Check if the property value changed */ if(HDmemcmp(tmp_value,prop->value,prop->size)) { /* Make a copy of the class's property */ if((pcopy=H5P_dup_prop(prop,H5P_PROP_WITHIN_LIST))==NULL) HGOTO_ERROR (H5E_PLIST, H5E_CANTCOPY, FAIL,"Can't copy property"); /* Copy the changed value into the new property */ HDmemcpy(pcopy->value,tmp_value,prop->size); /* Insert the changed property into the property list */ if(H5P_add_prop(slist,pcopy)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTINSERT, FAIL,"Can't insert property into skip list"); } /* end if */ done: /* Release the temporary value buffer */ if(tmp_value!=NULL) H5MM_xfree(tmp_value); /* Cleanup on failure */ if(ret_value<0) { if(pcopy!=NULL) H5P_free_prop(pcopy); } /* end if */ FUNC_LEAVE_NOAPI(ret_value); } /* end H5P_do_prop_cb1() */ /*------------------------------------------------------------------------- * Function: H5P_init * * Purpose: Initialize the interface from some other layer. * * Return: Success: non-negative * * Failure: negative * * Programmer: Quincey Koziol * Saturday, March 4, 2000 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5P_init(void) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5P_init, FAIL); /* FUNC_ENTER() does all the work */ done: FUNC_LEAVE_NOAPI(ret_value); } /*-------------------------------------------------------------------------- NAME H5P_init_interface -- Initialize interface-specific information USAGE herr_t H5P_init_interface() RETURNS Non-negative on success/Negative on failure DESCRIPTION Initializes any interface-specific data or routines. --------------------------------------------------------------------------*/ static herr_t H5P_init_interface(void) { H5P_genclass_t *root_class; /* Pointer to root property list class created */ H5P_genclass_t *pclass; /* Pointer to property list class to create */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT(H5P_init_interface); /* * Initialize the Generic Property class & object groups. */ if (H5I_init_group(H5I_GENPROP_CLS, H5I_GENPROPCLS_HASHSIZE, 0, (H5I_free_t)H5P_close_class) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL, "unable to initialize atom group"); if (H5I_init_group(H5I_GENPROP_LST, H5I_GENPROPOBJ_HASHSIZE, 0, (H5I_free_t)H5P_close) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL, "unable to initialize atom group"); /* Create root property list class */ /* Allocate the root class */ assert(H5P_CLS_NO_CLASS_g==(-1)); if (NULL==(root_class = H5P_create_class (NULL,"root",1,NULL,NULL,NULL,NULL,NULL,NULL))) HGOTO_ERROR (H5E_PLIST, H5E_CANTINIT, FAIL, "class initialization failed"); /* Register the root class */ if ((H5P_CLS_NO_CLASS_g = H5I_register (H5I_GENPROP_CLS, root_class))<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't register property list class"); /* Register the file creation and file access property classes */ /* Allocate the file creation class */ assert(H5P_CLS_FILE_CREATE_g==(-1)); if (NULL==(pclass = H5P_create_class (root_class,"file create",1,NULL,NULL,NULL,NULL,NULL,NULL))) HGOTO_ERROR (H5E_PLIST, H5E_CANTINIT, FAIL, "class initialization failed"); /* Register the file creation class */ if ((H5P_CLS_FILE_CREATE_g = H5I_register (H5I_GENPROP_CLS, pclass))<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't register property list class"); /* Allocate the file access class */ assert(H5P_CLS_FILE_ACCESS_g==(-1)); if (NULL==(pclass = H5P_create_class (root_class,"file access",1,H5F_acs_create,NULL,H5F_acs_copy,NULL,H5F_acs_close,NULL))) HGOTO_ERROR (H5E_PLIST, H5E_CANTINIT, FAIL, "class initialization failed"); /* Register the file access class */ if ((H5P_CLS_FILE_ACCESS_g = H5I_register (H5I_GENPROP_CLS, pclass))<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't register property list class"); /* Register the dataset creation and data xfer property classes */ /* Allocate the dataset creation class */ assert(H5P_CLS_DATASET_CREATE_g==(-1)); if (NULL==(pclass = H5P_create_class (root_class,"dataset create",1,NULL,NULL,H5D_crt_copy,NULL,H5D_crt_close,NULL))) HGOTO_ERROR (H5E_PLIST, H5E_CANTINIT, FAIL, "class initialization failed"); /* Register the dataset creation class */ if ((H5P_CLS_DATASET_CREATE_g = H5I_register (H5I_GENPROP_CLS, pclass))<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't register property list class"); /* Allocate the data xfer class */ assert(H5P_CLS_DATASET_XFER_g==(-1)); if (NULL==(pclass = H5P_create_class (root_class,"data xfer",1,H5D_xfer_create,NULL,H5D_xfer_copy,NULL,H5D_xfer_close,NULL))) HGOTO_ERROR (H5E_PLIST, H5E_CANTINIT, FAIL, "class initialization failed"); /* Register the data xfer class */ if ((H5P_CLS_DATASET_XFER_g = H5I_register (H5I_GENPROP_CLS, pclass))<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't register property list class"); /* Allocate the mount class */ assert(H5P_CLS_MOUNT_g==(-1)); if (NULL==(pclass = H5P_create_class (root_class,"file mount",1,NULL,NULL,NULL,NULL,NULL,NULL))) HGOTO_ERROR (H5E_PLIST, H5E_CANTINIT, FAIL, "class initialization failed"); /* Register the mount class */ if ((H5P_CLS_MOUNT_g = H5I_register (H5I_GENPROP_CLS, pclass))<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't register property list class"); done: FUNC_LEAVE_NOAPI(ret_value); } /*-------------------------------------------------------------------------- NAME H5P_term_interface PURPOSE Terminate various H5P objects USAGE void H5P_term_interface() RETURNS Non-negative on success/Negative on failure DESCRIPTION Release the atom group and any other resources allocated. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS Can't report errors... EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ int H5P_term_interface(void) { int nlist=0; int nclass=0; int n=0; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5P_term_interface); if (H5_interface_initialize_g) { /* Destroy HDF5 library property classes & lists */ /* Check if there are any open property list classes or lists */ nclass = H5I_nmembers(H5I_GENPROP_CLS); nlist = H5I_nmembers(H5I_GENPROP_LST); n=nclass+nlist; /* If there are any open classes or groups, attempt to get rid of them. */ if (n) { /* Clear the lists */ if(nlist>0) { H5I_clear_group(H5I_GENPROP_LST, FALSE); /* Reset the default property lists, if they've been closed */ if(H5I_nmembers(H5I_GENPROP_LST)==0) { H5P_LST_NO_CLASS_g = H5P_LST_FILE_CREATE_g = H5P_LST_FILE_ACCESS_g = H5P_LST_DATASET_CREATE_g = H5P_LST_DATASET_XFER_g = H5P_LST_MOUNT_g = (-1); } /* end if */ } /* end if */ /* Only attempt to close the classes after all the lists are closed */ if(nlist==0 && nclass>0) { H5I_clear_group(H5I_GENPROP_CLS, FALSE); /* Reset the default property lists, if they've been closed */ if(H5I_nmembers(H5I_GENPROP_CLS)==0) { H5P_CLS_NO_CLASS_g = H5P_CLS_FILE_CREATE_g = H5P_CLS_FILE_ACCESS_g = H5P_CLS_DATASET_CREATE_g = H5P_CLS_DATASET_XFER_g = H5P_CLS_MOUNT_g = (-1); } /* end if */ } /* end if */ } else { H5I_destroy_group(H5I_GENPROP_LST); n++; /*H5I*/ H5I_destroy_group(H5I_GENPROP_CLS); n++; /*H5I*/ H5_interface_initialize_g = 0; } } FUNC_LEAVE_NOAPI(n); } /*-------------------------------------------------------------------------- NAME H5P_copy_pclass PURPOSE Internal routine to copy a generic property class USAGE hid_t H5P_copy_pclass(pclass) H5P_genclass_t *pclass; IN: Property class to copy RETURNS Success: valid property class ID on success (non-negative) Failure: negative DESCRIPTION Copy a property class and return the ID. This routine does not make any callbacks. (They are only make when operating on property lists). GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static H5P_genclass_t * H5P_copy_pclass(H5P_genclass_t *pclass) { H5P_genclass_t *new_pclass = NULL; /* Property list class copied */ H5P_genprop_t *pcopy; /* Copy of property to insert into class */ H5P_genclass_t *ret_value=NULL; /* return value */ FUNC_ENTER_NOAPI_NOINIT(H5P_copy_pclass); assert(pclass); /* * Create new property class object */ /* Create the new property list class */ if (NULL==(new_pclass=H5P_create_class(pclass->parent, pclass->name, 0, pclass->create_func, pclass->create_data, pclass->copy_func, pclass->copy_data, pclass->close_func, pclass->close_data))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, NULL, "unable to create property list class"); /* Copy the properties registered for this class */ if(pclass->nprops>0) { H5SL_node_t *curr_node; /* Current node in skip list */ /* Walk through the properties in the old class */ curr_node=H5SL_first(pclass->props); while(curr_node!=NULL) { /* Make a copy of the class's property */ if((pcopy=H5P_dup_prop(H5SL_item(curr_node),H5P_PROP_WITHIN_CLASS))==NULL) HGOTO_ERROR (H5E_PLIST, H5E_CANTCOPY, NULL,"Can't copy property"); /* Insert the initialized property into the property list */ if(H5P_add_prop(new_pclass->props,pcopy)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTINSERT, NULL,"Can't insert property into class"); /* Increment property count for class */ new_pclass->nprops++; /* Get the next property node in the list */ curr_node=H5SL_next(curr_node); } /* end while */ } /* end if */ /* Set the return value */ ret_value=new_pclass; done: if (ret_value==NULL && new_pclass) H5P_close_class(new_pclass); FUNC_LEAVE_NOAPI(ret_value); } /* H5P_copy_pclass() */ /*-------------------------------------------------------------------------- NAME H5P_copy_plist PURPOSE Internal routine to copy a generic property list USAGE hid_t H5P_copy_plist(old_plist_id) hid_t old_plist_id; IN: Property list ID to copy RETURNS Success: valid property list ID on success (non-negative) Failure: negative DESCRIPTION Copy a property list and return the ID. This routine calls the class 'copy' callback after any property 'copy' callbacks are called (assuming all property 'copy' callbacks return successfully). GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ hid_t H5P_copy_plist(H5P_genplist_t *old_plist) { H5P_genclass_t *tclass; /* Temporary class pointer */ H5P_genplist_t *new_plist=NULL; /* New property list generated from copy */ H5P_genprop_t *tmp; /* Temporary pointer to properties */ H5P_genprop_t *new_prop; /* New property created for copy */ hid_t new_plist_id; /* Property list ID of new list created */ H5SL_node_t *curr_node; /* Current node in skip list */ H5SL_t *seen=NULL; /* Skip list containing properties already seen */ size_t nseen; /* Number of items 'seen' */ hbool_t has_parent_class; /* Flag to indicate that this property list's class has a parent */ hid_t ret_value=FAIL; /* return value */ FUNC_ENTER_NOAPI(H5P_copy_plist, FAIL); assert(old_plist); /* * Create new property list object */ /* Allocate room for the property list */ if (NULL==(new_plist = H5FL_CALLOC(H5P_genplist_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,"memory allocation failed"); /* Set class state */ new_plist->pclass = old_plist->pclass; new_plist->nprops = 0; /* Initially the plist has the same number of properties as the class */ new_plist->class_init = 0; /* Initially, wait until the class callback finishes to set */ /* Initialize the skip list to hold the changed properties */ if((new_plist->props=H5SL_create(H5SL_TYPE_STR,0.5,H5P_DEFAULT_SKIPLIST_HEIGHT))==NULL) HGOTO_ERROR(H5E_PLIST,H5E_CANTCREATE,FAIL,"can't create skip list for changed properties"); /* Create the skip list for deleted properties */ if((new_plist->del=H5SL_create(H5SL_TYPE_STR,0.5,H5P_DEFAULT_SKIPLIST_HEIGHT))==NULL) HGOTO_ERROR(H5E_PLIST,H5E_CANTCREATE,FAIL,"can't create skip list for deleted properties"); /* Create the skip list to hold names of properties already seen * (This prevents a property in the class hierarchy from having it's * 'create' callback called, if a property in the class hierarchy has * already been seen) */ if((seen=H5SL_create(H5SL_TYPE_STR,0.5,H5P_DEFAULT_SKIPLIST_HEIGHT))==NULL) HGOTO_ERROR(H5E_PLIST,H5E_CANTCREATE,FAIL,"can't create skip list for seen properties"); nseen=0; /* Cycle through the deleted properties & copy them into the new list's deleted section */ if(H5SL_count(old_plist->del)>0) { curr_node=H5SL_first(old_plist->del); while(curr_node) { char *new_name; /* Pointer to new name */ /* Duplicate string for insertion into new deleted property skip list */ if((new_name=H5MM_xstrdup((char *)H5SL_item(curr_node)))==NULL) HGOTO_ERROR(H5E_RESOURCE,H5E_NOSPACE,FAIL,"memory allocation failed"); /* Insert property name into deleted list */ if(H5SL_insert(new_plist->del,new_name,new_name)<0) HGOTO_ERROR(H5E_PLIST,H5E_CANTINSERT,FAIL,"can't insert property into deleted skip list"); /* Add property name to "seen" list */ if(H5SL_insert(seen,new_name,new_name)<0) HGOTO_ERROR(H5E_PLIST,H5E_CANTINSERT,FAIL,"can't insert property into seen skip list"); nseen++; /* Get the next property node in the skip list */ curr_node=H5SL_next(curr_node); } /* end while */ } /* end if */ /* Cycle through the properties and copy them also */ if(H5SL_count(old_plist->props)>0) { curr_node=H5SL_first(old_plist->props); while(curr_node) { /* Get a pointer to the node's property */ tmp=H5SL_item(curr_node); /* Make a copy of the list's property */ if((new_prop=H5P_dup_prop(tmp,H5P_PROP_WITHIN_LIST))==NULL) HGOTO_ERROR (H5E_PLIST, H5E_CANTCOPY, FAIL,"Can't copy property"); /* Call property copy callback, if it exists */ if(new_prop->copy) { if((new_prop->copy)(new_prop->name,new_prop->size,new_prop->value)<0) { H5P_free_prop(new_prop); HGOTO_ERROR (H5E_PLIST, H5E_CANTCOPY, FAIL,"Can't copy property"); } /* end if */ } /* end if */ /* Insert the initialized property into the property list */ if(H5P_add_prop(new_plist->props,new_prop)<0) { H5P_free_prop(new_prop); HGOTO_ERROR (H5E_PLIST, H5E_CANTINSERT, FAIL,"Can't insert property into list"); } /* end if */ /* Add property name to "seen" list */ if(H5SL_insert(seen,new_prop->name,new_prop->name)<0) HGOTO_ERROR(H5E_PLIST,H5E_CANTINSERT,FAIL,"can't insert property into seen skip list"); nseen++; /* Increment the number of properties in list */ new_plist->nprops++; /* Get the next property node in the skip list */ curr_node=H5SL_next(curr_node); } /* end while */ } /* end if */ /* * Check for copying class properties (up through list of parent classes also), * initialize each with default value & make property 'copy' callback. */ tclass=old_plist->pclass; has_parent_class=(tclass!=NULL && tclass->parent!=NULL && tclass->parent->nprops>0); while(tclass!=NULL) { if(tclass->nprops>0) { /* Walk through the properties in the old class */ curr_node=H5SL_first(tclass->props); while(curr_node!=NULL) { /* Get pointer to property from node */ tmp=H5SL_item(curr_node); /* Only "copy" properties we haven't seen before */ if(nseen==0 || H5SL_search(seen,tmp->name)==NULL) { /* Call property creation callback, if it exists */ if(tmp->copy) { /* Call the callback & insert changed value into skip list (if necessary) */ if(H5P_do_prop_cb1(new_plist->props,tmp,tmp->copy)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTCOPY, FAIL,"Can't create property"); } /* end if */ /* Add property name to "seen" list, if we have other classes to work on */ if(has_parent_class) { if(H5SL_insert(seen,tmp->name,tmp->name)<0) HGOTO_ERROR(H5E_PLIST,H5E_CANTINSERT,FAIL,"can't insert property into seen skip list"); nseen++; } /* end if */ /* Increment the number of properties in list */ new_plist->nprops++; } /* end if */ /* Get the next property node in the skip list */ curr_node=H5SL_next(curr_node); } /* end while */ } /* end if */ /* Go up to parent class */ tclass=tclass->parent; } /* end while */ /* Increment the number of property lists derived from class */ if(H5P_access_class(new_plist->pclass,H5P_MOD_INC_LST)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTINIT, FAIL,"Can't increment class ref count"); /* Get an atom for the property list */ if ((new_plist_id = H5I_register(H5I_GENPROP_LST, new_plist))<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to atomize property list"); /* Save the property list ID in the property list struct, for use in the property class's 'close' callback */ new_plist->plist_id=new_plist_id; /* Call the class callback (if it exists) now that we have the property list ID */ if(new_plist->pclass->copy_func!=NULL) { if((new_plist->pclass->copy_func)(new_plist_id,old_plist->plist_id,old_plist->pclass->copy_data)<0) { /* Delete ID, ignore return value */ H5I_remove(new_plist_id); HGOTO_ERROR (H5E_PLIST, H5E_CANTINIT, FAIL,"Can't initialize property"); } /* end if */ } /* end if */ /* Set the class initialization flag */ new_plist->class_init=1; /* Set the return value */ ret_value=new_plist_id; done: /* Release the list of 'seen' properties */ if(seen!=NULL) H5SL_close(seen); if (ret_value<0 && new_plist) H5P_close(new_plist); FUNC_LEAVE_NOAPI(ret_value); } /* H5P_copy_plist() */ /*-------------------------------------------------------------------------- NAME H5Pcopy PURPOSE Routine to copy a property list or class USAGE hid_t H5Pcopy(id) hid_t id; IN: Property list or class ID to copy RETURNS Success: valid property list ID on success (non-negative) Failure: negative DESCRIPTION Copy a property list or class and return the ID. This routine calls the class 'copy' callback after any property 'copy' callbacks are called (assuming all property 'copy' callbacks return successfully). GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ hid_t H5Pcopy(hid_t id) { void *obj; /* Property object to copy */ hid_t ret_value=FALSE; /* return value */ FUNC_ENTER_API(H5Pcopy, FAIL); H5TRACE1("i","i",id); if (H5P_DEFAULT==id) HGOTO_DONE(H5P_DEFAULT); /* Check arguments. */ if (H5I_GENPROP_LST != H5I_get_type(id) && H5I_GENPROP_CLS != H5I_get_type(id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not property object"); if(NULL == (obj = H5I_object(id))) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "property object doesn't exist"); /* Compare property lists */ if(H5I_GENPROP_LST == H5I_get_type(id)) { if((ret_value=H5P_copy_plist(obj))<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy property list"); } /* end if */ /* Must be property classes */ else { H5P_genclass_t *copy_class; /* Copy of class */ /* Copy the class */ if((copy_class=H5P_copy_pclass(obj))==NULL) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy property class"); /* Get an atom for the copied class */ if ((ret_value = H5I_register(H5I_GENPROP_CLS, copy_class))<0) { H5P_close_class(copy_class); HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to atomize property list class"); } /* end if */ } /* end else */ done: FUNC_LEAVE_API(ret_value); } /* H5Pcopy() */ /*-------------------------------------------------------------------------- NAME H5P_dup_prop PURPOSE Internal routine to duplicate a property USAGE H5P_genprop_t *H5P_dup_prop(oprop) H5P_genprop_t *oprop; IN: Pointer to property to copy H5P_prop_within_t type; IN: Type of object the property will be inserted into RETURNS Returns a pointer to the newly created duplicate of a property on success, NULL on failure. DESCRIPTION Allocates memory and copies property information into a new property object. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static H5P_genprop_t * H5P_dup_prop(H5P_genprop_t *oprop, H5P_prop_within_t type) { H5P_genprop_t *prop=NULL; /* Pointer to new property copied */ H5P_genprop_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5P_dup_prop); assert(oprop); assert(type!=H5P_PROP_WITHIN_UNKNOWN); /* Allocate the new property */ if (NULL==(prop = H5FL_MALLOC (H5P_genprop_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); /* Copy basic property information */ HDmemcpy(prop,oprop,sizeof(H5P_genprop_t)); /* Check if we should duplicate the name or share it */ /* Duplicating property for a class */ if(type==H5P_PROP_WITHIN_CLASS) { assert(oprop->type==H5P_PROP_WITHIN_CLASS); assert(oprop->shared_name==0); /* Duplicate name */ prop->name = H5MM_xstrdup(oprop->name); } /* end if */ /* Duplicating property for a list */ else { /* Check if we are duplicating a property from a list or a class */ /* Duplicating a property from a list */ if(oprop->type==H5P_PROP_WITHIN_LIST) { /* If the old property's name wasn't shared, we have to copy it here also */ if(!oprop->shared_name) prop->name = H5MM_xstrdup(oprop->name); } /* end if */ /* Duplicating a property from a class */ else { assert(oprop->type==H5P_PROP_WITHIN_CLASS); assert(oprop->shared_name==0); /* Share the name */ prop->shared_name=1; /* Set the type */ prop->type=type; } /* end else */ } /* end else */ /* Duplicate current value, if it exists */ if(oprop->value!=NULL) { assert(prop->size>0); if (NULL==(prop->value = H5MM_malloc (prop->size))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); HDmemcpy(prop->value,oprop->value,prop->size); } /* end if */ /* Set return value */ ret_value=prop; done: /* Free any resources allocated */ if(ret_value==NULL) { if(prop!=NULL) { if(prop->name!=NULL) H5MM_xfree(prop->name); if(prop->value!=NULL) H5MM_xfree(prop->value); H5FL_FREE(H5P_genprop_t,prop); } /* end if */ } /* end if */ FUNC_LEAVE_NOAPI(ret_value); } /* H5P_dup_prop() */ /*-------------------------------------------------------------------------- NAME H5P_create_prop PURPOSE Internal routine to create a new property USAGE H5P_genprop_t *H5P_create_prop(name,size,type,value,prp_create,prp_set, prp_get,prp_delete,prp_close) const char *name; IN: Name of property to register size_t size; IN: Size of property in bytes H5P_prop_within_t type; IN: Type of object the property will be inserted into void *value; IN: Pointer to buffer containing value for property H5P_prp_create_func_t prp_create; IN: Function pointer to property creation callback H5P_prp_set_func_t prp_set; IN: Function pointer to property set callback H5P_prp_get_func_t prp_get; IN: Function pointer to property get callback H5P_prp_delete_func_t prp_delete; IN: Function pointer to property delete callback H5P_prp_copy_func_t prp_copy; IN: Function pointer to property copy callback H5P_prp_compare_func_t prp_cmp; IN: Function pointer to property compare callback H5P_prp_close_func_t prp_close; IN: Function pointer to property close callback RETURNS Returns a pointer to the newly created property on success, NULL on failure. DESCRIPTION Allocates memory and copies property information into a new property object. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static H5P_genprop_t * H5P_create_prop(const char *name, size_t size, H5P_prop_within_t type, void *value, H5P_prp_create_func_t prp_create, H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get, H5P_prp_delete_func_t prp_delete, H5P_prp_copy_func_t prp_copy, H5P_prp_compare_func_t prp_cmp, H5P_prp_close_func_t prp_close) { H5P_genprop_t *prop=NULL; /* Pointer to new property copied */ H5P_genprop_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5P_create_prop); assert(name); assert((size>0 && value!=NULL) || (size==0)); assert(type!=H5P_PROP_WITHIN_UNKNOWN); /* Allocate the new property */ if (NULL==(prop = H5FL_MALLOC (H5P_genprop_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); /* Set the property initial values */ prop->name = H5MM_xstrdup(name); /* Duplicate name */ prop->shared_name=0; prop->size=size; prop->type=type; /* Duplicate value, if it exists */ if(value!=NULL) { if (NULL==(prop->value = H5MM_malloc (prop->size))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); HDmemcpy(prop->value,value,prop->size); } /* end if */ else prop->value=NULL; /* Set the function pointers */ prop->create=prp_create; prop->set=prp_set; prop->get=prp_get; prop->del=prp_delete; prop->copy=prp_copy; /* Use custom comparison routine if available, otherwise default to memcmp() */ if(prp_cmp!=NULL) prop->cmp=prp_cmp; else prop->cmp=&memcmp; prop->close=prp_close; /* Set return value */ ret_value=prop; done: /* Free any resources allocated */ if(ret_value==NULL) { if(prop!=NULL) { if(prop->name!=NULL) H5MM_xfree(prop->name); if(prop->value!=NULL) H5MM_xfree(prop->value); H5FL_FREE(H5P_genprop_t,prop); } /* end if */ } /* end if */ FUNC_LEAVE_NOAPI(ret_value); } /* H5P_create_prop() */ /*-------------------------------------------------------------------------- NAME H5P_add_prop PURPOSE Internal routine to insert a property into a property skip list USAGE herr_t H5P_add_prop(slist, prop) H5SL_t *slist; IN/OUT: Pointer to skip list of properties H5P_genprop_t *prop; IN: Pointer to property to insert RETURNS Returns non-negative on success, negative on failure. DESCRIPTION Inserts a property into a skip list of properties. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5P_add_prop(H5SL_t *slist, H5P_genprop_t *prop) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5P_add_prop,FAIL); assert(slist); assert(prop); assert(prop->type!=H5P_PROP_WITHIN_UNKNOWN); /* Insert property into skip list */ if(H5SL_insert(slist,prop,prop->name)<0) HGOTO_ERROR(H5E_PLIST,H5E_CANTINSERT,FAIL,"can't insert property into skip list"); done: FUNC_LEAVE_NOAPI(ret_value); } /* H5P_add_prop() */ /*-------------------------------------------------------------------------- NAME H5P_find_prop_plist PURPOSE Internal routine to check for a property in a property list's skip list USAGE H5P_genprop_t *H5P_find_prop(plist, name) H5P_genplist_t *plist; IN: Pointer to property list to check const char *name; IN: Name of property to check for RETURNS Returns pointer to property on success, NULL on failure. DESCRIPTION Checks for a property in a property list's skip list of properties. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static H5P_genprop_t * H5P_find_prop_plist(H5P_genplist_t *plist, const char *name) { H5P_genprop_t *ret_value; /* Property pointer return value */ FUNC_ENTER_NOAPI_NOINIT(H5P_find_prop_plist); assert(plist); assert(name); /* Check if the property has been deleted from list */ if(H5SL_search(plist->del,name)!=NULL) { HGOTO_ERROR(H5E_PLIST,H5E_NOTFOUND,NULL,"can't find property in skip list"); } /* end if */ else { /* Get the property data from the skip list */ if((ret_value=H5SL_search(plist->props,name))==NULL) { H5P_genclass_t *tclass; /* Temporary class pointer */ /* Couldn't find property in list itself, start searching through class info */ tclass=plist->pclass; while(tclass!=NULL) { /* Find the property in the class */ if((ret_value=H5SL_search(tclass->props,name))!=NULL) /* Got pointer to property - leave now */ break; /* Go up to parent class */ tclass=tclass->parent; } /* end while */ /* Check if we haven't found the property */ if(ret_value==NULL) HGOTO_ERROR(H5E_PLIST,H5E_NOTFOUND,NULL,"can't find property in skip list"); } /* end else */ } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value); } /* H5P_find_prop_plist() */ /*-------------------------------------------------------------------------- NAME H5P_find_prop_pclass PURPOSE Internal routine to check for a property in a class skip list USAGE H5P_genprop_t *H5P_find_prop_class(pclass, name) H5P_genclass *pclass; IN: Pointer generic property class to check const char *name; IN: Name of property to check for RETURNS Returns pointer to property on success, NULL on failure. DESCRIPTION Checks for a property in a class's skip list of properties. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static H5P_genprop_t * H5P_find_prop_pclass(H5P_genclass_t *pclass, const char *name) { H5P_genprop_t *ret_value; /* Property pointer return value */ FUNC_ENTER_NOAPI_NOINIT(H5P_find_prop_pclass); assert(pclass); assert(name); /* Get the property from the skip list */ if((ret_value=H5SL_search(pclass->props,name))==NULL) HGOTO_ERROR(H5E_PLIST,H5E_NOTFOUND,NULL,"can't find property in skip list"); done: FUNC_LEAVE_NOAPI(ret_value); } /* H5P_find_prop_pclass() */ /*-------------------------------------------------------------------------- NAME H5P_free_prop PURPOSE Internal routine to destroy a property node USAGE herr_t H5P_free_prop(prop) H5P_genprop_t *prop; IN: Pointer to property to destroy RETURNS Returns non-negative on success, negative on failure. DESCRIPTION Releases all the memory for a property list. Does _not_ call the properties 'close' callback, that should already have been done. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5P_free_prop(H5P_genprop_t *prop) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5P_free_prop); assert(prop); /* Release the property value if it exists */ if(prop->value) H5MM_xfree(prop->value); /* Only free the name if we own it */ if(prop->shared_name==0) H5MM_xfree(prop->name); H5FL_FREE(H5P_genprop_t,prop); FUNC_LEAVE_NOAPI(SUCCEED); } /* H5P_free_prop() */ /*-------------------------------------------------------------------------- NAME H5P_free_prop_cb PURPOSE Internal routine to properties from a property skip list USAGE herr_t H5P_free_prop_cb(item, key, op_data) void *item; IN/OUT: Pointer to property void *key; IN/OUT: Pointer to property key void *_make_cb; IN: Whether to make property callbacks or not RETURNS Returns zero on success, negative on failure. DESCRIPTION Calls the property 'close' callback for a property & frees property info. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5P_free_prop_cb(void *item, void UNUSED *key, void *op_data) { H5P_genprop_t *tprop=(H5P_genprop_t *)item; /* Temporary pointer to property */ unsigned make_cb=*(unsigned *)op_data; /* Whether to make property 'close' callback */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5P_free_prop_cb); assert(tprop); /* Call the close callback and ignore the return value, there's nothing we can do about it */ if(make_cb && tprop->close!=NULL) (tprop->close)(tprop->name,tprop->size,tprop->value); /* Free the property, ignoring return value, nothing we can do */ H5P_free_prop(tprop); FUNC_LEAVE_NOAPI(0); } /* H5P_free_prop_cb() */ /*-------------------------------------------------------------------------- NAME H5P_free_del_name_cb PURPOSE Internal routine to free 'deleted' property name USAGE herr_t H5P_free_del_name_cb(item, key, op_data) void *item; IN/OUT: Pointer to deleted name void *key; IN/OUT: Pointer to key void *op_data; IN: Operator callback data (unused) RETURNS Returns zero on success, negative on failure. DESCRIPTION Frees the deleted property name GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5P_free_del_name_cb(void *item, void UNUSED *key, void UNUSED *op_data) { char *del_name=(char *)item; /* Temporary pointer to deleted name */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5P_free_del_name_cb); assert(del_name); /* Free the name */ H5MM_xfree(del_name); FUNC_LEAVE_NOAPI(0); } /* H5P_free_del_name_cb() */ /*-------------------------------------------------------------------------- NAME H5P_access_class PURPOSE Internal routine to increment or decrement list & class dependancies on a property list class USAGE herr_t H5P_access_class(pclass,mod) H5P_genclass_t *pclass; IN: Pointer to class to modify H5P_class_mod_t mod; IN: Type of modification to class RETURNS Returns non-negative on success, negative on failure. DESCRIPTION Increment/Decrement the class or list dependancies for a given class. This routine is the final arbiter on decisions about actually releasing a class in memory, such action is only taken when the reference counts for both dependent classes & lists reach zero. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5P_access_class(H5P_genclass_t *pclass, H5P_class_mod_t mod) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5P_access_class); assert(pclass); assert(mod>H5P_MOD_ERR && modclasses++; break; case H5P_MOD_DEC_CLS: /* Decrement the dependant class count*/ pclass->classes--; break; case H5P_MOD_INC_LST: /* Increment the dependant list count*/ pclass->plists++; break; case H5P_MOD_DEC_LST: /* Decrement the dependant list count*/ pclass->plists--; break; case H5P_MOD_INC_REF: /* Increment the ID reference count*/ /* Reset the deleted flag if incrementing the reference count */ if(pclass->deleted) pclass->deleted=0; pclass->ref_count++; break; case H5P_MOD_DEC_REF: /* Decrement the ID reference count*/ pclass->ref_count--; /* Mark the class object as deleted if reference count drops to zero */ if(pclass->ref_count==0) pclass->deleted=1; break; case H5P_MOD_ERR: case H5P_MOD_MAX: assert(0 && "Invalid H5P class modification"); } /* end switch */ /* Check if we can release the class information now */ if(pclass->deleted && pclass->plists==0 && pclass->classes==0 ) { H5P_genclass_t *par_class=pclass->parent; /* Pointer to class's parent */ assert(pclass->name); H5MM_xfree(pclass->name); /* Free the class properties without making callbacks */ if(pclass->props) { unsigned make_cb=0; H5SL_destroy(pclass->props,H5P_free_prop_cb,&make_cb); } /* end if */ H5FL_FREE(H5P_genclass_t,pclass); /* Reduce the number of dependent classes on parent class also */ if(par_class!=NULL) H5P_access_class(par_class, H5P_MOD_DEC_CLS); } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED); } /* H5P_access_class() */ /*-------------------------------------------------------------------------- NAME H5P_check_class PURPOSE Internal callback routine to check for duplicated names in parent class. USAGE int H5P_check_class(obj, id, key) H5P_genclass_t *obj; IN: Pointer to class hid_t id; IN: ID of object being looked at const void *key; IN: Pointer to information used to compare classes. RETURNS Returns >0 on match, 0 on no match and <0 on failure. DESCRIPTION Checks whether a property list class has the same parent and name as a new class being created. This is a callback routine for H5I_search() GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static int H5P_check_class(void *_obj, hid_t UNUSED id, void *_key) { H5P_genclass_t *obj=(H5P_genclass_t *)_obj; /* Pointer to the class for this ID */ const H5P_check_class_t *key=(const H5P_check_class_t *)_key; /* Pointer to key information for comparison */ int ret_value=0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5P_check_class); assert(obj); assert(H5I_GENPROP_CLS==H5I_get_type(id)); assert(key); /* Check if the class object has the same parent as the new class */ if(obj->parent==key->parent) { /* Check if they have the same name */ if(HDstrcmp(obj->name,key->name)==0) ret_value=1; /* Indicate a match */ } /* end if */ FUNC_LEAVE_NOAPI(ret_value); } /* end H5P_check_class() */ /*-------------------------------------------------------------------------- NAME H5P_create_class PURPOSE Internal routine to create a new property list class. USAGE H5P_genclass_t H5P_create_class(par_class, name, internal, cls_create, create_data, cls_close, close_data) H5P_genclass_t *par_class; IN: Pointer to parent class const char *name; IN: Name of class we are creating unsigned internal; IN: Whether this is an internal class or not H5P_cls_create_func_t; IN: The callback function to call when each property list in this class is created. void *create_data; IN: Pointer to user data to pass along to class creation callback. H5P_cls_copy_func_t; IN: The callback function to call when each property list in this class is copied. void *copy_data; IN: Pointer to user data to pass along to class copy callback. H5P_cls_close_func_t; IN: The callback function to call when each property list in this class is closed. void *close_data; IN: Pointer to user data to pass along to class close callback. RETURNS Returns a pointer to the newly created property list class on success, NULL on failure. DESCRIPTION Allocates memory and attaches a class to the property list class hierarchy. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static H5P_genclass_t * H5P_create_class(H5P_genclass_t *par_class, const char *name, unsigned internal, H5P_cls_create_func_t cls_create, void *create_data, H5P_cls_copy_func_t cls_copy, void *copy_data, H5P_cls_close_func_t cls_close, void *close_data ) { H5P_genclass_t *pclass=NULL; /* Property list class created */ H5P_genclass_t *ret_value; /* return value */ FUNC_ENTER_NOAPI_NOINIT(H5P_create_class); assert(name); /* Allow internal classes to break some rules */ /* (This allows the root of the tree to be created with this routine -QAK) */ if(!internal) { assert(par_class); } /* Allocate room for the class */ if (NULL==(pclass = H5FL_CALLOC(H5P_genclass_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,"memory allocation failed"); /* Set class state */ pclass->parent = par_class; pclass->name = H5MM_xstrdup(name); pclass->nprops = 0; /* Classes are created without properties initially */ pclass->plists = 0; /* No properties lists of this class yet */ pclass->classes = 0; /* No classes derived from this class yet */ pclass->ref_count = 1; /* This is the first reference to the new class */ pclass->internal = internal; pclass->deleted = 0; /* Not deleted yet... :-) */ pclass->revision = H5P_GET_NEXT_REV; /* Get a revision number for the class */ /* Create the skip list for properties */ if((pclass->props=H5SL_create(H5SL_TYPE_STR,0.5,H5P_DEFAULT_SKIPLIST_HEIGHT))==NULL) HGOTO_ERROR(H5E_PLIST,H5E_CANTCREATE,NULL,"can't create skip list for properties"); /* Set callback functions and pass-along data */ pclass->create_func = cls_create; pclass->create_data = create_data; pclass->copy_func = cls_copy; pclass->copy_data = copy_data; pclass->close_func = cls_close; pclass->close_data = close_data; /* Increment parent class's derived class value */ if(par_class!=NULL) { if(H5P_access_class(par_class,H5P_MOD_INC_CLS)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTINIT, NULL,"Can't increment parent class ref count"); } /* end if */ /* Set return value */ ret_value=pclass; done: /* Free any resources allocated */ if(ret_value==NULL) { if(pclass!=NULL) H5FL_FREE(H5P_genclass_t,pclass); } FUNC_LEAVE_NOAPI(ret_value); } /* H5P_create_class() */ /*-------------------------------------------------------------------------- NAME H5Pcreate_class PURPOSE Create a new property list class. USAGE hid_t H5Pcreate_class(parent, name, cls_create, create_data, cls_close, close_data) hid_t parent; IN: Property list class ID of parent class const char *name; IN: Name of class we are creating H5P_cls_create_func_t cls_create; IN: The callback function to call when each property list in this class is created. void *create_data; IN: Pointer to user data to pass along to class creation callback. H5P_cls_copy_func_t cls_copy; IN: The callback function to call when each property list in this class is copied. void *copy_data; IN: Pointer to user data to pass along to class copy callback. H5P_cls_close_func_t cls_close; IN: The callback function to call when each property list in this class is closed. void *close_data; IN: Pointer to user data to pass along to class close callback. RETURNS Returns a valid property list class ID on success, NULL on failure. DESCRIPTION Allocates memory and attaches a class to the property list class hierarchy. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ hid_t H5Pcreate_class(hid_t parent, const char *name, H5P_cls_create_func_t cls_create, void *create_data, H5P_cls_copy_func_t cls_copy, void *copy_data, H5P_cls_close_func_t cls_close, void *close_data ) { H5P_genclass_t *par_class = NULL; /* Pointer to the parent class */ H5P_genclass_t *pclass = NULL; /* Property list class created */ hid_t ret_value; /* Return value */ FUNC_ENTER_API(H5Pcreate_class, FAIL); H5TRACE8("i","isxxxxxx",parent,name,cls_create,create_data,cls_copy, copy_data,cls_close,close_data); /* Check arguments. */ if (H5P_DEFAULT!=parent && (H5I_GENPROP_CLS!=H5I_get_type(parent))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class"); if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid class name"); if ((create_data!=NULL && cls_create==NULL) || (copy_data!=NULL && cls_copy==NULL) || (close_data!=NULL && cls_close==NULL)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "data specified, but no callback provided"); /* Get the pointer to the parent class */ if(parent==H5P_DEFAULT) par_class=NULL; else if (NULL == (par_class = H5I_object(parent))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't retrieve parent class"); /* Create the new property list class */ if (NULL==(pclass=H5P_create_class(par_class, name, 0, cls_create, create_data, cls_copy, copy_data, cls_close, close_data))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, FAIL, "unable to create property list class"); /* Get an atom for the class */ if ((ret_value = H5I_register(H5I_GENPROP_CLS, pclass))<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to atomize property list class"); done: if (ret_value<0 && pclass) H5P_close_class(pclass); FUNC_LEAVE_API(ret_value); } /* H5Pcreate_class() */ /*-------------------------------------------------------------------------- NAME H5P_create PURPOSE Internal routine to create a new property list of a property list class. USAGE H5P_genplist_t *H5P_create(class) H5P_genclass_t *class; IN: Property list class create list from RETURNS Returns a pointer to the newly created property list on success, NULL on failure. DESCRIPTION Creates a property list of a given class. If a 'create' callback exists for the property list class, it is called before the property list is passed back to the user. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS If this routine is called from a library routine other than H5P_c, the calling routine is responsible for getting an ID for the property list and calling the class 'create' callback (if one exists) and also setting the "class_init" flag. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static H5P_genplist_t * H5P_create(H5P_genclass_t *pclass) { H5P_genclass_t *tclass; /* Temporary class pointer */ H5P_genplist_t *plist=NULL; /* New property list created */ H5P_genprop_t *tmp; /* Temporary pointer to parent class properties */ H5SL_t *seen=NULL; /* Skip list to hold names of properties already seen */ H5P_genplist_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5P_create); assert(pclass); /* * Create new property list object */ /* Allocate room for the property list */ if (NULL==(plist = H5FL_CALLOC(H5P_genplist_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,"memory allocation failed"); /* Set class state */ plist->pclass = pclass; plist->nprops = 0; /* Initially the plist has the same number of properties as the class */ plist->class_init = 0; /* Initially, wait until the class callback finishes to set */ /* Create the skip list for changed properties */ if((plist->props=H5SL_create(H5SL_TYPE_STR,0.5,H5P_DEFAULT_SKIPLIST_HEIGHT))==NULL) HGOTO_ERROR(H5E_PLIST,H5E_CANTCREATE,NULL,"can't create skip list for changed properties"); /* Create the skip list for deleted properties */ if((plist->del=H5SL_create(H5SL_TYPE_STR,0.5,H5P_DEFAULT_SKIPLIST_HEIGHT))==NULL) HGOTO_ERROR(H5E_PLIST,H5E_CANTCREATE,NULL,"can't create skip list for deleted properties"); /* Create the skip list to hold names of properties already seen * (This prevents a property in the class hierarchy from having it's * 'create' callback called, if a property in the class hierarchy has * already been seen) */ if((seen=H5SL_create(H5SL_TYPE_STR,0.5,H5P_DEFAULT_SKIPLIST_HEIGHT))==NULL) HGOTO_ERROR(H5E_PLIST,H5E_CANTCREATE,NULL,"can't create skip list for seen properties"); /* * Check if we should copy class properties (up through list of parent classes also), * initialize each with default value & make property 'create' callback. */ tclass=pclass; while(tclass!=NULL) { if(tclass->nprops>0) { H5SL_node_t *curr_node; /* Current node in skip list */ /* Walk through the properties in the old class */ curr_node=H5SL_first(tclass->props); while(curr_node!=NULL) { /* Get pointer to property from node */ tmp=H5SL_item(curr_node); /* Only "create" properties we haven't seen before */ if(H5SL_search(seen,tmp->name)==NULL) { /* Call property creation callback, if it exists */ if(tmp->create) { /* Call the callback & insert changed value into skip list (if necessary) */ if(H5P_do_prop_cb1(plist->props,tmp,tmp->create)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTCOPY, NULL,"Can't create property"); } /* end if */ /* Add property name to "seen" list */ if(H5SL_insert(seen,tmp->name,tmp->name)<0) HGOTO_ERROR(H5E_PLIST,H5E_CANTINSERT,NULL,"can't insert property into seen skip list"); /* Increment the number of properties in list */ plist->nprops++; } /* end if */ /* Get the next property node in the skip list */ curr_node=H5SL_next(curr_node); } /* end while */ } /* end if */ /* Go up to parent class */ tclass=tclass->parent; } /* end while */ /* Increment the number of property lists derived from class */ if(H5P_access_class(plist->pclass,H5P_MOD_INC_LST)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTINIT, NULL,"Can't increment class ref count"); /* Set return value */ ret_value=plist; done: /* Release the skip list of 'seen' properties */ if(seen!=NULL) H5SL_close(seen); /* Release resources allocated on failure */ if(ret_value==NULL) { if(plist!=NULL) { /* Close & free any changed properties */ if(plist->props) { unsigned make_cb=1; H5SL_destroy(plist->props,H5P_free_prop_cb,&make_cb); } /* end if */ /* Close the deleted property skip list */ if(plist->del) H5SL_close(plist->del); /* Release the property list itself */ H5FL_FREE(H5P_genplist_t,plist); } /* end if */ } /* end if */ FUNC_LEAVE_NOAPI(ret_value); } /* H5P_create() */ /*-------------------------------------------------------------------------- NAME H5P_create_id PURPOSE Internal routine to create a new property list of a property list class. USAGE hid_t H5P_create_id(pclass) H5P_genclass_t *pclass; IN: Property list class create list from RETURNS Returns a valid property list ID on success, FAIL on failure. DESCRIPTION Creates a property list of a given class. If a 'create' callback exists for the property list class, it is called before the property list is passed back to the user. If 'create' callbacks exist for any individual properties in the property list, they are called before the class 'create' callback. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ hid_t H5P_create_id(H5P_genclass_t *pclass) { H5P_genplist_t *plist=NULL; /* Property list created */ hid_t plist_id=FAIL; /* Property list ID */ hid_t ret_value; /* return value */ FUNC_ENTER_NOAPI(H5P_create_id, FAIL); assert(pclass); /* Create the new property list */ if ((plist=H5P_create(pclass))==NULL) HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, FAIL, "unable to create property list"); /* Get an atom for the property list */ if ((plist_id = H5I_register(H5I_GENPROP_LST, plist))<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to atomize property list"); /* Save the property list ID in the property list struct, for use in the property class's 'close' callback */ plist->plist_id=plist_id; /* Call the class callback (if it exists) now that we have the property list ID */ if(plist->pclass->create_func!=NULL) { if((plist->pclass->create_func)(plist_id,plist->pclass->create_data)<0) { /* Delete ID, ignore return value */ H5I_remove(plist_id); HGOTO_ERROR (H5E_PLIST, H5E_CANTINIT, FAIL,"Can't initialize property"); } /* end if */ } /* end if */ /* Set the class initialization flag */ plist->class_init=1; /* Set the return value */ ret_value=plist_id; done: if (ret_value<0 && plist) H5P_close(plist); FUNC_LEAVE_NOAPI(ret_value); } /* H5P_create_id() */ /*-------------------------------------------------------------------------- NAME H5Pcreate PURPOSE Routine to create a new property list of a property list class. USAGE hid_t H5Pcreate(cls_id) hid_t cls_id; IN: Property list class create list from RETURNS Returns a valid property list ID on success, FAIL on failure. DESCRIPTION Creates a property list of a given class. If a 'create' callback exists for the property list class, it is called before the property list is passed back to the user. If 'create' callbacks exist for any individual properties in the property list, they are called before the class 'create' callback. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ hid_t H5Pcreate(hid_t cls_id) { H5P_genclass_t *pclass; /* Property list class to modify */ hid_t ret_value; /* return value */ FUNC_ENTER_API(H5Pcreate, FAIL); H5TRACE1("i","i",cls_id); /* Check arguments. */ if (NULL == (pclass = H5I_object_verify(cls_id, H5I_GENPROP_CLS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class"); /* Create the new property list */ if((ret_value=H5P_create_id(pclass))<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, FAIL, "unable to create property list"); done: FUNC_LEAVE_API(ret_value); } /* H5Pcreate() */ /*-------------------------------------------------------------------------- NAME H5P_register PURPOSE Internal routine to register a new property in a property list class. USAGE herr_t H5P_register(class, name, size, default, prp_create, prp_set, prp_get, prp_close) H5P_genclass_t *class; IN: Property list class to close const char *name; IN: Name of property to register size_t size; IN: Size of property in bytes void *def_value; IN: Pointer to buffer containing default value for property in newly created property lists H5P_prp_create_func_t prp_create; IN: Function pointer to property creation callback H5P_prp_set_func_t prp_set; IN: Function pointer to property set callback H5P_prp_get_func_t prp_get; IN: Function pointer to property get callback H5P_prp_delete_func_t prp_delete; IN: Function pointer to property delete callback H5P_prp_copy_func_t prp_copy; IN: Function pointer to property copy callback H5P_prp_compare_func_t prp_cmp; IN: Function pointer to property compare callback H5P_prp_close_func_t prp_close; IN: Function pointer to property close callback RETURNS Returns non-negative on success, negative on failure. DESCRIPTION Registers a new property with a property list class. The property will exist in all property list objects of that class after this routine is finished. The name of the property must not already exist. The default property value must be provided and all new property lists created with this property will have the property value set to the default provided. Any of the callback routines may be set to NULL if they are not needed. Zero-sized properties are allowed and do not store any data in the property list. These may be used as flags to indicate the presence or absence of a particular piece of information. The 'default' pointer for a zero-sized property may be set to NULL. The property 'create' & 'close' callbacks are called for zero-sized properties, but the 'set' and 'get' callbacks are never called. The 'create' callback is called when a new property list with this property is being created. H5P_prp_create_func_t is defined as: typedef herr_t (*H5P_prp_create_func_t)(hid_t prop_id, const char *name, size_t size, void *initial_value); where the parameters to the callback function are: hid_t prop_id; IN: The ID of the property list being created. const char *name; IN: The name of the property being modified. size_t size; IN: The size of the property value void *initial_value; IN/OUT: The initial value for the property being created. (The 'default' value passed to H5Pregister) The 'create' routine may modify the value to be set and those changes will be stored as the initial value of the property. If the 'create' routine returns a negative value, the new property value is not copied into the property and the property list creation routine returns an error value. The 'set' callback is called before a new value is copied into the property. H5P_prp_set_func_t is defined as: typedef herr_t (*H5P_prp_set_func_t)(hid_t prop_id, const char *name, size_t size, void *value); where the parameters to the callback function are: hid_t prop_id; IN: The ID of the property list being modified. const char *name; IN: The name of the property being modified. size_t size; IN: The size of the property value void *new_value; IN/OUT: The value being set for the property. The 'set' routine may modify the value to be set and those changes will be stored as the value of the property. If the 'set' routine returns a negative value, the new property value is not copied into the property and the property list set routine returns an error value. The 'get' callback is called before a value is retrieved from the property. H5P_prp_get_func_t is defined as: typedef herr_t (*H5P_prp_get_func_t)(hid_t prop_id, const char *name, size_t size, void *value); where the parameters to the callback function are: hid_t prop_id; IN: The ID of the property list being queried. const char *name; IN: The name of the property being queried. size_t size; IN: The size of the property value void *value; IN/OUT: The value being retrieved for the property. The 'get' routine may modify the value to be retrieved and those changes will be returned to the calling function. If the 'get' routine returns a negative value, the property value is returned and the property list get routine returns an error value. The 'delete' callback is called when a property is deleted from a property list. H5P_prp_del_func_t is defined as: typedef herr_t (*H5P_prp_del_func_t)(hid_t prop_id, const char *name, size_t size, void *value); where the parameters to the callback function are: hid_t prop_id; IN: The ID of the property list the property is deleted from. const char *name; IN: The name of the property being deleted. size_t size; IN: The size of the property value void *value; IN/OUT: The value of the property being deleted. The 'delete' routine may modify the value passed in, but the value is not used by the library when the 'delete' routine returns. If the 'delete' routine returns a negative value, the property list deletion routine returns an error value but the property is still deleted. The 'copy' callback is called when a property list with this property is copied. H5P_prp_copy_func_t is defined as: typedef herr_t (*H5P_prp_copy_func_t)(const char *name, size_t size, void *value); where the parameters to the callback function are: const char *name; IN: The name of the property being copied. size_t size; IN: The size of the property value void *value; IN: The value of the property being copied. The 'copy' routine may modify the value to be copied and those changes will be stored as the value of the property. If the 'copy' routine returns a negative value, the new property value is not copied into the property and the property list copy routine returns an error value. The 'compare' callback is called when a property list with this property is compared to another property list. H5P_prp_compare_func_t is defined as: typedef int (*H5P_prp_compare_func_t)( void *value1, void *value2, size_t size); where the parameters to the callback function are: const void *value1; IN: The value of the first property being compared. const void *value2; IN: The value of the second property being compared. size_t size; IN: The size of the property value The 'compare' routine may not modify the values to be compared. The 'compare' routine should return a positive value if VALUE1 is greater than VALUE2, a negative value if VALUE2 is greater than VALUE1 and zero if VALUE1 and VALUE2 are equal. The 'close' callback is called when a property list with this property is being destroyed. H5P_prp_close_func_t is defined as: typedef herr_t (*H5P_prp_close_func_t)(const char *name, size_t size, void *value); where the parameters to the callback function are: const char *name; IN: The name of the property being closed. size_t size; IN: The size of the property value void *value; IN: The value of the property being closed. The 'close' routine may modify the value passed in, but the value is not used by the library when the 'close' routine returns. If the 'close' routine returns a negative value, the property list close routine returns an error value but the property list is still closed. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS The 'set' callback function may be useful to range check the value being set for the property or may perform some tranformation/translation of the value set. The 'get' callback would then [probably] reverse the transformation, etc. A single 'get' or 'set' callback could handle multiple properties by performing different actions based on the property name or other properties in the property list. I would like to say "the property list is not closed" when a 'close' routine fails, but I don't think that's possible due to other properties in the list being successfully closed & removed from the property list. I suppose that it would be possible to just remove the properties which have successful 'close' callbacks, but I'm not happy with the ramifications of a mangled, un-closable property list hanging around... Any comments? -QAK EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5P_register(H5P_genclass_t *pclass, const char *name, size_t size, void *def_value, H5P_prp_create_func_t prp_create, H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get, H5P_prp_delete_func_t prp_delete, H5P_prp_copy_func_t prp_copy, H5P_prp_compare_func_t prp_cmp, H5P_prp_close_func_t prp_close) { H5P_genclass_t *new_class; /* New class pointer */ H5P_genprop_t *new_prop=NULL; /* Temporary property pointer */ H5P_genprop_t *pcopy; /* Property copy */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5P_register, FAIL); assert(pclass); assert(name); assert((size>0 && def_value!=NULL) || (size==0)); /* Check for duplicate named properties */ if(H5SL_search(pclass->props,name)!=NULL) HGOTO_ERROR(H5E_PLIST, H5E_EXISTS, FAIL, "property already exists"); /* Check if class needs to be split because property lists or classes have * been created since the last modification was made to the class. */ if(pclass->plists>0 || pclass->classes>0) { if((new_class=H5P_create_class(pclass->parent,pclass->name, pclass->internal,pclass->create_func,pclass->create_data, pclass->copy_func,pclass->copy_data, pclass->close_func,pclass->close_data))==NULL) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy class"); /* Walk through the skip list of the old class and copy properties */ if(pclass->nprops>0) { H5SL_node_t *curr_node; /* Current node in skip list */ /* Walk through the properties in the old class */ curr_node=H5SL_first(pclass->props); while(curr_node!=NULL) { /* Make a copy of the class's property */ if((pcopy=H5P_dup_prop(H5SL_item(curr_node),H5P_PROP_WITHIN_CLASS))==NULL) HGOTO_ERROR (H5E_PLIST, H5E_CANTCOPY, FAIL,"Can't copy property"); /* Insert the initialized property into the property list */ if(H5P_add_prop(new_class->props,pcopy)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTINSERT, FAIL,"Can't insert property into class"); /* Increment property count for class */ new_class->nprops++; /* Get the next property node in the skip list */ curr_node=H5SL_next(curr_node); } /* end while */ } /* end if */ /* Use the new class instead of the old one */ pclass=new_class; } /* end if */ /* Create property object from parameters */ if((new_prop=H5P_create_prop(name,size,H5P_PROP_WITHIN_CLASS,def_value,prp_create,prp_set,prp_get,prp_delete,prp_copy,prp_cmp,prp_close))==NULL) HGOTO_ERROR (H5E_PLIST, H5E_CANTCREATE, FAIL,"Can't create property"); /* Insert property into property list class */ if(H5P_add_prop(pclass->props,new_prop)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTINSERT, FAIL,"Can't insert property into class"); /* Increment property count for class */ pclass->nprops++; /* Update the revision for the class */ pclass->revision = H5P_GET_NEXT_REV; done: if(ret_value==FAIL) { if(new_prop!=NULL) { if(new_prop->name!=NULL) H5MM_xfree(new_prop->name); if(new_prop->value!=NULL) H5MM_xfree(new_prop->value); H5FL_FREE(H5P_genprop_t,new_prop); } /* end if */ } /* end if */ FUNC_LEAVE_NOAPI(ret_value); } /* H5P_register() */ /*-------------------------------------------------------------------------- NAME H5Pregister PURPOSE Routine to register a new property in a property list class. USAGE herr_t H5Pregister(class, name, size, default, prp_create, prp_set, prp_get, prp_close) hid_t class; IN: Property list class to close const char *name; IN: Name of property to register size_t size; IN: Size of property in bytes void *def_value; IN: Pointer to buffer containing default value for property in newly created property lists H5P_prp_create_func_t prp_create; IN: Function pointer to property creation callback H5P_prp_set_func_t prp_set; IN: Function pointer to property set callback H5P_prp_get_func_t prp_get; IN: Function pointer to property get callback H5P_prp_delete_func_t prp_delete; IN: Function pointer to property delete callback H5P_prp_copy_func_t prp_copy; IN: Function pointer to property copy callback H5P_prp_close_func_t prp_close; IN: Function pointer to property close callback RETURNS Returns non-negative on success, negative on failure. DESCRIPTION Registers a new property with a property list class. The property will exist in all property list objects of that class after this routine is finished. The name of the property must not already exist. The default property value must be provided and all new property lists created with this property will have the property value set to the default provided. Any of the callback routines may be set to NULL if they are not needed. Zero-sized properties are allowed and do not store any data in the property list. These may be used as flags to indicate the presence or absence of a particular piece of information. The 'default' pointer for a zero-sized property may be set to NULL. The property 'create' & 'close' callbacks are called for zero-sized properties, but the 'set' and 'get' callbacks are never called. The 'create' callback is called when a new property list with this property is being created. H5P_prp_create_func_t is defined as: typedef herr_t (*H5P_prp_create_func_t)(hid_t prop_id, const char *name, size_t size, void *initial_value); where the parameters to the callback function are: hid_t prop_id; IN: The ID of the property list being created. const char *name; IN: The name of the property being modified. size_t size; IN: The size of the property value void *initial_value; IN/OUT: The initial value for the property being created. (The 'default' value passed to H5Pregister) The 'create' routine may modify the value to be set and those changes will be stored as the initial value of the property. If the 'create' routine returns a negative value, the new property value is not copied into the property and the property list creation routine returns an error value. The 'set' callback is called before a new value is copied into the property. H5P_prp_set_func_t is defined as: typedef herr_t (*H5P_prp_set_func_t)(hid_t prop_id, const char *name, size_t size, void *value); where the parameters to the callback function are: hid_t prop_id; IN: The ID of the property list being modified. const char *name; IN: The name of the property being modified. size_t size; IN: The size of the property value void *new_value; IN/OUT: The value being set for the property. The 'set' routine may modify the value to be set and those changes will be stored as the value of the property. If the 'set' routine returns a negative value, the new property value is not copied into the property and the property list set routine returns an error value. The 'get' callback is called before a value is retrieved from the property. H5P_prp_get_func_t is defined as: typedef herr_t (*H5P_prp_get_func_t)(hid_t prop_id, const char *name, size_t size, void *value); where the parameters to the callback function are: hid_t prop_id; IN: The ID of the property list being queried. const char *name; IN: The name of the property being queried. size_t size; IN: The size of the property value void *value; IN/OUT: The value being retrieved for the property. The 'get' routine may modify the value to be retrieved and those changes will be returned to the calling function. If the 'get' routine returns a negative value, the property value is returned and the property list get routine returns an error value. The 'delete' callback is called when a property is deleted from a property list. H5P_prp_del_func_t is defined as: typedef herr_t (*H5P_prp_del_func_t)(hid_t prop_id, const char *name, size_t size, void *value); where the parameters to the callback function are: hid_t prop_id; IN: The ID of the property list the property is deleted from. const char *name; IN: The name of the property being deleted. size_t size; IN: The size of the property value void *value; IN/OUT: The value of the property being deleted. The 'delete' routine may modify the value passed in, but the value is not used by the library when the 'delete' routine returns. If the 'delete' routine returns a negative value, the property list deletion routine returns an error value but the property is still deleted. The 'copy' callback is called when a property list with this property is copied. H5P_prp_copy_func_t is defined as: typedef herr_t (*H5P_prp_copy_func_t)(const char *name, size_t size, void *value); where the parameters to the callback function are: const char *name; IN: The name of the property being copied. size_t size; IN: The size of the property value void *value; IN: The value of the property being copied. The 'copy' routine may modify the value to be copied and those changes will be stored as the value of the property. If the 'copy' routine returns a negative value, the new property value is not copied into the property and the property list copy routine returns an error value. The 'close' callback is called when a property list with this property is being destroyed. H5P_prp_close_func_t is defined as: typedef herr_t (*H5P_prp_close_func_t)(const char *name, size_t size, void *value); where the parameters to the callback function are: const char *name; IN: The name of the property being closed. size_t size; IN: The size of the property value void *value; IN: The value of the property being closed. The 'close' routine may modify the value passed in, but the value is not used by the library when the 'close' routine returns. If the 'close' routine returns a negative value, the property list close routine returns an error value but the property list is still closed. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS The 'set' callback function may be useful to range check the value being set for the property or may perform some tranformation/translation of the value set. The 'get' callback would then [probably] reverse the transformation, etc. A single 'get' or 'set' callback could handle multiple properties by performing different actions based on the property name or other properties in the property list. I would like to say "the property list is not closed" when a 'close' routine fails, but I don't think that's possible due to other properties in the list being successfully closed & removed from the property list. I suppose that it would be possible to just remove the properties which have successful 'close' callbacks, but I'm not happy with the ramifications of a mangled, un-closable property list hanging around... Any comments? -QAK EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5Pregister(hid_t cls_id, const char *name, size_t size, void *def_value, H5P_prp_create_func_t prp_create, H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get, H5P_prp_delete_func_t prp_delete, H5P_prp_copy_func_t prp_copy, H5P_prp_close_func_t prp_close) { H5P_genclass_t *pclass; /* Property list class to modify */ herr_t ret_value; /* return value */ FUNC_ENTER_API(H5Pregister, FAIL); H5TRACE10("e","iszxxxxxxx",cls_id,name,size,def_value,prp_create,prp_set, prp_get,prp_delete,prp_copy,prp_close); /* Check arguments. */ if (NULL == (pclass = H5I_object_verify(cls_id, H5I_GENPROP_CLS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class"); if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid class name"); if (size>0 && def_value==NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "properties >0 size must have default"); /* Create the new property list class */ if ((ret_value=H5P_register(pclass,name,size,def_value,prp_create,prp_set,prp_get,prp_delete,prp_copy,NULL,prp_close))<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to register property in class"); done: FUNC_LEAVE_API(ret_value); } /* H5Pregister() */ /*-------------------------------------------------------------------------- NAME H5P_insert PURPOSE Internal routine to insert a new property in a property list. USAGE herr_t H5P_insert(plist, name, size, value, prp_set, prp_get, prp_close) H5P_genplist_t *plist; IN: Property list to add property to const char *name; IN: Name of property to add size_t size; IN: Size of property in bytes void *value; IN: Pointer to the value for the property H5P_prp_set_func_t prp_set; IN: Function pointer to property set callback H5P_prp_get_func_t prp_get; IN: Function pointer to property get callback H5P_prp_delete_func_t prp_delete; IN: Function pointer to property delete callback H5P_prp_copy_func_t prp_copy; IN: Function pointer to property copy callback H5P_prp_compare_func_t prp_cmp; IN: Function pointer to property compare callback H5P_prp_close_func_t prp_close; IN: Function pointer to property close callback RETURNS Returns non-negative on success, negative on failure. DESCRIPTION Inserts a temporary property into a property list. The property will exist only in this property list object. The name of the property must not already exist. The value must be provided unless the property is zero- sized. Any of the callback routines may be set to NULL if they are not needed. Zero-sized properties are allowed and do not store any data in the property list. These may be used as flags to indicate the presence or absence of a particular piece of information. The 'value' pointer for a zero-sized property may be set to NULL. The property 'close' callback is called for zero-sized properties, but the 'set' and 'get' callbacks are never called. The 'set' callback is called before a new value is copied into the property. H5P_prp_set_func_t is defined as: typedef herr_t (*H5P_prp_set_func_t)(hid_t prop_id, const char *name, size_t size, void *value); where the parameters to the callback function are: hid_t prop_id; IN: The ID of the property list being modified. const char *name; IN: The name of the property being modified. size_t size; IN: The size of the property value void *new_value; IN/OUT: The value being set for the property. The 'set' routine may modify the value to be set and those changes will be stored as the value of the property. If the 'set' routine returns a negative value, the new property value is not copied into the property and the property list set routine returns an error value. The 'get' callback is called before a value is retrieved from the property. H5P_prp_get_func_t is defined as: typedef herr_t (*H5P_prp_get_func_t)(hid_t prop_id, const char *name, size_t size, void *value); where the parameters to the callback function are: hid_t prop_id; IN: The ID of the property list being queried. const char *name; IN: The name of the property being queried. size_t size; IN: The size of the property value void *value; IN/OUT: The value being retrieved for the property. The 'get' routine may modify the value to be retrieved and those changes will be returned to the calling function. If the 'get' routine returns a negative value, the property value is returned and the property list get routine returns an error value. The 'delete' callback is called when a property is deleted from a property list. H5P_prp_del_func_t is defined as: typedef herr_t (*H5P_prp_del_func_t)(hid_t prop_id, const char *name, size_t size, void *value); where the parameters to the callback function are: hid_t prop_id; IN: The ID of the property list the property is deleted from. const char *name; IN: The name of the property being deleted. size_t size; IN: The size of the property value void *value; IN/OUT: The value of the property being deleted. The 'delete' routine may modify the value passed in, but the value is not used by the library when the 'delete' routine returns. If the 'delete' routine returns a negative value, the property list deletion routine returns an error value but the property is still deleted. The 'copy' callback is called when a property list with this property is copied. H5P_prp_copy_func_t is defined as: typedef herr_t (*H5P_prp_copy_func_t)(const char *name, size_t size, void *value); where the parameters to the callback function are: const char *name; IN: The name of the property being copied. size_t size; IN: The size of the property value void *value; IN: The value of the property being copied. The 'copy' routine may modify the value to be copied and those changes will be stored as the value of the property. If the 'copy' routine returns a negative value, the new property value is not copied into the property and the property list copy routine returns an error value. The 'compare' callback is called when a property list with this property is compared to another property list. H5P_prp_compare_func_t is defined as: typedef int (*H5P_prp_compare_func_t)( void *value1, void *value2, size_t size); where the parameters to the callback function are: const void *value1; IN: The value of the first property being compared. const void *value2; IN: The value of the second property being compared. size_t size; IN: The size of the property value The 'compare' routine may not modify the values to be compared. The 'compare' routine should return a positive value if VALUE1 is greater than VALUE2, a negative value if VALUE2 is greater than VALUE1 and zero if VALUE1 and VALUE2 are equal. The 'close' callback is called when a property list with this property is being destroyed. H5P_prp_close_func_t is defined as: typedef herr_t (*H5P_prp_close_func_t)(const char *name, size_t size, void *value); where the parameters to the callback function are: const char *name; IN: The name of the property being closed. size_t size; IN: The size of the property value void *value; IN: The value of the property being closed. The 'close' routine may modify the value passed in, but the value is not used by the library when the 'close' routine returns. If the 'close' routine returns a negative value, the property list close routine returns an error value but the property list is still closed. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS The 'set' callback function may be useful to range check the value being set for the property or may perform some tranformation/translation of the value set. The 'get' callback would then [probably] reverse the transformation, etc. A single 'get' or 'set' callback could handle multiple properties by performing different actions based on the property name or other properties in the property list. There is no 'create' callback routine for temporary property list objects, the initial value is assumed to have any necessary setup already performed on it. I would like to say "the property list is not closed" when a 'close' routine fails, but I don't think that's possible due to other properties in the list being successfully closed & removed from the property list. I suppose that it would be possible to just remove the properties which have successful 'close' callbacks, but I'm not happy with the ramifications of a mangled, un-closable property list hanging around... Any comments? -QAK EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5P_insert(H5P_genplist_t *plist, const char *name, size_t size, void *value, H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get, H5P_prp_delete_func_t prp_delete, H5P_prp_copy_func_t prp_copy, H5P_prp_compare_func_t prp_cmp, H5P_prp_close_func_t prp_close) { H5P_genprop_t *new_prop=NULL; /* Temporary property pointer */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5P_insert); assert(plist); assert(name); assert((size>0 && value!=NULL) || (size==0)); /* Check for duplicate named properties */ if(H5SL_search(plist->props,name)!=NULL) HGOTO_ERROR(H5E_PLIST, H5E_EXISTS, FAIL, "property already exists"); /* Check if the property has been deleted */ if(H5SL_search(plist->del,name)!=NULL) { /* Remove the property name from the deleted property skip list */ if(H5SL_remove(plist->del,name)==NULL) HGOTO_ERROR(H5E_PLIST,H5E_CANTDELETE,FAIL,"can't remove property from deleted skip list"); /* Fall through to add property to list */ } /* end if */ else { H5P_genclass_t *tclass; /* Temporary class pointer */ /* Check if the property is already in the class hierarchy */ tclass=plist->pclass; while(tclass!=NULL) { if(tclass->nprops>0) { /* Find the property in the class */ if(H5SL_search(tclass->props,name)!=NULL) HGOTO_ERROR(H5E_PLIST, H5E_EXISTS, FAIL, "property already exists"); } /* end if */ /* Go up to parent class */ tclass=tclass->parent; } /* end while */ /* Fall through to add property to list */ } /* end else */ /* Ok to add to property list */ /* Create property object from parameters */ if((new_prop=H5P_create_prop(name,size,H5P_PROP_WITHIN_LIST,value,NULL,prp_set,prp_get,prp_delete,prp_copy,prp_cmp,prp_close))==NULL) HGOTO_ERROR (H5E_PLIST, H5E_CANTCREATE, FAIL,"Can't create property"); /* Insert property into property list class */ if(H5P_add_prop(plist->props,new_prop)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTINSERT, FAIL,"Can't insert property into class"); /* Increment property count for class */ plist->nprops++; done: if(ret_value==FAIL) { if(new_prop!=NULL) { if(new_prop->name!=NULL) H5MM_xfree(new_prop->name); if(new_prop->value!=NULL) H5MM_xfree(new_prop->value); H5FL_FREE(H5P_genprop_t,new_prop); } /* end if */ } /* end if */ FUNC_LEAVE_NOAPI(ret_value); } /* H5P_insert() */ /*-------------------------------------------------------------------------- NAME H5Pinsert PURPOSE Routine to insert a new property in a property list. USAGE herr_t H5Pinsert(plist, name, size, value, prp_set, prp_get, prp_close) hid_t plist; IN: Property list to add property to const char *name; IN: Name of property to add size_t size; IN: Size of property in bytes void *value; IN: Pointer to the value for the property H5P_prp_set_func_t prp_set; IN: Function pointer to property set callback H5P_prp_get_func_t prp_get; IN: Function pointer to property get callback H5P_prp_delete_func_t prp_delete; IN: Function pointer to property delete callback H5P_prp_copy_func_t prp_copy; IN: Function pointer to property copy callback H5P_prp_close_func_t prp_close; IN: Function pointer to property close callback RETURNS Returns non-negative on success, negative on failure. DESCRIPTION Inserts a temporary property into a property list. The property will exist only in this property list object. The name of the property must not already exist. The value must be provided unless the property is zero- sized. Any of the callback routines may be set to NULL if they are not needed. Zero-sized properties are allowed and do not store any data in the property list. These may be used as flags to indicate the presence or absence of a particular piece of information. The 'value' pointer for a zero-sized property may be set to NULL. The property 'close' callback is called for zero-sized properties, but the 'set' and 'get' callbacks are never called. The 'set' callback is called before a new value is copied into the property. H5P_prp_set_func_t is defined as: typedef herr_t (*H5P_prp_set_func_t)(hid_t prop_id, const char *name, size_t size, void *value); where the parameters to the callback function are: hid_t prop_id; IN: The ID of the property list being modified. const char *name; IN: The name of the property being modified. size_t size; IN: The size of the property value void *new_value; IN/OUT: The value being set for the property. The 'set' routine may modify the value to be set and those changes will be stored as the value of the property. If the 'set' routine returns a negative value, the new property value is not copied into the property and the property list set routine returns an error value. The 'get' callback is called before a value is retrieved from the property. H5P_prp_get_func_t is defined as: typedef herr_t (*H5P_prp_get_func_t)(hid_t prop_id, const char *name, size_t size, void *value); where the parameters to the callback function are: hid_t prop_id; IN: The ID of the property list being queried. const char *name; IN: The name of the property being queried. size_t size; IN: The size of the property value void *value; IN/OUT: The value being retrieved for the property. The 'get' routine may modify the value to be retrieved and those changes will be returned to the calling function. If the 'get' routine returns a negative value, the property value is returned and the property list get routine returns an error value. The 'delete' callback is called when a property is deleted from a property list. H5P_prp_del_func_t is defined as: typedef herr_t (*H5P_prp_del_func_t)(hid_t prop_id, const char *name, size_t size, void *value); where the parameters to the callback function are: hid_t prop_id; IN: The ID of the property list the property is deleted from. const char *name; IN: The name of the property being deleted. size_t size; IN: The size of the property value void *value; IN/OUT: The value of the property being deleted. The 'delete' routine may modify the value passed in, but the value is not used by the library when the 'delete' routine returns. If the 'delete' routine returns a negative value, the property list deletion routine returns an error value but the property is still deleted. The 'copy' callback is called when a property list with this property is copied. H5P_prp_copy_func_t is defined as: typedef herr_t (*H5P_prp_copy_func_t)(const char *name, size_t size, void *value); where the parameters to the callback function are: const char *name; IN: The name of the property being copied. size_t size; IN: The size of the property value void *value; IN: The value of the property being copied. The 'copy' routine may modify the value to be copied and those changes will be stored as the value of the property. If the 'copy' routine returns a negative value, the new property value is not copied into the property and the property list copy routine returns an error value. The 'close' callback is called when a property list with this property is being destroyed. H5P_prp_close_func_t is defined as: typedef herr_t (*H5P_prp_close_func_t)(const char *name, size_t size, void *value); where the parameters to the callback function are: const char *name; IN: The name of the property being closed. size_t size; IN: The size of the property value void *value; IN: The value of the property being closed. The 'close' routine may modify the value passed in, but the value is not used by the library when the 'close' routine returns. If the 'close' routine returns a negative value, the property list close routine returns an error value but the property list is still closed. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS The 'set' callback function may be useful to range check the value being set for the property or may perform some tranformation/translation of the value set. The 'get' callback would then [probably] reverse the transformation, etc. A single 'get' or 'set' callback could handle multiple properties by performing different actions based on the property name or other properties in the property list. There is no 'create' callback routine for temporary property list objects, the initial value is assumed to have any necessary setup already performed on it. I would like to say "the property list is not closed" when a 'close' routine fails, but I don't think that's possible due to other properties in the list being successfully closed & removed from the property list. I suppose that it would be possible to just remove the properties which have successful 'close' callbacks, but I'm not happy with the ramifications of a mangled, un-closable property list hanging around... Any comments? -QAK EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5Pinsert(hid_t plist_id, const char *name, size_t size, void *value, H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get, H5P_prp_delete_func_t prp_delete, H5P_prp_copy_func_t prp_copy, H5P_prp_close_func_t prp_close) { H5P_genplist_t *plist; /* Property list to modify */ herr_t ret_value; /* return value */ FUNC_ENTER_API(H5Pinsert, FAIL); H5TRACE9("e","iszxxxxxx",plist_id,name,size,value,prp_set,prp_get, prp_delete,prp_copy,prp_close); /* Check arguments. */ if (NULL == (plist = H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property name"); if (size>0 && value==NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "properties >0 size must have default"); /* Create the new property list class */ if ((ret_value=H5P_insert(plist,name,size,value,prp_set,prp_get,prp_delete,prp_copy,NULL,prp_close))<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to register property in plist"); done: FUNC_LEAVE_API(ret_value); } /* H5Pinsert() */ /*-------------------------------------------------------------------------- NAME H5P_set PURPOSE Internal routine to set a property's value in a property list. USAGE herr_t H5P_set(plist, name, value) H5P_genplist_t *plist; IN: Property list to find property in const char *name; IN: Name of property to set void *value; IN: Pointer to the value for the property RETURNS Returns non-negative on success, negative on failure. DESCRIPTION Sets a new value for a property in a property list. The property name must exist or this routine will fail. If there is a 'set' callback routine registered for this property, the 'value' will be passed to that routine and any changes to the 'value' will be used when setting the property value. The information pointed at by the 'value' pointer (possibly modified by the 'set' callback) is copied into the property list value and may be changed by the application making the H5Pset call without affecting the property value. If the 'set' callback routine returns an error, the property value will not be modified. This routine may not be called for zero-sized properties and will return an error in that case. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5P_set(H5P_genplist_t *plist, const char *name, const void *value) { H5P_genclass_t *tclass; /* Temporary class pointer */ H5P_genprop_t *prop; /* Temporary property pointer */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5P_set, FAIL); assert(plist); assert(name); assert(value); /* Check if the property has been deleted */ if(H5SL_search(plist->del,name)!=NULL) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "property doesn't exist"); /* Find property in changed list */ if((prop=H5SL_search(plist->props,name))!=NULL) { /* Check for property size >0 */ if(prop->size==0) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "property has zero size"); /* Make a copy of the value and pass to 'set' callback */ if(prop->set!=NULL) { void *tmp_value; /* Temporary value for property */ /* Make a copy of the current value, in case the callback fails */ if (NULL==(tmp_value=H5MM_malloc(prop->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed temporary property value"); HDmemcpy(tmp_value,value,prop->size); /* Call user's callback */ if((*(prop->set))(plist->plist_id,name,prop->size,tmp_value)<0) { H5MM_xfree(tmp_value); HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set property value"); } /* end if */ /* Copy new [possibly unchanged] value into property value */ HDmemcpy(prop->value,tmp_value,prop->size); /* Free the temporary value buffer */ H5MM_xfree(tmp_value); } /* end if */ /* No 'set' callback, just copy value */ else HDmemcpy(prop->value,value,prop->size); } /* end if */ else { /* * Check if we should set class properties (up through list of parent classes also), * & make property 'set' callback. */ tclass=plist->pclass; while(tclass!=NULL) { if(tclass->nprops>0) { /* Find the property in the class */ if((prop=H5SL_search(tclass->props,name))!=NULL) { H5P_genprop_t *pcopy; /* Copy of property to insert into skip list */ /* Check for property size >0 */ if(prop->size==0) HGOTO_ERROR(H5E_PLIST,H5E_BADVALUE,FAIL,"property has zero size"); /* Make a copy of the value and pass to 'set' callback */ if(prop->set!=NULL) { void *tmp_value; /* Temporary value for property */ /* Make a copy of the current value, in case the callback fails */ if (NULL==(tmp_value=H5MM_malloc(prop->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed temporary property value"); HDmemcpy(tmp_value,value,prop->size); /* Call user's callback */ if((*(prop->set))(plist->plist_id,name,prop->size,tmp_value)<0) { H5MM_xfree(tmp_value); HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set property value"); } /* end if */ if(HDmemcmp(tmp_value,prop->value,prop->size)) { /* Make a copy of the class's property */ if((pcopy=H5P_dup_prop(prop,H5P_PROP_WITHIN_LIST))==NULL) HGOTO_ERROR(H5E_PLIST,H5E_CANTCOPY,FAIL,"Can't copy property"); /* Copy new value into property value */ HDmemcpy(pcopy->value,tmp_value,pcopy->size); /* Insert the changed property into the property list */ if(H5P_add_prop(plist->props,pcopy)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTINSERT, FAIL,"Can't insert changed property into skip list"); } /* end if */ /* Free the temporary value buffer */ H5MM_xfree(tmp_value); } /* end if */ /* No 'set' callback, just copy value */ else { if(HDmemcmp(value,prop->value,prop->size)) { /* Make a copy of the class's property */ if((pcopy=H5P_dup_prop(prop,H5P_PROP_WITHIN_LIST))==NULL) HGOTO_ERROR(H5E_PLIST,H5E_CANTCOPY,FAIL,"Can't copy property"); HDmemcpy(pcopy->value,value,pcopy->size); /* Insert the changed property into the property list */ if(H5P_add_prop(plist->props,pcopy)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTINSERT, FAIL,"Can't insert changed property into skip list"); } /* end if */ } /* end else */ /* Leave */ HGOTO_DONE(SUCCEED); } /* end while */ } /* end if */ /* Go up to parent class */ tclass=tclass->parent; } /* end while */ /* If we get this far, then it wasn't in the list of changed properties, * nor in the properties in the class hierarchy, indicate an error */ HGOTO_ERROR(H5E_PLIST,H5E_NOTFOUND,FAIL,"can't find property in skip list"); } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value); } /* H5P_set() */ /*-------------------------------------------------------------------------- NAME H5Pset PURPOSE Routine to set a property's value in a property list. USAGE herr_t H5P_set(plist_id, name, value) hid_t plist_id; IN: Property list to find property in const char *name; IN: Name of property to set void *value; IN: Pointer to the value for the property RETURNS Returns non-negative on success, negative on failure. DESCRIPTION Sets a new value for a property in a property list. The property name must exist or this routine will fail. If there is a 'set' callback routine registered for this property, the 'value' will be passed to that routine and any changes to the 'value' will be used when setting the property value. The information pointed at by the 'value' pointer (possibly modified by the 'set' callback) is copied into the property list value and may be changed by the application making the H5Pset call without affecting the property value. If the 'set' callback routine returns an error, the property value will not be modified. This routine may not be called for zero-sized properties and will return an error in that case. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5Pset(hid_t plist_id, const char *name, void *value) { H5P_genplist_t *plist; /* Property list to modify */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pset, FAIL); H5TRACE3("e","isx",plist_id,name,value); /* Check arguments. */ if (NULL == (plist = H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property name"); if (value==NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalied property value"); /* Go set the value */ if(H5P_set(plist,name,value)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to set value in plist"); done: FUNC_LEAVE_API(ret_value); } /* H5Pset() */ /*-------------------------------------------------------------------------- NAME H5P_exist_plist PURPOSE Internal routine to query the existance of a property in a property list. USAGE herr_t H5P_exist_plist(plist, name) H5P_genplist_t *plist; IN: Property list to check const char *name; IN: Name of property to check for RETURNS Success: Positive if the property exists in the property list, zero if the property does not exist. Failure: negative value DESCRIPTION This routine checks if a property exists within a property list. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ htri_t H5P_exist_plist(H5P_genplist_t *plist, const char *name) { htri_t ret_value=FAIL; /* return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5P_exist_plist); assert(plist); assert(name); /* Check for property in deleted property list */ if(H5SL_search(plist->del,name)!=NULL) ret_value=0; else { /* Check for property in changed property list */ if(H5SL_search(plist->props,name)!=NULL) ret_value=1; else { H5P_genclass_t *tclass; /* Temporary class pointer */ tclass=plist->pclass; while(tclass!=NULL) { if(H5SL_search(tclass->props,name)!=NULL) HGOTO_DONE(1); /* Go up to parent class */ tclass=tclass->parent; } /* end while */ /* If we've reached here, we couldn't find the property */ ret_value=0; } /* end else */ } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value); } /* H5P_exist_plist() */ /*-------------------------------------------------------------------------- NAME H5P_exist_pclass PURPOSE Internal routine to query the existance of a property in a property class. USAGE herr_t H5P_exist_pclass(pclass, name) H5P_genclass_t *pclass; IN: Property class to check const char *name; IN: Name of property to check for RETURNS Success: Positive if the property exists in the property list, zero if the property does not exist. Failure: negative value DESCRIPTION This routine checks if a property exists within a property list. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static htri_t H5P_exist_pclass(H5P_genclass_t *pclass, const char *name) { htri_t ret_value=FAIL; /* return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5P_exist_pclass); assert(pclass); assert(name); /* Check for property in property list */ if(H5SL_search(pclass->props,name)==NULL) ret_value=0; else ret_value=1; FUNC_LEAVE_NOAPI(ret_value); } /* H5P_exist_pclass() */ /*-------------------------------------------------------------------------- NAME H5Pexist PURPOSE Routine to query the existance of a property in a property object. USAGE htri_t H5P_exist(id, name) hid_t id; IN: Property object ID to check const char *name; IN: Name of property to check for RETURNS Success: Positive if the property exists in the property object, zero if the property does not exist. Failure: negative value DESCRIPTION This routine checks if a property exists within a property list or class. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ htri_t H5Pexist(hid_t id, const char *name) { H5P_genplist_t *plist; /* Property list to query */ H5P_genclass_t *pclass; /* Property class to query */ htri_t ret_value; /* return value */ FUNC_ENTER_API(H5Pexist, FAIL); H5TRACE2("t","is",id,name); /* Check arguments. */ if (H5I_GENPROP_LST != H5I_get_type(id) && H5I_GENPROP_CLS != H5I_get_type(id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property object"); if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property name"); /* Check for the existance of the property in the list or class */ if(H5I_GENPROP_LST == H5I_get_type(id)) { if (NULL == (plist = H5I_object(id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); if ((ret_value=H5P_exist_plist(plist,name))<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property does not exist in list"); } /* end if */ else if(H5I_GENPROP_CLS == H5I_get_type(id)) { if (NULL == (pclass = H5I_object(id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property class"); if ((ret_value=H5P_exist_pclass(pclass,name))<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property does not exist in class"); } /* end if */ else HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property object"); done: FUNC_LEAVE_API(ret_value); } /* H5Pexist() */ /*-------------------------------------------------------------------------- NAME H5P_get_size_plist PURPOSE Internal routine to query the size of a property in a property list. USAGE herr_t H5P_get_size_plist(plist, name) H5P_genplist_t *plist; IN: Property list to check const char *name; IN: Name of property to query size_t *size; OUT: Size of property RETURNS Success: non-negative value Failure: negative value DESCRIPTION This routine retrieves the size of a property's value in bytes. Zero- sized properties are allowed and return a value of 0. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5P_get_size_plist(H5P_genplist_t *plist, const char *name, size_t *size) { H5P_genprop_t *prop; /* Temporary property pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_NOAPI_NOINIT(H5P_get_size_plist); assert(plist); assert(name); assert(size); /* Find property */ if((prop=H5P_find_prop_plist(plist,name))==NULL) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "property doesn't exist"); /* Get property size */ *size=prop->size; done: FUNC_LEAVE_NOAPI(ret_value); } /* H5P_get_size_plist() */ /*-------------------------------------------------------------------------- NAME H5P_get_size_pclass PURPOSE Internal routine to query the size of a property in a property class. USAGE herr_t H5P_get_size_pclass(pclass, name) H5P_genclass_t *pclass; IN: Property class to check const char *name; IN: Name of property to query size_t *size; OUT: Size of property RETURNS Success: non-negative value Failure: negative value DESCRIPTION This routine retrieves the size of a property's value in bytes. Zero- sized properties are allowed and return a value of 0. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5P_get_size_pclass(H5P_genclass_t *pclass, const char *name, size_t *size) { H5P_genprop_t *prop; /* Temporary property pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_NOAPI_NOINIT(H5P_get_size_pclass); assert(pclass); assert(name); assert(size); /* Find property */ if((prop=H5P_find_prop_pclass(pclass,name))==NULL) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "property doesn't exist"); /* Get property size */ *size=prop->size; done: FUNC_LEAVE_NOAPI(ret_value); } /* H5P_get_size_pclass() */ /*-------------------------------------------------------------------------- NAME H5Pget_size PURPOSE Routine to query the size of a property in a property list or class. USAGE herr_t H5Pget_size(id, name) hid_t id; IN: ID of property list or class to check const char *name; IN: Name of property to query size_t *size; OUT: Size of property RETURNS Success: non-negative value Failure: negative value DESCRIPTION This routine retrieves the size of a property's value in bytes. Zero- sized properties are allowed and return a value of 0. This function works for both property lists and classes. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5Pget_size(hid_t id, const char *name, size_t *size) { H5P_genclass_t *pclass; /* Property class to query */ H5P_genplist_t *plist; /* Property list to query */ herr_t ret_value; /* return value */ FUNC_ENTER_API(H5Pget_size, FAIL); H5TRACE3("e","is*z",id,name,size); /* Check arguments. */ if (H5I_GENPROP_LST != H5I_get_type(id) && H5I_GENPROP_CLS != H5I_get_type(id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property object"); if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property name"); if (size==NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property size"); if (H5I_GENPROP_LST == H5I_get_type(id)) { if (NULL == (plist = H5I_object(id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); /* Check the property size */ if ((ret_value=H5P_get_size_plist(plist,name,size))<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to query size in plist"); } /* end if */ else if (H5I_GENPROP_CLS == H5I_get_type(id)) { if (NULL == (pclass = H5I_object(id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); /* Check the property size */ if ((ret_value=H5P_get_size_pclass(pclass,name,size))<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to query size in plist"); } /* end if */ else HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property object"); done: FUNC_LEAVE_API(ret_value); } /* H5Pget_size() */ /*-------------------------------------------------------------------------- NAME H5P_get_class PURPOSE Internal routine to query the class of a generic property list USAGE H5P_genclass_t *H5P_get_class(plist) H5P_genplist_t *plist; IN: Property list to check RETURNS Success: Pointer to the class for a property list Failure: NULL DESCRIPTION This routine retrieves a pointer to the class for a property list. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static H5P_genclass_t * H5P_get_class(H5P_genplist_t *plist) { H5P_genclass_t *ret_value; /* return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5P_get_class); assert(plist); /* Get property size */ ret_value=plist->pclass; FUNC_LEAVE_NOAPI(ret_value); } /* H5P_get_class() */ /*-------------------------------------------------------------------------- NAME H5Pget_class PURPOSE Routine to query the class of a generic property list USAGE hid_t H5Pget_class(plist_id) hid_t plist_id; IN: Property list to query RETURNS Success: ID of class object Failure: negative DESCRIPTION This routine retrieves the class of a property list. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS Change the name of this function to H5Pget_class (and remove old H5Pget_class) EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ hid_t H5Pget_class(hid_t plist_id) { H5P_genplist_t *plist; /* Property list to query */ H5P_genclass_t *pclass=NULL; /* Property list class */ hid_t ret_value=FAIL; /* return value */ FUNC_ENTER_API(H5Pget_class, FAIL); H5TRACE1("i","i",plist_id); /* Check arguments. */ if (NULL == (plist = H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); /* Retrieve the property list class */ if ((pclass=H5P_get_class(plist))==NULL) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "unable to query class of property list"); /* Increment the outstanding references to the class object */ if(H5P_access_class(pclass,H5P_MOD_INC_REF)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTINIT, FAIL,"Can't increment class ID ref count"); /* Get an atom for the class */ if ((ret_value = H5I_register(H5I_GENPROP_CLS, pclass))<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to atomize property list class"); done: if (ret_value<0 && pclass) H5P_close_class(pclass); FUNC_LEAVE_API(ret_value); } /* H5Pget_class() */ /*-------------------------------------------------------------------------- NAME H5P_get_nprops_plist PURPOSE Internal routine to query the number of properties in a property list USAGE herr_t H5P_get_nprops_plist(plist, nprops) H5P_genplist_t *plist; IN: Property list to check size_t *nprops; OUT: Number of properties in the property list RETURNS Success: non-negative value Failure: negative value DESCRIPTION This routine retrieves the number of a properties in a property list. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5P_get_nprops_plist(H5P_genplist_t *plist, size_t *nprops) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5P_get_nprops_plist); assert(plist); assert(nprops); /* Get property size */ *nprops=plist->nprops; FUNC_LEAVE_NOAPI(SUCCEED); } /* H5P_get_nprops_plist() */ /*-------------------------------------------------------------------------- NAME H5P_get_nprops_pclass PURPOSE Internal routine to query the number of properties in a property class USAGE herr_t H5P_get_nprops_pclass(pclass, nprops) H5P_genclass_t *pclass; IN: Property class to check size_t *nprops; OUT: Number of properties in the property list RETURNS Success: non-negative value (can't fail) Failure: negative value DESCRIPTION This routine retrieves the number of a properties in a property class. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5P_get_nprops_pclass(H5P_genclass_t *pclass, size_t *nprops) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5P_get_nprops_pclass, FAIL) assert(pclass); assert(nprops); /* Get number of properties */ *nprops=pclass->nprops; done: FUNC_LEAVE_NOAPI(ret_value) } /* H5P_get_nprops_pclass() */ /*-------------------------------------------------------------------------- NAME H5Pget_nprops PURPOSE Routine to query the size of a property in a property list or class. USAGE herr_t H5Pget_nprops(id, nprops) hid_t id; IN: ID of Property list or class to check size_t *nprops; OUT: Number of properties in the property object RETURNS Success: non-negative value Failure: negative value DESCRIPTION This routine retrieves the number of properties in a property list or class. If a property class ID is given, the number of registered properties in the class is returned in NPROPS. If a property list ID is given, the current number of properties in the list is returned in NPROPS. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5Pget_nprops(hid_t id, size_t *nprops) { H5P_genplist_t *plist; /* Property list to query */ H5P_genclass_t *pclass; /* Property class to query */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pget_nprops, FAIL); H5TRACE2("e","i*z",id,nprops); /* Check arguments. */ if (H5I_GENPROP_LST != H5I_get_type(id) && H5I_GENPROP_CLS != H5I_get_type(id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property object"); if (nprops==NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property nprops pointer"); if(H5I_GENPROP_LST == H5I_get_type(id)) { if (NULL == (plist = H5I_object(id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); if (H5P_get_nprops_plist(plist,nprops)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to query # of properties in plist"); } /* end if */ else if(H5I_GENPROP_CLS == H5I_get_type(id)) { if (NULL == (pclass = H5I_object(id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property class"); if (H5P_get_nprops_pclass(pclass,nprops)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to query # of properties in pclass"); } /* end if */ else HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property object"); done: FUNC_LEAVE_API(ret_value); } /* H5Pget_nprops() */ /*-------------------------------------------------------------------------- NAME H5P_cmp_prop PURPOSE Internal routine to compare two generic properties USAGE int H5P_cmp_prop(prop1, prop2) H5P_genprop_t *prop1; IN: 1st property to compare H5P_genprop_t *prop1; IN: 2nd property to compare RETURNS Success: negative if prop1 "less" than prop2, positive if prop1 "greater" than prop2, zero if prop1 is "equal" to prop2 Failure: can't fail DESCRIPTION This function compares two generic properties together to see if they are the same property. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static int H5P_cmp_prop(H5P_genprop_t *prop1, H5P_genprop_t *prop2) { int cmp_value; /* Value from comparison */ int ret_value=0; /* return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5P_cmp_prop); assert(prop1); assert(prop2); /* Check the name */ if((cmp_value=HDstrcmp(prop1->name,prop2->name))!=0) HGOTO_DONE(cmp_value); /* Check the size of properties */ if(prop1->size < prop2->size) HGOTO_DONE(-1); if(prop1->size > prop2->size) HGOTO_DONE(1); /* Check if they both have the same 'create' callback */ if(prop1->create==NULL && prop2->create!=NULL) HGOTO_DONE(-1); if(prop1->create!=NULL && prop2->create==NULL) HGOTO_DONE(1); if(prop1->create!=prop2->create) HGOTO_DONE(-1); /* Check if they both have the same 'set' callback */ if(prop1->set==NULL && prop2->set!=NULL) HGOTO_DONE(-1); if(prop1->set!=NULL && prop2->set==NULL) HGOTO_DONE(1); if(prop1->set!=prop2->set) HGOTO_DONE(-1); /* Check if they both have the same 'get' callback */ if(prop1->get==NULL && prop2->get!=NULL) HGOTO_DONE(-1); if(prop1->get!=NULL && prop2->get==NULL) HGOTO_DONE(1); if(prop1->get!=prop2->get) HGOTO_DONE(-1); /* Check if they both have the same 'delete' callback */ if(prop1->del==NULL && prop2->del!=NULL) HGOTO_DONE(-1); if(prop1->del!=NULL && prop2->del==NULL) HGOTO_DONE(1); if(prop1->del!=prop2->del) HGOTO_DONE(-1); /* Check if they both have the same 'copy' callback */ if(prop1->copy==NULL && prop2->copy!=NULL) HGOTO_DONE(-1); if(prop1->copy!=NULL && prop2->copy==NULL) HGOTO_DONE(1); if(prop1->copy!=prop2->copy) HGOTO_DONE(-1); /* Check if they both have the same 'compare' callback */ if(prop1->cmp==NULL && prop2->cmp!=NULL) HGOTO_DONE(-1); if(prop1->cmp!=NULL && prop2->cmp==NULL) HGOTO_DONE(1); if(prop1->cmp!=prop2->cmp) HGOTO_DONE(-1); /* Check if they both have the same 'close' callback */ if(prop1->close==NULL && prop2->close!=NULL) HGOTO_DONE(-1); if(prop1->close!=NULL && prop2->close==NULL) HGOTO_DONE(1); if(prop1->close!=prop2->close) HGOTO_DONE(-1); /* Check if they both have values allocated (or not allocated) */ if(prop1->value==NULL && prop2->value!=NULL) HGOTO_DONE(-1); if(prop1->value!=NULL && prop2->value==NULL) HGOTO_DONE(1); if(prop1->value!=NULL) { /* Call comparison routine */ if((cmp_value=prop1->cmp(prop1->value,prop2->value,prop1->size))!=0) HGOTO_DONE(cmp_value); } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value); } /* H5P_cmp_prop() */ /*-------------------------------------------------------------------------- NAME H5P_cmp_class PURPOSE Internal routine to compare two generic property classes USAGE int H5P_cmp_class(pclass1, pclass2) H5P_genclass_t *pclass1; IN: 1st property class to compare H5P_genclass_t *pclass2; IN: 2nd property class to compare RETURNS Success: negative if class1 "less" than class2, positive if class1 "greater" than class2, zero if class1 is "equal" to class2 Failure: can't fail DESCRIPTION This function compares two generic property classes together to see if they are the same class. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static int H5P_cmp_class(H5P_genclass_t *pclass1, H5P_genclass_t *pclass2) { H5SL_node_t *tnode1,*tnode2; /* Temporary pointer to property nodes */ int cmp_value; /* Value from comparison */ int ret_value=0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5P_cmp_class); assert(pclass1); assert(pclass2); /* Use the revision number to quickly check for identical classes */ if(pclass1->revision==pclass2->revision) HGOTO_DONE(0); /* Check the name */ if((cmp_value=HDstrcmp(pclass1->name,pclass2->name))!=0) HGOTO_DONE(cmp_value); /* Check the number of properties */ if(pclass1->nprops < pclass2->nprops) HGOTO_DONE(-1); if(pclass1->nprops > pclass2->nprops) HGOTO_DONE(1); /* Check the number of property lists created from the class */ if(pclass1->plists < pclass2->plists) HGOTO_DONE(-1); if(pclass1->plists > pclass2->plists) HGOTO_DONE(1); /* Check the number of classes derived from the class */ if(pclass1->classes < pclass2->classes) HGOTO_DONE(-1); if(pclass1->classes > pclass2->classes) HGOTO_DONE(1); /* Check the number of ID references open on the class */ if(pclass1->ref_count < pclass2->ref_count) HGOTO_DONE(-1); if(pclass1->ref_count > pclass2->ref_count) HGOTO_DONE(1); /* Check whether they are internal or not */ if(pclass1->internal < pclass2->internal) HGOTO_DONE(-1); if(pclass1->internal > pclass2->internal) HGOTO_DONE(1); /* Check whether they are deleted or not */ if(pclass1->deleted < pclass2->deleted) HGOTO_DONE(-1); if(pclass1->deleted > pclass2->deleted) HGOTO_DONE(1); /* Check whether they have creation callback functions & data */ if(pclass1->create_func==NULL && pclass2->create_func!=NULL) HGOTO_DONE(-1); if(pclass1->create_func!=NULL && pclass2->create_func==NULL) HGOTO_DONE(1); if(pclass1->create_func!=pclass2->create_func) HGOTO_DONE(-1); if(pclass1->create_data < pclass2->create_data) HGOTO_DONE(-1); if(pclass1->create_data > pclass2->create_data) HGOTO_DONE(1); /* Check whether they have close callback functions & data */ if(pclass1->close_func==NULL && pclass2->close_func!=NULL) HGOTO_DONE(-1); if(pclass1->close_func!=NULL && pclass2->close_func==NULL) HGOTO_DONE(1); if(pclass1->close_func!=pclass2->close_func) HGOTO_DONE(-1); if(pclass1->close_data < pclass2->close_data) HGOTO_DONE(-1); if(pclass1->close_data > pclass2->close_data) HGOTO_DONE(1); /* Cycle through the properties and compare them also */ tnode1=H5SL_first(pclass1->props); tnode2=H5SL_first(pclass2->props); while(tnode1 || tnode2) { H5P_genprop_t *prop1, *prop2; /* Property for node */ /* Check if they both have properties in this skip list node */ if(tnode1==NULL && tnode2!=NULL) HGOTO_DONE(-1); if(tnode1!=NULL && tnode2==NULL) HGOTO_DONE(1); /* Compare the two properties */ prop1=H5SL_item(tnode1); prop2=H5SL_item(tnode2); if((cmp_value=H5P_cmp_prop(prop1,prop2))!=0) HGOTO_DONE(cmp_value); /* Advance the pointers */ tnode1=H5SL_next(tnode1); tnode2=H5SL_next(tnode2); } /* end while */ done: FUNC_LEAVE_NOAPI(ret_value); } /* H5P_cmp_class() */ /*-------------------------------------------------------------------------- NAME H5P_cmp_plist PURPOSE Internal routine to compare two generic property lists USAGE int H5P_cmp_plist(plist1, plist2) H5P_genplist_t *plist1; IN: 1st property list to compare H5P_genplist_t *plist2; IN: 2nd property list to compare RETURNS Success: negative if list1 "less" than list2, positive if list1 "greater" than list2, zero if list1 is "equal" to list2 Failure: can't fail DESCRIPTION This function compares two generic property lists together to see if they are the same list. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static int H5P_cmp_plist(H5P_genplist_t *plist1, H5P_genplist_t *plist2) { H5SL_node_t *tnode1,*tnode2; /* Temporary pointer to property nodes */ int cmp_value; /* Value from comparison */ int ret_value=0; /* return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5P_cmp_plist); assert(plist1); assert(plist2); /* Check the number of properties */ if(plist1->nprops < plist2->nprops) HGOTO_DONE(-1); if(plist1->nprops > plist2->nprops) HGOTO_DONE(1); /* Check whether they've been initialized */ if(plist1->class_init < plist2->class_init) HGOTO_DONE(-1); if(plist1->class_init > plist2->class_init) HGOTO_DONE(1); /* Check for identical deleted properties */ if(H5SL_count(plist1->del)>0) { /* Check for no deleted properties in plist2 */ if(H5SL_count(plist2->del)==0) HGOTO_DONE(1); tnode1=H5SL_first(plist1->del); tnode2=H5SL_first(plist2->del); while(tnode1 || tnode2) { const char *name1, *name2; /* Name for node */ /* Check if they both have properties in this node */ if(tnode1==NULL && tnode2!=NULL) HGOTO_DONE(-1); if(tnode1!=NULL && tnode2==NULL) HGOTO_DONE(1); /* Compare the two deleted properties */ name1=H5SL_item(tnode1); name2=H5SL_item(tnode2); if((cmp_value=HDstrcmp(name1,name2))!=0) HGOTO_DONE(cmp_value); /* Advance the pointers */ tnode1=H5SL_next(tnode1); tnode2=H5SL_next(tnode2); } /* end while */ } /* end if */ else if(H5SL_count(plist2->del)>0) HGOTO_DONE (-1); /* Cycle through the changed properties and compare them also */ if(H5SL_count(plist1->props)>0) { /* Check for no changed properties in plist2 */ if(H5SL_count(plist2->props)==0) HGOTO_DONE(1); tnode1=H5SL_first(plist1->props); tnode2=H5SL_first(plist2->props); while(tnode1 || tnode2) { H5P_genprop_t *prop1, *prop2; /* Property for node */ /* Check if they both have properties in this node */ if(tnode1==NULL && tnode2!=NULL) HGOTO_DONE(-1); if(tnode1!=NULL && tnode2==NULL) HGOTO_DONE(1); /* Compare the two properties */ prop1=H5SL_item(tnode1); prop2=H5SL_item(tnode2); if((cmp_value=H5P_cmp_prop(prop1,prop2))!=0) HGOTO_DONE(cmp_value); /* Advance the pointers */ tnode1=H5SL_next(tnode1); tnode2=H5SL_next(tnode2); } /* end while */ } /* end if */ else if(H5SL_count(plist2->props)>0) HGOTO_DONE (-1); /* Check the parent classes */ if((cmp_value=H5P_cmp_class(plist1->pclass,plist2->pclass))!=0) HGOTO_DONE(cmp_value); done: FUNC_LEAVE_NOAPI(ret_value); } /* H5P_cmp_plist() */ /*-------------------------------------------------------------------------- NAME H5Pequal PURPOSE Routine to query whether two property lists or two property classes are equal USAGE htri_t H5Pequal(id1, id2) hid_t id1; IN: Property list or class ID to compare hid_t id2; IN: Property list or class ID to compare RETURNS Success: TRUE if equal, FALSE if unequal Failure: negative DESCRIPTION Determines whether two property lists or two property classes are equal. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ htri_t H5Pequal(hid_t id1, hid_t id2) { void *obj1, *obj2; /* Property objects to compare */ htri_t ret_value=FALSE; /* return value */ FUNC_ENTER_API(H5Pequal, FAIL); H5TRACE2("t","ii",id1,id2); /* Check arguments. */ if ((H5I_GENPROP_LST != H5I_get_type(id1) && H5I_GENPROP_CLS != H5I_get_type(id1)) || (H5I_GENPROP_LST != H5I_get_type(id2) && H5I_GENPROP_CLS != H5I_get_type(id2))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not property objects"); if (H5I_get_type(id1) != H5I_get_type(id2)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not the same kind of property objects"); if(NULL == (obj1 = H5I_object(id1)) || NULL == (obj2 = H5I_object(id2))) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "property object doesn't exist"); /* Compare property lists */ if(H5I_GENPROP_LST == H5I_get_type(id1)) { if(H5P_cmp_plist(obj1,obj2)==0) ret_value=TRUE; } /* end if */ /* Must be property classes */ else { if(H5P_cmp_class(obj1,obj2)==0) ret_value=TRUE; } /* end else */ done: FUNC_LEAVE_API(ret_value); } /* H5Pequal() */ /*-------------------------------------------------------------------------- NAME H5P_isa_class_real PURPOSE Internal routine to query whether a property class is the same as another class. USAGE htri_t H5P_isa_class_real(pclass1, pclass2) H5P_genclass_t *pclass1; IN: Property class to check H5P_genclass_t *pclass2; IN: Property class to compare with RETURNS Success: TRUE (1) or FALSE (0) Failure: negative value DESCRIPTION This routine queries whether a property class is the same as another class, and walks up the hierarchy of derived classes, checking if the first class is derived from the second class also. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static htri_t H5P_isa_class_real(H5P_genclass_t *pclass1, H5P_genclass_t *pclass2) { htri_t ret_value; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5P_isa_class_real); assert(pclass1); assert(pclass2); /* Compare property classes */ if(H5P_cmp_class(pclass1,pclass2)==0) { HGOTO_DONE(TRUE); } else { /* Check if the class is derived, and walk up the chain, if so */ if(pclass1->parent!=NULL) ret_value=H5P_isa_class_real(pclass1->parent,pclass2); else HGOTO_DONE(FALSE); } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value); } /* H5P_isa_class_real() */ /*-------------------------------------------------------------------------- NAME H5P_isa_class PURPOSE Internal routine to query whether a property list is a certain class USAGE hid_t H5P_isa_class(plist_id, pclass_id) hid_t plist_id; IN: Property list to query hid_t pclass_id; IN: Property class to query RETURNS Success: TRUE (1) or FALSE (0) Failure: negative DESCRIPTION This routine queries whether a property list is a member of the property list class. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS This function is special in that it is an internal library function, but accepts hid_t's as parameters. Since it is used in basically the same way as the H5I functions, this should be OK. Don't make more library functions which accept hid_t's without thorough discussion. -QAK EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ htri_t H5P_isa_class(hid_t plist_id, hid_t pclass_id) { H5P_genplist_t *plist; /* Property list to query */ H5P_genclass_t *pclass; /* Property list class */ htri_t ret_value; /* return value */ FUNC_ENTER_NOAPI(H5P_isa_class, FAIL); /* Check arguments. */ if (NULL == (plist = H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); if (NULL == (pclass = H5I_object_verify(pclass_id, H5I_GENPROP_CLS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property class"); /* Compare the property list's class against the other class */ if ((ret_value = H5P_isa_class_real(plist->pclass, pclass))<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to compare property list classes"); done: FUNC_LEAVE_NOAPI(ret_value); } /* H5P_isa_class() */ /*-------------------------------------------------------------------------- NAME H5Pisa_class PURPOSE Routine to query whether a property list is a certain class USAGE hid_t H5Pisa_class(plist_id, pclass_id) hid_t plist_id; IN: Property list to query hid_t pclass_id; IN: Property class to query RETURNS Success: TRUE (1) or FALSE (0) Failure: negative DESCRIPTION This routine queries whether a property list is a member of the property list class. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS What about returning a value indicating that the property class is further up the class hierarchy? EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ htri_t H5Pisa_class(hid_t plist_id, hid_t pclass_id) { htri_t ret_value; /* return value */ FUNC_ENTER_API(H5Pisa_class, FAIL); H5TRACE2("t","ii",plist_id,pclass_id); /* Check arguments. */ if (H5I_GENPROP_LST != H5I_get_type(plist_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); if (H5I_GENPROP_CLS != H5I_get_type(pclass_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property class"); /* Compare the property list's class against the other class */ if ((ret_value = H5P_isa_class(plist_id, pclass_id))<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to compare property list classes"); done: FUNC_LEAVE_API(ret_value); } /* H5Pisa_class() */ /*-------------------------------------------------------------------------- NAME H5P_object_verify PURPOSE Internal routine to query whether a property list is a certain class and retrieve the property list object associated with it. USAGE void *H5P_object_verify(plist_id, pclass_id) hid_t plist_id; IN: Property list to query hid_t pclass_id; IN: Property class to query RETURNS Success: valid pointer to a property list object Failure: NULL DESCRIPTION This routine queries whether a property list is member of a certain class and retrieves the property list object associated with it. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS This function is special in that it is an internal library function, but accepts hid_t's as parameters. Since it is used in basically the same way as the H5I functions, this should be OK. Don't make more library functions which accept hid_t's without thorough discussion. -QAK This function is similar (in spirit) to H5I_object_verify() EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ void * H5P_object_verify(hid_t plist_id, hid_t pclass_id) { void *ret_value; /* return value */ FUNC_ENTER_NOAPI(H5P_object_verify, NULL); /* Compare the property list's class against the other class */ if (H5P_isa_class(plist_id,pclass_id)!=TRUE) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, NULL, "property list is not a member of the class"); /* Get the plist structure */ if(NULL == (ret_value = H5I_object(plist_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID"); done: FUNC_LEAVE_NOAPI(ret_value); } /* H5P_object_verify() */ /*-------------------------------------------------------------------------- NAME H5P_iterate_plist PURPOSE Internal routine to iterate over the properties in a property list USAGE herr_t H5P_iterate_plist(plist_id, idx, iter_func, iter_data) hid_t plist_id; IN: ID of property list to iterate over int *idx; IN/OUT: Index of the property to begin with H5P_iterate_t iter_func; IN: Function pointer to function to be called with each property iterated over. void *iter_data; IN/OUT: Pointer to iteration data from user RETURNS Success: Returns the return value of the last call to ITER_FUNC if it was non-zero, or zero if all properties have been processed. Failure: negative value DESCRIPTION This routine iterates over the properties in the property object specified with PLIST_ID. For each property in the object, the ITER_DATA and some additional information, specified below, are passed to the ITER_FUNC function. The iteration begins with the IDX property in the object and the next element to be processed by the operator is returned in IDX. If IDX is NULL, then the iterator starts at the first property; since no stopping point is returned in this case, the iterator cannot be restarted if one of the calls to its operator returns non-zero. The prototype for H5P_iterate_t is: typedef herr_t (*H5P_iterate_t)(hid_t id, const char *name, void *iter_data); The operation receives the property list or class identifier for the object being iterated over, ID, the name of the current property within the object, NAME, and the pointer to the operator data passed in to H5Piterate, ITER_DATA. The return values from an operator are: Zero causes the iterator to continue, returning zero when all properties have been processed. Positive causes the iterator to immediately return that positive value, indicating short-circuit success. The iterator can be restarted at the index of the next property. Negative causes the iterator to immediately return that value, indicating failure. The iterator can be restarted at the index of the next property. H5Piterate assumes that the properties in the object identified by ID remains unchanged through the iteration. If the membership changes during the iteration, the function's behavior is undefined. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static int H5P_iterate_plist(hid_t plist_id, int *idx, H5P_iterate_t iter_func, void *iter_data) { H5P_genclass_t *tclass; /* Temporary class pointer */ H5P_genplist_t *plist; /* Property list pointer */ H5P_genprop_t *tmp; /* Temporary pointer to properties */ H5SL_t *seen=NULL; /* Skip list to hold names of properties already seen */ H5SL_node_t *curr_node; /* Current node in skip list */ int curr_idx=0; /* Current iteration index */ int ret_value=FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5P_iterate_plist); assert(idx); assert(iter_func); /* Get the property list object */ if (NULL == (plist = H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); /* Create the skip list to hold names of properties already seen */ if((seen=H5SL_create(H5SL_TYPE_STR,0.5,H5P_DEFAULT_SKIPLIST_HEIGHT))==NULL) HGOTO_ERROR(H5E_PLIST,H5E_CANTCREATE,FAIL,"can't create skip list for seen properties"); /* Walk through the changed properties in the list */ if(H5SL_count(plist->props)>0) { curr_node=H5SL_first(plist->props); while(curr_node!=NULL) { /* Get pointer to property from node */ tmp=H5SL_item(curr_node); /* Check if we've found the correctly indexed property */ if(curr_idx>=*idx) { /* Call the callback function */ ret_value=(*iter_func)(plist_id,tmp->name,iter_data); if(ret_value!=0) HGOTO_DONE(ret_value); } /* end if */ /* Increment the current index */ curr_idx++; /* Add property name to "seen" list */ if(H5SL_insert(seen,tmp->name,tmp->name)<0) HGOTO_ERROR(H5E_PLIST,H5E_CANTINSERT,FAIL,"can't insert property into seen skip list"); /* Get the next property node in the skip list */ curr_node=H5SL_next(curr_node); } /* end while */ } /* end if */ /* Walk up the class hiearchy */ tclass=plist->pclass; while(tclass!=NULL) { if(tclass->nprops>0) { /* Walk through the properties in the class */ curr_node=H5SL_first(tclass->props); while(curr_node!=NULL) { /* Get pointer to property from node */ tmp=H5SL_item(curr_node); /* Only call iterator callback for properties we haven't seen * before and that haven't been deleted */ if(H5SL_search(seen,tmp->name)==NULL && H5SL_search(plist->del,tmp->name)==NULL) { /* Check if we've found the correctly indexed property */ if(curr_idx>=*idx) { /* Call the callback function */ ret_value=(*iter_func)(plist_id,tmp->name,iter_data); if(ret_value!=0) HGOTO_DONE(ret_value); } /* end if */ /* Increment the current index */ curr_idx++; /* Add property name to "seen" list */ if(H5SL_insert(seen,tmp->name,tmp->name)<0) HGOTO_ERROR(H5E_PLIST,H5E_CANTINSERT,FAIL,"can't insert property into seen skip list"); } /* end if */ /* Get the next property node in the skip list */ curr_node=H5SL_next(curr_node); } /* end while */ } /* end if */ /* Go up to parent class */ tclass=tclass->parent; } /* end while */ done: /* Set the index we stopped at */ *idx=curr_idx; /* Release the skip list of 'seen' properties */ if(seen!=NULL) H5SL_close(seen); FUNC_LEAVE_NOAPI(ret_value); } /* H5P_iterate_plist() */ /*-------------------------------------------------------------------------- NAME H5P_iterate_pclass PURPOSE Internal routine to iterate over the properties in a property class USAGE herr_t H5P_iterate_pclass(pclass_id, idx, iter_func, iter_data) hid_t pclass_id; IN: ID of property class to iterate over int *idx; IN/OUT: Index of the property to begin with H5P_iterate_t iter_func; IN: Function pointer to function to be called with each property iterated over. void *iter_data; IN/OUT: Pointer to iteration data from user RETURNS Success: Returns the return value of the last call to ITER_FUNC if it was non-zero, or zero if all properties have been processed. Failure: negative value DESCRIPTION This routine iterates over the properties in the property object specified with PCLASS_ID. For each property in the object, the ITER_DATA and some additional information, specified below, are passed to the ITER_FUNC function. The iteration begins with the IDX property in the object and the next element to be processed by the operator is returned in IDX. If IDX is NULL, then the iterator starts at the first property; since no stopping point is returned in this case, the iterator cannot be restarted if one of the calls to its operator returns non-zero. The prototype for H5P_iterate_t is: typedef herr_t (*H5P_iterate_t)(hid_t id, const char *name, void *iter_data); The operation receives the property list or class identifier for the object being iterated over, ID, the name of the current property within the object, NAME, and the pointer to the operator data passed in to H5Piterate, ITER_DATA. The return values from an operator are: Zero causes the iterator to continue, returning zero when all properties have been processed. Positive causes the iterator to immediately return that positive value, indicating short-circuit success. The iterator can be restarted at the index of the next property. Negative causes the iterator to immediately return that value, indicating failure. The iterator can be restarted at the index of the next property. H5Piterate assumes that the properties in the object identified by ID remains unchanged through the iteration. If the membership changes during the iteration, the function's behavior is undefined. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static int H5P_iterate_pclass(hid_t pclass_id, int *idx, H5P_iterate_t iter_func, void *iter_data) { H5P_genclass_t *pclass; /* Property list pointer */ H5SL_node_t *curr_node; /* Current node in skip list */ H5P_genprop_t *prop; /* Temporary property pointer */ int curr_idx=0; /* Current iteration index */ int ret_value=FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5P_iterate_pclass); assert(idx); assert(iter_func); /* Get the property list object */ if (NULL == (pclass = H5I_object_verify(pclass_id, H5I_GENPROP_CLS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property class"); /* Cycle through the properties and call the callback */ curr_idx=0; curr_node=H5SL_first(pclass->props); while(curr_node!=NULL) { if(curr_idx>=*idx) { /* Get the property for the node */ prop=H5SL_item(curr_node); /* Call the callback function */ ret_value=(*iter_func)(pclass_id,prop->name,iter_data); /* Check if iteration function succeeded */ if(ret_value!=0) HGOTO_DONE(ret_value); } /* end if */ /* Increment the iteration index */ curr_idx++; /* Get the next property node in the skip list */ curr_node=H5SL_next(curr_node); } /* end while */ done: /* Set the index we stopped at */ *idx=curr_idx; FUNC_LEAVE_NOAPI(ret_value); } /* H5P_iterate_pclass() */ /*-------------------------------------------------------------------------- NAME H5Piterate PURPOSE Routine to iterate over the properties in a property list or class USAGE int H5Piterate(pclass_id, idx, iter_func, iter_data) hid_t id; IN: ID of property object to iterate over int *idx; IN/OUT: Index of the property to begin with H5P_iterate_t iter_func; IN: Function pointer to function to be called with each property iterated over. void *iter_data; IN/OUT: Pointer to iteration data from user RETURNS Success: Returns the return value of the last call to ITER_FUNC if it was non-zero, or zero if all properties have been processed. Failure: negative value DESCRIPTION This routine iterates over the properties in the property object specified with ID. The properties in both property lists and classes may be iterated over with this function. For each property in the object, the ITER_DATA and some additional information, specified below, are passed to the ITER_FUNC function. The iteration begins with the IDX property in the object and the next element to be processed by the operator is returned in IDX. If IDX is NULL, then the iterator starts at the first property; since no stopping point is returned in this case, the iterator cannot be restarted if one of the calls to its operator returns non-zero. The IDX value is 0-based (ie. to start at the "first" property, the IDX value should be 0). The prototype for H5P_iterate_t is: typedef herr_t (*H5P_iterate_t)(hid_t id, const char *name, void *iter_data); The operation receives the property list or class identifier for the object being iterated over, ID, the name of the current property within the object, NAME, and the pointer to the operator data passed in to H5Piterate, ITER_DATA. The return values from an operator are: Zero causes the iterator to continue, returning zero when all properties have been processed. Positive causes the iterator to immediately return that positive value, indicating short-circuit success. The iterator can be restarted at the index of the next property. Negative causes the iterator to immediately return that value, indicating failure. The iterator can be restarted at the index of the next property. H5Piterate assumes that the properties in the object identified by ID remains unchanged through the iteration. If the membership changes during the iteration, the function's behavior is undefined. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ int H5Piterate(hid_t id, int *idx, H5P_iterate_t iter_func, void *iter_data) { int fake_idx=0; /* Index when user doesn't provide one */ int ret_value; /* return value */ FUNC_ENTER_API(H5Piterate, FAIL); H5TRACE4("Is","i*Isxx",id,idx,iter_func,iter_data); /* Check arguments. */ if (H5I_GENPROP_LST != H5I_get_type(id) && H5I_GENPROP_CLS != H5I_get_type(id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property object"); if (iter_func==NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration callback"); if (H5I_GENPROP_LST == H5I_get_type(id)) { /* Iterate over a property list */ if ((ret_value=H5P_iterate_plist(id,(idx ? idx : &fake_idx),iter_func,iter_data))<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to iterate over list"); } /* end if */ else if (H5I_GENPROP_CLS == H5I_get_type(id)) { /* Iterate over a property class */ if ((ret_value=H5P_iterate_pclass(id,(idx ? idx : &fake_idx),iter_func,iter_data))<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to iterate over class"); } /* end if */ else HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property object"); done: FUNC_LEAVE_API(ret_value); } /* H5Piterate() */ /*-------------------------------------------------------------------------- NAME H5P_peek_unsigned PURPOSE Internal routine to quickly retrieve the value of a property in a property list. USAGE int H5P_peek_unsigned(plist, name) H5P_genplist_t *plist; IN: Property list to check const char *name; IN: Name of property to query RETURNS Directly returns the value of the property in the list DESCRIPTION This function directly returns the value of a property in a property list. Because this function is only able to just copy a particular property value to the return value, there is no way to check for errors. We attempt to make certain that bad things don't happen by validating that the size of the property is the same as the size of the return type, but that can't catch all errors. This function does call the user's 'get' callback routine still. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS No error checking! Use with caution! EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ unsigned H5P_peek_unsigned(H5P_genplist_t *plist, const char *name) { unsigned ret_value; /* return value */ FUNC_ENTER_NOAPI(H5P_peek_unsigned, UFAIL); assert(plist); assert(name); /* Get the value to return, don't worry about the return value, we can't return it */ H5P_get(plist,name,&ret_value); done: FUNC_LEAVE_NOAPI(ret_value); } /* H5P_peek_unsigned() */ /*-------------------------------------------------------------------------- NAME H5P_peek_hid_t PURPOSE Internal routine to quickly retrieve the value of a property in a property list. USAGE hid_t H5P_peek_hid_t(plist, name) H5P_genplist_t *plist; IN: Property list to check const char *name; IN: Name of property to query RETURNS Directly returns the value of the property in the list DESCRIPTION This function directly returns the value of a property in a property list. Because this function is only able to just copy a particular property value to the return value, there is no way to check for errors. We attempt to make certain that bad things don't happen by validating that the size of the property is the same as the size of the return type, but that can't catch all errors. This function does call the user's 'get' callback routine still. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS No error checking! Use with caution! EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ hid_t H5P_peek_hid_t(H5P_genplist_t *plist, const char *name) { hid_t ret_value; /* return value */ FUNC_ENTER_NOAPI(H5P_peek_hid_t, FAIL); assert(plist); assert(name); /* Get the value to return, don't worry about the return value, we can't return it */ H5P_get(plist,name,&ret_value); done: FUNC_LEAVE_NOAPI(ret_value); } /* H5P_peek_hid_t() */ /*-------------------------------------------------------------------------- NAME H5P_peek_voidp PURPOSE Internal routine to quickly retrieve the value of a property in a property list. USAGE void *H5P_peek_voidp(plist, name) H5P_genplist_t *plist; IN: Property list to check const char *name; IN: Name of property to query RETURNS Directly returns the value of the property in the list DESCRIPTION This function directly returns the value of a property in a property list. Because this function is only able to just copy a particular property value to the return value, there is no way to check for errors. We attempt to make certain that bad things don't happen by validating that the size of the property is the same as the size of the return type, but that can't catch all errors. This function does call the user's 'get' callback routine still. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS No error checking! Use with caution! EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ void * H5P_peek_voidp(H5P_genplist_t *plist, const char *name) { void * ret_value; /* return value */ FUNC_ENTER_NOAPI(H5P_peek_voidp, NULL); assert(plist); assert(name); /* Get the value to return, don't worry about the return value, we can't return it */ H5P_get(plist,name,&ret_value); done: FUNC_LEAVE_NOAPI(ret_value); } /* H5P_peek_voidp() */ /*-------------------------------------------------------------------------- NAME H5P_peek_size_t PURPOSE Internal routine to quickly retrieve the value of a property in a property list. USAGE hsize_t H5P_peek_size_t(plist, name) H5P_genplist_t *plist; IN: Property list to check const char *name; IN: Name of property to query RETURNS Directly returns the value of the property in the list DESCRIPTION This function directly returns the value of a property in a property list. Because this function is only able to just copy a particular property value to the return value, there is no way to check for errors. We attempt to make certain that bad things don't happen by validating that the size of the property is the same as the size of the return type, but that can't catch all errors. This function does call the user's 'get' callback routine still. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS No error checking! Use with caution! EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ size_t H5P_peek_size_t(H5P_genplist_t *plist, const char *name) { size_t ret_value; /* return value */ FUNC_ENTER_NOAPI(H5P_peek_size_t, UFAIL); assert(plist); assert(name); /* Get the value to return, don't worry about the return value, we can't return it */ H5P_get(plist,name,&ret_value); done: FUNC_LEAVE_NOAPI(ret_value); } /* H5P_peek_size_t() */ /*-------------------------------------------------------------------------- NAME H5P_get PURPOSE Internal routine to query the value of a property in a property list. USAGE herr_t H5P_get(plist, name, value) H5P_genplist_t *plist; IN: Property list to check const char *name; IN: Name of property to query void *value; OUT: Pointer to the buffer for the property value RETURNS Returns non-negative on success, negative on failure. DESCRIPTION Retrieves a copy of the value for a property in a property list. The property name must exist or this routine will fail. If there is a 'get' callback routine registered for this property, the copy of the value of the property will first be passed to that routine and any changes to the copy of the value will be used when returning the property value from this routine. If the 'get' callback routine returns an error, 'value' will not be modified and this routine will return an error. This routine may not be called for zero-sized properties. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5P_get(H5P_genplist_t *plist, const char *name, void *value) { H5P_genclass_t *tclass; /* Temporary class pointer */ H5P_genprop_t *prop; /* Temporary property pointer */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5P_get, FAIL); assert(plist); assert(name); assert(value); /* Check if the property has been deleted */ if(H5SL_search(plist->del,name)!=NULL) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "property doesn't exist"); /* Find property */ if((prop=H5SL_search(plist->props,name))!=NULL) { /* Check for property size >0 */ if(prop->size==0) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "property has zero size"); /* Make a copy of the value and pass to 'get' callback */ if(prop->get!=NULL) { void *tmp_value; /* Temporary value for property */ /* Make a copy of the current value, in case the callback fails */ if (NULL==(tmp_value=H5MM_malloc(prop->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed temporary property value"); HDmemcpy(tmp_value,prop->value,prop->size); /* Call user's callback */ if((*(prop->get))(plist->plist_id,name,prop->size,tmp_value)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't get property value"); /* Copy new [possibly unchanged] value into return value */ HDmemcpy(value,tmp_value,prop->size); /* Free the temporary value buffer */ H5MM_xfree(tmp_value); } /* end if */ /* No 'get' callback, just copy value */ else HDmemcpy(value,prop->value,prop->size); } /* end if */ else { /* * Check if we should get class properties (up through list of parent classes also), * & make property 'get' callback. */ tclass=plist->pclass; while(tclass!=NULL) { if(tclass->nprops>0) { /* Find the property in the class */ if((prop=H5SL_search(tclass->props,name))!=NULL) { /* Check for property size >0 */ if(prop->size==0) HGOTO_ERROR(H5E_PLIST,H5E_BADVALUE,FAIL,"property has zero size"); /* Call the 'get' callback, if there is one */ if(prop->get!=NULL) { void *tmp_value; /* Temporary value for property */ /* Make a copy of the current value, in case the callback fails */ if (NULL==(tmp_value=H5MM_malloc(prop->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed temporary property value"); HDmemcpy(tmp_value,prop->value,prop->size); /* Call user's callback */ if((*(prop->get))(plist->plist_id,name,prop->size,tmp_value)<0) { H5MM_xfree(tmp_value); HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set property value"); } /* end if */ if(HDmemcmp(tmp_value,prop->value,prop->size)) { H5P_genprop_t *pcopy; /* Copy of property to insert into skip list */ /* Make a copy of the class's property */ if((pcopy=H5P_dup_prop(prop,H5P_PROP_WITHIN_LIST))==NULL) HGOTO_ERROR(H5E_PLIST,H5E_CANTCOPY,FAIL,"Can't copy property"); /* Copy new value into property value */ HDmemcpy(pcopy->value,tmp_value,prop->size); /* Insert the changed property into the property list */ if(H5P_add_prop(plist->props,pcopy)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTINSERT, FAIL,"Can't insert changed property into skip list"); } /* end if */ /* Copy new [possibly unchanged] value into return value */ HDmemcpy(value,tmp_value,prop->size); /* Free the temporary value buffer */ H5MM_xfree(tmp_value); } /* end if */ /* No 'get' callback, just copy value */ else HDmemcpy(value,prop->value,prop->size); /* Leave */ HGOTO_DONE(SUCCEED); } /* end while */ } /* end if */ /* Go up to parent class */ tclass=tclass->parent; } /* end while */ /* If we get this far, then it wasn't in the list of changed properties, * nor in the properties in the class hierarchy, indicate an error */ HGOTO_ERROR(H5E_PLIST,H5E_NOTFOUND,FAIL,"can't find property in skip list"); } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value); } /* H5P_get() */ /*-------------------------------------------------------------------------- NAME H5Pget PURPOSE Routine to query the value of a property in a property list. USAGE herr_t H5Pget(plist_id, name, value) hid_t plist_id; IN: Property list to check const char *name; IN: Name of property to query void *value; OUT: Pointer to the buffer for the property value RETURNS Returns non-negative on success, negative on failure. DESCRIPTION Retrieves a copy of the value for a property in a property list. The property name must exist or this routine will fail. If there is a 'get' callback routine registered for this property, the copy of the value of the property will first be passed to that routine and any changes to the copy of the value will be used when returning the property value from this routine. If the 'get' callback routine returns an error, 'value' will not be modified and this routine will return an error. This routine may not be called for zero-sized properties. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5Pget(hid_t plist_id, const char *name, void *value) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pget, FAIL); H5TRACE3("e","isx",plist_id,name,value); /* Check arguments. */ if(NULL == (plist = H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property name"); if (value==NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalied property value"); /* Go get the value */ if(H5P_get(plist,name,value)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to query property value"); done: FUNC_LEAVE_API(ret_value); } /* H5Pget() */ /*-------------------------------------------------------------------------- NAME H5P_remove PURPOSE Internal routine to remove a property from a property list. USAGE herr_t H5P_remove(plist, name) H5P_genplist_t *plist; IN: Property list to modify const char *name; IN: Name of property to remove RETURNS Returns non-negative on success, negative on failure. DESCRIPTION Removes a property from a property list. Both properties which were in existance when the property list was created (i.e. properties registered with H5Pregister) and properties added to the list after it was created (i.e. added with H5Pinsert) may be removed from a property list. Properties do not need to be removed a property list before the list itself is closed, they will be released automatically when H5Pclose is called. The 'close' callback for this property is called before the property is release, if the callback exists. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5P_remove(hid_t plist_id, H5P_genplist_t *plist, const char *name) { H5P_genclass_t *tclass; /* Temporary class pointer */ H5P_genprop_t *prop; /* Temporary property pointer */ char *del_name; /* Pointer to deleted name */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5P_remove,FAIL); assert(plist); assert(name); /* Indicate that the property isn't in the list if it has been deleted already */ if(H5SL_search(plist->del,name)!=NULL) HGOTO_ERROR(H5E_PLIST,H5E_NOTFOUND,FAIL,"can't find property in skip list"); /* Get the property node from the changed property skip list */ if((prop=H5SL_search(plist->props,name))!=NULL) { /* Pass value to 'close' callback, if it exists */ if(prop->del!=NULL) { /* Call user's callback */ if((*(prop->del))(plist_id,name,prop->size,prop->value)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't close property value"); } /* end if */ /* Duplicate string for insertion into new deleted property skip list */ if((del_name=H5MM_xstrdup(name))==NULL) HGOTO_ERROR(H5E_RESOURCE,H5E_NOSPACE,FAIL,"memory allocation failed"); /* Insert property name into deleted list */ if(H5SL_insert(plist->del,del_name,del_name)<0) HGOTO_ERROR(H5E_PLIST,H5E_CANTINSERT,FAIL,"can't insert property into deleted skip list"); /* Remove the property from the skip list */ if(H5SL_remove(plist->props,prop->name)==NULL) HGOTO_ERROR(H5E_PLIST,H5E_CANTDELETE,FAIL,"can't remove property from skip list"); /* Free the property, ignoring return value, nothing we can do */ H5P_free_prop(prop); /* Decrement the number of properties in list */ plist->nprops--; } /* end if */ /* Walk through all the properties in the class hierarchy, looking for the property */ else { /* * Check if we should delete class properties (up through list of parent classes also), * & make property 'delete' callback. */ tclass=plist->pclass; while(tclass!=NULL) { if(tclass->nprops>0) { /* Find the property in the class */ if((prop=H5P_find_prop_pclass(tclass,name))!=NULL) { /* Pass value to 'del' callback, if it exists */ if(prop->del!=NULL) { void *tmp_value; /* Temporary value buffer */ /* Allocate space for a temporary copy of the property value */ if (NULL==(tmp_value=H5MM_malloc(prop->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for temporary property value"); HDmemcpy(tmp_value,prop->value,prop->size); /* Call user's callback */ if((*(prop->del))(plist_id,name,prop->size,tmp_value)<0) { H5MM_xfree(tmp_value); HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't close property value"); } /* end if */ /* Release the temporary value buffer */ H5MM_xfree(tmp_value); } /* end if */ /* Duplicate string for insertion into new deleted property skip list */ if((del_name=H5MM_xstrdup(name))==NULL) HGOTO_ERROR(H5E_RESOURCE,H5E_NOSPACE,FAIL,"memory allocation failed"); /* Insert property name into deleted list */ if(H5SL_insert(plist->del,del_name,del_name)<0) HGOTO_ERROR(H5E_PLIST,H5E_CANTINSERT,FAIL,"can't insert property into deleted skip list"); /* Decrement the number of properties in list */ plist->nprops--; /* Leave */ HGOTO_DONE(SUCCEED); } /* end while */ } /* end if */ /* Go up to parent class */ tclass=tclass->parent; } /* end while */ /* If we get this far, then it wasn't in the list of changed properties, * nor in the properties in the class hierarchy, indicate an error */ HGOTO_ERROR(H5E_PLIST,H5E_NOTFOUND,FAIL,"can't find property in skip list"); } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value); } /* H5P_remove() */ /*-------------------------------------------------------------------------- NAME H5Premove PURPOSE Routine to remove a property from a property list. USAGE herr_t H5Premove(plist_id, name) hid_t plist_id; IN: Property list to modify const char *name; IN: Name of property to remove RETURNS Returns non-negative on success, negative on failure. DESCRIPTION Removes a property from a property list. Both properties which were in existance when the property list was created (i.e. properties registered with H5Pregister) and properties added to the list after it was created (i.e. added with H5Pinsert) may be removed from a property list. Properties do not need to be removed a property list before the list itself is closed, they will be released automatically when H5Pclose is called. The 'close' callback for this property is called before the property is release, if the callback exists. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5Premove(hid_t plist_id, const char *name) { H5P_genplist_t *plist; /* Property list to modify */ herr_t ret_value; /* return value */ FUNC_ENTER_API(H5Premove, FAIL); H5TRACE2("e","is",plist_id,name); /* Check arguments. */ if (NULL == (plist = H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property name"); /* Create the new property list class */ if ((ret_value=H5P_remove(plist_id,plist,name))<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTDELETE, FAIL, "unable to remove property"); done: FUNC_LEAVE_API(ret_value); } /* H5Premove() */ /*-------------------------------------------------------------------------- NAME H5P_copy_prop_plist PURPOSE Internal routine to copy a property from one list to another USAGE herr_t H5P_copy_prop_plist(dst_plist, src_plist, name) hid_t dst_id; IN: ID of destination property list or class hid_t src_id; IN: ID of source property list or class const char *name; IN: Name of property to copy RETURNS Success: non-negative value. Failure: negative value. DESCRIPTION Copies a property from one property list to another. If a property is copied from one list to another, the property will be first deleted from the destination list (generating a call to the 'close' callback for the property, if one exists) and then the property is copied from the source list to the destination list (generating a call to the 'copy' callback for the property, if one exists). If the property does not exist in the destination list, this call is equivalent to calling H5Pinsert and the 'create' callback will be called (if such a callback exists for the property). GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5P_copy_prop_plist(hid_t dst_id, hid_t src_id, const char *name) { H5P_genplist_t *dst_plist; /* Pointer to destination property list */ H5P_genplist_t *src_plist; /* Pointer to source property list */ H5P_genprop_t *prop; /* Temporary property pointer */ H5P_genprop_t *new_prop=NULL; /* Pointer to new property */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_NOAPI_NOINIT(H5P_copy_prop_plist); assert(name); /* Get the objects to operate on */ if(NULL == (src_plist = H5I_object(src_id)) || NULL == (dst_plist = H5I_object(dst_id))) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "property object doesn't exist"); /* If the property exists in the destination alread */ if(H5P_find_prop_plist(dst_plist,name)!=NULL) { /* Delete the property from the destination list, calling the 'close' callback if necessary */ if(H5P_remove(dst_id,dst_plist,name)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTDELETE, FAIL, "unable to remove property"); /* Get the pointer to the source property */ prop=H5P_find_prop_plist(src_plist,name); /* Make a copy of the source property */ if((new_prop=H5P_dup_prop(prop,H5P_PROP_WITHIN_LIST))==NULL) HGOTO_ERROR (H5E_PLIST, H5E_CANTCOPY, FAIL,"Can't copy property"); /* Call property copy callback, if it exists */ if(new_prop->copy) { if((new_prop->copy)(new_prop->name,new_prop->size,new_prop->value)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTCOPY, FAIL,"Can't copy property"); } /* end if */ /* Insert the initialized property into the property list */ if(H5P_add_prop(dst_plist->props,new_prop)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTINSERT, FAIL,"Can't insert property into list"); /* Increment the number of properties in list */ dst_plist->nprops++; } /* end if */ /* If not, get the information required to do an H5Pinsert with the property into the destination list */ else { /* Get the pointer to the source property */ prop=H5P_find_prop_plist(src_plist,name); /* Create property object from parameters */ if((new_prop=H5P_create_prop(prop->name,prop->size,H5P_PROP_WITHIN_LIST,prop->value,prop->create,prop->set,prop->get,prop->del,prop->copy,prop->cmp,prop->close))==NULL) HGOTO_ERROR (H5E_PLIST, H5E_CANTCREATE, FAIL,"Can't create property"); /* Call property creation callback, if it exists */ if(new_prop->create) { if((new_prop->create)(new_prop->name,new_prop->size,new_prop->value)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTINIT, FAIL,"Can't initialize property"); } /* end if */ /* Insert property into property list class */ if(H5P_add_prop(dst_plist->props,new_prop)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTINSERT, FAIL,"Can't insert property into class"); /* Increment property count for class */ dst_plist->nprops++; } /* end else */ done: /* Cleanup, if necessary */ if(ret_value<0) { if(new_prop!=NULL) H5P_free_prop(new_prop); } /* end if */ FUNC_LEAVE_NOAPI(ret_value); } /* H5P_copy_prop_plist() */ /*-------------------------------------------------------------------------- NAME H5P_copy_prop_pclass PURPOSE Internal routine to copy a property from one class to another USAGE herr_t H5P_copy_prop_pclass(dst_pclass, src_pclass, name) H5P_genclass_t *dst_pclass; IN: Pointer to destination class H5P_genclass_t *src_pclass; IN: Pointer to source class const char *name; IN: Name of property to copy RETURNS Success: non-negative value. Failure: negative value. DESCRIPTION Copies a property from one property class to another. If a property is copied from one class to another, all the property information will be first deleted from the destination class and then the property information will be copied from the source class into the destination class. If the property does not exist in the destination class or list, this call is equivalent to calling H5Pregister. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5P_copy_prop_pclass(H5P_genclass_t *dst_pclass, H5P_genclass_t *src_pclass, const char *name) { H5P_genprop_t *prop; /* Temporary property pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_NOAPI_NOINIT(H5P_copy_prop_pclass); assert(dst_pclass); assert(src_pclass); assert(name); /* If the property exists in the destination already */ if(H5P_exist_pclass(dst_pclass,name)) { /* Delete the old property from the destination class */ if(H5P_unregister(dst_pclass,name)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTDELETE, FAIL, "unable to remove property"); } /* end if */ /* Get the property from the source */ if((prop=H5P_find_prop_pclass(src_pclass,name))==NULL) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "unable to locate property"); /* Register the property into the destination */ if(H5P_register(dst_pclass,name,prop->size,prop->value,prop->create,prop->set,prop->get,prop->del,prop->copy,prop->cmp,prop->close)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTDELETE, FAIL, "unable to remove property"); done: /* Cleanup, if necessary */ FUNC_LEAVE_NOAPI(ret_value); } /* H5P_copy_prop_pclass() */ /*-------------------------------------------------------------------------- NAME H5Pcopy_prop PURPOSE Routine to copy a property from one list or class to another USAGE herr_t H5Pcopy_prop(dst_id, src_id, name) hid_t dst_id; IN: ID of destination property list or class hid_t src_id; IN: ID of source property list or class const char *name; IN: Name of property to copy RETURNS Success: non-negative value. Failure: negative value. DESCRIPTION Copies a property from one property list or class to another. If a property is copied from one class to another, all the property information will be first deleted from the destination class and then the property information will be copied from the source class into the destination class. If a property is copied from one list to another, the property will be first deleted from the destination list (generating a call to the 'close' callback for the property, if one exists) and then the property is copied from the source list to the destination list (generating a call to the 'copy' callback for the property, if one exists). If the property does not exist in the destination class or list, this call is equivalent to calling H5Pregister or H5Pinsert (for a class or list, as appropriate) and the 'create' callback will be called in the case of the property being copied into a list (if such a callback exists for the property). GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5Pcopy_prop(hid_t dst_id, hid_t src_id, const char *name) { void *src_obj, *dst_obj; /* Property objects to copy between */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pcopy_prop, FAIL); H5TRACE3("e","iis",dst_id,src_id,name); /* Check arguments. */ if ((H5I_GENPROP_LST != H5I_get_type(src_id) && H5I_GENPROP_CLS != H5I_get_type(src_id)) || (H5I_GENPROP_LST != H5I_get_type(dst_id) && H5I_GENPROP_CLS != H5I_get_type(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not property objects"); if (H5I_get_type(src_id) != H5I_get_type(dst_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not the same kind of property objects"); if (!name || !*name) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no name given"); if(NULL == (src_obj = H5I_object(src_id)) || NULL == (dst_obj = H5I_object(dst_id))) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "property object doesn't exist"); /* Compare property lists */ if(H5I_GENPROP_LST == H5I_get_type(src_id)) { if(H5P_copy_prop_plist(dst_id,src_id,name)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy property between lists"); } /* end if */ /* Must be property classes */ else { if(H5P_copy_prop_pclass(dst_obj,src_obj,name)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy property between classes"); } /* end else */ done: FUNC_LEAVE_API(ret_value); } /* H5Pcopy_prop() */ /*-------------------------------------------------------------------------- NAME H5P_unregister PURPOSE Internal routine to remove a property from a property list class. USAGE herr_t H5P_unregister(pclass, name) H5P_genclass_t *pclass; IN: Property list class to modify const char *name; IN: Name of property to remove RETURNS Returns non-negative on success, negative on failure. DESCRIPTION Removes a property from a property list class. Future property lists created of that class will not contain this property. Existing property lists containing this property are not affected. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5P_unregister(H5P_genclass_t *pclass, const char *name) { H5P_genprop_t *prop; /* Temporary property pointer */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5P_unregister); assert(pclass); assert(name); /* Get the property node from the skip list */ if((prop=H5SL_search(pclass->props,name))==NULL) HGOTO_ERROR(H5E_PLIST,H5E_NOTFOUND,FAIL,"can't find property in skip list"); /* Remove the property from the skip list */ if(H5SL_remove(pclass->props,prop->name)==NULL) HGOTO_ERROR(H5E_PLIST,H5E_CANTDELETE,FAIL,"can't remove property from skip list"); /* Free the property, ignoring return value, nothing we can do */ H5P_free_prop(prop); /* Decrement the number of registered properties in class */ pclass->nprops--; /* Update the revision for the class */ pclass->revision = H5P_GET_NEXT_REV; done: FUNC_LEAVE_NOAPI(ret_value); } /* H5P_unregister() */ /*-------------------------------------------------------------------------- NAME H5Punregister PURPOSE Routine to remove a property from a property list class. USAGE herr_t H5Punregister(pclass_id, name) hid_t pclass_id; IN: Property list class to modify const char *name; IN: Name of property to remove RETURNS Returns non-negative on success, negative on failure. DESCRIPTION Removes a property from a property list class. Future property lists created of that class will not contain this property. Existing property lists containing this property are not affected. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5Punregister(hid_t pclass_id, const char *name) { H5P_genclass_t *pclass; /* Property list class to modify */ herr_t ret_value; /* return value */ FUNC_ENTER_API(H5Punregister, FAIL); H5TRACE2("e","is",pclass_id,name); /* Check arguments. */ if (NULL == (pclass = H5I_object_verify(pclass_id, H5I_GENPROP_CLS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class"); if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property name"); /* Remove the property list from class */ if ((ret_value=H5P_unregister(pclass,name))<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to remove property from class"); done: FUNC_LEAVE_API(ret_value); } /* H5Punregister() */ /*-------------------------------------------------------------------------- NAME H5P_close PURPOSE Internal routine to close a property list. USAGE herr_t H5P_close(plist) H5P_genplist_t *plist; IN: Property list to close RETURNS Returns non-negative on success, negative on failure. DESCRIPTION Closes a property list. If a 'close' callback exists for the property list class, it is called before the property list is destroyed. If 'close' callbacks exist for any individual properties in the property list, they are called after the class 'close' callback. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS The property list class 'close' callback routine is not called from here, it must have been check for and called properly prior to this routine being called EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5P_close(void *_plist) { H5P_genclass_t *tclass; /* Temporary class pointer */ H5P_genplist_t *plist=(H5P_genplist_t *)_plist; H5SL_t *seen=NULL; /* Skip list to hold names of properties already seen */ size_t nseen; /* Number of items 'seen' */ hbool_t has_parent_class; /* Flag to indicate that this property list's class has a parent */ size_t ndel; /* Number of items deleted */ H5SL_node_t *curr_node; /* Current node in skip list */ H5P_genprop_t *tmp; /* Temporary pointer to properties */ unsigned make_cb=0; /* Operator data for property free callback */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_NOAPI_NOINIT(H5P_close); assert(plist); /* Make call to property list class close callback, if needed */ if(plist->class_init!=0 && plist->pclass->close_func!=NULL) { /* Call user's "close" callback function, ignoring return value */ (plist->pclass->close_func)(plist->plist_id,plist->pclass->close_data); } /* end if */ /* Create the skip list to hold names of properties already seen * (This prevents a property in the class hierarchy from having it's * 'close' callback called, if a property in the class hierarchy has * already been seen) */ if((seen=H5SL_create(H5SL_TYPE_STR,0.5,H5P_DEFAULT_SKIPLIST_HEIGHT))==NULL) HGOTO_ERROR(H5E_PLIST,H5E_CANTCREATE,FAIL,"can't create skip list for seen properties"); nseen=0; /* Walk through the changed properties in the list */ if(H5SL_count(plist->props)>0) { curr_node=H5SL_first(plist->props); while(curr_node!=NULL) { /* Get pointer to property from node */ tmp=H5SL_item(curr_node); /* Call property close callback, if it exists */ if(tmp->close) { /* Call the 'close' callback */ (tmp->close)(tmp->name,tmp->size,tmp->value); } /* end if */ /* Add property name to "seen" list */ if(H5SL_insert(seen,tmp->name,tmp->name)<0) HGOTO_ERROR(H5E_PLIST,H5E_CANTINSERT,FAIL,"can't insert property into seen skip list"); nseen++; /* Get the next property node in the skip list */ curr_node=H5SL_next(curr_node); } /* end while */ } /* end if */ /* Determine number of deleted items from property list */ ndel=H5SL_count(plist->del); /* * Check if we should remove class properties (up through list of parent classes also), * initialize each with default value & make property 'remove' callback. */ tclass=plist->pclass; has_parent_class=(tclass!=NULL && tclass->parent!=NULL && tclass->parent->nprops>0); while(tclass!=NULL) { if(tclass->nprops>0) { /* Walk through the properties in the class */ curr_node=H5SL_first(tclass->props); while(curr_node!=NULL) { /* Get pointer to property from node */ tmp=H5SL_item(curr_node); /* Only "delete" properties we haven't seen before * and that haven't already been deleted */ if((nseen==0 || H5SL_search(seen,tmp->name)==NULL) && (ndel==0 || H5SL_search(plist->del,tmp->name)==NULL)) { /* Call property close callback, if it exists */ if(tmp->close) { void *tmp_value; /* Temporary value buffer */ /* Allocate space for a temporary copy of the property value */ if (NULL==(tmp_value=H5MM_malloc(tmp->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for temporary property value"); HDmemcpy(tmp_value,tmp->value,tmp->size); /* Call the 'close' callback */ (tmp->close)(tmp->name,tmp->size,tmp_value); /* Release the temporary value buffer */ H5MM_xfree(tmp_value); } /* end if */ /* Add property name to "seen" list, if we have other classes to work on */ if(has_parent_class) { if(H5SL_insert(seen,tmp->name,tmp->name)<0) HGOTO_ERROR(H5E_PLIST,H5E_CANTINSERT,FAIL,"can't insert property into seen skip list"); nseen++; } /* end if */ } /* end if */ /* Get the next property node in the skip list */ curr_node=H5SL_next(curr_node); } /* end while */ } /* end if */ /* Go up to parent class */ tclass=tclass->parent; } /* end while */ /* Decrement class's dependant property list value! */ if(H5P_access_class(plist->pclass,H5P_MOD_DEC_LST)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTINIT, FAIL, "Can't decrement class ref count"); /* Free the list of 'seen' properties */ H5SL_close(seen); seen=NULL; /* Free the list of deleted property names */ H5SL_destroy(plist->del,H5P_free_del_name_cb,NULL); /* Free the properties */ H5SL_destroy(plist->props,H5P_free_prop_cb,&make_cb); /* Destroy property list object */ H5FL_FREE(H5P_genplist_t,plist); done: /* Release the skip list of 'seen' properties */ if(seen!=NULL) H5SL_close(seen); FUNC_LEAVE_NOAPI(ret_value); } /* H5P_close() */ /*-------------------------------------------------------------------------- NAME H5Pclose PURPOSE Routine to close a property list. USAGE herr_t H5Pclose(plist_id) hid_t plist_id; IN: Property list to close RETURNS Returns non-negative on success, negative on failure. DESCRIPTION Closes a property list. If a 'close' callback exists for the property list class, it is called before the property list is destroyed. If 'close' callbacks exist for any individual properties in the property list, they are called after the class 'close' callback. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5Pclose(hid_t plist_id) { herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pclose, FAIL); H5TRACE1("e","i",plist_id); if (plist_id==H5P_DEFAULT) HGOTO_DONE(SUCCEED); /* Check arguments. */ if (H5I_GENPROP_LST != H5I_get_type(plist_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); /* Close the property list */ if (H5I_dec_ref(plist_id) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't close"); done: FUNC_LEAVE_API(ret_value); } /* H5Pclose() */ /*-------------------------------------------------------------------------- NAME H5P_get_class_name PURPOSE Internal routine to query the name of a generic property list class USAGE char *H5P_get_class_name(pclass) H5P_genclass_t *pclass; IN: Property list class to check RETURNS Success: Pointer to a malloc'ed string containing the class name Failure: NULL DESCRIPTION This routine retrieves the name of a generic property list class. The pointer to the name must be free'd by the user for successful calls. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ char * H5P_get_class_name(H5P_genclass_t *pclass) { char *ret_value; /* return value */ FUNC_ENTER_NOAPI(H5P_get_class_name, NULL); assert(pclass); /* Get class name */ ret_value=H5MM_xstrdup(pclass->name); done: FUNC_LEAVE_NOAPI(ret_value); } /* H5P_get_class_name() */ /*-------------------------------------------------------------------------- NAME H5Pget_class_name PURPOSE Routine to query the name of a generic property list class USAGE char *H5Pget_class_name(pclass_id) hid_t pclass_id; IN: Property class to query RETURNS Success: Pointer to a malloc'ed string containing the class name Failure: NULL DESCRIPTION This routine retrieves the name of a generic property list class. The pointer to the name must be free'd by the user for successful calls. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ char * H5Pget_class_name(hid_t pclass_id) { H5P_genclass_t *pclass; /* Property class to query */ char *ret_value; /* return value */ FUNC_ENTER_API(H5Pget_class_name, NULL); /* Check arguments. */ if (NULL == (pclass = H5I_object_verify(pclass_id, H5I_GENPROP_CLS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a property class"); /* Get the property list class name */ if ((ret_value=H5P_get_class_name(pclass))==NULL) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, NULL, "unable to query name of class"); done: FUNC_LEAVE_API(ret_value); } /* H5Pget_class_name() */ /*-------------------------------------------------------------------------- NAME H5P_get_class_path PURPOSE Internal routine to query the full path of a generic property list class USAGE char *H5P_get_class_name(pclass) H5P_genclass_t *pclass; IN: Property list class to check RETURNS Success: Pointer to a malloc'ed string containing the full path of class Failure: NULL DESCRIPTION This routine retrieves the full path name of a generic property list class, starting with the root of the class hierarchy. The pointer to the name must be free'd by the user for successful calls. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ char * H5P_get_class_path(H5P_genclass_t *pclass) { char *par_path; /* Parent class's full path */ size_t par_path_len;/* Parent class's full path's length */ size_t my_path_len; /* This class's name's length */ char *ret_value; /* return value */ FUNC_ENTER_NOAPI_NOINIT(H5P_get_class_path); assert(pclass); /* Recursively build the full path */ if(pclass->parent!=NULL) { /* Get the parent class's path */ par_path=H5P_get_class_path(pclass->parent); if(par_path!=NULL) { /* Get the string lengths we need to allocate space */ par_path_len=HDstrlen(par_path); my_path_len=HDstrlen(pclass->name); /* Allocate enough space for the parent class's path, plus the '/' * separator, this class's name and the string terminator */ if(NULL==(ret_value=H5MM_malloc(par_path_len+1+my_path_len+1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for class name"); /* Build the full path for this class */ HDstrcpy(ret_value,par_path); HDstrcat(ret_value,"/"); HDstrcat(ret_value,pclass->name); /* Free the parent class's path */ H5MM_xfree(par_path); } /* end if */ else ret_value=H5MM_xstrdup(pclass->name); } /* end if */ else ret_value=H5MM_xstrdup(pclass->name); done: FUNC_LEAVE_NOAPI(ret_value); } /* H5P_get_class_path() */ /*-------------------------------------------------------------------------- NAME H5P_open_class_path PURPOSE Internal routine to open [a copy of] a class with its full path name USAGE H5P_genclass_t *H5P_open_class_path(path) const char *path; IN: Full path name of class to open [copy of] RETURNS Success: Pointer to a generic property class object Failure: NULL DESCRIPTION This routine opens [a copy] of the class indicated by the full path. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ H5P_genclass_t * H5P_open_class_path(const char *path) { char *tmp_path=NULL; /* Temporary copy of the path */ char *curr_name; /* Pointer to current component of path name */ char *delimit; /* Pointer to path delimiter during traversal */ H5P_genclass_t *curr_class; /* Pointer to class during path traversal */ H5P_genclass_t *ret_value; /* Return value */ H5P_check_class_t check_info; /* Structure to hold the information for checking duplicate names */ FUNC_ENTER_NOAPI_NOINIT(H5P_open_class_path); assert(path); /* Duplicate the path to use */ tmp_path=HDstrdup(path); assert(tmp_path); /* Find the generic property class with this full path */ curr_name=tmp_path; curr_class=NULL; while((delimit=HDstrchr(curr_name,'/'))!=NULL) { /* Change the delimiter to terminate the string */ *delimit='\0'; /* Set up the search structure */ check_info.parent=curr_class; check_info.name=curr_name; /* Find the class with this name & parent by iterating over the open classes */ if((curr_class=H5I_search(H5I_GENPROP_CLS,H5P_check_class,&check_info))==NULL) HGOTO_ERROR (H5E_PLIST, H5E_NOTFOUND, NULL, "can't locate class"); /* Advance the pointer in the path to the start of the next component */ curr_name=delimit+1; } /* end while */ /* Should be pointing to the last component in the path name now... */ /* Set up the search structure */ check_info.parent=curr_class; check_info.name=curr_name; /* Find the class with this name & parent by iterating over the open classes */ if((curr_class=H5I_search(H5I_GENPROP_CLS,H5P_check_class,&check_info))==NULL) HGOTO_ERROR (H5E_PLIST, H5E_NOTFOUND, NULL, "can't locate class"); /* Copy it */ if((ret_value=H5P_copy_pclass(curr_class))==NULL) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, NULL, "can't copy property class"); done: /* Free the duplicated path */ H5MM_xfree(tmp_path); FUNC_LEAVE_NOAPI(ret_value); } /* H5P_open_class_path() */ /*-------------------------------------------------------------------------- NAME H5P_get_class_parent PURPOSE Internal routine to query the parent class of a generic property class USAGE H5P_genclass_t *H5P_get_class_parent(pclass) H5P_genclass_t *pclass; IN: Property class to check RETURNS Success: Pointer to the parent class of a property class Failure: NULL DESCRIPTION This routine retrieves a pointer to the parent class for a property class. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static H5P_genclass_t * H5P_get_class_parent(H5P_genclass_t *pclass) { H5P_genclass_t *ret_value; /* return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5P_get_class_parent); assert(pclass); /* Get property size */ ret_value=pclass->parent; FUNC_LEAVE_NOAPI(ret_value); } /* H5P_get_class_parent() */ /*-------------------------------------------------------------------------- NAME H5Pget_class_parent PURPOSE routine to query the parent class of a generic property class USAGE hid_t H5Pget_class_parent(pclass_id) hid_t pclass_id; IN: Property class to query RETURNS Success: ID of parent class object Failure: NULL DESCRIPTION This routine retrieves an ID for the parent class of a property class. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ hid_t H5Pget_class_parent(hid_t pclass_id) { H5P_genclass_t *pclass; /* Property class to query */ H5P_genclass_t *parent=NULL; /* Parent's property class */ hid_t ret_value; /* return value */ FUNC_ENTER_API(H5Pget_class_parent, FAIL); H5TRACE1("i","i",pclass_id); /* Check arguments. */ if (NULL == (pclass = H5I_object_verify(pclass_id, H5I_GENPROP_CLS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property class"); /* Retrieve the property class's parent */ if ((parent=H5P_get_class_parent(pclass))==NULL) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "unable to query class of property list"); /* Increment the outstanding references to the class object */ if(H5P_access_class(parent,H5P_MOD_INC_REF)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTINIT, FAIL,"Can't increment class ID ref count"); /* Get an atom for the class */ if ((ret_value = H5I_register(H5I_GENPROP_CLS, parent))<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to atomize property list class"); done: if (ret_value<0 && parent) H5P_close_class(parent); FUNC_LEAVE_API(ret_value); } /* H5Pget_class_parent() */ /*-------------------------------------------------------------------------- NAME H5P_close_class PURPOSE Internal routine to close a property list class. USAGE herr_t H5P_close_class(class) H5P_genclass_t *class; IN: Property list class to close RETURNS Returns non-negative on success, negative on failure. DESCRIPTION Releases memory and de-attach a class from the property list class hierarchy. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5P_close_class(void *_pclass) { H5P_genclass_t *pclass=(H5P_genclass_t *)_pclass; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5P_close_class); assert(pclass); /* Decrement the reference count & check if the object should go away */ if(H5P_access_class(pclass,H5P_MOD_DEC_REF)<0) HGOTO_ERROR (H5E_PLIST, H5E_NOTFOUND, FAIL, "Can't decrement ID ref count"); done: FUNC_LEAVE_NOAPI(ret_value); } /* H5P_close_class() */ /*-------------------------------------------------------------------------- NAME H5Pclose_class PURPOSE Close a property list class. USAGE herr_t H5Pclose_class(cls_id) hid_t cls_id; IN: Property list class ID to class RETURNS Returns non-negative on success, negative on failure. DESCRIPTION Releases memory and de-attach a class from the property list class hierarchy. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5Pclose_class(hid_t cls_id) { hid_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(H5Pclose_class, FAIL); H5TRACE1("e","i",cls_id); /* Check arguments */ if (H5I_GENPROP_CLS != H5I_get_type(cls_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class"); /* Close the property list class */ if (H5I_dec_ref(cls_id) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't close"); done: FUNC_LEAVE_API(ret_value); } /* H5Pclose_class() */ xdmf-3.0+git20160803/Utilities/hdf5/H5Tinit.WIN32.c.in0000640000175000017500000005124413003006557021537 0ustar alastairalastair/* Generated automatically by H5detect -- do not edit */ /*------------------------------------------------------------------------- * Copyright (C) 1997 National Center for Supercomputing Applications. * All rights reserved. * *------------------------------------------------------------------------- * * Created: Apr 18, 2000 * Patrick Lu * * Purpose: This machine-generated source code contains * information about the various integer and * floating point numeric formats found on this * architecture. The parameters below should be * checked carefully and errors reported to the * HDF5 maintainer. * * Each of the numeric formats listed below are * printed from most significant bit to least * significant bit even though the actual bytes * might be stored in a different order in * memory. The integers above each binary byte * indicate the relative order of the bytes in * memory; little-endian machines have * decreasing numbers while big-endian machines * have increasing numbers. * * The fields of the numbers are printed as * letters with `S' for the mantissa sign bit, * `M' for the mantissa magnitude, and `E' for * the exponent. The exponent has an associated * bias which can be subtracted to find the * true exponent. The radix point is assumed * to be before the first `M' bit. Any bit * of a floating-point value not falling into one * of these categories is printed as a question * mark. Bits of integer types are printed as * `I' for 2's complement and `U' for magnitude. * * If the most significant bit of the normalized * mantissa (always a `1' except for `0.0') is * not stored then an `implicit=yes' appears * under the field description. In thie case, * the radix point is still assumed to be * before the first `M' but after the implicit * bit. * * Modifications: * * DO NOT MAKE MODIFICATIONS TO THIS FILE! * It was generated by code in `H5detect.c'. * *------------------------------------------------------------------------- */ #define H5T_PACKAGE /*suppress error about including H5Tpkg.h*/ #define PABLO_MASK H5Tinit_mask #include #include #include #include #include #include static int interface_initialize_g = 0; #define INTERFACE_INIT NULL /* Declare external the free list for H5T_t's */ H5FL_EXTERN(H5T_t); int H5TN_term_interface(void) { interface_initialize_g = 0; return 0; } herr_t H5TN_init_interface(void) { H5T_t *dt = NULL; FUNC_ENTER (H5TN_init_interface, FAIL); /* * 0 * IIIIIIII * Alignment: none */ if (NULL==(dt = H5FL_ALLOC (H5T_t,1))) { HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } dt->state = H5T_STATE_IMMUTABLE; dt->ent.header = HADDR_UNDEF; dt->type = H5T_INTEGER; dt->size = 1; dt->u.atomic.order = H5T_ORDER_LE; dt->u.atomic.offset = 0; dt->u.atomic.prec = 8; dt->u.atomic.lsb_pad = H5T_PAD_ZERO; dt->u.atomic.msb_pad = H5T_PAD_ZERO; dt->u.atomic.u.i.sign = H5T_SGN_2; if ((H5T_NATIVE_SCHAR_g = H5I_register (H5I_DATATYPE, dt))<0) { HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't initialize type system (atom registration " "failure"); } H5T_NATIVE_SCHAR_ALIGN_g = 1; /* * 0 * UUUUUUUU * Alignment: none */ if (NULL==(dt = H5FL_ALLOC (H5T_t,1))) { HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } dt->state = H5T_STATE_IMMUTABLE; dt->ent.header = HADDR_UNDEF; dt->type = H5T_INTEGER; dt->size = 1; dt->u.atomic.order = H5T_ORDER_LE; dt->u.atomic.offset = 0; dt->u.atomic.prec = 8; dt->u.atomic.lsb_pad = H5T_PAD_ZERO; dt->u.atomic.msb_pad = H5T_PAD_ZERO; dt->u.atomic.u.i.sign = H5T_SGN_NONE; if ((H5T_NATIVE_UCHAR_g = H5I_register (H5I_DATATYPE, dt))<0) { HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't initialize type system (atom registration " "failure"); } H5T_NATIVE_UCHAR_ALIGN_g = 1; /* * 1 0 * IIIIIIII IIIIIIII * Alignment: none */ if (NULL==(dt = H5FL_ALLOC (H5T_t,1))) { HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } dt->state = H5T_STATE_IMMUTABLE; dt->ent.header = HADDR_UNDEF; dt->type = H5T_INTEGER; dt->size = 2; dt->u.atomic.order = H5T_ORDER_LE; dt->u.atomic.offset = 0; dt->u.atomic.prec = 16; dt->u.atomic.lsb_pad = H5T_PAD_ZERO; dt->u.atomic.msb_pad = H5T_PAD_ZERO; dt->u.atomic.u.i.sign = H5T_SGN_2; if ((H5T_NATIVE_SHORT_g = H5I_register (H5I_DATATYPE, dt))<0) { HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't initialize type system (atom registration " "failure"); } H5T_NATIVE_SHORT_ALIGN_g = 1; /* * 1 0 * UUUUUUUU UUUUUUUU * Alignment: none */ if (NULL==(dt = H5FL_ALLOC (H5T_t,1))) { HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } dt->state = H5T_STATE_IMMUTABLE; dt->ent.header = HADDR_UNDEF; dt->type = H5T_INTEGER; dt->size = 2; dt->u.atomic.order = H5T_ORDER_LE; dt->u.atomic.offset = 0; dt->u.atomic.prec = 16; dt->u.atomic.lsb_pad = H5T_PAD_ZERO; dt->u.atomic.msb_pad = H5T_PAD_ZERO; dt->u.atomic.u.i.sign = H5T_SGN_NONE; if ((H5T_NATIVE_USHORT_g = H5I_register (H5I_DATATYPE, dt))<0) { HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't initialize type system (atom registration " "failure"); } H5T_NATIVE_USHORT_ALIGN_g = 1; /* * 3 2 1 0 * IIIIIIII IIIIIIII IIIIIIII IIIIIIII * Alignment: none */ if (NULL==(dt = H5FL_ALLOC (H5T_t,1))) { HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } dt->state = H5T_STATE_IMMUTABLE; dt->ent.header = HADDR_UNDEF; dt->type = H5T_INTEGER; dt->size = 4; dt->u.atomic.order = H5T_ORDER_LE; dt->u.atomic.offset = 0; dt->u.atomic.prec = 32; dt->u.atomic.lsb_pad = H5T_PAD_ZERO; dt->u.atomic.msb_pad = H5T_PAD_ZERO; dt->u.atomic.u.i.sign = H5T_SGN_2; if ((H5T_NATIVE_INT_g = H5I_register (H5I_DATATYPE, dt))<0) { HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't initialize type system (atom registration " "failure"); } H5T_NATIVE_INT_ALIGN_g = 1; /* * 3 2 1 0 * UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU * Alignment: none */ if (NULL==(dt = H5FL_ALLOC (H5T_t,1))) { HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } dt->state = H5T_STATE_IMMUTABLE; dt->ent.header = HADDR_UNDEF; dt->type = H5T_INTEGER; dt->size = 4; dt->u.atomic.order = H5T_ORDER_LE; dt->u.atomic.offset = 0; dt->u.atomic.prec = 32; dt->u.atomic.lsb_pad = H5T_PAD_ZERO; dt->u.atomic.msb_pad = H5T_PAD_ZERO; dt->u.atomic.u.i.sign = H5T_SGN_NONE; if ((H5T_NATIVE_UINT_g = H5I_register (H5I_DATATYPE, dt))<0) { HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't initialize type system (atom registration " "failure"); } H5T_NATIVE_UINT_ALIGN_g = 1; /* * 3 2 1 0 * IIIIIIII IIIIIIII IIIIIIII IIIIIIII * Alignment: none */ if (NULL==(dt = H5FL_ALLOC (H5T_t,1))) { HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } dt->state = H5T_STATE_IMMUTABLE; dt->ent.header = HADDR_UNDEF; dt->type = H5T_INTEGER; dt->size = 4; dt->u.atomic.order = H5T_ORDER_LE; dt->u.atomic.offset = 0; dt->u.atomic.prec = 32; dt->u.atomic.lsb_pad = H5T_PAD_ZERO; dt->u.atomic.msb_pad = H5T_PAD_ZERO; dt->u.atomic.u.i.sign = H5T_SGN_2; if ((H5T_NATIVE_LONG_g = H5I_register (H5I_DATATYPE, dt))<0) { HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't initialize type system (atom registration " "failure"); } H5T_NATIVE_LONG_ALIGN_g = 1; /* * 3 2 1 0 * UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU * Alignment: none */ if (NULL==(dt = H5FL_ALLOC (H5T_t,1))) { HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } dt->state = H5T_STATE_IMMUTABLE; dt->ent.header = HADDR_UNDEF; dt->type = H5T_INTEGER; dt->size = 4; dt->u.atomic.order = H5T_ORDER_LE; dt->u.atomic.offset = 0; dt->u.atomic.prec = 32; dt->u.atomic.lsb_pad = H5T_PAD_ZERO; dt->u.atomic.msb_pad = H5T_PAD_ZERO; dt->u.atomic.u.i.sign = H5T_SGN_NONE; if ((H5T_NATIVE_ULONG_g = H5I_register (H5I_DATATYPE, dt))<0) { HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't initialize type system (atom registration " "failure"); } H5T_NATIVE_ULONG_ALIGN_g = 1; /* * 0 * IIIIIIII * Alignment: none */ if (NULL==(dt = H5FL_ALLOC (H5T_t,1))) { HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } dt->state = H5T_STATE_IMMUTABLE; dt->ent.header = HADDR_UNDEF; dt->type = H5T_INTEGER; dt->size = 1; dt->u.atomic.order = H5T_ORDER_LE; dt->u.atomic.offset = 0; dt->u.atomic.prec = 8; dt->u.atomic.lsb_pad = H5T_PAD_ZERO; dt->u.atomic.msb_pad = H5T_PAD_ZERO; dt->u.atomic.u.i.sign = H5T_SGN_2; if ((H5T_NATIVE_INT8_g = H5I_register (H5I_DATATYPE, dt))<0) { HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't initialize type system (atom registration " "failure"); } H5T_NATIVE_INT8_ALIGN_g = 1; /* * 0 * UUUUUUUU * Alignment: none */ if (NULL==(dt = H5FL_ALLOC (H5T_t,1))) { HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } dt->state = H5T_STATE_IMMUTABLE; dt->ent.header = HADDR_UNDEF; dt->type = H5T_INTEGER; dt->size = 1; dt->u.atomic.order = H5T_ORDER_LE; dt->u.atomic.offset = 0; dt->u.atomic.prec = 8; dt->u.atomic.lsb_pad = H5T_PAD_ZERO; dt->u.atomic.msb_pad = H5T_PAD_ZERO; dt->u.atomic.u.i.sign = H5T_SGN_NONE; if ((H5T_NATIVE_UINT8_g = H5I_register (H5I_DATATYPE, dt))<0) { HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't initialize type system (atom registration " "failure"); } H5T_NATIVE_UINT8_ALIGN_g = 1; /* * 1 0 * IIIIIIII IIIIIIII * Alignment: none */ if (NULL==(dt = H5FL_ALLOC (H5T_t,1))) { HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } dt->state = H5T_STATE_IMMUTABLE; dt->ent.header = HADDR_UNDEF; dt->type = H5T_INTEGER; dt->size = 2; dt->u.atomic.order = H5T_ORDER_LE; dt->u.atomic.offset = 0; dt->u.atomic.prec = 16; dt->u.atomic.lsb_pad = H5T_PAD_ZERO; dt->u.atomic.msb_pad = H5T_PAD_ZERO; dt->u.atomic.u.i.sign = H5T_SGN_2; if ((H5T_NATIVE_INT16_g = H5I_register (H5I_DATATYPE, dt))<0) { HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't initialize type system (atom registration " "failure"); } H5T_NATIVE_INT16_ALIGN_g = 1; /* * 1 0 * UUUUUUUU UUUUUUUU * Alignment: none */ if (NULL==(dt = H5FL_ALLOC (H5T_t,1))) { HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } dt->state = H5T_STATE_IMMUTABLE; dt->ent.header = HADDR_UNDEF; dt->type = H5T_INTEGER; dt->size = 2; dt->u.atomic.order = H5T_ORDER_LE; dt->u.atomic.offset = 0; dt->u.atomic.prec = 16; dt->u.atomic.lsb_pad = H5T_PAD_ZERO; dt->u.atomic.msb_pad = H5T_PAD_ZERO; dt->u.atomic.u.i.sign = H5T_SGN_NONE; if ((H5T_NATIVE_UINT16_g = H5I_register (H5I_DATATYPE, dt))<0) { HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't initialize type system (atom registration " "failure"); } H5T_NATIVE_UINT16_ALIGN_g = 1; /* * 3 2 1 0 * IIIIIIII IIIIIIII IIIIIIII IIIIIIII * Alignment: none */ if (NULL==(dt = H5FL_ALLOC (H5T_t,1))) { HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } dt->state = H5T_STATE_IMMUTABLE; dt->ent.header = HADDR_UNDEF; dt->type = H5T_INTEGER; dt->size = 4; dt->u.atomic.order = H5T_ORDER_LE; dt->u.atomic.offset = 0; dt->u.atomic.prec = 32; dt->u.atomic.lsb_pad = H5T_PAD_ZERO; dt->u.atomic.msb_pad = H5T_PAD_ZERO; dt->u.atomic.u.i.sign = H5T_SGN_2; if ((H5T_NATIVE_INT32_g = H5I_register (H5I_DATATYPE, dt))<0) { HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't initialize type system (atom registration " "failure"); } H5T_NATIVE_INT32_ALIGN_g = 1; /* * 3 2 1 0 * UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU * Alignment: none */ if (NULL==(dt = H5FL_ALLOC (H5T_t,1))) { HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } dt->state = H5T_STATE_IMMUTABLE; dt->ent.header = HADDR_UNDEF; dt->type = H5T_INTEGER; dt->size = 4; dt->u.atomic.order = H5T_ORDER_LE; dt->u.atomic.offset = 0; dt->u.atomic.prec = 32; dt->u.atomic.lsb_pad = H5T_PAD_ZERO; dt->u.atomic.msb_pad = H5T_PAD_ZERO; dt->u.atomic.u.i.sign = H5T_SGN_NONE; if ((H5T_NATIVE_UINT32_g = H5I_register (H5I_DATATYPE, dt))<0) { HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't initialize type system (atom registration " "failure"); } H5T_NATIVE_UINT32_ALIGN_g = 1; /* * 7 6 5 4 * IIIIIIII IIIIIIII IIIIIIII IIIIIIII * 3 2 1 0 * IIIIIIII IIIIIIII IIIIIIII IIIIIIII * Alignment: none */ if (NULL==(dt = H5FL_ALLOC (H5T_t,1))) { HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } dt->state = H5T_STATE_IMMUTABLE; dt->ent.header = HADDR_UNDEF; dt->type = H5T_INTEGER; dt->size = 8; dt->u.atomic.order = H5T_ORDER_LE; dt->u.atomic.offset = 0; dt->u.atomic.prec = 64; dt->u.atomic.lsb_pad = H5T_PAD_ZERO; dt->u.atomic.msb_pad = H5T_PAD_ZERO; dt->u.atomic.u.i.sign = H5T_SGN_2; if ((H5T_NATIVE_INT64_g = H5I_register (H5I_DATATYPE, dt))<0) { HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't initialize type system (atom registration " "failure"); } H5T_NATIVE_INT64_ALIGN_g = 1; /* * 7 6 5 4 * UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU * 3 2 1 0 * UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU * Alignment: none */ if (NULL==(dt = H5FL_ALLOC (H5T_t,1))) { HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } dt->state = H5T_STATE_IMMUTABLE; dt->ent.header = HADDR_UNDEF; dt->type = H5T_INTEGER; dt->size = 8; dt->u.atomic.order = H5T_ORDER_LE; dt->u.atomic.offset = 0; dt->u.atomic.prec = 64; dt->u.atomic.lsb_pad = H5T_PAD_ZERO; dt->u.atomic.msb_pad = H5T_PAD_ZERO; dt->u.atomic.u.i.sign = H5T_SGN_NONE; if ((H5T_NATIVE_UINT64_g = H5I_register (H5I_DATATYPE, dt))<0) { HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't initialize type system (atom registration " "failure"); } H5T_NATIVE_UINT64_ALIGN_g = 1; /* * 7 6 5 4 * IIIIIIII IIIIIIII IIIIIIII IIIIIIII * 3 2 1 0 * IIIIIIII IIIIIIII IIIIIIII IIIIIIII * Alignment: none */ if (NULL==(dt = H5FL_ALLOC (H5T_t,1))) { HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } dt->state = H5T_STATE_IMMUTABLE; dt->ent.header = HADDR_UNDEF; dt->type = H5T_INTEGER; dt->size = 8; dt->u.atomic.order = H5T_ORDER_LE; dt->u.atomic.offset = 0; dt->u.atomic.prec = 64; dt->u.atomic.lsb_pad = H5T_PAD_ZERO; dt->u.atomic.msb_pad = H5T_PAD_ZERO; dt->u.atomic.u.i.sign = H5T_SGN_2; if ((H5T_NATIVE_LLONG_g = H5I_register (H5I_DATATYPE, dt))<0) { HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't initialize type system (atom registration " "failure"); } H5T_NATIVE_LLONG_ALIGN_g = 1; /* * 7 6 5 4 * UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU * 3 2 1 0 * UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU * Alignment: none */ if (NULL==(dt = H5FL_ALLOC (H5T_t,1))) { HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } dt->state = H5T_STATE_IMMUTABLE; dt->ent.header = HADDR_UNDEF; dt->type = H5T_INTEGER; dt->size = 8; dt->u.atomic.order = H5T_ORDER_LE; dt->u.atomic.offset = 0; dt->u.atomic.prec = 64; dt->u.atomic.lsb_pad = H5T_PAD_ZERO; dt->u.atomic.msb_pad = H5T_PAD_ZERO; dt->u.atomic.u.i.sign = H5T_SGN_NONE; if ((H5T_NATIVE_ULLONG_g = H5I_register (H5I_DATATYPE, dt))<0) { HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't initialize type system (atom registration " "failure"); } H5T_NATIVE_ULLONG_ALIGN_g = 1; /* * 3 2 1 0 * SEEEEEEE EMMMMMMM MMMMMMMM MMMMMMMM * Implicit bit? yes * Alignment: none */ if (NULL==(dt = H5FL_ALLOC (H5T_t,1))) { HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } dt->state = H5T_STATE_IMMUTABLE; dt->ent.header = HADDR_UNDEF; dt->type = H5T_FLOAT; dt->size = 4; dt->u.atomic.order = H5T_ORDER_LE; dt->u.atomic.offset = 0; dt->u.atomic.prec = 32; dt->u.atomic.lsb_pad = H5T_PAD_ZERO; dt->u.atomic.msb_pad = H5T_PAD_ZERO; dt->u.atomic.u.f.sign = 31; dt->u.atomic.u.f.epos = 23; dt->u.atomic.u.f.esize = 8; dt->u.atomic.u.f.ebias = 0x0000007f; dt->u.atomic.u.f.mpos = 0; dt->u.atomic.u.f.msize = 23; dt->u.atomic.u.f.norm = H5T_NORM_IMPLIED; dt->u.atomic.u.f.pad = H5T_PAD_ZERO; if ((H5T_NATIVE_FLOAT_g = H5I_register (H5I_DATATYPE, dt))<0) { HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't initialize type system (atom registration " "failure"); } H5T_NATIVE_FLOAT_ALIGN_g = 1; /* * 7 6 5 4 * SEEEEEEE EEEEMMMM MMMMMMMM MMMMMMMM * 3 2 1 0 * MMMMMMMM MMMMMMMM MMMMMMMM MMMMMMMM * Implicit bit? yes * Alignment: none */ if (NULL==(dt = H5FL_ALLOC (H5T_t,1))) { HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } dt->state = H5T_STATE_IMMUTABLE; dt->ent.header = HADDR_UNDEF; dt->type = H5T_FLOAT; dt->size = 8; dt->u.atomic.order = H5T_ORDER_LE; dt->u.atomic.offset = 0; dt->u.atomic.prec = 64; dt->u.atomic.lsb_pad = H5T_PAD_ZERO; dt->u.atomic.msb_pad = H5T_PAD_ZERO; dt->u.atomic.u.f.sign = 63; dt->u.atomic.u.f.epos = 52; dt->u.atomic.u.f.esize = 11; dt->u.atomic.u.f.ebias = 0x000003ff; dt->u.atomic.u.f.mpos = 0; dt->u.atomic.u.f.msize = 52; dt->u.atomic.u.f.norm = H5T_NORM_IMPLIED; dt->u.atomic.u.f.pad = H5T_PAD_ZERO; if ((H5T_NATIVE_DOUBLE_g = H5I_register (H5I_DATATYPE, dt))<0) { HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't initialize type system (atom registration " "failure"); } H5T_NATIVE_DOUBLE_ALIGN_g = 1; /* * 11 10 9 8 * ???????? ???????? SEEEEEEE EEEEEEEE * 7 6 5 4 * MMMMMMMM MMMMMMMM MMMMMMMM MMMMMMMM * 3 2 1 0 * MMMMMMMM MMMMMMMM MMMMMMMM MMMMMMMM * Implicit bit? no * Alignment: none */ if (NULL==(dt = H5FL_ALLOC (H5T_t,1))) { HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } dt->state = H5T_STATE_IMMUTABLE; dt->ent.header = HADDR_UNDEF; dt->type = H5T_FLOAT; dt->size = 12; dt->u.atomic.order = H5T_ORDER_LE; dt->u.atomic.offset = 0; dt->u.atomic.prec = 80; dt->u.atomic.lsb_pad = H5T_PAD_ZERO; dt->u.atomic.msb_pad = H5T_PAD_ZERO; dt->u.atomic.u.f.sign = 79; dt->u.atomic.u.f.epos = 64; dt->u.atomic.u.f.esize = 15; dt->u.atomic.u.f.ebias = 0x00003fff; dt->u.atomic.u.f.mpos = 0; dt->u.atomic.u.f.msize = 64; dt->u.atomic.u.f.norm = H5T_NORM_NONE; dt->u.atomic.u.f.pad = H5T_PAD_ZERO; if ((H5T_NATIVE_LDOUBLE_g = H5I_register (H5I_DATATYPE, dt))<0) { HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't initialize type system (atom registration " "failure"); } H5T_NATIVE_LDOUBLE_ALIGN_g = 1; FUNC_LEAVE (SUCCEED); } xdmf-3.0+git20160803/Utilities/hdf5/H5FDcore.c0000640000175000017500000006203213003006557020401 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Robb Matzke * Tuesday, August 10, 1999 * * Purpose: A driver which stores the HDF5 data in main memory using * only the HDF5 public API. This driver is useful for fast * access to small, temporary hdf5 files. */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5FD_core_init_interface #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fprivate.h" /* File access */ #include "H5FDprivate.h" /* File drivers */ #include "H5FDcore.h" /* Core file driver */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Pprivate.h" /* Property lists */ /* The driver identification number, initialized at runtime */ static hid_t H5FD_CORE_g = 0; /* * The description of a file belonging to this driver. The `eoa' and `eof' * determine the amount of hdf5 address space in use and the high-water mark * of the file (the current size of the underlying memory). */ typedef struct H5FD_core_t { H5FD_t pub; /*public stuff, must be first */ char *name; /*for equivalence testing */ unsigned char *mem; /*the underlying memory */ haddr_t eoa; /*end of allocated region */ haddr_t eof; /*current allocated size */ size_t increment; /*multiples for mem allocation */ int fd; /*backing store file descriptor */ hbool_t dirty; /*changes not saved? */ } H5FD_core_t; /* Driver-specific file access properties */ typedef struct H5FD_core_fapl_t { size_t increment; /*how much to grow memory */ hbool_t backing_store; /*write to file name on flush */ } H5FD_core_fapl_t; /* Allocate memory in multiples of this size by default */ #define H5FD_CORE_INCREMENT 8192 /* * These macros check for overflow of various quantities. These macros * assume that file_offset_t is signed and haddr_t and size_t are unsigned. * * ADDR_OVERFLOW: Checks whether a file address of type `haddr_t' * is too large to be represented by the second argument * of the file seek function. * * SIZE_OVERFLOW: Checks whether a buffer size of type `hsize_t' is too * large to be represented by the `size_t' type. * * REGION_OVERFLOW: Checks whether an address and size pair describe data * which can be addressed entirely in memory. */ #define MAXADDR ((haddr_t)((~(size_t)0)-1)) #define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || (A) > (haddr_t)MAXADDR) #define SIZE_OVERFLOW(Z) ((Z) > (hsize_t)MAXADDR) #define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ HADDR_UNDEF==(A)+(Z) || \ (size_t)((A)+(Z))<(size_t)(A)) /* Prototypes */ static void *H5FD_core_fapl_get(H5FD_t *_file); static H5FD_t *H5FD_core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); static herr_t H5FD_core_close(H5FD_t *_file); static int H5FD_core_cmp(const H5FD_t *_f1, const H5FD_t *_f2); static haddr_t H5FD_core_get_eoa(H5FD_t *_file); static herr_t H5FD_core_set_eoa(H5FD_t *_file, haddr_t addr); static haddr_t H5FD_core_get_eof(H5FD_t *_file); static herr_t H5FD_core_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle); static herr_t H5FD_core_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, void *buf); static herr_t H5FD_core_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, const void *buf); static herr_t H5FD_core_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing); static const H5FD_class_t H5FD_core_g = { "core", /*name */ MAXADDR, /*maxaddr */ H5F_CLOSE_WEAK, /*fc_degree */ NULL, /*sb_size */ NULL, /*sb_encode */ NULL, /*sb_decode */ sizeof(H5FD_core_fapl_t), /*fapl_size */ H5FD_core_fapl_get, /*fapl_get */ NULL, /*fapl_copy */ NULL, /*fapl_free */ 0, /*dxpl_size */ NULL, /*dxpl_copy */ NULL, /*dxpl_free */ H5FD_core_open, /*open */ H5FD_core_close, /*close */ H5FD_core_cmp, /*cmp */ NULL, /*query */ NULL, /*alloc */ NULL, /*free */ H5FD_core_get_eoa, /*get_eoa */ H5FD_core_set_eoa, /*set_eoa */ H5FD_core_get_eof, /*get_eof */ H5FD_core_get_handle, /*get_handle */ H5FD_core_read, /*read */ H5FD_core_write, /*write */ H5FD_core_flush, /*flush */ NULL, /*lock */ NULL, /*unlock */ H5FD_FLMAP_SINGLE /*fl_map */ }; /*-------------------------------------------------------------------------- NAME H5FD_core_init_interface -- Initialize interface-specific information USAGE herr_t H5FD_core_init_interface() RETURNS Non-negative on success/Negative on failure DESCRIPTION Initializes any interface-specific data or routines. (Just calls H5FD_core_init currently). --------------------------------------------------------------------------*/ static herr_t H5FD_core_init_interface(void) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_core_init_interface) FUNC_LEAVE_NOAPI(H5FD_core_init()) } /* H5FD_core_init_interface() */ /*------------------------------------------------------------------------- * Function: H5FD_core_init * * Purpose: Initialize this driver by registering the driver with the * library. * * Return: Success: The driver ID for the core driver. * * Failure: Negative. * * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: * *------------------------------------------------------------------------- */ hid_t H5FD_core_init(void) { hid_t ret_value=H5FD_CORE_g; /* Return value */ FUNC_ENTER_NOAPI(H5FD_core_init, FAIL) if (H5I_VFL!=H5Iget_type(H5FD_CORE_g)) H5FD_CORE_g = H5FD_register(&H5FD_core_g,sizeof(H5FD_class_t)); /* Set return value */ ret_value=H5FD_CORE_g; done: FUNC_LEAVE_NOAPI(ret_value) } /*--------------------------------------------------------------------------- * Function: H5FD_core_term * * Purpose: Shut down the VFD * * Return: * * Programmer: Quincey Koziol * Friday, Jan 30, 2004 * * Modification: * *--------------------------------------------------------------------------- */ void H5FD_core_term(void) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_core_term) /* Reset VFL ID */ H5FD_CORE_g=0; FUNC_LEAVE_NOAPI_VOID } /* end H5FD_core_term() */ /*------------------------------------------------------------------------- * Function: H5Pset_fapl_core * * Purpose: Modify the file access property list to use the H5FD_CORE * driver defined in this source file. The INCREMENT specifies * how much to grow the memory each time we need more. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Thursday, February 19, 1998 * * Modifications: * Robb Matzke, 1999-10-19 * Added the BACKING_STORE argument. If set then the entire file * contents are flushed to a file with the same name as this * core file. * * Raymond Lu, 2001-10-25 * Changed the file access list to the new generic list. * *------------------------------------------------------------------------- */ herr_t H5Pset_fapl_core(hid_t fapl_id, size_t increment, hbool_t backing_store) { H5FD_core_fapl_t fa; H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value; FUNC_ENTER_API(H5Pset_fapl_core, FAIL) H5TRACE3("e","izb",fapl_id,increment,backing_store); /* Check argument */ if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") fa.increment = increment; fa.backing_store = backing_store; ret_value= H5P_set_driver(plist, H5FD_CORE, &fa); done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5Pget_fapl_core * * Purpose: Queries properties set by the H5Pset_fapl_core() function. * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Tuesday, August 10, 1999 * * Modifications: * Robb Matzke, 1999-10-19 * Added the BACKING_STORE argument. * * Raymond Lu * 2001-10-25 * Changed file access list to the new generic property list. * *------------------------------------------------------------------------- */ herr_t H5Pget_fapl_core(hid_t fapl_id, size_t *increment/*out*/, hbool_t *backing_store/*out*/) { H5FD_core_fapl_t *fa; H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Pget_fapl_core, FAIL) H5TRACE3("e","ixx",fapl_id,increment,backing_store); if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") if (H5FD_CORE!=H5P_get_driver(plist)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver") if (NULL==(fa=H5P_get_driver_info(plist))) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info") if (increment) *increment = fa->increment; if (backing_store) *backing_store = fa->backing_store; done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_core_fapl_get * * Purpose: Returns a copy of the file access properties. * * Return: Success: Ptr to new file access properties. * * Failure: NULL * * Programmer: Robb Matzke * Friday, August 13, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static void * H5FD_core_fapl_get(H5FD_t *_file) { H5FD_core_t *file = (H5FD_core_t*)_file; H5FD_core_fapl_t *fa = NULL; void *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_core_fapl_get, NULL) if (NULL==(fa=H5MM_calloc(sizeof(H5FD_core_fapl_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") fa->increment = file->increment; fa->backing_store = (file->fd>=0); /* Set return value */ ret_value=fa; done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_core_open * * Purpose: Create memory as an HDF5 file. * * Return: Success: A pointer to a new file data structure. The * public fields will be initialized by the * caller, which is always H5FD_open(). * * Failure: NULL * * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: * Robb Matzke, 1999-10-19 * The backing store file is created and opened if specified. *------------------------------------------------------------------------- */ static H5FD_t * H5FD_core_open(const char *name, unsigned UNUSED flags, hid_t fapl_id, haddr_t maxaddr) { H5FD_core_t *file=NULL; H5FD_core_fapl_t *fa=NULL; H5P_genplist_t *plist; /* Property list pointer */ int fd=-1; H5FD_t *ret_value; FUNC_ENTER_NOAPI(H5FD_core_open, NULL) /* Check arguments */ if (!(H5F_ACC_CREAT & flags)) HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, NULL, "must create core files, not open them") if (0==maxaddr || HADDR_UNDEF==maxaddr) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr") if (ADDR_OVERFLOW(maxaddr)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "maxaddr overflow") if (H5P_DEFAULT!=fapl_id) { if(NULL == (plist = H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") fa = H5P_get_driver_info(plist); } /* end if */ /* Open backing store */ if (fa && fa->backing_store && name && (fd=HDopen(name, (O_CREAT|O_TRUNC|O_RDWR), 0666))<0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open backing store") /* Create the new file struct */ if (NULL==(file=H5MM_calloc(sizeof(H5FD_core_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate file struct") file->fd = fd; if (name && *name) file->name = HDstrdup(name); /* * The increment comes from either the file access property list or the * default value. But if the file access property list was zero then use * the default value instead. */ file->increment = (fa && fa->increment>0) ? fa->increment : H5FD_CORE_INCREMENT; /* Set return value */ ret_value=(H5FD_t *)file; done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_core_close * * Purpose: Closes the file. * * Return: Success: 0 * * Failure: -1 * * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: * Robb Matzke, 1999-10-19 * The contents of memory are written to the backing store if * one is open. *------------------------------------------------------------------------- */ static herr_t H5FD_core_close(H5FD_t *_file) { H5FD_core_t *file = (H5FD_core_t*)_file; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_core_close, FAIL) /* Release resources */ if (file->fd>=0) HDclose(file->fd); if (file->name) H5MM_xfree(file->name); if (file->mem) H5MM_xfree(file->mem); HDmemset(file, 0, sizeof(H5FD_core_t)); H5MM_xfree(file); done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_core_cmp * * Purpose: Compares two files belonging to this driver by name. If one * file doesn't have a name then it is less than the other file. * If neither file has a name then the comparison is by file * address. * * Return: Success: A value like strcmp() * * Failure: never fails (arguments were checked by the * caller). * * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static int H5FD_core_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { const H5FD_core_t *f1 = (const H5FD_core_t*)_f1; const H5FD_core_t *f2 = (const H5FD_core_t*)_f2; int ret_value; FUNC_ENTER_NOAPI(H5FD_core_cmp, FAIL) if (NULL==f1->name && NULL==f2->name) { if (f1f2) HGOTO_DONE(1) HGOTO_DONE(0) } if (NULL==f1->name) HGOTO_DONE(-1) if (NULL==f2->name) HGOTO_DONE(1) ret_value = HDstrcmp(f1->name, f2->name); done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_core_get_eoa * * Purpose: Gets the end-of-address marker for the file. The EOA marker * is the first address past the last byte allocated in the * format address space. * * Return: Success: The end-of-address marker. * * Failure: HADDR_UNDEF * * Programmer: Robb Matzke * Monday, August 2, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static haddr_t H5FD_core_get_eoa(H5FD_t *_file) { haddr_t ret_value; /* Return value */ H5FD_core_t *file = (H5FD_core_t*)_file; FUNC_ENTER_NOAPI(H5FD_core_get_eoa, HADDR_UNDEF) /* Set return value */ ret_value=file->eoa; done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_core_set_eoa * * Purpose: Set the end-of-address marker for the file. This function is * called shortly after an existing HDF5 file is opened in order * to tell the driver where the end of the HDF5 data is located. * * Return: Success: 0 * * Failure: -1 * * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_core_set_eoa(H5FD_t *_file, haddr_t addr) { H5FD_core_t *file = (H5FD_core_t*)_file; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_core_set_eoa, FAIL) if (ADDR_OVERFLOW(addr)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "address overflow") file->eoa = addr; done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_core_get_eof * * Purpose: Returns the end-of-file marker, which is the greater of * either the size of the underlying memory or the HDF5 * end-of-address markers. * * Return: Success: End of file address, the first address past * the end of the "file", either the memory * or the HDF5 file. * * Failure: HADDR_UNDEF * * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static haddr_t H5FD_core_get_eof(H5FD_t *_file) { haddr_t ret_value; /* Return value */ H5FD_core_t *file = (H5FD_core_t*)_file; FUNC_ENTER_NOAPI(H5FD_core_get_eof, HADDR_UNDEF) /* Set return value */ ret_value=MAX(file->eof, file->eoa); done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_core_get_handle * * Purpose: Returns the file handle of CORE file driver. * * Returns: Non-negative if succeed or negative if fails. * * Programmer: Raymond Lu * Sept. 16, 2002 * * Modifications: * *------------------------------------------------------------------------- */ /* ARGSUSED */ static herr_t H5FD_core_get_handle(H5FD_t *_file, hid_t UNUSED fapl, void** file_handle) { H5FD_core_t *file = (H5FD_core_t *)_file; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5FD_core_get_handle, FAIL) if(!file_handle) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file handle not valid") *file_handle = &(file->mem); done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_core_read * * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR * into buffer BUF according to data transfer properties in * DXPL_ID. * * Return: Success: Zero. Result is stored in caller-supplied * buffer BUF. * * Failure: -1, Contents of buffer BUF are undefined. * * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: * *------------------------------------------------------------------------- */ /* ARGSUSED */ static herr_t H5FD_core_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, haddr_t addr, size_t size, void *buf/*out*/) { H5FD_core_t *file = (H5FD_core_t*)_file; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_core_read, FAIL) assert(file && file->pub.cls); assert(buf); /* Check for overflow conditions */ if (HADDR_UNDEF == addr) HGOTO_ERROR(H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed") if (REGION_OVERFLOW(addr, size)) HGOTO_ERROR(H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed") if (addr + size > file->eoa) HGOTO_ERROR(H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed") /* Read the part which is before the EOF marker */ if (addr < file->eof) { size_t nbytes; #ifndef NDEBUG hsize_t temp_nbytes; temp_nbytes = file->eof-addr; H5_CHECK_OVERFLOW(temp_nbytes,hsize_t,size_t); nbytes = MIN(size,(size_t)temp_nbytes); #else /* NDEBUG */ nbytes = MIN(size,(size_t)(file->eof-addr)); #endif /* NDEBUG */ HDmemcpy(buf, file->mem + addr, nbytes); size -= nbytes; addr += nbytes; buf = (char *)buf + nbytes; } /* Read zeros for the part which is after the EOF markers */ if (size > 0) HDmemset(buf, 0, size); done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_core_write * * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR * from buffer BUF according to data transfer properties in * DXPL_ID. * * Return: Success: Zero * * Failure: -1 * * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: * *------------------------------------------------------------------------- */ /* ARGSUSED */ static herr_t H5FD_core_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, haddr_t addr, size_t size, const void *buf) { H5FD_core_t *file = (H5FD_core_t*)_file; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_core_write, FAIL) assert(file && file->pub.cls); assert(buf); /* Check for overflow conditions */ if (REGION_OVERFLOW(addr, size)) HGOTO_ERROR(H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed") if (addr+size>file->eoa) HGOTO_ERROR(H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed") /* * Allocate more memory if necessary, careful of overflow. Also, if the * allocation fails then the file should remain in a usable state. Be * careful of non-Posix realloc() that doesn't understand what to do when * the first argument is null. */ if (addr+size>file->eof) { unsigned char *x; size_t new_eof; H5_ASSIGN_OVERFLOW(new_eof,file->increment*((addr+size)/file->increment),hsize_t,size_t); if ((addr+size) % file->increment) new_eof += file->increment; if (NULL==file->mem) x = H5MM_malloc(new_eof); else x = H5MM_realloc(file->mem, new_eof); if (!x) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate memory block") file->mem = x; file->eof = new_eof; } /* Write from BUF to memory */ HDmemcpy(file->mem+addr, buf, size); file->dirty = TRUE; done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_core_flush * * Purpose: Flushes the file to backing store if there is any and if the * dirty flag is set. * * Return: Success: 0 * * Failure: -1 * * Programmer: Robb Matzke * Friday, October 15, 1999 * * Modifications: * *------------------------------------------------------------------------- */ /* ARGSUSED */ static herr_t H5FD_core_flush(H5FD_t *_file, hid_t UNUSED dxpl_id, unsigned UNUSED closing) { H5FD_core_t *file = (H5FD_core_t*)_file; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_core_flush, FAIL) /* Write to backing store */ if (file->dirty && file->fd>=0) { haddr_t size = file->eof; unsigned char *ptr = file->mem; if (0!=HDlseek(file->fd, (off_t)0, SEEK_SET)) HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "error seeking in backing store") while (size) { ssize_t n; H5_CHECK_OVERFLOW(size,hsize_t,size_t); n = HDwrite(file->fd, ptr, (size_t)size); if (n<0 && EINTR==errno) continue; if (n<0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "error writing backing store") ptr += (size_t)n; size -= (size_t)n; } file->dirty = FALSE; } done: FUNC_LEAVE_NOAPI(ret_value) } xdmf-3.0+git20160803/Utilities/hdf5/H5FDfamily.h0000640000175000017500000000316413003006557020740 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Robb Matzke * Monday, August 4, 1999 * * Purpose: The public header file for the family driver. */ #ifndef H5FDfamily_H #define H5FDfamily_H #include "H5Ipublic.h" #define H5FD_FAMILY (H5FD_family_init()) #ifdef __cplusplus extern "C" { #endif H5_DLL hid_t H5FD_family_init(void); H5_DLL void H5FD_family_term(void); H5_DLL herr_t H5Pset_fapl_family(hid_t fapl_id, hsize_t memb_size, hid_t memb_fapl_id); H5_DLL herr_t H5Pget_fapl_family(hid_t fapl_id, hsize_t *memb_size/*out*/, hid_t *memb_fapl_id/*out*/); #ifdef __cplusplus } #endif #endif xdmf-3.0+git20160803/Utilities/hdf5/H5T.c0000640000175000017500000053751113003006557017453 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Module Info: This module contains most of the "core" functionality of * the H5T interface, including the API initialization code, etc. * Many routines that are infrequently used, or are specialized for * one particular datatype class are in another module. */ #define H5T_PACKAGE /*suppress error about including H5Tpkg */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5T_init_interface #include "H5private.h" /*generic functions */ #include "H5Dprivate.h" /*datasets (for H5Tcopy) */ #include "H5Eprivate.h" /*error handling */ #include "H5FLprivate.h" /* Free Lists */ #include "H5FOprivate.h" /* File objects */ #include "H5Gprivate.h" /*groups */ #include "H5Iprivate.h" /*ID functions */ #include "H5MMprivate.h" /*memory management */ #include "H5Pprivate.h" /* Property Lists */ #include "H5Tpkg.h" /*data-type functions */ /* Check for header needed for SGI floating-point code */ #ifdef H5_HAVE_SYS_FPU_H #include #endif /* H5_HAVE_SYS_FPU_H */ /* * Predefined data types. These are initialized at runtime in H5Tinit.c and * by H5T_init_interface() in this source file. * * If more of these are added, the new ones must be added to the list of * types to reset in H5T_term_interface(). */ hid_t H5T_IEEE_F32BE_g = FAIL; hid_t H5T_IEEE_F32LE_g = FAIL; hid_t H5T_IEEE_F64BE_g = FAIL; hid_t H5T_IEEE_F64LE_g = FAIL; hid_t H5T_STD_I8BE_g = FAIL; hid_t H5T_STD_I8LE_g = FAIL; hid_t H5T_STD_I16BE_g = FAIL; hid_t H5T_STD_I16LE_g = FAIL; hid_t H5T_STD_I32BE_g = FAIL; hid_t H5T_STD_I32LE_g = FAIL; hid_t H5T_STD_I64BE_g = FAIL; hid_t H5T_STD_I64LE_g = FAIL; hid_t H5T_STD_U8BE_g = FAIL; hid_t H5T_STD_U8LE_g = FAIL; hid_t H5T_STD_U16BE_g = FAIL; hid_t H5T_STD_U16LE_g = FAIL; hid_t H5T_STD_U32BE_g = FAIL; hid_t H5T_STD_U32LE_g = FAIL; hid_t H5T_STD_U64BE_g = FAIL; hid_t H5T_STD_U64LE_g = FAIL; hid_t H5T_STD_B8BE_g = FAIL; hid_t H5T_STD_B8LE_g = FAIL; hid_t H5T_STD_B16BE_g = FAIL; hid_t H5T_STD_B16LE_g = FAIL; hid_t H5T_STD_B32BE_g = FAIL; hid_t H5T_STD_B32LE_g = FAIL; hid_t H5T_STD_B64BE_g = FAIL; hid_t H5T_STD_B64LE_g = FAIL; hid_t H5T_STD_REF_OBJ_g = FAIL; hid_t H5T_STD_REF_DSETREG_g = FAIL; hid_t H5T_UNIX_D32BE_g = FAIL; hid_t H5T_UNIX_D32LE_g = FAIL; hid_t H5T_UNIX_D64BE_g = FAIL; hid_t H5T_UNIX_D64LE_g = FAIL; hid_t H5T_C_S1_g = FAIL; hid_t H5T_FORTRAN_S1_g = FAIL; hid_t H5T_NATIVE_SCHAR_g = FAIL; hid_t H5T_NATIVE_UCHAR_g = FAIL; hid_t H5T_NATIVE_SHORT_g = FAIL; hid_t H5T_NATIVE_USHORT_g = FAIL; hid_t H5T_NATIVE_INT_g = FAIL; hid_t H5T_NATIVE_UINT_g = FAIL; hid_t H5T_NATIVE_LONG_g = FAIL; hid_t H5T_NATIVE_ULONG_g = FAIL; hid_t H5T_NATIVE_LLONG_g = FAIL; hid_t H5T_NATIVE_ULLONG_g = FAIL; hid_t H5T_NATIVE_FLOAT_g = FAIL; hid_t H5T_NATIVE_DOUBLE_g = FAIL; hid_t H5T_NATIVE_LDOUBLE_g = FAIL; hid_t H5T_NATIVE_B8_g = FAIL; hid_t H5T_NATIVE_B16_g = FAIL; hid_t H5T_NATIVE_B32_g = FAIL; hid_t H5T_NATIVE_B64_g = FAIL; hid_t H5T_NATIVE_OPAQUE_g = FAIL; hid_t H5T_NATIVE_HADDR_g = FAIL; hid_t H5T_NATIVE_HSIZE_g = FAIL; hid_t H5T_NATIVE_HSSIZE_g = FAIL; hid_t H5T_NATIVE_HERR_g = FAIL; hid_t H5T_NATIVE_HBOOL_g = FAIL; hid_t H5T_NATIVE_INT8_g = FAIL; hid_t H5T_NATIVE_UINT8_g = FAIL; hid_t H5T_NATIVE_INT_LEAST8_g = FAIL; hid_t H5T_NATIVE_UINT_LEAST8_g = FAIL; hid_t H5T_NATIVE_INT_FAST8_g = FAIL; hid_t H5T_NATIVE_UINT_FAST8_g = FAIL; hid_t H5T_NATIVE_INT16_g = FAIL; hid_t H5T_NATIVE_UINT16_g = FAIL; hid_t H5T_NATIVE_INT_LEAST16_g = FAIL; hid_t H5T_NATIVE_UINT_LEAST16_g = FAIL; hid_t H5T_NATIVE_INT_FAST16_g = FAIL; hid_t H5T_NATIVE_UINT_FAST16_g = FAIL; hid_t H5T_NATIVE_INT32_g = FAIL; hid_t H5T_NATIVE_UINT32_g = FAIL; hid_t H5T_NATIVE_INT_LEAST32_g = FAIL; hid_t H5T_NATIVE_UINT_LEAST32_g = FAIL; hid_t H5T_NATIVE_INT_FAST32_g = FAIL; hid_t H5T_NATIVE_UINT_FAST32_g = FAIL; hid_t H5T_NATIVE_INT64_g = FAIL; hid_t H5T_NATIVE_UINT64_g = FAIL; hid_t H5T_NATIVE_INT_LEAST64_g = FAIL; hid_t H5T_NATIVE_UINT_LEAST64_g = FAIL; hid_t H5T_NATIVE_INT_FAST64_g = FAIL; hid_t H5T_NATIVE_UINT_FAST64_g = FAIL; /* * Alignment constraints for native types. These are initialized at run time * in H5Tinit.c. These alignments are mainly for offsets in HDF5 compound * datatype or C structures, which are different from the alignments for memory * address below this group of variables. */ size_t H5T_NATIVE_SCHAR_COMP_ALIGN_g = 0; size_t H5T_NATIVE_UCHAR_COMP_ALIGN_g = 0; size_t H5T_NATIVE_SHORT_COMP_ALIGN_g = 0; size_t H5T_NATIVE_USHORT_COMP_ALIGN_g = 0; size_t H5T_NATIVE_INT_COMP_ALIGN_g = 0; size_t H5T_NATIVE_UINT_COMP_ALIGN_g = 0; size_t H5T_NATIVE_LONG_COMP_ALIGN_g = 0; size_t H5T_NATIVE_ULONG_COMP_ALIGN_g = 0; size_t H5T_NATIVE_LLONG_COMP_ALIGN_g = 0; size_t H5T_NATIVE_ULLONG_COMP_ALIGN_g = 0; size_t H5T_NATIVE_FLOAT_COMP_ALIGN_g = 0; size_t H5T_NATIVE_DOUBLE_COMP_ALIGN_g = 0; size_t H5T_NATIVE_LDOUBLE_COMP_ALIGN_g = 0; size_t H5T_POINTER_COMP_ALIGN_g = 0; size_t H5T_HVL_COMP_ALIGN_g = 0; size_t H5T_HOBJREF_COMP_ALIGN_g = 0; size_t H5T_HDSETREGREF_COMP_ALIGN_g = 0; /* * Alignment constraints for native types. These are initialized at run time * in H5Tinit.c */ size_t H5T_NATIVE_SCHAR_ALIGN_g = 0; size_t H5T_NATIVE_UCHAR_ALIGN_g = 0; size_t H5T_NATIVE_SHORT_ALIGN_g = 0; size_t H5T_NATIVE_USHORT_ALIGN_g = 0; size_t H5T_NATIVE_INT_ALIGN_g = 0; size_t H5T_NATIVE_UINT_ALIGN_g = 0; size_t H5T_NATIVE_LONG_ALIGN_g = 0; size_t H5T_NATIVE_ULONG_ALIGN_g = 0; size_t H5T_NATIVE_LLONG_ALIGN_g = 0; size_t H5T_NATIVE_ULLONG_ALIGN_g = 0; size_t H5T_NATIVE_FLOAT_ALIGN_g = 0; size_t H5T_NATIVE_DOUBLE_ALIGN_g = 0; size_t H5T_NATIVE_LDOUBLE_ALIGN_g = 0; /* * Alignment constraints for C9x types. These are initialized at run time in * H5Tinit.c if the types are provided by the system. Otherwise we set their * values to 0 here (no alignment calculated). */ size_t H5T_NATIVE_INT8_ALIGN_g = 0; size_t H5T_NATIVE_UINT8_ALIGN_g = 0; size_t H5T_NATIVE_INT_LEAST8_ALIGN_g = 0; size_t H5T_NATIVE_UINT_LEAST8_ALIGN_g = 0; size_t H5T_NATIVE_INT_FAST8_ALIGN_g = 0; size_t H5T_NATIVE_UINT_FAST8_ALIGN_g = 0; size_t H5T_NATIVE_INT16_ALIGN_g = 0; size_t H5T_NATIVE_UINT16_ALIGN_g = 0; size_t H5T_NATIVE_INT_LEAST16_ALIGN_g = 0; size_t H5T_NATIVE_UINT_LEAST16_ALIGN_g = 0; size_t H5T_NATIVE_INT_FAST16_ALIGN_g = 0; size_t H5T_NATIVE_UINT_FAST16_ALIGN_g = 0; size_t H5T_NATIVE_INT32_ALIGN_g = 0; size_t H5T_NATIVE_UINT32_ALIGN_g = 0; size_t H5T_NATIVE_INT_LEAST32_ALIGN_g = 0; size_t H5T_NATIVE_UINT_LEAST32_ALIGN_g = 0; size_t H5T_NATIVE_INT_FAST32_ALIGN_g = 0; size_t H5T_NATIVE_UINT_FAST32_ALIGN_g = 0; size_t H5T_NATIVE_INT64_ALIGN_g = 0; size_t H5T_NATIVE_UINT64_ALIGN_g = 0; size_t H5T_NATIVE_INT_LEAST64_ALIGN_g = 0; size_t H5T_NATIVE_UINT_LEAST64_ALIGN_g = 0; size_t H5T_NATIVE_INT_FAST64_ALIGN_g = 0; size_t H5T_NATIVE_UINT_FAST64_ALIGN_g = 0; /* Useful floating-point values for conversion routines */ /* (+/- Inf for all floating-point types) */ float H5T_NATIVE_FLOAT_POS_INF_g = 0.0; float H5T_NATIVE_FLOAT_NEG_INF_g = 0.0; double H5T_NATIVE_DOUBLE_POS_INF_g = 0.0; double H5T_NATIVE_DOUBLE_NEG_INF_g = 0.0; /* * The path database. Each path has a source and destination data type pair * which is used as the key by which the `entries' array is sorted. */ static struct { int npaths; /*number of paths defined */ int apaths; /*number of paths allocated */ H5T_path_t **path; /*sorted array of path pointers */ int nsoft; /*number of soft conversions defined */ int asoft; /*number of soft conversions allocated */ H5T_soft_t *soft; /*unsorted array of soft conversions */ } H5T_g; /* The overflow handler */ H5T_overflow_t H5T_overflow_g = NULL; /* The native endianess of the platform */ H5T_order_t H5T_native_order_g = H5T_ORDER_ERROR; /* Declare the free list for H5T_t's and H5T_shared_t's */ H5FL_DEFINE(H5T_t); H5FL_DEFINE(H5T_shared_t); /* Declare the free list for H5T_path_t's */ H5FL_DEFINE(H5T_path_t); /* Static local functions */ static H5T_t *H5T_open_oid(H5G_entry_t *ent, hid_t dxpl_id); static herr_t H5T_print_stats(H5T_path_t *path, int *nprint/*in,out*/); static herr_t H5T_unregister(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, H5T_conv_t func, hid_t dxpl_id); static herr_t H5T_register(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, H5T_conv_t func, hid_t dxpl_id); /* * Type initialization macros * * These use the "template macro" technique to reduce the amount of gratuitous * duplicated code when initializing the datatypes for the library. The main * template macro is the H5T_INIT_TYPE() macro below. * */ /* Define the code template for types which need no extra initialization for the "GUTS" in the H5T_INIT_TYPE macro */ #define H5T_INIT_TYPE_NONE_CORE { \ } /* Define the code template for bitfields for the "GUTS" in the H5T_INIT_TYPE macro */ #define H5T_INIT_TYPE_BITFIELD_CORE { \ dt->shared->type = H5T_BITFIELD; \ } /* Define the code template for times for the "GUTS" in the H5T_INIT_TYPE macro */ #define H5T_INIT_TYPE_TIME_CORE { \ dt->shared->type = H5T_TIME; \ } /* Define the code template for types which reset the offset for the "GUTS" in the H5T_INIT_TYPE macro */ #define H5T_INIT_TYPE_OFFSET_CORE { \ dt->shared->u.atomic.offset = 0; \ } /* Define common code for all numeric types (floating-point & int, signed & unsigned) */ #define H5T_INIT_TYPE_NUM_COMMON(ENDIANNESS) { \ dt->shared->u.atomic.order = ENDIANNESS; \ dt->shared->u.atomic.offset = 0; \ dt->shared->u.atomic.lsb_pad = H5T_PAD_ZERO; \ dt->shared->u.atomic.msb_pad = H5T_PAD_ZERO; \ } /* Define the code templates for standard floats for the "GUTS" in the H5T_INIT_TYPE macro */ #define H5T_INIT_TYPE_FLOAT_COMMON(ENDIANNESS) { \ H5T_INIT_TYPE_NUM_COMMON(ENDIANNESS) \ dt->shared->u.atomic.u.f.sign = 31; \ dt->shared->u.atomic.u.f.epos = 23; \ dt->shared->u.atomic.u.f.esize = 8; \ dt->shared->u.atomic.u.f.ebias = 0x7f; \ dt->shared->u.atomic.u.f.mpos = 0; \ dt->shared->u.atomic.u.f.msize = 23; \ dt->shared->u.atomic.u.f.norm = H5T_NORM_IMPLIED; \ dt->shared->u.atomic.u.f.pad = H5T_PAD_ZERO; \ } #define H5T_INIT_TYPE_FLOATLE_CORE { \ H5T_INIT_TYPE_FLOAT_COMMON(H5T_ORDER_LE) \ } #define H5T_INIT_TYPE_FLOATBE_CORE { \ H5T_INIT_TYPE_FLOAT_COMMON(H5T_ORDER_BE) \ } /* Define the code templates for standard doubles for the "GUTS" in the H5T_INIT_TYPE macro */ #define H5T_INIT_TYPE_DOUBLE_COMMON(ENDIANNESS) { \ H5T_INIT_TYPE_NUM_COMMON(ENDIANNESS) \ dt->shared->u.atomic.u.f.sign = 63; \ dt->shared->u.atomic.u.f.epos = 52; \ dt->shared->u.atomic.u.f.esize = 11; \ dt->shared->u.atomic.u.f.ebias = 0x03ff; \ dt->shared->u.atomic.u.f.mpos = 0; \ dt->shared->u.atomic.u.f.msize = 52; \ dt->shared->u.atomic.u.f.norm = H5T_NORM_IMPLIED; \ dt->shared->u.atomic.u.f.pad = H5T_PAD_ZERO; \ } #define H5T_INIT_TYPE_DOUBLELE_CORE { \ H5T_INIT_TYPE_DOUBLE_COMMON(H5T_ORDER_LE) \ } #define H5T_INIT_TYPE_DOUBLEBE_CORE { \ H5T_INIT_TYPE_DOUBLE_COMMON(H5T_ORDER_BE) \ } /* Define the code templates for standard signed integers for the "GUTS" in the H5T_INIT_TYPE macro */ #define H5T_INIT_TYPE_SINT_COMMON(ENDIANNESS) { \ H5T_INIT_TYPE_NUM_COMMON(ENDIANNESS) \ dt->shared->u.atomic.u.i.sign = H5T_SGN_2; \ } #define H5T_INIT_TYPE_SINTLE_CORE { \ H5T_INIT_TYPE_SINT_COMMON(H5T_ORDER_LE) \ } #define H5T_INIT_TYPE_SINTBE_CORE { \ H5T_INIT_TYPE_SINT_COMMON(H5T_ORDER_BE) \ } /* Define the code templates for standard unsigned integers for the "GUTS" in the H5T_INIT_TYPE macro */ #define H5T_INIT_TYPE_UINT_COMMON(ENDIANNESS) { \ H5T_INIT_TYPE_NUM_COMMON(ENDIANNESS) \ dt->shared->u.atomic.u.i.sign = H5T_SGN_NONE; \ } #define H5T_INIT_TYPE_UINTLE_CORE { \ H5T_INIT_TYPE_UINT_COMMON(H5T_ORDER_LE) \ } #define H5T_INIT_TYPE_UINTBE_CORE { \ H5T_INIT_TYPE_UINT_COMMON(H5T_ORDER_BE) \ } /* Define a macro for common code for all newly allocate datatypes */ #define H5T_INIT_TYPE_ALLOC_COMMON(TYPE) { \ dt->ent.header = HADDR_UNDEF; \ dt->shared->type = TYPE; \ } /* Define the code templates for opaque for the "GUTS" in the H5T_INIT_TYPE macro */ #define H5T_INIT_TYPE_OPAQ_CORE { \ H5T_INIT_TYPE_ALLOC_COMMON(H5T_OPAQUE) \ dt->shared->u.opaque.tag = H5MM_strdup(""); \ } /* Define the code templates for strings for the "GUTS" in the H5T_INIT_TYPE macro */ #define H5T_INIT_TYPE_STRING_COMMON { \ H5T_INIT_TYPE_ALLOC_COMMON(H5T_STRING) \ H5T_INIT_TYPE_NUM_COMMON(H5T_ORDER_NONE) \ dt->shared->u.atomic.u.s.cset = H5T_CSET_ASCII; \ } #define H5T_INIT_TYPE_CSTRING_CORE { \ H5T_INIT_TYPE_STRING_COMMON \ dt->shared->u.atomic.u.s.pad = H5T_STR_NULLTERM; \ } #define H5T_INIT_TYPE_FORSTRING_CORE { \ H5T_INIT_TYPE_STRING_COMMON \ dt->shared->u.atomic.u.s.pad = H5T_STR_SPACEPAD; \ } /* Define the code templates for references for the "GUTS" in the H5T_INIT_TYPE macro */ #define H5T_INIT_TYPE_REF_COMMON(RTYPE) { \ H5T_INIT_TYPE_ALLOC_COMMON(H5T_REFERENCE) \ H5T_INIT_TYPE_NUM_COMMON(H5T_ORDER_NONE) \ dt->shared->u.atomic.u.r.rtype = RTYPE; \ } #define H5T_INIT_TYPE_OBJREF_CORE { \ H5T_INIT_TYPE_REF_COMMON(H5R_OBJECT) \ } #define H5T_INIT_TYPE_REGREF_CORE { \ H5T_INIT_TYPE_REF_COMMON(H5R_DATASET_REGION) \ } /* Define the code templates for the "SIZE_TMPL" in the H5T_INIT_TYPE macro */ #define H5T_INIT_TYPE_SET_SIZE(SIZE) { \ dt->shared->size = SIZE; \ dt->shared->u.atomic.prec = 8*SIZE; \ } #define H5T_INIT_TYPE_NOSET_SIZE(SIZE) { \ } /* Define the code templates for the "CRT_TMPL" in the H5T_INIT_TYPE macro */ #define H5T_INIT_TYPE_COPY_CREATE(BASE) { \ /* Base off of existing datatype */ \ if(NULL==(dt = H5T_copy(BASE,H5T_COPY_TRANSIENT))) \ HGOTO_ERROR (H5E_RESOURCE, H5E_CANTCOPY, FAIL, "duplicating base type failed") \ } #define H5T_INIT_TYPE_ALLOC_CREATE(BASE) { \ /* Allocate new datatype info */ \ if (NULL==(dt = H5T_alloc())) \ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") \ } #define H5T_INIT_TYPE(GUTS,GLOBAL,CRT_TMPL,BASE,SIZE_TMPL,SIZE) { \ /* Get new datatype struct */ \ H5_GLUE3(H5T_INIT_TYPE_,CRT_TMPL,_CREATE)(BASE) \ \ /* Adjust information for all types */ \ dt->shared->state = H5T_STATE_IMMUTABLE; \ H5_GLUE3(H5T_INIT_TYPE_,SIZE_TMPL,_SIZE)(SIZE) \ \ /* Adjust information for this type */ \ H5_GLUE3(H5T_INIT_TYPE_,GUTS,_CORE) \ \ /* Atomize result */ \ if ((GLOBAL = H5I_register(H5I_DATATYPE, dt)) < 0) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom") \ } /*------------------------------------------------------------------------- * Function: H5T_init * * Purpose: Initialize the interface from some other package. * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Wednesday, December 16, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_init(void) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_init, FAIL); /* FUNC_ENTER() does all the work */ done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_init_inf * * Purpose: Initialize the +/- Infinity floating-poing values for type * conversion. * * Return: Success: non-negative * * Failure: negative * * Programmer: Quincey Koziol * Saturday, November 22, 2003 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5T_init_inf(void) { H5T_t *dst_p; /* Datatype type operate on */ H5T_atomic_t *dst; /* Datatype's atomic info */ uint8_t *d; /* Pointer to value to set */ size_t half_size; /* Half the type size */ size_t u; /* Local index value */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5T_init_inf); /* Get the float datatype */ if (NULL==(dst_p=H5I_object(H5T_NATIVE_FLOAT_g))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); dst = &dst_p->shared->u.atomic; /* Check that we can re-order the bytes correctly */ if (H5T_ORDER_LE!=H5T_native_order_g && H5T_ORDER_BE!=H5T_native_order_g) HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order"); /* +Inf */ d=(uint8_t *)&H5T_NATIVE_FLOAT_POS_INF_g; H5T_bit_set (d, dst->u.f.sign, (size_t)1, FALSE); H5T_bit_set (d, dst->u.f.epos, dst->u.f.esize, TRUE); H5T_bit_set (d, dst->u.f.mpos, dst->u.f.msize, FALSE); /* Swap the bytes if the machine architecture is big-endian */ if (H5T_ORDER_BE==H5T_native_order_g) { half_size = dst_p->shared->size/2; for (u=0; ushared->size-(u+1)]; d[dst_p->shared->size-(u+1)] = d[u]; d[u] = tmp; } } /* -Inf */ d=(uint8_t *)&H5T_NATIVE_FLOAT_NEG_INF_g; H5T_bit_set (d, dst->u.f.sign, (size_t)1, TRUE); H5T_bit_set (d, dst->u.f.epos, dst->u.f.esize, TRUE); H5T_bit_set (d, dst->u.f.mpos, dst->u.f.msize, FALSE); /* Swap the bytes if the machine architecture is big-endian */ if (H5T_ORDER_BE==H5T_native_order_g) { half_size = dst_p->shared->size/2; for (u=0; ushared->size-(u+1)]; d[dst_p->shared->size-(u+1)] = d[u]; d[u] = tmp; } } /* Get the double datatype */ if (NULL==(dst_p=H5I_object(H5T_NATIVE_DOUBLE_g))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); dst = &dst_p->shared->u.atomic; /* Check that we can re-order the bytes correctly */ if (H5T_ORDER_LE!=H5T_native_order_g && H5T_ORDER_BE!=H5T_native_order_g) HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order"); /* +Inf */ d=(uint8_t *)&H5T_NATIVE_DOUBLE_POS_INF_g; H5T_bit_set (d, dst->u.f.sign, (size_t)1, FALSE); H5T_bit_set (d, dst->u.f.epos, dst->u.f.esize, TRUE); H5T_bit_set (d, dst->u.f.mpos, dst->u.f.msize, FALSE); /* Swap the bytes if the machine architecture is big-endian */ if (H5T_ORDER_BE==H5T_native_order_g) { half_size = dst_p->shared->size/2; for (u=0; ushared->size-(u+1)]; d[dst_p->shared->size-(u+1)] = d[u]; d[u] = tmp; } } /* -Inf */ d=(uint8_t *)&H5T_NATIVE_DOUBLE_NEG_INF_g; H5T_bit_set (d, dst->u.f.sign, (size_t)1, TRUE); H5T_bit_set (d, dst->u.f.epos, dst->u.f.esize, TRUE); H5T_bit_set (d, dst->u.f.mpos, dst->u.f.msize, FALSE); /* Swap the bytes if the machine architecture is big-endian */ if (H5T_ORDER_BE==H5T_native_order_g) { half_size = dst_p->shared->size/2; for (u=0; ushared->size-(u+1)]; d[dst_p->shared->size-(u+1)] = d[u]; d[u] = tmp; } } done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_init_hw * * Purpose: Perform hardware specific [floating-point] initialization * * Return: Success: non-negative * * Failure: negative * * Programmer: Quincey Koziol * Monday, November 24, 2003 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5T_init_hw(void) { #ifdef H5_HAVE_GET_FPC_CSR union fpc_csr csr; /* Union to hold results of floating-point status register query */ #endif /* H5_HAVE_GET_FPC_CSR */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_init_hw); #ifdef H5_HAVE_GET_FPC_CSR /* [This code is specific to SGI machines] */ /* Get the floating-point status register */ csr.fc_word=get_fpc_csr(); /* If the "flush denormalized values to zero" flag is set, unset it */ if(csr.fc_struct.flush) { csr.fc_struct.flush=0; set_fpc_csr(csr.fc_word); } /* end if */ #endif /* H5_HAVE_GET_FPC_CSR */ FUNC_LEAVE_NOAPI(ret_value); } /*-------------------------------------------------------------------------- NAME H5T_init_interface -- Initialize interface-specific information USAGE herr_t H5T_init_interface() RETURNS Non-negative on success/Negative on failure DESCRIPTION Initializes any interface-specific data or routines. --------------------------------------------------------------------------*/ herr_t H5T_init_interface(void) { H5T_t *native_schar=NULL; /* Datatype structure for native signed char */ H5T_t *native_uchar=NULL; /* Datatype structure for native unsigned char */ H5T_t *native_short=NULL; /* Datatype structure for native short */ H5T_t *native_ushort=NULL; /* Datatype structure for native unsigned short */ H5T_t *native_int=NULL; /* Datatype structure for native int */ H5T_t *native_uint=NULL; /* Datatype structure for native unsigned int */ H5T_t *native_long=NULL; /* Datatype structure for native long */ H5T_t *native_ulong=NULL; /* Datatype structure for native unsigned long */ H5T_t *native_llong=NULL; /* Datatype structure for native llong */ H5T_t *native_ullong=NULL; /* Datatype structure for native unsigned llong */ H5T_t *native_float=NULL; /* Datatype structure for native float */ H5T_t *native_double=NULL; /* Datatype structure for native double */ H5T_t *std_u8le=NULL; /* Datatype structure for unsigned 8-bit little-endian integer */ H5T_t *std_u8be=NULL; /* Datatype structure for unsigned 8-bit big-endian integer */ H5T_t *std_u16le=NULL; /* Datatype structure for unsigned 16-bit little-endian integer */ H5T_t *std_u16be=NULL; /* Datatype structure for unsigned 16-bit big-endian integer */ H5T_t *std_u32le=NULL; /* Datatype structure for unsigned 32-bit little-endian integer */ H5T_t *std_u32be=NULL; /* Datatype structure for unsigned 32-bit big-endian integer */ H5T_t *std_i32le=NULL; /* Datatype structure for signed 32-bit little-endian integer */ H5T_t *std_u64le=NULL; /* Datatype structure for unsigned 64-bit little-endian integer */ H5T_t *std_u64be=NULL; /* Datatype structure for unsigned 64-bit big-endian integer */ H5T_t *ieee_f64le=NULL; /* Datatype structure for IEEE 64-bit little-endian floating-point */ H5T_t *dt = NULL; H5T_t *fixedpt=NULL; /* Datatype structure for native int */ H5T_t *floatpt=NULL; /* Datatype structure for native float */ H5T_t *string=NULL; /* Datatype structure for C string */ H5T_t *bitfield=NULL; /* Datatype structure for bitfield */ H5T_t *compound=NULL; /* Datatype structure for compound objects */ H5T_t *enum_type=NULL; /* Datatype structure for enum objects */ H5T_t *vlen=NULL; /* Datatype structure for vlen objects */ H5T_t *array=NULL; /* Datatype structure for array objects */ hsize_t dim[1]={1}; /* Dimension info for array datatype */ herr_t status; unsigned copied_dtype=1; /* Flag to indicate whether datatype was copied or allocated (for error cleanup) */ herr_t ret_value=SUCCEED; FUNC_ENTER_NOAPI_NOINIT(H5T_init_interface); /* Initialize the atom group for the file IDs */ if (H5I_init_group(H5I_DATATYPE, (size_t)H5I_DATATYPEID_HASHSIZE, H5T_RESERVED_ATOMS, (H5I_free_t)H5T_close)<0) HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize interface"); /* Make certain there aren't too many classes of datatypes defined */ /* Only 16 (numbered 0-15) are supported in the current file format */ assert(H5T_NCLASSES<16); /* Perform any necessary hardware initializations */ if(H5T_init_hw()<0) HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize interface"); /* * Initialize pre-defined native data types from code generated during * the library configuration by H5detect. */ if (H5TN_init_interface()<0) HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize interface"); /* Get the atomic datatype structures needed by the initialization code below */ if (NULL==(native_schar=H5I_object(H5T_NATIVE_SCHAR_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object"); if (NULL==(native_uchar=H5I_object(H5T_NATIVE_UCHAR_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object"); if (NULL==(native_short=H5I_object(H5T_NATIVE_SHORT_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object"); if (NULL==(native_ushort=H5I_object(H5T_NATIVE_USHORT_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object"); if (NULL==(native_int=H5I_object(H5T_NATIVE_INT_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object"); if (NULL==(native_uint=H5I_object(H5T_NATIVE_UINT_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object"); if (NULL==(native_long=H5I_object(H5T_NATIVE_LONG_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object"); if (NULL==(native_ulong=H5I_object(H5T_NATIVE_ULONG_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object"); if (NULL==(native_llong=H5I_object(H5T_NATIVE_LLONG_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object"); if (NULL==(native_ullong=H5I_object(H5T_NATIVE_ULLONG_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object"); if (NULL==(native_float=H5I_object(H5T_NATIVE_FLOAT_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object"); if (NULL==(native_double=H5I_object(H5T_NATIVE_DOUBLE_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object"); /*------------------------------------------------------------ * Native types *------------------------------------------------------------ */ /* 1-byte bit field */ H5T_INIT_TYPE(BITFIELD,H5T_NATIVE_B8_g,COPY,native_uint,SET,1) /* 2-byte bit field */ H5T_INIT_TYPE(BITFIELD,H5T_NATIVE_B16_g,COPY,native_uint,SET,2) /* 4-byte bit field */ H5T_INIT_TYPE(BITFIELD,H5T_NATIVE_B32_g,COPY,native_uint,SET,4) /* 8-byte bit field */ H5T_INIT_TYPE(BITFIELD,H5T_NATIVE_B64_g,COPY,native_uint,SET,8) /* haddr_t */ H5T_INIT_TYPE(OFFSET,H5T_NATIVE_HADDR_g,COPY,native_uint,SET,sizeof(haddr_t)) /* hsize_t */ H5T_INIT_TYPE(OFFSET,H5T_NATIVE_HSIZE_g,COPY,native_uint,SET,sizeof(hsize_t)) /* hssize_t */ H5T_INIT_TYPE(OFFSET,H5T_NATIVE_HSSIZE_g,COPY,native_int,SET,sizeof(hssize_t)) /* herr_t */ H5T_INIT_TYPE(OFFSET,H5T_NATIVE_HERR_g,COPY,native_int,SET,sizeof(herr_t)) /* hbool_t */ H5T_INIT_TYPE(OFFSET,H5T_NATIVE_HBOOL_g,COPY,native_int,SET,sizeof(hbool_t)) /*------------------------------------------------------------ * IEEE Types *------------------------------------------------------------ */ /* IEEE 4-byte little-endian float */ H5T_INIT_TYPE(FLOATLE,H5T_IEEE_F32LE_g,COPY,native_double,SET,4) /* IEEE 4-byte big-endian float */ H5T_INIT_TYPE(FLOATBE,H5T_IEEE_F32BE_g,COPY,native_double,SET,4) /* IEEE 8-byte little-endian float */ H5T_INIT_TYPE(DOUBLELE,H5T_IEEE_F64LE_g,COPY,native_double,SET,8) ieee_f64le=dt; /* Keep type for later */ /* IEEE 8-byte big-endian float */ H5T_INIT_TYPE(DOUBLEBE,H5T_IEEE_F64BE_g,COPY,native_double,SET,8) /*------------------------------------------------------------ * Other "standard" types *------------------------------------------------------------ */ /* 1-byte little-endian (endianness is irrelevant) signed integer */ H5T_INIT_TYPE(SINTLE,H5T_STD_I8LE_g,COPY,native_int,SET,1) /* 1-byte big-endian (endianness is irrelevant) signed integer */ H5T_INIT_TYPE(SINTBE,H5T_STD_I8BE_g,COPY,native_int,SET,1) /* 2-byte little-endian signed integer */ H5T_INIT_TYPE(SINTLE,H5T_STD_I16LE_g,COPY,native_int,SET,2) /* 2-byte big-endian signed integer */ H5T_INIT_TYPE(SINTBE,H5T_STD_I16BE_g,COPY,native_int,SET,2) /* 4-byte little-endian signed integer */ H5T_INIT_TYPE(SINTLE,H5T_STD_I32LE_g,COPY,native_int,SET,4) std_i32le=dt; /* Keep type for later */ /* 4-byte big-endian signed integer */ H5T_INIT_TYPE(SINTBE,H5T_STD_I32BE_g,COPY,native_int,SET,4) /* 8-byte little-endian signed integer */ H5T_INIT_TYPE(SINTLE,H5T_STD_I64LE_g,COPY,native_int,SET,8) /* 8-byte big-endian signed integer */ H5T_INIT_TYPE(SINTBE,H5T_STD_I64BE_g,COPY,native_int,SET,8) /* 1-byte little-endian (endianness is irrelevant) unsigned integer */ H5T_INIT_TYPE(UINTLE,H5T_STD_U8LE_g,COPY,native_uint,SET,1) std_u8le=dt; /* Keep type for later */ /* 1-byte big-endian (endianness is irrelevant) unsigned integer */ H5T_INIT_TYPE(UINTBE,H5T_STD_U8BE_g,COPY,native_uint,SET,1) std_u8be=dt; /* Keep type for later */ /* 2-byte little-endian unsigned integer */ H5T_INIT_TYPE(UINTLE,H5T_STD_U16LE_g,COPY,native_uint,SET,2) std_u16le=dt; /* Keep type for later */ /* 2-byte big-endian unsigned integer */ H5T_INIT_TYPE(UINTBE,H5T_STD_U16BE_g,COPY,native_uint,SET,2) std_u16be=dt; /* Keep type for later */ /* 4-byte little-endian unsigned integer */ H5T_INIT_TYPE(UINTLE,H5T_STD_U32LE_g,COPY,native_uint,SET,4) std_u32le=dt; /* Keep type for later */ /* 4-byte big-endian unsigned integer */ H5T_INIT_TYPE(UINTBE,H5T_STD_U32BE_g,COPY,native_uint,SET,4) std_u32be=dt; /* Keep type for later */ /* 8-byte little-endian unsigned integer */ H5T_INIT_TYPE(UINTLE,H5T_STD_U64LE_g,COPY,native_uint,SET,8) std_u64le=dt; /* Keep type for later */ /* 8-byte big-endian unsigned integer */ H5T_INIT_TYPE(UINTBE,H5T_STD_U64BE_g,COPY,native_uint,SET,8) std_u64be=dt; /* Keep type for later */ /*------------------------------------------------------------ * Little- & Big-endian bitfields *------------------------------------------------------------ */ /* little-endian (order is irrelevant) 8-bit bitfield */ H5T_INIT_TYPE(BITFIELD,H5T_STD_B8LE_g,COPY,std_u8le,NOSET,-) bitfield=dt; /* Keep type for later */ /* big-endian (order is irrelevant) 8-bit bitfield */ H5T_INIT_TYPE(BITFIELD,H5T_STD_B8BE_g,COPY,std_u8be,NOSET,-) /* Little-endian 16-bit bitfield */ H5T_INIT_TYPE(BITFIELD,H5T_STD_B16LE_g,COPY,std_u16le,NOSET,-) /* Big-endian 16-bit bitfield */ H5T_INIT_TYPE(BITFIELD,H5T_STD_B16BE_g,COPY,std_u16be,NOSET,-) /* Little-endian 32-bit bitfield */ H5T_INIT_TYPE(BITFIELD,H5T_STD_B32LE_g,COPY,std_u32le,NOSET,-) /* Big-endian 32-bit bitfield */ H5T_INIT_TYPE(BITFIELD,H5T_STD_B32BE_g,COPY,std_u32be,NOSET,-) /* Little-endian 64-bit bitfield */ H5T_INIT_TYPE(BITFIELD,H5T_STD_B64LE_g,COPY,std_u64le,NOSET,-) /* Big-endian 64-bit bitfield */ H5T_INIT_TYPE(BITFIELD,H5T_STD_B64BE_g,COPY,std_u64be,NOSET,-) /*------------------------------------------------------------ * The Unix architecture for dates and times. *------------------------------------------------------------ */ /* Little-endian 32-bit UNIX time_t */ H5T_INIT_TYPE(TIME,H5T_UNIX_D32LE_g,COPY,std_u32le,NOSET,-) /* Big-endian 32-bit UNIX time_t */ H5T_INIT_TYPE(TIME,H5T_UNIX_D32BE_g,COPY,std_u32be,NOSET,-) /* Little-endian 64-bit UNIX time_t */ H5T_INIT_TYPE(TIME,H5T_UNIX_D64LE_g,COPY,std_u64le,NOSET,-) /* Big-endian 64-bit UNIX time_t */ H5T_INIT_TYPE(TIME,H5T_UNIX_D64BE_g,COPY,std_u64be,NOSET,-) /* Indicate that the types that are created from here down are allocated * H5FL_ALLOC(), not copied with H5T_copy() */ copied_dtype=0; /* Opaque data */ H5T_INIT_TYPE(OPAQ,H5T_NATIVE_OPAQUE_g,ALLOC,-,SET,1) /*------------------------------------------------------------ * The `C' architecture *------------------------------------------------------------ */ /* One-byte character string */ H5T_INIT_TYPE(CSTRING,H5T_C_S1_g,ALLOC,-,SET,1) string=dt; /* Keep type for later */ /*------------------------------------------------------------ * The `Fortran' architecture *------------------------------------------------------------ */ /* One-byte character string */ H5T_INIT_TYPE(FORSTRING,H5T_FORTRAN_S1_g,ALLOC,-,SET,1) /*------------------------------------------------------------ * Pointer types *------------------------------------------------------------ */ /* Object pointer (i.e. object header address in file) */ H5T_INIT_TYPE(OBJREF,H5T_STD_REF_OBJ_g,ALLOC,-,SET,H5R_OBJ_REF_BUF_SIZE) /* Dataset Region pointer (i.e. selection inside a dataset) */ H5T_INIT_TYPE(REGREF,H5T_STD_REF_DSETREG_g,ALLOC,-,SET,H5R_DSET_REG_REF_BUF_SIZE) /* * Register conversion functions beginning with the most general and * ending with the most specific. */ fixedpt = native_int; floatpt = native_float; if (NULL == (compound = H5T_create(H5T_COMPOUND, (size_t)1))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); if (NULL == (enum_type = H5T_create(H5T_ENUM, (size_t)1))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); if (NULL == (vlen = H5T_vlen_create(native_int))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); if (NULL == (array = H5T_array_create(native_int,1,dim,NULL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); status = 0; status |= H5T_register(H5T_PERS_SOFT, "i_i", fixedpt, fixedpt, H5T_conv_i_i, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_SOFT, "f_f", floatpt, floatpt, H5T_conv_f_f, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_SOFT, "s_s", string, string, H5T_conv_s_s, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_SOFT, "b_b", bitfield, bitfield, H5T_conv_b_b, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_SOFT, "ibo", fixedpt, fixedpt, H5T_conv_order, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_SOFT, "ibo(opt)", fixedpt, fixedpt, H5T_conv_order_opt, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_SOFT, "fbo", floatpt, floatpt, H5T_conv_order, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_SOFT, "fbo(opt)", floatpt, floatpt, H5T_conv_order_opt, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_SOFT, "struct(no-opt)", compound, compound, H5T_conv_struct, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_SOFT, "struct(opt)", compound, compound, H5T_conv_struct_opt, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_SOFT, "enum", enum_type, enum_type, H5T_conv_enum, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_SOFT, "vlen", vlen, vlen, H5T_conv_vlen, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_SOFT, "array", array, array, H5T_conv_array, H5AC_dxpl_id); /* Custom conversion for 32-bit ints to 64-bit floats (undocumented) */ status |= H5T_register(H5T_PERS_HARD, "u32le_f64le", std_u32le, ieee_f64le, H5T_conv_i32le_f64le, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "i32le_f64le", std_i32le, ieee_f64le, H5T_conv_i32le_f64le, H5AC_dxpl_id); /* * Native conversions should be listed last since we can use hardware to * perform the conversion. We list the odd types like `llong', `long', * and `short' before the usual types like `int' and `char' so that when * diagnostics are printed we favor the usual names over the odd names * when two or more types are the same size. */ /* floating point */ status |= H5T_register(H5T_PERS_HARD, "flt_dbl", native_float, native_double, H5T_conv_float_double, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "dbl_flt", native_double, native_float, H5T_conv_double_float, H5AC_dxpl_id); /* from long_long */ status |= H5T_register(H5T_PERS_HARD, "llong_ullong", native_llong, native_ullong, H5T_conv_llong_ullong, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "ullong_llong", native_ullong, native_llong, H5T_conv_ullong_llong, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "llong_long", native_llong, native_long, H5T_conv_llong_long, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "llong_ulong", native_llong, native_ulong, H5T_conv_llong_ulong, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "ullong_long", native_ullong, native_long, H5T_conv_ullong_long, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "ullong_ulong", native_ullong, native_ulong, H5T_conv_ullong_ulong, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "llong_short", native_llong, native_short, H5T_conv_llong_short, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "llong_ushort", native_llong, native_ushort, H5T_conv_llong_ushort, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "ullong_short", native_ullong, native_short, H5T_conv_ullong_short, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "ullong_ushort", native_ullong, native_ushort, H5T_conv_ullong_ushort, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "llong_int", native_llong, native_int, H5T_conv_llong_int, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "llong_uint", native_llong, native_uint, H5T_conv_llong_uint, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "ullong_int", native_ullong, native_int, H5T_conv_ullong_int, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "ullong_uint", native_ullong, native_uint, H5T_conv_ullong_uint, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "llong_schar", native_llong, native_schar, H5T_conv_llong_schar, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "llong_uchar", native_llong, native_uchar, H5T_conv_llong_uchar, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "ullong_schar", native_ullong, native_schar, H5T_conv_ullong_schar, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "ullong_uchar", native_ullong, native_uchar, H5T_conv_ullong_uchar, H5AC_dxpl_id); /* From long */ status |= H5T_register(H5T_PERS_HARD, "long_llong", native_long, native_llong, H5T_conv_long_llong, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "long_ullong", native_long, native_ullong, H5T_conv_long_ullong, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "ulong_llong", native_ulong, native_llong, H5T_conv_ulong_llong, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "ulong_ullong", native_ulong, native_ullong, H5T_conv_ulong_ullong, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "long_ulong", native_long, native_ulong, H5T_conv_long_ulong, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "ulong_long", native_ulong, native_long, H5T_conv_ulong_long, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "long_short", native_long, native_short, H5T_conv_long_short, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "long_ushort", native_long, native_ushort, H5T_conv_long_ushort, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "ulong_short", native_ulong, native_short, H5T_conv_ulong_short, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "ulong_ushort", native_ulong, native_ushort, H5T_conv_ulong_ushort, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "long_int", native_long, native_int, H5T_conv_long_int, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "long_uint", native_long, native_uint, H5T_conv_long_uint, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "ulong_int", native_ulong, native_int, H5T_conv_ulong_int, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "ulong_uint", native_ulong, native_uint, H5T_conv_ulong_uint, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "long_schar", native_long, native_schar, H5T_conv_long_schar, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "long_uchar", native_long, native_uchar, H5T_conv_long_uchar, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "ulong_schar", native_ulong, native_schar, H5T_conv_ulong_schar, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "ulong_uchar", native_ulong, native_uchar, H5T_conv_ulong_uchar, H5AC_dxpl_id); /* From short */ status |= H5T_register(H5T_PERS_HARD, "short_llong", native_short, native_llong, H5T_conv_short_llong, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "short_ullong", native_short, native_ullong, H5T_conv_short_ullong, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "ushort_llong", native_ushort, native_llong, H5T_conv_ushort_llong, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "ushort_ullong", native_ushort, native_ullong, H5T_conv_ushort_ullong, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "short_long", native_short, native_long, H5T_conv_short_long, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "short_ulong", native_short, native_ulong, H5T_conv_short_ulong, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "ushort_long", native_ushort, native_long, H5T_conv_ushort_long, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "ushort_ulong", native_ushort, native_ulong, H5T_conv_ushort_ulong, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "short_ushort", native_short, native_ushort, H5T_conv_short_ushort, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "ushort_short", native_ushort, native_short, H5T_conv_ushort_short, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "short_int", native_short, native_int, H5T_conv_short_int, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "short_uint", native_short, native_uint, H5T_conv_short_uint, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "ushort_int", native_ushort, native_int, H5T_conv_ushort_int, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "ushort_uint", native_ushort, native_uint, H5T_conv_ushort_uint, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "short_schar", native_short, native_schar, H5T_conv_short_schar, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "short_uchar", native_short, native_uchar, H5T_conv_short_uchar, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "ushort_schar", native_ushort, native_schar, H5T_conv_ushort_schar, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "ushort_uchar", native_ushort, native_uchar, H5T_conv_ushort_uchar, H5AC_dxpl_id); /* From int */ status |= H5T_register(H5T_PERS_HARD, "int_llong", native_int, native_llong, H5T_conv_int_llong, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "int_ullong", native_int, native_ullong, H5T_conv_int_ullong, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "uint_llong", native_uint, native_llong, H5T_conv_uint_llong, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "uint_ullong", native_uint, native_ullong, H5T_conv_uint_ullong, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "int_long", native_int, native_long, H5T_conv_int_long, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "int_ulong", native_int, native_ulong, H5T_conv_int_ulong, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "uint_long", native_uint, native_long, H5T_conv_uint_long, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "uint_ulong", native_uint, native_ulong, H5T_conv_uint_ulong, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "int_short", native_int, native_short, H5T_conv_int_short, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "int_ushort", native_int, native_ushort, H5T_conv_int_ushort, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "uint_short", native_uint, native_short, H5T_conv_uint_short, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "uint_ushort", native_uint, native_ushort, H5T_conv_uint_ushort, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "int_uint", native_int, native_uint, H5T_conv_int_uint, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "uint_int", native_uint, native_int, H5T_conv_uint_int, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "int_schar", native_int, native_schar, H5T_conv_int_schar, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "int_uchar", native_int, native_uchar, H5T_conv_int_uchar, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "uint_schar", native_uint, native_schar, H5T_conv_uint_schar, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "uint_uchar", native_uint, native_uchar, H5T_conv_uint_uchar, H5AC_dxpl_id); /* From char */ status |= H5T_register(H5T_PERS_HARD, "schar_llong", native_schar, native_llong, H5T_conv_schar_llong, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "schar_ullong", native_schar, native_ullong, H5T_conv_schar_ullong, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "uchar_llong", native_uchar, native_llong, H5T_conv_uchar_llong, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "uchar_ullong", native_uchar, native_ullong, H5T_conv_uchar_ullong, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "schar_long", native_schar, native_long, H5T_conv_schar_long, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "schar_ulong", native_schar, native_ulong, H5T_conv_schar_ulong, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "uchar_long", native_uchar, native_long, H5T_conv_uchar_long, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "uchar_ulong", native_uchar, native_ulong, H5T_conv_uchar_ulong, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "schar_short", native_schar, native_short, H5T_conv_schar_short, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "schar_ushort", native_schar, native_ushort, H5T_conv_schar_ushort, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "uchar_short", native_uchar, native_short, H5T_conv_uchar_short, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "uchar_ushort", native_uchar, native_ushort, H5T_conv_uchar_ushort, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "schar_int", native_schar, native_int, H5T_conv_schar_int, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "schar_uint", native_schar, native_uint, H5T_conv_schar_uint, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "uchar_int", native_uchar, native_int, H5T_conv_uchar_int, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "uchar_uint", native_uchar, native_uint, H5T_conv_uchar_uint, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "schar_uchar", native_schar, native_uchar, H5T_conv_schar_uchar, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "uchar_schar", native_uchar, native_schar, H5T_conv_uchar_schar, H5AC_dxpl_id); /* * The special no-op conversion is the fastest, so we list it last. The * data types we use are not important as long as the source and * destination are equal. */ status |= H5T_register(H5T_PERS_HARD, "no-op", native_int, native_int, H5T_conv_noop, H5AC_dxpl_id); /* Initialize the +/- Infinity values for floating-point types */ status |= H5T_init_inf(); if (status<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to register conversion function(s)"); done: /* General cleanup */ if (compound!=NULL) H5T_close(compound); if (enum_type!=NULL) H5T_close(enum_type); if (vlen!=NULL) H5T_close(vlen); if (array!=NULL) H5T_close(array); /* Error cleanup */ if(ret_value<0) { if(dt!=NULL) { /* Check if we should call H5T_close or H5FL_FREE */ if(copied_dtype) H5T_close(dt); else { H5FL_FREE(H5T_shared_t, dt->shared); H5FL_FREE(H5T_t,dt); } } /* end if */ } /* end if */ FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_unlock_cb * * Purpose: Clear the immutable flag for a data type. This function is * called when the library is closing in order to unlock all * registered data types and thus make them free-able. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Monday, April 27, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static int H5T_unlock_cb (void *_dt, hid_t UNUSED id, void UNUSED *key) { H5T_t *dt = (H5T_t *)_dt; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_unlock_cb); assert (dt); if (H5T_STATE_IMMUTABLE==dt->shared->state) dt->shared->state = H5T_STATE_RDONLY; FUNC_LEAVE_NOAPI(SUCCEED); } /*------------------------------------------------------------------------- * Function: H5T_term_interface * * Purpose: Close this interface. * * Return: Success: Positive if any action might have caused a * change in some other interface; zero * otherwise. * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 20, 1998 * * Modifications: * Robb Matzke, 1998-06-11 * Statistics are only printed for conversion functions that were * called. *------------------------------------------------------------------------- */ int H5T_term_interface(void) { int i, nprint=0, n=0; H5T_path_t *path = NULL; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_term_interface); if (H5_interface_initialize_g) { /* Unregister all conversion functions */ for (i=0; ifunc) { H5T_print_stats(path, &nprint/*in,out*/); path->cdata.command = H5T_CONV_FREE; if ((path->func)(FAIL, FAIL, &(path->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL,H5AC_dxpl_id)<0) { #ifdef H5T_DEBUG if (H5DEBUG(T)) { fprintf (H5DEBUG(T), "H5T: conversion function " "0x%08lx failed to free private data for " "%s (ignored)\n", (unsigned long)(path->func), path->name); } #endif H5E_clear(); /*ignore the error*/ } } if(path->src) H5T_close (path->src); if(path->dst) H5T_close (path->dst); H5FL_FREE(H5T_path_t,path); H5T_g.path[i] = NULL; } /* Clear conversion tables */ H5T_g.path = H5MM_xfree(H5T_g.path); H5T_g.npaths = H5T_g.apaths = 0; H5T_g.soft = H5MM_xfree(H5T_g.soft); H5T_g.nsoft = H5T_g.asoft = 0; /* Unlock all datatypes, then free them */ H5I_search (H5I_DATATYPE, H5T_unlock_cb, NULL); H5I_destroy_group(H5I_DATATYPE); /* Reset all the datatype IDs */ H5T_IEEE_F32BE_g = FAIL; H5T_IEEE_F32LE_g = FAIL; H5T_IEEE_F64BE_g = FAIL; H5T_IEEE_F64LE_g = FAIL; H5T_STD_I8BE_g = FAIL; H5T_STD_I8LE_g = FAIL; H5T_STD_I16BE_g = FAIL; H5T_STD_I16LE_g = FAIL; H5T_STD_I32BE_g = FAIL; H5T_STD_I32LE_g = FAIL; H5T_STD_I64BE_g = FAIL; H5T_STD_I64LE_g = FAIL; H5T_STD_U8BE_g = FAIL; H5T_STD_U8LE_g = FAIL; H5T_STD_U16BE_g = FAIL; H5T_STD_U16LE_g = FAIL; H5T_STD_U32BE_g = FAIL; H5T_STD_U32LE_g = FAIL; H5T_STD_U64BE_g = FAIL; H5T_STD_U64LE_g = FAIL; H5T_STD_B8BE_g = FAIL; H5T_STD_B8LE_g = FAIL; H5T_STD_B16BE_g = FAIL; H5T_STD_B16LE_g = FAIL; H5T_STD_B32BE_g = FAIL; H5T_STD_B32LE_g = FAIL; H5T_STD_B64BE_g = FAIL; H5T_STD_B64LE_g = FAIL; H5T_STD_REF_OBJ_g = FAIL; H5T_STD_REF_DSETREG_g = FAIL; H5T_UNIX_D32BE_g = FAIL; H5T_UNIX_D32LE_g = FAIL; H5T_UNIX_D64BE_g = FAIL; H5T_UNIX_D64LE_g = FAIL; H5T_C_S1_g = FAIL; H5T_FORTRAN_S1_g = FAIL; H5T_NATIVE_SCHAR_g = FAIL; H5T_NATIVE_UCHAR_g = FAIL; H5T_NATIVE_SHORT_g = FAIL; H5T_NATIVE_USHORT_g = FAIL; H5T_NATIVE_INT_g = FAIL; H5T_NATIVE_UINT_g = FAIL; H5T_NATIVE_LONG_g = FAIL; H5T_NATIVE_ULONG_g = FAIL; H5T_NATIVE_LLONG_g = FAIL; H5T_NATIVE_ULLONG_g = FAIL; H5T_NATIVE_FLOAT_g = FAIL; H5T_NATIVE_DOUBLE_g = FAIL; H5T_NATIVE_LDOUBLE_g = FAIL; H5T_NATIVE_B8_g = FAIL; H5T_NATIVE_B16_g = FAIL; H5T_NATIVE_B32_g = FAIL; H5T_NATIVE_B64_g = FAIL; H5T_NATIVE_OPAQUE_g = FAIL; H5T_NATIVE_HADDR_g = FAIL; H5T_NATIVE_HSIZE_g = FAIL; H5T_NATIVE_HSSIZE_g = FAIL; H5T_NATIVE_HERR_g = FAIL; H5T_NATIVE_HBOOL_g = FAIL; H5T_NATIVE_INT8_g = FAIL; H5T_NATIVE_UINT8_g = FAIL; H5T_NATIVE_INT_LEAST8_g = FAIL; H5T_NATIVE_UINT_LEAST8_g = FAIL; H5T_NATIVE_INT_FAST8_g = FAIL; H5T_NATIVE_UINT_FAST8_g = FAIL; H5T_NATIVE_INT16_g = FAIL; H5T_NATIVE_UINT16_g = FAIL; H5T_NATIVE_INT_LEAST16_g = FAIL; H5T_NATIVE_UINT_LEAST16_g = FAIL; H5T_NATIVE_INT_FAST16_g = FAIL; H5T_NATIVE_UINT_FAST16_g = FAIL; H5T_NATIVE_INT32_g = FAIL; H5T_NATIVE_UINT32_g = FAIL; H5T_NATIVE_INT_LEAST32_g = FAIL; H5T_NATIVE_UINT_LEAST32_g = FAIL; H5T_NATIVE_INT_FAST32_g = FAIL; H5T_NATIVE_UINT_FAST32_g = FAIL; H5T_NATIVE_INT64_g = FAIL; H5T_NATIVE_UINT64_g = FAIL; H5T_NATIVE_INT_LEAST64_g = FAIL; H5T_NATIVE_UINT_LEAST64_g = FAIL; H5T_NATIVE_INT_FAST64_g = FAIL; H5T_NATIVE_UINT_FAST64_g = FAIL; /* Mark interface as closed */ H5_interface_initialize_g = 0; n = 1; /*H5I*/ } FUNC_LEAVE_NOAPI(n); } /*------------------------------------------------------------------------- * Function: H5Tcreate * * Purpose: Create a new type and initialize it to reasonable values. * The type is a member of type class TYPE and is SIZE bytes. * * Return: Success: A new type identifier. * * Failure: Negative * * Errors: * ARGS BADVALUE Invalid size. * DATATYPE CANTINIT Can't create type. * DATATYPE CANTREGISTER Can't register data type atom. * * Programmer: Robb Matzke * Friday, December 5, 1997 * * Modifications: * *------------------------------------------------------------------------- */ hid_t H5Tcreate(H5T_class_t type, size_t size) { H5T_t *dt = NULL; hid_t ret_value; FUNC_ENTER_API(H5Tcreate, FAIL); H5TRACE2("i","Ttz",type,size); /* check args */ if (size == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid size"); /* create the type */ if (NULL == (dt = H5T_create(type, size))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to create type"); /* Make it an atom */ if ((ret_value = H5I_register(H5I_DATATYPE, dt)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register data type atom"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Topen * * Purpose: Opens a named data type. * * Return: Success: Object ID of the named data type. * * Failure: Negative * * Programmer: Robb Matzke * Monday, June 1, 1998 * * Modifications: * *------------------------------------------------------------------------- */ hid_t H5Topen(hid_t loc_id, const char *name) { H5T_t *type = NULL; H5G_entry_t *loc = NULL; H5G_entry_t ent; hbool_t ent_found = FALSE; /* Entry at 'name' found */ hid_t dxpl_id = H5AC_dxpl_id; /* dxpl to use to open datatype */ hid_t ret_value =FAIL; FUNC_ENTER_API(H5Topen, FAIL); H5TRACE2("i","is",loc_id,name); /* Check args */ if (NULL==(loc=H5G_loc (loc_id))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location"); if (!name || !*name) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no name"); /* * Find the named data type object header and read the data type message * from it. */ if (H5G_find (loc, name, &ent/*out*/, dxpl_id)<0) HGOTO_ERROR (H5E_DATATYPE, H5E_NOTFOUND, FAIL, "not found"); ent_found = TRUE; /* Check that the object found is the correct type */ if (H5G_get_type(&ent, dxpl_id) != H5G_TYPE) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a named datatype") /* Open it */ if ((type=H5T_open (&ent, dxpl_id)) ==NULL) HGOTO_ERROR (H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to open named data type"); /* Register the type and return the ID */ if ((ret_value=H5I_register (H5I_DATATYPE, type))<0) HGOTO_ERROR (H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register named data type"); done: if(ret_value<0) { if(type!=NULL) H5T_close(type); else { if(ent_found && ent.header) H5G_free_ent_name(&ent); } /* end else */ } /* end if */ FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Tcopy * * Purpose: Copies a data type. The resulting data type is not locked. * The data type should be closed when no longer needed by * calling H5Tclose(). * * Return: Success: The ID of a new data type. * * Failure: Negative * * Programmer: Robb Matzke * Tuesday, December 9, 1997 * * Modifications: * * Robb Matzke, 4 Jun 1998 * The returned type is always transient and unlocked. If the TYPE_ID * argument is a dataset instead of a data type then this function * returns a transient, modifiable data type which is a copy of the * dataset's data type. * *------------------------------------------------------------------------- */ hid_t H5Tcopy(hid_t type_id) { H5T_t *dt = NULL; H5T_t *new_dt = NULL; H5D_t *dset = NULL; hid_t ret_value; FUNC_ENTER_API(H5Tcopy, FAIL); H5TRACE1("i","i",type_id); switch (H5I_get_type (type_id)) { case H5I_DATATYPE: /* The argument is a data type handle */ if (NULL==(dt=H5I_object (type_id))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); break; case H5I_DATASET: /* The argument is a dataset handle */ if (NULL==(dset=H5I_object (type_id))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset"); if (NULL==(dt=H5D_typeof (dset))) HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get the dataset data type"); break; default: HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type or dataset"); } /* end switch */ /* Copy */ if (NULL == (new_dt = H5T_copy(dt, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy"); /* Atomize result */ if ((ret_value = H5I_register(H5I_DATATYPE, new_dt)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register data type atom"); done: if(ret_value<0) { if(new_dt!=NULL) H5T_close(new_dt); } /* end if */ FUNC_LEAVE_API(ret_value); } /* end H5Tcopy() */ /*------------------------------------------------------------------------- * Function: H5Tclose * * Purpose: Frees a data type and all associated memory. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Tuesday, December 9, 1997 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Tclose(hid_t type_id) { H5T_t *dt = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Tclose, FAIL); H5TRACE1("e","i",type_id); /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); if (H5T_STATE_IMMUTABLE==dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "immutable data type"); /* When the reference count reaches zero the resources are freed */ if (H5I_dec_ref(type_id) < 0) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "problem freeing id"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Tequal * * Purpose: Determines if two data types are equal. * * Return: Success: TRUE if equal, FALSE if unequal * * Failure: Negative * * Errors: * * Programmer: Robb Matzke * Wednesday, December 10, 1997 * * Modifications: * *------------------------------------------------------------------------- */ htri_t H5Tequal(hid_t type1_id, hid_t type2_id) { const H5T_t *dt1 = NULL; const H5T_t *dt2 = NULL; htri_t ret_value; FUNC_ENTER_API(H5Tequal, FAIL); H5TRACE2("t","ii",type1_id,type2_id); /* check args */ if (NULL == (dt1 = H5I_object_verify(type1_id,H5I_DATATYPE)) || NULL == (dt2 = H5I_object_verify(type2_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); ret_value = (0 == H5T_cmp(dt1, dt2, FALSE)) ? TRUE : FALSE; done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Tlock * * Purpose: Locks a type, making it read only and non-destructable. This * is normally done by the library for predefined data types so * the application doesn't inadvertently change or delete a * predefined type. * * Once a data type is locked it can never be unlocked unless * the entire library is closed. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Friday, January 9, 1998 * * Modifications: * * Robb Matzke, 1 Jun 1998 * It is illegal to lock a named data type since we must allow named * types to be closed (to release file resources) but locking a type * prevents that. *------------------------------------------------------------------------- */ herr_t H5Tlock(hid_t type_id) { H5T_t *dt = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Tlock, FAIL); H5TRACE1("e","i",type_id); /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); if (H5T_STATE_NAMED==dt->shared->state || H5T_STATE_OPEN==dt->shared->state) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "unable to lock named data type"); if (H5T_lock (dt, TRUE)<0) HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to lock transient data type"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Tget_class * * Purpose: Returns the data type class identifier for data type TYPE_ID. * * Return: Success: One of the non-negative data type class * constants. * * Failure: H5T_NO_CLASS (Negative) * * Programmer: Robb Matzke * Monday, December 8, 1997 * * Modifications: * *------------------------------------------------------------------------- */ H5T_class_t H5Tget_class(hid_t type_id) { H5T_t *dt = NULL; H5T_class_t ret_value; /* Return value */ FUNC_ENTER_API(H5Tget_class, H5T_NO_CLASS); H5TRACE1("Tt","i",type_id); /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_NO_CLASS, "not a data type"); /* Set return value */ ret_value= H5T_get_class(dt, FALSE); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_get_class * * Purpose: Returns the data type class identifier for a datatype ptr. * * Return: Success: One of the non-negative data type class * constants. * * Failure: H5T_NO_CLASS (Negative) * * Programmer: Robb Matzke * Monday, December 8, 1997 * * Modifications: * Broke out from H5Tget_class - QAK - 6/4/99 * *------------------------------------------------------------------------- */ H5T_class_t H5T_get_class(const H5T_t *dt, htri_t internal) { H5T_class_t ret_value; FUNC_ENTER_NOAPI(H5T_get_class, H5T_NO_CLASS); assert(dt); /* Externally, a VL string is a string; internally, a VL string is a VL. */ if(internal) { ret_value=dt->shared->type; } else { if(H5T_IS_VL_STRING(dt->shared)) ret_value=H5T_STRING; else ret_value=dt->shared->type; } done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5T_get_class() */ /*------------------------------------------------------------------------- * Function: H5Tdetect_class * * Purpose: Check whether a datatype contains (or is) a certain type of * datatype. * * Return: TRUE (1) or FALSE (0) on success/Negative on failure * * Programmer: Quincey Koziol * Wednesday, November 29, 2000 * * Modifications: * *------------------------------------------------------------------------- */ htri_t H5Tdetect_class(hid_t type, H5T_class_t cls) { H5T_t *dt = NULL; htri_t ret_value; /* Return value */ FUNC_ENTER_API(H5Tdetect_class, FAIL); H5TRACE2("t","iTt",type,cls); /* Check args */ if (NULL == (dt = H5I_object_verify(type,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_NO_CLASS, "not a data type"); if (!(cls>H5T_NO_CLASS && clsshared)) ret_value = (H5T_STRING==cls); else ret_value=H5T_detect_class(dt,cls); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_detect_class * * Purpose: Check whether a datatype contains (or is) a certain type of * datatype. * * Return: TRUE (1) or FALSE (0) on success/Negative on failure * * Programmer: Quincey Koziol * Wednesday, November 29, 2000 * * Modifications: * *------------------------------------------------------------------------- */ htri_t H5T_detect_class (const H5T_t *dt, H5T_class_t cls) { unsigned i; htri_t ret_value=FALSE; /* Return value */ FUNC_ENTER_NOAPI(H5T_detect_class, FAIL); assert(dt); assert(cls>H5T_NO_CLASS && clsshared->type==cls) HGOTO_DONE(TRUE); /* check for types that might have the correct type as a component */ switch(dt->shared->type) { case H5T_COMPOUND: for (i=0; ishared->u.compnd.nmembs; i++) { htri_t nested_ret; /* Return value from nested call */ /* Check if this field's type is the correct type */ if(dt->shared->u.compnd.memb[i].type->shared->type==cls) HGOTO_DONE(TRUE); /* Recurse if it's VL, compound, enum or array */ if(H5T_IS_COMPLEX(dt->shared->u.compnd.memb[i].type->shared->type)) if((nested_ret=H5T_detect_class(dt->shared->u.compnd.memb[i].type,cls))!=FALSE) HGOTO_DONE(nested_ret); } /* end for */ break; case H5T_ARRAY: case H5T_VLEN: case H5T_ENUM: HGOTO_DONE(H5T_detect_class(dt->shared->parent,cls)); default: break; } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5Tis_variable_str * * Purpose: Check whether a datatype is a variable-length string * * Return: TRUE (1) or FALSE (0) on success/Negative on failure * * Programmer: Raymond Lu * November 4, 2002 * * Modifications: * *------------------------------------------------------------------------- */ htri_t H5Tis_variable_str(hid_t dtype_id) { H5T_t *dt; /* Datatype to query */ htri_t ret_value; /* Return value */ FUNC_ENTER_API(H5Tis_variable_str, FAIL); H5TRACE1("t","i",dtype_id); /* Check args */ if (NULL == (dt = H5I_object_verify(dtype_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); /* Set return value */ ret_value=H5T_IS_VL_STRING(dt->shared); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Tget_size * * Purpose: Determines the total size of a datatype in bytes. * * Return: Success: Size of the datatype in bytes. The size of * datatype is the size of an instance of that * datatype. * * Failure: 0 (valid datatypes are never zero size) * * Programmer: Robb Matzke * Monday, December 8, 1997 * * Modifications: * *------------------------------------------------------------------------- */ size_t H5Tget_size(hid_t type_id) { H5T_t *dt = NULL; size_t ret_value; FUNC_ENTER_API(H5Tget_size, 0); H5TRACE1("z","i",type_id); /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a datatype"); /* size */ ret_value = H5T_get_size(dt); done: FUNC_LEAVE_API(ret_value); } /* end H5Tget_size() */ /*------------------------------------------------------------------------- * Function: H5Tset_size * * Purpose: Sets the total size in bytes for a datatype (this operation * is not permitted on reference datatypes). If the size is * decreased so that the significant bits of the datatype * extend beyond the edge of the new size, then the `offset' * property is decreased toward zero. If the `offset' becomes * zero and the significant bits of the datatype still hang * over the edge of the new size, then the number of significant * bits is decreased. * * Adjusting the size of an H5T_STRING automatically sets the * precision to 8*size. * * All data types have a positive size. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Wednesday, January 7, 1998 * * Modifications: * Robb Matzke, 22 Dec 1998 * Moved the real work into a private function. * *------------------------------------------------------------------------- */ herr_t H5Tset_size(hid_t type_id, size_t size) { H5T_t *dt = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Tset_size, FAIL); H5TRACE2("e","iz",type_id,size); /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); if (H5T_STATE_TRANSIENT!=dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only"); if (size <= 0 && size!=H5T_VARIABLE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "size must be positive"); if (size == H5T_VARIABLE && dt->shared->type!=H5T_STRING) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "only strings may be variable length"); if (H5T_ENUM==dt->shared->type && dt->shared->u.enumer.nmembs>0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not allowed after members are defined"); if (H5T_REFERENCE==dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for this datatype"); if (size==0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't adjust size to 0"); /* Do the work */ if (H5T_set_size(dt, size)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to set size for data type"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Tget_super * * Purpose: Returns the type from which TYPE is derived. In the case of * an enumeration type the return value is an integer type. * * Return: Success: Type ID for base data type. * * Failure: negative * * Programmer: Robb Matzke * Wednesday, December 23, 1998 * * Modifications: * *------------------------------------------------------------------------- */ hid_t H5Tget_super(hid_t type) { H5T_t *dt=NULL, *super=NULL; hid_t ret_value; FUNC_ENTER_API(H5Tget_super, FAIL); H5TRACE1("i","i",type); if (NULL==(dt=H5I_object_verify(type,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); if((super=H5T_get_super(dt))==NULL) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "not a data type"); if ((ret_value=H5I_register(H5I_DATATYPE, super))<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register parent data type"); done: if(ret_value<0) { if(super!=NULL) H5T_close(super); } /* end if */ FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_get_super * * Purpose: Private function for H5Tget_super. Returns the type from * which TYPE is derived. In the case of an enumeration type * the return value is an integer type. * * Return: Success: Data type for base data type. * * Failure: NULL * * Programmer: Raymond Lu * October 9, 2002 * * Modifications: * *------------------------------------------------------------------------- */ H5T_t * H5T_get_super(H5T_t *dt) { H5T_t *ret_value=NULL; FUNC_ENTER_NOAPI(H5T_get_super, NULL); assert(dt); if (!dt->shared->parent) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "not a derived data type"); if (NULL==(ret_value=H5T_copy(dt->shared->parent, H5T_COPY_ALL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy parent data type"); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_register * * Purpose: Register a hard or soft conversion function for a data type * conversion path. The path is specified by the source and * destination data types SRC_ID and DST_ID (for soft functions * only the class of these types is important). If FUNC is a * hard function then it replaces any previous path; if it's a * soft function then it replaces all existing paths to which it * applies and is used for any new path to which it applies as * long as that path doesn't have a hard function. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Friday, January 9, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5T_register(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, H5T_conv_t func, hid_t dxpl_id) { hid_t tmp_sid=-1, tmp_did=-1;/*temporary data type IDs */ H5T_path_t *old_path=NULL; /*existing conversion path */ H5T_path_t *new_path=NULL; /*new conversion path */ H5T_cdata_t cdata; /*temporary conversion data */ int nprint=0; /*number of paths shut down */ int i; /*counter */ herr_t ret_value=SUCCEED; /*return value */ FUNC_ENTER_NOAPI_NOINIT(H5T_register); /* Check args */ assert(src); assert(dst); assert(func); assert(H5T_PERS_HARD==pers || H5T_PERS_SOFT==pers); assert(name && *name); if (H5T_PERS_HARD==pers) { /* Only bother to register the path if it's not a no-op path (for this machine) */ if(H5T_cmp(src, dst, FALSE)) { /* Locate or create a new conversion path */ if (NULL==(new_path=H5T_path_find(src, dst, name, func, dxpl_id))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to locate/allocate conversion path"); /* * Notify all other functions to recalculate private data since some * functions might cache a list of conversion functions. For * instance, the compound type converter caches a list of conversion * functions for the members, so adding a new function should cause * the list to be recalculated to use the new function. */ for (i=0; icdata.recalc = TRUE; } /* end for */ } /* end if */ } else { /* Add function to end of soft list */ if (H5T_g.nsoft>=H5T_g.asoft) { size_t na = MAX(32, 2*H5T_g.asoft); H5T_soft_t *x = H5MM_realloc(H5T_g.soft, na*sizeof(H5T_soft_t)); if (!x) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); H5T_g.asoft = (int)na; H5T_g.soft = x; } /* end if */ HDstrncpy (H5T_g.soft[H5T_g.nsoft].name, name, (size_t)H5T_NAMELEN); H5T_g.soft[H5T_g.nsoft].name[H5T_NAMELEN-1] = '\0'; H5T_g.soft[H5T_g.nsoft].src = src->shared->type; H5T_g.soft[H5T_g.nsoft].dst = dst->shared->type; H5T_g.soft[H5T_g.nsoft].func = func; H5T_g.nsoft++; /* * Any existing path (except the no-op path) to which this new soft * conversion function applies should be replaced by a new path that * uses this function. */ for (i=1; iis_hard || old_path->src->shared->type!=src->shared->type || old_path->dst->shared->type!=dst->shared->type) { continue; } if ((tmp_sid = H5I_register(H5I_DATATYPE, H5T_copy(old_path->src, H5T_COPY_ALL)))<0 || (tmp_did = H5I_register(H5I_DATATYPE, H5T_copy(old_path->dst, H5T_COPY_ALL)))<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register data types for conv query"); HDmemset(&cdata, 0, sizeof cdata); cdata.command = H5T_CONV_INIT; if ((func)(tmp_sid, tmp_did, &cdata, (size_t)0, (size_t)0, (size_t)0, NULL, NULL, dxpl_id)<0) { H5I_dec_ref(tmp_sid); H5I_dec_ref(tmp_did); tmp_sid = tmp_did = -1; H5E_clear(); continue; } /* end if */ /* Create a new conversion path */ if (NULL==(new_path=H5FL_CALLOC(H5T_path_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); HDstrncpy(new_path->name, name, (size_t)H5T_NAMELEN); new_path->name[H5T_NAMELEN-1] = '\0'; if (NULL==(new_path->src=H5T_copy(old_path->src, H5T_COPY_ALL)) || NULL==(new_path->dst=H5T_copy(old_path->dst, H5T_COPY_ALL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy data types"); new_path->func = func; new_path->is_hard = FALSE; new_path->cdata = cdata; /* Replace previous path */ H5T_g.path[i] = new_path; new_path = NULL; /*so we don't free it on error*/ /* Free old path */ H5T_print_stats(old_path, &nprint); old_path->cdata.command = H5T_CONV_FREE; if ((old_path->func)(tmp_sid, tmp_did, &(old_path->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL, dxpl_id)<0) { #ifdef H5T_DEBUG if (H5DEBUG(T)) { fprintf (H5DEBUG(T), "H5T: conversion function 0x%08lx " "failed to free private data for %s (ignored)\n", (unsigned long)(old_path->func), old_path->name); } #endif } /* end if */ H5T_close(old_path->src); H5T_close(old_path->dst); H5FL_FREE(H5T_path_t,old_path); /* Release temporary atoms */ H5I_dec_ref(tmp_sid); H5I_dec_ref(tmp_did); tmp_sid = tmp_did = -1; /* We don't care about any failures during the freeing process */ H5E_clear(); } /* end for */ } /* end else */ done: if (ret_value<0) { if (new_path) { if (new_path->src) H5T_close(new_path->src); if (new_path->dst) H5T_close(new_path->dst); H5FL_FREE(H5T_path_t,new_path); } /* end if */ if (tmp_sid>=0) H5I_dec_ref(tmp_sid); if (tmp_did>=0) H5I_dec_ref(tmp_did); } /* end if */ FUNC_LEAVE_NOAPI(ret_value); } /* end H5T_register() */ /*------------------------------------------------------------------------- * Function: H5Tregister * * Purpose: Register a hard or soft conversion function for a data type * conversion path. The path is specified by the source and * destination data types SRC_ID and DST_ID (for soft functions * only the class of these types is important). If FUNC is a * hard function then it replaces any previous path; if it's a * soft function then it replaces all existing paths to which it * applies and is used for any new path to which it applies as * long as that path doesn't have a hard function. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Friday, January 9, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Tregister(H5T_pers_t pers, const char *name, hid_t src_id, hid_t dst_id, H5T_conv_t func) { H5T_t *src; /*source data type descriptor */ H5T_t *dst; /*destination data type desc */ herr_t ret_value=SUCCEED; /*return value */ FUNC_ENTER_API(H5Tregister, FAIL); H5TRACE5("e","Tesiix",pers,name,src_id,dst_id,func); /* Check args */ if (H5T_PERS_HARD!=pers && H5T_PERS_SOFT!=pers) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid function persistence"); if (!name || !*name) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "conversion must have a name for debugging"); if (NULL==(src=H5I_object_verify(src_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); if (NULL==(dst=H5I_object_verify(dst_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); if (!func) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no conversion function specified"); /* Go register the function */ if(H5T_register(pers,name,src,dst,func,H5AC_ind_dxpl_id)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't register conversion function"); done: FUNC_LEAVE_API(ret_value); } /* end H5Tregister() */ /*------------------------------------------------------------------------- * Function: H5T_unregister * * Purpose: Removes conversion paths that match the specified criteria. * All arguments are optional. Missing arguments are wild cards. * The special no-op path cannot be removed. * * Return: Succeess: non-negative * * Failure: negative * * Programmer: Robb Matzke * Tuesday, January 13, 1998 * * Modifications: * Adapted to non-API function - QAK, 11/17/99 * *------------------------------------------------------------------------- */ static herr_t H5T_unregister(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, H5T_conv_t func, hid_t dxpl_id) { H5T_path_t *path = NULL; /*conversion path */ H5T_soft_t *soft = NULL; /*soft conversion information */ int nprint=0; /*number of paths shut down */ int i; /*counter */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_unregister, FAIL); /* Remove matching entries from the soft list */ if (H5T_PERS_DONTCARE==pers || H5T_PERS_SOFT==pers) { for (i=H5T_g.nsoft-1; i>=0; --i) { soft = H5T_g.soft+i; assert(soft); if (name && *name && HDstrcmp(name, soft->name)) continue; if (src && src->shared->type!=soft->src) continue; if (dst && dst->shared->type!=soft->dst) continue; if (func && func!=soft->func) continue; HDmemmove(H5T_g.soft+i, H5T_g.soft+i+1, (H5T_g.nsoft-(i+1)) * sizeof(H5T_soft_t)); --H5T_g.nsoft; } } /* Remove matching conversion paths, except no-op path */ for (i=H5T_g.npaths-1; i>0; --i) { path = H5T_g.path[i]; assert(path); /* Not a match */ if (((H5T_PERS_SOFT==pers && path->is_hard) || (H5T_PERS_HARD==pers && !path->is_hard)) || (name && *name && HDstrcmp(name, path->name)) || (src && H5T_cmp(src, path->src, FALSE)) || (dst && H5T_cmp(dst, path->dst, FALSE)) || (func && func!=path->func)) { /* * Notify all other functions to recalculate private data since some * functions might cache a list of conversion functions. For * instance, the compound type converter caches a list of conversion * functions for the members, so removing a function should cause * the list to be recalculated to avoid the removed function. */ path->cdata.recalc = TRUE; } /* end if */ else { /* Remove from table */ HDmemmove(H5T_g.path+i, H5T_g.path+i+1, (H5T_g.npaths-(i+1))*sizeof(H5T_path_t*)); --H5T_g.npaths; /* Shut down path */ H5T_print_stats(path, &nprint); path->cdata.command = H5T_CONV_FREE; if ((path->func)(FAIL, FAIL, &(path->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL, dxpl_id)<0) { #ifdef H5T_DEBUG if (H5DEBUG(T)) { fprintf(H5DEBUG(T), "H5T: conversion function 0x%08lx failed " "to free private data for %s (ignored)\n", (unsigned long)(path->func), path->name); } #endif } H5T_close(path->src); H5T_close(path->dst); H5FL_FREE(H5T_path_t,path); H5E_clear(); /*ignore all shutdown errors*/ } /* end else */ } /* end for */ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5T_unregister() */ /*------------------------------------------------------------------------- * Function: H5Tunregister * * Purpose: Removes conversion paths that match the specified criteria. * All arguments are optional. Missing arguments are wild cards. * The special no-op path cannot be removed. * * Return: Succeess: non-negative * * Failure: negative * * Programmer: Robb Matzke * Tuesday, January 13, 1998 * * Modifications: * Changed to use H5T_unregister wrapper function - QAK, 11/17/99 * *------------------------------------------------------------------------- */ herr_t H5Tunregister(H5T_pers_t pers, const char *name, hid_t src_id, hid_t dst_id, H5T_conv_t func) { H5T_t *src=NULL, *dst=NULL; /*data type descriptors */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Tunregister, FAIL); H5TRACE5("e","Tesiix",pers,name,src_id,dst_id,func); /* Check arguments */ if (src_id>0 && (NULL==(src=H5I_object_verify(src_id,H5I_DATATYPE)))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "src is not a data type"); if (dst_id>0 && (NULL==(dst=H5I_object_verify(dst_id,H5I_DATATYPE)))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dst is not a data type"); if (H5T_unregister(pers,name,src,dst,func,H5AC_ind_dxpl_id)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDELETE, FAIL, "internal unregister function failed"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Tfind * * Purpose: Finds a conversion function that can handle a conversion from * type SRC_ID to type DST_ID. The PCDATA argument is a pointer * to a pointer to type conversion data which was created and * initialized by the type conversion function of this path * when the conversion function was installed on the path. * * Return: Success: A pointer to a suitable conversion function. * * Failure: NULL * * Programmer: Robb Matzke * Tuesday, January 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ H5T_conv_t H5Tfind(hid_t src_id, hid_t dst_id, H5T_cdata_t **pcdata) { H5T_conv_t ret_value; H5T_t *src = NULL, *dst = NULL; H5T_path_t *path = NULL; FUNC_ENTER_API(H5Tfind, NULL); H5TRACE3("x","iix",src_id,dst_id,pcdata); /* Check args */ if (NULL == (src = H5I_object_verify(src_id,H5I_DATATYPE)) || NULL == (dst = H5I_object_verify(dst_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type"); if (!pcdata) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, NULL, "no address to receive cdata pointer"); /* Find it */ if (NULL==(path=H5T_path_find(src, dst, NULL, NULL, H5AC_ind_dxpl_id))) HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL, "conversion function not found"); if (pcdata) *pcdata = &(path->cdata); /* Set return value */ ret_value = path->func; done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Tconvert * * Purpose: Convert NELMTS elements from type SRC_ID to type DST_ID. The * source elements are packed in BUF and on return the * destination will be packed in BUF. That is, the conversion * is performed in place. The optional background buffer is an * array of NELMTS values of destination type which are merged * with the converted values to fill in cracks (for instance, * BACKGROUND might be an array of structs with the `a' and `b' * fields already initialized and the conversion of BUF supplies * the `c' and `d' field values). The PLIST_ID a dataset transfer * property list which is passed to the conversion functions. (It's * currently only used to pass along the VL datatype custom allocation * information -QAK 7/1/99) * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Wednesday, June 10, 1998 * * Modifications: * Added xfer_parms argument to pass VL datatype custom allocation * information down the chain. - QAK, 7/1/99 * *------------------------------------------------------------------------- */ herr_t H5Tconvert(hid_t src_id, hid_t dst_id, size_t nelmts, void *buf, void *background, hid_t dxpl_id) { H5T_path_t *tpath=NULL; /*type conversion info */ H5T_t *src=NULL, *dst=NULL; /*unatomized types */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Tconvert, FAIL); H5TRACE6("e","iizxxi",src_id,dst_id,nelmts,buf,background,dxpl_id); /* Check args */ if (NULL==(src=H5I_object_verify(src_id,H5I_DATATYPE)) || NULL==(dst=H5I_object_verify(dst_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); if(H5P_DEFAULT == dxpl_id) dxpl_id = H5P_DATASET_XFER_DEFAULT; else if(TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not dataset transfer property list"); /* Find the conversion function */ if (NULL==(tpath=H5T_path_find(src, dst, NULL, NULL, dxpl_id))) HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert between src and dst data types"); if (H5T_convert(tpath, src_id, dst_id, nelmts, (size_t)0, (size_t)0, buf, background, dxpl_id)<0) HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "data type conversion failed"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Tget_overflow * * Purpose: Returns a pointer to the current global overflow function. * This is an application-defined function that is called * whenever a data type conversion causes an overflow. * * Return: Success: Ptr to an application-defined function. * * Failure: NULL (this can happen if no overflow handling * function is registered). * * Programmer: Robb Matzke * Tuesday, July 7, 1998 * * Modifications: * *------------------------------------------------------------------------- */ H5T_overflow_t H5Tget_overflow(void) { H5T_overflow_t ret_value; /* Return value */ FUNC_ENTER_API(H5Tget_overflow, NULL); H5TRACE0("x",""); if (NULL==H5T_overflow_g) HGOTO_ERROR(H5E_DATATYPE, H5E_UNINITIALIZED, NULL, "no overflow handling function is registered"); /* Set return value */ ret_value=H5T_overflow_g; done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Tset_overflow * * Purpose: Sets the overflow handler to be the specified function. FUNC * will be called for all data type conversions that result in * an overflow. See the definition of `H5T_overflow_t' for * documentation of arguments and return values. The NULL * pointer may be passed to remove the overflow handler. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Tuesday, July 7, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Tset_overflow(H5T_overflow_t func) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Tset_overflow, FAIL); H5TRACE1("e","x",func); H5T_overflow_g = func; done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * API functions are above; library-private functions are below... *------------------------------------------------------------------------- */ /*------------------------------------------------------------------------- * Function: H5T_create * * Purpose: Creates a new data type and initializes it to reasonable * values. The new data type is SIZE bytes and an instance of * the class TYPE. * * Return: Success: Pointer to the new type. * * Failure: NULL * * Programmer: Robb Matzke * Friday, December 5, 1997 * * Modifications: * *------------------------------------------------------------------------- */ H5T_t * H5T_create(H5T_class_t type, size_t size) { H5T_t *dt = NULL; hid_t subtype; H5T_t *ret_value; FUNC_ENTER_NOAPI(H5T_create, NULL); switch (type) { case H5T_INTEGER: case H5T_FLOAT: case H5T_TIME: case H5T_STRING: case H5T_BITFIELD: HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, NULL, "type class is not appropriate - use H5Tcopy()"); case H5T_OPAQUE: case H5T_COMPOUND: if(NULL == (dt = H5T_alloc())) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); dt->shared->type = type; if(type==H5T_COMPOUND) dt->shared->u.compnd.packed=TRUE; /* Start out packed */ else if(type==H5T_OPAQUE) /* Initialize the tag in case it's not set later. A null tag will * cause problems for later operations. */ dt->shared->u.opaque.tag = H5MM_strdup(""); break; case H5T_ENUM: if (sizeof(char)==size) { subtype = H5T_NATIVE_SCHAR_g; } else if (sizeof(short)==size) { subtype = H5T_NATIVE_SHORT_g; } else if (sizeof(int)==size) { subtype = H5T_NATIVE_INT_g; } else if (sizeof(long)==size) { subtype = H5T_NATIVE_LONG_g; } else if (sizeof(long_long)==size) { subtype = H5T_NATIVE_LLONG_g; } else { HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "no applicable native integer type"); } if(NULL == (dt = H5T_alloc())) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); dt->shared->type = type; if (NULL==(dt->shared->parent=H5T_copy(H5I_object(subtype), H5T_COPY_ALL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy base data type"); break; case H5T_VLEN: /* Variable length datatype */ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, NULL, "base type required - use H5Tvlen_create()"); case H5T_ARRAY: /* Array datatype */ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, NULL, "base type required - use H5Tarray_create()"); default: HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, NULL, "unknown data type class"); } dt->shared->size = size; /* Set return value */ ret_value=dt; done: if(ret_value==NULL) { if(dt->shared != NULL) H5FL_FREE(H5T_shared_t, dt->shared); if(dt!=NULL) H5FL_FREE(H5T_t,dt); } /* end if */ FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_isa * * Purpose: Determines if an object has the requisite messages for being * a data type. * * Return: Success: TRUE if the required data type messages are * present; FALSE otherwise. * * Failure: FAIL if the existence of certain messages * cannot be determined. * * Programmer: Robb Matzke * Monday, November 2, 1998 * * Modifications: * *------------------------------------------------------------------------- */ htri_t H5T_isa(H5G_entry_t *ent, hid_t dxpl_id) { htri_t ret_value; FUNC_ENTER_NOAPI(H5T_isa, FAIL); assert(ent); if ((ret_value=H5O_exists(ent, H5O_DTYPE_ID, 0, dxpl_id))<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to read object header"); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_open * * Purpose: Open a named data type. * * Return: Success: Ptr to a new data type. * * Failure: NULL * * Programmer: Robb Matzke * Monday, June 1, 1998 * * Modifications: * Changed to use H5T_open_oid - QAK - 3/17/99 * *------------------------------------------------------------------------- */ H5T_t* H5T_open (H5G_entry_t *ent, hid_t dxpl_id) { H5T_shared_t *shared_fo=NULL; H5T_t *dt=NULL; H5T_t *ret_value; FUNC_ENTER_NOAPI(H5T_open, NULL); assert (ent); /* Check if datatype was already open */ if((shared_fo=H5FO_opened(ent->file,ent->header))==NULL) { /* Clear any errors from H5FO_opened() */ H5E_clear(); /* Open the datatype object */ if ((dt=H5T_open_oid(ent, dxpl_id)) ==NULL) HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL, "not found"); /* Add the datatype to the list of opened objects in the file */ if(H5FO_insert(dt->ent.file, dt->ent.header, dt->shared)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, NULL, "can't insert datatype into list of open objects") /* Increment object count for the object in the top file */ if(H5FO_top_incr(dt->ent.file, dt->ent.header) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINC, NULL, "can't increment object count") /* Mark any datatypes as being in memory now */ if (H5T_vlen_mark(dt, NULL, H5T_VLEN_MEMORY)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid datatype location") dt->shared->fo_count=1; } else { if(NULL == (dt = H5FL_MALLOC(H5T_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate space for datatype") /* Shallow copy (take ownership) of the group entry object */ if(H5G_ent_copy(&(dt->ent),ent,H5G_COPY_SHALLOW)<0) HGOTO_ERROR (H5E_DATATYPE, H5E_CANTCOPY, NULL, "can't copy group entry") dt->shared=shared_fo; shared_fo->fo_count++; /* Check if the object has been opened through the top file yet */ if(H5FO_top_count(dt->ent.file, dt->ent.header) == 0) { /* Open the object through this top file */ if(H5O_open(&(dt->ent)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to open object header") } /* end if */ /* Increment object count for the object in the top file */ if(H5FO_top_incr(dt->ent.file, dt->ent.header) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINC, NULL, "can't increment object count") } ret_value = dt; done: if(ret_value==NULL) { if(dt) { if(shared_fo==NULL) /* Need to free shared fo */ H5FL_FREE(H5T_shared_t, dt->shared); H5FL_FREE(H5T_t, dt); } if(shared_fo) shared_fo->fo_count--; } FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_open_oid * * Purpose: Open a named data type. * * Return: Success: Ptr to a new data type. * * Failure: NULL * * Programmer: Quincey Koziol * Wednesday, March 17, 1999 * * Modifications: * *------------------------------------------------------------------------- */ H5T_t * H5T_open_oid (H5G_entry_t *ent, hid_t dxpl_id) { H5T_t *dt=NULL; H5T_t *ret_value; FUNC_ENTER_NOAPI(H5T_open_oid, NULL); assert (ent); if (H5O_open (ent)<0) HGOTO_ERROR (H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to open named data type"); if (NULL==(dt=H5O_read (ent, H5O_DTYPE_ID, 0, NULL, dxpl_id))) HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to load type message from object header"); /* Mark the type as named and open */ dt->shared->state = H5T_STATE_OPEN; /* Shallow copy (take ownership) of the group entry object */ H5G_ent_copy(&(dt->ent),ent,H5G_COPY_SHALLOW); /* Set return value */ ret_value=dt; done: if(ret_value==NULL) { if(dt==NULL) H5O_close(ent); } /* end if */ FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_copy * * Purpose: Copies datatype OLD_DT. The resulting data type is not * locked and is a transient type. * * Return: Success: Pointer to a new copy of the OLD_DT argument. * * Failure: NULL * * Programmer: Robb Matzke * Thursday, December 4, 1997 * * Modifications: * * Robb Matzke, 4 Jun 1998 * Added the METHOD argument. If it's H5T_COPY_TRANSIENT then the * result will be an unlocked transient type. Otherwise if it's * H5T_COPY_ALL then the result is a named type if the original is a * named type, but the result is not opened. Finally, if it's * H5T_COPY_REOPEN and the original type is a named type then the result * is a named type and the type object header is opened again. The * H5T_COPY_REOPEN method is used when returning a named type to the * application. * * Robb Matzke, 22 Dec 1998 * Now able to copy enumeration data types. * * Robb Matzke, 20 May 1999 * Now able to copy opaque types. * * Pedro Vicente, 21 Sep 2002 * Added a deep copy of the symbol table entry * *------------------------------------------------------------------------- */ H5T_t * H5T_copy(const H5T_t *old_dt, H5T_copy_t method) { H5T_t *new_dt=NULL, *tmp=NULL; H5T_shared_t *reopened_fo; unsigned i; char *s; H5T_t *ret_value; FUNC_ENTER_NOAPI(H5T_copy, NULL); /* check args */ assert(old_dt); /* Allocate space */ if (NULL==(new_dt = H5FL_MALLOC(H5T_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); if (NULL==(new_dt->shared = H5FL_MALLOC(H5T_shared_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); /* Copy shared information (entry information is copied last) */ *(new_dt->shared) = *(old_dt->shared); /* Copy parent information */ if (new_dt->shared->parent) new_dt->shared->parent = H5T_copy(new_dt->shared->parent, method); /* Check what sort of copy we are making */ switch (method) { case H5T_COPY_TRANSIENT: /* * Return an unlocked transient type. */ new_dt->shared->state = H5T_STATE_TRANSIENT; break; case H5T_COPY_ALL: /* * Return a transient type (locked or unlocked) or an unopened named * type. Immutable transient types are degraded to read-only. */ if (H5T_STATE_OPEN==old_dt->shared->state) { new_dt->shared->state = H5T_STATE_NAMED; } else if (H5T_STATE_IMMUTABLE==old_dt->shared->state) { new_dt->shared->state = H5T_STATE_RDONLY; } break; case H5T_COPY_REOPEN: /* * Return a transient type (locked or unlocked) or an opened named * type. Immutable transient types are degraded to read-only. */ if (H5F_addr_defined(old_dt->ent.header)) { /* Check if the object is already open */ if((reopened_fo=H5FO_opened(old_dt->ent.file, old_dt->ent.header))==NULL) { /* Clear any errors from H5FO_opened() */ H5E_clear(); /* Open named datatype again */ if (H5O_open (&(old_dt->ent))<0) HGOTO_ERROR (H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to reopen named data type"); /* Insert opened named datatype into opened object list for the file */ if(H5FO_insert(old_dt->ent.file, old_dt->ent.header, new_dt->shared)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, NULL, "can't insert datatype into list of open objects") /* Increment object count for the object in the top file */ if(H5FO_top_incr(old_dt->ent.file, old_dt->ent.header) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINC, NULL, "can't increment object count") new_dt->shared->fo_count=1; } else { /* The object is already open. Free the H5T_shared_t struct * we had been using and use the one that already exists. * Not terribly efficient. */ H5FL_FREE(H5T_shared_t, new_dt->shared); new_dt->shared = reopened_fo; reopened_fo->fo_count++; /* Check if the object has been opened through the top file yet */ if(H5FO_top_count(old_dt->ent.file, old_dt->ent.header) == 0) { /* Open the object through this top file */ if(H5O_open(&(old_dt->ent)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to open object header") } /* end if */ /* Increment object count for the object in the top file */ if(H5FO_top_incr(old_dt->ent.file, old_dt->ent.header) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINC, NULL, "can't increment object count") } new_dt->shared->state = H5T_STATE_OPEN; } else if (H5T_STATE_IMMUTABLE==old_dt->shared->state) { new_dt->shared->state = H5T_STATE_RDONLY; } break; } /* end switch */ switch(new_dt->shared->type) { case H5T_COMPOUND: { int accum_change=0; /* Amount of change in the offset of the fields */ /* * Copy all member fields to new type, then overwrite the * name and type fields of each new member with copied values. * That is, H5T_copy() is a deep copy. */ new_dt->shared->u.compnd.memb = H5MM_malloc(new_dt->shared->u.compnd.nalloc * sizeof(H5T_cmemb_t)); if (NULL==new_dt->shared->u.compnd.memb) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); HDmemcpy(new_dt->shared->u.compnd.memb, old_dt->shared->u.compnd.memb, new_dt->shared->u.compnd.nmembs * sizeof(H5T_cmemb_t)); for (i=0; ishared->u.compnd.nmembs; i++) { unsigned j; int old_match; s = new_dt->shared->u.compnd.memb[i].name; new_dt->shared->u.compnd.memb[i].name = H5MM_xstrdup(s); tmp = H5T_copy (old_dt->shared->u.compnd.memb[i].type, method); new_dt->shared->u.compnd.memb[i].type = tmp; /* Apply the accumulated size change to the offset of the field */ new_dt->shared->u.compnd.memb[i].offset += accum_change; if(old_dt->shared->u.compnd.sorted != H5T_SORT_VALUE) { for (old_match=-1, j=0; jshared->u.compnd.nmembs; j++) { if(!HDstrcmp(new_dt->shared->u.compnd.memb[i].name,old_dt->shared->u.compnd.memb[j].name)) { old_match=j; break; } /* end if */ } /* end for */ /* check if we couldn't find a match */ if(old_match<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "fields in datatype corrupted"); } /* end if */ else { old_match=i; } /* end else */ /* If the field changed size, add that change to the accumulated size change */ if(new_dt->shared->u.compnd.memb[i].type->shared->size != old_dt->shared->u.compnd.memb[old_match].type->shared->size) { /* Adjust the size of the member */ new_dt->shared->u.compnd.memb[i].size = (old_dt->shared->u.compnd.memb[old_match].size*tmp->shared->size)/old_dt->shared->u.compnd.memb[old_match].type->shared->size; accum_change += (new_dt->shared->u.compnd.memb[i].type->shared->size - old_dt->shared->u.compnd.memb[old_match].type->shared->size); } /* end if */ } /* end for */ /* Apply the accumulated size change to the size of the compound struct */ new_dt->shared->size += accum_change; } break; case H5T_ENUM: /* * Copy all member fields to new type, then overwrite the name fields * of each new member with copied values. That is, H5T_copy() is a * deep copy. */ new_dt->shared->u.enumer.name = H5MM_malloc(new_dt->shared->u.enumer.nalloc * sizeof(char*)); new_dt->shared->u.enumer.value = H5MM_malloc(new_dt->shared->u.enumer.nalloc * new_dt->shared->size); if (NULL==new_dt->shared->u.enumer.value) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); HDmemcpy(new_dt->shared->u.enumer.value, old_dt->shared->u.enumer.value, new_dt->shared->u.enumer.nmembs * new_dt->shared->size); for (i=0; ishared->u.enumer.nmembs; i++) { s = old_dt->shared->u.enumer.name[i]; new_dt->shared->u.enumer.name[i] = H5MM_xstrdup(s); } break; case H5T_VLEN: if(method==H5T_COPY_TRANSIENT || method==H5T_COPY_REOPEN) { /* H5T_copy converts any VL type into a memory VL type */ if (H5T_vlen_mark(new_dt, NULL, H5T_VLEN_MEMORY)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid VL location"); } break; case H5T_OPAQUE: /* * Copy the tag name. */ new_dt->shared->u.opaque.tag = HDstrdup(new_dt->shared->u.opaque.tag); break; case H5T_ARRAY: /* Re-compute the array's size, in case it's base type changed size */ new_dt->shared->size=new_dt->shared->u.array.nelem*new_dt->shared->parent->shared->size; break; default: break; } /* end switch */ /* Deep copy of the symbol table entry, if there was one */ if ( new_dt->shared->state == H5T_STATE_NAMED || new_dt->shared->state == H5T_STATE_OPEN) { if (!H5F_addr_defined(old_dt->ent.header)) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "named dataype with invalid address"); if (H5G_ent_copy(&(new_dt->ent), &(old_dt->ent),H5G_COPY_DEEP)<0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to copy entry"); } /* end if */ else { HDmemset (&(new_dt->ent), 0, sizeof(new_dt->ent)); new_dt->ent.header = HADDR_UNDEF; } /* end else */ /* Set return value */ ret_value=new_dt; done: if(ret_value==NULL) { if(new_dt->shared != NULL) H5FL_FREE(H5T_shared_t, new_dt->shared); if(new_dt!=NULL) H5FL_FREE (H5T_t,new_dt); } /* end if */ FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_lock * * Purpose: Lock a transient data type making it read-only. If IMMUTABLE * is set then the type cannot be closed except when the library * itself closes. * * This function is a no-op if the type is not transient or if * the type is already read-only or immutable. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Thursday, June 4, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_lock (H5T_t *dt, hbool_t immutable) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_lock, FAIL); assert (dt); switch (dt->shared->state) { case H5T_STATE_TRANSIENT: dt->shared->state = immutable ? H5T_STATE_IMMUTABLE : H5T_STATE_RDONLY; break; case H5T_STATE_RDONLY: if (immutable) dt->shared->state = H5T_STATE_IMMUTABLE; break; case H5T_STATE_IMMUTABLE: case H5T_STATE_NAMED: case H5T_STATE_OPEN: /*void*/ break; } done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_alloc * * Purpose: Allocates a new H5T_t structure, initializing it correctly. * * Return: Pointer to new H5T_t on success/NULL on failure * * Programmer: Quincey Koziol * Monday, August 29, 2005 * * Modifications: * *------------------------------------------------------------------------- */ H5T_t * H5T_alloc(void) { H5T_t *dt; /* Pointer to datatype allocated */ H5T_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5T_alloc, NULL) /* Allocate & initialize new datatype info */ if(NULL == (dt = H5FL_CALLOC(H5T_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") H5G_ent_reset(&(dt->ent)); if(NULL == (dt->shared = H5FL_CALLOC(H5T_shared_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Assign return value */ ret_value = dt; done: if(ret_value == NULL) { if(dt != NULL) { if(dt->shared != NULL) H5FL_FREE(H5T_shared_t, dt->shared); H5FL_FREE(H5T_t, dt); } /* end if */ } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_alloc() */ /*------------------------------------------------------------------------- * Function: H5T_free * * Purpose: Frees all memory associated with a datatype, but does not * free the H5T_t or H5T_shared_t structures (which should * be done in H5T_close). * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Monday, January 6, 2003 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_free(H5T_t *dt) { unsigned i; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_free, FAIL); assert(dt && dt->shared); /* * If a named type is being closed then close the object header and * remove from the list of open objects in the file. */ if (H5T_STATE_OPEN==dt->shared->state) { assert (H5F_addr_defined(dt->ent.header)); /* Remove the datatype from the list of opened objects in the file */ if(H5FO_top_decr(dt->ent.file, dt->ent.header) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "can't decrement count for object") if(H5FO_delete(dt->ent.file, H5AC_dxpl_id, dt->ent.header)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "can't remove datatype from list of open objects") if (H5O_close(&(dt->ent))<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to close data type object header"); dt->shared->state = H5T_STATE_NAMED; } /* * Don't free locked datatypes. */ if (H5T_STATE_IMMUTABLE==dt->shared->state) HGOTO_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to close immutable datatype"); /* Close the datatype */ switch (dt->shared->type) { case H5T_COMPOUND: for (i=0; ishared->u.compnd.nmembs; i++) { H5MM_xfree(dt->shared->u.compnd.memb[i].name); H5T_close(dt->shared->u.compnd.memb[i].type); } H5MM_xfree(dt->shared->u.compnd.memb); break; case H5T_ENUM: for (i=0; ishared->u.enumer.nmembs; i++) H5MM_xfree(dt->shared->u.enumer.name[i]); H5MM_xfree(dt->shared->u.enumer.name); H5MM_xfree(dt->shared->u.enumer.value); break; case H5T_OPAQUE: H5MM_xfree(dt->shared->u.opaque.tag); break; default: break; } /* Free the ID to name info */ H5G_free_ent_name(&(dt->ent)); /* Close the parent */ if (dt->shared->parent && H5T_close(dt->shared->parent)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, FAIL, "unable to close parent data type"); done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5T_free() */ /*------------------------------------------------------------------------- * Function: H5T_close * * Purpose: Frees a data type and all associated memory. If the data * type is locked then nothing happens. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Monday, December 8, 1997 * * Modifications: * Robb Matzke, 1999-04-27 * This function fails if the datatype state is IMMUTABLE. * * Robb Matzke, 1999-05-20 * Closes opaque types also. * * Pedro Vicente, 22 Aug 2002 * Added "ID to name" support * * Quincey Koziol, 2003-01-06 * Moved "guts" of function to H5T_free() * *------------------------------------------------------------------------- */ herr_t H5T_close(H5T_t *dt) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_close, FAIL); assert(dt && dt->shared); dt->shared->fo_count--; if(dt->shared->state != H5T_STATE_OPEN || dt->shared->fo_count == 0) { if(H5T_free(dt)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "unable to free datatype"); H5FL_FREE(H5T_shared_t, dt->shared); } else { /* * If a named type is being closed then close the object header and * remove from the list of open objects in the file. */ if(H5T_STATE_OPEN==dt->shared->state) { /* Decrement the ref. count for this object in the top file */ if(H5FO_top_decr(dt->ent.file, dt->ent.header) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "can't decrement count for object") /* Check reference count for this object in the top file */ if(H5FO_top_count(dt->ent.file, dt->ent.header) == 0) if(H5O_close(&(dt->ent)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to close") } /* end if */ /* Free the ID to name info since we're not calling H5T_free*/ H5G_free_ent_name(&(dt->ent)); } /* Free the datatype struct */ H5FL_FREE(H5T_t,dt); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_set_size * * Purpose: Sets the total size in bytes for a data type (this operation * is not permitted on reference data types). If the size is * decreased so that the significant bits of the data type * extend beyond the edge of the new size, then the `offset' * property is decreased toward zero. If the `offset' becomes * zero and the significant bits of the data type still hang * over the edge of the new size, then the number of significant * bits is decreased. * * Adjusting the size of an H5T_STRING automatically sets the * precision to 8*size. * * All data types have a positive size. * * Return: Success: non-negative * * Failure: nagative * * Programmer: Robb Matzke * Tuesday, December 22, 1998 * * Modifications: * Robb Matzke, 22 Dec 1998 * Also works with derived data types. * *------------------------------------------------------------------------- */ herr_t H5T_set_size(H5T_t *dt, size_t size) { size_t prec, offset; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_set_size, FAIL); /* Check args */ assert(dt); assert(size!=0); assert(H5T_REFERENCE!=dt->shared->type); assert(!(H5T_ENUM==dt->shared->type && 0==dt->shared->u.enumer.nmembs)); if (dt->shared->parent) { if (H5T_set_size(dt->shared->parent, size)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to set size for parent data type"); /* Adjust size of datatype appropriately */ if(dt->shared->type==H5T_ARRAY) dt->shared->size = dt->shared->parent->shared->size * dt->shared->u.array.nelem; else if(dt->shared->type!=H5T_VLEN) dt->shared->size = dt->shared->parent->shared->size; } else { if (H5T_IS_ATOMIC(dt->shared)) { offset = dt->shared->u.atomic.offset; prec = dt->shared->u.atomic.prec; /* Decrement the offset and precision if necessary */ if (prec > 8*size) offset = 0; else if (offset+prec > 8*size) offset = 8 * size - prec; if (prec > 8*size) prec = 8 * size; } else { prec = offset = 0; } switch (dt->shared->type) { case H5T_INTEGER: case H5T_TIME: case H5T_BITFIELD: case H5T_OPAQUE: /* nothing to check */ break; case H5T_COMPOUND: /* If decreasing size, check the last member isn't being cut. */ if(sizeshared->size) { int num_membs; unsigned i, max_index=0; size_t memb_offset, max_offset=0; size_t max_size; if((num_membs = H5T_get_nmembers(dt))<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to get number of members"); for(i=0; i<(unsigned)num_membs; i++) { memb_offset = H5T_get_member_offset(dt, i); if(memb_offset > max_offset) { max_offset = memb_offset; max_index = i; } } max_size = H5T_get_member_size(dt, max_index); if(size<(max_offset+max_size)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "size shrinking will cut off last member "); } break; case H5T_STRING: /* Convert string to variable-length datatype */ if(size==H5T_VARIABLE) { H5T_t *base = NULL; /* base data type */ H5T_cset_t tmp_cset; /* Temp. cset info */ H5T_str_t tmp_strpad; /* Temp. strpad info */ /* Get a copy of unsigned char type as the base/parent type */ if (NULL==(base=H5I_object(H5T_NATIVE_UCHAR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid base datatype"); dt->shared->parent=H5T_copy(base,H5T_COPY_ALL); /* change this datatype into a VL string */ dt->shared->type = H5T_VLEN; /* * Force conversions (i.e. memory to memory conversions * should duplicate data, not point to the same VL strings) */ dt->shared->force_conv = TRUE; /* Before we mess with the info in the union, extract the * values we need */ tmp_cset=dt->shared->u.atomic.u.s.cset; tmp_strpad=dt->shared->u.atomic.u.s.pad; /* This is a string, not a sequence */ dt->shared->u.vlen.type = H5T_VLEN_STRING; /* Set character set and padding information */ dt->shared->u.vlen.cset = tmp_cset; dt->shared->u.vlen.pad = tmp_strpad; /* Set up VL information */ if (H5T_vlen_mark(dt, NULL, H5T_VLEN_MEMORY)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid VL location"); } else { prec = 8 * size; offset = 0; } /* end else */ break; case H5T_FLOAT: /* * The sign, mantissa, and exponent fields should be adjusted * first when decreasing the size of a floating point type. */ if (dt->shared->u.atomic.u.f.sign >= prec+offset || dt->shared->u.atomic.u.f.epos + dt->shared->u.atomic.u.f.esize > prec+offset || dt->shared->u.atomic.u.f.mpos + dt->shared->u.atomic.u.f.msize > prec+offset) { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "adjust sign, mantissa, and exponent fields first"); } break; case H5T_ENUM: case H5T_VLEN: case H5T_ARRAY: assert("can't happen" && 0); case H5T_REFERENCE: assert("invalid type" && 0); default: assert("not implemented yet" && 0); } /* Commit (if we didn't convert this type to a VL string) */ if(dt->shared->type!=H5T_VLEN) { dt->shared->size = size; if (H5T_IS_ATOMIC(dt->shared)) { dt->shared->u.atomic.offset = offset; dt->shared->u.atomic.prec = prec; } } /* end if */ } done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_get_size * * Purpose: Determines the total size of a data type in bytes. * * Return: Success: Size of the data type in bytes. The size of * the data type is the size of an instance of * that data type. * * Failure: 0 (valid data types are never zero size) * * Programmer: Robb Matzke * Tuesday, December 9, 1997 * * Modifications: * *------------------------------------------------------------------------- */ size_t H5T_get_size(const H5T_t *dt) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_get_size); /* check args */ assert(dt); FUNC_LEAVE_NOAPI(dt->shared->size); } /*------------------------------------------------------------------------- * Function: H5T_cmp * * Purpose: Compares two data types. * * Return: Success: 0 if DT1 and DT2 are equal. * <0 if DT1 is less than DT2. * >0 if DT1 is greater than DT2. * * Failure: 0, never fails * * Programmer: Robb Matzke * Wednesday, December 10, 1997 * * Modifications: * Robb Matzke, 22 Dec 1998 * Able to compare enumeration data types. * * Robb Matzke, 20 May 1999 * Compares bitfields and opaque types. * * Quincey Koziol, 19 Mar 2005 * Allow an enumerated datatypes to compare equal, if the "superset" * flag is set and dt2 has a superset of the enumerated values in dt1 *------------------------------------------------------------------------- */ int H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset) { unsigned *idx1 = NULL, *idx2 = NULL; int ret_value = 0; int i, j; unsigned u; int tmp; hbool_t swapped; size_t base_size; FUNC_ENTER_NOAPI(H5T_cmp, 0); /* the easy case */ if (dt1 == dt2) HGOTO_DONE(0); assert(dt1); assert(dt2); /* compare */ if (dt1->shared->type < dt2->shared->type) HGOTO_DONE(-1); if (dt1->shared->type > dt2->shared->type) HGOTO_DONE(1); if (dt1->shared->size < dt2->shared->size) HGOTO_DONE(-1); if (dt1->shared->size > dt2->shared->size) HGOTO_DONE(1); if (dt1->shared->parent && !dt2->shared->parent) HGOTO_DONE(-1); if (!dt1->shared->parent && dt2->shared->parent) HGOTO_DONE(1); if (dt1->shared->parent) { tmp = H5T_cmp(dt1->shared->parent, dt2->shared->parent, superset); if (tmp<0) HGOTO_DONE(-1); if (tmp>0) HGOTO_DONE(1); } switch(dt1->shared->type) { case H5T_COMPOUND: /* * Compound data types... */ if (dt1->shared->u.compnd.nmembs < dt2->shared->u.compnd.nmembs) HGOTO_DONE(-1); if (dt1->shared->u.compnd.nmembs > dt2->shared->u.compnd.nmembs) HGOTO_DONE(1); /* Build an index for each type so the names are sorted */ if (NULL==(idx1 = H5MM_malloc(dt1->shared->u.compnd.nmembs * sizeof(unsigned))) || NULL==(idx2 = H5MM_malloc(dt2->shared->u.compnd.nmembs * sizeof(unsigned)))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed"); for (u=0; ushared->u.compnd.nmembs; u++) idx1[u] = idx2[u] = u; if(dt1->shared->u.enumer.nmembs > 1) { for (i=dt1->shared->u.compnd.nmembs-1, swapped=TRUE; swapped && i>=0; --i) for (j=0, swapped=FALSE; jshared->u.compnd.memb[idx1[j]].name, dt1->shared->u.compnd.memb[idx1[j+1]].name) > 0) { tmp = idx1[j]; idx1[j] = idx1[j+1]; idx1[j+1] = tmp; swapped = TRUE; } for (i=dt2->shared->u.compnd.nmembs-1, swapped=TRUE; swapped && i>=0; --i) for (j=0, swapped=FALSE; jshared->u.compnd.memb[idx2[j]].name, dt2->shared->u.compnd.memb[idx2[j+1]].name) > 0) { tmp = idx2[j]; idx2[j] = idx2[j+1]; idx2[j+1] = tmp; swapped = TRUE; } } /* end if */ #ifdef H5T_DEBUG /* I don't quite trust the code above yet :-) --RPM */ for (u=0; ushared->u.compnd.nmembs-1; u++) { assert(HDstrcmp(dt1->shared->u.compnd.memb[idx1[u]].name, dt1->shared->u.compnd.memb[idx1[u + 1]].name)); assert(HDstrcmp(dt2->shared->u.compnd.memb[idx2[u]].name, dt2->shared->u.compnd.memb[idx2[u + 1]].name)); } #endif /* Compare the members */ for (u=0; ushared->u.compnd.nmembs; u++) { tmp = HDstrcmp(dt1->shared->u.compnd.memb[idx1[u]].name, dt2->shared->u.compnd.memb[idx2[u]].name); if (tmp < 0) HGOTO_DONE(-1); if (tmp > 0) HGOTO_DONE(1); if (dt1->shared->u.compnd.memb[idx1[u]].offset < dt2->shared->u.compnd.memb[idx2[u]].offset) HGOTO_DONE(-1); if (dt1->shared->u.compnd.memb[idx1[u]].offset > dt2->shared->u.compnd.memb[idx2[u]].offset) HGOTO_DONE(1); if (dt1->shared->u.compnd.memb[idx1[u]].size < dt2->shared->u.compnd.memb[idx2[u]].size) HGOTO_DONE(-1); if (dt1->shared->u.compnd.memb[idx1[u]].size > dt2->shared->u.compnd.memb[idx2[u]].size) HGOTO_DONE(1); tmp = H5T_cmp(dt1->shared->u.compnd.memb[idx1[u]].type, dt2->shared->u.compnd.memb[idx2[u]].type, superset); if (tmp < 0) HGOTO_DONE(-1); if (tmp > 0) HGOTO_DONE(1); } break; case H5T_ENUM: /* * Enumeration data types... */ /* If we are doing a "superset" comparison, dt2 is allowed to have * more members than dt1 */ if(superset) { if (dt1->shared->u.enumer.nmembs > dt2->shared->u.enumer.nmembs) HGOTO_DONE(1); } /* end if */ else { if (dt1->shared->u.enumer.nmembs < dt2->shared->u.enumer.nmembs) HGOTO_DONE(-1); if (dt1->shared->u.enumer.nmembs > dt2->shared->u.enumer.nmembs) HGOTO_DONE(1); } /* end else */ /* Build an index for each type so the names are sorted */ if (NULL==(idx1 = H5MM_malloc(dt1->shared->u.enumer.nmembs * sizeof(unsigned))) || NULL==(idx2 = H5MM_malloc(dt2->shared->u.enumer.nmembs * sizeof(unsigned)))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed"); for (u=0; ushared->u.enumer.nmembs; u++) idx1[u] = u; if(dt1->shared->u.enumer.nmembs > 1) for (i=dt1->shared->u.enumer.nmembs-1, swapped=TRUE; swapped && i>=0; --i) for (j=0, swapped=FALSE; jshared->u.enumer.name[idx1[j]], dt1->shared->u.enumer.name[idx1[j+1]]) > 0) { tmp = idx1[j]; idx1[j] = idx1[j+1]; idx1[j+1] = tmp; swapped = TRUE; } for (u=0; ushared->u.enumer.nmembs; u++) idx2[u] = u; if(dt2->shared->u.enumer.nmembs > 1) for (i=dt2->shared->u.enumer.nmembs-1, swapped=TRUE; swapped && i>=0; --i) for (j=0, swapped=FALSE; jshared->u.enumer.name[idx2[j]], dt2->shared->u.enumer.name[idx2[j+1]]) > 0) { tmp = idx2[j]; idx2[j] = idx2[j+1]; idx2[j+1] = tmp; swapped = TRUE; } #ifdef H5T_DEBUG /* I don't quite trust the code above yet :-) --RPM */ for (u=0; ushared->u.enumer.nmembs-1; u++) { assert(HDstrcmp(dt1->shared->u.enumer.name[idx1[u]], dt1->shared->u.enumer.name[idx1[u+1]])); assert(HDstrcmp(dt2->shared->u.enumer.name[idx2[u]], dt2->shared->u.enumer.name[idx2[u+1]])); } #endif /* Compare the members */ base_size = dt1->shared->parent->shared->size; for (u=0; ushared->u.enumer.nmembs; u++) { unsigned idx = 0; if(superset) { unsigned lt = 0, rt; /* Final, left & right key indices */ int cmp = 1; /* Key comparison value */ /* If a superset is allowed, dt2 may have more members * than dt1, so binary search for matching member name in * dt2 */ rt = dt2->shared->u.enumer.nmembs; while (lt < rt && cmp) { idx = (lt + rt) / 2; /* compare */ if ((cmp = HDstrcmp(dt1->shared->u.enumer.name[idx1[u]], dt2->shared->u.enumer.name[idx2[idx]] ) ) < 0) rt = idx; else lt = idx+1; } /* Leave, if we couldn't find match */ if (cmp) HGOTO_DONE(-1); } /* end if */ else { /* Check for exact member name match when not doing * "superset" comparison */ tmp = HDstrcmp(dt1->shared->u.enumer.name[idx1[u]], dt2->shared->u.enumer.name[idx2[u]]); if (tmp<0) HGOTO_DONE(-1); if (tmp>0) HGOTO_DONE(1); /* Set index value appropriately */ idx = u; } /* end else */ tmp = HDmemcmp(dt1->shared->u.enumer.value+idx1[u]*base_size, dt2->shared->u.enumer.value+idx2[idx]*base_size, base_size); if (tmp<0) HGOTO_DONE(-1); if (tmp>0) HGOTO_DONE(1); } break; case H5T_VLEN: assert(dt1->shared->u.vlen.type>H5T_VLEN_BADTYPE && dt1->shared->u.vlen.typeshared->u.vlen.type>H5T_VLEN_BADTYPE && dt2->shared->u.vlen.typeshared->u.vlen.loc>H5T_VLEN_BADLOC && dt1->shared->u.vlen.locshared->u.vlen.loc>H5T_VLEN_BADLOC && dt2->shared->u.vlen.locshared->u.vlen.type==H5T_VLEN_SEQUENCE && dt2->shared->u.vlen.type==H5T_VLEN_STRING) { HGOTO_DONE(-1); } else if (dt1->shared->u.vlen.type==H5T_VLEN_STRING && dt2->shared->u.vlen.type==H5T_VLEN_SEQUENCE) { HGOTO_DONE(1); } /* Arbitrarily sort VL datatypes in memory before disk */ if (dt1->shared->u.vlen.loc==H5T_VLEN_MEMORY && dt2->shared->u.vlen.loc==H5T_VLEN_DISK) { HGOTO_DONE(-1); } else if (dt1->shared->u.vlen.loc==H5T_VLEN_DISK && dt2->shared->u.vlen.loc==H5T_VLEN_MEMORY) { HGOTO_DONE(1); } /* Don't allow VL types in different files to compare as equal */ if (dt1->shared->u.vlen.f < dt2->shared->u.vlen.f) HGOTO_DONE(-1); if (dt1->shared->u.vlen.f > dt2->shared->u.vlen.f) HGOTO_DONE(1); break; case H5T_OPAQUE: if(dt1->shared->u.opaque.tag && dt2->shared->u.opaque.tag) HGOTO_DONE(HDstrcmp(dt1->shared->u.opaque.tag,dt2->shared->u.opaque.tag)); break; case H5T_ARRAY: if (dt1->shared->u.array.ndims < dt2->shared->u.array.ndims) HGOTO_DONE(-1); if (dt1->shared->u.array.ndims > dt2->shared->u.array.ndims) HGOTO_DONE(1); for (j=0; jshared->u.array.ndims; j++) { if (dt1->shared->u.array.dim[j] < dt2->shared->u.array.dim[j]) HGOTO_DONE(-1); if (dt1->shared->u.array.dim[j] > dt2->shared->u.array.dim[j]) HGOTO_DONE(1); } for (j=0; jshared->u.array.ndims; j++) { if (dt1->shared->u.array.perm[j] < dt2->shared->u.array.perm[j]) HGOTO_DONE(-1); if (dt1->shared->u.array.perm[j] > dt2->shared->u.array.perm[j]) HGOTO_DONE(1); } tmp = H5T_cmp(dt1->shared->parent, dt2->shared->parent, superset); if (tmp < 0) HGOTO_DONE(-1); if (tmp > 0) HGOTO_DONE(1); break; default: /* * Atomic datatypes... */ if (dt1->shared->u.atomic.order < dt2->shared->u.atomic.order) HGOTO_DONE(-1); if (dt1->shared->u.atomic.order > dt2->shared->u.atomic.order) HGOTO_DONE(1); if (dt1->shared->u.atomic.prec < dt2->shared->u.atomic.prec) HGOTO_DONE(-1); if (dt1->shared->u.atomic.prec > dt2->shared->u.atomic.prec) HGOTO_DONE(1); if (dt1->shared->u.atomic.offset < dt2->shared->u.atomic.offset) HGOTO_DONE(-1); if (dt1->shared->u.atomic.offset > dt2->shared->u.atomic.offset) HGOTO_DONE(1); if (dt1->shared->u.atomic.lsb_pad < dt2->shared->u.atomic.lsb_pad) HGOTO_DONE(-1); if (dt1->shared->u.atomic.lsb_pad > dt2->shared->u.atomic.lsb_pad) HGOTO_DONE(1); if (dt1->shared->u.atomic.msb_pad < dt2->shared->u.atomic.msb_pad) HGOTO_DONE(-1); if (dt1->shared->u.atomic.msb_pad > dt2->shared->u.atomic.msb_pad) HGOTO_DONE(1); switch (dt1->shared->type) { case H5T_INTEGER: if (dt1->shared->u.atomic.u.i.sign < dt2->shared->u.atomic.u.i.sign) HGOTO_DONE(-1); if (dt1->shared->u.atomic.u.i.sign > dt2->shared->u.atomic.u.i.sign) HGOTO_DONE(1); break; case H5T_FLOAT: if (dt1->shared->u.atomic.u.f.sign < dt2->shared->u.atomic.u.f.sign) HGOTO_DONE(-1); if (dt1->shared->u.atomic.u.f.sign > dt2->shared->u.atomic.u.f.sign) HGOTO_DONE(1); if (dt1->shared->u.atomic.u.f.epos < dt2->shared->u.atomic.u.f.epos) HGOTO_DONE(-1); if (dt1->shared->u.atomic.u.f.epos > dt2->shared->u.atomic.u.f.epos) HGOTO_DONE(1); if (dt1->shared->u.atomic.u.f.esize < dt2->shared->u.atomic.u.f.esize) HGOTO_DONE(-1); if (dt1->shared->u.atomic.u.f.esize > dt2->shared->u.atomic.u.f.esize) HGOTO_DONE(1); if (dt1->shared->u.atomic.u.f.ebias < dt2->shared->u.atomic.u.f.ebias) HGOTO_DONE(-1); if (dt1->shared->u.atomic.u.f.ebias > dt2->shared->u.atomic.u.f.ebias) HGOTO_DONE(1); if (dt1->shared->u.atomic.u.f.mpos < dt2->shared->u.atomic.u.f.mpos) HGOTO_DONE(-1); if (dt1->shared->u.atomic.u.f.mpos > dt2->shared->u.atomic.u.f.mpos) HGOTO_DONE(1); if (dt1->shared->u.atomic.u.f.msize < dt2->shared->u.atomic.u.f.msize) HGOTO_DONE(-1); if (dt1->shared->u.atomic.u.f.msize > dt2->shared->u.atomic.u.f.msize) HGOTO_DONE(1); if (dt1->shared->u.atomic.u.f.norm < dt2->shared->u.atomic.u.f.norm) HGOTO_DONE(-1); if (dt1->shared->u.atomic.u.f.norm > dt2->shared->u.atomic.u.f.norm) HGOTO_DONE(1); if (dt1->shared->u.atomic.u.f.pad < dt2->shared->u.atomic.u.f.pad) HGOTO_DONE(-1); if (dt1->shared->u.atomic.u.f.pad > dt2->shared->u.atomic.u.f.pad) HGOTO_DONE(1); break; case H5T_TIME: /* order and precision are checked above */ /*void */ break; case H5T_STRING: if (dt1->shared->u.atomic.u.s.cset < dt2->shared->u.atomic.u.s.cset) HGOTO_DONE(-1); if (dt1->shared->u.atomic.u.s.cset > dt2->shared->u.atomic.u.s.cset) HGOTO_DONE(1); if (dt1->shared->u.atomic.u.s.pad < dt2->shared->u.atomic.u.s.pad) HGOTO_DONE(-1); if (dt1->shared->u.atomic.u.s.pad > dt2->shared->u.atomic.u.s.pad) HGOTO_DONE(1); break; case H5T_BITFIELD: /*void */ break; case H5T_REFERENCE: if (dt1->shared->u.atomic.u.r.rtype < dt2->shared->u.atomic.u.r.rtype) HGOTO_DONE(-1); if (dt1->shared->u.atomic.u.r.rtype > dt2->shared->u.atomic.u.r.rtype) HGOTO_DONE(1); switch(dt1->shared->u.atomic.u.r.rtype) { case H5R_OBJECT: case H5R_DATASET_REGION: /* Does this need more to distinguish it? -QAK 11/30/98 */ /*void */ break; default: assert("not implemented yet" && 0); } break; default: assert("not implemented yet" && 0); } break; } /* end switch */ done: if(idx1!=NULL) H5MM_xfree(idx1); if(idx2!=NULL) H5MM_xfree(idx2); FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_path_find * * Purpose: Finds the path which converts type SRC_ID to type DST_ID, * creating a new path if necessary. If FUNC is non-zero then * it is set as the hard conversion function for that path * regardless of whether the path previously existed. Changing * the conversion function of a path causes statistics to be * reset to zero after printing them. The NAME is used only * when creating a new path and is just for debugging. * * If SRC and DST are both null pointers then the special no-op * conversion path is used. This path is always stored as the * first path in the path table. * * Return: Success: Pointer to the path, valid until the path * database is modified. * * Failure: NULL if the path does not exist and no * function can be found to apply to the new * path. * * Programmer: Robb Matzke * Tuesday, January 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ H5T_path_t * H5T_path_find(const H5T_t *src, const H5T_t *dst, const char *name, H5T_conv_t func, hid_t dxpl_id) { int lt, rt; /*left and right edges */ int md; /*middle */ int cmp; /*comparison result */ int old_npaths; /* Previous number of paths in table */ H5T_path_t *table=NULL; /*path existing in the table */ H5T_path_t *path=NULL; /*new path */ H5T_path_t *ret_value; /*return value */ hid_t src_id=-1, dst_id=-1; /*src and dst type identifiers */ int i; /*counter */ int nprint=0; /*lines of output printed */ FUNC_ENTER_NOAPI(H5T_path_find, NULL); assert((!src && !dst) || (src && dst)); /* * Make sure the first entry in the table is the no-op conversion path. */ if (0==H5T_g.npaths) { if (NULL==(H5T_g.path=H5MM_malloc(128*sizeof(H5T_path_t*)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for type conversion path table"); H5T_g.apaths = 128; if (NULL==(H5T_g.path[0]=H5FL_CALLOC(H5T_path_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for no-op conversion path"); HDstrcpy(H5T_g.path[0]->name, "no-op"); H5T_g.path[0]->func = H5T_conv_noop; H5T_g.path[0]->cdata.command = H5T_CONV_INIT; if (H5T_conv_noop(FAIL, FAIL, &(H5T_g.path[0]->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL, dxpl_id)<0) { #ifdef H5T_DEBUG if (H5DEBUG(T)) { fprintf(H5DEBUG(T), "H5T: unable to initialize no-op " "conversion function (ignored)\n"); } #endif H5E_clear(); /*ignore the error*/ } H5T_g.path[0]->is_noop = TRUE; H5T_g.npaths = 1; } /* * Find the conversion path. If source and destination types are equal * then use entry[0], otherwise do a binary search over the * remaining entries. * * Quincey Koziol, 2 July, 1999 * Only allow the no-op conversion to occur if no "force conversion" flags * are set */ if (src->shared->force_conv==FALSE && dst->shared->force_conv==FALSE && 0==H5T_cmp(src, dst, TRUE)) { table = H5T_g.path[0]; cmp = 0; md = 0; } else { lt = md = 1; rt = H5T_g.npaths; cmp = -1; while (cmp && ltsrc, FALSE); if (0==cmp) cmp = H5T_cmp(dst, H5T_g.path[md]->dst, FALSE); if (cmp<0) { rt = md; } else if (cmp>0) { lt = md+1; } else { table = H5T_g.path[md]; } } } /* Keep a record of the number of paths in the table, in case one of the * initialization calls below (hard or soft) causes more entries to be * added to the table - QAK, 1/26/02 */ old_npaths=H5T_g.npaths; /* * If we didn't find the path or if the caller is specifying a new hard * conversion function then create a new path and add the new function to * the path. */ if (!table || func) { if (NULL==(path=H5FL_CALLOC(H5T_path_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for type conversion path"); if (name && *name) { HDstrncpy(path->name, name, (size_t)H5T_NAMELEN); path->name[H5T_NAMELEN-1] = '\0'; } else { HDstrcpy(path->name, "NONAME"); } if ((src && NULL==(path->src=H5T_copy(src, H5T_COPY_ALL))) || (dst && NULL==(path->dst=H5T_copy(dst, H5T_COPY_ALL)))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy data type for conversion path"); } else { path = table; } /* * If a hard conversion function is specified and none is defined for the * path then add it to the path and initialize its conversion data. */ if (func) { assert(path!=table); assert(NULL==path->func); if (path->src && (src_id=H5I_register(H5I_DATATYPE, H5T_copy(path->src, H5T_COPY_ALL)))<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL, "unable to register source conversion type for query"); if (path->dst && (dst_id=H5I_register(H5I_DATATYPE, H5T_copy(path->dst, H5T_COPY_ALL)))<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL, "unable to register destination conversion type for query"); path->cdata.command = H5T_CONV_INIT; if ((func)(src_id, dst_id, &(path->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL, dxpl_id)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to initialize conversion function"); if (src_id>=0) H5I_dec_ref(src_id); if (dst_id>=0) H5I_dec_ref(dst_id); src_id = dst_id = -1; path->func = func; path->is_hard = TRUE; } /* * If the path doesn't have a function by now (because it's a new path * and the caller didn't supply a hard function) then scan the soft list * for an applicable function and add it to the path. This can't happen * for the no-op conversion path. */ assert(path->func || (src && dst)); for (i=H5T_g.nsoft-1; i>=0 && !path->func; --i) { if (src->shared->type!=H5T_g.soft[i].src || dst->shared->type!=H5T_g.soft[i].dst) { continue; } if ((src_id=H5I_register(H5I_DATATYPE, H5T_copy(path->src, H5T_COPY_ALL)))<0 || (dst_id=H5I_register(H5I_DATATYPE, H5T_copy(path->dst, H5T_COPY_ALL)))<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL, "unable to register conversion types for query"); path->cdata.command = H5T_CONV_INIT; if ((H5T_g.soft[i].func) (src_id, dst_id, &(path->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL, dxpl_id)<0) { HDmemset (&(path->cdata), 0, sizeof(H5T_cdata_t)); H5E_clear(); /*ignore the error*/ } else { HDstrcpy (path->name, H5T_g.soft[i].name); path->func = H5T_g.soft[i].func; path->is_hard = FALSE; } H5I_dec_ref(src_id); H5I_dec_ref(dst_id); src_id = dst_id = -1; } if (!path->func) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "no appropriate function for conversion path"); /* Check if paths were inserted into the table through a recursive call * and re-compute the correct location for this path if so. - QAK, 1/26/02 */ if(old_npaths!=H5T_g.npaths) { lt = md = 1; rt = H5T_g.npaths; cmp = -1; while (cmp && ltsrc, FALSE); if (0==cmp) cmp = H5T_cmp(dst, H5T_g.path[md]->dst, FALSE); if (cmp<0) { rt = md; } else if (cmp>0) { lt = md+1; } else { table = H5T_g.path[md]; } } } /* end if */ /* Replace an existing table entry or add a new entry */ if (table && path!=table) { assert(table==H5T_g.path[md]); H5T_print_stats(table, &nprint/*in,out*/); table->cdata.command = H5T_CONV_FREE; if ((table->func)(FAIL, FAIL, &(table->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL, dxpl_id)<0) { #ifdef H5T_DEBUG if (H5DEBUG(T)) { fprintf(H5DEBUG(T), "H5T: conversion function 0x%08lx free " "failed for %s (ignored)\n", (unsigned long)(path->func), path->name); } #endif H5E_clear(); /*ignore the failure*/ } if (table->src) H5T_close(table->src); if (table->dst) H5T_close(table->dst); H5FL_FREE(H5T_path_t,table); table = path; H5T_g.path[md] = path; } else if (path!=table) { assert(cmp); if (H5T_g.npaths >= H5T_g.apaths) { size_t na = MAX(128, 2 * H5T_g.apaths); H5T_path_t **x = H5MM_realloc (H5T_g.path, na*sizeof(H5T_path_t*)); if (!x) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); H5T_g.apaths = (int)na; H5T_g.path = x; } if (cmp>0) md++; HDmemmove(H5T_g.path+md+1, H5T_g.path+md, (H5T_g.npaths-md) * sizeof(H5T_path_t*)); H5T_g.npaths++; H5T_g.path[md] = path; table = path; } /* Set return value */ ret_value = path; done: if (!ret_value && path && path!=table) { if (path->src) H5T_close(path->src); if (path->dst) H5T_close(path->dst); H5FL_FREE(H5T_path_t,path); } if (src_id>=0) H5I_dec_ref(src_id); if (dst_id>=0) H5I_dec_ref(dst_id); FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_path_noop * * Purpose: Is the path the special no-op path? The no-op function can be * set by the application and there might be more than one no-op * path in a multi-threaded application if one thread is using * the no-op path when some other thread changes its definition. * * Return: TRUE/FALSE (can't fail) * * Programmer: Quincey Koziol * Thursday, May 8, 2003 * * Modifications: * *------------------------------------------------------------------------- */ hbool_t H5T_path_noop(const H5T_path_t *p) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_path_noop); assert(p); FUNC_LEAVE_NOAPI(p->is_noop || (p->is_hard && 0==H5T_cmp(p->src, p->dst, FALSE))); } /* end H5T_path_noop() */ /*------------------------------------------------------------------------- * Function: H5T_path_bkg * * Purpose: Get the "background" flag for the conversion path. * * Return: Background flag (can't fail) * * Programmer: Quincey Koziol * Thursday, May 8, 2003 * * Modifications: * *------------------------------------------------------------------------- */ H5T_bkg_t H5T_path_bkg(const H5T_path_t *p) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_path_bkg); assert(p); FUNC_LEAVE_NOAPI(p->cdata.need_bkg); } /* end H5T_path_bkg() */ /*------------------------------------------------------------------------- * Function: H5T_convert * * Purpose: Call a conversion function to convert from source to * destination data type and accumulate timing statistics. * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Tuesday, December 15, 1998 * * Modifications: * Robb Matzke, 1999-06-16 * The timers are updated only if H5T debugging is enabled at * runtime in addition to compile time. * * Robb Matzke, 1999-06-16 * Added support for non-zero strides. If BUF_STRIDE is non-zero * then convert one value at each memory location advancing * BUF_STRIDE bytes each time; otherwise assume both source and * destination values are packed. * * Quincey Koziol, 1999-07-01 * Added dataset transfer properties, to allow custom VL * datatype allocation function to be passed down to VL * conversion routine. * * Robb Matzke, 2000-05-17 * Added the BKG_STRIDE argument which gets passed to all the * conversion functions. If BUF_STRIDE is non-zero then each * data element is at a multiple of BUF_STRIDE bytes in BUF * (on both input and output). If BKG_STRIDE is also set then * the BKG buffer is used in such a way that temporary space * for each element is aligned on a BKG_STRIDE byte boundary. * If either BUF_STRIDE or BKG_STRIDE are zero then the BKG * buffer will be accessed as though it were a packed array * of destination datatype. *------------------------------------------------------------------------- */ herr_t H5T_convert(H5T_path_t *tpath, hid_t src_id, hid_t dst_id, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist) { #ifdef H5T_DEBUG H5_timer_t timer; #endif herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_convert, FAIL); #ifdef H5T_DEBUG if (H5DEBUG(T)) H5_timer_begin(&timer); #endif tpath->cdata.command = H5T_CONV_CONV; if ((tpath->func)(src_id, dst_id, &(tpath->cdata), nelmts, buf_stride, bkg_stride, buf, bkg, dset_xfer_plist)<0) HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "data type conversion failed"); #ifdef H5T_DEBUG if (H5DEBUG(T)) { H5_timer_end(&(tpath->stats.timer), &timer); tpath->stats.ncalls++; tpath->stats.nelmts += nelmts; } #endif done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_entof * * Purpose: Returns a pointer to the entry for a named data type. * * Return: Success: Ptr directly into named data type * * Failure: NULL * * Programmer: Robb Matzke * Friday, June 5, 1998 * * Modifications: * *------------------------------------------------------------------------- */ H5G_entry_t * H5T_entof (H5T_t *dt) { H5G_entry_t *ret_value = NULL; FUNC_ENTER_NOAPI(H5T_entof, NULL); assert (dt); switch (dt->shared->state) { case H5T_STATE_TRANSIENT: case H5T_STATE_RDONLY: case H5T_STATE_IMMUTABLE: HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, NULL, "not a named data type"); case H5T_STATE_NAMED: case H5T_STATE_OPEN: ret_value = &(dt->ent); break; } done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_is_immutable * * Purpose: Check if a datatype is immutable. * * Return: TRUE * * FALSE * * Programmer: Raymond Lu * Friday, Dec 7, 2001 * * Modifications: * *------------------------------------------------------------------------- */ htri_t H5T_is_immutable(const H5T_t *dt) { htri_t ret_value = FALSE; FUNC_ENTER_NOAPI(H5T_is_immutable, FAIL); assert(dt); if(dt->shared->state == H5T_STATE_IMMUTABLE) ret_value = TRUE; done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_is_named * * Purpose: Check if a datatype is named. * * Return: TRUE * * FALSE * * Programmer: Pedro Vicente * Tuesday, Sep 3, 2002 * * Modifications: * *------------------------------------------------------------------------- */ htri_t H5T_is_named(const H5T_t *dt) { htri_t ret_value = FALSE; FUNC_ENTER_NOAPI(H5T_is_named, FAIL); assert(dt); if(dt->shared->state == H5T_STATE_OPEN || dt->shared->state == H5T_STATE_NAMED) ret_value = TRUE; done: FUNC_LEAVE_NOAPI(ret_value); } /*-------------------------------------------------------------------------- NAME H5T_get_ref_type PURPOSE Retrieves the type of reference for a datatype USAGE H5R_type_t H5Tget_ref_type(dt) H5T_t *dt; IN: datatype pointer for the reference datatype RETURNS Success: A reference type defined in H5Rpublic.h Failure: H5R_BADTYPE DESCRIPTION Given a reference datatype object, this function returns the reference type of the datatype. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ H5R_type_t H5T_get_ref_type(const H5T_t *dt) { H5R_type_t ret_value = H5R_BADTYPE; FUNC_ENTER_NOAPI(H5T_get_ref_type, H5R_BADTYPE); assert(dt); if(dt->shared->type==H5T_REFERENCE) ret_value=dt->shared->u.atomic.u.r.rtype; done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5T_get_ref_type() */ /*------------------------------------------------------------------------- * Function: H5T_is_sensible * * Purpose: Determines if a data type is sensible to store on disk * (i.e. not partially initialized) * * Return: Success: TRUE, FALSE * * Failure: Negative * * Programmer: Quincey Koziol * Tuesday, June 11, 2002 * * Modifications: * *------------------------------------------------------------------------- */ htri_t H5T_is_sensible(const H5T_t *dt) { htri_t ret_value; FUNC_ENTER_NOAPI(H5T_is_sensible, FAIL); assert(dt); switch(dt->shared->type) { case H5T_COMPOUND: /* Only allow compound datatypes with at least one member to be stored on disk */ if(dt->shared->u.compnd.nmembs > 0) ret_value=TRUE; else ret_value=FALSE; break; case H5T_ENUM: /* Only allow enum datatypes with at least one member to be stored on disk */ if(dt->shared->u.enumer.nmembs > 0) ret_value=TRUE; else ret_value=FALSE; break; default: /* Assume all other datatype are sensible to store on disk */ ret_value=TRUE; break; } /* end switch */ done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_is_relocatable * * Purpose: Check if a datatype will change between disk and memory. * * Notes: Currently, only variable-length and object references change * between disk & memory (see cases where things are changed in * the H5T_set_loc() code above). * * Return: * One of two values on success: * TRUE - If the location of any vlen types changed * FALSE - If the location of any vlen types is the same * <0 is returned on failure * * Programmer: Quincey Koziol * Thursday, June 24, 2004 * * Modifications: * *------------------------------------------------------------------------- */ htri_t H5T_is_relocatable(const H5T_t *dt) { htri_t ret_value = FALSE; FUNC_ENTER_NOAPI(H5T_is_relocatable, FAIL); assert(dt); if(H5T_detect_class(dt, H5T_VLEN)) ret_value = TRUE; done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5T_is_relocatable() */ /*------------------------------------------------------------------------- * Function: H5T_print_stats * * Purpose: Print statistics about a conversion path. Statistics are * printed only if all the following conditions are true: * * 1. The library was compiled with H5T_DEBUG defined. * 2. Data type debugging is turned on at run time. * 3. The path was called at least one time. * * The optional NPRINT argument keeps track of the number of * conversions paths for which statistics have been shown. If * its value is zero then table headers are printed before the * first line of output. * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Monday, December 14, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5T_print_stats(H5T_path_t UNUSED * path, int UNUSED * nprint/*in,out*/) { #ifdef H5T_DEBUG hsize_t nbytes; char bandwidth[32]; #endif FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_print_stats); #ifdef H5T_DEBUG if (H5DEBUG(T) && path->stats.ncalls>0) { if (nprint && 0==(*nprint)++) { HDfprintf (H5DEBUG(T), "H5T: type conversion statistics:\n"); HDfprintf (H5DEBUG(T), " %-16s %10s %10s %8s %8s %8s %10s\n", "Conversion", "Elmts", "Calls", "User", "System", "Elapsed", "Bandwidth"); HDfprintf (H5DEBUG(T), " %-16s %10s %10s %8s %8s %8s %10s\n", "----------", "-----", "-----", "----", "------", "-------", "---------"); } if(path->src && path->dst) nbytes = MAX (H5T_get_size (path->src), H5T_get_size (path->dst)); else if(path->src) nbytes = H5T_get_size (path->src); else if(path->dst) nbytes = H5T_get_size (path->dst); else nbytes = 0; nbytes *= path->stats.nelmts; H5_bandwidth(bandwidth, (double)nbytes, path->stats.timer.etime); HDfprintf (H5DEBUG(T), " %-16s %10Hd %10d %8.2f %8.2f %8.2f %10s\n", path->name, path->stats.nelmts, path->stats.ncalls, path->stats.timer.utime, path->stats.timer.stime, path->stats.timer.etime, bandwidth); } #endif FUNC_LEAVE_NOAPI(SUCCEED); } /*------------------------------------------------------------------------- * Function: H5T_debug * * Purpose: Prints information about a data type. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Wednesday, January 7, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_debug(const H5T_t *dt, FILE *stream) { const char *s1="", *s2=""; unsigned i; size_t k, base_size; uint64_t tmp; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_debug, FAIL); /* Check args */ assert(dt); assert(stream); switch (dt->shared->type) { case H5T_INTEGER: s1 = "int"; break; case H5T_FLOAT: s1 = "float"; break; case H5T_TIME: s1 = "time"; break; case H5T_STRING: s1 = "str"; break; case H5T_BITFIELD: s1 = "bits"; break; case H5T_OPAQUE: s1 = "opaque"; break; case H5T_COMPOUND: s1 = "struct"; break; case H5T_ENUM: s1 = "enum"; break; default: s1 = ""; break; } switch (dt->shared->state) { case H5T_STATE_TRANSIENT: s2 = "[transient]"; break; case H5T_STATE_RDONLY: s2 = "[constant]"; break; case H5T_STATE_IMMUTABLE: s2 = "[predefined]"; break; case H5T_STATE_NAMED: s2 = "[named,closed]"; break; case H5T_STATE_OPEN: s2 = "[named,open]"; break; } fprintf(stream, "%s%s {nbytes=%lu", s1, s2, (unsigned long)(dt->shared->size)); if (H5T_IS_ATOMIC(dt->shared)) { switch (dt->shared->u.atomic.order) { case H5T_ORDER_BE: s1 = "BE"; break; case H5T_ORDER_LE: s1 = "LE"; break; case H5T_ORDER_VAX: s1 = "VAX"; break; case H5T_ORDER_NONE: s1 = "NONE"; break; default: s1 = "order?"; break; } fprintf(stream, ", %s", s1); if (dt->shared->u.atomic.offset) { fprintf(stream, ", offset=%lu", (unsigned long) (dt->shared->u.atomic.offset)); } if (dt->shared->u.atomic.prec != 8 * dt->shared->size) { fprintf(stream, ", prec=%lu", (unsigned long) (dt->shared->u.atomic.prec)); } switch (dt->shared->type) { case H5T_INTEGER: switch (dt->shared->u.atomic.u.i.sign) { case H5T_SGN_NONE: s1 = "unsigned"; break; case H5T_SGN_2: s1 = NULL; break; default: s1 = "sign?"; break; } if (s1) fprintf(stream, ", %s", s1); break; case H5T_FLOAT: switch (dt->shared->u.atomic.u.f.norm) { case H5T_NORM_IMPLIED: s1 = "implied"; break; case H5T_NORM_MSBSET: s1 = "msbset"; break; case H5T_NORM_NONE: s1 = "no-norm"; break; default: s1 = "norm?"; break; } fprintf(stream, ", sign=%lu+1", (unsigned long) (dt->shared->u.atomic.u.f.sign)); fprintf(stream, ", mant=%lu+%lu (%s)", (unsigned long) (dt->shared->u.atomic.u.f.mpos), (unsigned long) (dt->shared->u.atomic.u.f.msize), s1); fprintf(stream, ", exp=%lu+%lu", (unsigned long) (dt->shared->u.atomic.u.f.epos), (unsigned long) (dt->shared->u.atomic.u.f.esize)); tmp = dt->shared->u.atomic.u.f.ebias >> 32; if (tmp) { size_t hi=(size_t)tmp; size_t lo =(size_t)(dt->shared->u.atomic.u.f.ebias & 0xffffffff); fprintf(stream, " bias=0x%08lx%08lx", (unsigned long)hi, (unsigned long)lo); } else { size_t lo = (size_t)(dt->shared->u.atomic.u.f.ebias & 0xffffffff); fprintf(stream, " bias=0x%08lx", (unsigned long)lo); } break; default: /* No additional info */ break; } } else if (H5T_COMPOUND==dt->shared->type) { /* Compound data type */ for (i=0; ishared->u.compnd.nmembs; i++) { fprintf(stream, "\n\"%s\" @%lu", dt->shared->u.compnd.memb[i].name, (unsigned long) (dt->shared->u.compnd.memb[i].offset)); #ifdef OLD_WAY if (dt->shared->u.compnd.memb[i].ndims) { fprintf(stream, "["); for (j = 0; j < dt->shared->u.compnd.memb[i].ndims; j++) { fprintf(stream, "%s%lu", j ? ", " : "", (unsigned long)(dt->shared->u.compnd.memb[i].dim[j])); } fprintf(stream, "]"); } #endif /* OLD_WAY */ fprintf(stream, " "); H5T_debug(dt->shared->u.compnd.memb[i].type, stream); } fprintf(stream, "\n"); } else if (H5T_ENUM==dt->shared->type) { /* Enumeration data type */ fprintf(stream, " "); H5T_debug(dt->shared->parent, stream); base_size = dt->shared->parent->shared->size; for (i=0; ishared->u.enumer.nmembs; i++) { fprintf(stream, "\n\"%s\" = 0x", dt->shared->u.enumer.name[i]); for (k=0; kshared->u.enumer.value+i*base_size+k)); } } fprintf(stream, "\n"); } else if (H5T_OPAQUE==dt->shared->type) { fprintf(stream, ", tag=\"%s\"", dt->shared->u.opaque.tag); } else { /* Unknown */ fprintf(stream, "unknown class %d\n", (int)(dt->shared->type)); } fprintf(stream, "}"); done: FUNC_LEAVE_NOAPI(ret_value); } xdmf-3.0+git20160803/Utilities/hdf5/H5Ppkg.h0000640000175000017500000001425113003006557020145 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Quincey Koziol * Friday, November 16, 2001 * * Purpose: This file contains declarations which are visible only within * the H5P package. Source files outside the H5P package should * include H5Pprivate.h instead. */ #ifndef H5P_PACKAGE #error "Do not include this file outside the H5P package!" #endif #ifndef _H5Ppkg_H #define _H5Ppkg_H /* * Define this to enable debugging. */ #ifdef NDEBUG # undef H5P_DEBUG #endif /* Get package's private header */ #include "H5Pprivate.h" /* Other private headers needed by this file */ #include "H5SLprivate.h" /* Skip lists */ /* Define enum for type of object that property is within */ typedef enum { H5P_PROP_WITHIN_UNKNOWN=0, /* Property container is unknown */ H5P_PROP_WITHIN_LIST, /* Property is within a list */ H5P_PROP_WITHIN_CLASS /* Property is within a class */ } H5P_prop_within_t; /* Define enum for modifications to class */ typedef enum { H5P_MOD_ERR=(-1), /* Indicate an error */ H5P_MOD_INC_CLS, /* Increment the dependant class count*/ H5P_MOD_DEC_CLS, /* Decrement the dependant class count*/ H5P_MOD_INC_LST, /* Increment the dependant list count*/ H5P_MOD_DEC_LST, /* Decrement the dependant list count*/ H5P_MOD_INC_REF, /* Increment the ID reference count*/ H5P_MOD_DEC_REF, /* Decrement the ID reference count*/ H5P_MOD_MAX /* Upper limit on class modifications */ } H5P_class_mod_t; /* Define structure to hold property information */ typedef struct H5P_genprop_t { /* Values for this property */ char *name; /* Name of property */ size_t size; /* Size of property value */ void *value; /* Pointer to property value */ H5P_prop_within_t type; /* Type of object the property is within */ unsigned shared_name; /* Boolean: whether the name is shared or not */ /* Callback function pointers & info */ H5P_prp_create_func_t create; /* Function to call when a property is created */ H5P_prp_set_func_t set; /* Function to call when a property value is set */ H5P_prp_get_func_t get; /* Function to call when a property value is retrieved */ H5P_prp_delete_func_t del; /* Function to call when a property is deleted */ H5P_prp_copy_func_t copy; /* Function to call when a property is copied */ H5P_prp_compare_func_t cmp; /* Function to call when a property is compared */ H5P_prp_close_func_t close; /* Function to call when a property is closed */ } H5P_genprop_t; /* Define structure to hold class information */ struct H5P_genclass_t { struct H5P_genclass_t *parent; /* Pointer to parent class */ char *name; /* Name of property list class */ size_t nprops; /* Number of properties in class */ unsigned plists; /* Number of property lists that have been created since the last modification to the class */ unsigned classes; /* Number of classes that have been derived since the last modification to the class */ unsigned ref_count; /* Number of oustanding ID's open on this class object */ unsigned internal; /* Whether this class is internal to the library or not */ unsigned deleted; /* Whether this class has been deleted and is waiting for dependent classes & proplists to close */ unsigned revision; /* Revision number of a particular class (global) */ H5SL_t *props; /* Skip list containing properties */ /* Callback function pointers & info */ H5P_cls_create_func_t create_func; /* Function to call when a property list is created */ void *create_data; /* Pointer to user data to pass along to create callback */ H5P_cls_copy_func_t copy_func; /* Function to call when a property list is copied */ void *copy_data; /* Pointer to user data to pass along to copy callback */ H5P_cls_close_func_t close_func; /* Function to call when a property list is closed */ void *close_data; /* Pointer to user data to pass along to close callback */ }; /* Define structure to hold property list information */ struct H5P_genplist_t { H5P_genclass_t *pclass; /* Pointer to class info */ hid_t plist_id; /* Copy of the property list ID (for use in close callback) */ size_t nprops; /* Number of properties in class */ unsigned class_init:1; /* Whether the class initialization callback finished successfully */ H5SL_t *del; /* Skip list containing names of deleted properties */ H5SL_t *props; /* Skip list containing properties */ }; /* Private functions, not part of the publicly documented API */ H5_DLL herr_t H5P_add_prop(H5SL_t *props, H5P_genprop_t *prop); H5_DLL herr_t H5P_access_class(H5P_genclass_t *pclass, H5P_class_mod_t mod); H5_DLL char *H5P_get_class_path(H5P_genclass_t *pclass); H5_DLL H5P_genclass_t *H5P_open_class_path(const char *path); H5_DLL int H5P_tbbt_strcmp(const void *k1, const void *k2, int cmparg); H5_DLL herr_t H5P_close_class(void *_pclass); /* Testing functions */ #ifdef H5P_TESTING H5_DLL char *H5P_get_class_path_test(hid_t pclass_id); H5_DLL hid_t H5P_open_class_path_test(const char *path); #endif /* H5P_TESTING */ #endif /* _H5Ppkg_H */ xdmf-3.0+git20160803/Utilities/hdf5/H5Smpio.c0000640000175000017500000006736513003006557020344 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: rky 980813 * * Purpose: Functions to read/write directly between app buffer and file. * * Beware of the ifdef'ed print statements. * I didn't make them portable. */ #define H5S_PACKAGE /*suppress error about including H5Spkg */ #include "H5private.h" /* Generic Functions */ #include "H5Dprivate.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fprivate.h" /* File access */ #include "H5FDprivate.h" /* File drivers */ #include "H5Iprivate.h" /* IDs */ #include "H5Oprivate.h" /* Object headers */ #include "H5Pprivate.h" /* Property lists */ #include "H5Spkg.h" /* Dataspaces */ #ifdef H5_HAVE_PARALLEL static herr_t H5S_mpio_all_type( const H5S_t *space, size_t elmt_size, /* out: */ MPI_Datatype *new_type, size_t *count, hsize_t *extra_offset, hbool_t *is_derived_type ); static herr_t H5S_mpio_none_type( const H5S_t *space, size_t elmt_size, /* out: */ MPI_Datatype *new_type, size_t *count, hsize_t *extra_offset, hbool_t *is_derived_type ); static herr_t H5S_mpio_hyper_type( const H5S_t *space, size_t elmt_size, /* out: */ MPI_Datatype *new_type, size_t *count, hsize_t *extra_offset, hbool_t *is_derived_type ); static herr_t H5S_mpio_span_hyper_type( const H5S_t *space, size_t elmt_size, /* out: */ MPI_Datatype *new_type, size_t *count, hsize_t *extra_offset, hbool_t *is_derived_type ); static herr_t H5S_obtain_datatype(const hsize_t size[], H5S_hyper_span_t* span,MPI_Datatype *span_type, size_t elmt_size,int dimindex); /*------------------------------------------------------------------------- * Function: H5S_mpio_all_type * * Purpose: Translate an HDF5 "all" selection into an MPI type. * * Return: non-negative on success, negative on failure. * * Outputs: *new_type the MPI type corresponding to the selection * *count how many objects of the new_type in selection * (useful if this is the buffer type for xfer) * *extra_offset Number of bytes of offset within dataset * *is_derived_type 0 if MPI primitive type, 1 if derived * * Programmer: rky 980813 * * Modifications: * * Quincey Koziol, June 18, 2002 * Added 'extra_offset' parameter * *------------------------------------------------------------------------- */ static herr_t H5S_mpio_all_type( const H5S_t *space, size_t elmt_size, /* out: */ MPI_Datatype *new_type, size_t *count, hsize_t *extra_offset, hbool_t *is_derived_type ) { hsize_t total_bytes; hssize_t snelmts; /*total number of elmts (signed) */ hsize_t nelmts; /*total number of elmts */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT(H5S_mpio_all_type); /* Check args */ assert (space); /* Just treat the entire extent as a block of bytes */ if((snelmts = H5S_GET_EXTENT_NPOINTS(space))<0) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "src dataspace has invalid selection") H5_ASSIGN_OVERFLOW(nelmts,snelmts,hssize_t,hsize_t); total_bytes = (hsize_t)elmt_size*nelmts; /* fill in the return values */ *new_type = MPI_BYTE; H5_ASSIGN_OVERFLOW(*count, total_bytes, hsize_t, size_t); *extra_offset = 0; *is_derived_type = 0; done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_mpio_all_type() */ /*------------------------------------------------------------------------- * Function: H5S_mpio_none_type * * Purpose: Translate an HDF5 "none" selection into an MPI type. * * Return: non-negative on success, negative on failure. * * Outputs: *new_type the MPI type corresponding to the selection * *count how many objects of the new_type in selection * (useful if this is the buffer type for xfer) * *extra_offset Number of bytes of offset within dataset * *is_derived_type 0 if MPI primitive type, 1 if derived * * Programmer: Quincey Koziol, October 29, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5S_mpio_none_type( const H5S_t UNUSED *space, size_t UNUSED elmt_size, /* out: */ MPI_Datatype *new_type, size_t *count, hsize_t *extra_offset, hbool_t *is_derived_type ) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_mpio_none_type); /* fill in the return values */ *new_type = MPI_BYTE; *count = 0; *extra_offset = 0; *is_derived_type = 0; FUNC_LEAVE_NOAPI(SUCCEED); } /* H5S_mpio_none_type() */ /*------------------------------------------------------------------------- * Function: H5S_mpio_hyper_type * * Purpose: Translate an HDF5 hyperslab selection into an MPI type. * * Return: non-negative on success, negative on failure. * * Outputs: *new_type the MPI type corresponding to the selection * *count how many objects of the new_type in selection * (useful if this is the buffer type for xfer) * *extra_offset Number of bytes of offset within dataset * *is_derived_type 0 if MPI primitive type, 1 if derived * * Programmer: rky 980813 * * Modifications: ppw 990401 * rky, ppw 2000-09-26 Freed old type after creating struct type. * rky 2000-10-05 Changed displacements to be MPI_Aint. * rky 2000-10-06 Added code for cases of empty hyperslab. * akc, rky 2000-11-16 Replaced hard coded dimension size with * H5S_MAX_RANK. * * Quincey Koziol, June 18, 2002 * Added 'extra_offset' parameter. Also accomodate selection * offset in MPI type built. * * Albert Cheng, August 4, 2004 * Reimplemented the algorithm of forming the outer_type by * defining it as (start, vector, extent) in one call. * *------------------------------------------------------------------------- */ static herr_t H5S_mpio_hyper_type( const H5S_t *space, size_t elmt_size, /* out: */ MPI_Datatype *new_type, size_t *count, hsize_t *extra_offset, hbool_t *is_derived_type ) { H5S_sel_iter_t sel_iter; /* Selection iteration info */ hbool_t sel_iter_init=0; /* Selection iteration info has been initialized */ struct dim { /* less hassle than malloc/free & ilk */ hssize_t start; hsize_t strid; hsize_t block; hsize_t xtent; hsize_t count; } d[H5S_MAX_RANK]; int i; int offset[H5S_MAX_RANK]; int max_xtent[H5S_MAX_RANK]; H5S_hyper_dim_t *diminfo; /* [rank] */ int rank; int block_length[3]; MPI_Datatype inner_type, outer_type, old_types[3]; MPI_Aint extent_len, displacement[3]; int mpi_code; /* MPI return code */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT(H5S_mpio_hyper_type); /* Check args */ assert (space); assert(sizeof(MPI_Aint) >= sizeof(elmt_size)); if (0==elmt_size) goto empty; /* Initialize selection iterator */ if (H5S_select_iter_init(&sel_iter, space, elmt_size)<0) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator"); sel_iter_init=1; /* Selection iteration info has been initialized */ /* Abbreviate args */ diminfo=sel_iter.u.hyp.diminfo; assert (diminfo); /* make a local copy of the dimension info so we can operate with them */ /* Check if this is a "flattened" regular hyperslab selection */ if(sel_iter.u.hyp.iter_rank!=0 && sel_iter.u.hyp.iter_rankextent.rank) { /* Flattened selection */ rank=sel_iter.u.hyp.iter_rank; assert (rank >= 0 && rank<=H5S_MAX_RANK); /* within array bounds */ if (0==rank) goto empty; #ifdef H5Smpi_DEBUG HDfprintf(stderr, "%s: Flattened selection\n",FUNC); #endif for ( i=0; iextent.rank; assert (rank >= 0 && rank<=H5S_MAX_RANK); /* within array bounds */ if (0==rank) goto empty; #ifdef H5Smpi_DEBUG HDfprintf(stderr, "%s: Non-flattened selection\n",FUNC); #endif for ( i=0; iselect.offset[i]; d[i].strid = diminfo[i].stride; d[i].block = diminfo[i].block; d[i].count = diminfo[i].count; d[i].xtent = space->extent.size[i]; #ifdef H5Smpi_DEBUG HDfprintf(stderr, "%s: start=%Hd stride=%Hu count=%Hu block=%Hu xtent=%Hu", FUNC, d[i].start, d[i].strid, d[i].count, d[i].block, d[i].xtent ); if (i==0) HDfprintf(stderr, " rank=%d\n", rank ); else HDfprintf(stderr, "\n" ); #endif if (0==d[i].block) goto empty; if (0==d[i].count) goto empty; if (0==d[i].xtent) goto empty; } } /* end else */ /********************************************************************** Compute array "offset[rank]" which gives the offsets for a multi- dimensional array with dimensions "d[i].xtent" (i=0,1,...,rank-1). **********************************************************************/ offset[rank-1] = 1; max_xtent[rank-1] = d[rank-1].xtent; #ifdef H5Smpi_DEBUG i=rank-1; HDfprintf(stderr, " offset[%2d]=%d; max_xtent[%2d]=%d\n", i, offset[i], i, max_xtent[i]); #endif for (i=rank-2; i>=0; --i) { offset[i] = offset[i+1]*d[i+1].xtent; max_xtent[i] = max_xtent[i+1]*d[i].xtent; #ifdef H5Smpi_DEBUG HDfprintf(stderr, " offset[%2d]=%d; max_xtent[%2d]=%d\n", i, offset[i], i, max_xtent[i]); #endif } /* Create a type covering the selected hyperslab. * Multidimensional dataspaces are stored in row-major order. * The type is built from the inside out, going from the * fastest-changing (i.e., inner) dimension * to the slowest (outer). */ /******************************************************* * Construct contig type for inner contig dims: *******************************************************/ #ifdef H5Smpi_DEBUG HDfprintf(stderr, "%s: Making contig type %d MPI_BYTEs\n", FUNC,elmt_size ); for (i=rank-1; i>=0; --i) HDfprintf(stderr, "d[%d].xtent=%Hu \n", i, d[i].xtent); #endif if (MPI_SUCCESS != (mpi_code= MPI_Type_contiguous( (int)elmt_size, MPI_BYTE, &inner_type ))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code); /******************************************************* * Construct the type by walking the hyperslab dims * from the inside out: *******************************************************/ for ( i=rank-1; i>=0; --i) { #ifdef H5Smpi_DEBUG HDfprintf(stderr, "%s: Dimension i=%d \n" "start=%Hd count=%Hu block=%Hu stride=%Hu, xtent=%Hu max_xtent=%d\n", FUNC, i, d[i].start, d[i].count, d[i].block, d[i].strid, d[i].xtent, max_xtent[i]); #endif #ifdef H5Smpi_DEBUG HDfprintf(stderr, "%s: i=%d Making vector-type \n", FUNC,i); #endif /**************************************** * Build vector type of the selection. ****************************************/ mpi_code =MPI_Type_vector((int)(d[i].count), /* count */ (int)(d[i].block), /* blocklength */ (int)(d[i].strid), /* stride */ inner_type, /* old type */ &outer_type); /* new type */ MPI_Type_free( &inner_type ); if (mpi_code!=MPI_SUCCESS) HMPI_GOTO_ERROR(FAIL, "couldn't create MPI vector type", mpi_code); /**************************************** * Then build the dimension type as (start, vector type, xtent). ****************************************/ /* calculate start and extent values of this dimension */ displacement[1] = d[i].start * offset[i] * elmt_size; displacement[2] = (MPI_Aint)elmt_size * max_xtent[i]; if(MPI_SUCCESS != (mpi_code = MPI_Type_extent(outer_type, &extent_len))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_extent failed", mpi_code); /************************************************* * Restructure this datatype ("outer_type") * so that it still starts at 0, but its extent * is the full extent in this dimension. *************************************************/ if (displacement[1] > 0 || (int)extent_len < displacement[2]) { block_length[0] = 1; block_length[1] = 1; block_length[2] = 1; displacement[0] = 0; old_types[0] = MPI_LB; old_types[1] = outer_type; old_types[2] = MPI_UB; #ifdef H5Smpi_DEBUG HDfprintf(stderr, "%s: i=%d Extending struct type\n" "***displacements: %d, %d, %d\n", FUNC, i, displacement[0], displacement[1], displacement[2]); #endif mpi_code = MPI_Type_struct ( 3, /* count */ block_length, /* blocklengths */ displacement, /* displacements */ old_types, /* old types */ &inner_type); /* new type */ MPI_Type_free (&outer_type); if (mpi_code!=MPI_SUCCESS) HMPI_GOTO_ERROR(FAIL, "couldn't resize MPI vector type", mpi_code); } else { inner_type = outer_type; } } /* end for */ /*************************** * End of loop, walking * thru dimensions. ***************************/ /* At this point inner_type is actually the outermost type, even for 0-trip loop */ *new_type = inner_type; if (MPI_SUCCESS != (mpi_code= MPI_Type_commit( new_type ))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code); /* fill in the remaining return values */ *count = 1; /* only have to move one of these suckers! */ *extra_offset = 0; *is_derived_type = 1; HGOTO_DONE(SUCCEED); empty: /* special case: empty hyperslab */ *new_type = MPI_BYTE; *count = 0; *extra_offset = 0; *is_derived_type = 0; done: /* Release selection iterator */ if(sel_iter_init) { if (H5S_SELECT_ITER_RELEASE(&sel_iter)<0) HDONE_ERROR (H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator"); } /* end if */ #ifdef H5Smpi_DEBUG HDfprintf(stderr, "Leave %s, count=%ld is_derived_type=%d\n", FUNC, *count, *is_derived_type ); #endif FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5S_mpio_span_hyper_type * * Purpose: Translate an HDF5 irregular hyperslab selection into an MPI type. * * Return: non-negative on success, negative on failure. * * Outputs: *new_type the MPI type corresponding to the selection * *count how many objects of the new_type in selection * (useful if this is the buffer type for xfer) * *extra_offset Number of bytes of offset within dataset * *is_derived_type 0 if MPI primitive type, 1 if derived * * Programmer: kyang * */ static herr_t H5S_mpio_span_hyper_type( const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type,/* out: */ size_t *count, hsize_t *extra_offset, hbool_t *is_derived_type ){ MPI_Datatype span_type; H5S_hyper_span_t *ospan; H5S_hyper_span_info_t *odown; hsize_t *size; int rank; int mpi_code; herr_t ret_value = SUCCEED; MPI_Aint extent,lb; FUNC_ENTER_NOAPI_NOINIT(H5S_mpio_span_hyper_type); /* Check args */ assert (space); /* assert(sizeof(MPI_Aint) >= sizeof(elmt_size)); not sure the reason*/ rank = space->extent.rank; /* size = HDcalloc((size_t)rank,sizeof(hsize_t)); */ if (0==elmt_size) goto empty; size = space->extent.size; if(size == 0) goto empty; odown = space->select.sel_info.hslab->span_lst; if(odown == NULL) goto empty; ospan = odown->head; if(ospan == NULL) goto empty; /* obtain derived data type */ if(FAIL == H5S_obtain_datatype(space->extent.size,ospan,&span_type,elmt_size,rank)) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL,"couldn't obtain MPI derived data type"); if (MPI_SUCCESS != (mpi_code = MPI_Type_commit(&span_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code); *new_type = span_type; /* fill in the remaining return values */ *count = 1; *extra_offset = 0; *is_derived_type = 1; HGOTO_DONE(SUCCEED); empty: /* special case: empty hyperslab */ *new_type = MPI_BYTE; *count = 0; *extra_offset = 0; *is_derived_type = 0; done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5S_obtain datatype * * Purpose: Obtain an MPI derived datatype based on span-tree implementation * * Return: non-negative on success, negative on failure. * * Outputs: *span_type the MPI type corresponding to the selection * * Programmer: kyang * */ static herr_t H5S_obtain_datatype(const hsize_t size[], H5S_hyper_span_t* span, MPI_Datatype *span_type, size_t elmt_size, int dimindex) { int innercount,outercount; MPI_Datatype bas_type; MPI_Datatype temp_type; MPI_Datatype tempinner_type; MPI_Datatype *inner_type; int *blocklen; MPI_Aint *disp; MPI_Aint stride; MPI_Aint extent,lb; H5S_hyper_span_info_t *down; H5S_hyper_span_t *tspan; int mpi_code; herr_t ret_value = SUCCEED; #ifdef H5_HAVE_MPI2 MPI_Aint sizeaint,sizedtype; #endif /* H5_HAVE_MPI2 */ hsize_t total_lowd,total_lowd1; int i; int ret; FUNC_ENTER_NOAPI_NOINIT(H5S_obtain_datatype); assert(span); inner_type = NULL; down = NULL; tspan = NULL; down = span->down; tspan = span; outercount = 0; /* obtain the number of span tree for this dimension */ while(tspan) { tspan = tspan->next; outercount ++; } if(outercount == 0) { span_type = NULL; return 0; } /* MPI2 hasn't been widely acccepted, adding H5_HAVE_MPI2 for the future use */ #ifdef H5_HAVE_MPI2 MPI_Type_extent(MPI_Aint,&sizeaint); MPI_Type_extent(MPI_Datatype,&sizedtype); blocklen = (int *)HDcalloc((size_t)outercount,sizeof(int)); disp = (MPI_Aint *)HDcalloc((size_t)outercount,sizeaint); inner_type = (MPI_Datatype *)HDcalloc((size_t)outercount,sizedtype); #else blocklen = (int *)HDcalloc((size_t)outercount,sizeof(int)); disp = (MPI_Aint *)HDcalloc((size_t)outercount,sizeof(MPI_Aint)); inner_type = (MPI_Datatype *)HDcalloc((size_t)outercount,sizeof(MPI_Datatype)); #endif tspan = span; outercount = 0; /* if this is the fastest changing dimension, it is the base case for derived datatype. */ if(down == NULL){ assert(dimindex <= 1); if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous((int)elmt_size, MPI_BYTE,&bas_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code); if(MPI_SUCCESS != (mpi_code = MPI_Type_commit(&bas_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code); while(tspan){ disp[outercount] = (MPI_Aint)elmt_size * tspan->low; blocklen[outercount] = tspan->nelem; tspan = tspan->next; outercount ++; } if(MPI_SUCCESS != (mpi_code = MPI_Type_hindexed(outercount,blocklen, disp,bas_type,span_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_hindexed failed", mpi_code); } else {/* dimindex is the rank of the dimension */ assert(dimindex >1); /* Calculate the total bytes of the lower dimension */ total_lowd = 1; /* one dimension down */ total_lowd1 = 1; /* two dimensions down */ for ( i = dimindex-1; i > 0; i--) total_lowd = total_lowd * size[i]; for ( i = dimindex-1; i > 1; i--) total_lowd1 = total_lowd1 * size[i]; while(tspan){ /* Displacement should be in byte and should have dimension information */ /* First using MPI Type vector to build derived data type for this span only */ /* Need to calculate the disp in byte for this dimension. */ /* Calculate the total bytes of the lower dimension */ disp[outercount] = tspan->low*total_lowd*elmt_size; blocklen[outercount] = 1; /* generating inner derived datatype by using MPI_Type_hvector */ if(FAIL == H5S_obtain_datatype(size,tspan->down->head,&temp_type,elmt_size,dimindex-1)) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL,"couldn't obtain MPI derived data type"); if(MPI_SUCCESS != (mpi_code = MPI_Type_commit(&temp_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code); /* building the inner vector datatype */ stride = total_lowd*elmt_size; innercount = tspan->nelem; if(MPI_SUCCESS != (mpi_code = MPI_Type_hvector(innercount,1,stride,temp_type,&tempinner_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_hvector failed", mpi_code); if(MPI_SUCCESS != (mpi_code = MPI_Type_commit(&tempinner_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code); if(MPI_SUCCESS != (mpi_code =MPI_Type_free(&temp_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_free failed",mpi_code); inner_type[outercount] = tempinner_type; outercount ++; tspan = tspan->next; } /* building the whole vector datatype */ if(MPI_SUCCESS != (mpi_code = MPI_Type_struct(outercount,blocklen,disp,inner_type,span_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_struct failed", mpi_code); } if(inner_type != NULL){ if(down != NULL) { for(i=0;i * Monday, July 26, 1999 * * Purpose: The Virtual File Layer as described in documentation. * This is the greatest common denominator for all types of * storage access whether a file, memory, network, etc. This * layer usually just dispatches the request to an actual * file driver layer. */ #define H5F_PACKAGE /*suppress error about including H5Fpkg */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5FD_init_interface /* Packages needed by this file */ #include "H5private.h" /* Generic Functions */ #include "H5Dprivate.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* File access */ #include "H5FDprivate.h" /* File drivers */ #include "H5FDcore.h" /* Files stored entirely in memory */ #include "H5FDfamily.h" /* File families */ #include "H5FDgass.h" /* Remote files using GASS I/O */ #include "H5FDlog.h" /* sec2 driver with I/O logging (for debugging) */ #include "H5FDmpi.h" /* MPI-based file drivers */ #include "H5FDmulti.h" /* Usage-partitioned file family */ #include "H5FDsec2.h" /* POSIX unbuffered file I/O */ #include "H5FDsrb.h" /* Remote access using SRB */ #include "H5FDstdio.h" /* Standard C buffered I/O */ #include "H5FDstream.h" /* In-memory files streamed via sockets */ #include "H5FLprivate.h" /* Free lists */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Pprivate.h" /* Property lists */ /* static prototypes */ static herr_t H5FD_pl_copy(void *(*copy_func)(const void *), size_t pl_size, const void *old_pl, void **copied_pl); static herr_t H5FD_pl_close(hid_t driver_id, herr_t (*free_func)(void *), void *pl); static herr_t H5FD_free_cls(H5FD_class_t *cls); static haddr_t H5FD_alloc_from_free_list(H5FD_t *file, H5FD_mem_t type, H5FD_mem_t mapped_type, hsize_t size); static haddr_t H5FD_alloc_metadata(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size); static haddr_t H5FD_alloc_raw(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size); static haddr_t H5FD_real_alloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size); static haddr_t H5FD_update_eoa(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size); /* Declare a free list to manage the H5FD_free_t struct */ H5FL_DEFINE(H5FD_free_t); /* Declare a PQ free list to manage the metadata accumulator buffer */ H5FL_BLK_DEFINE_STATIC(meta_accum); /* Local macro definitions */ #define H5FD_ACCUM_THROTTLE 8 #define H5FD_ACCUM_THRESHOLD 2048 /* Static local variables */ /* * Global count of the number of H5FD_t's handed out. This is used as a * "serial number" for files that are currently open and is used for the * 'fileno[2]' field in H5G_stat_t. However, if a VFL driver is not able * to detect whether two files are the same, a file that has been opened * by H5Fopen more than once with that VFL driver will have two different * serial numbers. :-/ * * Also, if a file is opened, the 'fileno[2]' field is retrieved for an * object and the file is closed and re-opened, the 'fileno[2]' value will * be different. */ static unsigned long file_serial_no[2]; /*------------------------------------------------------------------------- * Function: H5FD_init_interface * * Purpose: Initialize the virtual file layer. * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Monday, July 26, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_init_interface(void) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5FD_init_interface) if (H5I_init_group(H5I_VFL, H5I_VFL_HASHSIZE, 0, (H5I_free_t)H5FD_free_cls)<0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize interface") /* Reset the file serial numbers */ HDmemset(file_serial_no,0,sizeof(file_serial_no)); done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_term_interface * * Purpose: Terminate this interface: free all memory and reset global * variables to their initial values. Release all ID groups * associated with this interface. * * Return: Success: Positive if anything was done that might * have affected other interfaces; zero * otherwise. * * Failure: Never fails. * * Programmer: Robb Matzke * Friday, February 19, 1999 * * Modifications: * *------------------------------------------------------------------------- */ int H5FD_term_interface(void) { int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_term_interface) if (H5_interface_initialize_g) { if ((n=H5I_nmembers(H5I_VFL))!=0) { H5I_clear_group(H5I_VFL, FALSE); /* Reset the VFL drivers, if they've been closed */ if(H5I_nmembers(H5I_VFL)==0) { H5FD_sec2_term(); H5FD_log_term(); H5FD_stdio_term(); H5FD_family_term(); #ifdef H5_HAVE_GASS H5FD_gass_term(); #endif #ifdef H5_HAVE_SRB H5FD_srb_term(); #endif H5FD_core_term(); H5FD_multi_term(); #ifdef H5_HAVE_PARALLEL H5FD_mpio_term(); H5FD_mpiposix_term(); #endif /* H5_HAVE_PARALLEL */ #ifdef H5_HAVE_STREAM H5FD_stream_term(); #endif } /* end if */ } else { H5I_destroy_group(H5I_VFL); H5_interface_initialize_g = 0; n = 1; /*H5I*/ } } FUNC_LEAVE_NOAPI(n) } /*------------------------------------------------------------------------- * Function: H5FD_free_cls * * Purpose: Frees a file driver class struct and returns an indication of * success. This function is used as the free callback for the * virtual file layer object identifiers (cf H5FD_init_interface). * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Monday, July 26, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_free_cls(H5FD_class_t *cls) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_free_cls) H5MM_xfree(cls); FUNC_LEAVE_NOAPI(SUCCEED) } /*------------------------------------------------------------------------- * Function: H5FDregister * * Purpose: Registers a new file driver as a member of the virtual file * driver class. Certain fields of the class struct are * required and that is checked here so it doesn't have to be * checked every time the field is accessed. * * Return: Success: A file driver ID which is good until the * library is closed or the driver is * unregistered. * * Failure: A negative value. * * Programmer: Robb Matzke * Monday, July 26, 1999 * * Modifications: * Copied guts of function info H5FD_register * Quincey Koziol * Friday, January 30, 2004 * *------------------------------------------------------------------------- */ hid_t H5FDregister(const H5FD_class_t *cls) { hid_t ret_value; H5FD_mem_t type; FUNC_ENTER_API(H5FDregister, FAIL) H5TRACE1("i","x",cls); /* Check arguments */ if (!cls) HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, FAIL, "null class pointer is disallowed") if (!cls->open || !cls->close) HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, FAIL, "`open' and/or `close' methods are not defined") if (!cls->get_eoa || !cls->set_eoa) HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, FAIL, "`get_eoa' and/or `set_eoa' methods are not defined") if (!cls->get_eof) HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, FAIL, "`get_eof' method is not defined") if (!cls->read || !cls->write) HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, FAIL, "`read' and/or `write' method is not defined") for (type=H5FD_MEM_DEFAULT; typefl_map[type]fl_map[type]>=H5FD_MEM_NTYPES) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid free-list mapping") /* Create the new class ID */ if ((ret_value=H5FD_register(cls, sizeof(H5FD_class_t)))<0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register file driver ID") done: FUNC_LEAVE_API(ret_value) } /* end H5FDregister() */ /*------------------------------------------------------------------------- * Function: H5FD_register * * Purpose: Registers a new file driver as a member of the virtual file * driver class. Certain fields of the class struct are * required and that is checked here so it doesn't have to be * checked every time the field is accessed. * * Return: Success: A file driver ID which is good until the * library is closed or the driver is * unregistered. * * Failure: A negative value. * * Programmer: Robb Matzke * Monday, July 26, 1999 * * Modifications: * Broke into public and internal routines & added 'size' * parameter to internal routine, which allows us to create * sub-classes of H5FD_class_t for internal support (see the * MPI drivers, etc.) * Quincey Koziol * January 30, 2004 * *------------------------------------------------------------------------- */ hid_t H5FD_register(const void *_cls, size_t size) { hid_t ret_value; const H5FD_class_t *cls=(const H5FD_class_t *)_cls; H5FD_class_t *saved=NULL; H5FD_mem_t type; FUNC_ENTER_NOAPI(H5FD_register, FAIL) /* Check arguments */ assert(cls); assert(cls->open && cls->close); assert(cls->get_eoa && cls->set_eoa); assert(cls->get_eof); assert(cls->read && cls->write); for (type=H5FD_MEM_DEFAULT; typefl_map[type]>=H5FD_MEM_NOLIST && cls->fl_map[type]cls); if (file->cls->sb_size) ret_value = (file->cls->sb_size)(file); done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_sb_encode * * Purpose: Encode driver-specific data into the output arguments. The * NAME is a nine-byte buffer which should get an * eight-character driver name and/or version followed by a null * terminator. The BUF argument is a buffer to receive the * encoded driver-specific data. The size of the BUF array is * the size returned by the H5FD_sb_size() call. * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Monday, August 16, 1999 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5FD_sb_encode(H5FD_t *file, char *name/*out*/, uint8_t *buf) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_sb_encode, FAIL) assert(file && file->cls); if (file->cls->sb_encode && (file->cls->sb_encode)(file, name/*out*/, buf/*out*/)<0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver sb_encode request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_sb_decode * * Purpose: Decodes the driver information block. * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Monday, August 16, 1999 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5FD_sb_decode(H5FD_t *file, const char *name, const uint8_t *buf) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_sb_decode, FAIL) assert(file && file->cls); if (file->cls->sb_decode && (file->cls->sb_decode)(file, name, buf)<0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver sb_decode request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_pl_copy * * Purpose: Copies the driver-specific part of the a property list. * This is common code, used by both the dataset transfer and * file access property list routines. * * Return: Success: non-negative * * Failure: negative * * Programmer: Quincey Koziol * Thursday, October 23, 2003 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_pl_copy(void *(*copy_func)(const void *), size_t pl_size, const void *old_pl, void **copied_pl) { void *new_pl = NULL; /* Copy of property list */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5FD_pl_copy) /* Copy old pl, if one exists */ if (old_pl) { /* Allow the driver to copy or do it ourselves */ if (copy_func) { new_pl = (copy_func)(old_pl); } else if (pl_size>0) { if((new_pl = H5MM_malloc(pl_size))==NULL) HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, FAIL, "property list allocation failed") HDmemcpy(new_pl, old_pl, pl_size); } else HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, FAIL, "no way to copy driver property list") } /* end if */ /* Set copied value */ *copied_pl=new_pl; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_pl_copy() */ /*------------------------------------------------------------------------- * Function: H5FD_pl_close * * Purpose: Closes a driver for a property list * This is common code, used by both the dataset transfer and * file access property list routines. * * Return: Success: non-negative * Failure: negative * * Programmer: Quincey Koziol * Thursday, October 23, 2003 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_pl_close(hid_t driver_id, herr_t (*free_func)(void *), void *pl) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5FD_pl_close) /* Allow driver to free or do it ourselves */ if (pl && free_func) { if ((free_func)(pl)<0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver free request failed") } else H5MM_xfree(pl); /* Decrement reference count for driver */ if(H5I_dec_ref(driver_id)<0) HGOTO_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't decrement reference count for driver") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_pl_close() */ /*------------------------------------------------------------------------- * Function: H5FD_fapl_get * * Purpose: Gets the file access property list associated with a file. * Usually the file will copy what it needs from the original * file access property list when the file is created. The * purpose of this function is to create a new file access * property list based on the settings in the file, which may * have been modified from the original file access property * list. * * Return: Success: Pointer to a new file access property list * with all members copied. If the file is * closed then this property list lives on, and * vice versa. * * Failure: NULL, including when the file has no * properties. * * Programmer: Robb Matzke * Friday, August 13, 1999 * * Modifications: * *------------------------------------------------------------------------- */ void * H5FD_fapl_get(H5FD_t *file) { void *ret_value=NULL; FUNC_ENTER_NOAPI(H5FD_fapl_get, NULL) assert(file); if (file->cls->fapl_get) ret_value = (file->cls->fapl_get)(file); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_fapl_get() */ /*------------------------------------------------------------------------- * Function: H5FD_fapl_open * * Purpose: Mark a driver as used by a file access property list * * Return: Success: non-negative * * Failure: negative * * Programmer: Quincey Koziol * Thursday, October 23, 2003 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5FD_fapl_open(H5P_genplist_t *plist, hid_t driver_id, const void *driver_info) { void *copied_driver_info; /* Temporary VFL driver info */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_fapl_open, FAIL) /* Increment the reference count on driver and copy driver info */ if(H5I_inc_ref(driver_id)<0) HGOTO_ERROR(H5E_FILE, H5E_CANTINC, FAIL, "unable to increment ref count on VFL driver") if(H5FD_fapl_copy(driver_id, driver_info, &copied_driver_info)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy VFL driver info") /* Set the driver properties for the list */ if(H5P_set(plist, H5F_ACS_FILE_DRV_ID_NAME, &driver_id) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set driver ID") if(H5P_set(plist, H5F_ACS_FILE_DRV_INFO_NAME, &copied_driver_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set driver info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_fapl_open() */ /*------------------------------------------------------------------------- * Function: H5FD_fapl_copy * * Purpose: Copies the driver-specific part of the file access property * list. * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Tuesday, August 3, 1999 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5FD_fapl_copy(hid_t driver_id, const void *old_fapl, void **copied_fapl) { H5FD_class_t *driver=NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_fapl_copy, FAIL) /* Check args */ if (NULL==(driver=H5I_object(driver_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a driver ID") /* Copy the file access property list */ if(H5FD_pl_copy(driver->fapl_copy,driver->fapl_size,old_fapl,copied_fapl)<0) HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, FAIL, "can't copy driver file access property list") done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_fapl_close * * Purpose: Closes a driver for a dataset transfer property list * * Return: Success: non-negative * Failure: negative * * Programmer: Robb Matzke * Tuesday, August 3, 1999 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5FD_fapl_close(hid_t driver_id, void *fapl) { H5FD_class_t *driver=NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_fapl_close, FAIL) /* Check args */ if(driver_id>0) { if (NULL==(driver=H5I_object(driver_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a driver ID") /* Close the driver for the property list */ if(H5FD_pl_close(driver_id,driver->fapl_free,fapl)<0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver fapl_free request failed") } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_fapl_close() */ /*------------------------------------------------------------------------- * Function: H5FD_dxpl_open * * Purpose: Mark a driver as used by a data transfer property list * * Return: Success: non-negative * * Failure: negative * * Programmer: Quincey Koziol * Thursday, October 23, 2003 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5FD_dxpl_open(H5P_genplist_t *plist, hid_t driver_id, const void *driver_info) { void *copied_driver_info; /* Temporary VFL driver info */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_dxpl_open, FAIL) /* Increment the reference count on the driver and copy the driver info */ if(H5I_inc_ref(driver_id)<0) HGOTO_ERROR (H5E_DATASET, H5E_CANTINC, FAIL, "can't increment VFL driver ID") if(H5FD_dxpl_copy(driver_id, driver_info, &copied_driver_info)<0) HGOTO_ERROR (H5E_DATASET, H5E_CANTCOPY, FAIL, "can't copy VFL driver") /* Set the driver information for the new property list */ if(H5P_set(plist, H5D_XFER_VFL_ID_NAME, &driver_id)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTSET, FAIL, "can't set VFL driver ID") if(H5P_set(plist, H5D_XFER_VFL_INFO_NAME, &copied_driver_info)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTSET, FAIL, "can't set VFL driver info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_dxpl_open() */ /*------------------------------------------------------------------------- * Function: H5FD_dxpl_copy * * Purpose: Copies the driver-specific part of the data transfer property * list. * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Tuesday, August 3, 1999 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5FD_dxpl_copy(hid_t driver_id, const void *old_dxpl, void **copied_dxpl) { H5FD_class_t *driver=NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_dxpl_copy, FAIL) /* Check args */ if (NULL==(driver=H5I_object(driver_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a driver ID") /* Copy the file access property list */ if(H5FD_pl_copy(driver->dxpl_copy,driver->dxpl_size,old_dxpl,copied_dxpl)<0) HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, FAIL, "can't copy driver data transfer property list") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_dxpl_copy() */ /*------------------------------------------------------------------------- * Function: H5FD_dxpl_close * * Purpose: Closes a driver for a dataset transfer property list * * Return: Success: non-negative * Failure: negative * * Programmer: Robb Matzke * Tuesday, August 3, 1999 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5FD_dxpl_close(hid_t driver_id, void *dxpl) { H5FD_class_t *driver=NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_dxpl_close, FAIL) /* Check args */ if(driver_id>0) { if (NULL==(driver=H5I_object(driver_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a driver ID") /* Close the driver for the property list */ if(H5FD_pl_close(driver_id,driver->dxpl_free,dxpl)<0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver fapl_free request failed") } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_dxpl_close() */ /*------------------------------------------------------------------------- * Function: H5FDopen * * Purpose: Opens a file named NAME for the type(s) of access described * by the bit vector FLAGS according to a file access property * list FAPL_ID (which may be the constant H5P_DEFAULT). The * file should expect to handle format addresses in the range [0, * MAXADDR] (if MAXADDR is the undefined address then the caller * doesn't care about the address range). * * Possible values for the FLAGS bits are: * * H5F_ACC_RDWR: Open the file for read and write access. If * this bit is not set then open the file for * read only access. It is permissible to open a * file for read and write access when only read * access is requested by the library (the * library will never attempt to write to a file * which it opened with only read access). * * H5F_ACC_CREATE: Create the file if it doesn't already exist. * However, see H5F_ACC_EXCL below. * * H5F_ACC_TRUNC: Truncate the file if it already exists. This * is equivalent to deleting the file and then * creating a new empty file. * * H5F_ACC_EXCL: When used with H5F_ACC_CREATE, if the file * already exists then the open should fail. * Note that this is unsupported/broken with * some file drivers (e.g., sec2 across nfs) and * will contain a race condition when used to * perform file locking. * * The MAXADDR is the maximum address which will be requested by * the library during an allocation operation. Usually this is * the same value as the MAXADDR field of the class structure, * but it can be smaller if the driver is being used under some * other driver. * * Note that when the driver `open' callback gets control that * the public part of the file struct (the H5FD_t part) will be * incomplete and will be filled in after that callback returns. * * Return: Success: Pointer to a new file driver struct. * * Failure: NULL * * Programmer: Robb Matzke * Tuesday, July 27, 1999 * * Modifications: * *------------------------------------------------------------------------- */ H5FD_t * H5FDopen(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { H5FD_t *ret_value=NULL; FUNC_ENTER_API(H5FDopen, NULL) /* Check arguments */ if(H5P_DEFAULT == fapl_id) fapl_id = H5P_FILE_ACCESS_DEFAULT; else if (TRUE!=H5P_isa_class(fapl_id,H5P_FILE_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") if (NULL==(ret_value=H5FD_open(name, flags, fapl_id, maxaddr))) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, NULL, "unable to open file") done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_open * * Purpose: Private version of H5FDopen() * * Return: Success: Pointer to a new file driver struct * * Failure: NULL * * Programmer: Robb Matzke * Wednesday, August 4, 1999 * * Modifications: * * Raymond Lu * Tuesday, Oct 23, 2001 * Changed the file access list to the new generic property * list. * *------------------------------------------------------------------------- */ H5FD_t * H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { H5FD_class_t *driver; H5FD_t *file=NULL; hid_t driver_id = -1; hsize_t meta_block_size=0; hsize_t sdata_block_size=0; H5P_genplist_t *plist; /* Property list pointer */ H5FD_t *ret_value; FUNC_ENTER_NOAPI(H5FD_open, NULL) /* Get file access property list */ if(NULL == (plist = H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") if (0==maxaddr) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "zero format address range") if(H5P_get(plist, H5F_ACS_FILE_DRV_ID_NAME, &driver_id) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get driver ID") /* Get driver info */ if (NULL==(driver=H5I_object(driver_id))) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, NULL, "invalid driver ID in file access property list") if (NULL==driver->open) HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, NULL, "file driver has no `open' method") /* Dispatch to file driver */ if (HADDR_UNDEF==maxaddr) maxaddr = driver->maxaddr; if (NULL==(file=(driver->open)(name, flags, fapl_id, maxaddr))) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, NULL, "open failed") /* * Fill in public fields. We must increment the reference count on the * driver ID to prevent it from being freed while this file is open. */ file->driver_id = driver_id; if(H5I_inc_ref(file->driver_id)<0) HGOTO_ERROR(H5E_VFL, H5E_CANTINC, NULL, "unable to increment ref count on VFL driver") file->cls = driver; file->maxaddr = maxaddr; file->reserved_alloc = 0; HDmemset(file->fl, 0, sizeof(file->fl)); if(H5P_get(plist, H5F_ACS_META_BLOCK_SIZE_NAME, &(meta_block_size)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get meta data block size") file->def_meta_block_size = meta_block_size; if(H5P_get(plist, H5F_ACS_SDATA_BLOCK_SIZE_NAME, &(sdata_block_size)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get 'small data' block size") file->def_sdata_block_size = sdata_block_size; file->accum_loc = HADDR_UNDEF; if(H5P_get(plist, H5F_ACS_ALIGN_THRHD_NAME, &(file->threshold)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get alignment threshold") if(H5P_get(plist, H5F_ACS_ALIGN_NAME, &(file->alignment)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get alignment") /* Retrieve the VFL driver feature flags */ if (H5FD_query(file, &(file->feature_flags))<0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, NULL, "unable to query file driver") /* Increment the global serial number & assign it to this H5FD_t object */ if(++file_serial_no[0]==0) { /* (Just error out if we wrap both numbers around for now...) */ if(++file_serial_no[1]==0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, NULL, "unable to get file serial number") } /* end if */ HDmemcpy(file->fileno,file_serial_no,sizeof(file_serial_no)); /* Set return value */ ret_value=file; done: /* Can't cleanup 'file' information, since we don't know what type it is */ FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FDclose * * Purpose: Closes the file by calling the driver `close' callback, which * should free all driver-private data and free the file struct. * Note that the public part of the file struct (the H5FD_t part) * will be all zero during the driver close callback like during * the `open' callback. * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Tuesday, July 27, 1999 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5FDclose(H5FD_t *file) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5FDclose, FAIL) H5TRACE1("e","x",file); if (!file || !file->cls) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file pointer") if (H5FD_close(file)<0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to close file") done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_close * * Purpose: Private version of H5FDclose() * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Wednesday, August 4, 1999 * * Modifications: * Robb Matzke, 2000-11-10 * Removed a call to set *file to all zero because the struct * has already been freed by the close method. This fixes a write * to freed memory. * * Bill Wendling, 2003-02-17 * Split out the freeing of the freelist from this function * so that the Flexible PHDF5 stuff can call it without * having to call H5FD_close(). *------------------------------------------------------------------------- */ herr_t H5FD_close(H5FD_t *file) { const H5FD_class_t *driver; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5FD_close, FAIL) /* check args */ assert(file && file->cls); /* Free the freelist (this call never fails) */ (void)H5FD_free_freelist(file); /* Prepare to close file by clearing all public fields */ driver = file->cls; if(H5I_dec_ref(file->driver_id)<0) HGOTO_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't close driver ID") /* * Dispatch to the driver for actual close. If the driver fails to * close the file then the file will be in an unusable state. */ assert(driver->close); if ((driver->close)(file) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "close failed") done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_free_freelist * Purpose: Split off from H5FD_close(). Free the elements in the * free list for this file driver. * Return: Success: SUCCEED * Failure: Never fails * Programmer: Bill Wendling * 17. February 2003 * Modifications: *------------------------------------------------------------------------- */ herr_t H5FD_free_freelist(H5FD_t *file) { H5FD_mem_t i; #ifdef H5F_DEBUG unsigned nblocks = 0; hsize_t nbytes = 0; #endif /* H5F_DEBUG */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5FD_free_freelist, FAIL) /* check args */ assert(file && file->cls); /* * Free all free-lists, leaking any memory thus described. Also leaks * file space allocated but not used when metadata aggregation is * turned on. */ for (i = H5FD_MEM_DEFAULT; i < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, i)) { H5FD_free_t *cur, *next; for (cur = file->fl[i]; cur; cur = next) { #ifdef H5F_DEBUG ++nblocks; nbytes += cur->size; #endif /* H5F_DEBUG */ next = cur->next; H5FL_FREE(H5FD_free_t, cur); } file->fl[i] = NULL; } #ifdef H5F_DEBUG if (nblocks && H5DEBUG(F)) HDfprintf(H5DEBUG(F), "H5F: leaked %Hu bytes of file memory in %u blocks\n", nbytes, nblocks); #endif /* H5F_DEBUG */ /* Check if we need to reset the metadata accumulator information */ if (file->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) { /* Free the buffer */ if (file->meta_accum) file->meta_accum = H5FL_BLK_FREE(meta_accum, file->meta_accum); /* Reset the buffer sizes & location */ file->accum_buf_size = file->accum_size = 0; file->accum_loc = HADDR_UNDEF; file->accum_dirty = 0; } done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FDcmp * * Purpose: Compare the keys of two files using the file driver callback * if the files belong to the same driver, otherwise sort the * files by driver class pointer value. * * Return: Success: A value like strcmp() * * Failure: Must never fail. If both file handles are * invalid then they compare equal. If one file * handle is invalid then it compares less than * the other. If both files belong to the same * driver and the driver doesn't provide a * comparison callback then the file pointers * themselves are compared. * * Programmer: Robb Matzke * Tuesday, July 27, 1999 * * Modifications: * *------------------------------------------------------------------------- */ int H5FDcmp(const H5FD_t *f1, const H5FD_t *f2) { int ret_value; FUNC_ENTER_API(H5FDcmp, -1) /*return value is arbitrary*/ H5TRACE2("Is","xx",f1,f2); ret_value = H5FD_cmp(f1, f2); done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_cmp * * Purpose: Private version of H5FDcmp() * * Return: Success: A value like strcmp() * * Failure: Must never fail. * * Programmer: Robb Matzke * Wednesday, August 4, 1999 * * Modifications: * *------------------------------------------------------------------------- */ int H5FD_cmp(const H5FD_t *f1, const H5FD_t *f2) { int ret_value; FUNC_ENTER_NOAPI(H5FD_cmp, -1) /*return value is arbitrary*/ if ((!f1 || !f1->cls) && (!f2 || !f2->cls)) HGOTO_DONE(0) if (!f1 || !f1->cls) HGOTO_DONE(-1) if (!f2 || !f2->cls) HGOTO_DONE(1) if (f1->cls < f2->cls) HGOTO_DONE(-1) if (f1->cls > f2->cls) HGOTO_DONE(1) /* Files are same driver; no cmp callback */ if (!f1->cls->cmp) { if (f1f2) HGOTO_DONE(1) HGOTO_DONE(0) } ret_value = (f1->cls->cmp)(f1, f2); done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FDquery * * Purpose: Query a VFL driver for its feature flags. (listed in H5FDpublic.h) * * Return: Success: non-negative * * Failure: negative * * Programmer: Quincey Koziol * Friday, August 25, 2000 * * Modifications: * *------------------------------------------------------------------------- */ int H5FDquery(const H5FD_t *f, unsigned long *flags/*out*/) { int ret_value; FUNC_ENTER_API(H5FDquery, FAIL) H5TRACE2("Is","xx",f,flags); assert(f); assert(flags); ret_value = H5FD_query(f, flags); done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_query * * Purpose: Private version of H5FDquery() * * Return: Success: non-negative * * Failure: negative * * Programmer: Quincey Koziol * Friday, August 25, 2000 * * Modifications: * *------------------------------------------------------------------------- */ int H5FD_query(const H5FD_t *f, unsigned long *flags/*out*/) { int ret_value=0; FUNC_ENTER_NOAPI(H5FD_query, FAIL) assert(f); assert(flags); /* Check for query driver and call it */ if (f->cls->query) ret_value = (f->cls->query)(f, flags); else *flags=0; done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FDalloc * * Purpose: Allocates SIZE bytes of memory from the FILE. The memory will * be used according to the allocation class TYPE. First we try * to satisfy the request from one of the free lists, according * to the free list map provided by the driver. The free list * array has one entry for each request type and the value of * that array element can be one of four possibilities: * * It can be the constant H5FD_MEM_DEFAULT (or zero) which * indicates that the identity mapping is used. In other * words, the request type maps to its own free list. * * It can be the request type itself, which has the same * effect as the H5FD_MEM_DEFAULT value above. * * It can be the ID for another request type, which * indicates that the free list for the specified type * should be used instead. * * It can be the constant H5FD_MEM_NOLIST which means that * no free list should be used for this type of request. * * If the request cannot be satisfied from a free list then * either the driver's `alloc' callback is invoked (if one was * supplied) or the end-of-address marker is extended. The * `alloc' callback is always called with the same arguments as * the H5FDalloc(). * * Return: Success: The format address of the new file memory. * * Failure: The undefined address HADDR_UNDEF * * Programmer: Robb Matzke * Tuesday, July 27, 1999 * * Modifications: * *------------------------------------------------------------------------- */ haddr_t H5FDalloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size) { haddr_t ret_value = HADDR_UNDEF; FUNC_ENTER_API(H5FDalloc, HADDR_UNDEF) H5TRACE4("a","xMtih",file,type,dxpl_id,size); /* Check args */ if (!file || !file->cls) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "invalid file pointer") if (type=H5FD_MEM_NTYPES) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "invalid request type") if (size==0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "zero-size request") if (H5P_DEFAULT == dxpl_id) dxpl_id= H5P_DATASET_XFER_DEFAULT; else if (TRUE!=H5P_isa_class(dxpl_id,H5P_DATASET_XFER)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, HADDR_UNDEF, "not a data transfer property list") /* Do the real work */ if (HADDR_UNDEF==(ret_value=H5FD_alloc(file, type, dxpl_id, size))) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "unable to allocate file memory") done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_alloc * Purpose: Private version of H5FDalloc(). * * Return: Success: The format address of the new file memory. * Failure: The undefined address HADDR_UNDEF * Programmer: Robb Matzke * Wednesday, August 4, 1999 * Modifications: * Albert Cheng, 2001/05/01 * Implement the allocation by alignment/threshold. * * Bill Wendling, 2002/12/02 * Split apart into subfunctions for each separate task. * *------------------------------------------------------------------------- */ haddr_t H5FD_alloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size) { H5FD_mem_t mapped_type; haddr_t ret_value = HADDR_UNDEF; FUNC_ENTER_NOAPI(H5FD_alloc, HADDR_UNDEF) /* check args */ assert(file); assert(file->cls); assert(type >= H5FD_MEM_DEFAULT && type < H5FD_MEM_NTYPES); assert(size > 0); #ifdef H5F_DEBUG if (H5DEBUG(F)) HDfprintf(H5DEBUG(F), "%s: alignment=%Hd, threshold=%Hd, size=%Hd\n", FUNC, file->alignment, file->threshold, size); #endif /* H5F_DEBUG */ /* Map the allocation request to a free list */ if (H5FD_MEM_DEFAULT == file->cls->fl_map[type]) mapped_type = type; else mapped_type = file->cls->fl_map[type]; /* Try to allocate from the free list first */ if ((ret_value = H5FD_alloc_from_free_list(file, type, mapped_type, size)) != HADDR_UNDEF) HGOTO_DONE(ret_value) #ifdef H5F_DEBUG if (H5DEBUG(F)) HDfprintf(H5DEBUG(F), "%s: Could not allocate from freelists\n", FUNC); #endif /* H5F_DEBUG */ if (type != H5FD_MEM_DRAW) { /* Handle metadata differently from "raw" data */ if ((ret_value = H5FD_alloc_metadata(file, type, dxpl_id, size)) == HADDR_UNDEF) HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, HADDR_UNDEF, "can't allocate for metadata") } else { /* Allocate "raw" data */ if ((ret_value = H5FD_alloc_raw(file, type, dxpl_id, size)) == HADDR_UNDEF) HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, HADDR_UNDEF, "can't allocate for raw data") } done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_alloc_from_free_list * Purpose: Try to allocate SIZE bytes of memory from the free list * if possible. * * This is split from H5FD_alloc(). * Return: Success: The format address of the new file memory. * Failure: The undefined address HADDR_UNDEF * Programmer: Bill Wendling * 02. December, 2002 * Modifications: *------------------------------------------------------------------------- */ static haddr_t H5FD_alloc_from_free_list(H5FD_t *file, H5FD_mem_t type, H5FD_mem_t mapped_type, hsize_t size) { haddr_t ret_value = HADDR_UNDEF; FUNC_ENTER_NOAPI(H5FD_alloc_from_free_list, HADDR_UNDEF) assert(file); assert(type >= H5FD_MEM_DEFAULT && type < H5FD_MEM_NTYPES); assert(size > 0); /* * Try to satisfy the request from the free list. Only perform the * search if the free list has the potential of satisfying the * request. * * Here, aligned requests are requests that are >= threshold and * alignment > 1. * * For non-aligned request, first try to find an exact match, * otherwise use the best match which is the smallest size that meets * the requested size. * * For aligned address request, find a block in the following order * of preferences: * * 1. block address is aligned and exact match in size; * 2. block address is aligned with smallest size > requested size; * 3. block address is not aligned with smallest size >= requested size. */ if (mapped_type >= H5FD_MEM_DEFAULT && (file->maxsize == 0 || size <= file->maxsize)) { H5FD_free_t *prev = NULL, *best = NULL; H5FD_free_t *cur = file->fl[mapped_type]; int found_aligned = 0; int need_aligned; hsize_t head; need_aligned = file->alignment > 1 && size >= file->threshold; while (cur) { file->maxsize = MAX(file->maxsize, cur->size); if (need_aligned) { if ((head = cur->addr % file->alignment) == 0) { /* * Aligned address */ if (cur->size == size) { /* exact match */ ret_value = cur->addr; /* * Make certain we don't hand out a block of raw data * from the free list which overlaps with the metadata * aggregation buffer (if it's turned on) */ if (type == H5FD_MEM_DRAW && (file->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) && H5F_addr_overlap(ret_value, size, file->accum_loc, file->accum_size)) { ret_value = HADDR_UNDEF; } else { if (prev) prev->next = cur->next; else file->fl[mapped_type] = cur->next; H5FL_FREE(H5FD_free_t, cur); if (size == file->maxsize) file->maxsize = 0; /*unknown*/ HGOTO_DONE(ret_value) } } if (cur->size > size) if (!best || !found_aligned || cur->size < best->size) { best = cur; found_aligned = 1; } } else { /* * Non-aligned address * * Check to see if this block is big enough to skip * to the next aligned address and is still big * enough for the requested size. the extra * cur->size>head is for preventing unsigned * underflow. (this can be improved by checking for * an exact match after excluding the head. Such * match is as good as the found_aligned case above.) */ head = file->alignment - head; /* actual head size */ if (!found_aligned && cur->size > head && cur->size-head >= size && (!best || cur->size < best->size)) best = cur; } } else { /* !need_aligned */ if (cur->size == size) { /* exact match */ ret_value = cur->addr; /* * Make certain we don't hand out a block of raw data * from the free list which overlaps with the metadata * aggregation buffer (if it's turned on) */ if (type == H5FD_MEM_DRAW && (file->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) && H5F_addr_overlap(ret_value, size, file->accum_loc, file->accum_size)) { ret_value = HADDR_UNDEF; } else { if (prev) prev->next = cur->next; else file->fl[mapped_type] = cur->next; H5FL_FREE(H5FD_free_t, cur); if (size == file->maxsize) file->maxsize = 0; /*unknown*/ HGOTO_DONE(ret_value) } } else { if (cur->size > size && (!best || cur->size < best->size)) best = cur; } } prev = cur; cur = cur->next; } /* Couldn't find exact match, use best fitting piece found */ if (best) { if (best->size == file->maxsize) file->maxsize = 0; /*unknown*/ if (!need_aligned || found_aligned) { /* free only tail */ ret_value = best->addr; /* * Make certain we don't hand out a block of raw data * from the free list which overlaps with the metadata * aggregation buffer (if it's turned on) */ if (type == H5FD_MEM_DRAW && (file->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) && H5F_addr_overlap(ret_value, size, file->accum_loc, file->accum_size)) { ret_value = HADDR_UNDEF; } else { best->addr += size; /* Reduce size of block on free list */ best->size -= size; HGOTO_DONE(ret_value) } } else { /* * Split into 3 pieces. Keep the the head and tail in the * freelist. */ H5FD_free_t *tmp = NULL; head = file->alignment - (best->addr % file->alignment); ret_value = best->addr + head; /* * Make certain we don't hand out a block of raw data * from the free list which overlaps with the metadata * aggregation buffer (if it's turned on) */ if (type == H5FD_MEM_DRAW && (file->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) && H5F_addr_overlap(ret_value, size, file->accum_loc, file->accum_size)) { ret_value = HADDR_UNDEF; } else { /* Attempt to allocate memory for temporary node */ if((tmp = H5FL_MALLOC(H5FD_free_t))==NULL) HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, HADDR_UNDEF, "free block allocation failed") if ((tmp->size = (best->size - (head + size)))!=0) { tmp->addr = best->addr + (head + size); tmp->next = best->next; best->next = tmp; } else { /* no tail piece */ H5FL_FREE(H5FD_free_t,tmp); } best->size = head; HGOTO_DONE(ret_value) } /* end else */ } /* end else */ } /* end if */ } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_alloc_metadata * Purpose: Try to allocate SIZE bytes of memory from the metadata * block if possible. * * This is split from H5FD_alloc(). * Return: Success: The format address of the new file memory. * Failure: The undefined address HADDR_UNDEF * Programmer: Bill Wendling * 2. December, 2002 * Modifications: * *------------------------------------------------------------------------- */ static haddr_t H5FD_alloc_metadata(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size) { haddr_t ret_value = HADDR_UNDEF; FUNC_ENTER_NOAPI(H5FD_alloc_metadata, HADDR_UNDEF) /* check args */ assert(file); assert(type >= H5FD_MEM_DEFAULT && type < H5FD_MEM_NTYPES); assert(size > 0); /* * If the metadata aggregation feature is enabled for this VFL * driver, allocate "generic" metadata space and sub-allocate out of * that, if possible. Otherwise just allocate through * H5FD_real_alloc() */ /* * Allocate all types of metadata out of the metadata block */ if (file->feature_flags & H5FD_FEAT_AGGREGATE_METADATA) { /* * Check if the space requested is larger than the space left in * the block */ if (size > file->cur_meta_block_size) { haddr_t new_meta; /* Address for new metadata */ /* * Check if the block asked for is too large for a metadata * block */ if (size >= file->def_meta_block_size) { /* Allocate more room for this new block the regular way */ new_meta = H5FD_real_alloc(file, type, dxpl_id, size); /* * Check if the new metadata is at the end of the current * metadata block */ if (file->eoma + file->cur_meta_block_size == new_meta) { /* * Treat the allocation request as if the current * metadata block grew by the amount allocated and * just update the eoma address. Don't bother * updating the cur_meta_block_size since it will * just grow and shrink by the same amount. */ ret_value = file->eoma; file->eoma += size; } else { /* Use the new metadata block for the space allocated */ ret_value = new_meta; } } else { /* Allocate another metadata block */ new_meta = H5FD_real_alloc(file, H5FD_MEM_DEFAULT, dxpl_id, file->def_meta_block_size); /* * Check if the new metadata is at the end of the current * metadata block */ if (file->eoma + file->cur_meta_block_size == new_meta) { file->cur_meta_block_size += file->def_meta_block_size; } else { /* * Return the unused portion of the metadata block to * a free list */ if (file->eoma != 0) if (H5FD_free(file, H5FD_MEM_DEFAULT, dxpl_id, file->eoma, file->cur_meta_block_size) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, HADDR_UNDEF, "can't free metadata block") /* Point the metadata block at the newly allocated block */ file->eoma = new_meta; file->cur_meta_block_size = file->def_meta_block_size; } /* Allocate space out of the metadata block */ ret_value = file->eoma; file->cur_meta_block_size -= size; file->eoma += size; } } else { /* Allocate space out of the metadata block */ ret_value = file->eoma; file->cur_meta_block_size -= size; file->eoma += size; } } else { /* Allocate data the regular way */ ret_value = H5FD_real_alloc(file, type, dxpl_id, size); } done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_alloc_raw * Purpose: Try to allocate SIZE bytes of raw data. * * This is split from H5FD_alloc(). * Return: Success: The format address of the new file memory. * Failure: The undefined address HADDR_UNDEF * Programmer: Bill Wendling * 2. December, 2002 * Modifications: *------------------------------------------------------------------------- */ static haddr_t H5FD_alloc_raw(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size) { haddr_t ret_value = HADDR_UNDEF; FUNC_ENTER_NOAPI(H5FD_alloc_raw, HADDR_UNDEF) /* check args */ assert(file); assert(type >= H5FD_MEM_DEFAULT && type < H5FD_MEM_NTYPES); assert(size > 0); /* * If the "small data" aggregation feature is enabled for this VFL driver, * allocate "small data" space and sub-allocate out of that, if * possible. Otherwise just allocate through H5FD_real_alloc() */ if (file->feature_flags & H5FD_FEAT_AGGREGATE_SMALLDATA) { /* * Check if the space requested is larger than the space left in * the block */ if (size > file->cur_sdata_block_size) { haddr_t new_data; /* Address for new raw data block */ /* Check if the block asked for is too large for the "small data" block */ if (size >= file->def_sdata_block_size) { /* Allocate more room for this new block the regular way */ new_data = H5FD_real_alloc(file, type, dxpl_id, size); /* * Check if the new raw data is at the end of the current * "small data" block */ if (file->eosda + file->cur_sdata_block_size == new_data) { /* * Treat the allocation request as if the current * "small data" block grew by the amount allocated * and just update the eosda address. Don't bother * updating the cur_sdata_block_size since it will * just grow and shrink by the same amount. */ ret_value = file->eosda; file->eosda += size; } else { /* Use the new "small data" block for the space allocated */ ret_value = new_data; } } else { /* Allocate another "small data" block */ new_data = H5FD_real_alloc(file, type, dxpl_id, file->def_sdata_block_size); /* * Check if the new raw data is at the end of the current * "small data" block */ if (file->eosda + file->cur_sdata_block_size == new_data) { file->cur_sdata_block_size += file->def_sdata_block_size; } else { /* * Return the unused portion of the "small data" * block to a free list */ if (file->eosda != 0) if (H5FD_free(file, H5FD_MEM_DRAW, dxpl_id, file->eosda, file->cur_sdata_block_size) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, HADDR_UNDEF, "can't free 'small data' block") /* * Point the "small data" block at the newly * allocated block */ file->eosda = new_data; file->cur_sdata_block_size = file->def_sdata_block_size; } /* Allocate space out of the "small data" block */ ret_value = file->eosda; file->cur_sdata_block_size -= size; file->eosda += size; } } else { /* Allocate space out of the "small data" block */ ret_value = file->eosda; file->cur_sdata_block_size -= size; file->eosda += size; } } else { /* Allocate data the regular way */ ret_value = H5FD_real_alloc(file, type, dxpl_id, size); } done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_real_alloc * * Purpose: Double private version of H5FDalloc() :-) * * Return: Success: The format address of the new file memory. * * Failure: The undefined address HADDR_UNDEF * * Programmer: Quincey Koziol * Friday, August 25, 2000 * * Modifications: * Albert Cheng, 2001/05/01 * Implement the allocation by alignment/threshold. * *------------------------------------------------------------------------- */ static haddr_t H5FD_real_alloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size) { haddr_t ret_value = HADDR_UNDEF; FUNC_ENTER_NOAPI_NOINIT(H5FD_real_alloc) /* check args */ assert(file); assert(file->cls); assert(type >= H5FD_MEM_DEFAULT && type < H5FD_MEM_NTYPES); assert(size > 0); /* * Dispatch to driver `alloc' callback or extend the end-of-address * marker */ if (file->cls->alloc) { if ((ret_value = (file->cls->alloc)(file, type, dxpl_id, size)) == HADDR_UNDEF) HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, HADDR_UNDEF, "driver allocation request failed") } else { if ((ret_value = H5FD_update_eoa(file, type, dxpl_id, size)) == HADDR_UNDEF) HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, HADDR_UNDEF, "driver eoa update request failed") } done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_real_alloc() */ /*------------------------------------------------------------------------- * Function: H5FD_update_eoa * Purpose: Update the EOA field of the file's memory. * * This was split off from the H5FD_real_alloc function to * make life easier for all. * Return: Success: The format address of the new file memory. * Failure: The undefined address HADDR_UNDEF * Programmer: Bill Wendling * Wednesday, 04. December, 2002 * Modifications: * *------------------------------------------------------------------------- */ static haddr_t H5FD_update_eoa(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size) { haddr_t eoa, oldeoa = 0; hsize_t wasted; haddr_t ret_value = HADDR_UNDEF; FUNC_ENTER_NOAPI_NOINIT(H5FD_update_eoa) /* check args */ assert(file); assert(file->cls); assert(type >= H5FD_MEM_DEFAULT && type < H5FD_MEM_NTYPES); assert(size > 0); eoa = file->cls->get_eoa(file); #ifdef H5F_DEBUG if (file->alignment * file->threshold != 1 && H5DEBUG(F)) HDfprintf(H5DEBUG(F), "%s: alignment=%Hd, threshold=%Hd, size=%Hd, Begin eoa=%a\n", FUNC, file->alignment, file->threshold, size, eoa); #endif /* H5F_DEBUG */ /* * Wasted is 0 if not exceeding threshold or eoa happens to be * aligned */ wasted = (size >= file->threshold) ? (eoa % file->alignment) : 0; if (wasted) { wasted = file->alignment - wasted; /* actual waste */ oldeoa = eoa; /* save it for later freeing */ /* Advance eoa to the next alignment by allocating the wasted */ if (H5F_addr_overflow(eoa, size) || eoa + wasted > file->maxaddr) HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, HADDR_UNDEF, "file allocation request failed") eoa += wasted; if (file->cls->set_eoa(file, eoa) < 0) HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, HADDR_UNDEF, "file allocation request failed") } /* allocate the aligned memory */ if (H5F_addr_overflow(eoa, size) || eoa + size > file->maxaddr) HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, HADDR_UNDEF, "file allocation request failed") ret_value = eoa; eoa += size; if (file->cls->set_eoa(file, eoa) < 0) HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, HADDR_UNDEF, "file allocation request failed") /* Free the wasted memory */ if (wasted) { if(H5FD_free(file, type, dxpl_id, oldeoa, wasted)<0) HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, HADDR_UNDEF, "file deallocation request failed") } /* end if */ #ifdef H5F_DEBUG if (file->alignment * file->threshold != 1 && H5DEBUG(F)) HDfprintf(H5DEBUG(F), "%s: ret_value=%a, wasted=%Hd, Ended eoa=%a\n", FUNC, ret_value, wasted, eoa); #endif /* H5F_DEBUG */ done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FDfree * * Purpose: Frees format addresses starting with ADDR and continuing for * SIZE bytes in the file FILE. The type of space being freed is * specified by TYPE, which is mapped to a free list as * described for the H5FDalloc() function above. If the request * doesn't map to a free list then either the application `free' * callback is invoked (if defined) or the memory is leaked. * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Wednesday, July 28, 1999 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5FDfree(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5FDfree, FAIL) H5TRACE5("e","xMtiah",file,type,dxpl_id,addr,size); /* Check args */ if (!file || !file->cls) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file pointer") if (type=H5FD_MEM_NTYPES) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid request type") if (H5P_DEFAULT == dxpl_id) dxpl_id= H5P_DATASET_XFER_DEFAULT; else if (TRUE!=H5P_isa_class(dxpl_id,H5P_DATASET_XFER)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data transfer property list") /* Do the real work */ if (H5FD_free(file, type, dxpl_id, addr, size)<0) HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "file deallocation request failed") done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_free * * Purpose: Private version of H5FDfree() * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Wednesday, August 4, 1999 * * Modifications: * Bill Wendling, February 20, 2003 * Added support for Flexible PHDF5. If the process is the * Set-Aside-Process, then we execute this function. Clients * don't. * *------------------------------------------------------------------------- */ herr_t H5FD_free(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size) { H5FD_mem_t mapped_type; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_free, FAIL) /* Check args */ assert(file); assert(file->cls); assert(type >= H5FD_MEM_DEFAULT && type < H5FD_MEM_NTYPES); if (!H5F_addr_defined(addr) || addr>file->maxaddr || H5F_addr_overflow(addr, size) || addr+size>file->maxaddr) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid region") /* Allow 0-sized free's to occur without penalty */ if(0==size) HGOTO_DONE(SUCCEED) /* Map request type to free list */ if (H5FD_MEM_DEFAULT==file->cls->fl_map[type]) { mapped_type = type; } else { mapped_type = file->cls->fl_map[type]; } /* * If the request maps to a free list then add memory to the free list * without ever telling the driver that it was freed. Otherwise let the * driver deallocate the memory. */ if (mapped_type>=H5FD_MEM_DEFAULT) { H5FD_free_t *last; /* Last merged node */ H5FD_free_t *last_prev=NULL;/* Pointer to node before merged node */ H5FD_free_t *curr; /* Current free block being inspected */ H5FD_free_t *prev; /* Previous free block being inspected */ /* Adjust the metadata accumulator to remove the freed block, if it overlaps */ if((file->feature_flags&H5FD_FEAT_ACCUMULATE_METADATA) && H5F_addr_overlap(addr,size,file->accum_loc,file->accum_size)) { size_t overlap_size; /* Size of overlap with accumulator */ /* Check for overlapping the beginning of the accumulator */ if(H5F_addr_le(addr,file->accum_loc)) { /* Check for completely overlapping the accumulator */ if(H5F_addr_ge(addr+size,file->accum_loc+file->accum_size)) { /* Reset the entire accumulator */ file->accum_loc=HADDR_UNDEF; file->accum_size=FALSE; file->accum_dirty=FALSE; } /* end if */ /* Block to free must end within the accumulator */ else { size_t new_accum_size; /* Size of new accumulator buffer */ /* Calculate the size of the overlap with the accumulator, etc. */ H5_ASSIGN_OVERFLOW(overlap_size,(addr+size)-file->accum_loc,haddr_t,size_t); new_accum_size=file->accum_size-overlap_size; /* Move the accumulator buffer information to eliminate the freed block */ HDmemmove(file->meta_accum,file->meta_accum+overlap_size,new_accum_size); /* Adjust the accumulator information */ file->accum_loc+=overlap_size; file->accum_size=new_accum_size; } /* end else */ } /* end if */ /* Block to free must start within the accumulator */ else { /* Calculate the size of the overlap with the accumulator */ H5_ASSIGN_OVERFLOW(overlap_size,(file->accum_loc+file->accum_size)-addr,haddr_t,size_t); /* Block to free is in the middle of the accumulator */ if(H5F_addr_lt(addr,file->accum_loc+file->accum_size)) { haddr_t tail_addr; size_t tail_size; /* Calculate the address & size of the tail to write */ tail_addr=addr+size; H5_ASSIGN_OVERFLOW(tail_size,(file->accum_loc+file->accum_size)-tail_addr,haddr_t,size_t); /* Write out the part of the accumulator after the block to free */ /* (Use the driver's write call directly - to avoid looping back and writing to metadata accumulator) */ if ((file->cls->write)(file, H5FD_MEM_DEFAULT, dxpl_id, tail_addr, tail_size, file->meta_accum+(tail_addr-file->accum_loc))<0) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "file write request failed") } /* end if */ /* Adjust the accumulator information */ file->accum_size=file->accum_size-overlap_size; } /* end else */ } /* end if */ /* Scan through the existing blocks for the mapped type to see if we can extend one */ curr=file->fl[mapped_type]; last=prev=NULL; while(curr!=NULL) { /* Check if the block to free adjoins the start of the current block */ if((addr+size)==curr->addr) { /* If we previously found & merged a node, eliminate it from the list & free it */ if(last!=NULL) { /* Check if there was a previous block in the list */ if(last_prev!=NULL) /* Eliminate the merged block from the list */ last_prev->next=last->next; /* No previous block, this must be the head of the list */ else /* Eliminate the merged block from the list */ file->fl[mapped_type] = last->next; /* Check for eliminating the block before the 'current' one */ if(last==prev) prev=last_prev; /* Free the memory for the merged block */ H5FL_FREE(H5FD_free_t,last); } /* end if */ /* Adjust the address and size of the block found */ curr->addr=addr; curr->size+=size; /* Adjust the information about to memory block to include the merged block */ addr=curr->addr; size=curr->size; /* Update the information about the merged node */ last=curr; last_prev=prev; } /* end if */ else { /* Check if the block to free adjoins the end of the current block */ if((curr->addr+curr->size)==addr) { /* If we previously found & merged a node, eliminate it from the list & free it */ if(last!=NULL) { /* Check if there was a previous block in the list */ if(last_prev!=NULL) /* Eliminate the merged block from the list */ last_prev->next=last->next; /* No previous block, this must be the head of the list */ else /* Eliminate the merged block from the list */ file->fl[mapped_type] = last->next; /* Check for eliminating the block before the 'current' one */ if(last==prev) prev=last_prev; /* Free the memory for the merged block */ H5FL_FREE(H5FD_free_t,last); } /* end if */ /* Adjust the size of the block found */ curr->size+=size; /* Adjust the information about to memory block to include the merged block */ addr=curr->addr; size=curr->size; /* Update the information about the merged node */ last=curr; last_prev=prev; } /* end if */ } /* end else */ /* Advance to next node in list */ prev=curr; curr=curr->next; } /* end while */ /* Check if we adjusted an existing block */ if(last!=NULL) { /* Move the node found to the front, if it wasn't already there */ if(last_prev!=NULL) { last_prev->next=last->next; last->next = file->fl[mapped_type]; file->fl[mapped_type] = last; } /* end if */ } /* end if */ else { /* Allocate a new node to hold the free block's information */ if(NULL==(last = H5FL_MALLOC(H5FD_free_t))) HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, FAIL, "can't allocate node for free space info") last->addr = addr; last->size = size; last->next = file->fl[mapped_type]; file->fl[mapped_type] = last; } /* end else */ /* Check if we increased the size of the largest block on the list */ file->maxsize = MAX(file->maxsize, last->size); /* Check if this free block is at the end of file allocated space. * Truncate it if this is true. */ if(file->cls->get_eoa) { haddr_t eoa; eoa = file->cls->get_eoa(file); if(eoa == (last->addr+last->size)) { if(file->cls->set_eoa(file, last->addr) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "set end of space allocation request failed") /* Remove this free block from the list */ file->fl[mapped_type] = last->next; if(file->maxsize==last->size) file->maxsize=0; /*unknown*/ H5FL_FREE(H5FD_free_t, last); } } } else if (file->cls->free) { if ((file->cls->free)(file, type, dxpl_id, addr, size)<0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver free request failed") } else { /* leak memory */ #ifdef H5F_DEBUG HDfprintf(stderr, "%s: LEAKED MEMORY!!!!!!\n", FUNC); #endif /* H5F_DEBUG */ } done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FDrealloc * * Purpose: Changes the size of an allocated chunk of memory, possibly * also changing its location in the file. * * Return: Success: New address of the block of memory, not * necessarily the same as the original address. * * Failure: HADDR_UNDEF * * Programmer: Robb Matzke * Tuesday, August 3, 1999 * * Modifications: * *------------------------------------------------------------------------- */ haddr_t H5FDrealloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t old_addr, hsize_t old_size, hsize_t new_size) { haddr_t ret_value=HADDR_UNDEF; FUNC_ENTER_API(H5FDrealloc, HADDR_UNDEF) H5TRACE6("a","xMtiahh",file,type,dxpl_id,old_addr,old_size,new_size); /* Check args */ if (H5P_DEFAULT == dxpl_id) dxpl_id= H5P_DATASET_XFER_DEFAULT; else if (TRUE!=H5P_isa_class(dxpl_id,H5P_DATASET_XFER)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, HADDR_UNDEF, "not a data transfer property list") if (HADDR_UNDEF==(ret_value=H5FD_realloc(file, type, dxpl_id, old_addr, old_size, new_size))) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "file reallocation request failed") done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_realloc * * Purpose: Private version of H5FDrealloc() * * Return: Success: New address of the block of memory, not * necessarily the same as the original address. * * Failure: HADDR_UNDEF * * Programmer: Robb Matzke * Wednesday, August 4, 1999 * * Modifications: * *------------------------------------------------------------------------- */ haddr_t H5FD_realloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t old_addr, hsize_t old_size, hsize_t new_size) { haddr_t new_addr=old_addr; uint8_t _buf[8192]; uint8_t *buf=_buf; haddr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_realloc, HADDR_UNDEF) if (new_size==old_size) { /*nothing to do*/ } else if (0==old_size) { /* allocate memory */ assert(!H5F_addr_defined(old_addr)); if (HADDR_UNDEF==(new_addr=H5FD_alloc(file, type, dxpl_id, new_size))) HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, HADDR_UNDEF, "file allocation failed") } else if (0==new_size) { /* free memory */ assert(H5F_addr_defined(old_addr)); if(H5FD_free(file, type, dxpl_id, old_addr, old_size)<0) HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, HADDR_UNDEF, "file deallocation request failed") new_addr = HADDR_UNDEF; } else if (new_sizesizeof(size_t) and the * object on disk is too large to read into a memory buffer all at one * time. This chunk of code would have to be re-written using a loop * to move pieces of the realloced data through a fixed size buffer, etc. * -QAK, 6/20/01 */ if (HADDR_UNDEF==(new_addr=H5FD_alloc(file, type, dxpl_id, new_size))) HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, HADDR_UNDEF, "file allocation failed") H5_CHECK_OVERFLOW(old_size,hsize_t,size_t); if (old_size>sizeof(_buf) && NULL==(buf=H5MM_malloc((size_t)old_size))) { (void)H5FD_free(file, type, dxpl_id, new_addr, new_size); HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, "memory allocation failed") } if (H5FD_read(file, type, dxpl_id, old_addr, (size_t)old_size, buf)<0 || H5FD_write(file, type, dxpl_id, new_addr, (size_t)old_size, buf)<0) { (void)H5FD_free(file, type, dxpl_id, new_addr, new_size); if (buf!=_buf) H5MM_xfree(buf); HGOTO_ERROR(H5E_FILE, H5E_READERROR, HADDR_UNDEF, "unable to move file block") } if (buf!=_buf) H5MM_xfree(buf); if(H5FD_free(file, type, dxpl_id, old_addr, old_size)<0) HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, HADDR_UNDEF, "file deallocation request failed") } /* Set return value */ ret_value=new_addr; done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_can_extend * * Purpose: Check if a block in the file can be extended. * * This is a simple check currently, which only checks for the * block being at the end of the file. A more sophisticated check * would also use the free space list to see if there is a block * appropriately placed to accomodate the space requested. * * Return: Success: TRUE(1)/FALSE(0) * * Failure: FAIL * * Programmer: Quincey Koziol * Friday, June 11, 2004 * * Modifications: * *------------------------------------------------------------------------- */ htri_t H5FD_can_extend(H5FD_t *file, H5FD_mem_t type, haddr_t addr, hsize_t size, hsize_t UNUSED extra_requested) { haddr_t eoa; /* End of address space in the file */ htri_t ret_value=FALSE; /* Return value */ FUNC_ENTER_NOAPI(H5FD_can_extend, FAIL) /* Retrieve the end of the address space */ if (HADDR_UNDEF==(eoa=H5FD_get_eoa(file))) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver get_eoa request failed") /* Check if the block is exactly at the end of the file */ if((addr+size)==eoa) HGOTO_DONE(TRUE) /* Check if block is inside the metadata or small data accumulator */ else { if(type!=H5FD_MEM_DRAW) { if (file->feature_flags & H5FD_FEAT_AGGREGATE_METADATA) { /* If the metadata block is at the end of the file, and * the block to test adjoins the beginning of the metadata * block, then it's extendable */ if (file->eoma + file->cur_meta_block_size == eoa && (addr+size)==file->eoma) HGOTO_DONE(TRUE) } /* end if */ } /* end if */ else { if (file->feature_flags & H5FD_FEAT_AGGREGATE_SMALLDATA) { /* If the small data block is at the end of the file, and * the block to test adjoins the beginning of the small data * block, then it's extendable */ if (file->eosda + file->cur_sdata_block_size == eoa && (addr+size)==file->eosda) HGOTO_DONE(TRUE) } /* end if */ } /* end else */ } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_can_extend() */ /*------------------------------------------------------------------------- * Function: H5FD_extend * * Purpose: Extend a block in the file. * * This is simple code currently, which only checks for the * block being at the end of the file. A more sophisticated check * would also use the free space list to see if there is a block * appropriately placed to accomodate the space requested. * * Return: Success: TRUE(1)/FALSE(0) * * Failure: FAIL * * Programmer: Quincey Koziol * Saturday, June 12, 2004 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5FD_extend(H5FD_t *file, H5FD_mem_t type, haddr_t addr, hsize_t size, hsize_t extra_requested) { haddr_t eoa; /* End of address space in the file */ hbool_t update_eoma=FALSE; /* Whether we need to update the eoma */ hbool_t update_eosda=FALSE; /* Whether we need to update the eosda */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_extend, FAIL) /* Retrieve the end of the address space */ if (HADDR_UNDEF==(eoa=H5FD_get_eoa(file))) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver get_eoa request failed") /* Check if the block is exactly at the end of the file */ /* (Check if block is inside the metadata or small data accumulator) */ if((addr+size)!=eoa) { if(type!=H5FD_MEM_DRAW) { if (file->feature_flags & H5FD_FEAT_AGGREGATE_METADATA) { /* If the metadata block is at the end of the file, and * the block to test adjoins the beginning of the metadata * block, then it's extendable */ if (file->eoma + file->cur_meta_block_size == eoa && (addr+size)==file->eoma) update_eoma=TRUE; else HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, FAIL, "can't extend block") } /* end if */ else HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, FAIL, "can't extend block") } /* end if */ else { if (file->feature_flags & H5FD_FEAT_AGGREGATE_SMALLDATA) { /* If the small data block is at the end of the file, and * the block to test adjoins the beginning of the small data * block, then it's extendable */ if (file->eosda + file->cur_sdata_block_size == eoa && (addr+size)==file->eosda) update_eosda=TRUE; else HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, FAIL, "can't extend block") } /* end if */ else HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, FAIL, "can't extend block") } /* end else */ } /* end else */ /* Check for overflowing the file */ if (H5F_addr_overflow(eoa, extra_requested) || eoa + extra_requested > file->maxaddr) HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, FAIL, "file allocation request failed") /* Extend the file */ eoa += extra_requested; if (file->cls->set_eoa(file, eoa) < 0) HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, FAIL, "file allocation request failed") /* Update the metadata and/or small data block */ assert(!(update_eoma && update_eosda)); if(update_eoma) file->eoma+=extra_requested; if(update_eosda) file->eosda+=extra_requested; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_extend() */ /*------------------------------------------------------------------------- * Function: H5FDget_eoa * * Purpose: Returns the address of the first byte after the last * allocated memory in the file. * * Return: Success: First byte after allocated memory. * * Failure: HADDR_UNDEF * * Programmer: Robb Matzke * Friday, July 30, 1999 * * Modifications: * *------------------------------------------------------------------------- */ haddr_t H5FDget_eoa(H5FD_t *file) { haddr_t ret_value; FUNC_ENTER_API(H5FDget_eoa, HADDR_UNDEF) H5TRACE1("a","x",file); /* Check args */ if (!file || !file->cls) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "invalid file pointer") /* The real work */ if (HADDR_UNDEF==(ret_value=H5FD_get_eoa(file))) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "file get eoa request failed") done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_get_eoa * * Purpose: Private version of H5FDget_eoa() * * Return: Success: First byte after allocated memory. * * Failure: HADDR_UNDEF * * Programmer: Robb Matzke * Wednesday, August 4, 1999 * * Modifications: * *------------------------------------------------------------------------- */ haddr_t H5FD_get_eoa(H5FD_t *file) { haddr_t ret_value; FUNC_ENTER_NOAPI(H5FD_get_eoa, HADDR_UNDEF) assert(file && file->cls); /* Dispatch to driver */ if (HADDR_UNDEF==(ret_value=(file->cls->get_eoa)(file))) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "driver get_eoa request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FDset_eoa * * Purpose: Set the end-of-address marker for the file. The ADDR is the * address of the first byte past the last allocated byte of the * file. This function is called from two places: * * It is called after an existing file is opened in order to * "allocate" enough space to read the superblock and then * to "allocate" the entire hdf5 file based on the contents * of the superblock. * * It is called during file memory allocation if the * allocation request cannot be satisfied from the free list * and the driver didn't supply an allocation callback. * * Return: Success: Non-negative * * Failure: Negative, no side effect * * Programmer: Robb Matzke * Friday, July 30, 1999 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5FDset_eoa(H5FD_t *file, haddr_t addr) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5FDset_eoa, FAIL) H5TRACE2("e","xa",file,addr); /* Check args */ if (!file || !file->cls) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file pointer") if (!H5F_addr_defined(addr) || addr>file->maxaddr) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid end-of-address value") /* The real work */ if (H5FD_set_eoa(file, addr)<0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "file set eoa request failed") done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_set_eoa * * Purpose: Private version of H5FDset_eoa() * * Return: Success: Non-negative * * Failure: Negative, no side effect * * Programmer: Robb Matzke * Wednesday, August 4, 1999 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5FD_set_eoa(H5FD_t *file, haddr_t addr) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_set_eoa, FAIL) assert(file && file->cls); assert(H5F_addr_defined(addr) && addr<=file->maxaddr); /* Dispatch to driver */ if ((file->cls->set_eoa)(file, addr)<0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver set_eoa request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FDget_eof * * Purpose: Returns the end-of-file address, which is the greater of the * end-of-format address and the actual EOF marker. This * function is called after an existing file is opened in order * for the library to learn the true size of the underlying file * and to determine whether the hdf5 data has been truncated. * * It is also used when a file is first opened to learn whether * the file is empty or not. * * It is permissible for the driver to return the maximum address * for the file size if the file is not empty. * * Return: Success: The EOF address. * * Failure: HADDR_UNDEF * * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: * *------------------------------------------------------------------------- */ haddr_t H5FDget_eof(H5FD_t *file) { haddr_t ret_value; FUNC_ENTER_API(H5FDget_eof, HADDR_UNDEF) H5TRACE1("a","x",file); /* Check arguments */ if (!file || !file->cls) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "invalid file pointer") /* The real work */ if (HADDR_UNDEF==(ret_value=H5FD_get_eof(file))) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "file get eof request failed") done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_get_eof * * Purpose: Private version of H5FDget_eof() * * Return: Success: The EOF address. * * Failure: HADDR_UNDEF * * Programmer: Robb Matzke * Wednesday, August 4, 1999 * * Modifications: * *------------------------------------------------------------------------- */ haddr_t H5FD_get_eof(H5FD_t *file) { haddr_t ret_value; FUNC_ENTER_NOAPI(H5FD_get_eof, HADDR_UNDEF) assert(file && file->cls); /* Dispatch to driver */ if (file->cls->get_eof) { if (HADDR_UNDEF==(ret_value=(file->cls->get_eof)(file))) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "driver get_eof request failed") } else { ret_value = file->maxaddr; } done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FDread * * Purpose: Reads SIZE bytes from FILE beginning at address ADDR * according to the data transfer property list DXPL_ID (which may * be the constant H5P_DEFAULT). The result is written into the * buffer BUF. * * Return: Success: Non-negative. The read result is written into * the BUF buffer which should be allocated by * the caller. * * Failure: Negative. The contents of BUF is undefined. * * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5FDread(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, void *buf/*out*/) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5FDread, FAIL) H5TRACE6("e","xMtiazx",file,type,dxpl_id,addr,size,buf); /* Check args */ if (!file || !file->cls) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file pointer") /* Get the default dataset transfer property list if the user didn't provide one */ if (H5P_DEFAULT == dxpl_id) dxpl_id= H5P_DATASET_XFER_DEFAULT; else if (TRUE!=H5P_isa_class(dxpl_id,H5P_DATASET_XFER)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data transfer property list") if (!buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null result buffer") /* Do the real work */ if (H5FD_read(file, type, dxpl_id, addr, size, buf)<0) HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "file read request failed") done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_read * * Purpose: Private version of H5FDread() * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Wednesday, August 4, 1999 * * Modifications: * Albert Cheng, 2000-11-21 * Disable the code that does early return when size==0 for * Parallel mode since a collective call would require the process * to continue on with "nothing" to transfer. * *------------------------------------------------------------------------- */ herr_t H5FD_read(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, void *buf/*out*/) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_read, FAIL) assert(file && file->cls); assert(H5I_GENPROP_LST==H5I_get_type(dxpl_id)); assert(TRUE==H5P_isa_class(dxpl_id,H5P_DATASET_XFER)); assert(buf); #ifndef H5_HAVE_PARALLEL /* Do not return early for Parallel mode since the I/O could be a */ /* collective transfer. */ /* The no-op case */ if (0==size) HGOTO_DONE(SUCCEED) #endif /* H5_HAVE_PARALLEL */ /* Check if this information is in the metadata accumulator */ if((file->feature_flags&H5FD_FEAT_ACCUMULATE_METADATA) && type!=H5FD_MEM_DRAW) { /* Current read overlaps with metadata accumulator */ if(H5F_addr_overlap(addr,size,file->accum_loc,file->accum_size)) { unsigned char *read_buf=(unsigned char *)buf; /* Pointer to the buffer being read in */ size_t amount_read; /* Amount to read at a time */ #ifndef NDEBUG hsize_t tempamount_read; /* Amount to read at a time */ #endif /* NDEBUG */ hsize_t read_off; /* Offset to read from */ /* Double check that we aren't reading raw data */ assert(type!=H5FD_MEM_DRAW); /* Read the part before the metadata accumulator */ if(addraccum_loc) { /* Set the amount to read */ H5_ASSIGN_OVERFLOW(amount_read,file->accum_loc-addr,hsize_t,size_t); /* Dispatch to driver */ if ((file->cls->read)(file, type, dxpl_id, addr, amount_read, read_buf)<0) HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "driver read request failed") /* Adjust the buffer, address & size */ read_buf+=amount_read; addr+=amount_read; size-=amount_read; } /* end if */ /* Copy the part overlapping the metadata accumulator */ if(size>0 && (addr>=file->accum_loc && addr<(file->accum_loc+file->accum_size))) { /* Set the offset to "read" from */ read_off=addr-file->accum_loc; /* Set the amount to "read" */ #ifndef NDEBUG tempamount_read = file->accum_size-read_off; H5_CHECK_OVERFLOW(tempamount_read,hsize_t,size_t); amount_read = MIN(size, (size_t)tempamount_read); #else /* NDEBUG */ amount_read = MIN(size, (size_t)(file->accum_size-read_off)); #endif /* NDEBUG */ /* Copy the data out of the buffer */ HDmemcpy(read_buf,file->meta_accum+read_off,amount_read); /* Adjust the buffer, address & size */ read_buf+=amount_read; addr+=amount_read; size-=amount_read; } /* end if */ /* Read the part after the metadata accumulator */ if(size>0 && addr>=(file->accum_loc+file->accum_size)) { /* Dispatch to driver */ if ((file->cls->read)(file, type, dxpl_id, addr, size, read_buf)<0) HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "driver read request failed") /* Adjust the buffer, address & size */ read_buf+=size; addr+=size; size-=size; } /* end if */ /* Make certain we've read it all */ assert(size==0); } /* end if */ /* Current read doesn't overlap with metadata accumulator, read it into accumulator */ else { /* Only update the metadata accumulator if it is not dirty or if * we are allowed to write the accumulator out during reads (when * it is dirty) */ if(file->feature_flags&H5FD_FEAT_ACCUMULATE_METADATA_READ || !file->accum_dirty) { /* Flush current contents, if dirty */ if(file->accum_dirty) { if ((file->cls->write)(file, H5FD_MEM_DEFAULT, dxpl_id, file->accum_loc, file->accum_size, file->meta_accum)<0) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "driver write request failed") /* Reset accumulator dirty flag */ file->accum_dirty=FALSE; } /* end if */ /* Cache the new piece of metadata */ /* Check if we need to resize the buffer */ if(size>file->accum_buf_size) { /* Grow the metadata accumulator buffer */ if ((file->meta_accum=H5FL_BLK_REALLOC(meta_accum,file->meta_accum,size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer") /* Note the new buffer size */ file->accum_buf_size=size; } /* end if */ else { /* Check if we should shrink the accumulator buffer */ if(size<(file->accum_buf_size/H5FD_ACCUM_THROTTLE) && file->accum_buf_size>H5FD_ACCUM_THRESHOLD) { size_t new_size=(file->accum_buf_size/H5FD_ACCUM_THROTTLE); /* New size of accumulator buffer */ /* Shrink the accumulator buffer */ if ((file->meta_accum=H5FL_BLK_REALLOC(meta_accum,file->meta_accum,new_size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer") /* Note the new buffer size */ file->accum_buf_size=new_size; } /* end if */ } /* end else */ /* Update accumulator information */ file->accum_loc=addr; file->accum_size=size; file->accum_dirty=FALSE; /* Read into accumulator */ if ((file->cls->read)(file, H5FD_MEM_DEFAULT, dxpl_id, file->accum_loc, file->accum_size, file->meta_accum)<0) HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "driver read request failed") /* Copy into buffer */ HDmemcpy(buf,file->meta_accum,size); } /* end if */ else { /* Dispatch to driver */ if ((file->cls->read)(file, type, dxpl_id, addr, size, buf)<0) HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "driver read request failed") } /* end else */ } /* end else */ } /* end if */ else { /* Dispatch to driver */ if ((file->cls->read)(file, type, dxpl_id, addr, size, buf)<0) HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "driver read request failed") } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FDwrite * * Purpose: Writes SIZE bytes to FILE beginning at address ADDR according * to the data transfer property list DXPL_ID (which may be the * constant H5P_DEFAULT). The bytes to be written come from the * buffer BUF. * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5FDwrite(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, const void *buf) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5FDwrite, FAIL) H5TRACE6("e","xMtiazx",file,type,dxpl_id,addr,size,buf); /* Check args */ if (!file || !file->cls) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file pointer") /* Get the default dataset transfer property list if the user didn't provide one */ if (H5P_DEFAULT == dxpl_id) dxpl_id= H5P_DATASET_XFER_DEFAULT; else if (TRUE!=H5P_isa_class(dxpl_id,H5P_DATASET_XFER)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data transfer property list") if (!buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null buffer") /* The real work */ if (H5FD_write(file, type, dxpl_id, addr, size, buf)<0) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "file write request failed") done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_write * * Purpose: Private version of H5FDwrite() * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Wednesday, August 4, 1999 * * Modifications: * Albert Cheng, 2000-11-21 * Disable the code that does early return when size==0 for * Parallel mode since a collective call would require the process * to continue on with "nothing" to transfer. * *------------------------------------------------------------------------- */ herr_t H5FD_write(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, const void *buf) { size_t new_size; /* New size of the accumulator buffer */ size_t old_offset; /* Offset of old data within the accumulator buffer */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_write, FAIL) assert(file && file->cls); assert(H5I_GENPROP_LST==H5I_get_type(dxpl_id)); assert(TRUE==H5P_isa_class(dxpl_id,H5P_DATASET_XFER)); assert(buf); #ifndef H5_HAVE_PARALLEL /* Do not return early for Parallel mode since the I/O could be a */ /* collective transfer. */ /* The no-op case */ if (0==size) HGOTO_DONE(SUCCEED) #endif /* H5_HAVE_PARALLEL */ /* Check for accumulating metadata */ if((file->feature_flags&H5FD_FEAT_ACCUMULATE_METADATA) && type!=H5FD_MEM_DRAW) { /* Check if there is already metadata in the accumulator */ if(file->accum_size>0) { /* Check if the piece of metadata being written adjoins or is inside the metadata accumulator */ if((addr>=file->accum_loc && addr<=(file->accum_loc+file->accum_size)) || ((addr+size)>file->accum_loc && (addr+size)<=(file->accum_loc+file->accum_size)) || (addraccum_loc && (addr+size)>=file->accum_loc)) { /* Check if the new metadata adjoins the beginning of the current accumulator */ if((addr+size)==file->accum_loc) { /* Check if we need more buffer space */ if((size+file->accum_size)>file->accum_buf_size) { /* Adjust the buffer size, by doubling it */ file->accum_buf_size = MAX(file->accum_buf_size*2,size+file->accum_size); /* Reallocate the metadata accumulator buffer */ if ((file->meta_accum=H5FL_BLK_REALLOC(meta_accum,file->meta_accum,file->accum_buf_size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer") #ifdef H5_USING_PURIFY HDmemset(file->meta_accum+file->accum_size,0,(file->accum_buf_size-file->accum_size)); #endif /* H5_USING_PURIFY */ } /* end if */ /* Move the existing metadata to the proper location */ HDmemmove(file->meta_accum+size,file->meta_accum,file->accum_size); /* Copy the new metadata at the front */ HDmemcpy(file->meta_accum,buf,size); /* Set the new size & location of the metadata accumulator */ file->accum_loc=addr; file->accum_size=file->accum_size+size; /* Mark it as written to */ file->accum_dirty=TRUE; } /* end if */ /* Check if the new metadata adjoins the end of the current accumulator */ else if(addr==(file->accum_loc+file->accum_size)) { /* Check if we need more buffer space */ if((size+file->accum_size)>file->accum_buf_size) { /* Adjust the buffer size, by doubling it */ file->accum_buf_size = MAX(file->accum_buf_size*2,size+file->accum_size); /* Reallocate the metadata accumulator buffer */ if ((file->meta_accum=H5FL_BLK_REALLOC(meta_accum,file->meta_accum,file->accum_buf_size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer") #ifdef H5_USING_PURIFY HDmemset(file->meta_accum+file->accum_size,0,(file->accum_buf_size-file->accum_size)); #endif /* H5_USING_PURIFY */ } /* end if */ /* Copy the new metadata to the end */ HDmemcpy(file->meta_accum+file->accum_size,buf,size); /* Set the new size of the metadata accumulator */ file->accum_size=file->accum_size+size; /* Mark it as written to */ file->accum_dirty=TRUE; } /* end if */ /* Check if the new metadata is entirely within the current accumulator */ else if(addr>=file->accum_loc && (addr+size)<=(file->accum_loc+file->accum_size)) { /* Copy the new metadata to the proper location within the accumulator */ HDmemcpy(file->meta_accum+(addr-file->accum_loc),buf,size); /* Mark it as written to */ file->accum_dirty=TRUE; } /* end if */ /* Check if the new metadata overlaps the beginning of the current accumulator */ else if(addraccum_loc && (addr+size)<=(file->accum_loc+file->accum_size)) { /* Calculate the new accumulator size, based on the amount of overlap */ H5_ASSIGN_OVERFLOW(new_size,(file->accum_loc-addr)+file->accum_size,hsize_t,size_t); /* Check if we need more buffer space */ if(new_size>file->accum_buf_size) { /* Adjust the buffer size, by doubling it */ file->accum_buf_size = MAX(file->accum_buf_size*2,new_size); /* Reallocate the metadata accumulator buffer */ if ((file->meta_accum=H5FL_BLK_REALLOC(meta_accum,file->meta_accum,file->accum_buf_size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer") #ifdef H5_USING_PURIFY HDmemset(file->meta_accum+file->accum_size,0,(file->accum_buf_size-file->accum_size)); #endif /* H5_USING_PURIFY */ } /* end if */ /* Calculate the proper offset of the existing metadata */ H5_ASSIGN_OVERFLOW(old_offset,(addr+size)-file->accum_loc,hsize_t,size_t); /* Move the existing metadata to the proper location */ HDmemmove(file->meta_accum+size,file->meta_accum+old_offset,(file->accum_size-old_offset)); /* Copy the new metadata at the front */ HDmemcpy(file->meta_accum,buf,size); /* Set the new size & location of the metadata accumulator */ file->accum_loc=addr; file->accum_size=new_size; /* Mark it as written to */ file->accum_dirty=TRUE; } /* end if */ /* Check if the new metadata overlaps the end of the current accumulator */ else if(addr>=file->accum_loc && (addr+size)>(file->accum_loc+file->accum_size)) { /* Calculate the new accumulator size, based on the amount of overlap */ H5_ASSIGN_OVERFLOW(new_size,(addr-file->accum_loc)+size,hsize_t,size_t); /* Check if we need more buffer space */ if(new_size>file->accum_buf_size) { /* Adjust the buffer size, by doubling it */ file->accum_buf_size = MAX(file->accum_buf_size*2,new_size); /* Reallocate the metadata accumulator buffer */ if ((file->meta_accum=H5FL_BLK_REALLOC(meta_accum,file->meta_accum,file->accum_buf_size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer") #ifdef H5_USING_PURIFY HDmemset(file->meta_accum+file->accum_size,0,(file->accum_buf_size-file->accum_size)); #endif /* H5_USING_PURIFY */ } /* end if */ /* Copy the new metadata to the end */ HDmemcpy(file->meta_accum+(addr-file->accum_loc),buf,size); /* Set the new size & location of the metadata accumulator */ file->accum_size=new_size; /* Mark it as written to */ file->accum_dirty=TRUE; } /* end if */ else { assert(0 && "New metadata overlapped both beginning and end of existing metadata accumulator!"); } /* end else */ } /* end if */ /* New piece of metadata doesn't adjoin or overlap the existing accumulator */ else { /* Write out the existing metadata accumulator, with dispatch to driver */ if(file->accum_dirty) { if ((file->cls->write)(file, H5FD_MEM_DEFAULT, dxpl_id, file->accum_loc, file->accum_size, file->meta_accum)<0) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "driver write request failed") /* Reset accumulator dirty flag */ file->accum_dirty=FALSE; } /* end if */ /* Cache the new piece of metadata */ /* Check if we need to resize the buffer */ if(size>file->accum_buf_size) { /* Grow the metadata accumulator buffer */ if ((file->meta_accum=H5FL_BLK_REALLOC(meta_accum,file->meta_accum,size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer") /* Note the new buffer size */ file->accum_buf_size=size; #ifdef H5_USING_PURIFY HDmemset(file->meta_accum+file->accum_size,0,(file->accum_buf_size-file->accum_size)); #endif /* H5_USING_PURIFY */ } /* end if */ else { /* Check if we should shrink the accumulator buffer */ if(size<(file->accum_buf_size/H5FD_ACCUM_THROTTLE) && file->accum_buf_size>H5FD_ACCUM_THRESHOLD) { size_t tmp_size=(file->accum_buf_size/H5FD_ACCUM_THROTTLE); /* New size of accumulator buffer */ /* Shrink the accumulator buffer */ if ((file->meta_accum=H5FL_BLK_REALLOC(meta_accum,file->meta_accum,tmp_size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer") /* Note the new buffer size */ file->accum_buf_size=tmp_size; } /* end if */ } /* end else */ /* Update the metadata accumulator information */ file->accum_loc=addr; file->accum_size=size; file->accum_dirty=TRUE; /* Store the piece of metadata in the accumulator */ HDmemcpy(file->meta_accum,buf,size); } /* end else */ } /* end if */ /* No metadata in the accumulator, grab this piece and keep it */ else { /* Check if we need to reallocate the buffer */ if(size>file->accum_buf_size) { /* Reallocate the metadata accumulator buffer */ if ((file->meta_accum=H5FL_BLK_REALLOC(meta_accum,file->meta_accum,size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer") /* Note the new buffer size */ file->accum_buf_size=size; } /* end if */ /* Update the metadata accumulator information */ file->accum_loc=addr; file->accum_size=size; file->accum_dirty=TRUE; /* Store the piece of metadata in the accumulator */ HDmemcpy(file->meta_accum,buf,size); } /* end else */ } /* end if */ else { /* Dispatch to driver */ if ((file->cls->write)(file, type, dxpl_id, addr, size, buf)<0) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "driver write request failed") } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FDflush * * Purpose: Notify driver to flush all cached data. If the driver has no * flush method then nothing happens. * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: * Quincey Koziol, May 20, 2002 * Added 'closing' parameter * *------------------------------------------------------------------------- */ herr_t H5FDflush(H5FD_t *file, hid_t dxpl_id, unsigned closing) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5FDflush, FAIL) H5TRACE3("e","xiIu",file,dxpl_id,closing); /* Check args */ if (!file || !file->cls) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file pointer") if (H5P_DEFAULT == dxpl_id) dxpl_id= H5P_DATASET_XFER_DEFAULT; else if (TRUE!=H5P_isa_class(dxpl_id,H5P_DATASET_XFER)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data transfer property list") /* Do the real work */ if (H5FD_flush(file,dxpl_id,closing)<0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "file flush request failed") done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_flush * * Purpose: Private version of H5FDflush() * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Wednesday, August 4, 1999 * * Modifications: * Quincey Koziol, May 20, 2002 * Added 'closing' parameter * *------------------------------------------------------------------------- */ herr_t H5FD_flush(H5FD_t *file, hid_t dxpl_id, unsigned closing) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_flush, FAIL) assert(file && file->cls); /* Check if we need to flush out the metadata accumulator */ if((file->feature_flags&H5FD_FEAT_ACCUMULATE_METADATA) && file->accum_dirty && file->accum_size>0) { /* Flush the metadata contents */ /* Not certain if the type and dxpl should be the way they are... -QAK */ if ((file->cls->write)(file, H5FD_MEM_DEFAULT, dxpl_id, file->accum_loc, file->accum_size, file->meta_accum)<0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver write request failed") /* Reset the dirty flag */ file->accum_dirty=FALSE; } /* end if */ if (file->cls->flush && (file->cls->flush)(file,dxpl_id,closing)<0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver flush request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_get_fileno * * Purpose: Quick and dirty routine to retrieve the file's 'fileno' value * (Mainly added to stop non-file routines from poking about in the * H5FD_t data structure) * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * March 27, 2002 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5FD_get_fileno(const H5FD_t *file, unsigned long *filenum) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_get_fileno, FAIL) assert(file); assert(filenum); /* Retrieve the file's serial number */ HDmemcpy(filenum,file->fileno,sizeof(file->fileno)); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_get_fileno() */ /*-------------------------------------------------------------------------- * Function: H5FDget_vfd_handle * * Purpose: Returns a pointer to the file handle of low-level virtual * file driver. * * Return: Non-negative if succeed; negative otherwise. * * Programmer: Raymond Lu * Sep. 16, 2002 * * Modifications: * *-------------------------------------------------------------------------- */ herr_t H5FDget_vfd_handle(H5FD_t *file, hid_t fapl, void** file_handle) { herr_t ret_value; FUNC_ENTER_API(H5FDget_vfd_handle, FAIL) /* Check arguments */ assert(file); assert(file_handle); ret_value=H5FD_get_vfd_handle(file, fapl, file_handle); done: FUNC_LEAVE_API(ret_value) } /*-------------------------------------------------------------------------- * Function: H5FD_get_vfd_handle * * Purpose: Retrieve the file handle for file driver. * * Return: Non-negative if succeed; negative if fails. * * Programmer: Raymond Lu * Sep. 16, 2002 * * Modifications: * *-------------------------------------------------------------------------- */ herr_t H5FD_get_vfd_handle(H5FD_t *file, hid_t fapl, void** file_handle) { herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5FD_get_vfd_handle, FAIL) assert(file_handle); if(file->cls->get_handle && ((ret_value=file->cls->get_handle(file, fapl, file_handle)) < 0)) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get file handle for file driver") done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_get_freespace * * Purpose: Retrieve the amount of free space in a file. * * Return: Success: Amount of free space in file * Failure: Negative * * Programmer: Quincey Koziol * Monday, October 6, 2003 * * Modifications: * *------------------------------------------------------------------------- */ hssize_t H5FD_get_freespace(const H5FD_t *file) { H5FD_free_t *free_node; /* Pointer to node on free list */ H5FD_mem_t type; /* Type of memory */ hssize_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_get_freespace, FAIL) /* check args */ assert(file); assert(file->cls); /* Initialize return value */ ret_value=0; /* Iterate over all the types of memory, to retrieve amount of free space for each */ for (type=H5FD_MEM_DEFAULT; typefl[type]; while(free_node) { ret_value+=(hssize_t)free_node->size; free_node=free_node->next; } /* end while */ } /* end for */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_get_freespace() */ xdmf-3.0+git20160803/Utilities/hdf5/H5FDmpio.c0000640000175000017500000017605613003006557020431 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Purpose: This is the MPI-2 I/O driver. * */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5FD_mpio_init_interface #include "H5private.h" /* Generic Functions */ #include "H5ACprivate.h" /* Metadata cache */ #include "H5Dprivate.h" /* Dataset functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fprivate.h" /* File access */ #include "H5FDprivate.h" /* File drivers */ #include "H5FDmpi.h" /* MPI-based file drivers */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Pprivate.h" /* Property lists */ #ifdef H5_HAVE_PARALLEL /* * The driver identification number, initialized at runtime if H5_HAVE_PARALLEL * is defined. This allows applications to still have the H5FD_MPIO * "constants" in their source code. */ static hid_t H5FD_MPIO_g = 0; /* * The description of a file belonging to this driver. * The EOF value is only used just after the file is opened in order for the * library to determine whether the file is empty, truncated, or okay. The MPIO * driver doesn't bother to keep it updated since it's an expensive operation. */ typedef struct H5FD_mpio_t { H5FD_t pub; /*public stuff, must be first */ MPI_File f; /*MPIO file handle */ MPI_Comm comm; /*communicator */ MPI_Info info; /*file information */ int mpi_rank; /* This process's rank */ int mpi_size; /* Total number of processes */ haddr_t eof; /*end-of-file marker */ haddr_t eoa; /*end-of-address marker */ haddr_t last_eoa; /* Last known end-of-address marker */ } H5FD_mpio_t; /* Private Prototypes */ /* Callbacks */ static void *H5FD_mpio_fapl_get(H5FD_t *_file); static void *H5FD_mpio_fapl_copy(const void *_old_fa); static herr_t H5FD_mpio_fapl_free(void *_fa); static H5FD_t *H5FD_mpio_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); static herr_t H5FD_mpio_close(H5FD_t *_file); static herr_t H5FD_mpio_query(const H5FD_t *_f1, unsigned long *flags); static haddr_t H5FD_mpio_get_eoa(H5FD_t *_file); static herr_t H5FD_mpio_set_eoa(H5FD_t *_file, haddr_t addr); static haddr_t H5FD_mpio_get_eof(H5FD_t *_file); static herr_t H5FD_mpio_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle); static herr_t H5FD_mpio_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, void *buf); static herr_t H5FD_mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, const void *buf); static herr_t H5FD_mpio_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing); static int H5FD_mpio_mpi_rank(const H5FD_t *_file); static int H5FD_mpio_mpi_size(const H5FD_t *_file); static MPI_Comm H5FD_mpio_communicator(const H5FD_t *_file); /* MPIO-specific file access properties */ typedef struct H5FD_mpio_fapl_t { MPI_Comm comm; /*communicator */ MPI_Info info; /*file information */ } H5FD_mpio_fapl_t; /* The MPIO file driver information */ static const H5FD_class_mpi_t H5FD_mpio_g = { { /* Start of superclass information */ "mpio", /*name */ HADDR_MAX, /*maxaddr */ H5F_CLOSE_SEMI, /* fc_degree */ NULL, /*sb_size */ NULL, /*sb_encode */ NULL, /*sb_decode */ sizeof(H5FD_mpio_fapl_t), /*fapl_size */ H5FD_mpio_fapl_get, /*fapl_get */ H5FD_mpio_fapl_copy, /*fapl_copy */ H5FD_mpio_fapl_free, /*fapl_free */ 0, /*dxpl_size */ NULL, /*dxpl_copy */ NULL, /*dxpl_free */ H5FD_mpio_open, /*open */ H5FD_mpio_close, /*close */ NULL, /*cmp */ H5FD_mpio_query, /*query */ NULL, /*alloc */ NULL, /*free */ H5FD_mpio_get_eoa, /*get_eoa */ H5FD_mpio_set_eoa, /*set_eoa */ H5FD_mpio_get_eof, /*get_eof */ H5FD_mpio_get_handle, /*get_handle */ H5FD_mpio_read, /*read */ H5FD_mpio_write, /*write */ H5FD_mpio_flush, /*flush */ NULL, /*lock */ NULL, /*unlock */ H5FD_FLMAP_SINGLE /*fl_map */ }, /* End of superclass information */ H5FD_mpio_mpi_rank, /*get_rank */ H5FD_mpio_mpi_size, /*get_size */ H5FD_mpio_communicator /*get_comm */ }; #ifdef H5FDmpio_DEBUG /* Flags to control debug actions in H5Fmpio. * Meant to be indexed by characters. * * 'c' show result of MPI_Get_count after read * 'r' show read offset and size * 't' trace function entry and exit * 'w' show write offset and size */ static int H5FD_mpio_Debug[256] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; #endif /*-------------------------------------------------------------------------- NAME H5FD_mpio_init_interface -- Initialize interface-specific information USAGE herr_t H5FD_mpio_init_interface() RETURNS Non-negative on success/Negative on failure DESCRIPTION Initializes any interface-specific data or routines. (Just calls H5FD_mpio_init currently). --------------------------------------------------------------------------*/ static herr_t H5FD_mpio_init_interface(void) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_mpio_init_interface) FUNC_LEAVE_NOAPI(H5FD_mpio_init()) } /* H5FD_mpio_init_interface() */ /*------------------------------------------------------------------------- * Function: H5FD_mpio_init * * Purpose: Initialize this driver by registering the driver with the * library. * * Return: Success: The driver ID for the mpio driver. * * Failure: Negative. * * Programmer: Robb Matzke * Thursday, August 5, 1999 * * Modifications: * *------------------------------------------------------------------------- */ hid_t H5FD_mpio_init(void) { #ifdef H5FDmpio_DEBUG static int H5FD_mpio_Debug_inited=0; #endif /* H5FDmpio_DEBUG */ hid_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_mpio_init, FAIL) if (H5I_VFL!=H5I_get_type(H5FD_MPIO_g)) H5FD_MPIO_g = H5FD_register((const H5FD_class_t *)&H5FD_mpio_g,sizeof(H5FD_class_mpi_t)); #ifdef H5FDmpio_DEBUG if (!H5FD_mpio_Debug_inited) { /* set debug mask */ /* Should this be done in H5F global initialization instead of here? */ const char *s = HDgetenv ("H5FD_mpio_Debug"); if (s) { while (*s){ H5FD_mpio_Debug[(int)*s]++; s++; } } H5FD_mpio_Debug_inited++; } #endif /* H5FDmpio_DEBUG */ /* Set return value */ ret_value=H5FD_MPIO_g; done: FUNC_LEAVE_NOAPI(ret_value) } /*--------------------------------------------------------------------------- * Function: H5FD_mpio_term * * Purpose: Shut down the VFD * * Return: * * Programmer: Quincey Koziol * Friday, Jan 30, 2004 * * Modification: * *--------------------------------------------------------------------------- */ void H5FD_mpio_term(void) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_mpio_term) /* Reset VFL ID */ H5FD_MPIO_g=0; FUNC_LEAVE_NOAPI_VOID } /* end H5FD_mpio_term() */ /*------------------------------------------------------------------------- * Function: H5Pset_fapl_mpio * * Purpose: Store the user supplied MPIO communicator comm and info in * the file access property list FAPL_ID which can then be used * to create and/or open the file. This function is available * only in the parallel HDF5 library and is not collective. * * comm is the MPI communicator to be used for file open as * defined in MPI_FILE_OPEN of MPI-2. This function makes a * duplicate of comm. Any modification to comm after this function * call returns has no effect on the access property list. * * info is the MPI Info object to be used for file open as * defined in MPI_FILE_OPEN of MPI-2. This function makes a * duplicate of info. Any modification to info after this * function call returns has no effect on the access property * list. * * If fapl_id has previously set comm and info values, they * will be replaced and the old communicator and Info object * are freed. * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Albert Cheng * Feb 3, 1998 * * Modifications: * Robb Matzke, 1998-02-18 * Check all arguments before the property list is updated so we * don't leave the property list in a bad state if something * goes wrong. Also, the property list data type changed to * allow more generality so all the mpi-related stuff is in the * `u.mpi' member. The `access_mode' will contain only * mpi-related flags defined in H5Fpublic.h. * * Albert Cheng, 1998-04-16 * Removed the ACCESS_MODE argument. The access mode is changed * to be controlled by data transfer property list during data * read/write calls. * * Robb Matzke, 1999-08-06 * Modified to work with the virtual file layer. * * Raymond Lu, 2001-10-23 * Changed the file access list to the new generic property * list. * * Albert Cheng, 2003-04-17 * Modified the description of the function that it now stores * a duplicate of the communicator and INFO object. Free the * old duplicates if previously set. (Work is actually done * by H5P_set_driver.) * *------------------------------------------------------------------------- */ herr_t H5Pset_fapl_mpio(hid_t fapl_id, MPI_Comm comm, MPI_Info info) { H5FD_mpio_fapl_t fa; H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value; FUNC_ENTER_API(H5Pset_fapl_mpio, FAIL) H5TRACE3("e","iMcMi",fapl_id,comm,info); if(fapl_id==H5P_DEFAULT) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't set values in default property list") /* Check arguments */ if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a file access list") if (MPI_COMM_NULL == comm) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a valid communicator") /* Initialize driver specific properties */ fa.comm = comm; fa.info = info; /* duplication is done during driver setting. */ ret_value= H5P_set_driver(plist, H5FD_MPIO, &fa); done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5Pget_fapl_mpio * * Purpose: If the file access property list is set to the H5FD_MPIO * driver then this function returns duplicates of the MPI * communicator and Info object stored through the comm and * info pointers. It is the responsibility of the application * to free the returned communicator and Info object. * * Return: Success: Non-negative with the communicator and * Info object returned through the comm and * info arguments if non-null. Since they are * duplicates of the stored objects, future * modifications to the access property list do * not affect them and it is the responsibility * of the application to free them. * * Failure: Negative * * Programmer: Robb Matzke * Thursday, February 26, 1998 * * Modifications: * * Albert Cheng, Apr 16, 1998 * Removed the access_mode argument. The access_mode is changed * to be controlled by data transfer property list during data * read/write calls. * * Raymond Lu, 2001-10-23 * Changed the file access list to the new generic property * list. * * Albert Cheng, 2003-04-17 * Return duplicates of the stored communicator and Info object. * *------------------------------------------------------------------------- */ herr_t H5Pget_fapl_mpio(hid_t fapl_id, MPI_Comm *comm/*out*/, MPI_Info *info/*out*/) { H5FD_mpio_fapl_t *fa; H5P_genplist_t *plist; /* Property list pointer */ MPI_Comm comm_tmp=MPI_COMM_NULL; int mpi_code; /* mpi return code */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Pget_fapl_mpio, FAIL) H5TRACE3("e","ixx",fapl_id,comm,info); if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a file access list") if (H5FD_MPIO!=H5P_get_driver(plist)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver") if (NULL==(fa=H5P_get_driver_info(plist))) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info") /* Store the duplicated communicator in a temporary variable for error */ /* recovery in case the INFO duplication fails. We cannot attempt to */ /* the value into *comm yet since if MPI_Comm_dup fails, we will end */ /* up freeing whatever *comm holds and that could be invalid. */ if (comm){ if (MPI_SUCCESS != (mpi_code=MPI_Comm_dup(fa->comm, &comm_tmp))) HMPI_GOTO_ERROR(FAIL, "MPI_Comm_dup failed", mpi_code) } if (info){ if (MPI_INFO_NULL != fa->info){ if (MPI_SUCCESS != (mpi_code=MPI_Info_dup(fa->info, info))) HMPI_GOTO_ERROR(FAIL, "MPI_Info_dup failed", mpi_code) }else{ /* do not dup it */ *info = MPI_INFO_NULL; } } if (comm) *comm = comm_tmp; done: if (FAIL==ret_value){ /* need to free anything created here */ if (comm_tmp != MPI_COMM_NULL) MPI_Comm_free(&comm_tmp); } FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5Pset_dxpl_mpio * * Purpose: Set the data transfer property list DXPL_ID to use transfer * mode XFER_MODE. The property list can then be used to control * the I/O transfer mode during data I/O operations. The valid * transfer modes are: * * H5FD_MPIO_INDEPENDENT: * Use independent I/O access (the default). * * H5FD_MPIO_COLLECTIVE: * Use collective I/O access. * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Albert Cheng * April 2, 1998 * * Modifications: * Robb Matzke, 1999-08-06 * Modified to work with the virtual file layer. *------------------------------------------------------------------------- */ herr_t H5Pset_dxpl_mpio(hid_t dxpl_id, H5FD_mpio_xfer_t xfer_mode) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value; FUNC_ENTER_API(H5Pset_dxpl_mpio, FAIL) H5TRACE2("e","iDt",dxpl_id,xfer_mode); if(dxpl_id==H5P_DEFAULT) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't set values in default property list") /* Check arguments */ if(NULL == (plist = H5P_object_verify(dxpl_id,H5P_DATASET_XFER))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dxpl") if (H5FD_MPIO_INDEPENDENT!=xfer_mode && H5FD_MPIO_COLLECTIVE!=xfer_mode) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "incorrect xfer_mode") /* Set the transfer mode */ if (H5P_set(plist,H5D_XFER_IO_XFER_MODE_NAME,&xfer_mode)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value") /* Initialize driver-specific properties */ ret_value= H5P_set_driver(plist, H5FD_MPIO, NULL); done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5Pget_dxpl_mpio * * Purpose: Queries the transfer mode current set in the data transfer * property list DXPL_ID. This is not collective. * * Return: Success: Non-negative, with the transfer mode returned * through the XFER_MODE argument if it is * non-null. * * Failure: Negative * * Programmer: Albert Cheng * April 2, 1998 * * Modifications: * Robb Matzke, 1999-08-06 * Modified to work with the virtual file layer. *------------------------------------------------------------------------- */ herr_t H5Pget_dxpl_mpio(hid_t dxpl_id, H5FD_mpio_xfer_t *xfer_mode/*out*/) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Pget_dxpl_mpio, FAIL) H5TRACE2("e","ix",dxpl_id,xfer_mode); if(NULL == (plist = H5P_object_verify(dxpl_id,H5P_DATASET_XFER))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dxpl") if (H5FD_MPIO!=H5P_get_driver(plist)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver") /* Get the transfer mode */ if (xfer_mode) if (H5P_get(plist,H5D_XFER_IO_XFER_MODE_NAME,xfer_mode)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to get value") done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_mpio_fapl_get * * Purpose: Returns a file access property list which could be used to * create another file the same as this one. * * Return: Success: Ptr to new file access property list with all * fields copied from the file pointer. * * Failure: NULL * * Programmer: Robb Matzke * Friday, August 13, 1999 * * Modifications: * Albert Cheng, 2003-04-17 * Duplicate the communicator and Info object so that the new * property list is insulated from the old one. *------------------------------------------------------------------------- */ static void * H5FD_mpio_fapl_get(H5FD_t *_file) { H5FD_mpio_t *file = (H5FD_mpio_t*)_file; H5FD_mpio_fapl_t *fa = NULL; void *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_mpio_fapl_get, NULL) assert(file); assert(H5FD_MPIO==file->pub.driver_id); if (NULL==(fa=H5MM_calloc(sizeof(H5FD_mpio_fapl_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Duplicate communicator and Info object. */ if (FAIL==H5FD_mpi_comm_info_dup(file->comm, file->info, &fa->comm, &fa->info)) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOPY, NULL, "Communicator/Info duplicate failed") /* Set return value */ ret_value=fa; done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_mpio_fapl_copy * * Purpose: Copies the mpio-specific file access properties. * * Return: Success: Ptr to a new property list * * Failure: NULL * * Programmer: Albert Cheng * Jan 8, 2003 * * Modifications: * *------------------------------------------------------------------------- */ static void * H5FD_mpio_fapl_copy(const void *_old_fa) { void *ret_value = NULL; const H5FD_mpio_fapl_t *old_fa = (const H5FD_mpio_fapl_t*)_old_fa; H5FD_mpio_fapl_t *new_fa = NULL; FUNC_ENTER_NOAPI(H5FD_mpio_fapl_copy, NULL) #ifdef H5FDmpio_DEBUG if (H5FD_mpio_Debug[(int)'t']) fprintf(stderr, "enter H5FD_mpio_fapl_copy\n"); #endif if (NULL==(new_fa=H5MM_malloc(sizeof(H5FD_mpio_fapl_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Copy the general information */ HDmemcpy(new_fa, old_fa, sizeof(H5FD_mpio_fapl_t)); /* Duplicate communicator and Info object. */ if (FAIL==H5FD_mpi_comm_info_dup(old_fa->comm, old_fa->info, &new_fa->comm, &new_fa->info)) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOPY, NULL, "Communicator/Info duplicate failed") ret_value = new_fa; done: if (NULL == ret_value){ /* cleanup */ if (new_fa) H5MM_xfree(new_fa); } #ifdef H5FDmpio_DEBUG if (H5FD_mpio_Debug[(int)'t']) fprintf(stderr, "leaving H5FD_mpio_fapl_copy\n"); #endif FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpio_fapl_copy() */ /*------------------------------------------------------------------------- * Function: H5FD_mpio_fapl_free * * Purpose: Frees the mpio-specific file access properties. * * Return: Success: 0 * * Failure: -1 * * Programmer: Albert Cheng * Jan 8, 2003 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_mpio_fapl_free(void *_fa) { herr_t ret_value = SUCCEED; H5FD_mpio_fapl_t *fa = (H5FD_mpio_fapl_t*)_fa; FUNC_ENTER_NOAPI(H5FD_mpio_fapl_free, FAIL) #ifdef H5FDmpio_DEBUG if (H5FD_mpio_Debug[(int)'t']) fprintf(stderr, "in H5FD_mpio_fapl_free\n"); #endif assert(fa); /* Free the internal communicator and INFO object */ assert(MPI_COMM_NULL!=fa->comm); H5FD_mpi_comm_info_free(&fa->comm, &fa->info); H5MM_xfree(fa); done: #ifdef H5FDmpio_DEBUG if (H5FD_mpio_Debug[(int)'t']) fprintf(stderr, "leaving H5FD_mpio_fapl_free\n"); #endif FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpio_fapl_free() */ /*------------------------------------------------------------------------- * Function: H5FD_mpio_open * * Purpose: Opens a file with name NAME. The FLAGS are a bit field with * purpose similar to the second argument of open(2) and which * are defined in H5Fpublic.h. The file access property list * FAPL_ID contains the properties driver properties and MAXADDR * is the largest address which this file will be expected to * access. This is collective. * * Return: Success: A new file pointer. * * Failure: NULL * * Programmer: * January 30, 1998 * * Modifications: * Robb Matzke, 1998-02-18 * Added the ACCESS_PARMS argument. Moved some error checking * here from elsewhere. * * rky, 1998-01-11 * Added H5FD_mpio_Debug debug flags controlled by MPI_Info. * * rky, 1998-08-28 * Init flag controlling redundant metadata writes to disk. * * rky, 1998-12-07 * Added barrier after MPI_File_set_size to prevent race * condition -- subsequent writes were being truncated, causing * holes in file. * * Robb Matzke, 1999-08-06 * Modified to work with the virtual file layer. * * rky & ppw, 1999-11-07 * Modified "H5FD_mpio_open" so that file-truncation is * avoided for brand-new files (with zero filesize). * * Albert Cheng, 2003-04-17 * Duplicate the communicator and Info object so that file is * insulated from the old one. *------------------------------------------------------------------------- */ static H5FD_t * H5FD_mpio_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t UNUSED maxaddr) { H5FD_mpio_t *file=NULL; MPI_File fh; unsigned file_opened=0; /* Flag to indicate that the file was successfully opened */ int mpi_amode; int mpi_rank; /* MPI rank of this process */ int mpi_size; /* Total number of MPI processes */ int mpi_code; /* mpi return code */ MPI_Offset size; const H5FD_mpio_fapl_t *fa=NULL; H5FD_mpio_fapl_t _fa; H5P_genplist_t *plist; /* Property list pointer */ MPI_Comm comm_dup=MPI_COMM_NULL; MPI_Info info_dup=MPI_INFO_NULL; H5FD_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_mpio_open, NULL) #ifdef H5FDmpio_DEBUG if (H5FD_mpio_Debug[(int)'t']) { fprintf(stdout, "Entering H5FD_mpio_open(name=\"%s\", flags=0x%x, " "fapl_id=%d, maxaddr=%lu)\n", name, flags, (int)fapl_id, (unsigned long)maxaddr); } #endif /* Obtain a pointer to mpio-specific file access properties */ if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") if (H5P_FILE_ACCESS_DEFAULT==fapl_id || H5FD_MPIO!=H5P_get_driver(plist)) { _fa.comm = MPI_COMM_SELF; /*default*/ _fa.info = MPI_INFO_NULL; /*default*/ fa = &_fa; } else { fa = H5P_get_driver_info(plist); assert(fa); } /* Duplicate communicator and Info object for use by this file. */ if (FAIL==H5FD_mpi_comm_info_dup(fa->comm, fa->info, &comm_dup, &info_dup)) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOPY, NULL, "Communicator/Info duplicate failed") /* convert HDF5 flags to MPI-IO flags */ /* some combinations are illegal; let MPI-IO figure it out */ mpi_amode = (flags&H5F_ACC_RDWR) ? MPI_MODE_RDWR : MPI_MODE_RDONLY; if (flags&H5F_ACC_CREAT) mpi_amode |= MPI_MODE_CREATE; if (flags&H5F_ACC_EXCL) mpi_amode |= MPI_MODE_EXCL; #ifdef H5FDmpio_DEBUG /* Check for debug commands in the info parameter */ { char debug_str[128]; int flag, i; if (MPI_INFO_NULL != info_dup) { /*OKAY: CAST DISCARDS CONST*/ MPI_Info_get(fa->info, (char *)H5F_MPIO_DEBUG_KEY, 127, debug_str, &flag); if (flag) { fprintf(stdout, "H5FD_mpio debug flags=%s\n", debug_str ); for (i=0; debug_str[i]/*end of string*/ && i<128/*just in case*/; ++i) { H5FD_mpio_Debug[(int)debug_str[i]] = 1; } } } } #endif /*OKAY: CAST DISCARDS CONST*/ if (MPI_SUCCESS != (mpi_code=MPI_File_open(comm_dup, (char*)name, mpi_amode, info_dup, &fh))) HMPI_GOTO_ERROR(NULL, "MPI_File_open failed", mpi_code) file_opened=1; /* Get the MPI rank of this process and the total number of processes */ if (MPI_SUCCESS != (mpi_code=MPI_Comm_rank (comm_dup, &mpi_rank))) HMPI_GOTO_ERROR(NULL, "MPI_Comm_rank failed", mpi_code) if (MPI_SUCCESS != (mpi_code=MPI_Comm_size (comm_dup, &mpi_size))) HMPI_GOTO_ERROR(NULL, "MPI_Comm_size failed", mpi_code) /* Build the return value and initialize it */ if (NULL==(file=H5MM_calloc(sizeof(H5FD_mpio_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") file->f = fh; file->comm = comm_dup; file->info = info_dup; file->mpi_rank = mpi_rank; file->mpi_size = mpi_size; /* Only processor p0 will get the filesize and broadcast it. */ if (mpi_rank == 0) { /* Get current file size */ if (MPI_SUCCESS != (mpi_code=MPI_File_get_size(fh, &size))) HMPI_GOTO_ERROR(NULL, "MPI_File_get_size failed", mpi_code) } /* end if */ /* Broadcast file size */ if (MPI_SUCCESS != (mpi_code=MPI_Bcast(&size, sizeof(MPI_Offset), MPI_BYTE, 0, comm_dup))) HMPI_GOTO_ERROR(NULL, "MPI_Bcast failed", mpi_code) /* Determine if the file should be truncated */ if(size && (flags & H5F_ACC_TRUNC)) { if (MPI_SUCCESS != (mpi_code=MPI_File_set_size(fh, (MPI_Offset)0))) HMPI_GOTO_ERROR(NULL, "MPI_File_set_size failed", mpi_code) /* Don't let any proc return until all have truncated the file. */ if (MPI_SUCCESS!= (mpi_code=MPI_Barrier(comm_dup))) HMPI_GOTO_ERROR(NULL, "MPI_Barrier failed", mpi_code) /* File is zero size now */ size = 0; } /* end if */ /* Set the size of the file (from library's perspective) */ file->eof = H5FD_mpi_MPIOff_to_haddr(size); /* Set return value */ ret_value=(H5FD_t*)file; done: if(ret_value==NULL) { if(file_opened) MPI_File_close(&fh); if (MPI_COMM_NULL != comm_dup) MPI_Comm_free(&comm_dup); if (MPI_INFO_NULL != info_dup) MPI_Info_free(&info_dup); if (file) H5MM_xfree(file); } /* end if */ #ifdef H5FDmpio_DEBUG if (H5FD_mpio_Debug[(int)'t']) fprintf(stdout, "Leaving H5FD_mpio_open\n" ); #endif FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_mpio_close * * Purpose: Closes a file. This is collective. * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Unknown * January 30, 1998 * * Modifications: * Robb Matzke, 1998-02-18 * Added the ACCESS_PARMS argument. * * Robb Matzke, 1999-08-06 * Modified to work with the virtual file layer. * * Albert Cheng, 2003-04-17 * Free the communicator stored. *------------------------------------------------------------------------- */ static herr_t H5FD_mpio_close(H5FD_t *_file) { H5FD_mpio_t *file = (H5FD_mpio_t*)_file; int mpi_code; /* MPI return code */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_mpio_close, FAIL) #ifdef H5FDmpio_DEBUG if (H5FD_mpio_Debug[(int)'t']) fprintf(stdout, "Entering H5FD_mpio_close\n"); #endif assert(file); assert(H5FD_MPIO==file->pub.driver_id); /* MPI_File_close sets argument to MPI_FILE_NULL */ if (MPI_SUCCESS != (mpi_code=MPI_File_close(&(file->f)/*in,out*/))) HMPI_GOTO_ERROR(FAIL, "MPI_File_close failed", mpi_code) /* Clean up other stuff */ H5FD_mpi_comm_info_free(&file->comm, &file->info); H5MM_xfree(file); done: #ifdef H5FDmpio_DEBUG if (H5FD_mpio_Debug[(int)'t']) fprintf(stdout, "Leaving H5FD_mpio_close\n"); #endif FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_mpio_query * * Purpose: Set the flags that this VFL driver is capable of supporting. * (listed in H5FDpublic.h) * * Return: Success: non-negative * * Failure: negative * * Programmer: Quincey Koziol * Friday, August 25, 2000 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_mpio_query(const H5FD_t UNUSED *_file, unsigned long *flags /* out */) { herr_t ret_value=SUCCEED; FUNC_ENTER_NOAPI(H5FD_mpio_query, FAIL) /* Set the VFL feature flags that this driver supports */ if(flags) { *flags=0; *flags|=H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ /* Distinguish between updating the metadata accumulator on writes and * reads. This is particularly (perhaps only, even) important for MPI-I/O * where we guarantee that writes are collective, but reads may not be. * If we were to allow the metadata accumulator to be written during a * read operation, the application would hang. */ *flags|=H5FD_FEAT_ACCUMULATE_METADATA_WRITE; /* OK to accumulate metadata for faster writes */ *flags|=H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_mpio_get_eoa * * Purpose: Gets the end-of-address marker for the file. The EOA marker * is the first address past the last byte allocated in the * format address space. * * Return: Success: The end-of-address marker. * * Failure: HADDR_UNDEF * * Programmer: Robb Matzke * Friday, August 6, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static haddr_t H5FD_mpio_get_eoa(H5FD_t *_file) { H5FD_mpio_t *file = (H5FD_mpio_t*)_file; haddr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_mpio_get_eoa, HADDR_UNDEF) assert(file); assert(H5FD_MPIO==file->pub.driver_id); /* Set return value */ ret_value=file->eoa; done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_mpio_set_eoa * * Purpose: Set the end-of-address marker for the file. This function is * called shortly after an existing HDF5 file is opened in order * to tell the driver where the end of the HDF5 data is located. * * Return: Success: 0 * * Failure: -1 * * Programmer: Robb Matzke * Friday, August 6, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_mpio_set_eoa(H5FD_t *_file, haddr_t addr) { H5FD_mpio_t *file = (H5FD_mpio_t*)_file; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_mpio_set_eoa, FAIL) assert(file); assert(H5FD_MPIO==file->pub.driver_id); file->eoa = addr; done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_mpio_get_eof * * Purpose: Gets the end-of-file marker for the file. The EOF marker * is the real size of the file. * * The MPIO driver doesn't bother keeping this field updated * since that's a relatively expensive operation. Fortunately * the library only needs the EOF just after the file is opened * in order to determine whether the file is empty, truncated, * or okay. Therefore, any MPIO I/O function will set its value * to HADDR_UNDEF which is the error return value of this * function. * * Keeping the EOF updated (during write calls) is expensive * because any process may extend the physical end of the * file. -QAK * * Return: Success: The end-of-address marker. * * Failure: HADDR_UNDEF * * Programmer: Robb Matzke * Friday, August 6, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static haddr_t H5FD_mpio_get_eof(H5FD_t *_file) { H5FD_mpio_t *file = (H5FD_mpio_t*)_file; haddr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_mpio_get_eof, HADDR_UNDEF) assert(file); assert(H5FD_MPIO==file->pub.driver_id); /* Set return value */ ret_value=file->eof; done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_mpio_get_handle * * Purpose: Returns the file handle of MPIO file driver. * * Returns: Non-negative if succeed or negative if fails. * * Programmer: Raymond Lu * Sept. 16, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_mpio_get_handle(H5FD_t *_file, hid_t UNUSED fapl, void** file_handle) { H5FD_mpio_t *file = (H5FD_mpio_t *)_file; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5FD_mpio_get_handle, FAIL) if(!file_handle) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file handle not valid") *file_handle = &(file->f); done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_mpio_read * * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR * into buffer BUF according to data transfer properties in * DXPL_ID using potentially complex file and buffer types to * effect the transfer. * * Reading past the end of the MPI file returns zeros instead of * failing. MPI is able to coalesce requests from different * processes (collective or independent). * * Return: Success: Zero. Result is stored in caller-supplied * buffer BUF. * * Failure: -1, Contents of buffer BUF are undefined. * * Programmer: rky, 1998-01-30 * * Modifications: * Robb Matzke, 1998-02-18 * Added the ACCESS_PARMS argument. * * rky, 1998-04-10 * Call independent or collective MPI read, based on * ACCESS_PARMS. * * Albert Cheng, 1998-06-01 * Added XFER_MODE to control independent or collective MPI * read. * * rky, 1998-08-16 * Use BTYPE, FTYPE, and DISP from access parms. The guts of * H5FD_mpio_read and H5FD_mpio_write should be replaced by a * single dual-purpose routine. * * Robb Matzke, 1999-04-21 * Changed XFER_MODE to XFER_PARMS for all H5F_*_read() * callbacks. * * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. * * Robb Matzke, 1999-08-06 * Modified to work with the virtual file layer. * * Quincey Koziol, 2002-05-14 * Only call MPI_Get_count if we can use MPI_BYTE for the MPI type * for the I/O transfer. Someday we might include code to decode * the MPI type used for more complicated transfers and call * MPI_Get_count all the time. * * Quincey Koziol - 2002/06/17 * Removed 'disp' parameter from H5FD_mpio_setup routine and use * the address of the dataset in MPI_File_set_view() calls, as * necessary. * * Quincey Koziol - 2002/06/24 * Removed "lazy" MPI_File_set_view() calls, since they would fail * if the first I/O was a collective I/O using MPI derived types * and the next I/O was an independent I/O. * * Quincey Koziol - 2003/10/22-31 * Restructured code massively, straightening out logic and finally * getting the bytes_read stuff working. * *------------------------------------------------------------------------- */ static herr_t H5FD_mpio_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t dxpl_id, haddr_t addr, size_t size, void *buf/*out*/) { H5FD_mpio_t *file = (H5FD_mpio_t*)_file; MPI_Offset mpi_off; MPI_Status mpi_stat; int mpi_code; /* mpi return code */ MPI_Datatype buf_type=MPI_BYTE; /* MPI description of the selection in memory */ int size_i; /* Integer copy of 'size' to read */ int bytes_read; /* Number of bytes read in */ int n; int type_size; /* MPI datatype used for I/O's size */ int io_size; /* Actual number of bytes requested */ unsigned use_view_this_time=0; herr_t ret_value=SUCCEED; FUNC_ENTER_NOAPI(H5FD_mpio_read, FAIL) #ifdef H5FDmpio_DEBUG if (H5FD_mpio_Debug[(int)'t']) fprintf(stdout, "Entering H5FD_mpio_read\n" ); #endif assert(file); assert(H5FD_MPIO==file->pub.driver_id); /* Make certain we have the correct type of property list */ assert(H5I_GENPROP_LST==H5I_get_type(dxpl_id)); assert(TRUE==H5P_isa_class(dxpl_id,H5P_DATASET_XFER)); assert(buf); /* Portably initialize MPI status variable */ HDmemset(&mpi_stat,0,sizeof(MPI_Status)); /* some numeric conversions */ if (H5FD_mpi_haddr_to_MPIOff(addr, &mpi_off/*out*/)<0) HGOTO_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "can't convert from haddr to MPI off") size_i = (int)size; if ((hsize_t)size_i != size) HGOTO_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "can't convert from size to size_i") #ifdef H5FDmpio_DEBUG if (H5FD_mpio_Debug[(int)'r']) fprintf(stdout, "in H5FD_mpio_read mpi_off=%ld size_i=%d\n", (long)mpi_off, size_i ); #endif /* Only look for MPI views for raw data transfers */ if(type==H5FD_MEM_DRAW) { H5P_genplist_t *plist; /* Property list pointer */ H5FD_mpio_xfer_t xfer_mode; /* I/O tranfer mode */ /* Obtain the data transfer properties */ if(NULL == (plist = H5I_object(dxpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") xfer_mode=(H5FD_mpio_xfer_t)H5P_peek_unsigned(plist, H5D_XFER_IO_XFER_MODE_NAME); /* * Set up for a fancy xfer using complex types, or single byte block. We * wouldn't need to rely on the use_view field if MPI semantics allowed * us to test that btype=ftype=MPI_BYTE (or even MPI_TYPE_NULL, which * could mean "use MPI_BYTE" by convention). */ if(xfer_mode==H5FD_MPIO_COLLECTIVE) { MPI_Datatype file_type; /* Remember that views are used */ use_view_this_time=TRUE; /* prepare for a full-blown xfer using btype, ftype, and disp */ if(H5P_get(plist,H5FD_MPI_XFER_MEM_MPI_TYPE_NAME,&buf_type)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get MPI-I/O type property") if(H5P_get(plist,H5FD_MPI_XFER_FILE_MPI_TYPE_NAME,&file_type)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get MPI-I/O type property") /* * Set the file view when we are using MPI derived types */ /*OKAY: CAST DISCARDS CONST QUALIFIER*/ if (MPI_SUCCESS != (mpi_code=MPI_File_set_view(file->f, mpi_off, MPI_BYTE, file_type, H5FD_mpi_native_g, file->info))) HMPI_GOTO_ERROR(FAIL, "MPI_File_set_view failed", mpi_code) /* When using types, use the address as the displacement for * MPI_File_set_view and reset the address for the read to zero */ mpi_off=0; } /* end if */ } /* end if */ /* Read the data. */ if (use_view_this_time) { #ifdef H5FDmpio_DEBUG if (H5FD_mpio_Debug[(int)'t']) fprintf(stdout, "H5FD_mpio_read: using MPIO collective mode\n"); #endif if (MPI_SUCCESS!= (mpi_code=MPI_File_read_at_all(file->f, mpi_off, buf, size_i, buf_type, &mpi_stat ))) HMPI_GOTO_ERROR(FAIL, "MPI_File_read_at_all failed", mpi_code) /* * Reset the file view when we used MPI derived types */ /*OKAY: CAST DISCARDS CONST QUALIFIER*/ if (MPI_SUCCESS != (mpi_code=MPI_File_set_view(file->f, 0, MPI_BYTE, MPI_BYTE, H5FD_mpi_native_g, file->info))) HMPI_GOTO_ERROR(FAIL, "MPI_File_set_view failed", mpi_code) } else { if (MPI_SUCCESS!= (mpi_code=MPI_File_read_at(file->f, mpi_off, buf, size_i, buf_type, &mpi_stat))) HMPI_GOTO_ERROR(FAIL, "MPI_File_read_at failed", mpi_code) } /* How many bytes were actually read? */ /* [This works because the "basic elements" we use for all our MPI derived * types are MPI_BYTE. We should be using the 'buf_type' for the MPI * datatype in this call though... (We aren't because using it causes * the LANL "qsc" machine to dump core - 12/19/03) - QAK] */ if (MPI_SUCCESS != (mpi_code=MPI_Get_elements(&mpi_stat, MPI_BYTE, &bytes_read))) HMPI_GOTO_ERROR(FAIL, "MPI_Get_elements failed", mpi_code) /* Get the type's size */ if (MPI_SUCCESS != (mpi_code=MPI_Type_size(buf_type,&type_size))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_size failed", mpi_code) /* Compute the actual number of bytes requested */ io_size=type_size*size_i; /* Check for read failure */ if (bytes_read<0 || bytes_read>io_size) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed") /* * This gives us zeroes beyond end of physical MPI file. */ if ((n=(io_size-bytes_read)) > 0) HDmemset((char*)buf+bytes_read, 0, (size_t)n); done: #ifdef H5FDmpio_DEBUG if (H5FD_mpio_Debug[(int)'t']) fprintf(stdout, "Leaving H5FD_mpio_read\n" ); #endif FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_mpio_write * * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR * from buffer BUF according to data transfer properties in * DXPL_ID using potentially complex file and buffer types to * effect the transfer. * * MPI is able to coalesce requests from different processes * (collective and independent). * * Return: Success: Zero. USE_TYPES and OLD_USE_TYPES in the * access params are altered. * * Failure: -1, USE_TYPES and OLD_USE_TYPES in the * access params may be altered. * * Programmer: Unknown * January 30, 1998 * * Modifications: * rky, 1998-08-28 * If the file->allsame flag is set, we assume that all the * procs in the relevant MPI communicator will write identical * data at identical offsets in the file, so only proc 0 will * write, and all other procs will wait for p0 to finish. This * is useful for writing metadata, for example. Note that we * don't _check_ that the data is identical. Also, the mechanism * we use to eliminate the redundant writes is by requiring a * call to H5FD_mpio_tas_allsame before the write, which is * rather klugey. Would it be better to pass a parameter to * low-level writes like H5F_block_write and H5F_low_write, * instead? Or...??? Also, when I created this mechanism I * wanted to minimize the difference in behavior between the old * way of doing things (i.e., all procs write) and the new way, * so the writes are eliminated at the very lowest level, here * in H5FD_mpio_write. It may be better to rethink that, and * short-circuit the writes at a higher level (e.g., at the * points in the code where H5FD_mpio_tas_allsame is called). * * * Robb Matzke, 1998-02-18 * Added the ACCESS_PARMS argument. * * rky, 1998-04-10 * Call independent or collective MPI write, based on * ACCESS_PARMS. * * rky, 1998-04-24 * Removed redundant write from H5FD_mpio_write. * * Albert Cheng, 1998-06-01 * Added XFER_MODE to control independent or collective MPI * write. * * rky, 1998-08-16 * Use BTYPE, FTYPE, and DISP from access parms. The guts of * H5FD_mpio_read and H5FD_mpio_write should be replaced by a * single dual-purpose routine. * * rky, 1998-08-28 * Added ALLSAME parameter to make all but proc 0 skip the * actual write. * * Robb Matzke, 1999-04-21 * Changed XFER_MODE to XFER_PARMS for all H5FD_*_write() * callbacks. * * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. * * Robb Matzke, 1999-08-06 * Modified to work with the virtual file layer. * * Albert Cheng, 1999-12-19 * When only-p0-write-allsame-data, p0 Bcasts the * ret_value to other processes. This prevents * a racing condition (that other processes try to * read the file before p0 finishes writing) and also * allows all processes to report the same ret_value. * * Kim Yates, Pat Weidhaas, 2000-09-26 * Move block of coding where only p0 writes after the * MPI_File_set_view call. * * Quincey Koziol, 2002-05-10 * Instead of always writing metadata from process 0, spread the * burden among all the processes by using a round-robin rotation * scheme. * * Quincey Koziol, 2002-05-10 * Removed allsame code, keying off the type parameter instead. * * Quincey Koziol, 2002-05-14 * Only call MPI_Get_count if we can use MPI_BYTE for the MPI type * for the I/O transfer. Someday we might include code to decode * the MPI type used for more complicated transfers and call * MPI_Get_count all the time. * * Quincey Koziol - 2002/06/17 * Removed 'disp' parameter from H5FD_mpio_setup routine and use * the address of the dataset in MPI_File_set_view() calls, as * necessary. * * Quincey Koziol - 2002/06/24 * Removed "lazy" MPI_File_set_view() calls, since they would fail * if the first I/O was a collective I/O using MPI derived types * and the next I/O was an independent I/O. * * Quincey Koziol - 2002/07/18 * Added "block_before_meta_write" dataset transfer flag, which * is set during writes from a metadata cache flush and indicates * that all the processes must sync up before (one of them) * writing metadata. * * Quincey Koziol - 2003/10/22-31 * Restructured code massively, straightening out logic and finally * getting the bytes_written stuff working. * *------------------------------------------------------------------------- */ static herr_t H5FD_mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, const void *buf) { H5FD_mpio_t *file = (H5FD_mpio_t*)_file; MPI_Offset mpi_off; MPI_Status mpi_stat; MPI_Datatype buf_type=MPI_BYTE; /* MPI description of the selection in memory */ int mpi_code; /* MPI return code */ int size_i, bytes_written; int type_size; /* MPI datatype used for I/O's size */ int io_size; /* Actual number of bytes requested */ unsigned use_view_this_time=0; H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; FUNC_ENTER_NOAPI(H5FD_mpio_write, FAIL) #ifdef H5FDmpio_DEBUG if (H5FD_mpio_Debug[(int)'t']) fprintf(stdout, "Entering H5FD_mpio_write\n" ); #endif assert(file); assert(H5FD_MPIO==file->pub.driver_id); /* Make certain we have the correct type of property list */ assert(H5I_GENPROP_LST==H5I_get_type(dxpl_id)); assert(TRUE==H5P_isa_class(dxpl_id,H5P_DATASET_XFER)); assert(buf); /* Portably initialize MPI status variable */ HDmemset(&mpi_stat,0,sizeof(MPI_Status)); /* some numeric conversions */ if (H5FD_mpi_haddr_to_MPIOff(addr, &mpi_off)<0) HGOTO_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "can't convert from haddr to MPI off") size_i = (int)size; if ((hsize_t)size_i != size) HGOTO_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "can't convert from size to size_i") #ifdef H5FDmpio_DEBUG if (H5FD_mpio_Debug[(int)'w']) fprintf(stdout, "in H5FD_mpio_write mpi_off=%ld size_i=%d\n", (long)mpi_off, size_i); #endif /* Obtain the data transfer properties */ if(NULL == (plist = H5I_object(dxpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") if(type==H5FD_MEM_DRAW) { H5FD_mpio_xfer_t xfer_mode; /* I/O tranfer mode */ /* Obtain the data transfer properties */ xfer_mode = (H5FD_mpio_xfer_t)H5P_peek_unsigned(plist, H5D_XFER_IO_XFER_MODE_NAME); /* * Set up for a fancy xfer using complex types, or single byte block. We * wouldn't need to rely on the use_view field if MPI semantics allowed * us to test that btype=ftype=MPI_BYTE (or even MPI_TYPE_NULL, which * could mean "use MPI_BYTE" by convention). */ if(xfer_mode==H5FD_MPIO_COLLECTIVE) { MPI_Datatype file_type; /* Remember that views are used */ use_view_this_time=TRUE; /* prepare for a full-blown xfer using btype, ftype, and disp */ if(H5P_get(plist,H5FD_MPI_XFER_MEM_MPI_TYPE_NAME,&buf_type)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get MPI-I/O type property") if(H5P_get(plist,H5FD_MPI_XFER_FILE_MPI_TYPE_NAME,&file_type)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get MPI-I/O type property") /* * Set the file view when we are using MPI derived types */ /*OKAY: CAST DISCARDS CONST QUALIFIER*/ if (MPI_SUCCESS != (mpi_code=MPI_File_set_view(file->f, mpi_off, MPI_BYTE, file_type, H5FD_mpi_native_g, file->info))) HMPI_GOTO_ERROR(FAIL, "MPI_File_set_view failed", mpi_code) /* When using types, use the address as the displacement for * MPI_File_set_view and reset the address for the read to zero */ mpi_off=0; } /* end if */ } /* end if */ else { unsigned block_before_meta_write=0; /* Whether to block before a metadata write */ /* Check if we need to syncronize all processes before attempting metadata write * (Prevents race condition where the process writing the metadata goes ahead * and writes the metadata to the file before all the processes have * read the data, "transmitting" data from the "future" to the reading * process. -QAK ) * * The only time we don't want to block before a metadata write is when * we are flushing out a bunch of metadata. Then, we block before the * first write and don't block for further writes in the sequence. */ if(H5P_exist_plist(plist,H5AC_BLOCK_BEFORE_META_WRITE_NAME)>0) if(H5P_get(plist,H5AC_BLOCK_BEFORE_META_WRITE_NAME,&block_before_meta_write)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get H5AC property") if(block_before_meta_write) if (MPI_SUCCESS!= (mpi_code=MPI_Barrier(file->comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed", mpi_code) /* Only one process will do the actual write if all procs in comm write same metadata */ if (file->mpi_rank != H5_PAR_META_WRITE) { #ifdef H5FDmpio_DEBUG if (H5FD_mpio_Debug[(int)'w']) { fprintf(stdout, " proc %d: in H5FD_mpio_write (write omitted)\n", file->mpi_rank ); } #endif HGOTO_DONE(SUCCEED) /* skip the actual write */ } /* end if */ } /* end if */ /* Write the data. */ if (use_view_this_time) { #ifdef H5FDmpio_DEBUG if (H5FD_mpio_Debug[(int)'t']) fprintf(stdout, "H5FD_mpio_write: using MPIO collective mode\n"); #endif /*OKAY: CAST DISCARDS CONST QUALIFIER*/ if (MPI_SUCCESS != (mpi_code=MPI_File_write_at_all(file->f, mpi_off, (void*)buf, size_i, buf_type, &mpi_stat))) HMPI_GOTO_ERROR(FAIL, "MPI_File_write_at_all failed", mpi_code) /* * Reset the file view when we used MPI derived types */ /*OKAY: CAST DISCARDS CONST QUALIFIER*/ if (MPI_SUCCESS != (mpi_code=MPI_File_set_view(file->f, 0, MPI_BYTE, MPI_BYTE, H5FD_mpi_native_g, file->info))) HMPI_GOTO_ERROR(FAIL, "MPI_File_set_view failed", mpi_code) } else { /*OKAY: CAST DISCARDS CONST QUALIFIER*/ if (MPI_SUCCESS != (mpi_code=MPI_File_write_at(file->f, mpi_off, (void*)buf, size_i, buf_type, &mpi_stat))) HMPI_GOTO_ERROR(FAIL, "MPI_File_write_at failed", mpi_code) } /* How many bytes were actually written? */ /* [This works because the "basic elements" we use for all our MPI derived * types are MPI_BYTE. We should be using the 'buf_type' for the MPI * datatype in this call though... (We aren't because using it causes * the LANL "qsc" machine to dump core - 12/19/03) - QAK] */ if (MPI_SUCCESS != (mpi_code=MPI_Get_elements(&mpi_stat, MPI_BYTE, &bytes_written))) HMPI_GOTO_ERROR(FAIL, "MPI_Get_elements failed", mpi_code) /* Get the type's size */ if (MPI_SUCCESS != (mpi_code=MPI_Type_size(buf_type,&type_size))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_size failed", mpi_code) /* Compute the actual number of bytes requested */ io_size=type_size*size_i; /* Check for write failure */ if (bytes_written != io_size) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") /* Forget the EOF value (see H5FD_mpio_get_eof()) --rpm 1999-08-06 */ file->eof = HADDR_UNDEF; done: /* if only one process writes, need to broadcast the ret_value to other processes */ if (type!=H5FD_MEM_DRAW) { if (MPI_SUCCESS != (mpi_code=MPI_Bcast(&ret_value, sizeof(ret_value), MPI_BYTE, H5_PAR_META_WRITE, file->comm))) HMPI_DONE_ERROR(FAIL, "MPI_Bcast failed", mpi_code) } /* end if */ #ifdef H5FDmpio_DEBUG if (H5FD_mpio_Debug[(int)'t']) fprintf(stdout, "proc %d: Leaving H5FD_mpio_write with ret_value=%d\n", file->mpi_rank, ret_value ); #endif FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_mpio_flush * * Purpose: Makes sure that all data is on disk. This is collective. * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Unknown * January 30, 1998 * * Modifications: * Robb Matzke, 1998-02-18 * Added the ACCESS_PARMS argument. * * Robb Matzke, 1999-08-06 * Modified to work with the virtual file layer. * * Robb Matzke, 2000-12-29 * Make sure file size is at least as large as the last * allocated byte. * * Quincey Koziol, 2002-06-?? * Changed file extension method to use MPI_File_set_size instead * read->write method. * *------------------------------------------------------------------------- */ static herr_t H5FD_mpio_flush(H5FD_t *_file, hid_t UNUSED dxpl_id, unsigned closing) { H5FD_mpio_t *file = (H5FD_mpio_t*)_file; int mpi_code; /* mpi return code */ MPI_Offset mpi_off; herr_t ret_value=SUCCEED; FUNC_ENTER_NOAPI(H5FD_mpio_flush, FAIL) #ifdef H5FDmpio_DEBUG if (H5FD_mpio_Debug[(int)'t']) fprintf(stdout, "Entering H5FD_mpio_flush\n" ); #endif assert(file); assert(H5FD_MPIO==file->pub.driver_id); /* Extend the file to make sure it's large enough, then sync. * Unfortunately, keeping track of EOF is an expensive operation, so * we can't just check whether EOFeoa>file->last_eoa) { #ifdef H5_MPI_FILE_SET_SIZE_BIG if (H5FD_mpi_haddr_to_MPIOff(file->eoa, &mpi_off)<0) HGOTO_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "cannot convert from haddr_t to MPI_Offset") /* Extend the file's size */ if (MPI_SUCCESS != (mpi_code=MPI_File_set_size(file->f, mpi_off))) HMPI_GOTO_ERROR(FAIL, "MPI_File_set_size failed", mpi_code) #else /* H5_MPI_FILE_SET_SIZE_BIG */ if (0==file->mpi_rank) { uint8_t byte=0; MPI_Status mpi_stat; /* Portably initialize MPI status variable */ HDmemset(&mpi_stat,0,sizeof(MPI_Status)); if (H5FD_mpi_haddr_to_MPIOff(file->eoa-1, &mpi_off)<0) HGOTO_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "cannot convert from haddr_t to MPI_Offset") if (MPI_SUCCESS != (mpi_code=MPI_File_read_at(file->f, mpi_off, &byte, 1, MPI_BYTE, &mpi_stat))) HMPI_GOTO_ERROR(FAIL, "MPI_File_read_at failed", mpi_code) if (MPI_SUCCESS != (mpi_code=MPI_File_write_at(file->f, mpi_off, &byte, 1, MPI_BYTE, &mpi_stat))) HMPI_GOTO_ERROR(FAIL, "MPI_File_write_at failed", mpi_code) } /* end if */ #endif /* H5_MPI_FILE_SET_SIZE_BIG */ /* Don't let any proc return until all have extended the file. * (Prevents race condition where some processes go ahead and write * more data to the file before all the processes have finished making * it the shorter length, potentially truncating the file and dropping * the new data written) */ if (MPI_SUCCESS!= (mpi_code=MPI_Barrier(file->comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed", mpi_code) /* Update the 'last' eoa value */ file->last_eoa=file->eoa; } /* end if */ /* Only sync the file if we are not going to immediately close it */ if(!closing) { if (MPI_SUCCESS != (mpi_code=MPI_File_sync(file->f))) HMPI_GOTO_ERROR(FAIL, "MPI_File_sync failed", mpi_code) } /* end if */ done: #ifdef H5FDmpio_DEBUG if (H5FD_mpio_Debug[(int)'t']) fprintf(stdout, "Leaving H5FD_mpio_flush\n" ); #endif FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_mpio_mpi_rank * * Purpose: Returns the MPI rank for a process * * Return: Success: non-negative * Failure: negative * * Programmer: Quincey Koziol * Thursday, May 16, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static int H5FD_mpio_mpi_rank(const H5FD_t *_file) { const H5FD_mpio_t *file = (const H5FD_mpio_t*)_file; int ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_mpio_mpi_rank, FAIL) assert(file); assert(H5FD_MPIO==file->pub.driver_id); /* Set return value */ ret_value=file->mpi_rank; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpio_mpi_rank() */ /*------------------------------------------------------------------------- * Function: H5FD_mpio_mpi_size * * Purpose: Returns the number of MPI processes * * Return: Success: non-negative * Failure: negative * * Programmer: Quincey Koziol * Thursday, May 16, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static int H5FD_mpio_mpi_size(const H5FD_t *_file) { const H5FD_mpio_t *file = (const H5FD_mpio_t*)_file; int ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_mpio_mpi_size, FAIL) assert(file); assert(H5FD_MPIO==file->pub.driver_id); /* Set return value */ ret_value=file->mpi_size; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpio_mpi_size() */ /*------------------------------------------------------------------------- * Function: H5FD_mpio_communicator * * Purpose: Returns the MPI communicator for the file. * * Return: Success: The communicator * * Failure: NULL * * Programmer: Robb Matzke * Monday, August 9, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static MPI_Comm H5FD_mpio_communicator(const H5FD_t *_file) { const H5FD_mpio_t *file = (const H5FD_mpio_t*)_file; MPI_Comm ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_mpio_communicator, MPI_COMM_NULL) assert(file); assert(H5FD_MPIO==file->pub.driver_id); /* Set return value */ ret_value=file->comm; done: FUNC_LEAVE_NOAPI(ret_value) } #endif /* H5_HAVE_PARALLEL */ xdmf-3.0+git20160803/Utilities/hdf5/H5MFprivate.h0000640000175000017500000000473713003006557021151 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*------------------------------------------------------------------------- * * Created: H5MFprivate.h * Jul 11 1997 * Robb Matzke * * Purpose: Private header file for file memory management. * * Modifications: * *------------------------------------------------------------------------- */ #ifndef _H5MFprivate_H #define _H5MFprivate_H /* Private headers needed by this file */ #include "H5private.h" #include "H5Fprivate.h" #include "H5FDprivate.h" /*file driver */ /* * Feature: Define H5MF_DEBUG on the compiler command line if you want to * see diagnostics from this layer. */ #ifdef NDEBUG # undef H5MF_DEBUG #endif /* * Library prototypes... */ H5_DLL haddr_t H5MF_alloc(H5F_t *f, H5FD_mem_t type, hid_t dxpl_id, hsize_t size); H5_DLL herr_t H5MF_xfree(H5F_t *f, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size); H5_DLL haddr_t H5MF_realloc(H5F_t *f, H5FD_mem_t type, hid_t dxpl_id, haddr_t old_addr, hsize_t old_size, hsize_t new_size); H5_DLL herr_t H5MF_reserve(H5F_t *f, hsize_t size); H5_DLL herr_t H5MF_free_reserved(H5F_t *f, hsize_t size); H5_DLL hbool_t H5MF_alloc_overflow(H5F_t *f, hsize_t size); H5_DLL htri_t H5MF_can_extend(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size, hsize_t extra_requested); H5_DLL htri_t H5MF_extend(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size, hsize_t extra_requested); #endif xdmf-3.0+git20160803/Utilities/hdf5/H5Dio.c0000640000175000017500000042551513003006557017763 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #define H5D_PACKAGE /*suppress error about including H5Dpkg */ #include "H5private.h" /* Generic Functions */ #include "H5Dpkg.h" /* Dataset functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free Lists */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Sprivate.h" /* Dataspace functions */ #include "H5SLprivate.h" /* Skip lists */ #include "H5Vprivate.h" /* Vector and array functions */ /*#define H5D_DEBUG*/ #ifdef H5_HAVE_PARALLEL /* Remove this if H5R_DATASET_REGION is no longer used in this file */ # include "H5Rpublic.h" #endif /*H5_HAVE_PARALLEL*/ /* Local macros */ #define H5D_DEFAULT_SKIPLIST_HEIGHT 8 /* Local typedefs */ /* Information for mapping between file space and memory space */ /* Structure holding information about a chunk's selection for mapping */ typedef struct H5D_chunk_info_t { hsize_t index; /* "Index" of chunk in dataset */ size_t chunk_points; /* Number of elements selected in chunk */ H5S_t *fspace; /* Dataspace describing chunk & selection in it */ hsize_t coords[H5O_LAYOUT_NDIMS]; /* Coordinates of chunk in file dataset's dataspace */ H5S_t *mspace; /* Dataspace describing selection in memory corresponding to this chunk */ unsigned mspace_shared; /* Indicate that the memory space for a chunk is shared and shouldn't be freed */ } H5D_chunk_info_t; /* Main structure holding the mapping between file chunks and memory */ typedef struct fm_map { H5SL_t *fsel; /* Skip list containing file dataspaces for all chunks */ hsize_t last_index; /* Index of last chunk operated on */ H5D_chunk_info_t *last_chunk_info; /* Pointer to last chunk's info */ const H5S_t *file_space; /* Pointer to the file dataspace */ const H5S_t *mem_space; /* Pointer to the memory dataspace */ unsigned mem_space_copy; /* Flag to indicate that the memory dataspace must be copied */ hsize_t f_dims[H5O_LAYOUT_NDIMS]; /* File dataspace dimensions */ H5S_t *mchunk_tmpl; /* Dataspace template for new memory chunks */ unsigned f_ndims; /* Number of dimensions for file dataspace */ H5S_sel_iter_t mem_iter; /* Iterator for elements in memory selection */ unsigned m_ndims; /* Number of dimensions for memory dataspace */ hsize_t chunks[H5O_LAYOUT_NDIMS]; /* Number of chunks in each dimension */ hsize_t chunk_dim[H5O_LAYOUT_NDIMS]; /* Size of chunk in each dimension */ hsize_t down_chunks[H5O_LAYOUT_NDIMS]; /* "down" size of number of chunks in each dimension */ H5O_layout_t *layout; /* Dataset layout information*/ H5S_sel_type msel_type; /* Selection type in memory */ } fm_map; /* Local functions */ static herr_t H5D_fill(const void *fill, const H5T_t *fill_type, void *buf, const H5T_t *buf_type, const H5S_t *space, hid_t dxpl_id); static herr_t H5D_read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, const H5S_t *file_space, hid_t dset_xfer_plist, void *buf/*out*/); static herr_t H5D_write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, const H5S_t *file_space, hid_t dset_xfer_plist, const void *buf); static herr_t H5D_contig_read(H5D_io_info_t *io_info, hsize_t nelmts, const H5T_t *mem_type, const H5S_t *mem_space, const H5S_t *file_space, H5T_path_t *tpath, hid_t src_id, hid_t dst_id, void *buf/*out*/); static herr_t H5D_contig_write(H5D_io_info_t *io_info, hsize_t nelmts, const H5T_t *mem_type, const H5S_t *mem_space, const H5S_t *file_space, H5T_path_t *tpath, hid_t src_id, hid_t dst_id, const void *buf); static herr_t H5D_chunk_read(H5D_io_info_t *io_info, hsize_t nelmts, const H5T_t *mem_type, const H5S_t *mem_space, const H5S_t *file_space, H5T_path_t *tpath, hid_t src_id, hid_t dst_id, void *buf/*out*/); static herr_t H5D_chunk_write(H5D_io_info_t *io_info, hsize_t nelmts, const H5T_t *mem_type, const H5S_t *mem_space, const H5S_t *file_space, H5T_path_t *tpath, hid_t src_id, hid_t dst_id, const void *buf); #ifdef H5_HAVE_PARALLEL /*static herr_t H5D_io_assist_mpio(hid_t dxpl_id, H5D_dxpl_cache_t *dxpl_cache, hbool_t *xfer_mode_changed); static herr_t H5D_io_restore_mpio(hid_t dxpl_id); static htri_t H5D_get_collective_io_consensus(const H5F_t *file, const htri_t local_opinion, const unsigned flags); */ static herr_t H5D_ioinfo_make_ind(H5D_io_info_t *io_info); static herr_t H5D_ioinfo_make_coll(H5D_io_info_t *io_info); static herr_t H5D_ioinfo_term(H5D_io_info_t *io_info); static herr_t H5D_mpio_get_min_chunk(const H5D_io_info_t *io_info, const fm_map *fm, int *min_chunkf); #endif /* H5_HAVE_PARALLEL */ /* I/O info operations */ static herr_t H5D_ioinfo_init(H5D_t *dset, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, const H5S_t *mem_space, const H5S_t *file_space, H5T_path_t *tpath, H5D_io_info_t *io_info); /* Chunk operations */ static herr_t H5D_create_chunk_map(const H5D_t *dataset, const H5T_t *mem_type, const H5S_t *file_space, const H5S_t *mem_space, fm_map *fm); static herr_t H5D_destroy_chunk_map(const fm_map *fm); static herr_t H5D_free_chunk_info(void *item, void *key, void *opdata); static herr_t H5D_create_chunk_file_map_hyper(const fm_map *fm); static herr_t H5D_create_chunk_mem_map_hyper(const fm_map *fm); static herr_t H5D_chunk_file_cb(void *elem, hid_t type_id, unsigned ndims, const hsize_t *coords, void *fm); static herr_t H5D_chunk_mem_cb(void *elem, hid_t type_id, unsigned ndims, const hsize_t *coords, void *fm); /* Declare a free list to manage blocks of single datatype element data */ H5FL_BLK_DEFINE(type_elem); /* Declare a free list to manage blocks of type conversion data */ H5FL_BLK_DEFINE(type_conv); /* Declare a free list to manage the H5D_chunk_info_t struct */ H5FL_DEFINE_STATIC(H5D_chunk_info_t); /*-------------------------------------------------------------------------- NAME H5Dfill PURPOSE Fill a selection in memory with a value USAGE herr_t H5Dfill(fill, fill_type, space, buf, buf_type) const void *fill; IN: Pointer to fill value to use hid_t fill_type_id; IN: Datatype of the fill value void *buf; IN/OUT: Memory buffer to fill selection within hid_t buf_type_id; IN: Datatype of the elements in buffer hid_t space_id; IN: Dataspace describing memory buffer & containing selection to use. RETURNS Non-negative on success/Negative on failure. DESCRIPTION Use the selection in the dataspace to fill elements in a memory buffer. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS If "fill" parameter is NULL, use all zeros as fill value EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5Dfill(const void *fill, hid_t fill_type_id, void *buf, hid_t buf_type_id, hid_t space_id) { H5S_t *space; /* Dataspace */ H5T_t *fill_type; /* Fill-value datatype */ H5T_t *buf_type; /* Buffer datatype */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Dfill, FAIL) H5TRACE5("e","xixii",fill,fill_type_id,buf,buf_type_id,space_id); /* Check args */ if (buf==NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid buffer") if (NULL == (space=H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a dataspace") if (NULL == (fill_type=H5I_object_verify(fill_type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a datatype") if (NULL == (buf_type=H5I_object_verify(buf_type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a datatype") /* Fill the selection in the memory buffer */ if(H5D_fill(fill,fill_type,buf,buf_type,space, H5AC_dxpl_id)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTENCODE, FAIL, "filling selection failed") done: FUNC_LEAVE_API(ret_value) } /* H5Dfill() */ /*-------------------------------------------------------------------------- NAME H5D_fill PURPOSE Fill a selection in memory with a value (internal version) USAGE herr_t H5D_fill(fill, fill_type, buf, buf_type, space) const void *fill; IN: Pointer to fill value to use H5T_t *fill_type; IN: Datatype of the fill value void *buf; IN/OUT: Memory buffer to fill selection within H5T_t *buf_type; IN: Datatype of the elements in buffer H5S_t *space; IN: Dataspace describing memory buffer & containing selection to use. RETURNS Non-negative on success/Negative on failure. DESCRIPTION Use the selection in the dataspace to fill elements in a memory buffer. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS If "fill" parameter is NULL, use all zeros as fill value. If "fill_type" parameter is NULL, use "buf_type" for the fill value datatype. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5D_fill(const void *fill, const H5T_t *fill_type, void *buf, const H5T_t *buf_type, const H5S_t *space, hid_t dxpl_id) { H5T_path_t *tpath = NULL; /* Conversion information*/ uint8_t *tconv_buf = NULL; /* Data type conv buffer */ uint8_t *bkg_buf = NULL; /* Temp conversion buffer */ hid_t src_id = -1, dst_id = -1; /* Temporary type IDs */ size_t src_type_size; /* Size of source type */ size_t dst_type_size; /* Size of destination type*/ size_t buf_size; /* Desired buffer size */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5D_fill) /* Check args */ assert(fill_type); assert(buf); assert(buf_type); assert(space); /* Make sure the dataspace has an extent set */ if( !(H5S_has_extent(space)) ) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspace extent has not been set") /* Get the memory and file datatype sizes */ src_type_size = H5T_get_size(fill_type); dst_type_size = H5T_get_size(buf_type); /* Get the maximum buffer size needed and allocate it */ buf_size=MAX(src_type_size,dst_type_size); if (NULL==(tconv_buf = H5FL_BLK_MALLOC(type_elem,buf_size)) || NULL==(bkg_buf = H5FL_BLK_CALLOC(type_elem,buf_size))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Check for actual fill value to replicate */ if(fill==NULL) /* If there's no fill value, just use zeros */ HDmemset(tconv_buf,0,dst_type_size); else { /* Copy the user's data into the buffer for conversion */ HDmemcpy(tconv_buf,fill,src_type_size); /* Set up type conversion function */ if (NULL == (tpath = H5T_path_find(fill_type, buf_type, NULL, NULL, dxpl_id))) HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest data types") /* Convert memory buffer into disk buffer */ if (!H5T_path_noop(tpath)) { if ((src_id = H5I_register(H5I_DATATYPE, H5T_copy(fill_type, H5T_COPY_ALL)))<0 || (dst_id = H5I_register(H5I_DATATYPE, H5T_copy(buf_type, H5T_COPY_ALL)))<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register types for conversion") /* Perform data type conversion */ if (H5T_convert(tpath, src_id, dst_id, 1, 0, 0, tconv_buf, bkg_buf, dxpl_id)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "data type conversion failed") } /* end if */ } /* end if */ /* Fill the selection in the memory buffer */ if(H5S_select_fill(tconv_buf, dst_type_size, space, buf)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTENCODE, FAIL, "filling selection failed") done: if (tconv_buf) H5FL_BLK_FREE(type_elem,tconv_buf); if (bkg_buf) H5FL_BLK_FREE(type_elem,bkg_buf); FUNC_LEAVE_NOAPI(ret_value) } /* H5D_fill() */ /*-------------------------------------------------------------------------- NAME H5D_get_dxpl_cache_real PURPOSE Get all the values for the DXPL cache. USAGE herr_t H5D_get_dxpl_cache_real(dxpl_id, cache) hid_t dxpl_id; IN: DXPL to query H5D_dxpl_cache_t *cache;IN/OUT: DXPL cache to fill with values RETURNS Non-negative on success/Negative on failure. DESCRIPTION Query all the values from a DXPL that are needed by internal routines within the library. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5D_get_dxpl_cache_real(hid_t dxpl_id, H5D_dxpl_cache_t *cache) { H5P_genplist_t *dx_plist; /* Data transfer property list */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5D_get_dxpl_cache_real,FAIL) /* Check args */ assert(cache); /* Get the dataset transfer property list */ if (NULL == (dx_plist = H5I_object(dxpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list") /* Get maximum temporary buffer size */ if(H5P_get(dx_plist, H5D_XFER_MAX_TEMP_BUF_NAME, &cache->max_temp_buf)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTGET, FAIL, "Can't retrieve maximum temporary buffer size") /* Get temporary buffer pointer */ if(H5P_get(dx_plist, H5D_XFER_TCONV_BUF_NAME, &cache->tconv_buf)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTGET, FAIL, "Can't retrieve temporary buffer pointer") /* Get background buffer pointer */ if(H5P_get(dx_plist, H5D_XFER_BKGR_BUF_NAME, &cache->bkgr_buf)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTGET, FAIL, "Can't retrieve background buffer pointer") /* Get background buffer type */ if(H5P_get(dx_plist, H5D_XFER_BKGR_BUF_TYPE_NAME, &cache->bkgr_buf_type)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTGET, FAIL, "Can't retrieve background buffer type") /* Get B-tree split ratios */ if(H5P_get(dx_plist, H5D_XFER_BTREE_SPLIT_RATIO_NAME, &cache->btree_split_ratio)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTGET, FAIL, "Can't retrieve B-tree split ratios") /* Get I/O vector size */ if(H5P_get(dx_plist, H5D_XFER_HYPER_VECTOR_SIZE_NAME, &cache->vec_size)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTGET, FAIL, "Can't retrieve I/O vector size") #ifdef H5_HAVE_PARALLEL /* Collect Parallel I/O information for possible later use */ if(H5P_get(dx_plist, H5D_XFER_IO_XFER_MODE_NAME, &cache->xfer_mode)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTGET, FAIL, "Can't retrieve parallel transfer method") #endif /*H5_HAVE_PARALLEL*/ /* Get error detection properties */ if(H5P_get(dx_plist, H5D_XFER_EDC_NAME, &cache->err_detect)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTGET, FAIL, "Can't retrieve error detection info") /* Get filter callback function */ if(H5P_get(dx_plist, H5D_XFER_FILTER_CB_NAME, &cache->filter_cb)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTGET, FAIL, "Can't retrieve filter callback function") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D_get_dxpl_cache_real() */ /*-------------------------------------------------------------------------- NAME H5D_get_dxpl_cache PURPOSE Get all the values for the DXPL cache. USAGE herr_t H5D_get_dxpl_cache(dxpl_id, cache) hid_t dxpl_id; IN: DXPL to query H5D_dxpl_cache_t *cache;IN/OUT: DXPL cache to fill with values RETURNS Non-negative on success/Negative on failure. DESCRIPTION Query all the values from a DXPL that are needed by internal routines within the library. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS The CACHE pointer should point at already allocated memory to place non-default property list info. If a default property list is used, the CACHE pointer will be changed to point at the default information. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5D_get_dxpl_cache(hid_t dxpl_id, H5D_dxpl_cache_t **cache) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5D_get_dxpl_cache,FAIL) /* Check args */ assert(cache); /* Check for the default DXPL */ if(dxpl_id==H5P_DATASET_XFER_DEFAULT) *cache=&H5D_def_dxpl_cache; else if(H5D_get_dxpl_cache_real(dxpl_id,*cache)<0) HGOTO_ERROR (H5E_DATASET, H5E_CANTGET, FAIL, "Can't retrieve DXPL values") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D_get_dxpl_cache() */ /*------------------------------------------------------------------------- * Function: H5Dread * * Purpose: Reads (part of) a DSET from the file into application * memory BUF. The part of the dataset to read is defined with * MEM_SPACE_ID and FILE_SPACE_ID. The data points are * converted from their file type to the MEM_TYPE_ID specified. * Additional miscellaneous data transfer properties can be * passed to this function with the PLIST_ID argument. * * The FILE_SPACE_ID can be the constant H5S_ALL which indicates * that the entire file data space is to be referenced. * * The MEM_SPACE_ID can be the constant H5S_ALL in which case * the memory data space is the same as the file data space * defined when the dataset was created. * * The number of elements in the memory data space must match * the number of elements in the file data space. * * The PLIST_ID can be the constant H5P_DEFAULT in which * case the default data transfer properties are used. * * Return: Non-negative on success/Negative on failure * * Errors: * ARGS BADTYPE Not a data space. * ARGS BADTYPE Not a data type. * ARGS BADTYPE Not a dataset. * ARGS BADTYPE Not xfer parms. * ARGS BADVALUE No output buffer. * DATASET READERROR Can't read data. * * Programmer: Robb Matzke * Thursday, December 4, 1997 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, void *buf/*out*/) { H5D_t *dset = NULL; const H5S_t *mem_space = NULL; const H5S_t *file_space = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Dread, FAIL) H5TRACE6("e","iiiiix",dset_id,mem_type_id,mem_space_id,file_space_id, plist_id,buf); /* check arguments */ if (NULL == (dset = H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") if (NULL == dset->ent.file) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") if (H5S_ALL != mem_space_id) { if (NULL == (mem_space = H5I_object_verify(mem_space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") /* Check for valid selection */ if(H5S_SELECT_VALID(mem_space)!=TRUE) HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "selection+offset not within extent") } if (H5S_ALL != file_space_id) { if (NULL == (file_space = H5I_object_verify(file_space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") /* Check for valid selection */ if(H5S_SELECT_VALID(file_space)!=TRUE) HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "selection+offset not within extent") } /* Get the default dataset transfer property list if the user didn't provide one */ if (H5P_DEFAULT == plist_id) plist_id= H5P_DATASET_XFER_DEFAULT; else if (TRUE!=H5P_isa_class(plist_id,H5P_DATASET_XFER)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") if (!buf && H5S_GET_SELECT_NPOINTS(file_space)!=0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer") /* read raw data */ if (H5D_read(dset, mem_type_id, mem_space, file_space, plist_id, buf/*out*/) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data") done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5Dwrite * * Purpose: Writes (part of) a DSET from application memory BUF to the * file. The part of the dataset to write is defined with the * MEM_SPACE_ID and FILE_SPACE_ID arguments. The data points * are converted from their current type (MEM_TYPE_ID) to their * file data type. Additional miscellaneous data transfer * properties can be passed to this function with the * PLIST_ID argument. * * The FILE_SPACE_ID can be the constant H5S_ALL which indicates * that the entire file data space is to be referenced. * * The MEM_SPACE_ID can be the constant H5S_ALL in which case * the memory data space is the same as the file data space * defined when the dataset was created. * * The number of elements in the memory data space must match * the number of elements in the file data space. * * The PLIST_ID can be the constant H5P_DEFAULT in which * case the default data transfer properties are used. * * Return: Non-negative on success/Negative on failure * * Errors: * * Programmer: Robb Matzke * Thursday, December 4, 1997 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, const void *buf) { H5D_t *dset = NULL; const H5S_t *mem_space = NULL; const H5S_t *file_space = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Dwrite, FAIL) H5TRACE6("e","iiiiix",dset_id,mem_type_id,mem_space_id,file_space_id, plist_id,buf); /* check arguments */ if (NULL == (dset = H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") if (NULL == dset->ent.file) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") if (H5S_ALL != mem_space_id) { if (NULL == (mem_space = H5I_object_verify(mem_space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") /* Check for valid selection */ if (H5S_SELECT_VALID(mem_space)!=TRUE) HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "memory selection+offset not within extent") } if (H5S_ALL != file_space_id) { if (NULL == (file_space = H5I_object_verify(file_space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") /* Check for valid selection */ if (H5S_SELECT_VALID(file_space)!=TRUE) HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "file selection+offset not within extent") } /* Get the default dataset transfer property list if the user didn't provide one */ if (H5P_DEFAULT == plist_id) plist_id= H5P_DATASET_XFER_DEFAULT; else if (TRUE!=H5P_isa_class(plist_id,H5P_DATASET_XFER)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") if (!buf && H5S_GET_SELECT_NPOINTS(file_space)!=0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer") /* write raw data */ if (H5D_write(dset, mem_type_id, mem_space, file_space, plist_id, buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data") done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5D_read * * Purpose: Reads (part of) a DATASET into application memory BUF. See * H5Dread() for complete details. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Thursday, December 4, 1997 * * Modifications: * Robb Matzke, 1998-06-09 * The data space is no longer cached in the dataset struct. * * Robb Matzke, 1998-08-11 * Added timing calls around all the data space I/O functions. * * rky, 1998-09-18 * Added must_convert to do non-optimized read when necessary. * * Quincey Koziol, 1999-07-02 * Changed xfer_parms parameter to xfer plist parameter, so it * could be passed to H5T_convert. * * Albert Cheng, 2000-11-21 * Added the code that when it detects it is not safe to process a * COLLECTIVE read request without hanging, it changes it to * INDEPENDENT calls. * * Albert Cheng, 2000-11-27 * Changed to use the optimized MPIO transfer for Collective calls only. * * Raymond Lu, 2001-10-2 * Changed the way to retrieve property for generic property list. * * Raymond Lu, 2002-2-26 * For the new fill value design, data space can either be allocated * or not allocated at this stage. Fill value or data from space is * returned to outgoing buffer. * * QAK - 2002/04/02 * Removed the must_convert parameter and move preconditions to * H5S__opt_possible() routine * *------------------------------------------------------------------------- */ static herr_t H5D_read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, const H5S_t *file_space, hid_t dxpl_id, void *buf/*out*/) { hssize_t snelmts; /*total number of elmts (signed) */ hsize_t nelmts; /*total number of elmts */ H5T_path_t *tpath = NULL; /*type conversion info */ const H5T_t *mem_type = NULL; /* Memory datatype */ H5D_io_info_t io_info; /* Dataset I/O info */ hbool_t io_info_init = FALSE; /* Whether the I/O info has been initialized */ H5D_dxpl_cache_t _dxpl_cache; /* Data transfer property cache buffer */ H5D_dxpl_cache_t *dxpl_cache=&_dxpl_cache; /* Data transfer property cache */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5D_read) /* check args */ assert(dataset && dataset->ent.file); /* Get memory datatype */ if (NULL == (mem_type = H5I_object_verify(mem_type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") if (!file_space) file_space = dataset->shared->space; if (!mem_space) mem_space = file_space; if((snelmts = H5S_GET_SELECT_NPOINTS(mem_space))<0) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "src dataspace has invalid selection") H5_ASSIGN_OVERFLOW(nelmts,snelmts,hssize_t,hsize_t); /* Fill the DXPL cache values for later use */ if (H5D_get_dxpl_cache(dxpl_id,&dxpl_cache)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't fill dxpl cache") #ifdef H5_HAVE_PARALLEL /* Collective access is not permissible without a MPI based VFD */ if (dxpl_cache->xfer_mode==H5FD_MPIO_COLLECTIVE && !IS_H5FD_MPI(dataset->ent.file)) HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL, "collective access for MPI-based drivers only") #endif /*H5_HAVE_PARALLEL*/ /* Make certain that the number of elements in each selection is the same */ if (nelmts!=(hsize_t)H5S_GET_SELECT_NPOINTS(file_space)) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "src and dest data spaces have different sizes") /* Make sure that both selections have their extents set */ if( !(H5S_has_extent(file_space)) ) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file dataspace does not have extent set") if( !(H5S_has_extent(mem_space)) ) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "memory dataspace does not have extent set") /* Retrieve dataset properties */ /* */ /* If space hasn't been allocated and not using external storage, * return fill value to buffer if fill time is upon allocation, or * do nothing if fill time is never. If the dataset is compact and * fill time is NEVER, there is no way to tell whether part of data * has been overwritten. So just proceed in reading. */ if(nelmts > 0 && dataset->shared->efl.nused==0 && ((dataset->shared->layout.type==H5D_CONTIGUOUS && !H5F_addr_defined(dataset->shared->layout.u.contig.addr)) || (dataset->shared->layout.type==H5D_CHUNKED && !H5F_addr_defined(dataset->shared->layout.u.chunk.addr)))) { H5D_fill_value_t fill_status; /* Whether/How the fill value is defined */ /* Retrieve dataset's fill-value properties */ if(H5P_is_fill_value_defined(&dataset->shared->dcpl_cache.fill, &fill_status)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't tell if fill value defined") /* Should be impossible, but check anyway... */ if(fill_status == H5D_FILL_VALUE_UNDEFINED && (dataset->shared->dcpl_cache.fill_time == H5D_FILL_TIME_ALLOC || dataset->shared->dcpl_cache.fill_time == H5D_FILL_TIME_IFSET)) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "read failed: dataset doesn't exist, no data can be read") /* If we're never going to fill this dataset, just leave the junk in the user's buffer */ if(dataset->shared->dcpl_cache.fill_time == H5D_FILL_TIME_NEVER) HGOTO_DONE(SUCCEED) /* Go fill the user's selection with the dataset's fill value */ if(H5D_fill(dataset->shared->dcpl_cache.fill.buf,dataset->shared->type,buf,mem_type,mem_space,dxpl_id)<0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "filling buf failed") else HGOTO_DONE(SUCCEED) } /* end if */ /* * Locate the type conversion function and data space conversion * functions, and set up the element numbering information. If a data * type conversion is necessary then register data type atoms. Data type * conversion is necessary if the user has set the `need_bkg' to a high * enough value in xfer_parms since turning off data type conversion also * turns off background preservation. */ if (NULL==(tpath=H5T_path_find(dataset->shared->type, mem_type, NULL, NULL, dxpl_id))) HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest data types") /* Set up I/O operation */ if(H5D_ioinfo_init(dataset,dxpl_cache,dxpl_id,mem_space,file_space,tpath,&io_info)<0) HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to set up I/O operation") io_info_init = TRUE; /* Determine correct I/O routine to invoke */ if(dataset->shared->layout.type!=H5D_CHUNKED) { if(H5D_contig_read(&io_info, nelmts, mem_type, mem_space, file_space, tpath, dataset->shared->type_id, mem_type_id, buf)<0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data") } /* end if */ else { if(H5D_chunk_read(&io_info, nelmts, mem_type, mem_space, file_space, tpath, dataset->shared->type_id, mem_type_id, buf)<0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data") } /* end else */ done: #ifdef H5_HAVE_PARALLEL /* Shut down io_info struct */ if (io_info_init) if(H5D_ioinfo_term(&io_info) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "can't shut down io_info") #endif /*H5_HAVE_PARALLEL*/ FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_read() */ /*------------------------------------------------------------------------- * Function: H5D_write * * Purpose: Writes (part of) a DATASET to a file from application memory * BUF. See H5Dwrite() for complete details. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Thursday, December 4, 1997 * * Modifications: * Robb Matzke, 9 Jun 1998 * The data space is no longer cached in the dataset struct. * * rky 980918 * Added must_convert to do non-optimized read when necessary. * * Quincey Koziol, 2 July 1999 * Changed xfer_parms parameter to xfer plist parameter, so it could * be passed to H5T_convert * * Albert Cheng, 2000-11-21 * Added the code that when it detects it is not safe to process a * COLLECTIVE write request without hanging, it changes it to * INDEPENDENT calls. * * Albert Cheng, 2000-11-27 * Changed to use the optimized MPIO transfer for Collective calls only. * * Raymond Lu, 2001-10-2 * Changed the way to retrieve property for generic property list. * * Raymond Lu, 2002-2-26 * For the new fill value design, space may not be allocated until * this function is called. Allocate and initialize space if it * hasn't been. * * QAK - 2002/04/02 * Removed the must_convert parameter and move preconditions to * H5S__opt_possible() routine * * Nat Furrer and James Laird, 2004/6/7 * Added check for filter encode capability *------------------------------------------------------------------------- */ static herr_t H5D_write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, const H5S_t *file_space, hid_t dxpl_id, const void *buf) { hssize_t snelmts; /*total number of elmts (signed) */ hsize_t nelmts; /*total number of elmts */ H5T_path_t *tpath = NULL; /*type conversion info */ const H5T_t *mem_type = NULL; /* Memory datatype */ H5D_io_info_t io_info; /* Dataset I/O info */ hbool_t io_info_init = FALSE; /* Whether the I/O info has been initialized */ H5D_dxpl_cache_t _dxpl_cache; /* Data transfer property cache buffer */ H5D_dxpl_cache_t *dxpl_cache=&_dxpl_cache; /* Data transfer property cache */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5D_write) /* check args */ assert(dataset && dataset->ent.file); /* Get the memory datatype */ if (NULL == (mem_type = H5I_object_verify(mem_type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") /* All filters in the DCPL must have encoding enabled. */ if(! dataset->shared->checked_filters) { if(H5Z_can_apply(dataset->shared->dcpl_id, dataset->shared->type_id) <0) HGOTO_ERROR(H5E_PLINE, H5E_CANAPPLY, FAIL, "can't apply filters") dataset->shared->checked_filters = TRUE; } /* Check if we are allowed to write to this file */ if (0==(H5F_get_intent(dataset->ent.file) & H5F_ACC_RDWR)) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "no write intent on file") /* Fill the DXPL cache values for later use */ if (H5D_get_dxpl_cache(dxpl_id,&dxpl_cache)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't fill dxpl cache") /* Various MPI based checks */ if (IS_H5FD_MPI(dataset->ent.file)) { /* If MPI based VFD is used, no VL datatype support yet. */ /* This is because they use the global heap in the file and we don't */ /* support parallel access of that yet */ if(H5T_detect_class(mem_type, H5T_VLEN)>0) HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL, "Parallel IO does not support writing VL datatypes yet") /* If MPI based VFD is used, no VL datatype support yet. */ /* This is because they use the global heap in the file and we don't */ /* support parallel access of that yet */ /* We should really use H5T_detect_class() here, but it will be difficult * to detect the type of the reference if it is nested... -QAK */ if (H5T_get_class(mem_type, TRUE)==H5T_REFERENCE && H5T_get_ref_type(mem_type)==H5R_DATASET_REGION) HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL, "Parallel IO does not support writing region reference datatypes yet") } /* end if */ #ifdef H5_HAVE_PARALLEL else { /* Collective access is not permissible without a MPI based VFD */ if (dxpl_cache->xfer_mode==H5FD_MPIO_COLLECTIVE) HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL, "collective access for MPI-based driver only") } /* end else */ #endif /*H5_HAVE_PARALLEL*/ if (!file_space) file_space = dataset->shared->space; if (!mem_space) mem_space = file_space; if((snelmts = H5S_GET_SELECT_NPOINTS(mem_space))<0) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "src dataspace has invalid selection") H5_ASSIGN_OVERFLOW(nelmts,snelmts,hssize_t,hsize_t); #ifdef H5_HAVE_PARALLEL /* Collective access is not permissible without a MPI based VFD */ if (dxpl_cache->xfer_mode==H5FD_MPIO_COLLECTIVE && !IS_H5FD_MPI(dataset->ent.file)) HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL, "collective access for MPI-based driver only") #endif /*H5_HAVE_PARALLEL*/ /* Make certain that the number of elements in each selection is the same */ if (nelmts!=(hsize_t)H5S_GET_SELECT_NPOINTS(file_space)) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "src and dest data spaces have different sizes") /* Make sure that both selections have their extents set */ if( !(H5S_has_extent(file_space)) ) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file dataspace does not have extent set") if( !(H5S_has_extent(mem_space)) ) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "memory dataspace does not have extent set") /* Retrieve dataset properties */ /* */ /* Allocate data space and initialize it if it hasn't been. */ if(nelmts > 0 && dataset->shared->efl.nused==0 && ((dataset->shared->layout.type==H5D_CONTIGUOUS && !H5F_addr_defined(dataset->shared->layout.u.contig.addr)) || (dataset->shared->layout.type==H5D_CHUNKED && !H5F_addr_defined(dataset->shared->layout.u.chunk.addr)))) { hssize_t file_nelmts; /* Number of elements in file dataset's dataspace */ hbool_t full_overwrite; /* Whether we are over-writing all the elements */ /* Get the number of elements in file dataset's dataspace */ if((file_nelmts=H5S_GET_EXTENT_NPOINTS(file_space))<0) HGOTO_ERROR (H5E_DATASET, H5E_BADVALUE, FAIL, "can't retrieve number of elements in file dataset") /* Always allow fill values to be written if the dataset has a VL datatype */ if(H5T_detect_class(dataset->shared->type, H5T_VLEN)) full_overwrite=FALSE; else full_overwrite=(hsize_t)file_nelmts==nelmts ? TRUE : FALSE; /* Allocate storage */ if(H5D_alloc_storage(dataset->ent.file,dxpl_id,dataset,H5D_ALLOC_WRITE, TRUE, full_overwrite)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize storage") } /* end if */ /* * Locate the type conversion function and data space conversion * functions, and set up the element numbering information. If a data * type conversion is necessary then register data type atoms. Data type * conversion is necessary if the user has set the `need_bkg' to a high * enough value in xfer_parms since turning off data type conversion also * turns off background preservation. */ if (NULL==(tpath=H5T_path_find(mem_type, dataset->shared->type, NULL, NULL, dxpl_id))) HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest data types") /* Set up I/O operation */ if(H5D_ioinfo_init(dataset,dxpl_cache,dxpl_id,mem_space,file_space,tpath,&io_info)<0) HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to set up I/O operation") io_info_init = TRUE; /* Determine correct I/O routine to invoke */ if(dataset->shared->layout.type!=H5D_CHUNKED) { if(H5D_contig_write(&io_info, nelmts, mem_type, mem_space, file_space, tpath, mem_type_id, dataset->shared->type_id, buf)<0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data") } /* end if */ else { if(H5D_chunk_write(&io_info, nelmts, mem_type, mem_space, file_space, tpath, mem_type_id, dataset->shared->type_id, buf)<0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data") } /* end else */ #ifdef OLD_WAY /* * This was taken out because it can be called in a parallel program with * independent access, causing the metadata cache to get corrupted. Its been * disabled for all types of access (serial as well as parallel) to make the * modification time consistent for all programs. -QAK */ /* * Update modification time. We have to do this explicitly because * writing to a dataset doesn't necessarily change the object header. */ if (H5O_touch(&(dataset->ent), FALSE, dxpl_id)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update modification time") #endif /* OLD_WAY */ done: #ifdef H5_HAVE_PARALLEL /* Shut down io_info struct */ if (io_info_init) if(H5D_ioinfo_term(&io_info) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "can't shut down io_info") #endif /*H5_HAVE_PARALLEL*/ FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_write() */ /*------------------------------------------------------------------------- * Function: H5D_contig_read * * Purpose: Read from a contiguous dataset. * * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu * Thursday, April 10, 2003 * * Modifications: * QAK - 2003/04/17 * Hacked on it a lot. :-) * *------------------------------------------------------------------------- */ static herr_t H5D_contig_read(H5D_io_info_t *io_info, hsize_t nelmts, const H5T_t *mem_type, const H5S_t *mem_space, const H5S_t *file_space, H5T_path_t *tpath, hid_t src_id, hid_t dst_id, void *buf/*out*/) { H5D_t *dataset=io_info->dset; /* Local pointer to dataset info */ const H5D_dxpl_cache_t *dxpl_cache=io_info->dxpl_cache; /* Local pointer to dataset transfer info */ herr_t status; /*function return status*/ #ifdef H5S_DEBUG H5_timer_t timer; #endif size_t src_type_size; /*size of source type */ size_t dst_type_size; /*size of destination type*/ size_t max_type_size; /* Size of largest source/destination type */ size_t target_size; /*desired buffer size */ size_t request_nelmts; /*requested strip mine */ H5S_sel_iter_t mem_iter; /*memory selection iteration info*/ hbool_t mem_iter_init=0; /*memory selection iteration info has been initialized */ H5S_sel_iter_t bkg_iter; /*background iteration info*/ hbool_t bkg_iter_init=0; /*background iteration info has been initialized */ H5S_sel_iter_t file_iter; /*file selection iteration info*/ hbool_t file_iter_init=0; /*file selection iteration info has been initialized */ H5T_bkg_t need_bkg; /*type of background buf*/ uint8_t *tconv_buf = NULL; /*data type conv buffer */ uint8_t *bkg_buf = NULL; /*background buffer */ hsize_t smine_start; /*strip mine start loc */ size_t n, smine_nelmts; /*elements per strip */ H5D_storage_t store; /*union of storage info for dataset */ herr_t ret_value = SUCCEED; /*return value */ FUNC_ENTER_NOAPI_NOINIT(H5D_contig_read) /* Initialize storage info for this dataset */ if (dataset->shared->efl.nused>0) HDmemcpy(&store.efl,&(dataset->shared->efl),sizeof(H5O_efl_t)); else { store.contig.dset_addr=dataset->shared->layout.u.contig.addr; store.contig.dset_size=dataset->shared->layout.u.contig.size; } /* end if */ /* Set dataset storage for I/O info */ io_info->store=&store; /* * If there is no type conversion then read directly into the * application's buffer. This saves at least one mem-to-mem copy. */ if (H5T_path_noop(tpath)) { #ifdef H5S_DEBUG H5_timer_begin(&timer); #endif /* Sanity check dataset, then read it */ assert(((dataset->shared->layout.type==H5D_CONTIGUOUS && H5F_addr_defined(dataset->shared->layout.u.contig.addr)) || (dataset->shared->layout.type==H5D_CHUNKED && H5F_addr_defined(dataset->shared->layout.u.chunk.addr))) || dataset->shared->efl.nused>0 || 0 == nelmts || dataset->shared->layout.type==H5D_COMPACT); H5_CHECK_OVERFLOW(nelmts,hsize_t,size_t); status = (io_info->ops.read)(io_info, (size_t)nelmts, H5T_get_size(dataset->shared->type), file_space, mem_space, buf/*out*/); #ifdef H5S_DEBUG H5_timer_end(&(io_info->stats->stats[1].read_timer), &timer); io_info->stats->stats[1].read_nbytes += nelmts * H5T_get_size(dataset->shared->type); io_info->stats->stats[1].read_ncalls++; #endif /* Check return value from optimized read */ if (status<0) { HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "optimized read failed") } else /* direct xfer accomplished successfully */ HGOTO_DONE(SUCCEED) } /* end if */ /* * This is the general case (type conversion, usually). */ if(nelmts==0) HGOTO_DONE(SUCCEED) /* Compute element sizes and other parameters */ src_type_size = H5T_get_size(dataset->shared->type); dst_type_size = H5T_get_size(mem_type); max_type_size = MAX(src_type_size, dst_type_size); target_size = dxpl_cache->max_temp_buf; /* XXX: This could cause a problem if the user sets their buffer size * to the same size as the default, and then the dataset elements are * too large for the buffer... - QAK */ if(target_size==H5D_XFER_MAX_TEMP_BUF_DEF) { /* If the buffer is too small to hold even one element, make it bigger */ if(target_size(nelmts*max_type_size)) target_size=(size_t)(nelmts*max_type_size); } /* end if */ request_nelmts = target_size / max_type_size; /* Sanity check elements in temporary buffer */ if (request_nelmts==0) HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "temporary buffer max size is too small") /* Figure out the strip mine size. */ if (H5S_select_iter_init(&file_iter, file_space, src_type_size)<0) HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize file selection information") file_iter_init=1; /*file selection iteration info has been initialized */ if (H5S_select_iter_init(&mem_iter, mem_space, dst_type_size)<0) HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information") mem_iter_init=1; /*file selection iteration info has been initialized */ if (H5S_select_iter_init(&bkg_iter, mem_space, dst_type_size)<0) HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize background selection information") bkg_iter_init=1; /*file selection iteration info has been initialized */ /* * Get a temporary buffer for type conversion unless the app has already * supplied one through the xfer properties. Instead of allocating a * buffer which is the exact size, we allocate the target size. The * malloc() is usually less resource-intensive if we allocate/free the * same size over and over. */ if (H5T_path_bkg(tpath)) { H5T_bkg_t path_bkg; /* Type conversion's background info */ /* Retrieve the bkgr buffer property */ need_bkg=dxpl_cache->bkgr_buf_type; path_bkg = H5T_path_bkg(tpath); need_bkg = MAX(path_bkg, need_bkg); } else { need_bkg = H5T_BKG_NO; /*never needed even if app says yes*/ } /* end else */ if (NULL==(tconv_buf=dxpl_cache->tconv_buf)) { /* Allocate temporary buffer */ if((tconv_buf=H5FL_BLK_MALLOC(type_conv,target_size))==NULL) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion") } /* end if */ if (need_bkg && NULL==(bkg_buf=dxpl_cache->bkgr_buf)) { /* Allocate background buffer */ /* (Need calloc()-like call since memory needs to be initialized) */ if((bkg_buf=H5FL_BLK_CALLOC(type_conv,(request_nelmts*dst_type_size)))==NULL) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for background conversion") } /* end if */ /* Start strip mining... */ for (smine_start=0; smine_startshared->layout.type==H5D_CONTIGUOUS && H5F_addr_defined(dataset->shared->layout.u.contig.addr)) || (dataset->shared->layout.type==H5D_CHUNKED && H5F_addr_defined(dataset->shared->layout.u.chunk.addr))) || dataset->shared->efl.nused>0 || dataset->shared->layout.type==H5D_COMPACT); n = H5D_select_fgath(io_info, file_space, &file_iter, smine_nelmts, tconv_buf/*out*/); #ifdef H5S_DEBUG H5_timer_end(&(io_info->stats->stats[1].gath_timer), &timer); io_info->stats->stats[1].gath_nbytes += n * src_type_size; io_info->stats->stats[1].gath_ncalls++; #endif if (n!=smine_nelmts) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file gather failed") if (H5T_BKG_YES==need_bkg) { #ifdef H5S_DEBUG H5_timer_begin(&timer); #endif n = H5D_select_mgath(buf, mem_space, &bkg_iter, smine_nelmts, dxpl_cache, bkg_buf/*out*/); #ifdef H5S_DEBUG H5_timer_end(&(io_info->stats->stats[1].bkg_timer), &timer); io_info->stats->stats[1].bkg_nbytes += n * dst_type_size; io_info->stats->stats[1].bkg_ncalls++; #endif if (n!=smine_nelmts) HGOTO_ERROR (H5E_IO, H5E_READERROR, FAIL, "mem gather failed") } /* end if */ /* * Perform data type conversion. */ if (H5T_convert(tpath, src_id, dst_id, smine_nelmts, 0, 0, tconv_buf, bkg_buf, io_info->dxpl_id)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "data type conversion failed") /* * Scatter the data into memory. */ #ifdef H5S_DEBUG H5_timer_begin(&timer); #endif status = H5D_select_mscat(tconv_buf, mem_space, &mem_iter, smine_nelmts, dxpl_cache, buf/*out*/); #ifdef H5S_DEBUG H5_timer_end(&(io_info->stats->stats[1].scat_timer), &timer); io_info->stats->stats[1].scat_nbytes += smine_nelmts * dst_type_size; io_info->stats->stats[1].scat_ncalls++; #endif if (status<0) HGOTO_ERROR (H5E_DATASET, H5E_READERROR, FAIL, "scatter failed") } /* end for */ done: /* Release selection iterators */ if(file_iter_init) { if(H5S_SELECT_ITER_RELEASE(&file_iter)<0) HDONE_ERROR (H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") } /* end if */ if(mem_iter_init) { if(H5S_SELECT_ITER_RELEASE(&mem_iter)<0) HDONE_ERROR (H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") } /* end if */ if(bkg_iter_init) { if(H5S_SELECT_ITER_RELEASE(&bkg_iter)<0) HDONE_ERROR (H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") } /* end if */ if (tconv_buf && NULL==dxpl_cache->tconv_buf) H5FL_BLK_FREE(type_conv,tconv_buf); if (bkg_buf && NULL==dxpl_cache->bkgr_buf) H5FL_BLK_FREE(type_conv,bkg_buf); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_contig_read() */ /*------------------------------------------------------------------------- * Function: H5D_contig_write * * Purpose: Write to a contiguous dataset. * * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu * Thursday, April 10, 2003 * * Modifications: * QAK - 2003/04/17 * Hacked on it a lot. :-) * *------------------------------------------------------------------------- */ static herr_t H5D_contig_write(H5D_io_info_t *io_info, hsize_t nelmts, const H5T_t *mem_type, const H5S_t *mem_space, const H5S_t *file_space, H5T_path_t *tpath, hid_t src_id, hid_t dst_id, const void *buf) { H5D_t *dataset=io_info->dset; /* Local pointer to dataset info */ const H5D_dxpl_cache_t *dxpl_cache=io_info->dxpl_cache; /* Local pointer to dataset transfer info */ herr_t status; /*function return status*/ #ifdef H5S_DEBUG H5_timer_t timer; #endif size_t src_type_size; /*size of source type */ size_t dst_type_size; /*size of destination type*/ size_t max_type_size; /* Size of largest source/destination type */ size_t target_size; /*desired buffer size */ size_t request_nelmts; /*requested strip mine */ H5S_sel_iter_t mem_iter; /*memory selection iteration info*/ hbool_t mem_iter_init=0; /*memory selection iteration info has been initialized */ H5S_sel_iter_t bkg_iter; /*background iteration info*/ hbool_t bkg_iter_init=0; /*background iteration info has been initialized */ H5S_sel_iter_t file_iter; /*file selection iteration info*/ hbool_t file_iter_init=0; /*file selection iteration info has been initialized */ H5T_bkg_t need_bkg; /*type of background buf*/ uint8_t *tconv_buf = NULL; /*data type conv buffer */ uint8_t *bkg_buf = NULL; /*background buffer */ hsize_t smine_start; /*strip mine start loc */ size_t n, smine_nelmts; /*elements per strip */ H5D_storage_t store; /*union of storage info for dataset */ herr_t ret_value = SUCCEED; /*return value */ FUNC_ENTER_NOAPI_NOINIT(H5D_contig_write) /* Initialize storage info for this dataset */ if (dataset->shared->efl.nused>0) HDmemcpy(&store.efl,&(dataset->shared->efl),sizeof(H5O_efl_t)); else { store.contig.dset_addr=dataset->shared->layout.u.contig.addr; store.contig.dset_size=dataset->shared->layout.u.contig.size; } /* end if */ /* Set dataset storage for I/O info */ io_info->store=&store; /* * If there is no type conversion then write directly from the * application's buffer. This saves at least one mem-to-mem copy. */ if (H5T_path_noop(tpath)) { #ifdef H5S_DEBUG H5_timer_begin(&timer); #endif H5_CHECK_OVERFLOW(nelmts,hsize_t,size_t); status = (io_info->ops.write)(io_info, (size_t)nelmts, H5T_get_size(dataset->shared->type), file_space, mem_space, buf); #ifdef H5S_DEBUG H5_timer_end(&(io_info->stats->stats[0].write_timer), &timer); io_info->stats->stats[0].write_nbytes += nelmts * H5T_get_size(mem_type); io_info->stats->stats[0].write_ncalls++; #endif /* Check return value from optimized write */ if (status<0) { HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "optimized write failed") } else /* direct xfer accomplished successfully */ HGOTO_DONE(SUCCEED) } /* end if */ /* * This is the general case. */ if(nelmts==0) HGOTO_DONE(SUCCEED) /* Compute element sizes and other parameters */ src_type_size = H5T_get_size(mem_type); dst_type_size = H5T_get_size(dataset->shared->type); max_type_size = MAX(src_type_size, dst_type_size); target_size = dxpl_cache->max_temp_buf; /* XXX: This could cause a problem if the user sets their buffer size * to the same size as the default, and then the dataset elements are * too large for the buffer... - QAK */ if(target_size==H5D_XFER_MAX_TEMP_BUF_DEF) { /* If the buffer is too small to hold even one element, make it bigger */ if(target_size(nelmts*max_type_size)) target_size=(size_t)(nelmts*max_type_size); } /* end if */ request_nelmts = target_size / max_type_size; /* Sanity check elements in temporary buffer */ if (request_nelmts==0) HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "temporary buffer max size is too small") /* Figure out the strip mine size. */ if (H5S_select_iter_init(&file_iter, file_space, dst_type_size)<0) HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize file selection information") file_iter_init=1; /*file selection iteration info has been initialized */ if (H5S_select_iter_init(&mem_iter, mem_space, src_type_size)<0) HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information") mem_iter_init=1; /*file selection iteration info has been initialized */ if (H5S_select_iter_init(&bkg_iter, file_space, dst_type_size)<0) HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize background selection information") bkg_iter_init=1; /*file selection iteration info has been initialized */ /* * Get a temporary buffer for type conversion unless the app has already * supplied one through the xfer properties. Instead of allocating a * buffer which is the exact size, we allocate the target size. The * malloc() is usually less resource-intensive if we allocate/free the * same size over and over. */ if(H5T_detect_class(dataset->shared->type, H5T_VLEN)) { /* Old data is retrieved into background buffer for VL datatype. The * data is used later for freeing heap objects. */ need_bkg = H5T_BKG_YES; } else if (H5T_path_bkg(tpath)) { H5T_bkg_t path_bkg; /* Type conversion's background info */ /* Retrieve the bkgr buffer property */ need_bkg=dxpl_cache->bkgr_buf_type; path_bkg = H5T_path_bkg(tpath); need_bkg = MAX (path_bkg, need_bkg); } else { need_bkg = H5T_BKG_NO; /*never needed even if app says yes*/ } /* end else */ if (NULL==(tconv_buf=dxpl_cache->tconv_buf)) { /* Allocate temporary buffer */ if((tconv_buf=H5FL_BLK_MALLOC(type_conv,target_size))==NULL) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion") } /* end if */ if (need_bkg && NULL==(bkg_buf=dxpl_cache->bkgr_buf)) { /* Allocate background buffer */ /* (Don't need calloc()-like call since file data is already initialized) */ if((bkg_buf=H5FL_BLK_MALLOC(type_conv,(request_nelmts*dst_type_size)))==NULL) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for background conversion") } /* end if */ /* Start strip mining... */ for (smine_start=0; smine_startstats->stats[0].gath_timer), &timer); io_info->stats->stats[0].gath_nbytes += n * src_type_size; io_info->stats->stats[0].gath_ncalls++; #endif if (n!=smine_nelmts) HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "mem gather failed") if (H5T_BKG_YES==need_bkg) { #ifdef H5S_DEBUG H5_timer_begin(&timer); #endif n = H5D_select_fgath(io_info, file_space, &bkg_iter, smine_nelmts, bkg_buf/*out*/); #ifdef H5S_DEBUG H5_timer_end(&(io_info->stats->stats[0].bkg_timer), &timer); io_info->stats->stats[0].bkg_nbytes += n * dst_type_size; io_info->stats->stats[0].bkg_ncalls++; #endif if (n!=smine_nelmts) HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "file gather failed") } /* end if */ /* * Perform data type conversion. */ if (H5T_convert(tpath, src_id, dst_id, smine_nelmts, 0, 0, tconv_buf, bkg_buf, io_info->dxpl_id)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "data type conversion failed") /* * Scatter the data out to the file. */ #ifdef H5S_DEBUG H5_timer_begin(&timer); #endif status = H5D_select_fscat(io_info, file_space, &file_iter, smine_nelmts, tconv_buf); #ifdef H5S_DEBUG H5_timer_end(&(io_info->stats->stats[0].scat_timer), &timer); io_info->stats->stats[0].scat_nbytes += smine_nelmts * dst_type_size; io_info->stats->stats[0].scat_ncalls++; #endif if (status<0) HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "scatter failed") } /* end for */ done: /* Release selection iterators */ if(file_iter_init) { if(H5S_SELECT_ITER_RELEASE(&file_iter)<0) HDONE_ERROR (H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") } /* end if */ if(mem_iter_init) { if(H5S_SELECT_ITER_RELEASE(&mem_iter)<0) HDONE_ERROR (H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") } /* end if */ if(bkg_iter_init) { if(H5S_SELECT_ITER_RELEASE(&bkg_iter)<0) HDONE_ERROR (H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") } /* end if */ if (tconv_buf && NULL==dxpl_cache->tconv_buf) H5FL_BLK_FREE(type_conv,tconv_buf); if (bkg_buf && NULL==dxpl_cache->bkgr_buf) H5FL_BLK_FREE(type_conv,bkg_buf); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_contig_write() */ /*------------------------------------------------------------------------- * Function: H5D_chunk_read * * Purpose: Read from a chunked dataset. * * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu * Thursday, April 10, 2003 * * Modifications: * QAK - 2003/04/17 * Hacked on it a lot. :-) * *------------------------------------------------------------------------- */ static herr_t H5D_chunk_read(H5D_io_info_t *io_info, hsize_t nelmts, const H5T_t *mem_type, const H5S_t *mem_space, const H5S_t *file_space, H5T_path_t *tpath, hid_t src_id, hid_t dst_id, void *buf/*out*/) { H5D_t *dataset=io_info->dset; /* Local pointer to dataset info */ const H5D_dxpl_cache_t *dxpl_cache=io_info->dxpl_cache; /* Local pointer to dataset transfer info */ fm_map fm; /* File<->memory mapping */ H5SL_node_t *chunk_node; /* Current node in chunk skip list */ herr_t status; /*function return status*/ #ifdef H5S_DEBUG H5_timer_t timer; #endif size_t src_type_size; /*size of source type */ size_t dst_type_size; /*size of destination type*/ size_t max_type_size; /* Size of largest source/destination type */ size_t target_size; /*desired buffer size */ size_t request_nelmts; /*requested strip mine */ hsize_t smine_start; /*strip mine start loc */ size_t n, smine_nelmts; /*elements per strip */ H5S_sel_iter_t mem_iter; /*memory selection iteration info*/ hbool_t mem_iter_init=0; /*memory selection iteration info has been initialized */ H5S_sel_iter_t bkg_iter; /*background iteration info*/ hbool_t bkg_iter_init=0; /*background iteration info has been initialized */ H5S_sel_iter_t file_iter; /*file selection iteration info*/ hbool_t file_iter_init=0; /*file selection iteration info has been initialized */ H5T_bkg_t need_bkg; /*type of background buf*/ uint8_t *tconv_buf = NULL; /*data type conv buffer */ uint8_t *bkg_buf = NULL; /*background buffer */ H5D_storage_t store; /*union of EFL and chunk pointer in file space */ #ifdef H5_HAVE_PARALLEL int count_chunk; /* Number of chunks accessed */ int min_num_chunk; /* Number of chunks to access collectively */ #endif herr_t ret_value = SUCCEED; /*return value */ FUNC_ENTER_NOAPI_NOINIT(H5D_chunk_read) /* Map elements between file and memory for each chunk*/ if(H5D_create_chunk_map(dataset, mem_type, file_space, mem_space, &fm)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't build chunk mapping") /* Set dataset storage for I/O info */ io_info->store=&store; /* * If there is no type conversion then read directly into the * application's buffer. This saves at least one mem-to-mem copy. */ if (H5T_path_noop(tpath)) { #ifdef H5S_DEBUG H5_timer_begin(&timer); #endif /* Sanity check dataset, then read it */ assert(((dataset->shared->layout.type==H5D_CONTIGUOUS && H5F_addr_defined(dataset->shared->layout.u.contig.addr)) || (dataset->shared->layout.type==H5D_CHUNKED && H5F_addr_defined(dataset->shared->layout.u.chunk.addr))) || dataset->shared->efl.nused>0 || 0 == nelmts || dataset->shared->layout.type==H5D_COMPACT); /* Get first node in chunk skip list */ chunk_node=H5SL_first(fm.fsel); #ifdef H5_HAVE_PARALLEL if(io_info->dxpl_cache->xfer_mode == H5FD_MPIO_COLLECTIVE) { if(H5D_mpio_get_min_chunk(io_info, &fm, &min_num_chunk)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get minimum number of chunk") } count_chunk = 0; #endif /* H5_HAVE_PARALLEL */ /* Iterate through chunks to be operated on */ while(chunk_node) { H5D_chunk_info_t *chunk_info; /* chunk information */ #ifdef H5_HAVE_PARALLEL hbool_t make_ind, make_coll; /* Flags to indicate that the MPI mode should change */ #endif /* H5_HAVE_PARALLEL */ /* Get the actual chunk information from the skip list node */ chunk_info=H5SL_item(chunk_node); /* Pass in chunk's coordinates in a union. */ store.chunk.offset = chunk_info->coords; store.chunk.index = chunk_info->index; #ifdef H5_HAVE_PARALLEL /* Reset flags for changing parallel I/O mode */ make_ind = make_coll = FALSE; if(io_info->dxpl_cache->xfer_mode == H5FD_MPIO_COLLECTIVE) { /* Increment chunk we are operating on */ count_chunk++; /* If the number of chunk is greater than minimum number of chunk, Do independent read */ if(count_chunk > min_num_chunk) { /* Switch to independent I/O (permanently) */ make_ind = TRUE; } #ifndef H5_MPI_COMPLEX_DERIVED_DATATYPE_WORKS else { /* Switch to independent I/O (temporarily) */ make_ind = TRUE; make_coll = TRUE; } /* end else */ #endif /* H5_MPI_COMPLEX_DERIVED_DATATYPE_WORKS */ } /* end if */ /* Switch to independent I/O */ if(make_ind) if(H5D_ioinfo_make_ind(io_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't switch to independent I/O") #endif /* H5_HAVE_PARALLEL */ /* Perform the actual read operation */ status = (io_info->ops.read)(io_info, chunk_info->chunk_points, H5T_get_size(dataset->shared->type), chunk_info->fspace, chunk_info->mspace, buf); #ifdef H5_HAVE_PARALLEL /* Switch back to collective I/O */ if(make_coll) if(H5D_ioinfo_make_coll(io_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't switch to independent I/O") #endif /* H5_HAVE_PARALLEL */ /* Check return value from optimized read */ if (status<0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "optimized read failed") /* Get the next chunk node in the skip list */ chunk_node=H5SL_next(chunk_node); } /* end while */ #ifdef H5S_DEBUG H5_timer_end(&(io_info->stats->stats[1].read_timer), &timer); io_info->stats->stats[1].read_nbytes += nelmts * H5T_get_size(dataset->shared->type); io_info->stats->stats[1].read_ncalls++; #endif /* direct xfer accomplished successfully */ HGOTO_DONE(SUCCEED) } /* end if */ /* * This is the general case (type conversion, usually). */ if(nelmts==0) HGOTO_DONE(SUCCEED) /* Compute element sizes and other parameters */ src_type_size = H5T_get_size(dataset->shared->type); dst_type_size = H5T_get_size(mem_type); max_type_size = MAX(src_type_size, dst_type_size); target_size = dxpl_cache->max_temp_buf; /* XXX: This could cause a problem if the user sets their buffer size * to the same size as the default, and then the dataset elements are * too large for the buffer... - QAK */ if(target_size==H5D_XFER_MAX_TEMP_BUF_DEF) { /* If the buffer is too small to hold even one element, make it bigger */ if(target_size(nelmts*max_type_size)) target_size=(size_t)(nelmts*max_type_size); } /* end if */ request_nelmts = target_size / max_type_size; /* Sanity check elements in temporary buffer */ if (request_nelmts==0) HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "temporary buffer max size is too small") /* * Get a temporary buffer for type conversion unless the app has already * supplied one through the xfer properties. Instead of allocating a * buffer which is the exact size, we allocate the target size. The * malloc() is usually less resource-intensive if we allocate/free the * same size over and over. */ if (H5T_path_bkg(tpath)) { H5T_bkg_t path_bkg; /* Type conversion's background info */ /* Retrieve the bkgr buffer property */ need_bkg=dxpl_cache->bkgr_buf_type; path_bkg = H5T_path_bkg(tpath); need_bkg = MAX(path_bkg, need_bkg); } else { need_bkg = H5T_BKG_NO; /*never needed even if app says yes*/ } /* end else */ if (NULL==(tconv_buf=dxpl_cache->tconv_buf)) { /* Allocate temporary buffer */ if((tconv_buf=H5FL_BLK_MALLOC(type_conv,target_size))==NULL) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion") } /* end if */ if (need_bkg && NULL==(bkg_buf=dxpl_cache->bkgr_buf)) { /* Allocate background buffer */ /* (Need calloc()-like call since memory needs to be initialized) */ if((bkg_buf=H5FL_BLK_CALLOC(type_conv,(request_nelmts*dst_type_size)))==NULL) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for background conversion") } /* end if */ /* Loop over all the chunks, performing I/O on each */ /* Get first node in chunk skip list */ chunk_node=H5SL_first(fm.fsel); /* Iterate through chunks to be operated on */ while(chunk_node) { H5D_chunk_info_t *chunk_info; /* chunk information */ /* Get the actual chunk information from the skip list nodes */ chunk_info=H5SL_item(chunk_node); /* initialize selection iterator */ if (H5S_select_iter_init(&file_iter, chunk_info->fspace, src_type_size)<0) HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize file selection information") file_iter_init=1; /*file selection iteration info has been initialized */ if (H5S_select_iter_init(&mem_iter, chunk_info->mspace, dst_type_size)<0) HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information") mem_iter_init=1; /*file selection iteration info has been initialized */ if (H5S_select_iter_init(&bkg_iter, chunk_info->mspace, dst_type_size)<0) HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize background selection information") bkg_iter_init=1; /*file selection iteration info has been initialized */ /* Pass in chunk's coordinates in a union*/ store.chunk.offset = chunk_info->coords; store.chunk.index = chunk_info->index; for (smine_start=0; smine_startchunk_points; smine_start+=smine_nelmts) { /* Go figure out how many elements to read from the file */ assert(H5S_SELECT_ITER_NELMTS(&file_iter)==(chunk_info->chunk_points-smine_start)); smine_nelmts = (size_t)MIN(request_nelmts, (chunk_info->chunk_points-smine_start)); /* * Gather the data from disk into the data type conversion * buffer. Also gather data from application to background buffer * if necessary. */ #ifdef H5S_DEBUG H5_timer_begin(&timer); #endif /* Sanity check that space is allocated, then read data from it */ assert(((dataset->shared->layout.type==H5D_CONTIGUOUS && H5F_addr_defined(dataset->shared->layout.u.contig.addr)) || (dataset->shared->layout.type==H5D_CHUNKED && H5F_addr_defined(dataset->shared->layout.u.chunk.addr))) || dataset->shared->efl.nused>0 || dataset->shared->layout.type==H5D_COMPACT); n = H5D_select_fgath(io_info, chunk_info->fspace, &file_iter, smine_nelmts, tconv_buf/*out*/); #ifdef H5S_DEBUG H5_timer_end(&(io_info->stats->stats[1].gath_timer), &timer); io_info->stats->stats[1].gath_nbytes += n * src_type_size; io_info->stats->stats[1].gath_ncalls++; #endif if (n!=smine_nelmts) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file gather failed") if (H5T_BKG_YES==need_bkg) { #ifdef H5S_DEBUG H5_timer_begin(&timer); #endif n = H5D_select_mgath(buf, chunk_info->mspace, &bkg_iter, smine_nelmts, dxpl_cache, bkg_buf/*out*/); #ifdef H5S_DEBUG H5_timer_end(&(io_info->stats->stats[1].bkg_timer), &timer); io_info->stats->stats[1].bkg_nbytes += n * dst_type_size; io_info->stats->stats[1].bkg_ncalls++; #endif if (n!=smine_nelmts) HGOTO_ERROR (H5E_IO, H5E_READERROR, FAIL, "mem gather failed") } /* end if */ /* * Perform data type conversion. */ if (H5T_convert(tpath, src_id, dst_id, smine_nelmts, 0, 0, tconv_buf, bkg_buf, io_info->dxpl_id)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "data type conversion failed") /* * Scatter the data into memory. */ #ifdef H5S_DEBUG H5_timer_begin(&timer); #endif status = H5D_select_mscat(tconv_buf, chunk_info->mspace, &mem_iter, smine_nelmts, dxpl_cache, buf/*out*/); #ifdef H5S_DEBUG H5_timer_end(&(io_info->stats->stats[1].scat_timer), &timer); io_info->stats->stats[1].scat_nbytes += smine_nelmts * dst_type_size; io_info->stats->stats[1].scat_ncalls++; #endif if (status<0) HGOTO_ERROR (H5E_DATASET, H5E_READERROR, FAIL, "scatter failed") } /* end for */ /* Release selection iterators */ if(file_iter_init) { if(H5S_SELECT_ITER_RELEASE(&file_iter)<0) HGOTO_ERROR (H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") file_iter_init=0; } /* end if */ if(mem_iter_init) { if(H5S_SELECT_ITER_RELEASE(&mem_iter)<0) HGOTO_ERROR (H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") mem_iter_init=0; } /* end if */ if(bkg_iter_init) { if(H5S_SELECT_ITER_RELEASE(&bkg_iter)<0) HGOTO_ERROR (H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") bkg_iter_init=0; } /* end if */ /* Get the next chunk node in the skip list */ chunk_node=H5SL_next(chunk_node); } /* end while */ done: /* Release selection iterators, if necessary */ if(file_iter_init) { if(H5S_SELECT_ITER_RELEASE(&file_iter)<0) HDONE_ERROR (H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") } /* end if */ if(mem_iter_init) { if(H5S_SELECT_ITER_RELEASE(&mem_iter)<0) HDONE_ERROR (H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") } /* end if */ if(bkg_iter_init) { if(H5S_SELECT_ITER_RELEASE(&bkg_iter)<0) HDONE_ERROR (H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") } /* end if */ if (tconv_buf && NULL==dxpl_cache->tconv_buf) H5FL_BLK_FREE(type_conv,tconv_buf); if (bkg_buf && NULL==dxpl_cache->bkgr_buf) H5FL_BLK_FREE(type_conv,bkg_buf); /* Release chunk mapping information */ if(H5D_destroy_chunk_map(&fm) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't release chunk mapping") FUNC_LEAVE_NOAPI(ret_value) } /* H5D_chunk_read() */ /*------------------------------------------------------------------------- * Function: H5D_chunk_write * * Purpose: Writes to a chunked dataset. * * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu * Thursday, April 10, 2003 * * Modifications: * QAK - 2003/04/17 * Hacked on it a lot. :-) * Kent Yang: 8/10/04 * Added support for collective chunk IO. * *------------------------------------------------------------------------- */ static herr_t H5D_chunk_write(H5D_io_info_t *io_info, hsize_t nelmts, const H5T_t *mem_type, const H5S_t *mem_space, const H5S_t *file_space, H5T_path_t *tpath, hid_t src_id, hid_t dst_id, const void *buf) { H5D_t *dataset=io_info->dset; /* Local pointer to dataset info */ const H5D_dxpl_cache_t *dxpl_cache=io_info->dxpl_cache; /* Local pointer to dataset transfer info */ fm_map fm; /* File<->memory mapping */ H5SL_node_t *chunk_node; /* Current node in chunk skip list */ herr_t status; /*function return status*/ #ifdef H5S_DEBUG H5_timer_t timer; #endif size_t src_type_size; /*size of source type */ size_t dst_type_size; /*size of destination type*/ size_t max_type_size; /* Size of largest source/destination type */ size_t target_size; /*desired buffer size */ size_t request_nelmts; /*requested strip mine */ hsize_t smine_start; /*strip mine start loc */ size_t n, smine_nelmts; /*elements per strip */ H5S_sel_iter_t mem_iter; /*memory selection iteration info*/ hbool_t mem_iter_init=0; /*memory selection iteration info has been initialized */ H5S_sel_iter_t bkg_iter; /*background iteration info*/ hbool_t bkg_iter_init=0; /*background iteration info has been initialized */ H5S_sel_iter_t file_iter; /*file selection iteration info*/ hbool_t file_iter_init=0; /*file selection iteration info has been initialized */ H5T_bkg_t need_bkg; /*type of background buf*/ uint8_t *tconv_buf = NULL; /*data type conv buffer */ uint8_t *bkg_buf = NULL; /*background buffer */ H5D_storage_t store; /*union of EFL and chunk pointer in file space */ #ifdef H5_HAVE_PARALLEL int count_chunk; /* Number of chunks accessed */ int min_num_chunk; /* Number of chunks to access collectively */ #endif herr_t ret_value = SUCCEED; /*return value */ FUNC_ENTER_NOAPI_NOINIT(H5D_chunk_write) /* Map elements between file and memory for each chunk*/ if(H5D_create_chunk_map(dataset, mem_type, file_space, mem_space, &fm)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't build chunk mapping") /* Set dataset storage for I/O info */ io_info->store=&store; /* * If there is no type conversion then write directly from the * application's buffer. This saves at least one mem-to-mem copy. */ if (H5T_path_noop(tpath)) { #ifdef H5S_DEBUG H5_timer_begin(&timer); #endif #ifdef H5_HAVE_PARALLEL if(io_info->dxpl_cache->xfer_mode == H5FD_MPIO_COLLECTIVE) { if(H5D_mpio_get_min_chunk(io_info, &fm, &min_num_chunk)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get minimum number of chunk") } count_chunk = 0; #endif /* H5_HAVE_PARALLEL */ /* Get first node in chunk skip list */ chunk_node=H5SL_first(fm.fsel); /* Iterate through chunks to be operated on */ while(chunk_node) { H5D_chunk_info_t *chunk_info; /* Chunk information */ #ifdef H5_HAVE_PARALLEL hbool_t make_ind, make_coll; /* Flags to indicate that the MPI mode should change */ #endif /* H5_HAVE_PARALLEL */ /* Get the actual chunk information from the skip list node */ chunk_info=H5SL_item(chunk_node); /* Pass in chunk's coordinates in a union. */ store.chunk.offset = chunk_info->coords; store.chunk.index = chunk_info->index; #ifdef H5_HAVE_PARALLEL /* Reset flags for changing parallel I/O mode */ make_ind = make_coll = FALSE; if(io_info->dxpl_cache->xfer_mode == H5FD_MPIO_COLLECTIVE) { /* Increment chunk we are operating on */ count_chunk++; /* If the number of chunk is greater than minimum number of chunk, Do independent write */ if(count_chunk > min_num_chunk) { /* Switch to independent I/O (permanently) */ make_ind = TRUE; } #ifndef H5_MPI_COMPLEX_DERIVED_DATATYPE_WORKS else { /* Switch to independent I/O (temporarily) */ make_ind = TRUE; make_coll = TRUE; } /* end else */ #endif /* H5_MPI_COMPLEX_DERIVED_DATATYPE_WORKS */ } /* end if */ /* Switch to independent I/O */ if(make_ind) if(H5D_ioinfo_make_ind(io_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't switch to independent I/O") #endif /* H5_HAVE_PARALLEL */ /* Perform the actual write operation */ status = (io_info->ops.write)(io_info, chunk_info->chunk_points, H5T_get_size(dataset->shared->type), chunk_info->fspace, chunk_info->mspace, buf); #ifdef H5_HAVE_PARALLEL /* Switch back to collective I/O */ if(make_coll) if(H5D_ioinfo_make_coll(io_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't switch to independent I/O") #endif /* H5_HAVE_PARALLEL */ /* Check return value from optimized write */ if (status<0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "optimized write failed") /* Get the next chunk node in the skip list */ chunk_node=H5SL_next(chunk_node); } /* end while */ #ifdef H5S_DEBUG H5_timer_end(&(io_info->stats->stats[0].write_timer), &timer); io_info->stats->stats[0].write_nbytes += nelmts * H5T_get_size(mem_type); io_info->stats->stats[0].write_ncalls++; #endif /* direct xfer accomplished successfully */ HGOTO_DONE(SUCCEED) } /* end if */ /* * This is the general case (type conversion, usually). */ if(nelmts==0) HGOTO_DONE(SUCCEED) /* Compute element sizes and other parameters */ src_type_size = H5T_get_size(mem_type); dst_type_size = H5T_get_size(dataset->shared->type); max_type_size = MAX(src_type_size, dst_type_size); target_size = dxpl_cache->max_temp_buf; /* XXX: This could cause a problem if the user sets their buffer size * to the same size as the default, and then the dataset elements are * too large for the buffer... - QAK */ if(target_size==H5D_XFER_MAX_TEMP_BUF_DEF) { /* If the buffer is too small to hold even one element, make it bigger */ if(target_size(nelmts*max_type_size)) target_size=(size_t)(nelmts*max_type_size); } /* end if */ request_nelmts = target_size / max_type_size; /* Sanity check elements in temporary buffer */ if (request_nelmts==0) HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "temporary buffer max size is too small") /* * Get a temporary buffer for type conversion unless the app has already * supplied one through the xfer properties. Instead of allocating a * buffer which is the exact size, we allocate the target size. The * malloc() is usually less resource-intensive if we allocate/free the * same size over and over. */ if(H5T_detect_class(dataset->shared->type, H5T_VLEN)) { /* Old data is retrieved into background buffer for VL datatype. The * data is used later for freeing heap objects. */ need_bkg = H5T_BKG_YES; } else if (H5T_path_bkg(tpath)) { H5T_bkg_t path_bkg; /* Type conversion's background info */ /* Retrieve the bkgr buffer property */ need_bkg=dxpl_cache->bkgr_buf_type; path_bkg = H5T_path_bkg(tpath); need_bkg = MAX (path_bkg, need_bkg); } else { need_bkg = H5T_BKG_NO; /*never needed even if app says yes*/ } /* end else */ if (NULL==(tconv_buf=dxpl_cache->tconv_buf)) { /* Allocate temporary buffer */ if((tconv_buf=H5FL_BLK_MALLOC(type_conv,target_size))==NULL) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion") } /* end if */ if (need_bkg && NULL==(bkg_buf=dxpl_cache->bkgr_buf)) { /* Allocate background buffer */ /* (Don't need calloc()-like call since file data is already initialized) */ if((bkg_buf=H5FL_BLK_MALLOC(type_conv,(request_nelmts*dst_type_size)))==NULL) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for background conversion") } /* end if */ /* Loop over all the chunks, performing I/O on each */ /* Get first node in chunk skip list */ chunk_node=H5SL_first(fm.fsel); /* Iterate through chunks to be operated on */ while(chunk_node) { H5D_chunk_info_t *chunk_info; /* chunk information */ /* Get the actual chunk information from the skip list node */ chunk_info=H5SL_item(chunk_node); /* initialize selection iterator */ if (H5S_select_iter_init(&file_iter, chunk_info->fspace, dst_type_size)<0) HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize file selection information") file_iter_init=1; /*file selection iteration info has been initialized */ if (H5S_select_iter_init(&mem_iter, chunk_info->mspace, src_type_size)<0) HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information") mem_iter_init=1; /*file selection iteration info has been initialized */ if (H5S_select_iter_init(&bkg_iter, chunk_info->fspace, dst_type_size)<0) HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize background selection information") bkg_iter_init=1; /*file selection iteration info has been initialized */ /*pass in chunk's coordinates in a union*/ store.chunk.offset = chunk_info->coords; store.chunk.index = chunk_info->index; for (smine_start=0; smine_startchunk_points; smine_start+=smine_nelmts) { /* Go figure out how many elements to read from the file */ assert(H5S_SELECT_ITER_NELMTS(&file_iter)==(chunk_info->chunk_points-smine_start)); smine_nelmts = (size_t)MIN(request_nelmts, (chunk_info->chunk_points-smine_start)); /* * Gather the data from disk into the data type conversion * buffer. Also gather data from application to background buffer * if necessary. */ #ifdef H5S_DEBUG H5_timer_begin(&timer); #endif n = H5D_select_mgath(buf, chunk_info->mspace, &mem_iter, smine_nelmts, dxpl_cache, tconv_buf/*out*/); #ifdef H5S_DEBUG H5_timer_end(&(io_info->stats->stats[1].gath_timer), &timer); io_info->stats->stats[1].gath_nbytes += n * src_type_size; io_info->stats->stats[1].gath_ncalls++; #endif if (n!=smine_nelmts) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file gather failed") if (H5T_BKG_YES==need_bkg) { #ifdef H5S_DEBUG H5_timer_begin(&timer); #endif n = H5D_select_fgath(io_info, chunk_info->fspace, &bkg_iter, smine_nelmts, bkg_buf/*out*/); #ifdef H5S_DEBUG H5_timer_end(&(io_info->stats->stats[0].bkg_timer), &timer); io_info->stats->stats[0].bkg_nbytes += n * dst_type_size; io_info->stats->stats[0].bkg_ncalls++; #endif if (n!=smine_nelmts) HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "file gather failed") } /* end if */ /* * Perform data type conversion. */ if (H5T_convert(tpath, src_id, dst_id, smine_nelmts, 0, 0, tconv_buf, bkg_buf, io_info->dxpl_id)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "data type conversion failed") /* * Scatter the data out to the file. */ #ifdef H5S_DEBUG H5_timer_begin(&timer); #endif status = H5D_select_fscat(io_info, chunk_info->fspace, &file_iter, smine_nelmts, tconv_buf); #ifdef H5S_DEBUG H5_timer_end(&(io_info->stats->stats[0].scat_timer), &timer); io_info->stats->stats[0].scat_nbytes += n * dst_type_size; io_info->stats->stats[0].scat_ncalls++; #endif if (status<0) HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "scatter failed") } /* end for */ /* Release selection iterators */ if(file_iter_init) { if(H5S_SELECT_ITER_RELEASE(&file_iter)<0) HGOTO_ERROR (H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") file_iter_init=0; } /* end if */ if(mem_iter_init) { if(H5S_SELECT_ITER_RELEASE(&mem_iter)<0) HGOTO_ERROR (H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") mem_iter_init=0; } /* end if */ if(bkg_iter_init) { if(H5S_SELECT_ITER_RELEASE(&bkg_iter)<0) HGOTO_ERROR (H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") bkg_iter_init=0; } /* end if */ /* Get the next chunk node in the skip list */ chunk_node=H5SL_next(chunk_node); } /* end while */ done: /* Release selection iterators, if necessary */ if(file_iter_init) { if(H5S_SELECT_ITER_RELEASE(&file_iter)<0) HDONE_ERROR (H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") } /* end if */ if(mem_iter_init) { if(H5S_SELECT_ITER_RELEASE(&mem_iter)<0) HDONE_ERROR (H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") } /* end if */ if(bkg_iter_init) { if(H5S_SELECT_ITER_RELEASE(&bkg_iter)<0) HDONE_ERROR (H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") } /* end if */ if (tconv_buf && NULL==dxpl_cache->tconv_buf) H5FL_BLK_FREE(type_conv,tconv_buf); if (bkg_buf && NULL==dxpl_cache->bkgr_buf) H5FL_BLK_FREE(type_conv,bkg_buf); /* Release chunk mapping information */ if(H5D_destroy_chunk_map(&fm) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't release chunk mapping") FUNC_LEAVE_NOAPI(ret_value) } /* H5D_chunk_write() */ /*------------------------------------------------------------------------- * Function: H5D_create_chunk_map * * Purpose: Creates the mapping between elements selected in each chunk * and the elements in the memory selection. * * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu * Thursday, April 10, 2003 * * Modifications: * QAK - 2003/04/17 * Hacked on it a lot. :-) * *------------------------------------------------------------------------- */ static herr_t H5D_create_chunk_map(const H5D_t *dataset, const H5T_t *mem_type, const H5S_t *file_space, const H5S_t *mem_space, fm_map *fm) { H5S_t *tmp_mspace=NULL; /* Temporary memory dataspace */ H5S_t *equiv_mspace=NULL; /* Equivalent memory dataspace */ hbool_t equiv_mspace_init=0;/* Equivalent memory dataspace was created */ hssize_t old_offset[H5O_LAYOUT_NDIMS]; /* Old selection offset */ hbool_t file_space_normalized = FALSE; /* File dataspace was normalized */ hid_t f_tid=(-1); /* Temporary copy of file datatype for iteration */ hbool_t iter_init=0; /* Selection iteration info has been initialized */ unsigned f_ndims; /* The number of dimensions of the file's dataspace */ int sm_ndims; /* The number of dimensions of the memory buffer's dataspace (signed) */ H5SL_node_t *curr_node; /* Current node in skip list */ H5S_sel_type fsel_type; /* Selection type on disk */ char bogus; /* "bogus" buffer to pass to selection iterator */ unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5D_create_chunk_map) /* Get layout for dataset */ fm->layout = &(dataset->shared->layout); /* Check if the memory space is scalar & make equivalent memory space */ if((sm_ndims = H5S_GET_EXTENT_NDIMS(mem_space))<0) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get dimension number") if(sm_ndims==0) { hsize_t dims[H5O_LAYOUT_NDIMS]; /* Temporary dimension information */ /* Set up "equivalent" n-dimensional dataspace with size '1' in each dimension */ for(u=0; ushared->layout.u.chunk.ndims-1; u++) dims[u]=1; if((equiv_mspace = H5S_create_simple(dataset->shared->layout.u.chunk.ndims-1,dims,NULL))==NULL) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTCREATE, FAIL, "unable to create equivalent dataspace for scalar space") /* Indicate that this space needs to be released */ equiv_mspace_init=1; /* Set the number of dimensions for the memory dataspace */ fm->m_ndims=dataset->shared->layout.u.chunk.ndims-1; } /* end else */ else { equiv_mspace=(H5S_t *)mem_space; /* Casting away 'const' OK... */ /* Set the number of dimensions for the memory dataspace */ H5_ASSIGN_OVERFLOW(fm->m_ndims,sm_ndims,int,unsigned); } /* end else */ /* Get dim number and dimensionality for each dataspace */ fm->f_ndims=f_ndims=dataset->shared->layout.u.chunk.ndims-1; if(H5S_get_simple_extent_dims(file_space, fm->f_dims, NULL)<0) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get dimensionality") /* Normalize hyperslab selections by adjusting them by the offset */ /* (It might be worthwhile to normalize both the file and memory dataspaces * before any (contiguous, chunked, etc) file I/O operation, in order to * speed up hyperslab calculations by removing the extra checks and/or * additions involving the offset and the hyperslab selection -QAK) */ if(H5S_hyper_normalize_offset((H5S_t *)file_space, old_offset)<0) HGOTO_ERROR (H5E_DATASET, H5E_BADSELECT, FAIL, "unable to normalize dataspace by offset") file_space_normalized = TRUE; /* Decide the number of chunks in each dimension*/ for(u=0; uchunk_dim[u]=fm->layout->u.chunk.dim[u]; /* Round up to the next integer # of chunks, to accomodate partial chunks */ fm->chunks[u] = ((fm->f_dims[u]+dataset->shared->layout.u.chunk.dim[u])-1) / dataset->shared->layout.u.chunk.dim[u]; } /* end for */ /* Compute the "down" size of 'chunks' information */ if(H5V_array_down(f_ndims,fm->chunks,fm->down_chunks)<0) HGOTO_ERROR (H5E_INTERNAL, H5E_BADVALUE, FAIL, "can't compute 'down' sizes") /* Initialize skip list for chunk selections */ if((fm->fsel=H5SL_create(H5SL_TYPE_HSIZE,0.5,H5D_DEFAULT_SKIPLIST_HEIGHT))==NULL) HGOTO_ERROR(H5E_DATASET,H5E_CANTCREATE,FAIL,"can't create skip list for chunk selections") /* Initialize "last chunk" information */ fm->last_index=(hsize_t)-1; fm->last_chunk_info=NULL; /* Point at the dataspaces */ fm->file_space=file_space; fm->mem_space=equiv_mspace; fm->mem_space_copy=equiv_mspace_init; /* Make certain to copy memory dataspace if necessary */ /* Get type of selection on disk & in memory */ if((fsel_type=H5S_GET_SELECT_TYPE(file_space))msel_type=H5S_GET_SELECT_TYPE(equiv_mspace))shared->type, H5T_COPY_ALL)))<0) HGOTO_ERROR (H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register file datatype") /* Spaces aren't the same shape, iterate over the memory selection directly */ if(H5S_select_iterate(&bogus, f_tid, file_space, H5D_chunk_file_cb, fm)<0) HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create file chunk selections") /* Reset "last chunk" info */ fm->last_index=(hsize_t)-1; fm->last_chunk_info=NULL; } /* end if */ else { /* Build the file selection for each chunk */ if(H5D_create_chunk_file_map_hyper(fm)<0) HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create file chunk selections") /* Clean file chunks' hyperslab span "scratch" information */ curr_node=H5SL_first(fm->fsel); while(curr_node) { H5D_chunk_info_t *chunk_info; /* Pointer chunk information */ /* Get pointer to chunk's information */ chunk_info=H5SL_item(curr_node); assert(chunk_info); /* Clean hyperslab span's "scratch" information */ if(H5S_hyper_reset_scratch(chunk_info->fspace)<0) HGOTO_ERROR (H5E_DATASET, H5E_CANTFREE, FAIL, "unable to reset span scratch info") /* Get the next chunk node in the skip list */ curr_node=H5SL_next(curr_node); } /* end while */ } /* end else */ /* Build the memory selection for each chunk */ if(fsel_type!=H5S_SEL_POINTS && H5S_select_shape_same(file_space,equiv_mspace)==TRUE) { /* Reset chunk template information */ fm->mchunk_tmpl=NULL; /* If the selections are the same shape, use the file chunk information * to generate the memory chunk information quickly. */ if(H5D_create_chunk_mem_map_hyper(fm)<0) HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create memory chunk selections") } /* end if */ else { size_t elmt_size; /* Memory datatype size */ /* Make a copy of equivalent memory space */ if((tmp_mspace = H5S_copy(equiv_mspace,TRUE))==NULL) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy memory space") /* De-select the mem space copy */ if(H5S_select_none(tmp_mspace)<0) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to de-select memory space") /* Save chunk template information */ fm->mchunk_tmpl=tmp_mspace; /* Create temporary datatypes for selection iteration */ if(f_tid<0) { if((f_tid = H5I_register(H5I_DATATYPE, H5T_copy(dataset->shared->type, H5T_COPY_ALL)))<0) HGOTO_ERROR (H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register file datatype") } /* end if */ /* Create selection iterator for memory selection */ if((elmt_size=H5T_get_size(mem_type))==0) HGOTO_ERROR(H5E_DATATYPE, H5E_BADSIZE, FAIL, "datatype size invalid") if (H5S_select_iter_init(&(fm->mem_iter), equiv_mspace, elmt_size)<0) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator") iter_init=1; /* Selection iteration info has been initialized */ /* Spaces aren't the same shape, iterate over the memory selection directly */ if(H5S_select_iterate(&bogus, f_tid, file_space, H5D_chunk_mem_cb, fm)<0) HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create memory chunk selections") /* Clean up hyperslab stuff, if necessary */ if(fm->msel_type!=H5S_SEL_POINTS) { /* Clean memory chunks' hyperslab span "scratch" information */ curr_node=H5SL_first(fm->fsel); while(curr_node) { H5D_chunk_info_t *chunk_info; /* Pointer chunk information */ /* Get pointer to chunk's information */ chunk_info=H5SL_item(curr_node); assert(chunk_info); /* Clean hyperslab span's "scratch" information */ if(H5S_hyper_reset_scratch(chunk_info->mspace)<0) HGOTO_ERROR (H5E_DATASET, H5E_CANTFREE, FAIL, "unable to reset span scratch info") /* Get the next chunk node in the skip list */ curr_node=H5SL_next(curr_node); } /* end while */ } /* end if */ } /* end else */ done: /* Release the [potentially partially built] chunk mapping information if an error occurs */ if(ret_value<0) { if(tmp_mspace && !fm->mchunk_tmpl) { if(H5S_close(tmp_mspace)<0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "can't release memory chunk dataspace template") } /* end if */ if (H5D_destroy_chunk_map(fm)<0) HDONE_ERROR (H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release chunk mapping") } /* end if */ /* Reset the global dataspace info */ fm->file_space=NULL; fm->mem_space=NULL; if(equiv_mspace_init && equiv_mspace) { if(H5S_close(equiv_mspace)<0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "can't release memory chunk dataspace template") } /* end if */ if(iter_init) { if (H5S_SELECT_ITER_RELEASE(&(fm->mem_iter))<0) HDONE_ERROR (H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator") } if(f_tid!=(-1)) { if(H5I_dec_ref(f_tid)<0) HDONE_ERROR (H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") } /* end if */ if(file_space_normalized) { if(H5S_hyper_denormalize_offset((H5S_t *)file_space, old_offset)<0) HGOTO_ERROR (H5E_DATASET, H5E_BADSELECT, FAIL, "unable to normalize dataspace by offset") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_create_chunk_map() */ /*-------------------------------------------------------------------------- NAME H5D_free_chunk_info PURPOSE Internal routine to destroy a chunk info node USAGE void H5D_free_chunk_info(chunk_info) void *chunk_info; IN: Pointer to chunk info to destroy RETURNS No return value DESCRIPTION Releases all the memory for a chunk info node. Called by H5SL_iterate GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5D_free_chunk_info(void *item, void UNUSED *key, void UNUSED *opdata) { H5D_chunk_info_t *chunk_info=(H5D_chunk_info_t *)item; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_free_chunk_info) assert(chunk_info); /* Close the chunk's file dataspace */ (void)H5S_close(chunk_info->fspace); /* Close the chunk's memory dataspace, if it's not shared */ if(!chunk_info->mspace_shared) (void)H5S_close(chunk_info->mspace); /* Free the actual chunk info */ H5FL_FREE(H5D_chunk_info_t,chunk_info); FUNC_LEAVE_NOAPI(0); } /* H5D_free_chunk_info() */ /*------------------------------------------------------------------------- * Function: H5D_destroy_chunk_map * * Purpose: Destroy chunk mapping information. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Saturday, May 17, 2003 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5D_destroy_chunk_map(const fm_map *fm) { herr_t ret_value = SUCCEED; /*return value */ FUNC_ENTER_NOAPI_NOINIT(H5D_destroy_chunk_map) /* Free the chunk info skip list */ if(fm->fsel) { if(H5SL_count(fm->fsel)>0) if(H5SL_iterate(fm->fsel,H5D_free_chunk_info,NULL)<0) HGOTO_ERROR(H5E_PLIST,H5E_CANTNEXT,FAIL,"can't iterate over chunks") H5SL_close(fm->fsel); } /* end if */ /* Free the memory chunk dataspace template */ if(fm->mchunk_tmpl) if(H5S_close(fm->mchunk_tmpl)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "can't release memory chunk dataspace template") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_destroy_chunk_map() */ /*------------------------------------------------------------------------- * Function: H5D_create_chunk_file_map_hyper * * Purpose: Create all chunk selections in file. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Thursday, May 29, 2003 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5D_create_chunk_file_map_hyper(const fm_map *fm) { hssize_t ssel_points; /* Number of elements in file selection */ hsize_t sel_points; /* Number of elements in file selection */ hsize_t sel_start[H5O_LAYOUT_NDIMS]; /* Offset of low bound of file selection */ hsize_t sel_end[H5O_LAYOUT_NDIMS]; /* Offset of high bound of file selection */ hsize_t start_coords[H5O_LAYOUT_NDIMS]; /* Starting coordinates of selection */ hsize_t coords[H5O_LAYOUT_NDIMS]; /* Current coordinates of chunk */ hsize_t end[H5O_LAYOUT_NDIMS]; /* Current coordinates of chunk */ hsize_t chunk_index; /* Index of chunk */ int curr_dim; /* Current dimension to increment */ unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5D_create_chunk_file_map_hyper) /* Sanity check */ assert(fm->f_ndims>0); /* Get number of elements selected in file */ if((ssel_points=H5S_GET_SELECT_NPOINTS(fm->file_space))<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get file selection # of elements") H5_ASSIGN_OVERFLOW(sel_points,ssel_points,hssize_t,hsize_t); /* Get bounding box for selection (to reduce the number of chunks to iterate over) */ if(H5S_SELECT_BOUNDS(fm->file_space, sel_start, sel_end)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get file selection bound info") /* Set initial chunk location & hyperslab size */ for(u=0; uf_ndims; u++) { start_coords[u]=(sel_start[u]/fm->layout->u.chunk.dim[u])*fm->layout->u.chunk.dim[u]; coords[u]=start_coords[u]; end[u]=(coords[u]+fm->chunk_dim[u])-1; } /* end for */ /* Calculate the index of this chunk */ if(H5V_chunk_index(fm->f_ndims,coords,fm->layout->u.chunk.dim,fm->down_chunks,&chunk_index)<0) HGOTO_ERROR (H5E_DATASPACE, H5E_BADRANGE, FAIL, "can't get chunk index") /* Iterate through each chunk in the dataset */ while(sel_points) { /* Check for intersection of temporary chunk and file selection */ /* (Casting away const OK - QAK) */ if(H5S_hyper_intersect_block((H5S_t *)fm->file_space,coords,end)==TRUE) { H5S_t *tmp_fchunk; /* Temporary file dataspace */ H5D_chunk_info_t *new_chunk_info; /* chunk information to insert into skip list */ hssize_t schunk_points; /* Number of elements in chunk selection */ /* Create "temporary" chunk for selection operations (copy file space) */ if((tmp_fchunk = H5S_copy(fm->file_space,TRUE))==NULL) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy memory space") /* Make certain selections are stored in span tree form (not "optimized hyperslab" or "all") */ if(H5S_hyper_convert(tmp_fchunk)<0) { (void)H5S_close(tmp_fchunk); HGOTO_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to convert selection to span trees") } /* end if */ /* "AND" temporary chunk and current chunk */ if(H5S_select_hyperslab(tmp_fchunk,H5S_SELECT_AND,coords,NULL,fm->chunk_dim,NULL)<0) { (void)H5S_close(tmp_fchunk); HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't create chunk selection") } /* end if */ /* Resize chunk's dataspace dimensions to size of chunk */ if(H5S_set_extent_real(tmp_fchunk,fm->chunk_dim)<0) { (void)H5S_close(tmp_fchunk); HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't adjust chunk dimensions") } /* end if */ /* Move selection back to have correct offset in chunk */ if(H5S_hyper_adjust_u(tmp_fchunk,coords)<0) { (void)H5S_close(tmp_fchunk); HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't adjust chunk selection") } /* end if */ /* Add temporary chunk to the list of chunks */ /* Allocate the file & memory chunk information */ if (NULL==(new_chunk_info = H5FL_MALLOC (H5D_chunk_info_t))) { (void)H5S_close(tmp_fchunk); HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate chunk info") } /* end if */ /* Initialize the chunk information */ /* Set the chunk index */ new_chunk_info->index=chunk_index; /* Set the file chunk dataspace */ new_chunk_info->fspace=tmp_fchunk; /* Set the memory chunk dataspace */ new_chunk_info->mspace=NULL; new_chunk_info->mspace_shared=0; /* Copy the chunk's coordinates */ for(u=0; uf_ndims; u++) new_chunk_info->coords[u]=coords[u]; new_chunk_info->coords[fm->f_ndims]=0; /* Insert the new chunk into the skip list */ if(H5SL_insert(fm->fsel,new_chunk_info,&new_chunk_info->index)<0) { H5D_free_chunk_info(new_chunk_info,NULL,NULL); HGOTO_ERROR(H5E_DATASPACE,H5E_CANTINSERT,FAIL,"can't insert chunk into skip list") } /* end if */ /* Get number of elements selected in chunk */ if((schunk_points=H5S_GET_SELECT_NPOINTS(tmp_fchunk))<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get file selection # of elements") H5_ASSIGN_OVERFLOW(new_chunk_info->chunk_points,schunk_points,hssize_t,size_t); /* Decrement # of points left in file selection */ sel_points-=(hsize_t)schunk_points; /* Leave if we are done */ if(sel_points==0) HGOTO_DONE(SUCCEED) assert(sel_points>0); } /* end if */ /* Increment chunk index */ chunk_index++; /* Set current increment dimension */ curr_dim=(int)fm->f_ndims-1; /* Increment chunk location in fastest changing dimension */ H5_CHECK_OVERFLOW(fm->chunk_dim[curr_dim],hsize_t,hssize_t); coords[curr_dim]+=fm->chunk_dim[curr_dim]; end[curr_dim]+=fm->chunk_dim[curr_dim]; /* Bring chunk location back into bounds, if necessary */ if(coords[curr_dim]>sel_end[curr_dim]) { do { /* Reset current dimension's location to 0 */ coords[curr_dim]=start_coords[curr_dim]; /*lint !e771 The start_coords will always be initialized */ end[curr_dim]=(coords[curr_dim]+(hssize_t)fm->chunk_dim[curr_dim])-1; /* Decrement current dimension */ curr_dim--; /* Increment chunk location in current dimension */ coords[curr_dim]+=fm->chunk_dim[curr_dim]; end[curr_dim]=(coords[curr_dim]+fm->chunk_dim[curr_dim])-1; } while(coords[curr_dim]>sel_end[curr_dim]); /* Re-Calculate the index of this chunk */ if(H5V_chunk_index(fm->f_ndims,coords,fm->layout->u.chunk.dim,fm->down_chunks,&chunk_index)<0) HGOTO_ERROR (H5E_DATASPACE, H5E_BADRANGE, FAIL, "can't get chunk index") } /* end if */ } /* end while */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_create_chunk_file_map_hyper() */ /*------------------------------------------------------------------------- * Function: H5D_create_chunk_mem_map_hyper * * Purpose: Create all chunk selections in memory by copying the file * chunk selections and adjusting their offsets to be correct * for the memory. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Thursday, May 29, 2003 * * Assumptions: That the file and memory selections are the same shape. * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5D_create_chunk_mem_map_hyper(const fm_map *fm) { H5SL_node_t *curr_node; /* Current node in skip list */ hsize_t file_sel_start[H5O_LAYOUT_NDIMS]; /* Offset of low bound of file selection */ hsize_t file_sel_end[H5O_LAYOUT_NDIMS]; /* Offset of high bound of file selection */ hsize_t mem_sel_start[H5O_LAYOUT_NDIMS]; /* Offset of low bound of file selection */ hsize_t mem_sel_end[H5O_LAYOUT_NDIMS]; /* Offset of high bound of file selection */ hssize_t adjust[H5O_LAYOUT_NDIMS]; /* Adjustment to make to all file chunks */ hssize_t chunk_adjust[H5O_LAYOUT_NDIMS]; /* Adjustment to make to a particular chunk */ unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5D_create_chunk_mem_map_hyper) /* Sanity check */ assert(fm->f_ndims>0); /* Check for all I/O going to a single chunk */ if(H5SL_count(fm->fsel)==1) { H5D_chunk_info_t *chunk_info; /* Pointer to chunk information */ /* Get the node */ curr_node=H5SL_first(fm->fsel); /* Get pointer to chunk's information */ chunk_info=H5SL_item(curr_node); assert(chunk_info); /* Check if it's OK to share dataspace */ if(fm->mem_space_copy) { /* Copy the memory dataspace & selection to be the chunk's dataspace & selection */ if((chunk_info->mspace = H5S_copy(fm->mem_space,FALSE))==NULL) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy memory space") } /* end if */ else { /* Just point at the memory dataspace & selection */ /* (Casting away const OK -QAK) */ chunk_info->mspace=(H5S_t *)fm->mem_space; /* Indicate that the chunk's memory space is shared */ chunk_info->mspace_shared=1; } /* end else */ } /* end if */ else { /* Get bounding box for file selection */ if(H5S_SELECT_BOUNDS(fm->file_space, file_sel_start, file_sel_end)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get file selection bound info") /* Get bounding box for memory selection */ if(H5S_SELECT_BOUNDS(fm->mem_space, mem_sel_start, mem_sel_end)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get file selection bound info") /* Calculate the adjustment for memory selection from file selection */ assert(fm->m_ndims==fm->f_ndims); for(u=0; uf_ndims; u++) { H5_CHECK_OVERFLOW(file_sel_start[u],hsize_t,hssize_t); H5_CHECK_OVERFLOW(mem_sel_start[u],hsize_t,hssize_t); adjust[u]=(hssize_t)file_sel_start[u]-(hssize_t)mem_sel_start[u]; } /* end for */ /* Iterate over each chunk in the chunk list */ curr_node=H5SL_first(fm->fsel); while(curr_node) { H5D_chunk_info_t *chunk_info; /* Pointer to chunk information */ /* Get pointer to chunk's information */ chunk_info=H5SL_item(curr_node); assert(chunk_info); /* Copy the information */ /* Copy the memory dataspace */ if((chunk_info->mspace = H5S_copy(fm->mem_space,TRUE))==NULL) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy memory space") /* Release the current selection */ if(H5S_SELECT_RELEASE(chunk_info->mspace)<0) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection") /* Copy the file chunk's selection */ if(H5S_select_copy(chunk_info->mspace,chunk_info->fspace,FALSE)<0) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy selection") /* Compensate for the chunk offset */ for(u=0; uf_ndims; u++) { H5_CHECK_OVERFLOW(chunk_info->coords[u],hsize_t,hssize_t); chunk_adjust[u]=adjust[u]-(hssize_t)chunk_info->coords[u]; /*lint !e771 The adjust array will always be initialized */ } /* end for */ /* Adjust the selection */ if(H5S_hyper_adjust_s(chunk_info->mspace,chunk_adjust)<0) /*lint !e772 The chunk_adjust array will always be initialized */ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't adjust chunk selection") /* Get the next chunk node in the skip list */ curr_node=H5SL_next(curr_node); } /* end while */ } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_create_chunk_mem_map_hyper() */ /*------------------------------------------------------------------------- * Function: H5D_chunk_file_cb * * Purpose: Callback routine for file selection iterator. Used when * creating selections in file for each point selected. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Wednesday, July 23, 2003 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5D_chunk_file_cb(void UNUSED *elem, hid_t UNUSED type_id, unsigned ndims, const hsize_t *coords, void *_fm) { fm_map *fm = (fm_map*)_fm; /* File<->memory chunk mapping info */ H5D_chunk_info_t *chunk_info; /* Chunk information for current chunk */ hsize_t coords_in_chunk[H5O_LAYOUT_NDIMS]; /* Coordinates of element in chunk */ hsize_t chunk_index; /* Chunk index */ unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5D_chunk_file_cb) /* Calculate the index of this chunk */ if(H5V_chunk_index(ndims,coords,fm->layout->u.chunk.dim,fm->down_chunks,&chunk_index)<0) HGOTO_ERROR (H5E_DATASPACE, H5E_BADRANGE, FAIL, "can't get chunk index") /* Find correct chunk in file & memory skip list */ if(chunk_index==fm->last_index) { /* If the chunk index is the same as the last chunk index we used, * get the cached info to operate on. */ chunk_info=fm->last_chunk_info; } /* end if */ else { /* If the chunk index is not the same as the last chunk index we used, * find the chunk in the skip list. */ /* Get the chunk node from the skip list */ if((chunk_info=H5SL_search(fm->fsel,&chunk_index))==NULL) { H5S_t *fspace; /* Memory chunk's dataspace */ /* Allocate the file & memory chunk information */ if (NULL==(chunk_info = H5FL_MALLOC (H5D_chunk_info_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate chunk info") /* Initialize the chunk information */ /* Set the chunk index */ chunk_info->index=chunk_index; /* Create a dataspace for the chunk */ if((fspace = H5S_create_simple(fm->f_ndims,fm->chunk_dim,NULL))==NULL) { H5FL_FREE(H5D_chunk_info_t,chunk_info); HGOTO_ERROR (H5E_DATASPACE, H5E_CANTCREATE, FAIL, "unable to create dataspace for chunk") } /* end if */ /* De-select the chunk space */ if(H5S_select_none(fspace)<0) { (void)H5S_close(fspace); H5FL_FREE(H5D_chunk_info_t,chunk_info); HGOTO_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to de-select dataspace") } /* end if */ /* Set the file chunk dataspace */ chunk_info->fspace=fspace; /* Set the memory chunk dataspace */ chunk_info->mspace=NULL; chunk_info->mspace_shared=0; /* Set the number of selected elements in chunk to zero */ chunk_info->chunk_points=0; /* Compute the chunk's coordinates */ for(u=0; uf_ndims; u++) { H5_CHECK_OVERFLOW(fm->layout->u.chunk.dim[u],hsize_t,hssize_t); chunk_info->coords[u]=(coords[u]/(hssize_t)fm->layout->u.chunk.dim[u])*(hssize_t)fm->layout->u.chunk.dim[u]; } /* end for */ chunk_info->coords[fm->f_ndims]=0; /* Insert the new chunk into the skip list */ if(H5SL_insert(fm->fsel,chunk_info,&chunk_info->index)<0) { H5D_free_chunk_info(chunk_info,NULL,NULL); HGOTO_ERROR(H5E_DATASPACE,H5E_CANTINSERT,FAIL,"can't insert chunk into skip list") } /* end if */ } /* end if */ /* Update the "last chunk seen" information */ fm->last_index=chunk_index; fm->last_chunk_info=chunk_info; } /* end else */ /* Get the coordinates of the element in the chunk */ for(u=0; uf_ndims; u++) coords_in_chunk[u]=coords[u]%fm->layout->u.chunk.dim[u]; /* Add point to file selection for chunk */ if(H5S_select_elements(chunk_info->fspace,H5S_SELECT_APPEND,1,(const hsize_t **)coords_in_chunk)<0) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTSELECT, FAIL, "unable to select element") /* Increment the number of elemented selected in chunk */ chunk_info->chunk_points++; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_chunk_file_cb() */ /*------------------------------------------------------------------------- * Function: H5D_chunk_mem_cb * * Purpose: Callback routine for file selection iterator. Used when * creating selections in memory for each chunk. * * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu * Thursday, April 10, 2003 * * Modifications: * QAK - 2003/04/17 * Hacked on it a lot. :-) * *------------------------------------------------------------------------- */ /* ARGSUSED */ static herr_t H5D_chunk_mem_cb(void UNUSED *elem, hid_t UNUSED type_id, unsigned ndims, const hsize_t *coords, void *_fm) { fm_map *fm = (fm_map*)_fm; /* File<->memory chunk mapping info */ H5D_chunk_info_t *chunk_info; /* Chunk information for current chunk */ hsize_t coords_in_mem[H5O_LAYOUT_NDIMS]; /* Coordinates of element in memory */ hsize_t chunk_index; /* Chunk index */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5D_chunk_mem_cb) /* Calculate the index of this chunk */ if(H5V_chunk_index(ndims,coords,fm->layout->u.chunk.dim,fm->down_chunks,&chunk_index)<0) HGOTO_ERROR (H5E_DATASPACE, H5E_BADRANGE, FAIL, "can't get chunk index") /* Find correct chunk in file & memory skip list */ if(chunk_index==fm->last_index) { /* If the chunk index is the same as the last chunk index we used, * get the cached spaces to operate on. */ chunk_info=fm->last_chunk_info; } /* end if */ else { /* If the chunk index is not the same as the last chunk index we used, * find the chunk in the skip list. */ /* Get the chunk node from the skip list */ if((chunk_info=H5SL_search(fm->fsel,&chunk_index))==NULL) HGOTO_ERROR(H5E_DATASPACE,H5E_NOTFOUND,FAIL,"can't locate chunk in skip list") /* Check if the chunk already has a memory space */ if(chunk_info->mspace==NULL) { /* Copy the template memory chunk dataspace */ if((chunk_info->mspace = H5S_copy(fm->mchunk_tmpl,FALSE))==NULL) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy file space") } /* end else */ /* Update the "last chunk seen" information */ fm->last_index=chunk_index; fm->last_chunk_info=chunk_info; } /* end else */ /* Get coordinates of selection iterator for memory */ if(H5S_SELECT_ITER_COORDS(&fm->mem_iter,coords_in_mem)<0) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get iterator coordinates") /* Add point to memory selection for chunk */ if(fm->msel_type==H5S_SEL_POINTS) { if(H5S_select_elements(chunk_info->mspace,H5S_SELECT_APPEND,1,(const hsize_t **)coords_in_mem)<0) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTSELECT, FAIL, "unable to select element") } /* end if */ else { if(H5S_hyper_add_span_element(chunk_info->mspace, fm->m_ndims, coords_in_mem)<0) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTSELECT, FAIL, "unable to select element") } /* end else */ /* Move memory selection iterator to next element in selection */ if(H5S_SELECT_ITER_NEXT(&fm->mem_iter,1)<0) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTNEXT, FAIL, "unable to move to next iterator location") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_chunk_mem_cb() */ /*------------------------------------------------------------------------- * Function: H5D_ioinfo_init * * Purpose: Routine for determining correct I/O operations for * each I/O action. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Thursday, September 30, 2004 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5D_ioinfo_init(H5D_t *dset, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, const H5S_t #if !(defined H5_HAVE_PARALLEL || defined H5S_DEBUG) UNUSED #endif /* H5_HAVE_PARALLEL */ *mem_space, const H5S_t #if !(defined H5_HAVE_PARALLEL || defined H5S_DEBUG) UNUSED #endif /* H5_HAVE_PARALLEL */ *file_space, H5T_path_t #ifndef H5_HAVE_PARALLEL UNUSED #endif /* H5_HAVE_PARALLEL */ *tpath, H5D_io_info_t *io_info) { herr_t ret_value = SUCCEED; /* Return value */ #if defined H5_HAVE_PARALLEL || defined H5S_DEBUG FUNC_ENTER_NOAPI_NOINIT(H5D_ioinfo_init) #else /* defined H5_HAVE_PARALLEL || defined H5S_DEBUG */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_ioinfo_init) #endif /* defined H5_HAVE_PARALLEL || defined H5S_DEBUG */ /* check args */ HDassert(dset); HDassert(dset->ent.file); HDassert(mem_space); HDassert(file_space); HDassert(tpath); HDassert(io_info); /* Set up "normal" I/O fields */ io_info->dset=dset; io_info->dxpl_cache=dxpl_cache; io_info->dxpl_id=dxpl_id; io_info->store=NULL; /* Set later in I/O routine? */ /* Set I/O operations to initial values */ io_info->ops=dset->shared->io_ops; #ifdef H5_HAVE_PARALLEL /* Start in the "not modified" xfer_mode state */ io_info->xfer_mode_changed = FALSE; if(IS_H5FD_MPI(dset->ent.file)) { htri_t opt; /* Flag whether a selection is optimizable */ /* Get MPI communicator */ if((io_info->comm = H5F_mpi_get_comm(dset->ent.file)) == MPI_COMM_NULL) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't retrieve MPI communicator") /* * Check if we can set direct MPI-IO read/write functions */ opt=H5D_mpio_opt_possible(io_info, mem_space, file_space, tpath); if(opt==FAIL) HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "invalid check for direct IO dataspace "); /* Check if we can use the optimized parallel I/O routines */ if(opt==TRUE) { /* Set the pointers to the MPI-specific routines */ io_info->ops.read = H5D_mpio_select_read; io_info->ops.write = H5D_mpio_select_write; } /* end if */ else { /* Set the pointers to the non-MPI-specific routines */ io_info->ops.read = H5D_select_read; io_info->ops.write = H5D_select_write; /* If we won't be doing collective I/O, but the user asked for * collective I/O, change the request to use independent I/O, but * mark it so that we remember to revert the change. */ if(io_info->dxpl_cache->xfer_mode==H5FD_MPIO_COLLECTIVE) { H5P_genplist_t *dx_plist; /* Data transer property list */ /* Get the dataset transfer property list */ if (NULL == (dx_plist = H5I_object(dxpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list") /* Change the xfer_mode to independent for handling the I/O */ io_info->dxpl_cache->xfer_mode = H5FD_MPIO_INDEPENDENT; if(H5P_set (dx_plist, H5D_XFER_IO_XFER_MODE_NAME, &io_info->dxpl_cache->xfer_mode) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set transfer mode") /* Indicate that the transfer mode should be restored before returning * to user. */ io_info->xfer_mode_changed = TRUE; } /* end if */ #ifdef H5_HAVE_INSTRUMENTED_LIBRARY /**** Test for collective chunk IO notice the following code should be removed after a more general collective chunk IO algorithm is applied. (This property is only reset for independent I/O) */ if(dset->shared->layout.type == H5D_CHUNKED) { /*only check for chunking storage */ htri_t check_prop; check_prop = H5Pexist(dxpl_id,H5D_XFER_COLL_CHUNK_NAME); if(check_prop < 0) HGOTO_ERROR(H5E_PLIST, H5E_UNSUPPORTED, FAIL, "unable to check property list"); if(check_prop > 0) { int prop_value = 0; if(H5Pset(dxpl_id,H5D_XFER_COLL_CHUNK_NAME,&prop_value)<0) HGOTO_ERROR(H5E_PLIST, H5E_UNSUPPORTED, FAIL, "unable to set property value"); } /* end if */ } /* end if */ #endif /* H5_HAVE_INSTRUMENTED_LIBRARY */ } /* end else */ } /* end if */ else { /* Set the pointers to the non-MPI-specific routines */ io_info->ops.read = H5D_select_read; io_info->ops.write = H5D_select_write; } /* end else */ #else /* H5_HAVE_PARALLEL */ io_info->ops.read = H5D_select_read; io_info->ops.write = H5D_select_write; #endif /* H5_HAVE_PARALLEL */ #ifdef H5S_DEBUG /* Get the information for the I/O statistics */ if((io_info->stats=H5S_find(mem_space,file_space))==NULL) HGOTO_ERROR(H5E_DATASET, H5E_BADSELECT, FAIL, "can't set up selection statistics"); #endif /* H5S_DEBUG */ #if defined H5_HAVE_PARALLEL || defined H5S_DEBUG done: #endif /* H5_HAVE_PARALLEL || H5S_DEBUG */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_ioinfo_init() */ #ifdef H5_HAVE_PARALLEL /*------------------------------------------------------------------------- * Function: H5D_ioinfo_make_ind * * Purpose: Switch to MPI independent I/O * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Friday, August 12, 2005 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5D_ioinfo_make_ind(H5D_io_info_t *io_info) { H5P_genplist_t *dx_plist; /* Data transer property list */ herr_t ret_value = SUCCEED; /*return value */ FUNC_ENTER_NOAPI_NOINIT(H5D_ioinfo_make_ind) /* Get the dataset transfer property list */ if (NULL == (dx_plist = H5I_object(io_info->dxpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list") /* Change the xfer_mode to independent, handle the request, * then set xfer_mode before return. */ io_info->dxpl_cache->xfer_mode = H5FD_MPIO_INDEPENDENT; if(H5P_set (dx_plist, H5D_XFER_IO_XFER_MODE_NAME, &io_info->dxpl_cache->xfer_mode) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set transfer mode") /* Set the pointers to the non-MPI-specific routines */ io_info->ops.read = H5D_select_read; io_info->ops.write = H5D_select_write; /* Indicate that the transfer mode should be restored before returning * to user. */ io_info->xfer_mode_changed=TRUE; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_ioinfo_make_ind() */ /*------------------------------------------------------------------------- * Function: H5D_ioinfo_make_coll * * Purpose: Switch to MPI collective I/O * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Friday, August 12, 2005 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5D_ioinfo_make_coll(H5D_io_info_t *io_info) { H5P_genplist_t *dx_plist; /* Data transer property list */ herr_t ret_value = SUCCEED; /*return value */ FUNC_ENTER_NOAPI_NOINIT(H5D_ioinfo_make_coll) /* Get the dataset transfer property list */ if (NULL == (dx_plist = H5I_object(io_info->dxpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list") /* Change the xfer_mode to independent, handle the request, * then set xfer_mode before return. */ io_info->dxpl_cache->xfer_mode = H5FD_MPIO_COLLECTIVE; if(H5P_set (dx_plist, H5D_XFER_IO_XFER_MODE_NAME, &io_info->dxpl_cache->xfer_mode) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set transfer mode") /* Set the pointers to the MPI-specific routines */ io_info->ops.read = H5D_mpio_select_read; io_info->ops.write = H5D_mpio_select_write; /* Indicate that the transfer mode should _NOT_ be restored before returning * to user. */ io_info->xfer_mode_changed=FALSE; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_ioinfo_make_coll() */ /*------------------------------------------------------------------------- * Function: H5D_ioinfo_term * * Purpose: Common logic for terminating an I/O info object * (Only used for restoring MPI transfer mode currently) * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Friday, February 6, 2004 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5D_ioinfo_term(H5D_io_info_t *io_info) { herr_t ret_value = SUCCEED; /*return value */ FUNC_ENTER_NOAPI_NOINIT(H5D_ioinfo_term) /* Check if we need to revert the change to the xfer mode */ if (io_info->xfer_mode_changed) { H5P_genplist_t *dx_plist; /* Data transer property list */ /* Get the dataset transfer property list */ if (NULL == (dx_plist = H5I_object(io_info->dxpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list") /* Restore the original parallel I/O mode */ io_info->dxpl_cache->xfer_mode = H5FD_MPIO_COLLECTIVE; if(H5P_set (dx_plist, H5D_XFER_IO_XFER_MODE_NAME, &io_info->dxpl_cache->xfer_mode) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set transfer mode") } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_ioinfo_term() */ /*------------------------------------------------------------------------- * Function: H5D_mpio_get_min_chunk * * Purpose: Routine for obtaining minimum number of chunks to cover * hyperslab selection selected by all processors. * * Return: Non-negative on success/Negative on failure * * Programmer: * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5D_mpio_get_min_chunk(const H5D_io_info_t *io_info, const fm_map *fm, int *min_chunkf) { int num_chunkf; /* Number of chunks to iterate over */ int mpi_code; /* MPI return code */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT(H5D_mpio_get_min_chunk); /* Get the number of chunks to perform I/O on */ num_chunkf = H5SL_count(fm->fsel); /* Determine the minimum # of chunks for all processes */ if (MPI_SUCCESS != (mpi_code = MPI_Allreduce(&num_chunkf, min_chunkf, 1, MPI_INT, MPI_MIN, io_info->comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Allreduce failed", mpi_code) done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5D_mpio_get_min_chunk() */ #endif /*H5_HAVE_PARALLEL*/ xdmf-3.0+git20160803/Utilities/hdf5/hdf5_zlib.h.in0000640000175000017500000000003613003006557021316 0ustar alastairalastair#include <@HDF5_ZLIB_HEADER@> xdmf-3.0+git20160803/Utilities/hdf5/H5FDmpi.h0000640000175000017500000000737113003006557020250 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Quincey Koziol * Friday, January 30, 2004 * * Purpose: The public header file for common items for all MPI VFL drivers */ #ifndef H5FDmpi_H #define H5FDmpi_H /* Type of I/O for data transfer properties */ typedef enum H5FD_mpio_xfer_t { H5FD_MPIO_INDEPENDENT = 0, /*zero is the default*/ H5FD_MPIO_COLLECTIVE } H5FD_mpio_xfer_t; #ifdef H5_HAVE_PARALLEL /* Sub-class the H5FD_class_t to add more specific functions for MPI-based VFDs */ typedef struct H5FD_class_mpi_t { H5FD_class_t super; /* Superclass information & methods */ int (*get_rank)(const H5FD_t *file); /* Get the MPI rank of a process */ int (*get_size)(const H5FD_t *file); /* Get the MPI size of a communicator */ MPI_Comm (*get_comm)(const H5FD_t *file); /* Get the communicator for a file */ } H5FD_class_mpi_t; #endif /* H5_HAVE_PARALLEL */ /* Include all the MPI VFL headers */ #include "H5FDmpio.h" /* MPI I/O file driver */ #include "H5FDmpiposix.h" /* MPI/posix I/O file driver */ /* Macros */ /* Single macro to check for all file drivers that use MPI */ #define IS_H5FD_MPI(file) \ (IS_H5FD_MPIO(file) || IS_H5FD_MPIPOSIX(file)) #ifdef H5_HAVE_PARALLEL /* ======== Temporary data transfer properties ======== */ /* Definitions for memory MPI type property */ #define H5FD_MPI_XFER_MEM_MPI_TYPE_NAME "H5FD_mpi_mem_mpi_type" #define H5FD_MPI_XFER_MEM_MPI_TYPE_SIZE sizeof(MPI_Datatype) /* Definitions for file MPI type property */ #define H5FD_MPI_XFER_FILE_MPI_TYPE_NAME "H5FD_mpi_file_mpi_type" #define H5FD_MPI_XFER_FILE_MPI_TYPE_SIZE sizeof(MPI_Datatype) /* * The view is set to this value */ H5_DLLVAR char H5FD_mpi_native_g[]; /* Function prototypes */ #ifdef __cplusplus extern "C" { #endif /* General routines */ H5_DLL haddr_t H5FD_mpi_MPIOff_to_haddr(MPI_Offset mpi_off); H5_DLL herr_t H5FD_mpi_haddr_to_MPIOff(haddr_t addr, MPI_Offset *mpi_off/*out*/); H5_DLL herr_t H5FD_mpi_comm_info_dup(MPI_Comm comm, MPI_Info info, MPI_Comm *comm_new, MPI_Info *info_new); H5_DLL herr_t H5FD_mpi_comm_info_free(MPI_Comm *comm, MPI_Info *info); #ifdef NOT_YET H5_DLL herr_t H5FD_mpio_wait_for_left_neighbor(H5FD_t *file); H5_DLL herr_t H5FD_mpio_signal_right_neighbor(H5FD_t *file); #endif /* NOT_YET */ H5_DLL herr_t H5FD_mpi_setup_collective(hid_t dxpl_id, MPI_Datatype btype, MPI_Datatype ftype); H5_DLL herr_t H5FD_mpi_teardown_collective(hid_t dxpl_id); /* Driver specific methods */ H5_DLL int H5FD_mpi_get_rank(const H5FD_t *file); H5_DLL int H5FD_mpi_get_size(const H5FD_t *file); H5_DLL MPI_Comm H5FD_mpi_get_comm(const H5FD_t *_file); #ifdef __cplusplus } #endif #endif /* H5_HAVE_PARALLEL */ #endif /* H5FDmpi_H */ xdmf-3.0+git20160803/Utilities/hdf5/H5Fmount.c0000640000175000017500000005317413003006557020516 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #define H5F_PACKAGE /*suppress error about including H5Fpkg */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5F_init_mount_interface /* Packages needed by this file... */ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* File access */ #include "H5Gprivate.h" /* Groups */ #include "H5Iprivate.h" /* IDs */ #include "H5Pprivate.h" /* Property lists */ #include "H5MMprivate.h" /* Memory management */ /* PRIVATE PROTOTYPES */ /*-------------------------------------------------------------------------- NAME H5F_init_mount_interface -- Initialize interface-specific information USAGE herr_t H5F_init_mount_interface() RETURNS Non-negative on success/Negative on failure DESCRIPTION Initializes any interface-specific data or routines. (Just calls H5F_init_iterface currently). --------------------------------------------------------------------------*/ static herr_t H5F_init_mount_interface(void) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_init_mount_interface) FUNC_LEAVE_NOAPI(H5F_init()) } /* H5F_init_mount_interface() */ /*------------------------------------------------------------------------- * Function: H5F_close_mounts * * Purpose: Close all mounts for a given file * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Saturday, July 2, 2005 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5F_close_mounts(H5F_t *f) { unsigned u; /* Local index */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5F_close_mounts, FAIL) HDassert(f); /* Unmount all child files */ for (u = 0; u < f->mtab.nmounts; u++) { /* Detach the child file from the parent file */ f->mtab.child[u].file->mtab.parent = NULL; /* Close the internal group maintaining the mount point */ if(H5G_close(f->mtab.child[u].group) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "can't close child group") /* Close the child file */ if(H5F_try_close(f->mtab.child[u].file) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close child file") } /* end if */ f->mtab.nmounts = 0; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_close_mounts() */ /*------------------------------------------------------------------------- * Function: H5F_mount * * Purpose: Mount file CHILD onto the group specified by LOC and NAME, * using mount properties in PLIST. CHILD must not already be * mouted and must not be a mount ancestor of the mount-point. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Tuesday, October 6, 1998 * * Modifications: * * Robb Matzke, 1998-10-14 * The reference count for the mounted H5F_t is incremented. * * Pedro Vicente, 22 Aug 2002 * Added `id to name' support. * *------------------------------------------------------------------------- */ static herr_t H5F_mount(H5G_entry_t *loc, const char *name, H5F_t *child, hid_t UNUSED plist_id, hid_t dxpl_id) { H5G_t *mount_point = NULL; /*mount point group */ H5G_entry_t *mp_ent = NULL; /*mount point symbol table entry*/ H5F_t *ancestor = NULL; /*ancestor files */ H5F_t *parent = NULL; /*file containing mount point */ unsigned lt, rt, md; /*binary search indices */ int cmp; /*binary search comparison value*/ H5G_entry_t *ent = NULL; /*temporary symbol table entry */ H5G_entry_t mp_open_ent; /* entry of moint point to be opened */ H5RS_str_t *name_r; /* Ref-counted version of name */ herr_t ret_value = SUCCEED; /*return value */ FUNC_ENTER_NOAPI_NOINIT(H5F_mount) assert(loc); assert(name && *name); assert(child); assert(TRUE==H5P_isa_class(plist_id,H5P_MOUNT)); /* * Check that the child isn't mounted, that the mount point exists, that * the parent & child files have the same file close degree, and * that the mount wouldn't introduce a cycle in the mount tree. */ if (child->mtab.parent) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "file is already mounted") if (H5G_find(loc, name, &mp_open_ent/*out*/, H5AC_dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") if (NULL==(mount_point=H5G_open(&mp_open_ent, dxpl_id))) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point not found") parent = H5G_fileof(mount_point); mp_ent = H5G_entof(mount_point); for (ancestor=parent; ancestor; ancestor=ancestor->mtab.parent) { if (ancestor==child) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount would introduce a cycle") } if(parent->shared->fc_degree != child->shared->fc_degree) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mounted file has different file close degree than parent") /* * Use a binary search to locate the position that the child should be * inserted into the parent mount table. At the end of this paragraph * `md' will be the index where the child should be inserted. */ lt = md = 0; rt=parent->mtab.nmounts; cmp = -1; while (ltmtab.child[md].group); cmp = H5F_addr_cmp(mp_ent->header, ent->header); if (cmp<0) { rt = md; } else if (cmp>0) { lt = md+1; } } if (cmp>0) md++; if (!cmp) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point is already in use") /* Make room in the table */ if (parent->mtab.nmounts>=parent->mtab.nalloc) { unsigned n = MAX(16, 2*parent->mtab.nalloc); H5F_mount_t *x = H5MM_realloc(parent->mtab.child, n*sizeof(parent->mtab.child[0])); if (!x) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for mount table") parent->mtab.child = x; parent->mtab.nalloc = n; } /* Insert into table */ HDmemmove(parent->mtab.child+md+1, parent->mtab.child+md, (parent->mtab.nmounts-md)*sizeof(parent->mtab.child[0])); parent->mtab.nmounts++; parent->mtab.child[md].group = mount_point; parent->mtab.child[md].file = child; child->mtab.parent = parent; /* Set the group's mountpoint flag */ if(H5G_mount(parent->mtab.child[md].group)<0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "unable to set group mounted flag") /* Search the open IDs and replace names for mount operation */ /* We pass H5G_UNKNOWN as object type; search all IDs */ name_r=H5RS_wrap(name); assert(name_r); if (H5G_replace_name( H5G_UNKNOWN, loc, name_r, NULL, NULL, NULL, OP_MOUNT )<0) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to replace name") if(H5RS_decr(name_r)<0) HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to decrement name string") done: if (ret_value<0 && mount_point) if(H5G_close(mount_point)<0) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "unable to close mounted group") FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5F_unmount * * Purpose: Unmount the child which is mounted at the group specified by * LOC and NAME or fail if nothing is mounted there. Neither * file is closed. * * Because the mount point is specified by name and opened as a * group, the H5G_namei() will resolve it to the root of the * mounted file, not the group where the file is mounted. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Tuesday, October 6, 1998 * * Modifications: * * Robb Matzke, 1998-10-14 * The ref count for the child is decremented by calling H5F_close(). * * Pedro Vicente, 22 Aug 2002 * Added `id to name' support. * *------------------------------------------------------------------------- */ static herr_t H5F_unmount(H5G_entry_t *loc, const char *name, hid_t dxpl_id) { H5G_t *mounted = NULL; /*mount point group */ H5G_t *child_group = NULL; /* Child's group in parent mtab */ H5F_t *child_file = NULL; /* Child's file in parent mtab */ H5G_entry_t *mnt_ent = NULL; /*mounted symbol table entry */ H5F_t *child = NULL; /*mounted file */ H5F_t *parent = NULL; /*file where mounted */ H5G_entry_t *ent = NULL; /*temporary symbol table entry */ H5G_entry_t mnt_open_ent; /* entry used to open mount point*/ int child_idx; /* Index of child in parent's mtab */ herr_t ret_value = SUCCEED; /*return value */ FUNC_ENTER_NOAPI_NOINIT(H5F_unmount) assert(loc); assert(name && *name); /* * Get the mount point, or more precisely the root of the mounted file. * If we get the root group and the file has a parent in the mount tree, * then we must have found the mount point. */ if (H5G_find(loc, name, &mnt_open_ent/*out*/, H5AC_dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") if (NULL==(mounted=H5G_open(&mnt_open_ent, dxpl_id))) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point not found") child = H5G_fileof(mounted); mnt_ent = H5G_entof(mounted); ent = H5G_entof(child->shared->root_grp); child_idx = -1; if (child->mtab.parent && H5F_addr_eq(mnt_ent->header, ent->header)) { unsigned u; /*counters */ /* * We've been given the root group of the child. We do a reverse * lookup in the parent's mount table to find the correct entry. */ parent = child->mtab.parent; for (u=0; umtab.nmounts; u++) { if (parent->mtab.child[u].file==child) { /* Found the correct index */ child_idx = u; break; } } } else { unsigned lt, rt, md=0; /*binary search indices */ int cmp; /*binary search comparison value*/ /* * We've been given the mount point in the parent. We use a binary * search in the parent to locate the mounted file, if any. */ parent = child; /*we guessed wrong*/ lt = 0; rt = parent->mtab.nmounts; cmp = -1; while (ltmtab.child[md].group); cmp = H5F_addr_cmp(mnt_ent->header, ent->header); if (cmp<0) { rt = md; } else { lt = md+1; } } if (cmp) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "not a mount point") /* Found the correct index */ child_idx = md; mnt_ent = ent; } HDassert(child_idx >= 0); /* Search the open IDs replace names to reflect unmount operation */ if (H5G_replace_name(H5G_UNKNOWN, mnt_ent, mnt_ent->user_path_r, NULL, NULL, NULL, OP_UNMOUNT )<0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to replace name ") /* Save the information about the child from the mount table */ child_group = parent->mtab.child[child_idx].group; child_file = parent->mtab.child[child_idx].file; /* Eliminate the mount point from the table */ HDmemmove(parent->mtab.child+child_idx, parent->mtab.child+child_idx+1, (parent->mtab.nmounts-child_idx)*sizeof(parent->mtab.child[0])); parent->mtab.nmounts -= 1; /* Unmount the child file from the parent file */ if(H5G_unmount(child_group)<0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "unable to reset group mounted flag") if(H5G_close(child_group)<0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "unable to close unmounted group") /* Detach child file from parent & see if it should close */ child_file->mtab.parent = NULL; if(H5F_try_close(child_file)<0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close unmounted file") done: if (mounted) if(H5G_close(mounted)<0 && ret_value>=0) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "can't close group") FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5F_mountpoint * * Purpose: If ENT is a mount point then copy the entry for the root * group of the mounted file into ENT. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Tuesday, October 6, 1998 * * Modifications: * * Pedro Vicente, 22 Aug 2002 * Added `id to name' support. * *------------------------------------------------------------------------- */ herr_t H5F_mountpoint(H5G_entry_t *find/*in,out*/) { H5F_t *parent = find->file; unsigned lt, rt, md=0; int cmp; H5G_entry_t *ent = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5F_mountpoint, FAIL) assert(find); /* * The loop is necessary because we might have file1 mounted at the root * of file2, which is mounted somewhere in file3. */ do { /* * Use a binary search to find the potential mount point in the mount * table for the parent */ lt = 0; rt = parent->mtab.nmounts; cmp = -1; while (ltmtab.child[md].group); cmp = H5F_addr_cmp(find->header, ent->header); if (cmp<0) { rt = md; } else { lt = md+1; } } /* Copy root info over to ENT */ if (0==cmp) { /* Get the entry for the root group in the child's file */ ent = H5G_entof(parent->mtab.child[md].file->shared->root_grp); /* Don't lose the user path of the group when we copy the root group's entry */ if(H5G_ent_copy(find,ent,H5G_COPY_LIMITED)<0) HGOTO_ERROR(H5E_FILE, H5E_CANTCOPY, FAIL, "unable to copy group entry") /* Switch to child's file */ parent = ent->file; } } while (!cmp); done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5F_has_mount * * Purpose: Check if a file has mounted files within it. * * Return: Success: TRUE/FALSE * Failure: Negative * * Programmer: Quincey Koziol * Thursday, January 2, 2002 * * Modifications: * *------------------------------------------------------------------------- */ htri_t H5F_has_mount(const H5F_t *file) { htri_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5F_has_mount, FAIL) assert(file); if(file->mtab.nmounts>0) ret_value=TRUE; else ret_value=FALSE; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_has_mount() */ /*------------------------------------------------------------------------- * Function: H5F_is_mount * * Purpose: Check if a file is mounted within another file. * * Return: Success: TRUE/FALSE * Failure: Negative * * Programmer: Quincey Koziol * Thursday, January 2, 2002 * * Modifications: * *------------------------------------------------------------------------- */ htri_t H5F_is_mount(const H5F_t *file) { htri_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5F_is_mount, FAIL) assert(file); if(file->mtab.parent!=NULL) ret_value=TRUE; else ret_value=FALSE; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_is_mount() */ /*------------------------------------------------------------------------- * Function: H5Fmount * * Purpose: Mount file CHILD_ID onto the group specified by LOC_ID and * NAME using mount properties PLIST_ID. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Tuesday, October 6, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Fmount(hid_t loc_id, const char *name, hid_t child_id, hid_t plist_id) { H5G_entry_t *loc = NULL; H5F_t *child = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Fmount, FAIL) H5TRACE4("e","isii",loc_id,name,child_id,plist_id); /* Check arguments */ if (NULL==(loc=H5G_loc(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") if (NULL==(child=H5I_object_verify(child_id,H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") if(H5P_DEFAULT == plist_id) plist_id = H5P_MOUNT_DEFAULT; else if(TRUE != H5P_isa_class(plist_id, H5P_MOUNT)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not property list") /* Do the mount */ if (H5F_mount(loc, name, child, plist_id, H5AC_dxpl_id)<0) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to mount file") done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5Funmount * * Purpose: Given a mount point, dissassociate the mount point's file * from the file mounted there. Do not close either file. * * The mount point can either be the group in the parent or the * root group of the mounted file (both groups have the same * name). If the mount point was opened before the mount then * it's the group in the parent, but if it was opened after the * mount then it's the root group of the child. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Tuesday, October 6, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Funmount(hid_t loc_id, const char *name) { H5G_entry_t *loc = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Funmount, FAIL) H5TRACE2("e","is",loc_id,name); /* Check args */ if (NULL==(loc=H5G_loc(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") /* Unmount */ if (H5F_unmount(loc, name, H5AC_dxpl_id)<0) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to unmount file") done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5F_mount_count_ids_recurse * * Purpose: Helper routine for counting number of open IDs in mount * hierarchy. * * Return: * * Programmer: Quincey Koziol * Tuesday, July 19, 2005 * * Modifications: * *------------------------------------------------------------------------- */ static void H5F_mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs) { unsigned u; /* Local index value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_mount_count_ids_recurse) /* Sanity check */ HDassert(f); HDassert(nopen_files); HDassert(nopen_objs); /* If this file is still open, increment number of file IDs open */ if(f->file_id > 0) *nopen_files += 1; /* Increment number of open objects in file * (Reduced by number of mounted files, we'll add back in the mount point's * groups later, if they are open) */ *nopen_objs += (f->nopen_objs - f->mtab.nmounts); /* Iterate over files mounted in this file and add in their open ID counts also */ for(u = 0; u < f->mtab.nmounts; u++) { /* Increment the open object count if the mount point group has an open ID */ if(H5G_get_shared_count(f->mtab.child[u].group) > 1) *nopen_objs += 1; H5F_mount_count_ids_recurse(f->mtab.child[u].file, nopen_files, nopen_objs); } /* end for */ FUNC_LEAVE_NOAPI_VOID } /* end H5F_mount_count_ids_recurse() */ /*------------------------------------------------------------------------- * Function: H5F_mount_count_ids * * Purpose: Count the number of open file & object IDs in a mount hierarchy * * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Tues, July 19, 2005 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5F_mount_count_ids(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5F_mount_count_ids, FAIL) /* Sanity check */ HDassert(f); HDassert(nopen_files); HDassert(nopen_objs); /* Find the top file in the mounting hierarchy */ while(f->mtab.parent) f = f->mtab.parent; /* Count open IDs in the hierarchy */ H5F_mount_count_ids_recurse(f, nopen_files, nopen_objs); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_mount_count_ids() */ xdmf-3.0+git20160803/Utilities/hdf5/H5Shyper.c0000640000175000017500000105366513003006557020526 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Quincey Koziol * Thursday, June 18, 1998 * * Purpose: Hyperslab selection data space I/O functions. */ #define H5S_PACKAGE /*suppress error about including H5Spkg */ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free Lists */ #include "H5Iprivate.h" /* ID Functions */ #include "H5Spkg.h" /* Dataspace functions */ #include "H5Vprivate.h" /* Vector functions */ /* Local datatypes */ /* Static function prototypes */ static herr_t H5S_hyper_free_span_info (H5S_hyper_span_info_t *span_info); static herr_t H5S_hyper_free_span (H5S_hyper_span_t *span); static H5S_hyper_span_info_t *H5S_hyper_copy_span (H5S_hyper_span_info_t *spans); static herr_t H5S_hyper_span_scratch (H5S_hyper_span_info_t *spans, void *scr_value); static herr_t H5S_hyper_span_precompute (H5S_hyper_span_info_t *spans, size_t elmt_size); static herr_t H5S_generate_hyperslab (H5S_t *space, H5S_seloper_t op, const hsize_t start[], const hsize_t stride[], const hsize_t count[], const hsize_t block[]); static herr_t H5S_hyper_generate_spans(H5S_t *space); /* Selection callbacks */ static herr_t H5S_hyper_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection); static herr_t H5S_hyper_get_seq_list(const H5S_t *space, unsigned flags, H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes, size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len); static herr_t H5S_hyper_release(H5S_t *space); static htri_t H5S_hyper_is_valid(const H5S_t *space); static hssize_t H5S_hyper_serial_size(const H5S_t *space); static herr_t H5S_hyper_serialize(const H5S_t *space, uint8_t *buf); static herr_t H5S_hyper_deserialize(H5S_t *space, const uint8_t *buf); static herr_t H5S_hyper_bounds(const H5S_t *space, hsize_t *start, hsize_t *end); static htri_t H5S_hyper_is_contiguous(const H5S_t *space); static htri_t H5S_hyper_is_single(const H5S_t *space); static htri_t H5S_hyper_is_regular(const H5S_t *space); static herr_t H5S_hyper_iter_init(H5S_sel_iter_t *iter, const H5S_t *space); /* Selection iteration callbacks */ static herr_t H5S_hyper_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords); static herr_t H5S_hyper_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end); static hsize_t H5S_hyper_iter_nelmts(const H5S_sel_iter_t *iter); static htri_t H5S_hyper_iter_has_next_block(const H5S_sel_iter_t *sel_iter); static herr_t H5S_hyper_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem); static herr_t H5S_hyper_iter_next_block(H5S_sel_iter_t *sel_iter); static herr_t H5S_hyper_iter_release(H5S_sel_iter_t *sel_iter); /* Selection properties for hyperslab selections */ const H5S_select_class_t H5S_sel_hyper[1] = {{ H5S_SEL_HYPERSLABS, /* Methods on selection */ H5S_hyper_copy, H5S_hyper_get_seq_list, H5S_hyper_release, H5S_hyper_is_valid, H5S_hyper_serial_size, H5S_hyper_serialize, H5S_hyper_deserialize, H5S_hyper_bounds, H5S_hyper_is_contiguous, H5S_hyper_is_single, H5S_hyper_is_regular, H5S_hyper_iter_init, }}; /* Iteration properties for hyperslab selections */ static const H5S_sel_iter_class_t H5S_sel_iter_hyper[1] = {{ H5S_SEL_HYPERSLABS, /* Methods on selection iterator */ H5S_hyper_iter_coords, H5S_hyper_iter_block, H5S_hyper_iter_nelmts, H5S_hyper_iter_has_next_block, H5S_hyper_iter_next, H5S_hyper_iter_next_block, H5S_hyper_iter_release, }}; /* Static variables */ /* Array for default stride, block, etc. */ static const hsize_t _ones[H5O_LAYOUT_NDIMS]={ 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1,1}; /* Declare a free list to manage the H5S_hyper_sel_t struct */ H5FL_DEFINE_STATIC(H5S_hyper_sel_t); /* Declare a free list to manage the H5S_hyper_span_t struct */ H5FL_DEFINE_STATIC(H5S_hyper_span_t); /* Declare a free list to manage the H5S_hyper_span_info_t struct */ H5FL_DEFINE_STATIC(H5S_hyper_span_info_t); /* #define H5S_HYPER_DEBUG */ #ifdef H5S_HYPER_DEBUG static herr_t H5S_hyper_print_spans_helper(FILE *f, struct H5S_hyper_span_t *span,unsigned depth) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_hyper_print_spans_helper); while(span) { HDfprintf(f,"%s: depth=%u, span=%p, (%d, %d), nelem=%u, pstride=%u\n",FUNC,depth,span,(int)span->low,(int)span->high,(unsigned)span->nelem,(unsigned)span->pstride); if(span->down && span->down->head) { HDfprintf(f,"%s: spans=%p, count=%u, scratch=%p, head=%p\n",FUNC,span->down,span->down->count,span->down->scratch,span->down->head); H5S_hyper_print_spans_helper(f,span->down->head,depth+1); } /* end if */ span=span->next; } /* end while */ FUNC_LEAVE_NOAPI(SUCCEED); } herr_t H5S_hyper_print_spans(FILE *f, const struct H5S_hyper_span_info_t *span_lst) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_hyper_print_spans); if(span_lst!=NULL) { HDfprintf(f,"%s: spans=%p, count=%u, scratch=%p, head=%p\n",FUNC,span_lst,span_lst->count,span_lst->scratch,span_lst->head); H5S_hyper_print_spans_helper(f,span_lst->head,0); } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED); } herr_t H5S_space_print_spans(FILE *f, const H5S_t *space) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_space_print_spans); H5S_hyper_print_spans(f,space->select.sel_info.hslab->span_lst); FUNC_LEAVE_NOAPI(SUCCEED); } static herr_t H5S_hyper_print_diminfo_helper(FILE *f, const char *field, unsigned ndims, const H5S_hyper_dim_t *dinfo) { unsigned u; /* Local index variable */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_hyper_print_diminfo_helper); if(dinfo!=NULL) { HDfprintf(f,"%s: %s: start=[",FUNC,field); for(u=0; uextent.rank,space->select.sel_info.hslab->opt_diminfo); H5S_hyper_print_diminfo_helper(f,"app_diminfo",space->extent.rank,space->select.sel_info.hslab->app_diminfo); FUNC_LEAVE_NOAPI(SUCCEED); } #endif /* H5S_HYPER_DEBUG */ /*------------------------------------------------------------------------- * Function: H5S_hyper_iter_init * * Purpose: Initializes iteration information for hyperslab span tree selection. * * Return: non-negative on success, negative on failure. * * Programmer: Quincey Koziol * Saturday, February 24, 2001 * * Notes: If the 'elmt_size' parameter is set to zero, the regular * hyperslab selection iterator will not be 'flattened'. This * is used by the H5S_select_shape_same() code to avoid changing * the rank and appearance of the selection. * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5S_hyper_iter_init(H5S_sel_iter_t *iter, const H5S_t *space) { const H5S_hyper_dim_t *tdiminfo; /* Temporary pointer to diminfo information */ H5S_hyper_span_info_t *spans; /* Pointer to hyperslab span info node */ unsigned rank; /* Dataspace's dimension rank */ unsigned u; /* Index variable */ int i; /* Index variable */ FUNC_ENTER_NOAPI_NOFUNC(H5S_hyper_iter_init); /* Check args */ assert(space && H5S_SEL_HYPERSLABS==H5S_GET_SELECT_TYPE(space)); assert(iter); /* Initialize the number of points to iterate over */ iter->elmt_left=space->select.num_elem; iter->u.hyp.iter_rank=0; /* Get the rank of the dataspace */ rank=space->extent.rank; /* Set the temporary pointer to the dimension information */ tdiminfo=space->select.sel_info.hslab->opt_diminfo; /* Check for the special case of just one H5Sselect_hyperslab call made */ if(space->select.sel_info.hslab->diminfo_valid) { /* Initialize the information needed for regular hyperslab I/O */ const hsize_t *mem_size; /* Temporary pointer to dataspace extent's dimension sizes */ hsize_t acc; /* Accumulator for "flattened" dimension's sizes */ unsigned cont_dim=0; /* # of contiguous dimensions */ /* Set the temporary pointer to the dataspace extent's dimension sizes */ mem_size=space->extent.size; /* * For a regular hyperslab to be contiguous up to some dimension, it * must have only one block (i.e. count==1 in all dimensions up to that * dimension) and the block size must be the same as the dataspace's * extent in that dimension and all dimensions up to that dimension. */ /* Don't flatten adjacent elements into contiguous block if the * element size is 0. This is for the H5S_select_shape_same() code. */ if(iter->elmt_size>0) { /* Check for any "contiguous" blocks that can be flattened */ for(u=rank-1; u>0; u--) { if(tdiminfo[u].count==1 && tdiminfo[u].block==mem_size[u]) cont_dim++; } /* end for */ } /* end if */ /* Check if the regular selection can be "flattened" */ if(cont_dim>0) { unsigned last_dim_flattened=1; /* Flag to indicate that the last dimension was flattened */ unsigned flat_rank=rank-cont_dim; /* Number of dimensions after flattening */ unsigned curr_dim; /* Current dimension */ /* Set the iterator's rank to the contiguous dimensions */ iter->u.hyp.iter_rank=flat_rank; /* "Flatten" dataspace extent and selection information */ curr_dim=flat_rank-1; for(i=rank-1, acc=1; i>=0; i--) { if(tdiminfo[i].block==mem_size[i] && i>0) { /* "Flatten" this dimension */ assert(tdiminfo[i].start==0); acc *= mem_size[i]; /* Indicate that the dimension was flattened */ last_dim_flattened=1; } /* end if */ else { if(last_dim_flattened) { /* First dimension after flattened dimensions */ iter->u.hyp.diminfo[curr_dim].start = tdiminfo[i].start*acc; /* Special case for single block regular selections */ if(tdiminfo[i].count==1) iter->u.hyp.diminfo[curr_dim].stride = 1; else iter->u.hyp.diminfo[curr_dim].stride = tdiminfo[i].stride*acc; iter->u.hyp.diminfo[curr_dim].count = tdiminfo[i].count; iter->u.hyp.diminfo[curr_dim].block = tdiminfo[i].block*acc; iter->u.hyp.size[curr_dim] = mem_size[i]*acc; iter->u.hyp.sel_off[curr_dim] = space->select.offset[i]*acc; /* Reset the "last dim flattened" flag to avoid flattened any further dimensions */ last_dim_flattened=0; /* Reset the "accumulator" for possible further dimension flattening */ acc=1; } /* end if */ else { /* All other dimensions */ iter->u.hyp.diminfo[curr_dim].start = tdiminfo[i].start; iter->u.hyp.diminfo[curr_dim].stride = tdiminfo[i].stride; iter->u.hyp.diminfo[curr_dim].count = tdiminfo[i].count; iter->u.hyp.diminfo[curr_dim].block = tdiminfo[i].block; iter->u.hyp.size[curr_dim] = mem_size[i]; iter->u.hyp.sel_off[curr_dim] = space->select.offset[i]; } /* end else */ /* Decrement "current" flattened dimension */ curr_dim--; } /* end if */ } /* end for */ /* Initialize "flattened" iterator offset to initial location and dataspace extent and selection information to correct values */ for(u=0; uu.hyp.off[u]=iter->u.hyp.diminfo[u].start; } /* end if */ else { /* Initialize position to initial location */ /* Also make local copy of the regular selection information */ for(u=0; uu.hyp.diminfo[u].start = tdiminfo[u].start; iter->u.hyp.diminfo[u].stride = tdiminfo[u].stride; iter->u.hyp.diminfo[u].count = tdiminfo[u].count; iter->u.hyp.diminfo[u].block = tdiminfo[u].block; /* Position information */ iter->u.hyp.off[u]=tdiminfo[u].start; } /* end if */ } /* end else */ /* Flag the diminfo information as valid in the iterator */ iter->u.hyp.diminfo_valid=TRUE; /* Initialize irregular region information also (for release) */ iter->u.hyp.spans=NULL; } /* end if */ else { /* Initialize the information needed for non-regular hyperslab I/O */ assert(space->select.sel_info.hslab->span_lst); /* Make a copy of the span tree to iterate over */ iter->u.hyp.spans=H5S_hyper_copy_span(space->select.sel_info.hslab->span_lst); /* Set the nelem & pstride values according to the element size */ H5S_hyper_span_precompute(iter->u.hyp.spans,iter->elmt_size); /* Initialize the starting span_info's and spans */ spans=iter->u.hyp.spans; for(u=0; uhead); /* Set the pointer to the first span in the list for this node */ iter->u.hyp.span[u] = spans->head; /* Set the initial offset to low bound of span */ iter->u.hyp.off[u]=iter->u.hyp.span[u]->low; /* Get the pointer to the next level down */ spans=spans->head->down; } /* end for */ /* Flag the diminfo information as not valid in the iterator */ iter->u.hyp.diminfo_valid=FALSE; } /* end else */ /* Initialize type of selection iterator */ iter->type=H5S_sel_iter_hyper; FUNC_LEAVE_NOAPI(SUCCEED); } /* H5S_hyper_iter_init() */ /*------------------------------------------------------------------------- * Function: H5S_hyper_iter_coords * * Purpose: Retrieve the current coordinates of iterator for current * selection * * Return: non-negative on success, negative on failure * * Programmer: Quincey Koziol * Tuesday, April 22, 2003 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5S_hyper_iter_coords (const H5S_sel_iter_t *iter, hsize_t *coords) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_hyper_iter_coords); /* Check args */ assert (iter); assert (coords); /* Copy the offset of the current point */ /* Check for a single "regular" hyperslab */ if(iter->u.hyp.diminfo_valid) { /* Check if this is a "flattened" regular hyperslab selection */ if(iter->u.hyp.iter_rank!=0 && iter->u.hyp.iter_rankrank) { unsigned flat_dim; /* The rank of the flattened dimension */ /* Get the rank of the flattened dimension */ flat_dim=iter->u.hyp.iter_rank-1; /* Copy the coordinates up to where things got flattened */ HDmemcpy(coords,iter->u.hyp.off,sizeof(hsize_t)*flat_dim); /* Compute the coordinates for the flattened dimensions */ H5V_array_calc(iter->u.hyp.off[flat_dim],iter->rank-flat_dim,&(iter->dims[flat_dim]),&(coords[flat_dim])); } /* end if */ else HDmemcpy(coords,iter->u.hyp.off,sizeof(hsize_t)*iter->rank); } /* end if */ else HDmemcpy(coords,iter->u.hyp.off,sizeof(hsize_t)*iter->rank); FUNC_LEAVE_NOAPI(SUCCEED); } /* H5S_hyper_iter_coords() */ /*------------------------------------------------------------------------- * Function: H5S_hyper_iter_block * * Purpose: Retrieve the current block of iterator for current * selection * * Return: non-negative on success, negative on failure * * Programmer: Quincey Koziol * Monday, June 2, 2003 * * Notes: This routine assumes that the iterator is always located at * the beginning of a block. * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5S_hyper_iter_block (const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end) { unsigned u; /* Local index variable */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_hyper_iter_block); /* Check args */ assert (iter); assert (start); assert (end); /* Copy the offset of the current point */ /* Check for a single "regular" hyperslab */ if(iter->u.hyp.diminfo_valid) { /* Compute the end of the block */ for(u=0; urank; u++) { start[u]=iter->u.hyp.off[u]; end[u]=(start[u]+iter->u.hyp.diminfo[u].block)-1; } /* end for */ } /* end if */ else { /* Copy the start of the block */ for(u=0; urank; u++) start[u]=iter->u.hyp.span[u]->low; /* Copy the end of the block */ for(u=0; urank; u++) end[u]=iter->u.hyp.span[u]->high; } /* end else */ FUNC_LEAVE_NOAPI(SUCCEED); } /* H5S_hyper_iter_block() */ /*------------------------------------------------------------------------- * Function: H5S_hyper_iter_nelmts * * Purpose: Return number of elements left to process in iterator * * Return: non-negative number of elements on success, zero on failure * * Programmer: Quincey Koziol * Tuesday, June 16, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static hsize_t H5S_hyper_iter_nelmts (const H5S_sel_iter_t *iter) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_hyper_iter_nelmts); /* Check args */ assert (iter); FUNC_LEAVE_NOAPI(iter->elmt_left); } /* H5S_hyper_iter_nelmts() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_iter_has_next_block PURPOSE Check if there is another block left in the current iterator USAGE htri_t H5S_hyper_iter_has_next_block(iter) const H5S_sel_iter_t *iter; IN: Pointer to selection iterator RETURNS Non-negative (TRUE/FALSE) on success/Negative on failure DESCRIPTION Check if there is another block available in the selection iterator. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static htri_t H5S_hyper_iter_has_next_block(const H5S_sel_iter_t *iter) { unsigned u; /* Local index variable */ herr_t ret_value=FALSE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_hyper_iter_has_next_block); /* Check args */ assert (iter); /* Check for a single "regular" hyperslab */ if(iter->u.hyp.diminfo_valid) { const H5S_hyper_dim_t *tdiminfo; /* Temporary pointer to diminfo information */ const hsize_t *toff; /* Temporary offset in selection */ /* Check if the offset of the iterator is at the last location in all dimensions */ tdiminfo=iter->u.hyp.diminfo; toff=iter->u.hyp.off; for(u=0; urank; u++) { /* If there is only one block, continue */ if(tdiminfo[u].count==1) continue; if(toff[u]!=(tdiminfo[u].start+((tdiminfo[u].count-1)*tdiminfo[u].stride))) HGOTO_DONE(TRUE); } /* end for */ } /* end if */ else { /* Check for any levels of the tree with more sequences in them */ for(u=0; urank; u++) if(iter->u.hyp.span[u]->next!=NULL) HGOTO_DONE(TRUE); } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_hyper_iter_has_next_block() */ /*------------------------------------------------------------------------- * Function: H5S_hyper_iter_next * * Purpose: Moves a hyperslab iterator to the beginning of the next sequence * of elements to read. Handles walking off the end in all dimensions. * * Return: Success: non-negative * Failure: negative * * Programmer: Quincey Koziol * Friday, September 8, 2000 * * Modifications: * Modified for both general and optimized hyperslab I/O * Quincey Koziol, April 17, 2003 * *------------------------------------------------------------------------- */ static herr_t H5S_hyper_iter_next(H5S_sel_iter_t *iter, size_t nelem) { unsigned ndims; /* Number of dimensions of dataset */ int fast_dim; /* Rank of the fastest changing dimension for the dataspace */ unsigned i; /* Counters */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_hyper_iter_next); /* Check for the special case of just one H5Sselect_hyperslab call made */ /* (i.e. a regular hyperslab selection */ if(iter->u.hyp.diminfo_valid) { const H5S_hyper_dim_t *tdiminfo; /* Temporary pointer to diminfo information */ hsize_t iter_offset[H5O_LAYOUT_NDIMS]; hsize_t iter_count[H5O_LAYOUT_NDIMS]; int temp_dim; /* Temporary rank holder */ /* Check if this is a "flattened" regular hyperslab selection */ if(iter->u.hyp.iter_rank!=0 && iter->u.hyp.iter_rankrank) { /* Set the aliases for the dimension rank */ ndims=iter->u.hyp.iter_rank; } /* end if */ else { /* Set the aliases for the dimension rank */ ndims=iter->rank; } /* end else */ /* Set the fastest dimension rank */ fast_dim=ndims-1; /* Set the local copy of the diminfo pointer */ tdiminfo=iter->u.hyp.diminfo; /* Calculate the offset and block count for each dimension */ for(i=0; iu.hyp.off[i]-tdiminfo[i].start; iter_count[i]=0; } /* end if */ else { iter_offset[i]=(iter->u.hyp.off[i]-tdiminfo[i].start)%tdiminfo[i].stride; iter_count[i]=(iter->u.hyp.off[i]-tdiminfo[i].start)/tdiminfo[i].stride; } /* end else */ } /* end for */ /* Loop through, advancing the offset & counts, until all the nelements are accounted for */ while(nelem>0) { /* Start with the fastest changing dimension */ temp_dim=fast_dim; while(temp_dim>=0) { if(temp_dim==fast_dim) { size_t actual_elem; /* Actual # of elements advanced on each iteration through loop */ hsize_t block_elem; /* Number of elements left in a block */ /* Compute the number of elements left in block */ block_elem=tdiminfo[temp_dim].block-iter_offset[temp_dim]; /* Compute the number of actual elements to advance */ actual_elem=(size_t)MIN(nelem,block_elem); /* Move the iterator over as many elements as possible */ iter_offset[temp_dim]+=actual_elem; /* Decrement the number of elements advanced */ nelem-=actual_elem; } /* end if */ else { /* Move to the next row in the current dimension */ iter_offset[temp_dim]++; } /* end else */ /* If this block is still in the range of blocks to output for the dimension, break out of loop */ if(iter_offset[temp_dim]u.hyp.off[i]=tdiminfo[i].start+(tdiminfo[i].stride*iter_count[i])+iter_offset[i]; } /* end if */ /* Must be an irregular hyperslab selection */ else { H5S_hyper_span_t *curr_span; /* Current hyperslab span node */ H5S_hyper_span_t **ispan; /* Iterator's hyperslab span nodes */ hsize_t *abs_arr; /* Absolute hyperslab span position */ int curr_dim; /* Temporary rank holder */ /* Set the rank of the fastest changing dimension */ ndims=iter->rank; fast_dim=(ndims-1); /* Get the pointers to the current span info and span nodes */ abs_arr=iter->u.hyp.off; ispan=iter->u.hyp.span; /* Loop through, advancing the span information, until all the nelements are accounted for */ while(nelem>0) { /* Start at the fastest dim */ curr_dim=fast_dim; /* Work back up through the dimensions */ while(curr_dim>=0) { /* Reset the current span */ curr_span=ispan[curr_dim]; /* Increment absolute position */ if(curr_dim==fast_dim) { size_t actual_elem; /* Actual # of elements advanced on each iteration through loop */ hsize_t span_elem; /* Number of elements left in a span */ /* Compute the number of elements left in block */ span_elem=(curr_span->high-abs_arr[curr_dim])+1; /* Compute the number of actual elements to advance */ actual_elem=(size_t)MIN(nelem,span_elem); /* Move the iterator over as many elements as possible */ abs_arr[curr_dim]+=actual_elem; /* Decrement the number of elements advanced */ nelem-=actual_elem; } /* end if */ else { /* Move to the next row in the current dimension */ abs_arr[curr_dim]++; } /* end else */ /* Check if we are still within the span */ if(abs_arr[curr_dim]<=curr_span->high) { break; } /* end if */ /* If we walked off that span, advance to the next span */ else { /* Advance span in this dimension */ curr_span=curr_span->next; /* Check if we have a valid span in this dimension still */ if(curr_span!=NULL) { /* Reset the span in the current dimension */ ispan[curr_dim]=curr_span; /* Reset absolute position */ abs_arr[curr_dim]=curr_span->low; break; } /* end if */ else { /* If we finished the span list in this dimension, decrement the dimension worked on and loop again */ curr_dim--; } /* end else */ } /* end else */ } /* end while */ /* Check if we are finished with the spans in the tree */ if(curr_dim>=0) { /* Walk back down the iterator positions, reseting them */ while(curr_dimdown); assert(curr_span->down->head); /* Increment current dimension */ curr_dim++; /* Set the new span_info & span for this dimension */ ispan[curr_dim]=curr_span->down->head; /* Advance span down the tree */ curr_span=curr_span->down->head; /* Reset the absolute offset for the dim */ abs_arr[curr_dim]=curr_span->low; } /* end while */ /* Verify that the curr_span points to the fastest dim */ assert(curr_span==ispan[fast_dim]); } /* end if */ } /* end while */ } /* end else */ FUNC_LEAVE_NOAPI(SUCCEED); } /* H5S_hyper_iter_next() */ /*------------------------------------------------------------------------- * Function: H5S_hyper_iter_next_block * * Purpose: Moves a hyperslab iterator to the beginning of the next sequence * of elements to read. Handles walking off the end in all dimensions. * * Return: Success: non-negative * Failure: negative * * Programmer: Quincey Koziol * Tuesday, June 3, 2003 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5S_hyper_iter_next_block(H5S_sel_iter_t *iter) { unsigned ndims; /* Number of dimensions of dataset */ int fast_dim; /* Rank of the fastest changing dimension for the dataspace */ unsigned u; /* Counters */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_hyper_iter_next_block); /* Check for the special case of just one H5Sselect_hyperslab call made */ /* (i.e. a regular hyperslab selection */ if(iter->u.hyp.diminfo_valid) { const H5S_hyper_dim_t *tdiminfo; /* Temporary pointer to diminfo information */ hsize_t iter_offset[H5O_LAYOUT_NDIMS]; hsize_t iter_count[H5O_LAYOUT_NDIMS]; int temp_dim; /* Temporary rank holder */ /* Check if this is a "flattened" regular hyperslab selection */ if(iter->u.hyp.iter_rank!=0 && iter->u.hyp.iter_rankrank) { /* Set the aliases for the dimension rank */ ndims=iter->u.hyp.iter_rank; } /* end if */ else { /* Set the aliases for the dimension rank */ ndims=iter->rank; } /* end else */ /* Set the fastest dimension rank */ fast_dim=ndims-1; /* Set the local copy of the diminfo pointer */ tdiminfo=iter->u.hyp.diminfo; /* Calculate the offset and block count for each dimension */ for(u=0; uu.hyp.off[u]-tdiminfo[u].start; iter_count[u]=0; } /* end if */ else { iter_offset[u]=(iter->u.hyp.off[u]-tdiminfo[u].start)%tdiminfo[u].stride; iter_count[u]=(iter->u.hyp.off[u]-tdiminfo[u].start)/tdiminfo[u].stride; } /* end else */ } /* end for */ /* Advance one block */ temp_dim=fast_dim; /* Start with the fastest changing dimension */ while(temp_dim>=0) { if(temp_dim==fast_dim) { /* Move iterator over current block */ iter_offset[temp_dim]+=tdiminfo[temp_dim].block; } /* end if */ else { /* Move to the next row in the current dimension */ iter_offset[temp_dim]++; } /* end else */ /* If this block is still in the range of blocks to output for the dimension, break out of loop */ if(iter_offset[temp_dim]u.hyp.off[u]=tdiminfo[u].start+(tdiminfo[u].stride*iter_count[u])+iter_offset[u]; } /* end if */ /* Must be an irregular hyperslab selection */ else { H5S_hyper_span_t *curr_span; /* Current hyperslab span node */ H5S_hyper_span_t **ispan; /* Iterator's hyperslab span nodes */ hsize_t *abs_arr; /* Absolute hyperslab span position */ int curr_dim; /* Temporary rank holder */ /* Set the rank of the fastest changing dimension */ ndims=iter->rank; fast_dim=(ndims-1); /* Get the pointers to the current span info and span nodes */ abs_arr=iter->u.hyp.off; ispan=iter->u.hyp.span; /* Loop through, advancing the span information, until all the nelements are accounted for */ curr_dim=fast_dim; /* Start at the fastest dim */ /* Work back up through the dimensions */ while(curr_dim>=0) { /* Reset the current span */ curr_span=ispan[curr_dim]; /* Increment absolute position */ if(curr_dim==fast_dim) { /* Move the iterator over rest of element in span */ abs_arr[curr_dim]=curr_span->high+1; } /* end if */ else { /* Move to the next row in the current dimension */ abs_arr[curr_dim]++; } /* end else */ /* Check if we are still within the span */ if(abs_arr[curr_dim]<=curr_span->high) { break; } /* end if */ /* If we walked off that span, advance to the next span */ else { /* Advance span in this dimension */ curr_span=curr_span->next; /* Check if we have a valid span in this dimension still */ if(curr_span!=NULL) { /* Reset the span in the current dimension */ ispan[curr_dim]=curr_span; /* Reset absolute position */ abs_arr[curr_dim]=curr_span->low; break; } /* end if */ else { /* If we finished the span list in this dimension, decrement the dimension worked on and loop again */ curr_dim--; } /* end else */ } /* end else */ } /* end while */ /* Check if we are finished with the spans in the tree */ if(curr_dim>=0) { /* Walk back down the iterator positions, reseting them */ while(curr_dimdown); assert(curr_span->down->head); /* Increment current dimension */ curr_dim++; /* Set the new span_info & span for this dimension */ ispan[curr_dim]=curr_span->down->head; /* Advance span down the tree */ curr_span=curr_span->down->head; /* Reset the absolute offset for the dim */ abs_arr[curr_dim]=curr_span->low; } /* end while */ /* Verify that the curr_span points to the fastest dim */ assert(curr_span==ispan[fast_dim]); } /* end if */ } /* end else */ FUNC_LEAVE_NOAPI(SUCCEED); } /* H5S_hyper_iter_next() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_iter_release PURPOSE Release hyperslab selection iterator information for a dataspace USAGE herr_t H5S_hyper_iter_release(iter) H5S_sel_iter_t *iter; IN: Pointer to selection iterator RETURNS Non-negative on success/Negative on failure DESCRIPTION Releases all information for a dataspace hyperslab selection iterator GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_hyper_iter_release (H5S_sel_iter_t *iter) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_hyper_iter_release); /* Check args */ assert (iter); /* Release the information needed for non-regular hyperslab I/O */ /* Free the copy of the selections span tree */ if(iter->u.hyp.spans!=NULL) H5S_hyper_free_span_info(iter->u.hyp.spans); FUNC_LEAVE_NOAPI(SUCCEED); } /* H5S_hyper_iter_release() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_new_span PURPOSE Make a new hyperslab span node USAGE H5S_hyper_span_t *H5S_hyper_new_span(low, high, down, next) hsize_t low, high; IN: Low and high bounds for new span node H5S_hyper_span_info_t *down; IN: Down span tree for new node H5S_hyper_span_t *next; IN: Next span for new node RETURNS Pointer to next span node on success, NULL on failure DESCRIPTION Allocate and initialize a new hyperslab span node, filling in the low & high bounds, the down span and next span pointers also. Increment the reference count of the 'down span' if applicable. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static H5S_hyper_span_t * H5S_hyper_new_span (hsize_t low, hsize_t high, H5S_hyper_span_info_t *down, H5S_hyper_span_t *next) { H5S_hyper_span_t *ret_value; FUNC_ENTER_NOAPI_NOINIT(H5S_hyper_new_span); /* Allocate a new span node */ if((ret_value = H5FL_MALLOC(H5S_hyper_span_t))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate hyperslab span"); /* Copy the span's basic information */ ret_value->low=low; ret_value->high=high; ret_value->nelem=(high-low)+1; ret_value->pstride=0; ret_value->down=down; ret_value->next=next; /* Increment the reference count of the 'down span' if there is one */ if(ret_value->down!=NULL) ret_value->down->count++; done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_hyper_new_span() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_span_precompute_helper PURPOSE Helper routine to precompute the nelem and pstrides in bytes. USAGE herr_t H5S_hyper_span_precompute_helper(span_info, elmt_size) H5S_hyper_span_info_t *span_info; IN/OUT: Span tree to work on size_t elmt_size; IN: element size to work with RETURNS Non-negative on success, negative on failure DESCRIPTION Change the nelem and pstride values in the span tree from elements to bytes using the elmt_size parameter. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_hyper_span_precompute_helper (H5S_hyper_span_info_t *spans, size_t elmt_size) { H5S_hyper_span_t *span; /* Hyperslab span */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5S_hyper_span_precompute_helper); assert(spans); /* Check if we've already set this down span tree */ if(spans->scratch!=(H5S_hyper_span_info_t *)~((size_t)NULL)) { /* Set the tree's scratch pointer */ spans->scratch=(H5S_hyper_span_info_t *)~((size_t)NULL); /* Set the scratch pointers in all the nodes */ span=spans->head; /* Loop over all the spans for this down span tree */ while(span!=NULL) { /* If there are down spans, set their scratch value also */ if(span->down!=NULL) { if(H5S_hyper_span_precompute_helper(span->down,elmt_size)==FAIL) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "can't reset hyperslab scratch pointer"); } /* end if */ /* Change the nelem & pstride values into bytes */ span->nelem *= elmt_size; span->pstride *= elmt_size; /* Advance to next span */ span=span->next; } /* end while */ } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_hyper_span_precompute_helper() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_span_precompute PURPOSE Precompute the nelem and pstrides in bytes. USAGE herr_t H5S_hyper_span_precompute(span_info, elmt_size) H5S_hyper_span_info_t *span_info; IN/OUT: Span tree to work on size_t elmt_size; IN: element size to work with RETURNS Non-negative on success, negative on failure DESCRIPTION Change the nelem and pstride values in the span tree from elements to bytes using the elmt_size parameter. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_hyper_span_precompute (H5S_hyper_span_info_t *spans, size_t elmt_size) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5S_hyper_span_precompute); assert(spans); /* Call the helper routine to actually do the work */ if(H5S_hyper_span_precompute_helper(spans,elmt_size)==FAIL) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "can't precompute span info"); /* Reset the scratch pointers for the next routine which needs them */ if(H5S_hyper_span_scratch(spans,NULL)==FAIL) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "can't reset hyperslab scratch pointer"); done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_hyper_span_precompute() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_span_scratch PURPOSE Set the scratch pointers on hyperslab span trees USAGE herr_t H5S_hyper_span_scratch(span_info) H5S_hyper_span_info_t *span_info; IN: Span tree to reset RETURNS Non-negative on success, negative on failure DESCRIPTION Set the scratch pointers on a hyperslab span tree. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_hyper_span_scratch (H5S_hyper_span_info_t *spans, void *scr_value) { H5S_hyper_span_t *span; /* Hyperslab span */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5S_hyper_span_scratch); assert(spans); /* Check if we've already set this down span tree */ if(spans->scratch!=scr_value) { /* Set the tree's scratch pointer */ spans->scratch=scr_value; /* Set the scratch pointers in all the nodes */ span=spans->head; while(span!=NULL) { /* If there are down spans, set their scratch value also */ if(span->down!=NULL) { if(H5S_hyper_span_scratch(span->down,scr_value)==FAIL) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "can't reset hyperslab scratch pointer"); } /* end if */ /* Advance to next span */ span=span->next; } /* end while */ } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_hyper_span_scratch() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_copy_span_helper PURPOSE Helper routine to copy a hyperslab span tree USAGE H5S_hyper_span_info_t * H5S_hyper_copy_span_helper(spans) H5S_hyper_span_info_t *spans; IN: Span tree to copy RETURNS Pointer to the copied span tree on success, NULL on failure DESCRIPTION Copy a hyperslab span tree, using reference counting as appropriate. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static H5S_hyper_span_info_t * H5S_hyper_copy_span_helper (H5S_hyper_span_info_t *spans) { H5S_hyper_span_t *span; /* Hyperslab span */ H5S_hyper_span_t *new_span; /* Temporary hyperslab span */ H5S_hyper_span_t *prev_span; /* Previous hyperslab span */ H5S_hyper_span_info_t *new_down; /* New down span tree */ H5S_hyper_span_info_t *ret_value; FUNC_ENTER_NOAPI_NOINIT(H5S_hyper_copy_span_helper); assert(spans); /* Check if the span tree was already copied */ if(spans->scratch!=NULL && spans->scratch!=(H5S_hyper_span_info_t *)~((size_t)NULL)) { /* Just return the value of the already copied span tree */ ret_value=spans->scratch; /* Increment the reference count of the span tree */ ret_value->count++; } /* end if */ else { /* Allocate a new span_info node */ if((ret_value = H5FL_MALLOC(H5S_hyper_span_info_t))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate hyperslab span"); /* Copy the span_info information */ ret_value->count=1; ret_value->scratch=NULL; ret_value->head=NULL; /* Set the scratch pointer in the node being copied to the newly allocated node */ spans->scratch=ret_value; /* Copy over the nodes in the span list */ span=spans->head; prev_span=NULL; while(span!=NULL) { /* Allocate a new node */ if((new_span = H5S_hyper_new_span(span->low,span->high,NULL,NULL))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate hyperslab span"); /* Append to list of spans */ if(prev_span==NULL) ret_value->head=new_span; else prev_span->next=new_span; /* Copy the pstride */ new_span->pstride=span->pstride; /* Recurse to copy the 'down' spans, if there are any */ if(span->down!=NULL) { if((new_down = H5S_hyper_copy_span_helper(span->down))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate hyperslab span"); new_span->down=new_down; } /* end if */ /* Update the previous (new) span */ prev_span=new_span; /* Advance to next span */ span=span->next; } /* end while */ } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_hyper_copy_span_helper() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_copy_span PURPOSE Copy a hyperslab span tree USAGE H5S_hyper_span_info_t * H5S_hyper_copy_span(span_info) H5S_hyper_span_info_t *span_info; IN: Span tree to copy RETURNS Non-negative on success, negative on failure DESCRIPTION Copy a hyperslab span tree, using reference counting as appropriate. (Which means that just the nodes in the top span tree are duplicated and the reference counts of their 'down spans' are just incremented) GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static H5S_hyper_span_info_t * H5S_hyper_copy_span (H5S_hyper_span_info_t *spans) { H5S_hyper_span_info_t *ret_value; FUNC_ENTER_NOAPI_NOINIT(H5S_hyper_copy_span); assert(spans); /* Copy the hyperslab span tree */ ret_value=H5S_hyper_copy_span_helper(spans); /* Reset the scratch pointers for the next routine which needs them */ if(H5S_hyper_span_scratch(spans,NULL)==FAIL) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTFREE, NULL, "can't reset span tree scratch pointers"); done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_hyper_copy_span() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_cmp_spans PURPOSE Check if two hyperslab slabs are the same USAGE htri_d H5S_hyper_cmp_spans(span1, span2) H5S_hyper_span_t *span1; IN: First span tree to compare H5S_hyper_span_t *span2; IN: Second span tree to compare RETURNS TRUE (1) or FALSE (0) on success, negative on failure DESCRIPTION Compare two hyperslab slabs to determine if they refer to the same selection. If span1 & span2 are both NULL, that counts as equal GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static htri_t H5S_hyper_cmp_spans (H5S_hyper_span_info_t *span_info1, H5S_hyper_span_info_t *span_info2) { H5S_hyper_span_t *span1; H5S_hyper_span_t *span2; htri_t nest=FAIL; htri_t ret_value=FAIL; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_hyper_cmp_spans); /* Check for redundant comparison */ if(span_info1==span_info2) ret_value=TRUE; else { /* Check for both spans being NULL */ if(span_info1==NULL && span_info2==NULL) ret_value=TRUE; else { /* Check for one span being NULL */ if(span_info1==NULL || span_info2==NULL) ret_value=FALSE; else { /* Get the pointers to the actual lists of spans */ span1=span_info1->head; span2=span_info2->head; /* Sanity checking */ assert(span1); assert(span2); /* infinite loop which must be broken out of */ while (1) { /* Check for both spans being NULL */ if(span1==NULL && span2==NULL) { ret_value=TRUE; break; } /* end if */ else { /* Check for one span being NULL */ if(span1==NULL || span2==NULL) { ret_value=FALSE; break; } /* end if */ else { /* Check if the actual low & high span information is the same */ if(span1->low!=span2->low || span1->high!=span2->high) { ret_value=FALSE; break; } /* end if */ else { if(span1->down!=NULL || span2!=NULL) { if((nest=H5S_hyper_cmp_spans(span1->down,span2->down))==FAIL) { ret_value=FAIL; break; } /* end if */ else { if(nest==FALSE) { ret_value=FALSE; break; } /* end if */ else { /* Keep going... */ } /* end else */ } /* end else */ } /* end if */ else { /* Keep going... */ } /* end else */ } /* end else */ } /* end else */ } /* end else */ /* Advance to the next nodes in the span list */ span1=span1->next; span2=span2->next; } /* end while */ } /* end else */ } /* end else */ } /* end else */ FUNC_LEAVE_NOAPI(ret_value); } /* H5S_hyper_cmp_spans() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_free_span_info PURPOSE Free a hyperslab span info node USAGE herr_t H5S_hyper_free_span_info(span_info) H5S_hyper_span_info_t *span_info; IN: Span info node to free RETURNS Non-negative on success, negative on failure DESCRIPTION Free a hyperslab span info node, along with all the span nodes and the 'down spans' from the nodes, if reducing their reference count to zero indicates it is appropriate to do so. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_hyper_free_span_info (H5S_hyper_span_info_t *span_info) { H5S_hyper_span_t *span, *next_span; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5S_hyper_free_span_info); assert(span_info); /* Decrement the span tree's reference count */ span_info->count--; /* Free the span tree if the reference count drops to zero */ if(span_info->count==0) { /* Work through the list of spans pointed to by this 'info' node */ span=span_info->head; while(span!=NULL) { next_span=span->next; if(H5S_hyper_free_span(span)<0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "failed to release hyperslab span"); span=next_span; } /* end while */ /* Free this span info */ H5FL_FREE(H5S_hyper_span_info_t,span_info); } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_hyper_free_span_info() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_free_span PURPOSE Free a hyperslab span node USAGE herr_t H5S_hyper_free_span(span) H5S_hyper_span_t *span; IN: Span node to free RETURNS Non-negative on success, negative on failure DESCRIPTION Free a hyperslab span node, along with the 'down spans' from the node, if reducing their reference count to zero indicates it is appropriate to do so. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_hyper_free_span (H5S_hyper_span_t *span) { herr_t ret_value=SUCCEED; FUNC_ENTER_NOAPI_NOINIT(H5S_hyper_free_span); assert(span); /* Decrement the reference count of the 'down spans', freeing them if appropriate */ if(span->down!=NULL) { if(H5S_hyper_free_span_info(span->down)<0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "failed to release hyperslab span tree"); } /* end if */ /* Free this span */ H5FL_FREE(H5S_hyper_span_t,span); done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_hyper_free_span() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_copy PURPOSE Copy a selection from one dataspace to another USAGE herr_t H5S_hyper_copy(dst, src) H5S_t *dst; OUT: Pointer to the destination dataspace H5S_t *src; IN: Pointer to the source dataspace RETURNS Non-negative on success/Negative on failure DESCRIPTION Copies all the hyperslab selection information from the source dataspace to the destination dataspace. If the SHARE_SELECTION flag is set, then the selection can be shared between the source and destination dataspaces. (This should only occur in situations where the destination dataspace will immediately change to a new selection) GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5S_hyper_copy (H5S_t *dst, const H5S_t *src, hbool_t share_selection) { H5S_hyper_sel_t *dst_hslab; /* Pointer to destination hyperslab info */ const H5S_hyper_sel_t *src_hslab; /* Pointer to source hyperslab info */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_NOAPI(H5S_hyper_copy, FAIL); assert(src); assert(dst); /* Allocate space for the hyperslab selection information */ if((dst->select.sel_info.hslab=H5FL_MALLOC(H5S_hyper_sel_t))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab info"); /* Set temporary pointers */ dst_hslab=dst->select.sel_info.hslab; src_hslab=src->select.sel_info.hslab; /* Copy the hyperslab information */ dst_hslab->diminfo_valid=src_hslab->diminfo_valid; if(src_hslab->diminfo_valid) { size_t u; /* Local index variable */ for(u=0; uextent.rank; u++) { dst_hslab->opt_diminfo[u]=src_hslab->opt_diminfo[u]; dst_hslab->app_diminfo[u]=src_hslab->app_diminfo[u]; } /* end for */ } /* end if */ dst->select.sel_info.hslab->span_lst=src->select.sel_info.hslab->span_lst; /* Check if there is hyperslab span information to copy */ /* (Regular hyperslab information is copied with the selection structure) */ if(src->select.sel_info.hslab->span_lst!=NULL) { if(share_selection) { /* Share the source's span tree by incrementing the reference count on it */ dst->select.sel_info.hslab->span_lst->count++; } /* end if */ else /* Copy the hyperslab span information */ dst->select.sel_info.hslab->span_lst=H5S_hyper_copy_span(src->select.sel_info.hslab->span_lst); } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5S_hyper_copy() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_is_valid_helper PURPOSE Check whether the selection fits within the extent, with the current offset defined. USAGE htri_t H5S_hyper_is_valid_helper(spans, offset, rank); const H5S_hyper_span_info_t *spans; IN: Pointer to current hyperslab span tree const hssize_t *offset; IN: Pointer to offset array const hsize_t *size; IN: Pointer to size array hsize_t rank; IN: Current rank looking at RETURNS TRUE if the selection fits within the extent, FALSE if it does not and Negative on an error. DESCRIPTION Determines if the current selection at the current offet fits within the extent for the dataspace. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static htri_t H5S_hyper_is_valid_helper (const H5S_hyper_span_info_t *spans, const hssize_t *offset, const hsize_t *size, hsize_t rank) { H5S_hyper_span_t *curr; /* Hyperslab information nodes */ htri_t tmp; /* temporary return value */ htri_t ret_value=TRUE; /* return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_hyper_is_valid_helper); assert(spans); assert(offset); assert(size); assert(rankhead; while(curr!=NULL && ret_value==TRUE) { /* Check if an offset has been defined */ /* Bounds check the selected point + offset against the extent */ if((((hssize_t)curr->low+offset[rank])>=(hssize_t)size[rank]) || (((hssize_t)curr->low+offset[rank])<0) || (((hssize_t)curr->high+offset[rank])>=(hssize_t)size[rank]) || (((hssize_t)curr->high+offset[rank])<0)) { ret_value=FALSE; break; } /* end if */ /* Recurse if this node has down spans */ if(curr->down!=NULL) { if((tmp=H5S_hyper_is_valid_helper(curr->down,offset,size,rank+1))!=TRUE) { ret_value=tmp; break; } /* end if */ } /* end if */ /* Advance to next node */ curr=curr->next; } /* end while */ FUNC_LEAVE_NOAPI(ret_value); } /* end H5S_hyper_is_valid_helper() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_is_valid PURPOSE Check whether the selection fits within the extent, with the current offset defined. USAGE htri_t H5S_hyper_is_valid(space); H5S_t *space; IN: Dataspace pointer to query RETURNS TRUE if the selection fits within the extent, FALSE if it does not and Negative on an error. DESCRIPTION Determines if the current selection at the current offet fits within the extent for the dataspace. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ htri_t H5S_hyper_is_valid (const H5S_t *space) { unsigned u; /* Counter */ htri_t ret_value=TRUE; /* return value */ FUNC_ENTER_NOAPI_NOFUNC(H5S_hyper_is_valid); assert(space); /* Check for a "regular" hyperslab selection */ if(space->select.sel_info.hslab->diminfo_valid) { const H5S_hyper_dim_t *diminfo=space->select.sel_info.hslab->opt_diminfo; /* local alias for diminfo */ hssize_t end; /* The high bound of a region in a dimension */ /* Check each dimension */ for(u=0; uextent.rank; u++) { /* if block or count is zero, then can skip the test since */ /* no data point is chosen */ if (diminfo[u].count && diminfo[u].block) { /* Bounds check the start point in this dimension */ if(((hssize_t)diminfo[u].start+space->select.offset[u])<0 || ((hssize_t)diminfo[u].start+space->select.offset[u])>=(hssize_t)space->extent.size[u]) HGOTO_DONE(FALSE) /* Compute the largest location in this dimension */ end=(hssize_t)(diminfo[u].start+diminfo[u].stride*(diminfo[u].count-1)+(diminfo[u].block-1))+space->select.offset[u]; /* Bounds check the end point in this dimension */ if(end<0 || end>=(hssize_t)space->extent.size[u]) HGOTO_DONE(FALSE) } /* end if */ } /* end for */ } /* end if */ else { /* Call the recursive routine to validate the span tree */ ret_value=H5S_hyper_is_valid_helper(space->select.sel_info.hslab->span_lst,space->select.offset,space->extent.size,(hsize_t)0); } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5S_hyper_is_valid() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_span_nblocks PURPOSE Count the number of blocks in a span tree USAGE hssize_t H5S_hyper_span_nblocks(spans) const H5S_hyper_span_info_t *spans; IN: Hyperslab span tree to count elements of RETURNS Number of blocks in span tree on success; negative on failure DESCRIPTION Counts the number of blocks described by the spans in a span tree. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static hssize_t H5S_hyper_span_nblocks (H5S_hyper_span_info_t *spans) { H5S_hyper_span_t *span; /* Hyperslab span */ hssize_t ret_value; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_hyper_span_nblocks); /* Count the number of elements in the span tree */ if(spans==NULL) ret_value=0; else { span=spans->head; ret_value=0; while(span!=NULL) { /* If there are down spans, add the total down span blocks */ if(span->down!=NULL) ret_value+=H5S_hyper_span_nblocks(span->down); /* If there are no down spans, just count the block in this span */ else ret_value++; /* Advance to next span */ span=span->next; } /* end while */ } /* end else */ FUNC_LEAVE_NOAPI(ret_value); } /* H5S_hyper_span_nblocks() */ /*-------------------------------------------------------------------------- NAME H5S_get_select_hyper_nblocks PURPOSE Get the number of hyperslab blocks in current hyperslab selection USAGE hssize_t H5S_get_select_hyper_nblocks(space) H5S_t *space; IN: Dataspace ptr of selection to query RETURNS The number of hyperslab blocks in selection on success, negative on failure DESCRIPTION Returns the number of hyperslab blocks in current selection for dataspace. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static hssize_t H5S_get_select_hyper_nblocks(H5S_t *space) { hssize_t ret_value; /* return value */ unsigned u; /* Counter */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_get_select_hyper_nblocks); assert(space); /* Check for a "regular" hyperslab selection */ if(space->select.sel_info.hslab->diminfo_valid) { /* Check each dimension */ for(ret_value=1,u=0; uextent.rank; u++) ret_value*=space->select.sel_info.hslab->app_diminfo[u].count; } /* end if */ else ret_value = H5S_hyper_span_nblocks(space->select.sel_info.hslab->span_lst); FUNC_LEAVE_NOAPI(ret_value); } /* H5S_get_select_hyper_nblocks() */ /*-------------------------------------------------------------------------- NAME H5Sget_select_hyper_nblocks PURPOSE Get the number of hyperslab blocks in current hyperslab selection USAGE hssize_t H5Sget_select_hyper_nblocks(dsid) hid_t dsid; IN: Dataspace ID of selection to query RETURNS The number of hyperslab blocks in selection on success, negative on failure DESCRIPTION Returns the number of hyperslab blocks in current selection for dataspace. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ hssize_t H5Sget_select_hyper_nblocks(hid_t spaceid) { H5S_t *space = NULL; /* Dataspace to modify selection of */ hssize_t ret_value; /* return value */ FUNC_ENTER_API(H5Sget_select_hyper_nblocks, FAIL); H5TRACE1("Hs","i",spaceid); /* Check args */ if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); if(H5S_GET_SELECT_TYPE(space)!=H5S_SEL_HYPERSLABS) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a hyperslab selection"); ret_value = H5S_get_select_hyper_nblocks(space); done: FUNC_LEAVE_API(ret_value); } /* H5Sget_select_hyper_nblocks() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_serial_size PURPOSE Determine the number of bytes needed to store the serialized hyperslab selection information. USAGE hssize_t H5S_hyper_serial_size(space) H5S_t *space; IN: Dataspace pointer to query RETURNS The number of bytes required on success, negative on an error. DESCRIPTION Determines the number of bytes required to serialize the current hyperslab selection information for storage on disk. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ hssize_t H5S_hyper_serial_size (const H5S_t *space) { unsigned u; /* Counter */ hssize_t block_count; /* block counter for regular hyperslabs */ hssize_t ret_value; /* return value */ FUNC_ENTER_NOAPI_NOFUNC(H5S_hyper_serial_size); assert(space); /* Basic number of bytes required to serialize hyperslab selection: * + + + * + + <# of blocks (4 bytes)> = 24 bytes */ ret_value=24; /* Check for a "regular" hyperslab selection */ if(space->select.sel_info.hslab->diminfo_valid) { /* Check each dimension */ for(block_count=1,u=0; uextent.rank; u++) block_count*=space->select.sel_info.hslab->opt_diminfo[u].count; ret_value+=8*block_count*space->extent.rank; } /* end if */ else { /* Spin through hyperslab spans, adding 8 * rank bytes for each block */ block_count=H5S_hyper_span_nblocks(space->select.sel_info.hslab->span_lst); ret_value+=8*space->extent.rank*block_count; } /* end else */ FUNC_LEAVE_NOAPI(ret_value); } /* end H5S_hyper_serial_size() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_serialize_helper PURPOSE Serialize the current selection into a user-provided buffer. USAGE herr_t H5S_hyper_serialize_helper(spans, start, end, rank, buf) H5S_hyper_span_info_t *spans; IN: Hyperslab span tree to serialize hssize_t start[]; IN/OUT: Accumulated start points hssize_t end[]; IN/OUT: Accumulated end points hsize_t rank; IN: Current rank looking at uint8 *buf; OUT: Buffer to put serialized selection into RETURNS Non-negative on success/Negative on failure DESCRIPTION Serializes the current element selection into a buffer. (Primarily for storing on disk). GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_hyper_serialize_helper (const H5S_hyper_span_info_t *spans, hsize_t *start, hsize_t *end, hsize_t rank, uint8_t **buf) { H5S_hyper_span_t *curr; /* Pointer to current hyperslab span */ hsize_t u; /* Index variable */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_NOAPI_NOINIT(H5S_hyper_serialize_helper); /* Sanity checks */ assert(spans); assert(start); assert(end); assert(rankhead; while(curr!=NULL) { /* Recurse if this node has down spans */ if(curr->down!=NULL) { /* Add the starting and ending points for this span to the list */ start[rank]=curr->low; end[rank]=curr->high; /* Recurse down to the next dimension */ if(H5S_hyper_serialize_helper(curr->down,start,end,rank+1,buf)<0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "failed to release hyperslab spans"); } /* end if */ else { /* Encode all the previous dimensions starting & ending points */ /* Encode previous starting points */ for(u=0; ulow); /* Encode previous ending points */ for(u=0; uhigh); } /* end else */ /* Advance to next node */ curr=curr->next; } /* end while */ done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_hyper_serialize_helper() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_serialize PURPOSE Serialize the current selection into a user-provided buffer. USAGE herr_t H5S_hyper_serialize(space, buf) H5S_t *space; IN: Dataspace pointer of selection to serialize uint8 *buf; OUT: Buffer to put serialized selection into RETURNS Non-negative on success/Negative on failure DESCRIPTION Serializes the current element selection into a buffer. (Primarily for storing on disk). GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5S_hyper_serialize (const H5S_t *space, uint8_t *buf) { const H5S_hyper_dim_t *diminfo; /* Alias for dataspace's diminfo information */ hsize_t tmp_count[H5O_LAYOUT_NDIMS]; /* Temporary hyperslab counts */ hsize_t offset[H5O_LAYOUT_NDIMS]; /* Offset of element in dataspace */ hsize_t start[H5O_LAYOUT_NDIMS]; /* Location of start of hyperslab */ hsize_t end[H5O_LAYOUT_NDIMS]; /* Location of end of hyperslab */ hsize_t temp_off; /* Offset in a given dimension */ uint8_t *lenp; /* pointer to length location for later storage */ uint32_t len=0; /* number of bytes used */ int i; /* local counting variable */ hssize_t block_count; /* block counter for regular hyperslabs */ int fast_dim; /* Rank of the fastest changing dimension for the dataspace */ int temp_dim; /* Temporary rank holder */ int ndims; /* Rank of the dataspace */ int done; /* Whether we are done with the iteration */ FUNC_ENTER_NOAPI_NOFUNC(H5S_hyper_serialize); assert(space); /* Store the preamble information */ UINT32ENCODE(buf, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */ UINT32ENCODE(buf, (uint32_t)1); /* Store the version number */ UINT32ENCODE(buf, (uint32_t)0); /* Store the un-used padding */ lenp=buf; /* keep the pointer to the length location for later */ buf+=4; /* skip over space for length */ /* Encode number of dimensions */ UINT32ENCODE(buf, (uint32_t)space->extent.rank); len+=4; /* Check for a "regular" hyperslab selection */ if(space->select.sel_info.hslab->diminfo_valid) { /* Set some convienence values */ ndims=space->extent.rank; fast_dim=ndims-1; diminfo=space->select.sel_info.hslab->opt_diminfo; /* Check each dimension */ for(block_count=1,i=0; i0) { /* Add 8 bytes times the rank for each hyperslab selected */ len+=8*ndims; /* Encode hyperslab starting location */ for(i=0; i0) { /* Reset the block counts */ tmp_count[fast_dim]=diminfo[fast_dim].count; /* Bubble up the decrement to the slower changing dimensions */ temp_dim=fast_dim-1; while(temp_dim>=0 && done==0) { /* Decrement the block count */ tmp_count[temp_dim]--; /* Check if we have more blocks left */ if(tmp_count[temp_dim]>0) break; /* Check for getting out of iterator */ if(temp_dim==0) done=1; /* Reset the block count in this dimension */ tmp_count[temp_dim]=diminfo[temp_dim].count; /* Wrapped a dimension, go up to next dimension */ temp_dim--; } /* end while */ } /* end if */ else break; /* Break out now, for 1-D selections */ /* Re-compute offset array */ for(i=0; iselect.sel_info.hslab->span_lst); UINT32ENCODE(buf, (uint32_t)block_count); len+=4; /* Add 8 bytes times the rank for each hyperslab selected */ H5_CHECK_OVERFLOW(block_count,hssize_t,hsize_t); H5_CHECK_OVERFLOW((8*space->extent.rank*(hsize_t)block_count),hsize_t,size_t); len+=(size_t)(8*space->extent.rank*block_count); /* Encode each hyperslab in selection */ H5S_hyper_serialize_helper(space->select.sel_info.hslab->span_lst,start,end,(hsize_t)0,&buf); } /* end else */ /* Encode length */ UINT32ENCODE(lenp, (uint32_t)len); /* Store the length of the extra information */ FUNC_LEAVE_NOAPI(SUCCEED); } /* H5S_hyper_serialize() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_deserialize PURPOSE Deserialize the current selection from a user-provided buffer. USAGE herr_t H5S_hyper_deserialize(space, buf) H5S_t *space; IN/OUT: Dataspace pointer to place selection into uint8 *buf; IN: Buffer to retrieve serialized selection from RETURNS Non-negative on success/Negative on failure DESCRIPTION Deserializes the current selection into a buffer. (Primarily for retrieving from disk). GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5S_hyper_deserialize (H5S_t *space, const uint8_t *buf) { uint32_t rank; /* rank of points */ size_t num_elem=0; /* number of elements in selection */ hsize_t start[H5O_LAYOUT_NDIMS]; /* hyperslab start information */ hsize_t end[H5O_LAYOUT_NDIMS]; /* hyperslab end information */ hsize_t stride[H5O_LAYOUT_NDIMS]; /* hyperslab stride information */ hsize_t count[H5O_LAYOUT_NDIMS]; /* hyperslab count information */ hsize_t block[H5O_LAYOUT_NDIMS]; /* hyperslab block information */ hsize_t *tstart=NULL; /* temporary hyperslab pointers */ hsize_t *tend=NULL; /* temporary hyperslab pointers */ hsize_t *tstride=NULL; /* temporary hyperslab pointers */ hsize_t *tcount=NULL; /* temporary hyperslab pointers */ hsize_t *tblock=NULL; /* temporary hyperslab pointers */ unsigned i,j; /* local counting variables */ herr_t ret_value=FAIL; /* return value */ FUNC_ENTER_NOAPI(H5S_hyper_deserialize, FAIL); /* Check args */ assert(space); assert(buf); /* Deserialize slabs to select */ buf+=16; /* Skip over selection header */ UINT32DECODE(buf,rank); /* decode the rank of the point selection */ if(rank!=space->extent.rank) HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "rank of pointer does not match dataspace"); UINT32DECODE(buf,num_elem); /* decode the number of points */ /* Set the count & stride for all blocks */ for(tcount=count,tstride=stride,j=0; j immediately followed by <"opposite" corner coordinate>, followed by the next "start" and "opposite" coordinate, etc. until all the block information requested has been put into the user's buffer. No guarantee of any order of the blocks is implied. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_hyper_span_blocklist(H5S_hyper_span_info_t *spans, hsize_t start[], hsize_t end[], hsize_t rank, hsize_t *startblock, hsize_t *numblocks, hsize_t **buf) { H5S_hyper_span_t *curr; /* Pointer to current hyperslab span */ hsize_t u; /* Index variable */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_NOAPI_NOINIT(H5S_hyper_span_blocklist); /* Sanity checks */ assert(spans); assert(rank0); assert(buf && *buf); /* Walk through the list of spans, recursing or outputing them */ curr=spans->head; while(curr!=NULL && *numblocks>0) { /* Recurse if this node has down spans */ if(curr->down!=NULL) { /* Add the starting and ending points for this span to the list */ start[rank]=curr->low; end[rank]=curr->high; /* Recurse down to the next dimension */ if(H5S_hyper_span_blocklist(curr->down,start,end,rank+1,startblock,numblocks,buf)<0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "failed to release hyperslab spans"); } /* end if */ else { /* Skip this block if we haven't skipped all the startblocks yet */ if(*startblock>0) { /* Decrement the starting block */ (*startblock)--; } /* Process this block */ else { /* Encode all the previous dimensions starting & ending points */ /* Copy previous starting points */ for(u=0; ulow, sizeof(hsize_t)); (*buf)++; /* Copy previous ending points */ for(u=0; uhigh, sizeof(hsize_t)); (*buf)++; /* Decrement the number of blocks processed */ (*numblocks)--; } /* end else */ } /* end else */ /* Advance to next node */ curr=curr->next; } /* end while */ done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_hyper_span_blocklist() */ /*-------------------------------------------------------------------------- NAME H5S_get_select_hyper_blocklist PURPOSE Get the list of hyperslab blocks currently selected USAGE herr_t H5S_get_select_hyper_blocklist(space, startblock, numblocks, buf) H5S_t *space; IN: Dataspace pointer of selection to query hsize_t startblock; IN: Hyperslab block to start with hsize_t numblocks; IN: Number of hyperslab blocks to get hsize_t *buf; OUT: List of hyperslab blocks selected RETURNS Non-negative on success, negative on failure DESCRIPTION Puts a list of the hyperslab blocks into the user's buffer. The blocks start with the 'startblock'th block in the list of blocks and put 'numblocks' number of blocks into the user's buffer (or until the end of the list of blocks, whichever happens first) The block coordinates have the same dimensionality (rank) as the dataspace they are located within. The list of blocks is formatted as follows: <"start" coordinate> immediately followed by <"opposite" corner coordinate>, followed by the next "start" and "opposite" coordinate, etc. until all the block information requested has been put into the user's buffer. No guarantee of any order of the blocks is implied. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_get_select_hyper_blocklist(H5S_t *space, hbool_t internal, hsize_t startblock, hsize_t numblocks, hsize_t *buf) { H5S_hyper_dim_t *diminfo; /* Alias for dataspace's diminfo information */ hsize_t tmp_count[H5O_LAYOUT_NDIMS]; /* Temporary hyperslab counts */ hsize_t offset[H5O_LAYOUT_NDIMS]; /* Offset of element in dataspace */ hsize_t start[H5O_LAYOUT_NDIMS]; /* Location of start of hyperslab */ hsize_t end[H5O_LAYOUT_NDIMS]; /* Location of end of hyperslab */ hsize_t temp_off; /* Offset in a given dimension */ int i; /* Counter */ int fast_dim; /* Rank of the fastest changing dimension for the dataspace */ int temp_dim; /* Temporary rank holder */ int ndims; /* Rank of the dataspace */ int done; /* Whether we are done with the iteration */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_get_select_hyper_blocklist); assert(space); assert(buf); /* Check for a "regular" hyperslab selection */ if(space->select.sel_info.hslab->diminfo_valid) { /* Set some convienence values */ ndims=space->extent.rank; fast_dim=ndims-1; /* Check which set of dimension information to use */ if(internal) /* * Use the "optimized dimension information" to pass back information * on the blocks set, not the "application information". */ diminfo=space->select.sel_info.hslab->opt_diminfo; else /* * Use the "application dimension information" to pass back to the user * the blocks they set, not the optimized, internal information. */ diminfo=space->select.sel_info.hslab->app_diminfo; /* Build the tables of count sizes as well as the initial offset */ for(i=0; i0) { /* Iterate over the blocks in the fastest dimension */ while(tmp_count[fast_dim]>0 && numblocks>0) { /* Check if we should copy this block information */ if(startblock==0) { /* Copy the starting location */ HDmemcpy(buf,offset,sizeof(hsize_t)*ndims); buf+=ndims; /* Compute the ending location */ HDmemcpy(buf,offset,sizeof(hsize_t)*ndims); for(i=0; i0 && numblocks>0) { /* Reset the block counts */ tmp_count[fast_dim]=diminfo[fast_dim].count; /* Bubble up the decrement to the slower changing dimensions */ temp_dim=fast_dim-1; while(temp_dim>=0 && done==0) { /* Decrement the block count */ tmp_count[temp_dim]--; /* Check if we have more blocks left */ if(tmp_count[temp_dim]>0) break; /* Check for getting out of iterator */ if(temp_dim==0) done=1; /* Reset the block count in this dimension */ tmp_count[temp_dim]=diminfo[temp_dim].count; /* Wrapped a dimension, go up to next dimension */ temp_dim--; } /* end while */ } /* end if */ /* Re-compute offset array */ for(i=0; iselect.sel_info.hslab->span_lst,start,end,(hsize_t)0,&startblock,&numblocks,&buf); FUNC_LEAVE_NOAPI(ret_value); } /* H5S_get_select_hyper_blocklist() */ /*-------------------------------------------------------------------------- NAME H5Sget_select_hyper_blocklist PURPOSE Get the list of hyperslab blocks currently selected USAGE herr_t H5Sget_select_hyper_blocklist(dsid, startblock, numblocks, buf) hid_t dsid; IN: Dataspace ID of selection to query hsize_t startblock; IN: Hyperslab block to start with hsize_t numblocks; IN: Number of hyperslab blocks to get hsize_t *buf; OUT: List of hyperslab blocks selected RETURNS Non-negative on success, negative on failure DESCRIPTION Puts a list of the hyperslab blocks into the user's buffer. The blocks start with the 'startblock'th block in the list of blocks and put 'numblocks' number of blocks into the user's buffer (or until the end of the list of blocks, whichever happen first) The block coordinates have the same dimensionality (rank) as the dataspace they are located within. The list of blocks is formatted as follows: <"start" coordinate> immediately followed by <"opposite" corner coordinate>, followed by the next "start" and "opposite" coordinate, etc. until all the block information requested has been put into the user's buffer. No guarantee of any order of the blocks is implied. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5Sget_select_hyper_blocklist(hid_t spaceid, hsize_t startblock, hsize_t numblocks, hsize_t *buf) { H5S_t *space = NULL; /* Dataspace to modify selection of */ herr_t ret_value; /* return value */ FUNC_ENTER_API(H5Sget_select_hyper_blocklist, FAIL); H5TRACE4("e","ihh*h",spaceid,startblock,numblocks,buf); /* Check args */ if(buf==NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pointer"); if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); if(H5S_GET_SELECT_TYPE(space)!=H5S_SEL_HYPERSLABS) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a hyperslab selection"); /* Go get the correct number of blocks */ if(numblocks>0) ret_value = H5S_get_select_hyper_blocklist(space,0,startblock,numblocks,buf); else ret_value=SUCCEED; /* Successfully got 0 blocks... */ done: FUNC_LEAVE_API(ret_value); } /* H5Sget_select_hyper_blocklist() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_bounds_helper PURPOSE Gets the bounding box containing the selection. USAGE htri_t H5S_hyper_bounds_helper(spans, offset, rank); const H5S_hyper_span_info_t *spans; IN: Pointer to current hyperslab span tree const hssize_t *offset; IN: Pointer to offset array hsize_t rank; IN: Current rank looking at hsize_t *start; OUT: Start array bounds hsize_t *end; OUT: End array bounds RETURNS Non-negative on success, negative on failure DESCRIPTION Retrieves the bounding box containing the current selection and places it into the user's buffers. The start and end buffers must be large enough to hold the dataspace rank number of coordinates. The bounding box exactly contains the selection, ie. if a 2-D element selection is currently defined with the following points: (4,5), (6,8) (10,7), the bounding box with be (4, 5), (10, 8). The bounding box calculations _does_ include the current offset of the selection within the dataspace extent. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_hyper_bounds_helper (const H5S_hyper_span_info_t *spans, const hssize_t *offset, hsize_t rank, hsize_t *start, hsize_t *end) { H5S_hyper_span_t *curr; /* Hyperslab information nodes */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5S_hyper_bounds_helper) assert(spans); assert(offset); assert(rankhead; while(curr!=NULL) { /* Check for offset moving selection negative */ if(((hssize_t)curr->low+offset[rank])<0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "offset moves selection out of bounds") /* Check if the current span extends the bounding box */ if((curr->low+offset[rank])low+offset[rank]; if((curr->high+offset[rank])>end[rank]) end[rank]=curr->high+offset[rank]; /* Recurse if this node has down spans */ if(curr->down!=NULL) { if(H5S_hyper_bounds_helper(curr->down,offset,rank+1,start,end)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADSELECT, FAIL, "failure in lower dimension") } /* end if */ /* Advance to next node */ curr=curr->next; } /* end while */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_hyper_bounds_helper() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_bounds PURPOSE Gets the bounding box containing the selection. USAGE herr_t H5S_hyper_bounds(space, hsize_t *start, hsize_t *end) H5S_t *space; IN: Dataspace pointer of selection to query hsize_t *start; OUT: Starting coordinate of bounding box hsize_t *end; OUT: Opposite coordinate of bounding box RETURNS Non-negative on success, negative on failure DESCRIPTION Retrieves the bounding box containing the current selection and places it into the user's buffers. The start and end buffers must be large enough to hold the dataspace rank number of coordinates. The bounding box exactly contains the selection, ie. if a 2-D element selection is currently defined with the following points: (4,5), (6,8) (10,7), the bounding box with be (4, 5), (10, 8). The bounding box calculations _does_ include the current offset of the selection within the dataspace extent. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5S_hyper_bounds(const H5S_t *space, hsize_t *start, hsize_t *end) { int rank; /* Dataspace rank */ int i; /* index variable */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5S_hyper_bounds,FAIL) assert(space); assert(start); assert(end); /* Set the start and end arrays up */ rank=space->extent.rank; for(i=0; iselect.sel_info.hslab->diminfo_valid) { const H5S_hyper_dim_t *diminfo=space->select.sel_info.hslab->opt_diminfo; /* local alias for diminfo */ /* Check each dimension */ for(i=0; iselect.offset[i]+(hssize_t)diminfo[i].start)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "offset moves selection out of bounds") /* Compute the smallest location in this dimension */ start[i]=diminfo[i].start+space->select.offset[i]; /* Compute the largest location in this dimension */ end[i]=diminfo[i].start+diminfo[i].stride*(diminfo[i].count-1)+(diminfo[i].block-1)+space->select.offset[i]; } /* end for */ } /* end if */ else { /* Call the recursive routine to get the bounds for the span tree */ ret_value=H5S_hyper_bounds_helper(space->select.sel_info.hslab->span_lst,space->select.offset,(hsize_t)0,start,end); } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5S_hyper_bounds() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_is_contiguous PURPOSE Check if a hyperslab selection is contiguous within the dataspace extent. USAGE htri_t H5S_hyper_is_contiguous(space) H5S_t *space; IN: Dataspace pointer to check RETURNS TRUE/FALSE/FAIL DESCRIPTION Checks to see if the current selection in the dataspace is contiguous. This is primarily used for reading the entire selection in one swoop. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ htri_t H5S_hyper_is_contiguous(const H5S_t *space) { H5S_hyper_span_info_t *spans; /* Hyperslab span info node */ H5S_hyper_span_t *span; /* Hyperslab span node */ unsigned u; /* index variable */ unsigned small_contiguous, /* Flag for small contiguous block */ large_contiguous; /* Flag for large contiguous block */ htri_t ret_value=FALSE; /* return value */ FUNC_ENTER_NOAPI_NOFUNC(H5S_hyper_is_contiguous); assert(space); /* Check for a "regular" hyperslab selection */ if(space->select.sel_info.hslab->diminfo_valid) { const H5S_hyper_dim_t *diminfo=space->select.sel_info.hslab->opt_diminfo; /* local alias for diminfo */ /* * For a regular hyperslab to be contiguous, it must have only one * block (i.e. count==1 in all dimensions) and the block size must be * the same as the dataspace extent's in all but the slowest changing * dimension. (dubbed "large contiguous" block) * * OR * * The selection must have only one block (i.e. count==1) in all * dimensions and the block size must be 1 in all but the fastest * changing dimension. (dubbed "small contiguous" block) */ /* Initialize flags */ large_contiguous=TRUE; /* assume true and reset if the dimensions don't match */ small_contiguous=FALSE; /* assume false initially */ /* Check for a "large contigous" block */ for(u=0; uextent.rank; u++) { if(diminfo[u].count>1) { large_contiguous=FALSE; break; } /* end if */ if(u>0 && diminfo[u].block!=space->extent.size[u]) { large_contiguous=FALSE; break; } /* end if */ } /* end for */ /* If we didn't find a large contiguous block, check for a small one */ if(large_contiguous==FALSE) { small_contiguous=TRUE; for(u=0; uextent.rank; u++) { if(diminfo[u].count>1) { small_contiguous=FALSE; break; } /* end if */ if(u<(space->extent.rank-1) && diminfo[u].block!=1) { small_contiguous=FALSE; break; } /* end if */ } /* end for */ } /* end if */ /* Indicate true if it's either a large or small contiguous block */ if(large_contiguous || small_contiguous) ret_value=TRUE; } /* end if */ else { /* * For a hyperslab to be contiguous, it must have only one block and * (either it's size must be the same as the dataspace extent's in all * but the slowest changing dimension * OR * block size must be 1 in all but the fastest changing dimension). */ /* Initialize flags */ large_contiguous=TRUE; /* assume true and reset if the dimensions don't match */ small_contiguous=FALSE; /* assume false initially */ /* Get information for slowest changing information */ spans=space->select.sel_info.hslab->span_lst; span=spans->head; /* If there are multiple spans in the slowest changing dimension, the selection isn't contiguous */ if(span->next!=NULL) large_contiguous=FALSE; else { /* Now check the rest of the dimensions */ if(span->down!=NULL) { u=1; /* Current dimension working on */ /* Get the span information for the next fastest dimension */ spans=span->down; /* Cycle down the spans until we run out of down spans or find a non-contiguous span */ while(spans!=NULL) { span=spans->head; /* Check that this is the only span and it spans the entire dimension */ if(span->next!=NULL) { large_contiguous=FALSE; break; } /* end if */ else { /* If this span doesn't cover the entire dimension, then this selection isn't contiguous */ if(((span->high-span->low)+1)!=space->extent.size[u]) { large_contiguous=FALSE; break; } /* end if */ else { /* Walk down to the next span */ spans=span->down; /* Increment dimension */ u++; } /* end else */ } /* end else */ } /* end while */ } /* end if */ } /* end else */ /* If we didn't find a large contiguous block, check for a small one */ if(large_contiguous==FALSE) { small_contiguous=TRUE; /* Get information for slowest changing information */ spans=space->select.sel_info.hslab->span_lst; span=spans->head; /* Current dimension working on */ u=0; /* Cycle down the spans until we run out of down spans or find a non-contiguous span */ while(spans!=NULL) { span=spans->head; /* Check that this is the only span and it spans the entire dimension */ if(span->next!=NULL) { small_contiguous=FALSE; break; } /* end if */ else { /* If this span doesn't cover the entire dimension, then this selection isn't contiguous */ if(u<(space->extent.rank-1) && ((span->high-span->low)+1)!=1) { small_contiguous=FALSE; break; } /* end if */ else { /* Walk down to the next span */ spans=span->down; /* Increment dimension */ u++; } /* end else */ } /* end else */ } /* end while */ } /* end if */ /* Indicate true if it's either a large or small contiguous block */ if(large_contiguous || small_contiguous) ret_value=TRUE; } /* end else */ FUNC_LEAVE_NOAPI(ret_value); } /* H5S_hyper_is_contiguous() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_is_single PURPOSE Check if a hyperslab selection is a single block within the dataspace extent. USAGE htri_t H5S_hyper_is_single(space) H5S_t *space; IN: Dataspace pointer to check RETURNS TRUE/FALSE/FAIL DESCRIPTION Checks to see if the current selection in the dataspace is a single block. This is primarily used for reading the entire selection in one swoop. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ htri_t H5S_hyper_is_single(const H5S_t *space) { H5S_hyper_span_info_t *spans; /* Hyperslab span info node */ H5S_hyper_span_t *span; /* Hyperslab span node */ unsigned u; /* index variable */ htri_t ret_value=TRUE; /* return value */ FUNC_ENTER_NOAPI_NOFUNC(H5S_hyper_is_single); assert(space); /* Check for a "single" hyperslab selection */ if(space->select.sel_info.hslab->diminfo_valid) { /* * For a regular hyperslab to be single, it must have only one * block (i.e. count==1 in all dimensions) */ /* Check for a single block */ for(u=0; uextent.rank; u++) { if(space->select.sel_info.hslab->opt_diminfo[u].count>1) HGOTO_DONE(FALSE) } /* end for */ } /* end if */ else { /* * For a region to be single, it must have only one block */ /* Get information for slowest changing information */ spans=space->select.sel_info.hslab->span_lst; /* Cycle down the spans until we run out of down spans or find a non-contiguous span */ while(spans!=NULL) { span=spans->head; /* Check that this is the only span and it spans the entire dimension */ if(span->next!=NULL) HGOTO_DONE(FALSE) else /* Walk down to the next span */ spans=span->down; } /* end while */ } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_hyper_is_single() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_is_regular PURPOSE Check if a hyperslab selection is "regular" USAGE htri_t H5S_hyper_is_regular(space) const H5S_t *space; IN: Dataspace pointer to check RETURNS TRUE/FALSE/FAIL DESCRIPTION Checks to see if the current selection in a dataspace is the a regular pattern. This is primarily used for reading the entire selection in one swoop. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS Doesn't check for "regular" hyperslab selections composed of spans EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ htri_t H5S_hyper_is_regular(const H5S_t *space) { htri_t ret_value; /* return value */ FUNC_ENTER_NOAPI_NOFUNC(H5S_hyper_is_regular); /* Check args */ assert(space); /* Only simple check for regular hyperslabs for now... */ if(space->select.sel_info.hslab->diminfo_valid) ret_value=TRUE; else ret_value=FALSE; FUNC_LEAVE_NOAPI(ret_value); } /* H5S_hyper_is_regular() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_release PURPOSE Release hyperslab selection information for a dataspace USAGE herr_t H5S_hyper_release(space) H5S_t *space; IN: Pointer to dataspace RETURNS Non-negative on success/Negative on failure DESCRIPTION Releases all hyperslab selection information for a dataspace GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG * Robb Matzke, 1998-08-25 * The fields which are freed are set to NULL to prevent them from being * freed again later. This fixes some allocation problems where * changing the hyperslab selection of one data space causes a core dump * when closing some other data space. --------------------------------------------------------------------------*/ herr_t H5S_hyper_release (H5S_t *space) { herr_t ret_value=SUCCEED; FUNC_ENTER_NOAPI(H5S_hyper_release, FAIL); /* Check args */ assert (space && H5S_SEL_HYPERSLABS==H5S_GET_SELECT_TYPE(space)); /* Reset the number of points selected */ space->select.num_elem=0; /* Release irregular hyperslab information */ if(space->select.sel_info.hslab->span_lst!=NULL) { if(H5S_hyper_free_span_info(space->select.sel_info.hslab->span_lst)<0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "failed to release hyperslab spans"); } /* end if */ /* Release space for the hyperslab selection information */ H5FL_FREE(H5S_hyper_sel_t,space->select.sel_info.hslab); space->select.sel_info.hslab=NULL; done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_hyper_release() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_recover_span PURPOSE Recover a generated span, if appropriate USAGE herr_t H5S_hyper_recover_span(recover, curr_span, next_span) unsigned *recover; IN/OUT: Pointer recover flag H5S_hyper_span_t **curr_span; IN/OUT: Pointer to current span in list H5S_hyper_span_t *next_span; IN: Pointer to next span RETURNS Non-negative on success, negative on failure DESCRIPTION Check if the current span needs to be recovered and free it if so. Set the current span to the next span in any case. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_hyper_recover_span (unsigned *recover, H5S_hyper_span_t **curr_span, H5S_hyper_span_t *next_span) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_hyper_recover_span); assert(recover); assert(curr_span); /* Check if the span should be recovered */ if(*recover) { H5S_hyper_free_span(*curr_span); *recover=0; } /* end if */ /* Set the current span to next span */ *curr_span=next_span; FUNC_LEAVE_NOAPI(SUCCEED); } /* H5S_hyper_recover_span() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_coord_to_span PURPOSE Create a span tree for a single element USAGE H5S_hyper_span_t *H5S_hyper_coord_to_span(rank, coords) unsigned rank; IN: Number of dimensions of coordinate hsize_t *coords; IN: Location of element RETURNS Non-negative on success, negative on failure DESCRIPTION Create a span tree for a single element GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static H5S_hyper_span_t * H5S_hyper_coord_to_span(unsigned rank, hsize_t *coords) { H5S_hyper_span_t *new_span; /* Pointer to new span tree for coordinate */ H5S_hyper_span_info_t *down=NULL; /* Pointer to new span tree for next level down */ H5S_hyper_span_t *ret_value=NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5S_hyper_coord_to_span); assert(rank>0); assert(coords); /* Search for location to insert new element in tree */ if(rank>1) { /* Allocate a span info node */ if((down = H5FL_MALLOC(H5S_hyper_span_info_t))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate hyperslab span"); /* Set the reference count */ down->count=0; /* Reset the scratch pad space */ down->scratch=0; /* Build span tree for coordinates below this one */ if((down->head=H5S_hyper_coord_to_span(rank-1,&coords[1]))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate hyperslab span"); } /* end if */ /* Build span for this coordinate */ if((new_span = H5S_hyper_new_span(coords[0],coords[0],down,NULL))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate hyperslab span"); /* Set return value */ ret_value=new_span; done: if(ret_value==NULL) { if(down!=NULL) H5S_hyper_free_span_info(down); } /* end if */ FUNC_LEAVE_NOAPI(ret_value); } /* H5S_hyper_coord_to_span() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_add_span_element_helper PURPOSE Add a single elment to a span tree USAGE herr_t H5S_hyper_add_span_element_helper(prev_span, span_tree, rank, coords) H5S_hyper_span_info_t *span_tree; IN/OUT: Pointer to span tree to append to unsigned rank; IN: Number of dimensions of coordinates hsize_t *coords; IN: Location of element to add to span tree RETURNS Non-negative on success, negative on failure DESCRIPTION Add a single element to an existing span tree. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS Assumes that the element is not already covered by the span tree EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_hyper_add_span_element_helper(H5S_hyper_span_info_t *span_tree, unsigned rank, hsize_t *coords) { H5S_hyper_span_info_t *tspan_info; /* Temporary pointer to span info */ H5S_hyper_span_info_t *prev_span_info; /* Pointer to span info for level above current position */ H5S_hyper_span_t *tmp_span; /* Temporary pointer to a span */ H5S_hyper_span_t *tmp2_span; /* Another temporary pointer to a span */ H5S_hyper_span_t *new_span; /* New span created for element */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5S_hyper_add_span_element_helper); assert(span_tree); assert(rank>0); assert(coords); /* Get pointer to last span in span tree */ tspan_info=span_tree; if(span_tree->scratch) tmp_span=(H5S_hyper_span_t *)span_tree->scratch; else { tmp_span=span_tree->head; assert(tmp_span); span_tree->scratch=(H5S_hyper_span_info_t *)tmp_span; } /* end else */ /* Find last span tree which includes a portion of the coordinate */ prev_span_info=NULL; while(coords[0]>=tmp_span->low && coords[0]<=tmp_span->high) { /* Move rank & coordinate offset down a dimension */ rank--; coords++; /* Remember the span tree we are descending into */ prev_span_info=tspan_info; tspan_info=tmp_span->down; /* Get the last span in this span's 'down' tree */ if(tspan_info->scratch) tmp_span=(H5S_hyper_span_t *)tspan_info->scratch; else { tmp_span=tspan_info->head; assert(tmp_span); tspan_info->scratch=(H5S_hyper_span_info_t *)tmp_span; } /* end else */ } /* end while */ /* Check if we made it all the way to the bottom span in the tree */ if(rank>1) { /* Before we create another span at this level in the tree, check if * the last span's "down tree" was equal to any other spans in this * list of spans in the span tree. * * If so, release last span information and make last span merge into * previous span (if possible), or at least share their "down tree" * information. */ tmp2_span=tspan_info->head; while(tmp2_span!=tmp_span) { if(H5S_hyper_cmp_spans(tmp2_span->down,tmp_span->down)==TRUE) { /* Check for merging into previous span */ if(tmp2_span->high+1==tmp_span->low) { /* Release last span created */ H5S_hyper_free_span(tmp_span); /* Increase size of previous span */ tmp2_span->high++; tmp2_span->nelem++; /* Reset the 'tmp_span' for the rest of this block's algorithm */ tmp_span=tmp2_span; } /* end if */ /* Span is disjoint, but has the same "down tree" selection */ else { /* Release "down tree" information */ H5S_hyper_free_span_info(tmp_span->down); /* Point at earlier span's "down tree" */ tmp_span->down=tmp2_span->down; /* Increment reference count on shared "down tree" */ tmp_span->down->count++; } /* end else */ /* Found span to merge into, break out now */ break; } /* end if */ /* Advance to next span to check */ tmp2_span=tmp2_span->next; } /* end while */ /* Make span tree for current coordinates */ if((new_span=H5S_hyper_coord_to_span(rank,coords))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span"); /* Add new span tree as span */ assert(tmp_span); tmp_span->next=new_span; /* Make scratch pointer point to last span in list */ assert(tspan_info); tspan_info->scratch=(H5S_hyper_span_info_t *)new_span; /* Set the proper 'pstride' for new span */ new_span->pstride=new_span->low-tmp_span->low; } /* end if */ else { /* Does new node adjoin existing node? */ if(tmp_span->high+1==coords[0]) { tmp_span->high++; tmp_span->nelem++; /* Check if this span tree should now be merged with a level higher in the tree */ if(prev_span_info!=NULL) { /* Before we create another span at this level in the tree, check if * the last span's "down tree" was equal to any other spans in this * list of spans in the span tree. * * If so, release last span information and make last span merge into * previous span (if possible), or at least share their "down tree" * information. */ tmp2_span=prev_span_info->head; tmp_span=(H5S_hyper_span_t *)prev_span_info->scratch; while(tmp2_span!=tmp_span) { if(H5S_hyper_cmp_spans(tmp2_span->down,tmp_span->down)==TRUE) { /* Check for merging into previous span */ if(tmp2_span->high+1==tmp_span->low) { /* Release last span created */ H5S_hyper_free_span(tmp_span); /* Increase size of previous span */ tmp2_span->high++; tmp2_span->nelem++; /* Update pointers */ tmp2_span->next=NULL; prev_span_info->scratch=(H5S_hyper_span_info_t *)tmp2_span; } /* end if */ /* Span is disjoint, but has the same "down tree" selection */ else { /* Release "down tree" information */ H5S_hyper_free_span_info(tmp_span->down); /* Point at earlier span's "down tree" */ tmp_span->down=tmp2_span->down; /* Increment reference count on shared "down tree" */ tmp_span->down->count++; } /* end else */ /* Found span to merge into, break out now */ break; } /* end if */ /* Advance to next span to check */ tmp2_span=tmp2_span->next; } /* end while */ } /* end if */ } /* end if */ else { if((new_span = H5S_hyper_new_span(coords[0],coords[0],NULL,NULL))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span"); /* Add new span tree as span */ assert(tmp_span); tmp_span->next=new_span; /* Make scratch pointer point to last span in list */ tspan_info->scratch=(H5S_hyper_span_info_t *)new_span; /* Set the proper 'pstride' for new span */ new_span->pstride=new_span->low-tmp_span->low; } /* end else */ } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_hyper_add_span_element_helper() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_add_span_element PURPOSE Add a single elment to a span tree USAGE herr_t H5S_hyper_add_span_element(space, span_tree, rank, coords) H5S_t *space; IN/OUT: Pointer to dataspace to add coordinate to unsigned rank; IN: Number of dimensions of coordinates hsize_t *coords; IN: Location of element to add to span tree RETURNS Non-negative on success, negative on failure DESCRIPTION Add a single element to an existing span tree. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS Assumes that the element is not already in the dataspace's selection EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5S_hyper_add_span_element(H5S_t *space, unsigned rank, hsize_t *coords) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5S_hyper_add_span_element); assert(space); assert(rank>0); assert(coords); /* Check if this is the first element in the selection */ if(space->select.sel_info.hslab==NULL) { H5S_hyper_span_info_t *head; /* Pointer to new head of span tree */ /* Allocate a span info node */ if((head = H5FL_MALLOC(H5S_hyper_span_info_t))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span"); /* Set the reference count */ head->count=1; /* Reset the scratch pad space */ head->scratch=0; /* Build span tree for this coordinate */ if((head->head=H5S_hyper_coord_to_span(rank,coords))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span"); /* Allocate selection info */ if((space->select.sel_info.hslab=H5FL_MALLOC(H5S_hyper_sel_t))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab info"); /* Set the selection to the new span tree */ space->select.sel_info.hslab->span_lst=head; /* Set selection type */ space->select.type=H5S_sel_hyper; /* Reset "regular" hyperslab flag */ space->select.sel_info.hslab->diminfo_valid=FALSE; /* Set # of elements in selection */ space->select.num_elem=1; } /* end if */ else { if(H5S_hyper_add_span_element_helper(space->select.sel_info.hslab->span_lst,rank,coords)<0) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span"); /* Increment # of elements in selection */ space->select.num_elem++; } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_hyper_add_span_element() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_reset_scratch PURPOSE Reset the scratch information for span tree USAGE herr_t H5S_hyper_reset_scratch(space) H5S_t *space; IN/OUT: Pointer to dataspace to reset scratch pointers RETURNS Non-negative on success, negative on failure DESCRIPTION Resets the "scratch" pointers used for various tasks in computing hyperslab spans. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5S_hyper_reset_scratch(H5S_t *space) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5S_hyper_reset_scratch); assert(space); /* Check if there are spans in the span tree */ if(space->select.sel_info.hslab->span_lst!=NULL) /* Reset the scratch pointers for the next routine which needs them */ if(H5S_hyper_span_scratch(space->select.sel_info.hslab->span_lst,NULL)==FAIL) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "can't reset span tree scratch pointers"); done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_hyper_reset_scratch() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_convert PURPOSE Convert a compatible selection to span tree form USAGE herr_t H5S_hyper_convert(space) H5S_t *space; IN/OUT: Pointer to dataspace to convert RETURNS Non-negative on success, negative on failure DESCRIPTION Converts a compatible selection (currently only "all" selections) to the span-tree form of a hyperslab selection. (Point and "none" selection aren't currently supported and hyperslab selection always have the span-tree form available). GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5S_hyper_convert(H5S_t *space) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5S_hyper_convert); assert(space); /* Check the type of selection */ switch(H5S_GET_SELECT_TYPE(space)) { case H5S_SEL_ALL: /* All elements selected in dataspace */ /* Convert current "all" selection to "real" hyperslab selection */ { hsize_t tmp_start[H5O_LAYOUT_NDIMS]; /* Temporary start information */ hsize_t tmp_stride[H5O_LAYOUT_NDIMS]; /* Temporary stride information */ hsize_t tmp_count[H5O_LAYOUT_NDIMS]; /* Temporary count information */ hsize_t tmp_block[H5O_LAYOUT_NDIMS]; /* Temporary block information */ unsigned u; /* Local index variable */ /* Fill in temporary information for the dimensions */ for(u=0; uextent.rank; u++) { tmp_start[u]=0; tmp_stride[u]=1; tmp_count[u]=1; tmp_block[u]=space->extent.size[u]; } /* end for */ /* Convert to hyperslab selection */ if(H5S_select_hyperslab(space,H5S_SELECT_SET,tmp_start,tmp_stride,tmp_count,tmp_block)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't convert selection"); } /* end case */ break; case H5S_SEL_HYPERSLABS: /* Hyperslab selection */ break; case H5S_SEL_NONE: /* No elements selected in dataspace */ case H5S_SEL_POINTS: /* Point selection */ default: HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "can't convert to span tree selection"); } /* end switch */ done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_hyper_convert() */ #ifdef LATER /*-------------------------------------------------------------------------- NAME H5S_hyper_intersect_helper PURPOSE Helper routine to detect intersections in span trees USAGE htri_t H5S_hyper_intersect_helper(spans1, spans2) H5S_hyper_span_info_t *spans1; IN: First span tree to operate with H5S_hyper_span_info_t *spans2; IN: Second span tree to operate with RETURNS Non-negative on success, negative on failure DESCRIPTION Quickly detect intersections between two span trees GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static htri_t H5S_hyper_intersect_helper (H5S_hyper_span_info_t *spans1, H5S_hyper_span_info_t *spans2) { H5S_hyper_span_t *curr1; /* Pointer to current span in 1st span tree */ H5S_hyper_span_t *curr2; /* Pointer to current span in 2nd span tree */ htri_t status; /* Status from recursive call */ htri_t ret_value=FALSE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5S_hyper_intersect_helper); /* Sanity check */ assert((spans1 && spans2) || (spans1==NULL && spans2==NULL)); /* "NULL" span trees compare as overlapping */ if(spans1==NULL && spans2==NULL) HGOTO_DONE(TRUE); /* Get the span lists for each span in this tree */ curr1=spans1->head; curr2=spans2->head; /* Iterate over the spans in each tree */ while(curr1!=NULL && curr2!=NULL) { /* Check for 1st span entirely before 2nd span */ if(curr1->highlow) curr1=curr1->next; /* Check for 2nd span entirely before 1st span */ else if(curr2->highlow) curr2=curr2->next; /* Spans must overlap */ else { /* Recursively check spans in next dimension down */ if((status=H5S_hyper_intersect_helper(curr1->down,curr2->down))<0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADSELECT, FAIL, "can't perform hyperslab intersection check"); /* If there is a span intersection in the down dimensions, the span trees overlap */ if(status==TRUE) HGOTO_DONE(TRUE); /* No intersection in down dimensions, advance to next span */ if(curr1->highhigh) curr1=curr1->next; else curr2=curr2->next; } /* end else */ } /* end while */ done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_hyper_intersect_helper() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_intersect PURPOSE Detect intersections in span trees USAGE htri_t H5S_hyper_intersect(space1, space2) H5S_t *space1; IN: First dataspace to operate on span tree H5S_t *space2; IN: Second dataspace to operate on span tree RETURNS Non-negative on success, negative on failure DESCRIPTION Quickly detect intersections between two span trees GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ htri_t H5S_hyper_intersect (H5S_t *space1, H5S_t *space2) { htri_t ret_value=FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5S_hyper_intersect); /* Sanity check */ assert(space1); assert(space2); /* Check that the space selections both have span trees */ if(space1->select.sel_info.hslab->span_lst==NULL || space2->select.sel_info.hslab->span_lst==NULL) HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "dataspace does not have span tree"); /* Check that the dataspaces are both the same rank */ if(space1->extent.rank!=space2->extent.rank) HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "dataspace ranks don't match"); /* Perform the span-by-span intersection check */ if((ret_value=H5S_hyper_intersect_helper(space1->select.sel_info.hslab->span_lst,space2->select.sel_info.hslab->span_lst))<0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADSELECT, FAIL, "can't perform hyperslab intersection check"); done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_hyper_intersect() */ #endif /* LATER */ /*-------------------------------------------------------------------------- NAME H5S_hyper_intersect_block_helper PURPOSE Helper routine to detect intersections in span trees USAGE htri_t H5S_hyper_intersect_block_helper(spans, start, end) H5S_hyper_span_info_t *spans; IN: First span tree to operate with hssize_t *offset; IN: Selection offset coordinate hsize_t *start; IN: Starting coordinate for block hsize_t *end; IN: Ending coordinate for block RETURN Non-negative on success, negative on failure DESCRIPTION Quickly detect intersections between span tree and block GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static htri_t H5S_hyper_intersect_block_helper (const H5S_hyper_span_info_t *spans, hsize_t *start, hsize_t *end) { H5S_hyper_span_t *curr; /* Pointer to current span in 1st span tree */ htri_t status; /* Status from recursive call */ htri_t ret_value=FALSE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5S_hyper_intersect_block_helper); /* Sanity check */ assert(spans); assert(start); assert(end); /* Get the span list for spans in this tree */ curr=spans->head; /* Iterate over the spans in the tree */ while(curr!=NULL) { /* Check for span entirely before block */ if(curr->high < *start) /* Advance to next span in this dimension */ curr=curr->next; /* If this span is past the end of the block, then we're done in this dimension */ else if(curr->low > *end) HGOTO_DONE(FALSE) /* block & span overlap */ else { if(curr->down==NULL) HGOTO_DONE(TRUE) else { /* Recursively check spans in next dimension down */ if((status=H5S_hyper_intersect_block_helper(curr->down,start+1,end+1))<0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADSELECT, FAIL, "can't perform hyperslab intersection check"); /* If there is a span intersection in the down dimensions, the span trees overlap */ if(status==TRUE) HGOTO_DONE(TRUE); /* No intersection in down dimensions, advance to next span */ curr=curr->next; } /* end else */ } /* end else */ } /* end while */ done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_hyper_intersect_block_helper() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_intersect_block PURPOSE Detect intersections in span trees USAGE htri_t H5S_hyper_intersect_block(space, start, end) H5S_t *space; IN: First dataspace to operate on span tree hssize_t *start; IN: Starting coordinate for block hssize_t *end; IN: Ending coordinate for block RETURNS Non-negative on success, negative on failure DESCRIPTION Quickly detect intersections between span tree and block GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ htri_t H5S_hyper_intersect_block (H5S_t *space, hsize_t *start, hsize_t *end) { htri_t ret_value=FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5S_hyper_intersect_block); /* Sanity check */ assert(space); assert(start); assert(end); /* Check for 'all' selection, instead of a hyperslab selection */ /* (Technically, this shouldn't be in the "hyperslab" routines...) */ if(H5S_GET_SELECT_TYPE(space)==H5S_SEL_ALL) HGOTO_DONE(TRUE); /* Check that the space selection has a span tree */ if(space->select.sel_info.hslab->span_lst==NULL) if(H5S_hyper_generate_spans(space)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "dataspace does not have span tree"); /* Perform the span-by-span intersection check */ if((ret_value=H5S_hyper_intersect_block_helper(space->select.sel_info.hslab->span_lst,start,end))<0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADSELECT, FAIL, "can't perform hyperslab intersection check"); done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_hyper_intersect_block() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_adjust_helper_u PURPOSE Helper routine to adjust offsets in span trees USAGE herr_t H5S_hyper_adjust_helper_u(spans, offset) H5S_hyper_span_info_t *spans; IN: Span tree to operate with const hsize_t *offset; IN: Offset to subtract RETURNS Non-negative on success, negative on failure DESCRIPTION Adjust the location of the spans in a span tree by subtracting an offset GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_hyper_adjust_helper_u (H5S_hyper_span_info_t *spans, const hsize_t *offset) { H5S_hyper_span_t *span; /* Pointer to current span in span tree */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_hyper_adjust_helper_u); /* Sanity check */ assert(spans); assert(offset); /* Check if we've already set this down span tree */ if(spans->scratch!=(H5S_hyper_span_info_t *)~((size_t)NULL)) { /* Set the tree's scratch pointer */ spans->scratch=(H5S_hyper_span_info_t *)~((size_t)NULL); /* Get the span lists for each span in this tree */ span=spans->head; /* Iterate over the spans in tree */ while(span!=NULL) { /* Adjust span offset */ assert(span->low>=*offset); span->low-=*offset; span->high-=*offset; /* Recursively adjust spans in next dimension down */ if(span->down!=NULL) H5S_hyper_adjust_helper_u(span->down,offset+1); /* Advance to next span in this dimension */ span=span->next; } /* end while */ } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED); } /* H5S_hyper_adjust_helper_u() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_adjust_u PURPOSE Adjust a hyperslab selection by subtracting an offset USAGE herr_t H5S_hyper_adjust_u(space,offset) H5S_t *space; IN/OUT: Pointer to dataspace to adjust const hsize_t *offset; IN: Offset to subtract RETURNS Non-negative on success, negative on failure DESCRIPTION Moves a hyperslab selection by subtracting an offset from it. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5S_hyper_adjust_u(H5S_t *space, const hsize_t *offset) { unsigned u; /* Local index variable */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5S_hyper_adjust_u); assert(space); assert(offset); /* Subtract the offset from the "regular" coordinates, if they exist */ if(space->select.sel_info.hslab->diminfo_valid) { for(u=0; uextent.rank; u++) { assert(space->select.sel_info.hslab->opt_diminfo[u].start>=offset[u]); space->select.sel_info.hslab->opt_diminfo[u].start-=offset[u]; } /* end for */ } /* end if */ /* Subtract the offset from the span tree coordinates, if they exist */ if(space->select.sel_info.hslab->span_lst) { if(H5S_hyper_adjust_helper_u(space->select.sel_info.hslab->span_lst,offset)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADSELECT, FAIL, "can't perform hyperslab offset adjustment"); /* Reset the scratch pointers for the next routine which needs them */ if(H5S_hyper_span_scratch(space->select.sel_info.hslab->span_lst,NULL)==FAIL) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "can't reset hyperslab scratch pointer"); } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_hyper_adjust_u() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_adjust_helper_s PURPOSE Helper routine to adjust offsets in span trees USAGE herr_t H5S_hyper_adjust_helper_s(spans, offset) H5S_hyper_span_info_t *spans; IN: Span tree to operate with const hssize_t *offset; IN: Offset to subtract RETURNS Non-negative on success, negative on failure DESCRIPTION Adjust the location of the spans in a span tree by subtracting an offset GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_hyper_adjust_helper_s (H5S_hyper_span_info_t *spans, const hssize_t *offset) { H5S_hyper_span_t *span; /* Pointer to current span in span tree */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_hyper_adjust_helper_s); /* Sanity check */ assert(spans); assert(offset); /* Check if we've already set this down span tree */ if(spans->scratch!=(H5S_hyper_span_info_t *)~((size_t)NULL)) { /* Set the tree's scratch pointer */ spans->scratch=(H5S_hyper_span_info_t *)~((size_t)NULL); /* Get the span lists for each span in this tree */ span=spans->head; /* Iterate over the spans in tree */ while(span!=NULL) { /* Adjust span offset */ assert((hssize_t)span->low>=*offset); span->low-=*offset; span->high-=*offset; /* Recursively adjust spans in next dimension down */ if(span->down!=NULL) H5S_hyper_adjust_helper_s(span->down,offset+1); /* Advance to next span in this dimension */ span=span->next; } /* end while */ } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED); } /* H5S_hyper_adjust_helper_s() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_adjust_s PURPOSE Adjust a hyperslab selection by subtracting an offset USAGE herr_t H5S_hyper_adjust_s(space,offset) H5S_t *space; IN/OUT: Pointer to dataspace to adjust const hssize_t *offset; IN: Offset to subtract RETURNS Non-negative on success, negative on failure DESCRIPTION Moves a hyperslab selection by subtracting an offset from it. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5S_hyper_adjust_s(H5S_t *space, const hssize_t *offset) { unsigned u; /* Local index variable */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5S_hyper_adjust_s); assert(space); assert(offset); /* Subtract the offset from the "regular" coordinates, if they exist */ if(space->select.sel_info.hslab->diminfo_valid) { for(u=0; uextent.rank; u++) { assert((hssize_t)space->select.sel_info.hslab->opt_diminfo[u].start>=offset[u]); space->select.sel_info.hslab->opt_diminfo[u].start-=offset[u]; } /* end for */ } /* end if */ /* Subtract the offset from the span tree coordinates, if they exist */ if(space->select.sel_info.hslab->span_lst) { if(H5S_hyper_adjust_helper_s(space->select.sel_info.hslab->span_lst,offset)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADSELECT, FAIL, "can't perform hyperslab offset adjustment"); /* Reset the scratch pointers for the next routine which needs them */ if(H5S_hyper_span_scratch(space->select.sel_info.hslab->span_lst,NULL)==FAIL) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "can't reset hyperslab scratch pointer"); } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_hyper_adjust_s() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_move_helper PURPOSE Helper routine to move offset in span trees USAGE herr_t H5S_hyper_move_helper(spans, offset) H5S_hyper_span_info_t *spans; IN: Span tree to operate with const hssize_t *offset; IN: Offset to move to RETURNS Non-negative on success, negative on failure DESCRIPTION Adjust the location of the spans in a span tree by moving selection to an offset. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_hyper_move_helper (H5S_hyper_span_info_t *spans, const hssize_t *offset) { H5S_hyper_span_t *span; /* Pointer to current span in span tree */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_hyper_move_helper); /* Sanity check */ assert(spans); assert(offset); /* Check if we've already set this down span tree */ if(spans->scratch!=(H5S_hyper_span_info_t *)~((size_t)NULL)) { /* Set the tree's scratch pointer */ spans->scratch=(H5S_hyper_span_info_t *)~((size_t)NULL); /* Get the span lists for each span in this tree */ span=spans->head; /* Iterate over the spans in tree */ while(span!=NULL) { /* Adjust span location */ assert(*offset>=0); span->high=*offset+(span->high-span->low); span->low=*offset; /* Recursively move spans in next dimension down */ if(span->down!=NULL) H5S_hyper_move_helper(span->down,offset+1); /* Advance to next span in this dimension */ span=span->next; } /* end while */ } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED); } /* H5S_hyper_move_helper() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_move PURPOSE Move a hyperslab selection by to an offset USAGE herr_t H5S_hyper_move(space,offset) H5S_t *space; IN/OUT: Pointer to dataspace to move const hssize_t *offset; IN: Offset to move to RETURNS Non-negative on success, negative on failure DESCRIPTION Moves a hyperslab selection to a new offset. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5S_hyper_move(H5S_t *space, const hssize_t *offset) { unsigned u; /* Local index variable */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5S_hyper_move); assert(space); assert(offset); /* Move to the offset with the "regular" coordinates, if they exist */ if(space->select.sel_info.hslab->diminfo_valid) { for(u=0; uextent.rank; u++) { assert(offset[u]>=0); space->select.sel_info.hslab->opt_diminfo[u].start=offset[u]; } /* end for */ } /* end if */ /* Subtract the offset from the span tree coordinates, if they exist */ if(space->select.sel_info.hslab->span_lst) { if(H5S_hyper_move_helper(space->select.sel_info.hslab->span_lst,offset)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADSELECT, FAIL, "can't perform hyperslab offset movement"); /* Reset the scratch pointers for the next routine which needs them */ if(H5S_hyper_span_scratch(space->select.sel_info.hslab->span_lst,NULL)==FAIL) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "can't reset hyperslab scratch pointer"); } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_hyper_move() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_normalize_offset PURPOSE "Normalize" a hyperslab selection by adjusting it's coordinates by the amount of the selection offset. USAGE herr_t H5S_hyper_normalize_offset(space, old_offset) H5S_t *space; IN/OUT: Pointer to dataspace to move hssize_t *old_offset; OUT: Pointer to space to store old offset RETURNS Non-negative on success, negative on failure DESCRIPTION Copies the current selection offset into the array provided, then inverts the selection offset, subtracts the offset from the hyperslab selection and resets the offset to zero. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5S_hyper_normalize_offset(H5S_t *space, hssize_t *old_offset) { unsigned u; /* Local index variable */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5S_hyper_normalize_offset); assert(space); /* Check for 'all' selection, instead of a hyperslab selection */ /* (Technically, this check shouldn't be in the "hyperslab" routines...) */ if(H5S_GET_SELECT_TYPE(space)==H5S_SEL_HYPERSLABS) { /* Copy & invert the selection offset */ for(u=0; uextent.rank; u++) { old_offset[u] = space->select.offset[u]; space->select.offset[u] = -space->select.offset[u]; } /* end for */ /* Call the existing 'adjust' routine */ if(H5S_hyper_adjust_s(space, space->select.offset)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADSELECT, FAIL, "can't perform hyperslab normalization"); /* Zero out the selection offset */ HDmemset(space->select.offset, 0, sizeof(hssize_t) * space->extent.rank); } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_hyper_normalize_offset() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_denormalize_offset PURPOSE "Denormalize" a hyperslab selection by reverse adjusting it's coordinates by the amount of the former selection offset. USAGE herr_t H5S_hyper_normalize_offset(space, old_offset) H5S_t *space; IN/OUT: Pointer to dataspace to move hssize_t *old_offset; IN: Pointer to old offset array RETURNS Non-negative on success, negative on failure DESCRIPTION Subtracts the old offset from the current selection (canceling out the effect of the "normalize" routine), then restores the old offset into the dataspace. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5S_hyper_denormalize_offset(H5S_t *space, const hssize_t *old_offset) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5S_hyper_denormalize_offset); assert(space); /* Check for 'all' selection, instead of a hyperslab selection */ /* (Technically, this check shouldn't be in the "hyperslab" routines...) */ if(H5S_GET_SELECT_TYPE(space)==H5S_SEL_HYPERSLABS) { /* Call the existing 'adjust' routine */ if(H5S_hyper_adjust_s(space, old_offset)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADSELECT, FAIL, "can't perform hyperslab normalization"); /* Copy the selection offset over */ HDmemcpy(space->select.offset, old_offset, sizeof(hssize_t) * space->extent.rank); } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_hyper_denormalize_offset() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_append_span PURPOSE Create a new span and append to span list USAGE herr_t H5S_hyper_append_span(prev_span, span_tree, low, high, down, next) H5S_hyper_span_t **prev_span; IN/OUT: Pointer to previous span in list H5S_hyper_span_info_t **span_tree; IN/OUT: Pointer to span tree to append to hsize_t low, high; IN: Low and high bounds for new span node H5S_hyper_span_info_t *down; IN: Down span tree for new node H5S_hyper_span_t *next; IN: Next span for new node RETURNS Non-negative on success, negative on failure DESCRIPTION Create a new span node and append to a span list. Update the previous span in the list also. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_hyper_append_span (H5S_hyper_span_t **prev_span, H5S_hyper_span_info_t ** span_tree, hsize_t low, hsize_t high, H5S_hyper_span_info_t *down, H5S_hyper_span_t *next) { H5S_hyper_span_t *new_span; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5S_hyper_append_span); assert(prev_span); assert(span_tree); /* Check for adding first node to merged spans */ if(*prev_span==NULL) { /* Allocate new span node to append to list */ if((new_span = H5S_hyper_new_span(low,high,down,next))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span"); /* Make first node in span list */ /* Check that we haven't already allocated a span tree */ assert(*span_tree==NULL); /* Allocate a new span_info node */ if((*span_tree = H5FL_MALLOC(H5S_hyper_span_info_t))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span"); /* Set the span tree's basic information */ (*span_tree)->count=1; (*span_tree)->scratch=NULL; (*span_tree)->head=new_span; /* Update previous merged span */ *prev_span=new_span; } /* end if */ /* Merge or append to existing merged spans list */ else { /* Check if span can just extend the previous merged span */ if((((*prev_span)->high+1)==low) && H5S_hyper_cmp_spans(down,(*prev_span)->down)==TRUE) { /* Extend previous merged span to include new high bound */ (*prev_span)->high=high; (*prev_span)->nelem+=(high-low)+1; } /* end if */ else { /* Allocate new span node to append to list */ if((new_span = H5S_hyper_new_span(low,high,down,next))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span"); /* Check if there is actually a down span */ if(new_span->down) { /* Check if the down spans for the new span node are the same as the previous span node */ if(H5S_hyper_cmp_spans(new_span->down,(*prev_span)->down)==TRUE) { /* Release the down span for the new node */ H5S_hyper_free_span_info(new_span->down); /* Point the new node's down span at the previous node's down span */ new_span->down=(*prev_span)->down; /* Increment the reference count to the shared down span */ new_span->down->count++; } /* end if */ } /* end if */ /* Indicate elements from previous span */ new_span->pstride=low-(*prev_span)->low; /* Append to end of merged spans list */ (*prev_span)->next=new_span; *prev_span=new_span; } /* end else */ } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_hyper_append_span() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_clip_spans PURPOSE Clip a new span tree against the current spans in the hyperslab selection USAGE herr_t H5S_hyper_clip_spans(span_a, span_b, a_not_b, a_and_b, b_not_a) H5S_hyper_span_t *a_spans; IN: Span tree 'a' to clip with. H5S_hyper_span_t *b_spans; IN: Span tree 'b' to clip with. H5S_hyper_span_t **a_not_b; OUT: Span tree of 'a' hyperslab spans which doesn't overlap with 'b' hyperslab spans. H5S_hyper_span_t **a_and_b; OUT: Span tree of 'a' hyperslab spans which overlaps with 'b' hyperslab spans. H5S_hyper_span_t **b_not_a; OUT: Span tree of 'b' hyperslab spans which doesn't overlap with 'a' hyperslab spans. RETURNS non-negative on success, negative on failure DESCRIPTION Clip one span tree ('a') against another span tree ('b'). Creates span trees for the area defined by the 'a' span tree which does not overlap the 'b' span tree, the area defined by the overlap of the 'a' hyperslab span tree and the 'b' span tree, and the area defined by the 'b' hyperslab span tree which does not overlap the 'a' span tree. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_hyper_clip_spans (H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_spans, H5S_hyper_span_info_t **a_not_b, H5S_hyper_span_info_t **a_and_b, H5S_hyper_span_info_t **b_not_a) { H5S_hyper_span_t *span_a; /* Pointer to a node in span tree 'a' */ H5S_hyper_span_t *span_b; /* Pointer to a node in span tree 'b' */ H5S_hyper_span_t *tmp_span; /* Temporary pointer to new span */ H5S_hyper_span_t *last_a_not_b; /* Pointer to previous node in span tree 'a_not_b' */ H5S_hyper_span_t *last_a_and_b; /* Pointer to previous node in span tree 'a_and_b' */ H5S_hyper_span_t *last_b_not_a; /* Pointer to previous node in span tree 'b_not_a' */ H5S_hyper_span_info_t *down_a_not_b; /* Temporary pointer to a_not_b span tree of down spans for overlapping nodes */ H5S_hyper_span_info_t *down_a_and_b; /* Temporary pointer to a_and_b span tree of down spans for overlapping nodes */ H5S_hyper_span_info_t *down_b_not_a; /* Temporary pointer to b_and_a span tree of down spans for overlapping nodes */ unsigned recover_a, recover_b; /* Flags to indicate when to recover temporary spans */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5S_hyper_clip_spans); /* Check args */ assert (a_spans); assert (b_spans); assert (a_not_b); assert (a_and_b); assert (b_not_a); /* Check if both span trees are not defined */ if(a_spans==NULL && b_spans==NULL) { *a_not_b=NULL; *a_and_b=NULL; *b_not_a=NULL; } /* end if */ /* If span 'a' is not defined, but 'b' is, copy 'b' and set the other return span trees to empty */ else if(a_spans==NULL) { *a_not_b=NULL; *a_and_b=NULL; if((*b_not_a=H5S_hyper_copy_span(b_spans))==NULL) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOPY, FAIL, "can't copy hyperslab span tree"); } /* end if */ /* If span 'b' is not defined, but 'a' is, copy 'a' and set the other return span trees to empty */ else if(b_spans==NULL) { if((*a_not_b=H5S_hyper_copy_span(a_spans))==NULL) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOPY, FAIL, "can't copy hyperslab span tree"); *a_and_b=NULL; *b_not_a=NULL; } /* end if */ /* If span 'a' and 'b' are both defined, calculate the proper span trees */ else { /* Check if both span trees completely overlap */ if(H5S_hyper_cmp_spans(a_spans,b_spans)==TRUE) { *a_not_b=NULL; if((*a_and_b=H5S_hyper_copy_span(a_spans))==NULL) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOPY, FAIL, "can't copy hyperslab span tree"); *b_not_a=NULL; } /* end if */ else { /* Get the pointers to the new and old span lists */ span_a=a_spans->head; span_b=b_spans->head; /* Set the pointer to the previous spans */ last_a_not_b=NULL; last_a_and_b=NULL; last_b_not_a=NULL; /* No spans to recover yet */ recover_a=recover_b=0; /* Work through the list of spans in the new list */ while(span_a!=NULL && span_b!=NULL) { /* Check if span 'a' is completely before span 'b' */ /* AAAAAAA */ /* <-----------------------------------> */ /* BBBBBBBBBB */ if(span_a->highlow) { /* Copy span 'a' and add to a_not_b list */ /* Merge/add span 'a' with/to a_not_b list */ if(H5S_hyper_append_span(&last_a_not_b,a_not_b,span_a->low,span_a->high,span_a->down,NULL)==FAIL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span"); /* Advance span 'a', leave span 'b' */ H5S_hyper_recover_span(&recover_a,&span_a,span_a->next); } /* end if */ /* Check if span 'a' overlaps only the lower bound */ /* of span 'b' , up to the upper bound of span 'b' */ /* AAAAAAAAAAAA */ /* <-----------------------------------> */ /* BBBBBBBBBB */ else if(span_a->lowlow && (span_a->high>=span_b->low && span_a->high<=span_b->high)) { /* Split span 'a' into two parts at the low bound of span 'b' */ /* Merge/add lower part of span 'a' with/to a_not_b list */ if(H5S_hyper_append_span(&last_a_not_b,a_not_b,span_a->low,span_b->low-1,span_a->down,NULL)==FAIL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span"); /* Check for overlaps between upper part of span 'a' and lower part of span 'b' */ /* Make certain both spans either have a down span or both don't have one */ assert((span_a->down!=NULL && span_b->down!=NULL) || (span_a->down==NULL && span_b->down==NULL)); /* If there are no down spans, just add the overlapping area to the a_and_b list */ if(span_a->down==NULL) { /* Merge/add overlapped part with/to a_and_b list */ if(H5S_hyper_append_span(&last_a_and_b,a_and_b,span_b->low,span_a->high,NULL,NULL)==FAIL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span"); } /* end if */ /* If there are down spans, check for the overlap in them and add to each appropriate list */ else { /* NULL out the temporary pointers to clipped areas in down spans */ down_a_not_b=NULL; down_a_and_b=NULL; down_b_not_a=NULL; /* Check for overlaps in the 'down spans' of span 'a' & 'b' */ if(H5S_hyper_clip_spans(span_a->down,span_b->down,&down_a_not_b,&down_a_and_b,&down_b_not_a)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't clip hyperslab information"); /* Check for additions to the a_not_b list */ if(down_a_not_b!=NULL) { /* Merge/add overlapped part with/to a_not_b list */ if(H5S_hyper_append_span(&last_a_not_b,a_not_b,span_b->low,span_a->high,down_a_not_b,NULL)==FAIL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span"); /* Release the down span tree generated */ H5S_hyper_free_span_info(down_a_not_b); } /* end if */ /* Check for additions to the a_and_b list */ if(down_a_and_b!=NULL) { /* Merge/add overlapped part with/to a_and_b list */ if(H5S_hyper_append_span(&last_a_and_b,a_and_b,span_b->low,span_a->high,down_a_and_b,NULL)==FAIL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span"); /* Release the down span tree generated */ H5S_hyper_free_span_info(down_a_and_b); } /* end if */ /* Check for additions to the b_not_a list */ if(down_b_not_a!=NULL) { /* Merge/add overlapped part with/to b_not_a list */ if(H5S_hyper_append_span(&last_b_not_a,b_not_a,span_b->low,span_a->high,down_b_not_a,NULL)==FAIL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span"); /* Release the down span tree generated */ H5S_hyper_free_span_info(down_b_not_a); } /* end if */ } /* end else */ /* Split off upper part of span 'b' at upper span of span 'a' */ /* Check if there is actually an upper part of span 'b' to split off */ if(span_a->highhigh) { /* Allocate new span node for upper part of span 'b' */ if((tmp_span = H5S_hyper_new_span(span_a->high+1,span_b->high,span_b->down,span_b->next))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span"); /* Advance span 'a' */ H5S_hyper_recover_span(&recover_a,&span_a,span_a->next); /* Make upper part of span 'b' into new span 'b' */ H5S_hyper_recover_span(&recover_b,&span_b,tmp_span); recover_b=1; } /* end if */ /* No upper part of span 'b' to split */ else { /* Advance both 'a' and 'b' */ H5S_hyper_recover_span(&recover_a,&span_a,span_a->next); H5S_hyper_recover_span(&recover_b,&span_b,span_b->next); } /* end else */ } /* end if */ /* Check if span 'a' overlaps the lower & upper bound */ /* of span 'b' */ /* AAAAAAAAAAAAAAAAAAAAA */ /* <-----------------------------------> */ /* BBBBBBBBBB */ else if(span_a->lowlow && span_a->high>span_b->high) { /* Split off lower part of span 'a' at lower span of span 'b' */ /* Merge/add lower part of span 'a' with/to a_not_b list */ if(H5S_hyper_append_span(&last_a_not_b,a_not_b,span_a->low,span_b->low-1,span_a->down,NULL)==FAIL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span"); /* Check for overlaps between middle part of span 'a' and span 'b' */ /* Make certain both spans either have a down span or both don't have one */ assert((span_a->down!=NULL && span_b->down!=NULL) || (span_a->down==NULL && span_b->down==NULL)); /* If there are no down spans, just add the overlapping area to the a_and_b list */ if(span_a->down==NULL) { /* Merge/add overlapped part with/to a_and_b list */ if(H5S_hyper_append_span(&last_a_and_b,a_and_b,span_b->low,span_b->high,NULL,NULL)==FAIL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span"); } /* end if */ /* If there are down spans, check for the overlap in them and add to each appropriate list */ else { /* NULL out the temporary pointers to clipped areas in down spans */ down_a_not_b=NULL; down_a_and_b=NULL; down_b_not_a=NULL; /* Check for overlaps in the 'down spans' of span 'a' & 'b' */ if(H5S_hyper_clip_spans(span_a->down,span_b->down,&down_a_not_b,&down_a_and_b,&down_b_not_a)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't clip hyperslab information"); /* Check for additions to the a_not_b list */ if(down_a_not_b!=NULL) { /* Merge/add overlapped part with/to a_not_b list */ if(H5S_hyper_append_span(&last_a_not_b,a_not_b,span_b->low,span_b->high,down_a_not_b,NULL)==FAIL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span"); /* Release the down span tree generated */ H5S_hyper_free_span_info(down_a_not_b); } /* end if */ /* Check for additions to the a_and_b list */ if(down_a_and_b!=NULL) { /* Merge/add overlapped part with/to a_and_b list */ if(H5S_hyper_append_span(&last_a_and_b,a_and_b,span_b->low,span_b->high,down_a_and_b,NULL)==FAIL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span"); /* Release the down span tree generated */ H5S_hyper_free_span_info(down_a_and_b); } /* end if */ /* Check for additions to the b_not_a list */ if(down_b_not_a!=NULL) { /* Merge/add overlapped part with/to b_not_a list */ if(H5S_hyper_append_span(&last_b_not_a,b_not_a,span_b->low,span_b->high,down_b_not_a,NULL)==FAIL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span"); /* Release the down span tree generated */ H5S_hyper_free_span_info(down_b_not_a); } /* end if */ } /* end else */ /* Split off upper part of span 'a' at upper span of span 'b' */ /* Allocate new span node for upper part of span 'a' */ if((tmp_span = H5S_hyper_new_span(span_b->high+1,span_a->high,span_a->down,span_a->next))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span"); /* Make upper part of span 'a' the new span 'a' */ H5S_hyper_recover_span(&recover_a,&span_a,tmp_span); recover_a=1; /* Advance span 'b' */ H5S_hyper_recover_span(&recover_b,&span_b,span_b->next); } /* end if */ /* Check if span 'a' is entirely within span 'b' */ /* AAAAA */ /* <-----------------------------------> */ /* BBBBBBBBBB */ else if(span_a->low>=span_b->low && span_a->high<=span_b->high) { /* Split off lower part of span 'b' at lower span of span 'a' */ /* Check if there is actually a lower part of span 'b' to split off */ if(span_a->low>span_b->low) { /* Merge/add lower part of span 'b' with/to b_not_a list */ if(H5S_hyper_append_span(&last_b_not_a,b_not_a,span_b->low,span_a->low-1,span_b->down,NULL)==FAIL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span"); } /* end if */ else { /* Keep going, nothing to split off */ } /* end else */ /* Check for overlaps between span 'a' and midle of span 'b' */ /* Make certain both spans either have a down span or both don't have one */ assert((span_a->down!=NULL && span_b->down!=NULL) || (span_a->down==NULL && span_b->down==NULL)); /* If there are no down spans, just add the overlapping area to the a_and_b list */ if(span_a->down==NULL) { /* Merge/add overlapped part with/to a_and_b list */ if(H5S_hyper_append_span(&last_a_and_b,a_and_b,span_a->low,span_a->high,NULL,NULL)==FAIL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span"); } /* end if */ /* If there are down spans, check for the overlap in them and add to each appropriate list */ else { /* NULL out the temporary pointers to clipped areas in down spans */ down_a_not_b=NULL; down_a_and_b=NULL; down_b_not_a=NULL; /* Check for overlaps in the 'down spans' of span 'a' & 'b' */ if(H5S_hyper_clip_spans(span_a->down,span_b->down,&down_a_not_b,&down_a_and_b,&down_b_not_a)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't clip hyperslab information"); /* Check for additions to the a_not_b list */ if(down_a_not_b!=NULL) { /* Merge/add overlapped part with/to a_not_b list */ if(H5S_hyper_append_span(&last_a_not_b,a_not_b,span_a->low,span_a->high,down_a_not_b,NULL)==FAIL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span"); /* Release the down span tree generated */ H5S_hyper_free_span_info(down_a_not_b); } /* end if */ /* Check for additions to the a_and_b list */ if(down_a_and_b!=NULL) { /* Merge/add overlapped part with/to a_and_b list */ if(H5S_hyper_append_span(&last_a_and_b,a_and_b,span_a->low,span_a->high,down_a_and_b,NULL)==FAIL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span"); /* Release the down span tree generated */ H5S_hyper_free_span_info(down_a_and_b); } /* end if */ /* Check for additions to the b_not_a list */ if(down_b_not_a!=NULL) { /* Merge/add overlapped part with/to b_not_a list */ if(H5S_hyper_append_span(&last_b_not_a,b_not_a,span_a->low,span_a->high,down_b_not_a,NULL)==FAIL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span"); /* Release the down span tree generated */ H5S_hyper_free_span_info(down_b_not_a); } /* end if */ } /* end else */ /* Check if there is actually an upper part of span 'b' to split off */ if(span_a->highhigh) { /* Split off upper part of span 'b' at upper span of span 'a' */ /* Allocate new span node for upper part of spans 'a' */ if((tmp_span = H5S_hyper_new_span(span_a->high+1,span_b->high,span_b->down,span_b->next))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span"); /* And advance span 'a' */ H5S_hyper_recover_span(&recover_a,&span_a,span_a->next); /* Make upper part of span 'b' the new span 'b' */ H5S_hyper_recover_span(&recover_b,&span_b,tmp_span); recover_b=1; } /* end if */ else { /* Advance both span 'a' & span 'b' */ H5S_hyper_recover_span(&recover_a,&span_a,span_a->next); H5S_hyper_recover_span(&recover_b,&span_b,span_b->next); } /* end else */ } /* end if */ /* Check if span 'a' overlaps only the upper bound */ /* of span 'b' */ /* AAAAAAAAAA */ /* <-----------------------------------> */ /* BBBBBBBBBB */ else if((span_a->low>=span_b->low && span_a->low<=span_b->high) && span_a->high>span_b->high) { /* Check if there is actually a lower part of span 'b' to split off */ if(span_a->low>span_b->low) { /* Split off lower part of span 'b' at lower span of span 'a' */ /* Merge/add lower part of span 'b' with/to b_not_a list */ if(H5S_hyper_append_span(&last_b_not_a,b_not_a,span_b->low,span_a->low-1,span_b->down,NULL)==FAIL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span"); } /* end if */ else { /* Keep going, nothing to split off */ } /* end else */ /* Check for overlaps between lower part of span 'a' and upper part of span 'b' */ /* Make certain both spans either have a down span or both don't have one */ assert((span_a->down!=NULL && span_b->down!=NULL) || (span_a->down==NULL && span_b->down==NULL)); /* If there are no down spans, just add the overlapping area to the a_and_b list */ if(span_a->down==NULL) { /* Merge/add overlapped part with/to a_and_b list */ if(H5S_hyper_append_span(&last_a_and_b,a_and_b,span_a->low,span_b->high,NULL,NULL)==FAIL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span"); } /* end if */ /* If there are down spans, check for the overlap in them and add to each appropriate list */ else { /* NULL out the temporary pointers to clipped areas in down spans */ down_a_not_b=NULL; down_a_and_b=NULL; down_b_not_a=NULL; /* Check for overlaps in the 'down spans' of span 'a' & 'b' */ if(H5S_hyper_clip_spans(span_a->down,span_b->down,&down_a_not_b,&down_a_and_b,&down_b_not_a)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't clip hyperslab information"); /* Check for additions to the a_not_b list */ if(down_a_not_b!=NULL) { /* Merge/add overlapped part with/to a_not_b list */ if(H5S_hyper_append_span(&last_a_not_b,a_not_b,span_a->low,span_b->high,down_a_not_b,NULL)==FAIL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span"); /* Release the down span tree generated */ H5S_hyper_free_span_info(down_a_not_b); } /* end if */ /* Check for additions to the a_and_b list */ if(down_a_and_b!=NULL) { /* Merge/add overlapped part with/to a_and_b list */ if(H5S_hyper_append_span(&last_a_and_b,a_and_b,span_a->low,span_b->high,down_a_and_b,NULL)==FAIL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span"); /* Release the down span tree generated */ H5S_hyper_free_span_info(down_a_and_b); } /* end if */ /* Check for additions to the b_not_a list */ if(down_b_not_a!=NULL) { /* Merge/add overlapped part with/to b_not_a list */ if(H5S_hyper_append_span(&last_b_not_a,b_not_a,span_a->low,span_b->high,down_b_not_a,NULL)==FAIL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span"); /* Release the down span tree generated */ H5S_hyper_free_span_info(down_b_not_a); } /* end if */ } /* end else */ /* Split off upper part of span 'a' at upper span of span 'b' */ /* Allocate new span node for upper part of span 'a' */ if((tmp_span = H5S_hyper_new_span(span_b->high+1,span_a->high,span_a->down,span_a->next))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span"); /* Make upper part of span 'a' into new span 'a' */ H5S_hyper_recover_span(&recover_a,&span_a,tmp_span); recover_a=1; /* Advance span 'b' */ H5S_hyper_recover_span(&recover_b,&span_b,span_b->next); } /* end if */ /* span 'a' must be entirely above span 'b' */ /* AAAAA */ /* <-----------------------------------> */ /* BBBBBBBBBB */ else { /* Copy span 'b' and add to b_not_a list */ /* Merge/add span 'b' with/to b_not_a list */ if(H5S_hyper_append_span(&last_b_not_a,b_not_a,span_b->low,span_b->high,span_b->down,NULL)==FAIL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span"); /* Advance span 'b', leave span 'a' */ H5S_hyper_recover_span(&recover_b,&span_b,span_b->next); } /* end else */ } /* end while */ /* Clean up 'a' spans which haven't been covered yet */ if(span_a!=NULL && span_b==NULL) { while(span_a!=NULL) { /* Copy span 'a' and add to a_not_b list */ /* Merge/add span 'a' with/to a_not_b list */ if(H5S_hyper_append_span(&last_a_not_b,a_not_b,span_a->low,span_a->high,span_a->down,NULL)==FAIL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span"); /* Advance to the next 'a' span */ H5S_hyper_recover_span(&recover_a,&span_a,span_a->next); } /* end while */ } /* end if */ /* Clean up 'b' spans which haven't been covered yet */ else if(span_a==NULL && span_b!=NULL) { while(span_b!=NULL) { /* Copy span 'b' and add to b_not_a list */ /* Merge/add span 'b' with/to b_not_a list */ if(H5S_hyper_append_span(&last_b_not_a,b_not_a,span_b->low,span_b->high,span_b->down,NULL)==FAIL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span"); /* Advance to the next 'b' span */ H5S_hyper_recover_span(&recover_b,&span_b,span_b->next); } /* end while */ } /* end if */ } /* end else */ } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_hyper_clip_spans() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_merge_spans_helper PURPOSE Merge two hyperslab span tree together USAGE H5S_hyper_span_info_t *H5S_hyper_merge_spans_helper(a_spans, b_spans) H5S_hyper_span_info_t *a_spans; IN: First hyperslab spans to merge together H5S_hyper_span_info_t *b_spans; IN: Second hyperslab spans to merge together RETURNS Pointer to span tree containing the merged spans on success, NULL on failure DESCRIPTION Merge two sets of hyperslab spans together and return the span tree from the merged set. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static H5S_hyper_span_info_t * H5S_hyper_merge_spans_helper (H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_spans) { H5S_hyper_span_info_t *merged_spans=NULL; /* Pointer to the merged span tree */ H5S_hyper_span_info_t *tmp_spans; /* Pointer to temporary new span tree */ H5S_hyper_span_t *tmp_span; /* Pointer to temporary new span */ H5S_hyper_span_t *span_a; /* Pointer to current span 'a' working on */ H5S_hyper_span_t *span_b; /* Pointer to current span 'b' working on */ H5S_hyper_span_t *prev_span_merge; /* Pointer to previous merged span */ unsigned recover_a, recover_b; /* Flags to indicate when to recover temporary spans */ H5S_hyper_span_info_t *ret_value; FUNC_ENTER_NOAPI_NOINIT(H5S_hyper_merge_spans_helper); /* Make certain both 'a' & 'b' spans have down span trees or neither does */ assert((a_spans!=NULL && b_spans!=NULL) || (a_spans==NULL && b_spans==NULL)); /* Check if the span trees for the 'a' span and the 'b' span are the same */ if(H5S_hyper_cmp_spans(a_spans,b_spans)==TRUE) { if(a_spans==NULL) merged_spans=NULL; else { /* Copy one of the span trees to return */ if((merged_spans=H5S_hyper_copy_span(a_spans))==NULL) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOPY, NULL, "can't copy hyperslab span tree"); } /* end else */ } /* end if */ else { /* Get the pointers to the 'a' and 'b' span lists */ span_a=a_spans->head; span_b=b_spans->head; /* Set the pointer to the previous spans */ prev_span_merge=NULL; /* No spans to recover yet */ recover_a=recover_b=0; /* Work through the list of spans in the new list */ while(span_a!=NULL && span_b!=NULL) { /* Check if the 'a' span is completely before 'b' span */ /* AAAAAAA */ /* <-----------------------------------> */ /* BBBBBBBBBB */ if(span_a->highlow) { /* Merge/add span 'a' with/to the merged spans */ if(H5S_hyper_append_span(&prev_span_merge,&merged_spans,span_a->low,span_a->high,span_a->down,NULL)==FAIL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate hyperslab span"); /* Advance span 'a' */ H5S_hyper_recover_span(&recover_a,&span_a,span_a->next); } /* end if */ /* Check if span 'a' overlaps only the lower bound */ /* of span 'b', up to the upper bound of span 'b' */ /* AAAAAAAAAAAA */ /* <-----------------------------------> */ /* BBBBBBBBBB */ else if(span_a->lowlow && (span_a->high>=span_b->low && span_a->high<=span_b->high)) { /* Check if span 'a' and span 'b' down spans are equal */ if(H5S_hyper_cmp_spans(span_a->down,span_b->down)==TRUE) { /* Merge/add copy of span 'a' with/to merged spans */ if(H5S_hyper_append_span(&prev_span_merge,&merged_spans,span_a->low,span_a->high,span_a->down,NULL)==FAIL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate hyperslab span"); } /* end if */ else { /* Merge/add lower part of span 'a' with/to merged spans */ if(H5S_hyper_append_span(&prev_span_merge,&merged_spans,span_a->low,span_b->low-1,span_a->down,NULL)==FAIL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate hyperslab span"); /* Get merged span tree for overlapped section */ tmp_spans=H5S_hyper_merge_spans_helper(span_a->down,span_b->down); /* Merge/add overlapped section to merged spans */ if(H5S_hyper_append_span(&prev_span_merge,&merged_spans,span_b->low,span_a->high,tmp_spans,NULL)==FAIL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate hyperslab span"); /* Release merged span tree for overlapped section */ H5S_hyper_free_span_info(tmp_spans); } /* end else */ /* Check if there is an upper part of span 'b' */ if(span_a->highhigh) { /* Copy upper part of span 'b' as new span 'b' */ /* Allocate new span node to append to list */ if((tmp_span = H5S_hyper_new_span(span_a->high+1,span_b->high,span_b->down,span_b->next))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate hyperslab span"); /* Advance span 'a' */ H5S_hyper_recover_span(&recover_a,&span_a,span_a->next); /* Set new span 'b' to tmp_span */ H5S_hyper_recover_span(&recover_b,&span_b,tmp_span); recover_b=1; } /* end if */ else { /* Advance both span 'a' & 'b' */ H5S_hyper_recover_span(&recover_a,&span_a,span_a->next); H5S_hyper_recover_span(&recover_b,&span_b,span_b->next); } /* end else */ } /* end if */ /* Check if span 'a' overlaps the lower & upper bound */ /* of span 'b' */ /* AAAAAAAAAAAAAAAAAAAAA */ /* <-----------------------------------> */ /* BBBBBBBBBB */ else if(span_a->lowlow && span_a->high>span_b->high) { /* Check if span 'a' and span 'b' down spans are equal */ if(H5S_hyper_cmp_spans(span_a->down,span_b->down)==TRUE) { /* Merge/add copy of lower & middle parts of span 'a' to merged spans */ if(H5S_hyper_append_span(&prev_span_merge,&merged_spans,span_a->low,span_b->high,span_a->down,NULL)==FAIL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate hyperslab span"); } /* end if */ else { /* Merge/add lower part of span 'a' to merged spans */ if(H5S_hyper_append_span(&prev_span_merge,&merged_spans,span_a->low,span_b->low-1,span_a->down,NULL)==FAIL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate hyperslab span"); /* Get merged span tree for overlapped section */ tmp_spans=H5S_hyper_merge_spans_helper(span_a->down,span_b->down); /* Merge/add overlapped section to merged spans */ if(H5S_hyper_append_span(&prev_span_merge,&merged_spans,span_b->low,span_b->high,tmp_spans,NULL)==FAIL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate hyperslab span"); /* Release merged span tree for overlapped section */ H5S_hyper_free_span_info(tmp_spans); } /* end else */ /* Copy upper part of span 'a' as new span 'a' (remember to free) */ /* Allocate new span node to append to list */ if((tmp_span = H5S_hyper_new_span(span_b->high+1,span_a->high,span_a->down,span_a->next))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate hyperslab span"); /* Set new span 'a' to tmp_span */ H5S_hyper_recover_span(&recover_a,&span_a,tmp_span); recover_a=1; /* Advance span 'b' */ H5S_hyper_recover_span(&recover_b,&span_b,span_b->next); } /* end if */ /* Check if span 'a' is entirely within span 'b' */ /* AAAAA */ /* <-----------------------------------> */ /* BBBBBBBBBB */ else if(span_a->low>=span_b->low && span_a->high<=span_b->high) { /* Check if span 'a' and span 'b' down spans are equal */ if(H5S_hyper_cmp_spans(span_a->down,span_b->down)==TRUE) { /* Merge/add copy of lower & middle parts of span 'b' to merged spans */ if(H5S_hyper_append_span(&prev_span_merge,&merged_spans,span_b->low,span_a->high,span_a->down,NULL)==FAIL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate hyperslab span"); } /* end if */ else { /* Check if there is a lower part of span 'b' */ if(span_a->low>span_b->low) { /* Merge/add lower part of span 'b' to merged spans */ if(H5S_hyper_append_span(&prev_span_merge,&merged_spans,span_b->low,span_a->low-1,span_b->down,NULL)==FAIL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate hyperslab span"); } /* end if */ else { /* No lower part of span 'b' , keep going... */ } /* end else */ /* Get merged span tree for overlapped section */ tmp_spans=H5S_hyper_merge_spans_helper(span_a->down,span_b->down); /* Merge/add overlapped section to merged spans */ if(H5S_hyper_append_span(&prev_span_merge,&merged_spans,span_a->low,span_a->high,tmp_spans,NULL)==FAIL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate hyperslab span"); /* Release merged span tree for overlapped section */ H5S_hyper_free_span_info(tmp_spans); } /* end else */ /* Check if there is an upper part of span 'b' */ if(span_a->highhigh) { /* Copy upper part of span 'b' as new span 'b' (remember to free) */ /* Allocate new span node to append to list */ if((tmp_span = H5S_hyper_new_span(span_a->high+1,span_b->high,span_b->down,span_b->next))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate hyperslab span"); /* Advance span 'a' */ H5S_hyper_recover_span(&recover_a,&span_a,span_a->next); /* Set new span 'b' to tmp_span */ H5S_hyper_recover_span(&recover_b,&span_b,tmp_span); recover_b=1; } /* end if */ else { /* Advance both spans */ H5S_hyper_recover_span(&recover_a,&span_a,span_a->next); H5S_hyper_recover_span(&recover_b,&span_b,span_b->next); } /* end else */ } /* end if */ /* Check if span 'a' overlaps only the upper bound */ /* of span 'b' */ /* AAAAAAAAAA */ /* <-----------------------------------> */ /* BBBBBBBBBB */ else if((span_a->low>=span_b->low && span_a->low<=span_b->high) && span_a->high>span_b->high) { /* Check if span 'a' and span 'b' down spans are equal */ if(H5S_hyper_cmp_spans(span_a->down,span_b->down)==TRUE) { /* Merge/add copy of span 'b' to merged spans if so */ if(H5S_hyper_append_span(&prev_span_merge,&merged_spans,span_b->low,span_b->high,span_b->down,NULL)==FAIL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate hyperslab span"); } /* end if */ else { /* Check if there is a lower part of span 'b' */ if(span_a->low>span_b->low) { /* Merge/add lower part of span 'b' to merged spans */ if(H5S_hyper_append_span(&prev_span_merge,&merged_spans,span_b->low,span_a->low-1,span_b->down,NULL)==FAIL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate hyperslab span"); } /* end if */ else { /* No lower part of span 'b' , keep going... */ } /* end else */ /* Get merged span tree for overlapped section */ tmp_spans=H5S_hyper_merge_spans_helper(span_a->down,span_b->down); /* Merge/add overlapped section to merged spans */ if(H5S_hyper_append_span(&prev_span_merge,&merged_spans,span_a->low,span_b->high,tmp_spans,NULL)==FAIL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate hyperslab span"); /* Release merged span tree for overlapped section */ H5S_hyper_free_span_info(tmp_spans); } /* end else */ /* Copy upper part of span 'a' as new span 'a' */ /* Allocate new span node to append to list */ if((tmp_span = H5S_hyper_new_span(span_b->high+1,span_a->high,span_a->down,span_a->next))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate hyperslab span"); /* Set new span 'a' to tmp_span */ H5S_hyper_recover_span(&recover_a,&span_a,tmp_span); recover_a=1; /* Advance span 'b' */ H5S_hyper_recover_span(&recover_b,&span_b,span_b->next); } /* end if */ /* Span 'a' must be entirely above span 'b' */ /* AAAAA */ /* <-----------------------------------> */ /* BBBBBBBBBB */ else { /* Merge/add span 'b' with the merged spans */ if(H5S_hyper_append_span(&prev_span_merge,&merged_spans,span_b->low,span_b->high,span_b->down,NULL)==FAIL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate hyperslab span"); /* Advance span 'b' */ H5S_hyper_recover_span(&recover_b,&span_b,span_b->next); } /* end else */ } /* end while */ /* Clean up 'a' spans which haven't been added to the list of merged spans */ if(span_a!=NULL && span_b==NULL) { while(span_a!=NULL) { /* Merge/add all 'a' spans into the merged spans */ if(H5S_hyper_append_span(&prev_span_merge,&merged_spans,span_a->low,span_a->high,span_a->down,NULL)==FAIL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate hyperslab span"); /* Advance to next 'a' span, until all processed */ H5S_hyper_recover_span(&recover_a,&span_a,span_a->next); } /* end while */ } /* end if */ /* Clean up 'b' spans which haven't been added to the list of merged spans */ if(span_a==NULL && span_b!=NULL) { while(span_b!=NULL) { /* Merge/add all 'b' spans into the merged spans */ if(H5S_hyper_append_span(&prev_span_merge,&merged_spans,span_b->low,span_b->high,span_b->down,NULL)==FAIL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate hyperslab span"); /* Advance to next 'b' span, until all processed */ H5S_hyper_recover_span(&recover_b,&span_b,span_b->next); } /* end while */ } /* end if */ } /* end else */ /* Set return value */ ret_value=merged_spans; done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_hyper_merge_spans_helper() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_merge_spans PURPOSE Merge new hyperslab spans to existing hyperslab selection USAGE herr_t H5S_hyper_merge_spans(space, new_spans, can_own) H5S_t *space; IN: Dataspace to add new spans to hyperslab selection. H5S_hyper_span_t *new_spans; IN: Span tree of new spans to add to hyperslab selection hbool_t can_own; IN: Flag to indicate that it is OK to point directly to the new spans, instead of copying them. RETURNS non-negative on success, negative on failure DESCRIPTION Add a set of hyperslab spans to an existing hyperslab selection. The new spans are required to be non-overlapping with the existing spans in the dataspace's current hyperslab selection. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_hyper_merge_spans (H5S_t *space, H5S_hyper_span_info_t *new_spans, hbool_t can_own) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_hyper_merge_spans); /* Check args */ assert (space); assert (new_spans); /* If this is the first span tree in the hyperslab selection, just use it */ if(space->select.sel_info.hslab->span_lst==NULL) { if(can_own) space->select.sel_info.hslab->span_lst=new_spans; else space->select.sel_info.hslab->span_lst=H5S_hyper_copy_span(new_spans); } /* end if */ else { H5S_hyper_span_info_t *merged_spans; /* Get the merged spans */ merged_spans=H5S_hyper_merge_spans_helper(space->select.sel_info.hslab->span_lst, new_spans); /* Sanity checking since we started with some spans, we should still have some after the merge */ assert(merged_spans); /* Free the previous spans */ H5S_hyper_free_span_info(space->select.sel_info.hslab->span_lst); /* Point to the new merged spans */ space->select.sel_info.hslab->span_lst=merged_spans; } /* end else */ FUNC_LEAVE_NOAPI(SUCCEED); } /* H5S_hyper_merge_spans() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_spans_nelem PURPOSE Count the number of elements in a span tree USAGE hsize_t H5S_hyper_spans_nelem(spans) const H5S_hyper_span_info_t *spans; IN: Hyperslan span tree to count elements of RETURNS Number of elements in span tree on success; negative on failure DESCRIPTION Counts the number of elements described by the spans in a span tree. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static hsize_t H5S_hyper_spans_nelem (H5S_hyper_span_info_t *spans) { H5S_hyper_span_t *span; /* Hyperslab span */ hsize_t ret_value; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_hyper_spans_nelem); /* Count the number of elements in the span tree */ if(spans==NULL) ret_value=0; else { span=spans->head; ret_value=0; while(span!=NULL) { /* If there are down spans, multiply the size of this span by the total down span elements */ if(span->down!=NULL) ret_value+=span->nelem*H5S_hyper_spans_nelem(span->down); /* If there are no down spans, just count the elements in this span */ else ret_value+=span->nelem; /* Advance to next span */ span=span->next; } /* end while */ } /* end else */ FUNC_LEAVE_NOAPI(ret_value); } /* H5S_hyper_spans_nelem() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_make_spans PURPOSE Create a span tree USAGE H5S_hyper_span_t *H5S_hyper_make_spans(rank, start, stride, count, block) unsigned rank; IN: # of dimensions of the space const hsize_t *start; IN: Starting location of the hyperslabs const hsize_t *stride; IN: Stride from the beginning of one block to the next const hsize_t *count; IN: Number of blocks const hsize_t *block; IN: Size of hyperslab block RETURNS Pointer to new span tree on success, NULL on failure DESCRIPTION Generates a new span tree for the hyperslab parameters specified. Each span tree has a list of the elements spanned in each dimension, with each span node containing a pointer to the list of spans in the next dimension down. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static H5S_hyper_span_info_t * H5S_hyper_make_spans (unsigned rank, const hsize_t *start, const hsize_t *stride, const hsize_t *count, const hsize_t *block) { H5S_hyper_span_info_t *down;/* Pointer to spans in next dimension down */ H5S_hyper_span_t *span; /* New hyperslab span */ H5S_hyper_span_t *last_span;/* Current position in hyperslab span list */ H5S_hyper_span_t *head; /* Head of new hyperslab span list */ hsize_t stride_iter; /* Iterator over the stride values */ int i; /* Counters */ unsigned u; /* Counters */ H5S_hyper_span_info_t *ret_value; FUNC_ENTER_NOAPI_NOINIT(H5S_hyper_make_spans); /* Check args */ assert (rank>0); assert (start); assert (stride); assert (count); assert (block); /* Start creating spans in fastest changing dimension */ down=NULL; for(i=(rank-1); i>=0; i--) { /* Start a new list in this dimension */ head=last_span=NULL; /* Generate all the spans segments for this dimension */ for(u=0, stride_iter=0; ulow=start[i]+stride_iter; span->high=span->low+(block[i]-1); span->nelem=block[i]; span->pstride=stride[i]; span->next=NULL; /* Append to the list of spans in this dimension */ if(head==NULL) head=span; else last_span->next=span; /* Move current pointer */ last_span=span; /* Set the information for the next dimension down's spans, if appropriate */ if(down!=NULL) { span->down=down; down->count++; /* Increment reference count for shared span */ } /* end if */ else { span->down=NULL; } /* end else */ } /* end for */ /* Allocate a span info node */ if((down = H5FL_MALLOC(H5S_hyper_span_info_t))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate hyperslab span"); /* Set the reference count */ down->count=0; /* Reset the scratch pad space */ down->scratch=0; /* Keep the pointer to the next dimension down's completed list */ down->head=head; } /* end for */ /* Indicate that there is a pointer to this tree */ down->count=1; /* Success! Return the head of the list in the slowest changing dimension */ ret_value=down; done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_hyper_make_spans() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_can_rebuild PURPOSE Check if optimized hyperslab information can be recovered USAGE htri_t H5S_hyper_can_rebuild(space) const H5S_t *space; IN: Dataspace to check RETURNS TRUE/FALSE on success, <0 on failure DESCRIPTION Examine the span tree for a hyperslab selection and determine if it can be used to rebuild the start/stride/count/block information for the selection. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS To be able to recover the optimized information, the span tree must conform to span tree able to be generated from a single H5S_SELECT_SET operation. This routine doesn't currently detect strided block situations. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static htri_t H5S_hyper_can_rebuild (const H5S_t *space) { H5S_hyper_span_t *span; /* Current hyperslab span */ htri_t ret_value=TRUE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_hyper_can_rebuild); /* Check args */ assert (space); assert (space->select.sel_info.hslab->span_lst); /* For each level of the span tree check that there is only one span at * that level. */ span=space->select.sel_info.hslab->span_lst->head; while(span!=NULL) { if(span->next!=NULL) HGOTO_DONE(FALSE); if(span->down) span=span->down->head; else break; } /* end while */ done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_hyper_can_rebuild() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_rebuild PURPOSE Recover optimized hyperslab information from span tree USAGE herr_t H5S_hyper_rebuild(space) H5S_t *space; IN: Dataspace to rebuild optimized selection within RETURNS Non-negative on success/Negative on failure DESCRIPTION Use the span tree information to recover the optimized form of a hyperslab selection. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS The recovered optimized information will be similar to that generated from a single H5S_SELECT_SET operation. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_hyper_rebuild (H5S_t *space) { H5S_hyper_dim_t *diminfo; /* Per-dimension info for the selection */ H5S_hyper_dim_t *app_diminfo; /* "Application view" per-dimension for the selection */ H5S_hyper_span_t *span; /* Current hyperslab span */ unsigned curr_dim; /* Current dimension being worked on */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_hyper_rebuild); /* Check args */ assert (space); assert (space->select.sel_info.hslab->span_lst); /* Get head of span list */ span=space->select.sel_info.hslab->span_lst->head; /* Protect against empty tree */ if(span!=NULL) { /* Iterate down the span tree */ curr_dim=0; diminfo=space->select.sel_info.hslab->opt_diminfo; app_diminfo=space->select.sel_info.hslab->app_diminfo; while(span!=NULL) { /* Sanity check */ assert(curr_dimextent.rank); /* Recover the optimized dimension information */ app_diminfo[curr_dim].start = diminfo[curr_dim].start = span->low; app_diminfo[curr_dim].stride = diminfo[curr_dim].stride = 1; app_diminfo[curr_dim].count = diminfo[curr_dim].count = 1; app_diminfo[curr_dim].block = diminfo[curr_dim].block = (span->high-span->low)+1; /* Walk down the span tree */ if(span->down) { span=span->down->head; curr_dim++; } /* end if */ else break; } /* end while */ /* Indicate that the diminfo is valid */ space->select.sel_info.hslab->diminfo_valid=TRUE; } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED); } /* H5S_hyper_rebuild() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_generate_spans PURPOSE Create span tree for a regular hyperslab selection USAGE herr_t H5S_hyper_generate_spans(space) H5S_t *space; IN/OUT: Pointer to dataspace RETURNS Non-negative on success, negative on failure DESCRIPTION Create a span tree representation of a regular hyperslab selection and add it to the information for the hyperslab selection. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_hyper_generate_spans(H5S_t *space) { hsize_t tmp_start[H5O_LAYOUT_NDIMS]; /* Temporary start information */ hsize_t tmp_stride[H5O_LAYOUT_NDIMS]; /* Temporary stride information */ hsize_t tmp_count[H5O_LAYOUT_NDIMS]; /* Temporary count information */ hsize_t tmp_block[H5O_LAYOUT_NDIMS]; /* Temporary block information */ unsigned u; /* Counter */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5S_hyper_generate_spans); assert(space); assert(H5S_GET_SELECT_TYPE(space)==H5S_SEL_HYPERSLABS); /* Get the diminfo */ for(u=0; uextent.rank; u++) { tmp_start[u]=space->select.sel_info.hslab->opt_diminfo[u].start; tmp_stride[u]=space->select.sel_info.hslab->opt_diminfo[u].stride; tmp_count[u]=space->select.sel_info.hslab->opt_diminfo[u].count; tmp_block[u]=space->select.sel_info.hslab->opt_diminfo[u].block; } /* end for */ /* Build the hyperslab information also */ if(H5S_generate_hyperslab (space, H5S_SELECT_SET, tmp_start, tmp_stride, tmp_count, tmp_block)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't generate hyperslabs"); done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_hyper_generate_spans() */ /*------------------------------------------------------------------------- * Function: H5S_generate_hyperlab * * Purpose: Generate hyperslab information from H5S_select_hyperslab() * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol (split from HS_select_hyperslab()). * Tuesday, September 12, 2000 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5S_generate_hyperslab (H5S_t *space, H5S_seloper_t op, const hsize_t start[], const hsize_t stride[], const hsize_t count[], const hsize_t block[]) { H5S_hyper_span_info_t *new_spans=NULL; /* Span tree for new hyperslab */ H5S_hyper_span_info_t *a_not_b=NULL; /* Span tree for hyperslab spans in old span tree and not in new span tree */ H5S_hyper_span_info_t *a_and_b=NULL; /* Span tree for hyperslab spans in both old and new span trees */ H5S_hyper_span_info_t *b_not_a=NULL; /* Span tree for hyperslab spans in new span tree and not in old span tree */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5S_generate_hyperslab); /* Check args */ assert(space); assert(op>H5S_SELECT_NOOP && opextent.rank,start,stride,count,block))==NULL) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't create hyperslab information"); /* Generate list of blocks to add/remove based on selection operation */ if(op==H5S_SELECT_SET) { /* Add new spans to current selection */ if(H5S_hyper_merge_spans(space,new_spans,TRUE)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslabs"); /* Set the number of elements in current selection */ space->select.num_elem=H5S_hyper_spans_nelem(new_spans); /* Indicate that the new_spans are owned */ new_spans=NULL; } /* end if */ else { hbool_t updated_spans = FALSE; /* Whether the spans in the selection were modified */ /* Generate lists of spans which overlap and don't overlap */ if(H5S_hyper_clip_spans(space->select.sel_info.hslab->span_lst,new_spans,&a_not_b,&a_and_b,&b_not_a)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't clip hyperslab information"); switch(op) { case H5S_SELECT_OR: /* Add any new spans from b_not_a to current selection */ if(b_not_a!=NULL) { if(H5S_hyper_merge_spans(space,b_not_a,FALSE)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslabs"); /* Update the number of elements in current selection */ space->select.num_elem+=H5S_hyper_spans_nelem(b_not_a); /* Indicate that the spans were updated */ updated_spans = TRUE; } /* end if */ break; case H5S_SELECT_AND: /* Free the current selection */ if(H5S_hyper_free_span_info(space->select.sel_info.hslab->span_lst)<0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "failed to release hyperslab spans"); space->select.sel_info.hslab->span_lst=NULL; /* Reset the number of items in selection */ space->select.num_elem=0; /* Check if there are any overlapped selections */ if(a_and_b!=NULL) { if(H5S_hyper_merge_spans(space,a_and_b,TRUE)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslabs"); /* Update the number of elements in current selection */ space->select.num_elem=H5S_hyper_spans_nelem(a_and_b); /* Indicate that the a_and_b spans are owned */ a_and_b=NULL; /* Indicate that the spans were updated */ updated_spans = TRUE; } /* end if */ break; case H5S_SELECT_XOR: /* Free the current selection */ if(H5S_hyper_free_span_info(space->select.sel_info.hslab->span_lst)<0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "failed to release hyperslab spans"); space->select.sel_info.hslab->span_lst=NULL; /* Reset the number of items in selection */ space->select.num_elem=0; /* Check if there are any non-overlapped selections */ if(a_not_b!=NULL) { if(H5S_hyper_merge_spans(space,a_not_b,FALSE)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslabs"); /* Update the number of elements in current selection */ space->select.num_elem=H5S_hyper_spans_nelem(a_not_b); /* Indicate that the spans were updated */ updated_spans = TRUE; } /* end if */ if(b_not_a!=NULL) { if(H5S_hyper_merge_spans(space,b_not_a,FALSE)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslabs"); /* Update the number of elements in current selection */ space->select.num_elem+=H5S_hyper_spans_nelem(b_not_a); /* Indicate that the spans were updated */ updated_spans = TRUE; } /* end if */ break; case H5S_SELECT_NOTB: /* Free the current selection */ if(H5S_hyper_free_span_info(space->select.sel_info.hslab->span_lst)<0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "failed to release hyperslab spans"); space->select.sel_info.hslab->span_lst=NULL; /* Reset the number of items in selection */ space->select.num_elem=0; /* Check if there are any non-overlapped selections */ if(a_not_b!=NULL) { if(H5S_hyper_merge_spans(space,a_not_b,TRUE)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslabs"); /* Update the number of elements in current selection */ space->select.num_elem=H5S_hyper_spans_nelem(a_not_b); /* Indicate that the a_not_b are owned */ a_not_b=NULL; /* Indicate that the spans were updated */ updated_spans = TRUE; } /* end if */ break; case H5S_SELECT_NOTA: /* Free the current selection */ if(H5S_hyper_free_span_info(space->select.sel_info.hslab->span_lst)<0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "failed to release hyperslab spans"); space->select.sel_info.hslab->span_lst=NULL; /* Reset the number of items in selection */ space->select.num_elem=0; /* Check if there are any non-overlapped selections */ if(b_not_a!=NULL) { if(H5S_hyper_merge_spans(space,b_not_a,TRUE)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslabs"); /* Update the number of elements in current selection */ space->select.num_elem=H5S_hyper_spans_nelem(b_not_a); /* Indicate that the b_not_a are owned */ b_not_a=NULL; /* Indicate that the spans were updated */ updated_spans = TRUE; } /* end if */ break; default: HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation"); } /* end switch */ /* Free the hyperslab trees generated from the clipping algorithm */ if(a_not_b) H5S_hyper_free_span_info(a_not_b); if(a_and_b) H5S_hyper_free_span_info(a_and_b); if(b_not_a) H5S_hyper_free_span_info(b_not_a); /* Check if the resulting hyperslab span tree is empty */ if(space->select.sel_info.hslab->span_lst==NULL) { H5S_hyper_span_info_t *spans; /* Empty hyperslab span tree */ /* Sanity check */ assert(space->select.num_elem==0); /* Allocate a span info node */ if((spans = H5FL_MALLOC(H5S_hyper_span_info_t))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span"); /* Set the reference count */ spans->count=1; /* Reset the scratch pad space */ spans->scratch=0; /* Set to empty tree */ spans->head=NULL; /* Set pointer to empty span tree */ space->select.sel_info.hslab->span_lst=spans; } /* end if */ else { /* Check if we updated the spans */ if(updated_spans) { htri_t status; /* Status from internal calls */ /* Check if the resulting hyperslab span tree can be used to re-build * "optimized" start/stride/count/block information. */ status=H5S_hyper_can_rebuild(space); if(status<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOUNT, FAIL, "can't check for rebuilding hyperslab info"); if(status>0) if(H5S_hyper_rebuild(space)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOUNT, FAIL, "can't rebuild hyperslab info"); } /* end if */ } /* end else */ } /* end else */ done: /* Free the new spans */ if(new_spans!=NULL) if(H5S_hyper_free_span_info(new_spans)<0) HDONE_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "failed to release temporary hyperslab spans"); FUNC_LEAVE_NOAPI(ret_value); } /* end H5S_generate_hyperslab() */ /*------------------------------------------------------------------------- * Function: H5S_select_hyperslab * * Purpose: Internal version of H5Sselect_hyperslab(). * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Wednesday, January 10, 2001 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op, const hsize_t start[], const hsize_t *stride, const hsize_t count[], const hsize_t *block) { hsize_t int_stride[H5O_LAYOUT_NDIMS]; /* Internal storage for stride information */ hsize_t int_count[H5O_LAYOUT_NDIMS]; /* Internal storage for count information */ hsize_t int_block[H5O_LAYOUT_NDIMS]; /* Internal storage for block information */ const hsize_t *opt_stride; /* Optimized stride information */ const hsize_t *opt_count; /* Optimized count information */ const hsize_t *opt_block; /* Optimized block information */ unsigned u; /* Counters */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5S_select_hyperslab, FAIL); /* Check args */ assert(space); assert(start); assert(count); assert(op>H5S_SELECT_NOOP && opextent.rank; u++) { /* Check for overlapping hyperslab blocks in new selection. */ if(count[u]>1 && stride[u]extent.rank; u++) { /* contiguous hyperslabs have the block size equal to the stride */ if(stride[u]==block[u]) { int_count[u]=1; int_stride[u]=1; if(block[u]==1) int_block[u]=count[u]; else int_block[u]=block[u]*count[u]; } /* end if */ else { if(count[u]==1) int_stride[u]=1; else { assert(stride[u]>block[u]); int_stride[u]=stride[u]; } /* end else */ int_count[u]=count[u]; int_block[u]=block[u]; } /* end else */ } /* end for */ } /* end else */ /* Fixup operation for non-hyperslab selections */ switch(H5S_GET_SELECT_TYPE(space)) { case H5S_SEL_NONE: /* No elements selected in dataspace */ switch(op) { case H5S_SELECT_SET: /* Select "set" operation */ /* Change "none" selection to hyperslab selection */ break; case H5S_SELECT_OR: /* Binary "or" operation for hyperslabs */ case H5S_SELECT_XOR: /* Binary "xor" operation for hyperslabs */ case H5S_SELECT_NOTA: /* Binary "B not A" operation for hyperslabs */ op=H5S_SELECT_SET; /* Maps to "set" operation when applied to "none" selection */ break; case H5S_SELECT_AND: /* Binary "and" operation for hyperslabs */ case H5S_SELECT_NOTB: /* Binary "A not B" operation for hyperslabs */ HGOTO_DONE(SUCCEED); /* Selection stays "none" */ default: HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation"); } /* end switch */ break; case H5S_SEL_ALL: /* All elements selected in dataspace */ switch(op) { case H5S_SELECT_SET: /* Select "set" operation */ /* Change "all" selection to hyperslab selection */ break; case H5S_SELECT_OR: /* Binary "or" operation for hyperslabs */ HGOTO_DONE(SUCCEED); /* Selection stays "all" */ case H5S_SELECT_AND: /* Binary "and" operation for hyperslabs */ op=H5S_SELECT_SET; /* Maps to "set" operation when applied to "none" selection */ break; case H5S_SELECT_XOR: /* Binary "xor" operation for hyperslabs */ case H5S_SELECT_NOTB: /* Binary "A not B" operation for hyperslabs */ /* Convert current "all" selection to "real" hyperslab selection */ /* Then allow operation to proceed */ { hsize_t tmp_start[H5O_LAYOUT_NDIMS]; /* Temporary start information */ hsize_t tmp_stride[H5O_LAYOUT_NDIMS]; /* Temporary stride information */ hsize_t tmp_count[H5O_LAYOUT_NDIMS]; /* Temporary count information */ hsize_t tmp_block[H5O_LAYOUT_NDIMS]; /* Temporary block information */ /* Fill in temporary information for the dimensions */ for(u=0; uextent.rank; u++) { tmp_start[u]=0; tmp_stride[u]=1; tmp_count[u]=1; tmp_block[u]=space->extent.size[u]; } /* end for */ /* Convert to hyperslab selection */ if(H5S_select_hyperslab(space,H5S_SELECT_SET,tmp_start,tmp_stride,tmp_count,tmp_block)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't convert selection"); } /* end case */ break; case H5S_SELECT_NOTA: /* Binary "B not A" operation for hyperslabs */ /* Convert to "none" selection */ if(H5S_select_none(space)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't convert selection"); HGOTO_DONE(SUCCEED); default: HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation"); } /* end switch */ break; case H5S_SEL_HYPERSLABS: /* Hyperslab operation on hyperslab selection, OK */ break; case H5S_SEL_POINTS: /* Can't combine hyperslab operations and point selections currently */ if(op==H5S_SELECT_SET) /* Allow only "set" operation to proceed */ break; /* Else fall through to error */ default: HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation"); } /* end switch */ if(op==H5S_SELECT_SET) { /* If we are setting a new selection, remove current selection first */ if(H5S_SELECT_RELEASE(space)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release hyperslab"); /* Allocate space for the hyperslab selection information */ if((space->select.sel_info.hslab=H5FL_MALLOC(H5S_hyper_sel_t))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab info"); /* Save the diminfo */ space->select.num_elem=1; for(u=0; uextent.rank; u++) { space->select.sel_info.hslab->app_diminfo[u].start = start[u]; space->select.sel_info.hslab->app_diminfo[u].stride = stride[u]; space->select.sel_info.hslab->app_diminfo[u].count = count[u]; space->select.sel_info.hslab->app_diminfo[u].block = block[u]; space->select.sel_info.hslab->opt_diminfo[u].start = start[u]; space->select.sel_info.hslab->opt_diminfo[u].stride = opt_stride[u]; space->select.sel_info.hslab->opt_diminfo[u].count = opt_count[u]; space->select.sel_info.hslab->opt_diminfo[u].block = opt_block[u]; space->select.num_elem*=(opt_count[u]*opt_block[u]); } /* end for */ /* Indicate that the dimension information is valid */ space->select.sel_info.hslab->diminfo_valid=TRUE; /* Indicate that there's no slab information */ space->select.sel_info.hslab->span_lst=NULL; } /* end if */ else if(op>=H5S_SELECT_OR && op<=H5S_SELECT_NOTA) { /* Sanity check */ assert(H5S_GET_SELECT_TYPE(space)==H5S_SEL_HYPERSLABS); /* Check if there's no hyperslab span information currently */ if(space->select.sel_info.hslab->span_lst==NULL) if(H5S_hyper_generate_spans(space)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "dataspace does not have span tree"); /* Indicate that the regular dimensions are no longer valid */ space->select.sel_info.hslab->diminfo_valid=FALSE; /* Add in the new hyperslab information */ if(H5S_generate_hyperslab (space, op, start, opt_stride, opt_count, opt_block)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't generate hyperslabs"); } /* end if */ else HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation"); /* Set selection type */ space->select.type=H5S_sel_hyper; done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5S_select_hyperslab() */ /*-------------------------------------------------------------------------- NAME H5Sselect_hyperslab PURPOSE Specify a hyperslab to combine with the current hyperslab selection USAGE herr_t H5Sselect_hyperslab(dsid, op, start, stride, count, block) hid_t dsid; IN: Dataspace ID of selection to modify H5S_seloper_t op; IN: Operation to perform on current selection const hsize_t *start; IN: Offset of start of hyperslab const hsize_t *stride; IN: Hyperslab stride const hsize_t *count; IN: Number of blocks included in hyperslab const hsize_t *block; IN: Size of block in hyperslab RETURNS Non-negative on success/Negative on failure DESCRIPTION Combines a hyperslab selection with the current selection for a dataspace. If the current selection is not a hyperslab, it is freed and the hyperslab parameters passed in are combined with the H5S_SEL_ALL hyperslab (ie. a selection composing the entire current extent). If STRIDE or BLOCK is NULL, they are assumed to be set to all '1'. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5Sselect_hyperslab(hid_t space_id, H5S_seloper_t op, const hsize_t start[], const hsize_t stride[], const hsize_t count[], const hsize_t block[]) { H5S_t *space = NULL; /* Dataspace to modify selection of */ unsigned u; /* Local index variable */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Sselect_hyperslab, FAIL); H5TRACE6("e","iSs*h*h*h*h",space_id,op,start,stride,count,block); /* Check args */ if (NULL == (space=H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); if (H5S_SCALAR==H5S_GET_EXTENT_TYPE(space)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hyperslab doesn't support H5S_SCALAR space"); if(start==NULL || count==NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hyperslab not specified"); if(!(op>H5S_SELECT_NOOP && opextent.rank; u++) { if(stride[u]==0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid stride==0 value"); } /* end for */ } /* end if */ if (H5S_select_hyperslab(space, op, start, stride, count, block)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to set hyperslab selection"); done: FUNC_LEAVE_API(ret_value); } /* end H5Sselect_hyperslab() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_get_seq_list_gen PURPOSE Create a list of offsets & lengths for a selection USAGE herr_t H5S_select_hyper_get_file_list_gen(space,iter,maxseq,maxelem,nseq,nelem,off,len) H5S_t *space; IN: Dataspace containing selection to use. H5S_sel_iter_t *iter; IN/OUT: Selection iterator describing last position of interest in selection. size_t maxseq; IN: Maximum number of sequences to generate size_t maxelem; IN: Maximum number of elements to include in the generated sequences size_t *nseq; OUT: Actual number of sequences generated size_t *nelem; OUT: Actual number of elements in sequences generated hsize_t *off; OUT: Array of offsets size_t *len; OUT: Array of lengths RETURNS Non-negative on success/Negative on failure. DESCRIPTION Use the selection in the dataspace to generate a list of byte offsets and lengths for the region(s) selected. Start/Restart from the position in the ITER parameter. The number of sequences generated is limited by the MAXSEQ parameter and the number of sequences actually generated is stored in the NSEQ parameter. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_hyper_get_seq_list_gen(const H5S_t *space,H5S_sel_iter_t *iter, size_t maxseq, size_t maxelem, size_t *nseq, size_t *nelem, hsize_t *off, size_t *len) { H5S_hyper_span_t *curr_span; /* Current hyperslab span node */ H5S_hyper_span_t **ispan; /* Iterator's hyperslab span nodes */ hsize_t slab[H5O_LAYOUT_NDIMS]; /* Cumulative size of each dimension in bytes */ hsize_t acc; /* Accumulator for computing cumulative sizes */ hsize_t loc_off; /* Element offset in the dataspace */ hsize_t last_span_end=0; /* The offset of the end of the last span */ hsize_t *abs_arr; /* Absolute hyperslab span position */ const hssize_t *off_arr; /* Offset within the dataspace extent */ size_t span_size=0; /* Number of bytes in current span to actually process */ size_t io_left; /* Number of elements left to process */ size_t io_bytes_left; /* Number of bytes left to process */ size_t io_used; /* Number of elements processed */ size_t curr_seq=0; /* Number of sequence/offsets stored in the arrays */ size_t elem_size; /* Size of each element iterating over */ int ndims; /* Number of dimensions of dataset */ int fast_dim; /* Rank of the fastest changing dimension for the dataspace */ int curr_dim; /* Current dimension being operated on */ int i; /* Index variable */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_hyper_get_seq_list_gen); /* Check args */ assert(space); assert(iter); assert(maxseq>0); assert(maxelem>0); assert(nseq); assert(nelem); assert(off); assert(len); /* Set the rank of the fastest changing dimension */ ndims=space->extent.rank; fast_dim=(ndims-1); /* Get the pointers to the current span info and span nodes */ curr_span=iter->u.hyp.span[fast_dim]; abs_arr=iter->u.hyp.off; off_arr=space->select.offset; ispan=iter->u.hyp.span; elem_size=iter->elmt_size; /* Set the amount of elements to perform I/O on, etc. */ H5_CHECK_OVERFLOW(iter->elmt_left,hsize_t,size_t); io_left=MIN(maxelem,(size_t)iter->elmt_left); io_bytes_left=io_left*elem_size; /* Compute the cumulative size of dataspace dimensions */ for(i=fast_dim, acc=elem_size; i>=0; i--) { slab[i]=acc; acc*=space->extent.size[i]; } /* end for */ /* Set the offset of the first element iterated on */ for(i=0, loc_off=0; ielmt_left*elem_size)); /* Take care of any partial spans leftover from previous I/Os */ if(abs_arr[fast_dim]!=curr_span->low) { /* Finish the span in the fastest changing dimension */ /* Compute the number of bytes to attempt in this span */ H5_ASSIGN_OVERFLOW(span_size,((curr_span->high-abs_arr[fast_dim])+1)*elem_size,hsize_t,size_t); /* Check number of bytes against upper bounds allowed */ if(span_size>io_bytes_left) span_size=io_bytes_left; /* Add the partial span to the list of sequences */ off[curr_seq]=loc_off; len[curr_seq]=span_size; /* Increment sequence count */ curr_seq++; /* Set the location of the last span's end */ last_span_end=loc_off+span_size; /* Decrement I/O left to perform */ io_bytes_left-=span_size; /* Advance the hyperslab iterator */ /* Check if we are done */ if(io_bytes_left>0) { /* Move to next span in fastest changing dimension */ curr_span=curr_span->next; if(curr_span!=NULL) { /* Move location offset of destination */ loc_off+=(curr_span->low-abs_arr[fast_dim])*elem_size; /* Move iterator for fastest changing dimension */ abs_arr[fast_dim]=curr_span->low; } /* end if */ } /* end if */ else { abs_arr[fast_dim]+=span_size/elem_size; /* Check if we are still within the span */ if(abs_arr[fast_dim]<=curr_span->high) { iter->u.hyp.span[fast_dim]=curr_span; goto partial_done; /* finished with partial span */ } /* end if */ /* If we walked off that span, advance to the next span */ else { /* Advance span in this dimension */ curr_span=curr_span->next; /* Check if we have a valid span in this dimension still */ if(curr_span!=NULL) { /* Reset absolute position */ abs_arr[fast_dim]=curr_span->low; iter->u.hyp.span[fast_dim]=curr_span; goto partial_done; /* finished with partial span */ } /* end if */ } /* end else */ } /* end else */ /* Adjust iterator pointers */ if(curr_span==NULL) { /* Same as code in main loop */ /* Start at the next fastest dim */ curr_dim=fast_dim-1; /* Work back up through the dimensions */ while(curr_dim>=0) { /* Reset the current span */ curr_span=iter->u.hyp.span[curr_dim]; /* Increment absolute position */ abs_arr[curr_dim]++; /* Check if we are still within the span */ if(abs_arr[curr_dim]<=curr_span->high) { break; } /* end if */ /* If we walked off that span, advance to the next span */ else { /* Advance span in this dimension */ curr_span=curr_span->next; /* Check if we have a valid span in this dimension still */ if(curr_span!=NULL) { /* Reset the span in the current dimension */ ispan[curr_dim]=curr_span; /* Reset absolute position */ abs_arr[curr_dim]=curr_span->low; break; } /* end if */ else { /* If we finished the span list in this dimension, decrement the dimension worked on and loop again */ curr_dim--; } /* end else */ } /* end else */ } /* end while */ /* Check if we are finished with the spans in the tree */ if(curr_dim<0) { /* We had better be done with I/O or bad things are going to happen... */ assert(io_bytes_left==0); goto partial_done; /* finished with partial span */ } /* end if */ else { /* Walk back down the iterator positions, reseting them */ while(curr_dimdown); assert(curr_span->down->head); /* Increment current dimension */ curr_dim++; /* Set the new span_info & span for this dimension */ iter->u.hyp.span[curr_dim]=curr_span->down->head; /* Advance span down the tree */ curr_span=curr_span->down->head; /* Reset the absolute offset for the dim */ abs_arr[curr_dim]=curr_span->low; } /* end while */ /* Verify that the curr_span points to the fastest dim */ assert(curr_span==iter->u.hyp.span[fast_dim]); } /* end else */ /* Reset the buffer offset */ for(i=0, loc_off=0; i0 && curr_seqpstride; /* Loop over all the spans in the fastest changing dimension */ while(curr_span!=NULL) { /* Move location offset of destination */ loc_off+=curr_span->pstride; /* Compute the number of elements to attempt in this span */ H5_ASSIGN_OVERFLOW(span_size,curr_span->nelem,hsize_t,size_t); /* Check number of elements against upper bounds allowed */ if(span_size>=io_bytes_left) { /* Trim the number of bytes to output */ span_size=io_bytes_left; io_bytes_left=0; /* COMMON */ /* Store the I/O information for the span */ /* Check if this is appending onto previous sequence */ if(curr_seq>0 && last_span_end==loc_off) len[curr_seq-1]+=span_size; else { off[curr_seq]=loc_off; len[curr_seq]=span_size; /* Increment the number of sequences in arrays */ curr_seq++; } /* end else */ /* Set the location of the last span's end */ last_span_end=loc_off+span_size; /* If the sequence & offset arrays are full, do what? */ if(curr_seq>=maxseq) { /* Break out now, we are finished with sequences */ break; } /* end else */ /* end COMMON */ /* Break out now, we are finished with I/O */ break; } /* end if */ else { /* Decrement I/O left to perform */ io_bytes_left-=span_size; /* COMMON */ /* Store the I/O information for the span */ /* Check if this is appending onto previous sequence */ if(curr_seq>0 && last_span_end==loc_off) len[curr_seq-1]+=span_size; else { off[curr_seq]=loc_off; len[curr_seq]=span_size; /* Increment the number of sequences in arrays */ curr_seq++; } /* end else */ /* Set the location of the last span's end */ last_span_end=loc_off+span_size; /* If the sequence & offset arrays are full, do what? */ if(curr_seq>=maxseq) { /* Break out now, we are finished with sequences */ break; } /* end else */ /* end COMMON */ } /* end else */ /* Move to next span in fastest changing dimension */ curr_span=curr_span->next; } /* end while */ /* Check if we are done */ if(io_bytes_left==0 || curr_seq>=maxseq) { abs_arr[fast_dim]=curr_span->low+(span_size/elem_size); /* Check if we are still within the span */ if(abs_arr[fast_dim]<=curr_span->high) { iter->u.hyp.span[fast_dim]=curr_span; break; } /* end if */ /* If we walked off that span, advance to the next span */ else { /* Advance span in this dimension */ curr_span=curr_span->next; /* Check if we have a valid span in this dimension still */ if(curr_span!=NULL) { /* Reset absolute position */ abs_arr[fast_dim]=curr_span->low; iter->u.hyp.span[fast_dim]=curr_span; break; } /* end if */ } /* end else */ } /* end if */ /* Adjust iterator pointers */ /* Start at the next fastest dim */ curr_dim=fast_dim-1; /* Work back up through the dimensions */ while(curr_dim>=0) { /* Reset the current span */ curr_span=iter->u.hyp.span[curr_dim]; /* Increment absolute position */ abs_arr[curr_dim]++; /* Check if we are still within the span */ if(abs_arr[curr_dim]<=curr_span->high) { break; } /* end if */ /* If we walked off that span, advance to the next span */ else { /* Advance span in this dimension */ curr_span=curr_span->next; /* Check if we have a valid span in this dimension still */ if(curr_span!=NULL) { /* Reset the span in the current dimension */ ispan[curr_dim]=curr_span; /* Reset absolute position */ abs_arr[curr_dim]=curr_span->low; break; } /* end if */ else { /* If we finished the span list in this dimension, decrement the dimension worked on and loop again */ curr_dim--; } /* end else */ } /* end else */ } /* end while */ /* Check if we are finished with the spans in the tree */ if(curr_dim<0) { /* We had better be done with I/O or bad things are going to happen... */ assert(io_bytes_left==0); break; } /* end if */ else { /* Walk back down the iterator positions, reseting them */ while(curr_dimdown); assert(curr_span->down->head); /* Increment current dimension to the next dimension down */ curr_dim++; /* Set the new span for the next dimension down */ iter->u.hyp.span[curr_dim]=curr_span->down->head; /* Advance span down the tree */ curr_span=curr_span->down->head; /* Reset the absolute offset for the dim */ abs_arr[curr_dim]=curr_span->low; } /* end while */ /* Verify that the curr_span points to the fastest dim */ assert(curr_span==iter->u.hyp.span[fast_dim]); } /* end else */ /* Reset the buffer offset */ for(i=0, loc_off=0; ielmt_left-=io_used; /* Set the number of sequences generated */ *nseq=curr_seq; /* Set the number of elements used */ *nelem=io_used; FUNC_LEAVE_NOAPI(SUCCEED); } /* end H5S_hyper_get_seq_list_gen() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_get_seq_list_opt PURPOSE Create a list of offsets & lengths for a selection USAGE herr_t H5S_select_hyper_get_file_list_opt(space,iter,maxseq,maxelem,nseq,nelem,off,len) H5S_t *space; IN: Dataspace containing selection to use. H5S_sel_iter_t *iter; IN/OUT: Selection iterator describing last position of interest in selection. size_t maxseq; IN: Maximum number of sequences to generate size_t maxelem; IN: Maximum number of elements to include in the generated sequences size_t *nseq; OUT: Actual number of sequences generated size_t *nelem; OUT: Actual number of elements in sequences generated hsize_t *off; OUT: Array of offsets size_t *len; OUT: Array of lengths RETURNS Non-negative on success/Negative on failure. DESCRIPTION Use the selection in the dataspace to generate a list of byte offsets and lengths for the region(s) selected. Start/Restart from the position in the ITER parameter. The number of sequences generated is limited by the MAXSEQ parameter and the number of sequences actually generated is stored in the NSEQ parameter. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_hyper_get_seq_list_opt(const H5S_t *space,H5S_sel_iter_t *iter, size_t maxseq, size_t maxelem, size_t *nseq, size_t *nelem, hsize_t *off, size_t *len) { hsize_t *mem_size; /* Size of the source buffer */ hsize_t slab[H5O_LAYOUT_NDIMS]; /* Hyperslab size */ const hssize_t *sel_off; /* Selection offset in dataspace */ hsize_t offset[H5O_LAYOUT_NDIMS]; /* Coordinate offset in dataspace */ hsize_t tmp_count[H5O_LAYOUT_NDIMS];/* Temporary block count */ hsize_t tmp_block[H5O_LAYOUT_NDIMS];/* Temporary block offset */ hsize_t wrap[H5O_LAYOUT_NDIMS]; /* Bytes to wrap around at the end of a row */ hsize_t skip[H5O_LAYOUT_NDIMS]; /* Bytes to skip between blocks */ const H5S_hyper_dim_t *tdiminfo; /* Temporary pointer to diminfo information */ hsize_t fast_dim_start, /* Local copies of fastest changing dimension info */ fast_dim_stride, fast_dim_block, fast_dim_offset; size_t fast_dim_buf_off; /* Local copy of amount to move fastest dimension buffer offset */ size_t fast_dim_count; /* Number of blocks left in fastest changing dimension */ size_t tot_blk_count; /* Total number of blocks left to output */ size_t act_blk_count; /* Actual number of blocks to output */ size_t total_rows; /* Total number of entire rows to output */ size_t curr_rows; /* Current number of entire rows to output */ int fast_dim; /* Rank of the fastest changing dimension for the dataspace */ int temp_dim; /* Temporary rank holder */ int ndims; /* Number of dimensions of dataset */ hsize_t acc; /* Accumulator */ hsize_t loc; /* Coordinate offset */ int i; /* Local index variable */ size_t curr_seq=0; /* Current sequence being operated on */ size_t actual_elem; /* The actual number of elements to count */ size_t actual_bytes;/* The actual number of bytes to copy */ size_t nelmts; /* Starting number of elements */ size_t io_left; /* The number of elements left in I/O operation */ size_t start_io_left; /* The initial number of elements left in I/O operation */ size_t elem_size; /* Size of each element iterating over */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_hyper_get_seq_list_opt); /* Check args */ assert(space); assert(iter); assert(maxseq>0); assert(maxelem>0); assert(nseq); assert(nelem); assert(off); assert(len); /* Set the local copy of the diminfo pointer */ tdiminfo=iter->u.hyp.diminfo; /* Check if this is a "flattened" regular hyperslab selection */ if(iter->u.hyp.iter_rank!=0 && iter->u.hyp.iter_rankextent.rank) { /* Set the aliases for a few important dimension ranks */ ndims=iter->u.hyp.iter_rank; fast_dim=ndims-1; /* Set the local copy of the selection offset */ sel_off=iter->u.hyp.sel_off; /* Set up the pointer to the size of the memory space */ mem_size=iter->u.hyp.size; } /* end if */ else { /* Set the aliases for a few important dimension ranks */ ndims=space->extent.rank; fast_dim=ndims-1; /* Set the local copy of the selection offset */ sel_off=space->select.offset; /* Set up the pointer to the size of the memory space */ mem_size=space->extent.size; } /* end else */ /* initialize row sizes for each dimension */ elem_size=iter->elmt_size; for(i=(ndims-1),acc=elem_size; i>=0; i--) { slab[i]=acc; acc*=mem_size[i]; } /* end for */ /* Calculate the number of elements to sequence through */ H5_CHECK_OVERFLOW(iter->elmt_left,hsize_t,size_t); start_io_left=io_left=MIN((size_t)iter->elmt_left,maxelem); /* Check if we stopped in the middle of a sequence of elements */ if((iter->u.hyp.off[fast_dim]-tdiminfo[fast_dim].start)%tdiminfo[fast_dim].stride!=0 || ((iter->u.hyp.off[fast_dim]!=tdiminfo[fast_dim].start) && tdiminfo[fast_dim].count==1)) { size_t leftover; /* The number of elements left over from the last sequence */ /* Calculate the number of elements left in the sequence */ if(tdiminfo[fast_dim].count==1) { H5_ASSIGN_OVERFLOW(leftover, tdiminfo[fast_dim].block-(iter->u.hyp.off[fast_dim]-tdiminfo[fast_dim].start) ,hsize_t,size_t); } /* end if */ else { H5_ASSIGN_OVERFLOW(leftover, tdiminfo[fast_dim].block-((iter->u.hyp.off[fast_dim]-tdiminfo[fast_dim].start)%tdiminfo[fast_dim].stride) ,hsize_t,size_t); } /* end else */ /* Make certain that we don't write too many */ actual_elem=MIN(leftover,io_left); /* Compute the initial buffer offset */ for(i=0,loc=0; iu.hyp.off[i]+sel_off[i])*slab[i]; /* Add a new sequence */ off[curr_seq]=loc; H5_ASSIGN_OVERFLOW(len[curr_seq],actual_elem*elem_size,hsize_t,size_t); /* Increment sequence count */ curr_seq++; /* Decrement the number of elements left */ io_left -= actual_elem; /* Advance the hyperslab iterator */ H5S_hyper_iter_next(iter,actual_elem); /* Decrement the number of elements left in selection */ iter->elmt_left-=actual_elem; } /* end if */ /* Now that we've cleared the "remainder" of the previous fastest dimension * sequence, we must be at the beginning of a sequence, so use the fancy * algorithm to compute the offsets and run through as many as possible, * until the buffer fills up. */ if(io_left>0 && curr_sequ.hyp.off[i] + sel_off[i]; /* Compute the current "counts" for this location */ for(i=0; iu.hyp.off[i]-tdiminfo[i].start; } /* end if */ else { tmp_count[i] = (iter->u.hyp.off[i]-tdiminfo[i].start)/tdiminfo[i].stride; tmp_block[i] = (iter->u.hyp.off[i]-tdiminfo[i].start)%tdiminfo[i].stride; } /* end else */ } /* end for */ /* Compute the initial buffer offset */ for(i=0,loc=0; i0) { /* Get number of blocks in fastest dimension */ H5_ASSIGN_OVERFLOW(fast_dim_count,tdiminfo[fast_dim].count-tmp_count[fast_dim],hsize_t,size_t); /* Make certain this entire row will fit into buffer */ fast_dim_count=MIN(fast_dim_count,tot_blk_count); /* Number of blocks to sequence over */ act_blk_count=fast_dim_count; /* Loop over all the blocks in the fastest changing dimension */ while(fast_dim_count>0) { /* Store the sequence information */ off[curr_seq]=loc; len[curr_seq]=actual_bytes; /* Increment sequence count */ curr_seq++; /* Increment information to reflect block just processed */ loc+=fast_dim_buf_off; /* Decrement number of blocks */ fast_dim_count--; } /* end while */ /* Decrement number of elements left */ io_left -= actual_elem*act_blk_count; /* Decrement number of blocks left */ tot_blk_count -= act_blk_count; /* Increment information to reflect block just processed */ tmp_count[fast_dim]+=act_blk_count; /* Check if we finished the entire row of blocks */ if(tmp_count[fast_dim]>=tdiminfo[fast_dim].count) { /* Increment offset in destination buffer */ loc += wrap[fast_dim]; /* Increment information to reflect block just processed */ offset[fast_dim]=fast_dim_offset; /* reset the offset in the fastest dimension */ tmp_count[fast_dim]=0; /* Increment the offset and count for the other dimensions */ temp_dim=fast_dim-1; while(temp_dim>=0) { /* Move to the next row in the curent dimension */ offset[temp_dim]++; tmp_block[temp_dim]++; /* If this block is still in the range of blocks to output for the dimension, break out of loop */ if(tmp_block[temp_dim]0) { #define DUFF_GUTS \ /* Store the sequence information */ \ off[curr_seq]=loc; \ len[curr_seq]=actual_bytes; \ \ /* Increment sequence count */ \ curr_seq++; \ \ /* Increment information to reflect block just processed */ \ loc+=fast_dim_buf_off; #ifdef NO_DUFFS_DEVICE /* Loop over all the blocks in the fastest changing dimension */ while(fast_dim_count>0) { DUFF_GUTS /* Decrement number of blocks */ fast_dim_count--; } /* end while */ #else /* NO_DUFFS_DEVICE */ { size_t duffs_index; /* Counting index for Duff's device */ duffs_index = (fast_dim_count + 7) / 8; switch (fast_dim_count % 8) { case 0: do { DUFF_GUTS case 7: DUFF_GUTS case 6: DUFF_GUTS case 5: DUFF_GUTS case 4: DUFF_GUTS case 3: DUFF_GUTS case 2: DUFF_GUTS case 1: DUFF_GUTS } while (--duffs_index > 0); } /* end switch */ } #endif /* NO_DUFFS_DEVICE */ #undef DUFF_GUTS /* Increment offset in destination buffer */ loc += wrap[fast_dim]; /* Increment the offset and count for the other dimensions */ temp_dim=fast_dim-1; while(temp_dim>=0) { /* Move to the next row in the curent dimension */ offset[temp_dim]++; tmp_block[temp_dim]++; /* If this block is still in the range of blocks to output for the dimension, break out of loop */ if(tmp_block[temp_dim]0 && curr_seq0) { /* Store the sequence information */ off[curr_seq]=loc; len[curr_seq]=actual_bytes; /* Increment sequence count */ curr_seq++; /* Increment information to reflect block just processed */ loc+=fast_dim_buf_off; /* Decrement number of blocks */ fast_dim_count--; } /* end while */ /* Decrement number of elements left */ io_left -= actual_elem*tot_blk_count; /* Increment information to reflect block just processed */ offset[fast_dim]+=(fast_dim_stride*tot_blk_count); /* move the offset in the fastest dimension */ /* Handle any leftover, partial blocks in this row */ if(io_left>0 && curr_sequ.hyp.off[i] = offset[i] - sel_off[i]; /* Decrement the number of elements left in selection */ iter->elmt_left-=(nelmts-io_left); } /* end if */ /* Set the number of sequences generated */ *nseq=curr_seq; /* Set the number of bytes used */ *nelem=start_io_left-io_left; FUNC_LEAVE_NOAPI(SUCCEED); } /* end H5S_hyper_get_seq_list_opt() */ /*-------------------------------------------------------------------------- NAME H5S_hyper_get_seq_list PURPOSE Create a list of offsets & lengths for a selection USAGE herr_t H5S_hyper_get_seq_list(space,flags,iter,maxseq,maxelem,nseq,nelem,off,len) H5S_t *space; IN: Dataspace containing selection to use. unsigned flags; IN: Flags for extra information about operation H5S_sel_iter_t *iter; IN/OUT: Selection iterator describing last position of interest in selection. size_t maxseq; IN: Maximum number of sequences to generate size_t maxelem; IN: Maximum number of elements to include in the generated sequences size_t *nseq; OUT: Actual number of sequences generated size_t *nelem; OUT: Actual number of elements in sequences generated hsize_t *off; OUT: Array of offsets size_t *len; OUT: Array of lengths RETURNS Non-negative on success/Negative on failure. DESCRIPTION Use the selection in the dataspace to generate a list of byte offsets and lengths for the region(s) selected. Start/Restart from the position in the ITER parameter. The number of sequences generated is limited by the MAXSEQ parameter and the number of sequences actually generated is stored in the NSEQ parameter. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_hyper_get_seq_list(const H5S_t *space, unsigned UNUSED flags, H5S_sel_iter_t *iter, size_t maxseq, size_t maxelem, size_t *nseq, size_t *nelem, hsize_t *off, size_t *len) { herr_t ret_value; /* return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_hyper_get_seq_list); /* Check args */ assert(space); assert(iter); assert(maxseq>0); assert(maxelem>0); assert(nseq); assert(nelem); assert(off); assert(len); /* Check for the special case of just one H5Sselect_hyperslab call made */ if(space->select.sel_info.hslab->diminfo_valid) /* Use optimized call to generate sequence list */ ret_value=H5S_hyper_get_seq_list_opt(space,iter,maxseq,maxelem,nseq,nelem,off,len); else /* Call the general sequence generator routine */ ret_value=H5S_hyper_get_seq_list_gen(space,iter,maxseq,maxelem,nseq,nelem,off,len); FUNC_LEAVE_NOAPI(ret_value); } /* end H5S_hyper_get_seq_list() */ xdmf-3.0+git20160803/Utilities/hdf5/H5Tvlen.c0000640000175000017500000013202413003006557020326 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Module Info: This module contains the functionality for variable-length * datatypes in the H5T interface. */ #define H5T_PACKAGE /*suppress error about including H5Tpkg */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5T_init_vlen_interface #include "H5private.h" /* Generic Functions */ #include "H5Dprivate.h" /* Dataset functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free Lists */ #include "H5HGprivate.h" /* Global Heaps */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Pprivate.h" /* Property lists */ #include "H5Tpkg.h" /* Datatypes */ /* Local functions */ static htri_t H5T_vlen_set_loc(const H5T_t *dt, H5F_t *f, H5T_vlen_loc_t loc); static herr_t H5T_vlen_reclaim_recurse(void *elem, const H5T_t *dt, H5MM_free_t free_func, void *free_info); static ssize_t H5T_vlen_seq_mem_getlen(const void *_vl); static void * H5T_vlen_seq_mem_getptr(void *_vl); static htri_t H5T_vlen_seq_mem_isnull(const H5F_t *f, void *_vl); static herr_t H5T_vlen_seq_mem_read(H5F_t *f, hid_t dxpl_id, void *_vl, void *_buf, size_t len); static herr_t H5T_vlen_seq_mem_write(H5F_t *f, hid_t dxpl_id, const H5T_vlen_alloc_info_t *vl_alloc_info, void *_vl, void *_buf, void *_bg, size_t seq_len, size_t base_size); static herr_t H5T_vlen_seq_mem_setnull(H5F_t *f, hid_t dxpl_id, void *_vl, void *_bg); static ssize_t H5T_vlen_str_mem_getlen(const void *_vl); static void * H5T_vlen_str_mem_getptr(void *_vl); static htri_t H5T_vlen_str_mem_isnull(const H5F_t *f, void *_vl); static herr_t H5T_vlen_str_mem_read(H5F_t *f, hid_t dxpl_id, void *_vl, void *_buf, size_t len); static herr_t H5T_vlen_str_mem_write(H5F_t *f, hid_t dxpl_id, const H5T_vlen_alloc_info_t *vl_alloc_info, void *_vl, void *_buf, void *_bg, size_t seq_len, size_t base_size); static herr_t H5T_vlen_str_mem_setnull(H5F_t *f, hid_t dxpl_id, void *_vl, void *_bg); static ssize_t H5T_vlen_disk_getlen(const void *_vl); static void * H5T_vlen_disk_getptr(void *_vl); static htri_t H5T_vlen_disk_isnull(const H5F_t *f, void *_vl); static herr_t H5T_vlen_disk_read(H5F_t *f, hid_t dxpl_id, void *_vl, void *_buf, size_t len); static herr_t H5T_vlen_disk_write(H5F_t *f, hid_t dxpl_id, const H5T_vlen_alloc_info_t *vl_alloc_info, void *_vl, void *_buf, void *_bg, size_t seq_len, size_t base_size); static herr_t H5T_vlen_disk_setnull(H5F_t *f, hid_t dxpl_id, void *_vl, void *_bg); /* Local variables */ /* Default settings for variable-length allocation routines */ static H5T_vlen_alloc_info_t H5T_vlen_def_vl_alloc_info ={ H5D_XFER_VLEN_ALLOC_DEF, H5D_XFER_VLEN_ALLOC_INFO_DEF, H5D_XFER_VLEN_FREE_DEF, H5D_XFER_VLEN_FREE_INFO_DEF }; /* Declare extern the free lists for H5T_t's and H5T_shared_t's */ H5FL_EXTERN(H5T_t); H5FL_EXTERN(H5T_shared_t); /*-------------------------------------------------------------------------- NAME H5T_init_vlen_interface -- Initialize interface-specific information USAGE herr_t H5T_init_vlen_interface() RETURNS Non-negative on success/Negative on failure DESCRIPTION Initializes any interface-specific data or routines. (Just calls H5T_init_iterface currently). --------------------------------------------------------------------------*/ static herr_t H5T_init_vlen_interface(void) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_init_vlen_interface) FUNC_LEAVE_NOAPI(H5T_init()) } /* H5T_init_vlen_interface() */ /*------------------------------------------------------------------------- * Function: H5Tvlen_create * * Purpose: Create a new variable-length datatype based on the specified * BASE_TYPE. * * Return: Success: ID of new VL datatype * * Failure: Negative * * Programmer: Quincey Koziol * Thursday, May 20, 1999 * * Modifications: * *------------------------------------------------------------------------- */ hid_t H5Tvlen_create(hid_t base_id) { H5T_t *base = NULL; /*base datatype */ H5T_t *dt = NULL; /*new datatype */ hid_t ret_value; /*return value */ FUNC_ENTER_API(H5Tvlen_create, FAIL) H5TRACE1("i","i",base_id); /* Check args */ if (NULL==(base=H5I_object_verify(base_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an valid base datatype") /* Create up VL datatype */ if ((dt=H5T_vlen_create(base))==NULL) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid VL location") /* Atomize the type */ if ((ret_value=H5I_register(H5I_DATATYPE, dt))<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype") done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5T_vlen_create * * Purpose: Create a new variable-length datatype based on the specified * BASE_TYPE. * * Return: Success: new VL datatype * * Failure: NULL * * Programmer: Quincey Koziol * Tuesday, November 20, 2001 * * Modifications: * *------------------------------------------------------------------------- */ H5T_t * H5T_vlen_create(const H5T_t *base) { H5T_t *dt = NULL; /*new VL datatype */ H5T_t *ret_value; /*return value */ FUNC_ENTER_NOAPI_NOINIT(H5T_vlen_create) /* Check args */ assert(base); /* Build new type */ if(NULL == (dt = H5T_alloc())) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") dt->shared->type = H5T_VLEN; /* * Force conversions (i.e. memory to memory conversions should duplicate * data, not point to the same VL sequences) */ dt->shared->force_conv = TRUE; dt->shared->parent = H5T_copy(base, H5T_COPY_ALL); /* This is a sequence, not a string */ dt->shared->u.vlen.type = H5T_VLEN_SEQUENCE; /* Set up VL information */ if (H5T_vlen_mark(dt, NULL, H5T_VLEN_MEMORY)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid VL location") /* Set return value */ ret_value=dt; done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5T_vlen_set_loc * * Purpose: Sets the location of a VL datatype to be either on disk or in memory * * Return: * One of two values on success: * TRUE - If the location of any vlen types changed * FALSE - If the location of any vlen types is the same * <0 is returned on failure * * Programmer: Quincey Koziol * Friday, June 4, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static htri_t H5T_vlen_set_loc(const H5T_t *dt, H5F_t *f, H5T_vlen_loc_t loc) { htri_t ret_value = 0; /* Indicate that success, but no location change */ FUNC_ENTER_NOAPI_NOINIT(H5T_vlen_set_loc) /* check parameters */ assert(dt); assert(loc>H5T_VLEN_BADLOC && locshared->u.vlen.loc) { /* Indicate that the location changed */ ret_value=TRUE; switch(loc) { case H5T_VLEN_MEMORY: /* Memory based VL datatype */ assert(f==NULL); /* Mark this type as being stored in memory */ dt->shared->u.vlen.loc=H5T_VLEN_MEMORY; if(dt->shared->u.vlen.type==H5T_VLEN_SEQUENCE) { /* size in memory, disk size is different */ dt->shared->size = sizeof(hvl_t); /* Set up the function pointers to access the VL sequence in memory */ dt->shared->u.vlen.getlen=H5T_vlen_seq_mem_getlen; dt->shared->u.vlen.getptr=H5T_vlen_seq_mem_getptr; dt->shared->u.vlen.isnull=H5T_vlen_seq_mem_isnull; dt->shared->u.vlen.read=H5T_vlen_seq_mem_read; dt->shared->u.vlen.write=H5T_vlen_seq_mem_write; dt->shared->u.vlen.setnull=H5T_vlen_seq_mem_setnull; } else if(dt->shared->u.vlen.type==H5T_VLEN_STRING) { /* size in memory, disk size is different */ dt->shared->size = sizeof(char *); /* Set up the function pointers to access the VL string in memory */ dt->shared->u.vlen.getlen=H5T_vlen_str_mem_getlen; dt->shared->u.vlen.getptr=H5T_vlen_str_mem_getptr; dt->shared->u.vlen.isnull=H5T_vlen_str_mem_isnull; dt->shared->u.vlen.read=H5T_vlen_str_mem_read; dt->shared->u.vlen.write=H5T_vlen_str_mem_write; dt->shared->u.vlen.setnull=H5T_vlen_str_mem_setnull; } else { assert(0 && "Invalid VL type"); } /* Reset file ID (since this VL is in memory) */ dt->shared->u.vlen.f=NULL; break; case H5T_VLEN_DISK: /* Disk based VL datatype */ assert(f); /* Mark this type as being stored on disk */ dt->shared->u.vlen.loc=H5T_VLEN_DISK; /* * Size of element on disk is 4 bytes for the length, plus the size * of an address in this file, plus 4 bytes for the size of a heap * ID. Memory size is different */ dt->shared->size = 4 + H5F_SIZEOF_ADDR(f) + 4; /* Set up the function pointers to access the VL information on disk */ /* VL sequences and VL strings are stored identically on disk, so use the same functions */ dt->shared->u.vlen.getlen=H5T_vlen_disk_getlen; dt->shared->u.vlen.getptr=H5T_vlen_disk_getptr; dt->shared->u.vlen.isnull=H5T_vlen_disk_isnull; dt->shared->u.vlen.read=H5T_vlen_disk_read; dt->shared->u.vlen.write=H5T_vlen_disk_write; dt->shared->u.vlen.setnull=H5T_vlen_disk_setnull; /* Set file ID (since this VL is on disk) */ dt->shared->u.vlen.f=f; break; default: HGOTO_ERROR (H5E_DATATYPE, H5E_BADRANGE, FAIL, "invalid VL datatype location") } /* end switch */ /*lint !e788 All appropriate cases are covered */ } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_vlen_set_loc() */ /*------------------------------------------------------------------------- * Function: H5T_vlen_seq_mem_getlen * * Purpose: Retrieves the length of a memory based VL element. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Wednesday, June 2, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static ssize_t H5T_vlen_seq_mem_getlen(const void *_vl) { const hvl_t *vl=(const hvl_t *)_vl; /* Pointer to the user's hvl_t information */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_vlen_seq_mem_getlen) /* check parameters */ assert(vl); FUNC_LEAVE_NOAPI((ssize_t)vl->len) } /* end H5T_vlen_seq_mem_getlen() */ /*------------------------------------------------------------------------- * Function: H5T_vlen_seq_mem_getptr * * Purpose: Retrieves the pointer for a memory based VL element. * * Return: Non-NULL on success/NULL on failure * * Programmer: Quincey Koziol * Saturday, June 12, 2004 * * Modifications: * *------------------------------------------------------------------------- */ static void * H5T_vlen_seq_mem_getptr(void *_vl) { hvl_t *vl=(hvl_t *)_vl; /* Pointer to the user's hvl_t information */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_vlen_seq_mem_getptr) /* check parameters */ assert(vl); FUNC_LEAVE_NOAPI(vl->p) } /* end H5T_vlen_seq_mem_getptr() */ /*------------------------------------------------------------------------- * Function: H5T_vlen_seq_mem_isnull * * Purpose: Checks if a memory sequence is the "null" sequence * * Return: TRUE/FALSE on success/Negative on failure * * Programmer: Quincey Koziol * Saturday, November 8, 2003 * * Modifications: * *------------------------------------------------------------------------- */ /* ARGSUSED */ static htri_t H5T_vlen_seq_mem_isnull(const H5F_t UNUSED *f, void *_vl) { hvl_t *vl=(hvl_t *)_vl; /* Pointer to the user's hvl_t information */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_vlen_seq_mem_isnull) /* check parameters */ assert(vl); FUNC_LEAVE_NOAPI((vl->len==0 || vl->p==NULL) ? TRUE : FALSE) } /* end H5T_vlen_seq_mem_isnull() */ /*------------------------------------------------------------------------- * Function: H5T_vlen_seq_mem_read * * Purpose: "Reads" the memory based VL sequence into a buffer * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Wednesday, June 2, 1999 * * Modifications: * *------------------------------------------------------------------------- */ /* ARGSUSED */ static herr_t H5T_vlen_seq_mem_read(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_vl, void *buf, size_t len) { hvl_t *vl=(hvl_t *)_vl; /* Pointer to the user's hvl_t information */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_vlen_seq_mem_read) /* check parameters */ assert(vl && vl->p); assert(buf); HDmemcpy(buf,vl->p,len); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5T_vlen_seq_mem_read() */ /*------------------------------------------------------------------------- * Function: H5T_vlen_seq_mem_write * * Purpose: "Writes" the memory based VL sequence from a buffer * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Wednesday, June 2, 1999 * * Modifications: * *------------------------------------------------------------------------- */ /* ARGSUSED */ static herr_t H5T_vlen_seq_mem_write(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const H5T_vlen_alloc_info_t *vl_alloc_info, void *_vl, void *buf, void UNUSED *_bg, size_t seq_len, size_t base_size) { hvl_t vl; /* Temporary hvl_t to use during operation */ size_t len; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5T_vlen_seq_mem_write) /* check parameters */ assert(_vl); assert(buf); if(seq_len!=0) { len=seq_len*base_size; /* Use the user's memory allocation routine is one is defined */ if(vl_alloc_info->alloc_func!=NULL) { if(NULL==(vl.p=(vl_alloc_info->alloc_func)(len,vl_alloc_info->alloc_info))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for VL data") } /* end if */ else { /* Default to system malloc */ if(NULL==(vl.p=H5MM_malloc(len))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for VL data") } /* end else */ /* Copy the data into the newly allocated buffer */ HDmemcpy(vl.p,buf,len); } /* end if */ else vl.p=NULL; /* Set the sequence length */ vl.len=seq_len; /* Set pointer in user's buffer with memcpy, to avoid alignment issues */ HDmemcpy(_vl,&vl,sizeof(hvl_t)); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_vlen_seq_mem_write() */ /*------------------------------------------------------------------------- * Function: H5T_vlen_seq_mem_setnull * * Purpose: Sets a VL info object in memory to the "nil" value * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Saturday, November 8, 2003 * * Modifications: * *------------------------------------------------------------------------- */ /* ARGSUSED */ static herr_t H5T_vlen_seq_mem_setnull(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_vl, void UNUSED *_bg) { hvl_t vl; /* Temporary hvl_t to use during operation */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_vlen_seq_mem_setnull) /* check parameters */ assert(_vl); /* Set the "nil" hvl_t */ vl.len=0; vl.p=NULL; /* Set pointer in user's buffer with memcpy, to avoid alignment issues */ HDmemcpy(_vl,&vl,sizeof(hvl_t)); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5T_vlen_seq_mem_setnull() */ /*------------------------------------------------------------------------- * Function: H5T_vlen_str_mem_getlen * * Purpose: Retrieves the length of a memory based VL string. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Wednesday, June 2, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static ssize_t H5T_vlen_str_mem_getlen(const void *_vl) { const char *s=*(const char * const *)_vl; /* Pointer to the user's string information */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_vlen_str_mem_getlen) /* check parameters */ assert(s); FUNC_LEAVE_NOAPI((ssize_t)HDstrlen(s)) } /* end H5T_vlen_str_mem_getlen() */ /*------------------------------------------------------------------------- * Function: H5T_vlen_str_mem_getptr * * Purpose: Retrieves the pointer for a memory based VL string. * * Return: Non-NULL on success/NULL on failure * * Programmer: Quincey Koziol * Saturday, June 12, 2004 * * Modifications: * *------------------------------------------------------------------------- */ static void * H5T_vlen_str_mem_getptr(void *_vl) { char *s=*(char **)_vl; /* Pointer to the user's string information */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_vlen_str_mem_getptr) /* check parameters */ assert(s); FUNC_LEAVE_NOAPI(s) } /* end H5T_vlen_str_mem_getptr() */ /*------------------------------------------------------------------------- * Function: H5T_vlen_str_mem_isnull * * Purpose: Checks if a memory string is a NULL pointer * * Return: TRUE/FALSE on success/Negative on failure * * Programmer: Quincey Koziol * Saturday, November 8, 2003 * * Modifications: * *------------------------------------------------------------------------- */ /* ARGSUSED */ static htri_t H5T_vlen_str_mem_isnull(const H5F_t UNUSED *f, void *_vl) { char *s=*(char **)_vl; /* Pointer to the user's string information */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_vlen_str_mem_isnull) FUNC_LEAVE_NOAPI(s==NULL ? TRUE : FALSE) } /* end H5T_vlen_str_mem_isnull() */ /*------------------------------------------------------------------------- * Function: H5T_vlen_str_mem_read * * Purpose: "Reads" the memory based VL string into a buffer * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Wednesday, June 2, 1999 * * Modifications: * *------------------------------------------------------------------------- */ /* ARGSUSED */ static herr_t H5T_vlen_str_mem_read(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_vl, void *buf, size_t len) { char *s=*(char **)_vl; /* Pointer to the user's hvl_t information */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_vlen_str_mem_read) if(len>0) { /* check parameters */ assert(s); assert(buf); HDmemcpy(buf,s,len); } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5T_vlen_str_mem_read() */ /*------------------------------------------------------------------------- * Function: H5T_vlen_str_mem_write * * Purpose: "Writes" the memory based VL string from a buffer * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Wednesday, June 2, 1999 * * Modifications: * *------------------------------------------------------------------------- */ /* ARGSUSED */ static herr_t H5T_vlen_str_mem_write(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const H5T_vlen_alloc_info_t *vl_alloc_info, void *_vl, void *buf, void UNUSED *_bg, size_t seq_len, size_t base_size) { char *t; /* Pointer to temporary buffer allocated */ size_t len; /* Maximum length of the string to copy */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5T_vlen_str_mem_write) /* check parameters */ assert(buf); /* Use the user's memory allocation routine if one is defined */ if(vl_alloc_info->alloc_func!=NULL) { if(NULL==(t=(vl_alloc_info->alloc_func)((seq_len+1)*base_size,vl_alloc_info->alloc_info))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for VL data") } /* end if */ else { /* Default to system malloc */ if(NULL==(t=H5MM_malloc((seq_len+1)*base_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for VL data") } /* end else */ len=(seq_len*base_size); HDmemcpy(t,buf,len); t[len]='\0'; /* Set pointer in user's buffer with memcpy, to avoid alignment issues */ HDmemcpy(_vl,&t,sizeof(char *)); done: FUNC_LEAVE_NOAPI(ret_value) /*lint !e429 The pointer in 't' has been copied */ } /* end H5T_vlen_str_mem_write() */ /*------------------------------------------------------------------------- * Function: H5T_vlen_str_mem_setnull * * Purpose: Sets a VL info object in memory to the "null" value * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Saturday, November 8, 2003 * * Modifications: * *------------------------------------------------------------------------- */ /* ARGSUSED */ static herr_t H5T_vlen_str_mem_setnull(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_vl, void UNUSED *_bg) { char *t=NULL; /* Pointer to temporary buffer allocated */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_vlen_str_mem_setnull) /* Set pointer in user's buffer with memcpy, to avoid alignment issues */ HDmemcpy(_vl,&t,sizeof(char *)); FUNC_LEAVE_NOAPI(SUCCEED) /*lint !e429 The pointer in 't' has been copied */ } /* end H5T_vlen_str_mem_setnull() */ /*------------------------------------------------------------------------- * Function: H5T_vlen_disk_getlen * * Purpose: Retrieves the length of a disk based VL element. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Wednesday, June 2, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static ssize_t H5T_vlen_disk_getlen(const void *_vl) { const uint8_t *vl=(const uint8_t *)_vl; /* Pointer to the disk VL information */ size_t seq_len; /* Sequence length */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_vlen_disk_getlen) /* check parameters */ assert(vl); UINT32DECODE(vl, seq_len); FUNC_LEAVE_NOAPI((ssize_t)seq_len) } /* end H5T_vlen_disk_getlen() */ /*------------------------------------------------------------------------- * Function: H5T_vlen_disk_getptr * * Purpose: Retrieves the pointer to a disk based VL element. * * Return: Non-NULL on success/NULL on failure * * Programmer: Quincey Koziol * Saturday, June 12, 2004 * * Modifications: * *------------------------------------------------------------------------- */ /* ARGSUSED */ static void * H5T_vlen_disk_getptr(void UNUSED *vl) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_vlen_disk_getptr) /* check parameters */ assert(vl); FUNC_LEAVE_NOAPI(NULL) } /* end H5T_vlen_disk_getptr() */ /*------------------------------------------------------------------------- * Function: H5T_vlen_disk_isnull * * Purpose: Checks if a disk VL info object is the "nil" object * * Return: TRUE/FALSE on success/Negative on failure * * Programmer: Quincey Koziol * Saturday, November 8, 2003 * * Modifications: * *------------------------------------------------------------------------- */ static htri_t H5T_vlen_disk_isnull(const H5F_t *f, void *_vl) { uint8_t *vl=(uint8_t *)_vl; /* Pointer to the disk VL information */ haddr_t addr; /* Sequence's heap address */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_vlen_disk_isnull) /* check parameters */ assert(vl); /* Skip the sequence's length */ vl+=4; /* Get the heap address */ H5F_addr_decode(f,(const uint8_t **)&vl,&addr); FUNC_LEAVE_NOAPI(addr==0 ? TRUE : FALSE) } /* end H5T_vlen_disk_isnull() */ /*------------------------------------------------------------------------- * Function: H5T_vlen_disk_read * * Purpose: Reads the disk based VL element into a buffer * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Wednesday, June 2, 1999 * * Modifications: * *------------------------------------------------------------------------- */ /* ARGSUSED */ static herr_t H5T_vlen_disk_read(H5F_t *f, hid_t dxpl_id, void *_vl, void *buf, size_t UNUSED len) { uint8_t *vl=(uint8_t *)_vl; /* Pointer to the user's hvl_t information */ H5HG_t hobjid; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5T_vlen_disk_read) /* check parameters */ assert(vl); assert(buf); assert(f); /* Skip the length of the sequence */ vl += 4; /* Get the heap information */ H5F_addr_decode(f,(const uint8_t **)&vl,&(hobjid.addr)); INT32DECODE(vl,hobjid.idx); /* Check if this sequence actually has any data */ if(hobjid.addr>0) { /* Read the VL information from disk */ if(H5HG_read(f,dxpl_id,&hobjid,buf)==NULL) HGOTO_ERROR(H5E_DATATYPE, H5E_READERROR, FAIL, "Unable to read VL information") } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_vlen_disk_read() */ /*------------------------------------------------------------------------- * Function: H5T_vlen_disk_write * * Purpose: Writes the disk based VL element from a buffer * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Wednesday, June 2, 1999 * * Modifications: * * Raymond Lu * Thursday, June 26, 2002 * Free heap objects storing old data. * *------------------------------------------------------------------------- */ /* ARGSUSED */ static herr_t H5T_vlen_disk_write(H5F_t *f, hid_t dxpl_id, const H5T_vlen_alloc_info_t UNUSED *vl_alloc_info, void *_vl, void *buf, void *_bg, size_t seq_len, size_t base_size) { uint8_t *vl=(uint8_t *)_vl; /*Pointer to the user's hvl_t information*/ uint8_t *bg=(uint8_t *)_bg; /*Pointer to the old data hvl_t */ H5HG_t hobjid; /* New VL sequence's heap ID */ size_t len; /* Size of new sequence on disk (in bytes) */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5T_vlen_disk_write) /* check parameters */ assert(vl); assert(seq_len==0 || buf); assert(f); /* Free heap object for old data. */ if(bg!=NULL) { H5HG_t bg_hobjid; /* "Background" VL info sequence's ID info */ /* Skip the length of the sequence and heap object ID from background data. */ bg += 4; /* Get heap information */ H5F_addr_decode(f, (const uint8_t **)&bg, &(bg_hobjid.addr)); INT32DECODE(bg, bg_hobjid.idx); /* Free heap object for old data */ if(bg_hobjid.addr>0) { /* Free heap object */ if(H5HG_remove(f, dxpl_id, &bg_hobjid)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "Unable to remove heap object") } /* end if */ } /* end if */ /* Set the length of the sequence */ UINT32ENCODE(vl, seq_len); /* Write the VL information to disk (allocates space also) */ len=(seq_len*base_size); if(H5HG_insert(f,dxpl_id,len,buf,&hobjid)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "Unable to write VL information") /* Encode the heap information */ H5F_addr_encode(f,&vl,hobjid.addr); INT32ENCODE(vl,hobjid.idx); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_vlen_disk_write() */ /*------------------------------------------------------------------------- * Function: H5T_vlen_disk_setnull * * Purpose: Sets a VL info object on disk to the "nil" value * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Saturday, November 8, 2003 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5T_vlen_disk_setnull(H5F_t *f, hid_t dxpl_id, void *_vl, void *_bg) { uint8_t *vl=(uint8_t *)_vl; /*Pointer to the user's hvl_t information*/ uint8_t *bg=(uint8_t *)_bg; /*Pointer to the old data hvl_t */ uint32_t seq_len=0; /* Sequence length */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5T_vlen_disk_setnull) /* check parameters */ assert(f); assert(vl); /* Free heap object for old data. */ if(bg!=NULL) { H5HG_t bg_hobjid; /* "Background" VL info sequence's ID info */ /* Skip the length of the sequence and heap object ID from background data. */ bg += 4; /* Get heap information */ H5F_addr_decode(f, (const uint8_t **)&bg, &(bg_hobjid.addr)); INT32DECODE(bg, bg_hobjid.idx); /* Free heap object for old data */ if(bg_hobjid.addr>0) { /* Free heap object */ if(H5HG_remove(f, dxpl_id, &bg_hobjid)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "Unable to remove heap object") } /* end if */ } /* end if */ /* Set the length of the sequence */ UINT32ENCODE(vl, seq_len); /* Encode the "nil" heap pointer information */ H5F_addr_encode(f,&vl,(haddr_t)0); INT32ENCODE(vl,0); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_vlen_disk_setnull() */ /*-------------------------------------------------------------------------- NAME H5T_vlen_reclaim_recurse PURPOSE Internal recursive routine to free VL datatypes USAGE herr_t H5T_vlen_reclaim(elem,dt) void *elem; IN/OUT: Pointer to the dataset element H5T_t *dt; IN: Datatype of dataset element RETURNS SUCCEED/FAIL DESCRIPTION Frees any dynamic memory used by VL datatypes in the current dataset element. Performs a recursive depth-first traversal of all compound datatypes to free all VL datatype information allocated by any field. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5T_vlen_reclaim_recurse(void *elem, const H5T_t *dt, H5MM_free_t free_func, void *free_info) { unsigned i; /* local index variable */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT(H5T_vlen_reclaim_recurse) assert(elem); assert(dt); /* Check the datatype of this element */ switch(dt->shared->type) { case H5T_ARRAY: /* Recurse on each element, if the array's base type is array, VL, enum or compound */ if(H5T_IS_COMPLEX(dt->shared->parent->shared->type)) { void *off; /* offset of field */ /* Calculate the offset member and recurse on it */ for(i=0; ishared->u.array.nelem; i++) { off=((uint8_t *)elem)+i*(dt->shared->parent->shared->size); if(H5T_vlen_reclaim_recurse(off,dt->shared->parent,free_func,free_info)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "Unable to free array element") } /* end for */ } /* end if */ break; case H5T_COMPOUND: /* Check each field and recurse on VL, compound, enum or array ones */ for (i=0; ishared->u.compnd.nmembs; i++) { /* Recurse if it's VL, compound, enum or array */ if(H5T_IS_COMPLEX(dt->shared->u.compnd.memb[i].type->shared->type)) { void *off; /* offset of field */ /* Calculate the offset member and recurse on it */ off=((uint8_t *)elem)+dt->shared->u.compnd.memb[i].offset; if(H5T_vlen_reclaim_recurse(off,dt->shared->u.compnd.memb[i].type,free_func,free_info)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "Unable to free compound field") } /* end if */ } /* end for */ break; case H5T_VLEN: /* Recurse on the VL information if it's VL, compound, enum or array, then free VL sequence */ if(dt->shared->u.vlen.type==H5T_VLEN_SEQUENCE) { hvl_t *vl=(hvl_t *)elem; /* Temp. ptr to the vl info */ /* Check if there is anything actually in this sequence */ if(vl->len!=0) { /* Recurse if it's VL, array, enum or compound */ if(H5T_IS_COMPLEX(dt->shared->parent->shared->type)) { void *off; /* offset of field */ /* Calculate the offset of each array element and recurse on it */ while(vl->len>0) { off=((uint8_t *)vl->p)+(vl->len-1)*dt->shared->parent->shared->size; if(H5T_vlen_reclaim_recurse(off,dt->shared->parent,free_func,free_info)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "Unable to free VL element") vl->len--; } /* end while */ } /* end if */ /* Free the VL sequence */ if(free_func!=NULL) (*free_func)(vl->p,free_info); else H5MM_xfree(vl->p); } /* end if */ } else if(dt->shared->u.vlen.type==H5T_VLEN_STRING) { /* Free the VL string */ if(free_func!=NULL) (*free_func)(*(char **)elem,free_info); else H5MM_xfree(*(char **)elem); } else { assert(0 && "Invalid VL type"); } /* end else */ break; default: break; } /* end switch */ /*lint !e788 All appropriate cases are covered */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_vlen_reclaim_recurse() */ /*-------------------------------------------------------------------------- NAME H5T_vlen_reclaim PURPOSE Default method to reclaim any VL data for a buffer element USAGE herr_t H5T_vlen_reclaim(elem,type_id,ndim,point,op_data) void *elem; IN/OUT: Pointer to the dataset element hid_t type_id; IN: Datatype of dataset element unsigned ndim; IN: Number of dimensions in dataspace hsize_t *point; IN: Coordinate location of element in dataspace void *op_data IN: Operator data RETURNS SUCCEED/FAIL DESCRIPTION Frees any dynamic memory used by VL datatypes in the current dataset element. Recursively descends compound datatypes to free all VL datatype information allocated by any field. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ /* ARGSUSED */ herr_t H5T_vlen_reclaim(void *elem, hid_t type_id, unsigned UNUSED ndim, const hsize_t UNUSED *point, void *op_data) { H5T_vlen_alloc_info_t *vl_alloc_info = (H5T_vlen_alloc_info_t *)op_data; /* VL allocation info from iterator */ H5T_t *dt; herr_t ret_value; FUNC_ENTER_NOAPI(H5T_vlen_reclaim, FAIL) assert(elem); assert(vl_alloc_info); assert(H5I_DATATYPE == H5I_get_type(type_id)); /* Check args */ if (NULL==(dt=H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Pull the free function and free info pointer out of the op_data and call the recurse datatype free function */ ret_value=H5T_vlen_reclaim_recurse(elem,dt,vl_alloc_info->free_func,vl_alloc_info->free_info); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_vlen_reclaim() */ /*-------------------------------------------------------------------------- NAME H5T_vlen_get_alloc_info PURPOSE Retrieve allocation info for VL datatypes USAGE herr_t H5T_vlen_get_alloc_info(dxpl_id,vl_alloc_info) hid_t dxpl_id; IN: Data transfer property list to query H5T_vlen_alloc_info_t *vl_alloc_info; IN/OUT: Pointer to VL allocation information to fill RETURNS SUCCEED/FAIL DESCRIPTION Retrieve the VL allocation functions and information from a dataset transfer property list. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS The VL_ALLOC_INFO pointer should point at already allocated memory to place non-default property list info. If a default property list is used, the VL_ALLOC_INFO pointer will be changed to point at the default information. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5T_vlen_get_alloc_info(hid_t dxpl_id, H5T_vlen_alloc_info_t **vl_alloc_info) { H5P_genplist_t *plist; /* DX property list */ herr_t ret_value=SUCCEED; FUNC_ENTER_NOAPI(H5T_vlen_get_alloc_info, FAIL) assert(H5I_GENPROP_LST == H5I_get_type(dxpl_id)); assert(vl_alloc_info); /* Check for the default DXPL */ if(dxpl_id==H5P_DATASET_XFER_DEFAULT) *vl_alloc_info=&H5T_vlen_def_vl_alloc_info; else { /* Check args */ if(NULL == (plist = H5P_object_verify(dxpl_id,H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list") /* Get the allocation functions & information */ if (H5P_get(plist,H5D_XFER_VLEN_ALLOC_NAME,&(*vl_alloc_info)->alloc_func)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value") if (H5P_get(plist,H5D_XFER_VLEN_ALLOC_INFO_NAME,&(*vl_alloc_info)->alloc_info)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value") if (H5P_get(plist,H5D_XFER_VLEN_FREE_NAME,&(*vl_alloc_info)->free_func)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value") if (H5P_get(plist,H5D_XFER_VLEN_FREE_INFO_NAME,&(*vl_alloc_info)->free_info)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value") } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_vlen_get_alloc_info() */ /*-------------------------------------------------------------------------- NAME H5T_vlen_mark PURPOSE Recursively mark any VL datatypes as on disk/in memory USAGE htri_t H5T_vlen_mark(dt,f,loc) H5T_t *dt; IN/OUT: Pointer to the datatype to mark H5F_t *dt; IN: Pointer to the file the datatype is in H5T_vlen_type_t loc IN: location of VL type RETURNS One of two values on success: TRUE - If the location of any vlen types changed FALSE - If the location of any vlen types is the same <0 is returned on failure DESCRIPTION Recursively descends any VL or compound datatypes to mark all VL datatypes as either on disk or in memory. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ htri_t H5T_vlen_mark(H5T_t *dt, H5F_t *f, H5T_vlen_loc_t loc) { htri_t vlen_changed; /* Whether H5T_vlen_mark changed the type (even if the size didn't change) */ htri_t ret_value = 0; /* Indicate that success, but no location change */ unsigned i; /* Local index variable */ int accum_change=0; /* Amount of change in the offset of the fields */ size_t old_size; /* Previous size of a field */ FUNC_ENTER_NOAPI(H5T_vlen_mark, FAIL); assert(dt); assert(loc>H5T_VLEN_BADLOC && locshared->type) { case H5T_ARRAY: /* Recurse on VL, compound and array base element type */ /* Recurse if it's VL, compound or array */ /* (If the type is compound and the force_conv flag is _not_ set, the type cannot change in size, so don't recurse) */ if(dt->shared->parent->shared->force_conv && H5T_IS_COMPLEX(dt->shared->parent->shared->type)) { /* Keep the old base element size for later */ old_size=dt->shared->parent->shared->size; /* Mark the VL, compound or array type */ if((vlen_changed=H5T_vlen_mark(dt->shared->parent,f,loc))<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location"); if(vlen_changed>0) ret_value=vlen_changed; /* Check if the field changed size */ if(old_size != dt->shared->parent->shared->size) { /* Adjust the size of the array */ dt->shared->size = dt->shared->u.array.nelem*dt->shared->parent->shared->size; } /* end if */ } /* end if */ break; case H5T_COMPOUND: /* Check each field and recurse on VL, compound and array type */ /* Compound datatypes can't change in size if the force_conv flag is not set */ if(dt->shared->force_conv) { /* Sort the fields based on offsets */ H5T_sort_value(dt,NULL); for (i=0; ishared->u.compnd.nmembs; i++) { /* Apply the accumulated size change to the offset of the field */ dt->shared->u.compnd.memb[i].offset += accum_change; /* Recurse if it's VL, compound, enum or array */ /* (If the force_conv flag is _not_ set, the type cannot change in size, so don't recurse) */ if(dt->shared->u.compnd.memb[i].type->shared->force_conv && H5T_IS_COMPLEX(dt->shared->u.compnd.memb[i].type->shared->type)) { /* Keep the old field size for later */ old_size=dt->shared->u.compnd.memb[i].type->shared->size; /* Mark the VL, compound, enum or array type */ if((vlen_changed=H5T_vlen_mark(dt->shared->u.compnd.memb[i].type,f,loc))<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location"); if(vlen_changed>0) ret_value=vlen_changed; /* Check if the field changed size */ if(old_size != dt->shared->u.compnd.memb[i].type->shared->size) { /* Adjust the size of the member */ dt->shared->u.compnd.memb[i].size = (dt->shared->u.compnd.memb[i].size*dt->shared->u.compnd.memb[i].type->shared->size)/old_size; /* Add that change to the accumulated size change */ accum_change += (dt->shared->u.compnd.memb[i].type->shared->size - (int)old_size); } /* end if */ } /* end if */ } /* end for */ /* Apply the accumulated size change to the datatype */ dt->shared->size += accum_change; } /* end if */ break; case H5T_VLEN: /* Recurse on the VL information if it's VL, compound or array, then free VL sequence */ /* Recurse if it's VL, compound or array */ /* (If the force_conv flag is _not_ set, the type cannot change in size, so don't recurse) */ if(dt->shared->parent->shared->force_conv && H5T_IS_COMPLEX(dt->shared->parent->shared->type)) { if((vlen_changed=H5T_vlen_mark(dt->shared->parent,f,loc))<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location"); if(vlen_changed>0) ret_value=vlen_changed; } /* end if */ /* Mark this VL sequence */ if((vlen_changed=H5T_vlen_set_loc(dt,f,loc))<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location"); if(vlen_changed>0) ret_value=vlen_changed; break; default: break; } /* end switch */ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5T_vlen_mark() */ xdmf-3.0+git20160803/Utilities/hdf5/H5Tbit.c0000640000175000017500000003103613003006557020141 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Module Info: Operations on bit vectors. A bit vector is an array of bytes * with the least-significant bits in the first byte. That is, * the bytes are in little-endian order. */ #define H5T_PACKAGE /*suppress error about including H5Tpkg */ #include "H5private.h" /*generic functions */ #include "H5Eprivate.h" /*error handling */ #include "H5Iprivate.h" /*ID functions */ #include "H5Tpkg.h" /*data-type functions */ /*------------------------------------------------------------------------- * Function: H5T_bit_copy * * Purpose: Copies bits from one vector to another. * * Return: void * * Programmer: Robb Matzke * Wednesday, June 10, 1998 * * Modifications: * *------------------------------------------------------------------------- */ void H5T_bit_copy (uint8_t *dst, size_t dst_offset, const uint8_t *src, size_t src_offset, size_t size) { int shift; unsigned mask_lo, mask_hi; int s_idx, d_idx; /* * Normalize the offset to be a byte number and a bit offset within that * byte. */ s_idx = (int)src_offset / 8; d_idx = (int)dst_offset / 8; src_offset %= 8; dst_offset %= 8; /* * Get things rolling. This means copying bits until we're aligned on a * source byte. This the following example, five bits are copied to the * destination. * * src[s_idx] * +---------------+---------------+ * |7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0| * +---------------+---------------+ * ... : : : : : | | | | | * ... v v v v v V V V V V * ...+---------------+---------------+ * ...|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0| * ...+---------------+---------------+ * dst[d_idx+1] dst[d_idx] */ while (src_offset && size>0) { unsigned nbits = (unsigned)MIN3 (size, 8-dst_offset, 8-src_offset); unsigned mask = (1<>src_offset)&mask) << dst_offset; src_offset += nbits; if (src_offset>=8) { s_idx++; src_offset %= 8; } dst_offset += nbits; if (dst_offset>=8) { d_idx++; dst_offset %= 8; } size -= nbits; } /* * The middle bits. We are aligned on a source byte which needs to be * copied to two (or one in the degenerate case) destination bytes. * * src[s_idx] * +---------------+ * |7 6 5 4 3 2 1 0| * +---------------+ * | | | | | | | | * V V V V V V V V * +---------------+---------------+ * |7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0| * +---------------+---------------+ * dst[d_idx+1] dst[d_idx] * * * Calculate shifts and masks. See diagrams below. MASK_LO in this * example is 0x1f (the low five bits) and MASK_HI is 0xe0 (the high three * bits). SHIFT is three since the source must be shifted right three bits * to line up with the destination. */ shift = (int)dst_offset; mask_lo = (1<<(8-shift))-1; mask_hi = (~mask_lo) & 0xff; for (/*void*/; size>8; size-=8, d_idx++, s_idx++) { if (shift) { dst[d_idx+0] &= ~(mask_lo<>(8-shift)); dst[d_idx+1] |= (src[s_idx] & mask_hi) >> (8-shift); } else { dst[d_idx] = src[s_idx]; } } /* Finish up */ while (size>0) { unsigned nbits = (unsigned)MIN3 (size, 8-dst_offset, 8-src_offset); unsigned mask = (1<>src_offset)&mask) << dst_offset; src_offset += nbits; if (src_offset>=8) { s_idx++; src_offset %= 8; } dst_offset += nbits; if (dst_offset>=8) { d_idx++; dst_offset %= 8; } size -= nbits; } } /*------------------------------------------------------------------------- * Function: H5T_bit_get_d * * Purpose: Return a small bit sequence as a number. Bit vector starts * at OFFSET and is SIZE bits long. * * Return: Success: The bit sequence interpretted as an unsigned * integer. * * Failure: 0 * * Programmer: Robb Matzke * Tuesday, June 23, 1998 * * Modifications: * *------------------------------------------------------------------------- */ hsize_t H5T_bit_get_d (uint8_t *buf, size_t offset, size_t size) { hsize_t val=0; size_t i, hs; hsize_t ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOFUNC(H5T_bit_get_d); assert (8*sizeof(val)>=size); H5T_bit_copy ((uint8_t*)&val, 0, buf, offset, size); switch (H5T_native_order_g) { case H5T_ORDER_LE: break; case H5T_ORDER_BE: for (i=0, hs=sizeof(val)/2; i=size); switch (H5T_native_order_g) { case H5T_ORDER_LE: break; case H5T_ORDER_BE: for (i=0, hs=sizeof(val)/2; i=8) { buf[idx++] = value ? 0xff : 0x00; size -= 8; } /* The last partial byte */ if (size) { if (value) { buf[idx] |= (1<0; iu++, size--) { if (value==(hbool_t)((buf[idx]>>iu) & 0x01)) HGOTO_DONE(8*idx+(ssize_t)iu - base); } offset = 0; idx++; } /* Middle */ while (size>=8) { if ((value?0x00:0xff)!=buf[idx]) { for (i=0; i<8; i++) { if (value==(hbool_t)((buf[idx]>>i) & 0x01)) HGOTO_DONE(8*idx+i - base); } } size -= 8; idx++; } /* End */ for (i=0; i<(ssize_t)size; i++) { if (value==(hbool_t)((buf[idx]>>i) & 0x01)) HGOTO_DONE(8*idx+i - base); } break; case H5T_BIT_MSB: /* Calculate index */ idx = (ssize_t)((offset+size-1) / 8); offset %= 8; /* Beginning */ if (size>8-offset && (offset+size)%8) { for (iu=(offset+size)%8; iu>0; --iu, --size) { if (value==(hbool_t)((buf[idx]>>(iu-1)) & 0x01)) HGOTO_DONE(8*idx+(ssize_t)(iu-1) - base); } --idx; } /* Middle */ while (size>=8) { if ((value?0x00:0xff)!=buf[idx]) { for (i=7; i>=0; --i) { if (value==(hbool_t)((buf[idx]>>i) & 0x01)) HGOTO_DONE(8*idx+i - base); } } size -= 8; --idx; } /* End */ if (size>0) { for (iu=offset+size; iu>offset; --iu) { if (value==(hbool_t)((buf[idx]>>(iu-1)) & 0x01)) HGOTO_DONE(8*idx+(ssize_t)(iu-1) - base); } } break; } done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_bit_inc * * Purpose: Increment part of a bit field by adding 1. The bit field * starts with bit position START and is SIZE bits long. * * Return: Success: The carry-out value. One if overflows, * zero otherwise. * * Failure: Negative * * Programmer: Robb Matzke * Friday, June 26, 1998 * * Modifications: * *------------------------------------------------------------------------- */ htri_t H5T_bit_inc(uint8_t *buf, size_t start, size_t size) { size_t idx = start / 8; unsigned carry = 1; unsigned acc, mask; /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_bit_inc); assert(buf); start %= 8; /* The first partial byte */ if (start) { if (size+start<8) mask = (1<>start) & mask; acc += 1; carry = acc & (1<=8) { acc = buf[idx]; acc += 1; carry = acc & 0x100; buf[idx] = acc & 0xff; idx++; size -= 8; } /* The last bits */ if (carry && size>0) { mask = (1< 1 && numofelements > 1) { /* Compute the leftover bytes if there are any */ leftover = nbytes%bytesoftype; /* Allocate the destination buffer */ if (NULL==(dest = H5MM_malloc(nbytes))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed for shuffle buffer") if(flags & H5Z_FLAG_REVERSE) { /* Get the pointer to the source buffer */ _src =(unsigned char *)(*buf); /* Input; unshuffle */ for(i=0; i 0) { DUFF_GUTS; j--; } /* end for */ #else /* NO_DUFFS_DEVICE */ { size_t duffs_index; /* Counting index for Duff's device */ duffs_index = (numofelements + 7) / 8; switch (numofelements % 8) { case 0: do { DUFF_GUTS case 7: DUFF_GUTS case 6: DUFF_GUTS case 5: DUFF_GUTS case 4: DUFF_GUTS case 3: DUFF_GUTS case 2: DUFF_GUTS case 1: DUFF_GUTS } while (--duffs_index > 0); } /* end switch */ } #endif /* NO_DUFFS_DEVICE */ #undef DUFF_GUTS } /* end for */ /* Add leftover to the end of data */ if(leftover>0) { /* Adjust back to end of shuffled bytes */ _dest -= (bytesoftype - 1); /*lint !e794 _dest is initialized */ HDmemcpy((void*)_dest, (void*)_src, leftover); } } /* end if */ else { /* Get the pointer to the destination buffer */ _dest =(unsigned char *)dest; /* Output; shuffle */ for(i=0; i 0) { DUFF_GUTS; j--; } /* end for */ #else /* NO_DUFFS_DEVICE */ { size_t duffs_index; /* Counting index for Duff's device */ duffs_index = (numofelements + 7) / 8; switch (numofelements % 8) { case 0: do { DUFF_GUTS case 7: DUFF_GUTS case 6: DUFF_GUTS case 5: DUFF_GUTS case 4: DUFF_GUTS case 3: DUFF_GUTS case 2: DUFF_GUTS case 1: DUFF_GUTS } while (--duffs_index > 0); } /* end switch */ } #endif /* NO_DUFFS_DEVICE */ #undef DUFF_GUTS } /* end for */ /* Add leftover to the end of data */ if(leftover>0) { /* Adjust back to end of shuffled bytes */ _src -= (bytesoftype - 1); /*lint !e794 _src is initialized */ HDmemcpy((void*)_dest, (void*)_src, leftover); } } /* end else */ /* Free the input buffer */ H5MM_xfree(*buf); /* Set the buffer information to return */ *buf = dest; *buf_size=nbytes; } /* end else */ /* Set the return value */ ret_value = nbytes; done: FUNC_LEAVE_NOAPI(ret_value) } #endif /*H5_HAVE_FILTER_SHUFFLE */ xdmf-3.0+git20160803/Utilities/hdf5/H5FDstream.c0000640000175000017500000011554413003006557020753 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Copyright � 2000 The author. * The author prefers this code not be used for military purposes. * * * Author: Thomas Radke * Tuesday, September 12, 2000 * * Purpose: This code provides the Stream Virtual File Driver. * It is very much based on the core VFD which keeps an * entire HDF5 data file to be processed in main memory. * In addition to that, the memory image of the file is * read from/written to a socket during an open/flush operation. * * Modifications: * Thomas Radke, Thursday, October 26, 2000 * Added support for Windows. * Catch SIGPIPE on an open socket. * */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5FD_stream_init_interface #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5FDprivate.h" /* File drivers */ #include "H5FDstream.h" /* Stream file driver */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Pprivate.h" /* Property lists */ /* Only build this driver if it was configured with --with-Stream-VFD */ #ifdef H5_HAVE_STREAM #ifdef H5FD_STREAM_HAVE_UNIX_SOCKETS #ifdef H5_HAVE_SYS_TYPES_H #include /* socket stuff */ #endif #ifdef H5_HAVE_SYS_SOCKET_H #include /* socket stuff */ #endif #include /* gethostbyname */ #include /* socket stuff */ #ifdef H5_HAVE_NETINET_TCP_H #include /* socket stuff */ #endif #ifdef H5_HAVE_SYS_FILIO_H #include /* socket stuff */ #endif #endif #ifndef H5_HAVE_SOCKLEN_T typedef int socklen_t; #endif /* Some useful macros */ #ifdef MIN #undef MIN #endif #ifdef MAX #undef MAX #endif #define MIN(x,y) ((x) < (y) ? (x) : (y)) #define MAX(x,y) ((x) > (y) ? (x) : (y)) /* Uncomment this to switch on debugging output */ /* #define DEBUG 1 */ /* Define some socket stuff which is different for UNIX and Windows */ #ifdef H5FD_STREAM_HAVE_UNIX_SOCKETS #define H5FD_STREAM_CLOSE_SOCKET(a) close(a) #define H5FD_STREAM_IOCTL_SOCKET(a, b, c) ioctl(a, b, c) #define H5FD_STREAM_ERROR_CHECK(rc) ((rc) < 0) #else #define H5FD_STREAM_CLOSE_SOCKET(a) closesocket (a) #define H5FD_STREAM_IOCTL_SOCKET(a, b, c) ioctlsocket (a, b, (u_long *) (c)) #define H5FD_STREAM_ERROR_CHECK(rc) ((rc) == (SOCKET) (SOCKET_ERROR)) #endif /* The driver identification number, initialized at runtime */ static hid_t H5FD_STREAM_g = 0; /* * The description of a file belonging to this driver. The `eoa' and `eof' * determine the amount of hdf5 address space in use and the high-water mark * of the file (the current size of the underlying memory). */ typedef struct H5FD_stream_t { H5FD_t pub; /* public stuff, must be first */ H5FD_stream_fapl_t fapl; /* file access property list */ unsigned char *mem; /* the underlying memory */ haddr_t eoa; /* end of allocated region */ haddr_t eof; /* current allocated size */ H5FD_STREAM_SOCKET_TYPE socket; /* socket to write / read from */ hbool_t dirty; /* flag indicating unflushed data */ hbool_t internal_socket; /* flag indicating an internal socket */ } H5FD_stream_t; /* Allocate memory in multiples of this size (in bytes) by default */ #define H5FD_STREAM_INCREMENT 8192 /* default backlog argument for listen call */ #define H5FD_STREAM_BACKLOG 1 /* number of successive ports to hunt for until bind(2) succeeds (default 0 means no port hunting - only try the one given in the filename) */ #define H5FD_STREAM_MAXHUNT 0 /* default file access property list */ static const H5FD_stream_fapl_t default_fapl = { H5FD_STREAM_INCREMENT, /* address space allocation blocksize */ H5FD_STREAM_INVALID_SOCKET, /* no external socket descriptor */ TRUE, /* enable I/O on socket */ H5FD_STREAM_BACKLOG, /* default backlog for listen(2) */ NULL, /* do not broadcast received files */ NULL, /* argument to READ broadcast routine */ H5FD_STREAM_MAXHUNT, /* default number of ports to hunt */ 0 /* unknown port for unbound socket */ }; /* * These macros check for overflow of various quantities. These macros * assume that file_offset_t is signed and haddr_t and size_t are unsigned. * * ADDR_OVERFLOW: Checks whether a file address of type `haddr_t' * is too large to be represented by the second argument * of the file seek function. * * SIZE_OVERFLOW: Checks whether a buffer size of type `hsize_t' is too * large to be represented by the `size_t' type. * * REGION_OVERFLOW: Checks whether an address and size pair describe data * which can be addressed entirely in memory. */ #ifdef H5_HAVE_LSEEK64 # define file_offset_t off64_t #else # define file_offset_t off_t #endif #define MAXADDR (((haddr_t)1<<(8*sizeof(file_offset_t)-1))-1) #define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || \ ((A) & ~(haddr_t)MAXADDR)) #define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) #define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ HADDR_UNDEF==(A)+(Z) || \ (size_t)((A)+(Z))<(size_t)(A)) /* Function prototypes */ static void *H5FD_stream_fapl_get (H5FD_t *_stream); static H5FD_t *H5FD_stream_open (const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); static herr_t H5FD_stream_flush (H5FD_t *_stream, hid_t dxpl_id, unsigned closing); static herr_t H5FD_stream_close (H5FD_t *_stream); static herr_t H5FD_stream_query(const H5FD_t *_f1, unsigned long *flags); static haddr_t H5FD_stream_get_eoa (H5FD_t *_stream); static herr_t H5FD_stream_set_eoa (H5FD_t *_stream, haddr_t addr); static haddr_t H5FD_stream_get_eof (H5FD_t *_stream); static herr_t H5FD_stream_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle); static herr_t H5FD_stream_read (H5FD_t *_stream, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, void *buf); static herr_t H5FD_stream_write (H5FD_t *_stream, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, const void *buf); /* The Stream VFD's class information structure */ static const H5FD_class_t H5FD_stream_g = { "stream", /*name */ MAXADDR, /*maxaddr */ H5F_CLOSE_WEAK, /*fc_degree */ NULL, /*sb_size */ NULL, /*sb_encode */ NULL, /*sb_decode */ sizeof (H5FD_stream_fapl_t), /*fapl_size */ H5FD_stream_fapl_get, /*fapl_get */ NULL, /*fapl_copy */ NULL, /*fapl_free */ 0, /*dxpl_size */ NULL, /*dxpl_copy */ NULL, /*dxpl_free */ H5FD_stream_open, /*open */ H5FD_stream_close, /*close */ NULL, /*cmp */ H5FD_stream_query, /*query */ NULL, /*alloc */ NULL, /*free */ H5FD_stream_get_eoa, /*get_eoa */ H5FD_stream_set_eoa, /*set_eoa */ H5FD_stream_get_eof, /*get_eof */ H5FD_stream_get_handle, /*get_handle */ H5FD_stream_read, /*read */ H5FD_stream_write, /*write */ H5FD_stream_flush, /*flush */ NULL, /*lock */ NULL, /*unlock */ H5FD_FLMAP_SINGLE /*fl_map */ }; /*-------------------------------------------------------------------------- NAME H5FD_stream_init_interface -- Initialize interface-specific information USAGE herr_t H5FD_stream_init_interface() RETURNS Non-negative on success/Negative on failure DESCRIPTION Initializes any interface-specific data or routines. (Just calls H5FD_stream_init currently). --------------------------------------------------------------------------*/ static herr_t H5FD_stream_init_interface(void) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_stream_init_interface) FUNC_LEAVE_NOAPI(H5FD_stream_init()) } /* H5FD_stream_init_interface() */ /*------------------------------------------------------------------------- * Function: H5FD_stream_init * * Purpose: Initialize this driver by registering it with the library. * * Return: Success: The driver ID for the Stream driver. * Failure: Negative. * * Programmer: Thomas Radke * Tuesday, September 12, 2000 * * Modifications: * *------------------------------------------------------------------------- */ hid_t H5FD_stream_init (void) { hid_t ret_value=H5FD_STREAM_g; /* Return value */ FUNC_ENTER_NOAPI(H5FD_stream_init, FAIL) if (H5I_VFL != H5Iget_type (H5FD_STREAM_g)) { H5FD_STREAM_g = H5FD_register (&H5FD_stream_g,sizeof(H5FD_class_t)); /* set the process signal mask to ignore SIGPIPE signals */ /* NOTE: Windows doesn't know SIGPIPE signals that's why the #ifdef */ #ifdef SIGPIPE if (signal (SIGPIPE, SIG_IGN) == SIG_ERR) fprintf (stderr, "Stream VFD warning: failed to set the process signal " "mask to ignore SIGPIPE signals\n"); #endif } /* Set return value */ ret_value=H5FD_STREAM_g; done: FUNC_LEAVE_NOAPI(ret_value) } /*--------------------------------------------------------------------------- * Function: H5FD_stream_term * * Purpose: Shut down the VFD * * Return: * * Programmer: Quincey Koziol * Friday, Jan 30, 2004 * * Modification: * *--------------------------------------------------------------------------- */ void H5FD_stream_term(void) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_stream_term) /* Reset VFL ID */ H5FD_STREAM_g=0; FUNC_LEAVE_NOAPI_VOID } /* end H5FD_stream_term() */ /*------------------------------------------------------------------------- * Function: H5Pset_fapl_stream * * Purpose: Modify the file access property list to use the Stream * driver defined in this source file. The INCREMENT specifies * how much to grow the memory each time we need more. * If a valid socket argument is given this will be used * by the driver instead of parsing the 'hostname:port' filename * and opening a socket internally. * * Return: Success: Non-negative * Failure: Negative * * Programmer: Thomas Radke * Tuesday, September 12, 2000 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Pset_fapl_stream (hid_t fapl_id, H5FD_stream_fapl_t *fapl) { H5FD_stream_fapl_t user_fapl; H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Pset_fapl_stream, FAIL) H5TRACE2 ("e", "ix", fapl_id, fapl); if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) HGOTO_ERROR (H5E_PLIST, H5E_BADTYPE, FAIL, "not a fapl") if (fapl) { if (! fapl->do_socket_io && fapl->broadcast_fn == NULL) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "read broadcast function pointer is NULL") user_fapl = *fapl; if (fapl->increment == 0) user_fapl.increment = H5FD_STREAM_INCREMENT; user_fapl.port = 0; ret_value = H5P_set_driver (plist, H5FD_STREAM, &user_fapl); } else ret_value = H5P_set_driver (plist, H5FD_STREAM, &default_fapl); done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5Pget_fapl_stream * * Purpose: Queries properties set by the H5Pset_fapl_stream() function. * * Return: Success: Non-negative * Failure: Negative * * Programmer: Thomas Radke * Tuesday, September 12, 2000 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Pget_fapl_stream(hid_t fapl_id, H5FD_stream_fapl_t *fapl /* out */) { H5FD_stream_fapl_t *this_fapl; H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Pget_fapl_stream, FAIL) H5TRACE2("e","ix",fapl_id,fapl); if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) HGOTO_ERROR (H5E_PLIST, H5E_BADTYPE, FAIL, "not a fapl") if (H5FD_STREAM != H5P_get_driver (plist)) HGOTO_ERROR (H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver") if (NULL == (this_fapl = H5P_get_driver_info (plist))) HGOTO_ERROR (H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info") if (fapl) *fapl = *this_fapl; done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_stream_fapl_get * * Purpose: Returns a copy of the file access properties * * Return: Success: Ptr to new file access properties * Failure: NULL * * Programmer: Thomas Radke * Tuesday, September 12, 2000 * * Modifications: * *------------------------------------------------------------------------- */ static void * H5FD_stream_fapl_get (H5FD_t *_stream) { H5FD_stream_t *stream = (H5FD_stream_t *) _stream; H5FD_stream_fapl_t *fapl; void *ret_value; FUNC_ENTER_NOAPI(H5FD_stream_fapl_get, NULL) if ((fapl = H5MM_calloc (sizeof (H5FD_stream_fapl_t))) == NULL) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") *fapl = stream->fapl; /* Set return value */ ret_value=fapl; done: FUNC_LEAVE_NOAPI(ret_value) } static H5FD_STREAM_SOCKET_TYPE H5FD_stream_open_socket (const char *filename, int o_flags, H5FD_stream_fapl_t *fapl) { struct sockaddr_in server; struct hostent *he; H5FD_STREAM_SOCKET_TYPE sock=H5FD_STREAM_INVALID_SOCKET; char *hostname=NULL; unsigned short int first_port; const char *separator, *tmp; int on = 1; H5FD_STREAM_SOCKET_TYPE ret_value=H5FD_STREAM_INVALID_SOCKET; FUNC_ENTER_NOAPI_NOINIT(H5FD_stream_open_socket) /* Parse "hostname:port" from filename argument */ for (separator = filename; *separator != ':' && *separator; separator++) ; if (separator == filename || !*separator) { HGOTO_ERROR(H5E_ARGS,H5E_BADVALUE,H5FD_STREAM_INVALID_SOCKET,"invalid host address") } else { tmp = separator; if (! tmp[1]) HGOTO_ERROR(H5E_ARGS,H5E_BADVALUE,H5FD_STREAM_INVALID_SOCKET,"no port number") while (*++tmp) { if (! isdigit (*tmp)) HGOTO_ERROR(H5E_ARGS,H5E_BADVALUE,H5FD_STREAM_INVALID_SOCKET,"invalid port number") } } hostname = (char *) H5MM_malloc ((size_t)(separator - filename + 1)); /* Return if out of memory */ if (hostname == NULL) HGOTO_ERROR(H5E_RESOURCE,H5E_NOSPACE,H5FD_STREAM_INVALID_SOCKET,"memory allocation failed") HDstrncpy (hostname, filename, (size_t)(separator - filename)); hostname[separator - filename] = 0; fapl->port = atoi (separator + 1); HDmemset (&server, 0, sizeof (server)); server.sin_family = AF_INET; server.sin_port = htons (fapl->port); if (! (he = gethostbyname (hostname))) { HGOTO_ERROR(H5E_RESOURCE,H5E_NOSPACE,H5FD_STREAM_INVALID_SOCKET,"unable to get host address") } else if (H5FD_STREAM_ERROR_CHECK (sock = socket (AF_INET, SOCK_STREAM, 0))) HGOTO_ERROR(H5E_RESOURCE,H5E_NOSPACE,H5FD_STREAM_INVALID_SOCKET,"unable to open socket") if (O_RDONLY == o_flags) { HDmemcpy (&server.sin_addr, he->h_addr, (size_t)he->h_length); #ifdef DEBUG fprintf (stderr, "Stream VFD: connecting to host '%s' port %d\n", hostname, fapl->port); #endif if (connect (sock, (struct sockaddr *) &server, sizeof (server)) < 0) HGOTO_ERROR(H5E_RESOURCE,H5E_NOSPACE,H5FD_STREAM_INVALID_SOCKET,"unable to connect") } else { server.sin_addr.s_addr = INADDR_ANY; if (H5FD_STREAM_IOCTL_SOCKET (sock, FIONBIO, &on) < 0) { HGOTO_ERROR(H5E_RESOURCE,H5E_NOSPACE,H5FD_STREAM_INVALID_SOCKET,"unable to set non-blocking mode for socket") } else if (setsockopt (sock, IPPROTO_TCP, TCP_NODELAY, (const char *) &on, sizeof(on)) < 0) { HGOTO_ERROR(H5E_RESOURCE,H5E_NOSPACE,H5FD_STREAM_INVALID_SOCKET,"unable to set socket option TCP_NODELAY") #ifdef HAVE_SO_REUSEADDR } else if (setsockopt (sock, SOL_SOCKET, SO_REUSEADDR, (const char *) &on, sizeof(on)) < 0) { HGOTO_ERROR(H5E_RESOURCE,H5E_NOSPACE,H5FD_STREAM_INVALID_SOCKET,"unable to set socket option SO_REUSEADDR") #endif } else { /* Try to bind the socket to the given port. If maxhunt is given try some successive ports also. */ first_port = fapl->port; while (fapl->port <= first_port + fapl->maxhunt) { #ifdef DEBUG fprintf (stderr, "Stream VFD: binding to port %d\n", fapl->port); #endif server.sin_port = htons (fapl->port); if (bind (sock, (struct sockaddr *) &server, sizeof (server)) < 0) fapl->port++; else break; } if (fapl->port > first_port + fapl->maxhunt) { fapl->port = 0; HGOTO_ERROR(H5E_RESOURCE,H5E_NOSPACE,H5FD_STREAM_INVALID_SOCKET,"unable to bind socket") } else if (listen (sock, fapl->backlog) < 0) HGOTO_ERROR(H5E_RESOURCE,H5E_NOSPACE,H5FD_STREAM_INVALID_SOCKET,"unable to listen on socket") } } /* Set return value for success */ ret_value=sock; done: /* Cleanup variables */ if(hostname!=NULL) hostname=H5MM_xfree(hostname); /* Clean up on error */ if(ret_value==H5FD_STREAM_INVALID_SOCKET) { if (!H5FD_STREAM_ERROR_CHECK(sock)) H5FD_STREAM_CLOSE_SOCKET(sock); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } static herr_t H5FD_stream_read_from_socket (H5FD_stream_t *stream) { int size; size_t max_size = 0; unsigned char *ptr=NULL; herr_t ret_value=SUCCEED; FUNC_ENTER_NOAPI_NOINIT(H5FD_stream_read_from_socket) stream->eof = 0; stream->mem = NULL; while (1) { if (max_size <= 0) { /* * Allocate initial buffer as increment + 1 * to prevent unnecessary reallocation * if increment is exactly a multiple of the filesize */ max_size = stream->fapl.increment; if (! stream->mem) max_size++; ptr = H5MM_realloc (stream->mem, (size_t) (stream->eof + max_size)); if (! ptr) HGOTO_ERROR(H5E_RESOURCE,H5E_NOSPACE,FAIL,"unable to allocate file space buffer") stream->mem = ptr; ptr += stream->eof; } /* now receive the next chunk of data */ size = recv (stream->socket, ptr, max_size, 0); if (size < 0 && (EINTR == errno || EAGAIN == errno #ifndef _WIN32 || EWOULDBLOCK #endif )) continue; if (size < 0) HGOTO_ERROR(H5E_IO,H5E_READERROR,FAIL,"error reading from file from socket") if (! size) break; max_size -= (size_t) size; stream->eof += (haddr_t) size; ptr += size; #ifdef DEBUG fprintf (stderr, "Stream VFD: read %d bytes (%d total) from socket\n", size, (int) stream->eof); #endif } #ifdef DEBUG fprintf (stderr, "Stream VFD: read total of %d bytes from socket\n", (int) stream->eof); #endif done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_stream_open * * Purpose: Opens an HDF5 file in memory. * * Return: Success: A pointer to a new file data structure. The * public fields will be initialized by the * caller, which is always H5FD_open(). * Failure: NULL * * Programmer: Thomas Radke * Tuesday, September 12, 2000 * * Modifications: * *------------------------------------------------------------------------- */ static H5FD_t * H5FD_stream_open (const char *filename, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { H5FD_stream_t *stream=NULL; const H5FD_stream_fapl_t *fapl; int o_flags; #ifdef WIN32 WSADATA wsadata; #endif H5P_genplist_t *plist=NULL; /* Property list pointer */ H5FD_t *ret_value; /* Function return value */ FUNC_ENTER_NOAPI(H5FD_stream_open, NULL) /* Check arguments */ if (filename == NULL|| *filename == '\0') HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, NULL,"invalid file name") if (maxaddr == 0 || HADDR_UNDEF == maxaddr) HGOTO_ERROR (H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr") if (ADDR_OVERFLOW (maxaddr)) HGOTO_ERROR (H5E_ARGS, H5E_OVERFLOW, NULL, "maxaddr overflow") /* Build the open flags */ o_flags = (H5F_ACC_RDWR & flags) ? O_RDWR : O_RDONLY; if (H5F_ACC_TRUNC & flags) o_flags |= O_TRUNC; if (H5F_ACC_CREAT & flags) o_flags |= O_CREAT; if (H5F_ACC_EXCL & flags) o_flags |= O_EXCL; if ((O_RDWR & o_flags) && ! (O_CREAT & o_flags)) HGOTO_ERROR (H5E_ARGS, H5E_UNSUPPORTED, NULL, "open stream for read/write not supported") #ifdef WIN32 if (WSAStartup (MAKEWORD (2, 0), &wsadata)) HGOTO_ERROR (H5E_IO, H5E_CANTINIT, NULL, "Couldn't start Win32 socket layer") #endif fapl = NULL; if (H5P_FILE_ACCESS_DEFAULT != fapl_id) { if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") fapl = H5P_get_driver_info (plist); } if (fapl == NULL) fapl = &default_fapl; /* Create the new file struct */ stream = (H5FD_stream_t *) H5MM_calloc (sizeof (H5FD_stream_t)); if (stream == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate file struct") stream->fapl = *fapl; stream->socket = H5FD_STREAM_INVALID_SOCKET; /* if an external socket is provided with the file access property list we use that, otherwise the filename argument is parsed and a socket is opened internally */ if (fapl->do_socket_io) { if (! H5FD_STREAM_ERROR_CHECK (fapl->socket)) { stream->internal_socket = FALSE; stream->socket = fapl->socket; } else { stream->internal_socket = TRUE; stream->socket = H5FD_stream_open_socket (filename, o_flags, &stream->fapl); if (stream->socket != H5FD_STREAM_INVALID_SOCKET) { /* update the port ID in the file access property so that it can be queried via H5P_get_fapl_stream() later on */ H5P_set_driver (plist, H5FD_STREAM, &stream->fapl); } else HGOTO_ERROR(H5E_IO, H5E_CANTOPENFILE, NULL, "can't open internal socket") } } /* read the data from socket into memory */ if (O_RDONLY == o_flags) { if (fapl->do_socket_io) { #ifdef DEBUG fprintf (stderr, "Stream VFD: reading file from socket\n"); #endif if(H5FD_stream_read_from_socket (stream)<0) HGOTO_ERROR(H5E_IO, H5E_READERROR, NULL, "can't read file from socket") } /* Now call the user's broadcast routine if given */ if (fapl->broadcast_fn) { if ((fapl->broadcast_fn) (&stream->mem, &stream->eof, fapl->broadcast_arg) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, NULL, "broadcast error") /* check for filesize of zero bytes */ if (stream->eof == 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, NULL, "zero filesize") } /* For files which are read from a socket: the opened socket is not needed anymore */ if (stream->internal_socket && ! H5FD_STREAM_ERROR_CHECK (stream->socket)) H5FD_STREAM_CLOSE_SOCKET (stream->socket); stream->socket = H5FD_STREAM_INVALID_SOCKET; } /* Set return value on success */ ret_value=(H5FD_t*)stream; done: if(ret_value==NULL) { if(stream!=NULL) { if (stream->mem) H5MM_xfree (stream->mem); if (stream->internal_socket && ! H5FD_STREAM_ERROR_CHECK (stream->socket)) H5FD_STREAM_CLOSE_SOCKET (stream->socket); H5MM_xfree(stream); } /* end if */ } FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_stream_flush * * Purpose: Flushes the file via sockets to any connected clients * if its dirty flag is set. * * Return: Success: 0 * Failure: -1 * * Programmer: Thomas Radke * Tuesday, September 12, 2000 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_stream_flush (H5FD_t *_stream, hid_t UNUSED dxpl_id, unsigned UNUSED closing) { H5FD_stream_t *stream = (H5FD_stream_t *) _stream; size_t size; ssize_t bytes_send; int on = 1; unsigned char *ptr; struct sockaddr from; socklen_t fromlen; H5FD_STREAM_SOCKET_TYPE sock; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_stream_flush, FAIL) /* Write to backing store */ if (stream->dirty && ! H5FD_STREAM_ERROR_CHECK (stream->socket)) { #ifdef DEBUG fprintf (stderr, "Stream VFD: accepting client connections\n"); #endif fromlen = sizeof (from); while (! H5FD_STREAM_ERROR_CHECK (sock = accept (stream->socket, &from, &fromlen))) { if (H5FD_STREAM_IOCTL_SOCKET (sock, FIONBIO, &on) < 0) { H5FD_STREAM_CLOSE_SOCKET (sock); continue; /* continue the loop for other clients to connect */ } size = stream->eof; ptr = stream->mem; while (size) { bytes_send = send (sock, ptr, size, 0); if (bytes_send < 0) { if (EINTR == errno || EAGAIN == errno #ifndef _WIN32 || EWOULDBLOCK == errno #endif ) continue; /* continue the outermost loop for other clients to connect */ break; } ptr += bytes_send; size -= bytes_send; #ifdef DEBUG fprintf (stderr, "Stream VFD: wrote %d bytes to socket, %d in total, " "%d left\n", bytes_send, (int) (ptr - stream->mem), size); #endif } H5FD_STREAM_CLOSE_SOCKET (sock); } stream->dirty = FALSE; } done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_stream_close * * Purpose: Closes the file. * * Return: Success: 0 * Failure: -1 * * Programmer: Thomas Radke * Tuesday, September 12, 2000 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_stream_close (H5FD_t *_stream) { H5FD_stream_t *stream = (H5FD_stream_t *) _stream; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_stream_close, FAIL) /* Release resources */ if (! H5FD_STREAM_ERROR_CHECK (stream->socket) && stream->internal_socket) H5FD_STREAM_CLOSE_SOCKET (stream->socket); if (stream->mem) H5MM_xfree (stream->mem); HDmemset (stream, 0, sizeof (H5FD_stream_t)); H5MM_xfree (stream); done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_stream_query * * Purpose: Set the flags that this VFL driver is capable of supporting. * (listed in H5FDpublic.h) * * Return: Success: non-negative * * Failure: negative * * Programmer: Quincey Koziol * Tuesday, September 26, 2000 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_stream_query(const H5FD_t UNUSED * _f, unsigned long *flags/*out*/) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_stream_query, SUCCEED) /* Set the VFL feature flags that this driver supports */ if (flags) { *flags = 0; /* OK to perform data sieving for faster raw data reads & writes */ *flags |= H5FD_FEAT_DATA_SIEVE; *flags|=H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ } done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_stream_get_eoa * * Purpose: Gets the end-of-address marker for the file. The EOA marker * is the first address past the last byte allocated in the * format address space. * * Return: Success: The end-of-address marker. * Failure: HADDR_UNDEF * * Programmer: Thomas Radke * Tuesday, September 12, 2000 * * Modifications: * *------------------------------------------------------------------------- */ static haddr_t H5FD_stream_get_eoa (H5FD_t *_stream) { H5FD_stream_t *stream = (H5FD_stream_t *) _stream; haddr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_stream_get_eoa, HADDR_UNDEF) /* Set return value */ ret_value=stream->eoa; done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_stream_set_eoa * * Purpose: Set the end-of-address marker for the file. This function is * called shortly after an existing HDF5 file is opened in order * to tell the driver where the end of the HDF5 data is located. * * Return: Success: 0 * Failure: -1 * * Programmer: Thomas Radke * Tuesday, September 12, 2000 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_stream_set_eoa (H5FD_t *_stream, haddr_t addr) { H5FD_stream_t *stream = (H5FD_stream_t *) _stream; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_stream_set_eoa, FAIL) if (ADDR_OVERFLOW (addr)) HGOTO_ERROR (H5E_ARGS, H5E_OVERFLOW, FAIL, "address overflow") stream->eoa = addr; done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_stream_get_eof * * Purpose: Returns the end-of-file marker, which is the greater of * either the size of the underlying memory or the HDF5 * end-of-address markers. * * Return: Success: End of file address, the first address past * the end of the "file", either the memory * or the HDF5 file. * Failure: HADDR_UNDEF * * Programmer: Thomas Radke * Tuesday, September 12, 2000 * * Modifications: * *------------------------------------------------------------------------- */ static haddr_t H5FD_stream_get_eof (H5FD_t *_stream) { H5FD_stream_t *stream = (H5FD_stream_t *) _stream; haddr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_stream_get_eof, HADDR_UNDEF) /* Set return value */ ret_value= MAX (stream->eof, stream->eoa); done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_stream_get_handle * * Purpose: Returns the file handle of stream file driver. * * Returns: Non-negative if succeed or negative if fails. * * Programmer: Raymond Lu * Sept. 16, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_stream_get_handle(H5FD_t *_file, hid_t UNUSED fapl, void** file_handle) { H5FD_stream_t *file = (H5FD_stream_t *)_file; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5FD_stream_get_handle, FAIL) if(!file_handle) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file handle not valid") *file_handle = &(file->socket); done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_stream_read * * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR * into buffer BUF according to data transfer properties in * DXPL_ID. * * Return: Success: 0 * Result is stored in caller-supplied buffer BUF * Failure: -1 * Contents of buffer BUF are undefined * * Programmer: Thomas Radke * Tuesday, September 12, 2000 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_stream_read (H5FD_t *_stream, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, haddr_t addr, size_t size, void *buf /*out*/) { H5FD_stream_t *stream = (H5FD_stream_t *) _stream; size_t nbytes; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_stream_read, FAIL) assert (stream && stream->pub.cls); assert (buf); /* Check for overflow conditions */ if (HADDR_UNDEF == addr) HGOTO_ERROR (H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed") if (REGION_OVERFLOW (addr, size)) HGOTO_ERROR (H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed") if (addr + size > stream->eoa) HGOTO_ERROR (H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed") /* Read the part which is before the EOF marker */ if (addr < stream->eof) { nbytes = MIN (size, stream->eof - addr); HDmemcpy (buf, stream->mem + addr, nbytes); size -= nbytes; addr += nbytes; buf = (char *) buf + nbytes; } /* Read zeros for the part which is after the EOF markers */ if (size > 0) HDmemset (buf, 0, size); done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_stream_write * * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR * from buffer BUF according to data transfer properties in * DXPL_ID. * * Return: Success: Zero * Failure: -1 * * Programmer: Thomas Radke * Tuesday, September 12, 2000 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_stream_write (H5FD_t *_stream, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, haddr_t addr, size_t size, const void *buf) { H5FD_stream_t *stream = (H5FD_stream_t *) _stream; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_stream_write, FAIL) assert (stream && stream->pub.cls); assert (buf); /* Check for overflow conditions */ if (REGION_OVERFLOW (addr, size)) HGOTO_ERROR (H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed") if (addr + size > stream->eoa) HGOTO_ERROR (H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed") /* * Allocate more memory if necessary, careful of overflow. Also, if the * allocation fails then the file should remain in a usable state. Be * careful of non-Posix realloc() that doesn't understand what to do when * the first argument is null. */ if (addr + size > stream->eof) { unsigned char *x; haddr_t new_eof = stream->fapl.increment * ((addr+size) / stream->fapl.increment); if ((addr+size) % stream->fapl.increment) new_eof += stream->fapl.increment; if (stream->mem == NULL) x = H5MM_malloc ((size_t) new_eof); else x = H5MM_realloc (stream->mem, (size_t) new_eof); if (x == NULL) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate memory block") stream->mem = x; stream->eof = new_eof; } /* Write from BUF to memory */ HDmemcpy (stream->mem + addr, buf, size); stream->dirty = TRUE; done: FUNC_LEAVE_NOAPI(ret_value) } #endif /* H5_HAVE_STREAM */ xdmf-3.0+git20160803/Utilities/hdf5/H5V.c0000640000175000017500000013233013003006557017443 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Robb Matzke * Friday, October 10, 1997 */ #include "H5private.h" #include "H5Eprivate.h" #include "H5Oprivate.h" #include "H5Vprivate.h" /* Local macros */ #define H5V_HYPER_NDIMS H5O_LAYOUT_NDIMS /* Local prototypes */ static void H5V_stride_optimize1(unsigned *np/*in,out*/, hsize_t *elmt_size/*in,out*/, const hsize_t *size, hsize_t *stride1); static void H5V_stride_optimize2(unsigned *np/*in,out*/, hsize_t *elmt_size/*in,out*/, const hsize_t *size, hsize_t *stride1, hsize_t *stride2); #ifdef LATER static void H5V_stride_copy2(hsize_t nelmts, hsize_t elmt_size, unsigned dst_n, const hsize_t *dst_size, const ssize_t *dst_stride, void *_dst, unsigned src_n, const hsize_t *src_size, const ssize_t *src_stride, const void *_src); #endif /* LATER */ /*------------------------------------------------------------------------- * Function: H5V_stride_optimize1 * * Purpose: Given a stride vector which references elements of the * specified size, optimize the dimensionality, the stride * vector, and the element size to minimize the dimensionality * and the number of memory accesses. * * All arguments are passed by reference and their values may be * modified by this function. * * Return: None * * Programmer: Robb Matzke * Saturday, October 11, 1997 * * Modifications: * *------------------------------------------------------------------------- */ static void H5V_stride_optimize1(unsigned *np/*in,out*/, hsize_t *elmt_size/*in,out*/, const hsize_t *size, hsize_t *stride1) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5V_stride_optimize1); /* * This has to be true because if we optimize the dimensionality down to * zero we still must make one reference. */ assert(1 == H5V_vector_reduce_product(0, NULL)); /* * Combine adjacent memory accesses */ while (*np && stride1[*np-1]>0 && (hsize_t)(stride1[*np-1])==*elmt_size) { *elmt_size *= size[*np-1]; if (--*np) stride1[*np-1] += size[*np] * stride1[*np]; } FUNC_LEAVE_NOAPI_VOID } /*------------------------------------------------------------------------- * Function: H5V_stride_optimize2 * * Purpose: Given two stride vectors which reference elements of the * specified size, optimize the dimensionality, the stride * vectors, and the element size to minimize the dimensionality * and the number of memory accesses. * * All arguments are passed by reference and their values may be * modified by this function. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Saturday, October 11, 1997 * * Modifications: * Unrolled loops for common cases * Quincey Koziol * ?, ? ?, 2001? * *------------------------------------------------------------------------- */ static void H5V_stride_optimize2(unsigned *np/*in,out*/, hsize_t *elmt_size/*in,out*/, const hsize_t *size, hsize_t *stride1, hsize_t *stride2) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5V_stride_optimize2) /* * This has to be true because if we optimize the dimensionality down to * zero we still must make one reference. */ assert(1 == H5V_vector_reduce_product(0, NULL)); assert (*elmt_size>0); /* * Combine adjacent memory accesses */ /* Unroll loop for common cases */ switch(*np) { case 1: /* For 0-D datasets (dunno if this ever gets used...) */ if(stride1[0] == *elmt_size && stride2[0] == *elmt_size) { *elmt_size *= size[0]; --*np; /* *np decrements to a value of 0 now */ } /* end if */ break; case 2: /* For 1-D datasets */ if(stride1[1] == *elmt_size && stride2[1] == *elmt_size) { *elmt_size *= size[1]; --*np; /* *np decrements to a value of 1 now */ stride1[0] += size[1] * stride1[1]; stride2[0] += size[1] * stride2[1]; if(stride1[0] == *elmt_size && stride2[0] == *elmt_size) { *elmt_size *= size[0]; --*np; /* *np decrements to a value of 0 now */ } /* end if */ } /* end if */ break; case 3: /* For 2-D datasets */ if(stride1[2] == *elmt_size && stride2[2] == *elmt_size) { *elmt_size *= size[2]; --*np; /* *np decrements to a value of 2 now */ stride1[1] += size[2] * stride1[2]; stride2[1] += size[2] * stride2[2]; if(stride1[1] == *elmt_size && stride2[1] == *elmt_size) { *elmt_size *= size[1]; --*np; /* *np decrements to a value of 1 now */ stride1[0] += size[1] * stride1[1]; stride2[0] += size[1] * stride2[1]; if(stride1[0] == *elmt_size && stride2[0] == *elmt_size) { *elmt_size *= size[0]; --*np; /* *np decrements to a value of 0 now */ } /* end if */ } /* end if */ } /* end if */ break; case 4: /* For 3-D datasets */ if(stride1[3] == *elmt_size && stride2[3] == *elmt_size) { *elmt_size *= size[3]; --*np; /* *np decrements to a value of 3 now */ stride1[2] += size[3] * stride1[3]; stride2[2] += size[3] * stride2[3]; if(stride1[2] == *elmt_size && stride2[2] == *elmt_size) { *elmt_size *= size[2]; --*np; /* *np decrements to a value of 2 now */ stride1[1] += size[2] * stride1[2]; stride2[1] += size[2] * stride2[2]; if(stride1[1] == *elmt_size && stride2[1] == *elmt_size) { *elmt_size *= size[1]; --*np; /* *np decrements to a value of 1 now */ stride1[0] += size[1] * stride1[1]; stride2[0] += size[1] * stride2[1]; if(stride1[0] == *elmt_size && stride2[0] == *elmt_size) { *elmt_size *= size[0]; --*np; /* *np decrements to a value of 0 now */ } /* end if */ } /* end if */ } /* end if */ } /* end if */ break; default: while (*np && stride1[*np-1] == *elmt_size && stride2[*np-1] == *elmt_size) { *elmt_size *= size[*np-1]; if (--*np) { stride1[*np-1] += size[*np] * stride1[*np]; stride2[*np-1] += size[*np] * stride2[*np]; } } break; } /* end switch */ FUNC_LEAVE_NOAPI_VOID } /*------------------------------------------------------------------------- * Function: H5V_hyper_stride * * Purpose: Given a description of a hyperslab, this function returns * (through STRIDE[]) the byte strides appropriate for accessing * all bytes of the hyperslab and the byte offset where the * striding will begin. The SIZE can be passed to the various * stride functions. * * The dimensionality of the whole array, the hyperslab, and the * returned stride array is N. The whole array dimensions are * TOTAL_SIZE and the hyperslab is at offset OFFSET and has * dimensions SIZE. * * The stride and starting point returned will cause the * hyperslab elements to be referenced in C order. * * Return: Success: Byte offset from beginning of array to start * of striding. * * Failure: abort() -- should never fail * * Programmer: Robb Matzke * Saturday, October 11, 1997 * * Modifications: * Unrolled loops for common cases * Quincey Koziol * ?, ? ?, 2001? * *------------------------------------------------------------------------- */ hsize_t H5V_hyper_stride(unsigned n, const hsize_t *size, const hsize_t *total_size, const hsize_t *offset, hsize_t *stride/*out*/) { hsize_t skip; /*starting point byte offset */ hsize_t acc; /*accumulator */ int i; /*counter */ hsize_t ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOFUNC(H5V_hyper_stride) assert(n <= H5V_HYPER_NDIMS); assert(size); assert(total_size); assert(stride); /* init */ assert(n>0); stride[n-1] = 1; skip = offset ? offset[n-1] : 0; switch(n) { case 2: /* 1-D dataset */ assert (total_size[1]>=size[1]); stride[0] = total_size[1]-size[1]; /*overflow checked*/ acc = total_size[1]; skip += acc * (offset ? offset[0] : 0); break; case 3: /* 2-D dataset */ assert (total_size[2]>=size[2]); stride[1] = total_size[2]-size[2]; /*overflow checked*/ acc = total_size[2]; skip += acc * (offset ? (hsize_t)offset[1] : 0); assert (total_size[1]>=size[1]); stride[0] = acc * (total_size[1] - size[1]); /*overflow checked*/ acc *= total_size[1]; skip += acc * (offset ? (hsize_t)offset[0] : 0); break; case 4: /* 3-D dataset */ assert (total_size[3]>=size[3]); stride[2] = total_size[3]-size[3]; /*overflow checked*/ acc = total_size[3]; skip += acc * (offset ? (hsize_t)offset[2] : 0); assert (total_size[2]>=size[2]); stride[1] = acc * (total_size[2] - size[2]); /*overflow checked*/ acc *= total_size[2]; skip += acc * (offset ? (hsize_t)offset[1] : 0); assert (total_size[1]>=size[1]); stride[0] = acc * (total_size[1] - size[1]); /*overflow checked*/ acc *= total_size[1]; skip += acc * (offset ? (hsize_t)offset[0] : 0); break; default: /* others */ for (i=(int)(n-2), acc=1; i>=0; --i) { assert (total_size[i+1]>=size[i+1]); stride[i] = acc * (total_size[i+1] - size[i+1]); /*overflow checked*/ acc *= total_size[i+1]; skip += acc * (offset ? (hsize_t)offset[i] : 0); } break; } /* end switch */ /* Set return value */ ret_value=skip; FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5V_hyper_eq * * Purpose: Determines whether two hyperslabs are equal. This function * assumes that both hyperslabs are relative to the same array, * for if not, they could not possibly be equal. * * Return: Success: TRUE if the hyperslabs are equal (that is, * both refer to exactly the same elements of an * array) * * FALSE otherwise. * * Failure: TRUE the rank is zero or if both hyperslabs * are of zero size. * * Programmer: Robb Matzke * Friday, October 17, 1997 * * Modifications: * *------------------------------------------------------------------------- */ htri_t H5V_hyper_eq(unsigned n, const hsize_t *offset1, const hsize_t *size1, const hsize_t *offset2, const hsize_t *size2) { hsize_t nelmts1 = 1, nelmts2 = 1; unsigned i; htri_t ret_value=TRUE; /* Return value */ /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5V_hyper_eq) if (n == 0) HGOTO_DONE(TRUE) for (i=0; i 0 && n <= H5V_HYPER_NDIMS); assert(_size); assert(total_size); assert(dst); #ifndef NDEBUG for (u = 0; u < n; u++) { assert(_size[u] > 0); assert(total_size[u] > 0); } #endif /* Copy the size vector so we can modify it */ H5V_vector_cpy(n, size, _size); /* Compute an optimal destination stride vector */ dst_start = H5V_hyper_stride(n, size, total_size, offset, dst_stride); H5V_stride_optimize1(&n, &elmt_size, size, dst_stride); /* Copy */ ret_value = H5V_stride_fill(n, elmt_size, size, dst_stride, dst+dst_start, fill_value); FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5V_hyper_copy * * Purpose: Copies a hyperslab from the source to the destination. * * A hyperslab is a logically contiguous region of * multi-dimensional size SIZE of an array whose dimensionality * is N and whose total size is DST_TOTAL_SIZE or SRC_TOTAL_SIZE. * The minimum corner of the hyperslab begins at a * multi-dimensional offset from the minimum corner of the DST * (destination) or SRC (source) array. The sizes and offsets * are assumed to be in C order, that is, the first size/offset * varies the slowest while the last varies the fastest in the * mapping from N-dimensional space to linear space. This * function assumes that the array elements are single bytes (if * your array has multi-byte elements then add an additional * dimension whose size is that of your element). * * The SRC and DST array may be the same array, but the results * are undefined if the source hyperslab overlaps the * destination hyperslab. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Friday, October 10, 1997 * * Modifications: * Unrolled loops for common cases * Quincey Koziol * ?, ? ?, 2001? * *------------------------------------------------------------------------- */ herr_t H5V_hyper_copy(unsigned n, const hsize_t *_size, /*destination*/ const hsize_t *dst_size, const hsize_t *dst_offset, void *_dst, /*source*/ const hsize_t *src_size, const hsize_t *src_offset, const void *_src) { const uint8_t *src = (const uint8_t*)_src; /*cast for ptr arithmtc */ uint8_t *dst = (uint8_t*) _dst; /*cast for ptr arithmtc */ hsize_t size[H5V_HYPER_NDIMS]; /*a modifiable _size */ hsize_t src_stride[H5V_HYPER_NDIMS]; /*source stride info */ hsize_t dst_stride[H5V_HYPER_NDIMS]; /*dest stride info */ hsize_t dst_start, src_start; /*offset to start at */ hsize_t elmt_size = 1; /*element size in bytes */ herr_t ret_value; /*return status */ #ifndef NDEBUG unsigned u; #endif FUNC_ENTER_NOAPI_NOFUNC(H5V_hyper_copy) /* check args */ assert(n > 0 && n <= H5V_HYPER_NDIMS); assert(_size); assert(dst_size); assert(src_size); assert(dst); assert(src); #ifndef NDEBUG for (u = 0; u < n; u++) { assert(_size[u] > 0); assert(dst_size[u] > 0); assert(src_size[u] > 0); } #endif /* Copy the size vector so we can modify it */ H5V_vector_cpy(n, size, _size); /* Compute stride vectors for source and destination */ #ifdef NO_INLINED_CODE dst_start = H5V_hyper_stride(n, size, dst_size, dst_offset, dst_stride); src_start = H5V_hyper_stride(n, size, src_size, src_offset, src_stride); #else /* NO_INLINED_CODE */ /* in-line version of two calls to H5V_hyper_stride() */ { hsize_t dst_acc; /*accumulator */ hsize_t src_acc; /*accumulator */ int ii; /*counter */ /* init */ assert(n>0); dst_stride[n-1] = 1; src_stride[n-1] = 1; dst_start = dst_offset ? dst_offset[n-1] : 0; src_start = src_offset ? src_offset[n-1] : 0; /* Unroll loop for common cases */ switch(n) { case 2: assert (dst_size[1]>=size[1]); assert (src_size[1]>=size[1]); dst_stride[0] = dst_size[1] - size[1]; /*overflow checked*/ src_stride[0] = src_size[1] - size[1]; /*overflow checked*/ dst_acc = dst_size[1]; src_acc = src_size[1]; dst_start += dst_acc * (dst_offset ? dst_offset[0] : 0); src_start += src_acc * (src_offset ? src_offset[0] : 0); break; case 3: assert (dst_size[2]>=size[2]); assert (src_size[2]>=size[2]); dst_stride[1] = dst_size[2] - size[2]; /*overflow checked*/ src_stride[1] = src_size[2] - size[2]; /*overflow checked*/ dst_acc = dst_size[2]; src_acc = src_size[2]; dst_start += dst_acc * (dst_offset ? dst_offset[1] : 0); src_start += src_acc * (src_offset ? src_offset[1] : 0); assert (dst_size[1]>=size[1]); assert (src_size[1]>=size[1]); dst_stride[0] = dst_acc * (dst_size[1] - size[1]); /*overflow checked*/ src_stride[0] = src_acc * (src_size[1] - size[1]); /*overflow checked*/ dst_acc *= dst_size[1]; src_acc *= src_size[1]; dst_start += dst_acc * (dst_offset ? dst_offset[0] : 0); src_start += src_acc * (src_offset ? src_offset[0] : 0); break; case 4: assert (dst_size[3]>=size[3]); assert (src_size[3]>=size[3]); dst_stride[2] = dst_size[3] - size[3]; /*overflow checked*/ src_stride[2] = src_size[3] - size[3]; /*overflow checked*/ dst_acc = dst_size[3]; src_acc = src_size[3]; dst_start += dst_acc * (dst_offset ? dst_offset[2] : 0); src_start += src_acc * (src_offset ? src_offset[2] : 0); assert (dst_size[2]>=size[2]); assert (src_size[2]>=size[2]); dst_stride[1] = dst_acc * (dst_size[2] - size[2]); /*overflow checked*/ src_stride[1] = src_acc * (src_size[2] - size[2]); /*overflow checked*/ dst_acc *= dst_size[2]; src_acc *= src_size[2]; dst_start += dst_acc * (dst_offset ? dst_offset[1] : 0); src_start += src_acc * (src_offset ? src_offset[1] : 0); assert (dst_size[1]>=size[1]); assert (src_size[1]>=size[1]); dst_stride[0] = dst_acc * (dst_size[1] - size[1]); /*overflow checked*/ src_stride[0] = src_acc * (src_size[1] - size[1]); /*overflow checked*/ dst_acc *= dst_size[1]; src_acc *= src_size[1]; dst_start += dst_acc * (dst_offset ? dst_offset[0] : 0); src_start += src_acc * (src_offset ? src_offset[0] : 0); break; default: /* others */ for (ii=(int)(n-2), dst_acc=1, src_acc=1; ii>=0; --ii) { assert (dst_size[ii+1]>=size[ii+1]); assert (src_size[ii+1]>=size[ii+1]); dst_stride[ii] = dst_acc * (dst_size[ii+1] - size[ii+1]); /*overflow checked*/ src_stride[ii] = src_acc * (src_size[ii+1] - size[ii+1]); /*overflow checked*/ dst_acc *= dst_size[ii+1]; src_acc *= src_size[ii+1]; dst_start += dst_acc * (dst_offset ? dst_offset[ii] : 0); src_start += src_acc * (src_offset ? src_offset[ii] : 0); } break; } /* end switch */ } #endif /* NO_INLINED_CODE */ /* Optimize the strides as a pair */ H5V_stride_optimize2(&n, &elmt_size, size, dst_stride, src_stride); /* Perform the copy in terms of stride */ ret_value = H5V_stride_copy(n, elmt_size, size, dst_stride, dst+dst_start, src_stride, src+src_start); FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5V_stride_fill * * Purpose: Fills all bytes of a hyperslab with the same value using * memset(). * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Saturday, October 11, 1997 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5V_stride_fill(unsigned n, hsize_t elmt_size, const hsize_t *size, const hsize_t *stride, void *_dst, unsigned fill_value) { uint8_t *dst = (uint8_t*)_dst; /*cast for ptr arithmetic */ hsize_t idx[H5V_HYPER_NDIMS]; /*1-origin indices */ hsize_t nelmts; /*number of elements to fill */ hsize_t i; /*counter */ int j; /*counter */ hbool_t carry; /*subtraction carray value */ FUNC_ENTER_NOAPI_NOFUNC(H5V_stride_fill) assert (elmt_size < SIZET_MAX); H5V_vector_cpy(n, idx, size); nelmts = H5V_vector_reduce_product(n, size); for (i=0; i=0 && carry; --j) { dst += stride[j]; if (--idx[j]) carry = FALSE; else { assert(size); idx[j] = size[j]; } /* end else */ } } FUNC_LEAVE_NOAPI(SUCCEED) } /*------------------------------------------------------------------------- * Function: H5V_stride_copy * * Purpose: Uses DST_STRIDE and SRC_STRIDE to advance through the arrays * DST and SRC while copying bytes from SRC to DST. This * function minimizes the number of calls to memcpy() by * combining various strides, but it will never touch memory * outside the hyperslab defined by the strides. * * Note: If the src_stride is all zero and elmt_size is one, then it's * probably more efficient to use H5V_stride_fill() instead. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Saturday, October 11, 1997 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5V_stride_copy(unsigned n, hsize_t elmt_size, const hsize_t *size, const hsize_t *dst_stride, void *_dst, const hsize_t *src_stride, const void *_src) { uint8_t *dst = (uint8_t*)_dst; /*cast for ptr arithmetic*/ const uint8_t *src = (const uint8_t*) _src; /*cast for ptr arithmetic*/ hsize_t idx[H5V_HYPER_NDIMS]; /*1-origin indices */ hsize_t nelmts; /*num elements to copy */ hsize_t i; /*counter */ int j; /*counters */ hbool_t carry; /*carray for subtraction*/ FUNC_ENTER_NOAPI_NOFUNC(H5V_stride_copy) assert (elmt_size=0 && carry; --j) { src += src_stride[j]; dst += dst_stride[j]; if (--idx[j]) carry = FALSE; else { assert(size); idx[j] = size[j]; } } } } else { H5_CHECK_OVERFLOW(elmt_size,hsize_t,size_t); HDmemcpy (dst, src, (size_t)elmt_size); /*lint !e671 The elmt_size will be OK */ } FUNC_LEAVE_NOAPI(SUCCEED) } /*------------------------------------------------------------------------- * Function: H5V_stride_copy_s * * Purpose: Uses DST_STRIDE and SRC_STRIDE to advance through the arrays * DST and SRC while copying bytes from SRC to DST. This * function minimizes the number of calls to memcpy() by * combining various strides, but it will never touch memory * outside the hyperslab defined by the strides. * * Note: If the src_stride is all zero and elmt_size is one, then it's * probably more efficient to use H5V_stride_fill() instead. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Saturday, October 11, 1997 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5V_stride_copy_s(unsigned n, hsize_t elmt_size, const hsize_t *size, const hssize_t *dst_stride, void *_dst, const hssize_t *src_stride, const void *_src) { uint8_t *dst = (uint8_t*)_dst; /*cast for ptr arithmetic*/ const uint8_t *src = (const uint8_t*) _src; /*cast for ptr arithmetic*/ hsize_t idx[H5V_HYPER_NDIMS]; /*1-origin indices */ hsize_t nelmts; /*num elements to copy */ hsize_t i; /*counter */ int j; /*counters */ hbool_t carry; /*carray for subtraction*/ FUNC_ENTER_NOAPI_NOFUNC(H5V_stride_copy_s) assert (elmt_size=0 && carry; --j) { src += src_stride[j]; dst += dst_stride[j]; if (--idx[j]) carry = FALSE; else { assert(size); idx[j] = size[j]; } } } } else { H5_CHECK_OVERFLOW(elmt_size,hsize_t,size_t); HDmemcpy (dst, src, (size_t)elmt_size); /*lint !e671 The elmt_size will be OK */ } FUNC_LEAVE_NOAPI(SUCCEED) } #ifdef LATER /*------------------------------------------------------------------------- * Function: H5V_stride_copy2 * * Purpose: Similar to H5V_stride_copy() except the source and * destination each have their own dimensionality and size and * we copy exactly NELMTS elements each of size ELMT_SIZE. The * size counters wrap if NELMTS is more than a size counter. * * Return: None * * Programmer: Robb Matzke * Saturday, October 11, 1997 * * Modifications: * *------------------------------------------------------------------------- */ static void H5V_stride_copy2(hsize_t nelmts, hsize_t elmt_size, /* destination */ unsigned dst_n, const hsize_t *dst_size, const hsize_t *dst_stride, void *_dst, /* source */ unsigned src_n, const hsize_t *src_size, const hsize_t *src_stride, const void *_src) { uint8_t *dst = (uint8_t *) _dst; const uint8_t *src = (const uint8_t *) _src; hsize_t dst_idx[H5V_HYPER_NDIMS]; hsize_t src_idx[H5V_HYPER_NDIMS]; hsize_t i; /* Local index variable */ int j; /* Local index variable */ hbool_t carry; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5V_stride_copy2) assert (elmt_size < SIZET_MAX); assert(dst_n>0); assert(src_n>0); H5V_vector_cpy(dst_n, dst_idx, dst_size); H5V_vector_cpy(src_n, src_idx, src_size); for (i=0; i=0 && carry; --j) { dst += dst_stride[j]; if (--dst_idx[j]) carry = FALSE; else { assert(dst_size); dst_idx[j] = dst_size[j]; } /* end else */ } for (j=(int)(src_n-1), carry=TRUE; j>=0 && carry; --j) { src += src_stride[j]; if (--src_idx[j]) carry = FALSE; else { assert(src_size); src_idx[j] = src_size[j]; } /* end else */ } } FUNC_LEAVE_NOAPI_VOID } #endif /* LATER */ /*------------------------------------------------------------------------- * Function: H5V_array_fill * * Purpose: Fills all bytes of an array with the same value using * memset(). Increases amount copied by power of two until the * halfway point is crossed, then copies the rest in one swoop. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Thursday, June 18, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5V_array_fill(void *_dst, const void *src, size_t size, size_t count) { size_t copy_size; /* size of the buffer to copy */ size_t copy_items; /* number of items currently copying*/ size_t items_left; /* number of items left to copy */ uint8_t *dst=(uint8_t*)_dst;/* alias for pointer arithmetic */ FUNC_ENTER_NOAPI_NOFUNC(H5V_array_fill) assert (dst); assert (src); assert (size < SIZET_MAX && size > 0); assert (count < SIZET_MAX && count > 0); HDmemcpy(dst, src, size); /* copy first item */ /* Initialize counters, etc. while compensating for first element copied */ copy_size = size; copy_items = 1; items_left = count - 1; dst += size; /* copy until we've copied at least half of the items */ while (items_left >= copy_items) { HDmemcpy(dst, _dst, copy_size); /* copy the current chunk */ dst += copy_size; /* move the offset for the next chunk */ items_left -= copy_items; /* decrement the number of items left */ copy_size *= 2; /* increase the size of the chunk to copy */ copy_items *= 2; /* increase the count of items we are copying */ } /* end while */ if (items_left > 0) /* if there are any items left to copy */ HDmemcpy(dst, _dst, items_left * size); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5V_array_fill() */ /*------------------------------------------------------------------------- * Function: H5V_array_down * * Purpose: Given a set of dimension sizes, calculate the size of each * "down" slice. This is the size of the dimensions for all the * dimensions below the current one, which is used for indexing * offsets in this dimension. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Monday, April 28, 2003 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5V_array_down(unsigned n, const hsize_t *total_size, hsize_t *down) { hsize_t acc; /*accumulator */ int i; /*counter */ FUNC_ENTER_NOAPI_NOFUNC(H5V_array_down) assert(n <= H5V_HYPER_NDIMS); assert(total_size); assert(down); /* Build the sizes of each dimension in the array */ /* (From fastest to slowest) */ for(i=(int)(n-1),acc=1; i>=0; i--) { down[i]=acc; acc *= total_size[i]; } /* end for */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5V_array_down() */ /*------------------------------------------------------------------------- * Function: H5V_array_offset_pre * * Purpose: Given a coordinate description of a location in an array, this * function returns the byte offset of the coordinate. * * The dimensionality of the whole array, and the offset is N. * The whole array dimensions are TOTAL_SIZE and the coordinate * is at offset OFFSET. * * Return: Success: Byte offset from beginning of array to element offset * Failure: abort() -- should never fail * * Programmer: Quincey Koziol * Tuesday, June 22, 1999 * * Modifications: * Use precomputed accumulator array * Quincey Koziol * Saturday, April 26, 2003 * *------------------------------------------------------------------------- */ hsize_t H5V_array_offset_pre(unsigned n, const hsize_t *acc, const hsize_t *offset) { int i; /*counter */ hsize_t ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOFUNC(H5V_array_offset_pre) assert(n <= H5V_HYPER_NDIMS); assert(acc); assert(offset); /* Compute offset in array */ for (i=(int)(n-1), ret_value=0; i>=0; --i) ret_value += acc[i] * offset[i]; FUNC_LEAVE_NOAPI(ret_value) } /* end H5V_array_offset_pre() */ /*------------------------------------------------------------------------- * Function: H5V_array_offset * * Purpose: Given a coordinate description of a location in an array, this * function returns the byte offset of the coordinate. * * The dimensionality of the whole array, and the offset is N. * The whole array dimensions are TOTAL_SIZE and the coordinate * is at offset OFFSET. * * Return: Success: Byte offset from beginning of array to element offset * Failure: abort() -- should never fail * * Programmer: Quincey Koziol * Tuesday, June 22, 1999 * * Modifications: * *------------------------------------------------------------------------- */ hsize_t H5V_array_offset(unsigned n, const hsize_t *total_size, const hsize_t *offset) { hsize_t acc_arr[H5V_HYPER_NDIMS]; /* Accumulated size of down dimensions */ hsize_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5V_array_offset, (HDabort(), 0)) /*lint !e527 Don't worry about unreachable statement */ assert(n <= H5V_HYPER_NDIMS); assert(total_size); assert(offset); /* Build the sizes of each dimension in the array */ if(H5V_array_down(n,total_size,acc_arr)<0) HGOTO_ERROR(H5E_INTERNAL, H5E_BADVALUE, UFAIL, "can't compute down sizes") /* Set return value */ ret_value=H5V_array_offset_pre(n,acc_arr,offset); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5V_array_offset() */ /*------------------------------------------------------------------------- * Function: H5V_array_calc * * Purpose: Given a linear offset in an array and the dimensions of that * array, this function computes the coordinates of that offset * in the array. * * The dimensionality of the whole array, and the coordinates is N. * The array dimensions are TOTAL_SIZE and the coordinates * are returned in COORD. The linear offset is in OFFSET. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Wednesday, April 16, 2003 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5V_array_calc(hsize_t offset, unsigned n, const hsize_t *total_size, hsize_t *coords) { hsize_t idx[H5V_HYPER_NDIMS]; /* Size of each dimension in bytes */ hsize_t acc; /* Size accumulator */ unsigned u; /* Local index variable */ int i; /* Local index variable */ FUNC_ENTER_NOAPI_NOFUNC(H5V_array_calc) /* Sanity check */ assert(n <= H5V_HYPER_NDIMS); assert(total_size); assert(coords); /* Build the sizes of each dimension in the array */ /* (From fastest to slowest) */ for(i=(int)(n-1),acc=1; i>=0; i--) { idx[i]=acc; acc *= total_size[i]; } /* end for */ /* Compute the coordinates from the offset */ for(u=0; u * Friday, March 27, 1998 */ #ifndef _H5HGprivate_H #define _H5HGprivate_H /* Include package's public header */ #include "H5HGpublic.h" /* Private headers needed by this file. */ #include "H5Fprivate.h" /* File access */ /* * Each collection has a magic number for some redundancy. */ #define H5HG_MAGIC "GCOL" #define H5HG_SIZEOF_MAGIC 4 /* Information to locate object in global heap */ typedef struct H5HG_t { haddr_t addr; /*address of collection */ size_t idx; /*object ID within collection */ } H5HG_t; /* Typedef for heap in memory (defined in H5HGpkg.h) */ typedef struct H5HG_heap_t H5HG_heap_t; H5_DLL herr_t H5HG_insert(H5F_t *f, hid_t dxpl_id, size_t size, void *obj, H5HG_t *hobj/*out*/); H5_DLL void *H5HG_read(H5F_t *f, hid_t dxpl_id, H5HG_t *hobj, void *object); H5_DLL int H5HG_link(H5F_t *f, hid_t dxpl_id, const H5HG_t *hobj, int adjust); H5_DLL herr_t H5HG_remove(H5F_t *f, hid_t dxpl_id, H5HG_t *hobj); /* Debugging functions */ H5_DLL herr_t H5HG_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int fwidth); #endif xdmf-3.0+git20160803/Utilities/hdf5/H5Tfloat.c0000640000175000017500000003436613003006557020501 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Module Info: This module contains the functionality for floating-point * datatypes in the H5T interface. */ #define H5T_PACKAGE /*suppress error about including H5Tpkg */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5T_init_float_interface #include "H5private.h" /*generic functions */ #include "H5Eprivate.h" /*error handling */ #include "H5Iprivate.h" /*ID functions */ #include "H5Tpkg.h" /*data-type functions */ /*-------------------------------------------------------------------------- NAME H5T_init_float_interface -- Initialize interface-specific information USAGE herr_t H5T_init_float_interface() RETURNS Non-negative on success/Negative on failure DESCRIPTION Initializes any interface-specific data or routines. (Just calls H5T_init_iterface currently). --------------------------------------------------------------------------*/ static herr_t H5T_init_float_interface(void) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_init_float_interface) FUNC_LEAVE_NOAPI(H5T_init()) } /* H5T_init_float_interface() */ /*------------------------------------------------------------------------- * Function: H5Tget_fields * * Purpose: Returns information about the locations of the various bit * fields of a floating point datatype. The field positions * are bit positions in the significant region of the datatype. * Bits are numbered with the least significant bit number zero. * * Any (or even all) of the arguments can be null pointers. * * Return: Success: Non-negative, field locations and sizes are * returned through the arguments. * * Failure: Negative * * Programmer: Robb Matzke * Wednesday, January 7, 1998 * * Modifications: * Robb Matzke, 22 Dec 1998 * Also works with derived datatypes. *------------------------------------------------------------------------- */ herr_t H5Tget_fields(hid_t type_id, size_t *spos/*out*/, size_t *epos/*out*/, size_t *esize/*out*/, size_t *mpos/*out*/, size_t *msize/*out*/) { H5T_t *dt = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Tget_fields, FAIL) H5TRACE6("e","ixxxxx",type_id,spos,epos,esize,mpos,msize); /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") while (dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ if (H5T_FLOAT != dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for datatype class") /* Get values */ if (spos) *spos = dt->shared->u.atomic.u.f.sign; if (epos) *epos = dt->shared->u.atomic.u.f.epos; if (esize) *esize = dt->shared->u.atomic.u.f.esize; if (mpos) *mpos = dt->shared->u.atomic.u.f.mpos; if (msize) *msize = dt->shared->u.atomic.u.f.msize; done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5Tset_fields * * Purpose: Sets the locations and sizes of the various floating point * bit fields. The field positions are bit positions in the * significant region of the datatype. Bits are numbered with * the least significant bit number zero. * * Fields are not allowed to extend beyond the number of bits of * precision, nor are they allowed to overlap with one another. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Wednesday, January 7, 1998 * * Modifications: * Robb Matzke, 22 Dec 1998 * Also works for derived datatypes. * *------------------------------------------------------------------------- */ herr_t H5Tset_fields(hid_t type_id, size_t spos, size_t epos, size_t esize, size_t mpos, size_t msize) { H5T_t *dt = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Tset_fields, FAIL) H5TRACE6("e","izzzzz",type_id,spos,epos,esize,mpos,msize); /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") if (H5T_STATE_TRANSIENT!=dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "datatype is read-only") while (dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ if (H5T_FLOAT != dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for datatype class") if (epos + esize > dt->shared->u.atomic.prec) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "exponent bit field size/location is invalid") if (mpos + msize > dt->shared->u.atomic.prec) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "mantissa bit field size/location is invalid") if (spos >= dt->shared->u.atomic.prec) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "sign location is not valid") /* Check for overlap */ if (spos >= epos && spos < epos + esize) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "sign bit appears within exponent field") if (spos >= mpos && spos < mpos + msize) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "sign bit appears within mantissa field") if ((mpos < epos && mpos + msize > epos) || (epos < mpos && epos + esize > mpos)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "exponent and mantissa fields overlap") /* Commit */ dt->shared->u.atomic.u.f.sign = spos; dt->shared->u.atomic.u.f.epos = epos; dt->shared->u.atomic.u.f.mpos = mpos; dt->shared->u.atomic.u.f.esize = esize; dt->shared->u.atomic.u.f.msize = msize; done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5Tget_ebias * * Purpose: Retrieves the exponent bias of a floating-point type. * * Return: Success: The bias * * Failure: 0 * * Programmer: Robb Matzke * Wednesday, January 7, 1998 * * Modifications: * Robb Matzke, 22 Dec 1998 * Also works with derived datatypes. *------------------------------------------------------------------------- */ size_t H5Tget_ebias(hid_t type_id) { H5T_t *dt = NULL; size_t ret_value; FUNC_ENTER_API(H5Tget_ebias, 0) H5TRACE1("z","i",type_id); /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a datatype") while (dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ if (H5T_FLOAT != dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, 0, "operation not defined for datatype class") /* bias */ H5_ASSIGN_OVERFLOW(ret_value,dt->shared->u.atomic.u.f.ebias,uint64_t,size_t); done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5Tset_ebias * * Purpose: Sets the exponent bias of a floating-point type. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Wednesday, January 7, 1998 * * Modifications: * Robb Matzke, 22 Dec 1998 * Also works with derived datatypes. * *------------------------------------------------------------------------- */ herr_t H5Tset_ebias(hid_t type_id, size_t ebias) { H5T_t *dt = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Tset_ebias, FAIL) H5TRACE2("e","iz",type_id,ebias); /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") if (H5T_STATE_TRANSIENT!=dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "datatype is read-only") while (dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ if (H5T_FLOAT != dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for datatype class") /* Commit */ dt->shared->u.atomic.u.f.ebias = ebias; done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5Tget_norm * * Purpose: Returns the mantisssa normalization of a floating-point data * type. * * Return: Success: Normalization ID * * Failure: H5T_NORM_ERROR (Negative) * * Programmer: Robb Matzke * Wednesday, January 7, 1998 * * Modifications: * Robb Matzke, 22 Dec 1998 * Also works with derived datatypes. * *------------------------------------------------------------------------- */ H5T_norm_t H5Tget_norm(hid_t type_id) { H5T_t *dt = NULL; H5T_norm_t ret_value; FUNC_ENTER_API(H5Tget_norm, H5T_NORM_ERROR) H5TRACE1("Tn","i",type_id); /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_NORM_ERROR, "not a datatype") while (dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ if (H5T_FLOAT != dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5T_NORM_ERROR, "operation not defined for datatype class") /* norm */ ret_value = dt->shared->u.atomic.u.f.norm; done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5Tset_norm * * Purpose: Sets the mantissa normalization method for a floating point * datatype. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Wednesday, January 7, 1998 * * Modifications: * Robb Matzke, 22 Dec 1998 * Also works for derived datatypes. * *------------------------------------------------------------------------- */ herr_t H5Tset_norm(hid_t type_id, H5T_norm_t norm) { H5T_t *dt = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Tset_norm, FAIL) H5TRACE2("e","iTn",type_id,norm); /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") if (H5T_STATE_TRANSIENT!=dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "datatype is read-only") if (norm < H5T_NORM_IMPLIED || norm > H5T_NORM_NONE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal normalization") while (dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ if (H5T_FLOAT != dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for datatype class") /* Commit */ dt->shared->u.atomic.u.f.norm = norm; done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5Tget_inpad * * Purpose: If any internal bits of a floating point type are unused * (that is, those significant bits which are not part of the * sign, exponent, or mantissa) then they will be filled * according to the value of this property. * * Return: Success: The internal padding type. * * Failure: H5T_PAD_ERROR (Negative) * * Programmer: Robb Matzke * Friday, January 9, 1998 * * Modifications: * Robb Matzke, 22 Dec 1998 * Also works for derived datatypes. * *------------------------------------------------------------------------- */ H5T_pad_t H5Tget_inpad(hid_t type_id) { H5T_t *dt = NULL; H5T_pad_t ret_value; FUNC_ENTER_API(H5Tget_inpad, H5T_PAD_ERROR) H5TRACE1("Tp","i",type_id); /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_PAD_ERROR, "not a datatype") while (dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ if (H5T_FLOAT != dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5T_PAD_ERROR, "operation not defined for datatype class") /* pad */ ret_value = dt->shared->u.atomic.u.f.pad; done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5Tset_inpad * * Purpose: If any internal bits of a floating point type are unused * (that is, those significant bits which are not part of the * sign, exponent, or mantissa) then they will be filled * according to the value of this property. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Friday, January 9, 1998 * * Modifications: * Robb Matzke, 22 Dec 1998 * Also works for derived datatypes. * *------------------------------------------------------------------------- */ herr_t H5Tset_inpad(hid_t type_id, H5T_pad_t pad) { H5T_t *dt = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Tset_inpad, FAIL) H5TRACE2("e","iTp",type_id,pad); /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") if (H5T_STATE_TRANSIENT!=dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "datatype is read-only") if (pad < H5T_PAD_ZERO || pad >= H5T_NPAD) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal internal pad type") while (dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ if (H5T_FLOAT != dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for datatype class") /* Commit */ dt->shared->u.atomic.u.f.pad = pad; done: FUNC_LEAVE_API(ret_value) } xdmf-3.0+git20160803/Utilities/hdf5/H5Tfixed.c0000640000175000017500000001267713003006557020474 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Module Info: This module contains the functionality for fixed-point (i.e. * integer) datatypes in the H5T interface. */ #define H5T_PACKAGE /*suppress error about including H5Tpkg */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5T_init_fixed_interface #include "H5private.h" /*generic functions */ #include "H5Eprivate.h" /*error handling */ #include "H5Iprivate.h" /*ID functions */ #include "H5Tpkg.h" /*data-type functions */ /*-------------------------------------------------------------------------- NAME H5T_init_fixed_interface -- Initialize interface-specific information USAGE herr_t H5T_init_fixed_interface() RETURNS Non-negative on success/Negative on failure DESCRIPTION Initializes any interface-specific data or routines. (Just calls H5T_init_iterface currently). --------------------------------------------------------------------------*/ static herr_t H5T_init_fixed_interface(void) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_init_fixed_interface) FUNC_LEAVE_NOAPI(H5T_init()) } /* H5T_init_fixed_interface() */ /*------------------------------------------------------------------------- * Function: H5Tget_sign * * Purpose: Retrieves the sign type for an integer type. * * Return: Success: The sign type. * * Failure: H5T_SGN_ERROR (Negative) * * Programmer: Robb Matzke * Wednesday, January 7, 1998 * * Modifications: * Robb Matzke, 22 Dec 1998 * Also works with derived datatypes. *------------------------------------------------------------------------- */ H5T_sign_t H5Tget_sign(hid_t type_id) { H5T_t *dt = NULL; H5T_sign_t ret_value; FUNC_ENTER_API(H5Tget_sign, H5T_SGN_ERROR) H5TRACE1("Ts","i",type_id); /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_SGN_ERROR, "not an integer datatype") ret_value = H5T_get_sign(dt); done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5T_get_sign * * Purpose: Private function for H5Tget_sign. Retrieves the sign type * for an integer type. * * Return: Success: The sign type. * * Failure: H5T_SGN_ERROR (Negative) * * Programmer: Raymond Lu * October 8, 2002 * * Modifications: * *------------------------------------------------------------------------- */ H5T_sign_t H5T_get_sign(H5T_t const *dt) { H5T_sign_t ret_value; FUNC_ENTER_NOAPI(H5T_get_sign, H5T_SGN_ERROR) assert(dt); /* Defer to parent */ while(dt->shared->parent) dt = dt->shared->parent; /* Check args */ if (H5T_INTEGER!=dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5T_SGN_ERROR, "operation not defined for datatype class") /* Sign */ ret_value = dt->shared->u.atomic.u.i.sign; done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5Tset_sign * * Purpose: Sets the sign property for an integer. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Wednesday, January 7, 1998 * * Modifications: * Robb Matzke, 22 Dec 1998 * Also works with derived datatypes. * *------------------------------------------------------------------------- */ herr_t H5Tset_sign(hid_t type_id, H5T_sign_t sign) { H5T_t *dt = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Tset_sign, FAIL) H5TRACE2("e","iTs",type_id,sign); /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an integer datatype") if (H5T_STATE_TRANSIENT!=dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "datatype is read-only") if (sign < H5T_SGN_NONE || sign >= H5T_NSGN) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal sign type") if (H5T_ENUM==dt->shared->type && dt->shared->u.enumer.nmembs>0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not allowed after members are defined") while (dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ if (H5T_INTEGER!=dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for datatype class") /* Commit */ dt->shared->u.atomic.u.i.sign = sign; done: FUNC_LEAVE_API(ret_value) } xdmf-3.0+git20160803/Utilities/hdf5/H5MPprivate.h0000640000175000017500000003412413003006557021154 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Header file for private definitions of the MPE instrumentation. */ #ifndef _H5MPprivate_H #define _H5MPprivate_H #ifdef H5_HAVE_MPE /*------------------------------------------------------------------------ * Purpose: Begin to collect MPE log information for a function. It should * be ahead of the actual function's process. * * Programmer: Long Wang * *------------------------------------------------------------------------ */ #include "mpe.h" /* * #define eventa(func_name) h5_mpe_ ## func_name ## _a * #define eventb(func_name) h5_mpe_ ## func_name ## _b */ #define eventa(func_name) h5_mpe_eventa #define eventb(func_name) h5_mpe_eventb #define COLOR(func_name) color_ ## func_name #define MPE_LOG_VARS(func_name) \ static int eventa(func_name) = -1; \ static int eventb(func_name) = -1; \ char* p_end_funcname = #func_name; \ char* p_event_start = "start" #func_name; #define BEGIN_MPE_LOG(func_name) \ if (H5_MPEinit_g){ \ if (H5_MPEinit_g && eventa(func_name) == -1 && eventb(func_name) == -1) { \ char* p_color = COLOR(func_name); \ eventa(func_name)=MPE_Log_get_event_number(); \ eventb(func_name)=MPE_Log_get_event_number(); \ MPE_Describe_state(eventa(func_name), eventb(func_name), p_end_funcname,p_color); \ } \ MPE_Log_event(eventa(func_name), 0, p_event_start); \ } /*------------------------------------------------------------------------ * Purpose: Finish the collection of MPE log information for a function. * It should be after the actual function's process. * * Programmer: Long Wang */ #define FINISH_MPE_LOG \ if (H5_MPEinit_g) { \ MPE_Log_event(eventb(func_name), 0, p_end_funcname); \ } /* color for each public HDF5 API function */ #define color_H5_init_library "red" #define color_H5open "red" #define color_H5close "red" #define color_H5dont_atexit "red" #define color_H5garbage_collect "red" #define color_H5set_free_list_limits "red" #define color_H5get_libversion "red" #define color_H5check_version "red" #define color_H5Dcreate "red" #define color_H5Dopen "red" #define color_H5Dclose "red" #define color_H5Dget_space "red" #define color_H5Dget_space_status "red" #define color_H5Dget_type "red" #define color_H5Dget_create_plist "red" #define color_H5Dget_storage_size "red" #define color_H5Dread "red" #define color_H5Dwrite "red" #define color_H5Dextend "red" #define color_H5Diterate "red" #define color_H5Dvlen_reclaim "red" #define color_H5Dvlen_get_buf_size "red" #define color_H5Dfill "red" #define color_H5Ddebug "red" #define color_H5Dset_extent "red" #define color_H5Dget_offset "red" #define color_H5Eset_auto "red" #define color_H5Eget_auto "red" #define color_H5Eclear "red" #define color_H5Eprint "red" #define color_H5Ewalk "red" #define color_H5Eget_major "red" #define color_H5Eget_minor "red" #define color_H5Epush "red" #define color_H5Fis_hdf5 "red" #define color_H5Fcreate "red" #define color_H5Fopen "red" #define color_H5Freopen "red" #define color_H5Fflush "red" #define color_H5Fclose "red" #define color_H5Fget_create_plist "red" #define color_H5Fget_access_plist "red" #define color_H5Fget_obj_count "red" #define color_H5Fget_vfd_handle "red" #define color_H5Fget_obj_ids "red" #define color_H5Fmount "red" #define color_H5Funmount "red" #define color_H5Fget_freespace "red" #define color_H5Fget_filesize "red" #define color_H5Fget_name "red" #define color_H5Gcreate "red" #define color_H5Gopen "red" #define color_H5Gclose "red" #define color_H5Giterate "red" #define color_H5Gmove2 "red" #define color_H5Glink2 "red" #define color_H5Gunlink "red" #define color_H5Gget_objinfo "red" #define color_H5Gget_linkval "red" #define color_H5Gset_comment "red" #define color_H5Gget_comment "red" #define color_H5Gget_num_objs "red" #define color_H5Gget_objname_by_idx "red" #define color_H5Gget_objtype_by_idx "red" #define color_H5Idec_ref "red" #define color_H5Iget_file_id "red" #define color_H5Iget_name "red" #define color_H5Iget_ref "red" #define color_H5Iget_type "red" #define color_H5Iinc_ref "red" #define color_H5Rdereference "red" #define color_H5Rcreate "red" #define color_H5Rget_region "red" #define color_H5Rget_object_type "red" #define color_H5Rget_obj_type "red" #define color_H5Topen "red" #define color_H5Tcreate "red" #define color_H5Tcopy "red" #define color_H5Tclose "red" #define color_H5Tequal "red" #define color_H5Tlock "red" #define color_H5Tcommit "red" #define color_H5Tcommitted "red" #define color_H5Tinsert "red" #define color_H5Tpack "red" #define color_H5Tenum_create "red" #define color_H5Tenum_insert "red" #define color_H5Tenum_nameof "red" #define color_H5Tenum_valueof "red" #define color_H5Tvlen_create "red" #define color_H5Tarray_create "red" #define color_H5Tis_variable_str "red" #define color_H5Tget_array_dims "red" #define color_H5Tget_array_ndims "red" #define color_H5Tset_tag "red" #define color_H5Tget_tag "red" #define color_H5Tget_super "red" #define color_H5Tget_class "red" #define color_H5Tdetect_class "red" #define color_H5Tget_size "red" #define color_H5Tget_order "red" #define color_H5Tget_precision "red" #define color_H5Tget_offset "red" #define color_H5Tget_pad "red" #define color_H5Tget_sign "red" #define color_H5Tget_fields "red" #define color_H5Tget_ebias "red" #define color_H5Tget_norm "red" #define color_H5Tget_inpad "red" #define color_H5Tget_strpad "red" #define color_H5Tget_nmembers "red" #define color_H5Tget_num_members "red" #define color_H5Tget_member_name "red" #define color_H5Tget_member_index "red" #define color_H5Tget_member_offset "red" #define color_H5Tget_member_class "red" #define color_H5Tget_member_value "red" #define color_H5Tget_member_type "red" #define color_H5Tget_cset "red" #define color_H5Tset_size "red" #define color_H5Tset_order "red" #define color_H5Tset_precision "red" #define color_H5Tset_offset "red" #define color_H5Tset_pad "red" #define color_H5Tset_sign "red" #define color_H5Tset_fields "red" #define color_H5Tset_ebias "red" #define color_H5Tset_norm "red" #define color_H5Tset_inpad "red" #define color_H5Tset_cset "red" #define color_H5Tset_strpad "red" #define color_H5Tregister "red" #define color_H5Tunregister "red" #define color_H5Tfind "red" #define color_H5Tconvert "red" #define color_H5Tget_overflow "red" #define color_H5Tset_overflow "red" #define color_H5Tget_native_type "red" #define color_H5Acreate "red" #define color_H5Aopen_name "red" #define color_H5Aopen_idx "red" #define color_H5Awrite "red" #define color_H5Aread "red" #define color_H5Aclose "red" #define color_H5Aget_space "red" #define color_H5Aget_type "red" #define color_H5Aget_name "red" #define color_H5Aget_num_attrs "red" #define color_H5Aget_storage_size "red" #define color_H5Aiterate "red" #define color_H5Adelete "red" #define color_H5Arename "red" #define color_H5FDregister "red" #define color_H5FDunregister "red" #define color_H5FDopen "red" #define color_H5FDclose "red" #define color_H5FDcmp "red" #define color_H5FDquery "red" #define color_H5FDalloc "red" #define color_H5FDfree "red" #define color_H5FDrealloc "red" #define color_H5FDget_eoa "red" #define color_H5FDset_eoa "red" #define color_H5FDget_eof "red" #define color_H5FDget_vdf_handle "red" #define color_H5FDread "red" #define color_H5FDwrite "red" #define color_H5FDflush "red" #define color_H5FDget_vfd_handle "red" #define color_H5Pset_fapl_core "red" #define color_H5Pget_fapl_core "red" #define color_H5Pset_fapl_family "red" #define color_H5Pget_fapl_family "red" #define color_H5Pset_fapl_log "red" #define color_H5Pget_fapl_log "red" #define color_H5Pset_fapl_mpio "red" #define color_H5Pget_fapl_mpio "red" #define color_H5Pset_dxpl_mpio "red" #define color_H5Pget_dxpl_mpio "red" #define color_H5Pset_fapl_mpiposix "red" #define color_H5Pget_fapl_mpiposix "red" #define color_H5Pset_fapl_sec2 "red" #define color_H5Pget_fapl_sec2 "red" #define color_H5Pset_fapl_stream "red" #define color_H5Pget_fapl_stream "red" #define color_H5Pget_filter "red" #define color_H5Pset_btree_ratios "red" #define color_H5Pget_btree_ratios "red" #define color_H5Pset_shuffle "red" #define color_H5Pcreate_class "red" #define color_H5Pget_class_name "red" #define color_H5Pcreate "red" #define color_H5Pregister "red" #define color_H5Pinsert "red" #define color_H5Pset "red" #define color_H5Pexist "red" #define color_H5Pget_size "red" #define color_H5Pget_nprops "red" #define color_H5Pget_class "red" #define color_H5Pget_class_parent "red" #define color_H5Pget "red" #define color_H5Pequal "red" #define color_H5Pisa_class "red" #define color_H5Piterate "red" #define color_H5Pcopy_prop "red" #define color_H5Premove "red" #define color_H5Punregister "red" #define color_H5Pclose_class "red" #define color_H5Pclose "red" #define color_H5Pcopy "red" #define color_H5Pget_version "red" #define color_H5Pset_userblock "red" #define color_H5Pget_userblock "red" #define color_H5Pset_alignment "red" #define color_H5Pget_alignment "red" #define color_H5Pset_sizes "red" #define color_H5Pget_sizes "red" #define color_H5Pset_sym_k "red" #define color_H5Pget_sym_k "red" #define color_H5Pset_istore_k "red" #define color_H5Pget_istore_k "red" #define color_H5Pset_layout "red" #define color_H5Pget_layout "red" #define color_H5Pset_chunk "red" #define color_H5Pget_chunk "red" #define color_H5Pset_external "red" #define color_H5Pget_external_count "red" #define color_H5Pget_external "red" #define color_H5Pset_driver "red" #define color_H5Pget_driver "red" #define color_H5Pget_driver_info "red" #define color_H5Pset_family_offset "red" #define color_H5Pget_family_offset "red" #define color_H5Pset_multi_type "red" #define color_H5Pget_multi_type "red" #define color_H5Pset_buffer "red" #define color_H5Pget_buffer "red" #define color_H5Pset_preserve "red" #define color_H5Pget_preserve "red" #define color_H5Pall_filters_avail "red" #define color_H5Pset_filter "red" #define color_H5Pmodify_filter "red" #define color_H5Pget_nfilters "red" #define color_H5Pget_filter "red" #define color_H5Pget_filter_by_id "red" #define color_H5Premove_filter "red" #define color_H5Pset_deflate "red" #define color_H5Pset_fletcher32 "red" #define color_H5Pset_szip "red" #define color_H5Pset_cache "red" #define color_H5Pget_cache "red" #define color_H5Pset_hyper_cache "red" #define color_H5Pget_hyper_cache "red" #define color_H5Pset_htree_ratios "red" #define color_H5Pget_htree_ratios "red" #define color_H5Pset_fill_value "red" #define color_H5Pget_fill_value "red" #define color_H5Pfill_value_defined "red" #define color_H5Pset_alloc_time "red" #define color_H5Pget_alloc_time "red" #define color_H5Pset_fill_time "red" #define color_H5Pget_fill_time "red" #define color_H5Pset_gc_references "red" #define color_H5Pget_gc_references "red" #define color_H5Pset_fclose_degree "red" #define color_H5Pget_fclose_degree "red" #define color_H5Pset_vlen_mem_manager "red" #define color_H5Pget_vlen_mem_manager "red" #define color_H5Pset_meta_block_size "red" #define color_H5Pget_meta_block_size "red" #define color_H5Pset_sieve_buf_size "red" #define color_H5Pget_sieve_buf_size "red" #define color_H5Pset_hyper_vector_size "red" #define color_H5Pget_hyper_vector_size "red" #define color_H5Pset_small_data_block_size "red" #define color_H5Pget_small_data_block_size "red" #define color_H5Pset_edc_check "red" #define color_H5Pget_edc_check "red" #define color_H5Pset_filter_callback "red" #define color_H5Screate "red" #define color_H5Screate_simple "red" #define color_H5Sset_extent_simple "red" #define color_H5Scopy "red" #define color_H5Sclose "red" #define color_H5Sget_simple_extent_npoints "red" #define color_H5Sget_simple_extent_ndims "red" #define color_H5Sget_simple_extent_dims "red" #define color_H5Sis_simple "red" #define color_H5Sset_space "red" #define color_H5Sget_select_npoints "red" #define color_H5Sselect_hyperslab "red" #define color_H5Scombine_hyperslab "red" #define color_H5Sselect_select "red" #define color_H5Scombine_select "red" #define color_H5Sselect_elements "red" #define color_H5Sget_simple_extent_type "red" #define color_H5Sset_extent_none "red" #define color_H5Sextent_copy "red" #define color_H5Sselect_all "red" #define color_H5Sselect_none "red" #define color_H5Soffset_simple "red" #define color_H5Sselect_valid "red" #define color_H5Sget_select_hyper_nblocks "red" #define color_H5Sget_select_elem_npoints "red" #define color_H5Sget_select_hyper_blocklist "red" #define color_H5Sget_select_elem_pointlist "red" #define color_H5Sget_select_bounds "red" #define color_H5Sget_select_type "red" #define color_H5Zregister "red" #define color_H5Zfilter_avail "red" #define color_H5Zunregister "red" #define color_H5Zget_filter_info "red" #else #define MPE_LOG_VARS(func_name) /* void */ #define BEGIN_MPE_LOG(func_name) /* void */ #define FINISH_MPE_LOG /* void */ #endif #endif xdmf-3.0+git20160803/Utilities/hdf5/H5Gpublic.h0000640000175000017500000001347313003006557020636 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*------------------------------------------------------------------------- * * Created: H5Gproto.h * Jul 11 1997 * Robb Matzke * * Purpose: Public declarations for the H5G package (symbol * tables). * * Modifications: * *------------------------------------------------------------------------- */ #ifndef _H5Gpublic_H #define _H5Gpublic_H /* Public headers needed by this file */ #include #include "H5public.h" #include "H5Ipublic.h" #include "H5Opublic.h" #ifdef __cplusplus extern "C" { #endif /* Types of links */ typedef enum H5G_link_t { H5G_LINK_ERROR = -1, H5G_LINK_HARD = 0, H5G_LINK_SOFT = 1 } H5G_link_t; /* * An object has a certain type. The first few numbers are reserved for use * internally by HDF5. Users may add their own types with higher values. The * values are never stored in the file -- they only exist while an * application is running. An object may satisfy the `isa' function for more * than one type. */ #ifdef H5_WANT_H5_V1_4_COMPAT #define H5G_UNKNOWN -1 /* Unknown object type */ #define H5G_LINK 0 /* Object is a symbolic link */ #define H5G_GROUP 1 /* Object is a group */ #define H5G_DATASET 2 /* Object is a dataset */ #define H5G_TYPE 3 /* Object is a named data type */ #define H5G_RESERVED_4 4 /* Reserved for future use */ #define H5G_RESERVED_5 5 /* Reserved for future use */ #define H5G_RESERVED_6 6 /* Reserved for future use */ #define H5G_RESERVED_7 7 /* Reserved for future use */ #else /*H5_WANT_H5_V1_4_COMPAT*/ typedef enum H5G_obj_t { H5G_UNKNOWN = -1, /* Unknown object type */ H5G_LINK, /* Object is a symbolic link */ H5G_GROUP, /* Object is a group */ H5G_DATASET, /* Object is a dataset */ H5G_TYPE, /* Object is a named data type */ H5G_RESERVED_4, /* Reserved for future use */ H5G_RESERVED_5, /* Reserved for future use */ H5G_RESERVED_6, /* Reserved for future use */ H5G_RESERVED_7 /* Reserved for future use */ } H5G_obj_t; #endif /*H5_WANT_H5_V1_4_COMPAT*/ #define H5G_NTYPES 256 /* Max possible number of types */ #define H5G_NLIBTYPES 8 /* Number of internal types */ #define H5G_NUSERTYPES (H5G_NTYPES-H5G_NLIBTYPES) #define H5G_USERTYPE(X) (8+(X)) /* User defined types */ /* Information about an object */ typedef struct H5G_stat_t { unsigned long fileno[2]; /*file number */ unsigned long objno[2]; /*object number */ unsigned nlink; /*number of hard links to object*/ #ifdef H5_WANT_H5_V1_4_COMPAT int type; /*basic object type */ #else /*H5_WANT_H5_V1_4_COMPAT*/ H5G_obj_t type; /*basic object type */ #endif /*H5_WANT_H5_V1_4_COMPAT*/ time_t mtime; /*modification time */ size_t linklen; /*symbolic link value length */ H5O_stat_t ohdr; /* Object header information */ } H5G_stat_t; #define H5G_SAME_LOC 0 #define H5Glink(cur_loc_id, type, cur_name, new_name) \ H5Glink2(cur_loc_id, cur_name, type, H5G_SAME_LOC, new_name) #define H5Gmove(src_loc_id, src_name, dst_name) \ H5Gmove2(src_loc_id, src_name, H5G_SAME_LOC, dst_name) typedef herr_t (*H5G_iterate_t)(hid_t group, const char *name, void *op_data); H5_DLL hid_t H5Gcreate(hid_t loc_id, const char *name, size_t size_hint); H5_DLL hid_t H5Gopen(hid_t loc_id, const char *name); H5_DLL herr_t H5Gclose(hid_t group_id); H5_DLL herr_t H5Giterate(hid_t loc_id, const char *name, int *idx, H5G_iterate_t op, void *op_data); H5_DLL herr_t H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs); H5_DLL ssize_t H5Gget_objname_by_idx(hid_t loc_id, hsize_t idx, char* name, size_t size); #ifdef H5_WANT_H5_V1_4_COMPAT H5_DLL int H5Gget_objtype_by_idx(hid_t loc_id, hsize_t idx); #else /*H5_WANT_H5_V1_4_COMPAT*/ H5_DLL H5G_obj_t H5Gget_objtype_by_idx(hid_t loc_id, hsize_t idx); #endif /*H5_WANT_H5_V1_4_COMPAT*/ H5_DLL herr_t H5Gmove2(hid_t src_loc, const char *src, hid_t dst_loc, const char *dst); H5_DLL herr_t H5Glink2(hid_t src_loc, const char *cur_name, H5G_link_t type, hid_t dst_loc, const char *new_name); H5_DLL herr_t H5Gunlink(hid_t loc_id, const char *name); H5_DLL herr_t H5Gget_objinfo(hid_t loc_id, const char *name, hbool_t follow_link, H5G_stat_t *statbuf/*out*/); H5_DLL herr_t H5Gget_linkval(hid_t loc_id, const char *name, size_t size, char *buf/*out*/); H5_DLL herr_t H5Gset_comment(hid_t loc_id, const char *name, const char *comment); H5_DLL int H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize, char *buf); #ifdef __cplusplus } #endif #endif xdmf-3.0+git20160803/Utilities/hdf5/H5Epublic.h0000640000175000017500000003442113003006557020630 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * This file contains public declarations for the H5E module. */ #ifndef _H5Epublic_H #define _H5Epublic_H #include /*FILE arg of H5Eprint() */ /* Public headers needed by this file */ #include "H5public.h" #include "H5Ipublic.h" /* * One often needs to temporarily disable automatic error reporting when * trying something that's likely or expected to fail. For instance, to * determine if an object exists one can call H5Gget_objinfo() which will fail if * the object doesn't exist. The code to try can be nested between calls to * H5Eget_auto() and H5Eset_auto(), but it's easier just to use this macro * like: * H5E_BEGIN_TRY { * ...stuff here that's likely to fail... * } H5E_END_TRY; * * Warning: don't break, return, or longjmp() from the body of the loop or * the error reporting won't be properly restored! */ #define H5E_BEGIN_TRY { \ H5E_auto_t H5E_saved_efunc; \ void *H5E_saved_edata; \ H5Eget_auto (&H5E_saved_efunc, &H5E_saved_edata); \ H5Eset_auto (NULL, NULL); #define H5E_END_TRY \ H5Eset_auto (H5E_saved_efunc, H5E_saved_edata); \ } /* * Public API Convenience Macros for Error reporting - Documented */ /* Use the Standard C __FILE__ & __LINE__ macros instead of typing them in */ #define H5Epush_sim(func,maj,min,str) H5Epush(__FILE__,func,__LINE__,maj,min,str) /* * Public API Convenience Macros for Error reporting - Undocumented */ /* Use the Standard C __FILE__ & __LINE__ macros instead of typing them in */ /* And return after pushing error onto stack */ #define H5Epush_ret(func,maj,min,str,ret) { \ H5Epush(__FILE__,func,__LINE__,maj,min,str); \ return(ret); \ } /* Use the Standard C __FILE__ & __LINE__ macros instead of typing them in */ /* And goto a label after pushing error onto stack */ #define H5Epush_goto(func,maj,min,str,label) { \ H5Epush(__FILE__,func,__LINE__,maj,min,str); \ goto label; \ } /* * Declare an enumerated type which holds all the valid major HDF error codes. */ typedef enum H5E_major_t { H5E_NONE_MAJOR = 0, /*special zero, no error */ H5E_ARGS, /*invalid arguments to routine */ H5E_RESOURCE, /*resource unavailable */ H5E_INTERNAL, /* Internal error (too specific to document * in detail) */ H5E_FILE, /*file Accessability */ H5E_IO, /*Low-level I/O */ H5E_FUNC, /*function Entry/Exit */ H5E_ATOM, /*object Atom */ H5E_CACHE, /*object Cache */ H5E_BTREE, /*B-Tree Node */ H5E_SYM, /*symbol Table */ H5E_HEAP, /*Heap */ H5E_OHDR, /*object Header */ H5E_DATATYPE, /*Datatype */ H5E_DATASPACE, /*Dataspace */ H5E_DATASET, /*Dataset */ H5E_STORAGE, /*data storage */ H5E_PLIST, /*Property lists */ H5E_ATTR, /*Attribute */ H5E_PLINE, /*Data filters */ H5E_EFL, /*External file list */ H5E_REFERENCE, /*References */ H5E_VFL, /*Virtual File Layer */ H5E_TBBT, /*Threaded, Balanced, Binary Trees */ H5E_TST, /*Ternary Search Trees */ H5E_RS, /*Reference Counted Strings */ H5E_ERROR, /*Error API */ H5E_SLIST /*Skip Lists */ } H5E_major_t; /* Declare an enumerated type which holds all the valid minor HDF error codes */ typedef enum H5E_minor_t { H5E_NONE_MINOR = 0, /*special zero, no error */ /* Argument errors */ H5E_UNINITIALIZED, /*information is unitialized */ H5E_UNSUPPORTED, /*feature is unsupported */ H5E_BADTYPE, /*incorrect type found */ H5E_BADRANGE, /*argument out of range */ H5E_BADVALUE, /*bad value for argument */ /* Resource errors */ H5E_NOSPACE, /*no space available for allocation */ H5E_CANTCOPY, /*unable to copy object */ H5E_CANTFREE, /*unable to free object */ H5E_ALREADYEXISTS, /*Object already exists */ H5E_CANTLOCK, /*Unable to lock object */ H5E_CANTUNLOCK, /*Unable to unlock object */ H5E_CANTGC, /*Unable to garbage collect */ H5E_CANTGETSIZE, /*Unable to compute size */ /* File accessability errors */ H5E_FILEEXISTS, /*file already exists */ H5E_FILEOPEN, /*file already open */ H5E_CANTCREATE, /*Can't create file */ H5E_CANTOPENFILE, /*Can't open file */ H5E_CANTCLOSEFILE, /*Can't close file */ H5E_NOTHDF5, /*not an HDF5 format file */ H5E_BADFILE, /*bad file ID accessed */ H5E_TRUNCATED, /*file has been truncated */ H5E_MOUNT, /*file mount error */ /* Generic low-level file I/O errors */ H5E_SEEKERROR, /*seek failed */ H5E_READERROR, /*read failed */ H5E_WRITEERROR, /*write failed */ H5E_CLOSEERROR, /*close failed */ H5E_OVERFLOW, /*address overflowed */ H5E_FCNTL, /*file fcntl failed */ /* Function entry/exit interface errors */ H5E_CANTINIT, /*Can't initialize object */ H5E_ALREADYINIT, /*object already initialized */ H5E_CANTRELEASE, /*Can't release object */ /* Object atom related errors */ H5E_BADATOM, /*Can't find atom information */ H5E_BADGROUP, /*Can't find group information */ H5E_CANTREGISTER, /*Can't register new atom */ H5E_CANTINC, /*Can't increment reference count */ H5E_CANTDEC, /*Can't decrement reference count */ H5E_NOIDS, /*Out of IDs for group */ /* Cache related errors */ H5E_CANTFLUSH, /*Can't flush object from cache */ H5E_CANTSERIALIZE, /*Unable to serialize data from cache */ H5E_CANTLOAD, /*Can't load object into cache */ H5E_PROTECT, /*protected object error */ H5E_NOTCACHED, /*object not currently cached */ H5E_SYSTEM, /*Internal error detected */ H5E_CANTINS, /*Unable to insert metadata into cache */ H5E_CANTRENAME, /*Unable to rename metadata */ H5E_CANTPROTECT, /*Unable to protect metadata */ H5E_CANTUNPROTECT, /*Unable to unprotect metadata */ /* B-tree related errors */ H5E_NOTFOUND, /*object not found */ H5E_EXISTS, /*object already exists */ H5E_CANTENCODE, /*Can't encode value */ H5E_CANTDECODE, /*Can't decode value */ H5E_CANTSPLIT, /*Can't split node */ H5E_CANTINSERT, /*Can't insert object */ H5E_CANTLIST, /*Can't list node */ /* Object header related errors */ H5E_LINKCOUNT, /*bad object header link count */ H5E_VERSION, /*wrong version number */ H5E_ALIGNMENT, /*alignment error */ H5E_BADMESG, /*unrecognized message */ H5E_CANTDELETE, /* Can't delete message */ H5E_BADITER, /* Iteration failed */ /* Group related errors */ H5E_CANTOPENOBJ, /*Can't open object */ H5E_CANTCLOSEOBJ, /*Can't close object */ H5E_COMPLEN, /*name component is too long */ H5E_LINK, /*link count failure */ H5E_SLINK, /*symbolic link error */ H5E_PATH, /*Problem with path to object */ /* Datatype conversion errors */ H5E_CANTCONVERT, /*Can't convert datatypes */ H5E_BADSIZE, /*Bad size for object */ /* Dataspace errors */ H5E_CANTCLIP, /*Can't clip hyperslab region */ H5E_CANTCOUNT, /*Can't count elements */ H5E_CANTSELECT, /*Can't select hyperslab */ H5E_CANTNEXT, /*Can't move to next iterator location */ H5E_BADSELECT, /*Invalid selection */ H5E_CANTCOMPARE, /*Can't compare objects */ /* Property list errors */ H5E_CANTGET, /*Can't get value */ H5E_CANTSET, /*Can't set value */ H5E_DUPCLASS, /*Duplicate class name in parent class */ /* Parallel errors */ H5E_MPI, /*some MPI function failed */ H5E_MPIERRSTR, /*MPI Error String */ /* Heap errors */ H5E_CANTRESTORE, /*Can't restore condition */ /* TBBT errors */ H5E_CANTMAKETREE, /*Can't create TBBT tree */ /* I/O pipeline errors */ H5E_NOFILTER, /*requested filter is not available */ H5E_CALLBACK, /*callback failed */ H5E_CANAPPLY, /*error from filter "can apply" callback */ H5E_SETLOCAL, /*error from filter "set local" callback */ H5E_NOENCODER, /* Filter present, but encoding disabled */ /* System level errors */ H5E_SYSERRSTR /* System error message */ } H5E_minor_t; /* Information about an error */ typedef struct H5E_error_t { H5E_major_t maj_num; /*major error number */ H5E_minor_t min_num; /*minor error number */ const char *func_name; /*function in which error occurred */ const char *file_name; /*file in which error occurred */ unsigned line; /*line in file where error occurs */ const char *desc; /*optional supplied description */ } H5E_error_t; /* Error stack traversal direction */ typedef enum H5E_direction_t { H5E_WALK_UPWARD = 0, /*begin deep, end at API function */ H5E_WALK_DOWNWARD = 1 /*begin at API function, end deep */ } H5E_direction_t; #ifdef __cplusplus extern "C" { #endif /* Error stack traversal callback function */ typedef herr_t (*H5E_walk_t)(int n, H5E_error_t *err_desc, void *client_data); typedef herr_t (*H5E_auto_t)(void *client_data); H5_DLL herr_t H5Eset_auto (H5E_auto_t func, void *client_data); H5_DLL herr_t H5Eget_auto (H5E_auto_t *func, void **client_data); H5_DLL herr_t H5Eclear (void); H5_DLL herr_t H5Eprint (FILE *stream); H5_DLL herr_t H5Ewalk (H5E_direction_t direction, H5E_walk_t func, void *client_data); H5_DLL const char *H5Eget_major (H5E_major_t major_number); H5_DLL const char *H5Eget_minor (H5E_minor_t minor_number); H5_DLL herr_t H5Epush(const char *file, const char *func, unsigned line, H5E_major_t maj, H5E_minor_t min, const char *str); #ifdef __cplusplus } #endif #endif xdmf-3.0+git20160803/Utilities/hdf5/H5Cprivate.h0000640000175000017500000003740513003006557021027 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*------------------------------------------------------------------------- * * Created: H5Cprivate.h * 6/3/04 * John Mainzer * * Purpose: Constants and typedefs available to the rest of the * library. * * Modifications: * *------------------------------------------------------------------------- */ #ifndef _H5Cprivate_H #define _H5Cprivate_H #include "H5Cpublic.h" /*public prototypes */ /* Pivate headers needed by this header */ #include "H5private.h" /* Generic Functions */ #include "H5Fprivate.h" /* File access */ #define H5C_DO_SANITY_CHECKS 0 /* This sanity checking constant was picked out of the air. Increase * or decrease it if appropriate. Its purposes is to detect corrupt * object sizes, so it probably doesn't matter if it is a bit big. * * JRM - 5/17/04 */ #define H5C_MAX_ENTRY_SIZE ((size_t)(10 * 1024 * 1024)) /* H5C_COLLECT_CACHE_STATS controls overall collection of statistics * on cache activity. In general, this #define should be set to 0. */ #define H5C_COLLECT_CACHE_STATS 0 /* H5C_COLLECT_CACHE_ENTRY_STATS controls collection of statistics * in individual cache entries. * * H5C_COLLECT_CACHE_ENTRY_STATS should only be defined to true if * H5C_COLLECT_CACHE_STATS is also defined to true. */ #if H5C_COLLECT_CACHE_STATS #define H5C_COLLECT_CACHE_ENTRY_STATS 1 #else #define H5C_COLLECT_CACHE_ENTRY_STATS 0 #endif /* H5C_COLLECT_CACHE_STATS */ #ifdef H5_HAVE_PARALLEL /* we must maintain the clean and dirty LRU lists when we are compiled * with parallel support. */ #define H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS 1 #else /* H5_HAVE_PARALLEL */ /* The clean and dirty LRU lists don't buy us anything here -- we may * want them on for testing on occasion, but in general they should be * off. */ #define H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS 0 #endif /* H5_HAVE_PARALLEL */ /* * Class methods pertaining to caching. Each type of cached object will * have a constant variable with permanent life-span that describes how * to cache the object. That variable will be of type H5C_class_t and * have the following required fields... * * LOAD: Loads an object from disk to memory. The function * should allocate some data structure and return it. * * FLUSH: Writes some data structure back to disk. It would be * wise for the data structure to include dirty flags to * indicate whether it really needs to be written. This * function is also responsible for freeing memory allocated * by the LOAD method if the DEST argument is non-zero (by * calling the DEST method). * * DEST: Just frees memory allocated by the LOAD method. * * CLEAR: Just marks object as non-dirty. * * SIZE: Report the size (on disk) of the specified cache object. * Note that the space allocated on disk may not be contiguous. */ typedef void *(*H5C_load_func_t)(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *udata1, void *udata2); typedef herr_t (*H5C_flush_func_t)(H5F_t *f, hid_t dxpl_id, hbool_t dest, haddr_t addr, void *thing); typedef herr_t (*H5C_dest_func_t)(H5F_t *f, void *thing); typedef herr_t (*H5C_clear_func_t)(H5F_t *f, void *thing, hbool_t dest); typedef herr_t (*H5C_size_func_t)(const H5F_t *f, const void *thing, size_t *size_ptr); typedef struct H5C_class_t { int id; H5C_load_func_t load; H5C_flush_func_t flush; H5C_dest_func_t dest; H5C_clear_func_t clear; H5C_size_func_t size; } H5C_class_t; /* Type defintions of call back functions used by the cache as a whole */ typedef herr_t (*H5C_write_permitted_func_t)(const H5F_t *f, hid_t dxpl_id, hbool_t * write_permitted_ptr); /* Default max cache size and min clean size are give here to make * them generally accessable. */ #define H5C__DEFAULT_MAX_CACHE_SIZE ((size_t)(8 * 1024 * 1024)) #define H5C__DEFAULT_MIN_CLEAN_SIZE ((size_t)(4 * 1024 * 1024)) /**************************************************************************** * * structure H5C_cache_entry_t * * Instances of the H5C_cache_entry_t structure are used to store cache * entries in a hash table and sometimes in a skip list. * See H5SL.c for the particulars of the skip list. * * In typical application, this structure is the first field in a * structure to be cached. For historical reasons, the external module * is responsible for managing the is_dirty field. All other fields are * managed by the cache. * * The fields of this structure are discussed individually below: * * JRM - 4/26/04 * * addr: Base address of the cache entry on disk. * * size: Length of the cache entry on disk. Note that unlike normal * caches, the entries in this cache are of variable length. * The entries should never overlap, and when we do writebacks, * we will want to writeback adjacent entries where possible. * * type: Pointer to the instance of H5C_class_t containing pointers * to the methods for cache entries of the current type. This * field should be NULL when the instance of H5C_cache_entry_t * is not in use. * * The name is not particularly descriptive, but is retained * to avoid changes in existing code. * * is_dirty: Boolean flag indicating whether the contents of the cache * entry has been modified since the last time it was written * to disk. * * NOTE: For historical reasons, this field is not maintained * by the cache. Instead, the module using the cache * sets this flag when it modifies the entry, and the * flush and clear functions supplied by that module * reset the dirty when appropriate. * * This is a bit quirky, so we may want to change this * someday. However it will require a change in the * cache interface. * * is_protected: Boolean flag indicating whether this entry is protected * (or locked, to use more conventional terms). When it is * protected, the entry cannot be flushed or accessed until * it is unprotected (or unlocked -- again to use more * conventional terms). * * Note that protected entries are removed from the LRU lists * and inserted on the protected list. * * in_slist: Boolean flag indicating whether the entry is in the skip list * As a general rule, entries are placed in the list when they * are marked dirty. However they may remain in the list after * being flushed. * * * Fields supporting the hash table: * * Fields in the cache are indexed by a more or less conventional hash table. * If there are multiple entries in any hash bin, they are stored in a doubly * linked list. * * ht_next: Next pointer used by the hash table to store multiple * entries in a single hash bin. This field points to the * next entry in the doubly linked list of entries in the * hash bin, or NULL if there is no next entry. * * ht_prev: Prev pointer used by the hash table to store multiple * entries in a single hash bin. This field points to the * previous entry in the doubly linked list of entries in * the hash bin, or NULL if there is no previuos entry. * * * Fields supporting replacement policies: * * The cache must have a replacement policy, and it will usually be * necessary for this structure to contain fields supporting that policy. * * While there has been interest in several replacement policies for * this cache, the initial development schedule is tight. Thus I have * elected to support only a modified LRU policy for the first cut. * * When additional replacement policies are added, the fields in this * section will be used in different ways or not at all. Thus the * documentation of these fields is repeated for each replacement policy. * * Modified LRU: * * When operating in parallel mode, we must ensure that a read does not * cause a write. If it does, the process will hang, as the write will * be collective and the other processes will not know to participate. * * To deal with this issue, I have modified the usual LRU policy by adding * clean and dirty LRU lists to the usual LRU list. When reading in * parallel mode, we evict from the clean LRU list only. This implies * that we must try to ensure that the clean LRU list is reasonably well * stocked. See the comments on H5C_t in H5C.c for more details. * * Note that even if we start with a completely clean cache, a sequence * of protects without unprotects can empty the clean LRU list. In this * case, the cache must grow temporarily. At the next write, we will * attempt to evict enough entries to get the cache down to its nominal * maximum size. * * The use of the replacement policy fields under the Modified LRU policy * is discussed below: * * next: Next pointer in either the LRU or the protected list, * depending on the current value of protected. If there * is no next entry on the list, this field should be set * to NULL. * * prev: Prev pointer in either the LRU or the protected list, * depending on the current value of protected. If there * is no previous entry on the list, this field should be * set to NULL. * * aux_next: Next pointer on either the clean or dirty LRU lists. * This entry should be NULL when protected is true. When * protected is false, and dirty is true, it should point * to the next item on the dirty LRU list. When protected * is false, and dirty is false, it should point to the * next item on the clean LRU list. In either case, when * there is no next item, it should be NULL. * * aux_prev: Previous pointer on either the clean or dirty LRU lists. * This entry should be NULL when protected is true. When * protected is false, and dirty is true, it should point * to the previous item on the dirty LRU list. When protected * is false, and dirty is false, it should point to the * previous item on the clean LRU list. In either case, when * there is no previous item, it should be NULL. * * * Cache entry stats collection fields: * * These fields should only be compiled in when both H5C_COLLECT_CACHE_STATS * and H5C_COLLECT_CACHE_ENTRY_STATS are true. When present, they allow * collection of statistics on individual cache entries. * * accesses: int32_t containing the number of times this cache entry has * been referenced in its lifetime. * * clears: int32_t containing the number of times this cache entry has * been cleared in its life time. * * flushes: int32_t containing the number of times this cache entry has * been flushed to file in its life time. * ****************************************************************************/ typedef struct H5C_cache_entry_t { haddr_t addr; size_t size; const H5C_class_t * type; hbool_t is_dirty; hbool_t is_protected; hbool_t in_slist; /* fields supporting the hash table: */ struct H5C_cache_entry_t * ht_next; struct H5C_cache_entry_t * ht_prev; /* fields supporting replacement policies: */ struct H5C_cache_entry_t * next; struct H5C_cache_entry_t * prev; struct H5C_cache_entry_t * aux_next; struct H5C_cache_entry_t * aux_prev; #if H5C_COLLECT_CACHE_ENTRY_STATS /* cache entry stats fields */ int32_t accesses; int32_t clears; int32_t flushes; #endif /* H5C_COLLECT_CACHE_ENTRY_STATS */ } H5C_cache_entry_t; /* Typedef for the main structure for the cache (defined in H5C.c) */ typedef struct H5C_t H5C_t; /* * Library prototypes. */ H5_DLL H5C_t * H5C_create(size_t max_cache_size, size_t min_clean_size, int max_type_id, const char * (* type_name_table_ptr), H5C_write_permitted_func_t check_write_permitted); H5_DLL herr_t H5C_dest(H5F_t * f, hid_t primary_dxpl_id, hid_t secondary_dxpl_id, H5C_t * cache_ptr); H5_DLL herr_t H5C_dest_empty(H5C_t * cache_ptr); H5_DLL herr_t H5C_flush_cache(H5F_t * f, hid_t primary_dxpl_id, hid_t secondary_dxpl_id, H5C_t * cache_ptr, unsigned flags); H5_DLL herr_t H5C_insert_entry(H5F_t * f, hid_t primary_dxpl_id, hid_t secondary_dxpl_id, H5C_t * cache_ptr, const H5C_class_t * type, haddr_t addr, void * thing); H5_DLL herr_t H5C_rename_entry(H5C_t * cache_ptr, const H5C_class_t * type, haddr_t old_addr, haddr_t new_addr); H5_DLL void * H5C_protect(H5F_t * f, hid_t primary_dxpl_id, hid_t secondary_dxpl_id, H5C_t * cache_ptr, const H5C_class_t * type, haddr_t addr, const void * udata1, void * udata2); H5_DLL herr_t H5C_unprotect(H5F_t * f, hid_t primary_dxpl_id, hid_t secondary_dxpl_id, H5C_t * cache_ptr, const H5C_class_t * type, haddr_t addr, void * thing, hbool_t deleted); H5_DLL herr_t H5C_stats(H5C_t * cache_ptr, const char * cache_name, hbool_t display_detailed_stats); H5_DLL void H5C_stats__reset(H5C_t * cache_ptr); H5_DLL herr_t H5C_set_skip_flags(H5C_t * cache_ptr, hbool_t skip_file_checks, hbool_t skip_dxpl_id_checks); #endif /* !_H5Cprivate_H */ xdmf-3.0+git20160803/Utilities/hdf5/H5A.c0000640000175000017500000016147713003006557017434 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #define H5A_PACKAGE /*suppress error about including H5Apkg */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5A_init_interface /* Private header files */ #include "H5private.h" /* Generic Functions */ #include "H5Apkg.h" /* Attributes */ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free Lists */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Sprivate.h" /* Dataspace functions */ /* PRIVATE PROTOTYPES */ static hid_t H5A_create(const H5G_entry_t *ent, const char *name, const H5T_t *type, const H5S_t *space, hid_t dxpl_id); static hid_t H5A_open(H5G_entry_t *ent, unsigned idx, hid_t dxpl_id); static herr_t H5A_write(H5A_t *attr, const H5T_t *mem_type, const void *buf, hid_t dxpl_id); static herr_t H5A_read(const H5A_t *attr, const H5T_t *mem_type, void *buf, hid_t dxpl_id); static int H5A_get_index(H5G_entry_t *ent, const char *name, hid_t dxpl_id); static hsize_t H5A_get_storage_size(const H5A_t *attr); static herr_t H5A_rename(H5G_entry_t *ent, const char *old_name, const char *new_name, hid_t dxpl_id); /* Object header iterator callbacks */ /* Data structure for callback for locating the index by name */ typedef struct H5A_iter_cb1 { const char *name; int idx; } H5A_iter_cb1; static herr_t H5A_find_idx_by_name(const void *mesg, unsigned idx, void *op_data); /* The number of reserved IDs in dataset ID group */ #define H5A_RESERVED_ATOMS 0 /* Declare the free lists for H5A_t's */ H5FL_DEFINE(H5A_t); /* Declare a free list to manage blocks of type conversion data */ H5FL_BLK_DEFINE(attr_buf); /*-------------------------------------------------------------------------- NAME H5A_init_interface -- Initialize interface-specific information USAGE herr_t H5A_init_interface() RETURNS Non-negative on success/Negative on failure DESCRIPTION Initializes any interface-specific data or routines. --------------------------------------------------------------------------*/ static herr_t H5A_init_interface(void) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5A_init_interface) /* * Create attribute group. */ if (H5I_init_group(H5I_ATTR, H5I_ATTRID_HASHSIZE, H5A_RESERVED_ATOMS, (H5I_free_t)H5A_close)<0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "unable to initialize interface") done: FUNC_LEAVE_NOAPI(ret_value) } /*-------------------------------------------------------------------------- NAME H5A_term_interface PURPOSE Terminate various H5A objects USAGE void H5A_term_interface() RETURNS DESCRIPTION Release any other resources allocated. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS Can't report errors... EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ int H5A_term_interface(void) { int n=0; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5A_term_interface) if (H5_interface_initialize_g) { if ((n=H5I_nmembers(H5I_ATTR))>0) { (void)H5I_clear_group(H5I_ATTR, FALSE); } else { (void)H5I_destroy_group(H5I_ATTR); H5_interface_initialize_g = 0; n = 1; } } FUNC_LEAVE_NOAPI(n) } /*-------------------------------------------------------------------------- NAME H5Acreate PURPOSE Creates a dataset as an attribute of another dataset or group USAGE hid_t H5Acreate (loc_id, name, type_id, space_id, plist_id) hid_t loc_id; IN: Object (dataset or group) to be attached to const char *name; IN: Name of attribute to create hid_t type_id; IN: ID of datatype for attribute hid_t space_id; IN: ID of dataspace for attribute hid_t plist_id; IN: ID of creation property list (currently not used) RETURNS Non-negative on success/Negative on failure ERRORS DESCRIPTION This function creates an attribute which is attached to the object specified with 'location_id'. The name specified with 'name' for each attribute for an object must be unique for that object. The 'type_id' and 'space_id' are created with the H5T and H5S interfaces respectively. Currently only simple dataspaces are allowed for attribute dataspaces. The 'plist_id' property list is currently un-used, but will be used int the future for optional properties of attributes. The attribute ID returned from this function must be released with H5Aclose or resource leaks will develop. The link created (see H5G API documentation for more information on link types) is a hard link, so the attribute may be shared among datasets and will not be removed from the file until the reference count for the attribute is reduced to zero. The location object may be either a group or a dataset, both of which may have any sort of attribute. * * Modifications: * Robb Matzke, 5 Jun 1998 * The LOC_ID can also be a committed datatype. * --------------------------------------------------------------------------*/ /* ARGSUSED */ hid_t H5Acreate(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t UNUSED plist_id) { H5G_entry_t *ent = NULL; H5T_t *type = NULL; H5S_t *space = NULL; hid_t ret_value = FAIL; FUNC_ENTER_API(H5Acreate, FAIL) H5TRACE5("i","isiii",loc_id,name,type_id,space_id,plist_id); /* check arguments */ if (H5I_FILE==H5I_get_type(loc_id) || H5I_ATTR==H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") if (NULL==(ent=H5G_loc(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") if (NULL == (type = H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a type") if (NULL == (space = H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") /* Go do the real work for attaching the attribute to the dataset */ if ((ret_value=H5A_create(ent,name,type,space, H5AC_dxpl_id))<0) HGOTO_ERROR (H5E_ATTR, H5E_CANTINIT, FAIL, "unable to create attribute") done: FUNC_LEAVE_API(ret_value) } /* H5Acreate() */ /*------------------------------------------------------------------------- * Function: H5A_create * * Purpose: * This is the guts of the H5Acreate function. * Usage: * hid_t H5A_create (ent, name, type, space) * const H5G_entry_t *ent; IN: Pointer to symbol table entry for object to attribute * const char *name; IN: Name of attribute * H5T_t *type; IN: Datatype of attribute * H5S_t *space; IN: Dataspace of attribute * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * April 2, 1998 * * Modifications: * * Pedro Vicente, 22 Aug 2002 * Added a deep copy of the symbol table entry * *------------------------------------------------------------------------- */ static hid_t H5A_create(const H5G_entry_t *ent, const char *name, const H5T_t *type, const H5S_t *space, hid_t dxpl_id) { H5A_t *attr = NULL; H5A_iter_cb1 cb; /* Iterator callback */ hid_t ret_value = FAIL; FUNC_ENTER_NOAPI_NOINIT(H5A_create) /* check args */ assert(ent); assert(name); assert(type); assert(space); /* Iterate over the existing attributes to check for duplicates */ cb.name=name; cb.idx=(-1); if((ret_value=H5O_iterate(ent,H5O_ATTR_ID,H5A_find_idx_by_name,&cb,dxpl_id))<0) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "error iterating over attributes") if(ret_value>0) HGOTO_ERROR(H5E_ATTR, H5E_ALREADYEXISTS, FAIL, "attribute already exists") /* Check if the dataspace has an extent set (or is NULL) */ if( !(H5S_has_extent(space)) ) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspace extent has not been set") /* Build the attribute information */ if((attr = H5FL_CALLOC(H5A_t))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for attribute info") /* Copy the attribute name */ attr->name=HDstrdup(name); /* Copy the attribute's datatype */ attr->dt=H5T_copy(type, H5T_COPY_ALL); /* Mark any VL datatypes as being on disk now */ if (H5T_vlen_mark(attr->dt, ent->file, H5T_VLEN_DISK)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid VL location"); /* Copy the dataspace for the attribute */ attr->ds=H5S_copy(space, FALSE); /* Mark it initially set to initialized */ attr->initialized = TRUE; /*for now, set to false later*/ /* Deep copy of the symbol table entry */ if (H5G_ent_copy(&(attr->ent),ent,H5G_COPY_DEEP)<0) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to copy entry") /* Compute the size of pieces on disk */ if(H5T_committed(attr->dt)) { H5O_shared_t sh_mesg; /* Reset shared message information */ HDmemset(&sh_mesg,0,sizeof(H5O_shared_t)); /* Get shared message information for datatype */ if (H5O_get_share(H5O_DTYPE_ID,attr->ent.file, type, &sh_mesg/*out*/)<0) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to copy entry") /* Compute shared message size for datatype */ attr->dt_size=H5O_raw_size(H5O_SHARED_ID,attr->ent.file,&sh_mesg); } /* end if */ else attr->dt_size=H5O_raw_size(H5O_DTYPE_ID,attr->ent.file,type); assert(attr->dt_size>0); attr->ds_size=H5S_raw_size(attr->ent.file,space); assert(attr->ds_size>0); H5_ASSIGN_OVERFLOW(attr->data_size,H5S_GET_EXTENT_NPOINTS(attr->ds)*H5T_get_size(attr->dt),hssize_t,size_t); /* Hold the symbol table entry (and file) open */ if (H5O_open(&(attr->ent)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open") attr->ent_opened=1; /* Create the attribute message and save the attribute index */ if (H5O_modify(&(attr->ent), H5O_ATTR_ID, H5O_NEW_MESG, 0, H5O_UPDATE_TIME, attr, dxpl_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to update attribute header messages") /* Register the new attribute and get an ID for it */ if ((ret_value = H5I_register(H5I_ATTR, attr)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register attribute for ID") /* Now it's safe to say it's uninitialized */ attr->initialized = FALSE; done: if (ret_value < 0) { if(attr) (void)H5A_close(attr); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5A_create() */ /*-------------------------------------------------------------------------- NAME H5A_find_idx_by_name PURPOSE Iterator callback to determine the index of a attribute USAGE herr_t H5A_find_idx_by_name (mesg, idx, op_data) const H5A_t *mesg; IN: Pointer to attribute unsigned idx; IN: Index of attribute void *op_data; IN: Op data passed in RETURNS Non-negative on success, negative on failure ERRORS DESCRIPTION This function determines if an attribute matches the name to search for (from the 'op_data') and sets the index value in the 'op_data'. --------------------------------------------------------------------------*/ static herr_t H5A_find_idx_by_name(const void *_mesg, unsigned idx, void *_op_data) { const H5A_t *mesg = (const H5A_t *)_mesg; /* Pointer to attribute */ H5A_iter_cb1 *op_data = (H5A_iter_cb1 *)_op_data; /* Pointer to op data */ int ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5A_find_idx_by_name) assert(mesg); assert(op_data); /* * Compare found attribute name to queried name and set the idx in the * callback info if names are the same. */ if(HDstrcmp(mesg->name,op_data->name)==0) { op_data->idx=idx; ret_value=1; } /* end if */ else ret_value=0; FUNC_LEAVE_NOAPI(ret_value) } /* H5A_find_idx_by_name() */ /*-------------------------------------------------------------------------- NAME H5A_get_index PURPOSE Determine the index of an attribute in an object header USAGE int H5A_get_index (ent, name) H5G_entry_t *ent; IN: Symbol table entry of object const char *name; IN: Name of dataset to find RETURNS non-negative on success, negative on failure ERRORS DESCRIPTION This function determines the index of the attribute within an object header. This is not stored in the attribute structure because it is only a subjective measure and can change if attributes are deleted from the object header. --------------------------------------------------------------------------*/ static int H5A_get_index(H5G_entry_t *ent, const char *name, hid_t dxpl_id) { H5A_iter_cb1 cb; /* Iterator callback */ int ret_value=FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5A_get_index) assert(ent); assert(name); cb.name=name; cb.idx=(-1); if((ret_value=H5O_iterate(ent,H5O_ATTR_ID,H5A_find_idx_by_name,&cb,dxpl_id))<0) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "error iterating over attributes") if(ret_value>0) ret_value=cb.idx; else HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "attribute not found") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5A_get_index() */ /*-------------------------------------------------------------------------- NAME H5Aopen_name PURPOSE Opens an attribute for an object by looking up the attribute name USAGE hid_t H5Aopen_name (loc_id, name) hid_t loc_id; IN: Object (dataset or group) to be attached to const char *name; IN: Name of attribute to locate and open RETURNS ID of attribute on success, negative on failure ERRORS DESCRIPTION This function opens an existing attribute for access. The attribute name specified is used to look up the corresponding attribute for the object. The attribute ID returned from this function must be released with H5Aclose or resource leaks will develop. The location object may be either a group or a dataset, both of which may have any sort of attribute. * * Modifications: * Robb Matzke, 5 Jun 1998 * The LOC_ID can also be a named (committed) datatype. --------------------------------------------------------------------------*/ hid_t H5Aopen_name(hid_t loc_id, const char *name) { H5G_entry_t *ent = NULL; /*Symtab entry of object to attribute*/ int idx=0; hid_t ret_value; FUNC_ENTER_API(H5Aopen_name, FAIL) H5TRACE2("i","is",loc_id,name); /* check arguments */ if (H5I_FILE==H5I_get_type(loc_id) || H5I_ATTR==H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") if (NULL==(ent=H5G_loc(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") /* Look up the attribute for the object */ if((idx=H5A_get_index(ent,name, H5AC_dxpl_id))<0) HGOTO_ERROR(H5E_ATTR, H5E_BADVALUE, FAIL, "attribute not found") /* Go do the real work for opening the attribute */ if ((ret_value=H5A_open(ent, (unsigned)idx, H5AC_dxpl_id))<0) HGOTO_ERROR (H5E_ATTR, H5E_CANTINIT, FAIL, "unable to open attribute") done: FUNC_LEAVE_API(ret_value) } /* H5Aopen_name() */ /*-------------------------------------------------------------------------- NAME H5Aopen_idx PURPOSE Opens the n'th attribute for an object USAGE hid_t H5Aopen_idx (loc_id, idx) hid_t loc_id; IN: Object (dataset or group) to be attached to unsigned idx; IN: Index (0-based) attribute to open RETURNS ID of attribute on success, negative on failure ERRORS DESCRIPTION This function opens an existing attribute for access. The attribute index specified is used to look up the corresponding attribute for the object. The attribute ID returned from this function must be released with H5Aclose or resource leaks will develop. The location object may be either a group or a dataset, both of which may have any sort of attribute. * * Modifications: * Robb Matzke, 5 Jun 1998 * The LOC_ID can also be a named (committed) datatype. * --------------------------------------------------------------------------*/ hid_t H5Aopen_idx(hid_t loc_id, unsigned idx) { H5G_entry_t *ent = NULL; /*Symtab entry of object to attribute */ hid_t ret_value; FUNC_ENTER_API(H5Aopen_idx, FAIL) H5TRACE2("i","iIu",loc_id,idx); /* check arguments */ if (H5I_FILE==H5I_get_type(loc_id) || H5I_ATTR==H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") if (NULL==(ent=H5G_loc(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") /* Go do the real work for opening the attribute */ if ((ret_value=H5A_open(ent, idx, H5AC_dxpl_id))<0) HGOTO_ERROR (H5E_ATTR, H5E_CANTINIT, FAIL, "unable to open attribute") done: FUNC_LEAVE_API(ret_value) } /* H5Aopen_idx() */ /*------------------------------------------------------------------------- * Function: H5A_open * * Purpose: * This is the guts of the H5Aopen_xxx functions * Usage: * herr_t H5A_open (ent, idx) * const H5G_entry_t *ent; IN: Pointer to symbol table entry for object to attribute * unsigned idx; IN: index of attribute to open (0-based) * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * April 2, 1998 * * Modifications: * * Pedro Vicente, 22 Aug 2002 * Added a deep copy of the symbol table entry * *------------------------------------------------------------------------- */ static hid_t H5A_open(H5G_entry_t *ent, unsigned idx, hid_t dxpl_id) { H5A_t *attr = NULL; hid_t ret_value; FUNC_ENTER_NOAPI_NOINIT(H5A_open) /* check args */ assert(ent); /* Read in attribute with H5O_read() */ H5_CHECK_OVERFLOW(idx,unsigned,int); if (NULL==(attr=H5O_read(ent, H5O_ATTR_ID, (int)idx, NULL, dxpl_id))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to load attribute info from dataset header") attr->initialized=1; /* Deep copy of the symbol table entry */ if (H5G_ent_copy(&(attr->ent),ent,H5G_COPY_DEEP)<0) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to copy entry") /* Hold the symbol table entry (and file) open */ if (H5O_open(&(attr->ent)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open") attr->ent_opened=1; /* Register the new attribute and get an ID for it */ if ((ret_value = H5I_register(H5I_ATTR, attr)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register attribute for ID") done: if (ret_value < 0) { if(attr) (void)H5A_close(attr); } FUNC_LEAVE_NOAPI(ret_value) } /* H5A_open() */ /*-------------------------------------------------------------------------- NAME H5Awrite PURPOSE Write out data to an attribute USAGE herr_t H5Awrite (attr_id, type_id, buf) hid_t attr_id; IN: Attribute to write hid_t type_id; IN: Memory datatype of buffer const void *buf; IN: Buffer of data to write RETURNS Non-negative on success/Negative on failure ERRORS DESCRIPTION This function writes a complete attribute to disk. --------------------------------------------------------------------------*/ herr_t H5Awrite(hid_t attr_id, hid_t type_id, const void *buf) { H5A_t *attr = NULL; const H5T_t *mem_type = NULL; herr_t ret_value; FUNC_ENTER_API(H5Awrite, FAIL) H5TRACE3("e","iix",attr_id,type_id,buf); /* check arguments */ if (NULL == (attr = H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") if (NULL == (mem_type = H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") if (NULL == buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null attribute buffer") /* Go write the actual data to the attribute */ if ((ret_value=H5A_write(attr,mem_type,buf, H5AC_dxpl_id))<0) HGOTO_ERROR(H5E_ATTR, H5E_WRITEERROR, FAIL, "unable to write attribute") done: FUNC_LEAVE_API(ret_value) } /* H5Awrite() */ /*-------------------------------------------------------------------------- NAME H5A_write PURPOSE Actually write out data to an attribute USAGE herr_t H5A_write (attr, mem_type, buf) H5A_t *attr; IN: Attribute to write const H5T_t *mem_type; IN: Memory datatype of buffer const void *buf; IN: Buffer of data to write RETURNS Non-negative on success/Negative on failure ERRORS DESCRIPTION This function writes a complete attribute to disk. --------------------------------------------------------------------------*/ static herr_t H5A_write(H5A_t *attr, const H5T_t *mem_type, const void *buf, hid_t dxpl_id) { uint8_t *tconv_buf = NULL; /* datatype conv buffer */ uint8_t *bkg_buf = NULL; /* temp conversion buffer */ hssize_t snelmts; /* elements in attribute */ size_t nelmts; /* elements in attribute */ H5T_path_t *tpath = NULL; /* conversion information*/ hid_t src_id = -1, dst_id = -1;/* temporary type atoms */ size_t src_type_size; /* size of source type */ size_t dst_type_size; /* size of destination type*/ size_t buf_size; /* desired buffer size */ int idx; /* index of attribute in object header */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT(H5A_write) assert(attr); assert(mem_type); assert(buf); /* Create buffer for data to store on disk */ if((snelmts=H5S_GET_EXTENT_NPOINTS(attr->ds))<0) HGOTO_ERROR (H5E_ATTR, H5E_CANTCOUNT, FAIL, "dataspace is invalid") H5_ASSIGN_OVERFLOW(nelmts,snelmts,hssize_t,size_t); if(nelmts>0) { /* Get the memory and file datatype sizes */ src_type_size = H5T_get_size(mem_type); dst_type_size = H5T_get_size(attr->dt); /* Convert memory buffer into disk buffer */ /* Set up type conversion function */ if (NULL == (tpath = H5T_path_find(mem_type, attr->dt, NULL, NULL, dxpl_id))) HGOTO_ERROR(H5E_ATTR, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dst datatypes") /* Check for type conversion required */ if (!H5T_path_noop(tpath)) { if ((src_id = H5I_register(H5I_DATATYPE, H5T_copy(mem_type, H5T_COPY_ALL)))<0 || (dst_id = H5I_register(H5I_DATATYPE, H5T_copy(attr->dt, H5T_COPY_ALL)))<0) HGOTO_ERROR(H5E_ATTR, H5E_CANTREGISTER, FAIL, "unable to register types for conversion") /* Get the maximum buffer size needed and allocate it */ buf_size=nelmts*MAX(src_type_size,dst_type_size); if (NULL==(tconv_buf = H5FL_BLK_MALLOC (attr_buf, buf_size)) || NULL==(bkg_buf = H5FL_BLK_CALLOC(attr_buf, buf_size))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Copy the user's data into the buffer for conversion */ HDmemcpy(tconv_buf,buf,(src_type_size*nelmts)); /* Perform datatype conversion */ if (H5T_convert(tpath, src_id, dst_id, nelmts, (size_t)0, (size_t)0, tconv_buf, bkg_buf, dxpl_id)<0) HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "datatype conversion failed") /* Free the previous attribute data buffer, if there is one */ if(attr->data) H5FL_BLK_FREE(attr_buf, attr->data); /* Set the pointer to the attribute data to the converted information */ attr->data=tconv_buf; } /* end if */ /* No type conversion necessary */ else { HDassert(dst_type_size==src_type_size); /* Allocate the attribute buffer, if there isn't one */ if(attr->data==NULL) if (NULL==(attr->data = H5FL_BLK_MALLOC(attr_buf, dst_type_size*nelmts))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Copy the attribute data into the user's buffer */ HDmemcpy(attr->data,buf,(dst_type_size*nelmts)); } /* end else */ /* Look up the attribute for the object */ if((idx=H5A_get_index(&(attr->ent),attr->name,dxpl_id))<0) HGOTO_ERROR(H5E_ATTR, H5E_BADVALUE, FAIL, "attribute not found") /* Modify the attribute data */ if (H5O_modify(&(attr->ent), H5O_ATTR_ID, idx, 0, H5O_UPDATE_DATA_ONLY|H5O_UPDATE_TIME, attr, dxpl_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to update attribute header messages") } /* end if */ /* Indicate the the attribute doesn't need fill-values */ attr->initialized=TRUE; done: /* Release resources */ if (src_id >= 0) (void)H5I_dec_ref(src_id); if (dst_id >= 0) (void)H5I_dec_ref(dst_id); if (bkg_buf) H5FL_BLK_FREE(attr_buf, bkg_buf); FUNC_LEAVE_NOAPI(ret_value) } /* H5A_write() */ /*-------------------------------------------------------------------------- NAME H5Aread PURPOSE Read in data from an attribute USAGE herr_t H5Aread (attr_id, type_id, buf) hid_t attr_id; IN: Attribute to read hid_t type_id; IN: Memory datatype of buffer void *buf; IN: Buffer for data to read RETURNS Non-negative on success/Negative on failure ERRORS DESCRIPTION This function reads a complete attribute from disk. --------------------------------------------------------------------------*/ herr_t H5Aread(hid_t attr_id, hid_t type_id, void *buf) { H5A_t *attr = NULL; const H5T_t *mem_type = NULL; herr_t ret_value; FUNC_ENTER_API(H5Aread, FAIL) H5TRACE3("e","iix",attr_id,type_id,buf); /* check arguments */ if (NULL == (attr = H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") if (NULL == (mem_type = H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") if (NULL == buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null attribute buffer") /* Go write the actual data to the attribute */ if ((ret_value=H5A_read(attr,mem_type,buf,H5AC_dxpl_id))<0) HGOTO_ERROR(H5E_ATTR, H5E_READERROR, FAIL, "unable to read attribute") done: FUNC_LEAVE_API(ret_value) } /* H5Aread() */ /*-------------------------------------------------------------------------- NAME H5A_read PURPOSE Actually read in data from an attribute USAGE herr_t H5A_read (attr, mem_type, buf) H5A_t *attr; IN: Attribute to read const H5T_t *mem_type; IN: Memory datatype of buffer void *buf; IN: Buffer for data to read RETURNS Non-negative on success/Negative on failure ERRORS DESCRIPTION This function reads a complete attribute from disk. --------------------------------------------------------------------------*/ static herr_t H5A_read(const H5A_t *attr, const H5T_t *mem_type, void *buf, hid_t dxpl_id) { uint8_t *tconv_buf = NULL; /* datatype conv buffer*/ uint8_t *bkg_buf = NULL; /* background buffer */ hssize_t snelmts; /* elements in attribute */ size_t nelmts; /* elements in attribute*/ H5T_path_t *tpath = NULL; /* type conversion info */ hid_t src_id = -1, dst_id = -1;/* temporary type atoms*/ size_t src_type_size; /* size of source type */ size_t dst_type_size; /* size of destination type */ size_t buf_size; /* desired buffer size */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT(H5A_read) assert(attr); assert(mem_type); assert(buf); /* Create buffer for data to store on disk */ if((snelmts=H5S_GET_EXTENT_NPOINTS(attr->ds))<0) HGOTO_ERROR (H5E_ATTR, H5E_CANTCOUNT, FAIL, "dataspace is invalid") H5_ASSIGN_OVERFLOW(nelmts,snelmts,hssize_t,size_t); if(nelmts>0) { /* Get the memory and file datatype sizes */ src_type_size = H5T_get_size(attr->dt); dst_type_size = H5T_get_size(mem_type); /* Check if the attribute has any data yet, if not, fill with zeroes */ if(attr->ent_opened && !attr->initialized) { HDmemset(buf,0,(dst_type_size*nelmts)); } /* end if */ else { /* Attribute exists and has a value */ /* Convert memory buffer into disk buffer */ /* Set up type conversion function */ if (NULL == (tpath = H5T_path_find(attr->dt, mem_type, NULL, NULL, dxpl_id))) HGOTO_ERROR(H5E_ATTR, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dst datatypes") /* Check for type conversion required */ if (!H5T_path_noop(tpath)) { if ((src_id = H5I_register(H5I_DATATYPE, H5T_copy(attr->dt, H5T_COPY_ALL)))<0 || (dst_id = H5I_register(H5I_DATATYPE, H5T_copy(mem_type, H5T_COPY_ALL)))<0) HGOTO_ERROR(H5E_ATTR, H5E_CANTREGISTER, FAIL, "unable to register types for conversion") /* Get the maximum buffer size needed and allocate it */ buf_size=nelmts*MAX(src_type_size,dst_type_size); if (NULL==(tconv_buf = H5FL_BLK_MALLOC(attr_buf, buf_size)) || NULL==(bkg_buf = H5FL_BLK_CALLOC(attr_buf, buf_size))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Copy the attribute data into the buffer for conversion */ HDmemcpy(tconv_buf,attr->data,(src_type_size*nelmts)); /* Perform datatype conversion. */ if (H5T_convert(tpath, src_id, dst_id, nelmts, (size_t)0, (size_t)0, tconv_buf, bkg_buf, dxpl_id)<0) HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "datatype conversion failed") /* Copy the converted data into the user's buffer */ HDmemcpy(buf,tconv_buf,(dst_type_size*nelmts)); } /* end if */ /* No type conversion necessary */ else { HDassert(dst_type_size==src_type_size); /* Copy the attribute data into the user's buffer */ HDmemcpy(buf,attr->data,(dst_type_size*nelmts)); } /* end else */ } /* end else */ } /* end if */ done: /* Release resources */ if (src_id >= 0) (void)H5I_dec_ref(src_id); if (dst_id >= 0) (void)H5I_dec_ref(dst_id); if (tconv_buf) H5FL_BLK_FREE(attr_buf, tconv_buf); if (bkg_buf) H5FL_BLK_FREE(attr_buf, bkg_buf); FUNC_LEAVE_NOAPI(ret_value) } /* H5A_read() */ /*-------------------------------------------------------------------------- NAME H5Aget_space PURPOSE Gets a copy of the dataspace for an attribute USAGE hid_t H5Aget_space (attr_id) hid_t attr_id; IN: Attribute to get dataspace of RETURNS A dataspace ID on success, negative on failure ERRORS DESCRIPTION This function retrieves a copy of the dataspace for an attribute. The dataspace ID returned from this function must be released with H5Sclose or resource leaks will develop. --------------------------------------------------------------------------*/ hid_t H5Aget_space(hid_t attr_id) { H5A_t *attr = NULL; H5S_t *dst = NULL; hid_t ret_value; FUNC_ENTER_API(H5Aget_space, FAIL) H5TRACE1("i","i",attr_id); /* check arguments */ if (NULL == (attr = H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") /* Copy the attribute's dataspace */ if (NULL==(dst=H5S_copy (attr->ds, FALSE))) HGOTO_ERROR (H5E_ATTR, H5E_CANTINIT, FAIL, "unable to copy dataspace") /* Atomize */ if ((ret_value=H5I_register (H5I_DATASPACE, dst))<0) HGOTO_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace atom") done: FUNC_LEAVE_API(ret_value) } /* H5Aget_space() */ /*-------------------------------------------------------------------------- NAME H5Aget_type PURPOSE Gets a copy of the datatype for an attribute USAGE hid_t H5Aget_type (attr_id) hid_t attr_id; IN: Attribute to get datatype of RETURNS A datatype ID on success, negative on failure ERRORS DESCRIPTION This function retrieves a copy of the datatype for an attribute. The datatype ID returned from this function must be released with H5Tclose or resource leaks will develop. * * Modifications: * Robb Matzke, 4 Jun 1998 * The datatype is reopened if it's a named type before returning it to * the application. The datatypes returned by this function are always * read-only. If an error occurs when atomizing the return datatype * then the datatype is closed. --------------------------------------------------------------------------*/ hid_t H5Aget_type(hid_t attr_id) { H5A_t *attr = NULL; H5T_t *dst = NULL; hid_t ret_value; FUNC_ENTER_API(H5Aget_type, FAIL) H5TRACE1("i","i",attr_id); /* check arguments */ if (NULL == (attr = H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") /* * Copy the attribute's datatype. If the type is a named type then * reopen the type before returning it to the user. Make the type * read-only. */ if (NULL==(dst=H5T_copy(attr->dt, H5T_COPY_REOPEN))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to copy datatype") /* Mark any VL datatypes as being in memory now */ if (H5T_vlen_mark(dst, NULL, H5T_VLEN_MEMORY)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid VL location") if (H5T_lock(dst, FALSE)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to lock transient datatype") /* Atomize */ if ((ret_value=H5I_register(H5I_DATATYPE, dst))<0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register datatype atom") done: if(ret_value<0) { if(dst!=NULL) (void)H5T_close(dst); } /* end if */ FUNC_LEAVE_API(ret_value) } /* H5Aget_type() */ /*-------------------------------------------------------------------------- NAME H5Aget_name PURPOSE Gets a copy of the name for an attribute USAGE hssize_t H5Aget_name (attr_id, buf_size, buf) hid_t attr_id; IN: Attribute to get name of size_t buf_size; IN: The size of the buffer to store the string in. char *buf; IN: Buffer to store name in RETURNS This function returns the length of the attribute's name (which may be longer than 'buf_size') on success or negative for failure. ERRORS DESCRIPTION This function retrieves the name of an attribute for an attribute ID. Up to 'buf_size' characters are stored in 'buf' followed by a '\0' string terminator. If the name of the attribute is longer than 'buf_size'-1, the string terminator is stored in the last position of the buffer to properly terminate the string. --------------------------------------------------------------------------*/ ssize_t H5Aget_name(hid_t attr_id, size_t buf_size, char *buf) { H5A_t *attr = NULL; size_t copy_len, nbytes; ssize_t ret_value; FUNC_ENTER_API(H5Aget_name, FAIL) H5TRACE3("Zs","izs",attr_id,buf_size,buf); /* check arguments */ if (NULL == (attr = H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") if (!buf && buf_size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid buffer") /* get the real attribute length */ nbytes = HDstrlen(attr->name); assert((ssize_t)nbytes>=0); /*overflow, pretty unlikey --rpm*/ /* compute the string length which will fit into the user's buffer */ copy_len = MIN(buf_size-1, nbytes); /* Copy all/some of the name */ if(buf && copy_len>0) { HDmemcpy(buf, attr->name, copy_len); /* Terminate the string */ buf[copy_len]='\0'; } /* Set return value */ ret_value = (ssize_t)nbytes; done: FUNC_LEAVE_API(ret_value) } /* H5Aget_type() */ /*------------------------------------------------------------------------- * Function: H5Aget_storage_size * * Purpose: Returns the amount of storage size that is required for this * attribute. * * Return: Success: The amount of storage size allocated for the * attribute. The return value may be zero * if no data has been stored. * * Failure: Zero * * Programmer: Raymond Lu * October 23, 2002 * * Modifications: * *------------------------------------------------------------------------- */ hsize_t H5Aget_storage_size(hid_t attr_id) { H5A_t *attr=NULL; hsize_t ret_value; /* Return value */ FUNC_ENTER_API(H5Aget_storage_size, 0) H5TRACE1("h","i",attr_id); /* Check args */ if (NULL==(attr=H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not an attribute") /* Set return value */ ret_value = H5A_get_storage_size(attr); done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5A_get_storage_size * * Purpose: Private function for H5Aget_storage_size. Returns the * amount of storage size that is required for this * attribute. * * Return: Success: The amount of storage size allocated for the * attribute. The return value may be zero * if no data has been stored. * * Failure: Zero * * Programmer: Raymond Lu * October 23, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static hsize_t H5A_get_storage_size(const H5A_t *attr) { hsize_t ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5A_get_storage_size) /* Set return value */ ret_value = attr->data_size; FUNC_LEAVE_NOAPI(ret_value) } /*-------------------------------------------------------------------------- NAME H5Aget_num_attrs PURPOSE Determines the number of attributes attached to an object USAGE int H5Aget_num_attrs (loc_id) hid_t loc_id; IN: Object (dataset or group) to be queried RETURNS Number of attributes on success, negative on failure ERRORS DESCRIPTION This function returns the number of attributes attached to a dataset or group, 'location_id'. * * Modifications: * Robb Matzke, 5 Jun 1998 * The LOC_ID can also be a named (committed) datatype. --------------------------------------------------------------------------*/ int H5Aget_num_attrs(hid_t loc_id) { H5G_entry_t *ent = NULL; /*symtab ent of object to attribute */ void *obj = NULL; int ret_value; FUNC_ENTER_API(H5Aget_num_attrs, FAIL) H5TRACE1("Is","i",loc_id); /* check arguments */ if (H5I_FILE==H5I_get_type(loc_id) || H5I_ATTR==H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") if(NULL == (obj = H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADATOM, FAIL, "illegal object atom") switch (H5I_get_type (loc_id)) { case H5I_DATASET: ent = H5D_entof ((H5D_t*)obj); break; case H5I_DATATYPE: if (NULL==(ent=H5T_entof ((H5T_t*)obj))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "target datatype is not committed") break; case H5I_GROUP: ent = H5G_entof ((H5G_t*)obj); break; default: HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "inappropriate attribute target") } /*lint !e788 All appropriate cases are covered */ /* Look up the attribute for the object */ ret_value=H5O_count(ent, H5O_ATTR_ID, H5AC_ind_dxpl_id); done: FUNC_LEAVE_API(ret_value) } /* H5Aget_num_attrs() */ /*------------------------------------------------------------------------- * Function: H5Arename * * Purpose: Rename an attribute * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Raymond Lu * October 23, 2002 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Arename(hid_t loc_id, const char *old_name, const char *new_name) { H5G_entry_t *ent = NULL; /*symtab ent of object to attribute */ herr_t ret_value; /* Return value */ FUNC_ENTER_API(H5Arename, FAIL) H5TRACE3("e","iss",loc_id,old_name,new_name); /* check arguments */ if (!old_name || !new_name) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "name is nil") if (H5I_FILE==H5I_get_type(loc_id) || H5I_ATTR==H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") if (NULL==(ent=H5G_loc(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") /* Call private function */ ret_value = H5A_rename(ent, old_name, new_name, H5AC_dxpl_id); done: FUNC_LEAVE_API(ret_value) } /* H5Arename() */ /*------------------------------------------------------------------------- * Function: H5A_rename * * Purpose: Private function for H5Arename. Rename an attribute * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Raymond Lu * October 23, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5A_rename(H5G_entry_t *ent, const char *old_name, const char *new_name, hid_t dxpl_id) { int seq, idx=FAIL; /* Index of attribute being querried */ H5A_t found_attr; /* Attribute with OLD_NAME */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5A_rename) /* Check arguments */ assert(ent); assert(old_name); assert(new_name); /* Read in the existing attributes to check for duplicates */ seq=0; while(H5O_read(ent, H5O_ATTR_ID, seq, &found_attr, dxpl_id)!=NULL) { /* * Compare found attribute name. */ if(HDstrcmp(found_attr.name,old_name)==0) { idx = seq; break; } if(H5O_reset (H5O_ATTR_ID, &found_attr)<0) HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't release attribute info") seq++; } H5E_clear (); if(idx<0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "attribute cannot be found") /* Copy the attribute name. */ if(found_attr.name) HDfree(found_attr.name); found_attr.name = HDstrdup(new_name); if(!found_attr.name) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "String copy failed") /* Indicate entry is not opened and the attribute doesn't need fill-values. */ found_attr.ent_opened=FALSE; found_attr.initialized=TRUE; /* Modify the attribute message */ if (H5O_modify(ent, H5O_ATTR_ID, idx, 0, H5O_UPDATE_TIME, &found_attr, dxpl_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to update attribute header messages") /* Close the attribute */ if(H5A_free(&found_attr)<0) HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "unable to close renamed attribute") done: FUNC_LEAVE_NOAPI(ret_value) } /*-------------------------------------------------------------------------- NAME H5Aiterate PURPOSE Calls a user's function for each attribute on an object USAGE herr_t H5Aiterate (loc_id, attr_num, op, data) hid_t loc_id; IN: Object (dataset or group) to be iterated over unsigned *attr_num; IN/OUT: Starting (IN) & Ending (OUT) attribute number H5A_operator_t op; IN: User's function to pass each attribute to void *op_data; IN/OUT: User's data to pass through to iterator operator function RETURNS Returns a negative value if something is wrong, the return value of the last operator if it was non-zero, or zero if all attributes were processed. ERRORS DESCRIPTION This function interates over the attributes of dataset or group specified with 'loc_id'. For each attribute of the object, the 'op_data' and some additional information (specified below) are passed to the 'op' function. The iteration begins with the '*attr_number' object in the group and the next attribute to be processed by the operator is returned in '*attr_number'. The operation receives the ID for the group or dataset being iterated over ('loc_id'), the name of the current attribute about the object ('attr_name') and the pointer to the operator data passed in to H5Aiterate ('op_data'). The return values from an operator are: A. Zero causes the iterator to continue, returning zero when all attributes have been processed. B. Positive causes the iterator to immediately return that positive value, indicating short-circuit success. The iterator can be restarted at the next attribute. C. Negative causes the iterator to immediately return that value, indicating failure. The iterator can be restarted at the next attribute. * * Modifications: * Robb Matzke, 5 Jun 1998 * The LOC_ID can also be a named (committed) datatype. * * Robb Matzke, 5 Jun 1998 * Like the group iterator, if ATTR_NUM is the null pointer then all * attributes are processed. * --------------------------------------------------------------------------*/ herr_t H5Aiterate(hid_t loc_id, unsigned *attr_num, H5A_operator_t op, void *op_data) { H5G_entry_t *ent = NULL; /*symtab ent of object to attribute */ H5A_t found_attr; herr_t ret_value = 0; int idx, start_idx; FUNC_ENTER_API(H5Aiterate, FAIL) H5TRACE4("e","i*Iuxx",loc_id,attr_num,op,op_data); /* check arguments */ if (H5I_FILE==H5I_get_type(loc_id) || H5I_ATTR==H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") if (NULL==(ent=H5G_loc(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") /* * Look up the attribute for the object. Make certain the start point is * reasonable. */ start_idx = idx = (attr_num ? (int)*attr_num : 0); if (idx<0) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index specified") if(idx0) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index specified") if (attr_num) *attr_num = (unsigned)idx; done: FUNC_LEAVE_API(ret_value) } /* H5Aiterate() */ /*-------------------------------------------------------------------------- NAME H5Adelete PURPOSE Deletes an attribute from a location USAGE herr_t H5Adelete (loc_id, name) hid_t loc_id; IN: Object (dataset or group) to have attribute deleted from const char *name; IN: Name of attribute to delete RETURNS Non-negative on success/Negative on failure ERRORS DESCRIPTION This function removes the named attribute from a dataset or group. This function should not be used when attribute IDs are open on 'loc_id' as it may cause the internal indexes of the attributes to change and future writes to the open attributes to produce incorrect results. * * Modifications: * Robb Matzke, 5 Jun 1998 * The LOC_ID can also be a named (committed) datatype. * --------------------------------------------------------------------------*/ herr_t H5Adelete(hid_t loc_id, const char *name) { H5G_entry_t *ent = NULL; /*symtab ent of object to attribute */ int found; herr_t ret_value; FUNC_ENTER_API(H5Adelete, FAIL) H5TRACE2("e","is",loc_id,name); /* check arguments */ if (H5I_FILE==H5I_get_type(loc_id) || H5I_ATTR==H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") if (NULL==(ent=H5G_loc(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") /* Look up the attribute index for the object */ if((found=H5A_get_index(ent,name,H5AC_dxpl_id))<0) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "attribute not found") /* Delete the attribute from the location */ if ((ret_value=H5O_remove(ent, H5O_ATTR_ID, found, TRUE, H5AC_dxpl_id)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute header message") done: FUNC_LEAVE_API(ret_value) } /* H5Adelete() */ /*-------------------------------------------------------------------------- NAME H5Aclose PURPOSE Close an attribute ID USAGE herr_t H5Aclose (attr_id) hid_t attr_id; IN: Attribute to release access to RETURNS Non-negative on success/Negative on failure ERRORS DESCRIPTION This function releases an attribute from use. Further use of the attribute ID will result in undefined behavior. --------------------------------------------------------------------------*/ herr_t H5Aclose(hid_t attr_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Aclose, FAIL) H5TRACE1("e","i",attr_id); /* check arguments */ if (NULL == H5I_object_verify(attr_id, H5I_ATTR)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") /* Decrement references to that atom (and close it) */ if(H5I_dec_ref (attr_id)<0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "can't close attribute") done: FUNC_LEAVE_API(ret_value) } /* H5Aclose() */ /*------------------------------------------------------------------------- * Function: H5A_copy * * Purpose: Copies attribute OLD_ATTR. * * Return: Success: Pointer to a new copy of the OLD_ATTR argument. * * Failure: NULL * * Programmer: Robb Matzke * Thursday, December 4, 1997 * * Modifications: * *------------------------------------------------------------------------- */ H5A_t * H5A_copy(H5A_t *_new_attr, const H5A_t *old_attr, unsigned update_flags) { H5A_t *new_attr=NULL; hbool_t allocated_attr=FALSE; /* Whether the attribute was allocated */ H5A_t *ret_value=NULL; /* Return value */ FUNC_ENTER_NOAPI(H5A_copy, NULL) /* check args */ assert(old_attr); /* get space */ if(_new_attr==NULL) { /* Sanity check - We should not be only updating data if we don'y have anything */ HDassert(!(update_flags&H5O_UPDATE_DATA_ONLY)); if (NULL==(new_attr = H5FL_MALLOC(H5A_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") allocated_attr=TRUE; } /* end if */ else new_attr=_new_attr; if(!(update_flags&H5O_UPDATE_DATA_ONLY)) { /* Copy the top level of the attribute */ *new_attr = *old_attr; /* Don't open the object header for a copy */ new_attr->ent_opened=0; /* Copy the guts of the attribute */ new_attr->name=HDstrdup(old_attr->name); new_attr->dt=H5T_copy(old_attr->dt, H5T_COPY_ALL); new_attr->ds=H5S_copy(old_attr->ds, FALSE); } /* end if */ if(old_attr->data) { if(!(update_flags&H5O_UPDATE_DATA_ONLY) || new_attr->data==NULL) { if (NULL==(new_attr->data=H5FL_BLK_MALLOC(attr_buf,old_attr->data_size))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") } /* end if */ HDmemcpy(new_attr->data,old_attr->data,old_attr->data_size); } /* end if */ /* Set the return value */ ret_value=new_attr; done: if(ret_value==NULL) { if(new_attr!=NULL && allocated_attr) (void)H5A_close(new_attr); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5A_free * * Purpose: Frees all memory associated with an attribute, but does not * free the H5A_t structure (which should be done in H5T_close). * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Monday, November 15, 2004 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5A_free(H5A_t *attr) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5A_free, FAIL) assert(attr); /* Free dynamicly allocated items */ if(attr->name) H5MM_xfree(attr->name); if(attr->dt) if(H5T_close(attr->dt)<0) HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release datatype info") if(attr->ds) if(H5S_close(attr->ds)<0) HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release dataspace info") if(attr->data) H5FL_BLK_FREE(attr_buf, attr->data); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A_free() */ /*------------------------------------------------------------------------- * Function: H5A_close * * Purpose: Frees an attribute and all associated memory. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Monday, December 8, 1997 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5A_close(H5A_t *attr) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5A_close, FAIL) assert(attr); /* Check if the attribute has any data yet, if not, fill with zeroes */ if(attr->ent_opened && !attr->initialized) { uint8_t *tmp_buf=H5FL_BLK_CALLOC(attr_buf, attr->data_size); if (NULL == tmp_buf) HGOTO_ERROR(H5E_ATTR, H5E_NOSPACE, FAIL, "memory allocation failed for attribute fill-value") /* Go write the fill data to the attribute */ if (H5A_write(attr,attr->dt,tmp_buf,H5AC_dxpl_id)<0) HGOTO_ERROR(H5E_ATTR, H5E_WRITEERROR, FAIL, "unable to write attribute") /* Free temporary buffer */ H5FL_BLK_FREE(attr_buf, tmp_buf); } /* end if */ /* Free dynamicly allocated items */ if(H5A_free(attr)<0) HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release attribute info") /* Close the object's symbol-table entry */ if(attr->ent_opened) if(H5O_close(&(attr->ent))<0) HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release object header info") H5FL_FREE(H5A_t, attr); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A_close() */ /*------------------------------------------------------------------------- * Function: H5A_entof * * Purpose: Return the symbol table entry for an attribute. It's the * symbol table entry for the object to which the attribute * belongs, not the attribute itself. * * Return: Success: Ptr to entry * * Failure: NULL * * Programmer: Robb Matzke * Thursday, August 6, 1998 * * Modifications: * *------------------------------------------------------------------------- */ H5G_entry_t * H5A_entof(H5A_t *attr) { H5G_entry_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5A_entof, NULL) assert(attr); /* Set return value */ ret_value=&(attr->ent); done: FUNC_LEAVE_NOAPI(ret_value) } xdmf-3.0+git20160803/Utilities/hdf5/H5FDsec2.h0000640000175000017500000000270513003006557020313 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Robb Matzke * Monday, August 2, 1999 * * Purpose: The public header file for the sec2 driver. */ #ifndef H5FDsec2_H #define H5FDsec2_H #include "H5Ipublic.h" #define H5FD_SEC2 (H5FD_sec2_init()) #ifdef __cplusplus extern "C" { #endif H5_DLL hid_t H5FD_sec2_init(void); H5_DLL void H5FD_sec2_term(void); H5_DLL herr_t H5Pset_fapl_sec2(hid_t fapl_id); #ifdef __cplusplus } #endif #endif xdmf-3.0+git20160803/Utilities/hdf5/CVS/0000740000175000017500000000000013003006557017324 5ustar alastairalastairxdmf-3.0+git20160803/Utilities/hdf5/CVS/Repository0000640000175000017500000000002413003006557021424 0ustar alastairalastairXdmf/Utilities/hdf5 xdmf-3.0+git20160803/Utilities/hdf5/CVS/Root0000640000175000017500000000006413003006557020174 0ustar alastairalastair:pserver:anonymous@public.kitware.com:/cvsroot/Xdmf xdmf-3.0+git20160803/Utilities/hdf5/CVS/Entries0000640000175000017500000002063213003006557020665 0ustar alastairalastair/.NoDartCoverage/1.2/Tue Mar 4 15:24:29 2003// /CMakeLists.txt/1.49/Wed Jan 6 16:32:58 2010// /CTestCustom.ctest.in/1.6/Mon Jan 15 15:25:50 2007// /H5.c/1.10/Mon Jan 15 15:33:24 2007// /H5A.c/1.6/Mon Jan 15 15:44:07 2007// /H5AC.c/1.6/Mon Jan 15 15:44:07 2007// /H5ACprivate.h/1.6/Mon Jan 15 15:44:08 2007// /H5ACpublic.h/1.5/Mon Jan 15 15:44:08 2007// /H5Apkg.h/1.6/Mon Jan 15 15:44:08 2007// /H5Aprivate.h/1.5/Mon Jan 15 15:44:08 2007// /H5Apublic.h/1.6/Mon Jan 15 15:44:08 2007// /H5B.c/1.6/Mon Jan 15 15:44:08 2007// /H5Bpkg.h/1.3/Mon Jan 15 15:44:08 2007// /H5Bprivate.h/1.6/Mon Jan 15 15:44:08 2007// /H5Bpublic.h/1.5/Mon Jan 15 15:44:08 2007// /H5C.c/1.1/Mon Jan 15 15:44:08 2007// /H5Cprivate.h/1.1/Mon Jan 15 15:44:08 2007// /H5Cpublic.h/1.1/Mon Jan 15 15:44:08 2007// /H5D.c/1.7/Mon Jan 15 15:44:08 2007// /H5Dcompact.c/1.1/Mon Jan 15 15:44:08 2007// /H5Dcontig.c/1.1/Mon Jan 15 15:44:08 2007// /H5Defl.c/1.1/Mon Jan 15 15:44:08 2007// /H5Dio.c/1.4/Wed Jan 17 19:33:23 2007// /H5Distore.c/1.1/Mon Jan 15 15:44:09 2007// /H5Dmpio.c/1.1/Mon Jan 15 15:44:09 2007// /H5Dpkg.h/1.3/Mon Jan 15 15:44:09 2007// /H5Dprivate.h/1.6/Mon Jan 15 15:44:09 2007// /H5Dpublic.h/1.6/Mon Jan 15 15:44:09 2007// /H5Dselect.c/1.1/Mon Jan 15 15:44:09 2007// /H5Dtest.c/1.1/Mon Jan 15 15:44:09 2007// /H5E.c/1.8/Mon Jan 15 15:44:09 2007// /H5Eprivate.h/1.6/Mon Jan 15 15:44:09 2007// /H5Epublic.h/1.7/Mon Jan 15 15:44:09 2007// /H5F.c/1.6/Mon Jan 15 15:44:09 2007// /H5FD.c/1.6/Mon Jan 15 15:44:09 2007// /H5FDcore.c/1.7/Mon Jan 15 15:44:09 2007// /H5FDcore.h/1.6/Mon Jan 15 15:44:10 2007// /H5FDfamily.c/1.6/Mon Jan 15 15:44:10 2007// /H5FDfamily.h/1.6/Mon Jan 15 15:44:10 2007// /H5FDgass.c/1.8/Mon Jan 15 15:44:10 2007// /H5FDgass.h/1.6/Mon Jan 15 15:44:10 2007// /H5FDlog.c/1.8/Mon Jan 15 15:44:10 2007// /H5FDlog.h/1.6/Mon Jan 15 15:44:10 2007// /H5FDmpi.c/1.1/Mon Jan 15 15:44:10 2007// /H5FDmpi.h/1.1/Mon Jan 15 15:44:10 2007// /H5FDmpio.c/1.6/Mon Jan 15 15:44:10 2007// /H5FDmpio.h/1.6/Mon Jan 15 15:44:10 2007// /H5FDmpiposix.c/1.5/Tue Mar 6 15:16:04 2007// /H5FDmpiposix.h/1.3/Mon Jan 15 15:44:10 2007// /H5FDmulti.c/1.6/Mon Jan 15 15:44:10 2007// /H5FDmulti.h/1.6/Mon Jan 15 15:44:10 2007// /H5FDprivate.h/1.6/Mon Jan 15 15:44:10 2007// /H5FDpublic.h/1.6/Mon Jan 15 15:44:10 2007// /H5FDsec2.c/1.8/Mon Jan 15 15:44:10 2007// /H5FDsec2.h/1.6/Mon Jan 15 15:44:10 2007// /H5FDsrb.c/1.7/Mon Jan 15 15:44:10 2007// /H5FDsrb.h/1.5/Mon Jan 15 15:44:11 2007// /H5FDstdio.c/1.7/Mon Jan 15 15:44:11 2007// /H5FDstdio.h/1.6/Mon Jan 15 15:44:11 2007// /H5FDstream.c/1.9/Mon Jul 30 13:30:07 2007// /H5FDstream.h/1.6/Mon Jan 15 15:44:11 2007// /H5FL.c/1.6/Mon Jan 15 15:44:11 2007// /H5FLprivate.h/1.6/Mon Jan 15 15:44:11 2007// /H5FO.c/1.3/Mon Jan 15 15:44:11 2007// /H5FOprivate.h/1.3/Mon Jan 15 15:44:11 2007// /H5FS.c/1.3/Mon Jan 15 15:44:11 2007// /H5FSprivate.h/1.3/Mon Jan 15 15:44:11 2007// /H5Fdbg.c/1.1/Mon Jan 15 15:44:11 2007// /H5Fmount.c/1.1/Mon Jan 15 15:44:11 2007// /H5Fpkg.h/1.6/Mon Jan 15 15:44:11 2007// /H5Fprivate.h/1.6/Mon Jan 15 15:44:12 2007// /H5Fpublic.h/1.6/Mon Jan 15 15:44:13 2007// /H5Fsfile.c/1.1/Mon Jan 15 15:44:13 2007// /H5Fsuper.c/1.1/Mon Jan 15 15:44:14 2007// /H5G.c/1.6/Mon Jan 15 15:44:14 2007// /H5Gent.c/1.6/Mon Jan 15 15:44:14 2007// /H5Gnode.c/1.6/Mon Jan 15 15:44:14 2007// /H5Gpkg.h/1.6/Mon Jan 15 15:44:15 2007// /H5Gprivate.h/1.6/Mon Jan 15 15:44:15 2007// /H5Gpublic.h/1.6/Mon Jan 15 15:44:15 2007// /H5Gstab.c/1.6/Mon Jan 15 15:44:15 2007// /H5HG.c/1.6/Mon Jan 15 15:44:15 2007// /H5HGdbg.c/1.1/Mon Jan 15 15:44:15 2007// /H5HGpkg.h/1.1/Mon Jan 15 15:44:15 2007// /H5HGprivate.h/1.6/Mon Jan 15 15:44:15 2007// /H5HGpublic.h/1.5/Mon Jan 15 15:44:15 2007// /H5HL.c/1.6/Mon Jan 15 15:44:15 2007// /H5HLdbg.c/1.1/Mon Jan 15 15:44:15 2007// /H5HLpkg.h/1.1/Mon Jan 15 15:44:15 2007// /H5HLprivate.h/1.6/Mon Jan 15 15:44:15 2007// /H5HLpublic.h/1.5/Mon Jan 15 15:44:16 2007// /H5HP.c/1.3/Mon Jan 15 15:44:16 2007// /H5HPprivate.h/1.3/Mon Jan 15 15:44:16 2007// /H5I.c/1.7/Mon Jan 15 15:44:16 2007// /H5Ipkg.h/1.3/Mon Jan 15 15:44:16 2007// /H5Iprivate.h/1.6/Mon Jan 15 15:44:16 2007// /H5Ipublic.h/1.6/Mon Jan 15 15:44:16 2007// /H5MF.c/1.6/Mon Jan 15 15:44:16 2007// /H5MFprivate.h/1.6/Mon Jan 15 15:44:16 2007// /H5MM.c/1.6/Mon Jan 15 15:44:16 2007// /H5MMprivate.h/1.6/Mon Jan 15 15:44:17 2007// /H5MMpublic.h/1.5/Mon Jan 15 15:44:17 2007// /H5MPprivate.h/1.3/Mon Jan 15 15:44:17 2007// /H5O.c/1.6/Mon Jan 15 15:44:17 2007// /H5Oattr.c/1.6/Mon Jan 15 15:44:17 2007// /H5Obogus.c/1.3/Mon Jan 15 15:44:17 2007// /H5Ocont.c/1.6/Mon Jan 15 15:44:17 2007// /H5Odtype.c/1.7/Mon Jan 15 15:44:17 2007// /H5Oefl.c/1.6/Mon Jan 15 15:44:17 2007// /H5Ofill.c/1.6/Mon Jan 15 15:44:17 2007// /H5Olayout.c/1.6/Mon Jan 15 15:44:18 2007// /H5Omtime.c/1.7/Mon Jan 15 15:44:18 2007// /H5Oname.c/1.6/Mon Jan 15 15:44:18 2007// /H5Onull.c/1.6/Mon Jan 15 15:44:18 2007// /H5Opkg.h/1.3/Mon Jan 15 15:44:18 2007// /H5Opline.c/1.3/Mon Jan 15 15:44:18 2007// /H5Oprivate.h/1.6/Mon Jan 15 15:44:18 2007// /H5Opublic.h/1.5/Mon Jan 15 15:44:18 2007// /H5Osdspace.c/1.6/Mon Jan 15 15:44:18 2007// /H5Oshared.c/1.6/Mon Jan 15 15:44:18 2007// /H5Ostab.c/1.6/Mon Jan 15 15:44:18 2007// /H5P.c/1.6/Mon Jan 15 15:44:18 2007// /H5Pdcpl.c/1.3/Mon Jan 15 15:44:19 2007// /H5Pdxpl.c/1.3/Mon Jan 15 15:44:19 2007// /H5Pfapl.c/1.3/Mon Jan 15 15:44:19 2007// /H5Pfcpl.c/1.3/Mon Jan 15 15:44:19 2007// /H5Ppkg.h/1.3/Mon Jan 15 15:44:19 2007// /H5Pprivate.h/1.5/Mon Jan 15 15:44:19 2007// /H5Ppublic.h/1.6/Mon Jan 15 15:44:19 2007// /H5Ptest.c/1.3/Mon Jan 15 15:44:19 2007// /H5R.c/1.6/Mon Jan 15 15:44:19 2007// /H5RC.c/1.1/Mon Jan 15 15:44:20 2007// /H5RCprivate.h/1.1/Mon Jan 15 15:44:20 2007// /H5RS.c/1.3/Mon Jan 15 15:44:20 2007// /H5RSprivate.h/1.3/Mon Jan 15 15:44:20 2007// /H5Rprivate.h/1.6/Mon Jan 15 15:44:20 2007// /H5Rpublic.h/1.6/Mon Jan 15 15:44:20 2007// /H5S.c/1.6/Mon Jan 15 15:44:20 2007// /H5SL.c/1.1/Mon Jan 15 15:44:20 2007// /H5SLprivate.h/1.1/Mon Jan 15 15:44:20 2007// /H5ST.c/1.3/Mon Jan 15 15:44:20 2007// /H5STprivate.h/1.3/Mon Jan 15 15:44:20 2007// /H5Sall.c/1.6/Mon Jan 15 15:44:20 2007// /H5Shyper.c/1.6/Mon Jan 15 15:44:20 2007// /H5Smpio.c/1.6/Mon Jan 15 15:44:21 2007// /H5Snone.c/1.6/Mon Jan 15 15:44:21 2007// /H5Spkg.h/1.6/Mon Jan 15 15:44:21 2007// /H5Spoint.c/1.6/Mon Jan 15 15:44:21 2007// /H5Sprivate.h/1.6/Mon Jan 15 15:44:22 2007// /H5Spublic.h/1.6/Mon Jan 15 15:44:22 2007// /H5Sselect.c/1.6/Mon Jan 15 15:44:22 2007// /H5Stest.c/1.3/Mon Jan 15 15:44:22 2007// /H5T.c/1.6/Mon Jan 15 15:44:22 2007// /H5TS.c/1.6/Mon Jan 15 15:44:23 2007// /H5TSprivate.h/1.6/Mon Jan 15 15:44:23 2007// /H5Tarray.c/1.3/Mon Jan 15 15:44:23 2007// /H5Tbit.c/1.6/Mon Jan 15 15:44:23 2007// /H5Tcommit.c/1.4/Wed Jan 17 16:18:33 2007// /H5Tcompound.c/1.3/Mon Jan 15 15:44:23 2007// /H5Tconv.c/1.8/Mon Jan 15 15:44:23 2007// /H5Tcset.c/1.3/Mon Jan 15 15:44:25 2007// /H5Tenum.c/1.3/Mon Jan 15 15:44:25 2007// /H5Tfields.c/1.3/Mon Jan 15 15:44:25 2007// /H5Tfixed.c/1.3/Mon Jan 15 15:44:25 2007// /H5Tfloat.c/1.3/Mon Jan 15 15:44:25 2007// /H5Tinit.WIN32.c.in/1.4/Mon Jan 15 15:44:25 2007// /H5Tnative.c/1.3/Mon Jan 15 15:44:25 2007// /H5Toffset.c/1.3/Mon Jan 15 15:44:25 2007// /H5Topaque.c/1.3/Mon Jan 15 15:44:25 2007// /H5Torder.c/1.3/Mon Jan 15 15:44:25 2007// /H5Tpad.c/1.3/Mon Jan 15 15:44:25 2007// /H5Tpkg.h/1.6/Mon Jan 15 15:44:25 2007// /H5Tprecis.c/1.3/Mon Jan 15 15:44:25 2007// /H5Tprivate.h/1.6/Mon Jan 15 15:44:25 2007// /H5Tpublic.h/1.6/Mon Jan 15 15:44:25 2007// /H5Tstrpad.c/1.3/Mon Jan 15 15:44:26 2007// /H5Tvlen.c/1.6/Mon Jan 15 15:44:26 2007// /H5V.c/1.6/Mon Jan 15 15:44:26 2007// /H5Vprivate.h/1.6/Mon Jan 15 15:44:26 2007// /H5Z.c/1.6/Mon Jan 15 15:44:26 2007// /H5Zdeflate.c/1.7/Mon Jan 15 15:44:26 2007// /H5Zfletcher32.c/1.3/Mon Jan 15 15:44:26 2007// /H5Zpkg.h/1.3/Mon Jan 15 15:44:26 2007// /H5Zprivate.h/1.6/Mon Jan 15 15:44:26 2007// /H5Zpublic.h/1.6/Mon Jan 15 15:44:26 2007// /H5Zshuffle.c/1.3/Mon Jan 15 15:44:26 2007// /H5Zszip.c/1.3/Mon Jan 15 15:44:26 2007// /H5api_adpt.h/1.9/Mon Jan 15 15:44:26 2007// /H5config.WIN32.h.in/1.7/Mon Jan 15 15:44:26 2007// /H5config.h.cmake.in/1.8/Thu Sep 20 18:14:53 2007// /H5detect.c/1.8/Mon Jan 15 15:44:26 2007// /H5private.h/1.9/Thu Feb 1 21:11:35 2007// /H5pubconf.WIN32.h.in/1.7/Mon Jan 15 15:44:26 2007// /H5pubconf.h.cmake.in/1.5/Mon Jan 15 15:44:26 2007// /H5public.h/1.6/Mon Jan 15 15:44:26 2007// /HDF5Config.cmake.in/1.7/Wed Mar 7 18:37:11 2007// /README.txt/1.5/Mon Jan 15 15:44:26 2007// /hdf5.h/1.6/Mon Jan 15 15:44:26 2007// /hdf5_zlib.h.in/1.3/Mon Jan 15 15:44:26 2007// D/CMake//// D/HDF5Tests//// xdmf-3.0+git20160803/Utilities/hdf5/H5ACpublic.h0000640000175000017500000000306613003006557020730 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*------------------------------------------------------------------------- * * Created: H5ACproto.h * Jul 10 1997 * Robb Matzke * * Purpose: Public include file for cache functions. * * Modifications: * *------------------------------------------------------------------------- */ #ifndef _H5ACpublic_H #define _H5ACpublic_H /* Public headers needed by this file */ #include "H5public.h" #ifdef __cplusplus extern "C" { #endif #ifdef __cplusplus } #endif #endif xdmf-3.0+git20160803/Utilities/hdf5/H5FDmulti.h0000640000175000017500000000420613003006557020607 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Robb Matzke * Monday, August 2, 1999 * * Purpose: The public header file for the "multi" driver. */ #ifndef H5FDmulti_H #define H5FDmulti_H #include "H5Ipublic.h" #include "H5Ppublic.h" /* Property lists */ #include "H5Fpublic.h" #define H5FD_MULTI (H5FD_multi_init()) #ifdef __cplusplus extern "C" { #endif H5_DLL hid_t H5FD_multi_init(void); H5_DLL void H5FD_multi_term(void); H5_DLL herr_t H5Pset_fapl_multi(hid_t fapl_id, const H5FD_mem_t *memb_map, const hid_t *memb_fapl, const char * const *memb_name, const haddr_t *memb_addr, hbool_t relax); H5_DLL herr_t H5Pget_fapl_multi(hid_t fapl_id, H5FD_mem_t *memb_map/*out*/, hid_t *memb_fapl/*out*/, char **memb_name/*out*/, haddr_t *memb_addr/*out*/, hbool_t *relax/*out*/); H5_DLL herr_t H5Pset_dxpl_multi(hid_t dxpl_id, const hid_t *memb_dxpl); H5_DLL herr_t H5Pget_dxpl_multi(hid_t dxpl_id, hid_t *memb_dxpl/*out*/); H5_DLL herr_t H5Pset_fapl_split(hid_t fapl, const char *meta_ext, hid_t meta_plist_id, const char *raw_ext, hid_t raw_plist_id); #ifdef __cplusplus } #endif #endif xdmf-3.0+git20160803/Utilities/hdf5/H5TSprivate.h0000640000175000017500000000456713003006557021176 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*------------------------------------------------------------------------- * * Created: H5TSprivate.h * May 2 2000 * Chee Wai LEE * * Purpose: Private non-prototype header. * * Modifications: * *------------------------------------------------------------------------- */ #ifndef H5TSprivate_H_ #define H5TSprivate_H_ /* Public headers needed by this file */ #ifdef LATER #include "H5TSpublic.h" /*Public API prototypes */ #endif /* LATER */ /* Library level data structures */ typedef struct H5TS_mutex_struct { pthread_t *owner_thread; /* current lock owner */ pthread_mutex_t atomic_lock; /* lock for atomicity of new mechanism */ pthread_cond_t cond_var; /* condition variable */ unsigned int lock_count; } H5TS_mutex_t; /* Extern global variables */ extern pthread_once_t H5TS_first_init_g; extern pthread_key_t H5TS_errstk_key_g; extern pthread_key_t H5TS_funcstk_key_g; #if defined c_plusplus || defined __cplusplus extern "C" { #endif /* c_plusplus || __cplusplus */ H5_DLL void H5TS_first_thread_init(void); H5_DLL herr_t H5TS_mutex_lock(H5TS_mutex_t *mutex); H5_DLL herr_t H5TS_mutex_unlock(H5TS_mutex_t *mutex); H5_DLL herr_t H5TS_cancel_count_inc(void); H5_DLL herr_t H5TS_cancel_count_dec(void); #if defined c_plusplus || defined __cplusplus } #endif /* c_plusplus || __cplusplus */ #endif /* H5TSprivate_H_ */ xdmf-3.0+git20160803/Utilities/hdf5/H5Tenum.c0000640000175000017500000004763013003006557020336 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Module Info: This module contains the functionality for enumerated datatypes * in the H5T interface. */ #define H5T_PACKAGE /*suppress error about including H5Tpkg */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5T_init_enum_interface #include "H5private.h" /*generic functions */ #include "H5Eprivate.h" /*error handling */ #include "H5FLprivate.h" /*Free Lists */ #include "H5Iprivate.h" /*ID functions */ #include "H5MMprivate.h" /*memory management */ #include "H5Tpkg.h" /*data-type functions */ /* Declare extern the free lists for H5T_t's and H5T_shared_t's */ H5FL_EXTERN(H5T_t); H5FL_EXTERN(H5T_shared_t); /* Static local functions */ static char *H5T_enum_nameof(const H5T_t *dt, const void *value, char *name/*out*/, size_t size); static herr_t H5T_enum_valueof(const H5T_t *dt, const char *name, void *value/*out*/); /*-------------------------------------------------------------------------- NAME H5T_init_enum_interface -- Initialize interface-specific information USAGE herr_t H5T_init_enum_interface() RETURNS Non-negative on success/Negative on failure DESCRIPTION Initializes any interface-specific data or routines. (Just calls H5T_init_iterface currently). --------------------------------------------------------------------------*/ static herr_t H5T_init_enum_interface(void) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_init_enum_interface) FUNC_LEAVE_NOAPI(H5T_init()) } /* H5T_init_enum_interface() */ /*------------------------------------------------------------------------- * Function: H5Tenum_create * * Purpose: Create a new enumeration data type based on the specified * TYPE, which must be an integer type. * * Return: Success: ID of new enumeration data type * * Failure: Negative * * Programmer: Robb Matzke * Tuesday, December 22, 1998 * * Modifications: * *------------------------------------------------------------------------- */ hid_t H5Tenum_create(hid_t parent_id) { H5T_t *parent = NULL; /*base integer data type */ H5T_t *dt = NULL; /*new enumeration data type */ hid_t ret_value; /*return value */ FUNC_ENTER_API(H5Tenum_create, FAIL) H5TRACE1("i","i",parent_id); /* Check args */ if (NULL==(parent=H5I_object_verify(parent_id,H5I_DATATYPE)) || H5T_INTEGER!=parent->shared->type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an integer data type") /* Build new type */ if((dt=H5T_enum_create(parent))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "cannot create enum type") /* Atomize the type */ if ((ret_value=H5I_register(H5I_DATATYPE, dt))<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register data type atom") done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5T_enum_create * * Purpose: Private function for H5Tenum_create. Create a new * enumeration data type based on the specified * TYPE, which must be an integer type. * * Return: Success: new enumeration data type * * Failure: NULL * * Programmer: Raymond Lu * October 9, 2002 * * Modifications: * *------------------------------------------------------------------------- */ H5T_t * H5T_enum_create(const H5T_t *parent) { H5T_t *ret_value; /*new enumeration data type */ FUNC_ENTER_NOAPI(H5T_enum_create, NULL) assert(parent); /* Build new type */ if(NULL == (ret_value = H5T_alloc())) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") ret_value->shared->type = H5T_ENUM; ret_value->shared->parent = H5T_copy(parent, H5T_COPY_ALL); assert(ret_value->shared->parent); ret_value->shared->size = ret_value->shared->parent->shared->size; done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5Tenum_insert * * Purpose: Insert a new enumeration data type member into an enumeration * type. TYPE is the enumeration type, NAME is the name of the * new member, and VALUE points to the value of the new member. * The NAME and VALUE must both be unique within the TYPE. VALUE * points to data which is of the data type defined when the * enumeration type was created. * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Wednesday, December 23, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Tenum_insert(hid_t type, const char *name, const void *value) { H5T_t *dt=NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Tenum_insert, FAIL) H5TRACE3("e","isx",type,name,value); /* Check args */ if (NULL==(dt=H5I_object_verify(type,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") if (H5T_ENUM!=dt->shared->type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an enumeration data type") if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") if (!value) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no value specified") /* Do work */ if (H5T_enum_insert(dt, name, value)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to insert new enumeration member") done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5T_enum_insert * * Purpose: Insert a new member having a NAME and VALUE into an * enumeration data TYPE. The NAME and VALUE must both be * unique. The VALUE points to data of the data type defined for * the enumeration base type. * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Wednesday, December 23, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_enum_insert(const H5T_t *dt, const char *name, const void *value) { unsigned i; char **names=NULL; uint8_t *values=NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_enum_insert, FAIL) assert(dt); assert(name && *name); assert(value); /* The name and value had better not already exist */ for (i=0; ishared->u.enumer.nmembs; i++) { if (!HDstrcmp(dt->shared->u.enumer.name[i], name)) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "name redefinition") if (!HDmemcmp(dt->shared->u.enumer.value+i*dt->shared->size, value, dt->shared->size)) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "value redefinition") } /* Increase table sizes */ if (dt->shared->u.enumer.nmembs >= dt->shared->u.enumer.nalloc) { unsigned n = MAX(32, 2*dt->shared->u.enumer.nalloc); if (NULL==(names=H5MM_realloc(dt->shared->u.enumer.name, n*sizeof(char*)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") dt->shared->u.enumer.name = names; if (NULL==(values=H5MM_realloc(dt->shared->u.enumer.value, n*dt->shared->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") dt->shared->u.enumer.value = values; dt->shared->u.enumer.nalloc = n; } /* Insert new member at end of member arrays */ dt->shared->u.enumer.sorted = H5T_SORT_NONE; i = dt->shared->u.enumer.nmembs++; dt->shared->u.enumer.name[i] = H5MM_xstrdup(name); HDmemcpy(dt->shared->u.enumer.value+i*dt->shared->size, value, dt->shared->size); done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5Tget_member_value * * Purpose: Return the value for an enumeration data type member. * * Return: Success: non-negative with the member value copied * into the memory pointed to by VALUE. * * Failure: negative, VALUE memory is undefined. * * Programmer: Robb Matzke * Wednesday, December 23, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Tget_member_value(hid_t type, unsigned membno, void *value/*out*/) { H5T_t *dt=NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Tget_member_value, FAIL) H5TRACE3("e","iIux",type,membno,value); if (NULL==(dt=H5I_object_verify(type,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") if (H5T_ENUM!=dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for data type class") if (membno>=dt->shared->u.enumer.nmembs) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid member number") if (!value) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null value buffer") if (H5T_get_member_value(dt, membno, value)<0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get member value") done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5T_get_member_value * * Purpose: Private function for H5T_get_member_value. Return the * value for an enumeration data type member. * * Return: Success: non-negative with the member value copied * into the memory pointed to by VALUE. * * Failure: negative, VALUE memory is undefined. * * Programmer: Raymond Lu * October 9, 2002 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_get_member_value(const H5T_t *dt, unsigned membno, void *value/*out*/) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_get_member_value, FAIL) assert(dt); assert(value); HDmemcpy(value, dt->shared->u.enumer.value + membno*dt->shared->size, dt->shared->size); done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5Tenum_nameof * * Purpose: Finds the symbol name that corresponds to the specified VALUE * of an enumeration data type TYPE. At most SIZE characters of * the symbol name are copied into the NAME buffer. If the * entire symbol anem and null terminator do not fit in the NAME * buffer then as many characters as possible are copied (not * null terminated) and the function fails. * * Return: Success: Non-negative. * * Failure: Negative, first character of NAME is set to * null if SIZE allows it. * * Programmer: Robb Matzke * Monday, January 4, 1999 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Tenum_nameof(hid_t type, const void *value, char *name/*out*/, size_t size) { H5T_t *dt = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Tenum_nameof, FAIL) H5TRACE4("e","ixxz",type,value,name,size); /* Check args */ if (NULL==(dt=H5I_object_verify(type,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") if (H5T_ENUM!=dt->shared->type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an enumeration data type") if (!value) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no value supplied") if (!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name buffer supplied") if (NULL==H5T_enum_nameof(dt, value, name, size)) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "nameof query failed") done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5T_enum_nameof * * Purpose: Finds the symbol name that corresponds the the specified * VALUE of an enumeration data type DT. At most SIZE characters * of the symbol name are copied into the NAME buffer. If the * entire symbol name and null terminator do not fit in the NAME * buffer then as many characters as possible are copied and the * function returns failure. * * If NAME is the null pointer and SIZE is zero then enough * space is allocated to hold the result and a pointer to that * memory is returned. * * Return: Success: Pointer to NAME * * Failure: NULL, name[0] is set to null. * * Programmer: Robb Matzke * Monday, January 4, 1999 * * Modifications: * Raymond Lu * Wednesday, Febuary 9, 2005 * Made a copy of original datatype and do sorting and search * on that copy, to protect the original order of members. *------------------------------------------------------------------------- */ static char * H5T_enum_nameof(const H5T_t *dt, const void *value, char *name/*out*/, size_t size) { unsigned lt, md=0, rt; /*indices for binary search */ int cmp=(-1); /*comparison result */ H5T_t *copied_dt = NULL; /*do sorting in copied datatype */ char *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5T_enum_nameof, NULL) /* Check args */ assert(dt && H5T_ENUM==dt->shared->type); assert(value); assert(name || 0==size); if (name && size>0) *name = '\0'; /* Sanity check */ if (dt->shared->u.enumer.nmembs == 0) HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL, "datatype has no members") /* Do a binary search over the values to find the correct one. Do sorting * and search on the copied datatype to protect the original order. */ if (NULL==(copied_dt=H5T_copy(dt, H5T_COPY_ALL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy data type"); if(H5T_sort_value(copied_dt, NULL)<0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOMPARE, NULL, "value sort failed") lt = 0; rt = copied_dt->shared->u.enumer.nmembs; while (ltshared->u.enumer.value+md*copied_dt->shared->size, copied_dt->shared->size); if (cmp<0) { rt = md; } else if (cmp>0) { lt = md+1; } else { break; } } /* Value was not yet defined. This fixes bug # 774, 2002/06/05 EIP */ if (cmp!=0) HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL, "value is currently not defined") /* Save result name */ if (!name && NULL==(name=H5MM_malloc(HDstrlen(copied_dt->shared->u.enumer.name[md])+1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); HDstrncpy(name, copied_dt->shared->u.enumer.name[md], size); if (HDstrlen(copied_dt->shared->u.enumer.name[md])>=size) HGOTO_ERROR(H5E_DATATYPE, H5E_NOSPACE, NULL, "name has been truncated") /* Set return value */ ret_value=name; if (H5T_close(copied_dt)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, NULL, "unable to close data type"); done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5Tenum_valueof * * Purpose: Finds the value that corresponds to the specified NAME f an * enumeration TYPE. The VALUE argument should be at least as * large as the value of H5Tget_size(type) in order to hold the * result. * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Monday, January 4, 1999 * * Modifications: * Raymond Lu * Wednesday, Febuary 9, 2005 * Made a copy of original datatype and do sorting and search * on that copy, to protect the original order of members. *------------------------------------------------------------------------- */ herr_t H5Tenum_valueof(hid_t type, const char *name, void *value/*out*/) { H5T_t *dt = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Tenum_valueof, FAIL) H5TRACE3("e","isx",type,name,value); /* Check args */ if (NULL==(dt=H5I_object_verify(type,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") if (H5T_ENUM!=dt->shared->type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an enumeration data type") if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") if (!value) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no value buffer") if (H5T_enum_valueof(dt, name, value)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "valueof query failed") done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5T_enum_valueof * * Purpose: Finds the value that corresponds the the specified symbol * NAME of an enumeration data type DT and copy it to the VALUE * result buffer. The VALUE should be allocated by the caller to * be large enough for the result. * * Return: Success: Non-negative, value stored in VALUE. * * Failure: Negative, VALUE is undefined. * * Programmer: Robb Matzke * Monday, January 4, 1999 * * Modifications: * Raymond Lu * Wednesday, Febuary 9, 2005 * Made a copy of original datatype and do sorting and search * on that copy, to protect the original order of members. *------------------------------------------------------------------------- */ static herr_t H5T_enum_valueof(const H5T_t *dt, const char *name, void *value/*out*/) { unsigned lt, md=0, rt; /*indices for binary search */ int cmp=(-1); /*comparison result */ H5T_t *copied_dt = NULL; /*do sorting in copied datatype */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_enum_valueof, FAIL) /* Check args */ assert(dt && H5T_ENUM==dt->shared->type); assert(name && *name); assert(value); /* Sanity check */ if (dt->shared->u.enumer.nmembs == 0) HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, FAIL, "datatype has no members") /* Do a binary search over the names to find the correct one. Do sorting * and search on the copied datatype to protect the original order. */ if (NULL==(copied_dt=H5T_copy(dt, H5T_COPY_ALL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy data type"); if(H5T_sort_name(copied_dt, NULL)<0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOMPARE, FAIL, "value sort failed") lt = 0; rt = copied_dt->shared->u.enumer.nmembs; while (ltshared->u.enumer.name[md]); if (cmp<0) { rt = md; } else if (cmp>0) { lt = md+1; } else { break; } } /* Value was not yet defined. This fixes bug # 774, 2002/06/05 EIP */ if (cmp!=0) HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, FAIL, "string doesn't exist in the enumeration type") HDmemcpy(value, copied_dt->shared->u.enumer.value+md*copied_dt->shared->size, copied_dt->shared->size); if (H5T_close(copied_dt)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, FAIL, "unable to close data type"); done: FUNC_LEAVE_NOAPI(ret_value) } xdmf-3.0+git20160803/Utilities/hdf5/H5Snone.c0000640000175000017500000006024513003006557020325 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Quincey Koziol * Tuesday, November 10, 1998 * * Purpose: "None" selection data space I/O functions. */ #define H5S_PACKAGE /*suppress error about including H5Spkg */ #include "H5private.h" #include "H5Eprivate.h" #include "H5Iprivate.h" #include "H5Spkg.h" #include "H5Vprivate.h" #include "H5Dprivate.h" /* Static function prototypes */ /* Selection callbacks */ static herr_t H5S_none_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection); static herr_t H5S_none_get_seq_list(const H5S_t *space, unsigned flags, H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes, size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len); static herr_t H5S_none_release(H5S_t *space); static htri_t H5S_none_is_valid(const H5S_t *space); static hssize_t H5S_none_serial_size(const H5S_t *space); static herr_t H5S_none_serialize(const H5S_t *space, uint8_t *buf); static herr_t H5S_none_deserialize(H5S_t *space, const uint8_t *buf); static herr_t H5S_none_bounds(const H5S_t *space, hsize_t *start, hsize_t *end); static htri_t H5S_none_is_contiguous(const H5S_t *space); static htri_t H5S_none_is_single(const H5S_t *space); static htri_t H5S_none_is_regular(const H5S_t *space); static herr_t H5S_none_iter_init(H5S_sel_iter_t *iter, const H5S_t *space); /* Selection iteration callbacks */ static herr_t H5S_none_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords); static herr_t H5S_none_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end); static hsize_t H5S_none_iter_nelmts(const H5S_sel_iter_t *iter); static htri_t H5S_none_iter_has_next_block(const H5S_sel_iter_t *iter); static herr_t H5S_none_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem); static herr_t H5S_none_iter_next_block(H5S_sel_iter_t *sel_iter); static herr_t H5S_none_iter_release(H5S_sel_iter_t *sel_iter); /* Selection properties for "none" selections */ const H5S_select_class_t H5S_sel_none[1] = {{ H5S_SEL_NONE, /* Methods on selection */ H5S_none_copy, H5S_none_get_seq_list, H5S_none_release, H5S_none_is_valid, H5S_none_serial_size, H5S_none_serialize, H5S_none_deserialize, H5S_none_bounds, H5S_none_is_contiguous, H5S_none_is_single, H5S_none_is_regular, H5S_none_iter_init, }}; /* Iteration properties for "none" selections */ static const H5S_sel_iter_class_t H5S_sel_iter_none[1] = {{ H5S_SEL_NONE, /* Methods on selection iterator */ H5S_none_iter_coords, H5S_none_iter_block, H5S_none_iter_nelmts, H5S_none_iter_has_next_block, H5S_none_iter_next, H5S_none_iter_next_block, H5S_none_iter_release, }}; /*------------------------------------------------------------------------- * Function: H5S_none_iter_init * * Purpose: Initializes iteration information for "none" selection. * * Return: non-negative on success, negative on failure. * * Programmer: Quincey Koziol * Tuesday, June 16, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5S_none_iter_init (H5S_sel_iter_t *iter, const H5S_t UNUSED *space) { FUNC_ENTER_NOAPI_NOFUNC(H5S_none_iter_init); /* Check args */ assert (space && H5S_SEL_NONE==H5S_GET_SELECT_TYPE(space)); assert (iter); /* Initialize type of selection iterator */ iter->type=H5S_sel_iter_none; FUNC_LEAVE_NOAPI(SUCCEED); } /* H5S_none_iter_init() */ /*------------------------------------------------------------------------- * Function: H5S_none_iter_coords * * Purpose: Retrieve the current coordinates of iterator for current * selection * * Return: non-negative on success, negative on failure * * Programmer: Quincey Koziol * Tuesday, April 22, 2003 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5S_none_iter_coords (const H5S_sel_iter_t UNUSED *iter, hsize_t UNUSED *coords) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_none_iter_coords); /* Check args */ assert (iter); assert (coords); FUNC_LEAVE_NOAPI(FAIL); } /* H5S_none_iter_coords() */ /*------------------------------------------------------------------------- * Function: H5S_none_iter_block * * Purpose: Retrieve the current block of iterator for current * selection * * Return: non-negative on success, negative on failure * * Programmer: Quincey Koziol * Monday, June 2, 2003 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5S_none_iter_block (const H5S_sel_iter_t UNUSED *iter, hsize_t UNUSED *start, hsize_t UNUSED *end) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_none_iter_block); /* Check args */ assert (iter); assert (start); assert (end); FUNC_LEAVE_NOAPI(FAIL); } /* H5S_none_iter_block() */ /*------------------------------------------------------------------------- * Function: H5S_none_iter_nelmts * * Purpose: Return number of elements left to process in iterator * * Return: non-negative number of elements on success, zero on failure * * Programmer: Quincey Koziol * Tuesday, June 16, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static hsize_t H5S_none_iter_nelmts (const H5S_sel_iter_t UNUSED *iter) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_none_iter_nelmts); /* Check args */ assert (iter); FUNC_LEAVE_NOAPI(0); } /* H5S_none_iter_nelmts() */ /*-------------------------------------------------------------------------- NAME H5S_none_iter_has_next_block PURPOSE Check if there is another block left in the current iterator USAGE htri_t H5S_none_iter_has_next_block(iter) const H5S_sel_iter_t *iter; IN: Pointer to selection iterator RETURNS Non-negative (TRUE/FALSE) on success/Negative on failure DESCRIPTION Check if there is another block available in the selection iterator. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static htri_t H5S_none_iter_has_next_block(const H5S_sel_iter_t UNUSED *iter) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_none_iter_has_next_block); /* Check args */ assert (iter); FUNC_LEAVE_NOAPI(FAIL); } /* H5S_none_iter_has_next_block() */ /*-------------------------------------------------------------------------- NAME H5S_none_iter_next PURPOSE Increment selection iterator USAGE herr_t H5S_none_iter_next(iter, nelem) H5S_sel_iter_t *iter; IN: Pointer to selection iterator size_t nelem; IN: Number of elements to advance by RETURNS Non-negative on success/Negative on failure DESCRIPTION Advance selection iterator to the NELEM'th next element in the selection. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_none_iter_next(H5S_sel_iter_t UNUSED *iter, size_t UNUSED nelem) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_none_iter_next); /* Check args */ assert (iter); assert (nelem>0); FUNC_LEAVE_NOAPI(SUCCEED); } /* H5S_none_iter_next() */ /*-------------------------------------------------------------------------- NAME H5S_none_iter_next_block PURPOSE Increment selection iterator to next block USAGE herr_t H5S_none_iter_next(iter) H5S_sel_iter_t *iter; IN: Pointer to selection iterator RETURNS Non-negative on success/Negative on failure DESCRIPTION Advance selection iterator to the next block in the selection. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_none_iter_next_block(H5S_sel_iter_t UNUSED *iter) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_none_iter_next); /* Check args */ assert (iter); FUNC_LEAVE_NOAPI(FAIL); } /* H5S_none_iter_next_block() */ /*-------------------------------------------------------------------------- NAME H5S_none_iter_release PURPOSE Release "none" selection iterator information for a dataspace USAGE herr_t H5S_none_iter_release(iter) H5S_sel_iter_t *iter; IN: Pointer to selection iterator RETURNS Non-negative on success/Negative on failure DESCRIPTION Releases all information for a dataspace "none" selection iterator GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_none_iter_release (H5S_sel_iter_t UNUSED * iter) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_none_iter_release); /* Check args */ assert (iter); FUNC_LEAVE_NOAPI(SUCCEED); } /* H5S_none_iter_release() */ /*-------------------------------------------------------------------------- NAME H5S_none_release PURPOSE Release none selection information for a dataspace USAGE herr_t H5S_none_release(space) H5S_t *space; IN: Pointer to dataspace RETURNS Non-negative on success/Negative on failure DESCRIPTION Releases "none" selection information for a dataspace GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_none_release (H5S_t UNUSED * space) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_none_release); /* Check args */ assert (space); FUNC_LEAVE_NOAPI(SUCCEED); } /* H5S_none_release() */ /*-------------------------------------------------------------------------- NAME H5S_none_copy PURPOSE Copy a selection from one dataspace to another USAGE herr_t H5S_none_copy(dst, src) H5S_t *dst; OUT: Pointer to the destination dataspace H5S_t *src; IN: Pointer to the source dataspace RETURNS Non-negative on success/Negative on failure DESCRIPTION Copies the 'none' selection information from the source dataspace to the destination dataspace. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_none_copy(H5S_t *dst, const H5S_t UNUSED *src, hbool_t UNUSED share_selection) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_none_copy); assert(src); assert(dst); /* Set number of elements in selection */ dst->select.num_elem=0; FUNC_LEAVE_NOAPI(SUCCEED); } /* end H5S_none_copy() */ /*-------------------------------------------------------------------------- NAME H5S_none_is_valid PURPOSE Check whether the selection fits within the extent, with the current offset defined. USAGE htri_t H5S_none_is_valid(space); H5S_t *space; IN: Dataspace pointer to query RETURNS TRUE if the selection fits within the extent, FALSE if it does not and Negative on an error. DESCRIPTION Determines if the current selection at the current offet fits within the extent for the dataspace. Offset is irrelevant for this type of selection. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static htri_t H5S_none_is_valid (const H5S_t UNUSED *space) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_none_is_valid); assert(space); FUNC_LEAVE_NOAPI(TRUE); } /* end H5S_none_is_valid() */ /*-------------------------------------------------------------------------- NAME H5S_none_serial_size PURPOSE Determine the number of bytes needed to store the serialized "none" selection information. USAGE hssize_t H5S_none_serial_size(space) H5S_t *space; IN: Dataspace pointer to query RETURNS The number of bytes required on success, negative on an error. DESCRIPTION Determines the number of bytes required to serialize an "none" selection for storage on disk. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static hssize_t H5S_none_serial_size (const H5S_t UNUSED *space) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_none_serial_size); assert(space); /* Basic number of bytes required to serialize point selection: * + + + * = 16 bytes */ FUNC_LEAVE_NOAPI(16); } /* end H5S_none_serial_size() */ /*-------------------------------------------------------------------------- NAME H5S_none_serialize PURPOSE Serialize the current selection into a user-provided buffer. USAGE herr_t H5S_none_serialize(space, buf) H5S_t *space; IN: Dataspace pointer of selection to serialize uint8 *buf; OUT: Buffer to put serialized selection into RETURNS Non-negative on success/Negative on failure DESCRIPTION Serializes the current element selection into a buffer. (Primarily for storing on disk). GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_none_serialize (const H5S_t *space, uint8_t *buf) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_none_serialize); assert(space); /* Store the preamble information */ UINT32ENCODE(buf, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */ UINT32ENCODE(buf, (uint32_t)1); /* Store the version number */ UINT32ENCODE(buf, (uint32_t)0); /* Store the un-used padding */ UINT32ENCODE(buf, (uint32_t)0); /* Store the additional information length */ FUNC_LEAVE_NOAPI(SUCCEED); } /* H5S_none_serialize() */ /*-------------------------------------------------------------------------- NAME H5S_none_deserialize PURPOSE Deserialize the current selection from a user-provided buffer. USAGE herr_t H5S_none_deserialize(space, buf) H5S_t *space; IN/OUT: Dataspace pointer to place selection into uint8 *buf; IN: Buffer to retrieve serialized selection from RETURNS Non-negative on success/Negative on failure DESCRIPTION Deserializes the current selection into a buffer. (Primarily for retrieving from disk). GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_none_deserialize (H5S_t *space, const uint8_t UNUSED *buf) { herr_t ret_value; /* return value */ FUNC_ENTER_NOAPI_NOINIT(H5S_none_deserialize); assert(space); /* Change to "none" selection */ if((ret_value=H5S_select_none(space))<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection"); done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_none_deserialize() */ /*-------------------------------------------------------------------------- NAME H5S_none_bounds PURPOSE Gets the bounding box containing the selection. USAGE herr_t H5S_none_bounds(space, start, end) H5S_t *space; IN: Dataspace pointer of selection to query hsize_t *start; OUT: Starting coordinate of bounding box hsize_t *end; OUT: Opposite coordinate of bounding box RETURNS Non-negative on success, negative on failure DESCRIPTION Retrieves the bounding box containing the current selection and places it into the user's buffers. The start and end buffers must be large enough to hold the dataspace rank number of coordinates. The bounding box exactly contains the selection, ie. if a 2-D element selection is currently defined with the following points: (4,5), (6,8) (10,7), the bounding box with be (4, 5), (10, 8). Calling this function on a "none" selection returns fail. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_none_bounds(const H5S_t UNUSED *space, hsize_t UNUSED *start, hsize_t UNUSED *end) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_none_bounds); assert(space); assert(start); assert(end); FUNC_LEAVE_NOAPI(FAIL); } /* H5Sget_none_bounds() */ /*-------------------------------------------------------------------------- NAME H5S_none_is_contiguous PURPOSE Check if a "none" selection is contiguous within the dataspace extent. USAGE htri_t H5S_all_is_contiguous(space) H5S_t *space; IN: Dataspace pointer to check RETURNS TRUE/FALSE/FAIL DESCRIPTION Checks to see if the current selection in the dataspace is contiguous. This is primarily used for reading the entire selection in one swoop. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static htri_t H5S_none_is_contiguous(const H5S_t UNUSED *space) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_none_is_contiguous); assert(space); FUNC_LEAVE_NOAPI(FALSE); } /* H5S_none_is_contiguous() */ /*-------------------------------------------------------------------------- NAME H5S_none_is_single PURPOSE Check if a "none" selection is a single block within the dataspace extent. USAGE htri_t H5S_none_is_single(space) H5S_t *space; IN: Dataspace pointer to check RETURNS TRUE/FALSE/FAIL DESCRIPTION Checks to see if the current selection in the dataspace is a single block. This is primarily used for reading the entire selection in one swoop. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static htri_t H5S_none_is_single(const H5S_t UNUSED *space) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_none_is_single); assert(space); FUNC_LEAVE_NOAPI(FALSE); } /* H5S_none_is_single() */ /*-------------------------------------------------------------------------- NAME H5S_none_is_regular PURPOSE Check if a "none" selection is "regular" USAGE htri_t H5S_none_is_regular(space) const H5S_t *space; IN: Dataspace pointer to check RETURNS TRUE/FALSE/FAIL DESCRIPTION Checks to see if the current selection in a dataspace is the a regular pattern. This is primarily used for reading the entire selection in one swoop. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static htri_t H5S_none_is_regular(const H5S_t UNUSED *space) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_none_is_regular); /* Check args */ assert(space); FUNC_LEAVE_NOAPI(TRUE); } /* H5S_none_is_regular() */ /*-------------------------------------------------------------------------- NAME H5S_select_none PURPOSE Specify that nothing is selected in the extent USAGE herr_t H5S_select_none(dsid) hid_t dsid; IN: Dataspace ID of selection to modify RETURNS Non-negative on success/Negative on failure DESCRIPTION This function de-selects the entire extent for a dataspace. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5S_select_none (H5S_t *space) { herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_NOAPI(H5S_select_none, FAIL); /* Check args */ assert(space); /* Remove current selection first */ if(H5S_SELECT_RELEASE(space)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release hyperslab"); /* Set number of elements in selection */ space->select.num_elem=0; /* Set selection type */ space->select.type=H5S_sel_none; done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_select_none() */ /*-------------------------------------------------------------------------- NAME H5Sselect_none PURPOSE Specify that nothing is selected in the extent USAGE herr_t H5Sselect_none(dsid) hid_t dsid; IN: Dataspace ID of selection to modify RETURNS Non-negative on success/Negative on failure DESCRIPTION This function de-selects the entire extent for a dataspace. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5Sselect_none (hid_t spaceid) { H5S_t *space = NULL; /* Dataspace to modify selection of */ herr_t ret_value; /* return value */ FUNC_ENTER_API(H5Sselect_none, FAIL); /* Check args */ if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); /* Change to "none" selection */ if((ret_value=H5S_select_none(space))<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection"); done: FUNC_LEAVE_API(ret_value); } /* H5Sselect_none() */ /*-------------------------------------------------------------------------- NAME H5S_none_get_seq_list PURPOSE Create a list of offsets & lengths for a selection USAGE herr_t H5S_all_get_seq_list(space,flags,iter,maxseq,maxelem,nseq,nelem,off,len) H5S_t *space; IN: Dataspace containing selection to use. unsigned flags; IN: Flags for extra information about operation H5S_sel_iter_t *iter; IN/OUT: Selection iterator describing last position of interest in selection. size_t maxseq; IN: Maximum number of sequences to generate size_t maxelem; IN: Maximum number of elements to include in the generated sequences size_t *nseq; OUT: Actual number of sequences generated size_t *nelem; OUT: Actual number of elements in sequences generated hsize_t *off; OUT: Array of offsets size_t *len; OUT: Array of lengths RETURNS Non-negative on success/Negative on failure. DESCRIPTION Use the selection in the dataspace to generate a list of byte offsets and lengths for the region(s) selected. Start/Restart from the position in the ITER parameter. The number of sequences generated is limited by the MAXSEQ parameter and the number of sequences actually generated is stored in the NSEQ parameter. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_none_get_seq_list(const H5S_t UNUSED *space, unsigned UNUSED flags, H5S_sel_iter_t UNUSED *iter, size_t UNUSED maxseq, size_t UNUSED maxelem, size_t *nseq, size_t *nelem, hsize_t UNUSED *off, size_t UNUSED *len) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_none_get_seq_list); /* Check args */ assert(space); assert(iter); assert(maxseq>0); assert(maxelem>0); assert(nseq); assert(nelem); assert(off); assert(len); /* "none" selections don't generate sequences of bytes */ *nseq=0; /* They don't use any elements, either */ *nelem=0; FUNC_LEAVE_NOAPI(SUCCEED); } /* end H5S_all_get_seq_list() */ xdmf-3.0+git20160803/Utilities/hdf5/H5Gnode.c0000640000175000017500000017361213003006557020302 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*------------------------------------------------------------------------- * * Created: H5Gnode.c * Jun 26 1997 * Robb Matzke * * Purpose: Functions for handling symbol table nodes. A * symbol table node is a small collection of symbol * table entries. A B-tree usually points to the * symbol table nodes for any given symbol table. * *------------------------------------------------------------------------- */ #define H5G_PACKAGE /*suppress error about including H5Gpkg */ #define H5F_PACKAGE /*suppress error about including H5Fpkg */ /* Packages needed by this file... */ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* File access */ #include "H5FLprivate.h" /* Free Lists */ #include "H5Gpkg.h" /* Groups */ #include "H5HLprivate.h" /* Local Heaps */ #include "H5MFprivate.h" /* File memory management */ #include "H5MMprivate.h" /* Memory management */ /* Private typedefs */ /* * Each key field of the B-link tree that points to symbol table * nodes consists of this structure... */ typedef struct H5G_node_key_t { size_t offset; /*offset into heap for name */ } H5G_node_key_t; /* Private macros */ #define H5G_NODE_VERS 1 /*symbol table node version number */ #define H5G_NODE_SIZEOF_HDR(F) (H5G_NODE_SIZEOF_MAGIC + 4) /* PRIVATE PROTOTYPES */ static herr_t H5G_node_serialize(H5F_t *f, H5G_node_t *sym, size_t size, uint8_t *buf); static size_t H5G_node_size(const H5F_t *f); static herr_t H5G_node_shared_free(void *shared); /* Metadata cache callbacks */ static H5G_node_t *H5G_node_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_udata1, void *_udata2); static herr_t H5G_node_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5G_node_t *sym); static herr_t H5G_node_dest(H5F_t *f, H5G_node_t *sym); static herr_t H5G_node_clear(H5F_t *f, H5G_node_t *sym, hbool_t destroy); static herr_t H5G_compute_size(const H5F_t *f, const H5G_node_t *sym, size_t *size_ptr); /* B-tree callbacks */ static size_t H5G_node_sizeof_rkey(const H5F_t *f, const void *_udata); static H5RC_t *H5G_node_get_shared(const H5F_t *f, const void *_udata); static herr_t H5G_node_create(H5F_t *f, hid_t dxpl_id, H5B_ins_t op, void *_lt_key, void *_udata, void *_rt_key, haddr_t *addr_p/*out*/); static int H5G_node_cmp2(H5F_t *f, hid_t dxpl_id, void *_lt_key, void *_udata, void *_rt_key); static int H5G_node_cmp3(H5F_t *f, hid_t dxpl_id, void *_lt_key, void *_udata, void *_rt_key); static herr_t H5G_node_found(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_lt_key, void *_udata); static H5B_ins_t H5G_node_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key, hbool_t *lt_key_changed, void *_md_key, void *_udata, void *_rt_key, hbool_t *rt_key_changed, haddr_t *new_node_p/*out*/); static H5B_ins_t H5G_node_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *lt_key, hbool_t *lt_key_changed, void *udata, void *rt_key, hbool_t *rt_key_changed); static herr_t H5G_node_decode_key(const H5F_t *f, const H5B_t *bt, const uint8_t *raw, void *_key); static herr_t H5G_node_encode_key(const H5F_t *f, const H5B_t *bt, uint8_t *raw, void *_key); static herr_t H5G_node_debug_key(FILE *stream, H5F_t *f, hid_t dxpl_id, int indent, int fwidth, const void *key, const void *udata); /* H5G inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_SNODE[1] = {{ H5AC_SNODE_ID, (H5AC_load_func_t)H5G_node_load, (H5AC_flush_func_t)H5G_node_flush, (H5AC_dest_func_t)H5G_node_dest, (H5AC_clear_func_t)H5G_node_clear, (H5AC_size_func_t)H5G_compute_size, }}; /* H5G inherits B-tree like properties from H5B */ H5B_class_t H5B_SNODE[1] = {{ H5B_SNODE_ID, /*id */ sizeof(H5G_node_key_t), /*sizeof_nkey */ H5G_node_sizeof_rkey, /*get_sizeof_rkey */ H5G_node_get_shared, /*get_shared */ H5G_node_create, /*new */ H5G_node_cmp2, /*cmp2 */ H5G_node_cmp3, /*cmp3 */ H5G_node_found, /*found */ H5G_node_insert, /*insert */ TRUE, /*follow min branch? */ TRUE, /*follow max branch? */ H5G_node_remove, /*remove */ H5G_node_decode_key, /*decode */ H5G_node_encode_key, /*encode */ H5G_node_debug_key, /*debug */ }}; /* Declare a free list to manage the H5B_shared_t struct */ H5FL_EXTERN(H5B_shared_t); /* Declare a free list to manage the H5G_node_t struct */ H5FL_DEFINE_STATIC(H5G_node_t); /* Declare a free list to manage sequences of H5G_entry_t's */ H5FL_SEQ_DEFINE_STATIC(H5G_entry_t); /* Declare a free list to manage blocks of symbol node data */ H5FL_BLK_DEFINE_STATIC(symbol_node); /* Declare a free list to manage the native key offset sequence information */ H5FL_SEQ_DEFINE_STATIC(size_t); /* Declare a free list to manage the raw page information */ H5FL_BLK_DEFINE_STATIC(grp_page); /*------------------------------------------------------------------------- * Function: H5G_node_sizeof_rkey * * Purpose: Returns the size of a raw B-link tree key for the specified * file. * * Return: Success: Size of the key. * * Failure: never fails * * Programmer: Robb Matzke * matzke@llnl.gov * Jul 14 1997 * * Modifications: * *------------------------------------------------------------------------- */ static size_t H5G_node_sizeof_rkey(const H5F_t *f, const void UNUSED * udata) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_node_sizeof_rkey); FUNC_LEAVE_NOAPI(H5F_SIZEOF_SIZE(f)); /*the name offset */ } /*------------------------------------------------------------------------- * Function: H5G_node_get_shared * * Purpose: Returns the shared B-tree info for the specified UDATA. * * Return: Success: Pointer to the raw B-tree page for this file's groups * * Failure: Can't fail * * Programmer: Robb Matzke * Wednesday, October 8, 1997 * * Modifications: * *------------------------------------------------------------------------- */ static H5RC_t * H5G_node_get_shared(const H5F_t *f, const void UNUSED *_udata) { H5RC_t *rc; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_node_get_shared); assert(f); /* Increment reference count on shared B-tree node */ rc=H5F_GRP_BTREE_SHARED(f); H5RC_INC(rc); /* Return the pointer to the ref-count object */ FUNC_LEAVE_NOAPI(rc); } /* end H5G_node_get_shared() */ /*------------------------------------------------------------------------- * Function: H5G_node_decode_key * * Purpose: Decodes a raw key into a native key. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Jul 8 1997 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5G_node_decode_key(const H5F_t *f, const H5B_t UNUSED *bt, const uint8_t *raw, void *_key) { H5G_node_key_t *key = (H5G_node_key_t *) _key; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_node_decode_key); assert(f); assert(raw); assert(key); H5F_DECODE_LENGTH(f, raw, key->offset); FUNC_LEAVE_NOAPI(SUCCEED); } /*------------------------------------------------------------------------- * Function: H5G_node_encode_key * * Purpose: Encodes a native key into a raw key. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Jul 8 1997 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5G_node_encode_key(const H5F_t *f, const H5B_t UNUSED *bt, uint8_t *raw, void *_key) { H5G_node_key_t *key = (H5G_node_key_t *) _key; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_node_encode_key); assert(f); assert(raw); assert(key); H5F_ENCODE_LENGTH(f, raw, key->offset); FUNC_LEAVE_NOAPI(SUCCEED); } /*------------------------------------------------------------------------- * Function: H5G_node_debug_key * * Purpose: Prints a key. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Friday, February 28, 2003 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5G_node_debug_key (FILE *stream, H5F_t *f, hid_t dxpl_id, int indent, int fwidth, const void *_key, const void *_udata) { const H5G_node_key_t *key = (const H5G_node_key_t *) _key; const H5G_bt_ud0_t *udata = (const H5G_bt_ud0_t *) _udata; const H5HL_t *heap = NULL; const char *s; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5G_node_debug_key); assert (key); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Heap offset:", (unsigned)key->offset); HDfprintf(stream, "%*s%-*s ", indent, "", fwidth, "Name:"); if (NULL == (heap = H5HL_protect(f, dxpl_id, udata->heap_addr))) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to protect symbol name"); s = H5HL_offset_into(f, heap, key->offset); HDfprintf (stream, "%s\n", s); if (H5HL_unprotect(f, dxpl_id, heap, udata->heap_addr) < 0) HGOTO_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol name"); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_node_size * * Purpose: Returns the total size of a symbol table node. * * Return: Success: Total size of the node in bytes. * * Failure: Never fails. * * Programmer: Robb Matzke * matzke@llnl.gov * Jun 23 1997 * * Modifications: * *------------------------------------------------------------------------- */ static size_t H5G_node_size(const H5F_t *f) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_node_size); FUNC_LEAVE_NOAPI(H5G_NODE_SIZEOF_HDR(f) + (2 * H5F_SYM_LEAF_K(f)) * H5G_SIZEOF_ENTRY(f)); } /*------------------------------------------------------------------------- * Function: H5G_node_load * * Purpose: Loads a symbol table node from the file. * * Return: Success: Ptr to the new table. * * Failure: NULL * * Programmer: Robb Matzke * matzke@llnl.gov * Jun 23 1997 * * Modifications: * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. * * Quincey Koziol, 2002-7-180 * Added dxpl parameter to allow more control over I/O from metadata * cache. *------------------------------------------------------------------------- */ static H5G_node_t * H5G_node_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *_udata1, void UNUSED * _udata2) { H5G_node_t *sym = NULL; size_t size = 0; uint8_t *buf = NULL; const uint8_t *p = NULL; H5G_node_t *ret_value; /*for error handling */ FUNC_ENTER_NOAPI_NOINIT(H5G_node_load); /* * Check arguments. */ assert(f); assert(H5F_addr_defined(addr)); assert(!_udata1); assert(NULL == _udata2); /* * Initialize variables. */ size = H5G_node_size(f); if ((buf=H5FL_BLK_MALLOC(symbol_node,size))==NULL) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for symbol table node"); p=buf; if (NULL==(sym = H5FL_CALLOC(H5G_node_t)) || NULL==(sym->entry=H5FL_SEQ_CALLOC(H5G_entry_t,(2*H5F_SYM_LEAF_K(f))))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); if (H5F_block_read(f, H5FD_MEM_BTREE, addr, size, dxpl_id, buf) < 0) HGOTO_ERROR(H5E_SYM, H5E_READERROR, NULL, "unable to read symbol table node"); /* magic */ if (HDmemcmp(p, H5G_NODE_MAGIC, H5G_NODE_SIZEOF_MAGIC)) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, NULL, "bad symbol table node signature"); p += 4; /* version */ if (H5G_NODE_VERS != *p++) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, NULL, "bad symbol table node version"); /* reserved */ p++; /* number of symbols */ UINT16DECODE(p, sym->nsyms); /* entries */ if (H5G_ent_decode_vec(f, &p, sym->entry, sym->nsyms) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, NULL, "unable to decode symbol table entries"); /* Set return value */ ret_value = sym; done: if (buf) H5FL_BLK_FREE(symbol_node,buf); if (!ret_value) { if (sym) if(H5G_node_dest(f, sym)<0) HGOTO_ERROR(H5E_SYM, H5E_CANTFREE, NULL, "unable to destroy symbol table node"); } FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_node_flush * * Purpose: Flush a symbol table node to disk. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Jun 23 1997 * * Modifications: * rky, 1998-08-28 * Only p0 writes metadata to disk. * * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. * * Quincey Koziol, 2002-7-180 * Added dxpl parameter to allow more control over I/O from metadata * cache. * * Pedro Vicente, 18 Sep 2002 * Added `id to name' support. * *------------------------------------------------------------------------- */ static herr_t H5G_node_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5G_node_t *sym) { uint8_t *buf = NULL; size_t size; unsigned u; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5G_node_flush); /* * Check arguments. */ assert(f); assert(H5F_addr_defined(addr)); assert(sym); /* * Look for dirty entries and set the node dirty flag. */ for (u = 0; u < sym->nsyms; u++) if (sym->entry[u].dirty) { /* Set the node's dirty flag */ sym->cache_info.is_dirty = TRUE; /* Reset the entry's dirty flag */ sym->entry[u].dirty=FALSE; } /* end if */ /* * Write the symbol node to disk. */ if (sym->cache_info.is_dirty) { size = H5G_node_size(f); /* Allocate temporary buffer */ if ((buf=H5FL_BLK_MALLOC(symbol_node,size))==NULL) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); if (H5G_node_serialize(f, sym, size, buf) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSERIALIZE, FAIL, "node serialization failed"); if (H5F_block_write(f, H5FD_MEM_BTREE, addr, size, dxpl_id, buf) < 0) HGOTO_ERROR(H5E_SYM, H5E_WRITEERROR, FAIL, "unable to write symbol table node to the file"); H5FL_BLK_FREE(symbol_node,buf); /* Reset the node's dirty flag */ sym->cache_info.is_dirty = FALSE; } /* * Destroy the symbol node? This might happen if the node is being * preempted from the cache. */ if (destroy) { if(H5G_node_dest(f, sym)<0) HGOTO_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to destroy symbol table node"); } done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_node_serialize * * Purpose: Serialize the symbol table node * * Return: Non-negative on success/Negative on failure * * Programmer: Bill Wendling * wendling@ncsa.uiuc.edu * Sept. 16, 2003 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5G_node_serialize(H5F_t *f, H5G_node_t *sym, size_t size, uint8_t *buf) { uint8_t *p; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT(H5G_node_serialize); /* check args */ assert(f); assert(sym); assert(buf); p = buf; /* magic number */ HDmemcpy(p, H5G_NODE_MAGIC, H5G_NODE_SIZEOF_MAGIC); p += 4; /* version number */ *p++ = H5G_NODE_VERS; /* reserved */ *p++ = 0; /* number of symbols */ UINT16ENCODE(p, sym->nsyms); /* entries */ if (H5G_ent_encode_vec(f, &p, sym->entry, sym->nsyms) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "can't serialize") HDmemset(p, 0, size - (p - buf)); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_node_dest * * Purpose: Destroy a symbol table node in memory. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * Jan 15 2003 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5G_node_dest(H5F_t UNUSED *f, H5G_node_t *sym) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_node_dest); /* * Check arguments. */ assert(sym); /* Verify that node is clean */ assert (sym->cache_info.is_dirty==FALSE); if(sym->entry) sym->entry = H5FL_SEQ_FREE(H5G_entry_t,sym->entry); H5FL_FREE(H5G_node_t,sym); FUNC_LEAVE_NOAPI(SUCCEED); } /* end H5G_node_dest() */ /*------------------------------------------------------------------------- * Function: H5G_node_clear * * Purpose: Mark a symbol table node in memory as non-dirty. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * Mar 20 2003 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5G_node_clear(H5F_t *f, H5G_node_t *sym, hbool_t destroy) { unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT(H5G_node_clear); /* * Check arguments. */ assert(sym); /* Look for dirty entries and reset their dirty flag. */ for(u = 0; u < sym->nsyms; u++) sym->entry[u].dirty=FALSE; sym->cache_info.is_dirty = FALSE; /* * Destroy the symbol node? This might happen if the node is being * preempted from the cache. */ if (destroy) if (H5G_node_dest(f, sym) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to destroy symbol table node"); done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5G_node_clear() */ /*------------------------------------------------------------------------- * Function: H5G_compute_size * * Purpose: Compute the size in bytes of the specified instance of * H5G_node_t on disk, and return it in *size_ptr. On failure * the value of size_ptr is undefined. * * Return: Non-negative on success/Negative on failure * * Programmer: John Mainzer * 5/13/04 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5G_compute_size(const H5F_t *f, const H5G_node_t UNUSED *sym, size_t *size_ptr) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_compute_size); /* * Check arguments. */ assert(f); assert(size_ptr); *size_ptr = H5G_node_size(f); FUNC_LEAVE_NOAPI(SUCCEED); } /* H5G_compute_size() */ /*------------------------------------------------------------------------- * Function: H5G_node_create * * Purpose: Creates a new empty symbol table node. This function is * called by the B-tree insert function for an empty tree. It * is also called internally to split a symbol node with LT_KEY * and RT_KEY null pointers. * * Return: Success: Non-negative. The address of symbol table * node is returned through the ADDR_P argument. * * Failure: Negative * * Programmer: Robb Matzke * matzke@llnl.gov * Jun 23 1997 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5G_node_create(H5F_t *f, hid_t dxpl_id, H5B_ins_t UNUSED op, void *_lt_key, void UNUSED *_udata, void *_rt_key, haddr_t *addr_p/*out*/) { H5G_node_key_t *lt_key = (H5G_node_key_t *) _lt_key; H5G_node_key_t *rt_key = (H5G_node_key_t *) _rt_key; H5G_node_t *sym = NULL; hsize_t size = 0; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5G_node_create); /* * Check arguments. */ assert(f); assert(H5B_INS_FIRST == op); if (NULL==(sym = H5FL_CALLOC(H5G_node_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); size = H5G_node_size(f); if (HADDR_UNDEF==(*addr_p=H5MF_alloc(f, H5FD_MEM_BTREE, dxpl_id, size))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to allocate file space"); sym->cache_info.is_dirty = TRUE; sym->entry = H5FL_SEQ_CALLOC(H5G_entry_t,(2*H5F_SYM_LEAF_K(f))); if (NULL==sym->entry) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); if (H5AC_set(f, dxpl_id, H5AC_SNODE, *addr_p, sym) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to cache symbol table leaf node"); /* * The left and right symbols in an empty tree are both the * empty string stored at offset zero by the H5G functions. This * allows the comparison functions to work correctly without knowing * that there are no symbols. */ if (lt_key) lt_key->offset = 0; if (rt_key) rt_key->offset = 0; done: if(ret_value<0) { if(sym!=NULL) { if(sym->entry!=NULL) H5FL_SEQ_FREE(H5G_entry_t,sym->entry); H5FL_FREE(H5G_node_t,sym); } /* end if */ } /* end if */ FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_node_cmp2 * * Purpose: Compares two keys from a B-tree node (LT_KEY and RT_KEY). * The UDATA pointer supplies extra data not contained in the * keys (in this case, the heap address). * * Return: Success: negative if LT_KEY is less than RT_KEY. * * positive if LT_KEY is greater than RT_KEY. * * zero if LT_KEY and RT_KEY are equal. * * Failure: FAIL (same as LT_KEYheap_addr))) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to protect symbol name"); base = H5HL_offset_into(f, heap, 0); /* Get pointers to string names */ s1=base+lt_key->offset; s2=base+rt_key->offset; /* Set return value */ ret_value = HDstrcmp(s1, s2); done: if (heap && H5HL_unprotect(f, dxpl_id, heap, udata->heap_addr) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol name"); FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_node_cmp3 * * Purpose: Compares two keys from a B-tree node (LT_KEY and RT_KEY) * against another key (not necessarily the same type) * pointed to by UDATA. * * Return: Success: negative if the UDATA key is less than * or equal to the LT_KEY * * positive if the UDATA key is greater * than the RT_KEY. * * zero if the UDATA key falls between * the LT_KEY (exclusive) and the * RT_KEY (inclusive). * * Failure: FAIL (same as UDATA < LT_KEY) * * Programmer: Robb Matzke * matzke@llnl.gov * Jun 23 1997 * * Modifications: * *------------------------------------------------------------------------- */ static int H5G_node_cmp3(H5F_t *f, hid_t dxpl_id, void *_lt_key, void *_udata, void *_rt_key) { H5G_bt_ud0_t *udata = (H5G_bt_ud0_t *) _udata; H5G_node_key_t *lt_key = (H5G_node_key_t *) _lt_key; H5G_node_key_t *rt_key = (H5G_node_key_t *) _rt_key; const H5HL_t *heap = NULL; const char *s; const char *base; /* Base of heap */ int ret_value=0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5G_node_cmp3); /* Get base address of heap */ if (NULL == (heap = H5HL_protect(f, dxpl_id, udata->heap_addr))) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to protect symbol name"); base = H5HL_offset_into(f, heap, 0); /* left side */ s=base+lt_key->offset; if (HDstrcmp(udata->name, s) <= 0) HGOTO_DONE(-1); /* right side */ s=base+rt_key->offset; if (HDstrcmp(udata->name, s) > 0) HGOTO_DONE(1); done: if (heap && H5HL_unprotect(f, dxpl_id, heap, udata->heap_addr) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol name"); FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_node_found * * Purpose: The B-tree search engine has found the symbol table node * which contains the requested symbol if the symbol exists. * This function should examine that node for the symbol and * return information about the symbol through the UDATA * structure which contains the symbol name on function * entry. * * If the operation flag in UDATA is H5G_OPER_FIND, then * the entry is copied from the symbol table to the UDATA * entry field. Otherwise the entry is copied from the * UDATA entry field to the symbol table. * * Return: Success: Non-negative if found and data returned through * the UDATA pointer. * * Failure: Negative if not found. * * Programmer: Robb Matzke * matzke@llnl.gov * Jun 23 1997 * * Modifications: * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. *------------------------------------------------------------------------- */ static herr_t H5G_node_found(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *_lt_key, void *_udata) { H5G_bt_ud1_t *udata = (H5G_bt_ud1_t *) _udata; H5G_node_t *sn = NULL; const H5HL_t *heap = NULL; unsigned lt = 0, idx = 0, rt; int cmp = 1; const char *s; const char *base; /* Base of heap */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5G_node_found); /* * Check arguments. */ assert(f); assert(H5F_addr_defined(addr)); assert(udata); /* * Load the symbol table node for exclusive access. */ if (NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL, H5AC_READ))) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL, "unable to protect symbol table node"); /* Get base address of heap */ if (NULL == (heap = H5HL_protect(f, dxpl_id, udata->common.heap_addr))) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to protect symbol name"); base = H5HL_offset_into(f, heap, 0); /* * Binary search. */ rt = sn->nsyms; while (lt < rt && cmp) { idx = (lt + rt) / 2; s=base+sn->entry[idx].name_off; cmp = HDstrcmp(udata->common.name, s); if (cmp < 0) rt = idx; else lt = idx + 1; } if (H5HL_unprotect(f, dxpl_id, heap, udata->common.heap_addr) < 0) HGOTO_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol name"); heap=NULL; base=NULL; if (cmp) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "not found"); /* * The caller is querying the symbol entry, copy it into the UDATA * entry field. * * (do a NULL copy, since the entry's name will be constructed later) */ if (H5G_ent_copy(udata->ent, &sn->entry[idx], H5G_COPY_NULL)<0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to copy entry"); /* Leave object in same file as lookup occurs in */ /* If a file is opened through different H5Fopen() calls, the symbol * table entry from the B-tree lookup ("&sn->entry[idx]" above) will be * in the "first" file, but the lookup might occur in the second file. - QAK */ udata->ent->file = f; done: if (sn && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, FALSE) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to release symbol table node"); FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_node_insert * * Purpose: The B-tree insertion engine has found the symbol table node * which should receive the new symbol/address pair. This * function adds it to that node unless it already existed. * * If the node has no room for the symbol then the node is * split into two nodes. The original node contains the * low values and the new node contains the high values. * The new symbol table entry is added to either node as * appropriate. When a split occurs, this function will * write the maximum key of the low node to the MID buffer * and return the address of the new node. * * If the new key is larger than RIGHT then update RIGHT * with the new key. * * Return: Success: An insertion command for the caller, one of * the H5B_INS_* constants. The address of the * new node, if any, is returned through the * NEW_NODE_P argument. NEW_NODE_P might not be * initialized if the return value is * H5B_INS_NOOP. * * Failure: H5B_INS_ERROR, NEW_NODE_P might not be * initialized. * * Programmer: Robb Matzke * matzke@llnl.gov * Jun 24 1997 * * Modifications: * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. *------------------------------------------------------------------------- */ static H5B_ins_t H5G_node_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, void UNUSED *_lt_key, hbool_t UNUSED *lt_key_changed, void *_md_key, void *_udata, void *_rt_key, hbool_t *rt_key_changed, haddr_t *new_node_p) { H5G_node_key_t *md_key = (H5G_node_key_t *) _md_key; H5G_node_key_t *rt_key = (H5G_node_key_t *) _rt_key; H5G_bt_ud1_t *udata = (H5G_bt_ud1_t *) _udata; H5G_node_t *sn = NULL, *snrt = NULL; const H5HL_t *heap = NULL; size_t offset; /*offset of name in heap */ const char *s; const char *base; /* Base of heap */ unsigned lt = 0, rt; /* Binary search cntrs */ int cmp = 1, idx = -1; H5G_node_t *insert_into = NULL; /*node that gets new entry*/ H5B_ins_t ret_value = H5B_INS_ERROR; FUNC_ENTER_NOAPI_NOINIT(H5G_node_insert); /* * Check arguments. */ assert(f); assert(H5F_addr_defined(addr)); assert(md_key); assert(rt_key); assert(udata); assert(new_node_p); /* * Load the symbol node. */ if (NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL, H5AC_WRITE))) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_INS_ERROR, "unable to protect symbol table node"); /* Get base address of heap */ if (NULL == (heap = H5HL_protect(f, dxpl_id, udata->common.heap_addr))) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_INS_ERROR, "unable to protect symbol name"); base = H5HL_offset_into(f, heap, 0); /* * Where does the new symbol get inserted? We use a binary search. */ rt = sn->nsyms; while (lt < rt) { idx = (lt + rt) / 2; s=base+sn->entry[idx].name_off; if (0 == (cmp = HDstrcmp(udata->common.name, s))) /*already present */ { HCOMMON_ERROR(H5E_SYM, H5E_CANTINSERT, "symbol is already present in symbol table"); if (H5HL_unprotect(f, dxpl_id, heap, udata->common.heap_addr) < 0) HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to unprotect symbol name"); heap=NULL; base=NULL; HGOTO_DONE(H5B_INS_ERROR); } if (cmp < 0) rt = idx; else lt = idx + 1; } idx += cmp > 0 ? 1 : 0; if (H5HL_unprotect(f, dxpl_id, heap, udata->common.heap_addr) < 0) HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to unprotect symbol name"); heap=NULL; base=NULL; /* * Add the new name to the heap. */ offset = H5HL_insert(f, dxpl_id, udata->common.heap_addr, HDstrlen(udata->common.name)+1, udata->common.name); udata->ent->name_off = offset; if (0==offset || (size_t)(-1)==offset) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, H5B_INS_ERROR, "unable to insert symbol name into heap"); if (sn->nsyms >= 2*H5F_SYM_LEAF_K(f)) { /* * The node is full. Split it into a left and right * node and return the address of the new right node (the * left node is at the same address as the original node). */ ret_value = H5B_INS_RIGHT; /* The right node */ if (H5G_node_create(f, dxpl_id, H5B_INS_FIRST, NULL, NULL, NULL, new_node_p/*out*/)<0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5B_INS_ERROR, "unable to split symbol table node"); if (NULL == (snrt = H5AC_protect(f, dxpl_id, H5AC_SNODE, *new_node_p, NULL, NULL, H5AC_WRITE))) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_INS_ERROR, "unable to split symbol table node"); HDmemcpy(snrt->entry, sn->entry + H5F_SYM_LEAF_K(f), H5F_SYM_LEAF_K(f) * sizeof(H5G_entry_t)); snrt->nsyms = H5F_SYM_LEAF_K(f); snrt->cache_info.is_dirty = TRUE; /* The left node */ HDmemset(sn->entry + H5F_SYM_LEAF_K(f), 0, H5F_SYM_LEAF_K(f) * sizeof(H5G_entry_t)); sn->nsyms = H5F_SYM_LEAF_K(f); sn->cache_info.is_dirty = TRUE; /* The middle key */ md_key->offset = sn->entry[sn->nsyms - 1].name_off; /* Where to insert the new entry? */ if (idx <= (int)H5F_SYM_LEAF_K(f)) { insert_into = sn; if (idx == (int)H5F_SYM_LEAF_K(f)) md_key->offset = offset; } else { idx -= H5F_SYM_LEAF_K(f); insert_into = snrt; if (idx == (int)H5F_SYM_LEAF_K (f)) { rt_key->offset = offset; *rt_key_changed = TRUE; } } } else { /* Where to insert the new entry? */ ret_value = H5B_INS_NOOP; sn->cache_info.is_dirty = TRUE; insert_into = sn; if (idx == (int)sn->nsyms) { rt_key->offset = offset; *rt_key_changed = TRUE; } } /* Move entries down to make room for new entry */ HDmemmove(insert_into->entry + idx + 1, insert_into->entry + idx, (insert_into->nsyms - idx) * sizeof(H5G_entry_t)); /* Copy new entry into table */ /* (use H5G_COPY_NULL because we don't track the object names in the table) */ H5G_ent_copy(&(insert_into->entry[idx]), udata->ent, H5G_COPY_NULL); /* Flag entry as dirty */ insert_into->entry[idx].dirty = TRUE; /* Increment # of symbols in table */ insert_into->nsyms += 1; done: if (snrt && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, *new_node_p, snrt, FALSE) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to release symbol table node"); if (sn && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, FALSE) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to release symbol table node"); FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_node_remove * * Purpose: The B-tree removal engine has found the symbol table node * which should contain the name which is being removed. This * function removes the name from the symbol table and * decrements the link count on the object to which the name * points. * * If the udata->name parameter is set to NULL, then remove * all entries in this symbol table node. This only occurs * during the deletion of the entire group, so don't bother * freeing individual name entries in the local heap, the group's * symbol table removal code will just free the entire local * heap eventually. Do reduce the link counts for each object * however. * * Return: Success: If all names are removed from the symbol * table node then H5B_INS_REMOVE is returned; * otherwise H5B_INS_NOOP is returned. * * Failure: H5B_INS_ERROR * * Programmer: Robb Matzke * Thursday, September 24, 1998 * * Modifications: * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. * * Pedro Vicente, 18 Sep 2002 * Added `id to name' support. * * Quincey Koziol, 2003-03-22 * Added support for deleting all the entries at once. * *------------------------------------------------------------------------- */ static H5B_ins_t H5G_node_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key/*in,out*/, hbool_t UNUSED *lt_key_changed/*out*/, void *_udata/*in,out*/, void *_rt_key/*in,out*/, hbool_t *rt_key_changed/*out*/) { H5G_node_key_t *lt_key = (H5G_node_key_t *)_lt_key; H5G_node_key_t *rt_key = (H5G_node_key_t *)_rt_key; H5G_bt_ud2_t *udata = (H5G_bt_ud2_t *)_udata; H5G_node_t *sn = NULL; const H5HL_t *heap = NULL; unsigned lt=0, rt, idx=0; int cmp=1; const char *s = NULL; const char *base; /* Base of heap */ H5B_ins_t ret_value = H5B_INS_ERROR; FUNC_ENTER_NOAPI_NOINIT(H5G_node_remove); /* Check arguments */ assert(f); assert(H5F_addr_defined(addr)); assert(lt_key); assert(rt_key); assert(udata); /* Load the symbol table */ if (NULL==(sn=H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL, H5AC_WRITE))) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_INS_ERROR, "unable to protect symbol table node"); /* "Normal" removal of a single entry from the symbol table node */ if(udata->common.name!=NULL) { size_t len=0; hbool_t found; /* Indicate that the string was found */ /* Get base address of heap */ if (NULL == (heap = H5HL_protect(f, dxpl_id, udata->common.heap_addr))) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_INS_ERROR, "unable to protect symbol name"); base = H5HL_offset_into(f, heap, 0); /* Find the name with a binary search */ rt = sn->nsyms; while (ltentry[idx].name_off; cmp = HDstrcmp(udata->common.name, s); if (cmp<0) { rt = idx; } else { lt = idx+1; } } if (H5HL_unprotect(f, dxpl_id, heap, udata->common.heap_addr) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to unprotect symbol name"); heap=NULL; base=NULL; if (cmp) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_INS_ERROR, "not found"); if (H5G_CACHED_SLINK==sn->entry[idx].type) { /* Remove the symbolic link value */ if (NULL == (heap = H5HL_protect(f, dxpl_id, udata->common.heap_addr))) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_INS_ERROR, "unable to protect symbol name"); s = H5HL_offset_into(f, heap, sn->entry[idx].cache.slink.lval_offset); if (s) { len=HDstrlen(s)+1; found=1; } /* end if */ else found=0; if (H5HL_unprotect(f, dxpl_id, heap, udata->common.heap_addr) < 0) HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to unprotect symbol name"); heap=NULL; s=NULL; if (found) H5HL_remove(f, dxpl_id, udata->common.heap_addr, sn->entry[idx].cache.slink.lval_offset, len); H5E_clear(); /* no big deal */ } else { /* Decrement the reference count, if requested */ if(udata->adj_link) { HDassert(H5F_addr_defined(sn->entry[idx].header)); if (H5O_link(sn->entry+idx, -1, dxpl_id)<0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5B_INS_ERROR, "unable to decrement object link count") } /* end if */ } /* Remove the name from the local heap */ if (NULL == (heap = H5HL_protect(f, dxpl_id, udata->common.heap_addr))) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_INS_ERROR, "unable to protect symbol name"); s = H5HL_offset_into(f, heap, sn->entry[idx].name_off); if (s) { len=HDstrlen(s)+1; found=1; } /* end if */ else found=0; if (H5HL_unprotect(f, dxpl_id, heap, udata->common.heap_addr) < 0) HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to unprotect symbol name"); heap=NULL; s=NULL; if (found) H5HL_remove(f, dxpl_id, udata->common.heap_addr, sn->entry[idx].name_off, len); H5E_clear(); /* no big deal */ /* Remove the entry from the symbol table node */ if(1==sn->nsyms) { /* * We are about to remove the only symbol in this node. Copy the left * key to the right key and mark the right key as dirty. Free this * node and indicate that the pointer to this node in the B-tree * should be removed also. */ assert(0==idx); *rt_key = *lt_key; *rt_key_changed = TRUE; sn->nsyms = 0; sn->cache_info.is_dirty = TRUE; if (H5MF_xfree(f, H5FD_MEM_BTREE, dxpl_id, addr, (hsize_t)H5G_node_size(f))<0 || H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, TRUE)<0) { sn = NULL; HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to free symbol table node"); } sn = NULL; ret_value = H5B_INS_REMOVE; } else if (0==idx) { /* * We are about to remove the left-most entry from the symbol table * node but there are other entries to the right. No key values * change. */ sn->nsyms -= 1; sn->cache_info.is_dirty = TRUE; HDmemmove(sn->entry+idx, sn->entry+idx+1, (sn->nsyms-idx)*sizeof(H5G_entry_t)); ret_value = H5B_INS_NOOP; } else if (idx+1==sn->nsyms) { /* * We are about to remove the right-most entry from the symbol table * node but there are other entries to the left. The right key * should be changed to reflect the new right-most entry. */ sn->nsyms -= 1; sn->cache_info.is_dirty = TRUE; rt_key->offset = sn->entry[sn->nsyms-1].name_off; *rt_key_changed = TRUE; ret_value = H5B_INS_NOOP; } else { /* * We are about to remove an entry from the middle of a symbol table * node. */ sn->nsyms -= 1; sn->cache_info.is_dirty = TRUE; HDmemmove(sn->entry+idx, sn->entry+idx+1, (sn->nsyms-idx)*sizeof(H5G_entry_t)); ret_value = H5B_INS_NOOP; } } /* end if */ /* Remove all entries from node, during B-tree deletion */ else { /* Reduce the link count for all entries in this node */ for(idx=0; idxnsyms; idx++) { if (H5G_CACHED_SLINK!=sn->entry[idx].type) { /* Decrement the reference count, if requested */ if(udata->adj_link) { HDassert(H5F_addr_defined(sn->entry[idx].header)); if (H5O_link(sn->entry+idx, -1, dxpl_id)<0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, H5B_INS_ERROR, "unable to decrement object link count") } /* end if */ } /* end if */ } /* end for */ /* * We are about to remove all the symbols in this node. Copy the left * key to the right key and mark the right key as dirty. Free this * node and indicate that the pointer to this node in the B-tree * should be removed also. */ *rt_key = *lt_key; *rt_key_changed = TRUE; sn->nsyms = 0; sn->cache_info.is_dirty = TRUE; if (H5MF_xfree(f, H5FD_MEM_BTREE, dxpl_id, addr, (hsize_t)H5G_node_size(f))<0 || H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, TRUE)<0) { sn = NULL; HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to free symbol table node"); } sn = NULL; ret_value = H5B_INS_REMOVE; } /* end else */ done: if (sn && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, FALSE)<0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to release symbol table node"); FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_node_iterate * * Purpose: This function gets called during a group iterate operation. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Jun 24 1997 * * Modifications: * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. * * Quincey Koziol, 2002-04-22 * Changed to callback from H5B_iterate *------------------------------------------------------------------------- */ int H5G_node_iterate (H5F_t *f, hid_t dxpl_id, const void UNUSED *_lt_key, haddr_t addr, const void UNUSED *_rt_key, void *_udata) { H5G_bt_it_ud1_t *udata = (H5G_bt_it_ud1_t *)_udata; H5G_node_t *sn = NULL; const H5HL_t *heap = NULL; unsigned nsyms; /* # of symbols in node */ size_t n, *name_off=NULL; const char *name; char buf[1024], *s; unsigned u; /* Local index variable */ int ret_value; FUNC_ENTER_NOAPI(H5G_node_iterate, H5B_ITER_ERROR); /* * Check arguments. */ assert(f); assert(H5F_addr_defined(addr)); assert(udata); /* * Save information about the symbol table node since we can't lock it * because we're about to call an application function. */ if (NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL, H5AC_READ))) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_ITER_ERROR, "unable to load symbol table node"); nsyms = sn->nsyms; if (NULL==(name_off = H5FL_SEQ_MALLOC(size_t, (size_t)nsyms))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, H5B_ITER_ERROR, "memory allocation failed"); for(u = 0; u < nsyms; u++) name_off[u] = sn->entry[u].name_off; if (H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, FALSE) != SUCCEED) { sn = NULL; HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_ITER_ERROR, "unable to release object header"); } sn=NULL; /* Make certain future references will be caught */ /* * Iterate over the symbol table node entries. */ for(u = 0, ret_value = H5B_ITER_CONT; u < nsyms && !ret_value; u++) { if (udata->skip>0) { --udata->skip; } else { if (NULL == (heap = H5HL_protect(f, dxpl_id, udata->heap_addr))) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_ITER_ERROR, "unable to protect symbol name"); name = H5HL_offset_into(f, heap, name_off[u]); assert (name); n = HDstrlen (name); if (n+1>sizeof(buf)) { if (NULL==(s = H5MM_malloc (n+1))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, H5B_ITER_ERROR, "memory allocation failed"); } else { s = buf; } HDstrcpy (s, name); if (H5HL_unprotect(f, dxpl_id, heap, udata->heap_addr) < 0) HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_ITER_ERROR, "unable to unprotect symbol name"); heap=NULL; name=NULL; ret_value = (udata->op)(udata->group_id, s, udata->op_data); if (s!=buf) H5MM_xfree (s); } /* Increment the number of entries passed through */ /* (whether we skipped them or not) */ udata->final_ent++; } if (ret_value<0) HERROR (H5E_SYM, H5E_CANTNEXT, "iteration operator failed"); done: if (heap && H5HL_unprotect(f, dxpl_id, heap, udata->heap_addr) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_ITER_ERROR, "unable to unprotect symbol name"); if (sn && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, FALSE) != SUCCEED) HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_ITER_ERROR, "unable to release object header"); if(name_off) H5FL_SEQ_FREE(size_t,name_off); FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_node_sumup * * Purpose: This function gets called during a group iterate operation * to return total number of members in the group. * * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu * Nov 20, 2002 * * Modifications: * *------------------------------------------------------------------------- */ int H5G_node_sumup(H5F_t *f, hid_t dxpl_id, const void UNUSED *_lt_key, haddr_t addr, const void UNUSED *_rt_key, void *_udata) { hsize_t *num_objs = (hsize_t *)_udata; H5G_node_t *sn = NULL; int ret_value = H5B_ITER_CONT; FUNC_ENTER_NOAPI(H5G_node_sumup, H5B_ITER_ERROR); /* * Check arguments. */ assert(f); assert(H5F_addr_defined(addr)); assert(num_objs); /* Find the object node and add the number of symbol entries. */ if (NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL, H5AC_READ))) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_ITER_ERROR, "unable to load symbol table node"); *num_objs += sn->nsyms; done: if (sn && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, FALSE) != SUCCEED) HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_ITER_ERROR, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_node_name * * Purpose: This function gets called during a group iterate operation * to return object name by giving idx. * * Return: 0 if object isn't found in this node; 1 if object is found; * Negative on failure * * Programmer: Raymond Lu * Nov 20, 2002 * * Modifications: * *------------------------------------------------------------------------- */ int H5G_node_name(H5F_t *f, hid_t dxpl_id, const void UNUSED *_lt_key, haddr_t addr, const void UNUSED *_rt_key, void *_udata) { H5G_bt_it_ud2_t *udata = (H5G_bt_it_ud2_t *)_udata; const H5HL_t *heap = NULL; size_t name_off; hsize_t loc_idx; const char *name; H5G_node_t *sn = NULL; int ret_value = H5B_ITER_CONT; FUNC_ENTER_NOAPI(H5G_node_name, H5B_ITER_ERROR); /* * Check arguments. */ assert(f); assert(H5F_addr_defined(addr)); assert(udata); if (NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL, H5AC_READ))) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_ITER_ERROR, "unable to load symbol table node"); /* Find the node, locate the object symbol table entry and retrieve the name */ if(udata->idx >= udata->num_objs && udata->idx < (udata->num_objs + sn->nsyms)) { loc_idx = udata->idx - udata->num_objs; name_off = sn->entry[loc_idx].name_off; if (NULL == (heap = H5HL_protect(f, dxpl_id, udata->heap_addr))) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_ITER_ERROR, "unable to protect symbol name"); name = H5HL_offset_into(f, heap, name_off); assert (name); udata->name = H5MM_strdup (name); assert(udata->name); if (H5HL_unprotect(f, dxpl_id, heap, udata->heap_addr) < 0) HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_ITER_ERROR, "unable to unprotect symbol name"); heap=NULL; name=NULL; ret_value = H5B_ITER_STOP; } else { udata->num_objs += sn->nsyms; } done: if (sn && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, FALSE) != SUCCEED) HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_ITER_ERROR, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_node_type * * Purpose: This function gets called during a group iterate operation * to return object type by given idx. * * Return: 0 if object isn't found in this node; 1 if found; * Negative on failure * * Programmer: Raymond Lu * Nov 20, 2002 * * *------------------------------------------------------------------------- */ int H5G_node_type(H5F_t *f, hid_t dxpl_id, const void UNUSED *_lt_key, haddr_t addr, const void UNUSED *_rt_key, void *_udata) { H5G_bt_it_ud3_t *udata = (H5G_bt_it_ud3_t*)_udata; hsize_t loc_idx; H5G_node_t *sn = NULL; int ret_value = H5B_ITER_CONT; FUNC_ENTER_NOAPI(H5G_node_type, H5B_ITER_ERROR); /* Check arguments. */ assert(f); assert(H5F_addr_defined(addr)); assert(udata); /* Find the node, locate the object symbol table entry and retrieve the type */ if (NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL, H5AC_READ))) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_ITER_ERROR, "unable to load symbol table node"); if(udata->idx >= udata->num_objs && udata->idx < (udata->num_objs + sn->nsyms)) { loc_idx = udata->idx - udata->num_objs; udata->type = H5G_get_type(&(sn->entry[loc_idx]), dxpl_id); ret_value = H5B_ITER_STOP; } else { udata->num_objs += sn->nsyms; } done: if (sn && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, FALSE) != SUCCEED) HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_ITER_ERROR, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_node_init * * Purpose: This function gets called during a file opening to initialize * global information about group B-tree nodes for file. * * Return: Non-negative on success * Negative on failure * * Programmer: Quincey Koziol * Jul 5, 2004 * *------------------------------------------------------------------------- */ herr_t H5G_node_init(H5F_t *f) { H5B_shared_t *shared; /* Shared B-tree node info */ size_t u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5G_node_init, FAIL); /* Check arguments. */ assert(f); /* Allocate space for the shared structure */ if(NULL==(shared=H5FL_MALLOC(H5B_shared_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for shared B-tree info") /* Set up the "global" information for this file's groups */ shared->type= H5B_SNODE; shared->two_k=2*H5F_KVALUE(f,H5B_SNODE); shared->sizeof_rkey = H5G_node_sizeof_rkey(f, NULL); assert(shared->sizeof_rkey); shared->sizeof_rnode = H5B_nodesize(f, shared, &shared->sizeof_keys); assert(shared->sizeof_rnode); if(NULL==(shared->page=H5FL_BLK_MALLOC(grp_page,shared->sizeof_rnode))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree page") #ifdef H5_USING_PURIFY HDmemset(shared->page,0,shared->sizeof_rnode); #endif /* H5_USING_PURIFY */ if(NULL==(shared->nkey=H5FL_SEQ_MALLOC(size_t,(size_t)(2*H5F_KVALUE(f,H5B_SNODE)+1)))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree page") /* Initialize the offsets into the native key buffer */ for(u=0; u<(2*H5F_KVALUE(f,H5B_SNODE)+1); u++) shared->nkey[u]=u*H5B_SNODE->sizeof_nkey; /* Make shared B-tree info reference counted */ if(NULL==(f->shared->grp_btree_shared=H5RC_create(shared,H5G_node_shared_free))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't create ref-count wrapper for shared B-tree info") done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5G_node_init() */ /*------------------------------------------------------------------------- * Function: H5G_node_close * * Purpose: This function gets called during a file close to shutdown * global information about group B-tree nodes for file. * * Return: Non-negative on success * Negative on failure * * Programmer: Quincey Koziol * Jul 5, 2004 * * *------------------------------------------------------------------------- */ herr_t H5G_node_close(const H5F_t *f) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_node_close) /* Check arguments. */ assert(f); /* Free the raw B-tree node buffer */ if (H5F_GRP_BTREE_SHARED(f)) H5RC_DEC(H5F_GRP_BTREE_SHARED(f)); FUNC_LEAVE_NOAPI(SUCCEED); } /* end H5G_node_close */ /*------------------------------------------------------------------------- * Function: H5G_node_shared_free * * Purpose: Free B-tree shared info * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Thursday, July 8, 2004 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5G_node_shared_free (void *_shared) { H5B_shared_t *shared = (H5B_shared_t *)_shared; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_node_shared_free) /* Free the raw B-tree node buffer */ H5FL_BLK_FREE(grp_page,shared->page); /* Free the B-tree native key offsets buffer */ H5FL_SEQ_FREE(size_t,shared->nkey); /* Free the shared B-tree info */ H5FL_FREE(H5B_shared_t,shared); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5G_node_shared_free() */ /*------------------------------------------------------------------------- * Function: H5G_node_debug * * Purpose: Prints debugging information about a symbol table node * or a B-tree node for a symbol table B-tree. * * Return: 0(zero) on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 4 1997 * * Modifications: * Robb Matzke, 1999-07-28 * The ADDR and HEAP arguments are passed by value. *------------------------------------------------------------------------- */ herr_t H5G_node_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, int fwidth, haddr_t heap) { H5G_node_t *sn = NULL; const char *s; const H5HL_t *heap_ptr = NULL; unsigned u; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5G_node_debug, FAIL); /* * Check arguments. */ assert(f); assert(H5F_addr_defined(addr)); assert(stream); assert(indent >= 0); assert(fwidth >= 0); /* * If we couldn't load the symbol table node, then try loading the * B-tree node. */ if (NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL, H5AC_READ))) { H5G_bt_ud0_t udata; /*data to pass through B-tree */ H5E_clear(); /*discard that error */ udata.heap_addr = heap; if ( H5B_debug(f, dxpl_id, addr, stream, indent, fwidth, H5B_SNODE, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL, "unable to debug B-tree node"); HGOTO_DONE(SUCCEED); } fprintf(stream, "%*sSymbol Table Node...\n", indent, ""); fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Dirty:", sn->cache_info.is_dirty ? "Yes" : "No"); fprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Size of Node (in bytes):", (unsigned)H5G_node_size(f)); fprintf(stream, "%*s%-*s %u of %u\n", indent, "", fwidth, "Number of Symbols:", sn->nsyms, (unsigned)(2 * H5F_SYM_LEAF_K(f))); indent += 3; fwidth = MAX(0, fwidth - 3); for (u = 0; u < sn->nsyms; u++) { fprintf(stream, "%*sSymbol %u:\n", indent - 3, "", u); if (heap>0 && H5F_addr_defined(heap)) { if (NULL == (heap_ptr = H5HL_protect(f, dxpl_id, heap))) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to protect symbol name"); s = H5HL_offset_into(f, heap_ptr, sn->entry[u].name_off); if (s) fprintf(stream, "%*s%-*s `%s'\n", indent, "", fwidth, "Name:", s); if (H5HL_unprotect(f, dxpl_id, heap_ptr, heap) < 0) HGOTO_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol name"); heap_ptr=NULL; s=NULL; } else fprintf(stream, "%*s%-*s\n", indent, "", fwidth, "Warning: Invalid heap address given, name not displayed!"); H5G_ent_debug(f, dxpl_id, sn->entry + u, stream, indent, fwidth, heap); } done: if (sn && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, FALSE) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to release symbol table node"); FUNC_LEAVE_NOAPI(ret_value); } xdmf-3.0+git20160803/Utilities/hdf5/H5Zdeflate.c0000640000175000017500000001575513003006557021007 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Robb Matzke * Friday, August 27, 1999 */ #define H5Z_PACKAGE /*suppress error about including H5Zpkg */ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5MMprivate.h" /* Memory management */ #include "H5Zpkg.h" /* Data filters */ #ifdef H5_HAVE_FILTER_DEFLATE #ifdef H5_HAVE_ZLIB_H # include "hdf5_zlib.h" #endif /* Local function prototypes */ static size_t H5Z_filter_deflate (unsigned flags, size_t cd_nelmts, const unsigned cd_values[], size_t nbytes, size_t *buf_size, void **buf); /* This message derives from H5Z */ const H5Z_class_t H5Z_DEFLATE[1] = {{ H5Z_FILTER_DEFLATE, /* Filter id number */ "deflate", /* Filter name for debugging */ NULL, /* The "can apply" callback */ NULL, /* The "set local" callback */ H5Z_filter_deflate, /* The actual filter function */ }}; #define H5Z_DEFLATE_SIZE_ADJUST(s) (HDceil(((double)(s))*1.001)+12) /*------------------------------------------------------------------------- * Function: H5Z_filter_deflate * * Purpose: Implement an I/O filter around the 'deflate' algorithm in * libz * * Return: Success: Size of buffer filtered * Failure: 0 * * Programmer: Robb Matzke * Thursday, April 16, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static size_t H5Z_filter_deflate (unsigned flags, size_t cd_nelmts, const unsigned cd_values[], size_t nbytes, size_t *buf_size, void **buf) { void *outbuf = NULL; /* Pointer to new buffer */ int status; /* Status from zlib operation */ size_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5Z_filter_deflate, 0) /* Check arguments */ if (cd_nelmts!=1 || cd_values[0]>9) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid deflate aggression level") if (flags & H5Z_FLAG_REVERSE) { /* Input; uncompress */ z_stream z_strm; /* zlib parameters */ size_t nalloc = *buf_size; /* Number of bytes for output (compressed) buffer */ /* Allocate space for the compressed buffer */ if (NULL==(outbuf = H5MM_malloc(nalloc))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed for deflate uncompression") /* Set the uncompression parameters */ HDmemset(&z_strm, 0, sizeof(z_strm)); z_strm.next_in = *buf; H5_ASSIGN_OVERFLOW(z_strm.avail_in,nbytes,size_t,uInt); z_strm.next_out = outbuf; H5_ASSIGN_OVERFLOW(z_strm.avail_out,nalloc,size_t,uInt); /* Initialize the uncompression routines */ if (Z_OK!=inflateInit(&z_strm)) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, 0, "inflateInit() failed") /* Loop to uncompress the buffer */ do { /* Uncompress some data */ status = inflate(&z_strm, Z_SYNC_FLUSH); /* Check if we are done uncompressing data */ if (Z_STREAM_END==status) break; /*done*/ /* Check for error */ if (Z_OK!=status) { (void)inflateEnd(&z_strm); HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, 0, "inflate() failed") } else { /* If we're not done and just ran out of buffer space, get more */ if (0==z_strm.avail_out) { /* Allocate a buffer twice as big */ nalloc *= 2; if (NULL==(outbuf = H5MM_realloc(outbuf, nalloc))) { (void)inflateEnd(&z_strm); HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed for deflate uncompression") } /* Update pointers to buffer for next set of uncompressed data */ z_strm.next_out = (unsigned char*)outbuf + z_strm.total_out; z_strm.avail_out = (uInt)(nalloc - z_strm.total_out); } } /* end else */ } while(status==Z_OK); /* Free the input buffer */ H5MM_xfree(*buf); /* Set return values */ *buf = outbuf; outbuf = NULL; *buf_size = nalloc; ret_value = z_strm.total_out; /* Finish uncompressing the stream */ (void)inflateEnd(&z_strm); } else { /* * Output; compress but fail if the result would be larger than the * input. The library doesn't provide in-place compression, so we * must allocate a separate buffer for the result. */ const Bytef *z_src = (const Bytef*)(*buf); Bytef *z_dst; /*destination buffer */ uLongf z_dst_nbytes = (uLongf)H5Z_DEFLATE_SIZE_ADJUST(nbytes); uLong z_src_nbytes = (uLong)nbytes; int aggression; /* Compression aggression setting */ /* Set the compression aggression level */ H5_ASSIGN_OVERFLOW(aggression,cd_values[0],unsigned,int); /* Allocate output (compressed) buffer */ if (NULL==(z_dst=outbuf=H5MM_malloc(z_dst_nbytes))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "unable to allocate deflate destination buffer") /* Perform compression from the source to the destination buffer */ status = compress2 (z_dst, &z_dst_nbytes, z_src, z_src_nbytes, aggression); /* Check for various zlib errors */ if (Z_BUF_ERROR==status) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, 0, "overflow") else if (Z_MEM_ERROR==status) HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, 0, "deflate memory error") else if (Z_OK!=status) HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, 0, "other deflate error") /* Successfully uncompressed the buffer */ else { /* Free the input buffer */ H5MM_xfree(*buf); /* Set return values */ *buf = outbuf; outbuf = NULL; *buf_size = nbytes; ret_value = z_dst_nbytes; } } done: if(outbuf) H5MM_xfree(outbuf); FUNC_LEAVE_NOAPI(ret_value) } #endif /* H5_HAVE_FILTER_DEFLATE */ xdmf-3.0+git20160803/Utilities/hdf5/H5Fsuper.c0000640000175000017500000006202513003006557020505 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #define H5F_PACKAGE /*suppress error about including H5Fpkg */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5F_init_super_interface /* Packages needed by this file... */ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* File access */ #include "H5FDprivate.h" /* File drivers */ #include "H5Iprivate.h" /* IDs */ #include "H5Pprivate.h" /* Property lists */ /* PRIVATE PROTOTYPES */ /*-------------------------------------------------------------------------- NAME H5F_init_super_interface -- Initialize interface-specific information USAGE herr_t H5T_init_super_interface() RETURNS Non-negative on success/Negative on failure DESCRIPTION Initializes any interface-specific data or routines. (Just calls H5F_init_iterface currently). --------------------------------------------------------------------------*/ static herr_t H5F_init_super_interface(void) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_init_super_interface) FUNC_LEAVE_NOAPI(H5F_init()) } /* H5F_init_super_interface() */ /*------------------------------------------------------------------------- * Function: H5F_read_superblock * * Purpose: Reads the superblock from the file or from the BUF. If * ADDR is a valid address, then it reads it from the file. * If not, then BUF must be non-NULL for it to read from the * BUF. * * Return: Success: SUCCEED * Failure: FAIL * * Programmer: Bill Wendling * wendling@ncsa.uiuc.edu * Sept 12, 2003 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5F_read_superblock(H5F_t *f, hid_t dxpl_id, H5G_entry_t *root_ent) { haddr_t stored_eoa; /*relative end-of-addr in file */ haddr_t eof; /*end of file address */ uint8_t *q; /*ptr into temp I/O buffer */ size_t sizeof_addr = 0; size_t sizeof_size = 0; const size_t fixed_size = 24; /*fixed sizeof superblock */ unsigned sym_leaf_k = 0; size_t variable_size; /*variable sizeof superblock */ unsigned btree_k[H5B_NUM_BTREE_ID]; /* B-tree internal node 'K' values */ H5F_file_t *shared = NULL; /* shared part of `file' */ H5FD_t *lf = NULL; /* file driver part of `shared' */ uint8_t *p; /* Temporary pointer into encoding buffers */ unsigned i; /* Index variable */ unsigned chksum; /* Checksum temporary variable */ size_t driver_size; /* Size of driver info block, in bytes */ char driver_name[9]; /* Name of driver, for driver info block */ unsigned super_vers; /* Super block version */ unsigned freespace_vers; /* Freespace info version */ unsigned obj_dir_vers; /* Object header info version */ unsigned share_head_vers; /* Shared header info version */ uint8_t buf[H5F_SUPERBLOCK_SIZE]; /* Local buffer */ H5P_genplist_t *c_plist; /* File creation property list */ herr_t ret_value = SUCCEED; /* Decoding */ FUNC_ENTER_NOAPI(H5F_read_superblock, FAIL) /* Short cuts */ shared = f->shared; lf = shared->lf; /* Get the shared file creation property list */ if (NULL == (c_plist = H5I_object(shared->fcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") /* Read the superblock if it hasn't been read before. */ if (HADDR_UNDEF == (shared->super_addr=H5F_locate_signature(lf,dxpl_id))) HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "unable to find file signature") if (H5FD_set_eoa(lf, shared->super_addr + fixed_size) < 0 || H5FD_read(lf, H5FD_MEM_SUPER, dxpl_id, shared->super_addr, fixed_size, buf) < 0) HGOTO_ERROR(H5E_FILE, H5E_READERROR, FAIL, "unable to read superblock") /* Signature, already checked */ p = buf + H5F_SIGNATURE_LEN; /* Superblock version */ super_vers = *p++; if (super_vers > HDF5_SUPERBLOCK_VERSION_MAX) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad superblock version number") if (H5P_set(c_plist, H5F_CRT_SUPER_VERS_NAME, &super_vers) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set superblock version") /* Freespace version */ freespace_vers = *p++; if (HDF5_FREESPACE_VERSION != freespace_vers) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad free space version number") if (H5P_set(c_plist, H5F_CRT_FREESPACE_VERS_NAME, &freespace_vers) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to free space version") /* Root group version number */ obj_dir_vers = *p++; if (HDF5_OBJECTDIR_VERSION != obj_dir_vers) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad object directory version number") if (H5P_set(c_plist, H5F_CRT_OBJ_DIR_VERS_NAME, &obj_dir_vers) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set object directory version") /* Skip over reserved byte */ p++; /* Shared header version number */ share_head_vers = *p++; if (HDF5_SHAREDHEADER_VERSION != share_head_vers) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad shared-header format version number") if (H5P_set(c_plist, H5F_CRT_SHARE_HEAD_VERS_NAME, &share_head_vers) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set shared-header format version") /* Size of file addresses */ sizeof_addr = *p++; if (sizeof_addr != 2 && sizeof_addr != 4 && sizeof_addr != 8 && sizeof_addr != 16 && sizeof_addr != 32) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad byte number in an address") if (H5P_set(c_plist, H5F_CRT_ADDR_BYTE_NUM_NAME,&sizeof_addr) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set byte number in an address") shared->sizeof_addr = sizeof_addr; /* Keep a local copy also */ /* Size of file sizes */ sizeof_size = *p++; if (sizeof_size != 2 && sizeof_size != 4 && sizeof_size != 8 && sizeof_size != 16 && sizeof_size != 32) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad byte number for object size") if (H5P_set(c_plist, H5F_CRT_OBJ_BYTE_NUM_NAME, &sizeof_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set byte number for object size") shared->sizeof_size = sizeof_size; /* Keep a local copy also */ /* Skip over reserved byte */ p++; /* Various B-tree sizes */ UINT16DECODE(p, sym_leaf_k); if (sym_leaf_k == 0) HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, FAIL, "bad symbol table leaf node 1/2 rank") if (H5P_set(c_plist, H5F_CRT_SYM_LEAF_NAME, &sym_leaf_k) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set rank for symbol table leaf nodes") shared->sym_leaf_k = sym_leaf_k; /* Keep a local copy also */ /* Need 'get' call to set other array values */ if (H5P_get(c_plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get rank for btree internal nodes") UINT16DECODE(p, btree_k[H5B_SNODE_ID]); if (btree_k[H5B_SNODE_ID] == 0) HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, FAIL, "bad 1/2 rank for btree internal nodes") /* * Delay setting the value in the property list until we've checked * for the indexed storage B-tree internal 'K' value later. */ /* File consistency flags. Not really used yet */ UINT32DECODE(p, shared->consist_flags); assert(((size_t)(p - buf)) == fixed_size); /* Decode the variable-length part of the superblock... */ variable_size = (super_vers>0 ? 4 : 0) + /* Potential indexed storage B-tree internal 'K' value */ H5F_SIZEOF_ADDR(f) + /*base addr*/ H5F_SIZEOF_ADDR(f) + /*global free list*/ H5F_SIZEOF_ADDR(f) + /*end-of-address*/ H5F_SIZEOF_ADDR(f) + /*reserved address*/ H5G_SIZEOF_ENTRY(f); /*root group ptr*/ assert(fixed_size + variable_size <= sizeof(buf)); if (H5FD_set_eoa(lf, shared->super_addr + fixed_size+variable_size) < 0 || H5FD_read(lf, H5FD_MEM_SUPER, dxpl_id, shared->super_addr + fixed_size, variable_size, p) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to read superblock") /* * If the superblock version # is greater than 0, read in the indexed * storage B-tree internal 'K' value */ if (super_vers > 0) { UINT16DECODE(p, btree_k[H5B_ISTORE_ID]); p += 2; /* reserved */ } else btree_k[H5B_ISTORE_ID] = HDF5_BTREE_ISTORE_IK_DEF; /* Set the B-tree internal node values, etc */ if (H5P_set(c_plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set rank for btree internal nodes") HDmemcpy(shared->btree_k, btree_k, sizeof(unsigned) * (size_t)H5B_NUM_BTREE_ID); /* Keep a local copy also */ H5F_addr_decode(f, (const uint8_t **)&p, &shared->base_addr/*out*/); H5F_addr_decode(f, (const uint8_t **)&p, &shared->freespace_addr/*out*/); H5F_addr_decode(f, (const uint8_t **)&p, &stored_eoa/*out*/); H5F_addr_decode(f, (const uint8_t **)&p, &shared->driver_addr/*out*/); if (H5G_ent_decode(f, (const uint8_t **)&p, root_ent/*out*/) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to read root symbol entry") /* * Check if superblock address is different from base address and * adjust base address and "end of address" address if so. */ if (!H5F_addr_eq(shared->super_addr,shared->base_addr)) { /* Check if the superblock moved earlier in the file */ if (H5F_addr_lt(shared->super_addr, shared->base_addr)) stored_eoa -= (shared->base_addr - shared->super_addr); else /* The superblock moved later in the file */ stored_eoa += (shared->super_addr - shared->base_addr); shared->base_addr = shared->super_addr; } /* end if */ /* Compute super block checksum */ assert(sizeof(chksum) == sizeof(shared->super_chksum)); for (q = (uint8_t *)&chksum, chksum = 0, i = 0; i < fixed_size + variable_size; ++i) q[i % sizeof(shared->super_chksum)] ^= buf[i]; /* Set the super block checksum */ shared->super_chksum = chksum; /* Decode the optional driver information block */ if (H5F_addr_defined(shared->driver_addr)) { haddr_t drv_addr = shared->base_addr + shared->driver_addr; uint8_t dbuf[H5F_DRVINFOBLOCK_SIZE]; /* Local buffer */ if (H5FD_set_eoa(lf, drv_addr + 16) < 0 || H5FD_read(lf, H5FD_MEM_SUPER, dxpl_id, drv_addr, (size_t)16, dbuf) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to read driver information block") p = dbuf; /* Version number */ if (HDF5_DRIVERINFO_VERSION != *p++) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "bad driver information block version number") p += 3; /* reserved */ /* Driver info size */ UINT32DECODE(p, driver_size); /* Driver name and/or version */ HDstrncpy(driver_name, (const char *)p, (size_t)8); driver_name[8] = '\0'; p += 8; /* advance past name/version */ /* Read driver information and decode */ assert((driver_size + 16) <= sizeof(dbuf)); if (H5FD_set_eoa(lf, drv_addr + 16 + driver_size) < 0 || H5FD_read(lf, H5FD_MEM_SUPER, dxpl_id, drv_addr+16, driver_size, p) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to read file driver information") if (H5FD_sb_decode(lf, driver_name, p) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to decode driver information") /* Compute driver info block checksum */ assert(sizeof(chksum) == sizeof(shared->drvr_chksum)); for (q = (uint8_t *)&chksum, chksum = 0, i = 0; i < (driver_size + 16); ++i) q[i % sizeof(shared->drvr_chksum)] ^= dbuf[i]; /* Set the driver info block checksum */ shared->drvr_chksum = chksum; } /* end if */ /* * The user-defined data is the area of the file before the base * address. */ if (H5P_set(c_plist, H5F_CRT_USER_BLOCK_NAME, &shared->base_addr) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set usr block size") /* * Make sure that the data is not truncated. One case where this is * possible is if the first file of a family of files was opened * individually. */ if (HADDR_UNDEF == (eof = H5FD_get_eof(lf))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to determine file size") if (eof < stored_eoa) HGOTO_ERROR(H5E_FILE, H5E_TRUNCATED, FAIL, "truncated file") /* * Tell the file driver how much address space has already been * allocated so that it knows how to allocate additional memory. */ if (H5FD_set_eoa(lf, stored_eoa) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to set end-of-address marker for file") done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5F_init_superblock * * Purpose: Allocates the superblock for the file and initializes * information about the superblock in memory. Does not write * any superblock information to the file. * * Return: Success: SUCCEED * Failure: FAIL * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * Sept 15, 2003 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5F_init_superblock(const H5F_t *f, hid_t dxpl_id) { hsize_t userblock_size = 0; /* Size of userblock, in bytes */ size_t superblock_size; /* Size of superblock, in bytes */ size_t driver_size; /* Size of driver info block (bytes)*/ unsigned super_vers; /* Super block version */ haddr_t addr; /* Address of superblock */ H5P_genplist_t *plist; /* Property list */ herr_t ret_value=SUCCEED; /* Encoding */ FUNC_ENTER_NOAPI(H5F_init_superblock, FAIL) /* Get the shared file creation property list */ if (NULL == (plist = H5I_object(f->shared->fcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") /* * The superblock starts immediately after the user-defined * header, which we have already insured is a proper size. The * base address is set to the same thing as the superblock for * now. */ if(H5P_get(plist, H5F_CRT_USER_BLOCK_NAME, &userblock_size) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get user block size") f->shared->super_addr = userblock_size; f->shared->base_addr = f->shared->super_addr; f->shared->consist_flags = 0x03; /* Grab superblock version from property list */ if (H5P_get(plist, H5F_CRT_SUPER_VERS_NAME, &super_vers) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get super block version") /* Compute the size of the superblock */ superblock_size=H5F_SIGNATURE_LEN /* Signature length (8 bytes) */ + 16 /* Length of required fixed-size portion */ + ((super_vers>0) ? 4 : 0) /* Version specific fixed-size portion */ + 4 * H5F_sizeof_addr(f) /* Variable-sized addresses */ + H5G_SIZEOF_ENTRY(f); /* Size of root group symbol table entry */ /* Compute the size of the driver information block. */ H5_ASSIGN_OVERFLOW(driver_size, H5FD_sb_size(f->shared->lf), hsize_t, size_t); if (driver_size > 0) driver_size += 16; /* Driver block header */ /* * Allocate space for the userblock, superblock, and driver info * block. We do it with one allocation request because the * userblock and superblock need to be at the beginning of the * file and only the first allocation request is required to * return memory at format address zero. */ H5_CHECK_OVERFLOW(f->shared->base_addr, haddr_t, hsize_t); addr = H5FD_alloc(f->shared->lf, H5FD_MEM_SUPER, dxpl_id, ((hsize_t)f->shared->base_addr + superblock_size + driver_size)); if (HADDR_UNDEF == addr) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to allocate file space for userblock and/or superblock") if (0 != addr) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "file driver failed to allocate userblock and/or superblock at address zero") /* * The file driver information block begins immediately after the * superblock. */ if (driver_size > 0) f->shared->driver_addr = superblock_size; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_init_superblock() */ /*------------------------------------------------------------------------- * Function: H5F_write_superblock * * Purpose: Writes (and optionally allocates) the superblock for the file. * If BUF is non-NULL, then write the serialized superblock * information into it. It should be a buffer of size * H5F_SUPERBLOCK_SIZE + H5F_DRVINFOBLOCK_SIZE or larger. * * Return: Success: SUCCEED * Failure: FAIL * * Programmer: Bill Wendling * wendling@ncsa.uiuc.edu * Sept 12, 2003 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5F_write_superblock(H5F_t *f, hid_t dxpl_id) { uint8_t sbuf[H5F_SUPERBLOCK_SIZE]; /* Superblock encoding buffer */ uint8_t dbuf[H5F_DRVINFOBLOCK_SIZE];/* Driver info block encoding buffer*/ uint8_t *p = NULL; /* Ptr into encoding buffers */ unsigned i; /* Index variable */ unsigned chksum; /* Checksum temporary variable */ size_t superblock_size; /* Size of superblock, in bytes */ size_t driver_size; /* Size of driver info block (bytes)*/ char driver_name[9]; /* Name of driver, for driver info block */ unsigned super_vers; /* Super block version */ unsigned freespace_vers; /* Freespace info version */ unsigned obj_dir_vers; /* Object header info version */ unsigned share_head_vers; /* Shared header info version */ H5P_genplist_t *plist; /* Property list */ herr_t ret_value = SUCCEED; /* Encoding */ FUNC_ENTER_NOAPI(H5F_write_superblock, FAIL) /* Get the shared file creation property list */ if (NULL == (plist = H5I_object(f->shared->fcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") /* Grab values from property list */ if (H5P_get(plist, H5F_CRT_SUPER_VERS_NAME, &super_vers) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get super block version") if (H5P_get(plist, H5F_CRT_FREESPACE_VERS_NAME, &freespace_vers) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get free space version") if (H5P_get(plist, H5F_CRT_OBJ_DIR_VERS_NAME, &obj_dir_vers) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get object directory version") if (H5P_get(plist, H5F_CRT_SHARE_HEAD_VERS_NAME, &share_head_vers) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get shared-header format version") /* Encode the file super block */ p = sbuf; HDmemcpy(p, H5F_SIGNATURE, (size_t)H5F_SIGNATURE_LEN); p += H5F_SIGNATURE_LEN; *p++ = (uint8_t)super_vers; *p++ = (uint8_t)freespace_vers; *p++ = (uint8_t)obj_dir_vers; *p++ = 0; /* reserved*/ *p++ = (uint8_t)share_head_vers; assert (H5F_SIZEOF_ADDR(f) <= 255); *p++ = (uint8_t)H5F_SIZEOF_ADDR(f); assert (H5F_SIZEOF_SIZE(f) <= 255); *p++ = (uint8_t)H5F_SIZEOF_SIZE(f); *p++ = 0; /* reserved */ UINT16ENCODE(p, f->shared->sym_leaf_k); UINT16ENCODE(p, f->shared->btree_k[H5B_SNODE_ID]); UINT32ENCODE(p, f->shared->consist_flags); /* * Versions of the superblock >0 have the indexed storage B-tree * internal 'K' value stored */ if (super_vers > 0) { UINT16ENCODE(p, f->shared->btree_k[H5B_ISTORE_ID]); *p++ = 0; /*reserved */ *p++ = 0; /*reserved */ } H5F_addr_encode(f, &p, f->shared->base_addr); H5F_addr_encode(f, &p, f->shared->freespace_addr); H5F_addr_encode(f, &p, H5FD_get_eoa(f->shared->lf)); H5F_addr_encode(f, &p, f->shared->driver_addr); if(H5G_ent_encode(f, &p, H5G_entof(f->shared->root_grp))<0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to encode root group information") H5_ASSIGN_OVERFLOW(superblock_size, p - sbuf, int, size_t); /* Double check we didn't overrun the block (unlikely) */ assert(superblock_size <= sizeof(sbuf)); /* Encode the driver information block. */ H5_ASSIGN_OVERFLOW(driver_size, H5FD_sb_size(f->shared->lf), hsize_t, size_t); if (driver_size > 0) { driver_size += 16; /* Driver block header */ /* Double check we didn't overrun the block (unlikely) */ assert(driver_size <= sizeof(dbuf)); /* Encode the driver information block */ p = dbuf; *p++ = HDF5_DRIVERINFO_VERSION; /* Version */ *p++ = 0; /* reserved */ *p++ = 0; /* reserved */ *p++ = 0; /* reserved */ /* Driver info size, excluding header */ UINT32ENCODE(p, driver_size - 16); /* Encode driver-specific data */ if (H5FD_sb_encode(f->shared->lf, driver_name, dbuf + 16) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to encode driver information") /* Driver name */ HDmemcpy(dbuf + 8, driver_name, (size_t)8); } /* end if */ /* Compute super block checksum */ assert(sizeof(chksum) == sizeof(f->shared->super_chksum)); for (p = (uint8_t *)&chksum, chksum = 0, i = 0; i < superblock_size; ++i) p[i % sizeof(f->shared->super_chksum)] ^= sbuf[i]; /* Compare with current checksums */ if (chksum != f->shared->super_chksum) { /* Write superblock */ if (H5FD_write(f->shared->lf, H5FD_MEM_SUPER, dxpl_id, f->shared->super_addr, superblock_size, sbuf) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write superblock") /* Update checksum information if different */ f->shared->super_chksum = chksum; } /* end if */ /* Check for driver info block */ if (HADDR_UNDEF != f->shared->driver_addr) { /* Compute driver info block checksum */ assert(sizeof(chksum) == sizeof(f->shared->drvr_chksum)); for (p = (uint8_t *)&chksum, chksum = 0, i = 0; i < driver_size; ++i) p[i % sizeof(f->shared->drvr_chksum)] ^= dbuf[i]; /* Compare with current checksums */ if (chksum != f->shared->drvr_chksum) { /* Write driver information block */ if (H5FD_write(f->shared->lf, H5FD_MEM_SUPER, dxpl_id, f->shared->base_addr + f->shared->driver_addr, driver_size, dbuf) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write driver information block") /* Update checksum information if different */ f->shared->drvr_chksum = chksum; } /* end if */ } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } xdmf-3.0+git20160803/Utilities/hdf5/CMakeLists.txt0000640000175000017500000005154013003006557021440 0ustar alastairalastairCMAKE_MINIMUM_REQUIRED(VERSION 2.4) if(COMMAND cmake_policy) cmake_policy(SET CMP0003 NEW) endif(COMMAND cmake_policy) PROJECT(VTKHDF5 C) INCLUDE_REGULAR_EXPRESSION("^.*\\.[ch]$") # EXPORT() will be in cmake 2.6, add an empty macro so older cmake versions still work IF(NOT COMMAND EXPORT) MACRO(EXPORT) ENDMACRO(EXPORT) ENDIF(NOT COMMAND EXPORT) SET(LIBRARY_OUTPUT_PATH ${VTKHDF5_BINARY_DIR}/bin CACHE PATH "Single output directory for building all libraries.") SET(EXECUTABLE_OUTPUT_PATH ${VTKHDF5_BINARY_DIR}/bin CACHE PATH "Single output directory for building all executables.") MARK_AS_ADVANCED(LIBRARY_OUTPUT_PATH EXECUTABLE_OUTPUT_PATH) # Choose install directories. IF(NOT VTKHDF5_INSTALL_LIB_DIR) SET(VTKHDF5_INSTALL_LIB_DIR /lib) ENDIF(NOT VTKHDF5_INSTALL_LIB_DIR) # Let parent project set VTKHDF5_INSTALL_NO_DEVELOPMENT or # VTKHDF5_INSTALL_NO_RUNTIME to remove components from the installation. SET(VTKHDF5_INSTALL_NO_LIBRARIES) IF(BUILD_SHARED_LIBS) IF(VTKHDF5_INSTALL_NO_RUNTIME AND VTKHDF5_INSTALL_NO_DEVELOPMENT) SET(VTKHDF5_INSTALL_NO_LIBRARIES 1) ENDIF(VTKHDF5_INSTALL_NO_RUNTIME AND VTKHDF5_INSTALL_NO_DEVELOPMENT) ELSE(BUILD_SHARED_LIBS) IF(VTKHDF5_INSTALL_NO_DEVELOPMENT) SET(VTKHDF5_INSTALL_NO_LIBRARIES 1) ENDIF(VTKHDF5_INSTALL_NO_DEVELOPMENT) ENDIF(BUILD_SHARED_LIBS) SET(CMAKE_C_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_C_FLAGS}") IF(NOT HDF5_ZLIB_HEADER) SET(HDF5_ZLIB_HEADER "zlib.h") ENDIF(NOT HDF5_ZLIB_HEADER) CONFIGURE_FILE(${VTKHDF5_SOURCE_DIR}/hdf5_zlib.h.in ${VTKHDF5_BINARY_DIR}/hdf5_zlib.h) # Block warnings unless we are instructed to allow them. # SET(HDF5_WARNINGS_ALLOW 1) IF(NOT HDF5_WARNINGS_ALLOW) # MSVC uses /w to suppress warnings. It also complains if another # warning level is given, so remove it. IF(MSVC) SET(HDF5_WARNINGS_BLOCKED 1) STRING(REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /w") ENDIF(MSVC) # Borland uses -w- to suppress warnings. IF(BORLAND) SET(HDF5_WARNINGS_BLOCKED 1) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w-") ENDIF(BORLAND) # Most compilers use -w to suppress warnings. IF(NOT HDF5_WARNINGS_BLOCKED) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w") ENDIF(NOT HDF5_WARNINGS_BLOCKED) ENDIF(NOT HDF5_WARNINGS_ALLOW) SET(PACKAGE_VERSION "\"1.6.5\"") SET(PACKAGE_TARNAME "\"hdf5\"") SET(PACKAGE_NAME "\"HDF5\"") SET(PACKAGE_STRING "\"HDF5 1.6.5\"") SET(PACKAGE_BUGREPORT "\"hdfhelp@ncsa.uiuc.edu\"") SET(LINUX_LFS 0) IF(CMAKE_SYSTEM MATCHES "Linux-([3-9]\\.[0-9]|2\\.[4-9])\\.") OPTION(HDF5_ENABLE_LINUX_LFS "Enable support for large (64-bit) files on Linux." ON) IF(HDF5_ENABLE_LINUX_LFS) SET(LINUX_LFS 1) ENDIF(HDF5_ENABLE_LINUX_LFS) ENDIF(CMAKE_SYSTEM MATCHES "Linux-([3-9]\\.[0-9]|2\\.[4-9])\\.") SET(HDF5_EXTRA_FLAGS) IF(LINUX_LFS) SET(HDF5_EXTRA_FLAGS -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE) ENDIF(LINUX_LFS) ADD_DEFINITIONS(${HDF5_EXTRA_FLAGS}) OPTION(HDF5_STREAM_VFD "Compile Stream Virtual File Driver support" ON) OPTION(HDF5_ENABLE_HSIZET "Enable datasets larger than memory" ON) IF(VTK_USE_MPI) OPTION(HDF5_ENABLE_PARALLEL "Enable parallel build (uses MPI)" OFF) ENDIF(VTK_USE_MPI) # Include all the necessary files for macros INCLUDE (CheckFunctionExists) INCLUDE (CheckIncludeFile) INCLUDE (CheckIncludeFileCXX) INCLUDE (CheckIncludeFiles) INCLUDE (CheckLibraryExists) INCLUDE (CheckSymbolExists) INCLUDE (CheckTypeSize) # This macro checks if the symbol exists in the library and if it # does, it appends library to the list. SET(LINK_LIBS "") MACRO(CHECK_LIBRARY_EXISTS_CONCAT LIBRARY SYMBOL VARIABLE) CHECK_LIBRARY_EXISTS("${LIBRARY};${LINK_LIBS}" ${SYMBOL} "" ${VARIABLE}) IF(${VARIABLE}) SET(LINK_LIBS ${LINK_LIBS} ${LIBRARY}) ENDIF(${VARIABLE}) ENDMACRO(CHECK_LIBRARY_EXISTS_CONCAT) CHECK_LIBRARY_EXISTS_CONCAT("m" printf HAVE_LIBM) CHECK_LIBRARY_EXISTS_CONCAT("ws2_32" printf HAVE_LIBWS2_32) CHECK_LIBRARY_EXISTS_CONCAT("wsock32" printf HAVE_LIBWSOCK32) #CHECK_LIBRARY_EXISTS_CONCAT("dl" dlopen HAVE_LIBDL) CHECK_LIBRARY_EXISTS_CONCAT("ucb" gethostname HAVE_LIBUCB) CHECK_LIBRARY_EXISTS_CONCAT("socket" connect HAVE_LIBSOCKET) CHECK_LIBRARY_EXISTS("c" gethostbyname "" NOT_NEED_LIBNSL) IF(NOT NOT_NEED_LIBNSL) CHECK_LIBRARY_EXISTS_CONCAT("nsl" gethostbyname HAVE_LIBNSL) ENDIF(NOT NOT_NEED_LIBNSL) SET(USE_INCLUDES "") # Check if header file exists and add it to the list. MACRO(CHECK_INCLUDE_FILE_CONCAT FILE VARIABLE) CHECK_INCLUDE_FILES("${USE_INCLUDES};${FILE}" ${VARIABLE}) IF(${VARIABLE}) SET(USE_INCLUDES ${USE_INCLUDES} ${FILE}) ENDIF(${VARIABLE}) ENDMACRO(CHECK_INCLUDE_FILE_CONCAT) CHECK_INCLUDE_FILE_CONCAT("globus/common.h" HAVE_GLOBUS_COMMON_H) CHECK_INCLUDE_FILE_CONCAT("io.h" HAVE_IO_H) CHECK_INCLUDE_FILE_CONCAT("mfhdf.h" HAVE_MFHDF_H) CHECK_INCLUDE_FILE_CONCAT("pdb.h" HAVE_PDB_H) CHECK_INCLUDE_FILE_CONCAT("pthread.h" HAVE_PTHREAD_H) CHECK_INCLUDE_FILE_CONCAT("setjmp.h" HAVE_SETJMP_H) CHECK_INCLUDE_FILE_CONCAT("srbclient.h" HAVE_SRBCLIENT_H) CHECK_INCLUDE_FILE_CONCAT("stddef.h" HAVE_STDDEF_H) CHECK_INCLUDE_FILE_CONCAT("stdint.h" HAVE_STDINT_H) CHECK_INCLUDE_FILE_CONCAT("string.h" HAVE_STRING_H) CHECK_INCLUDE_FILE_CONCAT("strings.h" HAVE_STRINGS_H) CHECK_INCLUDE_FILE_CONCAT("sys/ioctl.h" HAVE_SYS_IOCTL_H) CHECK_INCLUDE_FILE_CONCAT("sys/proc.h" HAVE_SYS_PROC_H) CHECK_INCLUDE_FILE_CONCAT("sys/resource.h" HAVE_SYS_RESOURCE_H) CHECK_INCLUDE_FILE_CONCAT("sys/socket.h" HAVE_SYS_SOCKET_H) CHECK_INCLUDE_FILE_CONCAT("sys/stat.h" HAVE_SYS_STAT_H) IF(CMAKE_SYSTEM_NAME MATCHES "OSF") CHECK_INCLUDE_FILE_CONCAT("sys/sysinfo.h" HAVE_SYS_SYSINFO_H) ELSE(CMAKE_SYSTEM_NAME MATCHES "OSF") SET(HAVE_SYS_SYSINFO_H "" CACHE INTERNAL "" FORCE) ENDIF(CMAKE_SYSTEM_NAME MATCHES "OSF") CHECK_INCLUDE_FILE_CONCAT("sys/time.h" HAVE_SYS_TIME_H) CHECK_INCLUDE_FILE_CONCAT("sys/timeb.h" HAVE_SYS_TIMEB_H) CHECK_INCLUDE_FILE_CONCAT("sys/types.h" HAVE_SYS_TYPES_H) CHECK_INCLUDE_FILE_CONCAT("unistd.h" HAVE_UNISTD_H) CHECK_INCLUDE_FILE_CONCAT("stdlib.h" HAVE_STDLIB_H) CHECK_INCLUDE_FILE_CONCAT("memory.h" HAVE_MEMORY_H) CHECK_INCLUDE_FILE_CONCAT("dlfcn.h" HAVE_DLFCN_H) CHECK_INCLUDE_FILE_CONCAT("features.h" HAVE_FEATURES_H) CHECK_INCLUDE_FILE_CONCAT("inttypes.h" HAVE_INTTYPES_H) CHECK_INCLUDE_FILE_CONCAT("winsock.h" HAVE_WINSOCK_H) # if the c compiler found stdint, check the C++ as well. On some systems this # file will be found by C but not C++, only do this test if the C++ compiler # has been initialized (e.g. the project also includes some c++) IF (HAVE_STDINT_H AND CMAKE_CXX_COMPILER_LOADED) CHECK_INCLUDE_FILE_CXX("stdint.h" HAVE_STDINT_H_CXX) IF (NOT HAVE_STDINT_H_CXX) SET (HAVE_STDINT_H "" CACHE INTERNAL "Have includes HAVE_STDINT_H") ENDIF (NOT HAVE_STDINT_H_CXX) ENDIF (HAVE_STDINT_H AND CMAKE_CXX_COMPILER_LOADED) IF(HDF5_ZLIB_INCLUDE_DIRS OR VTK_ZLIB_LIBRARIES) SET(HAVE_ZLIB_H 1) ELSE(HDF5_ZLIB_INCLUDE_DIRS OR VTK_ZLIB_LIBRARIES) CHECK_INCLUDE_FILE_CONCAT("zlib.h" HAVE_ZLIB_H) ENDIF(HDF5_ZLIB_INCLUDE_DIRS OR VTK_ZLIB_LIBRARIES) CHECK_TYPE_SIZE(char SIZEOF_CHAR) CHECK_TYPE_SIZE(short SIZEOF_SHORT) CHECK_TYPE_SIZE(int SIZEOF_INT) CHECK_TYPE_SIZE(long SIZEOF_LONG) CHECK_TYPE_SIZE(float SIZEOF_FLOAT) CHECK_TYPE_SIZE(double SIZEOF_DOUBLE) CHECK_TYPE_SIZE("long double" SIZEOF_LONG_DOUBLE) CHECK_TYPE_SIZE(int8_t SIZEOF_INT8_T) CHECK_TYPE_SIZE(uint8_t SIZEOF_UINT8_T) CHECK_TYPE_SIZE(int_least8_t SIZEOF_INT_LEAST8_T) CHECK_TYPE_SIZE(uint_least8_t SIZEOF_UINT_LEAST8_T) CHECK_TYPE_SIZE(int_fast8_t SIZEOF_INT_FAST8_T) CHECK_TYPE_SIZE(uint_fast8_t SIZEOF_UINT_FAST8_T) CHECK_TYPE_SIZE(int16_t SIZEOF_INT16_T) CHECK_TYPE_SIZE(uint16_t SIZEOF_UINT16_T) CHECK_TYPE_SIZE(int_least16_t SIZEOF_INT_LEAST16_T) CHECK_TYPE_SIZE(uint_least16_t SIZEOF_UINT_LEAST16_T) CHECK_TYPE_SIZE(int_fast16_t SIZEOF_INT_FAST16_T) CHECK_TYPE_SIZE(uint_fast16_t SIZEOF_UINT_FAST16_T) CHECK_TYPE_SIZE(int32_t SIZEOF_INT32_T) CHECK_TYPE_SIZE(uint32_t SIZEOF_UINT32_T) CHECK_TYPE_SIZE(int_least32_t SIZEOF_INT_LEAST32_T) CHECK_TYPE_SIZE(uint_least32_t SIZEOF_UINT_LEAST32_T) CHECK_TYPE_SIZE(int_fast32_t SIZEOF_INT_FAST32_T) CHECK_TYPE_SIZE(uint_fast32_t SIZEOF_UINT_FAST32_T) CHECK_TYPE_SIZE(int64_t SIZEOF_INT64_T) CHECK_TYPE_SIZE(uint64_t SIZEOF_UINT64_T) CHECK_TYPE_SIZE(jdshkjfhdks SIZEOF_JDSHKJFHDKS) CHECK_TYPE_SIZE(int_least64_t SIZEOF_INT_LEAST64_T) CHECK_TYPE_SIZE(uint_least64_t SIZEOF_UINT_LEAST64_T) CHECK_TYPE_SIZE(int_fast64_t SIZEOF_INT_FAST64_T) CHECK_TYPE_SIZE(uint_fast64_t SIZEOF_UINT_FAST64_T) CHECK_TYPE_SIZE(size_t SIZEOF_SIZE_T) CHECK_TYPE_SIZE(ssize_t SIZEOF_SSIZE_T) CHECK_TYPE_SIZE(off_t SIZEOF_OFF_T) CHECK_TYPE_SIZE(__int64 SIZEOF___INT64) CHECK_TYPE_SIZE("long long" SIZEOF_LONG_LONG) # For other tests to use the same libraries SET(CMAKE_REQUIRED_LIBRARIES ${LINK_LIBS}) # Check for some functions that are used CHECK_FUNCTION_EXISTS(strdup HAVE_STRDUP) CHECK_FUNCTION_EXISTS(snprintf HAVE_SNPRINTF) CHECK_FUNCTION_EXISTS(system HAVE_SYSTEM) CHECK_FUNCTION_EXISTS(vsnprintf HAVE_VSNPRINTF) CHECK_FUNCTION_EXISTS(waitpid HAVE_WAITPID) CHECK_FUNCTION_EXISTS(signal HAVE_SIGNAL) CHECK_FUNCTION_EXISTS(ioctl HAVE_IOCTL) CHECK_FUNCTION_EXISTS(sigaction HAVE_SIGACTION) CHECK_FUNCTION_EXISTS(getpwuid HAVE_GETPWUID) CHECK_FUNCTION_EXISTS(getrusage HAVE_GETRUSAGE) CHECK_FUNCTION_EXISTS(gettimeofday HAVE_GETTIMEOFDAY) CHECK_FUNCTION_EXISTS(longjmp HAVE_LONGJMP) CHECK_FUNCTION_EXISTS(fork HAVE_FORK) CHECK_FUNCTION_EXISTS(difftime HAVE_DIFFTIME) CHECK_FUNCTION_EXISTS(gethostname HAVE_GETHOSTNAME) CHECK_FUNCTION_EXISTS(sigaction HAVE_SIGACTION) CHECK_FUNCTION_EXISTS(frexpf HAVE_FREXPF) CHECK_FUNCTION_EXISTS(frexpl HAVE_FREXPL) CHECK_SYMBOL_EXISTS(TIOCGWINSZ "sys/ioctl.h" HAVE_TIOCGWINSZ) CHECK_SYMBOL_EXISTS(TIOCGETD "sys/ioctl.h" HAVE_TIOCGETD) # e.g. IBM BlueGene/L doesn't have SO_REUSEADDR, because "setsockopt is not needed for # BlueGene/L applications" according to the BlueGene/L Application Development handbook CHECK_SYMBOL_EXISTS(SO_REUSEADDR "sys/types.h;sys/socket.h" HAVE_SO_REUSEADDR) IF(HDF5_STREAM_VFD) CHECK_INCLUDE_FILE_CONCAT("netdb.h" HAVE_NETDB_H) CHECK_INCLUDE_FILE_CONCAT("netinet/tcp.h" HAVE_NETINET_TCP_H) CHECK_INCLUDE_FILE_CONCAT("sys/filio.h" HAVE_SYS_FILIO_H) SET(H5_HAVE_STREAM 1) ENDIF(HDF5_STREAM_VFD) # Cray Xt3/Catamount doesn't support IP networking IF(CMAKE_SYSTEM MATCHES Catamount) SET(H5_HAVE_STREAM 0) ENDIF(CMAKE_SYSTEM MATCHES Catamount) # For other other specific tests, use this macro. MACRO(OTHER_INTERNAL_TEST OTHER_TEST) IF("${OTHER_TEST}" MATCHES "^${OTHER_TEST}$") SET(MACRO_CHECK_FUNCTION_DEFINITIONS "-D${OTHER_TEST} ${CMAKE_REQUIRED_FLAGS}") SET(OTHER_TEST_ADD_LIBRARIES) IF(CMAKE_REQUIRED_LIBRARIES) SET(OTHER_TEST_ADD_LIBRARIES "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") ENDIF(CMAKE_REQUIRED_LIBRARIES) FOREACH(def ${HDF5_EXTRA_TEST_DEFINITIONS}) SET(MACRO_CHECK_FUNCTION_DEFINITIONS "${MACRO_CHECK_FUNCTION_DEFINITIONS} -D${def}=${${def}}") ENDFOREACH(def) FOREACH(def HAVE_SYS_TIME_H HAVE_UNISTD_H HAVE_SYS_TYPES_H HAVE_SYS_SOCKET_H) IF("${def}") SET(MACRO_CHECK_FUNCTION_DEFINITIONS "${MACRO_CHECK_FUNCTION_DEFINITIONS} -D${def}") ENDIF("${def}") ENDFOREACH(def) IF(LINUX_LFS) #don't be tempted to put this all in one multiline string macro will fail SET(MACRO_CHECK_FUNCTION_DEFINITIONS "${MACRO_CHECK_FUNCTION_DEFINITIONS} -D_FILE_OFFSET_BITS=64") SET(MACRO_CHECK_FUNCTION_DEFINITIONS "${MACRO_CHECK_FUNCTION_DEFINITIONS} -D_LARGEFILE64_SOURCE") SET(MACRO_CHECK_FUNCTION_DEFINITIONS "${MACRO_CHECK_FUNCTION_DEFINITIONS} -D_LARGEFILE_SOURCE") ENDIF(LINUX_LFS) MESSAGE(STATUS "Performing Other Test ${OTHER_TEST}") TRY_COMPILE(${OTHER_TEST} ${CMAKE_BINARY_DIR} ${VTKHDF5_SOURCE_DIR}/CMake/HDF5Tests.c CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} "${OTHER_TEST_ADD_LIBRARIES}" OUTPUT_VARIABLE OUTPUT) IF(${OTHER_TEST}) SET(${OTHER_TEST} 1 CACHE INTERNAL "Other test ${FUNCTION}") MESSAGE(STATUS "Performing Other Test ${OTHER_TEST} - Success") ELSE(${OTHER_TEST}) MESSAGE(STATUS "Performing Other Test ${OTHER_TEST} - Failed") SET(${OTHER_TEST} "" CACHE INTERNAL "Other test ${FUNCTION}") WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log "Performing Other Test ${OTHER_TEST} failed with the following " "output:\n${OUTPUT}\n" APPEND) ENDIF(${OTHER_TEST}) ENDIF("${OTHER_TEST}" MATCHES "^${OTHER_TEST}$") ENDMACRO(OTHER_INTERNAL_TEST) # Do curl specific tests FOREACH(CURL_TEST TIME_WITH_SYS_TIME STDC_HEADERS HAVE_TM_ZONE HAVE_STRUCT_TM_TM_ZONE HAVE_ATTRIBUTE HAVE_FUNCTION HAVE_TM_GMTOFF HAVE_TIMEZONE HAVE_STRUCT_TIMEZONE HAVE_STAT_ST_BLOCKS HAVE_FUNCTION SYSTEM_SCOPE_THREADS HAVE_SOCKLEN_T DEV_T_IS_SCALAR HAVE_OFF64_T ) OTHER_INTERNAL_TEST(${CURL_TEST}) ENDFOREACH(CURL_TEST) IF(HAVE_OFF64_T) CHECK_FUNCTION_EXISTS(lseek64 HAVE_LSEEK64) CHECK_FUNCTION_EXISTS(fseek64 HAVE_FSEEK64) ENDIF(HAVE_OFF64_T) SET(HDF5_EXTRA_TEST_DEFINITIONS INLINE_TEST_INLINE) FOREACH(inline_test inline __inline__ __inline) SET(INLINE_TEST_INLINE ${inline_test}) OTHER_INTERNAL_TEST(INLINE_TEST_${inline_test}) ENDFOREACH(inline_test) SET(HDF5_EXTRA_TEST_DEFINITIONS) IF(INLINE_TEST___inline__) SET(inline __inline__) ELSE(INLINE_TEST___inline__) IF(INLINE_TEST___inline) SET(inline __inline) ELSE(INLINE_TEST___inline) IF(INLINE_TEST_inline) SET(inline inline) ENDIF(INLINE_TEST_inline) ENDIF(INLINE_TEST___inline) ENDIF(INLINE_TEST___inline__) IF(PRINTF_LL_WIDTH MATCHES "^PRINTF_LL_WIDTH$") MESSAGE(STATUS "Checking for apropriate format for 64 bit long:") SET(CURRENT_TEST_DEFINITIONS "-DPRINTF_LL_WIDTH") IF(SIZEOF_LONG_LONG) SET(CURRENT_TEST_DEFINITIONS "${CURRENT_TEST_DEFINITIONS} -DHAVE_LONG_LONG") ENDIF(SIZEOF_LONG_LONG) TRY_RUN(HDF5_PRINTF_LL_TEST_RUN HDF5_PRINTF_LL_TEST_COMPILE ${VTKHDF5_BINARY_DIR}/CMake ${VTKHDF5_SOURCE_DIR}/CMake/HDF5Tests.c CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${CURRENT_TEST_DEFINITIONS} OUTPUT_VARIABLE OUTPUT) IF (HDF5_PRINTF_LL_TEST_COMPILE) IF (HDF5_PRINTF_LL_TEST_RUN MATCHES 0) STRING(REGEX REPLACE ".*PRINTF_LL_WIDTH=\\[(.+)\\].*" "\\1" PRINTF_LL_WIDTH "${OUTPUT}" ) SET(PRINTF_LL_WIDTH "\"${PRINTF_LL_WIDTH}\"" CACHE INTERNAL "Width for printf for type `long long' or `__int64', us. `ll") ELSE (HDF5_PRINTF_LL_TEST_RUN MATCHES 0) SET(PRINTF_LL_WIDTH "\"unknown\"" CACHE INTERNAL "Width for printf for type `long long' or `__int64', us. `ll") ENDIF(HDF5_PRINTF_LL_TEST_RUN MATCHES 0) ELSE (HDF5_PRINTF_LL_TEST_COMPILE) WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log "Test PRINTF_LL_WIDTH failed with the following output:\n${OUTPUT}\n" APPEND) ENDIF(HDF5_PRINTF_LL_TEST_COMPILE) MESSAGE(STATUS "Checking for apropriate format for 64 bit long: ${PRINTF_LL_WIDTH}") ENDIF(PRINTF_LL_WIDTH MATCHES "^PRINTF_LL_WIDTH$") # Some things that are always true SET(CONVERT_DENORMAL_FLOAT 1) SET(HAVE_LIBZ 1) SET(HAVE_FILTER_DEFLATE 1) SET(HAVE_FILTER_FLETCHER32 1) SET(HAVE_FILTER_SHUFFLE 1) IF(HDF5_ENABLE_HSIZET) SET(HAVE_LARGE_HSIZET 1) ENDIF(HDF5_ENABLE_HSIZET) IF(HDF5_ENABLE_PARALLEL AND VTK_USE_MPI) SET(HAVE_PARALLEL 1) FIND_PACKAGE(MPI) ADD_DEFINITIONS("-DMPICH_IGNORE_CXX_SEEK") INCLUDE_DIRECTORIES(${MPI_INCLUDE_PATH}) SET(HDF5_MPI_INCLUDE_PATH ${MPI_INCLUDE_PATH}) ENDIF (HDF5_ENABLE_PARALLEL AND VTK_USE_MPI) IF(CYGWIN) SET(HAVE_LSEEK64 0) ENDIF(CYGWIN) SET(common_SRCS H5.c H5FDmpio.c H5HP.c H5Pfapl.c H5Tconv.c H5A.c H5FDmpiposix.c H5I.c H5Pfcpl.c H5Tcset.c H5AC.c H5FDmulti.c H5MF.c H5Ptest.c H5Tenum.c H5B.c H5FDsec2.c H5MM.c H5R.c H5Tfields.c H5C.c H5FDsrb.c H5O.c H5RC.c H5Tfixed.c H5D.c H5FDstdio.c H5Oattr.c H5RS.c H5Tfloat.c H5Dcompact.c H5FDstream.c H5Obogus.c H5S.c H5Tnative.c H5Dcontig.c H5FL.c H5Ocont.c H5SL.c H5Toffset.c H5Defl.c H5FO.c H5Odtype.c H5ST.c H5Topaque.c H5Dio.c H5FS.c H5Oefl.c H5Sall.c H5Torder.c H5Distore.c H5Fdbg.c H5Ofill.c H5Shyper.c H5Tpad.c H5Dmpio.c H5Fmount.c H5Olayout.c H5Smpio.c H5Tprecis.c H5Dselect.c H5Fsfile.c H5Omtime.c H5Snone.c H5Tstrpad.c H5Dtest.c H5Fsuper.c H5Oname.c H5Spoint.c H5Tvlen.c H5E.c H5G.c H5Onull.c H5Sselect.c H5V.c H5F.c H5Gent.c H5Opline.c H5Stest.c H5Z.c H5FD.c H5Gnode.c H5Osdspace.c H5T.c H5Zdeflate.c H5FDcore.c H5Gstab.c H5Oshared.c H5TS.c H5Zfletcher32.c H5FDfamily.c H5HG.c H5Ostab.c H5Tarray.c H5Zshuffle.c H5FDgass.c H5HGdbg.c H5P.c H5Tbit.c H5Zszip.c H5FDlog.c H5HL.c H5Pdcpl.c H5Tcommit.c H5detect.c H5FDmpi.c H5HLdbg.c H5Pdxpl.c H5Tcompound.c ) IF(APPLE) SET_SOURCE_FILES_PROPERTIES( H5.c H5D.c H5E.c PROPERTIES COMPILE_FLAGS -fno-common) ENDIF(APPLE) INCLUDE_DIRECTORIES(${VTKHDF5_SOURCE_DIR} ${VTKHDF5_BINARY_DIR}) # This variable is used in H5pubconf to detect shared libraries. IF(BUILD_SHARED_LIBS) SET(VTKHDF5_BUILD_SHARED_LIBS 1) ELSE(BUILD_SHARED_LIBS) SET(VTKHDF5_BUILD_SHARED_LIBS 0) ENDIF(BUILD_SHARED_LIBS) SET(CONFIG_FILE_EXT h.cmake) CONFIGURE_FILE(${VTKHDF5_SOURCE_DIR}/H5config.${CONFIG_FILE_EXT}.in ${VTKHDF5_BINARY_DIR}/H5config.h IMMEDIATE) FILE(READ "${VTKHDF5_BINARY_DIR}/H5config.h" HDF5_PUBLIC_CONFIG) STRING(REGEX REPLACE "#define " "#define H5_" HDF5_PUBLIC_CONFIG ${HDF5_PUBLIC_CONFIG}) STRING(REGEX REPLACE "#undef " "#undef H5_" HDF5_PUBLIC_CONFIG ${HDF5_PUBLIC_CONFIG}) CONFIGURE_FILE(${VTKHDF5_SOURCE_DIR}/H5pubconf.${CONFIG_FILE_EXT}.in ${VTKHDF5_BINARY_DIR}/H5pubconf.h) SET(common_SRCS ${common_SRCS} ${VTKHDF5_BINARY_DIR}/H5Tinit.c) SET_SOURCE_FILES_PROPERTIES (${VTKHDF5_BINARY_DIR}/H5Tinit.c GENERATED) IF(HDF5_ZLIB_INCLUDE_DIRS) INCLUDE_DIRECTORIES(${HDF5_ZLIB_INCLUDE_DIRS}) ENDIF(HDF5_ZLIB_INCLUDE_DIRS) IF(VTK_ZLIB_INCLUDE_DIRS) INCLUDE_DIRECTORIES(${VTK_ZLIB_INCLUDE_DIRS}) ENDIF(VTK_ZLIB_INCLUDE_DIRS) ADD_LIBRARY(vtkhdf5 ${common_SRCS}) TARGET_LINK_LIBRARIES(vtkhdf5 ${LINK_LIBS}) IF(HDF5_ENABLE_PARALLEL AND VTK_USE_MPI) IF (MPI_LIBRARY) SET(HDFMPI_LIBS "${MPI_LIBRARY}") ELSE (MPI_LIBRARY) MESSAGE("Could not find the required MPI libraries") ENDIF (MPI_LIBRARY) IF (MPI_EXTRA_LIBRARY) SET(HDFMPI_LIBS ${HDFMPI_LIBS} "${MPI_EXTRA_LIBRARY}") ENDIF (MPI_EXTRA_LIBRARY) TARGET_LINK_LIBRARIES(vtkhdf5 ${HDFMPI_LIBS}) ENDIF (HDF5_ENABLE_PARALLEL AND VTK_USE_MPI) IF(XDMF_ZLIB_LIBRARIES) TARGET_LINK_LIBRARIES(vtkhdf5 ${XDMF_ZLIB_LIBRARIES}) ENDIF(XDMF_ZLIB_LIBRARIES) IF(VTK_ZLIB_LIBRARIES) TARGET_LINK_LIBRARIES(vtkhdf5 ${VTK_ZLIB_LIBRARIES}) ENDIF(VTK_ZLIB_LIBRARIES) IF(NOT VTKHDF5_INSTALL_NO_LIBRARIES) IF(PV_INSTALL_HAS_CMAKE_24) INSTALL(TARGETS vtkhdf5 RUNTIME DESTINATION ${PV_INSTALL_BIN_DIR_CM24} COMPONENT Runtime LIBRARY DESTINATION ${PV_INSTALL_LIB_DIR_CM24} COMPONENT Runtime ARCHIVE DESTINATION ${PV_INSTALL_LIB_DIR_CM24} COMPONENT Development) ELSE(PV_INSTALL_HAS_CMAKE_24) INSTALL_TARGETS(${VTKHDF5_INSTALL_LIB_DIR} vtkhdf5) ENDIF(PV_INSTALL_HAS_CMAKE_24) ENDIF(NOT VTKHDF5_INSTALL_NO_LIBRARIES) # Install HDF5 Headers IF(NOT VTKHDF5_INSTALL_NO_DEVELOPMENT) SET(VTKHDF5_INSTALL_INCLUDE_DIR ${XDMF_HDF5_INCLUDE_INSTALL_CONFIG}) FILE(GLOB vtkhdf5_HEADERS ${VTKHDF5_SOURCE_DIR}/*.h ${VTKHDF5_BINARY_DIR}/*.h ) INSTALL(FILES ${vtkhdf5_HEADERS} DESTINATION ${VTKHDF5_INSTALL_INCLUDE_DIR} COMPONENT Development ) ENDIF(NOT VTKHDF5_INSTALL_NO_DEVELOPMENT) IF(NOT CMAKE_CROSSCOMPILING) ADD_EXECUTABLE(H5detect H5detect.c) TARGET_LINK_LIBRARIES(H5detect ${LINK_LIBS}) IF (${EXPORT_EXECUTABLES_FILE}) EXPORT(TARGETS H5detect FILE ${EXPORT_EXECUTABLES_FILE} NAMESPACE ${EXPORT_EXECUTABLES_PREFIX} APPEND) ENDIF (${EXPORT_EXECUTABLES_FILE}) ENDIF(NOT CMAKE_CROSSCOMPILING) GET_TARGET_PROPERTY(CMD H5detect LOCATION) ADD_CUSTOM_COMMAND( OUTPUT ${VTKHDF5_BINARY_DIR}/H5Tinit.c COMMAND ${CMD} ARGS > ${VTKHDF5_BINARY_DIR}/H5Tinit.c DEPENDS H5detect ) CONFIGURE_FILE(${VTKHDF5_SOURCE_DIR}/HDF5Config.cmake.in ${VTKHDF5_BINARY_DIR}/HDF5Config.cmake @ONLY) CONFIGURE_FILE(${VTKHDF5_SOURCE_DIR}/CTestCustom.ctest.in ${VTKHDF5_BINARY_DIR}/CTestCustom.ctest @ONLY) MARK_AS_ADVANCED(HDF5_STREAM_VFD HDF5_ENABLE_HSIZET HDF5_ENABLE_LINUX_LFS HDF5_ENABLE_PARALLEL) xdmf-3.0+git20160803/Utilities/hdf5/H5Oefl.c0000640000175000017500000003414513003006557020130 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Robb Matzke * Tuesday, November 25, 1997 */ #define H5O_PACKAGE /*suppress error about including H5Opkg */ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fprivate.h" /* File access */ #include "H5HLprivate.h" /* Local Heaps */ #include "H5MMprivate.h" /* Memory management */ #include "H5Opkg.h" /* Object headers */ /* PRIVATE PROTOTYPES */ static void *H5O_efl_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t *sh); static herr_t H5O_efl_encode(H5F_t *f, uint8_t *p, const void *_mesg); static void *H5O_efl_copy(const void *_mesg, void *_dest, unsigned update_flags); static size_t H5O_efl_size(const H5F_t *f, const void *_mesg); static herr_t H5O_efl_reset(void *_mesg); static herr_t H5O_efl_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * stream, int indent, int fwidth); /* This message derives from H5O */ const H5O_class_t H5O_EFL[1] = {{ H5O_EFL_ID, /*message id number */ "external file list", /*message name for debugging */ sizeof(H5O_efl_t), /*native message size */ H5O_efl_decode, /*decode message */ H5O_efl_encode, /*encode message */ H5O_efl_copy, /*copy native value */ H5O_efl_size, /*size of message on disk */ H5O_efl_reset, /*reset method */ NULL, /* free method */ NULL, /* file delete method */ NULL, /* link method */ NULL, /*get share method */ NULL, /*set share method */ H5O_efl_debug, /*debug the message */ }}; #define H5O_EFL_VERSION 1 /*------------------------------------------------------------------------- * Function: H5O_efl_decode * * Purpose: Decode an external file list message and return a pointer to * the message (and some other data). * * Return: Success: Ptr to a new message struct. * * Failure: NULL * * Programmer: Robb Matzke * Tuesday, November 25, 1997 * * Modifications: * Robb Matzke, 1998-07-20 * Rearranged the message to add a version number near the beginning. * *------------------------------------------------------------------------- */ static void * H5O_efl_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t UNUSED *sh) { H5O_efl_t *mesg = NULL; int version; const char *s = NULL; const H5HL_t *heap; size_t u; /* Local index variable */ void *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_efl_decode); /* Check args */ assert(f); assert(p); assert (!sh); if (NULL==(mesg = H5MM_calloc(sizeof(H5O_efl_t)))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); /* Version */ version = *p++; if (version!=H5O_EFL_VERSION) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for external file list message"); /* Reserved */ p += 3; /* Number of slots */ UINT16DECODE(p, mesg->nalloc); assert(mesg->nalloc>0); UINT16DECODE(p, mesg->nused); assert(mesg->nused <= mesg->nalloc); /* Heap address */ H5F_addr_decode(f, &p, &(mesg->heap_addr)); #ifndef NDEBUG assert (H5F_addr_defined(mesg->heap_addr)); if (NULL == (heap = H5HL_protect(f, dxpl_id, mesg->heap_addr))) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "unable to read protect link value") s = H5HL_offset_into(f, heap, 0); assert (s && !*s); if (H5HL_unprotect(f, dxpl_id, heap, mesg->heap_addr) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "unable to read unprotect link value") #endif /* Decode the file list */ mesg->slot = H5MM_calloc(mesg->nalloc*sizeof(H5O_efl_entry_t)); if (NULL==mesg->slot) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); for (u=0; unused; u++) { /* Name */ H5F_DECODE_LENGTH (f, p, mesg->slot[u].name_offset); if (NULL == (heap = H5HL_protect(f, dxpl_id, mesg->heap_addr))) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "unable to read protect link value") s = H5HL_offset_into(f, heap, mesg->slot[u].name_offset); assert (s && *s); mesg->slot[u].name = H5MM_xstrdup (s); assert(mesg->slot[u].name); if (H5HL_unprotect(f, dxpl_id, heap, mesg->heap_addr) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "unable to read unprotect link value") /* File offset */ H5F_DECODE_LENGTH (f, p, mesg->slot[u].offset); /* Size */ H5F_DECODE_LENGTH (f, p, mesg->slot[u].size); assert (mesg->slot[u].size>0); } /* Set return value */ ret_value=mesg; done: if(ret_value==NULL) { if(mesg!=NULL) H5MM_xfree (mesg); } /* end if */ FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_efl_encode * * Purpose: Encodes a message. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Tuesday, November 25, 1997 * * Modifications: * Robb Matzke, 1998-07-20 * Rearranged the message to add a version number near the beginning. * * Robb Matzke, 1999-10-14 * Entering the name into the local heap happens when the dataset is * created. Otherwise we could end up in infinite recursion if the heap * happens to hash to the same cache slot as the object header. * *------------------------------------------------------------------------- */ static herr_t H5O_efl_encode(H5F_t *f, uint8_t *p, const void *_mesg) { const H5O_efl_t *mesg = (const H5O_efl_t *)_mesg; size_t u; /* Local index variable */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_efl_encode); /* check args */ assert(f); assert(mesg); assert(p); /* Version */ *p++ = H5O_EFL_VERSION; /* Reserved */ *p++ = 0; *p++ = 0; *p++ = 0; /* Number of slots */ assert (mesg->nalloc>0); UINT16ENCODE(p, mesg->nused); /*yes, twice*/ assert (mesg->nused>0 && mesg->nused<=mesg->nalloc); UINT16ENCODE(p, mesg->nused); /* Heap address */ assert (H5F_addr_defined(mesg->heap_addr)); H5F_addr_encode(f, &p, mesg->heap_addr); /* Encode file list */ for (u=0; unused; u++) { /* * The name should have been added to the heap when the dataset was * created. */ assert(mesg->slot[u].name_offset); H5F_ENCODE_LENGTH (f, p, mesg->slot[u].name_offset); H5F_ENCODE_LENGTH (f, p, mesg->slot[u].offset); H5F_ENCODE_LENGTH (f, p, mesg->slot[u].size); } FUNC_LEAVE_NOAPI(SUCCEED); } /*------------------------------------------------------------------------- * Function: H5O_efl_copy * * Purpose: Copies a message from _MESG to _DEST, allocating _DEST if * necessary. * * Return: Success: Ptr to _DEST * * Failure: NULL * * Programmer: Robb Matzke * Tuesday, November 25, 1997 * * Modifications: * *------------------------------------------------------------------------- */ static void * H5O_efl_copy(const void *_mesg, void *_dest, unsigned UNUSED update_flags) { const H5O_efl_t *mesg = (const H5O_efl_t *) _mesg; H5O_efl_t *dest = (H5O_efl_t *) _dest; size_t u; /* Local index variable */ void *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_efl_copy); /* check args */ assert(mesg); if (!dest) { if (NULL==(dest = H5MM_calloc(sizeof(H5O_efl_t))) || NULL==(dest->slot=H5MM_malloc(mesg->nalloc* sizeof(H5O_efl_entry_t)))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); } else if (dest->nallocnalloc) { H5MM_xfree(dest->slot); if (NULL==(dest->slot = H5MM_malloc(mesg->nalloc* sizeof(H5O_efl_entry_t)))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); } dest->heap_addr = mesg->heap_addr; dest->nalloc = mesg->nalloc; dest->nused = mesg->nused; for (u = 0; u < mesg->nused; u++) { dest->slot[u] = mesg->slot[u]; dest->slot[u].name = H5MM_xstrdup (mesg->slot[u].name); } /* Set return value */ ret_value=dest; done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_efl_size * * Purpose: Returns the size of the raw message in bytes not counting the * message type or size fields, but only the data fields. This * function doesn't take into account message alignment. This * function doesn't count unused slots. * * Return: Success: Message data size in bytes. * * Failure: 0 * * Programmer: Robb Matzke * Tuesday, November 25, 1997 * * Modifications: * *------------------------------------------------------------------------- */ static size_t H5O_efl_size(const H5F_t *f, const void *_mesg) { const H5O_efl_t *mesg = (const H5O_efl_t *) _mesg; size_t ret_value = 0; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_efl_size); /* check args */ assert(f); assert(mesg); ret_value = H5F_SIZEOF_ADDR(f) + /*heap address */ 2 + /*slots allocated*/ 2 + /*num slots used*/ 4 + /*reserved */ mesg->nused * (H5F_SIZEOF_SIZE(f) + /*name offset */ H5F_SIZEOF_SIZE(f) + /*file offset */ H5F_SIZEOF_SIZE(f)); /*file size */ FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_efl_reset * * Purpose: Frees internal pointers and resets the message to an * initialial state. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Tuesday, November 25, 1997 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_efl_reset(void *_mesg) { H5O_efl_t *mesg = (H5O_efl_t *) _mesg; size_t u; /* Local index variable */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_efl_reset); /* check args */ assert(mesg); /* reset */ for (u=0; unused; u++) mesg->slot[u].name = H5MM_xfree (mesg->slot[u].name); mesg->heap_addr = HADDR_UNDEF; mesg->nused = mesg->nalloc = 0; if(mesg->slot) mesg->slot = H5MM_xfree(mesg->slot); FUNC_LEAVE_NOAPI(SUCCEED); } /*------------------------------------------------------------------------- * Function: H5O_efl_total_size * * Purpose: Return the total size of the external file list by summing * the sizes of all of the files. * * Return: Success: Total reserved size for external data. * * Failure: 0 * * Programmer: Robb Matzke * Tuesday, March 3, 1998 * * Modifications: * *------------------------------------------------------------------------- */ hsize_t H5O_efl_total_size (H5O_efl_t *efl) { hsize_t ret_value = 0, tmp; FUNC_ENTER_NOAPI_NOINIT(H5O_efl_total_size); if (efl->nused>0 && H5O_EFL_UNLIMITED==efl->slot[efl->nused-1].size) { ret_value = H5O_EFL_UNLIMITED; } else { size_t u; /* Local index variable */ for (u=0; unused; u++, ret_value=tmp) { tmp = ret_value + efl->slot[u].size; if (tmp<=ret_value) HGOTO_ERROR (H5E_EFL, H5E_OVERFLOW, 0, "total external storage size overflowed"); } } done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_efl_debug * * Purpose: Prints debugging info for a message. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Tuesday, November 25, 1997 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_efl_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg, FILE * stream, int indent, int fwidth) { const H5O_efl_t *mesg = (const H5O_efl_t *) _mesg; char buf[64]; size_t u; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_efl_debug); /* check args */ assert(f); assert(mesg); assert(stream); assert(indent >= 0); assert(fwidth >= 0); HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "Heap address:", mesg->heap_addr); HDfprintf(stream, "%*s%-*s %u/%u\n", indent, "", fwidth, "Slots used/allocated:", mesg->nused, mesg->nalloc); for (u = 0; u < mesg->nused; u++) { sprintf (buf, "File %u", (unsigned)u); HDfprintf (stream, "%*s%s:\n", indent, "", buf); HDfprintf(stream, "%*s%-*s \"%s\"\n", indent+3, "", MAX (fwidth-3, 0), "Name:", mesg->slot[u].name); HDfprintf(stream, "%*s%-*s %lu\n", indent+3, "", MAX (fwidth-3, 0), "Name offset:", (unsigned long)(mesg->slot[u].name_offset)); HDfprintf (stream, "%*s%-*s %lu\n", indent+3, "", MAX (fwidth-3, 0), "Offset of data in file:", (unsigned long)(mesg->slot[u].offset)); HDfprintf (stream, "%*s%-*s %lu\n", indent+3, "", MAX (fwidth-3, 0), "Bytes reserved for data:", (unsigned long)(mesg->slot[u].size)); } FUNC_LEAVE_NOAPI(SUCCEED); } xdmf-3.0+git20160803/Utilities/hdf5/H5Bpublic.h0000640000175000017500000000407713003006557020631 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*------------------------------------------------------------------------- * * Created: H5Bproto.h * Jul 10 1997 * Robb Matzke * * Purpose: Public declarations for the H5B package. * * Modifications: * *------------------------------------------------------------------------- */ #ifndef _H5Bpublic_H #define _H5Bpublic_H /* Public headers needed by this file */ #include "H5public.h" /* B-tree IDs for various internal things. */ /* Not really a "public" symbol, but that should be OK -QAK */ /* Note - if more of these are added, any 'K' values (for internal or leaf * nodes) they use will need to be stored in the file somewhere. -QAK */ typedef enum H5B_subid_t { H5B_SNODE_ID = 0, /*B-tree is for symbol table nodes */ H5B_ISTORE_ID = 1, /*B-tree is for indexed object storage */ H5B_NUM_BTREE_ID /* Number of B-tree key IDs (must be last) */ } H5B_subid_t; #ifdef __cplusplus extern "C" { #endif #ifdef __cplusplus } #endif #endif xdmf-3.0+git20160803/Utilities/hdf5/H5Tpublic.h0000640000175000017500000006152713003006557020656 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * This file contains public declarations for the H5T module. */ #ifndef _H5Tpublic_H #define _H5Tpublic_H /* Public headers needed by this file */ #include "H5public.h" #include "H5Ipublic.h" #define HOFFSET(S,M) (offsetof(S,M)) /* These are the various classes of datatypes */ /* If this goes over 16 types (0-15), the file format will need to change) */ typedef enum H5T_class_t { H5T_NO_CLASS = -1, /*error */ H5T_INTEGER = 0, /*integer types */ H5T_FLOAT = 1, /*floating-point types */ H5T_TIME = 2, /*date and time types */ H5T_STRING = 3, /*character string types */ H5T_BITFIELD = 4, /*bit field types */ H5T_OPAQUE = 5, /*opaque types */ H5T_COMPOUND = 6, /*compound types */ H5T_REFERENCE = 7, /*reference types */ H5T_ENUM = 8, /*enumeration types */ H5T_VLEN = 9, /*Variable-Length types */ H5T_ARRAY = 10, /*Array types */ H5T_NCLASSES /*this must be last */ } H5T_class_t; /* Byte orders */ typedef enum H5T_order_t { H5T_ORDER_ERROR = -1, /*error */ H5T_ORDER_LE = 0, /*little endian */ H5T_ORDER_BE = 1, /*bit endian */ H5T_ORDER_VAX = 2, /*VAX mixed endian */ H5T_ORDER_NONE = 3 /*no particular order (strings, bits,..) */ /*H5T_ORDER_NONE must be last */ } H5T_order_t; /* Types of integer sign schemes */ typedef enum H5T_sign_t { H5T_SGN_ERROR = -1, /*error */ H5T_SGN_NONE = 0, /*this is an unsigned type */ H5T_SGN_2 = 1, /*two's complement */ H5T_NSGN = 2 /*this must be last! */ } H5T_sign_t; /* Floating-point normalization schemes */ typedef enum H5T_norm_t { H5T_NORM_ERROR = -1, /*error */ H5T_NORM_IMPLIED = 0, /*msb of mantissa isn't stored, always 1 */ H5T_NORM_MSBSET = 1, /*msb of mantissa is always 1 */ H5T_NORM_NONE = 2 /*not normalized */ /*H5T_NORM_NONE must be last */ } H5T_norm_t; /* * Character set to use for text strings. Do not change these values since * they appear in HDF5 files! */ typedef enum H5T_cset_t { H5T_CSET_ERROR = -1, /*error */ H5T_CSET_ASCII = 0, /*US ASCII */ H5T_CSET_RESERVED_1 = 1, /*reserved for later use */ H5T_CSET_RESERVED_2 = 2, /*reserved for later use */ H5T_CSET_RESERVED_3 = 3, /*reserved for later use */ H5T_CSET_RESERVED_4 = 4, /*reserved for later use */ H5T_CSET_RESERVED_5 = 5, /*reserved for later use */ H5T_CSET_RESERVED_6 = 6, /*reserved for later use */ H5T_CSET_RESERVED_7 = 7, /*reserved for later use */ H5T_CSET_RESERVED_8 = 8, /*reserved for later use */ H5T_CSET_RESERVED_9 = 9, /*reserved for later use */ H5T_CSET_RESERVED_10 = 10, /*reserved for later use */ H5T_CSET_RESERVED_11 = 11, /*reserved for later use */ H5T_CSET_RESERVED_12 = 12, /*reserved for later use */ H5T_CSET_RESERVED_13 = 13, /*reserved for later use */ H5T_CSET_RESERVED_14 = 14, /*reserved for later use */ H5T_CSET_RESERVED_15 = 15 /*reserved for later use */ } H5T_cset_t; #define H5T_NCSET H5T_CSET_RESERVED_1 /*Number of character sets actually defined */ /* * Type of padding to use in character strings. Do not change these values * since they appear in HDF5 files! */ typedef enum H5T_str_t { H5T_STR_ERROR = -1, /*error */ H5T_STR_NULLTERM = 0, /*null terminate like in C */ H5T_STR_NULLPAD = 1, /*pad with nulls */ H5T_STR_SPACEPAD = 2, /*pad with spaces like in Fortran */ H5T_STR_RESERVED_3 = 3, /*reserved for later use */ H5T_STR_RESERVED_4 = 4, /*reserved for later use */ H5T_STR_RESERVED_5 = 5, /*reserved for later use */ H5T_STR_RESERVED_6 = 6, /*reserved for later use */ H5T_STR_RESERVED_7 = 7, /*reserved for later use */ H5T_STR_RESERVED_8 = 8, /*reserved for later use */ H5T_STR_RESERVED_9 = 9, /*reserved for later use */ H5T_STR_RESERVED_10 = 10, /*reserved for later use */ H5T_STR_RESERVED_11 = 11, /*reserved for later use */ H5T_STR_RESERVED_12 = 12, /*reserved for later use */ H5T_STR_RESERVED_13 = 13, /*reserved for later use */ H5T_STR_RESERVED_14 = 14, /*reserved for later use */ H5T_STR_RESERVED_15 = 15 /*reserved for later use */ } H5T_str_t; #define H5T_NSTR H5T_STR_RESERVED_3 /*num H5T_str_t types actually defined */ /* Type of padding to use in other atomic types */ typedef enum H5T_pad_t { H5T_PAD_ERROR = -1, /*error */ H5T_PAD_ZERO = 0, /*always set to zero */ H5T_PAD_ONE = 1, /*always set to one */ H5T_PAD_BACKGROUND = 2, /*set to background value */ H5T_NPAD = 3 /*THIS MUST BE LAST */ } H5T_pad_t; /* Commands sent to conversion functions */ typedef enum H5T_cmd_t { H5T_CONV_INIT = 0, /*query and/or initialize private data */ H5T_CONV_CONV = 1, /*convert data from source to dest datatype */ H5T_CONV_FREE = 2 /*function is being removed from path */ } H5T_cmd_t; /* How is the `bkg' buffer used by the conversion function? */ typedef enum H5T_bkg_t { H5T_BKG_NO = 0, /*background buffer is not needed, send NULL */ H5T_BKG_TEMP = 1, /*bkg buffer used as temp storage only */ H5T_BKG_YES = 2 /*init bkg buf with data before conversion */ } H5T_bkg_t; /* Type conversion client data */ typedef struct H5T_cdata_t { H5T_cmd_t command;/*what should the conversion function do? */ H5T_bkg_t need_bkg;/*is the background buffer needed? */ hbool_t recalc; /*recalculate private data */ void *priv; /*private data */ } H5T_cdata_t; /* Conversion function persistence */ typedef enum H5T_pers_t { H5T_PERS_DONTCARE = -1, /*wild card */ H5T_PERS_HARD = 0, /*hard conversion function */ H5T_PERS_SOFT = 1 /*soft conversion function */ } H5T_pers_t; /* The order to retrieve atomic native datatype */ typedef enum H5T_direction_t { H5T_DIR_DEFAULT = 0, /*default direction is inscendent */ H5T_DIR_ASCEND = 1, /*in inscendent order */ H5T_DIR_DESCEND = 2 /*in descendent order */ } H5T_direction_t; /* Variable Length Datatype struct in memory */ /* (This is only used for VL sequences, not VL strings, which are stored in char *'s) */ typedef struct { size_t len; /* Length of VL data (in base type units) */ void *p; /* Pointer to VL data */ } hvl_t; /* Variable Length String information */ #define H5T_VARIABLE ((size_t)(-1)) /* Indicate that a string is variable length (null-terminated in C, instead of fixed length) */ /* Opaque information */ #define H5T_OPAQUE_TAG_MAX 256 /* Maximum length of an opaque tag */ /* This could be raised without too much difficulty */ #ifdef __cplusplus extern "C" { #endif /* All datatype conversion functions are... */ typedef herr_t (*H5T_conv_t) (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); /* * If an error occurs during a data type conversion then the function * registered with H5Tset_overflow() is called. It's arguments are the * source and destination data types, a buffer which has the source value, * and a buffer to receive an optional result for the overflow conversion. * If the overflow handler chooses a value for the result it should return * non-negative; otherwise the hdf5 library will choose an appropriate * result. */ typedef herr_t (*H5T_overflow_t)(hid_t src_id, hid_t dst_id, void *src_buf, void *dst_buf); /* When this header is included from a private header, don't make calls to H5open() */ #undef H5OPEN #ifndef _H5private_H #define H5OPEN H5open(), #else /* _H5private_H */ #define H5OPEN #endif /* _H5private_H */ /* * The IEEE floating point types in various byte orders. */ #define H5T_IEEE_F32BE (H5OPEN H5T_IEEE_F32BE_g) #define H5T_IEEE_F32LE (H5OPEN H5T_IEEE_F32LE_g) #define H5T_IEEE_F64BE (H5OPEN H5T_IEEE_F64BE_g) #define H5T_IEEE_F64LE (H5OPEN H5T_IEEE_F64LE_g) H5_DLLVAR hid_t H5T_IEEE_F32BE_g; H5_DLLVAR hid_t H5T_IEEE_F32LE_g; H5_DLLVAR hid_t H5T_IEEE_F64BE_g; H5_DLLVAR hid_t H5T_IEEE_F64LE_g; /* * These are "standard" types. For instance, signed (2's complement) and * unsigned integers of various sizes and byte orders. */ #define H5T_STD_I8BE (H5OPEN H5T_STD_I8BE_g) #define H5T_STD_I8LE (H5OPEN H5T_STD_I8LE_g) #define H5T_STD_I16BE (H5OPEN H5T_STD_I16BE_g) #define H5T_STD_I16LE (H5OPEN H5T_STD_I16LE_g) #define H5T_STD_I32BE (H5OPEN H5T_STD_I32BE_g) #define H5T_STD_I32LE (H5OPEN H5T_STD_I32LE_g) #define H5T_STD_I64BE (H5OPEN H5T_STD_I64BE_g) #define H5T_STD_I64LE (H5OPEN H5T_STD_I64LE_g) #define H5T_STD_U8BE (H5OPEN H5T_STD_U8BE_g) #define H5T_STD_U8LE (H5OPEN H5T_STD_U8LE_g) #define H5T_STD_U16BE (H5OPEN H5T_STD_U16BE_g) #define H5T_STD_U16LE (H5OPEN H5T_STD_U16LE_g) #define H5T_STD_U32BE (H5OPEN H5T_STD_U32BE_g) #define H5T_STD_U32LE (H5OPEN H5T_STD_U32LE_g) #define H5T_STD_U64BE (H5OPEN H5T_STD_U64BE_g) #define H5T_STD_U64LE (H5OPEN H5T_STD_U64LE_g) #define H5T_STD_B8BE (H5OPEN H5T_STD_B8BE_g) #define H5T_STD_B8LE (H5OPEN H5T_STD_B8LE_g) #define H5T_STD_B16BE (H5OPEN H5T_STD_B16BE_g) #define H5T_STD_B16LE (H5OPEN H5T_STD_B16LE_g) #define H5T_STD_B32BE (H5OPEN H5T_STD_B32BE_g) #define H5T_STD_B32LE (H5OPEN H5T_STD_B32LE_g) #define H5T_STD_B64BE (H5OPEN H5T_STD_B64BE_g) #define H5T_STD_B64LE (H5OPEN H5T_STD_B64LE_g) #define H5T_STD_REF_OBJ (H5OPEN H5T_STD_REF_OBJ_g) #define H5T_STD_REF_DSETREG (H5OPEN H5T_STD_REF_DSETREG_g) H5_DLLVAR hid_t H5T_STD_I8BE_g; H5_DLLVAR hid_t H5T_STD_I8LE_g; H5_DLLVAR hid_t H5T_STD_I16BE_g; H5_DLLVAR hid_t H5T_STD_I16LE_g; H5_DLLVAR hid_t H5T_STD_I32BE_g; H5_DLLVAR hid_t H5T_STD_I32LE_g; H5_DLLVAR hid_t H5T_STD_I64BE_g; H5_DLLVAR hid_t H5T_STD_I64LE_g; H5_DLLVAR hid_t H5T_STD_U8BE_g; H5_DLLVAR hid_t H5T_STD_U8LE_g; H5_DLLVAR hid_t H5T_STD_U16BE_g; H5_DLLVAR hid_t H5T_STD_U16LE_g; H5_DLLVAR hid_t H5T_STD_U32BE_g; H5_DLLVAR hid_t H5T_STD_U32LE_g; H5_DLLVAR hid_t H5T_STD_U64BE_g; H5_DLLVAR hid_t H5T_STD_U64LE_g; H5_DLLVAR hid_t H5T_STD_B8BE_g; H5_DLLVAR hid_t H5T_STD_B8LE_g; H5_DLLVAR hid_t H5T_STD_B16BE_g; H5_DLLVAR hid_t H5T_STD_B16LE_g; H5_DLLVAR hid_t H5T_STD_B32BE_g; H5_DLLVAR hid_t H5T_STD_B32LE_g; H5_DLLVAR hid_t H5T_STD_B64BE_g; H5_DLLVAR hid_t H5T_STD_B64LE_g; H5_DLLVAR hid_t H5T_STD_REF_OBJ_g; H5_DLLVAR hid_t H5T_STD_REF_DSETREG_g; /* * Types which are particular to Unix. */ #define H5T_UNIX_D32BE (H5OPEN H5T_UNIX_D32BE_g) #define H5T_UNIX_D32LE (H5OPEN H5T_UNIX_D32LE_g) #define H5T_UNIX_D64BE (H5OPEN H5T_UNIX_D64BE_g) #define H5T_UNIX_D64LE (H5OPEN H5T_UNIX_D64LE_g) H5_DLLVAR hid_t H5T_UNIX_D32BE_g; H5_DLLVAR hid_t H5T_UNIX_D32LE_g; H5_DLLVAR hid_t H5T_UNIX_D64BE_g; H5_DLLVAR hid_t H5T_UNIX_D64LE_g; /* * Types particular to the C language. String types use `bytes' instead * of `bits' as their size. */ #define H5T_C_S1 (H5OPEN H5T_C_S1_g) H5_DLLVAR hid_t H5T_C_S1_g; /* * Types particular to Fortran. */ #define H5T_FORTRAN_S1 (H5OPEN H5T_FORTRAN_S1_g) H5_DLLVAR hid_t H5T_FORTRAN_S1_g; /* * These types are for Intel CPU's. They are little endian with IEEE * floating point. */ #define H5T_INTEL_I8 H5T_STD_I8LE #define H5T_INTEL_I16 H5T_STD_I16LE #define H5T_INTEL_I32 H5T_STD_I32LE #define H5T_INTEL_I64 H5T_STD_I64LE #define H5T_INTEL_U8 H5T_STD_U8LE #define H5T_INTEL_U16 H5T_STD_U16LE #define H5T_INTEL_U32 H5T_STD_U32LE #define H5T_INTEL_U64 H5T_STD_U64LE #define H5T_INTEL_B8 H5T_STD_B8LE #define H5T_INTEL_B16 H5T_STD_B16LE #define H5T_INTEL_B32 H5T_STD_B32LE #define H5T_INTEL_B64 H5T_STD_B64LE #define H5T_INTEL_F32 H5T_IEEE_F32LE #define H5T_INTEL_F64 H5T_IEEE_F64LE /* * These types are for DEC Alpha CPU's. They are little endian with IEEE * floating point. */ #define H5T_ALPHA_I8 H5T_STD_I8LE #define H5T_ALPHA_I16 H5T_STD_I16LE #define H5T_ALPHA_I32 H5T_STD_I32LE #define H5T_ALPHA_I64 H5T_STD_I64LE #define H5T_ALPHA_U8 H5T_STD_U8LE #define H5T_ALPHA_U16 H5T_STD_U16LE #define H5T_ALPHA_U32 H5T_STD_U32LE #define H5T_ALPHA_U64 H5T_STD_U64LE #define H5T_ALPHA_B8 H5T_STD_B8LE #define H5T_ALPHA_B16 H5T_STD_B16LE #define H5T_ALPHA_B32 H5T_STD_B32LE #define H5T_ALPHA_B64 H5T_STD_B64LE #define H5T_ALPHA_F32 H5T_IEEE_F32LE #define H5T_ALPHA_F64 H5T_IEEE_F64LE /* * These types are for MIPS cpu's commonly used in SGI systems. They are big * endian with IEEE floating point. */ #define H5T_MIPS_I8 H5T_STD_I8BE #define H5T_MIPS_I16 H5T_STD_I16BE #define H5T_MIPS_I32 H5T_STD_I32BE #define H5T_MIPS_I64 H5T_STD_I64BE #define H5T_MIPS_U8 H5T_STD_U8BE #define H5T_MIPS_U16 H5T_STD_U16BE #define H5T_MIPS_U32 H5T_STD_U32BE #define H5T_MIPS_U64 H5T_STD_U64BE #define H5T_MIPS_B8 H5T_STD_B8BE #define H5T_MIPS_B16 H5T_STD_B16BE #define H5T_MIPS_B32 H5T_STD_B32BE #define H5T_MIPS_B64 H5T_STD_B64BE #define H5T_MIPS_F32 H5T_IEEE_F32BE #define H5T_MIPS_F64 H5T_IEEE_F64BE /* * The predefined native types. These are the types detected by H5detect and * they violate the naming scheme a little. Instead of a class name, * precision and byte order as the last component, they have a C-like type * name. If the type begins with `U' then it is the unsigned version of the * integer type; other integer types are signed. The type LLONG corresponds * to C's `long_long' and LDOUBLE is `long double' (these types might be the * same as `LONG' and `DOUBLE' respectively. */ #define H5T_NATIVE_CHAR (CHAR_MIN?H5T_NATIVE_SCHAR:H5T_NATIVE_UCHAR) #define H5T_NATIVE_SCHAR (H5OPEN H5T_NATIVE_SCHAR_g) #define H5T_NATIVE_UCHAR (H5OPEN H5T_NATIVE_UCHAR_g) #define H5T_NATIVE_SHORT (H5OPEN H5T_NATIVE_SHORT_g) #define H5T_NATIVE_USHORT (H5OPEN H5T_NATIVE_USHORT_g) #define H5T_NATIVE_INT (H5OPEN H5T_NATIVE_INT_g) #define H5T_NATIVE_UINT (H5OPEN H5T_NATIVE_UINT_g) #define H5T_NATIVE_LONG (H5OPEN H5T_NATIVE_LONG_g) #define H5T_NATIVE_ULONG (H5OPEN H5T_NATIVE_ULONG_g) #define H5T_NATIVE_LLONG (H5OPEN H5T_NATIVE_LLONG_g) #define H5T_NATIVE_ULLONG (H5OPEN H5T_NATIVE_ULLONG_g) #define H5T_NATIVE_FLOAT (H5OPEN H5T_NATIVE_FLOAT_g) #define H5T_NATIVE_DOUBLE (H5OPEN H5T_NATIVE_DOUBLE_g) #define H5T_NATIVE_LDOUBLE (H5OPEN H5T_NATIVE_LDOUBLE_g) #define H5T_NATIVE_B8 (H5OPEN H5T_NATIVE_B8_g) #define H5T_NATIVE_B16 (H5OPEN H5T_NATIVE_B16_g) #define H5T_NATIVE_B32 (H5OPEN H5T_NATIVE_B32_g) #define H5T_NATIVE_B64 (H5OPEN H5T_NATIVE_B64_g) #define H5T_NATIVE_OPAQUE (H5OPEN H5T_NATIVE_OPAQUE_g) #define H5T_NATIVE_HADDR (H5OPEN H5T_NATIVE_HADDR_g) #define H5T_NATIVE_HSIZE (H5OPEN H5T_NATIVE_HSIZE_g) #define H5T_NATIVE_HSSIZE (H5OPEN H5T_NATIVE_HSSIZE_g) #define H5T_NATIVE_HERR (H5OPEN H5T_NATIVE_HERR_g) #define H5T_NATIVE_HBOOL (H5OPEN H5T_NATIVE_HBOOL_g) H5_DLLVAR hid_t H5T_NATIVE_SCHAR_g; H5_DLLVAR hid_t H5T_NATIVE_UCHAR_g; H5_DLLVAR hid_t H5T_NATIVE_SHORT_g; H5_DLLVAR hid_t H5T_NATIVE_USHORT_g; H5_DLLVAR hid_t H5T_NATIVE_INT_g; H5_DLLVAR hid_t H5T_NATIVE_UINT_g; H5_DLLVAR hid_t H5T_NATIVE_LONG_g; H5_DLLVAR hid_t H5T_NATIVE_ULONG_g; H5_DLLVAR hid_t H5T_NATIVE_LLONG_g; H5_DLLVAR hid_t H5T_NATIVE_ULLONG_g; H5_DLLVAR hid_t H5T_NATIVE_FLOAT_g; H5_DLLVAR hid_t H5T_NATIVE_DOUBLE_g; H5_DLLVAR hid_t H5T_NATIVE_LDOUBLE_g; H5_DLLVAR hid_t H5T_NATIVE_B8_g; H5_DLLVAR hid_t H5T_NATIVE_B16_g; H5_DLLVAR hid_t H5T_NATIVE_B32_g; H5_DLLVAR hid_t H5T_NATIVE_B64_g; H5_DLLVAR hid_t H5T_NATIVE_OPAQUE_g; H5_DLLVAR hid_t H5T_NATIVE_HADDR_g; H5_DLLVAR hid_t H5T_NATIVE_HSIZE_g; H5_DLLVAR hid_t H5T_NATIVE_HSSIZE_g; H5_DLLVAR hid_t H5T_NATIVE_HERR_g; H5_DLLVAR hid_t H5T_NATIVE_HBOOL_g; /* C9x integer types */ #define H5T_NATIVE_INT8 (H5OPEN H5T_NATIVE_INT8_g) #define H5T_NATIVE_UINT8 (H5OPEN H5T_NATIVE_UINT8_g) #define H5T_NATIVE_INT_LEAST8 (H5OPEN H5T_NATIVE_INT_LEAST8_g) #define H5T_NATIVE_UINT_LEAST8 (H5OPEN H5T_NATIVE_UINT_LEAST8_g) #define H5T_NATIVE_INT_FAST8 (H5OPEN H5T_NATIVE_INT_FAST8_g) #define H5T_NATIVE_UINT_FAST8 (H5OPEN H5T_NATIVE_UINT_FAST8_g) H5_DLLVAR hid_t H5T_NATIVE_INT8_g; H5_DLLVAR hid_t H5T_NATIVE_UINT8_g; H5_DLLVAR hid_t H5T_NATIVE_INT_LEAST8_g; H5_DLLVAR hid_t H5T_NATIVE_UINT_LEAST8_g; H5_DLLVAR hid_t H5T_NATIVE_INT_FAST8_g; H5_DLLVAR hid_t H5T_NATIVE_UINT_FAST8_g; #define H5T_NATIVE_INT16 (H5OPEN H5T_NATIVE_INT16_g) #define H5T_NATIVE_UINT16 (H5OPEN H5T_NATIVE_UINT16_g) #define H5T_NATIVE_INT_LEAST16 (H5OPEN H5T_NATIVE_INT_LEAST16_g) #define H5T_NATIVE_UINT_LEAST16 (H5OPEN H5T_NATIVE_UINT_LEAST16_g) #define H5T_NATIVE_INT_FAST16 (H5OPEN H5T_NATIVE_INT_FAST16_g) #define H5T_NATIVE_UINT_FAST16 (H5OPEN H5T_NATIVE_UINT_FAST16_g) H5_DLLVAR hid_t H5T_NATIVE_INT16_g; H5_DLLVAR hid_t H5T_NATIVE_UINT16_g; H5_DLLVAR hid_t H5T_NATIVE_INT_LEAST16_g; H5_DLLVAR hid_t H5T_NATIVE_UINT_LEAST16_g; H5_DLLVAR hid_t H5T_NATIVE_INT_FAST16_g; H5_DLLVAR hid_t H5T_NATIVE_UINT_FAST16_g; #define H5T_NATIVE_INT32 (H5OPEN H5T_NATIVE_INT32_g) #define H5T_NATIVE_UINT32 (H5OPEN H5T_NATIVE_UINT32_g) #define H5T_NATIVE_INT_LEAST32 (H5OPEN H5T_NATIVE_INT_LEAST32_g) #define H5T_NATIVE_UINT_LEAST32 (H5OPEN H5T_NATIVE_UINT_LEAST32_g) #define H5T_NATIVE_INT_FAST32 (H5OPEN H5T_NATIVE_INT_FAST32_g) #define H5T_NATIVE_UINT_FAST32 (H5OPEN H5T_NATIVE_UINT_FAST32_g) H5_DLLVAR hid_t H5T_NATIVE_INT32_g; H5_DLLVAR hid_t H5T_NATIVE_UINT32_g; H5_DLLVAR hid_t H5T_NATIVE_INT_LEAST32_g; H5_DLLVAR hid_t H5T_NATIVE_UINT_LEAST32_g; H5_DLLVAR hid_t H5T_NATIVE_INT_FAST32_g; H5_DLLVAR hid_t H5T_NATIVE_UINT_FAST32_g; #define H5T_NATIVE_INT64 (H5OPEN H5T_NATIVE_INT64_g) #define H5T_NATIVE_UINT64 (H5OPEN H5T_NATIVE_UINT64_g) #define H5T_NATIVE_INT_LEAST64 (H5OPEN H5T_NATIVE_INT_LEAST64_g) #define H5T_NATIVE_UINT_LEAST64 (H5OPEN H5T_NATIVE_UINT_LEAST64_g) #define H5T_NATIVE_INT_FAST64 (H5OPEN H5T_NATIVE_INT_FAST64_g) #define H5T_NATIVE_UINT_FAST64 (H5OPEN H5T_NATIVE_UINT_FAST64_g) H5_DLLVAR hid_t H5T_NATIVE_INT64_g; H5_DLLVAR hid_t H5T_NATIVE_UINT64_g; H5_DLLVAR hid_t H5T_NATIVE_INT_LEAST64_g; H5_DLLVAR hid_t H5T_NATIVE_UINT_LEAST64_g; H5_DLLVAR hid_t H5T_NATIVE_INT_FAST64_g; H5_DLLVAR hid_t H5T_NATIVE_UINT_FAST64_g; /* Operations defined on all datatypes */ H5_DLL hid_t H5Topen(hid_t loc_id, const char *name); H5_DLL hid_t H5Tcreate(H5T_class_t type, size_t size); H5_DLL hid_t H5Tcopy(hid_t type_id); H5_DLL herr_t H5Tclose(hid_t type_id); H5_DLL htri_t H5Tequal(hid_t type1_id, hid_t type2_id); H5_DLL herr_t H5Tlock(hid_t type_id); H5_DLL herr_t H5Tcommit(hid_t loc_id, const char *name, hid_t type_id); H5_DLL htri_t H5Tcommitted(hid_t type_id); /* Operations defined on compound datatypes */ H5_DLL herr_t H5Tinsert(hid_t parent_id, const char *name, size_t offset, hid_t member_id); H5_DLL herr_t H5Tpack(hid_t type_id); /* Operations defined on enumeration datatypes */ H5_DLL hid_t H5Tenum_create(hid_t base_id); H5_DLL herr_t H5Tenum_insert(hid_t type, const char *name, const void *value); H5_DLL herr_t H5Tenum_nameof(hid_t type, const void *value, char *name/*out*/, size_t size); H5_DLL herr_t H5Tenum_valueof(hid_t type, const char *name, void *value/*out*/); /* Operations defined on variable-length datatypes */ H5_DLL hid_t H5Tvlen_create(hid_t base_id); /* Operations defined on array datatypes */ H5_DLL hid_t H5Tarray_create(hid_t base_id, int ndims, const hsize_t dim[/* ndims */], const int perm[/* ndims */]); H5_DLL int H5Tget_array_ndims(hid_t type_id); H5_DLL int H5Tget_array_dims(hid_t type_id, hsize_t dims[], int perm[]); /* Operations defined on opaque datatypes */ H5_DLL herr_t H5Tset_tag(hid_t type, const char *tag); H5_DLL char *H5Tget_tag(hid_t type); /* Querying property values */ H5_DLL hid_t H5Tget_super(hid_t type); H5_DLL H5T_class_t H5Tget_class(hid_t type_id); H5_DLL htri_t H5Tdetect_class(hid_t type_id, H5T_class_t cls); H5_DLL size_t H5Tget_size(hid_t type_id); H5_DLL H5T_order_t H5Tget_order(hid_t type_id); H5_DLL size_t H5Tget_precision(hid_t type_id); H5_DLL int H5Tget_offset(hid_t type_id); H5_DLL herr_t H5Tget_pad(hid_t type_id, H5T_pad_t *lsb/*out*/, H5T_pad_t *msb/*out*/); H5_DLL H5T_sign_t H5Tget_sign(hid_t type_id); H5_DLL herr_t H5Tget_fields(hid_t type_id, size_t *spos/*out*/, size_t *epos/*out*/, size_t *esize/*out*/, size_t *mpos/*out*/, size_t *msize/*out*/); H5_DLL size_t H5Tget_ebias(hid_t type_id); H5_DLL H5T_norm_t H5Tget_norm(hid_t type_id); H5_DLL H5T_pad_t H5Tget_inpad(hid_t type_id); H5_DLL H5T_str_t H5Tget_strpad(hid_t type_id); H5_DLL int H5Tget_nmembers(hid_t type_id); H5_DLL char *H5Tget_member_name(hid_t type_id, unsigned membno); H5_DLL int H5Tget_member_index(hid_t type_id, const char *name); H5_DLL size_t H5Tget_member_offset(hid_t type_id, unsigned membno); H5_DLL H5T_class_t H5Tget_member_class(hid_t type_id, unsigned membno); H5_DLL hid_t H5Tget_member_type(hid_t type_id, unsigned membno); H5_DLL herr_t H5Tget_member_value(hid_t type_id, unsigned membno, void *value/*out*/); H5_DLL H5T_cset_t H5Tget_cset(hid_t type_id); H5_DLL htri_t H5Tis_variable_str(hid_t type_id); H5_DLL hid_t H5Tget_native_type(hid_t type_id, H5T_direction_t direction); /* Setting property values */ H5_DLL herr_t H5Tset_size(hid_t type_id, size_t size); H5_DLL herr_t H5Tset_order(hid_t type_id, H5T_order_t order); H5_DLL herr_t H5Tset_precision(hid_t type_id, size_t prec); H5_DLL herr_t H5Tset_offset(hid_t type_id, size_t offset); H5_DLL herr_t H5Tset_pad(hid_t type_id, H5T_pad_t lsb, H5T_pad_t msb); H5_DLL herr_t H5Tset_sign(hid_t type_id, H5T_sign_t sign); H5_DLL herr_t H5Tset_fields(hid_t type_id, size_t spos, size_t epos, size_t esize, size_t mpos, size_t msize); H5_DLL herr_t H5Tset_ebias(hid_t type_id, size_t ebias); H5_DLL herr_t H5Tset_norm(hid_t type_id, H5T_norm_t norm); H5_DLL herr_t H5Tset_inpad(hid_t type_id, H5T_pad_t pad); H5_DLL herr_t H5Tset_cset(hid_t type_id, H5T_cset_t cset); H5_DLL herr_t H5Tset_strpad(hid_t type_id, H5T_str_t strpad); /* Type conversion database */ H5_DLL herr_t H5Tregister(H5T_pers_t pers, const char *name, hid_t src_id, hid_t dst_id, H5T_conv_t func); H5_DLL herr_t H5Tunregister(H5T_pers_t pers, const char *name, hid_t src_id, hid_t dst_id, H5T_conv_t func); H5_DLL H5T_conv_t H5Tfind(hid_t src_id, hid_t dst_id, H5T_cdata_t **pcdata); H5_DLL herr_t H5Tconvert(hid_t src_id, hid_t dst_id, size_t nelmts, void *buf, void *background, hid_t plist_id); H5_DLL H5T_overflow_t H5Tget_overflow(void); H5_DLL herr_t H5Tset_overflow(H5T_overflow_t func); #ifdef __cplusplus } #endif #endif xdmf-3.0+git20160803/Utilities/hdf5/H5FLprivate.h0000640000175000017500000003473013003006557021144 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*------------------------------------------------------------------------- * * Created: H5FLprivate.h * Mar 23 2000 * Quincey Koziol * * Purpose: Private non-prototype header. * * Modifications: * *------------------------------------------------------------------------- */ #ifndef _H5FLprivate_H #define _H5FLprivate_H /* Public headers needed by this file */ #ifdef LATER #include "H5FLpublic.h" /*API prototypes */ #endif /* LATER */ /* Private headers needed by this file */ /* Macros for turning off free lists in the library */ /* #define H5_NO_FREE_LISTS */ #if defined H5_NO_FREE_LISTS || defined H5_USING_PURIFY #define H5_NO_REG_FREE_LISTS #define H5_NO_ARR_FREE_LISTS #define H5_NO_SEQ_FREE_LISTS #define H5_NO_BLK_FREE_LISTS #endif /* H5_NO_FREE_LISTS */ /* * Private datatypes. */ /* Data structure to store each block in free list */ typedef struct H5FL_reg_node_t { struct H5FL_reg_node_t *next; /* Pointer to next block in free list */ } H5FL_reg_node_t; /* Data structure for free list of blocks */ typedef struct H5FL_reg_head_t { unsigned init; /* Whether the free list has been initialized */ unsigned allocated; /* Number of blocks allocated */ unsigned onlist; /* Number of blocks on free list */ size_t list_mem; /* Amount of memory on free list */ const char *name; /* Name of the type */ size_t size; /* Size of the blocks in the list */ H5FL_reg_node_t *list; /* List of free blocks */ } H5FL_reg_head_t; /* * Macros for defining & using free lists for a type */ #define H5FL_REG_NAME(t) H5_##t##_reg_free_list #ifndef H5_NO_REG_FREE_LISTS /* Common macros for H5FL_DEFINE & H5FL_DEFINE_STATIC */ #define H5FL_DEFINE_COMMON(t) H5FL_reg_head_t H5FL_REG_NAME(t)={0,0,0,0,#t,sizeof(t),NULL} /* Declare a free list to manage objects of type 't' */ #define H5FL_DEFINE(t) H5_DLL H5FL_DEFINE_COMMON(t) /* Reference a free list for type 't' defined in another file */ #define H5FL_EXTERN(t) extern H5_DLL H5FL_reg_head_t H5FL_REG_NAME(t) /* Declare a static free list to manage objects of type 't' */ #define H5FL_DEFINE_STATIC(t) static H5FL_DEFINE_COMMON(t) /* Allocate an object of type 't' */ #define H5FL_MALLOC(t) H5FL_reg_malloc(&(H5FL_REG_NAME(t))) /* Allocate an object of type 't' and clear it to all zeros */ #define H5FL_CALLOC(t) H5FL_reg_calloc(&(H5FL_REG_NAME(t))) /* Free an object of type 't' */ #define H5FL_FREE(t,obj) H5FL_reg_free(&(H5FL_REG_NAME(t)),obj) /* Re-allocating an object of type 't' is not defined, because these free-lists * only support fixed sized types, like structs, etc.. */ #else /* H5_NO_REG_FREE_LISTS */ #include "H5MMprivate.h" /* Common macro for H5FL_DEFINE & H5FL_DEFINE_STATIC */ #define H5FL_DEFINE_COMMON(t) int H5FL_REG_NAME(t) #define H5FL_DEFINE(t) H5_DLL H5FL_DEFINE_COMMON(t) #define H5FL_EXTERN(t) extern H5_DLL int H5FL_REG_NAME(t) #define H5FL_DEFINE_STATIC(t) static H5FL_DEFINE_COMMON(t) #define H5FL_MALLOC(t) H5MM_malloc(sizeof(t)) #define H5FL_CALLOC(t) H5MM_calloc(sizeof(t)) #define H5FL_FREE(t,obj) H5MM_xfree(obj) #endif /* H5_NO_REG_FREE_LISTS */ /* Data structure to store information about each block allocated */ typedef union H5FL_blk_list_t { size_t size; /* Size of the page */ union H5FL_blk_list_t *next; /* Pointer to next block in free list */ double unused1; /* Unused normally, just here for aligment */ haddr_t unused2; /* Unused normally, just here for aligment */ } H5FL_blk_list_t; /* Data structure for priority queue node of block free lists */ typedef struct H5FL_blk_node_t { size_t size; /* Size of the blocks in the list */ H5FL_blk_list_t *list; /* List of free blocks */ struct H5FL_blk_node_t *next; /* Pointer to next free list in queue */ struct H5FL_blk_node_t *prev; /* Pointer to previous free list in queue */ } H5FL_blk_node_t; /* Data structure for priority queue of native block free lists */ typedef struct H5FL_blk_head_t { unsigned init; /* Whether the free list has been initialized */ unsigned allocated; /* Number of blocks allocated */ unsigned onlist; /* Number of blocks on free list */ size_t list_mem; /* Amount of memory in block on free list */ const char *name; /* Name of the type */ H5FL_blk_node_t *head; /* Pointer to first free list in queue */ } H5FL_blk_head_t; /* * Macros for defining & using priority queues */ #define H5FL_BLK_NAME(t) H5_##t##_blk_free_list #ifndef H5_NO_BLK_FREE_LISTS /* Common macro for H5FL_BLK_DEFINE & H5FL_BLK_DEFINE_STATIC */ #define H5FL_BLK_DEFINE_COMMON(t) H5FL_blk_head_t H5FL_BLK_NAME(t)={0,0,0,0,#t"_blk",NULL} /* Declare a free list to manage objects of type 't' */ #define H5FL_BLK_DEFINE(t) H5_DLL H5FL_BLK_DEFINE_COMMON(t) /* Reference a free list for type 't' defined in another file */ #define H5FL_BLK_EXTERN(t) extern H5_DLL H5FL_blk_head_t H5FL_BLK_NAME(t) /* Declare a static free list to manage objects of type 't' */ #define H5FL_BLK_DEFINE_STATIC(t) static H5FL_BLK_DEFINE_COMMON(t) /* Allocate an block of type 't' */ #define H5FL_BLK_MALLOC(t,size) H5FL_blk_malloc(&(H5FL_BLK_NAME(t)),size) /* Allocate an block of type 't' and clear it to zeros */ #define H5FL_BLK_CALLOC(t,size) H5FL_blk_calloc(&(H5FL_BLK_NAME(t)),size) /* Free a block of type 't' */ #define H5FL_BLK_FREE(t,blk) H5FL_blk_free(&(H5FL_BLK_NAME(t)),blk) /* Re-allocate a block of type 't' */ #define H5FL_BLK_REALLOC(t,blk,new_size) H5FL_blk_realloc(&(H5FL_BLK_NAME(t)),blk,new_size) /* Check if there is a free block available to re-use */ #define H5FL_BLK_AVAIL(t,size) H5FL_blk_free_block_avail(&(H5FL_BLK_NAME(t)),size) #else /* H5_NO_BLK_FREE_LISTS */ /* Common macro for H5FL_BLK_DEFINE & H5FL_BLK_DEFINE_STATIC */ #define H5FL_BLK_DEFINE_COMMON(t) int H5FL_BLK_NAME(t) #define H5FL_BLK_DEFINE(t) H5_DLL H5FL_BLK_DEFINE_COMMON(t) #define H5FL_BLK_EXTERN(t) extern H5_DLL int H5FL_BLK_NAME(t) #define H5FL_BLK_DEFINE_STATIC(t) static H5FL_BLK_DEFINE_COMMON(t) #define H5FL_BLK_MALLOC(t,size) H5MM_malloc(size) #define H5FL_BLK_CALLOC(t,size) H5MM_calloc(size) #define H5FL_BLK_FREE(t,blk) H5MM_xfree(blk) #define H5FL_BLK_REALLOC(t,blk,new_size) H5MM_realloc(blk,new_size) #define H5FL_BLK_AVAIL(t,size) (FALSE) #endif /* H5_NO_BLK_FREE_LISTS */ /* Data structure to store each array in free list */ typedef union H5FL_arr_list_t { union H5FL_arr_list_t *next; /* Pointer to next block in free list */ size_t nelem; /* Number of elements in this array */ double unused1; /* Unused normally, just here for aligment */ haddr_t unused2; /* Unused normally, just here for aligment */ } H5FL_arr_list_t; /* Data structure for each size of array element */ typedef struct H5FL_arr_node_t { size_t size; /* Size of the blocks in the list */ unsigned onlist; /* Number of blocks on free list */ H5FL_arr_list_t *list; /* List of free blocks */ } H5FL_arr_node_t; /* Data structure for free list of array blocks */ typedef struct H5FL_arr_head_t { unsigned init; /* Whether the free list has been initialized */ unsigned allocated; /* Number of blocks allocated */ size_t list_mem; /* Amount of memory in block on free list */ const char *name; /* Name of the type */ int maxelem; /* Maximum number of elements in an array */ size_t base_size; /* Size of the "base" object in the list */ size_t elem_size; /* Size of the array elements in the list */ H5FL_arr_node_t *list_arr; /* Array of lists of free blocks */ } H5FL_arr_head_t; /* * Macros for defining & using free lists for an array of a type */ #define H5FL_ARR_NAME(t) H5_##t##_arr_free_list #ifndef H5_NO_ARR_FREE_LISTS /* Common macro for H5FL_BLK_DEFINE & H5FL_BLK_DEFINE_STATIC */ #define H5FL_ARR_DEFINE_COMMON(b,t,m) H5FL_arr_head_t H5FL_ARR_NAME(t)={0,0,0,#t"_arr",m+1,b,sizeof(t),NULL} /* Declare a free list to manage arrays of type 't' */ #define H5FL_ARR_DEFINE(t,m) H5_DLL H5FL_ARR_DEFINE_COMMON(0,t,m) /* Declare a free list to manage base 'b' + arrays of type 't' */ #define H5FL_BARR_DEFINE(b,t,m) H5_DLL H5FL_ARR_DEFINE_COMMON(sizeof(b),t,m) /* Reference a free list for arrays of type 't' defined in another file */ #define H5FL_ARR_EXTERN(t) extern H5_DLL H5FL_arr_head_t H5FL_ARR_NAME(t) /* Declare a static free list to manage arrays of type 't' */ #define H5FL_ARR_DEFINE_STATIC(t,m) static H5FL_ARR_DEFINE_COMMON(0,t,m) /* Declare a static free list to manage base 'b' + arrays of type 't' */ #define H5FL_BARR_DEFINE_STATIC(b,t,m) static H5FL_ARR_DEFINE_COMMON(sizeof(b),t,m) /* Allocate an array of type 't' */ #define H5FL_ARR_MALLOC(t,elem) H5FL_arr_malloc(&(H5FL_ARR_NAME(t)),elem) /* Allocate an array of type 't' and clear it to all zeros */ #define H5FL_ARR_CALLOC(t,elem) H5FL_arr_calloc(&(H5FL_ARR_NAME(t)),elem) /* Free an array of type 't' */ #define H5FL_ARR_FREE(t,obj) H5FL_arr_free(&(H5FL_ARR_NAME(t)),obj) /* Re-allocate an array of type 't' */ #define H5FL_ARR_REALLOC(t,obj,new_elem) H5FL_arr_realloc(&(H5FL_ARR_NAME(t)),obj,new_elem) #else /* H5_NO_ARR_FREE_LISTS */ /* Common macro for H5FL_ARR_DEFINE & H5FL_ARR_DEFINE_STATIC */ #define H5FL_ARR_DEFINE_COMMON(t,m) size_t H5FL_ARR_NAME(t) #define H5FL_ARR_DEFINE(t,m) H5_DLL H5FL_ARR_DEFINE_COMMON(t,m) = 0 #define H5FL_BARR_DEFINE(b,t,m) H5_DLL H5FL_ARR_DEFINE_COMMON(t,m) = sizeof(b) #define H5FL_ARR_EXTERN(t) extern H5_DLL H5FL_ARR_DEFINE_COMMON(t,m) #define H5FL_ARR_DEFINE_STATIC(t,m) static H5FL_ARR_DEFINE_COMMON(t,m) = 0 #define H5FL_BARR_DEFINE_STATIC(b,t,m) static H5FL_ARR_DEFINE_COMMON(t,m) = sizeof(b) #define H5FL_ARR_MALLOC(t,elem) H5MM_malloc(H5FL_ARR_NAME(t) + ((elem)*sizeof(t))) #define H5FL_ARR_CALLOC(t,elem) H5MM_calloc(H5FL_ARR_NAME(t) + ((elem)*sizeof(t))) #define H5FL_ARR_FREE(t,obj) H5MM_xfree(obj) #define H5FL_ARR_REALLOC(t,obj,new_elem) H5MM_realloc(obj,H5FL_ARR_NAME(t) + ((new_elem)*sizeof(t))) #endif /* H5_NO_ARR_FREE_LISTS */ /* Data structure for free list of sequence blocks */ typedef struct H5FL_seq_head_t { H5FL_blk_head_t queue; /* Priority queue of sequence blocks */ size_t size; /* Size of the sequence elements in the list */ } H5FL_seq_head_t; /* * Macros for defining & using free lists for a sequence of a type * * Sequences are like arrays, except they have no upper limit. * */ #define H5FL_SEQ_NAME(t) H5_##t##_seq_free_list #ifndef H5_NO_SEQ_FREE_LISTS /* Common macro for H5FL_SEQ_DEFINE & H5FL_SEQ_DEFINE_STATIC */ #define H5FL_SEQ_DEFINE_COMMON(t) H5FL_seq_head_t H5FL_SEQ_NAME(t)={{0,0,0,0,#t"_seq",NULL},sizeof(t)} /* Declare a free list to manage sequences of type 't' */ #define H5FL_SEQ_DEFINE(t) H5_DLL H5FL_SEQ_DEFINE_COMMON(t) /* Reference a free list for sequences of type 't' defined in another file */ #define H5FL_SEQ_EXTERN(t) extern H5_DLL H5FL_seq_head_t H5FL_SEQ_NAME(t) /* Declare a static free list to manage sequences of type 't' */ #define H5FL_SEQ_DEFINE_STATIC(t) static H5FL_SEQ_DEFINE_COMMON(t) /* Allocate a sequence of type 't' */ #define H5FL_SEQ_MALLOC(t,elem) H5FL_seq_malloc(&(H5FL_SEQ_NAME(t)),elem) /* Allocate a sequence of type 't' and clear it to all zeros */ #define H5FL_SEQ_CALLOC(t,elem) H5FL_seq_calloc(&(H5FL_SEQ_NAME(t)),elem) /* Free a sequence of type 't' */ #define H5FL_SEQ_FREE(t,obj) H5FL_seq_free(&(H5FL_SEQ_NAME(t)),obj) /* Re-allocate a sequence of type 't' */ #define H5FL_SEQ_REALLOC(t,obj,new_elem) H5FL_seq_realloc(&(H5FL_SEQ_NAME(t)),obj,new_elem) #else /* H5_NO_SEQ_FREE_LISTS */ /* Common macro for H5FL_BLK_DEFINE & H5FL_BLK_DEFINE_STATIC */ #define H5FL_SEQ_DEFINE_COMMON(t) int H5FL_SEQ_NAME(t) #define H5FL_SEQ_DEFINE(t) H5_DLL H5FL_SEQ_DEFINE_COMMON(t) #define H5FL_SEQ_EXTERN(t) extern H5_DLL int H5FL_SEQ_NAME(t) #define H5FL_SEQ_DEFINE_STATIC(t) static H5FL_SEQ_DEFINE_COMMON(t) #define H5FL_SEQ_MALLOC(t,elem) H5MM_malloc((elem)*sizeof(t)) #define H5FL_SEQ_CALLOC(t,elem) H5MM_calloc((elem)*sizeof(t)) #define H5FL_SEQ_FREE(t,obj) H5MM_xfree(obj) #define H5FL_SEQ_REALLOC(t,obj,new_elem) H5MM_realloc(obj,(new_elem)*sizeof(t)) #endif /* H5_NO_SEQ_FREE_LISTS */ /* * Library prototypes. */ H5_DLL void * H5FL_blk_malloc(H5FL_blk_head_t *head, size_t size); H5_DLL void * H5FL_blk_calloc(H5FL_blk_head_t *head, size_t size); H5_DLL void * H5FL_blk_free(H5FL_blk_head_t *head, void *block); H5_DLL void * H5FL_blk_realloc(H5FL_blk_head_t *head, void *block, size_t new_size); H5_DLL htri_t H5FL_blk_free_block_avail(H5FL_blk_head_t *head, size_t size); H5_DLL void * H5FL_reg_malloc(H5FL_reg_head_t *head); H5_DLL void * H5FL_reg_calloc(H5FL_reg_head_t *head); H5_DLL void * H5FL_reg_free(H5FL_reg_head_t *head, void *obj); H5_DLL void * H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem); H5_DLL void * H5FL_arr_calloc(H5FL_arr_head_t *head, size_t elem); H5_DLL void * H5FL_arr_free(H5FL_arr_head_t *head, void *obj); H5_DLL void * H5FL_arr_realloc(H5FL_arr_head_t *head, void *obj, size_t new_elem); H5_DLL void * H5FL_seq_malloc(H5FL_seq_head_t *head, size_t elem); H5_DLL void * H5FL_seq_calloc(H5FL_seq_head_t *head, size_t elem); H5_DLL void * H5FL_seq_free(H5FL_seq_head_t *head, void *obj); H5_DLL void * H5FL_seq_realloc(H5FL_seq_head_t *head, void *obj, size_t new_elem); H5_DLL herr_t H5FL_garbage_coll(void); H5_DLL herr_t H5FL_set_free_list_limits(int reg_global_lim, int reg_list_lim, int arr_global_lim, int arr_list_lim, int blk_global_lim, int blk_list_lim); H5_DLL int H5FL_term_interface(void); #endif xdmf-3.0+git20160803/Utilities/hdf5/H5Dselect.c0000640000175000017500000007141013003006557020622 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* Programmer: Quincey Koziol * Thursday, September 30, 2004 * * Purpose: Dataspace I/O functions. */ #define H5D_PACKAGE /*suppress error about including H5Dpkg */ #include "H5private.h" /* Generic Functions */ #include "H5Dpkg.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free Lists */ /* Declare a free list to manage sequences of size_t */ H5FL_SEQ_DEFINE_STATIC(size_t); /* Declare a free list to manage sequences of hsize_t */ H5FL_SEQ_DEFINE_STATIC(hsize_t); /*------------------------------------------------------------------------- * Function: H5D_select_fscat * * Purpose: Scatters dataset elements from the type conversion buffer BUF * to the file F where the data points are arranged according to * the file dataspace FILE_SPACE and stored according to * LAYOUT and EFL. Each element is ELMT_SIZE bytes. * The caller is requesting that NELMTS elements are copied. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Thursday, June 20, 2002 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5D_select_fscat (H5D_io_info_t *io_info, const H5S_t *space, H5S_sel_iter_t *iter, size_t nelmts, const void *_buf) { const uint8_t *buf=_buf; /* Alias for pointer arithmetic */ hsize_t _off[H5D_XFER_HYPER_VECTOR_SIZE_DEF]; /* Array to store sequence offsets */ hsize_t *off=NULL; /* Pointer to sequence offsets */ hsize_t mem_off; /* Offset in memory */ size_t mem_curr_seq; /* "Current sequence" in memory */ size_t dset_curr_seq; /* "Current sequence" in dataset */ size_t _len[H5D_XFER_HYPER_VECTOR_SIZE_DEF]; /* Array to store sequence lengths */ size_t *len=NULL; /* Array to store sequence lengths */ size_t orig_mem_len, mem_len; /* Length of sequence in memory */ size_t nseq; /* Number of sequences generated */ size_t nelem; /* Number of elements used in sequences */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5D_select_fscat, FAIL); /* Check args */ assert (io_info); assert (space); assert (iter); assert (nelmts>0); assert (_buf); assert(TRUE==H5P_isa_class(io_info->dxpl_id,H5P_DATASET_XFER)); /* Allocate the vector I/O arrays */ if(io_info->dxpl_cache->vec_size!=H5D_XFER_HYPER_VECTOR_SIZE_DEF) { if((len = H5FL_SEQ_MALLOC(size_t,io_info->dxpl_cache->vec_size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O length vector array"); if((off = H5FL_SEQ_MALLOC(hsize_t,io_info->dxpl_cache->vec_size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O offset vector array"); } /* end if */ else { len=_len; off=_off; } /* end else */ /* Loop until all elements are written */ while(nelmts>0) { /* Get list of sequences for selection to write */ if(H5S_SELECT_GET_SEQ_LIST(space,H5S_GET_SEQ_LIST_SORTED,iter,io_info->dxpl_cache->vec_size,nelmts,&nseq,&nelem,off,len)<0) HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed"); /* Reset the current sequence information */ mem_curr_seq=dset_curr_seq=0; orig_mem_len=mem_len=nelem*iter->elmt_size; mem_off=0; /* Write sequence list out */ if ((*io_info->ops.writevv)(io_info, nseq, &dset_curr_seq, len, off, 1, &mem_curr_seq, &mem_len, &mem_off, buf)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_WRITEERROR, FAIL, "write error"); /* Update buffer */ buf += orig_mem_len; /* Decrement number of elements left to process */ nelmts -= nelem; } /* end while */ done: if(io_info->dxpl_cache->vec_size!=H5D_XFER_HYPER_VECTOR_SIZE_DEF) { if(len!=NULL) H5FL_SEQ_FREE(size_t,len); if(off!=NULL) H5FL_SEQ_FREE(hsize_t,off); } /* end if */ FUNC_LEAVE_NOAPI(ret_value); } /* H5D_select_fscat() */ /*------------------------------------------------------------------------- * Function: H5D_select_fgath * * Purpose: Gathers data points from file F and accumulates them in the * type conversion buffer BUF. The LAYOUT argument describes * how the data is stored on disk and EFL describes how the data * is organized in external files. ELMT_SIZE is the size in * bytes of a datum which this function treats as opaque. * FILE_SPACE describes the dataspace of the dataset on disk * and the elements that have been selected for reading (via * hyperslab, etc). This function will copy at most NELMTS * elements. * * Return: Success: Number of elements copied. * Failure: 0 * * Programmer: Quincey Koziol * Monday, June 24, 2002 * * Modifications: * *------------------------------------------------------------------------- */ size_t H5D_select_fgath (H5D_io_info_t *io_info, const H5S_t *space, H5S_sel_iter_t *iter, size_t nelmts, void *_buf/*out*/) { uint8_t *buf=_buf; /* Alias for pointer arithmetic */ hsize_t _off[H5D_XFER_HYPER_VECTOR_SIZE_DEF]; /* Array to store sequence offsets */ hsize_t *off=NULL; /* Pointer to sequence offsets */ hsize_t mem_off; /* Offset in memory */ size_t mem_curr_seq; /* "Current sequence" in memory */ size_t dset_curr_seq; /* "Current sequence" in dataset */ size_t _len[H5D_XFER_HYPER_VECTOR_SIZE_DEF]; /* Array to store sequence lengths */ size_t *len=NULL; /* Pointer to sequence lengths */ size_t orig_mem_len, mem_len; /* Length of sequence in memory */ size_t nseq; /* Number of sequences generated */ size_t nelem; /* Number of elements used in sequences */ size_t ret_value=nelmts; /* Return value */ FUNC_ENTER_NOAPI(H5D_select_fgath, 0); /* Check args */ assert (io_info); assert (io_info->dset); assert (io_info->store); assert (space); assert (iter); assert (nelmts>0); assert (_buf); /* Allocate the vector I/O arrays */ if(io_info->dxpl_cache->vec_size!=H5D_XFER_HYPER_VECTOR_SIZE_DEF) { if((len = H5FL_SEQ_MALLOC(size_t,io_info->dxpl_cache->vec_size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "can't allocate I/O length vector array"); if((off = H5FL_SEQ_MALLOC(hsize_t,io_info->dxpl_cache->vec_size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "can't allocate I/O offset vector array"); } /* end if */ else { len=_len; off=_off; } /* end else */ /* Loop until all elements are read */ while(nelmts>0) { /* Get list of sequences for selection to read */ if(H5S_SELECT_GET_SEQ_LIST(space,H5S_GET_SEQ_LIST_SORTED,iter,io_info->dxpl_cache->vec_size,nelmts,&nseq,&nelem,off,len)<0) HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, 0, "sequence length generation failed"); /* Reset the current sequence information */ mem_curr_seq=dset_curr_seq=0; orig_mem_len=mem_len=nelem*iter->elmt_size; mem_off=0; /* Read sequence list in */ if ((*io_info->ops.readvv)(io_info, nseq, &dset_curr_seq, len, off, 1, &mem_curr_seq, &mem_len, &mem_off, buf)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_READERROR, 0, "read error"); /* Update buffer */ buf += orig_mem_len; /* Decrement number of elements left to process */ nelmts -= nelem; } /* end while */ done: if(io_info->dxpl_cache->vec_size!=H5D_XFER_HYPER_VECTOR_SIZE_DEF) { if(len!=NULL) H5FL_SEQ_FREE(size_t,len); if(off!=NULL) H5FL_SEQ_FREE(hsize_t,off); } /* end if */ FUNC_LEAVE_NOAPI(ret_value); } /* H5D_select_fgath() */ /*------------------------------------------------------------------------- * Function: H5D_select_mscat * * Purpose: Scatters NELMTS data points from the scatter buffer * TSCAT_BUF to the application buffer BUF. Each element is * ELMT_SIZE bytes and they are organized in application memory * according to SPACE. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Monday, July 8, 2002 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5D_select_mscat (const void *_tscat_buf, const H5S_t *space, H5S_sel_iter_t *iter, size_t nelmts, const H5D_dxpl_cache_t *dxpl_cache, void *_buf/*out*/) { uint8_t *buf=(uint8_t *)_buf; /* Get local copies for address arithmetic */ const uint8_t *tscat_buf=(const uint8_t *)_tscat_buf; hsize_t _off[H5D_XFER_HYPER_VECTOR_SIZE_DEF]; /* Array to store sequence offsets */ hsize_t *off=NULL; /* Pointer to sequence offsets */ size_t _len[H5D_XFER_HYPER_VECTOR_SIZE_DEF]; /* Array to store sequence lengths */ size_t *len=NULL; /* Pointer to sequence lengths */ size_t curr_len; /* Length of bytes left to process in sequence */ size_t nseq; /* Number of sequences generated */ size_t curr_seq; /* Current sequence being processed */ size_t nelem; /* Number of elements used in sequences */ herr_t ret_value=SUCCEED; /* Number of elements scattered */ FUNC_ENTER_NOAPI(H5D_select_mscat, FAIL); /* Check args */ assert (tscat_buf); assert (space); assert (iter); assert (nelmts>0); assert (buf); /* Allocate the vector I/O arrays */ if(dxpl_cache->vec_size!=H5D_XFER_HYPER_VECTOR_SIZE_DEF) { if((len = H5FL_SEQ_MALLOC(size_t,dxpl_cache->vec_size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O length vector array"); if((off = H5FL_SEQ_MALLOC(hsize_t,dxpl_cache->vec_size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O offset vector array"); } /* end if */ else { len=_len; off=_off; } /* end else */ /* Loop until all elements are written */ while(nelmts>0) { /* Get list of sequences for selection to write */ if(H5S_SELECT_GET_SEQ_LIST(space,0,iter,dxpl_cache->vec_size,nelmts,&nseq,&nelem,off,len)<0) HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, 0, "sequence length generation failed"); /* Loop, while sequences left to process */ for(curr_seq=0; curr_seqvec_size!=H5D_XFER_HYPER_VECTOR_SIZE_DEF) { if(len!=NULL) H5FL_SEQ_FREE(size_t,len); if(off!=NULL) H5FL_SEQ_FREE(hsize_t,off); } /* end if */ FUNC_LEAVE_NOAPI(ret_value); } /* H5D_select_mscat() */ /*------------------------------------------------------------------------- * Function: H5D_select_mgath * * Purpose: Gathers dataset elements from application memory BUF and * copies them into the gather buffer TGATH_BUF. * Each element is ELMT_SIZE bytes and arranged in application * memory according to SPACE. * The caller is requesting that at most NELMTS be gathered. * * Return: Success: Number of elements copied. * Failure: 0 * * Programmer: Quincey Koziol * Monday, June 24, 2002 * * Modifications: * *------------------------------------------------------------------------- */ size_t H5D_select_mgath (const void *_buf, const H5S_t *space, H5S_sel_iter_t *iter, size_t nelmts, const H5D_dxpl_cache_t *dxpl_cache, void *_tgath_buf/*out*/) { const uint8_t *buf=(const uint8_t *)_buf; /* Get local copies for address arithmetic */ uint8_t *tgath_buf=(uint8_t *)_tgath_buf; hsize_t _off[H5D_XFER_HYPER_VECTOR_SIZE_DEF]; /* Array to store sequence offsets */ hsize_t *off=NULL; /* Pointer to sequence offsets */ size_t _len[H5D_XFER_HYPER_VECTOR_SIZE_DEF]; /* Array to store sequence lengths */ size_t *len=NULL; /* Pointer to sequence lengths */ size_t curr_len; /* Length of bytes left to process in sequence */ size_t nseq; /* Number of sequences generated */ size_t curr_seq; /* Current sequence being processed */ size_t nelem; /* Number of elements used in sequences */ size_t ret_value=nelmts; /* Number of elements gathered */ FUNC_ENTER_NOAPI(H5D_select_mgath, 0); /* Check args */ assert (buf); assert (space); assert (iter); assert (nelmts>0); assert (tgath_buf); /* Allocate the vector I/O arrays */ if(dxpl_cache->vec_size!=H5D_XFER_HYPER_VECTOR_SIZE_DEF) { if((len = H5FL_SEQ_MALLOC(size_t,dxpl_cache->vec_size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "can't allocate I/O length vector array"); if((off = H5FL_SEQ_MALLOC(hsize_t,dxpl_cache->vec_size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "can't allocate I/O offset vector array"); } /* end if */ else { len=_len; off=_off; } /* end else */ /* Loop until all elements are written */ while(nelmts>0) { /* Get list of sequences for selection to write */ if(H5S_SELECT_GET_SEQ_LIST(space,0,iter,dxpl_cache->vec_size,nelmts,&nseq,&nelem,off,len)<0) HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, 0, "sequence length generation failed"); /* Loop, while sequences left to process */ for(curr_seq=0; curr_seqvec_size!=H5D_XFER_HYPER_VECTOR_SIZE_DEF) { if(len!=NULL) H5FL_SEQ_FREE(size_t,len); if(off!=NULL) H5FL_SEQ_FREE(hsize_t,off); } /* end if */ FUNC_LEAVE_NOAPI(ret_value); } /* H5D_select_mgath() */ /*------------------------------------------------------------------------- * Function: H5D_select_read * * Purpose: Reads directly from file into application memory. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Tuesday, July 23, 2002 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5D_select_read(H5D_io_info_t *io_info, size_t nelmts, size_t elmt_size, const H5S_t *file_space, const H5S_t *mem_space, void *buf/*out*/) { H5S_sel_iter_t mem_iter; /* Memory selection iteration info */ hbool_t mem_iter_init=0; /* Memory selection iteration info has been initialized */ H5S_sel_iter_t file_iter; /* File selection iteration info */ hbool_t file_iter_init=0; /* File selection iteration info has been initialized */ hsize_t _mem_off[H5D_XFER_HYPER_VECTOR_SIZE_DEF]; /* Array to store sequence offsets in memory */ hsize_t *mem_off=NULL; /* Pointer to sequence offsets in memory */ hsize_t _file_off[H5D_XFER_HYPER_VECTOR_SIZE_DEF]; /* Array to store sequence offsets in the file */ hsize_t *file_off=NULL; /* Pointer to sequence offsets in the file */ size_t _mem_len[H5D_XFER_HYPER_VECTOR_SIZE_DEF]; /* Array to store sequence lengths in memory */ size_t *mem_len=NULL; /* Pointer to sequence lengths in memory */ size_t _file_len[H5D_XFER_HYPER_VECTOR_SIZE_DEF]; /* Array to store sequence lengths in the file */ size_t *file_len=NULL; /* Pointer to sequence lengths in the file */ size_t mem_nseq; /* Number of sequences generated in the file */ size_t file_nseq; /* Number of sequences generated in memory */ size_t mem_nelem; /* Number of elements used in memory sequences */ size_t file_nelem; /* Number of elements used in file sequences */ size_t curr_mem_seq; /* Current memory sequence to operate on */ size_t curr_file_seq; /* Current file sequence to operate on */ ssize_t tmp_file_len; /* Temporary number of bytes in file sequence */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5D_select_read, FAIL); /* Check args */ assert(io_info); assert(io_info->dset); assert(io_info->dxpl_cache); assert(io_info->store); assert(buf); assert(TRUE==H5P_isa_class(io_info->dxpl_id,H5P_DATASET_XFER)); /* Initialize file iterator */ if (H5S_select_iter_init(&file_iter, file_space, elmt_size)<0) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator"); file_iter_init=1; /* File selection iteration info has been initialized */ /* Initialize memory iterator */ if (H5S_select_iter_init(&mem_iter, mem_space, elmt_size)<0) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator"); mem_iter_init=1; /* Memory selection iteration info has been initialized */ /* Allocate the vector I/O arrays */ if(io_info->dxpl_cache->vec_size!=H5D_XFER_HYPER_VECTOR_SIZE_DEF) { if((mem_len = H5FL_SEQ_MALLOC(size_t,io_info->dxpl_cache->vec_size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O length vector array"); if((mem_off = H5FL_SEQ_MALLOC(hsize_t,io_info->dxpl_cache->vec_size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O offset vector array"); if((file_len = H5FL_SEQ_MALLOC(size_t,io_info->dxpl_cache->vec_size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O length vector array"); if((file_off = H5FL_SEQ_MALLOC(hsize_t,io_info->dxpl_cache->vec_size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O offset vector array"); } /* end if */ else { mem_len=_mem_len; mem_off=_mem_off; file_len=_file_len; file_off=_file_off; } /* end else */ /* Initialize sequence counts */ curr_mem_seq=curr_file_seq=0; mem_nseq=file_nseq=0; /* Loop, until all bytes are processed */ while(nelmts>0) { /* Check if more file sequences are needed */ if(curr_file_seq>=file_nseq) { /* Get sequences for file selection */ if(H5S_SELECT_GET_SEQ_LIST(file_space,H5S_GET_SEQ_LIST_SORTED,&file_iter,io_info->dxpl_cache->vec_size,nelmts,&file_nseq,&file_nelem,file_off,file_len)<0) HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed"); /* Start at the beginning of the sequences again */ curr_file_seq=0; } /* end if */ /* Check if more memory sequences are needed */ if(curr_mem_seq>=mem_nseq) { /* Get sequences for memory selection */ if(H5S_SELECT_GET_SEQ_LIST(mem_space,0,&mem_iter,io_info->dxpl_cache->vec_size,nelmts,&mem_nseq,&mem_nelem,mem_off,mem_len)<0) HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed"); /* Start at the beginning of the sequences again */ curr_mem_seq=0; } /* end if */ /* Read file sequences into current memory sequence */ if ((tmp_file_len=(*io_info->ops.readvv)(io_info, file_nseq, &curr_file_seq, file_len, file_off, mem_nseq, &curr_mem_seq, mem_len, mem_off, buf))<0) HGOTO_ERROR(H5E_DATASPACE, H5E_READERROR, FAIL, "read error"); /* Decrement number of elements left to process */ assert((tmp_file_len%elmt_size)==0); nelmts-=(tmp_file_len/elmt_size); } /* end while */ done: /* Release file selection iterator */ if(file_iter_init) { if (H5S_SELECT_ITER_RELEASE(&file_iter)<0) HDONE_ERROR (H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator"); } /* end if */ /* Release memory selection iterator */ if(mem_iter_init) { if (H5S_SELECT_ITER_RELEASE(&mem_iter)<0) HDONE_ERROR (H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator"); } /* end if */ /* Free vector arrays */ if(io_info->dxpl_cache->vec_size!=H5D_XFER_HYPER_VECTOR_SIZE_DEF) { if(file_len!=NULL) H5FL_SEQ_FREE(size_t,file_len); if(file_off!=NULL) H5FL_SEQ_FREE(hsize_t,file_off); if(mem_len!=NULL) H5FL_SEQ_FREE(size_t,mem_len); if(mem_off!=NULL) H5FL_SEQ_FREE(hsize_t,mem_off); } /* end if */ FUNC_LEAVE_NOAPI(ret_value); } /* end H5D_select_read() */ /*------------------------------------------------------------------------- * Function: H5D_select_write * * Purpose: Writes directly from application memory into a file * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Tuesday, July 23, 2002 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5D_select_write(H5D_io_info_t *io_info, size_t nelmts, size_t elmt_size, const H5S_t *file_space, const H5S_t *mem_space, const void *buf/*out*/) { H5S_sel_iter_t mem_iter; /* Memory selection iteration info */ hbool_t mem_iter_init=0; /* Memory selection iteration info has been initialized */ H5S_sel_iter_t file_iter; /* File selection iteration info */ hbool_t file_iter_init=0; /* File selection iteration info has been initialized */ hsize_t _mem_off[H5D_XFER_HYPER_VECTOR_SIZE_DEF]; /* Array to store sequence offsets in memory */ hsize_t *mem_off=NULL; /* Pointer to sequence offsets in memory */ hsize_t _file_off[H5D_XFER_HYPER_VECTOR_SIZE_DEF]; /* Array to store sequence offsets in the file */ hsize_t *file_off=NULL; /* Pointer to sequence offsets in the file */ size_t _mem_len[H5D_XFER_HYPER_VECTOR_SIZE_DEF]; /* Array to store sequence lengths in memory */ size_t *mem_len=NULL; /* Pointer to sequence lengths in memory */ size_t _file_len[H5D_XFER_HYPER_VECTOR_SIZE_DEF]; /* Array to store sequence lengths in the file */ size_t *file_len=NULL; /* Pointer to sequence lengths in the file */ size_t mem_nseq; /* Number of sequences generated in the file */ size_t file_nseq; /* Number of sequences generated in memory */ size_t mem_nelem; /* Number of elements used in memory sequences */ size_t file_nelem; /* Number of elements used in file sequences */ size_t curr_mem_seq; /* Current memory sequence to operate on */ size_t curr_file_seq; /* Current file sequence to operate on */ ssize_t tmp_file_len; /* Temporary number of bytes in file sequence */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5D_select_write, FAIL); /* Check args */ assert(io_info); assert(io_info->dset); assert(io_info->store); assert(TRUE==H5P_isa_class(io_info->dxpl_id,H5P_DATASET_XFER)); assert(buf); /* Allocate the vector I/O arrays */ if(io_info->dxpl_cache->vec_size!=H5D_XFER_HYPER_VECTOR_SIZE_DEF) { if((mem_len = H5FL_SEQ_MALLOC(size_t,io_info->dxpl_cache->vec_size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O length vector array"); if((mem_off = H5FL_SEQ_MALLOC(hsize_t,io_info->dxpl_cache->vec_size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O offset vector array"); if((file_len = H5FL_SEQ_MALLOC(size_t,io_info->dxpl_cache->vec_size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O length vector array"); if((file_off = H5FL_SEQ_MALLOC(hsize_t,io_info->dxpl_cache->vec_size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O offset vector array"); } /* end if */ else { mem_len=_mem_len; mem_off=_mem_off; file_len=_file_len; file_off=_file_off; } /* end else */ /* Initialize file iterator */ if (H5S_select_iter_init(&file_iter, file_space, elmt_size)<0) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator"); file_iter_init=1; /* File selection iteration info has been initialized */ /* Initialize memory iterator */ if (H5S_select_iter_init(&mem_iter, mem_space, elmt_size)<0) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator"); mem_iter_init=1; /* Memory selection iteration info has been initialized */ /* Initialize sequence counts */ curr_mem_seq=curr_file_seq=0; mem_nseq=file_nseq=0; /* Loop, until all bytes are processed */ while(nelmts>0) { /* Check if more file sequences are needed */ if(curr_file_seq>=file_nseq) { /* Get sequences for file selection */ if(H5S_SELECT_GET_SEQ_LIST(file_space,H5S_GET_SEQ_LIST_SORTED,&file_iter,io_info->dxpl_cache->vec_size,nelmts,&file_nseq,&file_nelem,file_off,file_len)<0) HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed"); /* Start at the beginning of the sequences again */ curr_file_seq=0; } /* end if */ /* Check if more memory sequences are needed */ if(curr_mem_seq>=mem_nseq) { /* Get sequences for memory selection */ if(H5S_SELECT_GET_SEQ_LIST(mem_space,0,&mem_iter,io_info->dxpl_cache->vec_size,nelmts,&mem_nseq,&mem_nelem,mem_off,mem_len)<0) HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed"); /* Start at the beginning of the sequences again */ curr_mem_seq=0; } /* end if */ /* Write memory sequences into file sequences */ if ((tmp_file_len=(*io_info->ops.writevv)(io_info, file_nseq, &curr_file_seq, file_len, file_off, mem_nseq, &curr_mem_seq, mem_len, mem_off, buf))<0) HGOTO_ERROR(H5E_DATASPACE, H5E_WRITEERROR, FAIL, "write error"); /* Decrement number of elements left to process */ assert((tmp_file_len%elmt_size)==0); nelmts-=(tmp_file_len/elmt_size); } /* end while */ done: /* Release file selection iterator */ if(file_iter_init) { if (H5S_SELECT_ITER_RELEASE(&file_iter)<0) HDONE_ERROR (H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator"); } /* end if */ /* Release memory selection iterator */ if(mem_iter_init) { if (H5S_SELECT_ITER_RELEASE(&mem_iter)<0) HDONE_ERROR (H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator"); } /* end if */ /* Free vector arrays */ if(io_info->dxpl_cache->vec_size!=H5D_XFER_HYPER_VECTOR_SIZE_DEF) { if(file_len!=NULL) H5FL_SEQ_FREE(size_t,file_len); if(file_off!=NULL) H5FL_SEQ_FREE(hsize_t,file_off); if(mem_len!=NULL) H5FL_SEQ_FREE(size_t,mem_len); if(mem_off!=NULL) H5FL_SEQ_FREE(hsize_t,mem_off); } /* end if */ FUNC_LEAVE_NOAPI(ret_value); } /* end H5D_select_write() */ xdmf-3.0+git20160803/Utilities/hdf5/H5Ppublic.h0000640000175000017500000003432013003006557020641 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * This file contains function prototypes for each exported function in the * H5P module. */ #ifndef _H5Ppublic_H #define _H5Ppublic_H /* Default Template for creation, access, etc. templates */ #define H5P_DEFAULT 0 /* Public headers needed by this file */ #include "H5public.h" #include "H5Ipublic.h" #include "H5Dpublic.h" #include "H5Fpublic.h" #include "H5FDpublic.h" #include "H5MMpublic.h" #include "H5Zpublic.h" /* Metroworks doesn't define off_t. */ #ifdef __MWERKS__ typedef long off_t; /* Metroworks does not define EINTR in */ # define EINTR 4 #endif /*__MWERKS__*/ #ifdef H5_WANT_H5_V1_4_COMPAT /* Backward compatibility typedef... */ typedef hid_t H5P_class_t; /* Alias H5P_class_t to hid_t */ /* H5P_DATASET_XFER was the name from the beginning through 1.2. It was * changed to H5P_DATA_XFER on v1.3.0. Then it was changed back to * H5P_DATASET_XFER right before the release of v1.4.0-beta2. * Define an alias here to help applications that had ported to v1.3. * Should be removed in later version. */ #define H5P_DATA_XFER H5P_DATASET_XFER #endif /* H5_WANT_H5_V1_4_COMPAT */ #ifdef __cplusplus extern "C" { #endif /* Define property list class callback function pointer types */ typedef herr_t (*H5P_cls_create_func_t)(hid_t prop_id, void *create_data); typedef herr_t (*H5P_cls_copy_func_t)(hid_t new_prop_id, hid_t old_prop_id, void *copy_data); typedef herr_t (*H5P_cls_close_func_t)(hid_t prop_id, void *close_data); /* Define property list callback function pointer types */ typedef herr_t (*H5P_prp_cb1_t)(const char *name, size_t size, void *value); typedef herr_t (*H5P_prp_cb2_t)(hid_t prop_id, const char *name, size_t size, void *value); typedef H5P_prp_cb1_t H5P_prp_create_func_t; typedef H5P_prp_cb2_t H5P_prp_set_func_t; typedef H5P_prp_cb2_t H5P_prp_get_func_t; typedef H5P_prp_cb2_t H5P_prp_delete_func_t; typedef H5P_prp_cb1_t H5P_prp_copy_func_t; typedef int (*H5P_prp_compare_func_t)(const void *value1, const void *value2, size_t size); typedef H5P_prp_cb1_t H5P_prp_close_func_t; /* Define property list iteration function type */ typedef herr_t (*H5P_iterate_t)(hid_t id, const char *name, void *iter_data); /* * The library created property list classes * * NOTE: When adding H5P_* macros, remember to redefine them in H5Pprivate.h * */ /* When this header is included from a private header, don't make calls to H5open() */ #undef H5OPEN #ifndef _H5private_H #define H5OPEN H5open(), #else /* _H5private_H */ #define H5OPEN #endif /* _H5private_H */ #define H5P_NO_CLASS (H5OPEN H5P_CLS_NO_CLASS_g) #define H5P_FILE_CREATE (H5OPEN H5P_CLS_FILE_CREATE_g) #define H5P_FILE_ACCESS (H5OPEN H5P_CLS_FILE_ACCESS_g) #define H5P_DATASET_CREATE (H5OPEN H5P_CLS_DATASET_CREATE_g) #define H5P_DATASET_XFER (H5OPEN H5P_CLS_DATASET_XFER_g) #define H5P_MOUNT (H5OPEN H5P_CLS_MOUNT_g) H5_DLLVAR hid_t H5P_CLS_NO_CLASS_g; H5_DLLVAR hid_t H5P_CLS_FILE_CREATE_g; H5_DLLVAR hid_t H5P_CLS_FILE_ACCESS_g; H5_DLLVAR hid_t H5P_CLS_DATASET_CREATE_g; H5_DLLVAR hid_t H5P_CLS_DATASET_XFER_g; H5_DLLVAR hid_t H5P_CLS_MOUNT_g; /* * The library created default property lists * * NOTE: When adding H5P_* macros, remember to redefine them in H5Pprivate.h * */ #define H5P_NO_CLASS_DEFAULT (H5OPEN H5P_LST_NO_CLASS_g) #define H5P_FILE_CREATE_DEFAULT (H5OPEN H5P_LST_FILE_CREATE_g) #define H5P_FILE_ACCESS_DEFAULT (H5OPEN H5P_LST_FILE_ACCESS_g) #define H5P_DATASET_CREATE_DEFAULT (H5OPEN H5P_LST_DATASET_CREATE_g) #define H5P_DATASET_XFER_DEFAULT (H5OPEN H5P_LST_DATASET_XFER_g) #define H5P_MOUNT_DEFAULT (H5OPEN H5P_LST_MOUNT_g) H5_DLLVAR hid_t H5P_LST_NO_CLASS_g; H5_DLLVAR hid_t H5P_LST_FILE_CREATE_g; H5_DLLVAR hid_t H5P_LST_FILE_ACCESS_g; H5_DLLVAR hid_t H5P_LST_DATASET_CREATE_g; H5_DLLVAR hid_t H5P_LST_DATASET_XFER_g; H5_DLLVAR hid_t H5P_LST_MOUNT_g; /* Public functions */ H5_DLL hid_t H5Pcreate_class(hid_t parent, const char *name, H5P_cls_create_func_t cls_create, void *create_data, H5P_cls_copy_func_t cls_copy, void *copy_data, H5P_cls_close_func_t cls_close, void *close_data); H5_DLL char *H5Pget_class_name(hid_t pclass_id); H5_DLL hid_t H5Pcreate(hid_t cls_id); H5_DLL herr_t H5Pregister(hid_t cls_id, const char *name, size_t size, void *def_value, H5P_prp_create_func_t prp_create, H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get, H5P_prp_delete_func_t prp_del, H5P_prp_copy_func_t prp_copy, H5P_prp_close_func_t prp_close); H5_DLL herr_t H5Pinsert(hid_t plist_id, const char *name, size_t size, void *value, H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get, H5P_prp_delete_func_t prp_delete, H5P_prp_copy_func_t prp_copy, H5P_prp_close_func_t prp_close); H5_DLL herr_t H5Pset(hid_t plist_id, const char *name, void *value); H5_DLL htri_t H5Pexist(hid_t plist_id, const char *name); H5_DLL herr_t H5Pget_size(hid_t id, const char *name, size_t *size); H5_DLL herr_t H5Pget_nprops(hid_t id, size_t *nprops); H5_DLL hid_t H5Pget_class(hid_t plist_id); H5_DLL hid_t H5Pget_class_parent(hid_t pclass_id); H5_DLL herr_t H5Pget(hid_t plist_id, const char *name, void * value); H5_DLL htri_t H5Pequal(hid_t id1, hid_t id2); H5_DLL htri_t H5Pisa_class(hid_t plist_id, hid_t pclass_id); H5_DLL int H5Piterate(hid_t id, int *idx, H5P_iterate_t iter_func, void *iter_data); H5_DLL herr_t H5Pcopy_prop(hid_t dst_id, hid_t src_id, const char *name); H5_DLL herr_t H5Premove(hid_t plist_id, const char *name); H5_DLL herr_t H5Punregister(hid_t pclass_id, const char *name); H5_DLL herr_t H5Pclose_class(hid_t plist_id); H5_DLL herr_t H5Pclose(hid_t plist_id); H5_DLL hid_t H5Pcopy(hid_t plist_id); H5_DLL herr_t H5Pget_version(hid_t plist_id, unsigned *boot/*out*/, unsigned *freelist/*out*/, unsigned *stab/*out*/, unsigned *shhdr/*out*/); H5_DLL herr_t H5Pset_userblock(hid_t plist_id, hsize_t size); H5_DLL herr_t H5Pget_userblock(hid_t plist_id, hsize_t *size); H5_DLL herr_t H5Pset_alignment(hid_t fapl_id, hsize_t threshold, hsize_t alignment); H5_DLL herr_t H5Pget_alignment(hid_t fapl_id, hsize_t *threshold/*out*/, hsize_t *alignment/*out*/); H5_DLL herr_t H5Pset_sizes(hid_t plist_id, size_t sizeof_addr, size_t sizeof_size); H5_DLL herr_t H5Pget_sizes(hid_t plist_id, size_t *sizeof_addr/*out*/, size_t *sizeof_size/*out*/); #ifdef H5_WANT_H5_V1_4_COMPAT H5_DLL herr_t H5Pset_sym_k(hid_t plist_id, int ik, int lk); H5_DLL herr_t H5Pget_sym_k(hid_t plist_id, int *ik/*out*/, int *lk/*out*/); #else /* H5_WANT_H5_V1_4_COMPAT */ H5_DLL herr_t H5Pset_sym_k(hid_t plist_id, unsigned ik, unsigned lk); H5_DLL herr_t H5Pget_sym_k(hid_t plist_id, unsigned *ik/*out*/, unsigned *lk/*out*/); #endif /* H5_WANT_H5_V1_4_COMPAT */ H5_DLL herr_t H5Pset_istore_k(hid_t plist_id, unsigned ik); H5_DLL herr_t H5Pget_istore_k(hid_t plist_id, unsigned *ik/*out*/); H5_DLL herr_t H5Pset_layout(hid_t plist_id, H5D_layout_t layout); H5_DLL H5D_layout_t H5Pget_layout(hid_t plist_id); H5_DLL herr_t H5Pset_chunk(hid_t plist_id, int ndims, const hsize_t dim[]); H5_DLL int H5Pget_chunk(hid_t plist_id, int max_ndims, hsize_t dim[]/*out*/); H5_DLL herr_t H5Pset_external(hid_t plist_id, const char *name, off_t offset, hsize_t size); H5_DLL int H5Pget_external_count(hid_t plist_id); H5_DLL herr_t H5Pget_external(hid_t plist_id, unsigned idx, size_t name_size, char *name/*out*/, off_t *offset/*out*/, hsize_t *size/*out*/); H5_DLL herr_t H5Pset_driver(hid_t plist_id, hid_t driver_id, const void *driver_info); H5_DLL hid_t H5Pget_driver(hid_t plist_id); H5_DLL void *H5Pget_driver_info(hid_t plist_id); H5_DLL herr_t H5Pset_family_offset(hid_t fapl_id, hsize_t offset); H5_DLL herr_t H5Pget_family_offset(hid_t fapl_id, hsize_t *offset); H5_DLL herr_t H5Pset_multi_type(hid_t fapl_id, H5FD_mem_t type); H5_DLL herr_t H5Pget_multi_type(hid_t fapl_id, H5FD_mem_t *type); #ifdef H5_WANT_H5_V1_4_COMPAT H5_DLL herr_t H5Pset_buffer(hid_t plist_id, hsize_t size, void *tconv, void *bkg); H5_DLL hsize_t H5Pget_buffer(hid_t plist_id, void **tconv/*out*/, void **bkg/*out*/); #else /* H5_WANT_H5_V1_4_COMPAT */ H5_DLL herr_t H5Pset_buffer(hid_t plist_id, size_t size, void *tconv, void *bkg); H5_DLL size_t H5Pget_buffer(hid_t plist_id, void **tconv/*out*/, void **bkg/*out*/); #endif /* H5_WANT_H5_V1_4_COMPAT */ H5_DLL herr_t H5Pset_preserve(hid_t plist_id, hbool_t status); H5_DLL int H5Pget_preserve(hid_t plist_id); H5_DLL herr_t H5Pmodify_filter(hid_t plist_id, H5Z_filter_t filter, unsigned int flags, size_t cd_nelmts, const unsigned int cd_values[/*cd_nelmts*/]); H5_DLL herr_t H5Pset_filter(hid_t plist_id, H5Z_filter_t filter, unsigned int flags, size_t cd_nelmts, const unsigned int c_values[]); H5_DLL int H5Pget_nfilters(hid_t plist_id); H5_DLL H5Z_filter_t H5Pget_filter(hid_t plist_id, unsigned filter, unsigned int *flags/*out*/, size_t *cd_nelmts/*out*/, unsigned cd_values[]/*out*/, size_t namelen, char name[]); H5_DLL H5Z_filter_t H5Pget_filter_by_id(hid_t plist_id, H5Z_filter_t id, unsigned int *flags/*out*/, size_t *cd_nelmts/*out*/, unsigned cd_values[]/*out*/, size_t namelen, char name[]); H5_DLL htri_t H5Pall_filters_avail(hid_t plist_id); H5_DLL herr_t H5Pset_deflate(hid_t plist_id, unsigned aggression); H5_DLL herr_t H5Pset_szip(hid_t plist_id, unsigned options_mask, unsigned pixels_per_block); H5_DLL herr_t H5Pset_shuffle(hid_t plist_id); H5_DLL herr_t H5Pset_fletcher32(hid_t plist_id); H5_DLL herr_t H5Pset_edc_check(hid_t plist_id, H5Z_EDC_t check); H5_DLL H5Z_EDC_t H5Pget_edc_check(hid_t plist_id); H5_DLL herr_t H5Pset_filter_callback(hid_t plist_id, H5Z_filter_func_t func, void* op_data); #ifdef H5_WANT_H5_V1_4_COMPAT H5_DLL herr_t H5Pset_cache(hid_t plist_id, int mdc_nelmts, int rdcc_nelmts, size_t rdcc_nbytes, double rdcc_w0); H5_DLL herr_t H5Pget_cache(hid_t plist_id, int *mdc_nelmts/*out*/, int *rdcc_nelmts/*out*/, size_t *rdcc_nbytes/*out*/, double *rdcc_w0); #else /* H5_WANT_H5_V1_4_COMPAT */ H5_DLL herr_t H5Pset_cache(hid_t plist_id, int mdc_nelmts, size_t rdcc_nelmts, size_t rdcc_nbytes, double rdcc_w0); H5_DLL herr_t H5Pget_cache(hid_t plist_id, int *mdc_nelmts/*out*/, size_t *rdcc_nelmts/*out*/, size_t *rdcc_nbytes/*out*/, double *rdcc_w0); #endif /* H5_WANT_H5_V1_4_COMPAT */ #ifdef H5_WANT_H5_V1_4_COMPAT H5_DLL herr_t H5Pset_hyper_cache(hid_t plist_id, unsigned cache, unsigned limit); H5_DLL herr_t H5Pget_hyper_cache(hid_t plist_id, unsigned *cache, unsigned *limit); #endif /* H5_WANT_H5_V1_4_COMPAT */ H5_DLL herr_t H5Pset_btree_ratios(hid_t plist_id, double left, double middle, double right); H5_DLL herr_t H5Pget_btree_ratios(hid_t plist_id, double *left/*out*/, double *middle/*out*/, double *right/*out*/); H5_DLL herr_t H5Pset_fill_value(hid_t plist_id, hid_t type_id, const void *value); H5_DLL herr_t H5Pget_fill_value(hid_t plist_id, hid_t type_id, void *value/*out*/); H5_DLL herr_t H5Pfill_value_defined(hid_t plist, H5D_fill_value_t *status); H5_DLL herr_t H5Pset_alloc_time(hid_t plist_id, H5D_alloc_time_t alloc_time); H5_DLL herr_t H5Pget_alloc_time(hid_t plist_id, H5D_alloc_time_t *alloc_time/*out*/); H5_DLL herr_t H5Pset_fill_time(hid_t plist_id, H5D_fill_time_t fill_time); H5_DLL herr_t H5Pget_fill_time(hid_t plist_id, H5D_fill_time_t *fill_time/*out*/); H5_DLL herr_t H5Pset_gc_references(hid_t fapl_id, unsigned gc_ref); H5_DLL herr_t H5Pget_gc_references(hid_t fapl_id, unsigned *gc_ref/*out*/); H5_DLL herr_t H5Pset_fclose_degree(hid_t fapl_id, H5F_close_degree_t degree); H5_DLL herr_t H5Pget_fclose_degree(hid_t fapl_id, H5F_close_degree_t *degree); H5_DLL herr_t H5Pset_vlen_mem_manager(hid_t plist_id, H5MM_allocate_t alloc_func, void *alloc_info, H5MM_free_t free_func, void *free_info); H5_DLL herr_t H5Pget_vlen_mem_manager(hid_t plist_id, H5MM_allocate_t *alloc_func, void **alloc_info, H5MM_free_t *free_func, void **free_info); H5_DLL herr_t H5Pset_meta_block_size(hid_t fapl_id, hsize_t size); H5_DLL herr_t H5Pget_meta_block_size(hid_t fapl_id, hsize_t *size/*out*/); #ifdef H5_WANT_H5_V1_4_COMPAT H5_DLL herr_t H5Pset_sieve_buf_size(hid_t fapl_id, hsize_t size); H5_DLL herr_t H5Pget_sieve_buf_size(hid_t fapl_id, hsize_t *size/*out*/); #else /* H5_WANT_H5_V1_4_COMPAT */ H5_DLL herr_t H5Pset_sieve_buf_size(hid_t fapl_id, size_t size); H5_DLL herr_t H5Pget_sieve_buf_size(hid_t fapl_id, size_t *size/*out*/); #endif /* H5_WANT_H5_V1_4_COMPAT */ H5_DLL herr_t H5Pset_hyper_vector_size(hid_t fapl_id, size_t size); H5_DLL herr_t H5Pget_hyper_vector_size(hid_t fapl_id, size_t *size/*out*/); H5_DLL herr_t H5Pset_small_data_block_size(hid_t fapl_id, hsize_t size); H5_DLL herr_t H5Pget_small_data_block_size(hid_t fapl_id, hsize_t *size/*out*/); H5_DLL herr_t H5Premove_filter(hid_t plist_id, H5Z_filter_t filter); #ifdef __cplusplus } #endif #endif xdmf-3.0+git20160803/Utilities/hdf5/H5Topaque.c0000640000175000017500000001116213003006557020653 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Module Info: This module contains the functionality for opaque * datatypes in the H5T interface. */ #define H5T_PACKAGE /*suppress error about including H5Tpkg */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5T_init_opaque_interface #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Tpkg.h" /* Datatypes */ /*-------------------------------------------------------------------------- NAME H5T_init_opaque_interface -- Initialize interface-specific information USAGE herr_t H5T_init_opaque_interface() RETURNS Non-negative on success/Negative on failure DESCRIPTION Initializes any interface-specific data or routines. (Just calls H5T_init_iterface currently). --------------------------------------------------------------------------*/ static herr_t H5T_init_opaque_interface(void) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_init_opaque_interface) FUNC_LEAVE_NOAPI(H5T_init()) } /* H5T_init_opaque_interface() */ /*------------------------------------------------------------------------- * Function: H5Tset_tag * * Purpose: Tag an opaque datatype with a unique ASCII identifier. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Thursday, May 20, 1999 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Tset_tag(hid_t type_id, const char *tag) { H5T_t *dt=NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Tset_tag, FAIL) H5TRACE2("e","is",type_id,tag); /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") if (H5T_STATE_TRANSIENT!=dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only") while (dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ if (H5T_OPAQUE!=dt->shared->type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an opaque data type") if (!tag) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no tag") if (HDstrlen(tag) >= H5T_OPAQUE_TAG_MAX) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "tag too long") /* Commit */ H5MM_xfree(dt->shared->u.opaque.tag); dt->shared->u.opaque.tag = H5MM_strdup(tag); done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5Tget_tag * * Purpose: Get tha tag associated with an opaque datatype. * * Return: A pointer to an allocated string. The caller should free * the string. NULL is returned for errors. * * Programmer: Robb Matzke * Thursday, May 20, 1999 * * Modifications: * *------------------------------------------------------------------------- */ char * H5Tget_tag(hid_t type_id) { H5T_t *dt=NULL; char *ret_value; FUNC_ENTER_API(H5Tget_tag, NULL) /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type") while (dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ if (H5T_OPAQUE != dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "operation not defined for data type class") /* result */ if (NULL==(ret_value=H5MM_strdup(dt->shared->u.opaque.tag))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") done: FUNC_LEAVE_API(ret_value) } xdmf-3.0+git20160803/Utilities/hdf5/H5O.c0000640000175000017500000040121213003006557017432 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*------------------------------------------------------------------------- * * Created: H5O.c * Aug 5 1997 * Robb Matzke * * Purpose: Object header virtual functions. * * Modifications: * *------------------------------------------------------------------------- */ #define H5F_PACKAGE /*suppress error about including H5Fpkg */ #define H5O_PACKAGE /*suppress error about including H5Opkg */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5O_init_interface #include "H5private.h" /* Generic Functions */ #include "H5ACprivate.h" /* Metadata cache */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* File access */ #include "H5FLprivate.h" /* Free lists */ #include "H5Iprivate.h" /* IDs */ #include "H5MFprivate.h" /* File memory management */ #include "H5MMprivate.h" /* Memory management */ #include "H5Opkg.h" /* Object headers */ #include "H5Pprivate.h" /* Property lists */ #ifdef H5_HAVE_GETTIMEOFDAY #include #endif /* H5_HAVE_GETTIMEOFDAY */ /* Private typedefs */ /* User data for iteration while removing a message */ typedef struct { H5F_t *f; /* Pointer to file for insertion */ hid_t dxpl_id; /* DXPL during iteration */ int sequence; /* Sequence # to search for */ unsigned nfailed; /* # of failed message removals */ H5O_operator_t op; /* Callback routine for removal operations */ void *op_data; /* Callback data for removal operations */ hbool_t adj_link; /* Whether to adjust links when removing messages */ } H5O_iter_ud1_t; /* Typedef for "internal" iteration operations */ typedef herr_t (*H5O_operator_int_t)(H5O_mesg_t *mesg/*in,out*/, unsigned idx, unsigned * oh_flags_ptr, void *operator_data/*in,out*/); /* PRIVATE PROTOTYPES */ static herr_t H5O_init(H5F_t *f, hid_t dxpl_id, size_t size_hint, H5G_entry_t *ent/*out*/, haddr_t header); static herr_t H5O_reset_real(const H5O_class_t *type, void *native); static herr_t H5O_free_mesg(H5O_mesg_t *mesg); static void * H5O_copy_real(const H5O_class_t *type, const void *mesg, void *dst); static int H5O_count_real (H5G_entry_t *ent, const H5O_class_t *type, hid_t dxpl_id); static htri_t H5O_exists_real(H5G_entry_t *ent, const H5O_class_t *type, int sequence, hid_t dxpl_id); #ifdef NOT_YET static herr_t H5O_share(H5F_t *f, hid_t dxpl_id, const H5O_class_t *type, const void *mesg, H5HG_t *hobj/*out*/); #endif /* NOT_YET */ static unsigned H5O_find_in_ohdr(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_class_t **type_p, int sequence); static int H5O_modify_real(H5G_entry_t *ent, const H5O_class_t *type, int overwrite, unsigned flags, unsigned update_flags, const void *mesg, hid_t dxpl_id); static int H5O_append_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_class_t *type, unsigned flags, const void *mesg); static herr_t H5O_remove_real(H5G_entry_t *ent, const H5O_class_t *type, int sequence, H5O_operator_t op, void *op_data, hbool_t adj_link, hid_t dxpl_id); static unsigned H5O_alloc(H5F_t *f, H5O_t *oh, const H5O_class_t *type, size_t size); static unsigned H5O_alloc_extend_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno, size_t size); static unsigned H5O_alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size); static herr_t H5O_delete_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh); static herr_t H5O_delete_mesg(H5F_t *f, hid_t dxpl_id, H5O_mesg_t *mesg, hbool_t adj_link); static unsigned H5O_new_mesg(H5F_t *f, H5O_t *oh, unsigned *flags, const H5O_class_t *orig_type, const void *orig_mesg, H5O_shared_t *sh_mesg, const H5O_class_t **new_type, const void **new_mesg, hid_t dxpl_id); static herr_t H5O_write_mesg(H5O_t *oh, unsigned idx, const H5O_class_t *type, const void *mesg, unsigned flags, unsigned update_flags); static herr_t H5O_iterate_real(const H5G_entry_t *ent, const H5O_class_t *type, H5AC_protect_t prot, hbool_t internal, void *op, void *op_data, hid_t dxpl_id); /* Metadata cache callbacks */ static H5O_t *H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_udata1, void *_udata2); static herr_t H5O_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5O_t *oh); static herr_t H5O_dest(H5F_t *f, H5O_t *oh); static herr_t H5O_clear(H5F_t *f, H5O_t *oh, hbool_t destroy); static herr_t H5O_compute_size(const H5F_t *f, const H5O_t *oh, size_t *size_ptr); /* H5O inherits cache-like properties from H5AC */ static const H5AC_class_t H5AC_OHDR[1] = {{ H5AC_OHDR_ID, (H5AC_load_func_t)H5O_load, (H5AC_flush_func_t)H5O_flush, (H5AC_dest_func_t)H5O_dest, (H5AC_clear_func_t)H5O_clear, (H5AC_size_func_t)H5O_compute_size, }}; /* ID to type mapping */ static const H5O_class_t *const message_type_g[] = { H5O_NULL, /*0x0000 Null */ H5O_SDSPACE, /*0x0001 Simple Dimensionality */ NULL, /*0x0002 Data space (fiber bundle?) */ H5O_DTYPE, /*0x0003 Data Type */ H5O_FILL, /*0x0004 Old data storage -- fill value */ H5O_FILL_NEW, /*0x0005 New Data storage -- fill value */ NULL, /*0x0006 Data storage -- compact object */ H5O_EFL, /*0x0007 Data storage -- external data files */ H5O_LAYOUT, /*0x0008 Data Layout */ #ifdef H5O_ENABLE_BOGUS H5O_BOGUS, /*0x0009 "Bogus" */ #else /* H5O_ENABLE_BOGUS */ NULL, /*0x0009 "Bogus" */ #endif /* H5O_ENABLE_BOGUS */ NULL, /*0x000A Not assigned */ H5O_PLINE, /*0x000B Data storage -- filter pipeline */ H5O_ATTR, /*0x000C Attribute list */ H5O_NAME, /*0x000D Object name */ H5O_MTIME, /*0x000E Object modification date and time */ H5O_SHARED, /*0x000F Shared header message */ H5O_CONT, /*0x0010 Object header continuation */ H5O_STAB, /*0x0011 Symbol table */ H5O_MTIME_NEW, /*0x0012 New Object modification date and time */ }; /* * An array of functions indexed by symbol table entry cache type * (H5G_type_t) that are called to retrieve constant messages cached in the * symbol table entry. */ static void *(*H5O_fast_g[H5G_NCACHED]) (const H5G_cache_t *, const H5O_class_t *, void *); /* Declare a free list to manage the H5O_t struct */ H5FL_DEFINE_STATIC(H5O_t); /* Declare a free list to manage the H5O_mesg_t sequence information */ H5FL_SEQ_DEFINE_STATIC(H5O_mesg_t); /* Declare a free list to manage the H5O_chunk_t sequence information */ H5FL_SEQ_DEFINE_STATIC(H5O_chunk_t); /* Declare a free list to manage the chunk image information */ H5FL_BLK_DEFINE_STATIC(chunk_image); /* Declare external the free list for time_t's */ H5FL_EXTERN(time_t); /* Declare extern the free list for H5O_cont_t's */ H5FL_EXTERN(H5O_cont_t); /*------------------------------------------------------------------------- * Function: H5O_init_interface * * Purpose: Initialize the H5O interface. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Tuesday, January 6, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_init_interface(void) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_init_interface); /* * Initialize functions that decode messages from symbol table entries. */ H5O_fast_g[H5G_CACHED_STAB] = H5O_stab_fast; FUNC_LEAVE_NOAPI(SUCCEED); } /*------------------------------------------------------------------------- * Function: H5O_create * * Purpose: Creates a new object header. Allocates space for it and * then calls an initialization function. The object header * is opened for write access and should eventually be * closed by calling H5O_close(). * * Return: Success: Non-negative, the ENT argument contains * information about the object header, * including its address. * * Failure: Negative * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 5 1997 * * Modifications: * * Bill Wendling, 1. November 2002 * Separated the create function into two different functions. One * which allocates space and an initialization function which * does the rest of the work (initializes, caches, and opens the * object header). * *------------------------------------------------------------------------- */ herr_t H5O_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, H5G_entry_t *ent/*out*/) { haddr_t header; herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_NOAPI(H5O_create, FAIL); /* check args */ assert(f); assert(ent); size_hint = H5O_ALIGN (MAX (H5O_MIN_SIZE, size_hint)); /* allocate disk space for header and first chunk */ if (HADDR_UNDEF == (header = H5MF_alloc(f, H5FD_MEM_OHDR, dxpl_id, (hsize_t)H5O_SIZEOF_HDR(f) + size_hint))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for object header header"); /* initialize the object header */ if (H5O_init(f, dxpl_id, size_hint, ent, header) != SUCCEED) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to initialize object header"); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_init * * Purpose: Initialize a new object header, sets the link count to 0, * and caches the header. The object header is opened for * write access and should eventually be closed by calling * H5O_close(). * * Return: Success: SUCCEED, the ENT argument contains * information about the object header, * including its address. * Failure: FAIL * * Programmer: Bill Wendling * 1, November 2002 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_init(H5F_t *f, hid_t dxpl_id, size_t size_hint, H5G_entry_t *ent/*out*/, haddr_t header) { H5O_t *oh = NULL; haddr_t tmp_addr; herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_init); /* check args */ assert(f); assert(ent); size_hint = H5O_ALIGN(MAX(H5O_MIN_SIZE, size_hint)); ent->file = f; ent->header = header; /* allocate the object header and fill in header fields */ if (NULL == (oh = H5FL_MALLOC(H5O_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); oh->cache_info.is_dirty = TRUE; oh->version = H5O_VERSION; oh->nlink = 0; /* create the chunk list and initialize the first chunk */ oh->nchunks = 1; oh->alloc_nchunks = H5O_NCHUNKS; if (NULL == (oh->chunk = H5FL_SEQ_MALLOC(H5O_chunk_t, (size_t)oh->alloc_nchunks))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); tmp_addr = ent->header + (hsize_t)H5O_SIZEOF_HDR(f); oh->chunk[0].dirty = TRUE; oh->chunk[0].addr = tmp_addr; oh->chunk[0].size = size_hint; if (NULL == (oh->chunk[0].image = H5FL_BLK_CALLOC(chunk_image, size_hint))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); /* create the message list and initialize the first message */ oh->nmesgs = 1; oh->alloc_nmesgs = H5O_NMESGS; if (NULL == (oh->mesg = H5FL_SEQ_CALLOC(H5O_mesg_t, (size_t)oh->alloc_nmesgs))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); oh->mesg[0].type = H5O_NULL; oh->mesg[0].dirty = TRUE; oh->mesg[0].native = NULL; oh->mesg[0].raw = oh->chunk[0].image + H5O_SIZEOF_MSGHDR(f); oh->mesg[0].raw_size = size_hint - H5O_SIZEOF_MSGHDR(f); oh->mesg[0].chunkno = 0; /* cache it */ if (H5AC_set(f, dxpl_id, H5AC_OHDR, ent->header, oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to cache object header"); /* open it */ if (H5O_open(ent) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object header"); done: if(ret_value<0 && oh) { if(H5O_dest(f,oh)<0) HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy object header data"); } /* end if */ FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_open * * Purpose: Opens an object header which is described by the symbol table * entry OBJ_ENT. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Monday, January 5, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5O_open(const H5G_entry_t *obj_ent) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5O_open, FAIL); /* Check args */ assert(obj_ent); assert(obj_ent->file); #ifdef H5O_DEBUG if (H5DEBUG(O)) HDfprintf(H5DEBUG(O), "> %a\n", obj_ent->header); #endif /* Increment open-lock counters */ obj_ent->file->nopen_objs++; done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_close * * Purpose: Closes an object header that was previously open. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Monday, January 5, 1998 * * Modifications: * * Pedro Vicente, 22 Aug 2002 * Added `id to name' support. * *------------------------------------------------------------------------- */ herr_t H5O_close(H5G_entry_t *obj_ent) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5O_close, FAIL); /* Check args */ assert(obj_ent); assert(obj_ent->file); assert(obj_ent->file->nopen_objs > 0); /* Decrement open-lock counters */ --obj_ent->file->nopen_objs; #ifdef H5O_DEBUG if (H5DEBUG(O)) { if (obj_ent->file->file_id < 0 && 1==obj_ent->file->shared->nrefs) { HDfprintf(H5DEBUG(O), "< %a auto %lu remaining\n", obj_ent->header, (unsigned long)(obj_ent->file->nopen_objs)); } else { HDfprintf(H5DEBUG(O), "< %a\n", obj_ent->header); } } #endif /* * If the file open object count has reached the number of open mount points * (each of which has a group open in the file) attempt to close the file. */ if(obj_ent->file->nopen_objs == obj_ent->file->mtab.nmounts) { /* Attempt to close down the file hierarchy */ if(H5F_try_close(obj_ent->file) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "problem attempting file close") } /* end if */ /* Free the ID to name buffers */ H5G_free_ent_name(obj_ent); done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5O_close() */ /*------------------------------------------------------------------------- * Function: H5O_load * * Purpose: Loads an object header from disk. * * Return: Success: Pointer to the new object header. * * Failure: NULL * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 5 1997 * * Modifications: * * Robb Matzke, 1997-08-30 * Plugged memory leaks that occur during error handling. * * Robb Matzke, 1998-01-07 * Able to distinguish between constant and variable messages. * * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. * * Quincey Koziol, 2002-7-180 * Added dxpl parameter to allow more control over I/O from metadata * cache. *------------------------------------------------------------------------- */ static H5O_t * H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * _udata1, void UNUSED * _udata2) { H5O_t *oh = NULL; H5O_t *ret_value; uint8_t buf[16], *p; size_t mesg_size; size_t hdr_size; unsigned id; int mesgno; unsigned curmesg = 0, nmesgs; unsigned chunkno; haddr_t chunk_addr; size_t chunk_size; uint8_t flags; FUNC_ENTER_NOAPI(H5O_load, NULL); /* check args */ assert(f); assert(H5F_addr_defined(addr)); assert(!_udata1); assert(!_udata2); /* allocate ohdr and init chunk list */ if (NULL==(oh = H5FL_CALLOC(H5O_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); /* read fixed-lenth part of object header */ hdr_size = H5O_SIZEOF_HDR(f); assert(hdr_size<=sizeof(buf)); if (H5F_block_read(f, H5FD_MEM_OHDR, addr, hdr_size, dxpl_id, buf) < 0) HGOTO_ERROR(H5E_OHDR, H5E_READERROR, NULL, "unable to read object header"); p = buf; /* decode version */ oh->version = *p++; if (H5O_VERSION != oh->version) HGOTO_ERROR(H5E_OHDR, H5E_VERSION, NULL, "bad object header version number"); /* reserved */ p++; /* decode number of messages */ UINT16DECODE(p, nmesgs); /* decode link count */ UINT32DECODE(p, oh->nlink); /* decode first chunk info */ chunk_addr = addr + (hsize_t)hdr_size; UINT32DECODE(p, chunk_size); /* build the message array */ oh->alloc_nmesgs = MAX(H5O_NMESGS, nmesgs); if (NULL==(oh->mesg=H5FL_SEQ_CALLOC(H5O_mesg_t,(size_t)oh->alloc_nmesgs))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); /* read each chunk from disk */ while (H5F_addr_defined(chunk_addr)) { /* increase chunk array size */ if (oh->nchunks >= oh->alloc_nchunks) { unsigned na = oh->alloc_nchunks + H5O_NCHUNKS; H5O_chunk_t *x = H5FL_SEQ_REALLOC (H5O_chunk_t, oh->chunk, (size_t)na); if (!x) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); oh->alloc_nchunks = na; oh->chunk = x; } /* read the chunk raw data */ chunkno = oh->nchunks++; oh->chunk[chunkno].dirty = FALSE; oh->chunk[chunkno].addr = chunk_addr; oh->chunk[chunkno].size = chunk_size; if (NULL==(oh->chunk[chunkno].image = H5FL_BLK_MALLOC(chunk_image,chunk_size))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); if (H5F_block_read(f, H5FD_MEM_OHDR, chunk_addr, chunk_size, dxpl_id, oh->chunk[chunkno].image) < 0) HGOTO_ERROR(H5E_OHDR, H5E_READERROR, NULL, "unable to read object header data"); /* load messages from this chunk */ for (p = oh->chunk[chunkno].image; p < oh->chunk[chunkno].image + chunk_size; p += mesg_size) { UINT16DECODE(p, id); UINT16DECODE(p, mesg_size); assert (mesg_size==H5O_ALIGN (mesg_size)); flags = *p++; p += 3; /*reserved*/ /* Try to detect invalidly formatted object header messages */ if (p + mesg_size > oh->chunk[chunkno].image + chunk_size) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "corrupt object header"); /* Skip header messages we don't know about */ /* (Usually from future versions of the library */ if (id >= NELMTS(message_type_g) || NULL == message_type_g[id]) continue; if (H5O_NULL_ID == id && oh->nmesgs > 0 && H5O_NULL_ID == oh->mesg[oh->nmesgs - 1].type->id && oh->mesg[oh->nmesgs - 1].chunkno == chunkno) { /* combine adjacent null messages */ mesgno = oh->nmesgs - 1; oh->mesg[mesgno].raw_size += H5O_SIZEOF_MSGHDR(f) + mesg_size; } else { /* new message */ if (oh->nmesgs >= nmesgs) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "corrupt object header"); mesgno = oh->nmesgs++; oh->mesg[mesgno].type = message_type_g[id]; oh->mesg[mesgno].dirty = FALSE; oh->mesg[mesgno].flags = flags; oh->mesg[mesgno].native = NULL; oh->mesg[mesgno].raw = p; oh->mesg[mesgno].raw_size = mesg_size; oh->mesg[mesgno].chunkno = chunkno; } } assert(p == oh->chunk[chunkno].image + chunk_size); /* decode next object header continuation message */ for (chunk_addr = HADDR_UNDEF; !H5F_addr_defined(chunk_addr) && curmesg < oh->nmesgs; ++curmesg) { if (H5O_CONT_ID == oh->mesg[curmesg].type->id) { H5O_cont_t *cont; cont = (H5O_CONT->decode) (f, dxpl_id, oh->mesg[curmesg].raw, NULL); oh->mesg[curmesg].native = cont; chunk_addr = cont->addr; chunk_size = cont->size; cont->chunkno = oh->nchunks; /*the next chunk to allocate */ } } } /* Set return value */ ret_value = oh; done: if (!ret_value && oh) { if(H5O_dest(f,oh)<0) HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, NULL, "unable to destroy object header data"); } FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_flush * * Purpose: Flushes (and destroys) an object header. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 5 1997 * * Modifications: * * Robb Matzke, 1998-01-07 * Handles constant vs non-constant messages. * * rky, 1998-08-28 * Only p0 writes metadata to disk. * * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. * * Quincey Koziol, 2002-7-180 * Added dxpl parameter to allow more control over I/O from metadata * cache. *------------------------------------------------------------------------- */ static herr_t H5O_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5O_t *oh) { uint8_t buf[16], *p; int id; unsigned u; H5O_mesg_t *curr_msg; /* Pointer to current message being operated on */ H5O_cont_t *cont = NULL; herr_t (*encode)(H5F_t*, uint8_t*, const void*) = NULL; unsigned combine=0; /* Whether to combine the object header prefix & the first chunk */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5O_flush, FAIL); /* check args */ assert(f); assert(H5F_addr_defined(addr)); assert(oh); /* flush */ if (oh->cache_info.is_dirty) { p = buf; /* encode version */ *p++ = oh->version; /* reserved */ *p++ = 0; /* encode number of messages */ UINT16ENCODE(p, oh->nmesgs); /* encode link count */ UINT32ENCODE(p, oh->nlink); /* encode body size */ UINT32ENCODE(p, oh->chunk[0].size); /* zero to alignment */ HDmemset (p, 0, (size_t)(H5O_SIZEOF_HDR(f)-12)); /* write the object header prefix */ /* Check if we can combine the object header prefix & the first chunk into one I/O operation */ if(oh->chunk[0].dirty && (addr+H5O_SIZEOF_HDR(f))==oh->chunk[0].addr) { combine=1; } /* end if */ else { if (H5F_block_write(f, H5FD_MEM_OHDR, addr, (size_t)H5O_SIZEOF_HDR(f), dxpl_id, buf) < 0) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to write object header hdr to disk"); } /* end else */ /* encode messages */ for (u = 0, curr_msg=&oh->mesg[0]; u < oh->nmesgs; u++,curr_msg++) { if (curr_msg->dirty) { p = curr_msg->raw - H5O_SIZEOF_MSGHDR(f); id = curr_msg->type->id; UINT16ENCODE(p, id); assert (curr_msg->raw_sizeraw_size); *p++ = curr_msg->flags; *p++ = 0; /*reserved*/ *p++ = 0; /*reserved*/ *p++ = 0; /*reserved*/ if (curr_msg->native) { assert(curr_msg->type->encode); /* allocate file space for chunks that have none yet */ if (H5O_CONT_ID == curr_msg->type->id && !H5F_addr_defined(((H5O_cont_t *)(curr_msg->native))->addr)) { cont = (H5O_cont_t *) (curr_msg->native); assert(cont->chunkno < oh->nchunks); assert(!H5F_addr_defined(oh->chunk[cont->chunkno].addr)); cont->size = oh->chunk[cont->chunkno].size; /* Free the space we'd reserved in the file to hold this chunk */ H5MF_free_reserved(f, (hsize_t)cont->size); if (HADDR_UNDEF==(cont->addr=H5MF_alloc(f, H5FD_MEM_OHDR, dxpl_id, (hsize_t)cont->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate space for object header data"); oh->chunk[cont->chunkno].addr = cont->addr; } /* * Encode the message. If the message is shared then we * encode a Shared Object message instead of the object * which is being shared. */ assert(curr_msg->raw >= oh->chunk[curr_msg->chunkno].image); assert (curr_msg->raw_size == H5O_ALIGN (curr_msg->raw_size)); assert(curr_msg->raw + curr_msg->raw_size <= oh->chunk[curr_msg->chunkno].image + oh->chunk[curr_msg->chunkno].size); if (curr_msg->flags & H5O_FLAG_SHARED) { encode = H5O_SHARED->encode; } else { encode = curr_msg->type->encode; } if ((encode)(f, curr_msg->raw, curr_msg->native)<0) HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to encode object header message"); } curr_msg->dirty = FALSE; oh->chunk[curr_msg->chunkno].dirty = TRUE; } } /* write each chunk to disk */ for (u = 0; u < oh->nchunks; u++) { if (oh->chunk[u].dirty) { assert(H5F_addr_defined(oh->chunk[u].addr)); if(u==0 && combine) { /* Allocate space for the combined prefix and first chunk */ if((p=H5FL_BLK_MALLOC(chunk_image,(H5O_SIZEOF_HDR(f)+oh->chunk[u].size)))==NULL) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); /* Copy in the prefix */ HDmemcpy(p,buf,(size_t)H5O_SIZEOF_HDR(f)); /* Copy in the first chunk */ HDmemcpy(p+H5O_SIZEOF_HDR(f),oh->chunk[u].image,oh->chunk[u].size); /* Write the combined prefix/chunk out */ if (H5F_block_write(f, H5FD_MEM_OHDR, addr, (H5O_SIZEOF_HDR(f)+oh->chunk[u].size), dxpl_id, p) < 0) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to write object header data to disk"); /* Release the memory for the combined prefix/chunk */ p = H5FL_BLK_FREE(chunk_image,p); } /* end if */ else { if (H5F_block_write(f, H5FD_MEM_OHDR, oh->chunk[u].addr, (oh->chunk[u].size), dxpl_id, oh->chunk[u].image) < 0) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to write object header data to disk"); } /* end else */ oh->chunk[u].dirty = FALSE; } /* end if */ } /* end for */ oh->cache_info.is_dirty = FALSE; } if (destroy) { if(H5O_dest(f,oh)<0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy object header data"); } done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_dest * * Purpose: Destroys an object header. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * Jan 15 2003 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_dest(H5F_t UNUSED *f, H5O_t *oh) { unsigned i; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_dest); /* check args */ assert(oh); /* Verify that node is clean */ assert (oh->cache_info.is_dirty==FALSE); /* destroy chunks */ for (i = 0; i < oh->nchunks; i++) { /* Verify that chunk is clean */ assert (oh->chunk[i].dirty==0); oh->chunk[i].image = H5FL_BLK_FREE(chunk_image,oh->chunk[i].image); } if(oh->chunk) oh->chunk = H5FL_SEQ_FREE(H5O_chunk_t,oh->chunk); /* destroy messages */ for (i = 0; i < oh->nmesgs; i++) { /* Verify that message is clean */ assert (oh->mesg[i].dirty==0); H5O_free_mesg(&oh->mesg[i]); } if(oh->mesg) oh->mesg = H5FL_SEQ_FREE(H5O_mesg_t,oh->mesg); /* destroy object header */ H5FL_FREE(H5O_t,oh); FUNC_LEAVE_NOAPI(SUCCEED); } /* end H5O_dest() */ /*------------------------------------------------------------------------- * Function: H5O_clear * * Purpose: Mark a object header in memory as non-dirty. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * Mar 20 2003 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_clear(H5F_t *f, H5O_t *oh, hbool_t destroy) { unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT(H5O_clear); /* check args */ assert(oh); /* Mark chunks as clean */ for (u = 0; u < oh->nchunks; u++) oh->chunk[u].dirty=FALSE; /* Mark messages as clean */ for (u = 0; u < oh->nmesgs; u++) oh->mesg[u].dirty=FALSE; /* Mark whole header as clean */ oh->cache_info.is_dirty=FALSE; if (destroy) if (H5O_dest(f, oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy object header data"); done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5O_clear() */ /*------------------------------------------------------------------------- * Function: H5O_compute_size * * Purpose: Compute the size in bytes of the specified instance of * H5O_t on disk, and return it in *len_ptr. On failure, * the value of *len_ptr is undefined. * * The value returned will probably be low unless the object * has just been flushed, as we simply total up the size of * the header with the sizes of the chunks. Thus any message * that has been added since the last flush will not be * reflected in the total. * * Return: Non-negative on success/Negative on failure * * Programmer: John Mainzer * 5/13/04 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_compute_size(const H5F_t *f, const H5O_t *oh, size_t *size_ptr) { unsigned u; size_t size; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_compute_size); /* check args */ HDassert(f); HDassert(oh); HDassert(size_ptr); size = H5O_SIZEOF_HDR(f); for (u = 0; u < oh->nchunks; u++) size += oh->chunk[u].size; HDassert(size >= H5O_SIZEOF_HDR(f)); *size_ptr = size; FUNC_LEAVE_NOAPI(SUCCEED); } /* H5O_compute_size() */ /*------------------------------------------------------------------------- * Function: H5O_reset * * Purpose: Some message data structures have internal fields that * need to be freed. This function does that if appropriate * but doesn't free NATIVE. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 12 1997 * * Modifications: * Changed to use IDs for types, instead of type objects, then * call "real" routine. * Quincey Koziol * Feb 14 2003 * *------------------------------------------------------------------------- */ herr_t H5O_reset(unsigned type_id, void *native) { const H5O_class_t *type; /* Actual H5O class type for the ID */ herr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5O_reset,FAIL); /* check args */ assert(type_idreset) { if ((type->reset) (native) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "reset method failed"); } else { HDmemset(native, 0, type->native_size); } } done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5O_reset_real() */ /*------------------------------------------------------------------------- * Function: H5O_free * * Purpose: Similar to H5O_reset() except it also frees the message * pointer. * * Return: Success: NULL * * Failure: NULL * * Programmer: Robb Matzke * Thursday, May 21, 1998 * * Modifications: * *------------------------------------------------------------------------- */ void * H5O_free (unsigned type_id, void *mesg) { const H5O_class_t *type; /* Actual H5O class type for the ID */ void * ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5O_free, NULL); /* check args */ assert(type_idflags & H5O_FLAG_SHARED) mesg->native = H5O_free_real(H5O_SHARED, mesg->native); else mesg->native = H5O_free_real(mesg->type, mesg->native); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_free_mesg() */ /*------------------------------------------------------------------------- * Function: H5O_free_real * * Purpose: Similar to H5O_reset() except it also frees the message * pointer. * * Return: Success: NULL * * Failure: NULL * * Programmer: Robb Matzke * Thursday, May 21, 1998 * * Modifications: * *------------------------------------------------------------------------- */ void * H5O_free_real(const H5O_class_t *type, void *msg_native) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_free_real) /* check args */ assert(type); if (msg_native) { H5O_reset_real(type, msg_native); if (NULL!=(type->free)) (type->free)(msg_native); else H5MM_xfree (msg_native); } FUNC_LEAVE_NOAPI(NULL) } /* end H5O_free_real() */ /*------------------------------------------------------------------------- * Function: H5O_copy * * Purpose: Copies a message. If MESG is is the null pointer then a null * pointer is returned with no error. * * Return: Success: Ptr to the new message * * Failure: NULL * * Programmer: Robb Matzke * Thursday, May 21, 1998 * * Modifications: * Changed to use IDs for types, instead of type objects, then * call "real" routine. * Quincey Koziol * Feb 14 2003 * *------------------------------------------------------------------------- */ void * H5O_copy (unsigned type_id, const void *mesg, void *dst) { const H5O_class_t *type; /* Actual H5O class type for the ID */ void *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5O_copy, NULL); /* check args */ assert(type_idcopy); if (mesg) { if (NULL==(ret_value=(type->copy)(mesg, dst, 0))) HGOTO_ERROR (H5E_OHDR, H5E_CANTINIT, NULL, "unable to copy object header message"); } done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5O_copy_real() */ /*------------------------------------------------------------------------- * Function: H5O_link * * Purpose: Adjust the link count for an object header by adding * ADJUST to the link count. * * Return: Success: New link count * * Failure: Negative * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 5 1997 * * Modifications: * * Robb Matzke, 1998-08-27 * This function can also be used to obtain the current number of links * if zero is passed for ADJUST. If that's the case then we don't check * for write access on the file. * *------------------------------------------------------------------------- */ int H5O_link(const H5G_entry_t *ent, int adjust, hid_t dxpl_id) { H5O_t *oh = NULL; hbool_t deleted=FALSE; /* Whether the object was deleted as a result of this action */ int ret_value = FAIL; FUNC_ENTER_NOAPI(H5O_link, FAIL); /* check args */ assert(ent); assert(ent->file); assert(H5F_addr_defined(ent->header)); if (adjust!=0 && 0==(ent->file->intent & H5F_ACC_RDWR)) HGOTO_ERROR (H5E_OHDR, H5E_WRITEERROR, FAIL, "no write intent on file"); /* get header */ if (NULL == (oh = H5AC_protect(ent->file, dxpl_id, H5AC_OHDR, ent->header, NULL, NULL, H5AC_WRITE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header"); /* adjust link count */ if (adjust<0) { if (oh->nlink + adjust < 0) HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "link count would be negative"); oh->nlink += adjust; oh->cache_info.is_dirty = TRUE; /* Check if the object should be deleted */ if(oh->nlink==0) { /* Check if the object is still open by the user */ if(H5FO_opened(ent->file,ent->header)!=NULL) { /* Flag the object to be deleted when it's closed */ if(H5FO_mark(ent->file,ent->header,TRUE)<0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "can't mark object for deletion"); } /* end if */ else { /* Delete object right now */ if(H5O_delete_oh(ent->file,dxpl_id,oh)<0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "can't delete object from file"); /* Mark the object header as deleted */ deleted=TRUE; } /* end else */ } /* end if */ } else if (adjust>0) { /* A new object, or one that will be deleted */ if(oh->nlink==0) { /* Check if the object is current open, but marked for deletion */ if(H5FO_marked(ent->file,ent->header)>0) { /* Remove "delete me" flag on the object */ if(H5FO_mark(ent->file,ent->header,FALSE)<0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "can't mark object for deletion"); } /* end if */ } /* end if */ oh->nlink += adjust; oh->cache_info.is_dirty = TRUE; } /* Set return value */ ret_value = oh->nlink; done: if (oh && H5AC_unprotect(ent->file, dxpl_id, H5AC_OHDR, ent->header, oh, deleted) < 0) HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_count * * Purpose: Counts the number of messages in an object header which are a * certain type. * * Return: Success: Number of messages of specified type. * * Failure: Negative * * Programmer: Robb Matzke * Tuesday, April 21, 1998 * * Modifications: * Changed to use IDs for types, instead of type objects, then * call "real" routine. * Quincey Koziol * Feb 14 2003 * *------------------------------------------------------------------------- */ int H5O_count (H5G_entry_t *ent, unsigned type_id, hid_t dxpl_id) { const H5O_class_t *type; /* Actual H5O class type for the ID */ int ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5O_count, FAIL); /* Check args */ assert (ent); assert (ent->file); assert (H5F_addr_defined(ent->header)); assert(type_idfile); assert (H5F_addr_defined(ent->header)); assert (type); /* Load the object header */ if (NULL == (oh = H5AC_protect(ent->file, dxpl_id, H5AC_OHDR, ent->header, NULL, NULL, H5AC_READ))) HGOTO_ERROR (H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header"); /* Loop over all messages, counting the ones of the type looked for */ for (u=acc=0; unmesgs; u++) if (oh->mesg[u].type==type) acc++; /* Set return value */ ret_value=acc; done: if (oh && H5AC_unprotect(ent->file, dxpl_id, H5AC_OHDR, ent->header, oh, FALSE) != SUCCEED) HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value); } /* end H5O_count_real() */ /*------------------------------------------------------------------------- * Function: H5O_exists * * Purpose: Determines if a particular message exists in an object * header without trying to decode the message. * * Return: Success: FALSE if the message does not exist; TRUE if * th message exists. * * Failure: FAIL if the existence of the message could * not be determined due to some error such as * not being able to read the object header. * * Programmer: Robb Matzke * Monday, November 2, 1998 * * Modifications: * Changed to use IDs for types, instead of type objects, then * call "real" routine. * Quincey Koziol * Feb 14 2003 * *------------------------------------------------------------------------- */ htri_t H5O_exists(H5G_entry_t *ent, unsigned type_id, int sequence, hid_t dxpl_id) { const H5O_class_t *type; /* Actual H5O class type for the ID */ htri_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5O_exists, FAIL); assert(ent); assert(ent->file); assert(type_id=0); /* Call the "real" exists routine */ if((ret_value=H5O_exists_real(ent, type, sequence, dxpl_id))<0) HGOTO_ERROR(H5E_OHDR, H5E_READERROR, FAIL, "unable to verify object header message"); done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5O_exists() */ /*------------------------------------------------------------------------- * Function: H5O_exists_real * * Purpose: Determines if a particular message exists in an object * header without trying to decode the message. * * Return: Success: FALSE if the message does not exist; TRUE if * th message exists. * * Failure: FAIL if the existence of the message could * not be determined due to some error such as * not being able to read the object header. * * Programmer: Robb Matzke * Monday, November 2, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static htri_t H5O_exists_real(H5G_entry_t *ent, const H5O_class_t *type, int sequence, hid_t dxpl_id) { H5O_t *oh=NULL; unsigned u; htri_t ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_exists_real); assert(ent); assert(ent->file); assert(type); assert(sequence>=0); /* Load the object header */ if (NULL == (oh = H5AC_protect(ent->file, dxpl_id, H5AC_OHDR, ent->header, NULL, NULL, H5AC_READ))) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header"); /* Scan through the messages looking for the right one */ for (u=0; unmesgs; u++) { if (type->id!=oh->mesg[u].type->id) continue; if (--sequence<0) break; } /* Set return value */ ret_value=(sequence<0); done: if (oh && H5AC_unprotect(ent->file, dxpl_id, H5AC_OHDR, ent->header, oh, FALSE) != SUCCEED) HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value); } /* end H5O_exists_real() */ /*------------------------------------------------------------------------- * Function: H5O_read * * Purpose: Reads a message from an object header and returns a pointer * to it. The caller will usually supply the memory through * MESG and the return value will be MESG. But if MESG is * the null pointer, then this function will malloc() memory * to hold the result and return its pointer instead. * * Return: Success: Ptr to message in native format. The message * should be freed by calling H5O_reset(). If * MESG is a null pointer then the caller should * also call H5MM_xfree() on the return value * after calling H5O_reset(). * * Failure: NULL * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 6 1997 * * Modifications: * Changed to use IDs for types, instead of type objects, then * call "real" routine. * Quincey Koziol * Feb 14 2003 * *------------------------------------------------------------------------- */ void * H5O_read(const H5G_entry_t *ent, unsigned type_id, int sequence, void *mesg, hid_t dxpl_id) { const H5O_class_t *type; /* Actual H5O class type for the ID */ void *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5O_read, NULL); /* check args */ assert(ent); assert(ent->file); assert(H5F_addr_defined(ent->header)); assert(type_id= 0); /* Call the "real" read routine */ if((ret_value=H5O_read_real(ent, type, sequence, mesg, dxpl_id))==NULL) HGOTO_ERROR(H5E_OHDR, H5E_READERROR, NULL, "unable to load object header"); done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5O_read() */ /*------------------------------------------------------------------------- * Function: H5O_read_real * * Purpose: Reads a message from an object header and returns a pointer * to it. The caller will usually supply the memory through * MESG and the return value will be MESG. But if MESG is * the null pointer, then this function will malloc() memory * to hold the result and return its pointer instead. * * Return: Success: Ptr to message in native format. The message * should be freed by calling H5O_reset(). If * MESG is a null pointer then the caller should * also call H5MM_xfree() on the return value * after calling H5O_reset(). * * Failure: NULL * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 6 1997 * * Modifications: * Bill Wendling, 2003-09-30 * Protect the object header and pass it into the H5O_find_in_ohdr * function. This is done because the H5O_find_in_ohdr used to * protect the ohdr, find the message, and then unprotect it. This * saves time and also helps the FPHDF5 stuff, where unprotecting * actually destroys the object in the cache. *------------------------------------------------------------------------- */ void * H5O_read_real(const H5G_entry_t *ent, const H5O_class_t *type, int sequence, void *mesg, hid_t dxpl_id) { H5O_t *oh = NULL; int idx; const H5G_cache_t *cache = NULL; H5G_type_t cache_type; void *ret_value = NULL; FUNC_ENTER_NOAPI_NOINIT(H5O_read_real); /* check args */ assert(ent); assert(ent->file); assert(H5F_addr_defined(ent->header)); assert(type); assert(sequence >= 0); /* can we get it from the symbol table entry? */ cache = H5G_ent_cache(ent, &cache_type); if (H5O_fast_g[cache_type]) { ret_value = (H5O_fast_g[cache_type]) (cache, type, mesg); if (ret_value) HGOTO_DONE(ret_value); H5E_clear(); /*don't care, try reading from header */ } /* copy the message to the user-supplied buffer */ if (NULL == (oh = H5AC_protect(ent->file, dxpl_id, H5AC_OHDR, ent->header, NULL, NULL, H5AC_READ))) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "unable to load object header"); /* can we get it from the object header? */ if ((idx = H5O_find_in_ohdr(ent->file, dxpl_id, oh, &type, sequence)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, NULL, "unable to find message in object header"); if (oh->mesg[idx].flags & H5O_FLAG_SHARED) { /* * If the message is shared then then the native pointer points to an * H5O_SHARED message. We use that information to look up the real * message in the global heap or some other object header. */ H5O_shared_t *shared; shared = (H5O_shared_t *)(oh->mesg[idx].native); ret_value=H5O_shared_read(ent->file,dxpl_id,shared,type,mesg); } else { /* * The message is not shared, but rather exists in the object * header. The object header caches the native message (along with * the raw message) so we must copy the native message before * returning. */ if (NULL==(ret_value = (type->copy) (oh->mesg[idx].native, mesg, 0))) HGOTO_ERROR (H5E_OHDR, H5E_CANTINIT, NULL, "unable to copy message to user space"); } done: if (oh && H5AC_unprotect(ent->file, dxpl_id, H5AC_OHDR, ent->header, oh, FALSE) < 0) HDONE_ERROR(H5E_OHDR, H5E_PROTECT, NULL, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value); } /* end H5O_read_real() */ /*------------------------------------------------------------------------- * Function: H5O_find_in_ohdr * * Purpose: Find a message in the object header without consulting * a symbol table entry. * * Return: Success: Index number of message. * Failure: Negative * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 6 1997 * * Modifications: * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. * * Bill Wendling, 2003-09-30 * Modified so that the object header needs to be AC_protected * before calling this function. *------------------------------------------------------------------------- */ static unsigned H5O_find_in_ohdr(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_class_t **type_p, int sequence) { unsigned u; const H5O_class_t *type = NULL; unsigned ret_value; FUNC_ENTER_NOAPI_NOINIT(H5O_find_in_ohdr); /* Check args */ assert(f); assert(oh); assert(type_p); /* Scan through the messages looking for the right one */ for (u = 0; u < oh->nmesgs; u++) { if (*type_p && (*type_p)->id != oh->mesg[u].type->id) continue; if (--sequence < 0) break; } if (sequence >= 0) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, UFAIL, "unable to find object header message"); /* * Decode the message if necessary. If the message is shared then decode * a shared message, ignoring the message type. */ if (oh->mesg[u].flags & H5O_FLAG_SHARED) type = H5O_SHARED; else type = oh->mesg[u].type; if (NULL == oh->mesg[u].native) { assert(type->decode); oh->mesg[u].native = (type->decode) (f, dxpl_id, oh->mesg[u].raw, NULL); if (NULL == oh->mesg[u].native) HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, UFAIL, "unable to decode message"); } /* * Return the message type. If this is a shared message then return the * pointed-to type. */ *type_p = oh->mesg[u].type; /* Set return value */ ret_value=u; done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_modify * * Purpose: Modifies an existing message or creates a new message. * The cache fields in that symbol table entry ENT are *not* * updated, you must do that separately because they often * depend on multiple object header messages. Besides, we * don't know which messages will be constant and which will * not. * * The OVERWRITE argument is either a sequence number of a * message to overwrite (usually zero) or the constant * H5O_NEW_MESG (-1) to indicate that a new message is to * be created. If the message to overwrite doesn't exist then * it is created (but only if it can be inserted so its sequence * number is OVERWRITE; that is, you can create a message with * the sequence number 5 if there is no message with sequence * number 4). * * The UPDATE_TIME argument is a boolean that allows the caller * to skip updating the modification time. This is useful when * several calls to H5O_modify will be made in a sequence. * * Return: Success: The sequence number of the message that * was modified or created. * * Failure: Negative * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 6 1997 * * Modifications: * * Robb Matzke, 7 Jan 1998 * Handles constant vs non-constant messages. Once a message is made * constant it can never become non-constant. Constant messages cannot * be modified. * * Changed to use IDs for types, instead of type objects, then * call "real" routine. * Quincey Koziol * Feb 14 2003 * *------------------------------------------------------------------------- */ int H5O_modify(H5G_entry_t *ent, unsigned type_id, int overwrite, unsigned flags, unsigned update_flags, const void *mesg, hid_t dxpl_id) { const H5O_class_t *type; /* Actual H5O class type for the ID */ int ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5O_modify, FAIL); /* check args */ assert(ent); assert(ent->file); assert(H5F_addr_defined(ent->header)); assert(type_idfile); assert(H5F_addr_defined(ent->header)); assert(type); assert(mesg); assert (0==(flags & ~H5O_FLAG_BITS)); if (0==(ent->file->intent & H5F_ACC_RDWR)) HGOTO_ERROR (H5E_OHDR, H5E_WRITEERROR, FAIL, "no write intent on file"); if (NULL == (oh = H5AC_protect(ent->file, dxpl_id, H5AC_OHDR, ent->header, NULL, NULL, H5AC_WRITE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header"); /* Count similar messages */ for (idx = 0, sequence = -1, idx_msg=&oh->mesg[0]; idx < oh->nmesgs; idx++, idx_msg++) { if (type->id != idx_msg->type->id) continue; if (++sequence == overwrite) break; } /* end for */ /* Was the right message found? */ if (overwrite >= 0 && (idx >= oh->nmesgs || sequence != overwrite)) { /* But can we insert a new one with this sequence number? */ if (overwrite == sequence + 1) overwrite = -1; else HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "message not found"); } /* end if */ /* Check for creating new message */ if (overwrite < 0) { /* Create a new message */ if((idx=H5O_new_mesg(ent->file,oh,&flags,type,mesg,&sh_mesg,&type,&mesg,dxpl_id))==UFAIL) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to create new message"); /* Set the correct sequence number for the message created */ sequence++; } else if (oh->mesg[idx].flags & H5O_FLAG_CONSTANT) { HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to modify constant message"); } else if (oh->mesg[idx].flags & H5O_FLAG_SHARED) { HGOTO_ERROR (H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to modify shared (constant) message"); } /* Write the information to the message */ if(H5O_write_mesg(oh,idx,type,mesg,flags,update_flags)<0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to write message"); /* Update the modification time message if any */ if(update_flags&H5O_UPDATE_TIME) H5O_touch_oh(ent->file, oh, FALSE); /* Set return value */ ret_value = sequence; done: if (oh && H5AC_unprotect(ent->file, dxpl_id, H5AC_OHDR, ent->header, oh, FALSE) < 0) HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value); } /* end H5O_modify_real() */ /*------------------------------------------------------------------------- * Function: H5O_protect * * Purpose: Wrapper around H5AC_protect for use during a H5O_protect-> * H5O_append->...->H5O_append->H5O_unprotect sequence of calls * during an object's creation. * * Return: Success: Pointer to the object header structure for the * object. * * Failure: NULL * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * Dec 31 2002 * * Modifications: * *------------------------------------------------------------------------- */ H5O_t * H5O_protect(H5G_entry_t *ent, hid_t dxpl_id) { H5O_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5O_protect, NULL); /* check args */ assert(ent); assert(ent->file); assert(H5F_addr_defined(ent->header)); if (0==(ent->file->intent & H5F_ACC_RDWR)) HGOTO_ERROR (H5E_OHDR, H5E_WRITEERROR, NULL, "no write intent on file"); if (NULL == (ret_value = H5AC_protect(ent->file, dxpl_id, H5AC_OHDR, ent->header, NULL, NULL, H5AC_WRITE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "unable to load object header"); done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5O_protect() */ /*------------------------------------------------------------------------- * Function: H5O_unprotect * * Purpose: Wrapper around H5AC_unprotect for use during a H5O_protect-> * H5O_append->...->H5O_append->H5O_unprotect sequence of calls * during an object's creation. * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * Dec 31 2002 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5O_unprotect(H5G_entry_t *ent, H5O_t *oh, hid_t dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5O_unprotect, FAIL); /* check args */ assert(ent); assert(ent->file); assert(H5F_addr_defined(ent->header)); assert(oh); if (H5AC_unprotect(ent->file, dxpl_id, H5AC_OHDR, ent->header, oh, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header"); done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5O_unprotect() */ /*------------------------------------------------------------------------- * Function: H5O_append * * Purpose: Simplified version of H5O_modify, used when creating a new * object header message (usually during object creation) * * Return: Success: The sequence number of the message that * was created. * * Failure: Negative * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * Dec 31 2002 * * Modifications: * Changed to use IDs for types, instead of type objects, then * call "real" routine. * Quincey Koziol * Feb 14 2003 * *------------------------------------------------------------------------- */ int H5O_append(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned type_id, unsigned flags, const void *mesg) { const H5O_class_t *type; /* Actual H5O class type for the ID */ int ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5O_append,FAIL); /* check args */ assert(f); assert(oh); assert(type_idget_share) HGOTO_ERROR (H5E_OHDR, H5E_UNSUPPORTED, UFAIL, "message class is not sharable"); if ((orig_type->get_share)(f, orig_mesg, sh_mesg/*out*/)<0) { /* * If the message isn't shared then turn off the shared bit * and treat it as an unshared message. */ H5E_clear (); *flags &= ~H5O_FLAG_SHARED; } else { /* Change type & message to use shared information */ *new_type=H5O_SHARED; *new_mesg=sh_mesg; } /* end else */ } /* end if */ else { *new_type=orig_type; *new_mesg=orig_mesg; } /* end else */ /* Compute the size needed to store the message on disk */ if ((size = ((*new_type)->raw_size) (f, *new_mesg)) >=H5O_MAX_SIZE) HGOTO_ERROR (H5E_OHDR, H5E_CANTINIT, UFAIL, "object header message is too large (16k max)"); /* Allocate space in the object headed for the message */ if ((ret_value = H5O_alloc(f, oh, orig_type, size)) == UFAIL) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, UFAIL, "unable to allocate space for message"); /* Increment any links in message */ if((*new_type)->link && ((*new_type)->link)(f,dxpl_id,(*new_mesg))<0) HGOTO_ERROR (H5E_OHDR, H5E_LINK, UFAIL, "unable to adjust shared object link count"); done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5O_new_mesg() */ /*------------------------------------------------------------------------- * Function: H5O_write_mesg * * Purpose: Write message to object header * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Friday, September 3, 2003 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_write_mesg(H5O_t *oh, unsigned idx, const H5O_class_t *type, const void *mesg, unsigned flags, unsigned update_flags) { H5O_mesg_t *idx_msg; /* Pointer to message to modify */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_write_mesg); /* check args */ assert(oh); assert(type); assert(mesg); /* Set pointer to the correct message */ idx_msg=&oh->mesg[idx]; /* Reset existing native information */ if(!(update_flags&H5O_UPDATE_DATA_ONLY)) H5O_reset_real(type, idx_msg->native); /* Copy the native value for the message */ if (NULL == (idx_msg->native = (type->copy) (mesg, idx_msg->native, update_flags))) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to copy message to object header"); idx_msg->flags = flags; idx_msg->dirty = TRUE; oh->cache_info.is_dirty = TRUE; done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5O_write_mesg() */ /*------------------------------------------------------------------------- * Function: H5O_touch_oh * * Purpose: If FORCE is non-zero then create a modification time message * unless one already exists. Then update any existing * modification time message with the current time. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Monday, July 27, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5O_touch_oh(H5F_t *f, H5O_t *oh, hbool_t force) { unsigned idx; #ifdef H5_HAVE_GETTIMEOFDAY struct timeval now_tv; #endif /* H5_HAVE_GETTIMEOFDAY */ time_t now; size_t size; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_touch_oh); assert(oh); /* Look for existing message */ for (idx=0; idxnmesgs; idx++) { if (H5O_MTIME==oh->mesg[idx].type || H5O_MTIME_NEW==oh->mesg[idx].type) break; } #ifdef H5_HAVE_GETTIMEOFDAY HDgettimeofday(&now_tv,NULL); now=now_tv.tv_sec; #else /* H5_HAVE_GETTIMEOFDAY */ now = HDtime(NULL); #endif /* H5_HAVE_GETTIMEOFDAY */ /* Create a new message */ if (idx==oh->nmesgs) { if (!force) HGOTO_DONE(SUCCEED); /*nothing to do*/ size = (H5O_MTIME_NEW->raw_size)(f, &now); if ((idx=H5O_alloc(f, oh, H5O_MTIME_NEW, size))==UFAIL) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to allocate space for modification time message"); } /* Update the native part */ if (NULL==oh->mesg[idx].native) { if (NULL==(oh->mesg[idx].native = H5FL_MALLOC(time_t))) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "memory allocation failed for modification time message"); } *((time_t*)(oh->mesg[idx].native)) = now; oh->mesg[idx].dirty = TRUE; oh->cache_info.is_dirty = TRUE; done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_touch * * Purpose: Touch an object by setting the modification time to the * current time and marking the object as dirty. Unless FORCE * is non-zero, nothing happens if there is no MTIME message in * the object header. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Monday, July 27, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5O_touch(H5G_entry_t *ent, hbool_t force, hid_t dxpl_id) { H5O_t *oh = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5O_touch, FAIL); /* check args */ assert(ent); assert(ent->file); assert(H5F_addr_defined(ent->header)); if (0==(ent->file->intent & H5F_ACC_RDWR)) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "no write intent on file"); /* Get the object header */ if (NULL==(oh=H5AC_protect(ent->file, dxpl_id, H5AC_OHDR, ent->header, NULL, NULL, H5AC_WRITE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header"); /* Create/Update the modification time message */ if (H5O_touch_oh(ent->file, oh, force)<0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to update object modificaton time"); done: if (oh && H5AC_unprotect(ent->file, dxpl_id, H5AC_OHDR, ent->header, oh, FALSE)<0) HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value); } #ifdef H5O_ENABLE_BOGUS /*------------------------------------------------------------------------- * Function: H5O_bogus_oh * * Purpose: Create a "bogus" message unless one already exists. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * * Tuesday, January 21, 2003 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5O_bogus_oh(H5F_t *f, H5O_t *oh) { int idx; size_t size; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER(H5O_bogus_oh, FAIL); assert(f); assert(oh); /* Look for existing message */ for (idx=0; idxnmesgs; idx++) if (H5O_BOGUS==oh->mesg[idx].type) break; /* Create a new message */ if (idx==oh->nmesgs) { size = (H5O_BOGUS->raw_size)(f, NULL); if ((idx=H5O_alloc(f, oh, H5O_BOGUS, size))<0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to allocate space for 'bogus' message"); /* Allocate the native message in memory */ if (NULL==(oh->mesg[idx].native = H5MM_malloc(sizeof(H5O_bogus_t)))) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "memory allocation failed for 'bogus' message"); /* Update the native part */ ((H5O_bogus_t *)(oh->mesg[idx].native))->u = H5O_BOGUS_VALUE; /* Mark the message and object header as dirty */ oh->mesg[idx].dirty = TRUE; oh->dirty = TRUE; } /* end if */ done: FUNC_LEAVE(ret_value); } /* end H5O_bogus_oh() */ /*------------------------------------------------------------------------- * Function: H5O_bogus * * Purpose: Create a "bogus" message in an object. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * * Tuesday, January 21, 2003 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5O_bogus(H5G_entry_t *ent, hid_t dxpl_id) { H5O_t *oh = NULL; herr_t ret_value = SUCCEED; FUNC_ENTER(H5O_bogus, FAIL); /* check args */ assert(ent); assert(ent->file); assert(H5F_addr_defined(ent->header)); /* Verify write access to the file */ if (0==(ent->file->intent & H5F_ACC_RDWR)) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "no write intent on file"); /* Get the object header */ if (NULL==(oh=H5AC_protect(ent->file, dxpl_id, H5AC_OHDR, ent->header, NULL, NULL, H5AC_WRITE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header"); /* Create the "bogus" message */ if (H5O_bogus_oh(ent->file, oh)<0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to update object 'bogus' message"); done: if (oh && H5AC_unprotect(ent->file, dxpl_id, H5AC_OHDR, ent->header, oh, FALSE)<0) HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header"); FUNC_LEAVE(ret_value); } /* end H5O_bogus() */ #endif /* H5O_ENABLE_BOGUS */ /*------------------------------------------------------------------------- * Function: H5O_remove * * Purpose: Removes the specified message from the object header. * If sequence is H5O_ALL (-1) then all messages of the * specified type are removed. Removing a message causes * the sequence numbers to change for subsequent messages of * the same type. * * No attempt is made to join adjacent free areas of the * object header into a single larger free area. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 28 1997 * * Modifications: * * Robb Matzke, 7 Jan 1998 * Does not remove constant messages. * * Changed to use IDs for types, instead of type objects, then * call "real" routine. * Quincey Koziol * Feb 14 2003 * *------------------------------------------------------------------------- */ herr_t H5O_remove(H5G_entry_t *ent, unsigned type_id, int sequence, hbool_t adj_link, hid_t dxpl_id) { const H5O_class_t *type; /* Actual H5O class type for the ID */ herr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5O_remove, FAIL) /* check args */ HDassert(ent); HDassert(ent->file); HDassert(H5F_addr_defined(ent->header)); HDassert(type_id < NELMTS(message_type_g)); type = message_type_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); /* Call the "real" remove routine */ if((ret_value = H5O_remove_real(ent, type, sequence, NULL, NULL, adj_link, dxpl_id))<0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to remove object header message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_remove() */ /*------------------------------------------------------------------------- * Function: H5O_remove_op * * Purpose: Removes messages from the object header that a callback * routine indicates should be removed. * * No attempt is made to join adjacent free areas of the * object header into a single larger free area. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * Sep 6 2005 * *------------------------------------------------------------------------- */ herr_t H5O_remove_op(H5G_entry_t *ent, unsigned type_id, H5O_operator_t op, void *op_data, hbool_t adj_link, hid_t dxpl_id) { const H5O_class_t *type; /* Actual H5O class type for the ID */ herr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5O_remove_op, FAIL) /* check args */ HDassert(ent); HDassert(ent->file); HDassert(H5F_addr_defined(ent->header)); HDassert(type_id < NELMTS(message_type_g)); type = message_type_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); /* Call the "real" remove routine */ if((ret_value = H5O_remove_real(ent, type, H5O_ALL, op, op_data, adj_link, dxpl_id))<0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to remove object header message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_remove_op() */ /*------------------------------------------------------------------------- * Function: H5O_remove_cb * * Purpose: Object header iterator callback routine to remove messages * of a particular type that match a particular sequence number, * or all messages if the sequence number is H5O_ALL (-1). * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * Sep 6 2005 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_remove_cb(H5O_mesg_t *mesg/*in,out*/, unsigned idx, unsigned * oh_flags_ptr, void *_udata/*in,out*/) { H5O_iter_ud1_t *udata = (H5O_iter_ud1_t *)_udata; /* Operator user data */ htri_t try_remove = FALSE; /* Whether to try removing a message */ herr_t ret_value = H5O_ITER_CONT; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_remove_cb) /* check args */ HDassert(mesg); /* Check for callback routine */ if(udata->op) { /* Call the iterator callback */ if((try_remove = (udata->op)(mesg->native, idx, udata->op_data)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, H5O_ITER_ERROR, "unable to delete file space for object header message") } /* end if */ else { /* If there's no callback routine, does the sequence # match? */ if ((int)idx == udata->sequence || H5O_ALL == udata->sequence) try_remove = TRUE; } /* end else */ /* Try removing the message, if indicated */ if(try_remove) { /* * Keep track of how many times we failed trying to remove constant * messages. */ if (mesg->flags & H5O_FLAG_CONSTANT) { udata->nfailed++; } /* end if */ else { /* Free any space referred to in the file from this message */ if(H5O_delete_mesg(udata->f, udata->dxpl_id, mesg, udata->adj_link)<0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, H5O_ITER_ERROR, "unable to delete file space for object header message") /* Free any native information */ H5O_free_mesg(mesg); /* Change message type to nil and zero it */ mesg->type = H5O_NULL; HDmemset(mesg->raw, 0, mesg->raw_size); /* Indicate that the message was modified */ mesg->dirty = TRUE; /* Indicate that the object header was modified */ *oh_flags_ptr = TRUE; } /* end else */ /* Break out now, if we've found the correct message */ if(udata->sequence != H5O_ALL) HGOTO_DONE(H5O_ITER_STOP) } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_remove_cb() */ /*------------------------------------------------------------------------- * Function: H5O_remove_real * * Purpose: Removes the specified message from the object header. * If sequence is H5O_ALL (-1) then all messages of the * specified type are removed. Removing a message causes * the sequence numbers to change for subsequent messages of * the same type. * * No attempt is made to join adjacent free areas of the * object header into a single larger free area. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 28 1997 * * Modifications: * * Robb Matzke, 7 Jan 1998 * Does not remove constant messages. * *------------------------------------------------------------------------- */ static herr_t H5O_remove_real(H5G_entry_t *ent, const H5O_class_t *type, int sequence, H5O_operator_t op, void *op_data, hbool_t adj_link, hid_t dxpl_id) { H5O_iter_ud1_t udata; /* User data for iterator */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_remove_real) /* check args */ HDassert(ent); HDassert(ent->file); HDassert(type); if (0==(ent->file->intent & H5F_ACC_RDWR)) HGOTO_ERROR (H5E_HEAP, H5E_WRITEERROR, FAIL, "no write intent on file") /* Set up iterator operator data */ udata.f = ent->file; udata.dxpl_id = dxpl_id; udata.sequence = sequence; udata.nfailed = 0; udata.op = op; udata.op_data = op_data; udata.adj_link = adj_link; /* Iterate over the messages, deleting appropriate one(s) */ if(H5O_iterate_real(ent, type, H5AC_WRITE, TRUE, (void *)H5O_remove_cb, &udata, dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "error iterating over messages") /* Fail if we tried to remove any constant messages */ if (udata.nfailed) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to remove constant message(s)") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_remove_real() */ /*------------------------------------------------------------------------- * Function: H5O_alloc_extend_chunk * * Purpose: Extends a chunk which hasn't been allocated on disk yet * to make the chunk large enough to contain a message whose * data size is exactly SIZE bytes (SIZE need not be aligned). * * If the last message of the chunk is the null message, then * that message will be extended with the chunk. Otherwise a * new null message is created. * * F is the file in which the chunk will be written. It is * included to ensure that there is enough space to extend * this chunk. * * Return: Success: Message index for null message which * is large enough to hold SIZE bytes. * * Failure: Negative * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 7 1997 * * Modifications: * Robb Matzke, 1999-08-26 * If new memory is allocated as a multiple of some alignment * then we're careful to initialize the part of the new memory * from the end of the expected message to the end of the new * memory. *------------------------------------------------------------------------- */ static unsigned H5O_alloc_extend_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno, size_t size) { unsigned u; unsigned idx; size_t delta, old_size; size_t aligned_size = H5O_ALIGN(size); uint8_t *old_addr; unsigned ret_value; FUNC_ENTER_NOAPI_NOINIT(H5O_alloc_extend_chunk); /* check args */ assert(oh); assert(chunkno < oh->nchunks); assert(size > 0); if (H5F_addr_defined(oh->chunk[chunkno].addr)) HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, UFAIL, "chunk is on disk"); /* try to extend a null message */ for (idx=0; idxnmesgs; idx++) { if (oh->mesg[idx].chunkno==chunkno) { if (H5O_NULL_ID == oh->mesg[idx].type->id && (oh->mesg[idx].raw + oh->mesg[idx].raw_size == oh->chunk[chunkno].image + oh->chunk[chunkno].size)) { delta = MAX (H5O_MIN_SIZE, aligned_size - oh->mesg[idx].raw_size); assert (delta=H5O_ALIGN (delta)); /* Reserve space in the file to hold the increased chunk size */ if( H5MF_reserve(f, (hsize_t)delta) < 0 ) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, UFAIL, "unable to reserve space in file"); oh->mesg[idx].dirty = TRUE; oh->mesg[idx].raw_size += delta; old_addr = oh->chunk[chunkno].image; /* Be careful not to indroduce garbage */ oh->chunk[chunkno].image = H5FL_BLK_REALLOC(chunk_image,old_addr, (oh->chunk[chunkno].size + delta)); if (NULL==oh->chunk[chunkno].image) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, UFAIL, "memory allocation failed"); HDmemset(oh->chunk[chunkno].image + oh->chunk[chunkno].size, 0, delta); oh->chunk[chunkno].size += delta; /* adjust raw addresses for messages of this chunk */ if (old_addr != oh->chunk[chunkno].image) { for (u = 0; u < oh->nmesgs; u++) { if (oh->mesg[u].chunkno == chunkno) oh->mesg[u].raw = oh->chunk[chunkno].image + (oh->mesg[u].raw - old_addr); } } HGOTO_DONE(idx); } } /* end if */ } /* Reserve space in the file */ delta = MAX(H5O_MIN_SIZE, aligned_size+H5O_SIZEOF_MSGHDR(f)); delta = H5O_ALIGN(delta); if( H5MF_reserve(f, (hsize_t)delta) < 0 ) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, UFAIL, "unable to reserve space in file"); /* create a new null message */ if (oh->nmesgs >= oh->alloc_nmesgs) { unsigned na = oh->alloc_nmesgs + H5O_NMESGS; H5O_mesg_t *x = H5FL_SEQ_REALLOC (H5O_mesg_t, oh->mesg, (size_t)na); if (NULL==x) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, UFAIL, "memory allocation failed"); oh->alloc_nmesgs = na; oh->mesg = x; } idx = oh->nmesgs++; oh->mesg[idx].type = H5O_NULL; oh->mesg[idx].dirty = TRUE; oh->mesg[idx].native = NULL; oh->mesg[idx].raw = oh->chunk[chunkno].image + oh->chunk[chunkno].size + H5O_SIZEOF_MSGHDR(f); oh->mesg[idx].raw_size = delta - H5O_SIZEOF_MSGHDR(f); oh->mesg[idx].chunkno = chunkno; old_addr = oh->chunk[chunkno].image; old_size = oh->chunk[chunkno].size; oh->chunk[chunkno].size += delta; oh->chunk[chunkno].image = H5FL_BLK_REALLOC(chunk_image,old_addr, oh->chunk[chunkno].size); if (NULL==oh->chunk[chunkno].image) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, UFAIL, "memory allocation failed"); HDmemset(oh->chunk[chunkno].image+old_size, 0, oh->chunk[chunkno].size - old_size); /* adjust raw addresses for messages of this chunk */ if (old_addr != oh->chunk[chunkno].image) { for (u = 0; u < oh->nmesgs; u++) { if (oh->mesg[u].chunkno == chunkno) oh->mesg[u].raw = oh->chunk[chunkno].image + (oh->mesg[u].raw - old_addr); } } /* Set return value */ ret_value=idx; done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_alloc_new_chunk * * Purpose: Allocates a new chunk for the object header but doen't * give the new chunk a file address yet. One of the other * chunks will get an object continuation message. If there * isn't room in any other chunk for the object continuation * message, then some message from another chunk is moved into * this chunk to make room. * * SIZE need not be aligned. * * Return: Success: Index number of the null message for the * new chunk. The null message will be at * least SIZE bytes not counting the message * ID or size fields. * * Failure: Negative * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 7 1997 * * Modifications: * *------------------------------------------------------------------------- */ static unsigned H5O_alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size) { size_t cont_size; /*continuation message size */ int found_null = (-1); /*best fit null message */ int found_other = (-1); /*best fit other message */ unsigned idx; /*message number */ uint8_t *p = NULL; /*ptr into new chunk */ H5O_cont_t *cont = NULL; /*native continuation message */ int chunkno; unsigned u; unsigned ret_value; /*return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_alloc_new_chunk); /* check args */ assert (oh); assert (size > 0); size = H5O_ALIGN(size); /* * Find the smallest null message that will hold an object * continuation message. Failing that, find the smallest message * that could be moved to make room for the continuation message. * Don't ever move continuation message from one chunk to another. */ cont_size = H5O_ALIGN (H5F_SIZEOF_ADDR(f) + H5F_SIZEOF_SIZE(f)); for (u=0; unmesgs; u++) { if (H5O_NULL_ID == oh->mesg[u].type->id) { if (cont_size == oh->mesg[u].raw_size) { found_null = u; break; } else if (oh->mesg[u].raw_size >= cont_size && (found_null < 0 || (oh->mesg[u].raw_size < oh->mesg[found_null].raw_size))) { found_null = u; } } else if (H5O_CONT_ID == oh->mesg[u].type->id) { /*don't consider continuation messages */ } else if (oh->mesg[u].raw_size >= cont_size && (found_other < 0 || oh->mesg[u].raw_size < oh->mesg[found_other].raw_size)) { found_other = u; } } assert(found_null >= 0 || found_other >= 0); /* * If we must move some other message to make room for the null * message, then make sure the new chunk has enough room for that * other message. */ if (found_null < 0) size += H5O_SIZEOF_MSGHDR(f) + oh->mesg[found_other].raw_size; /* * The total chunk size must include the requested space plus enough * for the message header. This must be at least some minimum and a * multiple of the alignment size. */ size = MAX(H5O_MIN_SIZE, size + H5O_SIZEOF_MSGHDR(f)); assert (size == H5O_ALIGN (size)); /* Reserve space in the file to hold the new chunk */ if( H5MF_reserve(f, (hsize_t)size) < 0 ) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, UFAIL, "unable to reserve space in file for new chunk"); /* * Create the new chunk without giving it a file address. */ if (oh->nchunks >= oh->alloc_nchunks) { unsigned na = oh->alloc_nchunks + H5O_NCHUNKS; H5O_chunk_t *x = H5FL_SEQ_REALLOC (H5O_chunk_t, oh->chunk, (size_t)na); if (!x) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, UFAIL, "memory allocation failed"); oh->alloc_nchunks = na; oh->chunk = x; } chunkno = oh->nchunks++; oh->chunk[chunkno].dirty = TRUE; oh->chunk[chunkno].addr = HADDR_UNDEF; oh->chunk[chunkno].size = size; if (NULL==(oh->chunk[chunkno].image = p = H5FL_BLK_CALLOC(chunk_image,size))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, UFAIL, "memory allocation failed"); /* * Make sure we have enough space for all possible new messages * that could be generated below. */ if (oh->nmesgs + 3 > oh->alloc_nmesgs) { int old_alloc=oh->alloc_nmesgs; unsigned na = oh->alloc_nmesgs + MAX (H5O_NMESGS, 3); H5O_mesg_t *x = H5FL_SEQ_REALLOC (H5O_mesg_t, oh->mesg, (size_t)na); if (!x) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, UFAIL, "memory allocation failed"); oh->alloc_nmesgs = na; oh->mesg = x; /* Set new object header info to zeros */ HDmemset(&oh->mesg[old_alloc], 0, (oh->alloc_nmesgs-old_alloc)*sizeof(H5O_mesg_t)); } /* * Describe the messages of the new chunk. */ if (found_null < 0) { found_null = u = oh->nmesgs++; oh->mesg[u].type = H5O_NULL; oh->mesg[u].dirty = TRUE; oh->mesg[u].native = NULL; oh->mesg[u].raw = oh->mesg[found_other].raw; oh->mesg[u].raw_size = oh->mesg[found_other].raw_size; oh->mesg[u].chunkno = oh->mesg[found_other].chunkno; oh->mesg[found_other].dirty = TRUE; /* Copy the message to the new location */ HDmemcpy(p+H5O_SIZEOF_MSGHDR(f),oh->mesg[found_other].raw,oh->mesg[found_other].raw_size); oh->mesg[found_other].raw = p + H5O_SIZEOF_MSGHDR(f); oh->mesg[found_other].chunkno = chunkno; p += H5O_SIZEOF_MSGHDR(f) + oh->mesg[found_other].raw_size; size -= H5O_SIZEOF_MSGHDR(f) + oh->mesg[found_other].raw_size; } idx = oh->nmesgs++; oh->mesg[idx].type = H5O_NULL; oh->mesg[idx].dirty = TRUE; oh->mesg[idx].native = NULL; oh->mesg[idx].raw = p + H5O_SIZEOF_MSGHDR(f); oh->mesg[idx].raw_size = size - H5O_SIZEOF_MSGHDR(f); oh->mesg[idx].chunkno = chunkno; /* * If the null message that will receive the continuation message * is larger than the continuation message, then split it into * two null messages. */ if (oh->mesg[found_null].raw_size > cont_size) { u = oh->nmesgs++; oh->mesg[u].type = H5O_NULL; oh->mesg[u].dirty = TRUE; oh->mesg[u].native = NULL; oh->mesg[u].raw = oh->mesg[found_null].raw + cont_size + H5O_SIZEOF_MSGHDR(f); oh->mesg[u].raw_size = oh->mesg[found_null].raw_size - (cont_size + H5O_SIZEOF_MSGHDR(f)); oh->mesg[u].chunkno = oh->mesg[found_null].chunkno; oh->mesg[found_null].dirty = TRUE; oh->mesg[found_null].raw_size = cont_size; } /* * Initialize the continuation message. */ oh->mesg[found_null].type = H5O_CONT; oh->mesg[found_null].dirty = TRUE; if (NULL==(cont = H5FL_MALLOC(H5O_cont_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, UFAIL, "memory allocation failed"); cont->addr = HADDR_UNDEF; cont->size = 0; cont->chunkno = chunkno; oh->mesg[found_null].native = cont; /* Set return value */ ret_value=idx; done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_alloc * * Purpose: Allocate enough space in the object header for this message. * * Return: Success: Index of message * * Failure: Negative * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 6 1997 * * Modifications: * *------------------------------------------------------------------------- */ static unsigned H5O_alloc(H5F_t *f, H5O_t *oh, const H5O_class_t *type, size_t size) { unsigned idx; H5O_mesg_t *msg; /* Pointer to newly allocated message */ size_t aligned_size = H5O_ALIGN(size); unsigned ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_alloc); /* check args */ assert (oh); assert (type); /* look for a null message which is large enough */ for (idx = 0; idx < oh->nmesgs; idx++) { if (H5O_NULL_ID == oh->mesg[idx].type->id && oh->mesg[idx].raw_size >= aligned_size) break; } #ifdef LATER /* * Perhaps if we join adjacent null messages we could make one * large enough... we leave this as an exercise for future * programmers :-) This isn't a high priority because when an * object header is read from disk the null messages are combined * anyway. */ #endif /* if we didn't find one, then allocate more header space */ if (idx >= oh->nmesgs) { unsigned chunkno; /* * Look for a chunk which hasn't had disk space allocated yet * since we can just increase the size of that chunk. */ for (chunkno = 0; chunkno < oh->nchunks; chunkno++) { if ((idx = H5O_alloc_extend_chunk(f, oh, chunkno, size)) != UFAIL) { break; } H5E_clear(); } /* * Create a new chunk */ if (idx == UFAIL) { if ((idx = H5O_alloc_new_chunk(f, oh, size)) == UFAIL) HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, UFAIL, "unable to create a new object header data chunk"); } } /* Set pointer to newly allocated message */ msg=&oh->mesg[idx]; /* do we need to split the null message? */ if (msg->raw_size > aligned_size) { H5O_mesg_t *null_msg; /* Pointer to null message */ size_t mesg_size = aligned_size+ H5O_SIZEOF_MSGHDR(f); /* Total size of newly allocated message */ assert(msg->raw_size - aligned_size >= H5O_SIZEOF_MSGHDR(f)); if (oh->nmesgs >= oh->alloc_nmesgs) { int old_alloc=oh->alloc_nmesgs; unsigned na = oh->alloc_nmesgs + H5O_NMESGS; H5O_mesg_t *x = H5FL_SEQ_REALLOC (H5O_mesg_t, oh->mesg, (size_t)na); if (!x) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, UFAIL, "memory allocation failed"); oh->alloc_nmesgs = na; oh->mesg = x; /* Set new object header info to zeros */ HDmemset(&oh->mesg[old_alloc],0, (oh->alloc_nmesgs-old_alloc)*sizeof(H5O_mesg_t)); /* "Retarget" local 'msg' pointer into newly allocated array of messages */ msg=&oh->mesg[idx]; } null_msg=&oh->mesg[oh->nmesgs++]; null_msg->type = H5O_NULL; null_msg->dirty = TRUE; null_msg->native = NULL; null_msg->raw = msg->raw + mesg_size; null_msg->raw_size = msg->raw_size - mesg_size; null_msg->chunkno = msg->chunkno; msg->raw_size = aligned_size; } /* initialize the new message */ msg->type = type; msg->dirty = TRUE; msg->native = NULL; oh->cache_info.is_dirty = TRUE; /* Set return value */ ret_value=idx; done: FUNC_LEAVE_NOAPI(ret_value); } #ifdef NOT_YET /*------------------------------------------------------------------------- * Function: H5O_share * * Purpose: Writes a message to the global heap. * * Return: Success: Non-negative, and HOBJ describes the global heap * object. * * Failure: Negative * * Programmer: Robb Matzke * Thursday, April 2, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_share (H5F_t *f, hid_t dxpl_id, const H5O_class_t *type, const void *mesg, H5HG_t *hobj/*out*/) { size_t size; void *buf = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_share); /* Check args */ assert (f); assert (type); assert (mesg); assert (hobj); /* Encode the message put it in the global heap */ if ((size = (type->raw_size)(f, mesg))>0) { if (NULL==(buf = H5MM_malloc (size))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); if ((type->encode)(f, buf, mesg)<0) HGOTO_ERROR (H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to encode message"); if (H5HG_insert (f, dxpl_id, size, buf, hobj)<0) HGOTO_ERROR (H5E_OHDR, H5E_CANTINIT, FAIL, "unable to store message in global heap"); } done: if(buf) H5MM_xfree (buf); FUNC_LEAVE_NOAPI(ret_value); } #endif /* NOT_YET */ /*------------------------------------------------------------------------- * Function: H5O_raw_size * * Purpose: Call the 'raw_size' method for a * particular class of object header. * * Return: Size of message on success, 0 on failure * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * Feb 13 2003 * * Modifications: * *------------------------------------------------------------------------- */ size_t H5O_raw_size(unsigned type_id, const H5F_t *f, const void *mesg) { const H5O_class_t *type; /* Actual H5O class type for the ID */ size_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5O_raw_size,0) /* Check args */ HDassert(type_idraw_size); HDassert(f); HDassert(mesg); /* Compute the raw data size for the mesg */ if ((ret_value = (type->raw_size)(f, mesg))==0) HGOTO_ERROR (H5E_OHDR, H5E_CANTCOUNT, 0, "unable to determine size of message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_raw_size() */ /*------------------------------------------------------------------------- * Function: H5O_mesg_size * * Purpose: Calculate the final size of an encoded message in an object * header. * * Return: Size of message on success, 0 on failure * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * Sep 6 2005 * *------------------------------------------------------------------------- */ size_t H5O_mesg_size(unsigned type_id, const H5F_t *f, const void *mesg) { const H5O_class_t *type; /* Actual H5O class type for the ID */ size_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5O_mesg_size,0) /* Check args */ HDassert(type_idraw_size); HDassert(f); HDassert(mesg); /* Compute the raw data size for the mesg */ if((ret_value = (type->raw_size)(f, mesg)) == 0) HGOTO_ERROR (H5E_OHDR, H5E_CANTCOUNT, 0, "unable to determine size of message") /* Adjust size for alignment, if necessary */ ret_value = H5O_ALIGN(ret_value); /* Add space for message header */ ret_value += H5O_SIZEOF_MSGHDR(f); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_mesg_size() */ /*------------------------------------------------------------------------- * Function: H5O_get_share * * Purpose: Call the 'get_share' method for a * particular class of object header. * * Return: Success: Non-negative, and SHARE describes the shared * object. * * Failure: Negative * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * Oct 2 2003 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5O_get_share(unsigned type_id, H5F_t *f, const void *mesg, H5O_shared_t *share) { const H5O_class_t *type; /* Actual H5O class type for the ID */ herr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5O_get_share,FAIL); /* Check args */ assert(type_idget_share); assert (f); assert (mesg); assert (share); /* Compute the raw data size for the mesg */ if ((ret_value = (type->get_share)(f, mesg, share))<0) HGOTO_ERROR (H5E_OHDR, H5E_CANTGET, FAIL, "unable to retrieve shared message information"); done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5O_get_share() */ /*------------------------------------------------------------------------- * Function: H5O_delete * * Purpose: Delete an object header from a file. This frees the file * space used for the object header (and it's continuation blocks) * and also walks through each header message and asks it to * remove all the pieces of the file referenced by the header. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * Mar 19 2003 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5O_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr) { H5O_t *oh=NULL; /* Object header information */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5O_delete,FAIL); /* Check args */ assert (f); assert(H5F_addr_defined(addr)); /* Get the object header information */ if (NULL == (oh = H5AC_protect(f, dxpl_id, H5AC_OHDR, addr, NULL, NULL, H5AC_WRITE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header"); /* Delete object */ if(H5O_delete_oh(f,dxpl_id,oh)<0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "can't delete object from file"); done: if (oh && H5AC_unprotect(f, dxpl_id, H5AC_OHDR, addr, oh, TRUE)<0) HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value); } /* end H5O_delete() */ /*------------------------------------------------------------------------- * Function: H5O_delete_oh * * Purpose: Internal function to: * Delete an object header from a file. This frees the file * space used for the object header (and it's continuation blocks) * and also walks through each header message and asks it to * remove all the pieces of the file referenced by the header. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * Mar 19 2003 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_delete_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh) { H5O_mesg_t *curr_msg; /* Pointer to current message being operated on */ H5O_chunk_t *curr_chk; /* Pointer to current chunk being operated on */ unsigned u; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_delete_oh); /* Check args */ assert (f); assert (oh); /* Walk through the list of object header messages, asking each one to * delete any file space used */ for (u = 0, curr_msg=&oh->mesg[0]; u < oh->nmesgs; u++,curr_msg++) { /* Free any space referred to in the file from this message */ if(H5O_delete_mesg(f, dxpl_id, curr_msg, TRUE)<0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to delete file space for object header message"); } /* end for */ /* Free all the chunks for the object header */ for (u = 0, curr_chk=&oh->chunk[0]; u < oh->nchunks; u++,curr_chk++) { haddr_t chk_addr; /* Actual address of chunk */ hsize_t chk_size; /* Actual size of chunk */ if(u==0) { chk_addr = curr_chk->addr - H5O_SIZEOF_HDR(f); chk_size = curr_chk->size + H5O_SIZEOF_HDR(f); } /* end if */ else { chk_addr = curr_chk->addr; chk_size = curr_chk->size; } /* end else */ /* Free the file space for the chunk */ if (H5MF_xfree(f, H5FD_MEM_OHDR, dxpl_id, chk_addr, chk_size)<0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free object header"); } /* end for */ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5O_delete_oh() */ /*------------------------------------------------------------------------- * Function: H5O_delete_mesg * * Purpose: Internal function to: * Delete an object header message from a file. This frees the file * space used for anything referred to in the object header message. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * September 26 2003 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_delete_mesg(H5F_t *f, hid_t dxpl_id, H5O_mesg_t *mesg, hbool_t adj_link) { const H5O_class_t *type; /* Type of object to free */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_delete_mesg); /* Check args */ assert (f); assert (mesg); /* Get the message to free's type */ if(mesg->flags & H5O_FLAG_SHARED) type=H5O_SHARED; else type = mesg->type; /* Check if there is a file space deletion callback for this type of message */ if(type->del) { /* * Decode the message if necessary. */ if (NULL == mesg->native) { assert(type->decode); mesg->native = (type->decode) (f, dxpl_id, mesg->raw, NULL); if (NULL == mesg->native) HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, FAIL, "unable to decode message"); } /* end if */ if ((type->del)(f, dxpl_id, mesg->native, adj_link)<0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to delete file space for object header message"); } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5O_delete_msg() */ /*------------------------------------------------------------------------- * Function: H5O_get_info * * Purpose: Retrieve information about an object header * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * Oct 7 2003 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5O_get_info(H5G_entry_t *ent, H5O_stat_t *ostat, hid_t dxpl_id) { H5O_t *oh=NULL; /* Object header information */ H5O_mesg_t *curr_msg; /* Pointer to current message being operated on */ hsize_t total_size; /* Total amount of space used in file */ hsize_t free_space; /* Free space in object header */ unsigned u; /* Local index variable */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5O_get_info,FAIL); /* Check args */ assert (ent); assert (ostat); /* Get the object header information */ if (NULL == (oh = H5AC_protect(ent->file, dxpl_id, H5AC_OHDR, ent->header, NULL, NULL, H5AC_READ))) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header"); /* Iterate over all the messages, accumulating the total size & free space */ total_size=H5O_SIZEOF_HDR(ent->file); free_space=0; for (u = 0, curr_msg=&oh->mesg[0]; u < oh->nmesgs; u++,curr_msg++) { /* Accumulate the size for this message */ total_size+= H5O_SIZEOF_MSGHDR(ent->file) + curr_msg->raw_size; /* Check for this message being free space */ if (H5O_NULL_ID == curr_msg->type->id) free_space+= H5O_SIZEOF_MSGHDR(ent->file) + curr_msg->raw_size; } /* end for */ /* Set the information for this object header */ ostat->size=total_size; ostat->free=free_space; ostat->nmesgs=oh->nmesgs; ostat->nchunks=oh->nchunks; done: if (oh && H5AC_unprotect(ent->file, dxpl_id, H5AC_OHDR, ent->header, oh, FALSE)<0) HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value); } /* end H5O_get_info() */ /*------------------------------------------------------------------------- * Function: H5O_iterate * * Purpose: Iterate through object headers of a certain type. * * Return: Returns a negative value if something is wrong, the return * value of the last operator if it was non-zero, or zero if all * object headers were processed. * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * Nov 19 2004 * * Description: * This function interates over the object headers of an object * specified with 'ent' of type 'type_id'. For each object header of the * object, the 'op_data' and some additional information (specified below) are * passed to the 'op' function. * The operation receives a pointer to the object header message for the * object being iterated over ('mesg'), and the pointer to the operator data * passed in to H5O_iterate ('op_data'). The return values from an operator * are: * A. Zero causes the iterator to continue, returning zero when all * object headers of that type have been processed. * B. Positive causes the iterator to immediately return that positive * value, indicating short-circuit success. * C. Negative causes the iterator to immediately return that value, * indicating failure. * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5O_iterate(const H5G_entry_t *ent, unsigned type_id, H5O_operator_t op, void *op_data, hid_t dxpl_id) { const H5O_class_t *type; /* Actual H5O class type for the ID */ herr_t ret_value=0; /* Return value */ FUNC_ENTER_NOAPI(H5O_iterate, FAIL) /* check args */ HDassert(ent); HDassert(ent->file); HDassert(H5F_addr_defined(ent->header)); HDassert(type_idfile); HDassert(H5F_addr_defined(ent->header)); HDassert(type); HDassert(op); /* Protect the object header to iterate over */ if (NULL == (oh = H5AC_protect(ent->file, dxpl_id, H5AC_OHDR, ent->header, NULL, NULL, prot))) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header"); /* Iterate over messages */ for (sequence = 0, idx = 0, idx_msg = &oh->mesg[0]; idx < oh->nmesgs; idx++, idx_msg++) { if (type->id == idx_msg->type->id) { /* * Decode the message if necessary. If the message is shared then decode * a shared message, ignoring the message type. */ if (NULL == idx_msg->native) { const H5O_class_t *decode_type; if (idx_msg->flags & H5O_FLAG_SHARED) decode_type = H5O_SHARED; else decode_type = type; /* Decode the message if necessary */ HDassert(decode_type->decode); if (NULL == (idx_msg->native = (decode_type->decode) (ent->file, dxpl_id, idx_msg->raw, NULL))) HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, FAIL, "unable to decode message") } /* end if */ /* Check for making an "internal" (i.e. within the H5O package) callback */ if(internal) { /* Call the "internal" iterator callback */ if((ret_value = ((H5O_operator_int_t)op)(idx_msg, sequence, &oh_flags, op_data)) != 0) break; } /* end if */ else { /* Call the iterator callback */ if((ret_value = ((H5O_operator_t)op)(idx_msg->native, sequence, op_data)) != 0) break; } /* end else */ /* Increment sequence value for message type */ sequence++; } /* end if */ } /* end for */ /* Check if object header was modified */ if(oh_flags) { /* Shouldn't be able to modify object header if we don't have write access */ HDassert(prot == H5AC_WRITE); oh->cache_info.is_dirty = TRUE; H5O_touch_oh(ent->file, oh, FALSE); } /* end if */ done: if (oh && H5AC_unprotect(ent->file, dxpl_id, H5AC_OHDR, ent->header, oh, FALSE) < 0) HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_iterate_real() */ /*------------------------------------------------------------------------- * Function: H5O_debug_id * * Purpose: Act as a proxy for calling the 'debug' method for a * particular class of object header. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * Feb 13 2003 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5O_debug_id(hid_t type_id, H5F_t *f, hid_t dxpl_id, const void *mesg, FILE *stream, int indent, int fwidth) { const H5O_class_t *type; /* Actual H5O class type for the ID */ herr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5O_debug_id,FAIL); /* Check args */ assert(type_id>=0 && type_id<(hid_t)(sizeof(message_type_g)/sizeof(message_type_g[0]))); type=message_type_g[type_id]; /* map the type ID to the actual type object */ assert(type); assert(type->debug); assert(f); assert(mesg); assert(stream); assert(indent >= 0); assert(fwidth >= 0); /* Call the debug method in the class */ if ((ret_value = (type->debug)(f, dxpl_id, mesg, stream, indent, fwidth))<0) HGOTO_ERROR (H5E_OHDR, H5E_BADTYPE, FAIL, "unable to debug message"); done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5O_debug_id() */ /*------------------------------------------------------------------------- * Function: H5O_debug * * Purpose: Prints debugging info about an object header. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 6 1997 * * Modifications: * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. *------------------------------------------------------------------------- */ herr_t H5O_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int fwidth) { H5O_t *oh = NULL; unsigned i, chunkno; size_t mesg_total = 0, chunk_total = 0; int *sequence; haddr_t tmp_addr; herr_t ret_value = SUCCEED; void *(*decode)(H5F_t*, hid_t, const uint8_t*, H5O_shared_t*); herr_t (*debug)(H5F_t*, hid_t, const void*, FILE*, int, int)=NULL; FUNC_ENTER_NOAPI(H5O_debug, FAIL); /* check args */ assert(f); assert(H5F_addr_defined(addr)); assert(stream); assert(indent >= 0); assert(fwidth >= 0); if (NULL == (oh = H5AC_protect(f, dxpl_id, H5AC_OHDR, addr, NULL, NULL, H5AC_READ))) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header"); /* debug */ HDfprintf(stream, "%*sObject Header...\n", indent, ""); HDfprintf(stream, "%*s%-*s %d\n", indent, "", fwidth, "Dirty:", (int) (oh->cache_info.is_dirty)); HDfprintf(stream, "%*s%-*s %d\n", indent, "", fwidth, "Version:", (int) (oh->version)); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Header size (in bytes):", (unsigned) H5O_SIZEOF_HDR(f)); HDfprintf(stream, "%*s%-*s %d\n", indent, "", fwidth, "Number of links:", (int) (oh->nlink)); HDfprintf(stream, "%*s%-*s %u (%u)\n", indent, "", fwidth, "Number of messages (allocated):", (unsigned) (oh->nmesgs), (unsigned) (oh->alloc_nmesgs)); HDfprintf(stream, "%*s%-*s %u (%u)\n", indent, "", fwidth, "Number of chunks (allocated):", (unsigned) (oh->nchunks), (unsigned) (oh->alloc_nchunks)); /* debug each chunk */ for (i=0, chunk_total=0; inchunks; i++) { chunk_total += oh->chunk[i].size; HDfprintf(stream, "%*sChunk %d...\n", indent, "", i); HDfprintf(stream, "%*s%-*s %d\n", indent + 3, "", MAX(0, fwidth - 3), "Dirty:", (int) (oh->chunk[i].dirty)); HDfprintf(stream, "%*s%-*s %a\n", indent + 3, "", MAX(0, fwidth - 3), "Address:", oh->chunk[i].addr); tmp_addr = addr + (hsize_t)H5O_SIZEOF_HDR(f); if (0 == i && H5F_addr_ne(oh->chunk[i].addr, tmp_addr)) HDfprintf(stream, "*** WRONG ADDRESS!\n"); HDfprintf(stream, "%*s%-*s %lu\n", indent + 3, "", MAX(0, fwidth - 3), "Size in bytes:", (unsigned long) (oh->chunk[i].size)); } /* debug each message */ if (NULL==(sequence = H5MM_calloc(NELMTS(message_type_g)*sizeof(int)))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); for (i=0, mesg_total=0; inmesgs; i++) { mesg_total += H5O_SIZEOF_MSGHDR(f) + oh->mesg[i].raw_size; HDfprintf(stream, "%*sMessage %d...\n", indent, "", i); /* check for bad message id */ if (oh->mesg[i].type->id < 0 || oh->mesg[i].type->id >= (int)NELMTS(message_type_g)) { HDfprintf(stream, "*** BAD MESSAGE ID 0x%04x\n", oh->mesg[i].type->id); continue; } /* message name and size */ HDfprintf(stream, "%*s%-*s 0x%04x `%s' (%d)\n", indent + 3, "", MAX(0, fwidth - 3), "Message ID (sequence number):", (unsigned) (oh->mesg[i].type->id), oh->mesg[i].type->name, sequence[oh->mesg[i].type->id]++); HDfprintf (stream, "%*s%-*s %s\n", indent+3, "", MAX (0, fwidth-3), "Shared:", (oh->mesg[i].flags & H5O_FLAG_SHARED) ? "Yes" : "No"); HDfprintf(stream, "%*s%-*s %s\n", indent + 3, "", MAX(0, fwidth - 3), "Constant:", (oh->mesg[i].flags & H5O_FLAG_CONSTANT) ? "Yes" : "No"); if (oh->mesg[i].flags & ~H5O_FLAG_BITS) { HDfprintf (stream, "%*s%-*s 0x%02x\n", indent+3,"",MAX(0,fwidth-3), "*** ADDITIONAL UNKNOWN FLAGS --->", oh->mesg[i].flags & ~H5O_FLAG_BITS); } HDfprintf(stream, "%*s%-*s %lu bytes\n", indent+3, "", MAX(0,fwidth-3), "Raw size in obj header:", (unsigned long) (oh->mesg[i].raw_size)); HDfprintf(stream, "%*s%-*s %d\n", indent + 3, "", MAX(0, fwidth - 3), "Chunk number:", (int) (oh->mesg[i].chunkno)); chunkno = oh->mesg[i].chunkno; if (chunkno >= oh->nchunks) HDfprintf(stream, "*** BAD CHUNK NUMBER\n"); /* check the size */ if ((oh->mesg[i].raw + oh->mesg[i].raw_size > oh->chunk[chunkno].image + oh->chunk[chunkno].size) || (oh->mesg[i].raw < oh->chunk[chunkno].image)) { HDfprintf(stream, "*** BAD MESSAGE RAW ADDRESS\n"); } /* decode the message */ if (oh->mesg[i].flags & H5O_FLAG_SHARED) { decode = H5O_SHARED->decode; debug = H5O_SHARED->debug; } else { decode = oh->mesg[i].type->decode; debug = oh->mesg[i].type->debug; } if (NULL==oh->mesg[i].native && decode) oh->mesg[i].native = (decode)(f, dxpl_id, oh->mesg[i].raw, NULL); if (NULL==oh->mesg[i].native) debug = NULL; /* print the message */ HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), "Message Information:"); if (debug) (debug)(f, dxpl_id, oh->mesg[i].native, stream, indent+6, MAX(0, fwidth-6)); else HDfprintf(stream, "%*s\n", indent + 6, ""); /* If the message is shared then also print the pointed-to message */ if (oh->mesg[i].flags & H5O_FLAG_SHARED) { H5O_shared_t *shared = (H5O_shared_t*)(oh->mesg[i].native); void *mesg = NULL; if (shared->in_gh) { void *p = H5HG_read (f, dxpl_id, oh->mesg[i].native, NULL); mesg = (oh->mesg[i].type->decode)(f, dxpl_id, p, oh->mesg[i].native); H5MM_xfree (p); } else { mesg = H5O_read_real(&(shared->u.ent), oh->mesg[i].type, 0, NULL, dxpl_id); } if (oh->mesg[i].type->debug) { (oh->mesg[i].type->debug)(f, dxpl_id, mesg, stream, indent+3, MAX (0, fwidth-3)); } H5O_free_real(oh->mesg[i].type, mesg); } } sequence = H5MM_xfree(sequence); if (mesg_total != chunk_total) HDfprintf(stream, "*** TOTAL SIZE DOES NOT MATCH ALLOCATED SIZE!\n"); done: if (oh && H5AC_unprotect(f, dxpl_id, H5AC_OHDR, addr, oh, FALSE) < 0) HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value); } xdmf-3.0+git20160803/Utilities/hdf5/H5config.h.cmake.in0000640000175000017500000004727013003006557022204 0ustar alastairalastair/* src/H5config.h.in. Generated from configure.in by autoheader. */ /* Define if your system can handle converting denormalized floating-point values. */ #cmakedefine CONVERT_DENORMAL_FLOAT ${CONVERT_DENORMAL_FLOAT} /* Define if `dev_t' is a scalar */ #cmakedefine DEV_T_IS_SCALAR ${DEV_T_IS_SCALAR} /* Define if gettimeofday() populates the tz pointer passed in */ #cmakedefine GETTIMEOFDAY_GIVES_TZ ${GETTIMEOFDAY_GIVES_TZ} /* Define to 1 if you have the `alarm' function. */ #cmakedefine HAVE_ALARM ${HAVE_ALARM} /* Define if the __attribute__(()) extension is present */ #cmakedefine HAVE_ATTRIBUTE ${HAVE_ATTRIBUTE} /* Define to 1 if you have the `BSDgettimeofday' function. */ #cmakedefine HAVE_BSDGETTIMEOFDAY ${HAVE_BSDGETTIMEOFDAY} /* Define to 1 if you have the `difftime' function. */ #cmakedefine HAVE_DIFFTIME ${HAVE_DIFFTIME} /* Define to 1 if you have the header file. */ #cmakedefine HAVE_DLFCN_H ${HAVE_DLFCN_H} /* Define to 1 if you have the header file. */ #cmakedefine HAVE_DMALLOC_H ${HAVE_DMALLOC_H} /* Define to 1 if you have the header file. */ #cmakedefine HAVE_FEATURES_H ${HAVE_FEATURES_H} /* Define if support for deflate filter is enabled */ #cmakedefine HAVE_FILTER_DEFLATE ${HAVE_FILTER_DEFLATE} /* Define if support for Fletcher32 checksum is enabled */ #cmakedefine HAVE_FILTER_FLETCHER32 ${HAVE_FILTER_FLETCHER32} /* Define if support for shuffle filter is enabled */ #cmakedefine HAVE_FILTER_SHUFFLE ${HAVE_FILTER_SHUFFLE} /* Define if support for szip filter is enabled */ #cmakedefine HAVE_FILTER_SZIP ${HAVE_FILTER_SZIP} /* Define to 1 if you have the `fork' function. */ #cmakedefine HAVE_FORK ${HAVE_FORK} /* Define to 1 if you have the `frexpf' function. */ #cmakedefine HAVE_FREXPF ${HAVE_FREXPF} /* Define to 1 if you have the `frexpl' function. */ #cmakedefine HAVE_FREXPL ${HAVE_FREXPL} /* Define to 1 if you have the `fseek64' function. */ #cmakedefine HAVE_FSEEK64 ${HAVE_FSEEK64} /* Define if the function stack tracing code is to be compiled in */ #cmakedefine HAVE_FUNCSTACK ${HAVE_FUNCSTACK} /* Define if the compiler understand the __FUNCTION__ keyword */ #cmakedefine HAVE_FUNCTION ${HAVE_FUNCTION} /* Define if the Globus GASS is defined */ #cmakedefine HAVE_GASS ${HAVE_GASS} /* Define to 1 if you have the `GetConsoleScreenBufferInfo' function. */ #cmakedefine HAVE_GETCONSOLESCREENBUFFERINFO ${HAVE_GETCONSOLESCREENBUFFERINFO} /* Define to 1 if you have the `gethostname' function. */ #cmakedefine HAVE_GETHOSTNAME ${HAVE_GETHOSTNAME} /* Define to 1 if you have the `getpwuid' function. */ #cmakedefine HAVE_GETPWUID ${HAVE_GETPWUID} /* Define to 1 if you have the `getrusage' function. */ #cmakedefine HAVE_GETRUSAGE ${HAVE_GETRUSAGE} /* Define to 1 if you have the `gettextinfo' function. */ #cmakedefine HAVE_GETTEXTINFO ${HAVE_GETTEXTINFO} /* Define to 1 if you have the `gettimeofday' function. */ #cmakedefine HAVE_GETTIMEOFDAY ${HAVE_GETTIMEOFDAY} /* Define to 1 if you have the `get_fpc_csr' function. */ #cmakedefine HAVE_GET_FPC_CSR ${HAVE_GET_FPC_CSR} /* Define to 1 if you have the header file. */ #cmakedefine HAVE_GLOBUS_COMMON_H ${HAVE_GLOBUS_COMMON_H} /* Define if we have GPFS support */ #cmakedefine HAVE_GPFS ${HAVE_GPFS} /* Define to 1 if you have the header file. */ #cmakedefine HAVE_GPFS_H ${HAVE_GPFS_H} /* Define if library will contain instrumentation to detect correct optimization operation */ #cmakedefine HAVE_INSTRUMENTED_LIBRARY ${HAVE_INSTRUMENTED_LIBRARY} /* Define to 1 if you have the header file. */ #cmakedefine HAVE_INTTYPES_H ${HAVE_INTTYPES_H} /* Define to 1 if you have the `ioctl' function. */ #cmakedefine HAVE_IOCTL ${HAVE_IOCTL} /* Define to 1 if you have the header file. */ #cmakedefine HAVE_IO_H ${HAVE_IO_H} /* Define if it's safe to use `long long' for hsize_t and hssize_t */ #cmakedefine HAVE_LARGE_HSIZET ${HAVE_LARGE_HSIZET} /* Define to 1 if you have the `crypto' library (-lcrypto). */ #cmakedefine HAVE_LIBCRYPTO ${HAVE_LIBCRYPTO} /* Define to 1 if you have the `dmalloc' library (-ldmalloc). */ #cmakedefine HAVE_LIBDMALLOC ${HAVE_LIBDMALLOC} /* Define to 1 if you have the `elf' library (-lelf). */ #cmakedefine HAVE_LIBELF ${HAVE_LIBELF} /* Define to 1 if you have the `globus_common' library (-lglobus_common). */ #cmakedefine HAVE_LIBGLOBUS_COMMON ${HAVE_LIBGLOBUS_COMMON} /* Define to 1 if you have the `globus_gaa' library (-lglobus_gaa). */ #cmakedefine HAVE_LIBGLOBUS_GAA ${HAVE_LIBGLOBUS_GAA} /* Define to 1 if you have the `globus_gass_cache' library (-lglobus_gass_cache). */ #cmakedefine HAVE_LIBGLOBUS_GASS_CACHE ${HAVE_LIBGLOBUS_GASS_CACHE} /* Define to 1 if you have the `globus_gass_file' library (-lglobus_gass_file). */ #cmakedefine HAVE_LIBGLOBUS_GASS_FILE ${HAVE_LIBGLOBUS_GASS_FILE} /* Define to 1 if you have the `globus_gass_transfer' library (-lglobus_gass_transfer). */ #cmakedefine HAVE_LIBGLOBUS_GASS_TRANSFER ${HAVE_LIBGLOBUS_GASS_TRANSFER} /* Define to 1 if you have the `globus_gass_transfer_assist' library (-lglobus_gass_transfer_assist). */ #cmakedefine HAVE_LIBGLOBUS_GASS_TRANSFER_ASSIST ${HAVE_LIBGLOBUS_GASS_TRANSFER_ASSIST} /* Define to 1 if you have the `globus_gss' library (-lglobus_gss). */ #cmakedefine HAVE_LIBGLOBUS_GSS ${HAVE_LIBGLOBUS_GSS} /* Define to 1 if you have the `globus_gss_assist' library (-lglobus_gss_assist). */ #cmakedefine HAVE_LIBGLOBUS_GSS_ASSIST ${HAVE_LIBGLOBUS_GSS_ASSIST} /* Define to 1 if you have the `globus_io' library (-lglobus_io). */ #cmakedefine HAVE_LIBGLOBUS_IO ${HAVE_LIBGLOBUS_IO} /* Define to 1 if you have the `lmpe' library (-llmpe). */ #cmakedefine HAVE_LIBLMPE ${HAVE_LIBLMPE} /* Define to 1 if you have the `m' library (-lm). */ #cmakedefine HAVE_LIBM ${HAVE_LIBM} /* Define to 1 if you have the `mpe' library (-lmpe). */ #cmakedefine HAVE_LIBMPE ${HAVE_LIBMPE} /* Define to 1 if you have the `mpi' library (-lmpi). */ #cmakedefine HAVE_LIBMPI ${HAVE_LIBMPI} /* Define to 1 if you have the `mpich' library (-lmpich). */ #cmakedefine HAVE_LIBMPICH ${HAVE_LIBMPICH} /* Define to 1 if you have the `mpio' library (-lmpio). */ #cmakedefine HAVE_LIBMPIO ${HAVE_LIBMPIO} /* Define to 1 if you have the `nsl' library (-lnsl). */ #cmakedefine HAVE_LIBNSL ${HAVE_LIBNSL} /* Define to 1 if you have the `pthread' library (-lpthread). */ #cmakedefine HAVE_LIBPTHREAD ${HAVE_LIBPTHREAD} /* Define to 1 if you have the `socket' library (-lsocket). */ #cmakedefine HAVE_LIBSOCKET ${HAVE_LIBSOCKET} /* Define to 1 if you have the `SrbClient' library (-lSrbClient). */ #cmakedefine HAVE_LIBSRBCLIENT ${HAVE_LIBSRBCLIENT} /* Define to 1 if you have the `ssl' library (-lssl). */ #cmakedefine HAVE_LIBSSL ${HAVE_LIBSSL} /* Define to 1 if you have the `sz' library (-lsz). */ #cmakedefine HAVE_LIBSZ ${HAVE_LIBSZ} /* Define to 1 if you have the `z' library (-lz). */ #cmakedefine HAVE_LIBZ ${HAVE_LIBZ} /* Define to 1 if you have the `longjmp' function. */ #cmakedefine HAVE_LONGJMP ${HAVE_LONGJMP} /* Define to 1 if you have the `lseek64' function. */ #cmakedefine HAVE_LSEEK64 ${HAVE_LSEEK64} /* Define to 1 if you have the header file. */ #cmakedefine HAVE_MEMORY_H ${HAVE_MEMORY_H} /* Define if we have MPE support */ #cmakedefine HAVE_MPE ${HAVE_MPE} /* Define to 1 if you have the header file. */ #cmakedefine HAVE_MPE_H ${HAVE_MPE_H} /* Define to 1 if you have the header file. */ #cmakedefine HAVE_NETINET_IN_H ${HAVE_NETINET_IN_H} /* Define to 1 if you have the header file. */ #cmakedefine HAVE_NETINET_TCP_H ${HAVE_NETINET_TCP_H} /* Define if we have parallel support */ #cmakedefine HAVE_PARALLEL ${HAVE_PARALLEL} /* Define to 1 if you have the header file. */ #cmakedefine HAVE_PTHREAD_H ${HAVE_PTHREAD_H} /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SETJMP_H ${HAVE_SETJMP_H} /* Define to 1 if you have the `setsysinfo' function. */ #cmakedefine HAVE_SETSYSINFO ${HAVE_SETSYSINFO} /* Define to 1 if you have the `sigaction' function. */ #cmakedefine HAVE_SIGACTION ${HAVE_SIGACTION} /* Define to 1 if you have the `signal' function. */ #cmakedefine HAVE_SIGNAL ${HAVE_SIGNAL} /* Define to 1 if you have the `snprintf' function. */ #cmakedefine HAVE_SNPRINTF ${HAVE_SNPRINTF} /* Define if `socklen_t' is defined */ #cmakedefine HAVE_SOCKLEN_T ${HAVE_SOCKLEN_T} /* Define if SO_REUSEADDR is defined */ #cmakedefine HAVE_SO_REUSEADDR ${HAVE_SO_REUSEADDR} /* Define if the SRB is defined */ #cmakedefine HAVE_SRB ${HAVE_SRB} /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SRBCLIENT_H ${HAVE_SRBCLIENT_H} /* Define if `struct stat' has the `st_blocks' field */ #cmakedefine HAVE_STAT_ST_BLOCKS ${HAVE_STAT_ST_BLOCKS} /* Define to 1 if you have the header file. */ #cmakedefine HAVE_STDDEF_H ${HAVE_STDDEF_H} /* Define to 1 if you have the header file. */ #cmakedefine HAVE_STDINT_H ${HAVE_STDINT_H} /* Define to 1 if you have the header file. */ #cmakedefine HAVE_STDLIB_H ${HAVE_STDLIB_H} /* Define to 1 if you have the `strdup' function. */ #cmakedefine HAVE_STRDUP ${HAVE_STRDUP} /* Define if the stream virtual file driver should be compiled */ #cmakedefine H5_HAVE_STREAM ${H5_HAVE_STREAM} /* Define to 1 if you have the header file. */ #cmakedefine HAVE_STRINGS_H ${HAVE_STRINGS_H} /* Define to 1 if you have the header file. */ #cmakedefine HAVE_STRING_H ${HAVE_STRING_H} /* Define if `struct text_info' is defined */ #cmakedefine HAVE_STRUCT_TEXT_INFO ${HAVE_STRUCT_TEXT_INFO} /* Define if `struct timezone' is defined */ #cmakedefine HAVE_STRUCT_TIMEZONE ${HAVE_STRUCT_TIMEZONE} /* Define to 1 if `tm_zone' is member of `struct tm'. */ #cmakedefine HAVE_STRUCT_TM_TM_ZONE ${HAVE_STRUCT_TM_TM_ZONE} /* Define if `struct videoconfig' is defined */ #cmakedefine HAVE_STRUCT_VIDEOCONFIG ${HAVE_STRUCT_VIDEOCONFIG} /* Define to 1 if you have the `system' function. */ #cmakedefine HAVE_SYSTEM ${HAVE_SYSTEM} /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_FILIO_H ${HAVE_SYS_FILIO_H} /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_FPU_H ${HAVE_SYS_FPU_H} /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_IOCTL_H ${HAVE_SYS_IOCTL_H} /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_PROC_H ${HAVE_SYS_PROC_H} /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_RESOURCE_H ${HAVE_SYS_RESOURCE_H} /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_SOCKET_H ${HAVE_SYS_SOCKET_H} /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_STAT_H ${HAVE_SYS_STAT_H} /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_SYSINFO_H ${HAVE_SYS_SYSINFO_H} /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_TIMEB_H ${HAVE_SYS_TIMEB_H} /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_TIME_H ${HAVE_SYS_TIME_H} /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_TYPES_H ${HAVE_SYS_TYPES_H} /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SZLIB_H ${HAVE_SZLIB_H} /* Define if we have thread safe support */ #cmakedefine HAVE_THREADSAFE ${HAVE_THREADSAFE} /* Define if `timezone' is a global variable */ #cmakedefine HAVE_TIMEZONE ${HAVE_TIMEZONE} /* Define if the ioctl TIOCGETD is defined */ #cmakedefine HAVE_TIOCGETD ${HAVE_TIOCGETD} /* Define if the ioctl TIOGWINSZ is defined */ #cmakedefine HAVE_TIOCGWINSZ ${HAVE_TIOCGWINSZ} /* Define if `tm_gmtoff' is a member of `struct tm' */ #cmakedefine HAVE_TM_GMTOFF ${HAVE_TM_GMTOFF} /* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use `HAVE_STRUCT_TM_TM_ZONE' instead. */ #cmakedefine HAVE_TM_ZONE ${HAVE_TM_ZONE} /* Define to 1 if you don't have `tm_zone' but do have the external array `tzname'. */ #cmakedefine HAVE_TZNAME ${HAVE_TZNAME} /* Define to 1 if you have the header file. */ #cmakedefine HAVE_UNISTD_H ${HAVE_UNISTD_H} /* Define to 1 if you have the `vsnprintf' function. */ #cmakedefine HAVE_VSNPRINTF ${HAVE_VSNPRINTF} /* Define to 1 if you have the `waitpid' function. */ #cmakedefine HAVE_WAITPID ${HAVE_WAITPID} /* Define to 1 if you have the header file. */ #cmakedefine HAVE_WINSOCK_H ${HAVE_WINSOCK_H} /* Define to 1 if you have the header file. */ #cmakedefine HAVE_ZLIB_H ${HAVE_ZLIB_H} /* Define to 1 if you have the `_getvideoconfig' function. */ #cmakedefine HAVE__GETVIDEOCONFIG ${HAVE__GETVIDEOCONFIG} /* Define to 1 if you have the `_scrsize' function. */ #cmakedefine HAVE__SCRSIZE ${HAVE__SCRSIZE} /* Define if `__tm_gmtoff' is a member of `struct tm' */ #cmakedefine HAVE___TM_GMTOFF ${HAVE___TM_GMTOFF} /* Define if your system can handle complicated MPI derived datatype correctly. */ #cmakedefine MPI_COMPLEX_DERIVED_DATATYPE_WORKS ${MPI_COMPLEX_DERIVED_DATATYPE_WORKS} /* Define if your system's `MPI_File_set_size' function works for files over 2GB. */ #cmakedefine MPI_FILE_SET_SIZE_BIG ${MPI_FILE_SET_SIZE_BIG} /* Define if shared writing must be disabled (CodeWarrior only) */ #cmakedefine NO_SHARED_WRITING ${NO_SHARED_WRITING} /* Define to the address where bug reports for this package should be sent. */ #cmakedefine PACKAGE_BUGREPORT ${PACKAGE_BUGREPORT} /* Define to the full name of this package. */ #cmakedefine PACKAGE_NAME ${PACKAGE_NAME} /* Define to the full name and version of this package. */ #cmakedefine PACKAGE_STRING ${PACKAGE_STRING} /* Define to the one symbol short name of this package. */ #cmakedefine PACKAGE_TARNAME ${PACKAGE_TARNAME} /* Define to the version of this package. */ #cmakedefine PACKAGE_VERSION ${PACKAGE_VERSION} /* Width for printf() for type `long long' or `__int64', use `ll' */ #cmakedefine PRINTF_LL_WIDTH ${PRINTF_LL_WIDTH} /* The size of a `char', as computed by sizeof. */ #cmakedefine SIZEOF_CHAR ${SIZEOF_CHAR} /* The size of a `double', as computed by sizeof. */ #cmakedefine SIZEOF_DOUBLE ${SIZEOF_DOUBLE} /* The size of a `float', as computed by sizeof. */ #cmakedefine SIZEOF_FLOAT ${SIZEOF_FLOAT} /* The size of a `int', as computed by sizeof. */ #cmakedefine SIZEOF_INT ${SIZEOF_INT} /* The size of a `int16_t', as computed by sizeof. */ #cmakedefine SIZEOF_INT16_T ${SIZEOF_INT16_T} /* The size of a `int32_t', as computed by sizeof. */ #cmakedefine SIZEOF_INT32_T ${SIZEOF_INT32_T} /* The size of a `int64_t', as computed by sizeof. */ #cmakedefine SIZEOF_INT64_T ${SIZEOF_INT64_T} /* The size of a `int8_t', as computed by sizeof. */ #cmakedefine SIZEOF_INT8_T ${SIZEOF_INT8_T} /* The size of a `int_fast16_t', as computed by sizeof. */ #cmakedefine SIZEOF_INT_FAST16_T ${SIZEOF_INT_FAST16_T} /* The size of a `int_fast32_t', as computed by sizeof. */ #cmakedefine SIZEOF_INT_FAST32_T ${SIZEOF_INT_FAST32_T} /* The size of a `int_fast64_t', as computed by sizeof. */ #cmakedefine SIZEOF_INT_FAST64_T ${SIZEOF_INT_FAST64_T} /* The size of a `int_fast8_t', as computed by sizeof. */ #cmakedefine SIZEOF_INT_FAST8_T ${SIZEOF_INT_FAST8_T} /* The size of a `int_least16_t', as computed by sizeof. */ #cmakedefine SIZEOF_INT_LEAST16_T ${SIZEOF_INT_LEAST16_T} /* The size of a `int_least32_t', as computed by sizeof. */ #cmakedefine SIZEOF_INT_LEAST32_T ${SIZEOF_INT_LEAST32_T} /* The size of a `int_least64_t', as computed by sizeof. */ #cmakedefine SIZEOF_INT_LEAST64_T ${SIZEOF_INT_LEAST64_T} /* The size of a `int_least8_t', as computed by sizeof. */ #cmakedefine SIZEOF_INT_LEAST8_T ${SIZEOF_INT_LEAST8_T} /* The size of a `long', as computed by sizeof. */ #cmakedefine SIZEOF_LONG ${SIZEOF_LONG} /* The size of a `long double', as computed by sizeof. */ #cmakedefine SIZEOF_LONG_DOUBLE ${SIZEOF_LONG_DOUBLE} /* The size of a `long long', as computed by sizeof. */ #cmakedefine SIZEOF_LONG_LONG ${SIZEOF_LONG_LONG} /* The size of a `off_t', as computed by sizeof. */ #cmakedefine SIZEOF_OFF_T ${SIZEOF_OFF_T} /* The size of a `short', as computed by sizeof. */ #cmakedefine SIZEOF_SHORT ${SIZEOF_SHORT} /* The size of a `size_t', as computed by sizeof. */ #cmakedefine SIZEOF_SIZE_T ${SIZEOF_SIZE_T} /* The size of a `ssize_t', as computed by sizeof. */ #cmakedefine SIZEOF_SSIZE_T ${SIZEOF_SSIZE_T} /* The size of a `uint16_t', as computed by sizeof. */ #cmakedefine SIZEOF_UINT16_T ${SIZEOF_UINT16_T} /* The size of a `uint32_t', as computed by sizeof. */ #cmakedefine SIZEOF_UINT32_T ${SIZEOF_UINT32_T} /* The size of a `uint64_t', as computed by sizeof. */ #cmakedefine SIZEOF_UINT64_T ${SIZEOF_UINT64_T} /* The size of a `uint8_t', as computed by sizeof. */ #cmakedefine SIZEOF_UINT8_T ${SIZEOF_UINT8_T} /* The size of a `uint_fast16_t', as computed by sizeof. */ #cmakedefine SIZEOF_UINT_FAST16_T ${SIZEOF_UINT_FAST16_T} /* The size of a `uint_fast32_t', as computed by sizeof. */ #cmakedefine SIZEOF_UINT_FAST32_T ${SIZEOF_UINT_FAST32_T} /* The size of a `uint_fast64_t', as computed by sizeof. */ #cmakedefine SIZEOF_UINT_FAST64_T ${SIZEOF_UINT_FAST64_T} /* The size of a `uint_fast8_t', as computed by sizeof. */ #cmakedefine SIZEOF_UINT_FAST8_T ${SIZEOF_UINT_FAST8_T} /* The size of a `uint_least16_t', as computed by sizeof. */ #cmakedefine SIZEOF_UINT_LEAST16_T ${SIZEOF_UINT_LEAST16_T} /* The size of a `uint_least32_t', as computed by sizeof. */ #cmakedefine SIZEOF_UINT_LEAST32_T ${SIZEOF_UINT_LEAST32_T} /* The size of a `uint_least64_t', as computed by sizeof. */ #cmakedefine SIZEOF_UINT_LEAST64_T ${SIZEOF_UINT_LEAST64_T} /* The size of a `uint_least8_t', as computed by sizeof. */ #cmakedefine SIZEOF_UINT_LEAST8_T ${SIZEOF_UINT_LEAST8_T} /* The size of a `__int64', as computed by sizeof. */ #cmakedefine SIZEOF___INT64 ${SIZEOF___INT64} /* Define to 1 if you have the ANSI C header files. */ #cmakedefine STDC_HEADERS ${STDC_HEADERS} /* Define if your system supports pthread_attr_setscope(&attribute, PTHREAD_SCOPE_SYSTEM) call. */ #cmakedefine SYSTEM_SCOPE_THREADS ${SYSTEM_SCOPE_THREADS} /* Define to 1 if you can safely include both and . */ #cmakedefine TIME_WITH_SYS_TIME ${TIME_WITH_SYS_TIME} /* Define to 1 if your declares `struct tm'. */ #cmakedefine TM_IN_SYS_TIME ${TM_IN_SYS_TIME} /* Define if the HDF5 v1.4 compatibility functions are to be compiled in */ #cmakedefine WANT_H5_V1_4_COMPAT ${WANT_H5_V1_4_COMPAT} /* Define to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel and VAX). */ #cmakedefine WORDS_BIGENDIAN ${WORDS_BIGENDIAN} /* Define to empty if `const' does not conform to ANSI C. */ #cmakedefine const ${const} /* Define to `__inline__' or `__inline' if that's what the C compiler calls it, or to nothing if 'inline' is not supported under any name. */ #ifndef __cplusplus #cmakedefine inline ${inline} #endif /* Define to `long' if does not define. */ #cmakedefine off_t ${off_t} /* Define to `unsigned long' if does not define. */ #cmakedefine size_t ${size_t} /* Define to `long' if does not define. */ #cmakedefine ssize_t ${ssize_t} #if defined(__cplusplus) && defined(inline) #undef inline #endif #if defined ( _MSC_VER ) #pragma warning ( disable : 4057 ) #pragma warning ( disable : 4100 ) #pragma warning ( disable : 4115 ) #pragma warning ( disable : 4127 ) #pragma warning ( disable : 4189 ) #pragma warning ( disable : 4244 ) #pragma warning ( disable : 4251 ) #pragma warning ( disable : 4273 ) #pragma warning ( disable : 4305 ) #pragma warning ( disable : 4309 ) #pragma warning ( disable : 4505 ) #pragma warning ( disable : 4701 ) #pragma warning ( disable : 4706 ) #pragma warning ( disable : 4786 ) #endif #cmakedefine BUILD_SHARED_LIBS #if defined(BUILD_SHARED_LIBS) || defined(H5_BUILD_SHARED_LIBS) # if defined (vtkhdf5_EXPORTS) # define _HDF5DLL_ # else # define _HDF5USEDLL_ # endif #endif xdmf-3.0+git20160803/Utilities/hdf5/H5Ofill.c0000640000175000017500000006507113003006557020312 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* Programmer: Robb Matzke * Wednesday, September 30, 1998 * * Purpose: The fill message indicates a bit pattern to use for * uninitialized data points of a dataset. */ #define H5O_PACKAGE /*suppress error about including H5Opkg */ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free Lists */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Opkg.h" /* Object header functions */ #include "H5Pprivate.h" /* Property lists */ static void *H5O_fill_new_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t *sh); static herr_t H5O_fill_new_encode(H5F_t *f, uint8_t *p, const void *_mesg); static void *H5O_fill_new_copy(const void *_mesg, void *_dest, unsigned update_flags); static size_t H5O_fill_new_size(const H5F_t *f, const void *_mesg); static herr_t H5O_fill_new_reset(void *_mesg); static herr_t H5O_fill_new_free(void *_mesg); static herr_t H5O_fill_new_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE *stream, int indent, int fwidth); static void *H5O_fill_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t *sh); static herr_t H5O_fill_encode(H5F_t *f, uint8_t *p, const void *_mesg); static void *H5O_fill_copy(const void *_mesg, void *_dest, unsigned update_flags); static size_t H5O_fill_size(const H5F_t *f, const void *_mesg); static herr_t H5O_fill_reset(void *_mesg); static herr_t H5O_fill_free(void *_mesg); static herr_t H5O_fill_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE *stream, int indent, int fwidth); /* This message derives from H5O, for old fill value before version 1.5 */ const H5O_class_t H5O_FILL[1] = {{ H5O_FILL_ID, /*message id number */ "fill", /*message name for debugging */ sizeof(H5O_fill_t), /*native message size */ H5O_fill_decode, /*decode message */ H5O_fill_encode, /*encode message */ H5O_fill_copy, /*copy the native value */ H5O_fill_size, /*raw message size */ H5O_fill_reset, /*free internal memory */ H5O_fill_free, /* free method */ NULL, /* file delete method */ NULL, /* link method */ NULL, /*get share method */ NULL, /*set share method */ H5O_fill_debug, /*debug the message */ }}; /* This message derives from H5O, for new fill value after version 1.4 */ const H5O_class_t H5O_FILL_NEW[1] = {{ H5O_FILL_NEW_ID, /*message id number */ "fill_new", /*message name for debugging */ sizeof(H5O_fill_new_t), /*native message size */ H5O_fill_new_decode, /*decode message */ H5O_fill_new_encode, /*encode message */ H5O_fill_new_copy, /*copy the native value */ H5O_fill_new_size, /*raw message size */ H5O_fill_new_reset, /*free internal memory */ H5O_fill_new_free, /* free method */ NULL, /* file delete method */ NULL, /* link method */ NULL, /*get share method */ NULL, /*set share method */ H5O_fill_new_debug, /*debug the message */ }}; /* Initial version of the "old" fill value information */ #define H5O_FILL_VERSION 1 /* Revised version of the "new" fill value information */ #define H5O_FILL_VERSION_2 2 /* Declare a free list to manage the H5O_fill_new_t struct */ H5FL_DEFINE(H5O_fill_new_t); /* Declare a free list to manage the H5O_fill_t struct */ H5FL_DEFINE(H5O_fill_t); /*------------------------------------------------------------------------- * Function: H5O_fill_new_decode * * Purpose: Decode a new fill value message. The new fill value * message is fill value plus space allocation time and * fill value writing time and whether fill value is defined. * * Return: Success: Ptr to new message in native struct. * * Failure: NULL * * Programmer: Raymond Lu * Feb 26, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static void * H5O_fill_new_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const uint8_t *p, H5O_shared_t UNUSED *sh) { H5O_fill_new_t *mesg=NULL; int version; void *ret_value; FUNC_ENTER_NOAPI_NOINIT(H5O_fill_new_decode); assert(f); assert(p); assert(!sh); if (NULL==(mesg=H5FL_CALLOC(H5O_fill_new_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fill value message"); /* Version */ version = *p++; if( version != H5O_FILL_VERSION && version !=H5O_FILL_VERSION_2) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for fill value message"); /* Space allocation time */ mesg->alloc_time = (H5D_alloc_time_t)*p++; /* Fill value write time */ mesg->fill_time = (H5D_fill_time_t)*p++; /* Whether fill value is defined */ mesg->fill_defined = *p++; /* Only decode fill value information if one is defined */ if(mesg->fill_defined) { INT32DECODE(p, mesg->size); if (mesg->size>0) { H5_CHECK_OVERFLOW(mesg->size,ssize_t,size_t); if (NULL==(mesg->buf=H5MM_malloc((size_t)mesg->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fill value"); HDmemcpy(mesg->buf, p, (size_t)mesg->size); } } /* end if */ else mesg->size=(-1); /* Set return value */ ret_value = (void*)mesg; done: if (!ret_value && mesg) { if(mesg->buf) H5MM_xfree(mesg->buf); H5FL_FREE(H5O_fill_new_t,mesg); } FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_fill_decode * * Purpose: Decode a fill value message. * * Return: Success: Ptr to new message in native struct. * * Failure: NULL * * Programmer: Robb Matzke * Wednesday, September 30, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static void * H5O_fill_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const uint8_t *p, H5O_shared_t UNUSED *sh) { H5O_fill_t *mesg=NULL; void *ret_value; FUNC_ENTER_NOAPI_NOINIT(H5O_fill_decode); assert(f); assert(p); assert(!sh); if (NULL==(mesg=H5FL_CALLOC(H5O_fill_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fill value message"); UINT32DECODE(p, mesg->size); if (mesg->size>0) { if (NULL==(mesg->buf=H5MM_malloc(mesg->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fill value"); HDmemcpy(mesg->buf, p, mesg->size); } /* Set return value */ ret_value = (void*)mesg; done: if (!ret_value && mesg) { if(mesg->buf) H5MM_xfree(mesg->buf); H5FL_FREE(H5O_fill_t,mesg); } FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_fill_new_encode * * Purpose: Encode a new fill value message. The new fill value * message is fill value plus space allocation time and * fill value writing time and whether fill value is defined. * * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu * Feb 26, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_fill_new_encode(H5F_t UNUSED *f, uint8_t *p, const void *_mesg) { const H5O_fill_new_t *mesg = (const H5O_fill_new_t *)_mesg; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_fill_new_encode); assert(f); assert(p); assert(mesg && NULL==mesg->type); /* Version */ *p++ = H5O_FILL_VERSION; /* Space allocation time */ *p++ = mesg->alloc_time; /* Fill value writing time */ *p++ = mesg->fill_time; /* Whether fill value is defined */ *p++ = mesg->fill_defined; /* Does it handle undefined fill value? */ INT32ENCODE(p, mesg->size); if(mesg->size>0) if(mesg->buf) { H5_CHECK_OVERFLOW(mesg->size,ssize_t,size_t); HDmemcpy(p, mesg->buf, (size_t)mesg->size); } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED); } /*------------------------------------------------------------------------- * Function: H5O_fill_encode * * Purpose: Encode a fill value message. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Thursday, October 1, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_fill_encode(H5F_t UNUSED *f, uint8_t *p, const void *_mesg) { const H5O_fill_t *mesg = (const H5O_fill_t *)_mesg; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_fill_encode); assert(f); assert(p); assert(mesg && NULL==mesg->type); UINT32ENCODE(p, mesg->size); if(mesg->buf) HDmemcpy(p, mesg->buf, mesg->size); FUNC_LEAVE_NOAPI(SUCCEED); } /*------------------------------------------------------------------------- * Function: H5O_fill_new_copy * * Purpose: Copies a message from _MESG to _DEST, allocating _DEST if * necessary. The new fill value message is fill value plus * space allocation time and fill value writing time and * whether fill value is defined. * * Return: Success: Ptr to _DEST * * Failure: NULL * * Programmer: Raymond Lu * Feb 26, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static void * H5O_fill_new_copy(const void *_mesg, void *_dest, unsigned UNUSED update_flags) { const H5O_fill_new_t *mesg = (const H5O_fill_new_t *)_mesg; H5O_fill_new_t *dest = (H5O_fill_new_t *)_dest; void *ret_value; FUNC_ENTER_NOAPI_NOINIT(H5O_fill_new_copy); assert(mesg); if (!dest && NULL==(dest=H5FL_MALLOC(H5O_fill_new_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fill message"); /* Copy data type of fill value */ if (mesg->type) { if(NULL==(dest->type=H5T_copy(mesg->type, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy fill value data type"); } /* end if */ else dest->type=NULL; /* Copy fill value and its size */ if (mesg->buf) { H5_CHECK_OVERFLOW(mesg->size,ssize_t,size_t); if (NULL==(dest->buf=H5MM_malloc((size_t)mesg->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fill value"); HDmemcpy(dest->buf, mesg->buf, (size_t)mesg->size); } /* end if */ else dest->buf=NULL; dest->size = mesg->size; /* Copy three fill value attributes */ dest->alloc_time = mesg->alloc_time; dest->fill_time = mesg->fill_time; dest->fill_defined = mesg->fill_defined; /* Set return value */ ret_value = dest; done: if (!ret_value && dest) { if(dest->buf) H5MM_xfree(dest->buf); if (dest->type) H5T_close(dest->type); if (!_dest) H5FL_FREE(H5O_fill_new_t,dest); } FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_fill_copy * * Purpose: Copies a message from _MESG to _DEST, allocating _DEST if * necessary. * * Return: Success: Ptr to _DEST * * Failure: NULL * * Programmer: Robb Matzke * Thursday, October 1, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static void * H5O_fill_copy(const void *_mesg, void *_dest, unsigned UNUSED update_flags) { const H5O_fill_t *mesg = (const H5O_fill_t *)_mesg; H5O_fill_t *dest = (H5O_fill_t *)_dest; void *ret_value; FUNC_ENTER_NOAPI_NOINIT(H5O_fill_copy); assert(mesg); if (!dest && NULL==(dest=H5FL_CALLOC(H5O_fill_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fill message"); if (mesg->type) { if(NULL==(dest->type=H5T_copy(mesg->type, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy fill value data type"); } /* end if */ else dest->type=NULL; if (mesg->buf) { if (NULL==(dest->buf=H5MM_malloc(mesg->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fill value"); HDmemcpy(dest->buf, mesg->buf, mesg->size); } /* end if */ else dest->buf=NULL; dest->size = mesg->size; /* Set return value */ ret_value = dest; done: if (!ret_value && dest) { if(dest->buf) H5MM_xfree(dest->buf); if (dest->type) H5T_close(dest->type); if (!_dest) H5FL_FREE(H5O_fill_t,dest); } FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_fill_new_size * * Purpose: Returns the size of the raw message in bytes not counting the * message type or size fields, but only the data fields. This * function doesn't take into account alignment. The new fill * value message is fill value plus space allocation time and * fill value writing time and whether fill value is defined. * * Return: Success: Message data size in bytes w/o alignment. * * Failure: 0 * * Programmer: Robb Matzke * Thursday, October 1, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static size_t H5O_fill_new_size(const H5F_t UNUSED *f, const void *_mesg) { const H5O_fill_new_t *mesg = (const H5O_fill_new_t *)_mesg; size_t ret_value; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_fill_new_size); assert(f); assert(mesg); ret_value = 1 + /* Version number */ 1 + /* Space allocation time */ 1 + /* Fill value write time */ 1 + /* Fill value defined */ 4 + /* Fill value size */ (mesg->size>0 ? mesg->size : 0); /* Size of fill value */ FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_fill_size * * Purpose: Returns the size of the raw message in bytes not counting the * message type or size fields, but only the data fields. This * function doesn't take into account alignment. * * Return: Success: Message data size in bytes w/o alignment. * * Failure: 0 * * Programmer: Robb Matzke * Thursday, October 1, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static size_t H5O_fill_size(const H5F_t UNUSED *f, const void *_mesg) { const H5O_fill_t *mesg = (const H5O_fill_t *)_mesg; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_fill_size); assert(f); assert(mesg); FUNC_LEAVE_NOAPI(4+mesg->size); } /*------------------------------------------------------------------------- * Function: H5O_fill_new_reset * * Purpose: Resets a new message to an initial state. The new fill value * message is fill value plus space allocation time and * fill value writing time and whether fill value is defined. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Thursday, October 1, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_fill_new_reset(void *_mesg) { H5O_fill_new_t *mesg = (H5O_fill_new_t *)_mesg; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_fill_new_reset); assert(mesg); if(mesg->buf) mesg->buf = H5MM_xfree(mesg->buf); mesg->size = -1; if (mesg->type) { H5T_close(mesg->type); mesg->type = NULL; } mesg->alloc_time = (H5D_alloc_time_t)0; mesg->fill_time = (H5D_fill_time_t)0; mesg->fill_defined = FALSE; FUNC_LEAVE_NOAPI(SUCCEED); } /*------------------------------------------------------------------------- * Function: H5O_fill_reset * * Purpose: Resets a message to an initial state * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Thursday, October 1, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_fill_reset(void *_mesg) { H5O_fill_t *mesg = (H5O_fill_t *)_mesg; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_fill_reset); assert(mesg); if(mesg->buf) mesg->buf = H5MM_xfree(mesg->buf); mesg->size = 0; if (mesg->type) { H5T_close(mesg->type); mesg->type = NULL; } FUNC_LEAVE_NOAPI(SUCCEED); } /*------------------------------------------------------------------------- * Function: H5O_fill_new_free * * Purpose: Free's the message * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Thursday, December 5, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_fill_new_free (void *mesg) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_fill_new_free); assert (mesg); H5FL_FREE(H5O_fill_new_t,mesg); FUNC_LEAVE_NOAPI(SUCCEED); } /*------------------------------------------------------------------------- * Function: H5O_fill_free * * Purpose: Free's the message * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Thursday, December 5, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_fill_free (void *mesg) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_fill_free); assert (mesg); H5FL_FREE(H5O_fill_t,mesg); FUNC_LEAVE_NOAPI(SUCCEED); } /*------------------------------------------------------------------------- * Function: H5O_fill_new_debug * * Purpose: Prints debugging info for the message. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Thursday, October 1, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_fill_new_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg, FILE *stream, int indent, int fwidth) { const H5O_fill_new_t *mesg = (const H5O_fill_new_t *)_mesg; H5D_fill_value_t fill_status; /* Whether the fill value is defined */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_fill_new_debug); assert(f); assert(mesg); assert(stream); assert(indent>=0); assert(fwidth>=0); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Version:", (unsigned)H5O_FILL_VERSION); fprintf(stream, "%*s%-*s ", indent, "", fwidth, "Space Allocation Time:"); switch(mesg->alloc_time) { case H5D_ALLOC_TIME_EARLY: fprintf(stream,"Early\n"); break; case H5D_ALLOC_TIME_LATE: fprintf(stream,"Late\n"); break; case H5D_ALLOC_TIME_INCR: fprintf(stream,"Incremental\n"); break; default: fprintf(stream,"Unknown!\n"); break; } /* end switch */ fprintf(stream, "%*s%-*s ", indent, "", fwidth, "Fill Time:"); switch(mesg->fill_time) { case H5D_FILL_TIME_ALLOC: fprintf(stream,"On Allocation\n"); break; case H5D_FILL_TIME_NEVER: fprintf(stream,"Never\n"); break; case H5D_FILL_TIME_IFSET: fprintf(stream,"If Set\n"); break; default: fprintf(stream,"Unknown!\n"); break; } /* end switch */ fprintf(stream, "%*s%-*s ", indent, "", fwidth, "Fill Value Defined:"); H5P_is_fill_value_defined((const H5O_fill_t *)mesg, &fill_status); switch(fill_status) { case H5D_FILL_VALUE_UNDEFINED: fprintf(stream,"Undefined\n"); break; case H5D_FILL_VALUE_DEFAULT: fprintf(stream,"Default\n"); break; case H5D_FILL_VALUE_USER_DEFINED: fprintf(stream,"User Defined\n"); break; default: fprintf(stream,"Unknown!\n"); break; } /* end switch */ HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, "Size:", mesg->size); fprintf(stream, "%*s%-*s ", indent, "", fwidth, "Data type:"); if (mesg->type) { H5T_debug(mesg->type, stream); fprintf(stream, "\n"); } else { fprintf(stream, "\n"); } FUNC_LEAVE_NOAPI(SUCCEED); } /*------------------------------------------------------------------------- * Function: H5O_fill_debug * * Purpose: Prints debugging info for the message. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Thursday, October 1, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_fill_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg, FILE *stream, int indent, int fwidth) { const H5O_fill_t *mesg = (const H5O_fill_t *)_mesg; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_fill_debug); assert(f); assert(mesg); assert(stream); assert(indent>=0); assert(fwidth>=0); HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, "Bytes:", mesg->size); fprintf(stream, "%*s%-*s ", indent, "", fwidth, "Data type:"); if (mesg->type) { H5T_debug(mesg->type, stream); fprintf(stream, "\n"); } else { fprintf(stream, "\n"); } FUNC_LEAVE_NOAPI(SUCCEED); } /*------------------------------------------------------------------------- * Function: H5O_fill_convert * * Purpose: Convert a fill value from whatever data type it currently has * to the specified dataset type. The `type' field of the fill * value struct will be set to NULL to indicate that it has the * same type as the dataset. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Thursday, October 1, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5O_fill_convert(void *_fill, H5T_t *dset_type, hid_t dxpl_id) { H5O_fill_new_t *fill = _fill; H5T_path_t *tpath=NULL; /*type conversion info */ void *buf=NULL, *bkg=NULL; /*conversion buffers */ hid_t src_id=-1, dst_id=-1; /*datatype identifiers */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_fill_convert); assert(fill); assert(dset_type); /* No-op cases */ if (!fill->buf || !fill->type || 0==H5T_cmp(fill->type, dset_type, FALSE)) { if (fill->type) H5T_close(fill->type); fill->type = NULL; HGOTO_DONE(SUCCEED); } /* * Can we convert between source and destination data types? */ if (NULL==(tpath=H5T_path_find(fill->type, dset_type, NULL, NULL, dxpl_id))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert between src and dst datatypes") /* Don't bother doing anything if there will be no actual conversion */ if (!H5T_path_noop(tpath)) { if ((src_id = H5I_register(H5I_DATATYPE, H5T_copy(fill->type, H5T_COPY_ALL)))<0 || (dst_id = H5I_register(H5I_DATATYPE, H5T_copy(dset_type, H5T_COPY_ALL)))<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy/register data type"); /* * Datatype conversions are always done in place, so we need a buffer * that is large enough for both source and destination. */ if (H5T_get_size(fill->type)>=H5T_get_size(dset_type)) { buf = fill->buf; } else { if (NULL==(buf=H5MM_malloc(H5T_get_size(dset_type)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion"); HDmemcpy(buf, fill->buf, H5T_get_size(fill->type)); } if (H5T_path_bkg(tpath) && NULL==(bkg=H5MM_malloc(H5T_get_size(dset_type)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion"); /* Do the conversion */ if (H5T_convert(tpath, src_id, dst_id, 1, 0, 0, buf, bkg, dxpl_id)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed"); /* Update the fill message */ if (buf!=fill->buf) { H5MM_xfree(fill->buf); fill->buf = buf; } H5T_close(fill->type); fill->type = NULL; H5_ASSIGN_OVERFLOW(fill->size,H5T_get_size(dset_type),size_t,ssize_t); } /* end if */ done: if (src_id>=0) H5I_dec_ref(src_id); if (dst_id>=0) H5I_dec_ref(dst_id); if (buf!=fill->buf) H5MM_xfree(buf); if (bkg) H5MM_xfree(bkg); FUNC_LEAVE_NOAPI(ret_value); } xdmf-3.0+git20160803/Utilities/hdf5/H5FO.c0000640000175000017500000004453113003006557017547 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Open object info algorithms. * * These are used to track the objects currently open in a file, for various * internal mechanisms which need to be aware of such things. * */ #define H5F_PACKAGE /*suppress error about including H5Fpkg */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* File access */ #include "H5FLprivate.h" /* Free lists */ #include "H5FOprivate.h" /* File objects */ #include "H5Oprivate.h" /* Object headers */ /* Private typedefs */ /* Information about open objects in a file */ typedef struct H5FO_open_obj_t { haddr_t addr; /* Address of object header for object */ void *obj; /* Pointer to the object */ hbool_t deleted; /* Flag to indicate that the object was deleted from the file */ } H5FO_open_obj_t; /* Information about counted objects in a file */ typedef struct H5FO_obj_count_t { haddr_t addr; /* Address of object header for object */ hsize_t count; /* Number of times object is opened */ } H5FO_obj_count_t; /* Declare a free list to manage the H5FO_open_obj_t struct */ H5FL_DEFINE_STATIC(H5FO_open_obj_t); /* Declare a free list to manage the H5FO_obj_count_t struct */ H5FL_DEFINE_STATIC(H5FO_obj_count_t); /*-------------------------------------------------------------------------- NAME H5FO_create PURPOSE Create an open object info set USAGE herr_t H5FO_create(f) H5F_t *f; IN/OUT: File to create opened object info set for RETURNS Returns non-negative on success, negative on failure DESCRIPTION Create a new open object info set. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5FO_create(const H5F_t *f) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FO_create,FAIL) /* Sanity check */ assert(f); assert(f->shared); /* Create container used to store open object info */ if((f->shared->open_objs=H5SL_create(H5SL_TYPE_HADDR,0.5,16))==NULL) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to create open object container") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FO_create() */ /*-------------------------------------------------------------------------- NAME H5FO_opened PURPOSE Checks if an object at an address is already open in the file. USAGE void * H5FO_opened(f,addr) const H5F_t *f; IN: File to check opened object info set haddr_t addr; IN: Address of object to check RETURNS Returns a pointer to the object on success, NULL on failure DESCRIPTION Check is an object at an address (the address of the object's object header) is already open in the file and return the ID for that object if it is open. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ void * H5FO_opened(const H5F_t *f, haddr_t addr) { H5FO_open_obj_t *open_obj; /* Information about open object */ void *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOFUNC(H5FO_opened) /* Sanity check */ assert(f); assert(f->shared); assert(f->shared->open_objs); assert(H5F_addr_defined(addr)); /* Get the object node from the container */ if((open_obj=H5SL_search(f->shared->open_objs,&addr))!=NULL) { ret_value=open_obj->obj; assert(ret_value!=NULL); } /* end if */ else ret_value=NULL; FUNC_LEAVE_NOAPI(ret_value) } /* end H5FO_opened() */ /*-------------------------------------------------------------------------- NAME H5FO_insert PURPOSE Insert a newly opened object/pointer pair into the opened object info set USAGE herr_t H5FO_insert(f,addr,obj) H5F_t *f; IN/OUT: File's opened object info set haddr_t addr; IN: Address of object to insert void *obj; IN: Pointer to object to insert int type; IN: Type of object being inserted RETURNS Returns a non-negative on success, negative on failure DESCRIPTION Insert an object/ID pair into the opened object info set. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5FO_insert(const H5F_t *f, haddr_t addr, void *obj) { H5FO_open_obj_t *open_obj; /* Information about open object */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FO_insert,FAIL) /* Sanity check */ assert(f); assert(f->shared); assert(f->shared->open_objs); assert(H5F_addr_defined(addr)); assert(obj); /* Allocate new opened object information structure */ if((open_obj=H5FL_MALLOC(H5FO_open_obj_t))==NULL) HGOTO_ERROR(H5E_CACHE,H5E_NOSPACE,FAIL,"memory allocation failed") /* Assign information */ open_obj->addr=addr; open_obj->obj=obj; open_obj->deleted=0; /* Insert into container */ if(H5SL_insert(f->shared->open_objs,&open_obj->addr,open_obj)<0) HGOTO_ERROR(H5E_CACHE,H5E_CANTINSERT,FAIL,"can't insert object into container") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FO_insert() */ /*-------------------------------------------------------------------------- NAME H5FO_delete PURPOSE Remove an opened object/ID pair from the opened object info set USAGE herr_t H5FO_delete(f,addr) H5F_t *f; IN/OUT: File's opened object info set haddr_t addr; IN: Address of object to remove RETURNS Returns a non-negative on success, negative on failure DESCRIPTION Remove an object/ID pair from the opened object info. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5FO_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr) { H5FO_open_obj_t *open_obj; /* Information about open object */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FO_delete,FAIL) /* Sanity check */ assert(f); assert(f->shared); assert(f->shared->open_objs); assert(H5F_addr_defined(addr)); /* Remove from container */ if((open_obj=H5SL_remove(f->shared->open_objs,&addr))==NULL) HGOTO_ERROR(H5E_CACHE,H5E_CANTRELEASE,FAIL,"can't remove object from container") /* Check if the object was deleted from the file */ if(open_obj->deleted) { if(H5O_delete(f, dxpl_id, addr)<0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "can't delete object from file") } /* end if */ /* Release the object information */ H5FL_FREE(H5FO_open_obj_t,open_obj); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FO_delete() */ /*-------------------------------------------------------------------------- NAME H5FO_mark PURPOSE Mark an object to be deleted when it is closed USAGE herr_t H5FO_mark(f,addr) const H5F_t *f; IN: File opened object is in haddr_t addr; IN: Address of object to delete RETURNS Returns a non-negative ID for the object on success, negative on failure DESCRIPTION Mark an opened object for deletion from the file when it is closed. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5FO_mark(const H5F_t *f, haddr_t addr, hbool_t deleted) { H5FO_open_obj_t *open_obj; /* Information about open object */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOFUNC(H5FO_mark) /* Sanity check */ assert(f); assert(f->shared); assert(f->shared->open_objs); assert(H5F_addr_defined(addr)); /* Get the object node from the container */ if((open_obj=H5SL_search(f->shared->open_objs,&addr))!=NULL) open_obj->deleted=deleted; else ret_value=FAIL; FUNC_LEAVE_NOAPI(ret_value) } /* end H5FO_mark() */ /*-------------------------------------------------------------------------- NAME H5FO_marked PURPOSE Check if an object is marked to be deleted when it is closed USAGE htri_t H5FO_mark(f,addr) const H5F_t *f; IN: File opened object is in haddr_t addr; IN: Address of object to delete RETURNS Returns a TRUE/FALSE on success, negative on failure DESCRIPTION Checks if the object is currently in the "opened objects" tree and whether its marks for deletion from the file when it is closed. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ htri_t H5FO_marked(const H5F_t *f, haddr_t addr) { H5FO_open_obj_t *open_obj; /* Information about open object */ htri_t ret_value=FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOFUNC(H5FO_marked) /* Sanity check */ assert(f); assert(f->shared); assert(f->shared->open_objs); assert(H5F_addr_defined(addr)); /* Get the object node from the container */ if((open_obj=H5SL_search(f->shared->open_objs,&addr))!=NULL) ret_value=open_obj->deleted; FUNC_LEAVE_NOAPI(ret_value) } /* end H5FO_marked() */ /*-------------------------------------------------------------------------- NAME H5FO_dest PURPOSE Destroy an open object info set USAGE herr_t H5FO_dest(f) H5F_t *f; IN/OUT: File's opened object info set RETURNS Returns a non-negative on success, negative on failure DESCRIPTION Destroy an existing open object info set. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5FO_dest(const H5F_t *f) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FO_dest,FAIL) /* Sanity check */ assert(f); assert(f->shared); assert(f->shared->open_objs); /* Check if the object info set is empty */ if(H5SL_count(f->shared->open_objs)!=0) HGOTO_ERROR(H5E_CACHE, H5E_CANTRELEASE, FAIL, "objects still in open object info set") /* Release the open object info set container */ if(H5SL_close(f->shared->open_objs)<0) HGOTO_ERROR(H5E_CACHE, H5E_CANTCLOSEOBJ, FAIL, "can't close open object info set") f->shared->open_objs=NULL; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FO_dest() */ /*-------------------------------------------------------------------------- NAME H5FO_top_create PURPOSE Create the "top" open object count set USAGE herr_t H5FO_create(f) H5F_t *f; IN/OUT: File to create opened object count set for RETURNS Returns non-negative on success, negative on failure DESCRIPTION Create a new open object count set. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5FO_top_create(H5F_t *f) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FO_top_create, FAIL) /* Sanity check */ HDassert(f); /* Create container used to store open object info */ if((f->obj_count = H5SL_create(H5SL_TYPE_HADDR, 0.5, 16)) == NULL) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to create open object container") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FO_top_create() */ /*-------------------------------------------------------------------------- NAME H5FO_top_incr PURPOSE Increment the "top" reference count for an object in a file USAGE herr_t H5FO_top_incr(f, addr) H5F_t *f; IN/OUT: File's opened object info set haddr_t addr; IN: Address of object to increment RETURNS Returns a non-negative on success, negative on failure DESCRIPTION Increment the reference count for an object in the opened object count set. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5FO_top_incr(const H5F_t *f, haddr_t addr) { H5FO_obj_count_t *obj_count; /* Ref. count for object */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FO_top_incr, FAIL) /* Sanity check */ HDassert(f); HDassert(f->obj_count); HDassert(H5F_addr_defined(addr)); /* Get the object node from the container */ if((obj_count = H5SL_search(f->obj_count, &addr)) != NULL) { (obj_count->count)++; } /* end if */ else { /* Allocate new opened object information structure */ if((obj_count = H5FL_MALLOC(H5FO_obj_count_t)) == NULL) HGOTO_ERROR(H5E_CACHE,H5E_NOSPACE,FAIL,"memory allocation failed") /* Assign information */ obj_count->addr = addr; obj_count->count = 1; /* Insert into container */ if(H5SL_insert(f->obj_count, &obj_count->addr, obj_count) < 0) HGOTO_ERROR(H5E_CACHE,H5E_CANTINSERT,FAIL,"can't insert object into container") } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FO_top_incr() */ /*-------------------------------------------------------------------------- NAME H5FO_top_decr PURPOSE Decrement the "top" reference count for an object in a file USAGE herr_t H5FO_top_decr(f, addr) H5F_t *f; IN/OUT: File's opened object info set haddr_t addr; IN: Address of object to decrement RETURNS Returns a non-negative on success, negative on failure DESCRIPTION Decrement the reference count for an object in the opened object count set. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5FO_top_decr(const H5F_t *f, haddr_t addr) { H5FO_obj_count_t *obj_count; /* Ref. count for object */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FO_top_decr, FAIL) /* Sanity check */ HDassert(f); HDassert(f->obj_count); HDassert(H5F_addr_defined(addr)); /* Get the object node from the container */ if((obj_count = H5SL_search(f->obj_count, &addr)) != NULL) { /* Decrement the reference count for the object */ (obj_count->count)--; if(obj_count->count == 0) { /* Remove from container */ if((obj_count = H5SL_remove(f->obj_count, &addr)) == NULL) HGOTO_ERROR(H5E_CACHE, H5E_CANTRELEASE, FAIL, "can't remove object from container") /* Release the object information */ H5FL_FREE(H5FO_obj_count_t, obj_count); } /* end if */ } /* end if */ else HGOTO_ERROR(H5E_CACHE, H5E_NOTFOUND, FAIL, "can't decrement ref. count") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FO_top_decr() */ /*-------------------------------------------------------------------------- NAME H5FO_top_count PURPOSE Return the "top" reference count for an object in a file USAGE hsize_t H5FO_top_incr(f, addr) H5F_t *f; IN/OUT: File's opened object info set haddr_t addr; IN: Address of object to increment RETURNS Returns a non-negative on success, negative on failure DESCRIPTION Retrieves the reference count for an object in the opened object count set. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ hsize_t H5FO_top_count(const H5F_t *f, haddr_t addr) { H5FO_obj_count_t *obj_count; /* Ref. count for object */ hsize_t ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FO_top_count) /* Sanity check */ HDassert(f); HDassert(f->obj_count); HDassert(H5F_addr_defined(addr)); /* Get the object node from the container */ if((obj_count = H5SL_search(f->obj_count, &addr)) != NULL) ret_value = obj_count->count; else ret_value = 0; FUNC_LEAVE_NOAPI(ret_value) } /* end H5FO_top_count() */ /*-------------------------------------------------------------------------- NAME H5FO_top_dest PURPOSE Destroy an open object info set USAGE herr_t H5FO_top_dest(f) H5F_t *f; IN/OUT: File's opened object info set RETURNS Returns a non-negative on success, negative on failure DESCRIPTION Destroy an existing open object info set. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5FO_top_dest(H5F_t *f) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FO_top_dest, FAIL) /* Sanity check */ HDassert(f); HDassert(f->obj_count); /* Check if the object count set is empty */ if(H5SL_count(f->obj_count) != 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTRELEASE, FAIL, "objects still in open object info set") /* Release the open object count set container */ if(H5SL_close(f->obj_count) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTCLOSEOBJ, FAIL, "can't close open object info set") f->obj_count = NULL; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FO_top_dest() */ xdmf-3.0+git20160803/Utilities/hdf5/H5FDmpiposix.c0000640000175000017500000015621013003006557021323 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Quincey Koziol * Thursday, July 11, 2002 * * Purpose: This is a "combination" MPI-2 and posix I/O driver. * It uses MPI for coordinating the actions of several processes * and posix I/O calls to do the actual I/O to the disk. * * This driver was derived from the H5FDmpio.c driver and may * share bugs/quirks/etc. * * Limitations: * There is no "collective" I/O mode with this driver. * * This will almost certainly _not_ work correctly for files * accessed on distributed parallel systems with the file located * on a non-parallel filesystem. * */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5FD_mpiposix_init_interface #include "H5private.h" /* Generic Functions */ #include "H5ACprivate.h" /* Metadata cache */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fprivate.h" /* File access */ #include "H5FDprivate.h" /* File drivers */ #include "H5FDmpi.h" /* MPI-based file drivers */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Pprivate.h" /* Property lists */ /* Features: * H5_HAVE_GPFS -- issue gpfs_fcntl() calls to hopefully improve * performance when accessing files on a GPFS * file system. * * REPORT_IO -- if set then report all POSIX file calls to stderr. * */ /* #define REPORT_IO */ #ifdef H5_HAVE_GPFS # include #endif #ifdef H5_HAVE_PARALLEL /* * The driver identification number, initialized at runtime if H5_HAVE_PARALLEL * is defined. This allows applications to still have the H5FD_MPIPOSIX * "constants" in their source code (it also makes this file strictly ANSI * compliant when H5_HAVE_PARALLEL isn't defined) */ static hid_t H5FD_MPIPOSIX_g = 0; /* File operations */ #define OP_UNKNOWN 0 #define OP_READ 1 #define OP_WRITE 2 /* * The description of a file belonging to this driver. * The EOF value * is only used just after the file is opened in order for the library to * determine whether the file is empty, truncated, or okay. The MPIPOSIX driver * doesn't bother to keep it updated since it's an expensive operation. */ typedef struct H5FD_mpiposix_t { H5FD_t pub; /*public stuff, must be first */ int fd; /*the unix file handle */ MPI_Comm comm; /*communicator */ int mpi_rank; /* This process's rank */ int mpi_size; /* Total number of processes */ haddr_t eof; /*end-of-file marker */ haddr_t eoa; /*end-of-address marker */ haddr_t last_eoa; /* Last known end-of-address marker */ haddr_t pos; /* Current file I/O position */ int op; /* Last file I/O operation */ hsize_t naccess; /* Number of (write) accesses to file */ size_t blksize; /* Block size of file system */ hbool_t use_gpfs; /* Use GPFS to write things */ #ifndef WIN32 /* * On most systems the combination of device and i-node number uniquely * identify a file. */ dev_t device; /*file device number */ ino_t inode; /*file i-node number */ #else /* * On WIN32 the low-order word of a unique identifier associated with the * file and the volume serial number uniquely identify a file. This number * (which, both? -rpm) may change when the system is restarted or when the * file is opened. After a process opens a file, the identifier is * constant until the file is closed. An application can use this * identifier and the volume serial number to determine whether two * handles refer to the same file. */ int fileindexlo; int fileindexhi; #endif } H5FD_mpiposix_t; /* * This driver supports systems that have the lseek64() function by defining * some macros here so we don't have to have conditional compilations later * throughout the code. * * file_offset_t: The datatype for file offsets, the second argument of * the lseek() or lseek64() call. * * file_seek: The function which adjusts the current file position, * either lseek() or lseek64(). */ /* adding for windows NT file system support. */ /* pvn: added __MWERKS__ support. */ #ifdef H5_HAVE_LSEEK64 # define file_offset_t off64_t # define file_seek lseek64 # define file_truncate ftruncate64 #elif defined (WIN32) && !defined(__MWERKS__) # /*MSVC*/ # define file_offset_t __int64 # define file_seek _lseeki64 # define file_truncate _ftruncatei64 #else # define file_offset_t off_t # define file_seek HDlseek # define file_truncate HDftruncate #endif /* * These macros check for overflow of various quantities. These macros * assume that file_offset_t is signed and haddr_t and size_t are unsigned. * * ADDR_OVERFLOW: Checks whether a file address of type `haddr_t' * is too large to be represented by the second argument * of the file seek function. * * SIZE_OVERFLOW: Checks whether a buffer size of type `hsize_t' is too * large to be represented by the `size_t' type. * * REGION_OVERFLOW: Checks whether an address and size pair describe data * which can be addressed entirely by the second * argument of the file seek function. */ #define MAXADDR (((haddr_t)1<<(8*sizeof(file_offset_t)-1))-1) #define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || \ ((A) & ~(haddr_t)MAXADDR)) #define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) #define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ sizeof(file_offset_t) * * Programmer: Quincey Koziol * Friday, Jan 30, 2004 * * Modification: * *--------------------------------------------------------------------------- */ void H5FD_mpiposix_term(void) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_mpiposix_term) /* Reset VFL ID */ H5FD_MPIPOSIX_g=0; FUNC_LEAVE_NOAPI_VOID } /* end H5FD_mpiposix_term() */ #ifdef H5_WANT_H5_V1_4_COMPAT /*------------------------------------------------------------------------- * Function: H5Pset_fapl_mpiposix * * Purpose: Store the user supplied MPI communicator COMM in * the file access property list FAPL_ID which can then be used * to create and/or open the file. This function is available * only in the parallel HDF5 library and is not collective. * * comm is the MPI communicator to be used for file open as * defined in MPI_FILE_OPEN of MPI-2. This function makes a * duplicate of comm. Any modification to comm after this function * call returns has no effect on the access property list. * * If fapl_id has previously set comm value, it will be replaced * and the old communicator is freed. * * Return: Success: Non-negative * Failure: Negative * * Programmer: Quincey Koziol * Thursday, July 11, 2002 * * Modifications: * Albert Cheng, 2003-04-24 * Modified the description of the function that it now stores * a duplicate of the communicator. Free the old duplicate if * previously set. (Work is actually done by H5P_set_driver.) * *------------------------------------------------------------------------- */ herr_t H5Pset_fapl_mpiposix(hid_t fapl_id, MPI_Comm comm) { H5FD_mpiposix_fapl_t fa; H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value; FUNC_ENTER_API(H5Pset_fapl_mpiposix, FAIL) H5TRACE2("e","iMc",fapl_id,comm); /* Check arguments */ if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a file access list") if (MPI_COMM_NULL == comm) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a valid communicator") /* Initialize driver specific properties */ fa.comm = comm; fa.use_gpfs = FALSE; /* duplication is done during driver setting. */ ret_value= H5P_set_driver(plist, H5FD_MPIPOSIX, &fa); done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_fapl_mpiposix() */ /*------------------------------------------------------------------------- * Function: H5Pget_fapl_mpiposix * * Purpose: If the file access property list is set to the H5FD_MPIPOSIX * driver then this function returns a duplicate of the MPI * communicator through the comm pointer. It is the responsibility * of the application to free the returned communicator. * * Return: Success: Non-negative with the communicator and * information returned through the COMM * argument if non-null. Since it is a duplicate * of the stored object, future modifications to * the access property list do not affect it and * it is the responsibility of the application to * free it. * * Failure: Negative * * Programmer: Quincey Koziol * Thursday, July 11, 2002 * * Modifications: * Albert Cheng, 2003-04-24 * Return duplicate of the stored communicator. * * Bill Wendling, 2003-05-01 * Return the USE_GPFS flag. * *------------------------------------------------------------------------- */ herr_t H5Pget_fapl_mpiposix(hid_t fapl_id, MPI_Comm *comm/*out*/) { H5FD_mpiposix_fapl_t *fa; H5P_genplist_t *plist; /* Property list pointer */ int mpi_code; /* mpi return code */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Pget_fapl_mpiposix, FAIL) H5TRACE2("e","ix",fapl_id,comm); if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a file access list") if (H5FD_MPIPOSIX!=H5P_get_driver(plist)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver") if (NULL==(fa=H5P_get_driver_info(plist))) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info") /* Get MPI Communicator */ if (comm){ if (MPI_SUCCESS != (mpi_code=MPI_Comm_dup(fa->comm, comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Comm_dup failed", mpi_code) } done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_fapl_mpiposix() */ #else /* H5_WANT_H5_V1_4_COMPAT */ /*------------------------------------------------------------------------- * Function: H5Pset_fapl_mpiposix * * Purpose: Store the user supplied MPI communicator COMM in * the file access property list FAPL_ID which can then be used * to create and/or open the file. This function is available * only in the parallel HDF5 library and is not collective. * * comm is the MPI communicator to be used for file open as * defined in MPI_FILE_OPEN of MPI-2. This function makes a * duplicate of comm. Any modification to comm after this function * call returns has no effect on the access property list. * * If fapl_id has previously set comm value, it will be replaced * and the old communicator is freed. * * Return: Success: Non-negative * Failure: Negative * * Programmer: Quincey Koziol * Thursday, July 11, 2002 * * Modifications: * Albert Cheng, 2003-04-24 * Modified the description of the function that it now stores * a duplicate of the communicator. Free the old duplicate if * previously set. (Work is actually done by H5P_set_driver.) * * Bill Wendling, 2003-05-01 * Modified to take an extra flag indicating that we should * use the GPFS hints (if available) for this file. * *------------------------------------------------------------------------- */ herr_t H5Pset_fapl_mpiposix(hid_t fapl_id, MPI_Comm comm, hbool_t use_gpfs) { H5FD_mpiposix_fapl_t fa; H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value; FUNC_ENTER_API(H5Pset_fapl_mpiposix, FAIL) H5TRACE3("e","iMcb",fapl_id,comm,use_gpfs); /* Check arguments */ if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a file access list") if (MPI_COMM_NULL == comm) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a valid communicator") /* Initialize driver specific properties */ fa.comm = comm; fa.use_gpfs = use_gpfs; /* duplication is done during driver setting. */ ret_value= H5P_set_driver(plist, H5FD_MPIPOSIX, &fa); done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_fapl_mpiposix() */ /*------------------------------------------------------------------------- * Function: H5Pget_fapl_mpiposix * * Purpose: If the file access property list is set to the H5FD_MPIPOSIX * driver then this function returns a duplicate of the MPI * communicator through the comm pointer. It is the responsibility * of the application to free the returned communicator. * * Return: Success: Non-negative with the communicator and * information returned through the COMM * argument if non-null. Since it is a duplicate * of the stored object, future modifications to * the access property list do not affect it and * it is the responsibility of the application to * free it. * * Failure: Negative * * Programmer: Quincey Koziol * Thursday, July 11, 2002 * * Modifications: * Albert Cheng, 2003-04-24 * Return duplicate of the stored communicator. * * Bill Wendling, 2003-05-01 * Return the USE_GPFS flag. * *------------------------------------------------------------------------- */ herr_t H5Pget_fapl_mpiposix(hid_t fapl_id, MPI_Comm *comm/*out*/, hbool_t *use_gpfs/*out*/) { H5FD_mpiposix_fapl_t *fa; H5P_genplist_t *plist; /* Property list pointer */ int mpi_code; /* mpi return code */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Pget_fapl_mpiposix, FAIL) H5TRACE3("e","ixx",fapl_id,comm,use_gpfs); if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a file access list") if (H5FD_MPIPOSIX!=H5P_get_driver(plist)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver") if (NULL==(fa=H5P_get_driver_info(plist))) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info") /* Get MPI Communicator */ if (comm){ if (MPI_SUCCESS != (mpi_code=MPI_Comm_dup(fa->comm, comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Comm_dup failed", mpi_code) } if (use_gpfs) *use_gpfs = fa->use_gpfs; done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_fapl_mpiposix() */ #endif /* H5_WANT_H5_V1_4_COMPAT */ /*------------------------------------------------------------------------- * Function: H5FD_mpiposix_fapl_get * * Purpose: Returns a file access property list which could be used to * create another file the same as this one. * * Return: Success: Ptr to new file access property list with all * fields copied from the file pointer. * * Failure: NULL * * Programmer: Quincey Koziol * Thursday, July 11, 2002 * * Modifications: * Albert Cheng, 2003-04-24 * Duplicate the communicator object so that the new * property list is insulated from the old one. * *------------------------------------------------------------------------- */ static void * H5FD_mpiposix_fapl_get(H5FD_t *_file) { H5FD_mpiposix_t *file = (H5FD_mpiposix_t*)_file; H5FD_mpiposix_fapl_t *fa = NULL; int mpi_code; /* MPI return code */ void *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_mpiposix_fapl_get, NULL) assert(file); assert(H5FD_MPIPOSIX==file->pub.driver_id); if (NULL==(fa=H5MM_calloc(sizeof(H5FD_mpiposix_fapl_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Duplicate the communicator. */ if (MPI_SUCCESS != (mpi_code=MPI_Comm_dup(file->comm, &fa->comm))) HMPI_GOTO_ERROR(NULL, "MPI_Comm_dup failed", mpi_code) fa->use_gpfs = file->use_gpfs; /* Set return value */ ret_value=fa; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpiposix_fapl_get() */ /*------------------------------------------------------------------------- * Function: H5FD_mpiposix_fapl_copy * * Purpose: Copies the mpiposix-specific file access properties. * * Return: Success: Ptr to a new property list * * Failure: NULL * * Programmer: Albert Cheng * Apr 24, 2003 * * Modifications: * *------------------------------------------------------------------------- */ static void * H5FD_mpiposix_fapl_copy(const void *_old_fa) { void *ret_value = NULL; const H5FD_mpiposix_fapl_t *old_fa = (const H5FD_mpiposix_fapl_t*)_old_fa; H5FD_mpiposix_fapl_t *new_fa = NULL; int mpi_code; /* MPI return code */ FUNC_ENTER_NOAPI(H5FD_mpiposix_fapl_copy, NULL) if (NULL==(new_fa=H5MM_malloc(sizeof(H5FD_mpiposix_fapl_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Copy the general information */ HDmemcpy(new_fa, old_fa, sizeof(H5FD_mpiposix_fapl_t)); /* Duplicate communicator. */ if (MPI_SUCCESS != (mpi_code=MPI_Comm_dup(old_fa->comm, &new_fa->comm))) HMPI_GOTO_ERROR(NULL, "MPI_Comm_dup failed", mpi_code) new_fa->use_gpfs = old_fa->use_gpfs; ret_value = new_fa; done: if (NULL == ret_value){ /* cleanup */ if (new_fa) H5MM_xfree(new_fa); } FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpiposix_fapl_copy() */ /*------------------------------------------------------------------------- * Function: H5FD_mpiposix_fapl_free * * Purpose: Frees the mpiposix-specific file access properties. * * Return: Success: 0 * * Failure: -1 * * Programmer: Albert Cheng * Apr 24, 2003 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_mpiposix_fapl_free(void *_fa) { herr_t ret_value = SUCCEED; H5FD_mpiposix_fapl_t *fa = (H5FD_mpiposix_fapl_t*)_fa; FUNC_ENTER_NOAPI(H5FD_mpiposix_fapl_free, FAIL) assert(fa); /* Free the internal communicator */ assert(MPI_COMM_NULL!=fa->comm); MPI_Comm_free(&fa->comm); H5MM_xfree(fa); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpiposix_fapl_free() */ /*------------------------------------------------------------------------- * Function: H5FD_mpiposix_open * * Purpose: Opens a file with name NAME. The FLAGS are a bit field with * purpose similar to the second argument of open(2) and which * are defined in H5Fpublic.h. The file access property list * FAPL_ID contains the properties driver properties and MAXADDR * is the largest address which this file will be expected to * access. This is collective. * * Return: Success: A new file pointer. * Failure: NULL * * Programmer: Quincey Koziol * Thursday, July 11, 2002 * * Modifications: * Albert Cheng, 2003-04-24 * Duplicate the communicator so that file is insulated from the * old one. * *------------------------------------------------------------------------- */ static H5FD_t * H5FD_mpiposix_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { H5FD_mpiposix_t *file=NULL; /* New MPIPOSIX file struct */ int o_flags; /* Flags for file open call */ int fd=(-1); /* File handle for file opened */ int mpi_rank; /* MPI rank of this process */ int mpi_size; /* Total number of MPI processes */ int mpi_code; /* mpi return code */ const H5FD_mpiposix_fapl_t *fa=NULL; /* MPIPOSIX file access property list information */ H5FD_mpiposix_fapl_t _fa; /* Private copy of default file access property list information */ H5P_genplist_t *plist; /* Property list pointer */ h5_stat_t sb; /* Portable 'stat' struct */ #ifdef WIN32 HFILE filehandle; struct _BY_HANDLE_FILE_INFORMATION fileinfo; int results; #endif H5FD_t *ret_value=NULL; /* Return value */ MPI_Comm comm_dup=MPI_COMM_NULL; FUNC_ENTER_NOAPI(H5FD_mpiposix_open, NULL) /* Check arguments */ if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name") if (0==maxaddr || HADDR_UNDEF==maxaddr) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr") if (ADDR_OVERFLOW(maxaddr)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "bogus maxaddr") /* Obtain a pointer to mpiposix-specific file access properties */ if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") if (H5P_FILE_ACCESS_DEFAULT==fapl_id || H5FD_MPIPOSIX!=H5P_get_driver(plist)) { _fa.comm = MPI_COMM_SELF; /*default*/ _fa.use_gpfs = FALSE; fa = &_fa; } /* end if */ else { fa = H5P_get_driver_info(plist); assert(fa); } /* end else */ /* Duplicate the communicator for use by this file. */ if (MPI_SUCCESS != (mpi_code=MPI_Comm_dup(fa->comm, &comm_dup))) HMPI_GOTO_ERROR(NULL, "MPI_Comm_dup failed", mpi_code) /* Get the MPI rank of this process and the total number of processes */ if (MPI_SUCCESS != (mpi_code=MPI_Comm_rank (comm_dup, &mpi_rank))) HMPI_GOTO_ERROR(NULL, "MPI_Comm_rank failed", mpi_code) if (MPI_SUCCESS != (mpi_code=MPI_Comm_size (comm_dup, &mpi_size))) HMPI_GOTO_ERROR(NULL, "MPI_Comm_size failed", mpi_code) /* Build the open flags */ o_flags = (H5F_ACC_RDWR & flags) ? O_RDWR : O_RDONLY; /* Only set the creation flag(s) for process 0 */ if(mpi_rank==0) { if (H5F_ACC_TRUNC & flags) o_flags |= O_TRUNC; if (H5F_ACC_CREAT & flags) o_flags |= O_CREAT; if (H5F_ACC_EXCL & flags) o_flags |= O_EXCL; } /* end if */ /* Process 0 opens (or creates) the file while the rest of the * processes wait. Then process 0 signals the other processes and they * open (never create) the file and all processes proceed. */ /* Process 0 opens (or creates) file and broadcasts result to other processes */ if(mpi_rank==0) { /* Open the file */ fd=HDopen(name, o_flags, 0666); } /* end if */ /* Broadcast the results of the open() from process 0 */ /* This is necessary because of the "tentative open" code in H5F_open() * where the file is attempted to be opened with different flags from the * user's, in order to check for the file's existence, etc. Here, process 0 * gets different flags from the other processes (since it is in charge of * creating the file, if necessary) and can fail in situations where the * other process's file opens would succeed, so allow the other processes * to check for that situation and bail out now also. - QAK */ if (MPI_SUCCESS != (mpi_code= MPI_Bcast(&fd, sizeof(int), MPI_BYTE, 0, comm_dup))) HMPI_GOTO_ERROR(NULL, "MPI_Bcast failed", mpi_code) /* If the file open on process 0 failed, bail out on all processes now */ if(fd<0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file") /* Other processes (non 0) wait for broadcast result from process 0 and then open file */ if(mpi_rank!=0) { /* Open the file */ if ((fd=HDopen(name, o_flags, 0666))<0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file") } /* end if */ /* Process 0 fstat()s the file and broadcasts the results to the other processes */ if(mpi_rank==0) { /* Get the stat information */ if (HDfstat(fd, &sb)<0) HGOTO_ERROR(H5E_FILE, H5E_BADFILE, NULL, "unable to fstat file") } /* end if */ /* Broadcast the results of the fstat() from process 0 */ if (MPI_SUCCESS != (mpi_code= MPI_Bcast(&sb, sizeof(h5_stat_t), MPI_BYTE, 0, comm_dup))) HMPI_GOTO_ERROR(NULL, "MPI_Bcast failed", mpi_code) #ifdef H5_HAVE_GPFS if (fa->use_gpfs) { /* * Free all byte range tokens. This is a good thing to do if raw data is aligned on 256kB boundaries (a GPFS page is * 256kB). Care should be taken that there aren't too many sub-page writes, or the mmfsd may become overwhelmed. This * should probably eventually be passed down here as a property. The gpfs_fcntl() will most likely fail if `fd' isn't * on a GPFS file system. */ struct { gpfsFcntlHeader_t hdr; gpfsFreeRange_t fr; } hint; HDmemset(&hint, 0, sizeof hint); hint.hdr.totalLength = sizeof hint; hint.hdr.fcntlVersion = GPFS_FCNTL_CURRENT_VERSION; hint.fr.structLen = sizeof hint.fr; hint.fr.structType = GPFS_FREE_RANGE; hint.fr.start = 0; hint.fr.length = 0; if (gpfs_fcntl(fd, &hint)<0) HGOTO_ERROR(H5E_FILE, H5E_FCNTL, NULL, "failed to send hints to GPFS") } #endif /* H5_HAVE_GPFS */ /* Build the file struct and initialize it */ if (NULL==(file=H5MM_calloc(sizeof(H5FD_mpiposix_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") #ifdef REPORT_IO HDfprintf(stderr, "open: rank=%d name=%s file=0x%08lx\n", mpi_rank, name, (unsigned long)file); #endif /* Set the general file information */ file->fd = fd; file->eof = sb.st_size; #ifndef WIN32 file->blksize = sb.st_blksize; #endif /* Set this field in the H5FD_mpiposix_t struct for later use */ file->use_gpfs = fa->use_gpfs; /* Set the MPI information */ file->comm = comm_dup; file->mpi_rank = mpi_rank; file->mpi_size = mpi_size; /* Reset the last file I/O operation */ file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; /* Set the information for the file's device and inode */ #ifdef WIN32 filehandle = _get_osfhandle(fd); results = GetFileInformationByHandle((HANDLE)filehandle, &fileinfo); file->fileindexhi = fileinfo.nFileIndexHigh; file->fileindexlo = fileinfo.nFileIndexLow; #else file->device = sb.st_dev; file->inode = sb.st_ino; #endif /* Indicate success */ ret_value=(H5FD_t *)file; done: /* Error cleanup */ if(ret_value==NULL) { /* Close the file if it was left open */ if(fd!=(-1)) HDclose(fd); if (MPI_COMM_NULL != comm_dup) MPI_Comm_free(&comm_dup); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpiposix_open() */ /*------------------------------------------------------------------------- * Function: H5FD_mpiposix_close * * Purpose: Closes a file. * * Return: Success: Non-negative * Failure: Negative * * Programmer: Quincey Koziol * Thursday, July 11, 2002 * * Modifications: * Albert Cheng, 2003-04-24 * Free the communicator stored. *------------------------------------------------------------------------- */ static herr_t H5FD_mpiposix_close(H5FD_t *_file) { H5FD_mpiposix_t *file = (H5FD_mpiposix_t*)_file; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_mpiposix_close, FAIL) assert(file); assert(H5FD_MPIPOSIX==file->pub.driver_id); /* Close the unix file */ if (HDclose(file->fd)<0) HGOTO_ERROR(H5E_IO, H5E_CANTCLOSEFILE, FAIL, "unable to close file") /* make sure all processes have closed the file before returning. */ MPI_Barrier(file->comm); /* Clean up other stuff */ MPI_Comm_free(&file->comm); H5MM_xfree(file); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpiposix_close() */ /*------------------------------------------------------------------------- * Function: H5FD_mpiposix_cmp * * Purpose: Compares two files belonging to this driver using an * arbitrary (but consistent) ordering. * * Return: Success: A value like strcmp() * Failure: never fails (arguments were checked by the * caller). * * Programmer: Quincey Koziol * Thursday, July 11, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static int H5FD_mpiposix_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { const H5FD_mpiposix_t *f1 = (const H5FD_mpiposix_t*)_f1; const H5FD_mpiposix_t *f2 = (const H5FD_mpiposix_t*)_f2; int ret_value=0; FUNC_ENTER_NOAPI(H5FD_mpiposix_cmp, H5FD_VFD_DEFAULT) #ifdef WIN32 if (f1->fileindexhi < f2->fileindexhi) HGOTO_DONE(-1) if (f1->fileindexhi > f2->fileindexhi) HGOTO_DONE(1) if (f1->fileindexlo < f2->fileindexlo) HGOTO_DONE(-1) if (f1->fileindexlo > f2->fileindexlo) HGOTO_DONE(1) #else #ifdef H5_DEV_T_IS_SCALAR if (f1->device < f2->device) HGOTO_DONE(-1) if (f1->device > f2->device) HGOTO_DONE(1) #else /* H5_DEV_T_IS_SCALAR */ /* If dev_t isn't a scalar value on this system, just use memcmp to * determine if the values are the same or not. The actual return value * shouldn't really matter... */ if(HDmemcmp(&(f1->device),&(f2->device),sizeof(dev_t))<0) HGOTO_DONE(-1) if(HDmemcmp(&(f1->device),&(f2->device),sizeof(dev_t))>0) HGOTO_DONE(1) #endif /* H5_DEV_T_IS_SCALAR */ if (f1->inode < f2->inode) HGOTO_DONE(-1) if (f1->inode > f2->inode) HGOTO_DONE(1) #endif done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpiposix_cmp() */ /*------------------------------------------------------------------------- * Function: H5FD_mpiposix_query * * Purpose: Set the flags that this VFL driver is capable of supporting. * (listed in H5FDpublic.h) * * Return: Success: non-negative * Failure: negative * * Programmer: Quincey Koziol * Thursday, July 11, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_mpiposix_query(const H5FD_t UNUSED *_file, unsigned long *flags /* out */) { herr_t ret_value=SUCCEED; FUNC_ENTER_NOAPI(H5FD_mpiposix_query, FAIL) /* Set the VFL feature flags that this driver supports */ if(flags) { *flags=0; *flags|=H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ /* Distinguish between updating the metadata accumulator on writes and * reads. This is particularly (perhaps only, even) important for MPI-I/O * where we guarantee that writes are collective, but reads may not be. * If we were to allow the metadata accumulator to be written during a * read operation, the application would hang. */ *flags|=H5FD_FEAT_ACCUMULATE_METADATA_WRITE; /* OK to accumulate metadata for faster writes */ *flags|=H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpiposix_query() */ /*------------------------------------------------------------------------- * Function: H5FD_mpiposix_get_eoa * * Purpose: Gets the end-of-address marker for the file. The EOA marker * is the first address past the last byte allocated in the * format address space. * * Return: Success: The end-of-address marker. * Failure: HADDR_UNDEF * * Programmer: Quincey Koziol * Thursday, July 11, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static haddr_t H5FD_mpiposix_get_eoa(H5FD_t *_file) { H5FD_mpiposix_t *file = (H5FD_mpiposix_t*)_file; haddr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_mpiposix_get_eoa, HADDR_UNDEF) assert(file); assert(H5FD_MPIPOSIX==file->pub.driver_id); /* Set return value */ ret_value=file->eoa; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpiposix_get_eoa() */ /*------------------------------------------------------------------------- * Function: H5FD_mpiposix_set_eoa * * Purpose: Set the end-of-address marker for the file. This function is * called shortly after an existing HDF5 file is opened in order * to tell the driver where the end of the HDF5 data is located. * * Return: Success: non-negative * Failure: negative * * Programmer: Quincey Koziol * Thursday, July 11, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_mpiposix_set_eoa(H5FD_t *_file, haddr_t addr) { H5FD_mpiposix_t *file = (H5FD_mpiposix_t*)_file; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_mpiposix_set_eoa, FAIL) assert(file); assert(H5FD_MPIPOSIX==file->pub.driver_id); file->eoa = addr; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpi_posix_set_eoa() */ /*------------------------------------------------------------------------- * Function: H5FD_mpiposix_get_eof * * Purpose: Gets the end-of-file marker for the file. The EOF marker * is the real size of the file. * * The MPIPOSIX driver doesn't bother keeping this field updated * since that's a relatively expensive operation. Fortunately * the library only needs the EOF just after the file is opened * in order to determine whether the file is empty, truncated, * or okay. * * Return: Success: The end-of-address marker. * Failure: HADDR_UNDEF * * Programmer: Quincey Koziol * Thursday, July 11, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static haddr_t H5FD_mpiposix_get_eof(H5FD_t *_file) { H5FD_mpiposix_t *file = (H5FD_mpiposix_t*)_file; haddr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_mpiposix_get_eof, HADDR_UNDEF) assert(file); assert(H5FD_MPIPOSIX==file->pub.driver_id); /* Set return value */ ret_value=MAX(file->eof,file->eoa); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpiposix_get_eof() */ /*------------------------------------------------------------------------- * Function: H5FD_mpiposix_get_handle * * Purpose: Returns the file handle of MPI-POSIX file driver. * * Returns: Non-negative if succeed or negative if fails. * * Programmer: Raymond Lu * Sept. 16, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_mpiposix_get_handle(H5FD_t *_file, hid_t UNUSED fapl, void** file_handle) { H5FD_mpiposix_t *file = (H5FD_mpiposix_t *)_file; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5FD_mpiposix_get_handle, FAIL) if(!file_handle) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file handle not valid") *file_handle = &(file->fd); done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_mpiposix_read * * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR * into buffer BUF according to data transfer properties in * DXPL_ID using potentially complex file and buffer types to * effect the transfer. * * Reading past the end of the file returns zeros instead of * failing. * * Return: Success: Non-negative. Result is stored in caller-supplied * buffer BUF. * Failure: Negative, Contents of buffer BUF are undefined. * * Programmer: Quincey Koziol * Thursday, July 11, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_mpiposix_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, haddr_t addr, size_t size, void *buf/*out*/) { H5FD_mpiposix_t *file = (H5FD_mpiposix_t*)_file; ssize_t nbytes; /* Number of bytes read each I/O call */ herr_t ret_value=SUCCEED; FUNC_ENTER_NOAPI(H5FD_mpiposix_read, FAIL) assert(file); assert(H5FD_MPIPOSIX==file->pub.driver_id); assert(buf); /* Check for overflow conditions */ if (HADDR_UNDEF==addr) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined") if (REGION_OVERFLOW(addr, size)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow") if (addr+size>file->eoa) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow") #ifdef REPORT_IO { int commrank; MPI_Comm_rank(MPI_COMM_WORLD, &commrank); HDfprintf(stderr, "read: rank=%d file=0x%08lx type=%d, addr=%a size=%Zu\n", commrank, (unsigned long)file, (int)type, addr, size); } #endif /* Seek to the correct location */ if ((addr!=file->pos || OP_READ!=file->op) && file_seek(file->fd, (file_offset_t)addr, SEEK_SET)<0) HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") /* * Read data, being careful of interrupted system calls, partial results, * and the end of the file. */ while (size>0) { do { nbytes = HDread(file->fd, buf, size); } while (-1==nbytes && EINTR==errno); if (-1==nbytes) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed") if (0==nbytes) { /* end of file but not end of format address space */ HDmemset(buf, 0, size); break; } /* end if */ assert(nbytes>=0); assert((size_t)nbytes<=size); size -= nbytes; addr += (haddr_t)nbytes; buf = (char*)buf + nbytes; } /* Update current position */ file->pos = addr; file->op = OP_READ; done: /* Check for error */ if(ret_value<0) { /* Reset last file I/O information */ file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpiposix_read() */ /*------------------------------------------------------------------------- * Function: H5FD_mpiposix_write * * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR * from buffer BUF according to data transfer properties in * DXPL_ID using potentially complex file and buffer types to * effect the transfer. * * Return: Success: non-negative * Failure: negative * * Programmer: Quincey Koziol * Thursday, July 11, 2002 * * Modifications: * * Quincey Koziol - 2002/07/18 * Added "block_before_meta_write" dataset transfer flag, which * is set during writes from a metadata cache flush and indicates * that all the processes must sync up before (one of them) * writing metadata. * *------------------------------------------------------------------------- */ static herr_t H5FD_mpiposix_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, const void *buf) { H5FD_mpiposix_t *file = (H5FD_mpiposix_t*)_file; int mpi_code; /* MPI return code */ ssize_t nbytes; /* Number of bytes written each I/O call */ H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_mpiposix_write, FAIL) assert(file); assert(H5FD_MPIPOSIX==file->pub.driver_id); assert(H5I_GENPROP_LST==H5I_get_type(dxpl_id)); assert(TRUE==H5P_isa_class(dxpl_id,H5P_DATASET_XFER)); assert(buf); /* Check for overflow conditions */ if (HADDR_UNDEF==addr) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined") if (REGION_OVERFLOW(addr, size)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow") if (addr+size>file->eoa) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow") /* Obtain the data transfer properties */ if(NULL == (plist = H5I_object(dxpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") /* Metadata specific actions */ if(type!=H5FD_MEM_DRAW) { unsigned block_before_meta_write=0; /* Whether to block before a metadata write */ /* Check if we need to syncronize all processes before attempting metadata write * (Prevents race condition where the process writing the metadata goes ahead * and writes the metadata to the file before all the processes have * read the data, "transmitting" data from the "future" to the reading * process. -QAK ) * * The only time we don't want to block before a metadata write is when * we are flushing out a bunch of metadata. Then, we block before the * first write and don't block for further writes in the sequence. */ if(H5P_exist_plist(plist,H5AC_BLOCK_BEFORE_META_WRITE_NAME)>0) if(H5P_get(plist,H5AC_BLOCK_BEFORE_META_WRITE_NAME,&block_before_meta_write)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get H5AC property") if(block_before_meta_write) if (MPI_SUCCESS!= (mpi_code=MPI_Barrier(file->comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed", mpi_code) /* Only one process will do the actual write if all procs in comm write same metadata */ if (file->mpi_rank != H5_PAR_META_WRITE) HGOTO_DONE(SUCCEED) /* skip the actual write */ } /* end if */ #ifdef REPORT_IO { int commrank; MPI_Comm_rank(MPI_COMM_WORLD, &commrank); HDfprintf(stderr, "write: rank=%d file=0x%08lx type=%d, addr=%a size=%Zu %s\n", commrank, (unsigned long)file, (int)type, addr, size, 0==file->naccess?"(FIRST ACCESS)":""); } #endif if (0==file->naccess++) { /* First write access to this file */ #ifdef H5_HAVE_GPFS if (file->use_gpfs) { struct { gpfsFcntlHeader_t hdr; gpfsMultipleAccessRange_t mar; } hint; HDmemset(&hint, 0, sizeof hint); hint.hdr.totalLength = sizeof hint; hint.hdr.fcntlVersion = GPFS_FCNTL_CURRENT_VERSION; hint.mar.structLen = sizeof hint.mar; hint.mar.structType = GPFS_MULTIPLE_ACCESS_RANGE; hint.mar.accRangeCnt = 1; hint.mar.accRangeArray[0].blockNumber = addr / file->blksize; hint.mar.accRangeArray[0].start = addr % file->blksize; hint.mar.accRangeArray[0].length = MIN(file->blksize-hint.mar.accRangeArray[0].start, size); hint.mar.accRangeArray[0].isWrite = 1; if (gpfs_fcntl(file->fd, &hint)<0) HGOTO_ERROR(H5E_FILE, H5E_FCNTL, NULL, "failed to send hints to GPFS") } #endif /* H5_HAVE_GPFS */ } /* Seek to the correct location */ if ((addr!=file->pos || OP_WRITE!=file->op) && file_seek(file->fd, (file_offset_t)addr, SEEK_SET)<0) HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") /* * Write the data, being careful of interrupted system calls and partial * results */ while (size>0) { do { nbytes = HDwrite(file->fd, buf, size); } while (-1==nbytes && EINTR==errno); if (-1==nbytes) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") assert(nbytes>0); assert((size_t)nbytes<=size); size -= nbytes; addr += (haddr_t)nbytes; buf = (const char*)buf + nbytes; } /* end while */ /* Update current last file I/O information */ file->pos = addr; file->op = OP_WRITE; done: /* Check for error */ if(ret_value<0) { /* Reset last file I/O information */ file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; } /* end if */ /* Guard against getting into metadata broadcast in failure cases */ else { /* when only one process writes, need to broadcast the ret_value to other processes */ if (type!=H5FD_MEM_DRAW) { if (MPI_SUCCESS != (mpi_code= MPI_Bcast(&ret_value, sizeof(ret_value), MPI_BYTE, H5_PAR_META_WRITE, file->comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Bcast failed", mpi_code) } /* end if */ } /* end else */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpiposix_write() */ /*------------------------------------------------------------------------- * Function: H5FD_mpiposix_flush * * Purpose: Makes sure that all data is on disk. This is collective. * * Return: Success: Non-negative * Failure: Negative * * Programmer: Quincey Koziol * Thursday, July 11, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_mpiposix_flush(H5FD_t *_file, hid_t UNUSED dxpl_id, unsigned UNUSED closing) { H5FD_mpiposix_t *file = (H5FD_mpiposix_t*)_file; #ifdef WIN32 HFILE filehandle; /* Windows file handle */ LARGE_INTEGER li; /* 64-bit integer for SetFilePointer() call */ #endif /* WIN32 */ int mpi_code; /* MPI return code */ herr_t ret_value=SUCCEED; FUNC_ENTER_NOAPI(H5FD_mpiposix_flush, FAIL) assert(file); assert(H5FD_MPIPOSIX==file->pub.driver_id); /* Extend the file to make sure it's large enough */ if(file->eoa>file->last_eoa) { /* Use the round-robin process to truncate (extend) the file */ if(file->mpi_rank == H5_PAR_META_WRITE) { #ifdef WIN32 /* Map the posix file handle to a Windows file handle */ filehandle = _get_osfhandle(filehandle); /* Translate 64-bit integers into form Windows wants */ /* [This algorithm is from the Windows documentation for SetFilePointer()] */ li.QuadPart = file->eoa; SetFilePointer((HANDLE)filehandle,li.LowPart,&li.HighPart,FILE_BEGIN); if(SetEndOfFile((HANDLE)filehandle)==0) HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") #else /* WIN32 */ if(-1==file_truncate(file->fd, (file_offset_t)file->eoa)) HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") #endif /* WIN32 */ } /* end if */ /* Don't let any proc return until all have extended the file. * (Prevents race condition where some processes go ahead and write * more data to the file before all the processes have finished making * it the shorter length, potentially truncating the file and dropping * the new data written) */ if (MPI_SUCCESS!= (mpi_code=MPI_Barrier(file->comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed", mpi_code) /* Update the 'last' eoa and eof values */ file->last_eoa=file->eoa; file->eof = file->eoa; /* Reset last file I/O information */ file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpiposix_flush() */ /*------------------------------------------------------------------------- * Function: H5FD_mpiposix_mpi_rank * * Purpose: Returns the MPI rank for a process * * Return: Success: non-negative * Failure: negative * * Programmer: Quincey Koziol * Thursday, July 11, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static int H5FD_mpiposix_mpi_rank(const H5FD_t *_file) { const H5FD_mpiposix_t *file = (const H5FD_mpiposix_t*)_file; int ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_mpiposix_mpi_rank, FAIL) assert(file); assert(H5FD_MPIPOSIX==file->pub.driver_id); /* Set return value */ ret_value=file->mpi_rank; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpiposix_mpi_rank() */ /*------------------------------------------------------------------------- * Function: H5FD_mpiposix_mpi_size * * Purpose: Returns the number of MPI processes * * Return: Success: non-negative * Failure: negative * * Programmer: Quincey Koziol * Thursday, July 11, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static int H5FD_mpiposix_mpi_size(const H5FD_t *_file) { const H5FD_mpiposix_t *file = (const H5FD_mpiposix_t*)_file; int ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_mpiposix_mpi_size, FAIL) assert(file); assert(H5FD_MPIPOSIX==file->pub.driver_id); /* Set return value */ ret_value=file->mpi_size; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpiposix_mpi_size() */ /*------------------------------------------------------------------------- * Function: H5FD_mpiposix_communicator * * Purpose: Returns the MPI communicator for the file. * * Return: Success: The communicator * * Failure: NULL * * Programmer: Quincey Koziol * Thursday, July 11, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static MPI_Comm H5FD_mpiposix_communicator(const H5FD_t *_file) { const H5FD_mpiposix_t *file = (const H5FD_mpiposix_t*)_file; MPI_Comm ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_mpiposix_communicator, MPI_COMM_NULL) assert(file); assert(H5FD_MPIPOSIX==file->pub.driver_id); /* Set return value */ ret_value=file->comm; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpi_posix_communicator() */ #endif /*H5_HAVE_PARALLEL*/ xdmf-3.0+git20160803/Utilities/hdf5/H5HLprivate.h0000640000175000017500000000576213003006557021151 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*------------------------------------------------------------------------- * * Created: H5HLprivate.h * Jul 16 1997 * Robb Matzke * * Purpose: * * Modifications: * *------------------------------------------------------------------------- */ #ifndef _H5HLprivate_H #define _H5HLprivate_H /* Include package's public header */ #include "H5HLpublic.h" /* Private headers needed by this file. */ #include "H5private.h" /* Generic Functions */ #include "H5Fprivate.h" /* File access */ /* * Feature: Define H5HL_DEBUG on the compiler command line if you want to * diagnostic messages from this layer. */ #ifdef NDEBUG # undef H5HL_DEBUG #endif #define H5HL_MAGIC "HEAP" /*heap magic number */ #define H5HL_SIZEOF_MAGIC 4 #define H5HL_ALIGN(X) (((X)+7)&(unsigned)(~0x07)) /*align on 8-byte boundary */ #define H5HL_SIZEOF_FREE(F) \ H5HL_ALIGN(H5F_SIZEOF_SIZE (F) + /*ptr to next free block */ \ H5F_SIZEOF_SIZE (F)) /*size of this free block */ /****************************/ /* Library Private Typedefs */ /****************************/ /* Typedef for local heap in memory (defined in H5HLpkg.h) */ typedef struct H5HL_t H5HL_t; /* * Library prototypes... */ H5_DLL herr_t H5HL_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, haddr_t *addr/*out*/); H5_DLL const H5HL_t *H5HL_protect(H5F_t *f, hid_t dxpl_id, haddr_t addr); H5_DLL void *H5HL_offset_into(H5F_t *f, const H5HL_t *heap, size_t offset); H5_DLL herr_t H5HL_unprotect(H5F_t *f, hid_t dxpl_id, const H5HL_t *heap, haddr_t addr); H5_DLL size_t H5HL_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t size, const void *buf); H5_DLL herr_t H5HL_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t offset, size_t size); H5_DLL herr_t H5HL_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr); /* Debugging functions */ H5_DLL herr_t H5HL_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, int fwidth); #endif xdmf-3.0+git20160803/Utilities/hdf5/H5config.WIN32.h.in0000640000175000017500000001211013003006557021707 0ustar alastairalastair/*** THIS HEADER is adapted from UNIX platform (autoconf routine)***, it is modified and manually maintained by HDF group, many UNIX comments are intentionally kept for maintenance purpose ***/ /* src/H5config.h. Generated automatically by configure. */ /* src/H5config.h.in. Generated automatically from configure.in by autoheader. */ /* Define to empty if the keyword does not work. */ /* #undef const */ /* Define if your struct tm has tm_zone. */ #define HAVE_TM_ZONE 1 /* Define if you don't have tm_zone but do have the external array tzname. */ /* #undef HAVE_TZNAME */ /* Define to `long' if doesn't define. */ /* #undef off_t */ /* Define to `unsigned' if doesn't define. */ /* #undef size_t */ /* Define if you have the ANSI C header files. */ #define STDC_HEADERS 1 /* Define if your declares struct tm. */ /* #undef TM_IN_SYS_TIME */ /* Define if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel and VAX). */ /* #undef WORDS_BIGENDIAN */ /* Define if the __attribute__(()) extension is present */ #define HAVE_ATTRIBUTE 1 /* Define if the compiler understands the __FUNCTION__ keyword. */ //#define HAVE_FUNCTION 1 /* Define if we have parallel support */ /* #undef HAVE_PARALLEL */ /* Define if it's safe to use `long long' for hsize_t and hssize_t */ #define HAVE_LARGE_HSIZET 1 /* The width parameter for printf formats for type `long long', us. `ll' */ #ifdef __MWERKS__ #define PRINTF_LL_WIDTH "ll" #else #define PRINTF_LL_WIDTH "I64" #endif /* Define if `tm_gmtoff' is a member of `struct tm' */ //#define HAVE_TM_GMTOFF 1 /* Define if `timezone' is a global variable */ /* #undef HAVE_TIMEZONE */ /* Define if `struct timezone' is defined */ //#define HAVE_STRUCT_TIMEZONE 1 /* The number of bytes in a char */ #define SIZEOF_CHAR 1 /* The number of bytes in a short. */ #define SIZEOF_SHORT 2 /* The number of bytes in a size_t. */ #define SIZEOF_SIZE_T 4 /* The number of bytes in a ssize_t. */ #define SIZEOF_SSIZE_T 4 /* The number of bytes in a int. */ #define SIZEOF_INT 4 /* The number of bytes in a long. */ #define SIZEOF_LONG 4 /* The number of bytes in a long long. we use __int64 instead, ignore this constant */ /*#define SIZEOF_LONG_LONG 0*/ /* number of bytes in a __int64*/ #define HAVE___int64 #define SIZEOF___INT64 8 /* The number of bytes in a double. */ #define SIZEOF_DOUBLE 8 /* The number of bytes in a float. */ #define SIZEOF_FLOAT 4 /* The number of bytes in a long double. */ #define SIZEOF_LONG_DOUBLE 8 /* The number of bytes in a off_t. */ #define SIZEOF_OFF_T 4 /* Define if you have the BSDgettimeofday function. */ /* #undef HAVE_BSDGETTIMEOFDAY */ /* Define if you have the difftime function. */ #define HAVE_DIFFTIME 1 /* Define if you have the fork function. */ #define HAVE_FORK 1 /* Define if you have the fseek64 function. */ /* #undef HAVE_FSEEK64 */ /* Define if you have the gethostname function. */ #define HAVE_GETHOSTNAME 1 /* Define if you have the getpwuid function. */ //#define HAVE_GETPWUID 1 /* Define if you have the ioctl function. */ #define HAVE_IOCTL 1 /* Define if you have the longjmp function. */ #define HAVE_LONGJMP 1 /* Define if you have the getrusage function. */ //#define HAVE_GETRUSAGE 1 /* Define if you have the gettimeofday function. */ //#define HAVE_GETTIMEOFDAY 1 /* Define if you have the lseek64 function. */ /* #undef HAVE_LSEEK64 */ /* Define if you have the sigaction function. */ #define HAVE_SIGACTION 1 #define HAVE_SIGNAL 1 #define HAVE__SNPRINTF 1 #define HAVE_STRDUP 1 /* Define if you have the system function. */ #define HAVE_SYSTEM 1 /* Define if you have the waitpid function. */ //#define HAVE_WAITPID 1 /* Define if you have the header file. */ //#define HAVE_UNISTD_H 1 /* Define if you have the header file. */ #define HAVE_ZLIB_H 1 /* Define if you have the coug library (-lcoug). */ /* #undef HAVE_LIBCOUG */ /* Define if you have the m library (-lm). */ #define HAVE_LIBM 1 /* Define if you have the mpi library (-lmpi). */ /* #undef HAVE_LIBMPI */ /* Define if you have the mpio library (-lmpio). */ /* #undef HAVE_LIBMPIO */ /* Define if you have the z library (-lz). */ /* #undef HAVE_LIBZ */ /*WIN32 specific stuff*/ #define HAVE_WINDOWS_H #define HAVE_IO_H 1 #undef HAVE_ATTRIBUTE #define HAVE_SYS_STAT_H /*use this flag to get around some of the problems with not having RUSAGE and time functions(see iopipe.c)*/ #define HAVE_SYS_TIMEB /* Define if you have the header file. */ #define HAVE_SYS_TYPES_H 1 /* Define to `long' if system headers don't define the ssize_t type */ #define ssize_t long /*new macro that was added to the configure script*/ #define HAVE_STDDEF_H #define HAVE_WINSOCK_H /* Define if you have the setjmp.h header. */ #define HAVE_SETJMP_H 1 /*remove these 2 definitions if you don't want the zlib*/ #define HAVE_LIBZ 1 #define HAVE_COMPRESS2 1 #ifdef win32 #if defined(__MWERKS__) || defined(__cplusplus) # define H5_inline inline # else # define H5_inline __inline #endif #endif xdmf-3.0+git20160803/Utilities/hdf5/H5pubconf.WIN32.h.in0000640000175000017500000000616713003006557022115 0ustar alastairalastair/* H5pubconf.h is adapted from UNIX platform and manually maintained on the windows platform. */ /*#define H5_HAVE_TM_ZONE 1 windows do not use this constant.*/ #define H5_MALLOC_WORKS 1 /* code warrior returns 0 in malloc(0) */ #if defined(__MWERKS__) #undef H5_MALLOC_WORKS #endif /* code warrior v.8 does not allow shared writing by default; the feature can be enabled by defining _MSL_ALLOW_SHARED_WRITING to 1 in the file file_io.win32.c and including it on the projects */ #if defined(__MWERKS__) #define H5_NO_SHARED_WRITING #endif #define H5_STDC_HEADERS 1 #define H5_HAVE_ATTRIBUTE 1 #undef H5_HAVE_ATTRIBUTE #define H5_HAVE_LARGE_HSIZET 1 #ifdef __MWERKS__ #define H5_PRINTF_LL_WIDTH "ll" #else #define H5_PRINTF_LL_WIDTH "I64" #endif #define H5_HAVE___int64 #define H5_SIZEOF___INT64 8 #define H5_SIZEOF_CHAR 1 #define H5_SIZEOF_DOUBLE 8 #define H5_SIZEOF_FLOAT 4 #define H5_SIZEOF_INT 4 #define H5_SIZEOF_INT16_T 0 #define H5_SIZEOF_INT32_T 0 #define H5_SIZEOF_INT64_T 0 #define H5_SIZEOF_INT8_T 0 #define H5_SIZEOF_INT_FAST16_T 0 #define H5_SIZEOF_INT_FAST32_T 0 #define H5_SIZEOF_INT_FAST64_T 0 #define H5_SIZEOF_INT_FAST8_T 0 #define H5_SIZEOF_INT_LEAST16_T 0 #define H5_SIZEOF_INT_LEAST32_T 0 #define H5_SIZEOF_INT_LEAST64_T 0 #define H5_SIZEOF_INT_LEAST8_T 0 #define H5_SIZEOF_LONG 4 #define H5_SIZEOF_LONG_LONG 0 #define H5_SIZEOF_LONG_DOUBLE 8 #define H5_SIZEOF_OFF_T 4 #define H5_SIZEOF_SHORT 2 #define H5_SIZEOF_SIZE_T 4 #define H5_SIZEOF_SSIZE_T 0 #define H5_SIZEOF_UINT16_T 0 #define H5_SIZEOF_UINT32_T 0 #define H5_SIZEOF_UINT64_T 0 #define H5_SIZEOF_UINT8_T 0 #define H5_SIZEOF_UINT_FAST16_T 0 #define H5_SIZEOF_UINT_FAST32_T 0 #define H5_SIZEOF_UINT_FAST64_T 0 #define H5_SIZEOF_UINT_FAST8_T 0 #define H5_SIZEOF_UINT_LEAST16_T 0 #define H5_SIZEOF_UINT_LEAST32_T 0 #define H5_SIZEOF_UINT_LEAST64_T 0 #define H5_SIZEOF_UINT_LEAST8_T 0 #define H5_HAVE_DIFFTIME 1 #define H5_HAVE_FORK 1 #define H5_HAVE_GETHOSTNAME 1 #define H5_HAVE_IOCTL 1 #define H5_HAVE_LONGJMP 1 #define H5_HAVE_SIGACTION 1 #define H5_HAVE_SIGNAL 1 #define H5_HAVE__SNPRINTF 1 #define H5_HAVE_STRDUP 1 #define H5_HAVE_SYSTEM 1 #define H5_HAVE__VSNPRINTF 1 #define H5_HAVE_IO_H 1 #define H5_HAVE_SETJMP_H 1 #define H5_HAVE_STDDEF_H 1 #define H5_HAVE_SYS_STAT_H 1 #define H5_HAVE_SYS_TIMEB 1 #define H5_HAVE_SYS_TYPES_H 1 #define H5_HAVE_WINSOCK_H 1 /* comment the following line out if you are not using check sum filter*/ #define H5_HAVE_FILTER_FLETCHER32 1 /* comment the following line out if you are not using shuffle filter*/ #define H5_HAVE_FILTER_SHUFFLE 1 /* comment the following two lines out if you are not using deflate(gzip) filter*/ #define H5_HAVE_FILTER_DEFLATE 1 #define H5_HAVE_ZLIB_H 1 /* comment the following two lines out if you are not using szip filter*/ #define H5_HAVE_SZLIB_H 1 #define H5_HAVE_FILTER_SZIP 1 #if defined(__MWERKS__) || defined(__cplusplus) #define H5_inline inline #else #define H5_inline __inline #endif #if _MSC_VER >= 1300 /* .Net supports FUNCTION */ #define H5_HAVE_FUNCTION 1 #else #undef H5_HAVE_FUNCTION #endif xdmf-3.0+git20160803/Utilities/hdf5/H5Tcset.c0000640000175000017500000001206613003006557020323 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Module Info: This module contains the functionality for setting & querying * the character set (cset) for the H5T interface. */ #define H5T_PACKAGE /*suppress error about including H5Tpkg */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5T_init_cset_interface #include "H5private.h" /*generic functions */ #include "H5Eprivate.h" /*error handling */ #include "H5Iprivate.h" /*ID functions */ #include "H5Tpkg.h" /*data-type functions */ /*-------------------------------------------------------------------------- NAME H5T_init_cset_interface -- Initialize interface-specific information USAGE herr_t H5T_init_cset_interface() RETURNS Non-negative on success/Negative on failure DESCRIPTION Initializes any interface-specific data or routines. (Just calls H5T_init_iterface currently). --------------------------------------------------------------------------*/ static herr_t H5T_init_cset_interface(void) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_init_cset_interface) FUNC_LEAVE_NOAPI(H5T_init()) } /* H5T_init_cset_interface() */ /*------------------------------------------------------------------------- * Function: H5Tget_cset * * Purpose: HDF5 is able to distinguish between character sets of * different nationalities and to convert between them to the * extent possible. * * Return: Success: The character set of a string type. * * Failure: H5T_CSET_ERROR (Negative) * * Programmer: Robb Matzke * Friday, January 9, 1998 * * Modifications: * Robb Matzke, 22 Dec 1998 * Also works for derived data types. * *------------------------------------------------------------------------- */ H5T_cset_t H5Tget_cset(hid_t type_id) { H5T_t *dt = NULL; H5T_cset_t ret_value; FUNC_ENTER_API(H5Tget_cset, H5T_CSET_ERROR) H5TRACE1("Tc","i",type_id); /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_CSET_ERROR, "not a data type") while (dt->shared->parent && !H5T_IS_STRING(dt->shared)) dt = dt->shared->parent; /*defer to parent*/ if (!H5T_IS_STRING(dt->shared)) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, H5T_CSET_ERROR, "operation not defined for data type class") /* result */ if(H5T_IS_FIXED_STRING(dt->shared)) ret_value = dt->shared->u.atomic.u.s.cset; else ret_value = dt->shared->u.vlen.cset; done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5Tset_cset * * Purpose: HDF5 is able to distinguish between character sets of * different nationalities and to convert between them to the * extent possible. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Friday, January 9, 1998 * * Modifications: * Robb Matzke, 22 Dec 1998 * Also works with derived data types. * *------------------------------------------------------------------------- */ herr_t H5Tset_cset(hid_t type_id, H5T_cset_t cset) { H5T_t *dt = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Tset_cset, FAIL) H5TRACE2("e","iTc",type_id,cset); /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") if (H5T_STATE_TRANSIENT!=dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only") if (cset < H5T_CSET_ASCII || cset >= H5T_NCSET) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal character set type") while (dt->shared->parent && !H5T_IS_STRING(dt->shared)) dt = dt->shared->parent; /*defer to parent*/ if (!H5T_IS_STRING(dt->shared)) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "operation not defined for data type class") /* Commit */ if(H5T_IS_FIXED_STRING(dt->shared)) dt->shared->u.atomic.u.s.cset = cset; else dt->shared->u.vlen.cset = cset; done: FUNC_LEAVE_API(ret_value) } xdmf-3.0+git20160803/Utilities/hdf5/H5Pprivate.h0000640000175000017500000000752613003006557021045 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * This file contains private information about the H5P module */ #ifndef _H5Pprivate_H #define _H5Pprivate_H /* Include package's public header */ #include "H5Ppublic.h" /* Private headers needed by this file */ #include "H5private.h" /* Generic Functions */ #include "H5Oprivate.h" /* Object headers */ /* Forward declarations for anonymous H5P objects */ typedef struct H5P_genplist_t H5P_genplist_t; typedef struct H5P_genclass_t H5P_genclass_t; /* Private functions, not part of the publicly documented API */ H5_DLL herr_t H5P_init(void); /* Internal versions of API routines */ H5_DLL herr_t H5P_close(void *_plist); H5_DLL hid_t H5P_create_id(H5P_genclass_t *pclass); H5_DLL hid_t H5P_copy_plist(H5P_genplist_t *old_plist); H5_DLL herr_t H5P_get(H5P_genplist_t *plist, const char *name, void *value); H5_DLL herr_t H5P_set(H5P_genplist_t *plist, const char *name, const void *value); H5_DLL herr_t H5P_insert(H5P_genplist_t *plist, const char *name, size_t size, void *value, H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get, H5P_prp_delete_func_t prp_delete, H5P_prp_copy_func_t prp_copy, H5P_prp_compare_func_t prp_cmp, H5P_prp_close_func_t prp_close); H5_DLL herr_t H5P_remove(hid_t plist_id, H5P_genplist_t *plist, const char *name); H5_DLL htri_t H5P_exist_plist(H5P_genplist_t *plist, const char *name); H5_DLL char *H5P_get_class_name(H5P_genclass_t *pclass); H5_DLL herr_t H5P_get_nprops_pclass(H5P_genclass_t *pclass, size_t *nprops); H5_DLL herr_t H5P_register(H5P_genclass_t *pclass, const char *name, size_t size, void *def_value, H5P_prp_create_func_t prp_create, H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get, H5P_prp_delete_func_t prp_delete, H5P_prp_copy_func_t prp_copy, H5P_prp_compare_func_t prp_cmp, H5P_prp_close_func_t prp_close); H5_DLL hid_t H5P_get_driver(H5P_genplist_t *plist); H5_DLL void * H5P_get_driver_info(H5P_genplist_t *plist); H5_DLL herr_t H5P_set_driver(H5P_genplist_t *plist, hid_t new_driver_id, const void *new_driver_info); H5_DLL herr_t H5P_set_vlen_mem_manager(H5P_genplist_t *plist, H5MM_allocate_t alloc_func, void *alloc_info, H5MM_free_t free_func, void *free_info); H5_DLL herr_t H5P_is_fill_value_defined(const struct H5O_fill_t *fill, H5D_fill_value_t *status); /* *SPECIAL* Don't make more of these! -QAK */ H5_DLL htri_t H5P_isa_class(hid_t plist_id, hid_t pclass_id); H5_DLL void *H5P_object_verify(hid_t plist_id, hid_t pclass_id); /* Private functions to "peek" at properties of a certain type */ H5_DLL unsigned H5P_peek_unsigned(H5P_genplist_t *plist, const char *name); H5_DLL hid_t H5P_peek_hid_t(H5P_genplist_t *plist, const char *name); H5_DLL void *H5P_peek_voidp(H5P_genplist_t *plist, const char *name); H5_DLL size_t H5P_peek_size_t(H5P_genplist_t *plist, const char *name); #endif xdmf-3.0+git20160803/Utilities/hdf5/H5Cpublic.h0000640000175000017500000000300013003006557020613 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*------------------------------------------------------------------------- * * Created: H5Cproto.h * June 4, 2005 * John Mainzer * * Purpose: Public include file for cache functions. * * Modifications: * *------------------------------------------------------------------------- */ #ifndef _H5Cpublic_H #define _H5Cpublic_H /* Public headers needed by this file */ #include "H5public.h" #ifdef __cplusplus extern "C" { #endif #ifdef __cplusplus } #endif #endif xdmf-3.0+git20160803/Utilities/hdf5/H5F.c0000640000175000017500000037327013003006557017435 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #define H5F_PACKAGE /*suppress error about including H5Fpkg */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5F_init_interface /* Packages needed by this file... */ #include "H5private.h" /* Generic Functions */ #include "H5Aprivate.h" /* Attributes */ #include "H5ACprivate.h" /* Metadata cache */ #include "H5Dprivate.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* File access */ #include "H5FDprivate.h" /* File drivers */ #include "H5FLprivate.h" /* Free lists */ #include "H5Iprivate.h" /* IDs */ #include "H5Gprivate.h" /* Groups */ #include "H5MMprivate.h" /* Memory management */ #include "H5Pprivate.h" /* Property lists */ #include "H5Tprivate.h" /* Datatypes */ /* Predefined file drivers */ #include "H5FDcore.h" /*temporary in-memory files */ #include "H5FDfamily.h" /*family of files */ #include "H5FDgass.h" /*GASS I/O */ #include "H5FDlog.h" /* sec2 driver with logging, for debugging */ #include "H5FDmpi.h" /* MPI-based file drivers */ #include "H5FDmulti.h" /*multiple files partitioned by mem usage */ #include "H5FDsec2.h" /*Posix unbuffered I/O */ #include "H5FDsrb.h" /*SRB I/O */ #include "H5FDstdio.h" /* Standard C buffered I/O */ #include "H5FDstream.h" /*in-memory files streamed via sockets */ /* Struct only used by functions H5F_get_objects and H5F_get_objects_cb */ typedef struct H5F_olist_t { H5I_type_t obj_type; /* Type of object to look for */ hid_t *obj_id_list; /* Pointer to the list of open IDs to return */ unsigned *obj_id_count; /* Number of open IDs */ struct { hbool_t local; /* Set flag for "local" file searches */ union { H5F_file_t *shared; /* Pointer to shared file to look inside */ const H5F_t *file; /* Pointer to file to look inside */ } ptr; } file_info; unsigned list_index; /* Current index in open ID array */ int max_index; /* Maximum # of IDs to put into array */ } H5F_olist_t; /* PRIVATE PROTOTYPES */ #ifdef NOT_YET static int H5F_flush_all_cb(void *f, hid_t fid, void *_invalidate); #endif /* NOT_YET */ static unsigned H5F_get_objects(const H5F_t *f, unsigned types, int max_objs, hid_t *obj_id_list); static int H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key); static herr_t H5F_get_vfd_handle(const H5F_t *file, hid_t fapl, void** file_handle); static H5F_t *H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id); static herr_t H5F_dest(H5F_t *f, hid_t dxpl_id); static H5F_t *H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id); static herr_t H5F_flush(H5F_t *f, hid_t dxpl_id, H5F_scope_t scope, unsigned flags); static herr_t H5F_close(H5F_t *f); /* Declare a free list to manage the H5F_t struct */ H5FL_DEFINE_STATIC(H5F_t); /* Declare a free list to manage the H5F_file_t struct */ H5FL_DEFINE_STATIC(H5F_file_t); /*------------------------------------------------------------------------- * Function: H5F_init * * Purpose: Initialize the interface from some other layer. * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Wednesday, December 16, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5F_init(void) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5F_init, FAIL) /* FUNC_ENTER() does all the work */ done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5F_init_interface * * Purpose: Initialize interface-specific information. * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Friday, November 20, 1998 * * Modifications: * Robb Matzke, 4 Aug 1997 * Changed pablo mask from H5_mask to H5F_mask for the FUNC_LEAVE call. * It was already H5F_mask for the PABLO_TRACE_ON call. * * Kim Yates, 1998-08-16 * Added .disp, .btype, .ftype to H5F_access_t. * * Robb Matzke, 1999-02-19 * Added initialization for the H5I_FILE_CLOSING ID group. * * Raymond Lu, April 10, 2000 * Put SRB into the 'Register predefined file drivers' list. * * Thomas Radke, 2000-09-12 * Put Stream VFD into the 'Register predefined file drivers' list. * * Raymond Lu, 2001-10-14 * Change File creation property list to generic property list mechanism. *------------------------------------------------------------------------- */ static herr_t H5F_init_interface(void) { size_t nprops; /* Number of properties */ herr_t ret_value = SUCCEED; /* File creation property class variables. In sequence, they are * - File create property list class to modify * - Default value for size of file user block * - Default value for 1/2 rank for symbol table leaf nodes * - Default value for 1/2 rank for btree internal nodes * - Default value for byte number in an address * - Default value for byte number for object size * - Default value for version number of superblock * - Default value for free-space version number * - Default value for object directory version number * - Default value for share-header format version */ H5P_genclass_t *crt_pclass; hsize_t userblock_size = H5F_CRT_USER_BLOCK_DEF; unsigned sym_leaf_k = H5F_CRT_SYM_LEAF_DEF; unsigned btree_k[H5B_NUM_BTREE_ID] = H5F_CRT_BTREE_RANK_DEF; size_t sizeof_addr = H5F_CRT_ADDR_BYTE_NUM_DEF; size_t sizeof_size = H5F_CRT_OBJ_BYTE_NUM_DEF; unsigned superblock_ver = H5F_CRT_SUPER_VERS_DEF; unsigned freespace_ver = H5F_CRT_FREESPACE_VERS_DEF; unsigned objectdir_ver = H5F_CRT_OBJ_DIR_VERS_DEF; unsigned sharedheader_ver = H5F_CRT_SHARE_HEAD_VERS_DEF; /* File access property class variables. In sequence, they are * - File access property class to modify * - Size of meta data cache(elements) * - Size of raw data chunk cache(elements) * - Size of raw data chunk cache(bytes) * - Preemption for reading chunks * - Threshold for alignment * - Alignment * - Minimum metadata allocation block size * - Maximum sieve buffer size * - Garbage-collect reference * - File driver ID * - File driver info */ H5P_genclass_t *acs_pclass; int mdc_nelmts = H5F_ACS_META_CACHE_SIZE_DEF; size_t rdcc_nelmts = H5F_ACS_DATA_CACHE_ELMT_SIZE_DEF; size_t rdcc_nbytes = H5F_ACS_DATA_CACHE_BYTE_SIZE_DEF; double rdcc_w0 = H5F_ACS_PREEMPT_READ_CHUNKS_DEF; hsize_t threshold = H5F_ACS_ALIGN_THRHD_DEF; hsize_t alignment = H5F_ACS_ALIGN_DEF; hsize_t meta_block_size = H5F_ACS_META_BLOCK_SIZE_DEF; size_t sieve_buf_size = H5F_ACS_SIEVE_BUF_SIZE_DEF; hsize_t sdata_block_size = H5F_ACS_SDATA_BLOCK_SIZE_DEF; unsigned gc_ref = H5F_ACS_GARBG_COLCT_REF_DEF; hid_t driver_id = H5F_ACS_FILE_DRV_ID_DEF; void *driver_info = H5F_ACS_FILE_DRV_INFO_DEF; H5F_close_degree_t close_degree = H5F_CLOSE_DEGREE_DEF; hsize_t family_offset = H5F_ACS_FAMILY_OFFSET_DEF; H5FD_mem_t mem_type = H5F_ACS_MULTI_TYPE_DEF; /* File mount property class variable. * - Mount property class to modify * - whether absolute symlinks is local to file */ H5P_genclass_t *mnt_pclass; hbool_t local = H5F_MNT_SYM_LOCAL_DEF; FUNC_ENTER_NOAPI_NOINIT(H5F_init_interface) /* * Initialize the atom group for the file IDs. There are two groups: * the H5I_FILE group contains all the ID's for files which are currently * open at the public API level while the H5I_FILE_CLOSING group contains * ID's for files for which the application has called H5Fclose() but * which are pending completion because there are object headers still * open within the file. */ if (H5I_init_group(H5I_FILE, (size_t)H5I_FILEID_HASHSIZE, 0, (H5I_free_t)H5F_close)<0) HGOTO_ERROR (H5E_FILE, H5E_CANTINIT, FAIL, "unable to initialize interface") /* ========== File Creation Property Class Initialization ============*/ assert(H5P_CLS_FILE_CREATE_g!=-1); /* Get the pointer to file creation class */ if(NULL == (crt_pclass = H5I_object(H5P_CLS_FILE_CREATE_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class") /* Get the number of properties in the class */ if(H5P_get_nprops_pclass(crt_pclass,&nprops)<0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't query number of properties") /* Assume that if there are properties in the class, they are the default ones */ if(nprops==0) { /* Register the user block size */ if(H5P_register(crt_pclass,H5F_CRT_USER_BLOCK_NAME,H5F_CRT_USER_BLOCK_SIZE, &userblock_size,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the 1/2 rank for symbol table leaf nodes */ if(H5P_register(crt_pclass,H5F_CRT_SYM_LEAF_NAME,H5F_CRT_SYM_LEAF_SIZE, &sym_leaf_k,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the 1/2 rank for btree internal nodes */ if(H5P_register(crt_pclass,H5F_CRT_BTREE_RANK_NAME,H5F_CRT_BTREE_RANK_SIZE, btree_k,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the byte number for an address */ if(H5P_register(crt_pclass,H5F_CRT_ADDR_BYTE_NUM_NAME, H5F_CRT_ADDR_BYTE_NUM_SIZE, &sizeof_addr,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the byte number for object size */ if(H5P_register(crt_pclass,H5F_CRT_OBJ_BYTE_NUM_NAME, H5F_CRT_OBJ_BYTE_NUM_SIZE,&sizeof_size,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the superblock version number */ if(H5P_register(crt_pclass,H5F_CRT_SUPER_VERS_NAME,H5F_CRT_SUPER_VERS_SIZE, &superblock_ver,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the free-space version number */ if(H5P_register(crt_pclass,H5F_CRT_FREESPACE_VERS_NAME, H5F_CRT_FREESPACE_VERS_SIZE,&freespace_ver,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the object directory version number */ if(H5P_register(crt_pclass,H5F_CRT_OBJ_DIR_VERS_NAME, H5F_CRT_OBJ_DIR_VERS_SIZE,&objectdir_ver,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the shared-header version number */ if(H5P_register(crt_pclass,H5F_CRT_SHARE_HEAD_VERS_NAME, H5F_CRT_SHARE_HEAD_VERS_SIZE, &sharedheader_ver,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") } /* end if */ /* Only register the default property list if it hasn't been created yet */ if(H5P_LST_FILE_CREATE_g==(-1)) { /* Register the default file creation property list */ if((H5P_LST_FILE_CREATE_g = H5P_create_id(crt_pclass))<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't insert property into class") } /* end if */ /* ========== File Access Property Class Initialization ============*/ assert(H5P_CLS_FILE_ACCESS_g!=-1); /* Get the pointer to file creation class */ if(NULL == (acs_pclass = H5I_object(H5P_CLS_FILE_ACCESS_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class") /* Get the number of properties in the class */ if(H5P_get_nprops_pclass(acs_pclass,&nprops)<0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't query number of properties") /* Assume that if there are properties in the class, they are the default ones */ if(nprops==0) { /* Register the size of meta data cache(elements) */ if(H5P_register(acs_pclass,H5F_ACS_META_CACHE_SIZE_NAME,H5F_ACS_META_CACHE_SIZE_SIZE, &mdc_nelmts,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the size of raw data chunk cache (elements) */ if(H5P_register(acs_pclass,H5F_ACS_DATA_CACHE_ELMT_SIZE_NAME,H5F_ACS_DATA_CACHE_ELMT_SIZE_SIZE, &rdcc_nelmts,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the size of raw data chunk cache(bytes) */ if(H5P_register(acs_pclass,H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME,H5F_ACS_DATA_CACHE_BYTE_SIZE_SIZE, &rdcc_nbytes,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the preemption for reading chunks */ if(H5P_register(acs_pclass,H5F_ACS_PREEMPT_READ_CHUNKS_NAME,H5F_ACS_PREEMPT_READ_CHUNKS_SIZE, &rdcc_w0,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the threshold for alignment */ if(H5P_register(acs_pclass,H5F_ACS_ALIGN_THRHD_NAME,H5F_ACS_ALIGN_THRHD_SIZE, &threshold,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the alignment */ if(H5P_register(acs_pclass,H5F_ACS_ALIGN_NAME,H5F_ACS_ALIGN_SIZE, &alignment,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the minimum metadata allocation block size */ if(H5P_register(acs_pclass,H5F_ACS_META_BLOCK_SIZE_NAME,H5F_ACS_META_BLOCK_SIZE_SIZE, &meta_block_size,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the maximum sieve buffer size */ if(H5P_register(acs_pclass,H5F_ACS_SIEVE_BUF_SIZE_NAME,H5F_ACS_SIEVE_BUF_SIZE_SIZE, &sieve_buf_size,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the minimum "small data" allocation block size */ if(H5P_register(acs_pclass,H5F_ACS_SDATA_BLOCK_SIZE_NAME,H5F_ACS_SDATA_BLOCK_SIZE_SIZE, &sdata_block_size,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the garbage collection reference */ if(H5P_register(acs_pclass,H5F_ACS_GARBG_COLCT_REF_NAME,H5F_ACS_GARBG_COLCT_REF_SIZE, &gc_ref,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the file driver ID */ if(H5P_register(acs_pclass,H5F_ACS_FILE_DRV_ID_NAME,H5F_ACS_FILE_DRV_ID_SIZE, &driver_id,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the file driver info */ if(H5P_register(acs_pclass,H5F_ACS_FILE_DRV_INFO_NAME,H5F_ACS_FILE_DRV_INFO_SIZE, &driver_info,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the file close degree */ if(H5P_register(acs_pclass,H5F_CLOSE_DEGREE_NAME,H5F_CLOSE_DEGREE_SIZE, &close_degree,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the offset of family driver info */ if(H5P_register(acs_pclass,H5F_ACS_FAMILY_OFFSET_NAME,H5F_ACS_FAMILY_OFFSET_SIZE, &family_offset,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the data type of multi driver info */ if(H5P_register(acs_pclass,H5F_ACS_MULTI_TYPE_NAME,H5F_ACS_MULTI_TYPE_SIZE, &mem_type,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") } /* end if */ /* Only register the default property list if it hasn't been created yet */ if(H5P_LST_FILE_ACCESS_g==(-1)) { /* Register the default file access property list */ if((H5P_LST_FILE_ACCESS_g = H5P_create_id(acs_pclass))<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't insert property into class") } /* end if */ /* ================ Mount Porperty Class Initialization ==============*/ assert(H5P_CLS_MOUNT_g!=-1); /* Get the pointer to file mount class */ if(NULL == (mnt_pclass = H5I_object(H5P_CLS_MOUNT_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class") /* Get the number of properties in the class */ if(H5P_get_nprops_pclass(mnt_pclass,&nprops)<0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't query number of properties") /* Assume that if there are properties in the class, they are the default ones */ if(nprops==0) { /* Register property of whether symlinks is local to file */ if(H5P_register(mnt_pclass,H5F_MNT_SYM_LOCAL_NAME,H5F_MNT_SYM_LOCAL_SIZE, &local,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") } /* end if */ /* Only register the default property list if it hasn't been created yet */ if(H5P_LST_MOUNT_g==(-1)) { /* Register the default file mount property list */ if((H5P_LST_MOUNT_g = H5P_create_id(mnt_pclass))<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't insert property into class") } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5F_term_interface * * Purpose: Terminate this interface: free all memory and reset global * variables to their initial values. Release all ID groups * associated with this interface. * * Return: Success: Positive if anything was done that might * have affected other interfaces; zero * otherwise. * * Failure: Never fails. * * Programmer: Robb Matzke * Friday, February 19, 1999 * * Modifications: * *------------------------------------------------------------------------- */ int H5F_term_interface(void) { int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_term_interface) if (H5_interface_initialize_g) { if ((n=H5I_nmembers(H5I_FILE))!=0) { H5I_clear_group(H5I_FILE, FALSE); } else { /* Make certain we've cleaned up all the shared file objects */ H5F_sfile_assert_num(0); H5I_destroy_group(H5I_FILE); H5_interface_initialize_g = 0; n = 1; /*H5I*/ } } FUNC_LEAVE_NOAPI(n) } /*---------------------------------------------------------------------------- * Function: H5F_acs_create * * Purpose: Callback routine which is called whenever a file access * property list is closed. This routine performs any generic * initialization needed on the properties the library put into * the list. * * Return: Success: Non-negative * Failure: Negative * * Programmer: Raymond Lu * Tuesday, Oct 23, 2001 * * Modifications: * *---------------------------------------------------------------------------- */ /* ARGSUSED */ herr_t H5F_acs_create(hid_t fapl_id, void UNUSED *copy_data) { hid_t driver_id; void* driver_info; H5P_genplist_t *plist; /* Property list */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5F_acs_create, FAIL) /* Check argument */ if(NULL == (plist = H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") /* Retrieve properties */ if(H5P_get(plist, H5F_ACS_FILE_DRV_ID_NAME, &driver_id) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get drver ID") if(H5P_get(plist, H5F_ACS_FILE_DRV_INFO_NAME, &driver_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get drver info") if(driver_id > 0) { /* Set the driver for the property list */ if(H5FD_fapl_open(plist, driver_id, driver_info)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set driver") } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /*-------------------------------------------------------------------------- * Function: H5F_acs_copy * * Purpose: Callback routine which is called whenever a file access * property list is copied. This routine performs any generic * copy needed on the properties. * * Return: Success: Non-negative * Failure: Negative * Programmer: Raymond Lu * Tuesday, Oct 23, 2001 * * Modifications: * *-------------------------------------------------------------------------- */ /* ARGSUSED */ herr_t H5F_acs_copy(hid_t new_fapl_id, hid_t old_fapl_id, void UNUSED *copy_data) { hid_t driver_id; void* driver_info; H5P_genplist_t *new_plist; /* New property list */ H5P_genplist_t *old_plist; /* Old property list */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5F_acs_copy, FAIL) if(NULL == (new_plist = H5I_object(new_fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") if(NULL == (old_plist = H5I_object(old_fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") /* Get values from old property list */ if(H5P_get(old_plist, H5F_ACS_FILE_DRV_ID_NAME, &driver_id) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get drver ID") if(H5P_get(old_plist, H5F_ACS_FILE_DRV_INFO_NAME, &driver_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get drver info") if(driver_id > 0) { /* Set the driver for the property list */ if(H5FD_fapl_open(new_plist, driver_id, driver_info)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set driver") } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /*-------------------------------------------------------------------------- * Function: H5F_acs_close * * Purpose: Callback routine which is called whenever a file access * property list is closed. This routine performs any generic * cleanup needed on the properties. * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Raymond Lu * Tuesday, Oct 23, 2001 * * Modifications: * *--------------------------------------------------------------------------- */ /* ARGSUSED */ herr_t H5F_acs_close(hid_t fapl_id, void UNUSED *close_data) { hid_t driver_id; void *driver_info; H5P_genplist_t *plist; /* Property list */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5F_acs_close, FAIL) /* Check argument */ if(NULL == (plist = H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") if(H5P_get(plist, H5F_ACS_FILE_DRV_ID_NAME, &driver_id) < 0) HGOTO_DONE(FAIL) /* Can't return errors when library is shutting down */ if(H5P_get(plist, H5F_ACS_FILE_DRV_INFO_NAME, &driver_info) < 0) HGOTO_DONE(FAIL) /* Can't return errors when library is shutting down */ if(driver_id > 0) { /* Close the driver for the property list */ if(H5FD_fapl_close(driver_id, driver_info)<0) HGOTO_DONE(FAIL) /* Can't return errors when library is shutting down */ } done: FUNC_LEAVE_NOAPI(ret_value) } #ifdef NOT_YET /*------------------------------------------------------------------------- * Function: H5F_flush_all_cb * * Purpose: Callback function for H5F_flush_all(). * * Return: Always returns zero. * * Programmer: Robb Matzke * Friday, February 19, 1999 * * Modifications: * Bill Wendling, 2003-03-18 * Changed H5F_flush to accept H5F_flush_t flags instead of a * series of h5bool_t's. * *------------------------------------------------------------------------- */ static int H5F_flush_all_cb(void *_f, hid_t UNUSED fid, void *_invalidate) { H5F_t *f=(H5F_t *)_f; unsigned invalidate = (*((hbool_t*)_invalidate); FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_flush_all_cb) H5F_flush(f, H5F_SCOPE_LOCAL, (invalidate ? H5F_FLUSH_INVALIDATE : H5F_FLUSH_NONE)); FUNC_LEAVE_NOAPI(0) } /*------------------------------------------------------------------------- * Function: H5F_flush_all * * Purpose: Flush all open files. If INVALIDATE is true then also remove * everything from the cache. * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Thursday, February 18, 1999 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5F_flush_all(hbool_t invalidate) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5F_flush_all, FAIL) H5I_search(H5I_FILE,H5F_flush_all_cb,&invalidate); done: FUNC_LEAVE_NOAPI(ret_value) } #endif /* NOT_YET */ #ifdef NOT_YET /*-------------------------------------------------------------------------- NAME H5F_encode_length_unusual -- encode an unusual length size USAGE void H5F_encode_length_unusual(f, p, l) const H5F_t *f; IN: pointer to the file record uint8_t **p; IN: pointer to buffer pointer to encode length in uint8_t *l; IN: pointer to length to encode ERRORS RETURNS none DESCRIPTION Encode non-standard (i.e. not 2, 4 or 8-byte) lengths in file meta-data. --------------------------------------------------------------------------*/ void H5F_encode_length_unusual(const H5F_t *f, uint8_t **p, uint8_t *l) { int i = (int)H5F_SIZEOF_SIZE(f)-1; #ifdef WORDS_BIGENDIAN /* * For non-little-endian platforms, encode each byte in memory backwards. */ for (/*void*/; i>=0; i--, (*p)++)*(*p) = *(l+i); #else /* platform has little-endian integers */ HDmemcpy(*p,l,(size_t)(i+1)); *p+=(i+1); #endif } #endif /* NOT_YET */ /*------------------------------------------------------------------------- * Function: H5Fget_create_plist * * Purpose: Get an atom for a copy of the file-creation property list for * this file. This function returns an atom with a copy of the * properties used to create a file. * * Return: Success: template ID * * Failure: FAIL * * Programmer: Unknown * * Modifications: * * Robb Matzke, 18 Feb 1998 * Calls H5P_copy_plist() to copy the property list and H5P_close() to free * that property list if an error occurs. * * Raymond Lu, Oct 14, 2001 * Changed to generic property list. * *------------------------------------------------------------------------- */ hid_t H5Fget_create_plist(hid_t file_id) { H5F_t *file = NULL; H5P_genplist_t *plist; /* Property list */ hid_t ret_value; FUNC_ENTER_API(H5Fget_create_plist, FAIL) H5TRACE1("i","i",file_id); /* check args */ if (NULL==(file=H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") if(NULL == (plist = H5I_object(file->shared->fcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") /* Create the property list object to return */ if((ret_value=H5P_copy_plist(plist)) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "unable to copy file creation properties") done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5Fget_access_plist * * Purpose: Returns a copy of the file access property list of the * specified file. * * NOTE: Make sure that, if you are going to overwrite * information in the copied property list that was * previously opened and assigned to the property list, then * you must close it before overwriting the values. * * Return: Success: Object ID for a copy of the file access * property list. * * Failure: FAIL * * Programmer: Robb Matzke * Wednesday, February 18, 1998 * * Modifications: * Raymond Lu, Oct 23, 2001 * Changed file access property list to the new generic * property list. * * Bill Wendling, Apr 21, 2003 * Fixed bug where the driver ID and info in the property * list were being overwritten but the original ID and info * weren't being close. * *------------------------------------------------------------------------- */ hid_t H5Fget_access_plist(hid_t file_id) { H5F_t *f = NULL; H5P_genplist_t *new_plist; /* New property list */ H5P_genplist_t *old_plist; /* Old property list */ hid_t ret_value = SUCCEED; void *driver_info=NULL; FUNC_ENTER_API(H5Fget_access_plist, FAIL) H5TRACE1("i","i",file_id); /* Check args */ if (NULL==(f=H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") /* Make a copy of the default file access property list */ if(NULL == (old_plist = H5I_object(H5P_LST_FILE_ACCESS_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") if((ret_value=H5P_copy_plist(old_plist)) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "can't copy file access property list") if(NULL == (new_plist = H5I_object(ret_value))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") /* Copy properties of the file access property list */ if(H5P_set(new_plist, H5F_ACS_META_CACHE_SIZE_NAME, &(f->shared->mdc_nelmts)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set meta data cache size") if(H5P_set(new_plist, H5F_ACS_DATA_CACHE_ELMT_SIZE_NAME, &(f->shared->rdcc_nelmts)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set data cache element size") if(H5P_set(new_plist, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, &(f->shared->rdcc_nbytes)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set data cache byte size") if(H5P_set(new_plist, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, &(f->shared->rdcc_w0)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set preempt read chunks") if(H5P_set(new_plist, H5F_ACS_ALIGN_THRHD_NAME, &(f->shared->threshold)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set alignment threshold") if(H5P_set(new_plist, H5F_ACS_ALIGN_NAME, &(f->shared->alignment)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set alignment") if(H5P_set(new_plist, H5F_ACS_GARBG_COLCT_REF_NAME, &(f->shared->gc_ref)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set garbage collect reference") if(H5P_set(new_plist, H5F_ACS_META_BLOCK_SIZE_NAME, &(f->shared->lf->def_meta_block_size)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set meta data cache size") if(H5P_set(new_plist, H5F_ACS_SIEVE_BUF_SIZE_NAME, &(f->shared->sieve_buf_size)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't sieve buffer size") if(H5P_set(new_plist, H5F_ACS_SDATA_BLOCK_SIZE_NAME, &(f->shared->lf->def_sdata_block_size)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set 'small data' cache size") /* * Since we're resetting the driver ID and info, close them if they * exist in this new property list. */ if (H5F_acs_close(ret_value, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't free the old driver information") /* Increment the reference count on the driver ID and insert it into the property list */ if(H5I_inc_ref(f->shared->lf->driver_id)<0) HGOTO_ERROR(H5E_FILE, H5E_CANTINC, FAIL, "unable to increment ref count on VFL driver") if(H5P_set(new_plist, H5F_ACS_FILE_DRV_ID_NAME, &(f->shared->lf->driver_id)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file driver ID") /* Set the driver "info" in the property list */ driver_info = H5FD_fapl_get(f->shared->lf); if(driver_info != NULL && H5P_set(new_plist, H5F_ACS_FILE_DRV_INFO_NAME, &driver_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file driver info") /* Set the file close degree appropriately */ if(f->shared->fc_degree == H5F_CLOSE_DEFAULT && H5P_set(new_plist, H5F_CLOSE_DEGREE_NAME, &(f->shared->lf->cls->fc_degree)) < 0) { HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file close degree") } else if(f->shared->fc_degree != H5F_CLOSE_DEFAULT && H5P_set(new_plist, H5F_CLOSE_DEGREE_NAME, &(f->shared->fc_degree)) < 0) { HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file close degree") } done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5Fget_obj_count * * Purpose: Public function returning the number of opened object IDs * (files, datasets, groups and datatypes) in the same file. * * Return: Non-negative on success; negative on failure. * * Programmer: Raymond Lu * Wednesday, Dec 5, 2001 * * Modification: * *------------------------------------------------------------------------- */ int H5Fget_obj_count(hid_t file_id, unsigned types) { H5F_t *f=NULL; int ret_value; /* Return value */ FUNC_ENTER_API(H5Fget_obj_count, FAIL) H5TRACE2("Is","iIu",file_id,types); if( file_id != (hid_t)H5F_OBJ_ALL && (NULL==(f=H5I_object_verify(file_id,H5I_FILE))) ) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file id") if( (types&H5F_OBJ_ALL)==0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not an object type") if((ret_value = H5F_get_obj_count(f, types))<0) HGOTO_ERROR(H5E_FILE, H5E_CANTCOUNT, FAIL, "can't get object count") done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5F_get_obj_count * * Purpose: Private function return the number of opened object IDs * (files, datasets, groups, datatypes) in the same file. * * Return: Non-negative on success; negative on failure. * * Programmer: Raymond Lu * Wednesday, Dec 5, 2001 * * Modification: * *------------------------------------------------------------------------- */ unsigned H5F_get_obj_count(const H5F_t *f, unsigned types) { unsigned ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_get_obj_count) ret_value=H5F_get_objects(f, types, -1, NULL); FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5Fget_object_ids * * Purpose: Public function to return a list of opened object IDs. * * Return: Non-negative on success; negative on failure. * * Programmer: Raymond Lu * Wednesday, Dec 5, 2001 * * Modification: * *------------------------------------------------------------------------- */ herr_t H5Fget_obj_ids(hid_t file_id, unsigned types, int max_objs, hid_t *oid_list) { herr_t ret_value; H5F_t *f=NULL; FUNC_ENTER_API(H5Fget_obj_ids, FAIL) H5TRACE4("e","iIuIs*i",file_id,types,max_objs,oid_list); if( file_id != (hid_t)H5F_OBJ_ALL && (NULL==(f=H5I_object_verify(file_id,H5I_FILE))) ) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file id") if( (types&H5F_OBJ_ALL)==0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not an object type") assert(oid_list); ret_value = H5F_get_obj_ids(f, types, max_objs, oid_list); done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5F_get_obj_ids * * Purpose: Private function to return a list of opened object IDs. * * Return: Non-negative on success; negative on failure. * * Programmer: Raymond Lu * Wednesday, Dec 5, 2001 * * Modification: * *------------------------------------------------------------------------- */ unsigned H5F_get_obj_ids(const H5F_t *f, unsigned types, int max_objs, hid_t *oid_list) { unsigned ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_get_obj_ids) ret_value = H5F_get_objects(f, types, max_objs, oid_list); FUNC_LEAVE_NOAPI(ret_value) } /*--------------------------------------------------------------------------- * Function: H5F_get_objects * * Purpose: This function is called by H5F_get_obj_count or * H5F_get_obj_ids to get number of object IDs and/or a * list of opened object IDs (in return value). * Return: Non-negative on success; negative on failure. * * Programmer: Raymond Lu * Wednesday, Dec 5, 2001 * * Modification: * *--------------------------------------------------------------------------- */ static unsigned H5F_get_objects(const H5F_t *f, unsigned types, int max_index, hid_t *obj_id_list) { unsigned obj_id_count=0; /* Number of open IDs */ H5F_olist_t olist; /* Structure to hold search results */ unsigned ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_get_objects) /* Set up search information */ olist.obj_id_list = (max_index==0 ? NULL : obj_id_list); olist.obj_id_count = &obj_id_count; olist.list_index = 0; olist.max_index = max_index; /* Determine if we are searching for local or global objects */ if(types&H5F_OBJ_LOCAL) { olist.file_info.local = TRUE; olist.file_info.ptr.file = f; } /* end if */ else { olist.file_info.local = FALSE; olist.file_info.ptr.shared = f ? f->shared : NULL; } /* end else */ /* Search through file IDs to count the number, and put their * IDs on the object list */ if(types & H5F_OBJ_FILE) { olist.obj_type = H5I_FILE; (void)H5I_search(H5I_FILE, H5F_get_objects_cb, &olist); } /* end if */ /* Search through dataset IDs to count number of datasets, and put their * IDs on the object list */ if( (max_index < 0 || (int)olist.list_index < max_index) && (types & H5F_OBJ_DATASET) ) { olist.obj_type = H5I_DATASET; (void)H5I_search(H5I_DATASET, H5F_get_objects_cb, &olist); } /* Search through group IDs to count number of groups, and put their * IDs on the object list */ if( (max_index < 0 || (int)olist.list_index < max_index) && (types & H5F_OBJ_GROUP) ) { olist.obj_type = H5I_GROUP; (void)H5I_search(H5I_GROUP, H5F_get_objects_cb, &olist); } /* Search through datatype IDs to count number of named datatypes, and put their * IDs on the object list */ if( (max_index < 0 || (int)olist.list_index < max_index) && (types & H5F_OBJ_DATATYPE) ) { olist.obj_type = H5I_DATATYPE; (void)H5I_search(H5I_DATATYPE, H5F_get_objects_cb, &olist); } /* Search through attribute IDs to count number of attributes, and put their * IDs on the object list */ if( (max_index < 0 || (int)olist.list_index < max_index) && (types & H5F_OBJ_ATTR) ) { olist.obj_type = H5I_ATTR; (void)H5I_search(H5I_ATTR, H5F_get_objects_cb, &olist); } /* Set the number of objects currently open */ ret_value = obj_id_count; FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5F_get_objects_cb * * Purpose: H5F_get_objects' callback function. It verifies if an * object is in the file, and either count it or put its ID * on the list. * * Programmer: Raymond Lu * Wednesday, Dec 5, 2001 * * Modification: * *------------------------------------------------------------------------- */ static int H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key) { H5F_olist_t *olist = (H5F_olist_t *)key; /* Alias for search info */ int ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5F_get_objects_cb) assert(obj_ptr); assert(olist); /* Count file IDs */ if(olist->obj_type == H5I_FILE) { if((olist->file_info.local && (!olist->file_info.ptr.file || (olist->file_info.ptr.file && (H5F_t*)obj_ptr == olist->file_info.ptr.file) )) || (!olist->file_info.local && ( !olist->file_info.ptr.shared || (olist->file_info.ptr.shared && ((H5F_t*)obj_ptr)->shared == olist->file_info.ptr.shared) ))) { /* Add the object's ID to the ID list, if appropriate */ if(olist->obj_id_list) { olist->obj_id_list[olist->list_index] = obj_id; olist->list_index++; } /* Increment the number of open objects */ if(olist->obj_id_count) (*olist->obj_id_count)++; /* Check if we've filled up the array */ if(olist->max_index>=0 && (int)olist->list_index>=olist->max_index) HGOTO_DONE(TRUE) /* Indicate that the iterator should stop */ } } else { /* either count opened object IDs or put the IDs on the list */ H5G_entry_t *ent; /* Group entry info for object */ switch(olist->obj_type) { case H5I_ATTR: ent = H5A_entof((H5A_t*)obj_ptr); break; case H5I_GROUP: ent = H5G_entof((H5G_t*)obj_ptr); break; case H5I_DATASET: ent = H5D_entof((H5D_t*)obj_ptr); break; case H5I_DATATYPE: if(H5T_is_named((H5T_t*)obj_ptr)==TRUE) ent = H5T_entof((H5T_t*)obj_ptr); else ent = NULL; break; default: HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unknown data object") } if((olist->file_info.local && ( (!olist->file_info.ptr.file && olist->obj_type==H5I_DATATYPE && H5T_is_immutable((H5T_t*)obj_ptr)==FALSE) || (!olist->file_info.ptr.file && olist->obj_type!=H5I_DATATYPE) || (ent && ent->file == olist->file_info.ptr.file) )) || (!olist->file_info.local && ((!olist->file_info.ptr.shared && olist->obj_type==H5I_DATATYPE && H5T_is_immutable((H5T_t*)obj_ptr)==FALSE) || (!olist->file_info.ptr.shared && olist->obj_type!=H5I_DATATYPE) || (ent && ent->file && ent->file->shared == olist->file_info.ptr.shared) ))) { /* Add the object's ID to the ID list, if appropriate */ if(olist->obj_id_list) { olist->obj_id_list[olist->list_index] = obj_id; olist->list_index++; } /* Increment the number of open objects */ if(olist->obj_id_count) (*olist->obj_id_count)++; /* Check if we've filled up the array */ if(olist->max_index>=0 && (int)olist->list_index>=olist->max_index) HGOTO_DONE(TRUE) /* Indicate that the iterator should stop */ } } done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5Fget_vfd_handle * * Purpose: Returns a pointer to the file handle of the low-level file * driver. * * Return: Success: non-negative value. * * Failture: negative. * * Programmer: Raymond Lu * Sep. 16, 2002 * * Modification: * *------------------------------------------------------------------------- */ herr_t H5Fget_vfd_handle(hid_t file_id, hid_t fapl, void **file_handle) { H5F_t *file=NULL; herr_t ret_value; FUNC_ENTER_API(H5Fget_vfd_handle, FAIL) H5TRACE3("e","iix",file_id,fapl,file_handle); /* Check args */ assert(file_handle); if(NULL==(file=H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file id") ret_value=H5F_get_vfd_handle(file, fapl, file_handle); done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5F_get_vfd_handle * * Purpose: Returns a pointer to the file handle of the low-level file * driver. This is the private function for H5Fget_vfd_handle. * * Return: Success: Non-negative. * * Failture: negative. * * Programmer: Raymond Lu * Sep. 16, 2002 * * Modification: * *------------------------------------------------------------------------- */ static herr_t H5F_get_vfd_handle(const H5F_t *file, hid_t fapl, void**file_handle) { herr_t ret_value; FUNC_ENTER_NOAPI_NOINIT(H5F_get_vfd_handle) assert(file_handle); if((ret_value=H5FD_get_vfd_handle(file->shared->lf, fapl, file_handle)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get file handle for file driver") done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5F_locate_signature * * Purpose: Finds the HDF5 super block signature in a file. The signature * can appear at address 0, or any power of two beginning with * 512. * * Return: Success: The absolute format address of the signature. * * Failure: HADDR_UNDEF * * Programmer: Robb Matzke * Friday, November 7, 1997 * * Modifications: * Robb Matzke, 1999-08-02 * Rewritten to use the virtual file layer. *------------------------------------------------------------------------- */ haddr_t H5F_locate_signature(H5FD_t *file, hid_t dxpl_id) { haddr_t addr, eoa; uint8_t buf[H5F_SIGNATURE_LEN]; unsigned n, maxpow; haddr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5F_locate_signature) /* Find the least N such that 2^N is larger than the file size */ if (HADDR_UNDEF==(addr=H5FD_get_eof(file)) || HADDR_UNDEF==(eoa=H5FD_get_eoa(file))) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, HADDR_UNDEF, "unable to obtain EOF/EOA value") for (maxpow=0; addr; maxpow++) addr>>=1; maxpow = MAX(maxpow, 9); /* * Search for the file signature at format address zero followed by * powers of two larger than 9. */ for (n=8; n=maxpow) { (void)H5FD_set_eoa(file, eoa); /* Ignore return value */ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, HADDR_UNDEF, "unable to find a valid file signature") } /* Set return value */ ret_value=addr; done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5Fis_hdf5 * * Purpose: Check the file signature to detect an HDF5 file. * * Bugs: This function is not robust: it only uses the default file * driver when attempting to open the file when in fact it * should use all known file drivers. * * Return: Success: TRUE/FALSE * * Failure: Negative * * Programmer: Unknown * * Modifications: * Robb Matzke, 1999-08-02 * Rewritten to use the virtual file layer. *------------------------------------------------------------------------- */ htri_t H5Fis_hdf5(const char *name) { H5FD_t *file = NULL; htri_t ret_value; FUNC_ENTER_API(H5Fis_hdf5, FAIL) H5TRACE1("t","s",name); /* Check args and all the boring stuff. */ if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "no file name specified") /* Open the file at the virtual file layer */ if (NULL==(file=H5FD_open(name, H5F_ACC_RDONLY, H5P_FILE_ACCESS_DEFAULT, HADDR_UNDEF))) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to open file") /* The file is an hdf5 file if the hdf5 file signature can be found */ ret_value = (HADDR_UNDEF!=H5F_locate_signature(file, H5AC_ind_dxpl_id)); done: /* Close the file */ if (file) if(H5FD_close(file)<0 && ret_value>=0) HDONE_ERROR(H5E_IO, H5E_CANTCLOSEFILE, FAIL, "unable to close file") FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5F_new * * Purpose: Creates a new file object and initializes it. The * H5Fopen and H5Fcreate functions then fill in various * fields. If SHARED is a non-null pointer then the shared info * to which it points has the reference count incremented. * Otherwise a new, empty shared info struct is created and * initialized with the specified file access property list. * * Errors: * * Return: Success: Ptr to a new file struct. * * Failure: NULL * * Programmer: Robb Matzke * matzke@llnl.gov * Jul 18 1997 * * Modifications: * * Raymond Lu, Oct 14, 2001 * Changed the file creation and access property list to the * new generic property list. * *------------------------------------------------------------------------- */ static H5F_t * H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id) { H5F_t *f=NULL, *ret_value; H5P_genplist_t *plist; /* Property list */ FUNC_ENTER_NOAPI_NOINIT(H5F_new) if (NULL==(f=H5FL_CALLOC(H5F_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") f->file_id = -1; if (shared) { f->shared = shared; } else { int n; f->shared = H5FL_CALLOC(H5F_file_t); f->shared->super_addr = HADDR_UNDEF; f->shared->base_addr = HADDR_UNDEF; f->shared->freespace_addr = HADDR_UNDEF; f->shared->driver_addr = HADDR_UNDEF; /* * Copy the file creation and file access property lists into the * new file handle. We do this early because some values might need * to change as the file is being opened. */ if(NULL == (plist = H5I_object(fcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not property list") f->shared->fcpl_id = H5P_copy_plist(plist); /* Get the FCPL values to cache */ if(H5P_get(plist, H5F_CRT_ADDR_BYTE_NUM_NAME, &f->shared->sizeof_addr)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get byte number for address") if(H5P_get(plist, H5F_CRT_OBJ_BYTE_NUM_NAME, &f->shared->sizeof_size)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get byte number for object size") if(H5P_get(plist, H5F_CRT_SYM_LEAF_NAME, &f->shared->sym_leaf_k)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get byte number for object size") if(H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, &f->shared->btree_k[0])<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "unable to get rank for btree internal nodes") /* Check for non-default indexed storage B-tree internal 'K' value * and increment the version # of the superblock if it is a non-default * value. */ if(f->shared->btree_k[H5B_ISTORE_ID]!=HDF5_BTREE_ISTORE_IK_DEF) { unsigned super_vers=HDF5_SUPERBLOCK_VERSION_MAX; /* Super block version */ H5P_genplist_t *c_plist; /* Property list */ if(NULL == (c_plist = H5I_object(f->shared->fcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not property list") if(H5P_set(c_plist, H5F_CRT_SUPER_VERS_NAME, &super_vers) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, NULL, "unable to set superblock version") } /* end if */ if(NULL == (plist = H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not file access property list") if(H5P_get(plist, H5F_ACS_META_CACHE_SIZE_NAME, &(f->shared->mdc_nelmts)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get meta data cache size") if(H5P_get(plist, H5F_ACS_DATA_CACHE_ELMT_SIZE_NAME, &(f->shared->rdcc_nelmts)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get data cache element size") if(H5P_get(plist, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, &(f->shared->rdcc_nbytes)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get data cache cache size") if(H5P_get(plist, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, &(f->shared->rdcc_w0)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get preempt read chunk") if(H5P_get(plist, H5F_ACS_ALIGN_THRHD_NAME, &(f->shared->threshold))<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get alignment threshold") if(H5P_get(plist, H5F_ACS_ALIGN_NAME, &(f->shared->alignment)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get alignment") if(H5P_get(plist, H5F_ACS_GARBG_COLCT_REF_NAME,&(f->shared->gc_ref))<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get garbage collect reference") if(H5P_get(plist, H5F_ACS_SIEVE_BUF_SIZE_NAME, &(f->shared->sieve_buf_size)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get sieve buffer size") /* * Create a meta data cache with the specified number of elements. * The cache might be created with a different number of elements and * the access property list should be updated to reflect that. */ if ((n=H5AC_create(f, f->shared->mdc_nelmts))<0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to create meta data cache") f->shared->mdc_nelmts = n; /* Create the file's "open object" information */ if(H5FO_create(f)<0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to create open object data structure") /* Add new "shared" struct to list of open files */ if(H5F_sfile_add(f->shared) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to append to list of open files") } /* end else */ f->shared->nrefs++; /* Create the file's "top open object" information */ if(H5FO_top_create(f)<0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to create open object data structure") /* Set return value */ ret_value = f; done: if (!ret_value && f) { if (!shared) H5FL_FREE(H5F_file_t,f->shared); H5FL_FREE(H5F_t,f); } FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5F_dest * * Purpose: Destroys a file structure. This function flushes the cache * but doesn't do any other cleanup other than freeing memory * for the file struct. The shared info for the file is freed * only when its reference count reaches zero. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Jul 18 1997 * * Modifications: * * Robb Matzke, 1998-10-14 * Nothing happens unless the reference count for the H5F_t goes to * zero. The reference counts are decremented here. * * Robb Matzke, 1999-02-19 * More careful about decrementing reference counts so they don't go * negative or wrap around to some huge value. Nothing happens if a * reference count is already zero. * * Robb Matzke, 2000-10-31 * H5FL_FREE() aborts if called with a null pointer (unlike the * original H5MM_free()). * * Pedro Vicente, 18 Sep 2002 * Added `id to name' support. * *------------------------------------------------------------------------- */ static herr_t H5F_dest(H5F_t *f, hid_t dxpl_id) { herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT(H5F_dest) /* Sanity check */ HDassert(f); if (1==f->shared->nrefs) { /* Remove shared file struct from list of open files */ if(H5F_sfile_remove(f->shared) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "problems closing file") /* * Do not close the root group since we didn't count it, but free * the memory associated with it. */ if (f->shared->root_grp) { /* Free the ID to name buffer */ if(H5G_free_grp_name(f->shared->root_grp)<0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "problems closing file") /* Free the memory for the root group */ if(H5G_free(f->shared->root_grp)<0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "problems closing file") f->shared->root_grp=NULL; } if (H5AC_dest(f, dxpl_id)) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "problems closing file") if (H5FO_dest(f)<0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "problems closing file") f->shared->cwfs = H5MM_xfree (f->shared->cwfs); if (H5G_node_close(f)<0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "problems closing file") /* Destroy file creation properties */ if(H5I_GENPROP_LST != H5I_get_type(f->shared->fcpl_id)) /* Push error, but keep going*/ HDONE_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a property list") if((ret_value=H5I_dec_ref(f->shared->fcpl_id)) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't close property list") /* Close low-level file */ if (H5FD_close(f->shared->lf)<0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "problems closing file") /* Destroy shared file struct */ f->shared = H5FL_FREE(H5F_file_t,f->shared); } else if (f->shared->nrefs>0) { /* * There are other references to the shared part of the file. * Only decrement the reference count. */ --f->shared->nrefs; } /* Free the non-shared part of the file */ f->name = H5MM_xfree(f->name); f->mtab.child = H5MM_xfree(f->mtab.child); f->mtab.nalloc = 0; if(H5FO_top_dest(f) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "problems closing file") H5FL_FREE(H5F_t,f); FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_dest() */ /*------------------------------------------------------------------------- * Function: H5F_open * * Purpose: Opens (or creates) a file. This function understands the * following flags which are similar in nature to the Posix * open(2) flags. * * H5F_ACC_RDWR: Open with read/write access. If the file is * currently open for read-only access then it * will be reopened. Absence of this flag * implies read-only access. * * H5F_ACC_CREAT: Create a new file if it doesn't exist yet. * The permissions are 0666 bit-wise AND with * the current umask. H5F_ACC_WRITE must also * be specified. * * H5F_ACC_EXCL: This flag causes H5F_open() to fail if the * file already exists. * * H5F_ACC_TRUNC: The file is truncated and a new HDF5 superblock * is written. This operation will fail if the * file is already open. * * Unlinking the file name from the group directed graph while * the file is opened causes the file to continue to exist but * one will not be able to upgrade the file from read-only * access to read-write access by reopening it. Disk resources * for the file are released when all handles to the file are * closed. NOTE: This paragraph probably only applies to Unix; * deleting the file name in other OS's has undefined results. * * The CREATE_PARMS argument is optional. A null pointer will * cause the default file creation parameters to be used. * * The ACCESS_PARMS argument is optional. A null pointer will * cause the default file access parameters to be used. * * Return: Success: A new file pointer. * * Failure: NULL * * Programmer: Robb Matzke * Tuesday, September 23, 1997 * * Modifications: * Albert Cheng, 1998-02-05 * Added the access_parms argument to pass down access template * information. * * Robb Matzke, 1998-02-18 * The H5F_access_t changed to allow more generality. The low * level driver is part of the file access template so the TYPE * argument has been removed. * * Robb Matzke, 1999-08-02 * Rewritten to use the virtual file layer. * * Robb Matzke, 1999-08-16 * Added decoding of file driver information block, which uses a * formerly reserved address slot in the boot block in order to * be compatible with previous versions of the file format. * * Robb Matzke, 1999-08-20 * Optimizations for opening a file. If the driver can't * determine when two file handles refer to the same file then * we open the file in one step. Otherwise if the first attempt * to open the file fails then we skip the second attempt if the * arguments would be the same. * * Raymond Lu, 2001-10-14 * Changed the file creation and access property lists to the * new generic property list. * * Bill Wendling, 2003-03-18 * Modified H5F_flush call to take one flag instead of * multiple Boolean flags. * *------------------------------------------------------------------------- */ static H5F_t * H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id) { H5F_t *file = NULL; /*the success return value */ H5F_file_t *shared = NULL; /*shared part of `file' */ H5FD_t *lf = NULL; /*file driver part of `shared' */ H5G_entry_t root_ent; /*root symbol table entry */ unsigned tent_flags; /*tentative flags */ H5FD_class_t *drvr; /*file driver class info */ hbool_t driver_has_cmp; /*`cmp' callback defined? */ H5P_genplist_t *a_plist; /*file access property list */ H5F_close_degree_t fc_degree; /*file close degree */ H5F_t *ret_value; /*actual return value */ FUNC_ENTER_NOAPI_NOINIT(H5F_open) /* * If the driver has a `cmp' method then the driver is capable of * determining when two file handles refer to the same file and the * library can insure that when the application opens a file twice * that the two handles coordinate their operations appropriately. * Otherwise it is the application's responsibility to never open the * same file more than once at a time. */ if((drvr=H5FD_get_class(fapl_id))==NULL) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "unable to retrieve VFL class") driver_has_cmp = (NULL!=drvr->cmp); /* * Opening a file is a two step process. First we try to open the * file in a way which doesn't affect its state (like not truncating * or creating it) so we can compare it with files that are already * open. If that fails then we try again with the full set of flags * (only if they're different than the original failed attempt). * However, if the file driver can't distinquish between files then * there's no reason to open the file tentatively because it's the * application's responsibility to prevent this situation (there's no * way for us to detect it here anyway). */ if (driver_has_cmp) { tent_flags = flags & ~(H5F_ACC_CREAT|H5F_ACC_TRUNC|H5F_ACC_EXCL); } else { tent_flags = flags; } if (NULL==(lf=H5FD_open(name, tent_flags, fapl_id, HADDR_UNDEF))) { if (tent_flags == flags) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file") H5E_clear(); tent_flags = flags; if (NULL==(lf=H5FD_open(name, tent_flags, fapl_id, HADDR_UNDEF))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file") } /* end if */ /* Is the file already open? */ if ((shared = H5F_sfile_search(lf)) != NULL) { /* * The file is already open, so use that one instead of the one we * just opened. We only one one H5FD_t* per file so one doesn't * confuse the other. But fail if this request was to truncate the * file (since we can't do that while the file is open), or if the * request was to create a non-existent file (since the file already * exists), or if the new request adds write access (since the * readers don't expect the file to change under them). */ if(H5FD_close(lf)<0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to close low-level file info") if (flags & H5F_ACC_TRUNC) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to truncate a file which is already open") if (flags & H5F_ACC_EXCL) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "file exists") if ((flags & H5F_ACC_RDWR) && 0 == (shared->flags & H5F_ACC_RDWR)) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "file is already open for read-only") /* Allocate new "high-level" file struct */ if ((file = H5F_new(shared, fcpl_id, fapl_id)) == NULL) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to create new file object") lf = file->shared->lf; } else if (flags!=tent_flags) { /* * This file is not yet open by the library and the flags we used to * open it are different than the desired flags. Close the tentative * file and open it for real. */ if(H5FD_close(lf)<0) { file = NULL; /*to prevent destruction of wrong file*/ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to close low-level file info") } /* end if */ if (NULL==(lf=H5FD_open(name, flags, fapl_id, HADDR_UNDEF))) { file = NULL; /*to prevent destruction of wrong file*/ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file") } if (NULL==(file = H5F_new(NULL, fcpl_id, fapl_id))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to create new file object") file->shared->flags = flags; file->shared->lf = lf; } else { /* * This file is not yet open by the library and our tentative opening * above is good enough. */ if (NULL==(file = H5F_new(NULL, fcpl_id, fapl_id))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to create new file object") file->shared->flags = flags; file->shared->lf = lf; } /* Short cuts */ shared = file->shared; lf = shared->lf; /* * The intent at the top level file struct are not necessarily the same as * the flags at the bottom. The top level describes how the file can be * accessed through the HDF5 library. The bottom level describes how the * file can be accessed through the C library. */ file->intent = flags; file->name = H5MM_xstrdup(name); /* * Read or write the file superblock, depending on whether the file is * empty or not. */ if (0==H5FD_get_eof(lf) && (flags & H5F_ACC_RDWR)) { /* * We've just opened a fresh new file (or truncated one). We need * to create & write the superblock. */ /* Initialize information about the superblock and allocate space for it */ if (H5F_init_superblock(file, dxpl_id)<0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to allocate file superblock") /* Create and open the root group */ if (H5G_mkroot(file, dxpl_id, NULL)<0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to create/open root group") /* Write the superblock to the file */ /* (This must be after the root group is created, since the root * group's symbol table entry is part of the superblock) */ if (H5F_write_superblock(file, dxpl_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to write file superblock") } else if (1 == shared->nrefs) { /* Read the superblock if it hasn't been read before. */ if (H5F_read_superblock(file, dxpl_id, &root_ent) < 0) HGOTO_ERROR(H5E_FILE, H5E_READERROR, NULL, "unable to read superblock") /* Make sure we can open the root group */ if (H5G_mkroot(file, dxpl_id, &root_ent)<0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to read root group") } /* * Decide the file close degree. If it's the first time to open the * file, set the degree to access property list value; if it's the * second time or later, verify the access property list value matches * the degree in shared file structure. */ if(NULL == (a_plist = H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not file access property list") if(H5P_get(a_plist, H5F_CLOSE_DEGREE_NAME, &fc_degree) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get file close degree") if(shared->nrefs == 1) { if(fc_degree == H5F_CLOSE_DEFAULT) shared->fc_degree = shared->lf->cls->fc_degree; else shared->fc_degree = fc_degree; } else if(shared->nrefs > 1) { if(fc_degree==H5F_CLOSE_DEFAULT && shared->fc_degree!=shared->lf->cls->fc_degree) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "file close degree doesn't match") if(fc_degree!=H5F_CLOSE_DEFAULT && fc_degree != shared->fc_degree) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "file close degree doesn't match") } /* Success */ ret_value = file; done: if (!ret_value && file) if(H5F_dest(file, dxpl_id)<0) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file") FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5Fcreate * * Purpose: This is the primary function for creating HDF5 files . The * flags parameter determines whether an existing file will be * overwritten or not. All newly created files are opened for * both reading and writing. All flags may be combined with the * bit-wise OR operator (`|') to change the behavior of the file * create call. * * The more complex behaviors of a file's creation and access * are controlled through the file-creation and file-access * property lists. The value of H5P_DEFAULT for a template * value indicates that the library should use the default * values for the appropriate template. * * See also: H5Fpublic.h for the list of supported flags. H5Ppublic.h for * the list of file creation and file access properties. * * Return: Success: A file ID * * Failure: FAIL * * Programmer: Unknown * * Modifications: * Robb Matzke, 1997-07-18 * File struct creation and destruction is through H5F_new() and * H5F_dest(). Writing the root symbol table entry is done with * H5G_encode(). * * Robb Matzke, 1997-08-29 * Moved creation of the boot block to H5F_flush(). * * Robb Matzke, 1997-09-23 * Most of the work is now done by H5F_open() since H5Fcreate() * and H5Fopen() originally contained almost identical code. * * Robb Matzke, 1998-02-18 * Better error checking for the creation and access property * lists. It used to be possible to swap the two and core the * library. Also, zero is no longer valid as a default property * list; one must use H5P_DEFAULT instead. * * Robb Matzke, 1999-08-02 * The file creation and file access property lists are passed * to the H5F_open() as object IDs. * * Raymond Lu, 2001-10-14 * Changed the file creation and access property list to the * new generic property list. * *------------------------------------------------------------------------- */ hid_t H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id) { H5F_t *new_file = NULL; /*file struct for new file */ hid_t ret_value; /*return value */ FUNC_ENTER_API(H5Fcreate, FAIL) H5TRACE4("i","sIuii",filename,flags,fcpl_id,fapl_id); /* Check/fix arguments */ if (!filename || !*filename) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file name") if (flags & ~(H5F_ACC_EXCL|H5F_ACC_TRUNC|H5F_ACC_DEBUG)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid flags") if ((flags & H5F_ACC_EXCL) && (flags & H5F_ACC_TRUNC)) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "mutually exclusive flags for file creation") /* Check file creation property list */ if(H5P_DEFAULT == fcpl_id) fcpl_id = H5P_FILE_CREATE_DEFAULT; else if(TRUE != H5P_isa_class(fcpl_id, H5P_FILE_CREATE)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not file create property list") /* Check the file access property list */ if(H5P_DEFAULT == fapl_id) fapl_id = H5P_FILE_ACCESS_DEFAULT; else if(TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not file access property list") /* * Adjust bit flags by turning on the creation bit and making sure that * the EXCL or TRUNC bit is set. All newly-created files are opened for * reading and writing. */ if (0==(flags & (H5F_ACC_EXCL|H5F_ACC_TRUNC))) flags |= H5F_ACC_EXCL; /*default*/ flags |= H5F_ACC_RDWR | H5F_ACC_CREAT; /* * Create a new file or truncate an existing file. */ if (NULL==(new_file=H5F_open(filename, flags, fcpl_id, fapl_id, H5AC_dxpl_id))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to create file") /* Get an atom for the file */ if ((ret_value = H5I_register(H5I_FILE, new_file))<0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file") /* Keep this ID in file object structure */ new_file->file_id = ret_value; done: if (ret_value<0 && new_file) if(H5F_close(new_file)<0) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "problems closing file") FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5Fopen * * Purpose: This is the primary function for accessing existing HDF5 * files. The FLAGS argument determines whether writing to an * existing file will be allowed or not. All flags may be * combined with the bit-wise OR operator (`|') to change the * behavior of the file open call. The more complex behaviors * of a file's access are controlled through the file-access * property list. * * See Also: H5Fpublic.h for a list of possible values for FLAGS. * * Return: Success: A file ID * * Failure: FAIL * * Programmer: Unknown * * Modifications: * Robb Matzke, 1997-07-18 * File struct creation and destruction is through H5F_new() and * H5F_dest(). Reading the root symbol table entry is done with * H5G_decode(). * * Robb Matzke, 1997-09-23 * Most of the work is now done by H5F_open() since H5Fcreate() * and H5Fopen() originally contained almost identical code. * * Robb Matzke, 1998-02-18 * Added better error checking for the flags and the file access * property list. It used to be possible to make the library * dump core by passing an object ID that was not a file access * property list. * * Robb Matzke, 1999-08-02 * The file access property list is passed to the H5F_open() as * object IDs. *------------------------------------------------------------------------- */ hid_t H5Fopen(const char *filename, unsigned flags, hid_t fapl_id) { H5F_t *new_file = NULL; /*file struct for new file */ hid_t ret_value; /*return value */ FUNC_ENTER_API(H5Fopen, FAIL) H5TRACE3("i","sIui",filename,flags,fapl_id); /* Check/fix arguments. */ if (!filename || !*filename) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file name") if ((flags & ~H5F_ACC_PUBLIC_FLAGS) || (flags & H5F_ACC_TRUNC) || (flags & H5F_ACC_EXCL)) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file open flags") if(H5P_DEFAULT == fapl_id) fapl_id = H5P_FILE_ACCESS_DEFAULT; else if(TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not file access property list") /* Open the file */ if (NULL==(new_file=H5F_open(filename, flags, H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to open file") /* Get an atom for the file */ if ((ret_value = H5I_register(H5I_FILE, new_file))<0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle") /* Keep this ID in file object structure */ new_file->file_id = ret_value; done: if (ret_value<0 && new_file) if(H5F_close(new_file)<0) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "problems closing file") FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5Fflush * * Purpose: Flushes all outstanding buffers of a file to disk but does * not remove them from the cache. The OBJECT_ID can be a file, * dataset, group, attribute, or named data type. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Thursday, August 6, 1998 * * Modifications: * Robb Matzke, 1998-10-16 * Added the `scope' argument. * * Bill Wendling, 2003-03-18 * Modified H5F_flush call to take one flag instead of * several Boolean flags. * *------------------------------------------------------------------------- */ herr_t H5Fflush(hid_t object_id, H5F_scope_t scope) { H5F_t *f = NULL; H5G_t *grp = NULL; H5T_t *type = NULL; H5D_t *dset = NULL; H5A_t *attr = NULL; H5G_entry_t *ent = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Fflush, FAIL) H5TRACE2("e","iFs",object_id,scope); switch (H5I_get_type(object_id)) { case H5I_FILE: if (NULL==(f=H5I_object(object_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") break; case H5I_GROUP: if (NULL==(grp=H5I_object(object_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid group identifier") ent = H5G_entof(grp); break; case H5I_DATATYPE: if (NULL==(type=H5I_object(object_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid type identifier") ent = H5T_entof(type); break; case H5I_DATASET: if (NULL==(dset=H5I_object(object_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier") ent = H5D_entof(dset); break; case H5I_ATTR: if (NULL==(attr=H5I_object(object_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid attribute identifier") ent = H5A_entof(attr); break; default: HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") } if (!f) { if (!ent) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "object is not assocated with a file") f = ent->file; } if (!f) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "object is not associated with a file") /* Flush the file */ if (H5F_flush(f, H5AC_dxpl_id, scope, H5F_FLUSH_NONE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "flush failed") done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5F_flush * * Purpose: Flushes (and optionally invalidates) cached data plus the * file super block. If the logical file size field is zero * then it is updated to be the length of the super block. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 29 1997 * * Modifications: * rky 1998-08-28 * Only p0 writes metadata to disk. * * Robb Matzke, 1998-10-16 * Added the `scope' argument to indicate what should be * flushed. If the value is H5F_SCOPE_GLOBAL then the entire * virtual file is flushed; a value of H5F_SCOPE_LOCAL means * that only the specified file is flushed. A value of * H5F_SCOPE_DOWN means flush the specified file and all * children. * * Robb Matzke, 1999-08-02 * If ALLOC_ONLY is non-zero then all this function does is * allocate space for the userblock and superblock. Also * rewritten to use the virtual file layer. * * Robb Matzke, 1999-08-16 * The driver information block is encoded and either allocated * or written to disk. * * Raymond Lu, 2001-10-14 * Changed to new generic property list. * * Quincey Koziol, 2002-05-20 * Added 'closing' parameter * * Quincey Koziol, 2002-06-05 * Added boot block & driver info block checksumming, to avoid * writing them out when they haven't changed. * * Quincey Koziol, 2002-06-06 * Return the remainders of the metadata & "small data" blocks to * the free list of blocks for the file. * * Bill Wendling, 2003-03-18 * Modified the flags being passed in to be one flag instead * of several. * *------------------------------------------------------------------------- */ static herr_t H5F_flush(H5F_t *f, hid_t dxpl_id, H5F_scope_t scope, unsigned flags) { unsigned nerrors = 0; /* Errors from nested flushes */ unsigned i; /* Index variable */ herr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5F_flush) /* Sanity check arguments */ assert(f); /* * Nothing to do if the file is read only. This determination is * made at the shared open(2) flags level, implying that opening a * file twice, once for read-only and once for read-write, and then * calling H5F_flush() with the read-only handle, still causes data * to be flushed. */ if (0 == (H5F_ACC_RDWR & f->shared->flags)) HGOTO_DONE(SUCCEED) /* Flush other stuff depending on scope */ if (H5F_SCOPE_GLOBAL == scope) { while (f->mtab.parent) f = f->mtab.parent; scope = H5F_SCOPE_DOWN; } if (H5F_SCOPE_DOWN == scope) for (i = 0; i < f->mtab.nmounts; i++) if (H5F_flush(f->mtab.child[i].file, dxpl_id, scope, flags) < 0) nerrors++; /* Flush any cached dataset storage raw data */ if (H5D_flush(f, dxpl_id, flags) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush dataset cache") /* flush (and invalidate) the entire meta data cache */ if (H5AC_flush(f, dxpl_id, flags & (H5F_FLUSH_INVALIDATE | H5F_FLUSH_CLEAR_ONLY)) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush meta data cache") /* * If we are invalidating everything (which only happens just before * the file closes), release the unused portion of the metadata and * "small data" blocks back to the free lists in the file. */ if (flags & H5F_FLUSH_INVALIDATE) { if (f->shared->lf->feature_flags & H5FD_FEAT_AGGREGATE_METADATA) { /* Return the unused portion of the metadata block to a free list */ if (f->shared->lf->eoma != 0) if (H5FD_free(f->shared->lf, H5FD_MEM_DEFAULT, dxpl_id, f->shared->lf->eoma, f->shared->lf->cur_meta_block_size) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "can't free metadata block") /* Reset metadata block information, just in case */ f->shared->lf->eoma=0; f->shared->lf->cur_meta_block_size=0; } /* end if */ if (f->shared->lf->feature_flags & H5FD_FEAT_AGGREGATE_SMALLDATA) { /* Return the unused portion of the "small data" block to a free list */ if (f->shared->lf->eosda != 0) if (H5FD_free(f->shared->lf, H5FD_MEM_DRAW, dxpl_id, f->shared->lf->eosda, f->shared->lf->cur_sdata_block_size) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "can't free 'small data' block") /* Reset "small data" block information, just in case */ f->shared->lf->eosda=0; f->shared->lf->cur_sdata_block_size=0; } /* end if */ } /* end if */ /* Write the superblock to disk */ if (H5F_write_superblock(f, dxpl_id) != SUCCEED) HGOTO_ERROR(H5E_CACHE, H5E_WRITEERROR, FAIL, "unable to write superblock to file") /* Flush file buffers to disk. */ if (H5FD_flush(f->shared->lf, dxpl_id, (unsigned)((flags & H5F_FLUSH_CLOSING) > 0)) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "low level flush failed") /* Check flush errors for children - errors are already on the stack */ ret_value = (nerrors ? FAIL : SUCCEED); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_flush() */ /*------------------------------------------------------------------------- * Function: H5F_close * * Purpose: Closes a file or causes the close operation to be pended. * This function is called two ways: from the API it gets called * by H5Fclose->H5I_dec_ref->H5F_close when H5I_dec_ref() * decrements the file ID reference count to zero. The file ID * is removed from the H5I_FILE group by H5I_dec_ref() just * before H5F_close() is called. If there are open object * headers then the close is pended by moving the file to the * H5I_FILE_CLOSING ID group (the f->closing contains the ID * assigned to file). * * This function is also called directly from H5O_close() when * the last object header is closed for the file and the file * has a pending close. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Tuesday, September 23, 1997 * * Modifications: * Robb Matzke, 1998-10-14 * Nothing happens unless the H5F_t reference count is one (the * file is flushed anyway). The reference count is decremented * by H5F_dest(). * * Robb Matzke, 1999-08-02 * Modified to use the virtual file layer. * * Bill Wendling, 2003-03-18 * Modified H5F_flush call to take one flag instead of * several Boolean flags. * *------------------------------------------------------------------------- */ static herr_t H5F_close(H5F_t *f) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5F_close) /* Sanity check */ HDassert(f); HDassert(f->file_id > 0); /* This routine should only be called when a file ID's ref count drops to zero */ /* Perform checks for "semi" file close degree here, since closing the * file is not allowed if there are objects still open */ if(f->shared->fc_degree == H5F_CLOSE_SEMI) { unsigned nopen_files = 0; /* Number of open files in file/mount hierarchy */ unsigned nopen_objs = 0; /* Number of open objects in file/mount hierarchy */ /* Get the number of open objects and open files on this file/mount hierarchy */ if(H5F_mount_count_ids(f, &nopen_files, &nopen_objs) < 0) HGOTO_ERROR(H5E_SYM, H5E_MOUNT, FAIL, "problem checking mount hierarchy") /* If there are no other file IDs open on this file/mount hier., but * there are still open objects, issue an error and bail out now, * without decrementing the file ID's reference count and triggering * a "real" attempt at closing the file */ if(nopen_files == 1 && nopen_objs > 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close file, there are objects still open") } /* end if */ /* Reset the file ID for this file */ f->file_id = -1; /* Attempt to close the file/mount hierarchy */ if(H5F_try_close(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close file") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_close() */ /*------------------------------------------------------------------------- * Function: H5F_try_close * * Purpose: Attempts to close a file due to one of several actions: * - The reference count on the file ID dropped to zero * - The last open object was closed in the file * - The file was unmounted * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Tuesday, July 19, 2005 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5F_try_close(H5F_t *f) { unsigned nopen_files = 0; /* Number of open files in file/mount hierarchy */ unsigned nopen_objs = 0; /* Number of open objects in file/mount hierarchy */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5F_try_close) /* Sanity check */ HDassert(f); /* Check if this file is already in the process of closing */ if(f->closing) HGOTO_DONE(SUCCEED) /* Get the number of open objects and open files on this file/mount hierarchy */ if(H5F_mount_count_ids(f, &nopen_files, &nopen_objs) < 0) HGOTO_ERROR(H5E_SYM, H5E_MOUNT, FAIL, "problem checking mount hierarchy") /* * Close file according to close degree: * * H5F_CLOSE_WEAK: if there are still objects open, wait until * they are all closed. * H5F_CLOSE_SEMI: if there are still objects open, return fail; * otherwise, close file. * H5F_CLOSE_STRONG: if there are still objects open, close them * first, then close file. */ switch(f->shared->fc_degree) { case H5F_CLOSE_WEAK: /* * If file or object IDS are still open then delay deletion of * resources until they have all been closed. Flush all * caches and update the object header anyway so that failing to * close all objects isn't a major problem. */ if ((nopen_files + nopen_objs) > 0) HGOTO_DONE(SUCCEED) break; case H5F_CLOSE_SEMI: /* Can leave safely if file IDs are still open on this file */ if (nopen_files > 0) HGOTO_DONE(SUCCEED) /* Sanity check: If close degree if "semi" and we have gotten this * far and there are objects left open, bail out now */ HDassert(nopen_files == 0 && nopen_objs == 0); /* If we've gotten this far (ie. there are no open objects in the file), fall through to flush & close */ break; case H5F_CLOSE_STRONG: /* If there are other open files in the hierarchy, we can leave now */ if(nopen_files > 0) HGOTO_DONE(SUCCEED) /* If we've gotten this far (ie. there are no open file IDs in the file/mount hierarchy), fall through to flush & close */ break; default: HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close file, unknown file close degree") } /* end switch */ /* Mark this file as closing (prevents re-entering file shutdown code below) */ f->closing = TRUE; /* If the file close degree is "strong", close all the open objects in this file */ if(f->shared->fc_degree == H5F_CLOSE_STRONG) { HDassert(nopen_files == 0); /* Forced close of all opened objects in this file */ if(f->nopen_objs > 0) { unsigned obj_count; /* # of open objects */ hid_t objs[128]; /* Array of objects to close */ unsigned u; /* Local index variable */ /* Get the list of IDs of open dataset, group, & attribute objects */ while((obj_count = H5F_get_obj_ids(f, H5F_OBJ_LOCAL|H5F_OBJ_DATASET|H5F_OBJ_GROUP|H5F_OBJ_ATTR, (int)(sizeof(objs)/sizeof(objs[0])), objs)) != 0) { /* Try to close all the open objects in this file */ for(u = 0; u < obj_count; u++) if(H5I_dec_ref(objs[u]) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CLOSEERROR, FAIL, "can't close object") } /* end while */ /* Get the list of IDs of open named datatype objects */ /* (Do this separately from the dataset & attribute IDs, because * they could be using one of the named datatypes and then the * open named datatype ID will get closed twice. */ while((obj_count = H5F_get_obj_ids(f, H5F_OBJ_LOCAL|H5F_OBJ_DATATYPE, (int)(sizeof(objs)/sizeof(objs[0])), objs)) != 0) { /* Try to close all the open objects in this file */ for(u = 0; u < obj_count; u++) if(H5I_dec_ref(objs[u]) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CLOSEERROR, FAIL, "can't close object") } /* end while */ } /* end if */ } /* end if */ /* Check if this is a child file in a mounting hierarchy & proceed up the * hierarchy if so. */ if(f->mtab.parent) if(H5F_try_close(f->mtab.parent) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close parent file") /* Unmount and close each child before closing the current file. */ if(H5F_close_mounts(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't unmount child files") #if H5AC_DUMP_STATS_ON_CLOSE /* Dump debugging info */ H5AC_stats(f); #endif /* H5AC_DUMP_STATS_ON_CLOSE */ /* Flush at this point since the file will be closed */ /* (Only try to flush the file if it was opened with write access) */ if(f->intent&H5F_ACC_RDWR) { /* Flush and destroy all caches */ if (H5F_flush(f, H5AC_dxpl_id, H5F_SCOPE_LOCAL, H5F_FLUSH_INVALIDATE | H5F_FLUSH_CLOSING) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache") } /* end if */ /* * Destroy the H5F_t struct and decrement the reference count for the * shared H5F_file_t struct. If the reference count for the H5F_file_t * struct reaches zero then destroy it also. */ if (H5F_dest(f, H5AC_dxpl_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "problems closing file") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_try_close() */ /*------------------------------------------------------------------------- * Function: H5Fclose * * Purpose: This function closes the file specified by FILE_ID by * flushing all data to storage, and terminating access to the * file through FILE_ID. If objects (e.g., datasets, groups, * etc.) are open in the file then the underlying storage is not * closed until those objects are closed; however, all data for * the file and the open objects is flushed. * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Saturday, February 20, 1999 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Fclose(hid_t file_id) { herr_t ret_value = SUCCEED; FUNC_ENTER_API(H5Fclose, FAIL) H5TRACE1("e","i",file_id); /* Check/fix arguments. */ if (H5I_FILE != H5I_get_type(file_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file ID") /* * Decrement reference count on atom. When it reaches zero the file will * be closed. */ if (H5I_dec_ref (file_id)<0) HGOTO_ERROR (H5E_ATOM, H5E_CANTCLOSEFILE, FAIL, "decrementing file ID failed") done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5Freopen * * Purpose: Reopen a file. The new file handle which is returned points * to the same file as the specified file handle. Both handles * share caches and other information. The only difference * between the handles is that the new handle is not mounted * anywhere and no files are mounted on it. * * Return: Success: New file ID * * Failure: FAIL * * Programmer: Robb Matzke * Friday, October 16, 1998 * * Modifications: * Quincey Koziol, May 14, 2002 * Keep old file's read/write intent in reopened file. * *------------------------------------------------------------------------- */ hid_t H5Freopen(hid_t file_id) { H5F_t *old_file=NULL; H5F_t *new_file=NULL; hid_t ret_value; FUNC_ENTER_API(H5Freopen, FAIL) H5TRACE1("i","i",file_id); if (NULL==(old_file=H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") /* Get a new "top level" file struct, sharing the same "low level" file struct */ if (NULL==(new_file=H5F_new(old_file->shared, H5P_FILE_CREATE_DEFAULT, H5P_FILE_ACCESS_DEFAULT))) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to reopen file") /* Keep old file's read/write intent in new file */ new_file->intent=old_file->intent; /* Duplicate old file's name */ new_file->name = H5MM_xstrdup(old_file->name); if ((ret_value=H5I_register(H5I_FILE, new_file))<0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle") /* Keep this ID in file object structure */ new_file->file_id = ret_value; done: if (ret_value<0 && new_file) if(H5F_dest(new_file, H5AC_dxpl_id)<0) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close file") FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5F_get_intent * * Purpose: Quick and dirty routine to retrieve the file's 'intent' flags * (Mainly added to stop non-file routines from poking about in the * H5F_t data structure) * * Return: 'intent' on success/abort on failure (shouldn't fail) * * Programmer: Quincey Koziol * September 29, 2000 * * Modifications: * *------------------------------------------------------------------------- */ unsigned H5F_get_intent(const H5F_t *f) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_get_intent) assert(f); FUNC_LEAVE_NOAPI(f->intent) } /*------------------------------------------------------------------------- * Function: H5F_sizeof_addr * * Purpose: Quick and dirty routine to retrieve the size of the file's size_t * (Mainly added to stop non-file routines from poking about in the * H5F_t data structure) * * Return: 'sizeof_addr' on success/abort on failure (shouldn't fail) * * Programmer: Quincey Koziol * September 29, 2000 * * Modifications: * * Raymond Lu, Oct 14, 2001 * Changed to generic property list. * *------------------------------------------------------------------------- */ size_t H5F_sizeof_addr(const H5F_t *f) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_sizeof_addr) assert(f); assert(f->shared); FUNC_LEAVE_NOAPI(f->shared->sizeof_addr) } /*------------------------------------------------------------------------- * Function: H5F_sizeof_size * * Purpose: Quick and dirty routine to retrieve the size of the file's off_t * (Mainly added to stop non-file routines from poking about in the * H5F_t data structure) * * Return: 'sizeof_size' on success/abort on failure (shouldn't fail) * * Programmer: Quincey Koziol * September 29, 2000 * * Modifications: * * Raymond Lu, Oct 14, 2001 * Changed to the new generic property list. * *------------------------------------------------------------------------- */ size_t H5F_sizeof_size(const H5F_t *f) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_sizeof_size) assert(f); assert(f->shared); FUNC_LEAVE_NOAPI(f->shared->sizeof_size) } /*------------------------------------------------------------------------- * Function: H5F_sym_leaf_k * * Purpose: Replaced a macro to retrieve the symbol table leaf size, * now that the generic properties are being used to store * the values. * * Return: Success: Non-negative, and the symbol table leaf size is * returned. * * Failure: Negative (should not happen) * * Programmer: Raymond Lu * slu@ncsa.uiuc.edu * Oct 14 2001 * * Modifications: * Quincey Koziol, 2001-10-15 * Added this header and removed unused ret_value variable. *------------------------------------------------------------------------- */ unsigned H5F_sym_leaf_k(const H5F_t *f) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_sym_leaf_k) assert(f); assert(f->shared); FUNC_LEAVE_NOAPI(f->shared->sym_leaf_k) } /*------------------------------------------------------------------------- * Function: H5F_Kvalue * * Purpose: Replaced a macro to retrieve a B-tree key value for a certain * type, now that the generic properties are being used to store * the B-tree values. * * Return: Success: Non-negative, and the B-tree key value is * returned. * * Failure: Negative (should not happen) * * Programmer: Raymond Lu * slu@ncsa.uiuc.edu * Oct 14 2001 * * Modifications: * Quincey Koziol, 2001-10-15 * Added this header and removed unused ret_value variable. *------------------------------------------------------------------------- */ unsigned H5F_Kvalue(const H5F_t *f, const H5B_class_t *type) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_Kvalue) assert(f); assert(f->shared); assert(type); FUNC_LEAVE_NOAPI(f->shared->btree_k[type->id]) } /* end H5F_Kvalue() */ /*------------------------------------------------------------------------- * Function: H5F_rdcc_nelmts * * Purpose: Replaced a macro to retrieve the raw data cache number of elments, * now that the generic properties are being used to store * the values. * * Return: Success: Non-negative, and the raw data cache number of * of elemnts is returned. * * Failure: Negative (should not happen) * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * Jun 1 2004 * * Modifications: * *------------------------------------------------------------------------- */ size_t H5F_rdcc_nelmts(const H5F_t *f) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_rdcc_nelmts) assert(f); assert(f->shared); FUNC_LEAVE_NOAPI(f->shared->rdcc_nelmts) } /* end H5F_rdcc_nelmts() */ /*------------------------------------------------------------------------- * Function: H5F_rdcc_nbytes * * Purpose: Replaced a macro to retrieve the raw data cache number of bytes, * now that the generic properties are being used to store * the values. * * Return: Success: Non-negative, and the raw data cache number of * of bytes is returned. * * Failure: Negative (should not happen) * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * Jun 1 2004 * * Modifications: * *------------------------------------------------------------------------- */ size_t H5F_rdcc_nbytes(const H5F_t *f) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_rdcc_nbytes) assert(f); assert(f->shared); FUNC_LEAVE_NOAPI(f->shared->rdcc_nbytes) } /* end H5F_rdcc_nbytes() */ /*------------------------------------------------------------------------- * Function: H5F_rdcc_w0 * * Purpose: Replaced a macro to retrieve the raw data cache 'w0' value * now that the generic properties are being used to store * the values. * * Return: Success: Non-negative, and the raw data cache 'w0' value * is returned. * * Failure: Negative (should not happen) * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * Jun 2 2004 * * Modifications: * *------------------------------------------------------------------------- */ double H5F_rdcc_w0(const H5F_t *f) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_rdcc_w0) assert(f); assert(f->shared); FUNC_LEAVE_NOAPI(f->shared->rdcc_w0) } /* end H5F_rdcc_w0() */ /*------------------------------------------------------------------------- * Function: H5F_has_feature * * Purpose: Check if a file has a particular feature enabled * * Return: Success: Non-negative - TRUE or FALSE * Failure: Negative (should not happen) * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * May 31 2004 * * Modifications: * *------------------------------------------------------------------------- */ hbool_t H5F_has_feature(const H5F_t *f, unsigned feature) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_has_feature) assert(f); assert(f->shared); FUNC_LEAVE_NOAPI((hbool_t)(f->shared->lf->feature_flags&feature)) } /* end H5F_has_feature() */ /*------------------------------------------------------------------------- * Function: H5F_get_driver_id * * Purpose: Quick and dirty routine to retrieve the file's 'driver_id' value * (Mainly added to stop non-file routines from poking about in the * H5F_t data structure) * * Return: 'driver_id' on success/abort on failure (shouldn't fail) * * Programmer: Quincey Koziol * October 10, 2000 * * Modifications: * *------------------------------------------------------------------------- */ hid_t H5F_get_driver_id(const H5F_t *f) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_get_driver_id) assert(f); assert(f->shared); assert(f->shared->lf); FUNC_LEAVE_NOAPI(f->shared->lf->driver_id) } /*------------------------------------------------------------------------- * Function: H5F_get_fileno * * Purpose: Quick and dirty routine to retrieve the file's 'fileno' value * (Mainly added to stop non-file routines from poking about in the * H5F_t data structure) * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * March 27, 2002 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5F_get_fileno(const H5F_t *f, unsigned long *filenum) { herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5F_get_fileno, FAIL) assert(f); assert(f->shared); assert(f->shared->lf); assert(filenum); /* Retrieve the file's serial number */ if(H5FD_get_fileno(f->shared->lf,filenum)<0) HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, FAIL, "can't retrieve fileno") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_get_fileno() */ /*------------------------------------------------------------------------- * Function: H5F_get_id * * Purpose: Get the file ID, incrementing it, or "resurrecting" it as * appropriate. * * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu * Oct 29, 2003 * * Modifications: *------------------------------------------------------------------------- */ hid_t H5F_get_id(H5F_t *file) { hid_t ret_value; FUNC_ENTER_NOAPI_NOINIT(H5F_get_id) assert(file); if(file->file_id == -1) { /* Get an atom for the file */ if ((file->file_id = H5I_register(H5I_FILE, file))<0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file") } else { /* Increment reference count on atom. */ if (H5I_inc_ref(file->file_id)<0) HGOTO_ERROR (H5E_ATOM, H5E_CANTSET, FAIL, "incrementing file ID failed") } ret_value = file->file_id; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_get_id() */ /*------------------------------------------------------------------------- * Function: H5F_get_base_addr * * Purpose: Quick and dirty routine to retrieve the file's 'base_addr' value * (Mainly added to stop non-file routines from poking about in the * H5F_t data structure) * * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu * December 20, 2002 * * Modifications: * *------------------------------------------------------------------------- */ haddr_t H5F_get_base_addr(const H5F_t *f) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_get_base_addr) assert(f); assert(f->shared); FUNC_LEAVE_NOAPI(f->shared->base_addr) } /* end H5F_get_base_addr() */ /*------------------------------------------------------------------------- * Function: H5F_get_eoa * * Purpose: Quick and dirty routine to retrieve the file's 'eoa' value * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * June 1, 2004 * * Modifications: * *------------------------------------------------------------------------- */ haddr_t H5F_get_eoa(const H5F_t *f) { haddr_t ret_value; FUNC_ENTER_NOAPI(H5F_get_eoa, HADDR_UNDEF) assert(f); assert(f->shared); /* Dispatch to driver */ if (HADDR_UNDEF==(ret_value=H5FD_get_eoa(f->shared->lf))) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "driver get_eoa request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_get_eoa() */ #ifdef H5_HAVE_PARALLEL /*------------------------------------------------------------------------- * Function: H5F_mpi_get_rank * * Purpose: Retrieves the rank of an MPI process. * * Return: Success: The rank (non-negative) * * Failure: Negative * * Programmer: Quincey Koziol * Friday, January 30, 2004 * * Modifications: * *------------------------------------------------------------------------- */ int H5F_mpi_get_rank(const H5F_t *f) { int ret_value; FUNC_ENTER_NOAPI(H5F_mpi_get_rank, FAIL) assert(f && f->shared); /* Dispatch to driver */ if ((ret_value=H5FD_mpi_get_rank(f->shared->lf))<0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "driver get_rank request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_mpi_get_rank() */ /*------------------------------------------------------------------------- * Function: H5F_mpi_get_comm * * Purpose: Retrieves the file's communicator * * Return: Success: The communicator (non-negative) * * Failure: Negative * * Programmer: Quincey Koziol * Friday, January 30, 2004 * * Modifications: * *------------------------------------------------------------------------- */ MPI_Comm H5F_mpi_get_comm(const H5F_t *f) { MPI_Comm ret_value; FUNC_ENTER_NOAPI(H5F_mpi_get_comm, MPI_COMM_NULL) assert(f && f->shared); /* Dispatch to driver */ if ((ret_value=H5FD_mpi_get_comm(f->shared->lf))==MPI_COMM_NULL) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, MPI_COMM_NULL, "driver get_comm request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_mpi_get_comm() */ #endif /* H5_HAVE_PARALLEL */ /*------------------------------------------------------------------------- * Function: H5F_grp_btree_shared * * Purpose: Replaced a macro to retrieve the shared B-tree node info * now that the generic properties are being used to store * the values. * * Return: Success: Non-void, and the shared B-tree node info * is returned. * * Failure: void (should not happen) * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * Jul 5 2004 * * Modifications: * *------------------------------------------------------------------------- */ H5RC_t * H5F_grp_btree_shared(const H5F_t *f) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_grp_btree_shared) assert(f); assert(f->shared); FUNC_LEAVE_NOAPI(f->shared->grp_btree_shared) } /* end H5F_grp_btree_shared() */ /*------------------------------------------------------------------------- * Function: H5F_sieve_buf_size * * Purpose: Replaced a macro to retrieve the dataset sieve buffer size * now that the generic properties are being used to store * the values. * * Return: Success: Non-void, and the dataset sieve buffer size * is returned. * * Failure: void (should not happen) * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * Jul 8 2005 * * Modifications: * *------------------------------------------------------------------------- */ size_t H5F_sieve_buf_size(const H5F_t *f) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_sieve_buf_size) assert(f); assert(f->shared); FUNC_LEAVE_NOAPI(f->shared->sieve_buf_size) } /* end H5F_sieve_buf_size() */ /*------------------------------------------------------------------------- * Function: H5F_block_read * * Purpose: Reads some data from a file/server/etc into a buffer. * The data is contiguous. The address is relative to the base * address for the file. * * Errors: * IO READERROR Low-level read failed. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Jul 10 1997 * * Modifications: * Albert Cheng, 1998-06-02 * Added XFER_MODE argument * * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. * * Robb Matzke, 1999-08-02 * Modified to use the virtual file layer. The data transfer * property list is passed in by object ID since that's how the * virtual file layer needs it. *------------------------------------------------------------------------- */ herr_t H5F_block_read(const H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, hid_t dxpl_id, void *buf/*out*/) { haddr_t abs_addr; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5F_block_read, FAIL) assert (f); assert (f->shared); assert(sizeshared->base_addr + addr; /* Read the data */ if (H5FD_read(f->shared->lf, type, dxpl_id, abs_addr, size, buf)<0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed") done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5F_block_write * * Purpose: Writes some data from memory to a file/server/etc. The * data is contiguous. The address is relative to the base * address. * * Errors: * IO WRITEERROR Low-level write failed. * IO WRITEERROR No write intent. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Jul 10 1997 * * Modifications: * Albert Cheng, 1998-06-02 * Added XFER_MODE argument * * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. * * Robb Matzke, 1999-08-02 * Modified to use the virtual file layer. The data transfer * property list is passed in by object ID since that's how the * virtual file layer needs it. *------------------------------------------------------------------------- */ herr_t H5F_block_write(const H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, hid_t dxpl_id, const void *buf) { haddr_t abs_addr; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5F_block_write, FAIL) assert (f); assert (f->shared); assert (sizeintent & H5F_ACC_RDWR)) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "no write intent") /* Convert the relative address to an absolute address */ abs_addr = f->shared->base_addr + addr; /* Write the data */ if (H5FD_write(f->shared->lf, type, dxpl_id, abs_addr, size, buf)) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5F_addr_encode * * Purpose: Encodes an address into the buffer pointed to by *PP and * then increments the pointer to the first byte after the * address. An undefined value is stored as all 1's. * * Return: void * * Programmer: Robb Matzke * Friday, November 7, 1997 * * Modifications: * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. *------------------------------------------------------------------------- */ void H5F_addr_encode(const H5F_t *f, uint8_t **pp/*in,out*/, haddr_t addr) { unsigned i; assert(f); assert(pp && *pp); if (H5F_addr_defined(addr)) { for (i=0; i>= 8; } assert("overflow" && 0 == addr); } else { for (i=0; ioffset and how it is being called. *------------------------------------------------------------------------- */ herr_t H5F_addr_pack(H5F_t UNUSED *f, haddr_t *addr_p/*out*/, const unsigned long objno[2]) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_addr_pack) assert(f); assert(objno); assert(addr_p); *addr_p = objno[0]; #if H5_SIZEOF_LONGshared->lf))<0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to check free space for file") done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_freespace() */ /*------------------------------------------------------------------------- * Function: H5Fget_filesize * * Purpose: Retrieves the file size of the HDF5 file. This function * is called after an existing file is opened in order * to learn the true size of the underlying file. * * Return: Success: Non-negative * Failure: Negative * * Programmer: David Pitt * david.pitt@bigpond.com * Apr 27, 2004 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Fget_filesize(hid_t file_id, hsize_t *size) { H5F_t *file=NULL; /* File object for file ID */ herr_t ret_value = SUCCEED; /* Return value */ haddr_t eof; FUNC_ENTER_API(H5Fget_filesize, FAIL) H5TRACE2("e","i*h",file_id,size); /* Check args */ if(NULL==(file=H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") /* Go get the actual file size */ if((eof = H5FDget_eof(file->shared->lf))==HADDR_UNDEF) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file size") *size = (hsize_t)eof; done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_filesize() */ /*------------------------------------------------------------------------- * Function: H5Fget_name * * Purpose: Gets the name of the file to which object OBJ_ID belongs. * If `name' is non-NULL then write up to `size' bytes into that * buffer and always return the length of the entry name. * Otherwise `size' is ignored and the function does not store the name, * just returning the number of characters required to store the name. * If an error occurs then the buffer pointed to by `name' (NULL or non-NULL) * is unchanged and the function returns a negative value. * * Return: Success: The length of the file name * Failure: Negative * * Programmer: Raymond Lu * June 29, 2004 * * Modifications: * *------------------------------------------------------------------------- */ ssize_t H5Fget_name(hid_t obj_id, char *name/*out*/, size_t size) { H5G_entry_t *ent; /*symbol table entry */ H5F_t *f; /* Top file in mount hierarchy */ size_t len=0; ssize_t ret_value; FUNC_ENTER_API (H5Fget_name, FAIL) H5TRACE3("Zs","ixz",obj_id,name,size); /* For file IDs, get the file object directly */ /* (This prevents the H5G_loc() call from returning the file pointer for * the top file in a mount hierarchy) */ if(H5I_get_type(obj_id) == H5I_FILE ) { if (NULL==(f=H5I_object(obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") } /* end if */ else { /* Get symbol table entry */ if((ent = H5G_loc(obj_id))==NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid object ID") f = ent->file; } /* end else */ len = HDstrlen(f->name); if(name) { HDstrncpy(name, f->name, MIN(len+1,size)); if(len >= size) name[size-1]='\0'; } /* end if */ /* Set return value */ ret_value=(ssize_t)len; done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_name() */ xdmf-3.0+git20160803/Utilities/hdf5/H5Oattr.c0000640000175000017500000005674213003006557020343 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #define H5A_PACKAGE /*prevent warning from including H5Apkg */ #define H5O_PACKAGE /*suppress error about including H5Opkg */ #define H5S_PACKAGE /*suppress error about including H5Spkg */ #include "H5private.h" /* Generic Functions */ #include "H5Apkg.h" /* Attributes */ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free Lists */ #include "H5Gprivate.h" /* Groups */ #include "H5MMprivate.h" /* Memory management */ #include "H5Opkg.h" /* Object headers */ #include "H5Spkg.h" /* Dataspaces */ /* PRIVATE PROTOTYPES */ static herr_t H5O_attr_encode (H5F_t *f, uint8_t *p, const void *mesg); static void *H5O_attr_decode (H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t *sh); static void *H5O_attr_copy (const void *_mesg, void *_dest, unsigned update_flags); static size_t H5O_attr_size (const H5F_t *f, const void *_mesg); static herr_t H5O_attr_reset (void *_mesg); static herr_t H5O_attr_free (void *mesg); static herr_t H5O_attr_delete (H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link); static herr_t H5O_attr_link(H5F_t *f, hid_t dxpl_id, const void *_mesg); static herr_t H5O_attr_debug (H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * stream, int indent, int fwidth); /* This message derives from H5O */ const H5O_class_t H5O_ATTR[1] = {{ H5O_ATTR_ID, /* message id number */ "attribute", /* message name for debugging */ sizeof(H5A_t), /* native message size */ H5O_attr_decode, /* decode message */ H5O_attr_encode, /* encode message */ H5O_attr_copy, /* copy the native value */ H5O_attr_size, /* size of raw message */ H5O_attr_reset, /* reset method */ H5O_attr_free, /* free method */ H5O_attr_delete, /* file delete method */ H5O_attr_link, /* link method */ NULL, /* get share method */ NULL, /* set share method */ H5O_attr_debug, /* debug the message */ }}; /* This is the initial version, which does not have support for shared datatypes */ #define H5O_ATTR_VERSION 1 /* This version allows support for shared datatypes */ #define H5O_ATTR_VERSION_NEW 2 /* Flags for attribute flag encoding */ #define H5O_ATTR_FLAG_TYPE_SHARED 0x01 /* Declare extern the free list for H5A_t's */ H5FL_EXTERN(H5A_t); /* Declare extern the free list for attribute data buffers */ H5FL_BLK_EXTERN(attr_buf); /* Declare external the free list for H5S_t's */ H5FL_EXTERN(H5S_t); /* Declare external the free list for H5S_extent_t's */ H5FL_EXTERN(H5S_extent_t); /*-------------------------------------------------------------------------- NAME H5O_attr_decode PURPOSE Decode a attribute message and return a pointer to a memory struct with the decoded information USAGE void *H5O_attr_decode(f, raw_size, p) H5F_t *f; IN: pointer to the HDF5 file struct size_t raw_size; IN: size of the raw information buffer const uint8_t *p; IN: the raw information buffer RETURNS Pointer to the new message in native order on success, NULL on failure DESCRIPTION This function decodes the "raw" disk form of a attribute message into a struct in memory native format. The struct is allocated within this function using malloc() and is returned to the caller. * * Modifications: * Robb Matzke, 17 Jul 1998 * Added padding for alignment. * * Robb Matzke, 20 Jul 1998 * Added a version number at the beginning. * * Raymond Lu, 8 April 2004 * Changed Dataspace operation on H5S_simple_t to H5S_extent_t. * --------------------------------------------------------------------------*/ static void * H5O_attr_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t UNUSED *sh) { H5A_t *attr = NULL; H5S_extent_t *extent; /*extent dimensionality information */ size_t name_len; /*attribute name length */ int version; /*message version number*/ unsigned flags=0; /* Attribute flags */ H5A_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_attr_decode); /* check args */ assert(f); assert(p); if (NULL==(attr = H5FL_CALLOC(H5A_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); /* Version number */ version = *p++; if (version!=H5O_ATTR_VERSION && version!=H5O_ATTR_VERSION_NEW) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for attribute message"); /* Get the flags byte if we have a later version of the attribute */ if(version>H5O_ATTR_VERSION) flags = *p++; else p++; /* Byte is unused when version<2 */ /* * Decode the sizes of the parts of the attribute. The sizes stored in * the file are exact but the parts are aligned on 8-byte boundaries. */ UINT16DECODE(p, name_len); /*including null*/ UINT16DECODE(p, attr->dt_size); UINT16DECODE(p, attr->ds_size); /* Decode and store the name */ if (NULL==(attr->name=H5MM_strdup((const char *)p))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); if(version < H5O_ATTR_VERSION_NEW) p += H5O_ALIGN(name_len); /* advance the memory pointer */ else p += name_len; /* advance the memory pointer */ /* decode the attribute datatype */ if (flags & H5O_ATTR_FLAG_TYPE_SHARED) { H5O_shared_t *shared; /* Shared information */ /* Get the shared information */ if (NULL == (shared = (H5O_SHARED->decode) (f, dxpl_id, p, NULL))) HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, NULL, "unable to decode shared message"); /* Get the actual datatype information */ if((attr->dt= H5O_shared_read(f, dxpl_id, shared, H5O_DTYPE, NULL))==NULL) HGOTO_ERROR(H5E_ATTR, H5E_CANTDECODE, NULL, "can't decode attribute datatype"); /* Free the shared information */ H5O_free_real(H5O_SHARED, shared); } /* end if */ else { if((attr->dt=(H5O_DTYPE->decode)(f,dxpl_id,p,NULL))==NULL) HGOTO_ERROR(H5E_ATTR, H5E_CANTDECODE, NULL, "can't decode attribute datatype"); } /* end else */ if(version < H5O_ATTR_VERSION_NEW) p += H5O_ALIGN(attr->dt_size); else p += attr->dt_size; /* decode the attribute dataspace */ if (NULL==(attr->ds = H5FL_CALLOC(H5S_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); if((extent=(H5O_SDSPACE->decode)(f,dxpl_id,p,NULL))==NULL) HGOTO_ERROR(H5E_ATTR, H5E_CANTDECODE, NULL, "can't decode attribute dataspace"); /* Copy the extent information */ HDmemcpy(&(attr->ds->extent),extent, sizeof(H5S_extent_t)); /* Release temporary extent information */ H5FL_FREE(H5S_extent_t,extent); /* Default to entire dataspace being selected */ if(H5S_select_all(attr->ds,0)<0) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTSET, NULL, "unable to set all selection"); if(version < H5O_ATTR_VERSION_NEW) p += H5O_ALIGN(attr->ds_size); else p += attr->ds_size; /* Compute the size of the data */ H5_ASSIGN_OVERFLOW(attr->data_size,H5S_GET_EXTENT_NPOINTS(attr->ds)*H5T_get_size(attr->dt),hsize_t,size_t); /* Go get the data */ if(attr->data_size) { if (NULL==(attr->data = H5FL_BLK_MALLOC(attr_buf, attr->data_size))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); HDmemcpy(attr->data,p,attr->data_size); } /* Indicate that the fill values aren't to be written out */ attr->initialized=1; /* Set return value */ ret_value=attr; done: FUNC_LEAVE_NOAPI(ret_value); } /*-------------------------------------------------------------------------- NAME H5O_attr_encode PURPOSE Encode a simple attribute message USAGE herr_t H5O_attr_encode(f, raw_size, p, mesg) H5F_t *f; IN: pointer to the HDF5 file struct const uint8 *p; IN: the raw information buffer const void *mesg; IN: Pointer to the simple datatype struct RETURNS Non-negative on success/Negative on failure DESCRIPTION This function encodes the native memory form of the attribute message in the "raw" disk form. * * Modifications: * Robb Matzke, 17 Jul 1998 * Added padding for alignment. * * Robb Matzke, 20 Jul 1998 * Added a version number at the beginning. * * Raymond Lu, 8 April 2004 * For data space, changed the operation on H5S_simple_t to * H5S_extent_t * --------------------------------------------------------------------------*/ static herr_t H5O_attr_encode(H5F_t *f, uint8_t *p, const void *mesg) { const H5A_t *attr = (const H5A_t *) mesg; size_t name_len; /* Attribute name length */ unsigned version; /* Attribute version */ hbool_t type_shared; /* Flag to indicate that a shared datatype is used for this attribute */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_attr_encode); /* check args */ assert(f); assert(p); assert(attr); /* Check whether datatype is shared */ if(H5T_committed(attr->dt)) type_shared = TRUE; else type_shared = FALSE; /* Check which version to write out */ if(type_shared) version = H5O_ATTR_VERSION_NEW; /* Write out new version if shared datatype */ else version = H5O_ATTR_VERSION; /* Encode Version */ *p++ = version; /* Set attribute flags if version >1 */ if(version>H5O_ATTR_VERSION) *p++ = (type_shared ? H5O_ATTR_FLAG_TYPE_SHARED : 0 ); /* Set flags for attribute */ else *p++ = 0; /* Reserved, for version <2 */ /* * Encode the lengths of the various parts of the attribute message. The * encoded lengths are exact but we pad each part except the data to be a * multiple of eight bytes (in the first version). */ name_len = HDstrlen(attr->name)+1; UINT16ENCODE(p, name_len); UINT16ENCODE(p, attr->dt_size); UINT16ENCODE(p, attr->ds_size); /* * Write the name including null terminator padded to the correct number * of bytes. */ HDmemcpy(p, attr->name, name_len); HDmemset(p+name_len, 0, H5O_ALIGN(name_len)-name_len); if(version < H5O_ATTR_VERSION_NEW) p += H5O_ALIGN(name_len); else p += name_len; /* encode the attribute datatype */ if(type_shared) { H5O_shared_t sh_mesg; /* Reset shared message information */ HDmemset(&sh_mesg,0,sizeof(H5O_shared_t)); /* Get shared message information from datatype */ if ((H5O_DTYPE->get_share)(f, attr->dt, &sh_mesg/*out*/)<0) HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "can't encode shared attribute datatype"); /* Encode shared message information for datatype */ if((H5O_SHARED->encode)(f,p,&sh_mesg)<0) HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "can't encode shared attribute datatype"); } /* end if */ else { /* Encode datatype information */ if((H5O_DTYPE->encode)(f,p,attr->dt)<0) HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "can't encode attribute datatype"); } /* end else */ if(version < H5O_ATTR_VERSION_NEW) { HDmemset(p+attr->dt_size, 0, H5O_ALIGN(attr->dt_size)-attr->dt_size); p += H5O_ALIGN(attr->dt_size); } /* end if */ else p += attr->dt_size; /* encode the attribute dataspace */ if((H5O_SDSPACE->encode)(f,p,&(attr->ds->extent))<0) HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "can't encode attribute dataspace"); if(version < H5O_ATTR_VERSION_NEW) { HDmemset(p+attr->ds_size, 0, H5O_ALIGN(attr->ds_size)-attr->ds_size); p += H5O_ALIGN(attr->ds_size); } /* end if */ else p += attr->ds_size; /* Store attribute data */ if(attr->data) HDmemcpy(p,attr->data,attr->data_size); else HDmemset(p,0,attr->data_size); done: FUNC_LEAVE_NOAPI(ret_value); } /*-------------------------------------------------------------------------- NAME H5O_attr_copy PURPOSE Copies a message from MESG to DEST, allocating DEST if necessary. USAGE void *H5O_attr_copy(mesg, dest) const void *mesg; IN: Pointer to the source attribute struct const void *dest; IN: Pointer to the destination attribute struct RETURNS Pointer to DEST on success, NULL on failure DESCRIPTION This function copies a native (memory) attribute message, allocating the destination structure if necessary. --------------------------------------------------------------------------*/ static void * H5O_attr_copy(const void *_src, void *_dst, unsigned update_flags) { const H5A_t *src = (const H5A_t *) _src; void *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_attr_copy); /* check args */ assert(src); /* copy */ if (NULL == (ret_value = H5A_copy(_dst,src,update_flags))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "can't copy attribute"); done: FUNC_LEAVE_NOAPI(ret_value); } /*-------------------------------------------------------------------------- NAME H5O_attr_size PURPOSE Return the raw message size in bytes USAGE size_t H5O_attr_size(f, mesg) H5F_t *f; IN: pointer to the HDF5 file struct const void *mesg; IN: Pointer to the source attribute struct RETURNS Size of message on success, 0 on failure DESCRIPTION This function returns the size of the raw attribute message on success. (Not counting the message type or size fields, only the data portion of the message). It doesn't take into account alignment. * * Modified: * Robb Matzke, 17 Jul 1998 * Added padding between message parts for alignment. --------------------------------------------------------------------------*/ static size_t H5O_attr_size(const H5F_t UNUSED *f, const void *_mesg) { const H5A_t *attr = (const H5A_t *)_mesg; size_t name_len; unsigned version; /* Attribute version */ hbool_t type_shared; /* Flag to indicate that a shared datatype is used for this attribute */ size_t ret_value = 0; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_attr_size); assert(attr); name_len = HDstrlen(attr->name)+1; /* Check whether datatype is shared */ if(H5T_committed(attr->dt)) type_shared = TRUE; else type_shared = FALSE; /* Check which version to write out */ if(type_shared) version = H5O_ATTR_VERSION_NEW; /* Write out new version if shared datatype */ else version = H5O_ATTR_VERSION; if(version < H5O_ATTR_VERSION_NEW) ret_value = 1 + /*version */ 1 + /*reserved */ 2 + /*name size inc. null */ 2 + /*type size */ 2 + /*space size */ H5O_ALIGN(name_len) + /*attribute name */ H5O_ALIGN(attr->dt_size) + /*data type */ H5O_ALIGN(attr->ds_size) + /*data space */ attr->data_size; /*the data itself */ else ret_value = 1 + /*version */ 1 + /*flags */ 2 + /*name size inc. null */ 2 + /*type size */ 2 + /*space size */ name_len + /*attribute name */ attr->dt_size + /*data type */ attr->ds_size + /*data space */ attr->data_size; /*the data itself */ FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_attr_reset * * Purpose: Frees resources within a attribute message, but doesn't free * the message itself. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Tuesday, December 9, 1997 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_attr_reset(void *_mesg) { H5A_t *attr = (H5A_t *) _mesg; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_attr_reset); if (attr) H5A_free(attr); FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_attr_free * * Purpose: Free's the message * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Thursday, November 18, 2004 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_attr_free (void *mesg) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_attr_free); assert (mesg); H5FL_FREE(H5A_t,mesg); FUNC_LEAVE_NOAPI(SUCCEED); } /* end H5O_attr_free() */ /*------------------------------------------------------------------------- * Function: H5O_attr_delete * * Purpose: Free file space referenced by message * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Friday, September 26, 2003 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_attr_delete(H5F_t UNUSED *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link) { const H5A_t *attr = (const H5A_t *) _mesg; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_attr_delete); /* check args */ assert(f); assert(attr); /* Check whether datatype is shared */ if(H5T_committed(attr->dt)) { /* Decrement the reference count on the shared datatype, if requested */ if(adj_link) if(H5T_link(attr->dt, -1, dxpl_id)<0) HGOTO_ERROR (H5E_OHDR, H5E_LINK, FAIL, "unable to adjust shared datatype link count") } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5O_attr_delete() */ /*------------------------------------------------------------------------- * Function: H5O_attr_link * * Purpose: Increment reference count on any objects referenced by * message * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Friday, September 26, 2003 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_attr_link(H5F_t UNUSED *f, hid_t dxpl_id, const void *_mesg) { const H5A_t *attr = (const H5A_t *) _mesg; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_attr_link); /* check args */ assert(f); assert(attr); /* Check whether datatype is shared */ if(H5T_committed(attr->dt)) { /* Increment the reference count on the shared datatype */ if(H5T_link(attr->dt,1,dxpl_id)<0) HGOTO_ERROR (H5E_OHDR, H5E_LINK, FAIL, "unable to adjust shared datatype link count"); } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5O_attr_link() */ /*-------------------------------------------------------------------------- NAME H5O_attr_debug PURPOSE Prints debugging information for an attribute message USAGE void *H5O_attr_debug(f, mesg, stream, indent, fwidth) H5F_t *f; IN: pointer to the HDF5 file struct const void *mesg; IN: Pointer to the source attribute struct FILE *stream; IN: Pointer to the stream for output data int indent; IN: Amount to indent information by int fwidth; IN: Field width (?) RETURNS Non-negative on success/Negative on failure DESCRIPTION This function prints debugging output to the stream passed as a parameter. --------------------------------------------------------------------------*/ static herr_t H5O_attr_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * stream, int indent, int fwidth) { const H5A_t *mesg = (const H5A_t *)_mesg; H5O_shared_t sh_mesg; /* Shared message information */ void *dt_mesg; /* Pointer to datatype message to dump */ herr_t (*debug)(H5F_t*, hid_t, const void*, FILE*, int, int)=NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_attr_debug); /* check args */ assert(f); assert(stream); assert(indent >= 0); assert(fwidth >= 0); fprintf(stream, "%*s%-*s \"%s\"\n", indent, "", fwidth, "Name:", mesg->name); fprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Initialized:", (unsigned int)mesg->initialized); fprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Opened:", (unsigned int)mesg->ent_opened); fprintf(stream, "%*sSymbol table entry...\n", indent, ""); H5G_ent_debug(f, dxpl_id, &(mesg->ent), stream, indent+3, MAX(0, fwidth-3), HADDR_UNDEF); fprintf(stream, "%*sData type...\n", indent, ""); fprintf(stream, "%*s%-*s %lu\n", indent+3, "", MAX(0,fwidth-3), "Size:", (unsigned long)(mesg->dt_size)); fprintf (stream, "%*s%-*s %s\n", indent+3, "", MAX(0,fwidth-3), "Shared:", (H5T_committed(mesg->dt) ? "Yes" : "No") ); if(H5T_committed(mesg->dt)) { /* Reset shared message information */ HDmemset(&sh_mesg,0,sizeof(H5O_shared_t)); /* Get shared message information from datatype */ if ((H5O_DTYPE->get_share)(f, mesg->dt, &sh_mesg/*out*/)<0) HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "can't retrieve shared message information"); debug=H5O_SHARED->debug; dt_mesg=&sh_mesg; } /* end if */ else { debug=H5O_DTYPE->debug; dt_mesg=mesg->dt; } /* end else */ if(debug) (debug)(f, dxpl_id, dt_mesg, stream, indent+3, MAX(0, fwidth-3)); else fprintf(stream, "%*s\n", indent + 6, ""); fprintf(stream, "%*sData space...\n", indent, ""); fprintf(stream, "%*s%-*s %lu\n", indent+3, "", MAX(0,fwidth-3), "Size:", (unsigned long)(mesg->ds_size)); H5S_debug(f, dxpl_id, mesg->ds, stream, indent+3, MAX(0, fwidth-3)); done: FUNC_LEAVE_NOAPI(ret_value); } xdmf-3.0+git20160803/Utilities/hdf5/H5Ostab.c0000640000175000017500000002605713003006557020316 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*------------------------------------------------------------------------- * * Created: H5Ostab.c * Aug 6 1997 * Robb Matzke * * Purpose: Symbol table messages. * * Modifications: * *------------------------------------------------------------------------- */ #define H5O_PACKAGE /*suppress error about including H5Opkg */ #define H5G_PACKAGE /*suppress error about including H5Gpkg */ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free lists */ #include "H5Gpkg.h" /* Groups */ #include "H5Opkg.h" /* Object headers */ /* PRIVATE PROTOTYPES */ static void *H5O_stab_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t *sh); static herr_t H5O_stab_encode(H5F_t *f, uint8_t *p, const void *_mesg); static void *H5O_stab_copy(const void *_mesg, void *_dest, unsigned update_flags); static size_t H5O_stab_size(const H5F_t *f, const void *_mesg); static herr_t H5O_stab_free(void *_mesg); static herr_t H5O_stab_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link); static herr_t H5O_stab_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * stream, int indent, int fwidth); /* This message derives from H5O */ const H5O_class_t H5O_STAB[1] = {{ H5O_STAB_ID, /*message id number */ "stab", /*message name for debugging */ sizeof(H5O_stab_t), /*native message size */ H5O_stab_decode, /*decode message */ H5O_stab_encode, /*encode message */ H5O_stab_copy, /*copy the native value */ H5O_stab_size, /*size of symbol table entry */ NULL, /*default reset method */ H5O_stab_free, /* free method */ H5O_stab_delete, /* file delete method */ NULL, /* link method */ NULL, /*get share method */ NULL, /*set share method */ H5O_stab_debug, /*debug the message */ }}; /* Declare a free list to manage the H5O_stab_t struct */ H5FL_DEFINE_STATIC(H5O_stab_t); /*------------------------------------------------------------------------- * Function: H5O_stab_decode * * Purpose: Decode a symbol table message and return a pointer to * a newly allocated one. * * Return: Success: Ptr to new message in native order. * * Failure: NULL * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 6 1997 * * Modifications: * *------------------------------------------------------------------------- */ static void * H5O_stab_decode(H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *p, H5O_shared_t UNUSED *sh) { H5O_stab_t *stab=NULL; void *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_stab_decode); /* check args */ assert(f); assert(p); assert(!sh); /* decode */ if (NULL==(stab = H5FL_CALLOC(H5O_stab_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); H5F_addr_decode(f, &p, &(stab->btree_addr)); H5F_addr_decode(f, &p, &(stab->heap_addr)); /* Set return value */ ret_value=stab; done: if(ret_value==NULL) { if(stab!=NULL) H5FL_FREE(H5O_stab_t,stab); } /* end if */ FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_stab_encode * * Purpose: Encodes a symbol table message. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 6 1997 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_stab_encode(H5F_t *f, uint8_t *p, const void *_mesg) { const H5O_stab_t *stab = (const H5O_stab_t *) _mesg; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_stab_encode); /* check args */ assert(f); assert(p); assert(stab); /* encode */ H5F_addr_encode(f, &p, stab->btree_addr); H5F_addr_encode(f, &p, stab->heap_addr); FUNC_LEAVE_NOAPI(SUCCEED); } /*------------------------------------------------------------------------- * Function: H5O_stab_fast * * Purpose: Initializes a new message struct with info from the cache of * a symbol table entry. * * Return: Success: Ptr to message struct, allocated if none * supplied. * * Failure: NULL * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 6 1997 * * Modifications: * *------------------------------------------------------------------------- */ void * H5O_stab_fast(const H5G_cache_t *cache, const H5O_class_t *type, void *_mesg) { H5O_stab_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_stab_fast); /* check args */ assert(cache); assert(type); if (H5O_STAB == type) { if (_mesg) { ret_value = (H5O_stab_t *) _mesg; } else if (NULL==(ret_value = H5FL_MALLOC(H5O_stab_t))) { HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); } ret_value->btree_addr = cache->stab.btree_addr; ret_value->heap_addr = cache->stab.heap_addr; } else ret_value=NULL; done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_stab_copy * * Purpose: Copies a message from _MESG to _DEST, allocating _DEST if * necessary. * * Return: Success: Ptr to _DEST * * Failure: NULL * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 6 1997 * * Modifications: * *------------------------------------------------------------------------- */ static void * H5O_stab_copy(const void *_mesg, void *_dest, unsigned UNUSED update_flags) { const H5O_stab_t *stab = (const H5O_stab_t *) _mesg; H5O_stab_t *dest = (H5O_stab_t *) _dest; void *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_stab_copy); /* check args */ assert(stab); if (!dest && NULL==(dest = H5FL_MALLOC(H5O_stab_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); /* copy */ *dest = *stab; /* Set return value */ ret_value=dest; done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_stab_size * * Purpose: Returns the size of the raw message in bytes not counting * the message type or size fields, but only the data fields. * This function doesn't take into account alignment. * * Return: Success: Message data size in bytes without alignment. * * Failure: zero * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 6 1997 * * Modifications: * *------------------------------------------------------------------------- */ static size_t H5O_stab_size(const H5F_t *f, const void UNUSED *_mesg) { size_t ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_stab_size); /* Set return value */ ret_value=2 * H5F_SIZEOF_ADDR(f); FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_stab_free * * Purpose: Free's the message * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Thursday, March 30, 2000 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_stab_free (void *mesg) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_stab_free); assert (mesg); H5FL_FREE(H5O_stab_t,mesg); FUNC_LEAVE_NOAPI(SUCCEED); } /*------------------------------------------------------------------------- * Function: H5O_stab_delete * * Purpose: Free file space referenced by message * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Thursday, March 20, 2003 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_stab_delete(H5F_t *f, hid_t dxpl_id, const void *mesg, hbool_t adj_link) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_stab_delete) /* check args */ assert(f); assert(mesg); /* Free the file space for the symbol table */ if (H5G_stab_delete(f, dxpl_id, mesg, adj_link)<0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free symbol table") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_stab_delete() */ /*------------------------------------------------------------------------- * Function: H5O_stab_debug * * Purpose: Prints debugging info for a symbol table message. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 6 1997 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_stab_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg, FILE * stream, int indent, int fwidth) { const H5O_stab_t *stab = (const H5O_stab_t *) _mesg; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_stab_debug); /* check args */ assert(f); assert(stab); assert(stream); assert(indent >= 0); assert(fwidth >= 0); HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "B-tree address:", stab->btree_addr); HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "Name heap address:", stab->heap_addr); FUNC_LEAVE_NOAPI(SUCCEED); } xdmf-3.0+git20160803/Utilities/hdf5/H5Tstrpad.c0000640000175000017500000001327013003006557020660 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Module Info: This module contains the functionality for setting & querying * the datatype string padding for the H5T interface. */ #define H5T_PACKAGE /*suppress error about including H5Tpkg */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5T_init_strpad_interface #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Iprivate.h" /* IDs */ #include "H5Tpkg.h" /* Datatypes */ /*-------------------------------------------------------------------------- NAME H5T_init_strpad_interface -- Initialize interface-specific information USAGE herr_t H5T_init_strpad_interface() RETURNS Non-negative on success/Negative on failure DESCRIPTION Initializes any interface-specific data or routines. (Just calls H5T_init_iterface currently). --------------------------------------------------------------------------*/ static herr_t H5T_init_strpad_interface(void) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_init_strpad_interface) FUNC_LEAVE_NOAPI(H5T_init()) } /* H5T_init_strpad_interface() */ /*------------------------------------------------------------------------- * Function: H5Tget_strpad * * Purpose: The method used to store character strings differs with the * programming language: C usually null terminates strings while * Fortran left-justifies and space-pads strings. This property * defines the storage mechanism for the string. * * Return: Success: The character set of a string type. * * Failure: H5T_STR_ERROR (Negative) * * Programmer: Robb Matzke * Friday, January 9, 1998 * * Modifications: * Robb Matzke, 22 Dec 1998 * Also works for derived datatypes. * *------------------------------------------------------------------------- */ H5T_str_t H5Tget_strpad(hid_t type_id) { H5T_t *dt = NULL; H5T_str_t ret_value; FUNC_ENTER_API(H5Tget_strpad, H5T_STR_ERROR) H5TRACE1("Tz","i",type_id); /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_STR_ERROR, "not a datatype") while (dt->shared->parent && !H5T_IS_STRING(dt->shared)) dt = dt->shared->parent; /*defer to parent*/ if (!H5T_IS_STRING(dt->shared)) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, H5T_STR_ERROR, "operation not defined for datatype class") /* result */ if(H5T_IS_FIXED_STRING(dt->shared)) ret_value = dt->shared->u.atomic.u.s.pad; else ret_value = dt->shared->u.vlen.pad; done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5Tset_strpad * * Purpose: The method used to store character strings differs with the * programming language: C usually null terminates strings while * Fortran left-justifies and space-pads strings. This property * defines the storage mechanism for the string. * * When converting from a long string to a short string if the * short string is H5T_STR_NULLPAD or H5T_STR_SPACEPAD then the * string is simply truncated; otherwise if the short string is * H5T_STR_NULLTERM it will be truncated and a null terminator * is appended. * * When converting from a short string to a long string, the * long string is padded on the end by appending nulls or * spaces. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Friday, January 9, 1998 * * Modifications: * Robb Matzke, 22 Dec 1998 * Also works for derived datatypes. * *------------------------------------------------------------------------- */ herr_t H5Tset_strpad(hid_t type_id, H5T_str_t strpad) { H5T_t *dt = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Tset_strpad, FAIL) H5TRACE2("e","iTz",type_id,strpad); /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") if (H5T_STATE_TRANSIENT!=dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "datatype is read-only") if (strpad < H5T_STR_NULLTERM || strpad >= H5T_NSTR) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal string pad type") while (dt->shared->parent && !H5T_IS_STRING(dt->shared)) dt = dt->shared->parent; /*defer to parent*/ if (!H5T_IS_STRING(dt->shared)) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "operation not defined for datatype class") /* Commit */ if(H5T_IS_FIXED_STRING(dt->shared)) dt->shared->u.atomic.u.s.pad = strpad; else dt->shared->u.vlen.pad = strpad; done: FUNC_LEAVE_API(ret_value) } xdmf-3.0+git20160803/Utilities/hdf5/H5Obogus.c0000640000175000017500000001604113003006557020474 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*------------------------------------------------------------------------- * * Created: H5Obogus.c * Jan 21 2003 * Quincey Koziol * * Purpose: "bogus" message. This message is guaranteed to never * be found in a valid HDF5 file and is only used to * generate a test file which verifies the library's * correct operation when parsing unknown object header * messages. * * Modifications: * *------------------------------------------------------------------------- */ #define H5O_PACKAGE /*suppress error about including H5Opkg */ #include "H5private.h" #include "H5Eprivate.h" #include "H5MMprivate.h" #include "H5Opkg.h" /* Object header functions */ #ifdef H5O_ENABLE_BOGUS /* PRIVATE PROTOTYPES */ static void *H5O_bogus_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t *sh); static herr_t H5O_bogus_encode(H5F_t *f, uint8_t *p, const void *_mesg); static size_t H5O_bogus_size(const H5F_t *f, const void *_mesg); static herr_t H5O_bogus_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * stream, int indent, int fwidth); /* This message derives from H5O */ const H5O_class_t H5O_BOGUS[1] = {{ H5O_BOGUS_ID, /*message id number */ "bogus", /*message name for debugging */ 0, /*native message size */ H5O_bogus_decode, /*decode message */ H5O_bogus_encode, /*encode message */ NULL, /*copy the native value */ H5O_bogus_size, /*raw message size */ NULL, /*free internal memory */ NULL, /*free method */ NULL, /* file delete method */ NULL, /* link method */ NULL, /*get share method */ NULL, /*set share method */ H5O_bogus_debug, /*debug the message */ }}; /*------------------------------------------------------------------------- * Function: H5O_bogus_decode * * Purpose: Decode a "bogus" message and return a pointer to a new * native message struct. * * Return: Success: Ptr to new message in native struct. * * Failure: NULL * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * Jan 21 2003 * * Modifications: * *------------------------------------------------------------------------- */ static void * H5O_bogus_decode(H5F_t UNUSED *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t UNUSED *sh) { H5O_bogus_t *mesg=NULL; void *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_bogus_decode); /* check args */ assert(f); assert(p); assert(!sh); /* Allocate the bogus message */ if (NULL==(mesg = H5MM_calloc(sizeof(H5O_bogus_t)))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); /* decode */ UINT32DECODE(p, mesg->u); /* Validate the bogus info */ if(mesg->u!=H5O_BOGUS_VALUE) HGOTO_ERROR (H5E_OHDR, H5E_BADVALUE, NULL, "invalid bogus value :-)"); /* Set return value */ ret_value=mesg; done: if(ret_value==NULL && mesg!=NULL) H5MM_xfree(mesg); FUNC_LEAVE_NOAPI(ret_value); } /* end H5O_bogus_decode() */ /*------------------------------------------------------------------------- * Function: H5O_bogus_encode * * Purpose: Encodes a "bogus" message. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * Jan 21 2003 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_bogus_encode(H5F_t UNUSED *f, uint8_t *p, const void UNUSED *mesg) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_bogus_encode); /* check args */ assert(f); assert(p); assert(mesg); /* encode */ UINT32ENCODE(p, H5O_BOGUS_VALUE); FUNC_LEAVE_NOAPI(SUCCEED); } /* end H5O_bogus_encode() */ /*------------------------------------------------------------------------- * Function: H5O_bogus_size * * Purpose: Returns the size of the raw message in bytes not * counting the message typ or size fields, but only the data * fields. This function doesn't take into account * alignment. * * Return: Success: Message data size in bytes w/o alignment. * * Failure: Negative * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * Jan 21 2003 * * Modifications: * *------------------------------------------------------------------------- */ static size_t H5O_bogus_size(const H5F_t UNUSED *f, const void UNUSED *mesg) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_bogus_size); /* check args */ assert(f); FUNC_LEAVE_NOAPI(4); } /* end H5O_bogus_size() */ /*------------------------------------------------------------------------- * Function: H5O_bogus_debug * * Purpose: Prints debugging info for the message. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * Jan 21 2003 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_bogus_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg, FILE *stream, int indent, int fwidth) { const H5O_bogus_t *mesg = (const H5O_bogus_t *)_mesg; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_name_debug); /* check args */ assert(f); assert(mesg); assert(stream); assert(indent >= 0); assert(fwidth >= 0); fprintf(stream, "%*s%-*s `%u'\n", indent, "", fwidth, "Bogus Value:", mesg->u); FUNC_LEAVE_NOAPI(SUCCEED); } #endif /* H5O_ENABLE_BOGUS */ xdmf-3.0+git20160803/Utilities/hdf5/HDF5Config.cmake.in0000640000175000017500000000043213003006557022115 0ustar alastairalastairSET(HDF5_EXTRA_FLAGS "@HDF5_EXTRA_FLAGS@") SET(HDF5_ENABLE_PARALLEL @HDF5_ENABLE_PARALLEL@) IF (VTK_USE_MPI AND HDF5_ENABLE_PARALLEL) SET(HDF5_MPI_INCLUDE_PATH "@HDF5_MPI_INCLUDE_PATH@") INCLUDE_DIRECTORIES(${HDF5_MPI_INCLUDE_PATH}) ENDIF (VTK_USE_MPI AND HDF5_ENABLE_PARALLEL) xdmf-3.0+git20160803/Utilities/hdf5/H5Vprivate.h0000640000175000017500000002445713003006557021055 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Robb Matzke * Friday, October 10, 1997 */ #ifndef H5Vprivate_H #define H5Vprivate_H #include "H5private.h" /* Vector comparison functions like Fortran66 comparison operators */ #define H5V_vector_eq_s(N,V1,V2) (H5V_vector_cmp_s (N, V1, V2)==0) #define H5V_vector_lt_s(N,V1,V2) (H5V_vector_cmp_s (N, V1, V2)<0) #define H5V_vector_gt_s(N,V1,V2) (H5V_vector_cmp_s (N, V1, V2)>0) #define H5V_vector_le_s(N,V1,V2) (H5V_vector_cmp_s (N, V1, V2)<=0) #define H5V_vector_ge_s(N,V1,V2) (H5V_vector_cmp_s (N, V1, V2)>=0) #define H5V_vector_eq_u(N,V1,V2) (H5V_vector_cmp_u (N, V1, V2)==0) #define H5V_vector_lt_u(N,V1,V2) (H5V_vector_cmp_u (N, V1, V2)<0) #define H5V_vector_gt_u(N,V1,V2) (H5V_vector_cmp_u (N, V1, V2)>0) #define H5V_vector_le_u(N,V1,V2) (H5V_vector_cmp_u (N, V1, V2)<=0) #define H5V_vector_ge_u(N,V1,V2) (H5V_vector_cmp_u (N, V1, V2)>=0) /* Other functions */ #define H5V_vector_cpy(N,DST,SRC) { \ assert (sizeof(*(DST))==sizeof(*(SRC))); \ if (SRC) HDmemcpy (DST, SRC, (N)*sizeof(*(DST))); \ else HDmemset (DST, 0, (N)*sizeof(*(DST))); \ } #define H5V_vector_zero(N,DST) HDmemset(DST,0,(N)*sizeof(*(DST))) /* A null pointer is equivalent to a zero vector */ #define H5V_ZERO NULL H5_DLL hsize_t H5V_hyper_stride(unsigned n, const hsize_t *size, const hsize_t *total_size, const hsize_t *offset, hsize_t *stride); H5_DLL htri_t H5V_hyper_disjointp(unsigned n, const hsize_t *offset1, const size_t *size1, const hsize_t *offset2, const size_t *size2); H5_DLL htri_t H5V_hyper_eq(unsigned n, const hsize_t *offset1, const hsize_t *size1, const hsize_t *offset2, const hsize_t *size2); H5_DLL herr_t H5V_hyper_fill(unsigned n, const hsize_t *_size, const hsize_t *total_size, const hsize_t *offset, void *_dst, unsigned fill_value); H5_DLL herr_t H5V_hyper_copy(unsigned n, const hsize_t *size, const hsize_t *dst_total_size, const hsize_t *dst_offset, void *_dst, const hsize_t *src_total_size, const hsize_t *src_offset, const void *_src); H5_DLL herr_t H5V_stride_fill(unsigned n, hsize_t elmt_size, const hsize_t *size, const hsize_t *stride, void *_dst, unsigned fill_value); H5_DLL herr_t H5V_stride_copy(unsigned n, hsize_t elmt_size, const hsize_t *_size, const hsize_t *dst_stride, void *_dst, const hsize_t *src_stride, const void *_src); H5_DLL herr_t H5V_stride_copy_s(unsigned n, hsize_t elmt_size, const hsize_t *_size, const hssize_t *dst_stride, void *_dst, const hssize_t *src_stride, const void *_src); H5_DLL herr_t H5V_array_fill(void *_dst, const void *src, size_t size, size_t count); H5_DLL herr_t H5V_array_down(unsigned n, const hsize_t *total_size, hsize_t *down); H5_DLL hsize_t H5V_array_offset_pre(unsigned n, const hsize_t *acc, const hsize_t *offset); H5_DLL hsize_t H5V_array_offset(unsigned n, const hsize_t *total_size, const hsize_t *offset); H5_DLL herr_t H5V_array_calc(hsize_t offset, unsigned n, const hsize_t *total_size, hsize_t *coords); H5_DLL herr_t H5V_chunk_index(unsigned ndims, const hsize_t *coord, const size_t *chunk, const hsize_t *down_nchunks, hsize_t *chunk_idx); H5_DLL ssize_t H5V_memcpyvv(void *_dst, size_t dst_max_nseq, size_t *dst_curr_seq, size_t dst_len_arr[], hsize_t dst_off_arr[], const void *_src, size_t src_max_nseq, size_t *src_curr_seq, size_t src_len_arr[], hsize_t src_off_arr[]); /*------------------------------------------------------------------------- * Function: H5V_vector_reduce_product * * Purpose: Product reduction of a vector. Vector elements and return * value are size_t because we usually want the number of * elements in an array and array dimensions are always of type * size_t. * * Return: Success: Product of elements * * Failure: 1 if N is zero * * Programmer: Robb Matzke * Friday, October 10, 1997 * * Modifications: * *------------------------------------------------------------------------- */ static H5_inline hsize_t UNUSED H5V_vector_reduce_product(unsigned n, const hsize_t *v) { hsize_t ret_value = 1; /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5V_vector_reduce_product) if (n && !v) HGOTO_DONE(0) while (n--) ret_value *= *v++; done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5V_vector_zerop_u * * Purpose: Determines if all elements of a vector are zero. * * Return: Success: TRUE if all elements are zero, * FALSE otherwise * * Failure: TRUE if N is zero * * Programmer: Robb Matzke * Friday, October 10, 1997 * * Modifications: * *------------------------------------------------------------------------- */ static H5_inline htri_t UNUSED H5V_vector_zerop_u(int n, const hsize_t *v) { htri_t ret_value=TRUE; /* Return value */ /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5V_vector_zerop_u) if (!v) HGOTO_DONE(TRUE) while (n--) if (*v++) HGOTO_DONE(FALSE) done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5V_vector_zerop_s * * Purpose: Determines if all elements of a vector are zero. * * Return: Success: TRUE if all elements are zero, * FALSE otherwise * * Failure: TRUE if N is zero * * Programmer: Robb Matzke * Friday, October 10, 1997 * * Modifications: * *------------------------------------------------------------------------- */ static H5_inline htri_t UNUSED H5V_vector_zerop_s(int n, const hssize_t *v) { htri_t ret_value=TRUE; /* Return value */ /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5V_vector_zerop_s) if (!v) HGOTO_DONE(TRUE) while (n--) if (*v++) HGOTO_DONE(FALSE) done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5V_vector_cmp_u * * Purpose: Compares two vectors of the same size and determines if V1 is * lexicographically less than, equal, or greater than V2. * * Return: Success: -1 if V1 is less than V2 * 0 if they are equal * 1 if V1 is greater than V2 * * Failure: 0 if N is zero * * Programmer: Robb Matzke * Friday, October 10, 1997 * * Modifications: * *------------------------------------------------------------------------- */ static H5_inline int UNUSED H5V_vector_cmp_u (unsigned n, const hsize_t *v1, const hsize_t *v2) { int ret_value=0; /* Return value */ /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5V_vector_cmp_u) if (v1 == v2) HGOTO_DONE(0) if (v1 == NULL) HGOTO_DONE(-1) if (v2 == NULL) HGOTO_DONE(1) while (n--) { if (*v1 < *v2) HGOTO_DONE(-1) if (*v1 > *v2) HGOTO_DONE(1) v1++; v2++; } done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5V_vector_cmp_s * * Purpose: Compares two vectors of the same size and determines if V1 is * lexicographically less than, equal, or greater than V2. * * Return: Success: -1 if V1 is less than V2 * 0 if they are equal * 1 if V1 is greater than V2 * * Failure: 0 if N is zero * * Programmer: Robb Matzke * Wednesday, April 8, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static H5_inline int UNUSED H5V_vector_cmp_s (unsigned n, const hssize_t *v1, const hssize_t *v2) { int ret_value=0; /* Return value */ /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5V_vector_cmp_s) if (v1 == v2) HGOTO_DONE(0) if (v1 == NULL) HGOTO_DONE(-1) if (v2 == NULL) HGOTO_DONE(1) while (n--) { if (*v1 < *v2) HGOTO_DONE(-1) if (*v1 > *v2) HGOTO_DONE(1) v1++; v2++; } done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5V_vector_inc * * Purpose: Increments V1 by V2 * * Return: void * * Programmer: Robb Matzke * Monday, October 13, 1997 * * Modifications: * *------------------------------------------------------------------------- */ static H5_inline void UNUSED H5V_vector_inc(int n, hsize_t *v1, const hsize_t *v2) { while (n--) *v1++ += *v2++; } #endif xdmf-3.0+git20160803/Utilities/hdf5/H5Dpkg.h0000640000175000017500000003717213003006557020140 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Quincey Koziol * Monday, April 14, 2003 * * Purpose: This file contains declarations which are visible only within * the H5D package. Source files outside the H5D package should * include H5Dprivate.h instead. */ #ifndef H5D_PACKAGE #error "Do not include this file outside the H5D package!" #endif #ifndef _H5Dpkg_H #define _H5Dpkg_H /* Get package's private header */ #include "H5Dprivate.h" /* Other private headers needed by this file */ #include "H5Gprivate.h" /* Groups */ #include "H5Oprivate.h" /* Object headers */ #include "H5Sprivate.h" /* Dataspaces */ #include "H5Tprivate.h" /* Datatype functions */ /**************************/ /* Package Private Macros */ /**************************/ /* The number of reserved IDs in dataset ID group */ #define H5D_RESERVED_ATOMS 0 /* Set the minimum object header size to create objects with */ #define H5D_MINHDR_SIZE 256 /* [Simple] Macro to construct a H5D_io_info_t from it's components */ #define H5D_BUILD_IO_INFO(io_info,ds,dxpl_c,dxpl_i,str) \ (io_info)->dset=ds; \ (io_info)->dxpl_cache=dxpl_c; \ (io_info)->dxpl_id=dxpl_i; \ (io_info)->store=str /****************************/ /* Package Private Typedefs */ /****************************/ /* * If there is no data type conversion then it might be possible to * transfer data points between application memory and the file in one * step without going through the data type conversion buffer. */ /* Read from file to application w/o intermediate scratch buffer */ struct H5D_io_info_t; typedef herr_t (*H5D_io_read_func_t)(struct H5D_io_info_t *io_info, size_t nelmts, size_t elmt_size, const H5S_t *file_space, const H5S_t *mem_space, void *buf/*out*/); /* Write directly from app buffer to file */ typedef herr_t (*H5D_io_write_func_t)(struct H5D_io_info_t *io_info, size_t nelmts, size_t elmt_size, const H5S_t *file_space, const H5S_t *mem_space, const void *buf); /* Function pointers for I/O on particular types of dataset layouts */ typedef ssize_t (*H5D_io_readvv_func_t)(const struct H5D_io_info_t *io_info, size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_len_arr[], hsize_t dset_offset_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[], void *buf); typedef ssize_t (*H5D_io_writevv_func_t)(const struct H5D_io_info_t *io_info, size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_len_arr[], hsize_t dset_offset_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[], const void *buf); /* Typedef for raw data I/O framework info */ typedef struct H5D_io_ops_t { H5D_io_read_func_t read; /* Direct I/O routine for reading */ H5D_io_write_func_t write; /* Direct I/O routine for writing */ H5D_io_readvv_func_t readvv; /* I/O routine for reading data */ H5D_io_writevv_func_t writevv; /* I/O routine for writing data */ } H5D_io_ops_t; /* Typedef for raw data I/O operation info */ typedef struct H5D_io_info_t { H5D_t *dset; /* Pointer to dataset being operated on */ #ifndef H5_HAVE_PARALLEL const #endif /* H5_HAVE_PARALLEL */ H5D_dxpl_cache_t *dxpl_cache; /* Pointer to cache DXPL info */ hid_t dxpl_id; /* Original DXPL ID */ #ifdef H5_HAVE_PARALLEL MPI_Comm comm; /* MPI communicator for file */ hbool_t xfer_mode_changed; /* Whether the transfer mode was changed */ #endif /* H5_HAVE_PARALLEL */ const H5D_storage_t *store; /* Dataset storage info */ H5D_io_ops_t ops; /* I/O operation function pointers */ #ifdef H5S_DEBUG H5S_iostats_t *stats; /* I/O statistics */ #endif /* H5S_DEBUG */ } H5D_io_info_t; /* The raw data chunk cache */ typedef struct H5D_rdcc_t { #ifdef H5D_ISTORE_DEBUG unsigned ninits; /* Number of chunk creations */ unsigned nhits; /* Number of cache hits */ unsigned nmisses;/* Number of cache misses */ unsigned nflushes;/* Number of cache flushes */ #endif /* H5D_ISTORE_DEBUG */ size_t nbytes; /* Current cached raw data in bytes */ size_t nslots; /* Number of chunk slots allocated */ struct H5D_rdcc_ent_t *head; /* Head of doubly linked list */ struct H5D_rdcc_ent_t *tail; /* Tail of doubly linked list */ int nused; /* Number of chunk slots in use */ struct H5D_rdcc_ent_t **slot; /* Chunk slots, each points to a chunk*/ } H5D_rdcc_t; /* The raw data contiguous data cache */ typedef struct H5D_rdcdc_t { unsigned char *sieve_buf; /* Buffer to hold data sieve buffer */ haddr_t sieve_loc; /* File location (offset) of the data sieve buffer */ size_t sieve_size; /* Size of the data sieve buffer used (in bytes) */ size_t sieve_buf_size; /* Size of the data sieve buffer allocated (in bytes) */ unsigned sieve_dirty; /* Flag to indicate that the data sieve buffer is dirty */ } H5D_rdcdc_t; /* * A dataset is made of two layers, an H5D_t struct that is unique to * each instance of an opened datset, and a shared struct that is only * created once for a given dataset. Thus, if a dataset is opened twice, * there will be two IDs and two H5D_t structs, both sharing one H5D_shared_t. */ typedef struct H5D_shared_t { size_t fo_count; /* reference count */ hid_t type_id; /* ID for dataset's datatype */ H5T_t *type; /* datatype of this dataset */ H5S_t *space; /* dataspace of this dataset */ hid_t dcpl_id; /* dataset creation property id */ H5D_dcpl_cache_t dcpl_cache; /* Cached DCPL values */ H5D_io_ops_t io_ops; /* I/O operations */ H5O_layout_t layout; /* data layout */ hbool_t checked_filters;/* TRUE if dataset passes can_apply check */ /* Cache some frequently accessed values from the DCPL */ H5O_efl_t efl; /* External file list information */ H5D_alloc_time_t alloc_time; /* Dataset allocation time */ H5D_fill_time_t fill_time; /* Dataset fill value writing time */ H5O_fill_t fill; /* Dataset fill value information */ /* Buffered/cached information for types of raw data storage*/ struct { H5D_rdcdc_t contig; /* Information about contiguous data */ /* (Note that the "contig" cache * information can be used by a chunked * dataset in certain circumstances) */ H5D_rdcc_t chunk; /* Information about chunked data */ } cache; } H5D_shared_t; struct H5D_t { H5G_entry_t ent; /* cached object header stuff */ H5D_shared_t *shared; /* cached information from file */ }; /* Enumerated type for allocating dataset's storage */ typedef enum { H5D_ALLOC_CREATE, /* Dataset is being created */ H5D_ALLOC_OPEN, /* Dataset is being opened */ H5D_ALLOC_EXTEND, /* Dataset's dataspace is being extended */ H5D_ALLOC_WRITE /* Dataset is being extended */ } H5D_time_alloc_t; /*****************************/ /* Package Private Variables */ /*****************************/ extern H5D_dxpl_cache_t H5D_def_dxpl_cache; /******************************/ /* Package Private Prototypes */ /******************************/ H5_DLL herr_t H5D_alloc_storage (H5F_t *f, hid_t dxpl_id, H5D_t *dset, H5D_time_alloc_t time_alloc, hbool_t update_time, hbool_t full_overwrite); /* Functions that perform serial I/O operations */ H5_DLL herr_t H5D_select_fscat (H5D_io_info_t *io_info, const H5S_t *file_space, H5S_sel_iter_t *file_iter, size_t nelmts, const void *_buf); H5_DLL size_t H5D_select_fgath (H5D_io_info_t *io_info, const H5S_t *file_space, H5S_sel_iter_t *file_iter, size_t nelmts, void *buf); H5_DLL herr_t H5D_select_mscat (const void *_tscat_buf, const H5S_t *space, H5S_sel_iter_t *iter, size_t nelmts, const H5D_dxpl_cache_t *dxpl_cache, void *_buf/*out*/); H5_DLL size_t H5D_select_mgath (const void *_buf, const H5S_t *space, H5S_sel_iter_t *iter, size_t nelmts, const H5D_dxpl_cache_t *dxpl_cache, void *_tgath_buf/*out*/); H5_DLL herr_t H5D_select_read(H5D_io_info_t *io_info, size_t nelmts, size_t elmt_size, const H5S_t *file_space, const H5S_t *mem_space, void *buf/*out*/); H5_DLL herr_t H5D_select_write(H5D_io_info_t *io_info, size_t nelmts, size_t elmt_size, const H5S_t *file_space, const H5S_t *mem_space, const void *buf/*out*/); /* Functions that operate on contiguous storage */ H5_DLL herr_t H5D_contig_create(H5F_t *f, hid_t dxpl_id, H5O_layout_t *layout); H5_DLL herr_t H5D_contig_fill(H5D_t *dset, hid_t dxpl_id); H5_DLL haddr_t H5D_contig_get_addr(const H5D_t *dset); H5_DLL ssize_t H5D_contig_readvv(const H5D_io_info_t *io_info, size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_len_arr[], hsize_t dset_offset_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[], void *buf); H5_DLL ssize_t H5D_contig_writevv(const H5D_io_info_t *io_info, size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_len_arr[], hsize_t dset_offset_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[], const void *buf); /* Functions that operate on compact dataset storage */ H5_DLL ssize_t H5D_compact_readvv(const H5D_io_info_t *io_info, size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_size_arr[], hsize_t dset_offset_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_size_arr[], hsize_t mem_offset_arr[], void *buf); H5_DLL ssize_t H5D_compact_writevv(const H5D_io_info_t *io_info, size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_size_arr[], hsize_t dset_offset_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_size_arr[], hsize_t mem_offset_arr[], const void *buf); /* Functions that operate on indexed storage */ /* forward reference for collective-chunk IO use */ struct H5D_istore_ud1_t; /*define in H5Distore.c*/ H5_DLL herr_t H5D_istore_init (const H5F_t *f, const H5D_t *dset); H5_DLL herr_t H5D_istore_flush (H5D_t *dset, hid_t dxpl_id, unsigned flags); H5_DLL herr_t H5D_istore_create(H5F_t *f, hid_t dxpl_id, H5O_layout_t *layout); H5_DLL herr_t H5D_istore_dest (H5D_t *dset, hid_t dxpl_id); H5_DLL herr_t H5D_istore_allocate (H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite); H5_DLL hsize_t H5D_istore_allocated(H5D_t *dset, hid_t dxpl_id); H5_DLL herr_t H5D_istore_prune_by_extent(const H5D_io_info_t *io_info); H5_DLL herr_t H5D_istore_initialize_by_extent(H5D_io_info_t *io_info); H5_DLL herr_t H5D_istore_update_cache(H5D_t *dset, hid_t dxpl_id); H5_DLL herr_t H5D_istore_dump_btree(H5F_t *f, hid_t dxpl_id, FILE *stream, unsigned ndims, haddr_t addr); #ifdef H5D_ISTORE_DEBUG H5_DLL herr_t H5D_istore_stats (H5D_t *dset, hbool_t headers); #endif /* H5D_ISTORE_DEBUG */ H5_DLL ssize_t H5D_istore_readvv(const H5D_io_info_t *io_info, size_t chunk_max_nseq, size_t *chunk_curr_seq, size_t chunk_len_arr[], hsize_t chunk_offset_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[], void *buf); H5_DLL ssize_t H5D_istore_writevv(const H5D_io_info_t *io_info, size_t chunk_max_nseq, size_t *chunk_curr_seq, size_t chunk_len_arr[], hsize_t chunk_offset_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[], const void *buf); H5_DLL haddr_t H5D_istore_get_addr(const H5D_io_info_t *io_info, struct H5D_istore_ud1_t *_udata); /* Functions that operate on external file list (efl) storage */ H5_DLL ssize_t H5D_efl_readvv(const H5D_io_info_t *io_info, size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_len_arr[], hsize_t dset_offset_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[], void *buf); H5_DLL ssize_t H5D_efl_writevv(const H5D_io_info_t *io_info, size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_len_arr[], hsize_t dset_offset_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[], const void *buf); #ifdef H5_HAVE_PARALLEL /* MPI-IO function to read directly from app buffer to file rky980813 */ H5_DLL herr_t H5D_mpio_select_read(H5D_io_info_t *io_info, size_t nelmts, size_t elmt_size, const struct H5S_t *file_space, const struct H5S_t *mem_space, void *buf/*out*/); /* MPI-IO function to read , it will select either regular or irregular read */ H5_DLL herr_t H5D_mpio_select_write(H5D_io_info_t *io_info, size_t nelmts, size_t elmt_size, const struct H5S_t *file_space, const struct H5S_t *mem_space, const void *buf); /* MPI-IO function to read directly from app buffer to file rky980813 */ H5_DLL herr_t H5D_mpio_spaces_read(H5D_io_info_t *io_info, size_t nelmts, size_t elmt_size, const struct H5S_t *file_space, const struct H5S_t *mem_space, void *buf/*out*/); /* MPI-IO function to write directly from app buffer to file rky980813 */ H5_DLL herr_t H5D_mpio_spaces_write(H5D_io_info_t *io_info, size_t nelmts, size_t elmt_size, const struct H5S_t *file_space, const struct H5S_t *mem_space, const void *buf); /* MPI-IO function to read directly from app buffer to file rky980813 */ H5_DLL herr_t H5D_mpio_spaces_span_read(H5D_io_info_t *io_info, size_t nelmts, size_t elmt_size, const struct H5S_t *file_space, const struct H5S_t *mem_space, void *buf/*out*/); /* MPI-IO function to write directly from app buffer to file rky980813 */ H5_DLL herr_t H5D_mpio_spaces_span_write(H5D_io_info_t *io_info, size_t nelmts, size_t elmt_size, const struct H5S_t *file_space, const struct H5S_t *mem_space, const void *buf); /* MPI-IO function to check if a direct I/O transfer is possible between * memory and the file */ H5_DLL htri_t H5D_mpio_opt_possible(const H5D_io_info_t *io_info, const H5S_t *mem_space, const H5S_t *file_space, const H5T_path_t *tpath); #endif /* H5_HAVE_PARALLEL */ /* Testing functions */ #ifdef H5D_TESTING H5_DLL herr_t H5D_layout_version_test(hid_t did, unsigned *version); H5_DLL herr_t H5D_layout_contig_size_test(hid_t did, hsize_t *size); #endif /* H5D_TESTING */ #endif /*_H5Dpkg_H*/ xdmf-3.0+git20160803/Utilities/hdf5/H5FDmpi.c0000640000175000017500000003772213003006557020246 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Quincey Koziol * Friday, January 30, 2004 * * Purpose: Common routines for all MPI-based VFL drivers. * */ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fprivate.h" /* File access */ #include "H5FDprivate.h" /* File drivers */ #include "H5FDmpi.h" /* Common MPI file driver */ #include "H5Pprivate.h" /* Property lists */ /* * The view is set to this value */ char H5FD_mpi_native_g[] = "native"; #ifdef H5_HAVE_PARALLEL /*------------------------------------------------------------------------- * Function: H5FD_mpi_get_rank * * Purpose: Retrieves the rank of an MPI process. * * Return: Success: The rank (non-negative) * * Failure: Negative * * Programmer: Quincey Koziol * Friday, January 30, 2004 * * Modifications: * *------------------------------------------------------------------------- */ int H5FD_mpi_get_rank(const H5FD_t *file) { const H5FD_class_mpi_t *cls=(const H5FD_class_mpi_t *)(file->cls); int ret_value; FUNC_ENTER_NOAPI(H5FD_mpi_get_rank, FAIL) assert(file && cls); assert(cls->get_rank); /* All MPI drivers must implement this */ /* Dispatch to driver */ if ((ret_value=(cls->get_rank)(file))<0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "driver get_rank request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpi_get_rank() */ /*------------------------------------------------------------------------- * Function: H5FD_mpi_get_size * * Purpose: Retrieves the size of the communicator used for the file * * Return: Success: The communicator size (non-negative) * * Failure: Negative * * Programmer: Quincey Koziol * Friday, January 30, 2004 * * Modifications: * *------------------------------------------------------------------------- */ int H5FD_mpi_get_size(const H5FD_t *file) { const H5FD_class_mpi_t *cls=(const H5FD_class_mpi_t *)(file->cls); int ret_value; FUNC_ENTER_NOAPI(H5FD_mpi_get_size, FAIL) assert(file && cls); assert(cls->get_size); /* All MPI drivers must implement this */ /* Dispatch to driver */ if ((ret_value=(cls->get_size)(file))<0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "driver get_size request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpi_get_size() */ /*------------------------------------------------------------------------- * Function: H5FD_mpi_get_comm * * Purpose: Retrieves the file's communicator * * Return: Success: The communicator (non-negative) * * Failure: Negative * * Programmer: Quincey Koziol * Friday, January 30, 2004 * * Modifications: * *------------------------------------------------------------------------- */ MPI_Comm H5FD_mpi_get_comm(const H5FD_t *file) { const H5FD_class_mpi_t *cls=(const H5FD_class_mpi_t *)(file->cls); MPI_Comm ret_value; FUNC_ENTER_NOAPI(H5FD_mpi_get_comm, MPI_COMM_NULL) assert(file && cls); assert(cls->get_comm); /* All MPI drivers must implement this */ /* Dispatch to driver */ if ((ret_value=(cls->get_comm)(file))==MPI_COMM_NULL) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, MPI_COMM_NULL, "driver get_comm request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpi_get_comm() */ /*------------------------------------------------------------------------- * Function: H5FD_mpi_MPIOff_to_haddr * * Purpose: Convert an MPI_Offset value to haddr_t. * * Return: Success: The haddr_t equivalent of the MPI_OFF * argument. * * Failure: HADDR_UNDEF * * Programmer: Unknown * January 30, 1998 * * Modifications: * Robb Matzke, 1999-04-23 * An error is reported for address overflows. The ADDR output * argument is optional. * * Robb Matzke, 1999-08-06 * Modified to work with the virtual file layer. *------------------------------------------------------------------------- */ haddr_t H5FD_mpi_MPIOff_to_haddr(MPI_Offset mpi_off) { haddr_t ret_value=HADDR_UNDEF; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_mpi_MPIOff_to_haddr) if (mpi_off != (MPI_Offset)(haddr_t)mpi_off) ret_value=HADDR_UNDEF; else ret_value=(haddr_t)mpi_off; FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_mpi_haddr_to_MPIOff * * Purpose: Convert an haddr_t value to MPI_Offset. * * Return: Success: Non-negative, the MPI_OFF argument contains * the converted value. * * Failure: Negative, MPI_OFF is undefined. * * Programmer: Unknown * January 30, 1998 * * Modifications: * Robb Matzke, 1999-04-23 * An error is reported for address overflows. The ADDR output * argument is optional. * * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. * * Robb Matzke, 1999-08-06 * Modified to work with the virtual file layer. *------------------------------------------------------------------------- */ herr_t H5FD_mpi_haddr_to_MPIOff(haddr_t addr, MPI_Offset *mpi_off/*out*/) { herr_t ret_value=FAIL; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_mpi_haddr_to_MPIOff) assert(mpi_off); /* Convert the HDF5 address into an MPI offset */ *mpi_off = (MPI_Offset)addr; if (addr != (haddr_t)((MPI_Offset)addr)) ret_value=FAIL; else ret_value=SUCCEED; FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_mpi_comm_info_dup * * Purpose: Make duplicates of communicator and Info object. * If the Info object is in fact MPI_INFO_NULL, no duplicate * is made but the same value assigned to the new Info object * handle. * * Return: Success: Non-negative. The new communicator and Info * object handles are returned via comm_new and * info_new pointers. * * Failure: Negative. * * Programmer: Albert Cheng * Jan 8, 2003 * * Modifications: *------------------------------------------------------------------------- */ herr_t H5FD_mpi_comm_info_dup(MPI_Comm comm, MPI_Info info, MPI_Comm *comm_new, MPI_Info *info_new) { herr_t ret_value=SUCCEED; MPI_Comm comm_dup=MPI_COMM_NULL; MPI_Info info_dup=MPI_INFO_NULL; int mpi_code; FUNC_ENTER_NOAPI(H5FD_mpi_comm_info_dup, FAIL) /* Check arguments */ if (MPI_COMM_NULL == comm) HGOTO_ERROR(H5E_INTERNAL, H5E_BADVALUE, FAIL, "not a valid argument") if (!comm_new || !info_new) HGOTO_ERROR(H5E_INTERNAL, H5E_BADVALUE, FAIL, "bad pointers") /* Dup them. Using temporary variables for error recovery cleanup. */ if (MPI_SUCCESS != (mpi_code=MPI_Comm_dup(comm, &comm_dup))) HMPI_GOTO_ERROR(FAIL, "MPI_Comm_dup failed", mpi_code) if (MPI_INFO_NULL != info){ if (MPI_SUCCESS != (mpi_code=MPI_Info_dup(info, &info_dup))) HMPI_GOTO_ERROR(FAIL, "MPI_Info_dup failed", mpi_code) }else{ /* No dup, just copy it. */ info_dup = info; } /* copy them to the return arguments */ *comm_new = comm_dup; *info_new = info_dup; done: if (FAIL == ret_value){ /* need to free anything created here */ if (MPI_COMM_NULL != comm_dup) MPI_Comm_free(&comm_dup); if (MPI_INFO_NULL != info_dup) MPI_Info_free(&info_dup); } FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_mpi_comm_info_free * * Purpose: Free the communicator and Info object. * If comm or info is in fact MPI_COMM_NULL or MPI_INFO_NULL * respectively, no action occurs to it. * * Return: Success: Non-negative. The values the pointers refer * to will be set to the corresponding NULL * handles. * * Failure: Negative. * * Programmer: Albert Cheng * Jan 8, 2003 * * Modifications: *------------------------------------------------------------------------- */ herr_t H5FD_mpi_comm_info_free(MPI_Comm *comm, MPI_Info *info) { herr_t ret_value=SUCCEED; FUNC_ENTER_NOAPI(H5FD_mpi_comm_info_free, FAIL) /* Check arguments */ if (!comm || !info) HGOTO_ERROR(H5E_INTERNAL, H5E_BADVALUE, FAIL, "not a valid argument") if (MPI_COMM_NULL != *comm) MPI_Comm_free(comm); if (MPI_INFO_NULL != *info) MPI_Info_free(info); done: FUNC_LEAVE_NOAPI(ret_value) } #ifdef NOT_YET /*------------------------------------------------------------------------- * Function: H5FD_mpio_wait_for_left_neighbor * * Purpose: Blocks until (empty) msg is received from immediately * lower-rank neighbor. In conjunction with * H5FD_mpio_signal_right_neighbor, useful for enforcing * 1-process-at-at-time access to critical regions to avoid race * conditions (though it is overkill to require that the * processes be allowed to proceed strictly in order of their * rank). * * Note: This routine doesn't read or write any file, just performs * interprocess coordination. It really should reside in a * separate package of such routines. * * Return: Success: 0 * Failure: -1 * * Programmer: rky * 19981207 * * Modifications: * Robb Matzke, 1999-08-09 * Modified to work with the virtual file layer. *------------------------------------------------------------------------- */ herr_t H5FD_mpio_wait_for_left_neighbor(H5FD_t *_file) { H5FD_mpio_t *file = (H5FD_mpio_t*)_file; char msgbuf[1]; MPI_Status rcvstat; int mpi_code; /* mpi return code */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_mpio_wait_for_left_neighbor, FAIL) assert(file); assert(H5FD_MPIO==file->pub.driver_id); /* Portably initialize MPI status variable */ HDmemset(&rcvstat,0,sizeof(MPI_Status)); /* p0 has no left neighbor; all other procs wait for msg */ if (file->mpi_rank != 0) { if (MPI_SUCCESS != (mpi_code=MPI_Recv( &msgbuf, 1, MPI_CHAR, file->mpi_rank-1, MPI_ANY_TAG, file->comm, &rcvstat ))) HMPI_GOTO_ERROR(FAIL, "MPI_Recv failed", mpi_code) } done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_mpio_signal_right_neighbor * * Purpose: Blocks until (empty) msg is received from immediately * lower-rank neighbor. In conjunction with * H5FD_mpio_wait_for_left_neighbor, useful for enforcing * 1-process-at-at-time access to critical regions to avoid race * conditions (though it is overkill to require that the * processes be allowed to proceed strictly in order of their * rank). * * Note: This routine doesn't read or write any file, just performs * interprocess coordination. It really should reside in a * separate package of such routines. * * Return: Success: 0 * Failure: -1 * * Programmer: rky * 19981207 * * Modifications: * Robb Matzke, 1999-08-09 * Modified to work with the virtual file layer. *------------------------------------------------------------------------- */ herr_t H5FD_mpio_signal_right_neighbor(H5FD_t *_file) { H5FD_mpio_t *file = (H5FD_mpio_t*)_file; char msgbuf[1]; int mpi_code; /* mpi return code */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_mpio_signal_right_neighbor, FAIL) assert(file); assert(H5FD_MPIO==file->pub.driver_id); if (file->mpi_rank != (file->mpi_size-1)) { if (MPI_SUCCESS != (mpi_code=MPI_Send(&msgbuf, 0/*empty msg*/, MPI_CHAR, file->mpi_rank+1, 0, file->comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Send failed", mpi_code) } done: FUNC_LEAVE_NOAPI(ret_value) } #endif /* NOT_YET */ /*------------------------------------------------------------------------- * Function: H5FD_mpi_setup_collective * * Purpose: Set the buffer type BTYPE, file type FTYPE for a data * transfer. Also request a MPI type transfer. * * Return: Success: 0 * Failure: -1 * * Programmer: Robb Matzke * Monday, August 9, 1999 * * Modifications: * * Quincey Koziol - 2002/06/17 * Removed 'disp' parameter, read & write routines will use * the address of the dataset in MPI_File_set_view() calls, as * necessary. * * Quincey Koziol - 2002/06/17 * Changed to set temporary properties in a dxpl, instead of * flags in the file struct, which will make this more threadsafe. * *------------------------------------------------------------------------- */ herr_t H5FD_mpi_setup_collective(hid_t dxpl_id, MPI_Datatype btype, MPI_Datatype ftype) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_mpi_setup_collective, FAIL) /* Check arguments */ if(NULL == (plist = H5P_object_verify(dxpl_id,H5P_DATASET_XFER))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dataset transfer list") /* Set buffer MPI type */ if(H5P_insert(plist,H5FD_MPI_XFER_MEM_MPI_TYPE_NAME,H5FD_MPI_XFER_MEM_MPI_TYPE_SIZE,&btype,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't insert MPI-I/O property") /* Set file MPI type */ if(H5P_insert(plist,H5FD_MPI_XFER_FILE_MPI_TYPE_NAME,H5FD_MPI_XFER_FILE_MPI_TYPE_SIZE,&ftype,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't insert MPI-I/O property") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpi_setup_collective() */ /*------------------------------------------------------------------------- * Function: H5FD_mpi_teardown_collective * * Purpose: Remove the temporary MPI-I/O properties from dxpl. * * Return: Success: Non-negative * Failure: Negative * * Programmer: Quincey Koziol * Monday, June 17, 2002 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5FD_mpi_teardown_collective(hid_t dxpl_id) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_mpi_teardown_collective, FAIL) /* Check arguments */ if(NULL == (plist = H5P_object_verify(dxpl_id,H5P_DATASET_XFER))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dataset transfer list") /* Remove buffer MPI type */ if(H5P_remove(dxpl_id,plist,H5FD_MPI_XFER_MEM_MPI_TYPE_NAME)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTDELETE, FAIL, "can't remove MPI-I/O property") /* Remove file MPI type */ if(H5P_remove(dxpl_id,plist,H5FD_MPI_XFER_FILE_MPI_TYPE_NAME)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTDELETE, FAIL, "can't remove MPI-I/O property") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpi_teardown_collective() */ #endif /* H5_HAVE_PARALLEL */ xdmf-3.0+git20160803/Utilities/hdf5/H5FDlog.h0000640000175000017500000000647713003006557020252 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Quincey Koziol * Monday, April 17, 2000 * * Purpose: The public header file for the log driver. */ #ifndef H5FDlog_H #define H5FDlog_H #include "H5Ipublic.h" #define H5FD_LOG (H5FD_log_init()) /* Flags for H5Pset_fapl_log() */ /* Flags for tracking where reads/writes/seeks occur */ #define H5FD_LOG_LOC_READ 0x0001 #define H5FD_LOG_LOC_WRITE 0x0002 #define H5FD_LOG_LOC_SEEK 0x0004 #define H5FD_LOG_LOC_IO (H5FD_LOG_LOC_READ|H5FD_LOG_LOC_WRITE|H5FD_LOG_LOC_SEEK) /* Flags for tracking number of times each byte is read/written */ #define H5FD_LOG_FILE_READ 0x0008 #define H5FD_LOG_FILE_WRITE 0x0010 #define H5FD_LOG_FILE_IO (H5FD_LOG_FILE_READ|H5FD_LOG_FILE_WRITE) /* Flag for tracking "flavor" (type) of information stored at each byte */ #define H5FD_LOG_FLAVOR 0x0020 /* Flags for tracking total number of reads/writes/seeks */ #define H5FD_LOG_NUM_READ 0x0040 #define H5FD_LOG_NUM_WRITE 0x0080 #define H5FD_LOG_NUM_SEEK 0x0100 #define H5FD_LOG_NUM_IO (H5FD_LOG_NUM_READ|H5FD_LOG_NUM_WRITE|H5FD_LOG_NUM_SEEK) /* Flags for tracking time spent in open/read/write/seek/close */ #define H5FD_LOG_TIME_OPEN 0x0200 /* Not implemented yet */ #define H5FD_LOG_TIME_READ 0x0400 /* Not implemented yet */ #define H5FD_LOG_TIME_WRITE 0x0800 /* Partially implemented (need to track total time) */ #define H5FD_LOG_TIME_SEEK 0x1000 /* Partially implemented (need to track total time & track time for seeks during reading) */ #define H5FD_LOG_TIME_CLOSE 0x2000 /* Fully implemented */ #define H5FD_LOG_TIME_IO (H5FD_LOG_TIME_OPEN|H5FD_LOG_TIME_READ|H5FD_LOG_TIME_WRITE|H5FD_LOG_TIME_SEEK|H5FD_LOG_TIME_CLOSE) /* Flag for tracking allocation of space in file */ #define H5FD_LOG_ALLOC 0x4000 #define H5FD_LOG_ALL (H5FD_LOG_ALLOC|H5FD_LOG_TIME_IO|H5FD_LOG_NUM_IO|H5FD_LOG_FLAVOR|H5FD_LOG_FILE_IO|H5FD_LOG_LOC_IO) #ifdef __cplusplus extern "C" { #endif H5_DLL hid_t H5FD_log_init(void); H5_DLL void H5FD_log_term(void); #ifdef H5_WANT_H5_V1_4_COMPAT H5_DLL herr_t H5Pset_fapl_log(hid_t fapl_id, const char *logfile, int verbosity); #else /* H5_WANT_H5_V1_4_COMPAT */ H5_DLL herr_t H5Pset_fapl_log(hid_t fapl_id, const char *logfile, unsigned flags, size_t buf_size); #endif /* H5_WANT_H5_V1_4_COMPAT */ #ifdef __cplusplus } #endif #endif xdmf-3.0+git20160803/Utilities/hdf5/H5RCprivate.h0000640000175000017500000000440613003006557021144 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * This file contains private information about the H5RC module */ #ifndef _H5RCprivate_H #define _H5RCprivate_H /**************************************/ /* Public headers needed by this file */ /**************************************/ #ifdef LATER #include "H5RCpublic.h" #endif /* LATER */ /***************************************/ /* Private headers needed by this file */ /***************************************/ #include "H5private.h" /************/ /* Typedefs */ /************/ /* Typedef for function to release object when reference count drops to zero */ typedef herr_t (*H5RC_free_func_t)(void *o); /* Typedef for reference counted objects */ typedef struct H5RC_t { void *o; /* Object to be reference counted */ size_t n; /* Reference count of number of pointers sharing object */ H5RC_free_func_t free_func; /* Function to free object */ } H5RC_t; /**********/ /* Macros */ /**********/ #define H5RC_INC(rc) ((rc)->n++) #define H5RC_DEC(rc) (H5RC_decr(rc)) #define H5RC_GET_OBJ(rc) ((rc)->o) /********************/ /* Private routines */ /********************/ H5_DLL H5RC_t *H5RC_create(void *s, H5RC_free_func_t free_func); H5_DLL herr_t H5RC_decr(H5RC_t *rc); #endif /* _H5RSprivate_H */ xdmf-3.0+git20160803/Utilities/hdf5/H5FDmpiposix.h0000640000175000017500000000416413003006557021330 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Quincey Koziol * Thursday, July 11, 2002 * * Purpose: The public header file for the mpiposix driver. */ #ifndef __H5FDmpiposix_H #define __H5FDmpiposix_H #ifdef H5_HAVE_PARALLEL # define H5FD_MPIPOSIX (H5FD_mpiposix_init()) #else # define H5FD_MPIPOSIX (-1) #endif /* Macros */ #define IS_H5FD_MPIPOSIX(f) /* (H5F_t *f) */ \ (H5FD_MPIPOSIX==H5F_get_driver_id(f)) #ifdef H5_HAVE_PARALLEL /* Function prototypes */ #ifdef __cplusplus extern "C" { #endif H5_DLL hid_t H5FD_mpiposix_init(void); H5_DLL void H5FD_mpiposix_term(void); #ifdef H5_WANT_H5_V1_4_COMPAT H5_DLL herr_t H5Pset_fapl_mpiposix(hid_t fapl_id, MPI_Comm comm); H5_DLL herr_t H5Pget_fapl_mpiposix(hid_t fapl_id, MPI_Comm *comm/*out*/); #else /* H5_WANT_H5_V1_4_COMPAT */ H5_DLL herr_t H5Pset_fapl_mpiposix(hid_t fapl_id, MPI_Comm comm, hbool_t use_gpfs); H5_DLL herr_t H5Pget_fapl_mpiposix(hid_t fapl_id, MPI_Comm *comm/*out*/, hbool_t *use_gpfs/*out*/); #endif /* H5_WANT_H5_V1_4_COMPAT */ #ifdef __cplusplus } #endif #endif /*H5_HAVE_PARALLEL*/ #endif /* __H5FDmpiposix_H */ xdmf-3.0+git20160803/Utilities/hdf5/H5FDsrb.c0000640000175000017500000006462713003006557020253 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Raymond Lu * Wednesday, April 12, 2000 * * Purpose: SRB I/O driver. */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5FD_srb_init_interface #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fprivate.h" /* File access */ #include "H5FDprivate.h" /* File drivers */ #include "H5FDsrb.h" /* SRB file driver */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Pprivate.h" /* Property lists */ #ifdef H5_HAVE_SRB /* The driver identification number, initialized at runtime */ static hid_t H5FD_SRB_g = 0; /* * This driver supports systems that have the lseek64() function by defining * some macros here so we don't have to have conditional compilations later * throughout the code. * * file_offset_t: The datatype for file offsets, the second argument of * the lseek() or lseek64() call. * * file_seek: The function which adjusts the current file position, * either lseek() or lseek64(). */ /* adding for windows NT file system support. */ #ifdef H5_HAVE_LSEEK64 # define file_offset_t off64_t # define file_seek lseek64 #elif defined (WIN32) # ifdef __MWERKS__ # define file_offset_t off_t # define file_seek lseek # else /*MSVC*/ # define file_offset_t __int64 # define file_seek _lseeki64 # endif #else # define file_offset_t off_t # define file_seek lseek #endif /* * These macros check for overflow of various quantities. These macros * assume that file_offset_t is signed and haddr_t and size_t are unsigned. * * ADDR_OVERFLOW: Checks whether a file address of type `haddr_t' * is too large to be represented by the second argument * of the file seek function. * * SIZE_OVERFLOW: Checks whether a buffer size of type `hsize_t' is too * large to be represented by the `size_t' type. * * REGION_OVERFLOW: Checks whether an address and size pair describe data * which can be addressed entirely by the second * argument of the file seek function. */ #define MAXADDR (((haddr_t)1<<(8*sizeof(file_offset_t)-1))-1) #define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || \ ((A) & ~(haddr_t)MAXADDR)) #define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) #define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ sizeof(file_offset_t) * * Programmer: Quincey Koziol * Friday, Jan 30, 2004 * * Modification: * *--------------------------------------------------------------------------- */ void H5FD_srb_term(void) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_srb_term) /* Reset VFL ID */ H5FD_SRB_g=0; FUNC_LEAVE_NOAPI_VOID } /* end H5FD_srb_term() */ /*------------------------------------------------------------------------- * Function: H5Pset_fapl_srb * * Purpose: Store srb connection(client to server) handler SRB_CONN * after connected and user supplied INFO in the file access * property list FAPL_ID, which can be used to create or open * file. * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Raymond Lu * April 12, 2000 * * Modifications: * * Raymond Lu, 2001-10-25 * Use the new generic property list for argument checking. * *------------------------------------------------------------------------- */ herr_t H5Pset_fapl_srb(hid_t fapl_id, SRB_Info info) { H5FD_srb_fapl_t fa; int srb_status; H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value; FUNC_ENTER_API(H5Pset_fapl_srb, FAIL) /*NO TRACE*/ if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") /*connect to SRB server */ fa.srb_conn = clConnect(info.srbHost, info.srbPort, info.srbAuth); if((srb_status = clStatus(fa.srb_conn)) != CLI_CONNECTION_OK) { fprintf(stderr,"%s",clErrorMessage(fa.srb_conn)); clFinish(fa.srb_conn); /*not sure about first 2 parameters. */ HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "Connection to srbMaster failed.") } fa.info = info; ret_value = H5P_set_driver(plist, H5FD_SRB, &fa); done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5Pget_fapl_srb * * Purpose: If the file access property list is set to the H5FD_SRB * driver then this function returns the srb file INFO. * * Return: Success: File INFO is returned. * Failure: Negative * * Programmer: Raymond Lu * April 12, 2000 * * Modifications: * * Raymond Lu, 2001-10-25 * Use the new generic property list for checking property list * ID. * *------------------------------------------------------------------------- */ herr_t H5Pget_fapl_srb(hid_t fapl_id, SRB_Info *info/*out*/) { H5P_genplist_t *plist; /* Property list pointer */ H5FD_srb_fapl_t *fa; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Pget_fapl_srb, FAIL) H5TRACE2("e","ix",fapl_id,info); if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") if(H5FD_SRB != H5P_get_driver(plist)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver") if(NULL==(fa=H5P_get_driver_info(plist))) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info") if(info) *info = fa->info; done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_srb_open * * Purpose: Opens a file with name NAME. The FLAGS are a bit field with * purpose similar to the second argument of open(2) and which * are defined in H5Fpublic.h. The file access property list * FAPL_ID contains the properties driver properties and MAXADDR * is the largest address which this file will be expected to * access. * * Return: Success: A new file pointer. * * Failure: NULL * * Programmer: Raymond Lu * April 12, 2000 * Modifications: *------------------------------------------------------------------------- */ static H5FD_t * H5FD_srb_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { struct srbStat srb_stat; H5FD_srb_fapl_t *fa=NULL; H5FD_srb_fapl_t _fa; H5FD_srb_t *file; int srb_fid; H5P_genplist_t *plist; /* Property list pointer */ H5FD_t *ret_value; FUNC_ENTER_NOAPI(H5FD_srb_open, FAIL) /* Check arguments */ if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name") if (0==maxaddr || HADDR_UNDEF==maxaddr) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr") if (ADDR_OVERFLOW(maxaddr)) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr") if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") if(H5P_FILE_ACCESS_DEFAULT==fapl_id || H5FD_SRB!=H5P_get_driver(plist)) { HDmemset((void*)&_fa, 0, sizeof(H5FD_srb_fapl_t)); fa = &_fa; } else { fa = H5P_get_driver_info(plist); assert(fa); } /* When I come down here, the possible flag values and the correct * responses are given here :- * * 1. H5F_ACC_CREAT | H5F_ACC_RDWR | H5F_ACC_EXCL : The file is * a new one. Go ahead and open it with srbObjCreate. * 2. H5F_ACC_CREAT | H5F_ACC_RDWR | H5F_ACC_TRUNC : how do I handle this? * srbObjCreate doesn't support truncate while srbObjOpen doesn't * support create. Try to call both srbFileCreate and srbFileOpen! * 3. H5F_ACC_RDWR | H5F_ACC_TRUNC : Use O_RDWR | O_TRUNC with srbObjOpen. * 4. H5F_ACC_RDWR : Use O_RDWR with srbObjOpen. * 5. Flag is not set : Use O_RDONLY with srbObjOpen. * * (In srbObjOpen, O_CREATE is not supported. For file creation, use * srbObjCreate.) */ if((flags & H5F_ACC_CREAT) && (flags & H5F_ACC_RDWR) && (flags & H5F_ACC_EXCL)) srb_fid = srbFileCreate(fa->srb_conn, fa->info.storSysType, fa->info.srbHost, name, fa->info.mode, fa->info.size); else if((flags & H5F_ACC_CREAT) && (flags & H5F_ACC_RDWR) && (flags & H5F_ACC_TRUNC)) { if( (srb_fid = srbFileCreate(fa->srb_conn, fa->info.storSysType, fa->info.srbHost, name, fa->info.mode, fa->info.size)) < 0 ) { srb_fid = srbFileOpen(fa->srb_conn, fa->info.storSysType, fa->info.srbHost, name, O_RDWR|O_TRUNC, fa->info.mode); } } else if((flags & H5F_ACC_RDWR) && (flags & H5F_ACC_TRUNC)) srb_fid = srbFileOpen(fa->srb_conn, fa->info.storSysType, fa->info.srbHost, name, O_RDWR|O_TRUNC, fa->info.mode); else if(flags & H5F_ACC_RDWR) srb_fid = srbFileOpen(fa->srb_conn, fa->info.storSysType, fa->info.srbHost, name, O_RDWR, fa->info.mode); else srb_fid = srbFileOpen(fa->srb_conn, fa->info.storSysType, fa->info.srbHost, name, O_RDONLY, fa->info.mode); if(srb_fid < 0) { #ifdef OLD_WAY fprintf(stderr, "cannot open file %s\n", name); fprintf(stderr,"%s",clErrorMessage(fa->srb_conn)); clFinish(fa->srb_conn); HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, NULL, "cannot open file") #else /* OLD_WAY */ HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, NULL, clErrorMessage(fa->srb_conn)) #endif /* OLD_WAY */ } if(srbFileStat(fa->srb_conn, fa->info.storSysType, fa->info.srbHost, name, &srb_stat)!=0) { #ifdef OLD_WAY srbFileClose(fa->srb_conn, srb_fid); clFinish(fa->srb_conn); HGOTO_ERROR(H5E_IO, H5E_BADFILE, NULL, "SRB file stat failed") #else /* OLD_WAY */ HGOTO_ERROR(H5E_IO, H5E_BADFILE, NULL, "SRB file stat failed") #endif /* OLD_WAY */ } if (NULL==(file=H5MM_calloc(sizeof(H5FD_srb_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate file struct") file->fd = srb_fid; file->eof = srb_stat.st_size; file->pos = HADDR_UNDEF; file->srb_conn = fa->srb_conn; file->info = fa->info; /* Set return value */ ret_value=(H5FD_t*)file; done: if(ret_value==NULL) { if(fa!=NULL) clFinish(fa->srb_conn); if(srb_fid>=0) srbFileClose(fa->srb_conn, srb_fid); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_srb_close * * Purpose: Closes a file and srb connection. * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Raymond Lu * Modification: *------------------------------------------------------------------------- */ static herr_t H5FD_srb_close(H5FD_t *_file) { H5FD_srb_t *file = (H5FD_srb_t *)_file; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_srb_close, FAIL) srbFileClose(file->srb_conn, file->fd); clFinish(file->srb_conn); H5MM_xfree(file); done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_srb_query * * Purpose: Set the flags that this VFL driver is capable of supporting. * (listed in H5FDpublic.h) * * Return: Success: non-negative * * Failure: negative * * Programmer: Quincey Koziol * Tuesday, September 26, 2000 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_srb_query(const UNUSED H5FD_t *_f, unsigned long *flags /* out */) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_srb_query, FAIL) /* Set the VFL feature flags that this driver supports */ if(flags) { *flags = 0; *flags|=H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ *flags|=H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ } done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_srb_get_eoa * * Purpose: Gets the end-of-address marker for the file. The EOA marker * is the first address past the last byte allocated in the * format address space. * * Return: Success: The end-of-address marker. * * Failure: HADDR_UNDEF * * Programmer: Raymond Lu * April 12, 2000 * * Modifications: *------------------------------------------------------------------------- */ static haddr_t H5FD_srb_get_eoa(H5FD_t *_file) { H5FD_srb_t *file = (H5FD_srb_t *)_file; haddr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_srb_get_eoa, HADDR_UNDEF) /* Set return value */ ret_value=file->eoa; done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_srb_set_eoa * * Purpose: Set the end-of-address marker for the file. This function is * called shortly after an existing HDF5 file is opened in order * to tell the driver where the end of the HDF5 data is located. * * Return: Success: 0 * * Failure: -1 * * Programmer: Robb Matzke * Friday, August 6, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_srb_set_eoa(H5FD_t *_file, haddr_t addr) { H5FD_srb_t *file = (H5FD_srb_t *)_file; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_srb_set_eoa, FAIL) file->eoa = addr; done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_srb_get_eof * * Purpose: Gets the end-of-file marker for the file. The EOF marker * is the real size of the file. * * Return: Success: The end-of-address marker. * * Failure: HADDR_UNDEF * * Programmer: Raymond Lu * April 12, 2000 * * Modifications: *------------------------------------------------------------------------- */ static haddr_t H5FD_srb_get_eof(H5FD_t *_file) { H5FD_srb_t *file = (H5FD_srb_t *)_file; haddr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_srb_get_eof, HADDR_UNDEF) /* Set return value */ ret_value=file->eof; done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_srb_get_handle * * Purpose: Returns the file handle of SRB file driver. * * Returns: Non-negative if succeed or negative if fails. * * Programmer: Raymond Lu * Sept. 16, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_srb_get_handle(H5FD_t *_file, hid_t UNUSED fapl, void** file_handle) { H5FD_srb_t *file = (H5FD_srb_t *)_file; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5FD_srb_get_eof, FAIL) if(!file_handle) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file handle not valid") *file_handle = &(file->fd); done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_srb_read * * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR * into buffer BUF. * * Return: Success: Zero. Result is stored in caller-supplied * buffer BUF. * * Failure: -1, Contents of buffer BUF are undefined. * * Programmer: Raymond Lu *------------------------------------------------------------------------- */ static herr_t H5FD_srb_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, haddr_t addr, size_t size, void *buf) { H5FD_srb_t *file = (H5FD_srb_t*)_file; ssize_t nbytes; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_srb_read, FAIL) /* Check for overflow conditions */ if (HADDR_UNDEF==addr) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "addr undefined") if (REGION_OVERFLOW(addr, size)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr too large") if (addr+size>file->eoa) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr too large") if( addr!=file->pos && srbFileSeek(file->srb_conn, (int)file->fd, (int)addr, SEEK_SET)<0 ) HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "srb file seek failed") /* * Read data, being careful of interrupted system calls, partial results, * and the end of the file. */ while(size>0) { if((nbytes=srbFileRead(file->srb_conn, (int)file->fd, (char*)buf, size))<0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "srb file write failed") if (0==nbytes) { /*end of file but not end of format address space*/ HDmemset(buf, 0, size); size = 0; } size -= nbytes; addr += (haddr_t)nbytes; buf = (char*)buf + nbytes; } /* Update current position */ file->pos = addr; done: if(ret_value<0) { /* Reset file position */ file->pos = HADDR_UNDEF; /* Close connection, etc. */ srbFileClose(file->srb_conn, file->fd); clFinish(file->srb_conn); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_srb_write * * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR * from buffer BUF. * * Return: Success: Zero. * * Failure: -1 * * Programmer: Raymond Lu * April 12, 2000 * Modifications: *------------------------------------------------------------------------- */ static herr_t H5FD_srb_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, haddr_t addr, size_t size, const void *buf) { H5FD_srb_t *file = (H5FD_srb_t*)_file; ssize_t nbytes; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_srb_write, FAIL) /* Check for overflow conditions */ if (HADDR_UNDEF==addr) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "addr undefined") if (REGION_OVERFLOW(addr, size)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr too large") if (addr+size>file->eoa) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr too large") if( addr!=file->pos && srbFileSeek(file->srb_conn, (int)file->fd, (int)addr, SEEK_SET)<0 ) HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "srb file seek failed") while(size>0) { if( (nbytes=srbFileWrite(file->srb_conn, (int)file->fd, (char*)buf, size)) < 0 ) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "srb file write failed") size -= nbytes; addr += (haddr_t)nbytes; buf = (const char*)buf + nbytes; } /* Update current position and eof */ file->pos = addr; if(file->pos > file->eof) file->eof = file->pos; done: if(ret_value<0) { /* Reset file position */ file->pos = HADDR_UNDEF; /* Close connection, etc. */ srbFileClose(file->srb_conn, file->fd); clFinish(file->srb_conn); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_srb_flush * * Purpose: Makes sure that all data is on disk. * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Raymond Lu * April 12, 2000 *------------------------------------------------------------------------- */ static herr_t H5FD_srb_flush(H5FD_t *_file, hid_t dxpl_id, unsigned UNUSED closing) { H5FD_srb_t *file = (H5FD_srb_t*)_file; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_srb_flush, FAIL) if(srbFileSync(file->srb_conn, file->fd) != 0) HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "srb file sync failed") done: if(ret_value<0) { srbFileClose(file->srb_conn, file->fd); clFinish(file->srb_conn); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } #endif /* H5_HAVE_SRB */ xdmf-3.0+git20160803/Utilities/hdf5/H5D.c0000640000175000017500000051000613003006557017421 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #define H5D_PACKAGE /*suppress error about including H5Dpkg */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5D_init_interface #include "H5private.h" /* Generic Functions */ #include "H5Dpkg.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free Lists */ #include "H5FOprivate.h" /* File objects */ #include "H5HLprivate.h" /* Local heaps */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Sprivate.h" /* Dataspaces */ #include "H5Vprivate.h" /* Vectors and arrays */ /*#define H5D_DEBUG*/ /* Local functions */ static herr_t H5D_init_storage(H5D_t *dataset, hbool_t full_overwrite, hid_t dxpl_id); static H5D_shared_t * H5D_new(hid_t dcpl_id, hbool_t creating, hbool_t vl_type); static H5D_t * H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space, hid_t dcpl_id, hid_t dxpl_id); static H5D_t * H5D_open_oid(const H5G_entry_t *ent, hid_t dxpl_id); static herr_t H5D_get_space_status(H5D_t *dset, H5D_space_status_t *allocation, hid_t dxpl_id); static hsize_t H5D_get_storage_size(H5D_t *dset, hid_t dxpl_id); static haddr_t H5D_get_offset(const H5D_t *dset); static herr_t H5D_extend(H5D_t *dataset, const hsize_t *size, hid_t dxpl_id); static herr_t H5D_set_extent(H5D_t *dataset, const hsize_t *size, hid_t dxpl_id); static herr_t H5D_init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, const H5T_t *type); static int H5D_crt_fill_value_cmp(const void *value1, const void *value2, size_t size); static int H5D_crt_ext_file_list_cmp(const void *value1, const void *value2, size_t size); static int H5D_crt_data_pipeline_cmp(const void *value1, const void *value2, size_t size); /* Internal data structure for computing variable-length dataset's total size */ typedef struct { hid_t dataset_id; /* ID of the dataset we are working on */ hid_t fspace_id; /* ID of the file dataset's dataspace we are working on */ hid_t mspace_id; /* ID of the memory dataset's dataspace we are working on */ void *fl_tbuf; /* Ptr to the temporary buffer we are using for fixed-length data */ void *vl_tbuf; /* Ptr to the temporary buffer we are using for VL data */ hid_t xfer_pid; /* ID of the dataset xfer property list */ hsize_t size; /* Accumulated number of bytes for the selection */ } H5D_vlen_bufsize_t; /* Declare a free list to manage the H5D_t and H5D_shared_t structs */ H5FL_DEFINE_STATIC(H5D_t); H5FL_DEFINE_STATIC(H5D_shared_t); /* Declare a free list to manage blocks of VL data */ H5FL_BLK_DEFINE_STATIC(vlen_vl_buf); /* Declare a free list to manage other blocks of VL data */ H5FL_BLK_DEFINE_STATIC(vlen_fl_buf); /* Declare the external PQ free list for the sieve buffer information */ H5FL_BLK_EXTERN(sieve_buf); /* Define a static "default" dataset structure to use to initialize new datasets */ static H5D_shared_t H5D_def_dset; /* Define a "default" dataset transfer property list cache structure to use for default DXPLs */ H5D_dxpl_cache_t H5D_def_dxpl_cache; /*------------------------------------------------------------------------- * Function: H5D_init * * Purpose: Initialize the interface from some other layer. * * Return: Success: non-negative * * Failure: negative * * Programmer: Quincey Koziol * Saturday, March 4, 2000 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5D_init(void) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5D_init, FAIL) /* FUNC_ENTER() does all the work */ done: FUNC_LEAVE_NOAPI(ret_value) } /*-------------------------------------------------------------------------- NAME H5D_init_interface -- Initialize interface-specific information USAGE herr_t H5D_init_interface() RETURNS Non-negative on success/Negative on failure DESCRIPTION Initializes any interface-specific data or routines. NOTES Care must be taken when using the H5P functions, since they can cause a deadlock in the library when the library is attempting to terminate -QAK --------------------------------------------------------------------------*/ static herr_t H5D_init_interface(void) { /* Dataset Transfer property class variables. In sequence, they are, * - Transfer Property list class to modify * - Default value for maximum temp buffer size * - Default value for type conversion buffer * - Default value for background buffer * - Default value for B-tree node split ratios * - Default value for hyperslab caching * - Default value for hyperslab cache limit * - Default value for vlen allocation function * - Default value for vlen allocation information * - Default value for vlen free function * - Default value for vlen free information * - Default value for file driver ID * - Default value for file driver info * - Default value for 'gather reads' property * - Default value for vector size * - Default value for I/O transfer mode * - Default value for EDC property * - Default value for filter callback */ H5P_genclass_t *xfer_pclass; size_t def_max_temp_buf = H5D_XFER_MAX_TEMP_BUF_DEF; void *def_tconv_buf = H5D_XFER_TCONV_BUF_DEF; void *def_bkgr_buf = H5D_XFER_BKGR_BUF_DEF; H5T_bkg_t def_bkgr_buf_type = H5D_XFER_BKGR_BUF_TYPE_DEF; double def_btree_split_ratio[3] = H5D_XFER_BTREE_SPLIT_RATIO_DEF; #ifdef H5_WANT_H5_V1_4_COMPAT unsigned def_hyper_cache = H5D_XFER_HYPER_CACHE_DEF; unsigned def_hyper_cache_lim = H5D_XFER_HYPER_CACHE_LIM_DEF; #endif /* H5_WANT_H5_V1_4_COMPAT */ H5MM_allocate_t def_vlen_alloc = H5D_XFER_VLEN_ALLOC_DEF; void *def_vlen_alloc_info = H5D_XFER_VLEN_ALLOC_INFO_DEF; H5MM_free_t def_vlen_free = H5D_XFER_VLEN_FREE_DEF; void *def_vlen_free_info = H5D_XFER_VLEN_FREE_INFO_DEF; hid_t def_vfl_id = H5D_XFER_VFL_ID_DEF; void *def_vfl_info = H5D_XFER_VFL_INFO_DEF; size_t def_hyp_vec_size = H5D_XFER_HYPER_VECTOR_SIZE_DEF; #ifdef H5_HAVE_PARALLEL H5FD_mpio_xfer_t def_io_xfer_mode = H5D_XFER_IO_XFER_MODE_DEF; #endif /* H5_HAVE_PARALLEL */ H5Z_EDC_t enable_edc = H5D_XFER_EDC_DEF; H5Z_cb_t filter_cb = H5D_XFER_FILTER_CB_DEF; /* Dataset creation property class variables. In sequence, they are, * - Creation property list class to modify * - Default value for storage layout property * - Default value for chunk dimensionality property * - Default value for chunk size * - Default value for fill value * - Default value for external file list * - Default value for data filter pipeline */ H5P_genclass_t *crt_pclass; H5D_layout_t layout = H5D_CRT_LAYOUT_DEF; unsigned chunk_ndims = H5D_CRT_CHUNK_DIM_DEF; size_t chunk_size[H5O_LAYOUT_NDIMS] = H5D_CRT_CHUNK_SIZE_DEF; H5O_fill_t fill = H5D_CRT_FILL_VALUE_DEF; H5D_alloc_time_t alloc_time = H5D_CRT_ALLOC_TIME_DEF; unsigned alloc_time_state = H5D_CRT_ALLOC_TIME_STATE_DEF; H5D_fill_time_t fill_time = H5D_CRT_FILL_TIME_DEF; H5O_efl_t efl = H5D_CRT_EXT_FILE_LIST_DEF; H5O_pline_t pline = H5D_CRT_DATA_PIPELINE_DEF; H5P_genplist_t *def_dcpl; /* Default Dataset Creation Property list */ size_t nprops; /* Number of properties */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5D_init_interface) /* Initialize the atom group for the dataset IDs */ if (H5I_init_group(H5I_DATASET, H5I_DATASETID_HASHSIZE, H5D_RESERVED_ATOMS, (H5I_free_t)H5D_close)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize interface") /* =========Dataset Transfer Property Class Initialization========= */ /* Register the default dataset transfer properties */ assert(H5P_CLS_DATASET_XFER_g!=(-1)); /* Get the pointer to the dataset transfer class */ if (NULL == (xfer_pclass = H5I_object(H5P_CLS_DATASET_XFER_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class") /* Get the number of properties in the class */ if(H5P_get_nprops_pclass(xfer_pclass,&nprops)<0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't query number of properties") /* Assume that if there are properties in the class, they are the default ones */ if(nprops==0) { /* Register the max. temp buffer size property */ if(H5P_register(xfer_pclass,H5D_XFER_MAX_TEMP_BUF_NAME,H5D_XFER_MAX_TEMP_BUF_SIZE,&def_max_temp_buf,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the type conversion buffer property */ if(H5P_register(xfer_pclass,H5D_XFER_TCONV_BUF_NAME,H5D_XFER_TCONV_BUF_SIZE,&def_tconv_buf,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the background buffer property */ if(H5P_register(xfer_pclass,H5D_XFER_BKGR_BUF_NAME,H5D_XFER_BKGR_BUF_SIZE,&def_bkgr_buf,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the background buffer type property */ if(H5P_register(xfer_pclass,H5D_XFER_BKGR_BUF_TYPE_NAME,H5D_XFER_BKGR_BUF_TYPE_SIZE,&def_bkgr_buf_type,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the B-Tree node splitting ratios property */ if(H5P_register(xfer_pclass,H5D_XFER_BTREE_SPLIT_RATIO_NAME,H5D_XFER_BTREE_SPLIT_RATIO_SIZE,def_btree_split_ratio,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") #ifdef H5_WANT_H5_V1_4_COMPAT /* Register the hyperslab caching property */ if(H5P_register(xfer_pclass,H5D_XFER_HYPER_CACHE_NAME,H5D_XFER_HYPER_CACHE_SIZE,&def_hyper_cache,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the hyperslab cache limit property */ if(H5P_register(xfer_pclass,H5D_XFER_HYPER_CACHE_LIM_NAME,H5D_XFER_HYPER_CACHE_LIM_SIZE,&def_hyper_cache_lim,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") #endif /* H5_WANT_H5_V1_4_COMPAT */ /* Register the vlen allocation function property */ if(H5P_register(xfer_pclass,H5D_XFER_VLEN_ALLOC_NAME,H5D_XFER_VLEN_ALLOC_SIZE,&def_vlen_alloc,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the vlen allocation information property */ if(H5P_register(xfer_pclass,H5D_XFER_VLEN_ALLOC_INFO_NAME,H5D_XFER_VLEN_ALLOC_INFO_SIZE,&def_vlen_alloc_info,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the vlen free function property */ if(H5P_register(xfer_pclass,H5D_XFER_VLEN_FREE_NAME,H5D_XFER_VLEN_FREE_SIZE,&def_vlen_free,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the vlen free information property */ if(H5P_register(xfer_pclass,H5D_XFER_VLEN_FREE_INFO_NAME,H5D_XFER_VLEN_FREE_INFO_SIZE,&def_vlen_free_info,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the file driver ID property */ if(H5P_register(xfer_pclass,H5D_XFER_VFL_ID_NAME,H5D_XFER_VFL_ID_SIZE,&def_vfl_id,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the file driver info property */ if(H5P_register(xfer_pclass,H5D_XFER_VFL_INFO_NAME,H5D_XFER_VFL_INFO_SIZE,&def_vfl_info,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the vector size property */ if(H5P_register(xfer_pclass,H5D_XFER_HYPER_VECTOR_SIZE_NAME,H5D_XFER_HYPER_VECTOR_SIZE_SIZE,&def_hyp_vec_size,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") #ifdef H5_HAVE_PARALLEL /* Register the I/O transfer mode property */ if(H5P_register(xfer_pclass,H5D_XFER_IO_XFER_MODE_NAME,H5D_XFER_IO_XFER_MODE_SIZE,&def_io_xfer_mode,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") #endif /* H5_HAVE_PARALLEL */ /* Register the EDC property */ if(H5P_register(xfer_pclass,H5D_XFER_EDC_NAME,H5D_XFER_EDC_SIZE,&enable_edc,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the filter callback property */ if(H5P_register(xfer_pclass,H5D_XFER_FILTER_CB_NAME,H5D_XFER_FILTER_CB_SIZE,&filter_cb,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") } /* end if */ /* Only register the default property list if it hasn't been created yet */ if(H5P_LST_DATASET_XFER_g==(-1)) { /* Register the default data transfer property list */ if ((H5P_LST_DATASET_XFER_g = H5P_create_id (xfer_pclass))<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't register default property list") } /* end if */ /* =========Dataset Creation Property Class Initialization========== */ /* Register the default dataset creation properties */ assert(H5P_CLS_DATASET_CREATE_g != -1); /* Get the pointer to the dataset creation class */ if(NULL == (crt_pclass = H5I_object(H5P_CLS_DATASET_CREATE_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class") /* Get the number of properties in the class */ if(H5P_get_nprops_pclass(crt_pclass,&nprops)<0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't query number of properties") /* Assume that if there are properties in the class, they are the default ones */ if(nprops==0) { /* Register the storage layout property */ if(H5P_register(crt_pclass, H5D_CRT_LAYOUT_NAME, H5D_CRT_LAYOUT_SIZE, &layout, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the chunking dimensionality property */ if(H5P_register(crt_pclass, H5D_CRT_CHUNK_DIM_NAME, H5D_CRT_CHUNK_DIM_SIZE, &chunk_ndims, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the chunking size property */ if(H5P_register(crt_pclass, H5D_CRT_CHUNK_SIZE_NAME, H5D_CRT_CHUNK_SIZE_SIZE, chunk_size, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the fill value property */ if(H5P_register(crt_pclass, H5D_CRT_FILL_VALUE_NAME, H5D_CRT_FILL_VALUE_SIZE, &fill, NULL, NULL, NULL, NULL, NULL, H5D_CRT_FILL_VALUE_CMP, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the space allocation time property */ if(H5P_register(crt_pclass, H5D_CRT_ALLOC_TIME_NAME, H5D_CRT_ALLOC_TIME_SIZE, &alloc_time, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the space allocation time state property */ if(H5P_register(crt_pclass, H5D_CRT_ALLOC_TIME_STATE_NAME, H5D_CRT_ALLOC_TIME_STATE_SIZE, &alloc_time_state, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the fill value writing time property */ if(H5P_register(crt_pclass, H5D_CRT_FILL_TIME_NAME, H5D_CRT_FILL_TIME_SIZE, &fill_time, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the external file list property */ if(H5P_register(crt_pclass, H5D_CRT_EXT_FILE_LIST_NAME, H5D_CRT_EXT_FILE_LIST_SIZE, &efl, NULL, NULL, NULL, NULL, NULL, H5D_CRT_EXT_FILE_LIST_CMP, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the data pipeline property */ if(H5P_register(crt_pclass, H5D_CRT_DATA_PIPELINE_NAME, H5D_CRT_DATA_PIPELINE_SIZE, &pline, NULL, NULL, NULL, NULL, NULL, H5D_CRT_DATA_PIPELINE_CMP, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") } /* end if */ /* Only register the default property list if it hasn't been created yet */ if(H5P_LST_DATASET_CREATE_g==(-1)) { /* Register the default data transfer property list */ if ((H5P_LST_DATASET_CREATE_g = H5P_create_id (crt_pclass))<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't register default property list") } /* end if */ /* Reset the "default dataset" information */ HDmemset(&H5D_def_dset,0,sizeof(H5D_shared_t)); /* Get the default dataset cretion property list values and initialize the * default dataset with them. */ if (NULL == (def_dcpl = H5I_object(H5P_LST_DATASET_CREATE_g))) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "can't get default dataset creation property list") /* Set up the default allocation time information */ if(H5P_get(def_dcpl, H5D_CRT_ALLOC_TIME_NAME, &H5D_def_dset.alloc_time) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve space allocation time") /* Get the default external file list information */ if(H5P_get(def_dcpl, H5D_CRT_EXT_FILE_LIST_NAME, &H5D_def_dset.efl) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve external file list") /* Get the default data storage method */ if(H5P_get(def_dcpl, H5D_CRT_LAYOUT_NAME, &H5D_def_dset.layout.type) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve layout") /* Get the default fill value time */ if (H5P_get(def_dcpl, H5D_CRT_FILL_TIME_NAME, &H5D_def_dset.fill_time) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve fill time") /* Get the default fill value */ if (H5P_get(def_dcpl, H5D_CRT_FILL_VALUE_NAME, &H5D_def_dset.fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve fill value") /* Reset the "default DXPL cache" information */ HDmemset(&H5D_def_dxpl_cache,0,sizeof(H5D_dxpl_cache_t)); /* Get the default DXPL cache information */ if (H5D_get_dxpl_cache_real(H5P_DATASET_XFER_DEFAULT, &H5D_def_dxpl_cache) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve default DXPL info") done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5D_term_interface * * Purpose: Terminate this interface. * * Return: Success: Positive if anything was done that might * affect other interfaces; zero otherwise. * * Failure: Negative. * * Programmer: Robb Matzke * Friday, November 20, 1998 * * Modifications: * *------------------------------------------------------------------------- */ int H5D_term_interface(void) { int n=0; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_term_interface) if (H5_interface_initialize_g) { if ((n=H5I_nmembers(H5I_DATASET))>0) { /* The dataset API uses the "force" flag set to true because it * is using the "file objects" (H5FO) API functions to track open * objects in the file. Using the H5FO code means that dataset * IDs can have reference counts >1, when an existing dataset is * opened more than once. However, the H5I code does not attempt * to close objects with reference counts>1 unless the "force" flag * is set to true. * * At some point (probably after the group and datatypes use the * the H5FO code), the H5FO code might need to be switched around * to storing pointers to the objects being tracked (H5D_t, H5G_t, * etc) and reference count those itself instead of relying on the * reference counting in the H5I layer. Then, the "force" flag can * be put back to false. * * Setting the "force" flag to true for all the interfaces won't * work because the "file driver" (H5FD) APIs use the H5I reference * counting to avoid closing a file driver out from underneath an * open file... * * QAK - 5/13/03 */ H5I_clear_group(H5I_DATASET, TRUE); } else { H5I_destroy_group(H5I_DATASET); H5_interface_initialize_g = 0; n = 1; /*H5I*/ } } FUNC_LEAVE_NOAPI(n) } /*------------------------------------------------------------------------- * Function: H5D_crt_copy * * Purpose: Callback routine which is called whenever any dataset * creation property list is copied. This routine copies * the properties from the old list to the new list. * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Raymond Lu * Tuesday, October 2, 2001 * * Modification: * *------------------------------------------------------------------------- */ /* ARGSUSED */ herr_t H5D_crt_copy(hid_t new_plist_id, hid_t old_plist_id, void UNUSED *copy_data) { H5O_fill_t src_fill, dst_fill; H5O_efl_t src_efl, dst_efl; H5O_pline_t src_pline, dst_pline; H5P_genplist_t *old_plist; H5P_genplist_t *new_plist; herr_t ret_value=SUCCEED; FUNC_ENTER_NOAPI(H5D_crt_copy, FAIL) /* Verify property list ID */ if (NULL == (new_plist = H5I_object(new_plist_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list") if (NULL == (old_plist = H5I_object(old_plist_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list") /* Get the fill value, external file list, and data pipeline properties * from the old property list */ if(H5P_get(old_plist, H5D_CRT_FILL_VALUE_NAME, &src_fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value") if(H5P_get(old_plist, H5D_CRT_EXT_FILE_LIST_NAME, &src_efl) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external file list") if(H5P_get(old_plist, H5D_CRT_DATA_PIPELINE_NAME, &src_pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") /* Make copies of fill value, external file list, and data pipeline */ if(src_fill.buf) { if(NULL==H5O_copy(H5O_FILL_ID, &src_fill, &dst_fill)) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't copy fill value") } /* end if */ else { dst_fill.type = dst_fill.buf = NULL; dst_fill.size = src_fill.size; } HDmemset(&dst_efl,0,sizeof(H5O_efl_t)); if(NULL==H5O_copy(H5O_EFL_ID, &src_efl, &dst_efl)) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't copy external file list") if(NULL==H5O_copy(H5O_PLINE_ID, &src_pline, &dst_pline)) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't copy data pipeline") /* Set the fill value, external file list, and data pipeline property * for the new property list */ if(H5P_set(new_plist, H5D_CRT_FILL_VALUE_NAME, &dst_fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set fill value") if(H5P_set(new_plist, H5D_CRT_EXT_FILE_LIST_NAME, &dst_efl) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set external file list") if(H5P_set(new_plist, H5D_CRT_DATA_PIPELINE_NAME, &dst_pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set pipeline") done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5D_crt_close * * Purpose: Callback routine which is called whenever any dataset create * property list is closed. This routine performs any generic * cleanup needed on the properties the library put into the list. * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Quincey Koziol * Wednesday, July 11, 2001 * * Modifications: * *------------------------------------------------------------------------- */ /* ARGSUSED */ herr_t H5D_crt_close(hid_t dcpl_id, void UNUSED *close_data) { H5O_fill_t fill; H5O_efl_t efl; H5O_pline_t pline; H5P_genplist_t *plist; /* Property list */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5D_crt_close, FAIL) /* Check arguments */ if (NULL == (plist = H5I_object(dcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list") /* Get the fill value, external file list, and data pipeline properties * from the old property list */ if(H5P_get(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value") if(H5P_get(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external file list") if(H5P_get(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") /* Clean up any values set for the fill-value, external file-list and * data pipeline */ if(H5O_reset(H5O_FILL_ID, &fill)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't release fill info") if(H5O_reset(H5O_EFL_ID, &efl)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't release external file list info") if(H5O_reset(H5O_PLINE_ID, &pline)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't release pipeline info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_crt_close() */ /*------------------------------------------------------------------------- * Function: H5D_crt_fill_value_cmp * * Purpose: Callback routine which is called whenever the fill value * property in the dataset creation property list is compared. * * Return: positive if VALUE1 is greater than VALUE2, negative if * VALUE2 is greater than VALUE1 and zero if VALUE1 and * VALUE2 are equal. * * Programmer: Quincey Koziol * Wednesday, January 7, 2004 * * Modification: * *------------------------------------------------------------------------- */ static int H5D_crt_fill_value_cmp(const void *value1, const void *value2, size_t UNUSED size) { const H5O_fill_t *fill1=(const H5O_fill_t *)value1, /* Create local aliases for values */ *fill2=(const H5O_fill_t *)value2; int cmp_value; /* Value from comparison */ herr_t ret_value=0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_crt_fill_value_cmp) /* Sanity check */ assert(fill1); assert(fill2); assert(size==sizeof(H5O_fill_t)); /* Check the size of fill values */ if(fill1->size < fill2->size) HGOTO_DONE(-1); if(fill1->size > fill2->size) HGOTO_DONE(1); /* Check the types of the fill values */ if(fill1->type==NULL && fill2->type!=NULL) HGOTO_DONE(-1); if(fill1->type!=NULL && fill2->type==NULL) HGOTO_DONE(1); if(fill1->type!=NULL) if((cmp_value=H5T_cmp(fill1->type,fill2->type, FALSE))!=0) HGOTO_DONE(cmp_value); /* Check the fill values in the buffers */ if(fill1->buf==NULL && fill2->buf!=NULL) HGOTO_DONE(-1); if(fill1->buf!=NULL && fill2->buf==NULL) HGOTO_DONE(1); if(fill1->buf!=NULL) if((cmp_value=HDmemcmp(fill1->buf,fill2->buf,fill1->size))!=0) HGOTO_DONE(cmp_value); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_crt_fill_value_cmp() */ /*------------------------------------------------------------------------- * Function: H5D_crt_ext_file_list_cmp * * Purpose: Callback routine which is called whenever the external file * list property in the dataset creation property list is * compared. * * Return: positive if VALUE1 is greater than VALUE2, negative if * VALUE2 is greater than VALUE1 and zero if VALUE1 and * VALUE2 are equal. * * Programmer: Quincey Koziol * Wednesday, January 7, 2004 * * Modification: * *------------------------------------------------------------------------- */ static int H5D_crt_ext_file_list_cmp(const void *value1, const void *value2, size_t UNUSED size) { const H5O_efl_t *efl1=(const H5O_efl_t *)value1, /* Create local aliases for values */ *efl2=(const H5O_efl_t *)value2; int cmp_value; /* Value from comparison */ herr_t ret_value=0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_crt_ext_file_list_cmp) /* Sanity check */ assert(efl1); assert(efl2); assert(size==sizeof(H5O_efl_t)); /* Check the heap address of external file lists */ if(H5F_addr_defined(efl1->heap_addr) || H5F_addr_defined(efl2->heap_addr)) { if(!H5F_addr_defined(efl1->heap_addr) && H5F_addr_defined(efl2->heap_addr)) HGOTO_DONE(-1); if(H5F_addr_defined(efl1->heap_addr) && !H5F_addr_defined(efl2->heap_addr)) HGOTO_DONE(1); if((cmp_value=H5F_addr_cmp(efl1->heap_addr,efl2->heap_addr))!=0) HGOTO_DONE(cmp_value); } /* end if */ /* Check the number of allocated efl entries */ if(efl1->nalloc < efl2->nalloc) HGOTO_DONE(-1); if(efl1->nalloc > efl2->nalloc) HGOTO_DONE(1); /* Check the number of used efl entries */ if(efl1->nused < efl2->nused) HGOTO_DONE(-1); if(efl1->nused > efl2->nused) HGOTO_DONE(1); /* Check the efl entry information */ if(efl1->slot==NULL && efl2->slot!=NULL) HGOTO_DONE(-1); if(efl1->slot!=NULL && efl2->slot==NULL) HGOTO_DONE(1); if(efl1->slot!=NULL && efl1->nused>0) { size_t u; /* Local index variable */ /* Loop through all entries, comparing them */ for(u=0; unused; u++) { /* Check the name offset of the efl entry */ if(efl1->slot[u].name_offset < efl2->slot[u].name_offset) HGOTO_DONE(-1); if(efl1->slot[u].name_offset > efl2->slot[u].name_offset) HGOTO_DONE(1); /* Check the name of the efl entry */ if(efl1->slot[u].name==NULL && efl2->slot[u].name!=NULL) HGOTO_DONE(-1); if(efl1->slot[u].name!=NULL && efl2->slot[u].name==NULL) HGOTO_DONE(1); if(efl1->slot[u].name!=NULL) if((cmp_value=HDstrcmp(efl1->slot[u].name,efl2->slot[u].name))!=0) HGOTO_DONE(cmp_value); /* Check the file offset of the efl entry */ if(efl1->slot[u].offset < efl2->slot[u].offset) HGOTO_DONE(-1); if(efl1->slot[u].offset > efl2->slot[u].offset) HGOTO_DONE(1); /* Check the file size of the efl entry */ if(efl1->slot[u].size < efl2->slot[u].size) HGOTO_DONE(-1); if(efl1->slot[u].size > efl2->slot[u].size) HGOTO_DONE(1); } /* end for */ } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_crt_ext_file_list_cmp() */ /*------------------------------------------------------------------------- * Function: H5D_crt_data_pipeline_cmp * * Purpose: Callback routine which is called whenever the filter pipeline * property in the dataset creation property list is compared. * * Return: positive if VALUE1 is greater than VALUE2, negative if * VALUE2 is greater than VALUE1 and zero if VALUE1 and * VALUE2 are equal. * * Programmer: Quincey Koziol * Wednesday, January 7, 2004 * * Modification: * *------------------------------------------------------------------------- */ static int H5D_crt_data_pipeline_cmp(const void *value1, const void *value2, size_t UNUSED size) { const H5O_pline_t *pline1=(const H5O_pline_t *)value1, /* Create local aliases for values */ *pline2=(const H5O_pline_t *)value2; int cmp_value; /* Value from comparison */ herr_t ret_value=0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_crt_data_pipeline_cmp) /* Sanity check */ assert(pline1); assert(pline2); assert(size==sizeof(H5O_pline_t)); /* Check the number of allocated pipeline entries */ if(pline1->nalloc < pline2->nalloc) HGOTO_DONE(-1); if(pline1->nalloc > pline2->nalloc) HGOTO_DONE(1); /* Check the number of used pipeline entries */ if(pline1->nused < pline2->nused) HGOTO_DONE(-1); if(pline1->nused > pline2->nused) HGOTO_DONE(1); /* Check the filter entry information */ if(pline1->filter==NULL && pline2->filter!=NULL) HGOTO_DONE(-1); if(pline1->filter!=NULL && pline2->filter==NULL) HGOTO_DONE(1); if(pline1->filter!=NULL && pline1->nused>0) { size_t u; /* Local index variable */ /* Loop through all filters, comparing them */ for(u=0; unused; u++) { /* Check the ID of the filter */ if(pline1->filter[u].id < pline2->filter[u].id) HGOTO_DONE(-1); if(pline1->filter[u].id > pline2->filter[u].id) HGOTO_DONE(1); /* Check the flags for the filter */ if(pline1->filter[u].flags < pline2->filter[u].flags) HGOTO_DONE(-1); if(pline1->filter[u].flags > pline2->filter[u].flags) HGOTO_DONE(1); /* Check the name of the filter */ if(pline1->filter[u].name==NULL && pline2->filter[u].name!=NULL) HGOTO_DONE(-1); if(pline1->filter[u].name!=NULL && pline2->filter[u].name==NULL) HGOTO_DONE(1); if(pline1->filter[u].name!=NULL) if((cmp_value=HDstrcmp(pline1->filter[u].name,pline2->filter[u].name))!=0) HGOTO_DONE(cmp_value); /* Check the number of parameters for the filter */ if(pline1->filter[u].cd_nelmts < pline2->filter[u].cd_nelmts) HGOTO_DONE(-1); if(pline1->filter[u].cd_nelmts > pline2->filter[u].cd_nelmts) HGOTO_DONE(1); /* Check the filter parameter information */ if(pline1->filter[u].cd_values==NULL && pline2->filter[u].cd_values!=NULL) HGOTO_DONE(-1); if(pline1->filter[u].cd_values!=NULL && pline2->filter[u].cd_values==NULL) HGOTO_DONE(1); if(pline1->filter[u].cd_values!=NULL && pline1->filter[u].cd_nelmts>0) { size_t v; /* Local index variable */ /* Loop through all parameters, comparing them */ for(v=0; vfilter[u].cd_nelmts; v++) { /* Check each parameter for the filter */ if(pline1->filter[u].cd_values[v] < pline2->filter[u].cd_values[v]) HGOTO_DONE(-1); if(pline1->filter[u].cd_values[v] > pline2->filter[u].cd_values[v]) HGOTO_DONE(1); } /* end for */ } /* end if */ } /* end for */ } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_crt_data_pipeline_cmp() */ /*------------------------------------------------------------------------- * Function: H5D_xfer_create * * Purpose: Callback routine which is called whenever any dataset transfer * property list is created. This routine performs any generic * initialization needed on the properties the library put into * the list. * Right now, it's just allocating the driver-specific dataset * transfer information. * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Quincey Koziol * Thursday, August 2, 2001 * * Notes: This same routine is currently used for the 'copy' callback. * Modifications: * *------------------------------------------------------------------------- */ /* ARGSUSED */ herr_t H5D_xfer_create(hid_t dxpl_id, void UNUSED *create_data) { hid_t driver_id; /* VFL driver ID */ void *driver_info; /* VFL driver info */ H5P_genplist_t *plist; /* Property list */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5D_xfer_create, FAIL) /* Check arguments */ if (NULL == (plist = H5I_object(dxpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list") /* Get the driver information */ if(H5P_get(plist, H5D_XFER_VFL_ID_NAME, &driver_id)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve VFL driver ID") if(H5P_get(plist, H5D_XFER_VFL_INFO_NAME, &driver_info)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve VFL driver info") /* Check if we have a valid driver ID */ if(driver_id>0) { /* Set the driver for the property list */ if(H5FD_dxpl_open(plist, driver_id, driver_info)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set driver") } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_xfer_create() */ /*------------------------------------------------------------------------- * Function: H5D_xfer_copy * * Purpose: Callback routine which is called whenever any dataset * transfer property list is copied. This routine copies * the properties from the old list to the new list. * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Raymond Lu * Tuesday, October 2, 2001 * * Modification: * *------------------------------------------------------------------------- */ /* ARGSUSED */ herr_t H5D_xfer_copy(hid_t new_dxpl_id, hid_t old_dxpl_id, void UNUSED *copy_data) { hid_t driver_id; void* driver_info; H5P_genplist_t *new_plist; /* New property list */ H5P_genplist_t *old_plist; /* Old property list */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5D_xfer_copy, FAIL) if(NULL == (new_plist = H5I_object(new_dxpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") if(NULL == (old_plist = H5I_object(old_dxpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") /* Get values from old property list */ if(H5P_get(old_plist, H5D_XFER_VFL_ID_NAME, &driver_id)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve VFL driver ID") if(H5P_get(old_plist, H5D_XFER_VFL_INFO_NAME, &driver_info)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get drver info") if(driver_id > 0) { /* Set the driver for the property list */ if(H5FD_dxpl_open(new_plist, driver_id, driver_info)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set driver") } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5D_xfer_close * * Purpose: Callback routine which is called whenever any dataset transfer * property list is closed. This routine performs any generic * cleanup needed on the properties the library put into the list. * Right now, it's just freeing the driver-specific dataset * transfer information. * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Quincey Koziol * Wednesday, July 11, 2001 * * Modifications: * *------------------------------------------------------------------------- */ /* ARGSUSED */ herr_t H5D_xfer_close(hid_t dxpl_id, void UNUSED *close_data) { hid_t driver_id; /* VFL driver ID */ void *driver_info; /* VFL driver info */ H5P_genplist_t *plist; /* Property list */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5D_xfer_close, FAIL) /* Check arguments */ if (NULL == (plist = H5I_object(dxpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list") if(H5P_get(plist, H5D_XFER_VFL_ID_NAME, &driver_id)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTGET, FAIL, "Can't retrieve VFL driver ID") if(H5P_get(plist, H5D_XFER_VFL_INFO_NAME, &driver_info)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTGET, FAIL, "Can't retrieve VFL driver info") if(driver_id>0) { /* Close the driver for the property list */ if(H5FD_dxpl_close(driver_id, driver_info)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't reset driver") } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_xfer_close() */ /*-------------------------------------------------------------------------- NAME H5D_get_dcpl_cache PURPOSE Get all the values for the DCPL cache. USAGE herr_t H5D_get_dcpl_cache(dcpl_id, cache) hid_t dcpl_id; IN: DCPL to query H5D_dcpl_cache_t *cache;IN/OUT: DCPL cache to fill with values RETURNS Non-negative on success/Negative on failure. DESCRIPTION Query all the values from a DCPL that are needed by internal routines within the library. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5D_get_dcpl_cache(hid_t dcpl_id, H5D_dcpl_cache_t *cache) { H5P_genplist_t *dc_plist; /* Data transfer property list */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5D_get_dcpl_cache) /* Check args */ assert(cache); /* Get the dataset transfer property list */ if (NULL == (dc_plist = H5I_object(dcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list") /* Get I/O pipeline info */ if(H5P_get(dc_plist, H5D_CRT_DATA_PIPELINE_NAME, &cache->pline)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTGET, FAIL, "Can't retrieve I/O pipeline info") /* Get fill value info */ if(H5P_get(dc_plist, H5D_CRT_FILL_VALUE_NAME, &cache->fill)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTGET, FAIL, "Can't retrieve fill value info") /* Get fill time info */ if(H5P_get(dc_plist, H5D_CRT_FILL_TIME_NAME, &cache->fill_time)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTGET, FAIL, "Can't retrieve fill time") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D_get_dcpl_cache() */ /*------------------------------------------------------------------------- * Function: H5Dcreate * * Purpose: Creates a new dataset named NAME at LOC_ID, opens the * dataset for access, and associates with that dataset constant * and initial persistent properties including the type of each * datapoint as stored in the file (TYPE_ID), the size of the * dataset (SPACE_ID), and other initial miscellaneous * properties (DCPL_ID). * * All arguments are copied into the dataset, so the caller is * allowed to derive new types, data spaces, and creation * parameters from the old ones and reuse them in calls to * create other datasets. * * Return: Success: The object ID of the new dataset. At this * point, the dataset is ready to receive its * raw data. Attempting to read raw data from * the dataset will probably return the fill * value. The dataset should be closed when * the caller is no longer interested in it. * * Failure: FAIL * * Errors: * ARGS BADTYPE Not a data space. * ARGS BADTYPE Not a dataset creation plist. * ARGS BADTYPE Not a file. * ARGS BADTYPE Not a type. * ARGS BADVALUE No name. * DATASET CANTINIT Can't create dataset. * DATASET CANTREGISTER Can't register dataset. * * Programmer: Robb Matzke * Wednesday, December 3, 1997 * * Modifications: * *------------------------------------------------------------------------- */ hid_t H5Dcreate(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t dcpl_id) { H5G_entry_t *loc = NULL; /* Entry for group to insert dataset into */ H5D_t *new_dset = NULL; /* New dataset's info */ const H5S_t *space; /* Dataspace for dataset */ hid_t ret_value; /* Return value */ FUNC_ENTER_API(H5Dcreate, FAIL) H5TRACE5("i","isiii",loc_id,name,type_id,space_id,dcpl_id); /* Check arguments */ if (NULL == (loc = H5G_loc(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID") if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") if (H5I_DATATYPE != H5I_get_type(type_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype ID") if (NULL == (space = H5I_object_verify(space_id,H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace ID") if(H5P_DEFAULT == dcpl_id) dcpl_id = H5P_DATASET_CREATE_DEFAULT; else if(TRUE != H5P_isa_class(dcpl_id, H5P_DATASET_CREATE)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not dataset create property list ID") /* build and open the new dataset */ if (NULL == (new_dset = H5D_create(loc, name, type_id, space, dcpl_id, H5AC_dxpl_id))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset") /* Register the new dataset to get an ID for it */ if ((ret_value = H5I_register(H5I_DATASET, new_dset)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register dataset") done: if(ret_value<0) { if(new_dset!=NULL) { if(H5D_close(new_dset)<0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset") } /* end if */ } /* end if */ FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5Dopen * * Purpose: Finds a dataset named NAME at LOC_ID, opens it, and returns * its ID. The dataset should be close when the caller is no * longer interested in it. * * Return: Success: A new dataset ID * * Failure: FAIL * * Errors: * * Programmer: Robb Matzke * Thursday, December 4, 1997 * * Modifications: * *------------------------------------------------------------------------- */ hid_t H5Dopen(hid_t loc_id, const char *name) { H5D_t *dset = NULL; H5G_entry_t *loc = NULL; /*location holding the dataset */ H5G_entry_t ent; /*dataset symbol table entry */ hbool_t ent_found = FALSE; /* Entry at 'name' found */ hid_t dxpl_id = H5AC_dxpl_id; /* dxpl to use to open datset */ hid_t ret_value; FUNC_ENTER_API(H5Dopen, FAIL) H5TRACE2("i","is",loc_id,name); /* Check args */ if (NULL == (loc = H5G_loc(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") /* Find the dataset object */ if (H5G_find(loc, name, &ent, dxpl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, FAIL, "not found") ent_found = TRUE; /* Check that the object found is the correct type */ if (H5G_get_type(&ent, dxpl_id) != H5G_DATASET) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a dataset") /* Open the dataset */ if ((dset = H5D_open(&ent, dxpl_id))==NULL) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't open dataset") /* Register an atom for the dataset */ if((ret_value=H5I_register(H5I_DATASET, dset)) <0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "can't register dataset atom") done: if(ret_value < 0) { if(dset != NULL) { if(H5D_close(dset) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset") } /* end if */ else { if(ent_found && ent.header) H5G_free_ent_name(&ent); } /* end else */ } /* end if */ FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5Dclose * * Purpose: Closes access to a dataset (DATASET_ID) and releases * resources used by it. It is illegal to subsequently use that * same dataset ID in calls to other dataset functions. * * Return: Non-negative on success/Negative on failure * * Errors: * ARGS BADTYPE Not a dataset. * DATASET CANTINIT Can't free. * * Programmer: Robb Matzke * Thursday, December 4, 1997 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Dclose(hid_t dset_id) { H5D_t *dset = NULL; /* Dataset object to release */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Dclose, FAIL) H5TRACE1("e","i",dset_id); /* Check args */ if (NULL == (dset = H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") if (NULL == dset->ent.file) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a dataset") /* * Decrement the counter on the dataset. It will be freed if the count * reaches zero. */ if (H5I_dec_ref(dset_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't free") done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5Dget_space * * Purpose: Returns a copy of the file data space for a dataset. * * Return: Success: ID for a copy of the data space. The data * space should be released by calling * H5Sclose(). * * Failure: FAIL * * Programmer: Robb Matzke * Wednesday, January 28, 1998 * * Modifications: * Robb Matzke, 9 Jun 1998 * The data space is not constant and is no longer cached by the dataset * struct. *------------------------------------------------------------------------- */ hid_t H5Dget_space(hid_t dset_id) { H5D_t *dset = NULL; H5S_t *space = NULL; hid_t ret_value; FUNC_ENTER_API(H5Dget_space, FAIL) H5TRACE1("i","i",dset_id); /* Check args */ if (NULL==(dset=H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") /* Read the data space message and return a data space object */ if (NULL==(space=H5S_copy (dset->shared->space, FALSE))) HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get data space") /* Create an atom */ if ((ret_value=H5I_register (H5I_DATASPACE, space))<0) HGOTO_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register data space") done: if(ret_value<0) { if(space!=NULL) { if(H5S_close(space)<0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace") } /* end if */ } /* end if */ FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5Dget_space_status * * Purpose: Returns the status of data space allocation. * * Return: * Success: Non-negative * * Failture: Negative * * Programmer: Raymond Lu * * Modification: * *------------------------------------------------------------------------- */ herr_t H5Dget_space_status(hid_t dset_id, H5D_space_status_t *allocation) { H5D_t *dset = NULL; herr_t ret_value = SUCCEED; FUNC_ENTER_API(H5Dget_space_status, FAIL) H5TRACE2("e","i*Ds",dset_id,allocation); /* Check arguments */ if(NULL==(dset=H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") /* Read data space address and return */ if(FAIL==(ret_value=H5D_get_space_status(dset, allocation, H5AC_ind_dxpl_id))) HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get space status") done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5D_get_space_status * * Purpose: Returns the status of data space allocation. * * Return: * Success: Non-negative * * Failture: Negative * * Programmer: Raymond Lu * * Modification: * *------------------------------------------------------------------------- */ static herr_t H5D_get_space_status(H5D_t *dset, H5D_space_status_t *allocation, hid_t dxpl_id) { H5S_t *space; /* Dataset's dataspace */ hsize_t space_allocated; /* The number of bytes allocated for chunks */ hssize_t total_elem; /* The total number of elements in dataspace */ size_t type_size; /* The size of the datatype for the dataset */ hsize_t full_size; /* The number of bytes in the dataset when fully populated */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT(H5D_get_space_status) assert(dset); /* Get the dataset's dataspace */ space=dset->shared->space; assert(space); /* Get the total number of elements in dataset's dataspace */ if((total_elem=H5S_GET_EXTENT_NPOINTS(space))<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "unable to get # of dataspace elements") /* Get the size of the dataset's datatype */ if((type_size=H5T_get_size(dset->shared->type))==0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "unable to get size of datatype") /* Compute the maximum size of the dataset in bytes */ H5_CHECK_OVERFLOW(total_elem,hssize_t,hsize_t); full_size=((hsize_t)total_elem)*type_size; /* Difficult to error check, since the error value is 0 and 0 is a valid value... :-/ */ space_allocated=H5D_get_storage_size(dset,dxpl_id); /* Decide on how much of the space is allocated */ if(space_allocated==0) *allocation = H5D_SPACE_STATUS_NOT_ALLOCATED; else if(space_allocated==full_size) *allocation = H5D_SPACE_STATUS_ALLOCATED; else { /* Should only happen for chunked datasets currently */ assert(dset->shared->layout.type==H5D_CHUNKED); *allocation = H5D_SPACE_STATUS_PART_ALLOCATED; } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5Dget_type * * Purpose: Returns a copy of the file data type for a dataset. * * Return: Success: ID for a copy of the data type. The data * type should be released by calling * H5Tclose(). * * Failure: FAIL * * Programmer: Robb Matzke * Tuesday, February 3, 1998 * * Modifications: * * Robb Matzke, 1 Jun 1998 * If the dataset has a named data type then a handle to the opened data * type is returned. Otherwise the returned data type is read-only. If * atomization of the data type fails then the data type is closed. * *------------------------------------------------------------------------- */ hid_t H5Dget_type(hid_t dset_id) { H5D_t *dset = NULL; H5T_t *copied_type = NULL; hid_t ret_value = FAIL; FUNC_ENTER_API(H5Dget_type, FAIL) H5TRACE1("i","i",dset_id); /* Check args */ if (NULL==(dset=H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") /* Copy the data type and mark it read-only */ if (NULL==(copied_type=H5T_copy (dset->shared->type, H5T_COPY_REOPEN))) HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to copy the data type") /* Mark any VL datatypes as being in memory now */ if (H5T_vlen_mark(copied_type, NULL, H5T_VLEN_MEMORY)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid VL location"); /* Unlock copied type */ if (H5T_lock (copied_type, FALSE)<0) HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to lock transient data type") /* Create an atom */ if ((ret_value=H5I_register (H5I_DATATYPE, copied_type))<0) HGOTO_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register data type") done: if(ret_value<0) { if(copied_type!=NULL) { if(H5T_close (copied_type)<0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release datatype") } /* end if */ } /* end if */ FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5Dget_create_plist * * Purpose: Returns a copy of the dataset creation property list. * * Return: Success: ID for a copy of the dataset creation * property list. The template should be * released by calling H5P_close(). * * Failure: FAIL * * Programmer: Robb Matzke * Tuesday, February 3, 1998 * * Modifications: * * Raymond Lu * Tuesday, October 2, 2001 * The way to retrieve and set property is changed for the * generic property list. * *------------------------------------------------------------------------- */ hid_t H5Dget_create_plist(hid_t dset_id) { H5D_t *dset = NULL; H5O_fill_t copied_fill={NULL,0,NULL}; H5P_genplist_t *dcpl_plist; H5P_genplist_t *new_plist; hid_t new_dcpl_id = FAIL; hid_t ret_value = FAIL; FUNC_ENTER_API(H5Dget_create_plist, FAIL) H5TRACE1("i","i",dset_id); /* Check args */ if (NULL==(dset=H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") if (NULL == (dcpl_plist = H5I_object(dset->shared->dcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") /* Copy the creation property list */ if((new_dcpl_id = H5P_copy_plist(dcpl_plist)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to copy the creation property list") if (NULL == (new_plist = H5I_object(new_dcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") /* Get the fill value property */ if(H5P_get(new_plist, H5D_CRT_FILL_VALUE_NAME, &copied_fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value") /* Copy the dataset type into the fill value message */ if(copied_fill.type==NULL) if(NULL==(copied_fill.type=H5T_copy(dset->shared->type, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to copy dataset data type for fill value") /* Set back the fill value property to property list */ if(H5P_set(new_plist, H5D_CRT_FILL_VALUE_NAME, &copied_fill) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set property list fill value") /* Set the return value */ ret_value=new_dcpl_id; done: if(ret_value<0) { if(new_dcpl_id>0) (void)H5I_dec_ref(new_dcpl_id); } /* end if */ FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5Dextend * * Purpose: This function makes sure that the dataset is at least of size * SIZE. The dimensionality of SIZE is the same as the data * space of the dataset being changed. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Friday, January 30, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Dextend(hid_t dset_id, const hsize_t *size) { H5D_t *dset = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Dextend, FAIL) H5TRACE2("e","i*h",dset_id,size); /* Check args */ if (NULL==(dset=H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") if (!size) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no size specified") /* Increase size */ if (H5D_extend (dset, size, H5AC_dxpl_id)<0) HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to extend dataset") done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5D_new * * Purpose: Creates a new, empty dataset structure * * Return: Success: Pointer to a new dataset descriptor. * * Failure: NULL * * Errors: * * Programmer: Quincey Koziol * Monday, October 12, 1998 * * Modifications: * * Raymond Lu * Tuesday, October 2, 2001 * Changed the way to query and inialization for generic * property list. * *------------------------------------------------------------------------- */ static H5D_shared_t * H5D_new(hid_t dcpl_id, hbool_t creating, hbool_t vl_type) { H5P_genplist_t *plist; /* Property list created */ H5D_shared_t *new_dset = NULL; /* New dataset object */ H5D_shared_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5D_new) if (NULL==(new_dset = H5FL_MALLOC(H5D_shared_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* If we are using the default dataset creation property list, during creation * don't bother to copy it, just increment the reference count */ if(!vl_type && creating && dcpl_id == H5P_DATASET_CREATE_DEFAULT) { /* Copy the default dataset information */ HDmemcpy(new_dset,&H5D_def_dset,sizeof(H5D_shared_t)); if(H5I_inc_ref(dcpl_id)<0) HGOTO_ERROR (H5E_DATASET, H5E_CANTINC, NULL, "Can't increment default DCPL ID") new_dset->dcpl_id = dcpl_id; } /* end if */ else { /* Reset the dataset information */ HDmemset(new_dset,0,sizeof(H5D_shared_t)); /* Get the property list */ if (NULL == (plist = H5I_object(dcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a property list") new_dset->dcpl_id = H5P_copy_plist(plist); } /* end else */ /* Set return value */ ret_value=new_dset; done: if(ret_value==NULL) { if(new_dset!=NULL) { if(new_dset->dcpl_id!=0) (void)H5I_dec_ref(new_dset->dcpl_id); H5FL_FREE(H5D_shared_t,new_dset); } /* end if */ } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5D_init_type * * Purpose: Copy a datatype for a dataset's use, performing all the * necessary adjustments, etc. * * Return: Success: SUCCEED * Failure: FAIL * * Errors: * * Programmer: Quincey Koziol * Thursday, June 24, 2004 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5D_init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, const H5T_t *type) { htri_t relocatable; /* Flag whether the type is relocatable */ htri_t immutable; /* Flag whether the type is immutable */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5D_init_type, FAIL) /* Sanity checking */ assert(file); assert(dset); assert(type); /* Check whether the datatype is relocatable */ if((relocatable=H5T_is_relocatable(type))<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't check datatype?") /* Check whether the datatype is immutable */ if((immutable=H5T_is_immutable(type))<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't check datatype?") /* Copy the datatype if it's a custom datatype or if it'll change when it's location is changed */ if(!immutable || relocatable) { /* Copy datatype for dataset */ if((dset->shared->type = H5T_copy(type, H5T_COPY_ALL))==NULL) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "can't copy datatype") /* Mark any datatypes as being on disk now */ if(H5T_vlen_mark(dset->shared->type, file, H5T_VLEN_DISK)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location") /* Get a datatype ID for the dataset's datatype */ if((dset->shared->type_id = H5I_register(H5I_DATATYPE, dset->shared->type))<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register type") } /* end if */ /* Not a custom datatype, just use it directly */ else { if(H5I_inc_ref(type_id)<0) HGOTO_ERROR (H5E_DATASET, H5E_CANTINC, FAIL, "Can't increment datatype ID") /* Use existing datatype */ dset->shared->type_id = type_id; dset->shared->type = (H5T_t *)type; /* (Cast away const OK - QAK) */ } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_init_type() */ /*------------------------------------------------------------------------- * Function: H5D_update_entry_info * * Purpose: Create and fill an H5G_entry_t object for insertion into * the group LOC. * * This code was originally found at the end of H5D_create() * but was placed here for general use. * * Return: Success: SUCCEED * Failure: FAIL * * Errors: * * Programmer: Bill Wendling * Thursday, October 31, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5D_update_entry_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset, H5P_genplist_t *plist) { size_t ohdr_size = H5D_MINHDR_SIZE; /* Size of dataset's object header */ H5G_entry_t *ent=NULL; /* Dataset's group entry */ H5O_layout_t *layout; /* Dataset's layout information */ H5T_t *type; /* Dataset's datatype */ H5S_t *space; /* Dataset's dataspace */ H5D_alloc_time_t alloc_time;/* Dataset's allocation time */ H5O_efl_t *efl; /* Dataset's external file list */ /* fill value variables */ H5D_fill_time_t fill_time; H5O_fill_t *fill_prop; /* Pointer to dataset's fill value information */ H5O_fill_new_t fill = { NULL, 0, NULL, H5D_ALLOC_TIME_LATE, H5D_FILL_TIME_ALLOC, TRUE }; H5D_fill_value_t fill_status; struct H5O_t *oh=NULL; /* Pointer to dataset's object header */ /* return code */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5D_update_entry_info, FAIL) /* Sanity checking */ assert(file); assert(dset); /* Pick up former parameters */ ent=&dset->ent; layout=&dset->shared->layout; type=dset->shared->type; space=dset->shared->space; alloc_time=dset->shared->alloc_time; efl=&dset->shared->efl; /* Add the dataset's raw data size to the size of the header, if the raw data will be stored as compact */ if (layout->type == H5D_COMPACT) ohdr_size += layout->u.compact.size; /* Create (open for write access) an object header */ if (H5O_create(file, dxpl_id, ohdr_size, ent) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset object header") /* Get a pointer to the object header itself */ if((oh=H5O_protect(ent, dxpl_id))==NULL) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to protect dataset object header") /* Point at dataset's copy, to cache it for later */ fill_prop=&dset->shared->fill; fill_time=dset->shared->fill_time; /* Check if dataset has non-default creation property list */ if(dset->shared->dcpl_id!=H5P_DATASET_CREATE_DEFAULT) { /* * Retrieve properties of fill value and others. Copy them into new fill * value struct. */ if (H5P_get(plist, H5D_CRT_FILL_TIME_NAME, &fill_time) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve fill time") dset->shared->fill_time=fill_time; /* Cache this for later */ /* Get the fill value information from the property list */ if (H5P_get(plist, H5D_CRT_FILL_VALUE_NAME, fill_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve fill value") } /* end if */ if (H5P_is_fill_value_defined(fill_prop, &fill_status) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't tell if fill value defined") /* Special case handling for variable-length types */ if(H5T_detect_class(type, H5T_VLEN)) { /* If the default fill value is chosen for variable-length types, always write it */ if(fill_time==H5D_FILL_TIME_IFSET && fill_status==H5D_FILL_VALUE_DEFAULT) { dset->shared->fill_time=fill_time=H5D_FILL_TIME_ALLOC; /* Update dataset creation property */ assert(dset->shared->dcpl_id!=H5P_DATASET_CREATE_DEFAULT); if (H5P_set(plist, H5D_CRT_FILL_TIME_NAME, &fill_time) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set fill time") } /* end if */ /* Don't allow never writing fill values with variable-length types */ if(fill_time==H5D_FILL_TIME_NEVER) HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "Dataset doesn't support VL datatype when fill value is not defined") } /* end if */ if (fill_status == H5D_FILL_VALUE_DEFAULT || fill_status == H5D_FILL_VALUE_USER_DEFINED) { if (H5O_copy(H5O_FILL_ID, fill_prop, &fill) == NULL) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT,FAIL, "unable to copy fill value") if (fill_prop->buf && fill_prop->size > 0 && H5O_fill_convert(&fill, type, dxpl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to convert fill value to dataset type") fill.fill_defined = TRUE; } else if (fill_status == H5D_FILL_VALUE_UNDEFINED) { fill.size = -1; fill.type = fill.buf = NULL; fill.fill_defined = FALSE; } else HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to determine if fill value is defined") fill.alloc_time = alloc_time; fill.fill_time = fill_time; if (fill.fill_defined == FALSE && fill_time == H5D_FILL_TIME_ALLOC) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT,FAIL, "unable to create dataset") /* Write new fill value message */ if (H5O_append(file, dxpl_id, oh, H5O_FILL_NEW_ID, H5O_FLAG_CONSTANT, &fill) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update fill value header message") /* If there is valid information for the old fill value struct, update it */ if (fill.buf) { /* Clear any previous values */ if(H5O_reset(H5O_FILL_ID, fill_prop)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't release fill info") /* Copy new fill value information to old fill value struct */ if(H5O_copy(H5O_FILL_ID, &fill, fill_prop) == NULL) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT,FAIL,"unable to copy fill value") /* Write old fill value */ if (fill_prop->buf && H5O_append(file, dxpl_id, oh, H5O_FILL_ID, H5O_FLAG_CONSTANT, fill_prop) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update fill value header message") /* Update dataset creation property */ assert(dset->shared->dcpl_id!=H5P_DATASET_CREATE_DEFAULT); if (H5P_set(plist, H5D_CRT_FILL_VALUE_NAME, fill_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set fill value") } /* end if */ /* Update the type and space header messages */ if (H5O_append(file, dxpl_id, oh, H5O_DTYPE_ID, H5O_FLAG_CONSTANT | H5O_FLAG_SHARED, type) < 0 || H5S_append(file, dxpl_id, oh, space) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update type or space header messages") /* Update the filters message, if this is a chunked dataset */ if(layout->type==H5D_CHUNKED) { H5O_pline_t pline; /* Chunked data I/O pipeline info */ if (H5P_get(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "Can't retrieve pipeline filter") if (pline.nused > 0 && H5O_append(file, dxpl_id, oh, H5O_PLINE_ID, H5O_FLAG_CONSTANT, &pline) < 0) HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update filter header message") } /* end if */ /* * Allocate storage if space allocate time is early; otherwise delay * allocation until later. */ if (alloc_time == H5D_ALLOC_TIME_EARLY) if (H5D_alloc_storage(file, dxpl_id, dset, H5D_ALLOC_CREATE, FALSE, FALSE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize storage") /* Update external storage message */ if (efl->nused > 0) { size_t heap_size = H5HL_ALIGN(1); size_t u; for (u = 0; u < efl->nused; ++u) heap_size += H5HL_ALIGN(HDstrlen(efl->slot[u].name) + 1); if (H5HL_create(file, dxpl_id, heap_size, &efl->heap_addr/*out*/) < 0 || H5HL_insert(file, dxpl_id, efl->heap_addr, 1, "") == (size_t)(-1)) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create external file list name heap") for (u = 0; u < efl->nused; ++u) { size_t offset = H5HL_insert(file, dxpl_id, efl->heap_addr, HDstrlen(efl->slot[u].name) + 1, efl->slot[u].name); assert(0 == efl->slot[u].name_offset); if (offset == (size_t)(-1)) HGOTO_ERROR(H5E_EFL, H5E_CANTINIT, FAIL, "unable to insert URL into name heap") efl->slot[u].name_offset = offset; } if (H5O_append(file, dxpl_id, oh, H5O_EFL_ID, H5O_FLAG_CONSTANT, efl) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update external file list message") } /* Update layout message */ /* (Don't make layout message constant unless allocation time is early, since space may not be allocated) */ /* Note: this is relying on H5D_alloc_storage not calling H5O_modify during dataset creation */ if (H5D_COMPACT != layout->type && H5O_append(file, dxpl_id, oh, H5O_LAYOUT_ID, (alloc_time == H5D_ALLOC_TIME_EARLY ? H5O_FLAG_CONSTANT : 0), layout) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update layout") #ifdef H5O_ENABLE_BOGUS /* * Add a "bogus" message. */ if (H5O_bogus_oh(file, dxpl_id, oh))<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to update 'bogus' message") #endif /* H5O_ENABLE_BOGUS */ /* Add a modification time message. */ if (H5O_touch_oh(file, oh, TRUE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update modification time message") done: /* Release fill value information */ if (H5O_reset(H5O_FILL_ID, &fill) <0) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to release fill-value info") /* Release pointer to object header itself */ if(ent!=NULL && oh!=NULL) if(H5O_unprotect(ent,oh, dxpl_id)<0) HDONE_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to unprotect dataset object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_update_entry_info() */ /*------------------------------------------------------------------------- * Function: H5D_create * * Purpose: Creates a new dataset with name NAME in file F and associates * with it a datatype TYPE for each element as stored in the * file, dimensionality information or dataspace SPACE, and * other miscellaneous properties CREATE_PARMS. All arguments * are deep-copied before being associated with the new dataset, * so the caller is free to subsequently modify them without * affecting the dataset. * * Return: Success: Pointer to a new dataset * * Failure: NULL * * Errors: * DATASET CANTINIT Can't update dataset header. * DATASET CANTINIT Problem with the dataset name. * DATASET CANTINIT Fail in file space allocation for * chunks * * Programmer: Robb Matzke * Thursday, December 4, 1997 * * Modifications: * Robb Matzke, 9 Jun 1998 * The data space message is no longer cached in the dataset struct. * * Robb Matzke, 27 Jul 1998 * Added the MTIME message to the dataset object header. * * Robb Matzke, 1999-10-14 * The names for the external file list are entered into the heap hear * instead of when the efl message is encoded, preventing a possible * infinite recursion situation. * * Raymond Lu * Tuesday, October 2, 2001 * Changed the way to retrieve and set property for generic property * list. * * Raymond Lu, 26 Feb 2002 * A new fill value message is added. Two properties, space allocation * time and fill value writing time, govern space allocation and fill * value writing. * * Bill Wendling, 1. November 2002 * Removed the cache updating mechanism. This was done so that it * can be called separately from the H5D_create function. There were * two of these mechanisms: one to create and insert into the parent * group the H5G_entry_t object and the other to update based upon * whether we're working with an external file or not. Between the * two, there is a conditional call to allocate space which isn't * part of updating the cache. * * Nat Furrer and James Laird * June 7, 2004 * Added checked_filters flag * *------------------------------------------------------------------------- */ static H5D_t * H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space, hid_t dcpl_id, hid_t dxpl_id) { const H5T_t *type; /* Datatype for dataset */ H5D_t *new_dset = NULL; int i, ndims; unsigned u; H5F_t *file=NULL; unsigned chunk_ndims = 0; /* Dimensionality of chunk */ H5P_genplist_t *dc_plist=NULL; /* New Property list */ hbool_t has_vl_type=FALSE; /* Flag to indicate a VL-type for dataset */ hbool_t chunk_init=FALSE; /* Flag to indicate that chunk information was initialized */ H5D_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5D_create, NULL) /* check args */ assert (loc); assert (name && *name); assert (H5I_DATATYPE==H5I_get_type(type_id)); assert (space); assert (H5I_GENPROP_LST==H5I_get_type(dcpl_id)); assert (H5I_GENPROP_LST==H5I_get_type(dxpl_id)); /* Get the dataset's datatype */ if (NULL == (type = H5I_object(type_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype") /* Check if the datatype is "sensible" for use in a dataset */ if(H5T_is_sensible(type)!=TRUE) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "datatype is not sensible") /* Check if the datatype is/contains a VL-type */ if(H5T_detect_class(type, H5T_VLEN)) has_vl_type=TRUE; /* Check if the dataspace has an extent set (or is NULL) */ if( !(H5S_has_extent(space)) ) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "dataspace extent has not been set.") /* Initialize the dataset object */ if (NULL==(new_dset = H5FL_CALLOC(H5D_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") H5G_ent_reset(&(new_dset->ent)); /* Initialize the shared dataset space */ if(NULL == (new_dset->shared = H5D_new(dcpl_id,TRUE,has_vl_type))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* What file is the dataset being added to? */ if(NULL==(file=H5G_insertion_file(loc, name, dxpl_id))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to locate insertion point") /* Copy datatype for dataset */ if(H5D_init_type(file, new_dset, type_id, type)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "can't copy datatype") /* Check if the filters in the DCPL can be applied to this dataset */ if(H5Z_can_apply(new_dset->shared->dcpl_id,new_dset->shared->type_id)<0) HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, NULL, "I/O filters can't operate on this dataset") /* Set the dataset's checked_filters flag to enable writing */ new_dset->shared->checked_filters = TRUE; /* Copy dataspace for dataset */ if((new_dset->shared->space = H5S_copy(space, FALSE))==NULL) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy dataspace") /* Set the dataset's dataspace to 'all' selection */ if(H5S_select_all(new_dset->shared->space,1)<0) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTSET, NULL, "unable to set all selection") /* Make the "set local" filter callbacks for this dataset */ if(H5Z_set_local(new_dset->shared->dcpl_id,new_dset->shared->type_id)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to set local filter parameters") /* Check if the dataset has a non-default DCPL & get important values, if so */ if(new_dset->shared->dcpl_id!=H5P_DATASET_CREATE_DEFAULT) { H5D_layout_t dcpl_layout; /* Dataset's layout information */ H5O_pline_t dcpl_pline; /* Dataset's I/O pipeline information */ H5D_alloc_time_t alloc_time; /* Dataset's allocation time */ /* Get new dataset's property list object */ if (NULL == (dc_plist = H5I_object(new_dset->shared->dcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "can't get dataset creation property list") if(H5P_get(dc_plist, H5D_CRT_DATA_PIPELINE_NAME, &dcpl_pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't retrieve pipeline filter") if(H5P_get(dc_plist, H5D_CRT_LAYOUT_NAME, &dcpl_layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't retrieve layout") if(dcpl_pline.nused > 0 && H5D_CHUNKED != dcpl_layout) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, NULL, "filters can only be used with chunked layout") if(H5P_get(dc_plist, H5D_CRT_ALLOC_TIME_NAME, &alloc_time) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't retrieve space allocation time") /* Check if the alloc_time is the default and error out */ if(alloc_time==H5D_ALLOC_TIME_DEFAULT) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, NULL, "invalid space allocation state") /* Don't allow compact datasets to allocate space later */ if(dcpl_layout==H5D_COMPACT && alloc_time!=H5D_ALLOC_TIME_EARLY) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, NULL, "compact dataset doesn't support late space allocation") /* Set the alloc_time for the dataset, in case the default was used */ new_dset->shared->alloc_time=alloc_time; /* If MPI VFD is used, no filter support yet. */ if(IS_H5FD_MPI(file) && dcpl_pline.nused > 0) HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, NULL, "Parallel I/O does not support filters yet") /* Chunked datasets are non-default, so retrieve their info here */ if(H5P_get(dc_plist, H5D_CRT_CHUNK_DIM_NAME, &chunk_ndims) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't retrieve chunk dimensions") /* Get the dataset's external file list information */ if(H5P_get(dc_plist, H5D_CRT_EXT_FILE_LIST_NAME, &new_dset->shared->efl) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't retrieve external file list") /* Set the dataset's data storage method */ new_dset->shared->layout.type=dcpl_layout; } /* end if */ /* Check if this dataset is going into a parallel file and set space allocation time */ if(IS_H5FD_MPI(file)) new_dset->shared->alloc_time=H5D_ALLOC_TIME_EARLY; /* Set up layout information */ new_dset->shared->layout.unused.ndims = H5S_GET_EXTENT_NDIMS(new_dset->shared->space) + 1; assert((unsigned)(new_dset->shared->layout.unused.ndims) <= NELMTS(new_dset->shared->layout.unused.dim)); if (H5S_get_simple_extent_dims(new_dset->shared->space, new_dset->shared->layout.unused.dim, NULL)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize storage info") new_dset->shared->layout.unused.dim[new_dset->shared->layout.unused.ndims-1] = H5T_get_size(new_dset->shared->type); switch (new_dset->shared->layout.type) { case H5D_CONTIGUOUS: { hssize_t tmp_size; /* Temporary holder for raw data size */ hsize_t max_dim[H5O_LAYOUT_NDIMS]; /* Maximum size of data in elements */ /* * The maximum size of the dataset cannot exceed the storage size. * Also, only the slowest varying dimension of a simple data space * can be extendible (currently only for external data storage). */ new_dset->shared->layout.u.contig.addr = HADDR_UNDEF; /* Initialize to no address */ if ((ndims=H5S_get_simple_extent_dims(new_dset->shared->space, NULL, max_dim))<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize contiguous storage") for (i=1; inew_dset->shared->layout.unused.dim[i]) HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, "only the first dimension can be extendible") if (new_dset->shared->efl.nused>0) { hsize_t max_points = H5S_get_npoints_max (new_dset->shared->space); hsize_t max_storage = H5O_efl_total_size (&new_dset->shared->efl); if (H5S_UNLIMITED==max_points) { if (H5O_EFL_UNLIMITED!=max_storage) HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, "unlimited data space but finite storage") } else if (max_points * H5T_get_size (type) < max_points) { HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, "data space * type size overflowed") } else if (max_points * H5T_get_size (type) > max_storage) { HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, "data space size exceeds external storage size") } /* Set the I/O functions for this layout type */ new_dset->shared->io_ops.readvv=H5D_efl_readvv; new_dset->shared->io_ops.writevv=H5D_efl_writevv; } /* end if */ else { if (ndims>0 && max_dim[0]>new_dset->shared->layout.unused.dim[0]) HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, NULL, "extendible contiguous non-external dataset") /* Set the I/O functions for this layout type */ new_dset->shared->io_ops.readvv=H5D_contig_readvv; new_dset->shared->io_ops.writevv=H5D_contig_writevv; } /* end else */ /* Compute the total size of a chunk */ tmp_size = H5S_GET_EXTENT_NPOINTS(new_dset->shared->space) * H5T_get_size(new_dset->shared->type); H5_ASSIGN_OVERFLOW(new_dset->shared->layout.u.contig.size,tmp_size,hssize_t,hsize_t); /* Get the sieve buffer size for this dataset */ new_dset->shared->cache.contig.sieve_buf_size = H5F_SIEVE_BUF_SIZE(loc->file); } /* end case */ break; case H5D_CHUNKED: { hsize_t max_dim[H5O_LAYOUT_NDIMS]; /* Maximum size of data in elements */ /* Set up layout information */ if((ndims=H5S_GET_EXTENT_NDIMS(new_dset->shared->space))<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "unable to get rank") new_dset->shared->layout.u.chunk.ndims = (unsigned)ndims + 1; assert((unsigned)(new_dset->shared->layout.u.chunk.ndims) <= NELMTS(new_dset->shared->layout.u.chunk.dim)); new_dset->shared->layout.u.chunk.addr = HADDR_UNDEF; /* Initialize to no address */ /* * Chunked storage allows any type of data space extension, so we * don't even bother checking. */ if(chunk_ndims != (unsigned)ndims) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, NULL, "dimensionality of chunks doesn't match the data space") if (new_dset->shared->efl.nused>0) HGOTO_ERROR (H5E_DATASET, H5E_BADVALUE, NULL, "external storage not supported with chunked layout") /* * The chunk size of a dimension with a fixed size cannot exceed * the maximum dimension size */ if(H5P_get(dc_plist, H5D_CRT_CHUNK_SIZE_NAME, new_dset->shared->layout.u.chunk.dim) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't retrieve chunk size") new_dset->shared->layout.u.chunk.dim[new_dset->shared->layout.u.chunk.ndims-1] = H5T_get_size(new_dset->shared->type); if (H5S_get_simple_extent_dims(new_dset->shared->space, NULL, max_dim)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to query maximum dimensions") for (u=0; ushared->layout.u.chunk.ndims-1; u++) if(max_dim[u] != H5S_UNLIMITED && max_dim[u] < new_dset->shared->layout.u.chunk.dim[u]) HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, "chunk size must be <= maximum dimension size for fixed-sized dimensions") /* Compute the total size of a chunk */ for (u=1, new_dset->shared->layout.u.chunk.size=new_dset->shared->layout.u.chunk.dim[0]; ushared->layout.u.chunk.ndims; u++) new_dset->shared->layout.u.chunk.size *= new_dset->shared->layout.u.chunk.dim[u]; /* Set the I/O functions for this layout type */ new_dset->shared->io_ops.readvv=H5D_istore_readvv; new_dset->shared->io_ops.writevv=H5D_istore_writevv; /* Initialize the chunk cache for the dataset */ if(H5D_istore_init(file,new_dset)<0) HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, "can't initialize chunk cache") /* Indicate that the chunk information was initialized */ chunk_init=TRUE; } /* end case */ break; case H5D_COMPACT: { hssize_t tmp_size; /* Temporary holder for raw data size */ hsize_t comp_data_size; /* * Compact dataset is stored in dataset object header message of * layout. */ tmp_size = H5S_GET_EXTENT_NPOINTS(space) * H5T_get_size(new_dset->shared->type); H5_ASSIGN_OVERFLOW(new_dset->shared->layout.u.compact.size,tmp_size,hssize_t,size_t); /* Verify data size is smaller than maximum header message size * (64KB) minus other layout message fields. */ comp_data_size=H5O_MAX_SIZE-H5O_layout_meta_size(file, &(new_dset->shared->layout)); if(new_dset->shared->layout.u.compact.size > comp_data_size) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "compact dataset size is bigger than header message maximum size") /* Set the I/O functions for this layout type */ new_dset->shared->io_ops.readvv=H5D_compact_readvv; new_dset->shared->io_ops.writevv=H5D_compact_writevv; } /* end case */ break; default: HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, NULL, "not implemented yet") } /* end switch */ /*lint !e788 All appropriate cases are covered */ /* Update the dataset's entry info. */ if (H5D_update_entry_info(file, dxpl_id, new_dset, dc_plist) != SUCCEED) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "can't update the metadata cache") /* Get the dataset's DCPL cache info */ if (H5D_get_dcpl_cache(new_dset->shared->dcpl_id,&new_dset->shared->dcpl_cache)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "can't fill DCPL cache") /* * Give the dataset a name. That is, create and add a new object to the * group this dataset is being initially created in. */ if (H5G_insert(loc, name, &new_dset->ent, dxpl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to name dataset") /* Add the dataset to the list of opened objects in the file */ if(H5FO_top_incr(new_dset->ent.file, new_dset->ent.header)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINC, NULL, "can't incr object ref. count") if(H5FO_insert(new_dset->ent.file,new_dset->ent.header,new_dset->shared)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, NULL, "can't insert dataset into list of open objects") new_dset->shared->fo_count=1; /* Success */ ret_value = new_dset; done: if (!ret_value && new_dset && new_dset->shared) { if( new_dset->shared) { if(new_dset->shared->layout.type==H5D_CHUNKED && chunk_init) { if(H5D_istore_dest(new_dset,H5AC_dxpl_id)<0) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, NULL, "unable to destroy chunk cache") } /* end if */ if (new_dset->shared->space) { if(H5S_close(new_dset->shared->space)<0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release dataspace") } /* end if */ if (new_dset->shared->type) { if(H5I_dec_ref(new_dset->shared->type_id)<0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release datatype") } /* end if */ if (H5F_addr_defined(new_dset->ent.header)) { if(H5O_close(&(new_dset->ent))<0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release object header") if(file) { if(H5O_delete(file, dxpl_id,new_dset->ent.header)<0) HDONE_ERROR(H5E_DATASET, H5E_CANTDELETE, NULL, "unable to delete object header") } /* end if */ } /* end if */ if(new_dset->shared->dcpl_id!=0) { if(H5I_dec_ref(new_dset->shared->dcpl_id)<0) HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, "unable to decrement ref count on property list") } /* end if */ H5FL_FREE(H5D_shared_t,new_dset->shared); } /* end if */ new_dset->ent.file = NULL; H5FL_FREE(H5D_t, new_dset); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_create() */ /*------------------------------------------------------------------------- * Function: H5D_isa * * Purpose: Determines if an object has the requisite messages for being * a dataset. * * Return: Success: TRUE if the required dataset messages are * present; FALSE otherwise. * * Failure: FAIL if the existence of certain messages * cannot be determined. * * Programmer: Robb Matzke * Monday, November 2, 1998 * * Modifications: * *------------------------------------------------------------------------- */ htri_t H5D_isa(H5G_entry_t *ent, hid_t dxpl_id) { htri_t exists; htri_t ret_value=TRUE; /* Return value */ FUNC_ENTER_NOAPI(H5D_isa, FAIL) assert(ent); /* Data type */ if ((exists=H5O_exists(ent, H5O_DTYPE_ID, 0, dxpl_id))<0) { HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to read object header") } else if (!exists) { HGOTO_DONE(FALSE) } /* Layout */ if ((exists=H5O_exists(ent, H5O_LAYOUT_ID, 0, dxpl_id))<0) { HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to read object header") } else if (!exists) { HGOTO_DONE(FALSE) } done: FUNC_LEAVE_NOAPI(ret_value) } /* *------------------------------------------------------------------------- * Function: H5D_open * * Purpose: Checks if dataset is already open, or opens a dataset for * access. * * Return: Success: Dataset ID * Failure: FAIL * * Errors: * * Programmer: Quincey Koziol * Friday, December 20, 2002 * * Modifications: * *------------------------------------------------------------------------- */ H5D_t* H5D_open(const H5G_entry_t *ent, hid_t dxpl_id) { H5D_shared_t *shared_fo=NULL; H5D_t *dataset=NULL; H5D_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5D_open, NULL) /* check args */ assert (ent); /* Check if dataset was already open */ if((shared_fo=H5FO_opened(ent->file,ent->header))==NULL) { /* Clear any errors from H5FO_opened() */ H5E_clear(); /* Open the dataset object */ if ((dataset=H5D_open_oid(ent, dxpl_id)) ==NULL) HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, NULL, "not found") /* Add the dataset to the list of opened objects in the file */ if(H5FO_insert(dataset->ent.file,dataset->ent.header,dataset->shared)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, NULL, "can't insert dataset into list of open objects") /* Increment object count for the object in the top file */ if(H5FO_top_incr(dataset->ent.file, dataset->ent.header) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINC, NULL, "can't increment object count") dataset->shared->fo_count = 1; } /* end if */ else { if(NULL == (dataset = H5FL_CALLOC(H5D_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate space for dataset") /* Shallow copy (take ownership) of the group entry object */ if(H5G_ent_copy(&(dataset->ent),ent,H5G_COPY_SHALLOW)<0) HGOTO_ERROR (H5E_DATASET, H5E_CANTCOPY, NULL, "can't copy group entry") dataset->shared=shared_fo; shared_fo->fo_count++; /* Check if the object has been opened through the top file yet */ if(H5FO_top_count(dataset->ent.file, dataset->ent.header) == 0) { /* Open the object through this top file */ if(H5O_open(&(dataset->ent)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "unable to open object header") } /* end if */ /* Increment object count for the object in the top file */ if(H5FO_top_incr(dataset->ent.file, dataset->ent.header) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINC, NULL, "can't increment object count") } /* end else */ ret_value = dataset; done: if(ret_value==NULL) { if(dataset) { if(shared_fo==NULL) /* Need to free shared fo */ H5FL_FREE(H5D_shared_t, dataset->shared); H5FL_FREE(H5D_t, dataset); } if(shared_fo) shared_fo->fo_count--; } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5D_open_oid * * Purpose: Opens a dataset for access. * * Return: Dataset pointer on success, NULL on failure * * Errors: * * Programmer: Quincey Koziol * Monday, October 12, 1998 * * Modifications: * * Raymond Lu * Tuesday, October 2, 2001 * Changed the way to set property for generic property list. * * Raymond Lu * Feb 26, 2002 * A new fill value message and two new properties are added. * * Pedro Vicente, 22 Aug 2002 * Added a deep copy of the symbol table entry * *------------------------------------------------------------------------- */ static H5D_t * H5D_open_oid(const H5G_entry_t *ent, hid_t dxpl_id) { H5D_t *dataset = NULL; /*new dataset struct */ H5O_fill_new_t fill = {NULL, 0, NULL, H5D_ALLOC_TIME_LATE, H5D_CRT_FILL_TIME_DEF, TRUE}; unsigned alloc_time_state; /* Allocation time state */ H5O_fill_t *fill_prop; /* Pointer to dataset's fill value area */ H5O_pline_t pline; /* I/O pipeline information */ H5P_genplist_t *plist; /* Property list */ H5D_t *ret_value = NULL; /*return value */ FUNC_ENTER_NOAPI(H5D_open_oid, NULL) /* check args */ assert (ent); /* Allocate the dataset structure */ if(NULL==(dataset=H5FL_CALLOC(H5D_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* (Set the 'vl_type' parameter to FALSE since it doesn't matter from here) */ if(NULL==(dataset->shared = H5D_new(H5P_DATASET_CREATE_DEFAULT,FALSE,FALSE))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Shallow copy (take ownership) of the group entry object */ if(H5G_ent_copy(&(dataset->ent),ent,H5G_COPY_SHALLOW)<0) HGOTO_ERROR (H5E_DATASET, H5E_CANTCOPY, NULL, "can't copy group entry") /* Find the dataset object */ if (H5O_open(&(dataset->ent)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "unable to open") /* Get the type and space */ if (NULL==(dataset->shared->type=H5O_read(&(dataset->ent), H5O_DTYPE_ID, 0, NULL, dxpl_id))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to load type info from dataset header") /* Get a datatype ID for the dataset's datatype */ if((dataset->shared->type_id = H5I_register(H5I_DATATYPE, dataset->shared->type))<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, NULL, "unable to register type") if (NULL==(dataset->shared->space=H5S_read(&(dataset->ent),dxpl_id))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to load space info from dataset header") /* Get dataset creation property list object */ if (NULL == (plist = H5I_object(dataset->shared->dcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "can't get dataset creation property list") /* Get the optional filters message */ if(NULL == H5O_read(&(dataset->ent), H5O_PLINE_ID, 0, &pline, dxpl_id)) { H5E_clear(); HDmemset(&pline, 0, sizeof(pline)); } if(H5P_set(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set pipeline") /* * Get the raw data layout info. It's actually stored in two locations: * the storage message of the dataset (dataset->storage) and certain * values are copied to the dataset create plist so the user can query * them. */ if (NULL==H5O_read(&(dataset->ent), H5O_LAYOUT_ID, 0, &(dataset->shared->layout), dxpl_id)) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to read data layout message") if(H5P_set(plist, H5D_CRT_LAYOUT_NAME, &dataset->shared->layout.type) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set layout") switch (dataset->shared->layout.type) { case H5D_CONTIGUOUS: /* Compute the size of the contiguous storage for versions of the * layout message less than version 3 because versions 1 & 2 would * truncate the dimension sizes to 32-bits of information. - QAK 5/26/04 */ if(dataset->shared->layout.version<3) { hssize_t tmp_size; /* Temporary holder for raw data size */ tmp_size = H5S_GET_EXTENT_NPOINTS(dataset->shared->space) * H5T_get_size(dataset->shared->type); H5_ASSIGN_OVERFLOW(dataset->shared->layout.u.contig.size,tmp_size,hssize_t,hsize_t); } /* end if */ /* Set the I/O functions for this layout type */ dataset->shared->io_ops.readvv=H5D_contig_readvv; dataset->shared->io_ops.writevv=H5D_contig_writevv; /* Get the sieve buffer size for this dataset */ dataset->shared->cache.contig.sieve_buf_size = H5F_SIEVE_BUF_SIZE(dataset->ent.file); break; case H5D_CHUNKED: /* * Chunked storage. The creation plist's dimension is one less than * the chunk dimension because the chunk includes a dimension for the * individual bytes of the data type. */ { unsigned chunk_ndims; /* Dimensionality of chunk */ chunk_ndims = dataset->shared->layout.u.chunk.ndims - 1; if(H5P_set(plist, H5D_CRT_CHUNK_DIM_NAME, &chunk_ndims) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set chunk dimensions") if(H5P_set(plist, H5D_CRT_CHUNK_SIZE_NAME, dataset->shared->layout.u.chunk.dim) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set chunk size") /* Initialize the chunk cache for the dataset */ if(H5D_istore_init(dataset->ent.file,dataset)<0) HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, "can't initialize chunk cache") } /* Set the I/O functions for this layout type */ dataset->shared->io_ops.readvv=H5D_istore_readvv; dataset->shared->io_ops.writevv=H5D_istore_writevv; break; case H5D_COMPACT: /* Set the I/O functions for this layout type */ dataset->shared->io_ops.readvv=H5D_compact_readvv; dataset->shared->io_ops.writevv=H5D_compact_writevv; break; default: HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, NULL, "not implemented yet") } /* end switch */ /*lint !e788 All appropriate cases are covered */ /* Point at dataset's copy, to cache it for later */ fill_prop=&dataset->shared->fill; /* Retrieve & release the previous fill-value settings */ if(H5P_get(plist, H5D_CRT_FILL_VALUE_NAME, fill_prop) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't get fill value") if(H5O_reset(H5O_FILL_ID, fill_prop)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, NULL, "can't release fill info") /* Get the new fill value message */ if(NULL == H5O_read(&(dataset->ent), H5O_FILL_NEW_ID, 0, &fill, dxpl_id)) { H5E_clear(); HDmemset(&fill, 0, sizeof(fill)); /* Set the space allocation time appropriately, based on the type of dataset storage */ switch (dataset->shared->layout.type) { case H5D_COMPACT: fill.alloc_time=H5D_ALLOC_TIME_EARLY; break; case H5D_CONTIGUOUS: fill.alloc_time=H5D_ALLOC_TIME_LATE; break; case H5D_CHUNKED: fill.alloc_time=H5D_ALLOC_TIME_INCR; break; default: HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, NULL, "not implemented yet") } /* end switch */ /*lint !e788 All appropriate cases are covered */ /* Set the default fill time */ fill.fill_time=H5D_CRT_FILL_TIME_DEF; } /* end if */ if(fill.fill_defined) { if(NULL==H5O_copy(H5O_FILL_ID, &fill, fill_prop)) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "can't copy fill value") } else { /* For compatibility with v1.4. Retrieve the old fill value message. * If size is 0, make it -1 for undefined. */ if(NULL == H5O_read(&(dataset->ent), H5O_FILL_ID, 0, fill_prop, dxpl_id)) { H5E_clear(); HDmemset(fill_prop, 0, sizeof(H5O_fill_t)); } if(fill_prop->size == 0) { fill_prop->type = fill_prop->buf = NULL; fill_prop->size = (size_t)-1; } } /* end else */ alloc_time_state=0; if( (dataset->shared->layout.type==H5D_COMPACT && fill.alloc_time==H5D_ALLOC_TIME_EARLY) || (dataset->shared->layout.type==H5D_CONTIGUOUS && fill.alloc_time==H5D_ALLOC_TIME_LATE) || (dataset->shared->layout.type==H5D_CHUNKED && fill.alloc_time==H5D_ALLOC_TIME_INCR)) alloc_time_state=1; /* Set revised fill value properties */ if(H5P_set(plist, H5D_CRT_FILL_VALUE_NAME, fill_prop) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set fill value") dataset->shared->alloc_time=fill.alloc_time; /* Cache this for later */ if(H5P_set(plist, H5D_CRT_ALLOC_TIME_NAME, &fill.alloc_time) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set allocation time") if(H5P_set(plist, H5D_CRT_ALLOC_TIME_STATE_NAME, &alloc_time_state) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set allocation time state") dataset->shared->fill_time=fill.fill_time; /* Cache this for later */ if(H5P_set(plist, H5D_CRT_FILL_TIME_NAME, &fill.fill_time) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set fill time") /* Get the external file list message, which might not exist. Space is * also undefined when space allocate time is H5D_ALLOC_TIME_LATE. */ if((dataset->shared->layout.type==H5D_CONTIGUOUS && !H5F_addr_defined(dataset->shared->layout.u.contig.addr)) || (dataset->shared->layout.type==H5D_CHUNKED && !H5F_addr_defined(dataset->shared->layout.u.chunk.addr))) { HDmemset(&dataset->shared->efl,0,sizeof(H5O_efl_t)); if(NULL != H5O_read(&(dataset->ent), H5O_EFL_ID, 0, &dataset->shared->efl, dxpl_id)) { if(H5P_set(plist, H5D_CRT_EXT_FILE_LIST_NAME, &dataset->shared->efl) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set external file list") /* Override the I/O functions for this layout type */ dataset->shared->io_ops.readvv=H5D_efl_readvv; dataset->shared->io_ops.writevv=H5D_efl_writevv; } /* end if */ } /* end if */ /* * Make sure all storage is properly initialized. * This is important only for parallel I/O where the space must * be fully allocated before I/O can happen. */ if ((H5F_get_intent(dataset->ent.file) & H5F_ACC_RDWR) && ((dataset->shared->layout.type==H5D_CONTIGUOUS && !H5F_addr_defined(dataset->shared->layout.u.contig.addr)) || (dataset->shared->layout.type==H5D_CHUNKED && !H5F_addr_defined(dataset->shared->layout.u.chunk.addr))) && IS_H5FD_MPI(dataset->ent.file)) { if (H5D_alloc_storage(dataset->ent.file, dxpl_id, dataset,H5D_ALLOC_OPEN, TRUE, FALSE)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize file storage") } /* Get the dataset's DCPL cache info */ if (H5D_get_dcpl_cache(dataset->shared->dcpl_id,&dataset->shared->dcpl_cache)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "can't fill DCPL cache") /* Success */ ret_value = dataset; done: /* Release fill value information */ if (H5O_reset(H5O_FILL_ID, &fill) <0) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, NULL, "unable to release fill-value info") if (ret_value==NULL && dataset) { if (H5F_addr_defined(dataset->ent.header)) { if(H5O_close(&(dataset->ent))<0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release object header") } /* end if */ if (dataset->shared->space) { if(H5S_close(dataset->shared->space)<0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release dataspace") } /* end if */ if (dataset->shared->type) { if(H5I_dec_ref(dataset->shared->type_id)<0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release datatype") } /* end if */ dataset->ent.file = NULL; H5FL_FREE(H5D_t,dataset); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_open_oid() */ /*------------------------------------------------------------------------- * Function: H5D_close * * Purpose: Insures that all data has been saved to the file, closes the * dataset object header, and frees all resources used by the * descriptor. * * Return: Non-negative on success/Negative on failure * * Errors: * DATASET CANTINIT Couldn't free the type or space, * but the dataset was freed anyway. * * Programmer: Robb Matzke * Thursday, December 4, 1997 * * Modifications: * Robb Matzke, 9 Jun 1998 * The data space message is no longer cached in the dataset struct. * *------------------------------------------------------------------------- */ herr_t H5D_close(H5D_t *dataset) { unsigned free_failed=FALSE; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5D_close, FAIL) /* check args */ assert(dataset && dataset->ent.file && dataset->shared); assert(dataset->shared->fo_count >0); /* Dump debugging info */ #ifdef H5D_ISTORE_DEBUG H5D_istore_stats(dataset, FALSE); #endif /* H5F_ISTORE_DEBUG */ dataset->shared->fo_count--; if(dataset->shared->fo_count ==0) { /* Free the data sieve buffer, if it's been allocated */ if(dataset->shared->cache.contig.sieve_buf) { assert(dataset->shared->layout.type!=H5D_COMPACT); /* We should never have a sieve buffer for compact storage */ /* Flush the raw data buffer, if its dirty */ if (dataset->shared->cache.contig.sieve_dirty) { /* Write dirty data sieve buffer to file */ if (H5F_block_write(dataset->ent.file, H5FD_MEM_DRAW, dataset->shared->cache.contig.sieve_loc, dataset->shared->cache.contig.sieve_size, H5AC_dxpl_id, dataset->shared->cache.contig.sieve_buf) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "block write failed") /* Reset sieve buffer dirty flag */ dataset->shared->cache.contig.sieve_dirty=0; } /* end if */ dataset->shared->cache.contig.sieve_buf = H5FL_BLK_FREE (sieve_buf,dataset->shared->cache.contig.sieve_buf); } /* end if */ /* Free cached information for each kind of dataset */ switch(dataset->shared->layout.type) { case H5D_CONTIGUOUS: break; case H5D_CHUNKED: /* Flush and destroy chunks in the cache */ if(H5D_istore_dest(dataset,H5AC_dxpl_id)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to destroy chunk cache") break; case H5D_COMPACT: /* Update header message of layout for compact dataset. */ if(dataset->shared->layout.u.compact.dirty) { if(H5O_modify(&(dataset->ent), H5O_LAYOUT_ID, 0, 0, H5O_UPDATE_TIME, &(dataset->shared->layout), H5AC_dxpl_id)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to update layout message") dataset->shared->layout.u.compact.dirty = FALSE; } /* end if */ /* Free the buffer for the raw data for compact datasets */ dataset->shared->layout.u.compact.buf=H5MM_xfree(dataset->shared->layout.u.compact.buf); break; default: assert ("not implemented yet" && 0); #ifdef NDEBUG HGOTO_ERROR (H5E_IO, H5E_UNSUPPORTED, FAIL, "unsupported storage layout") #endif /* NDEBUG */ } /* end switch */ /*lint !e788 All appropriate cases are covered */ /* * Release datatype, dataspace and creation property list -- there isn't * much we can do if one of these fails, so we just continue. */ free_failed=(H5I_dec_ref(dataset->shared->type_id)<0 || H5S_close(dataset->shared->space)<0 || H5I_dec_ref(dataset->shared->dcpl_id) < 0); /* Remove the dataset from the list of opened objects in the file */ if(H5FO_top_decr(dataset->ent.file, dataset->ent.header) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't decrement count for object") if(H5FO_delete(dataset->ent.file, H5AC_dxpl_id, dataset->ent.header)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't remove dataset from list of open objects") /* Close the dataset object */ /* (This closes the file, if this is the last object open) */ if(H5O_close(&(dataset->ent))<0) HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release object header"); /* * Free memory. Before freeing the memory set the file pointer to NULL. * We always check for a null file pointer in other H5D functions to be * sure we're not accessing an already freed dataset (see the assert() * above). */ dataset->ent.file = NULL; H5FL_FREE(H5D_shared_t,dataset->shared); } /* end if */ else { /* Decrement the ref. count for this object in the top file */ if(H5FO_top_decr(dataset->ent.file, dataset->ent.header) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't decrement count for object") /* Check reference count for this object in the top file */ if(H5FO_top_count(dataset->ent.file, dataset->ent.header) == 0) if(H5O_close(&(dataset->ent)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to close") if(H5G_free_ent_name(&dataset->ent)<0) free_failed=TRUE; } /* end else */ H5FL_FREE(H5D_t,dataset); if (free_failed) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "couldn't free the type or creation property list, but the dataset was freed anyway.") done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5D_extend * * Purpose: Increases the size of a dataset. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Friday, January 30, 1998 * * Modifications: * * Raymond Lu * Tuesday, October 2, 2001 * Changed the way to retrieve property for generic property * list. * * Nat Furrer and James Laird * June 17, 2004 * Added check for filter encode capability *------------------------------------------------------------------------- */ static herr_t H5D_extend (H5D_t *dataset, const hsize_t *size, hid_t dxpl_id) { int changed; /* Flag to indicate that the dataspace was successfully extended */ H5S_t *space = NULL; /* Dataset's dataspace */ H5D_fill_value_t fill_status; H5D_fill_time_t fill_time; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5D_extend, FAIL) /* Check args */ assert (dataset); assert (size); /* Check if the filters in the DCPL will need to encode, and if so, can they? * Filters need encoding if fill value is defined and a fill policy is set that requires * writing on an extend. */ if(! dataset->shared->checked_filters) { if(H5P_is_fill_value_defined(&(dataset->shared->fill), &fill_status) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Couldn't retrieve fill value from dataset."); if(fill_status == H5D_FILL_VALUE_DEFAULT || fill_status == H5D_FILL_VALUE_USER_DEFINED) { if( H5Pget_fill_time(dataset->shared->dcpl_id, &fill_time) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Couldn't retrieve fill time from dataset."); if(fill_time == H5D_FILL_TIME_ALLOC || (fill_time == H5D_FILL_TIME_IFSET && fill_status == H5D_FILL_VALUE_USER_DEFINED) ) { /* Filters must have encoding enabled. Ensure that all filters can be applied */ if(H5Z_can_apply(dataset->shared->dcpl_id, dataset->shared->type_id) <0) HGOTO_ERROR(H5E_PLINE, H5E_CANAPPLY, FAIL, "can't apply filters") dataset->shared->checked_filters = TRUE; } } } /* * NOTE: Restrictions on extensions were checked when the dataset was * created. All extensions are allowed here since none should be * able to muck things up. */ /* Increase the size of the data space */ space=dataset->shared->space; if ((changed=H5S_extend (space, size))<0) HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to increase size of data space") if (changed>0){ /* Save the new dataspace in the file if necessary */ if (H5S_modify (&(dataset->ent), space, TRUE, dxpl_id)<0) HGOTO_ERROR (H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update file with new dataspace") /* Update the index values for the cached chunks for this dataset */ if(H5D_CHUNKED == dataset->shared->layout.type) if(H5D_istore_update_cache(dataset, dxpl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update cached chunk indices") /* Allocate space for the new parts of the dataset, if appropriate */ if(dataset->shared->alloc_time==H5D_ALLOC_TIME_EARLY) if (H5D_alloc_storage(dataset->ent.file, dxpl_id, dataset, H5D_ALLOC_EXTEND, TRUE, FALSE)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize dataset with fill value") } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5D_entof * * Purpose: Returns a pointer to the entry for a dataset. * * Return: Success: Ptr to entry * * Failure: NULL * * Programmer: Robb Matzke * Friday, April 24, 1998 * * Modifications: * *------------------------------------------------------------------------- */ H5G_entry_t * H5D_entof (H5D_t *dataset) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_entof) FUNC_LEAVE_NOAPI( dataset ? &(dataset->ent) : (H5G_entry_t *)NULL) } /*------------------------------------------------------------------------- * Function: H5D_typeof * * Purpose: Returns a pointer to the dataset's data type. The data type * is not copied. * * Return: Success: Ptr to the dataset's data type, uncopied. * * Failure: NULL * * Programmer: Robb Matzke * Thursday, June 4, 1998 * * Modifications: * *------------------------------------------------------------------------- */ H5T_t * H5D_typeof (const H5D_t *dset) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_typeof) assert (dset); assert (dset->shared->type); FUNC_LEAVE_NOAPI(dset->shared->type) } /*------------------------------------------------------------------------- * Function: H5D_get_file * * Purpose: Returns the dataset's file pointer. * * Return: Success: Ptr to the dataset's file pointer. * * Failure: NULL * * Programmer: Quincey Koziol * Thursday, October 22, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static H5F_t * H5D_get_file (const H5D_t *dset) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_get_file) assert (dset); assert (dset->ent.file); FUNC_LEAVE_NOAPI(dset->ent.file) } /*------------------------------------------------------------------------- * Function: H5D_alloc_storage * * Purpose: Allocate storage for the raw data of a dataset. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Friday, January 16, 1998 * * Modifications: * Quincey Koziol * Thursday, August 22, 2002 * Moved here from H5F_arr_create and moved more logic into * this function from places where it was being called. * *------------------------------------------------------------------------- */ herr_t H5D_alloc_storage (H5F_t *f, hid_t dxpl_id, H5D_t *dset/*in,out*/, H5D_time_alloc_t time_alloc, hbool_t update_time, hbool_t full_overwrite) { struct H5O_layout_t *layout; /* The dataset's layout information */ unsigned init_space=0; /* Flag to indicate that space should be initialized */ unsigned addr_set=0; /* Flag to indicate that the dataset's storage address was set */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5D_alloc_storage) /* check args */ assert (f); assert (dset); /* If the data is stored in external files, don't set an address for the layout * We assume that external storage is already * allocated by the caller, or at least will be before I/O is performed. */ if(dset->shared->efl.nused==0) { /* Get a pointer to the dataset's layout information */ layout=&(dset->shared->layout); switch (layout->type) { case H5D_CONTIGUOUS: if(layout->u.contig.addr==HADDR_UNDEF) { /* Reserve space in the file for the entire array */ if (H5D_contig_create (f, dxpl_id, layout/*out*/)<0) HGOTO_ERROR (H5E_IO, H5E_CANTINIT, FAIL, "unable to initialize contiguous storage") /* Indicate that we set the storage addr */ addr_set=1; /* Indicate that we should initialize storage space */ init_space=1; } /* end if */ break; case H5D_CHUNKED: if(layout->u.chunk.addr==HADDR_UNDEF) { /* Create the root of the B-tree that describes chunked storage */ if (H5D_istore_create (f, dxpl_id, layout/*out*/)<0) HGOTO_ERROR (H5E_IO, H5E_CANTINIT, FAIL, "unable to initialize chunked storage") /* Indicate that we set the storage addr */ addr_set=1; /* Indicate that we should initialize storage space */ init_space=1; } /* end if */ /* If space allocation is set to 'early' and we are extending * the dataset, indicate that space should be allocated, so the * B-tree gets expanded. -QAK */ if(dset->shared->alloc_time==H5D_ALLOC_TIME_EARLY && time_alloc==H5D_ALLOC_EXTEND) init_space=1; break; case H5D_COMPACT: /* Check if space is already allocated */ if(layout->u.compact.buf==NULL) { /* Reserve space in layout header message for the entire array. */ assert(layout->u.compact.size>0); if (NULL==(layout->u.compact.buf=H5MM_malloc(layout->u.compact.size))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate memory for compact dataset") layout->u.compact.dirty = TRUE; /* Indicate that we set the storage addr */ addr_set=1; /* Indicate that we should initialize storage space */ init_space=1; } /* end if */ break; default: assert ("not implemented yet" && 0); #ifdef NDEBUG HGOTO_ERROR (H5E_IO, H5E_UNSUPPORTED, FAIL, "unsupported storage layout") #endif /* NDEBUG */ } /* end switch */ /*lint !e788 All appropriate cases are covered */ /* Check if we need to initialize the space */ if(init_space) { if (layout->type==H5D_CHUNKED) { /* If we are doing incremental allocation and the B-tree got * created during a H5Dwrite call, don't initialize the storage * now, wait for the actual writes to each block and let the * low-level chunking routines handle initialize the fill-values. * Otherwise, pass along the space initialization call and let * the low-level chunking routines sort out whether to write * fill values to the chunks they allocate space for. Yes, * this is icky. -QAK */ if(!(dset->shared->alloc_time==H5D_ALLOC_TIME_INCR && time_alloc==H5D_ALLOC_WRITE)) { if(H5D_init_storage(dset, full_overwrite, dxpl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize dataset with fill value") } /* end if */ } /* end if */ else { H5D_fill_value_t fill_status; /* The fill value status */ /* Check the dataset's fill-value status */ if (H5P_is_fill_value_defined(&(dset->shared->fill), &fill_status) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't tell if fill value defined") /* If we are filling the dataset on allocation or "if set" and * the fill value _is_ set, do that now */ if(dset->shared->fill_time==H5D_FILL_TIME_ALLOC || (dset->shared->fill_time==H5D_FILL_TIME_IFSET && fill_status==H5D_FILL_VALUE_USER_DEFINED)) { if(H5D_init_storage(dset, full_overwrite, dxpl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize dataset with fill value") } /* end if */ } /* end else */ } /* end if */ /* Also update header message for layout with new address, if we * set the address. (this is improves forward compatibility). */ if(time_alloc!=H5D_ALLOC_CREATE && addr_set) if (H5O_modify (&(dset->ent), H5O_LAYOUT_ID, 0, H5O_FLAG_CONSTANT, update_time, &(dset->shared->layout), dxpl_id) < 0) HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update layout message") } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_alloc_storage() */ /*------------------------------------------------------------------------- * Function: H5D_init_storage * * Purpose: Initialize the data for a new dataset. If a selection is * defined for SPACE then initialize only that part of the * dataset. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Monday, October 5, 1998 * * Modifications: * * Raymond Lu * Tuesday, October 2, 2001 * Changed the way to retrieve property for generic property * list. * *------------------------------------------------------------------------- */ static herr_t H5D_init_storage(H5D_t *dset, hbool_t full_overwrite, hid_t dxpl_id) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5D_init_storage) assert(dset); switch (dset->shared->layout.type) { case H5D_COMPACT: { hssize_t snpoints; /* Number of points in space (for error checking) */ size_t npoints; /* Number of points in space */ /* Get the number of elements in the dataset's dataspace */ snpoints = H5S_GET_EXTENT_NPOINTS(dset->shared->space); assert(snpoints>=0); H5_ASSIGN_OVERFLOW(npoints,snpoints,hssize_t,size_t); /* If we will be immediately overwriting the values, don't bother to clear them */ if(!full_overwrite) { /* If the fill value is defined, initialize the data buffer with it */ if(dset->shared->fill.buf) /* Initialize the cached data buffer with the fill value */ H5V_array_fill(dset->shared->layout.u.compact.buf, dset->shared->fill.buf, dset->shared->fill.size, npoints); else /* If the fill value is default, zero set data buf. */ HDmemset(dset->shared->layout.u.compact.buf, 0, dset->shared->layout.u.compact.size); } /* end if */ } break; case H5D_CONTIGUOUS: /* Don't write default fill values to external files */ /* If we will be immediately overwriting the values, don't bother to clear them */ if((dset->shared->efl.nused==0 || dset->shared->fill.buf) && !full_overwrite) { if (H5D_contig_fill(dset, dxpl_id)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to allocate all chunks of dataset") } /* end if */ break; case H5D_CHUNKED: /* * Allocate file space * for all chunks now and initialize each chunk with the fill value. */ if (H5D_istore_allocate(dset, dxpl_id, full_overwrite)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to allocate all chunks of dataset") break; default: assert ("not implemented yet" && 0); #ifdef NDEBUG HGOTO_ERROR (H5E_IO, H5E_UNSUPPORTED, FAIL, "unsupported storage layout") #endif /* NDEBUG */ } /* end switch */ /*lint !e788 All appropriate cases are covered */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_init_storage() */ /*------------------------------------------------------------------------- * Function: H5Dget_storage_size * * Purpose: Returns the amount of storage that is required for the * dataset. For chunked datasets this is the number of allocated * chunks times the chunk size. * * Return: Success: The amount of storage space allocated for the * dataset, not counting meta data. The return * value may be zero if no data has been stored. * * Failure: Zero * * Programmer: Robb Matzke * Wednesday, April 21, 1999 * * Modifications: * *------------------------------------------------------------------------- */ hsize_t H5Dget_storage_size(hid_t dset_id) { H5D_t *dset=NULL; hsize_t ret_value; /* Return value */ FUNC_ENTER_API(H5Dget_storage_size, 0) H5TRACE1("h","i",dset_id); /* Check args */ if (NULL==(dset=H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a dataset") /* Set return value */ ret_value = H5D_get_storage_size(dset,H5AC_ind_dxpl_id); done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5D_get_storage_size * * Purpose: Determines how much space has been reserved to store the raw * data of a dataset. * * Return: Success: Number of bytes reserved to hold raw data. * * Failure: 0 * * Programmer: Robb Matzke * Wednesday, April 21, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static hsize_t H5D_get_storage_size(H5D_t *dset, hid_t dxpl_id) { hsize_t ret_value; FUNC_ENTER_NOAPI(H5D_get_storage_size, 0) switch(dset->shared->layout.type) { case H5D_CHUNKED: if(dset->shared->layout.u.chunk.addr == HADDR_UNDEF) ret_value=0; else ret_value = H5D_istore_allocated(dset, dxpl_id); break; case H5D_CONTIGUOUS: /* Datasets which are not allocated yet are using no space on disk */ if(dset->shared->layout.u.contig.addr == HADDR_UNDEF) ret_value=0; else ret_value=dset->shared->layout.u.contig.size; break; case H5D_COMPACT: ret_value = dset->shared->layout.u.compact.size; break; default: HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a dataset type") } /*lint !e788 All appropriate cases are covered */ done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5Dget_offset * * Purpose: Returns the address of dataset in file. * * Return: Success: the address of dataset * * Failure: HADDR_UNDEF * * Programmer: Raymond Lu * November 6, 2002 * * Modifications: * *------------------------------------------------------------------------- */ haddr_t H5Dget_offset(hid_t dset_id) { H5D_t *dset=NULL; haddr_t ret_value; /* Return value */ FUNC_ENTER_API(H5Dget_offset, HADDR_UNDEF) H5TRACE1("a","i",dset_id); /* Check args */ if (NULL==(dset=H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, HADDR_UNDEF, "not a dataset") /* Set return value */ ret_value = H5D_get_offset(dset); done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5D_get_offset * * Purpose: Private function for H5D_get_offset. Returns the address * of dataset in file. * * Return: Success: the address of dataset * * Failure: HADDR_UNDEF * * Programmer: Raymond Lu * November 6, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static haddr_t H5D_get_offset(const H5D_t *dset) { haddr_t ret_value=HADDR_UNDEF; haddr_t base_addr; H5F_t *f; FUNC_ENTER_NOAPI(H5D_get_offset, HADDR_UNDEF) assert(dset); switch(dset->shared->layout.type) { case H5D_CHUNKED: case H5D_COMPACT: break; case H5D_CONTIGUOUS: /* If dataspace hasn't been allocated or dataset is stored in * an external file, the value will be HADDR_UNDEF. */ f = H5D_get_file(dset); base_addr = H5F_get_base_addr(f); /* If there's user block in file, returns the absolute dataset offset * from the beginning of file. */ if(base_addr!=HADDR_UNDEF) ret_value = dset->shared->layout.u.contig.addr + base_addr; else ret_value = dset->shared->layout.u.contig.addr; break; default: assert ("not implemented yet" && 0); #ifdef NDEBUG HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, HADDR_UNDEF, "unknown dataset layout type") #endif /* NDEBUG */ } /*lint !e788 All appropriate cases are covered */ done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5Diterate * * Purpose: This routine iterates over all the elements selected in a memory * buffer. The callback function is called once for each element selected * in the dataspace. The selection in the dataspace is modified so * that any elements already iterated over are removed from the selection * if the iteration is interrupted (by the H5D_operator_t function * returning non-zero) in the "middle" of the iteration and may be * re-started by the user where it left off. * * NOTE: Until "subtracting" elements from a selection is implemented, * the selection is not modified. * * Parameters: * void *buf; IN/OUT: Pointer to the buffer in memory containing * the elements to iterate over. * hid_t type_id; IN: Datatype ID for the elements stored in BUF. * hid_t space_id; IN: Dataspace ID for BUF, also contains the * selection to iterate over. * H5D_operator_t op; IN: Function pointer to the routine to be * called for each element in BUF iterated over. * void *operator_data; IN/OUT: Pointer to any user-defined data * associated with the operation. * * Operation information: * H5D_operator_t is defined as: * typedef herr_t (*H5D_operator_t)(void *elem, hid_t type_id, * unsigned ndim, const hsize_t *point, void *operator_data); * * H5D_operator_t parameters: * void *elem; IN/OUT: Pointer to the element in memory containing * the current point. * hid_t type_id; IN: Datatype ID for the elements stored in ELEM. * unsigned ndim; IN: Number of dimensions for POINT array * const hsize_t *point; IN: Array containing the location of the element * within the original dataspace. * void *operator_data; IN/OUT: Pointer to any user-defined data * associated with the operation. * * The return values from an operator are: * Zero causes the iterator to continue, returning zero when all * elements have been processed. * Positive causes the iterator to immediately return that positive * value, indicating short-circuit success. The iterator can be * restarted at the next element. * Negative causes the iterator to immediately return that value, * indicating failure. The iterator can be restarted at the next * element. * * Return: Returns the return value of the last operator if it was non-zero, * or zero if all elements were processed. Otherwise returns a * negative value. * * Programmer: Quincey Koziol * Friday, June 11, 1999 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Diterate(void *buf, hid_t type_id, hid_t space_id, H5D_operator_t op, void *operator_data) { H5S_t *space = NULL; herr_t ret_value; FUNC_ENTER_API(H5Diterate, FAIL) H5TRACE5("e","xiixx",buf,type_id,space_id,op,operator_data); /* Check args */ if (NULL==op) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid operator") if (buf==NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid buffer") if (H5I_DATATYPE != H5I_get_type(type_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid datatype") if (NULL == (space = H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataspace") if( !(H5S_has_extent(space)) ) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspace does not have extent set") ret_value=H5S_select_iterate(buf,type_id,space,op,operator_data); done: FUNC_LEAVE_API(ret_value) } /* end H5Diterate() */ /*------------------------------------------------------------------------- * Function: H5Dvlen_reclaim * * Purpose: Frees the buffers allocated for storing variable-length data * in memory. Only frees the VL data in the selection defined in the * dataspace. The dataset transfer property list is required to find the * correct allocation/free methods for the VL data in the buffer. * * Return: Non-negative on success, negative on failure * * Programmer: Quincey Koziol * Thursday, June 10, 1999 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Dvlen_reclaim(hid_t type_id, hid_t space_id, hid_t plist_id, void *buf) { H5T_vlen_alloc_info_t _vl_alloc_info; /* VL allocation info buffer */ H5T_vlen_alloc_info_t *vl_alloc_info=&_vl_alloc_info; /* VL allocation info */ herr_t ret_value; FUNC_ENTER_API(H5Dvlen_reclaim, FAIL) H5TRACE4("e","iiix",type_id,space_id,plist_id,buf); /* Check args */ if (H5I_DATATYPE!=H5I_get_type(type_id) || H5I_DATASPACE!=H5I_get_type(space_id) || buf==NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument") /* Get the default dataset transfer property list if the user didn't provide one */ if (H5P_DEFAULT == plist_id) plist_id= H5P_DATASET_XFER_DEFAULT; else if (TRUE!=H5P_isa_class(plist_id,H5P_DATASET_XFER)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") /* Get the allocation info */ if(H5T_vlen_get_alloc_info(plist_id,&vl_alloc_info)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to retrieve VL allocation info"); /* Call H5Diterate with args, etc. */ ret_value=H5Diterate(buf,type_id,space_id,H5T_vlen_reclaim,vl_alloc_info); done: FUNC_LEAVE_API(ret_value) } /* end H5Dvlen_reclaim() */ /*------------------------------------------------------------------------- * Function: H5D_vlen_get_buf_size_alloc * * Purpose: This routine makes certain there is enough space in the temporary * buffer for the new data to read in. All the VL data read in is actually * placed in this buffer, overwriting the previous data. Needless to say, * this data is not actually usable. * * Return: Non-negative on success, negative on failure * * Programmer: Quincey Koziol * Tuesday, August 17, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static void * H5D_vlen_get_buf_size_alloc(size_t size, void *info) { H5D_vlen_bufsize_t *vlen_bufsize=(H5D_vlen_bufsize_t *)info; void *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5D_vlen_get_buf_size_alloc, NULL) /* Get a temporary pointer to space for the VL data */ if ((vlen_bufsize->vl_tbuf=H5FL_BLK_REALLOC(vlen_vl_buf,vlen_bufsize->vl_tbuf,size))!=NULL) vlen_bufsize->size+=size; /* Set return value */ ret_value=vlen_bufsize->vl_tbuf; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_vlen_get_buf_size_alloc() */ /*------------------------------------------------------------------------- * Function: H5D_vlen_get_buf_size * * Purpose: This routine checks the number of bytes required to store a single * element from a dataset in memory, creating a selection with just the * single element selected to read in the element and using a custom memory * allocator for any VL data encountered. * The *size value is modified according to how many bytes are * required to store the element in memory. * * Implementation: This routine actually performs the read with a custom * memory manager which basically just counts the bytes requested and * uses a temporary memory buffer (through the H5FL API) to make certain * enough space is available to perform the read. Then the temporary * buffer is released and the number of bytes allocated is returned. * Kinda kludgy, but easier than the other method of trying to figure out * the sizes without actually reading the data in... - QAK * * Return: Non-negative on success, negative on failure * * Programmer: Quincey Koziol * Tuesday, August 17, 1999 * * Modifications: * *------------------------------------------------------------------------- */ /* ARGSUSED */ static herr_t H5D_vlen_get_buf_size(void UNUSED *elem, hid_t type_id, unsigned UNUSED ndim, const hsize_t *point, void *op_data) { H5D_vlen_bufsize_t *vlen_bufsize=(H5D_vlen_bufsize_t *)op_data; H5T_t *dt = NULL; herr_t ret_value=0; /* The correct return value, if this function succeeds */ FUNC_ENTER_NOAPI(H5D_vlen_get_buf_size, FAIL) assert(op_data); assert(H5I_DATATYPE == H5I_get_type(type_id)); /* Check args */ if (NULL==(dt=H5I_object(type_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") /* Make certain there is enough fixed-length buffer available */ if ((vlen_bufsize->fl_tbuf=H5FL_BLK_REALLOC(vlen_fl_buf,vlen_bufsize->fl_tbuf,H5T_get_size(dt)))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't resize tbuf") /* Select point to read in */ if (H5Sselect_elements(vlen_bufsize->fspace_id,H5S_SELECT_SET,1,(const hsize_t **)point)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't select point") /* Read in the point (with the custom VL memory allocator) */ if(H5Dread(vlen_bufsize->dataset_id,type_id,vlen_bufsize->mspace_id,vlen_bufsize->fspace_id,vlen_bufsize->xfer_pid,vlen_bufsize->fl_tbuf)<0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read point") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_vlen_get_buf_size() */ /*------------------------------------------------------------------------- * Function: H5Dvlen_get_buf_size * * Purpose: This routine checks the number of bytes required to store the VL * data from the dataset, using the space_id for the selection in the * dataset on disk and the type_id for the memory representation of the * VL data, in memory. The *size value is modified according to how many * bytes are required to store the VL data in memory. * * Implementation: This routine actually performs the read with a custom * memory manager which basically just counts the bytes requested and * uses a temporary memory buffer (through the H5FL API) to make certain * enough space is available to perform the read. Then the temporary * buffer is released and the number of bytes allocated is returned. * Kinda kludgy, but easier than the other method of trying to figure out * the sizes without actually reading the data in... - QAK * * Return: Non-negative on success, negative on failure * * Programmer: Quincey Koziol * Wednesday, August 11, 1999 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Dvlen_get_buf_size(hid_t dataset_id, hid_t type_id, hid_t space_id, hsize_t *size) { H5D_vlen_bufsize_t vlen_bufsize = {0, 0, 0, 0, 0, 0, 0}; char bogus; /* bogus value to pass to H5Diterate() */ H5P_genclass_t *pclass; /* Property class */ H5P_genplist_t *plist; /* Property list */ herr_t ret_value=FAIL; FUNC_ENTER_API(H5Dvlen_get_buf_size, FAIL) H5TRACE4("e","iii*h",dataset_id,type_id,space_id,size); /* Check args */ if (H5I_DATASET!=H5I_get_type(dataset_id) || H5I_DATATYPE!=H5I_get_type(type_id) || H5I_DATASPACE!=H5I_get_type(space_id) || size==NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument") /* Save the dataset ID */ vlen_bufsize.dataset_id=dataset_id; /* Get a copy of the dataspace ID */ if((vlen_bufsize.fspace_id=H5Dget_space(dataset_id))<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy dataspace") /* Create a scalar for the memory dataspace */ if((vlen_bufsize.mspace_id=H5Screate(H5S_SCALAR))<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't create dataspace") /* Grab the temporary buffers required */ if((vlen_bufsize.fl_tbuf=H5FL_BLK_MALLOC(vlen_fl_buf,1))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "no temporary buffers available") if((vlen_bufsize.vl_tbuf=H5FL_BLK_MALLOC(vlen_vl_buf,1))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "no temporary buffers available") /* Get the pointer to the dataset transfer class */ if (NULL == (pclass = H5I_object(H5P_CLS_DATASET_XFER_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class") /* Change to the custom memory allocation routines for reading VL data */ if((vlen_bufsize.xfer_pid=H5P_create_id(pclass))<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, FAIL, "no dataset xfer plists available") /* Get the property list struct */ if (NULL == (plist = H5I_object(vlen_bufsize.xfer_pid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list") /* Set the memory manager to the special allocation routine */ if(H5P_set_vlen_mem_manager(plist,H5D_vlen_get_buf_size_alloc,&vlen_bufsize,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set VL data allocation routine") /* Set the initial number of bytes required */ vlen_bufsize.size=0; /* Call H5Diterate with args, etc. */ ret_value=H5Diterate(&bogus,type_id,space_id,H5D_vlen_get_buf_size,&vlen_bufsize); /* Get the size if we succeeded */ if(ret_value>=0) *size=vlen_bufsize.size; done: if(vlen_bufsize.fspace_id>0) { if(H5I_dec_ref(vlen_bufsize.fspace_id)<0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace") } /* end if */ if(vlen_bufsize.mspace_id>0) { if(H5I_dec_ref(vlen_bufsize.mspace_id)<0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace") } /* end if */ if(vlen_bufsize.fl_tbuf!=NULL) H5FL_BLK_FREE(vlen_fl_buf,vlen_bufsize.fl_tbuf); if(vlen_bufsize.vl_tbuf!=NULL) H5FL_BLK_FREE(vlen_vl_buf,vlen_bufsize.vl_tbuf); if(vlen_bufsize.xfer_pid>0) { if(H5I_dec_ref(vlen_bufsize.xfer_pid)<0) HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to decrement ref count on property list") } /* end if */ FUNC_LEAVE_API(ret_value) } /* end H5Dvlen_get_buf_size() */ /*------------------------------------------------------------------------- * Function: H5Dset_extent * * Purpose: Modifies the dimensions of a dataset, based on H5Dextend. * Can change to a lower dimension. * * Return: Success: SUCCEED, Failure: FAIL * * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu * Robb Matzke * * Date: April 9, 2002 * * Comments: Public function, calls private H5D_set_extent * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Dset_extent(hid_t dset_id, const hsize_t *size) { H5D_t *dset = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Dset_extent, FAIL) H5TRACE2("e","i*h",dset_id,size); /* Check args */ if(NULL == (dset = H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") if(!size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no size specified") /* Private function */ if(H5D_set_extent(dset, size, H5AC_dxpl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set extend dataset") done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5D_set_extent * * Purpose: Based in H5D_extend, allows change to a lower dimension, * calls H5S_set_extent and H5D_istore_prune_by_extent instead * * Return: Success: SUCCEED, Failure: FAIL * * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu * Robb Matzke * * Date: April 9, 2002 * * Comments: Private function * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5D_set_extent(H5D_t *dset, const hsize_t *size, hid_t dxpl_id) { hsize_t curr_dims[H5O_LAYOUT_NDIMS]; /* Current dimension sizes */ int rank; /* Dataspace # of dimensions */ herr_t ret_value = SUCCEED; /* Return value */ H5S_t *space = NULL; int u; unsigned shrink = 0; /* Flag to indicate a dimension has shrank */ unsigned expand = 0; /* Flag to indicate a dimension has grown */ int changed = 0; FUNC_ENTER_NOAPI(H5D_set_extent, FAIL) /* Check args */ assert(dset); assert(size); /*------------------------------------------------------------------------- * Get the data space *------------------------------------------------------------------------- */ space = dset->shared->space; /*------------------------------------------------------------------------- * Check if we are shrinking or expanding any of the dimensions *------------------------------------------------------------------------- */ if((rank = H5S_get_simple_extent_dims(space, curr_dims, NULL)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataset dimensions") for(u = 0; u < rank; u++) { if(size[u] < curr_dims[u]) shrink = 1; if(size[u] > curr_dims[u]) expand = 1; } /*------------------------------------------------------------------------- * Modify the size of the data space *------------------------------------------------------------------------- */ if((changed=H5S_set_extent(space, size)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to modify size of data space") /* Don't bother updating things, unless they've changed */ if(changed) { /*------------------------------------------------------------------------- * Modify the dataset storage *------------------------------------------------------------------------- */ /* Save the new dataspace in the file if necessary */ if(H5S_modify(&(dset->ent), space, TRUE, dxpl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update file with new dataspace") /* Update the index values for the cached chunks for this dataset */ if(H5D_CHUNKED == dset->shared->layout.type) if(H5D_istore_update_cache(dset, dxpl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update cached chunk indices") /* Allocate space for the new parts of the dataset, if appropriate */ if(expand && dset->shared->alloc_time==H5D_ALLOC_TIME_EARLY) if(H5D_alloc_storage(dset->ent.file, dxpl_id, dset, H5D_ALLOC_EXTEND, TRUE, FALSE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize dataset storage") /*------------------------------------------------------------------------- * Remove chunk information in the case of chunked datasets * This removal takes place only in case we are shrinking the dateset *------------------------------------------------------------------------- */ if(shrink && H5D_CHUNKED == dset->shared->layout.type) { H5D_io_info_t io_info; /* Dataset I/O info */ H5D_dxpl_cache_t _dxpl_cache; /* Data transfer property cache buffer */ H5D_dxpl_cache_t *dxpl_cache=&_dxpl_cache; /* Data transfer property cache */ /* Fill the DXPL cache values for later use */ if (H5D_get_dxpl_cache(dxpl_id,&dxpl_cache)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't fill dxpl cache") /* Construct dataset I/O info */ H5D_BUILD_IO_INFO(&io_info,dset,dxpl_cache,dxpl_id,NULL); /* Remove excess chunks */ if(H5D_istore_prune_by_extent(&io_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to remove chunks ") /* Reset the elements outsize the new dimensions, but in existing chunks */ if(H5D_istore_initialize_by_extent(&io_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to initialize chunks ") } /* end if */ } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5D_flush * * Purpose: Flush any dataset information cached in memory * * Return: Success: Non-negative * Failure: Negative * * * Programmer: Ray Lu * * Date: August 14, 2002 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5D_flush(const H5F_t *f, hid_t dxpl_id, unsigned flags) { unsigned num_dsets; /* Number of datasets in file */ hid_t *id_list=NULL; /* list of dataset IDs */ H5D_t *dataset=NULL; /* Dataset pointer */ unsigned u; /* Index variable */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5D_flush, FAIL) /* Check args */ assert(f); /* Update layout message for compact dataset */ num_dsets=H5F_get_obj_count(f, H5F_OBJ_DATASET); /* Check for something to do */ if(num_dsets>0) { H5_CHECK_OVERFLOW(num_dsets,unsigned,size_t); if(NULL==(id_list=H5MM_malloc((size_t)num_dsets*sizeof(hid_t)))) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to allocate memory for ID list") if(H5F_get_obj_ids(f, H5F_OBJ_DATASET, -1, id_list) != num_dsets) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to get dataset ID list") for(u = 0; u < num_dsets; u++) { if(NULL==(dataset=H5I_object_verify(id_list[u], H5I_DATASET))) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to get dataset object") /* Flush the raw data buffer, if we have a dirty one */ if (dataset->shared->cache.contig.sieve_buf && dataset->shared->cache.contig.sieve_dirty) { assert(dataset->shared->layout.type!=H5D_COMPACT); /* We should never have a sieve buffer for compact storage */ /* Write dirty data sieve buffer to file */ if (H5F_block_write(f, H5FD_MEM_DRAW, dataset->shared->cache.contig.sieve_loc, dataset->shared->cache.contig.sieve_size, dxpl_id, dataset->shared->cache.contig.sieve_buf) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "block write failed") /* Reset sieve buffer dirty flag */ dataset->shared->cache.contig.sieve_dirty=0; } /* end if */ /* Flush cached information for each kind of dataset */ switch(dataset->shared->layout.type) { case H5D_CONTIGUOUS: break; case H5D_CHUNKED: /* Flush the raw data cache */ if (H5D_istore_flush(dataset, dxpl_id, flags & (H5F_FLUSH_INVALIDATE | H5F_FLUSH_CLEAR_ONLY)) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush raw data cache") break; case H5D_COMPACT: if(dataset->shared->layout.u.compact.dirty) { if(H5O_modify(&(dataset->ent), H5O_LAYOUT_ID, 0, 0, H5O_UPDATE_TIME, &(dataset->shared->layout), dxpl_id)<0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to update layout message") dataset->shared->layout.u.compact.dirty = FALSE; } /* end if */ break; default: assert ("not implemented yet" && 0); #ifdef NDEBUG HGOTO_ERROR (H5E_IO, H5E_UNSUPPORTED, FAIL, "unsupported storage layout") #endif /* NDEBUG */ } /* end switch */ /*lint !e788 All appropriate cases are covered */ } } /* end if */ done: if(id_list!=NULL) H5MM_xfree(id_list); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_flush() */ /*------------------------------------------------------------------------- * Function: H5Ddebug * * Purpose: Prints various information about a dataset. This function is * not to be documented in the API at this time. * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Wednesday, April 28, 1999 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Ddebug(hid_t dset_id) { H5D_t *dset=NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Ddebug, FAIL) H5TRACE1("e","i",dset_id); /* Check args */ if (NULL==(dset=H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") /* Print B-tree information */ if (H5D_CHUNKED==dset->shared->layout.type) { (void)H5D_istore_dump_btree(dset->ent.file, H5AC_dxpl_id, stdout, dset->shared->layout.u.chunk.ndims, dset->shared->layout.u.chunk.addr); } else if (H5D_CONTIGUOUS==dset->shared->layout.type) { HDfprintf(stdout, " %-10s %a\n", "Address:", dset->shared->layout.u.contig.addr); } done: FUNC_LEAVE_API(ret_value) } xdmf-3.0+git20160803/Utilities/hdf5/H5B.c0000640000175000017500000023773613003006557017437 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*------------------------------------------------------------------------- * * Created: hdf5btree.c * Jul 10 1997 * Robb Matzke * * Purpose: Implements balanced, sibling-linked, N-ary trees * capable of storing any type of data with unique key * values. * * A B-link-tree is a balanced tree where each node has * a pointer to its left and right siblings. A * B-link-tree is a rooted tree having the following * properties: * * 1. Every node, x, has the following fields: * * a. level[x], the level in the tree at which node * x appears. Leaf nodes are at level zero. * * b. n[x], the number of children pointed to by the * node. Internal nodes point to subtrees while * leaf nodes point to arbitrary data. * * c. The child pointers themselves, child[x,i] such * that 0 <= i < n[x]. * * d. n[x]+1 key values stored in increasing * order: * * key[x,0] < key[x,1] < ... < key[x,n[x]]. * * e. left[x] is a pointer to the node's left sibling * or the null pointer if this is the left-most * node at this level in the tree. * * f. right[x] is a pointer to the node's right * sibling or the null pointer if this is the * right-most node at this level in the tree. * * 3. The keys key[x,i] partition the key spaces of the * children of x: * * key[x,i] <= key[child[x,i],j] <= key[x,i+1] * * for any valid combination of i and j. * * 4. There are lower and upper bounds on the number of * child pointers a node can contain. These bounds * can be expressed in terms of a fixed integer k>=2 * called the `minimum degree' of the B-tree. * * a. Every node other than the root must have at least * k child pointers and k+1 keys. If the tree is * nonempty, the root must have at least one child * pointer and two keys. * * b. Every node can contain at most 2k child pointers * and 2k+1 keys. A node is `full' if it contains * exactly 2k child pointers and 2k+1 keys. * * 5. When searching for a particular value, V, and * key[V] = key[x,i] for some node x and entry i, * then: * * a. If i=0 the child[0] is followed. * * b. If i=n[x] the child[n[x]-1] is followed. * * c. Otherwise, the child that is followed * (either child[x,i-1] or child[x,i]) is * determined by the type of object to which the * leaf nodes of the tree point and is controlled * by the key comparison function registered for * that type of B-tree. * * * Modifications: * * Robb Matzke, 4 Aug 1997 * Added calls to H5E. * *------------------------------------------------------------------------- */ #define H5B_PACKAGE /*suppress error about including H5Bpkg */ #define H5F_PACKAGE /*suppress error about including H5Fpkg */ /* private headers */ #include "H5private.h" /* Generic Functions */ #include "H5ACprivate.h" /* Metadata cache */ #include "H5Bpkg.h" /* B-link trees */ #include "H5Dprivate.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* File access */ #include "H5FLprivate.h" /* Free Lists */ #include "H5Iprivate.h" /* IDs */ #include "H5MFprivate.h" /* File memory management */ #include "H5MMprivate.h" /* Memory management */ #include "H5Pprivate.h" /* Property lists */ /* Local macros */ #define H5B_SIZEOF_HDR(F) \ (H5B_SIZEOF_MAGIC + /*magic number */ \ 4 + /*type, level, num entries */ \ 2*H5F_SIZEOF_ADDR(F)) /*left and right sibling addresses */ #define H5B_NKEY(b,shared,idx) ((b)->native+(shared)->nkey[(idx)]) /* Local typedefs */ /* PRIVATE PROTOTYPES */ static H5B_ins_t H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type, uint8_t *lt_key, hbool_t *lt_key_changed, uint8_t *md_key, void *udata, uint8_t *rt_key, hbool_t *rt_key_changed, haddr_t *retval); static herr_t H5B_insert_child(H5B_t *bt, unsigned idx, haddr_t child, H5B_ins_t anchor, const void *md_key); static herr_t H5B_split(H5F_t *f, hid_t dxpl_id, H5B_t *old_bt, haddr_t old_addr, unsigned idx, void *udata, haddr_t *new_addr/*out*/); static H5B_t * H5B_copy(const H5B_t *old_bt); static herr_t H5B_serialize(const H5F_t *f, const H5B_t *bt); #ifdef H5B_DEBUG static herr_t H5B_assert(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type, void *udata); #endif /* Metadata cache callbacks */ static H5B_t *H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata); static herr_t H5B_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B_t *b); static herr_t H5B_dest(H5F_t *f, H5B_t *b); static herr_t H5B_clear(H5F_t *f, H5B_t *b, hbool_t destroy); static herr_t H5B_compute_size(const H5F_t *f, const H5B_t *bt, size_t *size_ptr); /* H5B inherits cache-like properties from H5AC */ static const H5AC_class_t H5AC_BT[1] = {{ H5AC_BT_ID, (H5AC_load_func_t)H5B_load, (H5AC_flush_func_t)H5B_flush, (H5AC_dest_func_t)H5B_dest, (H5AC_clear_func_t)H5B_clear, (H5AC_size_func_t)H5B_compute_size, }}; /* Declare a PQ free list to manage the native block information */ H5FL_BLK_DEFINE_STATIC(native_block); /* Declare a free list to manage the haddr_t sequence information */ H5FL_SEQ_DEFINE_STATIC(haddr_t); /* Declare a free list to manage the H5B_shared_t struct */ H5FL_DEFINE(H5B_shared_t); /* Declare a free list to manage the H5B_t struct */ H5FL_DEFINE_STATIC(H5B_t); /*------------------------------------------------------------------------- * Function: H5B_create * * Purpose: Creates a new empty B-tree leaf node. The UDATA pointer is * passed as an argument to the sizeof_rkey() method for the * B-tree. * * Return: Success: Non-negative, and the address of new node is * returned through the ADDR_P argument. * * Failure: Negative * * Programmer: Robb Matzke * matzke@llnl.gov * Jun 23 1997 * * Modifications: * Robb Matzke, 1999-07-28 * Changed the name of the ADDR argument to ADDR_P to make it * obvious that the address is passed by reference unlike most * other functions that take addresses. *------------------------------------------------------------------------- */ herr_t H5B_create(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, void *udata, haddr_t *addr_p/*out*/) { H5B_t *bt = NULL; H5B_shared_t *shared=NULL; /* Pointer to shared B-tree info */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5B_create, FAIL) /* * Check arguments. */ assert(f); assert(type); assert(addr_p); /* * Allocate file and memory data structures. */ if (NULL==(bt = H5FL_MALLOC(H5B_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree root node") HDmemset(&bt->cache_info,0,sizeof(H5AC_info_t)); bt->cache_info.is_dirty = TRUE; bt->level = 0; bt->left = HADDR_UNDEF; bt->right = HADDR_UNDEF; bt->nchildren = 0; if((bt->rc_shared=(type->get_shared)(f, udata))==NULL) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't retrieve B-tree node buffer") shared=H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); if (NULL==(bt->native=H5FL_BLK_MALLOC(native_block,shared->sizeof_keys)) || NULL==(bt->child=H5FL_SEQ_MALLOC(haddr_t,(size_t)shared->two_k))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree root node") if (HADDR_UNDEF==(*addr_p=H5MF_alloc(f, H5FD_MEM_BTREE, dxpl_id, (hsize_t)shared->sizeof_rnode))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for B-tree root node") /* * Cache the new B-tree node. */ if (H5AC_set(f, dxpl_id, H5AC_BT, *addr_p, bt) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't add B-tree root node to cache") #ifdef H5B_DEBUG H5B_assert(f, dxpl_id, *addr_p, shared->type, udata); #endif done: if (ret_value<0) { if(shared && shared->sizeof_rnode>0) { H5_CHECK_OVERFLOW(shared->sizeof_rnode,size_t,hsize_t); (void)H5MF_xfree(f, H5FD_MEM_BTREE, dxpl_id, *addr_p, (hsize_t)shared->sizeof_rnode); } /* end if */ if (bt) (void)H5B_dest(f,bt); } FUNC_LEAVE_NOAPI(ret_value) } /*lint !e818 Can't make udata a pointer to const */ /*------------------------------------------------------------------------- * Function: H5B_load * * Purpose: Loads a B-tree node from the disk. * * Return: Success: Pointer to a new B-tree node. * * Failure: NULL * * Programmer: Robb Matzke * matzke@llnl.gov * Jun 23 1997 * * Modifications: * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. * * Quincey Koziol, 2002-7-180 * Added dxpl parameter to allow more control over I/O from metadata * cache. *------------------------------------------------------------------------- */ static H5B_t * H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata) { const H5B_class_t *type = (const H5B_class_t *) _type; H5B_t *bt = NULL; H5B_shared_t *shared; /* Pointer to shared B-tree info */ uint8_t *p; /* Pointer into raw data buffer */ uint8_t *native; /* Pointer to native keys */ unsigned u; /* Local index variable */ H5B_t *ret_value; FUNC_ENTER_NOAPI(H5B_load, NULL) /* Check arguments */ assert(f); assert(H5F_addr_defined(addr)); assert(type); assert(type->get_shared); if (NULL==(bt = H5FL_MALLOC(H5B_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") HDmemset(&bt->cache_info,0,sizeof(H5AC_info_t)); if((bt->rc_shared=(type->get_shared)(f, udata))==NULL) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "can't retrieve B-tree node buffer") shared=H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); if (NULL==(bt->native=H5FL_BLK_MALLOC(native_block,shared->sizeof_keys)) || NULL==(bt->child=H5FL_SEQ_MALLOC(haddr_t,(size_t)shared->two_k))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") if (H5F_block_read(f, H5FD_MEM_BTREE, addr, shared->sizeof_rnode, dxpl_id, shared->page)<0) HGOTO_ERROR(H5E_BTREE, H5E_READERROR, NULL, "can't read B-tree node") p = shared->page; /* magic number */ if (HDmemcmp(p, H5B_MAGIC, (size_t)H5B_SIZEOF_MAGIC)) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "wrong B-tree signature") p += 4; /* node type and level */ if (*p++ != (uint8_t)type->id) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "incorrect B-tree node type") bt->level = *p++; /* entries used */ UINT16DECODE(p, bt->nchildren); /* sibling pointers */ H5F_addr_decode(f, (const uint8_t **) &p, &(bt->left)); H5F_addr_decode(f, (const uint8_t **) &p, &(bt->right)); /* the child/key pairs */ native=bt->native; for (u = 0; u < bt->nchildren; u++) { /* Decode native key value */ if ((type->decode) (f, bt, p, native) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, NULL, "unable to decode key") p += shared->sizeof_rkey; native += type->sizeof_nkey; /* Decode address value */ H5F_addr_decode(f, (const uint8_t **) &p, bt->child + u); } /* Decode final key */ if(bt->nchildren>0) { /* Decode native key value */ if ((type->decode) (f, bt, p, native) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, NULL, "unable to decode key") } /* end if */ /* Set return value */ ret_value = bt; done: if (!ret_value && bt) (void)H5B_dest(f,bt); FUNC_LEAVE_NOAPI(ret_value) } /*lint !e818 Can't make udata a pointer to const */ /*------------------------------------------------------------------------- * Function: H5B_serialize * * Purpose: Serialize the data structure for writing to disk or * storing on the SAP (for FPHDF5). * * Return: Success: SUCCEED * Failure: FAIL * * Programmer: Bill Wendling * wendling@ncsa.uiuc.edu * Sept. 15, 2003 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5B_serialize(const H5F_t *f, const H5B_t *bt) { H5B_shared_t *shared=NULL; /* Pointer to shared B-tree info */ unsigned u; uint8_t *p; /* Pointer into raw data buffer */ uint8_t *native; /* Pointer to native keys */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5B_serialize, FAIL) /* check arguments */ assert(f); assert(bt); assert(bt->rc_shared); shared=H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); p = shared->page; /* magic number */ HDmemcpy(p, H5B_MAGIC, (size_t)H5B_SIZEOF_MAGIC); p += 4; /* node type and level */ *p++ = (uint8_t)shared->type->id; H5_CHECK_OVERFLOW(bt->level, unsigned, uint8_t); *p++ = (uint8_t)bt->level; /* entries used */ UINT16ENCODE(p, bt->nchildren); /* sibling pointers */ H5F_addr_encode(f, &p, bt->left); H5F_addr_encode(f, &p, bt->right); /* child keys and pointers */ native=bt->native; for (u = 0; u < bt->nchildren; ++u) { /* encode the key */ if (shared->type->encode(f, bt, p, native) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, FAIL, "unable to encode B-tree key") p += shared->sizeof_rkey; native += shared->type->sizeof_nkey; /* encode the child address */ H5F_addr_encode(f, &p, bt->child[u]); } /* end for */ if(bt->nchildren>0) { /* Encode the final key */ if (shared->type->encode(f, bt, p, native) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, FAIL, "unable to encode B-tree key") } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5B_flush * * Purpose: Flushes a dirty B-tree node to disk. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Jun 23 1997 * * Modifications: * rky 980828 * Only p0 writes metadata to disk. * * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. * * Quincey Koziol, 2002-7-180 * Added dxpl parameter to allow more control over I/O from metadata * cache. * * Bill Wendling, 2003-09-15 * Separated out the bit of code that serializes the B-Tree * structure. * *------------------------------------------------------------------------- */ static herr_t H5B_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B_t *bt) { H5B_shared_t *shared; /* Pointer to shared B-tree info */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5B_flush, FAIL) /* check arguments */ assert(f); assert(H5F_addr_defined(addr)); assert(bt); shared=H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); assert(shared->type); assert(shared->type->encode); if (bt->cache_info.is_dirty) { if (H5B_serialize(f, bt) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSERIALIZE, FAIL, "unable to serialize B-tree") /* * Write the disk page. We always write the header, but we don't * bother writing data for the child entries that don't exist or * for the final unchanged children. */ if (H5F_block_write(f, H5FD_MEM_BTREE, addr, shared->sizeof_rnode, dxpl_id, shared->page) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTFLUSH, FAIL, "unable to save B-tree node to disk") bt->cache_info.is_dirty = FALSE; } /* end if */ if (destroy) if (H5B_dest(f,bt) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree node") done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5B_dest * * Purpose: Destroys a B-tree node in memory. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * Jan 15 2003 * * Modifications: * *------------------------------------------------------------------------- */ /* ARGSUSED */ static herr_t H5B_dest(H5F_t UNUSED *f, H5B_t *bt) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B_dest) /* * Check arguments. */ assert(bt); assert(bt->rc_shared); H5FL_SEQ_FREE(haddr_t,bt->child); H5FL_BLK_FREE(native_block,bt->native); H5RC_DEC(bt->rc_shared); H5FL_FREE(H5B_t,bt); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5B_dest() */ /*------------------------------------------------------------------------- * Function: H5B_clear * * Purpose: Mark a B-tree node in memory as non-dirty. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * Mar 20 2003 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5B_clear(H5F_t *f, H5B_t *bt, hbool_t destroy) { herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT(H5B_clear) /* * Check arguments. */ assert(bt); /* Reset the dirty flag. */ bt->cache_info.is_dirty = FALSE; if (destroy) if (H5B_dest(f, bt) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree node") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_clear() */ /*------------------------------------------------------------------------- * Function: H5B_compute_size * * Purpose: Compute the size in bytes of the specified instance of * H5B_t on disk, and return it in *len_ptr. On failure, * the value of *len_ptr is undefined. * * Return: Non-negative on success/Negative on failure * * Programmer: John Mainzer * 5/13/04 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5B_compute_size(const H5F_t *f, const H5B_t *bt, size_t *size_ptr) { H5B_shared_t *shared; /* Pointer to shared B-tree info */ size_t size; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5B_compute_size) /* check arguments */ HDassert(f); HDassert(bt); HDassert(bt->rc_shared); shared=H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); HDassert(shared->type); HDassert(size_ptr); /* Check node's size */ if ((size = H5B_nodesize(f, shared, NULL)) == 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGETSIZE, FAIL, "H5B_nodesize() failed") /* Set size value */ *size_ptr = size; done: FUNC_LEAVE_NOAPI(ret_value) } /* H5B_H5B_compute_size() */ /*------------------------------------------------------------------------- * Function: H5B_find * * Purpose: Locate the specified information in a B-tree and return * that information by filling in fields of the caller-supplied * UDATA pointer depending on the type of leaf node * requested. The UDATA can point to additional data passed * to the key comparison function. * * Note: This function does not follow the left/right sibling * pointers since it assumes that all nodes can be reached * from the parent node. * * Return: Non-negative on success (if found, values returned through the * UDATA argument). Negative on failure (if not found, UDATA is * undefined). * * Programmer: Robb Matzke * matzke@llnl.gov * Jun 23 1997 * * Modifications: * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. *------------------------------------------------------------------------- */ herr_t H5B_find(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void *udata) { H5B_t *bt = NULL; H5B_shared_t *shared; /* Pointer to shared B-tree info */ unsigned idx=0, lt = 0, rt; /* Final, left & right key indices */ int cmp = 1; /* Key comparison value */ int ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5B_find, FAIL) /* * Check arguments. */ assert(f); assert(type); assert(type->decode); assert(type->cmp3); assert(type->found); assert(H5F_addr_defined(addr)); /* * Perform a binary search to locate the child which contains * the thing for which we're searching. */ if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_READ))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree node") shared=H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); rt = bt->nchildren; while (lt < rt && cmp) { idx = (lt + rt) / 2; /* compare */ if ((cmp = (type->cmp3) (f, dxpl_id, H5B_NKEY(bt,shared,idx), udata, H5B_NKEY(bt,shared,idx+1))) < 0) { rt = idx; } else { lt = idx+1; } } if (cmp) /* Note: don't push error on stack, leave that to next higher level, * since many times the B-tree is searched in order to determine * if an object exists in the B-tree or not. -QAK */ #ifdef OLD_WAY HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "B-tree key not found") #else /* OLD_WAY */ HGOTO_DONE(FAIL) #endif /* OLD_WAY */ /* * Follow the link to the subtree or to the data node. */ assert(idx < bt->nchildren); if (bt->level > 0) { if (H5B_find(f, dxpl_id, type, bt->child[idx], udata) < 0) /* Note: don't push error on stack, leave that to next higher level, * since many times the B-tree is searched in order to determine * if an object exists in the B-tree or not. -QAK */ #ifdef OLD_WAY HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "key not found in subtree") #else /* OLD_WAY */ HGOTO_DONE(FAIL) #endif /* OLD_WAY */ } else { if ((type->found) (f, dxpl_id, bt->child[idx], H5B_NKEY(bt,shared,idx), udata) < 0) /* Note: don't push error on stack, leave that to next higher level, * since many times the B-tree is searched in order to determine * if an object exists in the B-tree or not. -QAK */ #ifdef OLD_WAY HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "key not found in leaf node") #else /* OLD_WAY */ HGOTO_DONE(FAIL) #endif /* OLD_WAY */ } done: if (bt && H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, FALSE) < 0) HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release node") FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5B_split * * Purpose: Split a single node into two nodes. The old node will * contain the left children and the new node will contain the * right children. * * The UDATA pointer is passed to the sizeof_rkey() method but is * otherwise unused. * * The OLD_BT argument is a pointer to a protected B-tree * node. * * Return: Non-negative on success (The address of the new node is * returned through the NEW_ADDR argument). Negative on failure. * * Programmer: Robb Matzke * matzke@llnl.gov * Jul 3 1997 * * Modifications: * Robb Matzke, 1999-07-28 * The OLD_ADDR argument is passed by value. The NEW_ADDR * argument has been renamed to NEW_ADDR_P *------------------------------------------------------------------------- */ static herr_t H5B_split(H5F_t *f, hid_t dxpl_id, H5B_t *old_bt, haddr_t old_addr, unsigned idx, void *udata, haddr_t *new_addr_p/*out*/) { H5P_genplist_t *dx_plist; /* Data transfer property list */ H5B_shared_t *shared; /* Pointer to shared B-tree info */ H5B_t *new_bt = NULL, *tmp_bt = NULL; unsigned nleft, nright; /* Number of keys in left & right halves */ double split_ratios[3]; /* B-tree split ratios */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5B_split) /* * Check arguments. */ assert(f); assert(old_bt); assert(H5F_addr_defined(old_addr)); /* * Initialize variables. */ shared=H5RC_GET_OBJ(old_bt->rc_shared); HDassert(shared); assert(old_bt->nchildren == shared->two_k); /* Get the dataset transfer property list */ if (NULL == (dx_plist = H5I_object(dxpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list") /* Get B-tree split ratios */ if(H5P_get(dx_plist, H5D_XFER_BTREE_SPLIT_RATIO_NAME, &split_ratios[0])<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTGET, FAIL, "Can't retrieve B-tree split ratios") #ifdef H5B_DEBUG if (H5DEBUG(B)) { const char *side; if (!H5F_addr_defined(old_bt->left) && !H5F_addr_defined(old_bt->right)) { side = "ONLY"; } else if (!H5F_addr_defined(old_bt->right)) { side = "RIGHT"; } else if (!H5F_addr_defined(old_bt->left)) { side = "LEFT"; } else { side = "MIDDLE"; } fprintf(H5DEBUG(B), "H5B_split: %3u {%5.3f,%5.3f,%5.3f} %6s", shared->two_k, split_ratios[0], split_ratios[1], split_ratios[2], side); } #endif /* * Decide how to split the children of the old node among the old node * and the new node. */ if (!H5F_addr_defined(old_bt->right)) { nleft = (unsigned)((double)shared->two_k * split_ratios[2]); /*right*/ } else if (!H5F_addr_defined(old_bt->left)) { nleft = (unsigned)((double)shared->two_k * split_ratios[0]); /*left*/ } else { nleft = (unsigned)((double)shared->two_k * split_ratios[1]); /*middle*/ } /* * Keep the new child in the same node as the child that split. This can * result in nodes that have an unused child when data is written * sequentially, but it simplifies stuff below. */ if (idxtwo_k) { --nleft; } else if (idx>=nleft && 0==nleft) { nleft++; } nright = shared->two_k - nleft; #ifdef H5B_DEBUG if (H5DEBUG(B)) fprintf(H5DEBUG(B), " split %3d/%-3d\n", nleft, nright); #endif /* * Create the new B-tree node. */ if (H5B_create(f, dxpl_id, shared->type, udata, new_addr_p/*out*/) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to create B-tree") if (NULL==(new_bt=H5AC_protect(f, dxpl_id, H5AC_BT, *new_addr_p, shared->type, udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to protect B-tree") new_bt->level = old_bt->level; /* * Copy data from the old node to the new node. */ HDmemcpy(new_bt->native, old_bt->native + nleft * shared->type->sizeof_nkey, (nright+1) * shared->type->sizeof_nkey); HDmemcpy(new_bt->child, &old_bt->child[nleft], nright*sizeof(haddr_t)); new_bt->nchildren = nright; /* * Truncate the old node. */ old_bt->cache_info.is_dirty = TRUE; old_bt->nchildren = nleft; /* * Update sibling pointers. */ new_bt->left = old_addr; new_bt->right = old_bt->right; if (H5F_addr_defined(old_bt->right)) { if (NULL == (tmp_bt = H5AC_protect(f, dxpl_id, H5AC_BT, old_bt->right, shared->type, udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load right sibling") tmp_bt->cache_info.is_dirty = TRUE; tmp_bt->left = *new_addr_p; if (H5AC_unprotect(f, dxpl_id, H5AC_BT, old_bt->right, tmp_bt, FALSE) != SUCCEED) HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node") tmp_bt=NULL; /* Make certain future references will be caught */ } old_bt->right = *new_addr_p; done: if (new_bt && H5AC_unprotect(f, dxpl_id, H5AC_BT, *new_addr_p, new_bt, FALSE) < 0) HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node") FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5B_insert * * Purpose: Adds a new item to the B-tree. If the root node of * the B-tree splits then the B-tree gets a new address. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Jun 23 1997 * * Modifications: * Robb Matzke, 28 Sep 1998 * The optional SPLIT_RATIOS[] indicates what percent of the child * pointers should go in the left node when a node splits. There are * three possibilities and a separate split ratio can be specified for * each: [0] The node that split is the left-most node at its level of * the tree, [1] the node that split has left and right siblings, [2] * the node that split is the right-most node at its level of the tree. * When a node is an only node at its level then we use the right-most * rule. If SPLIT_RATIOS is null then default values are used. * * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. *------------------------------------------------------------------------- */ herr_t H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void *udata) { /* * These are defined this way to satisfy alignment constraints. */ uint64_t _lt_key[128], _md_key[128], _rt_key[128]; uint8_t *lt_key=(uint8_t*)_lt_key; uint8_t *md_key=(uint8_t*)_md_key; uint8_t *rt_key=(uint8_t*)_rt_key; hbool_t lt_key_changed = FALSE, rt_key_changed = FALSE; haddr_t child, old_root; unsigned level; H5B_t *bt; H5B_t *new_bt; /* Copy of B-tree info */ H5B_shared_t *shared; /* Pointer to shared B-tree info */ H5B_ins_t my_ins = H5B_INS_ERROR; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5B_insert, FAIL) /* Check arguments. */ assert(f); assert(type); assert(type->sizeof_nkey <= sizeof _lt_key); assert(H5F_addr_defined(addr)); if ((int)(my_ins = H5B_insert_helper(f, dxpl_id, addr, type, lt_key, <_key_changed, md_key, udata, rt_key, &rt_key_changed, &child/*out*/))<0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to insert key") if (H5B_INS_NOOP == my_ins) HGOTO_DONE(SUCCEED) assert(H5B_INS_RIGHT == my_ins); /* the current root */ if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_READ))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to locate root of B-tree") shared=H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); level = bt->level; if (!lt_key_changed) HDmemcpy(lt_key, H5B_NKEY(bt,shared,0), type->sizeof_nkey); if (H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, FALSE) != SUCCEED) HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release new child") bt = NULL; /* the new node */ if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BT, child, type, udata, H5AC_READ))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load new node") if (!rt_key_changed) HDmemcpy(rt_key, H5B_NKEY(bt,shared,bt->nchildren), type->sizeof_nkey); if (H5AC_unprotect(f, dxpl_id, H5AC_BT, child, bt, FALSE) != SUCCEED) HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release new child") bt = NULL; /* * Copy the old root node to some other file location and make the new * root at the old root's previous address. This prevents the B-tree * from "moving". */ H5_CHECK_OVERFLOW(shared->sizeof_rnode,size_t,hsize_t); if (HADDR_UNDEF==(old_root=H5MF_alloc(f, H5FD_MEM_BTREE, dxpl_id, (hsize_t)shared->sizeof_rnode))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate file space to move root") /* update the new child's left pointer */ if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BT, child, type, udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load new child") bt->cache_info.is_dirty = TRUE; bt->left = old_root; if (H5AC_unprotect(f, dxpl_id, H5AC_BT, child, bt, FALSE) != SUCCEED) HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release new child") bt=NULL; /* Make certain future references will be caught */ /* * Move the node to the new location by checking it out & checking it in * at the new location -QAK */ /* Bring the old root into the cache if it's not already */ if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load new child") /* Make certain the old root info is marked as dirty before moving it, */ /* so it is certain to be written out at the new location */ bt->cache_info.is_dirty = TRUE; /* Make a copy of the old root information */ if (NULL == (new_bt = H5B_copy(bt))) { HCOMMON_ERROR(H5E_BTREE, H5E_CANTLOAD, "unable to copy old root"); if (H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, FALSE) != SUCCEED) HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release new child") HGOTO_DONE(FAIL) } if (H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, FALSE) != SUCCEED) HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release new child") bt=NULL; /* Make certain future references will be caught */ /* Move the location of the old root on the disk */ if (H5AC_rename(f, H5AC_BT, addr, old_root) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to move B-tree root node") /* clear the old root info at the old address (we already copied it) */ new_bt->cache_info.is_dirty = TRUE; new_bt->left = HADDR_UNDEF; new_bt->right = HADDR_UNDEF; /* Set the new information for the copy */ new_bt->level = level + 1; new_bt->nchildren = 2; new_bt->child[0] = old_root; HDmemcpy(H5B_NKEY(new_bt,shared,0), lt_key, shared->type->sizeof_nkey); new_bt->child[1] = child; HDmemcpy(H5B_NKEY(new_bt,shared,1), md_key, shared->type->sizeof_nkey); HDmemcpy(H5B_NKEY(new_bt,shared,2), rt_key, shared->type->sizeof_nkey); /* Insert the modified copy of the old root into the file again */ if (H5AC_set(f, dxpl_id, H5AC_BT, addr, new_bt) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTFLUSH, FAIL, "unable to flush old B-tree root node") #ifdef H5B_DEBUG H5B_assert(f, dxpl_id, addr, type, udata); #endif done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5B_insert_child * * Purpose: Insert a child to the left or right of child[IDX] depending * on whether ANCHOR is H5B_INS_LEFT or H5B_INS_RIGHT. The BT * argument is a pointer to a protected B-tree node. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Jul 8 1997 * * Modifications: * Robb Matzke, 1999-07-28 * The CHILD argument is passed by value. *------------------------------------------------------------------------- */ static herr_t H5B_insert_child(H5B_t *bt, unsigned idx, haddr_t child, H5B_ins_t anchor, const void *md_key) { H5B_shared_t *shared; /* Pointer to shared B-tree info */ uint8_t *base; /* Base offset for move */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B_insert_child) assert(bt); shared=H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); assert(bt->nchildrentwo_k); bt->cache_info.is_dirty = TRUE; /* Check for inserting right-most key into node (common when just appending * records to an unlimited dimension chunked dataset) */ base=H5B_NKEY(bt,shared,(idx+1)); if((idx+1)==bt->nchildren) { /* Make room for the new key */ HDmemcpy(base + shared->type->sizeof_nkey, base, shared->type->sizeof_nkey); /* No overlap possible - memcpy() OK */ HDmemcpy(base, md_key, shared->type->sizeof_nkey); /* The MD_KEY is the left key of the new node */ if (H5B_INS_RIGHT == anchor) idx++; /* Don't have to memmove() child addresses down, just add new child */ else /* Make room for the new child address */ bt->child[idx+1] = bt->child[idx]; } /* end if */ else { /* Make room for the new key */ HDmemmove(base + shared->type->sizeof_nkey, base, (bt->nchildren - idx) * shared->type->sizeof_nkey); HDmemcpy(base, md_key, shared->type->sizeof_nkey); /* The MD_KEY is the left key of the new node */ if (H5B_INS_RIGHT == anchor) idx++; /* Make room for the new child address */ HDmemmove(bt->child + idx + 1, bt->child + idx, (bt->nchildren - idx) * sizeof(haddr_t)); } /* end if */ bt->child[idx] = child; bt->nchildren += 1; FUNC_LEAVE_NOAPI(SUCCEED) } /*------------------------------------------------------------------------- * Function: H5B_insert_helper * * Purpose: Inserts the item UDATA into the tree rooted at ADDR and having * the specified type. * * On return, if LT_KEY_CHANGED is non-zero, then LT_KEY is * the new native left key. Similarily for RT_KEY_CHANGED * and RT_KEY. * * If the node splits, then MD_KEY contains the key that * was split between the two nodes (that is, the key that * appears as the max key in the left node and the min key * in the right node). * * Return: Success: A B-tree operation. The address of the new * node, if the node splits, is returned through * the NEW_NODE_P argument. The new node is always * to the right of the previous node. This * function is called recursively and the return * value influences the behavior of the caller. * See also, declaration of H5B_ins_t. * * Failure: H5B_INS_ERROR * * Programmer: Robb Matzke * matzke@llnl.gov * Jul 9 1997 * * Modifications: * * Robb Matzke, 28 Sep 1998 * The optional SPLIT_RATIOS[] indicates what percent of the child * pointers should go in the left node when a node splits. There are * three possibilities and a separate split ratio can be specified for * each: [0] The node that split is the left-most node at its level of * the tree, [1] the node that split has left and right siblings, [2] * the node that split is the right-most node at its level of the tree. * When a node is an only node at its level then we use the right-most * rule. If SPLIT_RATIOS is null then default values are used. * * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. The NEW_NODE argument is * renamed NEW_NODE_P *------------------------------------------------------------------------- */ static H5B_ins_t H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type, uint8_t *lt_key, hbool_t *lt_key_changed, uint8_t *md_key, void *udata, uint8_t *rt_key, hbool_t *rt_key_changed, haddr_t *new_node_p/*out*/) { H5B_t *bt = NULL, *twin = NULL; H5B_shared_t *shared; /* Pointer to shared B-tree info */ unsigned lt = 0, idx = 0, rt; /* Left, final & right index values */ int cmp = -1; /* Key comparison value */ haddr_t child_addr = HADDR_UNDEF; H5B_ins_t my_ins = H5B_INS_ERROR; H5B_ins_t ret_value = H5B_INS_ERROR; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5B_insert_helper) /* * Check arguments */ assert(f); assert(H5F_addr_defined(addr)); assert(type); assert(type->decode); assert(type->cmp3); assert(type->new_node); assert(lt_key); assert(lt_key_changed); assert(rt_key); assert(rt_key_changed); assert(new_node_p); *lt_key_changed = FALSE; *rt_key_changed = FALSE; /* * Use a binary search to find the child that will receive the new * data. When the search completes IDX points to the child that * should get the new data. */ if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to load node") shared=H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); rt = bt->nchildren; while (lt < rt && cmp) { idx = (lt + rt) / 2; if ((cmp = (type->cmp3) (f, dxpl_id, H5B_NKEY(bt,shared,idx), udata, H5B_NKEY(bt,shared,idx+1))) < 0) { rt = idx; } else { lt = idx + 1; } } if (0 == bt->nchildren) { /* * The value being inserted will be the only value in this tree. We * must necessarily be at level zero. */ assert(0 == bt->level); if ((type->new_node)(f, dxpl_id, H5B_INS_FIRST, H5B_NKEY(bt,shared,0), udata, H5B_NKEY(bt,shared,1), bt->child + 0/*out*/) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, H5B_INS_ERROR, "unable to create leaf node") bt->nchildren = 1; bt->cache_info.is_dirty = TRUE; idx = 0; if (type->follow_min) { if ((int)(my_ins = (type->insert)(f, dxpl_id, bt->child[idx], H5B_NKEY(bt,shared,idx), lt_key_changed, md_key, udata, H5B_NKEY(bt,shared,idx+1), rt_key_changed, &child_addr/*out*/)) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "unable to insert first leaf node") } else { my_ins = H5B_INS_NOOP; } } else if (cmp < 0 && idx == 0 && bt->level > 0) { /* * The value being inserted is less than any value in this tree. * Follow the minimum branch out of this node to a subtree. */ if ((int)(my_ins = H5B_insert_helper(f, dxpl_id, bt->child[idx], type, H5B_NKEY(bt,shared,idx), lt_key_changed, md_key, udata, H5B_NKEY(bt,shared,idx+1), rt_key_changed, &child_addr/*out*/))<0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert minimum subtree") } else if (cmp < 0 && idx == 0 && type->follow_min) { /* * The value being inserted is less than any leaf node out of this * current node. Follow the minimum branch to a leaf node and let the * subclass handle the problem. */ if ((int)(my_ins = (type->insert)(f, dxpl_id, bt->child[idx], H5B_NKEY(bt,shared,idx), lt_key_changed, md_key, udata, H5B_NKEY(bt,shared,idx+1), rt_key_changed, &child_addr/*out*/)) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert minimum leaf node") } else if (cmp < 0 && idx == 0) { /* * The value being inserted is less than any leaf node out of the * current node. Create a new minimum leaf node out of this B-tree * node. This node is not empty (handled above). */ my_ins = H5B_INS_LEFT; HDmemcpy(md_key, H5B_NKEY(bt,shared,idx), type->sizeof_nkey); if ((type->new_node)(f, dxpl_id, H5B_INS_LEFT, H5B_NKEY(bt,shared,idx), udata, md_key, &child_addr/*out*/) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert minimum leaf node") *lt_key_changed = TRUE; } else if (cmp > 0 && idx + 1 >= bt->nchildren && bt->level > 0) { /* * The value being inserted is larger than any value in this tree. * Follow the maximum branch out of this node to a subtree. */ idx = bt->nchildren - 1; if ((int)(my_ins = H5B_insert_helper(f, dxpl_id, bt->child[idx], type, H5B_NKEY(bt,shared,idx), lt_key_changed, md_key, udata, H5B_NKEY(bt,shared,idx+1), rt_key_changed, &child_addr/*out*/)) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert maximum subtree") } else if (cmp > 0 && idx + 1 >= bt->nchildren && type->follow_max) { /* * The value being inserted is larger than any leaf node out of the * current node. Follow the maximum branch to a leaf node and let the * subclass handle the problem. */ idx = bt->nchildren - 1; if ((int)(my_ins = (type->insert)(f, dxpl_id, bt->child[idx], H5B_NKEY(bt,shared,idx), lt_key_changed, md_key, udata, H5B_NKEY(bt,shared,idx+1), rt_key_changed, &child_addr/*out*/)) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert maximum leaf node") } else if (cmp > 0 && idx + 1 >= bt->nchildren) { /* * The value being inserted is larger than any leaf node out of the * current node. Create a new maximum leaf node out of this B-tree * node. */ idx = bt->nchildren - 1; my_ins = H5B_INS_RIGHT; HDmemcpy(md_key, H5B_NKEY(bt,shared,idx+1), type->sizeof_nkey); if ((type->new_node)(f, dxpl_id, H5B_INS_RIGHT, md_key, udata, H5B_NKEY(bt,shared,idx+1), &child_addr/*out*/) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert maximum leaf node") *rt_key_changed = TRUE; } else if (cmp) { /* * We couldn't figure out which branch to follow out of this node. THIS * IS A MAJOR PROBLEM THAT NEEDS TO BE FIXED --rpm. */ assert("INTERNAL HDF5 ERROR (contact rpm)" && 0); #ifdef NDEBUG HDabort(); #endif /* NDEBUG */ } else if (bt->level > 0) { /* * Follow a branch out of this node to another subtree. */ assert(idx < bt->nchildren); if ((int)(my_ins = H5B_insert_helper(f, dxpl_id, bt->child[idx], type, H5B_NKEY(bt,shared,idx), lt_key_changed, md_key, udata, H5B_NKEY(bt,shared,idx+1), rt_key_changed, &child_addr/*out*/)) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert subtree") } else { /* * Follow a branch out of this node to a leaf node of some other type. */ assert(idx < bt->nchildren); if ((int)(my_ins = (type->insert)(f, dxpl_id, bt->child[idx], H5B_NKEY(bt,shared,idx), lt_key_changed, md_key, udata, H5B_NKEY(bt,shared,idx+1), rt_key_changed, &child_addr/*out*/)) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert leaf node") } assert((int)my_ins >= 0); /* * Update the left and right keys of the current node. */ if (*lt_key_changed) { bt->cache_info.is_dirty = TRUE; if (idx > 0) *lt_key_changed = FALSE; else HDmemcpy(lt_key, H5B_NKEY(bt,shared,idx), type->sizeof_nkey); } if (*rt_key_changed) { bt->cache_info.is_dirty = TRUE; if (idx+1 < bt->nchildren) *rt_key_changed = FALSE; else HDmemcpy(rt_key, H5B_NKEY(bt,shared,idx+1), type->sizeof_nkey); } if (H5B_INS_CHANGE == my_ins) { /* * The insertion simply changed the address for the child. */ bt->child[idx] = child_addr; bt->cache_info.is_dirty = TRUE; ret_value = H5B_INS_NOOP; } else if (H5B_INS_LEFT == my_ins || H5B_INS_RIGHT == my_ins) { H5B_t *tmp_bt; /* * If this node is full then split it before inserting the new child. */ if (bt->nchildren == shared->two_k) { if (H5B_split(f, dxpl_id, bt, addr, idx, udata, new_node_p/*out*/)<0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, H5B_INS_ERROR, "unable to split node") if (NULL == (twin = H5AC_protect(f, dxpl_id, H5AC_BT, *new_node_p, type, udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to load node") if (idxnchildren) { tmp_bt = bt; } else { idx -= bt->nchildren; tmp_bt = twin; } } else { tmp_bt = bt; } /* Insert the child */ if (H5B_insert_child(tmp_bt, idx, child_addr, my_ins, md_key) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert child") } /* * If this node split, return the mid key (the one that is shared * by the left and right node). */ if (twin) { HDmemcpy(md_key, H5B_NKEY(twin,shared,0), type->sizeof_nkey); ret_value = H5B_INS_RIGHT; #ifdef H5B_DEBUG /* * The max key in the original left node must be equal to the min key * in the new node. */ cmp = (type->cmp2) (f, dxpl_id, H5B_NKEY(bt,shared,bt->nchildren), udata, H5B_NKEY(twin,shared,0)); assert(0 == cmp); #endif } else { ret_value = H5B_INS_NOOP; } done: { herr_t e1 = (bt && H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, FALSE) < 0); herr_t e2 = (twin && H5AC_unprotect(f, dxpl_id, H5AC_BT, *new_node_p, twin, FALSE)<0); if (e1 || e2) /*use vars to prevent short-circuit of side effects */ HDONE_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to release node(s)") } FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5B_iterate * * Purpose: Calls the list callback for each leaf node of the * B-tree, passing it the UDATA structure. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Jun 23 1997 * * Modifications: * Robb Matzke, 1999-04-21 * The key values are passed to the function which is called. * * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. * * Quincey Koziol, 2002-04-22 * Changed callback to function pointer from static function *------------------------------------------------------------------------- */ herr_t H5B_iterate (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t op, haddr_t addr, void *udata) { H5B_t *bt = NULL; H5B_shared_t *shared; /* Pointer to shared B-tree info */ haddr_t next_addr; haddr_t cur_addr = HADDR_UNDEF; haddr_t *child = NULL; uint8_t *key = NULL; unsigned nchildren; /* Number of children of B-tree node */ unsigned u; /* Local index variable */ unsigned level; haddr_t left_child; herr_t ret_value; FUNC_ENTER_NOAPI(H5B_iterate, FAIL) /* * Check arguments. */ assert(f); assert(type); assert(op); assert(H5F_addr_defined(addr)); assert(udata); if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_READ))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree node") shared=H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); level = bt->level; left_child = bt->child[0]; if (H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, FALSE) < 0) HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node") bt = NULL; /* Make certain future references will be caught */ if (level > 0) { /* Keep following the left-most child until we reach a leaf node. */ if ((ret_value=H5B_iterate(f, dxpl_id, type, op, left_child, udata))<0) HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "unable to list B-tree node") } else { /* * We've reached the left-most leaf. Now follow the right-sibling * pointer from leaf to leaf until we've processed all leaves. */ if (NULL==(child=H5FL_SEQ_MALLOC(haddr_t,(size_t)shared->two_k)) || NULL==(key=H5FL_BLK_MALLOC(native_block,shared->sizeof_keys))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") for (cur_addr=addr, ret_value=0; H5F_addr_defined(cur_addr) && !ret_value; cur_addr=next_addr) { /* * Save all the child addresses and native keys since we can't * leave the B-tree node protected during an application * callback. */ if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BT, cur_addr, type, udata, H5AC_READ))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "B-tree node") HDmemcpy(child, bt->child, bt->nchildren*sizeof(haddr_t)); HDmemcpy(key, bt->native, shared->sizeof_keys); next_addr = bt->right; nchildren = bt->nchildren; if (H5AC_unprotect(f, dxpl_id, H5AC_BT, cur_addr, bt, FALSE) < 0) HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node") bt = NULL; /* * Perform the iteration operator, which might invoke an * application callback. */ for (u=0, ret_value=H5B_ITER_CONT; usizeof_nkey, child[u], key+(u+1)*type->sizeof_nkey, udata); if (ret_value<0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "iterator function failed") } /* end for */ } /* end for */ } /* end else */ done: if(child!=NULL) H5FL_SEQ_FREE(haddr_t,child); if(key!=NULL) H5FL_BLK_FREE(native_block,key); FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5B_remove_helper * * Purpose: The recursive part of removing an item from a B-tree. The * sub B-tree that is being considered is located at ADDR and * the item to remove is described by UDATA. If the removed * item falls at the left or right end of the current level then * it might be necessary to adjust the left and/or right keys * (LT_KEY and/or RT_KEY) to to indicate that they changed by * setting LT_KEY_CHANGED and/or RT_KEY_CHANGED. * * Return: Success: A B-tree operation, see comments for * H5B_ins_t declaration. This function is * called recursively and the return value * influences the actions of the caller. It is * also called by H5B_remove(). * * Failure: H5B_INS_ERROR, a negative value. * * Programmer: Robb Matzke * Wednesday, September 16, 1998 * * Modifications: * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. *------------------------------------------------------------------------- */ static H5B_ins_t H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type, int level, uint8_t *lt_key/*out*/, hbool_t *lt_key_changed/*out*/, void *udata, uint8_t *rt_key/*out*/, hbool_t *rt_key_changed/*out*/) { H5B_t *bt = NULL, *sibling = NULL; H5B_shared_t *shared; /* Pointer to shared B-tree info */ unsigned idx=0, lt=0, rt; /* Final, left & right indices */ int cmp=1; /* Key comparison value */ H5B_ins_t ret_value = H5B_INS_ERROR; FUNC_ENTER_NOAPI(H5B_remove_helper, H5B_INS_ERROR) assert(f); assert(H5F_addr_defined(addr)); assert(type); assert(type->decode); assert(type->cmp3); assert(lt_key && lt_key_changed); assert(udata); assert(rt_key && rt_key_changed); /* * Perform a binary search to locate the child which contains the thing * for which we're searching. */ if (NULL==(bt=H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to load B-tree node") shared=H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); rt = bt->nchildren; while (ltcmp3)(f, dxpl_id, H5B_NKEY(bt,shared,idx), udata, H5B_NKEY(bt,shared,idx+1)))<0) { rt = idx; } else { lt = idx+1; } } if (cmp) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, H5B_INS_ERROR, "B-tree key not found") /* * Follow the link to the subtree or to the data node. The return value * will be one of H5B_INS_ERROR, H5B_INS_NOOP, or H5B_INS_REMOVE. */ assert(idxnchildren); if (bt->level>0) { /* We're at an internal node -- call recursively */ if ((int)(ret_value=H5B_remove_helper(f, dxpl_id, bt->child[idx], type, level+1, H5B_NKEY(bt,shared,idx)/*out*/, lt_key_changed/*out*/, udata, H5B_NKEY(bt,shared,idx+1)/*out*/, rt_key_changed/*out*/))<0) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, H5B_INS_ERROR, "key not found in subtree") } else if (type->remove) { /* * We're at a leaf node but the leaf node points to an object that * has a removal method. Pass the removal request to the pointed-to * object and let it decide how to progress. */ if ((int)(ret_value=(type->remove)(f, dxpl_id, bt->child[idx], H5B_NKEY(bt,shared,idx), lt_key_changed, udata, H5B_NKEY(bt,shared,idx+1), rt_key_changed))<0) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, H5B_INS_ERROR, "key not found in leaf node") } else { /* * We're at a leaf node which points to an object that has no removal * method. The best we can do is to leave the object alone but * remove the B-tree reference to the object. */ *lt_key_changed = FALSE; *rt_key_changed = FALSE; ret_value = H5B_INS_REMOVE; } /* * Update left and right key dirty bits if the subtree indicates that they * have changed. If the subtree's left key changed and the subtree is the * left-most child of the current node then we must update the key in our * parent and indicate that it changed. Similarly, if the right subtree * key changed and it's the right most key of this node we must update * our right key and indicate that it changed. */ if (*lt_key_changed) { bt->cache_info.is_dirty = TRUE; if (idx>0) { /* Don't propagate change out of this B-tree node */ *lt_key_changed = FALSE; } else { HDmemcpy(lt_key, H5B_NKEY(bt,shared,idx), type->sizeof_nkey); } } if (*rt_key_changed) { bt->cache_info.is_dirty = TRUE; if (idx+1nchildren) { /* Don't propagate change out of this B-tree node */ *rt_key_changed = FALSE; } else { HDmemcpy(rt_key, H5B_NKEY(bt,shared,idx+1), type->sizeof_nkey); /* Since our right key was changed, we must check for a right * sibling and change it's left-most key as well. * (Handle the ret_value==H5B_INS_REMOVE case below) */ if (ret_value!=H5B_INS_REMOVE && level>0) { if (H5F_addr_defined(bt->right)) { if (NULL == (sibling = H5AC_protect(f, dxpl_id, H5AC_BT, bt->right, type, udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to unlink node from tree") /* Make certain the native key for the right sibling is set up */ HDmemcpy(H5B_NKEY(sibling,shared,0), H5B_NKEY(bt,shared,idx+1), type->sizeof_nkey); sibling->cache_info.is_dirty = TRUE; if (H5AC_unprotect(f, dxpl_id, H5AC_BT, bt->right, sibling, FALSE) != SUCCEED) HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to release node from tree") sibling=NULL; /* Make certain future references will be caught */ } } } } /* * If the subtree returned H5B_INS_REMOVE then we should remove the * subtree entry from the current node. There are four cases: */ if (H5B_INS_REMOVE==ret_value && 1==bt->nchildren) { /* * The subtree is the only child of this node. Discard both * keys and the subtree pointer. Free this node (unless it's the * root node) and return H5B_INS_REMOVE. */ bt->cache_info.is_dirty = TRUE; bt->nchildren = 0; if (level>0) { if (H5F_addr_defined(bt->left)) { if (NULL == (sibling = H5AC_protect(f, dxpl_id, H5AC_BT, bt->left, type, udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to load node from tree") sibling->right = bt->right; sibling->cache_info.is_dirty = TRUE; if (H5AC_unprotect(f, dxpl_id, H5AC_BT, bt->left, sibling, FALSE) != SUCCEED) HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to release node from tree") sibling=NULL; /* Make certain future references will be caught */ } if (H5F_addr_defined(bt->right)) { if (NULL == (sibling = H5AC_protect(f, dxpl_id, H5AC_BT, bt->right, type, udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to unlink node from tree") /* Copy left-most key from deleted node to left-most key in it's right neighbor */ HDmemcpy(H5B_NKEY(sibling,shared,0), H5B_NKEY(bt,shared,0), type->sizeof_nkey); sibling->left = bt->left; sibling->cache_info.is_dirty = TRUE; if (H5AC_unprotect(f, dxpl_id, H5AC_BT, bt->right, sibling, FALSE) != SUCCEED) HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to release node from tree") sibling=NULL; /* Make certain future references will be caught */ } bt->left = HADDR_UNDEF; bt->right = HADDR_UNDEF; H5_CHECK_OVERFLOW(shared->sizeof_rnode,size_t,hsize_t); if (H5MF_xfree(f, H5FD_MEM_BTREE, dxpl_id, addr, (hsize_t)shared->sizeof_rnode)<0 || H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, TRUE)<0) { bt = NULL; HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to free B-tree node") } bt = NULL; } } else if (H5B_INS_REMOVE==ret_value && 0==idx) { /* * The subtree is the left-most child of this node. We discard the * left-most key and the left-most child (the child has already been * freed) and shift everything down by one. We copy the new left-most * key into lt_key and notify the caller that the left key has * changed. Return H5B_INS_NOOP. */ bt->cache_info.is_dirty = TRUE; bt->nchildren -= 1; HDmemmove(bt->native, bt->native + type->sizeof_nkey, (bt->nchildren+1) * type->sizeof_nkey); HDmemmove(bt->child, bt->child+1, bt->nchildren * sizeof(haddr_t)); HDmemcpy(lt_key, H5B_NKEY(bt,shared,0), type->sizeof_nkey); *lt_key_changed = TRUE; ret_value = H5B_INS_NOOP; } else if (H5B_INS_REMOVE==ret_value && idx+1==bt->nchildren) { /* * The subtree is the right-most child of this node. We discard the * right-most key and the right-most child (the child has already been * freed). We copy the new right-most key into rt_key and notify the * caller that the right key has changed. Return H5B_INS_NOOP. */ bt->cache_info.is_dirty = TRUE; bt->nchildren -= 1; HDmemcpy(rt_key, H5B_NKEY(bt,shared,bt->nchildren), type->sizeof_nkey); *rt_key_changed = TRUE; /* Since our right key was changed, we must check for a right * sibling and change it's left-most key as well. * (Handle the ret_value==H5B_INS_REMOVE case below) */ if (level>0) { if (H5F_addr_defined(bt->right)) { if (NULL == (sibling = H5AC_protect(f, dxpl_id, H5AC_BT, bt->right, type, udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to unlink node from tree") HDmemcpy(H5B_NKEY(sibling,shared,0), H5B_NKEY(bt,shared,bt->nchildren), type->sizeof_nkey); sibling->cache_info.is_dirty = TRUE; if (H5AC_unprotect(f, dxpl_id, H5AC_BT, bt->right, sibling, FALSE) != SUCCEED) HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to release node from tree") sibling=NULL; /* Make certain future references will be caught */ } } ret_value = H5B_INS_NOOP; } else if (H5B_INS_REMOVE==ret_value) { /* * There are subtrees out of this node to both the left and right of * the subtree being removed. The key to the left of the subtree and * the subtree are removed from this node and all keys and nodes to * the right are shifted left by one place. The subtree has already * been freed). Return H5B_INS_NOOP. */ bt->cache_info.is_dirty = TRUE; bt->nchildren -= 1; HDmemmove(bt->native + idx * type->sizeof_nkey, bt->native + (idx+1) * type->sizeof_nkey, (bt->nchildren+1-idx) * type->sizeof_nkey); HDmemmove(bt->child+idx, bt->child+idx+1, (bt->nchildren-idx) * sizeof(haddr_t)); ret_value = H5B_INS_NOOP; } else { ret_value = H5B_INS_NOOP; } done: if (bt && H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, FALSE)<0) HDONE_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to release node") FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5B_remove * * Purpose: Removes an item from a B-tree. * * Note: The current version does not attempt to rebalance the tree. * (Read the paper Yao & Lehman paper for details on why) * * Return: Non-negative on success/Negative on failure (failure includes * not being able to find the object which is to be removed). * * Programmer: Robb Matzke * Wednesday, September 16, 1998 * * Modifications: * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. *------------------------------------------------------------------------- */ herr_t H5B_remove(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void *udata) { /* These are defined this way to satisfy alignment constraints */ uint64_t _lt_key[128], _rt_key[128]; uint8_t *lt_key = (uint8_t*)_lt_key; /*left key*/ uint8_t *rt_key = (uint8_t*)_rt_key; /*right key*/ hbool_t lt_key_changed = FALSE; /*left key changed?*/ hbool_t rt_key_changed = FALSE; /*right key changed?*/ H5B_t *bt = NULL; /*btree node */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5B_remove, FAIL) /* Check args */ assert(f); assert(type); assert(type->sizeof_nkey <= sizeof _lt_key); assert(H5F_addr_defined(addr)); /* The actual removal */ if (H5B_remove_helper(f, dxpl_id, addr, type, 0, lt_key, <_key_changed, udata, rt_key, &rt_key_changed)==H5B_INS_ERROR) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to remove entry from B-tree") /* * If the B-tree is now empty then make sure we mark the root node as * being at level zero */ if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree root node") if (0==bt->nchildren && 0!=bt->level) { bt->level = 0; bt->cache_info.is_dirty = TRUE; } if (H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, FALSE) != SUCCEED) HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release node") bt=NULL; /* Make certain future references will be caught */ #ifdef H5B_DEBUG H5B_assert(f, dxpl_id, addr, type, udata); #endif done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5B_delete * * Purpose: Deletes an entire B-tree from the file, calling the 'remove' * callbacks for each node. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Thursday, March 20, 2003 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5B_delete(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void *udata) { H5B_t *bt; /* B-tree node being operated on */ H5B_shared_t *shared; /* Pointer to shared B-tree info */ unsigned u; /* Local index variable */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5B_delete, FAIL) /* Check args */ assert(f); assert(type); assert(H5F_addr_defined(addr)); /* Lock this B-tree node into memory for now */ if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree node") shared=H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); /* Iterate over all children in tree, deleting them */ if (bt->level > 0) { /* Iterate over all children in node, deleting them */ for (u=0; unchildren; u++) if (H5B_delete(f, dxpl_id, type, bt->child[u], udata)<0) HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "unable to delete B-tree node") } else { hbool_t lt_key_changed, rt_key_changed; /* Whether key changed (unused here, just for callback) */ /* Check for removal callback */ if(type->remove) { /* Iterate over all entries in node, calling callback */ for (u=0; unchildren; u++) { /* Call user's callback for each entry */ if ((type->remove)(f, dxpl_id, bt->child[u], H5B_NKEY(bt,shared,u), <_key_changed, udata, H5B_NKEY(bt,shared,u+1), &rt_key_changed)sizeof_rnode)<0) HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to free B-tree node") done: if (bt && H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, TRUE)<0) HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node in cache") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_delete() */ /*------------------------------------------------------------------------- * Function: H5B_nodesize * * Purpose: Returns the number of bytes needed for this type of * B-tree node. The size is the size of the header plus * enough space for 2t child pointers and 2t+1 keys. * * If TOTAL_NKEY_SIZE is non-null, what it points to will * be initialized with the total number of bytes required to * hold all the key values in native order. * * Return: Success: Size of node in file. * * Failure: 0 * * Programmer: Robb Matzke * matzke@llnl.gov * Jul 3 1997 * * Modifications: * *------------------------------------------------------------------------- */ size_t H5B_nodesize(const H5F_t *f, const H5B_shared_t *shared, size_t *total_nkey_size/*out*/) { size_t size; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B_nodesize) /* * Check arguments. */ assert(f); assert(shared); assert(shared->two_k > 0); assert(shared->sizeof_rkey > 0); /* * Total native key size. */ if (total_nkey_size) *total_nkey_size = (shared->two_k + 1) * shared->type->sizeof_nkey; /* * Total node size. */ size = (H5B_SIZEOF_HDR(f) + /*node header */ shared->two_k * H5F_SIZEOF_ADDR(f) + /*child pointers */ (shared->two_k + 1) * shared->sizeof_rkey); /*keys */ FUNC_LEAVE_NOAPI(size) } /*------------------------------------------------------------------------- * Function: H5B_copy * * Purpose: Deep copies an existing H5B_t node. * * Return: Success: Pointer to H5B_t object. * * Failure: NULL * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * Apr 18 2000 * * Modifications: * *------------------------------------------------------------------------- */ static H5B_t * H5B_copy(const H5B_t *old_bt) { H5B_t *new_node = NULL; H5B_shared_t *shared; /* Pointer to shared B-tree info */ H5B_t *ret_value; FUNC_ENTER_NOAPI(H5B_copy, NULL) /* * Check arguments. */ assert(old_bt); shared=H5RC_GET_OBJ(old_bt->rc_shared); HDassert(shared); /* Allocate memory for the new H5B_t object */ if (NULL==(new_node = H5FL_MALLOC(H5B_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for B-tree root node") /* Copy the main structure */ HDmemcpy(new_node,old_bt,sizeof(H5B_t)); if ( NULL==(new_node->native=H5FL_BLK_MALLOC(native_block,shared->sizeof_keys)) || NULL==(new_node->child=H5FL_SEQ_MALLOC(haddr_t,(size_t)shared->two_k))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for B-tree root node") /* Copy the other structures */ HDmemcpy(new_node->native,old_bt->native,shared->sizeof_keys); HDmemcpy(new_node->child,old_bt->child,(sizeof(haddr_t)*shared->two_k)); /* Increment the ref-count on the raw page */ H5RC_INC(new_node->rc_shared); /* Set return value */ ret_value=new_node; done: if(ret_value==NULL) { if(new_node) { H5FL_BLK_FREE (native_block,new_node->native); H5FL_SEQ_FREE (haddr_t,new_node->child); H5FL_FREE (H5B_t,new_node); } /* end if */ } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5B_copy */ /*------------------------------------------------------------------------- * Function: H5B_debug * * Purpose: Prints debugging info about a B-tree. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 4 1997 * * Modifications: * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. *------------------------------------------------------------------------- */ herr_t H5B_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int fwidth, const H5B_class_t *type, void *udata) { H5B_t *bt = NULL; H5B_shared_t *shared; /* Pointer to shared B-tree info */ unsigned u; /* Local index variable */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5B_debug, FAIL) /* * Check arguments. */ assert(f); assert(H5F_addr_defined(addr)); assert(stream); assert(indent >= 0); assert(fwidth >= 0); assert(type); /* * Load the tree node. */ if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_READ))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree node") shared=H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); /* * Print the values. */ HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Tree type ID:", ((shared->type->id)==H5B_SNODE_ID ? "H5B_SNODE_ID" : ((shared->type->id)==H5B_ISTORE_ID ? "H5B_ISTORE_ID" : "Unknown!"))); HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, "Size of node:", shared->sizeof_rnode); HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, "Size of raw (disk) key:", shared->sizeof_rkey); HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Dirty flag:", bt->cache_info.is_dirty ? "True" : "False"); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Level:", bt->level); HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "Address of left sibling:", bt->left); HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "Address of right sibling:", bt->right); HDfprintf(stream, "%*s%-*s %u (%u)\n", indent, "", fwidth, "Number of children (max):", bt->nchildren, shared->two_k); /* * Print the child addresses */ for (u = 0; u < bt->nchildren; u++) { HDfprintf(stream, "%*sChild %d...\n", indent, "", u); HDfprintf(stream, "%*s%-*s %a\n", indent + 3, "", MAX(0, fwidth - 3), "Address:", bt->child[u]); /* If there is a key debugging routine, use it to display the left & right keys */ if (type->debug_key) { /* Decode the 'left' key & print it */ HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), "Left Key:"); assert(H5B_NKEY(bt,shared,u)); (void)(type->debug_key)(stream, f, dxpl_id, indent+6, MAX (0, fwidth-6), H5B_NKEY(bt,shared,u), udata); /* Decode the 'right' key & print it */ HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), "Right Key:"); assert(H5B_NKEY(bt,shared,u+1)); (void)(type->debug_key)(stream, f, dxpl_id, indent+6, MAX (0, fwidth-6), H5B_NKEY(bt,shared,u+1), udata); } } done: if (bt && H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, FALSE) < 0) HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node") FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5B_assert * * Purpose: Verifies that the tree is structured correctly. * * Return: Success: SUCCEED * * Failure: aborts if something is wrong. * * Programmer: Robb Matzke * Tuesday, November 4, 1997 * * Modifications: * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. *------------------------------------------------------------------------- */ #ifdef H5B_DEBUG static herr_t H5B_assert(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type, void *udata) { H5B_t *bt = NULL; H5B_shared_t *shared; /* Pointer to shared B-tree info */ int i, ncell, cmp; static int ncalls = 0; herr_t status; herr_t ret_value=SUCCEED; /* Return value */ /* A queue of child data */ struct child_t { haddr_t addr; unsigned level; struct child_t *next; } *head = NULL, *tail = NULL, *prev = NULL, *cur = NULL, *tmp = NULL; FUNC_ENTER_NOAPI(H5B_assert, FAIL) if (0==ncalls++) { if (H5DEBUG(B)) { fprintf(H5DEBUG(B), "H5B: debugging B-trees (expensive)\n"); } } /* Initialize the queue */ bt = H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_READ); assert(bt); shared=H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); cur = H5MM_calloc(sizeof(struct child_t)); assert (cur); cur->addr = addr; cur->level = bt->level; head = tail = cur; status = H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, FALSE); assert(status >= 0); bt=NULL; /* Make certain future references will be caught */ /* * Do a breadth-first search of the tree. New nodes are added to the end * of the queue as the `cur' pointer is advanced toward the end. We don't * remove any nodes from the queue because we need them in the uniqueness * test. */ for (ncell = 0; cur; ncell++) { bt = H5AC_protect(f, dxpl_id, H5AC_BT, cur->addr, type, udata, H5AC_READ); assert(bt); /* Check node header */ assert(bt->level == cur->level); if (cur->next && cur->next->level == bt->level) { assert(H5F_addr_eq(bt->right, cur->next->addr)); } else { assert(!H5F_addr_defined(bt->right)); } if (prev && prev->level == bt->level) { assert(H5F_addr_eq(bt->left, prev->addr)); } else { assert(!H5F_addr_defined(bt->left)); } if (cur->level > 0) { for (i = 0; i < bt->nchildren; i++) { /* * Check that child nodes haven't already been seen. If they * have then the tree has a cycle. */ for (tmp = head; tmp; tmp = tmp->next) { assert(H5F_addr_ne(tmp->addr, bt->child[i])); } /* Add the child node to the end of the queue */ tmp = H5MM_calloc(sizeof(struct child_t)); assert (tmp); tmp->addr = bt->child[i]; tmp->level = bt->level - 1; tail->next = tmp; tail = tmp; /* Check that the keys are monotonically increasing */ cmp = (type->cmp2) (f, dxpl_id, H5B_NKEY(bt,shared,i), udata, H5B_NKEY(bt,shared,i+1)); assert(cmp < 0); } } /* Release node */ status = H5AC_unprotect(f, dxpl_id, H5AC_BT, cur->addr, bt, FALSE); assert(status >= 0); bt=NULL; /* Make certain future references will be caught */ /* Advance current location in queue */ prev = cur; cur = cur->next; } /* Free all entries from queue */ while (head) { tmp = head->next; H5MM_xfree(head); head = tmp; } done: FUNC_LEAVE_NOAPI(ret_value) } #endif /* H5B_DEBUG */ xdmf-3.0+git20160803/Utilities/hdf5/hdf5.h0000640000175000017500000000545113003006557017677 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * This is the main public HDF5 include file. Put further information in * a particular header file and include that here, don't fill this file with * lots of gunk... */ #ifndef _HDF5_H #define _HDF5_H #include "H5public.h" #include "H5Apublic.h" /* Attributes */ #include "H5ACpublic.h" /* Metadata cache */ #include "H5Bpublic.h" /* B-trees */ #include "H5Dpublic.h" /* Datasets */ #include "H5Epublic.h" /* Errors */ #include "H5Fpublic.h" /* Files */ #include "H5FDpublic.h" /* File drivers */ #include "H5Gpublic.h" /* Groups */ #include "H5HGpublic.h" /* Global heaps */ #include "H5HLpublic.h" /* Local heaps */ #include "H5Ipublic.h" /* ID management */ #include "H5MMpublic.h" /* Memory management */ #include "H5Opublic.h" /* Object headers */ #include "H5Ppublic.h" /* Property lists */ #include "H5Rpublic.h" /* References */ #include "H5Spublic.h" /* Dataspaces */ #include "H5Tpublic.h" /* Datatypes */ #include "H5Zpublic.h" /* Data filters */ /* Predefined file drivers */ #include "H5FDcore.h" /* Files stored entirely in memory */ #include "H5FDfamily.h" /* File families */ #include "H5FDgass.h" /* Remote files using GASS I/O */ #include "H5FDlog.h" /* sec2 driver with I/O logging (for debugging) */ #include "H5FDmpi.h" /* MPI-based file drivers */ #include "H5FDmulti.h" /* Usage-partitioned file family */ #include "H5FDsec2.h" /* POSIX unbuffered file I/O */ #include "H5FDsrb.h" /* Remote access using SRB */ #include "H5FDstdio.h" /* Standard C buffered I/O */ #include "H5FDstream.h" /* In-memory files streamed via sockets */ #endif xdmf-3.0+git20160803/Utilities/hdf5/H5Tfields.c0000640000175000017500000003621413003006557020634 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Module Info: This module contains commond functionality for fields in * enumerated & compound datatypes in the H5T interface. */ #define H5T_PACKAGE /*suppress error about including H5Tpkg */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5T_init_fields_interface #include "H5private.h" /*generic functions */ #include "H5Eprivate.h" /*error handling */ #include "H5Iprivate.h" /*ID functions */ #include "H5MMprivate.h" /*memory management */ #include "H5Tpkg.h" /*data-type functions */ /*-------------------------------------------------------------------------- NAME H5T_init_fields_interface -- Initialize interface-specific information USAGE herr_t H5T_init_fields_interface() RETURNS Non-negative on success/Negative on failure DESCRIPTION Initializes any interface-specific data or routines. (Just calls H5T_init_iterface currently). --------------------------------------------------------------------------*/ static herr_t H5T_init_fields_interface(void) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_init_fields_interface) FUNC_LEAVE_NOAPI(H5T_init()) } /* H5T_init_fields_interface() */ /*------------------------------------------------------------------------- * Function: H5Tget_nmembers * * Purpose: Determines how many members TYPE_ID has. The type must be * either a compound datatype or an enumeration datatype. * * Return: Success: Number of members defined in the datatype. * * Failure: Negative * * Errors: * * Programmer: Robb Matzke * Monday, December 8, 1997 * * Modifications: * Robb Matzke, 22 Dec 1998 * Also works with enumeration datatypes. *------------------------------------------------------------------------- */ int H5Tget_nmembers(hid_t type_id) { H5T_t *dt = NULL; int ret_value; FUNC_ENTER_API(H5Tget_nmembers, FAIL) H5TRACE1("Is","i",type_id); /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") if((ret_value = H5T_get_nmembers(dt))<0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "cannot return member number") done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5T_get_nmembers * * Purpose: Private function for H5Tget_nmembers. Determines how many * members DTYPE has. The type must be either a compound data * type or an enumeration datatype. * * Return: Success: Number of members defined in the datatype. * * Failure: Negative * * Errors: * * Programmer: Raymond Lu * October 8, 2002 * * Modifications: * *------------------------------------------------------------------------- */ int H5T_get_nmembers(const H5T_t *dt) { int ret_value; FUNC_ENTER_NOAPI(H5T_get_nmembers, FAIL) assert(dt); if (H5T_COMPOUND==dt->shared->type) ret_value = (int)dt->shared->u.compnd.nmembs; else if (H5T_ENUM==dt->shared->type) ret_value = (int)dt->shared->u.enumer.nmembs; else HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "operation not supported for type class") done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5Tget_member_name * * Purpose: Returns the name of a member of a compound or enumeration * datatype. Members are stored in no particular order with * numbers 0 through N-1 where N is the value returned by * H5Tget_nmembers(). * * Return: Success: Ptr to a string allocated with malloc(). The * caller is responsible for freeing the string. * * Failure: NULL * * Programmer: Robb Matzke * Wednesday, January 7, 1998 * * Modifications: * Robb Matzke, 22 Dec 1998 * Also works with enumeration datatypes. *------------------------------------------------------------------------- */ char * H5Tget_member_name(hid_t type_id, unsigned membno) { H5T_t *dt = NULL; char *ret_value; FUNC_ENTER_API(H5Tget_member_name, NULL) /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype") if((ret_value = H5T_get_member_name(dt, membno))==NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to get member name") done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5T_get_member_name * * Purpose: Private function for H5Tget_member_name. Returns the name * of a member of a compound or enumeration datatype. Members * are stored in no particular order with numbers 0 through * N-1 where N is the value returned by H5Tget_nmembers(). * * Return: Success: Ptr to a string allocated with malloc(). The * caller is responsible for freeing the string. * * Failure: NULL * * Programmer: Raymond Lu * October 9, 2002 * * Modifications: *------------------------------------------------------------------------- */ char * H5T_get_member_name(H5T_t const *dt, unsigned membno) { char *ret_value; FUNC_ENTER_NOAPI(H5T_get_member_name, NULL) assert(dt); switch (dt->shared->type) { case H5T_COMPOUND: if (membno>=dt->shared->u.compnd.nmembs) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid member number") ret_value = H5MM_xstrdup(dt->shared->u.compnd.memb[membno].name); break; case H5T_ENUM: if (membno>=dt->shared->u.enumer.nmembs) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid member number") ret_value = H5MM_xstrdup(dt->shared->u.enumer.name[membno]); break; default: HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "operation not supported for type class") } /*lint !e788 All appropriate cases are covered */ done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5Tget_member_index * * Purpose: Returns the index of a member in a compound or enumeration * datatype by given name.Members are stored in no particular * order with numbers 0 through N-1 where N is the value * returned by H5Tget_nmembers(). * * Return: Success: index of the member if exists. * Failure: -1. * * Programmer: Raymond Lu * Thursday, April 4, 2002 * * Modifications: * *------------------------------------------------------------------------- */ int H5Tget_member_index(hid_t type_id, const char *name) { H5T_t *dt = NULL; int ret_value=FAIL; unsigned i; FUNC_ENTER_API(H5Tget_member_index, FAIL) H5TRACE2("Is","is",type_id,name); /* Check arguments */ assert(name); if(NULL==(dt=H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Locate member by name */ switch (dt->shared->type) { case H5T_COMPOUND: for(i=0; i< dt->shared->u.compnd.nmembs; i++) { if(!HDstrcmp(dt->shared->u.compnd.memb[i].name, name)) HGOTO_DONE((int)i) } break; case H5T_ENUM: for(i=0; i< dt->shared->u.enumer.nmembs; i++) { if(!HDstrcmp(dt->shared->u.enumer.name[i], name)) HGOTO_DONE((int)i) } break; default: HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "operation not supported for this type") } /*lint !e788 All appropriate cases are covered */ done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5T_sort_value * * Purpose: Sorts the members of a compound datatype by their offsets; * sorts the members of an enum type by their values. This even * works for locked datatypes since it doesn't change the value * of the type. MAP is an optional parallel integer array which * is also swapped along with members of DT. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Wednesday, January 7, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_sort_value(const H5T_t *dt, int *map) { unsigned i, j, nmembs; size_t size; hbool_t swapped; uint8_t tbuf[32]; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_sort_value, FAIL) /* Check args */ assert(dt); assert(H5T_COMPOUND==dt->shared->type || H5T_ENUM==dt->shared->type); /* Use a bubble sort because we can short circuit */ if (H5T_COMPOUND==dt->shared->type) { if (H5T_SORT_VALUE!=dt->shared->u.compnd.sorted) { dt->shared->u.compnd.sorted = H5T_SORT_VALUE; nmembs = dt->shared->u.compnd.nmembs; for (i=nmembs-1, swapped=TRUE; i>0 && swapped; --i) { for (j=0, swapped=FALSE; jshared->u.compnd.memb[j].offset > dt->shared->u.compnd.memb[j+1].offset) { H5T_cmemb_t tmp = dt->shared->u.compnd.memb[j]; dt->shared->u.compnd.memb[j] = dt->shared->u.compnd.memb[j+1]; dt->shared->u.compnd.memb[j+1] = tmp; if (map) { int x = map[j]; map[j] = map[j+1]; map[j+1] = x; } swapped = TRUE; } } } #ifndef NDEBUG /* I never trust a sort :-) -RPM */ for (i=0; ishared->u.compnd.memb[i].offset < dt->shared->u.compnd.memb[i+1].offset); } #endif } } else if (H5T_ENUM==dt->shared->type) { if (H5T_SORT_VALUE!=dt->shared->u.enumer.sorted) { dt->shared->u.enumer.sorted = H5T_SORT_VALUE; nmembs = dt->shared->u.enumer.nmembs; size = dt->shared->size; assert(size<=sizeof(tbuf)); for (i=nmembs-1, swapped=TRUE; i>0 && swapped; --i) { for (j=0, swapped=FALSE; jshared->u.enumer.value+j*size, dt->shared->u.enumer.value+(j+1)*size, size)>0) { /* Swap names */ char *tmp = dt->shared->u.enumer.name[j]; dt->shared->u.enumer.name[j] = dt->shared->u.enumer.name[j+1]; dt->shared->u.enumer.name[j+1] = tmp; /* Swap values */ HDmemcpy(tbuf, dt->shared->u.enumer.value+j*size, size); HDmemcpy(dt->shared->u.enumer.value+j*size, dt->shared->u.enumer.value+(j+1)*size, size); HDmemcpy(dt->shared->u.enumer.value+(j+1)*size, tbuf, size); /* Swap map */ if (map) { int x = map[j]; map[j] = map[j+1]; map[j+1] = x; } swapped = TRUE; } } } #ifndef NDEBUG /* I never trust a sort :-) -RPM */ for (i=0; ishared->u.enumer.value+i*size, dt->shared->u.enumer.value+(i+1)*size, size)<0); } #endif } } done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5T_sort_name * * Purpose: Sorts members of a compound or enumeration datatype by their * names. This even works for locked datatypes since it doesn't * change the value of the types. * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Monday, January 4, 1999 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_sort_name(const H5T_t *dt, int *map) { unsigned i, j, nmembs; size_t size; hbool_t swapped; uint8_t tbuf[32]; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_sort_name, FAIL) /* Check args */ assert(dt); assert(H5T_COMPOUND==dt->shared->type || H5T_ENUM==dt->shared->type); /* Use a bubble sort because we can short circuit */ if (H5T_COMPOUND==dt->shared->type) { if (H5T_SORT_NAME!=dt->shared->u.compnd.sorted) { dt->shared->u.compnd.sorted = H5T_SORT_NAME; nmembs = dt->shared->u.compnd.nmembs; for (i=nmembs-1, swapped=TRUE; i>0 && swapped; --i) { for (j=0, swapped=FALSE; jshared->u.compnd.memb[j].name, dt->shared->u.compnd.memb[j+1].name)>0) { H5T_cmemb_t tmp = dt->shared->u.compnd.memb[j]; dt->shared->u.compnd.memb[j] = dt->shared->u.compnd.memb[j+1]; dt->shared->u.compnd.memb[j+1] = tmp; swapped = TRUE; if (map) { int x = map[j]; map[j] = map[j+1]; map[j+1] = x; } } } } #ifndef NDEBUG /* I never trust a sort :-) -RPM */ for (i=0; ishared->u.compnd.memb[i].name, dt->shared->u.compnd.memb[i+1].name)<0); } #endif } } else if (H5T_ENUM==dt->shared->type) { if (H5T_SORT_NAME!=dt->shared->u.enumer.sorted) { dt->shared->u.enumer.sorted = H5T_SORT_NAME; nmembs = dt->shared->u.enumer.nmembs; size = dt->shared->size; assert(size<=sizeof(tbuf)); for (i=nmembs-1, swapped=TRUE; i>0 && swapped; --i) { for (j=0, swapped=FALSE; jshared->u.enumer.name[j], dt->shared->u.enumer.name[j+1])>0) { /* Swap names */ char *tmp = dt->shared->u.enumer.name[j]; dt->shared->u.enumer.name[j] = dt->shared->u.enumer.name[j+1]; dt->shared->u.enumer.name[j+1] = tmp; /* Swap values */ HDmemcpy(tbuf, dt->shared->u.enumer.value+j*size, size); HDmemcpy(dt->shared->u.enumer.value+j*size, dt->shared->u.enumer.value+(j+1)*size, size); HDmemcpy(dt->shared->u.enumer.value+(j+1)*size, tbuf, size); /* Swap map */ if (map) { int x = map[j]; map[j] = map[j+1]; map[j+1] = x; } swapped = TRUE; } } } #ifndef NDEBUG /* I never trust a sort :-) -RPM */ for (i=0; ishared->u.enumer.name[i], dt->shared->u.enumer.name[i+1])<0); #endif } } done: FUNC_LEAVE_NOAPI(ret_value) } xdmf-3.0+git20160803/Utilities/hdf5/H5Stest.c0000640000175000017500000000621213003006557020337 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* Programmer: Quincey Koziol * Saturday, May 31, 2003 * * Purpose: Dataspace selection testing functions. */ #define H5S_PACKAGE /*suppress error about including H5Spkg */ #define H5S_TESTING /*suppress warning about H5S testing funcs*/ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Iprivate.h" /* ID Functions */ #include "H5Spkg.h" /* Dataspace functions */ /*-------------------------------------------------------------------------- NAME H5S_select_shape_same_test PURPOSE Determine if two dataspace selections are the same shape USAGE htri_t H5S_select_shape_same_test(sid1, sid2) hid_t sid1; IN: 1st dataspace to compare hid_t sid2; IN: 2nd dataspace to compare RETURNS Non-negative TRUE/FALSE on success, negative on failure DESCRIPTION Checks to see if the current selection in the dataspaces are the same dimensionality and shape. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS DO NOT USE THIS FUNCTION FOR ANYTHING EXCEPT TESTING H5P_get_class_path() EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ htri_t H5S_select_shape_same_test(hid_t sid1, hid_t sid2) { H5S_t *space1 = NULL; /* Pointer to 1st dataspace */ H5S_t *space2 = NULL; /* Pointer to 2nd dataspace */ htri_t ret_value; /* return value */ FUNC_ENTER_NOAPI(H5S_select_shape_same_test, FAIL); /* Get dataspace structures */ if (NULL == (space1=H5I_object_verify(sid1, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace"); if (NULL == (space2=H5I_object_verify(sid2, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace"); /* Check if the dataspace selections are the same shape */ if ((ret_value=H5S_select_shape_same(space1,space2))<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOMPARE, FAIL, "unable to compare dataspace selections"); done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_select_shape_same_test() */ xdmf-3.0+git20160803/Utilities/hdf5/H5FDfamily.c0000640000175000017500000011647713003006557020747 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Robb Matzke * Monday, November 10, 1997 * * Purpose: Implements a family of files that acts as a single hdf5 * file. The purpose is to be able to split a huge file on a * 64-bit platform, transfer all the <2GB members to a 32-bit * platform, and then access the entire huge file on the 32-bit * platform. * * All family members are logically the same size although their * physical sizes may vary. The logical member size is * determined by looking at the physical size of the first member * when the file is opened. When creating a file family, the * first member is created with a predefined physical size * (actually, this happens when the file family is flushed, and * can be quite time consuming on file systems that don't * implement holes, like nfs). * */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5FD_family_init_interface #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fprivate.h" /* File access */ #include "H5FDprivate.h" /* File drivers */ #include "H5FDfamily.h" /* Family file driver */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Pprivate.h" /* Property lists */ #undef MAX #define MAX(X,Y) ((X)>(Y)?(X):(Y)) #undef MIN #define MIN(X,Y) ((X)<(Y)?(X):(Y)) /* The driver identification number, initialized at runtime */ static hid_t H5FD_FAMILY_g = 0; /* The description of a file belonging to this driver. */ typedef struct H5FD_family_t { H5FD_t pub; /*public stuff, must be first */ hid_t memb_fapl_id; /*file access property list for members */ hsize_t memb_size; /*maximum size of each member file */ unsigned nmembs; /*number of family members */ unsigned amembs; /*number of member slots allocated */ H5FD_t **memb; /*dynamic array of member pointers */ haddr_t eoa; /*end of allocated addresses */ char *name; /*name generator printf format */ unsigned flags; /*flags for opening additional members */ } H5FD_family_t; /* Driver-specific file access properties */ typedef struct H5FD_family_fapl_t { hsize_t memb_size; /*size of each member */ hid_t memb_fapl_id; /*file access property list of each memb*/ } H5FD_family_fapl_t; /* Driver specific data transfer properties */ typedef struct H5FD_family_dxpl_t { hid_t memb_dxpl_id; /*data xfer property list of each memb */ } H5FD_family_dxpl_t; /* Callback prototypes */ static void *H5FD_family_fapl_get(H5FD_t *_file); static void *H5FD_family_fapl_copy(const void *_old_fa); static herr_t H5FD_family_fapl_free(void *_fa); static void *H5FD_family_dxpl_copy(const void *_old_dx); static herr_t H5FD_family_dxpl_free(void *_dx); static H5FD_t *H5FD_family_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); static herr_t H5FD_family_close(H5FD_t *_file); static int H5FD_family_cmp(const H5FD_t *_f1, const H5FD_t *_f2); static herr_t H5FD_family_query(const H5FD_t *_f1, unsigned long *flags); static haddr_t H5FD_family_get_eoa(H5FD_t *_file); static herr_t H5FD_family_set_eoa(H5FD_t *_file, haddr_t eoa); static haddr_t H5FD_family_get_eof(H5FD_t *_file); static herr_t H5FD_family_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle); static herr_t H5FD_family_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, void *_buf/*out*/); static herr_t H5FD_family_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, const void *_buf); static herr_t H5FD_family_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing); /* The class struct */ static const H5FD_class_t H5FD_family_g = { "family", /*name */ HADDR_MAX, /*maxaddr */ H5F_CLOSE_WEAK, /* fc_degree */ NULL, /*sb_size */ NULL, /*sb_encode */ NULL, /*sb_decode */ sizeof(H5FD_family_fapl_t), /*fapl_size */ H5FD_family_fapl_get, /*fapl_get */ H5FD_family_fapl_copy, /*fapl_copy */ H5FD_family_fapl_free, /*fapl_free */ sizeof(H5FD_family_dxpl_t), /*dxpl_size */ H5FD_family_dxpl_copy, /*dxpl_copy */ H5FD_family_dxpl_free, /*dxpl_free */ H5FD_family_open, /*open */ H5FD_family_close, /*close */ H5FD_family_cmp, /*cmp */ H5FD_family_query, /*query */ NULL, /*alloc */ NULL, /*free */ H5FD_family_get_eoa, /*get_eoa */ H5FD_family_set_eoa, /*set_eoa */ H5FD_family_get_eof, /*get_eof */ H5FD_family_get_handle, /*get_handle */ H5FD_family_read, /*read */ H5FD_family_write, /*write */ H5FD_family_flush, /*flush */ NULL, /*lock */ NULL, /*unlock */ H5FD_FLMAP_SINGLE /*fl_map */ }; /*-------------------------------------------------------------------------- NAME H5FD_family_init_interface -- Initialize interface-specific information USAGE herr_t H5FD_family_init_interface() RETURNS Non-negative on success/Negative on failure DESCRIPTION Initializes any interface-specific data or routines. (Just calls H5FD_family_init currently). --------------------------------------------------------------------------*/ static herr_t H5FD_family_init_interface(void) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_family_init_interface) FUNC_LEAVE_NOAPI(H5FD_family_init()) } /* H5FD_family_init_interface() */ /*------------------------------------------------------------------------- * Function: H5FD_family_init * * Purpose: Initialize this driver by registering the driver with the * library. * * Return: Success: The driver ID for the family driver. * * Failure: Negative * * Programmer: Robb Matzke * Wednesday, August 4, 1999 * * Modifications: * *------------------------------------------------------------------------- */ hid_t H5FD_family_init(void) { hid_t ret_value=H5FD_FAMILY_g; /* Return value */ FUNC_ENTER_NOAPI(H5FD_family_init, FAIL) if (H5I_VFL!=H5Iget_type(H5FD_FAMILY_g)) H5FD_FAMILY_g = H5FD_register(&H5FD_family_g,sizeof(H5FD_class_t)); /* Set return value */ ret_value=H5FD_FAMILY_g; done: FUNC_LEAVE_NOAPI(ret_value) } /*--------------------------------------------------------------------------- * Function: H5FD_family_term * * Purpose: Shut down the VFD * * Return: * * Programmer: Quincey Koziol * Friday, Jan 30, 2004 * * Modification: * *--------------------------------------------------------------------------- */ void H5FD_family_term(void) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_family_term) /* Reset VFL ID */ H5FD_FAMILY_g=0; FUNC_LEAVE_NOAPI_VOID } /* end H5FD_family_term() */ /*------------------------------------------------------------------------- * Function: H5Pset_fapl_family * * Purpose: Sets the file access property list FAPL_ID to use the family * driver. The MEMB_SIZE is the size in bytes of each file * member (used only when creating a new file) and the * MEMB_FAPL_ID is a file access property list to be used for * each family member. * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Wednesday, August 4, 1999 * * Modifications: * * Raymond Lu * Tuesday, Oct 23, 2001 * Changed the file access list to the new generic property * list. * *------------------------------------------------------------------------- */ herr_t H5Pset_fapl_family(hid_t fapl_id, hsize_t memb_size, hid_t memb_fapl_id) { herr_t ret_value; H5FD_family_fapl_t fa; H5P_genplist_t *plist; /* Property list pointer */ FUNC_ENTER_API(H5Pset_fapl_family, FAIL) H5TRACE3("e","ihi",fapl_id,memb_size,memb_fapl_id); /* Check arguments */ if(TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") if(H5P_DEFAULT == memb_fapl_id) memb_fapl_id = H5P_FILE_ACCESS_DEFAULT; else if(TRUE != H5P_isa_class(memb_fapl_id, H5P_FILE_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list") /* * Initialize driver specific information. No need to copy it into the FA * struct since all members will be copied by H5P_set_driver(). */ fa.memb_size = memb_size; fa.memb_fapl_id = memb_fapl_id; if(NULL == (plist = H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") ret_value= H5P_set_driver(plist, H5FD_FAMILY, &fa); done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5Pget_fapl_family * * Purpose: Returns information about the family file access property * list though the function arguments. * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Wednesday, August 4, 1999 * * Modifications: * * Raymond Lu * Tuesday, Oct 23, 2001 * Changed the file access list to the new generic property * list. * *------------------------------------------------------------------------- */ herr_t H5Pget_fapl_family(hid_t fapl_id, hsize_t *memb_size/*out*/, hid_t *memb_fapl_id/*out*/) { H5FD_family_fapl_t *fa; H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Pget_fapl_family, FAIL) H5TRACE3("e","ixx",fapl_id,memb_size,memb_fapl_id); if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list") if (H5FD_FAMILY!=H5P_get_driver(plist)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver") if (NULL==(fa=H5P_get_driver_info(plist))) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info") if (memb_size) *memb_size = fa->memb_size; if (memb_fapl_id) { if(NULL == (plist = H5I_object(fa->memb_fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list") *memb_fapl_id = H5P_copy_plist(plist); } /* end if */ done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_family_fapl_get * * Purpose: Gets a file access property list which could be used to * create an identical file. * * Return: Success: Ptr to new file access property list. * * Failure: NULL * * Programmer: Robb Matzke * Friday, August 13, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static void * H5FD_family_fapl_get(H5FD_t *_file) { H5FD_family_t *file = (H5FD_family_t*)_file; H5FD_family_fapl_t *fa = NULL; H5P_genplist_t *plist; /* Property list pointer */ void *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_family_fapl_get, NULL) if (NULL==(fa=H5MM_calloc(sizeof(H5FD_family_fapl_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") fa->memb_size = file->memb_size; if(NULL == (plist = H5I_object(file->memb_fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") fa->memb_fapl_id = H5P_copy_plist(plist); /* Set return value */ ret_value=fa; done: if(ret_value==NULL) { if(fa!=NULL) H5MM_xfree(fa); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_family_fapl_copy * * Purpose: Copies the family-specific file access properties. * * Return: Success: Ptr to a new property list * * Failure: NULL * * Programmer: Robb Matzke * Wednesday, August 4, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static void * H5FD_family_fapl_copy(const void *_old_fa) { const H5FD_family_fapl_t *old_fa = (const H5FD_family_fapl_t*)_old_fa; H5FD_family_fapl_t *new_fa = NULL; H5P_genplist_t *plist; /* Property list pointer */ void *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_family_fapl_copy, NULL) if (NULL==(new_fa=H5MM_malloc(sizeof(H5FD_family_fapl_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Copy the fields of the structure */ memcpy(new_fa, old_fa, sizeof(H5FD_family_fapl_t)); /* Deep copy the property list objects in the structure */ if(old_fa->memb_fapl_id==H5P_FILE_ACCESS_DEFAULT) { if(H5I_inc_ref(new_fa->memb_fapl_id)<0) HGOTO_ERROR(H5E_VFL, H5E_CANTINC, NULL, "unable to increment ref count on VFL driver") } /* end if */ else { if(NULL == (plist = H5I_object(old_fa->memb_fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") new_fa->memb_fapl_id = H5P_copy_plist(plist); } /* end else */ /* Set return value */ ret_value=new_fa; done: if(ret_value==NULL) { if(new_fa!=NULL) H5MM_xfree(new_fa); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_family_fapl_free * * Purpose: Frees the family-specific file access properties. * * Return: Success: 0 * * Failure: -1 * * Programmer: Robb Matzke * Wednesday, August 4, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_family_fapl_free(void *_fa) { H5FD_family_fapl_t *fa = (H5FD_family_fapl_t*)_fa; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_family_fapl_free, FAIL) if(H5I_dec_ref(fa->memb_fapl_id)<0) HGOTO_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't close driver ID") H5MM_xfree(fa); done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_family_dxpl_copy * * Purpose: Copes the family-specific data transfer properties. * * Return: Success: Ptr to new property list * * Failure: NULL * * Programmer: Robb Matzke * Wednesday, August 4, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static void * H5FD_family_dxpl_copy(const void *_old_dx) { const H5FD_family_dxpl_t *old_dx = (const H5FD_family_dxpl_t*)_old_dx; H5FD_family_dxpl_t *new_dx = NULL; H5P_genplist_t *plist; /* Property list pointer */ void *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_family_dxpl_copy, NULL) if (NULL==(new_dx=H5MM_malloc(sizeof(H5FD_family_dxpl_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") memcpy(new_dx, old_dx, sizeof(H5FD_family_dxpl_t)); if(old_dx->memb_dxpl_id==H5P_DATASET_XFER_DEFAULT) { if(H5I_inc_ref(new_dx->memb_dxpl_id)<0) HGOTO_ERROR(H5E_VFL, H5E_CANTINC, NULL, "unable to increment ref count on VFL driver") } /* end if */ else { if(NULL == (plist = H5I_object(old_dx->memb_dxpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") new_dx->memb_dxpl_id = H5P_copy_plist(plist); } /* end else */ /* Set return value */ ret_value=new_dx; done: if(ret_value==NULL) { if(new_dx!=NULL) H5MM_xfree(new_dx); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_family_dxpl_free * * Purpose: Frees the family-specific data transfer properties. * * Return: Success: 0 * * Failure: -1 * * Programmer: Robb Matzke * Wednesday, August 4, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_family_dxpl_free(void *_dx) { H5FD_family_dxpl_t *dx = (H5FD_family_dxpl_t*)_dx; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_family_dxpl_free, FAIL) if(H5I_dec_ref(dx->memb_dxpl_id)<0) HGOTO_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't close driver ID") H5MM_xfree(dx); done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_family_open * * Purpose: Creates and/or opens a family of files as an HDF5 file. * * Return: Success: A pointer to a new file dat structure. The * public fields will be initialized by the * caller, which is always H5FD_open(). * * Failure: NULL * * Programmer: Robb Matzke * Wednesday, August 4, 1999 * * Modifications: * Raymond Lu * Thursday, November 18, 2004 * When file is re-opened, member size passed in from access property * is checked to see if it's reasonable. If there is only 1 member * file, member size can't be smaller than current member size. * If there are at least 2 member files, member size can only be equal * the 1st member size. * *------------------------------------------------------------------------- */ static H5FD_t * H5FD_family_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { H5FD_family_t *file=NULL; H5FD_t *ret_value=NULL; char memb_name[4096], temp[4096]; hsize_t eof1=HADDR_UNDEF, eof2=HADDR_UNDEF; unsigned t_flags = flags & ~H5F_ACC_CREAT; H5P_genplist_t *plist; /* Property list pointer */ FUNC_ENTER_NOAPI(H5FD_family_open, NULL) /* Check arguments */ if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name") if (0==maxaddr || HADDR_UNDEF==maxaddr) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr") /* Initialize file from file access properties */ if (NULL==(file=H5MM_calloc(sizeof(H5FD_family_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate file struct") if (H5P_FILE_ACCESS_DEFAULT==fapl_id) { file->memb_fapl_id = H5P_FILE_ACCESS_DEFAULT; if(H5I_inc_ref(file->memb_fapl_id)<0) HGOTO_ERROR(H5E_VFL, H5E_CANTINC, NULL, "unable to increment ref count on VFL driver") file->memb_size = 1024*1024*1024; /*1GB*/ } else { H5FD_family_fapl_t *fa; if(NULL == (plist = H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") fa = H5P_get_driver_info(plist); if(fa->memb_fapl_id==H5P_FILE_ACCESS_DEFAULT) { if(H5I_inc_ref(fa->memb_fapl_id)<0) HGOTO_ERROR(H5E_VFL, H5E_CANTINC, NULL, "unable to increment ref count on VFL driver") file->memb_fapl_id = fa->memb_fapl_id; } /* end if */ else { if(NULL == (plist = H5I_object(fa->memb_fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") file->memb_fapl_id = H5P_copy_plist(plist); } /* end else */ file->memb_size = fa->memb_size; } file->name = H5MM_strdup(name); file->flags = flags; /* Check that names are unique */ sprintf(memb_name, name, 0); sprintf(temp, name, 1); if (!strcmp(memb_name, temp)) HGOTO_ERROR(H5E_FILE, H5E_FILEEXISTS, NULL, "file names not unique") /* Open all the family members */ while (1) { sprintf(memb_name, name, file->nmembs); /* Enlarge member array */ if (file->nmembs>=file->amembs) { unsigned n = MAX(64, 2*file->amembs); H5FD_t **x = H5MM_realloc(file->memb, n*sizeof(H5FD_t*)); if (!x) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to reallocate members") file->amembs = n; file->memb = x; } /* * Attempt to open file. If the first file cannot be opened then fail; * otherwise an open failure means that we've reached the last member. * Allow H5F_ACC_CREAT only on the first family member. */ H5E_BEGIN_TRY { file->memb[file->nmembs] = H5FDopen(memb_name, (0==file->nmembs ? flags : t_flags), file->memb_fapl_id, HADDR_UNDEF); } H5E_END_TRY; if (!file->memb[file->nmembs]) { if (0==file->nmembs) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open member file") H5Eclear(); break; } file->nmembs++; } /* * Get file size of the first 2 member files if exist. Check if user sets * reasonable member size. */ if(HADDR_UNDEF==(eof1 = H5FD_get_eof(file->memb[0]))) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, NULL, "file get eof1 request failed") if(file->memb[1] && (HADDR_UNDEF==(eof2 = H5FD_get_eof(file->memb[1])))) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, NULL, "file get eof2 request failed") if(eof1 && (eof2==HADDR_UNDEF || !eof2)) { /* If there is only 1 member file, new member size can't be smaller than * current member size. */ if(file->memb_sizememb_size = eof1; } else if(eof1 && eof2) { /* If there are at least 2 member files, new member size can only be equal * to the 1st member size */ file->memb_size = eof1; } ret_value=(H5FD_t *)file; done: /* Cleanup and fail */ if (ret_value==NULL && file!=NULL) { unsigned nerrors=0; /* Number of errors closing member files */ unsigned u; /* Local index variable */ for (u=0; unmembs; u++) if (file->memb[u]) if (H5FD_close(file->memb[u])<0) nerrors++; if (nerrors) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "unable to close member files") if (file->memb) H5MM_xfree(file->memb); if(H5I_dec_ref(file->memb_fapl_id)<0) HDONE_ERROR(H5E_VFL, H5E_CANTDEC, NULL, "can't close driver ID") if (file->name) H5MM_xfree(file->name); H5MM_xfree(file); } FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_family_close * * Purpose: Closes a family of files. * * Return: Success: Non-negative * * Failure: Negative with as many members closed as * possible. The only subsequent operation * permitted on the file is a close operation. * * Programmer: Robb Matzke * Wednesday, August 4, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_family_close(H5FD_t *_file) { H5FD_family_t *file = (H5FD_family_t*)_file; unsigned nerrors=0; /* Number of errors while closing member files */ unsigned u; /* Local index variable */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_family_close, FAIL) /* Close as many members as possible */ for (u=0; unmembs; u++) { if (file->memb[u]) { if (H5FDclose(file->memb[u])<0) nerrors++; else file->memb[u] = NULL; } } if (nerrors) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close member files") /* Clean up other stuff */ if(H5I_dec_ref(file->memb_fapl_id)<0) HGOTO_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't close driver ID") if (file->memb) H5MM_xfree(file->memb); if (file->name) H5MM_xfree(file->name); H5MM_xfree(file); done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_family_cmp * * Purpose: Compares two file families to see if they are the same. It * does this by comparing the first member of the two families. * * Return: Success: like strcmp() * * Failure: never fails (arguments were checked by the * caller). * * Programmer: Robb Matzke * Wednesday, August 4, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static int H5FD_family_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { const H5FD_family_t *f1 = (const H5FD_family_t*)_f1; const H5FD_family_t *f2 = (const H5FD_family_t*)_f2; int ret_value=(H5FD_VFD_DEFAULT); FUNC_ENTER_NOAPI(H5FD_family_cmp, H5FD_VFD_DEFAULT) assert(f1->nmembs>=1 && f1->memb[0]); assert(f2->nmembs>=1 && f2->memb[0]); ret_value= H5FDcmp(f1->memb[0], f2->memb[0]); done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_family_query * * Purpose: Set the flags that this VFL driver is capable of supporting. * (listed in H5FDpublic.h) * * Return: Success: non-negative * * Failure: negative * * Programmer: Quincey Koziol * Friday, August 25, 2000 * * Modifications: * *------------------------------------------------------------------------- */ /* ARGSUSED */ static herr_t H5FD_family_query(const H5FD_t UNUSED * _f, unsigned long *flags /* out */) { herr_t ret_value=SUCCEED; FUNC_ENTER_NOAPI(H5FD_family_query, FAIL) /* Set the VFL feature flags that this driver supports */ if(flags) { *flags=0; *flags|=H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ /**flags|=H5FD_FEAT_ACCUMULATE_METADATA;*/ /* OK to accumulate metadata for faster writes. * - Turn it off temporarily because there's a bug * when trying to flush metadata during closing. */ *flags|=H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ *flags|=H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ } done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_family_get_eoa * * Purpose: Returns the end-of-address marker for the file. The EOA * marker is the first address past the last byte allocated in * the format address space. * * Return: Success: The end-of-address-marker * * Failure: HADDR_UNDEF * * Programmer: Robb Matzke * Wednesday, August 4, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static haddr_t H5FD_family_get_eoa(H5FD_t *_file) { H5FD_family_t *file = (H5FD_family_t*)_file; haddr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_family_get_eoa, HADDR_UNDEF) /* Set return value */ ret_value=file->eoa; done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_family_set_eoa * * Purpose: Set the end-of-address marker for the file. * * Return: Success: 0 * * Failure: -1 * * Programmer: Robb Matzke * Wednesday, August 4, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_family_set_eoa(H5FD_t *_file, haddr_t eoa) { H5FD_family_t *file = (H5FD_family_t*)_file; haddr_t addr=eoa; char memb_name[4096]; unsigned u; /* Local index variable */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_family_set_eoa, FAIL) for (u=0; addr || unmembs; u++) { /* Enlarge member array */ if (u>=file->amembs) { unsigned n = MAX(64, 2*file->amembs); H5FD_t **x = H5MM_realloc(file->memb, n*sizeof(H5FD_t*)); if (!x) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate memory block") file->amembs = n; file->memb = x; file->nmembs = u; } /* Create another file if necessary */ if (u>=file->nmembs || !file->memb[u]) { file->nmembs = MAX(file->nmembs, u+1); sprintf(memb_name, file->name, u); H5E_BEGIN_TRY { H5_CHECK_OVERFLOW(file->memb_size,hsize_t,haddr_t); file->memb[u] = H5FDopen(memb_name, file->flags|H5F_ACC_CREAT, file->memb_fapl_id, (haddr_t)file->memb_size); } H5E_END_TRY; if (NULL==file->memb[u]) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to open member file") } /* Set the EOA marker for the member */ H5_CHECK_OVERFLOW(file->memb_size,hsize_t,haddr_t); if (addr>(haddr_t)file->memb_size) { if(H5FD_set_eoa(file->memb[u], (haddr_t)file->memb_size)<0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to set file eoa") addr -= file->memb_size; } else { if(H5FD_set_eoa(file->memb[u], addr)<0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to set file eoa") addr = 0; } } file->eoa = eoa; done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_family_get_eof * * Purpose: Returns the end-of-file marker, which is the greater of * either the total family size or the current EOA marker. * * Return: Success: End of file address, the first address past * the end of the family of files or the current * EOA, whichever is larger. * * Failure: HADDR_UNDEF * * Programmer: Robb Matzke * Wednesday, August 4, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static haddr_t H5FD_family_get_eof(H5FD_t *_file) { H5FD_family_t *file = (H5FD_family_t*)_file; haddr_t eof=0; int i; /* Local index variable */ haddr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_family_get_eof, HADDR_UNDEF) /* * Find the last member that has a non-zero EOF and break out of the loop * with `i' equal to that member. If all members have zero EOF then exit * loop with i==0. */ assert(file->nmembs>0); for (i=(int)file->nmembs-1; i>=0; --i) { if ((eof=H5FD_get_eof(file->memb[i]))!=0) break; if (0==i) break; } /* * The file size is the number of members before the i'th member plus the * size of the i'th member. */ eof += ((unsigned)i)*file->memb_size; /* Set return value */ ret_value=MAX(eof, file->eoa); done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_family_get_handle * * Purpose: Returns the file handle of FAMILY file driver. * * Returns: Non-negative if succeed or negative if fails. * * Programmer: Raymond Lu * Sept. 16, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_family_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle) { H5FD_family_t *file = (H5FD_family_t *)_file; H5P_genplist_t *plist; hsize_t offset; int memb; herr_t ret_value; FUNC_ENTER_NOAPI(H5FD_family_get_handle, FAIL) /* Get the plist structure and family offset */ if(NULL == (plist = H5P_object_verify(fapl, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") if(H5P_get(plist, H5F_ACS_FAMILY_OFFSET_NAME, &offset) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get offset for family driver") if(offset>(file->memb_size*file->nmembs)) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "offset is bigger than file size") memb = (int)(offset/file->memb_size); ret_value = H5FD_get_vfd_handle(file->memb[memb], fapl, file_handle); done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_family_read * * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR * into buffer BUF according to data transfer properties in * DXPL_ID. * * Return: Success: Zero. Result is stored in caller-supplied * buffer BUF. * * Failure: -1, contents of buffer BUF are undefined. * * Programmer: Robb Matzke * Wednesday, August 4, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_family_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, void *_buf/*out*/) { H5FD_family_t *file = (H5FD_family_t*)_file; unsigned char *buf = (unsigned char*)_buf; hid_t memb_dxpl_id = H5P_DATASET_XFER_DEFAULT; haddr_t sub; size_t req; hsize_t tempreq; unsigned u; /* Local index variable */ H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_family_read, FAIL) /* * Get the member data transfer property list. If the transfer property * list does not belong to this driver then assume defaults */ if(NULL == (plist = H5I_object(dxpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") if (H5P_DATASET_XFER_DEFAULT!=dxpl_id && H5FD_FAMILY==H5P_get_driver(plist)) { H5FD_family_dxpl_t *dx = H5P_get_driver_info(plist); assert(TRUE==H5P_isa_class(dxpl_id, H5P_DATASET_XFER)); assert(dx); memb_dxpl_id = dx->memb_dxpl_id; } /* Read from each member */ while (size>0) { H5_ASSIGN_OVERFLOW(u,addr /file->memb_size,hsize_t,unsigned); sub = addr % file->memb_size; /* This check is for mainly for IA32 architecture whose size_t's size * is 4 bytes, to prevent overflow when user application is trying to * write files bigger than 4GB. */ tempreq = file->memb_size-sub; if(tempreq > SIZET_MAX) tempreq = SIZET_MAX; req = MIN(size, (size_t)tempreq); assert(unmembs); if (H5FDread(file->memb[u], type, memb_dxpl_id, sub, req, buf)<0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "member file read failed") addr += req; buf += req; size -= req; } done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_family_write * * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR * from buffer BUF according to data transfer properties in * DXPL_ID. * * Return: Success: Zero * * Failure: -1 * * Programmer: Robb Matzke * Wednesday, August 4, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_family_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, const void *_buf) { H5FD_family_t *file = (H5FD_family_t*)_file; const unsigned char *buf = (const unsigned char*)_buf; hid_t memb_dxpl_id = H5P_DATASET_XFER_DEFAULT; haddr_t sub; size_t req; hsize_t tempreq; unsigned u; /* Local index variable */ H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_family_write, FAIL) /* * Get the member data transfer property list. If the transfer property * list does not belong to this driver then assume defaults. */ if(NULL == (plist = H5I_object(dxpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") if (H5P_DATASET_XFER_DEFAULT!=dxpl_id && H5FD_FAMILY==H5P_get_driver(plist)) { H5FD_family_dxpl_t *dx = H5P_get_driver_info(plist); assert(TRUE==H5P_isa_class(dxpl_id, H5P_DATASET_XFER)); assert(dx); memb_dxpl_id = dx->memb_dxpl_id; } /* Write to each member */ while (size>0) { H5_ASSIGN_OVERFLOW(u,addr /file->memb_size,hsize_t,unsigned); sub = addr % file->memb_size; /* This check is for mainly for IA32 architecture whose size_t's size * is 4 bytes, to prevent overflow when user application is trying to * write files bigger than 4GB. */ tempreq = file->memb_size-sub; if(tempreq > SIZET_MAX) tempreq = SIZET_MAX; req = MIN(size, (size_t)tempreq); assert(unmembs); if (H5FDwrite(file->memb[u], type, memb_dxpl_id, sub, req, buf)<0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "member file write failed") addr += req; buf += req; size -= req; } done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_family_flush * * Purpose: Flushes all family members. * * Return: Success: 0 * * Failure: -1, as many files flushed as possible. * * Programmer: Robb Matzke * Wednesday, August 4, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_family_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing) { H5FD_family_t *file = (H5FD_family_t*)_file; unsigned u, nerrors=0; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_family_flush, FAIL) for (u=0; unmembs; u++) if (file->memb[u] && H5FD_flush(file->memb[u], dxpl_id, closing)<0) nerrors++; if (nerrors) HGOTO_ERROR(H5E_IO, H5E_BADVALUE, FAIL, "unable to flush member files") done: FUNC_LEAVE_NOAPI(ret_value) } xdmf-3.0+git20160803/Utilities/hdf5/H5FSprivate.h0000640000175000017500000000321413003006557021144 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Header file for function stacks, etc. */ #ifndef _H5FSprivate_H #define _H5FSprivate_H #ifdef NOT_YET #include "H5FSpublic.h" #endif /* NOT_YET */ /* Private headers needed by this file */ #include "H5private.h" #define H5FS_NSLOTS 32 /*number of slots in an function stack */ /* A function stack */ typedef struct H5FS_t { int nused; /*num slots currently used in stack */ const char *slot[H5FS_NSLOTS]; /*array of function records */ } H5FS_t; H5_DLL herr_t H5FS_push (const char *func_name); H5_DLL herr_t H5FS_pop (void); H5_DLL herr_t H5FS_print (FILE *stream); #endif /* _H5FSprivate_H */ xdmf-3.0+git20160803/Utilities/hdf5/H5Pdcpl.c0000640000175000017500000016734613003006557020317 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #define H5P_PACKAGE /*suppress error about including H5Ppkg */ /* Private header files */ #include "H5private.h" /* Generic Functions */ #include "H5Dprivate.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Ppkg.h" /* Property lists */ #include "H5Zprivate.h" /* Data filters */ #ifdef H5_HAVE_FILTER_SZIP #ifdef H5_HAVE_SZLIB_H # include "szlib.h" #endif /* H5_HAVE_SZLIB_H */ #endif /* H5_HAVE_FILTER_SZIP */ /* Local datatypes */ /* Static function prototypes */ static herr_t H5P_set_layout(H5P_genplist_t *plist, H5D_layout_t layout); /*------------------------------------------------------------------------- * Function: H5P_set_layout * * Purpose: Sets the layout of raw data in the file. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Tuesday, November 23, 2004 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5P_set_layout(H5P_genplist_t *plist, H5D_layout_t layout) { unsigned alloc_time_state; /* State of allocation time property */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_NOAPI_NOINIT(H5P_set_layout); /* Get the allocation time state */ if(H5P_get(plist, H5D_CRT_ALLOC_TIME_STATE_NAME, &alloc_time_state) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set space allocation time"); /* If we still have the "default" allocation time, change it according to the new layout */ if(alloc_time_state) { H5D_alloc_time_t alloc_time; /* Space allocation time */ /* Set the default based on layout */ switch(layout) { case H5D_COMPACT: alloc_time=H5D_ALLOC_TIME_EARLY; break; case H5D_CONTIGUOUS: alloc_time=H5D_ALLOC_TIME_LATE; break; case H5D_CHUNKED: alloc_time=H5D_ALLOC_TIME_INCR; break; default: HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unknown layou t type") } /* end switch */ /* Set new allocation time */ if(H5P_set(plist, H5D_CRT_ALLOC_TIME_NAME, &alloc_time) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set space allocat ion time"); } /* end if */ /* Set layout value */ if(H5P_set(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set layout"); done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5P_set_layout() */ /*------------------------------------------------------------------------- * Function: H5Pset_layout * * Purpose: Sets the layout of raw data in the file. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Tuesday, January 6, 1998 * * Modifications: * * Raymond Lu * Tuesday, October 2, 2001 * Changed the way to check parameter and set property for * generic property list. * *------------------------------------------------------------------------- */ herr_t H5Pset_layout(hid_t plist_id, H5D_layout_t layout) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pset_layout, FAIL); H5TRACE2("e","iDl",plist_id,layout); /* Check arguments */ if (layout < 0 || layout >= H5D_NLAYOUTS) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "raw data layout method is not valid"); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Set value */ if(H5P_set_layout (plist, layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set layout"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Pget_layout * * Purpose: Retrieves layout type of a dataset creation property list. * * Return: Success: The layout type * * Failure: H5D_LAYOUT_ERROR (negative) * * Programmer: Robb Matzke * Wednesday, January 7, 1998 * * Modifications: * * Raymond Lu * Tuesday, October 2, 2001 * Changed the way to check parameter and get property for * generic property list. * *------------------------------------------------------------------------- */ H5D_layout_t H5Pget_layout(hid_t plist_id) { H5P_genplist_t *plist; /* Property list pointer */ H5D_layout_t ret_value=H5D_LAYOUT_ERROR; FUNC_ENTER_API(H5Pget_layout, H5D_LAYOUT_ERROR); H5TRACE1("Dl","i",plist_id); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5D_LAYOUT_ERROR, "can't find object for ID"); /* Get value */ if(H5P_get(plist, H5D_CRT_LAYOUT_NAME, &ret_value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5D_LAYOUT_ERROR, "can't get layout"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Pset_chunk * * Purpose: Sets the number of dimensions and the size of each chunk to * the values specified. The dimensionality of the chunk should * match the dimensionality of the data space. * * As a side effect, the layout method is changed to * H5D_CHUNKED. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Tuesday, January 6, 1998 * * Modifications: * * Raymond Lu * Tuesday, October 2, 2001 * Changed the way to check parameter and set property for * generic property list. * *------------------------------------------------------------------------- */ herr_t H5Pset_chunk(hid_t plist_id, int ndims, const hsize_t dim[/*ndims*/]) { int i; size_t real_dims[H5O_LAYOUT_NDIMS]; /* Full-sized array to hold chunk dims */ H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pset_chunk, FAIL); H5TRACE3("e","iIs*[a1]h",plist_id,ndims,dim); /* Check arguments */ if (ndims <= 0) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "chunk dimensionality must be positive"); if (ndims > H5S_MAX_RANK) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "chunk dimensionality is too large"); if (!dim) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no chunk dimensions specified"); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Initialize chunk dims to 0s */ HDmemset(real_dims,0,sizeof(real_dims)); for (i=0; i 0 && H5O_EFL_UNLIMITED==efl.slot[efl.nused-1].size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "previous file size is unlimited"); if (H5O_EFL_UNLIMITED!=size) { for (idx=0, total=size; idx= efl.nalloc) { size_t na = efl.nalloc + H5O_EFL_ALLOC; H5O_efl_entry_t *x = H5MM_realloc (efl.slot, na*sizeof(H5O_efl_entry_t)); if (!x) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); efl.nalloc = na; efl.slot = x; } idx = efl.nused; efl.slot[idx].name_offset = 0; /*not entered into heap yet*/ efl.slot[idx].name = H5MM_xstrdup (name); efl.slot[idx].offset = offset; efl.slot[idx].size = size; efl.nused++; if(H5P_set(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set external file list"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Pget_external_count * * Purpose: Returns the number of external files for this dataset. * * Return: Success: Number of external files * * Failure: Negative * * Programmer: Robb Matzke * Tuesday, March 3, 1998 * * Modifications: * * Raymond Lu * Tuesday, October 2, 2001 * Changed the way to check parameter and set property for * generic property list. * *------------------------------------------------------------------------- */ int H5Pget_external_count(hid_t plist_id) { H5O_efl_t efl; H5P_genplist_t *plist; /* Property list pointer */ int ret_value; /* return value */ FUNC_ENTER_API(H5Pget_external_count, FAIL); H5TRACE1("Is","i",plist_id); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Get value */ if(H5P_get(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external file list"); /* Set return value */ ret_value=(int)efl.nused; done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Pget_external * * Purpose: Returns information about an external file. External files * are numbered from zero to N-1 where N is the value returned * by H5Pget_external_count(). At most NAME_SIZE characters are * copied into the NAME array. If the external file name is * longer than NAME_SIZE with the null terminator, then the * return value is not null terminated (similar to strncpy()). * * If NAME_SIZE is zero or NAME is the null pointer then the * external file name is not returned. If OFFSET or SIZE are * null pointers then the corresponding information is not * returned. * * See Also: H5Pset_external() * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Tuesday, March 3, 1998 * * Modifications: * * Raymond Lu * Tuesday, October 2, 2001 * Changed the way to check parameter and get property for * generic property list. * *------------------------------------------------------------------------- */ herr_t H5Pget_external(hid_t plist_id, unsigned idx, size_t name_size, char *name/*out*/, off_t *offset/*out*/, hsize_t *size/*out*/) { H5O_efl_t efl; H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pget_external, FAIL); H5TRACE6("e","iIuzxxx",plist_id,idx,name_size,name,offset,size); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Get value */ if(H5P_get(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external file list"); if (idx>=efl.nused) HGOTO_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL, "external file index is out of range"); /* Return values */ if (name_size>0 && name) HDstrncpy (name, efl.slot[idx].name, name_size); if (offset) *offset = efl.slot[idx].offset; if (size) *size = efl.slot[idx].size; done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Pmodify_filter * * Purpose: Modifies the specified FILTER in the * transient or permanent output filter pipeline * depending on whether PLIST is a dataset creation or dataset * transfer property list. The FLAGS argument specifies certain * general properties of the filter and is documented below. * The CD_VALUES is an array of CD_NELMTS integers which are * auxiliary data for the filter. The integer vlues will be * stored in the dataset object header as part of the filter * information. * * The FLAGS argument is a bit vector of the following fields: * * H5Z_FLAG_OPTIONAL(0x0001) * If this bit is set then the filter is optional. If the * filter fails during an H5Dwrite() operation then the filter * is just excluded from the pipeline for the chunk for which it * failed; the filter will not participate in the pipeline * during an H5Dread() of the chunk. If this bit is clear and * the filter fails then the entire I/O operation fails. * If this bit is set but encoding is disabled for a filter, * attempting to write will generate an error. * * Note: This function currently supports only the permanent filter * pipeline. That is, PLIST_ID must be a dataset creation * property list. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Friday, April 5, 2003 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Pmodify_filter(hid_t plist_id, H5Z_filter_t filter, unsigned int flags, size_t cd_nelmts, const unsigned int cd_values[/*cd_nelmts*/]) { H5O_pline_t pline; H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pmodify_filter, FAIL); H5TRACE5("e","iZfIuz*[a3]Iu",plist_id,filter,flags,cd_nelmts,cd_values); /* Check args */ if (filter<0 || filter>H5Z_FILTER_MAX) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter identifier"); if (flags & ~((unsigned)H5Z_FLAG_DEFMASK)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid flags"); if (cd_nelmts>0 && !cd_values) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no client data values supplied"); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Get the pipeline property to append to */ if(H5P_get(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline"); /* Modify the filter parameters of the I/O pipeline */ if(H5Z_modify(&pline, filter, flags, cd_nelmts, cd_values) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to add filter to pipeline"); /* Put the I/O pipeline information back into the property list */ if(H5P_set(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set pipeline"); done: FUNC_LEAVE_API(ret_value); } /* end H5Pmodify_filter() */ /*------------------------------------------------------------------------- * Function: H5Pset_filter * * Purpose: Adds the specified FILTER and corresponding properties to the * end of the transient or permanent output filter pipeline * depending on whether PLIST is a dataset creation or dataset * transfer property list. The FLAGS argument specifies certain * general properties of the filter and is documented below. * The CD_VALUES is an array of CD_NELMTS integers which are * auxiliary data for the filter. The integer vlues will be * stored in the dataset object header as part of the filter * information. * * The FLAGS argument is a bit vector of the following fields: * * H5Z_FLAG_OPTIONAL(0x0001) * If this bit is set then the filter is optional. If the * filter fails during an H5Dwrite() operation then the filter * is just excluded from the pipeline for the chunk for which it * failed; the filter will not participate in the pipeline * during an H5Dread() of the chunk. If this bit is clear and * the filter fails then the entire I/O operation fails. * If this bit is set but encoding is disabled for a filter, * attempting to write will generate an error. * * Note: This function currently supports only the permanent filter * pipeline. That is, PLIST_ID must be a dataset creation * property list. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Wednesday, April 15, 1998 * * Modifications: * * Raymond Lu * Tuesday, October 2, 2001 * Changed the way to check parameter and set property for * generic property list. * *------------------------------------------------------------------------- */ herr_t H5Pset_filter(hid_t plist_id, H5Z_filter_t filter, unsigned int flags, size_t cd_nelmts, const unsigned int cd_values[/*cd_nelmts*/]) { H5O_pline_t pline; H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pset_filter, FAIL); H5TRACE5("e","iZfIuz*[a3]Iu",plist_id,filter,flags,cd_nelmts,cd_values); /* Check args */ if (filter<0 || filter>H5Z_FILTER_MAX) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter identifier"); if (flags & ~((unsigned)H5Z_FLAG_DEFMASK)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid flags"); if (cd_nelmts>0 && !cd_values) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no client data values supplied"); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Get the pipeline property to append to */ if(H5P_get(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline"); /* Add the filter to the I/O pipeline */ if(H5Z_append(&pline, filter, flags, cd_nelmts, cd_values) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to add filter to pipeline"); /* Put the I/O pipeline information back into the property list */ if(H5P_set(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set pipeline"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Pget_nfilters * * Purpose: Returns the number of filters in the permanent or transient * pipeline depending on whether PLIST_ID is a dataset creation * or dataset transfer property list. In each pipeline the * filters are numbered from zero through N-1 where N is the * value returned by this function. During output to the file * the filters of a pipeline are applied in increasing order * (the inverse is true for input). * * Note: Only permanent filters are supported at this time. * * Return: Success: Number of filters or zero if there are none. * * Failure: Negative * * Programmer: Robb Matzke * Tuesday, August 4, 1998 * * Modifications: * *------------------------------------------------------------------------- */ int H5Pget_nfilters(hid_t plist_id) { H5O_pline_t pline; H5P_genplist_t *plist; /* Property list pointer */ int ret_value; /* return value */ FUNC_ENTER_API(H5Pget_nfilters, FAIL); H5TRACE1("Is","i",plist_id); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Get value */ if(H5P_get(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline"); /* Set return value */ ret_value=(int)(pline.nused); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Pget_filter * * Purpose: This is the query counterpart of H5Pset_filter() and returns * information about a particular filter number in a permanent * or transient pipeline depending on whether PLIST_ID is a * dataset creation or transfer property list. On input, * CD_NELMTS indicates the number of entries in the CD_VALUES * array allocated by the caller while on exit it contains the * number of values defined by the filter. The IDX should be a * value between zero and N-1 as described for H5Pget_nfilters() * and the function will return failure if the filter number is * out or range. * * Return: Success: Filter identification number. * * Failure: H5Z_FILTER_ERROR (Negative) * * Programmer: Robb Matzke * Wednesday, April 15, 1998 * * Modifications: * * Raymond Lu * Tuesday, October 2, 2001 * Changed the way to check paramter and set property for * generic property list. * *------------------------------------------------------------------------- */ H5Z_filter_t H5Pget_filter(hid_t plist_id, unsigned idx, unsigned int *flags/*out*/, size_t *cd_nelmts/*in_out*/, unsigned cd_values[]/*out*/, size_t namelen, char name[]/*out*/) { H5O_pline_t pline; /* Filter pipeline */ H5Z_filter_info_t *filter; /* Pointer to filter information */ H5P_genplist_t *plist; /* Property list pointer */ size_t i; /* Local index variable */ H5Z_filter_t ret_value; /* return value */ FUNC_ENTER_API(H5Pget_filter, H5Z_FILTER_ERROR); H5TRACE7("Zf","iIux*zxzx",plist_id,idx,flags,cd_nelmts,cd_values,namelen, name); /* Check args */ if (cd_nelmts || cd_values) { if (cd_nelmts && *cd_nelmts>256) /* * It's likely that users forget to initialize this on input, so * we'll check that it has a reasonable value. The actual number * is unimportant because the H5O layer will detect when a message * is too large. */ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5Z_FILTER_ERROR, "probable uninitialized *cd_nelmts argument"); if (cd_nelmts && *cd_nelmts>0 && !cd_values) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5Z_FILTER_ERROR, "client data values not supplied"); /* * If cd_nelmts is null but cd_values is non-null then just ignore * cd_values */ if (!cd_nelmts) cd_values = NULL; } /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5Z_FILTER_ERROR, "can't find object for ID"); /* Get pipeline info */ if(H5P_get(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5Z_FILTER_ERROR, "can't get pipeline"); /* Check more args */ if (idx>=pline.nused) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5Z_FILTER_ERROR, "filter number is invalid"); /* Set pointer to particular filter to query */ filter=&pline.filter[idx]; if (flags) *flags = filter->flags; if (cd_values) { for (i=0; icd_nelmts && i<*cd_nelmts; i++) cd_values[i] = filter->cd_values[i]; } if (cd_nelmts) *cd_nelmts = filter->cd_nelmts; if (namelen>0 && name) { const char *s = filter->name; if (!s) { H5Z_class_t *cls = H5Z_find(filter->id); if (cls) s = cls->name; } if (s) HDstrncpy(name, s, namelen); else name[0] = '\0'; } /* Set return value */ ret_value=filter->id; done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Pget_filter_by_id * * Purpose: This is an additional query counterpart of H5Pset_filter() and * returns information about a particular filter in a permanent * or transient pipeline depending on whether PLIST_ID is a * dataset creation or transfer property list. On input, * CD_NELMTS indicates the number of entries in the CD_VALUES * array allocated by the caller while on exit it contains the * number of values defined by the filter. The ID should be the * filter ID to retrieve the parameters for. If the filter is not * set for the property list, an error will be returned. * * Return: Success: Non-negative * Failure: Negative * * Programmer: Quincey Koziol * Friday, April 5, 2003 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Pget_filter_by_id(hid_t plist_id, H5Z_filter_t id, unsigned int *flags/*out*/, size_t *cd_nelmts/*in_out*/, unsigned cd_values[]/*out*/, size_t namelen, char name[]/*out*/) { H5O_pline_t pline; /* Filter pipeline */ H5Z_filter_info_t *filter; /* Pointer to filter information */ H5P_genplist_t *plist; /* Property list pointer */ size_t i; /* Local index variable */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Pget_filter_by_id, FAIL); H5TRACE7("e","iZfx*zxzx",plist_id,id,flags,cd_nelmts,cd_values,namelen, name); /* Check args */ if (cd_nelmts || cd_values) { if (cd_nelmts && *cd_nelmts>256) /* * It's likely that users forget to initialize this on input, so * we'll check that it has a reasonable value. The actual number * is unimportant because the H5O layer will detect when a message * is too large. */ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "probable uninitialized *cd_nelmts argument"); if (cd_nelmts && *cd_nelmts>0 && !cd_values) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "client data values not supplied"); /* * If cd_nelmts is null but cd_values is non-null then just ignore * cd_values */ if (!cd_nelmts) cd_values = NULL; } /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Get pipeline info */ if(H5P_get(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline"); /* Get pointer to filter in pipeline */ if ((filter=H5Z_filter_info(&pline,id))==NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "filter ID is invalid"); /* Copy filter information into user's parameters */ if (flags) *flags = filter->flags; if (cd_values) { for (i=0; icd_nelmts && i<*cd_nelmts; i++) cd_values[i] = filter->cd_values[i]; } if (cd_nelmts) *cd_nelmts = filter->cd_nelmts; if (namelen>0 && name) { const char *s = filter->name; if (!s) { H5Z_class_t *cls = H5Z_find(filter->id); if (cls) s = cls->name; } if (s) HDstrncpy(name, s, namelen); else name[0] = '\0'; } done: FUNC_LEAVE_API(ret_value); } /* end H5Pget_filter_by_id() */ /*------------------------------------------------------------------------- * Function: H5Pall_filters_avail * * Purpose: This is a query routine to verify that all the filters set * in the dataset creation property list are available currently. * * Return: Success: TRUE if all filters available, FALSE if one or * more filters not currently available. * Failure: FAIL on error * * Programmer: Quincey Koziol * Tuesday, April 8, 2003 * * Modifications: * *------------------------------------------------------------------------- */ htri_t H5Pall_filters_avail(hid_t plist_id) { H5O_pline_t pline; /* Filter pipeline */ H5P_genplist_t *plist; /* Property list pointer */ hbool_t ret_value=TRUE; /* return value */ FUNC_ENTER_API(H5Pall_filters_avail, UFAIL); H5TRACE1("t","i",plist_id); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, UFAIL, "can't find object for ID"); /* Get pipeline info */ if(H5P_get(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, UFAIL, "can't get pipeline"); /* Set return value */ if((ret_value=H5Z_all_filters_avail(&pline))==UFAIL) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, UFAIL, "can't check pipeline information"); done: FUNC_LEAVE_API(ret_value); } /* end H5Pall_filters_avail() */ /*------------------------------------------------------------------------- * Function: H5Pset_deflate * * Purpose: Sets the compression method for a permanent or transient * filter pipeline (depending on whether PLIST_ID is a dataset * creation or transfer property list) to H5Z_FILTER_DEFLATE * and the compression level to LEVEL which should be a value * between zero and nine, inclusive. Lower compression levels * are faster but result in less compression. This is the same * algorithm as used by the GNU gzip program. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Wednesday, April 15, 1998 * * Modifications: * * Raymond Lu * Tuesday, October 2, 2001 * Changed the way to check parameter and set property for * generic property list. * *------------------------------------------------------------------------- */ herr_t H5Pset_deflate(hid_t plist_id, unsigned level) { H5O_pline_t pline; H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pset_deflate, FAIL); H5TRACE2("e","iIu",plist_id,level); /* Check arguments */ if (level>9) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid deflate level"); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Add the filter */ if(H5P_get(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline"); if(H5Z_append(&pline, H5Z_FILTER_DEFLATE, H5Z_FLAG_OPTIONAL, 1, &level)<0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to add deflate filter to pipeline"); if(H5P_set(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to set pipeline"); done: FUNC_LEAVE_API(ret_value); } /* end H5Pset_deflate() */ /*------------------------------------------------------------------------- * Function: H5Pset_szip * * Purpose: Sets the compression method for a permanent or transient * filter pipeline (depending on whether PLIST_ID is a dataset * creation or transfer property list) to H5Z_FILTER_SZIP * Szip is a special compression package that is said to be good * for scientific data. * * Return: Non-negative on success/Negative on failure * * Programmer: Kent Yang * Tuesday, April 1, 2003 * * Modifications: * * Nat Furrer and James Laird * June 17, 2004 * Now ensures that SZIP encoding is enabled * *------------------------------------------------------------------------- */ herr_t H5Pset_szip(hid_t plist_id, unsigned options_mask, unsigned pixels_per_block) { H5O_pline_t pline; H5P_genplist_t *plist; /* Property list pointer */ unsigned cd_values[2]; /* Filter parameters */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pset_szip, FAIL); H5TRACE3("e","iIuIu",plist_id,options_mask,pixels_per_block); /* Check arguments */ #ifdef H5_HAVE_FILTER_SZIP if(SZ_encoder_enabled()<=0) HGOTO_ERROR(H5E_PLINE, H5E_NOENCODER, FAIL, "Filter present but encoding is disabled."); #endif /* H5_HAVE_FILTER_SZIP */ if ((pixels_per_block%2)==1) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "pixels_per_block is not even"); if (pixels_per_block>H5_SZIP_MAX_PIXELS_PER_BLOCK) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "pixels_per_block is too large"); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Always set K13 compression (and un-set CHIP compression) */ options_mask &= (~H5_SZIP_CHIP_OPTION_MASK); options_mask |= H5_SZIP_ALLOW_K13_OPTION_MASK; /* Always set "raw" (no szip header) flag for data */ options_mask |= H5_SZIP_RAW_OPTION_MASK; /* Mask off the LSB and MSB options, if they were given */ /* (The HDF5 library sets them internally, as needed) */ options_mask &= ~(H5_SZIP_LSB_OPTION_MASK|H5_SZIP_MSB_OPTION_MASK); /* Set the parameters for the filter */ cd_values[0]=options_mask; cd_values[1]=pixels_per_block; /* Add the filter */ if(H5P_get(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline"); if(H5Z_append(&pline, H5Z_FILTER_SZIP, H5Z_FLAG_OPTIONAL, 2, cd_values)<0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to add szip filter to pipeline"); if(H5P_set(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to set pipeline"); done: FUNC_LEAVE_API(ret_value); } /* end H5Pset_szip() */ /*------------------------------------------------------------------------- * Function: H5Pset_shuffle * * Purpose: Sets the shuffling method for a permanent * filter to H5Z_FILTER_SHUFFLE * and bytes of the datatype of the array to be shuffled * * Return: Non-negative on success/Negative on failure * * Programmer: Kent Yang * Wednesday, November 13, 2002 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Pset_shuffle(hid_t plist_id) { H5O_pline_t pline; H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pset_shuffle, FAIL); H5TRACE1("e","i",plist_id); /* Check arguments */ if(TRUE != H5P_isa_class(plist_id, H5P_DATASET_CREATE)) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list"); /* Get the plist structure */ if(NULL == (plist = H5I_object(plist_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Add the filter */ if(H5P_get(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline"); if(H5Z_append(&pline, H5Z_FILTER_SHUFFLE, H5Z_FLAG_OPTIONAL, 0, NULL)<0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to shuffle the data"); if(H5P_set(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to set pipeline"); done: FUNC_LEAVE_API(ret_value); } /* end H5Pset_shuffle() */ /*------------------------------------------------------------------------- * Function: H5Pset_fletcher32 * * Purpose: Sets Fletcher32 checksum of EDC for a dataset creation * property list. * * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu * Dec 19, 2002 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Pset_fletcher32(hid_t plist_id) { H5O_pline_t pline; H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pset_fletcher32, FAIL); H5TRACE1("e","i",plist_id); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Add the Fletcher32 checksum as a filter */ if(H5P_get(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline"); if(H5Z_append(&pline, H5Z_FILTER_FLETCHER32, H5Z_FLAG_MANDATORY, 0, NULL)<0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to add deflate filter to pipeline"); if(H5P_set(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to set pipeline"); done: FUNC_LEAVE_API(ret_value); } /* end H5Pset_fletcher32() */ /*------------------------------------------------------------------------- * Function: H5Pset_fill_value * * Purpose: Set the fill value for a dataset creation property list. The * VALUE is interpretted as being of type TYPE, which need not * be the same type as the dataset but the library must be able * to convert VALUE to the dataset type when the dataset is * created. If VALUE is NULL, it will be interpreted as * undefining fill value. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Thursday, October 1, 1998 * * Modifications: * * Raymond Lu * Tuesday, October 2, 2001 * Changed the way to check parameter and set property for * generic property list. * *------------------------------------------------------------------------- */ herr_t H5Pset_fill_value(hid_t plist_id, hid_t type_id, const void *value) { H5O_fill_t fill; H5T_t *type = NULL; H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pset_fill_value, FAIL); H5TRACE3("e","iix",plist_id,type_id,value); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Get the "basic" fill value structure */ if(H5P_get(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value"); /* Reset the fill structure */ if(H5O_reset(H5O_FILL_ID, &fill)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't reset fill value"); if(value) { if (NULL==(type=H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); /* Set the fill value */ if (NULL==(fill.type=H5T_copy(type, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy data type"); fill.size = H5T_get_size(type); if (NULL==(fill.buf=H5MM_malloc(fill.size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "memory allocation failed for fill value"); HDmemcpy(fill.buf, value, fill.size); } else { fill.type = fill.buf = NULL; fill.size = (size_t)-1; } if(H5P_set(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set fill value"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Pget_fill_value * * Purpose: Queries the fill value property of a dataset creation * property list. The fill value is returned through the VALUE * pointer and the memory is allocated by the caller. The fill * value will be converted from its current data type to the * specified TYPE. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Thursday, October 1, 1998 * * Modifications: * * Raymond Lu * Tuesday, October 2, 2001 * Changed the way to check parameter and get property for * generic property list. * *------------------------------------------------------------------------- */ herr_t H5Pget_fill_value(hid_t plist_id, hid_t type_id, void *value/*out*/) { H5O_fill_t fill; H5T_t *type = NULL; /*data type */ H5T_path_t *tpath = NULL; /*type conversion info */ void *buf = NULL; /*conversion buffer */ void *bkg = NULL; /*conversion buffer */ hid_t src_id = -1; /*source data type id */ herr_t ret_value=SUCCEED; /* Return value */ H5P_genplist_t *plist; /* Property list pointer */ FUNC_ENTER_API(H5Pget_fill_value, FAIL); H5TRACE3("e","iix",plist_id,type_id,value); /* Check arguments */ if (NULL==(type=H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); if (!value) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,"no fill value output buffer"); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* * If no fill value is defined then return an error. We can't even * return zero because we don't know the data type of the dataset and * data type conversion might not have resulted in zero. If fill value * is undefined, also return error. */ if(H5P_get(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value"); if(fill.size == (size_t)-1) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "fill value is undefined"); if(fill.size == 0) { HDmemset(value, 0, H5T_get_size(type)); HGOTO_DONE(SUCCEED); } /* * Can we convert between the source and destination data types? */ if(NULL==(tpath=H5T_path_find(fill.type, type, NULL, NULL, H5AC_dxpl_id))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert between src and dst data types"); src_id = H5I_register(H5I_DATATYPE, H5T_copy (fill.type, H5T_COPY_TRANSIENT)); if (src_id<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy/register data type"); /* * Data type conversions are always done in place, so we need a buffer * other than the fill value buffer that is large enough for both source * and destination. The app-supplied buffer might do okay. */ if (H5T_get_size(type)>=H5T_get_size(fill.type)) { buf = value; if (H5T_path_bkg(tpath) && NULL==(bkg=H5MM_malloc(H5T_get_size(type)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion"); } else { if (NULL==(buf=H5MM_malloc(H5T_get_size(fill.type)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion"); if (H5T_path_bkg(tpath)) bkg = value; } HDmemcpy(buf, fill.buf, H5T_get_size(fill.type)); /* Do the conversion */ if (H5T_convert(tpath, src_id, type_id, 1, 0, 0, buf, bkg, H5AC_dxpl_id)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "data type conversion failed"); if (buf!=value) HDmemcpy(value, buf, H5T_get_size(type)); done: if (buf!=value) H5MM_xfree(buf); if (bkg!=value) H5MM_xfree(bkg); if (src_id>=0) H5I_dec_ref(src_id); FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5P_is_fill_value_defined * * Purpose: Check if fill value is defined. Internal version of function * * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu * Wednesday, January 16, 2002 * * Modifications: * Extracted from H5P_fill_value_defined, QAK, Dec. 13, 2002 * *------------------------------------------------------------------------- */ herr_t H5P_is_fill_value_defined(const struct H5O_fill_t *fill, H5D_fill_value_t *status) { herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5P_is_fill_value_defined, FAIL); assert(fill); assert(status); /* Check if the fill value was never set */ if(fill->size == (size_t)-1 && !fill->buf) *status = H5D_FILL_VALUE_UNDEFINED; /* Check if the fill value was set to the default fill value by the library */ else if(fill->size == 0 && !fill->buf) *status = H5D_FILL_VALUE_DEFAULT; /* Check if the fill value was set by the application */ else if(fill->size > 0 && fill->buf) *status = H5D_FILL_VALUE_USER_DEFINED; else { *status = H5D_FILL_VALUE_ERROR; HGOTO_ERROR(H5E_PLIST, H5E_BADRANGE, FAIL, "invalid combination of fill-value info"); } done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5P_is_fill_value_defined() */ /*------------------------------------------------------------------------- * Function: H5Pfill_value_defined * * Purpose: Check if fill value is defined. * * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu * Wednesday, January 16, 2002 * * Modifications: * * *------------------------------------------------------------------------- */ herr_t H5Pfill_value_defined(hid_t plist_id, H5D_fill_value_t *status) { H5P_genplist_t *plist; H5O_fill_t fill; herr_t ret_value = SUCCEED; FUNC_ENTER_API(H5Pfill_value_defined, FAIL); H5TRACE2("e","i*DF",plist_id,status); assert(status); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Get the fill value struct */ if(H5P_get(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value"); /* Get the fill-value status */ if(H5P_is_fill_value_defined(&fill, status) < 0) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't check fill value status"); done: FUNC_LEAVE_API(ret_value); } /* end H5Pfill_value_defined() */ /*------------------------------------------------------------------------- * Function: H5Pset_alloc_time * * Purpose: Set space allocation time for dataset during creation. * Valid values are H5D_ALLOC_TIME_DEFAULT, H5D_ALLOC_TIME_EARLY, * H5D_ALLOC_TIME_LATE, H5D_ALLOC_TIME_INCR * * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu * Wednesday, January 16, 2002 * * Modifications: * * *------------------------------------------------------------------------- */ herr_t H5Pset_alloc_time(hid_t plist_id, H5D_alloc_time_t alloc_time) { H5P_genplist_t *plist; /* Property list pointer */ unsigned alloc_time_state; /* State of allocation time property */ herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(H5Pset_alloc_time, FAIL); H5TRACE2("e","iDa",plist_id,alloc_time); /* Get the property list structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Check for resetting to default for layout type */ if(alloc_time==H5D_ALLOC_TIME_DEFAULT) { H5D_layout_t layout; /* Type of storage layout */ /* Retrieve the storage layout */ if(H5P_get(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get layout"); /* Set the default based on layout */ switch(layout) { case H5D_COMPACT: alloc_time=H5D_ALLOC_TIME_EARLY; break; case H5D_CONTIGUOUS: alloc_time=H5D_ALLOC_TIME_LATE; break; case H5D_CHUNKED: alloc_time=H5D_ALLOC_TIME_INCR; break; default: HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unknown layout type") } /* end switch */ /* Reset the "state" of the allocation time property back to the "default" */ alloc_time_state=1; } /* end if */ else /* Set the "state" of the allocation time property to indicate the user modified it */ alloc_time_state=0; /* Set values */ if(H5P_set(plist, H5D_CRT_ALLOC_TIME_NAME, &alloc_time) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set space allocation time"); if(H5P_set(plist, H5D_CRT_ALLOC_TIME_STATE_NAME, &alloc_time_state) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set space allocation time"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Pget_alloc_time * * Purpose: Get space allocation time for dataset creation. * Valid values are H5D_ALLOC_TIME_DEFAULT, H5D_ALLOC_TIME_EARLY, * H5D_ALLOC_TIME_LATE, H5D_ALLOC_TIME_INCR * * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu * Wednesday, January 16, 2002 * * Modifications: * * *------------------------------------------------------------------------- */ herr_t H5Pget_alloc_time(hid_t plist_id, H5D_alloc_time_t *alloc_time/*out*/) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(H5Pget_alloc_time, FAIL); H5TRACE2("e","ix",plist_id,alloc_time); /* Get the property list structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Get values */ if(!alloc_time || H5P_get(plist, H5D_CRT_ALLOC_TIME_NAME, alloc_time) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get space allocation time"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Pset_fill_time * * Purpose: Set fill value writing time for dataset. Valid values are * H5D_FILL_TIME_ALLOC and H5D_FILL_TIME_NEVER. * * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu * Wednesday, January 16, 2002 * * Modifications: * * *------------------------------------------------------------------------- */ herr_t H5Pset_fill_time(hid_t plist_id, H5D_fill_time_t fill_time) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(H5Pset_fill_time, FAIL); H5TRACE2("e","iDf",plist_id,fill_time); /* Check arguments */ if(fill_timeH5D_FILL_TIME_IFSET) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fill time setting"); /* Get the property list structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Set values */ if(H5P_set(plist, H5D_CRT_FILL_TIME_NAME, &fill_time) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set space allocation time"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Pget_fill_time * * Purpose: Get fill value writing time. Valid values are H5D_NEVER * and H5D_ALLOC. * * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu * Wednesday, January 16, 2002 * * Modifications: * * *------------------------------------------------------------------------- */ herr_t H5Pget_fill_time(hid_t plist_id, H5D_fill_time_t *fill_time/*out*/) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(H5Pget_fill_time, FAIL); H5TRACE2("e","ix",plist_id,fill_time); /* Get the property list structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Set values */ if(!fill_time || H5P_get(plist, H5D_CRT_FILL_TIME_NAME, fill_time) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set space allocation time"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Premove_filter * * Purpose: Deletes a filter from the dataset creation property list; * deletes all filters if FILTER is H5Z_FILTER_NONE * * Return: Non-negative on success/Negative on failure * * Programmer: Pedro Vicente * January 26, 2004 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Premove_filter(hid_t plist_id, H5Z_filter_t filter) { H5P_genplist_t *plist; /* Property list pointer */ H5O_pline_t pline; /* Filter pipeline */ herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(H5Premove_filter, FAIL) H5TRACE2("e","iZf",plist_id,filter); /* Get the property list structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get pipeline info */ if(H5P_get(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5Z_FILTER_ERROR, "can't get pipeline") /* Check if there are any filters */ if (pline.filter) { /* Delete filter */ if(H5Z_delete(&pline, filter) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5Z_FILTER_ERROR, "can't delete filter") /* Put the I/O pipeline information back into the property list */ if(H5P_set(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set pipeline") } /* end if */ done: FUNC_LEAVE_API(ret_value); } xdmf-3.0+git20160803/Utilities/hdf5/H5MMpublic.h0000640000175000017500000000344413003006557020756 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*------------------------------------------------------------------------- * * Created: H5MMproto.h * Jul 10 1997 * Robb Matzke * * Purpose: Public declarations for the H5MM (memory management) * package. * * Modifications: * *------------------------------------------------------------------------- */ #ifndef _H5MMpublic_H #define _H5MMpublic_H /* Public headers needed by this file */ #include "H5public.h" /* These typedefs are currently used for VL datatype allocation/freeing */ typedef void *(* H5MM_allocate_t)(size_t size,void *info); typedef void (* H5MM_free_t)(void *mem, void *free_info); #ifdef __cplusplus extern "C" { #endif #ifdef __cplusplus } #endif #endif xdmf-3.0+git20160803/Utilities/hdf5/H5public.h0000640000175000017500000002034213003006557020520 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * This file contains public declarations for the HDF5 module. */ #ifndef _H5public_H #define _H5public_H /* Include files for public use... */ /* * Since H5pubconf.h is a generated header file, it is messy to try * to put a #ifndef _H5pubconf_H ... #endif guard in it. * HDF5 has set an internal rule that it is being included here. * Source files should NOT include H5pubconf.h directly but include * it via H5public.h. The #ifndef _H5public_H guard above would * prevent repeated include. */ #include "H5pubconf.h" /*from configure */ #ifdef H5_HAVE_FEATURES_H #include /*for setting POSIX, BSD, etc. compatibility */ #endif #ifdef H5_HAVE_SYS_TYPES_H #include #endif #ifdef H5_STDC_HEADERS # include /*for H5T_NATIVE_CHAR defn in H5Tpublic.h */ #endif #ifndef __cplusplus #ifdef H5_HAVE_STDINT_H # include /*for C9x types */ #endif #endif #ifdef H5_HAVE_INTTYPES_H # include /* For uint64_t on some platforms */ #endif #ifdef H5_HAVE_STDDEF_H # include #endif #ifdef H5_HAVE_PARALLEL # include #ifndef MPI_FILE_NULL /*MPIO may be defined in mpi.h already */ # include #endif #endif #ifdef H5_HAVE_GASS /*for Globus GASS I/O */ #include "globus_common.h" #include "globus_gass_file.h" #endif #ifdef H5_HAVE_SRB /*for SRB I/O */ #include #endif #include "H5api_adpt.h" #ifdef __cplusplus extern "C" { #endif /* Version numbers */ #define H5_VERS_MAJOR 1 /* For major interface/format changes */ #define H5_VERS_MINOR 6 /* For minor interface/format changes */ #define H5_VERS_RELEASE 5 /* For tweaks, bug-fixes, or development */ #define H5_VERS_SUBRELEASE "" /* For pre-releases like snap0 */ /* Empty string for real releases. */ #define H5_VERS_INFO "HDF5 library version: 1.6.5" /* Full version string */ #define H5check() H5check_version(H5_VERS_MAJOR,H5_VERS_MINOR, \ H5_VERS_RELEASE) /* * Status return values. Failed integer functions in HDF5 result almost * always in a negative value (unsigned failing functions sometimes return * zero for failure) while successfull return is non-negative (often zero). * The negative failure value is most commonly -1, but don't bet on it. The * proper way to detect failure is something like: * * if ((dset = H5Dopen (file, name))<0) { * fprintf (stderr, "unable to open the requested dataset\n"); * } */ typedef int herr_t; /* * Boolean type. Successful return values are zero (false) or positive * (true). The typical true value is 1 but don't bet on it. Boolean * functions cannot fail. Functions that return `htri_t' however return zero * (false), positive (true), or negative (failure). The proper way to test * for truth from a htri_t function is: * * if ((retval = H5Tcommitted(type))>0) { * printf("data type is committed\n"); * } else if (!retval) { * printf("data type is not committed\n"); * } else { * printf("error determining whether data type is committed\n"); * } */ typedef unsigned int hbool_t; typedef int htri_t; /* Define the ssize_t type if it not is defined */ #if H5_SIZEOF_SSIZE_T==0 /* Undefine this size, we will re-define it in one of the sections below */ #undef H5_SIZEOF_SSIZE_T #if H5_SIZEOF_SIZE_T==H5_SIZEOF_INT typedef int ssize_t; # define H5_SIZEOF_SSIZE_T H5_SIZEOF_INT #elif H5_SIZEOF_SIZE_T==H5_SIZEOF_LONG typedef long ssize_t; # define H5_SIZEOF_SSIZE_T H5_SIZEOF_LONG #elif H5_SIZEOF_SIZE_T==H5_SIZEOF_LONG_LONG typedef long long ssize_t; # define H5_SIZEOF_SSIZE_T H5_SIZEOF_LONG_LONG #elif H5_SIZEOF_SIZE_T==H5_SIZEOF___INT64 typedef __int64 ssize_t; # define H5_SIZEOF_SSIZE_T H5_SIZEOF___INT64 #else /* Can't find matching type for ssize_t */ # error "nothing appropriate for ssize_t" #endif #endif /* * The sizes of file objects have their own types defined here. If large * sizes are enabled then use a 64-bit data type, otherwise use the size of * memory objects. */ #ifdef H5_HAVE_LARGE_HSIZET # if H5_SIZEOF_LONG_LONG>=8 typedef unsigned long long hsize_t; typedef signed long long hssize_t; # define H5_SIZEOF_HSIZE_T H5_SIZEOF_LONG_LONG # elif H5_SIZEOF___INT64>=8 typedef unsigned __int64 hsize_t; typedef signed __int64 hssize_t; # define H5_SIZEOF_HSIZE_T H5_SIZEOF___INT64 # endif #else /* H5_HAVE_LARGE_HSIZET */ typedef size_t hsize_t; typedef ssize_t hssize_t; # define H5_SIZEOF_HSIZE_T H5_SIZEOF_SIZE_T #endif /* H5_HAVE_LARGE_HSIZET */ /* * File addresses have there own types. */ #if H5_SIZEOF_INT64_T>=8 typedef uint64_t haddr_t; # define HADDR_UNDEF ((haddr_t)(int64_t)(-1)) # define H5_SIZEOF_HADDR_T H5_SIZEOF_INT64_T # ifdef H5_HAVE_PARALLEL # define HADDR_AS_MPI_TYPE MPI_LONG_LONG_INT # endif /* H5_HAVE_PARALLEL */ #elif H5_SIZEOF_INT>=8 typedef unsigned haddr_t; # define HADDR_UNDEF ((haddr_t)(-1)) # define H5_SIZEOF_HADDR_T H5_SIZEOF_INT # ifdef H5_HAVE_PARALLEL # define HADDR_AS_MPI_TYPE MPI_UNSIGNED # endif /* H5_HAVE_PARALLEL */ #elif H5_SIZEOF_LONG>=8 typedef unsigned long haddr_t; # define HADDR_UNDEF ((haddr_t)(long)(-1)) # define H5_SIZEOF_HADDR_T H5_SIZEOF_LONG # ifdef H5_HAVE_PARALLEL # define HADDR_AS_MPI_TYPE MPI_UNSIGNED_LONG # endif /* H5_HAVE_PARALLEL */ #elif H5_SIZEOF_LONG_LONG>=8 typedef unsigned long long haddr_t; # define HADDR_UNDEF ((haddr_t)(long long)(-1)) # define H5_SIZEOF_HADDR_T H5_SIZEOF_LONG_LONG # ifdef H5_HAVE_PARALLEL # define HADDR_AS_MPI_TYPE MPI_LONG_LONG_INT # endif /* H5_HAVE_PARALLEL */ #elif H5_SIZEOF___INT64>=8 typedef unsigned __int64 haddr_t; # define HADDR_UNDEF ((haddr_t)(__int64)(-1)) # define H5_SIZEOF_HADDR_T H5_SIZEOF___INT64 # ifdef H5_HAVE_PARALLEL # define HADDR_AS_MPI_TYPE MPI_LONG_LONG_INT # endif /* H5_HAVE_PARALLEL */ #else # error "nothing appropriate for haddr_t" #endif #if H5_SIZEOF_HADDR_T ==H5_SIZEOF_INT # define H5_PRINTF_HADDR_FMT "%u" #elif H5_SIZEOF_HADDR_T ==H5_SIZEOF_LONG # define H5_PRINTF_HADDR_FMT "%lu" #elif H5_SIZEOF_HADDR_T ==H5_SIZEOF_LONG_LONG # define H5_PRINTF_HADDR_FMT "%"H5_PRINTF_LL_WIDTH"u" #elif H5_SIZEOF_HADDR_T ==H5_SIZEOF___INT64 # define H5_PRINTF_HADDR_FMT "%"H5_PRINTF_LL_WIDTH"u" #else # error "nothing appropriate for H5_PRINTF_HADDR_FMT" #endif #define HADDR_MAX (HADDR_UNDEF-1) /* Functions in H5.c */ H5_DLL herr_t H5open(void); H5_DLL herr_t H5close(void); H5_DLL herr_t H5dont_atexit(void); H5_DLL herr_t H5garbage_collect(void); H5_DLL herr_t H5set_free_list_limits (int reg_global_lim, int reg_list_lim, int arr_global_lim, int arr_list_lim, int blk_global_lim, int blk_list_lim); H5_DLL herr_t H5get_libversion(unsigned *majnum, unsigned *minnum, unsigned *relnum); H5_DLL herr_t H5check_version(unsigned majnum, unsigned minnum, unsigned relnum); #ifdef __cplusplus } #endif #endif xdmf-3.0+git20160803/Utilities/hdf5/H5FS.c0000640000175000017500000001531413003006557017550 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Purpose: Provides internal function tracing in the form of a stack. * The FUNC_ENTER() macro adds the function name to the function * stack whenever a function is entered. * As the functions return with FUNC_LEAVE, * entries are removed from the stack. * * A function stack has a fixed maximum size. If this size is * exceeded then the stack will be truncated and only the * first called functions will have entries on the stack. This is * expected to be a rare condition. * */ #include "H5private.h" /* Generic Functions */ #include "H5FSprivate.h" /* Private function stack routines */ #ifdef H5_HAVE_FUNCSTACK #ifdef H5_HAVE_THREADSAFE /* * The per-thread function stack. pthread_once() initializes a special * key that will be used by all threads to create a stack specific to * each thread individually. The association of stacks to threads will * be handled by the pthread library. * * In order for this macro to work, H5FS_get_my_stack() must be preceeded * by "H5FS_t *fstack =". */ static H5FS_t *H5FS_get_stack(void); #define H5FS_get_my_stack() H5FS_get_stack() #else /* H5_HAVE_THREADSAFE */ /* * The function stack. Eventually we'll have some sort of global table so each * thread has it's own stack. The stacks will be created on demand when the * thread first calls H5FS_push(). */ H5FS_t H5FS_stack_g[1]; #define H5FS_get_my_stack() (H5FS_stack_g+0) #endif /* H5_HAVE_THREADSAFE */ #ifdef H5_HAVE_THREADSAFE /*------------------------------------------------------------------------- * Function: H5FS_get_stack * * Purpose: Support function for H5FS_get_my_stack() to initialize and * acquire per-thread function stack. * * Return: Success: function stack (H5FS_t *) * * Failure: NULL * * Programmer: Quincey Koziol * February 6, 2003 * * Modifications: * *------------------------------------------------------------------------- */ static H5FS_t * H5FS_get_stack(void) { H5FS_t *fstack; FUNC_ENTER_NOAPI_NOFUNC_NOFS(H5FS_get_stack); fstack = pthread_getspecific(H5TS_funcstk_key_g); if (!fstack) { /* no associated value with current thread - create one */ fstack = (H5FS_t *)HDmalloc(sizeof(H5FS_t)); /* Don't use H5MM_malloc() here, it causes infinite recursion */ pthread_setspecific(H5TS_funcstk_key_g, (void *)fstack); fstack->nused=0; } FUNC_LEAVE_NOAPI_NOFS(fstack); } /* end H5FS_get_stack() */ #endif /* H5_HAVE_THREADSAFE */ /*------------------------------------------------------------------------- * Function: H5FS_print * * Purpose: Prints the function stack in some default way. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * THursday, February 6, 2003 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5FS_print(FILE *stream) { H5FS_t *fstack = H5FS_get_my_stack (); /* Get the correct function stack */ const int indent = 2; /* Indention level */ int i; /* Local index ariable */ /* Don't push this function on the function stack... :-) */ FUNC_ENTER_NOAPI_NOFUNC_NOFS(H5FS_print); /* Sanity check */ assert(fstack); /* Default to outputting information to stderr */ if (!stream) stream = stderr; HDfprintf (stream, "HDF5-DIAG: Function stack from %s ", H5_lib_vers_info_g); /* try show the process or thread id in multiple processes cases*/ #ifdef H5_HAVE_THREADSAFE HDfprintf (stream, "thread %d.", (int)pthread_self()); #else /* H5_HAVE_THREADSAFE */ HDfprintf (stream, "thread 0."); #endif /* H5_HAVE_THREADSAFE */ if (fstack && fstack->nused>0) HDfprintf (stream, " Back trace follows."); HDfputc ('\n', stream); for (i=fstack->nused-1; i>=0; --i) HDfprintf(stream, "%*s#%03d: Routine: %s\n", indent, "", i, fstack->slot[i]); FUNC_LEAVE_NOAPI_NOFS(SUCCEED); } /* end H5FS_print() */ /*------------------------------------------------------------------------- * Function: H5FS_push * * Purpose: Pushes a new record onto function stack for the current * thread. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Thursday, February 6, 2003 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5FS_push(const char *func_name) { H5FS_t *fstack = H5FS_get_my_stack (); /* Don't push this function on the function stack... :-) */ FUNC_ENTER_NOAPI_NOFUNC_NOFS(H5FS_push); /* Sanity check */ assert (fstack); assert (func_name); /* * Push the function if there's room. Otherwise just increment count */ if (fstack->nusedslot[fstack->nused] = func_name; fstack->nused++; FUNC_LEAVE_NOAPI_NOFS(SUCCEED); } /* end H5FS_push() */ /*------------------------------------------------------------------------- * Function: H5FS_pop * * Purpose: Pops a record off function stack for the current thread. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Thursday, February 6, 2003 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5FS_pop(void) { H5FS_t *fstack = H5FS_get_my_stack (); /* Don't push this function on the function stack... :-) */ FUNC_ENTER_NOAPI_NOFUNC_NOFS(H5FS_pop); /* Sanity check */ assert (fstack); assert (fstack->nused>0); /* Pop the function. */ fstack->nused--; FUNC_LEAVE_NOAPI_NOFS(SUCCEED); } /* end H5FS_pop() */ #endif /* H5_HAVE_FUNCSTACK */ xdmf-3.0+git20160803/Utilities/hdf5/H5Apublic.h0000640000175000017500000000450713003006557020626 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * This file contains public declarations for the H5A module. */ #ifndef _H5Apublic_H #define _H5Apublic_H /* Public headers needed by this file */ #include "H5Ipublic.h" #ifdef __cplusplus extern "C" { #endif typedef herr_t (*H5A_operator_t)(hid_t location_id/*in*/, const char *attr_name/*in*/, void *operator_data/*in,out*/); /* Public function prototypes */ H5_DLL hid_t H5Acreate(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t plist_id); H5_DLL hid_t H5Aopen_name(hid_t loc_id, const char *name); H5_DLL hid_t H5Aopen_idx(hid_t loc_id, unsigned idx); H5_DLL herr_t H5Awrite(hid_t attr_id, hid_t type_id, const void *buf); H5_DLL herr_t H5Aread(hid_t attr_id, hid_t type_id, void *buf); H5_DLL herr_t H5Aclose(hid_t attr_id); H5_DLL hid_t H5Aget_space(hid_t attr_id); H5_DLL hid_t H5Aget_type(hid_t attr_id); H5_DLL ssize_t H5Aget_name(hid_t attr_id, size_t buf_size, char *buf); H5_DLL hsize_t H5Aget_storage_size(hid_t attr_id); H5_DLL int H5Aget_num_attrs(hid_t loc_id); H5_DLL herr_t H5Arename(hid_t loc_id, const char *old_name, const char *new_name); H5_DLL herr_t H5Aiterate(hid_t loc_id, unsigned *attr_num, H5A_operator_t op, void *op_data); H5_DLL herr_t H5Adelete(hid_t loc_id, const char *name); #ifdef __cplusplus } #endif #endif /* _H5Apublic_H */ xdmf-3.0+git20160803/Utilities/hdf5/H5HLpublic.h0000640000175000017500000000310513003006557020742 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*------------------------------------------------------------------------- * * Created: H5HLpublic.h * Jul 16 1997 * Robb Matzke * * Purpose: Public declarations for the H5HL (local heap) package. * * Modifications: * *------------------------------------------------------------------------- */ #ifndef _H5HLpublic_H #define _H5HLpublic_H /* Public headers needed by this file */ #include "H5public.h" #ifdef __cplusplus extern "C" { #endif #ifdef __cplusplus } #endif #endif xdmf-3.0+git20160803/Utilities/hdf5/H5Gprivate.h0000640000175000017500000002036113003006557021024 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*------------------------------------------------------------------------- * * Created: H5Gprivate.h * Jul 11 1997 * Robb Matzke * * Purpose: Library-visible declarations. * * Modifications: Aug 22, 2002 * Pedro Vicente * Added 'names' field to H5G_entry_t * Added H5G_replace_name * *------------------------------------------------------------------------- */ #ifndef _H5Gprivate_H #define _H5Gprivate_H /* Include package's public header */ #include "H5Gpublic.h" /* Private headers needed by this file */ #include "H5private.h" /* Generic Functions */ #include "H5Bprivate.h" /* B-trees */ #include "H5Fprivate.h" /* File access */ #include "H5RSprivate.h" /* Reference-counted strings */ /* * Define this to enable debugging. */ #ifdef NDEBUG # undef H5G_DEBUG #endif #define H5G_NODE_MAGIC "SNOD" /*symbol table node magic number */ #define H5G_NODE_SIZEOF_MAGIC 4 /*sizeof symbol node magic number */ #define H5G_NO_CHANGE (-1) /*see H5G_ent_modified() */ #define H5G_NLINKS 16 /*max symlinks to follow per lookup */ /* * The disk size for a symbol table entry... */ #define H5G_SIZEOF_SCRATCH 16 #define H5G_SIZEOF_ENTRY(F) \ (H5F_SIZEOF_SIZE(F) + /*offset of name into heap */ \ H5F_SIZEOF_ADDR(F) + /*address of object header */ \ 4 + /*entry type */ \ 4 + /*reserved */ \ H5G_SIZEOF_SCRATCH) /*scratch pad space */ /* * Various types of object header information can be cached in a symbol * table entry (it's normal home is the object header to which the entry * points). This datatype determines what (if anything) is cached in the * symbol table entry. */ typedef enum H5G_type_t { H5G_CACHED_ERROR = -1, /*force enum to be signed */ H5G_NOTHING_CACHED = 0, /*nothing is cached, must be 0 */ H5G_CACHED_STAB = 1, /*symbol table, `stab' */ H5G_CACHED_SLINK = 2, /*symbolic link */ H5G_NCACHED = 3 /*THIS MUST BE LAST */ } H5G_type_t; /* * A symbol table entry caches these parameters from object header * messages... The values are entered into the symbol table when an object * header is created (by hand) and are extracted from the symbol table with a * callback function registered in H5O_init_interface(). Be sure to update * H5G_ent_decode(), H5G_ent_encode(), and H5G_ent_debug() as well. */ typedef union H5G_cache_t { struct { haddr_t btree_addr; /*file address of symbol table B-tree*/ haddr_t heap_addr; /*file address of stab name heap */ } stab; struct { size_t lval_offset; /*link value offset */ } slink; } H5G_cache_t; /* * A symbol table entry. The two important fields are `name_off' and * `header'. The remaining fields are used for caching information that * also appears in the object header to which this symbol table entry * points. */ typedef struct H5G_entry_t { hbool_t dirty; /*entry out-of-date? */ H5G_type_t type; /*type of information cached */ H5G_cache_t cache; /*cached data from object header */ size_t name_off; /*offset of name within name heap */ haddr_t header; /*file address of object header */ H5F_t *file; /*file to which this obj hdr belongs */ H5RS_str_t *user_path_r; /* Path to object, as opened by user */ H5RS_str_t *canon_path_r; /* Path to object, as found in file */ unsigned user_path_hidden; /* Whether the user's path is valid */ } H5G_entry_t; typedef struct H5G_t H5G_t; typedef struct H5G_shared_t H5G_shared_t; /* Type of operation being performed for call to H5G_replace_name() */ typedef enum { OP_MOVE = 0, /* H5*move call */ OP_UNLINK, /* H5Gunlink call */ OP_MOUNT, /* H5Fmount call */ OP_UNMOUNT /* H5Funmount call */ } H5G_names_op_t; /* Depth of group entry copy */ typedef enum { H5G_COPY_NULL, /* Null destination names */ H5G_COPY_LIMITED, /* Limited copy from source to destination, omitting name & old name fields */ H5G_COPY_SHALLOW, /* Copy from source to destination, including name & old name fields */ H5G_COPY_DEEP /* Deep copy from source to destination, including duplicating name & old name fields */ } H5G_ent_copy_depth_t; /* * Library prototypes... These are the ones that other packages routinely * call. */ H5_DLL H5G_entry_t *H5G_loc(hid_t loc_id); H5_DLL herr_t H5G_mkroot(H5F_t *f, hid_t dxpl_id, H5G_entry_t *root_entry); H5_DLL H5G_entry_t *H5G_entof(H5G_t *grp); H5_DLL H5F_t *H5G_fileof(H5G_t *grp); H5_DLL herr_t H5G_free(H5G_t *grp); H5_DLL H5G_t *H5G_open(H5G_entry_t *ent, hid_t dxpl_id); H5_DLL herr_t H5G_close(H5G_t *grp); H5_DLL int H5G_get_type(H5G_entry_t *ent, hid_t dxpl_id); H5_DLL herr_t H5G_get_objinfo(H5G_entry_t *loc, const char *name, hbool_t follow_link, H5G_stat_t *statbuf/*out*/, hid_t dxpl_id); H5_DLL herr_t H5G_insert(H5G_entry_t *loc, const char *name, H5G_entry_t *ent, hid_t dxpl_id); H5_DLL herr_t H5G_find(H5G_entry_t *loc, const char *name, H5G_entry_t *ent/*out*/, hid_t dxpl_id); H5_DLL H5F_t *H5G_insertion_file(H5G_entry_t *loc, const char *name, hid_t dxpl_id); H5_DLL herr_t H5G_replace_name(int type, H5G_entry_t *loc, H5RS_str_t *src_name, H5G_entry_t *src_loc, H5RS_str_t *dst_name, H5G_entry_t *dst_loc, H5G_names_op_t op); H5_DLL herr_t H5G_free_grp_name(H5G_t *grp); H5_DLL herr_t H5G_get_shared_count(H5G_t *grp); H5_DLL herr_t H5G_mount(H5G_t *grp); H5_DLL herr_t H5G_unmount(H5G_t *grp); /* * These functions operate on symbol table nodes. */ H5_DLL herr_t H5G_node_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int fwidth, haddr_t heap); H5_DLL herr_t H5G_node_init(H5F_t *f); H5_DLL herr_t H5G_node_close(const H5F_t *f); /* * These functions operate on symbol table entries. They're used primarily * in the H5O package where header messages are cached in symbol table * entries. The subclasses of H5O probably don't need them though. */ H5_DLL herr_t H5G_ent_encode(H5F_t *f, uint8_t **pp, const H5G_entry_t *ent); H5_DLL herr_t H5G_ent_decode(H5F_t *f, const uint8_t **pp, H5G_entry_t *ent/*out*/); H5_DLL const H5G_cache_t *H5G_ent_cache(const H5G_entry_t *ent, H5G_type_t *cache_type); H5_DLL herr_t H5G_ent_copy(H5G_entry_t *dst, const H5G_entry_t *src, H5G_ent_copy_depth_t depth); H5_DLL herr_t H5G_ent_reset(H5G_entry_t *ent); H5_DLL herr_t H5G_free_ent_name(H5G_entry_t *ent); H5_DLL herr_t H5G_ent_debug(H5F_t *f, hid_t dxpl_id, const H5G_entry_t *ent, FILE * stream, int indent, int fwidth, haddr_t heap); #endif xdmf-3.0+git20160803/Utilities/hdf5/H5Zszip.c0000640000175000017500000003550313003006557020361 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #define H5Z_PACKAGE /*suppress error about including H5Zpkg */ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fprivate.h" /* File access */ #include "H5MMprivate.h" /* Memory management */ #include "H5Oprivate.h" /* Object headers */ #include "H5Ppublic.h" /* Property lists */ #include "H5Tpublic.h" /* Datatype functions */ #include "H5Zpkg.h" /* Data filters */ #ifdef H5_HAVE_FILTER_SZIP #ifdef H5_HAVE_SZLIB_H # include "szlib.h" #endif /* Local function prototypes */ static herr_t H5Z_can_apply_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id); static herr_t H5Z_set_local_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id); static size_t H5Z_filter_szip (unsigned flags, size_t cd_nelmts, const unsigned cd_values[], size_t nbytes, size_t *buf_size, void **buf); /* This message derives from H5Z */ const H5Z_class_t H5Z_SZIP[1] = {{ H5Z_FILTER_SZIP, /* Filter id number */ "szip", /* Filter name for debugging */ H5Z_can_apply_szip, /* The "can apply" callback */ H5Z_set_local_szip, /* The "set local" callback */ H5Z_filter_szip, /* The actual filter function */ }}; /* Local macros */ #define H5Z_SZIP_USER_NPARMS 2 /* Number of parameters that users can set */ #define H5Z_SZIP_TOTAL_NPARMS 4 /* Total number of parameters for filter */ #define H5Z_SZIP_PARM_MASK 0 /* "User" parameter for option mask */ #define H5Z_SZIP_PARM_PPB 1 /* "User" parameter for pixels-per-block */ #define H5Z_SZIP_PARM_BPP 2 /* "Local" parameter for bits-per-pixel */ #define H5Z_SZIP_PARM_PPS 3 /* "Local" parameter for pixels-per-scanline */ /*------------------------------------------------------------------------- * Function: H5Z_can_apply_szip * * Purpose: Check the parameters for szip compression for validity and * whether they fit a particular dataset. * * Note: This function currently range-checks for datatypes with * 8-bit boundaries (8, 16, 24, etc.). It appears that the szip * library can actually handle 1-24, 32 & 64 bit samples. If * this becomes important, we should make the checks below more * sophisticated and have them check for n-bit datatypes of the * correct size, etc. - QAK * * Return: Success: Non-negative * Failure: Negative * * Programmer: Quincey Koziol * Monday, April 7, 2003 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5Z_can_apply_szip(hid_t UNUSED dcpl_id, hid_t type_id, hid_t UNUSED space_id) { unsigned dtype_size; /* Datatype's size (in bits) */ H5T_order_t dtype_order; /* Datatype's endianness order */ herr_t ret_value=TRUE; /* Return value */ FUNC_ENTER_NOAPI(H5Z_can_apply_szip, FAIL) /* If this is the Szip filter, make sure it can encode */ if (SZ_encoder_enabled()<=0) HGOTO_ERROR(H5E_PLINE, H5E_NOENCODER, FAIL, "Filter present but encoding is disabled."); /* Get datatype's size, for checking the "bits-per-pixel" */ if((dtype_size=(8*H5Tget_size(type_id)))==0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size") /* Range check datatype's size */ if(dtype_size>32 && dtype_size!=64) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FALSE, "invalid datatype size") /* Get datatype's endianness order */ if((dtype_order=H5Tget_order(type_id))==H5T_ORDER_ERROR) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "can't retrieve datatype endianness order") /* Range check datatype's endianness order */ /* (Note: this may not handle non-atomic datatypes well) */ if(dtype_order != H5T_ORDER_LE && dtype_order != H5T_ORDER_BE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FALSE, "invalid datatype endianness order") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_can_apply_szip() */ /*------------------------------------------------------------------------- * Function: H5Z_set_local_szip * * Purpose: Set the "local" dataset parameters for szip compression. * * Return: Success: Non-negative * Failure: Negative * * Programmer: Quincey Koziol * Monday, April 7, 2003 * * Modifications: Used new logic to set the size of the scanline parameter. * Now SZIP compression can be applied to the chunk * of any shape and size with only one restriction: the number * of elements in the chunk has to be not less than number * of elements (pixels) in the block (cd_values[H5Z_SZIP_PARM_PPB] * parameter). * Elena Pourmal, July 20, 2004 * *------------------------------------------------------------------------- */ static herr_t H5Z_set_local_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id) { unsigned flags; /* Filter flags */ size_t cd_nelmts=H5Z_SZIP_USER_NPARMS; /* Number of filter parameters */ unsigned cd_values[H5Z_SZIP_TOTAL_NPARMS]; /* Filter parameters */ hsize_t dims[H5O_LAYOUT_NDIMS]; /* Dataspace (i.e. chunk) dimensions */ int ndims; /* Number of (chunk) dimensions */ H5T_order_t dtype_order; /* Datatype's endianness order */ int dtype_size; /* Datatype's size (in bits) */ size_t dtype_precision; /* Datatype's precision (in bits) */ size_t dtype_offset; /* Datatype's offset (in bits) */ hsize_t scanline; /* Size of dataspace's fastest changing dimension */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5Z_set_local_szip, FAIL) /* Get the filter's current parameters */ if(H5Pget_filter_by_id(dcpl_id,H5Z_FILTER_SZIP,&flags,&cd_nelmts, cd_values,0,NULL)<0) HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get szip parameters"); /* Get datatype's size, for checking the "bits-per-pixel" */ if((dtype_size=(8*H5Tget_size(type_id)))==0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size"); /* Get datatype's precision, in case is less than full bits */ if((dtype_precision=H5Tget_precision(type_id))==0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype precision"); if(dtype_precision24) { if (dtype_precision <= 32) { dtype_precision=32; } else if ( dtype_precision <= 64) { dtype_precision=64; } } /* Set "local" parameter for this dataset's "bits-per-pixel" */ cd_values[H5Z_SZIP_PARM_BPP]=dtype_precision; /* Get dimensions for dataspace */ if ((ndims=H5Sget_simple_extent_dims(space_id, dims, NULL))<0) HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "unable to get dataspace dimensions") /* Set "local" parameter for this dataset's "pixels-per-scanline" */ /* (Use the chunk's fastest changing dimension size) */ assert(ndims>0); scanline=dims[ndims-1]; /* Adjust scanline if it is smaller than number of pixels per block or if it is bigger than maximum pixels per scanline, or there are more than SZ_MAX_BLOCKS_PER_SCANLINE blocks per scanline */ /* Check the pixels per block against the 'scanline' size */ if(scanline * * Purpose: Functions in this file implement a cache for * things which exist on disk. All "things" associated * with a particular HDF file share the same cache; each * HDF file has it's own cache. * * Modifications: * * Robb Matzke, 4 Aug 1997 * Added calls to H5E. * * Quincey Koziol, 22 Apr 2000 * Turned on "H5AC_SORT_BY_ADDR" * * John Mainzer, 5/19/04 * Complete redesign and rewrite. See the header comments for * H5AC_t for an overview of what is going on. * * John Mainzer, 6/4/04 * Factored the new cache code into a separate file (H5C.c) to * facilitate re-use. Re-worked this file again to use H5C. * *------------------------------------------------------------------------- */ #define H5F_PACKAGE /*suppress error about including H5Fpkg */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5AC_init_interface #include "H5private.h" /* Generic Functions */ #include "H5ACprivate.h" /* Metadata cache */ #include "H5Dprivate.h" /* Dataset functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* Files */ #include "H5FDprivate.h" /* File drivers */ #include "H5Iprivate.h" /* IDs */ #include "H5Pprivate.h" /* Property lists */ /* * Private file-scope variables. */ /* Default dataset transfer property list for metadata I/O calls */ /* (Collective set, "block before metadata write" set and "library internal" set) */ /* (Global variable definition, declaration is in H5ACprivate.h also) */ hid_t H5AC_dxpl_id=(-1); /* Private dataset transfer property list for metadata I/O calls */ /* (Collective set and "library internal" set) */ /* (Static variable definition) */ static hid_t H5AC_noblock_dxpl_id=(-1); /* Dataset transfer property list for independent metadata I/O calls */ /* (just "library internal" set - i.e. independent transfer mode) */ /* (Global variable definition, declaration is in H5ACprivate.h also) */ hid_t H5AC_ind_dxpl_id=(-1); /* * Private file-scope function declarations: */ static herr_t H5AC_check_if_write_permitted(const H5F_t *f, hid_t dxpl_id, hbool_t * write_permitted_ptr); /*------------------------------------------------------------------------- * Function: H5AC_init * * Purpose: Initialize the interface from some other layer. * * Return: Success: non-negative * * Failure: negative * * Programmer: Quincey Koziol * Saturday, January 18, 2003 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5AC_init(void) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5AC_init, FAIL) /* FUNC_ENTER() does all the work */ done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5AC_init_interface * * Purpose: Initialize interface-specific information * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Thursday, July 18, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5AC_init_interface(void) { #ifdef H5_HAVE_PARALLEL H5P_genclass_t *xfer_pclass; /* Dataset transfer property list class object */ H5P_genplist_t *xfer_plist; /* Dataset transfer property list object */ unsigned block_before_meta_write; /* "block before meta write" property value */ unsigned library_internal=1; /* "library internal" property value */ H5FD_mpio_xfer_t xfer_mode; /* I/O transfer mode property value */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5AC_init_interface) /* Sanity check */ HDassert(H5P_CLS_DATASET_XFER_g!=(-1)); /* Get the dataset transfer property list class object */ if (NULL == (xfer_pclass = H5I_object(H5P_CLS_DATASET_XFER_g))) HGOTO_ERROR(H5E_CACHE, H5E_BADATOM, FAIL, "can't get property list class") /* Get an ID for the blocking, collective H5AC dxpl */ if ((H5AC_dxpl_id=H5P_create_id(xfer_pclass)) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, FAIL, "unable to register property list") /* Get the property list object */ if (NULL == (xfer_plist = H5I_object(H5AC_dxpl_id))) HGOTO_ERROR(H5E_CACHE, H5E_BADATOM, FAIL, "can't get new property list object") /* Insert 'block before metadata write' property */ block_before_meta_write=1; if(H5P_insert(xfer_plist,H5AC_BLOCK_BEFORE_META_WRITE_NAME,H5AC_BLOCK_BEFORE_META_WRITE_SIZE,&block_before_meta_write,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't insert metadata cache dxpl property") /* Insert 'library internal' property */ if(H5P_insert(xfer_plist,H5AC_LIBRARY_INTERNAL_NAME,H5AC_LIBRARY_INTERNAL_SIZE,&library_internal,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't insert metadata cache dxpl property") /* Set the transfer mode */ xfer_mode=H5FD_MPIO_COLLECTIVE; if (H5P_set(xfer_plist,H5D_XFER_IO_XFER_MODE_NAME,&xfer_mode)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value") /* Get an ID for the non-blocking, collective H5AC dxpl */ if ((H5AC_noblock_dxpl_id=H5P_create_id(xfer_pclass)) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, FAIL, "unable to register property list") /* Get the property list object */ if (NULL == (xfer_plist = H5I_object(H5AC_noblock_dxpl_id))) HGOTO_ERROR(H5E_CACHE, H5E_BADATOM, FAIL, "can't get new property list object") /* Insert 'block before metadata write' property */ block_before_meta_write=0; if(H5P_insert(xfer_plist,H5AC_BLOCK_BEFORE_META_WRITE_NAME,H5AC_BLOCK_BEFORE_META_WRITE_SIZE,&block_before_meta_write,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't insert metadata cache dxpl property") /* Insert 'library internal' property */ if(H5P_insert(xfer_plist,H5AC_LIBRARY_INTERNAL_NAME,H5AC_LIBRARY_INTERNAL_SIZE,&library_internal,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't insert metadata cache dxpl property") /* Set the transfer mode */ xfer_mode=H5FD_MPIO_COLLECTIVE; if (H5P_set(xfer_plist,H5D_XFER_IO_XFER_MODE_NAME,&xfer_mode)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value") /* Get an ID for the non-blocking, independent H5AC dxpl */ if ((H5AC_ind_dxpl_id=H5P_create_id(xfer_pclass)) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, FAIL, "unable to register property list") /* Get the property list object */ if (NULL == (xfer_plist = H5I_object(H5AC_ind_dxpl_id))) HGOTO_ERROR(H5E_CACHE, H5E_BADATOM, FAIL, "can't get new property list object") /* Insert 'block before metadata write' property */ block_before_meta_write=0; if(H5P_insert(xfer_plist,H5AC_BLOCK_BEFORE_META_WRITE_NAME,H5AC_BLOCK_BEFORE_META_WRITE_SIZE,&block_before_meta_write,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't insert metadata cache dxpl property") /* Insert 'library internal' property */ if(H5P_insert(xfer_plist,H5AC_LIBRARY_INTERNAL_NAME,H5AC_LIBRARY_INTERNAL_SIZE,&library_internal,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't insert metadata cache dxpl property") /* Set the transfer mode */ xfer_mode=H5FD_MPIO_INDEPENDENT; if (H5P_set(xfer_plist,H5D_XFER_IO_XFER_MODE_NAME,&xfer_mode)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value") done: FUNC_LEAVE_NOAPI(ret_value) #else /* H5_HAVE_PARALLEL */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5AC_init_interface) /* Sanity check */ assert(H5P_LST_DATASET_XFER_g!=(-1)); H5AC_dxpl_id=H5P_DATASET_XFER_DEFAULT; H5AC_noblock_dxpl_id=H5P_DATASET_XFER_DEFAULT; H5AC_ind_dxpl_id=H5P_DATASET_XFER_DEFAULT; FUNC_LEAVE_NOAPI(SUCCEED) #endif /* H5_HAVE_PARALLEL */ } /* end H5AC_init_interface() */ /*------------------------------------------------------------------------- * Function: H5AC_term_interface * * Purpose: Terminate this interface. * * Return: Success: Positive if anything was done that might * affect other interfaces; zero otherwise. * * Failure: Negative. * * Programmer: Quincey Koziol * Thursday, July 18, 2002 * * Modifications: * *------------------------------------------------------------------------- */ int H5AC_term_interface(void) { int n=0; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5AC_term_interface) if (H5_interface_initialize_g) { #ifdef H5_HAVE_PARALLEL if(H5AC_dxpl_id>0 || H5AC_noblock_dxpl_id>0 || H5AC_ind_dxpl_id>0) { /* Indicate more work to do */ n = 1; /* H5I */ /* Close H5AC dxpl */ if (H5I_dec_ref(H5AC_dxpl_id) < 0 || H5I_dec_ref(H5AC_noblock_dxpl_id) < 0 || H5I_dec_ref(H5AC_ind_dxpl_id) < 0) H5E_clear(); /*ignore error*/ else { /* Reset static IDs */ H5AC_dxpl_id=(-1); H5AC_noblock_dxpl_id=(-1); H5AC_ind_dxpl_id=(-1); /* Reset interface initialization flag */ H5_interface_initialize_g = 0; } /* end else */ } /* end if */ else #else /* H5_HAVE_PARALLEL */ /* Reset static IDs */ H5AC_dxpl_id=(-1); H5AC_noblock_dxpl_id=(-1); H5AC_ind_dxpl_id=(-1); #endif /* H5_HAVE_PARALLEL */ /* Reset interface initialization flag */ H5_interface_initialize_g = 0; } /* end if */ FUNC_LEAVE_NOAPI(n) } /* end H5AC_term_interface() */ /*------------------------------------------------------------------------- * Function: H5AC_create * * Purpose: Initialize the cache just after a file is opened. The * SIZE_HINT is the number of cache slots desired. If you * pass an invalid value then H5AC_NSLOTS is used. You can * turn off caching by using 1 for the SIZE_HINT value. * * Return: Success: Number of slots actually used. * * Failure: Negative * * Programmer: Robb Matzke * matzke@llnl.gov * Jul 9 1997 * * Modifications: * * Complete re-design and re-write to support the re-designed * metadata cache. * * At present, the size_hint is ignored, and the * max_cache_size and min_clean_size fields are hard * coded. This should be fixed, but a parameter * list change will be required, so I will leave it * for now. * * Since no-one seems to care, the function now returns * one on success. * JRM - 4/28/04 * * Reworked the function again after abstracting its guts to * the similar function in H5C.c. The function is now a * wrapper for H5C_create(). * JRM - 6/4/04 *------------------------------------------------------------------------- */ static const char * H5AC_entry_type_names[H5AC_NTYPES] = { "B-tree nodes", "symbol table nodes", "local heaps", "global heaps", "object headers" }; herr_t H5AC_create(const H5F_t *f, int UNUSED size_hint) { int ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5AC_create, FAIL) HDassert(f); HDassert(NULL == f->shared->cache); /* this is test code that should be removed when we start passing * in proper size hints. * -- JRM */ f->shared->cache = H5C_create(H5C__DEFAULT_MAX_CACHE_SIZE, H5C__DEFAULT_MIN_CLEAN_SIZE, (H5AC_NTYPES - 1), (const char **)H5AC_entry_type_names, H5AC_check_if_write_permitted); if ( NULL == f->shared->cache ) { HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") } done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_create() */ /*------------------------------------------------------------------------- * Function: H5AC_dest * * Purpose: Flushes all data to disk and destroys the cache. * This function fails if any object are protected since the * resulting file might not be consistent. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Jul 9 1997 * * Modifications: * * Complete re-design and re-write to support the re-designed * metadata cache. * JRM - 5/12/04 * * Abstracted the guts of the function to H5C_dest() in H5C.c, * and then re-wrote the function as a wrapper for H5C_dest(). * * JRM - 6/7/04 * *------------------------------------------------------------------------- */ herr_t H5AC_dest(H5F_t *f, hid_t dxpl_id) { H5AC_t *cache = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5AC_dest, FAIL) assert(f); assert(f->shared->cache); cache = f->shared->cache; f->shared->cache = NULL; if ( H5C_dest(f, dxpl_id, H5AC_noblock_dxpl_id, cache) < 0 ) { HGOTO_ERROR(H5E_CACHE, H5E_CANTFREE, FAIL, "can't destroy cache") } done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_dest() */ /*------------------------------------------------------------------------- * Function: H5AC_flush * * Purpose: Flush (and possibly destroy) the metadata cache associated * with the specified file. * * This is a re-write of an earlier version of the function * which was reputedly capable of flushing (and destroying * if requested) individual entries, individual entries if * they match the supplied type, all entries of a given type, * as well as all entries in the cache. * * As only this last capability is actually used at present, * I have not implemented the other capabilities in this * version of the function. * * The type and addr parameters are retained to avoid source * code changed, but values other than NULL and HADDR_UNDEF * respectively are errors. If all goes well, they should * be removed, and the function renamed to something more * descriptive -- perhaps H5AC_flush_cache. * * If the cache contains protected entries, the function will * fail, as protected entries cannot be flushed. However * all unprotected entries should be flushed before the * function returns failure. * * For historical purposes, the original version of the * purpose section is reproduced below: * * ============ Original Version of "Purpose:" ============ * * Flushes (and destroys if DESTROY is non-zero) the specified * entry from the cache. If the entry TYPE is CACHE_FREE and * ADDR is HADDR_UNDEF then all types of entries are * flushed. If TYPE is CACHE_FREE and ADDR is defined then * whatever is cached at ADDR is flushed. Otherwise the thing * at ADDR is flushed if it is the correct type. * * If there are protected objects they will not be flushed. * However, an attempt will be made to flush all non-protected * items before this function returns failure. * * Return: Non-negative on success/Negative on failure if there was a * request to flush all items and something was protected. * * Programmer: Robb Matzke * matzke@llnl.gov * Jul 9 1997 * * Modifications: * Robb Matzke, 1999-07-27 * The ADDR argument is passed by value. * * Complete re-write. See above for details. -- JRM 5/11/04 * * Abstracted the guts of the function to H5C_dest() in H5C.c, * and then re-wrote the function as a wrapper for H5C_dest(). * * JRM - 6/7/04 * *------------------------------------------------------------------------- */ herr_t H5AC_flush(H5F_t *f, hid_t dxpl_id, unsigned flags) { herr_t status; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5AC_flush, FAIL) HDassert(f); HDassert(f->shared->cache); status = H5C_flush_cache(f, dxpl_id, H5AC_noblock_dxpl_id, f->shared->cache, flags); if ( status < 0 ) { HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush entry.") } done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_flush() */ /*------------------------------------------------------------------------- * Function: H5AC_set * * Purpose: Adds the specified thing to the cache. The thing need not * exist on disk yet, but it must have an address and disk * space reserved. * * If H5AC_DEBUG is defined then this function checks * that the object being inserted isn't a protected object. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Jul 9 1997 * * Modifications: * Robb Matzke, 1999-07-27 * The ADDR argument is passed by value. * * Bill Wendling, 2003-09-16 * Added automatic "flush" if the FPHDF5 driver is being * used. This'll write the metadata to the SAP where other, * lesser processes can grab it. * * JRM - 5/13/04 * Complete re-write for the new metadata cache. The new * code is functionally almost identical to the old, although * the sanity check for a protected entry is now an assert * at the beginning of the function. * * JRM - 6/7/04 * Abstracted the guts of the function to H5C_insert_entry() * in H5C.c, and then re-wrote the function as a wrapper for * H5C_insert_entry(). * *------------------------------------------------------------------------- */ herr_t H5AC_set(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, void *thing) { herr_t result; H5AC_info_t *info; H5AC_t *cache; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5AC_set, FAIL) HDassert(f); HDassert(f->shared->cache); HDassert(type); HDassert(type->flush); HDassert(type->size); HDassert(H5F_addr_defined(addr)); HDassert(thing); /* Get local copy of this information */ cache = f->shared->cache; info = (H5AC_info_t *)thing; info->addr = addr; info->type = type; info->is_protected = FALSE; result = H5C_insert_entry(f, dxpl_id, H5AC_noblock_dxpl_id, cache, type, addr, thing); if ( result < 0 ) { HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, "H5C_insert_entry() failed") } done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_set() */ /*------------------------------------------------------------------------- * Function: H5AC_rename * * Purpose: Use this function to notify the cache that an object's * file address changed. * * If H5AC_DEBUG is defined then this function checks * that the old and new addresses don't correspond to the * address of a protected object. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Jul 9 1997 * * Modifications: * Robb Matzke, 1999-07-27 * The OLD_ADDR and NEW_ADDR arguments are passed by value. * * JRM 5/17/04 * Complete rewrite for the new meta-data cache. * * JRM - 6/7/04 * Abstracted the guts of the function to H5C_rename_entry() * in H5C.c, and then re-wrote the function as a wrapper for * H5C_rename_entry(). * *------------------------------------------------------------------------- */ herr_t H5AC_rename(H5F_t *f, const H5AC_class_t *type, haddr_t old_addr, haddr_t new_addr) { herr_t result; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5AC_rename, FAIL) HDassert(f); HDassert(f->shared->cache); HDassert(type); HDassert(H5F_addr_defined(old_addr)); HDassert(H5F_addr_defined(new_addr)); HDassert(H5F_addr_ne(old_addr, new_addr)); result = H5C_rename_entry(f->shared->cache, type, old_addr, new_addr); if ( result < 0 ) { HGOTO_ERROR(H5E_CACHE, H5E_CANTRENAME, FAIL, \ "H5C_rename_entry() failed.") } done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_rename() */ /*------------------------------------------------------------------------- * Function: H5AC_protect * * Purpose: If the target entry is not in the cache, load it. If * necessary, attempt to evict one or more entries to keep * the cache within its maximum size. * * Mark the target entry as protected, and return its address * to the caller. The caller must call H5AC_unprotect() when * finished with the entry. * * While it is protected, the entry may not be either evicted * or flushed -- nor may it be accessed by another call to * H5AC_protect. Any attempt to do so will result in a failure. * * This comment is a re-write of the original Purpose: section. * For historical interest, the original version is reproduced * below: * * Original Purpose section: * * Similar to H5AC_find() except the object is removed from * the cache and given to the caller, preventing other parts * of the program from modifying the protected object or * preempting it from the cache. * * The caller must call H5AC_unprotect() when finished with * the pointer. * * If H5AC_DEBUG is defined then we check that the * requested object isn't already protected. * * Return: Success: Ptr to the object. * * Failure: NULL * * Programmer: Robb Matzke * matzke@llnl.gov * Sep 2 1997 * * Modifications: * Robb Matzke, 1999-07-27 * The ADDR argument is passed by value. * * Bill Wendling, 2003-09-10 * Added parameter to indicate whether this is a READ or * WRITE type of protect. * * JRM -- 5/17/04 * Complete re-write for the new client cache. See revised * Purpose section above. * * JRM - 6/7/04 * Abstracted the guts of the function to H5C_protect() * in H5C.c, and then re-wrote the function as a wrapper for * H5C_protect(). * *------------------------------------------------------------------------- */ void * H5AC_protect(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, const void *udata1, void *udata2, H5AC_protect_t UNUSED rw) { void * thing = NULL; void * ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5AC_protect, NULL) /* check args */ HDassert(f); HDassert(f->shared->cache); HDassert(type); HDassert(type->flush); HDassert(type->load); HDassert(H5F_addr_defined(addr)); thing = H5C_protect(f, dxpl_id, H5AC_noblock_dxpl_id, f->shared->cache, type, addr, udata1, udata2); if ( thing == NULL ) { HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, NULL, "H5C_protect() failed.") } /* Set return value */ ret_value = thing; done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_protect() */ /*------------------------------------------------------------------------- * Function: H5AC_unprotect * * Purpose: Undo an H5AC_protect() call -- specifically, mark the * entry as unprotected, remove it from the protected list, * and give it back to the replacement policy. * * The TYPE and ADDR arguments must be the same as those in * the corresponding call to H5AC_protect() and the THING * argument must be the value returned by that call to * H5AC_protect(). * * If the deleted flag is TRUE, simply remove the target entry * from the cache, clear it, and free it without writing it to * disk. * * This verion of the function is a complete re-write to * use the new metadata cache. While there isn't all that * much difference between the old and new Purpose sections, * the original version is given below. * * Original purpose section: * * This function should be called to undo the effect of * H5AC_protect(). The TYPE and ADDR arguments should be the * same as the corresponding call to H5AC_protect() and the * THING argument should be the value returned by H5AC_protect(). * If the DELETED flag is set, then this object has been deleted * from the file and should not be returned to the cache. * * If H5AC_DEBUG is defined then this function fails * if the TYPE and ADDR arguments are not what was used when the * object was protected or if the object was never protected. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Sep 2 1997 * * Modifications: * Robb Matzke, 1999-07-27 * The ADDR argument is passed by value. * * Quincey Koziol, 2003-03-19 * Added "deleted" argument * * Bill Wendling, 2003-09-18 * If this is an FPHDF5 driver and the data is dirty, * perform a "flush" that writes the data to the SAP. * * John Mainzer 5/19/04 * Complete re-write for the new metadata cache. * * JRM - 6/7/04 * Abstracted the guts of the function to H5C_unprotect() * in H5C.c, and then re-wrote the function as a wrapper for * H5C_unprotect(). * *------------------------------------------------------------------------- */ herr_t H5AC_unprotect(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, void *thing, hbool_t deleted) { herr_t result; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5AC_unprotect, FAIL) HDassert(f); HDassert(f->shared->cache); HDassert(type); HDassert(type->clear); HDassert(type->flush); HDassert(H5F_addr_defined(addr)); HDassert(thing); HDassert( ((H5AC_info_t *)thing)->addr == addr ); HDassert( ((H5AC_info_t *)thing)->type == type ); result = H5C_unprotect(f, dxpl_id, H5AC_noblock_dxpl_id, f->shared->cache, type, addr, thing, deleted); if ( result < 0 ) { HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, \ "H5C_unprotect() failed.") } done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_unprotect() */ /*------------------------------------------------------------------------- * Function: H5AC_stats * * Purpose: Prints statistics about the cache. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Thursday, October 30, 1997 * * Modifications: * John Mainzer 5/19/04 * Re-write to support the new metadata cache. * * JRM - 6/7/04 * Abstracted the guts of the function to H5C_stats() * in H5C.c, and then re-wrote the function as a wrapper for * H5C_stats(). * *------------------------------------------------------------------------- */ herr_t H5AC_stats(const H5F_t *f) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5AC_stats, FAIL) HDassert(f); HDassert(f->shared->cache); (void)H5C_stats(f->shared->cache, f->name, FALSE); /* at present, this can't fail */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_stats() */ /*************************************************************************/ /**************************** Private Functions: *************************/ /*************************************************************************/ /*------------------------------------------------------------------------- * * Function: H5AC_check_if_write_permitted * * Purpose: Determine if a write is permitted under the current * circumstances, and set *write_permitted_ptr accordingly. * As a general rule it is, but when we are running in parallel * mode with collective I/O, we must ensure that a read cannot * cause a write. * * In the event of failure, the value of *write_permitted_ptr * is undefined. * * Return: Non-negative on success/Negative on failure. * * Programmer: John Mainzer, 5/15/04 * * Modifications: * *------------------------------------------------------------------------- */ #ifdef H5_HAVE_PARALLEL static herr_t H5AC_check_if_write_permitted(const H5F_t *f, hid_t dxpl_id, hbool_t * write_permitted_ptr) #else /* H5_HAVE_PARALLEL */ static herr_t H5AC_check_if_write_permitted(const H5F_t UNUSED * f, hid_t UNUSED dxpl_id, hbool_t * write_permitted_ptr) #endif /* H5_HAVE_PARALLEL */ { hbool_t write_permitted = TRUE; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5AC_check_if_write_permitted, FAIL) #ifdef H5_HAVE_PARALLEL if ( IS_H5FD_MPI(f) ) { H5P_genplist_t *dxpl; /* Dataset transfer property list */ H5FD_mpio_xfer_t xfer_mode; /* I/O transfer mode property value */ /* Get the dataset transfer property list */ if ( NULL == (dxpl = H5I_object(dxpl_id)) ) { HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, \ "not a dataset creation property list") } /* Get the transfer mode property */ if( H5P_get(dxpl, H5D_XFER_IO_XFER_MODE_NAME, &xfer_mode) < 0 ) { HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, \ "can't retrieve xfer mode") } if ( xfer_mode == H5FD_MPIO_INDEPENDENT ) { write_permitted = FALSE; } else { HDassert(xfer_mode == H5FD_MPIO_COLLECTIVE ); } } #endif /* H5_HAVE_PARALLEL */ *write_permitted_ptr = write_permitted; done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_check_if_write_permitted() */ xdmf-3.0+git20160803/Utilities/hdf5/H5.c0000640000175000017500000030276413003006557017327 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #define H5I_PACKAGE /* suppress error about including H5Ipkg */ #include "H5private.h" /* Generic Functions */ #include "H5Bprivate.h" /* B-link trees */ #include "H5Dprivate.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5FDprivate.h" /* File drivers */ #include "H5FLprivate.h" /* Free lists */ #include "H5Ipkg.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Pprivate.h" /* Property lists */ #include "H5Rpublic.h" /* References */ #include "H5Sprivate.h" /* Dataspaces */ #include "H5Tprivate.h" /* Datatypes */ #include "H5Zprivate.h" /* I/O pipeline filters */ #ifdef H5_HAVE_PARALLEL /* datatypes of predefined drivers needed by H5_trace() */ #include "H5FDmpio.h" #endif /* H5_HAVE_PARALLEL */ /* we need this for the struct rusage declaration */ #if defined(H5_HAVE_GETRUSAGE) && defined(H5_HAVE_SYS_RESOURCE_H) # include #endif /* statically initialize block for pthread_once call used in initializing */ /* the first global mutex */ #ifdef H5_HAVE_THREADSAFE H5_api_t H5_g; #else hbool_t H5_libinit_g = FALSE; /* Library hasn't been initialized */ #endif #ifdef H5_HAVE_MPE hbool_t H5_MPEinit_g = FALSE; /* MPE Library hasn't been initialized */ #endif char H5_lib_vers_info_g[] = H5_VERS_INFO; static hbool_t H5_dont_atexit_g = FALSE; H5_debug_t H5_debug_g; /*debugging info */ static void H5_debug_mask(const char*); /*-------------------------------------------------------------------------- * NAME * H5_init_library -- Initialize library-global information * USAGE * herr_t H5_init_library() * * RETURNS * Non-negative on success/Negative on failure * * DESCRIPTION * Initializes any library-global data or routines. * *-------------------------------------------------------------------------- */ herr_t H5_init_library(void) { herr_t ret_value=SUCCEED; FUNC_ENTER_NOAPI(H5_init_library, FAIL) /* * Make sure the package information is updated. */ HDmemset(&H5_debug_g, 0, sizeof H5_debug_g); H5_debug_g.pkg[H5_PKG_A].name = "a"; H5_debug_g.pkg[H5_PKG_AC].name = "ac"; H5_debug_g.pkg[H5_PKG_B].name = "b"; H5_debug_g.pkg[H5_PKG_D].name = "d"; H5_debug_g.pkg[H5_PKG_E].name = "e"; H5_debug_g.pkg[H5_PKG_F].name = "f"; H5_debug_g.pkg[H5_PKG_G].name = "g"; H5_debug_g.pkg[H5_PKG_HG].name = "hg"; H5_debug_g.pkg[H5_PKG_HL].name = "hl"; H5_debug_g.pkg[H5_PKG_I].name = "i"; H5_debug_g.pkg[H5_PKG_MF].name = "mf"; H5_debug_g.pkg[H5_PKG_MM].name = "mm"; H5_debug_g.pkg[H5_PKG_O].name = "o"; H5_debug_g.pkg[H5_PKG_P].name = "p"; H5_debug_g.pkg[H5_PKG_S].name = "s"; H5_debug_g.pkg[H5_PKG_T].name = "t"; H5_debug_g.pkg[H5_PKG_V].name = "v"; H5_debug_g.pkg[H5_PKG_Z].name = "z"; #ifdef H5_HAVE_MPE /* Initialize MPE instrumentation library. May need to move this * up earlier if any of the above initialization involves using * the instrumentation code. */ if (!H5_MPEinit_g) { int mpe_code; int mpi_initialized; MPI_Initialized(&mpi_initialized); if (mpi_initialized){ mpe_code = MPE_Init_log(); assert(mpe_code >=0); H5_MPEinit_g = TRUE; } } #endif /* * Install atexit() library cleanup routine unless the H5dont_atexit() * has been called. Once we add something to the atexit() list it stays * there permanently, so we set H5_dont_atexit_g after we add it to prevent * adding it again later if the library is cosed and reopened. */ if (!H5_dont_atexit_g) { (void)HDatexit(H5_term_library); H5_dont_atexit_g = TRUE; } /* * Initialize interfaces that might not be able to initialize themselves * soon enough. The file & dataset interfaces must be initialized because * calling H5P_create() might require the file/dataset property classes to be * initialized. The property interface must be initialized before the file * & dataset interfaces though, in order to provide them with the proper * property classes. */ if (H5P_init()<0) HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize property list interface") if (H5F_init()<0) HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize file interface") if (H5T_init()<0) HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize datatype interface") if (H5D_init()<0) HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize dataset interface") if (H5AC_init()<0) HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize metadata caching interface") /* Debugging? */ H5_debug_mask("-all"); H5_debug_mask(HDgetenv("HDF5_DEBUG")); done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5_term_library * * Purpose: Terminate interfaces in a well-defined order due to * dependencies among the interfaces, then terminate * library-specific data. * * Return: void * * Programmer: Robb Matzke * Friday, November 20, 1998 * * Modifications: * *------------------------------------------------------------------------- */ void H5_term_library(void) { int pending, ntries=0, n; unsigned at=0; char loop[1024]; H5E_auto_t func; #ifdef H5_HAVE_THREADSAFE /* explicit locking of the API */ H5_FIRST_THREAD_INIT H5_API_LOCK #endif /* Don't do anything if the library is already closed */ if (!(H5_INIT_GLOBAL)) goto done; /* Check if we should display error output */ (void)H5Eget_auto(&func,NULL); /* * Terminate each interface. The termination functions return a positive * value if they do something that might affect some other interface in a * way that would necessitate some cleanup work in the other interface. */ #define DOWN(F) \ (((n=H5##F##_term_interface()) && at+80 && at+5=0); } H5_MPEinit_g = FALSE; /* turn it off no matter what */ } #endif /* Mark library as closed */ H5_INIT_GLOBAL = FALSE; done: #ifdef H5_HAVE_THREADSAFE H5_API_UNLOCK #endif return; } /*------------------------------------------------------------------------- * Function: H5dont_atexit * * Purpose: Indicates that the library is not to clean up after itself * when the application exits by calling exit() or returning * from main(). This function must be called before any other * HDF5 function or constant is used or it will have no effect. * * If this function is used then certain memory buffers will not * be de-allocated nor will open files be flushed automatically. * The application may still call H5close() explicitly to * accomplish these things. * * Return: Success: non-negative * * Failure: negative if this function is called more than * once or if it is called too late. * * Programmer: Robb Matzke * Friday, November 20, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5dont_atexit(void) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT(H5dont_atexit) H5TRACE0("e",""); if (H5_dont_atexit_g) ret_value=FAIL; else H5_dont_atexit_g = TRUE; FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5garbage_collect * * Purpose: Walks through all the garbage collection routines for the * library, which are supposed to free any unused memory they have * allocated. * * These should probably be registered dynamicly in a linked list of * functions to call, but there aren't that many right now, so we * hard-wire them... * * Return: Success: non-negative * * Failure: negative * * Programmer: Quincey Koziol * Saturday, March 11, 2000 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5garbage_collect(void) { herr_t ret_value = SUCCEED; FUNC_ENTER_API(H5garbage_collect, FAIL) H5TRACE0("e",""); /* Call the garbage collection routines in the library */ if(H5FL_garbage_coll()<0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "can't garbage collect objects") done: FUNC_LEAVE_API(ret_value) } /* end H5garbage_collect() */ /*------------------------------------------------------------------------- * Function: H5set_free_list_limits * * Purpose: Sets limits on the different kinds of free lists. Setting a value * of -1 for a limit means no limit of that type. These limits are global * for the entire library. Each "global" limit only applies to free lists * of that type, so if an application sets a limit of 1 MB on each of the * global lists, up to 3 MB of total storage might be allocated (1MB on * each of regular, array and block type lists). * * Parameters: * int reg_global_lim; IN: The limit on all "regular" free list memory used * int reg_list_lim; IN: The limit on memory used in each "regular" free list * int arr_global_lim; IN: The limit on all "array" free list memory used * int arr_list_lim; IN: The limit on memory used in each "array" free list * int blk_global_lim; IN: The limit on all "block" free list memory used * int blk_list_lim; IN: The limit on memory used in each "block" free list * * Return: Success: non-negative * * Failure: negative * * Programmer: Quincey Koziol * Wednesday, August 2, 2000 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5set_free_list_limits(int reg_global_lim, int reg_list_lim, int arr_global_lim, int arr_list_lim, int blk_global_lim, int blk_list_lim) { herr_t ret_value = SUCCEED; FUNC_ENTER_API(H5set_free_list_limits, FAIL) H5TRACE6("e","IsIsIsIsIsIs",reg_global_lim,reg_list_lim,arr_global_lim, arr_list_lim,blk_global_lim,blk_list_lim); /* Call the free list function to actually set the limits */ if(H5FL_set_free_list_limits(reg_global_lim, reg_list_lim, arr_global_lim, arr_list_lim, blk_global_lim, blk_list_lim)<0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "can't set garbage collection limits") done: FUNC_LEAVE_API(ret_value) } /* end H5set_free_list_limits() */ /*------------------------------------------------------------------------- * Function: H5_debug_mask * * Purpose: Set runtime debugging flags according to the string S. The * string should contain file numbers and package names * separated by other characters. A file number applies to all * following package names up to the next file number. The * initial file number is `2' (the standard error stream). Each * package name can be preceded by a `+' or `-' to add or remove * the package from the debugging list (`+' is the default). The * special name `all' means all packages. * * The name `trace' indicates that API tracing is to be turned * on or off. * * Return: void * * Programmer: Robb Matzke * Wednesday, August 19, 1998 * * Modifications: * Robb Matzke, 2002-08-08 * Accepts the `ttop' word. If enabled then show only the * top level API calls, otherwise show all API calls. Also * turns on tracing as if the `trace' word was present. *------------------------------------------------------------------------- */ static void H5_debug_mask(const char *s) { FILE *stream = stderr; char pkg_name[32], *rest; size_t i; int clear; while (s && *s) { if (HDisalpha(*s) || '-'==*s || '+'==*s) { /* Enable or Disable debugging? */ if ('-'==*s) { clear = TRUE; s++; } else if ('+'==*s) { clear = FALSE; s++; } else { clear = FALSE; } /* Get the name */ for (i=0; HDisalpha(*s); i++, s++) if (i=(size_t)H5_NPKGS) fprintf(stderr, "HDF5_DEBUG: ignored %s\n", pkg_name); } } else if (HDisdigit(*s)) { int fd = (int)HDstrtol (s, &rest, 0); if ((stream=HDfdopen(fd, "w"))!=NULL) (void)HDsetvbuf (stream, NULL, _IOLBF, 0); s = rest; } else { s++; } } } /*------------------------------------------------------------------------- * Function: H5get_libversion * * Purpose: Returns the library version numbers through arguments. MAJNUM * will be the major revision number of the library, MINNUM the * minor revision number, and RELNUM the release revision number. * * Note: When printing an HDF5 version number it should be printed as * * printf("%u.%u.%u", maj, min, rel) or * printf("version %u.%u release %u", maj, min, rel) * * Return: Non-negative on success/Negative on failure * * Programmer: Unknown * * Modifications: * Robb Matzke, 4 Mar 1998 * Now use "normal" data types for the interface. Any of the arguments * may be null pointers * *------------------------------------------------------------------------- */ herr_t H5get_libversion(unsigned *majnum, unsigned *minnum, unsigned *relnum) { herr_t ret_value = SUCCEED; FUNC_ENTER_API(H5get_libversion, FAIL) H5TRACE3("e","*Iu*Iu*Iu",majnum,minnum,relnum); /* Set the version information */ if (majnum) *majnum = H5_VERS_MAJOR; if (minnum) *minnum = H5_VERS_MINOR; if (relnum) *relnum = H5_VERS_RELEASE; done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5check_version * * Purpose: Verifies that the arguments match the version numbers * compiled into the library. This function is intended to be * called from user to verify that the versions of header files * compiled into the application match the version of the hdf5 * library. * * Return: Success: SUCCEED * * Failure: abort() * * Programmer: Robb Matzke * Tuesday, April 21, 1998 * * Modifications: * Albert Cheng, May 12, 2001 * Added verification of H5_VERS_INFO. * *------------------------------------------------------------------------- */ herr_t H5check_version(unsigned majnum, unsigned minnum, unsigned relnum) { char lib_str[256]; char substr[] = H5_VERS_SUBRELEASE; static int checked = 0; /* If we've already checked the version info */ static int disable_version_check = 0; /* Set if the version check should be disabled */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT(H5check_version) H5TRACE3("e","IuIuIu",majnum,minnum,relnum); /* Don't check again, if we already have */ if (checked) HGOTO_DONE(SUCCEED) { const char *s; /* Environment string for disabling version check */ /* Allow different versions of the header files and library? */ s = HDgetenv ("HDF5_DISABLE_VERSION_CHECK"); if (s && HDisdigit(*s)) disable_version_check = (int)HDstrtol (s, NULL, 0); } if (H5_VERS_MAJOR!=majnum || H5_VERS_MINOR!=minnum || H5_VERS_RELEASE!=relnum) { switch (disable_version_check) { case 0: HDfputs ("Warning! The HDF5 header files included by this application " "do not match the\nversion used by the HDF5 library to which " "this application is linked. Data\ncorruption or " "segmentation faults may occur if the application " "is\nallowed to continue. You can, at your own risk, " "disable this check by setting\nthe environment variable " "'HDF5_DISABLE_VERSION_CHECK' to a value of '1'.\n" "Setting it to 2 will suppress the warning totally.\n", stderr); /* Mention the versions we are referring to */ HDfprintf (stderr, "Headers are %u.%u.%u, library is %u.%u.%u\n", majnum, minnum, relnum, (unsigned)H5_VERS_MAJOR, (unsigned)H5_VERS_MINOR, (unsigned)H5_VERS_RELEASE); /* Bail out now. */ HDfputs ("Bye...\n", stderr); HDabort (); case 2: /* continue silently */ break; default: /* continue with a warning */ HDfputs ("Warning! The HDF5 header files included by this application " "do not match the\nversion used by the HDF5 library to which " "this application is linked. Data\ncorruption or " "segmentation faults may occur if the application " "continues.\n'HDF5_DISABLE_VERSION_CHECK' " "environment variable set, application will\n" "continue.\n", stderr); /* Mention the versions we are referring to */ HDfprintf (stderr, "Headers are %u.%u.%u, library is %u.%u.%u\n", majnum, minnum, relnum, (unsigned)H5_VERS_MAJOR, (unsigned)H5_VERS_MINOR, (unsigned)H5_VERS_RELEASE); break; } /* end switch */ } /* end if */ /* Indicate that the version check has been performed */ checked = 1; if (!disable_version_check){ /* *verify if H5_VERS_INFO is consistent with the other version information. *Check only the first sizeof(lib_str) char. Assume the information *will fit within this size or enough significance. */ sprintf(lib_str, "HDF5 library version: %d.%d.%d", H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE); if (*substr){ HDstrcat(lib_str, "-"); HDstrncat(lib_str, substr, (sizeof(lib_str) - HDstrlen(lib_str)) - 1); } /* end if */ if (HDstrcmp(lib_str, H5_lib_vers_info_g)){ HDfputs ("Warning! Library version information error.\n" "The HDF5 library version information are not " "consistent in its source code.\nThis is NOT a fatal error " "but should be corrected. Setting the environment\n" "variable 'HDF5_DISABLE_VERSION_CHECK' to a value of 1 " "will suppress\nthis warning.\n", stderr); HDfprintf (stderr, "Library version information are:\n" "H5_VERS_MAJOR=%d, H5_VERS_MINOR=%d, H5_VERS_RELEASE=%d, " "H5_VERS_SUBRELEASE=%s,\nH5_VERS_INFO=%s\n", H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE, H5_VERS_SUBRELEASE, H5_VERS_INFO); } /* end if */ } done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5open * * Purpose: Initialize the library. This is normally called * automatically, but if you find that an HDF5 library function * is failing inexplicably, then try calling this function * first. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Tuesday, December 9, 1997 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5open(void) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API_NOCLEAR(H5open, FAIL) H5TRACE0("e",""); /* all work is done by FUNC_ENTER() */ done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5close * * Purpose: Terminate the library and release all resources. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Friday, January 30, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5close(void) { /* * Don't call FUNC_ENTER() since we don't want to initialize the whole * thing just to release it all right away. It is safe to call this * function for an uninitialized library. */ FUNC_ENTER_API_NOINIT(H5close) H5TRACE0("e",""); H5_term_library(); FUNC_LEAVE_API(SUCCEED) } #ifndef H5_HAVE_SNPRINTF /*------------------------------------------------------------------------- * Function: HDsnprintf * * Purpose: Writes output to the string BUF under control of the format * FMT that specifies how subsequent arguments are converted for * output. It is similar to sprintf except that SIZE specifies * the maximum number of characters to produce. The trailing * null character is counted towards this limit, so you should * allocated at least SIZE characters for the string BUF. * * Note: This function is for compatibility on systems that don't have * snprintf(3). It doesn't actually check for overflow like the * real snprintf() would. * * Return: Success: Number of characters stored, not including * the terminating null. If this value equals * SIZE then there was not enough space in BUF * for all the output. * * Failure: -1 * * Programmer: Robb Matzke * Tuesday, November 24, 1998 * * Modifications: * *------------------------------------------------------------------------- */ /* ARGSUSED */ int HDsnprintf(char *buf, size_t UNUSED size, const char *fmt, ...) { int n; va_list ap; va_start(ap, fmt); n = HDvsprintf(buf, fmt, ap); va_end(ap); return n; } #endif /* H5_HAVE_SNPRINTF */ #ifndef H5_HAVE_VSNPRINTF /*------------------------------------------------------------------------- * Function: HDvsnprintf * * Purpose: The same as HDsnprintf() except the variable arguments are * passed as a va_list. * * Note: This function is for compatibility on systems that don't have * vsnprintf(3). It doesn't actually check for overflow like the * real vsnprintf() would. * * Return: Success: Number of characters stored, not including * the terminating null. If this value equals * SIZE then there was not enough space in BUF * for all the output. * * Failure: -1 * * Programmer: Robb Matzke * Monday, April 26, 1999 * * Modifications: * *------------------------------------------------------------------------- */ /* ARGSUSED */ int HDvsnprintf(char *buf, size_t UNUSED size, const char *fmt, va_list ap) { return HDvsprintf(buf, fmt, ap); } #endif /* H5_HAVE_VSNPRINTF */ /*------------------------------------------------------------------------- * Function: HDfprintf * * Purpose: Prints the optional arguments under the control of the format * string FMT to the stream STREAM. This function takes the * same format as fprintf(3c) with a few added features: * * The conversion modifier `H' refers to the size of an * `hsize_t' or `hssize_t' type. For instance, "0x%018Hx" * prints an `hsize_t' value as a hex number right justified and * zero filled in an 18-character field. * * The conversion `a' refers to an `haddr_t' type. * * Return: Success: Number of characters printed * * Failure: -1 * * Programmer: Robb Matzke * Thursday, April 9, 1998 * * Modifications: * Robb Matzke, 1999-07-27 * The `%a' format refers to an argument of `haddr_t' type * instead of `haddr_t*' and the return value is correct. *------------------------------------------------------------------------- */ int HDfprintf(FILE *stream, const char *fmt, ...) { int n=0, nout = 0; int fwidth, prec; int zerofill; int leftjust; int plussign; int ldspace; int prefix; char modifier[8]; int conv; char *rest, format_templ[128]; const char *s; va_list ap; assert (stream); assert (fmt); va_start (ap, fmt); while (*fmt) { fwidth = prec = 0; zerofill = 0; leftjust = 0; plussign = 0; prefix = 0; ldspace = 0; modifier[0] = '\0'; if ('%'==fmt[0] && '%'==fmt[1]) { HDputc ('%', stream); fmt += 2; nout++; } else if ('%'==fmt[0]) { s = fmt + 1; /* Flags */ while (HDstrchr ("-+ #", *s)) { switch (*s) { case '-': leftjust = 1; break; case '+': plussign = 1; break; case ' ': ldspace = 1; break; case '#': prefix = 1; break; } /*lint !e744 Switch statement doesn't _need_ default */ s++; } /* Field width */ if (HDisdigit (*s)) { zerofill = ('0'==*s); fwidth = (int)HDstrtol (s, &rest, 10); s = rest; } else if ('*'==*s) { fwidth = va_arg (ap, int); if (fwidth<0) { leftjust = 1; fwidth = -fwidth; } s++; } /* Precision */ if ('.'==*s) { s++; if (HDisdigit (*s)) { prec = (int)HDstrtol (s, &rest, 10); s = rest; } else if ('*'==*s) { prec = va_arg (ap, int); s++; } if (prec<1) prec = 1; } /* Extra type modifiers */ if (HDstrchr ("ZHhlqLI", *s)) { switch (*s) { /*lint --e{506} Don't issue warnings about constant value booleans */ /*lint --e{774} Don't issue warnings boolean within 'if' always evaluates false/true */ case 'H': if (sizeof(hsize_t)0) sprintf (format_templ+HDstrlen(format_templ), "%d", fwidth); if (prec>0) sprintf (format_templ+HDstrlen(format_templ), ".%d", prec); if (*modifier) sprintf (format_templ+HDstrlen(format_templ), "%s", modifier); sprintf (format_templ+HDstrlen(format_templ), "%c", conv); /* Conversion */ switch (conv) { case 'd': case 'i': if (!HDstrcmp(modifier, "h")) { short x = (short)va_arg (ap, int); n = fprintf (stream, format_templ, x); } else if (!*modifier) { int x = va_arg (ap, int); n = fprintf (stream, format_templ, x); } else if (!HDstrcmp (modifier, "l")) { long x = va_arg (ap, long); n = fprintf (stream, format_templ, x); } else { int64_t x = va_arg(ap, int64_t); n = fprintf (stream, format_templ, x); } break; case 'o': case 'u': case 'x': case 'X': if (!HDstrcmp (modifier, "h")) { unsigned short x = (unsigned short)va_arg (ap, unsigned int); n = fprintf (stream, format_templ, x); } else if (!*modifier) { unsigned int x = va_arg (ap, unsigned int); /*lint !e732 Loss of sign not really occuring */ n = fprintf (stream, format_templ, x); } else if (!HDstrcmp (modifier, "l")) { unsigned long x = va_arg (ap, unsigned long); /*lint !e732 Loss of sign not really occuring */ n = fprintf (stream, format_templ, x); } else { uint64_t x = va_arg(ap, uint64_t); /*lint !e732 Loss of sign not really occuring */ n = fprintf (stream, format_templ, x); } break; case 'f': case 'e': case 'E': case 'g': case 'G': if (!HDstrcmp (modifier, "h")) { float x = (float) va_arg (ap, double); n = fprintf (stream, format_templ, x); } else if (!*modifier || !HDstrcmp (modifier, "l")) { double x = va_arg (ap, double); n = fprintf (stream, format_templ, x); } else { /* * Some compilers complain when `long double' and * `double' are the same thing. */ #if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE long double x = va_arg (ap, long double); n = fprintf (stream, format_templ, x); #else double x = va_arg (ap, double); n = fprintf (stream, format_templ, x); #endif } break; case 'a': { haddr_t x = va_arg (ap, haddr_t); /*lint !e732 Loss of sign not really occuring */ if (H5F_addr_defined(x)) { sprintf(format_templ, "%%%s%s%s%s%s", leftjust?"-":"", plussign?"+":"", ldspace?" ":"", prefix?"#":"", zerofill?"0":""); if (fwidth>0) sprintf(format_templ+HDstrlen(format_templ), "%d", fwidth); /*lint --e{506} Don't issue warnings about constant value booleans */ /*lint --e{774} Don't issue warnings boolean within 'if' always evaluates false/true */ if (sizeof(x)==H5_SIZEOF_INT) { HDstrcat(format_templ, "u"); } else if (sizeof(x)==H5_SIZEOF_LONG) { HDstrcat(format_templ, "lu"); } else if (sizeof(x)==H5_SIZEOF_LONG_LONG) { HDstrcat(format_templ, H5_PRINTF_LL_WIDTH); HDstrcat(format_templ, "u"); } n = fprintf(stream, format_templ, x); } else { HDstrcpy(format_templ, "%"); if (leftjust) HDstrcat(format_templ, "-"); if (fwidth) sprintf(format_templ+HDstrlen(format_templ), "%d", fwidth); HDstrcat(format_templ, "s"); fprintf(stream, format_templ, "UNDEF"); } } break; case 'c': { char x = (char)va_arg (ap, int); n = fprintf (stream, format_templ, x); } break; case 's': case 'p': { char *x = va_arg (ap, char*); /*lint !e64 Type mismatch not really occuring */ n = fprintf (stream, format_templ, x); } break; case 'n': format_templ[HDstrlen(format_templ)-1] = 'u'; n = fprintf (stream, format_templ, nout); break; default: HDfputs (format_templ, stream); n = (int)HDstrlen (format_templ); break; } nout += n; fmt = s; } else { HDputc (*fmt, stream); fmt++; nout++; } } va_end (ap); return nout; } /*------------------------------------------------------------------------- * Function: HDstrtoll * * Purpose: Converts the string S to an int64_t value according to the * given BASE, which must be between 2 and 36 inclusive, or be * the special value zero. * * The string must begin with an arbitrary amount of white space * (as determined by isspace(3c)) followed by a single optional * `+' or `-' sign. If BASE is zero or 16 the string may then * include a `0x' or `0X' prefix, and the number will be read in * base 16; otherwise a zero BASE is taken as 10 (decimal) * unless the next character is a `0', in which case it is taken * as 8 (octal). * * The remainder of the string is converted to an int64_t in the * obvious manner, stopping at the first character which is not * a valid digit in the given base. (In bases above 10, the * letter `A' in either upper or lower case represetns 10, `B' * represents 11, and so forth, with `Z' representing 35.) * * If REST is not null, the address of the first invalid * character in S is stored in *REST. If there were no digits * at all, the original value of S is stored in *REST. Thus, if * *S is not `\0' but **REST is `\0' on return the entire string * was valid. * * Return: Success: The result. * * Failure: If the input string does not contain any * digits then zero is returned and REST points * to the original value of S. If an overflow * or underflow occurs then the maximum or * minimum possible value is returned and the * global `errno' is set to ERANGE. If BASE is * incorrect then zero is returned. * * Programmer: Robb Matzke * Thursday, April 9, 1998 * * Modifications: * *------------------------------------------------------------------------- */ int64_t HDstrtoll(const char *s, const char **rest, int base) { int64_t sign=1, acc=0; hbool_t overflow = FALSE; errno = 0; if (!s || (base && (base<2 || base>36))) { if (rest) *rest = s; return 0; } /* Skip white space */ while (HDisspace (*s)) s++; /* Optional minus or plus sign */ if ('+'==*s) { s++; } else if ('-'==*s) { sign = -1; s++; } /* Zero base prefix */ if (0==base && '0'==*s && ('x'==s[1] || 'X'==s[1])) { base = 16; s += 2; } else if (0==base && '0'==*s) { base = 8; s++; } else if (0==base) { base = 10; } /* Digits */ while ((base<=10 && *s>='0' && *s<'0'+base) || (base>10 && ((*s>='0' && *s<='9') || (*s>='a' && *s<'a'+base-10) || (*s>='A' && *s<'A'+base-10)))) { if (!overflow) { int64_t digit = 0; if (*s>='0' && *s<='9') digit = *s - '0'; else if (*s>='a' && *s<='z') digit = (*s-'a')+10; else digit = (*s-'A')+10; if (acc*base+digit < acc) { overflow = TRUE; } else { acc = acc*base + digit; } } s++; } /* Overflow */ if (overflow) { if (sign>0) { acc = ((uint64_t)1<<(8*sizeof(int64_t)-1))-1; } else { acc = (uint64_t)1<<(8*sizeof(int64_t)-1); } errno = ERANGE; } /* Return values */ acc *= sign; if (rest) *rest = s; return acc; } /*------------------------------------------------------------------------- * Function: H5_timer_reset * * Purpose: Resets the timer struct to zero. Use this to reset a timer * that's being used as an accumulator for summing times. * * Return: void * * Programmer: Robb Matzke * Thursday, April 16, 1998 * * Modifications: * *------------------------------------------------------------------------- */ void H5_timer_reset (H5_timer_t *timer) { assert (timer); HDmemset (timer, 0, sizeof *timer); } /*------------------------------------------------------------------------- * Function: H5_timer_begin * * Purpose: Initialize a timer to time something. * * Return: void * * Programmer: Robb Matzke * Thursday, April 16, 1998 * * Modifications: * *------------------------------------------------------------------------- */ void H5_timer_begin (H5_timer_t *timer) { #ifdef H5_HAVE_GETRUSAGE struct rusage rusage; #endif #ifdef H5_HAVE_GETTIMEOFDAY struct timeval etime; #endif assert (timer); #ifdef H5_HAVE_GETRUSAGE HDgetrusage (RUSAGE_SELF, &rusage); timer->utime = (double)rusage.ru_utime.tv_sec + ((double)rusage.ru_utime.tv_usec/1e6); timer->stime = (double)rusage.ru_stime.tv_sec + ((double)rusage.ru_stime.tv_usec/1e6); #else timer->utime = 0.0; timer->stime = 0.0; #endif #ifdef H5_HAVE_GETTIMEOFDAY HDgettimeofday (&etime, NULL); timer->etime = (double)etime.tv_sec + ((double)etime.tv_usec/1e6); #else timer->etime = 0.0; #endif } /*------------------------------------------------------------------------- * Function: H5_timer_end * * Purpose: This function should be called at the end of a timed region. * The SUM is an optional pointer which will accumulate times. * TMS is the same struct that was passed to H5_timer_start(). * On return, TMS will contain total times for the timed region. * * Return: void * * Programmer: Robb Matzke * Thursday, April 16, 1998 * * Modifications: * *------------------------------------------------------------------------- */ void H5_timer_end (H5_timer_t *sum/*in,out*/, H5_timer_t *timer/*in,out*/) { H5_timer_t now; assert (timer); H5_timer_begin (&now); timer->utime = MAX(0.0, now.utime - timer->utime); timer->stime = MAX(0.0, now.stime - timer->stime); timer->etime = MAX(0.0, now.etime - timer->etime); if (sum) { sum->utime += timer->utime; sum->stime += timer->stime; sum->etime += timer->etime; } } /*------------------------------------------------------------------------- * Function: H5_bandwidth * * Purpose: Prints the bandwidth (bytes per second) in a field 10 * characters wide widh four digits of precision like this: * * NaN If <=0 seconds * 1234. TB/s * 123.4 TB/s * 12.34 GB/s * 1.234 MB/s * 4.000 kB/s * 1.000 B/s * 0.000 B/s If NBYTES==0 * 1.2345e-10 For bandwidth less than 1 * 6.7893e+94 For exceptionally large values * 6.678e+106 For really big values * * Return: void * * Programmer: Robb Matzke * Wednesday, August 5, 1998 * * Modifications: * *------------------------------------------------------------------------- */ void H5_bandwidth(char *buf/*out*/, double nbytes, double nseconds) { double bw; if (nseconds<=0.0) { HDstrcpy(buf, " NaN"); } else { bw = nbytes/nseconds; if (fabs(bw) < 0.0000000001) { /* That is == 0.0, but direct comparison between floats is bad */ HDstrcpy(buf, "0.000 B/s"); } else if (bw<1.0) { sprintf(buf, "%10.4e", bw); } else if (bw<1024.0) { sprintf(buf, "%05.4f", bw); HDstrcpy(buf+5, " B/s"); } else if (bw<1024.0*1024.0) { sprintf(buf, "%05.4f", bw/1024.0); HDstrcpy(buf+5, " kB/s"); } else if (bw<1024.0*1024.0*1024.0) { sprintf(buf, "%05.4f", bw/(1024.0*1024.0)); HDstrcpy(buf+5, " MB/s"); } else if (bw<1024.0*1024.0*1024.0*1024.0) { sprintf(buf, "%05.4f", bw/(1024.0*1024.0*1024.0)); HDstrcpy(buf+5, " GB/s"); } else if (bw<1024.0*1024.0*1024.0*1024.0*1024.0) { sprintf(buf, "%05.4f", bw/(1024.0*1024.0*1024.0*1024.0)); HDstrcpy(buf+5, " TB/s"); } else { sprintf(buf, "%10.4e", bw); if (HDstrlen(buf)>10) { sprintf(buf, "%10.3e", bw); } } } } /*------------------------------------------------------------------------- * Function: H5_trace * * Purpose: This function is called whenever an API function is called * and tracing is turned on. If RETURNING is non-zero then * the caller is about to return and RETURNING points to the * time for the corresponding function call event. Otherwise * we print the function name and the arguments. * * The TYPE argument is a string which gives the type of each of * the following argument pairs. Each type is zero or more * asterisks (one for each level of indirection, although some * types have one level of indirection already implied) followed * by either one letter (lower case) or two letters (first one * uppercase). * * The variable argument list consists of pairs of values. Each * pair is a string which is the formal argument name in the * calling function, followed by the argument value. The type * of the argument value is given by the TYPE string. * * Note: The TYPE string is meant to be terse and is generated by a * separate perl script. * * WARNING: DO NOT CALL ANY HDF5 FUNCTION THAT CALLS FUNC_ENTER(). DOING * SO MAY CAUSE H5_trace() TO BE INVOKED RECURSIVELY OR MAY * CAUSE LIBRARY INITIALIZATIONS THAT ARE NOT DESIRED. * * Return: void * * Programmer: Robb Matzke * Tuesday, June 16, 1998 * * Modifications: * Robb Matzke, 1999-08-02 * Added the `a' type letter for haddr_t arguments and `Mt' for * H5FD_mem_t arguments. * * Robb Matzke, 1999-10-25 * The `Ej' and `En' types are H5E_major_t and H5E_minor_t error * types. We only print the integer value here. * * Robb Matzke, 2002-08-08 * Better output for nested calls. Show only top-level calls * if so desired. Show event times if so desired. *------------------------------------------------------------------------- */ double H5_trace (const double *returning, const char *func, const char *type, ...) { va_list ap; char buf[64], *rest; const char *argname; int argno=0, ptr, asize_idx; hssize_t asize[16]; hssize_t i; void *vp = NULL; FILE *out = H5_debug_g.trace; H5_timer_t event_time; static H5_timer_t first_time = {0.0, 0.0, 0.0}; static int current_depth=0; static int last_call_depth=0; /* FUNC_ENTER() should not be called */ if (!out) return 0.0; /*tracing is off*/ va_start (ap, type); if (H5_debug_g.ttop) { if (returning) { if (current_depth>1) { --current_depth; return 0.0; } } else { if (current_depth>0) { /*do not update last_call_depth*/ current_depth++; return 0.0; } } } /* Get tim for event */ if (fabs(first_time.etime) < 0.0000000001) /* That is == 0.0, but direct comparison between floats is bad */ H5_timer_begin(&first_time); if (H5_debug_g.ttimes) { H5_timer_begin(&event_time); } else { HDmemset(&event_time, 0, sizeof event_time); } /* Print the first part of the line. This is the indication of the * nesting depth followed by the function name and either start of * argument list or start of return value. If this call is for a * function return and no other calls have been made to H5_trace() * since the one for the function call, then we're continuing * the same line. */ if (returning) { assert(current_depth>0); --current_depth; if (current_depth\n", out); if (H5_debug_g.ttimes) fprintf(out, "@%.6f ", event_time.etime-first_time.etime); for (i=0; i=0) fprintf (out, "SUCCEED"); else fprintf (out, "FAIL"); } break; case 'E': switch (type[1]) { case 'd': if (ptr) { if (vp) { fprintf (out, "0x%lx", (unsigned long)vp); } else { fprintf(out, "NULL"); } } else { H5E_direction_t direction = va_arg (ap, H5E_direction_t); /*lint !e64 Type mismatch not really occuring */ switch (direction) { case H5E_WALK_UPWARD: fprintf (out, "H5E_WALK_UPWARD"); break; case H5E_WALK_DOWNWARD: fprintf (out, "H5E_WALK_DOWNWARD"); break; default: fprintf (out, "%ld", (long)direction); break; } } break; case 'e': if (ptr) { if (vp) { fprintf (out, "0x%lx", (unsigned long)vp); } else { fprintf(out, "NULL"); } } else { H5E_error_t *error = va_arg (ap, H5E_error_t*); /*lint !e64 Type mismatch not really occuring */ fprintf (out, "0x%lx", (unsigned long)error); } break; case 'j': if (ptr) { if (vp) { fprintf(out, "0x%lx", (unsigned long)vp); } else { fprintf(out, "NULL"); } } else { H5E_major_t emaj = va_arg(ap, H5E_major_t); fprintf(out, "%d", (int)emaj); } break; case 'n': if (ptr) { if (vp) { fprintf(out, "0x%lx", (unsigned long)vp); } else { fprintf(out, "NULL"); } } else { H5E_minor_t emin = va_arg(ap, H5E_minor_t); fprintf(out, "%d", (int)emin); } break; default: fprintf (out, "BADTYPE(E%c)", type[1]); goto error; } break; case 'F': switch (type[1]) { case 'd': if (ptr) { if (vp) { fprintf(out, "0x%lx", (unsigned long)vp); } else { fprintf(out, "NULL"); } } else { H5F_close_degree_t degree = va_arg(ap, H5F_close_degree_t); /*lint !e64 Type mismatch not really occuring */ switch (degree) { case H5F_CLOSE_DEFAULT: fprintf(out, "H5F_CLOSE_DEFAULT"); break; case H5F_CLOSE_WEAK: fprintf(out, "H5F_CLOSE_WEAK"); break; case H5F_CLOSE_SEMI: fprintf(out, "H5F_CLOSE_SEMI"); break; case H5F_CLOSE_STRONG: fprintf(out, "H5F_CLOSE_STRONG"); break; } } break; case 's': if (ptr) { if (vp) { fprintf(out, "0x%lx", (unsigned long)vp); } else { fprintf(out, "NULL"); } } else { H5F_scope_t scope = va_arg(ap, H5F_scope_t); /*lint !e64 Type mismatch not really occuring */ switch (scope) { case H5F_SCOPE_LOCAL: fprintf(out, "H5F_SCOPE_LOCAL"); break; case H5F_SCOPE_GLOBAL: fprintf(out, "H5F_SCOPE_GLOBAL"); break; case H5F_SCOPE_DOWN: fprintf(out, "H5F_SCOPE_DOWN " "/*FOR INTERNAL USE ONLY!*/"); break; } } break; default: fprintf(out, "BADTYPE(F%c)", type[1]); goto error; } break; case 'G': switch (type[1]) { case 'l': if (ptr) { if (vp) { fprintf (out, "0x%lx", (unsigned long)vp); } else { fprintf(out, "NULL"); } } else { H5G_link_t link_type = va_arg (ap, H5G_link_t); /*lint !e64 Type mismatch not really occuring */ switch (link_type) { case H5G_LINK_ERROR: fprintf (out, "H5G_LINK_ERROR"); break; case H5G_LINK_HARD: fprintf (out, "H5G_LINK_HARD"); break; case H5G_LINK_SOFT: fprintf (out, "H5G_LINK_SOFT"); break; default: fprintf (out, "%ld", (long)link_type); break; } } break; case 's': if (ptr) { if (vp) { fprintf (out, "0x%lx", (unsigned long)vp); } else { fprintf(out, "NULL"); } } else { H5G_stat_t *statbuf = va_arg (ap, H5G_stat_t*); /*lint !e64 Type mismatch not really occuring */ fprintf (out, "0x%lx", (unsigned long)statbuf); } break; default: fprintf (out, "BADTYPE(G%c)", type[1]); goto error; } break; case 'h': if (ptr) { if (vp) { fprintf (out, "0x%lx", (unsigned long)vp); if (asize_idx>=0 && asize[asize_idx]>=0) { hsize_t *p = (hsize_t*)vp; fprintf(out, " {"); for (i=0; i=0 && asize[asize_idx]>=0) { hssize_t *p = (hssize_t*)vp; fprintf(out, " {"); for (i=0; i=0 && asize[asize_idx]>=0) { int *p = (int*)vp; fprintf(out, " {"); for (i=0; i=0 && asize[asize_idx]>=0) { unsigned *p = (unsigned*)vp; fprintf(out, " {"); for (i=0; i0) fprintf (out, "TRUE"); else if (!tri_var) fprintf (out, "FALSE"); else fprintf (out, "FAIL(%d)", (int)tri_var); } break; case 'x': if (ptr) { if (vp) { fprintf (out, "0x%lx", (unsigned long)vp); if (asize_idx>=0 && asize[asize_idx]>=0) { void **p = (void**)vp; fprintf(out, " {"); for (i=0; i=0 && asize[asize_idx]>=0) { size_t *p = (size_t*)vp; fprintf(out, " {"); for (i=0; i=0 && asize[asize_idx]>=0) { ssize_t *p = (ssize_t*)vp; fprintf(out, " {"); for (i=0; i0) ? 1 : 0; if (H5P_set(plist,H5D_XFER_HYPER_CACHE_NAME,&cache)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to set value"); if (H5P_set(plist,H5D_XFER_HYPER_CACHE_LIM_NAME,&limit)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to set value"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Pget_hyper_cache * * Purpose: Reads values previously set with H5Pset_hyper_cache(). * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Monday, September 21, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Pget_hyper_cache(hid_t plist_id, unsigned *cache/*out*/, unsigned *limit/*out*/) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pget_hyper_cache, FAIL); H5TRACE3("e","ixx",plist_id,cache,limit); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Return values */ if (cache) if (H5P_get(plist,H5D_XFER_HYPER_CACHE_NAME,cache)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value"); if (limit) if (H5P_get(plist,H5D_XFER_HYPER_CACHE_LIM_NAME,limit)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value"); done: FUNC_LEAVE_API(ret_value); } #endif /* H5_WANT_H5_V1_4_COMPAT */ /*------------------------------------------------------------------------- * Function: H5Pset_preserve * * Purpose: When reading or writing compound data types and the * destination is partially initialized and the read/write is * intended to initialize the other members, one must set this * property to TRUE. Otherwise the I/O pipeline treats the * destination datapoints as completely uninitialized. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Tuesday, March 17, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Pset_preserve(hid_t plist_id, hbool_t status) { H5T_bkg_t need_bkg; /* Value for background buffer type */ H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pset_preserve, FAIL); H5TRACE2("e","ib",plist_id,status); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Update property list */ need_bkg = status ? H5T_BKG_YES : H5T_BKG_NO; if (H5P_set(plist,H5D_XFER_BKGR_BUF_TYPE_NAME,&need_bkg)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Pget_preserve * * Purpose: The inverse of H5Pset_preserve() * * Return: Success: TRUE or FALSE * * Failure: Negative * * Programmer: Robb Matzke * Tuesday, March 17, 1998 * * Modifications: * *------------------------------------------------------------------------- */ int H5Pget_preserve(hid_t plist_id) { H5T_bkg_t need_bkg; /* Background value */ H5P_genplist_t *plist; /* Property list pointer */ int ret_value; /* return value */ FUNC_ENTER_API(H5Pget_preserve, FAIL); H5TRACE1("Is","i",plist_id); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Get value */ if (H5P_get(plist,H5D_XFER_BKGR_BUF_NAME,&need_bkg)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value"); /* Set return value */ ret_value= need_bkg ? TRUE : FALSE; done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Pset_edc_check * * Purpose: Enable or disable error-detecting for a dataset reading * process. This error-detecting algorithm is whichever * user chooses earlier. This function cannot control * writing process. * * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu * Jan 3, 2003 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Pset_edc_check(hid_t plist_id, H5Z_EDC_t check) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pset_edc_check, FAIL); H5TRACE2("e","iZe",plist_id,check); /* Check argument */ if (check != H5Z_ENABLE_EDC && check != H5Z_DISABLE_EDC) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid value"); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Update property list */ if (H5P_set(plist,H5D_XFER_EDC_NAME,&check)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Pget_edc_check * * Purpose: Enable or disable error-detecting for a dataset reading * process. This error-detecting algorithm is whichever * user chooses earlier. This function cannot control * writing process. * * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu * Jan 3, 2003 * * Modifications: * *------------------------------------------------------------------------- */ H5Z_EDC_t H5Pget_edc_check(hid_t plist_id) { H5P_genplist_t *plist; /* Property list pointer */ H5Z_EDC_t ret_value; /* return value */ FUNC_ENTER_API(H5Pget_edc_check, H5Z_ERROR_EDC); H5TRACE1("Ze","i",plist_id); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5Z_ERROR_EDC, "can't find object for ID"); /* Update property list */ if (H5P_get(plist,H5D_XFER_EDC_NAME,&ret_value)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5Z_ERROR_EDC, "unable to set value"); /* check valid value */ if (ret_value != H5Z_ENABLE_EDC && ret_value != H5Z_DISABLE_EDC) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5Z_ERROR_EDC, "not a valid value"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Pset_filter_callback * * Purpose: Sets user's callback function for dataset transfer property * list. This callback function defines what user wants to do * if certain filter fails. * * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu * Jan 14, 2003 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Pset_filter_callback(hid_t plist_id, H5Z_filter_func_t func, void *op_data) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ H5Z_cb_t cb_struct; FUNC_ENTER_API(H5Pset_filter_callback, FAIL); H5TRACE3("e","ixx",plist_id,func,op_data); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Update property list */ cb_struct.func = func; cb_struct.op_data = op_data; if (H5P_set(plist,H5D_XFER_FILTER_CB_NAME,&cb_struct)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Pget_btree_ratios * * Purpose: Queries B-tree split ratios. See H5Pset_btree_ratios(). * * Return: Success: Non-negative with split ratios returned through * the non-null arguments. * * Failure: Negative * * Programmer: Robb Matzke * Monday, September 28, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Pget_btree_ratios(hid_t plist_id, double *left/*out*/, double *middle/*out*/, double *right/*out*/) { double btree_split_ratio[3]; /* B-tree node split ratios */ H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pget_btree_ratios, FAIL); H5TRACE4("e","ixxx",plist_id,left,middle,right); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Get the split ratios */ if (H5P_get(plist,H5D_XFER_BTREE_SPLIT_RATIO_NAME,&btree_split_ratio)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value"); /* Get values */ if (left) *left = btree_split_ratio[0]; if (middle) *middle = btree_split_ratio[1]; if (right) *right = btree_split_ratio[2]; done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Pset_btree_ratios * * Purpose: Sets B-tree split ratios for a dataset transfer property * list. The split ratios determine what percent of children go * in the first node when a node splits. The LEFT ratio is * used when the splitting node is the left-most node at its * level in the tree; the RIGHT ratio is when the splitting node * is the right-most node at its level; and the MIDDLE ratio for * all other cases. A node which is the only node at its level * in the tree uses the RIGHT ratio when it splits. All ratios * are real numbers between 0 and 1, inclusive. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Monday, September 28, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Pset_btree_ratios(hid_t plist_id, double left, double middle, double right) { double split_ratio[3]; /* B-tree node split ratios */ H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pset_btree_ratios, FAIL); H5TRACE4("e","iddd",plist_id,left,middle,right); /* Check arguments */ if (left<0.0 || left>1.0 || middle<0.0 || middle>1.0 || right<0.0 || right>1.0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "split ratio must satisfy 0.0<=X<=1.0"); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Set values */ split_ratio[0] = left; split_ratio[1] = middle; split_ratio[2] = right; /* Set the split ratios */ if (H5P_set(plist,H5D_XFER_BTREE_SPLIT_RATIO_NAME,&split_ratio)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5P_set_vlen_mem_manager * * Purpose: Sets the memory allocate/free pair for VL datatypes. The * allocation routine is called when data is read into a new * array and the free routine is called when H5Dvlen_reclaim is * called. The alloc_info and free_info are user parameters * which are passed to the allocation and freeing functions * respectively. To reset the allocate/free functions to the * default setting of using the system's malloc/free functions, * call this routine with alloc_func and free_func set to NULL. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Thursday, July 1, 1999 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5P_set_vlen_mem_manager(H5P_genplist_t *plist, H5MM_allocate_t alloc_func, void *alloc_info, H5MM_free_t free_func, void *free_info) { herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_NOAPI(H5P_set_vlen_mem_manager, FAIL); assert(plist); /* Update property list */ if (H5P_set(plist,H5D_XFER_VLEN_ALLOC_NAME,&alloc_func)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value"); if (H5P_set(plist,H5D_XFER_VLEN_ALLOC_INFO_NAME,&alloc_info)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value"); if (H5P_set(plist,H5D_XFER_VLEN_FREE_NAME,&free_func)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value"); if (H5P_set(plist,H5D_XFER_VLEN_FREE_INFO_NAME,&free_info)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value"); done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5P_set_vlen_mem_manager() */ /*------------------------------------------------------------------------- * Function: H5Pset_vlen_mem_manager * * Purpose: Sets the memory allocate/free pair for VL datatypes. The * allocation routine is called when data is read into a new * array and the free routine is called when H5Dvlen_reclaim is * called. The alloc_info and free_info are user parameters * which are passed to the allocation and freeing functions * respectively. To reset the allocate/free functions to the * default setting of using the system's malloc/free functions, * call this routine with alloc_func and free_func set to NULL. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Thursday, July 1, 1999 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Pset_vlen_mem_manager(hid_t plist_id, H5MM_allocate_t alloc_func, void *alloc_info, H5MM_free_t free_func, void *free_info) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pset_vlen_mem_manager, FAIL); H5TRACE5("e","ixxxx",plist_id,alloc_func,alloc_info,free_func,free_info); /* Check arguments */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list"); /* Update property list */ if (H5P_set_vlen_mem_manager(plist,alloc_func,alloc_info,free_func,free_info)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set values"); done: FUNC_LEAVE_API(ret_value); } /* end H5Pset_vlen_mem_manager() */ /*------------------------------------------------------------------------- * Function: H5Pget_vlen_mem_manager * * Purpose: The inverse of H5Pset_vlen_mem_manager() * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Thursday, July 1, 1999 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Pget_vlen_mem_manager(hid_t plist_id, H5MM_allocate_t *alloc_func/*out*/, void **alloc_info/*out*/, H5MM_free_t *free_func/*out*/, void **free_info/*out*/) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pget_vlen_mem_manager, FAIL); H5TRACE5("e","ixxxx",plist_id,alloc_func,alloc_info,free_func,free_info); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); if(alloc_func!=NULL) if (H5P_get(plist,H5D_XFER_VLEN_ALLOC_NAME,alloc_func)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value"); if(alloc_info!=NULL) if (H5P_get(plist,H5D_XFER_VLEN_ALLOC_INFO_NAME,alloc_info)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value"); if(free_func!=NULL) if (H5P_get(plist,H5D_XFER_VLEN_FREE_NAME,free_func)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value"); if(free_info!=NULL) if (H5P_get(plist,H5D_XFER_VLEN_FREE_INFO_NAME,free_info)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Pset_hyper_vector_size * * Purpose: Given a dataset transfer property list, set the number of * "I/O vectors" (offset and length pairs) which are to be * accumulated in memory before being issued to the lower levels * of the library for reading or writing the actual data. * Increasing the number should give better performance, but use * more memory during hyperslab I/O. The vector size must be * greater than 1. * * The default is to use 1024 vectors for I/O during hyperslab * reading/writing. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Monday, July 9, 2001 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Pset_hyper_vector_size(hid_t plist_id, size_t vector_size) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pset_hyper_vector_size, FAIL); H5TRACE2("e","iz",plist_id,vector_size); /* Check arguments */ if (vector_size<1) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "vector size too small"); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Update property list */ if (H5P_set(plist,H5D_XFER_HYPER_VECTOR_SIZE_NAME,&vector_size)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value"); done: FUNC_LEAVE_API(ret_value); } /* end H5Pset_hyper_vector_size() */ /*------------------------------------------------------------------------- * Function: H5Pget_hyper_vector_size * * Purpose: Reads values previously set with H5Pset_hyper_vector_size(). * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Monday, July 9, 2001 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Pget_hyper_vector_size(hid_t plist_id, size_t *vector_size/*out*/) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pget_hyper_vector_size, FAIL); H5TRACE2("e","ix",plist_id,vector_size); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Return values */ if (vector_size) if (H5P_get(plist,H5D_XFER_HYPER_VECTOR_SIZE_NAME,vector_size)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value"); done: FUNC_LEAVE_API(ret_value); } /* end H5Pget_hyper_vector_size() */ xdmf-3.0+git20160803/Utilities/hdf5/H5Spublic.h0000640000175000017500000001511713003006557020647 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * This file contains public declarations for the H5S module. */ #ifndef _H5Spublic_H #define _H5Spublic_H /* Public headers needed by this file */ #include "H5public.h" #include "H5Ipublic.h" /* Define atomic datatypes */ #define H5S_ALL 0 #define H5S_UNLIMITED ((hsize_t)(hssize_t)(-1)) /* Define user-level maximum number of dimensions */ #define H5S_MAX_RANK 32 /* Different types of dataspaces */ typedef enum H5S_class_t { H5S_NO_CLASS = -1, /*error */ H5S_SCALAR = 0, /*scalar variable */ H5S_SIMPLE = 1, /*simple data space */ H5S_COMPLEX = 2 /*complex data space */ } H5S_class_t; /* Different ways of combining selections */ typedef enum H5S_seloper_t { H5S_SELECT_NOOP = -1, /* error */ H5S_SELECT_SET = 0, /* Select "set" operation */ H5S_SELECT_OR, /* Binary "or" operation for hyperslabs * (add new selection to existing selection) * Original region: AAAAAAAAAA * New region: BBBBBBBBBB * A or B: CCCCCCCCCCCCCCCC */ H5S_SELECT_AND, /* Binary "and" operation for hyperslabs * (only leave overlapped regions in selection) * Original region: AAAAAAAAAA * New region: BBBBBBBBBB * A and B: CCCC */ H5S_SELECT_XOR, /* Binary "xor" operation for hyperslabs * (only leave non-overlapped regions in selection) * Original region: AAAAAAAAAA * New region: BBBBBBBBBB * A xor B: CCCCCC CCCCCC */ H5S_SELECT_NOTB, /* Binary "not" operation for hyperslabs * (only leave non-overlapped regions in original selection) * Original region: AAAAAAAAAA * New region: BBBBBBBBBB * A not B: CCCCCC */ H5S_SELECT_NOTA, /* Binary "not" operation for hyperslabs * (only leave non-overlapped regions in new selection) * Original region: AAAAAAAAAA * New region: BBBBBBBBBB * B not A: CCCCCC */ H5S_SELECT_APPEND, /* Append elements to end of point selection */ H5S_SELECT_PREPEND, /* Prepend elements to beginning of point selection */ H5S_SELECT_INVALID /* Invalid upper bound on selection operations */ } H5S_seloper_t; /* Enumerated type for the type of selection */ typedef enum { H5S_SEL_ERROR = -1, /* Error */ H5S_SEL_NONE = 0, /* Nothing selected */ H5S_SEL_POINTS = 1, /* Sequence of points selected */ H5S_SEL_HYPERSLABS = 2, /* "New-style" hyperslab selection defined */ H5S_SEL_ALL = 3, /* Entire extent selected */ H5S_SEL_N = 4 /*THIS MUST BE LAST */ }H5S_sel_type; #ifdef __cplusplus extern "C" { #endif /* Functions in H5S.c */ H5_DLL hid_t H5Screate(H5S_class_t type); H5_DLL hid_t H5Screate_simple(int rank, const hsize_t dims[], const hsize_t maxdims[]); H5_DLL herr_t H5Sset_extent_simple(hid_t space_id, int rank, const hsize_t dims[], const hsize_t max[]); H5_DLL hid_t H5Scopy(hid_t space_id); H5_DLL herr_t H5Sclose(hid_t space_id); H5_DLL hssize_t H5Sget_simple_extent_npoints(hid_t space_id); H5_DLL int H5Sget_simple_extent_ndims(hid_t space_id); H5_DLL int H5Sget_simple_extent_dims(hid_t space_id, hsize_t dims[], hsize_t maxdims[]); H5_DLL htri_t H5Sis_simple(hid_t space_id); H5_DLL herr_t H5Sset_space(hid_t space_id, int rank, const hsize_t *dims); H5_DLL hssize_t H5Sget_select_npoints(hid_t spaceid); H5_DLL herr_t H5Sselect_hyperslab(hid_t space_id, H5S_seloper_t op, const hsize_t start[], const hsize_t _stride[], const hsize_t count[], const hsize_t _block[]); H5_DLL herr_t H5Sselect_elements(hid_t space_id, H5S_seloper_t op, size_t num_elemn, const hsize_t **coord); H5_DLL H5S_class_t H5Sget_simple_extent_type(hid_t space_id); H5_DLL herr_t H5Sset_extent_none(hid_t space_id); H5_DLL herr_t H5Sextent_copy(hid_t dst_id,hid_t src_id); H5_DLL herr_t H5Sselect_all(hid_t spaceid); H5_DLL herr_t H5Sselect_none(hid_t spaceid); H5_DLL herr_t H5Soffset_simple(hid_t space_id, const hssize_t *offset); H5_DLL htri_t H5Sselect_valid(hid_t spaceid); H5_DLL hssize_t H5Sget_select_hyper_nblocks(hid_t spaceid); H5_DLL hssize_t H5Sget_select_elem_npoints(hid_t spaceid); H5_DLL herr_t H5Sget_select_hyper_blocklist(hid_t spaceid, hsize_t startblock, hsize_t numblocks, hsize_t *buf); H5_DLL herr_t H5Sget_select_elem_pointlist(hid_t spaceid, hsize_t startpoint, hsize_t numpoints, hsize_t *buf); H5_DLL herr_t H5Sget_select_bounds(hid_t spaceid, hsize_t *start, hsize_t *end); H5_DLL H5S_sel_type H5Sget_select_type(hid_t spaceid); #ifdef __cplusplus } #endif #endif xdmf-3.0+git20160803/Utilities/hdf5/H5HLpkg.h0000640000175000017500000000613113003006557020247 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Quincey Koziol * Wednesday, July 9, 2003 * * Purpose: This file contains declarations which are visible * only within the H5HL package. Source files outside the * H5HL package should include H5HLprivate.h instead. */ #ifndef H5HL_PACKAGE #error "Do not include this file outside the H5HL package!" #endif #ifndef _H5HLpkg_H #define _H5HLpkg_H /* Get package's private header */ #include "H5HLprivate.h" /* Other private headers needed by this file */ /*****************************/ /* Package Private Variables */ /*****************************/ /* The cache subclass */ H5_DLLVAR const H5AC_class_t H5AC_LHEAP[1]; /**************************/ /* Package Private Macros */ /**************************/ #define H5HL_SIZEOF_HDR(F) \ H5HL_ALIGN(H5HL_SIZEOF_MAGIC + /*heap signature */ \ 4 + /*reserved */ \ H5F_SIZEOF_SIZE (F) + /*data size */ \ H5F_SIZEOF_SIZE (F) + /*free list head */ \ H5F_SIZEOF_ADDR (F)) /*data address */ /****************************/ /* Package Private Typedefs */ /****************************/ typedef struct H5HL_free_t { size_t offset; /*offset of free block */ size_t size; /*size of free block */ struct H5HL_free_t *prev; /*previous entry in free list */ struct H5HL_free_t *next; /*next entry in free list */ } H5HL_free_t; struct H5HL_t { H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */ /* first field in structure */ haddr_t addr; /*address of data */ size_t disk_alloc; /*data bytes allocated on disk */ size_t mem_alloc; /*data bytes allocated in mem */ size_t disk_resrv; /*data bytes "reserved" on disk */ uint8_t *chunk; /*the chunk, including header */ H5HL_free_t *freelist; /*the free list */ }; /******************************/ /* Package Private Prototypes */ /******************************/ #endif xdmf-3.0+git20160803/Utilities/hdf5/H5E.c0000640000175000017500000007146513003006557017435 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Purpose: Provides error handling in the form of a stack. The * FUNC_ENTER() macro clears the error stack whenever an API * function is entered. When an error is detected, an entry is * pushed onto the stack. As the functions unwind additional * entries are pushed onto the stack. The API function will * return some indication that an error occurred and the * application can print the error stack. * * Certain API functions in the H5E package (such as H5Eprint()) * do not clear the error stack. Otherwise, any function which * doesn't have an underscore immediately after the package name * will clear the error stack. For instance, H5Fopen() clears * the error stack while H5F_open() does not. * * An error stack has a fixed maximum size. If this size is * exceeded then the stack will be truncated and only the * inner-most functions will have entries on the stack. This is * expected to be a rare condition. * * Each thread has its own error stack, but since * multi-threading has not been added to the library yet, this * package maintains a single error stack. The error stack is * statically allocated to reduce the complexity of handling * errors within the H5E package. * */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5E_init_interface #include "H5private.h" /* Generic Functions */ #include "H5Iprivate.h" /* IDs */ #include "H5Eprivate.h" /* Private error routines */ #include "H5MMprivate.h" /* Memory management */ static const H5E_major_mesg_t H5E_major_mesg_g[] = { {H5E_NONE_MAJOR, "No error"}, {H5E_ARGS, "Function arguments"}, {H5E_RESOURCE, "Resource unavailable"}, {H5E_INTERNAL, "Internal HDF5 error"}, {H5E_FILE, "File interface"}, {H5E_IO, "Low-level I/O layer"}, {H5E_FUNC, "Function entry/exit"}, {H5E_ATOM, "Atom layer"}, {H5E_CACHE, "Meta data cache layer"}, {H5E_BTREE, "B-tree layer"}, {H5E_SYM, "Symbol table layer"}, {H5E_HEAP, "Heap layer"}, {H5E_OHDR, "Object header layer"}, {H5E_DATATYPE, "Datatype interface"}, {H5E_DATASPACE, "Dataspace interface"}, {H5E_DATASET, "Dataset interface"}, {H5E_STORAGE, "Data storage layer"}, {H5E_PLIST, "Property list interface"}, {H5E_ATTR, "Attribute layer"}, {H5E_PLINE, "Data filters layer"}, {H5E_EFL, "External file list"}, {H5E_REFERENCE, "References layer"}, {H5E_VFL, "Virtual File Layer"}, {H5E_TBBT, "Threaded, Balanced, Binary Trees"}, {H5E_TST, "Ternary Search Trees"}, {H5E_RS, "Reference Counted Strings"}, {H5E_ERROR, "Error API"}, {H5E_SLIST, "Skip Lists"}, }; static const H5E_minor_mesg_t H5E_minor_mesg_g[] = { {H5E_NONE_MINOR, "No error"}, /* Argument errors */ {H5E_UNINITIALIZED, "Information is uninitialized"}, {H5E_UNSUPPORTED, "Feature is unsupported"}, {H5E_BADTYPE, "Inappropriate type"}, {H5E_BADRANGE, "Out of range"}, {H5E_BADVALUE, "Bad value"}, /* Resource errors */ {H5E_NOSPACE, "No space available for allocation"}, {H5E_CANTCOPY, "Unable to copy object"}, {H5E_CANTFREE, "Unable to free object"}, {H5E_ALREADYEXISTS, "Object already exists"}, {H5E_CANTLOCK, "Unable to lock object"}, {H5E_CANTUNLOCK, "Unable to unlock object"}, {H5E_CANTGC, "Unable to garbage collect"}, {H5E_CANTGETSIZE, "Unable to compute size"}, /* File accessability errors */ {H5E_FILEEXISTS, "File already exists"}, {H5E_FILEOPEN, "File already open"}, {H5E_CANTCREATE, "Unable to create file"}, {H5E_CANTOPENFILE, "Unable to open file"}, {H5E_CANTCLOSEFILE, "Unable to close file"}, {H5E_NOTHDF5, "Not an HDF5 file"}, {H5E_BADFILE, "Bad file ID accessed"}, {H5E_TRUNCATED, "File has been truncated"}, {H5E_MOUNT, "File mount error"}, /* Generic low-level file I/O errors */ {H5E_SEEKERROR, "Seek failed"}, {H5E_READERROR, "Read failed"}, {H5E_WRITEERROR, "Write failed"}, {H5E_CLOSEERROR, "Close failed"}, {H5E_OVERFLOW, "Address overflowed"}, {H5E_FCNTL, "File control (fcntl) failed"}, /* Function entry/exit interface errors */ {H5E_CANTINIT, "Unable to initialize object"}, {H5E_ALREADYINIT, "Object already initialized"}, {H5E_CANTRELEASE, "Unable to release object"}, /* Object atom related errors */ {H5E_BADATOM, "Unable to find atom information (already closed?)"}, {H5E_BADGROUP, "Unable to find ID group information"}, {H5E_CANTREGISTER, "Unable to register new atom"}, {H5E_CANTINC, "Unable to increment reference count"}, {H5E_CANTDEC, "Unable to decrement reference count"}, {H5E_NOIDS, "Out of IDs for group"}, /* Cache related errors */ {H5E_CANTFLUSH, "Unable to flush data from cache"}, {H5E_CANTSERIALIZE, "Unable to serialize data from cache"}, {H5E_CANTLOAD, "Unable to load metadata into cache"}, {H5E_PROTECT, "Protected metadata error"}, {H5E_NOTCACHED, "Metadata not currently cached"}, {H5E_SYSTEM, "Internal error detected"}, {H5E_CANTINS, "Unable to insert metadata into cache"}, {H5E_CANTRENAME, "Unable to rename metadata"}, {H5E_CANTPROTECT, "Unable to protect metadata"}, {H5E_CANTUNPROTECT, "Unable to unprotect metadata"}, /* B-tree related errors */ {H5E_NOTFOUND, "Object not found"}, {H5E_EXISTS, "Object already exists"}, {H5E_CANTENCODE, "Unable to encode value"}, {H5E_CANTDECODE, "Unable to decode value"}, {H5E_CANTSPLIT, "Unable to split node"}, {H5E_CANTINSERT, "Unable to insert object"}, {H5E_CANTLIST, "Unable to list node"}, /* Object header related errors */ {H5E_LINKCOUNT, "Bad object header link count"}, {H5E_VERSION, "Wrong version number"}, {H5E_ALIGNMENT, "Alignment error"}, {H5E_BADMESG, "Unrecognized message"}, {H5E_CANTDELETE, "Can't delete message"}, {H5E_BADITER, "Iteration failed"}, /* Group related errors */ {H5E_CANTOPENOBJ, "Can't open object"}, {H5E_CANTCLOSEOBJ, "Can't close object"}, {H5E_COMPLEN, "Name component is too long"}, {H5E_LINK, "Link count failure"}, {H5E_SLINK, "Symbolic link error"}, {H5E_PATH, "Problem with path to object"}, /* Datatype conversion errors */ {H5E_CANTCONVERT, "Can't convert datatypes"}, {H5E_BADSIZE, "Bad size for object"}, /* Dataspace errors */ {H5E_CANTCLIP, "Can't clip hyperslab region"}, {H5E_CANTCOUNT, "Can't count elements"}, {H5E_CANTSELECT, "Can't select hyperslab"}, {H5E_CANTNEXT, "Can't move to next iterator location"}, {H5E_BADSELECT, "Invalid selection"}, {H5E_CANTCOMPARE, "Can't compare objects"}, /* Property list errors */ {H5E_CANTGET, "Can't get value"}, {H5E_CANTSET, "Can't set value"}, {H5E_DUPCLASS, "Duplicate class name in parent class"}, /* Parallel MPI errors */ {H5E_MPI, "Some MPI function failed"}, {H5E_MPIERRSTR, "MPI Error String"}, /* Heap errors */ {H5E_CANTRESTORE, "Can't restore condition"}, /* TBBT errors */ {H5E_CANTMAKETREE, "Can't create TBBT tree"}, /* I/O pipeline errors */ {H5E_NOFILTER, "Requested filter is not available"}, {H5E_CALLBACK, "Callback failed"}, {H5E_CANAPPLY, "Error from filter \"can apply\" callback"}, {H5E_SETLOCAL, "Error from filter \"set local\" callback"}, {H5E_NOENCODER, "Filter present, but encoder not enabled"}, /* I/O pipeline errors */ {H5E_SYSERRSTR, "System error message"} }; /* Interface initialization? */ static int interface_initialize_g = 0; #define INTERFACE_INIT H5E_init_interface #ifdef H5_HAVE_THREADSAFE /* * The per-thread error stack. pthread_once() initializes a special * key that will be used by all threads to create a stack specific to * each thread individually. The association of stacks to threads will * be handled by the pthread library. * * In order for this macro to work, H5E_get_my_stack() must be preceeded * by "H5E_t *estack =". */ static H5E_t * H5E_get_stack(void); #define H5E_get_my_stack() H5E_get_stack() #else /* H5_HAVE_THREADSAFE */ /* * The current error stack. */ H5E_t H5E_stack_g[1]; #define H5E_get_my_stack() (H5E_stack_g+0) #endif /* H5_HAVE_THREADSAFE */ #ifdef H5_HAVE_PARALLEL /* * variables used for MPI error reporting */ char H5E_mpi_error_str[MPI_MAX_ERROR_STRING]; int H5E_mpi_error_str_len; #endif /* Static function declarations */ static herr_t H5E_walk (H5E_direction_t direction, H5E_walk_t func, void *client_data); static herr_t H5E_walk_cb (int n, H5E_error_t *err_desc, void *client_data); /*------------------------------------------------------------------------- * Function: H5E_init_interface * * Purpose: Initialize the H5E interface. `stderr' is an extern or * function on some systems so we can't initialize * H5E_auto_data_g statically. * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, June 11, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5E_init_interface (void) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5E_init_interface) #ifndef H5_HAVE_THREADSAFE H5E_stack_g[0].nused = 0; H5E_stack_g[0].auto_func = (H5E_auto_t)H5Eprint; H5E_stack_g[0].auto_data = stderr; #endif /* H5_HAVE_THREADSAFE */ FUNC_LEAVE_NOAPI(SUCCEED) } #ifdef H5_HAVE_THREADSAFE /*------------------------------------------------------------------------- * Function: H5E_get_stack * * Purpose: Support function for H5E_get_my_stack() to initialize and * acquire per-thread error stack. * * Return: Success: error stack (H5E_t *) * * Failure: NULL * * Programmer: Chee Wai LEE * April 24, 2000 * * Modifications: * *------------------------------------------------------------------------- */ static H5E_t * H5E_get_stack(void) { H5E_t *estack; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5E_get_stack) estack = pthread_getspecific(H5TS_errstk_key_g); if (!estack) { /* no associated value with current thread - create one */ estack = (H5E_t *)H5MM_malloc(sizeof(H5E_t)); assert(estack); /* Set thread specific information */ estack->nused = 0; estack->auto_func = (H5E_auto_t)H5Eprint; estack->auto_data = stderr; pthread_setspecific(H5TS_errstk_key_g, (void *)estack); } FUNC_LEAVE_NOAPI(estack) } #endif /* H5_HAVE_THREADSAFE */ /*------------------------------------------------------------------------- * Function: H5Eset_auto * * Purpose: Turns on or off automatic printing of errors. When turned on * (non-null FUNC pointer) any API function which returns an * error indication will first call FUNC passing it CLIENT_DATA * as an argument. * * The default values before this function is called are * H5Eprint() with client data being the standard error stream, * stderr. * * Automatic stack traversal is always in the H5E_WALK_DOWNWARD * direction. * * See Also: H5Ewalk() * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Friday, February 27, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Eset_auto(H5E_auto_t func, void *client_data) { H5E_t *estack; /* Error stack to operate on */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Eset_auto, FAIL) H5TRACE2("e","xx",func,client_data); /* Get the thread-specific error stack */ if((estack = H5E_get_my_stack())==NULL) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") /* Set the automatic error reporting info */ estack->auto_func = func; estack->auto_data = client_data; done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5Eget_auto * * Purpose: Returns the current settings for the automatic error stack * traversal function and its data. Either (or both) arguments * may be null in which case the value is not returned. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Saturday, February 28, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Eget_auto(H5E_auto_t *func, void **client_data) { H5E_t *estack; /* Error stack to operate on */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Eget_auto, FAIL) H5TRACE2("e","*xx",func,client_data); /* Get the thread-specific error stack */ if((estack = H5E_get_my_stack())==NULL) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") /* Set the automatic error reporting info */ if (func) *func = estack->auto_func; if (client_data) *client_data = estack->auto_data; done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5Eclear * * Purpose: Clears the error stack for the current thread. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Friday, February 27, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Eclear(void) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Eclear, FAIL) H5TRACE0("e",""); /* FUNC_ENTER() does all the work */ done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5Eprint * * Purpose: Prints the error stack in some default way. This is just a * convenience function for H5Ewalk() with a function that * prints error messages. Users are encouraged to write there * own more specific error handlers. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Friday, February 27, 1998 * * Modifications: * Albert Cheng, 2000/12/02 * Show MPI process rank id if applicable. * Albert Cheng, 2001/07/14 * Show HDF5 library version information string too. * *------------------------------------------------------------------------- */ herr_t H5Eprint(FILE *stream) { H5E_t *estack = H5E_get_my_stack (); herr_t ret_value = FAIL; /* Don't clear the error stack! :-) */ FUNC_ENTER_API_NOCLEAR(H5Eprint, FAIL) /*NO TRACE*/ if (!stream) stream = stderr; fprintf (stream, "HDF5-DIAG: Error detected in %s ", H5_lib_vers_info_g); /* try show the process or thread id in multiple processes cases*/ #ifdef H5_HAVE_PARALLEL { int mpi_rank, mpi_initialized; MPI_Initialized(&mpi_initialized); if (mpi_initialized){ MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank); fprintf (stream, "MPI-process %d.", mpi_rank); }else fprintf (stream, "thread 0."); } #elif defined(H5_HAVE_THREADSAFE) fprintf (stream, "thread %lu.", (unsigned long)pthread_self()); #else fprintf (stream, "thread 0."); #endif if (estack && estack->nused>0) fprintf (stream, " Back trace follows."); HDfputc ('\n', stream); ret_value = H5E_walk (H5E_WALK_DOWNWARD, H5E_walk_cb, (void*)stream); done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5Ewalk * * Purpose: Walks the error stack for the current thread and calls some * function for each error along the way. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Friday, February 27, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Ewalk(H5E_direction_t direction, H5E_walk_t func, void *client_data) { herr_t ret_value; /* Don't clear the error stack! :-) */ FUNC_ENTER_API_NOCLEAR(H5Ewalk, FAIL) H5TRACE3("e","Edxx",direction,func,client_data); ret_value = H5E_walk (direction, func, client_data); done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5E_walk_cb * * Purpose: This is a default error stack traversal callback function * that prints error messages to the specified output stream. * It is not meant to be called directly but rather as an * argument to the H5Ewalk() function. This function is called * also by H5Eprint(). Application writers are encouraged to * use this function as a model for their own error stack * walking functions. * * N is a counter for how many times this function has been * called for this particular traversal of the stack. It always * begins at zero for the first error on the stack (either the * top or bottom error, or even both, depending on the traversal * direction and the size of the stack). * * ERR_DESC is an error description. It contains all the * information about a particular error. * * CLIENT_DATA is the same pointer that was passed as the * CLIENT_DATA argument of H5Ewalk(). It is expected to be a * file pointer (or stderr if null). * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Friday, December 12, 1997 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5E_walk_cb(int n, H5E_error_t *err_desc, void *client_data) { FILE *stream = (FILE *)client_data; const char *maj_str = NULL; const char *min_str = NULL; const int indent = 2; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5E_walk_cb) /*NO TRACE*/ /* Check arguments */ assert (err_desc); if (!client_data) client_data = stderr; /* Get descriptions for the major and minor error numbers */ maj_str = H5Eget_major (err_desc->maj_num); min_str = H5Eget_minor (err_desc->min_num); /* Print error message */ fprintf (stream, "%*s#%03d: %s line %u in %s(): %s\n", indent, "", n, err_desc->file_name, err_desc->line, err_desc->func_name, err_desc->desc); fprintf (stream, "%*smajor(%02d): %s\n", indent*2, "", err_desc->maj_num, maj_str); fprintf (stream, "%*sminor(%02d): %s\n", indent*2, "", err_desc->min_num, min_str); FUNC_LEAVE_NOAPI(SUCCEED) } /*------------------------------------------------------------------------- * Function: H5Eget_major * * Purpose: Given a major error number return a constant character string * that describes the error. * * Return: Success: Ptr to a character string. * * Failure: Ptr to "Invalid major error number" * * Programmer: Robb Matzke * Friday, February 27, 1998 * * Modifications: * *------------------------------------------------------------------------- */ const char * H5Eget_major (H5E_major_t n) { unsigned i; const char *ret_value="Invalid major error number"; /* * WARNING: Do not call the FUNC_ENTER() or FUNC_LEAVE() macros since * they might interact badly with the error stack. We are * probably calling this function during an error stack * traversal and adding/removing entries as the result of an * error would most likely mess things up. */ FUNC_ENTER_API_NOINIT(H5Eget_major) for (i=0; inusedslot[estack->nused].maj_num = maj_num; estack->slot[estack->nused].min_num = min_num; estack->slot[estack->nused].func_name = function_name; estack->slot[estack->nused].file_name = file_name; estack->slot[estack->nused].line = line; estack->slot[estack->nused].desc = desc; estack->nused++; } FUNC_LEAVE_NOAPI(SUCCEED) } /*------------------------------------------------------------------------- * Function: H5Epush * * Purpose: Pushes a new error record onto error stack for the current * thread. The error has major and minor numbers MAJ_NUM and * MIN_NUM, the name of a function where the error was detected, * the name of the file where the error was detected, the * line within that file, and an error description string. The * function name, file name, and error description strings must * be statically allocated. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Monday, October 18, 1999 * * Notes: Basically a public API wrapper around the H5E_push function. * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Epush(const char *file, const char *func, unsigned line, H5E_major_t maj, H5E_minor_t min, const char *str) { herr_t ret_value; FUNC_ENTER_API(H5Epush, FAIL) H5TRACE6("e","ssIuEjEns",file,func,line,maj,min,str); ret_value = H5E_push(maj, min, func, file, line, str); done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5E_clear * * Purpose: Clears the error stack for the current thread. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Friday, February 27, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5E_clear(void) { H5E_t *estack = H5E_get_my_stack (); herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5E_clear, FAIL) if (estack) estack->nused = 0; done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5E_walk * * Purpose: Walks the error stack, calling the specified function for * each error on the stack. The DIRECTION argument determines * whether the stack is walked from the inside out or the * outside in. The value H5E_WALK_UPWARD means begin with the * most specific error and end at the API; H5E_WALK_DOWNWARD * means to start at the API and end at the inner-most function * where the error was first detected. * * The function pointed to by FUNC will be called for each error * in the error stack. It's arguments will include an index * number (beginning at zero regardless of stack traversal * direction), an error stack entry, and the CLIENT_DATA pointer * passed to H5E_print. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Friday, December 12, 1997 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5E_walk (H5E_direction_t direction, H5E_walk_t func, void *client_data) { H5E_t *estack = H5E_get_my_stack (); int i; herr_t status; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5E_walk, FAIL) /* check args, but rather than failing use some default value */ if (direction!=H5E_WALK_UPWARD && direction!=H5E_WALK_DOWNWARD) { direction = H5E_WALK_UPWARD; } /* walk the stack */ assert (estack); if (func && H5E_WALK_UPWARD==direction) { for (i=0, status=SUCCEED; inused && status>=0; i++) { status = (func)(i, estack->slot+i, client_data); } } else if (func && H5E_WALK_DOWNWARD==direction) { for (i=estack->nused-1, status=SUCCEED; i>=0 && status>=0; --i) { status = (func)(estack->nused-(i+1), estack->slot+i, client_data); } } done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5E_dump_api_stack * * Purpose: Private function to dump the error stack during an error in * an API function if a callback function is defined for the * current error stack. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Thursday, January 20, 2005 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5E_dump_api_stack(int is_api) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5E_dump_api_stack, FAIL) /* Only dump the error stack during an API call */ if(is_api) { H5E_t *estack = H5E_get_my_stack(); assert(estack); if (estack->auto_func) (void)((estack->auto_func)(estack->auto_data)); } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } xdmf-3.0+git20160803/Utilities/hdf5/H5Tprivate.h0000640000175000017500000001023313003006557021036 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * This file contains private information about the H5T module */ #ifndef _H5Tprivate_H #define _H5Tprivate_H /* Get package's public header */ #include "H5Tpublic.h" /* Other public headers needed by this file */ #include "H5MMpublic.h" /* Memory management */ /* Private headers needed by this file */ #include "H5private.h" /* Generic Functions */ #include "H5Gprivate.h" /* Groups */ #include "H5Rprivate.h" /* References */ /* Forward references of package typedefs */ typedef struct H5T_t H5T_t; typedef struct H5T_stats_t H5T_stats_t; typedef struct H5T_path_t H5T_path_t; /* How to copy a datatype */ typedef enum H5T_copy_t { H5T_COPY_TRANSIENT, H5T_COPY_ALL, H5T_COPY_REOPEN } H5T_copy_t; /* Location of VL information */ typedef enum { H5T_VLEN_BADLOC = 0, /* invalid VL Type */ H5T_VLEN_MEMORY, /* VL data stored in memory */ H5T_VLEN_DISK, /* VL data stored on disk */ H5T_VLEN_MAXLOC /* highest type (Invalid as true type) */ } H5T_vlen_loc_t; /* VL allocation information */ typedef struct { H5MM_allocate_t alloc_func; /* Allocation function */ void *alloc_info; /* Allocation information */ H5MM_free_t free_func; /* Free function */ void *free_info; /* Free information */ } H5T_vlen_alloc_info_t; /* Private functions */ H5_DLL herr_t H5TN_init_interface(void); H5_DLL herr_t H5T_init(void); H5_DLL htri_t H5T_isa(H5G_entry_t *ent, hid_t dxpl_id); H5_DLL H5T_t *H5T_open(H5G_entry_t *ent, hid_t dxpl_id); H5_DLL H5T_t *H5T_copy(const H5T_t *old_dt, H5T_copy_t method); H5_DLL herr_t H5T_lock(H5T_t *dt, hbool_t immutable); H5_DLL herr_t H5T_close(H5T_t *dt); H5_DLL H5T_class_t H5T_get_class(const H5T_t *dt, htri_t internal); H5_DLL htri_t H5T_detect_class (const H5T_t *dt, H5T_class_t cls); H5_DLL size_t H5T_get_size(const H5T_t *dt); H5_DLL int H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset); H5_DLL herr_t H5T_debug(const H5T_t *dt, FILE * stream); H5_DLL H5G_entry_t *H5T_entof(H5T_t *dt); H5_DLL htri_t H5T_is_immutable(const H5T_t *dt); H5_DLL htri_t H5T_is_named(const H5T_t *dt); H5_DLL htri_t H5T_is_relocatable(const H5T_t *dt); H5_DLL H5T_path_t *H5T_path_find(const H5T_t *src, const H5T_t *dst, const char *name, H5T_conv_t func, hid_t dxpl_id); H5_DLL hbool_t H5T_path_noop(const H5T_path_t *p); H5_DLL H5T_bkg_t H5T_path_bkg(const H5T_path_t *p); H5_DLL herr_t H5T_convert(H5T_path_t *tpath, hid_t src_id, hid_t dst_id, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); H5_DLL herr_t H5T_vlen_reclaim(void *elem, hid_t type_id, unsigned ndim, const hsize_t *point, void *_op_data); H5_DLL herr_t H5T_vlen_get_alloc_info(hid_t dxpl_id, H5T_vlen_alloc_info_t **vl_alloc_info); H5_DLL htri_t H5T_vlen_mark(H5T_t *dt, H5F_t *f, H5T_vlen_loc_t loc); H5_DLL htri_t H5T_is_sensible(const H5T_t *dt); H5_DLL htri_t H5T_committed(const H5T_t *type); H5_DLL int H5T_link(const H5T_t *type, int adjust, hid_t dxpl_id); /* Reference specific functions */ H5_DLL H5R_type_t H5T_get_ref_type(const H5T_t *dt); #endif xdmf-3.0+git20160803/Utilities/hdf5/H5S.c0000640000175000017500000016357513003006557017457 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #define H5S_PACKAGE /*suppress error about including H5Spkg */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5S_init_interface #define _H5S_IN_H5S_C #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free lists */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Oprivate.h" /* Object headers */ #include "H5Spkg.h" /* Dataspaces */ /* Local static function prototypes */ static H5S_t * H5S_create(H5S_class_t type); static herr_t H5S_set_extent_simple (H5S_t *space, unsigned rank, const hsize_t *dims, const hsize_t *max); static htri_t H5S_is_simple(const H5S_t *sdim); #ifdef H5S_DEBUG /* Names of the selection names, for debugging */ static const char *H5S_sel_names[]={ "none", "point", "hyperslab", "all" }; /* The path table, variable length */ static H5S_iostats_t **H5S_iostats_g = NULL; static size_t H5S_aiostats_g = 0; /*entries allocated*/ static size_t H5S_niostats_g = 0; /*entries used*/ #endif /* H5S_DEBUG */ #ifdef H5_HAVE_PARALLEL /* Global vars whose value can be set from environment variable also */ hbool_t H5S_mpi_opt_types_g = TRUE; #endif /* H5_HAVE_PARALLEL */ /* Declare a free list to manage the H5S_extent_t struct */ H5FL_DEFINE(H5S_extent_t); /* Declare a free list to manage the H5S_t struct */ H5FL_DEFINE(H5S_t); /* Declare a free list to manage the array's of hsize_t's */ H5FL_ARR_DEFINE(hsize_t,H5S_MAX_RANK); /*-------------------------------------------------------------------------- NAME H5S_init_interface -- Initialize interface-specific information USAGE herr_t H5S_init_interface() RETURNS Non-negative on success/Negative on failure DESCRIPTION Initializes any interface-specific data or routines. --------------------------------------------------------------------------*/ static herr_t H5S_init_interface(void) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5S_init_interface); /* Initialize the atom group for the file IDs */ if (H5I_init_group(H5I_DATASPACE, H5I_DATASPACEID_HASHSIZE, H5S_RESERVED_ATOMS, (H5I_free_t)H5S_close)<0) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize interface"); #ifdef H5_HAVE_PARALLEL { /* Allow MPI buf-and-file-type optimizations? */ const char *s = HDgetenv ("HDF5_MPI_OPT_TYPES"); if (s && HDisdigit(*s)) H5S_mpi_opt_types_g = (int)HDstrtol (s, NULL, 0); } #endif /* H5_HAVE_PARALLEL */ done: FUNC_LEAVE_NOAPI(ret_value); } /*-------------------------------------------------------------------------- NAME H5S_term_interface PURPOSE Terminate various H5S objects USAGE void H5S_term_interface() RETURNS Non-negative on success/Negative on failure DESCRIPTION Release the atom group and any other resources allocated. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS Can't report errors... EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ int H5S_term_interface(void) { int n=0; #ifdef H5S_DEBUG size_t i; int j, nprints=0; H5S_iostats_t *path=NULL; char buf[256]; #endif /* H5S_DEBUG */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_term_interface); if (H5_interface_initialize_g) { if ((n=H5I_nmembers(H5I_DATASPACE))) { H5I_clear_group(H5I_DATASPACE, FALSE); } else { #ifdef H5S_DEBUG /* * Print statistics about each conversion path. */ if (H5DEBUG(S)) { for (i=0; istats[j].gath_ncalls && 0==path->stats[j].scat_ncalls && 0==path->stats[j].bkg_ncalls && 0==path->stats[j].read_ncalls && 0==path->stats[j].write_ncalls) { continue; } if (0==nprints++) { fprintf(H5DEBUG(S), "H5S: data space conversion " "statistics:\n"); fprintf(H5DEBUG(S), " %-16s %10s %10s %8s %8s %8s %10s\n", "Memory <> File", "Bytes", "Calls", "User", "System", "Elapsed", "Bandwidth"); fprintf(H5DEBUG(S), " %-16s %10s %10s %8s %8s %8s %10s\n", "--------------", "-----", "-----", "----", "------", "-------", "---------"); } /* Summary */ sprintf(buf, "%s %c %s", H5S_sel_names[path->mtype], 0==j?'>':'<', H5S_sel_names[path->ftype]); fprintf(H5DEBUG(S), " %-16s\n", buf); /* Gather */ if (path->stats[j].gath_ncalls) { H5_bandwidth(buf, (double)(path->stats[j].gath_nbytes), path->stats[j].gath_timer.etime); HDfprintf(H5DEBUG(S), " %16s %10Hu %10Hu %8.2f %8.2f %8.2f " "%10s\n", "gather", path->stats[j].gath_nbytes, path->stats[j].gath_ncalls, path->stats[j].gath_timer.utime, path->stats[j].gath_timer.stime, path->stats[j].gath_timer.etime, buf); } /* Scatter */ if (path->stats[j].scat_ncalls) { H5_bandwidth(buf, (double)(path->stats[j].scat_nbytes), path->stats[j].scat_timer.etime); HDfprintf(H5DEBUG(S), " %16s %10Hu %10Hu %8.2f %8.2f %8.2f " "%10s\n", "scatter", path->stats[j].scat_nbytes, path->stats[j].scat_ncalls, path->stats[j].scat_timer.utime, path->stats[j].scat_timer.stime, path->stats[j].scat_timer.etime, buf); } /* Background */ if (path->stats[j].bkg_ncalls) { H5_bandwidth(buf, (double)(path->stats[j].bkg_nbytes), path->stats[j].bkg_timer.etime); HDfprintf(H5DEBUG(S), " %16s %10Hu %10Hu %8.2f %8.2f %8.2f " "%10s\n", "background", path->stats[j].bkg_nbytes, path->stats[j].bkg_ncalls, path->stats[j].bkg_timer.utime, path->stats[j].bkg_timer.stime, path->stats[j].bkg_timer.etime, buf); } /* Read */ if (path->stats[j].read_ncalls) { H5_bandwidth(buf, (double)(path->stats[j].read_nbytes), path->stats[j].read_timer.etime); HDfprintf(H5DEBUG(S), " %16s %10Hu %10Hu %8.2f %8.2f %8.2f " "%10s\n", "read", path->stats[j].read_nbytes, path->stats[j].read_ncalls, path->stats[j].read_timer.utime, path->stats[j].read_timer.stime, path->stats[j].read_timer.etime, buf); } /* Write */ if (path->stats[j].write_ncalls) { H5_bandwidth(buf, (double)(path->stats[j].write_nbytes), path->stats[j].write_timer.etime); HDfprintf(H5DEBUG(S), " %16s %10Hu %10Hu %8.2f %8.2f %8.2f " "%10s\n", "write", path->stats[j].write_nbytes, path->stats[j].write_ncalls, path->stats[j].write_timer.utime, path->stats[j].write_timer.stime, path->stats[j].write_timer.etime, buf); } } } } #endif /* H5S_DEBUG */ /* Free data types */ H5I_destroy_group(H5I_DATASPACE); #ifdef H5S_DEBUG /* Clear/free conversion table */ for (i=0; iextent.type = type; ret_value->extent.rank = 0; ret_value->extent.size = ret_value->extent.max = NULL; switch(type) { case H5S_SCALAR: ret_value->extent.nelem = 1; break; case H5S_SIMPLE: ret_value->extent.nelem = 0; break; default: assert("unknown dataspace (extent) type" && 0); break; } /* end switch */ /* Start with "all" selection */ if(H5S_select_all(ret_value,0)<0) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTSET, NULL, "unable to set all selection"); /* Reset common selection info pointer */ ret_value->select.sel_info.hslab=NULL; } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5S_create() */ /*-------------------------------------------------------------------------- NAME H5Screate PURPOSE Create empty, typed dataspace USAGE hid_t H5Screate(type) H5S_type_t type; IN: Dataspace type to create RETURNS Valid dataspace ID on success, negative on failure DESCRIPTION Creates a new dataspace of a given type. The extent & selection are undefined GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ hid_t H5Screate(H5S_class_t type) { H5S_t *new_ds=NULL; /* New dataspace structure */ hid_t ret_value; /* Return value */ FUNC_ENTER_API(H5Screate, FAIL); H5TRACE1("i","Sc",type); /* Check args */ if(type<=H5S_NO_CLASS || type> H5S_SIMPLE) /* don't allow complex dataspace yet */ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid dataspace type"); if (NULL==(new_ds=H5S_create(type))) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTCREATE, FAIL, "unable to create dataspace"); /* Atomize */ if ((ret_value=H5I_register (H5I_DATASPACE, new_ds))<0) HGOTO_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register data space atom"); done: if (ret_value < 0) { if(new_ds!=NULL) H5S_close(new_ds); } /* end if */ FUNC_LEAVE_API(ret_value); } /* end H5Screate() */ /*------------------------------------------------------------------------- * Function: H5S_extent_release * * Purpose: Releases all memory associated with a dataspace extent. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Thursday, July 23, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5S_extent_release(H5S_extent_t *extent) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5S_extent_release, FAIL); assert(extent); /* Release extent */ if(extent->type==H5S_SIMPLE) { if(extent->size) H5FL_ARR_FREE(hsize_t,extent->size); if(extent->max) H5FL_ARR_FREE(hsize_t,extent->max); } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5S_extent_release() */ /*------------------------------------------------------------------------- * Function: H5S_close * * Purpose: Releases all memory associated with a data space. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Tuesday, December 9, 1997 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5S_close(H5S_t *ds) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5S_close, FAIL); assert(ds); /* Release selection (this should come before the extent release) */ H5S_SELECT_RELEASE(ds); /* Release extent */ H5S_extent_release(&ds->extent); /* Release the main structure */ H5FL_FREE(H5S_t,ds); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5Sclose * * Purpose: Release access to a data space object. * * Return: Non-negative on success/Negative on failure * * Errors: * * Programmer: Robb Matzke * Tuesday, December 9, 1997 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Sclose(hid_t space_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Sclose, FAIL); H5TRACE1("e","i",space_id); /* Check args */ if (NULL == H5I_object_verify(space_id,H5I_DATASPACE)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); /* When the reference count reaches zero the resources are freed */ if (H5I_dec_ref(space_id) < 0) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "problem freeing id"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Scopy * * Purpose: Copies a dataspace. * * Return: Success: ID of the new dataspace * * Failure: Negative * * Programmer: Robb Matzke * Friday, January 30, 1998 * * Modifications: * *------------------------------------------------------------------------- */ hid_t H5Scopy(hid_t space_id) { H5S_t *src = NULL; H5S_t *dst = NULL; hid_t ret_value; FUNC_ENTER_API(H5Scopy, FAIL); H5TRACE1("i","i",space_id); /* Check args */ if (NULL==(src=H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); /* Copy */ if (NULL==(dst=H5S_copy (src, FALSE))) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to copy data space"); /* Atomize */ if ((ret_value=H5I_register (H5I_DATASPACE, dst))<0) HGOTO_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register data space atom"); done: if(ret_value<0) { if(dst!=NULL) H5S_close(dst); } /* end if */ FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Sextent_copy * * Purpose: Copies a dataspace extent. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Thursday, July 23, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Sextent_copy(hid_t dst_id,hid_t src_id) { H5S_t *src = NULL; H5S_t *dst = NULL; hid_t ret_value = SUCCEED; FUNC_ENTER_API(H5Sextent_copy, FAIL); H5TRACE2("e","ii",dst_id,src_id); /* Check args */ if (NULL==(src=H5I_object_verify(src_id, H5I_DATASPACE))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); if (NULL==(dst=H5I_object_verify(dst_id, H5I_DATASPACE))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); /* Copy */ if (H5S_extent_copy(&(dst->extent),&(src->extent))<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy extent"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5S_extent_copy * * Purpose: Copies a dataspace extent * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Wednesday, June 3, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5S_extent_copy(H5S_extent_t *dst, const H5S_extent_t *src) { unsigned u; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5S_extent_copy, FAIL); /* Copy the regular fields */ dst->type=src->type; dst->nelem=src->nelem; dst->rank=src->rank; switch (src->type) { case H5S_SCALAR: dst->size=NULL; dst->max=NULL; break; case H5S_SIMPLE: if (src->size) { dst->size = H5FL_ARR_MALLOC(hsize_t,src->rank); for (u = 0; u < src->rank; u++) dst->size[u] = src->size[u]; } else dst->size=NULL; if (src->max) { dst->max = H5FL_ARR_MALLOC(hsize_t,src->rank); for (u = 0; u < src->rank; u++) dst->max[u] = src->max[u]; } else dst->max=NULL; break; case H5S_COMPLEX: /*void */ break; default: assert("unknown data space type" && 0); break; } done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5S_copy * * Purpose: Copies a data space, by copying the extent and selection through * H5S_extent_copy and H5S_select_copy. If the SHARE_SELECTION flag * is set, then the selection can be shared between the source and * destination dataspaces. (This should only occur in situations * where the destination dataspace will immediately change to a new * selection) * * Return: Success: A pointer to a new copy of SRC * * Failure: NULL * * Programmer: Robb Matzke * Thursday, December 4, 1997 * * Modifications: * *------------------------------------------------------------------------- */ H5S_t * H5S_copy(const H5S_t *src, hbool_t share_selection) { H5S_t *dst = NULL; H5S_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5S_copy, NULL); if (NULL==(dst = H5FL_MALLOC(H5S_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); /* Copy the source dataspace's extent */ if (H5S_extent_copy(&(dst->extent),&(src->extent))<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy extent"); /* Copy the source dataspace's selection */ if (H5S_select_copy(dst,src,share_selection)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy select"); /* Set the return value */ ret_value=dst; done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5S_get_simple_extent_npoints * * Purpose: Determines how many data points a dataset extent has. * * Return: Success: Number of data points in the dataset extent. * * Failure: negative * * Programmer: Robb Matzke * Tuesday, December 9, 1997 * * Note: This routine participates in the "Inlining C function pointers" * pattern, don't call it directly, use the appropriate macro * defined in H5Sprivate.h. * * Modifications: * Changed Name - QAK 7/7/98 * *------------------------------------------------------------------------- */ hssize_t H5S_get_simple_extent_npoints(const H5S_t *ds) { hssize_t ret_value; FUNC_ENTER_NOAPI(H5S_get_simple_extent_npoints, -1); /* check args */ assert(ds); /* Get the number of elements in extent */ ret_value = ds->extent.nelem; done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5Sget_simple_extent_npoints * * Purpose: Determines how many data points a dataset extent has. * * Return: Success: Number of data points in the dataset. * * Failure: negative * * Programmer: Robb Matzke * Tuesday, December 9, 1997 * * Modifications: * Changed Name - QAK 7/7/98 * *------------------------------------------------------------------------- */ hssize_t H5Sget_simple_extent_npoints(hid_t space_id) { H5S_t *ds = NULL; hssize_t ret_value; FUNC_ENTER_API(H5Sget_simple_extent_npoints, FAIL); H5TRACE1("Hs","i",space_id); /* Check args */ if (NULL == (ds = H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); ret_value = H5S_GET_EXTENT_NPOINTS(ds); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5S_get_npoints_max * * Purpose: Determines the maximum number of data points a data space may * have. If the `max' array is null then the maximum number of * data points is the same as the current number of data points * without regard to the hyperslab. If any element of the `max' * array is zero then the maximum possible size is returned. * * Return: Success: Maximum number of data points the data space * may have. * * Failure: 0 * * Programmer: Robb Matzke * Tuesday, December 9, 1997 * * Modifications: * *------------------------------------------------------------------------- */ hsize_t H5S_get_npoints_max(const H5S_t *ds) { hsize_t ret_value; unsigned u; FUNC_ENTER_NOAPI(H5S_get_npoints_max, 0); /* check args */ assert(ds); switch (H5S_GET_EXTENT_TYPE(ds)) { case H5S_SCALAR: ret_value = 1; break; case H5S_SIMPLE: if (ds->extent.max) { for (ret_value=1, u=0; uextent.rank; u++) { if (H5S_UNLIMITED==ds->extent.max[u]) { ret_value = HSIZET_MAX; break; } else ret_value *= ds->extent.max[u]; } } else { for (ret_value=1, u=0; uextent.rank; u++) ret_value *= ds->extent.size[u]; } break; case H5S_COMPLEX: HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, 0, "complex data spaces are not supported yet"); default: assert("unknown data space class" && 0); HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, 0, "internal error (unknown data space class)"); } done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5Sget_simple_extent_ndims * * Purpose: Determines the dimensionality of a data space. * * Return: Success: The number of dimensions in a data space. * * Failure: Negative * * Programmer: Robb Matzke * Thursday, December 11, 1997 * * Modifications: * *------------------------------------------------------------------------- */ int H5Sget_simple_extent_ndims(hid_t space_id) { H5S_t *ds = NULL; int ret_value; FUNC_ENTER_API(H5Sget_simple_extent_ndims, FAIL); H5TRACE1("Is","i",space_id); /* Check args */ if (NULL == (ds = H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); ret_value = H5S_GET_EXTENT_NDIMS(ds); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5S_get_simple_extent_ndims * * Purpose: Returns the number of dimensions in a data space. * * Return: Success: Non-negative number of dimensions. Zero * implies a scalar. * * Failure: Negative * * Programmer: Robb Matzke * Thursday, December 11, 1997 * * Note: This routine participates in the "Inlining C function pointers" * pattern, don't call it directly, use the appropriate macro * defined in H5Sprivate.h. * * Modifications: * *------------------------------------------------------------------------- */ int H5S_get_simple_extent_ndims(const H5S_t *ds) { int ret_value; FUNC_ENTER_NOAPI(H5S_get_simple_extent_ndims, FAIL); /* check args */ assert(ds); switch (H5S_GET_EXTENT_TYPE(ds)) { case H5S_SCALAR: case H5S_SIMPLE: ret_value = ds->extent.rank; break; case H5S_COMPLEX: HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "complex data spaces are not supported yet"); default: assert("unknown data space class" && 0); HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "internal error (unknown data space class)"); } done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5Sget_simple_extent_dims * * Purpose: Returns the size and maximum sizes in each dimension of * a data space DS through the DIMS and MAXDIMS arguments. * * Return: Success: Number of dimensions, the same value as * returned by H5Sget_simple_extent_ndims(). * * Failure: Negative * * Programmer: Robb Matzke * Thursday, December 11, 1997 * * Modifications: * June 18, 1998 Albert Cheng * Added maxdims argument. Removed dims argument check * since it can still return ndims even if both dims and * maxdims are NULLs. * *------------------------------------------------------------------------- */ int H5Sget_simple_extent_dims(hid_t space_id, hsize_t dims[]/*out*/, hsize_t maxdims[]/*out*/) { H5S_t *ds = NULL; int ret_value; FUNC_ENTER_API(H5Sget_simple_extent_dims, FAIL); H5TRACE3("Is","ixx",space_id,dims,maxdims); /* Check args */ if (NULL == (ds = H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace"); ret_value = H5S_get_simple_extent_dims(ds, dims, maxdims); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5S_get_simple_extent_dims * * Purpose: Returns the size in each dimension of a data space. This * function may not be meaningful for all types of data spaces. * * Return: Success: Number of dimensions. Zero implies scalar. * * Failure: Negative * * Programmer: Robb Matzke * Thursday, December 11, 1997 * * Modifications: * *------------------------------------------------------------------------- */ int H5S_get_simple_extent_dims(const H5S_t *ds, hsize_t dims[], hsize_t max_dims[]) { int ret_value; int i; FUNC_ENTER_NOAPI(H5S_get_simple_extent_dims, FAIL); /* check args */ assert(ds); switch (H5S_GET_EXTENT_TYPE(ds)) { case H5S_SCALAR: ret_value = 0; break; case H5S_SIMPLE: ret_value = ds->extent.rank; for (i=0; iextent.size[i]; if (max_dims) { if (ds->extent.max) max_dims[i] = ds->extent.max[i]; else max_dims[i] = ds->extent.size[i]; } } break; case H5S_COMPLEX: HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "complex data spaces are not supported yet"); default: assert("unknown data space class" && 0); HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "internal error (unknown data space class)"); } done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5S_modify * * Purpose: Updates a data space by writing a message to an object * header. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Tuesday, December 9, 1997 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5S_modify(H5G_entry_t *ent, const H5S_t *ds, hbool_t update_time, hid_t dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5S_modify, FAIL); assert(ent); assert(ds); switch (H5S_GET_EXTENT_TYPE(ds)) { case H5S_SCALAR: case H5S_SIMPLE: if (H5O_modify(ent, H5O_SDSPACE_ID, 0, 0, update_time, &(ds->extent), dxpl_id)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't update simple data space message"); break; case H5S_COMPLEX: HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "complex data spaces are not implemented yet"); default: assert("unknown data space class" && 0); break; } done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5S_append * * Purpose: Updates a data space by adding a message to an object * header. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Tuesday, December 31, 2002 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5S_append(H5F_t *f, hid_t dxpl_id, struct H5O_t *oh, const H5S_t *ds) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5S_append, FAIL); assert(f); assert(oh); assert(ds); switch (H5S_GET_EXTENT_TYPE(ds)) { case H5S_SCALAR: case H5S_SIMPLE: if (H5O_append(f, dxpl_id, oh, H5O_SDSPACE_ID, 0, &(ds->extent))<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't update simple data space message"); break; case H5S_COMPLEX: HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "complex data spaces are not implemented yet"); default: assert("unknown data space class" && 0); break; } done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5S_append() */ /*------------------------------------------------------------------------- * Function: H5S_read * * Purpose: Reads the data space from an object header. * * Return: Success: Pointer to a new data space. * * Failure: NULL * * Programmer: Robb Matzke * Tuesday, December 9, 1997 * * Modifications: * Robb Matzke, 9 Jun 1998 * Removed the unused file argument since the file is now part of the * ENT argument. *------------------------------------------------------------------------- */ H5S_t * H5S_read(const H5G_entry_t *ent, hid_t dxpl_id) { H5S_t *ds = NULL; /* Dataspace to return */ H5S_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5S_read, NULL); /* check args */ assert(ent); if (NULL==(ds = H5FL_CALLOC(H5S_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); if (H5O_read(ent, H5O_SDSPACE_ID, 0, &(ds->extent), dxpl_id) == NULL) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, NULL, "unable to load dataspace info from dataset header"); /* Default to entire dataspace being selected */ if(H5S_select_all(ds,0)<0) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTSET, NULL, "unable to set all selection"); /* Set the value for successful return */ ret_value=ds; done: if(ret_value==NULL) { if(ds!=NULL) H5FL_FREE(H5S_t,ds); } /* end if */ FUNC_LEAVE_NOAPI(ret_value); } /*-------------------------------------------------------------------------- NAME H5S_is_simple PURPOSE Check if a dataspace is simple (internal) USAGE htri_t H5S_is_simple(sdim) H5S_t *sdim; IN: Pointer to dataspace object to query RETURNS TRUE/FALSE/FAIL DESCRIPTION This function determines the if a dataspace is "simple". ie. if it has orthogonal, evenly spaced dimensions. --------------------------------------------------------------------------*/ static htri_t H5S_is_simple(const H5S_t *sdim) { htri_t ret_value; FUNC_ENTER_NOAPI(H5S_is_simple, FAIL); /* Check args and all the boring stuff. */ assert(sdim); ret_value = (H5S_GET_EXTENT_TYPE(sdim) == H5S_SIMPLE || H5S_GET_EXTENT_TYPE(sdim) == H5S_SCALAR) ? TRUE : FALSE; done: FUNC_LEAVE_NOAPI(ret_value); } /*-------------------------------------------------------------------------- NAME H5Sis_simple PURPOSE Check if a dataspace is simple USAGE htri_t H5Sis_simple(space_id) hid_t space_id; IN: ID of dataspace object to query RETURNS TRUE/FALSE/FAIL DESCRIPTION This function determines the if a dataspace is "simple". ie. if it has orthogonal, evenly spaced dimensions. --------------------------------------------------------------------------*/ htri_t H5Sis_simple(hid_t space_id) { H5S_t *space = NULL; /* dataspace to modify */ htri_t ret_value; FUNC_ENTER_API(H5Sis_simple, FAIL); H5TRACE1("t","i",space_id); /* Check args and all the boring stuff. */ if ((space = H5I_object_verify(space_id,H5I_DATASPACE)) == NULL) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space"); ret_value = H5S_is_simple(space); done: FUNC_LEAVE_API(ret_value); } /*-------------------------------------------------------------------------- NAME H5Sset_extent_simple PURPOSE Sets the size of a simple dataspace USAGE herr_t H5Sset_extent_simple(space_id, rank, dims, max) hid_t space_id; IN: Dataspace object to query int rank; IN: # of dimensions for the dataspace const size_t *dims; IN: Size of each dimension for the dataspace const size_t *max; IN: Maximum size of each dimension for the dataspace RETURNS Non-negative on success/Negative on failure DESCRIPTION This function sets the number and size of each dimension in the dataspace. Setting RANK to a value of zero converts the dataspace to a scalar dataspace. Dimensions are specified from slowest to fastest changing in the DIMS array (i.e. 'C' order). Setting the size of a dimension in the MAX array to zero indicates that the dimension is of unlimited size and should be allowed to expand. If MAX is NULL, the dimensions in the DIMS array are used as the maximum dimensions. Currently, only the first dimension in the array (the slowest) may be unlimited in size. --------------------------------------------------------------------------*/ herr_t H5Sset_extent_simple(hid_t space_id, int rank, const hsize_t dims[/*rank*/], const hsize_t max[/*rank*/]) { H5S_t *space = NULL; /* dataspace to modify */ int u; /* local counting variable */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Sset_extent_simple, FAIL); H5TRACE4("e","iIs*[a1]h*[a1]h",space_id,rank,dims,max); /* Check args */ if ((space = H5I_object_verify(space_id,H5I_DATASPACE)) == NULL) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space"); if (rank > 0 && dims == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no dimensions specified"); if (rank<0 || rank>H5S_MAX_RANK) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid rank"); if (dims) { for (u=0; uextent)<0) HGOTO_ERROR (H5E_RESOURCE, H5E_CANTFREE, FAIL, "failed to release previous dataspace extent"); if (rank == 0) { /* scalar variable */ space->extent.type = H5S_SCALAR; space->extent.nelem = 1; space->extent.rank = 0; /* set to scalar rank */ } else { hsize_t nelem; /* Number of elements in extent */ space->extent.type = H5S_SIMPLE; /* Set the rank and allocate space for the dims */ space->extent.rank = rank; space->extent.size = H5FL_ARR_MALLOC(hsize_t,rank); /* Copy the dimensions & compute the number of elements in the extent */ for(u=0, nelem=1; uextent.rank; u++) { space->extent.size[u]=dims[u]; nelem*=dims[u]; } /* end for */ space->extent.nelem = nelem; /* Copy the maximum dimensions if specified */ if(max!=NULL) { space->extent.max = H5FL_ARR_MALLOC(hsize_t,rank); HDmemcpy(space->extent.max, max, sizeof(hsize_t) * rank); } /* end if */ else { space->extent.max = NULL; } } /* Selection related cleanup */ /* Set offset to zeros */ for(u=0; uextent.rank; u++) space->select.offset[u]=0; /* If the selection is 'all', update the number of elements selected */ if(H5S_GET_SELECT_TYPE(space)==H5S_SEL_ALL) if(H5S_select_all(space, FALSE)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection"); done: FUNC_LEAVE_NOAPI(ret_value); } #ifdef H5S_DEBUG /*------------------------------------------------------------------------- * Function: H5S_find * * Purpose: Given two data spaces (MEM_SPACE and FILE_SPACE) this * function returns a pointer to the conversion path information, * creating a new conversion path entry if necessary. * * Return: Success: Ptr to a conversion path entry * * Failure: NULL * * Programmer: Robb Matzke * Wednesday, January 21, 1998 * * Modifications: * * Quincey Koziol * Instead of returning a point into the data space conversion table we * copy all the information into a user-supplied CONV buffer and return * non-negative on success or negative on failure. * * Robb Matzke, 11 Aug 1998 * Returns a pointer into the conversion path table. A path entry * contains pointers to the memory and file half of the conversion (the * pointers registered in the H5S_fconv_g[] and H5S_mconv_g[] tables) * along with other data whose scope is the conversion path (like path * statistics). * * John Mainzer, 8/30/04 * Modified code to check with all other processes that have the * file open before OKing collective I/O. * *------------------------------------------------------------------------- */ H5S_iostats_t * H5S_find (const H5S_t *mem_space, const H5S_t *file_space) { H5S_iostats_t *path=NULL; /* Space conversion path */ size_t u; /* Index variable */ H5S_iostats_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5S_find, NULL); /* Check args */ assert (mem_space && (H5S_SIMPLE==H5S_GET_EXTENT_TYPE(mem_space) || H5S_SCALAR==H5S_GET_EXTENT_TYPE(mem_space))); assert (file_space && (H5S_SIMPLE==H5S_GET_EXTENT_TYPE(file_space) || H5S_SCALAR==H5S_GET_EXTENT_TYPE(file_space))); /* * Is this path already present in the data space conversion path table? * If so then return a pointer to that entry. */ for (u=0; uftype==H5S_GET_SELECT_TYPE(file_space) && H5S_iostats_g[u]->mtype==H5S_GET_SELECT_TYPE(mem_space)) HGOTO_DONE(H5S_iostats_g[u]); /* * The path wasn't found. Create a new path. */ if (NULL==(path = H5MM_calloc(sizeof(*path)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for data space conversion path"); /* Initialize file & memory conversion functions */ path->ftype = H5S_GET_SELECT_TYPE(file_space); path->mtype = H5S_GET_SELECT_TYPE(mem_space); /* * Add the new path to the table. */ if (H5S_niostats_g>=H5S_aiostats_g) { size_t n = MAX(10, 2*H5S_aiostats_g); H5S_iostats_t **p = H5MM_realloc(H5S_iostats_g, n*sizeof(H5S_iostats_g[0])); if (NULL==p) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for data space conversion path table"); H5S_aiostats_g = n; H5S_iostats_g = p; } /* end if */ H5S_iostats_g[H5S_niostats_g++] = path; /* Set the return value */ ret_value=path; done: if(ret_value==NULL) { if(path!=NULL) H5MM_xfree(path); } /* end if */ FUNC_LEAVE_NOAPI(ret_value); } /* end H5S_find() */ #endif /* H5S_DEBUG */ /*------------------------------------------------------------------------- * Function: H5S_extend * * Purpose: Extend the dimensions of a data space. * * Return: Success: Number of dimensions whose size increased. * * Failure: Negative * * Programmer: Robb Matzke * Friday, January 30, 1998 * * Modifications: * *------------------------------------------------------------------------- */ int H5S_extend (H5S_t *space, const hsize_t *size) { int ret_value=0; unsigned u; FUNC_ENTER_NOAPI(H5S_extend, FAIL); /* Check args */ assert (space && H5S_SIMPLE==H5S_GET_EXTENT_TYPE(space)); assert (size); /* Check through all the dimensions to see if modifying the dataspace is allowed */ for (u=0; uextent.rank; u++) { if (space->extent.size[u]extent.max && H5S_UNLIMITED!=space->extent.max[u] && space->extent.max[u]extent.rank; u++) { if (space->extent.size[u]extent.size[u] = size[u]; nelem*=space->extent.size[u]; } space->extent.nelem = nelem; /* If the selection is 'all', update the number of elements selected */ if(H5S_GET_SELECT_TYPE(space)==H5S_SEL_ALL) if(H5S_select_all(space, FALSE)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection"); } done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5Screate_simple * * Purpose: Creates a new simple data space object and opens it for * access. The DIMS argument is the size of the simple dataset * and the MAXDIMS argument is the upper limit on the size of * the dataset. MAXDIMS may be the null pointer in which case * the upper limit is the same as DIMS. If an element of * MAXDIMS is H5S_UNLIMITED then the corresponding dimension is * unlimited, otherwise no element of MAXDIMS should be smaller * than the corresponding element of DIMS. * * Return: Success: The ID for the new simple data space object. * * Failure: Negative * * Errors: * * Programmer: Quincey Koziol * Tuesday, January 27, 1998 * * Modifications: * *------------------------------------------------------------------------- */ hid_t H5Screate_simple(int rank, const hsize_t dims[/*rank*/], const hsize_t maxdims[/*rank*/]) { hid_t ret_value; H5S_t *space = NULL; int i; FUNC_ENTER_API(H5Screate_simple, FAIL); H5TRACE3("i","Is*[a0]h*[a0]h",rank,dims,maxdims); /* Check arguments */ if (rank<0) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "dimensionality cannot be negative"); if (rank>H5S_MAX_RANK) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dimensionality is too large"); if (!dims && dims!=0) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no dimensions specified"); /* Check whether the current dimensions are valid */ for (i=0; iextent)); done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5S_raw_size() */ /*------------------------------------------------------------------------- * Function: H5S_get_simple_extent_type * * Purpose: Internal function for retrieving the type of extent for a dataspace object * * Return: Success: The class of the dataspace object * * Failure: N5S_NO_CLASS * * Errors: * * Programmer: Quincey Koziol * Thursday, September 28, 2000 * * Note: This routine participates in the "Inlining C function pointers" * pattern, don't call it directly, use the appropriate macro * defined in H5Sprivate.h. * * Modifications: * *------------------------------------------------------------------------- */ H5S_class_t H5S_get_simple_extent_type(const H5S_t *space) { H5S_class_t ret_value; FUNC_ENTER_NOAPI(H5S_get_simple_extent_type, H5S_NO_CLASS); assert(space); ret_value=H5S_GET_EXTENT_TYPE(space); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5Sget_simple_extent_type * * Purpose: Retrieves the type of extent for a dataspace object * * Return: Success: The class of the dataspace object * * Failure: N5S_NO_CLASS * * Errors: * * Programmer: Quincey Koziol * Thursday, July 23, 1998 * * Modifications: * *------------------------------------------------------------------------- */ H5S_class_t H5Sget_simple_extent_type(hid_t sid) { H5S_class_t ret_value; H5S_t *space; FUNC_ENTER_API(H5Sget_simple_extent_type, H5S_NO_CLASS); H5TRACE1("Sc","i",sid); /* Check arguments */ if (NULL == (space = H5I_object_verify(sid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5S_NO_CLASS, "not a dataspace"); ret_value=H5S_GET_EXTENT_TYPE(space); done: FUNC_LEAVE_API(ret_value); } /*-------------------------------------------------------------------------- NAME H5Sset_extent_none PURPOSE Resets the extent of a dataspace back to "none" USAGE herr_t H5Sset_extent_none(space_id) hid_t space_id; IN: Dataspace object to reset RETURNS Non-negative on success/Negative on failure DESCRIPTION This function resets the type of a dataspace back to "none" with no extent information stored for the dataspace. --------------------------------------------------------------------------*/ herr_t H5Sset_extent_none(hid_t space_id) { H5S_t *space = NULL; /* dataspace to modify */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Sset_extent_none, FAIL); H5TRACE1("e","i",space_id); /* Check args */ if (NULL == (space = H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space"); /* Clear the previous extent from the dataspace */ if(H5S_extent_release(&space->extent)<0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTDELETE, FAIL, "can't release previous dataspace"); space->extent.type=H5S_NO_CLASS; done: FUNC_LEAVE_API(ret_value); } /* end H5Sset_extent_none() */ /*-------------------------------------------------------------------------- NAME H5Soffset_simple PURPOSE Changes the offset of a selection within a simple dataspace extent USAGE herr_t H5Soffset_simple(space_id, offset) hid_t space_id; IN: Dataspace object to reset const hssize_t *offset; IN: Offset to position the selection at RETURNS Non-negative on success/Negative on failure DESCRIPTION This function creates an offset for the selection within an extent, allowing the same shaped selection to be moved to different locations within a dataspace without requiring it to be re-defined. --------------------------------------------------------------------------*/ herr_t H5Soffset_simple(hid_t space_id, const hssize_t *offset) { H5S_t *space = NULL; /* dataspace to modify */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Soffset_simple, FAIL); H5TRACE2("e","i*Hs",space_id,offset); /* Check args */ if (NULL == (space = H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space"); if (space->extent.rank==0 || H5S_GET_EXTENT_TYPE(space)==H5S_SCALAR) HGOTO_ERROR(H5E_ATOM, H5E_UNSUPPORTED, FAIL, "can't set offset on scalar dataspace"); if (offset == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no offset specified"); /* Set the selection offset */ if(H5S_select_offset(space,offset)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't set offset"); done: FUNC_LEAVE_API(ret_value); } /* end H5Soffset_simple() */ /*------------------------------------------------------------------------- * Function: H5S_set_extent * * Purpose: Modify the dimensions of a data space. Based on H5S_extend * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu * * Date: March 13, 2002 * *------------------------------------------------------------------------- */ int H5S_set_extent( H5S_t *space, const hsize_t *size ) { unsigned u; herr_t ret_value=0; FUNC_ENTER_NOAPI( H5S_set_extent, FAIL ); /* Check args */ assert( space && H5S_SIMPLE==H5S_GET_EXTENT_TYPE(space) ); assert( size); /* Verify that the dimensions being changed are allowed to change */ for ( u = 0; u < space->extent.rank; u++ ) { if ( space->extent.max && H5S_UNLIMITED != space->extent.max[u] && space->extent.max[u]!=size[u] ) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,"dimension cannot be modified"); ret_value++; } /* end for */ /* Update */ if (ret_value) H5S_set_extent_real(space,size); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5S_has_extent * * Purpose: Determines if a simple dataspace's extent has been set (e.g., * by H5Sset_extent_simple() ). Helps avoid write errors. * * Return: TRUE if dataspace has extent set * FALSE if dataspace's extent is uninitialized * * Programmer: James Laird * * Date: July 23, 2004 * *------------------------------------------------------------------------- */ hbool_t H5S_has_extent(const H5S_t *ds) { htri_t ret_value; FUNC_ENTER_NOAPI(H5S_has_extent, FAIL) assert(ds); if(ds->extent.rank==0 && ds->extent.nelem == 0) ret_value = FALSE; else ret_value = TRUE; done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5S_set_extent_real * * Purpose: Modify the dimensions of a data space. Based on H5S_extend * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu * * Date: March 13, 2002 * *------------------------------------------------------------------------- */ herr_t H5S_set_extent_real( H5S_t *space, const hsize_t *size ) { hsize_t nelem; /* Number of elements in extent */ unsigned u; /* Local index variable */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5S_set_extent_real, FAIL ); /* Check args */ assert(space && H5S_SIMPLE==H5S_GET_EXTENT_TYPE(space)); assert(size); /* Change the dataspace size & re-compute the number of elements in the extent */ for (u=0, nelem=1; u < space->extent.rank; u++ ) { space->extent.size[u] = size[u]; nelem*=space->extent.size[u]; } /* end for */ space->extent.nelem = nelem; /* If the selection is 'all', update the number of elements selected */ if(H5S_GET_SELECT_TYPE(space)==H5S_SEL_ALL) if(H5S_select_all(space, FALSE)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection"); done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5S_set_extent_real() */ /*------------------------------------------------------------------------- * Function: H5S_debug * * Purpose: Prints debugging information about a data space. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Tuesday, July 21, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5S_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE *stream, int indent, int fwidth) { const H5S_t *mesg = (const H5S_t*)_mesg; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5S_debug, FAIL); switch (H5S_GET_EXTENT_TYPE(mesg)) { case H5S_SCALAR: fprintf(stream, "%*s%-*s H5S_SCALAR\n", indent, "", fwidth, "Space class:"); break; case H5S_SIMPLE: fprintf(stream, "%*s%-*s H5S_SIMPLE\n", indent, "", fwidth, "Space class:"); H5O_debug_id(H5O_SDSPACE_ID, f, dxpl_id, &(mesg->extent), stream, indent+3, MAX(0, fwidth-3)); break; default: fprintf(stream, "%*s%-*s **UNKNOWN-%ld**\n", indent, "", fwidth, "Space class:", (long)(H5S_GET_EXTENT_TYPE(mesg))); break; } done: FUNC_LEAVE_NOAPI(ret_value); } xdmf-3.0+git20160803/Utilities/hdf5/H5Ocont.c0000640000175000017500000001747713003006557020336 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*------------------------------------------------------------------------- * * Created: H5Ocont.c * Aug 6 1997 * Robb Matzke * * Purpose: The object header continuation message. This * message is only generated and read from within * the H5O package. Therefore, do not change * any definitions in this file! * * Modifications: * *------------------------------------------------------------------------- */ #define H5O_PACKAGE /*suppress error about including H5Opkg */ #include "H5private.h" #include "H5Eprivate.h" #include "H5FLprivate.h" /* Free Lists */ #include "H5MMprivate.h" #include "H5Opkg.h" /* Object header functions */ /* PRIVATE PROTOTYPES */ static void *H5O_cont_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t *sh); static herr_t H5O_cont_encode(H5F_t *f, uint8_t *p, const void *_mesg); static size_t H5O_cont_size(const H5F_t *f, const void *_mesg); static herr_t H5O_cont_free(void *mesg); static herr_t H5O_cont_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * stream, int indent, int fwidth); /* This message derives from H5O */ const H5O_class_t H5O_CONT[1] = {{ H5O_CONT_ID, /*message id number */ "hdr continuation", /*message name for debugging */ sizeof(H5O_cont_t), /*native message size */ H5O_cont_decode, /*decode message */ H5O_cont_encode, /*encode message */ NULL, /*no copy method */ H5O_cont_size, /*size of header continuation */ NULL, /*reset method */ H5O_cont_free, /* free method */ NULL, /* file delete method */ NULL, /* link method */ NULL, /*get share method */ NULL, /*set share method */ H5O_cont_debug, /*debugging */ }}; /* Declare the free list for H5O_cont_t's */ H5FL_DEFINE(H5O_cont_t); /*------------------------------------------------------------------------- * Function: H5O_cont_decode * * Purpose: Decode the raw header continuation message. * * Return: Success: Ptr to the new native message * * Failure: NULL * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 6 1997 * * Modifications: * *------------------------------------------------------------------------- */ static void * H5O_cont_decode(H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *p, H5O_shared_t UNUSED *sh) { H5O_cont_t *cont = NULL; void *ret_value; FUNC_ENTER_NOAPI_NOINIT(H5O_cont_decode); /* check args */ assert(f); assert(p); assert (!sh); /* decode */ if (NULL==(cont = H5FL_MALLOC(H5O_cont_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); H5F_addr_decode(f, &p, &(cont->addr)); H5F_DECODE_LENGTH(f, p, cont->size); cont->chunkno=0; /* Set return value */ ret_value=cont; done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_cont_encode * * Purpose: Encodes a continuation message. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 7 1997 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_cont_encode(H5F_t *f, uint8_t *p, const void *_mesg) { const H5O_cont_t *cont = (const H5O_cont_t *) _mesg; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_cont_encode); /* check args */ assert(f); assert(p); assert(cont); /* encode */ H5F_addr_encode(f, &p, cont->addr); H5F_ENCODE_LENGTH(f, p, cont->size); FUNC_LEAVE_NOAPI(SUCCEED); } /*------------------------------------------------------------------------- * Function: H5O_cont_size * * Purpose: Returns the size of the raw message in bytes not counting * the message type or size fields, but only the data fields. * This function doesn't take into account alignment. * * Return: Success: Message data size in bytes without alignment. * * Failure: zero * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * Sep 6 2005 * * Modifications: * *------------------------------------------------------------------------- */ static size_t H5O_cont_size(const H5F_t *f, const void UNUSED *_mesg) { size_t ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_cont_size) /* Set return value */ ret_value = H5F_SIZEOF_ADDR(f) + /* Continuation header address */ H5F_SIZEOF_SIZE(f); /* Continuation header length */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_cont_size() */ /*------------------------------------------------------------------------- * Function: H5O_cont_free * * Purpose: Free's the message * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Monday, November 15, 2004 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_cont_free (void *mesg) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_cont_free); assert (mesg); H5FL_FREE(H5O_cont_t,mesg); FUNC_LEAVE_NOAPI(SUCCEED); } /* end H5O_cont_free() */ /*------------------------------------------------------------------------- * Function: H5O_cont_debug * * Purpose: Prints debugging info. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 6 1997 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_cont_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg, FILE * stream, int indent, int fwidth) { const H5O_cont_t *cont = (const H5O_cont_t *) _mesg; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_cont_debug); /* check args */ assert(f); assert(cont); assert(stream); assert(indent >= 0); assert(fwidth >= 0); HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "Continuation address:", cont->addr); HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, "Continuation size in bytes:", (unsigned long) (cont->size)); HDfprintf(stream, "%*s%-*s %d\n", indent, "", fwidth, "Points to chunk number:", (int) (cont->chunkno)); FUNC_LEAVE_NOAPI(SUCCEED); } xdmf-3.0+git20160803/Utilities/hdf5/H5Iprivate.h0000640000175000017500000000620013003006557021022 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*----------------------------------------------------------------------------- * File: H5Iprivate.h * Purpose: header file for ID API *---------------------------------------------------------------------------*/ /* avoid re-inclusion */ #ifndef _H5Iprivate_H #define _H5Iprivate_H /* Include package's public header */ #include "H5Ipublic.h" /* Private headers needed by this file */ #include "H5private.h" /* Default sizes of the hash-tables for various atom groups */ #define H5I_ERRSTACK_HASHSIZE 64 #define H5I_FILEID_HASHSIZE 64 #define H5I_TEMPID_HASHSIZE 64 #define H5I_DATATYPEID_HASHSIZE 64 #define H5I_DATASPACEID_HASHSIZE 64 #define H5I_DATASETID_HASHSIZE 64 #define H5I_OID_HASHSIZE 64 #define H5I_GROUPID_HASHSIZE 64 #define H5I_ATTRID_HASHSIZE 64 #define H5I_REFID_HASHSIZE 64 #define H5I_VFL_HASHSIZE 64 #define H5I_GENPROPCLS_HASHSIZE 64 #define H5I_GENPROPOBJ_HASHSIZE 128 /* * Function for freeing objects. This function will be called with an object * ID group number (object type) and a pointer to the object. The function * should free the object and return non-negative to indicate that the object * can be removed from the ID group. If the function returns negative * (failure) then the object will remain in the ID group. */ typedef herr_t (*H5I_free_t)(void*); /* Type of the function to compare objects & keys */ typedef int (*H5I_search_func_t)(void *obj, hid_t id, void *key); /* Private Functions in H5I.c */ H5_DLL int H5I_init_group(H5I_type_t grp, size_t hash_size, unsigned reserved, H5I_free_t func); H5_DLL int H5I_nmembers(H5I_type_t grp); H5_DLL herr_t H5I_clear_group(H5I_type_t grp, hbool_t force); H5_DLL herr_t H5I_destroy_group(H5I_type_t grp); H5_DLL hid_t H5I_register(H5I_type_t grp, void *object); H5_DLL void *H5I_object(hid_t id); H5_DLL void *H5I_object_verify(hid_t id, H5I_type_t id_type); H5_DLL H5I_type_t H5I_get_type(hid_t id); H5_DLL void *H5I_remove(hid_t id); H5_DLL void *H5I_search(H5I_type_t grp, H5I_search_func_t func, void *key); H5_DLL int H5I_get_ref(hid_t id); H5_DLL int H5I_inc_ref(hid_t id); H5_DLL int H5I_dec_ref(hid_t id); #endif xdmf-3.0+git20160803/Utilities/hdf5/H5G.c0000640000175000017500000041201313003006557017423 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*------------------------------------------------------------------------- * * Created: H5G.c * Jul 18 1997 * Robb Matzke * * Purpose: Symbol table functions. The functions that begin with * `H5G_stab_' don't understand the naming system; they operate * on a single symbol table at a time. * * The functions that begin with `H5G_node_' operate on the leaf * nodes of a symbol table B-tree. They should be defined in * the H5Gnode.c file. * * The remaining functions know how to traverse the group * directed graph. * * Names: Object names are a slash-separated list of components. If * the name begins with a slash then it's absolute, otherwise * it's relative ("/foo/bar" is absolute while "foo/bar" is * relative). Multiple consecutive slashes are treated as * single slashes and trailing slashes are ignored. The special * case `/' is the root group. Every file has a root group. * * API functions that look up names take a location ID and a * name. The location ID can be a file ID or a group ID and the * name can be relative or absolute. * * +--------------+----------- +--------------------------------+ * | Location ID | Name | Meaning | * +--------------+------------+--------------------------------+ * | File ID | "/foo/bar" | Find `foo' within `bar' within | * | | | the root group of the specified| * | | | file. | * +--------------+------------+--------------------------------+ * | File ID | "foo/bar" | Find `foo' within `bar' within | * | | | the current working group of | * | | | the specified file. | * +--------------+------------+--------------------------------+ * | File ID | "/" | The root group of the specified| * | | | file. | * +--------------+------------+--------------------------------+ * | File ID | "." | The current working group of | * | | | the specified file. | * +--------------+------------+--------------------------------+ * | Group ID | "/foo/bar" | Find `foo' within `bar' within | * | | | the root group of the file | * | | | containing the specified group.| * +--------------+------------+--------------------------------+ * | Group ID | "foo/bar" | File `foo' within `bar' within | * | | | the specified group. | * +--------------+------------+--------------------------------+ * | Group ID | "/" | The root group of the file | * | | | containing the specified group.| * +--------------+------------+--------------------------------+ * | Group ID | "." | The specified group. | * +--------------+------------+--------------------------------+ * * * Modifications: * * Robb Matzke, 5 Aug 1997 * Added calls to H5E. * * Robb Matzke, 30 Aug 1997 * Added `Errors:' field to function prologues. * * Pedro Vicente, 22 Aug 2002 * Added `id to name' support. * *------------------------------------------------------------------------- */ #define H5G_PACKAGE /*suppress error about including H5Gpkg */ #define H5F_PACKAGE /*suppress error about including H5Fpkg */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5G_init_interface /* Packages needed by this file... */ #include "H5private.h" /* Generic Functions */ #include "H5Aprivate.h" /* Attributes */ #include "H5Dprivate.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* File access */ #include "H5FLprivate.h" /* Free Lists */ #include "H5Gpkg.h" /* Groups */ #include "H5HLprivate.h" /* Local Heaps */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ /* Local macros */ #define H5G_INIT_HEAP 8192 #define H5G_RESERVED_ATOMS 0 #define H5G_SIZE_HINT 256 /*default root grp size hint */ /* * During name lookups (see H5G_namei()) we sometimes want information about * a symbolic link or a mount point. The normal operation is to follow the * symbolic link or mount point and return information about its target. */ #define H5G_TARGET_NORMAL 0x0000 #define H5G_TARGET_SLINK 0x0001 #define H5G_TARGET_MOUNT 0x0002 /* Local typedefs */ /* Struct only used by change name callback function */ typedef struct H5G_names_t { H5G_entry_t *loc; H5RS_str_t *src_name; H5G_entry_t *src_loc; H5RS_str_t *dst_name; H5G_entry_t *dst_loc; H5G_names_op_t op; } H5G_names_t; /* Enum for H5G_namei actions */ typedef enum { H5G_NAMEI_TRAVERSE, /* Just traverse groups */ H5G_NAMEI_INSERT /* Insert entry in group */ } H5G_namei_act_t ; /* * This table contains a list of object types, descriptions, and the * functions that determine if some object is a particular type. The table * is allocated dynamically. */ typedef struct H5G_typeinfo_t { int type; /*one of the public H5G_* types */ htri_t (*isa)(H5G_entry_t*, hid_t); /*function to determine type */ char *desc; /*description of object type */ } H5G_typeinfo_t; /* Local variables */ static H5G_typeinfo_t *H5G_type_g = NULL; /*object typing info */ static size_t H5G_ntypes_g = 0; /*entries in type table */ static size_t H5G_atypes_g = 0; /*entries allocated */ static char *H5G_comp_g = NULL; /*component buffer */ static size_t H5G_comp_alloc_g = 0; /*sizeof component buffer */ /* Declare a free list to manage the H5G_t struct */ H5FL_DEFINE(H5G_t); H5FL_DEFINE(H5G_shared_t); /* Declare extern the PQ free list for the wrapped strings */ H5FL_BLK_EXTERN(str_buf); /* Private prototypes */ static herr_t H5G_register_type(int type, htri_t(*isa)(H5G_entry_t*, hid_t), const char *desc); static const char * H5G_component(const char *name, size_t *size_p); static const char * H5G_basename(const char *name, size_t *size_p); static char * H5G_normalize(const char *name); static herr_t H5G_namei(const H5G_entry_t *loc_ent, const char *name, const char **rest/*out*/, H5G_entry_t *grp_ent/*out*/, H5G_entry_t *obj_ent/*out*/, unsigned target, int *nlinks/*out*/, H5G_namei_act_t action, H5G_entry_t *ent, hid_t dxpl_id); static herr_t H5G_traverse_slink(H5G_entry_t *grp_ent/*in,out*/, H5G_entry_t *obj_ent/*in,out*/, int *nlinks/*in,out*/, hid_t dxpl_id); static H5G_t *H5G_create(H5G_entry_t *loc, const char *name, size_t size_hint, hid_t dxpl_id); static htri_t H5G_isa(H5G_entry_t *ent, hid_t dxpl_id); static htri_t H5G_link_isa(H5G_entry_t *ent, hid_t dxpl_id); static H5G_t * H5G_open_oid(H5G_entry_t *ent, hid_t dxpl_id); static H5G_t *H5G_rootof(H5F_t *f); static herr_t H5G_link(H5G_entry_t *cur_loc, const char *cur_name, H5G_entry_t *new_loc, const char *new_name, H5G_link_t type, unsigned namei_flags, hid_t dxpl_id); static herr_t H5G_get_num_objs(H5G_entry_t *grp, hsize_t *num_objs, hid_t dxpl_id); static ssize_t H5G_get_objname_by_idx(H5G_entry_t *loc, hsize_t idx, char* name, size_t size, hid_t dxpl_id); static int H5G_get_objtype_by_idx(H5G_entry_t *loc, hsize_t idx, hid_t dxpl_id); static herr_t H5G_linkval(H5G_entry_t *loc, const char *name, size_t size, char *buf/*out*/, hid_t dxpl_id); static herr_t H5G_set_comment(H5G_entry_t *loc, const char *name, const char *buf, hid_t dxpl_id); static int H5G_get_comment(H5G_entry_t *loc, const char *name, size_t bufsize, char *buf, hid_t dxpl_id); static herr_t H5G_unlink(H5G_entry_t *loc, const char *name, hid_t dxpl_id); static herr_t H5G_move(H5G_entry_t *src_loc, const char *src_name, H5G_entry_t *dst_loc, const char *dst_name, hid_t dxpl_id); static htri_t H5G_common_path(const H5RS_str_t *fullpath_r, const H5RS_str_t *prefix_r); static H5RS_str_t *H5G_build_fullpath(const H5RS_str_t *prefix_r, const H5RS_str_t *name_r); static int H5G_replace_ent(void *obj_ptr, hid_t obj_id, void *key); /*------------------------------------------------------------------------- * Function: H5Gcreate * * Purpose: Creates a new group relative to LOC_ID and gives it the * specified NAME. The group is opened for write access * and it's object ID is returned. * * The optional SIZE_HINT specifies how much file space to * reserve to store the names that will appear in this * group. If a non-positive value is supplied for the SIZE_HINT * then a default size is chosen. * * See also: H5Gset(), H5Gpush(), H5Gpop() * * Errors: * * Return: Success: The object ID of a new, empty group open for * writing. Call H5Gclose() when finished with * the group. * * Failure: FAIL * * Programmer: Robb Matzke * Wednesday, September 24, 1997 * * Modifications: * *------------------------------------------------------------------------- */ hid_t H5Gcreate(hid_t loc_id, const char *name, size_t size_hint) { H5G_entry_t *loc = NULL; H5G_t *grp = NULL; hid_t ret_value; FUNC_ENTER_API(H5Gcreate, FAIL); H5TRACE3("i","isz",loc_id,name,size_hint); /* Check arguments */ if (NULL==(loc=H5G_loc (loc_id))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location"); if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name given"); /* Create the group */ if (NULL == (grp = H5G_create(loc, name, size_hint, H5AC_dxpl_id))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group"); if ((ret_value = H5I_register(H5I_GROUP, grp)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group"); done: if(ret_value<0) { if(grp!=NULL) H5G_close(grp); } /* end if */ FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5Gopen * * Purpose: Opens an existing group for modification. When finished, * call H5Gclose() to close it and release resources. * * Errors: * * Return: Success: Object ID of the group. * * Failure: FAIL * * Programmer: Robb Matzke * Wednesday, December 31, 1997 * * Modifications: * *------------------------------------------------------------------------- */ hid_t H5Gopen(hid_t loc_id, const char *name) { hid_t ret_value = FAIL; H5G_t *grp = NULL; H5G_entry_t *loc = NULL; H5G_entry_t ent; FUNC_ENTER_API(H5Gopen, FAIL); H5TRACE2("i","is",loc_id,name); /* Check args */ if (NULL==(loc=H5G_loc(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location"); if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name"); /* Open the parent group, making sure it's a group */ if (H5G_find(loc, name, &ent/*out*/, H5AC_dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found"); /* Open the group */ if ((grp = H5G_open(&ent, H5AC_dxpl_id))==NULL) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group"); /* Register an atom for the group */ if ((ret_value = H5I_register(H5I_GROUP, grp)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group"); done: if(ret_value<0) { if(grp!=NULL) H5G_close(grp); } /* end if */ FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Gclose * * Purpose: Closes the specified group. The group ID will no longer be * valid for accessing the group. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Wednesday, December 31, 1997 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Gclose(hid_t group_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Gclose, FAIL); H5TRACE1("e","i",group_id); /* Check args */ if (NULL == H5I_object_verify(group_id,H5I_GROUP)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group"); /* * Decrement the counter on the group atom. It will be freed if the count * reaches zero. */ if (H5I_dec_ref(group_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to close group"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Giterate * * Purpose: Iterates over the entries of a group. The LOC_ID and NAME * identify the group over which to iterate and IDX indicates * where to start iterating (zero means at the beginning). The * OPERATOR is called for each member and the iteration * continues until the operator returns non-zero or all members * are processed. The operator is passed a group ID for the * group being iterated, a member name, and OP_DATA for each * member. * * Return: Success: The return value of the first operator that * returns non-zero, or zero if all members were * processed with no operator returning non-zero. * * Failure: Negative if something goes wrong within the * library, or the negative value returned by one * of the operators. * * Programmer: Robb Matzke * Monday, March 23, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Giterate(hid_t loc_id, const char *name, int *idx_p, H5G_iterate_t op, void *op_data) { H5O_stab_t stab; /*info about B-tree */ int idx; H5G_bt_it_ud1_t udata; H5G_t *grp = NULL; herr_t ret_value; FUNC_ENTER_API(H5Giterate, FAIL); H5TRACE5("e","is*Isxx",loc_id,name,idx_p,op,op_data); /* Check args */ if (!name || !*name) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified"); idx = (idx_p == NULL ? 0 : *idx_p); if (!idx_p) idx_p = &idx; if (idx<0) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index specified"); if (!op) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no operator specified"); /* * Open the group on which to operate. We also create a group ID which * we can pass to the application-defined operator. */ if ((udata.group_id = H5Gopen (loc_id, name)) <0) HGOTO_ERROR (H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group"); if ((grp=H5I_object(udata.group_id))==NULL) { H5Gclose(udata.group_id); HGOTO_ERROR (H5E_ATOM, H5E_BADATOM, FAIL, "bad group atom"); } /* Get the B-tree info */ if (NULL==H5O_read (&(grp->ent), H5O_STAB_ID, 0, &stab, H5AC_dxpl_id)) HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "unable to determine local heap address") /* Build udata to pass through H5B_iterate() to H5G_node_iterate() */ udata.skip = idx; udata.heap_addr = stab.heap_addr; udata.op = op; udata.op_data = op_data; /* Set the number of entries looked at to zero */ udata.final_ent = 0; /* Iterate over the group members */ if ((ret_value = H5B_iterate (H5G_fileof(grp), H5AC_dxpl_id, H5B_SNODE, H5G_node_iterate, stab.btree_addr, &udata))<0) HERROR (H5E_SYM, H5E_CANTNEXT, "iteration operator failed"); H5I_dec_ref (udata.group_id); /*also closes 'grp'*/ /* Check for too high of a starting index (ex post facto :-) */ /* (Skipping exactly as many entries as are in the group is currently an error) */ if(idx>0 && idx>=udata.final_ent) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index specified"); /* Set the index we stopped at */ *idx_p=udata.final_ent; done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Gget_num_objs * * Purpose: Returns the number of objects in the group. It iterates * all B-tree leaves and sum up total number of group members. * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Raymond Lu * Nov 20, 2002 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs) { H5G_entry_t *loc = NULL; /* Pointer to symbol table entry */ herr_t ret_value; FUNC_ENTER_API(H5Gget_num_objs, FAIL); H5TRACE2("e","i*h",loc_id,num_objs); /* Check args */ if (NULL==(loc=H5G_loc (loc_id))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID"); if(H5G_get_type(loc,H5AC_ind_dxpl_id)!=H5G_GROUP) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a group"); if (!num_objs) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "nil pointer"); /* Call private function. */ ret_value = H5G_get_num_objs(loc, num_objs, H5AC_ind_dxpl_id); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Gget_objname_by_idx * * Purpose: Returns the name of objects in the group by giving index. * If `name' is non-NULL then write up to `size' bytes into that * buffer and always return the length of the entry name. * Otherwise `size' is ignored and the function does not store the name, * just returning the number of characters required to store the name. * If an error occurs then the buffer pointed to by `name' (NULL or non-NULL) * is unchanged and the function returns a negative value. * If a zero is returned for the name's length, then there is no name * associated with the ID. * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Raymond Lu * Nov 20, 2002 * * Modifications: * *------------------------------------------------------------------------- */ ssize_t H5Gget_objname_by_idx(hid_t loc_id, hsize_t idx, char *name, size_t size) { H5G_entry_t *loc = NULL; /* Pointer to symbol table entry */ ssize_t ret_value = FAIL; FUNC_ENTER_API(H5Gget_objname_by_idx, FAIL); H5TRACE4("Zs","ihsz",loc_id,idx,name,size); /* Check args */ if (NULL==(loc=H5G_loc (loc_id))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID"); if(H5G_get_type(loc,H5AC_ind_dxpl_id)!=H5G_GROUP) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a group"); /*call private function*/ ret_value = H5G_get_objname_by_idx(loc, idx, name, size, H5AC_ind_dxpl_id); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Gget_objtype_by_idx * * Purpose: Returns the type of objects in the group by giving index. * * * Return: Success: H5G_GROUP(1), H5G_DATASET(2), H5G_TYPE(3) * * Failure: H5G_UNKNOWN * * Programmer: Raymond Lu * Nov 20, 2002 * * Modifications: * *------------------------------------------------------------------------- */ #ifdef H5_WANT_H5_V1_4_COMPAT int H5Gget_objtype_by_idx(hid_t loc_id, hsize_t idx) { H5G_entry_t *loc = NULL; /* Pointer to symbol table entry */ int ret_value; FUNC_ENTER_API(H5Gget_objtype_by_idx, FAIL); H5TRACE2("Is","ih",loc_id,idx); /* Check args */ if (NULL==(loc=H5G_loc (loc_id))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID"); if(H5G_get_type(loc,H5AC_ind_dxpl_id)!=H5G_GROUP) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a group"); /*call private function*/ ret_value = H5G_get_objtype_by_idx(loc, idx, H5AC_ind_dxpl_id); done: FUNC_LEAVE_API(ret_value); } #else /*H5_WANT_H5_V1_4_COMPAT*/ H5G_obj_t H5Gget_objtype_by_idx(hid_t loc_id, hsize_t idx) { H5G_entry_t *loc = NULL; /* Pointer to symbol table entry */ H5G_obj_t ret_value; FUNC_ENTER_API(H5Gget_objtype_by_idx, H5G_UNKNOWN); H5TRACE2("Go","ih",loc_id,idx); /* Check args */ if (NULL==(loc=H5G_loc (loc_id))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "not a location ID"); if(H5G_get_type(loc,H5AC_ind_dxpl_id)!=H5G_GROUP) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "not a group"); /*call private function*/ ret_value = (H5G_obj_t)H5G_get_objtype_by_idx(loc, idx, H5AC_ind_dxpl_id); done: FUNC_LEAVE_API(ret_value); } #endif /*H5_WANT_H5_V1_4_COMPAT*/ /*------------------------------------------------------------------------- * Function: H5Gmove2 * * Purpose: Renames an object within an HDF5 file. The original name SRC * is unlinked from the group graph and the new name DST is * inserted as an atomic operation. Both names are interpreted * relative to SRC_LOC_ID and DST_LOC_ID, which are either a file * ID or a group ID. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Monday, April 6, 1998 * * Modifications: * * Raymond Lu * Thursday, April 18, 2002 * *------------------------------------------------------------------------- */ herr_t H5Gmove2(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dst_name) { H5G_entry_t *src_loc=NULL; H5G_entry_t *dst_loc=NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Gmove2, FAIL); H5TRACE4("e","isis",src_loc_id,src_name,dst_loc_id,dst_name); if (src_loc_id != H5G_SAME_LOC && NULL==(src_loc=H5G_loc(src_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location"); if (dst_loc_id != H5G_SAME_LOC && NULL==(dst_loc=H5G_loc(dst_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location"); if (!src_name || !*src_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no current name specified"); if (!dst_name || !*dst_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no new name specified"); if(src_loc_id == H5G_SAME_LOC && dst_loc_id == H5G_SAME_LOC) { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should not be both H5G_SAME_LOC"); } else if(src_loc_id == H5G_SAME_LOC) { src_loc = dst_loc; } else if(dst_loc_id == H5G_SAME_LOC) { dst_loc = src_loc; } else if(src_loc->file != dst_loc->file) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should be in the same file."); if (H5G_move(src_loc, src_name, dst_loc, dst_name, H5AC_dxpl_id)<0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to change object name"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Glink2 * * Purpose: Creates a link of the specified type from NEW_NAME to * CUR_NAME. * * If TYPE is H5G_LINK_HARD then CUR_NAME must name an existing * object. CUR_NAME and NEW_NAME are interpreted relative to * CUR_LOC_ID and NEW_LOC_ID, which is either a file ID or a * group ID. * * If TYPE is H5G_LINK_SOFT then CUR_NAME can be anything and is * interpreted at lookup time relative to the group which * contains the final component of NEW_NAME. For instance, if * CUR_NAME is `./foo' and NEW_NAME is `./x/y/bar' and a request * is made for `./x/y/bar' then the actual object looked up is * `./x/y/./foo'. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Monday, April 6, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type, hid_t new_loc_id, const char *new_name) { H5G_entry_t *cur_loc = NULL; H5G_entry_t *new_loc = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Glink2, FAIL); H5TRACE5("e","isGlis",cur_loc_id,cur_name,type,new_loc_id,new_name); /* Check arguments */ if (cur_loc_id != H5G_SAME_LOC && NULL==(cur_loc=H5G_loc(cur_loc_id))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location"); if (new_loc_id != H5G_SAME_LOC && NULL==(new_loc=H5G_loc(new_loc_id))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location"); if (type!=H5G_LINK_HARD && type!=H5G_LINK_SOFT) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "unrecognized link type"); if (!cur_name || !*cur_name) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no current name specified"); if (!new_name || !*new_name) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no new name specified"); if(cur_loc_id == H5G_SAME_LOC && new_loc_id == H5G_SAME_LOC) { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should not be both H5G_SAME_LOC"); } else if(cur_loc_id == H5G_SAME_LOC) { cur_loc = new_loc; } else if(new_loc_id == H5G_SAME_LOC) { new_loc = cur_loc; } else if(cur_loc->file != new_loc->file) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should be in the same file."); if (H5G_link(cur_loc, cur_name, new_loc, new_name, type, H5G_TARGET_NORMAL, H5AC_dxpl_id) <0) HGOTO_ERROR (H5E_SYM, H5E_LINK, FAIL, "unable to create link"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Gunlink * * Purpose: Removes the specified NAME from the group graph and * decrements the link count for the object to which NAME * points. If the link count reaches zero then all file-space * associated with the object will be reclaimed (but if the * object is open, then the reclamation of the file space is * delayed until all handles to the object are closed). * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Monday, April 6, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Gunlink(hid_t loc_id, const char *name) { H5G_entry_t *loc = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Gunlink, FAIL); H5TRACE2("e","is",loc_id,name); /* Check arguments */ if (NULL==(loc=H5G_loc(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location"); if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name"); /* Unlink */ if (H5G_unlink(loc, name, H5AC_dxpl_id)<0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to unlink object"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Gget_objinfo * * Purpose: Returns information about an object. If FOLLOW_LINK is * non-zero then all symbolic links are followed; otherwise all * links except the last component of the name are followed. * * Return: Non-negative on success, with the fields of STATBUF (if * non-null) initialized. Negative on failure. * * Programmer: Robb Matzke * Monday, April 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Gget_objinfo(hid_t loc_id, const char *name, hbool_t follow_link, H5G_stat_t *statbuf/*out*/) { H5G_entry_t *loc = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Gget_objinfo, FAIL); H5TRACE4("e","isbx",loc_id,name,follow_link,statbuf); /* Check arguments */ if (NULL==(loc=H5G_loc (loc_id))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location"); if (!name || !*name) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified"); /* Get info */ if (H5G_get_objinfo (loc, name, follow_link, statbuf, H5AC_ind_dxpl_id)<0) HGOTO_ERROR (H5E_ARGS, H5E_CANTINIT, FAIL, "cannot stat object"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Gget_linkval * * Purpose: Returns the value of a symbolic link whose name is NAME. At * most SIZE characters (counting the null terminator) are * copied to the BUF result buffer. * * Return: Success: Non-negative with the link value in BUF. * * Failure: Negative * * Programmer: Robb Matzke * Monday, April 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Gget_linkval(hid_t loc_id, const char *name, size_t size, char *buf/*out*/) { H5G_entry_t *loc = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Gget_linkval, FAIL); H5TRACE4("e","iszx",loc_id,name,size,buf); /* Check arguments */ if (NULL==(loc=H5G_loc (loc_id))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location"); if (!name || !*name) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified"); /* Get the link value */ if (H5G_linkval (loc, name, size, buf, H5AC_ind_dxpl_id)<0) HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "unable to get link value"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Gset_comment * * Purpose: Gives the specified object a comment. The COMMENT string * should be a null terminated string. An object can have only * one comment at a time. Passing NULL for the COMMENT argument * will remove the comment property from the object. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Monday, July 20, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Gset_comment(hid_t loc_id, const char *name, const char *comment) { H5G_entry_t *loc = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Gset_comment, FAIL); H5TRACE3("e","iss",loc_id,name,comment); if (NULL==(loc=H5G_loc(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location"); if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified"); if (H5G_set_comment(loc, name, comment, H5AC_dxpl_id)<0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to set comment value"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5Gget_comment * * Purpose: Return at most BUFSIZE characters of the comment for the * specified object. If BUFSIZE is large enough to hold the * entire comment then the comment string will be null * terminated, otherwise it will not. If the object does not * have a comment value then no bytes are copied to the BUF * buffer. * * Return: Success: Number of characters in the comment counting * the null terminator. The value returned may * be larger than the BUFSIZE argument. * * Failure: Negative * * Programmer: Robb Matzke * Monday, July 20, 1998 * * Modifications: * *------------------------------------------------------------------------- */ int H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize, char *buf) { H5G_entry_t *loc = NULL; int ret_value; FUNC_ENTER_API(H5Gget_comment, FAIL); H5TRACE4("Is","iszs",loc_id,name,bufsize,buf); if (NULL==(loc=H5G_loc(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location"); if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified"); if (bufsize>0 && !buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no buffer specified"); if ((ret_value=H5G_get_comment(loc, name, bufsize, buf, H5AC_ind_dxpl_id))<0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to get comment value"); done: FUNC_LEAVE_API(ret_value); } /* *------------------------------------------------------------------------- *------------------------------------------------------------------------- * N O A P I F U N C T I O N S B E Y O N D T H I S P O I N T *------------------------------------------------------------------------- *------------------------------------------------------------------------- */ /*------------------------------------------------------------------------- * Function: H5G_init_interface * * Purpose: Initializes the H5G interface. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Monday, January 5, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5G_init_interface(void) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5G_init_interface); /* Initialize the atom group for the group IDs */ if (H5I_init_group(H5I_GROUP, H5I_GROUPID_HASHSIZE, H5G_RESERVED_ATOMS, (H5I_free_t)H5G_close) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to initialize interface"); /* * Initialize the type info table. Begin with the most general types and * end with the most specific. For instance, any object that has a data * type message is a datatype but only some of them are datasets. */ H5G_register_type(H5G_TYPE, H5T_isa, "datatype"); H5G_register_type(H5G_GROUP, H5G_isa, "group"); H5G_register_type(H5G_DATASET, H5D_isa, "dataset"); H5G_register_type(H5G_LINK, H5G_link_isa, "link"); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_term_interface * * Purpose: Terminates the H5G interface * * Return: Success: Positive if anything is done that might * affect other interfaces; zero otherwise. * * Failure: Negative. * * Programmer: Robb Matzke * Monday, January 5, 1998 * * Modifications: * Robb Matzke, 2002-03-28 * Free the global component buffer. *------------------------------------------------------------------------- */ int H5G_term_interface(void) { size_t i; int n=0; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_term_interface); if (H5_interface_initialize_g) { if ((n=H5I_nmembers(H5I_GROUP))) { H5I_clear_group(H5I_GROUP, FALSE); } else { /* Empty the object type table */ for (i=0; i=0); assert(isa); assert(_desc); /* Copy the description */ if (NULL==(desc=H5MM_strdup(_desc))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for object type description"); /* * If the type is already registered then just update its entry without * moving it to the end */ for (i=0; i=H5G_atypes_g) { size_t n = MAX(32, 2*H5G_atypes_g); H5G_typeinfo_t *x = H5MM_realloc(H5G_type_g, n*sizeof(H5G_typeinfo_t)); if (!x) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for objec type table"); H5G_atypes_g = n; H5G_type_g = x; } /* Add a new entry */ H5G_type_g[H5G_ntypes_g].type = type; H5G_type_g[H5G_ntypes_g].isa = isa; H5G_type_g[H5G_ntypes_g].desc = desc; /*already copied*/ H5G_ntypes_g++; done: if (ret_value<0) H5MM_xfree(desc); FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_component * * Purpose: Returns the pointer to the first component of the * specified name by skipping leading slashes. Returns * the size in characters of the component through SIZE_P not * counting leading slashes or the null terminator. * * Errors: * * Return: Success: Ptr into NAME. * * Failure: Ptr to the null terminator of NAME. * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 11 1997 * * Modifications: * *------------------------------------------------------------------------- */ static const char * H5G_component(const char *name, size_t *size_p) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_component); assert(name); while ('/' == *name) name++; if (size_p) *size_p = HDstrcspn(name, "/"); FUNC_LEAVE_NOAPI(name); } /*------------------------------------------------------------------------- * Function: H5G_basename * * Purpose: Returns a pointer to the last component of the specified * name. The length of the component is returned through SIZE_P. * The base name is followed by zero or more slashes and a null * terminator, but SIZE_P does not count the slashes or the null * terminator. * * Note: The base name of the root directory is a single slash. * * Return: Success: Ptr to base name. * * Failure: Ptr to the null terminator. * * Programmer: Robb Matzke * Thursday, September 17, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static const char * H5G_basename(const char *name, size_t *size_p) { size_t i; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_basename); /* Find the end of the base name */ i = HDstrlen(name); while (i>0 && '/'==name[i-1]) --i; /* Skip backward over base name */ while (i>0 && '/'!=name[i-1]) --i; /* Watch out for root special case */ if ('/'==name[i] && size_p) *size_p = 1; FUNC_LEAVE_NOAPI(name+i); } /*------------------------------------------------------------------------- * Function: H5G_normalize * * Purpose: Returns a pointer to a new string which has duplicate and * trailing slashes removed from it. * * Return: Success: Ptr to normalized name. * Failure: NULL * * Programmer: Quincey Koziol * Saturday, August 16, 2003 * * Modifications: * *------------------------------------------------------------------------- */ static char * H5G_normalize(const char *name) { char *norm; /* Pointer to the normalized string */ size_t s,d; /* Positions within the strings */ unsigned last_slash; /* Flag to indicate last character was a slash */ char *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5G_normalize); /* Sanity check */ assert(name); /* Duplicate the name, to return */ if (NULL==(norm=H5MM_strdup(name))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for normalized string"); /* Walk through the characters, omitting duplicated '/'s */ s=d=0; last_slash=0; while(name[s]!='\0') { if(name[s]=='/') if(last_slash) ; else { norm[d++]=name[s]; last_slash=1; } /* end else */ else { norm[d++]=name[s]; last_slash=0; } /* end else */ s++; } /* end while */ /* Terminate normalized string */ norm[d]='\0'; /* Check for final '/' on normalized name & eliminate it */ if(d>1 && last_slash) norm[d-1]='\0'; /* Set return value */ ret_value=norm; done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5G_normalize() */ /*------------------------------------------------------------------------- * Function: H5G_namei * * Purpose: Translates a name to a symbol table entry. * * If the specified name can be fully resolved, then this * function returns the symbol table entry for the named object * through the OBJ_ENT argument. The symbol table entry for the * group containing the named object is returned through the * GRP_ENT argument if it is non-null. However, if the name * refers to the root object then the GRP_ENT will be * initialized with an undefined object header address. The * REST argument, if present, will point to the null terminator * of NAME. * * If the specified name cannot be fully resolved, then OBJ_ENT * is initialized with the undefined object header address. The * REST argument will point into the NAME argument to the start * of the component that could not be located. The GRP_ENT will * contain the entry for the symbol table that was being * searched at the time of the failure and will have an * undefined object header address if the search failed at the * root object. For instance, if NAME is `/foo/bar/baz' and the * root directory exists and contains an entry for `foo', and * foo is a group that contains an entry for bar, but bar is not * a group, then the results will be that REST points to `baz', * OBJ_ENT has an undefined object header address, and GRP_ENT * is the symbol table entry for `bar' in `/foo'. * * Every file has a root group whose name is `/'. Components of * a name are separated from one another by one or more slashes * (/). Slashes at the end of a name are ignored. If the name * begins with a slash then the search begins at the root group * of the file containing LOC_ENT. Otherwise it begins at * LOC_ENT. The component `.' is a no-op, but `..' is not * understood by this function (unless it appears as an entry in * the symbol table). * * Symbolic links are followed automatically, but if TARGET * includes the H5G_TARGET_SLINK bit and the last component of * the name is a symbolic link then that link is not followed. * The *NLINKS value is decremented each time a link is followed * and link traversal fails if the value would become negative. * If NLINKS is the null pointer then a default value is used. * * Mounted files are handled by calling H5F_mountpoint() after * each step of the translation. If the input argument to that * function is a mount point then the argument shall be replaced * with information about the root group of the mounted file. * But if TARGET includes the H5G_TARGET_MOUNT bit and the last * component of the name is a mount point then H5F_mountpoint() * is not called and information about the mount point itself is * returned. * * Errors: * * Return: Success: Non-negative if name can be fully resolved. * See above for values of REST, GRP_ENT, and * OBJ_ENT. NLINKS has been decremented for * each symbolic link that was followed. * * Failure: Negative if the name could not be fully * resolved. See above for values of REST, * GRP_ENT, and OBJ_ENT. * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 11 1997 * * Modifications: * Robb Matzke, 2002-03-28 * The component name buffer on the stack has been replaced by * a dynamically allocated buffer on the heap in order to * remove limitations on the length of a name component. * There are two reasons that the buffer pointer is global: * (1) We want to be able to reuse the buffer without * allocating and freeing it each time this function is * called. * (2) We need to be able to free it from H5G_term_interface() * when the library terminates. * * Pedro Vicente, 22 Aug 2002 * Modified to deep copies of symbol table entries * Added `id to name' support. * * Quincey Koziol, 2003-01-06 * Added "action" and "ent" parameters to allow different actions when * working on the last component of a name. (Specifically, this allows * inserting an entry into a group, instead of trying to look it up) * *------------------------------------------------------------------------- */ static herr_t H5G_namei(const H5G_entry_t *loc_ent, const char *name, const char **rest/*out*/, H5G_entry_t *grp_ent/*out*/, H5G_entry_t *obj_ent/*out*/, unsigned target, int *nlinks/*out*/, H5G_namei_act_t action, H5G_entry_t *ent, hid_t dxpl_id) { H5G_entry_t _grp_ent; /*entry for current group */ H5G_entry_t _obj_ent; /*entry found */ size_t nchars; /*component name length */ int _nlinks = H5G_NLINKS; const char *s = NULL; unsigned null_obj; /* Flag to indicate this function was called with obj_ent set to NULL */ unsigned null_grp; /* Flag to indicate this function was called with grp_ent set to NULL */ unsigned obj_copy = 0; /* Flag to indicate that the object entry is copied */ unsigned group_copy = 0; /* Flag to indicate that the group entry is copied */ unsigned last_comp = 0; /* Flag to indicate that a component is the last component in the name */ unsigned did_insert = 0; /* Flag to indicate that H5G_stab_insert was called */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5G_namei); /* Set up "out" parameters */ if (rest) *rest = name; if (!grp_ent) { grp_ent = &_grp_ent; null_grp = 1; } /* end if */ else null_grp = 0; if (!obj_ent) { obj_ent = &_obj_ent; null_obj = 1; } /* end if */ else null_obj = 0; if (!nlinks) nlinks = &_nlinks; /* Check args */ if (!name || !*name) HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "no name given"); if (!loc_ent) HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "no current working group"); /* * Where does the searching start? For absolute names it starts at the * root of the file; for relative names it starts at CWG. */ /* Check if we need to get the root group's entry */ if ('/' == *name) { H5G_t *tmp_grp; /* Temporary pointer to root group of file */ tmp_grp=H5G_rootof(loc_ent->file); assert(tmp_grp); /* Set the location entry to the root group's entry*/ loc_ent=&(tmp_grp->ent); } /* end if */ /* Deep copy of the symbol table entry (duplicates strings) */ if (H5G_ent_copy(obj_ent, loc_ent,H5G_COPY_DEEP)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to copy entry"); obj_copy = 1; H5G_ent_reset(grp_ent); /* traverse the name */ while ((name = H5G_component(name, &nchars)) && *name) { /* Update the "rest of name" pointer */ if (rest) *rest = name; /* * Copy the component name into a null-terminated buffer so * we can pass it down to the other symbol table functions. */ if (nchars+1 > H5G_comp_alloc_g) { H5G_comp_alloc_g = MAX3(1024, 2*H5G_comp_alloc_g, nchars+1); H5G_comp_g = H5MM_realloc(H5G_comp_g, H5G_comp_alloc_g); if (!H5G_comp_g) { H5G_comp_alloc_g = 0; HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "unable to allocate component buffer"); } } HDmemcpy(H5G_comp_g, name, nchars); H5G_comp_g[nchars] = '\0'; /* * The special name `.' is a no-op. */ if ('.' == H5G_comp_g[0] && !H5G_comp_g[1]) { name += nchars; continue; } /* * Advance to the next component of the name. */ /* If we've already copied a new entry into the group entry, * it needs to be freed before overwriting it with another entry */ if(group_copy) H5G_free_ent_name(grp_ent); /* Transfer "ownership" of the entry's information to the group entry */ H5G_ent_copy(grp_ent,obj_ent,H5G_COPY_SHALLOW); H5G_ent_reset(obj_ent); /* Set flag that we've copied a new entry into the group entry */ group_copy =1; /* Check if this is the last component of the name */ if(!((s=H5G_component(name+nchars, NULL)) && *s)) last_comp=1; switch(action) { case H5G_NAMEI_TRAVERSE: if (H5G_stab_find(grp_ent, H5G_comp_g, obj_ent/*out*/, dxpl_id )<0) { /* * Component was not found in the current symbol table, possibly * because GRP_ENT isn't a symbol table. */ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "component not found"); } break; case H5G_NAMEI_INSERT: if(!last_comp) { if (H5G_stab_find(grp_ent, H5G_comp_g, obj_ent/*out*/, dxpl_id )<0) { /* * Component was not found in the current symbol table, possibly * because GRP_ENT isn't a symbol table. */ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "component not found"); } } /* end if */ else { did_insert = 1; if (H5G_stab_insert(grp_ent, H5G_comp_g, ent, TRUE, dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert name"); HGOTO_DONE(SUCCEED); } /* end else */ break; } /* end switch */ /* * If we found a symbolic link then we should follow it. But if this * is the last component of the name and the H5G_TARGET_SLINK bit of * TARGET is set then we don't follow it. */ if(H5G_CACHED_SLINK==obj_ent->type && (0==(target & H5G_TARGET_SLINK) || !last_comp)) { if ((*nlinks)-- <= 0) HGOTO_ERROR (H5E_SYM, H5E_SLINK, FAIL, "too many links"); if (H5G_traverse_slink (grp_ent, obj_ent, nlinks, dxpl_id)<0) HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "symbolic link traversal failed"); } /* * Resolve mount points to the mounted group. Do not do this step if * the H5G_TARGET_MOUNT bit of TARGET is set and this is the last * component of the name. */ if (0==(target & H5G_TARGET_MOUNT) || !last_comp) H5F_mountpoint(obj_ent/*in,out*/); /* next component */ name += nchars; } /* end while */ /* Update the "rest of name" pointer */ if (rest) *rest = name; /*final null */ /* If this was an insert, make sure that the insert function was actually * called (this catches no-op names like "." and "/") */ if(action == H5G_NAMEI_INSERT && !did_insert) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group already exists"); done: /* If we started with a NULL obj_ent, free the entry information */ if(null_obj || (ret_value < 0 && obj_copy)) H5G_free_ent_name(obj_ent); /* If we started with a NULL grp_ent and we copied something into it, free the entry information */ if(null_grp && group_copy) H5G_free_ent_name(grp_ent); FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_traverse_slink * * Purpose: Traverses symbolic link. The link head appears in the group * whose entry is GRP_ENT and the link head entry is OBJ_ENT. * * Return: Success: Non-negative, OBJ_ENT will contain information * about the object to which the link points and * GRP_ENT will contain the information about * the group in which the link tail appears. * * Failure: Negative * * Programmer: Robb Matzke * Friday, April 10, 1998 * * Modifications: * * Pedro Vicente, 22 Aug 2002 * Added `id to name' support. * *------------------------------------------------------------------------- */ static herr_t H5G_traverse_slink (H5G_entry_t *grp_ent/*in,out*/, H5G_entry_t *obj_ent/*in,out*/, int *nlinks/*in,out*/, hid_t dxpl_id) { H5O_stab_t stab_mesg; /*info about local heap */ const char *clv = NULL; /*cached link value */ char *linkval = NULL; /*the copied link value */ H5G_entry_t tmp_grp_ent; /* Temporary copy of group entry */ H5RS_str_t *tmp_user_path_r=NULL, *tmp_canon_path_r=NULL; /* Temporary pointer to object's user path & canonical path */ const H5HL_t *heap; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5G_traverse_slink); /* Portably initialize the temporary group entry */ H5G_ent_reset(&tmp_grp_ent); /* Get the link value */ if (NULL==H5O_read (grp_ent, H5O_STAB_ID, 0, &stab_mesg, dxpl_id)) HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "unable to determine local heap address"); if (NULL == (heap = H5HL_protect(grp_ent->file, dxpl_id, stab_mesg.heap_addr))) HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "unable to read protect link value") clv = H5HL_offset_into(grp_ent->file, heap, obj_ent->cache.slink.lval_offset); linkval = H5MM_xstrdup (clv); assert(linkval); if (H5HL_unprotect(grp_ent->file, dxpl_id, heap, stab_mesg.heap_addr) < 0) HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "unable to read unprotect link value") /* Hold the entry's name (& old_name) to restore later */ tmp_user_path_r=obj_ent->user_path_r; obj_ent->user_path_r=NULL; tmp_canon_path_r=obj_ent->canon_path_r; obj_ent->canon_path_r=NULL; /* Free the names for the group entry */ H5G_free_ent_name(grp_ent); /* Clone the group entry, so we can track the names properly */ H5G_ent_copy(&tmp_grp_ent,grp_ent,H5G_COPY_DEEP); /* Traverse the link */ if (H5G_namei (&tmp_grp_ent, linkval, NULL, grp_ent, obj_ent, H5G_TARGET_NORMAL, nlinks, H5G_NAMEI_TRAVERSE, NULL, dxpl_id)) HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "unable to follow symbolic link"); /* Free the entry's names, we will use the original name for the object */ H5G_free_ent_name(obj_ent); /* Restore previous name for object */ obj_ent->user_path_r = tmp_user_path_r; tmp_user_path_r=NULL; obj_ent->canon_path_r = tmp_canon_path_r; tmp_canon_path_r=NULL; done: /* Error cleanup */ if(tmp_user_path_r) H5RS_decr(tmp_user_path_r); if(tmp_canon_path_r) H5RS_decr(tmp_canon_path_r); /* Release cloned copy of group entry */ H5G_free_ent_name(&tmp_grp_ent); H5MM_xfree (linkval); FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_mkroot * * Purpose: Creates a root group in an empty file and opens it. If a * root group is already open then this function immediately * returns. If ENT is non-null then it's the symbol table * entry for an existing group which will be opened as the root * group. Otherwise a new root group is created and then * opened. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 11 1997 * * Modifications: * * Pedro Vicente, 22 Aug 2002 * Added `id to name' support. * *------------------------------------------------------------------------- */ herr_t H5G_mkroot (H5F_t *f, hid_t dxpl_id, H5G_entry_t *ent) { H5G_entry_t new_root; /*new root object */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5G_mkroot, FAIL); /* check args */ assert(f); if (f->shared->root_grp) HGOTO_DONE(SUCCEED); /* Create information needed for group nodes */ if(H5G_node_init(f)<0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group node info") /* * If there is no root object then create one. The root group always starts * with a hard link count of one since it's pointed to by the boot block. */ if (!ent) { ent = &new_root; H5G_ent_reset(ent); if (H5G_stab_create (f, dxpl_id, (size_t)H5G_SIZE_HINT, ent/*out*/)<0) HGOTO_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "unable to create root group"); if (1 != H5O_link (ent, 1, dxpl_id)) HGOTO_ERROR (H5E_SYM, H5E_LINK, FAIL, "internal error (wrong link count)"); } else { /* * Open the root object as a group. */ if (H5O_open (ent)<0) HGOTO_ERROR (H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open root group"); } /* Create the path names for the root group's entry */ ent->user_path_r=H5RS_create("/"); assert(ent->user_path_r); ent->canon_path_r=H5RS_create("/"); assert(ent->canon_path_r); ent->user_path_hidden=0; /* * Create the group pointer. Also decrement the open object count so we * don't count the root group as an open object. The root group will * never be closed. */ if (NULL==(f->shared->root_grp = H5FL_CALLOC (H5G_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); if (NULL==(f->shared->root_grp->shared = H5FL_CALLOC (H5G_shared_t))) { H5FL_FREE(H5G_t, f->shared->root_grp); HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } /* Shallow copy (take ownership) of the group entry object */ if(H5G_ent_copy(&(f->shared->root_grp->ent), ent, H5G_COPY_SHALLOW)<0) HGOTO_ERROR (H5E_SYM, H5E_CANTCOPY, FAIL, "can't copy group entry") f->shared->root_grp->shared->fo_count = 1; assert (1==f->nopen_objs); f->nopen_objs = 0; done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_create * * Purpose: Creates a new empty group with the specified name. The name * is either an absolute name or is relative to LOC. * * Errors: * * Return: Success: A handle for the group. The group is opened * and should eventually be close by calling * H5G_close(). * * Failure: NULL * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 11 1997 * * Modifications: * * Pedro Vicente, 18 Sep 2002 * Added `id to name' support. * *------------------------------------------------------------------------- */ static H5G_t * H5G_create(H5G_entry_t *loc, const char *name, size_t size_hint, hid_t dxpl_id) { H5G_t *grp = NULL; /*new group */ H5F_t *file = NULL; /* File new group will be in */ unsigned stab_init=0; /* Flag to indicate that the symbol table was created successfully */ H5G_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5G_create); /* check args */ assert(loc); assert(name && *name); /* create an open group */ if (NULL==(grp = H5FL_CALLOC(H5G_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); if (NULL==(grp->shared = H5FL_CALLOC(H5G_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); /* What file is the group being added to? */ if (NULL==(file=H5G_insertion_file(loc, name, dxpl_id))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "unable to locate insertion point"); /* Create the group entry */ if (H5G_stab_create(file, dxpl_id, size_hint, &(grp->ent)/*out*/) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "can't create grp"); stab_init=1; /* Indicate that the symbol table information is valid */ /* insert child name into parent */ if(H5G_insert(loc,name,&(grp->ent), dxpl_id)<0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, NULL, "can't insert group"); /* Add group to list of open objects in file */ if(H5FO_top_incr(grp->ent.file, grp->ent.header)<0) HGOTO_ERROR(H5E_SYM, H5E_CANTINC, NULL, "can't incr object ref. count") if(H5FO_insert(grp->ent.file, grp->ent.header, grp->shared)<0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, NULL, "can't insert group into list of open objects") grp->shared->fo_count = 1; /* Set return value */ ret_value=grp; done: if(ret_value==NULL) { /* Check if we need to release the file-oriented symbol table info */ if(stab_init) { if(H5O_close(&(grp->ent))<0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, NULL, "unable to release object header"); if(H5O_delete(file, dxpl_id,grp->ent.header)<0) HDONE_ERROR(H5E_SYM, H5E_CANTDELETE, NULL, "unable to delete object header"); } /* end if */ if(grp!=NULL) { if(grp->shared != NULL) H5FL_FREE(H5G_shared_t, grp->shared); H5FL_FREE(H5G_t,grp); } } /* end if */ FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_isa * * Purpose: Determines if an object has the requisite messages for being * a group. * * Return: Success: TRUE if the required group messages are * present; FALSE otherwise. * * Failure: FAIL if the existence of certain messages * cannot be determined. * * Programmer: Robb Matzke * Monday, November 2, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static htri_t H5G_isa(H5G_entry_t *ent, hid_t dxpl_id) { htri_t ret_value; FUNC_ENTER_NOAPI_NOINIT(H5G_isa); assert(ent); if ((ret_value=H5O_exists(ent, H5O_STAB_ID, 0, dxpl_id))<0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header"); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_link_isa * * Purpose: Determines if an object has the requisite form for being * a soft link. * * Return: Success: TRUE if the symbol table entry is of type * H5G_LINK; FALSE otherwise. * * Failure: Shouldn't fail. * * Programmer: Quincey Koziol * Wednesday, June 23, 2004 * * Modifications: * *------------------------------------------------------------------------- */ static htri_t H5G_link_isa(H5G_entry_t *ent, hid_t UNUSED dxpl_id) { htri_t ret_value; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_link_isa); assert(ent); if(ent->type == H5G_CACHED_SLINK) ret_value=TRUE; else ret_value=FALSE; FUNC_LEAVE_NOAPI(ret_value); } /* end H5G_link_isa() */ /*------------------------------------------------------------------------- * Function: H5G_open * * Purpose: Opens an existing group. The group should eventually be * closed by calling H5G_close(). * * Return: Success: Ptr to a new group. * * Failure: NULL * * Programmer: Robb Matzke * Monday, January 5, 1998 * * Modifications: * Modified to call H5G_open_oid - QAK - 3/17/99 * * Pedro Vicente, 18 Sep 2002 * Added `id to name' support. * *------------------------------------------------------------------------- */ H5G_t * H5G_open(H5G_entry_t *ent, hid_t dxpl_id) { H5G_t *grp = NULL; H5G_shared_t *shared_fo=NULL; H5G_t *ret_value=NULL; FUNC_ENTER_NOAPI(H5G_open, NULL); /* Check args */ assert(ent); /* Check if group was already open */ if((shared_fo=H5FO_opened(ent->file, ent->header))==NULL) { /* Clear any errors from H5FO_opened() */ H5E_clear(); /* Open the group object */ if ((grp=H5G_open_oid(ent, dxpl_id)) ==NULL) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "not found"); /* Add group to list of open objects in file */ if(H5FO_insert(grp->ent.file, grp->ent.header, grp->shared)<0) { H5FL_FREE(H5G_shared_t, grp->shared); HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, NULL, "can't insert group into list of open objects") } /* Increment object count for the object in the top file */ if(H5FO_top_incr(grp->ent.file, grp->ent.header) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINC, NULL, "can't increment object count") /* Set open object count */ grp->shared->fo_count = 1; } else { if(NULL == (grp = H5FL_CALLOC(H5G_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate space for group") /* Shallow copy (take ownership) of the group entry object */ if(H5G_ent_copy(&(grp->ent), ent, H5G_COPY_SHALLOW)<0) HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, NULL, "can't copy group entry") /* Point to shared group info */ grp->shared = shared_fo; /* Increment shared reference count */ shared_fo->fo_count++; /* Check if the object has been opened through the top file yet */ if(H5FO_top_count(grp->ent.file, grp->ent.header) == 0) { /* Open the object through this top file */ if(H5O_open(&(grp->ent)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open object header") } /* end if */ /* Increment object count for the object in the top file */ if(H5FO_top_incr(grp->ent.file, grp->ent.header) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINC, NULL, "can't increment object count") } /* Set return value */ ret_value = grp; done: if (!ret_value && grp) H5FL_FREE(H5G_t,grp); FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_open_oid * * Purpose: Opens an existing group. The group should eventually be * closed by calling H5G_close(). * * Return: Success: Ptr to a new group. * * Failure: NULL * * Programmer: Quincey Koziol * Wednesday, March 17, 1999 * * Modifications: * * Pedro Vicente, 22 Aug 2002 * Added a deep copy of the symbol table entry * *------------------------------------------------------------------------- */ static H5G_t * H5G_open_oid(H5G_entry_t *ent, hid_t dxpl_id) { H5G_t *grp = NULL; H5G_t *ret_value = NULL; hbool_t ent_opened = FALSE; FUNC_ENTER_NOAPI_NOINIT(H5G_open_oid); /* Check args */ assert(ent); /* Open the object, making sure it's a group */ if (NULL==(grp = H5FL_CALLOC(H5G_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); if (NULL==(grp->shared = H5FL_CALLOC(H5G_shared_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); /* Copy over (take ownership) of the group entry object */ H5G_ent_copy(&(grp->ent),ent,H5G_COPY_SHALLOW); /* Grab the object header */ if (H5O_open(&(grp->ent)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open group") ent_opened = TRUE; /* Check if this object has the right message(s) to be treated as a group */ if(H5O_exists(&(grp->ent), H5O_STAB_ID, 0, dxpl_id) <= 0) HGOTO_ERROR (H5E_SYM, H5E_CANTOPENOBJ, NULL, "not a group") /* Set return value */ ret_value = grp; done: if(!ret_value) { if(grp) { if(ent_opened) H5O_close(&(grp->ent)); if(grp->shared) H5FL_FREE(H5G_shared_t, grp->shared); H5FL_FREE(H5G_t,grp); } /* end if */ } /* end if */ FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_close * * Purpose: Closes the specified group. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Monday, January 5, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5G_close(H5G_t *grp) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5G_close, FAIL); /* Check args */ assert(grp && grp->shared); assert(grp->shared->fo_count > 0); --grp->shared->fo_count; if (0 == grp->shared->fo_count) { assert (grp!=H5G_rootof(H5G_fileof(grp))); /* Remove the group from the list of opened objects in the file */ if(H5FO_top_decr(grp->ent.file, grp->ent.header) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't decrement count for object") if(H5FO_delete(grp->ent.file, H5AC_dxpl_id, grp->ent.header)<0) HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't remove group from list of open objects") if(H5O_close(&(grp->ent)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to close") H5FL_FREE (H5G_shared_t, grp->shared); } else { /* Decrement the ref. count for this object in the top file */ if(H5FO_top_decr(grp->ent.file, grp->ent.header) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't decrement count for object") /* Check reference count for this object in the top file */ if(H5FO_top_count(grp->ent.file, grp->ent.header) == 0) if(H5O_close(&(grp->ent)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to close") /* If this group is a mount point and the mount point is the last open * reference to the group, then attempt to close down the file hierarchy */ if(grp->shared->mounted && grp->shared->fo_count == 1) { /* Attempt to close down the file hierarchy */ if(H5F_try_close(grp->ent.file) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "problem attempting file close") } /* end if */ if(H5G_free_ent_name(&(grp->ent))<0) { H5FL_FREE (H5G_t,grp); HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't free group entry name"); } } H5FL_FREE (H5G_t,grp); done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5G_close() */ /*------------------------------------------------------------------------- * Function: H5G_free * * Purpose: Free memory used by an H5G_t struct (and its H5G_shared_t). * Does not close the group or decrement the reference count. * Used to free memory used by the root group. * * Return: Success: Non-negative * Failure: Negative * * Programmer: James Laird * Tuesday, September 7, 2004 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5G_free(H5G_t *grp) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5G_free, FAIL); assert(grp && grp->shared); H5FL_FREE(H5G_shared_t, grp->shared); H5FL_FREE(H5G_t, grp); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_rootof * * Purpose: Return a pointer to the root group of the file. If the file * is part of a virtual file then the root group of the virtual * file is returned. * * Return: Success: Ptr to the root group of the file. Do not * free the pointer -- it points directly into * the file struct. * * Failure: NULL * * Programmer: Robb Matzke * Tuesday, October 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static H5G_t * H5G_rootof(H5F_t *f) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_rootof); while (f->mtab.parent) f = f->mtab.parent; FUNC_LEAVE_NOAPI(f->shared->root_grp); } /*------------------------------------------------------------------------- * Function: H5G_insert * * Purpose: Inserts a symbol table entry into the group graph. * * Errors: * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Friday, September 19, 1997 * * Modifications: * * Pedro Vicente, 18 Sep 2002 * Added `id to name' support. * *------------------------------------------------------------------------- */ herr_t H5G_insert(H5G_entry_t *loc, const char *name, H5G_entry_t *ent, hid_t dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5G_insert, FAIL); /* Check args. */ assert (loc); assert (name && *name); assert (ent); /* * Lookup and insert the name -- it shouldn't exist yet. */ if (H5G_namei(loc, name, NULL, NULL, NULL, H5G_TARGET_NORMAL, NULL, H5G_NAMEI_INSERT, ent, dxpl_id)<0) HGOTO_ERROR(H5E_SYM, H5E_EXISTS, FAIL, "already exists"); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_find * * Purpose: Finds an object with the specified NAME at location LOC. On * successful return, GRP_ENT (if non-null) will be initialized * with the symbol table information for the group in which the * object appears (it will have an undefined object header * address if the object is the root object) and OBJ_ENT will be * initialized with the symbol table entry for the object * (OBJ_ENT is optional when the caller is interested only in * the existence of the object). * * Errors: * * Return: Success: Non-negative, see above for values of GRP_ENT * and OBJ_ENT. * * Failure: Negative * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 12 1997 * * Modifications: * Removed the "H5G_entry_t *grp_ent" parameter, since it was unused * Quincey Koziol * Aug 29 2005 * *------------------------------------------------------------------------- */ herr_t H5G_find(H5G_entry_t *loc, const char *name, H5G_entry_t *obj_ent/*out*/, hid_t dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5G_find, FAIL); /* check args */ assert (loc); assert (name && *name); if (H5G_namei(loc, name, NULL, NULL, obj_ent, H5G_TARGET_NORMAL, NULL, H5G_NAMEI_TRAVERSE, NULL, dxpl_id)<0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found"); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_entof * * Purpose: Returns a pointer to the entry for a group. * * Return: Success: Ptr to group entry * * Failure: NULL * * Programmer: Robb Matzke * Tuesday, March 24, 1998 * * Modifications: * *------------------------------------------------------------------------- */ H5G_entry_t * H5G_entof (H5G_t *grp) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_entof); FUNC_LEAVE_NOAPI(grp ? &(grp->ent) : NULL); } /*------------------------------------------------------------------------- * Function: H5G_fileof * * Purpose: Returns the file to which the specified group belongs. * * Return: Success: File pointer. * * Failure: NULL * * Programmer: Robb Matzke * Tuesday, March 24, 1998 * * Modifications: * *------------------------------------------------------------------------- */ H5F_t * H5G_fileof (H5G_t *grp) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_fileof); assert (grp); FUNC_LEAVE_NOAPI(grp->ent.file); } /*------------------------------------------------------------------------- * Function: H5G_loc * * Purpose: Given an object ID return a symbol table entry for the * object. * * Return: Success: Group pointer. * * Failure: NULL * * Programmer: Robb Matzke * Tuesday, March 24, 1998 * * Modifications: * *------------------------------------------------------------------------- */ H5G_entry_t * H5G_loc (hid_t loc_id) { H5F_t *f; H5G_entry_t *ret_value=NULL; H5G_t *group=NULL; H5T_t *dt=NULL; H5D_t *dset=NULL; H5A_t *attr=NULL; FUNC_ENTER_NOAPI(H5G_loc, NULL); switch (H5I_get_type(loc_id)) { case H5I_FILE: if (NULL==(f=H5I_object (loc_id))) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, NULL, "invalid file ID"); if (NULL==(ret_value=H5G_entof(H5G_rootof(f)))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "unable to get symbol table entry for root group"); /* Patch up root group's symbol table entry to reflect this file */ /* (Since the root group info is only stored once for files which * share an underlying low-level file) */ /* (but only for non-mounted files) */ if(!f->mtab.parent) ret_value->file = f; break; case H5I_GENPROP_CLS: case H5I_GENPROP_LST: HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "unable to get symbol table entry of property list"); case H5I_GROUP: if (NULL==(group=H5I_object (loc_id))) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, NULL, "invalid group ID"); if (NULL==(ret_value=H5G_entof(group))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "unable to get symbol table entry of group"); break; case H5I_DATATYPE: if (NULL==(dt=H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid type ID"); if (NULL==(ret_value=H5T_entof(dt))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "unable to get symbol table entry of datatype"); break; case H5I_DATASPACE: HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "unable to get symbol table entry of dataspace"); case H5I_DATASET: if (NULL==(dset=H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid data ID"); if (NULL==(ret_value=H5D_entof(dset))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "unable to get symbol table entry of dataset"); break; case H5I_ATTR: if (NULL==(attr=H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid attribute ID"); if (NULL==(ret_value=H5A_entof(attr))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "unable to get symbol table entry of attribute"); break; case H5I_REFERENCE: HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "unable to get symbol table entry of reference"); default: HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object ID"); } done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_link * * Purpose: Creates a link from NEW_NAME to CUR_NAME. See H5Glink() for * full documentation. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Monday, April 6, 1998 * * Modifications: * * Pedro Vicente, 18 Sep 2002 * Added `id to name' support. * *------------------------------------------------------------------------- */ static herr_t H5G_link (H5G_entry_t *cur_loc, const char *cur_name, H5G_entry_t *new_loc, const char *new_name, H5G_link_t type, unsigned namei_flags, hid_t dxpl_id) { H5G_entry_t cur_obj; /*entry for the link tail */ unsigned cur_obj_init=0; /* Flag to indicate that the current object is initialized */ H5G_entry_t grp_ent; /*ent for grp containing link hd*/ H5O_stab_t stab_mesg; /*symbol table message */ const char *rest = NULL; /*last component of new name */ char *norm_cur_name = NULL; /* Pointer to normalized current name */ char *norm_new_name = NULL; /* Pointer to normalized current name */ size_t nchars; /*characters in component */ size_t offset; /*offset to sym-link value */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5G_link); /* Check args */ assert (cur_loc); assert (new_loc); assert (cur_name && *cur_name); assert (new_name && *new_name); /* Get normalized copies of the current and new names */ if((norm_cur_name=H5G_normalize(cur_name))==NULL) HGOTO_ERROR (H5E_SYM, H5E_BADVALUE, FAIL, "can't normalize name"); if((norm_new_name=H5G_normalize(new_name))==NULL) HGOTO_ERROR (H5E_SYM, H5E_BADVALUE, FAIL, "can't normalize name"); switch (type) { case H5G_LINK_SOFT: /* * Lookup the the new_name so we can get the group which will contain * the new entry. The entry shouldn't exist yet. */ if (H5G_namei(new_loc, norm_new_name, &rest, &grp_ent, NULL, H5G_TARGET_NORMAL, NULL, H5G_NAMEI_TRAVERSE, NULL, dxpl_id)>=0) HGOTO_ERROR (H5E_SYM, H5E_EXISTS, FAIL, "already exists"); H5E_clear (); /*it's okay that we didn't find it*/ rest = H5G_component (rest, &nchars); /* * There should be one component left. Make sure it's null * terminated and that `rest' points to it. */ assert(!rest[nchars]); /* * Add the link-value to the local heap for the symbol table which * will contain the link. */ if (NULL==H5O_read (&grp_ent, H5O_STAB_ID, 0, &stab_mesg, dxpl_id)) HGOTO_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "unable to determine local heap address"); if ((size_t)(-1)==(offset=H5HL_insert (grp_ent.file, dxpl_id, stab_mesg.heap_addr, HDstrlen(norm_cur_name)+1, norm_cur_name))) HGOTO_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "unable to write link value to local heap"); H5O_reset (H5O_STAB_ID, &stab_mesg); /* * Create a symbol table entry for the link. The object header is * undefined and the cache contains the link-value offset. */ H5G_ent_reset(&cur_obj); cur_obj.file = grp_ent.file; cur_obj.type = H5G_CACHED_SLINK; cur_obj.cache.slink.lval_offset = offset; cur_obj_init=1; /* Indicate that the cur_obj struct is initialized */ /* * Insert the link head in the symbol table. This shouldn't ever * fail because we've already checked that the link head doesn't * exist and the file is writable (because the local heap is * writable). But if it does, the only side effect is that the local * heap has some extra garbage in it. * * Note: We don't increment the link count of the destination object */ if (H5G_stab_insert (&grp_ent, rest, &cur_obj, FALSE, dxpl_id)<0) HGOTO_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "unable to create new name/link for object"); break; case H5G_LINK_HARD: if (H5G_namei(cur_loc, norm_cur_name, NULL, NULL, &cur_obj, namei_flags, NULL, H5G_NAMEI_TRAVERSE, NULL, dxpl_id)<0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "source object not found"); cur_obj_init=1; /* Indicate that the cur_obj struct is initialized */ if (H5G_insert (new_loc, norm_new_name, &cur_obj, dxpl_id)<0) HGOTO_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "unable to create new name/link for object"); break; default: HGOTO_ERROR (H5E_SYM, H5E_BADVALUE, FAIL, "unrecognized link type"); } done: /* Free the group's ID to name buffer, if creating a soft link */ if(type == H5G_LINK_SOFT) H5G_free_ent_name(&grp_ent); /* Free the ID to name buffer */ if(cur_obj_init) H5G_free_ent_name(&cur_obj); /* Free the normalized path names */ if(norm_cur_name) H5MM_xfree(norm_cur_name); if(norm_new_name) H5MM_xfree(norm_new_name); FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_get_type * * Purpose: Returns the type of object pointed to by `ent'. * * Return: Success: An object type defined in H5Gpublic.h * * Failure: H5G_UNKNOWN * * Programmer: Robb Matzke * Wednesday, November 4, 1998 * * Modifications: * *------------------------------------------------------------------------- */ int H5G_get_type(H5G_entry_t *ent, hid_t dxpl_id) { htri_t isa; size_t i; int ret_value=H5G_UNKNOWN; /* Return value */ FUNC_ENTER_NOAPI(H5G_get_type, H5G_UNKNOWN); for (i=H5G_ntypes_g; i>0; --i) { if ((isa=(H5G_type_g[i-1].isa)(ent, dxpl_id))<0) { HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5G_UNKNOWN, "unable to determine object type"); } else if (isa) { HGOTO_DONE(H5G_type_g[i-1].type); } } if (0==i) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5G_UNKNOWN, "unable to determine object type"); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_get_objinfo * * Purpose: Returns information about an object. * * Return: Success: Non-negative with info about the object * returned through STATBUF if it isn't the null * pointer. * * Failure: Negative * * Programmer: Robb Matzke * Monday, April 13, 1998 * * Modifications: * * Pedro Vicente, 18 Sep 2002 * Added `id to name' support. * *------------------------------------------------------------------------- */ herr_t H5G_get_objinfo (H5G_entry_t *loc, const char *name, hbool_t follow_link, H5G_stat_t *statbuf/*out*/, hid_t dxpl_id) { H5G_entry_t grp_ent, obj_ent; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5G_get_objinfo, FAIL); assert (loc); assert (name && *name); if (statbuf) HDmemset (statbuf, 0, sizeof *statbuf); /* Find the object's symbol table entry */ if (H5G_namei(loc, name, NULL, &grp_ent/*out*/, &obj_ent/*out*/, (unsigned)(follow_link?H5G_TARGET_NORMAL:H5G_TARGET_SLINK), NULL, H5G_NAMEI_TRAVERSE, NULL, dxpl_id)<0) HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "unable to stat object"); /* * Initialize the stat buf. Symbolic links aren't normal objects and * therefore don't have much of the normal info. However, the link value * length is specific to symbolic links. */ if (statbuf) { /* Common code to retrieve the file's fileno */ if(H5F_get_fileno(obj_ent.file,statbuf->fileno)<0) HGOTO_ERROR (H5E_FILE, H5E_BADVALUE, FAIL, "unable to read fileno"); /* Retrieve information specific to each type of entry */ if (H5G_CACHED_SLINK==obj_ent.type) { H5O_stab_t stab_mesg; /* Symbol table message info */ const char *s; /* Pointer to link value */ const H5HL_t *heap; /* Pointer to local heap for group */ /* Named object is a symbolic link */ if (NULL == H5O_read(&grp_ent, H5O_STAB_ID, 0, &stab_mesg, dxpl_id)) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read symbolic link value") /* Lock the local heap */ if (NULL == (heap = H5HL_protect(grp_ent.file, dxpl_id, stab_mesg.heap_addr))) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to read protect link value") s = H5HL_offset_into(grp_ent.file, heap, obj_ent.cache.slink.lval_offset); statbuf->linklen = HDstrlen(s) + 1; /*count the null terminator*/ /* Release the local heap */ if (H5HL_unprotect(grp_ent.file, dxpl_id, heap, stab_mesg.heap_addr) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to read unprotect link value") /* Set object type */ statbuf->type = H5G_LINK; } else { /* Some other type of object */ statbuf->objno[0] = (unsigned long)(obj_ent.header); #if H5_SIZEOF_UINT64_T>H5_SIZEOF_LONG statbuf->objno[1] = (unsigned long)(obj_ent.header >> 8*sizeof(long)); #else statbuf->objno[1] = 0; #endif statbuf->nlink = H5O_link (&obj_ent, 0, dxpl_id); if (NULL==H5O_read(&obj_ent, H5O_MTIME_ID, 0, &(statbuf->mtime), dxpl_id)) { H5E_clear(); if (NULL==H5O_read(&obj_ent, H5O_MTIME_NEW_ID, 0, &(statbuf->mtime), dxpl_id)) { H5E_clear(); statbuf->mtime = 0; } } /* Get object type */ statbuf->type = #ifndef H5_WANT_H5_V1_4_COMPAT (H5G_obj_t) #endif /*H5_WANT_H5_V1_4_COMPAT*/ H5G_get_type(&obj_ent, dxpl_id); H5E_clear(); /*clear errors resulting from checking type*/ /* Get object header information */ if(H5O_get_info(&obj_ent, &(statbuf->ohdr), dxpl_id)<0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get object header information") } } /* end if */ done: /* Free the ID to name buffers */ H5G_free_ent_name(&grp_ent); H5G_free_ent_name(&obj_ent); FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_get_num_objs * * Purpose: Private function for H5Gget_num_objs. Returns the number * of objects in the group. It iterates all B-tree leaves * and sum up total number of group members. * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Raymond Lu * Nov 20, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5G_get_num_objs(H5G_entry_t *loc, hsize_t *num_objs, hid_t dxpl_id) { H5O_stab_t stab_mesg; /*info about B-tree */ herr_t ret_value; FUNC_ENTER_NOAPI_NOINIT(H5G_get_num_objs); /* Sanity check */ assert(loc); assert(num_objs); /* Reset the number of objects in the group */ *num_objs = 0; /* Get the B-tree info */ if (NULL==H5O_read (loc, H5O_STAB_ID, 0, &stab_mesg, dxpl_id)) HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "unable to determine local heap address"); /* Iterate over the group members */ if ((ret_value = H5B_iterate (loc->file, dxpl_id, H5B_SNODE, H5G_node_sumup, stab_mesg.btree_addr, num_objs))<0) HERROR (H5E_SYM, H5E_CANTINIT, "iteration operator failed"); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_get_objname_by_idx * * Purpose: Private function for H5Gget_objname_by_idx. * Returns the name of objects in the group by giving index. * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Raymond Lu * Nov 20, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static ssize_t H5G_get_objname_by_idx(H5G_entry_t *loc, hsize_t idx, char* name, size_t size, hid_t dxpl_id) { H5O_stab_t stab; /*info about local heap & B-tree */ H5G_bt_it_ud2_t udata; /* Iteration information */ ssize_t ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5G_get_objname_by_idx); /* Sanity check */ assert(loc); /* Get the B-tree & local heap info */ if (NULL==H5O_read (loc, H5O_STAB_ID, 0, &stab, dxpl_id)) HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "unable to determine local heap address"); /* Set iteration information */ udata.idx = idx; udata.num_objs = 0; udata.heap_addr = stab.heap_addr; udata.name = NULL; /* Iterate over the group members */ if ((ret_value = H5B_iterate (loc->file, dxpl_id, H5B_SNODE, H5G_node_name, stab.btree_addr, &udata))<0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "iteration operator failed"); /* If we don't know the name now, we almost certainly went out of bounds */ if(udata.name==NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "index out of bound"); /* Get the length of the name */ ret_value = (ssize_t)HDstrlen(udata.name); /* Copy the name into the user's buffer, if given */ if(name) { HDstrncpy(name, udata.name, MIN((size_t)(ret_value+1),size)); if((size_t)ret_value >= size) name[size-1]='\0'; } /* end if */ done: /* Free the duplicated name */ if(udata.name!=NULL) H5MM_xfree(udata.name); FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_get_objtype_by_idx * * Purpose: Private function for H5Gget_objtype_by_idx. * Returns the type of objects in the group by giving index. * * Return: Success: H5G_GROUP(1), H5G_DATASET(2), H5G_TYPE(3) * * Failure: UNKNOWN * * Programmer: Raymond Lu * Nov 20, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static int H5G_get_objtype_by_idx(H5G_entry_t *loc, hsize_t idx, hid_t dxpl_id) { H5O_stab_t stab_mesg; /*info about local heap & B-tree */ H5G_bt_it_ud3_t udata; /* User data for B-tree callback */ int ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5G_get_objtype_by_idx); /* Sanity check */ assert(loc); /* Get the B-tree & local heap info */ if (NULL==H5O_read (loc, H5O_STAB_ID, 0, &stab_mesg, dxpl_id)) HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "unable to determine local heap address"); /* Set iteration information */ udata.idx = idx; udata.num_objs = 0; udata.type = H5G_UNKNOWN; /* Iterate over the group members */ if (H5B_iterate (loc->file, dxpl_id, H5B_SNODE, H5G_node_type, stab_mesg.btree_addr, &udata)<0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "iteration operator failed"); /* If we don't know the type now, we almost certainly went out of bounds */ if(udata.type==H5G_UNKNOWN) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "index out of bound"); ret_value = udata.type; done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_linkval * * Purpose: Returns the value of a symbolic link. * * Return: Success: Non-negative, with at most SIZE bytes of the * link value copied into the BUF buffer. If the * link value is larger than SIZE characters * counting the null terminator then the BUF * result will not be null terminated. * * Failure: Negative * * Programmer: Robb Matzke * Monday, April 13, 1998 * * Modifications: * * Pedro Vicente, 18 Sep 2002 * Added `id to name' support. * *------------------------------------------------------------------------- */ static herr_t H5G_linkval (H5G_entry_t *loc, const char *name, size_t size, char *buf/*out*/, hid_t dxpl_id) { const char *s = NULL; H5G_entry_t grp_ent, obj_ent; H5O_stab_t stab_mesg; const H5HL_t *heap; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5G_linkval); /* * Get the symbol table entry for the link head and the symbol table * entry for the group in which the link head appears. */ if (H5G_namei(loc, name, NULL, &grp_ent/*out*/, &obj_ent/*out*/, H5G_TARGET_SLINK, NULL, H5G_NAMEI_TRAVERSE, NULL, dxpl_id)<0) HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "symbolic link was not found"); if (H5G_CACHED_SLINK!=obj_ent.type) HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "object is not a symbolic link"); /* * Get the address of the local heap for the link value and a pointer * into that local heap. */ if (NULL==H5O_read (&grp_ent, H5O_STAB_ID, 0, &stab_mesg, dxpl_id)) HGOTO_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "unable to determine local heap address"); if (NULL == (heap = H5HL_protect(grp_ent.file, dxpl_id, stab_mesg.heap_addr))) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to read protect link value") s = H5HL_offset_into(grp_ent.file, heap, obj_ent.cache.slink.lval_offset); /* Copy to output buffer */ if (size>0 && buf) HDstrncpy (buf, s, size); if (H5HL_unprotect(grp_ent.file, dxpl_id, heap, stab_mesg.heap_addr) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to read unprotect link value") done: /* Free the ID to name buffers */ H5G_free_ent_name(&grp_ent); H5G_free_ent_name(&obj_ent); FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_set_comment * * Purpose: (Re)sets the comment for an object. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Monday, July 20, 1998 * * Modifications: * * Pedro Vicente, 18 Sep 2002 * Added `id to name' support. * *------------------------------------------------------------------------- */ static herr_t H5G_set_comment(H5G_entry_t *loc, const char *name, const char *buf, hid_t dxpl_id) { H5G_entry_t obj_ent; H5O_name_t comment; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5G_set_comment); /* Get the symbol table entry for the object */ if (H5G_find(loc, name, &obj_ent/*out*/, dxpl_id)<0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found"); /* Remove the previous comment message if any */ if (H5O_remove(&obj_ent, H5O_NAME_ID, 0, TRUE, dxpl_id)<0) H5E_clear(); /* Add the new message */ if (buf && *buf) { comment.s = H5MM_xstrdup(buf); if (H5O_modify(&obj_ent, H5O_NAME_ID, H5O_NEW_MESG, 0, H5O_UPDATE_TIME, &comment, dxpl_id)<0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to set comment object header message"); H5O_reset(H5O_NAME_ID, &comment); } done: /* Free the ID to name buffer */ H5G_free_ent_name(&obj_ent); FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_get_comment * * Purpose: Get the comment value for an object. * * Return: Success: Number of bytes in the comment including the * null terminator. Zero if the object has no * comment. * * Failure: Negative * * Programmer: Robb Matzke * Monday, July 20, 1998 * * Modifications: * * Pedro Vicente, 18 Sep 2002 * Added `id to name' support. * *------------------------------------------------------------------------- */ static int H5G_get_comment(H5G_entry_t *loc, const char *name, size_t bufsize, char *buf, hid_t dxpl_id) { H5O_name_t comment; H5G_entry_t obj_ent; int ret_value; FUNC_ENTER_NOAPI_NOINIT(H5G_get_comment); /* Get the symbol table entry for the object */ if (H5G_find(loc, name, &obj_ent/*out*/, dxpl_id)<0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found"); /* Get the message */ comment.s = NULL; if (NULL==H5O_read(&obj_ent, H5O_NAME_ID, 0, &comment, dxpl_id)) { if (buf && bufsize>0) buf[0] = '\0'; ret_value = 0; } else { if(buf && bufsize) HDstrncpy(buf, comment.s, bufsize); ret_value = (int)HDstrlen(comment.s); H5O_reset(H5O_NAME_ID, &comment); } done: /* Free the ID to name buffer */ H5G_free_ent_name(&obj_ent); FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_unlink * * Purpose: Unlink a name from a group. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Thursday, September 17, 1998 * * Modifications: * * Pedro Vicente, 18 Sep 2002 * Added `id to name' support. * *------------------------------------------------------------------------- */ static herr_t H5G_unlink(H5G_entry_t *loc, const char *name, hid_t dxpl_id) { H5G_entry_t grp_ent, obj_ent; const char *base=NULL; char *norm_name = NULL; /* Pointer to normalized name */ int obj_type; /* Object type */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5G_unlink); /* Sanity check */ assert(loc); assert(name && *name); /* Get normalized copy of the name */ if((norm_name=H5G_normalize(name))==NULL) HGOTO_ERROR (H5E_SYM, H5E_BADVALUE, FAIL, "can't normalize name"); /* Reset the group entries to known values in a portable way */ H5G_ent_reset(&grp_ent); H5G_ent_reset(&obj_ent); /* Get the entry for the group that contains the object to be unlinked */ if (H5G_namei(loc, norm_name, NULL, &grp_ent, &obj_ent, H5G_TARGET_SLINK|H5G_TARGET_MOUNT, NULL, H5G_NAMEI_TRAVERSE, NULL, dxpl_id)<0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found"); if (!H5F_addr_defined(grp_ent.header)) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "no containing group specified"); if (NULL==(base=H5G_basename(norm_name, NULL)) || '/'==*base) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "problems obtaining object base name"); /* Get object type before unlink */ if((obj_type = H5G_get_type(&obj_ent, dxpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't determine object type"); /* Remove the name from the symbol table */ if (H5G_stab_remove(&grp_ent, base, dxpl_id)<0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to unlink name from symbol table"); /* Search the open IDs and replace names for unlinked object */ if (H5G_replace_name(obj_type, &obj_ent, NULL, NULL, NULL, NULL, OP_UNLINK )<0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to replace name"); done: /* Free the ID to name buffers */ H5G_free_ent_name(&grp_ent); H5G_free_ent_name(&obj_ent); /* Free the normalized path name */ if(norm_name) H5MM_xfree(norm_name); FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_move * * Purpose: Atomically rename an object. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Friday, September 25, 1998 * * Modifications: * * Raymond Lu * Thursday, April 18, 2002 * * Pedro Vicente, 22 Aug 2002 * Added `id to name' support. * *------------------------------------------------------------------------- */ static herr_t H5G_move(H5G_entry_t *src_loc, const char *src_name, H5G_entry_t *dst_loc, const char *dst_name, hid_t dxpl_id) { H5G_stat_t sb; char *linkval=NULL; size_t lv_size=32; H5G_entry_t obj_ent; /* Object entry for object being moved */ H5RS_str_t *src_name_r; /* Ref-counted version of src name */ H5RS_str_t *dst_name_r; /* Ref-counted version of dest name */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5G_move); /* Sanity check */ assert(src_loc); assert(dst_loc); assert(src_name && *src_name); assert(dst_name && *dst_name); if (H5G_get_objinfo(src_loc, src_name, FALSE, &sb, dxpl_id)<0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found"); if (H5G_LINK==sb.type) { /* * When renaming a symbolic link we rename the link but don't change * the value of the link. */ do { if (NULL==(linkval=H5MM_realloc(linkval, 2*lv_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate space for symbolic link value"); linkval[lv_size-1] = '\0'; if (H5G_linkval(src_loc, src_name, lv_size, linkval, dxpl_id)<0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read symbolic link value"); } while (linkval[lv_size-1]); if (H5G_link(src_loc, linkval, dst_loc, dst_name, H5G_LINK_SOFT, H5G_TARGET_NORMAL, dxpl_id)<0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to rename symbolic link"); H5MM_xfree(linkval); } else { /* * Rename the object. */ if (H5G_link(src_loc, src_name, dst_loc, dst_name, H5G_LINK_HARD, H5G_TARGET_MOUNT, dxpl_id)<0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to register new name for object"); } /* Search the open ID list and replace names for the move operation * This has to be done here because H5G_link and H5G_unlink have * internal object entries, and do not modify the entries list */ if (H5G_namei(src_loc, src_name, NULL, NULL, &obj_ent, H5G_TARGET_NORMAL|H5G_TARGET_SLINK, NULL, H5G_NAMEI_TRAVERSE, NULL, dxpl_id)) HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "unable to follow symbolic link"); src_name_r=H5RS_wrap(src_name); assert(src_name_r); dst_name_r=H5RS_wrap(dst_name); assert(dst_name_r); if (H5G_replace_name(sb.type, &obj_ent, src_name_r, src_loc, dst_name_r, dst_loc, OP_MOVE )<0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to replace name "); H5RS_decr(src_name_r); H5RS_decr(dst_name_r); H5G_free_ent_name(&obj_ent); /* Remove the old name */ if (H5G_unlink(src_loc, src_name, dxpl_id)<0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to deregister old object name"); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_insertion_file * * Purpose: Given a location and name that specifies a not-yet-existing * object return the file into which the object is about to be * inserted. * * Return: Success: File pointer * * Failure: NULL * * Programmer: Robb Matzke * Wednesday, October 14, 1998 * * Modifications: * * Pedro Vicente, 18 Sep 2002 * Added `id to name' support. * *------------------------------------------------------------------------- */ H5F_t * H5G_insertion_file(H5G_entry_t *loc, const char *name, hid_t dxpl_id) { H5F_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5G_insertion_file, NULL); assert(loc); assert(name && *name); /* Check if the location the object will be inserted into is part of a * file mounting chain (either a parent or a child) and perform a more * rigorous determination of the location's file (which traverses into * mounted files, etc.). */ if(H5F_has_mount(loc->file) || H5F_is_mount(loc->file)) { const char *rest; H5G_entry_t grp_ent; size_t size; /* * Look up the name to get the containing group and to make sure the name * doesn't already exist. */ if (H5G_namei(loc, name, &rest, &grp_ent, NULL, H5G_TARGET_NORMAL, NULL, H5G_NAMEI_TRAVERSE, NULL, dxpl_id)>=0) { H5G_free_ent_name(&grp_ent); HGOTO_ERROR(H5E_SYM, H5E_EXISTS, NULL, "name already exists"); } /* end if */ H5E_clear(); /* Make sure only the last component wasn't resolved */ rest = H5G_component(rest, &size); assert(*rest && size>0); rest = H5G_component(rest+size, NULL); if (*rest) { H5G_free_ent_name(&grp_ent); HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "insertion point not found"); } /* end if */ /* Set return value */ ret_value=grp_ent.file; /* Free the ID to name buffer */ H5G_free_ent_name(&grp_ent); } /* end if */ else /* Use the location's file */ ret_value=loc->file; done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_free_grp_name * * Purpose: Free the 'ID to name' buffers. * * Return: Non-negative on success/Negative on failure * * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu * * Date: August 22, 2002 * * Comments: Used now only on the root group close, in H5F_close() * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5G_free_grp_name(H5G_t *grp) { H5G_entry_t *ent; /* Group object's entry */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5G_free_grp_name, FAIL); /* Check args */ assert(grp && grp->shared); assert(grp->shared->fo_count > 0); /* Get the entry for the group */ if (NULL==( ent = H5G_entof(grp))) HGOTO_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "cannot get entry"); /* Free the entry */ H5G_free_ent_name(ent); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_free_ent_name * * Purpose: Free the 'ID to name' buffers. * * Return: Success * * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu * * Date: August 22, 2002 * * Comments: * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5G_free_ent_name(H5G_entry_t *ent) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5G_free_ent_name, FAIL); /* Check args */ assert(ent); if(ent->user_path_r) { H5RS_decr(ent->user_path_r); ent->user_path_r=NULL; } /* end if */ if(ent->canon_path_r) { H5RS_decr(ent->canon_path_r); ent->canon_path_r=NULL; } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_replace_name * * Purpose: Search the list of open IDs and replace names according to a * particular operation. The operation occured on the LOC * entry, which had SRC_NAME previously. The new name (if there * is one) is DST_NAME. Additional entry location information * (currently only needed for the 'move' operation) is passed * in SRC_LOC and DST_LOC. * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu * * Date: June 11, 2002 * * Comments: * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5G_replace_name(int type, H5G_entry_t *loc, H5RS_str_t *src_name, H5G_entry_t *src_loc, H5RS_str_t *dst_name, H5G_entry_t *dst_loc, H5G_names_op_t op ) { H5G_names_t names; /* Structure to hold operation information for callback */ unsigned search_group=0; /* Flag to indicate that groups are to be searched */ unsigned search_dataset=0; /* Flag to indicate that datasets are to be searched */ unsigned search_datatype=0; /* Flag to indicate that datatypes are to be searched */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5G_replace_name, FAIL); /* Set up common information for callback */ names.src_name=src_name; names.dst_name=dst_name; names.loc=loc; names.src_loc=src_loc; names.dst_loc=dst_loc; names.op=op; /* Determine which types of IDs need to be operated on */ switch(type) { /* Object is a group */ case H5G_GROUP: /* Search and replace names through group IDs */ search_group=1; break; /* Object is a dataset */ case H5G_DATASET: /* Search and replace names through dataset IDs */ search_dataset=1; break; /* Object is a named datatype */ case H5G_TYPE: /* Search and replace names through datatype IDs */ search_datatype=1; break; case H5G_UNKNOWN: /* We pass H5G_UNKNOWN as object type when we need to search all IDs */ case H5G_LINK: /* Symbolic links might resolve to any object, so we need to search all IDs */ /* Check if we will need to search groups */ if(H5I_nmembers(H5I_GROUP)>0) search_group=1; /* Check if we will need to search datasets */ if(H5I_nmembers(H5I_DATASET)>0) search_dataset=1; /* Check if we will need to search datatypes */ if(H5I_nmembers(H5I_DATATYPE)>0) search_datatype=1; break; default: HGOTO_ERROR (H5E_DATATYPE, H5E_BADTYPE, FAIL, "not valid object type"); } /* end switch */ /* Search through group IDs */ if(search_group) H5I_search(H5I_GROUP, H5G_replace_ent, &names); /* Search through dataset IDs */ if(search_dataset) H5I_search(H5I_DATASET, H5G_replace_ent, &names); /* Search through datatype IDs */ if(search_datatype) H5I_search(H5I_DATATYPE, H5G_replace_ent, &names); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_common_path * * Purpose: Determine if one path is a valid prefix of another path * * Return: TRUE for valid prefix, FALSE for not a valid prefix, FAIL * on error * * Programmer: Quincey Koziol, koziol@ncsa.uiuc.edu * * Date: September 24, 2002 * * Comments: * * Modifications: * *------------------------------------------------------------------------- */ static htri_t H5G_common_path(const H5RS_str_t *fullpath_r, const H5RS_str_t *prefix_r) { const char *fullpath; /* Pointer to actual fullpath string */ const char *prefix; /* Pointer to actual prefix string */ size_t nchars1,nchars2; /* Number of characters in components */ htri_t ret_value=FALSE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_common_path); /* Get component of each name */ fullpath=H5RS_get_str(fullpath_r); assert(fullpath); fullpath=H5G_component(fullpath,&nchars1); assert(fullpath); prefix=H5RS_get_str(prefix_r); assert(prefix); prefix=H5G_component(prefix,&nchars2); assert(prefix); /* Check if we have a real string for each component */ while(*fullpath && *prefix) { /* Check that the components we found are the same length */ if(nchars1==nchars2) { /* Check that the two components are equal */ if(HDstrncmp(fullpath,prefix,nchars1)==0) { /* Advance the pointers in the names */ fullpath+=nchars1; prefix+=nchars2; /* Get next component of each name */ fullpath=H5G_component(fullpath,&nchars1); assert(fullpath); prefix=H5G_component(prefix,&nchars2); assert(prefix); } /* end if */ else HGOTO_DONE(FALSE); } /* end if */ else HGOTO_DONE(FALSE); } /* end while */ /* If we reached the end of the prefix path to check, it must be a valid prefix */ if(*prefix=='\0') ret_value=TRUE; done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_build_fullpath * * Purpose: Build a full path from a prefix & base pair of reference counted * strings * * Return: Pointer to reference counted string on success, NULL on error * * Programmer: Quincey Koziol, koziol@ncsa.uiuc.edu * * Date: August 19, 2005 * * Comments: * * Modifications: * *------------------------------------------------------------------------- */ static H5RS_str_t * H5G_build_fullpath(const H5RS_str_t *prefix_r, const H5RS_str_t *name_r) { const char *prefix; /* Pointer to raw string of prefix */ const char *name; /* Pointer to raw string of name */ char *full_path; /* Full user path built */ size_t path_len; /* Length of the path */ unsigned need_sep; /* Flag to indicate if separator is needed */ H5RS_str_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5G_build_fullpath) /* Get the pointer to the prefix */ prefix=H5RS_get_str(prefix_r); /* Get the length of the prefix */ path_len=HDstrlen(prefix); /* Determine if there is a trailing separator in the name */ if(prefix[path_len-1]=='/') need_sep=0; else need_sep=1; /* Get the pointer to the raw src user path */ name=H5RS_get_str(name_r); /* Add in the length needed for the '/' separator and the relative path */ path_len+=HDstrlen(name)+need_sep; /* Allocate space for the path */ if(NULL==(full_path = H5FL_BLK_MALLOC(str_buf,path_len+1))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Build full path */ HDstrcpy(full_path,prefix); if(need_sep) HDstrcat(full_path,"/"); HDstrcat(full_path,name); /* Create reference counted string for path */ ret_value=H5RS_own(full_path); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_build_fullpath() */ /*------------------------------------------------------------------------- * Function: H5G_replace_ent * * Purpose: H5I_search callback function to replace group entry names * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu * * Date: June 5, 2002 * * Comments: * * Modifications: * *------------------------------------------------------------------------- */ static int H5G_replace_ent(void *obj_ptr, hid_t obj_id, void *key) { const H5G_names_t *names = (const H5G_names_t *)key; /* Get operation's information */ H5G_entry_t *ent = NULL; /* Group entry for object that the ID refers to */ H5F_t *top_ent_file; /* Top file in entry's mounted file chain */ H5F_t *top_loc_file; /* Top file in location's mounted file chain */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5G_replace_ent); assert(obj_ptr); /* Get the symbol table entry */ switch(H5I_get_type(obj_id)) { case H5I_GROUP: ent = H5G_entof((H5G_t*)obj_ptr); break; case H5I_DATASET: ent = H5D_entof((H5D_t*)obj_ptr); break; case H5I_DATATYPE: /* Avoid non-named datatypes */ if(!H5T_is_named((H5T_t*)obj_ptr)) HGOTO_DONE(SUCCEED); /* Do not exit search over IDs */ ent = H5T_entof((H5T_t*)obj_ptr); break; default: HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unknown data object"); } /* end switch */ assert(ent); switch(names->op) { /*------------------------------------------------------------------------- * OP_MOUNT *------------------------------------------------------------------------- */ case OP_MOUNT: if(ent->user_path_r) { if(ent->file->mtab.parent && H5RS_cmp(ent->user_path_r,ent->canon_path_r)) { /* Find the "top" file in the chain of mounted files */ top_ent_file=ent->file->mtab.parent; while(top_ent_file->mtab.parent!=NULL) top_ent_file=top_ent_file->mtab.parent; } /* end if */ else top_ent_file=ent->file; /* Check for entry being in correct file (or mounted file) */ if(top_ent_file->shared == names->loc->file->shared) { /* Check if the source is along the entry's path */ /* (But not actually the entry itself) */ if(H5G_common_path(ent->user_path_r,names->src_name) && H5RS_cmp(ent->user_path_r,names->src_name)!=0) { /* Hide the user path */ ent->user_path_hidden++; } /* end if */ } /* end if */ } /* end if */ break; /*------------------------------------------------------------------------- * OP_UNMOUNT *------------------------------------------------------------------------- */ case OP_UNMOUNT: if(ent->user_path_r) { if(ent->file->mtab.parent) { /* Find the "top" file in the chain of mounted files for the entry */ top_ent_file=ent->file->mtab.parent; while(top_ent_file->mtab.parent!=NULL) top_ent_file=top_ent_file->mtab.parent; } /* end if */ else top_ent_file=ent->file; if(names->loc->file->mtab.parent) { /* Find the "top" file in the chain of mounted files for the location */ top_loc_file=names->loc->file->mtab.parent; while(top_loc_file->mtab.parent!=NULL) top_loc_file=top_loc_file->mtab.parent; } /* end if */ else top_loc_file=names->loc->file; /* If the ID's entry is not in the file we operated on, skip it */ if(top_ent_file->shared == top_loc_file->shared) { if(ent->user_path_hidden) { if(H5G_common_path(ent->user_path_r,names->src_name)) { /* Un-hide the user path */ ent->user_path_hidden--; } /* end if */ } /* end if */ else { if(H5G_common_path(ent->user_path_r,names->src_name)) { /* Free user path */ H5RS_decr(ent->user_path_r); ent->user_path_r=NULL; } /* end if */ } /* end else */ } /* end if */ } /* end if */ break; /*------------------------------------------------------------------------- * OP_UNLINK *------------------------------------------------------------------------- */ case OP_UNLINK: /* If the ID's entry is not in the file we operated on, skip it */ if(ent->file->shared == names->loc->file->shared && names->loc->canon_path_r && ent->canon_path_r && ent->user_path_r) { /* Check if we are referring to the same object */ if(H5F_addr_eq(ent->header, names->loc->header)) { /* Check if the object was opened with the same canonical path as the one being moved */ if(H5RS_cmp(ent->canon_path_r,names->loc->canon_path_r)==0) { /* Free user path */ H5RS_decr(ent->user_path_r); ent->user_path_r=NULL; } /* end if */ } /* end if */ else { /* Check if the location being unlinked is in the canonical path for the current object */ if(H5G_common_path(ent->canon_path_r,names->loc->canon_path_r)) { /* Free user path */ H5RS_decr(ent->user_path_r); ent->user_path_r=NULL; } /* end if */ } /* end else */ } /* end if */ break; /*------------------------------------------------------------------------- * OP_MOVE *------------------------------------------------------------------------- */ case OP_MOVE: /* H5Gmove case, check for relative names case */ /* If the ID's entry is not in the file we operated on, skip it */ if(ent->file->shared == names->loc->file->shared) { if(ent->user_path_r && names->loc->user_path_r && names->src_loc->user_path_r && names->dst_loc->user_path_r) { H5RS_str_t *src_path_r; /* Full user path of source name */ H5RS_str_t *dst_path_r; /* Full user path of destination name */ H5RS_str_t *canon_src_path_r; /* Copy of canonical part of source path */ H5RS_str_t *canon_dst_path_r; /* Copy of canonical part of destination path */ /* Sanity check */ HDassert(names->src_name); HDassert(names->dst_name); /* Make certain that the source and destination names are full (not relative) paths */ if(*(H5RS_get_str(names->src_name))!='/') { /* Create reference counted string for full src path */ if((src_path_r = H5G_build_fullpath(names->src_loc->user_path_r, names->src_name)) == NULL) HGOTO_ERROR (H5E_SYM, H5E_PATH, FAIL, "can't build source path name") } /* end if */ else src_path_r=H5RS_dup(names->src_name); if(*(H5RS_get_str(names->dst_name))!='/') { /* Create reference counted string for full dst path */ if((dst_path_r = H5G_build_fullpath(names->dst_loc->user_path_r, names->dst_name)) == NULL) HGOTO_ERROR (H5E_SYM, H5E_PATH, FAIL, "can't build destination path name") } /* end if */ else dst_path_r=H5RS_dup(names->dst_name); /* Get the canonical parts of the source and destination names */ /* Check if the object being moved was accessed through a mounted file */ if(H5RS_cmp(names->loc->user_path_r,names->loc->canon_path_r)!=0) { size_t non_canon_name_len; /* Length of non-canonical part of name */ /* Get current string lengths */ non_canon_name_len=H5RS_len(names->loc->user_path_r)-H5RS_len(names->loc->canon_path_r); canon_src_path_r=H5RS_create(H5RS_get_str(src_path_r)+non_canon_name_len); canon_dst_path_r=H5RS_create(H5RS_get_str(dst_path_r)+non_canon_name_len); } /* end if */ else { canon_src_path_r=H5RS_dup(src_path_r); canon_dst_path_r=H5RS_dup(dst_path_r); } /* end else */ /* Check if the link being changed in the file is along the canonical path for this object */ if(H5G_common_path(ent->canon_path_r,canon_src_path_r)) { size_t user_dst_len; /* Length of destination user path */ size_t canon_dst_len; /* Length of destination canonical path */ const char *old_user_path; /* Pointer to previous user path */ char *new_user_path; /* Pointer to new user path */ char *new_canon_path; /* Pointer to new canonical path */ const char *tail_path; /* Pointer to "tail" of path */ size_t tail_len; /* Pointer to "tail" of path */ char *src_canon_prefix; /* Pointer to source canonical path prefix of component which is moving */ size_t src_canon_prefix_len;/* Length of the source canonical path prefix */ char *dst_canon_prefix; /* Pointer to destination canonical path prefix of component which is moving */ size_t dst_canon_prefix_len;/* Length of the destination canonical path prefix */ char *user_prefix; /* Pointer to user path prefix of component which is moving */ size_t user_prefix_len; /* Length of the user path prefix */ char *src_comp; /* The source name of the component which is actually changing */ char *dst_comp; /* The destination name of the component which is actually changing */ const char *canon_src_path; /* pointer to canonical part of source path */ const char *canon_dst_path; /* pointer to canonical part of destination path */ /* Get the pointers to the raw strings */ canon_src_path=H5RS_get_str(canon_src_path_r); canon_dst_path=H5RS_get_str(canon_dst_path_r); /* Get the source & destination components */ src_comp=HDstrrchr(canon_src_path,'/'); assert(src_comp); dst_comp=HDstrrchr(canon_dst_path,'/'); assert(dst_comp); /* Find the canonical prefixes for the entry */ src_canon_prefix_len=HDstrlen(canon_src_path)-HDstrlen(src_comp); if(NULL==(src_canon_prefix = H5MM_malloc(src_canon_prefix_len+1))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); HDstrncpy(src_canon_prefix,canon_src_path,src_canon_prefix_len); src_canon_prefix[src_canon_prefix_len]='\0'; dst_canon_prefix_len=HDstrlen(canon_dst_path)-HDstrlen(dst_comp); if(NULL==(dst_canon_prefix = H5MM_malloc(dst_canon_prefix_len+1))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); HDstrncpy(dst_canon_prefix,canon_dst_path,dst_canon_prefix_len); dst_canon_prefix[dst_canon_prefix_len]='\0'; /* Hold this for later use */ old_user_path=H5RS_get_str(ent->user_path_r); /* Find the user prefix for the entry */ user_prefix_len=HDstrlen(old_user_path)-H5RS_len(ent->canon_path_r); if(NULL==(user_prefix = H5MM_malloc(user_prefix_len+1))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); HDstrncpy(user_prefix,old_user_path,user_prefix_len); user_prefix[user_prefix_len]='\0'; /* Set the tail path info */ tail_path=old_user_path+user_prefix_len+src_canon_prefix_len+HDstrlen(src_comp); tail_len=HDstrlen(tail_path); /* Get the length of the destination paths */ user_dst_len=user_prefix_len+dst_canon_prefix_len+HDstrlen(dst_comp)+tail_len; canon_dst_len=dst_canon_prefix_len+HDstrlen(dst_comp)+tail_len; /* Allocate space for the new user path */ if(NULL==(new_user_path = H5FL_BLK_MALLOC(str_buf,user_dst_len+1))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); /* Allocate space for the new canonical path */ if(NULL==(new_canon_path = H5FL_BLK_MALLOC(str_buf,canon_dst_len+1))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); /* Create the new names */ HDstrcpy(new_user_path,user_prefix); HDstrcat(new_user_path,dst_canon_prefix); HDstrcat(new_user_path,dst_comp); HDstrcat(new_user_path,tail_path); HDstrcpy(new_canon_path,dst_canon_prefix); HDstrcat(new_canon_path,dst_comp); HDstrcat(new_canon_path,tail_path); /* Release the old user & canonical paths */ H5RS_decr(ent->user_path_r); H5RS_decr(ent->canon_path_r); /* Take ownership of the new user & canonical paths */ ent->user_path_r=H5RS_own(new_user_path); ent->canon_path_r=H5RS_own(new_canon_path); /* Free the extra paths allocated */ H5MM_xfree(src_canon_prefix); H5MM_xfree(dst_canon_prefix); H5MM_xfree(user_prefix); } /* end if */ /* Free the extra paths allocated */ H5RS_decr(src_path_r); H5RS_decr(dst_path_r); H5RS_decr(canon_src_path_r); H5RS_decr(canon_dst_path_r); } /* end if */ else { /* Release the old user path */ if(ent->user_path_r) { H5RS_decr(ent->user_path_r); ent->user_path_r = NULL; } /* end if */ } /* end else */ } /* end if */ break; default: HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid call"); } /* end switch */ done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_get_shared_count * * Purpose: Queries the group object's "shared count" * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Tuesday, July 5, 2005 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5G_get_shared_count(H5G_t *grp) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_get_shared_count); /* Check args */ HDassert(grp && grp->shared); FUNC_LEAVE_NOAPI(grp->shared->fo_count); } /* end H5G_get_shared_count() */ /*------------------------------------------------------------------------- * Function: H5G_mount * * Purpose: Sets the 'mounted' flag for a group * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Tuesday, July 19, 2005 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5G_mount(H5G_t *grp) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_mount); /* Check args */ HDassert(grp && grp->shared); HDassert(grp->shared->mounted == FALSE); /* Set the 'mounted' flag */ grp->shared->mounted = TRUE; FUNC_LEAVE_NOAPI(SUCCEED); } /* end H5G_mount() */ /*------------------------------------------------------------------------- * Function: H5G_unmount * * Purpose: Resets the 'mounted' flag for a group * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Tuesday, July 19, 2005 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5G_unmount(H5G_t *grp) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_unmount); /* Check args */ HDassert(grp && grp->shared); HDassert(grp->shared->mounted == TRUE); /* Reset the 'mounted' flag */ grp->shared->mounted = FALSE; FUNC_LEAVE_NOAPI(SUCCEED); } /* end H5G_unmount() */ xdmf-3.0+git20160803/Utilities/hdf5/H5MF.c0000640000175000017500000003364113003006557017545 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*------------------------------------------------------------------------- * * Created: H5MF.c * Jul 11 1997 * Robb Matzke * * Purpose: File memory management functions. * * Modifications: * Robb Matzke, 5 Aug 1997 * Added calls to H5E. * * Robb Matzke, 8 Jun 1998 * Implemented a very simple free list which is not persistent and which * is lossy. * *------------------------------------------------------------------------- */ #define H5F_PACKAGE /*suppress error about including H5Fpkg */ #include "H5private.h" #include "H5Eprivate.h" #include "H5Fpkg.h" #include "H5FDprivate.h" #include "H5MFprivate.h" /*------------------------------------------------------------------------- * Function: H5MF_alloc * * Purpose: Allocate SIZE bytes of file memory and return the relative * address where that contiguous chunk of file memory exists. * The TYPE argument describes the purpose for which the storage * is being requested. * * Return: Success: The file address of new chunk. * * Failure: HADDR_UNDEF * * Programmer: Robb Matzke * matzke@llnl.gov * Jul 11 1997 * * Modifications: * Robb Matzke, 1999-08-04 * Modified to work with the virtual file layer. *------------------------------------------------------------------------- */ haddr_t H5MF_alloc(H5F_t *f, H5FD_mem_t type, hid_t dxpl_id, hsize_t size) { haddr_t ret_value; FUNC_ENTER_NOAPI(H5MF_alloc, HADDR_UNDEF); /* check arguments */ assert(f); assert(size > 0); /* Fail if we don't have write access */ if (0==(f->intent & H5F_ACC_RDWR)) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, HADDR_UNDEF, "file is read-only"); /* Check that the file can address the new space */ if( H5MF_alloc_overflow(f, size) ) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, "not enough address space in file"); /* Allocate space from the virtual file layer */ if (HADDR_UNDEF==(ret_value=H5FD_alloc(f->shared->lf, type, dxpl_id, size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, "file allocation failed"); /* Convert absolute file address to relative file address */ assert(ret_value>=f->shared->base_addr); /* Set return value */ ret_value -= f->shared->base_addr; done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5MF_xfree * * Purpose: Frees part of a file, making that part of the file * available for reuse. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Jul 17 1997 * * Modifications: * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value * * Robb Matzke, 1999-08-03 * Modified to use the virtual file layer. *------------------------------------------------------------------------- */ herr_t H5MF_xfree(H5F_t *f, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOFUNC(H5MF_xfree); /* check arguments */ assert(f); if (!H5F_addr_defined(addr) || 0 == size) HGOTO_DONE(SUCCEED); assert(addr!=0); /* Convert relative address to absolute address */ addr += f->shared->base_addr; /* Allow virtual file layer to free block */ if (H5FD_free(f->shared->lf, type, dxpl_id, addr, size)<0) { #ifdef H5MF_DEBUG if (H5DEBUG(MF)) { fprintf(H5DEBUG(MF), "H5MF_free: lost %lu bytes of file storage\n", (unsigned long)size); } #endif } done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5MF_realloc * * Purpose: Changes the size of an allocated chunk, possibly moving it to * a new address. The chunk to change is at address OLD_ADDR * and is exactly OLD_SIZE bytes (if these are H5F_ADDR_UNDEF * and zero then this function acts like H5MF_alloc). The new * size will be NEW_SIZE and its address is the return value (if * NEW_SIZE is zero then this function acts like H5MF_free and * an undefined address is returned). * * If the new size is less than the old size then the new * address will be the same as the old address (except for the * special case where the new size is zero). * * If the new size is more than the old size then most likely a * new address will be returned. However, under certain * circumstances the library may return the same address. * * Return: Success: The relative file address of the new block. * * Failure: HADDR_UNDEF * * Programmer: Robb Matzke * Thursday, April 16, 1998 * * Modifications: * Robb Matzke, 1999-07-28 * The ORIG_ADDR is passed by value. The name of NEW_ADDR has * been changed to NEW_ADDR_P * * Robb Matzke, 1999-08-04 * Modified to work with the virtual file layer. *------------------------------------------------------------------------- */ haddr_t H5MF_realloc(H5F_t *f, H5FD_mem_t type, hid_t dxpl_id, haddr_t old_addr, hsize_t old_size, hsize_t new_size) { haddr_t ret_value; FUNC_ENTER_NOAPI(H5MF_realloc, HADDR_UNDEF); /* Convert old relative address to absolute address */ old_addr += f->shared->base_addr; /* Check that the file can address the new space. */ /* In the worst case, this means adding new_size bytes to the end of the file. */ if( H5MF_alloc_overflow(f, new_size) ) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, "not enough address space in file"); /* Reallocate memory from the virtual file layer */ ret_value = H5FD_realloc(f->shared->lf, type, dxpl_id, old_addr, old_size, new_size); if (HADDR_UNDEF==ret_value) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, "unable to allocate new file memory"); /* Convert return value to relative address */ assert(ret_value>=f->shared->base_addr); /* Set return value */ ret_value -= f->shared->base_addr; done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5MF_reserve * * Purpose: Sets aside file space that has not yet been allocated, but will * be (or might be in the worst case). This number is used to * ensure that there is room in the file when it is flushed to disk. * * Nothing changes (and no error is generated) if the file is opened * as read-only. * * Return: Success: 0 * * Failure: negative * * Programmer: James Laird * Nat Furrer * Thursday, May 27, 2004 * * Modifications: *------------------------------------------------------------------------- */ herr_t H5MF_reserve(H5F_t *f, hsize_t size) { herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5MF_reserve, FAIL); /* Check arguments */ assert(f); /* Check that there is room in the file to reserve this space */ if( H5MF_alloc_overflow( f, size ) ) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "not enough address space in file"); f->shared->lf->reserved_alloc += size; done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5MF_free_reserved * * Purpose: Releases the file space set aside by H5MF_reserve. This should * be called immediately before allocating the file space for which * the space was reserved. * * Return: None * * Programmer: James Laird * Nat Furrer * Thursday, May 27, 2004 * * Modifications: *------------------------------------------------------------------------- */ herr_t H5MF_free_reserved(H5F_t *f, hsize_t size) { FUNC_ENTER_NOAPI_NOFUNC(H5MF_free_reserved) /* Check arguments */ assert(f); /* If this assert breaks, it means that HDF5 is trying to free file space * that was never reserved. */ assert(size <= f->shared->lf->reserved_alloc); f->shared->lf->reserved_alloc -= size; FUNC_LEAVE_NOAPI(SUCCEED) } /*------------------------------------------------------------------------- * Function: H5MF_alloc_overflow * * Purpose: Checks if an allocation of file space would cause an overflow. * F is the file whose space is being allocated, SIZE is the amount * of space needed. * * Return: 0 if no overflow would result * 1 if overflow would result (the allocation should not be allowed) * * Programmer: James Laird * Nat Furrer * Tuesday, June 1, 2004 * * Modifications: *------------------------------------------------------------------------- */ hbool_t H5MF_alloc_overflow(H5F_t *f, hsize_t size) { hsize_t space_needed; /* Accumulator variable */ size_t c; /* Local index variable */ hbool_t ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOFUNC(H5MF_alloc_overflow) /* Start with the current end of the file's address. */ space_needed = (hsize_t)H5F_get_eoa(f); HDassert(H5F_addr_defined(space_needed)); /* Subtract the file's base address to get the actual amount of * space being used: * (end of allocated space - beginning of allocated space) */ HDassert(H5F_BASE_ADDR(f) < space_needed); space_needed -= (hsize_t)H5F_BASE_ADDR(f); /* Add the amount of space requested for this allocation */ space_needed += size; /* Also add space that is "reserved" for data to be flushed * to disk (e.g., for object headers and the heap). * This is the total amount of file space that will be * allocated. */ space_needed += f->shared->lf->reserved_alloc; /* Ensure that this final number is less than the file's * address space. We do this by shifting in multiples * of 16 bits because some systems will do nothing if * we shift by the size of a long long (64 bits) all at * once ( Linux ). Thus, we break one shift * into several smaller shifts. */ for(c=0; c < H5F_SIZEOF_ADDR(f); c += 2) space_needed = space_needed >> 16; if(space_needed != 0) ret_value=TRUE; else ret_value=FALSE; FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5MF_can_extend * * Purpose: Check if a block in the file can be extended. * * This is a simple check currently, which only checks for the * block being at the end of the file. A more sophisticated check * would also use the free space list to see if there is a block * appropriately placed to accomodate the space requested. * * Return: Success: TRUE(1)/FALSE(0) * * Failure: FAIL * * Programmer: Quincey Koziol * Friday, June 11, 2004 * * Modifications: * *------------------------------------------------------------------------- */ htri_t H5MF_can_extend(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size, hsize_t extra_requested) { htri_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5MF_can_extend, FAIL); /* Convert old relative address to absolute address */ addr += H5F_BASE_ADDR(f); /* Pass the request down to the virtual file layer */ if((ret_value=H5FD_can_extend(f->shared->lf, type, addr, size, extra_requested))<0) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate new file memory"); /* Make sure there is enough addressable space to satisfy the request */ if (ret_value == TRUE) ret_value = !H5MF_alloc_overflow(f, extra_requested); done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5MF_can_extend() */ /*------------------------------------------------------------------------- * Function: H5MF_extend * * Purpose: Extend a block in the file. * * Return: Success: TRUE(1)/FALSE(0) * * Failure: FAIL * * Programmer: Quincey Koziol * Saturday, June 12, 2004 * * Modifications: * *------------------------------------------------------------------------- */ htri_t H5MF_extend(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size, hsize_t extra_requested) { htri_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5MF_extend, FAIL); /* Make sure there is enough addressable space to satisfy the request */ if ( H5MF_alloc_overflow(f, extra_requested) ) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate new file memory: out of address space"); /* Convert old relative address to absolute address */ addr += H5F_BASE_ADDR(f); /* Pass the request down to the virtual file layer */ if((ret_value=H5FD_extend(f->shared->lf, type, addr, size, extra_requested))<0) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate new file memory"); done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5MF_extend() */ xdmf-3.0+git20160803/Utilities/hdf5/H5Osdspace.c0000640000175000017500000003423313003006557021002 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #define H5O_PACKAGE /*suppress error about including H5Opkg */ #define H5S_PACKAGE /*prevent warning from including H5Spkg.h */ #include "H5private.h" #include "H5Eprivate.h" #include "H5FLprivate.h" /*Free Lists */ #include "H5Gprivate.h" #include "H5MMprivate.h" #include "H5Opkg.h" /* Object header functions */ #include "H5Spkg.h" /* PRIVATE PROTOTYPES */ static void *H5O_sdspace_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t *sh); static herr_t H5O_sdspace_encode(H5F_t *f, uint8_t *p, const void *_mesg); static void *H5O_sdspace_copy(const void *_mesg, void *_dest, unsigned update_flags); static size_t H5O_sdspace_size(const H5F_t *f, const void *_mesg); static herr_t H5O_sdspace_reset(void *_mesg); static herr_t H5O_sdspace_free (void *_mesg); static herr_t H5O_sdspace_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * stream, int indent, int fwidth); /* This message derives from H5O */ const H5O_class_t H5O_SDSPACE[1] = {{ H5O_SDSPACE_ID, /* message id number */ "simple_dspace", /* message name for debugging */ sizeof(H5S_extent_t), /* native message size */ H5O_sdspace_decode, /* decode message */ H5O_sdspace_encode, /* encode message */ H5O_sdspace_copy, /* copy the native value */ H5O_sdspace_size, /* size of symbol table entry */ H5O_sdspace_reset, /* default reset method */ H5O_sdspace_free, /* free method */ NULL, /* file delete method */ NULL, /* link method */ NULL, /* get share method */ NULL, /* set share method */ H5O_sdspace_debug, /* debug the message */ }}; #define H5O_SDSPACE_VERSION 1 /* Declare external the free list for H5S_extent_t's */ H5FL_EXTERN(H5S_extent_t); /* Declare external the free list for hsize_t arrays */ H5FL_ARR_EXTERN(hsize_t); /*-------------------------------------------------------------------------- NAME H5O_sdspace_decode PURPOSE Decode a simple dimensionality message and return a pointer to a memory struct with the decoded information USAGE void *H5O_sdspace_decode(f, raw_size, p) H5F_t *f; IN: pointer to the HDF5 file struct size_t raw_size; IN: size of the raw information buffer const uint8 *p; IN: the raw information buffer RETURNS Pointer to the new message in native order on success, NULL on failure DESCRIPTION This function decodes the "raw" disk form of a simple dimensionality message into a struct in memory native format. The struct is allocated within this function using malloc() and is returned to the caller. MODIFICATIONS Robb Matzke, 1998-04-09 The current and maximum dimensions are now H5F_SIZEOF_SIZET bytes instead of just four bytes. Robb Matzke, 1998-07-20 Added a version number and reformatted the message for aligment. --------------------------------------------------------------------------*/ static void * H5O_sdspace_decode(H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *p, H5O_shared_t UNUSED *sh) { H5S_extent_t *sdim = NULL;/* New extent dimensionality structure */ void *ret_value; unsigned i; /* local counting variable */ unsigned flags, version; FUNC_ENTER_NOAPI_NOINIT(H5O_sdspace_decode); /* check args */ assert(f); assert(p); assert (!sh); /* decode */ if ((sdim = H5FL_CALLOC(H5S_extent_t)) != NULL) { /* Check version */ version = *p++; if (version!=H5O_SDSPACE_VERSION) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "wrong version number in data space message"); /* Get rank */ sdim->rank = *p++; if (sdim->rank>H5S_MAX_RANK) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "simple data space dimensionality is too large"); /* Get dataspace flags for later */ flags = *p++; /* Set the dataspace type to be simple or scalar as appropriate */ if(sdim->rank>0) sdim->type = H5S_SIMPLE; else sdim->type = H5S_SCALAR; p += 5; /*reserved*/ if (sdim->rank > 0) { if (NULL==(sdim->size=H5FL_ARR_MALLOC(hsize_t,sdim->rank))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); for (i = 0; i < sdim->rank; i++) H5F_DECODE_LENGTH (f, p, sdim->size[i]); if (flags & H5S_VALID_MAX) { if (NULL==(sdim->max=H5FL_ARR_MALLOC(hsize_t,sdim->rank))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); for (i = 0; i < sdim->rank; i++) H5F_DECODE_LENGTH (f, p, sdim->max[i]); } } /* Compute the number of elements in the extent */ for(i=0, sdim->nelem=1; irank; i++) sdim->nelem*=sdim->size[i]; } /* Set return value */ ret_value = (void*)sdim; /*success*/ done: if (!ret_value && sdim) { H5S_extent_release(sdim); H5FL_FREE(H5S_extent_t,sdim); } /* end if */ FUNC_LEAVE_NOAPI(ret_value); } /*-------------------------------------------------------------------------- NAME H5O_sdspace_encode PURPOSE Encode a simple dimensionality message USAGE herr_t H5O_sdspace_encode(f, raw_size, p, mesg) H5F_t *f; IN: pointer to the HDF5 file struct size_t raw_size; IN: size of the raw information buffer const uint8 *p; IN: the raw information buffer const void *mesg; IN: Pointer to the extent dimensionality struct RETURNS Non-negative on success/Negative on failure DESCRIPTION This function encodes the native memory form of the simple dimensionality message in the "raw" disk form. MODIFICATIONS Robb Matzke, 1998-04-09 The current and maximum dimensions are now H5F_SIZEOF_SIZET bytes instead of just four bytes. Robb Matzke, 1998-07-20 Added a version number and reformatted the message for aligment. --------------------------------------------------------------------------*/ static herr_t H5O_sdspace_encode(H5F_t *f, uint8_t *p, const void *mesg) { const H5S_extent_t *sdim = (const H5S_extent_t *) mesg; unsigned u; /* Local counting variable */ unsigned flags = 0; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_sdspace_encode); /* check args */ assert(f); assert(p); assert(sdim); /* set flags */ if (sdim->max) flags |= H5S_VALID_MAX; /* encode */ *p++ = H5O_SDSPACE_VERSION; *p++ = sdim->rank; *p++ = flags; *p++ = 0; /*reserved*/ *p++ = 0; /*reserved*/ *p++ = 0; /*reserved*/ *p++ = 0; /*reserved*/ *p++ = 0; /*reserved*/ if (sdim->rank > 0) { for (u = 0; u < sdim->rank; u++) H5F_ENCODE_LENGTH (f, p, sdim->size[u]); if (flags & H5S_VALID_MAX) { for (u = 0; u < sdim->rank; u++) H5F_ENCODE_LENGTH (f, p, sdim->max[u]); } } FUNC_LEAVE_NOAPI(SUCCEED); } /*-------------------------------------------------------------------------- NAME H5O_sdspace_copy PURPOSE Copies a message from MESG to DEST, allocating DEST if necessary. USAGE void *H5O_sdspace_copy(mesg, dest) const void *mesg; IN: Pointer to the source extent dimensionality struct const void *dest; IN: Pointer to the destination extent dimensionality struct RETURNS Pointer to DEST on success, NULL on failure DESCRIPTION This function copies a native (memory) simple dimensionality message, allocating the destination structure if necessary. MODIFICATIONS Raymond Lu April 8, 2004 Changed operation on H5S_simple_t to H5S_extent_t. --------------------------------------------------------------------------*/ static void * H5O_sdspace_copy(const void *mesg, void *dest, unsigned UNUSED update_flags) { const H5S_extent_t *src = (const H5S_extent_t *) mesg; H5S_extent_t *dst = (H5S_extent_t *) dest; void *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_sdspace_copy); /* check args */ assert(src); if (!dst && NULL==(dst = H5FL_MALLOC(H5S_extent_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); /* Copy extent information */ if(H5S_extent_copy(dst,src)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy extent"); /* Set return value */ ret_value=dst; done: FUNC_LEAVE_NOAPI(ret_value); } /*-------------------------------------------------------------------------- NAME H5O_sdspace_size PURPOSE Return the raw message size in bytes USAGE void *H5O_sdspace_size(f, mesg) H5F_t *f; IN: pointer to the HDF5 file struct const void *mesg; IN: Pointer to the source extent dimensionality struct RETURNS Size of message on success, zero on failure DESCRIPTION This function returns the size of the raw simple dimensionality message on success. (Not counting the message type or size fields, only the data portion of the message). It doesn't take into account alignment. MODIFICATIONS Robb Matzke, 1998-04-09 The current and maximum dimensions are now H5F_SIZEOF_SIZET bytes instead of just four bytes. --------------------------------------------------------------------------*/ static size_t H5O_sdspace_size(const H5F_t *f, const void *mesg) { const H5S_extent_t *space = (const H5S_extent_t *) mesg; /* * All dimensionality messages are at least 8 bytes long. */ size_t ret_value = 8; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_sdspace_size); /* add in the dimension sizes */ ret_value += space->rank * H5F_SIZEOF_SIZE (f); /* add in the space for the maximum dimensions, if they are present */ ret_value += space->max ? space->rank * H5F_SIZEOF_SIZE (f) : 0; FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_sdspace_reset * * Purpose: Frees the inside of a dataspace message and resets it to some * initial value. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Thursday, April 30, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_sdspace_reset(void *_mesg) { H5S_extent_t *mesg = (H5S_extent_t*)_mesg; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_sdspace_reset); H5S_extent_release(mesg); FUNC_LEAVE_NOAPI(SUCCEED); } /*------------------------------------------------------------------------- * Function: H5O_sdsdpace_free * * Purpose: Free's the message * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Thursday, March 30, 2000 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_sdspace_free (void *mesg) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_sdspace_free); assert (mesg); H5FL_FREE(H5S_extent_t,mesg); FUNC_LEAVE_NOAPI(SUCCEED); } /*-------------------------------------------------------------------------- NAME H5O_sdspace_debug PURPOSE Prints debugging information for a simple dimensionality message USAGE void *H5O_sdspace_debug(f, mesg, stream, indent, fwidth) H5F_t *f; IN: pointer to the HDF5 file struct const void *mesg; IN: Pointer to the source extent dimensionality struct FILE *stream; IN: Pointer to the stream for output data int indent; IN: Amount to indent information by int fwidth; IN: Field width (?) RETURNS Non-negative on success/Negative on failure DESCRIPTION This function prints debugging output to the stream passed as a parameter. --------------------------------------------------------------------------*/ static herr_t H5O_sdspace_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *mesg, FILE * stream, int indent, int fwidth) { const H5S_extent_t *sdim = (const H5S_extent_t *) mesg; unsigned u; /* local counting variable */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_sdspace_debug); /* check args */ assert(f); assert(sdim); assert(stream); assert(indent >= 0); assert(fwidth >= 0); HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, "Rank:", (unsigned long) (sdim->rank)); if(sdim->rank>0) { HDfprintf(stream, "%*s%-*s {", indent, "", fwidth, "Dim Size:"); for (u = 0; u < sdim->rank; u++) HDfprintf (stream, "%s%Hu", u?", ":"", sdim->size[u]); HDfprintf (stream, "}\n"); HDfprintf(stream, "%*s%-*s ", indent, "", fwidth, "Dim Max:"); if (sdim->max) { HDfprintf (stream, "{"); for (u = 0; u < sdim->rank; u++) { if (H5S_UNLIMITED==sdim->max[u]) { HDfprintf (stream, "%sINF", u?", ":""); } else { HDfprintf (stream, "%s%Hu", u?", ":"", sdim->max[u]); } } HDfprintf (stream, "}\n"); } else { HDfprintf (stream, "CONSTANT\n"); } } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED); } xdmf-3.0+git20160803/Utilities/hdf5/H5Dcompact.c0000640000175000017500000001170713003006557020774 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Raymond Lu * August 5, 2002 * * Purpose: Compact dataset I/O functions. These routines are similar * H5D_contig_* and H5D_istore_*. */ #define H5D_PACKAGE /*suppress error about including H5Dpkg */ #include "H5private.h" /* Generic Functions */ #include "H5Dpkg.h" /* Dataset functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fprivate.h" /* Files */ #include "H5FDprivate.h" /* File drivers */ #include "H5FLprivate.h" /* Free Lists */ #include "H5Oprivate.h" /* Object headers */ #include "H5Vprivate.h" /* Vector and array functions */ /*------------------------------------------------------------------------- * Function: H5D_compact_readvv * * Purpose: Reads some data vectors from a dataset into a buffer. * The data is in compact dataset. The address is relative * to the beginning address of the dataset. The offsets and * sequence lengths are in bytes. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * May 7, 2003 * * Notes: * Offsets in the sequences must be monotonically increasing * * Modifications: * *------------------------------------------------------------------------- */ ssize_t H5D_compact_readvv(const H5D_io_info_t *io_info, size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_size_arr[], hsize_t dset_offset_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_size_arr[], hsize_t mem_offset_arr[], void *buf) { ssize_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5D_compact_readvv, FAIL) assert(io_info->dset); /* Use the vectorized memory copy routine to do actual work */ if((ret_value=H5V_memcpyvv(buf,mem_max_nseq,mem_curr_seq,mem_size_arr,mem_offset_arr,io_info->dset->shared->layout.u.compact.buf,dset_max_nseq,dset_curr_seq,dset_size_arr,dset_offset_arr))<0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "vectorized memcpy failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_compact_readvv() */ /*------------------------------------------------------------------------- * Function: H5D_compact_writevv * * Purpose: Writes some data vectors from a dataset into a buffer. * The data is in compact dataset. The address is relative * to the beginning address for the file. The offsets and * sequence lengths are in bytes. This function only copies * data into the buffer in the LAYOUT struct and mark it * as DIRTY. Later in H5D_close, the data is copied into * header message in memory. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * May 2, 2003 * * Notes: * Offsets in the sequences must be monotonically increasing * * Modifications: * *------------------------------------------------------------------------- */ ssize_t H5D_compact_writevv(const H5D_io_info_t *io_info, size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_size_arr[], hsize_t dset_offset_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_size_arr[], hsize_t mem_offset_arr[], const void *buf) { ssize_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5D_compact_writevv, FAIL) assert(io_info->dset); /* Use the vectorized memory copy routine to do actual work */ if((ret_value=H5V_memcpyvv(io_info->dset->shared->layout.u.compact.buf,dset_max_nseq,dset_curr_seq,dset_size_arr,dset_offset_arr,buf,mem_max_nseq,mem_curr_seq,mem_size_arr,mem_offset_arr))<0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "vectorized memcpy failed") io_info->dset->shared->layout.u.compact.dirty = TRUE; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_compact_writevv() */ xdmf-3.0+git20160803/Utilities/hdf5/H5Dcontig.c0000640000175000017500000012164013003006557020627 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Quincey Koziol * Thursday, September 28, 2000 * * Purpose: * Contiguous dataset I/O functions. These routines are similar to * the H5D_istore_* routines and really only an abstract way of dealing * with the data sieve buffer from H5F_seq_read/write. */ #define H5D_PACKAGE /*suppress error about including H5Dpkg */ #include "H5private.h" /* Generic Functions */ #include "H5Dpkg.h" /* Dataset functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fprivate.h" /* Files */ #include "H5FDprivate.h" /* File drivers */ #include "H5FLprivate.h" /* Free Lists */ #include "H5MFprivate.h" /* File memory management */ #include "H5Oprivate.h" /* Object headers */ #include "H5Pprivate.h" /* Property lists */ #include "H5Sprivate.h" /* Dataspace functions */ #include "H5Vprivate.h" /* Vector and array functions */ /* Private prototypes */ static herr_t H5D_contig_write(H5D_t *dset, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, const H5D_storage_t *store, hsize_t offset, size_t size, const void *buf); /* Declare a PQ free list to manage the sieve buffer information */ H5FL_BLK_DEFINE(sieve_buf); /* Declare the free list to manage blocks of non-zero fill-value data */ H5FL_BLK_DEFINE_STATIC(non_zero_fill); /* Declare the free list to manage blocks of zero fill-value data */ H5FL_BLK_DEFINE_STATIC(zero_fill); /*------------------------------------------------------------------------- * Function: H5D_contig_create * * Purpose: Allocate file space for a contiguously stored dataset * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * April 19, 2003 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5D_contig_create(H5F_t *f, hid_t dxpl_id, H5O_layout_t *layout /*out */ ) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5D_contig_create, FAIL) /* check args */ assert(f); assert(layout); /* Allocate space for the contiguous data */ if (HADDR_UNDEF==(layout->u.contig.addr=H5MF_alloc(f, H5FD_MEM_DRAW, dxpl_id, layout->u.contig.size))) HGOTO_ERROR (H5E_IO, H5E_NOSPACE, FAIL, "unable to reserve file space") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_contig_create */ /*------------------------------------------------------------------------- * Function: H5D_contig_fill * * Purpose: Write fill values to a contiguously stored dataset. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * August 22, 2002 * * Modifications: * Bill Wendling, February 20, 2003 * Added support for getting the barrier COMM if you're using * Flexible PHDF5. * *------------------------------------------------------------------------- */ herr_t H5D_contig_fill(H5D_t *dset, hid_t dxpl_id) { H5D_storage_t store; /* Union of storage info for dataset */ H5D_dxpl_cache_t _dxpl_cache; /* Data transfer property cache buffer */ H5D_dxpl_cache_t *dxpl_cache=&_dxpl_cache; /* Data transfer property cache */ hssize_t snpoints; /* Number of points in space (for error checking) */ size_t npoints; /* Number of points in space */ size_t ptsperbuf; /* Maximum # of points which fit in the buffer */ size_t elmt_size; /* Size of each element */ size_t bufsize=64*1024; /* Size of buffer to write */ size_t size; /* Current # of points to write */ hsize_t offset; /* Offset of dataset */ void *buf = NULL; /* Buffer for fill value writing */ #ifdef H5_HAVE_PARALLEL MPI_Comm mpi_comm=MPI_COMM_NULL; /* MPI communicator for file */ int mpi_rank=(-1); /* This process's rank */ int mpi_code; /* MPI return code */ unsigned blocks_written=0; /* Flag to indicate that chunk was actually written */ unsigned using_mpi=0; /* Flag to indicate that the file is being accessed with an MPI-capable file driver */ #endif /* H5_HAVE_PARALLEL */ int non_zero_fill_f=(-1); /* Indicate that a non-zero fill-value was used */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5D_contig_fill, FAIL) /* Check args */ assert(TRUE==H5P_isa_class(dxpl_id,H5P_DATASET_XFER)); assert(dset && H5D_CONTIGUOUS==dset->shared->layout.type); assert(H5F_addr_defined(dset->shared->layout.u.contig.addr)); assert(dset->shared->layout.u.contig.size>0); assert(dset->shared->space); #ifdef H5_HAVE_PARALLEL /* Retrieve MPI parameters */ if(IS_H5FD_MPI(dset->ent.file)) { /* Get the MPI communicator */ if (MPI_COMM_NULL == (mpi_comm=H5F_mpi_get_comm(dset->ent.file))) HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "Can't retrieve MPI communicator") /* Get the MPI rank */ if ((mpi_rank=H5F_mpi_get_rank(dset->ent.file))<0) HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "Can't retrieve MPI rank") /* Set the MPI-capable file driver flag */ using_mpi=1; /* Fill the DXPL cache values for later use */ if (H5D_get_dxpl_cache(H5AC_ind_dxpl_id,&dxpl_cache)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't fill dxpl cache") } /* end if */ else { #endif /* H5_HAVE_PARALLEL */ /* Fill the DXPL cache values for later use */ if (H5D_get_dxpl_cache(dxpl_id,&dxpl_cache)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't fill dxpl cache") #ifdef H5_HAVE_PARALLEL } /* end else */ #endif /* H5_HAVE_PARALLEL */ /* Initialize storage info for this dataset */ store.contig.dset_addr=dset->shared->layout.u.contig.addr; store.contig.dset_size=dset->shared->layout.u.contig.size; /* Get size of elements */ elmt_size=H5T_get_size(dset->shared->type); assert(elmt_size>0); /* Get the number of elements in the dataset's dataspace */ snpoints = H5S_GET_EXTENT_NPOINTS(dset->shared->space); assert(snpoints>=0); H5_ASSIGN_OVERFLOW(npoints,snpoints,hssize_t,size_t); /* If fill value is not library default, use it to set the element size */ if(dset->shared->fill.buf) elmt_size=dset->shared->fill.size; /* * Fill the entire current extent with the fill value. We can do * this quite efficiently by making sure we copy the fill value * in relatively large pieces. */ ptsperbuf = MAX(1, bufsize/elmt_size); bufsize = ptsperbuf*elmt_size; /* Fill the buffer with the user's fill value */ if(dset->shared->fill.buf) { /* Allocate temporary buffer */ if ((buf=H5FL_BLK_MALLOC(non_zero_fill,bufsize))==NULL) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for fill buffer") H5V_array_fill(buf, dset->shared->fill.buf, elmt_size, ptsperbuf); /* Indicate that a non-zero fill buffer was used */ non_zero_fill_f=1; } /* end if */ else { /* Fill the buffer with the default fill value */ htri_t buf_avail; /* Check if there is an already zeroed out buffer available */ buf_avail=H5FL_BLK_AVAIL(zero_fill,bufsize); assert(buf_avail!=FAIL); /* Allocate temporary buffer (zeroing it if no buffer is available) */ if(!buf_avail) buf=H5FL_BLK_CALLOC(zero_fill,bufsize); else buf=H5FL_BLK_MALLOC(zero_fill,bufsize); if(buf==NULL) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for fill buffer") /* Indicate that a zero fill buffer was used */ non_zero_fill_f=0; } /* end else */ /* Start at the beginning of the dataset */ offset = 0; /* Loop through writing the fill value to the dataset */ while (npoints>0) { size = MIN(ptsperbuf, npoints) * elmt_size; #ifdef H5_HAVE_PARALLEL /* Check if this file is accessed with an MPI-capable file driver */ if(using_mpi) { /* Write the chunks out from only one process */ /* !! Use the internal "independent" DXPL!! -QAK */ if(H5_PAR_META_WRITE==mpi_rank) { if (H5D_contig_write(dset, dxpl_cache, H5AC_ind_dxpl_id, &store, offset, size, buf)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to write fill value to dataset") } /* end if */ /* Indicate that blocks are being written */ blocks_written=1; } /* end if */ else { #endif /* H5_HAVE_PARALLEL */ H5_CHECK_OVERFLOW(size,size_t,hsize_t); if (H5D_contig_write(dset, dxpl_cache, dxpl_id, &store, offset, size, buf)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to write fill value to dataset") #ifdef H5_HAVE_PARALLEL } /* end else */ #endif /* H5_HAVE_PARALLEL */ npoints -= MIN(ptsperbuf, npoints); offset += size; } /* end while */ #ifdef H5_HAVE_PARALLEL /* Only need to block at the barrier if we actually wrote fill values */ /* And if we are using an MPI-capable file driver */ if(using_mpi && blocks_written) { /* Wait at barrier to avoid race conditions where some processes are * still writing out fill values and other processes race ahead to data * in, getting bogus data. */ if (MPI_SUCCESS != (mpi_code=MPI_Barrier(mpi_comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed", mpi_code) } /* end if */ #endif /* H5_HAVE_PARALLEL */ done: /* Free the buffer for fill values */ if (buf) { assert(non_zero_fill_f>=0); if(non_zero_fill_f) H5FL_BLK_FREE(non_zero_fill,buf); else H5FL_BLK_FREE(zero_fill,buf); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_contig_fill() */ /*------------------------------------------------------------------------- * Function: H5D_contig_delete * * Purpose: Delete the file space for a contiguously stored dataset * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * March 20, 2003 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5D_contig_delete(H5F_t *f, hid_t dxpl_id, const struct H5O_layout_t *layout) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5D_contig_delete, FAIL) /* check args */ assert(f); assert(layout); /* Free the file space for the chunk */ if (H5MF_xfree(f, H5FD_MEM_DRAW, dxpl_id, layout->u.contig.addr, layout->u.contig.size)<0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free object header") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_contig_delete */ /*------------------------------------------------------------------------- * Function: H5D_contig_get_addr * * Purpose: Get the offset of the contiguous data on disk * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * June 2, 2004 * * Modifications: * *------------------------------------------------------------------------- */ haddr_t H5D_contig_get_addr(const H5D_t *dset) { FUNC_ENTER_NOAPI_NOFUNC(H5D_contig_get_addr) /* check args */ assert(dset); assert(dset->shared->layout.type==H5D_CONTIGUOUS); FUNC_LEAVE_NOAPI(dset->shared->layout.u.contig.addr) } /* end H5D_contig_get_addr */ /*------------------------------------------------------------------------- * Function: H5D_contig_write * * Purpose: Writes some data from a dataset into a buffer. * The data is contiguous. The address is relative to the base * address for the file. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Thursday, September 28, 2000 * * Modifications: * Re-written in terms of the new writevv call, QAK, 5/7/03 * *------------------------------------------------------------------------- */ static herr_t H5D_contig_write(H5D_t *dset, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, const H5D_storage_t *store, hsize_t offset, size_t size, const void *buf) { H5D_io_info_t io_info; /* Dataset I/O info */ hsize_t dset_off=offset; /* Offset in dataset */ size_t dset_len=size; /* Length in dataset */ size_t dset_curr_seq=0; /* "Current sequence" in dataset */ hsize_t mem_off=0; /* Offset in memory */ size_t mem_len=size; /* Length in memory */ size_t mem_curr_seq=0; /* "Current sequence" in memory */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5D_contig_write, FAIL) assert (dset); assert (dxpl_cache); assert (store); assert (buf); H5D_BUILD_IO_INFO(&io_info,dset,dxpl_cache,dxpl_id,store); if (H5D_contig_writevv(&io_info, 1, &dset_curr_seq, &dset_len, &dset_off, 1, &mem_curr_seq, &mem_len, &mem_off, buf)<0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "vector write failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_contig_write() */ /*------------------------------------------------------------------------- * Function: H5D_contig_readvv * * Purpose: Reads some data vectors from a dataset into a buffer. * The data is contiguous. The address is the start of the dataset, * relative to the base address for the file and the offsets and * sequence lengths are in bytes. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Friday, May 3, 2001 * * Notes: * Offsets in the sequences must be monotonically increasing * * Modifications: * *------------------------------------------------------------------------- */ ssize_t H5D_contig_readvv(const H5D_io_info_t *io_info, size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_len_arr[], hsize_t dset_offset_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[], void *_buf) { H5F_t *file=io_info->dset->ent.file; /* File for dataset */ H5D_rdcdc_t *dset_contig=&(io_info->dset->shared->cache.contig); /* Cached information about contiguous data */ const H5D_contig_storage_t *store_contig=&(io_info->store->contig); /* Contiguous storage info for this I/O operation */ unsigned char *buf=(unsigned char *)_buf; /* Pointer to buffer to fill */ haddr_t addr; /* Actual address to read */ size_t total_size=0; /* Total size of sequence in bytes */ size_t size; /* Size of sequence in bytes */ size_t u; /* Counting variable */ size_t v; /* Counting variable */ ssize_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5D_contig_readvv, FAIL) /* Check args */ assert(io_info); assert(io_info->dset); assert(io_info->store); assert(buf); /* Check if data sieving is enabled */ if(H5F_HAS_FEATURE(file,H5FD_FEAT_DATA_SIEVE)) { haddr_t sieve_start=HADDR_UNDEF, sieve_end=HADDR_UNDEF; /* Start & end locations of sieve buffer */ haddr_t contig_end; /* End locations of block to write */ size_t sieve_size=(size_t)-1; /* size of sieve buffer */ haddr_t abs_eoa; /* Absolute end of file address */ haddr_t rel_eoa; /* Relative end of file address */ hsize_t max_data; /* Actual maximum size of data to cache */ /* Set offsets in sequence lists */ u=*dset_curr_seq; v=*mem_curr_seq; /* Stash local copies of these value */ if(dset_contig->sieve_buf!=NULL) { sieve_start=dset_contig->sieve_loc; sieve_size=dset_contig->sieve_size; sieve_end=sieve_start+sieve_size; } /* end if */ /* Works through sequences as fast as possible */ for(; udset_addr+dset_offset_arr[u]; /* Compute offset in memory */ buf = (unsigned char *)_buf + mem_offset_arr[v]; /* Check if the sieve buffer is allocated yet */ if(dset_contig->sieve_buf==NULL) { /* Check if we can actually hold the I/O request in the sieve buffer */ if(size>dset_contig->sieve_buf_size) { if (H5F_block_read(file, H5FD_MEM_DRAW, addr, size, io_info->dxpl_id, buf)<0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "block read failed") } /* end if */ else { /* Allocate room for the data sieve buffer */ if (NULL==(dset_contig->sieve_buf=H5FL_BLK_MALLOC(sieve_buf,dset_contig->sieve_buf_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Determine the new sieve buffer size & location */ dset_contig->sieve_loc=addr; /* Make certain we don't read off the end of the file */ if (HADDR_UNDEF==(abs_eoa=H5F_get_eoa(file))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to determine file size") /* Adjust absolute EOA address to relative EOA address */ rel_eoa=abs_eoa-H5F_get_base_addr(file); /* Set up the buffer parameters */ max_data=store_contig->dset_size-dset_offset_arr[u]; /* Compute the size of the sieve buffer */ H5_ASSIGN_OVERFLOW(dset_contig->sieve_size,MIN3(rel_eoa-dset_contig->sieve_loc,max_data,dset_contig->sieve_buf_size),hsize_t,size_t); /* Read the new sieve buffer */ if (H5F_block_read(file, H5FD_MEM_DRAW, dset_contig->sieve_loc, dset_contig->sieve_size, io_info->dxpl_id, dset_contig->sieve_buf)<0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "block read failed") /* Grab the data out of the buffer (must be first piece of data in buffer ) */ HDmemcpy(buf,dset_contig->sieve_buf,size); /* Reset sieve buffer dirty flag */ dset_contig->sieve_dirty=0; /* Stash local copies of these value */ sieve_start=dset_contig->sieve_loc; sieve_size=dset_contig->sieve_size; sieve_end=sieve_start+sieve_size; } /* end else */ } /* end if */ else { /* Compute end of sequence to retrieve */ contig_end=addr+size-1; /* If entire read is within the sieve buffer, read it from the buffer */ if(addr>=sieve_start && contig_endsieve_buf+(addr-sieve_start); /* Grab the data out of the buffer */ HDmemcpy(buf,base_sieve_buf,size); } /* end if */ /* Entire request is not within this data sieve buffer */ else { /* Check if we can actually hold the I/O request in the sieve buffer */ if(size>dset_contig->sieve_buf_size) { /* Check for any overlap with the current sieve buffer */ if((sieve_start>=addr && sieve_start<(contig_end+1)) || ((sieve_end-1)>=addr && (sieve_end-1)<(contig_end+1))) { /* Flush the sieve buffer, if it's dirty */ if(dset_contig->sieve_dirty) { /* Write to file */ if (H5F_block_write(file, H5FD_MEM_DRAW, sieve_start, sieve_size, io_info->dxpl_id, dset_contig->sieve_buf)<0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "block write failed") /* Reset sieve buffer dirty flag */ dset_contig->sieve_dirty=0; } /* end if */ } /* end if */ /* Read directly into the user's buffer */ if (H5F_block_read(file, H5FD_MEM_DRAW, addr, size, io_info->dxpl_id, buf)<0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "block read failed") } /* end if */ /* Element size fits within the buffer size */ else { /* Flush the sieve buffer if it's dirty */ if(dset_contig->sieve_dirty) { /* Write to file */ if (H5F_block_write(file, H5FD_MEM_DRAW, sieve_start, sieve_size, io_info->dxpl_id, dset_contig->sieve_buf)<0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "block write failed") /* Reset sieve buffer dirty flag */ dset_contig->sieve_dirty=0; } /* end if */ /* Determine the new sieve buffer size & location */ dset_contig->sieve_loc=addr; /* Make certain we don't read off the end of the file */ if (HADDR_UNDEF==(abs_eoa=H5F_get_eoa(file))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to determine file size") /* Adjust absolute EOA address to relative EOA address */ rel_eoa=abs_eoa-H5F_get_base_addr(file); /* Only need this when resizing sieve buffer */ max_data=store_contig->dset_size-dset_offset_arr[u]; /* Compute the size of the sieve buffer */ /* Don't read off the end of the file, don't read past the end of the data element and don't read more than the buffer size */ H5_ASSIGN_OVERFLOW(dset_contig->sieve_size,MIN3(rel_eoa-dset_contig->sieve_loc,max_data,dset_contig->sieve_buf_size),hsize_t,size_t); /* Update local copies of sieve information */ sieve_start=dset_contig->sieve_loc; sieve_size=dset_contig->sieve_size; sieve_end=sieve_start+sieve_size; /* Read the new sieve buffer */ if (H5F_block_read(file, H5FD_MEM_DRAW, dset_contig->sieve_loc, dset_contig->sieve_size, io_info->dxpl_id, dset_contig->sieve_buf)<0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "block read failed") /* Grab the data out of the buffer (must be first piece of data in buffer ) */ HDmemcpy(buf,dset_contig->sieve_buf,size); /* Reset sieve buffer dirty flag */ dset_contig->sieve_dirty=0; } /* end else */ } /* end else */ } /* end else */ /* Update memory information */ mem_len_arr[v]-=size; mem_offset_arr[v]+=size; if(mem_len_arr[v]==0) v++; /* Update file information */ dset_len_arr[u]-=size; dset_offset_arr[u]+=size; if(dset_len_arr[u]==0) u++; /* Increment number of bytes copied */ total_size+=size; } /* end for */ } /* end if */ else { /* Work through all the sequences */ for(u=*dset_curr_seq, v=*mem_curr_seq; udset_addr+dset_offset_arr[u]; /* Compute offset in memory */ buf = (unsigned char *)_buf + mem_offset_arr[v]; /* Write data */ if (H5F_block_read(file, H5FD_MEM_DRAW, addr, size, io_info->dxpl_id, buf)<0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "block write failed") /* Update memory information */ mem_len_arr[v]-=size; mem_offset_arr[v]+=size; if(mem_len_arr[v]==0) v++; /* Update file information */ dset_len_arr[u]-=size; dset_offset_arr[u]+=size; if(dset_len_arr[u]==0) u++; /* Increment number of bytes copied */ total_size+=size; } /* end for */ } /* end else */ /* Update current sequence vectors */ *dset_curr_seq=u; *mem_curr_seq=v; /* Set return value */ H5_ASSIGN_OVERFLOW(ret_value,total_size,size_t,ssize_t); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_contig_readvv() */ /*------------------------------------------------------------------------- * Function: H5D_contig_writevv * * Purpose: Writes some data vectors into a dataset from vectors into a * buffer. The address is the start of the dataset, * relative to the base address for the file and the offsets and * sequence lengths are in bytes. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Friday, May 2, 2003 * * Notes: * Offsets in the sequences must be monotonically increasing * * Modifications: * *------------------------------------------------------------------------- */ ssize_t H5D_contig_writevv(const H5D_io_info_t *io_info, size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_len_arr[], hsize_t dset_offset_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[], const void *_buf) { H5F_t *file=io_info->dset->ent.file; /* File for dataset */ H5D_rdcdc_t *dset_contig=&(io_info->dset->shared->cache.contig); /* Cached information about contiguous data */ const H5D_contig_storage_t *store_contig=&(io_info->store->contig); /* Contiguous storage info for this I/O operation */ const unsigned char *buf=_buf; /* Pointer to buffer to fill */ haddr_t addr; /* Actual address to read */ size_t total_size=0; /* Size of sequence in bytes */ size_t size; /* Size of sequence in bytes */ size_t u; /* Counting variable */ size_t v; /* Counting variable */ ssize_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5D_contig_writevv, FAIL) /* Check args */ assert(io_info); assert(io_info->dset); assert(io_info->store); assert(buf); /* Check if data sieving is enabled */ if(H5F_HAS_FEATURE(file,H5FD_FEAT_DATA_SIEVE)) { haddr_t sieve_start=HADDR_UNDEF, sieve_end=HADDR_UNDEF; /* Start & end locations of sieve buffer */ haddr_t contig_end; /* End locations of block to write */ size_t sieve_size=(size_t)-1; /* size of sieve buffer */ haddr_t abs_eoa; /* Absolute end of file address */ haddr_t rel_eoa; /* Relative end of file address */ hsize_t max_data; /* Actual maximum size of data to cache */ /* Set offsets in sequence lists */ u=*dset_curr_seq; v=*mem_curr_seq; /* Stash local copies of these values */ if(dset_contig->sieve_buf!=NULL) { sieve_start=dset_contig->sieve_loc; sieve_size=dset_contig->sieve_size; sieve_end=sieve_start+sieve_size; } /* end if */ /* Works through sequences as fast as possible */ for(; udset_addr+dset_offset_arr[u]; /* Compute offset in memory */ buf = (const unsigned char *)_buf + mem_offset_arr[v]; /* No data sieve buffer yet, go allocate one */ if(dset_contig->sieve_buf==NULL) { /* Check if we can actually hold the I/O request in the sieve buffer */ if(size>dset_contig->sieve_buf_size) { if (H5F_block_write(file, H5FD_MEM_DRAW, addr, size, io_info->dxpl_id, buf)<0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "block write failed") } /* end if */ else { /* Allocate room for the data sieve buffer */ if (NULL==(dset_contig->sieve_buf=H5FL_BLK_MALLOC(sieve_buf,dset_contig->sieve_buf_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Determine the new sieve buffer size & location */ dset_contig->sieve_loc=addr; /* Make certain we don't read off the end of the file */ if (HADDR_UNDEF==(abs_eoa=H5F_get_eoa(file))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to determine file size") /* Adjust absolute EOA address to relative EOA address */ rel_eoa=abs_eoa-H5F_get_base_addr(file); /* Set up the buffer parameters */ max_data=store_contig->dset_size-dset_offset_arr[u]; /* Compute the size of the sieve buffer */ H5_ASSIGN_OVERFLOW(dset_contig->sieve_size,MIN3(rel_eoa-dset_contig->sieve_loc,max_data,dset_contig->sieve_buf_size),hsize_t,size_t); /* Check if there is any point in reading the data from the file */ if(dset_contig->sieve_size>size) { /* Read the new sieve buffer */ if (H5F_block_read(file, H5FD_MEM_DRAW, dset_contig->sieve_loc, dset_contig->sieve_size, io_info->dxpl_id, dset_contig->sieve_buf)<0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "block read failed") } /* end if */ /* Grab the data out of the buffer (must be first piece of data in buffer ) */ HDmemcpy(dset_contig->sieve_buf,buf,size); /* Set sieve buffer dirty flag */ dset_contig->sieve_dirty=1; /* Stash local copies of these values */ sieve_start=dset_contig->sieve_loc; sieve_size=dset_contig->sieve_size; sieve_end=sieve_start+sieve_size; } /* end else */ } /* end if */ else { /* Compute end of sequence to retrieve */ contig_end=addr+size-1; /* If entire write is within the sieve buffer, write it to the buffer */ if(addr>=sieve_start && contig_endsieve_buf+(addr-sieve_start); /* Put the data into the sieve buffer */ HDmemcpy(base_sieve_buf,buf,size); /* Set sieve buffer dirty flag */ dset_contig->sieve_dirty=1; } /* end if */ /* Entire request is not within this data sieve buffer */ else { /* Check if we can actually hold the I/O request in the sieve buffer */ if(size>dset_contig->sieve_buf_size) { /* Check for any overlap with the current sieve buffer */ if((sieve_start>=addr && sieve_start<(contig_end+1)) || ((sieve_end-1)>=addr && (sieve_end-1)<(contig_end+1))) { /* Flush the sieve buffer, if it's dirty */ if(dset_contig->sieve_dirty) { /* Write to file */ if (H5F_block_write(file, H5FD_MEM_DRAW, sieve_start, sieve_size, io_info->dxpl_id, dset_contig->sieve_buf)<0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "block write failed") /* Reset sieve buffer dirty flag */ dset_contig->sieve_dirty=0; } /* end if */ /* Force the sieve buffer to be re-read the next time */ dset_contig->sieve_loc=HADDR_UNDEF; dset_contig->sieve_size=0; } /* end if */ /* Write directly from the user's buffer */ if (H5F_block_write(file, H5FD_MEM_DRAW, addr, size, io_info->dxpl_id, buf)<0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "block write failed") } /* end if */ /* Element size fits within the buffer size */ else { /* Check if it is possible to (exactly) prepend or append to existing (dirty) sieve buffer */ if(((addr+size)==sieve_start || addr==sieve_end) && (size+sieve_size)<=dset_contig->sieve_buf_size && dset_contig->sieve_dirty) { /* Prepend to existing sieve buffer */ if((addr+size)==sieve_start) { /* Move existing sieve information to correct location */ HDmemmove(dset_contig->sieve_buf+size,dset_contig->sieve_buf,dset_contig->sieve_size); /* Copy in new information (must be first in sieve buffer) */ HDmemcpy(dset_contig->sieve_buf,buf,size); /* Adjust sieve location */ dset_contig->sieve_loc=addr; } /* end if */ /* Append to existing sieve buffer */ else { /* Copy in new information */ HDmemcpy(dset_contig->sieve_buf+sieve_size,buf,size); } /* end else */ /* Adjust sieve size */ dset_contig->sieve_size += size; /* Update local copies of sieve information */ sieve_start=dset_contig->sieve_loc; sieve_size=dset_contig->sieve_size; sieve_end=sieve_start+sieve_size; } /* end if */ /* Can't add the new data onto the existing sieve buffer */ else { /* Flush the sieve buffer if it's dirty */ if(dset_contig->sieve_dirty) { /* Write to file */ if (H5F_block_write(file, H5FD_MEM_DRAW, sieve_start, sieve_size, io_info->dxpl_id, dset_contig->sieve_buf)<0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "block write failed") /* Reset sieve buffer dirty flag */ dset_contig->sieve_dirty=0; } /* end if */ /* Determine the new sieve buffer size & location */ dset_contig->sieve_loc=addr; /* Make certain we don't read off the end of the file */ if (HADDR_UNDEF==(abs_eoa=H5F_get_eoa(file))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to determine file size") /* Adjust absolute EOA address to relative EOA address */ rel_eoa=abs_eoa-H5F_get_base_addr(file); /* Only need this when resizing sieve buffer */ max_data=store_contig->dset_size-dset_offset_arr[u]; /* Compute the size of the sieve buffer */ /* Don't read off the end of the file, don't read past the end of the data element and don't read more than the buffer size */ H5_ASSIGN_OVERFLOW(dset_contig->sieve_size,MIN3(rel_eoa-dset_contig->sieve_loc,max_data,dset_contig->sieve_buf_size),hsize_t,size_t); /* Update local copies of sieve information */ sieve_start=dset_contig->sieve_loc; sieve_size=dset_contig->sieve_size; sieve_end=sieve_start+sieve_size; /* Check if there is any point in reading the data from the file */ if(dset_contig->sieve_size>size) { /* Read the new sieve buffer */ if (H5F_block_read(file, H5FD_MEM_DRAW, dset_contig->sieve_loc, dset_contig->sieve_size, io_info->dxpl_id, dset_contig->sieve_buf)<0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "block read failed") } /* end if */ /* Grab the data out of the buffer (must be first piece of data in buffer ) */ HDmemcpy(dset_contig->sieve_buf,buf,size); /* Set sieve buffer dirty flag */ dset_contig->sieve_dirty=1; } /* end else */ } /* end else */ } /* end else */ } /* end else */ /* Update memory information */ mem_len_arr[v]-=size; mem_offset_arr[v]+=size; if(mem_len_arr[v]==0) v++; /* Update file information */ dset_len_arr[u]-=size; dset_offset_arr[u]+=size; if(dset_len_arr[u]==0) u++; /* Increment number of bytes copied */ total_size+=size; } /* end for */ } /* end if */ else { /* Work through all the sequences */ for(u=*dset_curr_seq, v=*mem_curr_seq; udset_addr+dset_offset_arr[u]; /* Compute offset in memory */ buf = (const unsigned char *)_buf + mem_offset_arr[v]; /* Write data */ if (H5F_block_write(file, H5FD_MEM_DRAW, addr, size, io_info->dxpl_id, buf)<0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "block write failed") /* Update memory information */ mem_len_arr[v]-=size; mem_offset_arr[v]+=size; if(mem_len_arr[v]==0) v++; /* Update file information */ dset_len_arr[u]-=size; dset_offset_arr[u]+=size; if(dset_len_arr[u]==0) u++; /* Increment number of bytes copied */ total_size+=size; } /* end for */ } /* end else */ /* Update current sequence vectors */ *dset_curr_seq=u; *mem_curr_seq=v; /* Set return value */ H5_ASSIGN_OVERFLOW(ret_value,total_size,size_t,ssize_t); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_contig_writevv() */ xdmf-3.0+git20160803/Utilities/hdf5/H5Odtype.c0000640000175000017500000015174213003006557020512 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #define H5O_PACKAGE /*suppress error about including H5Opkg */ #define H5T_PACKAGE /*prevent warning from including H5Tpkg */ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free Lists */ #include "H5Gprivate.h" /* Groups */ #include "H5MMprivate.h" /* Memory management */ #include "H5Opkg.h" /* Object headers */ #include "H5Tpkg.h" /* Datatypes */ /* PRIVATE PROTOTYPES */ static herr_t H5O_dtype_encode (H5F_t *f, uint8_t *p, const void *mesg); static void *H5O_dtype_decode (H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t *sh); static void *H5O_dtype_copy (const void *_mesg, void *_dest, unsigned update_flags); static size_t H5O_dtype_size (const H5F_t *f, const void *_mesg); static herr_t H5O_dtype_reset (void *_mesg); static herr_t H5O_dtype_free (void *_mesg); static herr_t H5O_dtype_get_share (H5F_t *f, const void *_mesg, H5O_shared_t *sh); static herr_t H5O_dtype_set_share (H5F_t *f, void *_mesg, const H5O_shared_t *sh); static herr_t H5O_dtype_debug (H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * stream, int indent, int fwidth); /* This message derives from H5O */ const H5O_class_t H5O_DTYPE[1] = {{ H5O_DTYPE_ID, /* message id number */ "data_type", /* message name for debugging */ sizeof(H5T_t), /* native message size */ H5O_dtype_decode, /* decode message */ H5O_dtype_encode, /* encode message */ H5O_dtype_copy, /* copy the native value */ H5O_dtype_size, /* size of raw message */ H5O_dtype_reset, /* reset method */ H5O_dtype_free, /* free method */ NULL, /* file delete method */ NULL, /* link method */ H5O_dtype_get_share, /* get share method */ H5O_dtype_set_share, /* set share method */ H5O_dtype_debug, /* debug the message */ }}; /* This is the correct version to create all datatypes which don't contain * array datatypes (atomic types, compound datatypes without array fields, * vlen sequences of objects which aren't arrays, etc.) */ #define H5O_DTYPE_VERSION_COMPAT 1 /* This is the correct version to create all datatypes which contain H5T_ARRAY * class objects (array definitely, potentially compound & vlen sequences also) */ #define H5O_DTYPE_VERSION_UPDATED 2 /* Declare external the free list for H5T_t's */ H5FL_EXTERN(H5T_t); H5FL_EXTERN(H5T_shared_t); /*------------------------------------------------------------------------- * Function: H5O_dtype_decode_helper * * Purpose: Decodes a datatype * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Monday, December 8, 1997 * * Modifications: * Robb Matzke, Thursday, May 20, 1999 * Added support for bitfields and opaque datatypes. *------------------------------------------------------------------------- */ static herr_t H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt) { unsigned flags, version; unsigned i, j; size_t z; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_dtype_decode_helper); /* check args */ assert(pp && *pp); assert(dt && dt->shared); /* decode */ UINT32DECODE(*pp, flags); version = (flags>>4) & 0x0f; if (version!=H5O_DTYPE_VERSION_COMPAT && version!=H5O_DTYPE_VERSION_UPDATED) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTLOAD, FAIL, "bad version number for datatype message"); dt->shared->type = (H5T_class_t)(flags & 0x0f); flags >>= 8; UINT32DECODE(*pp, dt->shared->size); switch (dt->shared->type) { case H5T_INTEGER: /* * Integer types... */ dt->shared->u.atomic.order = (flags & 0x1) ? H5T_ORDER_BE : H5T_ORDER_LE; dt->shared->u.atomic.lsb_pad = (flags & 0x2) ? H5T_PAD_ONE : H5T_PAD_ZERO; dt->shared->u.atomic.msb_pad = (flags & 0x4) ? H5T_PAD_ONE : H5T_PAD_ZERO; dt->shared->u.atomic.u.i.sign = (flags & 0x8) ? H5T_SGN_2 : H5T_SGN_NONE; UINT16DECODE(*pp, dt->shared->u.atomic.offset); UINT16DECODE(*pp, dt->shared->u.atomic.prec); break; case H5T_BITFIELD: /* * Bit fields... */ dt->shared->u.atomic.order = (flags & 0x1) ? H5T_ORDER_BE : H5T_ORDER_LE; dt->shared->u.atomic.lsb_pad = (flags & 0x2) ? H5T_PAD_ONE : H5T_PAD_ZERO; dt->shared->u.atomic.msb_pad = (flags & 0x4) ? H5T_PAD_ONE : H5T_PAD_ZERO; UINT16DECODE(*pp, dt->shared->u.atomic.offset); UINT16DECODE(*pp, dt->shared->u.atomic.prec); break; case H5T_OPAQUE: /* * Opaque types... */ z = flags & (H5T_OPAQUE_TAG_MAX - 1); assert(0==(z&0x7)); /*must be aligned*/ if (NULL==(dt->shared->u.opaque.tag=H5MM_malloc(z+1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); HDmemcpy(dt->shared->u.opaque.tag, *pp, z); dt->shared->u.opaque.tag[z] = '\0'; *pp += z; break; case H5T_FLOAT: /* * Floating-point types... */ dt->shared->u.atomic.order = (flags & 0x1) ? H5T_ORDER_BE : H5T_ORDER_LE; dt->shared->u.atomic.lsb_pad = (flags & 0x2) ? H5T_PAD_ONE : H5T_PAD_ZERO; dt->shared->u.atomic.msb_pad = (flags & 0x4) ? H5T_PAD_ONE : H5T_PAD_ZERO; dt->shared->u.atomic.u.f.pad = (flags & 0x8) ? H5T_PAD_ONE : H5T_PAD_ZERO; switch ((flags >> 4) & 0x03) { case 0: dt->shared->u.atomic.u.f.norm = H5T_NORM_NONE; break; case 1: dt->shared->u.atomic.u.f.norm = H5T_NORM_MSBSET; break; case 2: dt->shared->u.atomic.u.f.norm = H5T_NORM_IMPLIED; break; default: HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown floating-point normalization"); } dt->shared->u.atomic.u.f.sign = (flags >> 8) & 0xff; UINT16DECODE(*pp, dt->shared->u.atomic.offset); UINT16DECODE(*pp, dt->shared->u.atomic.prec); dt->shared->u.atomic.u.f.epos = *(*pp)++; dt->shared->u.atomic.u.f.esize = *(*pp)++; assert(dt->shared->u.atomic.u.f.esize > 0); dt->shared->u.atomic.u.f.mpos = *(*pp)++; dt->shared->u.atomic.u.f.msize = *(*pp)++; assert(dt->shared->u.atomic.u.f.msize > 0); UINT32DECODE(*pp, dt->shared->u.atomic.u.f.ebias); break; case H5T_COMPOUND: /* * Compound datatypes... */ dt->shared->u.compnd.nmembs = flags & 0xffff; assert(dt->shared->u.compnd.nmembs > 0); dt->shared->u.compnd.packed = TRUE; /* Start off packed */ dt->shared->u.compnd.nalloc = dt->shared->u.compnd.nmembs; dt->shared->u.compnd.memb = H5MM_calloc(dt->shared->u.compnd.nalloc* sizeof(H5T_cmemb_t)); if (NULL==dt->shared->u.compnd.memb) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); for (i = 0; i < dt->shared->u.compnd.nmembs; i++) { unsigned ndims=0; /* Number of dimensions of the array field */ hsize_t dim[H5O_LAYOUT_NDIMS]; /* Dimensions of the array */ int perm[H5O_LAYOUT_NDIMS]; /* Dimension permutations */ unsigned perm_word=0; /* Dimension permutation information */ H5T_t *array_dt; /* Temporary pointer to the array datatype */ H5T_t *temp_type; /* Temporary pointer to the field's datatype */ /* Decode the field name */ dt->shared->u.compnd.memb[i].name = H5MM_xstrdup((const char *)*pp); /*multiple of 8 w/ null terminator */ *pp += ((HDstrlen((const char *)*pp) + 8) / 8) * 8; /* Decode the field offset */ UINT32DECODE(*pp, dt->shared->u.compnd.memb[i].offset); /* Older versions of the library allowed a field to have * intrinsic 'arrayness'. Newer versions of the library * use the separate array datatypes. */ if(version==H5O_DTYPE_VERSION_COMPAT) { /* Decode the number of dimensions */ ndims = *(*pp)++; assert(ndims <= 4); *pp += 3; /*reserved bytes */ /* Decode dimension permutation (unused currently) */ UINT32DECODE(*pp, perm_word); /* Skip reserved bytes */ *pp += 4; /* Decode array dimension sizes */ for (j=0; j<4; j++) UINT32DECODE(*pp, dim[j]); } /* end if */ /* Allocate space for the field's datatype */ if(NULL == (temp_type = H5T_alloc())) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Decode the field's datatype information */ if (H5O_dtype_decode_helper(f, pp, temp_type)<0) { for (j=0; j<=i; j++) H5MM_xfree(dt->shared->u.compnd.memb[j].name); H5MM_xfree(dt->shared->u.compnd.memb); HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode member type"); } /* Go create the array datatype now, for older versions of the datatype message */ if(version==H5O_DTYPE_VERSION_COMPAT) { /* Check if this member is an array field */ if(ndims>0) { /* Set up the permutation vector for the array create */ for (j=0; j>(j*8))&0xff; /* Create the array datatype for the field */ if ((array_dt=H5T_array_create(temp_type,(int)ndims,dim,perm))==NULL) { for (j=0; j<=i; j++) H5MM_xfree(dt->shared->u.compnd.memb[j].name); H5MM_xfree(dt->shared->u.compnd.memb); HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to create array datatype"); } /* Close the base type for the array */ H5T_close(temp_type); /* Make the array type the type that is set for the field */ temp_type=array_dt; } /* end if */ } /* end if */ /* * Set the "force conversion" flag if VL datatype fields exist in this * type or any component types */ if(temp_type->shared->force_conv==TRUE) dt->shared->force_conv=TRUE; /* Member size */ dt->shared->u.compnd.memb[i].size = temp_type->shared->size; /* Set the field datatype (finally :-) */ dt->shared->u.compnd.memb[i].type=temp_type; /* Check if the datatype stayed packed */ if(dt->shared->u.compnd.packed) { /* Check if the member type is packed */ if(H5T_is_packed(temp_type)>0) { if(i==0) { /* If the is the first member, the datatype is not packed * if the first member isn't at offset 0 */ if(dt->shared->u.compnd.memb[i].offset>0) dt->shared->u.compnd.packed=FALSE; } /* end if */ else { /* If the is not the first member, the datatype is not * packed if the new member isn't adjoining the previous member */ if(dt->shared->u.compnd.memb[i].offset!=(dt->shared->u.compnd.memb[i-1].offset+dt->shared->u.compnd.memb[i-1].size)) dt->shared->u.compnd.packed=FALSE; } /* end else */ } /* end if */ else dt->shared->u.compnd.packed=FALSE; } /* end if */ } break; case H5T_ENUM: /* * Enumeration datatypes... */ dt->shared->u.enumer.nmembs = dt->shared->u.enumer.nalloc = flags & 0xffff; if(NULL == (dt->shared->parent = H5T_alloc())) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") if (H5O_dtype_decode_helper(f, pp, dt->shared->parent)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode parent datatype"); if (NULL==(dt->shared->u.enumer.name=H5MM_calloc(dt->shared->u.enumer.nalloc * sizeof(char*))) || NULL==(dt->shared->u.enumer.value=H5MM_calloc(dt->shared->u.enumer.nalloc * dt->shared->parent->shared->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); /* Names, each a multiple of 8 with null termination */ for (i=0; ishared->u.enumer.nmembs; i++) { dt->shared->u.enumer.name[i] = H5MM_xstrdup((const char*)*pp); *pp += ((HDstrlen((const char*)*pp)+8)/8)*8; } /* Values */ HDmemcpy(dt->shared->u.enumer.value, *pp, dt->shared->u.enumer.nmembs * dt->shared->parent->shared->size); *pp += dt->shared->u.enumer.nmembs * dt->shared->parent->shared->size; break; case H5T_REFERENCE: /* Reference datatypes... */ dt->shared->u.atomic.order = H5T_ORDER_NONE; dt->shared->u.atomic.prec = 8 * dt->shared->size; dt->shared->u.atomic.offset = 0; dt->shared->u.atomic.lsb_pad = H5T_PAD_ZERO; dt->shared->u.atomic.msb_pad = H5T_PAD_ZERO; /* Set reference type */ dt->shared->u.atomic.u.r.rtype = (H5R_type_t)(flags & 0x0f); break; case H5T_STRING: /* * Character string types... */ dt->shared->u.atomic.order = H5T_ORDER_NONE; dt->shared->u.atomic.prec = 8 * dt->shared->size; dt->shared->u.atomic.offset = 0; dt->shared->u.atomic.lsb_pad = H5T_PAD_ZERO; dt->shared->u.atomic.msb_pad = H5T_PAD_ZERO; dt->shared->u.atomic.u.s.pad = (H5T_str_t)(flags & 0x0f); dt->shared->u.atomic.u.s.cset = (H5T_cset_t)((flags>>4) & 0x0f); break; case H5T_VLEN: /* Variable length datatypes... */ /* Set the type of VL information, either sequence or string */ dt->shared->u.vlen.type = (H5T_vlen_type_t)(flags & 0x0f); if(dt->shared->u.vlen.type == H5T_VLEN_STRING) { dt->shared->u.vlen.pad = (H5T_str_t)((flags>>4) & 0x0f); dt->shared->u.vlen.cset = (H5T_cset_t)((flags>>8) & 0x0f); } /* end if */ /* Decode base type of VL information */ if(NULL == (dt->shared->parent = H5T_alloc())) HGOTO_ERROR (H5E_DATATYPE, H5E_NOSPACE, FAIL, "memory allocation failed") if (H5O_dtype_decode_helper(f, pp, dt->shared->parent)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode VL parent type"); dt->shared->force_conv=TRUE; /* Mark this type as on disk */ if (H5T_vlen_mark(dt, f, H5T_VLEN_DISK)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid VL location"); break; case H5T_TIME: /* Time datatypes */ dt->shared->u.atomic.order = (flags & 0x1) ? H5T_ORDER_BE : H5T_ORDER_LE; UINT16DECODE(*pp, dt->shared->u.atomic.prec); break; case H5T_ARRAY: /* Array datatypes... */ /* Decode the number of dimensions */ dt->shared->u.array.ndims = *(*pp)++; /* Double-check the number of dimensions */ assert(dt->shared->u.array.ndims <= H5S_MAX_RANK); /* Skip reserved bytes */ *pp += 3; /* Decode array dimension sizes & compute number of elements */ for (j=0, dt->shared->u.array.nelem=1; j<(unsigned)dt->shared->u.array.ndims; j++) { UINT32DECODE(*pp, dt->shared->u.array.dim[j]); dt->shared->u.array.nelem *= dt->shared->u.array.dim[j]; } /* end for */ /* Decode array dimension permutations (even though they are unused currently) */ for (j=0; j<(unsigned)dt->shared->u.array.ndims; j++) UINT32DECODE(*pp, dt->shared->u.array.perm[j]); /* Decode base type of array */ if(NULL == (dt->shared->parent = H5T_alloc())) HGOTO_ERROR (H5E_DATATYPE, H5E_NOSPACE, FAIL, "memory allocation failed") if (H5O_dtype_decode_helper(f, pp, dt->shared->parent)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode VL parent type"); /* * Set the "force conversion" flag if a VL base datatype is used or * or if any components of the base datatype are VL types. */ if(dt->shared->parent->shared->force_conv==TRUE) dt->shared->force_conv=TRUE; break; default: HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown datatype class found"); } done: if(ret_value <0) { if(dt != NULL) { if(dt->shared != NULL) H5FL_FREE(H5T_shared_t, dt->shared); H5FL_FREE(H5T_t, dt); } /* end if */ } FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_dtype_encode_helper * * Purpose: Encodes a datatype. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Monday, December 8, 1997 * * Modifications: * Robb Matzke, Thursday, May 20, 1999 * Added support for bitfields and opaque types. *------------------------------------------------------------------------- */ static herr_t H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) { htri_t has_array=FALSE; /* Whether a compound datatype has an array inside it */ unsigned flags = 0; char *hdr = (char *)*pp; unsigned i, j; size_t n, z, aligned; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_dtype_encode_helper); /* check args */ assert(pp && *pp); assert(dt); /* skip the type and class bit-field for now */ *pp += 4; UINT32ENCODE(*pp, dt->shared->size); switch (dt->shared->type) { case H5T_INTEGER: /* * Integer datatypes... */ switch (dt->shared->u.atomic.order) { case H5T_ORDER_LE: break; /*nothing */ case H5T_ORDER_BE: flags |= 0x01; break; default: HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "byte order is not supported in file format yet"); } switch (dt->shared->u.atomic.lsb_pad) { case H5T_PAD_ZERO: break; /*nothing */ case H5T_PAD_ONE: flags |= 0x02; break; default: HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet"); } switch (dt->shared->u.atomic.msb_pad) { case H5T_PAD_ZERO: break; /*nothing */ case H5T_PAD_ONE: flags |= 0x04; break; default: HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet"); } switch (dt->shared->u.atomic.u.i.sign) { case H5T_SGN_NONE: break; /*nothing */ case H5T_SGN_2: flags |= 0x08; break; default: HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "sign scheme is not supported in file format yet"); } UINT16ENCODE(*pp, dt->shared->u.atomic.offset); UINT16ENCODE(*pp, dt->shared->u.atomic.prec); break; case H5T_BITFIELD: /* * Bitfield datatypes... */ switch (dt->shared->u.atomic.order) { case H5T_ORDER_LE: break; /*nothing */ case H5T_ORDER_BE: flags |= 0x01; break; default: HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "byte order is not supported in file format yet"); } switch (dt->shared->u.atomic.lsb_pad) { case H5T_PAD_ZERO: break; /*nothing */ case H5T_PAD_ONE: flags |= 0x02; break; default: HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet"); } switch (dt->shared->u.atomic.msb_pad) { case H5T_PAD_ZERO: break; /*nothing */ case H5T_PAD_ONE: flags |= 0x04; break; default: HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet"); } UINT16ENCODE(*pp, dt->shared->u.atomic.offset); UINT16ENCODE(*pp, dt->shared->u.atomic.prec); break; case H5T_OPAQUE: /* * Opaque datatypes... The tag is stored in a field which is a * multiple of eight characters and null padded (not necessarily * null terminated). */ z = HDstrlen(dt->shared->u.opaque.tag); aligned = (z+7) & (H5T_OPAQUE_TAG_MAX - 8); flags |= aligned; HDmemcpy(*pp, dt->shared->u.opaque.tag, MIN(z,aligned)); for (n=MIN(z,aligned); nshared->u.atomic.order) { case H5T_ORDER_LE: break; /*nothing */ case H5T_ORDER_BE: flags |= 0x01; break; default: HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "byte order is not supported in file format yet"); } switch (dt->shared->u.atomic.lsb_pad) { case H5T_PAD_ZERO: break; /*nothing */ case H5T_PAD_ONE: flags |= 0x02; break; default: HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet"); } switch (dt->shared->u.atomic.msb_pad) { case H5T_PAD_ZERO: break; /*nothing */ case H5T_PAD_ONE: flags |= 0x04; break; default: HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet"); } switch (dt->shared->u.atomic.u.f.pad) { case H5T_PAD_ZERO: break; /*nothing */ case H5T_PAD_ONE: flags |= 0x08; break; default: HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet"); } switch (dt->shared->u.atomic.u.f.norm) { case H5T_NORM_NONE: break; /*nothing */ case H5T_NORM_MSBSET: flags |= 0x10; break; case H5T_NORM_IMPLIED: flags |= 0x20; break; default: HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "normalization scheme is not supported in file format yet"); } flags |= (dt->shared->u.atomic.u.f.sign << 8) & 0xff00; UINT16ENCODE(*pp, dt->shared->u.atomic.offset); UINT16ENCODE(*pp, dt->shared->u.atomic.prec); assert (dt->shared->u.atomic.u.f.epos<=255); *(*pp)++ = (uint8_t)(dt->shared->u.atomic.u.f.epos); assert (dt->shared->u.atomic.u.f.esize<=255); *(*pp)++ = (uint8_t)(dt->shared->u.atomic.u.f.esize); assert (dt->shared->u.atomic.u.f.mpos<=255); *(*pp)++ = (uint8_t)(dt->shared->u.atomic.u.f.mpos); assert (dt->shared->u.atomic.u.f.msize<=255); *(*pp)++ = (uint8_t)(dt->shared->u.atomic.u.f.msize); UINT32ENCODE(*pp, dt->shared->u.atomic.u.f.ebias); break; case H5T_COMPOUND: /* Check for an array datatype somewhere within the compound type */ if((has_array=H5T_detect_class(dt,H5T_ARRAY))<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "can't detect array class"); /* * Compound datatypes... */ flags = dt->shared->u.compnd.nmembs & 0xffff; for (i=0; ishared->u.compnd.nmembs; i++) { /* Name, multiple of eight bytes */ HDstrcpy((char*)(*pp), dt->shared->u.compnd.memb[i].name); n = HDstrlen(dt->shared->u.compnd.memb[i].name); for (z=n+1; z%8; z++) (*pp)[z] = '\0'; *pp += z; /* Member offset */ UINT32ENCODE(*pp, dt->shared->u.compnd.memb[i].offset); /* If we don't have any array fields, write out the old style * member information, for better backward compatibility * Write out all zeros for the array information, though... */ if(!has_array) { /* Dimensionality */ *(*pp)++ = 0; /* Reserved */ *(*pp)++ = 0; *(*pp)++ = 0; *(*pp)++ = 0; /* Dimension permutation */ UINT32ENCODE(*pp, 0); /* Reserved */ UINT32ENCODE(*pp, 0); /* Dimensions */ for (j=0; j<4; j++) UINT32ENCODE(*pp, 0); } /* end if */ /* Subtype */ if (H5O_dtype_encode_helper(pp, dt->shared->u.compnd.memb[i].type)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "unable to encode member type"); } break; case H5T_ENUM: /* * Enumeration datatypes... */ flags = dt->shared->u.enumer.nmembs & 0xffff; /* Parent type */ if (H5O_dtype_encode_helper(pp, dt->shared->parent)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "unable to encode parent datatype"); /* Names, each a multiple of eight bytes */ for (i=0; ishared->u.enumer.nmembs; i++) { HDstrcpy((char*)(*pp), dt->shared->u.enumer.name[i]); n = HDstrlen(dt->shared->u.enumer.name[i]); for (z=n+1; z%8; z++) (*pp)[z] = '\0'; *pp += z; } /* Values */ HDmemcpy(*pp, dt->shared->u.enumer.value, dt->shared->u.enumer.nmembs * dt->shared->parent->shared->size); *pp += dt->shared->u.enumer.nmembs * dt->shared->parent->shared->size; break; case H5T_REFERENCE: flags |= (dt->shared->u.atomic.u.r.rtype & 0x0f); break; case H5T_STRING: /* * Character string types... (not fully implemented) */ assert (dt->shared->u.atomic.order == H5T_ORDER_NONE); assert (dt->shared->u.atomic.prec == 8 * dt->shared->size); assert (dt->shared->u.atomic.offset == 0); assert (dt->shared->u.atomic.lsb_pad == H5T_PAD_ZERO); assert (dt->shared->u.atomic.msb_pad == H5T_PAD_ZERO); flags |= (dt->shared->u.atomic.u.s.pad & 0x0f); flags |= (dt->shared->u.atomic.u.s.cset & 0x0f) << 4; break; case H5T_VLEN: /* Variable length datatypes... */ flags |= (dt->shared->u.vlen.type & 0x0f); if(dt->shared->u.vlen.type == H5T_VLEN_STRING) { flags |= (dt->shared->u.vlen.pad & 0x0f) << 4; flags |= (dt->shared->u.vlen.cset & 0x0f) << 8; } /* end if */ /* Encode base type of VL information */ if (H5O_dtype_encode_helper(pp, dt->shared->parent)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "unable to encode VL parent type"); break; case H5T_TIME: /* Time datatypes... */ switch (dt->shared->u.atomic.order) { case H5T_ORDER_LE: break; /*nothing */ case H5T_ORDER_BE: flags |= 0x01; break; default: HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "byte order is not supported in file format yet"); } UINT16ENCODE(*pp, dt->shared->u.atomic.prec); break; case H5T_ARRAY: /* Array datatypes... */ /* Double-check the number of dimensions */ assert(dt->shared->u.array.ndims <= H5S_MAX_RANK); /* Encode the number of dimensions */ *(*pp)++ = dt->shared->u.array.ndims; /* Reserved */ *(*pp)++ = '\0'; *(*pp)++ = '\0'; *(*pp)++ = '\0'; /* Encode array dimensions */ for (j=0; j<(unsigned)dt->shared->u.array.ndims; j++) UINT32ENCODE(*pp, dt->shared->u.array.dim[j]); /* Encode array dimension permutations */ for (j=0; j<(unsigned)dt->shared->u.array.ndims; j++) UINT32ENCODE(*pp, dt->shared->u.array.perm[j]); /* Encode base type of array's information */ if (H5O_dtype_encode_helper(pp, dt->shared->parent)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "unable to encode VL parent type"); break; default: /*nothing */ break; } /* Encode the type's class, version and bit field */ *hdr++ = ((unsigned)(dt->shared->type) & 0x0f) | (((dt->shared->type==H5T_COMPOUND && has_array) ? H5O_DTYPE_VERSION_UPDATED : H5O_DTYPE_VERSION_COMPAT )<<4); *hdr++ = (flags >> 0) & 0xff; *hdr++ = (flags >> 8) & 0xff; *hdr++ = (flags >> 16) & 0xff; done: FUNC_LEAVE_NOAPI(ret_value); } /*-------------------------------------------------------------------------- NAME H5O_dtype_decode PURPOSE Decode a message and return a pointer to a memory struct with the decoded information USAGE void *H5O_dtype_decode(f, raw_size, p) H5F_t *f; IN: pointer to the HDF5 file struct size_t raw_size; IN: size of the raw information buffer const uint8 *p; IN: the raw information buffer RETURNS Pointer to the new message in native order on success, NULL on failure DESCRIPTION This function decodes the "raw" disk form of a simple datatype message into a struct in memory native format. The struct is allocated within this function using malloc() and is returned to the caller. --------------------------------------------------------------------------*/ static void * H5O_dtype_decode(H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *p, H5O_shared_t UNUSED *sh) { H5T_t *dt = NULL; void *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_dtype_decode); /* check args */ assert(p); if(NULL == (dt = H5T_alloc())) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") if (H5O_dtype_decode_helper(f, &p, dt) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, NULL, "can't decode type"); /* Set return value */ ret_value=dt; done: if(ret_value==NULL) { if(dt != NULL) { if(dt->shared != NULL) H5FL_FREE(H5T_shared_t, dt->shared); H5FL_FREE(H5T_t, dt); } /* end if */ } /* end if */ FUNC_LEAVE_NOAPI(ret_value); } /*-------------------------------------------------------------------------- NAME H5O_dtype_encode PURPOSE Encode a simple datatype message USAGE herr_t H5O_dtype_encode(f, raw_size, p, mesg) H5F_t *f; IN: pointer to the HDF5 file struct size_t raw_size; IN: size of the raw information buffer const uint8 *p; IN: the raw information buffer const void *mesg; IN: Pointer to the simple datatype struct RETURNS Non-negative on success/Negative on failure DESCRIPTION This function encodes the native memory form of the simple datatype message in the "raw" disk form. --------------------------------------------------------------------------*/ static herr_t H5O_dtype_encode(H5F_t UNUSED *f, uint8_t *p, const void *mesg) { const H5T_t *dt = (const H5T_t *) mesg; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_dtype_encode); /* check args */ assert(f); assert(p); assert(dt); /* encode */ if (H5O_dtype_encode_helper(&p, dt) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "can't encode type"); done: FUNC_LEAVE_NOAPI(ret_value); } /*-------------------------------------------------------------------------- NAME H5O_dtype_copy PURPOSE Copies a message from MESG to DEST, allocating DEST if necessary. USAGE void *H5O_dtype_copy(mesg, dest) const void *mesg; IN: Pointer to the source simple datatype struct const void *dest; IN: Pointer to the destination simple datatype struct RETURNS Pointer to DEST on success, NULL on failure DESCRIPTION This function copies a native (memory) simple datatype message, allocating the destination structure if necessary. --------------------------------------------------------------------------*/ static void * H5O_dtype_copy(const void *_src, void *_dst, unsigned UNUSED update_flags) { const H5T_t *src = (const H5T_t *) _src; H5T_t *dst = NULL; void *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_dtype_copy); /* check args */ assert(src); /* copy */ if (NULL == (dst = H5T_copy(src, H5T_COPY_ALL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "can't copy type"); /* was result already allocated? */ if (_dst) { *((H5T_t *) _dst) = *dst; H5FL_FREE(H5T_t,dst); dst = (H5T_t *) _dst; } /* Set return value */ ret_value=dst; done: FUNC_LEAVE_NOAPI(ret_value); } /*-------------------------------------------------------------------------- NAME H5O_dtype_size PURPOSE Return the raw message size in bytes USAGE void *H5O_dtype_size(f, mesg) H5F_t *f; IN: pointer to the HDF5 file struct const void *mesg; IN: Pointer to the source simple datatype struct RETURNS Size of message on success, 0 on failure DESCRIPTION This function returns the size of the raw simple datatype message on success. (Not counting the message type or size fields, only the data portion of the message). It doesn't take into account alignment. NOTES All datatype messages have a common 8 byte header, plus a variable- sized "properties" field. --------------------------------------------------------------------------*/ static size_t H5O_dtype_size(const H5F_t *f, const void *mesg) { unsigned i; size_t ret_value = 8; const H5T_t *dt = (const H5T_t *) mesg; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_dtype_size); assert(mesg); /* Add in the property field length for each datatype class */ switch (dt->shared->type) { case H5T_INTEGER: ret_value += 4; break; case H5T_BITFIELD: ret_value += 4; break; case H5T_OPAQUE: ret_value += (HDstrlen(dt->shared->u.opaque.tag)+7) & (H5T_OPAQUE_TAG_MAX - 8); break; case H5T_FLOAT: ret_value += 12; break; case H5T_COMPOUND: for (i=0; ishared->u.compnd.nmembs; i++) { ret_value += ((HDstrlen(dt->shared->u.compnd.memb[i].name) + 8) / 8) * 8; ret_value += 4 + /*member offset*/ 1 + /*dimensionality*/ 3 + /*reserved*/ 4 + /*permutation*/ 4 + /*reserved*/ 16; /*dimensions*/ ret_value += H5O_dtype_size(f, dt->shared->u.compnd.memb[i].type); } break; case H5T_ENUM: ret_value += H5O_dtype_size(f, dt->shared->parent); for (i=0; ishared->u.enumer.nmembs; i++) ret_value += ((HDstrlen(dt->shared->u.enumer.name[i])+8)/8)*8; ret_value += dt->shared->u.enumer.nmembs * dt->shared->parent->shared->size; break; case H5T_VLEN: ret_value += H5O_dtype_size(f, dt->shared->parent); break; case H5T_TIME: ret_value += 2; break; case H5T_ARRAY: ret_value += 4; /* ndims & reserved bytes*/ ret_value += 4*dt->shared->u.array.ndims; /* dimensions */ ret_value += 4*dt->shared->u.array.ndims; /* dimension permutations */ ret_value += H5O_dtype_size(f, dt->shared->parent); break; default: /*no properties */ break; } FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_dtype_reset * * Purpose: Frees resources within a message, but doesn't free * the message itself. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Tuesday, December 9, 1997 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_dtype_reset(void *_mesg) { H5T_t *dt = (H5T_t *) _mesg; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_dtype_reset); if (dt) H5T_free(dt); FUNC_LEAVE_NOAPI(SUCCEED); } /*------------------------------------------------------------------------- * Function: H5O_dtype_free * * Purpose: Free's the message * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Thursday, March 30, 2000 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_dtype_free (void *mesg) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_dtype_free); assert (mesg); H5FL_FREE(H5T_shared_t, ((H5T_t *) mesg)->shared); H5FL_FREE(H5T_t,mesg); FUNC_LEAVE_NOAPI(SUCCEED); } /*------------------------------------------------------------------------- * Function: H5O_dtype_get_share * * Purpose: Returns information about where the shared message is located * by filling in the SH shared message struct. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Monday, June 1, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_dtype_get_share(H5F_t UNUSED *f, const void *_mesg, H5O_shared_t *sh/*out*/) { const H5T_t *dt = (const H5T_t *)_mesg; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_dtype_get_share); assert (dt); assert (sh); if (H5F_addr_defined (dt->ent.header)) { /* If the address is defined, this had better be a named datatype */ HDassert (H5T_STATE_NAMED==dt->shared->state || H5T_STATE_OPEN==dt->shared->state); sh->in_gh = FALSE; sh->u.ent = dt->ent; } else HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype is not sharable"); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_dtype_set_share * * Purpose: Copies sharing information from SH into the message. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Thursday, June 4, 1998 * * Modifications: * * Pedro Vicente, 22 Aug 2002 * Added `id to name' support. * *------------------------------------------------------------------------- */ static herr_t H5O_dtype_set_share (H5F_t UNUSED *f, void *_mesg/*in,out*/, const H5O_shared_t *sh) { H5T_t *dt = (H5T_t *)_mesg; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_dtype_set_share); assert (dt); assert (sh); assert (!sh->in_gh); /* NULL copy here, names not appropriate */ H5G_ent_copy(&(dt->ent),&(sh->u.ent),H5G_COPY_NULL); /* Note that the datatype is a named datatype */ dt->shared->state = H5T_STATE_NAMED; FUNC_LEAVE_NOAPI(SUCCEED); } /*-------------------------------------------------------------------------- NAME H5O_dtype_debug PURPOSE Prints debugging information for a message USAGE void *H5O_dtype_debug(f, mesg, stream, indent, fwidth) H5F_t *f; IN: pointer to the HDF5 file struct const void *mesg; IN: Pointer to the source simple datatype struct FILE *stream; IN: Pointer to the stream for output data int indent; IN: Amount to indent information by int fwidth; IN: Field width (?) RETURNS Non-negative on success/Negative on failure DESCRIPTION This function prints debugging output to the stream passed as a parameter. --------------------------------------------------------------------------*/ static herr_t H5O_dtype_debug(H5F_t *f, hid_t dxpl_id, const void *mesg, FILE *stream, int indent, int fwidth) { const H5T_t *dt = (const H5T_t*)mesg; const char *s; char buf[256]; unsigned i; size_t k; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_dtype_debug); /* check args */ assert(f); assert(dt); assert(stream); assert(indent >= 0); assert(fwidth >= 0); switch (dt->shared->type) { case H5T_INTEGER: s = "integer"; break; case H5T_FLOAT: s = "floating-point"; break; case H5T_TIME: s = "date and time"; break; case H5T_STRING: s = "text string"; break; case H5T_BITFIELD: s = "bit field"; break; case H5T_OPAQUE: s = "opaque"; break; case H5T_COMPOUND: s = "compound"; break; case H5T_REFERENCE: s = "reference"; break; case H5T_ENUM: s = "enum"; break; case H5T_ARRAY: s = "array"; break; case H5T_VLEN: s = "vlen"; break; default: sprintf(buf, "H5T_CLASS_%d", (int) (dt->shared->type)); s = buf; break; } fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Type class:", s); fprintf(stream, "%*s%-*s %lu byte%s\n", indent, "", fwidth, "Size:", (unsigned long)(dt->shared->size), 1==dt->shared->size?"":"s"); if (H5T_COMPOUND == dt->shared->type) { fprintf(stream, "%*s%-*s %d\n", indent, "", fwidth, "Number of members:", dt->shared->u.compnd.nmembs); for (i=0; ishared->u.compnd.nmembs; i++) { sprintf(buf, "Member %d:", i); fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, buf, dt->shared->u.compnd.memb[i].name); fprintf(stream, "%*s%-*s %lu\n", indent+3, "", MAX(0, fwidth-3), "Byte offset:", (unsigned long) (dt->shared->u.compnd.memb[i].offset)); H5O_dtype_debug(f, dxpl_id, dt->shared->u.compnd.memb[i].type, stream, indent+3, MAX(0, fwidth - 3)); } } else if (H5T_ENUM==dt->shared->type) { fprintf(stream, "%*s%s\n", indent, "", "Base type:"); H5O_dtype_debug(f, dxpl_id, dt->shared->parent, stream, indent+3, MAX(0, fwidth-3)); fprintf(stream, "%*s%-*s %d\n", indent, "", fwidth, "Number of members:", dt->shared->u.enumer.nmembs); for (i=0; ishared->u.enumer.nmembs; i++) { sprintf(buf, "Member %d:", i); fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, buf, dt->shared->u.enumer.name[i]); fprintf(stream, "%*s%-*s 0x", indent, "", fwidth, "Raw bytes of value:"); for (k=0; kshared->parent->shared->size; k++) { fprintf(stream, "%02x", dt->shared->u.enumer.value[i*dt->shared->parent->shared->size+k]); } fprintf(stream, "\n"); } } else if (H5T_OPAQUE==dt->shared->type) { fprintf(stream, "%*s%-*s \"%s\"\n", indent, "", fwidth, "Tag:", dt->shared->u.opaque.tag); } else if (H5T_REFERENCE==dt->shared->type) { fprintf(stream, "%*s%-*s\n", indent, "", fwidth, "Fix dumping reference types!"); } else if (H5T_VLEN==dt->shared->type) { switch (dt->shared->u.vlen.type) { case H5T_VLEN_SEQUENCE: s = "sequence"; break; case H5T_VLEN_STRING: s = "string"; break; default: sprintf(buf, "H5T_VLEN_%d", dt->shared->u.vlen.type); s = buf; break; } fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Vlen type:", s); switch (dt->shared->u.vlen.loc) { case H5T_VLEN_MEMORY: s = "memory"; break; case H5T_VLEN_DISK: s = "disk"; break; default: sprintf(buf, "H5T_VLEN_%d", dt->shared->u.vlen.loc); s = buf; break; } fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Location:", s); } else if (H5T_ARRAY==dt->shared->type) { fprintf(stream, "%*s%-*s %d\n", indent, "", fwidth, "Rank:", dt->shared->u.array.ndims); fprintf(stream, "%*s%-*s {", indent, "", fwidth, "Dim Size:"); for (i=0; i<(unsigned)dt->shared->u.array.ndims; i++) { fprintf (stream, "%s%u", i?", ":"", (unsigned)dt->shared->u.array.dim[i]); } fprintf (stream, "}\n"); fprintf(stream, "%*s%-*s {", indent, "", fwidth, "Dim Permutation:"); for (i=0; i<(unsigned)dt->shared->u.array.ndims; i++) { fprintf (stream, "%s%d", i?", ":"", dt->shared->u.array.perm[i]); } fprintf (stream, "}\n"); fprintf(stream, "%*s%s\n", indent, "", "Base type:"); H5O_dtype_debug(f, dxpl_id, dt->shared->parent, stream, indent+3, MAX(0, fwidth-3)); } else { switch (dt->shared->u.atomic.order) { case H5T_ORDER_LE: s = "little endian"; break; case H5T_ORDER_BE: s = "big endian"; break; case H5T_ORDER_VAX: s = "VAX"; break; case H5T_ORDER_NONE: s = "none"; break; default: sprintf(buf, "H5T_ORDER_%d", dt->shared->u.atomic.order); s = buf; break; } fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Byte order:", s); fprintf(stream, "%*s%-*s %lu bit%s\n", indent, "", fwidth, "Precision:", (unsigned long)(dt->shared->u.atomic.prec), 1==dt->shared->u.atomic.prec?"":"s"); fprintf(stream, "%*s%-*s %lu bit%s\n", indent, "", fwidth, "Offset:", (unsigned long)(dt->shared->u.atomic.offset), 1==dt->shared->u.atomic.offset?"":"s"); switch (dt->shared->u.atomic.lsb_pad) { case H5T_PAD_ZERO: s = "zero"; break; case H5T_PAD_ONE: s = "one"; break; default: s = "pad?"; break; } fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Low pad type:", s); switch (dt->shared->u.atomic.msb_pad) { case H5T_PAD_ZERO: s = "zero"; break; case H5T_PAD_ONE: s = "one"; break; default: s = "pad?"; break; } fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "High pad type:", s); if (H5T_FLOAT == dt->shared->type) { switch (dt->shared->u.atomic.u.f.pad) { case H5T_PAD_ZERO: s = "zero"; break; case H5T_PAD_ONE: s = "one"; break; default: if (dt->shared->u.atomic.u.f.pad < 0) { sprintf(buf, "H5T_PAD_%d", -(dt->shared->u.atomic.u.f.pad)); } else { sprintf(buf, "bit-%d", dt->shared->u.atomic.u.f.pad); } s = buf; break; } fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Internal pad type:", s); switch (dt->shared->u.atomic.u.f.norm) { case H5T_NORM_IMPLIED: s = "implied"; break; case H5T_NORM_MSBSET: s = "msb set"; break; case H5T_NORM_NONE: s = "none"; break; default: sprintf(buf, "H5T_NORM_%d", (int) (dt->shared->u.atomic.u.f.norm)); s = buf; } fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Normalization:", s); fprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, "Sign bit location:", (unsigned long) (dt->shared->u.atomic.u.f.sign)); fprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, "Exponent location:", (unsigned long) (dt->shared->u.atomic.u.f.epos)); fprintf(stream, "%*s%-*s 0x%08lx\n", indent, "", fwidth, "Exponent bias:", (unsigned long) (dt->shared->u.atomic.u.f.ebias)); fprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, "Exponent size:", (unsigned long) (dt->shared->u.atomic.u.f.esize)); fprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, "Mantissa location:", (unsigned long) (dt->shared->u.atomic.u.f.mpos)); fprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, "Mantissa size:", (unsigned long) (dt->shared->u.atomic.u.f.msize)); } else if (H5T_INTEGER == dt->shared->type) { switch (dt->shared->u.atomic.u.i.sign) { case H5T_SGN_NONE: s = "none"; break; case H5T_SGN_2: s = "2's comp"; break; default: sprintf(buf, "H5T_SGN_%d", (int) (dt->shared->u.atomic.u.i.sign)); s = buf; break; } fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Sign scheme:", s); } } FUNC_LEAVE_NOAPI(SUCCEED); } xdmf-3.0+git20160803/Utilities/hdf5/H5Zpublic.h0000640000175000017500000002052713003006557020657 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* Programmer: Robb Matzke * Thursday, April 16, 1998 */ #ifndef _H5Zpublic_H #define _H5Zpublic_H /* * Filter identifiers. Values 0 through 255 are for filters defined by the * HDF5 library. Values 256 through 511 are available for testing new * filters. Subsequent values should be obtained from the HDF5 development * team at hdf5dev@ncsa.uiuc.edu. These values will never change because they * appear in the HDF5 files. */ typedef int H5Z_filter_t; #define H5Z_FILTER_ERROR (-1) /*no filter */ #define H5Z_FILTER_NONE 0 /*reserved indefinitely */ #define H5Z_FILTER_ALL 0 /*symbol to remove all filters in H5Premove_filter */ #define H5Z_FILTER_DEFLATE 1 /*deflation like gzip */ #define H5Z_FILTER_SHUFFLE 2 /*shuffle the data */ #define H5Z_FILTER_FLETCHER32 3 /*fletcher32 checksum of EDC */ #define H5Z_FILTER_SZIP 4 /*szip compression */ #define H5Z_FILTER_RESERVED 256 /*filter ids below this value are reserved */ #define H5Z_FILTER_MAX 65535 /*maximum filter id */ #define H5Z_MAX_NFILTERS 32 /* Maximum number of filters allowed in a pipeline (should probably be allowed to be an unlimited amount) */ /* Flags for filter definition */ #define H5Z_FLAG_DEFMASK 0x00ff /*definition flag mask */ #define H5Z_FLAG_MANDATORY 0x0000 /*filter is mandatory */ #define H5Z_FLAG_OPTIONAL 0x0001 /*filter is optional */ /* Additional flags for filter invocation */ #define H5Z_FLAG_INVMASK 0xff00 /*invocation flag mask */ #define H5Z_FLAG_REVERSE 0x0100 /*reverse direction; read */ #define H5Z_FLAG_SKIP_EDC 0x0200 /*skip EDC filters for read */ /* Special parameters for szip compression */ /* [These are aliases for the similar definitions in szlib.h, which we can't * include directly due to the duplication of various symbols with the zlib.h * header file] */ #define H5_SZIP_ALLOW_K13_OPTION_MASK 1 #define H5_SZIP_CHIP_OPTION_MASK 2 #define H5_SZIP_EC_OPTION_MASK 4 #define H5_SZIP_NN_OPTION_MASK 32 #define H5_SZIP_MAX_PIXELS_PER_BLOCK 32 /* Values to decide if EDC is enabled for reading data */ typedef enum H5Z_EDC_t { H5Z_ERROR_EDC = -1, /* error value */ H5Z_DISABLE_EDC = 0, H5Z_ENABLE_EDC = 1, H5Z_NO_EDC = 2 /* must be the last */ } H5Z_EDC_t; /* Bit flags for H5Zget_filter_info */ #define H5Z_FILTER_CONFIG_ENCODE_ENABLED (0x0001) #define H5Z_FILTER_CONFIG_DECODE_ENABLED (0x0002) /* Return values for filter callback function */ typedef enum H5Z_cb_return_t { H5Z_CB_ERROR = -1, H5Z_CB_FAIL = 0, /* I/O should fail if filter fails. */ H5Z_CB_CONT = 1, /* I/O continues if filter fails. */ H5Z_CB_NO = 2 } H5Z_cb_return_t; /* Filter callback function definition */ typedef H5Z_cb_return_t (*H5Z_filter_func_t)(H5Z_filter_t filter, void* buf, size_t buf_size, void* op_data); /* Structure for filter callback property */ typedef struct H5Z_cb_t { H5Z_filter_func_t func; void* op_data; } H5Z_cb_t; #ifdef __cplusplus extern "C" { #endif /* * Before a dataset gets created, the "can_apply" callbacks for any filters used * in the dataset creation property list are called * with the dataset's dataset creation property list, the dataset's datatype and * a dataspace describing a chunk (for chunked dataset storage). * * The "can_apply" callback must determine if the combination of the dataset * creation property list setting, the datatype and the dataspace represent a * valid combination to apply this filter to. For example, some cases of * invalid combinations may involve the filter not operating correctly on * certain datatypes (or certain datatype sizes), or certain sizes of the chunk * dataspace. * * The "can_apply" callback can be the NULL pointer, in which case, the library * will assume that it can apply to any combination of dataset creation * property list values, datatypes and dataspaces. * * The "can_apply" callback returns positive a valid combination, zero for an * invalid combination and negative for an error. */ typedef herr_t (*H5Z_can_apply_func_t)(hid_t dcpl_id, hid_t type_id, hid_t space_id); /* * After the "can_apply" callbacks are checked for new datasets, the "set_local" * callbacks for any filters used in the dataset creation property list are * called. These callbacks receive the dataset's private copy of the dataset * creation property list passed in to H5Dcreate (i.e. not the actual property * list passed in to H5Dcreate) and the datatype ID passed in to H5Dcreate * (which is not copied and should not be modified) and a dataspace describing * the chunk (for chunked dataset storage) (which should also not be modified). * * The "set_local" callback must set any parameters that are specific to this * dataset, based on the combination of the dataset creation property list * values, the datatype and the dataspace. For example, some filters perform * different actions based on different datatypes (or datatype sizes) or * different number of dimensions or dataspace sizes. * * The "set_local" callback can be the NULL pointer, in which case, the library * will assume that there are no dataset-specific settings for this filter. * * The "set_local" callback must return non-negative on success and negative * for an error. */ typedef herr_t (*H5Z_set_local_func_t)(hid_t dcpl_id, hid_t type_id, hid_t space_id); /* * A filter gets definition flags and invocation flags (defined above), the * client data array and size defined when the filter was added to the * pipeline, the size in bytes of the data on which to operate, and pointers * to a buffer and its allocated size. * * The filter should store the result in the supplied buffer if possible, * otherwise it can allocate a new buffer, freeing the original. The * allocated size of the new buffer should be returned through the BUF_SIZE * pointer and the new buffer through the BUF pointer. * * The return value from the filter is the number of bytes in the output * buffer. If an error occurs then the function should return zero and leave * all pointer arguments unchanged. */ typedef size_t (*H5Z_func_t)(unsigned int flags, size_t cd_nelmts, const unsigned int cd_values[], size_t nbytes, size_t *buf_size, void **buf); /* * The filter table maps filter identification numbers to structs that * contain a pointers to the filter function and timing statistics. */ typedef struct H5Z_class_t { H5Z_filter_t id; /* Filter ID number */ const char *name; /* Comment for debugging */ H5Z_can_apply_func_t can_apply; /* The "can apply" callback for a filter */ H5Z_set_local_func_t set_local; /* The "set local" callback for a filter */ H5Z_func_t filter; /* The actual filter function */ } H5Z_class_t; #ifdef H5_WANT_H5_V1_4_COMPAT H5_DLL herr_t H5Zregister(H5Z_filter_t id, const char *comment, H5Z_func_t filter); #else /* H5_WANT_H5_V1_4_COMPAT */ H5_DLL herr_t H5Zregister(const H5Z_class_t *cls); #endif /* H5_WANT_H5_V1_4_COMPAT */ H5_DLL herr_t H5Zunregister(H5Z_filter_t id); H5_DLL htri_t H5Zfilter_avail(H5Z_filter_t id); H5_DLL herr_t H5Zget_filter_info(H5Z_filter_t filter, unsigned int *filter_config_flags); #ifdef __cplusplus } #endif #endif xdmf-3.0+git20160803/Utilities/hdf5/H5Gpkg.h0000640000175000017500000002020213003006557020125 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Robb Matzke * Thursday, September 18, 1997 * * Purpose: This file contains declarations which are visible * only within the H5G package. Source files outside the * H5G package should include H5Gprivate.h instead. */ #ifndef H5G_PACKAGE #error "Do not include this file outside the H5G package!" #endif #ifndef _H5Gpkg_H #define _H5Gpkg_H /* Get package's private header */ #include "H5Gprivate.h" /* Other private headers needed by this file */ #include "H5ACprivate.h" /* Metadata cache */ #include "H5Oprivate.h" /* Object headers */ /* * A symbol table node is a collection of symbol table entries. It can * be thought of as the lowest level of the B-link tree that points to * a collection of symbol table entries that belong to a specific symbol * table or group. */ typedef struct H5G_node_t { H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */ /* first field in structure */ unsigned nsyms; /*number of symbols */ H5G_entry_t *entry; /*array of symbol table entries */ } H5G_node_t; /* * Shared information for all open group objects */ struct H5G_shared_t { int fo_count; /* open file object count */ hbool_t mounted; /* Group is mount point */ }; /* * A group handle passed around through layers of the library within and * above the H5G layer. */ struct H5G_t { H5G_shared_t* shared; /*shared file object data */ H5G_entry_t ent; /*info about the group */ }; /* * Common data exchange structure for symbol table nodes. This structure is * passed through the B-link tree layer to the methods for the objects * to which the B-link tree points. */ typedef struct H5G_bt_ud_common_t { /* downward */ const char *name; /*points to temporary memory */ haddr_t heap_addr; /*symbol table heap address */ } H5G_bt_ud_common_t; /* * Data exchange structure for symbol table nodes. This structure is * passed through the B-link tree layer to the methods for the objects * to which the B-link tree points for operations which require no * additional information. * * (Just an alias for the "common" info). */ typedef H5G_bt_ud_common_t H5G_bt_ud0_t; /* * Data exchange structure for symbol table nodes. This structure is * passed through the B-link tree layer to the methods for the objects * to which the B-link tree points. */ typedef struct H5G_bt_ud1_t { /* downward */ H5G_bt_ud_common_t common; /* Common info for B-tree user data (must be first) */ /* downward for INSERT, upward for FIND */ H5G_entry_t *ent; /*entry to insert into table */ } H5G_bt_ud1_t; /* * Data exchange structure for symbol table nodes. This structure is * passed through the B-link tree layer to the methods for the objects * to which the B-link tree points. */ typedef struct H5G_bt_ud2_t { /* downward */ H5G_bt_ud_common_t common; /* Common info for B-tree user data (must be first) */ hbool_t adj_link; /* Whether to adjust the link count on objects */ /* upward */ } H5G_bt_ud2_t; /* * Data exchange structure to pass through the B-tree layer for the * H5B_iterate function. */ typedef struct H5G_bt_it_ud1_t { /* downward */ hid_t group_id; /*group id to pass to iteration operator */ haddr_t heap_addr; /*symbol table heap address */ H5G_iterate_t op; /*iteration operator */ void *op_data; /*user-defined operator data */ int skip; /*initial entries to skip */ /* upward */ int final_ent; /*final entry looked at */ } H5G_bt_it_ud1_t; /* * Data exchange structure to pass through the B-tree layer for the * H5B_iterate function. */ typedef struct H5G_bt_it_ud2_t { /* downward */ haddr_t heap_addr; /*symbol table heap address */ hsize_t idx; /*index of group member to be queried */ hsize_t num_objs; /*the number of objects having been traversed*/ /* upward */ char *name; /*member name to be returned */ } H5G_bt_it_ud2_t; /* * Data exchange structure to pass through the B-tree layer for the * H5B_iterate function. */ typedef struct H5G_bt_it_ud3_t { /* downward */ hsize_t idx; /*index of group member to be queried */ hsize_t num_objs; /*the number of objects having been traversed*/ /* upward */ #ifdef H5_WANT_H5_V1_4_COMPAT int type; /*member type to be returned */ #else /* H5_WANT_H5_V1_4_COMPAT */ H5G_obj_t type; /*member type to be returned */ #endif /* H5_WANT_H5_V1_4_COMPAT */ } H5G_bt_it_ud3_t; /* * Data exchange structure to pass through the B-tree layer for the * H5B_iterate function. */ typedef struct H5G_bt_it_ud4_t { /* downward */ haddr_t heap_addr; /*symbol table heap address */ H5G_entry_t *grp_ent; /*entry of group */ /* upward */ } H5G_bt_it_ud4_t; /* * This is the class identifier to give to the B-tree functions. */ H5_DLLVAR H5B_class_t H5B_SNODE[1]; /* The cache subclass */ H5_DLLVAR const H5AC_class_t H5AC_SNODE[1]; /* * Functions that understand symbol tables but not names. The * functions that understand names are exported to the rest of * the library and appear in H5Gprivate.h. */ H5_DLL herr_t H5G_stab_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, H5G_entry_t *ent/*out*/); H5_DLL herr_t H5G_stab_find(H5G_entry_t *grp_ent, const char *name, H5G_entry_t *obj_ent/*out*/, hid_t dxpl_id); H5_DLL herr_t H5G_stab_insert(H5G_entry_t *grp_ent, const char *name, H5G_entry_t *obj_ent, hbool_t inc_link, hid_t dxpl_id); H5_DLL herr_t H5G_stab_delete(H5F_t *f, hid_t dxpl_id, const H5O_stab_t *stab, hbool_t adj_link); H5_DLL herr_t H5G_stab_remove(H5G_entry_t *grp_ent, const char *name, hid_t dxpl_id); /* * Functions that understand symbol table entries. */ H5_DLL herr_t H5G_ent_decode_vec(H5F_t *f, const uint8_t **pp, H5G_entry_t *ent, unsigned n); H5_DLL herr_t H5G_ent_encode_vec(H5F_t *f, uint8_t **pp, const H5G_entry_t *ent, unsigned n); H5_DLL herr_t H5G_ent_set_name(H5G_entry_t *loc, H5G_entry_t *obj, const char *name); /* Functions that understand symbol table nodes */ H5_DLL int H5G_node_iterate (H5F_t *f, hid_t dxpl_id, const void *_lt_key, haddr_t addr, const void *_rt_key, void *_udata); H5_DLL int H5G_node_sumup(H5F_t *f, hid_t dxpl_id, const void *_lt_key, haddr_t addr, const void *_rt_key, void *_udata); H5_DLL int H5G_node_name(H5F_t *f, hid_t dxpl_id, const void *_lt_key, haddr_t addr, const void *_rt_key, void *_udata); H5_DLL int H5G_node_type(H5F_t *f, hid_t dxpl_id, const void *_lt_key, haddr_t addr, const void *_rt_key, void *_udata); #endif xdmf-3.0+git20160803/Utilities/hdf5/H5Sprivate.h0000640000175000017500000003516713003006557021052 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * This file contains private information about the H5S module */ #ifndef _H5Sprivate_H #define _H5Sprivate_H #include "H5Spublic.h" /* Private headers needed by this file */ #include "H5private.h" /* Generic Functions */ #include "H5Dprivate.h" /* Dataset functions */ #include "H5Fprivate.h" /* Files */ #include "H5Gprivate.h" /* Groups */ #include "H5Oprivate.h" /* Object headers */ #include "H5Pprivate.h" /* Property lists */ /* Flags for H5S_find */ #define H5S_CONV_PAR_IO_POSSIBLE 0x0001 /* The storage options are mutually exclusive */ /* (2-bits reserved for storage type currently) */ #define H5S_CONV_STORAGE_COMPACT 0x0000 /* i.e. '0' */ #define H5S_CONV_STORAGE_CONTIGUOUS 0x0002 /* i.e. '1' */ #define H5S_CONV_STORAGE_CHUNKED 0x0004 /* i.e. '2' */ #define H5S_CONV_STORAGE_MASK 0x0006 /* Flags for "get_seq_list" methods */ #define H5S_GET_SEQ_LIST_SORTED 0x0001 /* Forward references of package typedefs */ typedef struct H5S_t H5S_t; typedef struct H5S_pnt_node_t H5S_pnt_node_t; typedef struct H5S_hyper_span_t H5S_hyper_span_t; typedef struct H5S_hyper_span_info_t H5S_hyper_span_info_t; /* Information about one dimension in a hyperslab selection */ typedef struct H5S_hyper_dim_t { hsize_t start; hsize_t stride; hsize_t count; hsize_t block; } H5S_hyper_dim_t; /* Point selection iteration container */ typedef struct { H5S_pnt_node_t *curr; /* Pointer to next node to output */ } H5S_point_iter_t; /* Hyperslab selection iteration container */ typedef struct { /* Common fields for all hyperslab selections */ hsize_t off[H5S_MAX_RANK]; /* Offset in span node (used as position for regular hyperslabs) */ unsigned iter_rank; /* Rank of iterator information */ /* (This should always be the same as the dataspace * rank, except for regular hyperslab selections in * which there are contiguous regions in the lower * dimensions which have been "flattened" out */ hbool_t diminfo_valid; /* Whether the dimension information is valid */ /* "Flattened" regular hyperslab selection fields */ H5S_hyper_dim_t diminfo[H5S_MAX_RANK]; /* "Flattened" regular selection information */ hsize_t size[H5S_MAX_RANK]; /* "Flattened" dataspace extent information */ hssize_t sel_off[H5S_MAX_RANK]; /* "Flattened" selection offset information */ /* Irregular hyperslab selection fields */ H5S_hyper_span_info_t *spans; /* Pointer to copy of the span tree */ H5S_hyper_span_t *span[H5S_MAX_RANK];/* Array of pointers to span nodes */ } H5S_hyper_iter_t; /* "All" selection iteration container */ typedef struct { hsize_t elmt_offset; /* Next element to output */ hsize_t byte_offset; /* Next byte to output */ } H5S_all_iter_t; /* Forward declaration of selection iteration class */ struct H5S_sel_iter_class_t; /* Selection iteration container */ typedef struct H5S_sel_iter_t { /* Selection class */ const struct H5S_sel_iter_class_t *type; /* Selection iteration class info */ /* Information common to all iterators */ unsigned rank; /* Rank of dataspace the selection iterator is operating on */ hsize_t *dims; /* Dimensions of dataspace the selection is operating on */ hsize_t elmt_left; /* Number of elements left to iterate over */ size_t elmt_size; /* Size of elements to iterate over */ /* Information specific to each type of iterator */ union { H5S_point_iter_t pnt; /* Point selection iteration information */ H5S_hyper_iter_t hyp; /* New Hyperslab selection iteration information */ H5S_all_iter_t all; /* "All" selection iteration information */ } u; } H5S_sel_iter_t; #ifdef H5S_DEBUG typedef struct H5S_iostats_t { H5S_sel_type ftype; H5S_sel_type mtype; struct { H5_timer_t scat_timer; /*time spent scattering */ hsize_t scat_nbytes; /*scatter throughput */ hsize_t scat_ncalls; /*number of calls */ H5_timer_t gath_timer; /*time spent gathering */ hsize_t gath_nbytes; /*gather throughput */ hsize_t gath_ncalls; /*number of calls */ H5_timer_t bkg_timer; /*time for background */ hsize_t bkg_nbytes; /*background throughput */ hsize_t bkg_ncalls; /*number of calls */ H5_timer_t read_timer; /*time for read calls */ hsize_t read_nbytes; /*total bytes read */ hsize_t read_ncalls; /*number of calls */ H5_timer_t write_timer; /*time for write calls */ hsize_t write_nbytes; /*total bytes written */ hsize_t write_ncalls; /*number of calls */ } stats[2]; /* 0=output, 1=input */ } H5S_iostats_t; #endif /* If the module using this macro is allowed access to the private variables, access them directly */ #ifdef H5S_PACKAGE #define H5S_GET_EXTENT_TYPE(S) ((S)->extent.type) #define H5S_GET_EXTENT_NDIMS(S) ((S)->extent.rank) #define H5S_GET_EXTENT_NPOINTS(S) ((S)->extent.nelem) #define H5S_GET_SELECT_NPOINTS(S) ((S)->select.num_elem) #define H5S_GET_SELECT_TYPE(S) ((S)->select.type->type) #define H5S_SELECT_GET_SEQ_LIST(S,FLAGS,ITER,MAXSEQ,MAXBYTES,NSEQ,NBYTES,OFF,LEN) ((*(S)->select.type->get_seq_list)(S,FLAGS,ITER,MAXSEQ,MAXBYTES,NSEQ,NBYTES,OFF,LEN)) #define H5S_SELECT_VALID(S) ((*(S)->select.type->is_valid)(S)) #define H5S_SELECT_RELEASE(S) ((*(S)->select.type->release)(S)) #define H5S_SELECT_SERIAL_SIZE(S) ((*(S)->select.type->serial_size)(S)) #define H5S_SELECT_SERIALIZE(S,BUF) ((*(S)->select.type->serialize)(S,BUF)) #define H5S_SELECT_BOUNDS(S,START,END) ((*(S)->select.type->bounds)(S,START,END)) #define H5S_SELECT_IS_CONTIGUOUS(S) ((*(S)->select.type->is_contiguous)(S)) #define H5S_SELECT_IS_SINGLE(S) ((*(S)->select.type->is_single)(S)) #define H5S_SELECT_IS_REGULAR(S) ((*(S)->select.type->is_regular)(S)) #define H5S_SELECT_ITER_COORDS(ITER,COORDS) ((*(ITER)->type->iter_coords)(ITER,COORDS)) #define H5S_SELECT_ITER_BLOCK(ITER,START,END) ((*(ITER)->type->iter_block)(ITER,START,END)) #define H5S_SELECT_ITER_NELMTS(ITER) ((*(ITER)->type->iter_nelmts)(ITER)) #define H5S_SELECT_ITER_HAS_NEXT_BLOCK(ITER) ((*(ITER)->type->iter_has_next_block)(ITER)) #define H5S_SELECT_ITER_NEXT(ITER,NELEM)((*(ITER)->type->iter_next)(ITER,NELEM)) #define H5S_SELECT_ITER_NEXT_BLOCK(ITER) ((*(ITER)->type->iter_next_block)(ITER)) #define H5S_SELECT_ITER_RELEASE(ITER) ((*(ITER)->type->iter_release)(ITER)) #else /* H5S_PACKAGE */ #define H5S_GET_EXTENT_TYPE(S) (H5S_get_simple_extent_type(S)) #define H5S_GET_EXTENT_NDIMS(S) (H5S_get_simple_extent_ndims(S)) #define H5S_GET_EXTENT_NPOINTS(S) (H5S_get_simple_extent_npoints(S)) #define H5S_GET_SELECT_NPOINTS(S) (H5S_get_select_npoints(S)) #define H5S_GET_SELECT_TYPE(S) (H5S_get_select_type(S)) #define H5S_SELECT_GET_SEQ_LIST(S,FLAGS,ITER,MAXSEQ,MAXBYTES,NSEQ,NBYTES,OFF,LEN) (H5S_select_get_seq_list(S,FLAGS,ITER,MAXSEQ,MAXBYTES,NSEQ,NBYTES,OFF,LEN)) #define H5S_SELECT_VALID(S) (H5S_select_valid(S)) #define H5S_SELECT_RELEASE(S) (H5S_select_release(S)) #define H5S_SELECT_SERIAL_SIZE(S) (H5S_select_serial_size(S)) #define H5S_SELECT_SERIALIZE(S,BUF) (H5S_select_serialize(S,BUF)) #define H5S_SELECT_BOUNDS(S,START,END) (H5S_get_select_bounds(S,START,END)) #define H5S_SELECT_IS_CONTIGUOUS(S) (H5S_select_is_contiguous(S)) #define H5S_SELECT_IS_SINGLE(S) (H5S_select_is_single(S)) #define H5S_SELECT_IS_REGULAR(S) (H5S_select_is_regular(S)) #define H5S_SELECT_ITER_COORDS(ITER,COORDS) (H5S_select_iter_coords(ITER,COORDS)) #define H5S_SELECT_ITER_BLOCK(ITER,START,END) (H5S_select_iter_block(ITER,START,END)) #define H5S_SELECT_ITER_NELMTS(ITER) (H5S_select_iter_nelmts(ITER)) #define H5S_SELECT_ITER_HAS_NEXT_BLOCK(ITER) (H5S_select_iter_has_next_block(ITER)) #define H5S_SELECT_ITER_NEXT(ITER,NELEM)(H5S_select_iter_next(ITER,NELEM)) #define H5S_SELECT_ITER_NEXT_BLOCK(ITER) (H5S_select_iter_next_block(ITER)) #define H5S_SELECT_ITER_RELEASE(ITER) (H5S_select_iter_release(ITER)) #endif /* H5S_PACKAGE */ /* Handle these two callbacks in a special way, since they have prologs that need to be executed */ #define H5S_SELECT_COPY(DST,SRC,SHARE) (H5S_select_copy(DST,SRC,SHARE)) #define H5S_SELECT_DESERIALIZE(S,BUF) (H5S_select_deserialize(S,BUF)) /* Operations on dataspaces */ H5_DLL H5S_t *H5S_copy(const H5S_t *src, hbool_t share_selection); H5_DLL herr_t H5S_close(H5S_t *ds); #ifdef H5S_DEBUG H5_DLL H5S_iostats_t *H5S_find(const H5S_t *mem_space, const H5S_t *file_space); #endif /* H5S_DEBUG */ H5_DLL H5S_class_t H5S_get_simple_extent_type(const H5S_t *ds); H5_DLL hssize_t H5S_get_simple_extent_npoints(const H5S_t *ds); H5_DLL hsize_t H5S_get_npoints_max(const H5S_t *ds); H5_DLL hbool_t H5S_has_extent(const H5S_t *ds); H5_DLL int H5S_get_simple_extent_ndims(const H5S_t *ds); H5_DLL int H5S_get_simple_extent_dims(const H5S_t *ds, hsize_t dims[]/*out*/, hsize_t max_dims[]/*out*/); H5_DLL herr_t H5S_modify(struct H5G_entry_t *ent, const H5S_t *space, hbool_t update_time, hid_t dxpl_id); H5_DLL herr_t H5S_append(H5F_t *f, hid_t dxpl_id, struct H5O_t *oh, const H5S_t *ds); H5_DLL size_t H5S_raw_size(const H5F_t *f, const H5S_t *space); H5_DLL H5S_t *H5S_read(const struct H5G_entry_t *ent, hid_t dxpl_id); H5_DLL int H5S_extend(H5S_t *space, const hsize_t *size); H5_DLL int H5S_set_extent(H5S_t *space, const hsize_t *size); H5_DLL herr_t H5S_set_extent_real(H5S_t *space, const hsize_t *size); H5_DLL H5S_t *H5S_create_simple(unsigned rank, const hsize_t dims[/*rank*/], const hsize_t maxdims[/*rank*/]); H5_DLL herr_t H5S_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE *stream, int indent, int fwidth); /* Operations on selections */ H5_DLL herr_t H5S_select_deserialize(H5S_t *space, const uint8_t *buf); H5_DLL H5S_sel_type H5S_get_select_type(const H5S_t *space); H5_DLL herr_t H5S_select_iterate(void *buf, hid_t type_id, const H5S_t *space, H5D_operator_t op, void *operator_data); H5_DLL herr_t H5S_select_fill(void *fill, size_t fill_size, const H5S_t *space, void *buf); H5_DLL htri_t H5S_select_valid(const H5S_t *space); H5_DLL hssize_t H5S_get_select_npoints(const H5S_t *space); H5_DLL herr_t H5S_get_select_bounds(const H5S_t *space, hsize_t *start, hsize_t *end); H5_DLL herr_t H5S_select_offset(H5S_t *space, const hssize_t *offset); H5_DLL herr_t H5S_select_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection); H5_DLL htri_t H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2); H5_DLL herr_t H5S_select_release(H5S_t *ds); H5_DLL herr_t H5S_select_get_seq_list(const H5S_t *space, unsigned flags, H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes, size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len); H5_DLL hssize_t H5S_select_serial_size(const H5S_t *space); H5_DLL herr_t H5S_select_serialize(const H5S_t *space, uint8_t *buf); H5_DLL htri_t H5S_select_is_contiguous(const H5S_t *space); H5_DLL htri_t H5S_select_is_single(const H5S_t *space); H5_DLL htri_t H5S_select_is_regular(const H5S_t *space); /* Operations on all selections */ H5_DLL herr_t H5S_select_all(H5S_t *space, unsigned rel_prev); /* Operations on none selections */ H5_DLL herr_t H5S_select_none(H5S_t *space); /* Operations on point selections */ H5_DLL herr_t H5S_select_elements (H5S_t *space, H5S_seloper_t op, size_t num_elem, const hsize_t **coord); /* Operations on hyperslab selections */ H5_DLL herr_t H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op, const hsize_t start[], const hsize_t *stride, const hsize_t count[], const hsize_t *block); H5_DLL herr_t H5S_hyper_add_span_element(H5S_t *space, unsigned rank, hsize_t *coords); H5_DLL herr_t H5S_hyper_reset_scratch(H5S_t *space); H5_DLL herr_t H5S_hyper_convert(H5S_t *space); #ifdef LATER H5_DLL htri_t H5S_hyper_intersect (H5S_t *space1, H5S_t *space2); #endif /* LATER */ H5_DLL htri_t H5S_hyper_intersect_block (H5S_t *space, hsize_t *start, hsize_t *end); H5_DLL herr_t H5S_hyper_adjust_u(H5S_t *space, const hsize_t *offset); H5_DLL herr_t H5S_hyper_adjust_s(H5S_t *space, const hssize_t *offset); H5_DLL herr_t H5S_hyper_move(H5S_t *space, const hssize_t *offset); H5_DLL herr_t H5S_hyper_normalize_offset(H5S_t *space, hssize_t *old_offset); H5_DLL herr_t H5S_hyper_denormalize_offset(H5S_t *space, const hssize_t *old_offset); /* Operations on selection iterators */ H5_DLL herr_t H5S_select_iter_init(H5S_sel_iter_t *iter, const H5S_t *space, size_t elmt_size); H5_DLL herr_t H5S_select_iter_coords(const H5S_sel_iter_t *sel_iter, hsize_t *coords); H5_DLL hsize_t H5S_select_iter_nelmts(const H5S_sel_iter_t *sel_iter); H5_DLL herr_t H5S_select_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem); H5_DLL herr_t H5S_select_iter_release(H5S_sel_iter_t *sel_iter); #ifdef H5_HAVE_PARALLEL #ifndef _H5S_IN_H5S_C /* Global vars whose value comes from environment variable */ /* (Defined in H5S.c) */ H5_DLLVAR hbool_t H5S_mpi_opt_types_g; #endif /* _H5S_IN_H5S_C */ H5_DLL herr_t H5S_mpio_space_type( const H5S_t *space, size_t elmt_size, /* out: */ MPI_Datatype *new_type, size_t *count, hsize_t *extra_offset, hbool_t *is_derived_type ); H5_DLL herr_t H5S_mpio_space_span_type( const H5S_t *space, size_t elmt_size, /* out: */ MPI_Datatype *new_type, size_t *count, hsize_t *extra_offset, hbool_t *is_derived_type ); #endif /* H5_HAVE_PARALLEL */ #endif /* _H5Sprivate_H */ xdmf-3.0+git20160803/Utilities/hdf5/H5Onull.c0000640000175000017500000000462613003006557020335 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*------------------------------------------------------------------------- * * Created: H5Onull.c * Aug 6 1997 * Robb Matzke * * Purpose: The null message. * * Modifications: * *------------------------------------------------------------------------- */ #define H5O_PACKAGE /*suppress error about including H5Opkg */ #include "H5private.h" #include "H5Opkg.h" /* Object header functions */ /* This message derives from H5O */ const H5O_class_t H5O_NULL[1] = {{ H5O_NULL_ID, /*message id number */ "null", /*message name for debugging */ 0, /*native message size */ NULL, /*no decode method */ NULL, /*no encode method */ NULL, /*no copy method */ NULL, /*no size method */ NULL, /*no reset method */ NULL, /*no free method */ NULL, /*no file delete method */ NULL, /*no link method */ NULL, /*no get share method */ NULL, /*no set share method */ NULL, /*no debug method */ }}; xdmf-3.0+git20160803/Utilities/hdf5/H5FDmpio.h0000640000175000017500000000413613003006557020423 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Robb Matzke * Monday, August 2, 1999 * * Purpose: The public header file for the mpio driver. */ #ifndef H5FDmpio_H #define H5FDmpio_H #ifdef H5_HAVE_PARALLEL # define H5FD_MPIO (H5FD_mpio_init()) #else # define H5FD_MPIO (-1) #endif /* H5_HAVE_PARALLEL */ /* Macros */ #define IS_H5FD_MPIO(f) /* (H5F_t *f) */ \ (H5FD_MPIO==H5F_get_driver_id(f)) #ifdef H5_HAVE_PARALLEL /*Turn on H5FDmpio_debug if H5F_DEBUG is on */ #ifdef H5F_DEBUG #ifndef H5FDmpio_DEBUG #define H5FDmpio_DEBUG #endif #endif /* Function prototypes */ #ifdef __cplusplus extern "C" { #endif H5_DLL hid_t H5FD_mpio_init(void); H5_DLL void H5FD_mpio_term(void); H5_DLL herr_t H5Pset_fapl_mpio(hid_t fapl_id, MPI_Comm comm, MPI_Info info); H5_DLL herr_t H5Pget_fapl_mpio(hid_t fapl_id, MPI_Comm *comm/*out*/, MPI_Info *info/*out*/); H5_DLL herr_t H5Pset_dxpl_mpio(hid_t dxpl_id, H5FD_mpio_xfer_t xfer_mode); H5_DLL herr_t H5Pget_dxpl_mpio(hid_t dxpl_id, H5FD_mpio_xfer_t *xfer_mode/*out*/); #ifdef __cplusplus } #endif #endif /* H5_HAVE_PARALLEL */ #endif xdmf-3.0+git20160803/Utilities/hdf5/H5Ipublic.h0000640000175000017500000000571213003006557020635 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * This file contains function prototypes for each exported function in * the H5I module. */ #ifndef _H5Ipublic_H #define _H5Ipublic_H /* Public headers needed by this file */ #include "H5public.h" /* * Group values allowed. Start with `1' instead of `0' because it makes the * tracing output look better when hid_t values are large numbers. Change the * GROUP_BITS in H5I.c if the MAXID gets larger than 32 (an assertion will * fail otherwise). * * When adding groups here, add a section to the 'misc19' test in test/tmisc.c * to verify that the H5I{inc|dec|get}_ref() routines work correctly with in. * */ typedef enum { H5I_BADID = (-1), /*invalid Group */ H5I_FILE = 1, /*group ID for File objects */ H5I_GROUP, /*group ID for Group objects */ H5I_DATATYPE, /*group ID for Datatype objects */ H5I_DATASPACE, /*group ID for Dataspace objects */ H5I_DATASET, /*group ID for Dataset objects */ H5I_ATTR, /*group ID for Attribute objects */ H5I_REFERENCE, /*group ID for Reference objects */ H5I_VFL, /*group ID for virtual file layer */ H5I_GENPROP_CLS, /*group ID for generic property list classes */ H5I_GENPROP_LST, /*group ID for generic property lists */ H5I_NGROUPS /*number of valid groups, MUST BE LAST! */ } H5I_type_t; /* Type of atoms to return to users */ typedef int hid_t; /* An invalid object ID. This is also negative for error return. */ #define H5I_INVALID_HID (-1) #ifdef __cplusplus extern "C" { #endif /* Public API functions */ H5_DLL H5I_type_t H5Iget_type(hid_t id); H5_DLL hid_t H5Iget_file_id(hid_t id); H5_DLL ssize_t H5Iget_name(hid_t id, char *name/*out*/, size_t size); H5_DLL int H5Iinc_ref(hid_t id); H5_DLL int H5Idec_ref(hid_t id); H5_DLL int H5Iget_ref(hid_t id); #ifdef __cplusplus } #endif #endif xdmf-3.0+git20160803/Utilities/hdf5/H5STprivate.h0000640000175000017500000000542013003006557021163 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * This file contains private information about the H5ST module */ #ifndef _H5STprivate_H #define _H5STprivate_H #ifdef LATER #include "H5STpublic.h" #endif /* LATER */ /* Private headers needed by this file */ #include "H5private.h" /* Typedefs */ /* Internal nodes for TST */ typedef struct H5ST_node *H5ST_ptr_t; typedef struct H5ST_node { char splitchar; /* Character represented at node */ H5ST_ptr_t up; /* Pointer to the node in the tree above (before) this node */ H5ST_ptr_t parent; /* Pointer to the next higher tree node in this tree */ H5ST_ptr_t lokid; /* Pointer to the lower node from this one, in this tree */ H5ST_ptr_t eqkid; /* Pointer to the parent node in the next tree down (after) this node */ H5ST_ptr_t hikid; /* Pointer to the higher node from this one, in this tree */ } H5ST_node_t; /* Wrapper about TST */ typedef struct { H5ST_ptr_t root; /* Pointer to actual TST */ } H5ST_tree_t; /* Macro to access "data" pointer in H5ST_node_t's returned from functions */ #define H5ST_NODE_DATA(p) ((void *)(p->eqkid)) /* Private routines */ H5_DLL H5ST_tree_t *H5ST_create(void); H5_DLL herr_t H5ST_close(H5ST_tree_t *p); H5_DLL herr_t H5ST_insert(H5ST_tree_t *root, const char *s, void *obj); H5_DLL htri_t H5ST_search(H5ST_tree_t *root, const char *s); H5_DLL H5ST_ptr_t H5ST_find(H5ST_tree_t *root, const char *s); H5_DLL void *H5ST_locate(H5ST_tree_t *root, const char *s); H5_DLL H5ST_ptr_t H5ST_findfirst(H5ST_tree_t *p); H5_DLL H5ST_ptr_t H5ST_findnext(H5ST_ptr_t p); H5_DLL void *H5ST_remove(H5ST_tree_t *root, const char *s); H5_DLL herr_t H5ST_delete(H5ST_tree_t *root, H5ST_ptr_t p); H5_DLL herr_t H5ST_dump(H5ST_ptr_t p); #endif /* _H5STprivate_H */ xdmf-3.0+git20160803/Utilities/hdf5/H5I.c0000640000175000017500000013424513003006557017435 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * FILE: H5I.c - Internal storage routines for handling "IDs" * * REMARKS: ID's which allow objects (void *'s currently) to be bundled * into "groups" for more general storage. * * DESIGN: The groups are stored in an array of pointers to store each * group in an element. Each "group" node contains a link to a * hash table to manage the IDs in each group. The allowed * "groups" are stored in an enum (called group_t) in * H5Ipublic.h. * * AUTHOR: Quincey Koziol * * MODIFICATIONS: * 1/3/96 - Starting writing specs & coding prototype * 1/7/96 - Finished coding prototype * 6/10/97 - Moved into HDF5 library */ #define H5I_PACKAGE /*suppress error about including H5Ipkg */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5I_init_interface #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free Lists */ #include "H5Ipkg.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ /* Define this to compile in support for dumping ID information */ /* #define H5I_DEBUG_OUTPUT */ #ifndef H5I_DEBUG_OUTPUT #include "H5Gprivate.h" /* Groups */ #else /* H5I_DEBUG_OUTPUT */ #define H5G_PACKAGE /*suppress error message about including H5Gpkg.h */ #include "H5Gpkg.h" /* Groups */ #include "H5Dprivate.h" /* Datasets */ #include "H5Tprivate.h" /* Datatypes */ #endif /* H5I_DEBUG_OUTPUT */ /* Local Macros */ /* * Define the following macro for fast hash calculations (but limited * hash sizes) */ #define HASH_SIZE_POWER_2 #ifdef HASH_SIZE_POWER_2 /* * Map an ID to a hash location (assumes s is a power of 2 and smaller * than the ID_MASK constant). */ # define H5I_LOC(a,s) ((hid_t)((size_t)(a)&((s)-1))) # define POWER_OF_TWO(n) ((((n) - 1) & (n)) == 0 && (n) > 0) #else /* * Map an ID to a hash location. */ # define H5I_LOC(a,s) (((hid_t)(a)&ID_MASK)%(s)) #endif /* Combine a Group number and an atom index into an atom */ #define H5I_MAKE(g,i) ((((hid_t)(g)&GROUP_MASK)<id_list) n++; } /* If no groups are used then clean up */ if (0==n) { for (grp=(H5I_type_t)0; grp= H5I_NGROUPS) && hash_size > 0) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid group number"); #ifdef HASH_SIZE_POWER_2 if (!POWER_OF_TWO(hash_size) || hash_size == 1) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid hash size"); #endif /* HASH_SIZE_POWER_2 */ if (H5I_id_group_list_g[grp] == NULL) { /* Allocate the group information for new group */ if (NULL==(grp_ptr = H5MM_calloc(sizeof(H5I_id_group_t)))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); H5I_id_group_list_g[grp] = grp_ptr; } else { /* Get the pointer to the existing group */ grp_ptr = H5I_id_group_list_g[grp]; } if (grp_ptr->count == 0) { /* Initialize the ID group structure for new groups */ grp_ptr->hash_size = hash_size; grp_ptr->reserved = reserved; grp_ptr->wrapped = 0; grp_ptr->ids = 0; grp_ptr->nextid = reserved; grp_ptr->free_func = free_func; grp_ptr->id_list = H5MM_calloc(hash_size*sizeof(H5I_id_info_t *)); if (NULL==grp_ptr->id_list) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } /* Increment the count of the times this group has been initialized */ grp_ptr->count++; done: if (ret_value<0) { /* Error condition cleanup */ if (grp_ptr != NULL) { H5MM_xfree(grp_ptr->id_list); H5MM_xfree(grp_ptr); } } FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5I_nmembers * * Purpose: Returns the number of members in a group. * * Return: Success: Number of members; zero if the group is empty * or has been deleted. * * Failure: Negative * * Programmer: Robb Matzke * Wednesday, March 24, 1999 * * Modifications: * *------------------------------------------------------------------------- */ int H5I_nmembers(H5I_type_t grp) { H5I_id_group_t *grp_ptr = NULL; int ret_value; FUNC_ENTER_NOAPI(H5I_nmembers, FAIL); if (grp<=H5I_BADID || grp>=H5I_NGROUPS) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid group number"); if (NULL==(grp_ptr=H5I_id_group_list_g[grp]) || grp_ptr->count<=0) HGOTO_DONE(0); /* Set return value */ H5_ASSIGN_OVERFLOW(ret_value, grp_ptr->ids, unsigned, int); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5I_clear_group * * Purpose: Removes all objects from the group, calling the free * function for each object regardless of the reference count. * * Return: Success: Non-negative * * Failure: negative * * Programmer: Robb Matzke * Wednesday, March 24, 1999 * * Modifications: * Robb Matzke, 1999-04-27 * If FORCE is zero then any item for which the free callback * failed is not removed. This function returns failure if * items could not be removed. * * Robb Matzke, 1999-08-17 * If the object reference count is larger than one then it must * be because the library is using the object internally. This * happens for instance for file driver ID's which are stored in * things like property lists, files, etc. Objects that have a * reference count larger than one are not affected unless FORCE * is non-zero. *------------------------------------------------------------------------- */ herr_t H5I_clear_group(H5I_type_t grp, hbool_t force) { H5I_id_group_t *grp_ptr = NULL; /* ptr to the atomic group */ H5I_id_info_t *cur=NULL; /* Current node being worked with */ H5I_id_info_t *next=NULL; /* Next node in list */ H5I_id_info_t *last=NULL; /* Last node seen */ H5I_id_info_t *tmp=NULL; /* Temporary node ptr */ int ret_value = SUCCEED; unsigned delete_node; /* Flag to indicate node should be removed from linked list */ unsigned i; FUNC_ENTER_NOAPI(H5I_clear_group, FAIL); if (grp <= H5I_BADID || grp >= H5I_NGROUPS) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid group number"); grp_ptr = H5I_id_group_list_g[grp]; if (grp_ptr == NULL || grp_ptr->count <= 0) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid group"); /* * Call free method for all objects in group regardless of their reference * counts. Ignore the return value from from the free method and remove * object from group regardless if FORCE is non-zero. */ for (i=0; ihash_size; i++) { for (cur=grp_ptr->id_list[i]; cur; cur=next) { /* * Do nothing to the object if the reference count is larger than * one and forcing is off. */ if (!force && cur->count>1) { next=cur->next; continue; } /* end if */ /* Check for a 'free' function and call it, if it exists */ if (grp_ptr->free_func && (grp_ptr->free_func)(cur->obj_ptr)<0) { if (force) { #ifdef H5I_DEBUG if (H5DEBUG(I)) { fprintf(H5DEBUG(I), "H5I: free grp=%d obj=0x%08lx " "failure ignored\n", (int)grp, (unsigned long)(cur->obj_ptr)); } /* end if */ #endif /*H5I_DEBUG*/ /* Indicate node should be removed from list */ delete_node=1; } /* end if */ else { /* Indicate node should _NOT_ be remove from list */ delete_node=0; } /* end else */ } /* end if */ else { /* Indicate node should be removed from list */ delete_node=1; } /* end else */ /* Check if we should delete this node or not */ if(delete_node) { /* Decrement the number of IDs in the group */ (grp_ptr->ids)--; /* Advance to next node */ next = cur->next; /* Re-scan the list of nodes and remove the node from the list */ /* (can't maintain static pointers to the previous node in the */ /* list, because the node's 'free' callback could have */ /* make an H5I call, which could potentially change the */ /* order of the nodes on the list - QAK) */ last=NULL; tmp=grp_ptr->id_list[i]; while(tmp!=cur) { assert(tmp!=NULL); last=tmp; tmp=tmp->next; } /* end while */ /* Delete the node from the list */ if(last==NULL) { /* Node at head of list, just advance the list head to next node */ assert(grp_ptr->id_list[i]==cur); grp_ptr->id_list[i] = next; } /* end if */ else { /* Node in middle of list, jump over it */ assert(last->next==cur); last->next=next; } /* end else */ /* Free the node */ H5FL_FREE(H5I_id_info_t,cur); } /* end if */ else { /* Advance to next node */ next = cur->next; } /* end else */ } /* end for */ } /* end for */ done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5I_destroy_group * * Purpose: Decrements the reference count on an entire group of IDs. * If the group reference count becomes zero then the group is * destroyed along with all atoms in that group regardless of * their reference counts. Destroying IDs involves calling * the free-func for each ID's object and then adding the ID * struct to the ID free list. * * Return: Non-negative on success/Negative on failure * * Programmer: Unknown * * Modifications: * * Robb Matzke, 25 Feb 1998 * IDs are freed when a group is destroyed. * *------------------------------------------------------------------------- */ herr_t H5I_destroy_group(H5I_type_t grp) { H5I_id_group_t *grp_ptr = NULL; /* ptr to the atomic group */ int ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5I_destroy_group, FAIL); if (grp <= H5I_BADID || grp >= H5I_NGROUPS) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid group number"); grp_ptr = H5I_id_group_list_g[grp]; if (grp_ptr == NULL || grp_ptr->count <= 0) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid group"); /* * Decrement the number of users of the atomic group. If this is the * last user of the group then release all atoms from the group. The * free function is invoked for each atom being freed. */ if (1==grp_ptr->count) { H5I_clear_group(grp, TRUE); H5E_clear(); /*don't care about errors*/ H5MM_xfree(grp_ptr->id_list); HDmemset (grp_ptr, 0, sizeof(*grp_ptr)); } else { --(grp_ptr->count); } done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5I_register * * Purpose: Registers an OBJECT in a GROUP and returns an ID for it. * This routine does _not_ check for unique-ness of the objects, * if you register an object twice, you will get two different * IDs for it. This routine does make certain that each ID in a * group is unique. IDs are created by getting a unique number * for the group the ID is in and incorporating the group into * the ID which is returned to the user. * * Return: Success: New object id. * * Failure: Negative * * Programmer: Unknown * * Modifications: * *------------------------------------------------------------------------- */ hid_t H5I_register(H5I_type_t grp, void *object) { H5I_id_group_t *grp_ptr=NULL; /*ptr to the group */ H5I_id_info_t *id_ptr=NULL; /*ptr to the new ID information */ hid_t new_id; /*new ID */ unsigned hash_loc; /*new item's hash table location*/ hid_t next_id; /*next ID to check */ hid_t ret_value=SUCCEED; /*return value */ H5I_id_info_t *curr_id; /*ptr to the current atom */ unsigned i; /*counter */ FUNC_ENTER_NOAPI(H5I_register, FAIL); /* Check arguments */ if (grp <= H5I_BADID || grp >= H5I_NGROUPS) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid group number"); grp_ptr = H5I_id_group_list_g[grp]; if (grp_ptr == NULL || grp_ptr->count <= 0) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid group"); if ((id_ptr = H5FL_MALLOC(H5I_id_info_t)) == NULL) HGOTO_ERROR(H5E_ATOM, H5E_NOSPACE, FAIL, "memory allocation failed"); /* Create the struct & it's ID */ new_id = H5I_MAKE(grp, grp_ptr->nextid); id_ptr->id = new_id; id_ptr->count = 1; /*initial reference count*/ id_ptr->obj_ptr = object; id_ptr->next = NULL; /* hash bucket already full, prepend to front of chain */ hash_loc = grp_ptr->nextid % (unsigned) grp_ptr->hash_size; if (grp_ptr->id_list[hash_loc] != NULL) id_ptr->next = grp_ptr->id_list[hash_loc]; /* Insert into the group */ grp_ptr->id_list[hash_loc] = id_ptr; grp_ptr->ids++; grp_ptr->nextid++; /* * This next section of code checks for the 'nextid' getting too large and * wrapping around, thus necessitating checking for duplicate IDs being * handed out. */ if (grp_ptr->nextid > (unsigned)ID_MASK) { grp_ptr->wrapped = 1; grp_ptr->nextid = grp_ptr->reserved; } /* * If we've wrapped around then we need to check for duplicate id's being * handed out. */ if (grp_ptr->wrapped) { /* * Make sure we check all available ID's. If we're about at the end * of the range then wrap around and check the beginning values. If * we check all possible values and didn't find any free ones *then* * we can fail. */ for (i=grp_ptr->reserved; inextid>(unsigned)ID_MASK) grp_ptr->nextid = grp_ptr->reserved; /* new ID to check for */ next_id = H5I_MAKE(grp, grp_ptr->nextid); hash_loc = H5I_LOC (grp_ptr->nextid, grp_ptr->hash_size); curr_id = grp_ptr->id_list[hash_loc]; if (curr_id == NULL) break; /* Ha! this is not likely... */ while (curr_id) { if (curr_id->id == next_id) break; curr_id = curr_id->next; } if (!curr_id) break; /* must not have found a match */ grp_ptr->nextid++; } if (i>=(unsigned)ID_MASK) /* All the IDs are gone! */ HGOTO_ERROR(H5E_ATOM, H5E_NOIDS, FAIL, "no IDs available in group"); } ret_value = new_id; done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5I_object * * Purpose: Find an object pointer for the specified ID. * * Return: Success: Non-null object pointer associated with the * specified ID. * * Failure: NULL * * Programmer: * * Modifications: * *------------------------------------------------------------------------- */ void * H5I_object(hid_t id) { H5I_id_info_t *id_ptr = NULL; /*ptr to the new atom */ void *ret_value = NULL; /*return value */ FUNC_ENTER_NOAPI(H5I_object, NULL); /* General lookup of the ID */ if (NULL!=(id_ptr = H5I_find_id(id))) { /* Get the object pointer to return */ ret_value = id_ptr->obj_ptr; } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5I_object_verify * * Purpose: Find an object pointer for the specified ID, verifying that * its in a particular group. * * Return: Success: Non-null object pointer associated with the * specified ID. * * Failure: NULL * * Programmer: Quincey Koziol * Wednesday, July 31, 2002 * * Modifications: * *------------------------------------------------------------------------- */ void * H5I_object_verify(hid_t id, H5I_type_t id_type) { H5I_id_info_t *id_ptr = NULL; /*ptr to the new atom */ void *ret_value = NULL; /*return value */ FUNC_ENTER_NOAPI(H5I_object_verify, NULL); assert(id_type>=H5I_FILE && id_typeobj_ptr; } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value); } /* H5I_object_verify() */ /*------------------------------------------------------------------------- * Function: H5I_get_type * * Purpose: Given an object ID return the group (type) to which it * belongs. The ID need not be the ID of an object which * currently exists because the group number (type) is encoded * in the object ID. * * Return: Success: A valid group number (type) * * Failure: H5I_BADID, a negative value. * * Programmer: Robb Matzke * Friday, February 19, 1999 * * Modifications: * *------------------------------------------------------------------------- */ H5I_type_t H5I_get_type(hid_t id) { H5I_type_t ret_value = H5I_BADID; FUNC_ENTER_NOAPI(H5I_get_type, H5I_BADID); if (id>0) ret_value = H5I_GROUP(id); assert(ret_value>=H5I_BADID && ret_value= H5I_NGROUPS || NULL==H5I_object(id)) HGOTO_DONE(H5I_BADID); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5I_remove * * Purpose: Removes the specified ID from its group. * * Return: Success: A pointer to the object that was removed, the * same pointer which would have been found by * calling H5I_object(). * * Failure: NULL * * Programmer: * * Modifications: * *------------------------------------------------------------------------- */ void * H5I_remove(hid_t id) { H5I_id_group_t *grp_ptr = NULL;/*ptr to the atomic group */ H5I_id_info_t *curr_id; /*ptr to the current atom */ H5I_id_info_t *last_id; /*ptr to the last atom */ H5I_type_t grp; /*atom's atomic group */ unsigned hash_loc; /*atom's hash table location */ void * ret_value = NULL; /*return value */ FUNC_ENTER_NOAPI(H5I_remove, NULL); /* Check arguments */ grp = H5I_GROUP(id); if (grp <= H5I_BADID || grp >= H5I_NGROUPS) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "invalid group number"); grp_ptr = H5I_id_group_list_g[grp]; if (grp_ptr == NULL || grp_ptr->count <= 0) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "invalid group"); /* Get the bucket in which the ID is located */ hash_loc = (unsigned) H5I_LOC(id, grp_ptr->hash_size); curr_id = grp_ptr->id_list[hash_loc]; if (curr_id == NULL) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "invalid ID"); last_id = NULL; while (curr_id != NULL) { if (curr_id->id == id) break; last_id = curr_id; curr_id = curr_id->next; } if (curr_id != NULL) { if (last_id == NULL) { /* ID is the first in the chain */ grp_ptr->id_list[hash_loc] = curr_id->next; } else { last_id->next = curr_id->next; } ret_value = curr_id->obj_ptr; H5FL_FREE(H5I_id_info_t,curr_id); } else { /* couldn't find the ID in the proper place */ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "invalid ID"); } /* Decrement the number of IDs in the group */ (grp_ptr->ids)--; done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5Idec_ref * * Purpose: Decrements the number of references outstanding for an ID. * If the reference count for an ID reaches zero, the object * will be closed. * * Return: Success: New reference count * Failure: Negative * * Programmer: Quincey Koziol * Dec 7, 2003 * * Modifications: * *------------------------------------------------------------------------- */ int H5Idec_ref(hid_t id) { int ret_value; /* Return value */ FUNC_ENTER_API(H5Idec_ref, FAIL); H5TRACE1("Is","i",id); /* Check arguments */ if (id<0) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID"); /* Do actual decrement operation */ if((ret_value = H5I_dec_ref(id))<0) HGOTO_ERROR (H5E_ATOM, H5E_CANTDEC, FAIL, "can't decrement ID ref count"); done: FUNC_LEAVE_API(ret_value); } /* end H5Idec_ref() */ /*------------------------------------------------------------------------- * Function: H5I_dec_ref * * Purpose: Decrements the number of references outstanding for an ID. * This will fail if the group is not a reference counted group. * The ID group's 'free' function will be called for the ID * if the reference count for the ID reaches 0 and a free * function has been defined at group creation time. * * Return: Success: New reference count. * * Failure: Negative * * Programmer: Unknown * * Modifications: * * Robb Matzke, 19 Feb 1998 * It is no longer an error when the reference count of an item reaches * zero and no `free' function has been defined. The object is still * removed from the list. * * Robb Matzke, 30 Dec 1998 * Fixed a bug where the return value was always zero instead of the new * reference count. * * Robb Matzke, 19 Feb 1999 * If the free method is defined and fails then the object is not * removed from the group and its reference count is not decremented. * The group number is now passed to the free method. * * Raymond, 11 Dec 2001 * If the freeing function fails, return failure instead of reference * count 1. This feature is needed by file close with H5F_CLOSE_SEMI * value. * *------------------------------------------------------------------------- */ int H5I_dec_ref(hid_t id) { H5I_type_t grp; /*group the object is in*/ H5I_id_group_t *grp_ptr; /*ptr to the group */ H5I_id_info_t *id_ptr; /*ptr to the new ID */ int ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5I_dec_ref, FAIL); /* Sanity check */ assert(id>=0); /* Check arguments */ grp = H5I_GROUP(id); if (grp <= H5I_BADID || grp >= H5I_NGROUPS) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid group number"); grp_ptr = H5I_id_group_list_g[grp]; if (grp_ptr == NULL || grp_ptr->count <= 0) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid group number"); /* General lookup of the ID */ if ((id_ptr=H5I_find_id(id))==NULL) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't locate ID"); /* * If this is the last reference to the object then invoke the group's * free method on the object. If the free method is undefined or * successful then remove the object from the group; otherwise leave * the object in the group without decrementing the reference * count. If the reference count is more than one then decrement the * reference count without calling the free method. * * Beware: the free method may call other H5I functions. */ if (1==id_ptr->count) { if (!grp_ptr->free_func || (grp_ptr->free_func)(id_ptr->obj_ptr)>=0) { H5I_remove(id); ret_value = 0; } else { ret_value = FAIL; } } else { ret_value = --(id_ptr->count); } done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5Iinc_ref * * Purpose: Increments the number of references outstanding for an ID. * * Return: Success: New reference count * Failure: Negative * * Programmer: Quincey Koziol * Dec 7, 2003 * * Modifications: * *------------------------------------------------------------------------- */ int H5Iinc_ref(hid_t id) { int ret_value; /* Return value */ FUNC_ENTER_API(H5Iinc_ref, FAIL); H5TRACE1("Is","i",id); /* Check arguments */ if (id<0) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID"); /* Do actual increment operation */ if((ret_value = H5I_inc_ref(id))<0) HGOTO_ERROR (H5E_ATOM, H5E_CANTINC, FAIL, "can't increment ID ref count"); done: FUNC_LEAVE_API(ret_value); } /* end H5Iinc_ref() */ /*------------------------------------------------------------------------- * Function: H5I_inc_ref * * Purpose: Increment the reference count for an object. * * Return: Success: The new reference count. * * Failure: Negative * * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: * *------------------------------------------------------------------------- */ int H5I_inc_ref(hid_t id) { H5I_type_t grp; /*group the object is in*/ H5I_id_group_t *grp_ptr; /*ptr to the group */ H5I_id_info_t *id_ptr; /*ptr to the ID */ int ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5I_inc_ref, FAIL); /* Sanity check */ assert(id>=0); /* Check arguments */ grp = H5I_GROUP(id); if (grp <= H5I_BADID || grp >= H5I_NGROUPS) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid group number"); grp_ptr = H5I_id_group_list_g[grp]; if (!grp_ptr || grp_ptr->count<=0) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid group"); /* General lookup of the ID */ if (NULL==(id_ptr=H5I_find_id(id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't locate ID"); /* Set return value */ ret_value=++(id_ptr->count); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5Iget_ref * * Purpose: Retrieves the number of references outstanding for an ID. * * Return: Success: Reference count * Failure: Negative * * Programmer: Quincey Koziol * Dec 7, 2003 * * Modifications: * *------------------------------------------------------------------------- */ int H5Iget_ref(hid_t id) { int ret_value; /* Return value */ FUNC_ENTER_API(H5Iget_ref, FAIL); H5TRACE1("Is","i",id); /* Check arguments */ if (id<0) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID"); /* Do actual retrieve operation */ if((ret_value = H5I_get_ref(id))<0) HGOTO_ERROR (H5E_ATOM, H5E_CANTGET, FAIL, "can't get ID ref count"); done: FUNC_LEAVE_API(ret_value); } /* end H5Iget_ref() */ /*------------------------------------------------------------------------- * Function: H5I_get_ref * * Purpose: Retrieve the reference count for an object. * * Return: Success: The reference count. * * Failure: Negative * * Programmer: Quincey Koziol * Saturday, Decemeber 6, 2003 * * Modifications: * *------------------------------------------------------------------------- */ int H5I_get_ref(hid_t id) { H5I_type_t grp; /*group the object is in*/ H5I_id_group_t *grp_ptr; /*ptr to the group */ H5I_id_info_t *id_ptr; /*ptr to the ID */ int ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5I_get_ref, FAIL); /* Sanity check */ assert(id>=0); /* Check arguments */ grp = H5I_GROUP(id); if (grp <= H5I_BADID || grp >= H5I_NGROUPS) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid group number"); grp_ptr = H5I_id_group_list_g[grp]; if (!grp_ptr || grp_ptr->count<=0) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid group"); /* General lookup of the ID */ if (NULL==(id_ptr=H5I_find_id(id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't locate ID"); /* Set return value */ ret_value=id_ptr->count; done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5I_get_ref() */ /*------------------------------------------------------------------------- * Function: H5I_search * * Purpose: Apply function FUNC to each member of group GRP and return a * pointer to the first object for which FUNC returns non-zero. * The FUNC should take a pointer to the object and the KEY as * arguments and return non-zero to terminate the search (zero * to continue). * * Limitation: Currently there is no way to start searching from where a * previous search left off. * * Return: Success: The first object in the group for which FUNC * returns non-zero. NULL if FUNC returned zero * for every object in the group. * * Failure: NULL * * Programmer: Robb Matzke * Friday, February 19, 1999 * * Modifications: * *------------------------------------------------------------------------- */ void * H5I_search(H5I_type_t grp, H5I_search_func_t func, void *key) { H5I_id_group_t *grp_ptr = NULL; /*ptr to the group */ H5I_id_info_t *id_ptr = NULL; /*ptr to the new ID */ H5I_id_info_t *next_id = NULL; /*ptr to the next ID */ unsigned i; /*counter */ void *ret_value = NULL; /*return value */ FUNC_ENTER_NOAPI(H5I_search, NULL); /* Check arguments */ if (grp <= H5I_BADID || grp >= H5I_NGROUPS) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "invalid group number"); grp_ptr = H5I_id_group_list_g[grp]; if (grp_ptr == NULL || grp_ptr->count <= 0) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "invalid group"); /* Only iterate through hash table if there are IDs in group */ if(grp_ptr->ids > 0) { /* Start at the beginning of the array */ for (i=0; ihash_size; i++) { id_ptr = grp_ptr->id_list[i]; while (id_ptr) { next_id= id_ptr->next; /* Protect against ID being deleted in callback */ if ((*func)(id_ptr->obj_ptr, id_ptr->id, key)) HGOTO_DONE(id_ptr->obj_ptr); /*found the item*/ id_ptr = next_id; } /* end while */ } /* end for */ } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5I_search() */ /*------------------------------------------------------------------------- * Function: H5I_find_id * * Purpose: Given an object ID find the info struct that describes the * object. * * Return: Success: Ptr to the object's info struct. * * Failure: NULL * * Programmer: * * Modifications: * *------------------------------------------------------------------------- */ static H5I_id_info_t * H5I_find_id(hid_t id) { H5I_id_group_t *grp_ptr; /*ptr to the group */ H5I_id_info_t *last_id; /*ptr to the last ID */ H5I_id_info_t *id_ptr; /*ptr to the new ID */ H5I_type_t grp; /*ID's group */ unsigned hash_loc; /*bucket pointer */ H5I_id_info_t *ret_value = NULL; /*return value */ FUNC_ENTER_NOAPI_NOINIT(H5I_find_id); /* Check arguments */ grp = H5I_GROUP(id); if (grp <= H5I_BADID || grp >= H5I_NGROUPS) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "invalid group number"); grp_ptr = H5I_id_group_list_g[grp]; if (grp_ptr == NULL || grp_ptr->count <= 0) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "invalid group"); /* Get the bucket in which the ID is located */ hash_loc = (unsigned)H5I_LOC(id, grp_ptr->hash_size); id_ptr = grp_ptr->id_list[hash_loc]; if (id_ptr == NULL) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "invalid ID"); /* Scan the bucket's linked list for a match */ last_id=NULL; while (id_ptr) { if (id_ptr->id == id) break; last_id=id_ptr; id_ptr = id_ptr->next; } /* If we found an object, move it to the front of the list, if it isn't there already */ if(id_ptr!=NULL && last_id!=NULL) { last_id->next=id_ptr->next; id_ptr->next=grp_ptr->id_list[hash_loc]; grp_ptr->id_list[hash_loc]=id_ptr; } /* end if */ /* Set the return value */ ret_value = id_ptr; done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5Iget_name * * Purpose: Gets a name of an object from its ID. * * Return: Success: The length of name. * * Failure: -1 * * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu * * Date: July 26, 2002 * * Comments: Public function * If `name' is non-NULL then write up to `size' bytes into that * buffer and always return the length of the entry name. * Otherwise `size' is ignored and the function does not store the name, * just returning the number of characters required to store the name. * If an error occurs then the buffer pointed to by `name' (NULL or non-NULL) * is unchanged and the function returns a negative value. * If a zero is returned for the name's length, then there is no name * associated with the ID. * * Modifications: * *------------------------------------------------------------------------- */ ssize_t H5Iget_name(hid_t id, char *name/*out*/, size_t size) { H5G_entry_t *ent; /*symbol table entry */ size_t len=0; ssize_t ret_value; FUNC_ENTER_API (H5Iget_name, FAIL); H5TRACE3("Zs","ixz",id,name,size); /* get symbol table entry */ if(NULL!=(ent = H5G_loc(id))) { if (ent->user_path_r != NULL && ent->user_path_hidden==0) { len = H5RS_len(ent->user_path_r); if(name) { HDstrncpy(name, H5RS_get_str(ent->user_path_r), MIN(len+1,size)); if(len >= size) name[size-1]='\0'; } /* end if */ } /* end if */ } /* end if */ /* Set return value */ ret_value=(ssize_t)len; done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5I_debug * * Purpose: Dump the contents of a group to stderr for debugging. * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, February 19, 1999 * * Modifications: * * Pedro Vicente, 22 Aug 2002 * Added `id to name' support. * *------------------------------------------------------------------------- */ #ifdef H5I_DEBUG_OUTPUT static herr_t H5I_debug(H5I_type_t grp) { H5I_id_group_t *grp_ptr; H5I_id_info_t *cur; H5G_entry_t *ent = NULL; int is, js; unsigned int iu; herr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5I_debug, FAIL); fprintf(stderr, "Dumping group %d\n", (int)grp); grp_ptr = H5I_id_group_list_g[grp]; /* Header */ fprintf(stderr, " count = %u\n", grp_ptr->count); fprintf(stderr, " reserved = %u\n", grp_ptr->reserved); fprintf(stderr, " wrapped = %u\n", grp_ptr->wrapped); fprintf(stderr, " hash_size = %lu\n", (unsigned long)grp_ptr->hash_size); fprintf(stderr, " ids = %u\n", grp_ptr->ids); fprintf(stderr, " nextid = %u\n", grp_ptr->nextid); /* Cache */ fprintf(stderr, " Cache:\n"); for (is=0; isid)==grp) { fprintf(stderr, " Entry-%d, ID=%lu\n", is, (unsigned long)(H5I_cache_g[is]->id)); } } /* List */ fprintf(stderr, " List:\n"); for (iu=0; iuhash_size; iu++) { for (js=0, cur=grp_ptr->id_list[iu]; cur; cur=cur->next, js++) { fprintf(stderr, " #%u.%d\n", iu, js); fprintf(stderr, " id = %lu\n", (unsigned long)(cur->id)); fprintf(stderr, " count = %u\n", cur->count); fprintf(stderr, " obj = 0x%08lx\n", (unsigned long)(cur->obj_ptr)); /* Get the symbol table entry, so we get get the name */ switch(grp) { case H5I_GROUP: ent = H5G_entof((H5G_t*)cur->obj_ptr); break; case H5I_DATASET: ent = H5D_entof((H5D_t*)cur->obj_ptr); break; case H5I_DATATYPE: ent = H5T_entof((H5T_t*)cur->obj_ptr); break; default: continue; /* Other types of IDs are not stored in files */ } /* end switch*/ if(ent) { if(ent->name) fprintf(stderr, " name = %s\n",ent->name); if(ent->old_name) fprintf(stderr, " old_name = %s\n",ent->old_name); } /* end if */ } /* end for */ } /* end for */ done: FUNC_LEAVE_NOAPI(SUCCEED); } #endif /* H5I_DEBUG_OUTPUT */ /*------------------------------------------------------------------------- * Function: H5Iget_file_id * * Purpose: The public version of H5I_get_file_id(), obtains the file * ID given an object ID. User has to close this ID. * * Return: Success: file ID * * Failure: a negative value * * Programmer: Raymond Lu * Oct 27, 2003 * * Modifications: * *------------------------------------------------------------------------- */ hid_t H5Iget_file_id(hid_t obj_id) { hid_t ret_value; FUNC_ENTER_API(H5Iget_file_id, FAIL); H5TRACE1("i","i",obj_id); if((ret_value = H5I_get_file_id(obj_id))<0) HGOTO_ERROR (H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve file ID"); done: FUNC_LEAVE_API(ret_value); } /*------------------------------------------------------------------------- * Function: H5I_get_file_id * * Purpose: The private version of H5Iget_file_id(), obtains the file * ID given an object ID. * * Return: Success: file ID * * Failure: a negative value * * Programmer: Raymond Lu * Oct 27, 2003 * * Modifications: * *------------------------------------------------------------------------- */ static hid_t H5I_get_file_id(hid_t obj_id) { H5G_entry_t *ent; hid_t ret_value; FUNC_ENTER_NOAPI_NOINIT(H5I_get_file_id); /* Get object type */ switch(H5I_GROUP(obj_id)) { case H5I_FILE: ret_value = obj_id; /* Increment reference count on atom. */ if (H5I_inc_ref(ret_value)<0) HGOTO_ERROR (H5E_ATOM, H5E_CANTSET, FAIL, "incrementing file ID failed"); break; case H5I_DATATYPE: if((ent = H5G_loc(obj_id))==NULL) HGOTO_ERROR (H5E_ATOM, H5E_CANTGET, FAIL, "not a named datatype"); ret_value = H5F_get_id(ent->file); break; case H5I_GROUP: case H5I_DATASET: case H5I_ATTR: if((ent = H5G_loc(obj_id))==NULL) HGOTO_ERROR (H5E_ATOM, H5E_CANTGET, FAIL, "can't get symbol table info"); ret_value = H5F_get_id(ent->file); break; default: HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid object ID"); } done: FUNC_LEAVE_NOAPI(ret_value); } xdmf-3.0+git20160803/Utilities/hdf5/H5MMprivate.h0000640000175000017500000000372713003006557021156 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*------------------------------------------------------------------------- * * Created: H5MMprivate.h * Jul 10 1997 * Robb Matzke * * Purpose: Private header for memory management. * * Modifications: * *------------------------------------------------------------------------- */ #ifndef _H5MMprivate_H #define _H5MMprivate_H #include "H5MMpublic.h" /* Private headers needed by this file */ #include "H5private.h" #ifdef NDEBUG #define H5MM_malloc(Z) HDmalloc(Z) #define H5MM_calloc(Z) HDcalloc(1,Z) #endif /* NDEBUG */ #define H5MM_free(Z) HDfree(Z) /* * Library prototypes... */ #ifndef NDEBUG H5_DLL void *H5MM_malloc(size_t size); H5_DLL void *H5MM_calloc(size_t size); #endif /* NDEBUG */ H5_DLL void *H5MM_realloc(void *mem, size_t size); H5_DLL char *H5MM_xstrdup(const char *s); H5_DLL char *H5MM_strdup(const char *s); H5_DLL void *H5MM_xfree(void *mem); #endif xdmf-3.0+git20160803/Utilities/hdf5/H5FDprivate.h0000640000175000017500000000767013003006557021137 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Robb Matzke * Monday, July 26, 1999 */ #ifndef _H5FDprivate_H #define _H5FDprivate_H /* Include package's public header */ #include "H5FDpublic.h" /* Private headers needed by this file */ /* * The MPI drivers are needed because there are * places where we check for things that aren't handled by these drivers. */ #include "H5FDmpi.h" /* MPI-based file drivers */ /* Macros */ /* Forward declarations for prototype arguments */ struct H5P_genplist_t; /* Prototypes */ H5_DLL int H5FD_term_interface(void); H5_DLL H5FD_class_t *H5FD_get_class(hid_t id); H5_DLL hsize_t H5FD_sb_size(H5FD_t *file); H5_DLL herr_t H5FD_sb_encode(H5FD_t *file, char *name/*out*/, uint8_t *buf); H5_DLL herr_t H5FD_sb_decode(H5FD_t *file, const char *name, const uint8_t *buf); H5_DLL void *H5FD_fapl_get(H5FD_t *file); H5_DLL herr_t H5FD_fapl_open(struct H5P_genplist_t *plist, hid_t driver_id, const void *driver_info); H5_DLL herr_t H5FD_fapl_copy(hid_t driver_id, const void *fapl, void **copied_fapl); H5_DLL herr_t H5FD_fapl_close(hid_t driver_id, void *fapl); H5_DLL herr_t H5FD_dxpl_open(struct H5P_genplist_t *plist, hid_t driver_id, const void *driver_info); H5_DLL herr_t H5FD_dxpl_copy(hid_t driver_id, const void *dxpl, void **copied_dxpl); H5_DLL herr_t H5FD_dxpl_close(hid_t driver_id, void *dxpl); H5_DLL hid_t H5FD_register(const void *cls, size_t size); H5_DLL H5FD_t *H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); H5_DLL herr_t H5FD_close(H5FD_t *file); H5_DLL herr_t H5FD_free_freelist(H5FD_t *file); H5_DLL int H5FD_cmp(const H5FD_t *f1, const H5FD_t *f2); H5_DLL int H5FD_query(const H5FD_t *f, unsigned long *flags/*out*/); H5_DLL haddr_t H5FD_alloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size); H5_DLL herr_t H5FD_free(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size); H5_DLL haddr_t H5FD_realloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t old_addr, hsize_t old_size, hsize_t new_size); H5_DLL haddr_t H5FD_get_eoa(H5FD_t *file); H5_DLL herr_t H5FD_set_eoa(H5FD_t *file, haddr_t addr); H5_DLL haddr_t H5FD_get_eof(H5FD_t *file); H5_DLL herr_t H5FD_read(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, void *buf/*out*/); H5_DLL herr_t H5FD_write(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, const void *buf); H5_DLL herr_t H5FD_flush(H5FD_t *file, hid_t dxpl_id, unsigned closing); H5_DLL herr_t H5FD_get_fileno(const H5FD_t *file, unsigned long *filenum); H5_DLL herr_t H5FD_get_vfd_handle(H5FD_t *file, hid_t fapl, void** file_handle); H5_DLL hssize_t H5FD_get_freespace(const H5FD_t *file); H5_DLL htri_t H5FD_can_extend(H5FD_t *file, H5FD_mem_t type, haddr_t addr, hsize_t size, hsize_t extra_requested); H5_DLL herr_t H5FD_extend(H5FD_t *file, H5FD_mem_t type, haddr_t addr, hsize_t size, hsize_t extra_requested); #endif /* !_H5FDprivate_H */ xdmf-3.0+git20160803/Utilities/hdf5/H5Spkg.h0000640000175000017500000002665413003006557020162 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Quincey Koziol * Thursday, September 28, 2000 * * Purpose: This file contains declarations which are visible only within * the H5S package. Source files outside the H5S package should * include H5Sprivate.h instead. */ #ifndef H5S_PACKAGE #error "Do not include this file outside the H5S package!" #endif #ifndef _H5Spkg_H #define _H5Spkg_H #include "H5Sprivate.h" /* Number of reserved IDs in ID group */ #define H5S_RESERVED_ATOMS 2 /* Flags to indicate special dataspace features are active */ #define H5S_VALID_MAX 0x01 #define H5S_VALID_PERM 0x02 /* * Dataspace extent information */ /* Extent container */ typedef struct { H5S_class_t type; /* Type of extent */ hsize_t nelem; /* Number of elements in extent */ unsigned rank; /* Number of dimensions */ hsize_t *size; /* Current size of the dimensions */ hsize_t *max; /* Maximum size of the dimensions */ } H5S_extent_t; /* * Dataspace selection information */ /* Node in point selection list (typedef'd in H5Sprivate.h) */ struct H5S_pnt_node_t { hsize_t *pnt; /* Pointer to a selected point */ struct H5S_pnt_node_t *next; /* pointer to next point in list */ }; /* Information about point selection list */ typedef struct { H5S_pnt_node_t *head; /* Pointer to head of point list */ } H5S_pnt_list_t; /* Information about new-style hyperslab spans */ /* Information a particular hyperslab span */ struct H5S_hyper_span_t { hsize_t low, high; /* Low & high bounds of span */ hsize_t nelem; /* Number of elements in span (only needed during I/O) */ hsize_t pstride; /* Pseudo-stride from start of previous span (only used during I/O) */ struct H5S_hyper_span_info_t *down; /* Pointer to list of spans in next dimension down */ struct H5S_hyper_span_t *next; /* Pointer to next span in list */ }; /* Information about a list of hyperslab spans */ struct H5S_hyper_span_info_t { unsigned count; /* Ref. count of number of spans which share this span */ struct H5S_hyper_span_info_t *scratch; /* Scratch pointer * (used during copies, as mark * during precomputes for I/O & * to point to the last span in a * list during single element adds) */ struct H5S_hyper_span_t *head; /* Pointer to list of spans in next dimension down */ }; /* Information about new-style hyperslab selection */ typedef struct { hbool_t diminfo_valid; /* Whether the dataset has valid diminfo */ H5S_hyper_dim_t opt_diminfo[H5S_MAX_RANK]; /* per-dim selection info */ H5S_hyper_dim_t app_diminfo[H5S_MAX_RANK]; /* per-dim selection info */ /* 'opt_diminfo' points to a [potentially] optimized version of the user's * hyperslab information. 'app_diminfo' points to the actual parameters * that the application used for setting the hyperslab selection. These * are only used for re-gurgitating the original values used to set the * hyperslab to the application when it queries the hyperslab selection * information. */ H5S_hyper_span_info_t *span_lst; /* List of hyperslab span information */ } H5S_hyper_sel_t; /* Selection information methods */ /* Method to copy a selection */ typedef herr_t (*H5S_sel_copy_func_t)(H5S_t *dst, const H5S_t *src, hbool_t share_selection); /* Method to retrieve a list of offset/length sequences for selection */ typedef herr_t (*H5S_sel_get_seq_list_func_t)(const H5S_t *space, unsigned flags, H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes, size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len); /* Method to release current selection */ typedef herr_t (*H5S_sel_release_func_t)(H5S_t *space); /* Method to determine if current selection is valid for dataspace */ typedef htri_t (*H5S_sel_is_valid_func_t)(const H5S_t *space); /* Method to determine number of bytes required to store current selection */ typedef hssize_t (*H5S_sel_serial_size_func_t)(const H5S_t *space); /* Method to store current selection in "serialized" form (a byte sequence suitable for storing on disk) */ typedef herr_t (*H5S_sel_serialize_func_t)(const H5S_t *space, uint8_t *buf); /* Method to store create selection from "serialized" form (a byte sequence suitable for storing on disk) */ typedef herr_t (*H5S_sel_deserialize_func_t)(H5S_t *space, const uint8_t *buf); /* Method to determine to smallest n-D bounding box containing the current selection */ typedef herr_t (*H5S_sel_bounds_func_t)(const H5S_t *space, hsize_t *start, hsize_t *end); /* Method to determine if current selection is contiguous */ typedef htri_t (*H5S_sel_is_contiguous_func_t)(const H5S_t *space); /* Method to determine if current selection is a single block */ typedef htri_t (*H5S_sel_is_single_func_t)(const H5S_t *space); /* Method to determine if current selection is "regular" */ typedef htri_t (*H5S_sel_is_regular_func_t)(const H5S_t *space); /* Method to initialize iterator for current selection */ typedef herr_t (*H5S_sel_iter_init_func_t)(H5S_sel_iter_t *sel_iter, const H5S_t *space); /* Selection class information */ typedef struct { H5S_sel_type type; /* Type of selection (all, none, points or hyperslab) */ /* Methods */ H5S_sel_copy_func_t copy; /* Method to make a copy of a selection */ H5S_sel_get_seq_list_func_t get_seq_list; /* Method to retrieve a list of offset/length sequences for selection */ H5S_sel_release_func_t release; /* Method to release current selection */ H5S_sel_is_valid_func_t is_valid; /* Method to determine if current selection is valid for dataspace */ H5S_sel_serial_size_func_t serial_size; /* Method to determine number of bytes required to store current selection */ H5S_sel_serialize_func_t serialize; /* Method to store current selection in "serialized" form (a byte sequence suitable for storing on disk) */ H5S_sel_deserialize_func_t deserialize; /* Method to store create selection from "serialized" form (a byte sequence suitable for storing on disk) */ H5S_sel_bounds_func_t bounds; /* Method to determine to smallest n-D bounding box containing the current selection */ H5S_sel_is_contiguous_func_t is_contiguous; /* Method to determine if current selection is contiguous */ H5S_sel_is_single_func_t is_single; /* Method to determine if current selection is a single block */ H5S_sel_is_regular_func_t is_regular; /* Method to determine if current selection is "regular" */ H5S_sel_iter_init_func_t iter_init; /* Method to initialize iterator for current selection */ } H5S_select_class_t; /* Selection information object */ typedef struct { const H5S_select_class_t *type; /* Pointer to selection's class info */ hssize_t offset[H5S_MAX_RANK]; /* Offset within the extent */ hsize_t num_elem; /* Number of elements in selection */ union { H5S_pnt_list_t *pnt_lst; /* List of selected points (order is important) */ H5S_hyper_sel_t *hslab; /* Info about hyperslab selections */ } sel_info; } H5S_select_t; /* Main dataspace structure (typedef'd in H5Sprivate.h) */ struct H5S_t { H5S_extent_t extent; /* Dataspace extent */ H5S_select_t select; /* Dataspace selection */ }; /* Selection iteration methods */ /* Method to retrieve the current coordinates of iterator for current selection */ typedef herr_t (*H5S_sel_iter_coords_func_t)(const H5S_sel_iter_t *iter, hsize_t *coords); /* Method to retrieve the current block of iterator for current selection */ typedef herr_t (*H5S_sel_iter_block_func_t)(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end); /* Method to determine number of elements left in iterator for current selection */ typedef hsize_t (*H5S_sel_iter_nelmts_func_t)(const H5S_sel_iter_t *iter); /* Method to determine if there are more blocks left in the current selection */ typedef htri_t (*H5S_sel_iter_has_next_block_func_t)(const H5S_sel_iter_t *iter); /* Method to move selection iterator to the next element in the selection */ typedef herr_t (*H5S_sel_iter_next_func_t)(H5S_sel_iter_t *iter, size_t nelem); /* Method to move selection iterator to the next block in the selection */ typedef herr_t (*H5S_sel_iter_next_block_func_t)(H5S_sel_iter_t *iter); /* Method to release iterator for current selection */ typedef herr_t (*H5S_sel_iter_release_func_t)(H5S_sel_iter_t *iter); /* Selection iteration class */ typedef struct H5S_sel_iter_class_t { H5S_sel_type type; /* Type of selection (all, none, points or hyperslab) */ /* Methods on selections */ H5S_sel_iter_coords_func_t iter_coords; /* Method to retrieve the current coordinates of iterator for current selection */ H5S_sel_iter_block_func_t iter_block; /* Method to retrieve the current block of iterator for current selection */ H5S_sel_iter_nelmts_func_t iter_nelmts; /* Method to determine number of elements left in iterator for current selection */ H5S_sel_iter_has_next_block_func_t iter_has_next_block; /* Method to query if there is another block left in the selection */ H5S_sel_iter_next_func_t iter_next; /* Method to move selection iterator to the next element in the selection */ H5S_sel_iter_next_block_func_t iter_next_block; /* Method to move selection iterator to the next block in the selection */ H5S_sel_iter_release_func_t iter_release; /* Method to release iterator for current selection */ } H5S_sel_iter_class_t; /* * All selection class methods. */ H5_DLLVAR const H5S_select_class_t H5S_sel_all[1]; /* * Hyperslab selection class methods. */ H5_DLLVAR const H5S_select_class_t H5S_sel_hyper[1]; /* * None selection class methods. */ H5_DLLVAR const H5S_select_class_t H5S_sel_none[1]; /* * Pointer selection class methods. */ H5_DLLVAR const H5S_select_class_t H5S_sel_point[1]; /* Extent functions */ H5_DLL herr_t H5S_extent_release(H5S_extent_t *extent); H5_DLL herr_t H5S_extent_copy(H5S_extent_t *dst, const H5S_extent_t *src); /* Operations on selections */ /* Testing functions */ #ifdef H5S_TESTING H5_DLL htri_t H5S_select_shape_same_test(hid_t sid1, hid_t sid2); #endif /* H5S_TESTING */ #endif /*_H5Spkg_H*/ xdmf-3.0+git20160803/Utilities/hdf5/H5Fdbg.c0000640000175000017500000001414113003006557020077 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* Programmer: Quincey Koziol * Wednesday, July 9, 2003 * * Purpose: File object debugging functions. */ #define H5F_PACKAGE /*suppress error about including H5Fpkg */ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* File access */ #include "H5Iprivate.h" /* ID Functions */ #include "H5Pprivate.h" /* Property lists */ /*------------------------------------------------------------------------- * Function: H5F_debug * * Purpose: Prints a file header to the specified stream. Each line * is indented and the field name occupies the specified width * number of characters. * * Errors: * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 1 1997 * * Modifications: * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. * * Raymond Lu, 2001-10-14 * Changed to the new generic property list. * *------------------------------------------------------------------------- */ herr_t H5F_debug(H5F_t *f, hid_t dxpl_id, FILE * stream, int indent, int fwidth) { hsize_t userblock_size; int super_vers, freespace_vers, obj_dir_vers, share_head_vers; H5P_genplist_t *plist; /* Property list */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5F_debug, FAIL) /* check args */ assert(f); assert(stream); assert(indent >= 0); assert(fwidth >= 0); /* Get property list */ if(NULL == (plist = H5I_object(f->shared->fcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") if(H5P_get(plist, H5F_CRT_USER_BLOCK_NAME, &userblock_size)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get user block size") if(H5P_get(plist, H5F_CRT_SUPER_VERS_NAME, &super_vers)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get super block version") if(H5P_get(plist, H5F_CRT_FREESPACE_VERS_NAME, &freespace_vers)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get super block version") if(H5P_get(plist, H5F_CRT_OBJ_DIR_VERS_NAME, &obj_dir_vers)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object directory version") if(H5P_get(plist, H5F_CRT_SHARE_HEAD_VERS_NAME, &share_head_vers)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get shared-header format version") /* debug */ HDfprintf(stream, "%*sFile Super Block...\n", indent, ""); HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "File name:", f->name); HDfprintf(stream, "%*s%-*s 0x%08x\n", indent, "", fwidth, "File access flags", (unsigned) (f->shared->flags)); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "File open reference count:", (unsigned) (f->shared->nrefs)); HDfprintf(stream, "%*s%-*s %a (abs)\n", indent, "", fwidth, "Address of super block:", f->shared->super_addr); HDfprintf(stream, "%*s%-*s %lu bytes\n", indent, "", fwidth, "Size of user block:", (unsigned long) userblock_size); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Super block version number:", (unsigned) super_vers); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Free list version number:", (unsigned) freespace_vers); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Root group symbol table entry version number:", (unsigned) obj_dir_vers); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Shared header version number:", (unsigned) share_head_vers); HDfprintf(stream, "%*s%-*s %u bytes\n", indent, "", fwidth, "Size of file offsets (haddr_t type):", (unsigned) f->shared->sizeof_addr); HDfprintf(stream, "%*s%-*s %u bytes\n", indent, "", fwidth, "Size of file lengths (hsize_t type):", (unsigned) f->shared->sizeof_size); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Symbol table leaf node 1/2 rank:", f->shared->sym_leaf_k); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Symbol table internal node 1/2 rank:", f->shared->btree_k[H5B_SNODE_ID]); HDfprintf(stream, "%*s%-*s 0x%08lx\n", indent, "", fwidth, "File consistency flags:", (unsigned long) (f->shared->consist_flags)); HDfprintf(stream, "%*s%-*s %a (abs)\n", indent, "", fwidth, "Base address:", f->shared->base_addr); HDfprintf(stream, "%*s%-*s %a (rel)\n", indent, "", fwidth, "Free list address:", f->shared->freespace_addr); HDfprintf(stream, "%*s%-*s %a (rel)\n", indent, "", fwidth, "Address of driver information block:", f->shared->driver_addr); HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Root group symbol table entry:", f->shared->root_grp ? "" : "(none)"); if (f->shared->root_grp) { H5G_ent_debug(f, dxpl_id, H5G_entof(f->shared->root_grp), stream, indent+3, MAX(0, fwidth-3), HADDR_UNDEF); } done: FUNC_LEAVE_NOAPI(ret_value) } xdmf-3.0+git20160803/Utilities/hdf5/H5Ipkg.h0000640000175000017500000000470113003006557020135 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Quincey Koziol * Thursday, May 15, 2003 * * Purpose: This file contains declarations which are visible only within * the H5I package. Source files outside the H5I package should * include H5Iprivate.h instead. */ #ifndef H5I_PACKAGE #error "Do not include this file outside the H5I package!" #endif #ifndef _H5Ipkg_H #define _H5Ipkg_H /* Get package's private header */ #include "H5Iprivate.h" /* Other private headers needed by this file */ /**************************/ /* Package Private Macros */ /**************************/ /* * Number of bits to use for Group ID in each atom. Increase if H5I_NGROUPS * becomes too large (an assertion would fail in H5I_init_interface). This is * the only number that must be changed since all other bit field sizes and * masks are calculated from GROUP_BITS. */ #define GROUP_BITS 5 #define GROUP_MASK ((1<>ID_BITS) & GROUP_MASK)) /****************************/ /* Package Private Typedefs */ /****************************/ /******************************/ /* Package Private Prototypes */ /******************************/ #endif /*_H5Ipkg_H*/ xdmf-3.0+git20160803/Utilities/hdf5/H5FDcore.h0000640000175000017500000000314413003006557020405 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Robb Matzke * Monday, August 2, 1999 * * Purpose: The public header file for the sec2 driver. */ #ifndef H5FDcore_H #define H5FDcore_H #include "H5Ipublic.h" #define H5FD_CORE (H5FD_core_init()) #ifdef __cplusplus extern "C" { #endif H5_DLL hid_t H5FD_core_init(void); H5_DLL void H5FD_core_term(void); H5_DLL herr_t H5Pset_fapl_core(hid_t fapl_id, size_t increment, hbool_t backing_store); H5_DLL herr_t H5Pget_fapl_core(hid_t fapl_id, size_t *increment/*out*/, hbool_t *backing_store/*out*/); #ifdef __cplusplus } #endif #endif xdmf-3.0+git20160803/Utilities/hdf5/H5Fpkg.h0000640000175000017500000001743713003006557020144 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Quincey Koziol * Thursday, September 28, 2000 * * Purpose: This file contains declarations which are visible only within * the H5F package. Source files outside the H5F package should * include H5Fprivate.h instead. */ #ifndef H5F_PACKAGE #error "Do not include this file outside the H5F package!" #endif #ifndef _H5Fpkg_H #define _H5Fpkg_H /* Get package's private header */ #include "H5Fprivate.h" /* Other public headers needed by this file */ #include "H5Bpublic.h" /* B-tree header, for H5B_NUM_BTREE_ID */ /* Other private headers needed by this file */ #include "H5private.h" /* Generic Functions */ #include "H5FOprivate.h" /* File objects */ #include "H5Gprivate.h" /* Groups */ #include "H5RCprivate.h" /* Reference counted object functions */ /* * Feature: Define this constant to be non-zero if you want to enable code * that minimizes the number of calls to lseek(). This has a huge * performance benefit on some systems. Set this constant to zero * on the compiler command line to disable that optimization. */ #ifndef H5F_OPT_SEEK # define H5F_OPT_SEEK 1 #endif /* * Feature: Define this constant on the compiler command-line if you want to * see some debugging messages on the debug stream. */ #ifdef NDEBUG # undef H5F_DEBUG #endif /* Maximum size of super-block buffer */ #define H5F_SUPERBLOCK_SIZE 256 #define H5F_DRVINFOBLOCK_SIZE 1024 /* Define the HDF5 file signature */ #define H5F_SIGNATURE "\211HDF\r\n\032\n" #define H5F_SIGNATURE_LEN 8 /* * Private file open flags. */ #define H5F_ACC_PUBLIC_FLAGS 0x00ffu /* * Define the structure to store the file information for HDF5 files. One of * these structures is allocated per file, not per H5Fopen(). That is, set of * H5F_t structs can all point to the same H5F_file_t struct. The `nrefs' * count in this struct indicates the number of H5F_t structs which are * pointing to this struct. */ typedef struct H5F_file_t { H5FD_t *lf; /* Lower level file handle for I/O */ unsigned nrefs; /* Ref count for times file is opened */ uint32_t consist_flags; /* File Consistency Flags */ unsigned flags; /* Access Permissions for file */ /* Cached values from FCPL */ unsigned sym_leaf_k; /* Size of leaves in symbol tables */ unsigned btree_k[H5B_NUM_BTREE_ID]; /* B-tree key values for each type */ size_t sizeof_addr; /* Size of addresses in file */ size_t sizeof_size; /* Size of offsets in file */ haddr_t super_addr; /* Absolute address of super block */ haddr_t base_addr; /* Absolute base address for rel.addrs. */ haddr_t freespace_addr; /* Relative address of free-space info */ haddr_t driver_addr; /* File driver information block address*/ unsigned super_chksum; /* Superblock checksum */ unsigned drvr_chksum; /* Driver info block checksum */ H5AC_t *cache; /* The object cache */ int mdc_nelmts; /* Size of meta data cache (elements) */ hid_t fcpl_id; /* File creation property list ID */ H5F_close_degree_t fc_degree; /* File close behavior degree */ size_t rdcc_nelmts; /* Size of raw data chunk cache (elmts) */ size_t rdcc_nbytes; /* Size of raw data chunk cache (bytes) */ double rdcc_w0; /* Preempt read chunks first? [0.0..1.0]*/ size_t sieve_buf_size; /* Size of the data sieve buffer allocated (in bytes) */ hsize_t threshold; /* Threshold for alignment */ hsize_t alignment; /* Alignment */ unsigned gc_ref; /* Garbage-collect references? */ int ncwfs; /* Num entries on cwfs list */ struct H5HG_heap_t **cwfs; /* Global heap cache */ struct H5G_t *root_grp; /* Open root group */ H5FO_t *open_objs; /* Open objects in file */ H5RC_t *grp_btree_shared; /* Ref-counted group B-tree node info */ } H5F_file_t; /* A record of the mount table */ typedef struct H5F_mount_t { struct H5G_t *group; /* Mount point group held open */ struct H5F_t *file; /* File mounted at that point */ } H5F_mount_t; /* * The mount table describes what files are attached to (mounted on) the file * to which this table belongs. */ typedef struct H5F_mtab_t { struct H5F_t *parent;/* Parent file */ unsigned nmounts;/* Number of children which are mounted */ unsigned nalloc; /* Number of mount slots allocated */ H5F_mount_t *child; /* An array of mount records */ } H5F_mtab_t; /* * This is the top-level file descriptor. One of these structures is * allocated every time H5Fopen() is called although they may contain pointers * to shared H5F_file_t structs. The reference count (nrefs) indicates the * number of times the file has been opened (the application can only open a * file once explicitly, but the library can open the file a second time to * indicate that the file is mounted on some other file). */ struct H5F_t { unsigned intent; /* The flags passed to H5F_open()*/ char *name; /* Name used to open file */ H5F_file_t *shared; /* The shared file info */ unsigned nopen_objs; /* Number of open object headers*/ H5FO_t *obj_count; /* # of time each object is opened through top file structure */ hid_t file_id; /* ID of this file */ hbool_t closing; /* File is in the process of being closed */ H5F_mtab_t mtab; /* File mount table */ }; /* Forward declarations for prototype arguments */ struct H5D_dxpl_cache_t; struct H5D_dcpl_cache_t; union H5D_storage_t; /* Private functions, not part of the publicly documented API */ #ifdef NOT_YET H5_DLL void H5F_encode_length_unusual(const H5F_t *f, uint8_t **p, uint8_t *l); #endif /* NOT_YET */ /* General routines */ H5_DLL herr_t H5F_try_close(H5F_t *f); H5_DLL haddr_t H5F_locate_signature(H5FD_t *file, hid_t dxpl_id); /* File mount related routines */ H5_DLL herr_t H5F_mountpoint(struct H5G_entry_t *find/*in,out*/); H5_DLL herr_t H5F_close_mounts(H5F_t *f); H5_DLL int H5F_term_unmount_cb(void *obj_ptr, hid_t obj_id, void *key); H5_DLL herr_t H5F_mount_count_ids(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs); /* Superblock related routines */ H5_DLL herr_t H5F_init_superblock(const H5F_t *f, hid_t dxpl_id); H5_DLL herr_t H5F_write_superblock(H5F_t *f, hid_t dxpl_id); H5_DLL herr_t H5F_read_superblock(H5F_t *f, hid_t dxpl_id, H5G_entry_t *root_ent); /* Shared file list related routines */ H5_DLL herr_t H5F_sfile_add(H5F_file_t *shared); H5_DLL H5F_file_t * H5F_sfile_search(H5FD_t *lf); H5_DLL herr_t H5F_sfile_remove(H5F_file_t *shared); #endif xdmf-3.0+git20160803/Utilities/hdf5/H5Tpad.c0000640000175000017500000001204313003006557020124 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Module Info: This module contains the functionality for setting & querying * the datatype padding for the H5T interface. */ #define H5T_PACKAGE /*suppress error about including H5Tpkg */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5T_init_pad_interface #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Iprivate.h" /* IDs */ #include "H5Tpkg.h" /* Datatypes */ /*-------------------------------------------------------------------------- NAME H5T_init_pad_interface -- Initialize interface-specific information USAGE herr_t H5T_init_pad_interface() RETURNS Non-negative on success/Negative on failure DESCRIPTION Initializes any interface-specific data or routines. (Just calls H5T_init_iterface currently). --------------------------------------------------------------------------*/ static herr_t H5T_init_pad_interface(void) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_init_pad_interface) FUNC_LEAVE_NOAPI(H5T_init()) } /* H5T_init_pad_interface() */ /*------------------------------------------------------------------------- * Function: H5Tget_pad * * Purpose: Gets the least significant pad type and the most significant * pad type and returns their values through the LSB and MSB * arguments, either of which may be the null pointer. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Friday, January 9, 1998 * * Modifications: * Robb Matzke, 22 Dec 1998 * Also works with derived data types. * *------------------------------------------------------------------------- */ herr_t H5Tget_pad(hid_t type_id, H5T_pad_t *lsb/*out*/, H5T_pad_t *msb/*out*/) { H5T_t *dt = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Tget_pad, FAIL) H5TRACE3("e","ixx",type_id,lsb,msb); /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") while (dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ if (!H5T_IS_ATOMIC(dt->shared)) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "operation not defined for specified data type") /* Get values */ if (lsb) *lsb = dt->shared->u.atomic.lsb_pad; if (msb) *msb = dt->shared->u.atomic.msb_pad; done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5Tset_pad * * Purpose: Sets the LSB and MSB pad types. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Friday, January 9, 1998 * * Modifications: * Robb Matzke, 22 Dec 1998 * Also works with derived data types. * *------------------------------------------------------------------------- */ herr_t H5Tset_pad(hid_t type_id, H5T_pad_t lsb, H5T_pad_t msb) { H5T_t *dt = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Tset_pad, FAIL) H5TRACE3("e","iTpTp",type_id,lsb,msb); /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") if (H5T_STATE_TRANSIENT!=dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only") if (lsb < H5T_PAD_ZERO || lsb >= H5T_NPAD || msb < H5T_PAD_ZERO || msb >= H5T_NPAD) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pad type") if (H5T_ENUM==dt->shared->type && dt->shared->u.enumer.nmembs>0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not allowed after members are defined") while (dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ if (!H5T_IS_ATOMIC(dt->shared)) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "operation not defined for specified data type") /* Commit */ dt->shared->u.atomic.lsb_pad = lsb; dt->shared->u.atomic.msb_pad = msb; done: FUNC_LEAVE_API(ret_value) } xdmf-3.0+git20160803/Utilities/hdf5/H5Opublic.h0000640000175000017500000000364313003006557020644 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*------------------------------------------------------------------------- * * Created: H5Opublic.h * Aug 5 1997 * Robb Matzke * * Purpose: Public declarations for the H5O (object header) * package. * * Modifications: * *------------------------------------------------------------------------- */ #ifndef _H5Opublic_H #define _H5Opublic_H /* Public headers needed by this file */ #include "H5public.h" typedef struct H5O_stat_t { hsize_t size; /* Total size of object header in file */ hsize_t free; /* Free space within object header */ unsigned nmesgs; /* Number of object header messages */ unsigned nchunks; /* Number of object header chunks */ } H5O_stat_t; #ifdef __cplusplus extern "C" { #endif #ifdef __cplusplus } #endif #endif xdmf-3.0+git20160803/Utilities/hdf5/H5MM.c0000640000175000017500000001562513003006557017556 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*------------------------------------------------------------------------- * * Created: H5MM.c * Jul 10 1997 * Robb Matzke * * Purpose: Memory management functions. * * Modifications: * *------------------------------------------------------------------------- */ #include "H5private.h" #include "H5Eprivate.h" #include "H5MMprivate.h" #ifndef NDEBUG /*------------------------------------------------------------------------- * Function: H5MM_malloc * * Purpose: Just like the POSIX version of malloc(3). This routine * specifically checks for allocations of 0 bytes and fails * in that case. This routine is not called when NDEBUG is * defined. * * Return: Success: Ptr to new memory * * Failure: NULL * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * Nov 8 2003 * * Modifications: * *------------------------------------------------------------------------- */ void * H5MM_malloc(size_t size) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5MM_malloc); assert(size); FUNC_LEAVE_NOAPI(HDmalloc(size)); } /* end H5MM_malloc() */ /*------------------------------------------------------------------------- * Function: H5MM_calloc * * Purpose: Similar to the POSIX version of calloc(3), except this routine * just takes a 'size' parameter. This routine * specifically checks for allocations of 0 bytes and fails * in that case. This routine is not called when NDEBUG is * defined. * * Return: Success: Ptr to new memory * * Failure: NULL * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * Nov 8 2003 * * Modifications: * *------------------------------------------------------------------------- */ void * H5MM_calloc(size_t size) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5MM_calloc); assert(size); FUNC_LEAVE_NOAPI(HDcalloc(1,size)); } /* end H5MM_calloc() */ #endif /* NDEBUG */ /*------------------------------------------------------------------------- * Function: H5MM_realloc * * Purpose: Just like the POSIX version of realloc(3). Specifically, the * following calls are equivalent * * H5MM_realloc (NULL, size) <==> H5MM_malloc (size) * H5MM_realloc (ptr, 0) <==> H5MM_xfree (ptr) * H5MM_realloc (NULL, 0) <==> NULL * * Return: Success: Ptr to new memory or NULL if the memory * was freed. * * Failure: abort() * * Programmer: Robb Matzke * matzke@llnl.gov * Jul 10 1997 * * Modifications: * *------------------------------------------------------------------------- */ void * H5MM_realloc(void *mem, size_t size) { void *ret_value; /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5MM_realloc); if (!mem) { if (0 == size) HGOTO_DONE(NULL); mem = H5MM_malloc(size); } else if (0 == size) { mem = H5MM_xfree(mem); } else { mem = HDrealloc(mem, size); assert(mem); } /* Set return value */ ret_value=mem; done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5MM_xstrdup * * Purpose: Duplicates a string. If the string to be duplicated is the * null pointer, then return null. If the string to be duplicated * is the empty string then return a new empty string. * * Return: Success: Ptr to a new string (or null if no string). * * Failure: abort() * * Programmer: Robb Matzke * matzke@llnl.gov * Jul 10 1997 * * Modifications: * *------------------------------------------------------------------------- */ char * H5MM_xstrdup(const char *s) { char *ret_value=NULL; /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5MM_xstrdup); if (s) { ret_value = H5MM_malloc(HDstrlen(s) + 1); assert (ret_value); HDstrcpy(ret_value, s); } /* end if */ #ifdef LATER done: #endif /* LATER */ FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5MM_strdup * * Purpose: Duplicates a string. If the string to be duplicated is the * null pointer, then return null. If the string to be duplicated * is the empty string then return a new empty string. * * Return: Success: Ptr to a new string (or null if no string). * * Failure: abort() * * Programmer: Robb Matzke * matzke@llnl.gov * Jul 10 1997 * * Modifications: * *------------------------------------------------------------------------- */ char * H5MM_strdup(const char *s) { char *ret_value; FUNC_ENTER_NOAPI(H5MM_strdup, NULL); if (!s) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, NULL, "null string"); if (NULL==(ret_value = H5MM_malloc(HDstrlen(s) + 1))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); HDstrcpy(ret_value, s); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5MM_xfree * * Purpose: Just like free(3) except null pointers are allowed as * arguments, and the return value (always NULL) can be * assigned to the pointer whose memory was just freed: * * thing = H5MM_xfree (thing); * * Return: Success: NULL * * Failure: never fails * * Programmer: Robb Matzke * matzke@llnl.gov * Jul 10 1997 * * Modifications: * *------------------------------------------------------------------------- */ void * H5MM_xfree(void *mem) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5MM_xfree); if (mem) HDfree(mem); FUNC_LEAVE_NOAPI(NULL); } xdmf-3.0+git20160803/Utilities/hdf5/H5Oname.c0000640000175000017500000002147613003006557020305 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*------------------------------------------------------------------------- * * Created: H5Oname.c * Aug 12 1997 * Robb Matzke * * Purpose: Object name message. * * Modifications: * *------------------------------------------------------------------------- */ #define H5O_PACKAGE /*suppress error about including H5Opkg */ #include "H5private.h" #include "H5Eprivate.h" #include "H5MMprivate.h" #include "H5Opkg.h" /* Object header functions */ /* PRIVATE PROTOTYPES */ static void *H5O_name_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t *sh); static herr_t H5O_name_encode(H5F_t *f, uint8_t *p, const void *_mesg); static void *H5O_name_copy(const void *_mesg, void *_dest, unsigned update_flags); static size_t H5O_name_size(const H5F_t *f, const void *_mesg); static herr_t H5O_name_reset(void *_mesg); static herr_t H5O_name_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * stream, int indent, int fwidth); /* This message derives from H5O */ const H5O_class_t H5O_NAME[1] = {{ H5O_NAME_ID, /*message id number */ "name", /*message name for debugging */ sizeof(H5O_name_t), /*native message size */ H5O_name_decode, /*decode message */ H5O_name_encode, /*encode message */ H5O_name_copy, /*copy the native value */ H5O_name_size, /*raw message size */ H5O_name_reset, /*free internal memory */ NULL, /* free method */ NULL, /* file delete method */ NULL, /* link method */ NULL, /*get share method */ NULL, /*set share method */ H5O_name_debug, /*debug the message */ }}; /*------------------------------------------------------------------------- * Function: H5O_name_decode * * Purpose: Decode a name message and return a pointer to a new * native message struct. * * Return: Success: Ptr to new message in native struct. * * Failure: NULL * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 12 1997 * * Modifications: * *------------------------------------------------------------------------- */ static void * H5O_name_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const uint8_t *p, H5O_shared_t UNUSED *sh) { H5O_name_t *mesg; void *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_name_decode); /* check args */ assert(f); assert(p); assert (!sh); /* decode */ if (NULL==(mesg = H5MM_calloc(sizeof(H5O_name_t))) || NULL==(mesg->s = H5MM_malloc (HDstrlen((const char*)p)+1))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); HDstrcpy(mesg->s, (const char*)p); /* Set return value */ ret_value=mesg; done: if(ret_value==NULL) { if(mesg) H5MM_xfree (mesg); } /* end if */ FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_name_encode * * Purpose: Encodes a name message. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 12 1997 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_name_encode(H5F_t UNUSED *f, uint8_t *p, const void *_mesg) { const H5O_name_t *mesg = (const H5O_name_t *) _mesg; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_name_encode); /* check args */ assert(f); assert(p); assert(mesg && mesg->s); /* encode */ HDstrcpy((char*)p, mesg->s); FUNC_LEAVE_NOAPI(SUCCEED); } /*------------------------------------------------------------------------- * Function: H5O_name_copy * * Purpose: Copies a message from _MESG to _DEST, allocating _DEST if * necessary. * * Return: Success: Ptr to _DEST * * Failure: NULL * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 12 1997 * * Modifications: * *------------------------------------------------------------------------- */ static void * H5O_name_copy(const void *_mesg, void *_dest, unsigned UNUSED update_flags) { const H5O_name_t *mesg = (const H5O_name_t *) _mesg; H5O_name_t *dest = (H5O_name_t *) _dest; void *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_name_copy); /* check args */ assert(mesg); if (!dest && NULL==(dest = H5MM_calloc(sizeof(H5O_name_t)))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); /* copy */ *dest = *mesg; if((dest->s = H5MM_xstrdup(mesg->s))==NULL) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); /* Set return value */ ret_value=dest; done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_name_size * * Purpose: Returns the size of the raw message in bytes not * counting the message typ or size fields, but only the data * fields. This function doesn't take into account * alignment. * * Return: Success: Message data size in bytes w/o alignment. * * Failure: Negative * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 12 1997 * * Modifications: * *------------------------------------------------------------------------- */ static size_t H5O_name_size(const H5F_t UNUSED *f, const void *_mesg) { const H5O_name_t *mesg = (const H5O_name_t *) _mesg; size_t ret_value; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_name_size); /* check args */ assert(f); assert(mesg); ret_value = mesg->s ? HDstrlen(mesg->s) + 1 : 0; FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_name_reset * * Purpose: Frees internal pointers and resets the message to an * initial state. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 12 1997 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_name_reset(void *_mesg) { H5O_name_t *mesg = (H5O_name_t *) _mesg; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_name_reset); /* check args */ assert(mesg); /* reset */ mesg->s = H5MM_xfree(mesg->s); FUNC_LEAVE_NOAPI(SUCCEED); } /*------------------------------------------------------------------------- * Function: H5O_name_debug * * Purpose: Prints debugging info for the message. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 12 1997 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_name_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg, FILE *stream, int indent, int fwidth) { const H5O_name_t *mesg = (const H5O_name_t *)_mesg; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_name_debug); /* check args */ assert(f); assert(mesg); assert(stream); assert(indent >= 0); assert(fwidth >= 0); fprintf(stream, "%*s%-*s `%s'\n", indent, "", fwidth, "Name:", mesg->s); FUNC_LEAVE_NOAPI(SUCCEED); } xdmf-3.0+git20160803/Utilities/hdf5/H5HGdbg.c0000640000175000017500000001134213003006557020210 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* Programmer: Quincey Koziol * Wednesday, July 9, 2003 * * Purpose: Global Heap object debugging functions. */ #define H5HG_PACKAGE /*suppress error about including H5HGpkg */ #include "H5private.h" /* Generic Functions */ #include "H5ACprivate.h" /* Metadata cache */ #include "H5Eprivate.h" /* Error handling */ #include "H5HGpkg.h" /* Global heaps */ #include "H5Iprivate.h" /* ID Functions */ /*------------------------------------------------------------------------- * Function: H5HG_debug * * Purpose: Prints debugging information about a global heap collection. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Mar 27, 1998 * * Modifications: * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. * * Robb Matzke, LLNL, 2003-06-05 * The size does not include the object header, just the data. *------------------------------------------------------------------------- */ herr_t H5HG_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int fwidth) { unsigned u, nused, maxobj; unsigned j, k; H5HG_heap_t *h = NULL; char buf[64]; uint8_t *p = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5HG_debug, FAIL); /* check arguments */ assert(f); assert(H5F_addr_defined (addr)); assert(stream); assert(indent >= 0); assert(fwidth >= 0); if (NULL == (h = H5AC_protect(f, dxpl_id, H5AC_GHEAP, addr, NULL, NULL, H5AC_READ))) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load global heap collection"); fprintf(stream, "%*sGlobal Heap Collection...\n", indent, ""); fprintf(stream, "%*s%-*s %d\n", indent, "", fwidth, "Dirty:", (int)(h->cache_info.is_dirty)); fprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, "Total collection size in file:", (unsigned long)(h->size)); for (u=1, nused=0, maxobj=0; unused; u++) { if (h->obj[u].begin) { nused++; if (u>maxobj) maxobj = u; } } fprintf (stream, "%*s%-*s %u/%lu/", indent, "", fwidth, "Objects defined/allocated/max:", nused, (unsigned long)h->nalloc); fprintf (stream, nused ? "%u\n": "NA\n", maxobj); fprintf (stream, "%*s%-*s %lu\n", indent, "", fwidth, "Free space:", (unsigned long)(h->obj[0].size)); for (u=1; unused; u++) { if (h->obj[u].begin) { sprintf (buf, "Object %u", u); fprintf (stream, "%*s%s\n", indent, "", buf); fprintf (stream, "%*s%-*s %d\n", indent+3, "", MIN(fwidth-3, 0), "Reference count:", h->obj[u].nrefs); fprintf (stream, "%*s%-*s %lu/%lu\n", indent+3, "", MIN(fwidth-3, 0), "Size of object body:", (unsigned long)(h->obj[u].size), (unsigned long)H5HG_ALIGN(h->obj[u].size)); p = h->obj[u].begin + H5HG_SIZEOF_OBJHDR (f); for (j=0; jobj[u].size; j+=16) { fprintf (stream, "%*s%04d: ", indent+6, "", j); for (k=0; k<16; k++) { if (8==k) fprintf (stream, " "); if (j+kobj[u].size) { fprintf (stream, "%02x ", p[j+k]); } else { HDfputs(" ", stream); } } for (k=0; k<16 && j+kobj[u].size; k++) { if (8==k) fprintf (stream, " "); HDfputc(p[j+k]>' ' && p[j+k]<='~' ? p[j+k] : '.', stream); } fprintf (stream, "\n"); } } } done: if (h && H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, addr, h, FALSE) != SUCCEED) HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value); } xdmf-3.0+git20160803/Utilities/hdf5/H5FDmulti.c0000640000175000017500000016747013003006557020617 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Robb Matzke * Monday, November 10, 1997 * * Purpose: Implements a file driver which dispatches I/O requests to * other file drivers depending on the purpose of the address * region being accessed. For instance, all meta-data could be * place in one file while all raw data goes to some other file. * This also serves as an example of coding a complex file driver, * therefore, it should not use any non-public definitions. */ #include #include /* Disable certain warnings in PC-Lint: */ /*lint --emacro( {534, 830}, H5P_DEFAULT, H5P_FILE_ACCESS, H5P_DATASET_XFER) */ /*lint --emacro( {534, 830}, H5F_ACC_DEBUG, H5F_ACC_RDWR) */ /*lint --emacro( {534, 830}, H5FD_MULTI) */ /*lint -esym( 534, H5Eclear, H5Epush) */ #include "hdf5.h" /* * Define H5FD_MULTI_DEBUG if you want the ability to print debugging * messages to the standard error stream. Messages are only printed if the * file is opened with the H5F_ACC_DEBUG flag. */ #define H5FD_MULTI_DEBUG /* Our version of MAX */ #undef MAX #define MAX(X,Y) ((X)>(Y)?(X):(Y)) #ifndef FALSE #define FALSE 0 #endif #ifndef TRUE #define TRUE 1 #endif /* Loop through all mapped files */ #define UNIQUE_MEMBERS(MAP,LOOPVAR) { \ H5FD_mem_t _unmapped, LOOPVAR; \ hbool_t _seen[H5FD_MEM_NTYPES]; \ \ memset(_seen, 0, sizeof _seen); \ for (_unmapped=H5FD_MEM_SUPER; _unmapped0 && LOOPVAR0 && LOOPVAR * * Programmer: Quincey Koziol * Friday, Jan 30, 2004 * * Modification: * *--------------------------------------------------------------------------- */ void H5FD_multi_term(void) { /* Reset VFL ID */ H5FD_MULTI_g=0; } /* end H5FD_multi_term() */ /*------------------------------------------------------------------------- * Function: H5Pset_fapl_split * * Purpose: Compatability function. Makes the multi driver act like the * old split driver which stored meta data in one file and raw * data in another file. * * Return: Success: 0 * * Failure: -1 * * Programmer: Robb Matzke * Wednesday, August 11, 1999 * * Modifications: * Albert Cheng, Sep 17, 2001 * Added feature that if the raw or meta extension string contains * a "%s", it will be substituted by the filename given for H5Fopen * or H5Fcreate. This is same as the multi-file syntax. If no %s * is found, one is inserted at the beginning. This is the previous * behavior. * *------------------------------------------------------------------------- */ herr_t H5Pset_fapl_split(hid_t fapl, const char *meta_ext, hid_t meta_plist_id, const char *raw_ext, hid_t raw_plist_id) { H5FD_mem_t mt, memb_map[H5FD_MEM_NTYPES]; hid_t memb_fapl[H5FD_MEM_NTYPES]; const char *memb_name[H5FD_MEM_NTYPES]; char meta_name[1024], raw_name[1024]; haddr_t memb_addr[H5FD_MEM_NTYPES]; /*NO TRACE*/ /* Clear the error stack */ H5Eclear(); /* Initialize */ for (mt=H5FD_MEM_DEFAULT; mt=H5FD_MEM_NTYPES) H5Epush_ret(func, H5E_INTERNAL, H5E_BADRANGE, "file resource type out of range", -1) if (H5FD_MEM_DEFAULT==mmt) mmt = mt; /* * All members of MEMB_FAPL must be either defaults or actual file * access property lists. */ if (H5P_DEFAULT!=memb_fapl[mmt] && TRUE!=H5Pisa_class(memb_fapl[mmt], H5P_FILE_ACCESS)) H5Epush_ret(func, H5E_INTERNAL, H5E_BADVALUE, "file resource type incorrect", -1) /* All names must be defined */ if (!memb_name[mmt] || !memb_name[mmt][0]) H5Epush_ret(func, H5E_INTERNAL, H5E_BADVALUE, "file resource type not set", -1) } /* * Initialize driver specific information. No need to copy it into the FA * struct since all members will be copied by H5Pset_driver(). */ memcpy(fa.memb_map, memb_map, H5FD_MEM_NTYPES*sizeof(H5FD_mem_t)); memcpy(fa.memb_fapl, memb_fapl, H5FD_MEM_NTYPES*sizeof(hid_t)); memcpy(fa.memb_name, memb_name, H5FD_MEM_NTYPES*sizeof(char*)); memcpy(fa.memb_addr, memb_addr, H5FD_MEM_NTYPES*sizeof(haddr_t)); fa.relax = relax; /* Patch up H5P_DEFAULT property lists for members */ for (mt=H5FD_MEM_DEFAULT; mtmemb_map, H5FD_MEM_NTYPES*sizeof(H5FD_mem_t)); if (memb_fapl) { for (mt=H5FD_MEM_DEFAULT; mtmemb_fapl[mt]>=0) memb_fapl[mt] = H5Pcopy(fa->memb_fapl[mt]); else memb_fapl[mt] = fa->memb_fapl[mt]; /*default or bad ID*/ } } if (memb_name) { for (mt=H5FD_MEM_DEFAULT; mtmemb_name[mt]) { memb_name[mt] = malloc(strlen(fa->memb_name[mt])+1); strcpy(memb_name[mt], fa->memb_name[mt]); } else memb_name[mt] = NULL; } } if (memb_addr) memcpy(memb_addr, fa->memb_addr, H5FD_MEM_NTYPES*sizeof(haddr_t)); if (relax) *relax = fa->relax; return 0; } /*------------------------------------------------------------------------- * Function: H5Pset_dxpl_multi * * Purpose: Set the data transfer property list DXPL_ID to use the multi * driver with the specified data transfer properties for each * memory usage type MEMB_DXPL[] (after the usage map is * applied). * * Return: Success: 0 * * Failure: -1 * * Programmer: Robb Matzke * Tuesday, August 10, 1999 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Pset_dxpl_multi(hid_t dxpl_id, const hid_t *memb_dxpl) { H5FD_multi_dxpl_t dx; H5FD_mem_t mt; static const char *func="H5FDset_dxpl_multi"; /* Function Name for error reporting */ /*NO TRACE*/ /* Clear the error stack */ H5Eclear(); /* Check arguments */ if (TRUE!=H5Pisa_class(dxpl_id, H5P_DATASET_XFER)) H5Epush_ret(func, H5E_PLIST, H5E_BADTYPE, "not a data transfer property list", -1) if (!memb_dxpl) H5Epush_ret(func, H5E_INTERNAL, H5E_BADVALUE, "invalid pointer", -1) for (mt=H5FD_MEM_DEFAULT; mtmemb_dxpl[mt]>=0) memb_dxpl[mt] = H5Pcopy(dx->memb_dxpl[mt]); else memb_dxpl[mt] = dx->memb_dxpl[mt]; /*default or bad ID */ } } return 0; } /*------------------------------------------------------------------------- * Function: H5FD_multi_sb_size * * Purpose: Returns the size of the private information to be stored in * the superblock. * * Return: Success: The super block driver data size. * * Failure: never fails * * Programmer: Robb Matzke * Monday, August 16, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static hsize_t H5FD_multi_sb_size(H5FD_t *_file) { H5FD_multi_t *file = (H5FD_multi_t*)_file; int nseen = 0; hsize_t nbytes = 8; /*size of header*/ /* Clear the error stack */ H5Eclear(); /* How many unique files? */ UNIQUE_MEMBERS(file->fa.memb_map, mt) { nseen++; } END_MEMBERS; /* Addresses and EOA markers */ nbytes += nseen * 2 * 8; /* Name templates */ UNIQUE_MEMBERS(file->fa.memb_map, mt) { size_t n = strlen(file->fa.memb_name[mt])+1; nbytes += (n+7) & ~((size_t)0x0007); } END_MEMBERS; return nbytes; } /*------------------------------------------------------------------------- * Function: H5FD_multi_sb_encode * * Purpose: Encode driver information for the superblock. The NAME * argument is a nine-byte buffer which will be initialized with * an eight-character name/version number and null termination. * * The encoding is a six-byte member mapping followed two bytes * which are unused. For each unique file in usage-type order * encode all the starting addresses as unsigned 64-bit integers, * then all the EOA values as unsigned 64-bit integers, then all * the template names as null terminated strings which are * multiples of 8 characters. * * Return: Success: 0 * * Failure: -1 * * Programmer: Robb Matzke * Monday, August 16, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_multi_sb_encode(H5FD_t *_file, char *name/*out*/, unsigned char *buf/*out*/) { H5FD_multi_t *file = (H5FD_multi_t*)_file; haddr_t memb_eoa; unsigned char *p; size_t nseen; size_t i; H5FD_mem_t m; static const char *func="H5FD_multi_sb_encode"; /* Function Name for error reporting */ /* Clear the error stack */ H5Eclear(); /* Name and version number */ strncpy(name, "NCSAmulti",8); name[8] = '\0'; assert(7==H5FD_MEM_NTYPES); for (m=H5FD_MEM_SUPER; mfa.memb_map[m]; buf[7] = 0; buf[8] = 0; /* * Copy the starting addresses and EOA values into the buffer in order of * usage type but only for types which map to something unique. */ /* Encode all starting addresses and EOA values */ nseen = 0; p = buf+8; assert(sizeof(haddr_t)<=8); UNIQUE_MEMBERS(file->fa.memb_map, mt) { memb_eoa = H5FDget_eoa(file->memb[mt]); memcpy(p, &(file->fa.memb_addr[mt]), sizeof(haddr_t)); p += sizeof(haddr_t); memcpy(p, &memb_eoa, sizeof(haddr_t)); p += sizeof(haddr_t); nseen++; } END_MEMBERS; if (H5Tconvert(H5T_NATIVE_HADDR, H5T_STD_U64LE, nseen*2, buf+8, NULL, H5P_DEFAULT)<0) H5Epush_ret(func, H5E_DATATYPE, H5E_CANTCONVERT, "can't convert superblock info", -1) /* Encode all name templates */ p = buf + 8 + nseen*2*8; UNIQUE_MEMBERS(file->fa.memb_map, mt) { size_t n = strlen(file->fa.memb_name[mt]) + 1; strcpy((char *)p, file->fa.memb_name[mt]); p += n; for (i=n; i%8; i++) *p++ = '\0'; } END_MEMBERS; return 0; } /*------------------------------------------------------------------------- * Function: H5FD_multi_sb_decode * * Purpose: Decodes the superblock information for this driver. The NAME * argument is the eight-character (plus null termination) name * stored in the file. * * The FILE argument is updated according to the information in * the superblock. This may mean that some member files are * closed and others are opened. * * Return: Success: 0 * * Failure: -1 * * Programmer: Robb Matzke * Monday, August 16, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_multi_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf) { H5FD_multi_t *file = (H5FD_multi_t*)_file; char x[2*H5FD_MEM_NTYPES*8]; H5FD_mem_t map[H5FD_MEM_NTYPES]; int i; size_t nseen=0; hbool_t map_changed=FALSE; hbool_t in_use[H5FD_MEM_NTYPES]; const char *memb_name[H5FD_MEM_NTYPES]; haddr_t memb_addr[H5FD_MEM_NTYPES]; haddr_t memb_eoa[H5FD_MEM_NTYPES]; haddr_t *ap; static const char *func="H5FD_multi_sb_decode"; /* Function Name for error reporting */ /* Clear the error stack */ H5Eclear(); /* Make sure the name/version number is correct */ if (strcmp(name, "NCSAmult")) H5Epush_ret(func, H5E_FILE, H5E_BADVALUE, "invalid multi superblock", -1) /* Set default values */ ALL_MEMBERS(mt) { memb_addr[mt] = HADDR_UNDEF; memb_eoa[mt] = HADDR_UNDEF; memb_name[mt] = NULL; } END_MEMBERS; /* * Read the map and count the unique members. */ memset(map, 0, sizeof map); for (i=0; i<6; i++) { map[i+1] = (H5FD_mem_t)buf[i]; if (file->fa.memb_map[i+1]!=map[i+1]) map_changed=TRUE; } UNIQUE_MEMBERS(map, mt) { nseen++; } END_MEMBERS; buf += 8; /* Decode Address and EOA values */ assert(sizeof(haddr_t)<=8); memcpy(x, buf, (nseen*2*8)); buf += nseen*2*8; if (H5Tconvert(H5T_STD_U64LE, H5T_NATIVE_HADDR, nseen*2, x, NULL, H5P_DEFAULT)<0) H5Epush_ret(func, H5E_DATATYPE, H5E_CANTCONVERT, "can't convert superblock info", -1) ap = (haddr_t*)x; UNIQUE_MEMBERS(map, mt) { memb_addr[_unmapped] = *ap++; memb_eoa[_unmapped] = *ap++; } END_MEMBERS; /* Decode name templates */ UNIQUE_MEMBERS(map, mt) { size_t n = strlen((const char *)buf)+1; memb_name[_unmapped] = (const char *)buf; buf += (n+7) & ~((unsigned)0x0007); } END_MEMBERS; /* * Use the mapping saved in the superblock in preference to the one * already set for the file. Since we may have opened files which are no * longer needed we should close all those files. We'll open the new * files at the end. */ if (map_changed) { #ifdef H5FD_MULTI_DEBUG if (file->flags & H5F_ACC_DEBUG) { fprintf(stderr, "H5FD_MULTI: member map override\n"); fprintf(stderr, " old value: "); ALL_MEMBERS(mt) { fprintf(stderr, "%s%d", mt?", ":"", (int)(file->fa.memb_map[mt])); } END_MEMBERS; fprintf(stderr, "\n new value: "); ALL_MEMBERS(mt) { fprintf(stderr, "%s%d", mt?", ":"", (int)(map[mt])); } END_MEMBERS; } #endif /* Commit map */ ALL_MEMBERS(mt) { file->fa.memb_map[mt] = map[mt]; } END_MEMBERS; /* Close files which are unused now */ memset(in_use, 0, sizeof in_use); UNIQUE_MEMBERS(map, mt) { in_use[mt] = TRUE; } END_MEMBERS; ALL_MEMBERS(mt) { if (!in_use[mt] && file->memb[mt]) { #ifdef H5FD_MULTI_DEBUG if (file->flags & H5F_ACC_DEBUG) { fprintf(stderr, "H5FD_MULTI: close member %d\n", (int)mt); } #endif (void)H5FDclose(file->memb[mt]); file->memb[mt] = NULL; } file->fa.memb_map[mt] = map[mt]; } END_MEMBERS; } /* Commit member starting addresses and name templates */ ALL_MEMBERS(mt) { file->fa.memb_addr[mt] = memb_addr[mt]; if (memb_name[mt]) { if (file->fa.memb_name[mt]) free(file->fa.memb_name[mt]); file->fa.memb_name[mt] = my_strdup(memb_name[mt]); } } END_MEMBERS; if (compute_next(file)<0) H5Epush_ret(func, H5E_INTERNAL, H5E_BADVALUE, "compute_next() failed", -1) /* Open all necessary files */ if (open_members(file)<0) H5Epush_ret(func, H5E_INTERNAL, H5E_BADVALUE, "open_members() failed", -1) /* Set the EOA marker for all open files */ UNIQUE_MEMBERS(file->fa.memb_map, mt) { if (file->memb[mt]) if(H5FDset_eoa(file->memb[mt], memb_eoa[mt])<0) H5Epush_ret(func, H5E_INTERNAL, H5E_CANTSET, "set_eoa() failed", -1) } END_MEMBERS; return 0; } /*------------------------------------------------------------------------- * Function: H5FD_multi_fapl_get * * Purpose: Returns a file access property list which indicates how the * specified file is being accessed. The return list could be * used to access another file the same way. * * Return: Success: Ptr to new file access property list with all * members copied from the file struct. * * Failure: NULL * * Programmer: Robb Matzke * Friday, August 13, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static void * H5FD_multi_fapl_get(H5FD_t *_file) { H5FD_multi_t *file = (H5FD_multi_t*)_file; /* Clear the error stack */ H5Eclear(); return H5FD_multi_fapl_copy(&(file->fa)); } /*------------------------------------------------------------------------- * Function: H5FD_multi_fapl_copy * * Purpose: Copies the multi-specific file access properties. * * Return: Success: Ptr to a new property list * * Failure: NULL * * Programmer: Robb Matzke * Wednesday, August 4, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static void * H5FD_multi_fapl_copy(const void *_old_fa) { const H5FD_multi_fapl_t *old_fa = (const H5FD_multi_fapl_t*)_old_fa; H5FD_multi_fapl_t *new_fa = malloc(sizeof(H5FD_multi_fapl_t)); H5FD_mem_t mt; int nerrors = 0; static const char *func="H5FD_multi_fapl_copy"; /* Function Name for error reporting */ assert(new_fa); /* Clear the error stack */ H5Eclear(); memcpy(new_fa, old_fa, sizeof(H5FD_multi_fapl_t)); for (mt=H5FD_MEM_DEFAULT; mtmemb_fapl[mt]>=0) { new_fa->memb_fapl[mt] = H5Pcopy(old_fa->memb_fapl[mt]); if (new_fa->memb_fapl[mt]<0) nerrors++; } if (old_fa->memb_name[mt]) { new_fa->memb_name[mt] = malloc(strlen(old_fa->memb_name[mt])+1); assert(new_fa->memb_name[mt]); strcpy(new_fa->memb_name[mt], old_fa->memb_name[mt]); } } if (nerrors) { for (mt=H5FD_MEM_DEFAULT; mtmemb_fapl[mt]>=0) (void)H5Pclose(new_fa->memb_fapl[mt]); if (new_fa->memb_name[mt]) free(new_fa->memb_name[mt]); } free(new_fa); H5Epush_ret(func, H5E_INTERNAL, H5E_BADVALUE, "invalid freespace objects", NULL) } return new_fa; } /*------------------------------------------------------------------------- * Function: H5FD_multi_fapl_free * * Purpose: Frees the multi-specific file access properties. * * Return: Success: 0 * * Failure: -1 * * Programmer: Robb Matzke * Wednesday, August 4, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_multi_fapl_free(void *_fa) { H5FD_multi_fapl_t *fa = (H5FD_multi_fapl_t*)_fa; H5FD_mem_t mt; static const char *func="H5FD_multi_fapl_free"; /* Function Name for error reporting */ /* Clear the error stack */ H5Eclear(); for (mt=H5FD_MEM_DEFAULT; mtmemb_fapl[mt]>=0) if(H5Pclose(fa->memb_fapl[mt])<0) H5Epush_ret(func, H5E_FILE, H5E_CANTCLOSEOBJ, "can't close property list", -1) if (fa->memb_name[mt]) free(fa->memb_name[mt]); } free(fa); return 0; } /*------------------------------------------------------------------------- * Function: H5FD_multi_dxpl_copy * * Purpose: Copes the multi-specific data transfer properties. * * Return: Success: Ptr to new property list * * Failure: NULL * * Programmer: Robb Matzke * Wednesday, August 4, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static void * H5FD_multi_dxpl_copy(const void *_old_dx) { const H5FD_multi_dxpl_t *old_dx = (const H5FD_multi_dxpl_t*)_old_dx; H5FD_multi_dxpl_t *new_dx = malloc(sizeof(H5FD_multi_dxpl_t)); H5FD_mem_t mt; int nerrors = 0; static const char *func="H5FD_multi_dxpl_copy"; /* Function Name for error reporting */ assert(new_dx); /* Clear the error stack */ H5Eclear(); memcpy(new_dx, old_dx, sizeof(H5FD_multi_dxpl_t)); for (mt=H5FD_MEM_DEFAULT; mtmemb_dxpl[mt]>=0) { new_dx->memb_dxpl[mt] = H5Pcopy(old_dx->memb_dxpl[mt]); if (new_dx->memb_dxpl[mt]<0) nerrors++; } } if (nerrors) { for (mt=H5FD_MEM_DEFAULT; mtmemb_dxpl[mt]); free(new_dx); H5Epush_ret(func, H5E_INTERNAL, H5E_BADVALUE, "invalid freespace objects", NULL) } return new_dx; } /*------------------------------------------------------------------------- * Function: H5FD_multi_dxpl_free * * Purpose: Frees the multi-specific data transfer properties. * * Return: Success: 0 * * Failure: -1 * * Programmer: Robb Matzke * Wednesday, August 4, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_multi_dxpl_free(void *_dx) { H5FD_multi_dxpl_t *dx = (H5FD_multi_dxpl_t*)_dx; H5FD_mem_t mt; static const char *func="H5FD_multi_dxpl_free"; /* Function Name for error reporting */ /* Clear the error stack */ H5Eclear(); for (mt=H5FD_MEM_DEFAULT; mtmemb_dxpl[mt]>=0) if(H5Pclose(dx->memb_dxpl[mt])<0) H5Epush_ret(func, H5E_FILE, H5E_CANTCLOSEOBJ, "can't close property list", -1) free(dx); return 0; } /*------------------------------------------------------------------------- * Function: H5FD_multi_open * * Purpose: Creates and/or opens a multi HDF5 file. * * Return: Success: A pointer to a new file data structure. The * public fields will be initialized by the * caller, which is always H5FD_open(). * * Failure: NULL * * Programmer: Robb Matzke * Wednesday, August 4, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static H5FD_t * H5FD_multi_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { H5FD_multi_t *file=NULL; hid_t close_fapl=-1; H5FD_multi_fapl_t *fa; H5FD_mem_t m; static const char *func="H5FD_multi_open"; /* Function Name for error reporting */ /* Clear the error stack */ H5Eclear(); /* Check arguments */ if (!name || !*name) H5Epush_ret(func, H5E_ARGS, H5E_BADVALUE, "invalid file name", NULL) if (0==maxaddr || HADDR_UNDEF==maxaddr) H5Epush_ret(func, H5E_ARGS, H5E_BADRANGE, "bogus maxaddr", NULL) /* * Initialize the file from the file access properties, using default * values if necessary. */ if (NULL==(file=calloc(1, sizeof(H5FD_multi_t)))) H5Epush_ret(func, H5E_RESOURCE, H5E_NOSPACE, "memory allocation failed", NULL) if (H5P_FILE_ACCESS_DEFAULT==fapl_id || H5FD_MULTI!=H5Pget_driver(fapl_id)) { close_fapl = fapl_id = H5Pcreate(H5P_FILE_ACCESS); if(H5Pset_fapl_multi(fapl_id, NULL, NULL, NULL, NULL, TRUE)<0) H5Epush_goto(func, H5E_FILE, H5E_CANTSET, "can't set property value", error) } fa = H5Pget_driver_info(fapl_id); assert(fa); ALL_MEMBERS(mt) { file->fa.memb_map[mt] = fa->memb_map[mt]; file->fa.memb_addr[mt] = fa->memb_addr[mt]; if (fa->memb_fapl[mt]>=0) file->fa.memb_fapl[mt] = H5Pcopy(fa->memb_fapl[mt]); else file->fa.memb_fapl[mt] = fa->memb_fapl[mt]; if (fa->memb_name[mt]) file->fa.memb_name[mt] = my_strdup(fa->memb_name[mt]); else file->fa.memb_name[mt] = NULL; } END_MEMBERS; file->fa.relax = fa->relax; file->flags = flags; file->name = my_strdup(name); if (close_fapl>=0) if(H5Pclose(close_fapl)<0) H5Epush_goto(func, H5E_FILE, H5E_CANTCLOSEOBJ, "can't close property list", error) /* Compute derived properties and open member files */ if (compute_next(file)<0) H5Epush_goto(func, H5E_INTERNAL, H5E_BADVALUE, "compute_next() failed", error) if (open_members(file)<0) H5Epush_goto(func, H5E_INTERNAL, H5E_BADVALUE, "open_members() failed", error) /* We must have opened at least the superblock file */ if (H5FD_MEM_DEFAULT==(m=file->fa.memb_map[H5FD_MEM_SUPER])) m = H5FD_MEM_SUPER; if (NULL==file->memb[m]) goto error; return (H5FD_t*)file; error: /* Cleanup and fail */ if (file) { ALL_MEMBERS(mt) { if (file->memb[mt]) (void)H5FDclose(file->memb[mt]); if (file->fa.memb_fapl[mt]>=0) (void)H5Pclose(file->fa.memb_fapl[mt]); if (file->fa.memb_name[mt]) free(file->fa.memb_name[mt]); } END_MEMBERS; if (file->name) free(file->name); free(file); } return NULL; } /*------------------------------------------------------------------------- * Function: H5FD_multi_close * * Purpose: Closes a multi file. * * Return: Success: Non-negative * * Failure: Negative with as many members closed as * possible. The only subsequent operation * permitted on the file is a close operation. * * Programmer: Robb Matzke * Wednesday, August 4, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_multi_close(H5FD_t *_file) { H5FD_multi_t *file = (H5FD_multi_t*)_file; int nerrors=0; static const char *func="H5FD_multi_close"; /* Function Name for error reporting */ /* Clear the error stack */ H5Eclear(); /* Close as many members as possible */ ALL_MEMBERS(mt) { if (file->memb[mt]) { #ifdef H5FD_MULTI_DEBUG if (file->flags & H5F_ACC_DEBUG) { fprintf(stderr, "H5FD_MULTI: closing member %d\n", (int)mt); } #endif if (H5FDclose(file->memb[mt])<0) { #ifdef H5FD_MULTI_DEBUG if (file->flags & H5F_ACC_DEBUG) { fprintf(stderr, "H5FD_MULTI: close failed\n"); } #endif nerrors++; } else { file->memb[mt] = NULL; } } } END_MEMBERS; if (nerrors) H5Epush_ret(func, H5E_INTERNAL, H5E_BADVALUE, "error closing member files", -1) /* Clean up other stuff */ ALL_MEMBERS(mt) { if (file->fa.memb_fapl[mt]>=0) (void)H5Pclose(file->fa.memb_fapl[mt]); if (file->fa.memb_name[mt]) free(file->fa.memb_name[mt]); } END_MEMBERS; free(file->name); free(file); return 0; } /*------------------------------------------------------------------------- * Function: H5FD_multi_cmp * * Purpose: Compares two file families to see if they are the same. It * does this by comparing the first common member of the two * families. If the families have no members in common then the * file with the earliest member is smaller than the other file. * We abort if neither file has any members. * * Return: Success: like strcmp() * * Failure: never fails (arguments were checked by the * caller). * * Programmer: Robb Matzke * Wednesday, August 4, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static int H5FD_multi_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { const H5FD_multi_t *f1 = (const H5FD_multi_t*)_f1; const H5FD_multi_t *f2 = (const H5FD_multi_t*)_f2; H5FD_mem_t mt; int cmp=0; /* Clear the error stack */ H5Eclear(); for (mt=H5FD_MEM_DEFAULT; mtmemb[mt] && f2->memb[mt]) break; if (!cmp) { if (f1->memb[mt]) cmp = -1; else if (f2->memb[mt]) cmp = 1; } } assert(cmp || mt=H5FD_MEM_NTYPES) return cmp; return H5FDcmp(f1->memb[mt], f2->memb[mt]); } /*------------------------------------------------------------------------- * Function: H5FD_multi_query * * Purpose: Set the flags that this VFL driver is capable of supporting. * (listed in H5FDpublic.h) * * Return: Success: non-negative * * Failure: negative * * Programmer: Quincey Koziol * Tuesday, September 26, 2000 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_multi_query(const H5FD_t *_f, unsigned long *flags /* out */) { /* Shut compiler up */ _f=_f; /* Set the VFL feature flags that this driver supports */ if(flags) { *flags=0; *flags|=H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ *flags|=H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ } return(0); } /*------------------------------------------------------------------------- * Function: H5FD_multi_get_eoa * * Purpose: Returns the end-of-address marker for the file. The EOA * marker is the first address past the last byte allocated in * the format address space. * * Return: Success: The end-of-address-marker * * Failure: HADDR_UNDEF * * Programmer: Robb Matzke * Wednesday, August 4, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static haddr_t H5FD_multi_get_eoa(H5FD_t *_file) { H5FD_multi_t *file = (H5FD_multi_t*)_file; /* Clear the error stack */ H5Eclear(); return file->eoa; } /*------------------------------------------------------------------------- * Function: H5FD_multi_set_eoa * * Purpose: Set the end-of-address marker for the file by savig the new * EOA value in the file struct. Also set the EOA marker for the * subfile in which the new EOA value falls. We don't set the * EOA values of any other subfiles. * * Return: Success: 0 * * Failure: -1 * * Programmer: Robb Matzke * Wednesday, August 4, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_multi_set_eoa(H5FD_t *_file, haddr_t eoa) { H5FD_multi_t *file = (H5FD_multi_t*)_file; H5FD_mem_t mt, mmt; herr_t status; static const char *func="H5FD_multi_set_eoa"; /* Function Name for error reporting */ /* Clear the error stack */ H5Eclear(); /* Find the subfile in which the new EOA value falls */ for (mt=H5FD_MEM_SUPER; mtfa.memb_map[mt]; if (H5FD_MEM_DEFAULT==mmt) mmt = mt; assert(mmt>0 && mmt=file->fa.memb_addr[mmt] && eoamemb_next[mmt]) { break; } } assert(mtmemb[mmt]) { H5E_BEGIN_TRY { status = H5FDset_eoa(file->memb[mmt], eoa-file->fa.memb_addr[mmt]); } H5E_END_TRY; if (status<0) H5Epush_ret(func, H5E_FILE, H5E_BADVALUE, "member H5FDset_eoa failed", -1) } /* Save new eoa for return later */ file->eoa = eoa; return 0; } /*------------------------------------------------------------------------- * Function: H5FD_multi_get_eof * * Purpose: Returns the end-of-file marker, which is the greater of * either the total multi size or the current EOA marker. * * Return: Success: End of file address, the first address past * the end of the multi of files or the current * EOA, whichever is larger. * * Failure: HADDR_UNDEF * * Programmer: Robb Matzke * Wednesday, August 4, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static haddr_t H5FD_multi_get_eof(H5FD_t *_file) { H5FD_multi_t *file = (H5FD_multi_t*)_file; haddr_t eof=0, tmp; static const char *func="H5FD_multi_eof"; /* Function Name for error reporting */ /* Clear the error stack */ H5Eclear(); UNIQUE_MEMBERS(file->fa.memb_map, mt) { if (file->memb[mt]) { H5E_BEGIN_TRY { tmp = H5FDget_eof(file->memb[mt]); } H5E_END_TRY; if (HADDR_UNDEF==tmp) H5Epush_ret(func, H5E_INTERNAL, H5E_BADVALUE, "member file has unknown eof", HADDR_UNDEF) if (tmp>0) tmp += file->fa.memb_addr[mt]; } else if (file->fa.relax) { /* * The member is not open yet (maybe it doesn't exist). Make the * best guess about the end-of-file. */ tmp = file->memb_next[mt]; assert(HADDR_UNDEF!=tmp); } else { H5Epush_ret(func, H5E_INTERNAL, H5E_BADVALUE, "bad eof", HADDR_UNDEF) } if (tmp>eof) eof = tmp; } END_MEMBERS; return MAX(file->eoa, eof); } /*------------------------------------------------------------------------- * Function: H5FD_multi_get_handle * * Purpose: Returns the file handle of MULTI file driver. * * Returns: Non-negative if succeed or negative if fails. * * Programmer: Raymond Lu * Sept. 16, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_multi_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle) { H5FD_multi_t *file = (H5FD_multi_t *)_file; H5FD_mem_t type, mmt; static const char *func="H5FD_multi_get_handle"; /* Function Name for error reporting */ /* Get data type for multi driver */ if(H5Pget_multi_type(fapl, &type) < 0) H5Epush_ret(func, H5E_INTERNAL, H5E_BADVALUE, "can't get data type for multi driver", -1) if(type=H5FD_MEM_NTYPES) H5Epush_ret(func, H5E_INTERNAL, H5E_BADVALUE, "data type is out of range", -1) mmt = file->fa.memb_map[type]; if(H5FD_MEM_DEFAULT==mmt) mmt = type; return (H5FDget_vfd_handle(file->memb[mmt], fapl, file_handle)); } /*------------------------------------------------------------------------- * Function: H5FD_multi_alloc * * Purpose: Allocate file memory. * * Return: Success: Address of new memory * * Failure: HADDR_UNDEF * * Programmer: Robb Matzke * Thursday, August 12, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static haddr_t H5FD_multi_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size) { H5FD_multi_t *file = (H5FD_multi_t*)_file; H5FD_mem_t mmt; haddr_t addr; static const char *func="H5FD_multi_alloc"; /* Function Name for error reporting */ mmt = file->fa.memb_map[type]; if (H5FD_MEM_DEFAULT==mmt) mmt = type; if (HADDR_UNDEF==(addr=H5FDalloc(file->memb[mmt], type, dxpl_id, size))) H5Epush_ret(func, H5E_INTERNAL, H5E_BADVALUE, "member file can't alloc", HADDR_UNDEF) addr += file->fa.memb_addr[mmt]; if (addr+size>file->eoa) file->eoa = addr+size; return addr; } /*------------------------------------------------------------------------- * Function: H5FD_multi_free * * Purpose: Frees memory * * Return: Success: 0 * * Failure: -1 * * Programmer: Robb Matzke * Thursday, August 12, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_multi_free(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size) { H5FD_multi_t *file = (H5FD_multi_t*)_file; H5FD_mem_t mmt; /* Clear the error stack */ H5Eclear(); mmt = file->fa.memb_map[type]; if (H5FD_MEM_DEFAULT==mmt) mmt = type; assert(addr>=file->fa.memb_addr[mmt]); assert(addr+size<=file->memb_next[mmt]); return H5FDfree(file->memb[mmt], type, dxpl_id, addr-file->fa.memb_addr[mmt], size); } /*------------------------------------------------------------------------- * Function: H5FD_multi_read * * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR * into buffer BUF according to data transfer properties in * DXPL_ID. * * Return: Success: Zero. Result is stored in caller-supplied * buffer BUF. * * Failure: -1, contents of buffer BUF are undefined. * * Programmer: Robb Matzke * Wednesday, August 4, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_multi_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, void *_buf/*out*/) { H5FD_multi_t *file = (H5FD_multi_t*)_file; H5FD_multi_dxpl_t *dx=NULL; H5FD_mem_t mt, mmt, hi=H5FD_MEM_DEFAULT; haddr_t start_addr=0; /* Clear the error stack */ H5Eclear(); /* Get the data transfer properties */ if (H5P_FILE_ACCESS_DEFAULT!=dxpl_id && H5FD_MULTI==H5Pget_driver(dxpl_id)) { dx = H5Pget_driver_info(dxpl_id); } /* Find the file to which this address belongs */ for (mt=H5FD_MEM_SUPER; mtfa.memb_map[mt]; if (H5FD_MEM_DEFAULT==mmt) mmt = mt; assert(mmt>0 && mmtfa.memb_addr[mmt]>addr) continue; if (file->fa.memb_addr[mmt]>=start_addr) { start_addr = file->fa.memb_addr[mmt]; hi = mmt; } } assert(hi>0); /* Read from that member */ return H5FDread(file->memb[hi], type, dx?dx->memb_dxpl[hi]:H5P_DEFAULT, addr-start_addr, size, _buf); } /*------------------------------------------------------------------------- * Function: H5FD_multi_write * * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR * from buffer BUF according to data transfer properties in * DXPL_ID. * * Return: Success: Zero * * Failure: -1 * * Programmer: Robb Matzke * Wednesday, August 4, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_multi_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, const void *_buf) { H5FD_multi_t *file = (H5FD_multi_t*)_file; H5FD_multi_dxpl_t *dx=NULL; H5FD_mem_t mt, mmt, hi=H5FD_MEM_DEFAULT; haddr_t start_addr=0; /* Clear the error stack */ H5Eclear(); /* Get the data transfer properties */ if (H5P_FILE_ACCESS_DEFAULT!=dxpl_id && H5FD_MULTI==H5Pget_driver(dxpl_id)) { dx = H5Pget_driver_info(dxpl_id); } /* Find the file to which this address belongs */ for (mt=H5FD_MEM_SUPER; mtfa.memb_map[mt]; if (H5FD_MEM_DEFAULT==mmt) mmt = mt; assert(mmt>0 && mmtfa.memb_addr[mmt]>addr) continue; if (file->fa.memb_addr[mmt]>=start_addr) { start_addr = file->fa.memb_addr[mmt]; hi = mmt; } } assert(hi>0); /* Write to that member */ return H5FDwrite(file->memb[hi], type, dx?dx->memb_dxpl[hi]:H5P_DEFAULT, addr-start_addr, size, _buf); } /*------------------------------------------------------------------------- * Function: H5FD_multi_flush * * Purpose: Flushes all multi members. * * Return: Success: 0 * * Failure: -1, as many files flushed as possible. * * Programmer: Robb Matzke * Wednesday, August 4, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_multi_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing) { H5FD_multi_t *file = (H5FD_multi_t*)_file; H5FD_mem_t mt; int nerrors=0; static const char *func="H5FD_multi_flush"; /* Function Name for error reporting */ #if 0 H5FD_mem_t mmt; /* Debugging stuff... */ fprintf(stderr, "multifile access information:\n"); /* print the map */ fprintf(stderr, " map="); for (mt=1; mtmemb_map[mt]; if (H5FD_MEM_DEFAULT==mmt) mmt = mt; fprintf(stderr, "%s%d", 1==mt?"":",", (int)mmt); } fprintf(stderr, "\n"); /* print info about each file */ fprintf(stderr, " File Starting Allocated Next Member\n"); fprintf(stderr, " Number Address Size Address Name\n"); fprintf(stderr, " ------ -------------------- -------------------- -------------------- ------------------------------\n"); for (mt=1; mtmemb_addr[mt]) { haddr_t eoa = H5FDget_eoa(file->memb[mt]); fprintf(stderr, " %6d %20llu %20llu %20llu %s\n", (int)mt, (unsigned long_long)(file->memb_addr[mt]), (unsigned long_long)eoa, (unsigned long_long)(file->memb_next[mt]), file->memb_name[mt]); } } #endif /* Clear the error stack */ H5Eclear(); /* Flush each file */ for (mt=H5FD_MEM_SUPER; mtmemb[mt]) { H5E_BEGIN_TRY { if (H5FDflush(file->memb[mt],dxpl_id,closing)<0) nerrors++; } H5E_END_TRY; } } if (nerrors) H5Epush_ret(func, H5E_INTERNAL, H5E_BADVALUE, "error flushing member files", -1) return 0; } /*------------------------------------------------------------------------- * Function: compute_next * * Purpose: Compute the memb_next[] values of the file based on the * file's member map and the member starting addresses. * * Return: Success: 0 * * Failure: -1 * * Programmer: Robb Matzke * Monday, August 23, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static int compute_next(H5FD_multi_t *file) { /* Clear the error stack */ H5Eclear(); ALL_MEMBERS(mt) { file->memb_next[mt] = HADDR_UNDEF; } END_MEMBERS; UNIQUE_MEMBERS(file->fa.memb_map, mt1) { UNIQUE_MEMBERS(file->fa.memb_map, mt2) { if (file->fa.memb_addr[mt1]fa.memb_addr[mt2] && (HADDR_UNDEF==file->memb_next[mt1] || file->memb_next[mt1]>file->fa.memb_addr[mt2])) { file->memb_next[mt1] = file->fa.memb_addr[mt2]; } } END_MEMBERS; if (HADDR_UNDEF==file->memb_next[mt1]) { file->memb_next[mt1] = HADDR_MAX; /*last member*/ } } END_MEMBERS; return 0; } /*------------------------------------------------------------------------- * Function: open_members * * Purpose: Opens all members which are not opened yet. * * Return: Success: 0 * * Failure: -1 * * Programmer: Robb Matzke * Monday, August 23, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static int open_members(H5FD_multi_t *file) { char tmp[1024]; int nerrors=0; static const char *func="(H5FD_multi)open_members"; /* Function Name for error reporting */ /* Clear the error stack */ H5Eclear(); UNIQUE_MEMBERS(file->fa.memb_map, mt) { if (file->memb[mt]) continue; /*already open*/ assert(file->fa.memb_name[mt]); sprintf(tmp, file->fa.memb_name[mt], file->name); #ifdef H5FD_MULTI_DEBUG if (file->flags & H5F_ACC_DEBUG) { fprintf(stderr, "H5FD_MULTI: open member %d \"%s\"\n", (int)mt, tmp); } #endif H5E_BEGIN_TRY { file->memb[mt] = H5FDopen(tmp, file->flags, file->fa.memb_fapl[mt], HADDR_UNDEF); } H5E_END_TRY; if (!file->memb[mt]) { #ifdef H5FD_MULTI_DEBUG if (file->flags & H5F_ACC_DEBUG) { fprintf(stderr, "H5FD_MULTI: open failed for member %d\n", (int)mt); } #endif if (!file->fa.relax || (file->flags & H5F_ACC_RDWR)) { nerrors++; } } } END_MEMBERS; if (nerrors) H5Epush_ret(func, H5E_INTERNAL, H5E_BADVALUE, "error opening member files", -1) return 0; } #ifdef _H5private_H /* * This is not related to the functionality of the driver code. * It is added here to trigger warning if HDF5 private definitions are included * by mistake. The code should use only HDF5 public API and definitions. */ #error "Do not use HDF5 private definitions" #endif xdmf-3.0+git20160803/Utilities/hdf5/H5Gent.c0000640000175000017500000005165113003006557020141 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Robb Matzke * Friday, September 19, 1997 */ #define H5G_PACKAGE /*suppress error about including H5Gpkg */ #define H5F_PACKAGE /*suppress error about including H5Fpkg */ /* Packages needed by this file... */ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* File access */ #include "H5FLprivate.h" /* Free Lists */ #include "H5Gpkg.h" /* Groups */ #include "H5HLprivate.h" /* Local Heaps */ /* Private prototypes */ #ifdef NOT_YET static herr_t H5G_ent_modified(H5G_entry_t *ent, H5G_type_t cache_type); #endif /* NOT_YET */ /* Declare extern the PQ free list for the wrapped strings */ H5FL_BLK_EXTERN(str_buf); /*------------------------------------------------------------------------- * Function: H5G_ent_cache * * Purpose: Returns a pointer to the cache associated with the symbol * table entry. You should modify the cache directly, then call * H5G_ent_modified() with the new cache type (even if the type is * still the same). * * Return: Success: Ptr to the cache in the symbol table entry. * * Failure: NULL * * Programmer: Robb Matzke * Friday, September 19, 1997 * * Modifications: * *------------------------------------------------------------------------- */ const H5G_cache_t * H5G_ent_cache(const H5G_entry_t *ent, H5G_type_t *cache_type) { const H5G_cache_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5G_ent_cache, NULL); if (!ent) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, NULL, "no entry"); if (cache_type) *cache_type = ent->type; /* Set return value */ ret_value=(const H5G_cache_t *)&(ent->cache); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_ent_modified * * Purpose: This function should be called after you make any * modifications to a symbol table entry cache. Supply the new * type for the cache. If CACHE_TYPE is the constant * H5G_NO_CHANGE then the cache type isn't changed--just the * dirty bit is set. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Friday, September 19, 1997 * * Modifications: * *------------------------------------------------------------------------- */ #ifdef NOT_YET static herr_t H5G_ent_modified(H5G_entry_t *ent, H5G_type_t cache_type) { FUNC_ENTER_NOAPI_NOFUNC(H5G_ent_modified) HDassert(ent); /* Update cache type, if requested */ if (H5G_NO_CHANGE != cache_type) ent->type = cache_type; ent->dirty = TRUE; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5G_ent_modified */ #endif /* NOT_YET */ /*------------------------------------------------------------------------- * Function: H5G_ent_decode_vec * * Purpose: Same as H5G_ent_decode() except it does it for an array of * symbol table entries. * * Errors: * SYM CANTDECODE Can't decode. * * Return: Success: Non-negative, with *pp pointing to the first byte * after the last symbol. * * Failure: Negative * * Programmer: Robb Matzke * matzke@llnl.gov * Jul 18 1997 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5G_ent_decode_vec(H5F_t *f, const uint8_t **pp, H5G_entry_t *ent, unsigned n) { unsigned u; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5G_ent_decode_vec, FAIL); /* check arguments */ assert(f); assert(pp); assert(ent); /* decode entries */ for (u = 0; u < n; u++) if (H5G_ent_decode(f, pp, ent + u) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "can't decode") done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_ent_decode * * Purpose: Decodes a symbol table entry pointed to by `*pp'. * * Errors: * * Return: Success: Non-negative with *pp pointing to the first byte * following the symbol table entry. * * Failure: Negative * * Programmer: Robb Matzke * matzke@llnl.gov * Jul 18 1997 * * Modifications: * Robb Matzke, 17 Jul 1998 * Added a 4-byte padding field for alignment and future expansion. * *------------------------------------------------------------------------- */ herr_t H5G_ent_decode(H5F_t *f, const uint8_t **pp, H5G_entry_t *ent) { const uint8_t *p_ret = *pp; uint32_t tmp; FUNC_ENTER_NOAPI_NOFUNC(H5G_ent_decode); /* check arguments */ assert(f); assert(pp); assert(ent); ent->file = f; /* decode header */ H5F_DECODE_LENGTH(f, *pp, ent->name_off); H5F_addr_decode(f, pp, &(ent->header)); UINT32DECODE(*pp, tmp); *pp += 4; /*reserved*/ ent->type=(H5G_type_t)tmp; /* decode scratch-pad */ switch (ent->type) { case H5G_NOTHING_CACHED: break; case H5G_CACHED_STAB: assert(2 * H5F_SIZEOF_ADDR(f) <= H5G_SIZEOF_SCRATCH); H5F_addr_decode(f, pp, &(ent->cache.stab.btree_addr)); H5F_addr_decode(f, pp, &(ent->cache.stab.heap_addr)); break; case H5G_CACHED_SLINK: UINT32DECODE (*pp, ent->cache.slink.lval_offset); break; default: HDabort(); } *pp = p_ret + H5G_SIZEOF_ENTRY(f); FUNC_LEAVE_NOAPI(SUCCEED); } /*------------------------------------------------------------------------- * Function: H5G_ent_encode_vec * * Purpose: Same as H5G_ent_encode() except it does it for an array of * symbol table entries. * * Errors: * SYM CANTENCODE Can't encode. * * Return: Success: Non-negative, with *pp pointing to the first byte * after the last symbol. * * Failure: Negative * * Programmer: Robb Matzke * matzke@llnl.gov * Jul 18 1997 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5G_ent_encode_vec(H5F_t *f, uint8_t **pp, const H5G_entry_t *ent, unsigned n) { unsigned u; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5G_ent_encode_vec, FAIL); /* check arguments */ assert(f); assert(pp); assert(ent); /* encode entries */ for (u = 0; u < n; u++) if (H5G_ent_encode(f, pp, ent + u) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "can't encode"); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5G_ent_encode * * Purpose: Encodes the specified symbol table entry into the buffer * pointed to by *pp. * * Errors: * * Return: Success: Non-negative, with *pp pointing to the first byte * after the symbol table entry. * * Failure: Negative * * Programmer: Robb Matzke * matzke@llnl.gov * Jul 18 1997 * * Modifications: * * Robb Matzke, 8 Aug 1997 * Writes zeros for the bytes that aren't used so the file doesn't * contain junk. * *------------------------------------------------------------------------- */ herr_t H5G_ent_encode(H5F_t *f, uint8_t **pp, const H5G_entry_t *ent) { uint8_t *p_ret = *pp + H5G_SIZEOF_ENTRY(f); FUNC_ENTER_NOAPI_NOFUNC(H5G_ent_encode); /* check arguments */ assert(f); assert(pp); if (ent) { /* encode header */ H5F_ENCODE_LENGTH(f, *pp, ent->name_off); H5F_addr_encode(f, pp, ent->header); UINT32ENCODE(*pp, ent->type); UINT32ENCODE(*pp, 0); /*reserved*/ /* encode scratch-pad */ switch (ent->type) { case H5G_NOTHING_CACHED: break; case H5G_CACHED_STAB: assert(2 * H5F_SIZEOF_ADDR(f) <= H5G_SIZEOF_SCRATCH); H5F_addr_encode(f, pp, ent->cache.stab.btree_addr); H5F_addr_encode(f, pp, ent->cache.stab.heap_addr); break; case H5G_CACHED_SLINK: UINT32ENCODE (*pp, ent->cache.slink.lval_offset); break; default: HDabort(); } } else { H5F_ENCODE_LENGTH(f, *pp, 0); H5F_addr_encode(f, pp, HADDR_UNDEF); UINT32ENCODE(*pp, H5G_NOTHING_CACHED); UINT32ENCODE(*pp, 0); /*reserved*/ } /* fill with zero */ while (*pp < p_ret) *(*pp)++ = 0; *pp = p_ret; FUNC_LEAVE_NOAPI(SUCCEED); } /*------------------------------------------------------------------------- * Function: H5G_ent_copy * * Purpose: Do a deep copy of symbol table entries * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu * * Date: August 2002 * * Comments: * * Modifications: * Quincey Koziol, Sept. 25, 2002: * - Changed source & destination parameters to match the rest * of the functions in the library. * - Added 'depth' parameter to determine how much of the group * entry structure we want to copy. The new depths are: * H5G_COPY_NULL - Copy all the fields from the * source to the destination, but set the destination's * user path and canonical path to NULL. * H5G_COPY_LIMITED - Copy all the fields from the * source to the destination, except for the user path * field, keeping it the same as its * previous value in the destination. * H5G_COPY_SHALLOW - Copy all the fields from the source * to the destination, including the user path and * canonical path. (Destination "takes ownership" of * user and canonical paths) * H5G_COPY_DEEP - Copy all the fields from the source to * the destination, deep copying the user and canonical * paths. * *------------------------------------------------------------------------- */ herr_t H5G_ent_copy(H5G_entry_t *dst, const H5G_entry_t *src, H5G_ent_copy_depth_t depth) { H5RS_str_t *tmp_user_path_r=NULL; /* Temporary string pointer for entry's user path */ FUNC_ENTER_NOAPI_NOFUNC(H5G_ent_copy); /* Check arguments */ assert(src); assert(dst); /* If the depth is "very shallow", keep the old entry's user path */ if(depth==H5G_COPY_LIMITED) { tmp_user_path_r=dst->user_path_r; if(dst->canon_path_r) H5RS_decr(dst->canon_path_r); } /* end if */ /* Copy the top level information */ HDmemcpy(dst,src,sizeof(H5G_entry_t)); /* Deep copy the names */ if(depth==H5G_COPY_DEEP) { dst->user_path_r=H5RS_dup(src->user_path_r); dst->canon_path_r=H5RS_dup(src->canon_path_r); } else if(depth==H5G_COPY_LIMITED) { dst->user_path_r=tmp_user_path_r; dst->canon_path_r=H5RS_dup(src->canon_path_r); } else if(depth==H5G_COPY_NULL) { dst->user_path_r=NULL; dst->canon_path_r=NULL; } else if(depth==H5G_COPY_SHALLOW) { #ifndef NDEBUG /* Discarding 'const' qualifier OK - QAK */ H5G_ent_reset((H5G_entry_t *)src); #endif /* NDEBUG */ } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED); } /*------------------------------------------------------------------------- * Function: H5G_ent_reset * * Purpose: Reset a symbol table entry to an empty state * * Return: Success: 0, Failure: -1 * * Programmer: Quincey Koziol, koziol@ncsa.uiuc.edu * * Date: August 2005 * * Comments: * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5G_ent_reset(H5G_entry_t *ent) { FUNC_ENTER_NOAPI_NOFUNC(H5G_ent_reset); /* Check arguments */ HDassert(ent); /* Clear the symbol table entry to an empty state */ HDmemset(ent, 0, sizeof(H5G_entry_t)); ent->header = HADDR_UNDEF; FUNC_LEAVE_NOAPI(SUCCEED); } /* end H5G_ent_reset() */ /*------------------------------------------------------------------------- * Function: H5G_ent_set_name * * Purpose: Set the name of a symbol entry OBJ, located at LOC * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu * * Date: August 22, 2002 * *------------------------------------------------------------------------- */ herr_t H5G_ent_set_name(H5G_entry_t *loc, H5G_entry_t *obj, const char *name) { size_t name_len; /* Length of name to append */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5G_ent_set_name, FAIL) assert(loc); assert(obj); assert(name); /* Reset the object's previous names, if they exist */ if(obj->user_path_r) { H5RS_decr(obj->user_path_r); obj->user_path_r=NULL; } /* end if */ if(obj->canon_path_r) { H5RS_decr(obj->canon_path_r); obj->canon_path_r=NULL; } /* end if */ obj->user_path_hidden=0; /* Get the length of the new name */ name_len = HDstrlen(name); /* Modify the object's user path, if a user path exists in the location */ if(loc->user_path_r) { const char *loc_user_path; /* Pointer to raw string for user path */ size_t user_path_len; /* Length of location's user path name */ char *new_user_path; /* Pointer to new user path */ /* Get the length of the strings involved */ user_path_len = H5RS_len(loc->user_path_r); /* Modify the object's user path */ /* Get the raw string for the user path */ loc_user_path=H5RS_get_str(loc->user_path_r); assert(loc_user_path); /* The location's user path already ends in a '/' separator */ if ('/'==loc_user_path[user_path_len-1]) { if (NULL==(new_user_path = H5FL_BLK_MALLOC(str_buf,user_path_len+name_len+1))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") HDstrcpy(new_user_path, loc_user_path); } /* end if */ /* The location's user path needs a separator */ else { if (NULL==(new_user_path = H5FL_BLK_MALLOC(str_buf,user_path_len+1+name_len+1))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") HDstrcpy(new_user_path, loc_user_path); HDstrcat(new_user_path, "/"); } /* end else */ /* Append the component's name */ HDstrcat(new_user_path, name); /* Give ownership of the user path to the entry */ obj->user_path_r=H5RS_own(new_user_path); assert(obj->user_path_r); } /* end if */ /* Modify the object's canonical path, if a canonical path exists in the location */ if(loc->canon_path_r) { const char *loc_canon_path; /* Pointer to raw string for canonical path */ size_t canon_path_len; /* Length of location's canonical path name */ char *new_canon_path; /* Pointer to new canonical path */ /* Get the length of the strings involved */ canon_path_len = H5RS_len(loc->canon_path_r); /* Modify the object's canonical path */ /* Get the raw string for the canonical path */ loc_canon_path=H5RS_get_str(loc->canon_path_r); assert(loc_canon_path); /* The location's canonical path already ends in a '/' separator */ if ('/'==loc_canon_path[canon_path_len-1]) { if (NULL==(new_canon_path = H5FL_BLK_MALLOC(str_buf,canon_path_len+name_len+1))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") HDstrcpy(new_canon_path, loc_canon_path); } /* end if */ /* The location's canonical path needs a separator */ else { if (NULL==(new_canon_path = H5FL_BLK_MALLOC(str_buf,canon_path_len+1+name_len+1))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") HDstrcpy(new_canon_path, loc_canon_path); HDstrcat(new_canon_path, "/"); } /* end else */ /* Append the component's name */ HDstrcat(new_canon_path, name); /* Give ownership of the canonical path to the entry */ obj->canon_path_r=H5RS_own(new_canon_path); assert(obj->canon_path_r); } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_ent_set_name() */ /*------------------------------------------------------------------------- * Function: H5G_ent_debug * * Purpose: Prints debugging information about a symbol table entry. * * Errors: * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 29 1997 * * Modifications: * Robb Matzke, 1999-07-28 * The HEAP argument is passed by value. *------------------------------------------------------------------------- */ herr_t H5G_ent_debug(H5F_t UNUSED *f, hid_t dxpl_id, const H5G_entry_t *ent, FILE * stream, int indent, int fwidth, haddr_t heap) { const char *lval = NULL; int nested_indent, nested_fwidth; FUNC_ENTER_NOAPI_NOFUNC(H5G_ent_debug); /* Calculate the indent & field width values for nested information */ nested_indent=indent+3; nested_fwidth=MAX(0,fwidth-3); HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, "Name offset into private heap:", (unsigned long) (ent->name_off)); HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "Object header address:", ent->header); HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Dirty:", ent->dirty ? "Yes" : "No"); HDfprintf(stream, "%*s%-*s ", indent, "", fwidth, "Cache info type:"); switch (ent->type) { case H5G_NOTHING_CACHED: HDfprintf(stream, "Nothing Cached\n"); break; case H5G_CACHED_STAB: HDfprintf(stream, "Symbol Table\n"); HDfprintf(stream, "%*s%-*s\n", indent, "", fwidth, "Cached entry information:"); HDfprintf(stream, "%*s%-*s %a\n", nested_indent, "", nested_fwidth, "B-tree address:", ent->cache.stab.btree_addr); HDfprintf(stream, "%*s%-*s %a\n", nested_indent, "", nested_fwidth, "Heap address:", ent->cache.stab.heap_addr); break; case H5G_CACHED_SLINK: HDfprintf (stream, "Symbolic Link\n"); HDfprintf(stream, "%*s%-*s\n", indent, "", fwidth, "Cached information:"); HDfprintf (stream, "%*s%-*s %lu\n", nested_indent, "", nested_fwidth, "Link value offset:", (unsigned long)(ent->cache.slink.lval_offset)); if (heap>0 && H5F_addr_defined(heap)) { const H5HL_t *heap_ptr; heap_ptr = H5HL_protect(ent->file, dxpl_id, heap); lval = H5HL_offset_into(ent->file, heap_ptr, ent->cache.slink.lval_offset); HDfprintf (stream, "%*s%-*s %s\n", nested_indent, "", nested_fwidth, "Link value:", lval); H5HL_unprotect(ent->file, dxpl_id, heap_ptr, heap); } else HDfprintf(stream, "%*s%-*s\n", nested_indent, "", nested_fwidth, "Warning: Invalid heap address given, name not displayed!"); break; default: HDfprintf(stream, "*** Unknown symbol type %d\n", ent->type); break; } FUNC_LEAVE_NOAPI(SUCCEED); } xdmf-3.0+git20160803/Utilities/hdf5/H5Zpkg.h0000640000175000017500000000351413003006557020157 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #ifndef H5Z_PACKAGE #error "Do not include this file outside the H5Z package!" #endif #ifndef _H5Zpkg_H #define _H5Zpkg_H /* Include private header file */ #include "H5Zprivate.h" /* Filter functions */ #ifdef H5_HAVE_FILTER_DEFLATE /* * Deflate filter */ H5_DLLVAR const H5Z_class_t H5Z_DEFLATE[1]; #endif /* H5_HAVE_FILTER_DEFLATE */ #ifdef H5_HAVE_FILTER_SHUFFLE /* * Shuffle filter */ H5_DLLVAR const H5Z_class_t H5Z_SHUFFLE[1]; #endif /* H5_HAVE_FILTER_SHUFFLE */ #ifdef H5_HAVE_FILTER_FLETCHER32 /* * Fletcher32 filter */ H5_DLLVAR const H5Z_class_t H5Z_FLETCHER32[1]; #endif /* H5_HAVE_FILTER_FLETCHER32 */ #ifdef H5_HAVE_FILTER_SZIP /* * szip filter */ H5_DLLVAR const H5Z_class_t H5Z_SZIP[1]; #endif /* H5_HAVE_FILTER_SZIP */ /* Package-local function prototypes */ #endif /* _H5Zpkg_H */ xdmf-3.0+git20160803/Utilities/hdf5/H5Sselect.c0000640000175000017500000015233113003006557020643 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* Programmer: Quincey Koziol * Friday, May 29, 1998 * * Purpose: Dataspace selection functions. */ #define H5S_PACKAGE /*suppress error about including H5Spkg */ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free Lists */ #include "H5Iprivate.h" /* IDs */ #include "H5Spkg.h" /* Dataspaces */ #include "H5Vprivate.h" /* Vector and array functions */ /* Local functions */ #ifdef LATER static herr_t H5S_select_iter_block (const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end); static htri_t H5S_select_iter_has_next_block (const H5S_sel_iter_t *iter); static herr_t H5S_select_iter_next_block(H5S_sel_iter_t *iter); #endif /* LATER */ /* Declare a free list to manage blocks of single datatype element data */ H5FL_BLK_EXTERN(type_elem); /*-------------------------------------------------------------------------- NAME H5S_select_offset PURPOSE Set the selection offset for a datapace USAGE herr_t H5S_select_offset(space, offset) H5S_t *space; IN/OUT: Dataspace object to set selection offset const hssize_t *offset; IN: Offset to position the selection at RETURNS Non-negative on success/Negative on failure DESCRIPTION Sets the selection offset for the dataspace GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS Only works for simple dataspaces currently EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5S_select_offset(H5S_t *space, const hssize_t *offset) { FUNC_ENTER_NOAPI_NOFUNC(H5S_select_offset); /* Check args */ assert(space); assert(space->extent.rank); assert(offset); /* Copy the offset over */ HDmemcpy(space->select.offset,offset,sizeof(hssize_t)*space->extent.rank); FUNC_LEAVE_NOAPI(SUCCEED); } /* H5S_select_offset() */ /*-------------------------------------------------------------------------- NAME H5S_select_copy PURPOSE Copy a selection from one dataspace to another USAGE herr_t H5S_select_copy(dst, src) H5S_t *dst; OUT: Pointer to the destination dataspace H5S_t *src; IN: Pointer to the source dataspace RETURNS Non-negative on success/Negative on failure DESCRIPTION Copies all the selection information (include offset) from the source dataspace to the destination dataspace. If the SHARE_SELECTION flag is set, then the selection can be shared between the source and destination dataspaces. (This should only occur in situations where the destination dataspace will immediately change to a new selection) GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5S_select_copy (H5S_t *dst, const H5S_t *src, hbool_t share_selection) { herr_t ret_value; /* return value */ FUNC_ENTER_NOAPI(H5S_select_copy, FAIL); /* Check args */ assert(dst); assert(src); /* Copy regular fields */ dst->select=src->select; /* Perform correct type of copy based on the type of selection */ if((ret_value=(*src->select.type->copy)(dst,src,share_selection))<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy selection specific information"); done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_select_copy() */ /*------------------------------------------------------------------------- * Function: H5S_select_release * * Purpose: Releases all memory associated with a dataspace selection. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Friday, May 30, 2003 * * Note: This routine participates in the "Inlining C function pointers" * pattern, don't call it directly, use the appropriate macro * defined in H5Sprivate.h. * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5S_select_release(H5S_t *ds) { herr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOFUNC(H5S_select_release); assert(ds); /* Call the selection type's release function */ ret_value=(*ds->select.type->release)(ds); FUNC_LEAVE_NOAPI(ret_value); } /* end H5S_select_release() */ /*------------------------------------------------------------------------- * Function: H5S_select_get_seq_list * * Purpose: Retrieves the next sequence of offset/length pairs for an * iterator on a dataspace * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Tuesday, May 18, 2004 * * Note: This routine participates in the "Inlining C function pointers" * pattern, don't call it directly, use the appropriate macro * defined in H5Sprivate.h. * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5S_select_get_seq_list(const H5S_t *space, unsigned flags, H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes, size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len) { herr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOFUNC(H5S_select_get_seq_list); assert(space); /* Call the selection type's get_seq_list function */ ret_value=(*space->select.type->get_seq_list)(space,flags,iter,maxseq,maxbytes,nseq,nbytes,off,len); FUNC_LEAVE_NOAPI(ret_value); } /* end H5S_select_get_seq_list() */ /*------------------------------------------------------------------------- * Function: H5S_select_serial_size * * Purpose: Determines the number of bytes required to store the current * selection * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Tuesday, May 18, 2004 * * Note: This routine participates in the "Inlining C function pointers" * pattern, don't call it directly, use the appropriate macro * defined in H5Sprivate.h. * * Modifications: * *------------------------------------------------------------------------- */ hssize_t H5S_select_serial_size(const H5S_t *space) { hssize_t ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOFUNC(H5S_select_serial_size); assert(space); /* Call the selection type's serial_size function */ ret_value=(*space->select.type->serial_size)(space); FUNC_LEAVE_NOAPI(ret_value); } /* end H5S_select_serial_size() */ /*-------------------------------------------------------------------------- NAME H5S_select_serialize PURPOSE Serialize the selection for a dataspace into a buffer USAGE herr_t H5S_select_serialize(space, buf) const H5S_t *space; IN: Dataspace with selection to serialize uint8_t *buf; OUT: Buffer to put serialized selection RETURNS Non-negative on success/Negative on failure DESCRIPTION Calls the appropriate dataspace selection callback to serialize the current selection into a buffer. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS This routine participates in the "Inlining C function pointers" pattern, don't call it directly, use the appropriate macro defined in H5Sprivate.h. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5S_select_serialize(const H5S_t *space, uint8_t *buf) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOFUNC(H5S_select_serialize); assert(space); assert(buf); /* Call the selection type's serialize function */ ret_value=(*space->select.type->serialize)(space,buf); FUNC_LEAVE_NOAPI(ret_value); } /* end H5S_select_serialize() */ /*-------------------------------------------------------------------------- NAME H5Sget_select_npoints PURPOSE Get the number of elements in current selection USAGE hssize_t H5Sget_select_npoints(dsid) hid_t dsid; IN: Dataspace ID of selection to query RETURNS Non-negative on success/Negative on failure DESCRIPTION Returns the number of elements in current selection for dataspace. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ hssize_t H5Sget_select_npoints(hid_t spaceid) { H5S_t *space = NULL; /* Dataspace to modify selection of */ hssize_t ret_value; /* return value */ FUNC_ENTER_API(H5Sget_select_npoints, FAIL); H5TRACE1("Hs","i",spaceid); /* Check args */ if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace"); ret_value = H5S_GET_SELECT_NPOINTS(space); done: FUNC_LEAVE_API(ret_value); } /* H5Sget_select_npoints() */ /*-------------------------------------------------------------------------- NAME H5S_get_select_npoints PURPOSE Get the number of elements in current selection USAGE hssize_t H5Sget_select_npoints(space) H5S_t *space; IN: Dataspace of selection to query RETURNS The number of elements in selection on success, 0 on failure DESCRIPTION Returns the number of elements in current selection for dataspace. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS This routine participates in the "Inlining C function pointers" pattern, don't call it directly, use the appropriate macro defined in H5Sprivate.h. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ hssize_t H5S_get_select_npoints(const H5S_t *space) { FUNC_ENTER_NOAPI_NOFUNC(H5S_get_select_npoints); /* Check args */ assert(space); FUNC_LEAVE_NOAPI(space->select.num_elem); } /* H5S_get_select_npoints() */ /*-------------------------------------------------------------------------- NAME H5Sselect_valid PURPOSE Check whether the selection fits within the extent, with the current offset defined. USAGE htri_t H5Sselect_void(dsid) hid_t dsid; IN: Dataspace ID to query RETURNS TRUE if the selection fits within the extent, FALSE if it does not and Negative on an error. DESCRIPTION Determines if the current selection at the current offet fits within the extent for the dataspace. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ htri_t H5Sselect_valid(hid_t spaceid) { H5S_t *space = NULL; /* Dataspace to modify selection of */ htri_t ret_value; /* return value */ FUNC_ENTER_API(H5Sselect_valid, 0); H5TRACE1("t","i",spaceid); /* Check args */ if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a dataspace"); ret_value = H5S_SELECT_VALID(space); done: FUNC_LEAVE_API(ret_value); } /* H5Sselect_valid() */ /*-------------------------------------------------------------------------- NAME H5S_select_valid PURPOSE Check whether the selection fits within the extent, with the current offset defined. USAGE htri_t H5S_select_void(space) H5S_t *space; IN: Dataspace to query RETURNS TRUE if the selection fits within the extent, FALSE if it does not and Negative on an error. DESCRIPTION Determines if the current selection at the current offet fits within the extent for the dataspace. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS This routine participates in the "Inlining C function pointers" pattern, don't call it directly, use the appropriate macro defined in H5Sprivate.h. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ htri_t H5S_select_valid(const H5S_t *space) { htri_t ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOFUNC(H5S_select_valid); assert(space); ret_value = (*space->select.type->is_valid)(space); FUNC_LEAVE_NOAPI(ret_value); } /* H5S_select_valid() */ /*-------------------------------------------------------------------------- NAME H5S_select_deserialize PURPOSE Deserialize the current selection from a user-provided buffer into a real selection in the dataspace. USAGE herr_t H5S_select_deserialize(space, buf) H5S_t *space; IN/OUT: Dataspace pointer to place selection into uint8 *buf; IN: Buffer to retrieve serialized selection from RETURNS Non-negative on success/Negative on failure DESCRIPTION Deserializes the current selection into a buffer. (Primarily for retrieving from disk). This routine just hands off to the appropriate routine for each type of selection. The format of the serialized information is shown in the H5S_select_serialize() header. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5S_select_deserialize (H5S_t *space, const uint8_t *buf) { const uint8_t *tbuf; /* Temporary pointer to the selection type */ uint32_t sel_type; /* Pointer to the selection type */ herr_t ret_value=FAIL; /* return value */ FUNC_ENTER_NOAPI(H5S_select_deserialize, FAIL); assert(space); tbuf=buf; UINT32DECODE(tbuf, sel_type); switch(sel_type) { case H5S_SEL_POINTS: /* Sequence of points selected */ ret_value=(*H5S_sel_point->deserialize)(space,buf); break; case H5S_SEL_HYPERSLABS: /* Hyperslab selection defined */ ret_value=(*H5S_sel_hyper->deserialize)(space,buf); break; case H5S_SEL_ALL: /* Entire extent selected */ ret_value=(*H5S_sel_all->deserialize)(space,buf); break; case H5S_SEL_NONE: /* Nothing selected */ ret_value=(*H5S_sel_none->deserialize)(space,buf); break; default: break; } if(ret_value<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTLOAD, FAIL, "can't deserialize selection"); done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_select_deserialize() */ /*-------------------------------------------------------------------------- NAME H5Sget_select_bounds PURPOSE Gets the bounding box containing the selection. USAGE herr_t H5S_get_select_bounds(space, start, end) hid_t dsid; IN: Dataspace ID of selection to query hsize_t *start; OUT: Starting coordinate of bounding box hsize_t *end; OUT: Opposite coordinate of bounding box RETURNS Non-negative on success, negative on failure DESCRIPTION Retrieves the bounding box containing the current selection and places it into the user's buffers. The start and end buffers must be large enough to hold the dataspace rank number of coordinates. The bounding box exactly contains the selection, ie. if a 2-D element selection is currently defined with the following points: (4,5), (6,8) (10,7), the bounding box with be (4, 5), (10, 8). Calling this function on a "none" selection returns fail. The bounding box calculations _does_ include the current offset of the selection within the dataspace extent. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS This routine participates in the "Inlining C function pointers" pattern, don't call it directly, use the appropriate macro defined in H5Sprivate.h. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5Sget_select_bounds(hid_t spaceid, hsize_t *start, hsize_t *end) { H5S_t *space = NULL; /* Dataspace to modify selection of */ herr_t ret_value; /* return value */ FUNC_ENTER_API(H5Sget_select_bounds, FAIL); H5TRACE3("e","i*h*h",spaceid,start,end); /* Check args */ if(start==NULL || end==NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pointer"); if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace"); ret_value = H5S_SELECT_BOUNDS(space,start,end); done: FUNC_LEAVE_API(ret_value); } /* H5Sget_select_bounds() */ /*-------------------------------------------------------------------------- NAME H5S_get_select_bounds PURPOSE Gets the bounding box containing the selection. USAGE herr_t H5S_get_select_bounds(space, start, end) H5S_t *space; IN: Dataspace ID of selection to query hsize_t *start; OUT: Starting coordinate of bounding box hsize_t *end; OUT: Opposite coordinate of bounding box RETURNS Non-negative on success, negative on failure DESCRIPTION Retrieves the bounding box containing the current selection and places it into the user's buffers. The start and end buffers must be large enough to hold the dataspace rank number of coordinates. The bounding box exactly contains the selection, ie. if a 2-D element selection is currently defined with the following points: (4,5), (6,8) (10,7), the bounding box with be (4, 5), (10, 8). Calling this function on a "none" selection returns fail. The bounding box calculations _does_ include the current offset of the selection within the dataspace extent. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5S_get_select_bounds(const H5S_t *space, hsize_t *start, hsize_t *end) { herr_t ret_value; /* return value */ FUNC_ENTER_NOAPI_NOFUNC(H5S_get_select_bounds); /* Check args */ assert(space); assert(start); assert(end); ret_value = (*space->select.type->bounds)(space,start,end); FUNC_LEAVE_NOAPI(ret_value); } /* H5S_get_select_bounds() */ /*-------------------------------------------------------------------------- NAME H5S_select_is_contiguous PURPOSE Determines if a selection is contiguous in the dataspace USAGE htri_t H5S_select_is_contiguous(space) const H5S_t *space; IN: Dataspace of selection to query RETURNS Non-negative (TRUE/FALSE) on success, negative on failure DESCRIPTION Checks the selection to determine if the points to iterated over will be contiguous in the particular dataspace. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS This routine participates in the "Inlining C function pointers" pattern, don't call it directly, use the appropriate macro defined in H5Sprivate.h. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ htri_t H5S_select_is_contiguous(const H5S_t *space) { herr_t ret_value; /* return value */ FUNC_ENTER_NOAPI_NOFUNC(H5S_select_is_contiguous); /* Check args */ assert(space); ret_value = (*space->select.type->is_contiguous)(space); FUNC_LEAVE_NOAPI(ret_value); } /* H5S_select_is_contiguous() */ /*-------------------------------------------------------------------------- NAME H5S_select_is_single PURPOSE Determines if a selection is a single block in the dataspace USAGE htri_t H5S_select_is_single(space) const H5S_t *space; IN: Dataspace of selection to query RETURNS Non-negative (TRUE/FALSE) on success, negative on failure DESCRIPTION Checks the selection to determine if it occupies a single block in the particular dataspace. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS This routine participates in the "Inlining C function pointers" pattern, don't call it directly, use the appropriate macro defined in H5Sprivate.h. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ htri_t H5S_select_is_single(const H5S_t *space) { herr_t ret_value; /* return value */ FUNC_ENTER_NOAPI_NOFUNC(H5S_select_is_single); /* Check args */ assert(space); ret_value = (*space->select.type->is_single)(space); FUNC_LEAVE_NOAPI(ret_value); } /* H5S_select_is_single() */ /*-------------------------------------------------------------------------- NAME H5S_select_is_regular PURPOSE Determines if a selection is "regular" in the dataspace USAGE htri_t H5S_select_is_regular(space) const H5S_t *space; IN: Dataspace of selection to query RETURNS Non-negative (TRUE/FALSE) on success, negative on failure DESCRIPTION Checks the selection to determine if it is "regular" (i.e. a single block or a strided pattern) in the particular dataspace. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS This routine participates in the "Inlining C function pointers" pattern, don't call it directly, use the appropriate macro defined in H5Sprivate.h. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ htri_t H5S_select_is_regular(const H5S_t *space) { herr_t ret_value; /* return value */ FUNC_ENTER_NOAPI_NOFUNC(H5S_select_is_regular); /* Check args */ assert(space); ret_value = (*space->select.type->is_regular)(space); FUNC_LEAVE_NOAPI(ret_value); } /* H5S_select_is_regular() */ /*-------------------------------------------------------------------------- NAME H5S_select_iter_init PURPOSE Initializes iteration information for a selection. USAGE herr_t H5S_select_iter_init(sel_iter, space, elmt_size) H5S_sel_iter_t *sel_iter; OUT: Selection iterator to initialize. H5S_t *space; IN: Dataspace object containing selection to iterate over size_t elmt_size; IN: Size of elements in the selection RETURNS Non-negative on success, negative on failure. DESCRIPTION Initialize the selection iterator object to point to the first element in the dataspace's selection. --------------------------------------------------------------------------*/ herr_t H5S_select_iter_init(H5S_sel_iter_t *sel_iter, const H5S_t *space, size_t elmt_size) { herr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOFUNC(H5S_select_iter_init); /* Check args */ assert(sel_iter); assert(space); /* Initialize common information */ /* Save the dataspace's rank */ sel_iter->rank=space->extent.rank; if(sel_iter->rank>0) { /* Point to the dataspace dimensions */ sel_iter->dims=space->extent.size; } /* end if */ else sel_iter->dims = NULL; /* Save the element size */ sel_iter->elmt_size=elmt_size; /* Call initialization routine for selection type */ ret_value= (*space->select.type->iter_init)(sel_iter, space); FUNC_LEAVE_NOAPI(ret_value); } /* H5S_select_iter_init() */ /*-------------------------------------------------------------------------- NAME H5S_select_iter_coords PURPOSE Get the coordinates of the current iterator position USAGE herr_t H5S_select_iter_coords(sel_iter,coords) H5S_sel_iter_t *sel_iter; IN: Selection iterator to query hsize_t *coords; OUT: Array to place iterator coordinates in RETURNS Non-negative on success, negative on failure. DESCRIPTION The current location of the iterator within the selection is placed in the COORDS array. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS This routine participates in the "Inlining C function pointers" pattern, don't call it directly, use the appropriate macro defined in H5Sprivate.h. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5S_select_iter_coords (const H5S_sel_iter_t *sel_iter, hsize_t *coords) { herr_t ret_value; /* return value */ FUNC_ENTER_NOAPI_NOFUNC(H5S_select_iter_coords); /* Check args */ assert(sel_iter); assert(coords); /* Call iter_coords routine for selection type */ ret_value = (*sel_iter->type->iter_coords)(sel_iter,coords); FUNC_LEAVE_NOAPI(ret_value); } /* H5S_select_iter_coords() */ #ifdef LATER /*-------------------------------------------------------------------------- NAME H5S_select_iter_block PURPOSE Get the block of the current iterator position USAGE herr_t H5S_select_iter_block(sel_iter,start,end) const H5S_sel_iter_t *sel_iter; IN: Selection iterator to query hsize_t *start; OUT: Array to place iterator start block coordinates hsize_t *end; OUT: Array to place iterator end block coordinates RETURNS Non-negative on success, negative on failure. DESCRIPTION The current location of the iterator within the selection is placed in the COORDS array. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS This routine participates in the "Inlining C function pointers" pattern, don't call it directly, use the appropriate macro defined in H5Sprivate.h. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_select_iter_block (const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end) { herr_t ret_value; /* return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_select_iter_block); /* Check args */ assert(iter); assert(start); assert(end); /* Call iter_block routine for selection type */ ret_value = (*iter->type->iter_block)(iter,start,end); FUNC_LEAVE_NOAPI(ret_value); } /* H5S_select_iter_block() */ #endif /* LATER */ /*-------------------------------------------------------------------------- NAME H5S_select_iter_nelmts PURPOSE Get the number of elements left to iterate over in selection USAGE hssize_t H5S_select_iter_nelmts(sel_iter) H5S_sel_iter_t *sel_iter; IN: Selection iterator to query RETURNS The number of elements in selection on success, 0 on failure DESCRIPTION Returns the number of elements in current selection for dataspace. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS This routine participates in the "Inlining C function pointers" pattern, don't call it directly, use the appropriate macro defined in H5Sprivate.h. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ hsize_t H5S_select_iter_nelmts (const H5S_sel_iter_t *sel_iter) { hsize_t ret_value; /* return value */ FUNC_ENTER_NOAPI_NOFUNC(H5S_select_iter_nelmts); /* Check args */ assert(sel_iter); /* Call iter_nelmts routine for selection type */ ret_value = (*sel_iter->type->iter_nelmts)(sel_iter); FUNC_LEAVE_NOAPI(ret_value); } /* H5S_select_iter_nelmts() */ #ifdef LATER /*-------------------------------------------------------------------------- NAME H5S_select_iter_has_next_block PURPOSE Check if there is another block available in the selection iterator USAGE htri_t H5S_select_iter_has_next_block(sel_iter) const H5S_sel_iter_t *sel_iter; IN: Selection iterator to query RETURNS Non-negative on success, negative on failure. DESCRIPTION Check if there is another block available to advance to in the selection iterator. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS This routine participates in the "Inlining C function pointers" pattern, don't call it directly, use the appropriate macro defined in H5Sprivate.h. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static htri_t H5S_select_iter_has_next_block (const H5S_sel_iter_t *iter) { herr_t ret_value; /* return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_select_iter_has_next_block); /* Check args */ assert(iter); /* Call iter_has_next_block routine for selection type */ ret_value = (*iter->type->iter_has_next_block)(iter); FUNC_LEAVE_NOAPI(ret_value); } /* H5S_select_iter_has_next_block() */ #endif /* LATER */ /*-------------------------------------------------------------------------- NAME H5S_select_iter_next PURPOSE Advance selection iterator to next element USAGE herr_t H5S_select_iter_next(iter, nelem) H5S_sel_iter_t *iter; IN/OUT: Selection iterator to change size_t nelem; IN: Number of elements to advance by RETURNS Non-negative on success, negative on failure. DESCRIPTION Move the current element for the selection iterator to the NELEM'th next element in the selection. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS This routine participates in the "Inlining C function pointers" pattern, don't call it directly, use the appropriate macro defined in H5Sprivate.h. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5S_select_iter_next(H5S_sel_iter_t *iter, size_t nelem) { herr_t ret_value; /* return value */ FUNC_ENTER_NOAPI_NOFUNC(H5S_select_iter_next); /* Check args */ assert(iter); assert(nelem>0); /* Call iter_next routine for selection type */ ret_value = (*iter->type->iter_next)(iter,nelem); /* Decrement the number of elements left in selection */ iter->elmt_left-=nelem; FUNC_LEAVE_NOAPI(ret_value); } /* H5S_select_iter_next() */ #ifdef LATER /*-------------------------------------------------------------------------- NAME H5S_select_iter_next_block PURPOSE Advance selection iterator to next block USAGE herr_t H5S_select_iter_next_block(iter) H5S_sel_iter_t *iter; IN/OUT: Selection iterator to change RETURNS Non-negative on success, negative on failure. DESCRIPTION Move the current element for the selection iterator to the next block in the selection. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS Doesn't maintain the 'elmt_left' field of the selection iterator. This routine participates in the "Inlining C function pointers" pattern, don't call it directly, use the appropriate macro defined in H5Sprivate.h. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_select_iter_next_block(H5S_sel_iter_t *iter) { herr_t ret_value; /* return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_select_iter_next_block); /* Check args */ assert(iter); /* Call iter_next_block routine for selection type */ ret_value = (*iter->type->iter_next_block)(iter); FUNC_LEAVE_NOAPI(ret_value); } /* H5S_select_iter_next_block() */ #endif /* LATER */ /*-------------------------------------------------------------------------- NAME H5S_select_iter_release PURPOSE Release a selection iterator's resources. USAGE hssize_t H5S_select_iter_release(sel_iter) H5S_sel_iter_t *sel_iter; IN: Selection iterator to query RETURNS The number of elements in selection on success, 0 on failure DESCRIPTION Returns the number of elements in current selection for dataspace. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS This routine participates in the "Inlining C function pointers" pattern, don't call it directly, use the appropriate macro defined in H5Sprivate.h. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5S_select_iter_release(H5S_sel_iter_t *sel_iter) { herr_t ret_value; /* return value */ FUNC_ENTER_NOAPI_NOFUNC(H5S_select_iter_release); /* Check args */ assert(sel_iter); /* Call selection type-specific release routine */ ret_value = (*sel_iter->type->iter_release)(sel_iter); FUNC_LEAVE_NOAPI(ret_value); } /* H5S_select_iter_release() */ /*-------------------------------------------------------------------------- NAME H5S_select_iterate PURPOSE Iterate over the selected elements in a memory buffer. USAGE herr_t H5S_select_iterate(buf, type_id, space, operator, operator_data) void *buf; IN/OUT: Buffer containing elements to iterate over hid_t type_id; IN: Datatype ID of BUF array. H5S_t *space; IN: Dataspace object containing selection to iterate over H5D_operator_t op; IN: Function pointer to the routine to be called for each element in BUF iterated over. void *operator_data; IN/OUT: Pointer to any user-defined data associated with the operation. RETURNS Returns the return value of the last operator if it was non-zero, or zero if all elements were processed. Otherwise returns a negative value. DESCRIPTION Iterates over the selected elements in a memory buffer, calling the user's callback function for each element. The selection in the dataspace is modified so that any elements already iterated over are removed from the selection if the iteration is interrupted (by the H5D_operator_t function returning non-zero) in the "middle" of the iteration and may be re-started by the user where it left off. NOTE: Until "subtracting" elements from a selection is implemented, the selection is not modified. --------------------------------------------------------------------------*/ herr_t H5S_select_iterate(void *buf, hid_t type_id, const H5S_t *space, H5D_operator_t op, void *operator_data) { H5T_t *dt; /* Datatype structure */ H5S_sel_iter_t iter; /* Selection iteration info */ hbool_t iter_init=0; /* Selection iteration info has been initialized */ uint8_t *loc; /* Current element location in buffer */ hsize_t coords[H5O_LAYOUT_NDIMS]; /* Coordinates of element in dataspace */ hssize_t nelmts; /* Number of elements in selection */ hsize_t space_size[H5O_LAYOUT_NDIMS]; /* Dataspace size */ hsize_t off[H5D_XFER_HYPER_VECTOR_SIZE_DEF]; /* Array to store sequence offsets */ hsize_t curr_off; /* Current offset within sequence */ hsize_t tmp_off; /* Temporary offset within sequence */ size_t len[H5D_XFER_HYPER_VECTOR_SIZE_DEF]; /* Array to store sequence lengths */ size_t curr_len; /* Length of bytes left to process in sequence */ size_t nseq; /* Number of sequences generated */ size_t curr_seq; /* Current sequnce being worked on */ size_t nelem; /* Number of elements used in sequences */ size_t max_elem; /* Maximum number of elements allowed in sequences */ size_t elmt_size; /* Datatype size */ unsigned ndims; /* Number of dimensions in dataspace */ int i; /* Local Index variable */ herr_t user_ret=0; /* User's return value */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5S_select_iterate, FAIL); /* Check args */ assert(buf); assert(H5I_DATATYPE == H5I_get_type(type_id)); assert(space); assert(op); /* Get the datatype size */ if (NULL==(dt=H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an valid base datatype"); if((elmt_size=H5T_get_size(dt))==0) HGOTO_ERROR(H5E_DATATYPE, H5E_BADSIZE, FAIL, "datatype size invalid"); /* Initialize iterator */ if (H5S_select_iter_init(&iter, space, elmt_size)<0) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator"); iter_init=1; /* Selection iteration info has been initialized */ /* Get the number of elements in selection */ if((nelmts = H5S_GET_SELECT_NPOINTS(space))<0) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTCOUNT, FAIL, "can't get number of elements selected"); /* Get the rank of the dataspace */ ndims=space->extent.rank; if (ndims > 0){ /* Copy the size of the space */ assert(space->extent.size); HDmemcpy(space_size, space->extent.size, ndims*sizeof(hsize_t)); } space_size[ndims]=elmt_size; /* Compute the maximum number of bytes required */ H5_ASSIGN_OVERFLOW(max_elem,nelmts,hssize_t,size_t); /* Loop, while elements left in selection */ while(max_elem>0 && user_ret==0) { /* Get the sequences of bytes */ if(H5S_SELECT_GET_SEQ_LIST(space,0,&iter,H5D_XFER_HYPER_VECTOR_SIZE_DEF,max_elem,&nseq,&nelem,off,len)<0) HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed"); /* Loop, while sequences left to process */ for(curr_seq=0; curr_seq0 && user_ret==0) { /* Compute the coordinate from the offset */ for(i=ndims, tmp_off=curr_off; i>=0; i--) { coords[i]=tmp_off%space_size[i]; tmp_off/=space_size[i]; } /* end for */ /* Get the location within the user's buffer */ loc=(unsigned char *)buf+curr_off; /* Call user's callback routine */ user_ret=(*op)(loc,type_id,ndims,coords,operator_data); /* Increment offset in dataspace */ curr_off+=elmt_size; /* Decrement number of bytes left in sequence */ curr_len-=elmt_size; } /* end while */ } /* end for */ /* Decrement number of elements left to process */ max_elem-=nelem; } /* end while */ /* Set return value */ ret_value=user_ret; done: /* Release selection iterator */ if(iter_init) { if (H5S_SELECT_ITER_RELEASE(&iter)<0) HDONE_ERROR (H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator"); } /* end if */ FUNC_LEAVE_NOAPI(ret_value); } /* end H5S_select_iterate() */ /*-------------------------------------------------------------------------- NAME H5Sget_select_type PURPOSE Retrieve the type of selection in a dataspace USAGE H5S_sel_type H5Sget_select_type(space_id) hid_t space_id; IN: Dataspace object to query RETURNS Non-negative on success/Negative on failure. Return value is from the set of values in the H5S_sel_type enumerated type. DESCRIPTION This function retrieves the type of selection currently defined for a dataspace. --------------------------------------------------------------------------*/ H5S_sel_type H5Sget_select_type(hid_t space_id) { H5S_t *space = NULL; /* dataspace to modify */ H5S_sel_type ret_value; /* Return value */ FUNC_ENTER_API(H5Sget_select_type, H5S_SEL_ERROR); H5TRACE1("St","i",space_id); /* Check args */ if (NULL == (space = H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5S_SEL_ERROR, "not a dataspace"); /* Set return value */ ret_value=H5S_GET_SELECT_TYPE(space); done: FUNC_LEAVE_API(ret_value); } /* end H5Sget_select_type() */ /*-------------------------------------------------------------------------- NAME H5S_get_select_type PURPOSE Retrieve the type of selection in a dataspace USAGE H5S_sel_type H5Sget_select_type(space) const H5S_t *space; IN: Dataspace object to query RETURNS Non-negative on success/Negative on failure. Return value is from the set of values in the H5S_sel_type enumerated type. DESCRIPTION This function retrieves the type of selection currently defined for a dataspace. COMMENTS This routine participates in the "Inlining C function pointers" pattern, don't call it directly, use the appropriate macro defined in H5Sprivate.h. --------------------------------------------------------------------------*/ H5S_sel_type H5S_get_select_type(const H5S_t *space) { H5S_sel_type ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOFUNC(H5S_get_select_type); /* Check args */ assert(space); /* Set return value */ ret_value=H5S_GET_SELECT_TYPE(space); FUNC_LEAVE_NOAPI(ret_value); } /* end H5S_get_select_type() */ /*-------------------------------------------------------------------------- NAME H5S_select_shape_same PURPOSE Check if two selections are the same shape USAGE htri_t H5S_select_shape_same(space1, space2) const H5S_t *space1; IN: 1st Dataspace pointer to compare const H5S_t *space2; IN: 2nd Dataspace pointer to compare RETURNS TRUE/FALSE/FAIL DESCRIPTION Checks to see if the current selection in the dataspaces are the same dimensionality and shape. This is primarily used for reading the entire selection in one swoop. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS Assumes that there is only a single "block" for hyperslab selections. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ htri_t H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2) { H5S_sel_iter_t iter1; /* Selection #1 iteration info */ H5S_sel_iter_t iter2; /* Selection #2 iteration info */ hbool_t iter1_init=0; /* Selection #1 iteration info has been initialized */ hbool_t iter2_init=0; /* Selection #2 iteration info has been initialized */ unsigned u; /* Index variable */ htri_t ret_value=TRUE; /* return value */ FUNC_ENTER_NOAPI(H5S_select_shape_same, FAIL); /* Check args */ assert(space1); assert(space2); /* Check for different dimensionality */ if (space1->extent.rank!=space2->extent.rank) HGOTO_DONE(FALSE); /* Check for different number of elements selected */ if(H5S_GET_SELECT_NPOINTS(space1)!=H5S_GET_SELECT_NPOINTS(space2)) HGOTO_DONE(FALSE); /* Check for "easy" cases before getting into generalized block iteration code */ if(H5S_GET_SELECT_TYPE(space1)==H5S_SEL_ALL && H5S_GET_SELECT_TYPE(space2)==H5S_SEL_ALL) { hsize_t dims1[H5O_LAYOUT_NDIMS]; /* End point of selection block in dataspace #1 */ hsize_t dims2[H5O_LAYOUT_NDIMS]; /* End point of selection block in dataspace #2 */ if(H5S_get_simple_extent_dims(space1, dims1, NULL)<0) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get dimensionality"); if(H5S_get_simple_extent_dims(space2, dims2, NULL)<0) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get dimensionality"); /* Check that the sizes are the same */ for (u=0; uextent.rank; u++) if(dims1[u]!=dims2[u]) HGOTO_DONE(FALSE); } /* end if */ else if(H5S_GET_SELECT_TYPE(space1)==H5S_SEL_NONE || H5S_GET_SELECT_TYPE(space2)==H5S_SEL_NONE) { HGOTO_DONE(TRUE); } /* end if */ else if((H5S_GET_SELECT_TYPE(space1)==H5S_SEL_HYPERSLABS && space1->select.sel_info.hslab->diminfo_valid) && (H5S_GET_SELECT_TYPE(space2)==H5S_SEL_HYPERSLABS && space2->select.sel_info.hslab->diminfo_valid)) { /* Check that the shapes are the same */ for (u=0; uextent.rank; u++) { if(space1->select.sel_info.hslab->opt_diminfo[u].stride!=space2->select.sel_info.hslab->opt_diminfo[u].stride) HGOTO_DONE(FALSE); if(space1->select.sel_info.hslab->opt_diminfo[u].count!=space2->select.sel_info.hslab->opt_diminfo[u].count) HGOTO_DONE(FALSE); if(space1->select.sel_info.hslab->opt_diminfo[u].block!=space2->select.sel_info.hslab->opt_diminfo[u].block) HGOTO_DONE(FALSE); } /* end for */ } /* end if */ /* Iterate through all the blocks in the selection */ else { hsize_t start1[H5O_LAYOUT_NDIMS]; /* Start point of selection block in dataspace #1 */ hsize_t start2[H5O_LAYOUT_NDIMS]; /* Start point of selection block in dataspace #2 */ hsize_t end1[H5O_LAYOUT_NDIMS]; /* End point of selection block in dataspace #1 */ hsize_t end2[H5O_LAYOUT_NDIMS]; /* End point of selection block in dataspace #2 */ hsize_t off1[H5O_LAYOUT_NDIMS]; /* Offset of selection #1 blocks */ hsize_t off2[H5O_LAYOUT_NDIMS]; /* Offset of selection #2 blocks */ htri_t status1,status2; /* Status from next block checks */ unsigned first_block=1; /* Flag to indicate the first block */ /* Initialize iterator for each dataspace selection * Use '0' for element size instead of actual element size to indicate * that the selection iterator shouldn't be "flattened", since we * aren't actually going to be doing I/O with the iterators. */ if (H5S_select_iter_init(&iter1, space1, 0)<0) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator"); iter1_init=1; if (H5S_select_iter_init(&iter2, space2, 0)<0) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator"); iter2_init=1; /* Iterate over all the blocks in each selection */ while(1) { /* Get the current block for each selection iterator */ if(H5S_SELECT_ITER_BLOCK(&iter1,start1,end1)<0) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get iterator block"); if(H5S_SELECT_ITER_BLOCK(&iter2,start2,end2)<0) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get iterator block"); /* The first block only compares the sizes and sets the relative offsets for later blocks */ if(first_block) { /* If the block sizes from each selection doesn't match, get out */ for (u=0; uextent.rank; u++) { if((end1[u]-start1[u])!=(end2[u]-start2[u])) HGOTO_DONE(FALSE); /* Set the relative locations of the selections */ off1[u]=start1[u]; off2[u]=start2[u]; } /* end for */ /* Reset "first block" flag */ first_block=0; } /* end if */ else { /* Check over the blocks for each selection */ for (u=0; uextent.rank; u++) { /* Check if the blocks are in the same relative location */ if((start1[u]-off1[u])!=(start2[u]-off2[u])) HGOTO_DONE(FALSE); /* If the block sizes from each selection doesn't match, get out */ if((end1[u]-start1[u])!=(end2[u]-start2[u])) HGOTO_DONE(FALSE); } /* end for */ } /* end else */ /* Check if we are able to advance to the next selection block */ if((status1=H5S_SELECT_ITER_HAS_NEXT_BLOCK(&iter1))<0) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTNEXT, FAIL, "unable to check iterator block"); if((status2=H5S_SELECT_ITER_HAS_NEXT_BLOCK(&iter2))<0) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTNEXT, FAIL, "unable to check iterator block"); /* Did we run out of blocks at the same time? */ if(status1==FALSE && status2==FALSE) break; else if(status1!=status2) { HGOTO_DONE(FALSE); } /* end if */ else { /* Advance to next block in selection iterators */ if(H5S_SELECT_ITER_NEXT_BLOCK(&iter1)<0) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTNEXT, FAIL, "unable to advance to next iterator block"); if(H5S_SELECT_ITER_NEXT_BLOCK(&iter2)<0) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTNEXT, FAIL, "unable to advance to next iterator block"); } /* end else */ } /* end while */ } /* end else */ done: if(iter1_init) { if (H5S_SELECT_ITER_RELEASE(&iter1)<0) HDONE_ERROR (H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator"); } /* end if */ if(iter2_init) { if (H5S_SELECT_ITER_RELEASE(&iter2)<0) HDONE_ERROR (H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator"); } /* end if */ FUNC_LEAVE_NOAPI(ret_value); } /* H5S_select_shape_same() */ /*-------------------------------------------------------------------------- NAME H5S_select_fill PURPOSE Fill a selection in memory with a value USAGE herr_t H5S_select_fill(fill,fill_size,space,buf) const void *fill; IN: Pointer to fill value to use size_t fill_size; IN: Size of elements in memory buffer & size of fill value H5S_t *space; IN: Dataspace describing memory buffer & containing selection to use. void *buf; IN/OUT: Memory buffer to fill selection in RETURNS Non-negative on success/Negative on failure. DESCRIPTION Use the selection in the dataspace to fill elements in a memory buffer. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS The memory buffer elements are assumed to have the same datatype as the fill value being placed into them. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5S_select_fill(void *_fill, size_t fill_size, const H5S_t *space, void *_buf) { H5S_sel_iter_t iter; /* Selection iteration info */ hbool_t iter_init=0; /* Selection iteration info has been initialized */ uint8_t *buf; /* Current location in buffer */ void *fill=_fill; /* Alias for fill-value buffer */ hssize_t nelmts; /* Number of elements in selection */ hsize_t off[H5D_XFER_HYPER_VECTOR_SIZE_DEF]; /* Array to store sequence offsets */ size_t len[H5D_XFER_HYPER_VECTOR_SIZE_DEF]; /* Array to store sequence lengths */ size_t nseq; /* Number of sequences generated */ size_t curr_seq; /* Current sequnce being worked on */ size_t nelem; /* Number of elements used in sequences */ size_t max_elem; /* Total number of elements in selection */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_NOAPI(H5S_select_fill, FAIL); /* Check args */ assert(fill_size>0); assert(space); assert(_buf); /* Check if we need a temporary fill value buffer */ if(fill==NULL) { if (NULL==(fill = H5FL_BLK_CALLOC(type_elem,fill_size))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "fill value buffer allocation failed"); } /* end if */ /* Initialize iterator */ if (H5S_select_iter_init(&iter, space, fill_size)<0) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator"); iter_init=1; /* Selection iteration info has been initialized */ /* Get the number of elements in selection */ if((nelmts = H5S_GET_SELECT_NPOINTS(space))<0) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTCOUNT, FAIL, "can't get number of elements selected"); /* Compute the number of bytes to process */ H5_ASSIGN_OVERFLOW(max_elem,nelmts,hssize_t,size_t); /* Loop, while elements left in selection */ while(max_elem>0) { /* Get the sequences of bytes */ if(H5S_SELECT_GET_SEQ_LIST(space,0,&iter,H5D_XFER_HYPER_VECTOR_SIZE_DEF,max_elem,&nseq,&nelem,off,len)<0) HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed"); /* Loop over sequences */ for(curr_seq=0; curr_seq * * Programmer: Quincey Koziol * Friday, Jan 30, 2004 * * Modification: * *--------------------------------------------------------------------------- */ void H5FD_gass_term(void) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_gass_term) /* Reset VFL ID */ H5FD_GASS_g=0; FUNC_LEAVE_NOAPI_VOID } /* end H5FD_gass_term() */ /*------------------------------------------------------------------------- * Function: H5Pset_fapl_gass * * Purpose: Store the user supplied GASS INFO in * the file access property list FAPL_ID which can then be used * to create and/or open the file. * * GASS info object to be used for file open using GASS. * Any modification to info after * this function call returns may have undetermined effect * to the access property list. Users should call this * function again to setup the property list. * * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Saurabh Bagchi * Friday, August 13, 1999 * * Modifications: * * Raymond Lu, 2001-10-25 * Changed the file access list to the new generic property list. * *------------------------------------------------------------------------- */ herr_t H5Pset_fapl_gass(hid_t fapl_id, GASS_Info info) { H5FD_gass_fapl_t fa; H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value; FUNC_ENTER_API(H5Pset_fapl_gass, FAIL) /*NO TRACE*/ /* Check arguments */ if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") #ifdef LATER #warning "We need to verify that INFO contain sensible information." #endif /* Initialize driver specific properties */ fa.info = info; ret_value= H5P_set_driver(plist, H5FD_GASS, &fa); done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5Pget_fapl_gass * * Purpose: If the file access property list is set to the H5FD_GASS * driver then this function returns the GASS info object * through the INFO pointer. * * Return: Success: Non-negative with the info object returned * through the INFO arguments if non-null. * The information is copied and it is therefore * valid only until the file access property * list is modified or closed. * * Failure: Negative * * Programmer: Saurabh Bagchi * Friday, August 13, 1999 * * Modifications: * * Raymond Lu, 2001-10-25 * Changed the file access list to the new generic property list. * *------------------------------------------------------------------------- */ herr_t H5Pget_fapl_gass(hid_t fapl_id, GASS_Info *info/*out*/) { H5FD_gass_fapl_t *fa; H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Pget_fapl_gass, FAIL) H5TRACE2("e","ix",fapl_id,info); if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") if (H5FD_GASS!=H5P_get_driver(plist)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver") if (NULL==(fa=H5P_get_driver_info(plist))) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info") if (info) *info = fa->info; done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_gass_open * * Purpose: Opens a file with name NAME. The FLAGS are a bit field with * purpose similar to the second argument of open(2) and which * are defined in H5Fpublic.h. The file access property list * FAPL_ID contains the driver properties and MAXADDR * is the largest address which this file will be expected to * access. * * Return: Success: A pointer to a new file data structure. The * public fields will be initialized by the * caller, which is always H5FD_open(). * * Failure: NULL * * Programmer: Saurabh Bagchi * Friday, August 13, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static H5FD_t * H5FD_gass_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { int fd; H5FD_gass_t *file=NULL; const H5FD_gass_fapl_t *fa=NULL; H5FD_gass_fapl_t _fa; char *filename = (char *) H5MM_malloc(80 * sizeof(char)); H5P_genplist_t *plist; /* Property list pointer */ h5_stat_t sb; H5FD_t *ret_value; FUNC_ENTER_NOAPI(H5FD_gass_open, NULL) /* fprintf(stdout, "Entering H5FD_gass_open name=%s flags=0x%x\n", name, flags); */ /* Check arguments */ if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name") if (0==maxaddr || HADDR_UNDEF==maxaddr) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr") if (ADDR_OVERFLOW(maxaddr)) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr") strcpy (filename, name); /* Obtain a pointer to gass-specific file access properties */ if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") if (H5P_FILE_ACCESS_DEFAULT==fapl_id || H5FD_GASS!=H5P_get_driver(plist)) { GASS_INFO_NULL (_fa.info); /* _fa.info = GASS_INFO_NULL; */ /* _fa.info = {0,0}; */ /*default*/ fa = &_fa; } else { fa = H5P_get_driver_info(plist); assert(fa); } /* When I come down here, the possible flag values and the correct responses are given here :- 1. H5F_ACC_CREAT | H5F_ACC_RDWR | H5F_ACC_EXCL : The file is a new one. Go ahead and open it in O_RDWR. 2. H5F_ACC_CREAT | H5F_ACC_RDWR | H5F_ACC_TRUNC : Use O_RDWR | O_TRUNC with gass_open. 3. H5F_ACC_RDWR | H5F_ACC_TRUNC : File already exists. Truncate it. 4. H5F_ACC_RDWR : Use O_RDWR with gass_open 5. H5F_ACC_RDWR is not set : Use O_RDONLY with gass_open One reason why we cannot simply pass on the flags to gass_open is that gass_open does not support many of them (e.g., O_CREAT) */ if ((flags & H5F_ACC_CREAT) && (flags & H5F_ACC_RDWR) && (flags & H5F_ACC_EXCL)) { if ((fd = globus_gass_open (filename, O_RDWR|O_TRUNC)) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTOPENFILE, NULL, "open failed") } else if ((flags & H5F_ACC_CREAT) && (flags & H5F_ACC_RDWR) && (flags & H5F_ACC_TRUNC)) { if ((fd = globus_gass_open (filename, O_RDWR|O_TRUNC)) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTOPENFILE, NULL, "open failed") } else if ((flags & H5F_ACC_RDWR) && (flags & H5F_ACC_TRUNC)) { if ((fd = globus_gass_open (filename, O_RDWR|O_TRUNC)) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTOPENFILE, NULL, "open failed") } else if (flags & H5F_ACC_RDWR) { if ((fd = globus_gass_open (filename, O_RDWR)) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTOPENFILE, NULL, "open failed") } else { /* This is case where H5F_ACC_RDWR is not set */ if ((fd = globus_gass_open (filename, O_RDONLY)) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTOPENFILE, NULL, "open failed") } if (HDfstat(fd, &sb)<0) { close(fd); HGOTO_ERROR(H5E_IO, H5E_BADFILE, NULL, "fstat failed") } /* Create the new file struct */ if (NULL==(file=H5MM_calloc(sizeof(H5FD_gass_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate file struct") file->fd = fd; file->eof = sb.st_size; file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; file->info = fa->info; /* Set return value */ ret_value=(H5FD_t*)file; done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_gass_close * * Purpose: Closes a GASS file. * * Return: Success: 0 * * Failure: -1, file not closed. * * Programmer: Saurabh Bagchi * Monday, August 16, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_gass_close (H5FD_t *_file) { H5FD_gass_t *file = (H5FD_gass_t *)_file; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_gass_close, FAIL) if (file == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file handle") if (globus_gass_close (file->fd) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTCLOSEFILE, FAIL, "can't close GASS file") H5MM_xfree(file); done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_gass_query * * Purpose: Set the flags that this VFL driver is capable of supporting. * (listed in H5FDpublic.h) * * Return: Success: non-negative * * Failure: negative * * Programmer: Quincey Koziol * Tuesday, September 26, 2000 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_gass_query(const UNUSED H5FD_t *_f, unsigned long *flags /* out */) { herr_t ret_value=SUCCEED; FUNC_ENTER_NOAPI(H5FD_gass_query, FAIL) /* Set the VFL feature flags that this driver supports */ if(flags) { *flags = 0; *flags|=H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ *flags|=H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ } done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_gass_get_eoa * * Purpose: Gets the end-of-address marker for the file. The EOA marker * is the first address past the last byte allocated in the * format address space. * * Return: Success: The end-of-address marker. * * Failure: HADDR_UNDEF * * Programmer: Saurabh Bagchi * Monday, August 16, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static haddr_t H5FD_gass_get_eoa(H5FD_t *_file) { H5FD_gass_t *file = (H5FD_gass_t *)_file; haddr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_gass_get_eoa, HADDR_UNDEF) /* Set return value */ ret_value=file->eoa; done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_gass_set_eoa * * Purpose: Set the end-of-address marker for the file. This function is * called shortly after an existing HDF5 file is opened in order * to tell the driver where the end of the HDF5 data is located. * * Return: Success: 0 * * Programmer: Saurabh Bagchi * Monday, August 16, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_gass_set_eoa(H5FD_t *_file, haddr_t addr) { H5FD_gass_t *file = (H5FD_gass_t *)_file; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_gass_set_eoa, FAIL) file->eoa = addr; done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_gass_get_eof * * Purpose: Returns the end-of-file marker, which is the greater of * either the Unix end-of-file or the HDF5 end-of-address * markers. * * Return: Success: End of file address, the first address past * the end of the "file", either the Unix file * or the HDF5 file. * * Failure: HADDR_UNDEF * * Programmer: Saurabh Bagchi * Monday, August 16, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static haddr_t H5FD_gass_get_eof(H5FD_t *_file) { H5FD_gass_t *file = (H5FD_gass_t*)_file; haddr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_gass_get_eof, HADDR_UNDEF) /* Set return value */ ret_value=MAX(file->eof, file->eoa); done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_gass_get_handle * * Purpose: Returns the file handle of GASS file driver. * * Returns: Non-negative if succeed or negative if fails. * * Programmer: Raymond Lu * Sept. 16, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_gass_get_handle(H5FD_t *_file, hid_t UNUSED fapl, void** file_handle) { H5FD_gass_t *file = (H5FD_gass_t *)_file; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5FD_gass_get_handle, FAIL) if(!file_handle) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file handle not valid") *file_handle = &(file->fd); done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_gass_read * * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR * into buffer BUF. * * Return: Success: Zero. Result is stored in caller-supplied * buffer BUF. * * Failure: -1, Contents of buffer BUF are undefined. * * Programmer: Saurabh Bagchi * Monday, August 16, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_gass_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t dxpl_id/*unused*/, haddr_t addr, size_t size, void *buf/*out*/) { H5FD_gass_t *file = (H5FD_gass_t*)_file; ssize_t nbytes; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_gass_read, FAIL) assert(file && file->pub.cls); assert(buf); /* Check for overflow conditions */ if (HADDR_UNDEF==addr) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "addr undefined") if (REGION_OVERFLOW(addr, size)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr too large") if (addr+size>file->eoa) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr too large") /* Seek to the correct location */ if ((addr!=file->pos || OP_READ!=file->op) && file_seek(file->fd, (file_offset_t)addr, SEEK_SET)<0) { file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "gass file seek failed") } /* * Read data, being careful of interrupted system calls, partial results, * and the end of the file. */ while (size>0) { do nbytes = read(file->fd, buf, size); while (-1==nbytes && EINTR==errno); if (-1==nbytes) { /* error */ file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "gass file read failed") } if (0==nbytes) { /* end of file but not end of format address space */ memset(buf, 0, size); size = 0; } assert(nbytes>=0); assert(nbytes<=size); size -= (hsize_t)nbytes; addr += (haddr_t)nbytes; buf = (char*)buf + nbytes; } /* Update current position */ file->pos = addr; file->op = OP_READ; done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_gass_write * * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR * from buffer BUF. * * Return: Success: Zero * * Failure: -1 * * Programmer: Saurabh Bagchi * Tuesday, August 17, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_gass_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id/*unused*/, haddr_t addr, size_t size, const void *buf) { H5FD_gass_t *file = (H5FD_gass_t*)_file; ssize_t nbytes; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_gass_write, FAIL) assert(file && file->pub.cls); assert(buf); /* Check for overflow conditions */ if (HADDR_UNDEF==addr) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "addr undefined") if (REGION_OVERFLOW(addr, size)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr too large") if (addr+size>file->eoa) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr too large") /* Seek to the correct location */ if ((addr!=file->pos || OP_WRITE!=file->op) && file_seek(file->fd, (file_offset_t)addr, SEEK_SET)<0) { file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "gass file seek failed") } /* * Write the data, being careful of interrupted system calls and partial * results */ while (size>0) { do nbytes = write(file->fd, buf, size); while (-1==nbytes && EINTR==errno); if (-1==nbytes) { /* error */ file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "gass file write failed") } assert(nbytes>0); assert(nbytes<=size); size -= (hsize_t)nbytes; addr += (haddr_t)nbytes; buf = (const char*)buf + nbytes; } /* Update current position and eof */ file->pos = addr; file->op = OP_WRITE; if (file->pos>file->eof) file->eof = file->pos; done: FUNC_LEAVE_NOAPI(ret_value) } #endif /* H5_HAVE_GASS */ xdmf-3.0+git20160803/Utilities/hdf5/CMake/0000740000175000017500000000000013003006557017651 5ustar alastairalastairxdmf-3.0+git20160803/Utilities/hdf5/CMake/CVS/0000740000175000017500000000000013003006557020304 5ustar alastairalastairxdmf-3.0+git20160803/Utilities/hdf5/CMake/CVS/Repository0000640000175000017500000000003213003006557022403 0ustar alastairalastairXdmf/Utilities/hdf5/CMake xdmf-3.0+git20160803/Utilities/hdf5/CMake/CVS/Root0000640000175000017500000000006413003006557021154 0ustar alastairalastair:pserver:anonymous@public.kitware.com:/cvsroot/Xdmf xdmf-3.0+git20160803/Utilities/hdf5/CMake/CVS/Entries0000640000175000017500000000022213003006557021636 0ustar alastairalastair/CheckTypeSize.c/1.5/Mon Jan 15 15:14:30 2007// /CheckTypeSize.cmake/1.6/Mon Jan 15 15:14:30 2007// /HDF5Tests.c/1.9/Wed Aug 1 19:03:01 2007// D xdmf-3.0+git20160803/Utilities/hdf5/CMake/HDF5Tests.c0000640000175000017500000000666013003006557021540 0ustar alastairalastair#define SIMPLE_TEST(x) int main(){ x; return 0; } #ifdef TIME_WITH_SYS_TIME /* Time with sys/time test */ #include #include #include int main () { if ((struct tm *) 0) return 0; ; return 0; } #endif #ifdef STDC_HEADERS #include #include #include #include int main() { return 0; } #endif /* STDC_HEADERS */ #ifdef HAVE_TM_ZONE #include #ifdef HAVE_SYS_TIME_H #include #endif #include SIMPLE_TEST(struct tm tm; tm.tm_zone); #endif /* HAVE_TM_ZONE */ #ifdef HAVE_STRUCT_TM_TM_ZONE #include #ifdef HAVE_SYS_TIME_H #include #endif #include SIMPLE_TEST(struct tm tm; tm.tm_zone); #endif /* HAVE_STRUCT_TM_TM_ZONE */ #ifdef HAVE_ATTRIBUTE SIMPLE_TEST(int __attribute__((unused)) x); #endif /* HAVE_ATTRIBUTE */ #ifdef HAVE_FUNCTION SIMPLE_TEST((void)__FUNCTION__); #endif /* HAVE_FUNCTION */ #ifdef HAVE_TM_GMTOFF #ifdef HAVE_SYS_TIME_H #include #endif #include SIMPLE_TEST(struct tm tm; tm.tm_gmtoff=0); #endif /* HAVE_TM_GMTOFF */ #ifdef HAVE_TIMEZONE #include #include SIMPLE_TEST(timezone=0); #endif /* HAVE_TIMEZONE */ #ifdef HAVE_STRUCT_TIMEZONE #include #ifdef HAVE_SYS_TIME_H #include #endif #include SIMPLE_TEST(struct timezone tz; tz.tz_minuteswest=0); #endif /* HAVE_STRUCT_TIMEZONE */ #ifdef HAVE_STAT_ST_BLOCKS #include SIMPLE_TEST(struct stat sb; sb.st_blocks=0); #endif /* HAVE_STAT_ST_BLOCKS */ #ifdef PRINTF_LL_WIDTH #ifdef HAVE_LONG_LONG # define LL_TYPE long long #else /* HAVE_LONG_LONG */ # define LL_TYPE __int64 #endif /* HAVE_LONG_LONG */ #include #include #include int main(void) { char *llwidthArgs[] = { "l64", "l", "L", "q", "ll", NULL }; char *s = malloc(128); char **currentArg = NULL; LL_TYPE x = (LL_TYPE)1048576 * (LL_TYPE)1048576; for (currentArg = llwidthArgs; *currentArg != NULL; currentArg++) { char formatString[64]; sprintf(formatString, "%%%sd", *currentArg); sprintf(s, formatString, x); if (strcmp(s, "1099511627776") == 0) { printf("PRINTF_LL_WIDTH=[%s]\n", *currentArg); exit(0); } } exit(1); } #endif /* PRINTF_LL_WIDTH */ #ifdef SYSTEM_SCOPE_THREADS #include #include int main(void) { pthread_attr_t attribute; int ret; pthread_attr_init(&attribute); ret=pthread_attr_setscope(&attribute, PTHREAD_SCOPE_SYSTEM); exit(ret==0 ? 0 : 1); } #endif /* SYSTEM_SCOPE_THREADS */ #ifdef HAVE_SOCKLEN_T #include #include #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif SIMPLE_TEST(socklen_t foo); #endif /* HAVE_SOCKLEN_T */ #ifdef DEV_T_IS_SCALAR #ifdef HAVE_SYS_TYPES_H #include #endif int main () { dev_t d1, d2; if(d1==d2) return 0; return 1; } #endif /* DEV_T_IS_SCALAR */ #if defined( INLINE_TEST_inline ) || defined( INLINE_TEST___inline__ ) || defined( INLINE_TEST___inline ) #ifndef __cplusplus typedef int foo_t; static INLINE_TEST_INLINE foo_t static_foo () { return 0; } INLINE_TEST_INLINE foo_t foo () {return 0; } int main() { return 0; } #endif #endif /* INLINE_TEST */ #ifdef HAVE_OFF64_T #include int main() { off64_t n = 0; return (int)n; } #endif xdmf-3.0+git20160803/Utilities/hdf5/CMake/CheckTypeSize.c0000740000175000017500000000116213003006557022532 0ustar alastairalastair#ifdef CHECK_TYPE_SIZE_TYPE #ifdef HAVE_SYS_TYPES_H # include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_STDINT_H # include #endif /* HAVE_STDINT_H */ #ifdef HAVE_STDDEF_H # include #endif /* HAVE_STDDEF_H */ #ifdef HAVE_INTTYPES_H # include #endif /* HAVE_INTTYPES_H */ #ifdef __CLASSIC_C__ int main(){ int ac; char*av[]; #else int main(int ac, char*av[]){ #endif if(ac > 1000){return *av[0];} return sizeof(CHECK_TYPE_SIZE_TYPE); } #else /* CHECK_TYPE_SIZE_TYPE */ # error "CHECK_TYPE_SIZE_TYPE has to specify the type" #endif /* CHECK_TYPE_SIZE_TYPE */ xdmf-3.0+git20160803/Utilities/hdf5/CMake/CheckTypeSize.cmake0000740000175000017500000000353013003006557023371 0ustar alastairalastair# # Check if the type exists and determine size of type. if the type # exists, the size will be stored to the variable. # # CHECK_TYPE_SIZE - macro which checks the size of type # VARIABLE - variable to store size if the type exists. # HAVE_${VARIABLE} - does the variable exists or not # MACRO(CHECK_TYPE_SIZE TYPE VARIABLE) SET(CMAKE_ALLOW_UNKNOWN_VARIABLE_READ_ACCESS 1) IF("HAVE_${VARIABLE}" MATCHES "^HAVE_${VARIABLE}$") SET(MACRO_CHECK_TYPE_SIZE_FLAGS "-DCHECK_TYPE_SIZE_TYPE=\"${TYPE}\" ${CMAKE_REQUIRED_FLAGS}") FOREACH(def HAVE_SYS_TYPES_H HAVE_STDINT_H HAVE_STDDEF_H HAVE_INTTYPES_H) IF("${def}") SET(MACRO_CHECK_TYPE_SIZE_FLAGS "${MACRO_CHECK_TYPE_SIZE_FLAGS} -D${def}") ENDIF("${def}") ENDFOREACH(def) MESSAGE(STATUS "Check size of ${TYPE}") IF(CMAKE_REQUIRED_LIBRARIES) SET(CHECK_TYPE_SIZE_ADD_LIBRARIES "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") ENDIF(CMAKE_REQUIRED_LIBRARIES) TRY_RUN(${VARIABLE} HAVE_${VARIABLE} ${CMAKE_BINARY_DIR} ${VTKHDF5_SOURCE_DIR}/CMake/CheckTypeSize.c CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_TYPE_SIZE_FLAGS} "${CHECK_TYPE_SIZE_ADD_LIBRARIES}" OUTPUT_VARIABLE OUTPUT) IF(HAVE_${VARIABLE}) MESSAGE(STATUS "Check size of ${TYPE} - done") FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeOutput.log "Determining size of ${TYPE} passed with the following output:\n${OUTPUT}\n\n") ELSE(HAVE_${VARIABLE}) MESSAGE(STATUS "Check size of ${TYPE} - failed") FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log "Determining size of ${TYPE} failed with the following output:\n${OUTPUT}\n\n") ENDIF(HAVE_${VARIABLE}) ENDIF("HAVE_${VARIABLE}" MATCHES "^HAVE_${VARIABLE}$") SET(CMAKE_ALLOW_UNKNOWN_VARIABLE_READ_ACCESS ) ENDMACRO(CHECK_TYPE_SIZE) xdmf-3.0+git20160803/Utilities/hdf5/H5Oprivate.h0000640000175000017500000003012213003006557021030 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*------------------------------------------------------------------------- * * Created: H5Oprivate.h * Aug 5 1997 * Robb Matzke * * Purpose: Object header private include file. * * Modifications: * *------------------------------------------------------------------------- */ #ifndef _H5Oprivate_H #define _H5Oprivate_H /* Include the public header file for this API */ #include "H5Opublic.h" /* Object header functions */ /* Public headers needed by this file */ #include "H5Dpublic.h" /* Dataset functions */ #include "H5Spublic.h" /* Dataspace functions */ /* Private headers needed by this file */ #include "H5HGprivate.h" /* Global heap functions */ #include "H5Tprivate.h" /* Datatype functions */ #include "H5Zprivate.h" /* I/O pipeline filters */ /* Object header macros */ #define H5O_MIN_SIZE H5O_ALIGN(32) /*min obj header data size */ #define H5O_MAX_SIZE 65536 /*max obj header data size */ #define H5O_NEW_MESG (-1) /*new message */ #define H5O_ALL (-1) /* Operate on all messages of type */ /* Flags which are part of a message */ #define H5O_FLAG_CONSTANT 0x01u #define H5O_FLAG_SHARED 0x02u #define H5O_FLAG_BITS (H5O_FLAG_CONSTANT|H5O_FLAG_SHARED) /* Flags for updating messages */ #define H5O_UPDATE_TIME 0x01u #define H5O_UPDATE_DATA_ONLY 0x02u /* Header message IDs */ #define H5O_NULL_ID 0x0000 /* Null Message. */ #define H5O_SDSPACE_ID 0x0001 /* Simple Dataspace Message. */ /* Complex dataspace is/was planned for message 0x0002 */ #define H5O_DTYPE_ID 0x0003 /* Datatype Message. */ #define H5O_FILL_ID 0x0004 /* Fill Value Message. (Old) */ #define H5O_FILL_NEW_ID 0x0005 /* Fill Value Message. (New) */ /* Compact data storage is/was planned for message 0x0006 */ #define H5O_EFL_ID 0x0007 /* External File List Message */ #define H5O_LAYOUT_ID 0x0008 /* Data Storage Layout Message. */ #define H5O_BOGUS_ID 0x0009 /* "Bogus" Message. */ /* message 0x000a appears unused... */ #define H5O_PLINE_ID 0x000b /* Filter pipeline message. */ #define H5O_ATTR_ID 0x000c /* Attribute Message. */ #define H5O_NAME_ID 0x000d /* Object name message. */ #define H5O_MTIME_ID 0x000e /* Modification time message. (Old) */ #define H5O_SHARED_ID 0x000f /* Shared object message. */ #define H5O_CONT_ID 0x0010 /* Object header continuation message. */ #define H5O_STAB_ID 0x0011 /* Symbol table message. */ #define H5O_MTIME_NEW_ID 0x0012 /* Modification time message. (New) */ /* * Fill Value Message. (Old) * (Data structure in memory) */ typedef struct H5O_fill_t { H5T_t *type; /*type. Null implies same as dataset */ size_t size; /*number of bytes in the fill value */ void *buf; /*the fill value */ } H5O_fill_t; /* * New Fill Value Message. The new fill value message is fill value plus * space allocation time and fill value writing time and whether fill * value is defined. */ typedef struct H5O_fill_new_t { H5T_t *type; /*type. Null implies same as dataset */ ssize_t size; /*number of bytes in the fill value */ void *buf; /*the fill value */ H5D_alloc_time_t alloc_time; /* time to allocate space */ H5D_fill_time_t fill_time; /* time to write fill value */ hbool_t fill_defined; /* whether fill value is defined */ } H5O_fill_new_t; /* * External File List Message * (Data structure in memory) */ #define H5O_EFL_ALLOC 16 /*number of slots to alloc at once */ #define H5O_EFL_UNLIMITED H5F_UNLIMITED /*max possible file size */ typedef struct H5O_efl_entry_t { size_t name_offset; /*offset of name within heap */ char *name; /*malloc'd name */ off_t offset; /*offset of data within file */ hsize_t size; /*size allocated within file */ } H5O_efl_entry_t; typedef struct H5O_efl_t { haddr_t heap_addr; /*address of name heap */ size_t nalloc; /*number of slots allocated */ size_t nused; /*number of slots used */ H5O_efl_entry_t *slot; /*array of external file entries */ } H5O_efl_t; /* * Data Layout Message. * (Data structure in memory) */ #define H5O_LAYOUT_NDIMS (H5S_MAX_RANK+1) typedef struct H5O_layout_contig_t { haddr_t addr; /* File address of data */ hsize_t size; /* Size of data in bytes */ } H5O_layout_contig_t; typedef struct H5O_layout_chunk_t { haddr_t addr; /* File address of B-tree */ unsigned ndims; /* Num dimensions in chunk */ size_t dim[H5O_LAYOUT_NDIMS]; /* Size of chunk in elements */ size_t size; /* Size of chunk in bytes */ H5RC_t *btree_shared; /* Ref-counted info for B-tree nodes */ } H5O_layout_chunk_t; typedef struct H5O_layout_compact_t { hbool_t dirty; /* Dirty flag for compact dataset */ size_t size; /* Size of buffer in bytes */ void *buf; /* Buffer for compact dataset */ } H5O_layout_compact_t; typedef struct H5O_layout_t { H5D_layout_t type; /* Type of layout */ unsigned version; /* Version of message */ /* Structure for "unused" dimension information */ struct { unsigned ndims; /*num dimensions in stored data */ hsize_t dim[H5O_LAYOUT_NDIMS]; /*size of data or chunk in bytes */ } unused; union { H5O_layout_contig_t contig; /* Information for contiguous layout */ H5O_layout_chunk_t chunk; /* Information for chunked layout */ H5O_layout_compact_t compact; /* Information for compact layout */ } u; } H5O_layout_t; /* Enable reading/writing "bogus" messages */ /* #define H5O_ENABLE_BOGUS */ #ifdef H5O_ENABLE_BOGUS /* * "Bogus" Message. * (Data structure in memory) */ #define H5O_BOGUS_VALUE 0xdeadbeef typedef struct H5O_bogus_t { unsigned u; /* Hold the bogus info */ } H5O_bogus_t; #endif /* H5O_ENABLE_BOGUS */ /* * Filter pipeline message. * (Data structure in memory) */ typedef struct H5O_pline_t { size_t nalloc; /*num elements in `filter' array */ size_t nused; /*num filters defined */ H5Z_filter_info_t *filter; /*array of filters */ } H5O_pline_t; /* * Object name message. * (Data structure in memory) */ typedef struct H5O_name_t { char *s; /*ptr to malloc'd memory */ } H5O_name_t; /* * Shared object message. This message ID never really appears in an object * header. Instead, bit 2 of the `Flags' field will be set and the ID field * will be the ID of the pointed-to message. */ typedef struct H5O_shared_t { hbool_t in_gh; /*shared by global heap? */ union { H5HG_t gh; /*global heap info */ H5G_entry_t ent; /*symbol table entry info */ } u; } H5O_shared_t; /* * Object header continuation message. * (Data structure in memory) */ typedef struct H5O_cont_t { haddr_t addr; /*address of continuation block */ size_t size; /*size of continuation block */ /* the following field(s) do not appear on disk */ unsigned chunkno; /*chunk this mesg refers to */ } H5O_cont_t; /* * Symbol table message. * (Data structure in memory) */ typedef struct H5O_stab_t { haddr_t btree_addr; /*address of B-tree */ haddr_t heap_addr; /*address of name heap */ } H5O_stab_t; /* Define return values from operator callback function for H5O_iterate */ /* (Actually, any postive value will cause the iterator to stop and pass back * that positive value to the function that called the iterator) */ #define H5O_ITER_ERROR (-1) #define H5O_ITER_CONT (0) #define H5O_ITER_STOP (1) /* Typedef for iteration operations */ typedef herr_t (*H5O_operator_t)(const void *mesg/*in*/, unsigned idx, void *operator_data/*in,out*/); /* General message operators */ H5_DLL herr_t H5O_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, H5G_entry_t *ent/*out*/); H5_DLL herr_t H5O_open(const H5G_entry_t *ent); H5_DLL herr_t H5O_close(H5G_entry_t *ent); H5_DLL int H5O_link(const H5G_entry_t *ent, int adjust, hid_t dxpl_id); H5_DLL int H5O_count(H5G_entry_t *ent, unsigned type_id, hid_t dxpl_id); H5_DLL htri_t H5O_exists(H5G_entry_t *ent, unsigned type_id, int sequence, hid_t dxpl_id); H5_DLL void *H5O_read(const H5G_entry_t *ent, unsigned type_id, int sequence, void *mesg, hid_t dxpl_id); H5_DLL int H5O_modify(H5G_entry_t *ent, unsigned type_id, int overwrite, unsigned flags, unsigned update_flags, const void *mesg, hid_t dxpl_id); H5_DLL struct H5O_t * H5O_protect(H5G_entry_t *ent, hid_t dxpl_id); H5_DLL herr_t H5O_unprotect(H5G_entry_t *ent, struct H5O_t *oh, hid_t dxpl_id); H5_DLL int H5O_append(H5F_t *f, hid_t dxpl_id, struct H5O_t *oh, unsigned type_id, unsigned flags, const void *mesg); H5_DLL herr_t H5O_touch(H5G_entry_t *ent, hbool_t force, hid_t dxpl_id); H5_DLL herr_t H5O_touch_oh(H5F_t *f, struct H5O_t *oh, hbool_t force); #ifdef H5O_ENABLE_BOGUS H5_DLL herr_t H5O_bogus(H5G_entry_t *ent, hid_t dxpl_id); H5_DLL herr_t H5O_bogus_oh(H5F_t *f, struct H5O_t *oh); #endif /* H5O_ENABLE_BOGUS */ H5_DLL herr_t H5O_remove(H5G_entry_t *ent, unsigned type_id, int sequence, hbool_t adj_link, hid_t dxpl_id); H5_DLL herr_t H5O_remove_op(H5G_entry_t *ent, unsigned type_id, H5O_operator_t op, void *op_data, hbool_t adj_link, hid_t dxpl_id); H5_DLL herr_t H5O_reset(unsigned type_id, void *native); H5_DLL void *H5O_free(unsigned type_id, void *mesg); H5_DLL void *H5O_copy(unsigned type_id, const void *mesg, void *dst); H5_DLL size_t H5O_raw_size(unsigned type_id, const H5F_t *f, const void *mesg); H5_DLL size_t H5O_mesg_size(unsigned type_id, const H5F_t *f, const void *mesg); H5_DLL herr_t H5O_get_share(unsigned type_id, H5F_t *f, const void *mesg, H5O_shared_t *share); H5_DLL herr_t H5O_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr); H5_DLL herr_t H5O_get_info(H5G_entry_t *ent, H5O_stat_t *ostat, hid_t dxpl_id); H5_DLL herr_t H5O_iterate(const H5G_entry_t *ent, unsigned type_id, H5O_operator_t op, void *op_data, hid_t dxpl_id); H5_DLL herr_t H5O_debug_id(hid_t type_id, H5F_t *f, hid_t dxpl_id, const void *mesg, FILE *stream, int indent, int fwidth); H5_DLL herr_t H5O_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, int fwidth); /* Layout operators */ H5_DLL size_t H5O_layout_meta_size(const H5F_t *f, const void *_mesg); /* EFL operators */ H5_DLL hsize_t H5O_efl_total_size(H5O_efl_t *efl); /* Fill value operators */ H5_DLL herr_t H5O_fill_convert(void *_fill, H5T_t *type, hid_t dxpl_id); #endif xdmf-3.0+git20160803/Utilities/hdf5/H5HGpublic.h0000640000175000017500000000243113003006557020736 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Robb Matzke * Friday, March 27, 1998 */ #ifndef _H5HGpublic_H #define _H5HGpublic_H /* Public headers needed by this file */ #include "H5public.h" #ifdef __cplusplus extern "C" { #endif #ifdef __cplusplus } #endif #endif xdmf-3.0+git20160803/Utilities/hdf5/H5Tcommit.c0000640000175000017500000002340413003006557020653 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Module Info: This module contains the functionality for committing datatypes * to a file for the H5T interface. */ #define H5T_PACKAGE /*suppress error about including H5Tpkg */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5T_init_commit_interface #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5FOprivate.h" /* File objects */ #include "H5Iprivate.h" /* IDs */ #include "H5Oprivate.h" /* Object headers */ #include "H5Tpkg.h" /* Datatypes */ /* Static local functions */ static herr_t H5T_commit(H5G_entry_t *loc, const char *name, H5T_t *type, hid_t dxpl_id); /*-------------------------------------------------------------------------- NAME H5T_init_commit_interface -- Initialize interface-specific information USAGE herr_t H5T_init_commit_interface() RETURNS Non-negative on success/Negative on failure DESCRIPTION Initializes any interface-specific data or routines. (Just calls H5T_init_iterface currently). --------------------------------------------------------------------------*/ static herr_t H5T_init_commit_interface(void) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_init_commit_interface) FUNC_LEAVE_NOAPI(H5T_init()) } /* H5T_init_commit_interface() */ /*------------------------------------------------------------------------- * Function: H5Tcommit * * Purpose: Save a transient datatype to a file and turn the type handle * into a named, immutable type. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Monday, June 1, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Tcommit(hid_t loc_id, const char *name, hid_t type_id) { H5G_entry_t *loc = NULL; H5T_t *type = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Tcommit, FAIL) H5TRACE3("e","isi",loc_id,name,type_id); /* Check arguments */ if (NULL==(loc=H5G_loc (loc_id))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if (!name || !*name) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no name") if (NULL==(type=H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Commit the type */ if (H5T_commit(loc, name, type, H5AC_dxpl_id)<0) HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype") done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5T_commit * * Purpose: Commit a type, giving it a name and causing it to become * immutable. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Monday, June 1, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5T_commit (H5G_entry_t *loc, const char *name, H5T_t *type, hid_t dxpl_id) { H5F_t *file = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5T_commit) HDassert (loc); HDassert (name && *name); HDassert (type); /* * Check arguments. We cannot commit an immutable type because H5Tclose() * normally fails on such types (try H5Tclose(H5T_NATIVE_INT)) but closing * a named type should always succeed. */ if (H5T_STATE_NAMED==type->shared->state || H5T_STATE_OPEN==type->shared->state) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "datatype is already committed") if (H5T_STATE_IMMUTABLE==type->shared->state) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "datatype is immutable") /* Find the insertion file */ if (NULL==(file=H5G_insertion_file(loc, name, dxpl_id))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to find insertion point") /* Check for a "sensible" datatype to store on disk */ if(H5T_is_sensible(type)<=0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "datatype is not sensible") /* Mark datatype as being on disk now. This step changes the size of datatype as * stored on disk. */ if(H5T_vlen_mark(type, file, H5T_VLEN_DISK)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid VL location"); /* * Create the object header and open it for write access. Insert the data * type message and then give the object header a name. */ if (H5O_create (file, dxpl_id, 64, &(type->ent))<0) HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to create datatype object header") if (H5O_modify (&(type->ent), H5O_DTYPE_ID, 0, H5O_FLAG_CONSTANT, H5O_UPDATE_TIME, type, dxpl_id)<0) HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to update type header message") /* * Give the datatype a name. That is, create and add a new object to the * group this datatype is being initially created in. */ if (H5G_insert (loc, name, &(type->ent), dxpl_id)<0) HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to name datatype") type->shared->state = H5T_STATE_OPEN; type->shared->fo_count=1; /* Add datatype to the list of open objects in the file */ if(H5FO_top_incr(type->ent.file, type->ent.header)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINC, FAIL, "can't incr object ref. count") if(H5FO_insert(type->ent.file, type->ent.header, type->shared)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL, "can't insert datatype into list of open objects") /* Mark datatype as being on memory now. Since this datatype may still be used in memory * after committed to disk, change its size back as in memory. */ if (H5T_vlen_mark(type, NULL, H5T_VLEN_MEMORY)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "cannot mark datatype in memory") done: if (ret_value<0) { if ((type->shared->state==H5T_STATE_TRANSIENT || type->shared->state==H5T_STATE_RDONLY) && H5F_addr_defined(type->ent.header)) { if(H5O_close(&(type->ent))<0) HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to release object header") if(H5O_delete(file, dxpl_id,type->ent.header)<0) HDONE_ERROR(H5E_DATATYPE, H5E_CANTDELETE, FAIL, "unable to delete object header") type->ent.header = HADDR_UNDEF; } } FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5Tcommitted * * Purpose: Determines if a datatype is committed or not. * * Return: Success: TRUE if committed, FALSE otherwise. * * Failure: Negative * * Programmer: Robb Matzke * Thursday, June 4, 1998 * * Modifications: * *------------------------------------------------------------------------- */ htri_t H5Tcommitted(hid_t type_id) { H5T_t *type = NULL; htri_t ret_value; /* Return value */ FUNC_ENTER_API(H5Tcommitted, FAIL) H5TRACE1("t","i",type_id); /* Check arguments */ if (NULL==(type=H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Set return value */ ret_value= H5T_committed(type); done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5T_committed * * Purpose: Determines if a datatype is committed or not. * * Return: Success: TRUE if committed, FALSE otherwise. * * Programmer: Quincey Koziol * Wednesday, September 24, 2003 * * Modifications: * *------------------------------------------------------------------------- */ htri_t H5T_committed(const H5T_t *type) { /* Use no-init for efficiency */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_committed) assert (type); FUNC_LEAVE_NOAPI(H5T_STATE_OPEN==type->shared->state || H5T_STATE_NAMED==type->shared->state) } /* end H5T_committed() */ /*------------------------------------------------------------------------- * Function: H5T_link * * Purpose: Adjust the link count for an object header by adding * ADJUST to the link count. * * Return: Success: New link count * * Failure: Negative * * Programmer: Quincey Koziol * Friday, September 26, 2003 * * Modifications: * *------------------------------------------------------------------------- */ int H5T_link(const H5T_t *type, int adjust, hid_t dxpl_id) { int ret_value; /* Return value */ /* Use no-init for efficiency */ FUNC_ENTER_NOAPI(H5T_link,FAIL) assert (type); /* Adjust the link count on the named datatype */ if((ret_value=H5O_link(&(type->ent),adjust,dxpl_id))<0) HGOTO_ERROR (H5E_DATATYPE, H5E_LINK, FAIL, "unable to adjust named datatype link count") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_link() */ xdmf-3.0+git20160803/Utilities/hdf5/H5Tcompound.c0000640000175000017500000004760613003006557021221 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Module Info: This module contains the functionality for compound datatypes * in the H5T interface. */ #define H5T_PACKAGE /*suppress error about including H5Tpkg */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5T_init_compound_interface #include "H5private.h" /*generic functions */ #include "H5Eprivate.h" /*error handling */ #include "H5Iprivate.h" /*ID functions */ #include "H5MMprivate.h" /*memory management */ #include "H5Tpkg.h" /*data-type functions */ /* Local macros */ #define H5T_COMPND_INC 64 /*typical max numb of members per struct */ /* Static local functions */ static herr_t H5T_pack(const H5T_t *dt); /*-------------------------------------------------------------------------- NAME H5T_init_compound_interface -- Initialize interface-specific information USAGE herr_t H5T_init_compound_interface() RETURNS Non-negative on success/Negative on failure DESCRIPTION Initializes any interface-specific data or routines. (Just calls H5T_init_iterface currently). --------------------------------------------------------------------------*/ static herr_t H5T_init_compound_interface(void) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_init_compound_interface) FUNC_LEAVE_NOAPI(H5T_init()) } /* H5T_init_compound_interface() */ /*------------------------------------------------------------------------- * Function: H5Tget_member_offset * * Purpose: Returns the byte offset of the beginning of a member with * respect to the beginning of the compound datatype datum. * * Return: Success: Byte offset. * * Failure: Zero. Zero is a valid offset, but this * function will fail only if a call to * H5Tget_member_dims() fails with the same * arguments. * * Programmer: Robb Matzke * Wednesday, January 7, 1998 * * Modifications: * *------------------------------------------------------------------------- */ size_t H5Tget_member_offset(hid_t type_id, unsigned membno) { H5T_t *dt = NULL; size_t ret_value; FUNC_ENTER_API(H5Tget_member_offset, 0) H5TRACE2("z","iIu",type_id,membno); /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)) || H5T_COMPOUND != dt->shared->type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a compound datatype") if (membno >= dt->shared->u.compnd.nmembs) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid member number") /* Value */ ret_value = H5T_get_member_offset(dt, membno); done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5T_get_member_offset * * Purpose: Private function for H5Tget_member_offset. Returns the byte * offset of the beginning of a member with respect to the * beginning of the compound datatype datum. * * Return: Success: Byte offset. * * Failure: Zero. Zero is a valid offset, but this * function will fail only if a call to * H5Tget_member_dims() fails with the same * arguments. * * Programmer: Raymond Lu * October 8, 2002 * * Modifications: * *------------------------------------------------------------------------- */ size_t H5T_get_member_offset(const H5T_t *dt, unsigned membno) { size_t ret_value; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_get_member_offset) assert(dt); assert(membno < dt->shared->u.compnd.nmembs); /* Value */ ret_value = dt->shared->u.compnd.memb[membno].offset; FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5Tget_member_class * * Purpose: Returns the datatype class of a member of a compound datatype. * * Return: Success: Non-negative * * Failure: H5T_NO_CLASS * * Programmer: Quincey Koziol * Thursday, November 9, 2000 * * Modifications: * *------------------------------------------------------------------------- */ H5T_class_t H5Tget_member_class(hid_t type_id, unsigned membno) { H5T_t *dt = NULL; H5T_class_t ret_value; FUNC_ENTER_API(H5Tget_member_class, H5T_NO_CLASS) H5TRACE2("Tt","iIu",type_id,membno); /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)) || H5T_COMPOUND != dt->shared->type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_NO_CLASS, "not a compound datatype") if (membno >= dt->shared->u.compnd.nmembs) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5T_NO_CLASS, "invalid member number") /* Get the type's class. We have to use this function to get type class * because of the concern of variable-length string. */ ret_value = H5T_get_class(dt->shared->u.compnd.memb[membno].type, FALSE); done: FUNC_LEAVE_API(ret_value) } /* end H5Tget_member_class() */ /*------------------------------------------------------------------------- * Function: H5Tget_member_type * * Purpose: Returns the datatype of the specified member. The caller * should invoke H5Tclose() to release resources associated with * the type. * * Return: Success: An OID of a copy of the member datatype; * modifying the returned datatype does not * modify the member type. * * Failure: Negative * * Programmer: Robb Matzke * Wednesday, January 7, 1998 * * Modifications: * * Robb Matzke, 4 Jun 1998 * If the member type is a named type then this function returns a * handle to the re-opened named type. * *------------------------------------------------------------------------- */ hid_t H5Tget_member_type(hid_t type_id, unsigned membno) { H5T_t *dt = NULL, *memb_dt = NULL; hid_t ret_value; FUNC_ENTER_API(H5Tget_member_type, FAIL) H5TRACE2("i","iIu",type_id,membno); /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)) || H5T_COMPOUND != dt->shared->type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound datatype") if (membno >= dt->shared->u.compnd.nmembs) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid member number") if ((memb_dt=H5T_get_member_type(dt, membno))==NULL) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to retrieve member type") if ((ret_value = H5I_register(H5I_DATATYPE, memb_dt)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable register datatype atom") done: if(ret_value<0) { if(memb_dt!=NULL) if(H5T_close(memb_dt)<0) HDONE_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, FAIL, "can't close datatype") } /* end if */ FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5T_get_member_type * * Purpose: Private function for H5Tget_member_type. Returns the data * type of the specified member. * * Return: Success: A copy of the member datatype; * modifying the returned datatype does not * modify the member type. * * Failure: NULL * * Programmer: Raymond Lu * October 8, 2002 * * Modifications: * *------------------------------------------------------------------------- */ H5T_t * H5T_get_member_type(const H5T_t *dt, unsigned membno) { H5T_t *ret_value = NULL; FUNC_ENTER_NOAPI(H5T_get_member_type, NULL) assert(dt); assert(membno < dt->shared->u.compnd.nmembs); /* Copy datatype into an atom */ if (NULL == (ret_value = H5T_copy(dt->shared->u.compnd.memb[membno].type, H5T_COPY_REOPEN))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy member datatype") done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5T_get_member_size * * Purpose: Returns the size of the specified member. * * Return: Success: The size in bytes of the member's datatype. * * Failure: 0 * * Programmer: Quincey Koziol * October 4, 2004 * * Modifications: * *------------------------------------------------------------------------- */ size_t H5T_get_member_size(const H5T_t *dt, unsigned membno) { size_t ret_value = 0; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_get_member_size) assert(dt); assert(membno < dt->shared->u.compnd.nmembs); /* Value */ ret_value = dt->shared->u.compnd.memb[membno].type->shared->size; FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5Tinsert * * Purpose: Adds another member to the compound datatype PARENT_ID. The * new member has a NAME which must be unique within the * compound datatype. The OFFSET argument defines the start of * the member in an instance of the compound datatype, and * MEMBER_ID is the type of the new member. * * Return: Success: Non-negative, the PARENT_ID compound data * type is modified to include a copy of the * member type MEMBER_ID. * * Failure: Negative * * Errors: * * Programmer: Robb Matzke * Monday, December 8, 1997 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Tinsert(hid_t parent_id, const char *name, size_t offset, hid_t member_id) { H5T_t *parent = NULL; /*the compound parent datatype */ H5T_t *member = NULL; /*the atomic member type */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Tinsert, FAIL) H5TRACE4("e","iszi",parent_id,name,offset,member_id); /* Check args */ if (parent_id==member_id) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't insert compound datatype within itself") if (NULL == (parent = H5I_object_verify(parent_id,H5I_DATATYPE)) || H5T_COMPOUND != parent->shared->type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound datatype") if (H5T_STATE_TRANSIENT!=parent->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "parent type read-only") if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no member name") if (NULL == (member = H5I_object_verify(member_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Insert */ if (H5T_insert(parent, name, offset, member) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL, "unable to insert member") done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5Tpack * * Purpose: Recursively removes padding from within a compound datatype * to make it more efficient (space-wise) to store that data. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Wednesday, January 7, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Tpack(hid_t type_id) { H5T_t *dt = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Tpack, FAIL) H5TRACE1("e","i",type_id); /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)) || H5T_detect_class(dt,H5T_COMPOUND)<=0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound datatype") /* Pack */ if (H5T_pack(dt) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to pack compound datatype") done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5T_insert * * Purpose: Adds a new MEMBER to the compound datatype PARENT. The new * member will have a NAME that is unique within PARENT and an * instance of PARENT will have the member begin at byte offset * OFFSET from the beginning. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Monday, December 8, 1997 * * Modifications: * Took out arrayness parameters - QAK, 10/6/00 * *------------------------------------------------------------------------- */ herr_t H5T_insert(const H5T_t *parent, const char *name, size_t offset, const H5T_t *member) { unsigned idx, i; size_t total_size; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_insert, FAIL) /* check args */ assert(parent && H5T_COMPOUND == parent->shared->type); assert(H5T_STATE_TRANSIENT==parent->shared->state); assert(member); assert(name && *name); /* Does NAME already exist in PARENT? */ for (i=0; ishared->u.compnd.nmembs; i++) { if (!HDstrcmp(parent->shared->u.compnd.memb[i].name, name)) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL, "member name is not unique") } /* Does the new member overlap any existing member ? */ total_size=member->shared->size; for (i=0; ishared->u.compnd.nmembs; i++) { if ((offset <= parent->shared->u.compnd.memb[i].offset && offset + total_size > parent->shared->u.compnd.memb[i].offset) || (parent->shared->u.compnd.memb[i].offset <= offset && parent->shared->u.compnd.memb[i].offset + parent->shared->u.compnd.memb[i].size > offset)) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL, "member overlaps with another member") } /* Does the new member overlap the end of the compound type? */ if(offset+total_size>parent->shared->size) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL, "member extends past end of compound type") /* Increase member array if necessary */ if (parent->shared->u.compnd.nmembs >= parent->shared->u.compnd.nalloc) { unsigned na = parent->shared->u.compnd.nalloc + H5T_COMPND_INC; H5T_cmemb_t *x = H5MM_realloc (parent->shared->u.compnd.memb, na * sizeof(H5T_cmemb_t)); if (!x) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") parent->shared->u.compnd.nalloc = na; parent->shared->u.compnd.memb = x; } /* Add member to end of member array */ idx = parent->shared->u.compnd.nmembs; parent->shared->u.compnd.memb[idx].name = H5MM_xstrdup(name); parent->shared->u.compnd.memb[idx].offset = offset; parent->shared->u.compnd.memb[idx].size = total_size; parent->shared->u.compnd.memb[idx].type = H5T_copy (member, H5T_COPY_ALL); parent->shared->u.compnd.sorted = H5T_SORT_NONE; parent->shared->u.compnd.nmembs++; /* Determine if the compound datatype stayed packed */ if(parent->shared->u.compnd.packed) { /* Check if the member type is packed */ if(H5T_is_packed(parent->shared->u.compnd.memb[idx].type)>0) { if(idx==0) { /* If the is the first member, the datatype is not packed * if the first member isn't at offset 0 */ if(parent->shared->u.compnd.memb[idx].offset>0) parent->shared->u.compnd.packed=FALSE; } /* end if */ else { /* If the is not the first member, the datatype is not * packed if the new member isn't adjoining the previous member */ if(parent->shared->u.compnd.memb[idx].offset!=(parent->shared->u.compnd.memb[idx-1].offset+parent->shared->u.compnd.memb[idx-1].size)) parent->shared->u.compnd.packed=FALSE; } /* end else */ } /* end if */ else parent->shared->u.compnd.packed=FALSE; } /* end if */ /* * Set the "force conversion" flag if the field's datatype indicates */ if(member->shared->force_conv==TRUE) parent->shared->force_conv=TRUE; done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5T_pack * * Purpose: Recursively packs a compound datatype by removing padding * bytes. This is done in place (that is, destructively). * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Wednesday, January 7, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5T_pack(const H5T_t *dt) { unsigned i; size_t offset; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5T_pack) assert(dt); if(H5T_detect_class(dt,H5T_COMPOUND)>0) { /* If datatype has been packed, skip packing it and indicate success */ if(H5T_is_packed(dt)== TRUE) HGOTO_DONE(SUCCEED) /* Check for packing unmodifiable datatype */ if (H5T_STATE_TRANSIENT!=dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "datatype is read-only") if(dt->shared->parent) { if (H5T_pack(dt->shared->parent) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to pack parent of datatype") /* Adjust size of datatype appropriately */ if(dt->shared->type==H5T_ARRAY) dt->shared->size = dt->shared->parent->shared->size * dt->shared->u.array.nelem; else if(dt->shared->type!=H5T_VLEN) dt->shared->size = dt->shared->parent->shared->size; } /* end if */ else if(dt->shared->type==H5T_COMPOUND) { /* Recursively pack the members */ for (i=0; ishared->u.compnd.nmembs; i++) if (H5T_pack(dt->shared->u.compnd.memb[i].type) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to pack part of a compound datatype") /* Remove padding between members */ if(H5T_sort_value(dt, NULL)<0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOMPARE, FAIL, "value sort failed") for (i=0, offset=0; ishared->u.compnd.nmembs; i++) { dt->shared->u.compnd.memb[i].offset = offset; offset += dt->shared->u.compnd.memb[i].size; } /* Change total size */ dt->shared->size = MAX(1, offset); /* Mark the type as packed now */ dt->shared->u.compnd.packed=TRUE; } /* end if */ } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5T_is_packed * * Purpose: Checks whether a datatype which is compound (or has compound * components) is packed. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Thursday, September 11, 2003 * * Modifications: * *------------------------------------------------------------------------- */ htri_t H5T_is_packed(const H5T_t *dt) { htri_t ret_value=TRUE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_is_packed) assert(dt); /* Go up the chain as far as possible */ while(dt->shared->parent) dt=dt->shared->parent; /* If this is a compound datatype, check if it is packed */ if(dt->shared->type==H5T_COMPOUND) ret_value=(htri_t)dt->shared->u.compnd.packed; FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_is_packed() */ xdmf-3.0+git20160803/Utilities/hdf5/H5Olayout.c0000640000175000017500000006113413003006557020675 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* Programmer: Robb Matzke * Wednesday, October 8, 1997 * * Purpose: Messages related to data layout. */ #define H5O_PACKAGE /*suppress error about including H5Opkg */ #include "H5private.h" #include "H5Dprivate.h" #include "H5Eprivate.h" #include "H5FLprivate.h" /*Free Lists */ #include "H5MFprivate.h" /* File space management */ #include "H5MMprivate.h" #include "H5Opkg.h" /* Object header functions */ /* PRIVATE PROTOTYPES */ static void *H5O_layout_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t *sh); static herr_t H5O_layout_encode(H5F_t *f, uint8_t *p, const void *_mesg); static void *H5O_layout_copy(const void *_mesg, void *_dest, unsigned update_flags); static size_t H5O_layout_size(const H5F_t *f, const void *_mesg); static herr_t H5O_layout_reset(void *_mesg); static herr_t H5O_layout_free(void *_mesg); static herr_t H5O_layout_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link); static herr_t H5O_layout_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * stream, int indent, int fwidth); /* This message derives from H5O */ const H5O_class_t H5O_LAYOUT[1] = {{ H5O_LAYOUT_ID, /*message id number */ "layout", /*message name for debugging */ sizeof(H5O_layout_t), /*native message size */ H5O_layout_decode, /*decode message */ H5O_layout_encode, /*encode message */ H5O_layout_copy, /*copy the native value */ H5O_layout_size, /*size of message on disk */ H5O_layout_reset, /*reset method */ H5O_layout_free, /*free the struct */ H5O_layout_delete, /* file delete method */ NULL, /* link method */ NULL, /*get share method */ NULL, /*set share method */ H5O_layout_debug, /*debug the message */ }}; /* For forward and backward compatibility. Version is 1 when space is * allocated; 2 when space is delayed for allocation; 3 * is revised to just store information needed for each storage type. */ #define H5O_LAYOUT_VERSION_1 1 #define H5O_LAYOUT_VERSION_2 2 #define H5O_LAYOUT_VERSION_3 3 /* Declare a free list to manage the H5O_layout_t struct */ H5FL_DEFINE(H5O_layout_t); /*------------------------------------------------------------------------- * Function: H5O_layout_decode * * Purpose: Decode an data layout message and return a pointer to a * new one created with malloc(). * * Return: Success: Ptr to new message in native order. * * Failure: NULL * * Programmer: Robb Matzke * Wednesday, October 8, 1997 * * Modifications: * Robb Matzke, 1998-07-20 * Rearranged the message to add a version number at the beginning. * * Raymond Lu, 2002-2-26 * Added version number 2 case depends on if space has been allocated * at the moment when layout header message is updated. * *------------------------------------------------------------------------- */ static void * H5O_layout_decode(H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *p, H5O_shared_t UNUSED *sh) { H5O_layout_t *mesg = NULL; unsigned u; void *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_layout_decode); /* check args */ assert(f); assert(p); assert (!sh); /* decode */ if (NULL==(mesg = H5FL_CALLOC(H5O_layout_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); /* Version. 1 when space allocated; 2 when space allocation is delayed */ mesg->version = *p++; if (mesg->versionversion>H5O_LAYOUT_VERSION_3) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for layout message"); if(mesg->version < H5O_LAYOUT_VERSION_3) { unsigned ndims; /* Num dimensions in chunk */ /* Dimensionality */ ndims = *p++; if (ndims>H5O_LAYOUT_NDIMS) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "dimensionality is too large"); /* Layout class */ mesg->type = (H5D_layout_t)*p++; assert(H5D_CONTIGUOUS == mesg->type || H5D_CHUNKED == mesg->type || H5D_COMPACT == mesg->type); /* Reserved bytes */ p += 5; /* Address */ if(mesg->type==H5D_CONTIGUOUS) H5F_addr_decode(f, &p, &(mesg->u.contig.addr)); else if(mesg->type==H5D_CHUNKED) H5F_addr_decode(f, &p, &(mesg->u.chunk.addr)); /* Read the size */ if(mesg->type!=H5D_CHUNKED) { mesg->unused.ndims=ndims; for (u = 0; u < ndims; u++) UINT32DECODE(p, mesg->unused.dim[u]); /* Don't compute size of contiguous storage here, due to possible * truncation of the dimension sizes when they were stored in this * version of the layout message. Compute the contiguous storage * size in the dataset code, where we've got the dataspace * information available also. - QAK 5/26/04 */ } /* end if */ else { mesg->u.chunk.ndims=ndims; for (u = 0; u < ndims; u++) UINT32DECODE(p, mesg->u.chunk.dim[u]); /* Compute chunk size */ for (u=1, mesg->u.chunk.size=mesg->u.chunk.dim[0]; uu.chunk.size *= mesg->u.chunk.dim[u]; } /* end if */ if(mesg->type == H5D_COMPACT) { UINT32DECODE(p, mesg->u.compact.size); if(mesg->u.compact.size > 0) { if(NULL==(mesg->u.compact.buf=H5MM_malloc(mesg->u.compact.size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for compact data buffer"); HDmemcpy(mesg->u.compact.buf, p, mesg->u.compact.size); p += mesg->u.compact.size; } } } /* end if */ else { /* Layout class */ mesg->type = (H5D_layout_t)*p++; /* Interpret the rest of the message according to the layout class */ switch(mesg->type) { case H5D_CONTIGUOUS: H5F_addr_decode(f, &p, &(mesg->u.contig.addr)); H5F_DECODE_LENGTH(f, p, mesg->u.contig.size); break; case H5D_CHUNKED: /* Dimensionality */ mesg->u.chunk.ndims = *p++; if (mesg->u.chunk.ndims>H5O_LAYOUT_NDIMS) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "dimensionality is too large"); /* B-tree address */ H5F_addr_decode(f, &p, &(mesg->u.chunk.addr)); /* Chunk dimensions */ for (u = 0; u < mesg->u.chunk.ndims; u++) UINT32DECODE(p, mesg->u.chunk.dim[u]); /* Compute chunk size */ for (u=1, mesg->u.chunk.size=mesg->u.chunk.dim[0]; uu.chunk.ndims; u++) mesg->u.chunk.size *= mesg->u.chunk.dim[u]; break; case H5D_COMPACT: UINT16DECODE(p, mesg->u.compact.size); if(mesg->u.compact.size > 0) { if(NULL==(mesg->u.compact.buf=H5MM_malloc(mesg->u.compact.size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for compact data buffer"); HDmemcpy(mesg->u.compact.buf, p, mesg->u.compact.size); p += mesg->u.compact.size; } /* end if */ break; default: HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "Invalid layout class"); } /* end switch */ } /* end else */ /* Set return value */ ret_value=mesg; done: if(ret_value==NULL) { if(mesg) H5FL_FREE(H5O_layout_t,mesg); } /* end if */ FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_layout_encode * * Purpose: Encodes a message. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Wednesday, October 8, 1997 * * Modifications: * Robb Matzke, 1998-07-20 * Rearranged the message to add a version number at the beginning. * * Raymond Lu, 2002-2-26 * Added version number 2 case depends on if space has been allocated * at the moment when layout header message is updated. * *------------------------------------------------------------------------- */ static herr_t H5O_layout_encode(H5F_t *f, uint8_t *p, const void *_mesg) { const H5O_layout_t *mesg = (const H5O_layout_t *) _mesg; unsigned u; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_layout_encode); /* check args */ assert(f); assert(mesg); assert(mesg->version>0); assert(p); /* Version */ *p++ = mesg->version; /* Check for which information to write */ if(mesg->version<3) { /* number of dimensions */ if(mesg->type!=H5D_CHUNKED) { assert(mesg->unused.ndims > 0 && mesg->unused.ndims <= H5O_LAYOUT_NDIMS); *p++ = mesg->unused.ndims; } /* end if */ else { assert(mesg->u.chunk.ndims > 0 && mesg->u.chunk.ndims <= H5O_LAYOUT_NDIMS); *p++ = mesg->u.chunk.ndims; } /* end else */ /* layout class */ *p++ = mesg->type; /* reserved bytes should be zero */ for (u=0; u<5; u++) *p++ = 0; /* data or B-tree address */ if(mesg->type==H5D_CONTIGUOUS) H5F_addr_encode(f, &p, mesg->u.contig.addr); else if(mesg->type==H5D_CHUNKED) H5F_addr_encode(f, &p, mesg->u.chunk.addr); /* dimension size */ if(mesg->type!=H5D_CHUNKED) for (u = 0; u < mesg->unused.ndims; u++) UINT32ENCODE(p, mesg->unused.dim[u]) else for (u = 0; u < mesg->u.chunk.ndims; u++) UINT32ENCODE(p, mesg->u.chunk.dim[u]); if(mesg->type==H5D_COMPACT) { UINT32ENCODE(p, mesg->u.compact.size); if(mesg->u.compact.size>0 && mesg->u.compact.buf) { HDmemcpy(p, mesg->u.compact.buf, mesg->u.compact.size); p += mesg->u.compact.size; } } } /* end if */ else { /* Layout class */ *p++ = mesg->type; /* Write out layout class specific information */ switch(mesg->type) { case H5D_CONTIGUOUS: H5F_addr_encode(f, &p, mesg->u.contig.addr); H5F_ENCODE_LENGTH(f, p, mesg->u.contig.size); break; case H5D_CHUNKED: /* Number of dimensions */ assert(mesg->u.chunk.ndims > 0 && mesg->u.chunk.ndims <= H5O_LAYOUT_NDIMS); *p++ = mesg->u.chunk.ndims; /* B-tree address */ H5F_addr_encode(f, &p, mesg->u.chunk.addr); /* Dimension sizes */ for (u = 0; u < mesg->u.chunk.ndims; u++) UINT32ENCODE(p, mesg->u.chunk.dim[u]); break; case H5D_COMPACT: /* Size of raw data */ UINT16ENCODE(p, mesg->u.compact.size); /* Raw data */ if(mesg->u.compact.size>0 && mesg->u.compact.buf) { HDmemcpy(p, mesg->u.compact.buf, mesg->u.compact.size); p += mesg->u.compact.size; } /* end if */ break; default: HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "Invalid layout class"); } /* end switch */ } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_layout_copy * * Purpose: Copies a message from _MESG to _DEST, allocating _DEST if * necessary. * * Return: Success: Ptr to _DEST * * Failure: NULL * * Programmer: Robb Matzke * Wednesday, October 8, 1997 * * Modifications: * *------------------------------------------------------------------------- */ static void * H5O_layout_copy(const void *_mesg, void *_dest, unsigned UNUSED update_flags) { const H5O_layout_t *mesg = (const H5O_layout_t *) _mesg; H5O_layout_t *dest = (H5O_layout_t *) _dest; void *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_layout_copy); /* check args */ assert(mesg); if (!dest && NULL==(dest=H5FL_MALLOC(H5O_layout_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); /* copy */ *dest = *mesg; /* Deep copy the buffer for compact datasets also */ if(mesg->type==H5D_COMPACT) { /* Allocate memory for the raw data */ if (NULL==(dest->u.compact.buf=H5MM_malloc(dest->u.compact.size))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate memory for compact dataset"); /* Copy over the raw data */ HDmemcpy(dest->u.compact.buf,mesg->u.compact.buf,dest->u.compact.size); } /* end if */ /* Set return value */ ret_value=dest; done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_layout_meta_size * * Purpose: Returns the size of the raw message in bytes except raw data * part for compact dataset. This function doesn't take into * account message alignment. * * Return: Success: Message data size in bytes(except raw data * for compact dataset) * Failure: 0 * * Programmer: Raymond Lu * August 14, 2002 * * Modifications: * *------------------------------------------------------------------------- */ size_t H5O_layout_meta_size(const H5F_t *f, const void *_mesg) { /* Casting away const OK - QAK */ H5O_layout_t *mesg = (H5O_layout_t *) _mesg; size_t ret_value; FUNC_ENTER_NOAPI_NOINIT(H5O_layout_meta_size); /* check args */ assert(f); assert(mesg); /* Check version information for new datasets */ if(mesg->version==0) { unsigned u; /* Check for dimension that would be truncated */ assert(mesg->unused.ndims > 0 && mesg->unused.ndims <= H5O_LAYOUT_NDIMS); for (u = 0; u < mesg->unused.ndims; u++) if(mesg->unused.dim[u]!=(0xffffffff&mesg->unused.dim[u])) { /* Make certain the message is encoded with the new version */ mesg->version=3; break; } /* end if */ /* If the message doesn't _have_ to be encoded with the new version */ if(mesg->version==0) { /* Version: 1 when space allocated; 2 when space allocation is delayed */ if(mesg->type==H5D_CONTIGUOUS) { if(mesg->u.contig.addr==HADDR_UNDEF) mesg->version = H5O_LAYOUT_VERSION_2; else mesg->version = H5O_LAYOUT_VERSION_1; } else if(mesg->type==H5D_COMPACT) { mesg->version = H5O_LAYOUT_VERSION_2; } else mesg->version = H5O_LAYOUT_VERSION_1; } /* end if */ } /* end if */ assert(mesg->version>0); if(mesg->versionunused.ndims * 4; /* size of each dimension */ if(mesg->type==H5D_COMPACT) ret_value += 4; /* size field for compact dataset */ else ret_value += H5F_SIZEOF_ADDR(f); /* file address of data or B-tree for chunked dataset */ } /* end if */ else { ret_value = 1 + /* Version number */ 1; /* layout class type */ switch(mesg->type) { case H5D_CONTIGUOUS: ret_value += H5F_SIZEOF_ADDR(f); /* Address of data */ ret_value += H5F_SIZEOF_SIZE(f); /* Length of data */ break; case H5D_CHUNKED: /* Number of dimensions (1 byte) */ assert(mesg->u.chunk.ndims > 0 && mesg->u.chunk.ndims <= H5O_LAYOUT_NDIMS); ret_value++; /* B-tree address */ ret_value += H5F_SIZEOF_ADDR(f); /* Address of data */ /* Dimension sizes */ ret_value += mesg->u.chunk.ndims*4; break; case H5D_COMPACT: /* Size of raw data */ ret_value+=2; break; default: HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, 0, "Invalid layout class"); } /* end switch */ } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_layout_size * * Purpose: Returns the size of the raw message in bytes. If it's * compact dataset, the data part is also included. * This function doesn't take into account message alignment. * * Return: Success: Message data size in bytes * * Failure: 0 * * Programmer: Robb Matzke * Wednesday, October 8, 1997 * * Modifications: * *------------------------------------------------------------------------- */ static size_t H5O_layout_size(const H5F_t *f, const void *_mesg) { const H5O_layout_t *mesg = (const H5O_layout_t *) _mesg; size_t ret_value; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_layout_size); /* check args */ assert(f); assert(mesg); ret_value = H5O_layout_meta_size(f, mesg); if(mesg->type==H5D_COMPACT) ret_value += mesg->u.compact.size;/* data for compact dataset */ FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_layout_reset * * Purpose: Frees resources within a data type message, but doesn't free * the message itself. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Friday, September 13, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_layout_reset (void *_mesg) { H5O_layout_t *mesg = (H5O_layout_t *) _mesg; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_layout_reset); if(mesg) { /* Free the compact storage buffer */ if(mesg->type==H5D_COMPACT) mesg->u.compact.buf=H5MM_xfree(mesg->u.compact.buf); /* Reset the message */ mesg->type=H5D_CONTIGUOUS; mesg->version=0; } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED); } /*------------------------------------------------------------------------- * Function: H5O_layout_free * * Purpose: Free's the message * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Saturday, March 11, 2000 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_layout_free (void *_mesg) { H5O_layout_t *mesg = (H5O_layout_t *) _mesg; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_layout_free); assert (mesg); /* Free the compact storage buffer */ if(mesg->type==H5D_COMPACT) mesg->u.compact.buf=H5MM_xfree(mesg->u.compact.buf); H5FL_FREE(H5O_layout_t,mesg); FUNC_LEAVE_NOAPI(SUCCEED); } /*------------------------------------------------------------------------- * Function: H5O_layout_delete * * Purpose: Free file space referenced by message * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Wednesday, March 19, 2003 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_layout_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t UNUSED adj_link) { const H5O_layout_t *mesg = (const H5O_layout_t *) _mesg; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_layout_delete); /* check args */ assert(f); assert(mesg); /* Perform different actions, depending on the type of storage */ switch(mesg->type) { case H5D_COMPACT: /* Compact data storage */ /* Nothing required */ break; case H5D_CONTIGUOUS: /* Contiguous block on disk */ /* Free the file space for the raw data */ if (H5D_contig_delete(f, dxpl_id, mesg)<0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free raw data"); break; case H5D_CHUNKED: /* Chunked blocks on disk */ /* Free the file space for the raw data */ if (H5D_istore_delete(f, dxpl_id, mesg)<0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free raw data"); break; default: HGOTO_ERROR (H5E_OHDR, H5E_BADTYPE, FAIL, "not valid storage type"); } /* end switch */ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5O_layout_delete() */ /*------------------------------------------------------------------------- * Function: H5O_layout_debug * * Purpose: Prints debugging info for a message. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Wednesday, October 8, 1997 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_layout_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg, FILE * stream, int indent, int fwidth) { const H5O_layout_t *mesg = (const H5O_layout_t *) _mesg; unsigned u; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_layout_debug); /* check args */ assert(f); assert(mesg); assert(stream); assert(indent >= 0); assert(fwidth >= 0); if(mesg->type==H5D_CHUNKED) { HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "B-tree address:", mesg->u.chunk.addr); HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, "Number of dimensions:", (unsigned long) (mesg->u.chunk.ndims)); /* Size */ HDfprintf(stream, "%*s%-*s {", indent, "", fwidth, "Size:"); for (u = 0; u < mesg->u.chunk.ndims; u++) { HDfprintf(stream, "%s%lu", u ? ", " : "", (unsigned long) (mesg->u.chunk.dim[u])); } HDfprintf(stream, "}\n"); } /* end if */ else if(mesg->type==H5D_CONTIGUOUS) { HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "Data address:", mesg->u.contig.addr); HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, "Data Size:", mesg->u.contig.size); } /* end if */ else { HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, "Data Size:", mesg->u.compact.size); } /* end else */ FUNC_LEAVE_NOAPI(SUCCEED); } xdmf-3.0+git20160803/Utilities/hdf5/H5Dmpio.c0000640000175000017500000003243013003006557020306 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: rky 980813 * * Purpose: Functions to read/write directly between app buffer and file. * * Beware of the ifdef'ed print statements. * I didn't make them portable. */ #define H5D_PACKAGE /*suppress error about including H5Dpkg */ #include "H5private.h" /* Generic Functions */ #include "H5Dpkg.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fprivate.h" /* File access */ #include "H5FDprivate.h" /* File drivers */ #include "H5Oprivate.h" /* Object headers */ #include "H5Pprivate.h" /* Property lists */ #include "H5Sprivate.h" /* Dataspaces */ #ifdef H5_HAVE_PARALLEL /* For regular hyperslab selection. */ static herr_t H5D_mpio_spaces_xfer(H5D_io_info_t *io_info, size_t elmt_size, const H5S_t *file_space, const H5S_t *mem_space, void *buf/*out*/, hbool_t do_write); /*------------------------------------------------------------------------- * Function: H5D_mpio_opt_possible * * Purpose: Checks if an direct I/O transfer is possible between memory and * the file. * * Return: Success: Non-negative: TRUE or FALSE * Failure: Negative * * Programmer: Quincey Koziol * Wednesday, April 3, 2002 * * Modifications: * *------------------------------------------------------------------------- */ htri_t H5D_mpio_opt_possible( const H5D_io_info_t *io_info, const H5S_t *mem_space, const H5S_t *file_space, const H5T_path_t *tpath) { int local_opinion = TRUE; /* This process's idea of whether to perform collective I/O or not */ int consensus; /* Consensus opinion of all processes */ int mpi_code; /* MPI error code */ htri_t ret_value=TRUE; FUNC_ENTER_NOAPI(H5D_mpio_opt_possible, FAIL); /* Check args */ assert(io_info); assert(mem_space); assert(file_space); /* For independent I/O, get out quickly and don't try to form consensus */ if (io_info->dxpl_cache->xfer_mode==H5FD_MPIO_INDEPENDENT) HGOTO_DONE(FALSE); /* Optimized MPI types flag must be set and it is must be collective IO */ /* (Don't allow parallel I/O for the MPI-posix driver, since it doesn't do real collective I/O) */ if (!(H5S_mpi_opt_types_g && io_info->dxpl_cache->xfer_mode==H5FD_MPIO_COLLECTIVE && !IS_H5FD_MPIPOSIX(io_info->dset->ent.file))) { local_opinion = FALSE; goto broadcast; } /* end if */ /* Check whether these are both simple or scalar dataspaces */ if (!((H5S_SIMPLE==H5S_GET_EXTENT_TYPE(mem_space) || H5S_SCALAR==H5S_GET_EXTENT_TYPE(mem_space)) && (H5S_SIMPLE==H5S_GET_EXTENT_TYPE(file_space) || H5S_SCALAR==H5S_GET_EXTENT_TYPE(file_space)))) { local_opinion = FALSE; goto broadcast; } /* end if */ /* Can't currently handle point selections */ if (H5S_SEL_POINTS==H5S_GET_SELECT_TYPE(mem_space) || H5S_SEL_POINTS==H5S_GET_SELECT_TYPE(file_space)) { local_opinion = FALSE; goto broadcast; } /* end if */ /* Dataset storage must be contiguous or chunked */ if (!(io_info->dset->shared->layout.type == H5D_CONTIGUOUS || io_info->dset->shared->layout.type == H5D_CHUNKED)) { local_opinion = FALSE; goto broadcast; } /* end if */ /*The handling of memory space is different for chunking and contiguous storage, For contigous storage, mem_space and file_space won't change when it it is doing disk IO. For chunking storage, mem_space will change for different chunks. So for chunking storage, whether we can use collective IO will defer until the each chunk IO is reached. For contiguous storage, if we find the MPI-IO cannot support complicated MPI derived data type, we will set use_par_opt_io = FALSE. */ #ifndef H5_MPI_COMPLEX_DERIVED_DATATYPE_WORKS if(io_info->dset->shared->layout.type == H5D_CONTIGUOUS) if((H5S_SELECT_IS_REGULAR(file_space) != TRUE) || (H5S_SELECT_IS_REGULAR(mem_space) != TRUE)) { local_opinion = FALSE; goto broadcast; } /* end if */ #endif /* Don't allow collective operations if filters need to be applied */ if(io_info->dset->shared->layout.type == H5D_CHUNKED) if(io_info->dset->shared->dcpl_cache.pline.nused>0) { local_opinion = FALSE; goto broadcast; } /* end if */ /* Don't allow collective operations if datatype conversions need to happen */ if(!H5T_path_noop(tpath)) { local_opinion = FALSE; goto broadcast; } /* end if */ broadcast: /* Form consensus opinion among all processes about whether to perform * collective I/O */ if (MPI_SUCCESS != (mpi_code = MPI_Allreduce(&local_opinion, &consensus, 1, MPI_INT, MPI_LAND, io_info->comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Allreduce failed", mpi_code) ret_value = consensus > 0 ? TRUE : FALSE; done: FUNC_LEAVE_NOAPI(ret_value); } /* H5D_mpio_opt_possible() */ /*------------------------------------------------------------------------- * Function: H5D_mpio_spaces_xfer * * Purpose: Use MPI-IO to transfer data efficiently * directly between app buffer and file. * * Return: non-negative on success, negative on failure. * * Programmer: rky 980813 * * Notes: * For collective data transfer only since this would eventually call * H5FD_mpio_setup to do setup to eveually call MPI_File_set_view in * H5FD_mpio_read or H5FD_mpio_write. MPI_File_set_view is a collective * call. Letting independent data transfer use this route would result in * hanging. * * The preconditions for calling this routine are located in the * H5S_mpio_opt_possible() routine, which determines whether this routine * can be called for a given dataset transfer. * * Modifications: * rky 980918 * Added must_convert parameter to let caller know we can't optimize * the xfer. * * Albert Cheng, 001123 * Include the MPI_type freeing as part of cleanup code. * * QAK - 2002/04/02 * Removed the must_convert parameter and move preconditions to * H5S_mpio_opt_possible() routine * * QAK - 2002/06/17 * Removed 'disp' parameter from H5FD_mpio_setup routine and use the * address of the dataset in MPI_File_set_view() calls, as necessary. * * QAK - 2002/06/18 * Removed 'dc_plist' parameter, since it was not used. Also, switch to * getting the 'extra_offset' setting for each selection. * *------------------------------------------------------------------------- */ static herr_t H5D_mpio_spaces_xfer(H5D_io_info_t *io_info, size_t elmt_size, const H5S_t *file_space, const H5S_t *mem_space, void *_buf /*out*/, hbool_t do_write ) { haddr_t addr; /* Address of dataset (or selection) within file */ size_t mpi_buf_count, mpi_file_count; /* Number of "objects" to transfer */ hsize_t mpi_buf_offset, mpi_file_offset; /* Offset within dataset where selection (ie. MPI type) begins */ MPI_Datatype mpi_buf_type, mpi_file_type; /* MPI types for buffer (memory) and file */ hbool_t mbt_is_derived=0, /* Whether the buffer (memory) type is derived and needs to be free'd */ mft_is_derived=0; /* Whether the file type is derived and needs to be free'd */ hbool_t plist_is_setup=0; /* Whether the dxpl has been customized */ uint8_t *buf=(uint8_t *)_buf; /* Alias for pointer arithmetic */ int mpi_code; /* MPI return code */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5D_mpio_spaces_xfer); /* Check args */ assert (io_info); assert (io_info->dset); assert (file_space); assert (mem_space); assert (buf); assert (IS_H5FD_MPIO(io_info->dset->ent.file)); /* Make certain we have the correct type of property list */ assert(TRUE==H5P_isa_class(io_info->dxpl_id,H5P_DATASET_XFER)); /* create the MPI buffer type */ if (H5S_mpio_space_type( mem_space, elmt_size, /* out: */ &mpi_buf_type, &mpi_buf_count, &mpi_buf_offset, &mbt_is_derived )<0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL,"couldn't create MPI buf type"); /* create the MPI file type */ if ( H5S_mpio_space_type( file_space, elmt_size, /* out: */ &mpi_file_type, &mpi_file_count, &mpi_file_offset, &mft_is_derived )<0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL,"couldn't create MPI file type"); /* Get the base address of the contiguous dataset or the chunk */ if(io_info->dset->shared->layout.type == H5D_CONTIGUOUS) addr = H5D_contig_get_addr(io_info->dset) + mpi_file_offset; else { haddr_t chunk_addr; /* for collective chunk IO */ assert(io_info->dset->shared->layout.type == H5D_CHUNKED); chunk_addr=H5D_istore_get_addr(io_info,NULL); addr = H5F_BASE_ADDR(io_info->dset->ent.file) + chunk_addr + mpi_file_offset; } /* * Pass buf type, file type to the file driver. Request an MPI type * transfer (instead of an elementary byteblock transfer). */ if(H5FD_mpi_setup_collective(io_info->dxpl_id, mpi_buf_type, mpi_file_type)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set MPI-I/O properties"); plist_is_setup=1; /* Adjust the buffer pointer to the beginning of the selection */ buf+=mpi_buf_offset; /* transfer the data */ if (do_write) { if (H5F_block_write(io_info->dset->ent.file, H5FD_MEM_DRAW, addr, mpi_buf_count, io_info->dxpl_id, buf) <0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,"MPI write failed"); } else { if (H5F_block_read (io_info->dset->ent.file, H5FD_MEM_DRAW, addr, mpi_buf_count, io_info->dxpl_id, buf) <0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL,"MPI read failed"); } done: /* Reset the dxpl settings */ if(plist_is_setup) { if(H5FD_mpi_teardown_collective(io_info->dxpl_id)<0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to reset dxpl values"); } /* end if */ /* free the MPI buf and file types */ if (mbt_is_derived) { if (MPI_SUCCESS != (mpi_code= MPI_Type_free( &mpi_buf_type ))) HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code); } if (mft_is_derived) { if (MPI_SUCCESS != (mpi_code= MPI_Type_free( &mpi_file_type ))) HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code); } FUNC_LEAVE_NOAPI(ret_value); } /* end H5D_mpio_spaces_xfer() */ /*------------------------------------------------------------------------- * Function: H5D_mpio_select_read * * Purpose: MPI-IO function to read directly from app buffer to file. * * Return: non-negative on success, negative on failure. * * Programmer: * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5D_mpio_select_read(H5D_io_info_t *io_info, size_t UNUSED nelmts, size_t elmt_size, const H5S_t *file_space, const H5S_t *mem_space, void *buf/*out*/) { herr_t ret_value; FUNC_ENTER_NOAPI_NOFUNC(H5D_mpio_select_read); ret_value = H5D_mpio_spaces_xfer(io_info, elmt_size, file_space, mem_space, buf, 0/*read*/); FUNC_LEAVE_NOAPI(ret_value); } /* end H5D_mpio_select_read() */ /*------------------------------------------------------------------------- * Function: H5D_mpio_select_write * * Purpose: MPI-IO function to write directly from app buffer to file. * * Return: non-negative on success, negative on failure. * * Programmer: * * Modifications: * * *------------------------------------------------------------------------- */ herr_t H5D_mpio_select_write(H5D_io_info_t *io_info, size_t UNUSED nelmts, size_t elmt_size, const H5S_t *file_space, const H5S_t *mem_space, const void *buf) { herr_t ret_value; FUNC_ENTER_NOAPI_NOFUNC(H5D_mpio_select_write); /*OKAY: CAST DISCARDS CONST QUALIFIER*/ ret_value = H5D_mpio_spaces_xfer(io_info, elmt_size, file_space, mem_space, (void*)buf, 1/*write*/); FUNC_LEAVE_NOAPI(ret_value); } /* end H5D_mpio_spaces_write() */ #endif /* H5_HAVE_PARALLEL */ xdmf-3.0+git20160803/Utilities/hdf5/H5Ptest.c0000640000175000017500000001111013003006557020325 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* Programmer: Quincey Koziol * Saturday May 31, 2003 * * Purpose: Generic Property Testing Functions */ #define H5P_PACKAGE /*suppress error about including H5Ppkg */ #define H5P_TESTING /*suppress warning about H5P testing funcs*/ /* Private header files */ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Iprivate.h" /* IDs */ #include "H5Ppkg.h" /* Property lists */ /* Local variables */ /* Local typedefs */ /*-------------------------------------------------------------------------- NAME H5P_get_class_path_test PURPOSE Routine to query the full path of a generic property list class USAGE char *H5P_get_class_name_test(pclass_id) hid_t pclass_id; IN: Property class to query RETURNS Success: Pointer to a malloc'ed string containing the full path of class Failure: NULL DESCRIPTION This routine retrieves the full path name of a generic property list class, starting with the root of the class hierarchy. The pointer to the name must be free'd by the user for successful calls. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS DO NOT USE THIS FUNCTION FOR ANYTHING EXCEPT TESTING H5P_get_class_path() EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ char * H5P_get_class_path_test(hid_t pclass_id) { H5P_genclass_t *pclass; /* Property class to query */ char *ret_value; /* return value */ FUNC_ENTER_NOAPI(H5P_get_class_path_test, NULL); /* Check arguments. */ if (NULL == (pclass = H5I_object_verify(pclass_id, H5I_GENPROP_CLS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a property class"); /* Get the property list class path */ if ((ret_value=H5P_get_class_path(pclass))==NULL) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, NULL, "unable to query full path of class"); done: FUNC_LEAVE_NOAPI(ret_value); } /* H5P_get_class_path_test() */ /*-------------------------------------------------------------------------- NAME H5P_open_class_path_test PURPOSE Routine to open a [copy of] a class with its full path name USAGE hid_t H5P_open_class_name_test(path) const char *path; IN: Full path name of class to open [copy of] RETURNS Success: ID of generic property class Failure: NULL DESCRIPTION This routine opens [a copy] of the class indicated by the full path. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS DO NOT USE THIS FUNCTION FOR ANYTHING EXCEPT TESTING H5P_open_class_path() EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ hid_t H5P_open_class_path_test(const char *path) { H5P_genclass_t *pclass=NULL;/* Property class to query */ hid_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5P_open_class_path_test, FAIL); /* Check arguments. */ if (NULL == path || *path=='\0') HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid class path"); /* Open the property list class */ if ((pclass=H5P_open_class_path(path))==NULL) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "unable to find class with full path"); /* Get an atom for the class */ if ((ret_value=H5I_register(H5I_GENPROP_CLS, pclass))<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to atomize property list class"); done: if(ret_value<0 && pclass) H5P_close_class(pclass); FUNC_LEAVE_NOAPI(ret_value); } /* H5P_open_class_path_test() */ xdmf-3.0+git20160803/Utilities/hdf5/H5Tconv.c0000640000175000017500000100340713003006557020332 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Module Info: Data type conversions for the H5T interface. */ #define H5T_PACKAGE /*suppress error about including H5Tpkg */ #include "H5private.h" /*generic functions */ #include "H5Eprivate.h" /*error handling */ #include "H5FLprivate.h" /*Free Lists */ #include "H5Iprivate.h" /*ID functions */ #include "H5MMprivate.h" /*memory management */ #include "H5Pprivate.h" /* Property Lists */ #include "H5Tpkg.h" /*data-type functions */ /* Conversion data for H5T_conv_struct() */ typedef struct H5T_conv_struct_t { int *src2dst; /*mapping from src to dst member num */ hid_t *src_memb_id; /*source member type ID's */ hid_t *dst_memb_id; /*destination member type ID's */ H5T_path_t **memb_path; /*conversion path for each member */ } H5T_conv_struct_t; /* Conversion data for H5T_conv_enum() */ typedef struct H5T_enum_struct_t { int base; /*lowest `in' value */ int length; /*num elements in arrays */ int *src2dst; /*map from src to dst index */ } H5T_enum_struct_t; /* Conversion data for the hardware conversion functions */ typedef struct H5T_conv_hw_t { size_t s_aligned; /*number source elements aligned */ size_t d_aligned; /*number destination elements aligned*/ } H5T_conv_hw_t; /* Declare a free list to manage pieces of vlen data */ H5FL_BLK_DEFINE_STATIC(vlen_seq); /* Declare a free list to manage pieces of array data */ H5FL_BLK_DEFINE_STATIC(array_seq); /* * These macros are for the bodies of functions that convert buffers of one * atomic type to another using hardware. * * They all start with `H5T_CONV_' and end with two letters that represent the * source and destination types, respectively. The letters `s' and `S' refer to * signed integers while the letters `u' and `U' refer to unsigned integers, and * the letters `f' and `F' refer to floating-point values. * * The letter which is capitalized indicates that the corresponding type * (source or destination) is at least as large as the other type. * * Certain conversions may experience overflow conditions which arise when the * source value has a magnitude that cannot be represented by the destination * type. * * Suffix Description * ------ ----------- * sS: Signed integers to signed integers where the destination is * at least as wide as the source. This case cannot generate * overflows. * * sU: Signed integers to unsigned integers where the destination is * at least as wide as the source. This case experiences * overflows when the source value is negative. * * uS: Unsigned integers to signed integers where the destination is * at least as wide as the source. This case can experience * overflows when the source and destination are the same size. * * uU: Unsigned integers to unsigned integers where the destination * is at least as wide as the source. Overflows are not * possible in this case. * * Ss: Signed integers to signed integers where the source is at * least as large as the destination. Overflows can occur when * the destination is narrower than the source. * * Su: Signed integers to unsigned integers where the source is at * least as large as the destination. Overflows occur when the * source value is negative and can also occur if the * destination is narrower than the source. * * Us: Unsigned integers to signed integers where the source is at * least as large as the destination. Overflows can occur for * all sizes. * * Uu: Unsigned integers to unsigned integers where the source is at * least as large as the destination. Overflows can occur if the * destination is narrower than the source. * * su: Conversion from signed integers to unsigned integers where * the source and destination are the same size. Overflow occurs * when the source value is negative. * * us: Conversion from unsigned integers to signed integers where * the source and destination are the same size. Overflow * occurs when the source magnitude is too large for the * destination. * * fF: Floating-point values to floating-point values where the * destination is at least as wide as the source. This case * cannot generate overflows. * * Ff: Floating-point values to floating-point values the source is at * least as large as the destination. Overflows can occur when * the destination is narrower than the source. * * The macros take a subset of these arguments in the order listed here: * * CDATA: A pointer to the H5T_cdata_t structure that was passed to the * conversion function. * * STYPE: The hid_t value for the source data type. * * DTYPE: The hid_t value for the destination data type. * * BUF: A pointer to the conversion buffer. * * NELMTS: The number of values to be converted. * * ST: The C name for source data type (e.g., int) * * DT: The C name for the destination data type (e.g., signed char) * * D_MIN: The minimum possible destination value. For unsigned * destination types this should be zero. For signed * destination types it's a negative value with a magnitude that * is usually one greater than D_MAX. Source values which are * smaller than D_MIN generate overflows. * * D_MAX: The maximum possible destination value. Source values which * are larger than D_MAX generate overflows. * * The macros are implemented with a generic programming technique, similar * to templates in C++. The macro which defines the "core" part of the * conversion (which actually moves the data from the source to the destination) * is invoked inside the H5T_CONV "template" macro by "gluing" it together, * which allows the core conversion macro to be invoked as necessary. * * "Core" macros come in two flavors: one which calls the exception handling * routine and one which doesn't (the "_NOEX" variant). The presence of the * exception handling routine is detected before the loop over the values and * the appropriate core routine loop is executed. * * The generic "core" macros are: (others are specific to particular conversion) * * Suffix Description * ------ ----------- * xX: Generic Conversion where the destination is at least as * wide as the source. This case cannot generate overflows. * * Xx: Generic signed conversion where the source is at least as large * as the destination. Overflows can occur when the destination is * narrower than the source. * * Ux: Generic conversion for the `Us', `Uu' & `us' cases * Overflow occurs when the source magnitude is too large for the * destination. * */ #define H5T_CONV_xX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ *((DT*)D) = (DT)(*((ST*)S)); \ } #define H5T_CONV_xX_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ *((DT*)D) = (DT)(*((ST*)S)); \ } /* Added a condition branch(else if (*((ST*)S) == (DT)(D_MAX))) which seems redundant. * It handles a special situation when the source is "float" and assigned the value * of "INT_MAX". A compiler may do roundup making this value "INT_MAX+1". However, * when do comparison "if (*((ST*)S) > (DT)(D_MAX))", the compiler may consider them * equal. In this case, do not return exception but make sure the maximum is assigned * to the destination. SLU - 2005/06/29 */ #define H5T_CONV_Xx_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ if (*((ST*)S) > (DT)(D_MAX)) { \ if ((H5T_overflow_g)(src_id, dst_id, S, D)<0) \ *((DT*)D) = (D_MAX); \ } else if (*((ST*)S) == (DT)(D_MAX)) { \ *((DT*)D) = (D_MAX); \ } else if (*((ST*)S) < (DT)(D_MIN)) { \ if ((H5T_overflow_g)(src_id, dst_id, S, D)<0) \ *((DT*)D) = (D_MIN); \ } else \ *((DT*)D) = (DT)(*((ST*)S)); \ } #define H5T_CONV_Xx_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ if (*((ST*)S) > (DT)(D_MAX)) { \ *((DT*)D) = (D_MAX); \ } else if (*((ST*)S) == (DT)(D_MAX)) { \ *((DT*)D) = (D_MAX); \ } else if (*((ST*)S) < (DT)(D_MIN)) { \ *((DT*)D) = (D_MIN); \ } else \ *((DT*)D) = (DT)(*((ST*)S)); \ } #define H5T_CONV_Ux_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ if (*((ST*)S) > (DT)(D_MAX)) { \ if ((H5T_overflow_g)(src_id, dst_id, S, D)<0) \ *((DT*)D) = (D_MAX); \ } else \ *((DT*)D) = (DT)(*((ST*)S)); \ } #define H5T_CONV_Ux_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ if (*((ST*)S) > (DT)(D_MAX)) { \ *((DT*)D) = (D_MAX); \ } else \ *((DT*)D) = (DT)(*((ST*)S)); \ } #define H5T_CONV_sS(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ assert(sizeof(ST)<=sizeof(DT)); \ H5T_CONV(H5T_CONV_xX, long_long, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ } #define H5T_CONV_sU_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ if (*((ST*)S)<0) { \ if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, S, D)<0) \ *((DT*)D) = 0; \ } else \ *((DT*)D) = (DT)(*((ST*)S)); \ } #define H5T_CONV_sU_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ if (*((ST*)S)<0) { \ *((DT*)D) = 0; \ } else \ *((DT*)D) = (DT)(*((ST*)S)); \ } #define H5T_CONV_sU(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ assert(sizeof(ST)<=sizeof(DT)); \ H5T_CONV(H5T_CONV_sU, long_long, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ } #define H5T_CONV_uS_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ if (sizeof(ST)==sizeof(DT) && *((ST*)S) > (DT)(D_MAX)) { \ if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, S, D)<0) \ *((DT*)D) = (D_MAX); \ } else \ *((DT*)D) = (DT)(*((ST*)S)); \ } #define H5T_CONV_uS_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ if (sizeof(ST)==sizeof(DT) && *((ST*)S) > (DT)(D_MAX)) { \ *((DT*)D) = (D_MAX); \ } else \ *((DT*)D) = (DT)(*((ST*)S)); \ } #define H5T_CONV_uS(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ assert(sizeof(ST)<=sizeof(DT)); \ H5T_CONV(H5T_CONV_uS, long_long, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ } #define H5T_CONV_uU(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ assert(sizeof(ST)<=sizeof(DT)); \ H5T_CONV(H5T_CONV_xX, long_long, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ } #define H5T_CONV_Ss(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ assert(sizeof(ST)>=sizeof(DT)); \ H5T_CONV(H5T_CONV_Xx, long_long, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ } #define H5T_CONV_Su_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ if (*((ST*)S) < 0) { \ if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, S, D)<0) \ *((DT*)D) = 0; \ } else if (sizeof(ST)>sizeof(DT) && *((ST*)S)>(ST)(D_MAX)) { \ /*sign vs. unsign ok in previous line*/ \ if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, S, D)<0) \ *((DT*)D) = (D_MAX); \ } else \ *((DT*)D) = (DT)(*((ST*)S)); \ } #define H5T_CONV_Su_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ if (*((ST*)S) < 0) { \ *((DT*)D) = 0; \ } else if (sizeof(ST)>sizeof(DT) && *((ST*)S)>(ST)(D_MAX)) { \ /*sign vs. unsign ok in previous line*/ \ *((DT*)D) = (D_MAX); \ } else \ *((DT*)D) = (DT)(*((ST*)S)); \ } #define H5T_CONV_Su(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ assert(sizeof(ST)>=sizeof(DT)); \ H5T_CONV(H5T_CONV_Su, long_long, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ } #define H5T_CONV_Us(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ assert(sizeof(ST)>=sizeof(DT)); \ H5T_CONV(H5T_CONV_Ux, long_long, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ } #define H5T_CONV_Uu(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ assert(sizeof(ST)>=sizeof(DT)); \ H5T_CONV(H5T_CONV_Ux, long_long, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ } #define H5T_CONV_su_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ /* Assumes memory format of unsigned & signed integers is same */ \ if (*((ST*)S)<0) { \ if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, S, D)<0) \ *((DT*)D) = 0; \ } else \ *((DT*)D) = (DT)(*((ST*)S)); \ } #define H5T_CONV_su_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ /* Assumes memory format of unsigned & signed integers is same */ \ if (*((ST*)S)<0) { \ *((DT*)D) = 0; \ } else \ *((DT*)D) = (DT)(*((ST*)S)); \ } #define H5T_CONV_su(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ assert(sizeof(ST)==sizeof(DT)); \ H5T_CONV(H5T_CONV_su, long_long, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ } #define H5T_CONV_us_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ /* Assumes memory format of unsigned & signed integers is same */ \ if (*((ST*)S) > (DT)(D_MAX)) { \ if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, S, D)<0) \ *((DT*)D) = (D_MAX); \ } else \ *((DT*)D) = (DT)(*((ST*)S)); \ } #define H5T_CONV_us_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ /* Assumes memory format of unsigned & signed integers is same */ \ if (*((ST*)S) > (DT)(D_MAX)) { \ *((DT*)D) = (D_MAX); \ } else \ *((DT*)D) = (DT)(*((ST*)S)); \ } #define H5T_CONV_us(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ assert(sizeof(ST)==sizeof(DT)); \ H5T_CONV(H5T_CONV_us, long_long, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ } #define H5T_CONV_fF(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ assert(sizeof(ST)<=sizeof(DT)); \ H5T_CONV(H5T_CONV_xX, double, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ } /* Same as H5T_CONV_Xx_CORE, except that instead of using D_MAX and D_MIN * when an overflow occurs, use the 'float' infinity values. */ #define H5T_CONV_Ff_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ if (*((ST*)S) > (DT)(D_MAX)) { \ if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, S, D)<0) \ *((DT*)D) = (H5T_NATIVE_FLOAT_POS_INF_g); \ } else if (*((ST*)S) < (DT)(D_MIN)) { \ if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, S, D)<0) \ *((DT*)D) = (H5T_NATIVE_FLOAT_NEG_INF_g); \ } else \ *((DT*)D) = (DT)(*((ST*)S)); \ } #define H5T_CONV_Ff_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ if (*((ST*)S) > (DT)(D_MAX)) { \ *((DT*)D) = (H5T_NATIVE_FLOAT_POS_INF_g); \ } else if (*((ST*)S) < (DT)(D_MIN)) { \ *((DT*)D) = (H5T_NATIVE_FLOAT_NEG_INF_g); \ } else \ *((DT*)D) = (DT)(*((ST*)S)); \ } #define H5T_CONV_Ff(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ assert(sizeof(ST)>=sizeof(DT)); \ H5T_CONV(H5T_CONV_Ff, double, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ } /* The main part of every integer hardware conversion macro */ #define H5T_CONV(GUTS,ATYPE,STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ size_t elmtno; /*element number */ \ uint8_t *src, *s; /*source buffer */ \ uint8_t *dst, *d; /*destination buffer */ \ H5T_t *st, *dt; /*data type descriptors */ \ ATYPE aligned; /*aligned type */ \ hbool_t s_mv, d_mv; /*move data to align it? */ \ ssize_t s_stride, d_stride; /*src and dst strides */ \ size_t safe; /* How many elements are safe to process in each pass */ \ \ switch (cdata->command) { \ case H5T_CONV_INIT: \ /* Sanity check and initialize statistics */ \ cdata->need_bkg = H5T_BKG_NO; \ if (NULL==(st=H5I_object(src_id)) || NULL==(dt=H5I_object(dst_id))) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, \ "unable to dereference datatype object ID") \ if (st->shared->size!=sizeof(ST) || dt->shared->size!=sizeof(DT)) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, \ "disagreement about datatype size") \ CI_ALLOC_PRIV \ break; \ \ case H5T_CONV_FREE: \ /* Print and free statistics */ \ CI_PRINT_STATS(STYPE,DTYPE); \ CI_FREE_PRIV \ break; \ \ case H5T_CONV_CONV: \ /* Initialize source & destination strides */ \ if (buf_stride) { \ assert(buf_stride>=sizeof(ST)); \ assert(buf_stride>=sizeof(DT)); \ H5_CHECK_OVERFLOW(buf_stride,size_t,ssize_t); \ s_stride = d_stride = (ssize_t)buf_stride; \ } else { \ s_stride = sizeof(ST); \ d_stride = sizeof(DT); \ } \ \ /* Is alignment required for source or dest? */ \ s_mv = H5T_NATIVE_##STYPE##_ALIGN_g>1 && \ ((size_t)buf%H5T_NATIVE_##STYPE##_ALIGN_g || \ /* Cray */ ((size_t)((ST*)buf)!=(size_t)buf) || \ s_stride%H5T_NATIVE_##STYPE##_ALIGN_g); \ d_mv = H5T_NATIVE_##DTYPE##_ALIGN_g>1 && \ ((size_t)buf%H5T_NATIVE_##DTYPE##_ALIGN_g || \ /* Cray */ ((size_t)((DT*)buf)!=(size_t)buf) || \ d_stride%H5T_NATIVE_##DTYPE##_ALIGN_g); \ CI_INC_SRC(s_mv) \ CI_INC_DST(d_mv) \ \ /* The outer loop of the type conversion macro, controlling which */ \ /* direction the buffer is walked */ \ while (nelmts>0) { \ /* Check if we need to go backwards through the buffer */ \ if(d_stride>s_stride) { \ /* Compute the number of "safe" destination elements at */ \ /* the end of the buffer (Those which don't overlap with */ \ /* any source elements at the beginning of the buffer) */ \ safe=nelmts-(((nelmts*s_stride)+(d_stride-1))/d_stride); \ \ /* If we're down to the last few elements, just wrap up */ \ /* with a "real" reverse copy */ \ if(safe<2) { \ src = (uint8_t*)buf+(nelmts-1)*s_stride; \ dst = (uint8_t*)buf+(nelmts-1)*d_stride; \ s_stride = -s_stride; \ d_stride = -d_stride; \ \ safe=nelmts; \ } /* end if */ \ else { \ src = (uint8_t*)buf+(nelmts-safe)*s_stride; \ dst = (uint8_t*)buf+(nelmts-safe)*d_stride; \ } /* end else */ \ } /* end if */ \ else { \ /* Single forward pass over all data */ \ src = dst = buf; \ safe=nelmts; \ } /* end else */ \ \ /* Perform loop over elements to convert */ \ if (s_mv && d_mv) { \ /* Alignment is required for both source and dest */ \ s = (uint8_t*)&aligned; \ H5T_CONV_LOOP_OUTER(PRE_SALIGN,PRE_DALIGN,POST_SALIGN,POST_DALIGN,GUTS,s,d,ST,DT,D_MIN,D_MAX) \ } else if(s_mv) { \ /* Alignment is required only for source */ \ s = (uint8_t*)&aligned; \ H5T_CONV_LOOP_OUTER(PRE_SALIGN,PRE_DNOALIGN,POST_SALIGN,POST_DNOALIGN,GUTS,s,dst,ST,DT,D_MIN,D_MAX) \ } else if(d_mv) { \ /* Alignment is required only for destination */ \ H5T_CONV_LOOP_OUTER(PRE_SNOALIGN,PRE_DALIGN,POST_SNOALIGN,POST_DALIGN,GUTS,src,d,ST,DT,D_MIN,D_MAX) \ } else { \ /* Alignment is not required for both source and destination */ \ H5T_CONV_LOOP_OUTER(PRE_SNOALIGN,PRE_DNOALIGN,POST_SNOALIGN,POST_DNOALIGN,GUTS,src,dst,ST,DT,D_MIN,D_MAX) \ } \ \ /* Decrement number of elements left to convert */ \ nelmts-=safe; \ } /* end while */ \ break; \ \ default: \ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, \ "unknown conversion command"); \ } \ } /* Macro defining action on source data which needs to be aligned (before main action) */ #define H5T_CONV_LOOP_PRE_SALIGN(ST) { \ HDmemcpy(&aligned, src, sizeof(ST)); \ } /* Macro defining action on source data which doesn't need to be aligned (before main action) */ #define H5T_CONV_LOOP_PRE_SNOALIGN(ST) { \ } /* Macro defining action on destination data which needs to be aligned (before main action) */ #define H5T_CONV_LOOP_PRE_DALIGN(DT) { \ d = (uint8_t*)&aligned; \ } /* Macro defining action on destination data which doesn't need to be aligned (before main action) */ #define H5T_CONV_LOOP_PRE_DNOALIGN(DT) { \ } /* Macro defining action on source data which needs to be aligned (after main action) */ #define H5T_CONV_LOOP_POST_SALIGN(ST) { \ } /* Macro defining action on source data which doesn't need to be aligned (after main action) */ #define H5T_CONV_LOOP_POST_SNOALIGN(ST) { \ } /* Macro defining action on destination data which needs to be aligned (after main action) */ #define H5T_CONV_LOOP_POST_DALIGN(DT) { \ HDmemcpy(dst, &aligned, sizeof(DT)); \ } /* Macro defining action on destination data which doesn't need to be aligned (after main action) */ #define H5T_CONV_LOOP_POST_DNOALIGN(DT) { \ } /* The outer wrapper for the type conversion loop, to check for an exception handling routine */ #define H5T_CONV_LOOP_OUTER(PRE_SALIGN_GUTS,PRE_DALIGN_GUTS,POST_SALIGN_GUTS,POST_DALIGN_GUTS,GUTS,S,D,ST,DT,D_MIN,D_MAX) \ if(H5T_overflow_g) { \ H5T_CONV_LOOP(PRE_SALIGN_GUTS,PRE_DALIGN_GUTS,POST_SALIGN_GUTS,POST_DALIGN_GUTS,GUTS,S,D,ST,DT,D_MIN,D_MAX) \ } \ else { \ H5T_CONV_LOOP(PRE_SALIGN_GUTS,PRE_DALIGN_GUTS,POST_SALIGN_GUTS,POST_DALIGN_GUTS,H5_GLUE(GUTS,_NOEX),S,D,ST,DT,D_MIN,D_MAX) \ } /* The inner loop of the type conversion macro, actually converting the elements */ #define H5T_CONV_LOOP(PRE_SALIGN_GUTS,PRE_DALIGN_GUTS,POST_SALIGN_GUTS,POST_DALIGN_GUTS,GUTS,S,D,ST,DT,D_MIN,D_MAX) \ for (elmtno=0; elmtnopriv)->s_aligned) { \ HDfprintf(H5DEBUG(T), \ " %Hu src elements aligned on %lu-byte boundaries\n", \ ((H5T_conv_hw_t *)cdata->priv)->s_aligned, \ (unsigned long)H5T_NATIVE_##STYPE##_ALIGN_g); \ } \ if (H5DEBUG(T) && ((H5T_conv_hw_t *)cdata->priv)->d_aligned) { \ HDfprintf(H5DEBUG(T), \ " %Hu dst elements aligned on %lu-byte boundaries\n", \ ((H5T_conv_hw_t *)cdata->priv)->d_aligned, \ (unsigned long)H5T_NATIVE_##DTYPE##_ALIGN_g); \ } \ } /* Allocate private alignment structure for atomic types */ # define CI_ALLOC_PRIV \ if (NULL==(cdata->priv=H5MM_calloc(sizeof(H5T_conv_hw_t)))) { \ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, \ "memory allocation failed"); \ } /* Free private alignment structure for atomic types */ # define CI_FREE_PRIV \ if(cdata->priv!=NULL) \ cdata->priv = H5MM_xfree(cdata->priv); /* Increment source alignment counter */ # define CI_INC_SRC(s) if (s) ((H5T_conv_hw_t *)cdata->priv)->s_aligned += nelmts; /* Increment destination alignment counter */ # define CI_INC_DST(d) if (d) ((H5T_conv_hw_t *)cdata->priv)->d_aligned += nelmts; #else /* H5T_DEBUG */ # define CI_PRINT_STATS(STYPE,DTYPE) /*void*/ # define CI_ALLOC_PRIV cdata->priv=NULL; # define CI_FREE_PRIV /* void */ # define CI_INC_SRC(s) /* void */ # define CI_INC_DST(d) /* void */ #endif /* H5T_DEBUG */ /* Swap two elements (I & J) of an array using a temporary variable */ #define H5_SWAP_BYTES(ARRAY,I,J) {uint8_t _tmp; _tmp=ARRAY[I]; ARRAY[I]=ARRAY[J]; ARRAY[J]=_tmp;} /* Minimum size of variable-length conversion buffer */ #define H5T_VLEN_MIN_CONF_BUF_SIZE 4096 /*------------------------------------------------------------------------- * Function: H5T_conv_noop * * Purpose: The no-op conversion. The library knows about this * conversion without it being registered. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Wednesday, January 14, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_noop(hid_t UNUSED src_id, hid_t UNUSED dst_id, H5T_cdata_t *cdata, size_t UNUSED nelmts, size_t UNUSED buf_stride, size_t UNUSED bkg_stride, void UNUSED *buf, void UNUSED *background, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_noop, FAIL); switch (cdata->command) { case H5T_CONV_INIT: cdata->need_bkg = H5T_BKG_NO; break; case H5T_CONV_CONV: /* Nothing to convert */ break; case H5T_CONV_FREE: break; default: HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command"); } done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_order_opt * * Purpose: Convert one type to another when byte order is the only * difference. This is the optimized version of H5T_conv_order() * for a handful of different sizes. * * Note: This is a soft conversion function. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Friday, January 25, 2002 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_order_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *_buf, void UNUSED *background, hid_t UNUSED dxpl_id) { uint8_t *buf = (uint8_t*)_buf; H5T_t *src = NULL; H5T_t *dst = NULL; size_t i; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_order_opt, FAIL); switch (cdata->command) { case H5T_CONV_INIT: /* Capability query */ if (NULL == (src = H5I_object(src_id)) || NULL == (dst = H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); if (src->shared->size != dst->shared->size || 0 != src->shared->u.atomic.offset || 0 != dst->shared->u.atomic.offset || !((H5T_ORDER_BE == src->shared->u.atomic.order && H5T_ORDER_LE == dst->shared->u.atomic.order) || (H5T_ORDER_LE == src->shared->u.atomic.order && H5T_ORDER_BE == dst->shared->u.atomic.order))) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported"); if (src->shared->size!=1 && src->shared->size!=2 && src->shared->size!=4 && src->shared->size!=8 && src->shared->size!=16) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported"); switch (src->shared->type) { case H5T_INTEGER: case H5T_BITFIELD: /* nothing to check */ break; case H5T_FLOAT: if (src->shared->u.atomic.u.f.sign != dst->shared->u.atomic.u.f.sign || src->shared->u.atomic.u.f.epos != dst->shared->u.atomic.u.f.epos || src->shared->u.atomic.u.f.esize != dst->shared->u.atomic.u.f.esize || src->shared->u.atomic.u.f.ebias != dst->shared->u.atomic.u.f.ebias || src->shared->u.atomic.u.f.mpos != dst->shared->u.atomic.u.f.mpos || src->shared->u.atomic.u.f.msize != dst->shared->u.atomic.u.f.msize || src->shared->u.atomic.u.f.norm != dst->shared->u.atomic.u.f.norm || src->shared->u.atomic.u.f.pad != dst->shared->u.atomic.u.f.pad) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported"); break; default: HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported"); } cdata->need_bkg = H5T_BKG_NO; break; case H5T_CONV_CONV: /* The conversion */ if (NULL == (src = H5I_object(src_id)) || NULL == (dst = H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); buf_stride = buf_stride ? buf_stride : src->shared->size; switch (src->shared->size) { case 1: /*no-op*/ break; case 2: for (/*void*/; nelmts>=20; nelmts-=20) { H5_SWAP_BYTES(buf, 0, 1); /* 0 */ buf += buf_stride; H5_SWAP_BYTES(buf, 0, 1); /* 1 */ buf += buf_stride; H5_SWAP_BYTES(buf, 0, 1); /* 2 */ buf += buf_stride; H5_SWAP_BYTES(buf, 0, 1); /* 3 */ buf += buf_stride; H5_SWAP_BYTES(buf, 0, 1); /* 4 */ buf += buf_stride; H5_SWAP_BYTES(buf, 0, 1); /* 5 */ buf += buf_stride; H5_SWAP_BYTES(buf, 0, 1); /* 6 */ buf += buf_stride; H5_SWAP_BYTES(buf, 0, 1); /* 7 */ buf += buf_stride; H5_SWAP_BYTES(buf, 0, 1); /* 8 */ buf += buf_stride; H5_SWAP_BYTES(buf, 0, 1); /* 9 */ buf += buf_stride; H5_SWAP_BYTES(buf, 0, 1); /* 10 */ buf += buf_stride; H5_SWAP_BYTES(buf, 0, 1); /* 11 */ buf += buf_stride; H5_SWAP_BYTES(buf, 0, 1); /* 12 */ buf += buf_stride; H5_SWAP_BYTES(buf, 0, 1); /* 13 */ buf += buf_stride; H5_SWAP_BYTES(buf, 0, 1); /* 14 */ buf += buf_stride; H5_SWAP_BYTES(buf, 0, 1); /* 15 */ buf += buf_stride; H5_SWAP_BYTES(buf, 0, 1); /* 16 */ buf += buf_stride; H5_SWAP_BYTES(buf, 0, 1); /* 17 */ buf += buf_stride; H5_SWAP_BYTES(buf, 0, 1); /* 18 */ buf += buf_stride; H5_SWAP_BYTES(buf, 0, 1); /* 19 */ buf += buf_stride; } for (i=0; i=20; nelmts-=20) { H5_SWAP_BYTES(buf, 0, 3); /* 0 */ H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; H5_SWAP_BYTES(buf, 0, 3); /* 1 */ H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; H5_SWAP_BYTES(buf, 0, 3); /* 2 */ H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; H5_SWAP_BYTES(buf, 0, 3); /* 3 */ H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; H5_SWAP_BYTES(buf, 0, 3); /* 4 */ H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; H5_SWAP_BYTES(buf, 0, 3); /* 5 */ H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; H5_SWAP_BYTES(buf, 0, 3); /* 6 */ H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; H5_SWAP_BYTES(buf, 0, 3); /* 7 */ H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; H5_SWAP_BYTES(buf, 0, 3); /* 8 */ H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; H5_SWAP_BYTES(buf, 0, 3); /* 9 */ H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; H5_SWAP_BYTES(buf, 0, 3); /* 10 */ H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; H5_SWAP_BYTES(buf, 0, 3); /* 11 */ H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; H5_SWAP_BYTES(buf, 0, 3); /* 12 */ H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; H5_SWAP_BYTES(buf, 0, 3); /* 13 */ H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; H5_SWAP_BYTES(buf, 0, 3); /* 14 */ H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; H5_SWAP_BYTES(buf, 0, 3); /* 15 */ H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; H5_SWAP_BYTES(buf, 0, 3); /* 16 */ H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; H5_SWAP_BYTES(buf, 0, 3); /* 17 */ H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; H5_SWAP_BYTES(buf, 0, 3); /* 18 */ H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; H5_SWAP_BYTES(buf, 0, 3); /* 19 */ H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; } for (i=0; i=10; nelmts-=10) { H5_SWAP_BYTES(buf, 0, 7); /* 0 */ H5_SWAP_BYTES(buf, 1, 6); H5_SWAP_BYTES(buf, 2, 5); H5_SWAP_BYTES(buf, 3, 4); buf += buf_stride; H5_SWAP_BYTES(buf, 0, 7); /* 1 */ H5_SWAP_BYTES(buf, 1, 6); H5_SWAP_BYTES(buf, 2, 5); H5_SWAP_BYTES(buf, 3, 4); buf += buf_stride; H5_SWAP_BYTES(buf, 0, 7); /* 2 */ H5_SWAP_BYTES(buf, 1, 6); H5_SWAP_BYTES(buf, 2, 5); H5_SWAP_BYTES(buf, 3, 4); buf += buf_stride; H5_SWAP_BYTES(buf, 0, 7); /* 3 */ H5_SWAP_BYTES(buf, 1, 6); H5_SWAP_BYTES(buf, 2, 5); H5_SWAP_BYTES(buf, 3, 4); buf += buf_stride; H5_SWAP_BYTES(buf, 0, 7); /* 4 */ H5_SWAP_BYTES(buf, 1, 6); H5_SWAP_BYTES(buf, 2, 5); H5_SWAP_BYTES(buf, 3, 4); buf += buf_stride; H5_SWAP_BYTES(buf, 0, 7); /* 5 */ H5_SWAP_BYTES(buf, 1, 6); H5_SWAP_BYTES(buf, 2, 5); H5_SWAP_BYTES(buf, 3, 4); buf += buf_stride; H5_SWAP_BYTES(buf, 0, 7); /* 6 */ H5_SWAP_BYTES(buf, 1, 6); H5_SWAP_BYTES(buf, 2, 5); H5_SWAP_BYTES(buf, 3, 4); buf += buf_stride; H5_SWAP_BYTES(buf, 0, 7); /* 7 */ H5_SWAP_BYTES(buf, 1, 6); H5_SWAP_BYTES(buf, 2, 5); H5_SWAP_BYTES(buf, 3, 4); buf += buf_stride; H5_SWAP_BYTES(buf, 0, 7); /* 8 */ H5_SWAP_BYTES(buf, 1, 6); H5_SWAP_BYTES(buf, 2, 5); H5_SWAP_BYTES(buf, 3, 4); buf += buf_stride; H5_SWAP_BYTES(buf, 0, 7); /* 9 */ H5_SWAP_BYTES(buf, 1, 6); H5_SWAP_BYTES(buf, 2, 5); H5_SWAP_BYTES(buf, 3, 4); buf += buf_stride; } for (i=0; i=10; nelmts-=10) { H5_SWAP_BYTES(buf, 0, 15); /* 0 */ H5_SWAP_BYTES(buf, 1, 14); H5_SWAP_BYTES(buf, 2, 13); H5_SWAP_BYTES(buf, 3, 12); H5_SWAP_BYTES(buf, 4, 11); H5_SWAP_BYTES(buf, 5, 10); H5_SWAP_BYTES(buf, 6, 9); H5_SWAP_BYTES(buf, 7, 8); buf += buf_stride; H5_SWAP_BYTES(buf, 0, 15); /* 1 */ H5_SWAP_BYTES(buf, 1, 14); H5_SWAP_BYTES(buf, 2, 13); H5_SWAP_BYTES(buf, 3, 12); H5_SWAP_BYTES(buf, 4, 11); H5_SWAP_BYTES(buf, 5, 10); H5_SWAP_BYTES(buf, 6, 9); H5_SWAP_BYTES(buf, 7, 8); buf += buf_stride; H5_SWAP_BYTES(buf, 0, 15); /* 2 */ H5_SWAP_BYTES(buf, 1, 14); H5_SWAP_BYTES(buf, 2, 13); H5_SWAP_BYTES(buf, 3, 12); H5_SWAP_BYTES(buf, 4, 11); H5_SWAP_BYTES(buf, 5, 10); H5_SWAP_BYTES(buf, 6, 9); H5_SWAP_BYTES(buf, 7, 8); buf += buf_stride; H5_SWAP_BYTES(buf, 0, 15); /* 3 */ H5_SWAP_BYTES(buf, 1, 14); H5_SWAP_BYTES(buf, 2, 13); H5_SWAP_BYTES(buf, 3, 12); H5_SWAP_BYTES(buf, 4, 11); H5_SWAP_BYTES(buf, 5, 10); H5_SWAP_BYTES(buf, 6, 9); H5_SWAP_BYTES(buf, 7, 8); buf += buf_stride; H5_SWAP_BYTES(buf, 0, 15); /* 4 */ H5_SWAP_BYTES(buf, 1, 14); H5_SWAP_BYTES(buf, 2, 13); H5_SWAP_BYTES(buf, 3, 12); H5_SWAP_BYTES(buf, 4, 11); H5_SWAP_BYTES(buf, 5, 10); H5_SWAP_BYTES(buf, 6, 9); H5_SWAP_BYTES(buf, 7, 8); buf += buf_stride; H5_SWAP_BYTES(buf, 0, 15); /* 5 */ H5_SWAP_BYTES(buf, 1, 14); H5_SWAP_BYTES(buf, 2, 13); H5_SWAP_BYTES(buf, 3, 12); H5_SWAP_BYTES(buf, 4, 11); H5_SWAP_BYTES(buf, 5, 10); H5_SWAP_BYTES(buf, 6, 9); H5_SWAP_BYTES(buf, 7, 8); buf += buf_stride; H5_SWAP_BYTES(buf, 0, 15); /* 6 */ H5_SWAP_BYTES(buf, 1, 14); H5_SWAP_BYTES(buf, 2, 13); H5_SWAP_BYTES(buf, 3, 12); H5_SWAP_BYTES(buf, 4, 11); H5_SWAP_BYTES(buf, 5, 10); H5_SWAP_BYTES(buf, 6, 9); H5_SWAP_BYTES(buf, 7, 8); buf += buf_stride; H5_SWAP_BYTES(buf, 0, 15); /* 7 */ H5_SWAP_BYTES(buf, 1, 14); H5_SWAP_BYTES(buf, 2, 13); H5_SWAP_BYTES(buf, 3, 12); H5_SWAP_BYTES(buf, 4, 11); H5_SWAP_BYTES(buf, 5, 10); H5_SWAP_BYTES(buf, 6, 9); H5_SWAP_BYTES(buf, 7, 8); buf += buf_stride; H5_SWAP_BYTES(buf, 0, 15); /* 8 */ H5_SWAP_BYTES(buf, 1, 14); H5_SWAP_BYTES(buf, 2, 13); H5_SWAP_BYTES(buf, 3, 12); H5_SWAP_BYTES(buf, 4, 11); H5_SWAP_BYTES(buf, 5, 10); H5_SWAP_BYTES(buf, 6, 9); H5_SWAP_BYTES(buf, 7, 8); buf += buf_stride; H5_SWAP_BYTES(buf, 0, 15); /* 9 */ H5_SWAP_BYTES(buf, 1, 14); H5_SWAP_BYTES(buf, 2, 13); H5_SWAP_BYTES(buf, 3, 12); H5_SWAP_BYTES(buf, 4, 11); H5_SWAP_BYTES(buf, 5, 10); H5_SWAP_BYTES(buf, 6, 9); H5_SWAP_BYTES(buf, 7, 8); buf += buf_stride; } for (i=0; icommand) { case H5T_CONV_INIT: /* Capability query */ if (NULL == (src = H5I_object(src_id)) || NULL == (dst = H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); if (src->shared->size != dst->shared->size || 0 != src->shared->u.atomic.offset || 0 != dst->shared->u.atomic.offset || !((H5T_ORDER_BE == src->shared->u.atomic.order && H5T_ORDER_LE == dst->shared->u.atomic.order) || (H5T_ORDER_LE == src->shared->u.atomic.order && H5T_ORDER_BE == dst->shared->u.atomic.order))) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported"); switch (src->shared->type) { case H5T_INTEGER: case H5T_BITFIELD: /* nothing to check */ break; case H5T_FLOAT: if (src->shared->u.atomic.u.f.sign != dst->shared->u.atomic.u.f.sign || src->shared->u.atomic.u.f.epos != dst->shared->u.atomic.u.f.epos || src->shared->u.atomic.u.f.esize != dst->shared->u.atomic.u.f.esize || src->shared->u.atomic.u.f.ebias != dst->shared->u.atomic.u.f.ebias || src->shared->u.atomic.u.f.mpos != dst->shared->u.atomic.u.f.mpos || src->shared->u.atomic.u.f.msize != dst->shared->u.atomic.u.f.msize || src->shared->u.atomic.u.f.norm != dst->shared->u.atomic.u.f.norm || src->shared->u.atomic.u.f.pad != dst->shared->u.atomic.u.f.pad) { HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported"); } break; default: HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported"); } cdata->need_bkg = H5T_BKG_NO; break; case H5T_CONV_CONV: /* The conversion */ if (NULL == (src = H5I_object(src_id)) || NULL == (dst = H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); buf_stride = buf_stride ? buf_stride : src->shared->size; md = src->shared->size / 2; for (i=0; ishared->size-(j+1)); } break; case H5T_CONV_FREE: /* Free private data */ break; default: HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command"); } done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_b_b * * Purpose: Convert from one bitfield to any other bitfield. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Thursday, May 20, 1999 * * Modifications: * Robb Matzke, 1999-06-16 * Added support for non-zero strides. If BUF_STRIDE is non-zero * then convert one value at each memory location advancing * BUF_STRIDE bytes each time; otherwise assume both source and * destination values are packed. *------------------------------------------------------------------------- */ herr_t H5T_conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *_buf, void UNUSED *background, hid_t UNUSED dxpl_id) { uint8_t *buf = (uint8_t*)_buf; H5T_t *src=NULL, *dst=NULL; /*source and dest data types */ int direction; /*direction of traversal */ size_t elmtno; /*element number */ size_t olap; /*num overlapping elements */ size_t half_size; /*1/2 of total size for swapping*/ uint8_t *s, *sp, *d, *dp; /*source and dest traversal ptrs*/ uint8_t dbuf[256]; /*temp destination buffer */ size_t msb_pad_offset; /*offset for dest MSB padding */ size_t i; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_b_b, FAIL); switch(cdata->command) { case H5T_CONV_INIT: /* Capability query */ if (NULL == (src = H5I_object(src_id)) || NULL == (dst = H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); if (H5T_ORDER_LE!=src->shared->u.atomic.order && H5T_ORDER_BE!=src->shared->u.atomic.order) HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order"); if (H5T_ORDER_LE!=dst->shared->u.atomic.order && H5T_ORDER_BE!=dst->shared->u.atomic.order) HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order"); cdata->need_bkg = H5T_BKG_NO; break; case H5T_CONV_FREE: break; case H5T_CONV_CONV: /* Get the data types */ if (NULL==(src=H5I_object(src_id)) || NULL==(dst=H5I_object(dst_id))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); /* * Do we process the values from beginning to end or vice versa? Also, * how many of the elements have the source and destination areas * overlapping? */ if (src->shared->size==dst->shared->size || buf_stride) { sp = dp = (uint8_t*)buf; direction = 1; olap = nelmts; } else if (src->shared->size>=dst->shared->size) { double olap_d = HDceil((double)(dst->shared->size)/ (double)(src->shared->size-dst->shared->size)); olap = (size_t)olap_d; sp = dp = (uint8_t*)buf; direction = 1; } else { double olap_d = HDceil((double)(src->shared->size)/ (double)(dst->shared->size-src->shared->size)); olap = (size_t)olap_d; sp = (uint8_t*)buf + (nelmts-1) * src->shared->size; dp = (uint8_t*)buf + (nelmts-1) * dst->shared->size; direction = -1; } /* The conversion loop */ for (elmtno=0; elmtno0) { s = sp; d = elmtno= nelmts ? dbuf : dp; } #ifndef NDEBUG /* I don't quite trust the overlap calculations yet --rpm */ if (d==dbuf) { assert ((dp>=sp && dpshared->size) || (sp>=dp && spshared->size)); } else { assert ((dpshared->size<=sp) || (spshared->size<=dp)); } #endif /* * Put the data in little endian order so our loops aren't so * complicated. We'll do all the conversion stuff assuming * little endian and then we'll fix the order at the end. */ if (H5T_ORDER_BE==src->shared->u.atomic.order) { half_size = src->shared->size/2; for (i=0; ishared->size-(i+1)]; s[src->shared->size-(i+1)] = s[i]; s[i] = tmp; } } /* * Copy the significant part of the value. If the source is larger * than the destination then invoke the overflow function or copy * as many bits as possible. Zero extra bits in the destination. */ if (src->shared->u.atomic.prec>dst->shared->u.atomic.prec) { if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, s, d)<0) { H5T_bit_copy(d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, dst->shared->u.atomic.prec); } } else { H5T_bit_copy(d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, src->shared->u.atomic.prec); H5T_bit_set(d, dst->shared->u.atomic.offset+src->shared->u.atomic.prec, dst->shared->u.atomic.prec-src->shared->u.atomic.prec, FALSE); } /* * Fill the destination padding areas. */ switch (dst->shared->u.atomic.lsb_pad) { case H5T_PAD_ZERO: H5T_bit_set(d, 0, dst->shared->u.atomic.offset, FALSE); break; case H5T_PAD_ONE: H5T_bit_set(d, 0, dst->shared->u.atomic.offset, TRUE); break; default: HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported LSB padding"); } msb_pad_offset = dst->shared->u.atomic.offset + dst->shared->u.atomic.prec; switch (dst->shared->u.atomic.msb_pad) { case H5T_PAD_ZERO: H5T_bit_set(d, msb_pad_offset, 8*dst->shared->size-msb_pad_offset, FALSE); break; case H5T_PAD_ONE: H5T_bit_set(d, msb_pad_offset, 8*dst->shared->size-msb_pad_offset, TRUE); break; default: HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported MSB padding"); } /* * Put the destination in the correct byte order. See note at * beginning of loop. */ if (H5T_ORDER_BE==dst->shared->u.atomic.order) { half_size = dst->shared->size/2; for (i=0; ishared->size-(i+1)]; d[dst->shared->size-(i+1)] = d[i]; d[i] = tmp; } } /* * If we had used a temporary buffer for the destination then we * should copy the value to the true destination buffer. */ if (d==dbuf) HDmemcpy (dp, d, dst->shared->size); if (buf_stride) { sp += direction * buf_stride; dp += direction * buf_stride; } else { sp += direction * src->shared->size; dp += direction * dst->shared->size; } } break; default: HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command"); } done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_struct_init * * Purpose: Initialize the `priv' field of `cdata' with conversion * information that is relatively constant. If `priv' is * already initialized then the member conversion functions * are recalculated. * * Priv fields are indexed by source member number or * destination member number depending on whether the field * contains information about the source data type or the * destination data type (fields that contains the same * information for both source and destination are indexed by * source member number). The src2dst[] priv array maps source * member numbers to destination member numbers, but if the * source member doesn't have a corresponding destination member * then the src2dst[i]=-1. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Monday, January 26, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5T_conv_struct_init (H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata, hid_t dxpl_id) { H5T_conv_struct_t *priv = (H5T_conv_struct_t*)(cdata->priv); int *src2dst = NULL; unsigned i, j; H5T_t *type = NULL; hid_t tid; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5T_conv_struct_init); if (!priv) { /* * Allocate private data structure and arrays. */ if (NULL==(priv=cdata->priv=H5MM_calloc(sizeof(H5T_conv_struct_t))) || NULL==(priv->src2dst=H5MM_malloc(src->shared->u.compnd.nmembs * sizeof(int))) || NULL==(priv->src_memb_id=H5MM_malloc(src->shared->u.compnd.nmembs * sizeof(hid_t))) || NULL==(priv->dst_memb_id=H5MM_malloc(dst->shared->u.compnd.nmembs * sizeof(hid_t)))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); src2dst = priv->src2dst; /* * Insure that members are sorted. */ H5T_sort_value(src, NULL); H5T_sort_value(dst, NULL); /* * Build a mapping from source member number to destination member * number. If some source member is not a destination member then that * mapping element will be negative. Also create atoms for each * source and destination member data type so we can look up the * member data type conversion functions later. */ for (i=0; ishared->u.compnd.nmembs; i++) { src2dst[i] = -1; for (j=0; jshared->u.compnd.nmembs; j++) { if (!HDstrcmp (src->shared->u.compnd.memb[i].name, dst->shared->u.compnd.memb[j].name)) { src2dst[i] = j; break; } } if (src2dst[i]>=0) { type = H5T_copy (src->shared->u.compnd.memb[i].type, H5T_COPY_ALL); tid = H5I_register (H5I_DATATYPE, type); assert (tid>=0); priv->src_memb_id[i] = tid; type = H5T_copy (dst->shared->u.compnd.memb[src2dst[i]].type, H5T_COPY_ALL); tid = H5I_register (H5I_DATATYPE, type); assert (tid>=0); priv->dst_memb_id[src2dst[i]] = tid; } } } else { /* Restore sorted conditions for the datatypes */ /* (Required for the src2dst array to be valid) */ H5T_sort_value(src, NULL); H5T_sort_value(dst, NULL); } /* end else */ /* * (Re)build the cache of member conversion functions and pointers to * their cdata entries. */ src2dst = priv->src2dst; H5MM_xfree(priv->memb_path); if (NULL==(priv->memb_path=H5MM_malloc(src->shared->u.compnd.nmembs * sizeof(H5T_path_t*)))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); for (i=0; ishared->u.compnd.nmembs; i++) { if (src2dst[i]>=0) { H5T_path_t *tpath = H5T_path_find(src->shared->u.compnd.memb[i].type, dst->shared->u.compnd.memb[src2dst[i]].type, NULL, NULL, dxpl_id); if (NULL==(priv->memb_path[i] = tpath)) { H5MM_xfree(priv->src2dst); H5MM_xfree(priv->src_memb_id); H5MM_xfree(priv->dst_memb_id); H5MM_xfree(priv->memb_path); cdata->priv = priv = H5MM_xfree (priv); HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unable to convert member data type"); } } } /* Check if we need a background buffer */ if (H5T_detect_class(src,H5T_COMPOUND)==TRUE || H5T_detect_class(dst,H5T_COMPOUND)==TRUE) cdata->need_bkg = H5T_BKG_YES; cdata->recalc = FALSE; done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_struct * * Purpose: Converts between compound data types. This is a soft * conversion function. The algorithm is basically: * * For each element do * For I=1..NELMTS do * If sizeof detination type <= sizeof source type then * Convert member to destination type; * Move member as far left as possible; * * For I=NELMTS..1 do * If not destination type then * Convert member to destination type; * Move member to correct position in BKG * * Copy BKG to BUF * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Thursday, January 22, 1998 * * Modifications: * Robb Matzke, 1999-06-16 * Added support for non-zero strides. If BUF_STRIDE is * non-zero then convert one value at each memory location * advancing BUF_STRIDE bytes each time; otherwise assume * both source and destination values are packed. * * Robb Matzke, 2000-05-17 * Added the BKG_STRIDE argument to fix a design bug. If * BUF_STRIDE and BKG_STRIDE are both non-zero then each * data element converted will be placed temporarily at a * multiple of BKG_STRIDE in the BKG buffer; otherwise the * BKG buffer is assumed to be a packed array of destination * datatype. *------------------------------------------------------------------------- */ herr_t H5T_conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *_buf, void *_bkg, hid_t dxpl_id) { uint8_t *buf = (uint8_t *)_buf; /*cast for pointer arithmetic */ uint8_t *bkg = (uint8_t *)_bkg; /*background pointer arithmetic */ uint8_t *xbuf=buf, *xbkg=bkg; /*temp pointers into buf and bkg*/ H5T_t *src = NULL; /*source data type */ H5T_t *dst = NULL; /*destination data type */ int *src2dst = NULL; /*maps src member to dst member */ H5T_cmemb_t *src_memb = NULL; /*source struct member descript.*/ H5T_cmemb_t *dst_memb = NULL; /*destination struct memb desc. */ size_t offset; /*byte offset wrt struct */ size_t src_delta; /*source stride */ size_t elmtno; unsigned u; /*counters */ int i; /*counters */ H5T_conv_struct_t *priv = (H5T_conv_struct_t *)(cdata->priv); herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_struct, FAIL); switch (cdata->command) { case H5T_CONV_INIT: /* * First, determine if this conversion function applies to the * conversion path SRC_ID-->DST_ID. If not, return failure; * otherwise initialize the `priv' field of `cdata' with information * that remains (almost) constant for this conversion path. */ if (NULL == (src = H5I_object(src_id)) || NULL == (dst = H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); assert (H5T_COMPOUND==src->shared->type); assert (H5T_COMPOUND==dst->shared->type); if (H5T_conv_struct_init (src, dst, cdata, dxpl_id)<0) HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize conversion data"); break; case H5T_CONV_FREE: /* * Free the private conversion data. */ H5MM_xfree(priv->src2dst); H5MM_xfree(priv->src_memb_id); H5MM_xfree(priv->dst_memb_id); H5MM_xfree(priv->memb_path); cdata->priv = priv = H5MM_xfree (priv); break; case H5T_CONV_CONV: /* * Conversion. */ if (NULL == (src = H5I_object(src_id)) || NULL == (dst = H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); assert (priv); assert (bkg && cdata->need_bkg); if (cdata->recalc && H5T_conv_struct_init (src, dst, cdata, dxpl_id)<0) HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize conversion data"); /* * Insure that members are sorted. */ H5T_sort_value(src, NULL); H5T_sort_value(dst, NULL); src2dst = priv->src2dst; /* * Direction of conversion and striding through background. */ if (buf_stride) { src_delta = buf_stride; if (!bkg_stride) bkg_stride = dst->shared->size; } else if (dst->shared->size <= src->shared->size) { src_delta = src->shared->size; bkg_stride = dst->shared->size; } else { src_delta = -(int)src->shared->size; /*overflow shouldn't be possible*/ bkg_stride = -(int)dst->shared->size; /*overflow shouldn't be possible*/ xbuf += (nelmts-1) * src->shared->size; xbkg += (nelmts-1) * dst->shared->size; } /* Conversion loop... */ for (elmtno=0; elmtnoshared->u.compnd.nmembs; u++) { if (src2dst[u]<0) continue; /*subsetting*/ src_memb = src->shared->u.compnd.memb + u; dst_memb = dst->shared->u.compnd.memb + src2dst[u]; if (dst_memb->size <= src_memb->size) { if (H5T_convert(priv->memb_path[u], priv->src_memb_id[u], priv->dst_memb_id[src2dst[u]], 1, 0, 0, /*no striding (packed array)*/ xbuf+src_memb->offset, xbkg+dst_memb->offset, dxpl_id)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert compound data type member"); HDmemmove (xbuf+offset, xbuf+src_memb->offset, dst_memb->size); offset += dst_memb->size; } else { HDmemmove (xbuf+offset, xbuf+src_memb->offset, src_memb->size); offset += src_memb->size; } } /* * For each source member which will be present in the * destination, convert the member to the destination type if it * is larger than the source type (that is, has not been converted * yet). Then copy the member to the destination offset in the * background buffer. */ for (i=src->shared->u.compnd.nmembs-1; i>=0; --i) { if (src2dst[i]<0) continue; /*subsetting*/ src_memb = src->shared->u.compnd.memb + i; dst_memb = dst->shared->u.compnd.memb + src2dst[i]; if (dst_memb->size > src_memb->size) { offset -= src_memb->size; if (H5T_convert(priv->memb_path[i], priv->src_memb_id[i], priv->dst_memb_id[src2dst[i]], 1, 0, 0, /*no striding (packed array)*/ xbuf+offset, xbkg+dst_memb->offset, dxpl_id)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert compound data type member"); } else { offset -= dst_memb->size; } HDmemmove (xbkg+dst_memb->offset, xbuf+offset, dst_memb->size); } assert (0==offset); /* * Update pointers */ xbuf += src_delta; xbkg += bkg_stride; } /* If the bkg_stride was set to -(dst->shared->size), make it positive now */ if(buf_stride==0 && dst->shared->size>src->shared->size) bkg_stride=dst->shared->size; /* * Copy the background buffer back into the in-place conversion * buffer. */ for (xbuf=buf, xbkg=bkg, elmtno=0; elmtnoshared->size); xbuf += buf_stride ? buf_stride : dst->shared->size; xbkg += bkg_stride; } break; default: /* Some other command we don't know about yet.*/ HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command"); } done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_struct_opt * * Purpose: Converts between compound data types in a manner more * efficient than the general-purpose H5T_conv_struct() * function. This function isn't applicable if the destination * is larger than the source type. This is a soft conversion * function. The algorithm is basically: * * For each member of the struct * If sizeof detination type <= sizeof source type then * Convert member to destination type for all elements * Move memb to BKG buffer for all elements * Else * Move member as far left as possible for all elements * * For each member of the struct (in reverse order) * If not destination type then * Convert member to destination type for all elements * Move member to correct position in BKG for all elements * * Copy BKG to BUF for all elements * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Thursday, January 22, 1998 * * Modifications: * Robb Matzke, 1999-06-16 * Added support for non-zero strides. If BUF_STRIDE is * non-zero then convert one value at each memory location * advancing BUF_STRIDE bytes each time; otherwise assume both * source and destination values are packed. * * Robb Matzke, 1999-06-16 * If the source and destination data structs are the same size * then we can convert on a field-by-field basis instead of an * element by element basis. In other words, for all struct * elements being converted by this function call, first convert * all of the field1's, then all field2's, etc. This can * drastically reduce the number of calls to H5T_convert() and * thereby eliminate most of the conversion constant overhead. * * Robb Matzke, 2000-05-17 * Added the BKG_STRIDE argument to fix a design bug. If * BUF_STRIDE and BKG_STRIDE are both non-zero then each * data element converted will be placed temporarily at a * multiple of BKG_STRIDE in the BKG buffer; otherwise the * BKG buffer is assumed to be a packed array of destination * datatype. *------------------------------------------------------------------------- */ herr_t H5T_conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *_buf, void *_bkg, hid_t dxpl_id) { uint8_t *buf = (uint8_t *)_buf; /*cast for pointer arithmetic */ uint8_t *bkg = (uint8_t *)_bkg; /*background pointer arithmetic */ uint8_t *xbuf = NULL; /*temporary pointer into `buf' */ uint8_t *xbkg = NULL; /*temporary pointer into `bkg' */ H5T_t *src = NULL; /*source data type */ H5T_t *dst = NULL; /*destination data type */ int *src2dst = NULL; /*maps src member to dst member */ H5T_cmemb_t *src_memb = NULL; /*source struct member descript.*/ H5T_cmemb_t *dst_memb = NULL; /*destination struct memb desc. */ size_t offset; /*byte offset wrt struct */ size_t elmtno; /*element counter */ unsigned u; /*counters */ int i; /*counters */ H5T_conv_struct_t *priv = NULL; /*private data */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_struct_opt, FAIL); switch (cdata->command) { case H5T_CONV_INIT: /* * First, determine if this conversion function applies to the * conversion path SRC_ID-->DST_ID. If not, return failure; * otherwise initialize the `priv' field of `cdata' with information * that remains (almost) constant for this conversion path. */ if (NULL == (src = H5I_object(src_id)) || NULL == (dst = H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); assert (H5T_COMPOUND==src->shared->type); assert (H5T_COMPOUND==dst->shared->type); /* Initialize data which is relatively constant */ if (H5T_conv_struct_init (src, dst, cdata, dxpl_id)<0) HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize conversion data"); priv = (H5T_conv_struct_t *)(cdata->priv); src2dst = priv->src2dst; /* * If the destination type is not larger than the source type then * this conversion function is guaranteed to work (provided all * members can be converted also). Otherwise the determination is * quite a bit more complicated. Essentially we have to make sure * that there is always room in the source buffer to do the * conversion of a member in place. This is basically the same pair * of loops as in the actual conversion except it checks that there * is room for each conversion instead of actually doing anything. */ if (dst->shared->size > src->shared->size) { for (u=0, offset=0; ushared->u.compnd.nmembs; u++) { if (src2dst[u]<0) continue; src_memb = src->shared->u.compnd.memb + u; dst_memb = dst->shared->u.compnd.memb + src2dst[u]; if (dst_memb->size > src_memb->size) offset += src_memb->size; } for (i=src->shared->u.compnd.nmembs-1; i>=0; --i) { if (src2dst[i]<0) continue; src_memb = src->shared->u.compnd.memb + i; dst_memb = dst->shared->u.compnd.memb + src2dst[i]; if (dst_memb->size > src_memb->size) { offset -= src_memb->size; if (dst_memb->size > src->shared->size-offset) { H5MM_xfree(priv->src2dst); H5MM_xfree(priv->src_memb_id); H5MM_xfree(priv->dst_memb_id); H5MM_xfree(priv->memb_path); cdata->priv = priv = H5MM_xfree (priv); HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "convertion is unsupported by this function"); } } } } break; case H5T_CONV_FREE: /* * Free the private conversion data. */ priv = (H5T_conv_struct_t *)(cdata->priv); H5MM_xfree(priv->src2dst); H5MM_xfree(priv->src_memb_id); H5MM_xfree(priv->dst_memb_id); H5MM_xfree(priv->memb_path); cdata->priv = priv = H5MM_xfree (priv); break; case H5T_CONV_CONV: /* * Conversion. */ if (NULL == (src = H5I_object(src_id)) || NULL == (dst = H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); /* Update cached data if necessary */ if (cdata->recalc && H5T_conv_struct_init (src, dst, cdata, dxpl_id)<0) HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize conversion data"); priv = (H5T_conv_struct_t *)(cdata->priv); src2dst = priv->src2dst; assert(priv); assert(bkg && cdata->need_bkg); /* * Insure that members are sorted. */ H5T_sort_value(src, NULL); H5T_sort_value(dst, NULL); /* * Calculate strides. If BUF_STRIDE is non-zero then convert one * data element at every BUF_STRIDE bytes through the main buffer * (BUF), leaving the result of each conversion at the same * location; otherwise assume the source and destination data are * packed tightly based on src->shared->size and dst->shared->size. Also, if * BUF_STRIDE and BKG_STRIDE are both non-zero then place * background data into the BKG buffer at multiples of BKG_STRIDE; * otherwise assume BKG buffer is the packed destination datatype. */ if (!buf_stride || !bkg_stride) bkg_stride = dst->shared->size; /* * For each member where the destination is not larger than the * source, stride through all the elements converting only that member * in each element and then copying the element to its final * destination in the bkg buffer. Otherwise move the element as far * left as possible in the buffer. */ for (u=0, offset=0; ushared->u.compnd.nmembs; u++) { if (src2dst[u]<0) continue; /*subsetting*/ src_memb = src->shared->u.compnd.memb + u; dst_memb = dst->shared->u.compnd.memb + src2dst[u]; if (dst_memb->size <= src_memb->size) { xbuf = buf + src_memb->offset; xbkg = bkg + dst_memb->offset; if (H5T_convert(priv->memb_path[u], priv->src_memb_id[u], priv->dst_memb_id[src2dst[u]], nelmts, buf_stride ? buf_stride : src->shared->size, bkg_stride, xbuf, xbkg, dxpl_id)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert compound data type member"); for (elmtno=0; elmtnosize); xbuf += buf_stride ? buf_stride : src->shared->size; xbkg += bkg_stride; } } else { for (xbuf=buf, elmtno=0; elmtnooffset, src_memb->size); xbuf += buf_stride ? buf_stride : src->shared->size; } offset += src_memb->size; } } /* * Work from right to left, converting those members that weren't * converted in the previous loop (those members where the destination * is larger than the source) and them to their final position in the * bkg buffer. */ for (i=src->shared->u.compnd.nmembs-1; i>=0; --i) { if (src2dst[i]<0) continue; src_memb = src->shared->u.compnd.memb + i; dst_memb = dst->shared->u.compnd.memb + src2dst[i]; if (dst_memb->size > src_memb->size) { offset -= src_memb->size; xbuf = buf + offset; xbkg = bkg + dst_memb->offset; if (H5T_convert(priv->memb_path[i], priv->src_memb_id[i], priv->dst_memb_id[src2dst[i]], nelmts, buf_stride ? buf_stride : src->shared->size, bkg_stride, xbuf, xbkg, dxpl_id)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert compound data type member"); for (elmtno=0; elmtnosize); xbuf += buf_stride ? buf_stride : src->shared->size; xbkg += bkg_stride; } } } /* Move background buffer into result buffer */ for (xbuf=buf, xbkg=bkg, elmtno=0; elmtnoshared->size); xbuf += buf_stride ? buf_stride : dst->shared->size; xbkg += bkg_stride; } break; default: /* Some other command we don't know about yet.*/ HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command"); } done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_enum_init * * Purpose: Initialize information for H5T_conv_enum(). * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Monday, January 4, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5T_conv_enum_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata) { H5T_enum_struct_t *priv=NULL; /*private conversion data */ int n; /*src value cast as native int */ int domain[2]; /*min and max source values */ int *map=NULL; /*map from src value to dst idx */ unsigned length; /*nelmts in map array */ unsigned i, j; /*counters */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5T_conv_enum_init); cdata->need_bkg = H5T_BKG_NO; if (NULL==(priv=cdata->priv=H5MM_calloc(sizeof(*priv)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); if (0==src->shared->u.enumer.nmembs) HGOTO_DONE(SUCCEED); /* * Check that the source symbol names are a subset of the destination * symbol names and build a map from source member index to destination * member index. */ H5T_sort_name(src, NULL); H5T_sort_name(dst, NULL); if (NULL==(priv->src2dst=H5MM_malloc(src->shared->u.enumer.nmembs*sizeof(int)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");; for (i=0, j=0; ishared->u.enumer.nmembs && jshared->u.enumer.nmembs; i++, j++) { while (jshared->u.enumer.nmembs && HDstrcmp(src->shared->u.enumer.name[i], dst->shared->u.enumer.name[j])) j++; if (j>=dst->shared->u.enumer.nmembs) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "source type is not a subset of destination type"); priv->src2dst[i] = j; } /* * The conversion function will use an O(log N) lookup method for each * value converted. However, if all of the following constraints are met * then we can build a perfect hash table and use an O(1) lookup method. * * A: The source data type size matches one of our native data type * sizes. * * B: After casting the source value bit pattern to a native type * the size of the range of values is less than 20% larger than * the number of values. * * If this special case is met then we use the source bit pattern cast as * a native integer type as an index into the `val2dst'. The values of * that array are the index numbers in the destination type or negative * if the entry is unused. */ if (1==src->shared->size || sizeof(short)==src->shared->size || sizeof(int)==src->shared->size) { for (i=0; ishared->u.enumer.nmembs; i++) { if (1==src->shared->size) { n = *((signed char*)(src->shared->u.enumer.value+i)); } else if (sizeof(short)==src->shared->size) { n = *((short*)(src->shared->u.enumer.value+i*src->shared->size)); } else { n = *((int*)(src->shared->u.enumer.value+i*src->shared->size)); } if (0==i) { domain[0] = domain[1] = n; } else { domain[0] = MIN(domain[0], n); domain[1] = MAX(domain[1], n); } } length = (domain[1]-domain[0])+1; if (src->shared->u.enumer.nmembs<2 || (double)length/src->shared->u.enumer.nmembs<1.2) { priv->base = domain[0]; priv->length = length; if (NULL==(map=H5MM_malloc(length*sizeof(int)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); for (i=0; ishared->u.enumer.nmembs; i++) { if (1==src->shared->size) { n = *((signed char*)(src->shared->u.enumer.value+i)); } else if (sizeof(short)==src->shared->size) { n = *((short*)(src->shared->u.enumer.value+i*src->shared->size)); } else { n = *((int*)(src->shared->u.enumer.value+i*src->shared->size)); } n -= priv->base; assert(n>=0 && nlength); assert(map[n]<0); map[n] = priv->src2dst[i]; } /* * Replace original src2dst array with our new one. The original * was indexed by source member number while the new one is * indexed by source values. */ H5MM_xfree(priv->src2dst); priv->src2dst = map; HGOTO_DONE(SUCCEED); } } /* Sort source type by value and adjust src2dst[] appropriately */ H5T_sort_value(src, priv->src2dst); done: if (ret_value<0 && priv) { H5MM_xfree(priv->src2dst); H5MM_xfree(priv); cdata->priv = NULL; } FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_enum * * Purpose: Converts one type of enumerated data to another. * * Return: Success: Non-negative * * Failure: negative * * Programmer: Robb Matzke * Monday, January 4, 1999 * * Modifications: * Robb Matzke, 1999-06-16 * Added support for non-zero strides. If BUF_STRIDE is non-zero * then convert one value at each memory location advancing * BUF_STRIDE bytes each time; otherwise assume both source and * destination values are packed. *------------------------------------------------------------------------- */ herr_t H5T_conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *_buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { uint8_t *buf = (uint8_t*)_buf; /*cast for pointer arithmetic */ H5T_t *src=NULL, *dst=NULL; /*src and dst data types */ uint8_t *s=NULL, *d=NULL; /*src and dst BUF pointers */ int src_delta, dst_delta; /*conversion strides */ int n; /*src value cast as native int */ size_t i; /*counters */ H5T_enum_struct_t *priv = (H5T_enum_struct_t*)(cdata->priv); herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_enum, FAIL); switch (cdata->command) { case H5T_CONV_INIT: /* * Determine if this conversion function applies to the conversion * path SRC_ID->DST_ID. If not return failure; otherwise initialize * the `priv' field of `cdata' with information about the underlying * integer conversion. */ if (NULL == (src = H5I_object(src_id)) || NULL == (dst = H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); assert (H5T_ENUM==src->shared->type); assert (H5T_ENUM==dst->shared->type); if (H5T_conv_enum_init(src, dst, cdata)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize private data"); break; case H5T_CONV_FREE: #ifdef H5T_DEBUG if (H5DEBUG(T)) { fprintf(H5DEBUG(T), " Using %s mapping function%s\n", priv->length?"O(1)":"O(log N)", priv->length?"":", where N is the number of enum members"); } #endif if (priv) { H5MM_xfree(priv->src2dst); H5MM_xfree(priv); } cdata->priv = NULL; break; case H5T_CONV_CONV: if (NULL == (src = H5I_object(src_id)) || NULL == (dst = H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); assert (H5T_ENUM==src->shared->type); assert (H5T_ENUM==dst->shared->type); /* priv->src2dst map was computed for certain sort keys. Make sure those same * sort keys are used here during conversion. See H5T_conv_enum_init(). But * we actually don't care about the source type's order when doing the O(1) * conversion algorithm, which is turned on by non-zero priv->length */ H5T_sort_name(dst, NULL); if (!priv->length) H5T_sort_value(src, NULL); /* * Direction of conversion. */ if (buf_stride) { src_delta = dst_delta = (int)buf_stride; s = d = buf; } else if (dst->shared->size <= src->shared->size) { src_delta = (int)src->shared->size; /*overflow shouldn't be possible*/ dst_delta = (int)dst->shared->size; /*overflow shouldn't be possible*/ s = d = buf; } else { src_delta = -(int)src->shared->size; /*overflow shouldn't be possible*/ dst_delta = -(int)dst->shared->size; /*overflow shouldn't be possible*/ s = buf + (nelmts-1) * src->shared->size; d = buf + (nelmts-1) * dst->shared->size; } for (i=0; ilength) { /* Use O(1) lookup */ if (1==src->shared->size) { n = *((signed char*)s); } else if (sizeof(short)==src->shared->size) { n = *((short*)s); } else { n = *((int*)s); } n -= priv->base; if (n<0 || n>=priv->length || priv->src2dst[n]<0) { if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, s, d)<0) { HDmemset(d, 0xff, dst->shared->size); } } else { HDmemcpy(d, dst->shared->u.enumer.value+priv->src2dst[n]*dst->shared->size, dst->shared->size); } } else { /* Use O(log N) lookup */ int lt = 0; int rt = src->shared->u.enumer.nmembs; int md, cmp; while (ltshared->u.enumer.value+md*src->shared->size, src->shared->size); if (cmp<0) { rt = md; } else if (cmp>0) { lt = md+1; } else { break; } } if (lt>=rt) { if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, s, d)<0) { HDmemset(d, 0xff, dst->shared->size); } } else { HDmemcpy(d, dst->shared->u.enumer.value+priv->src2dst[md]*dst->shared->size, dst->shared->size); } } } break; default: /* Some other command we don't know about yet.*/ HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command"); } done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_vlen * * Purpose: Converts between VL data types in memory and on disk. * This is a soft conversion function. The algorithm is * basically: * * For every VL struct in the main buffer: * 1. Allocate space for temporary dst VL data (reuse buffer * if possible) * 2. Copy VL data from src buffer into dst buffer * 3. Convert VL data into dst representation * 4. Allocate buffer in dst heap * 5. Free heap objects storing old data * 6. Write dst VL data into dst heap * 7. Store (heap ID or pointer) and length in main dst buffer * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Wednesday, May 26, 1999 * * Modifications: * * Quincey Koziol, 2 July, 1999 * Enabled support for non-zero strides. If BUF_STRIDE is non-zero * then convert one value at each memory location advancing * BUF_STRIDE bytes each time; otherwise assume both source and * destination values are packed. * * Raymond Lu, 26 June, 2002 * Background buffer is used for freeing heap objects storing * old data. At this moment, it only frees the first level of * VL datatype. It doesn't handle nested VL datatypes. * *------------------------------------------------------------------------- */ herr_t H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dxpl_id) { H5T_vlen_alloc_info_t _vl_alloc_info; /* VL allocation info buffer */ H5T_vlen_alloc_info_t *vl_alloc_info=&_vl_alloc_info; /* VL allocation info */ H5T_path_t *tpath; /* Type conversion path */ hbool_t noop_conv=FALSE; /* Flag to indicate a noop conversion */ hbool_t write_to_file=FALSE; /* Flag to indicate writing to file */ hbool_t parent_is_vlen; /* Flag to indicate parent is vlen datatyp */ hid_t tsrc_id = -1, tdst_id = -1;/*temporary type atoms */ H5T_t *src = NULL; /*source data type */ H5T_t *dst = NULL; /*destination data type */ H5HG_t bg_hobjid, parent_hobjid; uint8_t *s; /*source buffer */ uint8_t *d; /*destination buffer */ uint8_t *b; /*background buffer */ ssize_t s_stride, d_stride; /*src and dst strides */ ssize_t b_stride; /*bkg stride */ size_t safe; /*how many elements are safe to process in each pass */ ssize_t seq_len; /*the number of elements in the current sequence*/ size_t bg_seq_len=0; size_t src_base_size, dst_base_size;/*source & destination base size*/ void *conv_buf=NULL; /*temporary conversion buffer */ size_t conv_buf_size=0; /*size of conversion buffer in bytes */ void *tmp_buf=NULL; /*temporary background buffer */ size_t tmp_buf_size=0; /*size of temporary bkg buffer */ hbool_t nested=FALSE; /*flag of nested VL case */ size_t elmtno; /*element number counter */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_vlen, FAIL); switch (cdata->command) { case H5T_CONV_INIT: /* * First, determine if this conversion function applies to the * conversion path SRC_ID-->DST_ID. If not, return failure; * otherwise initialize the `priv' field of `cdata' with * information that remains (almost) constant for this * conversion path. */ if (NULL == (src = H5I_object(src_id)) || NULL == (dst = H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); assert (H5T_VLEN==src->shared->type); assert (H5T_VLEN==dst->shared->type); /* Variable-length types don't need a background buffer */ cdata->need_bkg = H5T_BKG_NO; break; case H5T_CONV_FREE: /* QAK - Nothing to do currently */ break; case H5T_CONV_CONV: /* * Conversion. */ if (NULL == (src = H5I_object(src_id)) || NULL == (dst = H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); /* Initialize source & destination strides */ if (buf_stride) { assert(buf_stride>=src->shared->size); assert(buf_stride>=dst->shared->size); H5_CHECK_OVERFLOW(buf_stride,size_t,ssize_t); s_stride = d_stride = (ssize_t)buf_stride; } else { H5_CHECK_OVERFLOW(src->shared->size,size_t,ssize_t); H5_CHECK_OVERFLOW(dst->shared->size,size_t,ssize_t); s_stride = (ssize_t)src->shared->size; d_stride = (ssize_t)dst->shared->size; } if(bkg) { if(bkg_stride) { H5_CHECK_OVERFLOW(bkg_stride,size_t,ssize_t); b_stride=(ssize_t)bkg_stride; } /* end if */ else b_stride=d_stride; } /* end if */ else b_stride=0; /* Get the size of the base types in src & dst */ src_base_size=H5T_get_size(src->shared->parent); dst_base_size=H5T_get_size(dst->shared->parent); /* Set up conversion path for base elements */ if (NULL==(tpath=H5T_path_find(src->shared->parent, dst->shared->parent, NULL, NULL, dxpl_id))) { HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest datatypes"); } else if (!H5T_path_noop(tpath)) { if ((tsrc_id = H5I_register(H5I_DATATYPE, H5T_copy(src->shared->parent, H5T_COPY_ALL)))<0 || (tdst_id = H5I_register(H5I_DATATYPE, H5T_copy(dst->shared->parent, H5T_COPY_ALL)))<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register types for conversion"); } else noop_conv=TRUE; /* Check if we need a temporary buffer for this conversion */ parent_is_vlen=H5T_detect_class(dst->shared->parent,H5T_VLEN); if(tpath->cdata.need_bkg || parent_is_vlen) { /* Set up initial background buffer */ tmp_buf_size=MAX(src_base_size,dst_base_size); if ((tmp_buf=H5FL_BLK_MALLOC(vlen_seq,tmp_buf_size))==NULL) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion"); } /* end if */ /* Get the allocation info */ if(H5T_vlen_get_alloc_info(dxpl_id,&vl_alloc_info)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to retrieve VL allocation info"); /* Set flags to indicate we are writing to or reading from the file */ if(dst->shared->u.vlen.f!=NULL) write_to_file=TRUE; /* Set the flag for nested VL case */ if(write_to_file && parent_is_vlen && bkg!=NULL) nested=1; /* The outer loop of the type conversion macro, controlling which */ /* direction the buffer is walked */ while (nelmts>0) { /* Check if we need to go backwards through the buffer */ if(d_stride>s_stride) { /* Compute the number of "safe" destination elements at */ /* the end of the buffer (Those which don't overlap with */ /* any source elements at the beginning of the buffer) */ safe=nelmts-(((nelmts*s_stride)+(d_stride-1))/d_stride); /* If we're down to the last few elements, just wrap up */ /* with a "real" reverse copy */ if(safe<2) { s = (uint8_t*)buf+(nelmts-1)*s_stride; d = (uint8_t*)buf+(nelmts-1)*d_stride; b = (uint8_t*)bkg+(nelmts-1)*b_stride; s_stride = -s_stride; d_stride = -d_stride; b_stride = -b_stride; safe=nelmts; } /* end if */ else { s = (uint8_t*)buf+(nelmts-safe)*s_stride; d = (uint8_t*)buf+(nelmts-safe)*d_stride; b = (uint8_t*)bkg+(nelmts-safe)*b_stride; } /* end else */ } /* end if */ else { /* Single forward pass over all data */ s = d = buf; b = bkg; safe=nelmts; } /* end else */ for (elmtno=0; elmtnoshared->u.vlen.isnull))(src->shared->u.vlen.f,s)) { /* Write "nil" sequence to destination location */ if((*(dst->shared->u.vlen.setnull))(dst->shared->u.vlen.f,dxpl_id,d,b)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "can't set VL data to 'nil'"); } /* end if */ else { /* Get length of element sequences */ if((seq_len=(*(src->shared->u.vlen.getlen))(s))<0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "incorrect length"); /* If we are reading from memory and there is no conversion, just get the pointer to sequence */ if(write_to_file && noop_conv) { /* Get direct pointer to sequence */ if((conv_buf=(*(src->shared->u.vlen.getptr))(s))==NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid source pointer"); } /* end if */ else { size_t src_size, dst_size; /*source & destination total size in bytes*/ src_size=seq_len*src_base_size; dst_size=seq_len*dst_base_size; /* Check if conversion buffer is large enough, resize if * necessary */ if(conv_buf_sizeshared->u.vlen.read))(src->shared->u.vlen.f,dxpl_id,s,conv_buf,src_size)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_READERROR, FAIL, "can't read VL data"); } /* end else */ if(!noop_conv) { /* Check if temporary buffer is large enough, resize if necessary */ /* (Chain off the conversion buffer size) */ if(tmp_buf && tmp_buf_size0) { if(tmp_buf_size<(bg_seq_len*MAX(src_base_size, dst_base_size))) { tmp_buf_size=(bg_seq_len*MAX(src_base_size, dst_base_size)); if((tmp_buf=H5FL_BLK_REALLOC(vlen_seq,tmp_buf, tmp_buf_size))==NULL) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion"); } H5F_addr_decode(dst->shared->u.vlen.f, (const uint8_t **)&tmp, &(bg_hobjid.addr)); INT32DECODE(tmp, bg_hobjid.idx); if(H5HG_read(dst->shared->u.vlen.f,dxpl_id,&bg_hobjid,tmp_buf)==NULL) HGOTO_ERROR (H5E_DATATYPE, H5E_READERROR, FAIL, "can't read VL sequence into background buffer"); } /* end if */ /* If the sequence gets shorter, pad out the original sequence with zeros */ H5_CHECK_OVERFLOW(bg_seq_len,size_t,ssize_t); if((ssize_t)bg_seq_lenshared->u.vlen.write))(dst->shared->u.vlen.f,dxpl_id,vl_alloc_info,d,conv_buf, b, (size_t)seq_len, dst_base_size)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "can't write VL data"); if(!noop_conv) { /* For nested VL case, free leftover heap objects from the deeper level if the length of new data elements is shorter than the old data elements.*/ H5_CHECK_OVERFLOW(bg_seq_len,size_t,ssize_t); if(nested && seq_len<(ssize_t)bg_seq_len) { size_t parent_seq_len; size_t u; uint8_t *tmp_p=tmp_buf; tmp_p += seq_len*dst_base_size; for(u=0; u<(bg_seq_len-seq_len); u++) { UINT32DECODE(tmp_p, parent_seq_len); if(parent_seq_len>0) { H5F_addr_decode(dst->shared->u.vlen.f, (const uint8_t **)&tmp_p, &(parent_hobjid.addr)); INT32DECODE(tmp_p, parent_hobjid.idx); if(H5HG_remove(dst->shared->u.vlen.f, dxpl_id,&parent_hobjid)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "Unable to remove heap object"); } } } /* end if */ } /* end if */ } /* end else */ /* Advance pointers */ s += s_stride; d += d_stride; b += b_stride; } /* end for */ /* Decrement number of elements left to convert */ nelmts-=safe; } /* end while */ /* Release the temporary datatype IDs used */ if (tsrc_id >= 0) H5I_dec_ref(tsrc_id); if (tdst_id >= 0) H5I_dec_ref(tdst_id); break; default: /* Some other command we don't know about yet.*/ HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command"); } /* end switch */ done: /* If the conversion buffer doesn't need to be freed, reset its pointer */ if(write_to_file && noop_conv) conv_buf=NULL; /* Release the conversion buffer (always allocated, except on errors) */ if(conv_buf!=NULL) H5FL_BLK_FREE(vlen_seq,conv_buf); /* Release the background buffer, if we have one */ if(tmp_buf!=NULL) H5FL_BLK_FREE(vlen_seq,tmp_buf); FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_array * * Purpose: Converts between array data types in memory and on disk. * This is a soft conversion function. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Monday, November 6, 2000 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *_buf, void UNUSED *_bkg, hid_t dxpl_id) { H5T_path_t *tpath; /* Type conversion path */ hid_t tsrc_id = -1, tdst_id = -1;/*temporary type atoms */ H5T_t *src = NULL; /*source data type */ H5T_t *dst = NULL; /*destination data type */ uint8_t *sp, *dp; /*source and dest traversal ptrs */ size_t src_delta, dst_delta; /*source & destination stride */ int direction; /*direction of traversal */ size_t elmtno; /*element number counter */ int i; /* local index variable */ void *bkg_buf=NULL; /*temporary background buffer */ size_t bkg_buf_size=0; /*size of background buffer in bytes */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_array, FAIL); switch (cdata->command) { case H5T_CONV_INIT: /* * First, determine if this conversion function applies to the * conversion path SRC_ID-->DST_ID. If not, return failure; * otherwise initialize the `priv' field of `cdata' with * information that remains (almost) constant for this * conversion path. */ if (NULL == (src = H5I_object(src_id)) || NULL == (dst = H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); assert (H5T_ARRAY==src->shared->type); assert (H5T_ARRAY==dst->shared->type); /* Check the number and sizes of the dimensions */ if(src->shared->u.array.ndims!=dst->shared->u.array.ndims) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "array datatypes do not have the same number of dimensions"); for(i=0; ishared->u.array.ndims; i++) if(src->shared->u.array.dim[i]!=dst->shared->u.array.dim[i]) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "array datatypes do not have the same sizes of dimensions"); #ifdef LATER for(i=0; ishared->u.array.ndims; i++) if(src->shared->u.array.perm[i]!=dst->shared->u.array.perm[i]) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "array datatypes do not have the same dimension permutations"); #endif /* LATER */ /* Array datatypes don't need a background buffer */ cdata->need_bkg = H5T_BKG_NO; break; case H5T_CONV_FREE: /* QAK - Nothing to do currently */ break; case H5T_CONV_CONV: /* * Conversion. */ if (NULL == (src = H5I_object(src_id)) || NULL == (dst = H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); /* * Do we process the values from beginning to end or vice * versa? Also, how many of the elements have the source and * destination areas overlapping? */ if (src->shared->size>=dst->shared->size || buf_stride>0) { sp = dp = (uint8_t*)_buf; direction = 1; } else { sp = (uint8_t*)_buf + (nelmts-1) * (buf_stride ? buf_stride : src->shared->size); dp = (uint8_t*)_buf + (nelmts-1) * (buf_stride ? buf_stride : dst->shared->size); direction = -1; } /* * Direction & size of buffer traversal. */ src_delta = direction * (buf_stride ? buf_stride : src->shared->size); dst_delta = direction * (buf_stride ? buf_stride : dst->shared->size); /* Set up conversion path for base elements */ if (NULL==(tpath=H5T_path_find(src->shared->parent, dst->shared->parent, NULL, NULL, dxpl_id))) { HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest datatypes"); } else if (!H5T_path_noop(tpath)) { if ((tsrc_id = H5I_register(H5I_DATATYPE, H5T_copy(src->shared->parent, H5T_COPY_ALL)))<0 || (tdst_id = H5I_register(H5I_DATATYPE, H5T_copy(dst->shared->parent, H5T_COPY_ALL)))<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register types for conversion"); } /* Check if we need a background buffer for this conversion */ if(tpath->cdata.need_bkg) { /* Allocate background buffer */ bkg_buf_size=src->shared->u.array.nelem*MAX(src->shared->size,dst->shared->size); if ((bkg_buf=H5FL_BLK_CALLOC(array_seq,bkg_buf_size))==NULL) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion"); } /* end if */ /* Perform the actual conversion */ for (elmtno=0; elmtnoshared->size); /* Convert array */ if (H5T_convert(tpath, tsrc_id, tdst_id, src->shared->u.array.nelem, 0, bkg_stride, dp, bkg_buf, dxpl_id)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed"); /* Advance the source & destination pointers */ sp += src_delta; dp += dst_delta; } /* Release the background buffer, if we have one */ if(bkg_buf!=NULL) H5FL_BLK_FREE(array_seq,bkg_buf); /* Release the temporary datatype IDs used */ if (tsrc_id >= 0) H5I_dec_ref(tsrc_id); if (tdst_id >= 0) H5I_dec_ref(tdst_id); break; default: /* Some other command we don't know about yet.*/ HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command"); } /* end switch */ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5T_conv_array() */ /*------------------------------------------------------------------------- * Function: H5T_conv_i_i * * Purpose: Convert one integer type to another. This is the catch-all * function for integer conversions and is probably not * particularly fast. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Wednesday, June 10, 1998 * * Modifications: * Robb Matzke, 7 Jul 1998 * Added overflow handling. * * Robb Matzke, 1999-06-16 * Added support for non-zero strides. If BUF_STRIDE is non-zero * then convert one value at each memory location advancing * BUF_STRIDE bytes each time; otherwise assume both source and * destination values are packed. *------------------------------------------------------------------------- */ herr_t H5T_conv_i_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { H5T_t *src = NULL; /*source data type */ H5T_t *dst = NULL; /*destination data type */ int direction; /*direction of traversal */ size_t elmtno; /*element number */ size_t half_size; /*half the type size */ size_t olap; /*num overlapping elements */ uint8_t *s, *sp, *d, *dp; /*source and dest traversal ptrs*/ uint8_t dbuf[64]; /*temp destination buffer */ size_t first; ssize_t sfirst; /*a signed version of `first' */ size_t i; /*Local index variables */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_i_i, FAIL); switch (cdata->command) { case H5T_CONV_INIT: if (NULL==(src=H5I_object(src_id)) || NULL==(dst=H5I_object(dst_id))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); if (H5T_ORDER_LE!=src->shared->u.atomic.order && H5T_ORDER_BE!=src->shared->u.atomic.order) HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order"); if (H5T_ORDER_LE!=dst->shared->u.atomic.order && H5T_ORDER_BE!=dst->shared->u.atomic.order) HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order"); if (dst->shared->size>sizeof dbuf) HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "destination size is too large"); cdata->need_bkg = H5T_BKG_NO; break; case H5T_CONV_FREE: break; case H5T_CONV_CONV: /* Get the data types */ if (NULL==(src=H5I_object(src_id)) || NULL==(dst=H5I_object(dst_id))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); /* * Do we process the values from beginning to end or vice versa? Also, * how many of the elements have the source and destination areas * overlapping? */ if (src->shared->size==dst->shared->size || buf_stride) { sp = dp = (uint8_t*)buf; direction = 1; olap = nelmts; } else if (src->shared->size>=dst->shared->size) { double olap_d = HDceil((double)(dst->shared->size)/ (double)(src->shared->size-dst->shared->size)); olap = (size_t)olap_d; sp = dp = (uint8_t*)buf; direction = 1; } else { double olap_d = HDceil((double)(src->shared->size)/ (double)(dst->shared->size-src->shared->size)); olap = (size_t)olap_d; sp = (uint8_t*)buf + (nelmts-1) * src->shared->size; dp = (uint8_t*)buf + (nelmts-1) * dst->shared->size; direction = -1; } /* The conversion loop */ for (elmtno=0; elmtno0) { s = sp; d = elmtno= nelmts ? dbuf : dp; } #ifndef NDEBUG /* I don't quite trust the overlap calculations yet --rpm */ if (d==dbuf) { assert ((dp>=sp && dpshared->size) || (sp>=dp && spshared->size)); } else { assert ((dpshared->size<=sp) || (spshared->size<=dp)); } #endif /* * Put the data in little endian order so our loops aren't so * complicated. We'll do all the conversion stuff assuming * little endian and then we'll fix the order at the end. */ if (H5T_ORDER_BE==src->shared->u.atomic.order) { half_size = src->shared->size/2; for (i=0; ishared->size-(i+1)]; s[src->shared->size-(i+1)] = s[i]; s[i] = tmp; } } /* * What is the bit number for the msb bit of S which is set? The * bit number is relative to the significant part of the number. */ sfirst = H5T_bit_find (s, src->shared->u.atomic.offset, src->shared->u.atomic.prec, H5T_BIT_MSB, TRUE); first = (size_t)sfirst; if (sfirst<0) { /* * The source has no bits set and must therefore be zero. * Set the destination to zero. */ H5T_bit_set (d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec, FALSE); } else if (H5T_SGN_NONE==src->shared->u.atomic.u.i.sign && H5T_SGN_NONE==dst->shared->u.atomic.u.i.sign) { /* * Source and destination are both unsigned, but if the * source has more precision bits than the destination then * it's possible to overflow. When overflow occurs the * destination will be set to the maximum possible value. */ if (src->shared->u.atomic.prec <= dst->shared->u.atomic.prec) { H5T_bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, src->shared->u.atomic.prec); H5T_bit_set (d, dst->shared->u.atomic.offset+src->shared->u.atomic.prec, dst->shared->u.atomic.prec-src->shared->u.atomic.prec, FALSE); } else if (first>=dst->shared->u.atomic.prec) { /*overflow*/ if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, s, d)<0) { H5T_bit_set (d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec, TRUE); } } else { H5T_bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, dst->shared->u.atomic.prec); } } else if (H5T_SGN_2==src->shared->u.atomic.u.i.sign && H5T_SGN_NONE==dst->shared->u.atomic.u.i.sign) { /* * If the source is signed and the destination isn't then we * can have overflow if the source contains more bits than * the destination (destination is set to the maximum * possible value) or overflow if the source is negative * (destination is set to zero). */ if (first+1 == src->shared->u.atomic.prec) { /*overflow*/ if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, s, d)<0) { H5T_bit_set (d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec, FALSE); } } else if (src->shared->u.atomic.prec < dst->shared->u.atomic.prec) { H5T_bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, src->shared->u.atomic.prec-1); H5T_bit_set (d, dst->shared->u.atomic.offset+src->shared->u.atomic.prec-1, (dst->shared->u.atomic.prec-src->shared->u.atomic.prec)+1, FALSE); } else if (first>=dst->shared->u.atomic.prec) { /*overflow*/ if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, s, d)<0) { H5T_bit_set (d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec, TRUE); } } else { H5T_bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, dst->shared->u.atomic.prec); } } else if (H5T_SGN_NONE==src->shared->u.atomic.u.i.sign && H5T_SGN_2==dst->shared->u.atomic.u.i.sign) { /* * If the source is not signed but the destination is then * overflow can occur in which case the destination is set to * the largest possible value (all bits set except the msb). */ if (first+1 >= dst->shared->u.atomic.prec) { /*overflow*/ if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, s, d)<0) { H5T_bit_set (d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec-1, TRUE); H5T_bit_set (d, (dst->shared->u.atomic.offset + dst->shared->u.atomic.prec-1), 1, FALSE); } } else if (src->shared->u.atomic.precshared->u.atomic.prec) { H5T_bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, src->shared->u.atomic.prec); H5T_bit_set (d, dst->shared->u.atomic.offset+src->shared->u.atomic.prec, dst->shared->u.atomic.prec-src->shared->u.atomic.prec, FALSE); } else { H5T_bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, dst->shared->u.atomic.prec); } } else if (first+1 == src->shared->u.atomic.prec) { /* * Both the source and the destination are signed and the * source value is negative. We could experience overflow * if the destination isn't wide enough in which case the * destination is set to a negative number with the largest * possible magnitude. */ ssize_t sfz = H5T_bit_find (s, src->shared->u.atomic.offset, src->shared->u.atomic.prec-1, H5T_BIT_MSB, FALSE); size_t fz = (size_t)sfz; if (sfz>=0 && fz+1>=dst->shared->u.atomic.prec) { /*overflow*/ if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, s, d)<0) { H5T_bit_set (d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec-1, FALSE); H5T_bit_set (d, (dst->shared->u.atomic.offset + dst->shared->u.atomic.prec-1), 1, TRUE); } } else if (src->shared->u.atomic.precshared->u.atomic.prec) { H5T_bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, src->shared->u.atomic.prec); H5T_bit_set (d, dst->shared->u.atomic.offset+src->shared->u.atomic.prec, dst->shared->u.atomic.prec-src->shared->u.atomic.prec, TRUE); } else { H5T_bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, dst->shared->u.atomic.prec); } } else { /* * Source and destination are both signed but the source * value is positive. We could have an overflow in which * case the destination is set to the largest possible * positive value. */ if (first+1>=dst->shared->u.atomic.prec) { /*overflow*/ if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, s, d)<0) { H5T_bit_set (d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec-1, TRUE); H5T_bit_set (d, (dst->shared->u.atomic.offset + dst->shared->u.atomic.prec-1), 1, FALSE); } } else if (src->shared->u.atomic.precshared->u.atomic.prec) { H5T_bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, src->shared->u.atomic.prec); H5T_bit_set (d, dst->shared->u.atomic.offset+src->shared->u.atomic.prec, dst->shared->u.atomic.prec-src->shared->u.atomic.prec, FALSE); } else { H5T_bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, dst->shared->u.atomic.prec); } } /* * Set padding areas in destination. */ if (dst->shared->u.atomic.offset>0) { assert (H5T_PAD_ZERO==dst->shared->u.atomic.lsb_pad || H5T_PAD_ONE==dst->shared->u.atomic.lsb_pad); H5T_bit_set (d, 0, dst->shared->u.atomic.offset, (hbool_t)(H5T_PAD_ONE==dst->shared->u.atomic.lsb_pad)); } if (dst->shared->u.atomic.offset+dst->shared->u.atomic.prec!=8*dst->shared->size) { assert (H5T_PAD_ZERO==dst->shared->u.atomic.msb_pad || H5T_PAD_ONE==dst->shared->u.atomic.msb_pad); H5T_bit_set (d, dst->shared->u.atomic.offset+dst->shared->u.atomic.prec, 8*dst->shared->size - (dst->shared->u.atomic.offset+ dst->shared->u.atomic.prec), (hbool_t)(H5T_PAD_ONE==dst->shared->u.atomic.msb_pad)); } /* * Put the destination in the correct byte order. See note at * beginning of loop. */ if (H5T_ORDER_BE==dst->shared->u.atomic.order) { half_size = dst->shared->size/2; for (i=0; ishared->size-(i+1)]; d[dst->shared->size-(i+1)] = d[i]; d[i] = tmp; } } /* * If we had used a temporary buffer for the destination then we * should copy the value to the true destination buffer. */ if (d==dbuf) HDmemcpy (dp, d, dst->shared->size); if (buf_stride) { sp += direction * buf_stride; dp += direction * buf_stride; } else { sp += direction * src->shared->size; dp += direction * dst->shared->size; } } break; default: HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command"); } done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_f_f * * Purpose: Convert one floating point type to another. This is a catch * all for floating point conversions and is probably not * particularly fast! * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Tuesday, June 23, 1998 * * Modifications: * Robb Matzke, 7 Jul 1998 * Added overflow handling. * * Robb Matzke, 1999-06-16 * Added support for non-zero strides. If BUF_STRIDE is non-zero * then convert one value at each memory location advancing * BUF_STRIDE bytes each time; otherwise assume both source and * destination values are packed. * * Robb Matzke, 2001-02-02 * Oops, forgot to increment the exponent when rounding the * significand resulted in a carry. Thanks to Guillaume Colin * de Verdiere for finding this one! *------------------------------------------------------------------------- */ herr_t H5T_conv_f_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { /* Traversal-related variables */ H5T_t *src_p; /*source data type */ H5T_t *dst_p; /*destination data type */ H5T_atomic_t src; /*atomic source info */ H5T_atomic_t dst; /*atomic destination info */ int direction; /*forward or backward traversal */ hbool_t denormalized=FALSE; /*is either source or destination denormalized?*/ size_t elmtno; /*element number */ size_t half_size; /*half the type size */ size_t olap; /*num overlapping elements */ ssize_t bitno=-1; /*bit number */ uint8_t *s, *sp, *d, *dp; /*source and dest traversal ptrs*/ uint8_t dbuf[64]; /*temp destination buffer */ /* Conversion-related variables */ hssize_t expo; /*exponent */ hssize_t expo_max; /*maximum possible dst exponent */ size_t msize=0; /*useful size of mantissa in src*/ size_t mpos; /*offset to useful mant is src */ size_t mrsh; /*amount to right shift mantissa*/ hbool_t carry=0; /*carry after rounding mantissa */ size_t i; /*miscellaneous counters */ size_t implied; /*destination implied bits */ herr_t ret_value=SUCCEED; /*return value */ FUNC_ENTER_NOAPI(H5T_conv_f_f, FAIL); switch (cdata->command) { case H5T_CONV_INIT: if (NULL==(src_p=H5I_object(src_id)) || NULL==(dst_p=H5I_object(dst_id))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); src = src_p->shared->u.atomic; dst = dst_p->shared->u.atomic; if (H5T_ORDER_LE!=src.order && H5T_ORDER_BE!=src.order) HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order"); if (H5T_ORDER_LE!=dst.order && H5T_ORDER_BE!=dst.order) HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order"); if (dst_p->shared->size>sizeof(dbuf)) HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "destination size is too large"); if (8*sizeof(expo)-1need_bkg = H5T_BKG_NO; break; case H5T_CONV_FREE: break; case H5T_CONV_CONV: /* Get the data types */ if (NULL==(src_p=H5I_object(src_id)) || NULL==(dst_p=H5I_object(dst_id))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); src = src_p->shared->u.atomic; dst = dst_p->shared->u.atomic; expo_max = ((hssize_t)1 << dst.u.f.esize) - 1; /* * Do we process the values from beginning to end or vice versa? Also, * how many of the elements have the source and destination areas * overlapping? */ if (src_p->shared->size==dst_p->shared->size || buf_stride) { sp = dp = (uint8_t*)buf; direction = 1; olap = nelmts; } else if (src_p->shared->size>=dst_p->shared->size) { double olap_d = HDceil((double)(dst_p->shared->size)/ (double)(src_p->shared->size-dst_p->shared->size)); olap = (size_t)olap_d; sp = dp = (uint8_t*)buf; direction = 1; } else { double olap_d = HDceil((double)(src_p->shared->size)/ (double)(dst_p->shared->size-src_p->shared->size)); olap = (size_t)olap_d; sp = (uint8_t*)buf + (nelmts-1) * src_p->shared->size; dp = (uint8_t*)buf + (nelmts-1) * dst_p->shared->size; direction = -1; } /* The conversion loop */ for (elmtno=0; elmtno0) { s = sp; d = elmtno= nelmts ? dbuf : dp; } #ifndef NDEBUG /* I don't quite trust the overlap calculations yet --rpm */ if (d==dbuf) { assert ((dp>=sp && dpshared->size) || (sp>=dp && spshared->size)); } else { assert ((dpshared->size<=sp) || (spshared->size<=dp)); } #endif /* * Put the data in little endian order so our loops aren't so * complicated. We'll do all the conversion stuff assuming * little endian and then we'll fix the order at the end. */ if (H5T_ORDER_BE==src.order) { half_size = src_p->shared->size/2; for (i=0; ishared->size-(i+1)]; s[src_p->shared->size-(i+1)] = s[i]; s[i] = tmp; } } /* * Check for special cases: +0, -0, +Inf, -Inf, NaN */ if (H5T_bit_find (s, src.u.f.mpos, src.u.f.msize, H5T_BIT_LSB, TRUE)<0) { if (H5T_bit_find (s, src.u.f.epos, src.u.f.esize, H5T_BIT_LSB, TRUE)<0) { /* +0 or -0 */ H5T_bit_copy (d, dst.u.f.sign, s, src.u.f.sign, 1); H5T_bit_set (d, dst.u.f.epos, dst.u.f.esize, FALSE); H5T_bit_set (d, dst.u.f.mpos, dst.u.f.msize, FALSE); goto padding; } else if (H5T_bit_find (s, src.u.f.epos, src.u.f.esize, H5T_BIT_LSB, FALSE)<0) { /* +Inf or -Inf */ H5T_bit_copy (d, dst.u.f.sign, s, src.u.f.sign, 1); H5T_bit_set (d, dst.u.f.epos, dst.u.f.esize, TRUE); H5T_bit_set (d, dst.u.f.mpos, dst.u.f.msize, FALSE); /*If the destination no implied mantissa bit, we'll need to set *the 1st bit of mantissa to 1. The Intel-Linux long double is *this case.*/ if (H5T_NORM_NONE==dst.u.f.norm) H5T_bit_set (d, dst.u.f.mpos+dst.u.f.msize-1, 1, TRUE); goto padding; } } else if (H5T_NORM_NONE==src.u.f.norm && H5T_bit_find (s, src.u.f.mpos, src.u.f.msize-1, H5T_BIT_LSB, TRUE)<0 && H5T_bit_find (s, src.u.f.epos, src.u.f.esize, H5T_BIT_LSB, FALSE)<0) { /*This is a special case for the source of no implied mantissa bit. *If the exponent bits are all 1s and only the 1st bit of mantissa *is set to 1. It's infinity. The Intel-Linux "long double" is this case.*/ /* +Inf or -Inf */ H5T_bit_copy (d, dst.u.f.sign, s, src.u.f.sign, 1); H5T_bit_set (d, dst.u.f.epos, dst.u.f.esize, TRUE); H5T_bit_set (d, dst.u.f.mpos, dst.u.f.msize, FALSE); /*If the destination no implied mantissa bit, we'll need to set *the 1st bit of mantissa to 1.*/ if (H5T_NORM_NONE==dst.u.f.norm) H5T_bit_set (d, dst.u.f.mpos+dst.u.f.msize-1, 1, TRUE); goto padding; } else if (H5T_bit_find (s, src.u.f.epos, src.u.f.esize, H5T_BIT_LSB, FALSE)<0) { /* * NaN. There are many NaN values, so we just set all bits of * the significand. */ H5T_bit_copy (d, dst.u.f.sign, s, src.u.f.sign, 1); H5T_bit_set (d, dst.u.f.epos, dst.u.f.esize, TRUE); H5T_bit_set(d, dst.u.f.mpos, dst.u.f.msize, TRUE); goto padding; } /* * Get the exponent as an unsigned quantity from the section of * the source bit field where it's located. Don't worry about * the exponent bias yet. */ expo = H5T_bit_get_d(s, src.u.f.epos, src.u.f.esize); if(expo==0) denormalized=TRUE; /* * Set markers for the source mantissa, excluding the leading `1' * (might be implied). */ implied = 1; mpos = src.u.f.mpos; mrsh = 0; if (0==expo || H5T_NORM_NONE==src.u.f.norm) { if ((bitno=H5T_bit_find(s, src.u.f.mpos, src.u.f.msize, H5T_BIT_MSB, TRUE))>0) { msize = bitno; } else if (0==bitno) { msize = 1; H5T_bit_set(s, src.u.f.mpos, 1, FALSE); } } else if (H5T_NORM_IMPLIED==src.u.f.norm) { msize = src.u.f.msize; } else { assert("normalization method not implemented yet" && 0); HDabort(); } /* * The sign for the destination is the same as the sign for the * source in all cases. */ H5T_bit_copy (d, dst.u.f.sign, s, src.u.f.sign, 1); /* * Calculate the true source exponent by adjusting according to * the source exponent bias. */ if (0==expo || H5T_NORM_NONE==src.u.f.norm) { assert(bitno>=0); expo -= (src.u.f.ebias-1) + (src.u.f.msize-bitno); } else if (H5T_NORM_IMPLIED==src.u.f.norm) { expo -= src.u.f.ebias; } else { assert("normalization method not implemented yet" && 0); HDabort(); } /* * If the destination is not normalized then right shift the * mantissa by one. */ if (H5T_NORM_NONE==dst.u.f.norm) mrsh++; /* * Calculate the destination exponent by adding the destination * bias and clipping by the minimum and maximum possible * destination exponent values. */ expo += dst.u.f.ebias; if (expo < -(hssize_t)(dst.u.f.msize)) { /* The exponent is way too small. Result is zero. */ expo = 0; H5T_bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE); msize = 0; } else if (expo<=0) { /* * The exponent is too small to fit in the exponent field, * but by shifting the mantissa to the right we can * accomodate that value. The mantissa of course is no * longer normalized. */ H5_ASSIGN_OVERFLOW(mrsh,(mrsh+1-expo),hssize_t,size_t); expo = 0; denormalized=TRUE; } else if (expo>=expo_max) { /* * The exponent is too large to fit in the available region * or it results in the maximum possible value. Use positive * or negative infinity instead unless the application * specifies something else. Before calling the overflow * handler make sure the source buffer we hand it is in the * original byte order. */ if (H5T_overflow_g) { uint8_t over_src[256]; assert(src_p->shared->size<=sizeof over_src); if (H5T_ORDER_BE==src.order) { for (i=0; ishared->size; i++) { over_src[src_p->shared->size-(i+1)] = s[i]; } } else { for (i=0; ishared->size; i++) { over_src[i] = s[i]; } } if ((H5T_overflow_g)(src_id, dst_id, over_src, d)>=0) { goto next; } } expo = expo_max; H5T_bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE); msize = 0; } /* * If the destination mantissa is smaller than the source * mantissa then round the source mantissa. Rounding may cause a * carry in which case the exponent has to be re-evaluated for * overflow. That is, if `carry' is clear then the implied * mantissa bit is `1', else it is `10' binary. */ if (msize>0 && mrsh<=dst.u.f.msize && mrsh+msize>dst.u.f.msize) { bitno = (ssize_t)(mrsh+msize - dst.u.f.msize); assert(bitno>=0 && (size_t)bitno<=msize); /*If the 1st bit being cut off is set and source isn't denormalized.*/ if(H5T_bit_get_d(s, mpos+bitno-1, 1) && !denormalized) { /*Don't do rounding if exponent is 111...110 and mantissa is 111...11. *To do rounding and increment exponent in this case will create an infinity value.*/ if((H5T_bit_find(s, mpos+bitno, msize-bitno, H5T_BIT_LSB, FALSE)>=0 || expodst.u.f.msize+1) { H5T_bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE); } else if (mrsh==dst.u.f.msize+1) { H5T_bit_set(d, dst.u.f.mpos+1, dst.u.f.msize-1, FALSE); H5T_bit_set(d, dst.u.f.mpos, 1, TRUE); } else if (mrsh==dst.u.f.msize) { H5T_bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE); H5T_bit_set_d(d, dst.u.f.mpos, MIN(2, dst.u.f.msize), (hsize_t)implied); } else { if (mrsh>0) { H5T_bit_set(d, dst.u.f.mpos+dst.u.f.msize-mrsh, mrsh, FALSE); H5T_bit_set_d(d, dst.u.f.mpos+dst.u.f.msize-mrsh, 2, (hsize_t)implied); } if (mrsh+msize>=dst.u.f.msize) { H5T_bit_copy(d, dst.u.f.mpos, s, (mpos+msize+mrsh-dst.u.f.msize), dst.u.f.msize-mrsh); } else { H5T_bit_copy(d, dst.u.f.mpos+dst.u.f.msize-(mrsh+msize), s, mpos, msize); H5T_bit_set(d, dst.u.f.mpos, dst.u.f.msize-(mrsh+msize), FALSE); } } /* Write the exponent */ if (carry) { expo++; if (expo>=expo_max) { /* * The exponent is too large to fit in the available * region or it results in the maximum possible value. * Use positive or negative infinity instead unless the * application specifies something else. Before * calling the overflow handler make sure the source * buffer we hand it is in the original byte order. */ if (H5T_overflow_g) { uint8_t over_src[256]; assert(src_p->shared->size<=sizeof over_src); if (H5T_ORDER_BE==src.order) { for (i=0; ishared->size; i++) over_src[src_p->shared->size-(i+1)] = s[i]; } else { for (i=0; ishared->size; i++) over_src[i] = s[i]; } if ((H5T_overflow_g)(src_id, dst_id, over_src, d)>=0) goto next; } expo = expo_max; H5T_bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE); } } /*reset CARRY*/ carry = 0; H5_CHECK_OVERFLOW(expo,hssize_t,hsize_t); H5T_bit_set_d(d, dst.u.f.epos, dst.u.f.esize, (hsize_t)expo); padding: /* * Set external padding areas */ if (dst.offset>0) { assert (H5T_PAD_ZERO==dst.lsb_pad || H5T_PAD_ONE==dst.lsb_pad); H5T_bit_set (d, 0, dst.offset, (hbool_t)(H5T_PAD_ONE==dst.lsb_pad)); } if (dst.offset+dst.prec!=8*dst_p->shared->size) { assert (H5T_PAD_ZERO==dst.msb_pad || H5T_PAD_ONE==dst.msb_pad); H5T_bit_set (d, dst.offset+dst.prec, 8*dst_p->shared->size - (dst.offset+dst.prec), (hbool_t)(H5T_PAD_ONE==dst.msb_pad)); } /* * Put the destination in the correct byte order. See note at * beginning of loop. */ if (H5T_ORDER_BE==dst.order) { half_size = dst_p->shared->size/2; for (i=0; ishared->size-(i+1)]; d[dst_p->shared->size-(i+1)] = d[i]; d[i] = tmp; } } /* * If we had used a temporary buffer for the destination then we * should copy the value to the true destination buffer. */ next: if (d==dbuf) HDmemcpy (dp, d, dst_p->shared->size); if (buf_stride) { sp += direction * buf_stride; dp += direction * buf_stride; } else { sp += direction * src_p->shared->size; dp += direction * dst_p->shared->size; } } break; default: HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command"); } done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_s_s * * Purpose: Convert one fixed-length string type to another. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Friday, August 7, 1998 * * Modifications: * Robb Matzke, 1999-06-16 * Added support for non-zero strides. If BUF_STRIDE is non-zero * then convert one value at each memory location advancing * BUF_STRIDE bytes each time; otherwise assume both source and * destination values are packed. *------------------------------------------------------------------------- */ herr_t H5T_conv_s_s (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { H5T_t *src=NULL; /*source data type */ H5T_t *dst=NULL; /*destination data type */ int direction; /*direction of traversal */ size_t elmtno; /*element number */ size_t olap; /*num overlapping elements */ size_t nchars=0; /*number of characters copied */ uint8_t *s, *sp, *d, *dp; /*src and dst traversal pointers*/ uint8_t *dbuf=NULL; /*temp buf for overlap convers. */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_s_s, FAIL); switch (cdata->command) { case H5T_CONV_INIT: if (NULL==(src=H5I_object(src_id)) || NULL==(dst=H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); if (8*src->shared->size != src->shared->u.atomic.prec || 8*dst->shared->size != dst->shared->u.atomic.prec) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad precision"); if (0 != src->shared->u.atomic.offset || 0 != dst->shared->u.atomic.offset) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad offset"); if (H5T_CSET_ASCII != src->shared->u.atomic.u.s.cset || H5T_CSET_ASCII != dst->shared->u.atomic.u.s.cset) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad character set"); if (src->shared->u.atomic.u.s.pad<0 || src->shared->u.atomic.u.s.pad>=H5T_NPAD || dst->shared->u.atomic.u.s.pad<0 || dst->shared->u.atomic.u.s.pad>=H5T_NPAD) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad character padding"); cdata->need_bkg = H5T_BKG_NO; break; case H5T_CONV_FREE: break; case H5T_CONV_CONV: /* Get the data types */ if (NULL==(src=H5I_object(src_id)) || NULL==(dst=H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); /* * Do we process the values from beginning to end or vice versa? Also, * how many of the elements have the source and destination areas * overlapping? */ if (src->shared->size==dst->shared->size || buf_stride) { /* * When the source and destination are the same size we can do * all the conversions in place. */ sp = dp = (uint8_t*)buf; direction = 1; olap = 0; } else if (src->shared->size>=dst->shared->size) { double olapd = HDceil((double)(dst->shared->size)/ (double)(src->shared->size-dst->shared->size)); olap = (size_t)olapd; sp = dp = (uint8_t*)buf; direction = 1; } else { double olapd = HDceil((double)(src->shared->size)/ (double)(dst->shared->size-src->shared->size)); olap = (size_t)olapd; sp = (uint8_t*)buf + (nelmts-1) * src->shared->size; dp = (uint8_t*)buf + (nelmts-1) * dst->shared->size; direction = -1; } /* Allocate the overlap buffer */ if (NULL==(dbuf=H5MM_malloc(dst->shared->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for string conversion"); /* The conversion loop. */ for (elmtno=0; elmtno0) { s = sp; d = elmtno= nelmts ? dbuf : dp; } #ifndef NDEBUG /* I don't quite trust the overlap calculations yet --rpm */ if (src->shared->size==dst->shared->size || buf_stride) { assert(s==d); } else if (d==dbuf) { assert((dp>=sp && dpshared->size) || (sp>=dp && spshared->size)); } else { assert((dpshared->size<=sp) || (spshared->size<=dp)); } #endif /* Copy characters from source to destination */ switch (src->shared->u.atomic.u.s.pad) { case H5T_STR_NULLTERM: for (nchars=0; ncharsshared->size && ncharsshared->size && s[nchars]; nchars++) { d[nchars] = s[nchars]; } break; case H5T_STR_NULLPAD: for (nchars=0; ncharsshared->size && ncharsshared->size && s[nchars]; nchars++) { d[nchars] = s[nchars]; } break; case H5T_STR_SPACEPAD: nchars = src->shared->size; while (nchars>0 && ' '==s[nchars-1]) --nchars; nchars = MIN(dst->shared->size, nchars); HDmemcpy(d, s, nchars); break; case H5T_STR_RESERVED_3: case H5T_STR_RESERVED_4: case H5T_STR_RESERVED_5: case H5T_STR_RESERVED_6: case H5T_STR_RESERVED_7: case H5T_STR_RESERVED_8: case H5T_STR_RESERVED_9: case H5T_STR_RESERVED_10: case H5T_STR_RESERVED_11: case H5T_STR_RESERVED_12: case H5T_STR_RESERVED_13: case H5T_STR_RESERVED_14: case H5T_STR_RESERVED_15: case H5T_STR_ERROR: HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "source string padding method not supported"); } /* Terminate or pad the destination */ switch (dst->shared->u.atomic.u.s.pad) { case H5T_STR_NULLTERM: while (ncharsshared->size) d[nchars++] = '\0'; d[dst->shared->size-1] = '\0'; break; case H5T_STR_NULLPAD: while (ncharsshared->size) d[nchars++] = '\0'; break; case H5T_STR_SPACEPAD: while (ncharsshared->size) d[nchars++] = ' '; break; case H5T_STR_RESERVED_3: case H5T_STR_RESERVED_4: case H5T_STR_RESERVED_5: case H5T_STR_RESERVED_6: case H5T_STR_RESERVED_7: case H5T_STR_RESERVED_8: case H5T_STR_RESERVED_9: case H5T_STR_RESERVED_10: case H5T_STR_RESERVED_11: case H5T_STR_RESERVED_12: case H5T_STR_RESERVED_13: case H5T_STR_RESERVED_14: case H5T_STR_RESERVED_15: case H5T_STR_ERROR: HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "destination string padding method not supported"); } /* * If we used a temporary buffer for the destination then we * should copy the value to the true destination buffer. */ if (d==dbuf) HDmemcpy(dp, d, dst->shared->size); if (buf_stride) { sp += direction * buf_stride; dp += direction * buf_stride; } else { sp += direction * src->shared->size; dp += direction * dst->shared->size; } } break; default: HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown converson command"); } done: H5MM_xfree(dbuf); FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_schar_uchar * * Purpose: Converts `signed char' to `unsigned char' * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Monday, November 16, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_schar_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_schar_uchar, FAIL); H5T_CONV_su(SCHAR, UCHAR, signed char, unsigned char, -, -); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_uchar_schar * * Purpose: Converts `unsigned char' to `signed char' * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Monday, November 16, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_uchar_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_uchar_schar, FAIL); H5T_CONV_us(UCHAR, SCHAR, unsigned char, signed char, -, SCHAR_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_schar_short * * Purpose: Converts `signed char' to `short' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_schar_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_schar_short, FAIL); H5T_CONV_sS(SCHAR, SHORT, signed char, short, -, -); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_schar_ushort * * Purpose: Converts `signed char' to `unsigned short' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_schar_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_schar_ushort, FAIL); H5T_CONV_sU(SCHAR, USHORT, signed char, unsigned short, -, -); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_uchar_short * * Purpose: Converts `unsigned char' to `short' * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_uchar_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_uchar_short, FAIL); H5T_CONV_uS(UCHAR, SHORT, unsigned char, short, -, SHRT_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_uchar_ushort * * Purpose: Converts `unsigned char' to `unsigned short' * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_uchar_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_uchar_ushort, FAIL); H5T_CONV_uU(UCHAR, USHORT, unsigned char, unsigned short, -, -); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_schar_int * * Purpose: Converts `signed char' to `int' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_schar_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_schar_int, FAIL); H5T_CONV_sS(SCHAR, INT, signed char, int, -, -); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_schar_uint * * Purpose: Converts `signed char' to `unsigned int' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_schar_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_schar_uint, FAIL); H5T_CONV_sU(SCHAR, UINT, signed char, unsigned, -, -); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_uchar_int * * Purpose: Converts `unsigned char' to `int' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_uchar_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_uchar_int, FAIL); H5T_CONV_uS(UCHAR, INT, unsigned char, int, -, INT_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_uchar_uint * * Purpose: Converts `unsigned char' to `unsigned int' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_uchar_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_uchar_uint, FAIL); H5T_CONV_uU(UCHAR, UINT, unsigned char, unsigned, -, -); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_schar_long * * Purpose: Converts `signed char' to `long' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_schar_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_schar_long, FAIL); H5T_CONV_sS(SCHAR, LONG, signed char, long, -, -); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_schar_ulong * * Purpose: Converts `signed char' to `unsigned long' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_schar_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_schar_ulong, FAIL); H5T_CONV_sU(SCHAR, ULONG, signed char, unsigned long, -, -); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_uchar_long * * Purpose: Converts `unsigned char' to `long' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_uchar_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_uchar_long, FAIL); H5T_CONV_uS(UCHAR, LONG, unsigned char, long, -, LONG_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_uchar_ulong * * Purpose: Converts `unsigned char' to `unsigned long' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_uchar_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_uchar_ulong, FAIL); H5T_CONV_uU(UCHAR, ULONG, unsigned char, unsigned long, -, -); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_schar_llong * * Purpose: Converts `signed char' to `long_long' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_schar_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_schar_llong, FAIL); H5T_CONV_sS(SCHAR, LLONG, signed char, long_long, -, -); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_schar_ullong * * Purpose: Converts `signed char' to `unsigned long_long' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_schar_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_schar_ullong, FAIL); H5T_CONV_sU(SCHAR, ULLONG, signed char, unsigned long_long, -, -); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_uchar_llong * * Purpose: Converts `unsigned char' to `long_long' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_uchar_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_uchar_llong, FAIL); H5T_CONV_uS(UCHAR, LLONG, unsigned char, long_long, -, LLONG_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_uchar_ullong * * Purpose: Converts `unsigned char' to `unsigned long_long' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_uchar_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_uchar_ullong, FAIL); H5T_CONV_uU(UCHAR, ULLONG, unsigned char, unsigned long_long, -, -); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_short_schar * * Purpose: Converts `short' to `signed char' * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_short_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_short_schar, FAIL); H5T_CONV_Ss(SHORT, SCHAR, short, signed char, SCHAR_MIN, SCHAR_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_short_uchar * * Purpose: Converts `short' to `unsigned char' * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_short_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_short_uchar, FAIL); H5T_CONV_Su(SHORT, UCHAR, short, unsigned char, -, UCHAR_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_ushort_schar * * Purpose: Converts `unsigned short' to `signed char' * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_ushort_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_ushort_schar, FAIL); H5T_CONV_Us(USHORT, SCHAR, unsigned short, signed char, -, SCHAR_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_ushort_uchar * * Purpose: Converts `unsigned short' to `unsigned char' * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_ushort_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_ushort_uchar, FAIL); H5T_CONV_Uu(USHORT, UCHAR, unsigned short, unsigned char, -, UCHAR_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_short_ushort * * Purpose: Converts `short' to `unsigned short' * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Monday, November 16, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_short_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_short_ushort, FAIL); H5T_CONV_su(SHORT, USHORT, short, unsigned short, -, -); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_ushort_short * * Purpose: Converts `unsigned short' to `short' * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Monday, November 16, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_ushort_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_ushort_short, FAIL); H5T_CONV_us(USHORT, SHORT, unsigned short, short, -, SHRT_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_short_int * * Purpose: Converts `short' to `int' * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_short_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_short_int, FAIL); H5T_CONV_sS(SHORT, INT, short, int, -, -); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_short_uint * * Purpose: Converts `short' to `unsigned int' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_short_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_short_uint, FAIL); H5T_CONV_sU(SHORT, UINT, short, unsigned, -, -); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_ushort_int * * Purpose: Converts `unsigned short' to `int' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_ushort_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_ushort_int, FAIL); H5T_CONV_uS(USHORT, INT, unsigned short, int, -, INT_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_ushort_uint * * Purpose: Converts `unsigned short' to `unsigned int' * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_ushort_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_ushort_uint, FAIL); H5T_CONV_uU(USHORT, UINT, unsigned short, unsigned, -, -); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_short_long * * Purpose: Converts `short' to `long' * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_short_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_short_long, FAIL); H5T_CONV_sS(SHORT, LONG, short, long, -, -); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_short_ulong * * Purpose: Converts `short' to `unsigned long' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_short_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_short_ulong, FAIL); H5T_CONV_sU(SHORT, ULONG, short, unsigned long, -, -); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_ushort_long * * Purpose: Converts `unsigned short' to `long' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_ushort_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_ushort_long, FAIL); H5T_CONV_uS(USHORT, LONG, unsigned short, long, -, LONG_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_ushort_ulong * * Purpose: Converts `unsigned short' to `unsigned long' * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_ushort_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_ushort_ulong, FAIL); H5T_CONV_uU(USHORT, ULONG, unsigned short, unsigned long, -, -); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_short_llong * * Purpose: Converts `short' to `long_long' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_short_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_short_llong, FAIL); H5T_CONV_sS(SHORT, LLONG, short, long_long, -, -); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_short_ullong * * Purpose: Converts `short' to `unsigned long_long' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_short_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_short_ullong, FAIL); H5T_CONV_sU(SHORT, ULLONG, short, unsigned long_long, -, -); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_ushort_llong * * Purpose: Converts `unsigned short' to `long_long' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_ushort_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_ushort_llong, FAIL); H5T_CONV_uS(USHORT, LLONG, unsigned short, long_long, -, LLONG_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_ushort_ullong * * Purpose: Converts `unsigned short' to `unsigned long_long' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_ushort_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_ushort_ullong, FAIL); H5T_CONV_uU(USHORT, ULLONG, unsigned short, unsigned long_long, -, -); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_int_schar * * Purpose: Converts `int' to `signed char' * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_int_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_int_schar, FAIL); H5T_CONV_Ss(INT, SCHAR, int, signed char, SCHAR_MIN, SCHAR_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_int_uchar * * Purpose: Converts `int' to `unsigned char' * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_int_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_int_uchar, FAIL); H5T_CONV_Su(INT, UCHAR, int, unsigned char, -, UCHAR_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_uint_schar * * Purpose: Converts `unsigned int' to `signed char' * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_uint_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_uint_schar, FAIL); H5T_CONV_Us(UINT, SCHAR, unsigned, signed char, -, SCHAR_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_uint_uchar * * Purpose: Converts `unsigned int' to `unsigned char' * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_uint_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_uint_uchar, FAIL); H5T_CONV_Uu(UINT, UCHAR, unsigned, unsigned char, -, UCHAR_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_int_short * * Purpose: Converts `int' to `short' * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_int_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_int_short, FAIL); H5T_CONV_Ss(INT, SHORT, int, short, SHRT_MIN, SHRT_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_int_ushort * * Purpose: Converts `int' to `unsigned short' * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_int_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_int_ushort, FAIL); H5T_CONV_Su(INT, USHORT, int, unsigned short, -, USHRT_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_uint_short * * Purpose: Converts `unsigned int' to `short' * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_uint_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_uint_short, FAIL); H5T_CONV_Us(UINT, SHORT, unsigned, short, -, SHRT_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_uint_ushort * * Purpose: Converts `unsigned int' to `unsigned short' * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_uint_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_uint_ushort, FAIL); H5T_CONV_Uu(UINT, USHORT, unsigned, unsigned short, -, USHRT_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_int_uint * * Purpose: Converts `int' to `unsigned int' * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Monday, November 16, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_int_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_int_uint, FAIL); H5T_CONV_su(INT, UINT, int, unsigned, -, -); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_uint_int * * Purpose: Converts `unsigned int' to `int' * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Monday, November 16, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_uint_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_uint_int, FAIL); H5T_CONV_us(UINT, INT, unsigned, int, -, INT_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_int_long * * Purpose: Converts `int' to `long' * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_int_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_int_long, FAIL); H5T_CONV_sS(INT, LONG, int, long, -, -); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_int_ulong * * Purpose: Converts `int' to `unsigned long' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_int_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_int_ulong, FAIL); H5T_CONV_sU(INT, LONG, int, unsigned long, -, -); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_uint_long * * Purpose: Converts `unsigned int' to `long' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_uint_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_uint_long, FAIL); H5T_CONV_uS(UINT, LONG, unsigned, long, -, LONG_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_uint_ulong * * Purpose: Converts `unsigned int' to `unsigned long' * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_uint_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_uint_ulong, FAIL); H5T_CONV_uU(UINT, ULONG, unsigned, unsigned long, -, -); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_int_llong * * Purpose: Converts `int' to `long_long' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_int_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_int_llong, FAIL); H5T_CONV_sS(INT, LLONG, int, long_long, -, -); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_int_ullong * * Purpose: Converts `int' to `unsigned long_long' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_int_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_int_ullong, FAIL); H5T_CONV_sU(INT, ULLONG, int, unsigned long_long, -, -); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_uint_llong * * Purpose: Converts `unsigned int' to `long_long' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_uint_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_uint_llong, FAIL); H5T_CONV_uS(UINT, LLONG, unsigned, long_long, -, LLONG_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_uint_ullong * * Purpose: Converts `unsigned int' to `unsigned long_long' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_uint_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_uint_ullong, FAIL); H5T_CONV_uU(UINT, ULLONG, unsigned, unsigned long_long, -, -); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_long_schar * * Purpose: Converts `long' to `signed char' * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_long_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_long_schar, FAIL); H5T_CONV_Ss(LONG, SCHAR, long, signed char, SCHAR_MIN, SCHAR_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_long_uchar * * Purpose: Converts `long' to `unsigned char' * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_long_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_long_uchar, FAIL); H5T_CONV_Su(LONG, UCHAR, long, unsigned char, -, UCHAR_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_ulong_schar * * Purpose: Converts `unsigned long' to `signed char' * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_ulong_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_ulong_schar, FAIL); H5T_CONV_Us(ULONG, SCHAR, unsigned long, signed char, -, SCHAR_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_ulong_uchar * * Purpose: Converts `unsigned long' to `unsigned char' * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_ulong_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_ulong_uchar, FAIL); H5T_CONV_Uu(ULONG, UCHAR, unsigned long, unsigned char, -, UCHAR_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_long_short * * Purpose: Converts `long' to `short' * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_long_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_long_short, FAIL); H5T_CONV_Ss(LONG, SHORT, long, short, SHRT_MIN, SHRT_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_long_ushort * * Purpose: Converts `long' to `unsigned short' * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_long_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_long_ushort, FAIL); H5T_CONV_Su(LONG, USHORT, long, unsigned short, -, USHRT_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_ulong_short * * Purpose: Converts `unsigned long' to `short' * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_ulong_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_ulong_short, FAIL); H5T_CONV_Us(ULONG, SHORT, unsigned long, short, -, SHRT_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_ulong_ushort * * Purpose: Converts `unsigned long' to `unsigned short' * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_ulong_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_ulong_ushort, FAIL); H5T_CONV_Uu(ULONG, USHORT, unsigned long, unsigned short, -, USHRT_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_long_int * * Purpose: Converts `long' to `int' * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_long_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_long_int, FAIL); H5T_CONV_Ss(LONG, INT, long, int, INT_MIN, INT_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_long_uint * * Purpose: Converts `long' to `unsigned int' * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_long_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_long_uint, FAIL); H5T_CONV_Su(LONG, UINT, long, unsigned, -, UINT_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_ulong_int * * Purpose: Converts `unsigned long' to `int' * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_ulong_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_ulong_int, FAIL); H5T_CONV_Us(ULONG, INT, unsigned long, int, -, INT_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_ulong_uint * * Purpose: Converts `unsigned long' to `unsigned int' * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_ulong_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_ulong_uint, FAIL); H5T_CONV_Uu(ULONG, UINT, unsigned long, unsigned, -, UINT_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_long_ulong * * Purpose: Converts `long' to `unsigned long' * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Monday, November 16, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_long_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_long_ulong, FAIL); H5T_CONV_su(LONG, ULONG, long, unsigned long, -, -); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_ulong_long * * Purpose: Converts `unsigned long' to `long' * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Monday, November 16, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_ulong_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_ulong_long, FAIL); H5T_CONV_us(ULONG, LONG, unsigned long, long, -, LONG_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_long_llong * * Purpose: Converts `long' to `long_long' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_long_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_long_llong, FAIL); H5T_CONV_sS(LONG, LLONG, long, long_long, -, -); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_long_ullong * * Purpose: Converts `long' to `unsigned long_long' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_long_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_long_ullong, FAIL); H5T_CONV_sU(LONG, ULLONG, long, unsigned long_long, -, -); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_ulong_llong * * Purpose: Converts `unsigned long' to `long_long' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_ulong_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_ulong_llong, FAIL); H5T_CONV_uS(ULONG, LLONG, unsigned long, long_long, -, LLONG_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_ulong_ullong * * Purpose: Converts `unsigned long' to `unsigned long_long' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_ulong_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_ulong_ullong, FAIL); H5T_CONV_uU(ULONG, ULLONG, unsigned long, unsigned long_long, -, -); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_llong_schar * * Purpose: Converts `long_long' to `signed char' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_llong_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_llong_schar, FAIL); H5T_CONV_Ss(LLONG, SCHAR, long_long, signed char, SCHAR_MIN, SCHAR_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_llong_uchar * * Purpose: Converts `long_long' to `unsigned char' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_llong_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_llong_uchar, FAIL); H5T_CONV_Su(LLONG, UCHAR, long_long, unsigned char, -, UCHAR_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_ullong_schar * * Purpose: Converts `unsigned long_long' to `signed char' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_ullong_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_ullong_schar, FAIL); H5T_CONV_Us(ULLONG, SCHAR, unsigned long_long, signed char, -, SCHAR_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_ullong_uchar * * Purpose: Converts `unsigned long_long' to `unsigned char' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_ullong_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_ullong_uchar, FAIL); H5T_CONV_Uu(ULLONG, UCHAR, unsigned long_long, unsigned char, -, UCHAR_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_llong_short * * Purpose: Converts `long_long' to `short' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_llong_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_llong_short, FAIL); H5T_CONV_Ss(LLONG, SHORT, long_long, short, SHRT_MIN, SHRT_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_llong_ushort * * Purpose: Converts `long_long' to `unsigned short' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_llong_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_llong_ushort, FAIL); H5T_CONV_Su(LLONG, USHORT, long_long, unsigned short, -, USHRT_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_ullong_short * * Purpose: Converts `unsigned long_long' to `short' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_ullong_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_ullong_short, FAIL); H5T_CONV_Us(ULLONG, SHORT, unsigned long_long, short, -, SHRT_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_ullong_ushort * * Purpose: Converts `unsigned long_long' to `unsigned short' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_ullong_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_ullong_ushort, FAIL); H5T_CONV_Uu(ULLONG, USHORT, unsigned long_long, unsigned short, -, USHRT_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_llong_int * * Purpose: Converts `long_long' to `int' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_llong_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_llong_int, FAIL); H5T_CONV_Ss(LLONG, INT, long_long, int, INT_MIN, INT_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_llong_uint * * Purpose: Converts `long_long' to `unsigned int' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_llong_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_llong_uint, FAIL); H5T_CONV_Su(LLONG, UINT, long_long, unsigned, -, UINT_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_ullong_int * * Purpose: Converts `unsigned long_long' to `int' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_ullong_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_ullong_int, FAIL); H5T_CONV_Us(ULLONG, INT, unsigned long_long, int, -, INT_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_ullong_uint * * Purpose: Converts `unsigned long_long' to `unsigned int' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_ullong_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_ullong_uint, FAIL); H5T_CONV_Uu(ULLONG, UINT, unsigned long_long, unsigned, -, UINT_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_llong_long * * Purpose: Converts `long_long' to `long' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_llong_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_llong_long, FAIL); H5T_CONV_Ss(LLONG, LONG, long_long, long, LONG_MIN, LONG_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_llong_ulong * * Purpose: Converts `long_long' to `unsigned long' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_llong_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_llong_ulong, FAIL); H5T_CONV_Su(LLONG, ULONG, long_long, unsigned long, -, ULONG_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_ullong_long * * Purpose: Converts `unsigned long_long' to `long' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_ullong_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_ullong_long, FAIL); H5T_CONV_Us(ULLONG, LONG, unsigned long_long, long, -, LONG_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_ullong_ulong * * Purpose: Converts `unsigned long_long' to `unsigned long' * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_ullong_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_ullong_ulong, FAIL); H5T_CONV_Uu(ULLONG, ULONG, unsigned long_long, unsigned long, -, ULONG_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_llong_ullong * * Purpose: Converts `long_long' to `unsigned long_long' * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Monday, November 16, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_llong_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_llong_ullong, FAIL); H5T_CONV_su(LLONG, ULLONG, long_long, unsigned long_long, -, -); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_ullong_llong * * Purpose: Converts `unsigned long_long' to `long_long' * * Return: Success: non-negative * * Failure: negative * * Programmer: Robb Matzke * Monday, November 16, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5T_conv_ullong_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_ullong_llong, FAIL); H5T_CONV_us(ULLONG, LLONG, unsigned long_long, long_long, -, LLONG_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_float_double * * Purpose: Convert native `float' to native `double' using hardware. * This is a fast special case. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Tuesday, June 23, 1998 * * Modifications: * Robb Matzke, 1999-06-16 * Added support for non-zero strides. If BUF_STRIDE is non-zero * then convert one value at each memory location advancing * BUF_STRIDE bytes each time; otherwise assume both source and * destination values are packed. *------------------------------------------------------------------------- */ herr_t H5T_conv_float_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_float_double, FAIL); H5T_CONV_fF(FLOAT, DOUBLE, float, double, -, -); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_double_float * * Purpose: Convert native `double' to native `float' using hardware. * This is a fast special case. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Tuesday, June 23, 1998 * * Modifications: * Robb Matzke, 7 Jul 1998 * Added overflow handling. * * Robb Matzke, 1999-06-16 * Added support for non-zero strides. If BUF_STRIDE is non-zero * then convert one value at each memory location advancing * BUF_STRIDE bytes each time; otherwise assume both source and * destination values are packed. *------------------------------------------------------------------------- */ herr_t H5T_conv_double_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_double_float, FAIL); H5T_CONV_Ff(DOUBLE, FLOAT, double, float, -FLT_MAX, FLT_MAX); done: FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5T_conv_i32le_f64le * * Purpose: Converts 4-byte little-endian integers (signed or unsigned) * to 8-byte litte-endian IEEE floating point. * * Return: Non-negative on success/Negative on failure * * * Programmer: Robb Matzke * Wednesday, June 10, 1998 * * Modifications: * Robb Matzke, 1999-06-16 * Added support for non-zero strides. If BUF_STRIDE is non-zero * then convert one value at each memory location advancing * BUF_STRIDE bytes each time; otherwise assume both source and * destination values are packed. *------------------------------------------------------------------------- */ herr_t H5T_conv_i32le_f64le (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { uint8_t *s=NULL, *d=NULL; /*src and dst buf pointers */ uint8_t tmp[8]; /*temporary destination buffer */ H5T_t *src = NULL; /*source data type */ size_t elmtno; /*element counter */ unsigned sign; /*sign bit */ unsigned cin, cout; /*carry in/out */ unsigned mbits=0; /*mantissa bits */ unsigned exponent; /*exponent */ int i; /*counter */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_i32le_f64le, FAIL); switch (cdata->command) { case H5T_CONV_INIT: assert (sizeof(int)>=4); cdata->need_bkg = H5T_BKG_NO; break; case H5T_CONV_FREE: /* Free private data */ break; case H5T_CONV_CONV: /* The conversion */ if (NULL==(src=H5I_object(src_id)) || NULL==H5I_object(dst_id)) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); s = (uint8_t*)buf + (buf_stride?buf_stride:4)*(nelmts-1); d = (uint8_t*)buf + (buf_stride?buf_stride:8)*(nelmts-1); for (elmtno=0; elmtnoshared->u.atomic.u.i.sign) { case H5T_SGN_NONE: sign = 0; break; case H5T_SGN_2: if (s[3] & 0x80) { sign = 1; for (i=0,cin=1; i<4; i++,cin=cout) { s[i] = ~s[i]; cout = ((unsigned)(s[i])+cin > 0xff) ? 1 : 0; s[i] += cin; } } else { sign = 0; } break; default: HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported integer sign method"); } /* * Where is the most significant bit that is set? We could do * this in a loop, but testing it this way might be faster. */ if (s[3]) { if (s[3] & 0x80) mbits = 32; else if (s[3] & 0x40) mbits = 31; else if (s[3] & 0x20) mbits = 30; else if (s[3] & 0x10) mbits = 29; else if (s[3] & 0x08) mbits = 28; else if (s[3] & 0x04) mbits = 27; else if (s[3] & 0x02) mbits = 26; else if (s[3] & 0x01) mbits = 25; } else if (s[2]) { if (s[2] & 0x80) mbits = 24; else if (s[2] & 0x40) mbits = 23; else if (s[2] & 0x20) mbits = 22; else if (s[2] & 0x10) mbits = 21; else if (s[2] & 0x08) mbits = 20; else if (s[2] & 0x04) mbits = 19; else if (s[2] & 0x02) mbits = 18; else if (s[2] & 0x01) mbits = 17; } else if (s[1]) { if (s[1] & 0x80) mbits = 16; else if (s[1] & 0x40) mbits = 15; else if (s[1] & 0x20) mbits = 14; else if (s[1] & 0x10) mbits = 13; else if (s[1] & 0x08) mbits = 12; else if (s[1] & 0x04) mbits = 11; else if (s[1] & 0x02) mbits = 10; else if (s[1] & 0x01) mbits = 9; } else if (s[0]) { if (s[0] & 0x80) mbits = 8; else if (s[0] & 0x40) mbits = 7; else if (s[0] & 0x20) mbits = 6; else if (s[0] & 0x10) mbits = 5; else if (s[0] & 0x08) mbits = 4; else if (s[0] & 0x04) mbits = 3; else if (s[0] & 0x02) mbits = 2; else if (s[0] & 0x01) mbits = 1; } else { /*zero*/ d[7] = d[6] = d[5] = d[4] = d[3] = d[2] = d[1] = d[0] = 0; continue; } /* * The sign and exponent. */ exponent = (mbits - 1) + 1023; d[7] = (sign<<7) | ((exponent>>4) & 0x7f); d[6] = (exponent & 0x0f) << 4; /* * The mantissa. */ switch (mbits) { case 32: d[5] = d[4] = d[3] = d[1] = d[0] = 0; break; case 31: d[6] |= 0x0f & (s[3]>>2); d[5] = (s[3]<<6) | (s[2]>>2); d[4] = (s[2]<<6) | (s[1]>>2); d[3] = (s[1]<<6) | (s[0]>>2); d[2] = (s[0]<<6); d[1] = d[0] = 0; break; case 30: d[6] |= 0x0f & (s[3]>>1); d[5] = (s[3]<<7) | (s[2]>>1); d[4] = (s[2]<<7) | (s[1]>>1); d[3] = (s[1]<<7) | (s[0]>>1); d[2] = (s[0]<<7); d[1] = d[0] = 0; break; case 29: d[6] |= 0x0f & s[3]; d[5] = s[2]; d[4] = s[1]; d[3] = s[0]; d[2] = d[1] = d[0] = 0; break; case 28: d[6] |= ((s[3]<<1) | (s[2]>>7)) & 0x0f; d[5] = (s[2]<<1) | (s[1]>>7); d[4] = (s[1]<<1) | (s[0]>>7); d[3] = (s[0]<<1); d[2] = d[1] = d[0] = 0; break; case 27: d[6] |= ((s[3]<<2) | (s[2]>>6)) & 0x0f; d[5] = (s[2]<<2) | (s[1]>>6); d[4] = (s[1]<<2) | (s[0]>>6); d[3] = (s[0]<<2); d[2] = d[1] = d[0] = 0; break; case 26: d[6] |= ((s[3]<<3) | (s[2]>>5)) & 0x0f; d[5] = (s[2]<<3) | (s[1]>>5); d[4] = (s[1]<<3) | (s[0]>>5); d[3] = (s[0]<<3); d[2] = d[1] = d[0] = 0; break; case 25: d[6] |= 0x0f & (s[2]>>4); d[5] = (s[2]<<4) | (s[1]>>4); d[4] = (s[1]<<4) | (s[0]>>4); d[3] = (s[0]<<4); d[2] = d[1] = d[0] = 0; break; case 24: d[6] |= 0x0f & (s[2]>>3); d[5] = (s[2]<<5) | (s[1]>>3); d[4] = (s[1]<<5) | (s[0]>>3); d[3] = (s[0]<<5); d[2] = d[1] = d[0] = 0; break; case 23: d[6] |= 0x0f & (s[2]>>2); d[5] = (s[2]<<6) | (s[1]>>2); d[4] = (s[1]<<6) | (s[0]>>2); d[3] = (s[0]<<6); d[2] = d[1] = d[0] = 0; break; case 22: d[6] |= 0x0f & (s[2]>>1); d[5] = (s[2]<<7) | (s[1]>>1); d[4] = (s[1]<<7) | (s[0]>>1); d[3] = (s[0]<<7); d[2] = d[1] = d[0] = 0; break; case 21: d[6] |= 0x0f & s[2]; d[5] = s[1]; d[4] = s[0]; d[3] = d[2] = d[1] = d[0] = 0; break; case 20: d[6] |= ((s[2]<<1) | (s[1]>>7)) & 0x0f; d[5] = (s[1]<<1) | (s[0]>>7); d[4] = (s[0]<<1); d[3] = d[2] = d[1] = d[0] = 0; break; case 19: d[6] |= ((s[2]<<2) | (s[1]>>6)) & 0x0f; d[5] = (s[1]<<2) | (s[0]>>6); d[4] = (s[0]<<2); d[3] = d[2] = d[1] = d[0] = 0; break; case 18: d[6] |= ((s[2]<<3) | (s[1]>>5)) & 0x0f; d[5] = (s[1]<<3) | (s[0]>>5); d[4] = (s[0]<<3); d[3] = d[2] = d[1] = d[0] = 0; break; case 17: d[6] |= 0x0f & (s[1]>>4); d[5] = (s[1]<<4) | (s[0]>>4); d[4] = (s[0]<<4); d[3] = d[2] = d[1] = d[0] = 0; break; case 16: d[6] |= 0x0f & (s[1]>>3); d[5] = (s[1]<<5) | (s[0]>>3); d[4] = (s[0]<<5); d[3] = d[2] = d[1] = d[0] = 0; break; case 15: d[6] |= 0x0f & (s[1]>>2); d[5] = (s[1]<<6) | (s[0]>>2); d[4] = (s[0]<<6); d[3] = d[2] = d[1] = d[0] = 0; break; case 14: d[6] |= 0x0f & (s[1]>>1); d[5] = (s[1]<<7) | (s[0]>>1); d[4] = (s[0]<<7); d[3] = d[2] = d[1] = d[0] = 0; break; case 13: d[6] |= 0x0f & s[1]; d[5] = s[0]; d[4] = d[3] = d[2] = d[1] = d[0] = 0; break; case 12: d[6] |= ((s[1]<<1) | (s[0]>>7)) & 0x0f; d[5] = (s[0]<<1); d[4] = d[3] = d[2] = d[1] = d[0] = 0; break; case 11: d[6] |= ((s[1]<<2) | (s[0]>>6)) & 0x0f; d[5] = (s[0]<<2); d[4] = d[3] = d[2] = d[1] = d[0] = 0; break; case 10: d[6] |= ((s[1]<<3) | (s[0]>>5)) & 0x0f; d[5] = (s[0]<<3); d[4] = d[3] = d[2] = d[1] = d[0] = 0; break; case 9: d[6] |= 0x0f & (s[0]>>4); d[5] = (s[0]<<4); d[4] = d[3] = d[2] = d[1] = d[0] = 0; break; case 8: d[6] |= 0x0f & (s[0]>>3); d[5] = (s[0]<<5); d[4] = d[3] = d[2] = d[1] = d[0] = 0; break; case 7: d[6] |= 0x0f & (s[0]>>2); d[5] = (s[0]<<6); d[4] = d[3] = d[2] = d[1] = d[0] = 0; break; case 6: d[6] |= 0x0f & (s[0]>>1); d[5] = (s[0]<<7); d[4] = d[3] = d[2] = d[1] = d[0] = 0; break; case 5: d[6] |= 0x0f & s[0]; d[5] = d[4] = d[3] = d[2] = d[1] = d[0] = 0; break; case 4: d[6] |= (s[0]<<1) & 0x0f; d[5] = d[4] = d[3] = d[2] = d[1] = d[0] = 0; break; case 3: d[6] |= (s[0]<<2) & 0x0f; d[5] = d[4] = d[3] = d[2] = d[1] = d[0] = 0; break; case 2: d[6] |= (s[0]<<3) & 0x0f; d[5] = d[4] = d[3] = d[2] = d[1] = d[0] = 0; break; case 1: d[5] = d[4] = d[3] = d[2] = d[1] = d[0] = 0; break; } /* * Copy temp buffer to the destination. This only happens for * the first value in the array, the last value processed. See * beginning of loop. */ if (d==tmp) HDmemcpy (s, d, 8); /* Advance pointers */ if (buf_stride) { s -= buf_stride; d -= buf_stride; } else { s -= 4; d -= 8; } } break; default: /* Some other command we don't know about yet.*/ HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command"); } done: FUNC_LEAVE_NOAPI(ret_value); } xdmf-3.0+git20160803/Utilities/hdf5/H5Torder.c0000640000175000017500000001141213003006557020472 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Module Info: This module contains the functionality for setting & querying * the datatype byte order for the H5T interface. */ #define H5T_PACKAGE /*suppress error about including H5Tpkg */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5T_init_order_interface #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Iprivate.h" /* IDs */ #include "H5Tpkg.h" /* Datatypes */ /*-------------------------------------------------------------------------- NAME H5T_init_order_interface -- Initialize interface-specific information USAGE herr_t H5T_init_order_interface() RETURNS Non-negative on success/Negative on failure DESCRIPTION Initializes any interface-specific data or routines. (Just calls H5T_init_iterface currently). --------------------------------------------------------------------------*/ static herr_t H5T_init_order_interface(void) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_init_order_interface) FUNC_LEAVE_NOAPI(H5T_init()) } /* H5T_init_order_interface() */ /*------------------------------------------------------------------------- * Function: H5Tget_order * * Purpose: Returns the byte order of a data type. * * Return: Success: A byte order constant * * Failure: H5T_ORDER_ERROR (Negative) * * Programmer: Robb Matzke * Wednesday, January 7, 1998 * * Modifications: * Robb Matzke, 22 Dec 1998 * Also works for derived data types. * *------------------------------------------------------------------------- */ H5T_order_t H5Tget_order(hid_t type_id) { H5T_t *dt = NULL; H5T_order_t ret_value; FUNC_ENTER_API(H5Tget_order, H5T_ORDER_ERROR) H5TRACE1("To","i",type_id); /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_ORDER_ERROR, "not a data type") while (dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ if (!H5T_IS_ATOMIC(dt->shared)) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, H5T_ORDER_ERROR, "operation not defined for specified data type") /* Order */ ret_value = dt->shared->u.atomic.order; done: FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5Tset_order * * Purpose: Sets the byte order for a data type. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Wednesday, January 7, 1998 * * Modifications: * Robb Matzke, 22 Dec 1998 * Also works for derived data types. * *------------------------------------------------------------------------- */ herr_t H5Tset_order(hid_t type_id, H5T_order_t order) { H5T_t *dt = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Tset_order, FAIL) H5TRACE2("e","iTo",type_id,order); /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") if (H5T_STATE_TRANSIENT!=dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only") if (order < H5T_ORDER_LE || order > H5T_ORDER_NONE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal byte order") if (H5T_ENUM==dt->shared->type && dt->shared->u.enumer.nmembs>0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not allowed after members are defined") while (dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ if (!H5T_IS_ATOMIC(dt->shared)) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "operation not defined for specified data type") /* Commit */ dt->shared->u.atomic.order = order; done: FUNC_LEAVE_API(ret_value) } xdmf-3.0+git20160803/Utilities/hdf5/H5Defl.c0000640000175000017500000003047313003006557020115 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Quincey Koziol * Thursday, September 30, 2004 */ #define H5D_PACKAGE /*suppress error about including H5Dpkg */ #include "H5private.h" /* Generic Functions */ #include "H5Dpkg.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fprivate.h" /* Files */ /* PRIVATE PROTOTYPES */ static herr_t H5D_efl_read (const H5O_efl_t *efl, haddr_t addr, size_t size, uint8_t *buf); static herr_t H5D_efl_write(const H5O_efl_t *efl, haddr_t addr, size_t size, const uint8_t *buf); /*------------------------------------------------------------------------- * Function: H5D_efl_read * * Purpose: Reads data from an external file list. It is an error to * read past the logical end of file, but reading past the end * of any particular member of the external file list results in * zeros. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Wednesday, March 4, 1998 * * Modifications: * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. *------------------------------------------------------------------------- */ static herr_t H5D_efl_read (const H5O_efl_t *efl, haddr_t addr, size_t size, uint8_t *buf) { int fd=-1; size_t to_read; #ifndef NDEBUG hsize_t tempto_read; #endif /* NDEBUG */ hsize_t skip=0; haddr_t cur; ssize_t n; size_t u; /* Local index variable */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5D_efl_read) /* Check args */ assert (efl && efl->nused>0); assert (H5F_addr_defined (addr)); assert (size < SIZET_MAX); assert (buf || 0==size); /* Find the first efl member from which to read */ for (u=0, cur=0; unused; u++) { if (H5O_EFL_UNLIMITED==efl->slot[u].size || addr < cur+efl->slot[u].size) { skip = addr - cur; break; } cur += efl->slot[u].size; } /* Read the data */ while (size) { assert(buf); if (u>=efl->nused) HGOTO_ERROR (H5E_EFL, H5E_OVERFLOW, FAIL, "read past logical end of file") if (H5F_OVERFLOW_HSIZET2OFFT (efl->slot[u].offset+skip)) HGOTO_ERROR (H5E_EFL, H5E_OVERFLOW, FAIL, "external file address overflowed") if ((fd=HDopen (efl->slot[u].name, O_RDONLY, 0))<0) HGOTO_ERROR (H5E_EFL, H5E_CANTOPENFILE, FAIL, "unable to open external raw data file") if (HDlseek (fd, (off_t)(efl->slot[u].offset+skip), SEEK_SET)<0) HGOTO_ERROR (H5E_EFL, H5E_SEEKERROR, FAIL, "unable to seek in external raw data file") #ifndef NDEBUG tempto_read = MIN(efl->slot[u].size-skip,(hsize_t)size); H5_CHECK_OVERFLOW(tempto_read,hsize_t,size_t); to_read = (size_t)tempto_read; #else /* NDEBUG */ to_read = MIN((size_t)(efl->slot[u].size-skip), size); #endif /* NDEBUG */ if ((n=HDread (fd, buf, to_read))<0) { HGOTO_ERROR (H5E_EFL, H5E_READERROR, FAIL, "read error in external raw data file") } else if ((size_t)n=0) HDclose (fd); FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5D_efl_write * * Purpose: Writes data to an external file list. It is an error to * write past the logical end of file, but writing past the end * of any particular member of the external file list just * extends that file. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Wednesday, March 4, 1998 * * Modifications: * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. *------------------------------------------------------------------------- */ static herr_t H5D_efl_write (const H5O_efl_t *efl, haddr_t addr, size_t size, const uint8_t *buf) { int fd=-1; size_t to_write; #ifndef NDEBUG hsize_t tempto_write; #endif /* NDEBUG */ haddr_t cur; hsize_t skip=0; size_t u; /* Local index variable */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5D_efl_write) /* Check args */ assert (efl && efl->nused>0); assert (H5F_addr_defined (addr)); assert (size < SIZET_MAX); assert (buf || 0==size); /* Find the first efl member in which to write */ for (u=0, cur=0; unused; u++) { if (H5O_EFL_UNLIMITED==efl->slot[u].size || addr < cur+efl->slot[u].size) { skip = addr - cur; break; } cur += efl->slot[u].size; } /* Write the data */ while (size) { assert(buf); if (u>=efl->nused) HGOTO_ERROR (H5E_EFL, H5E_OVERFLOW, FAIL, "write past logical end of file") if (H5F_OVERFLOW_HSIZET2OFFT (efl->slot[u].offset+skip)) HGOTO_ERROR (H5E_EFL, H5E_OVERFLOW, FAIL, "external file address overflowed") if ((fd=HDopen (efl->slot[u].name, O_CREAT|O_RDWR, 0666))<0) { if (HDaccess (efl->slot[u].name, F_OK)<0) { HGOTO_ERROR (H5E_EFL, H5E_CANTOPENFILE, FAIL, "external raw data file does not exist") } else { HGOTO_ERROR (H5E_EFL, H5E_CANTOPENFILE, FAIL, "unable to open external raw data file") } } if (HDlseek (fd, (off_t)(efl->slot[u].offset+skip), SEEK_SET)<0) HGOTO_ERROR (H5E_EFL, H5E_SEEKERROR, FAIL, "unable to seek in external raw data file") #ifndef NDEBUG tempto_write = MIN(efl->slot[u].size-skip,(hsize_t)size); H5_CHECK_OVERFLOW(tempto_write,hsize_t,size_t); to_write = (size_t)tempto_write; #else /* NDEBUG */ to_write = MIN((size_t)(efl->slot[u].size-skip), size); #endif /* NDEBUG */ if ((size_t)HDwrite (fd, buf, to_write)!=to_write) HGOTO_ERROR (H5E_EFL, H5E_READERROR, FAIL, "write error in external raw data file") HDclose (fd); fd = -1; size -= to_write; buf += to_write; skip = 0; u++; } done: if (fd>=0) HDclose (fd); FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5D_efl_readvv * * Purpose: Reads data from an external file list. It is an error to * read past the logical end of file, but reading past the end * of any particular member of the external file list results in * zeros. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Wednesday, May 7, 2003 * * Modifications: * *------------------------------------------------------------------------- */ ssize_t H5D_efl_readvv(const H5D_io_info_t *io_info, size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_len_arr[], hsize_t dset_offset_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[], void *_buf) { const H5O_efl_t *efl=&(io_info->store->efl); /* Pointer to efl info */ unsigned char *buf; /* Pointer to buffer to write */ haddr_t addr; /* Actual address to read */ size_t total_size=0; /* Total size of sequence in bytes */ size_t size; /* Size of sequence in bytes */ size_t u; /* Counting variable */ size_t v; /* Counting variable */ ssize_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5D_efl_readvv, FAIL) /* Check args */ assert (efl && efl->nused>0); assert (_buf); /* Work through all the sequences */ for(u=*dset_curr_seq, v=*mem_curr_seq; ustore->efl); /* Pointer to efl info */ const unsigned char *buf; /* Pointer to buffer to write */ haddr_t addr; /* Actual address to read */ size_t total_size=0; /* Total size of sequence in bytes */ size_t size; /* Size of sequence in bytes */ size_t u; /* Counting variable */ size_t v; /* Counting variable */ ssize_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5D_efl_writevv, FAIL) /* Check args */ assert (efl && efl->nused>0); assert (_buf); /* Work through all the sequences */ for(u=*dset_curr_seq, v=*mem_curr_seq; u * Jan 3, 2003 */ #define H5Z_PACKAGE /*suppress error about including H5Zpkg */ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fprivate.h" /* File access */ #include "H5MMprivate.h" /* Memory management */ #include "H5Zpkg.h" /* Data filters */ #ifdef H5_HAVE_FILTER_FLETCHER32 /* Local function prototypes */ static size_t H5Z_filter_fletcher32 (unsigned flags, size_t cd_nelmts, const unsigned cd_values[], size_t nbytes, size_t *buf_size, void **buf); /* This message derives from H5Z */ const H5Z_class_t H5Z_FLETCHER32[1] = {{ H5Z_FILTER_FLETCHER32, /* Filter id number */ "fletcher32", /* Filter name for debugging */ NULL, /* The "can apply" callback */ NULL, /* The "set local" callback */ H5Z_filter_fletcher32, /* The actual filter function */ }}; #define FLETCHER_LEN 4 /*------------------------------------------------------------------------- * Function: H5Z_filter_fletcher32_compute * * Purpose: Implement an Fletcher32 Checksum using 1's complement. * * Return: Success: Fletcher32 value * * Failure: Can't fail * * Programmer: Raymond Lu * Jan 3, 2003 * * Modifications: Pedro Vicente, March 10, 2004 * defined *SRC as unsigned char for all cases * *------------------------------------------------------------------------- */ static uint32_t H5Z_filter_fletcher32_compute(void *_src, size_t len) { unsigned char *src=(unsigned char *)_src; /*To handle unusual platforms like Cray*/ unsigned short tmp_src; size_t count = len; /* Number of bytes left to checksum */ uint32_t s1 = 0, s2 = 0; /* Temporary partial checksums */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5Z_filter_fletcher32_compute) /* Compute checksum */ while(count > 1) { /*To handle unusual platforms like Cray*/ tmp_src = (((unsigned short)src[0])<<8) | ((unsigned short)src[1]); src +=2; s1 += tmp_src; if(s1 & 0xFFFF0000) { /*Wrap around carry if occurred*/ s1 &= 0xFFFF; s1++; } s2 += s1; if(s2 & 0xFFFF0000) { /*Wrap around carry if occurred*/ s2 &= 0xFFFF; s2++; } count -= 2; } if(count==1) { s1 += *(unsigned char*)src; if(s1 & 0xFFFF0000) { /*Wrap around carry if occurred*/ s1 &= 0xFFFF; s1++; } s2 += s1; if(s2 & 0xFFFF0000) { /*Wrap around carry if occurred*/ s2 &= 0xFFFF; s2++; } } FUNC_LEAVE_NOAPI((s2 << 16) + s1) } /*------------------------------------------------------------------------- * Function: H5Z_filter_fletcher32 * * Purpose: Implement an I/O filter of Fletcher32 Checksum * * Return: Success: Size of buffer filtered * Failure: 0 * * Programmer: Raymond Lu * Jan 3, 2003 * * Modifications: * Raymond Lu * July 8, 2005 * There was a bug in the calculating code of the Fletcher32 * checksum in the library before v1.6.3. The checksum * value wasn't consistent between big-endian and little-endian * systems. This bug was fixed in Release 1.6.3. However, * after fixing the bug, the checksum value is no longer the * same as before on little-endian system. We'll check both * the correct checksum and the wrong checksum to be consistent * with Release 1.6.2 and before. * *------------------------------------------------------------------------- */ /* ARGSUSED */ static size_t H5Z_filter_fletcher32 (unsigned flags, size_t UNUSED cd_nelmts, const unsigned UNUSED cd_values[], size_t nbytes, size_t *buf_size, void **buf) { void *outbuf = NULL; /* Pointer to new buffer */ unsigned char *src = (unsigned char*)(*buf); uint32_t fletcher; /* Checksum value */ uint32_t reversed_fletcher; /* Possible wrong checksum value */ uint8_t c[4]; uint8_t tmp; size_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5Z_filter_fletcher32, 0) assert(sizeof(uint32_t)>=4); if (flags & H5Z_FLAG_REVERSE) { /* Read */ /* Do checksum if it's enabled for read; otherwise skip it * to save performance. */ if (!(flags & H5Z_FLAG_SKIP_EDC)) { unsigned char *tmp_src; /* Pointer to checksum in buffer */ size_t src_nbytes = nbytes; /* Original number of bytes */ uint32_t stored_fletcher; /* Stored checksum value */ /* Get the stored checksum */ src_nbytes -= FLETCHER_LEN; tmp_src=src+src_nbytes; UINT32DECODE(tmp_src, stored_fletcher); /* Compute checksum (can't fail) */ fletcher = H5Z_filter_fletcher32_compute(src,src_nbytes); /* The reversed checksum. There was a bug in the calculating code of * the Fletcher32 checksum in the library before v1.6.3. The checksum * value wasn't consistent between big-endian and little-endian systems. * This bug was fixed in Release 1.6.3. However, after fixing the bug, * the checksum value is no longer the same as before on little-endian * system. We'll check both the correct checksum and the wrong * checksum to be consistent with Release 1.6.2 and before. */ HDmemcpy(c, &fletcher, 4); tmp = c[1]; c[1] = c[0]; c[0] = tmp; tmp = c[3]; c[3] = c[2]; c[2] = tmp; HDmemcpy(&reversed_fletcher, c, 4); /* Verify computed checksum matches stored checksum */ if(stored_fletcher != fletcher && stored_fletcher != reversed_fletcher) HGOTO_ERROR(H5E_STORAGE, H5E_READERROR, 0, "data error detected by Fletcher32 checksum") } /* Set return values */ /* (Re-use the input buffer, just note that the size is smaller by the size of the checksum) */ ret_value = nbytes-FLETCHER_LEN; } else { /* Write */ unsigned char *dst; /* Temporary pointer to destination buffer */ /* Compute checksum (can't fail) */ fletcher = H5Z_filter_fletcher32_compute(src,nbytes); if (NULL==(dst=outbuf=H5MM_malloc(nbytes+FLETCHER_LEN))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "unable to allocate Fletcher32 checksum destination buffer") /* Copy raw data */ HDmemcpy((void*)dst, (void*)(*buf), nbytes); /* Append checksum to raw data for storage */ dst += nbytes; UINT32ENCODE(dst, fletcher); /* Free input buffer */ H5MM_xfree(*buf); /* Set return values */ *buf_size = nbytes + FLETCHER_LEN; *buf = outbuf; outbuf = NULL; ret_value = *buf_size; } done: if(outbuf) H5MM_xfree(outbuf); FUNC_LEAVE_NOAPI(ret_value) } #endif /* H5_HAVE_FILTER_FLETCHER32 */ xdmf-3.0+git20160803/Utilities/hdf5/H5ST.c0000640000175000017500000005306213003006557017570 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* TERNARY SEARCH TREE ALGS This code is described in "Ternary Search Trees" by Jon Bentley and Robert Sedgewick in the April, 1998, Dr. Dobb's Journal. */ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free lists */ #include "H5STprivate.h" /* Ternary search trees */ /* Declare a free list to manage the H5ST_node_t struct */ H5FL_DEFINE_STATIC(H5ST_node_t); /* Declare a free list to manage the H5ST_tree_t struct */ H5FL_DEFINE_STATIC(H5ST_tree_t); /*-------------------------------------------------------------------------- NAME H5ST_create PURPOSE Create a TST USAGE H5ST_ptr_t H5ST_create() RETURNS Returns a pointer to the new TST tree on success, NULL on failure. DESCRIPTION Create a TST. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ H5ST_tree_t * H5ST_create(void) { H5ST_tree_t *ret_value=NULL; /* Return value */ FUNC_ENTER_NOAPI(H5ST_create,NULL); /* Allocate wrapper for TST */ if((ret_value=H5FL_MALLOC(H5ST_tree_t))==NULL) HGOTO_ERROR(H5E_RESOURCE,H5E_NOSPACE,NULL,"memory allocation failed"); /* Set the internal fields */ ret_value->root=NULL; done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5ST_create() */ /*-------------------------------------------------------------------------- NAME H5ST_close_internal PURPOSE Close a TST, deallocating it. USAGE herr_t H5ST_close(p) H5ST_ptr_t p; IN/OUT: Root of TST to free RETURNS Returns non-negative on success, negative on failure. DESCRIPTION Close a TST, freeing all nodes. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5ST_close_internal(H5ST_ptr_t p) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5ST_close_internal); /* Recursively free TST */ if(p) { H5ST_close_internal(p->lokid); if (p->splitchar) H5ST_close_internal(p->eqkid); H5ST_close_internal(p->hikid); H5FL_FREE(H5ST_node_t,p); } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED); } /* end H5ST_close_internal() */ /*-------------------------------------------------------------------------- NAME H5ST_close PURPOSE Close a TST, deallocating it. USAGE herr_t H5ST_close(tree) H5ST_tree_t *tree; IN/OUT: TST tree to free RETURNS Returns non-negative on success, negative on failure. DESCRIPTION Close a TST, freeing all nodes. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5ST_close(H5ST_tree_t *tree) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5ST_close,FAIL); /* Check arguments */ if(tree==NULL) HGOTO_ERROR(H5E_ARGS,H5E_BADVALUE,FAIL,"invalid TST"); /* Free the TST itself */ if(H5ST_close_internal(tree->root)<0) HGOTO_ERROR(H5E_TST,H5E_CANTFREE,FAIL,"can't free TST"); /* Free root node itself */ H5FL_FREE(H5ST_tree_t,tree); done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5ST_close() */ /*-------------------------------------------------------------------------- NAME H5ST_insert PURPOSE Insert a string/object pair into a TST USAGE herr_t H5ST_insert(tree,s,obj) H5ST_tree_t *tree; IN/OUT: TST to insert string into const char *s; IN: String to use as key for object void *obj; IN: Pointer to object to insert RETURNS Returns non-negative on success, negative on failure. DESCRIPTION Insert a key (string)/object pair into a TST GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5ST_insert(H5ST_tree_t *tree, const char *s, void *obj) { int d; /* Comparison value */ H5ST_ptr_t pp, *p; /* Pointer to current node and pointer to that */ H5ST_ptr_t parent=NULL; /* Pointer to parent node */ H5ST_ptr_t up=NULL; /* Pointer to up node */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5ST_insert,FAIL); /* Find the correct location to insert object */ p = &tree->root; while((pp = *p)) { /* If this node matches the character in the key, then drop down to the lower tree */ if ((d = *s - pp->splitchar) == 0) { if (*s++ == 0) HGOTO_ERROR(H5E_TST,H5E_EXISTS,FAIL,"key already in tree"); up=pp; p = &(pp->eqkid); } /* end if */ else { /* Walk through the current tree, searching for the matching character */ parent=pp; if (d < 0) p = &(pp->lokid); else p = &(pp->hikid); } /* end else */ } /* end while */ /* Finish walking through the key string, adding nodes until the end */ for (;;) { if((*p = H5FL_MALLOC(H5ST_node_t))==NULL) HGOTO_ERROR(H5E_RESOURCE,H5E_NOSPACE,FAIL,"memory allocation failed"); pp = *p; pp->splitchar = *s; pp->up = up; pp->parent = parent; pp->lokid = pp->eqkid = pp->hikid = NULL; /* If this is the end of the key string, break out */ if (*s++ == 0) { pp->eqkid = (H5ST_ptr_t) obj; break; } /* end if */ /* Continue to next character */ parent=NULL; up=pp; p = &(pp->eqkid); } /* end for */ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5ST_insert() */ /*-------------------------------------------------------------------------- NAME H5ST_search PURPOSE Determine if a key is in the TST USAGE hbool_t H5ST_search(tree,s) H5ST_tree_t *tree; IN: TST to find string in const char *s; IN: String to use as key to locate RETURNS Success: TRUE if key string in TST, FALSE if not Failure: negative DESCRIPTION Locate a key (string) in a TST GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ htri_t H5ST_search(H5ST_tree_t *tree, const char *s) { H5ST_ptr_t p; /* Temporary pointer to TST node */ htri_t ret_value=FALSE; /* Return value */ FUNC_ENTER_NOAPI_NOFUNC(H5ST_search); p = tree->root; while (p) { if (*s < p->splitchar) p = p->lokid; else if (*s == p->splitchar) { if (*s++ == 0) HGOTO_DONE(TRUE); p = p->eqkid; } else p = p->hikid; } /* end while */ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5ST_search() */ /*-------------------------------------------------------------------------- NAME H5ST_find_internal PURPOSE Find the node matching a particular key string USAGE H5ST_ptr_t H5ST_find(p,s) H5ST_ptr_t p; IN: TST to find string in const char *s; IN: String to use as key to locate RETURNS Success: Non-NULL Failure: NULL DESCRIPTION Locate a key (string) in a TST GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static H5ST_ptr_t H5ST_find_internal(H5ST_ptr_t p, const char *s) { H5ST_ptr_t ret_value=NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5ST_find_internal); while (p) { if (*s < p->splitchar) p = p->lokid; else if (*s == p->splitchar) { if (*s++ == 0) HGOTO_DONE(p); p = p->eqkid; } else p = p->hikid; } /* end while */ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5ST_find_internal() */ /*-------------------------------------------------------------------------- NAME H5ST_find PURPOSE Find the node matching a particular key string USAGE H5ST_ptr_t H5ST_find(tree,s) H5ST_tree_t *tree; IN: TST to find string in const char *s; IN: String to use as key to locate RETURNS Success: Non-NULL Failure: NULL DESCRIPTION Locate a key (string) in a TST GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ H5ST_ptr_t H5ST_find(H5ST_tree_t *tree, const char *s) { H5ST_ptr_t ret_value=NULL; /* Return value */ FUNC_ENTER_NOAPI(H5ST_find,NULL); if((ret_value=H5ST_find_internal(tree->root,s))==NULL) HGOTO_ERROR(H5E_TST,H5E_NOTFOUND,NULL,"key not found in TST"); done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5ST_find() */ /*-------------------------------------------------------------------------- NAME H5ST_locate PURPOSE Find an object in a TST USAGE void *H5ST_locate(tree,s) H5ST_tree_t *tree; IN: TST to locate object within const char *s; IN: String of key for object to locate RETURNS Success: Non-NULL, pointer to object stored for key Failure: Negative DESCRIPTION Locate a node in a TST, returning the object from the node. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ void * H5ST_locate(H5ST_tree_t *tree, const char *s) { H5ST_ptr_t node; /* Pointer to node located */ void *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5ST_locate,NULL); /* Locate the node to remove */ if((node=H5ST_find_internal(tree->root,s))==NULL) HGOTO_ERROR(H5E_TST,H5E_NOTFOUND,NULL,"key not found in TST"); /* Get the pointer to the object to return */ ret_value=node->eqkid; done: FUNC_LEAVE_NOAPI(ret_value); } /* H5ST_locate() */ /*-------------------------------------------------------------------------- NAME H5ST_findfirst_internal PURPOSE Find the first node in a TST USAGE H5ST_ptr_t H5ST_findfirst_internal(p) H5ST_ptr_t p; IN: TST to locate first node within RETURNS Success: Non-NULL Failure: NULL DESCRIPTION Get the first (lexicographically) node in a TST GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static H5ST_ptr_t H5ST_findfirst_internal(H5ST_ptr_t p) { H5ST_ptr_t ret_value=NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5ST_findfirst_internal); while(p) { /* Find least node in current tree */ while(p->lokid) p=p->lokid; /* Is least node '\0'? */ if(p->splitchar=='\0') { /* Return it */ HGOTO_DONE(p); } /* end if */ else { /* Go down to next level of tree */ p=p->eqkid; } /* end else */ } /* end while */ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5ST_findfirst_internal() */ /*-------------------------------------------------------------------------- NAME H5ST_findfirst PURPOSE Find the first node in a TST USAGE H5ST_ptr_t H5ST_findfirst(tree) H5ST_tree_t *tree; IN: TST to locate first node within RETURNS Success: Non-NULL Failure: NULL DESCRIPTION Get the first (lexicographically) node in a TST GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ H5ST_ptr_t H5ST_findfirst(H5ST_tree_t *tree) { H5ST_ptr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5ST_findfirst,NULL); if((ret_value=H5ST_findfirst_internal(tree->root))==NULL) HGOTO_ERROR(H5E_TST,H5E_NOTFOUND,NULL,"no nodes in TST"); done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5ST_findfirst() */ /*-------------------------------------------------------------------------- NAME H5ST_getnext PURPOSE Internal routine to find the next node in a given level of a TST USAGE H5ST_ptr_t H5ST_getnext(p) H5ST_ptr_t *p; IN: Pointer to node to find next node from RETURNS Success: Non-NULL Failure: NULL DESCRIPTION Get the next (lexicographically) node in the current level of a TST GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static H5ST_ptr_t H5ST_getnext(H5ST_ptr_t p) { H5ST_ptr_t ret_value=NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5ST_getnext); /* If the node to continue from has higher-valued nodes attached */ if(p->hikid) { /* Go to first higher-valued node */ p=p->hikid; /* Find least node from here */ while(p->lokid) p=p->lokid; HGOTO_DONE(p); } /* end if */ else { H5ST_ptr_t q; /* Temporary TST node pointer */ /* Go up one level in current tree */ q=p->parent; if(q==NULL) HGOTO_DONE(NULL); /* While the previous node was the higher-valued node, keep backing up the tree */ while(q->hikid==p) { p=q; q=p->parent; if(q==NULL) HGOTO_DONE(NULL); } /* end while */ HGOTO_DONE(q); } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5ST_getnext() */ /*-------------------------------------------------------------------------- NAME H5ST_findnext PURPOSE Find the next node from a node in a TST USAGE H5ST_ptr_t H5ST_findnext(p) H5ST_ptr_t p; IN: Current node to continue from RETURNS Success: Non-NULL Failure: NULL DESCRIPTION Get the next (lexicographically) node in a TST GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ H5ST_ptr_t H5ST_findnext(H5ST_ptr_t p) { H5ST_ptr_t q; /* Temporary pointer to TST node */ H5ST_ptr_t ret_value=NULL; /* Return value */ FUNC_ENTER_NOAPI_NOFUNC(H5ST_findnext); /* Find the next node at the current level, or go back up the tree */ do { q=H5ST_getnext(p); if(q) { HGOTO_DONE(H5ST_findfirst_internal(q->eqkid)); } /* end if */ else p=p->up; } while(p); done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5ST_findnext() */ /*-------------------------------------------------------------------------- NAME H5ST_delete_internal PURPOSE Delete a node from a TST USAGE herr_t H5ST_delete_internal(root,p) H5ST_ptr_t *root; IN/OUT: Root of TST to delete node from H5ST_ptr_t p; IN: Node to delete RETURNS Success: Non-negative Failure: Negative DESCRIPTION Delete a node from a TST. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS This should be the final node for a string. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5ST_delete_internal(H5ST_ptr_t *root, H5ST_ptr_t p) { H5ST_ptr_t q, /* Temporary pointer to TST node */ newp; /* Pointer to node which will replace deleted node in tree */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5ST_delete_internal); /* Find node to replace one being deleted */ if(p->lokid) { /* If the deleted node has lo & hi kids, attach them together */ if(p->hikid) { q=p->lokid; while(q->hikid) q=q->hikid; q->hikid=p->hikid; p->hikid->parent=q; } /* end if */ newp=p->lokid; } /* end if */ else if(p->hikid) { newp=p->hikid; } /* end if */ else { newp=NULL; } /* end else */ /* Deleted node is in middle of tree */ if(p->parent) { /* Attach new node to correct side of parent */ if(p==p->parent->lokid) p->parent->lokid=newp; else p->parent->hikid=newp; if(newp) newp->parent=p->parent; } /* end if */ else { if(newp) newp->parent=p->parent; if(p->up) { p->up->eqkid=newp; /* If we deleted the last node in the TST, delete the upper node also */ if(newp==NULL) H5ST_delete_internal(root,p->up); } /* end if */ else /* Deleted last node at top level of tree */ *root=newp; } /* end else */ H5FL_FREE(H5ST_node_t,p); FUNC_LEAVE_NOAPI(SUCCEED); } /* end H5ST_delete_internal() */ /*-------------------------------------------------------------------------- NAME H5ST_delete PURPOSE Delete a node from a TST USAGE herr_t H5ST_delete(tree,p) H5ST_tree_t *tree; IN/OUT: TST to delete node from H5ST_ptr_t p; IN: Node to delete RETURNS Success: Non-negative Failure: Negative DESCRIPTION Delete a node from a TST. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS This should be the final node for a string. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5ST_delete(H5ST_tree_t *tree, H5ST_ptr_t p) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5ST_delete,FAIL); if(H5ST_delete_internal(&tree->root,p)<0) HGOTO_ERROR(H5E_TST,H5E_CANTDELETE,FAIL,"can't delete node from TST"); done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5ST_delete() */ /*-------------------------------------------------------------------------- NAME H5ST_remove PURPOSE Remove a node from a TST USAGE void *H5ST_remove(tree,s) H5ST_tree_t *tree; IN/OUT: TST to remove node from const char *s; IN: String of key for node to remove RETURNS Success: Non-NULL, pointer to object stored for key Failure: Negative DESCRIPTION Remove a node from a TST, returning the object from the node. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ void * H5ST_remove(H5ST_tree_t *tree, const char *s) { H5ST_ptr_t node; /* Pointer to node to remove */ void *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5ST_remove,NULL); /* Locate the node to remove */ if((node=H5ST_find_internal(tree->root,s))==NULL) HGOTO_ERROR(H5E_TST,H5E_NOTFOUND,NULL,"key not found in TST"); /* Get the pointer to the object to return */ ret_value=node->eqkid; /* Remove the node from the TST */ if(H5ST_delete_internal(&tree->root,node)<0) HGOTO_ERROR(H5E_TST,H5E_CANTDELETE,NULL,"can't delete node from TST"); done: FUNC_LEAVE_NOAPI(ret_value); } /* H5ST_remove() */ #ifdef H5ST_DEBUG /*-------------------------------------------------------------------------- NAME H5ST_dump_internal PURPOSE Dump all the nodes of a TST USAGE herr_t H5ST_dump(p) H5ST_ptr_t p; IN: Root of TST to dump RETURNS Success: Non-negative Failure: Negative DESCRIPTION Dump information for a TST. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5ST_dump_internal(H5ST_ptr_t p) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5ST_dump_internal); if (p) { printf("p=%p\n",p); printf("\tp->up=%p\n",p->up); printf("\tp->parent=%p\n",p->parent); printf("\tp->lokid=%p\n",p->lokid); printf("\tp->hikid=%p\n",p->hikid); printf("\tp->eqkid=%p\n",p->eqkid); printf("\tp->splitchar=%c\n",p->splitchar); H5ST_dump_internal(p->lokid); if (p->splitchar) H5ST_dump_internal(p->eqkid); else printf("%s\n", (char *) p->eqkid); H5ST_dump_internal(p->hikid); } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED); } /* end H5ST_dump_internal() */ /*-------------------------------------------------------------------------- NAME H5ST_dump PURPOSE Dump all the nodes of a TST USAGE herr_t H5ST_dump(tree) H5ST_tree_t *tree; IN: TST to dump RETURNS Success: Non-negative Failure: Negative DESCRIPTION Dump information for a TST. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5ST_dump(H5ST_tree_t *tree) { FUNC_ENTER_NOAPI_NOFUNC(H5ST_dump,NULL); /* Dump the tree */ H5ST_dump_internal(tree->root); FUNC_LEAVE_NOAPI(SUCCEED); } /* end H5ST_dump() */ #endif /* H5ST_DEBUG */ xdmf-3.0+git20160803/Utilities/hdf5/H5C.c0000640000175000017500000052716313003006557017434 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*------------------------------------------------------------------------- * * Created: H5C.c * June 1 2004 * John Mainzer * * Purpose: Functions in this file implement a generic cache for * things which exist on disk, and which may be * unambiguously referenced by their disk addresses. * * The code in this module was initially written in * support of a complete re-write of the metadata cache * in H5AC.c However, other uses for the cache code * suggested themselves, and thus this file was created * in an attempt to support re-use. * * For a detailed overview of the cache, please see the * header comment for H5C_t in this file. * * Modifications: * * QAK - 11/27/2004 * Switched over to using skip list routines instead of TBBT * routines. * *------------------------------------------------------------------------- */ /************************************************************************** * * To Do: * * Code Changes: * * - Remove extra functionality in H5C_flush_single_entry()? * * - Change protect/unprotect to lock/unlock. * * - Change the way the dirty flag is set. Probably pass it in * as a parameter in unprotect & insert. * * - Size should also be passed in as a parameter in insert and * unprotect -- or some other way should be found to advise the * cache of changes in entry size. * * - Flush entries in increasing address order in * H5C_make_space_in_cache(). * * - Also in H5C_make_space_in_cache(), use high and low water marks * to reduce the number of I/O calls. * * - When flushing, attempt to combine contiguous entries to reduce * I/O overhead. Can't do this just yet as some entries are not * contiguous. Do this in parallel only or in serial as well? * * - Create MPI type for dirty objects when flushing in parallel. * * - Now that TBBT routines aren't used, fix nodes in memory to * point directly to the skip list node from the LRU list, eliminating * skip list lookups when evicting objects from the cache. * * Tests: * * - Trim execution time. * * - Add random tests. * **************************************************************************/ #define H5F_PACKAGE /*suppress error about including H5Fpkg */ #include "H5private.h" /* Generic Functions */ #include "H5Cprivate.h" /* Cache */ #include "H5Dprivate.h" /* Dataset functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* Files */ #include "H5FDprivate.h" /* File drivers */ #include "H5FLprivate.h" /* Free Lists */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Pprivate.h" /* Property lists */ #include "H5SLprivate.h" /* Skip lists */ /**************************************************************************** * * We maintain doubly linked lists of instances of H5C_cache_entry_t for a * variety of reasons -- protected list, LRU list, and the clean and dirty * LRU lists at present. The following macros support linking and unlinking * of instances of H5C_cache_entry_t by both their regular and auxilary next * and previous pointers. * * The size and length fields are also maintained. * * Note that the relevant pair of prev and next pointers are presumed to be * NULL on entry in the insertion macros. * * Finally, observe that the sanity checking macros evaluate to the empty * string when H5C_DO_SANITY_CHECKS is FALSE. They also contain calls * to the HGOTO_ERROR macro, which may not be appropriate in all cases. * If so, we will need versions of the insertion and deletion macros which * do not reference the sanity checking macros. * JRM - 5/5/04 * ****************************************************************************/ #if H5C_DO_SANITY_CHECKS #define H5C__DLL_PRE_REMOVE_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ if ( ( (head_ptr) == NULL ) || \ ( (tail_ptr) == NULL ) || \ ( (entry_ptr) == NULL ) || \ ( (len) <= 0 ) || \ ( (Size) < (entry_ptr)->size ) || \ ( ( (Size) == (entry_ptr)->size ) && ( (len) != 1 ) ) || \ ( ( (entry_ptr)->prev == NULL ) && ( (head_ptr) != (entry_ptr) ) ) || \ ( ( (entry_ptr)->next == NULL ) && ( (tail_ptr) != (entry_ptr) ) ) || \ ( ( (len) == 1 ) && \ ( ! ( ( (head_ptr) == (entry_ptr) ) && \ ( (tail_ptr) == (entry_ptr) ) && \ ( (entry_ptr)->next == NULL ) && \ ( (entry_ptr)->prev == NULL ) && \ ( (Size) == (entry_ptr)->size ) \ ) \ ) \ ) \ ) { \ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "DLL pre remove SC failed") \ } #define H5C__DLL_SC(head_ptr, tail_ptr, len, Size, fv) \ if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ ( (head_ptr) != (tail_ptr) ) \ ) || \ ( (len) < 0 ) || \ ( (Size) < 0 ) || \ ( ( (len) == 1 ) && \ ( ( (head_ptr) != (tail_ptr) ) || ( (cache_ptr)->size <= 0 ) || \ ( (head_ptr) == NULL ) || ( (head_ptr)->size != (Size) ) \ ) \ ) || \ ( ( (len) >= 1 ) && \ ( ( (head_ptr) == NULL ) || ( (head_ptr)->prev != NULL ) || \ ( (tail_ptr) == NULL ) || ( (tail_ptr)->next != NULL ) \ ) \ ) \ ) { \ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "DLL sanity check failed") \ } #define H5C__DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ if ( ( (entry_ptr) == NULL ) || \ ( (entry_ptr)->next != NULL ) || \ ( (entry_ptr)->prev != NULL ) || \ ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ ( (head_ptr) != (tail_ptr) ) \ ) || \ ( (len) < 0 ) || \ ( ( (len) == 1 ) && \ ( ( (head_ptr) != (tail_ptr) ) || ( (Size) <= 0 ) || \ ( (head_ptr) == NULL ) || ( (head_ptr)->size != (Size) ) \ ) \ ) || \ ( ( (len) >= 1 ) && \ ( ( (head_ptr) == NULL ) || ( (head_ptr)->prev != NULL ) || \ ( (tail_ptr) == NULL ) || ( (tail_ptr)->next != NULL ) \ ) \ ) \ ) { \ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "DLL pre insert SC failed") \ } #else /* H5C_DO_SANITY_CHECKS */ #define H5C__DLL_PRE_REMOVE_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fv) #define H5C__DLL_SC(head_ptr, tail_ptr, len, Size, fv) #define H5C__DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fv) #endif /* H5C_DO_SANITY_CHECKS */ #define H5C__DLL_APPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ H5C__DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, \ fail_val) \ if ( (head_ptr) == NULL ) \ { \ (head_ptr) = (entry_ptr); \ (tail_ptr) = (entry_ptr); \ } \ else \ { \ (tail_ptr)->next = (entry_ptr); \ (entry_ptr)->prev = (tail_ptr); \ (tail_ptr) = (entry_ptr); \ } \ (len)++; \ (Size) += (entry_ptr)->size; #define H5C__DLL_PREPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ H5C__DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, \ fail_val) \ if ( (head_ptr) == NULL ) \ { \ (head_ptr) = (entry_ptr); \ (tail_ptr) = (entry_ptr); \ } \ else \ { \ (head_ptr)->prev = (entry_ptr); \ (entry_ptr)->next = (head_ptr); \ (head_ptr) = (entry_ptr); \ } \ (len)++; \ (Size) += entry_ptr->size; #define H5C__DLL_REMOVE(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ H5C__DLL_PRE_REMOVE_SC(entry_ptr, head_ptr, tail_ptr, len, Size, \ fail_val) \ { \ if ( (head_ptr) == (entry_ptr) ) \ { \ (head_ptr) = (entry_ptr)->next; \ if ( (head_ptr) != NULL ) \ { \ (head_ptr)->prev = NULL; \ } \ } \ else \ { \ (entry_ptr)->prev->next = (entry_ptr)->next; \ } \ if ( (tail_ptr) == (entry_ptr) ) \ { \ (tail_ptr) = (entry_ptr)->prev; \ if ( (tail_ptr) != NULL ) \ { \ (tail_ptr)->next = NULL; \ } \ } \ else \ { \ (entry_ptr)->next->prev = (entry_ptr)->prev; \ } \ entry_ptr->next = NULL; \ entry_ptr->prev = NULL; \ (len)--; \ (Size) -= entry_ptr->size; \ } #if H5C_DO_SANITY_CHECKS #define H5C__AUX_DLL_PRE_REMOVE_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv) \ if ( ( (hd_ptr) == NULL ) || \ ( (tail_ptr) == NULL ) || \ ( (entry_ptr) == NULL ) || \ ( (len) <= 0 ) || \ ( (Size) < (entry_ptr)->size ) || \ ( ( (Size) == (entry_ptr)->size ) && ( ! ( (len) == 1 ) ) ) || \ ( ( (entry_ptr)->aux_prev == NULL ) && ( (hd_ptr) != (entry_ptr) ) ) || \ ( ( (entry_ptr)->aux_next == NULL ) && ( (tail_ptr) != (entry_ptr) ) ) || \ ( ( (len) == 1 ) && \ ( ! ( ( (hd_ptr) == (entry_ptr) ) && ( (tail_ptr) == (entry_ptr) ) && \ ( (entry_ptr)->aux_next == NULL ) && \ ( (entry_ptr)->aux_prev == NULL ) && \ ( (Size) == (entry_ptr)->size ) \ ) \ ) \ ) \ ) { \ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "aux DLL pre remove SC failed") \ } #define H5C__AUX_DLL_SC(head_ptr, tail_ptr, len, Size, fv) \ if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ ( (head_ptr) != (tail_ptr) ) \ ) || \ ( (len) < 0 ) || \ ( (Size) < 0 ) || \ ( ( (len) == 1 ) && \ ( ( (head_ptr) != (tail_ptr) ) || ( (Size) <= 0 ) || \ ( (head_ptr) == NULL ) || ( (head_ptr)->size != (Size) ) \ ) \ ) || \ ( ( (len) >= 1 ) && \ ( ( (head_ptr) == NULL ) || ( (head_ptr)->aux_prev != NULL ) || \ ( (tail_ptr) == NULL ) || ( (tail_ptr)->aux_next != NULL ) \ ) \ ) \ ) { \ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "AUX DLL sanity check failed") \ } #define H5C__AUX_DLL_PRE_INSERT_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv) \ if ( ( (entry_ptr) == NULL ) || \ ( (entry_ptr)->aux_next != NULL ) || \ ( (entry_ptr)->aux_prev != NULL ) || \ ( ( ( (hd_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ ( (hd_ptr) != (tail_ptr) ) \ ) || \ ( (len) < 0 ) || \ ( ( (len) == 1 ) && \ ( ( (hd_ptr) != (tail_ptr) ) || ( (Size) <= 0 ) || \ ( (hd_ptr) == NULL ) || ( (hd_ptr)->size != (Size) ) \ ) \ ) || \ ( ( (len) >= 1 ) && \ ( ( (hd_ptr) == NULL ) || ( (hd_ptr)->aux_prev != NULL ) || \ ( (tail_ptr) == NULL ) || ( (tail_ptr)->aux_next != NULL ) \ ) \ ) \ ) { \ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "AUX DLL pre insert SC failed") \ } #else /* H5C_DO_SANITY_CHECKS */ #define H5C__AUX_DLL_PRE_REMOVE_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv) #define H5C__AUX_DLL_SC(head_ptr, tail_ptr, len, Size, fv) #define H5C__AUX_DLL_PRE_INSERT_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv) #endif /* H5C_DO_SANITY_CHECKS */ #define H5C__AUX_DLL_APPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val)\ H5C__AUX_DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, \ fail_val) \ if ( (head_ptr) == NULL ) \ { \ (head_ptr) = (entry_ptr); \ (tail_ptr) = (entry_ptr); \ } \ else \ { \ (tail_ptr)->aux_next = (entry_ptr); \ (entry_ptr)->aux_prev = (tail_ptr); \ (tail_ptr) = (entry_ptr); \ } \ (len)++; \ (Size) += entry_ptr->size; #define H5C__AUX_DLL_PREPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ H5C__AUX_DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, \ fv) \ if ( (head_ptr) == NULL ) \ { \ (head_ptr) = (entry_ptr); \ (tail_ptr) = (entry_ptr); \ } \ else \ { \ (head_ptr)->aux_prev = (entry_ptr); \ (entry_ptr)->aux_next = (head_ptr); \ (head_ptr) = (entry_ptr); \ } \ (len)++; \ (Size) += entry_ptr->size; #define H5C__AUX_DLL_REMOVE(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ H5C__AUX_DLL_PRE_REMOVE_SC(entry_ptr, head_ptr, tail_ptr, len, Size, \ fv) \ { \ if ( (head_ptr) == (entry_ptr) ) \ { \ (head_ptr) = (entry_ptr)->aux_next; \ if ( (head_ptr) != NULL ) \ { \ (head_ptr)->aux_prev = NULL; \ } \ } \ else \ { \ (entry_ptr)->aux_prev->aux_next = (entry_ptr)->aux_next; \ } \ if ( (tail_ptr) == (entry_ptr) ) \ { \ (tail_ptr) = (entry_ptr)->aux_prev; \ if ( (tail_ptr) != NULL ) \ { \ (tail_ptr)->aux_next = NULL; \ } \ } \ else \ { \ (entry_ptr)->aux_next->aux_prev = (entry_ptr)->aux_prev; \ } \ entry_ptr->aux_next = NULL; \ entry_ptr->aux_prev = NULL; \ (len)--; \ (Size) -= entry_ptr->size; \ } /*********************************************************************** * * Stats collection macros * * The following macros must handle stats collection when this collection * is enabled, and evaluate to the empty string when it is not. * ***********************************************************************/ #if H5C_COLLECT_CACHE_STATS #define H5C__UPDATE_STATS_FOR_INSERTION(cache_ptr, entry_ptr) \ (((cache_ptr)->insertions)[(entry_ptr)->type->id])++; \ if ( (cache_ptr)->index_len > (cache_ptr)->max_index_len ) \ (cache_ptr)->max_index_len = (cache_ptr)->index_len; \ if ( (cache_ptr)->index_size > (cache_ptr)->max_index_size ) \ (cache_ptr)->max_index_size = (cache_ptr)->index_size; \ if ( (cache_ptr)->slist_len > (cache_ptr)->max_slist_len ) \ (cache_ptr)->max_slist_len = (cache_ptr)->slist_len; \ if ( (cache_ptr)->slist_size > (cache_ptr)->max_slist_size ) \ (cache_ptr)->max_slist_size = (cache_ptr)->slist_size; \ if ( (entry_ptr)->size > \ ((cache_ptr)->max_size)[(entry_ptr)->type->id] ) { \ ((cache_ptr)->max_size)[(entry_ptr)->type->id] \ = (entry_ptr)->size; \ } #define H5C__UPDATE_STATS_FOR_UNPROTECT(cache_ptr) \ if ( (cache_ptr)->slist_len > (cache_ptr)->max_slist_len ) \ (cache_ptr)->max_slist_len = (cache_ptr)->slist_len; \ if ( (cache_ptr)->slist_size > (cache_ptr)->max_slist_size ) \ (cache_ptr)->max_slist_size = (cache_ptr)->slist_size; #define H5C__UPDATE_STATS_FOR_RENAME(cache_ptr, entry_ptr) \ (((cache_ptr)->renames)[(entry_ptr)->type->id])++; #define H5C__UPDATE_STATS_FOR_HT_INSERTION(cache_ptr) \ (cache_ptr)->total_ht_insertions++; #define H5C__UPDATE_STATS_FOR_HT_DELETION(cache_ptr) \ (cache_ptr)->total_ht_deletions++; #define H5C__UPDATE_STATS_FOR_HT_SEARCH(cache_ptr, success, depth) \ if ( success ) { \ (cache_ptr)->successful_ht_searches++; \ (cache_ptr)->total_successful_ht_search_depth += depth; \ } else { \ (cache_ptr)->failed_ht_searches++; \ (cache_ptr)->total_failed_ht_search_depth += depth; \ } #if H5C_COLLECT_CACHE_ENTRY_STATS #define H5C__RESET_CACHE_ENTRY_STATS(entry_ptr) \ (entry_ptr)->accesses = 0; \ (entry_ptr)->clears = 0; \ (entry_ptr)->flushes = 0; #define H5C__UPDATE_STATS_FOR_CLEAR(cache_ptr, entry_ptr) \ (((cache_ptr)->clears)[(entry_ptr)->type->id])++; \ ((entry_ptr)->clears)++; #define H5C__UPDATE_STATS_FOR_FLUSH(cache_ptr, entry_ptr) \ (((cache_ptr)->flushes)[(entry_ptr)->type->id])++; \ ((entry_ptr)->flushes)++; #define H5C__UPDATE_STATS_FOR_EVICTION(cache_ptr, entry_ptr) \ (((cache_ptr)->evictions)[(entry_ptr)->type->id])++; \ if ( (entry_ptr)->accesses > \ ((cache_ptr)->max_accesses)[(entry_ptr)->type->id] ) { \ ((cache_ptr)->max_accesses)[(entry_ptr)->type->id] \ = (entry_ptr)->accesses; \ } \ if ( (entry_ptr)->accesses < \ ((cache_ptr)->min_accesses)[(entry_ptr)->type->id] ) { \ ((cache_ptr)->min_accesses)[(entry_ptr)->type->id] \ = (entry_ptr)->accesses; \ } \ if ( (entry_ptr)->clears > \ ((cache_ptr)->max_clears)[(entry_ptr)->type->id] ) { \ ((cache_ptr)->max_clears)[(entry_ptr)->type->id] \ = (entry_ptr)->clears; \ } \ if ( (entry_ptr)->flushes > \ ((cache_ptr)->max_flushes)[(entry_ptr)->type->id] ) { \ ((cache_ptr)->max_flushes)[(entry_ptr)->type->id] \ = (entry_ptr)->flushes; \ } \ if ( (entry_ptr)->size > \ ((cache_ptr)->max_size)[(entry_ptr)->type->id] ) { \ ((cache_ptr)->max_size)[(entry_ptr)->type->id] \ = (entry_ptr)->size; \ } \ #define H5C__UPDATE_STATS_FOR_PROTECT(cache_ptr, entry_ptr, hit) \ if ( hit ) \ ((cache_ptr)->hits)[(entry_ptr)->type->id]++; \ else \ ((cache_ptr)->misses)[(entry_ptr)->type->id]++; \ if ( (cache_ptr)->index_len > (cache_ptr)->max_index_len ) \ (cache_ptr)->max_index_len = (cache_ptr)->index_len; \ if ( (cache_ptr)->index_size > (cache_ptr)->max_index_size ) \ (cache_ptr)->max_index_size = (cache_ptr)->index_size; \ if ( (cache_ptr)->pl_len > (cache_ptr)->max_pl_len ) \ (cache_ptr)->max_pl_len = (cache_ptr)->pl_len; \ if ( (cache_ptr)->pl_size > (cache_ptr)->max_pl_size ) \ (cache_ptr)->max_pl_size = (cache_ptr)->pl_size; \ if ( (entry_ptr)->size > \ ((cache_ptr)->max_size)[(entry_ptr)->type->id] ) { \ ((cache_ptr)->max_size)[(entry_ptr)->type->id] \ = (entry_ptr)->size; \ } \ ((entry_ptr)->accesses)++; #else /* H5C_COLLECT_CACHE_ENTRY_STATS */ #define H5C__RESET_CACHE_ENTRY_STATS(entry_ptr) #define H5C__UPDATE_STATS_FOR_CLEAR(cache_ptr, entry_ptr) \ (((cache_ptr)->clears)[(entry_ptr)->type->id])++; #define H5C__UPDATE_STATS_FOR_FLUSH(cache_ptr, entry_ptr) \ (((cache_ptr)->flushes)[(entry_ptr)->type->id])++; #define H5C__UPDATE_STATS_FOR_EVICTION(cache_ptr, entry_ptr) \ (((cache_ptr)->evictions)[(entry_ptr)->type->id])++; #define H5C__UPDATE_STATS_FOR_PROTECT(cache_ptr, entry_ptr, hit) \ if ( hit ) \ ((cache_ptr)->hits)[(entry_ptr)->type->id]++; \ else \ ((cache_ptr)->misses)[(entry_ptr)->type->id]++; \ if ( (cache_ptr)->index_len > (cache_ptr)->max_index_len ) \ (cache_ptr)->max_index_len = (cache_ptr)->index_len; \ if ( (cache_ptr)->index_size > (cache_ptr)->max_index_size ) \ (cache_ptr)->max_index_size = (cache_ptr)->index_size; \ if ( (cache_ptr)->pl_len > (cache_ptr)->max_pl_len ) \ (cache_ptr)->max_pl_len = (cache_ptr)->pl_len; \ if ( (cache_ptr)->pl_size > (cache_ptr)->max_pl_size ) \ (cache_ptr)->max_pl_size = (cache_ptr)->pl_size; #endif /* H5C_COLLECT_CACHE_ENTRY_STATS */ #else /* H5C_COLLECT_CACHE_STATS */ #define H5C__RESET_CACHE_ENTRY_STATS(entry_ptr) #define H5C__UPDATE_STATS_FOR_UNPROTECT(cache_ptr) #define H5C__UPDATE_STATS_FOR_RENAME(cache_ptr, entry_ptr) #define H5C__UPDATE_STATS_FOR_HT_INSERTION(cache_ptr) #define H5C__UPDATE_STATS_FOR_HT_DELETION(cache_ptr) #define H5C__UPDATE_STATS_FOR_HT_SEARCH(cache_ptr, success, depth) #define H5C__UPDATE_STATS_FOR_INSERTION(cache_ptr, entry_ptr) #define H5C__UPDATE_STATS_FOR_CLEAR(cache_ptr, entry_ptr) #define H5C__UPDATE_STATS_FOR_FLUSH(cache_ptr, entry_ptr) #define H5C__UPDATE_STATS_FOR_EVICTION(cache_ptr, entry_ptr) #define H5C__UPDATE_STATS_FOR_PROTECT(cache_ptr, entry_ptr, hit) #endif /* H5C_COLLECT_CACHE_STATS */ /*********************************************************************** * * Hash table access and manipulation macros: * * The following macros handle searches, insertions, and deletion in * the hash table. * * When modifying these macros, remember to modify the similar macros * in tst/cache.c * ***********************************************************************/ #define H5C__HASH_TABLE_LEN (32 * 1024) /* must be a power of 2 */ #define H5C__HASH_MASK ((size_t)(H5C__HASH_TABLE_LEN - 1) << 3) #define H5C__HASH_FCN(x) (int)(((x) & H5C__HASH_MASK) >> 3) #if H5C_DO_SANITY_CHECKS #define H5C__PRE_HT_INSERT_SC(cache_ptr, entry_ptr, fail_val) \ if ( ( (cache_ptr) == NULL ) || \ ( (cache_ptr)->magic != H5C__H5C_T_MAGIC ) || \ ( (entry_ptr) == NULL ) || \ ( ! H5F_addr_defined((entry_ptr)->addr) ) || \ ( (entry_ptr)->ht_next != NULL ) || \ ( (entry_ptr)->ht_prev != NULL ) || \ ( (entry_ptr)->size <= 0 ) || \ ( (k = H5C__HASH_FCN((entry_ptr)->addr)) < 0 ) || \ ( k >= H5C__HASH_TABLE_LEN ) ) { \ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, fail_val, \ "Pre HT insert SC failed") \ } #define H5C__PRE_HT_REMOVE_SC(cache_ptr, entry_ptr) \ if ( ( (cache_ptr) == NULL ) || \ ( (cache_ptr)->magic != H5C__H5C_T_MAGIC ) || \ ( (cache_ptr)->index_len < 1 ) || \ ( (entry_ptr) == NULL ) || \ ( (cache_ptr)->index_size < (entry_ptr)->size ) || \ ( ! H5F_addr_defined((entry_ptr)->addr) ) || \ ( (entry_ptr)->size <= 0 ) || \ ( H5C__HASH_FCN((entry_ptr)->addr) < 0 ) || \ ( H5C__HASH_FCN((entry_ptr)->addr) >= H5C__HASH_TABLE_LEN ) || \ ( ((cache_ptr)->index)[(H5C__HASH_FCN((entry_ptr)->addr))] \ == NULL ) || \ ( ( ((cache_ptr)->index)[(H5C__HASH_FCN((entry_ptr)->addr))] \ != (entry_ptr) ) && \ ( (entry_ptr)->ht_prev == NULL ) ) || \ ( ( ((cache_ptr)->index)[(H5C__HASH_FCN((entry_ptr)->addr))] == \ (entry_ptr) ) && \ ( (entry_ptr)->ht_prev != NULL ) ) ) { \ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Pre HT remove SC failed") \ } #define H5C__PRE_HT_SEARCH_SC(cache_ptr, Addr, fail_val) \ if ( ( (cache_ptr) == NULL ) || \ ( (cache_ptr)->magic != H5C__H5C_T_MAGIC ) || \ ( ! H5F_addr_defined(Addr) ) || \ ( H5C__HASH_FCN(Addr) < 0 ) || \ ( H5C__HASH_FCN(Addr) >= H5C__HASH_TABLE_LEN ) ) { \ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, fail_val, "Pre HT search SC failed") \ } #define H5C__POST_SUC_HT_SEARCH_SC(cache_ptr, entry_ptr, Addr, k, fail_val) \ if ( ( (cache_ptr) == NULL ) || \ ( (cache_ptr)->magic != H5C__H5C_T_MAGIC ) || \ ( (cache_ptr)->index_len < 1 ) || \ ( (entry_ptr) == NULL ) || \ ( (cache_ptr)->index_size < (entry_ptr)->size ) || \ ( H5F_addr_ne((entry_ptr)->addr, (Addr)) ) || \ ( (entry_ptr)->size <= 0 ) || \ ( ((cache_ptr)->index)[k] == NULL ) || \ ( ( ((cache_ptr)->index)[k] != (entry_ptr) ) && \ ( (entry_ptr)->ht_prev == NULL ) ) || \ ( ( ((cache_ptr)->index)[k] == (entry_ptr) ) && \ ( (entry_ptr)->ht_prev != NULL ) ) || \ ( ( (entry_ptr)->ht_prev != NULL ) && \ ( (entry_ptr)->ht_prev->ht_next != (entry_ptr) ) ) || \ ( ( (entry_ptr)->ht_next != NULL ) && \ ( (entry_ptr)->ht_next->ht_prev != (entry_ptr) ) ) ) { \ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, fail_val, \ "Post successful HT search SC failed") \ } #define H5C__POST_HT_SHIFT_TO_FRONT(cache_ptr, entry_ptr, k, fail_val) \ if ( ( (cache_ptr) == NULL ) || \ ( ((cache_ptr)->index)[k] != (entry_ptr) ) || \ ( (entry_ptr)->ht_prev != NULL ) ) { \ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, fail_val, \ "Post HT shift to front SC failed") \ } #else /* H5C_DO_SANITY_CHECKS */ #define H5C__PRE_HT_INSERT_SC(cache_ptr, entry_ptr, fail_val) #define H5C__PRE_HT_REMOVE_SC(cache_ptr, entry_ptr) #define H5C__PRE_HT_SEARCH_SC(cache_ptr, Addr, fail_val) #define H5C__POST_SUC_HT_SEARCH_SC(cache_ptr, entry_ptr, Addr, k, fail_val) #define H5C__POST_HT_SHIFT_TO_FRONT(cache_ptr, entry_ptr, k, fail_val) #endif /* H5C_DO_SANITY_CHECKS */ #define H5C__INSERT_IN_INDEX(cache_ptr, entry_ptr, fail_val) \ { \ int k; \ H5C__PRE_HT_INSERT_SC(cache_ptr, entry_ptr, fail_val) \ k = H5C__HASH_FCN((entry_ptr)->addr); \ if ( ((cache_ptr)->index)[k] == NULL ) \ { \ ((cache_ptr)->index)[k] = (entry_ptr); \ } \ else \ { \ (entry_ptr)->ht_next = ((cache_ptr)->index)[k]; \ (entry_ptr)->ht_next->ht_prev = (entry_ptr); \ ((cache_ptr)->index)[k] = (entry_ptr); \ } \ (cache_ptr)->index_len++; \ (cache_ptr)->index_size += (entry_ptr)->size; \ H5C__UPDATE_STATS_FOR_HT_INSERTION(cache_ptr) \ } #define H5C__DELETE_FROM_INDEX(cache_ptr, entry_ptr) \ { \ int k; \ H5C__PRE_HT_REMOVE_SC(cache_ptr, entry_ptr) \ k = H5C__HASH_FCN((entry_ptr)->addr); \ if ( (entry_ptr)->ht_next ) \ { \ (entry_ptr)->ht_next->ht_prev = (entry_ptr)->ht_prev; \ } \ if ( (entry_ptr)->ht_prev ) \ { \ (entry_ptr)->ht_prev->ht_next = (entry_ptr)->ht_next; \ } \ if ( ((cache_ptr)->index)[k] == (entry_ptr) ) \ { \ ((cache_ptr)->index)[k] = (entry_ptr)->ht_next; \ } \ (entry_ptr)->ht_next = NULL; \ (entry_ptr)->ht_prev = NULL; \ (cache_ptr)->index_len--; \ (cache_ptr)->index_size -= (entry_ptr)->size; \ H5C__UPDATE_STATS_FOR_HT_DELETION(cache_ptr) \ } #define H5C__SEARCH_INDEX(cache_ptr, Addr, entry_ptr, fail_val) \ { \ int k; \ int depth = 0; \ H5C__PRE_HT_SEARCH_SC(cache_ptr, Addr, fail_val) \ k = H5C__HASH_FCN(Addr); \ entry_ptr = ((cache_ptr)->index)[k]; \ while ( ( entry_ptr ) && ( H5F_addr_ne(Addr, (entry_ptr)->addr) ) ) \ { \ (entry_ptr) = (entry_ptr)->ht_next; \ (depth)++; \ } \ if ( entry_ptr ) \ { \ H5C__POST_SUC_HT_SEARCH_SC(cache_ptr, entry_ptr, Addr, k, fail_val) \ if ( entry_ptr != ((cache_ptr)->index)[k] ) \ { \ if ( (entry_ptr)->ht_next ) \ { \ (entry_ptr)->ht_next->ht_prev = (entry_ptr)->ht_prev; \ } \ HDassert( (entry_ptr)->ht_prev != NULL ); \ (entry_ptr)->ht_prev->ht_next = (entry_ptr)->ht_next; \ ((cache_ptr)->index)[k]->ht_prev = (entry_ptr); \ (entry_ptr)->ht_next = ((cache_ptr)->index)[k]; \ (entry_ptr)->ht_prev = NULL; \ ((cache_ptr)->index)[k] = (entry_ptr); \ H5C__POST_HT_SHIFT_TO_FRONT(cache_ptr, entry_ptr, k, fail_val) \ } \ } \ H5C__UPDATE_STATS_FOR_HT_SEARCH(cache_ptr, (entry_ptr != NULL), depth) \ } /************************************************************************** * * Skip list insertion and deletion macros: * * These used to be functions, but I converted them to macros to avoid some * function call overhead. * **************************************************************************/ /*------------------------------------------------------------------------- * * Macro: H5C__INSERT_ENTRY_IN_SLIST * * Purpose: Insert the specified instance of H5C_cache_entry_t into * the skip list in the specified instance of H5C_t. Update * the associated length and size fields. * * Return: N/A * * Programmer: John Mainzer, 5/10/04 * * Modifications: * * JRM -- 7/21/04 * Updated function to set the in_tree flag when inserting * an entry into the tree. Also modified the function to * update the tree size and len fields instead of the similar * index fields. * * All of this is part of the modifications to support the * hash table. * * JRM -- 7/27/04 * Converted the function H5C_insert_entry_in_tree() into * the macro H5C__INSERT_ENTRY_IN_TREE in the hopes of * wringing a little more speed out of the cache. * * Note that we don't bother to check if the entry is already * in the tree -- if it is, H5SL_insert() will fail. * * QAK -- 11/27/04 * Switched over to using skip list routines. * *------------------------------------------------------------------------- */ #define H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr) \ { \ HDassert( (cache_ptr) ); \ HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ HDassert( (entry_ptr) ); \ HDassert( (entry_ptr)->size > 0 ); \ HDassert( H5F_addr_defined((entry_ptr)->addr) ); \ HDassert( !((entry_ptr)->in_slist) ); \ \ if ( H5SL_insert((cache_ptr)->slist_ptr, &entry_ptr->addr, entry_ptr) < 0 ) \ HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Can't insert entry in skip list") \ \ (entry_ptr)->in_slist = TRUE; \ (cache_ptr)->slist_len++; \ (cache_ptr)->slist_size += (entry_ptr)->size; \ \ HDassert( (cache_ptr)->slist_len > 0 ); \ HDassert( (cache_ptr)->slist_size > 0 ); \ \ } /* H5C__INSERT_ENTRY_IN_SLIST */ /*------------------------------------------------------------------------- * * Function: H5C__REMOVE_ENTRY_FROM_SLIST * * Purpose: Remove the specified instance of H5C_cache_entry_t from the * index skip list in the specified instance of H5C_t. Update * the associated length and size fields. * * Return: N/A * * Programmer: John Mainzer, 5/10/04 * * Modifications: * * JRM -- 7/21/04 * Updated function for the addition of the hash table. * * JRM - 7/27/04 * Converted from the function H5C_remove_entry_from_tree() * to the macro H5C__REMOVE_ENTRY_FROM_TREE in the hopes of * wringing a little more performance out of the cache. * * QAK -- 11/27/04 * Switched over to using skip list routines. * *------------------------------------------------------------------------- */ #define H5C__REMOVE_ENTRY_FROM_SLIST(cache_ptr, entry_ptr) \ { \ HDassert( (cache_ptr) ); \ HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ HDassert( (entry_ptr) ); \ HDassert( !((entry_ptr)->is_protected) ); \ HDassert( (entry_ptr)->size > 0 ); \ HDassert( (entry_ptr)->in_slist ); \ HDassert( (cache_ptr)->slist_ptr ); \ \ if ( H5SL_remove((cache_ptr)->slist_ptr, &(entry_ptr)->addr) \ != (entry_ptr) ) \ \ HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, \ "Can't delete entry from skip list.") \ \ HDassert( (cache_ptr)->slist_len > 0 ); \ (cache_ptr)->slist_len--; \ HDassert( (cache_ptr)->slist_size >= (entry_ptr)->size ); \ (cache_ptr)->slist_size -= (entry_ptr)->size; \ (entry_ptr)->in_slist = FALSE; \ } /* H5C__REMOVE_ENTRY_FROM_SLIST */ /************************************************************************** * * Replacement policy update macros: * * These used to be functions, but I converted them to macros to avoid some * function call overhead. * **************************************************************************/ /*------------------------------------------------------------------------- * * Macro: H5C__UPDATE_RP_FOR_EVICTION * * Purpose: Update the replacement policy data structures for an * eviction of the specified cache entry. * * At present, we only support the modified LRU policy, so * this function deals with that case unconditionally. If * we ever support other replacement policies, the function * should switch on the current policy and act accordingly. * * Return: Non-negative on success/Negative on failure. * * Programmer: John Mainzer, 5/10/04 * * Modifications: * * JRM - 7/27/04 * Converted the function H5C_update_rp_for_eviction() to the * macro H5C__UPDATE_RP_FOR_EVICTION in an effort to squeeze * a bit more performance out of the cache. * * At least for the first cut, I am leaving the comments and * white space in the macro. If they cause dificulties with * the pre-processor, I'll have to remove them. * * JRM - 7/28/04 * Split macro into two version, one supporting the clean and * dirty LRU lists, and the other not. Yet another attempt * at optimization. * *------------------------------------------------------------------------- */ #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS #define H5C__UPDATE_RP_FOR_EVICTION(cache_ptr, entry_ptr, fail_val) \ { \ HDassert( (cache_ptr) ); \ HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ HDassert( (entry_ptr) ); \ HDassert( !((entry_ptr)->is_protected) ); \ HDassert( (entry_ptr)->size > 0 ); \ \ /* modified LRU specific code */ \ \ /* remove the entry from the LRU list. */ \ \ H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ /* If the entry is clean when it is evicted, it should be on the \ * clean LRU list, if it was dirty, it should be on the dirty LRU list. \ * Remove it from the appropriate list according to the value of the \ * dirty flag. \ */ \ \ if ( (entry_ptr)->is_dirty ) { \ \ H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->dLRU_head_ptr, \ (cache_ptr)->dLRU_tail_ptr, \ (cache_ptr)->dLRU_list_len, \ (cache_ptr)->dLRU_list_size, (fail_val)) \ } else { \ H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->cLRU_head_ptr, \ (cache_ptr)->cLRU_tail_ptr, \ (cache_ptr)->cLRU_list_len, \ (cache_ptr)->cLRU_list_size, (fail_val)) \ } \ \ } /* H5C__UPDATE_RP_FOR_EVICTION */ #else /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ #define H5C__UPDATE_RP_FOR_EVICTION(cache_ptr, entry_ptr, fail_val) \ { \ HDassert( (cache_ptr) ); \ HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ HDassert( (entry_ptr) ); \ HDassert( !((entry_ptr)->is_protected) ); \ HDassert( (entry_ptr)->size > 0 ); \ \ /* modified LRU specific code */ \ \ /* remove the entry from the LRU list. */ \ \ H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ } /* H5C__UPDATE_RP_FOR_EVICTION */ #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ /*------------------------------------------------------------------------- * * Macro: H5C__UPDATE_RP_FOR_FLUSH * * Purpose: Update the replacement policy data structures for a flush * of the specified cache entry. * * At present, we only support the modified LRU policy, so * this function deals with that case unconditionally. If * we ever support other replacement policies, the function * should switch on the current policy and act accordingly. * * Return: N/A * * Programmer: John Mainzer, 5/6/04 * * Modifications: * * JRM - 7/27/04 * Converted the function H5C_update_rp_for_flush() to the * macro H5C__UPDATE_RP_FOR_FLUSH in an effort to squeeze * a bit more performance out of the cache. * * At least for the first cut, I am leaving the comments and * white space in the macro. If they cause dificulties with * pre-processor, I'll have to remove them. * * JRM - 7/28/04 * Split macro into two version, one supporting the clean and * dirty LRU lists, and the other not. Yet another attempt * at optimization. * *------------------------------------------------------------------------- */ #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS #define H5C__UPDATE_RP_FOR_FLUSH(cache_ptr, entry_ptr, fail_val) \ { \ HDassert( (cache_ptr) ); \ HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ HDassert( (entry_ptr) ); \ HDassert( !((entry_ptr)->is_protected) ); \ HDassert( (entry_ptr)->size > 0 ); \ \ /* modified LRU specific code */ \ \ /* remove the entry from the LRU list, and re-insert it at the head. */ \ \ H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ /* since the entry is being flushed or cleared, one would think that it \ * must be dirty -- but that need not be the case. Use the dirty flag \ * to infer whether the entry is on the clean or dirty LRU list, and \ * remove it. Then insert it at the head of the clean LRU list. \ * \ * The function presumes that a dirty entry will be either cleared or \ * flushed shortly, so it is OK if we put a dirty entry on the clean \ * LRU list. \ */ \ \ if ( (entry_ptr)->is_dirty ) { \ H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->dLRU_head_ptr, \ (cache_ptr)->dLRU_tail_ptr, \ (cache_ptr)->dLRU_list_len, \ (cache_ptr)->dLRU_list_size, (fail_val)) \ } else { \ H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->cLRU_head_ptr, \ (cache_ptr)->cLRU_tail_ptr, \ (cache_ptr)->cLRU_list_len, \ (cache_ptr)->cLRU_list_size, (fail_val)) \ } \ \ H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->cLRU_head_ptr, \ (cache_ptr)->cLRU_tail_ptr, \ (cache_ptr)->cLRU_list_len, \ (cache_ptr)->cLRU_list_size, (fail_val)) \ \ /* End modified LRU specific code. */ \ \ } /* H5C__UPDATE_RP_FOR_FLUSH */ #else /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ #define H5C__UPDATE_RP_FOR_FLUSH(cache_ptr, entry_ptr, fail_val) \ { \ HDassert( (cache_ptr) ); \ HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ HDassert( (entry_ptr) ); \ HDassert( !((entry_ptr)->is_protected) ); \ HDassert( (entry_ptr)->size > 0 ); \ \ /* modified LRU specific code */ \ \ /* remove the entry from the LRU list, and re-insert it at the head. */ \ \ H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ /* End modified LRU specific code. */ \ \ } /* H5C__UPDATE_RP_FOR_FLUSH */ #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ /*------------------------------------------------------------------------- * * Macro: H5C__UPDATE_RP_FOR_INSERTION * * Purpose: Update the replacement policy data structures for an * insertion of the specified cache entry. * * At present, we only support the modified LRU policy, so * this function deals with that case unconditionally. If * we ever support other replacement policies, the function * should switch on the current policy and act accordingly. * * Return: N/A * * Programmer: John Mainzer, 5/17/04 * * Modifications: * * JRM - 7/27/04 * Converted the function H5C_update_rp_for_insertion() to the * macro H5C__UPDATE_RP_FOR_INSERTION in an effort to squeeze * a bit more performance out of the cache. * * At least for the first cut, I am leaving the comments and * white space in the macro. If they cause dificulties with * pre-processor, I'll have to remove them. * * JRM - 7/28/04 * Split macro into two version, one supporting the clean and * dirty LRU lists, and the other not. Yet another attempt * at optimization. * *------------------------------------------------------------------------- */ #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS #define H5C__UPDATE_RP_FOR_INSERTION(cache_ptr, entry_ptr, fail_val) \ { \ HDassert( (cache_ptr) ); \ HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ HDassert( (entry_ptr) ); \ HDassert( !((entry_ptr)->is_protected) ); \ HDassert( (entry_ptr)->size > 0 ); \ \ /* modified LRU specific code */ \ \ /* insert the entry at the head of the LRU list. */ \ \ H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ /* insert the entry at the head of the clean or dirty LRU list as \ * appropriate. \ */ \ \ if ( entry_ptr->is_dirty ) { \ H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->dLRU_head_ptr, \ (cache_ptr)->dLRU_tail_ptr, \ (cache_ptr)->dLRU_list_len, \ (cache_ptr)->dLRU_list_size, (fail_val)) \ } else { \ H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->cLRU_head_ptr, \ (cache_ptr)->cLRU_tail_ptr, \ (cache_ptr)->cLRU_list_len, \ (cache_ptr)->cLRU_list_size, (fail_val)) \ } \ \ /* End modified LRU specific code. */ \ \ } #else /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ #define H5C__UPDATE_RP_FOR_INSERTION(cache_ptr, entry_ptr, fail_val) \ { \ HDassert( (cache_ptr) ); \ HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ HDassert( (entry_ptr) ); \ HDassert( !((entry_ptr)->is_protected) ); \ HDassert( (entry_ptr)->size > 0 ); \ \ /* modified LRU specific code */ \ \ /* insert the entry at the head of the LRU list. */ \ \ H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ /* End modified LRU specific code. */ \ \ } #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ /*------------------------------------------------------------------------- * * Macro: H5C__UPDATE_RP_FOR_PROTECT * * Purpose: Update the replacement policy data structures for a * protect of the specified cache entry. * * To do this, unlink the specified entry from any data * structures used by the replacement policy, and add the * entry to the protected list. * * At present, we only support the modified LRU policy, so * this function deals with that case unconditionally. If * we ever support other replacement policies, the function * should switch on the current policy and act accordingly. * * Return: N/A * * Programmer: John Mainzer, 5/17/04 * * Modifications: * * JRM - 7/27/04 * Converted the function H5C_update_rp_for_protect() to the * macro H5C__UPDATE_RP_FOR_PROTECT in an effort to squeeze * a bit more performance out of the cache. * * At least for the first cut, I am leaving the comments and * white space in the macro. If they cause dificulties with * pre-processor, I'll have to remove them. * * JRM - 7/28/04 * Split macro into two version, one supporting the clean and * dirty LRU lists, and the other not. Yet another attempt * at optimization. * *------------------------------------------------------------------------- */ #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS #define H5C__UPDATE_RP_FOR_PROTECT(cache_ptr, entry_ptr, fail_val) \ { \ HDassert( (cache_ptr) ); \ HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ HDassert( (entry_ptr) ); \ HDassert( !((entry_ptr)->is_protected) ); \ HDassert( (entry_ptr)->size > 0 ); \ \ /* modified LRU specific code */ \ \ /* remove the entry from the LRU list. */ \ \ H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ /* Similarly, remove the entry from the clean or dirty LRU list \ * as appropriate. \ */ \ \ if ( (entry_ptr)->is_dirty ) { \ \ H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->dLRU_head_ptr, \ (cache_ptr)->dLRU_tail_ptr, \ (cache_ptr)->dLRU_list_len, \ (cache_ptr)->dLRU_list_size, (fail_val)) \ \ } else { \ \ H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->cLRU_head_ptr, \ (cache_ptr)->cLRU_tail_ptr, \ (cache_ptr)->cLRU_list_len, \ (cache_ptr)->cLRU_list_size, (fail_val)) \ } \ \ /* End modified LRU specific code. */ \ \ /* Regardless of the replacement policy, now add the entry to the \ * protected list. \ */ \ \ H5C__DLL_APPEND((entry_ptr), (cache_ptr)->pl_head_ptr, \ (cache_ptr)->pl_tail_ptr, \ (cache_ptr)->pl_len, \ (cache_ptr)->pl_size, (fail_val)) \ } /* H5C__UPDATE_RP_FOR_PROTECT */ #else /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ #define H5C__UPDATE_RP_FOR_PROTECT(cache_ptr, entry_ptr, fail_val) \ { \ HDassert( (cache_ptr) ); \ HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ HDassert( (entry_ptr) ); \ HDassert( !((entry_ptr)->is_protected) ); \ HDassert( (entry_ptr)->size > 0 ); \ \ /* modified LRU specific code */ \ \ /* remove the entry from the LRU list. */ \ \ H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ /* End modified LRU specific code. */ \ \ /* Regardless of the replacement policy, now add the entry to the \ * protected list. \ */ \ \ H5C__DLL_APPEND((entry_ptr), (cache_ptr)->pl_head_ptr, \ (cache_ptr)->pl_tail_ptr, \ (cache_ptr)->pl_len, \ (cache_ptr)->pl_size, (fail_val)) \ } /* H5C__UPDATE_RP_FOR_PROTECT */ #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ /*------------------------------------------------------------------------- * * Macro: H5C__UPDATE_RP_FOR_RENAME * * Purpose: Update the replacement policy data structures for a * rename of the specified cache entry. * * At present, we only support the modified LRU policy, so * this function deals with that case unconditionally. If * we ever support other replacement policies, the function * should switch on the current policy and act accordingly. * * Return: N/A * * Programmer: John Mainzer, 5/17/04 * * Modifications: * * JRM - 7/27/04 * Converted the function H5C_update_rp_for_rename() to the * macro H5C__UPDATE_RP_FOR_RENAME in an effort to squeeze * a bit more performance out of the cache. * * At least for the first cut, I am leaving the comments and * white space in the macro. If they cause dificulties with * pre-processor, I'll have to remove them. * * JRM - 7/28/04 * Split macro into two version, one supporting the clean and * dirty LRU lists, and the other not. Yet another attempt * at optimization. * *------------------------------------------------------------------------- */ #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS #define H5C__UPDATE_RP_FOR_RENAME(cache_ptr, entry_ptr, fail_val) \ { \ HDassert( (cache_ptr) ); \ HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ HDassert( (entry_ptr) ); \ HDassert( !((entry_ptr)->is_protected) ); \ HDassert( (entry_ptr)->size > 0 ); \ \ /* modified LRU specific code */ \ \ /* remove the entry from the LRU list, and re-insert it at the head. */ \ \ H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ /* move the entry to the head of either the clean or dirty LRU list \ * as appropriate. \ */ \ \ if ( (entry_ptr)->is_dirty ) { \ \ H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->dLRU_head_ptr, \ (cache_ptr)->dLRU_tail_ptr, \ (cache_ptr)->dLRU_list_len, \ (cache_ptr)->dLRU_list_size, (fail_val)) \ \ H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->dLRU_head_ptr, \ (cache_ptr)->dLRU_tail_ptr, \ (cache_ptr)->dLRU_list_len, \ (cache_ptr)->dLRU_list_size, (fail_val)) \ \ } else { \ \ H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->cLRU_head_ptr, \ (cache_ptr)->cLRU_tail_ptr, \ (cache_ptr)->cLRU_list_len, \ (cache_ptr)->cLRU_list_size, (fail_val)) \ \ H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->cLRU_head_ptr, \ (cache_ptr)->cLRU_tail_ptr, \ (cache_ptr)->cLRU_list_len, \ (cache_ptr)->cLRU_list_size, (fail_val)) \ } \ \ /* End modified LRU specific code. */ \ \ } /* H5C__UPDATE_RP_FOR_RENAME */ #else /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ #define H5C__UPDATE_RP_FOR_RENAME(cache_ptr, entry_ptr, fail_val) \ { \ HDassert( (cache_ptr) ); \ HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ HDassert( (entry_ptr) ); \ HDassert( !((entry_ptr)->is_protected) ); \ HDassert( (entry_ptr)->size > 0 ); \ \ /* modified LRU specific code */ \ \ /* remove the entry from the LRU list, and re-insert it at the head. */ \ \ H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ /* End modified LRU specific code. */ \ \ } /* H5C__UPDATE_RP_FOR_RENAME */ #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ /*------------------------------------------------------------------------- * * Macro: H5C__UPDATE_RP_FOR_UNPROTECT * * Purpose: Update the replacement policy data structures for an * unprotect of the specified cache entry. * * To do this, unlink the specified entry from the protected * list, and re-insert it in the data structures used by the * current replacement policy. * * At present, we only support the modified LRU policy, so * this function deals with that case unconditionally. If * we ever support other replacement policies, the function * should switch on the current policy and act accordingly. * * Return: N/A * * Programmer: John Mainzer, 5/19/04 * * Modifications: * * JRM - 7/27/04 * Converted the function H5C_update_rp_for_unprotect() to * the macro H5C__UPDATE_RP_FOR_UNPROTECT in an effort to * squeeze a bit more performance out of the cache. * * At least for the first cut, I am leaving the comments and * white space in the macro. If they cause dificulties with * pre-processor, I'll have to remove them. * * JRM - 7/28/04 * Split macro into two version, one supporting the clean and * dirty LRU lists, and the other not. Yet another attempt * at optimization. * *------------------------------------------------------------------------- */ #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS #define H5C__UPDATE_RP_FOR_UNPROTECT(cache_ptr, entry_ptr, fail_val) \ { \ HDassert( (cache_ptr) ); \ HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ HDassert( (entry_ptr) ); \ HDassert( (entry_ptr)->is_protected); \ HDassert( (entry_ptr)->size > 0 ); \ \ /* Regardless of the replacement policy, remove the entry from the \ * protected list. \ */ \ H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->pl_head_ptr, \ (cache_ptr)->pl_tail_ptr, (cache_ptr)->pl_len, \ (cache_ptr)->pl_size, (fail_val)) \ \ /* modified LRU specific code */ \ \ /* insert the entry at the head of the LRU list. */ \ \ H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, \ (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ /* Similarly, insert the entry at the head of either the clean or \ * dirty LRU list as appropriate. \ */ \ \ if ( (entry_ptr)->is_dirty ) { \ \ H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->dLRU_head_ptr, \ (cache_ptr)->dLRU_tail_ptr, \ (cache_ptr)->dLRU_list_len, \ (cache_ptr)->dLRU_list_size, (fail_val)) \ \ } else { \ \ H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->cLRU_head_ptr, \ (cache_ptr)->cLRU_tail_ptr, \ (cache_ptr)->cLRU_list_len, \ (cache_ptr)->cLRU_list_size, (fail_val)) \ } \ \ /* End modified LRU specific code. */ \ \ } /* H5C__UPDATE_RP_FOR_UNPROTECT */ #else /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ #define H5C__UPDATE_RP_FOR_UNPROTECT(cache_ptr, entry_ptr, fail_val) \ { \ HDassert( (cache_ptr) ); \ HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ HDassert( (entry_ptr) ); \ HDassert( (entry_ptr)->is_protected); \ HDassert( (entry_ptr)->size > 0 ); \ \ /* Regardless of the replacement policy, remove the entry from the \ * protected list. \ */ \ H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->pl_head_ptr, \ (cache_ptr)->pl_tail_ptr, (cache_ptr)->pl_len, \ (cache_ptr)->pl_size, (fail_val)) \ \ /* modified LRU specific code */ \ \ /* insert the entry at the head of the LRU list. */ \ \ H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, \ (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ /* End modified LRU specific code. */ \ \ } /* H5C__UPDATE_RP_FOR_UNPROTECT */ #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ /**************************************************************************** * * structure H5C_t * * Catchall structure for all variables specific to an instance of the cache. * * While the individual fields of the structure are discussed below, the * following overview may be helpful. * * Entries in the cache are stored in an instance of H5TB_TREE, indexed on * the entry's disk address. While the H5TB_TREE is less efficient than * hash table, it keeps the entries in address sorted order. As flushes * in parallel mode are more efficient if they are issued in increasing * address order, this is a significant benefit. Also the H5TB_TREE code * was readily available, which reduced development time. * * While the cache was designed with multiple replacement policies in mind, * at present only a modified form of LRU is supported. * * JRM - 4/26/04 * * Profiling has indicated that searches in the instance of H5TB_TREE are * too expensive. To deal with this issue, I have augmented the cache * with a hash table in which all entries will be stored. Given the * advantages of flushing entries in increasing address order, the TBBT * is retained, but only dirty entries are stored in it. At least for * now, we will leave entries in the TBBT after they are flushed. * * Note that index_size and index_len now refer to the total size of * and number of entries in the hash table. * * JRM - 7/19/04 * * Note that the dirty entries are now stored in a skip list, instead of * the threaded, balanced binary tree (TBBT). * * QAK - 11/27/04 * * ********************************************* * * WARNING: A copy of H5C_t is in tst/cache.c (under the name "local_H5C_t" * to allow the test code to access the internal fields of the * cache. If you modify H5C_t, be sure to update local_H5C_t * in cache.c as well. * * ********************************************* * * magic: Unsigned 32 bit integer always set to H5C__H5C_T_MAGIC. This * field is used to validate pointers to instances of H5C_t. * * max_type_id: Integer field containing the maximum type id number assigned * to a type of entry in the cache. All type ids from 0 to * max_type_id inclusive must be defined. The names of the * types are stored in the type_name_table discussed below, and * indexed by the ids. * * type_name_table_ptr: Pointer to an array of pointer to char of length * max_type_id + 1. The strings pointed to by the entries * in the array are the names of the entry types associated * with the indexing type IDs. * * max_cache_size: Nominal maximum number of bytes that may be stored in the * cache. This value should be viewed as a soft limit, as the * cache can exceed this value under the following circumstances: * * a) All entries in the cache are protected, and the cache is * asked to insert a new entry. In this case the new entry * will be created. If this causes the cache to exceed * max_cache_size, it will do so. The cache will attempt * to reduce its size as entries are unprotected. * * b) When running in parallel mode, the cache may not be * permitted to flush a dirty entry in response to a read. * If there are no clean entries available to evict, the * cache will exceed its maximum size. Again the cache * will attempt to reduce its size to the max_cache_size * limit on the next cache write. * * min_clean_size: Nominal minimum number of clean bytes in the cache. * The cache attempts to maintain this number of bytes of * clean data so as to avoid case b) above. Again, this is * a soft limit. * * * In addition to the call back functions required for each entry, the * cache requires the following call back functions for this instance of * the cache as a whole: * * check_write_permitted: In certain applications, the cache may not * be allowed to write to disk at certain time. If specified, * the check_write_permitted function is used to determine if * a write is permissible at any given point in time. * * If no such function is specified (i.e. this field is NULL), * the cache will presume that writes are always permissable. * * * The cache requires an index to facilitate searching for entries. The * following fields support that index. * * index_len: Number of entries currently in the hash table used to index * the cache. * * index_size: Number of bytes of cache entries currently stored in the * hash table used to index the cache. * * This value should not be mistaken for footprint of the * cache in memory. The average cache entry is small, and * the cache has a considerable overhead. Multiplying the * index_size by two should yield a conservative estimate * of the cache's memory footprint. * * index: Array of pointer to H5C_cache_entry_t of size * H5C__HASH_TABLE_LEN. At present, this value is a power * of two, not the usual prime number. * * I hope that the variable size of cache elements, the large * hash table size, and the way in which HDF5 allocates space * will combine to avoid problems with periodicity. If so, we * can use a trivial hash function (a bit-and and a 3 bit left * shift) with some small savings. * * If not, it will become evident in the statistics. Changing * to the usual prime number length hash table will require * changing the H5C__HASH_FCN macro and the deletion of the * H5C__HASH_MASK #define. No other changes should be required. * * * When we flush the cache, we need to write entries out in increasing * address order. An instance of a skip list is used to store dirty entries in * sorted order. Whether it is cheaper to sort the dirty entries as needed, * or to maintain the list is an open question. At a guess, it depends * on how frequently the cache is flushed. We will see how it goes. * * For now at least, I will not remove dirty entries from the list as they * are flushed. * * slist_len: Number of entries currently in the skip list * used to maintain a sorted list of dirty entries in the * cache. * * slist_size: Number of bytes of cache entries currently stored in the * skip list used to maintain a sorted list of * dirty entries in the cache. * * slist_ptr: pointer to the instance of H5SL_t used maintain a sorted * list of dirty entries in the cache. This sorted list has * two uses: * * a) It allows us to flush dirty entries in increasing address * order, which results in significant savings. * * b) It facilitates checking for adjacent dirty entries when * attempting to evict entries from the cache. While we * don't use this at present, I hope that this will allow * some optimizations when I get to it. * * * When a cache entry is protected, it must be removed from the LRU * list(s) as it cannot be either flushed or evicted until it is unprotected. * The following fields are used to implement the protected list (pl). * * pl_len: Number of entries currently residing on the protected list. * * pl_size: Number of bytes of cache entries currently residing on the * protected list. * * pl_head_ptr: Pointer to the head of the doubly linked list of protected * entries. Note that cache entries on this list are linked * by their next and prev fields. * * This field is NULL if the list is empty. * * pl_tail_ptr: Pointer to the tail of the doubly linked list of protected * entries. Note that cache entries on this list are linked * by their next and prev fields. * * This field is NULL if the list is empty. * * * The cache must have a replacement policy, and the fields supporting this * policy must be accessible from this structure. * * While there has been interest in several replacement policies for * this cache, the initial development schedule is tight. Thus I have * elected to support only a modified LRU policy for the first cut. * * To further simplify matters, I have simply included the fields needed * by the modified LRU in this structure. When and if we add support for * other policies, it will probably be easiest to just add the necessary * fields to this structure as well -- we only create one instance of this * structure per file, so the overhead is not excessive. * * * Fields supporting the modified LRU policy: * * See most any OS text for a discussion of the LRU replacement policy. * * When operating in parallel mode, we must ensure that a read does not * cause a write. If it does, the process will hang, as the write will * be collective and the other processes will not know to participate. * * To deal with this issue, I have modified the usual LRU policy by adding * clean and dirty LRU lists to the usual LRU list. * * The clean LRU list is simply the regular LRU list with all dirty cache * entries removed. * * Similarly, the dirty LRU list is the regular LRU list with all the clean * cache entries removed. * * When reading in parallel mode, we evict from the clean LRU list only. * This implies that we must try to ensure that the clean LRU list is * reasonably well stocked at all times. * * We attempt to do this by trying to flush enough entries on each write * to keep the cLRU_list_size >= min_clean_size. * * Even if we start with a completely clean cache, a sequence of protects * without unprotects can empty the clean LRU list. In this case, the * cache must grow temporarily. At the next write, we will attempt to * evict enough entries to reduce index_size to less than max_cache_size. * While this will usually be possible, all bets are off if enough entries * are protected. * * Discussions of the individual fields used by the modified LRU replacement * policy follow: * * LRU_list_len: Number of cache entries currently on the LRU list. * * Observe that LRU_list_len + pl_len must always equal * index_len. * * LRU_list_size: Number of bytes of cache entries currently residing on the * LRU list. * * Observe that LRU_list_size + pl_size must always equal * index_size. * * LRU_head_ptr: Pointer to the head of the doubly linked LRU list. Cache * entries on this list are linked by their next and prev fields. * * This field is NULL if the list is empty. * * LRU_tail_ptr: Pointer to the tail of the doubly linked LRU list. Cache * entries on this list are linked by their next and prev fields. * * This field is NULL if the list is empty. * * cLRU_list_len: Number of cache entries currently on the clean LRU list. * * Observe that cLRU_list_len + dLRU_list_len must always * equal LRU_list_len. * * cLRU_list_size: Number of bytes of cache entries currently residing on * the clean LRU list. * * Observe that cLRU_list_size + dLRU_list_size must always * equal LRU_list_size. * * cLRU_head_ptr: Pointer to the head of the doubly linked clean LRU list. * Cache entries on this list are linked by their aux_next and * aux_prev fields. * * This field is NULL if the list is empty. * * cLRU_tail_ptr: Pointer to the tail of the doubly linked clean LRU list. * Cache entries on this list are linked by their aux_next and * aux_prev fields. * * This field is NULL if the list is empty. * * dLRU_list_len: Number of cache entries currently on the dirty LRU list. * * Observe that cLRU_list_len + dLRU_list_len must always * equal LRU_list_len. * * dLRU_list_size: Number of cache entries currently on the dirty LRU list. * * Observe that cLRU_list_len + dLRU_list_len must always * equal LRU_list_len. * * dLRU_head_ptr: Pointer to the head of the doubly linked dirty LRU list. * Cache entries on this list are linked by their aux_next and * aux_prev fields. * * This field is NULL if the list is empty. * * dLRU_tail_ptr: Pointer to the tail of the doubly linked dirty LRU list. * Cache entries on this list are linked by their aux_next and * aux_prev fields. * * This field is NULL if the list is empty. * * * Statistics collection fields: * * When enabled, these fields are used to collect statistics as described * below. The first set are collected only when H5C_COLLECT_CACHE_STATS * is true. * * hits: Array of int64 of length H5C__MAX_NUM_TYPE_IDS. The cells * are used to record the number of times an entry with type id * equal to the array index has been in cache when requested in * the current epoch. * * misses: Array of int64 of length H5C__MAX_NUM_TYPE_IDS. The cells * are used to record the number of times an entry with type id * equal to the array index has not been in cache when * requested in the current epoch. * * insertions: Array of int64 of length H5C__MAX_NUM_TYPE_IDS. The cells * are used to record the number of times an entry with type * id equal to the array index has been inserted into the * cache in the current epoch. * * clears: Array of int64 of length H5C__MAX_NUM_TYPE_IDS. The cells * are used to record the number of times an entry with type * id equal to the array index has been cleared in the current * epoch. * * flushes: Array of int64 of length H5C__MAX_NUM_TYPE_IDS. The cells * are used to record the number of times an entry with type id * equal to the array index has been written to disk in the * current epoch. * * evictions: Array of int64 of length H5C__MAX_NUM_TYPE_IDS. The cells * are used to record the number of times an entry with type id * equal to the array index has been evicted from the cache in * the current epoch. * * renames: Array of int64 of length H5C__MAX_NUM_TYPE_IDS. The cells * are used to record the number of times an entry with type * id equal to the array index has been renamed in the current * epoch. * * total_ht_insertions: Number of times entries have been inserted into the * hash table in the current epoch. * * total_ht_deletions: Number of times entries have been deleted from the * hash table in the current epoch. * * successful_ht_searches: int64 containing the total number of successful * searches of the hash table in the current epoch. * * total_successful_ht_search_depth: int64 containing the total number of * entries other than the targets examined in successful * searches of the hash table in the current epoch. * * failed_ht_searches: int64 containing the total number of unsuccessful * searches of the hash table in the current epoch. * * total_failed_ht_search_depth: int64 containing the total number of * entries examined in unsuccessful searches of the hash * table in the current epoch. * * max_index_len: Largest value attained by the index_len field in the * current epoch. * * max_index_size: Largest value attained by the index_size field in the * current epoch. * * max_slist_len: Largest value attained by the slist_len field in the * current epoch. * * max_slist_size: Largest value attained by the slist_size field in the * current epoch. * * max_pl_len: Largest value attained by the pl_len field in the * current epoch. * * max_pl_size: Largest value attained by the pl_size field in the * current epoch. * * The remaining stats are collected only when both H5C_COLLECT_CACHE_STATS * and H5C_COLLECT_CACHE_ENTRY_STATS are true. * * max_accesses: Array of int32 of length H5C__MAX_NUM_TYPE_IDS. The cells * are used to record the maximum number of times any single * entry with type id equal to the array index has been * accessed in the current epoch. * * min_accesses: Array of int32 of length H5C__MAX_NUM_TYPE_IDS. The cells * are used to record the minimum number of times any single * entry with type id equal to the array index has been * accessed in the current epoch. * * max_clears: Array of int32 of length H5C__MAX_NUM_TYPE_IDS. The cells * are used to record the maximum number of times any single * entry with type id equal to the array index has been cleared * in the current epoch. * * max_flushes: Array of int32 of length H5C__MAX_NUM_TYPE_IDS. The cells * are used to record the maximum number of times any single * entry with type id equal to the array index has been * flushed in the current epoch. * * max_size: Array of size_t of length H5C__MAX_NUM_TYPE_IDS. The cells * are used to record the maximum size of any single entry * with type id equal to the array index that has resided in * the cache in the current epoch. * * * Fields supporting testing: * * For test purposes, it is useful to turn off some asserts and sanity * checks. The following flags support this. * * skip_file_checks: Boolean flag used to skip sanity checks on file * parameters passed to the cache. In the test bed, there * is no reason to have a file open, as the cache proper * just passes these parameters through without using them. * * When this flag is set, all sanity checks on the file * parameters are skipped. The field defaults to FALSE. * * skip_dxpl_id_checks: Boolean flag used to skip sanity checks on the * dxpl_id parameters passed to the cache. These are not * used directly by the cache, so skipping the checks * simplifies the test bed. * * When this flag is set, all sanity checks on the dxpl_id * parameters are skipped. The field defaults to FALSE. * ****************************************************************************/ #define H5C__H5C_T_MAGIC 0x005CAC0E #define H5C__MAX_NUM_TYPE_IDS 9 struct H5C_t { uint32_t magic; int32_t max_type_id; const char * (* type_name_table_ptr); size_t max_cache_size; size_t min_clean_size; H5C_write_permitted_func_t check_write_permitted; int32_t index_len; size_t index_size; H5C_cache_entry_t * (index[H5C__HASH_TABLE_LEN]); int32_t slist_len; size_t slist_size; H5SL_t * slist_ptr; int32_t pl_len; size_t pl_size; H5C_cache_entry_t * pl_head_ptr; H5C_cache_entry_t * pl_tail_ptr; int32_t LRU_list_len; size_t LRU_list_size; H5C_cache_entry_t * LRU_head_ptr; H5C_cache_entry_t * LRU_tail_ptr; int32_t cLRU_list_len; size_t cLRU_list_size; H5C_cache_entry_t * cLRU_head_ptr; H5C_cache_entry_t * cLRU_tail_ptr; int32_t dLRU_list_len; size_t dLRU_list_size; H5C_cache_entry_t * dLRU_head_ptr; H5C_cache_entry_t * dLRU_tail_ptr; #if H5C_COLLECT_CACHE_STATS /* stats fields */ int64_t hits[H5C__MAX_NUM_TYPE_IDS]; int64_t misses[H5C__MAX_NUM_TYPE_IDS]; int64_t insertions[H5C__MAX_NUM_TYPE_IDS]; int64_t clears[H5C__MAX_NUM_TYPE_IDS]; int64_t flushes[H5C__MAX_NUM_TYPE_IDS]; int64_t evictions[H5C__MAX_NUM_TYPE_IDS]; int64_t renames[H5C__MAX_NUM_TYPE_IDS]; int64_t total_ht_insertions; int64_t total_ht_deletions; int64_t successful_ht_searches; int64_t total_successful_ht_search_depth; int64_t failed_ht_searches; int64_t total_failed_ht_search_depth; int32_t max_index_len; size_t max_index_size; int32_t max_slist_len; size_t max_slist_size; int32_t max_pl_len; size_t max_pl_size; #if H5C_COLLECT_CACHE_ENTRY_STATS int32_t max_accesses[H5C__MAX_NUM_TYPE_IDS]; int32_t min_accesses[H5C__MAX_NUM_TYPE_IDS]; int32_t max_clears[H5C__MAX_NUM_TYPE_IDS]; int32_t max_flushes[H5C__MAX_NUM_TYPE_IDS]; size_t max_size[H5C__MAX_NUM_TYPE_IDS]; #endif /* H5C_COLLECT_CACHE_ENTRY_STATS */ #endif /* H5C_COLLECT_CACHE_STATS */ hbool_t skip_file_checks; hbool_t skip_dxpl_id_checks; }; /* * Private file-scope variables. */ /* Declare a free list to manage the H5C_t struct */ H5FL_DEFINE_STATIC(H5C_t); /* * Private file-scope function declarations: */ static herr_t H5C_flush_single_entry(H5F_t * f, hid_t primary_dxpl_id, hid_t secondary_dxpl_id, H5C_t * cache_ptr, const H5C_class_t * type_ptr, haddr_t addr, unsigned flags, hbool_t * first_flush_ptr, hbool_t del_entry_from_slist_on_destroy); static void * H5C_load_entry(H5F_t * f, hid_t dxpl_id, const H5C_class_t * type, haddr_t addr, const void * udata1, void * udata2, hbool_t skip_file_checks); static herr_t H5C_make_space_in_cache(H5F_t * f, hid_t primary_dxpl_id, hid_t secondary_dxpl_id, H5C_t * cache_ptr, size_t space_needed, hbool_t write_permitted); /*------------------------------------------------------------------------- * Function: H5C_create * * Purpose: Allocate, initialize, and return the address of a new * instance of H5C_t. * * In general, the max_cache_size parameter must be positive, * and the min_clean_size parameter must lie in the closed * interval [0, max_cache_size]. * * The check_write_permitted parameter must either be NULL, * or point to a function of type H5C_write_permitted_func_t. * If it is NULL, the cache will presume that writes are * always permitted. * * Return: Success: Pointer to the new instance. * * Failure: NULL * * Programmer: John Mainzer * 6/2/04 * * Modifications: * * JRM -- 7/20/04 * Updated for the addition of the hash table. * *------------------------------------------------------------------------- */ H5C_t * H5C_create(size_t max_cache_size, size_t min_clean_size, int max_type_id, const char * (* type_name_table_ptr), H5C_write_permitted_func_t check_write_permitted) { int i; H5C_t * cache_ptr = NULL; H5C_t * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(H5C_create, NULL) HDassert( max_cache_size > 0 ); HDassert( min_clean_size <= max_cache_size ); HDassert( max_type_id >= 0 ); HDassert( max_type_id < H5C__MAX_NUM_TYPE_IDS ); HDassert( type_name_table_ptr ); for ( i = 0; i <= max_type_id; i++ ) { HDassert( (type_name_table_ptr)[i] ); HDassert( HDstrlen(( type_name_table_ptr)[i]) > 0 ); } if ( NULL == (cache_ptr = H5FL_CALLOC(H5C_t)) ) { HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, \ "memory allocation failed") } if ( (cache_ptr->slist_ptr = H5SL_create(H5SL_TYPE_HADDR,0.5,16)) == NULL ) { HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, NULL, "can't create skip list.") } /* If we get this far, we should succeed. Go ahead and initialize all * the fields. */ cache_ptr->magic = H5C__H5C_T_MAGIC; cache_ptr->max_type_id = max_type_id; cache_ptr->type_name_table_ptr = type_name_table_ptr; cache_ptr->max_cache_size = max_cache_size; cache_ptr->min_clean_size = min_clean_size; cache_ptr->check_write_permitted = check_write_permitted; cache_ptr->index_len = 0; cache_ptr->index_size = (size_t)0; cache_ptr->slist_len = 0; cache_ptr->slist_size = (size_t)0; for ( i = 0; i < H5C__HASH_TABLE_LEN; i++ ) { (cache_ptr->index)[i] = NULL; } cache_ptr->pl_len = 0; cache_ptr->pl_size = (size_t)0; cache_ptr->pl_head_ptr = NULL; cache_ptr->pl_tail_ptr = NULL; cache_ptr->LRU_list_len = 0; cache_ptr->LRU_list_size = (size_t)0; cache_ptr->LRU_head_ptr = NULL; cache_ptr->LRU_tail_ptr = NULL; cache_ptr->cLRU_list_len = 0; cache_ptr->cLRU_list_size = (size_t)0; cache_ptr->cLRU_head_ptr = NULL; cache_ptr->cLRU_tail_ptr = NULL; cache_ptr->dLRU_list_len = 0; cache_ptr->dLRU_list_size = (size_t)0; cache_ptr->dLRU_head_ptr = NULL; cache_ptr->dLRU_tail_ptr = NULL; H5C_stats__reset(cache_ptr); cache_ptr->skip_file_checks = FALSE; cache_ptr->skip_dxpl_id_checks = FALSE; /* Set return value */ ret_value = cache_ptr; done: if ( ret_value == 0 ) { if ( cache_ptr != NULL ) { if ( cache_ptr->slist_ptr != NULL ) H5SL_close(cache_ptr->slist_ptr); cache_ptr->magic = 0; H5FL_FREE(H5C_t, cache_ptr); cache_ptr = NULL; } /* end if */ } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5C_create() */ /*------------------------------------------------------------------------- * Function: H5C_dest * * Purpose: Flush all data to disk and destroy the cache. * * This function fails if any object are protected since the * resulting file might not be consistent. * * The primary_dxpl_id and secondary_dxpl_id parameters * specify the dxpl_ids used on the first write occasioned * by the destroy (primary_dxpl_id), and on all subsequent * writes (secondary_dxpl_id). This is useful in the metadata * cache, but may not be needed elsewhere. If so, just use the * same dxpl_id for both parameters. * * Note that *cache_ptr has been freed upon successful return. * * Return: Non-negative on success/Negative on failure * * Programmer: John Mainzer * 6/2/04 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5C_dest(H5F_t * f, hid_t primary_dxpl_id, hid_t secondary_dxpl_id, H5C_t * cache_ptr) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5C_dest, FAIL) HDassert( cache_ptr ); HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); HDassert( cache_ptr->skip_file_checks || f ); if ( H5C_flush_cache(f, primary_dxpl_id, secondary_dxpl_id, cache_ptr, H5F_FLUSH_INVALIDATE) < 0 ) { HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache") } if ( cache_ptr->slist_ptr != NULL ) { H5SL_close(cache_ptr->slist_ptr); cache_ptr->slist_ptr = NULL; } cache_ptr->magic = 0; H5FL_FREE(H5C_t, cache_ptr); done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_dest() */ /*------------------------------------------------------------------------- * Function: H5C_dest_empty * * Purpose: Destroy an empty cache. * * This function fails if the cache is not empty on entry. * * Note that *cache_ptr has been freed upon successful return. * * Return: Non-negative on success/Negative on failure * * Programmer: John Mainzer * 6/2/04 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5C_dest_empty(H5C_t * cache_ptr) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5C_dest_empty, FAIL) /* This would normally be an assert, but we need to use an HGOTO_ERROR * call to shut up the compiler. */ if ( ( ! cache_ptr ) || ( cache_ptr->magic != H5C__H5C_T_MAGIC ) || ( cache_ptr->index_len != 0 ) ) { HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ "Bad cache_ptr or non-empty cache on entry.") } if ( cache_ptr->slist_ptr != NULL ) { H5SL_close(cache_ptr->slist_ptr); cache_ptr->slist_ptr = NULL; } cache_ptr->magic = 0; H5FL_FREE(H5C_t, cache_ptr); done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_dest_empty() */ /*------------------------------------------------------------------------- * Function: H5C_flush_cache * * Purpose: Flush (and possibly destroy) the entries contained in the * specified cache. * * If the cache contains protected entries, the function will * fail, as protected entries cannot be flushed. However * all unprotected entries should be flushed before the * function returns failure. * * The primary_dxpl_id and secondary_dxpl_id parameters * specify the dxpl_ids used on the first write occasioned * by the flush (primary_dxpl_id), and on all subsequent * writes (secondary_dxpl_id). This is useful in the metadata * cache, but may not be needed elsewhere. If so, just use the * same dxpl_id for both parameters. * * Return: Non-negative on success/Negative on failure or if there was * a request to flush all items and something was protected. * * Programmer: John Mainzer * 6/2/04 * * Modifications: * * JRM -- 7/20/04 * Modified the function for the addition of the hash table. * *------------------------------------------------------------------------- */ herr_t H5C_flush_cache(H5F_t * f, hid_t primary_dxpl_id, hid_t secondary_dxpl_id, H5C_t * cache_ptr, unsigned flags) { herr_t status; herr_t ret_value = SUCCEED; hbool_t destroy = ( (flags & H5F_FLUSH_INVALIDATE) != 0 ); hbool_t first_flush = TRUE; int32_t protected_entries = 0; int32_t i; H5SL_node_t * node_ptr; H5C_cache_entry_t * entry_ptr; #if H5C_DO_SANITY_CHECKS int32_t actual_slist_len = 0; size_t actual_slist_size = 0; #endif /* H5C_DO_SANITY_CHECKS */ FUNC_ENTER_NOAPI(H5C_flush_cache, FAIL) HDassert( cache_ptr ); HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); HDassert( cache_ptr->skip_file_checks || f ); HDassert( cache_ptr->slist_ptr ); if ( cache_ptr->slist_len == 0 ) { node_ptr = NULL; HDassert( cache_ptr->slist_size == 0 ); } else { node_ptr = H5SL_first(cache_ptr->slist_ptr); } while ( node_ptr != NULL ) { entry_ptr = (H5C_cache_entry_t *)H5SL_item(node_ptr); HDassert( entry_ptr != NULL ); HDassert( entry_ptr->in_slist ); #if H5C_DO_SANITY_CHECKS actual_slist_len++; actual_slist_size += entry_ptr->size; #endif /* H5C_DO_SANITY_CHECKS */ if ( entry_ptr->is_protected ) { /* we have major problems -- but lets flush everything * we can before we flag an error. */ protected_entries++; } else { status = H5C_flush_single_entry(f, primary_dxpl_id, secondary_dxpl_id, cache_ptr, NULL, entry_ptr->addr, flags, &first_flush, FALSE); if ( status < 0 ) { /* This shouldn't happen -- if it does, we are toast so * just scream and die. */ HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, \ "Can't flush entry.") } } node_ptr = H5SL_next(node_ptr); } /* while */ #if H5C_DO_SANITY_CHECKS HDassert( actual_slist_len == cache_ptr->slist_len ); HDassert( actual_slist_size == cache_ptr->slist_size ); #endif /* H5C_DO_SANITY_CHECKS */ if ( destroy ) { if(cache_ptr->slist_ptr) { /* Release all nodes from skip list, but keep list active */ H5SL_release(cache_ptr->slist_ptr); } cache_ptr->slist_len = 0; cache_ptr->slist_size = 0; /* Since we are doing a destroy, we must make a pass through * the hash table and flush all entries that remain. Note that * all remaining entries entries must be clean, so this will * not result in any writes to disk. */ for ( i = 0; i < H5C__HASH_TABLE_LEN; i++ ) { while ( cache_ptr->index[i] ) { entry_ptr = cache_ptr->index[i]; if ( entry_ptr->is_protected ) { /* we have major problems -- but lets flush and destroy * everything we can before we flag an error. */ H5C__DELETE_FROM_INDEX(cache_ptr, entry_ptr) if ( !entry_ptr->in_slist ) { protected_entries++; HDassert( !(entry_ptr->is_dirty) ); } } else { HDassert( !(entry_ptr->is_dirty) ); HDassert( !(entry_ptr->in_slist) ); status = H5C_flush_single_entry(f, primary_dxpl_id, secondary_dxpl_id, cache_ptr, NULL, entry_ptr->addr, flags, &first_flush, FALSE); if ( status < 0 ) { /* This shouldn't happen -- if it does, we are toast so * just scream and die. */ HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, \ "Can't flush entry.") } } } } HDassert( protected_entries == cache_ptr->pl_len ); if ( protected_entries > 0 ) { /* the caller asked us to flush and destroy a cache that * contains one or more protected entries. Since we can't * flush protected entries, we haven't destroyed them either. * Since they are all on the protected list, just re-insert * them into the cache before we flag an error. */ entry_ptr = cache_ptr->pl_head_ptr; while ( entry_ptr != NULL ) { entry_ptr->in_slist = FALSE; H5C__INSERT_IN_INDEX(cache_ptr, entry_ptr, FAIL) if ( entry_ptr->is_dirty ) { H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr) } entry_ptr = entry_ptr->next; } } } HDassert( protected_entries <= cache_ptr->pl_len ); if ( cache_ptr->pl_len > 0 ) { HGOTO_ERROR(H5E_CACHE, H5E_PROTECT, FAIL, "cache has protected items") } done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_flush_cache() */ /*------------------------------------------------------------------------- * Function: H5C_insert_entry * * Purpose: Adds the specified thing to the cache. The thing need not * exist on disk yet, but it must have an address and disk * space reserved. * * The primary_dxpl_id and secondary_dxpl_id parameters * specify the dxpl_ids used on the first write occasioned * by the insertion (primary_dxpl_id), and on all subsequent * writes (secondary_dxpl_id). This is useful in the * metadata cache, but may not be needed elsewhere. If so, * just use the same dxpl_id for both parameters. * * The primary_dxpl_id is the dxpl_id passed to the * check_write_permitted function if such a function has been * provided. * * Observe that this function cannot occasion a read. * * Return: Non-negative on success/Negative on failure * * Programmer: John Mainzer * 6/2/04 * * Modifications: * * JRM -- 7/21/04 * Updated function for the addition of the hash table. * *------------------------------------------------------------------------- */ herr_t H5C_insert_entry(H5F_t * f, hid_t primary_dxpl_id, hid_t secondary_dxpl_id, H5C_t * cache_ptr, const H5C_class_t * type, haddr_t addr, void * thing) { herr_t result; herr_t ret_value = SUCCEED; /* Return value */ hbool_t write_permitted = TRUE; H5C_cache_entry_t * entry_ptr; H5C_cache_entry_t * test_entry_ptr; FUNC_ENTER_NOAPI(H5C_insert_entry, FAIL) HDassert( cache_ptr ); HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); HDassert( cache_ptr->skip_file_checks || f ); HDassert( type ); HDassert( type->flush ); HDassert( type->size ); HDassert( H5F_addr_defined(addr) ); HDassert( thing ); entry_ptr = (H5C_cache_entry_t *)thing; entry_ptr->addr = addr; entry_ptr->type = type; if ( (type->size)(f, thing, &(entry_ptr->size)) < 0 ) { HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGETSIZE, FAIL, \ "Can't get size of thing") } HDassert( entry_ptr->size < H5C_MAX_ENTRY_SIZE ); entry_ptr->in_slist = FALSE; entry_ptr->ht_next = NULL; entry_ptr->ht_prev = NULL; entry_ptr->next = NULL; entry_ptr->prev = NULL; entry_ptr->aux_next = NULL; entry_ptr->aux_prev = NULL; H5C__RESET_CACHE_ENTRY_STATS(entry_ptr) if ((cache_ptr->index_size + entry_ptr->size) > cache_ptr->max_cache_size) { size_t space_needed; if ( cache_ptr->check_write_permitted != NULL ) { result = (cache_ptr->check_write_permitted)(f, primary_dxpl_id, &write_permitted); if ( result < 0 ) { HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, \ "Can't get write_permitted") } } HDassert( entry_ptr->size <= H5C_MAX_ENTRY_SIZE ); space_needed = (cache_ptr->index_size + entry_ptr->size) - cache_ptr->max_cache_size; /* It would be nice to be able to do a tight sanity check on * space_needed here, but it is hard to assign an upper bound on * its value other than then value assigned to it. * * This fact springs from several features of the cache: * * First, it is possible for the cache to grow without * bound as long as entries are protected and not unprotected. * * Second, when writes are not permitted it is also possible * for the cache to grow without bound. * * Finally, we don't check to see if the cache is oversized * at the end of an unprotect. As a result, it is possible * to have a vastly oversized cache with no protected entries * as long as all the protects preceed the unprotects. * * Since items 1 and 2 are not changing any time soon, I see * no point in worrying about the third. * * In any case, I hope this explains why there is no sanity * check on space_needed here. */ result = H5C_make_space_in_cache(f, primary_dxpl_id, secondary_dxpl_id, cache_ptr, space_needed, write_permitted); if ( result < 0 ) { HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, \ "H5C_make_space_in_cache failed.") } } /* verify that the new entry isn't already in the hash table -- scream * and die if it is. */ H5C__SEARCH_INDEX(cache_ptr, addr, test_entry_ptr, FAIL) if ( test_entry_ptr != NULL ) { if ( test_entry_ptr == entry_ptr ) { HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, \ "entry already in cache.") } else { HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, \ "duplicate entry in cache.") } } /* we don't initialize the protected field until here as it is * possible that the entry is already in the cache, and already * protected. If it is, we don't want to make things worse by * marking it unprotected. */ entry_ptr->is_protected = FALSE; H5C__INSERT_IN_INDEX(cache_ptr, entry_ptr, FAIL) if ( entry_ptr->is_dirty ) { H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr) } H5C__UPDATE_RP_FOR_INSERTION(cache_ptr, entry_ptr, FAIL) H5C__UPDATE_STATS_FOR_INSERTION(cache_ptr, entry_ptr) done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_insert_entry() */ /*------------------------------------------------------------------------- * * Function: H5C_rename_entry * * Purpose: Use this function to notify the cache that an entry's * file address changed. * * Return: Non-negative on success/Negative on failure * * Programmer: John Mainzer * 6/2/04 * * Modifications: * * JRM -- 7/21/04 * Updated function for the addition of the hash table. * *------------------------------------------------------------------------- */ herr_t H5C_rename_entry(H5C_t * cache_ptr, const H5C_class_t * type, haddr_t old_addr, haddr_t new_addr) { herr_t ret_value = SUCCEED; /* Return value */ H5C_cache_entry_t * entry_ptr = NULL; H5C_cache_entry_t * test_entry_ptr = NULL; FUNC_ENTER_NOAPI(H5C_rename_entry, FAIL) HDassert( cache_ptr ); HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); HDassert( type ); HDassert( H5F_addr_defined(old_addr) ); HDassert( H5F_addr_defined(new_addr) ); HDassert( H5F_addr_ne(old_addr, new_addr) ); H5C__SEARCH_INDEX(cache_ptr, old_addr, entry_ptr, FAIL) if ( ( entry_ptr == NULL ) || ( entry_ptr->type != type ) ) /* the old item doesn't exist in the cache, so we are done. */ HGOTO_DONE(SUCCEED) HDassert( entry_ptr->addr == old_addr ); HDassert( entry_ptr->type == type ); HDassert( !(entry_ptr->is_protected) ); H5C__SEARCH_INDEX(cache_ptr, new_addr, test_entry_ptr, FAIL) if ( test_entry_ptr != NULL ) { /* we are hosed */ if ( test_entry_ptr->type == type ) { HGOTO_ERROR(H5E_CACHE, H5E_CANTRENAME, FAIL, \ "Target already renamed & reinserted???.") } else { HGOTO_ERROR(H5E_CACHE, H5E_CANTRENAME, FAIL, \ "New address already in use?.") } } /* If we get this far, we have work to do. Remove *entry_ptr from * the hash table (and skip list if necessary), change its address to the * new address, and then re-insert. * * Update the replacement policy for a hit to avoid an eviction before * the renamed entry is touched. Update stats for a rename. * * Note that we do not check the size of the cache, or evict anything. * Since this is a simple re-name, cache size should be unaffected. */ H5C__DELETE_FROM_INDEX(cache_ptr, entry_ptr) if ( entry_ptr->in_slist ) { HDassert( cache_ptr->slist_ptr ); H5C__REMOVE_ENTRY_FROM_SLIST(cache_ptr, entry_ptr) } entry_ptr->addr = new_addr; H5C__INSERT_IN_INDEX(cache_ptr, entry_ptr, FAIL) if ( entry_ptr->is_dirty ) { H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr) } H5C__UPDATE_RP_FOR_RENAME(cache_ptr, entry_ptr, FAIL) H5C__UPDATE_STATS_FOR_RENAME(cache_ptr, entry_ptr) done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_rename_entry() */ /*------------------------------------------------------------------------- * Function: H5C_protect * * Purpose: If the target entry is not in the cache, load it. If * necessary, attempt to evict one or more entries to keep * the cache within its maximum size. * * Mark the target entry as protected, and return its address * to the caller. The caller must call H5C_unprotect() when * finished with the entry. * * While it is protected, the entry may not be either evicted * or flushed -- nor may it be accessed by another call to * H5C_protect. Any attempt to do so will result in a failure. * * The primary_dxpl_id and secondary_dxpl_id parameters * specify the dxpl_ids used on the first write occasioned * by the insertion (primary_dxpl_id), and on all subsequent * writes (secondary_dxpl_id). This is useful in the * metadata cache, but may not be needed elsewhere. If so, * just use the same dxpl_id for both parameters. * * All reads are performed with the primary_dxpl_id. * * Similarly, the primary_dxpl_id is passed to the * check_write_permitted function if it is called. * * Return: Success: Ptr to the desired entry * * Failure: NULL * * Programmer: John Mainzer - 6/2/04 * * Modifications: * * JRM - 7/21/04 * Updated for the addition of the hash table. * *------------------------------------------------------------------------- */ void * H5C_protect(H5F_t * f, hid_t primary_dxpl_id, hid_t secondary_dxpl_id, H5C_t * cache_ptr, const H5C_class_t * type, haddr_t addr, const void * udata1, void * udata2) { hbool_t hit = FALSE; void * thing = NULL; H5C_cache_entry_t * entry_ptr; void * ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5C_protect, NULL) /* check args */ HDassert( cache_ptr ); HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); HDassert( cache_ptr->skip_file_checks || f ); HDassert( type ); HDassert( type->flush ); HDassert( type->load ); HDassert( H5F_addr_defined(addr) ); /* first check to see if the target is in cache */ H5C__SEARCH_INDEX(cache_ptr, addr, entry_ptr, NULL) if ( entry_ptr != NULL ) { hit = TRUE; thing = (void *)entry_ptr; } else { /* must try to load the entry from disk. */ hit = FALSE; thing = H5C_load_entry(f, primary_dxpl_id, type, addr, udata1, udata2, cache_ptr->skip_file_checks); if ( thing == NULL ) { HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, "can't load entry") } entry_ptr = (H5C_cache_entry_t *)thing; /* try to free up some space if necessay */ if ( (cache_ptr->index_size + entry_ptr->size) > cache_ptr->max_cache_size ) { hbool_t write_permitted = TRUE; herr_t result; size_t space_needed; if ( cache_ptr->check_write_permitted != NULL ) { result = (cache_ptr->check_write_permitted)(f, primary_dxpl_id, &write_permitted); if ( result < 0 ) { HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, NULL, \ "Can't get write_permitted") } } HDassert( entry_ptr->size <= H5C_MAX_ENTRY_SIZE ); space_needed = (cache_ptr->index_size + entry_ptr->size) - cache_ptr->max_cache_size; /* It would be nice to be able to do a tight sanity check on * space_needed here, but it is hard to assign an upper bound on * its value other than then value assigned to it. * * This fact springs from several features of the cache: * * First, it is possible for the cache to grow without * bound as long as entries are protected and not unprotected. * * Second, when writes are not permitted it is also possible * for the cache to grow without bound. * * Finally, we don't check to see if the cache is oversized * at the end of an unprotect. As a result, it is possible * to have a vastly oversized cache with no protected entries * as long as all the protects preceed the unprotects. * * Since items 1 and 2 are not changing any time soon, I see * no point in worrying about the third. * * In any case, I hope this explains why there is no sanity * check on space_needed here. */ result = H5C_make_space_in_cache(f, primary_dxpl_id, secondary_dxpl_id, cache_ptr, space_needed, write_permitted); if ( result < 0 ) { HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, NULL, \ "H5C_make_space_in_cache failed.") } } /* Insert the entry in the hash table. It can't be dirty yet, so * we don't even check to see if it should go in the skip list. */ H5C__INSERT_IN_INDEX(cache_ptr, entry_ptr, NULL) /* insert the entry in the data structures used by the replacement * policy. We are just going to take it out again when we update * the replacement policy for a protect, but this simplifies the * code. If we do this often enough, we may want to optimize this. */ H5C__UPDATE_RP_FOR_INSERTION(cache_ptr, entry_ptr, NULL) } HDassert( entry_ptr->addr == addr ); HDassert( entry_ptr->type == type ); if ( entry_ptr->is_protected ) { HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, NULL, \ "Target already protected?!?.") } H5C__UPDATE_RP_FOR_PROTECT(cache_ptr, entry_ptr, NULL) entry_ptr->is_protected = TRUE; ret_value = thing; H5C__UPDATE_STATS_FOR_PROTECT(cache_ptr, entry_ptr, hit) done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_protect() */ /*------------------------------------------------------------------------- * Function: H5C_unprotect * * Purpose: Undo an H5C_protect() call -- specifically, mark the * entry as unprotected, remove it from the protected list, * and give it back to the replacement policy. * * The TYPE and ADDR arguments must be the same as those in * the corresponding call to H5C_protect() and the THING * argument must be the value returned by that call to * H5C_protect(). * * The primary_dxpl_id and secondary_dxpl_id parameters * specify the dxpl_ids used on the first write occasioned * by the unprotect (primary_dxpl_id), and on all subsequent * writes (secondary_dxpl_id). Since an uprotect cannot * occasion a write at present, all this is moot for now. * However, things change, and in any case, * H5C_flush_single_entry() needs primary_dxpl_id and * secondary_dxpl_id in its parameter list. * * The function can't cause a read either, so the dxpl_id * parameters are moot in this case as well. * * Return: Non-negative on success/Negative on failure * * If the deleted flag is TRUE, simply remove the target entry * from the cache, clear it, and free it without writing it to * disk. * * Return: Non-negative on success/Negative on failure * * Programmer: John Mainzer * 6/2/04 * * Modifications: * * JRM - 7/21/04 * Updated the function for the addition of the hash table. * In particular, we now add dirty entries to the skip list if * they aren't in the list already. * *------------------------------------------------------------------------- */ herr_t H5C_unprotect(H5F_t * f, hid_t primary_dxpl_id, hid_t secondary_dxpl_id, H5C_t * cache_ptr, const H5C_class_t * type, haddr_t addr, void * thing, hbool_t deleted) { herr_t ret_value = SUCCEED; /* Return value */ H5C_cache_entry_t * entry_ptr; H5C_cache_entry_t * test_entry_ptr; FUNC_ENTER_NOAPI(H5C_unprotect, FAIL) HDassert( cache_ptr ); HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); HDassert( cache_ptr->skip_file_checks || f ); HDassert( type ); HDassert( type->clear ); HDassert( type->flush ); HDassert( H5F_addr_defined(addr) ); HDassert( thing ); entry_ptr = (H5C_cache_entry_t *)thing; HDassert( entry_ptr->addr == addr ); HDassert( entry_ptr->type == type ); if ( ! (entry_ptr->is_protected) ) { HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, \ "Entry already unprotected??") } H5C__UPDATE_RP_FOR_UNPROTECT(cache_ptr, entry_ptr, FAIL) entry_ptr->is_protected = FALSE; /* add the entry to the skip list if it is dirty, and it isn't already in * the list. */ if ( ( entry_ptr->is_dirty ) && ( ! (entry_ptr->in_slist) ) ) { H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr) } /* this implementation of the "deleted" option is a bit inefficient, as * we re-insert the entry to be deleted into the replacement policy * data structures, only to remove them again. Depending on how often * we do this, we may want to optimize a bit. * * On the other hand, this implementation is reasonably clean, and * makes good use of existing code. * JRM - 5/19/04 */ if ( deleted ) { /* the following first flush flag will never be used as we are * calling H5C_flush_single_entry with both the H5F_FLUSH_CLEAR_ONLY * and H5F_FLUSH_INVALIDATE flags. However, it is needed for the * function call. */ hbool_t dummy_first_flush = TRUE; /* verify that the target entry is in the cache. */ H5C__SEARCH_INDEX(cache_ptr, addr, test_entry_ptr, FAIL) if ( test_entry_ptr == NULL ) { HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, \ "entry not in hash table?!?.") } else if ( test_entry_ptr != entry_ptr ) { HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, \ "hash table contains multiple entries for addr?!?.") } if ( H5C_flush_single_entry(f, primary_dxpl_id, secondary_dxpl_id, cache_ptr, type, addr, (H5F_FLUSH_CLEAR_ONLY|H5F_FLUSH_INVALIDATE), &dummy_first_flush, TRUE) < 0 ) { HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "Can't flush.") } } H5C__UPDATE_STATS_FOR_UNPROTECT(cache_ptr) done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_unprotect() */ /*------------------------------------------------------------------------- * Function: H5C_stats * * Purpose: Prints statistics about the cache. * * Return: Non-negative on success/Negative on failure * * Programmer: John Mainzer * 6/2/04 * * Modifications: * * JRM -- 7/21/04 * Updated function for the addition of the hash table. * *------------------------------------------------------------------------- */ herr_t H5C_stats(H5C_t * cache_ptr, const char * cache_name, hbool_t #if !H5C_COLLECT_CACHE_STATS UNUSED #endif /* H5C_COLLECT_CACHE_STATS */ display_detailed_stats) { herr_t ret_value = SUCCEED; /* Return value */ #if H5C_COLLECT_CACHE_STATS int i; int64_t total_hits = 0; int64_t total_misses = 0; int64_t total_insertions = 0; int64_t total_clears = 0; int64_t total_flushes = 0; int64_t total_evictions = 0; int64_t total_renames = 0; int32_t aggregate_max_accesses = 0; int32_t aggregate_min_accesses = 1000000; int32_t aggregate_max_clears = 0; int32_t aggregate_max_flushes = 0; size_t aggregate_max_size = 0; double hit_rate; double average_successful_search_depth = 0.0; double average_failed_search_depth = 0.0; #endif /* H5C_COLLECT_CACHE_STATS */ FUNC_ENTER_NOAPI(H5C_stats, FAIL) /* This would normally be an assert, but we need to use an HGOTO_ERROR * call to shut up the compiler. */ if ( ( ! cache_ptr ) || ( cache_ptr->magic != H5C__H5C_T_MAGIC ) || ( !cache_name ) ) { HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr or cache_name") } #if H5C_COLLECT_CACHE_STATS for ( i = 0; i <= cache_ptr->max_type_id; i++ ) { total_hits += cache_ptr->hits[i]; total_misses += cache_ptr->misses[i]; total_insertions += cache_ptr->insertions[i]; total_clears += cache_ptr->clears[i]; total_flushes += cache_ptr->flushes[i]; total_evictions += cache_ptr->evictions[i]; total_renames += cache_ptr->renames[i]; #if H5C_COLLECT_CACHE_ENTRY_STATS if ( aggregate_max_accesses < cache_ptr->max_accesses[i] ) aggregate_max_accesses = cache_ptr->max_accesses[i]; if ( aggregate_min_accesses > aggregate_max_accesses ) aggregate_min_accesses = aggregate_max_accesses; if ( aggregate_min_accesses > cache_ptr->min_accesses[i] ) aggregate_min_accesses = cache_ptr->min_accesses[i]; if ( aggregate_max_clears < cache_ptr->max_clears[i] ) aggregate_max_clears = cache_ptr->max_clears[i]; if ( aggregate_max_flushes < cache_ptr->max_flushes[i] ) aggregate_max_flushes = cache_ptr->max_flushes[i]; if ( aggregate_max_size < cache_ptr->max_size[i] ) aggregate_max_size = cache_ptr->max_size[i]; #endif /* H5C_COLLECT_CACHE_ENTRY_STATS */ } if ( ( total_hits > 0 ) || ( total_misses > 0 ) ) { hit_rate = 100.0 * ((double)(total_hits)) / ((double)(total_hits + total_misses)); } else { hit_rate = 0.0; } if ( cache_ptr->successful_ht_searches > 0 ) { average_successful_search_depth = ((double)(cache_ptr->total_successful_ht_search_depth)) / ((double)(cache_ptr->successful_ht_searches)); } if ( cache_ptr->failed_ht_searches > 0 ) { average_failed_search_depth = ((double)(cache_ptr->total_failed_ht_search_depth)) / ((double)(cache_ptr->failed_ht_searches)); } HDfprintf(stdout, "\nH5C: cache statistics for %s\n", cache_name); HDfprintf(stdout, "\n"); HDfprintf(stdout, " hash table insertion / deletions = %ld / %ld\n", (long)(cache_ptr->total_ht_insertions), (long)(cache_ptr->total_ht_deletions)); HDfprintf(stdout, " HT successful / failed searches = %ld / %ld\n", (long)(cache_ptr->successful_ht_searches), (long)(cache_ptr->failed_ht_searches)); HDfprintf(stdout, " Av. HT suc / failed search depth = %f / %f\n", average_successful_search_depth, average_failed_search_depth); HDfprintf(stdout, " current (max) index size / length = %ld (%ld) / %ld (%ld)\n", (long)(cache_ptr->index_size), (long)(cache_ptr->max_index_size), (long)(cache_ptr->index_len), (long)(cache_ptr->max_index_len)); HDfprintf(stdout, " current (max) skip list size / length = %ld (%ld) / %ld (%ld)\n", (long)(cache_ptr->slist_size), (long)(cache_ptr->max_slist_size), (long)(cache_ptr->slist_len), (long)(cache_ptr->max_slist_len)); HDfprintf(stdout, " current (max) PL size / length = %ld (%ld) / %ld (%ld)\n", (long)(cache_ptr->pl_size), (long)(cache_ptr->max_pl_size), (long)(cache_ptr->pl_len), (long)(cache_ptr->max_pl_len)); HDfprintf(stdout, " current LRU list size / length = %ld / %ld\n", (long)(cache_ptr->LRU_list_size), (long)(cache_ptr->LRU_list_len)); HDfprintf(stdout, " current clean LRU size / length = %ld / %ld\n", (long)(cache_ptr->cLRU_list_size), (long)(cache_ptr->cLRU_list_len)); HDfprintf(stdout, " current dirty LRU size / length = %ld / %ld\n", (long)(cache_ptr->dLRU_list_size), (long)(cache_ptr->dLRU_list_len)); HDfprintf(stdout, " Total hits / misses / hit_rate = %ld / %ld / %f\n", (long)total_hits, (long)total_misses, hit_rate); HDfprintf(stdout, " Total clears / flushes / evictions = %ld / %ld / %ld\n", (long)total_clears, (long)total_flushes, (long)total_evictions); HDfprintf(stdout, " Total insertions / renames = %ld / %ld\n", (long)total_insertions, (long)total_renames); #if H5C_COLLECT_CACHE_ENTRY_STATS HDfprintf(stdout, " aggregate max / min accesses = %d / %d\n", (int)aggregate_max_accesses, (int)aggregate_min_accesses); HDfprintf(stdout, " aggregate max_clears / max_flushes = %d / %d\n", (int)aggregate_max_clears, (int)aggregate_max_flushes); HDfprintf(stdout, " aggregate max_size = %d\n", (int)aggregate_max_size); #endif /* H5C_COLLECT_CACHE_ENTRY_STATS */ if ( display_detailed_stats ) { for ( i = 0; i <= cache_ptr->max_type_id; i++ ) { HDfprintf(stdout, "\n"); HDfprintf(stdout, " Stats on %s:\n", ((cache_ptr->type_name_table_ptr))[i]); if ( ( cache_ptr->hits[i] > 0 ) || ( cache_ptr->misses[i] > 0 ) ) { hit_rate = 100.0 * ((double)(cache_ptr->hits[i])) / ((double)(cache_ptr->hits[i] + cache_ptr->misses[i])); } else { hit_rate = 0.0; } HDfprintf(stdout, " hits / misses / hit_rate = %ld / %ld / %f\n", (long)(cache_ptr->hits[i]), (long)(cache_ptr->misses[i]), hit_rate); HDfprintf(stdout, " clears / flushes / evictions = %ld / %ld / %ld\n", (long)(cache_ptr->clears[i]), (long)(cache_ptr->flushes[i]), (long)(cache_ptr->evictions[i])); HDfprintf(stdout, " insertions / renames = %ld / %ld\n", (long)(cache_ptr->insertions[i]), (long)(cache_ptr->renames[i])); #if H5C_COLLECT_CACHE_ENTRY_STATS HDfprintf(stdout, " entry max / min accesses = %d / %d\n", cache_ptr->max_accesses[i], cache_ptr->min_accesses[i]); HDfprintf(stdout, " entry max_clears / max_flushes = %d / %d\n", cache_ptr->max_clears[i], cache_ptr->max_flushes[i]); HDfprintf(stdout, " entry max_size = %d\n", (int)(cache_ptr->max_size[i])); #endif /* H5C_COLLECT_CACHE_ENTRY_STATS */ } } HDfprintf(stdout, "\n"); #endif /* H5C_COLLECT_CACHE_STATS */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_stats() */ /*------------------------------------------------------------------------- * * Function: H5C_stats__reset * * Purpose: Reset the stats fields to their initial values. * * Return: void * * Programmer: John Mainzer, 4/28/04 * * Modifications: * * JRM - 7/21/04 * Updated for hash table related statistics. * *------------------------------------------------------------------------- */ void H5C_stats__reset(H5C_t * cache_ptr) { #if H5C_COLLECT_CACHE_STATS int i; #endif /* H5C_COLLECT_CACHE_STATS */ HDassert( cache_ptr ); HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); #if H5C_COLLECT_CACHE_STATS for ( i = 0; i <= cache_ptr->max_type_id; i++ ) { cache_ptr->hits[i] = 0; cache_ptr->misses[i] = 0; cache_ptr->insertions[i] = 0; cache_ptr->clears[i] = 0; cache_ptr->flushes[i] = 0; cache_ptr->evictions[i] = 0; cache_ptr->renames[i] = 0; } cache_ptr->total_ht_insertions = 0; cache_ptr->total_ht_deletions = 0; cache_ptr->successful_ht_searches = 0; cache_ptr->total_successful_ht_search_depth = 0; cache_ptr->failed_ht_searches = 0; cache_ptr->total_failed_ht_search_depth = 0; cache_ptr->max_index_len = 0; cache_ptr->max_index_size = (size_t)0; cache_ptr->max_slist_len = 0; cache_ptr->max_slist_size = (size_t)0; cache_ptr->max_pl_len = 0; cache_ptr->max_pl_size = (size_t)0; #if H5C_COLLECT_CACHE_ENTRY_STATS for ( i = 0; i <= cache_ptr->max_type_id; i++ ) { cache_ptr->max_accesses[i] = 0; cache_ptr->min_accesses[i] = 1000000; cache_ptr->max_clears[i] = 0; cache_ptr->max_flushes[i] = 0; cache_ptr->max_size[i] = (size_t)0; } #endif /* H5C_COLLECT_CACHE_ENTRY_STATS */ #endif /* H5C_COLLECT_CACHE_STATS */ return; } /* H5C_stats__reset() */ /*------------------------------------------------------------------------- * Function: H5C_set_skip_flags * * Purpose: Set the values of the skip sanity check flags. * * This function and the skip sanity check flags were created * for the convenience of the test bed. However it is * possible that there may be other uses for the flags. * * Return: Non-negative on success/Negative on failure * * Programmer: John Mainzer * 6/11/04 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5C_set_skip_flags(H5C_t * cache_ptr, hbool_t skip_file_checks, hbool_t skip_dxpl_id_checks) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5C_set_skip_flags, FAIL) /* This would normally be an assert, but we need to use an HGOTO_ERROR * call to shut up the compiler. */ if ( ( ! cache_ptr ) || ( cache_ptr->magic != H5C__H5C_T_MAGIC ) ) { HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr") } cache_ptr->skip_file_checks = skip_file_checks; cache_ptr->skip_dxpl_id_checks = skip_dxpl_id_checks; done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_set_skip_flags() */ /*************************************************************************/ /**************************** Private Functions: *************************/ /*************************************************************************/ /*------------------------------------------------------------------------- * * Function: H5C_flush_single_entry * * Purpose: Flush or clear (and evict if requested) the cache entry * with the specified address and type. If the type is NULL, * any unprotected entry at the specified address will be * flushed (and possibly evicted). * * Attempts to flush a protected entry will result in an * error. * * *first_flush_ptr should be true if only one * flush is contemplated before the next load, or if this * is the first of a sequence of flushes that will be * completed before the next load. *first_flush_ptr is set * to false if a flush actually takes place, and should be * left false until the end of the sequence. * * The primary_dxpl_id is used if *first_flush_ptr is TRUE * on entry, and a flush actually takes place. The * secondary_dxpl_id is used in any subsequent flush where * *first_flush_ptr is FALSE on entry. * * If the H5F_FLUSH_CLEAR_ONLY flag is set, the entry will * be cleared and not flushed -- in the case *first_flush_ptr, * primary_dxpl_id, and secondary_dxpl_id are all irrelevent, * and the call can't be part of a sequence of flushes. * * If the caller knows the address of the TBBT node at * which the target entry resides, it can avoid a lookup * by supplying that address in the tgt_node_ptr parameter. * If this parameter is NULL, the function will do a TBBT * search for the entry instead. * * The function does nothing silently if there is no entry * at the supplied address, or if the entry found has the * wrong type. * * Return: Non-negative on success/Negative on failure or if there was * an attempt to flush a protected item. * * Programmer: John Mainzer, 5/5/04 * * Modifications: * * JRM -- 7/21/04 * Updated function for the addition of the hash table. * * QAK -- 11/26/04 * Updated function for the switch from TBBTs to skip lists. * *------------------------------------------------------------------------- */ static herr_t H5C_flush_single_entry(H5F_t * f, hid_t primary_dxpl_id, hid_t secondary_dxpl_id, H5C_t * cache_ptr, const H5C_class_t * type_ptr, haddr_t addr, unsigned flags, hbool_t * first_flush_ptr, hbool_t del_entry_from_slist_on_destroy) { hbool_t destroy = ( (flags & H5F_FLUSH_INVALIDATE) != 0 ); hbool_t clear_only = ( (flags & H5F_FLUSH_CLEAR_ONLY) != 0); herr_t ret_value = SUCCEED; /* Return value */ herr_t status; H5C_cache_entry_t * entry_ptr = NULL; FUNC_ENTER_NOAPI_NOINIT(H5C_flush_single_entry) HDassert( cache_ptr ); HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); HDassert( cache_ptr->skip_file_checks || f ); HDassert( H5F_addr_defined(addr) ); HDassert( first_flush_ptr ); /* attempt to find the target entry in the hash table */ H5C__SEARCH_INDEX(cache_ptr, addr, entry_ptr, FAIL) #if H5C_DO_SANITY_CHECKS if ( entry_ptr->in_slist ) { if ( ( entry_ptr->addr != addr ) ) { HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ "Hash table and skip list out of sync.") } } else if ( entry_ptr != NULL ) { if ( ( entry_ptr->in_slist ) || ( entry_ptr->is_dirty ) || ( entry_ptr->addr != addr ) ) { HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ "entry failed sanity checks.") } } #endif /* H5C_DO_SANITY_CHECKS */ if ( ( entry_ptr != NULL ) && ( entry_ptr->is_protected ) ) { /* Attempt to flush a protected entry -- scream and die. */ HGOTO_ERROR(H5E_CACHE, H5E_PROTECT, FAIL, \ "Attempt to flush a protected entry.") } if ( ( entry_ptr != NULL ) && ( ( type_ptr == NULL ) || ( type_ptr->id == entry_ptr->type->id ) ) ) { /* we have work to do */ #ifdef H5_HAVE_PARALLEL #ifndef NDEBUG /* If MPI based VFD is used, do special parallel I/O sanity checks. * Note that we only do these sanity checks when the clear_only flag * is not set, and the entry to be flushed is dirty. Don't bother * otherwise as no file I/O can result. * * There are also cases (testing for instance) where it is convenient * to pass in dummy dxpl_ids. Since we don't use the dxpl_ids directly, * this isn't a problem -- but we do have to turn off sanity checks * involving them. We use cache_ptr->skip_dxpl_id_checks to do this. */ if ( ( ! cache_ptr->skip_dxpl_id_checks ) && ( ! clear_only ) && ( entry_ptr->is_dirty ) && ( IS_H5FD_MPI(f) ) ) { H5P_genplist_t *dxpl; /* Dataset transfer property list */ H5FD_mpio_xfer_t xfer_mode; /* I/O xfer mode property value */ /* Get the dataset transfer property list */ if ( NULL == (dxpl = H5I_object(primary_dxpl_id)) ) { HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, \ "not a dataset creation property list") } /* Get the transfer mode property */ if( H5P_get(dxpl, H5D_XFER_IO_XFER_MODE_NAME, &xfer_mode) < 0 ) { HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, \ "can't retrieve xfer mode") } /* Sanity check transfer mode */ HDassert( xfer_mode == H5FD_MPIO_COLLECTIVE ); } #endif /* NDEBUG */ #endif /* H5_HAVE_PARALLEL */ if ( clear_only ) { H5C__UPDATE_STATS_FOR_CLEAR(cache_ptr, entry_ptr) } else { H5C__UPDATE_STATS_FOR_FLUSH(cache_ptr, entry_ptr) } if ( destroy ) { H5C__UPDATE_STATS_FOR_EVICTION(cache_ptr, entry_ptr) } /* Always remove the entry from the hash table on a destroy. On a * flush with destroy, it is cheaper to discard the skip list all at once * rather than remove the entries one by one, so we only delete from * the list if requested. * * We must do deletions now as the callback routines will free the * entry if destroy is true. */ if ( destroy ) { H5C__DELETE_FROM_INDEX(cache_ptr, entry_ptr) if ( ( entry_ptr->in_slist ) && ( del_entry_from_slist_on_destroy ) ) { H5C__REMOVE_ENTRY_FROM_SLIST(cache_ptr, entry_ptr) } } /* Update the replacement policy for the flush or eviction. * Again, do this now so we don't have to reference freed * memory in the destroy case. */ if ( destroy ) { /* AKA eviction */ H5C__UPDATE_RP_FOR_EVICTION(cache_ptr, entry_ptr, FAIL) } else { H5C__UPDATE_RP_FOR_FLUSH(cache_ptr, entry_ptr, FAIL) } /* Clear the dirty flag only, if requested */ if ( clear_only ) { /* Call the callback routine to clear all dirty flags for object */ if ( (entry_ptr->type->clear)(f, entry_ptr, destroy) < 0 ) { HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "can't clear entry") } } else { /* Only block for all the processes on the first piece of metadata */ if ( *first_flush_ptr && entry_ptr->is_dirty ) { status = (entry_ptr->type->flush)(f, primary_dxpl_id, destroy, entry_ptr->addr, entry_ptr); *first_flush_ptr = FALSE; } else { status = (entry_ptr->type->flush)(f, secondary_dxpl_id, destroy, entry_ptr->addr, entry_ptr); } if ( status < 0 ) { HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, \ "unable to flush entry") } } if ( ! destroy ) { HDassert( !(entry_ptr->is_dirty) ); } } done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_flush_single_entry() */ /*------------------------------------------------------------------------- * * Function: H5C_load_entry * * Purpose: Attempt to load the entry at the specified disk address * and with the specified type into memory. If successful. * return the in memory address of the entry. Return NULL * on failure. * * Note that this function simply loads the entry into * core. It does not insert it into the cache. * * Return: Non-NULL on success / NULL on failure. * * Programmer: John Mainzer, 5/18/04 * * Modifications: * * JRM - 7/21/04 * Updated function for the addition of the hash table. * *------------------------------------------------------------------------- */ static void * H5C_load_entry(H5F_t * f, hid_t dxpl_id, const H5C_class_t * type, haddr_t addr, const void * udata1, void * udata2, hbool_t skip_file_checks) { void * thing = NULL; void * ret_value = NULL; H5C_cache_entry_t * entry_ptr = NULL; FUNC_ENTER_NOAPI_NOINIT(H5C_load_entry) HDassert( skip_file_checks || f ); HDassert( type ); HDassert( type->load ); HDassert( type->size ); HDassert( H5F_addr_defined(addr) ); if ( NULL == (thing = (type->load)(f, dxpl_id, addr, udata1, udata2)) ) { HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, "unable to load entry") } entry_ptr = (H5C_cache_entry_t *)thing; HDassert( entry_ptr->is_dirty == FALSE ); entry_ptr->addr = addr; entry_ptr->type = type; entry_ptr->is_protected = FALSE; entry_ptr->in_slist = FALSE; if ( (type->size)(f, thing, &(entry_ptr->size)) < 0 ) { HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGETSIZE, NULL, \ "Can't get size of thing") } HDassert( entry_ptr->size < H5C_MAX_ENTRY_SIZE ); entry_ptr->ht_next = NULL; entry_ptr->ht_prev = NULL; entry_ptr->next = NULL; entry_ptr->prev = NULL; entry_ptr->aux_next = NULL; entry_ptr->aux_prev = NULL; H5C__RESET_CACHE_ENTRY_STATS(entry_ptr); ret_value = thing; done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_load_entry() */ /*------------------------------------------------------------------------- * * Function: H5C_make_space_in_cache * * Purpose: Attempt to evict cache entries until the index_size * is at least needed_space below max_cache_size. * * In passing, also attempt to bring cLRU_list_size to a * value greater than min_clean_size. * * Depending on circumstances, both of these goals may * be impossible, as in parallel mode, we must avoid generating * a write as part of a read (to avoid deadlock in collective * I/O), and in all cases, it is possible (though hopefully * highly unlikely) that the protected list may exceed the * maximum size of the cache. * * Thus the function simply does its best, returning success * unless an error is encountered. * * The primary_dxpl_id and secondary_dxpl_id parameters * specify the dxpl_ids used on the first write occasioned * by the call (primary_dxpl_id), and on all subsequent * writes (secondary_dxpl_id). This is useful in the metadata * cache, but may not be needed elsewhere. If so, just use the * same dxpl_id for both parameters. * * Observe that this function cannot occasion a read. * * Return: Non-negative on success/Negative on failure. * * Programmer: John Mainzer, 5/14/04 * * Modifications: * * JRM --7/21/04 * Minor modifications in support of the addition of a hash * table to facilitate lookups. * *------------------------------------------------------------------------- */ static herr_t H5C_make_space_in_cache(H5F_t * f, hid_t primary_dxpl_id, hid_t secondary_dxpl_id, H5C_t * cache_ptr, size_t space_needed, hbool_t write_permitted) { hbool_t first_flush = TRUE; herr_t ret_value = SUCCEED; /* Return value */ herr_t result; int32_t entries_examined = 0; int32_t initial_list_len; H5C_cache_entry_t * entry_ptr; H5C_cache_entry_t * prev_ptr; FUNC_ENTER_NOAPI_NOINIT(H5C_make_space_in_cache) HDassert( cache_ptr ); HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); if ( write_permitted ) { initial_list_len = cache_ptr->LRU_list_len; entry_ptr = cache_ptr->LRU_tail_ptr; while ( ( (cache_ptr->index_size + space_needed) > cache_ptr->max_cache_size ) && ( entries_examined <= (2 * initial_list_len) ) && ( entry_ptr != NULL ) ) { HDassert( ! (entry_ptr->is_protected) ); prev_ptr = entry_ptr->prev; if ( entry_ptr->is_dirty ) { result = H5C_flush_single_entry(f, primary_dxpl_id, secondary_dxpl_id, cache_ptr, entry_ptr->type, entry_ptr->addr, (unsigned)0, &first_flush, FALSE); } else { result = H5C_flush_single_entry(f, primary_dxpl_id, secondary_dxpl_id, cache_ptr, entry_ptr->type, entry_ptr->addr, H5F_FLUSH_INVALIDATE, &first_flush, TRUE); } if ( result < 0 ) { HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, \ "unable to flush entry") } entry_ptr = prev_ptr; } #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS initial_list_len = cache_ptr->dLRU_list_len; entry_ptr = cache_ptr->dLRU_tail_ptr; while ( ( cache_ptr->cLRU_list_size < cache_ptr->min_clean_size ) && ( entries_examined <= initial_list_len ) && ( entry_ptr != NULL ) ) { HDassert( ! (entry_ptr->is_protected) ); HDassert( entry_ptr->is_dirty ); HDassert( entry_ptr->in_slist ); prev_ptr = entry_ptr->aux_prev; result = H5C_flush_single_entry(f, primary_dxpl_id, secondary_dxpl_id, cache_ptr, entry_ptr->type, entry_ptr->addr, (unsigned)0, &first_flush, FALSE); if ( result < 0 ) { HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, \ "unable to flush entry") } entry_ptr = prev_ptr; } #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ } else { HDassert( H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS ); initial_list_len = cache_ptr->cLRU_list_len; entry_ptr = cache_ptr->cLRU_tail_ptr; while ( ( (cache_ptr->index_size + space_needed) > cache_ptr->max_cache_size ) && ( entries_examined <= initial_list_len ) && ( entry_ptr != NULL ) ) { HDassert( ! (entry_ptr->is_protected) ); HDassert( ! (entry_ptr->is_dirty) ); prev_ptr = entry_ptr->aux_prev; result = H5C_flush_single_entry(f, primary_dxpl_id, secondary_dxpl_id, cache_ptr, entry_ptr->type, entry_ptr->addr, H5F_FLUSH_INVALIDATE, &first_flush, TRUE); if ( result < 0 ) { HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, \ "unable to flush entry") } entry_ptr = prev_ptr; } } done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_make_space_in_cache() */ xdmf-3.0+git20160803/Utilities/hdf5/H5RSprivate.h0000640000175000017500000000427513003006557021170 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * This file contains private information about the H5RS module */ #ifndef _H5RSprivate_H #define _H5RSprivate_H /**************************************/ /* Public headers needed by this file */ /**************************************/ #ifdef LATER #include "H5RSpublic.h" #endif /* LATER */ /***************************************/ /* Private headers needed by this file */ /***************************************/ #include "H5private.h" /************/ /* Typedefs */ /************/ /* Typedef for reference counted string (defined in H5RS.c) */ typedef struct H5RS_str_t H5RS_str_t; /**********/ /* Macros */ /**********/ /********************/ /* Private routines */ /********************/ H5_DLL H5RS_str_t *H5RS_create(const char *s); H5_DLL H5RS_str_t *H5RS_wrap(const char *s); H5_DLL H5RS_str_t *H5RS_own(char *s); H5_DLL herr_t H5RS_decr(H5RS_str_t *rs); H5_DLL herr_t H5RS_incr(H5RS_str_t *rs); H5_DLL H5RS_str_t *H5RS_dup(H5RS_str_t *s); H5_DLL int H5RS_cmp(const H5RS_str_t *rs1, const H5RS_str_t *rs2); H5_DLL ssize_t H5RS_len(const H5RS_str_t *rs); H5_DLL char *H5RS_get_str(const H5RS_str_t *rs); H5_DLL unsigned H5RS_get_count(const H5RS_str_t *rs); #endif /* _H5RSprivate_H */ xdmf-3.0+git20160803/Utilities/hdf5/H5Rpublic.h0000640000175000017500000000722013003006557020642 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * This file contains public declarations for the H5S module. */ #ifndef _H5Rpublic_H #define _H5Rpublic_H /* Public headers needed by this file */ #include "H5public.h" #include "H5Gpublic.h" #include "H5Ipublic.h" /* * Reference types allowed. */ typedef enum { H5R_BADTYPE = (-1), /*invalid Reference Type */ H5R_OBJECT, /*Object reference */ H5R_DATASET_REGION, /*Dataset Region Reference */ H5R_INTERNAL, /*Internal Reference */ H5R_MAXTYPE /*highest type (Invalid as true type) */ } H5R_type_t; #ifdef LATER /* Generic reference structure for user's code */ typedef struct { unsigned long oid[2]; /* OID of object referenced */ unsigned long region[2]; /* heap ID of region in object */ unsigned long file[2]; /* heap ID of external filename */ } href_t; #endif /* LATER */ /* Note! Be careful with the sizes of the references because they should really * depend on the run-time values in the file. Unfortunately, the arrays need * to be defined at compile-time, so we have to go with the worst case sizes for * them. -QAK */ #define H5R_OBJ_REF_BUF_SIZE sizeof(haddr_t) /* Object reference structure for user's code */ typedef haddr_t hobj_ref_t; /* Needs to be large enough to store largest haddr_t in a worst case machine (ie. 8 bytes currently) */ #define H5R_DSET_REG_REF_BUF_SIZE (sizeof(haddr_t)+4) /* 4 is used instead of sizeof(int) to permit portability between the Crays and other machines (the heap ID is always encoded as an int32 anyway) */ /* Dataset Region reference structure for user's code */ typedef unsigned char hdset_reg_ref_t[H5R_DSET_REG_REF_BUF_SIZE];/* Buffer to store heap ID and index */ /* Needs to be large enough to store largest haddr_t in a worst case machine (ie. 8 bytes currently) plus an int */ /* Publicly visible datastructures */ #ifdef __cplusplus extern "C" { #endif /* Functions in H5R.c */ H5_DLL herr_t H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t space_id); H5_DLL hid_t H5Rdereference(hid_t dataset, H5R_type_t ref_type, void *ref); H5_DLL hid_t H5Rget_region(hid_t dataset, H5R_type_t ref_type, void *ref); #ifdef H5_WANT_H5_V1_4_COMPAT H5_DLL int H5Rget_object_type(hid_t dataset, void *_ref); H5_DLL int H5Rget_obj_type(hid_t id, H5R_type_t ref_type, void *_ref); #else /* H5_WANT_H5_V1_4_COMPAT */ H5_DLL H5G_obj_t H5Rget_obj_type(hid_t id, H5R_type_t ref_type, void *_ref); #endif /* H5_WANT_H5_V1_4_COMPAT */ #ifdef __cplusplus } #endif #endif /* _H5Rpublic_H */ xdmf-3.0+git20160803/Utilities/hdf5/H5RC.c0000640000175000017500000000776713003006557017561 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Reference counting buffer algorithms. * * These are used for various internal buffers which are shared. * */ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free lists */ #include "H5RCprivate.h" /* Reference-counted buffers */ /* Private typedefs & structs */ /* Declare a free list to manage the H5RC_t struct */ H5FL_DEFINE_STATIC(H5RC_t); /*-------------------------------------------------------------------------- NAME H5RC_create PURPOSE Create a reference counted object USAGE H5RC_t *H5RC_create(o,free) const void *o; IN: Object to initialize ref-counted object with H5RC_free_func_t free; IN: Function to call when ref-count drop to zero RETURNS Returns a pointer to a new ref-counted object on success, NULL on failure. DESCRIPTION Create a reference counted object. The object is not duplicated, it is assumed to be owned by the reference counted object now and will be freed with the 'free' function when the reference count drops to zero. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ H5RC_t * H5RC_create(void *o, H5RC_free_func_t free_func) { H5RC_t *ret_value=NULL; /* Return value */ FUNC_ENTER_NOAPI(H5RC_create,NULL); /* Sanity check */ HDassert(o); HDassert(free_func); /* Allocate ref-counted string structure */ if((ret_value=H5FL_MALLOC(H5RC_t))==NULL) HGOTO_ERROR(H5E_RS,H5E_NOSPACE,NULL,"memory allocation failed"); /* Set the internal fields */ ret_value->o=o; ret_value->n=1; ret_value->free_func=free_func; done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5RC_create() */ /*-------------------------------------------------------------------------- NAME H5RC_decr PURPOSE Decrement the reference count for a ref-counted object USAGE herr_t H5RC_decr(rc) H5RC_t *rc; IN: Ref-counted object to decrement count for RETURNS SUCCEED/FAIL DESCRIPTION Decrements the reference count for a ref-counted object, calling the object's free function if ref-count drops to zero. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5RC_decr(H5RC_t *rc) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5RC_decr,FAIL); /* Sanity check */ HDassert(rc); HDassert(rc->o); HDassert(rc->n>0); HDassert(rc->free_func); /* Decrement reference count */ rc->n--; /* Check if we should delete this object now */ if(rc->n==0) { if((rc->free_func)(rc->o)<0) { H5FL_FREE(H5RC_t,rc); HGOTO_ERROR(H5E_RS,H5E_CANTFREE,FAIL,"memory release failed"); } /* end if */ H5FL_FREE(H5RC_t,rc); } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5RC_decr() */ xdmf-3.0+git20160803/Utilities/hdf5/H5FDsrb.h0000640000175000017500000000441013003006557020240 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Raymond Lu * Wednesday, April 12, 2000 * Purpose: The public header file for the SRB driver. */ #ifndef H5FDsrb_H #define H5FDsrb_H #include "H5FDpublic.h" #include "H5Ipublic.h" #ifdef H5_HAVE_SRB #define H5FD_SRB (H5FD_srb_init()) typedef struct SRB_Info { /* Define the SRB info object. */ char *srbHost; /* SRB host address of server */ char *srbPort; /* SRB host port number */ char *srbAuth; /* SRB Authentication-password */ int storSysType; /* Storage Type: 0=Unix, 1=UniTree, 2=HPSS, * 3=FTP, 4=HTTP */ int mode; /* File mode-Unix access mode */ int size; /* File Size-Only valid for HPSS, -1 is default */ } SRB_Info; #ifdef __cplusplus extern "C" { #endif H5_DLL hid_t H5FD_srb_init(void); H5_DLL void H5FD_srb_term(void); H5_DLL herr_t H5Pset_fapl_srb(hid_t fapl_id, SRB_Info info); H5_DLL herr_t H5Pget_fapl_srb(hid_t fapl_id, SRB_Info *info); #ifdef __cplusplus } #endif #else #define H5FD_SRB (-1) #endif /* H5_HAVE_SRB */ #endif /* H5FDsrb_H */ xdmf-3.0+git20160803/Utilities/hdf5/H5Bpkg.h0000640000175000017500000000475013003006557020132 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Quincey Koziol * Thursday, May 15, 2003 * * Purpose: This file contains declarations which are visible only within * the H5B package. Source files outside the H5B package should * include H5Bprivate.h instead. */ #ifndef H5B_PACKAGE #error "Do not include this file outside the H5B package!" #endif #ifndef _H5Bpkg_H #define _H5Bpkg_H /* Get package's private header */ #include "H5Bprivate.h" /* Other private headers needed by this file */ #include "H5RCprivate.h" /* Reference counted object functions */ /**************************/ /* Package Private Macros */ /**************************/ /****************************/ /* Package Private Typedefs */ /****************************/ /* * The B-tree node as stored in memory... */ struct H5B_t { H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */ /* first field in structure */ H5RC_t *rc_shared; /*ref-counted shared info */ unsigned level; /*node level */ unsigned nchildren; /*number of child pointers */ haddr_t left; /*address of left sibling */ haddr_t right; /*address of right sibling */ uint8_t *native; /*array of keys in native format */ haddr_t *child; /*2k child pointers */ }; /******************************/ /* Package Private Prototypes */ /******************************/ #endif /*_H5Bpkg_H*/ xdmf-3.0+git20160803/Utilities/hdf5/H5Apkg.h0000640000175000017500000000507613003006557020133 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Quincey Koziol * Monday, Apr 20 * * Purpose: This file contains declarations which are visible only within * the H5A package. Source files outside the H5A package should * include H5Aprivate.h instead. */ #ifndef H5A_PACKAGE #error "Do not include this file outside the H5A package!" #endif #ifndef _H5Apkg_H #define _H5Apkg_H /* * Define this to enable debugging. */ #ifdef NDEBUG # undef H5A_DEBUG #endif /* Get package's private header */ #include "H5Aprivate.h" /* Other private headers needed by this file */ #include "H5Sprivate.h" /* Dataspace */ #include "H5Tprivate.h" /* Datatype functions */ struct H5A_t { unsigned initialized;/* Indicate whether the attribute has been modified */ unsigned ent_opened; /* Object header entry opened? */ H5G_entry_t ent; /* Object Header entry (for both datasets & groups) */ char *name; /* Attribute's name */ H5T_t *dt; /* Attribute's datatype */ size_t dt_size; /* Size of datatype on disk */ H5S_t *ds; /* Attribute's dataspace */ size_t ds_size; /* Size of dataspace on disk */ void *data; /* Attribute data (on a temporary basis) */ size_t data_size; /* Size of data on disk */ }; /* Function prototypes for H5A package scope */ H5_DLL H5A_t *H5A_copy(H5A_t *new_attr, const H5A_t *old_attr, unsigned update_flags); H5_DLL herr_t H5A_free(H5A_t *attr); H5_DLL herr_t H5A_close(H5A_t *attr); #endif xdmf-3.0+git20160803/Utilities/hdf5/H5FDstdio.h0000640000175000017500000000271413003006557020601 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Robb Matzke * Monday, August 2, 1999 * * Purpose: The public header file for the sec2 driver. */ #ifndef H5FDstdio_H #define H5FDstdio_H #include "H5Ipublic.h" #define H5FD_STDIO (H5FD_stdio_init()) #ifdef __cplusplus extern "C" { #endif H5_DLL hid_t H5FD_stdio_init(void); H5_DLL void H5FD_stdio_term(void); H5_DLL herr_t H5Pset_fapl_stdio(hid_t fapl_id); #ifdef __cplusplus } #endif #endif xdmf-3.0+git20160803/Utilities/hdf5/H5TS.c0000640000175000017500000002353713003006557017574 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* private headers */ #include "H5private.h" /*library */ #include "H5Eprivate.h" /*error handling */ #include "H5MMprivate.h" /*memory management functions */ #ifdef H5_HAVE_THREADSAFE /* Module specific data structures */ /* cancelability structure */ typedef struct H5TS_cancel_struct { int previous_state; unsigned int cancel_count; } H5TS_cancel_t; /* Global variable definitions */ pthread_once_t H5TS_first_init_g = PTHREAD_ONCE_INIT; pthread_key_t H5TS_errstk_key_g; pthread_key_t H5TS_funcstk_key_g; pthread_key_t H5TS_cancel_key_g; hbool_t H5TS_allow_concurrent_g = FALSE; /* concurrent APIs override this */ /* Local function definitions */ #ifdef NOT_USED static void H5TS_mutex_init(H5TS_mutex_t *mutex); #endif /* NOT_USED */ /*-------------------------------------------------------------------------- * NAME * H5TS_key_destructor * * USAGE * H5TS_key_destructor() * * RETURNS * * DESCRIPTION * Frees the memory for a key. Called by each thread as it exits. * Currently all the thread-specific information for all keys are simple * structures allocated with malloc, so we can free them all uniformly. * * PROGRAMMER: Quincey Koziol * February 7, 2003 * * MODIFICATIONS: * *-------------------------------------------------------------------------- */ static void H5TS_key_destructor(void *key_val) { /* Use HDfree here instead of H5MM_xfree(), to avoid calling the H5FS routines */ if(key_val!=NULL) HDfree(key_val); } /*-------------------------------------------------------------------------- * NAME * H5TS_first_thread_init * * USAGE * H5TS_first_thread_init() * * RETURNS * * DESCRIPTION * Initialization of global API lock, keys for per-thread error stacks and * cancallability information. Called by the first thread that enters the * library. * * PROGRAMMER: Chee Wai LEE * May 2, 2000 * * MODIFICATIONS: * *-------------------------------------------------------------------------- */ void H5TS_first_thread_init(void) { H5_g.H5_libinit_g = FALSE; /* set the two pthread_t objects to ``null'' */ H5_g.init_lock.owner_thread = NULL; /* initialize global API mutex lock */ pthread_mutex_init(&H5_g.init_lock.atomic_lock, NULL); pthread_cond_init(&H5_g.init_lock.cond_var, NULL); H5_g.init_lock.lock_count = 0; /* initialize key for thread-specific error stacks */ pthread_key_create(&H5TS_errstk_key_g, H5TS_key_destructor); /* initialize key for thread-specific function stacks */ pthread_key_create(&H5TS_funcstk_key_g, H5TS_key_destructor); /* initialize key for thread cancellability mechanism */ pthread_key_create(&H5TS_cancel_key_g, H5TS_key_destructor); } /*-------------------------------------------------------------------------- * NAME * H5TS_mutex_lock * * USAGE * H5TS_mutex_lock(&mutex_var) * * RETURNS * 0 on success and non-zero on error. * * DESCRIPTION * Recursive lock semantics for HDF5 (locking) - * Multiple acquisition of a lock by a thread is permitted with a * corresponding unlock operation required. * * PROGRAMMER: Chee Wai LEE * May 2, 2000 * * MODIFICATIONS: * * 19 May 2000, Bill Wendling * Changed (*foo). form of accessing structure members to the -> form. * *-------------------------------------------------------------------------- */ herr_t H5TS_mutex_lock(H5TS_mutex_t *mutex) { herr_t ret_value; ret_value = pthread_mutex_lock(&mutex->atomic_lock); if (ret_value) return ret_value; if (mutex->owner_thread && pthread_equal(pthread_self(), *mutex->owner_thread)) { /* already owned by self - increment count */ mutex->lock_count++; } else if (!mutex->owner_thread) { /* no one else has locked it - set owner and grab lock */ mutex->owner_thread = H5MM_malloc(sizeof(pthread_t)); if (!mutex->owner_thread) { H5E_push(H5E_RESOURCE, H5E_NOSPACE, "H5TS_mutex_lock", __FILE__, __LINE__, "memory allocation failed"); return FAIL; } *mutex->owner_thread = pthread_self(); mutex->lock_count = 1; } else { /* if already locked by someone else */ for (;;) { pthread_cond_wait(&mutex->cond_var, &mutex->atomic_lock); if (!mutex->owner_thread) { mutex->owner_thread = H5MM_malloc(sizeof(pthread_t)); if (!mutex->owner_thread) { H5E_push(H5E_RESOURCE, H5E_NOSPACE, "H5TS_mutex_lock", __FILE__, __LINE__, "memory allocation failed"); return FAIL; } *mutex->owner_thread = pthread_self(); mutex->lock_count = 1; break; } } } return pthread_mutex_unlock(&mutex->atomic_lock); } /*-------------------------------------------------------------------------- * NAME * H5TS_mutex_unlock * * USAGE * H5TS_mutex_unlock(&mutex_var) * * RETURNS * 0 on success and non-zero on error. * * DESCRIPTION * Recursive lock semantics for HDF5 (unlocking) - * Multiple acquisition of a lock by a thread is permitted with a * corresponding unlock operation required. * * PROGRAMMER: Chee Wai LEE * May 2, 2000 * * MODIFICATIONS: * * 19 May 2000, Bill Wendling * Changed (*foo). form of accessing structure members to the -> form. * Also gave the function a return value. * *-------------------------------------------------------------------------- */ herr_t H5TS_mutex_unlock(H5TS_mutex_t *mutex) { herr_t ret_value; ret_value = pthread_mutex_lock(&mutex->atomic_lock); if (ret_value) return ret_value; mutex->lock_count--; if (mutex->lock_count == 0) { H5MM_xfree(mutex->owner_thread); mutex->owner_thread = NULL; ret_value = pthread_cond_signal(&mutex->cond_var); if (ret_value) { pthread_mutex_unlock(&mutex->atomic_lock); return ret_value; } } return pthread_mutex_unlock(&mutex->atomic_lock); } /*-------------------------------------------------------------------------- * NAME * H5TS_cancel_count_inc * * USAGE * H5TS_cancel_count_inc() * * RETURNS * 0 on success non-zero error code on error. * * DESCRIPTION * Creates a cancelation counter for a thread if it is the first time * the thread is entering the library. * * if counter value is zero, then set cancelability type of the thread * to PTHREAD_CANCEL_DISABLE as thread is entering the library and store * the previous cancelability type into cancelation counter. * Increase the counter value by 1. * * PROGRAMMER: Chee Wai LEE * May 2, 2000 * * MODIFICATIONS: * * 19 May 2000, Bill Wendling * Changed function to return a value. Also changed the malloc() call to * the H5MM_malloc() call and checked the returned pointer. * *-------------------------------------------------------------------------- */ herr_t H5TS_cancel_count_inc(void) { H5TS_cancel_t *cancel_counter; herr_t ret_value = 0; cancel_counter = pthread_getspecific(H5TS_cancel_key_g); if (!cancel_counter) { /* * First time thread calls library - create new counter and associate * with key */ cancel_counter = H5MM_calloc(sizeof(H5TS_cancel_t)); if (!cancel_counter) { H5E_push(H5E_RESOURCE, H5E_NOSPACE, "H5TS_cancel_count_inc", __FILE__, __LINE__, "memory allocation failed"); return FAIL; } ret_value = pthread_setspecific(H5TS_cancel_key_g, (void *)cancel_counter); } if (cancel_counter->cancel_count == 0) /* thread entering library */ ret_value = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cancel_counter->previous_state); ++cancel_counter->cancel_count; return ret_value; } /*-------------------------------------------------------------------------- * NAME * H5TS_cancel_count_dec * * USAGE * H5TS_cancel_count_dec() * * RETURNS * 0 on success and a non-zero error code on error. * * DESCRIPTION * If counter value is one, then set cancelability type of the thread * to the previous cancelability type stored in the cancelation counter. * (the thread is leaving the library). * * Decrement the counter value by 1. * * PROGRAMMER: Chee Wai LEE * May 2, 2000 * * MODIFICATIONS: * * 19 May 2000, Bill Wendling * Changed so that function returns a value. May be of limited usefulness. * *-------------------------------------------------------------------------- */ herr_t H5TS_cancel_count_dec(void) { herr_t ret_value = 0; register H5TS_cancel_t *cancel_counter; cancel_counter = pthread_getspecific(H5TS_cancel_key_g); if (cancel_counter->cancel_count == 1) ret_value = pthread_setcancelstate(cancel_counter->previous_state, NULL); --cancel_counter->cancel_count; return ret_value; } #endif /* H5_HAVE_THREADSAFE */ xdmf-3.0+git20160803/Utilities/hdf5/H5Spoint.c0000640000175000017500000013754213003006557020524 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Quincey Koziol * Tuesday, June 16, 1998 * * Purpose: Point selection data space I/O functions. */ #define H5S_PACKAGE /*suppress error about including H5Spkg */ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free Lists */ #include "H5Iprivate.h" /* ID Functions */ #include "H5MMprivate.h" /* Memory Management functions */ #include "H5Spkg.h" /* Dataspace functions */ #include "H5Vprivate.h" /* Vector functions */ /* Static function prototypes */ /* Selection callbacks */ static herr_t H5S_point_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection); static herr_t H5S_point_get_seq_list(const H5S_t *space, unsigned flags, H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes, size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len); static herr_t H5S_point_release(H5S_t *space); static htri_t H5S_point_is_valid(const H5S_t *space); static hssize_t H5S_point_serial_size(const H5S_t *space); static herr_t H5S_point_serialize(const H5S_t *space, uint8_t *buf); static herr_t H5S_point_deserialize(H5S_t *space, const uint8_t *buf); static herr_t H5S_point_bounds(const H5S_t *space, hsize_t *start, hsize_t *end); static htri_t H5S_point_is_contiguous(const H5S_t *space); static htri_t H5S_point_is_single(const H5S_t *space); static htri_t H5S_point_is_regular(const H5S_t *space); static herr_t H5S_point_iter_init(H5S_sel_iter_t *iter, const H5S_t *space); /* Selection iteration callbacks */ static herr_t H5S_point_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords); static herr_t H5S_point_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end); static hsize_t H5S_point_iter_nelmts(const H5S_sel_iter_t *iter); static htri_t H5S_point_iter_has_next_block(const H5S_sel_iter_t *iter); static herr_t H5S_point_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem); static herr_t H5S_point_iter_next_block(H5S_sel_iter_t *sel_iter); static herr_t H5S_point_iter_release(H5S_sel_iter_t *sel_iter); /* Selection properties for point selections */ const H5S_select_class_t H5S_sel_point[1] = {{ H5S_SEL_POINTS, /* Methods on selection */ H5S_point_copy, H5S_point_get_seq_list, H5S_point_release, H5S_point_is_valid, H5S_point_serial_size, H5S_point_serialize, H5S_point_deserialize, H5S_point_bounds, H5S_point_is_contiguous, H5S_point_is_single, H5S_point_is_regular, H5S_point_iter_init, }}; /* Iteration properties for point selections */ static const H5S_sel_iter_class_t H5S_sel_iter_point[1] = {{ H5S_SEL_POINTS, /* Methods on selection iterator */ H5S_point_iter_coords, H5S_point_iter_block, H5S_point_iter_nelmts, H5S_point_iter_has_next_block, H5S_point_iter_next, H5S_point_iter_next_block, H5S_point_iter_release, }}; /* Declare a free list to manage the H5S_pnt_node_t struct */ H5FL_DEFINE_STATIC(H5S_pnt_node_t); /* Declare a free list to manage the H5S_pnt_list_t struct */ H5FL_DEFINE_STATIC(H5S_pnt_list_t); /*------------------------------------------------------------------------- * Function: H5S_point_iter_init * * Purpose: Initializes iteration information for point selection. * * Return: non-negative on success, negative on failure. * * Programmer: Quincey Koziol * Tuesday, June 16, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5S_point_iter_init(H5S_sel_iter_t *iter, const H5S_t *space) { FUNC_ENTER_NOAPI_NOFUNC(H5S_point_iter_init); /* Check args */ assert (space && H5S_SEL_POINTS==H5S_GET_SELECT_TYPE(space)); assert (iter); /* Initialize the number of points to iterate over */ iter->elmt_left=space->select.num_elem; /* Start at the head of the list of points */ iter->u.pnt.curr=space->select.sel_info.pnt_lst->head; /* Initialize type of selection iterator */ iter->type=H5S_sel_iter_point; FUNC_LEAVE_NOAPI(SUCCEED); } /* H5S_point_iter_init() */ /*------------------------------------------------------------------------- * Function: H5S_point_iter_coords * * Purpose: Retrieve the current coordinates of iterator for current * selection * * Return: non-negative on success, negative on failure * * Programmer: Quincey Koziol * Tuesday, April 22, 2003 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5S_point_iter_coords (const H5S_sel_iter_t *iter, hsize_t *coords) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_iter_coords); /* Check args */ assert (iter); assert (coords); /* Copy the offset of the current point */ HDmemcpy(coords,iter->u.pnt.curr->pnt,sizeof(hsize_t)*iter->rank); FUNC_LEAVE_NOAPI(SUCCEED); } /* H5S_point_iter_coords() */ /*------------------------------------------------------------------------- * Function: H5S_point_iter_block * * Purpose: Retrieve the current block of iterator for current * selection * * Return: non-negative on success, negative on failure * * Programmer: Quincey Koziol * Monday, June 2, 2003 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5S_point_iter_block (const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_iter_block); /* Check args */ assert (iter); assert (start); assert (end); /* Copy the current point as a block */ HDmemcpy(start,iter->u.pnt.curr->pnt,sizeof(hsize_t)*iter->rank); HDmemcpy(end,iter->u.pnt.curr->pnt,sizeof(hsize_t)*iter->rank); FUNC_LEAVE_NOAPI(SUCCEED); } /* H5S_point_iter_block() */ /*------------------------------------------------------------------------- * Function: H5S_point_iter_nelmts * * Purpose: Return number of elements left to process in iterator * * Return: non-negative number of elements on success, zero on failure * * Programmer: Quincey Koziol * Tuesday, June 16, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static hsize_t H5S_point_iter_nelmts (const H5S_sel_iter_t *iter) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_iter_nelmts); /* Check args */ assert (iter); FUNC_LEAVE_NOAPI(iter->elmt_left); } /* H5S_point_iter_nelmts() */ /*-------------------------------------------------------------------------- NAME H5S_point_iter_has_next_block PURPOSE Check if there is another block left in the current iterator USAGE htri_t H5S_point_iter_has_next_block(iter) const H5S_sel_iter_t *iter; IN: Pointer to selection iterator RETURNS Non-negative (TRUE/FALSE) on success/Negative on failure DESCRIPTION Check if there is another block available in the selection iterator. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static htri_t H5S_point_iter_has_next_block(const H5S_sel_iter_t *iter) { htri_t ret_value=TRUE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_iter_has_next_block); /* Check args */ assert (iter); /* Check if there is another point in the list */ if(iter->u.pnt.curr->next==NULL) HGOTO_DONE(FALSE); done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_point_iter_has_next_block() */ /*-------------------------------------------------------------------------- NAME H5S_point_iter_next PURPOSE Increment selection iterator USAGE herr_t H5S_point_iter_next(iter, nelem) H5S_sel_iter_t *iter; IN: Pointer to selection iterator size_t nelem; IN: Number of elements to advance by RETURNS Non-negative on success/Negative on failure DESCRIPTION Advance selection iterator to the NELEM'th next element in the selection. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_point_iter_next(H5S_sel_iter_t *iter, size_t nelem) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_iter_next); /* Check args */ assert (iter); assert (nelem>0); /* Increment the iterator */ while(nelem>0) { iter->u.pnt.curr=iter->u.pnt.curr->next; nelem--; } /* end while */ FUNC_LEAVE_NOAPI(SUCCEED); } /* H5S_point_iter_next() */ /*-------------------------------------------------------------------------- NAME H5S_point_iter_next_block PURPOSE Increment selection iterator to next block USAGE herr_t H5S_point_iter_next_block(iter) H5S_sel_iter_t *iter; IN: Pointer to selection iterator RETURNS Non-negative on success/Negative on failure DESCRIPTION Advance selection iterator to the next block in the selection. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_point_iter_next_block(H5S_sel_iter_t *iter) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_iter_next_block); /* Check args */ assert (iter); /* Increment the iterator */ iter->u.pnt.curr=iter->u.pnt.curr->next; FUNC_LEAVE_NOAPI(SUCCEED); } /* H5S_point_iter_next_block() */ /*-------------------------------------------------------------------------- NAME H5S_point_iter_release PURPOSE Release point selection iterator information for a dataspace USAGE herr_t H5S_point_iter_release(iter) H5S_sel_iter_t *iter; IN: Pointer to selection iterator RETURNS Non-negative on success/Negative on failure DESCRIPTION Releases all information for a dataspace point selection iterator GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_point_iter_release (H5S_sel_iter_t UNUSED * iter) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_iter_release); /* Check args */ assert (iter); FUNC_LEAVE_NOAPI(SUCCEED); } /* H5S_point_iter_release() */ /*-------------------------------------------------------------------------- NAME H5S_point_add PURPOSE Add a series of elements to a point selection USAGE herr_t H5S_point_add(space, num_elem, coord) H5S_t *space; IN: Dataspace of selection to modify size_t num_elem; IN: Number of elements in COORD array. const hsize_t *coord[]; IN: The location of each element selected RETURNS Non-negative on success/Negative on failure DESCRIPTION This function adds elements to the current point selection for a dataspace GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_point_add (H5S_t *space, H5S_seloper_t op, size_t num_elem, const hsize_t **_coord) { H5S_pnt_node_t *top, *curr, *new_node; /* Point selection nodes */ const hsize_t *coord=(const hsize_t *)_coord; /* Pointer to the actual coordinates */ unsigned i; /* Counter */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5S_point_add); assert(space); assert(num_elem>0); assert(coord); assert(op==H5S_SELECT_SET || op==H5S_SELECT_APPEND || op==H5S_SELECT_PREPEND); top=curr=NULL; for(i=0; ipnt = H5MM_malloc(space->extent.rank*sizeof(hsize_t)))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate coordinate information"); /* Copy over the coordinates */ HDmemcpy(new_node->pnt,coord+(i*space->extent.rank),(space->extent.rank*sizeof(hsize_t))); /* Link into list */ new_node->next=NULL; if(top==NULL) top=new_node; else curr->next=new_node; curr=new_node; } /* end for */ /* Insert the list of points selected in the proper place */ if(op==H5S_SELECT_SET || op==H5S_SELECT_PREPEND) { /* Append current list, if there is one */ if(space->select.sel_info.pnt_lst->head!=NULL) curr->next=space->select.sel_info.pnt_lst->head; /* Put new list in point selection */ space->select.sel_info.pnt_lst->head=top; } /* end if */ else { /* op==H5S_SELECT_APPEND */ new_node=space->select.sel_info.pnt_lst->head; if(new_node!=NULL) { while(new_node->next!=NULL) new_node=new_node->next; /* Append new list to point selection */ new_node->next=top; } /* end if */ else space->select.sel_info.pnt_lst->head=top; } /* end else */ /* Set the number of elements in the new selection */ if(op==H5S_SELECT_SET) space->select.num_elem=num_elem; else space->select.num_elem+=num_elem; done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_point_add() */ /*-------------------------------------------------------------------------- NAME H5S_point_release PURPOSE Release point selection information for a dataspace USAGE herr_t H5S_point_release(space) H5S_t *space; IN: Pointer to dataspace RETURNS Non-negative on success/Negative on failure DESCRIPTION Releases all point selection information for a dataspace GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_point_release (H5S_t *space) { H5S_pnt_node_t *curr, *next; /* Point selection nodes */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_release); /* Check args */ assert (space); /* Delete all the nodes from the list */ curr=space->select.sel_info.pnt_lst->head; while(curr!=NULL) { next=curr->next; H5MM_xfree(curr->pnt); H5FL_FREE(H5S_pnt_node_t,curr); curr=next; } /* end while */ /* Free & reset the point list header */ H5FL_FREE(H5S_pnt_list_t,space->select.sel_info.pnt_lst); space->select.sel_info.pnt_lst=NULL; /* Reset the number of elements in the selection */ space->select.num_elem=0; FUNC_LEAVE_NOAPI(SUCCEED); } /* H5S_point_release() */ /*-------------------------------------------------------------------------- NAME H5S_select_elements PURPOSE Specify a series of elements in the dataspace to select USAGE herr_t H5S_select_elements(dsid, op, num_elem, coord) hid_t dsid; IN: Dataspace ID of selection to modify H5S_seloper_t op; IN: Operation to perform on current selection size_t num_elem; IN: Number of elements in COORD array. const hsize_t **coord; IN: The location of each element selected RETURNS Non-negative on success/Negative on failure DESCRIPTION This function selects array elements to be included in the selection for the dataspace. The COORD array is a 2-D array of size by NUM_ELEM (ie. a list of coordinates in the dataspace). The order of the element coordinates in the COORD array specifies the order that the array elements are iterated through when I/O is performed. Duplicate coordinates are not checked for. The selection operator, OP, determines how the new selection is to be combined with the existing selection for the dataspace. Currently, only H5S_SELECT_SET is supported, which replaces the existing selection with the one defined in this call. When operators other than H5S_SELECT_SET are used to combine a new selection with an existing selection, the selection ordering is reset to 'C' array ordering. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5S_select_elements (H5S_t *space, H5S_seloper_t op, size_t num_elem, const hsize_t **coord) { herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_NOAPI_NOINIT(H5S_select_elements); /* Check args */ assert(space); assert(num_elem); assert(coord); assert(op==H5S_SELECT_SET || op==H5S_SELECT_APPEND || op==H5S_SELECT_PREPEND); /* If we are setting a new selection, remove current selection first */ if(op==H5S_SELECT_SET || H5S_GET_SELECT_TYPE(space)!=H5S_SEL_POINTS) { if(H5S_SELECT_RELEASE(space)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release point selection"); } /* end if */ /* Allocate space for the point selection information if necessary */ if(H5S_GET_SELECT_TYPE(space)!=H5S_SEL_POINTS || space->select.sel_info.pnt_lst==NULL) { if((space->select.sel_info.pnt_lst = H5FL_CALLOC(H5S_pnt_list_t))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate element information"); } /* end if */ /* Add points to selection */ if(H5S_point_add(space,op,num_elem,coord)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert elements"); /* Set selection type */ space->select.type=H5S_sel_point; done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_select_elements() */ /*-------------------------------------------------------------------------- NAME H5S_point_copy PURPOSE Copy a selection from one dataspace to another USAGE herr_t H5S_point_copy(dst, src) H5S_t *dst; OUT: Pointer to the destination dataspace H5S_t *src; IN: Pointer to the source dataspace RETURNS Non-negative on success/Negative on failure DESCRIPTION Copies all the point selection information from the source dataspace to the destination dataspace. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_point_copy(H5S_t *dst, const H5S_t *src, hbool_t UNUSED share_selection) { H5S_pnt_node_t *curr, *new_node, *new_head; /* Point information nodes */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_NOAPI_NOINIT(H5S_point_copy); assert(src); assert(dst); /* Allocate room for the head of the point list */ if((dst->select.sel_info.pnt_lst=H5FL_MALLOC(H5S_pnt_list_t))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate point node"); curr=src->select.sel_info.pnt_lst->head; new_head=NULL; while(curr!=NULL) { /* Create each point */ if((new_node=H5FL_MALLOC(H5S_pnt_node_t))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate point node"); if((new_node->pnt = H5MM_malloc(src->extent.rank*sizeof(hsize_t)))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate coordinate information"); HDmemcpy(new_node->pnt,curr->pnt,(src->extent.rank*sizeof(hsize_t))); new_node->next=NULL; /* Keep the order the same when copying */ if(new_head==NULL) new_head=dst->select.sel_info.pnt_lst->head=new_node; else { new_head->next=new_node; new_head=new_node; } /* end else */ curr=curr->next; } /* end while */ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5S_point_copy() */ /*-------------------------------------------------------------------------- NAME H5S_point_is_valid PURPOSE Check whether the selection fits within the extent, with the current offset defined. USAGE htri_t H5S_point_is_valid(space); H5S_t *space; IN: Dataspace pointer to query RETURNS TRUE if the selection fits within the extent, FALSE if it does not and Negative on an error. DESCRIPTION Determines if the current selection at the current offet fits within the extent for the dataspace. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static htri_t H5S_point_is_valid (const H5S_t *space) { H5S_pnt_node_t *curr; /* Point information nodes */ unsigned u; /* Counter */ htri_t ret_value=TRUE; /* return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_is_valid); assert(space); /* Check each point to determine whether selection+offset is within extent */ curr=space->select.sel_info.pnt_lst->head; while(curr!=NULL) { /* Check each dimension */ for(u=0; uextent.rank; u++) { /* Check if an offset has been defined */ /* Bounds check the selected point + offset against the extent */ if(((curr->pnt[u]+space->select.offset[u])>space->extent.size[u]) || (((hssize_t)curr->pnt[u]+space->select.offset[u])<0)) HGOTO_DONE(FALSE) } /* end for */ curr=curr->next; } /* end while */ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5S_point_is_valid() */ /*-------------------------------------------------------------------------- NAME H5Sget_select_elem_npoints PURPOSE Get the number of points in current element selection USAGE hssize_t H5Sget_select_elem_npoints(dsid) hid_t dsid; IN: Dataspace ID of selection to query RETURNS The number of element points in selection on success, negative on failure DESCRIPTION Returns the number of element points in current selection for dataspace. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ hssize_t H5Sget_select_elem_npoints(hid_t spaceid) { H5S_t *space = NULL; /* Dataspace to modify selection of */ hssize_t ret_value; /* return value */ FUNC_ENTER_API(H5Sget_select_elem_npoints, FAIL); H5TRACE1("Hs","i",spaceid); /* Check args */ if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); if(H5S_GET_SELECT_TYPE(space)!=H5S_SEL_POINTS) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an element selection"); ret_value = H5S_GET_SELECT_NPOINTS(space); done: FUNC_LEAVE_API(ret_value); } /* H5Sget_select_elem_npoints() */ /*-------------------------------------------------------------------------- NAME H5S_point_serial_size PURPOSE Determine the number of bytes needed to store the serialized point selection information. USAGE hssize_t H5S_point_serial_size(space) H5S_t *space; IN: Dataspace pointer to query RETURNS The number of bytes required on success, negative on an error. DESCRIPTION Determines the number of bytes required to serialize the current point selection information for storage on disk. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static hssize_t H5S_point_serial_size (const H5S_t *space) { H5S_pnt_node_t *curr; /* Point information nodes */ hssize_t ret_value; /* return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_serial_size); assert(space); /* Basic number of bytes required to serialize point selection: * + + + * + + <# of points (4 bytes)> = 24 bytes */ ret_value=24; /* Count points in selection */ curr=space->select.sel_info.pnt_lst->head; while(curr!=NULL) { /* Add 4 bytes times the rank for each element selected */ ret_value+=4*space->extent.rank; curr=curr->next; } /* end while */ FUNC_LEAVE_NOAPI(ret_value); } /* end H5S_point_serial_size() */ /*-------------------------------------------------------------------------- NAME H5S_point_serialize PURPOSE Serialize the current selection into a user-provided buffer. USAGE herr_t H5S_point_serialize(space, buf) H5S_t *space; IN: Dataspace pointer of selection to serialize uint8 *buf; OUT: Buffer to put serialized selection into RETURNS Non-negative on success/Negative on failure DESCRIPTION Serializes the current element selection into a buffer. (Primarily for storing on disk). GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_point_serialize (const H5S_t *space, uint8_t *buf) { H5S_pnt_node_t *curr; /* Point information nodes */ uint8_t *lenp; /* pointer to length location for later storage */ uint32_t len=0; /* number of bytes used */ unsigned u; /* local counting variable */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_serialize); assert(space); /* Store the preamble information */ UINT32ENCODE(buf, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */ UINT32ENCODE(buf, (uint32_t)1); /* Store the version number */ UINT32ENCODE(buf, (uint32_t)0); /* Store the un-used padding */ lenp=buf; /* keep the pointer to the length location for later */ buf+=4; /* skip over space for length */ /* Encode number of dimensions */ UINT32ENCODE(buf, (uint32_t)space->extent.rank); len+=4; /* Encode number of elements */ UINT32ENCODE(buf, (uint32_t)space->select.num_elem); len+=4; /* Encode each point in selection */ curr=space->select.sel_info.pnt_lst->head; while(curr!=NULL) { /* Add 4 bytes times the rank for each element selected */ len+=4*space->extent.rank; /* Encode each point */ for(u=0; uextent.rank; u++) UINT32ENCODE(buf, (uint32_t)curr->pnt[u]); curr=curr->next; } /* end while */ /* Encode length */ UINT32ENCODE(lenp, (uint32_t)len); /* Store the length of the extra information */ FUNC_LEAVE_NOAPI(SUCCEED); } /* H5S_point_serialize() */ /*-------------------------------------------------------------------------- NAME H5S_point_deserialize PURPOSE Deserialize the current selection from a user-provided buffer. USAGE herr_t H5S_point_deserialize(space, buf) H5S_t *space; IN/OUT: Dataspace pointer to place selection into uint8 *buf; IN: Buffer to retrieve serialized selection from RETURNS Non-negative on success/Negative on failure DESCRIPTION Deserializes the current selection into a buffer. (Primarily for retrieving from disk). GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_point_deserialize (H5S_t *space, const uint8_t *buf) { H5S_seloper_t op=H5S_SELECT_SET; /* Selection operation */ uint32_t rank; /* Rank of points */ size_t num_elem=0; /* Number of elements in selection */ hsize_t *coord=NULL, *tcoord; /* Pointer to array of elements */ unsigned i,j; /* local counting variables */ herr_t ret_value; /* return value */ FUNC_ENTER_NOAPI_NOINIT(H5S_point_deserialize); /* Check args */ assert(space); assert(buf); /* Deserialize points to select */ buf+=16; /* Skip over selection header */ UINT32DECODE(buf,rank); /* decode the rank of the point selection */ if(rank!=space->extent.rank) HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "rank of pointer does not match dataspace"); UINT32DECODE(buf,num_elem); /* decode the number of points */ /* Allocate space for the coordinates */ if((coord = H5MM_malloc(num_elem*rank*sizeof(hsize_t)))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate coordinate information"); /* Retrieve the coordinates from the buffer */ for(tcoord=coord,i=0; i followed by the next coordinate, etc. until all the point information in the selection have been put into the user's buffer. The points are returned in the order they will be interated through when a selection is read/written from/to disk. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_get_select_elem_pointlist(H5S_t *space, hsize_t startpoint, hsize_t numpoints, hsize_t *buf) { H5S_pnt_node_t *node; /* Point node */ int rank; /* Dataspace rank */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_get_select_elem_pointlist); assert(space); assert(buf); /* Get the dataspace extent rank */ rank=space->extent.rank; /* Get the head of the point list */ node=space->select.sel_info.pnt_lst->head; /* Iterate to the first point to return */ while(node!=NULL && startpoint>0) { startpoint--; node=node->next; } /* end while */ /* Iterate through the node, copying each hyperslab's information */ while(node!=NULL && numpoints>0) { HDmemcpy(buf,node->pnt,sizeof(hsize_t)*rank); buf+=rank; numpoints--; node=node->next; } /* end while */ FUNC_LEAVE_NOAPI(SUCCEED); } /* H5S_get_select_elem_pointlist() */ /*-------------------------------------------------------------------------- NAME H5Sget_select_elem_pointlist PURPOSE Get the list of element points currently selected USAGE herr_t H5Sget_select_elem_pointlist(dsid, hsize_t *buf) hid_t dsid; IN: Dataspace ID of selection to query hsize_t startpoint; IN: Element point to start with hsize_t numpoints; IN: Number of element points to get hsize_t *buf; OUT: List of element points selected RETURNS Non-negative on success, negative on failure DESCRIPTION Puts a list of the element points into the user's buffer. The points start with the 'startpoint'th block in the list of points and put 'numpoints' number of points into the user's buffer (or until the end of the list of points, whichever happen first) The point coordinates have the same dimensionality (rank) as the dataspace they are located within. The list of points is formatted as follows: followed by the next coordinate, etc. until all the point information in the selection have been put into the user's buffer. The points are returned in the order they will be interated through when a selection is read/written from/to disk. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5Sget_select_elem_pointlist(hid_t spaceid, hsize_t startpoint, hsize_t numpoints, hsize_t *buf) { H5S_t *space = NULL; /* Dataspace to modify selection of */ herr_t ret_value; /* return value */ FUNC_ENTER_API(H5Sget_select_elem_pointlist, FAIL); H5TRACE4("e","ihh*h",spaceid,startpoint,numpoints,buf); /* Check args */ if(buf==NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pointer"); if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); if(H5S_GET_SELECT_TYPE(space)!=H5S_SEL_POINTS) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a point selection"); ret_value = H5S_get_select_elem_pointlist(space,startpoint,numpoints,buf); done: FUNC_LEAVE_API(ret_value); } /* H5Sget_select_elem_pointlist() */ /*-------------------------------------------------------------------------- NAME H5S_point_bounds PURPOSE Gets the bounding box containing the selection. USAGE herr_t H5S_point_bounds(space, start, end) H5S_t *space; IN: Dataspace pointer of selection to query hsize_t *start; OUT: Starting coordinate of bounding box hsize_t *end; OUT: Opposite coordinate of bounding box RETURNS Non-negative on success, negative on failure DESCRIPTION Retrieves the bounding box containing the current selection and places it into the user's buffers. The start and end buffers must be large enough to hold the dataspace rank number of coordinates. The bounding box exactly contains the selection, ie. if a 2-D element selection is currently defined with the following points: (4,5), (6,8) (10,7), the bounding box with be (4, 5), (10, 8). The bounding box calculations _does_ include the current offset of the selection within the dataspace extent. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_point_bounds(const H5S_t *space, hsize_t *start, hsize_t *end) { H5S_pnt_node_t *node; /* Point node */ int rank; /* Dataspace rank */ int i; /* index variable */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5S_point_bounds); assert(space); assert(start); assert(end); /* Get the dataspace extent rank */ rank=space->extent.rank; /* Set the start and end arrays up */ for(i=0; iselect.sel_info.pnt_lst->head; while(node!=NULL) { for(i=0; ipnt[i]+space->select.offset[i])<0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "offset moves selection out of bounds") if(start[i]>(node->pnt[i]+space->select.offset[i])) start[i]=node->pnt[i]+space->select.offset[i]; if(end[i]<(node->pnt[i]+space->select.offset[i])) end[i]=node->pnt[i]+space->select.offset[i]; } /* end for */ node=node->next; } /* end while */ done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_point_bounds() */ /*-------------------------------------------------------------------------- NAME H5S_point_is_contiguous PURPOSE Check if a point selection is contiguous within the dataspace extent. USAGE htri_t H5S_point_is_contiguous(space) H5S_t *space; IN: Dataspace pointer to check RETURNS TRUE/FALSE/FAIL DESCRIPTION Checks to see if the current selection in the dataspace is contiguous. This is primarily used for reading the entire selection in one swoop. This code currently doesn't properly check for contiguousness when there is more than one point, as that would take a lot of extra coding that we don't need now. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static htri_t H5S_point_is_contiguous(const H5S_t *space) { htri_t ret_value; /* return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_is_contiguous); assert(space); /* One point is definitely contiguous */ if(space->select.num_elem==1) ret_value=TRUE; else /* More than one point might be contiguous, but it's complex to check and we don't need it right now */ ret_value=FALSE; FUNC_LEAVE_NOAPI(ret_value); } /* H5S_point_is_contiguous() */ /*-------------------------------------------------------------------------- NAME H5S_point_is_single PURPOSE Check if a point selection is single within the dataspace extent. USAGE htri_t H5S_point_is_single(space) H5S_t *space; IN: Dataspace pointer to check RETURNS TRUE/FALSE/FAIL DESCRIPTION Checks to see if the current selection in the dataspace is a single block. This is primarily used for reading the entire selection in one swoop. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static htri_t H5S_point_is_single(const H5S_t *space) { htri_t ret_value; /* return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_is_single); assert(space); /* One point is definitely 'single' :-) */ if(space->select.num_elem==1) ret_value=TRUE; else ret_value=FALSE; FUNC_LEAVE_NOAPI(ret_value); } /* H5S_point_is_single() */ /*-------------------------------------------------------------------------- NAME H5S_point_is_regular PURPOSE Check if a point selection is "regular" USAGE htri_t H5S_point_is_regular(space) const H5S_t *space; IN: Dataspace pointer to check RETURNS TRUE/FALSE/FAIL DESCRIPTION Checks to see if the current selection in a dataspace is the a regular pattern. This is primarily used for reading the entire selection in one swoop. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS Doesn't check for points selected to be next to one another in a regular pattern yet. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static htri_t H5S_point_is_regular(const H5S_t *space) { htri_t ret_value; /* return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_is_regular); /* Check args */ assert(space); /* Only simple check for regular points for now... */ if(space->select.num_elem==1) ret_value=TRUE; else ret_value=FALSE; FUNC_LEAVE_NOAPI(ret_value); } /* H5S_point_is_regular() */ /*-------------------------------------------------------------------------- NAME H5Sselect_elements PURPOSE Specify a series of elements in the dataspace to select USAGE herr_t H5Sselect_elements(dsid, op, num_elem, coord) hid_t dsid; IN: Dataspace ID of selection to modify H5S_seloper_t op; IN: Operation to perform on current selection size_t num_elem; IN: Number of elements in COORD array. const hsize_t **coord; IN: The location of each element selected RETURNS Non-negative on success/Negative on failure DESCRIPTION This function selects array elements to be included in the selection for the dataspace. The COORD array is a 2-D array of size by NUM_ELEM (ie. a list of coordinates in the dataspace). The order of the element coordinates in the COORD array specifies the order that the array elements are iterated through when I/O is performed. Duplicate coordinates are not checked for. The selection operator, OP, determines how the new selection is to be combined with the existing selection for the dataspace. Currently, only H5S_SELECT_SET is supported, which replaces the existing selection with the one defined in this call. When operators other than H5S_SELECT_SET are used to combine a new selection with an existing selection, the selection ordering is reset to 'C' array ordering. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5Sselect_elements(hid_t spaceid, H5S_seloper_t op, size_t num_elem, const hsize_t **coord) { H5S_t *space = NULL; /* Dataspace to modify selection of */ herr_t ret_value; /* return value */ FUNC_ENTER_API(H5Sselect_elements, FAIL); H5TRACE4("e","iSsz**h",spaceid,op,num_elem,coord); /* Check args */ if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace"); if (H5S_SCALAR==H5S_GET_EXTENT_TYPE(space)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "point doesn't support H5S_SCALAR space"); if(coord==NULL || num_elem==0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "elements not specified"); if(!(op==H5S_SELECT_SET || op==H5S_SELECT_APPEND || op==H5S_SELECT_PREPEND)) HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "unsupported operation attempted"); /* Call the real element selection routine */ if((ret_value=H5S_select_elements(space,op,num_elem,coord))<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't select elements"); done: FUNC_LEAVE_API(ret_value); } /* H5Sselect_elements() */ /*-------------------------------------------------------------------------- NAME H5S_point_get_seq_list PURPOSE Create a list of offsets & lengths for a selection USAGE herr_t H5S_point_get_seq_list(space,flags,iter,maxseq,maxelem,nseq,nelem,off,len) H5S_t *space; IN: Dataspace containing selection to use. unsigned flags; IN: Flags for extra information about operation H5S_sel_iter_t *iter; IN/OUT: Selection iterator describing last position of interest in selection. size_t maxseq; IN: Maximum number of sequences to generate size_t maxelem; IN: Maximum number of elements to include in the generated sequences size_t *nseq; OUT: Actual number of sequences generated size_t *nelem; OUT: Actual number of elements in sequences generated hsize_t *off; OUT: Array of offsets size_t *len; OUT: Array of lengths RETURNS Non-negative on success/Negative on failure. DESCRIPTION Use the selection in the dataspace to generate a list of byte offsets and lengths for the region(s) selected. Start/Restart from the position in the ITER parameter. The number of sequences generated is limited by the MAXSEQ parameter and the number of sequences actually generated is stored in the NSEQ parameter. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_point_get_seq_list(const H5S_t *space, unsigned flags, H5S_sel_iter_t *iter, size_t maxseq, size_t maxelem, size_t *nseq, size_t *nelem, hsize_t *off, size_t *len) { size_t io_left; /* The number of bytes left in the selection */ size_t start_io_left; /* The initial number of bytes left in the selection */ H5S_pnt_node_t *node; /* Point node */ hsize_t dims[H5O_LAYOUT_NDIMS]; /* Total size of memory buf */ int ndims; /* Dimensionality of space*/ hsize_t acc; /* Coordinate accumulator */ hsize_t loc; /* Coordinate offset */ size_t curr_seq; /* Current sequence being operated on */ int i; /* Local index variable */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_NOAPI_NOINIT(H5S_point_get_seq_list); /* Check args */ assert(space); assert(iter); assert(maxseq>0); assert(maxelem>0); assert(nseq); assert(nelem); assert(off); assert(len); /* Choose the minimum number of bytes to sequence through */ H5_CHECK_OVERFLOW(iter->elmt_left,hsize_t,size_t); start_io_left=io_left=(size_t)MIN(iter->elmt_left,maxelem); /* Get the dataspace dimensions */ if ((ndims=H5S_get_simple_extent_dims (space, dims, NULL))<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to retrieve data space dimensions"); /* Walk through the points in the selection, starting at the current */ /* location in the iterator */ node=iter->u.pnt.curr; curr_seq=0; while(node!=NULL) { /* Compute the offset of each selected point in the buffer */ for(i=ndims-1,acc=iter->elmt_size,loc=0; i>=0; i--) { loc+=(node->pnt[i]+space->select.offset[i])*acc; acc*=dims[i]; } /* end for */ /* Check if this is a later point in the selection */ if(curr_seq>0) { /* If a sorted sequence is requested, make certain we don't go backwards in the offset */ if((flags&H5S_GET_SEQ_LIST_SORTED) && locelmt_size; } /* end if */ else { /* Add a new sequence */ off[curr_seq]=loc; len[curr_seq]=iter->elmt_size; /* Increment sequence count */ curr_seq++; } /* end else */ } /* end if */ else { /* Add a new sequence */ off[curr_seq]=loc; len[curr_seq]=iter->elmt_size; /* Increment sequence count */ curr_seq++; } /* end else */ /* Decrement number of elements left to process */ io_left--; /* Move the iterator */ iter->u.pnt.curr=node->next; iter->elmt_left--; /* Check if we're finished with all sequences */ if(curr_seq==maxseq) break; /* Check if we're finished with all the elements available */ if(io_left==0) break; /* Advance to the next point */ node=node->next; } /* end while */ /* Set the number of sequences generated */ *nseq=curr_seq; /* Set the number of elements used */ *nelem=start_io_left-io_left; done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5S_point_get_seq_list() */ xdmf-3.0+git20160803/Utilities/hdf5/H5Opline.c0000640000175000017500000003574213003006557020475 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Robb Matzke * Wednesday, April 15, 1998 * * Purpose: Data filter pipeline message. */ #define H5O_PACKAGE /*suppress error about including H5Opkg */ #include "H5private.h" #include "H5Eprivate.h" #include "H5FLprivate.h" /*Free Lists */ #include "H5MMprivate.h" #include "H5Opkg.h" /* Object header functions */ #define H5O_PLINE_VERSION 1 static herr_t H5O_pline_encode (H5F_t *f, uint8_t *p, const void *mesg); static void *H5O_pline_decode (H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t *sh); static void *H5O_pline_copy (const void *_mesg, void *_dest, unsigned update_flags); static size_t H5O_pline_size (const H5F_t *f, const void *_mesg); static herr_t H5O_pline_reset (void *_mesg); static herr_t H5O_pline_free (void *_mesg); static herr_t H5O_pline_debug (H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * stream, int indent, int fwidth); /* This message derives from H5O */ const H5O_class_t H5O_PLINE[1] = {{ H5O_PLINE_ID, /* message id number */ "filter pipeline", /* message name for debugging */ sizeof(H5O_pline_t), /* native message size */ H5O_pline_decode, /* decode message */ H5O_pline_encode, /* encode message */ H5O_pline_copy, /* copy the native value */ H5O_pline_size, /* size of raw message */ H5O_pline_reset, /* reset method */ H5O_pline_free, /* free method */ NULL, /* file delete method */ NULL, /* link method */ NULL, /* get share method */ NULL, /* set share method */ H5O_pline_debug, /* debug the message */ }}; /* Declare a free list to manage the H5O_pline_t struct */ H5FL_DEFINE(H5O_pline_t); /*------------------------------------------------------------------------- * Function: H5O_pline_decode * * Purpose: Decodes a filter pipeline message. * * Return: Success: Ptr to the native message. * * Failure: NULL * * Programmer: Robb Matzke * Wednesday, April 15, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static void * H5O_pline_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const uint8_t *p, H5O_shared_t UNUSED *sh) { H5O_pline_t *pline = NULL; void *ret_value; unsigned version; size_t i, j, n, name_length; FUNC_ENTER_NOAPI_NOINIT(H5O_pline_decode); /* check args */ assert(p); /* Decode */ if (NULL==(pline = H5FL_CALLOC(H5O_pline_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); version = *p++; if (version!=H5O_PLINE_VERSION) HGOTO_ERROR(H5E_PLINE, H5E_CANTLOAD, NULL, "bad version number for filter pipeline message"); pline->nused = *p++; if (pline->nused>H5Z_MAX_NFILTERS) HGOTO_ERROR(H5E_PLINE, H5E_CANTLOAD, NULL, "filter pipeline message has too many filters"); p += 6; /*reserved*/ pline->nalloc = pline->nused; pline->filter = H5MM_calloc(pline->nalloc*sizeof(pline->filter[0])); if (NULL==pline->filter) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); for (i=0; inused; i++) { UINT16DECODE(p, pline->filter[i].id); UINT16DECODE(p, name_length); if (name_length % 8) HGOTO_ERROR(H5E_PLINE, H5E_CANTLOAD, NULL, "filter name length is not a multiple of eight"); UINT16DECODE(p, pline->filter[i].flags); UINT16DECODE(p, pline->filter[i].cd_nelmts); if (name_length) { /* * Get the name, allocating an extra byte for an extra null * terminator just in case there isn't one in the file (there * should be, but to be safe...) */ pline->filter[i].name = H5MM_malloc(name_length+1); HDmemcpy(pline->filter[i].name, p, name_length); pline->filter[i].name[name_length] = '\0'; p += name_length; } if ((n=pline->filter[i].cd_nelmts)) { /* * Read the client data values and the padding */ pline->filter[i].cd_values = H5MM_malloc(n*sizeof(unsigned)); if (NULL==pline->filter[i].cd_values) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for client data"); for (j=0; jfilter[i].cd_nelmts; j++) UINT32DECODE(p, pline->filter[i].cd_values[j]); if (pline->filter[i].cd_nelmts % 2) p += 4; /*padding*/ } } /* Set return value */ ret_value = pline; done: if (NULL==ret_value && pline) { if (pline->filter) { for (i=0; inused; i++) { H5MM_xfree(pline->filter[i].name); H5MM_xfree(pline->filter[i].cd_values); } H5MM_xfree(pline->filter); } H5FL_FREE(H5O_pline_t,pline); } FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_pline_encode * * Purpose: Encodes message MESG into buffer P. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Wednesday, April 15, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_pline_encode (H5F_t UNUSED *f, uint8_t *p/*out*/, const void *mesg) { const H5O_pline_t *pline = (const H5O_pline_t*)mesg; size_t i, j, name_length; const char *name=NULL; H5Z_class_t *cls=NULL; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_pline_encode); /* Check args */ assert (p); assert (mesg); *p++ = H5O_PLINE_VERSION; *p++ = (uint8_t)(pline->nused); *p++ = 0; /*reserved 1*/ *p++ = 0; /*reserved 2*/ *p++ = 0; /*reserved 3*/ *p++ = 0; /*reserved 4*/ *p++ = 0; /*reserved 5*/ *p++ = 0; /*reserved 6*/ for (i=0; inused; i++) { /* * Get the filter name. If the pipeline message has a name in it then * use that one. Otherwise try to look up the filter and get the name * as it was registered. */ if (NULL==(name=pline->filter[i].name) && (cls=H5Z_find(pline->filter[i].id))) name = cls->name; name_length = name ? HDstrlen(name)+1 : 0; /* Encode the filter */ UINT16ENCODE(p, pline->filter[i].id); UINT16ENCODE(p, H5O_ALIGN(name_length)); UINT16ENCODE(p, pline->filter[i].flags); UINT16ENCODE(p, pline->filter[i].cd_nelmts); if (name_length>0) { HDmemcpy(p, name, name_length); p += name_length; while (name_length++ % 8) *p++ = 0; } for (j=0; jfilter[i].cd_nelmts; j++) UINT32ENCODE(p, pline->filter[i].cd_values[j]); if (pline->filter[i].cd_nelmts % 2) UINT32ENCODE(p, 0); } FUNC_LEAVE_NOAPI(SUCCEED); } /*------------------------------------------------------------------------- * Function: H5O_pline_copy * * Purpose: Copies a filter pipeline message from SRC to DST allocating * DST if necessary. If DST is already allocated then we assume * that it isn't initialized. * * Return: Success: Ptr to DST or allocated result. * * Failure: NULL * * Programmer: Robb Matzke * Wednesday, April 15, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static void * H5O_pline_copy (const void *_src, void *_dst/*out*/, unsigned UNUSED update_flags) { const H5O_pline_t *src = (const H5O_pline_t *)_src; H5O_pline_t *dst = (H5O_pline_t *)_dst; size_t i; H5O_pline_t *ret_value; FUNC_ENTER_NOAPI_NOINIT(H5O_pline_copy); if (!dst && NULL==(dst = H5FL_MALLOC (H5O_pline_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); *dst = *src; dst->nalloc = dst->nused; if (dst->nalloc>0) { dst->filter = H5MM_calloc(dst->nalloc * sizeof(dst->filter[0])); if (NULL==dst->filter) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); } else { dst->filter = NULL; } for (i=0; inused; i++) { dst->filter[i] = src->filter[i]; if (src->filter[i].name) { dst->filter[i].name = H5MM_xstrdup(src->filter[i].name); } if (src->filter[i].cd_nelmts>0) { dst->filter[i].cd_values = H5MM_malloc(src->filter[i].cd_nelmts* sizeof(unsigned)); if (NULL==dst->filter[i].cd_values) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); HDmemcpy (dst->filter[i].cd_values, src->filter[i].cd_values, src->filter[i].cd_nelmts * sizeof(unsigned)); } } /* Set return value */ ret_value = dst; done: if (!ret_value && dst) { if (dst->filter) { for (i=0; inused; i++) { H5MM_xfree(dst->filter[i].name); H5MM_xfree(dst->filter[i].cd_values); } H5MM_xfree(dst->filter); } if (!_dst) H5FL_FREE(H5O_pline_t,dst); } FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_pline_size * * Purpose: Determines the size of a raw filter pipeline message. * * Return: Success: Size of message. * * Failure: zero * * Programmer: Robb Matzke * Wednesday, April 15, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static size_t H5O_pline_size (const H5F_t UNUSED *f, const void *mesg) { const H5O_pline_t *pline = (const H5O_pline_t*)mesg; size_t i, name_len; const char *name = NULL; H5Z_class_t *cls = NULL; size_t ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_pline_size); /* Message header */ ret_value = 1 + /*version */ 1 + /*number of filters */ 6; /*reserved */ for (i=0; inused; i++) { /* Get the name of the filter, same as done with H5O_pline_encode() */ if (NULL==(name=pline->filter[i].name) && (cls=H5Z_find(pline->filter[i].id))) name = cls->name; name_len = name ? HDstrlen(name)+1 : 0; ret_value += 2 + /*filter identification number */ 2 + /*name length */ 2 + /*flags */ 2 + /*number of client data values */ H5O_ALIGN(name_len); /*length of the filter name */ ret_value += pline->filter[i].cd_nelmts * 4; if (pline->filter[i].cd_nelmts % 2) ret_value += 4; } FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_pline_reset * * Purpose: Resets a filter pipeline message by clearing all filters. * The MESG buffer is not freed. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Wednesday, April 15, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_pline_reset (void *mesg) { H5O_pline_t *pline = (H5O_pline_t*)mesg; size_t i; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_pline_reset); assert (pline); for (i=0; inused; i++) { H5MM_xfree(pline->filter[i].name); H5MM_xfree(pline->filter[i].cd_values); } if(pline->filter) H5MM_xfree(pline->filter); HDmemset(pline, 0, sizeof *pline); FUNC_LEAVE_NOAPI(SUCCEED); } /*------------------------------------------------------------------------- * Function: H5O_pline_free * * Purpose: Free's the message * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Saturday, March 11, 2000 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_pline_free (void *mesg) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_pline_free); assert (mesg); H5FL_FREE(H5O_pline_t,mesg); FUNC_LEAVE_NOAPI(SUCCEED); } /*------------------------------------------------------------------------- * Function: H5O_pline_debug * * Purpose: Prints debugging information for filter pipeline message MESG * on output stream STREAM. Each line is indented INDENT * characters and the field name takes up FWIDTH characters. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Wednesday, April 15, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_pline_debug (H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *mesg, FILE *stream, int indent, int fwidth) { const H5O_pline_t *pline = (const H5O_pline_t *)mesg; size_t i, j; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_pline_debug); /* check args */ assert(f); assert(pline); assert(stream); assert(indent >= 0); assert(fwidth >= 0); fprintf(stream, "%*s%-*s %lu/%lu\n", indent, "", fwidth, "Number of filters:", (unsigned long)(pline->nused), (unsigned long)(pline->nalloc)); for (i=0; inused; i++) { char name[32]; sprintf(name, "Filter at position %lu", (unsigned long)i); fprintf(stream, "%*s%-*s\n", indent, "", fwidth, name); fprintf(stream, "%*s%-*s 0x%04x\n", indent+3, "", MAX(0, fwidth-3), "Filter identification:", (unsigned)(pline->filter[i].id)); if (pline->filter[i].name) { fprintf(stream, "%*s%-*s \"%s\"\n", indent+3, "", MAX(0, fwidth-3), "Filter name:", pline->filter[i].name); } else { fprintf(stream, "%*s%-*s NONE\n", indent+3, "", MAX(0, fwidth-3), "Filter name:"); } fprintf(stream, "%*s%-*s 0x%04x\n", indent+3, "", MAX(0, fwidth-3), "Flags:", (unsigned)(pline->filter[i].flags)); fprintf(stream, "%*s%-*s %lu\n", indent+3, "", MAX(0, fwidth-3), "Num CD values:", (unsigned long)(pline->filter[i].cd_nelmts)); for (j=0; jfilter[i].cd_nelmts; j++) { char field_name[32]; sprintf(field_name, "CD value %lu", (unsigned long)j); fprintf(stream, "%*s%-*s %lu\n", indent+6, "", MAX(0, fwidth-6), field_name, (unsigned long)(pline->filter[i].cd_values[j])); } } FUNC_LEAVE_NOAPI(SUCCEED); } xdmf-3.0+git20160803/Utilities/hdf5/H5FDstream.h0000640000175000017500000000716413003006557020756 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Copyright © 2000 The author. * The author prefers this code not be used for military purposes. * * * Author: Thomas Radke * Tuesday, September 12, 2000 * * Purpose: The public header file for the Stream Virtual File Driver. * * Modifications: * Thomas Radke, Thursday, October 26, 2000 * Added support for Windows. * */ #ifndef H5FDstream_H #define H5FDstream_H #ifdef H5_HAVE_STREAM # define H5FD_STREAM (H5FD_stream_init()) #else # define H5FD_STREAM (-1) #endif /*H5_HAVE_STREAM */ #ifdef H5_HAVE_STREAM /* check what sockets type we have (Unix or Windows sockets) Note that only MS compilers require to use Windows sockets but gcc under Windows does not. */ #if ! defined(H5_HAVE_WINSOCK_H) || defined(__GNUC__) #define H5FD_STREAM_HAVE_UNIX_SOCKETS 1 #endif /* define the data type for socket descriptors and the constant indicating an invalid descriptor */ #ifdef H5FD_STREAM_HAVE_UNIX_SOCKETS #define H5FD_STREAM_SOCKET_TYPE int #define H5FD_STREAM_INVALID_SOCKET -1 #else #include #define H5FD_STREAM_SOCKET_TYPE SOCKET #define H5FD_STREAM_INVALID_SOCKET INVALID_SOCKET #endif #ifdef __cplusplus extern "C" { #endif /* prototype for read broadcast callback routine */ typedef int (*H5FD_stream_broadcast_t) (unsigned char **file, haddr_t *len, void *arg); /* driver-specific file access properties */ typedef struct H5FD_stream_fapl_t { size_t increment; /* how much to grow memory in reallocs */ H5FD_STREAM_SOCKET_TYPE socket; /* externally provided socket descriptor*/ hbool_t do_socket_io; /* do I/O on socket */ int backlog; /* backlog argument for listen call */ H5FD_stream_broadcast_t broadcast_fn; /* READ broadcast callback */ void *broadcast_arg; /* READ broadcast callback user argument*/ unsigned int maxhunt; /* how many more ports to try to bind to*/ unsigned short int port; /* port a socket was bound/connected to */ } H5FD_stream_fapl_t; /* prototypes of exported functions */ H5_DLL hid_t H5FD_stream_init (void); H5_DLL void H5FD_stream_term(void); H5_DLL herr_t H5Pset_fapl_stream (hid_t fapl_id, H5FD_stream_fapl_t *fapl); H5_DLL herr_t H5Pget_fapl_stream (hid_t fapl_id, H5FD_stream_fapl_t *fapl /*out*/ ); #ifdef __cplusplus } #endif #endif /* H5_HAVE_STREAM */ #endif /* H5FDstream_H */ xdmf-3.0+git20160803/Utilities/hdf5/H5Tnative.c0000640000175000017500000010474113003006557020655 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Module Info: This module contains the functionality for querying * a "native" datatype for the H5T interface. */ #define H5T_PACKAGE /*suppress error about including H5Tpkg */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5T_init_native_interface #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Iprivate.h" /* IDs */ #include "H5Pprivate.h" /* Property lists */ #include "H5MMprivate.h" /* Memory management */ #include "H5Tpkg.h" /* Datatypes */ /* Static local functions */ static H5T_t *H5T_get_native_type(H5T_t *dt, H5T_direction_t direction, size_t *struct_align, size_t *offset, size_t *comp_size); static H5T_t *H5T_get_native_integer(size_t prec, H5T_sign_t sign, H5T_direction_t direction, size_t *struct_align, size_t *offset, size_t *comp_size); static H5T_t *H5T_get_native_float(size_t size, H5T_direction_t direction, size_t *struct_align, size_t *offset, size_t *comp_size); static herr_t H5T_cmp_offset(size_t *comp_size, size_t *offset, size_t elem_size, size_t nelems, size_t align, size_t *struct_align); /*-------------------------------------------------------------------------- NAME H5T_init_native_interface -- Initialize interface-specific information USAGE herr_t H5T_init_native_interface() RETURNS Non-negative on success/Negative on failure DESCRIPTION Initializes any interface-specific data or routines. (Just calls H5T_init_iterface currently). --------------------------------------------------------------------------*/ static herr_t H5T_init_native_interface(void) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_init_native_interface) FUNC_LEAVE_NOAPI(H5T_init()) } /* H5T_init_native_interface() */ /*------------------------------------------------------------------------- * Function: H5Tget_native_type * * Purpose: High-level API to return the native type of a datatype. * The native type is chosen by matching the size and class of * querried datatype from the following native premitive * datatypes: * H5T_NATIVE_CHAR H5T_NATIVE_UCHAR * H5T_NATIVE_SHORT H5T_NATIVE_USHORT * H5T_NATIVE_INT H5T_NATIVE_UINT * H5T_NATIVE_LONG H5T_NATIVE_ULONG * H5T_NATIVE_LLONG H5T_NATIVE_ULLONG * * H5T_NATIVE_FLOAT * H5T_NATIVE_DOUBLE * H5T_NATIVE_LDOUBLE * * Compound, array, enum, and VL types all choose among these * types for theire members. Time, Bifield, Opaque, Reference * types are only copy out. * * Return: Success: Returns the native data type if successful. * * Failure: negative * * Programmer: Raymond Lu * Oct 3, 2002 * * Modifications: * *------------------------------------------------------------------------- */ hid_t H5Tget_native_type(hid_t type_id, H5T_direction_t direction) { H5T_t *dt; /* Datatype to create native datatype from */ H5T_t *new_dt=NULL; /* Datatype for native datatype created */ size_t comp_size=0; /* Compound datatype's size */ hid_t ret_value; /* Return value */ FUNC_ENTER_API(H5Tget_native_type, FAIL) H5TRACE2("i","iTd",type_id,direction); /* check argument */ if(NULL==(dt=H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") if(direction!=H5T_DIR_DEFAULT && direction!=H5T_DIR_ASCEND && direction!=H5T_DIR_DESCEND) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not valid direction value") if((new_dt = H5T_get_native_type(dt, direction, NULL, NULL, &comp_size))==NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "cannot retrieve native type") if((ret_value=H5I_register(H5I_DATATYPE, new_dt)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register data type") done: /* Error cleanup */ if(ret_value<0) { if(new_dt) if(H5T_close(new_dt)<0) HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to release datatype") } /* end if */ FUNC_LEAVE_API(ret_value) } /*------------------------------------------------------------------------- * Function: H5T_get_native_type * * Purpose: Returns the native type of a datatype. * * Return: Success: Returns the native data type if successful. * * Failure: negative * * Programmer: Raymond Lu * Oct 3, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static H5T_t* H5T_get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_align, size_t *offset, size_t *comp_size) { H5T_t *dt; /* Datatype to make native */ H5T_class_t h5_class; /* Class of datatype to make native */ size_t size; /* Size of datatype to make native */ size_t prec; /* Precision of datatype to make native */ int snmemb; /* Number of members in compound & enum types */ unsigned nmemb; /* Number of members in compound & enum types */ H5T_t *super_type; /* Super type of VL, array and enum datatypes */ H5T_t *nat_super_type; /* Native form of VL, array & enum super datatype */ H5T_t *new_type=NULL; /* New native datatype */ unsigned i; /* Local index variable */ H5T_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5T_get_native_type, NULL) assert(dtype); if((h5_class = H5T_get_class(dtype, FALSE))==H5T_NO_CLASS) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a valid class") if((size = H5T_get_size(dtype))==0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a valid size") switch(h5_class) { case H5T_INTEGER: { H5T_sign_t sign; /* Signedness of integer type */ if((sign = H5T_get_sign(dtype))==H5T_SGN_ERROR) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a valid signess") prec = dtype->shared->u.atomic.prec; if((ret_value = H5T_get_native_integer(prec, sign, direction, struct_align, offset, comp_size))==NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve integer type") } break; case H5T_FLOAT: if((ret_value = H5T_get_native_float(size, direction, struct_align, offset, comp_size))==NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type") break; case H5T_STRING: if((ret_value=H5T_copy(dtype, H5T_COPY_TRANSIENT))==NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type") if(H5T_IS_VL_STRING(dtype->shared)) { /* Update size, offset and compound alignment for parent. */ if(H5T_cmp_offset(comp_size, offset, sizeof(char *), 1, H5T_POINTER_COMP_ALIGN_g, struct_align)<0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") } else { /* Update size, offset and compound alignment for parent. */ if(H5T_cmp_offset(comp_size, offset, sizeof(char), size, H5T_NATIVE_SCHAR_COMP_ALIGN_g, struct_align)<0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") } break; /* These 2 types will be supported in the future. Simply return "not supported" * message for now.*/ case H5T_TIME: HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "time type is not supported yet") case H5T_BITFIELD: HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "bit field type is not supported yet") case H5T_OPAQUE: if((ret_value=H5T_copy(dtype, H5T_COPY_TRANSIENT))==NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type") /* Update size, offset and compound alignment for parent. */ if(H5T_cmp_offset(comp_size, offset, sizeof(char), size, H5T_NATIVE_SCHAR_COMP_ALIGN_g, struct_align)<0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") break; case H5T_REFERENCE: { size_t align; size_t ref_size; int not_equal; if((ret_value=H5T_copy(dtype, H5T_COPY_TRANSIENT))==NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type") /* Decide if the data type is object or dataset region reference. */ if(NULL==(dt=H5I_object(H5T_STD_REF_OBJ_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type") not_equal = H5T_cmp(ret_value, dt, FALSE); /* Update size, offset and compound alignment for parent. */ if(!not_equal) { align = H5T_HOBJREF_COMP_ALIGN_g; ref_size = sizeof(hobj_ref_t); } else { align = H5T_HDSETREGREF_COMP_ALIGN_g; ref_size = sizeof(hdset_reg_ref_t); } if(H5T_cmp_offset(comp_size, offset, ref_size, 1, align, struct_align)<0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") } break; case H5T_COMPOUND: { H5T_t *memb_type; /* Datatype of member */ H5T_t **memb_list; /* List of compound member IDs */ size_t *memb_offset; /* List of member offsets in compound type, including member size and alignment */ size_t children_size=0;/* Total size of compound members */ size_t children_st_align=0; /* The max alignment among compound members. This'll be the compound alignment */ char **comp_mname; /* List of member names in compound type */ if((snmemb = H5T_get_nmembers(dtype))<=0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "compound data type doesn't have any member") H5_ASSIGN_OVERFLOW(nmemb,snmemb,int,unsigned); if((memb_list = (H5T_t**)H5MM_malloc(nmemb*sizeof(H5T_t*)))==NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory") if((memb_offset = (size_t*)H5MM_calloc(nmemb*sizeof(size_t)))==NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory") if((comp_mname = (char**)H5MM_malloc(nmemb*sizeof(char*)))==NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory") /* Construct child compound type and retrieve a list of their IDs, offsets, total size, and alignment for compound type. */ for(i=0; i=H5Tget_precision(H5T_NATIVE_LLONG)) { match=H5T_NATIVE_INT_MATCH_LLONG; native_size = sizeof(long_long); } else if(prec>=H5Tget_precision(H5T_NATIVE_LONG)) { if(prec==H5Tget_precision(H5T_NATIVE_LONG)) { match=H5T_NATIVE_INT_MATCH_LONG; native_size = sizeof(long); } else { match=H5T_NATIVE_INT_MATCH_LLONG; native_size = sizeof(long_long); } } else if(prec>=H5Tget_precision(H5T_NATIVE_INT)) { if(prec==H5Tget_precision(H5T_NATIVE_INT)) { match=H5T_NATIVE_INT_MATCH_INT; native_size = sizeof(int); } else { match=H5T_NATIVE_INT_MATCH_LONG; native_size = sizeof(long); } } else if(prec>=H5Tget_precision(H5T_NATIVE_SHORT)) { if(prec==H5Tget_precision(H5T_NATIVE_SHORT)) { match=H5T_NATIVE_INT_MATCH_SHORT; native_size = sizeof(short); } else { match=H5T_NATIVE_INT_MATCH_INT; native_size = sizeof(int); } } else if(prec>=H5Tget_precision(H5T_NATIVE_SCHAR)) { if(prec==H5Tget_precision(H5T_NATIVE_SCHAR)) { match=H5T_NATIVE_INT_MATCH_CHAR; native_size = sizeof(char); } else { match=H5T_NATIVE_INT_MATCH_SHORT; native_size = sizeof(short); } } else { /* If no native type matches the queried datatype, simply choose the type of smallest size. */ match=H5T_NATIVE_INT_MATCH_CHAR; native_size = sizeof(char); } } /* Set the appropriate native datatype information */ switch(match) { case H5T_NATIVE_INT_MATCH_CHAR: if(sign==H5T_SGN_2) tid = H5T_NATIVE_SCHAR; else tid = H5T_NATIVE_UCHAR; align = H5T_NATIVE_SCHAR_COMP_ALIGN_g; break; case H5T_NATIVE_INT_MATCH_SHORT: if(sign==H5T_SGN_2) tid = H5T_NATIVE_SHORT; else tid = H5T_NATIVE_USHORT; align = H5T_NATIVE_SHORT_COMP_ALIGN_g; break; case H5T_NATIVE_INT_MATCH_INT: if(sign==H5T_SGN_2) tid = H5T_NATIVE_INT; else tid = H5T_NATIVE_UINT; align = H5T_NATIVE_INT_COMP_ALIGN_g; break; case H5T_NATIVE_INT_MATCH_LONG: if(sign==H5T_SGN_2) tid = H5T_NATIVE_LONG; else tid = H5T_NATIVE_ULONG; align = H5T_NATIVE_LONG_COMP_ALIGN_g; break; case H5T_NATIVE_INT_MATCH_LLONG: if(sign==H5T_SGN_2) tid = H5T_NATIVE_LLONG; else tid = H5T_NATIVE_ULLONG; align = H5T_NATIVE_LLONG_COMP_ALIGN_g; break; case H5T_NATIVE_INT_MATCH_UNKNOWN: default: HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "Unknown native integer match") } /* end switch */ /* Create new native type */ assert(tid>=0); if(NULL==(dt=H5I_object(tid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type") if((ret_value=H5T_copy(dt, H5T_COPY_TRANSIENT))==NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot copy type") /* compute size and offset of compound type member. */ if(H5T_cmp_offset(comp_size, offset, native_size, 1, align, struct_align)<0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5T_get_native_float * * Purpose: Returns the native floatt type of a datatype. * * Return: Success: Returns the native data type if successful. * * Failure: negative * * Programmer: Raymond Lu * Oct 3, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static H5T_t* H5T_get_native_float(size_t size, H5T_direction_t direction, size_t *struct_align, size_t *offset, size_t *comp_size) { H5T_t *dt=NULL; /* Appropriate native datatype to copy */ hid_t tid=(-1); /* Datatype ID of appropriate native datatype */ size_t align=0; /* Alignment necessary for native datatype */ size_t native_size=0; /* Datatype size of the native type */ enum match_type { /* The different kinds of floating point types we can match */ H5T_NATIVE_FLOAT_MATCH_FLOAT, H5T_NATIVE_FLOAT_MATCH_DOUBLE, H5T_NATIVE_FLOAT_MATCH_LDOUBLE, H5T_NATIVE_FLOAT_MATCH_UNKNOWN } match=H5T_NATIVE_FLOAT_MATCH_UNKNOWN; H5T_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5T_get_native_float, NULL) assert(size>0); if(direction == H5T_DIR_DEFAULT || direction == H5T_DIR_ASCEND) { if(size<=sizeof(float)) { match=H5T_NATIVE_FLOAT_MATCH_FLOAT; native_size = sizeof(float); } else if(size<=sizeof(double)) { match=H5T_NATIVE_FLOAT_MATCH_DOUBLE; native_size = sizeof(double); } else if(size<=sizeof(long double)) { match=H5T_NATIVE_FLOAT_MATCH_LDOUBLE; native_size = sizeof(long double); } else { /* If not match, return the biggest datatype */ match=H5T_NATIVE_FLOAT_MATCH_LDOUBLE; native_size = sizeof(long double); } } else { if(size>=sizeof(long double)) { match=H5T_NATIVE_FLOAT_MATCH_LDOUBLE; native_size = sizeof(long double); } else if(size>=sizeof(double)) { if(size==sizeof(double)) { match=H5T_NATIVE_FLOAT_MATCH_DOUBLE; native_size = sizeof(double); } else { match=H5T_NATIVE_FLOAT_MATCH_LDOUBLE; native_size = sizeof(long double); } } else if(size>=sizeof(float)) { if(size==sizeof(float)) { match=H5T_NATIVE_FLOAT_MATCH_FLOAT; native_size = sizeof(float); } else { match=H5T_NATIVE_FLOAT_MATCH_DOUBLE; native_size = sizeof(double); } } else { match=H5T_NATIVE_FLOAT_MATCH_FLOAT; native_size = sizeof(float); } } /* Set the appropriate native floating point information */ switch(match) { case H5T_NATIVE_FLOAT_MATCH_FLOAT: tid = H5T_NATIVE_FLOAT; align = H5T_NATIVE_FLOAT_COMP_ALIGN_g; break; case H5T_NATIVE_FLOAT_MATCH_DOUBLE: tid = H5T_NATIVE_DOUBLE; align = H5T_NATIVE_DOUBLE_COMP_ALIGN_g; break; case H5T_NATIVE_FLOAT_MATCH_LDOUBLE: tid = H5T_NATIVE_LDOUBLE; align = H5T_NATIVE_LDOUBLE_COMP_ALIGN_g; break; case H5T_NATIVE_FLOAT_MATCH_UNKNOWN: default: HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "Unknown native floating-point match") } /* end switch */ /* Create new native type */ assert(tid>=0); if(NULL==(dt=H5I_object(tid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type") if((ret_value=H5T_copy(dt, H5T_COPY_TRANSIENT))==NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type") /* compute offset of compound type member. */ if(H5T_cmp_offset(comp_size, offset, native_size, 1, align, struct_align)<0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5T_cmp_offset * * Purpose: This function is only for convenience. It computes the * compound type size, offset of the member being considered * and the alignment for the whole compound type. * * Return: Success: Non-negative value. * * Failure: Negative value. * * Programmer: Raymond Lu * December 10, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5T_cmp_offset(size_t *comp_size, size_t *offset, size_t elem_size, size_t nelems, size_t align, size_t *struct_align) { herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5T_cmp_offset, FAIL) if(offset && comp_size) { if(align>1 && *comp_size%align) { /* Add alignment value */ *offset = *comp_size + (align - *comp_size%align); *comp_size += (align - *comp_size%align); } else *offset = *comp_size; /* compute size of compound type member. */ *comp_size += nelems*elem_size; } if(struct_align && *struct_align < align) *struct_align = align; done: FUNC_LEAVE_NOAPI(ret_value) } xdmf-3.0+git20160803/Utilities/hdf5/H5pubconf.h.cmake.in0000640000175000017500000000002513003006557022356 0ustar alastairalastair@HDF5_PUBLIC_CONFIG@ xdmf-3.0+git20160803/Utilities/hdf5/H5Oshared.c0000640000175000017500000004006113003006557020622 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Robb Matzke * Wednesday, April 1, 1998 * * Purpose: Functions that operate on a shared message. The shared * message doesn't ever actually appear in the object header as * a normal message. Instead, if a message is shared, the * H5O_FLAG_SHARED bit is set and the message body is that * defined here for H5O_SHARED. The message ID is the ID of the * pointed-to message and the pointed-to message is stored in * the global heap. */ #define H5F_PACKAGE /*suppress error about including H5Fpkg */ #define H5O_PACKAGE /*suppress error about including H5Opkg */ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* File access */ #include "H5Gprivate.h" /* Groups */ #include "H5MMprivate.h" /* Memory management */ #include "H5Opkg.h" /* Object headers */ static void *H5O_shared_decode (H5F_t*, hid_t dxpl_id, const uint8_t*, H5O_shared_t *sh); static herr_t H5O_shared_encode (H5F_t*, uint8_t*, const void*); static void *H5O_shared_copy(const void *_mesg, void *_dest, unsigned update_flags); static size_t H5O_shared_size (const H5F_t*, const void *_mesg); static herr_t H5O_shared_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link); static herr_t H5O_shared_link(H5F_t *f, hid_t dxpl_id, const void *_mesg); static herr_t H5O_shared_debug (H5F_t*, hid_t dxpl_id, const void*, FILE*, int, int); /* This message derives from H5O */ const H5O_class_t H5O_SHARED[1] = {{ H5O_SHARED_ID, /*message id number */ "shared", /*message name for debugging */ sizeof(H5O_shared_t), /*native message size */ H5O_shared_decode, /*decode method */ H5O_shared_encode, /*encode method */ H5O_shared_copy, /*copy the native value */ H5O_shared_size, /*size method */ NULL, /*no reset method */ NULL, /*no free method */ H5O_shared_delete, /*file delete method */ H5O_shared_link, /*link method */ NULL, /*get share method */ NULL, /*set share method */ H5O_shared_debug, /*debug method */ }}; /* Old version, with full symbol table entry as link for object header sharing */ #define H5O_SHARED_VERSION_1 1 /* New version, with just address of object as link for object header sharing */ #define H5O_SHARED_VERSION 2 /*------------------------------------------------------------------------- * Function: H5O_shared_read * * Purpose: Reads a message referred to by a shared message. * * Return: Success: Ptr to message in native format. The message * should be freed by calling H5O_reset(). If * MESG is a null pointer then the caller should * also call H5MM_xfree() on the return value * after calling H5O_reset(). * * Failure: NULL * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * Sep 24 2003 * * Modifications: * *------------------------------------------------------------------------- */ void * H5O_shared_read(H5F_t *f, hid_t dxpl_id, H5O_shared_t *shared, const H5O_class_t *type, void *mesg) { void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_shared_read); /* check args */ assert(f); assert(shared); assert(type); /* Get the shared message */ if (shared->in_gh) { void *tmp_buf, *tmp_mesg; if (NULL==(tmp_buf = H5HG_read (f, dxpl_id, &(shared->u.gh), NULL))) HGOTO_ERROR (H5E_OHDR, H5E_CANTLOAD, NULL, "unable to read shared message from global heap"); tmp_mesg = (type->decode)(f, dxpl_id, tmp_buf, shared); tmp_buf = H5MM_xfree (tmp_buf); if (!tmp_mesg) HGOTO_ERROR (H5E_OHDR, H5E_CANTLOAD, NULL, "unable to decode object header shared message"); if (mesg) { HDmemcpy (mesg, tmp_mesg, type->native_size); H5MM_xfree (tmp_mesg); } /* end if */ else ret_value = tmp_mesg; } /* end if */ else { ret_value = H5O_read_real(&(shared->u.ent), type, 0, mesg, dxpl_id); if (type->set_share && (type->set_share)(f, ret_value, shared)<0) HGOTO_ERROR (H5E_OHDR, H5E_CANTINIT, NULL, "unable to set sharing information"); } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5O_shared_read() */ /*------------------------------------------------------------------------- * Function: H5O_shared_link_adj * * Purpose: Changes the link count for the object referenced by a shared * message. * * Return: Success: New link count * * Failure: Negative * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * Sep 26 2003 * * Modifications: * *------------------------------------------------------------------------- */ static int H5O_shared_link_adj(H5F_t *f, hid_t dxpl_id, const H5O_shared_t *shared, int adjust) { int ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_shared_link_adj); /* check args */ assert(f); assert(shared); if (shared->in_gh) { /* * The shared message is stored in the global heap. * Adjust the reference count on the global heap message. */ if ((ret_value = H5HG_link (f, dxpl_id, &(shared->u.gh), adjust))<0) HGOTO_ERROR (H5E_OHDR, H5E_LINK, FAIL, "unable to adjust shared object link count"); } /* end if */ else { /* * The shared message is stored in some other object header. * The other object header must be in the same file as the * new object header. Adjust the reference count on that * object header. */ if (shared->u.ent.file->shared != f->shared) HGOTO_ERROR(H5E_OHDR, H5E_LINK, FAIL, "interfile hard links are not allowed"); if ((ret_value = H5O_link (&(shared->u.ent), adjust, dxpl_id))<0) HGOTO_ERROR (H5E_OHDR, H5E_LINK, FAIL, "unable to adjust shared object link count"); } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5O_shared_link_adj() */ /*------------------------------------------------------------------------- * Function: H5O_shared_decode * * Purpose: Decodes a shared object message and returns it. * * Return: Success: Ptr to a new shared object message. * * Failure: NULL * * Programmer: Robb Matzke * Thursday, April 2, 1998 * * Modifications: * Robb Matzke, 1998-07-20 * Added a version number to the beginning of the message. *------------------------------------------------------------------------- */ static void * H5O_shared_decode (H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *buf, H5O_shared_t UNUSED *sh) { H5O_shared_t *mesg=NULL; unsigned flags, version; void *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_shared_decode); /* Check args */ assert (f); assert (buf); assert (!sh); /* Decode */ if (NULL==(mesg = H5MM_calloc (sizeof(H5O_shared_t)))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); /* Version */ version = *buf++; if (version!=H5O_SHARED_VERSION_1 && version!=H5O_SHARED_VERSION) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for shared object message"); /* Get the shared information flags */ flags = *buf++; mesg->in_gh = (flags & 0x01); /* Skip reserved bytes (for version 1) */ if(version==H5O_SHARED_VERSION_1) buf += 6; /* Body */ if (mesg->in_gh) { H5F_addr_decode (f, &buf, &(mesg->u.gh.addr)); INT32DECODE (buf, mesg->u.gh.idx); } /* end if */ else { if(version==H5O_SHARED_VERSION_1) H5G_ent_decode (f, &buf, &(mesg->u.ent)); else { assert(version==H5O_SHARED_VERSION); H5F_addr_decode (f, &buf, &(mesg->u.ent.header)); mesg->u.ent.file=f; } /* end else */ } /* end else */ /* Set return value */ ret_value=mesg; done: if(ret_value==NULL) { if(mesg!=NULL) H5MM_xfree(mesg); } /* end if */ FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_shared_encode * * Purpose: Encodes message _MESG into buffer BUF. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Thursday, April 2, 1998 * * Modifications: * Robb Matzke, 1998-07-20 * Added a version number to the beginning of the message. * *------------------------------------------------------------------------- */ static herr_t H5O_shared_encode (H5F_t *f, uint8_t *buf/*out*/, const void *_mesg) { const H5O_shared_t *mesg = (const H5O_shared_t *)_mesg; unsigned flags; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_shared_encode); /* Check args */ assert (f); assert (buf); assert (mesg); /* Encode */ *buf++ = H5O_SHARED_VERSION; flags = mesg->in_gh ? 0x01 : 0x00; *buf++ = flags; #ifdef OLD_WAY *buf++ = 0; /*reserved 1*/ *buf++ = 0; /*reserved 2*/ *buf++ = 0; /*reserved 3*/ *buf++ = 0; /*reserved 4*/ *buf++ = 0; /*reserved 5*/ *buf++ = 0; /*reserved 6*/ if (mesg->in_gh) { H5F_addr_encode (f, &buf, mesg->u.gh.addr); INT32ENCODE (buf, mesg->u.gh.idx); } /* end if */ else H5G_ent_encode (f, &buf, &(mesg->u.ent)); #else /* OLD_WAY */ if (mesg->in_gh) { H5F_addr_encode (f, &buf, mesg->u.gh.addr); INT32ENCODE (buf, mesg->u.gh.idx); } /* end if */ else H5F_addr_encode (f, &buf, mesg->u.ent.header); #endif /* OLD_WAY */ FUNC_LEAVE_NOAPI(SUCCEED); } /*------------------------------------------------------------------------- * Function: H5O_shared_copy * * Purpose: Copies a message from _MESG to _DEST, allocating _DEST if * necessary. * * Return: Success: Ptr to _DEST * * Failure: NULL * * Programmer: Quincey Koziol * koziol@ncsa.uiuc.edu * Sep 26 2003 * * Modifications: * *------------------------------------------------------------------------- */ static void * H5O_shared_copy(const void *_mesg, void *_dest, unsigned UNUSED update_flags) { const H5O_shared_t *mesg = (const H5O_shared_t *) _mesg; H5O_shared_t *dest = (H5O_shared_t *) _dest; void *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_shared_copy); /* check args */ assert(mesg); if (!dest && NULL==(dest = H5MM_malloc (sizeof(H5O_shared_t)))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); /* copy */ *dest = *mesg; /* Set return value */ ret_value=dest; done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5O_shared_copy() */ /*------------------------------------------------------------------------- * Function: H5O_shared_size * * Purpose: Returns the length of a shared object message. * * Return: Success: Length * * Failure: 0 * * Programmer: Robb Matzke * Thursday, April 2, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static size_t H5O_shared_size (const H5F_t *f, const void *_mesg) { const H5O_shared_t *shared = (const H5O_shared_t *) _mesg; size_t ret_value; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_shared_size); ret_value = 1 + /*version */ 1 + /*the flags field */ (shared->in_gh ? (H5F_SIZEOF_ADDR(f)+4) : /*sharing via global heap */ H5F_SIZEOF_ADDR(f)); /*sharing by another obj hdr */ FUNC_LEAVE_NOAPI(ret_value); } /*------------------------------------------------------------------------- * Function: H5O_shared_delete * * Purpose: Free file space referenced by message * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Friday, September 26, 2003 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_shared_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link) { const H5O_shared_t *shared = (const H5O_shared_t *) _mesg; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_shared_delete); /* check args */ assert(f); assert(shared); /* Decrement the reference count on the shared object, if requested */ if(adj_link) if(H5O_shared_link_adj(f, dxpl_id, shared, -1)<0) HGOTO_ERROR (H5E_OHDR, H5E_LINK, FAIL, "unable to adjust shared object link count") done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5O_shared_delete() */ /*------------------------------------------------------------------------- * Function: H5O_shared_link * * Purpose: Increment reference count on any objects referenced by * message * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Friday, September 26, 2003 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_shared_link(H5F_t *f, hid_t dxpl_id, const void *_mesg) { const H5O_shared_t *shared = (const H5O_shared_t *) _mesg; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_shared_link); /* check args */ assert(f); assert(shared); /* Decrement the reference count on the shared object */ if(H5O_shared_link_adj(f,dxpl_id,shared,1)<0) HGOTO_ERROR (H5E_OHDR, H5E_LINK, FAIL, "unable to adjust shared object link count"); done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5O_shared_link() */ /*------------------------------------------------------------------------- * Function: H5O_shared_debug * * Purpose: Prints debugging info for the message * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Thursday, April 2, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5O_shared_debug (H5F_t UNUSED *f, hid_t dxpl_id, const void *_mesg, FILE *stream, int indent, int fwidth) { const H5O_shared_t *mesg = (const H5O_shared_t *)_mesg; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_shared_debug); /* Check args */ assert (f); assert (mesg); assert (stream); assert (indent>=0); assert (fwidth>=0); if (mesg->in_gh) { HDfprintf (stream, "%*s%-*s %s\n", indent, "", fwidth, "Sharing method", "Global heap"); HDfprintf (stream, "%*s%-*s %a\n", indent, "", fwidth, "Collection address:", mesg->u.gh.addr); HDfprintf (stream, "%*s%-*s %d\n", indent, "", fwidth, "Object ID within collection:", mesg->u.gh.idx); } else { HDfprintf (stream, "%*s%-*s %s\n", indent, "", fwidth, "Sharing method", "Obj Hdr"); H5G_ent_debug (f, dxpl_id, &(mesg->u.ent), stream, indent, fwidth, HADDR_UNDEF); } FUNC_LEAVE_NOAPI(SUCCEED); } xdmf-3.0+git20160803/Utilities/hdf5/H5HPprivate.h0000640000175000017500000000523513003006557021150 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * This file contains private information about the H5HP module */ #ifndef _H5HPprivate_H #define _H5HPprivate_H /**************************************/ /* Public headers needed by this file */ /**************************************/ #ifdef LATER #include "H5HPpublic.h" #endif /* LATER */ /***************************************/ /* Private headers needed by this file */ /***************************************/ #include "H5private.h" /************/ /* Typedefs */ /************/ /* Typedef for heap struct (defined in H5HP.c) */ typedef struct H5HP_t H5HP_t; /* Typedef for objects which can be inserted into heaps */ /* This _must_ be the first field in objects which can be inserted into heaps */ typedef struct H5HP_info_t { size_t heap_loc; /* Location of object in heap */ }H5HP_info_t; /* Typedef for type of heap to create */ typedef enum { H5HP_MIN_HEAP, /* Minimum values in heap are at the "top" */ H5HP_MAX_HEAP /* Maximum values in heap are at the "top" */ } H5HP_type_t; /**********/ /* Macros */ /**********/ /********************/ /* Private routines */ /********************/ H5_DLL H5HP_t *H5HP_create(H5HP_type_t heap_type); H5_DLL herr_t H5HP_insert(H5HP_t *heap, int val, void *obj); H5_DLL ssize_t H5HP_count(const H5HP_t *heap); H5_DLL herr_t H5HP_top(const H5HP_t *heap, int *val); H5_DLL herr_t H5HP_remove(H5HP_t *heap, int *val, void **ptr); H5_DLL herr_t H5HP_change(H5HP_t *heap, int val, void *obj); H5_DLL herr_t H5HP_incr(H5HP_t *heap, unsigned amt, void *obj); H5_DLL herr_t H5HP_decr(H5HP_t *heap, unsigned amt, void *obj); H5_DLL herr_t H5HP_close(H5HP_t *heap); #endif /* _H5HPprivate_H */ xdmf-3.0+git20160803/Utilities/hdf5/H5FDlog.c0000640000175000017500000013221313003006557020231 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Quincey Koziol * Monday, April 17, 2000 * * Purpose: The POSIX unbuffered file driver using only the HDF5 public * API and with a few optimizations: the lseek() call is made * only when the current file position is unknown or needs to be * changed based on previous I/O through this driver (don't mix * I/O from this driver with I/O from other parts of the * application to the same file). * With custom modifications... */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5FD_log_init_interface #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fprivate.h" /* File access */ #include "H5FDprivate.h" /* File drivers */ #include "H5FDlog.h" /* Logging file driver */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Pprivate.h" /* Property lists */ #ifdef MAX #undef MAX #define MAX(X,Y) ((X)>(Y)?(X):(Y)) #endif /* MAX */ /* The driver identification number, initialized at runtime */ static hid_t H5FD_LOG_g = 0; /* File operations */ #define OP_UNKNOWN 0 #define OP_READ 1 #define OP_WRITE 2 /* Driver-specific file access properties */ typedef struct H5FD_log_fapl_t { char *logfile; /* Allocated log file name */ unsigned flags; /* Flags for logging behavior */ size_t buf_size; /* Size of buffers for track flavor and number of times each byte is accessed */ } H5FD_log_fapl_t; /* Define strings for the different file memory types */ static const char *flavors[]={ /* These are defined in H5FDpublic.h */ "H5FD_MEM_DEFAULT", "H5FD_MEM_SUPER", "H5FD_MEM_BTREE", "H5FD_MEM_DRAW", "H5FD_MEM_GHEAP", "H5FD_MEM_LHEAP", "H5FD_MEM_OHDR", }; /* * The description of a file belonging to this driver. The `eoa' and `eof' * determine the amount of hdf5 address space in use and the high-water mark * of the file (the current size of the underlying Unix file). The `pos' * value is used to eliminate file position updates when they would be a * no-op. Unfortunately we've found systems that use separate file position * indicators for reading and writing so the lseek can only be eliminated if * the current operation is the same as the previous operation. When opening * a file the `eof' will be set to the current file size, `eoa' will be set * to zero, `pos' will be set to H5F_ADDR_UNDEF (as it is when an error * occurs), and `op' will be set to H5F_OP_UNKNOWN. */ typedef struct H5FD_log_t { H5FD_t pub; /*public stuff, must be first */ int fd; /*the unix file */ haddr_t eoa; /*end of allocated region */ haddr_t eof; /*end of file; current file size*/ haddr_t pos; /*current file I/O position */ int op; /*last operation */ unsigned char *nread; /* Number of reads from a file location */ unsigned char *nwrite; /* Number of write to a file location */ unsigned char *flavor; /* Flavor of information written to file location */ size_t iosize; /* Size of I/O information buffers */ FILE *logfp; /* Log file pointer */ H5FD_log_fapl_t fa; /*driver-specific file access properties*/ #ifndef WIN32 /* * On most systems the combination of device and i-node number uniquely * identify a file. */ dev_t device; /*file device number */ ino_t inode; /*file i-node number */ #else /* * On WIN32 the low-order word of a unique identifier associated with the * file and the volume serial number uniquely identify a file. This number * (which, both? -rpm) may change when the system is restarted or when the * file is opened. After a process opens a file, the identifier is * constant until the file is closed. An application can use this * identifier and the volume serial number to determine whether two * handles refer to the same file. */ DWORD fileindexlo; DWORD fileindexhi; #endif } H5FD_log_t; /* * This driver supports systems that have the lseek64() function by defining * some macros here so we don't have to have conditional compilations later * throughout the code. * * file_offset_t: The datatype for file offsets, the second argument of * the lseek() or lseek64() call. * * file_seek: The function which adjusts the current file position, * either lseek() or lseek64(). */ /* adding for windows NT file system support. */ #ifdef H5_HAVE_LSEEK64 # define file_offset_t off64_t # define file_seek lseek64 #elif defined (WIN32) # ifdef __MWERKS__ # define file_offset_t off_t # define file_seek lseek # else /*MSVC*/ # define file_offset_t __int64 # define file_seek _lseeki64 # endif #else # define file_offset_t off_t # define file_seek lseek #endif /* * These macros check for overflow of various quantities. These macros * assume that file_offset_t is signed and haddr_t and size_t are unsigned. * * ADDR_OVERFLOW: Checks whether a file address of type `haddr_t' * is too large to be represented by the second argument * of the file seek function. * * SIZE_OVERFLOW: Checks whether a buffer size of type `hsize_t' is too * large to be represented by the `size_t' type. * * REGION_OVERFLOW: Checks whether an address and size pair describe data * which can be addressed entirely by the second * argument of the file seek function. */ #define MAXADDR (((haddr_t)1<<(8*sizeof(file_offset_t)-1))-1) #define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || \ ((A) & ~(haddr_t)MAXADDR)) #define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) #define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ sizeof(file_offset_t) * * Programmer: Quincey Koziol * Friday, Jan 30, 2004 * * Modification: * *--------------------------------------------------------------------------- */ void H5FD_log_term(void) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_log_term) /* Reset VFL ID */ H5FD_LOG_g=0; FUNC_LEAVE_NOAPI_VOID } /* end H5FD_log_term() */ #ifdef H5_WANT_H5_V1_4_COMPAT /*------------------------------------------------------------------------- * Function: H5Pset_fapl_log * * Purpose: Modify the file access property list to use the H5FD_LOG * driver defined in this source file. There are no driver * specific properties. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Thursday, February 19, 1998 * * Modifications: * We copy the LOGFILE value into our own access properties. * * Raymond Lu, 2001-10-25 * Changed the file access list to the new generic property list. * *------------------------------------------------------------------------- */ herr_t H5Pset_fapl_log(hid_t fapl_id, const char *logfile, int verbosity) { H5FD_log_fapl_t fa; /* File access property list information */ H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value; FUNC_ENTER_API(H5Pset_fapl_log, FAIL) H5TRACE3("e","isIs",fapl_id,logfile,verbosity); if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") fa.logfile=logfile; if(verbosity>0) { fa.flags=H5FD_LOG_LOC_IO|H5FD_LOG_FLAVOR; if(verbosity>1) fa.flags|=H5FD_LOG_FILE_IO; } /* end if */ fa.buf_size=32*(1024*1024); ret_value= H5P_set_driver(plist, H5FD_LOG, &fa); done: FUNC_LEAVE_API(ret_value) } #else /* H5_WANT_H5_V1_4_COMPAT */ /*------------------------------------------------------------------------- * Function: H5Pset_fapl_log * * Purpose: Modify the file access property list to use the H5FD_LOG * driver defined in this source file. There are no driver * specific properties. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Thursday, February 19, 1998 * * Modifications: * We copy the LOGFILE value into our own access properties. * * Raymond Lu, 2001-10-25 * Changed the file access list to the new generic property list. * *------------------------------------------------------------------------- */ herr_t H5Pset_fapl_log(hid_t fapl_id, const char *logfile, unsigned flags, size_t buf_size) { H5FD_log_fapl_t fa; /* File access property list information */ H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value; FUNC_ENTER_API(H5Pset_fapl_log, FAIL) H5TRACE4("e","isIuz",fapl_id,logfile,flags,buf_size); if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") fa.logfile=(char*)logfile; fa.flags=flags; fa.buf_size=buf_size; ret_value= H5P_set_driver(plist, H5FD_LOG, &fa); done: FUNC_LEAVE_API(ret_value) } #endif /* H5_WANT_H5_V1_4_COMPAT */ /*------------------------------------------------------------------------- * Function: H5FD_log_fapl_get * * Purpose: Returns a file access property list which indicates how the * specified file is being accessed. The return list could be * used to access another file the same way. * * Return: Success: Ptr to new file access property list with all * members copied from the file struct. * * Failure: NULL * * Programmer: Quincey Koziol * Thursday, April 20, 2000 * * Modifications: * *------------------------------------------------------------------------- */ static void * H5FD_log_fapl_get(H5FD_t *_file) { H5FD_log_t *file = (H5FD_log_t*)_file; void *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_log_fapl_get, NULL) /* Set return value */ ret_value= H5FD_log_fapl_copy(&(file->fa)); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_log_fapl_get() */ /*------------------------------------------------------------------------- * Function: H5FD_log_fapl_copy * * Purpose: Copies the log-specific file access properties. * * Return: Success: Ptr to a new property list * * Failure: NULL * * Programmer: Quincey Koziol * Thursday, April 20, 2000 * * Modifications: * *------------------------------------------------------------------------- */ static void * H5FD_log_fapl_copy(const void *_old_fa) { const H5FD_log_fapl_t *old_fa = (const H5FD_log_fapl_t*)_old_fa; H5FD_log_fapl_t *new_fa = H5MM_malloc(sizeof(H5FD_log_fapl_t)); void *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_log_fapl_copy, NULL) assert(new_fa); /* Copy the general information */ HDmemcpy(new_fa, old_fa, sizeof(H5FD_log_fapl_t)); /* Deep copy the log file name */ if(old_fa->logfile!=NULL) if (NULL==(new_fa->logfile=HDstrdup(old_fa->logfile))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate log file name") /* Set return value */ ret_value=new_fa; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_log_fapl_copy() */ /*------------------------------------------------------------------------- * Function: H5FD_log_fapl_free * * Purpose: Frees the log-specific file access properties. * * Return: Success: 0 * * Failure: -1 * * Programmer: Quincey Koziol * Thursday, April 20, 2000 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_log_fapl_free(void *_fa) { H5FD_log_fapl_t *fa = (H5FD_log_fapl_t*)_fa; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_log_fapl_free, FAIL) /* Free the fapl information */ if(fa->logfile) H5MM_xfree(fa->logfile); H5MM_xfree(fa); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_log_fapl_free() */ /*------------------------------------------------------------------------- * Function: H5FD_log_open * * Purpose: Create and/or opens a Unix file as an HDF5 file. * * Return: Success: A pointer to a new file data structure. The * public fields will be initialized by the * caller, which is always H5FD_open(). * * Failure: NULL * * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static H5FD_t * H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { int o_flags; int fd=(-1); H5FD_log_t *file=NULL; H5FD_log_fapl_t *fa; /* File access property list information */ #ifdef WIN32 HFILE filehandle; struct _BY_HANDLE_FILE_INFORMATION fileinfo; #endif h5_stat_t sb; H5P_genplist_t *plist; /* Property list */ H5FD_t *ret_value; FUNC_ENTER_NOAPI(H5FD_log_open, NULL) /* Check arguments */ if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name") if (0==maxaddr || HADDR_UNDEF==maxaddr) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr") if (ADDR_OVERFLOW(maxaddr)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "bogus maxaddr") /* Build the open flags */ o_flags = (H5F_ACC_RDWR & flags) ? O_RDWR : O_RDONLY; if (H5F_ACC_TRUNC & flags) o_flags |= O_TRUNC; if (H5F_ACC_CREAT & flags) o_flags |= O_CREAT; if (H5F_ACC_EXCL & flags) o_flags |= O_EXCL; /* Open the file */ if ((fd=HDopen(name, o_flags, 0666))<0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file") if (HDfstat(fd, &sb)<0) HGOTO_ERROR(H5E_FILE, H5E_BADFILE, NULL, "unable to fstat file") /* Create the new file struct */ if (NULL==(file=H5MM_calloc(sizeof(H5FD_log_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate file struct") /* Get the driver specific information */ if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") fa = H5P_get_driver_info(plist); file->fd = fd; H5_ASSIGN_OVERFLOW(file->eof,sb.st_size,h5_stat_size_t,haddr_t); file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; #ifdef WIN32 filehandle = _get_osfhandle(fd); (void)GetFileInformationByHandle((HANDLE)filehandle, &fileinfo); file->fileindexhi = fileinfo.nFileIndexHigh; file->fileindexlo = fileinfo.nFileIndexLow; #else file->device = sb.st_dev; file->inode = sb.st_ino; #endif /* Get the flags for logging */ file->fa.flags=fa->flags; /* Check if we are doing any logging at all */ if(file->fa.flags!=0) { file->iosize=fa->buf_size; if(file->fa.flags&H5FD_LOG_NUM_READ) { file->nread=H5MM_calloc(file->iosize); assert(file->nread); } /* end if */ if(file->fa.flags&H5FD_LOG_NUM_WRITE) { file->nwrite=H5MM_calloc(file->iosize); assert(file->nwrite); } /* end if */ if(file->fa.flags&H5FD_LOG_FLAVOR) { file->flavor=H5MM_calloc(file->iosize); assert(file->flavor); } /* end if */ if(fa->logfile) file->logfp=HDfopen(fa->logfile,"w"); else file->logfp=stderr; } /* end if */ /* Set return value */ ret_value=(H5FD_t*)file; done: if(ret_value==NULL) { if(fd>=0) HDclose(fd); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_log_open() */ /*------------------------------------------------------------------------- * Function: H5FD_log_close * * Purpose: Closes a Unix file. * * Return: Success: 0 * * Failure: -1, file not closed. * * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_log_close(H5FD_t *_file) { H5FD_log_t *file = (H5FD_log_t*)_file; #ifdef H5_HAVE_GETTIMEOFDAY struct timeval timeval_start,timeval_stop; struct timeval timeval_diff; #endif /* H5_HAVE_GETTIMEOFDAY */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_log_close, FAIL) #ifdef H5_HAVE_GETTIMEOFDAY if(file->fa.flags&H5FD_LOG_TIME_CLOSE) HDgettimeofday(&timeval_start,NULL); #endif /* H5_HAVE_GETTIMEOFDAY */ if (close(file->fd)<0) HGOTO_ERROR(H5E_IO, H5E_CANTCLOSEFILE, FAIL, "unable to close file") #ifdef H5_HAVE_GETTIMEOFDAY if(file->fa.flags&H5FD_LOG_TIME_CLOSE) HDgettimeofday(&timeval_stop,NULL); #endif /* H5_HAVE_GETTIMEOFDAY */ /* Dump I/O information */ if(file->fa.flags!=0) { haddr_t addr; haddr_t last_addr; unsigned char last_val; #ifdef H5_HAVE_GETTIMEOFDAY if(file->fa.flags&H5FD_LOG_TIME_CLOSE) { /* Calculate the elapsed gettimeofday time */ timeval_diff.tv_usec=timeval_stop.tv_usec-timeval_start.tv_usec; timeval_diff.tv_sec=timeval_stop.tv_sec-timeval_start.tv_sec; if(timeval_diff.tv_usec<0) { timeval_diff.tv_usec+=1000000; timeval_diff.tv_sec--; } /* end if */ HDfprintf(file->logfp,"Close took: (%f s)\n",(double)timeval_diff.tv_sec+((double)timeval_diff.tv_usec/(double)1000000.0)); } /* end if */ #endif /* H5_HAVE_GETTIMEOFDAY */ /* Dump the write I/O information */ if(file->fa.flags&H5FD_LOG_FILE_WRITE) { HDfprintf(file->logfp,"Dumping write I/O information:\n"); last_val=file->nwrite[0]; last_addr=0; addr=1; while(addreoa) { if(file->nwrite[addr]!=last_val) { HDfprintf(file->logfp,"\tAddr %10a-%10a (%10lu bytes) written to %3d times\n",last_addr,(addr-1),(unsigned long)(addr-last_addr),(int)last_val); last_val=file->nwrite[addr]; last_addr=addr; } /* end if */ addr++; } /* end while */ HDfprintf(file->logfp,"\tAddr %10a-%10a (%10lu bytes) written to %3d times\n",last_addr,(addr-1),(unsigned long)(addr-last_addr),(int)last_val); } /* end if */ /* Dump the read I/O information */ if(file->fa.flags&H5FD_LOG_FILE_READ) { HDfprintf(file->logfp,"Dumping read I/O information:\n"); last_val=file->nread[0]; last_addr=0; addr=1; while(addreoa) { if(file->nread[addr]!=last_val) { HDfprintf(file->logfp,"\tAddr %10a-%10a (%10lu bytes) read from %3d times\n",last_addr,(addr-1),(unsigned long)(addr-last_addr),(int)last_val); last_val=file->nread[addr]; last_addr=addr; } /* end if */ addr++; } /* end while */ HDfprintf(file->logfp,"\tAddr %10a-%10a (%10lu bytes) read from %3d times\n",last_addr,(addr-1),(unsigned long)(addr-last_addr),(int)last_val); } /* end if */ /* Dump the I/O flavor information */ if(file->fa.flags&H5FD_LOG_FLAVOR) { HDfprintf(file->logfp,"Dumping I/O flavor information:\n"); last_val=file->flavor[0]; last_addr=0; addr=1; while(addreoa) { if(file->flavor[addr]!=last_val) { HDfprintf(file->logfp,"\tAddr %10a-%10a (%10lu bytes) flavor is %s\n",last_addr,(addr-1),(unsigned long)(addr-last_addr),flavors[last_val]); last_val=file->flavor[addr]; last_addr=addr; } /* end if */ addr++; } /* end while */ HDfprintf(file->logfp,"\tAddr %10a-%10a (%10lu bytes) flavor is %s\n",last_addr,(addr-1),(unsigned long)(addr-last_addr),flavors[last_val]); } /* end if */ /* Free the logging information */ if(file->fa.flags&H5FD_LOG_FILE_WRITE) file->nwrite=H5MM_xfree(file->nwrite); if(file->fa.flags&H5FD_LOG_FILE_READ) file->nread=H5MM_xfree(file->nread); if(file->fa.flags&H5FD_LOG_FLAVOR) file->flavor=H5MM_xfree(file->flavor); if(file->logfp!=stderr) fclose(file->logfp); } /* end if */ H5MM_xfree(file); done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_log_cmp * * Purpose: Compares two files belonging to this driver using an * arbitrary (but consistent) ordering. * * Return: Success: A value like strcmp() * * Failure: never fails (arguments were checked by the * caller). * * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static int H5FD_log_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { const H5FD_log_t *f1 = (const H5FD_log_t*)_f1; const H5FD_log_t *f2 = (const H5FD_log_t*)_f2; int ret_value=0; FUNC_ENTER_NOAPI(H5FD_log_cmp, H5FD_VFD_DEFAULT) #ifdef WIN32 if (f1->fileindexhi < f2->fileindexhi) HGOTO_DONE(-1) if (f1->fileindexhi > f2->fileindexhi) HGOTO_DONE(1) if (f1->fileindexlo < f2->fileindexlo) HGOTO_DONE(-1) if (f1->fileindexlo > f2->fileindexlo) HGOTO_DONE(1) #else #ifdef H5_DEV_T_IS_SCALAR if (f1->device < f2->device) HGOTO_DONE(-1) if (f1->device > f2->device) HGOTO_DONE(1) #else /* H5_DEV_T_IS_SCALAR */ /* If dev_t isn't a scalar value on this system, just use memcmp to * determine if the values are the same or not. The actual return value * shouldn't really matter... */ if(HDmemcmp(&(f1->device),&(f2->device),sizeof(dev_t))<0) HGOTO_DONE(-1) if(HDmemcmp(&(f1->device),&(f2->device),sizeof(dev_t))>0) HGOTO_DONE(1) #endif /* H5_DEV_T_IS_SCALAR */ if (f1->inode < f2->inode) HGOTO_DONE(-1) if (f1->inode > f2->inode) HGOTO_DONE(1) #endif done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_log_query * * Purpose: Set the flags that this VFL driver is capable of supporting. * (listed in H5FDpublic.h) * * Return: Success: non-negative * * Failure: negative * * Programmer: Quincey Koziol * Friday, August 25, 2000 * * Modifications: * *------------------------------------------------------------------------- */ /* ARGSUSED */ static herr_t H5FD_log_query(const H5FD_t UNUSED * _f, unsigned long *flags /* out */) { herr_t ret_value=SUCCEED; FUNC_ENTER_NOAPI(H5FD_log_query, FAIL) /* Set the VFL feature flags that this driver supports */ if(flags) { *flags = 0; *flags|=H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ *flags|=H5FD_FEAT_ACCUMULATE_METADATA; /* OK to accumulate metadata for faster writes */ *flags|=H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ *flags|=H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ } done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_log_alloc * * Purpose: Allocate file memory. * * Return: Success: Address of new memory * * Failure: HADDR_UNDEF * * Programmer: Quincey Koziol * Monday, April 17, 2000 * * Modifications: * *------------------------------------------------------------------------- */ /* ARGSUSED */ static haddr_t H5FD_log_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, hsize_t size) { H5FD_log_t *file = (H5FD_log_t*)_file; haddr_t addr; haddr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_log_alloc, HADDR_UNDEF) /* Compute the address for the block to allocate */ addr = file->eoa; /* Check if we need to align this block */ if(size>=file->pub.threshold) { /* Check for an already aligned block */ if(addr%file->pub.alignment!=0) addr=((addr/file->pub.alignment)+1)*file->pub.alignment; } /* end if */ file->eoa = addr+size; /* Retain the (first) flavor of the information written to the file */ if(file->fa.flags!=0) { if(file->fa.flags&H5FD_LOG_FLAVOR) { assert(addriosize); H5_CHECK_OVERFLOW(size,hsize_t,size_t); HDmemset(&file->flavor[addr],(int)type,(size_t)size); } /* end if */ if(file->fa.flags&H5FD_LOG_ALLOC) HDfprintf(file->logfp,"%10a-%10a (%10Hu bytes) Allocated, flavor=%s\n",addr,addr+size-1,size,flavors[type]); } /* end if */ /* Set return value */ ret_value=addr; done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FD_log_alloc() */ /*------------------------------------------------------------------------- * Function: H5FD_log_get_eoa * * Purpose: Gets the end-of-address marker for the file. The EOA marker * is the first address past the last byte allocated in the * format address space. * * Return: Success: The end-of-address marker. * * Failure: HADDR_UNDEF * * Programmer: Robb Matzke * Monday, August 2, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static haddr_t H5FD_log_get_eoa(H5FD_t *_file) { H5FD_log_t *file = (H5FD_log_t*)_file; haddr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_log_get_eoa, HADDR_UNDEF) /* Set return value */ ret_value=file->eoa; done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_log_set_eoa * * Purpose: Set the end-of-address marker for the file. This function is * called shortly after an existing HDF5 file is opened in order * to tell the driver where the end of the HDF5 data is located. * * Return: Success: 0 * * Failure: -1 * * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5FD_log_set_eoa(H5FD_t *_file, haddr_t addr) { H5FD_log_t *file = (H5FD_log_t*)_file; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_log_set_eoa, FAIL) file->eoa = addr; done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_log_get_eof * * Purpose: Returns the end-of-file marker, which is the greater of * either the Unix end-of-file or the HDF5 end-of-address * markers. * * Return: Success: End of file address, the first address past * the end of the "file", either the Unix file * or the HDF5 file. * * Failure: HADDR_UNDEF * * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static haddr_t H5FD_log_get_eof(H5FD_t *_file) { H5FD_log_t *file = (H5FD_log_t*)_file; haddr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_log_get_eof, HADDR_UNDEF) /* Set return value */ ret_value=MAX(file->eof, file->eoa); done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_log_get_handle * * Purpose: Returns the file handle of LOG file driver. * * Returns: Non-negative if succeed or negative if fails. * * Programmer: Raymond Lu * Sept. 16, 2002 * * Modifications: * *------------------------------------------------------------------------- */ /* ARGSUSED */ static herr_t H5FD_log_get_handle(H5FD_t *_file, hid_t UNUSED fapl, void** file_handle) { H5FD_log_t *file = (H5FD_log_t *)_file; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5FD_log_get_handle, FAIL) if(!file_handle) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file handle not valid") *file_handle = &(file->fd); done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_log_read * * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR * into buffer BUF according to data transfer properties in * DXPL_ID. * * Return: Success: Zero. Result is stored in caller-supplied * buffer BUF. * * Failure: -1, Contents of buffer BUF are undefined. * * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: * *------------------------------------------------------------------------- */ /* ARGSUSED */ static herr_t H5FD_log_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, haddr_t addr, size_t size, void *buf/*out*/) { H5FD_log_t *file = (H5FD_log_t*)_file; ssize_t nbytes; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_log_read, FAIL) assert(file && file->pub.cls); assert(buf); /* Check for overflow conditions */ if (HADDR_UNDEF==addr) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined") if (REGION_OVERFLOW(addr, size)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow") if (addr+size>file->eoa) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow") /* Log the I/O information about the read */ if(file->fa.flags!=0) { size_t tmp_size=size; haddr_t tmp_addr=addr; /* Log information about the number of times these locations are read */ if(file->fa.flags&H5FD_LOG_FILE_READ) { assert((addr+size)iosize); while(tmp_size-->0) file->nread[tmp_addr++]++; } /* end if */ /* Log information about the seek, if it's going to occur */ if(file->fa.flags&H5FD_LOG_LOC_SEEK) { if(addr!=file->pos || OP_READ!=file->op) HDfprintf(file->logfp,"Seek: From %10a To %10a\n",file->pos,addr); } /* end if */ /* Log information about the read */ if(file->fa.flags&H5FD_LOG_LOC_READ) { /* Output the flavor information, if we have it */ if(file->fa.flags&H5FD_LOG_FLAVOR) HDfprintf(file->logfp,"%10a-%10a (%10Zu bytes) Read, flavor=%s\n",addr,addr+size-1,size,flavors[file->flavor[addr]]); else HDfprintf(file->logfp,"%10a-%10a (%10Zu bytes) Read\n",addr,addr+size-1,size); } /* end if */ } /* end if */ /* Seek to the correct location */ if ((addr!=file->pos || OP_READ!=file->op) && file_seek(file->fd, (file_offset_t)addr, SEEK_SET)<0) { file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") } /* * Read data, being careful of interrupted system calls, partial results, * and the end of the file. */ while (size>0) { do { nbytes = HDread(file->fd, buf, size); } while (-1==nbytes && EINTR==errno); if (-1==nbytes) { /* error */ file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed") } if (0==nbytes) { /* end of file but not end of format address space */ HDmemset(buf, 0, size); size = 0; } assert(nbytes>=0); assert((size_t)nbytes<=size); H5_CHECK_OVERFLOW(nbytes,ssize_t,size_t); size -= (size_t)nbytes; H5_CHECK_OVERFLOW(nbytes,ssize_t,haddr_t); addr += (haddr_t)nbytes; buf = (char*)buf + nbytes; } /* Update current position */ file->pos = addr; file->op = OP_READ; done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_log_write * * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR * from buffer BUF according to data transfer properties in * DXPL_ID. * * Return: Success: Zero * * Failure: -1 * * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: * *------------------------------------------------------------------------- */ /* ARGSUSED */ static herr_t H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, haddr_t addr, size_t size, const void *buf) { H5FD_log_t *file = (H5FD_log_t*)_file; ssize_t nbytes; size_t orig_size=size; /* Save the original size for later */ haddr_t orig_addr=addr; #ifdef H5_HAVE_GETTIMEOFDAY struct timeval timeval_start,timeval_stop; struct timeval timeval_diff; #endif /* H5_HAVE_GETTIMEOFDAY */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_log_write, FAIL) assert(file && file->pub.cls); assert(size>0); assert(buf); /* Verify that we are writing out the type of data we allocated in this location */ assert(type==H5FD_MEM_DEFAULT || type==(H5FD_mem_t)file->flavor[addr] || (H5FD_mem_t)file->flavor[addr]==H5FD_MEM_DEFAULT); assert(type==H5FD_MEM_DEFAULT || type==(H5FD_mem_t)file->flavor[(addr+size)-1] || (H5FD_mem_t)file->flavor[(addr+size)-1]==H5FD_MEM_DEFAULT); /* Check for overflow conditions */ if (HADDR_UNDEF==addr) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined") if (REGION_OVERFLOW(addr, size)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow") if (addr+size>file->eoa) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow") /* Log the I/O information about the write */ if(file->fa.flags&H5FD_LOG_FILE_WRITE) { size_t tmp_size=size; haddr_t tmp_addr=addr; assert((addr+size)iosize); while(tmp_size-->0) file->nwrite[tmp_addr++]++; } /* end if */ /* Seek to the correct location */ if (addr!=file->pos || OP_WRITE!=file->op) { #ifdef H5_HAVE_GETTIMEOFDAY if(file->fa.flags&H5FD_LOG_TIME_SEEK) HDgettimeofday(&timeval_start,NULL); #endif /* H5_HAVE_GETTIMEOFDAY */ if(file_seek(file->fd, (file_offset_t)addr, SEEK_SET)<0) { file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") } /* end if */ #ifdef H5_HAVE_GETTIMEOFDAY if(file->fa.flags&H5FD_LOG_TIME_SEEK) HDgettimeofday(&timeval_stop,NULL); #endif /* H5_HAVE_GETTIMEOFDAY */ /* Log information about the seek */ if(file->fa.flags&H5FD_LOG_LOC_SEEK) { #ifdef H5_HAVE_GETTIMEOFDAY HDfprintf(file->logfp,"Seek: From %10a To %10a",file->pos,addr); if(file->fa.flags&H5FD_LOG_TIME_SEEK) { /* Calculate the elapsed gettimeofday time */ timeval_diff.tv_usec=timeval_stop.tv_usec-timeval_start.tv_usec; timeval_diff.tv_sec=timeval_stop.tv_sec-timeval_start.tv_sec; if(timeval_diff.tv_usec<0) { timeval_diff.tv_usec+=1000000; timeval_diff.tv_sec--; } /* end if */ HDfprintf(file->logfp," (%f s)\n",(double)timeval_diff.tv_sec+((double)timeval_diff.tv_usec/(double)1000000.0)); } /* end if */ else HDfprintf(file->logfp,"\n"); #else /* H5_HAVE_GETTIMEOFDAY */ HDfprintf(file->logfp,"Seek: From %10a To %10a\n",file->pos,addr); #endif /* H5_HAVE_GETTIMEOFDAY */ } /* end if */ } /* end if */ /* * Write the data, being careful of interrupted system calls and partial * results */ #ifdef H5_HAVE_GETTIMEOFDAY if(file->fa.flags&H5FD_LOG_TIME_WRITE) HDgettimeofday(&timeval_start,NULL); #endif /* H5_HAVE_GETTIMEOFDAY */ while (size>0) { do { nbytes = HDwrite(file->fd, buf, size); } while (-1==nbytes && EINTR==errno); if (-1==nbytes) { /* error */ file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; if(file->fa.flags&H5FD_LOG_LOC_WRITE) HDfprintf(file->logfp,"Error! Writing: %10a-%10a (%10Zu bytes)\n",orig_addr,orig_addr+orig_size-1,orig_size); HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") } assert(nbytes>0); assert((size_t)nbytes<=size); H5_CHECK_OVERFLOW(nbytes,ssize_t,size_t); size -= (size_t)nbytes; H5_CHECK_OVERFLOW(nbytes,ssize_t,haddr_t); addr += (haddr_t)nbytes; buf = (const char*)buf + nbytes; } #ifdef H5_HAVE_GETTIMEOFDAY if(file->fa.flags&H5FD_LOG_TIME_WRITE) HDgettimeofday(&timeval_stop,NULL); #endif /* H5_HAVE_GETTIMEOFDAY */ /* Log information about the write */ if(file->fa.flags&H5FD_LOG_LOC_WRITE) { /* Output the flavor information, if desired */ if(file->fa.flags&H5FD_LOG_FLAVOR) HDfprintf(file->logfp,"%10a-%10a (%10Zu bytes) (%s) Written",orig_addr,orig_addr+orig_size-1,orig_size,flavors[file->flavor[orig_addr]]); else HDfprintf(file->logfp,"%10a-%10a (%10Zu bytes) Written",orig_addr,orig_addr+orig_size-1,orig_size); /* Check if this is the first write into a "default" section, grabbed by the metadata agregation algorithm */ if(file->fa.flags&H5FD_LOG_FLAVOR) { if((H5FD_mem_t)file->flavor[orig_addr]==H5FD_MEM_DEFAULT) HDmemset(&file->flavor[orig_addr],(int)type,orig_size); } /* end if */ #ifdef H5_HAVE_GETTIMEOFDAY if(file->fa.flags&H5FD_LOG_TIME_WRITE) { /* Calculate the elapsed gettimeofday time */ timeval_diff.tv_usec=timeval_stop.tv_usec-timeval_start.tv_usec; timeval_diff.tv_sec=timeval_stop.tv_sec-timeval_start.tv_sec; if(timeval_diff.tv_usec<0) { timeval_diff.tv_usec+=1000000; timeval_diff.tv_sec--; } /* end if */ HDfprintf(file->logfp," (%f s)\n",(double)timeval_diff.tv_sec+((double)timeval_diff.tv_usec/(double)1000000.0)); } /* end if */ else HDfprintf(file->logfp,"\n"); #else /* H5_HAVE_GETTIMEOFDAY */ HDfprintf(file->logfp,"\n"); #endif /* H5_HAVE_GETTIMEOFDAY */ } /* end if */ /* Update current position and eof */ file->pos = addr; file->op = OP_WRITE; if (file->pos>file->eof) file->eof = file->pos; done: FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- * Function: H5FD_log_flush * * Purpose: Makes sure that the true file size is the same (or larger) * than the end-of-address. * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Wednesday, August 4, 1999 * * Modifications: * *------------------------------------------------------------------------- */ /* ARGSUSED */ static herr_t H5FD_log_flush(H5FD_t *_file, hid_t UNUSED dxpl_id, unsigned UNUSED closing) { H5FD_log_t *file = (H5FD_log_t*)_file; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_log_flush, FAIL) if (file->eoa>file->eof) { if (-1==file_seek(file->fd, (file_offset_t)(file->eoa-1), SEEK_SET)) HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") if (write(file->fd, "", 1)!=1) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") file->eof = file->eoa; file->pos = file->eoa; file->op = OP_WRITE; } done: FUNC_LEAVE_NOAPI(ret_value) } xdmf-3.0+git20160803/Utilities/hdf5/H5Dprivate.h0000640000175000017500000002655213003006557021031 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * This file contains private information about the H5D module */ #ifndef _H5Dprivate_H #define _H5Dprivate_H /* Include package's public header */ #include "H5Dpublic.h" /* Private headers needed by this file */ #include "H5FDprivate.h" /* File drivers */ #include "H5Oprivate.h" /* Object headers */ /* * Feature: Define H5D_DEBUG on the compiler command line if you want to * debug dataset I/O. NDEBUG must not be defined in order for this * to have any effect. */ #ifdef NDEBUG # undef H5D_DEBUG #endif /* ======== Dataset creation properties ======== */ /* Definitions for storage layout property */ #define H5D_CRT_LAYOUT_NAME "layout" #define H5D_CRT_LAYOUT_SIZE sizeof(H5D_layout_t) #define H5D_CRT_LAYOUT_DEF H5D_CONTIGUOUS /* Definitions for chunk dimensionality property */ #define H5D_CRT_CHUNK_DIM_NAME "chunk_ndims" #define H5D_CRT_CHUNK_DIM_SIZE sizeof(unsigned) #define H5D_CRT_CHUNK_DIM_DEF 1 /* Definitions for chunk size */ #define H5D_CRT_CHUNK_SIZE_NAME "chunk_size" #define H5D_CRT_CHUNK_SIZE_SIZE sizeof(size_t[H5O_LAYOUT_NDIMS]) #define H5D_CRT_CHUNK_SIZE_DEF {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,\ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1} /* Definitions for fill value. size=0 means fill value will be 0 as * library default; size=-1 means fill value is undefined. */ #define H5D_CRT_FILL_VALUE_NAME "fill_value" #define H5D_CRT_FILL_VALUE_SIZE sizeof(H5O_fill_t) #define H5D_CRT_FILL_VALUE_DEF {NULL, 0, NULL} #define H5D_CRT_FILL_VALUE_CMP H5D_crt_fill_value_cmp /* Definitions for space allocation time */ #define H5D_CRT_ALLOC_TIME_NAME "alloc_time" #define H5D_CRT_ALLOC_TIME_SIZE sizeof(H5D_alloc_time_t) #define H5D_CRT_ALLOC_TIME_DEF H5D_ALLOC_TIME_LATE #define H5D_CRT_ALLOC_TIME_STATE_NAME "alloc_time_state" #define H5D_CRT_ALLOC_TIME_STATE_SIZE sizeof(unsigned) #define H5D_CRT_ALLOC_TIME_STATE_DEF 1 /* Definitions for time of fill value writing */ #define H5D_CRT_FILL_TIME_NAME "fill_time" #define H5D_CRT_FILL_TIME_SIZE sizeof(H5D_fill_time_t) #define H5D_CRT_FILL_TIME_DEF H5D_FILL_TIME_IFSET /* Definitions for external file list */ #define H5D_CRT_EXT_FILE_LIST_NAME "efl" #define H5D_CRT_EXT_FILE_LIST_SIZE sizeof(H5O_efl_t) #define H5D_CRT_EXT_FILE_LIST_DEF {HADDR_UNDEF, 0, 0, NULL} #define H5D_CRT_EXT_FILE_LIST_CMP H5D_crt_ext_file_list_cmp /* Definitions for data filter pipeline */ #define H5D_CRT_DATA_PIPELINE_NAME "pline" #define H5D_CRT_DATA_PIPELINE_SIZE sizeof(H5O_pline_t) #define H5D_CRT_DATA_PIPELINE_DEF {0, 0, NULL} #define H5D_CRT_DATA_PIPELINE_CMP H5D_crt_data_pipeline_cmp /* ======== Data transfer properties ======== */ /* Definitions for maximum temp buffer size property */ #define H5D_XFER_MAX_TEMP_BUF_NAME "max_temp_buf" #define H5D_XFER_MAX_TEMP_BUF_SIZE sizeof(size_t) #define H5D_XFER_MAX_TEMP_BUF_DEF (1024*1024) /* Definitions for type conversion buffer property */ #define H5D_XFER_TCONV_BUF_NAME "tconv_buf" #define H5D_XFER_TCONV_BUF_SIZE sizeof(void *) #define H5D_XFER_TCONV_BUF_DEF NULL /* Definitions for background buffer property */ #define H5D_XFER_BKGR_BUF_NAME "bkgr_buf" #define H5D_XFER_BKGR_BUF_SIZE sizeof(void *) #define H5D_XFER_BKGR_BUF_DEF NULL /* Definitions for background buffer type property */ #define H5D_XFER_BKGR_BUF_TYPE_NAME "bkgr_buf_type" #define H5D_XFER_BKGR_BUF_TYPE_SIZE sizeof(H5T_bkg_t) #define H5D_XFER_BKGR_BUF_TYPE_DEF H5T_BKG_NO /* Definitions for B-tree node splitting ratio property */ /* (These default B-tree node splitting ratios are also used for splitting * group's B-trees as well as chunked dataset's B-trees - QAK) */ #define H5D_XFER_BTREE_SPLIT_RATIO_NAME "btree_split_ratio" #define H5D_XFER_BTREE_SPLIT_RATIO_SIZE sizeof(double[3]) #define H5D_XFER_BTREE_SPLIT_RATIO_DEF {0.1, 0.5, 0.9} #ifdef H5_WANT_H5_V1_4_COMPAT /* Definitions for hyperslab caching property */ #define H5D_XFER_HYPER_CACHE_NAME "hyper_cache" #define H5D_XFER_HYPER_CACHE_SIZE sizeof(unsigned) #ifndef H5_HAVE_PARALLEL #define H5D_XFER_HYPER_CACHE_DEF 1 #else #define H5D_XFER_HYPER_CACHE_DEF 0 #endif /* Definitions for hyperslab cache limit property */ #define H5D_XFER_HYPER_CACHE_LIM_NAME "hyper_cache_limit" #define H5D_XFER_HYPER_CACHE_LIM_SIZE sizeof(unsigned) #define H5D_XFER_HYPER_CACHE_LIM_DEF 0 #endif /* H5_WANT_H5_V1_4_COMPAT */ /* Definitions for vlen allocation function property */ #define H5D_XFER_VLEN_ALLOC_NAME "vlen_alloc" #define H5D_XFER_VLEN_ALLOC_SIZE sizeof(H5MM_allocate_t) #define H5D_XFER_VLEN_ALLOC_DEF NULL /* Definitions for vlen allocation info property */ #define H5D_XFER_VLEN_ALLOC_INFO_NAME "vlen_alloc_info" #define H5D_XFER_VLEN_ALLOC_INFO_SIZE sizeof(void *) #define H5D_XFER_VLEN_ALLOC_INFO_DEF NULL /* Definitions for vlen free function property */ #define H5D_XFER_VLEN_FREE_NAME "vlen_free" #define H5D_XFER_VLEN_FREE_SIZE sizeof(H5MM_free_t) #define H5D_XFER_VLEN_FREE_DEF NULL /* Definitions for vlen free info property */ #define H5D_XFER_VLEN_FREE_INFO_NAME "vlen_free_info" #define H5D_XFER_VLEN_FREE_INFO_SIZE sizeof(void *) #define H5D_XFER_VLEN_FREE_INFO_DEF NULL /* Definitions for file driver ID property */ #define H5D_XFER_VFL_ID_NAME "vfl_id" #define H5D_XFER_VFL_ID_SIZE sizeof(hid_t) #define H5D_XFER_VFL_ID_DEF H5FD_VFD_DEFAULT /* Definitions for file driver info property */ #define H5D_XFER_VFL_INFO_NAME "vfl_info" #define H5D_XFER_VFL_INFO_SIZE sizeof(void *) #define H5D_XFER_VFL_INFO_DEF NULL /* Definitions for hyperslab vector size property */ /* (Be cautious about increasing the default size, there are arrays allocated * on the stack which depend on it - QAK) */ #define H5D_XFER_HYPER_VECTOR_SIZE_NAME "vec_size" #define H5D_XFER_HYPER_VECTOR_SIZE_SIZE sizeof(size_t) #define H5D_XFER_HYPER_VECTOR_SIZE_DEF 1024 /* Definitions for I/O transfer mode property */ #define H5D_XFER_IO_XFER_MODE_NAME "io_xfer_mode" #define H5D_XFER_IO_XFER_MODE_SIZE sizeof(H5FD_mpio_xfer_t) #define H5D_XFER_IO_XFER_MODE_DEF H5FD_MPIO_INDEPENDENT /* Definitions for EDC property */ #define H5D_XFER_EDC_NAME "err_detect" #define H5D_XFER_EDC_SIZE sizeof(H5Z_EDC_t) #define H5D_XFER_EDC_DEF H5Z_ENABLE_EDC /* Definitions for filter callback function property */ #define H5D_XFER_FILTER_CB_NAME "filter_cb" #define H5D_XFER_FILTER_CB_SIZE sizeof(H5Z_cb_t) #define H5D_XFER_FILTER_CB_DEF {NULL,NULL} #ifdef H5_HAVE_INSTRUMENTED_LIBRARY /* Definitions for collective chunk I/O property */ #define H5D_XFER_COLL_CHUNK_NAME "coll_chunk" #define H5D_XFER_COLL_CHUNK_SIZE sizeof(unsigned) #define H5D_XFER_COLL_CHUNK_DEF 1 #endif /* H5_HAVE_INSTRUMENTED_LIBRARY */ /****************************/ /* Library Private Typedefs */ /****************************/ /* Typedef for dataset in memory (defined in H5Dpkg.h) */ typedef struct H5D_t H5D_t; /* Typedef for dataset storage information */ typedef struct { hsize_t index; /* "Index" of chunk in dataset (must be first for TBBT routines) */ hsize_t *offset; /* Chunk's coordinates in elements */ } H5D_chunk_storage_t; typedef struct { haddr_t dset_addr; /* Address of dataset in file */ hsize_t dset_size; /* Total size of dataset in file */ } H5D_contig_storage_t; typedef union H5D_storage_t { H5O_efl_t efl; /* External file list information for dataset */ H5D_chunk_storage_t chunk; /* Chunk information for dataset */ H5D_contig_storage_t contig; /* Contiguous information for dataset */ } H5D_storage_t; /* Typedef for cached dataset transfer property list information */ typedef struct H5D_dxpl_cache_t { size_t max_temp_buf; /* Maximum temporary buffer size (H5D_XFER_MAX_TEMP_BUF_NAME) */ void *tconv_buf; /* Temporary conversion buffer (H5D_XFER_TCONV_BUF_NAME) */ void *bkgr_buf; /* Background conversion buffer (H5D_XFER_BKGR_BUF_NAME) */ H5T_bkg_t bkgr_buf_type; /* Background buffer type (H5D_XFER_BKGR_BUF_NAME) */ H5Z_EDC_t err_detect; /* Error detection info (H5D_XFER_EDC_NAME) */ double btree_split_ratio[3];/* B-tree split ratios (H5D_XFER_BTREE_SPLIT_RATIO_NAME) */ size_t vec_size; /* Size of hyperslab vector (H5D_XFER_HYPER_VECTOR_SIZE_NAME) */ #ifdef H5_HAVE_PARALLEL H5FD_mpio_xfer_t xfer_mode; /* Parallel transfer for this request (H5D_XFER_IO_XFER_MODE_NAME) */ #endif /*H5_HAVE_PARALLEL*/ H5Z_cb_t filter_cb; /* Filter callback function (H5D_XFER_FILTER_CB_NAME) */ } H5D_dxpl_cache_t; /* Typedef for cached dataset creation property list information */ typedef struct H5D_dcpl_cache_t { H5O_pline_t pline; /* I/O pipeline info (H5D_CRT_DATA_PIPELINE_NAME) */ H5O_fill_t fill; /* Fill value info (H5D_CRT_FILL_VALUE_NAME) */ H5D_fill_time_t fill_time; /* Fill time (H5D_CRT_FILL_TIME_NAME) */ } H5D_dcpl_cache_t; /* Library-private functions defined in H5D package */ H5_DLL herr_t H5D_init(void); H5_DLL H5D_t *H5D_open(const H5G_entry_t *ent, hid_t dxpl_id); H5_DLL herr_t H5D_close(H5D_t *dataset); H5_DLL htri_t H5D_isa(H5G_entry_t *ent, hid_t dxpl_id); H5_DLL H5G_entry_t *H5D_entof(H5D_t *dataset); H5_DLL H5T_t *H5D_typeof(const H5D_t *dset); H5_DLL herr_t H5D_crt_copy(hid_t new_plist_t, hid_t old_plist_t, void *copy_data); H5_DLL herr_t H5D_crt_close(hid_t dxpl_id, void *close_data); H5_DLL herr_t H5D_xfer_create(hid_t dxpl_id, void *create_data); H5_DLL herr_t H5D_xfer_copy(hid_t new_plist_id, hid_t old_plist_id, void *copy_data); H5_DLL herr_t H5D_xfer_close(hid_t dxpl_id, void *close_data); H5_DLL herr_t H5D_flush(const H5F_t *f, hid_t dxpl_id, unsigned flags); H5_DLL herr_t H5D_get_dxpl_cache(hid_t dxpl_id, H5D_dxpl_cache_t **cache); H5_DLL herr_t H5D_get_dxpl_cache_real(hid_t dxpl_id, H5D_dxpl_cache_t *cache); /* Functions that operate on contiguous storage */ H5_DLL herr_t H5D_contig_delete(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout); /* Functions that operate on indexed storage */ H5_DLL herr_t H5D_istore_delete(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout); H5_DLL herr_t H5D_istore_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, int fwidth, unsigned ndims); #endif xdmf-3.0+git20160803/Utilities/hdf5/H5Distore.c0000640000175000017500000040565213003006557020661 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* Programmer: Robb Matzke * Wednesday, October 8, 1997 * * Purpose: Indexed (chunked) I/O functions. The logical * multi-dimensional data space is regularly partitioned into * same-sized "chunks", the first of which is aligned with the * logical origin. The chunks are given a multi-dimensional * index which is used as a lookup key in a B-tree that maps * chunk index to disk address. Each chunk can be compressed * independently and the chunks may move around in the file as * their storage requirements change. * * Cache: Disk I/O is performed in units of chunks and H5MF_alloc() * contains code to optionally align chunks on disk block * boundaries for performance. * * The chunk cache is an extendible hash indexed by a function * of storage B-tree address and chunk N-dimensional offset * within the dataset. Collisions are not resolved -- one of * the two chunks competing for the hash slot must be preempted * from the cache. All entries in the hash also participate in * a doubly-linked list and entries are penalized by moving them * toward the front of the list. When a new chunk is about to * be added to the cache the heap is pruned by preempting * entries near the front of the list to make room for the new * entry which is added to the end of the list. */ #define H5B_PACKAGE /*suppress error about including H5Bpkg */ #define H5D_PACKAGE /*suppress error about including H5Dpkg */ #include "H5private.h" /* Generic Functions */ #include "H5Bpkg.h" /* B-link trees */ #include "H5Dpkg.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fprivate.h" /* Files */ #include "H5FDprivate.h" /* File drivers */ #include "H5FLprivate.h" /* Free Lists */ #include "H5Iprivate.h" /* IDs */ #include "H5MFprivate.h" /* File space management */ #include "H5MMprivate.h" /* Memory management */ #include "H5Oprivate.h" /* Object headers */ #include "H5Pprivate.h" /* Property lists */ #include "H5Sprivate.h" /* Dataspaces */ #include "H5Vprivate.h" /* Vector and array functions */ /* * Feature: If this constant is defined then every cache preemption and load * causes a character to be printed on the standard error stream: * * `.': Entry was preempted because it has been completely read or * completely written but not partially read and not partially * written. This is often a good reason for preemption because such * a chunk will be unlikely to be referenced in the near future. * * `:': Entry was preempted because it hasn't been used recently. * * `#': Entry was preempted because another chunk collided with it. This * is usually a relatively bad thing. If there are too many of * these then the number of entries in the cache can be increased. * * c: Entry was preempted because the file is closing. * * w: A chunk read operation was eliminated because the library is * about to write new values to the entire chunk. This is a good * thing, especially on files where the chunk size is the same as * the disk block size, chunks are aligned on disk block boundaries, * and the operating system can also eliminate a read operation. */ /*#define H5D_ISTORE_DEBUG */ /* * Given a B-tree node return the dimensionality of the chunks pointed to by * that node. */ #define H5D_ISTORE_NDIMS(X) (((X)->sizeof_rkey-8)/8) /* Raw data chunks are cached. Each entry in the cache is: */ typedef struct H5D_rdcc_ent_t { hbool_t locked; /*entry is locked in cache */ hbool_t dirty; /*needs to be written to disk? */ hsize_t offset[H5O_LAYOUT_NDIMS]; /*chunk name */ size_t rd_count; /*bytes remaining to be read */ size_t wr_count; /*bytes remaining to be written */ size_t chunk_size; /*size of a chunk */ size_t alloc_size; /*amount allocated for the chunk */ uint8_t *chunk; /*the unfiltered chunk data */ unsigned idx; /*index in hash table */ struct H5D_rdcc_ent_t *next;/*next item in doubly-linked list */ struct H5D_rdcc_ent_t *prev;/*previous item in doubly-linked list */ } H5D_rdcc_ent_t; typedef H5D_rdcc_ent_t *H5D_rdcc_ent_ptr_t; /* For free lists */ /* * B-tree key. A key contains the minimum logical N-dimensional address and * the logical size of the chunk to which this key refers. The * fastest-varying dimension is assumed to reference individual bytes of the * array, so a 100-element 1-d array of 4-byte integers would really be a 2-d * array with the slow varying dimension of size 100 and the fast varying * dimension of size 4 (the storage dimensionality has very little to do with * the real dimensionality). * * Only the first few values of the OFFSET and SIZE fields are actually * stored on disk, depending on the dimensionality. * * The chunk's file address is part of the B-tree and not part of the key. */ typedef struct H5D_istore_key_t { size_t nbytes; /*size of stored data */ hsize_t offset[H5O_LAYOUT_NDIMS]; /*logical offset to start*/ unsigned filter_mask; /*excluded filters */ } H5D_istore_key_t; typedef struct H5D_istore_ud1_t { H5D_istore_key_t key; /*key values */ haddr_t addr; /*file address of chunk */ const H5O_layout_t *mesg; /*layout message */ hsize_t total_storage; /*output from iterator */ FILE *stream; /*debug output stream */ hsize_t *dims; /*dataset dimensions */ } H5D_istore_ud1_t; #define H5D_HASH(D,ADDR) H5F_addr_hash(ADDR,(D)->cache.chunk.nslots) /* Private prototypes */ static void *H5D_istore_chunk_alloc(size_t size, const H5O_pline_t *pline); static void *H5D_istore_chunk_xfree(void *chk, const H5O_pline_t *pline); static herr_t H5D_istore_shared_create (const H5F_t *f, H5O_layout_t *layout); static herr_t H5D_istore_shared_free (void *page); /* B-tree iterator callbacks */ static int H5D_istore_iter_allocated(H5F_t *f, hid_t dxpl_id, const void *left_key, haddr_t addr, const void *right_key, void *_udata); static int H5D_istore_iter_dump(H5F_t *f, hid_t dxpl_id, const void *left_key, haddr_t addr, const void *right_key, void *_udata); static int H5D_istore_prune_extent(H5F_t *f, hid_t dxpl_id, const void *_lt_key, haddr_t addr, const void *_rt_key, void *_udata); /* B-tree callbacks */ static size_t H5D_istore_sizeof_rkey(const H5F_t *f, const void *_udata); static H5RC_t *H5D_istore_get_shared(const H5F_t *f, const void *_udata); static herr_t H5D_istore_new_node(H5F_t *f, hid_t dxpl_id, H5B_ins_t, void *_lt_key, void *_udata, void *_rt_key, haddr_t *addr_p /*out*/); static int H5D_istore_cmp2(H5F_t *f, hid_t dxpl_id, void *_lt_key, void *_udata, void *_rt_key); static int H5D_istore_cmp3(H5F_t *f, hid_t dxpl_id, void *_lt_key, void *_udata, void *_rt_key); static herr_t H5D_istore_found(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_lt_key, void *_udata); static H5B_ins_t H5D_istore_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key, hbool_t *lt_key_changed, void *_md_key, void *_udata, void *_rt_key, hbool_t *rt_key_changed, haddr_t *new_node/*out*/); static H5B_ins_t H5D_istore_remove( H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key, hbool_t *lt_key_changed, void *_udata, void *_rt_key, hbool_t *rt_key_changed); static herr_t H5D_istore_decode_key(const H5F_t *f, const H5B_t *bt, const uint8_t *raw, void *_key); static herr_t H5D_istore_encode_key(const H5F_t *f, const H5B_t *bt, uint8_t *raw, void *_key); static herr_t H5D_istore_debug_key(FILE *stream, H5F_t *f, hid_t dxpl_id, int indent, int fwidth, const void *key, const void *udata); /* inherits B-tree like properties from H5B */ H5B_class_t H5B_ISTORE[1] = {{ H5B_ISTORE_ID, /*id */ sizeof(H5D_istore_key_t), /*sizeof_nkey */ H5D_istore_sizeof_rkey, /*get_sizeof_rkey */ H5D_istore_get_shared, /*get_shared */ H5D_istore_new_node, /*new */ H5D_istore_cmp2, /*cmp2 */ H5D_istore_cmp3, /*cmp3 */ H5D_istore_found, /*found */ H5D_istore_insert, /*insert */ FALSE, /*follow min branch? */ FALSE, /*follow max branch? */ H5D_istore_remove, /*remove */ H5D_istore_decode_key, /*decode */ H5D_istore_encode_key, /*encode */ H5D_istore_debug_key, /*debug */ }}; /* Declare a free list to manage the H5B_shared_t struct */ H5FL_EXTERN(H5B_shared_t); /* Declare a free list to manage H5F_rdcc_ent_t objects */ H5FL_DEFINE_STATIC(H5D_rdcc_ent_t); /* Declare a free list to manage the H5F_rdcc_ent_ptr_t sequence information */ H5FL_SEQ_DEFINE_STATIC(H5D_rdcc_ent_ptr_t); /* Declare a free list to manage the chunk sequence information */ H5FL_BLK_DEFINE_STATIC(chunk); /* Declare a free list to manage the native key offset sequence information */ H5FL_SEQ_DEFINE_STATIC(size_t); /* Declare a free list to manage the raw page information */ H5FL_BLK_DEFINE_STATIC(chunk_page); /*------------------------------------------------------------------------- * Function: H5D_istore_sizeof_rkey * * Purpose: Returns the size of a raw key for the specified UDATA. The * size of the key is dependent on the number of dimensions for * the object to which this B-tree points. The dimensionality * of the UDATA is the only portion that's referenced here. * * Return: Success: Size of raw key in bytes. * * Failure: abort() * * Programmer: Robb Matzke * Wednesday, October 8, 1997 * * Modifications: * *------------------------------------------------------------------------- */ /* ARGSUSED */ static size_t H5D_istore_sizeof_rkey(const H5F_t UNUSED *f, const void *_udata) { const H5D_istore_ud1_t *udata = (const H5D_istore_ud1_t *) _udata; size_t nbytes; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_sizeof_rkey) assert(udata); assert(udata->mesg->u.chunk.ndims > 0 && udata->mesg->u.chunk.ndims <= H5O_LAYOUT_NDIMS); nbytes = 4 + /*storage size */ 4 + /*filter mask */ udata->mesg->u.chunk.ndims*8; /*dimension indices */ FUNC_LEAVE_NOAPI(nbytes) } /* end H5D_istore_sizeof_rkey() */ /*------------------------------------------------------------------------- * Function: H5D_istore_get_shared * * Purpose: Returns the shared B-tree info for the specified UDATA. * * Return: Success: Pointer to the raw B-tree page for this dataset * * Failure: Can't fail * * Programmer: Quincey Koziol * Monday, July 5, 2004 * * Modifications: * *------------------------------------------------------------------------- */ /* ARGSUSED */ static H5RC_t * H5D_istore_get_shared(const H5F_t UNUSED *f, const void *_udata) { const H5D_istore_ud1_t *udata = (const H5D_istore_ud1_t *) _udata; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_get_shared) assert(udata); assert(udata->mesg); assert(udata->mesg->u.chunk.btree_shared); /* Increment reference count on B-tree info */ H5RC_INC(udata->mesg->u.chunk.btree_shared); /* Return the pointer to the ref-count object */ FUNC_LEAVE_NOAPI(udata->mesg->u.chunk.btree_shared) } /* end H5D_istore_get_shared() */ /*------------------------------------------------------------------------- * Function: H5D_istore_decode_key * * Purpose: Decodes a raw key into a native key for the B-tree * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Friday, October 10, 1997 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5D_istore_decode_key(const H5F_t UNUSED *f, const H5B_t *bt, const uint8_t *raw, void *_key) { H5D_istore_key_t *key = (H5D_istore_key_t *) _key; H5B_shared_t *shared; /* Pointer to shared B-tree info */ size_t ndims; unsigned u; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_decode_key) /* check args */ assert(f); assert(bt); shared=H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); assert(raw); assert(key); ndims = H5D_ISTORE_NDIMS(shared); assert(ndims<=H5O_LAYOUT_NDIMS); /* decode */ UINT32DECODE(raw, key->nbytes); UINT32DECODE(raw, key->filter_mask); for (u=0; uoffset[u]); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D_istore_decode_key() */ /*------------------------------------------------------------------------- * Function: H5D_istore_encode_key * * Purpose: Encode a key from native format to raw format. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Friday, October 10, 1997 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5D_istore_encode_key(const H5F_t UNUSED *f, const H5B_t *bt, uint8_t *raw, void *_key) { H5D_istore_key_t *key = (H5D_istore_key_t *) _key; H5B_shared_t *shared; /* Pointer to shared B-tree info */ size_t ndims; unsigned u; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_encode_key) /* check args */ assert(f); assert(bt); shared=H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); assert(raw); assert(key); ndims = H5D_ISTORE_NDIMS(shared); assert(ndims<=H5O_LAYOUT_NDIMS); /* encode */ UINT32ENCODE(raw, key->nbytes); UINT32ENCODE(raw, key->filter_mask); for (u=0; uoffset[u]); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D_istore_encode_key() */ /*------------------------------------------------------------------------- * Function: H5D_istore_debug_key * * Purpose: Prints a key. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Thursday, April 16, 1998 * * Modifications: * *------------------------------------------------------------------------- */ /* ARGSUSED */ static herr_t H5D_istore_debug_key (FILE *stream, H5F_t UNUSED *f, hid_t UNUSED dxpl_id, int indent, int fwidth, const void *_key, const void *_udata) { const H5D_istore_key_t *key = (const H5D_istore_key_t *)_key; const H5D_istore_ud1_t *udata = (const H5D_istore_ud1_t *)_udata; unsigned u; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_debug_key) assert (key); HDfprintf(stream, "%*s%-*s %Zd bytes\n", indent, "", fwidth, "Chunk size:", key->nbytes); HDfprintf(stream, "%*s%-*s 0x%08x\n", indent, "", fwidth, "Filter mask:", key->filter_mask); HDfprintf(stream, "%*s%-*s {", indent, "", fwidth, "Logical offset:"); for (u=0; umesg->u.chunk.ndims; u++) HDfprintf (stream, "%s%Hd", u?", ":"", key->offset[u]); HDfputs ("}\n", stream); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D_istore_debug_key() */ /*------------------------------------------------------------------------- * Function: H5D_istore_cmp2 * * Purpose: Compares two keys sort of like strcmp(). The UDATA pointer * is only to supply extra information not carried in the keys * (in this case, the dimensionality) and is not compared * against the keys. * * Return: Success: -1 if LT_KEY is less than RT_KEY; * 1 if LT_KEY is greater than RT_KEY; * 0 if LT_KEY and RT_KEY are equal. * * Failure: FAIL (same as LT_KEYmesg->u.chunk.ndims > 0 && udata->mesg->u.chunk.ndims <= H5O_LAYOUT_NDIMS); /* Compare the offsets but ignore the other fields */ ret_value = H5V_vector_cmp_u(udata->mesg->u.chunk.ndims, lt_key->offset, rt_key->offset); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_istore_cmp2() */ /*------------------------------------------------------------------------- * Function: H5D_istore_cmp3 * * Purpose: Compare the requested datum UDATA with the left and right * keys of the B-tree. * * Return: Success: negative if the min_corner of UDATA is less * than the min_corner of LT_KEY. * * positive if the min_corner of UDATA is * greater than or equal the min_corner of * RT_KEY. * * zero otherwise. The min_corner of UDATA is * not necessarily contained within the address * space represented by LT_KEY, but a key that * would describe the UDATA min_corner address * would fall lexicographically between LT_KEY * and RT_KEY. * * Failure: FAIL (same as UDATA < LT_KEY) * * Programmer: Robb Matzke * Wednesday, October 8, 1997 * * Modifications: * *------------------------------------------------------------------------- */ /* ARGSUSED */ static int H5D_istore_cmp3(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_lt_key, void *_udata, void *_rt_key) { H5D_istore_key_t *lt_key = (H5D_istore_key_t *) _lt_key; H5D_istore_key_t *rt_key = (H5D_istore_key_t *) _rt_key; H5D_istore_ud1_t *udata = (H5D_istore_ud1_t *) _udata; int ret_value = 0; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_cmp3) assert(lt_key); assert(rt_key); assert(udata); assert(udata->mesg->u.chunk.ndims > 0 && udata->mesg->u.chunk.ndims <= H5O_LAYOUT_NDIMS); /* Special case for faster checks on 1-D chunks */ /* (Checking for ndims==2 because last dimension is the datatype size) */ /* The additional checking for the right key is necessary due to the */ /* slightly odd way the library initializes the right-most node in the */ /* indexed storage B-tree... */ /* (Dump the B-tree with h5debug to look at it) -QAK */ if(udata->mesg->u.chunk.ndims==2) { if(udata->key.offset[0]>rt_key->offset[0]) ret_value=1; else if(udata->key.offset[0]==rt_key->offset[0] && udata->key.offset[1]>=rt_key->offset[1]) ret_value=1; else if(udata->key.offset[0]offset[0]) ret_value=(-1); } /* end if */ else { if (H5V_vector_ge_u(udata->mesg->u.chunk.ndims, udata->key.offset, rt_key->offset)) ret_value = 1; else if (H5V_vector_lt_u(udata->mesg->u.chunk.ndims, udata->key.offset, lt_key->offset)) ret_value = -1; } /* end else */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_istore_cmp3() */ /*------------------------------------------------------------------------- * Function: H5D_istore_new_node * * Purpose: Adds a new entry to an i-storage B-tree. We can assume that * the domain represented by UDATA doesn't intersect the domain * already represented by the B-tree. * * Return: Success: Non-negative. The address of leaf is returned * through the ADDR argument. It is also added * to the UDATA. * * Failure: Negative * * Programmer: Robb Matzke * Tuesday, October 14, 1997 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5D_istore_new_node(H5F_t *f, hid_t dxpl_id, H5B_ins_t op, void *_lt_key, void *_udata, void *_rt_key, haddr_t *addr_p/*out*/) { H5D_istore_key_t *lt_key = (H5D_istore_key_t *) _lt_key; H5D_istore_key_t *rt_key = (H5D_istore_key_t *) _rt_key; H5D_istore_ud1_t *udata = (H5D_istore_ud1_t *) _udata; unsigned u; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5D_istore_new_node) /* check args */ assert(f); assert(lt_key); assert(rt_key); assert(udata); assert(udata->mesg->u.chunk.ndims > 0 && udata->mesg->u.chunk.ndims < H5O_LAYOUT_NDIMS); assert(addr_p); /* Allocate new storage */ assert (udata->key.nbytes > 0); H5_CHECK_OVERFLOW( udata->key.nbytes ,size_t, hsize_t); if (HADDR_UNDEF==(*addr_p=H5MF_alloc(f, H5FD_MEM_DRAW, dxpl_id, (hsize_t)udata->key.nbytes))) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "couldn't allocate new file storage") udata->addr = *addr_p; /* * The left key describes the storage of the UDATA chunk being * inserted into the tree. */ lt_key->nbytes = udata->key.nbytes; lt_key->filter_mask = udata->key.filter_mask; for (u=0; umesg->u.chunk.ndims; u++) lt_key->offset[u] = udata->key.offset[u]; /* * The right key might already be present. If not, then add a zero-width * chunk. */ if (H5B_INS_LEFT != op) { rt_key->nbytes = 0; rt_key->filter_mask = 0; for (u=0; umesg->u.chunk.ndims; u++) { assert (udata->key.offset[u]+udata->mesg->u.chunk.dim[u] > udata->key.offset[u]); rt_key->offset[u] = udata->key.offset[u] + udata->mesg->u.chunk.dim[u]; } } done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_istore_new_node() */ /*------------------------------------------------------------------------- * Function: H5D_istore_found * * Purpose: This function is called when the B-tree search engine has * found the leaf entry that points to a chunk of storage that * contains the beginning of the logical address space * represented by UDATA. The LT_KEY is the left key (the one * that describes the chunk) and RT_KEY is the right key (the * one that describes the next or last chunk). * * Note: It's possible that the chunk isn't really found. For * instance, in a sparse dataset the requested chunk might fall * between two stored chunks in which case this function is * called with the maximum stored chunk indices less than the * requested chunk indices. * * Return: Non-negative on success with information about the chunk * returned through the UDATA argument. Negative on failure. * * Programmer: Robb Matzke * Thursday, October 9, 1997 * * Modifications: * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. *------------------------------------------------------------------------- */ /* ARGSUSED */ static herr_t H5D_istore_found(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, haddr_t addr, const void *_lt_key, void *_udata) { H5D_istore_ud1_t *udata = (H5D_istore_ud1_t *) _udata; const H5D_istore_key_t *lt_key = (const H5D_istore_key_t *) _lt_key; unsigned u; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_found) /* Check arguments */ assert(f); assert(H5F_addr_defined(addr)); assert(udata); assert(lt_key); /* Is this *really* the requested chunk? */ for (u=0; umesg->u.chunk.ndims; u++) if (udata->key.offset[u] >= lt_key->offset[u]+udata->mesg->u.chunk.dim[u]) HGOTO_DONE(FAIL) /* Initialize return values */ udata->addr = addr; udata->key.nbytes = lt_key->nbytes; udata->key.filter_mask = lt_key->filter_mask; assert (lt_key->nbytes>0); for (u = 0; u < udata->mesg->u.chunk.ndims; u++) udata->key.offset[u] = lt_key->offset[u]; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_istore_found() */ /*------------------------------------------------------------------------- * Function: H5D_istore_insert * * Purpose: This function is called when the B-tree insert engine finds * the node to use to insert new data. The UDATA argument * points to a struct that describes the logical addresses being * added to the file. This function allocates space for the * data and returns information through UDATA describing a * file chunk to receive (part of) the data. * * The LT_KEY is always the key describing the chunk of file * memory at address ADDR. On entry, UDATA describes the logical * addresses for which storage is being requested (through the * `offset' and `size' fields). On return, UDATA describes the * logical addresses contained in a chunk on disk. * * Return: Success: An insertion command for the caller, one of * the H5B_INS_* constants. The address of the * new chunk is returned through the NEW_NODE * argument. * * Failure: H5B_INS_ERROR * * Programmer: Robb Matzke * Thursday, October 9, 1997 * * Modifications: * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. The NEW_NODE argument * is renamed NEW_NODE_P. *------------------------------------------------------------------------- */ /* ARGSUSED */ static H5B_ins_t H5D_istore_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key, hbool_t *lt_key_changed, void *_md_key, void *_udata, void *_rt_key, hbool_t UNUSED *rt_key_changed, haddr_t *new_node_p/*out*/) { H5D_istore_key_t *lt_key = (H5D_istore_key_t *) _lt_key; H5D_istore_key_t *md_key = (H5D_istore_key_t *) _md_key; H5D_istore_key_t *rt_key = (H5D_istore_key_t *) _rt_key; H5D_istore_ud1_t *udata = (H5D_istore_ud1_t *) _udata; int cmp; unsigned u; H5B_ins_t ret_value; FUNC_ENTER_NOAPI_NOINIT(H5D_istore_insert) /* check args */ assert(f); assert(H5F_addr_defined(addr)); assert(lt_key); assert(lt_key_changed); assert(md_key); assert(udata); assert(rt_key); assert(new_node_p); cmp = H5D_istore_cmp3(f, dxpl_id, lt_key, udata, rt_key); assert(cmp <= 0); if (cmp < 0) { /* Negative indices not supported yet */ HGOTO_ERROR(H5E_STORAGE, H5E_UNSUPPORTED, H5B_INS_ERROR, "internal error") } else if (H5V_vector_eq_u (udata->mesg->u.chunk.ndims, udata->key.offset, lt_key->offset) && lt_key->nbytes>0) { /* * Already exists. If the new size is not the same as the old size * then we should reallocate storage. */ if (lt_key->nbytes != udata->key.nbytes) { /* Currently, the old chunk data is "thrown away" after the space is reallocated, * so avoid data copy in H5MF_realloc() call by just free'ing the space and * allocating new space. * * This should keep the file smaller also, by freeing the space and then * allocating new space, instead of vice versa (in H5MF_realloc). * * QAK - 11/19/2002 */ #ifdef OLD_WAY if (HADDR_UNDEF==(*new_node_p=H5MF_realloc(f, H5FD_MEM_DRAW, addr, (hsize_t)lt_key->nbytes, (hsize_t)udata->key.nbytes))) HGOTO_ERROR (H5E_STORAGE, H5E_NOSPACE, H5B_INS_ERROR, "unable to reallocate chunk storage") #else /* OLD_WAY */ H5_CHECK_OVERFLOW( lt_key->nbytes ,size_t, hsize_t); if (H5MF_xfree(f, H5FD_MEM_DRAW, dxpl_id, addr, (hsize_t)lt_key->nbytes)<0) HGOTO_ERROR(H5E_STORAGE, H5E_CANTFREE, H5B_INS_ERROR, "unable to free chunk") H5_CHECK_OVERFLOW( udata->key.nbytes ,size_t, hsize_t); if (HADDR_UNDEF==(*new_node_p=H5MF_alloc(f, H5FD_MEM_DRAW, dxpl_id, (hsize_t)udata->key.nbytes))) HGOTO_ERROR(H5E_STORAGE, H5E_NOSPACE, H5B_INS_ERROR, "unable to reallocate chunk") #endif /* OLD_WAY */ lt_key->nbytes = udata->key.nbytes; lt_key->filter_mask = udata->key.filter_mask; *lt_key_changed = TRUE; udata->addr = *new_node_p; ret_value = H5B_INS_CHANGE; } else { udata->addr = addr; ret_value = H5B_INS_NOOP; } } else if (H5V_hyper_disjointp(udata->mesg->u.chunk.ndims, lt_key->offset, udata->mesg->u.chunk.dim, udata->key.offset, udata->mesg->u.chunk.dim)) { assert(H5V_hyper_disjointp(udata->mesg->u.chunk.ndims, rt_key->offset, udata->mesg->u.chunk.dim, udata->key.offset, udata->mesg->u.chunk.dim)); /* * Split this node, inserting the new new node to the right of the * current node. The MD_KEY is where the split occurs. */ md_key->nbytes = udata->key.nbytes; md_key->filter_mask = udata->key.filter_mask; for (u=0; umesg->u.chunk.ndims; u++) { assert(0 == udata->key.offset[u] % udata->mesg->u.chunk.dim[u]); md_key->offset[u] = udata->key.offset[u]; } /* * Allocate storage for the new chunk */ H5_CHECK_OVERFLOW( udata->key.nbytes ,size_t, hsize_t); if (HADDR_UNDEF==(*new_node_p=H5MF_alloc(f, H5FD_MEM_DRAW, dxpl_id, (hsize_t)udata->key.nbytes))) HGOTO_ERROR(H5E_STORAGE, H5E_NOSPACE, H5B_INS_ERROR, "file allocation failed") udata->addr = *new_node_p; ret_value = H5B_INS_RIGHT; } else { HGOTO_ERROR(H5E_IO, H5E_UNSUPPORTED, H5B_INS_ERROR, "internal error") } done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_istore_insert() */ /*------------------------------------------------------------------------- * Function: H5D_istore_iter_allocated * * Purpose: Simply counts the number of chunks for a dataset. * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Wednesday, April 21, 1999 * * Modifications: * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. * * Quincey Koziol, 2002-04-22 * Changed to callback from H5B_iterate *------------------------------------------------------------------------- */ /* ARGSUSED */ static int H5D_istore_iter_allocated (H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_lt_key, haddr_t UNUSED addr, const void UNUSED *_rt_key, void *_udata) { H5D_istore_ud1_t *bt_udata = (H5D_istore_ud1_t *)_udata; const H5D_istore_key_t *lt_key = (const H5D_istore_key_t *)_lt_key; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_iter_allocated) bt_udata->total_storage += lt_key->nbytes; FUNC_LEAVE_NOAPI(H5B_ITER_CONT) } /* H5D_istore_iter_allocated() */ /*------------------------------------------------------------------------- * Function: H5D_istore_iter_dump * * Purpose: If the UDATA.STREAM member is non-null then debugging * information is written to that stream. * * Return: Success: Non-negative * * Failure: Negative * * Programmer: Robb Matzke * Wednesday, April 21, 1999 * * Modifications: * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. * * Quincey Koziol, 2002-04-22 * Changed to callback from H5B_iterate *------------------------------------------------------------------------- */ /* ARGSUSED */ static int H5D_istore_iter_dump (H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_lt_key, haddr_t UNUSED addr, const void UNUSED *_rt_key, void *_udata) { H5D_istore_ud1_t *bt_udata = (H5D_istore_ud1_t *)_udata; const H5D_istore_key_t *lt_key = (const H5D_istore_key_t *)_lt_key; unsigned u; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_iter_dump) if (bt_udata->stream) { if (0==bt_udata->total_storage) { fprintf(bt_udata->stream, " Flags Bytes Address Logical Offset\n"); fprintf(bt_udata->stream, " ========== ======== ========== " "==============================\n"); } HDfprintf(bt_udata->stream, " 0x%08x %8Zu %10a [", lt_key->filter_mask, lt_key->nbytes, addr); for (u=0; umesg->u.chunk.ndims; u++) HDfprintf(bt_udata->stream, "%s%Hd", u?", ":"", lt_key->offset[u]); HDfputs("]\n", bt_udata->stream); /* Use "total storage" information as flag for printing headers */ bt_udata->total_storage++; } FUNC_LEAVE_NOAPI(H5B_ITER_CONT) } /* H5D_istore_iter_dump() */ /*------------------------------------------------------------------------- * Function: H5D_istore_init * * Purpose: Initialize the raw data chunk cache for a dataset. This is * called when the dataset is initialized. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Monday, May 18, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5D_istore_init (const H5F_t *f, const H5D_t *dset) { H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5D_istore_init, FAIL) if (H5F_RDCC_NBYTES(f)>0 && H5F_RDCC_NELMTS(f)>0) { rdcc->nbytes=H5F_RDCC_NBYTES(f); rdcc->nslots = H5F_RDCC_NELMTS(f); rdcc->slot = H5FL_SEQ_CALLOC (H5D_rdcc_ent_ptr_t,rdcc->nslots); if (NULL==rdcc->slot) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") } /* end if */ /* Allocate the shared structure */ if(H5D_istore_shared_create(f, &dset->shared->layout)<0) HGOTO_ERROR (H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create wrapper for shared B-tree info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_istore_init() */ /*------------------------------------------------------------------------- * Function: H5D_istore_flush_entry * * Purpose: Writes a chunk to disk. If RESET is non-zero then the * entry is cleared -- it's slightly faster to flush a chunk if * the RESET flag is turned on because it results in one fewer * memory copy. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Thursday, May 21, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5D_istore_flush_entry(const H5D_io_info_t *io_info, H5D_rdcc_ent_t *ent, hbool_t reset) { herr_t ret_value=SUCCEED; /*return value */ unsigned u; /*counters */ void *buf=NULL; /*temporary buffer */ size_t alloc; /*bytes allocated for BUF */ hbool_t point_of_no_return = FALSE; FUNC_ENTER_NOAPI_NOINIT(H5D_istore_flush_entry) assert(io_info); assert(io_info->dset); assert(ent); assert(!ent->locked); buf = ent->chunk; if (ent->dirty) { H5D_istore_ud1_t udata; /*pass through B-tree */ udata.mesg = &io_info->dset->shared->layout; udata.key.filter_mask = 0; udata.addr = HADDR_UNDEF; udata.key.nbytes = ent->chunk_size; for (u=0; udset->shared->layout.u.chunk.ndims; u++) udata.key.offset[u] = ent->offset[u]; alloc = ent->alloc_size; /* Should the chunk be filtered before writing it to disk? */ if (io_info->dset->shared->dcpl_cache.pline.nused) { if (!reset) { /* * Copy the chunk to a new buffer before running it through * the pipeline because we'll want to save the original buffer * for later. */ alloc = ent->chunk_size; if (NULL==(buf = H5MM_malloc(alloc))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for pipeline") HDmemcpy(buf, ent->chunk, ent->chunk_size); } else { /* * If we are reseting and something goes wrong after this * point then it's too late to recover because we may have * destroyed the original data by calling H5Z_pipeline(). * The only safe option is to continue with the reset * even if we can't write the data to disk. */ point_of_no_return = TRUE; ent->chunk = NULL; } if (H5Z_pipeline(&(io_info->dset->shared->dcpl_cache.pline), 0, &(udata.key.filter_mask), io_info->dxpl_cache->err_detect, io_info->dxpl_cache->filter_cb, &(udata.key.nbytes), &alloc, &buf)<0) HGOTO_ERROR(H5E_PLINE, H5E_WRITEERROR, FAIL, "output pipeline failed") } /* * Create the chunk it if it doesn't exist, or reallocate the chunk if * its size changed. Then write the data into the file. */ if (H5B_insert(io_info->dset->ent.file, io_info->dxpl_id, H5B_ISTORE, io_info->dset->shared->layout.u.chunk.addr, &udata)<0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to allocate chunk") if (H5F_block_write(io_info->dset->ent.file, H5FD_MEM_DRAW, udata.addr, udata.key.nbytes, io_info->dxpl_id, buf)<0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write raw data to file") /* Mark cache entry as clean */ ent->dirty = FALSE; #ifdef H5D_ISTORE_DEBUG io_info->dset->shared->cache.chunk.nflushes++; #endif /* H5D_ISTORE_DEBUG */ } /* end if */ /* Reset, but do not free or removed from list */ if (reset) { point_of_no_return = FALSE; if(buf==ent->chunk) buf = NULL; if(ent->chunk!=NULL) ent->chunk = H5D_istore_chunk_xfree(ent->chunk,&(io_info->dset->shared->dcpl_cache.pline)); } /* end if */ done: /* Free the temp buffer only if it's different than the entry chunk */ if (buf!=ent->chunk) H5MM_xfree(buf); /* * If we reached the point of no return then we have no choice but to * reset the entry. This can only happen if RESET is true but the * output pipeline failed. Do not free the entry or remove it from the * list. */ if (ret_value<0 && point_of_no_return) { if(ent->chunk) ent->chunk = H5D_istore_chunk_xfree(ent->chunk,&(io_info->dset->shared->dcpl_cache.pline)); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_istore_flush_entry() */ /*------------------------------------------------------------------------- * Function: H5D_istore_preempt * * Purpose: Preempts the specified entry from the cache, flushing it to * disk if necessary. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Thursday, May 21, 1998 * * Modifications: * Pedro Vicente, March 28, 2002 * Added flush parameter that switches the call to H5F_istore_flush_entry * The call with FALSE is used by the H5F_istore_prune_by_extent function * *------------------------------------------------------------------------- */ static herr_t H5D_istore_preempt(const H5D_io_info_t *io_info, H5D_rdcc_ent_t * ent, hbool_t flush) { H5D_rdcc_t *rdcc = &(io_info->dset->shared->cache.chunk); herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5D_istore_preempt) assert(io_info); assert(ent); assert(!ent->locked); assert(ent->idx < rdcc->nslots); if(flush) { /* Flush */ if(H5D_istore_flush_entry(io_info, ent, TRUE) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "cannot flush indexed storage buffer") } else { /* Don't flush, just free chunk */ if(ent->chunk != NULL) ent->chunk = H5D_istore_chunk_xfree(ent->chunk,&(io_info->dset->shared->dcpl_cache.pline)); } /* Unlink from list */ if(ent->prev) ent->prev->next = ent->next; else rdcc->head = ent->next; if(ent->next) ent->next->prev = ent->prev; else rdcc->tail = ent->prev; ent->prev = ent->next = NULL; /* Remove from cache */ rdcc->slot[ent->idx] = NULL; ent->idx = UINT_MAX; rdcc->nbytes -= ent->chunk_size; --rdcc->nused; /* Free */ H5FL_FREE(H5D_rdcc_ent_t, ent); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_istore_preempt() */ /*------------------------------------------------------------------------- * Function: H5D_istore_flush * * Purpose: Writes all dirty chunks to disk and optionally preempts them * from the cache. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Thursday, May 21, 1998 * * Modifications: * Pedro Vicente, March 28, 2002 * Added TRUE parameter to the call to H5F_istore_preempt * *------------------------------------------------------------------------- */ herr_t H5D_istore_flush (H5D_t *dset, hid_t dxpl_id, unsigned flags) { H5D_io_info_t io_info; /* Temporary I/O info object */ H5D_dxpl_cache_t _dxpl_cache; /* Data transfer property cache buffer */ H5D_dxpl_cache_t *dxpl_cache=&_dxpl_cache; /* Data transfer property cache */ H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); int nerrors=0; H5D_rdcc_ent_t *ent=NULL, *next=NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5D_istore_flush, FAIL) /* Fill the DXPL cache values for later use */ if (H5D_get_dxpl_cache(dxpl_id,&dxpl_cache)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't fill dxpl cache") /* Construct dataset I/O info */ H5D_BUILD_IO_INFO(&io_info,dset,dxpl_cache,dxpl_id,NULL); for (ent=rdcc->head; ent; ent=next) { next = ent->next; if ((flags&H5F_FLUSH_CLEAR_ONLY)) { /* Just mark cache entry as clean */ ent->dirty = FALSE; } /* end if */ else if ((flags&H5F_FLUSH_INVALIDATE)) { if (H5D_istore_preempt(&io_info, ent, TRUE )<0) nerrors++; } else { if (H5D_istore_flush_entry(&io_info, ent, FALSE)<0) nerrors++; } } /* end for */ if (nerrors) HGOTO_ERROR (H5E_IO, H5E_CANTFLUSH, FAIL, "unable to flush one or more raw data chunks") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_istore_flush() */ /*------------------------------------------------------------------------- * Function: H5D_istore_dest * * Purpose: Destroy the entire chunk cache by flushing dirty entries, * preempting all entries, and freeing the cache itself. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Thursday, May 21, 1998 * * Modifications: * Pedro Vicente, March 28, 2002 * Added TRUE parameter to the call to H5F_istore_preempt * *------------------------------------------------------------------------- */ herr_t H5D_istore_dest (H5D_t *dset, hid_t dxpl_id) { H5D_io_info_t io_info; /* Temporary I/O info object */ H5D_dxpl_cache_t _dxpl_cache; /* Data transfer property cache buffer */ H5D_dxpl_cache_t *dxpl_cache=&_dxpl_cache; /* Data transfer property cache */ H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); int nerrors=0; H5D_rdcc_ent_t *ent=NULL, *next=NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5D_istore_dest, FAIL) assert(dset); /* Fill the DXPL cache values for later use */ if (H5D_get_dxpl_cache(dxpl_id,&dxpl_cache)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't fill dxpl cache") /* Construct dataset I/O info */ H5D_BUILD_IO_INFO(&io_info,dset,dxpl_cache,dxpl_id,NULL); /* Flush all the cached chunks */ for (ent=rdcc->head; ent; ent=next) { #ifdef H5D_ISTORE_DEBUG HDfputc('c', stderr); HDfflush(stderr); #endif next = ent->next; if (H5D_istore_preempt(&io_info, ent, TRUE )<0) nerrors++; } if (nerrors) HGOTO_ERROR (H5E_IO, H5E_CANTFLUSH, FAIL, "unable to flush one or more raw data chunks") if(rdcc->slot) H5FL_SEQ_FREE (H5D_rdcc_ent_ptr_t,rdcc->slot); HDmemset (rdcc, 0, sizeof(H5D_rdcc_t)); /* Free the raw B-tree node buffer */ if(dset->shared->layout.u.chunk.btree_shared==NULL) HGOTO_ERROR (H5E_IO, H5E_CANTFREE, FAIL, "ref-counted page nil") if(H5RC_DEC(dset->shared->layout.u.chunk.btree_shared)<0) HGOTO_ERROR (H5E_IO, H5E_CANTFREE, FAIL, "unable to decrement ref-counted page") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_istore_dest() */ /*------------------------------------------------------------------------- * Function: H5D_istore_shared_create * * Purpose: Create & initialize B-tree shared info * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Monday, September 27, 2004 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5D_istore_shared_create (const H5F_t *f, H5O_layout_t *layout) { H5D_istore_ud1_t udata; H5B_shared_t *shared; /* Shared B-tree node info */ size_t u; /* Local index variable */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5D_istore_shared_create) /* Initialize "user" data for B-tree callbacks, etc. */ udata.mesg = layout; /* Allocate space for the shared structure */ if(NULL==(shared=H5FL_MALLOC(H5B_shared_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for shared B-tree info") /* Set up the "global" information for this file's groups */ shared->type= H5B_ISTORE; shared->two_k=2*H5F_KVALUE(f,H5B_ISTORE); shared->sizeof_rkey = H5D_istore_sizeof_rkey(f, &udata); assert(shared->sizeof_rkey); shared->sizeof_rnode = H5B_nodesize(f, shared, &shared->sizeof_keys); assert(shared->sizeof_rnode); if(NULL==(shared->page=H5FL_BLK_MALLOC(chunk_page,shared->sizeof_rnode))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree page") #ifdef H5_USING_PURIFY HDmemset(shared->page,0,shared->sizeof_rnode); #endif /* H5_USING_PURIFY */ if(NULL==(shared->nkey=H5FL_SEQ_MALLOC(size_t,(size_t)(2*H5F_KVALUE(f,H5B_ISTORE)+1)))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree page") /* Initialize the offsets into the native key buffer */ for(u=0; u<(2*H5F_KVALUE(f,H5B_ISTORE)+1); u++) shared->nkey[u]=u*H5B_ISTORE[0].sizeof_nkey; /* Make shared B-tree info reference counted */ if(NULL==(layout->u.chunk.btree_shared=H5RC_create(shared,H5D_istore_shared_free))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't create ref-count wrapper for shared B-tree info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_istore_shared_create() */ /*------------------------------------------------------------------------- * Function: H5D_istore_shared_free * * Purpose: Free B-tree shared info * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Thursday, July 8, 2004 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5D_istore_shared_free (void *_shared) { H5B_shared_t *shared = (H5B_shared_t *)_shared; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_shared_free) /* Free the raw B-tree node buffer */ H5FL_BLK_FREE(chunk_page,shared->page); /* Free the B-tree native key offsets buffer */ H5FL_SEQ_FREE(size_t,shared->nkey); /* Free the shared B-tree info */ H5FL_FREE(H5B_shared_t,shared); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D_istore_shared_free() */ /*------------------------------------------------------------------------- * Function: H5D_istore_prune * * Purpose: Prune the cache by preempting some things until the cache has * room for something which is SIZE bytes. Only unlocked * entries are considered for preemption. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Thursday, May 21, 1998 * * Modifications: * Pedro Vicente, March 28, 2002 * TRUE parameter to the call to H5F_istore_preempt * *------------------------------------------------------------------------- */ static herr_t H5D_istore_prune (const H5D_io_info_t *io_info, size_t size) { int i, j, nerrors=0; const H5D_rdcc_t *rdcc = &(io_info->dset->shared->cache.chunk); size_t total = rdcc->nbytes; const int nmeth=2; /*number of methods */ int w[1]; /*weighting as an interval */ H5D_rdcc_ent_t *p[2], *cur; /*list pointers */ H5D_rdcc_ent_t *n[2]; /*list next pointers */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5D_istore_prune) /* * Preemption is accomplished by having multiple pointers (currently two) * slide down the list beginning at the head. Pointer p(N+1) will start * traversing the list when pointer pN reaches wN percent of the original * list. In other words, preemption method N gets to consider entries in * approximate least recently used order w0 percent before method N+1 * where 100% means tha method N will run to completion before method N+1 * begins. The pointers participating in the list traversal are each * given a chance at preemption before any of the pointers are advanced. */ w[0] = (int)(rdcc->nused * H5F_RDCC_W0(io_info->dset->ent.file)); p[0] = rdcc->head; p[1] = NULL; while ((p[0] || p[1]) && rdcc->nbytes+size>total) { /* Introduce new pointers */ for (i=0; ihead; /* Compute next value for each pointer */ for (i=0; inext : NULL; /* Give each method a chance */ for (i=0; inbytes+size>total; i++) { if (0==i && p[0] && !p[0]->locked && ((0==p[0]->rd_count && 0==p[0]->wr_count) || (0==p[0]->rd_count && p[0]->chunk_size==p[0]->wr_count) || (p[0]->chunk_size==p[0]->rd_count && 0==p[0]->wr_count))) { /* * Method 0: Preempt entries that have been completely written * and/or completely read but not entries that are partially * written or partially read. */ cur = p[0]; #ifdef H5D_ISTORE_DEBUG HDputc('.', stderr); HDfflush(stderr); #endif } else if (1==i && p[1] && !p[1]->locked) { /* * Method 1: Preempt the entry without regard to * considerations other than being locked. This is the last * resort preemption. */ cur = p[1]; #ifdef H5D_ISTORE_DEBUG HDputc(':', stderr); HDfflush(stderr); #endif } else { /* Nothing to preempt at this point */ cur= NULL; } if (cur) { for (j=0; jnext; } if (H5D_istore_preempt(io_info, cur, TRUE)<0) nerrors++; } } /* Advance pointers */ for (i=0; idset; /* Local pointer to the dataset info */ const H5O_pline_t *pline=&(dset->shared->dcpl_cache.pline); /* I/O pipeline info */ const H5O_layout_t *layout=&(dset->shared->layout); /* Dataset layout */ const H5O_fill_t *fill=&(dset->shared->dcpl_cache.fill); /* Fill value info */ H5D_fill_time_t fill_time=dset->shared->dcpl_cache.fill_time; /* Fill time */ H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk);/*raw data chunk cache*/ H5D_rdcc_ent_t *ent = NULL; /*cache entry */ unsigned idx=0; /*hash index number */ hbool_t found = FALSE; /*already in cache? */ unsigned u; /*counters */ size_t chunk_size=0; /*size of a chunk */ void *chunk=NULL; /*the file chunk */ void *ret_value; /*return value */ FUNC_ENTER_NOAPI_NOINIT(H5D_istore_lock) assert(io_info); assert(dset); assert(io_info->dxpl_cache); assert(io_info->store); assert(TRUE==H5P_isa_class(io_info->dxpl_id,H5P_DATASET_XFER)); /* Get the chunk's size */ assert(layout->u.chunk.size>0); H5_ASSIGN_OVERFLOW(chunk_size,layout->u.chunk.size,hsize_t,size_t); /* Search for the chunk in the cache */ if (rdcc->nslots>0) { idx=H5D_HASH(dset->shared,io_info->store->chunk.index); ent = rdcc->slot[idx]; if (ent) { for (u=0, found=TRUE; uu.chunk.ndims; u++) { if (io_info->store->chunk.offset[u]!=ent->offset[u]) { found = FALSE; break; } /* end if */ } /* end for */ } /* end if */ } /* end if */ if (found) { /* * Already in the cache. Count a hit. */ #ifdef H5D_ISTORE_DEBUG rdcc->nhits++; #endif /* H5D_ISTORE_DEBUG */ } else if (relax) { /* * Not in the cache, but we're about to overwrite the whole thing * anyway, so just allocate a buffer for it but don't initialize that * buffer with the file contents. Count this as a hit instead of a * miss because we saved ourselves lots of work. */ #ifdef H5D_ISTORE_DEBUG HDputc('w', stderr); HDfflush(stderr); rdcc->nhits++; #endif if (NULL==(chunk=H5D_istore_chunk_alloc (chunk_size,pline))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for raw data chunk") } else { H5D_istore_ud1_t tmp_udata; /*B-tree pass-through */ haddr_t chunk_addr; /* Address of chunk on disk */ if(udata!=NULL) chunk_addr=udata->addr; else { /* Point at temporary storage for B-tree pass through */ udata=&tmp_udata; /* * Not in the cache. Read it from the file and count this as a miss * if it's in the file or an init if it isn't. */ chunk_addr = H5D_istore_get_addr(io_info, udata); } /* end else */ if (H5F_addr_defined(chunk_addr)) { size_t chunk_alloc=0; /*allocated chunk size */ /* * The chunk exists on disk. */ /* Chunk size on disk isn't [likely] the same size as the final chunk * size in memory, so allocate memory big enough. */ chunk_alloc = udata->key.nbytes; if (NULL==(chunk = H5D_istore_chunk_alloc (chunk_alloc,pline))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for raw data chunk") if (H5F_block_read(dset->ent.file, H5FD_MEM_DRAW, chunk_addr, udata->key.nbytes, io_info->dxpl_id, chunk)<0) HGOTO_ERROR (H5E_IO, H5E_READERROR, NULL, "unable to read raw data chunk") if (pline->nused) if (H5Z_pipeline(pline, H5Z_FLAG_REVERSE, &(udata->key.filter_mask), io_info->dxpl_cache->err_detect, io_info->dxpl_cache->filter_cb, &(udata->key.nbytes), &chunk_alloc, &chunk)<0) { HGOTO_ERROR(H5E_PLINE, H5E_READERROR, NULL, "data pipeline read failed") } #ifdef H5D_ISTORE_DEBUG rdcc->nmisses++; #endif /* H5D_ISTORE_DEBUG */ } else { H5D_fill_value_t fill_status; #ifdef OLD_WAY /* Clear the error stack from not finding the chunk on disk */ H5E_clear(); #endif /* OLD_WAY */ /* Chunk size on disk isn't [likely] the same size as the final chunk * size in memory, so allocate memory big enough. */ if (NULL==(chunk = H5D_istore_chunk_alloc (chunk_size,pline))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for raw data chunk") if (H5P_is_fill_value_defined(fill, &fill_status) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't tell if fill value defined") if(fill_time==H5D_FILL_TIME_ALLOC || (fill_time==H5D_FILL_TIME_IFSET && fill_status==H5D_FILL_VALUE_USER_DEFINED)) { if (fill && fill->buf) { /* * The chunk doesn't exist in the file. Replicate the fill * value throughout the chunk. */ assert(0==chunk_size % fill->size); H5V_array_fill(chunk, fill->buf, fill->size, chunk_size/fill->size); } else { /* * The chunk doesn't exist in the file and no fill value was * specified. Assume all zeros. */ HDmemset (chunk, 0, chunk_size); } /* end else */ } /* end if */ #ifdef H5_USING_PURIFY else HDmemset(chunk,0,chunk_size); #endif /* H5_USING_PURIFY */ #ifdef H5D_ISTORE_DEBUG rdcc->ninits++; #endif /* H5D_ISTORE_DEBUG */ } /* end else */ } assert (found || chunk_size>0); if (!found && rdcc->nslots>0 && chunk_size<=rdcc->nbytes && (!ent || !ent->locked)) { /* * Add the chunk to the cache only if the slot is not already locked. * Preempt enough things from the cache to make room. */ if (ent) { #ifdef H5D_ISTORE_DEBUG HDputc('#', stderr); HDfflush(stderr); #endif if (H5D_istore_preempt(io_info, ent, TRUE)<0) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, NULL, "unable to preempt chunk from cache") } if (H5D_istore_prune(io_info, chunk_size)<0) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, NULL, "unable to preempt chunk(s) from cache") /* Create a new entry */ ent = H5FL_MALLOC(H5D_rdcc_ent_t); ent->locked = 0; ent->dirty = FALSE; ent->chunk_size = chunk_size; ent->alloc_size = chunk_size; for (u=0; uu.chunk.ndims; u++) ent->offset[u] = io_info->store->chunk.offset[u]; ent->rd_count = chunk_size; ent->wr_count = chunk_size; ent->chunk = chunk; /* Add it to the cache */ assert(NULL==rdcc->slot[idx]); rdcc->slot[idx] = ent; ent->idx = idx; rdcc->nbytes += chunk_size; rdcc->nused++; /* Add it to the linked list */ ent->next = NULL; if (rdcc->tail) { rdcc->tail->next = ent; ent->prev = rdcc->tail; rdcc->tail = ent; } else { rdcc->head = rdcc->tail = ent; ent->prev = NULL; } found = TRUE; } else if (!found) { /* * The chunk is larger than the entire cache so we don't cache it. * This is the reason all those arguments have to be repeated for the * unlock function. */ ent = NULL; idx = UINT_MAX; } else { /* * The chunk is not at the beginning of the cache; move it backward * by one slot. This is how we implement the LRU preemption * algorithm. */ assert(ent); if (ent->next) { if (ent->next->next) ent->next->next->prev = ent; else rdcc->tail = ent; ent->next->prev = ent->prev; if (ent->prev) ent->prev->next = ent->next; else rdcc->head = ent->next; ent->prev = ent->next; ent->next = ent->next->next; ent->prev->next = ent; } } /* Lock the chunk into the cache */ if (ent) { assert (!ent->locked); ent->locked = TRUE; chunk = ent->chunk; } if (idx_hint) *idx_hint = idx; /* Set return value */ ret_value = chunk; done: if (!ret_value) if(chunk) chunk=H5D_istore_chunk_xfree (chunk,pline); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_istore_lock() */ /*------------------------------------------------------------------------- * Function: H5D_istore_unlock * * Purpose: Unlocks a previously locked chunk. The LAYOUT, COMP, and * OFFSET arguments should be the same as for H5F_rdcc_lock(). * The DIRTY argument should be set to non-zero if the chunk has * been modified since it was locked. The IDX_HINT argument is * the returned index hint from the lock operation and BUF is * the return value from the lock. * * The NACCESSED argument should be the number of bytes accessed * for reading or writing (depending on the value of DIRTY). * It's only purpose is to provide additional information to the * preemption policy. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Thursday, May 21, 1998 * * Modifications: * Robb Matzke, 1999-08-02 * The split_ratios are passed as part of the data transfer * property list. *------------------------------------------------------------------------- */ static herr_t H5D_istore_unlock(const H5D_io_info_t *io_info, hbool_t dirty, unsigned idx_hint, uint8_t *chunk, size_t naccessed) { const H5O_layout_t *layout=&(io_info->dset->shared->layout); /* Dataset layout */ const H5D_rdcc_t *rdcc = &(io_info->dset->shared->cache.chunk); H5D_rdcc_ent_t *ent = NULL; unsigned u; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5D_istore_unlock) assert(io_info); if (UINT_MAX==idx_hint) { /* * It's not in the cache, probably because it's too big. If it's * dirty then flush it to disk. In any case, free the chunk. * Note: we have to copy the layout and filter messages so we * don't discard the `const' qualifier. */ if (dirty) { H5D_rdcc_ent_t x; HDmemset (&x, 0, sizeof x); x.dirty = TRUE; for (u=0; uu.chunk.ndims; u++) x.offset[u] = io_info->store->chunk.offset[u]; assert(layout->u.chunk.size>0); H5_ASSIGN_OVERFLOW(x.chunk_size,layout->u.chunk.size,hsize_t,size_t); x.alloc_size = x.chunk_size; x.chunk = chunk; if (H5D_istore_flush_entry(io_info, &x, TRUE)<0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "cannot flush indexed storage buffer") } else { if(chunk) chunk=H5D_istore_chunk_xfree (chunk,&(io_info->dset->shared->dcpl_cache.pline)); } } else { /* Sanity check */ assert(idx_hintnslots); assert(rdcc->slot[idx_hint]); assert(rdcc->slot[idx_hint]->chunk==chunk); /* * It's in the cache so unlock it. */ ent = rdcc->slot[idx_hint]; assert (ent->locked); if (dirty) { ent->dirty = TRUE; ent->wr_count -= MIN (ent->wr_count, naccessed); } else { ent->rd_count -= MIN (ent->rd_count, naccessed); } ent->locked = FALSE; } done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_istore_unlock() */ /*------------------------------------------------------------------------- * Function: H5D_istore_readvv * * Purpose: Reads a multi-dimensional buffer from (part of) an indexed raw * storage array. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Wednesday, May 7, 2003 * * Modifications: * *------------------------------------------------------------------------- */ ssize_t H5D_istore_readvv(const H5D_io_info_t *io_info, size_t chunk_max_nseq, size_t *chunk_curr_seq, size_t chunk_len_arr[], hsize_t chunk_offset_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[], void *buf) { H5D_t *dset=io_info->dset; /* Local pointer to the dataset info */ H5D_istore_ud1_t udata; /*B-tree pass-through */ haddr_t chunk_addr; /* Chunk address on disk */ size_t u; /* Local index variables */ ssize_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5D_istore_readvv, FAIL) /* Check args */ assert(io_info); assert(dset && H5D_CHUNKED==dset->shared->layout.type); assert(dset->shared->layout.u.chunk.ndims>0 && dset->shared->layout.u.chunk.ndims<=H5O_LAYOUT_NDIMS); assert(io_info->dxpl_cache); assert(io_info->store); assert(chunk_len_arr); assert(chunk_offset_arr); assert(mem_len_arr); assert(mem_offset_arr); assert(buf); /* Get the address of this chunk on disk */ #ifdef QAK HDfprintf(stderr,"%s: io_info->store->chunk.offset={",FUNC); for(u=0; ushared->layout.u.chunk.ndims; u++) HDfprintf(stderr,"%Hd%s",io_info->store->chunk.offset[u],(u<(dset->shared->layout.u.chunk.ndims-1) ? ", " : "}\n")); #endif /* QAK */ chunk_addr=H5D_istore_get_addr(io_info, &udata); #ifdef QAK HDfprintf(stderr,"%s: chunk_addr=%a, chunk_size=%Zu\n",FUNC,chunk_addr,dset->shared->layout.u.chunk.size); HDfprintf(stderr,"%s: chunk_len_arr[%Zu]=%Zu\n",FUNC,*chunk_curr_seq,chunk_len_arr[*chunk_curr_seq]); HDfprintf(stderr,"%s: chunk_offset_arr[%Zu]=%Hu\n",FUNC,*chunk_curr_seq,chunk_offset_arr[*chunk_curr_seq]); HDfprintf(stderr,"%s: mem_len_arr[%Zu]=%Zu\n",FUNC,*mem_curr_seq,mem_len_arr[*mem_curr_seq]); HDfprintf(stderr,"%s: mem_offset_arr[%Zu]=%Hu\n",FUNC,*mem_curr_seq,mem_offset_arr[*mem_curr_seq]); HDfprintf(stderr,"%s: buf=%p\n",FUNC,buf); #endif /* QAK */ /* * If the chunk is too large to load into the cache and it has no * filters in the pipeline (i.e. not compressed) and if the address * for the chunk has been defined, then don't load the chunk into the * cache, just read the data from it directly. * * If MPI based VFD is used, must bypass the * chunk-cache scheme because other MPI processes could be * writing to other elements in the same chunk. Do a direct * read-through of only the elements requested. */ if (dset->shared->dcpl_cache.pline.nused==0 && ((dset->shared->layout.u.chunk.size>dset->shared->cache.chunk.nbytes && chunk_addr!=HADDR_UNDEF) || (IS_H5FD_MPI(dset->ent.file) && (H5F_ACC_RDWR & H5F_get_intent(dset->ent.file))))) { H5D_io_info_t chk_io_info; /* Temporary I/O info object */ H5D_storage_t chk_store; /* Chunk storage information */ /* Set up the storage information for the chunk */ chk_store.contig.dset_addr=chunk_addr; chk_store.contig.dset_size=(hsize_t)dset->shared->layout.u.chunk.size; /* Set up new dataset I/O info */ H5D_BUILD_IO_INFO(&chk_io_info,dset,io_info->dxpl_cache,io_info->dxpl_id,&chk_store); /* Do I/O directly on chunk without reading it into the cache */ if ((ret_value=H5D_contig_readvv(&chk_io_info, chunk_max_nseq, chunk_curr_seq, chunk_len_arr, chunk_offset_arr, mem_max_nseq, mem_curr_seq, mem_len_arr, mem_offset_arr, buf))<0) HGOTO_ERROR (H5E_IO, H5E_READERROR, FAIL, "unable to read raw data to file") } /* end if */ else { uint8_t *chunk; /* Pointer to cached chunk in memory */ unsigned idx_hint=0; /* Cache index hint */ ssize_t naccessed; /* Number of bytes accessed in chunk */ /* If the chunk address is not defined, check if the fill value is * undefined also. If both situations hold, don't bother copying * values to the destination buffer, since they will just be * garbage. * * Ideally, this will eventually be checked at a higher level and * the entire I/O operation on the chunk will be skipped. -QAK */ if(!H5F_addr_defined(chunk_addr)) { const H5O_fill_t *fill=&(dset->shared->dcpl_cache.fill); /* Fill value info */ H5D_fill_time_t fill_time=dset->shared->dcpl_cache.fill_time; /* Fill time */ H5D_fill_value_t fill_status; H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk);/*raw data chunk cache*/ hbool_t found = FALSE; /*already in cache? */ /* Check if the chunk is in the cache (but hasn't been written to disk yet) */ if (rdcc->nslots>0) { unsigned idx=H5D_HASH(dset->shared,io_info->store->chunk.index); /* Cache entry index */ H5D_rdcc_ent_t *ent = rdcc->slot[idx]; /* Cache entry */ /* Potential match... */ if (ent) { for (u=0, found=TRUE; ushared->layout.u.chunk.ndims; u++) { if (io_info->store->chunk.offset[u]!=ent->offset[u]) { found = FALSE; break; } /* end if */ } /* end for */ } /* end if */ } /* end if */ /* If the chunk is in the cache, then it must have valid data */ if(!found) { /* Check if the fill value is defined */ if (H5P_is_fill_value_defined(fill, &fill_status) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't tell if fill value defined") /* If we are never to return fill values, or if we would return them * but they aren't set, process the entire set of I/O vectors and * get out now. */ if(fill_time==H5D_FILL_TIME_NEVER || (fill_time==H5D_FILL_TIME_IFSET && fill_status!=H5D_FILL_VALUE_USER_DEFINED)) { size_t size; /* Size of sequence in bytes */ size_t v; /* Local index variable */ ssize_t bytes_processed=0; /* Eventual return value */ /* Work through all the sequences */ for(u=*mem_curr_seq, v=*chunk_curr_seq; udset; /* Local pointer to the dataset info */ H5D_istore_ud1_t udata; /*B-tree pass-through */ haddr_t chunk_addr; /* Chunk address on disk */ size_t u; /* Local index variables */ ssize_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5D_istore_writevv, FAIL) /* Check args */ assert(io_info); assert(dset && H5D_CHUNKED==dset->shared->layout.type); assert(dset->shared->layout.u.chunk.ndims>0 && dset->shared->layout.u.chunk.ndims<=H5O_LAYOUT_NDIMS); assert(io_info->dxpl_cache); assert(io_info->store); assert(chunk_len_arr); assert(chunk_offset_arr); assert(mem_len_arr); assert(mem_offset_arr); assert(buf); /* Get the address of this chunk on disk */ #ifdef QAK HDfprintf(stderr,"%s: io_info->store->chunk.offset={",FUNC); for(u=0; ushared->layout.u.chunk.ndims; u++) HDfprintf(stderr,"%Hd%s",io_info->store->chunk.offset[u],(u<(dset->shared->layout.u.chunk.ndims-1) ? ", " : "}\n")); #endif /* QAK */ chunk_addr=H5D_istore_get_addr(io_info, &udata); #ifdef QAK HDfprintf(stderr,"%s: chunk_addr=%a, chunk_size=%Zu\n",FUNC,chunk_addr,dset->shared->layout.u.chunk.size); HDfprintf(stderr,"%s: chunk_len_arr[%Zu]=%Zu\n",FUNC,*chunk_curr_seq,chunk_len_arr[*chunk_curr_seq]); HDfprintf(stderr,"%s: chunk_offset_arr[%Zu]=%Hu\n",FUNC,*chunk_curr_seq,chunk_offset_arr[*chunk_curr_seq]); HDfprintf(stderr,"%s: mem_len_arr[%Zu]=%Zu\n",FUNC,*mem_curr_seq,mem_len_arr[*mem_curr_seq]); HDfprintf(stderr,"%s: mem_offset_arr[%Zu]=%Hu\n",FUNC,*mem_curr_seq,mem_offset_arr[*mem_curr_seq]); #endif /* QAK */ /* * If the chunk is too large to load into the cache and it has no * filters in the pipeline (i.e. not compressed) and if the address * for the chunk has been defined, then don't load the chunk into the * cache, just write the data to it directly. * * If MPI based VFD is used, must bypass the * chunk-cache scheme because other MPI processes could be * writing to other elements in the same chunk. Do a direct * write-through of only the elements requested. */ #ifdef H5_HAVE_PARALLEL /* Additional sanity checks when operating in parallel */ if(IS_H5FD_MPI(dset->ent.file)) { if (chunk_addr==HADDR_UNDEF) HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "unable to locate raw data chunk") if (dset->shared->dcpl_cache.pline.nused>0) HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "cannot write to chunked storage with filters in parallel") } /* end if */ #endif /* H5_HAVE_PARALLEL */ if (dset->shared->dcpl_cache.pline.nused==0 && ((dset->shared->layout.u.chunk.size>dset->shared->cache.chunk.nbytes && chunk_addr!=HADDR_UNDEF) || (IS_H5FD_MPI(dset->ent.file) && (H5F_ACC_RDWR & H5F_get_intent(dset->ent.file))))) { H5D_io_info_t chk_io_info; /* Temporary I/O info object */ H5D_storage_t chk_store; /* Chunk storage information */ /* Set up the storage information for the chunk */ chk_store.contig.dset_addr=chunk_addr; chk_store.contig.dset_size=(hsize_t)dset->shared->layout.u.chunk.size; /* Set up new dataset I/O info */ H5D_BUILD_IO_INFO(&chk_io_info,dset,io_info->dxpl_cache,io_info->dxpl_id,&chk_store); /* Do I/O directly on chunk without reading it into the cache */ if ((ret_value=H5D_contig_writevv(&chk_io_info, chunk_max_nseq, chunk_curr_seq, chunk_len_arr, chunk_offset_arr, mem_max_nseq, mem_curr_seq, mem_len_arr, mem_offset_arr, buf))<0) HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "unable to write raw data to file") } /* end if */ else { uint8_t *chunk; /* Pointer to cached chunk in memory */ unsigned idx_hint=0; /* Cache index hint */ ssize_t naccessed; /* Number of bytes accessed in chunk */ size_t total_bytes; /* Total # of bytes accessed on disk & memory */ hbool_t relax; /* Whether whole chunk is selected */ /* * Lock the chunk, copy from application to chunk, then unlock the * chunk. */ #ifdef OLD_WAY /* Note that this is technically OK, since eventually all the data in the chunk * will be overwritten. However, it seems risky and a better approach would * be to lock the chunk in the dataset I/O routine (setting the relax flag * appropriately) and then unlock it after all the I/O the chunk was finished. -QAK */ if(chunk_max_nseq==1 && chunk_len_arr[0] == dset->shared->layout.u.chunk.size) relax = TRUE; else relax = FALSE; #else /* OLD_WAY */ relax=TRUE; total_bytes=0; for(u=*chunk_curr_seq; ushared->layout.u.chunk.size) relax=FALSE; if(relax) { total_bytes=0; for(u=*mem_curr_seq; ushared->layout.u.chunk.size) relax=FALSE; } /* end if */ #endif /* OLD_WAY */ if (NULL==(chunk=H5D_istore_lock(io_info, &udata, relax, &idx_hint))) HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "unable to read raw data chunk") /* Use the vectorized memory copy routine to do actual work */ if((naccessed=H5V_memcpyvv(chunk,chunk_max_nseq,chunk_curr_seq,chunk_len_arr,chunk_offset_arr,buf,mem_max_nseq,mem_curr_seq,mem_len_arr,mem_offset_arr))<0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "vectorized memcpy failed") H5_CHECK_OVERFLOW(naccessed,ssize_t,size_t); if (H5D_istore_unlock(io_info, TRUE, idx_hint, chunk, (size_t)naccessed)<0) HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "uanble to unlock raw data chunk") /* Set return value */ ret_value=naccessed; } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D_istore_writevv() */ /*------------------------------------------------------------------------- * Function: H5D_istore_create * * Purpose: Creates a new indexed-storage B-tree and initializes the * istore struct with information about the storage. The * struct should be immediately written to the object header. * * This function must be called before passing ISTORE to any of * the other indexed storage functions! * * Return: Non-negative on success (with the ISTORE argument initialized * and ready to write to an object header). Negative on failure. * * Programmer: Robb Matzke * Tuesday, October 21, 1997 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5D_istore_create(H5F_t *f, hid_t dxpl_id, H5O_layout_t *layout /*out */ ) { H5D_istore_ud1_t udata; #ifndef NDEBUG unsigned u; #endif herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5D_istore_create, FAIL) /* Check args */ assert(f); assert(layout && H5D_CHUNKED == layout->type); assert(layout->u.chunk.ndims > 0 && layout->u.chunk.ndims <= H5O_LAYOUT_NDIMS); #ifndef NDEBUG for (u = 0; u < layout->u.chunk.ndims; u++) assert(layout->u.chunk.dim[u] > 0); #endif /* Initialize "user" data for B-tree callbacks, etc. */ udata.mesg = layout; if (H5B_create(f, dxpl_id, H5B_ISTORE, &udata, &(layout->u.chunk.addr)/*out*/) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "can't create B-tree") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_istore_create() */ /*------------------------------------------------------------------------- * Function: H5D_istore_allocated * * Purpose: Return the number of bytes allocated in the file for storage * of raw data under the specified B-tree (ADDR is the address * of the B-tree). * * Return: Success: Number of bytes stored in all chunks. * * Failure: 0 * * Programmer: Robb Matzke * Wednesday, April 21, 1999 * * Modifications: * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. *------------------------------------------------------------------------- */ hsize_t H5D_istore_allocated(H5D_t *dset, hid_t dxpl_id) { H5D_io_info_t io_info; /* Temporary I/O info object */ const H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /*raw data chunk cache */ H5D_rdcc_ent_t *ent; /*cache entry */ H5D_dxpl_cache_t _dxpl_cache; /* Data transfer property cache buffer */ H5D_dxpl_cache_t *dxpl_cache=&_dxpl_cache; /* Data transfer property cache */ H5D_istore_ud1_t udata; hsize_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5D_istore_allocated, 0) assert(dset); /* Fill the DXPL cache values for later use */ if (H5D_get_dxpl_cache(dxpl_id,&dxpl_cache)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "can't fill dxpl cache") /* Construct dataset I/O info */ H5D_BUILD_IO_INFO(&io_info,dset,dxpl_cache,dxpl_id,NULL); /* Search for cached chunks that haven't been written out */ for(ent = rdcc->head; ent; ent = ent->next) { /* Flush the chunk out to disk, to make certain the size is correct later */ if (H5D_istore_flush_entry(&io_info, ent, FALSE)<0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, 0, "cannot flush indexed storage buffer") } /* end for */ HDmemset(&udata, 0, sizeof udata); udata.mesg = &dset->shared->layout; if (H5B_iterate(dset->ent.file, dxpl_id, H5B_ISTORE, H5D_istore_iter_allocated, dset->shared->layout.u.chunk.addr, &udata)<0) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, 0, "unable to iterate over chunk B-tree") /* Set return value */ ret_value=udata.total_storage; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_istore_allocated() */ /*------------------------------------------------------------------------- * Function: H5D_istore_get_addr * * Purpose: Get the file address of a chunk if file space has been * assigned. Save the retrieved information in the udata * supplied. * * Return: Non-negative on success/Negative on failure * * Programmer: Albert Cheng * June 27, 1998 * * Modifications: * Modified to return the address instead of returning it through * a parameter - QAK, 1/30/02 * *------------------------------------------------------------------------- */ haddr_t H5D_istore_get_addr(const H5D_io_info_t *io_info, H5D_istore_ud1_t *_udata) { H5D_istore_ud1_t tmp_udata; /* Information about a chunk */ H5D_istore_ud1_t *udata; /* Pointer to information about a chunk */ unsigned u; haddr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_get_addr) assert(io_info); assert(io_info->dset); assert(io_info->dset->shared->layout.u.chunk.ndims > 0); assert(io_info->store->chunk.offset); /* Check for udata struct to return */ udata = (_udata!=NULL ? _udata : &tmp_udata); /* Initialize the information about the chunk we are looking for */ for (u=0; udset->shared->layout.u.chunk.ndims; u++) udata->key.offset[u] = io_info->store->chunk.offset[u]; udata->mesg = &(io_info->dset->shared->layout); udata->addr = HADDR_UNDEF; /* Go get the chunk information */ if (H5B_find (io_info->dset->ent.file, io_info->dxpl_id, H5B_ISTORE, io_info->dset->shared->layout.u.chunk.addr, udata)<0) { /* Note: don't push error on stack, leave that to next higher level, * since many times the B-tree is searched in order to determine * if a chunk exists in the B-tree or not. -QAK */ #ifdef OLD_WAY H5E_clear(); HGOTO_ERROR(H5E_BTREE,H5E_NOTFOUND,HADDR_UNDEF,"Can't locate chunk info") #else /* OLD_WAY */ HGOTO_DONE(HADDR_UNDEF) #endif /* OLD_WAY */ } /* end if */ /* Success! Set the return value */ ret_value=udata->addr; done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D_istore_get_addr() */ /*------------------------------------------------------------------------- * Function: H5D_istore_chunk_alloc * * Purpose: Allocate space for a chunk in memory. This routine allocates * memory space for non-filtered chunks from a block free list * and uses malloc()/free() for filtered chunks. * * Return: Pointer to memory for chunk on success/NULL on failure * * Programmer: Quincey Koziol * April 22, 2004 * * Modifications: * *------------------------------------------------------------------------- */ static void * H5D_istore_chunk_alloc(size_t size, const H5O_pline_t *pline) { void *ret_value=NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_chunk_alloc) assert(size); assert(pline); if(pline->nused>0) ret_value=H5MM_malloc(size); else ret_value=H5FL_BLK_MALLOC(chunk,size); FUNC_LEAVE_NOAPI(ret_value) } /* H5D_istore_chunk_alloc() */ /*------------------------------------------------------------------------- * Function: H5D_istore_chunk_xfree * * Purpose: Free space for a chunk in memory. This routine allocates * memory space for non-filtered chunks from a block free list * and uses malloc()/free() for filtered chunks. * * Return: NULL (never fails) * * Programmer: Quincey Koziol * April 22, 2004 * * Modifications: * *------------------------------------------------------------------------- */ static void * H5D_istore_chunk_xfree(void *chk, const H5O_pline_t *pline) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_chunk_xfree) assert(pline); if(chk) { if(pline->nused>0) H5MM_xfree(chk); else H5FL_BLK_FREE(chunk,chk); } /* end if */ FUNC_LEAVE_NOAPI(NULL) } /* H5D_istore_chunk_xfree() */ /*------------------------------------------------------------------------- * Function: H5D_istore_allocate * * Purpose: Allocate file space for all chunks that are not allocated yet. * Return SUCCEED if all needed allocation succeed, otherwise * FAIL. * * Return: Non-negative on success/Negative on failure * * Note: Current implementation relies on cache_size being 0, * thus no chunk is cashed and written to disk immediately * when a chunk is unlocked (via H5F_istore_unlock) * This should be changed to do a direct flush independent * of the cache value. * * This routine might be called before the dcpl_cache is set up * correctly, so don't use those values. * * Programmer: Albert Cheng * June 26, 1998 * * Modifications: * rky, 1998-09-23 * Added barrier to preclude racing with data writes. * * rky, 1998-12-07 * Added Wait-Signal wrapper around unlock-lock critical region * to prevent race condition (unlock reads, lock writes the * chunk). * * Robb Matzke, 1999-08-02 * The split_ratios are passed in as part of the data transfer * property list. * * Quincey Koziol, 2002-05-16 * Rewrote algorithm to allocate & write blocks without using * lock/unlock code. * * Quincey Koziol, 2002-05-17 * Added feature to avoid writing fill-values if user has indicated * that they should never be written. *------------------------------------------------------------------------- */ herr_t H5D_istore_allocate(H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite) { H5D_io_info_t io_info; /* Dataset I/O info */ H5D_storage_t store; /* Dataset storage information */ hsize_t chunk_offset[H5O_LAYOUT_NDIMS]; /* Offset of current chunk */ hsize_t chunk_size; /* Size of chunk in bytes */ unsigned filter_mask=0; /* Filter mask for chunks that have them */ H5O_pline_t pline; /* I/O pipeline information */ hbool_t pline_initialized=FALSE; /* Flag to indicate that pline has valid info */ H5O_fill_t fill; /* Fill value information */ H5D_fill_time_t fill_time; /* When to write fill values */ H5D_fill_value_t fill_status; /* The fill value status */ unsigned should_fill=0; /* Whether fill values should be written */ H5D_istore_ud1_t udata; /* B-tree pass-through for creating chunk */ void *chunk=NULL; /* Chunk buffer for writing fill values */ H5D_dxpl_cache_t _dxpl_cache; /* Data transfer property cache buffer */ H5D_dxpl_cache_t *dxpl_cache=&_dxpl_cache; /* Data transfer property cache */ #ifdef H5_HAVE_PARALLEL MPI_Comm mpi_comm=MPI_COMM_NULL; /* MPI communicator for file */ int mpi_rank=(-1); /* This process's rank */ int mpi_code; /* MPI return code */ unsigned blocks_written=0; /* Flag to indicate that chunk was actually written */ unsigned using_mpi=0; /* Flag to indicate that the file is being accessed with an MPI-capable file driver */ #endif /* H5_HAVE_PARALLEL */ int carry; /* Flag to indicate that chunk increment carrys to higher dimension (sorta) */ unsigned chunk_exists; /* Flag to indicate whether a chunk exists already */ int i; /* Local index variable */ unsigned u; /* Local index variable */ H5P_genplist_t *dc_plist; /* Property list */ int space_ndims; /* Dataset's space rank */ hsize_t space_dim[H5O_LAYOUT_NDIMS]; /* Dataset's dataspace dimensions */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5D_istore_allocate, FAIL) /* Check args */ assert(dset && H5D_CHUNKED==dset->shared->layout.type); assert(dset->shared->layout.u.chunk.ndims>0 && dset->shared->layout.u.chunk.ndims<=H5O_LAYOUT_NDIMS); assert(H5F_addr_defined(dset->shared->layout.u.chunk.addr)); assert(TRUE==H5P_isa_class(dxpl_id,H5P_DATASET_XFER)); /* Get dataset's creation property list */ if (NULL == (dc_plist = H5I_object(dset->shared->dcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list") /* We only handle simple data spaces so far */ if ((space_ndims=H5S_get_simple_extent_dims(dset->shared->space, space_dim, NULL))<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get simple data space info") space_dim[space_ndims] = dset->shared->layout.u.chunk.dim[space_ndims]; /* Get necessary properties from dataset creation property list */ if(H5P_get(dc_plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) HGOTO_ERROR(H5E_STORAGE, H5E_CANTGET, FAIL, "can't get fill value") if(H5P_get(dc_plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_STORAGE, H5E_CANTGET, FAIL, "can't get data pipeline") pline_initialized=TRUE; if(H5P_get(dc_plist, H5D_CRT_FILL_TIME_NAME, &fill_time) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve fill time") /* Fill the DXPL cache values for later use */ if (H5D_get_dxpl_cache(dxpl_id,&dxpl_cache)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't fill dxpl cache") #ifdef H5_HAVE_PARALLEL /* Retrieve MPI parameters */ if(IS_H5FD_MPI(dset->ent.file)) { /* Get the MPI communicator */ if (MPI_COMM_NULL == (mpi_comm=H5F_mpi_get_comm(dset->ent.file))) HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "Can't retrieve MPI communicator") /* Get the MPI rank */ if ((mpi_rank=H5F_mpi_get_rank(dset->ent.file))<0) HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "Can't retrieve MPI rank") /* Set the MPI-capable file driver flag */ using_mpi=1; } /* end if */ #endif /* H5_HAVE_PARALLEL */ /* * Setup indice to go through all chunks. (Future improvement * should allocate only chunks that have no file space assigned yet. */ for (u=0; ushared->layout.u.chunk.ndims; u++) chunk_offset[u] = 0; chunk_size = dset->shared->layout.u.chunk.size; /* Check the dataset's fill-value status */ if (H5P_is_fill_value_defined(&fill, &fill_status) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't tell if fill value defined") /* If we are filling the dataset on allocation or "if set" and * the fill value _is_ set, _and_ we are not overwriting the new blocks, * or if there are any pipeline filters defined, * set the "should fill" flag */ if((!full_overwrite && (fill_time==H5D_FILL_TIME_ALLOC || (fill_time==H5D_FILL_TIME_IFSET && fill_status==H5D_FILL_VALUE_USER_DEFINED))) || pline.nused>0) should_fill=1; /* Check if fill values should be written to blocks */ if(should_fill) { /* Allocate chunk buffer for processes to use when writing fill values */ H5_CHECK_OVERFLOW(chunk_size,hsize_t,size_t); if (NULL==(chunk = H5D_istore_chunk_alloc((size_t)chunk_size,&pline))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for chunk") /* Fill the chunk with the proper values */ if(fill.buf) { /* * Replicate the fill value throughout the chunk. */ assert(0==chunk_size % fill.size); H5V_array_fill(chunk, fill.buf, fill.size, (size_t)chunk_size/fill.size); } else { /* * No fill value was specified, assume all zeros. */ HDmemset (chunk, 0, (size_t)chunk_size); } /* end else */ /* Check if there are filters which need to be applied to the chunk */ if (pline.nused>0) { size_t buf_size=(size_t)chunk_size; size_t nbytes=(size_t)chunk_size; /* Push the chunk through the filters */ if (H5Z_pipeline(&pline, 0, &filter_mask, dxpl_cache->err_detect, dxpl_cache->filter_cb, &nbytes, &buf_size, &chunk)<0) HGOTO_ERROR(H5E_PLINE, H5E_WRITEERROR, FAIL, "output pipeline failed") /* Keep the number of bytes the chunk turned in to */ chunk_size=nbytes; } /* end if */ } /* end if */ /* Set up dataset I/O info */ store.chunk.offset=chunk_offset; H5D_BUILD_IO_INFO(&io_info,dset,dxpl_cache,dxpl_id,&store); /* Loop over all chunks */ carry=0; while (carry==0) { /* Check if the chunk exists yet on disk */ chunk_exists=1; if(H5D_istore_get_addr(&io_info,NULL)==HADDR_UNDEF) { const H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /*raw data chunk cache */ H5D_rdcc_ent_t *ent = NULL; /*cache entry */ /* Didn't find the chunk on disk */ chunk_exists = 0; /* Look for chunk in cache */ for(ent = rdcc->head; ent && !chunk_exists; ent = ent->next) { /* Assume a match */ chunk_exists = 1; for(u = 0; u < dset->shared->layout.u.chunk.ndims && chunk_exists; u++) { if(ent->offset[u] != chunk_offset[u]) chunk_exists = 0; /* Reset if no match */ } /* end for */ } /* end for */ } /* end if */ if(!chunk_exists) { /* Initialize the chunk information */ udata.mesg = &dset->shared->layout; udata.key.filter_mask = filter_mask; udata.addr = HADDR_UNDEF; H5_CHECK_OVERFLOW(chunk_size,hsize_t,size_t); udata.key.nbytes = (size_t)chunk_size; for (u=0; ushared->layout.u.chunk.ndims; u++) udata.key.offset[u] = chunk_offset[u]; /* Allocate the chunk with all processes */ if (H5B_insert(dset->ent.file, dxpl_id, H5B_ISTORE, dset->shared->layout.u.chunk.addr, &udata)<0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to allocate chunk") /* Check if fill values should be written to blocks */ if(should_fill) { #ifdef H5_HAVE_PARALLEL /* Check if this file is accessed with an MPI-capable file driver */ if(using_mpi) { /* Write the chunks out from only one process */ /* !! Use the internal "independent" DXPL!! -QAK */ if(H5_PAR_META_WRITE==mpi_rank) { if (H5F_block_write(dset->ent.file, H5FD_MEM_DRAW, udata.addr, udata.key.nbytes, H5AC_ind_dxpl_id, chunk)<0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write raw data to file") } /* end if */ /* Indicate that blocks are being written */ blocks_written=1; } /* end if */ else { #endif /* H5_HAVE_PARALLEL */ if (H5F_block_write(dset->ent.file, H5FD_MEM_DRAW, udata.addr, udata.key.nbytes, dxpl_id, chunk)<0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write raw data to file") #ifdef H5_HAVE_PARALLEL } /* end else */ #endif /* H5_HAVE_PARALLEL */ } /* end if */ } /* end if */ /* Increment indices */ for (i=(int)dset->shared->layout.u.chunk.ndims-1, carry=1; i>=0 && carry; --i) { chunk_offset[i] += dset->shared->layout.u.chunk.dim[i]; if (chunk_offset[i] >= space_dim[i]) chunk_offset[i] = 0; else carry = 0; } /* end for */ } /* end while */ #ifdef H5_HAVE_PARALLEL /* Only need to block at the barrier if we actually allocated a chunk */ /* And if we are using an MPI-capable file driver */ if(using_mpi && blocks_written) { /* Wait at barrier to avoid race conditions where some processes are * still writing out chunks and other processes race ahead to read * them in, getting bogus data. */ if (MPI_SUCCESS != (mpi_code=MPI_Barrier(mpi_comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed", mpi_code); } /* end if */ #endif /* H5_HAVE_PARALLEL */ done: /* Free the chunk for fill values */ if(chunk!=NULL && pline_initialized) chunk=H5D_istore_chunk_xfree(chunk,&pline); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_istore_allocate() */ /*------------------------------------------------------------------------- * Function: H5D_istore_prune_by_extent * * Purpose: This function searches for chunks that are no longer necessary both in the * raw data cache and in the B-tree. * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu * Algorithm: Robb Matzke * * Date: March 27, 2002 * * The algorithm is: * * For chunks that are no longer necessary: * * 1. Search in the raw data cache for each chunk * 2. If found then preempt it from the cache * 3. Search in the B-tree for each chunk * 4. If found then remove it from the B-tree and deallocate file storage for the chunk * * This example shows a 2d dataset of 90x90 with a chunk size of 20x20. * * * 0 20 40 60 80 90 100 * 0 +---------+---------+---------+---------+-----+...+ * |:::::X:::::::::::::: : : | : * |:::::::X:::::::::::: : : | : Key * |::::::::::X::::::::: : : | : -------- * |::::::::::::X::::::: : : | : +-+ Dataset * 20+::::::::::::::::::::.........:.........:.....+...: | | Extent * | :::::X::::: : : | : +-+ * | ::::::::::: : : | : * | ::::::::::: : : | : ... Chunk * | :::::::X::: : : | : : : Boundary * 40+.........:::::::::::.........:.........:.....+...: :.: * | : : : : | : * | : : : : | : ... Allocated * | : : : : | : ::: & Filled * | : : : : | : ::: Chunk * 60+.........:.........:.........:.........:.....+...: * | : :::::::X::: : | : X Element * | : ::::::::::: : | : Written * | : ::::::::::: : | : * | : ::::::::::: : | : * 80+.........:.........:::::::::::.........:.....+...: O Fill Val * | : : ::::::::::: | : Explicitly * | : : ::::::X:::: | : Written * 90+---------+---------+---------+---------+-----+ : * : : : ::::::::::: : * 100:.........:.........:.........:::::::::::.........: * * * We have 25 total chunks for this dataset, 5 of which have space * allocated in the file because they were written to one or more * elements. These five chunks (and only these five) also have entries in * the storage B-tree for this dataset. * * Now lets say we want to shrink the dataset down to 70x70: * * * 0 20 40 60 70 80 90 100 * 0 +---------+---------+---------+----+----+-----+...+ * |:::::X:::::::::::::: : | : | : * |:::::::X:::::::::::: : | : | : Key * |::::::::::X::::::::: : | : | : -------- * |::::::::::::X::::::: : | : | : +-+ Dataset * 20+::::::::::::::::::::.........:....+....:.....|...: | | Extent * | :::::X::::: : | : | : +-+ * | ::::::::::: : | : | : * | ::::::::::: : | : | : ... Chunk * | :::::::X::: : | : | : : : Boundary * 40+.........:::::::::::.........:....+....:.....|...: :.: * | : : : | : | : * | : : : | : | : ... Allocated * | : : : | : | : ::: & Filled * | : : : | : | : ::: Chunk * 60+.........:.........:.........:....+....:.....|...: * | : :::::::X::: | : | : X Element * | : ::::::::::: | : | : Written * +---------+---------+---------+----+ : | : * | : ::::::::::: : | : * 80+.........:.........:::::::::X:.........:.....|...: O Fill Val * | : : ::::::::::: | : Explicitly * | : : ::::::X:::: | : Written * 90+---------+---------+---------+---------+-----+ : * : : : ::::::::::: : * 100:.........:.........:.........:::::::::::.........: * * * That means that the nine chunks along the bottom and right side should * no longer exist. Of those nine chunks, (0,80), (20,80), (40,80), * (60,80), (80,80), (80,60), (80,40), (80,20), and (80,0), one is actually allocated * that needs to be released. * To release the chunks, we traverse the B-tree to obtain a list of unused * allocated chunks, and then call H5B_remove() for each chunk. * *------------------------------------------------------------------------- */ herr_t H5D_istore_prune_by_extent(const H5D_io_info_t *io_info) { H5D_t *dset=io_info->dset; /* Local pointer to the dataset info */ const H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /*raw data chunk cache */ H5D_rdcc_ent_t *ent = NULL, *next = NULL; /*cache entry */ unsigned u; /*counters */ int found; /*remove this entry */ H5D_istore_ud1_t udata; /*B-tree pass-through */ hsize_t curr_dims[H5O_LAYOUT_NDIMS]; /*current dataspace dimensions */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5D_istore_prune_by_extent, FAIL) /* Check args */ assert(io_info); assert(dset && H5D_CHUNKED == dset->shared->layout.type); assert(dset->shared->layout.u.chunk.ndims > 0 && dset->shared->layout.u.chunk.ndims <= H5O_LAYOUT_NDIMS); assert(H5F_addr_defined(dset->shared->layout.u.chunk.addr)); /* Go get the rank & dimensions */ if(H5S_get_simple_extent_dims(dset->shared->space, curr_dims, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataset dimensions") /*------------------------------------------------------------------------- * Figure out what chunks are no longer in use for the specified extent * and release them from the linked list raw data cache *------------------------------------------------------------------------- */ found = 0; for(ent = rdcc->head; ent; ent = next) { next = ent->next; for(u = 0; u < dset->shared->layout.u.chunk.ndims - 1; u++) { if((hsize_t)ent->offset[u] > curr_dims[u]) { found = 1; break; } /* end if */ } /* end for */ if(found) { #ifdef H5D_ISTORE_DEBUG HDfputs("cache:remove:[", stderr); for(u = 0; u < dset->shared->layout.u.chunk.ndims - 1; u++) HDfprintf(stderr, "%s%Hd", u ? ", " : "", ent->offset[u]); HDfputs("]\n", stderr); #endif /* Preempt the entry from the cache, but do not flush it to disk */ if(H5D_istore_preempt(io_info, ent, FALSE) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, 0, "unable to preempt chunk") found=0; } } /*------------------------------------------------------------------------- * Check if there are any chunks on the B-tree *------------------------------------------------------------------------- */ HDmemset(&udata, 0, sizeof udata); udata.stream = stdout; udata.mesg = &dset->shared->layout; udata.dims = curr_dims; if(H5B_iterate(dset->ent.file, io_info->dxpl_id, H5B_ISTORE, H5D_istore_prune_extent, dset->shared->layout.u.chunk.addr, &udata) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, 0, "unable to iterate over B-tree") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_istore_prune_by_extent() */ /*------------------------------------------------------------------------- * Function: H5D_istore_prune_extent * * Purpose: Search for chunks that are no longer necessary in the B-tree. * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu * * Date: March 26, 2002 * * Comments: Called by H5D_prune_by_extent * * Modifications: * *------------------------------------------------------------------------- */ /* ARGSUSED */ static int H5D_istore_prune_extent(H5F_t *f, hid_t dxpl_id, const void *_lt_key, haddr_t UNUSED addr, const void UNUSED *_rt_key, void *_udata) { H5D_istore_ud1_t *bt_udata = (H5D_istore_ud1_t *)_udata; const H5D_istore_key_t *lt_key = (const H5D_istore_key_t *)_lt_key; unsigned u; H5D_istore_ud1_t udata; int ret_value=H5B_ITER_CONT; /* Return value */ /* The LT_KEY is the left key (the one that describes the chunk). It points to a chunk of * storage that contains the beginning of the logical address space represented by UDATA. */ FUNC_ENTER_NOAPI_NOINIT(H5D_istore_prune_extent) /* Figure out what chunks are no longer in use for the specified extent and release them */ for(u = 0; u < bt_udata->mesg->u.chunk.ndims - 1; u++) if((hsize_t)lt_key->offset[u] > bt_udata->dims[u]) { #ifdef H5D_ISTORE_DEBUG HDfputs("b-tree:remove:[", bt_udata->stream); for(u = 0; u < bt_udata->mesg->u.chunk.ndims - 1; u++) HDfprintf(bt_udata->stream, "%s%Hd", u ? ", " : "", lt_key->offset[u]); HDfputs("]\n", bt_udata->stream); #endif HDmemset(&udata, 0, sizeof udata); udata.key = *lt_key; udata.mesg = bt_udata->mesg; /* Remove */ if(H5B_remove(f, dxpl_id, H5B_ISTORE, bt_udata->mesg->u.chunk.addr, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5B_ITER_ERROR, "unable to remove entry") break; } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_istore_prune_extent() */ /*------------------------------------------------------------------------- * Function: H5D_istore_remove * * Purpose: Removes chunks that are no longer necessary in the B-tree. * * Return: Success: 0, Failure: -1 * * Programmer: Robb Matzke * Pedro Vicente, pvn@ncsa.uiuc.edu * * Date: March 28, 2002 * * Comments: Part of H5B_ISTORE * * Modifications: * *------------------------------------------------------------------------- */ /* ARGSUSED */ static H5B_ins_t H5D_istore_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key /*in,out */ , hbool_t *lt_key_changed /*out */ , void UNUSED * _udata /*in,out */ , void UNUSED * _rt_key /*in,out */ , hbool_t *rt_key_changed /*out */ ) { H5D_istore_key_t *lt_key = (H5D_istore_key_t *)_lt_key; H5B_ins_t ret_value=H5B_INS_REMOVE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5D_istore_remove) /* Remove raw data chunk from file */ if(H5MF_xfree(f, H5FD_MEM_DRAW, dxpl_id, addr, (hsize_t)lt_key->nbytes)<0) HGOTO_ERROR(H5E_STORAGE, H5E_CANTFREE, H5B_INS_ERROR, "unable to free chunk") /* Mark keys as unchanged */ *lt_key_changed = FALSE; *rt_key_changed = FALSE; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_istore_remove() */ /*------------------------------------------------------------------------- * Function: H5D_istore_initialize_by_extent * * Purpose: This function searches for chunks that have to be initialized with the fill * value both in the raw data cache and in the B-tree. * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu * * Date: April 4, 2002 * * Comments: * * (See the example of H5D_istore_prune_by_extent) * Next, there are seven chunks where the database extent boundary is * within the chunk. We find those seven just like we did with the previous nine. * Fot the ones that are allocated we initialize the part that lies outside the boundary * with the fill value. * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5D_istore_initialize_by_extent(H5D_io_info_t *io_info) { const H5O_layout_t *layout=&(io_info->dset->shared->layout); /* Dataset layout */ uint8_t *chunk = NULL; /*the file chunk */ unsigned idx_hint = 0; /*input value for H5F_istore_lock */ hsize_t chunk_offset[H5O_LAYOUT_NDIMS]; /*logical location of the chunks */ hsize_t idx_cur[H5O_LAYOUT_NDIMS]; /*multi-dimensional counters */ hsize_t idx_max[H5O_LAYOUT_NDIMS]; hsize_t sub_size[H5O_LAYOUT_NDIMS]; hsize_t naccessed; /*bytes accessed in chunk */ hsize_t end_chunk; /*chunk position counter */ hsize_t start[H5O_LAYOUT_NDIMS]; /*starting location of hyperslab */ hsize_t count[H5O_LAYOUT_NDIMS]; /*element count of hyperslab */ hsize_t size[H5O_LAYOUT_NDIMS]; /*current size of dimensions */ H5S_t *space_chunk = NULL; /*dataspace for a chunk */ hsize_t chunk_dims[H5O_LAYOUT_NDIMS]; /*current chunk dimensions */ hsize_t curr_dims[H5O_LAYOUT_NDIMS]; /*current dataspace dimensions */ hsize_t chunks[H5O_LAYOUT_NDIMS]; /*current number of chunks in each dimension */ hsize_t down_chunks[H5O_LAYOUT_NDIMS]; /* "down" size of number of elements in each dimension */ int srank; /*current # of dimensions (signed) */ unsigned rank; /*current # of dimensions */ int i, carry; /*counters */ unsigned u; int found = 0; /*initialize this entry */ H5P_genplist_t *dc_plist; /* Property list */ H5O_pline_t pline; /* I/O pipeline information */ H5O_fill_t fill; /* Fill value information */ H5D_fill_time_t fill_time; /* Fill time information */ H5D_storage_t store; /* Dataset storage information */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5D_istore_initialize_by_extent, FAIL) /* Check args */ assert(io_info); assert(io_info->dset && H5D_CHUNKED == layout->type); assert(layout->u.chunk.ndims > 0 && layout->u.chunk.ndims <= H5O_LAYOUT_NDIMS); assert(H5F_addr_defined(layout->u.chunk.addr)); /* Get dataset's creation property list */ if (NULL == (dc_plist = H5I_object(io_info->dset->shared->dcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list") /* Get necessary properties from property list */ if(H5P_get(dc_plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get fill value") if(H5P_get(dc_plist, H5D_CRT_FILL_TIME_NAME, &fill_time) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get fill time") if(H5P_get(dc_plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get data pipeline") /* Reset start & count arrays */ HDmemset(start, 0, sizeof(start)); HDmemset(count, 0, sizeof(count)); /* Go get the rank & dimensions */ if((srank = H5S_get_simple_extent_dims(io_info->dset->shared->space, curr_dims, NULL)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataset dimensions"); H5_ASSIGN_OVERFLOW(rank,srank,int,unsigned); /* Copy current dimensions */ for(u = 0; u < rank; u++) { size[u] = curr_dims[u]; /* Round up to the next integer # of chunks, to accomodate partial chunks */ chunks[u] = ((curr_dims[u]+layout->u.chunk.dim[u])-1) / layout->u.chunk.dim[u]; } /* end for */ size[u] = layout->u.chunk.dim[u]; /* Get the "down" sizes for each dimension */ if(H5V_array_down(rank,chunks,down_chunks)<0) HGOTO_ERROR (H5E_INTERNAL, H5E_BADVALUE, FAIL, "can't compute 'down' sizes") /* Create a data space for a chunk & set the extent */ for(u = 0; u < rank; u++) chunk_dims[u] = layout->u.chunk.dim[u]; if(NULL == (space_chunk = H5S_create_simple(rank,chunk_dims,NULL))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create simple dataspace") /* * Set up multi-dimensional counters (idx_max, and idx_cur) and * loop through the chunks copying each chunk from the application to the * chunk cache. */ for(u = 0; u < layout->u.chunk.ndims; u++) { idx_max[u] = (size[u] - 1) / layout->u.chunk.dim[u] + 1; idx_cur[u] = 0; } /* end for */ /* Point to local dataset storage info */ assert(io_info->store==NULL); /* Make certain we aren't blowing anything away */ io_info->store=&store; /* Loop over all chunks */ carry=0; while(carry==0) { for(u = 0, naccessed = 1; u < layout->u.chunk.ndims; u++) { /* The location and size of the chunk being accessed */ chunk_offset[u] = idx_cur[u] * layout->u.chunk.dim[u]; sub_size[u] = MIN((idx_cur[u] + 1) * layout->u.chunk.dim[u], size[u]) - chunk_offset[u]; naccessed *= sub_size[u]; } /* end for */ /* * Figure out what chunks have to be initialized. These are the chunks where the dataspace * extent boundary is within the chunk */ for(u = 0, found = 0; u < rank; u++) { end_chunk = chunk_offset[u] + layout->u.chunk.dim[u]; if(end_chunk > size[u]) { found = 1; break; } } /* end for */ if(found) { /* Calculate the index of this chunk */ if(H5V_chunk_index(rank,chunk_offset,layout->u.chunk.dim,down_chunks,&store.chunk.index)<0) HGOTO_ERROR (H5E_DATASPACE, H5E_BADRANGE, FAIL, "can't get chunk index") store.chunk.offset=chunk_offset; if(NULL == (chunk = H5D_istore_lock(io_info, NULL, FALSE, &idx_hint))) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to read raw data chunk") if(H5S_select_all(space_chunk,1) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to select space") for(u = 0; u < rank; u++) count[u] = MIN((idx_cur[u] + 1) * layout->u.chunk.dim[u], size[u] - chunk_offset[u]); #ifdef H5D_ISTORE_DEBUG HDfputs("cache:initialize:offset:[", stdout); for(u = 0; u < rank; u++) HDfprintf(stdout, "%s%Hd", u ? ", " : "", chunk_offset[u]); HDfputs("]", stdout); HDfputs(":count:[", stdout); for(u = 0; u < rank; u++) HDfprintf(stdout, "%s%Hd", u ? ", " : "", count[u]); HDfputs("]\n", stdout); #endif if(H5S_select_hyperslab(space_chunk, H5S_SELECT_NOTB, start, NULL, count, NULL) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to select hyperslab") /* Fill the selection in the memory buffer */ /* Use the size of the elements in the chunk directly instead of */ /* relying on the fill.size, which might be set to 0 if there is */ /* no fill-value defined for the dataset -QAK */ H5_CHECK_OVERFLOW(size[rank],hsize_t,size_t); if(H5S_select_fill(fill.buf, (size_t)size[rank], space_chunk, chunk) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTENCODE, FAIL, "filling selection failed") if(H5D_istore_unlock(io_info, TRUE, idx_hint, chunk, (size_t)naccessed) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to unlock raw data chunk") } /*found */ /* Increment indices */ for(i = (int)rank, carry = 1; i >= 0 && carry; --i) { if(++idx_cur[i] >= idx_max[i]) idx_cur[i] = 0; else carry = 0; } /* end for */ } /* end while */ done: if(space_chunk) if(H5S_close(space_chunk)<0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_istore_initialize_by_extent() */ /*------------------------------------------------------------------------- * Function: H5D_istore_delete * * Purpose: Delete raw data storage for entire dataset (i.e. all chunks) * * Return: Success: Non-negative * Failure: negative * * Programmer: Quincey Koziol * Thursday, March 20, 2003 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5D_istore_delete(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5D_istore_delete, FAIL) /* Check if the B-tree has been created in the file */ if(H5F_addr_defined(layout->u.chunk.addr)) { H5O_layout_t tmp_layout=*layout;/* Local copy of layout info */ H5D_istore_ud1_t udata; /* User data for B-tree iterator call */ /* Set up user data for B-tree deletion */ HDmemset(&udata, 0, sizeof udata); udata.mesg = &tmp_layout; /* Allocate the shared structure */ if(H5D_istore_shared_create(f, &tmp_layout)<0) HGOTO_ERROR (H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create wrapper for shared B-tree info") /* Delete entire B-tree */ if(H5B_delete(f, dxpl_id, H5B_ISTORE, tmp_layout.u.chunk.addr, &udata)<0) HGOTO_ERROR(H5E_IO, H5E_CANTDELETE, 0, "unable to delete chunk B-tree") /* Free the raw B-tree node buffer */ if(tmp_layout.u.chunk.btree_shared==NULL) HGOTO_ERROR (H5E_IO, H5E_CANTFREE, FAIL, "ref-counted page nil") if(H5RC_DEC(tmp_layout.u.chunk.btree_shared)<0) HGOTO_ERROR (H5E_IO, H5E_CANTFREE, FAIL, "unable to decrement ref-counted page") } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_istore_delete() */ /*------------------------------------------------------------------------- * Function: H5D_istore_update_cache * * Purpose: Update any cached chunks index values after the dataspace * size has changed * * Return: Success: Non-negative * Failure: negative * * Programmer: Quincey Koziol * Saturday, May 29, 2004 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5D_istore_update_cache(H5D_t *dset, hid_t dxpl_id) { H5D_io_info_t io_info; /* Temporary I/O info object */ H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /*raw data chunk cache */ H5D_rdcc_ent_t *ent, *next; /*cache entry */ H5D_rdcc_ent_t *old_ent; /* Old cache entry */ H5D_dxpl_cache_t _dxpl_cache; /* Data transfer property cache buffer */ H5D_dxpl_cache_t *dxpl_cache=&_dxpl_cache; /* Data transfer property cache */ unsigned rank; /*current # of dimensions */ hsize_t curr_dims[H5O_LAYOUT_NDIMS]; /*current dataspace dimensions */ hsize_t chunks[H5O_LAYOUT_NDIMS]; /*current number of chunks in each dimension */ hsize_t down_chunks[H5O_LAYOUT_NDIMS]; /* "down" size of number of elements in each dimension */ hsize_t idx; /* Chunk index */ unsigned old_idx; /* Previous index number */ unsigned u; /*counters */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5D_istore_update_cache, FAIL) /* Check args */ assert(dset && H5D_CHUNKED == dset->shared->layout.type); assert(dset->shared->layout.u.chunk.ndims > 0 && dset->shared->layout.u.chunk.ndims <= H5O_LAYOUT_NDIMS); /* Go get the rank & dimensions */ rank = dset->shared->layout.u.chunk.ndims-1; if(H5S_get_simple_extent_dims(dset->shared->space, curr_dims, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataset dimensions") /* Round up to the next integer # of chunks, to accomodate partial chunks */ for(u = 0; u < rank; u++) chunks[u] = ((curr_dims[u]+dset->shared->layout.u.chunk.dim[u])-1) / dset->shared->layout.u.chunk.dim[u]; /* Get the "down" sizes for each dimension */ if(H5V_array_down(rank,chunks,down_chunks)<0) HGOTO_ERROR (H5E_INTERNAL, H5E_BADVALUE, FAIL, "can't compute 'down' sizes") /* Fill the DXPL cache values for later use */ if (H5D_get_dxpl_cache(dxpl_id,&dxpl_cache)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't fill dxpl cache") /* Construct dataset I/O info */ H5D_BUILD_IO_INFO(&io_info,dset,dxpl_cache,dxpl_id,NULL); /* Recompute the index for each cached chunk that is in a dataset */ for(ent = rdcc->head; ent; ent = next) { next=ent->next; /* Calculate the index of this chunk */ if(H5V_chunk_index(rank,ent->offset,dset->shared->layout.u.chunk.dim,down_chunks,&idx)<0) HGOTO_ERROR (H5E_DATASPACE, H5E_BADRANGE, FAIL, "can't get chunk index") /* Compute the index for the chunk entry */ old_idx=ent->idx; /* Save for later */ ent->idx=H5D_HASH(dset->shared,idx); if(old_idx!=ent->idx) { /* Check if there is already a chunk at this chunk's new location */ old_ent = rdcc->slot[ent->idx]; if(old_ent!=NULL) { assert(old_ent->locked==0); /* Check if we are removing the entry we would walk to next */ if(old_ent==next) next=old_ent->next; /* Remove the old entry from the cache */ if (H5D_istore_preempt(&io_info, old_ent, TRUE )<0) HGOTO_ERROR (H5E_IO, H5E_CANTFLUSH, FAIL, "unable to flush one or more raw data chunks") } /* end if */ /* Insert this chunk into correct location in hash table */ rdcc->slot[ent->idx]=ent; /* Null out previous location */ rdcc->slot[old_idx]=NULL; } /* end if */ } /* end for */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_istore_update_cache() */ /*------------------------------------------------------------------------- * Function: H5D_istore_dump_btree * * Purpose: Prints information about the storage B-tree to the specified * stream. * * Return: Success: Non-negative * * Failure: negative * * Programmer: Robb Matzke * Wednesday, April 28, 1999 * * Modifications: * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. *------------------------------------------------------------------------- */ herr_t H5D_istore_dump_btree(H5F_t *f, hid_t dxpl_id, FILE *stream, unsigned ndims, haddr_t addr) { H5O_layout_t layout; H5D_istore_ud1_t udata; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5D_istore_dump_btree, FAIL) HDmemset(&udata, 0, sizeof udata); layout.u.chunk.ndims = ndims; udata.mesg = &layout; udata.stream = stream; if(stream) HDfprintf(stream, " Address: %a\n",addr); if(H5B_iterate(f, dxpl_id, H5B_ISTORE, H5D_istore_iter_dump, addr, &udata)<0) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, 0, "unable to iterate over chunk B-tree") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_istore_dump_btree() */ #ifdef H5D_ISTORE_DEBUG /*------------------------------------------------------------------------- * Function: H5D_istore_stats * * Purpose: Print raw data cache statistics to the debug stream. If * HEADERS is non-zero then print table column headers, * otherwise assume that the H5AC layer has already printed them. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Thursday, May 21, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5D_istore_stats (H5D_t *dset, hbool_t headers) { H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); double miss_rate; char ascii[32]; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5D_istore_stats, FAIL) if (!H5DEBUG(AC)) HGOTO_DONE(SUCCEED) if (headers) { fprintf(H5DEBUG(AC), "H5D: raw data cache statistics\n"); fprintf(H5DEBUG(AC), " %-18s %8s %8s %8s %8s+%-8s\n", "Layer", "Hits", "Misses", "MissRate", "Inits", "Flushes"); fprintf(H5DEBUG(AC), " %-18s %8s %8s %8s %8s-%-8s\n", "-----", "----", "------", "--------", "-----", "-------"); } #ifdef H5AC_DEBUG if (H5DEBUG(AC)) headers = TRUE; #endif if (headers) { if (rdcc->nhits>0 || rdcc->nmisses>0) { miss_rate = 100.0 * rdcc->nmisses / (rdcc->nhits + rdcc->nmisses); } else { miss_rate = 0.0; } if (miss_rate > 100) { sprintf(ascii, "%7d%%", (int) (miss_rate + 0.5)); } else { sprintf(ascii, "%7.2f%%", miss_rate); } fprintf(H5DEBUG(AC), " %-18s %8u %8u %7s %8d+%-9ld\n", "raw data chunks", rdcc->nhits, rdcc->nmisses, ascii, rdcc->ninits, (long)(rdcc->nflushes)-(long)(rdcc->ninits)); } done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_istore_stats() */ #endif /* H5D_ISTORE_DEBUG */ /*------------------------------------------------------------------------- * Function: H5D_istore_debug * * Purpose: Debugs a B-tree node for indexed raw data storage. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Thursday, April 16, 1998 * * Modifications: * Robb Matzke, 1999-07-28 * The ADDR argument is passed by value. *------------------------------------------------------------------------- */ herr_t H5D_istore_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, int fwidth, unsigned ndims) { H5O_layout_t layout; H5D_istore_ud1_t udata; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5D_istore_debug,FAIL) layout.u.chunk.ndims = ndims; HDmemset (&udata, 0, sizeof udata); udata.mesg = &layout; /* Allocate the shared structure */ if(H5D_istore_shared_create(f, &layout)<0) HGOTO_ERROR (H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create wrapper for shared B-tree info") (void)H5B_debug (f, dxpl_id, addr, stream, indent, fwidth, H5B_ISTORE, &udata); /* Free the raw B-tree node buffer */ if(layout.u.chunk.btree_shared==NULL) HGOTO_ERROR (H5E_IO, H5E_CANTFREE, FAIL, "ref-counted page nil") if(H5RC_DEC(layout.u.chunk.btree_shared)<0) HGOTO_ERROR (H5E_IO, H5E_CANTFREE, FAIL, "unable to decrement ref-counted page") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_istore_debug() */ xdmf-3.0+git20160803/Utilities/hdf5/H5SL.c0000640000175000017500000013352013003006557017556 0ustar alastairalastair/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Purpose: Provides a skip list abstract data type. * * (See "Skip Lists: A Probabilistic Alternative to Balanced Trees" * by William Pugh for additional information) * * (This implementation has the optimization for reducing key * key comparisons mentioned in section 3.5 of "A Skip List * Cookbook" by William Pugh) * * (Also, this implementation has a couple of home-grown * optimizations, including setting the "update" vector to the * actual 'forward' pointer to update, instead of the node * containing the forward pointer -QAK) * * (Note: This implementation does not have the information for * implementing the "Linear List Operations" (like insert/delete/ * search by position) in section 3.4 of "A Skip List Cookbook", * but they shouldn't be that hard to add, if necessary) * * (This implementation has an additional backward pointer, which * allows the list to be iterated in reverse) * * (We should also look into "Deterministic Skip Lists" (see * paper by Munro, Papadakis & Sedgewick)) * * (There's also an article on "Alternating Skip Lists", which * are similar to deterministic skip lists, in the August 2000 * issue of Dr. Dobb's Journal) * */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5SL_init_interface /* Private headers needed */ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free Lists */ #include "H5SLprivate.h" /* Skip list routines */ /* Local Macros */ /* Define the code template for insertions for the "OP" in the H5SL_LOCATE macro */ #define H5SL_LOCATE_INSERT_FOUND(SLIST,X,UPDATE,I,ITEM) \ HGOTO_ERROR(H5E_SLIST,H5E_CANTINSERT,NULL,"can't insert duplicate key"); /* Define the code template for removals for the "OP" in the H5SL_LOCATE macro */ #define H5SL_LOCATE_REMOVE_FOUND(SLIST,X,UPDATE,I,ITEM) \ void *tmp; \ \ for(I=0; I<=(int)SLIST->curr_level; I++) { \ if(*UPDATE[I]!=X) \ break; \ *UPDATE[I]=X->forward[I]; \ } /* end for */ \ if(SLIST->last==X) \ SLIST->last=X->backward; \ else \ X->forward[0]->backward=X->backward; \ tmp=X->item; \ H5FL_ARR_FREE(H5SL_node_ptr_t,X); \ while(SLIST->curr_level>0 && SLIST->header->forward[SLIST->curr_level]==NULL) \ SLIST->curr_level--; \ SLIST->nobjs--; \ HGOTO_DONE(tmp); /* Define the code template for searches for the "OP" in the H5SL_LOCATE macro */ #define H5SL_LOCATE_SEARCH_FOUND(SLIST,X,UPDATE,I,ITEM) \ HGOTO_DONE(X->item); /* Define the code template for finds for the "OP" in the H5SL_LOCATE macro */ #define H5SL_LOCATE_FIND_FOUND(SLIST,X,UPDATE,I,ITEM) \ HGOTO_DONE(X); /* Define a code template for updating the "update" vector for the "DOUPDATE" in the H5SL_LOCATE macro */ #define H5SL_LOCATE_YES_UPDATE(X,UPDATE,I) \ UPDATE[I]=&X->forward[I]; /* Define a code template for _NOT_ updating the "update" vector for the "DOUPDATE" in the H5SL_LOCATE macro */ #define H5SL_LOCATE_NO_UPDATE(X,UPDATE,I) /* Define a code template for comparing scalar keys for the "CMP" in the H5SL_LOCATE macro */ #define H5SL_LOCATE_SCALAR_CMP(TYPE,PKEY1,PKEY2) \ (*(TYPE *)PKEY1<*(TYPE *)PKEY2) /* Define a code template for comparing string keys for the "CMP" in the H5SL_LOCATE macro */ #define H5SL_LOCATE_STRING_CMP(TYPE,PKEY1,PKEY2) \ (HDstrcmp(PKEY1,PKEY2)<0) /* Define a code template for comparing scalar keys for the "EQ" in the H5SL_LOCATE macro */ #define H5SL_LOCATE_SCALAR_EQ(TYPE,PKEY1,PKEY2) \ (*(TYPE *)PKEY1==*(TYPE *)PKEY2) /* Define a code template for comparing string keys for the "EQ" in the H5SL_LOCATE macro */ #define H5SL_LOCATE_STRING_EQ(TYPE,PKEY1,PKEY2) \ (HDstrcmp(PKEY1,PKEY2)==0) /* Macro used to find node for operation */ #define H5SL_LOCATE(OP,DOUPDATE,CMP,SLIST,X,UPDATE,I,TYPE,ITEM,KEY,CHECKED) \ CHECKED=NULL; \ for(I=(int)SLIST->curr_level; I>=0; I--) { \ if(X->forward[I]!=CHECKED) { \ while(X->forward[I] && H5_GLUE3(H5SL_LOCATE_,CMP,_CMP)(TYPE,X->forward[I]->key,KEY) ) \ X=X->forward[I]; \ CHECKED=X->forward[I]; \ } /* end if */ \ H5_GLUE3(H5SL_LOCATE_,DOUPDATE,_UPDATE)(X,UPDATE,I) \ } /* end for */ \ X=X->forward[0]; \ if(X!=NULL && H5_GLUE3(H5SL_LOCATE_,CMP,_EQ)(TYPE,X->key,KEY) ) { \ /* What to do when a node is found */ \ H5_GLUE3(H5SL_LOCATE_,OP,_FOUND)(SLIST,X,UPDATE,I,ITEM) \ } /* end if */ /* Macro used to insert node */ #define H5SL_INSERT(CMP,SLIST,X,UPDATE,I,TYPE,ITEM,KEY,CHECKED) \ H5SL_LOCATE(INSERT,YES,CMP,SLIST,X,UPDATE,I,TYPE,ITEM,KEY,CHECKED) /* Macro used to remove node */ #define H5SL_REMOVE(CMP,SLIST,X,UPDATE,I,TYPE,ITEM,KEY,CHECKED) \ H5SL_LOCATE(REMOVE,YES,CMP,SLIST,X,UPDATE,I,TYPE,ITEM,KEY,CHECKED) /* Macro used to search for node */ #define H5SL_SEARCH(CMP,SLIST,X,UPDATE,I,TYPE,ITEM,KEY,CHECKED) \ H5SL_LOCATE(SEARCH,NO,CMP,SLIST,X,UPDATE,I,TYPE,ITEM,KEY,CHECKED) /* Macro used to find a node */ #define H5SL_FIND(CMP,SLIST,X,UPDATE,I,TYPE,ITEM,KEY,CHECKED) \ H5SL_LOCATE(FIND,NO,CMP,SLIST,X,UPDATE,I,TYPE,ITEM,KEY,CHECKED) /* Private typedefs & structs */ /* Skip list node data structure */ struct H5SL_node_t { const void *key; /* Pointer to node's key */ void *item; /* Pointer to node's item */ size_t level; /* The level of this node */ struct H5SL_node_t **forward; /* Array of forward pointers from this node */ struct H5SL_node_t *backward; /* Backward pointer from this node */ }; /* Main skip list data structure */ struct H5SL_t { /* Static values for each list */ H5SL_type_t type; /* Type of skip list */ double p; /* Probability of using a higher level [0..1) */ int p1; /* Probability converted into appropriate value for random # generator on this machine */ size_t max_level; /* Maximum number of levels */ /* Dynamic values for each list */ int curr_level; /* Current top level used in list */ size_t nobjs; /* Number of active objects in skip list */ H5SL_node_t *header; /* Header for nodes in skip list */ H5SL_node_t *last; /* Pointer to last node in skip list */ }; /* Static functions */ static size_t H5SL_random_level(int p1, size_t max_level); static H5SL_node_t * H5SL_new_node(size_t lvl, void *item, const void *key); static H5SL_node_t *H5SL_insert_common(H5SL_t *slist, void *item, const void *key); static herr_t H5SL_release_common(H5SL_t *slist, H5SL_operator_t op, void *op_data); static herr_t H5SL_close_common(H5SL_t *slist, H5SL_operator_t op, void *op_data); /* Declare a free list to manage the H5SL_t struct */ H5FL_DEFINE_STATIC(H5SL_t); /* Declare a "base + array" list to manage the H5SL_node_t struct */ typedef H5SL_node_t *H5SL_node_ptr_t; H5FL_BARR_DEFINE_STATIC(H5SL_node_t,H5SL_node_ptr_t,H5SL_LEVEL_MAX); /*-------------------------------------------------------------------------- NAME H5SL_init_interface PURPOSE Initialize interface-specific information USAGE herr_t H5SL_init_interface() RETURNS Non-negative on success/Negative on failure DESCRIPTION Initializes any interface-specific data or routines. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5SL_init_interface(void) { time_t curr_time; /* Current time, for seeding random number generator */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SL_init_interface) /* Create randomized set of numbers */ curr_time=HDtime(NULL); HDsrand((unsigned)curr_time); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5SL_init_interface() */ /*-------------------------------------------------------------------------- NAME H5SL_random_level PURPOSE Generate a random level USAGE size_t H5SL_random_level(p,max_level) int p1; IN: probability distribution size_t max_level; IN: Maximum level for node height RETURNS Returns non-negative level value DESCRIPTION Count elements in a skip list. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS Do we really need a 'random' value, or is a series of nodes with the correct heights "good enough". We could track the state of the nodes allocated for this list and issue node heights appropriately (i.e. 1,2, 1,4,1,2,1,8,...) (or would that be 1,1,2,1,1,2,4,... ?) EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static size_t H5SL_random_level(int p1, size_t max_level) { size_t lvl; /* Level generated */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SL_random_level); /* Account for starting at zero offset */ max_level--; lvl=0; while(HDrand()key=key; ret_value->item=item; ret_value->level=lvl; ret_value->forward=(H5SL_node_t **)((unsigned char *)ret_value+sizeof(H5SL_node_t)); done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5SL_new_node() */ /*-------------------------------------------------------------------------- NAME H5SL_insert_common PURPOSE Common code for inserting an object into a skip list USAGE H5SL_node_t *H5SL_insert_common(slist,item,key) H5SL_t *slist; IN/OUT: Pointer to skip list void *item; IN: Item to insert void *key; IN: Key for item to insert RETURNS Returns pointer to new node on success, NULL on failure. DESCRIPTION Common code for inserting an element into a skip list. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS Inserting an item with the same key as an existing object fails. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static H5SL_node_t * H5SL_insert_common(H5SL_t *slist, void *item, const void *key) { H5SL_node_t **update[H5SL_LEVEL_MAX]; /* 'update' vector */ H5SL_node_t *checked; /* Pointer to last node checked */ H5SL_node_t *x; /* Current node to examine */ size_t lvl; /* Level of new node */ int i; /* Local index value */ H5SL_node_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5SL_insert_common); /* Check args */ assert(slist); assert(key); /* Check internal consistency */ /* (Pre-condition) */ /* Insert item into skip list */ /* Work through the forward pointers for a node, finding the node at each * level that is before the location to insert */ x=slist->header; switch(slist->type) { case H5SL_TYPE_INT: H5SL_INSERT(SCALAR,slist,x,update,i,const int,item,key,checked) break; case H5SL_TYPE_HADDR: H5SL_INSERT(SCALAR,slist,x,update,i,const haddr_t,item,key,checked) break; case H5SL_TYPE_STR: H5SL_INSERT(STRING,slist,x,update,i,char *,item,key,checked) break; case H5SL_TYPE_HSIZE: H5SL_INSERT(SCALAR,slist,x,update,i,const hsize_t,item,key,checked) break; case H5SL_TYPE_UNSIGNED: H5SL_INSERT(SCALAR,slist,x,update,i,const unsigned,item,key,checked) break; } /* end switch */ /* 'key' must not have been found in existing list, if we get here */ /* Generate level for new node */ lvl=H5SL_random_level(slist->p1,slist->max_level); if((int)lvl>slist->curr_level) { /* Cap the increase in the current level to just one greater */ lvl=slist->curr_level+1; /* Set the update pointer correctly */ update[lvl]=&slist->header->forward[lvl]; /* Increase the maximum level of the list */ slist->curr_level=(int)lvl; } /* end if */ /* Create new node of proper level */ if((x=H5SL_new_node(lvl,item,key))==NULL) HGOTO_ERROR(H5E_SLIST,H5E_NOSPACE,NULL,"can't create new skip list node"); /* Update the backward links */ if(*update[0]!=NULL) { x->backward=(*update[0])->backward; (*update[0])->backward=x; } /* end if */ else { HDassert(slist->last); x->backward=slist->last; slist->last=x; } /* end else */ /* Link the new node into the existing forward pointers */ for(i=0; i<=(int)lvl; i++) { x->forward[i]=*update[i]; *update[i]=x; } /* end for */ /* Increment the number of nodes in the skip list */ slist->nobjs++; /* Set return value */ ret_value=x; done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5SL_insert_common() */ /*-------------------------------------------------------------------------- NAME H5SL_release_common PURPOSE Release all nodes from a skip list, optionally calling a 'free' operator USAGE herr_t H5SL_release_common(slist) H5SL_t *slist; IN/OUT: Pointer to skip list to release nodes H5SL_operator_t op; IN: Callback function to free item & key void *op_data; IN/OUT: Pointer to application data for callback RETURNS Returns non-negative on success, negative on failure. DESCRIPTION Release all the nodes in a skip list. The 'op' routine is called for each node in the list. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS The return value from the 'op' routine is ignored. The skip list itself is still valid, it just has all its nodes removed. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5SL_release_common(H5SL_t *slist, H5SL_operator_t op, void *op_data) { H5SL_node_t *node, *next_node; /* Pointers to skip list nodes */ size_t u; /* Local index variable */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SL_release_common); /* Check args */ assert(slist); /* Check internal consistency */ /* (Pre-condition) */ /* Free skip list nodes */ node=slist->header->forward[0]; while(node!=NULL) { next_node=node->forward[0]; /* Call callback, if one is given */ if(op!=NULL) (void)(op)(node->item,(void *)node->key,op_data); H5FL_ARR_FREE(H5SL_node_ptr_t,node); node=next_node; } /* end while */ /* Reset the header pointers */ for(u=0; umax_level; u++) slist->header->forward[u]=NULL; /* Reset the last pointer */ slist->last=slist->header; /* Reset the dynamic internal fields */ slist->curr_level=-1; slist->nobjs=0; FUNC_LEAVE_NOAPI(SUCCEED); } /* end H5SL_release_common() */ /*-------------------------------------------------------------------------- NAME H5SL_close_common PURPOSE Close a skip list, deallocating it and potentially freeing all its nodes. USAGE herr_t H5SL_close_common(slist,op,opdata) H5SL_t *slist; IN/OUT: Pointer to skip list to close H5SL_operator_t op; IN: Callback function to free item & key void *op_data; IN/OUT: Pointer to application data for callback RETURNS Returns non-negative on success, negative on failure. DESCRIPTION Close a skip list, freeing all internal information. Any objects left in the skip list have the 'op' routine called for each. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS If the 'op' routine returns non-zero, only the nodes up to that point in the list are released and the list is still valid. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5SL_close_common(H5SL_t *slist, H5SL_operator_t op, void *op_data) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SL_close_common); /* Check args */ assert(slist); /* Check internal consistency */ /* (Pre-condition) */ /* Free skip list nodes */ (void)H5SL_release_common(slist,op,op_data); /* always succeeds */ /* Release header node */ H5FL_ARR_FREE(H5SL_node_ptr_t,slist->header); /* Free skip list object */ H5FL_FREE(H5SL_t,slist); FUNC_LEAVE_NOAPI(SUCCEED); } /* end H5SL_close_common() */ /*-------------------------------------------------------------------------- NAME H5SL_create PURPOSE Create a skip list USAGE H5SL_t *H5SL_create(void) RETURNS Returns a pointer to a skip list on success, NULL on failure. DESCRIPTION Create a skip list. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ H5SL_t * H5SL_create(H5SL_type_t type, double p, size_t max_level) { H5SL_t *new_slist=NULL; /* Pointer to new skip list object created */ H5SL_node_t *header; /* Pointer to skip list header node */ size_t u; /* Local index variable */ H5SL_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5SL_create,NULL); /* Check args */ HDassert(p>0.0 && p<1.0); HDassert(max_level>0 && max_level<=H5SL_LEVEL_MAX); HDassert(type>=H5SL_TYPE_INT && type<=H5SL_TYPE_UNSIGNED); /* Allocate skip list structure */ if((new_slist=H5FL_MALLOC(H5SL_t))==NULL) HGOTO_ERROR(H5E_SLIST,H5E_NOSPACE,NULL,"memory allocation failed"); /* Set the static internal fields */ new_slist->type=type; new_slist->p=p; new_slist->p1=(int)(p*RAND_MAX); new_slist->max_level=max_level; /* Set the dynamic internal fields */ new_slist->curr_level=-1; new_slist->nobjs=0; /* Allocate the header node */ if((header=H5SL_new_node(max_level-1,NULL,NULL))==NULL) HGOTO_ERROR(H5E_SLIST,H5E_NOSPACE,NULL,"memory allocation failed"); /* Initialize header node's forward pointers */ for(u=0; uforward[u]=NULL; /* Initialize header node's backward pointer */ header->backward=NULL; /* Attach the header */ new_slist->header=header; new_slist->last=header; /* Set the return value */ ret_value=new_slist; done: /* Error cleanup */ if(ret_value==NULL) { if(new_slist!=NULL) { H5FL_FREE(H5SL_t,new_slist); } /* end if */ } /* end if */ FUNC_LEAVE_NOAPI(ret_value); } /* end H5SL_create() */ /*-------------------------------------------------------------------------- NAME H5SL_count PURPOSE Count the number of objects in a skip list USAGE size_t H5SL_count(slist) H5SL_t *slist; IN: Pointer to skip list to count RETURNS Returns number of objects on success, can't fail DESCRIPTION Count elements in a skip list. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ size_t H5SL_count(H5SL_t *slist) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SL_count); /* Check args */ assert(slist); /* Check internal consistency */ /* (Pre-condition) */ FUNC_LEAVE_NOAPI(slist->nobjs); } /* end H5SL_count() */ /*-------------------------------------------------------------------------- NAME H5SL_insert PURPOSE Insert an object into a skip list USAGE herr_t H5SL_insert(slist,item,key) H5SL_t *slist; IN/OUT: Pointer to skip list void *item; IN: Item to insert void *key; IN: Key for item to insert RETURNS Returns non-negative on success, negative on failure. DESCRIPTION Insert element into a skip list. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS Inserting an item with the same key as an existing object fails. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5SL_insert(H5SL_t *slist, void *item, const void *key) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5SL_insert); /* Check args */ assert(slist); assert(key); /* Check internal consistency */ /* (Pre-condition) */ /* Insert item into skip list */ if(H5SL_insert_common(slist,item,key)==NULL) HGOTO_ERROR(H5E_SLIST,H5E_CANTINSERT,FAIL,"can't create new skip list node") done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5SL_insert() */ /*-------------------------------------------------------------------------- NAME H5SL_add PURPOSE Insert an object into a skip list USAGE H5SL_node_t *H5SL_add(slist,item,key) H5SL_t *slist; IN/OUT: Pointer to skip list void *item; IN: Item to insert void *key; IN: Key for item to insert RETURNS Returns pointer to new skip list node on success, NULL on failure. DESCRIPTION Insert element into a skip list and return the skip list node for the new element in the list. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS Inserting an item with the same key as an existing object fails. This routine is a useful starting point for next/prev calls EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ H5SL_node_t * H5SL_add(H5SL_t *slist, void *item, const void *key) { H5SL_node_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5SL_add); /* Check args */ assert(slist); assert(key); /* Check internal consistency */ /* (Pre-condition) */ /* Insert item into skip list */ if((ret_value=H5SL_insert_common(slist,item,key))==NULL) HGOTO_ERROR(H5E_SLIST,H5E_CANTINSERT,NULL,"can't create new skip list node") done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5SL_add() */ /*-------------------------------------------------------------------------- NAME H5SL_remove PURPOSE Removes an object from a skip list USAGE void *H5SL_remove(slist,key) H5SL_t *slist; IN/OUT: Pointer to skip list void *key; IN: Key for item to remove RETURNS Returns pointer to item removed on success, NULL on failure. DESCRIPTION Remove element from a skip list. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ void * H5SL_remove(H5SL_t *slist, const void *key) { H5SL_node_t **update[H5SL_LEVEL_MAX]; /* 'update' vector */ H5SL_node_t *checked; /* Pointer to last node checked */ H5SL_node_t *x; /* Current node to examine */ int i; /* Local index value */ void *ret_value=NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SL_remove); /* Check args */ assert(slist); assert(key); /* Check internal consistency */ /* (Pre-condition) */ /* Remove item from skip list */ /* Work through the forward pointers for a node, finding the node at each * level that is before the location to remove */ x=slist->header; switch(slist->type) { case H5SL_TYPE_INT: H5SL_REMOVE(SCALAR,slist,x,update,i,const int,-,key,checked) break; case H5SL_TYPE_HADDR: H5SL_REMOVE(SCALAR,slist,x,update,i,const haddr_t,-,key,checked) break; case H5SL_TYPE_STR: H5SL_REMOVE(STRING,slist,x,update,i,char *,-,key,checked) break; case H5SL_TYPE_HSIZE: H5SL_REMOVE(SCALAR,slist,x,update,i,const hsize_t,-,key,checked) break; case H5SL_TYPE_UNSIGNED: H5SL_REMOVE(SCALAR,slist,x,update,i,const unsigned,-,key,checked) break; } /* end switch */ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5SL_remove() */ /*-------------------------------------------------------------------------- NAME H5SL_search PURPOSE Search for object in a skip list USAGE void *H5SL_search(slist,key) H5SL_t *slist; IN/OUT: Pointer to skip list void *key; IN: Key for item to search for RETURNS Returns pointer to item on success, NULL on failure DESCRIPTION Search for an object in a skip list, according to it's key GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ void * H5SL_search(H5SL_t *slist, const void *key) { H5SL_node_t *checked; /* Pointer to last node checked */ H5SL_node_t *x; /* Current node to examine */ int i; /* Local index value */ void *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SL_search); /* Check args */ assert(slist); assert(key); /* Check internal consistency */ /* (Pre-condition) */ /* Insert item into skip list */ /* Work through the forward pointers for a node, finding the node at each * level that is before the location to insert */ x=slist->header; switch(slist->type) { case H5SL_TYPE_INT: H5SL_SEARCH(SCALAR,slist,x,-,i,const int,-,key,checked) break; case H5SL_TYPE_HADDR: H5SL_SEARCH(SCALAR,slist,x,-,i,const haddr_t,-,key,checked) break; case H5SL_TYPE_STR: H5SL_SEARCH(STRING,slist,x,-,i,char *,-,key,checked) break; case H5SL_TYPE_HSIZE: H5SL_SEARCH(SCALAR,slist,x,-,i,const hsize_t,-,key,checked) break; case H5SL_TYPE_UNSIGNED: H5SL_SEARCH(SCALAR,slist,x,-,i,const unsigned,-,key,checked) break; } /* end switch */ /* 'key' must not have been found in list, if we get here */ ret_value=NULL; done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5SL_search() */ /*-------------------------------------------------------------------------- NAME H5SL_less PURPOSE Search for object in a skip list that is less than or equal to 'key' USAGE void *H5SL_less(slist,key) H5SL_t *slist; IN/OUT: Pointer to skip list void *key; IN: Key for item to search for RETURNS Returns pointer to item who key is less than or equal to 'key' on success, NULL on failure DESCRIPTION Search for an object in a skip list, according to it's key, returning the object itself (for an exact match), or the object with the next highest key that is less than 'key' GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ void * H5SL_less(H5SL_t *slist, const void *key) { H5SL_node_t *checked; /* Pointer to last node checked */ H5SL_node_t *x; /* Current node to examine */ int i; /* Local index value */ void *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SL_less); /* Check args */ assert(slist); assert(key); /* Check internal consistency */ /* (Pre-condition) */ /* Insert item into skip list */ /* Work through the forward pointers for a node, finding the node at each * level that is before the location to insert */ x=slist->header; switch(slist->type) { case H5SL_TYPE_INT: H5SL_SEARCH(SCALAR,slist,x,-,i,const int,-,key,checked) break; case H5SL_TYPE_HADDR: H5SL_SEARCH(SCALAR,slist,x,-,i,const haddr_t,-,key,checked) break; case H5SL_TYPE_STR: H5SL_SEARCH(STRING,slist,x,-,i,char *,-,key,checked) break; case H5SL_TYPE_HSIZE: H5SL_SEARCH(SCALAR,slist,x,-,i,const hsize_t,-,key,checked) break; case H5SL_TYPE_UNSIGNED: H5SL_SEARCH(SCALAR,slist,x,-,i,const unsigned,-,key,checked) break; } /* end switch */ /* An exact match for 'key' must not have been found in list, if we get here */ /* Check for a node with a key that is less than the given 'key' */ if(x==NULL) { /* Check for walking off the list */ if(slist->last!=slist->header) ret_value=slist->last->item; else ret_value=NULL; } /* end if */ else { if(x->backward!=slist->header) ret_value=x->backward->item; else ret_value=NULL; } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5SL_less() */ /*-------------------------------------------------------------------------- NAME H5SL_find PURPOSE Search for _node_ in a skip list USAGE H5SL_node_t *H5SL_node(slist,key) H5SL_t *slist; IN/OUT: Pointer to skip list void *key; IN: Key for item to search for RETURNS Returns pointer to _node_ matching key on success, NULL on failure DESCRIPTION Search for an object in a skip list, according to it's key and returns the node that the object is attached to GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS This routine is a useful starting point for next/prev calls EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ H5SL_node_t * H5SL_find(H5SL_t *slist, const void *key) { H5SL_node_t *checked; /* Pointer to last node checked */ H5SL_node_t *x; /* Current node to examine */ int i; /* Local index value */ H5SL_node_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SL_find); /* Check args */ assert(slist); assert(key); /* Check internal consistency */ /* (Pre-condition) */ /* Insert item into skip list */ /* Work through the forward pointers for a node, finding the node at each * level that is before the location to insert */ x=slist->header; switch(slist->type) { case H5SL_TYPE_INT: H5SL_FIND(SCALAR,slist,x,-,i,const int,-,key,checked) break; case H5SL_TYPE_HADDR: H5SL_FIND(SCALAR,slist,x,-,i,const haddr_t,-,key,checked) break; case H5SL_TYPE_STR: H5SL_FIND(STRING,slist,x,-,i,char *,-,key,checked) break; case H5SL_TYPE_HSIZE: H5SL_FIND(SCALAR,slist,x,-,i,const hsize_t,-,key,checked) break; case H5SL_TYPE_UNSIGNED: H5SL_FIND(SCALAR,slist,x,-,i,const unsigned,-,key,checked) break; } /* end switch */ /* 'key' must not have been found in list, if we get here */ ret_value=NULL; done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5SL_find() */ /*-------------------------------------------------------------------------- NAME H5SL_first PURPOSE Gets a pointer to the first node in a skip list USAGE H5SL_node_t *H5SL_first(slist) H5SL_t *slist; IN: Pointer to skip list RETURNS Returns pointer to first node in skip list on success, NULL on failure. DESCRIPTION Retrieves a pointer to the first node in a skip list, for iterating over the list. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ H5SL_node_t * H5SL_first(H5SL_t *slist) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SL_first); /* Check args */ assert(slist); /* Check internal consistency */ /* (Pre-condition) */ FUNC_LEAVE_NOAPI(slist->header->forward[0]); } /* end H5SL_first() */ /*-------------------------------------------------------------------------- NAME H5SL_next PURPOSE Gets a pointer to the next node in a skip list USAGE H5SL_node_t *H5SL_next(slist_node) H5SL_node_t *slist_node; IN: Pointer to skip list node RETURNS Returns pointer to node after slist_node in skip list on success, NULL on failure. DESCRIPTION Retrieves a pointer to the next node in a skip list, for iterating over the list. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ H5SL_node_t * H5SL_next(H5SL_node_t *slist_node) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SL_next); /* Check args */ assert(slist_node); /* Check internal consistency */ /* (Pre-condition) */ FUNC_LEAVE_NOAPI(slist_node->forward[0]); } /* end H5SL_next() */ /*-------------------------------------------------------------------------- NAME H5SL_prev PURPOSE Gets a pointer to the previos node in a skip list USAGE H5SL_node_t *H5SL_prev(slist_node) H5SL_node_t *slist_node; IN: Pointer to skip list node RETURNS Returns pointer to node before slist_node in skip list on success, NULL on failure. DESCRIPTION Retrieves a pointer to the previous node in a skip list, for iterating over the list. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ H5SL_node_t * H5SL_prev(H5SL_node_t *slist_node) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SL_prev); /* Check args */ assert(slist_node); /* Check internal consistency */ /* (Pre-condition) */ /* Walk backward, detecting the header node (which has it's key set to NULL) */ FUNC_LEAVE_NOAPI(slist_node->backward->key==NULL ? NULL : slist_node->backward); } /* end H5SL_prev() */ /*-------------------------------------------------------------------------- NAME H5SL_last PURPOSE Gets a pointer to the lsat node in a skip list USAGE H5SL_node_t *H5SL_last(slist) H5SL_t *slist; IN: Pointer to skip list RETURNS Returns pointer to last node in skip list on success, NULL on failure. DESCRIPTION Retrieves a pointer to the last node in a skip list, for iterating over the list. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ H5SL_node_t * H5SL_last(H5SL_t *slist) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SL_last); /* Check args */ assert(slist); /* Check internal consistency */ /* (Pre-condition) */ /* Find last node, avoiding the header node */ FUNC_LEAVE_NOAPI(slist->last==slist->header ? NULL : slist->last); } /* end H5SL_last() */ /*-------------------------------------------------------------------------- NAME H5SL_item PURPOSE Gets pointer to the 'item' for a skip list node USAGE void *H5SL_item(slist_node) H5SL_node_t *slist_node; IN: Pointer to skip list node RETURNS Returns pointer to node 'item' on success, NULL on failure. DESCRIPTION Retrieves a node's 'item' GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ void * H5SL_item(H5SL_node_t *slist_node) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SL_item); /* Check args */ assert(slist_node); /* Check internal consistency */ /* (Pre-condition) */ FUNC_LEAVE_NOAPI(slist_node->item); } /* end H5SL_item() */ /*-------------------------------------------------------------------------- NAME H5SL_iterate PURPOSE Iterate over all nodes in a skip list USAGE herr_t H5SL_iterate(slist, op, op_data) H5SL_t *slist; IN/OUT: Pointer to skip list to iterate over H5SL_operator_t op; IN: Callback function for iteration void *op_data; IN/OUT: Pointer to application data for callback RETURNS Returns a negative value if something is wrong, the return value of the last operator if it was non-zero, or zero if all nodes were processed. DESCRIPTION Iterate over all the nodes in a skip list, calling an application callback with the item, key and any operator data. The operator callback receives a pointer to the item and key for the list being iterated over ('mesg'), and the pointer to the operator data passed in to H5SL_iterate ('op_data'). The return values from an operator are: A. Zero causes the iterator to continue, returning zero when all nodes of that type have been processed. B. Positive causes the iterator to immediately return that positive value, indicating short-circuit success. C. Negative causes the iterator to immediately return that value, indicating failure. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5SL_iterate(H5SL_t *slist, H5SL_operator_t op, void *op_data) { H5SL_node_t *node; /* Pointers to skip list nodes */ herr_t ret_value=0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SL_iterate); /* Check args */ assert(slist); /* Check internal consistency */ /* (Pre-condition) */ /* Free skip list nodes */ node=slist->header->forward[0]; while(node!=NULL) { /* Call the iterator callback */ /* Casting away const OK -QAK */ if((ret_value=(op)(node->item,(void *)node->key,op_data))!=0) break; node=node->forward[0]; } /* end while */ FUNC_LEAVE_NOAPI(ret_value); } /* end H5SL_iterate() */ /*-------------------------------------------------------------------------- NAME H5SL_release PURPOSE Release all nodes from a skip list USAGE herr_t H5SL_release(slist) H5SL_t *slist; IN/OUT: Pointer to skip list to release nodes RETURNS Returns non-negative on success, negative on failure. DESCRIPTION Release all the nodes in a skip list. Any objects left in the skip list nodes are not deallocated. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS The skip list itself is still valid, it just has all its nodes removed. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5SL_release(H5SL_t *slist) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SL_release); /* Check args */ assert(slist); /* Check internal consistency */ /* (Pre-condition) */ /* Free skip list nodes */ H5SL_release_common(slist,NULL,NULL); /* always succeeds */ FUNC_LEAVE_NOAPI(SUCCEED); } /* end H5SL_release() */ /*-------------------------------------------------------------------------- NAME H5SL_free PURPOSE Release all nodes from a skip list, freeing all nodes USAGE herr_t H5SL_free(slist,op,op_data) H5SL_t *slist; IN/OUT: Pointer to skip list to release nodes H5SL_operator_t op; IN: Callback function to free item & key void *op_data; IN/OUT: Pointer to application data for callback RETURNS Returns non-negative on success, negative on failure. DESCRIPTION Release all the nodes in a skip list. Any objects left in the skip list have the 'op' routine called for each. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS The skip list itself is still valid, it just has all its nodes removed. The return value from the 'op' routine is ignored. This routine is essentially a combination of iterating over all the nodes (where the iterator callback is supposed to free the items and/or keys) followed by a call to H5SL_release(). EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5SL_free(H5SL_t *slist, H5SL_operator_t op, void *op_data) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SL_free); /* Check args */ assert(slist); /* Check internal consistency */ /* (Pre-condition) */ /* Free skip list nodes */ H5SL_release_common(slist,op,op_data); /* always succeeds */ FUNC_LEAVE_NOAPI(SUCCEED); } /* end H5SL_free() */ /*-------------------------------------------------------------------------- NAME H5SL_destroy PURPOSE Close a skip list, deallocating it and freeing all its nodes. USAGE herr_t H5SL_destroy(slist,op,opdata) H5SL_t *slist; IN/OUT: Pointer to skip list to close H5SL_operator_t op; IN: Callback function to free item & key void *op_data; IN/OUT: Pointer to application data for callback RETURNS Returns non-negative on success, negative on failure. DESCRIPTION Close a skip list, freeing all internal information. Any objects left in the skip list have the 'op' routine called for each. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS The return value from the 'op' routine is ignored. This routine is essentially a combination of iterating over all the nodes (where the iterator callback is supposed to free the items and/or keys) followed by a call to H5SL_close(). EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5SL_destroy(H5SL_t *slist, H5SL_operator_t op, void *op_data) { herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SL_destroy); /* Check args */ assert(slist); /* Check internal consistency */ /* (Pre-condition) */ /* Close skip list */ (void)H5SL_close_common(slist,op,op_data); /* always succeeds */ FUNC_LEAVE_NOAPI(ret_value); } /* end H5SL_destroy() */ /*-------------------------------------------------------------------------- NAME H5SL_close PURPOSE Close a skip list, deallocating it. USAGE herr_t H5SL_close(slist) H5SL_t *slist; IN/OUT: Pointer to skip list to close RETURNS Returns non-negative on success, negative on failure. DESCRIPTION Close a skip list, freeing all internal information. Any objects left in the skip list are not deallocated. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5SL_close(H5SL_t *slist) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SL_close); /* Check args */ assert(slist); /* Check internal consistency */ /* (Pre-condition) */ /* Close skip list */ (void)H5SL_close_common(slist,NULL,NULL); /* always succeeds */ FUNC_LEAVE_NOAPI(SUCCEED); } /* end H5SL_close() */ xdmf-3.0+git20160803/Utilities/Doxygen/0000740000175000017500000000000013003006557017460 5ustar alastairalastairxdmf-3.0+git20160803/Utilities/Doxygen/paper-clip.gif0000640000175000017500000000012513003006557022203 0ustar alastairalastairGIF89a ‘âââ]]]ÿÿÿ!ù, &”›ƒ’æ[iÀNÛ‡mè¢q’(¨ Ûc®÷.ÔÝ R;xdmf-3.0+git20160803/Utilities/Doxygen/CVS/0000740000175000017500000000000013003006557020113 5ustar alastairalastairxdmf-3.0+git20160803/Utilities/Doxygen/CVS/Repository0000640000175000017500000000002713003006557022216 0ustar alastairalastairXdmf/Utilities/Doxygen xdmf-3.0+git20160803/Utilities/Doxygen/CVS/Root0000640000175000017500000000006413003006557020763 0ustar alastairalastair:pserver:anonymous@public.kitware.com:/cvsroot/Xdmf xdmf-3.0+git20160803/Utilities/Doxygen/CVS/Entries0000640000175000017500000000030113003006557021443 0ustar alastairalastair/CMakeLists.txt/1.1/Mon Dec 29 21:52:23 2003// /doc_makeall.sh.in/1.1/Mon Dec 29 21:52:23 2003// /doxyfile.in/1.1/Mon Dec 29 21:52:23 2003// /paper-clip.gif/1.1/Mon Dec 29 21:52:23 2003/-kb/ D xdmf-3.0+git20160803/Utilities/Doxygen/CMakeLists.txt0000640000175000017500000000132013003006557022216 0ustar alastairalastair# # Build the documentation # INCLUDE (${CMAKE_ROOT}/Modules/Documentation.cmake) IF (BUILD_DOCUMENTATION) OPTION (DOCUMENTATION_DOWNLOAD_VTK_TAGFILE "Download the VTK tag file." ON) MARK_AS_ADVANCED ( DOCUMENTATION_DOWNLOAD_VTK_TAGFILE ) # # Configure the script and the doxyfile, then add target # CONFIGURE_FILE( ${Xdmf_SOURCE_DIR}/Utilities/Doxygen/doxyfile.in ${Xdmf_BINARY_DIR}/Utilities/Doxygen/doxyfile) CONFIGURE_FILE( ${Xdmf_SOURCE_DIR}/Utilities/Doxygen/doc_makeall.sh.in ${Xdmf_BINARY_DIR}/Utilities/Doxygen/doc_makeall.sh) ADD_CUSTOM_TARGET(XdmfDoxygenDoc ${BASH} ${Xdmf_BINARY_DIR}/Utilities/Doxygen/doc_makeall.sh) ENDIF (BUILD_DOCUMENTATION) xdmf-3.0+git20160803/Utilities/Doxygen/doxyfile.in0000640000175000017500000005112113003006557021635 0ustar alastairalastair# Doxyfile 1.0.0 # This file describes the settings to be used by doxygen for a project # # All text after a hash (#) is considered a comment and will be ignored # The format is: # TAG = value [value, ...] # Values that contain spaces should be placed between quotes (" ") #--------------------------------------------------------------------------- # General configuration options #--------------------------------------------------------------------------- # The PROJECT_NAME tag is a single word (or a sequence of word surrounded # by quotes) that should identify the project. PROJECT_NAME = "XDMF" # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or # if some version control system is used. PROJECT_NUMBER = # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. OUTPUT_DIRECTORY = "@Xdmf_BINARY_DIR@/Utilities/Doxygen/doc" # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # The default language is English, other supported languages are: # Dutch, French, Italian, Czech, Swedish, German and Japanese OUTPUT_LANGUAGE = English # The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. QUIET = NO # The WARNINGS tag can be used to turn on/off the warning messages that are # generated by doxygen. Possible values are YES and NO. If left blank # NO is used. WARNINGS = YES # The DISABLE_INDEX tag can be used to turn on/off the condensed index at # top of each HTML page. The value NO (the default) enables the index and # the value YES disables it. DISABLE_INDEX = NO # If the EXTRACT_ALL tag is set to YES all classes and functions will be # included in the documentation, even if no documentation was available. EXTRACT_ALL = YES # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. EXTRACT_PRIVATE = NO # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all # undocumented members inside documented classes or files. HIDE_UNDOC_MEMBERS = NO # If the HIDE_UNDOC_CLASSESS tag is set to YES, Doxygen will hide all # undocumented classes. HIDE_UNDOC_CLASSES = NO # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will # include brief member descriptions after the members that are listed in # the file and class documentation (similar to JavaDoc). # Set to NO to disable this. BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend # the brief description of a member or function before the detailed description. # Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. REPEAT_BRIEF = YES # If the ALWAYS_DETAILS_SEC and REPEAT_BRIEF tags are both set to YES then # Doxygen will generate a detailed section even if there is only a brief # description. ALWAYS_DETAILED_SEC = NO # If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full # path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = NO # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag # can be used to strip a user defined part of the path. Stripping is # only done if one of the specified strings matches the left-hand part of # the path. STRIP_FROM_PATH = # The INTERNAL_DOCS tag determines if documentation # that is typed after a \internal command is included. If the tag is set # to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. INTERNAL_DOCS = NO # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will # generate a class diagram (in Html and LaTeX) for classes with base or # super classes. Setting the tag to NO turns the diagrams off. CLASS_DIAGRAMS = YES # If the SOURCE_BROWSER tag is set to YES then a list of source files will # be generated. Documented entities will be cross-referenced with these sources. SOURCE_BROWSER = NO # Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. INLINE_SOURCES = NO # If the CASE_SENSE_NAMES tag is set to NO (the default) then Doxygen # will only generate file names in lower case letters. If set to # YES upper case letters are also allowed. This is useful if you have # classes or files whose names only differ in case and if your file system # supports case sensitive file names. CASE_SENSE_NAMES = NO # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen # will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = YES # If the JAVADOC_AUTOBRIEF tag is set to YES (the default) then Doxygen # will interpret the first line (until the first dot) of a JavaDoc-style # comment as the brief description. If set to NO, the Javadoc-style will # behave just like the Qt-style comments. JAVADOC_AUTOBRIEF = YES # if the INHERIT_DOCS tag is set to YES (the default) then an undocumented # member inherits the documentation from any documented member that it # reimplements. INHERIT_DOCS = YES # if the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. INLINE_INFO = YES # the TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. TAB_SIZE = 8 WARN_IF_UNDOCUMENTED = NO #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag can be used to specify the files and/or directories that contain # documented source files. You may enter file names like "myfile.cpp" or # directories like "/usr/src/myproject". Separate the files or directories # with spaces. INPUT = \ "@Xdmf_SOURCE_DIR@/libsrc" \ "@Xdmf_BINARY_DIR@/Utilities/Doxygen/dox/vtk" \ "@Xdmf_BINARY_DIR@/Utilities/Doxygen/dox/doc_Xdmf_index.dox" # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. FILE_PATTERNS = *.h # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = NO # The EXCLUDE tag can be used to specify files and/or directories that should # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. EXCLUDE = Common/vtkSetGet.h # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. EXCLUDE_PATTERNS = # The EXAMPLE_PATH tag can be used to specify one or more files or # directories that contain example code fragments that are included (see # the \include command). EXAMPLE_PATH = # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. EXAMPLE_PATTERNS = # The IMAGE_PATH tag can be used to specify one or more files or # directories that contain image that are included in the documentation (see # the \image command). IMAGE_PATH = "@Xdmf_SOURCE_DIR@/Utilities/Doxygen" # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program # by executing (via popen()) the command , where # is the value of the INPUT_FILTER tag, and is the name of an # input file. Doxygen will then use the output that the filter program writes # to standard output. INPUT_FILTER = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = # The HTML_HEADER tag can be used to specify a personal HTML header for # each generated HTML page. If it is left blank doxygen will generate a # standard header. HTML_HEADER = "@Xdmf_SOURCE_DIR@/libsrc/DocHeader.html" # The HTML_FOOTER tag can be used to specify a personal HTML footer for # each generated HTML page. If it is left blank doxygen will generate a # standard footer. HTML_FOOTER = "@Xdmf_SOURCE_DIR@/libsrc/DocFooter.html" # The HTML_STYLESHEET tag can be used to specify a user defined cascading # style sheet that is used by each HTML page. It can be used to # fine-tune the look of the HTML output. If the tag is left blank doxygen # will generate a default style sheet HTML_STYLESHEET = # If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, # files or namespaces will be aligned in HTML using tables. If set to # NO a bullet list will be used. HTML_ALIGN_MEMBERS = YES # If the GENERATE_HTMLHELP tag is set to YES, additional index files # will be generated that can be used as input for tools like the # Microsoft HTML help workshop to generate a compressed HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = YES # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index # of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. ALPHABETICAL_INDEX = YES # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) COLS_IN_ALPHA_INDEX = 3 #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. GENERATE_LATEX = YES # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. LATEX_OUTPUT = # If the COMPACT_LATEX tag is set to YES Doxygen generates more compact # LaTeX documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_LATEX = NO # The PAPER_TYPE tag can be used to set the paper type that is used # by the printer. Possible values are: a4, a4wide, letter, legal and # executive. If left blank a4wide will be used. PAPER_TYPE = a4wide # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. EXTRA_PACKAGES = # The LATEX_HEADER tag can be used to specify a personal LaTeX header for # the generated latex document. The header should contain everything until # the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! LATEX_HEADER = # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated # is prepared for conversion to pdf (using ps2pdf). The pdf file will # contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. PDF_HYPERLINKS = NO #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- # If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages GENERATE_MAN = YES # The MAN_OUTPUT tag is used to specify where the man pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. MAN_OUTPUT = # The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) MAN_EXTENSION = .3 #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- # If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will # evaluate all C-preprocessor directives found in the sources and include # files. ENABLE_PREPROCESSING = YES # If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro # names in the source code. If set to NO (the default) only conditional # compilation will be performed. MACRO_EXPANSION = YES # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # in the INCLUDE_PATH (see below) will be search if a #include is found. SEARCH_INCLUDES = YES # The INCLUDE_PATH tag can be used to specify one or more directories that # contain include files that are not input files but should be processed by # the preprocessor. INCLUDE_PATH = # The PREDEFINED tag can be used to specify one or more macro names that # are defined before the preprocessor is started (similar to the -D option of # gcc). The argument of the tag is a list of macros of the form: name # or name=definition (no spaces). If the definition and the = are # omitted =1 is assumed. PREDEFINED = \ "vtkSetMacro(name,type)= \ virtual void Set##name (type);" \ "vtkGetMacro(name,type)= \ virtual type Get##name ();" \ "vtkSetStringMacro(name)= \ virtual void Set##name (const char*);" \ "vtkGetStringMacro(name)= \ virtual char* Get##name ();" \ "vtkSetClampMacro(name,type,min,max)= \ virtual void Set##name (type);" \ "vtkSetObjectMacro(name,type)= \ virtual void Set##name (type*);" \ "vtkGetObjectMacro(name,type)= \ virtual type *Get##name ();" \ "vtkBooleanMacro(name,type)= \ virtual void name##On (); \ virtual void name##Off ();" \ "vtkSetVector2Macro(name,type)= \ virtual void Set##name (type, type); \ void Set##name (type [2]);" \ "vtkGetVector2Macro(name,type)= \ virtual type *Get##name (); \ virtual void Get##name (type &, type &); \ virtual void Get##name (type [2]);" \ "vtkSetVector3Macro(name,type)= \ virtual void Set##name (type, type, type); \ virtual void Set##name (type [3]);" \ "vtkGetVector3Macro(name,type)= \ virtual type *Get##name (); \ virtual void Get##name (type &, type &, type &); \ virtual void Get##name (type [3]);" \ "vtkSetVector4Macro(name,type)= \ virtual void Set##name (type, type, type, type); \ virtual void Set##name (type [4]);" \ "vtkGetVector4Macro(name,type)= \ virtual type *Get##name (); \ virtual void Get##name (type &, type &, type &, type &); \ virtual void Get##name (type [4]);" \ "vtkSetVector6Macro(name,type)= \ virtual void Set##name (type, type, type, type, \ type, type); \ virtual void Set##name (type [6]);" \ "vtkGetVector6Macro(name,type)= \ virtual type *Get##name (); \ virtual void Get##name (type &, type &, type &, \ type &, type &, type &); \ virtual void Get##name (type [6]);" \ "vtkSetVectorMacro(name,type,count)= \ virtual void Set##name(type data[]);" \ "vtkGetVectorMacro(name,type,count)= \ virtual type *Get##name (); \ virtual void Get##name(type data[##count]);" \ "vtkWorldCoordinateMacro(name)= \ virtual vtkCoordinate *Get##name##Coordinate (); \ virtual void Set##name(float x[3]); \ virtual void Set##name(float x, float y, float z); \ virtual float *Get##name();" \ "vtkViewportCoordinateMacro(name)= \ virtual vtkCoordinate *Get##name##Coordinate (); \ virtual void Set##name(float x[2]); \ virtual void Set##name(float x, float y); \ virtual float *Get##name();" \ "vtkTypeMacro(thisClass,superclass)= \ virtual const char *GetClassName(); \ static int IsTypeOf(const char *type); \ virtual int IsA(const char *type); \ static thisClass* SafeDownCast(vtkObject *o);" \ __cplusplus \ DOXYGEN_SKIP \ "XdmfSetValueMacro(var,type) = XdmfInt32 Set##var (type Value);" \ "XdmfSetIndexValueMacro(var,type) = XdmfInt32 Set##var (XdmfInt64 Index, type Value);" \ "XdmfGetValueMacro(var,type) = type Get##var ( void );" \ "XdmfGetIndexValueMacro(var,type) = type Get##var ( XdmfInt64 Index );" # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES # then the macro expansion is limited to the macros specified with the # PREDEFINED tag. EXPAND_ONLY_PREDEF = YES #--------------------------------------------------------------------------- # Configuration options related to external references #--------------------------------------------------------------------------- # The TAGFILES tag can be used to specify one or more tagfiles. TAGFILES = "@Xdmf_BINARY_DIR@/Utilities/Doxygen/vtkNightlyDoc.tag=http://www.vtk.org/doc/nightly/html" # When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. GENERATE_TAGFILE = "@Xdmf_BINARY_DIR@/Utilities/Doxygen/Xdmf.tag" # If the ALLEXTERNALS tag is set to YES all external classes will be listed # in the class index. If set to NO only the inherited external classes # will be listed. ALLEXTERNALS = NO # The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the search engine #--------------------------------------------------------------------------- # The SEARCHENGINE tag specifies whether or not a search engine should be # used. If set to NO the values of all tags below this one will be ignored. SEARCHENGINE = NO GENERATE_TREEVIEW = NO GENERATE_TODOLIST = YES GENERATE_BUGLIST = YES GENERATE_RTF = NO HAVE_DOT = YES DOT_PATH = "@DOT_PATH@" CLASS_GRAPH = YES COLLABORATION_GRAPH = YES TEMPLATE_RELATIONS = YES INCLUDE_GRAPH = YES INCLUDED_BY_GRAPH = YES GENERATE_LEGEND = YES GRAPHICAL_HIERARCHY = YES EXTRACT_STATIC = YES SHOW_INCLUDE_FILES = YES SORT_MEMBER_DOCS = NO DISTRIBUTE_GROUP_DOC = YES IGNORE_PREFIX = vtkKW vtkPV vtk vtkXdmf Xdmf xdmf-3.0+git20160803/Utilities/Doxygen/doc_makeall.sh.in0000640000175000017500000002654013003006557022665 0ustar alastairalastair# ------------------------------------------------------------------------- # Doxygen documentation batch # modified by S. Barre (Time-stamp: <2002-12-22 09:49:58 barre> # ------------------------------------------------------------------------- # Path to several tools (_PROG to avoid the typical GZIP env var pb) # Example: # DOXYGEN_PROG=@DOXYGEN@ (INCLUDE(FindDoxygen.cmake)) # GZIP_PROG=@GZIP@ (INCLUDE(FindCygwin.cmake)) # HHC_PROG=@HTML_HELP_COMPILER@ (INCLUDE(FindHTMLHelp.cmake)) # MV_PROG=@MV@ (INCLUDE(FindCygwin.cmake)) # PERL_PROG=@PERL@ (INCLUDE(FindPerl.cmake)) # RM_PROG=@RM@ (INCLUDE(FindCygwin.cmake)) # TAR_PROG=@TAR@ (INCLUDE(FindCygwin.cmake)) # WGET_PROG=@WGET@ (INCLUDE(FindWget.cmake)) # export DOXYGEN_PROG="@DOXYGEN@" # Doxygen export GZIP_PROG="@GZIP@" # gzip (Unix-like 'gzip compressor') export GNUPLOT_PROG="@GNUPLOT@" # gnuplot (data plotting program) export HHC_PROG="@HTML_HELP_COMPILER@" # HTML Help Compiler export MV_PROG="@MV@" # mv (Unix-like 'move/rename files') export PERL_PROG="@PERL@" # Perl export RM_PROG="@RM@" # rm (Unix-like 'remove files') export TAR_PROG="@TAR@" # tar (Unix-like 'archiver') export WGET_PROG="@WGET@" # wget (remote file retrieval) # PROJECT_NAME: # Documentation/project name. Used in some of the resulting file names and # xrefs to uniquify two or more projects linked together through their # Doxygen's tag files. Mandatory for each documentation set. # Note: might be the same as the doxyfile's PROJECT_NAME # Example: # PROJECT_NAME=VTK # export PROJECT_NAME=Xdmf # PATH_TO_VTK_DOX_SCRIPTS: # Path to the directory holding the Perl scripts used to produce the VTK doc # in Doxygen format. You need the VTK source files or a local copy of # these scripts. # Example: # PATH_TO_VTK_DOX_SCRIPTS=@VTK_DOXYGEN_HOME@ # export PATH_TO_VTK_DOX_SCRIPTS="@VTK_DOXYGEN_HOME@" # SOURCE_DIR: # Source directory. The top directory of the source files. # Example: # SOURCE_DIR=@Xdmf_SOURCE_DIR@ # export SOURCE_DIR="@Xdmf_SOURCE_DIR@" export BINARY_DIR="@Xdmf_BINARY_DIR@" # REL_PATH_TO_TOP: # Relative path from the top directory of the source files to the directory # (or top directory) holding the files to document. Useful if several parts # of the same source directory should be documented separately. # Example: # REL_PATH_TO_TOP=. # REL_PATH_TO_TOP=framework/src # export REL_PATH_TO_TOP=. # INTERMEDIATE_DOX_DIR: # Directory where the intermediate Doxygen files should be stored (mainly # these headers files converted from the VTK format to the Doxygen format). # This directory is erased at the end of this script, unless you comment # the corresponding line. # DOXTEMP might be used to simplify the syntax. # Example: # DOXTEMP=DOXTEMP=@Xdmf_BINARY_DIR@/Utilities/Doxygen # INTERMEDIATE_DOX_DIR=$DOXTEMP/dox # export DOXTEMP="@Xdmf_BINARY_DIR@/Utilities/Doxygen" export INTERMEDIATE_DOX_DIR="$DOXTEMP/dox" # CVSWEB_CHECKOUT, CVSWEB_CHECKOUT_SUFFIX: # URL to the CVSWeb of the project, in checkout mode (i.e. appending a file # name to this URL will retrieve the contents of the file). In the same way # CVSWEB_CHECKOUT_SUFFIX is appended to the result. # Example: # CVSWEB_CHECKOUT=http://public.kitware.com/cgi-bin/cvsweb.cgi/~checkout~/VTK # CVSWEB_CHECKOUT_SUFFIX=?cvsroot=CMake # export CVSWEB_CHECKOUT="http://public.kitware.com/cgi-bin/cvsweb.cgi/~checkout~/Xdmf/" export CVSWEB_CHECKOUT_SUFFIX="?cvsroot=Xdmf" # DOXYFILE: # Path to the Doxygen configuration file (i.e. doxyfile). # Example: # DOXYFILE=$DOXTEMP/doxyfile # export DOXYFILE="$DOXTEMP/doxyfile" # OUTPUT_DIRECTORY ALLOW_ERASE_OUTPUT_DIRECTORY: # Path to the Doxygen output directory (where the resulting doc is stored). # Note: should be the same as your doxyfile's OUTPUT_DIRECTORY # If ON, allows the output directory to be erased when some advanced output # file have been produced (HTML Help, or TAR archive for example). # Example: # OUTPUT_DIRECTORY=$DOXTEMP/doc # ALLOW_ERASE_OUTPUT_DIRECTORY=ON # export OUTPUT_DIRECTORY="$DOXTEMP/doc" export ALLOW_ERASE_OUTPUT_DIRECTORY=ON # COMPILE_HTML_HELP RESULTING_HTML_HELP_FILE: # Compile the CHM (Compressed HTML) HTML Help file, name of the resulting # file. If set to ON and name is non-empty these options will actually # trigger the HTML-Help compiler to create the CHM. The resulting # file (usually index.chm) will be renamed to this name. # Note: if ON, the whole $OUTPUT_DIRECTORY will be erased at the end of # this script, since this file is considered to be one of the # advanced final output, unless ALLOW_ERASE_OUTPUT_DIRECTORY is OFF # Note: your doxyfile should be configured to enable HTML Help creation # (using GENERATE_HTML = YES, GENERATE_HTMLHELP = YES) # Example: # COMPILE_HTML_HELP=ON # COMPILE_HTML_HELP=@DOCUMENTATION_HTML_HELP@ # RESULTING_HTML_HELP_FILE=$DOXTEMP/vtk4.chm # export COMPILE_HTML_HELP=@DOCUMENTATION_HTML_HELP@ export RESULTING_HTML_HELP_FILE="$DOXTEMP/$PROJECT_NAME.chm" # CREATE_HTML_TARZ_ARCHIVE RESULTING_HTML_TARZ_ARCHIVE_FILE: # Create a compressed (gzip) tar archive of the html directory (located # under the OUTPUT_DIRECTORY), and name of the resulting archive file. # Note: your doxyfile should be configured to enable HTML creation # (using GENERATE_HTML = YES) # Example: # CREATE_HTML_TARZ_ARCHIVE=ON # CREATE_HTML_TARZ_ARCHIVE=@DOCUMENTATION_HTML_TARZ@ # RESULTING_HTML_TARZ_ARCHIVE_FILE=$DOXTEMP/vtk4-html.tar.gz # export CREATE_HTML_TARZ_ARCHIVE=@DOCUMENTATION_HTML_TARZ@ export RESULTING_HTML_TARZ_ARCHIVE_FILE="$DOXTEMP/$PROJECT_NAME-html.tar.gz" # DOWNLOAD_VTK_TAGFILE VTK_TAGFILE VTK_TAGFILE_REMOTE_DIR VTK_TAGFILE_DEST_DIR: # Download the VTK tag file, name, remote location and destination dir of this # tag file. If set to ON, the tag file is retrieved from its remote location # using wget and stored in the destination dir. # The tag file is expected to be compressed using gzip, but DO NOT include # the .gz extension in VTK_TAGFILE. # Note: your doxyfile must be tailored to make use-of or create this tag file. # (using TAGFILES = vtk4-nightly.tag=http://www.vtk.org/doc/nightly/html # or GENERATE_TAGFILE = "@FOO_BINARY_DIR@/Utilities/Doxygen/vtk4.tag") # Example: # DOWNLOAD_VTK_TAGFILE=OFF # VTK_TAGFILE=vtk4-nightly.tag # VTK_TAGFILE_REMOTE_DIR=http://www.vtk.org/doc/nightly/html # VTK_TAGFILE_DEST_DIR=$DOXTEMP # export DOWNLOAD_VTK_TAGFILE=@DOCUMENTATION_DOWNLOAD_VTK_TAGFILE@ export VTK_TAGFILE=vtkNightlyDoc.tag export VTK_TAGFILE_REMOTE_DIR="http://www.vtk.org/files/nightly" export VTK_TAGFILE_DEST_DIR="$DOXTEMP" # ---------------------------------------------------------------------------- # Convert the VTK headers to the Doxygen format. if test "x$PERL_PROG" != "xNOTFOUND" ; then $PERL_PROG "$PATH_TO_VTK_DOX_SCRIPTS/doc_header2doxygen.pl" \ --to "$INTERMEDIATE_DOX_DIR" \ --relativeto "$SOURCE_DIR/$REL_PATH_TO_TOP" \ "$SOURCE_DIR/$REL_PATH_TO_TOP/vtk" \ "$BINARY_DIR/$REL_PATH_TO_TOP/vtk" fi # ---------------------------------------------------------------------------- # Build the full-text index. if test "x$PERL_PROG" != "xNOTFOUND" ; then $PERL_PROG "$PATH_TO_VTK_DOX_SCRIPTS/doc_index.pl" \ --project "$PROJECT_NAME" \ --stop "$PATH_TO_VTK_DOX_SCRIPTS/doc_index.stop" \ --store "doc_""$PROJECT_NAME""_index.dox" \ --to "$INTERMEDIATE_DOX_DIR" \ "$SOURCE_DIR/$REL_PATH_TO_TOP/vtk" \ "$BINARY_DIR/$REL_PATH_TO_TOP/vtk" fi # # ---------------------------------------------------------------------------- # # Generate the 'Class to Demos' page cross-linking each class to these # # demos that use that class. # if test "x$PERL_PROG" != "xNOTFOUND" ; then # $PERL_PROG $PATH_TO_VTK_DOX_SCRIPTS/doc_class2example.pl \ # --datamatch "\W((VTK|Xdmf)_DATA_ROOT|(VTK|MedVIP)Data|(vtk)?GetDataRoot|ExpandDataFileName)\W" \ # --dataicon "paper-clip.gif" \ # --dirmatch "^demos$" \ # --label "Demos" \ # --project "$PROJECT_NAME" \ # --store "doc_""$PROJECT_NAME""_class2demos.dox" \ # --title "Class To Demos" \ # --to "$INTERMEDIATE_DOX_DIR" \ # --unique "d" \ # "$SOURCE_DIR/framework/demos" # fi # ---------------------------------------------------------------------------- # Retrieve the (gziped) VTK 4 tag file and decompress it if test "x$DOWNLOAD_VTK_TAGFILE" == "xON" ; then if test "x$VTK_TAGFILE" != "x" ; then if test "x$WGET_PROG" != "xNOTFOUND" ; then $WGET_PROG -nd -nH \ "$VTK_TAGFILE_REMOTE_DIR/$VTK_TAGFILE.gz" \ -O "$VTK_TAGFILE_DEST_DIR/$VTK_TAGFILE.gz" if test "x$GZIP_PROG" != "xNOTFOUND" ; then $GZIP_PROG -d "$VTK_TAGFILE_DEST_DIR/$VTK_TAGFILE.gz" fi fi fi fi # ---------------------------------------------------------------------------- # Create the Doxygen doc. if test "x$DOXYGEN_PROG" != "xNOTFOUND" ; then if test "x$RM_PROG" != "xNOTFOUND" ; then $RM_PROG -fr "$OUTPUT_DIRECTORY" fi $DOXYGEN_PROG "$DOXYFILE" fi # ---------------------------------------------------------------------------- # Clean the HTML pages to remove the path to the intermediate Doxygen dir. if test "x$PERL_PROG" != "xNOTFOUND" ; then $PERL_PROG "$PATH_TO_VTK_DOX_SCRIPTS/doc_rmpath.pl" \ --to "$INTERMEDIATE_DOX_DIR" \ --html "$OUTPUT_DIRECTORY/html" fi # ---------------------------------------------------------------------------- # Create the CHM HTML HELP doc. if test "x$COMPILE_HTML_HELP" == "xON" ; then if test "x$RESULTING_HTML_HELP_FILE" != "x" ; then cd "$OUTPUT_DIRECTORY/html" if test "x$HHC_PROG" != "xNOTFOUND" ; then $HHC_PROG index.hhp if test "x$MV_PROG" != "xNOTFOUND" ; then $MV_PROG -f index.chm "$RESULTING_HTML_HELP_FILE" fi fi fi fi # ---------------------------------------------------------------------------- # Create the compressed tar archive. if test "x$CREATE_HTML_TARZ_ARCHIVE" == "xON" ; then if test "x$RESULTING_HTML_TARZ_ARCHIVE_FILE" != "x" ; then cd "$OUTPUT_DIRECTORY" if test "x$TAR_PROG" != "xNOTFOUND" ; then if test "x$RM_PROG" != "xNOTFOUND" ; then $RM_PROG -f html.tar fi $TAR_PROG -cf html.tar html if test "x$GZIP_PROG" != "xNOTFOUND" ; then if test "x$RM_PROG" != "xNOTFOUND" ; then $RM_PROG -f html.tar.gz fi $GZIP_PROG html.tar $MV_PROG -f html.tar.gz "$RESULTING_HTML_TARZ_ARCHIVE_FILE" fi fi fi fi # ---------------------------------------------------------------------------- # Clean-up. if test "x$RM_PROG" != "xNOTFOUND" ; then $RM_PROG -fr "$INTERMEDIATE_DOX_DIR" if test "x$DOWNLOAD_VTK_TAGFILE" == "xON" ; then if test "x$VTK_TAGFILE" != "x" ; then $RM_PROG -f "$VTK_TAGFILE_DEST_DIR/$VTK_TAGFILE" fi fi if test "x$COMPILE_HTML_HELP" == "xON" ; then if test "x$RESULTING_HTML_HELP_FILE" != "x" ; then if test "x$ALLOW_ERASE_OUTPUT_DIRECTORY" == "xON" ; then $RM_PROG -fr "$OUTPUT_DIRECTORY" fi fi fi fi xdmf-3.0+git20160803/Utilities/CVS/0000740000175000017500000000000013003006557016476 5ustar alastairalastairxdmf-3.0+git20160803/Utilities/CVS/Repository0000640000175000017500000000001713003006557020600 0ustar alastairalastairXdmf/Utilities xdmf-3.0+git20160803/Utilities/CVS/Root0000640000175000017500000000006413003006557017346 0ustar alastairalastair:pserver:anonymous@public.kitware.com:/cvsroot/Xdmf xdmf-3.0+git20160803/Utilities/CVS/Entries0000640000175000017500000000022413003006557020032 0ustar alastairalastair/CMakeLists.txt/1.2/Thu Jan 22 21:47:53 2009// D/Doxygen//// D/hdf5//// D/metis//// D/vtkexodus2//// D/vtklibxml2//// D/vtknetcdf//// D/vtkzlib//// xdmf-3.0+git20160803/Utilities/CMakeLists.txt0000640000175000017500000000026713003006557020612 0ustar alastairalastair# SET(VTKHDF5_INSTALL_LIB_DIR /lib/Xdmf) SET(VTKHDF5_INSTALL_LIB_DIR /lib) SUBDIRS(hdf5) IF(XDMF_BUILD_VTK) SUBDIRS(Doxygen) ENDIF(XDMF_BUILD_VTK) SET(VTK_INSTALL_LIB_DIR "/lib") xdmf-3.0+git20160803/Utilities/vtklibxml2/0000740000175000017500000000000013003006557020141 5ustar alastairalastairxdmf-3.0+git20160803/Utilities/vtklibxml2/relaxng.c0000640000175000017500000130554613003006557021765 0ustar alastairalastair/* * relaxng.c : implementation of the Relax-NG handling and validity checking * * See Copyright for the status of this software. * * Daniel Veillard */ /** * TODO: * - add support for DTD compatibility spec * http://www.oasis-open.org/committees/relax-ng/compatibility-20011203.html * - report better mem allocations pbms at runtime and abort immediately. */ #define IN_LIBXML #include "libxml.h" #ifdef LIBXML_SCHEMAS_ENABLED #include #include #include #include #include #include #include #include #include #include #include #include /* * The Relax-NG namespace */ static const xmlChar *xmlRelaxNGNs = (const xmlChar *) "http://relaxng.org/ns/structure/1.0"; #define IS_RELAXNG(node, type) \ ((node != NULL) && (node->ns != NULL) && \ (xmlStrEqual(node->name, (const xmlChar *) type)) && \ (xmlStrEqual(node->ns->href, xmlRelaxNGNs))) #if 0 #define DEBUG 1 #define DEBUG_GRAMMAR 1 #define DEBUG_CONTENT 1 #define DEBUG_TYPE 1 #define DEBUG_VALID 1 #define DEBUG_INTERLEAVE 1 #define DEBUG_LIST 1 #define DEBUG_INCLUDE 1 #define DEBUG_ERROR 1 #define DEBUG_COMPILE 1 #define DEBUG_PROGRESSIVE 1 #endif #define MAX_ERROR 5 #define TODO \ xmlGenericError(xmlGenericErrorContext, \ "Unimplemented block at %s:%d\n", \ __FILE__, __LINE__); typedef struct _xmlRelaxNGSchema xmlRelaxNGSchema; typedef xmlRelaxNGSchema *xmlRelaxNGSchemaPtr; typedef struct _xmlRelaxNGDefine xmlRelaxNGDefine; typedef xmlRelaxNGDefine *xmlRelaxNGDefinePtr; typedef struct _xmlRelaxNGDocument xmlRelaxNGDocument; typedef xmlRelaxNGDocument *xmlRelaxNGDocumentPtr; typedef struct _xmlRelaxNGInclude xmlRelaxNGInclude; typedef xmlRelaxNGInclude *xmlRelaxNGIncludePtr; typedef enum { XML_RELAXNG_COMBINE_UNDEFINED = 0, /* undefined */ XML_RELAXNG_COMBINE_CHOICE, /* choice */ XML_RELAXNG_COMBINE_INTERLEAVE /* interleave */ } xmlRelaxNGCombine; typedef enum { XML_RELAXNG_CONTENT_ERROR = -1, XML_RELAXNG_CONTENT_EMPTY = 0, XML_RELAXNG_CONTENT_SIMPLE, XML_RELAXNG_CONTENT_COMPLEX } xmlRelaxNGContentType; typedef struct _xmlRelaxNGGrammar xmlRelaxNGGrammar; typedef xmlRelaxNGGrammar *xmlRelaxNGGrammarPtr; struct _xmlRelaxNGGrammar { xmlRelaxNGGrammarPtr parent; /* the parent grammar if any */ xmlRelaxNGGrammarPtr children; /* the children grammar if any */ xmlRelaxNGGrammarPtr next; /* the next grammar if any */ xmlRelaxNGDefinePtr start; /* content */ xmlRelaxNGCombine combine; /* the default combine value */ xmlRelaxNGDefinePtr startList; /* list of definitions */ xmlHashTablePtr defs; /* define* */ xmlHashTablePtr refs; /* references */ }; typedef enum { XML_RELAXNG_NOOP = -1, /* a no operation from simplification */ XML_RELAXNG_EMPTY = 0, /* an empty pattern */ XML_RELAXNG_NOT_ALLOWED, /* not allowed top */ XML_RELAXNG_EXCEPT, /* except present in nameclass defs */ XML_RELAXNG_TEXT, /* textual content */ XML_RELAXNG_ELEMENT, /* an element */ XML_RELAXNG_DATATYPE, /* extenal data type definition */ XML_RELAXNG_PARAM, /* extenal data type parameter */ XML_RELAXNG_VALUE, /* value from an extenal data type definition */ XML_RELAXNG_LIST, /* a list of patterns */ XML_RELAXNG_ATTRIBUTE, /* an attrbute following a pattern */ XML_RELAXNG_DEF, /* a definition */ XML_RELAXNG_REF, /* reference to a definition */ XML_RELAXNG_EXTERNALREF, /* reference to an external def */ XML_RELAXNG_PARENTREF, /* reference to a def in the parent grammar */ XML_RELAXNG_OPTIONAL, /* optional patterns */ XML_RELAXNG_ZEROORMORE, /* zero or more non empty patterns */ XML_RELAXNG_ONEORMORE, /* one or more non empty patterns */ XML_RELAXNG_CHOICE, /* a choice between non empty patterns */ XML_RELAXNG_GROUP, /* a pair/group of non empty patterns */ XML_RELAXNG_INTERLEAVE, /* interleaving choice of non-empty patterns */ XML_RELAXNG_START /* Used to keep track of starts on grammars */ } xmlRelaxNGType; #define IS_NULLABLE (1 << 0) #define IS_NOT_NULLABLE (1 << 1) #define IS_INDETERMINIST (1 << 2) #define IS_MIXED (1 << 3) #define IS_TRIABLE (1 << 4) #define IS_PROCESSED (1 << 5) #define IS_COMPILABLE (1 << 6) #define IS_NOT_COMPILABLE (1 << 7) struct _xmlRelaxNGDefine { xmlRelaxNGType type; /* the type of definition */ xmlNodePtr node; /* the node in the source */ xmlChar *name; /* the element local name if present */ xmlChar *ns; /* the namespace local name if present */ xmlChar *value; /* value when available */ void *data; /* data lib or specific pointer */ xmlRelaxNGDefinePtr content; /* the expected content */ xmlRelaxNGDefinePtr parent; /* the parent definition, if any */ xmlRelaxNGDefinePtr next; /* list within grouping sequences */ xmlRelaxNGDefinePtr attrs; /* list of attributes for elements */ xmlRelaxNGDefinePtr nameClass; /* the nameClass definition if any */ xmlRelaxNGDefinePtr nextHash; /* next define in defs/refs hash tables */ short depth; /* used for the cycle detection */ short dflags; /* define related flags */ xmlRegexpPtr contModel; /* a compiled content model if available */ }; /** * _xmlRelaxNG: * * A RelaxNGs definition */ struct _xmlRelaxNG { void *_private; /* unused by the library for users or bindings */ xmlRelaxNGGrammarPtr topgrammar; xmlDocPtr doc; int idref; /* requires idref checking */ xmlHashTablePtr defs; /* define */ xmlHashTablePtr refs; /* references */ xmlRelaxNGDocumentPtr documents; /* all the documents loaded */ xmlRelaxNGIncludePtr includes; /* all the includes loaded */ int defNr; /* number of defines used */ xmlRelaxNGDefinePtr *defTab; /* pointer to the allocated definitions */ }; #define XML_RELAXNG_IN_ATTRIBUTE (1 << 0) #define XML_RELAXNG_IN_ONEORMORE (1 << 1) #define XML_RELAXNG_IN_LIST (1 << 2) #define XML_RELAXNG_IN_DATAEXCEPT (1 << 3) #define XML_RELAXNG_IN_START (1 << 4) #define XML_RELAXNG_IN_OOMGROUP (1 << 5) #define XML_RELAXNG_IN_OOMINTERLEAVE (1 << 6) #define XML_RELAXNG_IN_EXTERNALREF (1 << 7) #define XML_RELAXNG_IN_ANYEXCEPT (1 << 8) #define XML_RELAXNG_IN_NSEXCEPT (1 << 9) struct _xmlRelaxNGParserCtxt { void *userData; /* user specific data block */ xmlRelaxNGValidityErrorFunc error; /* the callback in case of errors */ xmlRelaxNGValidityWarningFunc warning; /* the callback in case of warning */ xmlStructuredErrorFunc serror; xmlRelaxNGValidErr err; xmlRelaxNGPtr schema; /* The schema in use */ xmlRelaxNGGrammarPtr grammar; /* the current grammar */ xmlRelaxNGGrammarPtr parentgrammar; /* the parent grammar */ int flags; /* parser flags */ int nbErrors; /* number of errors at parse time */ int nbWarnings; /* number of warnings at parse time */ const xmlChar *define; /* the current define scope */ xmlRelaxNGDefinePtr def; /* the current define */ int nbInterleaves; xmlHashTablePtr interleaves; /* keep track of all the interleaves */ xmlRelaxNGDocumentPtr documents; /* all the documents loaded */ xmlRelaxNGIncludePtr includes; /* all the includes loaded */ xmlChar *URL; xmlDocPtr document; int defNr; /* number of defines used */ int defMax; /* number of defines aloocated */ xmlRelaxNGDefinePtr *defTab; /* pointer to the allocated definitions */ const char *buffer; int size; /* the document stack */ xmlRelaxNGDocumentPtr doc; /* Current parsed external ref */ int docNr; /* Depth of the parsing stack */ int docMax; /* Max depth of the parsing stack */ xmlRelaxNGDocumentPtr *docTab; /* array of docs */ /* the include stack */ xmlRelaxNGIncludePtr inc; /* Current parsed include */ int incNr; /* Depth of the include parsing stack */ int incMax; /* Max depth of the parsing stack */ xmlRelaxNGIncludePtr *incTab; /* array of incs */ int idref; /* requires idref checking */ /* used to compile content models */ xmlAutomataPtr am; /* the automata */ xmlAutomataStatePtr state; /* used to build the automata */ int crng; /* compact syntax and other flags */ int freedoc; /* need to free the document */ }; #define FLAGS_IGNORABLE 1 #define FLAGS_NEGATIVE 2 #define FLAGS_MIXED_CONTENT 4 #define FLAGS_NOERROR 8 /** * xmlRelaxNGInterleaveGroup: * * A RelaxNGs partition set associated to lists of definitions */ typedef struct _xmlRelaxNGInterleaveGroup xmlRelaxNGInterleaveGroup; typedef xmlRelaxNGInterleaveGroup *xmlRelaxNGInterleaveGroupPtr; struct _xmlRelaxNGInterleaveGroup { xmlRelaxNGDefinePtr rule; /* the rule to satisfy */ xmlRelaxNGDefinePtr *defs; /* the array of element definitions */ xmlRelaxNGDefinePtr *attrs; /* the array of attributes definitions */ }; #define IS_DETERMINIST 1 #define IS_NEEDCHECK 2 /** * xmlRelaxNGPartitions: * * A RelaxNGs partition associated to an interleave group */ typedef struct _xmlRelaxNGPartition xmlRelaxNGPartition; typedef xmlRelaxNGPartition *xmlRelaxNGPartitionPtr; struct _xmlRelaxNGPartition { int nbgroups; /* number of groups in the partitions */ xmlHashTablePtr triage; /* hash table used to direct nodes to the * right group when possible */ int flags; /* determinist ? */ xmlRelaxNGInterleaveGroupPtr *groups; }; /** * xmlRelaxNGValidState: * * A RelaxNGs validation state */ #define MAX_ATTR 20 typedef struct _xmlRelaxNGValidState xmlRelaxNGValidState; typedef xmlRelaxNGValidState *xmlRelaxNGValidStatePtr; struct _xmlRelaxNGValidState { xmlNodePtr node; /* the current node */ xmlNodePtr seq; /* the sequence of children left to validate */ int nbAttrs; /* the number of attributes */ int maxAttrs; /* the size of attrs */ int nbAttrLeft; /* the number of attributes left to validate */ xmlChar *value; /* the value when operating on string */ xmlChar *endvalue; /* the end value when operating on string */ xmlAttrPtr *attrs; /* the array of attributes */ }; /** * xmlRelaxNGStates: * * A RelaxNGs container for validation state */ typedef struct _xmlRelaxNGStates xmlRelaxNGStates; typedef xmlRelaxNGStates *xmlRelaxNGStatesPtr; struct _xmlRelaxNGStates { int nbState; /* the number of states */ int maxState; /* the size of the array */ xmlRelaxNGValidStatePtr *tabState; }; #define ERROR_IS_DUP 1 /** * xmlRelaxNGValidError: * * A RelaxNGs validation error */ typedef struct _xmlRelaxNGValidError xmlRelaxNGValidError; typedef xmlRelaxNGValidError *xmlRelaxNGValidErrorPtr; struct _xmlRelaxNGValidError { xmlRelaxNGValidErr err; /* the error number */ int flags; /* flags */ xmlNodePtr node; /* the current node */ xmlNodePtr seq; /* the current child */ const xmlChar *arg1; /* first arg */ const xmlChar *arg2; /* second arg */ }; /** * xmlRelaxNGValidCtxt: * * A RelaxNGs validation context */ struct _xmlRelaxNGValidCtxt { void *userData; /* user specific data block */ xmlRelaxNGValidityErrorFunc error; /* the callback in case of errors */ xmlRelaxNGValidityWarningFunc warning; /* the callback in case of warning */ xmlStructuredErrorFunc serror; int nbErrors; /* number of errors in validation */ xmlRelaxNGPtr schema; /* The schema in use */ xmlDocPtr doc; /* the document being validated */ int flags; /* validation flags */ int depth; /* validation depth */ int idref; /* requires idref checking */ int errNo; /* the first error found */ /* * Errors accumulated in branches may have to be stacked to be * provided back when it's sure they affect validation. */ xmlRelaxNGValidErrorPtr err; /* Last error */ int errNr; /* Depth of the error stack */ int errMax; /* Max depth of the error stack */ xmlRelaxNGValidErrorPtr errTab; /* stack of errors */ xmlRelaxNGValidStatePtr state; /* the current validation state */ xmlRelaxNGStatesPtr states; /* the accumulated state list */ xmlRelaxNGStatesPtr freeState; /* the pool of free valid states */ int freeStatesNr; int freeStatesMax; xmlRelaxNGStatesPtr *freeStates; /* the pool of free state groups */ /* * This is used for "progressive" validation */ xmlRegExecCtxtPtr elem; /* the current element regexp */ int elemNr; /* the number of element validated */ int elemMax; /* the max depth of elements */ xmlRegExecCtxtPtr *elemTab; /* the stack of regexp runtime */ int pstate; /* progressive state */ xmlNodePtr pnode; /* the current node */ xmlRelaxNGDefinePtr pdef; /* the non-streamable definition */ int perr; /* signal error in content model * outside the regexp */ }; /** * xmlRelaxNGInclude: * * Structure associated to a RelaxNGs document element */ struct _xmlRelaxNGInclude { xmlRelaxNGIncludePtr next; /* keep a chain of includes */ xmlChar *href; /* the normalized href value */ xmlDocPtr doc; /* the associated XML document */ xmlRelaxNGDefinePtr content; /* the definitions */ xmlRelaxNGPtr schema; /* the schema */ }; /** * xmlRelaxNGDocument: * * Structure associated to a RelaxNGs document element */ struct _xmlRelaxNGDocument { xmlRelaxNGDocumentPtr next; /* keep a chain of documents */ xmlChar *href; /* the normalized href value */ xmlDocPtr doc; /* the associated XML document */ xmlRelaxNGDefinePtr content; /* the definitions */ xmlRelaxNGPtr schema; /* the schema */ }; /************************************************************************ * * * Some factorized error routines * * * ************************************************************************/ /** * xmlRngPErrMemory: * @ctxt: an Relax-NG parser context * @extra: extra informations * * Handle a redefinition of attribute error */ static void xmlRngPErrMemory(xmlRelaxNGParserCtxtPtr ctxt, const char *extra) { xmlStructuredErrorFunc schannel = NULL; xmlGenericErrorFunc channel = NULL; void *data = NULL; if (ctxt != NULL) { if (ctxt->serror != NULL) schannel = ctxt->serror; else channel = ctxt->error; data = ctxt->userData; ctxt->nbErrors++; } if (extra) __xmlRaiseError(schannel, channel, data, NULL, NULL, XML_FROM_RELAXNGP, XML_ERR_NO_MEMORY, XML_ERR_FATAL, NULL, 0, extra, NULL, NULL, 0, 0, "Memory allocation failed : %s\n", extra); else __xmlRaiseError(schannel, channel, data, NULL, NULL, XML_FROM_RELAXNGP, XML_ERR_NO_MEMORY, XML_ERR_FATAL, NULL, 0, NULL, NULL, NULL, 0, 0, "Memory allocation failed\n"); } /** * xmlRngVErrMemory: * @ctxt: a Relax-NG validation context * @extra: extra informations * * Handle a redefinition of attribute error */ static void xmlRngVErrMemory(xmlRelaxNGValidCtxtPtr ctxt, const char *extra) { xmlStructuredErrorFunc schannel = NULL; xmlGenericErrorFunc channel = NULL; void *data = NULL; if (ctxt != NULL) { if (ctxt->serror != NULL) schannel = ctxt->serror; else channel = ctxt->error; data = ctxt->userData; ctxt->nbErrors++; } if (extra) __xmlRaiseError(schannel, channel, data, NULL, NULL, XML_FROM_RELAXNGV, XML_ERR_NO_MEMORY, XML_ERR_FATAL, NULL, 0, extra, NULL, NULL, 0, 0, "Memory allocation failed : %s\n", extra); else __xmlRaiseError(schannel, channel, data, NULL, NULL, XML_FROM_RELAXNGV, XML_ERR_NO_MEMORY, XML_ERR_FATAL, NULL, 0, NULL, NULL, NULL, 0, 0, "Memory allocation failed\n"); } /** * xmlRngPErr: * @ctxt: a Relax-NG parser context * @node: the node raising the error * @error: the error code * @msg: message * @str1: extra info * @str2: extra info * * Handle a Relax NG Parsing error */ static void xmlRngPErr(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node, int error, const char *msg, const xmlChar * str1, const xmlChar * str2) { xmlStructuredErrorFunc schannel = NULL; xmlGenericErrorFunc channel = NULL; void *data = NULL; if (ctxt != NULL) { if (ctxt->serror != NULL) schannel = ctxt->serror; else channel = ctxt->error; data = ctxt->userData; ctxt->nbErrors++; } __xmlRaiseError(schannel, channel, data, NULL, node, XML_FROM_RELAXNGP, error, XML_ERR_ERROR, NULL, 0, (const char *) str1, (const char *) str2, NULL, 0, 0, msg, str1, str2); } /** * xmlRngVErr: * @ctxt: a Relax-NG validation context * @node: the node raising the error * @error: the error code * @msg: message * @str1: extra info * @str2: extra info * * Handle a Relax NG Validation error */ static void xmlRngVErr(xmlRelaxNGValidCtxtPtr ctxt, xmlNodePtr node, int error, const char *msg, const xmlChar * str1, const xmlChar * str2) { xmlStructuredErrorFunc schannel = NULL; xmlGenericErrorFunc channel = NULL; void *data = NULL; if (ctxt != NULL) { if (ctxt->serror != NULL) schannel = ctxt->serror; else channel = ctxt->error; data = ctxt->userData; ctxt->nbErrors++; } __xmlRaiseError(schannel, channel, data, NULL, node, XML_FROM_RELAXNGV, error, XML_ERR_ERROR, NULL, 0, (const char *) str1, (const char *) str2, NULL, 0, 0, msg, str1, str2); } /************************************************************************ * * * Preliminary type checking interfaces * * * ************************************************************************/ /** * xmlRelaxNGTypeHave: * @data: data needed for the library * @type: the type name * @value: the value to check * * Function provided by a type library to check if a type is exported * * Returns 1 if yes, 0 if no and -1 in case of error. */ typedef int (*xmlRelaxNGTypeHave) (void *data, const xmlChar * type); /** * xmlRelaxNGTypeCheck: * @data: data needed for the library * @type: the type name * @value: the value to check * @result: place to store the result if needed * * Function provided by a type library to check if a value match a type * * Returns 1 if yes, 0 if no and -1 in case of error. */ typedef int (*xmlRelaxNGTypeCheck) (void *data, const xmlChar * type, const xmlChar * value, void **result, xmlNodePtr node); /** * xmlRelaxNGFacetCheck: * @data: data needed for the library * @type: the type name * @facet: the facet name * @val: the facet value * @strval: the string value * @value: the value to check * * Function provided by a type library to check a value facet * * Returns 1 if yes, 0 if no and -1 in case of error. */ typedef int (*xmlRelaxNGFacetCheck) (void *data, const xmlChar * type, const xmlChar * facet, const xmlChar * val, const xmlChar * strval, void *value); /** * xmlRelaxNGTypeFree: * @data: data needed for the library * @result: the value to free * * Function provided by a type library to free a returned result */ typedef void (*xmlRelaxNGTypeFree) (void *data, void *result); /** * xmlRelaxNGTypeCompare: * @data: data needed for the library * @type: the type name * @value1: the first value * @value2: the second value * * Function provided by a type library to compare two values accordingly * to a type. * * Returns 1 if yes, 0 if no and -1 in case of error. */ typedef int (*xmlRelaxNGTypeCompare) (void *data, const xmlChar * type, const xmlChar * value1, xmlNodePtr ctxt1, void *comp1, const xmlChar * value2, xmlNodePtr ctxt2); typedef struct _xmlRelaxNGTypeLibrary xmlRelaxNGTypeLibrary; typedef xmlRelaxNGTypeLibrary *xmlRelaxNGTypeLibraryPtr; struct _xmlRelaxNGTypeLibrary { const xmlChar *namespace; /* the datatypeLibrary value */ void *data; /* data needed for the library */ xmlRelaxNGTypeHave have; /* the export function */ xmlRelaxNGTypeCheck check; /* the checking function */ xmlRelaxNGTypeCompare comp; /* the compare function */ xmlRelaxNGFacetCheck facet; /* the facet check function */ xmlRelaxNGTypeFree freef; /* the freeing function */ }; /************************************************************************ * * * Allocation functions * * * ************************************************************************/ static void xmlRelaxNGFreeGrammar(xmlRelaxNGGrammarPtr grammar); static void xmlRelaxNGFreeDefine(xmlRelaxNGDefinePtr define); static void xmlRelaxNGNormExtSpace(xmlChar * value); static void xmlRelaxNGFreeInnerSchema(xmlRelaxNGPtr schema); static int xmlRelaxNGEqualValidState(xmlRelaxNGValidCtxtPtr ctxt ATTRIBUTE_UNUSED, xmlRelaxNGValidStatePtr state1, xmlRelaxNGValidStatePtr state2); static void xmlRelaxNGFreeValidState(xmlRelaxNGValidCtxtPtr ctxt, xmlRelaxNGValidStatePtr state); /** * xmlRelaxNGFreeDocument: * @docu: a document structure * * Deallocate a RelaxNG document structure. */ static void xmlRelaxNGFreeDocument(xmlRelaxNGDocumentPtr docu) { if (docu == NULL) return; if (docu->href != NULL) xmlFree(docu->href); if (docu->doc != NULL) xmlFreeDoc(docu->doc); if (docu->schema != NULL) xmlRelaxNGFreeInnerSchema(docu->schema); xmlFree(docu); } /** * xmlRelaxNGFreeDocumentList: * @docu: a list of document structure * * Deallocate a RelaxNG document structures. */ static void xmlRelaxNGFreeDocumentList(xmlRelaxNGDocumentPtr docu) { xmlRelaxNGDocumentPtr next; while (docu != NULL) { next = docu->next; xmlRelaxNGFreeDocument(docu); docu = next; } } /** * xmlRelaxNGFreeInclude: * @incl: a include structure * * Deallocate a RelaxNG include structure. */ static void xmlRelaxNGFreeInclude(xmlRelaxNGIncludePtr incl) { if (incl == NULL) return; if (incl->href != NULL) xmlFree(incl->href); if (incl->doc != NULL) xmlFreeDoc(incl->doc); if (incl->schema != NULL) xmlRelaxNGFree(incl->schema); xmlFree(incl); } /** * xmlRelaxNGFreeIncludeList: * @incl: a include structure list * * Deallocate a RelaxNG include structure. */ static void xmlRelaxNGFreeIncludeList(xmlRelaxNGIncludePtr incl) { xmlRelaxNGIncludePtr next; while (incl != NULL) { next = incl->next; xmlRelaxNGFreeInclude(incl); incl = next; } } /** * xmlRelaxNGNewRelaxNG: * @ctxt: a Relax-NG validation context (optional) * * Allocate a new RelaxNG structure. * * Returns the newly allocated structure or NULL in case or error */ static xmlRelaxNGPtr xmlRelaxNGNewRelaxNG(xmlRelaxNGParserCtxtPtr ctxt) { xmlRelaxNGPtr ret; ret = (xmlRelaxNGPtr) xmlMalloc(sizeof(xmlRelaxNG)); if (ret == NULL) { xmlRngPErrMemory(ctxt, NULL); return (NULL); } memset(ret, 0, sizeof(xmlRelaxNG)); return (ret); } /** * xmlRelaxNGFreeInnerSchema: * @schema: a schema structure * * Deallocate a RelaxNG schema structure. */ static void xmlRelaxNGFreeInnerSchema(xmlRelaxNGPtr schema) { if (schema == NULL) return; if (schema->doc != NULL) xmlFreeDoc(schema->doc); if (schema->defTab != NULL) { int i; for (i = 0; i < schema->defNr; i++) xmlRelaxNGFreeDefine(schema->defTab[i]); xmlFree(schema->defTab); } xmlFree(schema); } /** * xmlRelaxNGFree: * @schema: a schema structure * * Deallocate a RelaxNG structure. */ void xmlRelaxNGFree(xmlRelaxNGPtr schema) { if (schema == NULL) return; if (schema->topgrammar != NULL) xmlRelaxNGFreeGrammar(schema->topgrammar); if (schema->doc != NULL) xmlFreeDoc(schema->doc); if (schema->documents != NULL) xmlRelaxNGFreeDocumentList(schema->documents); if (schema->includes != NULL) xmlRelaxNGFreeIncludeList(schema->includes); if (schema->defTab != NULL) { int i; for (i = 0; i < schema->defNr; i++) xmlRelaxNGFreeDefine(schema->defTab[i]); xmlFree(schema->defTab); } xmlFree(schema); } /** * xmlRelaxNGNewGrammar: * @ctxt: a Relax-NG validation context (optional) * * Allocate a new RelaxNG grammar. * * Returns the newly allocated structure or NULL in case or error */ static xmlRelaxNGGrammarPtr xmlRelaxNGNewGrammar(xmlRelaxNGParserCtxtPtr ctxt) { xmlRelaxNGGrammarPtr ret; ret = (xmlRelaxNGGrammarPtr) xmlMalloc(sizeof(xmlRelaxNGGrammar)); if (ret == NULL) { xmlRngPErrMemory(ctxt, NULL); return (NULL); } memset(ret, 0, sizeof(xmlRelaxNGGrammar)); return (ret); } /** * xmlRelaxNGFreeGrammar: * @grammar: a grammar structure * * Deallocate a RelaxNG grammar structure. */ static void xmlRelaxNGFreeGrammar(xmlRelaxNGGrammarPtr grammar) { if (grammar == NULL) return; if (grammar->children != NULL) { xmlRelaxNGFreeGrammar(grammar->children); } if (grammar->next != NULL) { xmlRelaxNGFreeGrammar(grammar->next); } if (grammar->refs != NULL) { xmlHashFree(grammar->refs, NULL); } if (grammar->defs != NULL) { xmlHashFree(grammar->defs, NULL); } xmlFree(grammar); } /** * xmlRelaxNGNewDefine: * @ctxt: a Relax-NG validation context * @node: the node in the input document. * * Allocate a new RelaxNG define. * * Returns the newly allocated structure or NULL in case or error */ static xmlRelaxNGDefinePtr xmlRelaxNGNewDefine(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node) { xmlRelaxNGDefinePtr ret; if (ctxt->defMax == 0) { ctxt->defMax = 16; ctxt->defNr = 0; ctxt->defTab = (xmlRelaxNGDefinePtr *) xmlMalloc(ctxt->defMax * sizeof(xmlRelaxNGDefinePtr)); if (ctxt->defTab == NULL) { xmlRngPErrMemory(ctxt, "allocating define\n"); return (NULL); } } else if (ctxt->defMax <= ctxt->defNr) { xmlRelaxNGDefinePtr *tmp; ctxt->defMax *= 2; tmp = (xmlRelaxNGDefinePtr *) xmlRealloc(ctxt->defTab, ctxt->defMax * sizeof (xmlRelaxNGDefinePtr)); if (tmp == NULL) { xmlRngPErrMemory(ctxt, "allocating define\n"); return (NULL); } ctxt->defTab = tmp; } ret = (xmlRelaxNGDefinePtr) xmlMalloc(sizeof(xmlRelaxNGDefine)); if (ret == NULL) { xmlRngPErrMemory(ctxt, "allocating define\n"); return (NULL); } memset(ret, 0, sizeof(xmlRelaxNGDefine)); ctxt->defTab[ctxt->defNr++] = ret; ret->node = node; ret->depth = -1; return (ret); } /** * xmlRelaxNGFreePartition: * @partitions: a partition set structure * * Deallocate RelaxNG partition set structures. */ static void xmlRelaxNGFreePartition(xmlRelaxNGPartitionPtr partitions) { xmlRelaxNGInterleaveGroupPtr group; int j; if (partitions != NULL) { if (partitions->groups != NULL) { for (j = 0; j < partitions->nbgroups; j++) { group = partitions->groups[j]; if (group != NULL) { if (group->defs != NULL) xmlFree(group->defs); if (group->attrs != NULL) xmlFree(group->attrs); xmlFree(group); } } xmlFree(partitions->groups); } if (partitions->triage != NULL) { xmlHashFree(partitions->triage, NULL); } xmlFree(partitions); } } /** * xmlRelaxNGFreeDefine: * @define: a define structure * * Deallocate a RelaxNG define structure. */ static void xmlRelaxNGFreeDefine(xmlRelaxNGDefinePtr define) { if (define == NULL) return; if ((define->type == XML_RELAXNG_VALUE) && (define->attrs != NULL)) { xmlRelaxNGTypeLibraryPtr lib; lib = (xmlRelaxNGTypeLibraryPtr) define->data; if ((lib != NULL) && (lib->freef != NULL)) lib->freef(lib->data, (void *) define->attrs); } if ((define->data != NULL) && (define->type == XML_RELAXNG_INTERLEAVE)) xmlRelaxNGFreePartition((xmlRelaxNGPartitionPtr) define->data); if ((define->data != NULL) && (define->type == XML_RELAXNG_CHOICE)) xmlHashFree((xmlHashTablePtr) define->data, NULL); if (define->name != NULL) xmlFree(define->name); if (define->ns != NULL) xmlFree(define->ns); if (define->value != NULL) xmlFree(define->value); if (define->contModel != NULL) xmlRegFreeRegexp(define->contModel); xmlFree(define); } /** * xmlRelaxNGNewStates: * @ctxt: a Relax-NG validation context * @size: the default size for the container * * Allocate a new RelaxNG validation state container * * Returns the newly allocated structure or NULL in case or error */ static xmlRelaxNGStatesPtr xmlRelaxNGNewStates(xmlRelaxNGValidCtxtPtr ctxt, int size) { xmlRelaxNGStatesPtr ret; if ((ctxt != NULL) && (ctxt->freeState != NULL) && (ctxt->freeStatesNr > 0)) { ctxt->freeStatesNr--; ret = ctxt->freeStates[ctxt->freeStatesNr]; ret->nbState = 0; return (ret); } if (size < 16) size = 16; ret = (xmlRelaxNGStatesPtr) xmlMalloc(sizeof(xmlRelaxNGStates) + (size - 1) * sizeof(xmlRelaxNGValidStatePtr)); if (ret == NULL) { xmlRngVErrMemory(ctxt, "allocating states\n"); return (NULL); } ret->nbState = 0; ret->maxState = size; ret->tabState = (xmlRelaxNGValidStatePtr *) xmlMalloc((size) * sizeof (xmlRelaxNGValidStatePtr)); if (ret->tabState == NULL) { xmlRngVErrMemory(ctxt, "allocating states\n"); xmlFree(ret); return (NULL); } return (ret); } /** * xmlRelaxNGAddStateUniq: * @ctxt: a Relax-NG validation context * @states: the states container * @state: the validation state * * Add a RelaxNG validation state to the container without checking * for unicity. * * Return 1 in case of success and 0 if this is a duplicate and -1 on error */ static int xmlRelaxNGAddStatesUniq(xmlRelaxNGValidCtxtPtr ctxt, xmlRelaxNGStatesPtr states, xmlRelaxNGValidStatePtr state) { if (state == NULL) { return (-1); } if (states->nbState >= states->maxState) { xmlRelaxNGValidStatePtr *tmp; int size; size = states->maxState * 2; tmp = (xmlRelaxNGValidStatePtr *) xmlRealloc(states->tabState, (size) * sizeof (xmlRelaxNGValidStatePtr)); if (tmp == NULL) { xmlRngVErrMemory(ctxt, "adding states\n"); return (-1); } states->tabState = tmp; states->maxState = size; } states->tabState[states->nbState++] = state; return (1); } /** * xmlRelaxNGAddState: * @ctxt: a Relax-NG validation context * @states: the states container * @state: the validation state * * Add a RelaxNG validation state to the container * * Return 1 in case of success and 0 if this is a duplicate and -1 on error */ static int xmlRelaxNGAddStates(xmlRelaxNGValidCtxtPtr ctxt, xmlRelaxNGStatesPtr states, xmlRelaxNGValidStatePtr state) { int i; if (state == NULL) { return (-1); } if (states->nbState >= states->maxState) { xmlRelaxNGValidStatePtr *tmp; int size; size = states->maxState * 2; tmp = (xmlRelaxNGValidStatePtr *) xmlRealloc(states->tabState, (size) * sizeof (xmlRelaxNGValidStatePtr)); if (tmp == NULL) { xmlRngVErrMemory(ctxt, "adding states\n"); return (-1); } states->tabState = tmp; states->maxState = size; } for (i = 0; i < states->nbState; i++) { if (xmlRelaxNGEqualValidState(ctxt, state, states->tabState[i])) { xmlRelaxNGFreeValidState(ctxt, state); return (0); } } states->tabState[states->nbState++] = state; return (1); } /** * xmlRelaxNGFreeStates: * @ctxt: a Relax-NG validation context * @states: teh container * * Free a RelaxNG validation state container */ static void xmlRelaxNGFreeStates(xmlRelaxNGValidCtxtPtr ctxt, xmlRelaxNGStatesPtr states) { if (states == NULL) return; if ((ctxt != NULL) && (ctxt->freeStates == NULL)) { ctxt->freeStatesMax = 40; ctxt->freeStatesNr = 0; ctxt->freeStates = (xmlRelaxNGStatesPtr *) xmlMalloc(ctxt->freeStatesMax * sizeof(xmlRelaxNGStatesPtr)); if (ctxt->freeStates == NULL) { xmlRngVErrMemory(ctxt, "storing states\n"); } } else if ((ctxt != NULL) && (ctxt->freeStatesNr >= ctxt->freeStatesMax)) { xmlRelaxNGStatesPtr *tmp; tmp = (xmlRelaxNGStatesPtr *) xmlRealloc(ctxt->freeStates, 2 * ctxt->freeStatesMax * sizeof (xmlRelaxNGStatesPtr)); if (tmp == NULL) { xmlRngVErrMemory(ctxt, "storing states\n"); xmlFree(states->tabState); xmlFree(states); return; } ctxt->freeStates = tmp; ctxt->freeStatesMax *= 2; } if ((ctxt == NULL) || (ctxt->freeStates == NULL)) { xmlFree(states->tabState); xmlFree(states); } else { ctxt->freeStates[ctxt->freeStatesNr++] = states; } } /** * xmlRelaxNGNewValidState: * @ctxt: a Relax-NG validation context * @node: the current node or NULL for the document * * Allocate a new RelaxNG validation state * * Returns the newly allocated structure or NULL in case or error */ static xmlRelaxNGValidStatePtr xmlRelaxNGNewValidState(xmlRelaxNGValidCtxtPtr ctxt, xmlNodePtr node) { xmlRelaxNGValidStatePtr ret; xmlAttrPtr attr; xmlAttrPtr attrs[MAX_ATTR]; int nbAttrs = 0; xmlNodePtr root = NULL; if (node == NULL) { root = xmlDocGetRootElement(ctxt->doc); if (root == NULL) return (NULL); } else { attr = node->properties; while (attr != NULL) { if (nbAttrs < MAX_ATTR) attrs[nbAttrs++] = attr; else nbAttrs++; attr = attr->next; } } if ((ctxt->freeState != NULL) && (ctxt->freeState->nbState > 0)) { ctxt->freeState->nbState--; ret = ctxt->freeState->tabState[ctxt->freeState->nbState]; } else { ret = (xmlRelaxNGValidStatePtr) xmlMalloc(sizeof(xmlRelaxNGValidState)); if (ret == NULL) { xmlRngVErrMemory(ctxt, "allocating states\n"); return (NULL); } memset(ret, 0, sizeof(xmlRelaxNGValidState)); } ret->value = NULL; ret->endvalue = NULL; if (node == NULL) { ret->node = (xmlNodePtr) ctxt->doc; ret->seq = root; } else { ret->node = node; ret->seq = node->children; } ret->nbAttrs = 0; if (nbAttrs > 0) { if (ret->attrs == NULL) { if (nbAttrs < 4) ret->maxAttrs = 4; else ret->maxAttrs = nbAttrs; ret->attrs = (xmlAttrPtr *) xmlMalloc(ret->maxAttrs * sizeof(xmlAttrPtr)); if (ret->attrs == NULL) { xmlRngVErrMemory(ctxt, "allocating states\n"); return (ret); } } else if (ret->maxAttrs < nbAttrs) { xmlAttrPtr *tmp; tmp = (xmlAttrPtr *) xmlRealloc(ret->attrs, nbAttrs * sizeof(xmlAttrPtr)); if (tmp == NULL) { xmlRngVErrMemory(ctxt, "allocating states\n"); return (ret); } ret->attrs = tmp; ret->maxAttrs = nbAttrs; } ret->nbAttrs = nbAttrs; if (nbAttrs < MAX_ATTR) { memcpy(ret->attrs, attrs, sizeof(xmlAttrPtr) * nbAttrs); } else { attr = node->properties; nbAttrs = 0; while (attr != NULL) { ret->attrs[nbAttrs++] = attr; attr = attr->next; } } } ret->nbAttrLeft = ret->nbAttrs; return (ret); } /** * xmlRelaxNGCopyValidState: * @ctxt: a Relax-NG validation context * @state: a validation state * * Copy the validation state * * Returns the newly allocated structure or NULL in case or error */ static xmlRelaxNGValidStatePtr xmlRelaxNGCopyValidState(xmlRelaxNGValidCtxtPtr ctxt, xmlRelaxNGValidStatePtr state) { xmlRelaxNGValidStatePtr ret; unsigned int maxAttrs; xmlAttrPtr *attrs; if (state == NULL) return (NULL); if ((ctxt->freeState != NULL) && (ctxt->freeState->nbState > 0)) { ctxt->freeState->nbState--; ret = ctxt->freeState->tabState[ctxt->freeState->nbState]; } else { ret = (xmlRelaxNGValidStatePtr) xmlMalloc(sizeof(xmlRelaxNGValidState)); if (ret == NULL) { xmlRngVErrMemory(ctxt, "allocating states\n"); return (NULL); } memset(ret, 0, sizeof(xmlRelaxNGValidState)); } attrs = ret->attrs; maxAttrs = ret->maxAttrs; memcpy(ret, state, sizeof(xmlRelaxNGValidState)); ret->attrs = attrs; ret->maxAttrs = maxAttrs; if (state->nbAttrs > 0) { if (ret->attrs == NULL) { ret->maxAttrs = state->maxAttrs; ret->attrs = (xmlAttrPtr *) xmlMalloc(ret->maxAttrs * sizeof(xmlAttrPtr)); if (ret->attrs == NULL) { xmlRngVErrMemory(ctxt, "allocating states\n"); ret->nbAttrs = 0; return (ret); } } else if (ret->maxAttrs < state->nbAttrs) { xmlAttrPtr *tmp; tmp = (xmlAttrPtr *) xmlRealloc(ret->attrs, state->maxAttrs * sizeof(xmlAttrPtr)); if (tmp == NULL) { xmlRngVErrMemory(ctxt, "allocating states\n"); ret->nbAttrs = 0; return (ret); } ret->maxAttrs = state->maxAttrs; ret->attrs = tmp; } memcpy(ret->attrs, state->attrs, state->nbAttrs * sizeof(xmlAttrPtr)); } return (ret); } /** * xmlRelaxNGEqualValidState: * @ctxt: a Relax-NG validation context * @state1: a validation state * @state2: a validation state * * Compare the validation states for equality * * Returns 1 if equald, 0 otherwise */ static int xmlRelaxNGEqualValidState(xmlRelaxNGValidCtxtPtr ctxt ATTRIBUTE_UNUSED, xmlRelaxNGValidStatePtr state1, xmlRelaxNGValidStatePtr state2) { int i; if ((state1 == NULL) || (state2 == NULL)) return (0); if (state1 == state2) return (1); if (state1->node != state2->node) return (0); if (state1->seq != state2->seq) return (0); if (state1->nbAttrLeft != state2->nbAttrLeft) return (0); if (state1->nbAttrs != state2->nbAttrs) return (0); if (state1->endvalue != state2->endvalue) return (0); if ((state1->value != state2->value) && (!xmlStrEqual(state1->value, state2->value))) return (0); for (i = 0; i < state1->nbAttrs; i++) { if (state1->attrs[i] != state2->attrs[i]) return (0); } return (1); } /** * xmlRelaxNGFreeValidState: * @state: a validation state structure * * Deallocate a RelaxNG validation state structure. */ static void xmlRelaxNGFreeValidState(xmlRelaxNGValidCtxtPtr ctxt, xmlRelaxNGValidStatePtr state) { if (state == NULL) return; if ((ctxt != NULL) && (ctxt->freeState == NULL)) { ctxt->freeState = xmlRelaxNGNewStates(ctxt, 40); } if ((ctxt == NULL) || (ctxt->freeState == NULL)) { if (state->attrs != NULL) xmlFree(state->attrs); xmlFree(state); } else { xmlRelaxNGAddStatesUniq(ctxt, ctxt->freeState, state); } } /************************************************************************ * * * Semi internal functions * * * ************************************************************************/ /** * xmlRelaxParserSetFlag: * @ctxt: a RelaxNG parser context * @flags: a set of flags values * * Semi private function used to pass informations to a parser context * which are a combination of xmlRelaxNGParserFlag . * * Returns 0 if success and -1 in case of error */ int xmlRelaxParserSetFlag(xmlRelaxNGParserCtxtPtr ctxt, int flags) { if (ctxt == NULL) return(-1); if (flags & XML_RELAXNGP_FREE_DOC) { ctxt->crng |= XML_RELAXNGP_FREE_DOC; flags -= XML_RELAXNGP_FREE_DOC; } if (flags & XML_RELAXNGP_CRNG) { ctxt->crng |= XML_RELAXNGP_CRNG; flags -= XML_RELAXNGP_CRNG; } if (flags != 0) return(-1); return(0); } /************************************************************************ * * * Document functions * * * ************************************************************************/ static xmlDocPtr xmlRelaxNGCleanupDoc(xmlRelaxNGParserCtxtPtr ctxt, xmlDocPtr doc); /** * xmlRelaxNGIncludePush: * @ctxt: the parser context * @value: the element doc * * Pushes a new include on top of the include stack * * Returns 0 in case of error, the index in the stack otherwise */ static int xmlRelaxNGIncludePush(xmlRelaxNGParserCtxtPtr ctxt, xmlRelaxNGIncludePtr value) { if (ctxt->incTab == NULL) { ctxt->incMax = 4; ctxt->incNr = 0; ctxt->incTab = (xmlRelaxNGIncludePtr *) xmlMalloc(ctxt->incMax * sizeof(ctxt->incTab[0])); if (ctxt->incTab == NULL) { xmlRngPErrMemory(ctxt, "allocating include\n"); return (0); } } if (ctxt->incNr >= ctxt->incMax) { ctxt->incMax *= 2; ctxt->incTab = (xmlRelaxNGIncludePtr *) xmlRealloc(ctxt->incTab, ctxt->incMax * sizeof(ctxt->incTab[0])); if (ctxt->incTab == NULL) { xmlRngPErrMemory(ctxt, "allocating include\n"); return (0); } } ctxt->incTab[ctxt->incNr] = value; ctxt->inc = value; return (ctxt->incNr++); } /** * xmlRelaxNGIncludePop: * @ctxt: the parser context * * Pops the top include from the include stack * * Returns the include just removed */ static xmlRelaxNGIncludePtr xmlRelaxNGIncludePop(xmlRelaxNGParserCtxtPtr ctxt) { xmlRelaxNGIncludePtr ret; if (ctxt->incNr <= 0) return (NULL); ctxt->incNr--; if (ctxt->incNr > 0) ctxt->inc = ctxt->incTab[ctxt->incNr - 1]; else ctxt->inc = NULL; ret = ctxt->incTab[ctxt->incNr]; ctxt->incTab[ctxt->incNr] = NULL; return (ret); } /** * xmlRelaxNGRemoveRedefine: * @ctxt: the parser context * @URL: the normalized URL * @target: the included target * @name: the define name to eliminate * * Applies the elimination algorithm of 4.7 * * Returns 0 in case of error, 1 in case of success. */ static int xmlRelaxNGRemoveRedefine(xmlRelaxNGParserCtxtPtr ctxt, const xmlChar * URL ATTRIBUTE_UNUSED, xmlNodePtr target, const xmlChar * name) { int found = 0; xmlNodePtr tmp, tmp2; xmlChar *name2; #ifdef DEBUG_INCLUDE if (name == NULL) xmlGenericError(xmlGenericErrorContext, "Elimination of start from %s\n", URL); else xmlGenericError(xmlGenericErrorContext, "Elimination of define %s from %s\n", name, URL); #endif tmp = target; while (tmp != NULL) { tmp2 = tmp->next; if ((name == NULL) && (IS_RELAXNG(tmp, "start"))) { found = 1; xmlUnlinkNode(tmp); xmlFreeNode(tmp); } else if ((name != NULL) && (IS_RELAXNG(tmp, "define"))) { name2 = xmlGetProp(tmp, BAD_CAST "name"); xmlRelaxNGNormExtSpace(name2); if (name2 != NULL) { if (xmlStrEqual(name, name2)) { found = 1; xmlUnlinkNode(tmp); xmlFreeNode(tmp); } xmlFree(name2); } } else if (IS_RELAXNG(tmp, "include")) { xmlChar *href = NULL; xmlRelaxNGDocumentPtr inc = tmp->psvi; if ((inc != NULL) && (inc->doc != NULL) && (inc->doc->children != NULL)) { if (xmlStrEqual (inc->doc->children->name, BAD_CAST "grammar")) { #ifdef DEBUG_INCLUDE href = xmlGetProp(tmp, BAD_CAST "href"); #endif if (xmlRelaxNGRemoveRedefine(ctxt, href, inc->doc->children-> children, name) == 1) { found = 1; } #ifdef DEBUG_INCLUDE if (href != NULL) xmlFree(href); #endif } } } tmp = tmp2; } return (found); } /** * xmlRelaxNGLoadInclude: * @ctxt: the parser context * @URL: the normalized URL * @node: the include node. * @ns: the namespace passed from the context. * * First lookup if the document is already loaded into the parser context, * check against recursion. If not found the resource is loaded and * the content is preprocessed before being returned back to the caller. * * Returns the xmlRelaxNGIncludePtr or NULL in case of error */ static xmlRelaxNGIncludePtr xmlRelaxNGLoadInclude(xmlRelaxNGParserCtxtPtr ctxt, const xmlChar * URL, xmlNodePtr node, const xmlChar * ns) { xmlRelaxNGIncludePtr ret = NULL; xmlDocPtr doc; int i; xmlNodePtr root, cur; #ifdef DEBUG_INCLUDE xmlGenericError(xmlGenericErrorContext, "xmlRelaxNGLoadInclude(%s)\n", URL); #endif /* * check against recursion in the stack */ for (i = 0; i < ctxt->incNr; i++) { if (xmlStrEqual(ctxt->incTab[i]->href, URL)) { xmlRngPErr(ctxt, NULL, XML_RNGP_INCLUDE_RECURSE, "Detected an Include recursion for %s\n", URL, NULL); return (NULL); } } /* * load the document */ doc = xmlReadFile((const char *) URL,NULL,0); if (doc == NULL) { xmlRngPErr(ctxt, node, XML_RNGP_PARSE_ERROR, "xmlRelaxNG: could not load %s\n", URL, NULL); return (NULL); } #ifdef DEBUG_INCLUDE xmlGenericError(xmlGenericErrorContext, "Parsed %s Okay\n", URL); #endif /* * Allocate the document structures and register it first. */ ret = (xmlRelaxNGIncludePtr) xmlMalloc(sizeof(xmlRelaxNGInclude)); if (ret == NULL) { xmlRngPErrMemory(ctxt, "allocating include\n"); xmlFreeDoc(doc); return (NULL); } memset(ret, 0, sizeof(xmlRelaxNGInclude)); ret->doc = doc; ret->href = xmlStrdup(URL); ret->next = ctxt->includes; ctxt->includes = ret; /* * transmit the ns if needed */ if (ns != NULL) { root = xmlDocGetRootElement(doc); if (root != NULL) { if (xmlHasProp(root, BAD_CAST "ns") == NULL) { xmlSetProp(root, BAD_CAST "ns", ns); } } } /* * push it on the stack */ xmlRelaxNGIncludePush(ctxt, ret); /* * Some preprocessing of the document content, this include recursing * in the include stack. */ #ifdef DEBUG_INCLUDE xmlGenericError(xmlGenericErrorContext, "cleanup of %s\n", URL); #endif doc = xmlRelaxNGCleanupDoc(ctxt, doc); if (doc == NULL) { ctxt->inc = NULL; return (NULL); } /* * Pop up the include from the stack */ xmlRelaxNGIncludePop(ctxt); #ifdef DEBUG_INCLUDE xmlGenericError(xmlGenericErrorContext, "Checking of %s\n", URL); #endif /* * Check that the top element is a grammar */ root = xmlDocGetRootElement(doc); if (root == NULL) { xmlRngPErr(ctxt, node, XML_RNGP_EMPTY, "xmlRelaxNG: included document is empty %s\n", URL, NULL); return (NULL); } if (!IS_RELAXNG(root, "grammar")) { xmlRngPErr(ctxt, node, XML_RNGP_GRAMMAR_MISSING, "xmlRelaxNG: included document %s root is not a grammar\n", URL, NULL); return (NULL); } /* * Elimination of redefined rules in the include. */ cur = node->children; while (cur != NULL) { if (IS_RELAXNG(cur, "start")) { int found = 0; found = xmlRelaxNGRemoveRedefine(ctxt, URL, root->children, NULL); if (!found) { xmlRngPErr(ctxt, node, XML_RNGP_START_MISSING, "xmlRelaxNG: include %s has a start but not the included grammar\n", URL, NULL); } } else if (IS_RELAXNG(cur, "define")) { xmlChar *name; name = xmlGetProp(cur, BAD_CAST "name"); if (name == NULL) { xmlRngPErr(ctxt, node, XML_RNGP_NAME_MISSING, "xmlRelaxNG: include %s has define without name\n", URL, NULL); } else { int found; xmlRelaxNGNormExtSpace(name); found = xmlRelaxNGRemoveRedefine(ctxt, URL, root->children, name); if (!found) { xmlRngPErr(ctxt, node, XML_RNGP_DEFINE_MISSING, "xmlRelaxNG: include %s has a define %s but not the included grammar\n", URL, name); } xmlFree(name); } } cur = cur->next; } return (ret); } /** * xmlRelaxNGValidErrorPush: * @ctxt: the validation context * @err: the error code * @arg1: the first string argument * @arg2: the second string argument * @dup: arg need to be duplicated * * Pushes a new error on top of the error stack * * Returns 0 in case of error, the index in the stack otherwise */ static int xmlRelaxNGValidErrorPush(xmlRelaxNGValidCtxtPtr ctxt, xmlRelaxNGValidErr err, const xmlChar * arg1, const xmlChar * arg2, int dup) { xmlRelaxNGValidErrorPtr cur; #ifdef DEBUG_ERROR xmlGenericError(xmlGenericErrorContext, "Pushing error %d at %d on stack\n", err, ctxt->errNr); #endif if (ctxt->errTab == NULL) { ctxt->errMax = 8; ctxt->errNr = 0; ctxt->errTab = (xmlRelaxNGValidErrorPtr) xmlMalloc(ctxt->errMax * sizeof (xmlRelaxNGValidError)); if (ctxt->errTab == NULL) { xmlRngVErrMemory(ctxt, "pushing error\n"); return (0); } ctxt->err = NULL; } if (ctxt->errNr >= ctxt->errMax) { ctxt->errMax *= 2; ctxt->errTab = (xmlRelaxNGValidErrorPtr) xmlRealloc(ctxt->errTab, ctxt->errMax * sizeof (xmlRelaxNGValidError)); if (ctxt->errTab == NULL) { xmlRngVErrMemory(ctxt, "pushing error\n"); return (0); } ctxt->err = &ctxt->errTab[ctxt->errNr - 1]; } if ((ctxt->err != NULL) && (ctxt->state != NULL) && (ctxt->err->node == ctxt->state->node) && (ctxt->err->err == err)) return (ctxt->errNr); cur = &ctxt->errTab[ctxt->errNr]; cur->err = err; if (dup) { cur->arg1 = xmlStrdup(arg1); cur->arg2 = xmlStrdup(arg2); cur->flags = ERROR_IS_DUP; } else { cur->arg1 = arg1; cur->arg2 = arg2; cur->flags = 0; } if (ctxt->state != NULL) { cur->node = ctxt->state->node; cur->seq = ctxt->state->seq; } else { cur->node = NULL; cur->seq = NULL; } ctxt->err = cur; return (ctxt->errNr++); } /** * xmlRelaxNGValidErrorPop: * @ctxt: the validation context * * Pops the top error from the error stack */ static void xmlRelaxNGValidErrorPop(xmlRelaxNGValidCtxtPtr ctxt) { xmlRelaxNGValidErrorPtr cur; if (ctxt->errNr <= 0) { ctxt->err = NULL; return; } ctxt->errNr--; if (ctxt->errNr > 0) ctxt->err = &ctxt->errTab[ctxt->errNr - 1]; else ctxt->err = NULL; cur = &ctxt->errTab[ctxt->errNr]; if (cur->flags & ERROR_IS_DUP) { if (cur->arg1 != NULL) xmlFree((xmlChar *) cur->arg1); cur->arg1 = NULL; if (cur->arg2 != NULL) xmlFree((xmlChar *) cur->arg2); cur->arg2 = NULL; cur->flags = 0; } } /** * xmlRelaxNGDocumentPush: * @ctxt: the parser context * @value: the element doc * * Pushes a new doc on top of the doc stack * * Returns 0 in case of error, the index in the stack otherwise */ static int xmlRelaxNGDocumentPush(xmlRelaxNGParserCtxtPtr ctxt, xmlRelaxNGDocumentPtr value) { if (ctxt->docTab == NULL) { ctxt->docMax = 4; ctxt->docNr = 0; ctxt->docTab = (xmlRelaxNGDocumentPtr *) xmlMalloc(ctxt->docMax * sizeof(ctxt->docTab[0])); if (ctxt->docTab == NULL) { xmlRngPErrMemory(ctxt, "adding document\n"); return (0); } } if (ctxt->docNr >= ctxt->docMax) { ctxt->docMax *= 2; ctxt->docTab = (xmlRelaxNGDocumentPtr *) xmlRealloc(ctxt->docTab, ctxt->docMax * sizeof(ctxt->docTab[0])); if (ctxt->docTab == NULL) { xmlRngPErrMemory(ctxt, "adding document\n"); return (0); } } ctxt->docTab[ctxt->docNr] = value; ctxt->doc = value; return (ctxt->docNr++); } /** * xmlRelaxNGDocumentPop: * @ctxt: the parser context * * Pops the top doc from the doc stack * * Returns the doc just removed */ static xmlRelaxNGDocumentPtr xmlRelaxNGDocumentPop(xmlRelaxNGParserCtxtPtr ctxt) { xmlRelaxNGDocumentPtr ret; if (ctxt->docNr <= 0) return (NULL); ctxt->docNr--; if (ctxt->docNr > 0) ctxt->doc = ctxt->docTab[ctxt->docNr - 1]; else ctxt->doc = NULL; ret = ctxt->docTab[ctxt->docNr]; ctxt->docTab[ctxt->docNr] = NULL; return (ret); } /** * xmlRelaxNGLoadExternalRef: * @ctxt: the parser context * @URL: the normalized URL * @ns: the inherited ns if any * * First lookup if the document is already loaded into the parser context, * check against recursion. If not found the resource is loaded and * the content is preprocessed before being returned back to the caller. * * Returns the xmlRelaxNGDocumentPtr or NULL in case of error */ static xmlRelaxNGDocumentPtr xmlRelaxNGLoadExternalRef(xmlRelaxNGParserCtxtPtr ctxt, const xmlChar * URL, const xmlChar * ns) { xmlRelaxNGDocumentPtr ret = NULL; xmlDocPtr doc; xmlNodePtr root; int i; /* * check against recursion in the stack */ for (i = 0; i < ctxt->docNr; i++) { if (xmlStrEqual(ctxt->docTab[i]->href, URL)) { xmlRngPErr(ctxt, NULL, XML_RNGP_EXTERNALREF_RECURSE, "Detected an externalRef recursion for %s\n", URL, NULL); return (NULL); } } /* * load the document */ doc = xmlReadFile((const char *) URL,NULL,0); if (doc == NULL) { xmlRngPErr(ctxt, NULL, XML_RNGP_PARSE_ERROR, "xmlRelaxNG: could not load %s\n", URL, NULL); return (NULL); } /* * Allocate the document structures and register it first. */ ret = (xmlRelaxNGDocumentPtr) xmlMalloc(sizeof(xmlRelaxNGDocument)); if (ret == NULL) { xmlRngPErr(ctxt, (xmlNodePtr) doc, XML_ERR_NO_MEMORY, "xmlRelaxNG: allocate memory for doc %s\n", URL, NULL); xmlFreeDoc(doc); return (NULL); } memset(ret, 0, sizeof(xmlRelaxNGDocument)); ret->doc = doc; ret->href = xmlStrdup(URL); ret->next = ctxt->documents; ctxt->documents = ret; /* * transmit the ns if needed */ if (ns != NULL) { root = xmlDocGetRootElement(doc); if (root != NULL) { if (xmlHasProp(root, BAD_CAST "ns") == NULL) { xmlSetProp(root, BAD_CAST "ns", ns); } } } /* * push it on the stack and register it in the hash table */ xmlRelaxNGDocumentPush(ctxt, ret); /* * Some preprocessing of the document content */ doc = xmlRelaxNGCleanupDoc(ctxt, doc); if (doc == NULL) { ctxt->doc = NULL; return (NULL); } xmlRelaxNGDocumentPop(ctxt); return (ret); } /************************************************************************ * * * Error functions * * * ************************************************************************/ #define VALID_ERR(a) xmlRelaxNGAddValidError(ctxt, a, NULL, NULL, 0); #define VALID_ERR2(a, b) xmlRelaxNGAddValidError(ctxt, a, b, NULL, 0); #define VALID_ERR3(a, b, c) xmlRelaxNGAddValidError(ctxt, a, b, c, 0); #define VALID_ERR2P(a, b) xmlRelaxNGAddValidError(ctxt, a, b, NULL, 1); #define VALID_ERR3P(a, b, c) xmlRelaxNGAddValidError(ctxt, a, b, c, 1); static const char * xmlRelaxNGDefName(xmlRelaxNGDefinePtr def) { if (def == NULL) return ("none"); switch (def->type) { case XML_RELAXNG_EMPTY: return ("empty"); case XML_RELAXNG_NOT_ALLOWED: return ("notAllowed"); case XML_RELAXNG_EXCEPT: return ("except"); case XML_RELAXNG_TEXT: return ("text"); case XML_RELAXNG_ELEMENT: return ("element"); case XML_RELAXNG_DATATYPE: return ("datatype"); case XML_RELAXNG_VALUE: return ("value"); case XML_RELAXNG_LIST: return ("list"); case XML_RELAXNG_ATTRIBUTE: return ("attribute"); case XML_RELAXNG_DEF: return ("def"); case XML_RELAXNG_REF: return ("ref"); case XML_RELAXNG_EXTERNALREF: return ("externalRef"); case XML_RELAXNG_PARENTREF: return ("parentRef"); case XML_RELAXNG_OPTIONAL: return ("optional"); case XML_RELAXNG_ZEROORMORE: return ("zeroOrMore"); case XML_RELAXNG_ONEORMORE: return ("oneOrMore"); case XML_RELAXNG_CHOICE: return ("choice"); case XML_RELAXNG_GROUP: return ("group"); case XML_RELAXNG_INTERLEAVE: return ("interleave"); case XML_RELAXNG_START: return ("start"); case XML_RELAXNG_NOOP: return ("noop"); case XML_RELAXNG_PARAM: return ("param"); } return ("unknown"); } /** * xmlRelaxNGGetErrorString: * @err: the error code * @arg1: the first string argument * @arg2: the second string argument * * computes a formatted error string for the given error code and args * * Returns the error string, it must be deallocated by the caller */ static xmlChar * xmlRelaxNGGetErrorString(xmlRelaxNGValidErr err, const xmlChar * arg1, const xmlChar * arg2) { char msg[1000]; if (arg1 == NULL) arg1 = BAD_CAST ""; if (arg2 == NULL) arg2 = BAD_CAST ""; msg[0] = 0; switch (err) { case XML_RELAXNG_OK: return (NULL); case XML_RELAXNG_ERR_MEMORY: return (xmlCharStrdup("out of memory\n")); case XML_RELAXNG_ERR_TYPE: snprintf(msg, 1000, "failed to validate type %s\n", arg1); break; case XML_RELAXNG_ERR_TYPEVAL: snprintf(msg, 1000, "Type %s doesn't allow value '%s'\n", arg1, arg2); break; case XML_RELAXNG_ERR_DUPID: snprintf(msg, 1000, "ID %s redefined\n", arg1); break; case XML_RELAXNG_ERR_TYPECMP: snprintf(msg, 1000, "failed to compare type %s\n", arg1); break; case XML_RELAXNG_ERR_NOSTATE: return (xmlCharStrdup("Internal error: no state\n")); case XML_RELAXNG_ERR_NODEFINE: return (xmlCharStrdup("Internal error: no define\n")); case XML_RELAXNG_ERR_INTERNAL: snprintf(msg, 1000, "Internal error: %s\n", arg1); break; case XML_RELAXNG_ERR_LISTEXTRA: snprintf(msg, 1000, "Extra data in list: %s\n", arg1); break; case XML_RELAXNG_ERR_INTERNODATA: return (xmlCharStrdup ("Internal: interleave block has no data\n")); case XML_RELAXNG_ERR_INTERSEQ: return (xmlCharStrdup("Invalid sequence in interleave\n")); case XML_RELAXNG_ERR_INTEREXTRA: snprintf(msg, 1000, "Extra element %s in interleave\n", arg1); break; case XML_RELAXNG_ERR_ELEMNAME: snprintf(msg, 1000, "Expecting element %s, got %s\n", arg1, arg2); break; case XML_RELAXNG_ERR_ELEMNONS: snprintf(msg, 1000, "Expecting a namespace for element %s\n", arg1); break; case XML_RELAXNG_ERR_ELEMWRONGNS: snprintf(msg, 1000, "Element %s has wrong namespace: expecting %s\n", arg1, arg2); break; case XML_RELAXNG_ERR_ELEMWRONG: snprintf(msg, 1000, "Did not expect element %s there\n", arg1); break; case XML_RELAXNG_ERR_TEXTWRONG: snprintf(msg, 1000, "Did not expect text in element %s content\n", arg1); break; case XML_RELAXNG_ERR_ELEMEXTRANS: snprintf(msg, 1000, "Expecting no namespace for element %s\n", arg1); break; case XML_RELAXNG_ERR_ELEMNOTEMPTY: snprintf(msg, 1000, "Expecting element %s to be empty\n", arg1); break; case XML_RELAXNG_ERR_NOELEM: snprintf(msg, 1000, "Expecting an element %s, got nothing\n", arg1); break; case XML_RELAXNG_ERR_NOTELEM: return (xmlCharStrdup("Expecting an element got text\n")); case XML_RELAXNG_ERR_ATTRVALID: snprintf(msg, 1000, "Element %s failed to validate attributes\n", arg1); break; case XML_RELAXNG_ERR_CONTENTVALID: snprintf(msg, 1000, "Element %s failed to validate content\n", arg1); break; case XML_RELAXNG_ERR_EXTRACONTENT: snprintf(msg, 1000, "Element %s has extra content: %s\n", arg1, arg2); break; case XML_RELAXNG_ERR_INVALIDATTR: snprintf(msg, 1000, "Invalid attribute %s for element %s\n", arg1, arg2); break; case XML_RELAXNG_ERR_LACKDATA: snprintf(msg, 1000, "Datatype element %s contains no data\n", arg1); break; case XML_RELAXNG_ERR_DATAELEM: snprintf(msg, 1000, "Datatype element %s has child elements\n", arg1); break; case XML_RELAXNG_ERR_VALELEM: snprintf(msg, 1000, "Value element %s has child elements\n", arg1); break; case XML_RELAXNG_ERR_LISTELEM: snprintf(msg, 1000, "List element %s has child elements\n", arg1); break; case XML_RELAXNG_ERR_DATATYPE: snprintf(msg, 1000, "Error validating datatype %s\n", arg1); break; case XML_RELAXNG_ERR_VALUE: snprintf(msg, 1000, "Error validating value %s\n", arg1); break; case XML_RELAXNG_ERR_LIST: return (xmlCharStrdup("Error validating list\n")); case XML_RELAXNG_ERR_NOGRAMMAR: return (xmlCharStrdup("No top grammar defined\n")); case XML_RELAXNG_ERR_EXTRADATA: return (xmlCharStrdup("Extra data in the document\n")); default: return (xmlCharStrdup("Unknown error !\n")); } if (msg[0] == 0) { snprintf(msg, 1000, "Unknown error code %d\n", err); } msg[1000 - 1] = 0; return (xmlStrdup((xmlChar *) msg)); } /** * xmlRelaxNGShowValidError: * @ctxt: the validation context * @err: the error number * @node: the node * @child: the node child generating the problem. * @arg1: the first argument * @arg2: the second argument * * Show a validation error. */ static void xmlRelaxNGShowValidError(xmlRelaxNGValidCtxtPtr ctxt, xmlRelaxNGValidErr err, xmlNodePtr node, xmlNodePtr child, const xmlChar * arg1, const xmlChar * arg2) { xmlChar *msg; if (ctxt->flags & FLAGS_NOERROR) return; #ifdef DEBUG_ERROR xmlGenericError(xmlGenericErrorContext, "Show error %d\n", err); #endif msg = xmlRelaxNGGetErrorString(err, arg1, arg2); if (msg == NULL) return; if (ctxt->errNo == XML_RELAXNG_OK) ctxt->errNo = err; xmlRngVErr(ctxt, (child == NULL ? node : child), err, (const char *) msg, arg1, arg2); xmlFree(msg); } /** * xmlRelaxNGPopErrors: * @ctxt: the validation context * @level: the error level in the stack * * pop and discard all errors until the given level is reached */ static void xmlRelaxNGPopErrors(xmlRelaxNGValidCtxtPtr ctxt, int level) { int i; xmlRelaxNGValidErrorPtr err; #ifdef DEBUG_ERROR xmlGenericError(xmlGenericErrorContext, "Pop errors till level %d\n", level); #endif for (i = level; i < ctxt->errNr; i++) { err = &ctxt->errTab[i]; if (err->flags & ERROR_IS_DUP) { if (err->arg1 != NULL) xmlFree((xmlChar *) err->arg1); err->arg1 = NULL; if (err->arg2 != NULL) xmlFree((xmlChar *) err->arg2); err->arg2 = NULL; err->flags = 0; } } ctxt->errNr = level; if (ctxt->errNr <= 0) ctxt->err = NULL; } /** * xmlRelaxNGDumpValidError: * @ctxt: the validation context * * Show all validation error over a given index. */ static void xmlRelaxNGDumpValidError(xmlRelaxNGValidCtxtPtr ctxt) { int i, j, k; xmlRelaxNGValidErrorPtr err, dup; #ifdef DEBUG_ERROR xmlGenericError(xmlGenericErrorContext, "Dumping error stack %d errors\n", ctxt->errNr); #endif for (i = 0, k = 0; i < ctxt->errNr; i++) { err = &ctxt->errTab[i]; if (k < MAX_ERROR) { for (j = 0; j < i; j++) { dup = &ctxt->errTab[j]; if ((err->err == dup->err) && (err->node == dup->node) && (xmlStrEqual(err->arg1, dup->arg1)) && (xmlStrEqual(err->arg2, dup->arg2))) { goto skip; } } xmlRelaxNGShowValidError(ctxt, err->err, err->node, err->seq, err->arg1, err->arg2); k++; } skip: if (err->flags & ERROR_IS_DUP) { if (err->arg1 != NULL) xmlFree((xmlChar *) err->arg1); err->arg1 = NULL; if (err->arg2 != NULL) xmlFree((xmlChar *) err->arg2); err->arg2 = NULL; err->flags = 0; } } ctxt->errNr = 0; } /** * xmlRelaxNGAddValidError: * @ctxt: the validation context * @err: the error number * @arg1: the first argument * @arg2: the second argument * @dup: need to dup the args * * Register a validation error, either generating it if it's sure * or stacking it for later handling if unsure. */ static void xmlRelaxNGAddValidError(xmlRelaxNGValidCtxtPtr ctxt, xmlRelaxNGValidErr err, const xmlChar * arg1, const xmlChar * arg2, int dup) { if (ctxt == NULL) return; if (ctxt->flags & FLAGS_NOERROR) return; #ifdef DEBUG_ERROR xmlGenericError(xmlGenericErrorContext, "Adding error %d\n", err); #endif /* * generate the error directly */ if (((ctxt->flags & FLAGS_IGNORABLE) == 0) || (ctxt->flags & FLAGS_NEGATIVE)) { xmlNodePtr node, seq; /* * Flush first any stacked error which might be the * real cause of the problem. */ if (ctxt->errNr != 0) xmlRelaxNGDumpValidError(ctxt); if (ctxt->state != NULL) { node = ctxt->state->node; seq = ctxt->state->seq; } else { node = seq = NULL; } xmlRelaxNGShowValidError(ctxt, err, node, seq, arg1, arg2); } /* * Stack the error for later processing if needed */ else { xmlRelaxNGValidErrorPush(ctxt, err, arg1, arg2, dup); } } /************************************************************************ * * * Type library hooks * * * ************************************************************************/ static xmlChar *xmlRelaxNGNormalize(xmlRelaxNGValidCtxtPtr ctxt, const xmlChar * str); /** * xmlRelaxNGSchemaTypeHave: * @data: data needed for the library * @type: the type name * * Check if the given type is provided by * the W3C XMLSchema Datatype library. * * Returns 1 if yes, 0 if no and -1 in case of error. */ static int xmlRelaxNGSchemaTypeHave(void *data ATTRIBUTE_UNUSED, const xmlChar * type) { xmlSchemaTypePtr typ; if (type == NULL) return (-1); typ = xmlSchemaGetPredefinedType(type, BAD_CAST "http://www.w3.org/2001/XMLSchema"); if (typ == NULL) return (0); return (1); } /** * xmlRelaxNGSchemaTypeCheck: * @data: data needed for the library * @type: the type name * @value: the value to check * @node: the node * * Check if the given type and value are validated by * the W3C XMLSchema Datatype library. * * Returns 1 if yes, 0 if no and -1 in case of error. */ static int xmlRelaxNGSchemaTypeCheck(void *data ATTRIBUTE_UNUSED, const xmlChar * type, const xmlChar * value, void **result, xmlNodePtr node) { xmlSchemaTypePtr typ; int ret; if ((type == NULL) || (value == NULL)) return (-1); typ = xmlSchemaGetPredefinedType(type, BAD_CAST "http://www.w3.org/2001/XMLSchema"); if (typ == NULL) return (-1); ret = xmlSchemaValPredefTypeNode(typ, value, (xmlSchemaValPtr *) result, node); if (ret == 2) /* special ID error code */ return (2); if (ret == 0) return (1); if (ret > 0) return (0); return (-1); } /** * xmlRelaxNGSchemaFacetCheck: * @data: data needed for the library * @type: the type name * @facet: the facet name * @val: the facet value * @strval: the string value * @value: the value to check * * Function provided by a type library to check a value facet * * Returns 1 if yes, 0 if no and -1 in case of error. */ static int xmlRelaxNGSchemaFacetCheck(void *data ATTRIBUTE_UNUSED, const xmlChar * type, const xmlChar * facetname, const xmlChar * val, const xmlChar * strval, void *value) { xmlSchemaFacetPtr facet; xmlSchemaTypePtr typ; int ret; if ((type == NULL) || (strval == NULL)) return (-1); typ = xmlSchemaGetPredefinedType(type, BAD_CAST "http://www.w3.org/2001/XMLSchema"); if (typ == NULL) return (-1); facet = xmlSchemaNewFacet(); if (facet == NULL) return (-1); if (xmlStrEqual(facetname, BAD_CAST "minInclusive")) { facet->type = XML_SCHEMA_FACET_MININCLUSIVE; } else if (xmlStrEqual(facetname, BAD_CAST "minExclusive")) { facet->type = XML_SCHEMA_FACET_MINEXCLUSIVE; } else if (xmlStrEqual(facetname, BAD_CAST "maxInclusive")) { facet->type = XML_SCHEMA_FACET_MAXINCLUSIVE; } else if (xmlStrEqual(facetname, BAD_CAST "maxExclusive")) { facet->type = XML_SCHEMA_FACET_MAXEXCLUSIVE; } else if (xmlStrEqual(facetname, BAD_CAST "totalDigits")) { facet->type = XML_SCHEMA_FACET_TOTALDIGITS; } else if (xmlStrEqual(facetname, BAD_CAST "fractionDigits")) { facet->type = XML_SCHEMA_FACET_FRACTIONDIGITS; } else if (xmlStrEqual(facetname, BAD_CAST "pattern")) { facet->type = XML_SCHEMA_FACET_PATTERN; } else if (xmlStrEqual(facetname, BAD_CAST "enumeration")) { facet->type = XML_SCHEMA_FACET_ENUMERATION; } else if (xmlStrEqual(facetname, BAD_CAST "whiteSpace")) { facet->type = XML_SCHEMA_FACET_WHITESPACE; } else if (xmlStrEqual(facetname, BAD_CAST "length")) { facet->type = XML_SCHEMA_FACET_LENGTH; } else if (xmlStrEqual(facetname, BAD_CAST "maxLength")) { facet->type = XML_SCHEMA_FACET_MAXLENGTH; } else if (xmlStrEqual(facetname, BAD_CAST "minLength")) { facet->type = XML_SCHEMA_FACET_MINLENGTH; } else { xmlSchemaFreeFacet(facet); return (-1); } facet->value = val; ret = xmlSchemaCheckFacet(facet, typ, NULL, type); if (ret != 0) { xmlSchemaFreeFacet(facet); return (-1); } ret = xmlSchemaValidateFacet(typ, facet, strval, value); xmlSchemaFreeFacet(facet); if (ret != 0) return (-1); return (0); } /** * xmlRelaxNGSchemaFreeValue: * @data: data needed for the library * @value: the value to free * * Function provided by a type library to free a Schemas value * * Returns 1 if yes, 0 if no and -1 in case of error. */ static void xmlRelaxNGSchemaFreeValue(void *data ATTRIBUTE_UNUSED, void *value) { xmlSchemaFreeValue(value); } /** * xmlRelaxNGSchemaTypeCompare: * @data: data needed for the library * @type: the type name * @value1: the first value * @value2: the second value * * Compare two values for equality accordingly a type from the W3C XMLSchema * Datatype library. * * Returns 1 if equal, 0 if no and -1 in case of error. */ static int xmlRelaxNGSchemaTypeCompare(void *data ATTRIBUTE_UNUSED, const xmlChar * type, const xmlChar * value1, xmlNodePtr ctxt1, void *comp1, const xmlChar * value2, xmlNodePtr ctxt2) { int ret; xmlSchemaTypePtr typ; xmlSchemaValPtr res1 = NULL, res2 = NULL; if ((type == NULL) || (value1 == NULL) || (value2 == NULL)) return (-1); typ = xmlSchemaGetPredefinedType(type, BAD_CAST "http://www.w3.org/2001/XMLSchema"); if (typ == NULL) return (-1); if (comp1 == NULL) { ret = xmlSchemaValPredefTypeNode(typ, value1, &res1, ctxt1); if (ret != 0) return (-1); if (res1 == NULL) return (-1); } else { res1 = (xmlSchemaValPtr) comp1; } ret = xmlSchemaValPredefTypeNode(typ, value2, &res2, ctxt2); if (ret != 0) { if ((comp1 == NULL) && (res1 != NULL)) xmlSchemaFreeValue(res1); return (-1); } if (res1 == NULL) { return (-1); } ret = xmlSchemaCompareValues(res1, res2); if (res1 != (xmlSchemaValPtr) comp1) xmlSchemaFreeValue(res1); xmlSchemaFreeValue(res2); if (ret == -2) return (-1); if (ret == 0) return (1); return (0); } /** * xmlRelaxNGDefaultTypeHave: * @data: data needed for the library * @type: the type name * * Check if the given type is provided by * the default datatype library. * * Returns 1 if yes, 0 if no and -1 in case of error. */ static int xmlRelaxNGDefaultTypeHave(void *data ATTRIBUTE_UNUSED, const xmlChar * type) { if (type == NULL) return (-1); if (xmlStrEqual(type, BAD_CAST "string")) return (1); if (xmlStrEqual(type, BAD_CAST "token")) return (1); return (0); } /** * xmlRelaxNGDefaultTypeCheck: * @data: data needed for the library * @type: the type name * @value: the value to check * @node: the node * * Check if the given type and value are validated by * the default datatype library. * * Returns 1 if yes, 0 if no and -1 in case of error. */ static int xmlRelaxNGDefaultTypeCheck(void *data ATTRIBUTE_UNUSED, const xmlChar * type ATTRIBUTE_UNUSED, const xmlChar * value ATTRIBUTE_UNUSED, void **result ATTRIBUTE_UNUSED, xmlNodePtr node ATTRIBUTE_UNUSED) { if (value == NULL) return (-1); if (xmlStrEqual(type, BAD_CAST "string")) return (1); if (xmlStrEqual(type, BAD_CAST "token")) { return (1); } return (0); } /** * xmlRelaxNGDefaultTypeCompare: * @data: data needed for the library * @type: the type name * @value1: the first value * @value2: the second value * * Compare two values accordingly a type from the default * datatype library. * * Returns 1 if yes, 0 if no and -1 in case of error. */ static int xmlRelaxNGDefaultTypeCompare(void *data ATTRIBUTE_UNUSED, const xmlChar * type, const xmlChar * value1, xmlNodePtr ctxt1 ATTRIBUTE_UNUSED, void *comp1 ATTRIBUTE_UNUSED, const xmlChar * value2, xmlNodePtr ctxt2 ATTRIBUTE_UNUSED) { int ret = -1; if (xmlStrEqual(type, BAD_CAST "string")) { ret = xmlStrEqual(value1, value2); } else if (xmlStrEqual(type, BAD_CAST "token")) { if (!xmlStrEqual(value1, value2)) { xmlChar *nval, *nvalue; /* * TODO: trivial optimizations are possible by * computing at compile-time */ nval = xmlRelaxNGNormalize(NULL, value1); nvalue = xmlRelaxNGNormalize(NULL, value2); if ((nval == NULL) || (nvalue == NULL)) ret = -1; else if (xmlStrEqual(nval, nvalue)) ret = 1; else ret = 0; if (nval != NULL) xmlFree(nval); if (nvalue != NULL) xmlFree(nvalue); } else ret = 1; } return (ret); } static int xmlRelaxNGTypeInitialized = 0; static xmlHashTablePtr xmlRelaxNGRegisteredTypes = NULL; /** * xmlRelaxNGFreeTypeLibrary: * @lib: the type library structure * @namespace: the URI bound to the library * * Free the structure associated to the type library */ static void xmlRelaxNGFreeTypeLibrary(xmlRelaxNGTypeLibraryPtr lib, const xmlChar * namespace ATTRIBUTE_UNUSED) { if (lib == NULL) return; if (lib->namespace != NULL) xmlFree((xmlChar *) lib->namespace); xmlFree(lib); } /** * xmlRelaxNGRegisterTypeLibrary: * @namespace: the URI bound to the library * @data: data associated to the library * @have: the provide function * @check: the checking function * @comp: the comparison function * * Register a new type library * * Returns 0 in case of success and -1 in case of error. */ static int xmlRelaxNGRegisterTypeLibrary(const xmlChar * namespace, void *data, xmlRelaxNGTypeHave have, xmlRelaxNGTypeCheck check, xmlRelaxNGTypeCompare comp, xmlRelaxNGFacetCheck facet, xmlRelaxNGTypeFree freef) { xmlRelaxNGTypeLibraryPtr lib; int ret; if ((xmlRelaxNGRegisteredTypes == NULL) || (namespace == NULL) || (check == NULL) || (comp == NULL)) return (-1); if (xmlHashLookup(xmlRelaxNGRegisteredTypes, namespace) != NULL) { xmlGenericError(xmlGenericErrorContext, "Relax-NG types library '%s' already registered\n", namespace); return (-1); } lib = (xmlRelaxNGTypeLibraryPtr) xmlMalloc(sizeof(xmlRelaxNGTypeLibrary)); if (lib == NULL) { xmlRngVErrMemory(NULL, "adding types library\n"); return (-1); } memset(lib, 0, sizeof(xmlRelaxNGTypeLibrary)); lib->namespace = xmlStrdup(namespace); lib->data = data; lib->have = have; lib->comp = comp; lib->check = check; lib->facet = facet; lib->freef = freef; ret = xmlHashAddEntry(xmlRelaxNGRegisteredTypes, namespace, lib); if (ret < 0) { xmlGenericError(xmlGenericErrorContext, "Relax-NG types library failed to register '%s'\n", namespace); xmlRelaxNGFreeTypeLibrary(lib, namespace); return (-1); } return (0); } /** * xmlRelaxNGInitTypes: * * Initilize the default type libraries. * * Returns 0 in case of success and -1 in case of error. */ int xmlRelaxNGInitTypes(void) { if (xmlRelaxNGTypeInitialized != 0) return (0); xmlRelaxNGRegisteredTypes = xmlHashCreate(10); if (xmlRelaxNGRegisteredTypes == NULL) { xmlGenericError(xmlGenericErrorContext, "Failed to allocate sh table for Relax-NG types\n"); return (-1); } xmlRelaxNGRegisterTypeLibrary(BAD_CAST "http://www.w3.org/2001/XMLSchema-datatypes", NULL, xmlRelaxNGSchemaTypeHave, xmlRelaxNGSchemaTypeCheck, xmlRelaxNGSchemaTypeCompare, xmlRelaxNGSchemaFacetCheck, xmlRelaxNGSchemaFreeValue); xmlRelaxNGRegisterTypeLibrary(xmlRelaxNGNs, NULL, xmlRelaxNGDefaultTypeHave, xmlRelaxNGDefaultTypeCheck, xmlRelaxNGDefaultTypeCompare, NULL, NULL); xmlRelaxNGTypeInitialized = 1; return (0); } /** * xmlRelaxNGCleanupTypes: * * Cleanup the default Schemas type library associated to RelaxNG */ void xmlRelaxNGCleanupTypes(void) { xmlSchemaCleanupTypes(); if (xmlRelaxNGTypeInitialized == 0) return; xmlHashFree(xmlRelaxNGRegisteredTypes, (xmlHashDeallocator) xmlRelaxNGFreeTypeLibrary); xmlRelaxNGTypeInitialized = 0; } /************************************************************************ * * * Compiling element content into regexp * * * * Sometime the element content can be compiled into a pure regexp, * * This allows a faster execution and streamability at that level * * * ************************************************************************/ static int xmlRelaxNGTryCompile(xmlRelaxNGParserCtxtPtr ctxt, xmlRelaxNGDefinePtr def); /** * xmlRelaxNGIsCompileable: * @define: the definition to check * * Check if a definition is nullable. * * Returns 1 if yes, 0 if no and -1 in case of error */ static int xmlRelaxNGIsCompileable(xmlRelaxNGDefinePtr def) { int ret = -1; if (def == NULL) { return (-1); } if ((def->type != XML_RELAXNG_ELEMENT) && (def->dflags & IS_COMPILABLE)) return (1); if ((def->type != XML_RELAXNG_ELEMENT) && (def->dflags & IS_NOT_COMPILABLE)) return (0); switch (def->type) { case XML_RELAXNG_NOOP: ret = xmlRelaxNGIsCompileable(def->content); break; case XML_RELAXNG_TEXT: case XML_RELAXNG_EMPTY: ret = 1; break; case XML_RELAXNG_ELEMENT: /* * Check if the element content is compileable */ if (((def->dflags & IS_NOT_COMPILABLE) == 0) && ((def->dflags & IS_COMPILABLE) == 0)) { xmlRelaxNGDefinePtr list; list = def->content; while (list != NULL) { ret = xmlRelaxNGIsCompileable(list); if (ret != 1) break; list = list->next; } /* * Because the routine is recursive, we must guard against * discovering both COMPILABLE and NOT_COMPILABLE */ if (ret == 0) { def->dflags &= ~IS_COMPILABLE; def->dflags |= IS_NOT_COMPILABLE; } if ((ret == 1) && !(def->dflags &= IS_NOT_COMPILABLE)) def->dflags |= IS_COMPILABLE; #ifdef DEBUG_COMPILE if (ret == 1) { xmlGenericError(xmlGenericErrorContext, "element content for %s is compilable\n", def->name); } else if (ret == 0) { xmlGenericError(xmlGenericErrorContext, "element content for %s is not compilable\n", def->name); } else { xmlGenericError(xmlGenericErrorContext, "Problem in RelaxNGIsCompileable for element %s\n", def->name); } #endif } /* * All elements return a compileable status unless they * are generic like anyName */ if ((def->nameClass != NULL) || (def->name == NULL)) ret = 0; else ret = 1; return (ret); case XML_RELAXNG_REF: case XML_RELAXNG_EXTERNALREF: case XML_RELAXNG_PARENTREF: if (def->depth == -20) { return (1); } else { xmlRelaxNGDefinePtr list; def->depth = -20; list = def->content; while (list != NULL) { ret = xmlRelaxNGIsCompileable(list); if (ret != 1) break; list = list->next; } } break; case XML_RELAXNG_START: case XML_RELAXNG_OPTIONAL: case XML_RELAXNG_ZEROORMORE: case XML_RELAXNG_ONEORMORE: case XML_RELAXNG_CHOICE: case XML_RELAXNG_GROUP: case XML_RELAXNG_DEF:{ xmlRelaxNGDefinePtr list; list = def->content; while (list != NULL) { ret = xmlRelaxNGIsCompileable(list); if (ret != 1) break; list = list->next; } break; } case XML_RELAXNG_EXCEPT: case XML_RELAXNG_ATTRIBUTE: case XML_RELAXNG_INTERLEAVE: case XML_RELAXNG_DATATYPE: case XML_RELAXNG_LIST: case XML_RELAXNG_PARAM: case XML_RELAXNG_VALUE: case XML_RELAXNG_NOT_ALLOWED: ret = 0; break; } if (ret == 0) def->dflags |= IS_NOT_COMPILABLE; if (ret == 1) def->dflags |= IS_COMPILABLE; #ifdef DEBUG_COMPILE if (ret == 1) { xmlGenericError(xmlGenericErrorContext, "RelaxNGIsCompileable %s : true\n", xmlRelaxNGDefName(def)); } else if (ret == 0) { xmlGenericError(xmlGenericErrorContext, "RelaxNGIsCompileable %s : false\n", xmlRelaxNGDefName(def)); } else { xmlGenericError(xmlGenericErrorContext, "Problem in RelaxNGIsCompileable %s\n", xmlRelaxNGDefName(def)); } #endif return (ret); } /** * xmlRelaxNGCompile: * ctxt: the RelaxNG parser context * @define: the definition tree to compile * * Compile the set of definitions, it works recursively, till the * element boundaries, where it tries to compile the content if possible * * Returns 0 if success and -1 in case of error */ static int xmlRelaxNGCompile(xmlRelaxNGParserCtxtPtr ctxt, xmlRelaxNGDefinePtr def) { int ret = 0; xmlRelaxNGDefinePtr list; if ((ctxt == NULL) || (def == NULL)) return (-1); switch (def->type) { case XML_RELAXNG_START: if ((xmlRelaxNGIsCompileable(def) == 1) && (def->depth != -25)) { xmlAutomataPtr oldam = ctxt->am; xmlAutomataStatePtr oldstate = ctxt->state; def->depth = -25; list = def->content; ctxt->am = xmlNewAutomata(); if (ctxt->am == NULL) return (-1); ctxt->state = xmlAutomataGetInitState(ctxt->am); while (list != NULL) { xmlRelaxNGCompile(ctxt, list); list = list->next; } xmlAutomataSetFinalState(ctxt->am, ctxt->state); def->contModel = xmlAutomataCompile(ctxt->am); xmlRegexpIsDeterminist(def->contModel); xmlFreeAutomata(ctxt->am); ctxt->state = oldstate; ctxt->am = oldam; } break; case XML_RELAXNG_ELEMENT: if ((ctxt->am != NULL) && (def->name != NULL)) { ctxt->state = xmlAutomataNewTransition2(ctxt->am, ctxt->state, NULL, def->name, def->ns, def); } if ((def->dflags & IS_COMPILABLE) && (def->depth != -25)) { xmlAutomataPtr oldam = ctxt->am; xmlAutomataStatePtr oldstate = ctxt->state; def->depth = -25; list = def->content; ctxt->am = xmlNewAutomata(); if (ctxt->am == NULL) return (-1); ctxt->state = xmlAutomataGetInitState(ctxt->am); while (list != NULL) { xmlRelaxNGCompile(ctxt, list); list = list->next; } xmlAutomataSetFinalState(ctxt->am, ctxt->state); def->contModel = xmlAutomataCompile(ctxt->am); if (!xmlRegexpIsDeterminist(def->contModel)) { /* * we can only use the automata if it is determinist */ xmlRegFreeRegexp(def->contModel); def->contModel = NULL; } xmlFreeAutomata(ctxt->am); ctxt->state = oldstate; ctxt->am = oldam; } else { xmlAutomataPtr oldam = ctxt->am; /* * we can't build the content model for this element content * but it still might be possible to build it for some of its * children, recurse. */ ret = xmlRelaxNGTryCompile(ctxt, def); ctxt->am = oldam; } break; case XML_RELAXNG_NOOP: ret = xmlRelaxNGCompile(ctxt, def->content); break; case XML_RELAXNG_OPTIONAL:{ xmlAutomataStatePtr oldstate = ctxt->state; xmlRelaxNGCompile(ctxt, def->content); xmlAutomataNewEpsilon(ctxt->am, oldstate, ctxt->state); break; } case XML_RELAXNG_ZEROORMORE:{ xmlAutomataStatePtr oldstate; ctxt->state = xmlAutomataNewEpsilon(ctxt->am, ctxt->state, NULL); oldstate = ctxt->state; list = def->content; while (list != NULL) { xmlRelaxNGCompile(ctxt, list); list = list->next; } xmlAutomataNewEpsilon(ctxt->am, ctxt->state, oldstate); ctxt->state = xmlAutomataNewEpsilon(ctxt->am, oldstate, NULL); break; } case XML_RELAXNG_ONEORMORE:{ xmlAutomataStatePtr oldstate; list = def->content; while (list != NULL) { xmlRelaxNGCompile(ctxt, list); list = list->next; } oldstate = ctxt->state; list = def->content; while (list != NULL) { xmlRelaxNGCompile(ctxt, list); list = list->next; } xmlAutomataNewEpsilon(ctxt->am, ctxt->state, oldstate); ctxt->state = xmlAutomataNewEpsilon(ctxt->am, oldstate, NULL); break; } case XML_RELAXNG_CHOICE:{ xmlAutomataStatePtr target = NULL; xmlAutomataStatePtr oldstate = ctxt->state; list = def->content; while (list != NULL) { ctxt->state = oldstate; ret = xmlRelaxNGCompile(ctxt, list); if (ret != 0) break; if (target == NULL) target = ctxt->state; else { xmlAutomataNewEpsilon(ctxt->am, ctxt->state, target); } list = list->next; } ctxt->state = target; break; } case XML_RELAXNG_REF: case XML_RELAXNG_EXTERNALREF: case XML_RELAXNG_PARENTREF: case XML_RELAXNG_GROUP: case XML_RELAXNG_DEF: list = def->content; while (list != NULL) { ret = xmlRelaxNGCompile(ctxt, list); if (ret != 0) break; list = list->next; } break; case XML_RELAXNG_TEXT:{ xmlAutomataStatePtr oldstate; ctxt->state = xmlAutomataNewEpsilon(ctxt->am, ctxt->state, NULL); oldstate = ctxt->state; xmlRelaxNGCompile(ctxt, def->content); xmlAutomataNewTransition(ctxt->am, ctxt->state, ctxt->state, BAD_CAST "#text", NULL); ctxt->state = xmlAutomataNewEpsilon(ctxt->am, oldstate, NULL); break; } case XML_RELAXNG_EMPTY: ctxt->state = xmlAutomataNewEpsilon(ctxt->am, ctxt->state, NULL); break; case XML_RELAXNG_EXCEPT: case XML_RELAXNG_ATTRIBUTE: case XML_RELAXNG_INTERLEAVE: case XML_RELAXNG_NOT_ALLOWED: case XML_RELAXNG_DATATYPE: case XML_RELAXNG_LIST: case XML_RELAXNG_PARAM: case XML_RELAXNG_VALUE: /* This should not happen and generate an internal error */ fprintf(stderr, "RNG internal error trying to compile %s\n", xmlRelaxNGDefName(def)); break; } return (ret); } /** * xmlRelaxNGTryCompile: * ctxt: the RelaxNG parser context * @define: the definition tree to compile * * Try to compile the set of definitions, it works recursively, * possibly ignoring parts which cannot be compiled. * * Returns 0 if success and -1 in case of error */ static int xmlRelaxNGTryCompile(xmlRelaxNGParserCtxtPtr ctxt, xmlRelaxNGDefinePtr def) { int ret = 0; xmlRelaxNGDefinePtr list; if ((ctxt == NULL) || (def == NULL)) return (-1); if ((def->type == XML_RELAXNG_START) || (def->type == XML_RELAXNG_ELEMENT)) { ret = xmlRelaxNGIsCompileable(def); if ((def->dflags & IS_COMPILABLE) && (def->depth != -25)) { ctxt->am = NULL; ret = xmlRelaxNGCompile(ctxt, def); #ifdef DEBUG_PROGRESSIVE if (ret == 0) { if (def->type == XML_RELAXNG_START) xmlGenericError(xmlGenericErrorContext, "compiled the start\n"); else xmlGenericError(xmlGenericErrorContext, "compiled element %s\n", def->name); } else { if (def->type == XML_RELAXNG_START) xmlGenericError(xmlGenericErrorContext, "failed to compile the start\n"); else xmlGenericError(xmlGenericErrorContext, "failed to compile element %s\n", def->name); } #endif return (ret); } } switch (def->type) { case XML_RELAXNG_NOOP: ret = xmlRelaxNGTryCompile(ctxt, def->content); break; case XML_RELAXNG_TEXT: case XML_RELAXNG_DATATYPE: case XML_RELAXNG_LIST: case XML_RELAXNG_PARAM: case XML_RELAXNG_VALUE: case XML_RELAXNG_EMPTY: case XML_RELAXNG_ELEMENT: ret = 0; break; case XML_RELAXNG_OPTIONAL: case XML_RELAXNG_ZEROORMORE: case XML_RELAXNG_ONEORMORE: case XML_RELAXNG_CHOICE: case XML_RELAXNG_GROUP: case XML_RELAXNG_DEF: case XML_RELAXNG_START: case XML_RELAXNG_REF: case XML_RELAXNG_EXTERNALREF: case XML_RELAXNG_PARENTREF: list = def->content; while (list != NULL) { ret = xmlRelaxNGTryCompile(ctxt, list); if (ret != 0) break; list = list->next; } break; case XML_RELAXNG_EXCEPT: case XML_RELAXNG_ATTRIBUTE: case XML_RELAXNG_INTERLEAVE: case XML_RELAXNG_NOT_ALLOWED: ret = 0; break; } return (ret); } /************************************************************************ * * * Parsing functions * * * ************************************************************************/ static xmlRelaxNGDefinePtr xmlRelaxNGParseAttribute(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node); static xmlRelaxNGDefinePtr xmlRelaxNGParseElement(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node); static xmlRelaxNGDefinePtr xmlRelaxNGParsePatterns(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr nodes, int group); static xmlRelaxNGDefinePtr xmlRelaxNGParsePattern(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node); static xmlRelaxNGPtr xmlRelaxNGParseDocument(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node); static int xmlRelaxNGParseGrammarContent(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr nodes); static xmlRelaxNGDefinePtr xmlRelaxNGParseNameClass(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node, xmlRelaxNGDefinePtr def); static xmlRelaxNGGrammarPtr xmlRelaxNGParseGrammar(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr nodes); static int xmlRelaxNGElementMatch(xmlRelaxNGValidCtxtPtr ctxt, xmlRelaxNGDefinePtr define, xmlNodePtr elem); #define IS_BLANK_NODE(n) (xmlRelaxNGIsBlank((n)->content)) /** * xmlRelaxNGIsNullable: * @define: the definition to verify * * Check if a definition is nullable. * * Returns 1 if yes, 0 if no and -1 in case of error */ static int xmlRelaxNGIsNullable(xmlRelaxNGDefinePtr define) { int ret; if (define == NULL) return (-1); if (define->dflags & IS_NULLABLE) return (1); if (define->dflags & IS_NOT_NULLABLE) return (0); switch (define->type) { case XML_RELAXNG_EMPTY: case XML_RELAXNG_TEXT: ret = 1; break; case XML_RELAXNG_NOOP: case XML_RELAXNG_DEF: case XML_RELAXNG_REF: case XML_RELAXNG_EXTERNALREF: case XML_RELAXNG_PARENTREF: case XML_RELAXNG_ONEORMORE: ret = xmlRelaxNGIsNullable(define->content); break; case XML_RELAXNG_EXCEPT: case XML_RELAXNG_NOT_ALLOWED: case XML_RELAXNG_ELEMENT: case XML_RELAXNG_DATATYPE: case XML_RELAXNG_PARAM: case XML_RELAXNG_VALUE: case XML_RELAXNG_LIST: case XML_RELAXNG_ATTRIBUTE: ret = 0; break; case XML_RELAXNG_CHOICE:{ xmlRelaxNGDefinePtr list = define->content; while (list != NULL) { ret = xmlRelaxNGIsNullable(list); if (ret != 0) goto done; list = list->next; } ret = 0; break; } case XML_RELAXNG_START: case XML_RELAXNG_INTERLEAVE: case XML_RELAXNG_GROUP:{ xmlRelaxNGDefinePtr list = define->content; while (list != NULL) { ret = xmlRelaxNGIsNullable(list); if (ret != 1) goto done; list = list->next; } return (1); } default: return (-1); } done: if (ret == 0) define->dflags |= IS_NOT_NULLABLE; if (ret == 1) define->dflags |= IS_NULLABLE; return (ret); } /** * xmlRelaxNGIsBlank: * @str: a string * * Check if a string is ignorable c.f. 4.2. Whitespace * * Returns 1 if the string is NULL or made of blanks chars, 0 otherwise */ static int xmlRelaxNGIsBlank(xmlChar * str) { if (str == NULL) return (1); while (*str != 0) { if (!(IS_BLANK_CH(*str))) return (0); str++; } return (1); } /** * xmlRelaxNGGetDataTypeLibrary: * @ctxt: a Relax-NG parser context * @node: the current data or value element * * Applies algorithm from 4.3. datatypeLibrary attribute * * Returns the datatypeLibary value or NULL if not found */ static xmlChar * xmlRelaxNGGetDataTypeLibrary(xmlRelaxNGParserCtxtPtr ctxt ATTRIBUTE_UNUSED, xmlNodePtr node) { xmlChar *ret, *escape; if ((IS_RELAXNG(node, "data")) || (IS_RELAXNG(node, "value"))) { ret = xmlGetProp(node, BAD_CAST "datatypeLibrary"); if (ret != NULL) { if (ret[0] == 0) { xmlFree(ret); return (NULL); } escape = xmlURIEscapeStr(ret, BAD_CAST ":/#?"); if (escape == NULL) { return (ret); } xmlFree(ret); return (escape); } } node = node->parent; while ((node != NULL) && (node->type == XML_ELEMENT_NODE)) { ret = xmlGetProp(node, BAD_CAST "datatypeLibrary"); if (ret != NULL) { if (ret[0] == 0) { xmlFree(ret); return (NULL); } escape = xmlURIEscapeStr(ret, BAD_CAST ":/#?"); if (escape == NULL) { return (ret); } xmlFree(ret); return (escape); } node = node->parent; } return (NULL); } /** * xmlRelaxNGParseValue: * @ctxt: a Relax-NG parser context * @node: the data node. * * parse the content of a RelaxNG value node. * * Returns the definition pointer or NULL in case of error */ static xmlRelaxNGDefinePtr xmlRelaxNGParseValue(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node) { xmlRelaxNGDefinePtr def = NULL; xmlRelaxNGTypeLibraryPtr lib = NULL; xmlChar *type; xmlChar *library; int success = 0; def = xmlRelaxNGNewDefine(ctxt, node); if (def == NULL) return (NULL); def->type = XML_RELAXNG_VALUE; type = xmlGetProp(node, BAD_CAST "type"); if (type != NULL) { xmlRelaxNGNormExtSpace(type); if (xmlValidateNCName(type, 0)) { xmlRngPErr(ctxt, node, XML_RNGP_TYPE_VALUE, "value type '%s' is not an NCName\n", type, NULL); } library = xmlRelaxNGGetDataTypeLibrary(ctxt, node); if (library == NULL) library = xmlStrdup(BAD_CAST "http://relaxng.org/ns/structure/1.0"); def->name = type; def->ns = library; lib = (xmlRelaxNGTypeLibraryPtr) xmlHashLookup(xmlRelaxNGRegisteredTypes, library); if (lib == NULL) { xmlRngPErr(ctxt, node, XML_RNGP_UNKNOWN_TYPE_LIB, "Use of unregistered type library '%s'\n", library, NULL); def->data = NULL; } else { def->data = lib; if (lib->have == NULL) { xmlRngPErr(ctxt, node, XML_RNGP_ERROR_TYPE_LIB, "Internal error with type library '%s': no 'have'\n", library, NULL); } else { success = lib->have(lib->data, def->name); if (success != 1) { xmlRngPErr(ctxt, node, XML_RNGP_TYPE_NOT_FOUND, "Error type '%s' is not exported by type library '%s'\n", def->name, library); } } } } if (node->children == NULL) { def->value = xmlStrdup(BAD_CAST ""); } else if (((node->children->type != XML_TEXT_NODE) && (node->children->type != XML_CDATA_SECTION_NODE)) || (node->children->next != NULL)) { xmlRngPErr(ctxt, node, XML_RNGP_TEXT_EXPECTED, "Expecting a single text value for content\n", NULL, NULL); } else if (def != NULL) { def->value = xmlNodeGetContent(node); if (def->value == NULL) { xmlRngPErr(ctxt, node, XML_RNGP_VALUE_NO_CONTENT, "Element has no content\n", NULL, NULL); } else if ((lib != NULL) && (lib->check != NULL) && (success == 1)) { void *val = NULL; success = lib->check(lib->data, def->name, def->value, &val, node); if (success != 1) { xmlRngPErr(ctxt, node, XML_RNGP_INVALID_VALUE, "Value '%s' is not acceptable for type '%s'\n", def->value, def->name); } else { if (val != NULL) def->attrs = val; } } } return (def); } /** * xmlRelaxNGParseData: * @ctxt: a Relax-NG parser context * @node: the data node. * * parse the content of a RelaxNG data node. * * Returns the definition pointer or NULL in case of error */ static xmlRelaxNGDefinePtr xmlRelaxNGParseData(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node) { xmlRelaxNGDefinePtr def = NULL, except; xmlRelaxNGDefinePtr param, lastparam = NULL; xmlRelaxNGTypeLibraryPtr lib; xmlChar *type; xmlChar *library; xmlNodePtr content; int tmp; type = xmlGetProp(node, BAD_CAST "type"); if (type == NULL) { xmlRngPErr(ctxt, node, XML_RNGP_TYPE_MISSING, "data has no type\n", NULL, NULL); return (NULL); } xmlRelaxNGNormExtSpace(type); if (xmlValidateNCName(type, 0)) { xmlRngPErr(ctxt, node, XML_RNGP_TYPE_VALUE, "data type '%s' is not an NCName\n", type, NULL); } library = xmlRelaxNGGetDataTypeLibrary(ctxt, node); if (library == NULL) library = xmlStrdup(BAD_CAST "http://relaxng.org/ns/structure/1.0"); def = xmlRelaxNGNewDefine(ctxt, node); if (def == NULL) { xmlFree(type); return (NULL); } def->type = XML_RELAXNG_DATATYPE; def->name = type; def->ns = library; lib = (xmlRelaxNGTypeLibraryPtr) xmlHashLookup(xmlRelaxNGRegisteredTypes, library); if (lib == NULL) { xmlRngPErr(ctxt, node, XML_RNGP_UNKNOWN_TYPE_LIB, "Use of unregistered type library '%s'\n", library, NULL); def->data = NULL; } else { def->data = lib; if (lib->have == NULL) { xmlRngPErr(ctxt, node, XML_RNGP_ERROR_TYPE_LIB, "Internal error with type library '%s': no 'have'\n", library, NULL); } else { tmp = lib->have(lib->data, def->name); if (tmp != 1) { xmlRngPErr(ctxt, node, XML_RNGP_TYPE_NOT_FOUND, "Error type '%s' is not exported by type library '%s'\n", def->name, library); } else if ((xmlStrEqual (library, BAD_CAST "http://www.w3.org/2001/XMLSchema-datatypes")) && ((xmlStrEqual(def->name, BAD_CAST "IDREF")) || (xmlStrEqual(def->name, BAD_CAST "IDREFS")))) { ctxt->idref = 1; } } } content = node->children; /* * Handle optional params */ while (content != NULL) { if (!xmlStrEqual(content->name, BAD_CAST "param")) break; if (xmlStrEqual(library, BAD_CAST "http://relaxng.org/ns/structure/1.0")) { xmlRngPErr(ctxt, node, XML_RNGP_PARAM_FORBIDDEN, "Type library '%s' does not allow type parameters\n", library, NULL); content = content->next; while ((content != NULL) && (xmlStrEqual(content->name, BAD_CAST "param"))) content = content->next; } else { param = xmlRelaxNGNewDefine(ctxt, node); if (param != NULL) { param->type = XML_RELAXNG_PARAM; param->name = xmlGetProp(content, BAD_CAST "name"); if (param->name == NULL) { xmlRngPErr(ctxt, node, XML_RNGP_PARAM_NAME_MISSING, "param has no name\n", NULL, NULL); } param->value = xmlNodeGetContent(content); if (lastparam == NULL) { def->attrs = lastparam = param; } else { lastparam->next = param; lastparam = param; } if (lib != NULL) { } } content = content->next; } } /* * Handle optional except */ if ((content != NULL) && (xmlStrEqual(content->name, BAD_CAST "except"))) { xmlNodePtr child; xmlRelaxNGDefinePtr tmp2, last = NULL; except = xmlRelaxNGNewDefine(ctxt, node); if (except == NULL) { return (def); } except->type = XML_RELAXNG_EXCEPT; child = content->children; def->content = except; if (child == NULL) { xmlRngPErr(ctxt, content, XML_RNGP_EXCEPT_NO_CONTENT, "except has no content\n", NULL, NULL); } while (child != NULL) { tmp2 = xmlRelaxNGParsePattern(ctxt, child); if (tmp2 != NULL) { if (last == NULL) { except->content = last = tmp2; } else { last->next = tmp2; last = tmp2; } } child = child->next; } content = content->next; } /* * Check there is no unhandled data */ if (content != NULL) { xmlRngPErr(ctxt, content, XML_RNGP_DATA_CONTENT, "Element data has unexpected content %s\n", content->name, NULL); } return (def); } static const xmlChar *invalidName = BAD_CAST "\1"; /** * xmlRelaxNGCompareNameClasses: * @defs1: the first element/attribute defs * @defs2: the second element/attribute defs * @name: the restriction on the name * @ns: the restriction on the namespace * * Compare the 2 lists of element definitions. The comparison is * that if both lists do not accept the same QNames, it returns 1 * If the 2 lists can accept the same QName the comparison returns 0 * * Returns 1 disttinct, 0 if equal */ static int xmlRelaxNGCompareNameClasses(xmlRelaxNGDefinePtr def1, xmlRelaxNGDefinePtr def2) { int ret = 1; xmlNode node; xmlNs ns; xmlRelaxNGValidCtxt ctxt; memset(&ctxt, 0, sizeof(xmlRelaxNGValidCtxt)); ctxt.flags = FLAGS_IGNORABLE | FLAGS_NOERROR; if ((def1->type == XML_RELAXNG_ELEMENT) || (def1->type == XML_RELAXNG_ATTRIBUTE)) { if (def2->type == XML_RELAXNG_TEXT) return (1); if (def1->name != NULL) { node.name = def1->name; } else { node.name = invalidName; } if (def1->ns != NULL) { if (def1->ns[0] == 0) { node.ns = NULL; } else { node.ns = &ns; ns.href = def1->ns; } } else { node.ns = NULL; } if (xmlRelaxNGElementMatch(&ctxt, def2, &node)) { if (def1->nameClass != NULL) { ret = xmlRelaxNGCompareNameClasses(def1->nameClass, def2); } else { ret = 0; } } else { ret = 1; } } else if (def1->type == XML_RELAXNG_TEXT) { if (def2->type == XML_RELAXNG_TEXT) return (0); return (1); } else if (def1->type == XML_RELAXNG_EXCEPT) { TODO ret = 0; } else { TODO ret = 0; } if (ret == 0) return (ret); if ((def2->type == XML_RELAXNG_ELEMENT) || (def2->type == XML_RELAXNG_ATTRIBUTE)) { if (def2->name != NULL) { node.name = def2->name; } else { node.name = invalidName; } node.ns = &ns; if (def2->ns != NULL) { if (def2->ns[0] == 0) { node.ns = NULL; } else { ns.href = def2->ns; } } else { ns.href = invalidName; } if (xmlRelaxNGElementMatch(&ctxt, def1, &node)) { if (def2->nameClass != NULL) { ret = xmlRelaxNGCompareNameClasses(def2->nameClass, def1); } else { ret = 0; } } else { ret = 1; } } else { TODO ret = 0; } return (ret); } /** * xmlRelaxNGCompareElemDefLists: * @ctxt: a Relax-NG parser context * @defs1: the first list of element/attribute defs * @defs2: the second list of element/attribute defs * * Compare the 2 lists of element or attribute definitions. The comparison * is that if both lists do not accept the same QNames, it returns 1 * If the 2 lists can accept the same QName the comparison returns 0 * * Returns 1 disttinct, 0 if equal */ static int xmlRelaxNGCompareElemDefLists(xmlRelaxNGParserCtxtPtr ctxt ATTRIBUTE_UNUSED, xmlRelaxNGDefinePtr * def1, xmlRelaxNGDefinePtr * def2) { xmlRelaxNGDefinePtr *basedef2 = def2; if ((def1 == NULL) || (def2 == NULL)) return (1); if ((*def1 == NULL) || (*def2 == NULL)) return (1); while (*def1 != NULL) { while ((*def2) != NULL) { if (xmlRelaxNGCompareNameClasses(*def1, *def2) == 0) return (0); def2++; } def2 = basedef2; def1++; } return (1); } /** * xmlRelaxNGGenerateAttributes: * @ctxt: a Relax-NG parser context * @def: the definition definition * * Check if the definition can only generate attributes * * Returns 1 if yes, 0 if no and -1 in case of error. */ static int xmlRelaxNGGenerateAttributes(xmlRelaxNGParserCtxtPtr ctxt, xmlRelaxNGDefinePtr def) { xmlRelaxNGDefinePtr parent, cur, tmp; /* * Don't run that check in case of error. Infinite recursion * becomes possible. */ if (ctxt->nbErrors != 0) return (-1); parent = NULL; cur = def; while (cur != NULL) { if ((cur->type == XML_RELAXNG_ELEMENT) || (cur->type == XML_RELAXNG_TEXT) || (cur->type == XML_RELAXNG_DATATYPE) || (cur->type == XML_RELAXNG_PARAM) || (cur->type == XML_RELAXNG_LIST) || (cur->type == XML_RELAXNG_VALUE) || (cur->type == XML_RELAXNG_EMPTY)) return (0); if ((cur->type == XML_RELAXNG_CHOICE) || (cur->type == XML_RELAXNG_INTERLEAVE) || (cur->type == XML_RELAXNG_GROUP) || (cur->type == XML_RELAXNG_ONEORMORE) || (cur->type == XML_RELAXNG_ZEROORMORE) || (cur->type == XML_RELAXNG_OPTIONAL) || (cur->type == XML_RELAXNG_PARENTREF) || (cur->type == XML_RELAXNG_EXTERNALREF) || (cur->type == XML_RELAXNG_REF) || (cur->type == XML_RELAXNG_DEF)) { if (cur->content != NULL) { parent = cur; cur = cur->content; tmp = cur; while (tmp != NULL) { tmp->parent = parent; tmp = tmp->next; } continue; } } if (cur == def) break; if (cur->next != NULL) { cur = cur->next; continue; } do { cur = cur->parent; if (cur == NULL) break; if (cur == def) return (1); if (cur->next != NULL) { cur = cur->next; break; } } while (cur != NULL); } return (1); } /** * xmlRelaxNGGetElements: * @ctxt: a Relax-NG parser context * @def: the definition definition * @eora: gather elements (0) or attributes (1) * * Compute the list of top elements a definition can generate * * Returns a list of elements or NULL if none was found. */ static xmlRelaxNGDefinePtr * xmlRelaxNGGetElements(xmlRelaxNGParserCtxtPtr ctxt, xmlRelaxNGDefinePtr def, int eora) { xmlRelaxNGDefinePtr *ret = NULL, parent, cur, tmp; int len = 0; int max = 0; /* * Don't run that check in case of error. Infinite recursion * becomes possible. */ if (ctxt->nbErrors != 0) return (NULL); parent = NULL; cur = def; while (cur != NULL) { if (((eora == 0) && ((cur->type == XML_RELAXNG_ELEMENT) || (cur->type == XML_RELAXNG_TEXT))) || ((eora == 1) && (cur->type == XML_RELAXNG_ATTRIBUTE))) { if (ret == NULL) { max = 10; ret = (xmlRelaxNGDefinePtr *) xmlMalloc((max + 1) * sizeof(xmlRelaxNGDefinePtr)); if (ret == NULL) { xmlRngPErrMemory(ctxt, "getting element list\n"); return (NULL); } } else if (max <= len) { xmlRelaxNGDefinePtr *temp; max *= 2; temp = xmlRealloc(ret, (max + 1) * sizeof(xmlRelaxNGDefinePtr)); if (temp == NULL) { xmlRngPErrMemory(ctxt, "getting element list\n"); xmlFree(ret); return (NULL); } ret = temp; } ret[len++] = cur; ret[len] = NULL; } else if ((cur->type == XML_RELAXNG_CHOICE) || (cur->type == XML_RELAXNG_INTERLEAVE) || (cur->type == XML_RELAXNG_GROUP) || (cur->type == XML_RELAXNG_ONEORMORE) || (cur->type == XML_RELAXNG_ZEROORMORE) || (cur->type == XML_RELAXNG_OPTIONAL) || (cur->type == XML_RELAXNG_PARENTREF) || (cur->type == XML_RELAXNG_REF) || (cur->type == XML_RELAXNG_DEF) || (cur->type == XML_RELAXNG_EXTERNALREF)) { /* * Don't go within elements or attributes or string values. * Just gather the element top list */ if (cur->content != NULL) { parent = cur; cur = cur->content; tmp = cur; while (tmp != NULL) { tmp->parent = parent; tmp = tmp->next; } continue; } } if (cur == def) break; if (cur->next != NULL) { cur = cur->next; continue; } do { cur = cur->parent; if (cur == NULL) break; if (cur == def) return (ret); if (cur->next != NULL) { cur = cur->next; break; } } while (cur != NULL); } return (ret); } /** * xmlRelaxNGCheckChoiceDeterminism: * @ctxt: a Relax-NG parser context * @def: the choice definition * * Also used to find indeterministic pattern in choice */ static void xmlRelaxNGCheckChoiceDeterminism(xmlRelaxNGParserCtxtPtr ctxt, xmlRelaxNGDefinePtr def) { xmlRelaxNGDefinePtr **list; xmlRelaxNGDefinePtr cur; int nbchild = 0, i, j, ret; int is_nullable = 0; int is_indeterminist = 0; xmlHashTablePtr triage = NULL; int is_triable = 1; if ((def == NULL) || (def->type != XML_RELAXNG_CHOICE)) return; if (def->dflags & IS_PROCESSED) return; /* * Don't run that check in case of error. Infinite recursion * becomes possible. */ if (ctxt->nbErrors != 0) return; is_nullable = xmlRelaxNGIsNullable(def); cur = def->content; while (cur != NULL) { nbchild++; cur = cur->next; } list = (xmlRelaxNGDefinePtr **) xmlMalloc(nbchild * sizeof(xmlRelaxNGDefinePtr *)); if (list == NULL) { xmlRngPErrMemory(ctxt, "building choice\n"); return; } i = 0; /* * a bit strong but safe */ if (is_nullable == 0) { triage = xmlHashCreate(10); } else { is_triable = 0; } cur = def->content; while (cur != NULL) { list[i] = xmlRelaxNGGetElements(ctxt, cur, 0); if ((list[i] == NULL) || (list[i][0] == NULL)) { is_triable = 0; } else if (is_triable == 1) { xmlRelaxNGDefinePtr *tmp; int res; tmp = list[i]; while ((*tmp != NULL) && (is_triable == 1)) { if ((*tmp)->type == XML_RELAXNG_TEXT) { res = xmlHashAddEntry2(triage, BAD_CAST "#text", NULL, (void *) cur); if (res != 0) is_triable = -1; } else if (((*tmp)->type == XML_RELAXNG_ELEMENT) && ((*tmp)->name != NULL)) { if (((*tmp)->ns == NULL) || ((*tmp)->ns[0] == 0)) res = xmlHashAddEntry2(triage, (*tmp)->name, NULL, (void *) cur); else res = xmlHashAddEntry2(triage, (*tmp)->name, (*tmp)->ns, (void *) cur); if (res != 0) is_triable = -1; } else if ((*tmp)->type == XML_RELAXNG_ELEMENT) { if (((*tmp)->ns == NULL) || ((*tmp)->ns[0] == 0)) res = xmlHashAddEntry2(triage, BAD_CAST "#any", NULL, (void *) cur); else res = xmlHashAddEntry2(triage, BAD_CAST "#any", (*tmp)->ns, (void *) cur); if (res != 0) is_triable = -1; } else { is_triable = -1; } tmp++; } } i++; cur = cur->next; } for (i = 0; i < nbchild; i++) { if (list[i] == NULL) continue; for (j = 0; j < i; j++) { if (list[j] == NULL) continue; ret = xmlRelaxNGCompareElemDefLists(ctxt, list[i], list[j]); if (ret == 0) { is_indeterminist = 1; } } } for (i = 0; i < nbchild; i++) { if (list[i] != NULL) xmlFree(list[i]); } xmlFree(list); if (is_indeterminist) { def->dflags |= IS_INDETERMINIST; } if (is_triable == 1) { def->dflags |= IS_TRIABLE; def->data = triage; } else if (triage != NULL) { xmlHashFree(triage, NULL); } def->dflags |= IS_PROCESSED; } /** * xmlRelaxNGCheckGroupAttrs: * @ctxt: a Relax-NG parser context * @def: the group definition * * Detects violations of rule 7.3 */ static void xmlRelaxNGCheckGroupAttrs(xmlRelaxNGParserCtxtPtr ctxt, xmlRelaxNGDefinePtr def) { xmlRelaxNGDefinePtr **list; xmlRelaxNGDefinePtr cur; int nbchild = 0, i, j, ret; if ((def == NULL) || ((def->type != XML_RELAXNG_GROUP) && (def->type != XML_RELAXNG_ELEMENT))) return; if (def->dflags & IS_PROCESSED) return; /* * Don't run that check in case of error. Infinite recursion * becomes possible. */ if (ctxt->nbErrors != 0) return; cur = def->attrs; while (cur != NULL) { nbchild++; cur = cur->next; } cur = def->content; while (cur != NULL) { nbchild++; cur = cur->next; } list = (xmlRelaxNGDefinePtr **) xmlMalloc(nbchild * sizeof(xmlRelaxNGDefinePtr *)); if (list == NULL) { xmlRngPErrMemory(ctxt, "building group\n"); return; } i = 0; cur = def->attrs; while (cur != NULL) { list[i] = xmlRelaxNGGetElements(ctxt, cur, 1); i++; cur = cur->next; } cur = def->content; while (cur != NULL) { list[i] = xmlRelaxNGGetElements(ctxt, cur, 1); i++; cur = cur->next; } for (i = 0; i < nbchild; i++) { if (list[i] == NULL) continue; for (j = 0; j < i; j++) { if (list[j] == NULL) continue; ret = xmlRelaxNGCompareElemDefLists(ctxt, list[i], list[j]); if (ret == 0) { xmlRngPErr(ctxt, def->node, XML_RNGP_GROUP_ATTR_CONFLICT, "Attributes conflicts in group\n", NULL, NULL); } } } for (i = 0; i < nbchild; i++) { if (list[i] != NULL) xmlFree(list[i]); } xmlFree(list); def->dflags |= IS_PROCESSED; } /** * xmlRelaxNGComputeInterleaves: * @def: the interleave definition * @ctxt: a Relax-NG parser context * @name: the definition name * * A lot of work for preprocessing interleave definitions * is potentially needed to get a decent execution speed at runtime * - trying to get a total order on the element nodes generated * by the interleaves, order the list of interleave definitions * following that order. * - if is used to handle mixed content, it is better to * flag this in the define and simplify the runtime checking * algorithm */ static void xmlRelaxNGComputeInterleaves(xmlRelaxNGDefinePtr def, xmlRelaxNGParserCtxtPtr ctxt, xmlChar * name ATTRIBUTE_UNUSED) { xmlRelaxNGDefinePtr cur, *tmp; xmlRelaxNGPartitionPtr partitions = NULL; xmlRelaxNGInterleaveGroupPtr *groups = NULL; xmlRelaxNGInterleaveGroupPtr group; int i, j, ret, res; int nbgroups = 0; int nbchild = 0; int is_mixed = 0; int is_determinist = 1; /* * Don't run that check in case of error. Infinite recursion * becomes possible. */ if (ctxt->nbErrors != 0) return; #ifdef DEBUG_INTERLEAVE xmlGenericError(xmlGenericErrorContext, "xmlRelaxNGComputeInterleaves(%s)\n", name); #endif cur = def->content; while (cur != NULL) { nbchild++; cur = cur->next; } #ifdef DEBUG_INTERLEAVE xmlGenericError(xmlGenericErrorContext, " %d child\n", nbchild); #endif groups = (xmlRelaxNGInterleaveGroupPtr *) xmlMalloc(nbchild * sizeof(xmlRelaxNGInterleaveGroupPtr)); if (groups == NULL) goto error; cur = def->content; while (cur != NULL) { groups[nbgroups] = (xmlRelaxNGInterleaveGroupPtr) xmlMalloc(sizeof(xmlRelaxNGInterleaveGroup)); if (groups[nbgroups] == NULL) goto error; if (cur->type == XML_RELAXNG_TEXT) is_mixed++; groups[nbgroups]->rule = cur; groups[nbgroups]->defs = xmlRelaxNGGetElements(ctxt, cur, 0); groups[nbgroups]->attrs = xmlRelaxNGGetElements(ctxt, cur, 1); nbgroups++; cur = cur->next; } #ifdef DEBUG_INTERLEAVE xmlGenericError(xmlGenericErrorContext, " %d groups\n", nbgroups); #endif /* * Let's check that all rules makes a partitions according to 7.4 */ partitions = (xmlRelaxNGPartitionPtr) xmlMalloc(sizeof(xmlRelaxNGPartition)); if (partitions == NULL) goto error; memset(partitions, 0, sizeof(xmlRelaxNGPartition)); partitions->nbgroups = nbgroups; partitions->triage = xmlHashCreate(nbgroups); for (i = 0; i < nbgroups; i++) { group = groups[i]; for (j = i + 1; j < nbgroups; j++) { if (groups[j] == NULL) continue; ret = xmlRelaxNGCompareElemDefLists(ctxt, group->defs, groups[j]->defs); if (ret == 0) { xmlRngPErr(ctxt, def->node, XML_RNGP_ELEM_TEXT_CONFLICT, "Element or text conflicts in interleave\n", NULL, NULL); } ret = xmlRelaxNGCompareElemDefLists(ctxt, group->attrs, groups[j]->attrs); if (ret == 0) { xmlRngPErr(ctxt, def->node, XML_RNGP_ATTR_CONFLICT, "Attributes conflicts in interleave\n", NULL, NULL); } } tmp = group->defs; if ((tmp != NULL) && (*tmp != NULL)) { while (*tmp != NULL) { if ((*tmp)->type == XML_RELAXNG_TEXT) { res = xmlHashAddEntry2(partitions->triage, BAD_CAST "#text", NULL, (void *) (long) (i + 1)); if (res != 0) is_determinist = -1; } else if (((*tmp)->type == XML_RELAXNG_ELEMENT) && ((*tmp)->name != NULL)) { if (((*tmp)->ns == NULL) || ((*tmp)->ns[0] == 0)) res = xmlHashAddEntry2(partitions->triage, (*tmp)->name, NULL, (void *) (long) (i + 1)); else res = xmlHashAddEntry2(partitions->triage, (*tmp)->name, (*tmp)->ns, (void *) (long) (i + 1)); if (res != 0) is_determinist = -1; } else if ((*tmp)->type == XML_RELAXNG_ELEMENT) { if (((*tmp)->ns == NULL) || ((*tmp)->ns[0] == 0)) res = xmlHashAddEntry2(partitions->triage, BAD_CAST "#any", NULL, (void *) (long) (i + 1)); else res = xmlHashAddEntry2(partitions->triage, BAD_CAST "#any", (*tmp)->ns, (void *) (long) (i + 1)); if ((*tmp)->nameClass != NULL) is_determinist = 2; if (res != 0) is_determinist = -1; } else { is_determinist = -1; } tmp++; } } else { is_determinist = 0; } } partitions->groups = groups; /* * and save the partition list back in the def */ def->data = partitions; if (is_mixed != 0) def->dflags |= IS_MIXED; if (is_determinist == 1) partitions->flags = IS_DETERMINIST; if (is_determinist == 2) partitions->flags = IS_DETERMINIST | IS_NEEDCHECK; return; error: xmlRngPErrMemory(ctxt, "in interleave computation\n"); if (groups != NULL) { for (i = 0; i < nbgroups; i++) if (groups[i] != NULL) { if (groups[i]->defs != NULL) xmlFree(groups[i]->defs); xmlFree(groups[i]); } xmlFree(groups); } xmlRelaxNGFreePartition(partitions); } /** * xmlRelaxNGParseInterleave: * @ctxt: a Relax-NG parser context * @node: the data node. * * parse the content of a RelaxNG interleave node. * * Returns the definition pointer or NULL in case of error */ static xmlRelaxNGDefinePtr xmlRelaxNGParseInterleave(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node) { xmlRelaxNGDefinePtr def = NULL; xmlRelaxNGDefinePtr last = NULL, cur; xmlNodePtr child; def = xmlRelaxNGNewDefine(ctxt, node); if (def == NULL) { return (NULL); } def->type = XML_RELAXNG_INTERLEAVE; if (ctxt->interleaves == NULL) ctxt->interleaves = xmlHashCreate(10); if (ctxt->interleaves == NULL) { xmlRngPErrMemory(ctxt, "create interleaves\n"); } else { char name[32]; snprintf(name, 32, "interleave%d", ctxt->nbInterleaves++); if (xmlHashAddEntry(ctxt->interleaves, BAD_CAST name, def) < 0) { xmlRngPErr(ctxt, node, XML_RNGP_INTERLEAVE_ADD, "Failed to add %s to hash table\n", (const xmlChar *) name, NULL); } } child = node->children; if (child == NULL) { xmlRngPErr(ctxt, node, XML_RNGP_INTERLEAVE_NO_CONTENT, "Element interleave is empty\n", NULL, NULL); } while (child != NULL) { if (IS_RELAXNG(child, "element")) { cur = xmlRelaxNGParseElement(ctxt, child); } else { cur = xmlRelaxNGParsePattern(ctxt, child); } if (cur != NULL) { cur->parent = def; if (last == NULL) { def->content = last = cur; } else { last->next = cur; last = cur; } } child = child->next; } return (def); } /** * xmlRelaxNGParseInclude: * @ctxt: a Relax-NG parser context * @node: the include node * * Integrate the content of an include node in the current grammar * * Returns 0 in case of success or -1 in case of error */ static int xmlRelaxNGParseInclude(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node) { xmlRelaxNGIncludePtr incl; xmlNodePtr root; int ret = 0, tmp; incl = node->psvi; if (incl == NULL) { xmlRngPErr(ctxt, node, XML_RNGP_INCLUDE_EMPTY, "Include node has no data\n", NULL, NULL); return (-1); } root = xmlDocGetRootElement(incl->doc); if (root == NULL) { xmlRngPErr(ctxt, node, XML_RNGP_EMPTY, "Include document is empty\n", NULL, NULL); return (-1); } if (!xmlStrEqual(root->name, BAD_CAST "grammar")) { xmlRngPErr(ctxt, node, XML_RNGP_GRAMMAR_MISSING, "Include document root is not a grammar\n", NULL, NULL); return (-1); } /* * Merge the definition from both the include and the internal list */ if (root->children != NULL) { tmp = xmlRelaxNGParseGrammarContent(ctxt, root->children); if (tmp != 0) ret = -1; } if (node->children != NULL) { tmp = xmlRelaxNGParseGrammarContent(ctxt, node->children); if (tmp != 0) ret = -1; } return (ret); } /** * xmlRelaxNGParseDefine: * @ctxt: a Relax-NG parser context * @node: the define node * * parse the content of a RelaxNG define element node. * * Returns 0 in case of success or -1 in case of error */ static int xmlRelaxNGParseDefine(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node) { xmlChar *name; int ret = 0, tmp; xmlRelaxNGDefinePtr def; const xmlChar *olddefine; name = xmlGetProp(node, BAD_CAST "name"); if (name == NULL) { xmlRngPErr(ctxt, node, XML_RNGP_DEFINE_NAME_MISSING, "define has no name\n", NULL, NULL); } else { xmlRelaxNGNormExtSpace(name); if (xmlValidateNCName(name, 0)) { xmlRngPErr(ctxt, node, XML_RNGP_INVALID_DEFINE_NAME, "define name '%s' is not an NCName\n", name, NULL); } def = xmlRelaxNGNewDefine(ctxt, node); if (def == NULL) { xmlFree(name); return (-1); } def->type = XML_RELAXNG_DEF; def->name = name; if (node->children == NULL) { xmlRngPErr(ctxt, node, XML_RNGP_DEFINE_EMPTY, "define has no children\n", NULL, NULL); } else { olddefine = ctxt->define; ctxt->define = name; def->content = xmlRelaxNGParsePatterns(ctxt, node->children, 0); ctxt->define = olddefine; } if (ctxt->grammar->defs == NULL) ctxt->grammar->defs = xmlHashCreate(10); if (ctxt->grammar->defs == NULL) { xmlRngPErr(ctxt, node, XML_RNGP_DEFINE_CREATE_FAILED, "Could not create definition hash\n", NULL, NULL); ret = -1; } else { tmp = xmlHashAddEntry(ctxt->grammar->defs, name, def); if (tmp < 0) { xmlRelaxNGDefinePtr prev; prev = xmlHashLookup(ctxt->grammar->defs, name); if (prev == NULL) { xmlRngPErr(ctxt, node, XML_RNGP_DEFINE_CREATE_FAILED, "Internal error on define aggregation of %s\n", name, NULL); ret = -1; } else { while (prev->nextHash != NULL) prev = prev->nextHash; prev->nextHash = def; } } } } return (ret); } /** * xmlRelaxNGProcessExternalRef: * @ctxt: the parser context * @node: the externlRef node * * Process and compile an externlRef node * * Returns the xmlRelaxNGDefinePtr or NULL in case of error */ static xmlRelaxNGDefinePtr xmlRelaxNGProcessExternalRef(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node) { xmlRelaxNGDocumentPtr docu; xmlNodePtr root, tmp; xmlChar *ns; int newNs = 0, oldflags; xmlRelaxNGDefinePtr def; docu = node->psvi; if (docu != NULL) { def = xmlRelaxNGNewDefine(ctxt, node); if (def == NULL) return (NULL); def->type = XML_RELAXNG_EXTERNALREF; if (docu->content == NULL) { /* * Then do the parsing for good */ root = xmlDocGetRootElement(docu->doc); if (root == NULL) { xmlRngPErr(ctxt, node, XML_RNGP_EXTERNALREF_EMTPY, "xmlRelaxNGParse: %s is empty\n", ctxt->URL, NULL); return (NULL); } /* * ns transmission rules */ ns = xmlGetProp(root, BAD_CAST "ns"); if (ns == NULL) { tmp = node; while ((tmp != NULL) && (tmp->type == XML_ELEMENT_NODE)) { ns = xmlGetProp(tmp, BAD_CAST "ns"); if (ns != NULL) { break; } tmp = tmp->parent; } if (ns != NULL) { xmlSetProp(root, BAD_CAST "ns", ns); newNs = 1; xmlFree(ns); } } else { xmlFree(ns); } /* * Parsing to get a precompiled schemas. */ oldflags = ctxt->flags; ctxt->flags |= XML_RELAXNG_IN_EXTERNALREF; docu->schema = xmlRelaxNGParseDocument(ctxt, root); ctxt->flags = oldflags; if ((docu->schema != NULL) && (docu->schema->topgrammar != NULL)) { docu->content = docu->schema->topgrammar->start; } /* * the externalRef may be reused in a different ns context */ if (newNs == 1) { xmlUnsetProp(root, BAD_CAST "ns"); } } def->content = docu->content; } else { def = NULL; } return (def); } /** * xmlRelaxNGParsePattern: * @ctxt: a Relax-NG parser context * @node: the pattern node. * * parse the content of a RelaxNG pattern node. * * Returns the definition pointer or NULL in case of error or if no * pattern is generated. */ static xmlRelaxNGDefinePtr xmlRelaxNGParsePattern(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node) { xmlRelaxNGDefinePtr def = NULL; if (node == NULL) { return (NULL); } if (IS_RELAXNG(node, "element")) { def = xmlRelaxNGParseElement(ctxt, node); } else if (IS_RELAXNG(node, "attribute")) { def = xmlRelaxNGParseAttribute(ctxt, node); } else if (IS_RELAXNG(node, "empty")) { def = xmlRelaxNGNewDefine(ctxt, node); if (def == NULL) return (NULL); def->type = XML_RELAXNG_EMPTY; if (node->children != NULL) { xmlRngPErr(ctxt, node, XML_RNGP_EMPTY_NOT_EMPTY, "empty: had a child node\n", NULL, NULL); } } else if (IS_RELAXNG(node, "text")) { def = xmlRelaxNGNewDefine(ctxt, node); if (def == NULL) return (NULL); def->type = XML_RELAXNG_TEXT; if (node->children != NULL) { xmlRngPErr(ctxt, node, XML_RNGP_TEXT_HAS_CHILD, "text: had a child node\n", NULL, NULL); } } else if (IS_RELAXNG(node, "zeroOrMore")) { def = xmlRelaxNGNewDefine(ctxt, node); if (def == NULL) return (NULL); def->type = XML_RELAXNG_ZEROORMORE; if (node->children == NULL) { xmlRngPErr(ctxt, node, XML_RNGP_EMPTY_CONSTRUCT, "Element %s is empty\n", node->name, NULL); } else { def->content = xmlRelaxNGParsePatterns(ctxt, node->children, 1); } } else if (IS_RELAXNG(node, "oneOrMore")) { def = xmlRelaxNGNewDefine(ctxt, node); if (def == NULL) return (NULL); def->type = XML_RELAXNG_ONEORMORE; if (node->children == NULL) { xmlRngPErr(ctxt, node, XML_RNGP_EMPTY_CONSTRUCT, "Element %s is empty\n", node->name, NULL); } else { def->content = xmlRelaxNGParsePatterns(ctxt, node->children, 1); } } else if (IS_RELAXNG(node, "optional")) { def = xmlRelaxNGNewDefine(ctxt, node); if (def == NULL) return (NULL); def->type = XML_RELAXNG_OPTIONAL; if (node->children == NULL) { xmlRngPErr(ctxt, node, XML_RNGP_EMPTY_CONSTRUCT, "Element %s is empty\n", node->name, NULL); } else { def->content = xmlRelaxNGParsePatterns(ctxt, node->children, 1); } } else if (IS_RELAXNG(node, "choice")) { def = xmlRelaxNGNewDefine(ctxt, node); if (def == NULL) return (NULL); def->type = XML_RELAXNG_CHOICE; if (node->children == NULL) { xmlRngPErr(ctxt, node, XML_RNGP_EMPTY_CONSTRUCT, "Element %s is empty\n", node->name, NULL); } else { def->content = xmlRelaxNGParsePatterns(ctxt, node->children, 0); } } else if (IS_RELAXNG(node, "group")) { def = xmlRelaxNGNewDefine(ctxt, node); if (def == NULL) return (NULL); def->type = XML_RELAXNG_GROUP; if (node->children == NULL) { xmlRngPErr(ctxt, node, XML_RNGP_EMPTY_CONSTRUCT, "Element %s is empty\n", node->name, NULL); } else { def->content = xmlRelaxNGParsePatterns(ctxt, node->children, 0); } } else if (IS_RELAXNG(node, "ref")) { def = xmlRelaxNGNewDefine(ctxt, node); if (def == NULL) return (NULL); def->type = XML_RELAXNG_REF; def->name = xmlGetProp(node, BAD_CAST "name"); if (def->name == NULL) { xmlRngPErr(ctxt, node, XML_RNGP_REF_NO_NAME, "ref has no name\n", NULL, NULL); } else { xmlRelaxNGNormExtSpace(def->name); if (xmlValidateNCName(def->name, 0)) { xmlRngPErr(ctxt, node, XML_RNGP_REF_NAME_INVALID, "ref name '%s' is not an NCName\n", def->name, NULL); } } if (node->children != NULL) { xmlRngPErr(ctxt, node, XML_RNGP_REF_NOT_EMPTY, "ref is not empty\n", NULL, NULL); } if (ctxt->grammar->refs == NULL) ctxt->grammar->refs = xmlHashCreate(10); if (ctxt->grammar->refs == NULL) { xmlRngPErr(ctxt, node, XML_RNGP_REF_CREATE_FAILED, "Could not create references hash\n", NULL, NULL); def = NULL; } else { int tmp; tmp = xmlHashAddEntry(ctxt->grammar->refs, def->name, def); if (tmp < 0) { xmlRelaxNGDefinePtr prev; prev = (xmlRelaxNGDefinePtr) xmlHashLookup(ctxt->grammar->refs, def->name); if (prev == NULL) { if (def->name != NULL) { xmlRngPErr(ctxt, node, XML_RNGP_REF_CREATE_FAILED, "Error refs definitions '%s'\n", def->name, NULL); } else { xmlRngPErr(ctxt, node, XML_RNGP_REF_CREATE_FAILED, "Error refs definitions\n", NULL, NULL); } def = NULL; } else { def->nextHash = prev->nextHash; prev->nextHash = def; } } } } else if (IS_RELAXNG(node, "data")) { def = xmlRelaxNGParseData(ctxt, node); } else if (IS_RELAXNG(node, "value")) { def = xmlRelaxNGParseValue(ctxt, node); } else if (IS_RELAXNG(node, "list")) { def = xmlRelaxNGNewDefine(ctxt, node); if (def == NULL) return (NULL); def->type = XML_RELAXNG_LIST; if (node->children == NULL) { xmlRngPErr(ctxt, node, XML_RNGP_EMPTY_CONSTRUCT, "Element %s is empty\n", node->name, NULL); } else { def->content = xmlRelaxNGParsePatterns(ctxt, node->children, 0); } } else if (IS_RELAXNG(node, "interleave")) { def = xmlRelaxNGParseInterleave(ctxt, node); } else if (IS_RELAXNG(node, "externalRef")) { def = xmlRelaxNGProcessExternalRef(ctxt, node); } else if (IS_RELAXNG(node, "notAllowed")) { def = xmlRelaxNGNewDefine(ctxt, node); if (def == NULL) return (NULL); def->type = XML_RELAXNG_NOT_ALLOWED; if (node->children != NULL) { xmlRngPErr(ctxt, node, XML_RNGP_NOTALLOWED_NOT_EMPTY, "xmlRelaxNGParse: notAllowed element is not empty\n", NULL, NULL); } } else if (IS_RELAXNG(node, "grammar")) { xmlRelaxNGGrammarPtr grammar, old; xmlRelaxNGGrammarPtr oldparent; #ifdef DEBUG_GRAMMAR xmlGenericError(xmlGenericErrorContext, "Found pattern\n"); #endif oldparent = ctxt->parentgrammar; old = ctxt->grammar; ctxt->parentgrammar = old; grammar = xmlRelaxNGParseGrammar(ctxt, node->children); if (old != NULL) { ctxt->grammar = old; ctxt->parentgrammar = oldparent; #if 0 if (grammar != NULL) { grammar->next = old->next; old->next = grammar; } #endif } if (grammar != NULL) def = grammar->start; else def = NULL; } else if (IS_RELAXNG(node, "parentRef")) { if (ctxt->parentgrammar == NULL) { xmlRngPErr(ctxt, node, XML_RNGP_PARENTREF_NO_PARENT, "Use of parentRef without a parent grammar\n", NULL, NULL); return (NULL); } def = xmlRelaxNGNewDefine(ctxt, node); if (def == NULL) return (NULL); def->type = XML_RELAXNG_PARENTREF; def->name = xmlGetProp(node, BAD_CAST "name"); if (def->name == NULL) { xmlRngPErr(ctxt, node, XML_RNGP_PARENTREF_NO_NAME, "parentRef has no name\n", NULL, NULL); } else { xmlRelaxNGNormExtSpace(def->name); if (xmlValidateNCName(def->name, 0)) { xmlRngPErr(ctxt, node, XML_RNGP_PARENTREF_NAME_INVALID, "parentRef name '%s' is not an NCName\n", def->name, NULL); } } if (node->children != NULL) { xmlRngPErr(ctxt, node, XML_RNGP_PARENTREF_NOT_EMPTY, "parentRef is not empty\n", NULL, NULL); } if (ctxt->parentgrammar->refs == NULL) ctxt->parentgrammar->refs = xmlHashCreate(10); if (ctxt->parentgrammar->refs == NULL) { xmlRngPErr(ctxt, node, XML_RNGP_PARENTREF_CREATE_FAILED, "Could not create references hash\n", NULL, NULL); def = NULL; } else if (def->name != NULL) { int tmp; tmp = xmlHashAddEntry(ctxt->parentgrammar->refs, def->name, def); if (tmp < 0) { xmlRelaxNGDefinePtr prev; prev = (xmlRelaxNGDefinePtr) xmlHashLookup(ctxt->parentgrammar->refs, def->name); if (prev == NULL) { xmlRngPErr(ctxt, node, XML_RNGP_PARENTREF_CREATE_FAILED, "Internal error parentRef definitions '%s'\n", def->name, NULL); def = NULL; } else { def->nextHash = prev->nextHash; prev->nextHash = def; } } } } else if (IS_RELAXNG(node, "mixed")) { if (node->children == NULL) { xmlRngPErr(ctxt, node, XML_RNGP_EMPTY_CONSTRUCT, "Mixed is empty\n", NULL, NULL); def = NULL; } else { def = xmlRelaxNGParseInterleave(ctxt, node); if (def != NULL) { xmlRelaxNGDefinePtr tmp; if ((def->content != NULL) && (def->content->next != NULL)) { tmp = xmlRelaxNGNewDefine(ctxt, node); if (tmp != NULL) { tmp->type = XML_RELAXNG_GROUP; tmp->content = def->content; def->content = tmp; } } tmp = xmlRelaxNGNewDefine(ctxt, node); if (tmp == NULL) return (def); tmp->type = XML_RELAXNG_TEXT; tmp->next = def->content; def->content = tmp; } } } else { xmlRngPErr(ctxt, node, XML_RNGP_UNKNOWN_CONSTRUCT, "Unexpected node %s is not a pattern\n", node->name, NULL); def = NULL; } return (def); } /** * xmlRelaxNGParseAttribute: * @ctxt: a Relax-NG parser context * @node: the element node * * parse the content of a RelaxNG attribute node. * * Returns the definition pointer or NULL in case of error. */ static xmlRelaxNGDefinePtr xmlRelaxNGParseAttribute(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node) { xmlRelaxNGDefinePtr ret, cur; xmlNodePtr child; int old_flags; ret = xmlRelaxNGNewDefine(ctxt, node); if (ret == NULL) return (NULL); ret->type = XML_RELAXNG_ATTRIBUTE; ret->parent = ctxt->def; child = node->children; if (child == NULL) { xmlRngPErr(ctxt, node, XML_RNGP_ATTRIBUTE_EMPTY, "xmlRelaxNGParseattribute: attribute has no children\n", NULL, NULL); return (ret); } old_flags = ctxt->flags; ctxt->flags |= XML_RELAXNG_IN_ATTRIBUTE; cur = xmlRelaxNGParseNameClass(ctxt, child, ret); if (cur != NULL) child = child->next; if (child != NULL) { cur = xmlRelaxNGParsePattern(ctxt, child); if (cur != NULL) { switch (cur->type) { case XML_RELAXNG_EMPTY: case XML_RELAXNG_NOT_ALLOWED: case XML_RELAXNG_TEXT: case XML_RELAXNG_ELEMENT: case XML_RELAXNG_DATATYPE: case XML_RELAXNG_VALUE: case XML_RELAXNG_LIST: case XML_RELAXNG_REF: case XML_RELAXNG_PARENTREF: case XML_RELAXNG_EXTERNALREF: case XML_RELAXNG_DEF: case XML_RELAXNG_ONEORMORE: case XML_RELAXNG_ZEROORMORE: case XML_RELAXNG_OPTIONAL: case XML_RELAXNG_CHOICE: case XML_RELAXNG_GROUP: case XML_RELAXNG_INTERLEAVE: case XML_RELAXNG_ATTRIBUTE: ret->content = cur; cur->parent = ret; break; case XML_RELAXNG_START: case XML_RELAXNG_PARAM: case XML_RELAXNG_EXCEPT: xmlRngPErr(ctxt, node, XML_RNGP_ATTRIBUTE_CONTENT, "attribute has invalid content\n", NULL, NULL); break; case XML_RELAXNG_NOOP: xmlRngPErr(ctxt, node, XML_RNGP_ATTRIBUTE_NOOP, "RNG Internal error, noop found in attribute\n", NULL, NULL); break; } } child = child->next; } if (child != NULL) { xmlRngPErr(ctxt, node, XML_RNGP_ATTRIBUTE_CHILDREN, "attribute has multiple children\n", NULL, NULL); } ctxt->flags = old_flags; return (ret); } /** * xmlRelaxNGParseExceptNameClass: * @ctxt: a Relax-NG parser context * @node: the except node * @attr: 1 if within an attribute, 0 if within an element * * parse the content of a RelaxNG nameClass node. * * Returns the definition pointer or NULL in case of error. */ static xmlRelaxNGDefinePtr xmlRelaxNGParseExceptNameClass(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node, int attr) { xmlRelaxNGDefinePtr ret, cur, last = NULL; xmlNodePtr child; if (!IS_RELAXNG(node, "except")) { xmlRngPErr(ctxt, node, XML_RNGP_EXCEPT_MISSING, "Expecting an except node\n", NULL, NULL); return (NULL); } if (node->next != NULL) { xmlRngPErr(ctxt, node, XML_RNGP_EXCEPT_MULTIPLE, "exceptNameClass allows only a single except node\n", NULL, NULL); } if (node->children == NULL) { xmlRngPErr(ctxt, node, XML_RNGP_EXCEPT_EMPTY, "except has no content\n", NULL, NULL); return (NULL); } ret = xmlRelaxNGNewDefine(ctxt, node); if (ret == NULL) return (NULL); ret->type = XML_RELAXNG_EXCEPT; child = node->children; while (child != NULL) { cur = xmlRelaxNGNewDefine(ctxt, child); if (cur == NULL) break; if (attr) cur->type = XML_RELAXNG_ATTRIBUTE; else cur->type = XML_RELAXNG_ELEMENT; if (xmlRelaxNGParseNameClass(ctxt, child, cur) != NULL) { if (last == NULL) { ret->content = cur; } else { last->next = cur; } last = cur; } child = child->next; } return (ret); } /** * xmlRelaxNGParseNameClass: * @ctxt: a Relax-NG parser context * @node: the nameClass node * @def: the current definition * * parse the content of a RelaxNG nameClass node. * * Returns the definition pointer or NULL in case of error. */ static xmlRelaxNGDefinePtr xmlRelaxNGParseNameClass(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node, xmlRelaxNGDefinePtr def) { xmlRelaxNGDefinePtr ret, tmp; xmlChar *val; ret = def; if ((IS_RELAXNG(node, "name")) || (IS_RELAXNG(node, "anyName")) || (IS_RELAXNG(node, "nsName"))) { if ((def->type != XML_RELAXNG_ELEMENT) && (def->type != XML_RELAXNG_ATTRIBUTE)) { ret = xmlRelaxNGNewDefine(ctxt, node); if (ret == NULL) return (NULL); ret->parent = def; if (ctxt->flags & XML_RELAXNG_IN_ATTRIBUTE) ret->type = XML_RELAXNG_ATTRIBUTE; else ret->type = XML_RELAXNG_ELEMENT; } } if (IS_RELAXNG(node, "name")) { val = xmlNodeGetContent(node); xmlRelaxNGNormExtSpace(val); if (xmlValidateNCName(val, 0)) { if (node->parent != NULL) xmlRngPErr(ctxt, node, XML_RNGP_ELEMENT_NAME, "Element %s name '%s' is not an NCName\n", node->parent->name, val); else xmlRngPErr(ctxt, node, XML_RNGP_ELEMENT_NAME, "name '%s' is not an NCName\n", val, NULL); } ret->name = val; val = xmlGetProp(node, BAD_CAST "ns"); ret->ns = val; if ((ctxt->flags & XML_RELAXNG_IN_ATTRIBUTE) && (val != NULL) && (xmlStrEqual(val, BAD_CAST "http://www.w3.org/2000/xmlns"))) { xmlRngPErr(ctxt, node, XML_RNGP_XML_NS, "Attribute with namespace '%s' is not allowed\n", val, NULL); } if ((ctxt->flags & XML_RELAXNG_IN_ATTRIBUTE) && (val != NULL) && (val[0] == 0) && (xmlStrEqual(ret->name, BAD_CAST "xmlns"))) { xmlRngPErr(ctxt, node, XML_RNGP_XMLNS_NAME, "Attribute with QName 'xmlns' is not allowed\n", val, NULL); } } else if (IS_RELAXNG(node, "anyName")) { ret->name = NULL; ret->ns = NULL; if (node->children != NULL) { ret->nameClass = xmlRelaxNGParseExceptNameClass(ctxt, node->children, (def->type == XML_RELAXNG_ATTRIBUTE)); } } else if (IS_RELAXNG(node, "nsName")) { ret->name = NULL; ret->ns = xmlGetProp(node, BAD_CAST "ns"); if (ret->ns == NULL) { xmlRngPErr(ctxt, node, XML_RNGP_NSNAME_NO_NS, "nsName has no ns attribute\n", NULL, NULL); } if ((ctxt->flags & XML_RELAXNG_IN_ATTRIBUTE) && (ret->ns != NULL) && (xmlStrEqual (ret->ns, BAD_CAST "http://www.w3.org/2000/xmlns"))) { xmlRngPErr(ctxt, node, XML_RNGP_XML_NS, "Attribute with namespace '%s' is not allowed\n", ret->ns, NULL); } if (node->children != NULL) { ret->nameClass = xmlRelaxNGParseExceptNameClass(ctxt, node->children, (def->type == XML_RELAXNG_ATTRIBUTE)); } } else if (IS_RELAXNG(node, "choice")) { xmlNodePtr child; xmlRelaxNGDefinePtr last = NULL; ret = xmlRelaxNGNewDefine(ctxt, node); if (ret == NULL) return (NULL); ret->parent = def; ret->type = XML_RELAXNG_CHOICE; if (node->children == NULL) { xmlRngPErr(ctxt, node, XML_RNGP_CHOICE_EMPTY, "Element choice is empty\n", NULL, NULL); } else { child = node->children; while (child != NULL) { tmp = xmlRelaxNGParseNameClass(ctxt, child, ret); if (tmp != NULL) { if (last == NULL) { last = ret->nameClass = tmp; } else { last->next = tmp; last = tmp; } } child = child->next; } } } else { xmlRngPErr(ctxt, node, XML_RNGP_CHOICE_CONTENT, "expecting name, anyName, nsName or choice : got %s\n", node->name, NULL); return (NULL); } if (ret != def) { if (def->nameClass == NULL) { def->nameClass = ret; } else { tmp = def->nameClass; while (tmp->next != NULL) { tmp = tmp->next; } tmp->next = ret; } } return (ret); } /** * xmlRelaxNGParseElement: * @ctxt: a Relax-NG parser context * @node: the element node * * parse the content of a RelaxNG element node. * * Returns the definition pointer or NULL in case of error. */ static xmlRelaxNGDefinePtr xmlRelaxNGParseElement(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node) { xmlRelaxNGDefinePtr ret, cur, last; xmlNodePtr child; const xmlChar *olddefine; ret = xmlRelaxNGNewDefine(ctxt, node); if (ret == NULL) return (NULL); ret->type = XML_RELAXNG_ELEMENT; ret->parent = ctxt->def; child = node->children; if (child == NULL) { xmlRngPErr(ctxt, node, XML_RNGP_ELEMENT_EMPTY, "xmlRelaxNGParseElement: element has no children\n", NULL, NULL); return (ret); } cur = xmlRelaxNGParseNameClass(ctxt, child, ret); if (cur != NULL) child = child->next; if (child == NULL) { xmlRngPErr(ctxt, node, XML_RNGP_ELEMENT_NO_CONTENT, "xmlRelaxNGParseElement: element has no content\n", NULL, NULL); return (ret); } olddefine = ctxt->define; ctxt->define = NULL; last = NULL; while (child != NULL) { cur = xmlRelaxNGParsePattern(ctxt, child); if (cur != NULL) { cur->parent = ret; switch (cur->type) { case XML_RELAXNG_EMPTY: case XML_RELAXNG_NOT_ALLOWED: case XML_RELAXNG_TEXT: case XML_RELAXNG_ELEMENT: case XML_RELAXNG_DATATYPE: case XML_RELAXNG_VALUE: case XML_RELAXNG_LIST: case XML_RELAXNG_REF: case XML_RELAXNG_PARENTREF: case XML_RELAXNG_EXTERNALREF: case XML_RELAXNG_DEF: case XML_RELAXNG_ZEROORMORE: case XML_RELAXNG_ONEORMORE: case XML_RELAXNG_OPTIONAL: case XML_RELAXNG_CHOICE: case XML_RELAXNG_GROUP: case XML_RELAXNG_INTERLEAVE: if (last == NULL) { ret->content = last = cur; } else { if ((last->type == XML_RELAXNG_ELEMENT) && (ret->content == last)) { ret->content = xmlRelaxNGNewDefine(ctxt, node); if (ret->content != NULL) { ret->content->type = XML_RELAXNG_GROUP; ret->content->content = last; } else { ret->content = last; } } last->next = cur; last = cur; } break; case XML_RELAXNG_ATTRIBUTE: cur->next = ret->attrs; ret->attrs = cur; break; case XML_RELAXNG_START: xmlRngPErr(ctxt, node, XML_RNGP_ELEMENT_CONTENT, "RNG Internal error, start found in element\n", NULL, NULL); break; case XML_RELAXNG_PARAM: xmlRngPErr(ctxt, node, XML_RNGP_ELEMENT_CONTENT, "RNG Internal error, param found in element\n", NULL, NULL); break; case XML_RELAXNG_EXCEPT: xmlRngPErr(ctxt, node, XML_RNGP_ELEMENT_CONTENT, "RNG Internal error, except found in element\n", NULL, NULL); break; case XML_RELAXNG_NOOP: xmlRngPErr(ctxt, node, XML_RNGP_ELEMENT_CONTENT, "RNG Internal error, noop found in element\n", NULL, NULL); break; } } child = child->next; } ctxt->define = olddefine; return (ret); } /** * xmlRelaxNGParsePatterns: * @ctxt: a Relax-NG parser context * @nodes: list of nodes * @group: use an implicit for elements * * parse the content of a RelaxNG start node. * * Returns the definition pointer or NULL in case of error. */ static xmlRelaxNGDefinePtr xmlRelaxNGParsePatterns(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr nodes, int group) { xmlRelaxNGDefinePtr def = NULL, last = NULL, cur, parent; parent = ctxt->def; while (nodes != NULL) { if (IS_RELAXNG(nodes, "element")) { cur = xmlRelaxNGParseElement(ctxt, nodes); if (def == NULL) { def = last = cur; } else { if ((group == 1) && (def->type == XML_RELAXNG_ELEMENT) && (def == last)) { def = xmlRelaxNGNewDefine(ctxt, nodes); def->type = XML_RELAXNG_GROUP; def->content = last; } last->next = cur; last = cur; } cur->parent = parent; } else { cur = xmlRelaxNGParsePattern(ctxt, nodes); if (cur != NULL) { if (def == NULL) { def = last = cur; } else { last->next = cur; last = cur; } } } nodes = nodes->next; } return (def); } /** * xmlRelaxNGParseStart: * @ctxt: a Relax-NG parser context * @nodes: start children nodes * * parse the content of a RelaxNG start node. * * Returns 0 in case of success, -1 in case of error */ static int xmlRelaxNGParseStart(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr nodes) { int ret = 0; xmlRelaxNGDefinePtr def = NULL, last; if (nodes == NULL) { xmlRngPErr(ctxt, nodes, XML_RNGP_START_EMPTY, "start has no children\n", NULL, NULL); return (-1); } if (IS_RELAXNG(nodes, "empty")) { def = xmlRelaxNGNewDefine(ctxt, nodes); if (def == NULL) return (-1); def->type = XML_RELAXNG_EMPTY; if (nodes->children != NULL) { xmlRngPErr(ctxt, nodes, XML_RNGP_EMPTY_CONTENT, "element empty is not empty\n", NULL, NULL); } } else if (IS_RELAXNG(nodes, "notAllowed")) { def = xmlRelaxNGNewDefine(ctxt, nodes); if (def == NULL) return (-1); def->type = XML_RELAXNG_NOT_ALLOWED; if (nodes->children != NULL) { xmlRngPErr(ctxt, nodes, XML_RNGP_NOTALLOWED_NOT_EMPTY, "element notAllowed is not empty\n", NULL, NULL); } } else { def = xmlRelaxNGParsePatterns(ctxt, nodes, 1); } if (ctxt->grammar->start != NULL) { last = ctxt->grammar->start; while (last->next != NULL) last = last->next; last->next = def; } else { ctxt->grammar->start = def; } nodes = nodes->next; if (nodes != NULL) { xmlRngPErr(ctxt, nodes, XML_RNGP_START_CONTENT, "start more than one children\n", NULL, NULL); return (-1); } return (ret); } /** * xmlRelaxNGParseGrammarContent: * @ctxt: a Relax-NG parser context * @nodes: grammar children nodes * * parse the content of a RelaxNG grammar node. * * Returns 0 in case of success, -1 in case of error */ static int xmlRelaxNGParseGrammarContent(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr nodes) { int ret = 0, tmp; if (nodes == NULL) { xmlRngPErr(ctxt, nodes, XML_RNGP_GRAMMAR_EMPTY, "grammar has no children\n", NULL, NULL); return (-1); } while (nodes != NULL) { if (IS_RELAXNG(nodes, "start")) { if (nodes->children == NULL) { xmlRngPErr(ctxt, nodes, XML_RNGP_START_EMPTY, "start has no children\n", NULL, NULL); } else { tmp = xmlRelaxNGParseStart(ctxt, nodes->children); if (tmp != 0) ret = -1; } } else if (IS_RELAXNG(nodes, "define")) { tmp = xmlRelaxNGParseDefine(ctxt, nodes); if (tmp != 0) ret = -1; } else if (IS_RELAXNG(nodes, "include")) { tmp = xmlRelaxNGParseInclude(ctxt, nodes); if (tmp != 0) ret = -1; } else { xmlRngPErr(ctxt, nodes, XML_RNGP_GRAMMAR_CONTENT, "grammar has unexpected child %s\n", nodes->name, NULL); ret = -1; } nodes = nodes->next; } return (ret); } /** * xmlRelaxNGCheckReference: * @ref: the ref * @ctxt: a Relax-NG parser context * @name: the name associated to the defines * * Applies the 4.17. combine attribute rule for all the define * element of a given grammar using the same name. */ static void xmlRelaxNGCheckReference(xmlRelaxNGDefinePtr ref, xmlRelaxNGParserCtxtPtr ctxt, const xmlChar * name) { xmlRelaxNGGrammarPtr grammar; xmlRelaxNGDefinePtr def, cur; grammar = ctxt->grammar; if (grammar == NULL) { xmlRngPErr(ctxt, ref->node, XML_ERR_INTERNAL_ERROR, "Internal error: no grammar in CheckReference %s\n", name, NULL); return; } if (ref->content != NULL) { xmlRngPErr(ctxt, ref->node, XML_ERR_INTERNAL_ERROR, "Internal error: reference has content in CheckReference %s\n", name, NULL); return; } if (grammar->defs != NULL) { def = xmlHashLookup(grammar->defs, name); if (def != NULL) { cur = ref; while (cur != NULL) { cur->content = def; cur = cur->nextHash; } } else { xmlRngPErr(ctxt, ref->node, XML_RNGP_REF_NO_DEF, "Reference %s has no matching definition\n", name, NULL); } } else { xmlRngPErr(ctxt, ref->node, XML_RNGP_REF_NO_DEF, "Reference %s has no matching definition\n", name, NULL); } } /** * xmlRelaxNGCheckCombine: * @define: the define(s) list * @ctxt: a Relax-NG parser context * @name: the name associated to the defines * * Applies the 4.17. combine attribute rule for all the define * element of a given grammar using the same name. */ static void xmlRelaxNGCheckCombine(xmlRelaxNGDefinePtr define, xmlRelaxNGParserCtxtPtr ctxt, const xmlChar * name) { xmlChar *combine; int choiceOrInterleave = -1; int missing = 0; xmlRelaxNGDefinePtr cur, last, tmp, tmp2; if (define->nextHash == NULL) return; cur = define; while (cur != NULL) { combine = xmlGetProp(cur->node, BAD_CAST "combine"); if (combine != NULL) { if (xmlStrEqual(combine, BAD_CAST "choice")) { if (choiceOrInterleave == -1) choiceOrInterleave = 1; else if (choiceOrInterleave == 0) { xmlRngPErr(ctxt, define->node, XML_RNGP_DEF_CHOICE_AND_INTERLEAVE, "Defines for %s use both 'choice' and 'interleave'\n", name, NULL); } } else if (xmlStrEqual(combine, BAD_CAST "interleave")) { if (choiceOrInterleave == -1) choiceOrInterleave = 0; else if (choiceOrInterleave == 1) { xmlRngPErr(ctxt, define->node, XML_RNGP_DEF_CHOICE_AND_INTERLEAVE, "Defines for %s use both 'choice' and 'interleave'\n", name, NULL); } } else { xmlRngPErr(ctxt, define->node, XML_RNGP_UNKNOWN_COMBINE, "Defines for %s use unknown combine value '%s''\n", name, combine); } xmlFree(combine); } else { if (missing == 0) missing = 1; else { xmlRngPErr(ctxt, define->node, XML_RNGP_NEED_COMBINE, "Some defines for %s needs the combine attribute\n", name, NULL); } } cur = cur->nextHash; } #ifdef DEBUG xmlGenericError(xmlGenericErrorContext, "xmlRelaxNGCheckCombine(): merging %s defines: %d\n", name, choiceOrInterleave); #endif if (choiceOrInterleave == -1) choiceOrInterleave = 0; cur = xmlRelaxNGNewDefine(ctxt, define->node); if (cur == NULL) return; if (choiceOrInterleave == 0) cur->type = XML_RELAXNG_INTERLEAVE; else cur->type = XML_RELAXNG_CHOICE; tmp = define; last = NULL; while (tmp != NULL) { if (tmp->content != NULL) { if (tmp->content->next != NULL) { /* * we need first to create a wrapper. */ tmp2 = xmlRelaxNGNewDefine(ctxt, tmp->content->node); if (tmp2 == NULL) break; tmp2->type = XML_RELAXNG_GROUP; tmp2->content = tmp->content; } else { tmp2 = tmp->content; } if (last == NULL) { cur->content = tmp2; } else { last->next = tmp2; } last = tmp2; } tmp->content = cur; tmp = tmp->nextHash; } define->content = cur; if (choiceOrInterleave == 0) { if (ctxt->interleaves == NULL) ctxt->interleaves = xmlHashCreate(10); if (ctxt->interleaves == NULL) { xmlRngPErr(ctxt, define->node, XML_RNGP_INTERLEAVE_CREATE_FAILED, "Failed to create interleaves hash table\n", NULL, NULL); } else { char tmpname[32]; snprintf(tmpname, 32, "interleave%d", ctxt->nbInterleaves++); if (xmlHashAddEntry(ctxt->interleaves, BAD_CAST tmpname, cur) < 0) { xmlRngPErr(ctxt, define->node, XML_RNGP_INTERLEAVE_CREATE_FAILED, "Failed to add %s to hash table\n", (const xmlChar *) tmpname, NULL); } } } } /** * xmlRelaxNGCombineStart: * @ctxt: a Relax-NG parser context * @grammar: the grammar * * Applies the 4.17. combine rule for all the start * element of a given grammar. */ static void xmlRelaxNGCombineStart(xmlRelaxNGParserCtxtPtr ctxt, xmlRelaxNGGrammarPtr grammar) { xmlRelaxNGDefinePtr starts; xmlChar *combine; int choiceOrInterleave = -1; int missing = 0; xmlRelaxNGDefinePtr cur; starts = grammar->start; if ((starts == NULL) || (starts->next == NULL)) return; cur = starts; while (cur != NULL) { if ((cur->node == NULL) || (cur->node->parent == NULL) || (!xmlStrEqual(cur->node->parent->name, BAD_CAST "start"))) { combine = NULL; xmlRngPErr(ctxt, cur->node, XML_RNGP_START_MISSING, "Internal error: start element not found\n", NULL, NULL); } else { combine = xmlGetProp(cur->node->parent, BAD_CAST "combine"); } if (combine != NULL) { if (xmlStrEqual(combine, BAD_CAST "choice")) { if (choiceOrInterleave == -1) choiceOrInterleave = 1; else if (choiceOrInterleave == 0) { xmlRngPErr(ctxt, cur->node, XML_RNGP_START_CHOICE_AND_INTERLEAVE, " use both 'choice' and 'interleave'\n", NULL, NULL); } } else if (xmlStrEqual(combine, BAD_CAST "interleave")) { if (choiceOrInterleave == -1) choiceOrInterleave = 0; else if (choiceOrInterleave == 1) { xmlRngPErr(ctxt, cur->node, XML_RNGP_START_CHOICE_AND_INTERLEAVE, " use both 'choice' and 'interleave'\n", NULL, NULL); } } else { xmlRngPErr(ctxt, cur->node, XML_RNGP_UNKNOWN_COMBINE, " uses unknown combine value '%s''\n", combine, NULL); } xmlFree(combine); } else { if (missing == 0) missing = 1; else { xmlRngPErr(ctxt, cur->node, XML_RNGP_NEED_COMBINE, "Some element miss the combine attribute\n", NULL, NULL); } } cur = cur->next; } #ifdef DEBUG xmlGenericError(xmlGenericErrorContext, "xmlRelaxNGCombineStart(): merging : %d\n", choiceOrInterleave); #endif if (choiceOrInterleave == -1) choiceOrInterleave = 0; cur = xmlRelaxNGNewDefine(ctxt, starts->node); if (cur == NULL) return; if (choiceOrInterleave == 0) cur->type = XML_RELAXNG_INTERLEAVE; else cur->type = XML_RELAXNG_CHOICE; cur->content = grammar->start; grammar->start = cur; if (choiceOrInterleave == 0) { if (ctxt->interleaves == NULL) ctxt->interleaves = xmlHashCreate(10); if (ctxt->interleaves == NULL) { xmlRngPErr(ctxt, cur->node, XML_RNGP_INTERLEAVE_CREATE_FAILED, "Failed to create interleaves hash table\n", NULL, NULL); } else { char tmpname[32]; snprintf(tmpname, 32, "interleave%d", ctxt->nbInterleaves++); if (xmlHashAddEntry(ctxt->interleaves, BAD_CAST tmpname, cur) < 0) { xmlRngPErr(ctxt, cur->node, XML_RNGP_INTERLEAVE_CREATE_FAILED, "Failed to add %s to hash table\n", (const xmlChar *) tmpname, NULL); } } } } /** * xmlRelaxNGCheckCycles: * @ctxt: a Relax-NG parser context * @nodes: grammar children nodes * @depth: the counter * * Check for cycles. * * Returns 0 if check passed, and -1 in case of error */ static int xmlRelaxNGCheckCycles(xmlRelaxNGParserCtxtPtr ctxt, xmlRelaxNGDefinePtr cur, int depth) { int ret = 0; while ((ret == 0) && (cur != NULL)) { if ((cur->type == XML_RELAXNG_REF) || (cur->type == XML_RELAXNG_PARENTREF)) { if (cur->depth == -1) { cur->depth = depth; ret = xmlRelaxNGCheckCycles(ctxt, cur->content, depth); cur->depth = -2; } else if (depth == cur->depth) { xmlRngPErr(ctxt, cur->node, XML_RNGP_REF_CYCLE, "Detected a cycle in %s references\n", cur->name, NULL); return (-1); } } else if (cur->type == XML_RELAXNG_ELEMENT) { ret = xmlRelaxNGCheckCycles(ctxt, cur->content, depth + 1); } else { ret = xmlRelaxNGCheckCycles(ctxt, cur->content, depth); } cur = cur->next; } return (ret); } /** * xmlRelaxNGTryUnlink: * @ctxt: a Relax-NG parser context * @cur: the definition to unlink * @parent: the parent definition * @prev: the previous sibling definition * * Try to unlink a definition. If not possble make it a NOOP * * Returns the new prev definition */ static xmlRelaxNGDefinePtr xmlRelaxNGTryUnlink(xmlRelaxNGParserCtxtPtr ctxt ATTRIBUTE_UNUSED, xmlRelaxNGDefinePtr cur, xmlRelaxNGDefinePtr parent, xmlRelaxNGDefinePtr prev) { if (prev != NULL) { prev->next = cur->next; } else { if (parent != NULL) { if (parent->content == cur) parent->content = cur->next; else if (parent->attrs == cur) parent->attrs = cur->next; else if (parent->nameClass == cur) parent->nameClass = cur->next; } else { cur->type = XML_RELAXNG_NOOP; prev = cur; } } return (prev); } /** * xmlRelaxNGSimplify: * @ctxt: a Relax-NG parser context * @nodes: grammar children nodes * * Check for simplification of empty and notAllowed */ static void xmlRelaxNGSimplify(xmlRelaxNGParserCtxtPtr ctxt, xmlRelaxNGDefinePtr cur, xmlRelaxNGDefinePtr parent) { xmlRelaxNGDefinePtr prev = NULL; while (cur != NULL) { if ((cur->type == XML_RELAXNG_REF) || (cur->type == XML_RELAXNG_PARENTREF)) { if (cur->depth != -3) { cur->depth = -3; xmlRelaxNGSimplify(ctxt, cur->content, cur); } } else if (cur->type == XML_RELAXNG_NOT_ALLOWED) { cur->parent = parent; if ((parent != NULL) && ((parent->type == XML_RELAXNG_ATTRIBUTE) || (parent->type == XML_RELAXNG_LIST) || (parent->type == XML_RELAXNG_GROUP) || (parent->type == XML_RELAXNG_INTERLEAVE) || (parent->type == XML_RELAXNG_ONEORMORE) || (parent->type == XML_RELAXNG_ZEROORMORE))) { parent->type = XML_RELAXNG_NOT_ALLOWED; break; } if ((parent != NULL) && (parent->type == XML_RELAXNG_CHOICE)) { prev = xmlRelaxNGTryUnlink(ctxt, cur, parent, prev); } else prev = cur; } else if (cur->type == XML_RELAXNG_EMPTY) { cur->parent = parent; if ((parent != NULL) && ((parent->type == XML_RELAXNG_ONEORMORE) || (parent->type == XML_RELAXNG_ZEROORMORE))) { parent->type = XML_RELAXNG_EMPTY; break; } if ((parent != NULL) && ((parent->type == XML_RELAXNG_GROUP) || (parent->type == XML_RELAXNG_INTERLEAVE))) { prev = xmlRelaxNGTryUnlink(ctxt, cur, parent, prev); } else prev = cur; } else { cur->parent = parent; if (cur->content != NULL) xmlRelaxNGSimplify(ctxt, cur->content, cur); if ((cur->type != XML_RELAXNG_VALUE) && (cur->attrs != NULL)) xmlRelaxNGSimplify(ctxt, cur->attrs, cur); if (cur->nameClass != NULL) xmlRelaxNGSimplify(ctxt, cur->nameClass, cur); /* * On Elements, try to move attribute only generating rules on * the attrs rules. */ if (cur->type == XML_RELAXNG_ELEMENT) { int attronly; xmlRelaxNGDefinePtr tmp, pre; while (cur->content != NULL) { attronly = xmlRelaxNGGenerateAttributes(ctxt, cur->content); if (attronly == 1) { /* * migrate cur->content to attrs */ tmp = cur->content; cur->content = tmp->next; tmp->next = cur->attrs; cur->attrs = tmp; } else { /* * cur->content can generate elements or text */ break; } } pre = cur->content; while ((pre != NULL) && (pre->next != NULL)) { tmp = pre->next; attronly = xmlRelaxNGGenerateAttributes(ctxt, tmp); if (attronly == 1) { /* * migrate tmp to attrs */ pre->next = tmp->next; tmp->next = cur->attrs; cur->attrs = tmp; } else { pre = tmp; } } } /* * This may result in a simplification */ if ((cur->type == XML_RELAXNG_GROUP) || (cur->type == XML_RELAXNG_INTERLEAVE)) { if (cur->content == NULL) cur->type = XML_RELAXNG_EMPTY; else if (cur->content->next == NULL) { if ((parent == NULL) && (prev == NULL)) { cur->type = XML_RELAXNG_NOOP; } else if (prev == NULL) { parent->content = cur->content; cur->content->next = cur->next; cur = cur->content; } else { cur->content->next = cur->next; prev->next = cur->content; cur = cur->content; } } } /* * the current node may have been transformed back */ if ((cur->type == XML_RELAXNG_EXCEPT) && (cur->content != NULL) && (cur->content->type == XML_RELAXNG_NOT_ALLOWED)) { prev = xmlRelaxNGTryUnlink(ctxt, cur, parent, prev); } else if (cur->type == XML_RELAXNG_NOT_ALLOWED) { if ((parent != NULL) && ((parent->type == XML_RELAXNG_ATTRIBUTE) || (parent->type == XML_RELAXNG_LIST) || (parent->type == XML_RELAXNG_GROUP) || (parent->type == XML_RELAXNG_INTERLEAVE) || (parent->type == XML_RELAXNG_ONEORMORE) || (parent->type == XML_RELAXNG_ZEROORMORE))) { parent->type = XML_RELAXNG_NOT_ALLOWED; break; } if ((parent != NULL) && (parent->type == XML_RELAXNG_CHOICE)) { prev = xmlRelaxNGTryUnlink(ctxt, cur, parent, prev); } else prev = cur; } else if (cur->type == XML_RELAXNG_EMPTY) { if ((parent != NULL) && ((parent->type == XML_RELAXNG_ONEORMORE) || (parent->type == XML_RELAXNG_ZEROORMORE))) { parent->type = XML_RELAXNG_EMPTY; break; } if ((parent != NULL) && ((parent->type == XML_RELAXNG_GROUP) || (parent->type == XML_RELAXNG_INTERLEAVE) || (parent->type == XML_RELAXNG_CHOICE))) { prev = xmlRelaxNGTryUnlink(ctxt, cur, parent, prev); } else prev = cur; } else { prev = cur; } } cur = cur->next; } } /** * xmlRelaxNGGroupContentType: * @ct1: the first content type * @ct2: the second content type * * Try to group 2 content types * * Returns the content type */ static xmlRelaxNGContentType xmlRelaxNGGroupContentType(xmlRelaxNGContentType ct1, xmlRelaxNGContentType ct2) { if ((ct1 == XML_RELAXNG_CONTENT_ERROR) || (ct2 == XML_RELAXNG_CONTENT_ERROR)) return (XML_RELAXNG_CONTENT_ERROR); if (ct1 == XML_RELAXNG_CONTENT_EMPTY) return (ct2); if (ct2 == XML_RELAXNG_CONTENT_EMPTY) return (ct1); if ((ct1 == XML_RELAXNG_CONTENT_COMPLEX) && (ct2 == XML_RELAXNG_CONTENT_COMPLEX)) return (XML_RELAXNG_CONTENT_COMPLEX); return (XML_RELAXNG_CONTENT_ERROR); } /** * xmlRelaxNGMaxContentType: * @ct1: the first content type * @ct2: the second content type * * Compute the max content-type * * Returns the content type */ static xmlRelaxNGContentType xmlRelaxNGMaxContentType(xmlRelaxNGContentType ct1, xmlRelaxNGContentType ct2) { if ((ct1 == XML_RELAXNG_CONTENT_ERROR) || (ct2 == XML_RELAXNG_CONTENT_ERROR)) return (XML_RELAXNG_CONTENT_ERROR); if ((ct1 == XML_RELAXNG_CONTENT_SIMPLE) || (ct2 == XML_RELAXNG_CONTENT_SIMPLE)) return (XML_RELAXNG_CONTENT_SIMPLE); if ((ct1 == XML_RELAXNG_CONTENT_COMPLEX) || (ct2 == XML_RELAXNG_CONTENT_COMPLEX)) return (XML_RELAXNG_CONTENT_COMPLEX); return (XML_RELAXNG_CONTENT_EMPTY); } /** * xmlRelaxNGCheckRules: * @ctxt: a Relax-NG parser context * @cur: the current definition * @flags: some accumulated flags * @ptype: the parent type * * Check for rules in section 7.1 and 7.2 * * Returns the content type of @cur */ static xmlRelaxNGContentType xmlRelaxNGCheckRules(xmlRelaxNGParserCtxtPtr ctxt, xmlRelaxNGDefinePtr cur, int flags, xmlRelaxNGType ptype) { int nflags = flags; xmlRelaxNGContentType ret, tmp, val = XML_RELAXNG_CONTENT_EMPTY; while (cur != NULL) { ret = XML_RELAXNG_CONTENT_EMPTY; if ((cur->type == XML_RELAXNG_REF) || (cur->type == XML_RELAXNG_PARENTREF)) { /* * This should actually be caught by list//element(ref) at the * element boundaries, c.f. Bug #159968 local refs are dropped * in step 4.19. */ #if 0 if (flags & XML_RELAXNG_IN_LIST) { xmlRngPErr(ctxt, cur->node, XML_RNGP_PAT_LIST_REF, "Found forbidden pattern list//ref\n", NULL, NULL); } #endif if (flags & XML_RELAXNG_IN_DATAEXCEPT) { xmlRngPErr(ctxt, cur->node, XML_RNGP_PAT_DATA_EXCEPT_REF, "Found forbidden pattern data/except//ref\n", NULL, NULL); } if (cur->depth > -4) { cur->depth = -4; ret = xmlRelaxNGCheckRules(ctxt, cur->content, flags, cur->type); cur->depth = ret - 15; } else if (cur->depth == -4) { ret = XML_RELAXNG_CONTENT_COMPLEX; } else { ret = (xmlRelaxNGContentType) (cur->depth + 15); } } else if (cur->type == XML_RELAXNG_ELEMENT) { /* * The 7.3 Attribute derivation rule for groups is plugged there */ xmlRelaxNGCheckGroupAttrs(ctxt, cur); if (flags & XML_RELAXNG_IN_DATAEXCEPT) { xmlRngPErr(ctxt, cur->node, XML_RNGP_PAT_DATA_EXCEPT_ELEM, "Found forbidden pattern data/except//element(ref)\n", NULL, NULL); } if (flags & XML_RELAXNG_IN_LIST) { xmlRngPErr(ctxt, cur->node, XML_RNGP_PAT_LIST_ELEM, "Found forbidden pattern list//element(ref)\n", NULL, NULL); } if (flags & XML_RELAXNG_IN_ATTRIBUTE) { xmlRngPErr(ctxt, cur->node, XML_RNGP_PAT_ATTR_ELEM, "Found forbidden pattern attribute//element(ref)\n", NULL, NULL); } if (flags & XML_RELAXNG_IN_ATTRIBUTE) { xmlRngPErr(ctxt, cur->node, XML_RNGP_PAT_ATTR_ELEM, "Found forbidden pattern attribute//element(ref)\n", NULL, NULL); } /* * reset since in the simple form elements are only child * of grammar/define */ nflags = 0; ret = xmlRelaxNGCheckRules(ctxt, cur->attrs, nflags, cur->type); if (ret != XML_RELAXNG_CONTENT_EMPTY) { xmlRngPErr(ctxt, cur->node, XML_RNGP_ELEM_CONTENT_EMPTY, "Element %s attributes have a content type error\n", cur->name, NULL); } ret = xmlRelaxNGCheckRules(ctxt, cur->content, nflags, cur->type); if (ret == XML_RELAXNG_CONTENT_ERROR) { xmlRngPErr(ctxt, cur->node, XML_RNGP_ELEM_CONTENT_ERROR, "Element %s has a content type error\n", cur->name, NULL); } else { ret = XML_RELAXNG_CONTENT_COMPLEX; } } else if (cur->type == XML_RELAXNG_ATTRIBUTE) { if (flags & XML_RELAXNG_IN_ATTRIBUTE) { xmlRngPErr(ctxt, cur->node, XML_RNGP_PAT_ATTR_ATTR, "Found forbidden pattern attribute//attribute\n", NULL, NULL); } if (flags & XML_RELAXNG_IN_LIST) { xmlRngPErr(ctxt, cur->node, XML_RNGP_PAT_LIST_ATTR, "Found forbidden pattern list//attribute\n", NULL, NULL); } if (flags & XML_RELAXNG_IN_OOMGROUP) { xmlRngPErr(ctxt, cur->node, XML_RNGP_PAT_ONEMORE_GROUP_ATTR, "Found forbidden pattern oneOrMore//group//attribute\n", NULL, NULL); } if (flags & XML_RELAXNG_IN_OOMINTERLEAVE) { xmlRngPErr(ctxt, cur->node, XML_RNGP_PAT_ONEMORE_INTERLEAVE_ATTR, "Found forbidden pattern oneOrMore//interleave//attribute\n", NULL, NULL); } if (flags & XML_RELAXNG_IN_DATAEXCEPT) { xmlRngPErr(ctxt, cur->node, XML_RNGP_PAT_DATA_EXCEPT_ATTR, "Found forbidden pattern data/except//attribute\n", NULL, NULL); } if (flags & XML_RELAXNG_IN_START) { xmlRngPErr(ctxt, cur->node, XML_RNGP_PAT_START_ATTR, "Found forbidden pattern start//attribute\n", NULL, NULL); } if ((!(flags & XML_RELAXNG_IN_ONEORMORE)) && (cur->name == NULL)) { if (cur->ns == NULL) { xmlRngPErr(ctxt, cur->node, XML_RNGP_ANYNAME_ATTR_ANCESTOR, "Found anyName attribute without oneOrMore ancestor\n", NULL, NULL); } else { xmlRngPErr(ctxt, cur->node, XML_RNGP_NSNAME_ATTR_ANCESTOR, "Found nsName attribute without oneOrMore ancestor\n", NULL, NULL); } } nflags = flags | XML_RELAXNG_IN_ATTRIBUTE; xmlRelaxNGCheckRules(ctxt, cur->content, nflags, cur->type); ret = XML_RELAXNG_CONTENT_EMPTY; } else if ((cur->type == XML_RELAXNG_ONEORMORE) || (cur->type == XML_RELAXNG_ZEROORMORE)) { if (flags & XML_RELAXNG_IN_DATAEXCEPT) { xmlRngPErr(ctxt, cur->node, XML_RNGP_PAT_DATA_EXCEPT_ONEMORE, "Found forbidden pattern data/except//oneOrMore\n", NULL, NULL); } if (flags & XML_RELAXNG_IN_START) { xmlRngPErr(ctxt, cur->node, XML_RNGP_PAT_START_ONEMORE, "Found forbidden pattern start//oneOrMore\n", NULL, NULL); } nflags = flags | XML_RELAXNG_IN_ONEORMORE; ret = xmlRelaxNGCheckRules(ctxt, cur->content, nflags, cur->type); ret = xmlRelaxNGGroupContentType(ret, ret); } else if (cur->type == XML_RELAXNG_LIST) { if (flags & XML_RELAXNG_IN_LIST) { xmlRngPErr(ctxt, cur->node, XML_RNGP_PAT_LIST_LIST, "Found forbidden pattern list//list\n", NULL, NULL); } if (flags & XML_RELAXNG_IN_DATAEXCEPT) { xmlRngPErr(ctxt, cur->node, XML_RNGP_PAT_DATA_EXCEPT_LIST, "Found forbidden pattern data/except//list\n", NULL, NULL); } if (flags & XML_RELAXNG_IN_START) { xmlRngPErr(ctxt, cur->node, XML_RNGP_PAT_START_LIST, "Found forbidden pattern start//list\n", NULL, NULL); } nflags = flags | XML_RELAXNG_IN_LIST; ret = xmlRelaxNGCheckRules(ctxt, cur->content, nflags, cur->type); } else if (cur->type == XML_RELAXNG_GROUP) { if (flags & XML_RELAXNG_IN_DATAEXCEPT) { xmlRngPErr(ctxt, cur->node, XML_RNGP_PAT_DATA_EXCEPT_GROUP, "Found forbidden pattern data/except//group\n", NULL, NULL); } if (flags & XML_RELAXNG_IN_START) { xmlRngPErr(ctxt, cur->node, XML_RNGP_PAT_START_GROUP, "Found forbidden pattern start//group\n", NULL, NULL); } if (flags & XML_RELAXNG_IN_ONEORMORE) nflags = flags | XML_RELAXNG_IN_OOMGROUP; else nflags = flags; ret = xmlRelaxNGCheckRules(ctxt, cur->content, nflags, cur->type); /* * The 7.3 Attribute derivation rule for groups is plugged there */ xmlRelaxNGCheckGroupAttrs(ctxt, cur); } else if (cur->type == XML_RELAXNG_INTERLEAVE) { if (flags & XML_RELAXNG_IN_LIST) { xmlRngPErr(ctxt, cur->node, XML_RNGP_PAT_LIST_INTERLEAVE, "Found forbidden pattern list//interleave\n", NULL, NULL); } if (flags & XML_RELAXNG_IN_DATAEXCEPT) { xmlRngPErr(ctxt, cur->node, XML_RNGP_PAT_DATA_EXCEPT_INTERLEAVE, "Found forbidden pattern data/except//interleave\n", NULL, NULL); } if (flags & XML_RELAXNG_IN_START) { xmlRngPErr(ctxt, cur->node, XML_RNGP_PAT_DATA_EXCEPT_INTERLEAVE, "Found forbidden pattern start//interleave\n", NULL, NULL); } if (flags & XML_RELAXNG_IN_ONEORMORE) nflags = flags | XML_RELAXNG_IN_OOMINTERLEAVE; else nflags = flags; ret = xmlRelaxNGCheckRules(ctxt, cur->content, nflags, cur->type); } else if (cur->type == XML_RELAXNG_EXCEPT) { if ((cur->parent != NULL) && (cur->parent->type == XML_RELAXNG_DATATYPE)) nflags = flags | XML_RELAXNG_IN_DATAEXCEPT; else nflags = flags; ret = xmlRelaxNGCheckRules(ctxt, cur->content, nflags, cur->type); } else if (cur->type == XML_RELAXNG_DATATYPE) { if (flags & XML_RELAXNG_IN_START) { xmlRngPErr(ctxt, cur->node, XML_RNGP_PAT_START_DATA, "Found forbidden pattern start//data\n", NULL, NULL); } xmlRelaxNGCheckRules(ctxt, cur->content, flags, cur->type); ret = XML_RELAXNG_CONTENT_SIMPLE; } else if (cur->type == XML_RELAXNG_VALUE) { if (flags & XML_RELAXNG_IN_START) { xmlRngPErr(ctxt, cur->node, XML_RNGP_PAT_START_VALUE, "Found forbidden pattern start//value\n", NULL, NULL); } xmlRelaxNGCheckRules(ctxt, cur->content, flags, cur->type); ret = XML_RELAXNG_CONTENT_SIMPLE; } else if (cur->type == XML_RELAXNG_TEXT) { if (flags & XML_RELAXNG_IN_LIST) { xmlRngPErr(ctxt, cur->node, XML_RNGP_PAT_LIST_TEXT, "Found forbidden pattern list//text\n", NULL, NULL); } if (flags & XML_RELAXNG_IN_DATAEXCEPT) { xmlRngPErr(ctxt, cur->node, XML_RNGP_PAT_DATA_EXCEPT_TEXT, "Found forbidden pattern data/except//text\n", NULL, NULL); } if (flags & XML_RELAXNG_IN_START) { xmlRngPErr(ctxt, cur->node, XML_RNGP_PAT_START_TEXT, "Found forbidden pattern start//text\n", NULL, NULL); } ret = XML_RELAXNG_CONTENT_COMPLEX; } else if (cur->type == XML_RELAXNG_EMPTY) { if (flags & XML_RELAXNG_IN_DATAEXCEPT) { xmlRngPErr(ctxt, cur->node, XML_RNGP_PAT_DATA_EXCEPT_EMPTY, "Found forbidden pattern data/except//empty\n", NULL, NULL); } if (flags & XML_RELAXNG_IN_START) { xmlRngPErr(ctxt, cur->node, XML_RNGP_PAT_START_EMPTY, "Found forbidden pattern start//empty\n", NULL, NULL); } ret = XML_RELAXNG_CONTENT_EMPTY; } else if (cur->type == XML_RELAXNG_CHOICE) { xmlRelaxNGCheckChoiceDeterminism(ctxt, cur); ret = xmlRelaxNGCheckRules(ctxt, cur->content, flags, cur->type); } else { ret = xmlRelaxNGCheckRules(ctxt, cur->content, flags, cur->type); } cur = cur->next; if (ptype == XML_RELAXNG_GROUP) { val = xmlRelaxNGGroupContentType(val, ret); } else if (ptype == XML_RELAXNG_INTERLEAVE) { tmp = xmlRelaxNGGroupContentType(val, ret); if (tmp != XML_RELAXNG_CONTENT_ERROR) tmp = xmlRelaxNGMaxContentType(val, ret); } else if (ptype == XML_RELAXNG_CHOICE) { val = xmlRelaxNGMaxContentType(val, ret); } else if (ptype == XML_RELAXNG_LIST) { val = XML_RELAXNG_CONTENT_SIMPLE; } else if (ptype == XML_RELAXNG_EXCEPT) { if (ret == XML_RELAXNG_CONTENT_ERROR) val = XML_RELAXNG_CONTENT_ERROR; else val = XML_RELAXNG_CONTENT_SIMPLE; } else { val = xmlRelaxNGGroupContentType(val, ret); } } return (val); } /** * xmlRelaxNGParseGrammar: * @ctxt: a Relax-NG parser context * @nodes: grammar children nodes * * parse a Relax-NG node * * Returns the internal xmlRelaxNGGrammarPtr built or * NULL in case of error */ static xmlRelaxNGGrammarPtr xmlRelaxNGParseGrammar(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr nodes) { xmlRelaxNGGrammarPtr ret, tmp, old; #ifdef DEBUG_GRAMMAR xmlGenericError(xmlGenericErrorContext, "Parsing a new grammar\n"); #endif ret = xmlRelaxNGNewGrammar(ctxt); if (ret == NULL) return (NULL); /* * Link the new grammar in the tree */ ret->parent = ctxt->grammar; if (ctxt->grammar != NULL) { tmp = ctxt->grammar->children; if (tmp == NULL) { ctxt->grammar->children = ret; } else { while (tmp->next != NULL) tmp = tmp->next; tmp->next = ret; } } old = ctxt->grammar; ctxt->grammar = ret; xmlRelaxNGParseGrammarContent(ctxt, nodes); ctxt->grammar = ret; if (ctxt->grammar == NULL) { xmlRngPErr(ctxt, nodes, XML_RNGP_GRAMMAR_CONTENT, "Failed to parse content\n", NULL, NULL); } else if (ctxt->grammar->start == NULL) { xmlRngPErr(ctxt, nodes, XML_RNGP_GRAMMAR_NO_START, "Element has no \n", NULL, NULL); } /* * Apply 4.17 mergingd rules to defines and starts */ xmlRelaxNGCombineStart(ctxt, ret); if (ret->defs != NULL) { xmlHashScan(ret->defs, (xmlHashScanner) xmlRelaxNGCheckCombine, ctxt); } /* * link together defines and refs in this grammar */ if (ret->refs != NULL) { xmlHashScan(ret->refs, (xmlHashScanner) xmlRelaxNGCheckReference, ctxt); } ctxt->grammar = old; return (ret); } /** * xmlRelaxNGParseDocument: * @ctxt: a Relax-NG parser context * @node: the root node of the RelaxNG schema * * parse a Relax-NG definition resource and build an internal * xmlRelaxNG struture which can be used to validate instances. * * Returns the internal XML RelaxNG structure built or * NULL in case of error */ static xmlRelaxNGPtr xmlRelaxNGParseDocument(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node) { xmlRelaxNGPtr schema = NULL; const xmlChar *olddefine; xmlRelaxNGGrammarPtr old; if ((ctxt == NULL) || (node == NULL)) return (NULL); schema = xmlRelaxNGNewRelaxNG(ctxt); if (schema == NULL) return (NULL); olddefine = ctxt->define; ctxt->define = NULL; if (IS_RELAXNG(node, "grammar")) { schema->topgrammar = xmlRelaxNGParseGrammar(ctxt, node->children); } else { xmlRelaxNGGrammarPtr tmp, ret; schema->topgrammar = ret = xmlRelaxNGNewGrammar(ctxt); if (schema->topgrammar == NULL) { return (schema); } /* * Link the new grammar in the tree */ ret->parent = ctxt->grammar; if (ctxt->grammar != NULL) { tmp = ctxt->grammar->children; if (tmp == NULL) { ctxt->grammar->children = ret; } else { while (tmp->next != NULL) tmp = tmp->next; tmp->next = ret; } } old = ctxt->grammar; ctxt->grammar = ret; xmlRelaxNGParseStart(ctxt, node); if (old != NULL) ctxt->grammar = old; } ctxt->define = olddefine; if (schema->topgrammar->start != NULL) { xmlRelaxNGCheckCycles(ctxt, schema->topgrammar->start, 0); if ((ctxt->flags & XML_RELAXNG_IN_EXTERNALREF) == 0) { xmlRelaxNGSimplify(ctxt, schema->topgrammar->start, NULL); while ((schema->topgrammar->start != NULL) && (schema->topgrammar->start->type == XML_RELAXNG_NOOP) && (schema->topgrammar->start->next != NULL)) schema->topgrammar->start = schema->topgrammar->start->content; xmlRelaxNGCheckRules(ctxt, schema->topgrammar->start, XML_RELAXNG_IN_START, XML_RELAXNG_NOOP); } } #ifdef DEBUG if (schema == NULL) xmlGenericError(xmlGenericErrorContext, "xmlRelaxNGParseDocument() failed\n"); #endif return (schema); } /************************************************************************ * * * Reading RelaxNGs * * * ************************************************************************/ /** * xmlRelaxNGNewParserCtxt: * @URL: the location of the schema * * Create an XML RelaxNGs parse context for that file/resource expected * to contain an XML RelaxNGs file. * * Returns the parser context or NULL in case of error */ xmlRelaxNGParserCtxtPtr xmlRelaxNGNewParserCtxt(const char *URL) { xmlRelaxNGParserCtxtPtr ret; if (URL == NULL) return (NULL); ret = (xmlRelaxNGParserCtxtPtr) xmlMalloc(sizeof(xmlRelaxNGParserCtxt)); if (ret == NULL) { xmlRngPErrMemory(NULL, "building parser\n"); return (NULL); } memset(ret, 0, sizeof(xmlRelaxNGParserCtxt)); ret->URL = xmlStrdup((const xmlChar *) URL); ret->error = xmlGenericError; ret->userData = xmlGenericErrorContext; return (ret); } /** * xmlRelaxNGNewMemParserCtxt: * @buffer: a pointer to a char array containing the schemas * @size: the size of the array * * Create an XML RelaxNGs parse context for that memory buffer expected * to contain an XML RelaxNGs file. * * Returns the parser context or NULL in case of error */ xmlRelaxNGParserCtxtPtr xmlRelaxNGNewMemParserCtxt(const char *buffer, int size) { xmlRelaxNGParserCtxtPtr ret; if ((buffer == NULL) || (size <= 0)) return (NULL); ret = (xmlRelaxNGParserCtxtPtr) xmlMalloc(sizeof(xmlRelaxNGParserCtxt)); if (ret == NULL) { xmlRngPErrMemory(NULL, "building parser\n"); return (NULL); } memset(ret, 0, sizeof(xmlRelaxNGParserCtxt)); ret->buffer = buffer; ret->size = size; ret->error = xmlGenericError; ret->userData = xmlGenericErrorContext; return (ret); } /** * xmlRelaxNGNewDocParserCtxt: * @doc: a preparsed document tree * * Create an XML RelaxNGs parser context for that document. * Note: since the process of compiling a RelaxNG schemas modifies the * document, the @doc parameter is duplicated internally. * * Returns the parser context or NULL in case of error */ xmlRelaxNGParserCtxtPtr xmlRelaxNGNewDocParserCtxt(xmlDocPtr doc) { xmlRelaxNGParserCtxtPtr ret; xmlDocPtr copy; if (doc == NULL) return (NULL); copy = xmlCopyDoc(doc, 1); if (copy == NULL) return (NULL); ret = (xmlRelaxNGParserCtxtPtr) xmlMalloc(sizeof(xmlRelaxNGParserCtxt)); if (ret == NULL) { xmlRngPErrMemory(NULL, "building parser\n"); return (NULL); } memset(ret, 0, sizeof(xmlRelaxNGParserCtxt)); ret->document = copy; ret->freedoc = 1; ret->userData = xmlGenericErrorContext; return (ret); } /** * xmlRelaxNGFreeParserCtxt: * @ctxt: the schema parser context * * Free the resources associated to the schema parser context */ void xmlRelaxNGFreeParserCtxt(xmlRelaxNGParserCtxtPtr ctxt) { if (ctxt == NULL) return; if (ctxt->URL != NULL) xmlFree(ctxt->URL); if (ctxt->doc != NULL) xmlRelaxNGFreeDocument(ctxt->doc); if (ctxt->interleaves != NULL) xmlHashFree(ctxt->interleaves, NULL); if (ctxt->documents != NULL) xmlRelaxNGFreeDocumentList(ctxt->documents); if (ctxt->includes != NULL) xmlRelaxNGFreeIncludeList(ctxt->includes); if (ctxt->docTab != NULL) xmlFree(ctxt->docTab); if (ctxt->incTab != NULL) xmlFree(ctxt->incTab); if (ctxt->defTab != NULL) { int i; for (i = 0; i < ctxt->defNr; i++) xmlRelaxNGFreeDefine(ctxt->defTab[i]); xmlFree(ctxt->defTab); } if ((ctxt->document != NULL) && (ctxt->freedoc)) xmlFreeDoc(ctxt->document); xmlFree(ctxt); } /** * xmlRelaxNGNormExtSpace: * @value: a value * * Removes the leading and ending spaces of the value * The string is modified "in situ" */ static void xmlRelaxNGNormExtSpace(xmlChar * value) { xmlChar *start = value; xmlChar *cur = value; if (value == NULL) return; while (IS_BLANK_CH(*cur)) cur++; if (cur == start) { do { while ((*cur != 0) && (!IS_BLANK_CH(*cur))) cur++; if (*cur == 0) return; start = cur; while (IS_BLANK_CH(*cur)) cur++; if (*cur == 0) { *start = 0; return; } } while (1); } else { do { while ((*cur != 0) && (!IS_BLANK_CH(*cur))) *start++ = *cur++; if (*cur == 0) { *start = 0; return; } /* don't try to normalize the inner spaces */ while (IS_BLANK_CH(*cur)) cur++; if (*cur == 0) { *start = 0; return; } *start++ = *cur++; } while (1); } } /** * xmlRelaxNGCleanupAttributes: * @ctxt: a Relax-NG parser context * @node: a Relax-NG node * * Check all the attributes on the given node */ static void xmlRelaxNGCleanupAttributes(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node) { xmlAttrPtr cur, next; cur = node->properties; while (cur != NULL) { next = cur->next; if ((cur->ns == NULL) || (xmlStrEqual(cur->ns->href, xmlRelaxNGNs))) { if (xmlStrEqual(cur->name, BAD_CAST "name")) { if ((!xmlStrEqual(node->name, BAD_CAST "element")) && (!xmlStrEqual(node->name, BAD_CAST "attribute")) && (!xmlStrEqual(node->name, BAD_CAST "ref")) && (!xmlStrEqual(node->name, BAD_CAST "parentRef")) && (!xmlStrEqual(node->name, BAD_CAST "param")) && (!xmlStrEqual(node->name, BAD_CAST "define"))) { xmlRngPErr(ctxt, node, XML_RNGP_FORBIDDEN_ATTRIBUTE, "Attribute %s is not allowed on %s\n", cur->name, node->name); } } else if (xmlStrEqual(cur->name, BAD_CAST "type")) { if ((!xmlStrEqual(node->name, BAD_CAST "value")) && (!xmlStrEqual(node->name, BAD_CAST "data"))) { xmlRngPErr(ctxt, node, XML_RNGP_FORBIDDEN_ATTRIBUTE, "Attribute %s is not allowed on %s\n", cur->name, node->name); } } else if (xmlStrEqual(cur->name, BAD_CAST "href")) { if ((!xmlStrEqual(node->name, BAD_CAST "externalRef")) && (!xmlStrEqual(node->name, BAD_CAST "include"))) { xmlRngPErr(ctxt, node, XML_RNGP_FORBIDDEN_ATTRIBUTE, "Attribute %s is not allowed on %s\n", cur->name, node->name); } } else if (xmlStrEqual(cur->name, BAD_CAST "combine")) { if ((!xmlStrEqual(node->name, BAD_CAST "start")) && (!xmlStrEqual(node->name, BAD_CAST "define"))) { xmlRngPErr(ctxt, node, XML_RNGP_FORBIDDEN_ATTRIBUTE, "Attribute %s is not allowed on %s\n", cur->name, node->name); } } else if (xmlStrEqual(cur->name, BAD_CAST "datatypeLibrary")) { xmlChar *val; xmlURIPtr uri; val = xmlNodeListGetString(node->doc, cur->children, 1); if (val != NULL) { if (val[0] != 0) { uri = xmlParseURI((const char *) val); if (uri == NULL) { xmlRngPErr(ctxt, node, XML_RNGP_INVALID_URI, "Attribute %s contains invalid URI %s\n", cur->name, val); } else { if (uri->scheme == NULL) { xmlRngPErr(ctxt, node, XML_RNGP_URI_NOT_ABSOLUTE, "Attribute %s URI %s is not absolute\n", cur->name, val); } if (uri->fragment != NULL) { xmlRngPErr(ctxt, node, XML_RNGP_URI_FRAGMENT, "Attribute %s URI %s has a fragment ID\n", cur->name, val); } xmlFreeURI(uri); } } xmlFree(val); } } else if (!xmlStrEqual(cur->name, BAD_CAST "ns")) { xmlRngPErr(ctxt, node, XML_RNGP_UNKNOWN_ATTRIBUTE, "Unknown attribute %s on %s\n", cur->name, node->name); } } cur = next; } } /** * xmlRelaxNGCleanupTree: * @ctxt: a Relax-NG parser context * @root: an xmlNodePtr subtree * * Cleanup the subtree from unwanted nodes for parsing, resolve * Include and externalRef lookups. */ static void xmlRelaxNGCleanupTree(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr root) { xmlNodePtr cur, delete; delete = NULL; cur = root; while (cur != NULL) { if (delete != NULL) { xmlUnlinkNode(delete); xmlFreeNode(delete); delete = NULL; } if (cur->type == XML_ELEMENT_NODE) { /* * Simplification 4.1. Annotations */ if ((cur->ns == NULL) || (!xmlStrEqual(cur->ns->href, xmlRelaxNGNs))) { if ((cur->parent != NULL) && (cur->parent->type == XML_ELEMENT_NODE) && ((xmlStrEqual(cur->parent->name, BAD_CAST "name")) || (xmlStrEqual(cur->parent->name, BAD_CAST "value")) || (xmlStrEqual(cur->parent->name, BAD_CAST "param")))) { xmlRngPErr(ctxt, cur, XML_RNGP_FOREIGN_ELEMENT, "element %s doesn't allow foreign elements\n", cur->parent->name, NULL); } delete = cur; goto skip_children; } else { xmlRelaxNGCleanupAttributes(ctxt, cur); if (xmlStrEqual(cur->name, BAD_CAST "externalRef")) { xmlChar *href, *ns, *base, *URL; xmlRelaxNGDocumentPtr docu; xmlNodePtr tmp; xmlURIPtr uri; ns = xmlGetProp(cur, BAD_CAST "ns"); if (ns == NULL) { tmp = cur->parent; while ((tmp != NULL) && (tmp->type == XML_ELEMENT_NODE)) { ns = xmlGetProp(tmp, BAD_CAST "ns"); if (ns != NULL) break; tmp = tmp->parent; } } href = xmlGetProp(cur, BAD_CAST "href"); if (href == NULL) { xmlRngPErr(ctxt, cur, XML_RNGP_MISSING_HREF, "xmlRelaxNGParse: externalRef has no href attribute\n", NULL, NULL); if (ns != NULL) xmlFree(ns); delete = cur; goto skip_children; } uri = xmlParseURI((const char *) href); if (uri == NULL) { xmlRngPErr(ctxt, cur, XML_RNGP_HREF_ERROR, "Incorrect URI for externalRef %s\n", href, NULL); if (ns != NULL) xmlFree(ns); if (href != NULL) xmlFree(href); delete = cur; goto skip_children; } if (uri->fragment != NULL) { xmlRngPErr(ctxt, cur, XML_RNGP_HREF_ERROR, "Fragment forbidden in URI for externalRef %s\n", href, NULL); if (ns != NULL) xmlFree(ns); xmlFreeURI(uri); if (href != NULL) xmlFree(href); delete = cur; goto skip_children; } xmlFreeURI(uri); base = xmlNodeGetBase(cur->doc, cur); URL = xmlBuildURI(href, base); if (URL == NULL) { xmlRngPErr(ctxt, cur, XML_RNGP_HREF_ERROR, "Failed to compute URL for externalRef %s\n", href, NULL); if (ns != NULL) xmlFree(ns); if (href != NULL) xmlFree(href); if (base != NULL) xmlFree(base); delete = cur; goto skip_children; } if (href != NULL) xmlFree(href); if (base != NULL) xmlFree(base); docu = xmlRelaxNGLoadExternalRef(ctxt, URL, ns); if (docu == NULL) { xmlRngPErr(ctxt, cur, XML_RNGP_EXTERNAL_REF_FAILURE, "Failed to load externalRef %s\n", URL, NULL); if (ns != NULL) xmlFree(ns); xmlFree(URL); delete = cur; goto skip_children; } if (ns != NULL) xmlFree(ns); xmlFree(URL); cur->psvi = docu; } else if (xmlStrEqual(cur->name, BAD_CAST "include")) { xmlChar *href, *ns, *base, *URL; xmlRelaxNGIncludePtr incl; xmlNodePtr tmp; href = xmlGetProp(cur, BAD_CAST "href"); if (href == NULL) { xmlRngPErr(ctxt, cur, XML_RNGP_MISSING_HREF, "xmlRelaxNGParse: include has no href attribute\n", NULL, NULL); delete = cur; goto skip_children; } base = xmlNodeGetBase(cur->doc, cur); URL = xmlBuildURI(href, base); if (URL == NULL) { xmlRngPErr(ctxt, cur, XML_RNGP_HREF_ERROR, "Failed to compute URL for include %s\n", href, NULL); if (href != NULL) xmlFree(href); if (base != NULL) xmlFree(base); delete = cur; goto skip_children; } if (href != NULL) xmlFree(href); if (base != NULL) xmlFree(base); ns = xmlGetProp(cur, BAD_CAST "ns"); if (ns == NULL) { tmp = cur->parent; while ((tmp != NULL) && (tmp->type == XML_ELEMENT_NODE)) { ns = xmlGetProp(tmp, BAD_CAST "ns"); if (ns != NULL) break; tmp = tmp->parent; } } incl = xmlRelaxNGLoadInclude(ctxt, URL, cur, ns); if (ns != NULL) xmlFree(ns); if (incl == NULL) { xmlRngPErr(ctxt, cur, XML_RNGP_INCLUDE_FAILURE, "Failed to load include %s\n", URL, NULL); xmlFree(URL); delete = cur; goto skip_children; } xmlFree(URL); cur->psvi = incl; } else if ((xmlStrEqual(cur->name, BAD_CAST "element")) || (xmlStrEqual(cur->name, BAD_CAST "attribute"))) { xmlChar *name, *ns; xmlNodePtr text = NULL; /* * Simplification 4.8. name attribute of element * and attribute elements */ name = xmlGetProp(cur, BAD_CAST "name"); if (name != NULL) { if (cur->children == NULL) { text = xmlNewChild(cur, cur->ns, BAD_CAST "name", name); } else { xmlNodePtr node; node = xmlNewDocNode(cur->doc, cur->ns, BAD_CAST "name", NULL); if (node != NULL) { xmlAddPrevSibling(cur->children, node); text = xmlNewText(name); xmlAddChild(node, text); text = node; } } if (text == NULL) { xmlRngPErr(ctxt, cur, XML_RNGP_CREATE_FAILURE, "Failed to create a name %s element\n", name, NULL); } xmlUnsetProp(cur, BAD_CAST "name"); xmlFree(name); ns = xmlGetProp(cur, BAD_CAST "ns"); if (ns != NULL) { if (text != NULL) { xmlSetProp(text, BAD_CAST "ns", ns); /* xmlUnsetProp(cur, BAD_CAST "ns"); */ } xmlFree(ns); } else if (xmlStrEqual(cur->name, BAD_CAST "attribute")) { xmlSetProp(text, BAD_CAST "ns", BAD_CAST ""); } } } else if ((xmlStrEqual(cur->name, BAD_CAST "name")) || (xmlStrEqual(cur->name, BAD_CAST "nsName")) || (xmlStrEqual(cur->name, BAD_CAST "value"))) { /* * Simplification 4.8. name attribute of element * and attribute elements */ if (xmlHasProp(cur, BAD_CAST "ns") == NULL) { xmlNodePtr node; xmlChar *ns = NULL; node = cur->parent; while ((node != NULL) && (node->type == XML_ELEMENT_NODE)) { ns = xmlGetProp(node, BAD_CAST "ns"); if (ns != NULL) { break; } node = node->parent; } if (ns == NULL) { xmlSetProp(cur, BAD_CAST "ns", BAD_CAST ""); } else { xmlSetProp(cur, BAD_CAST "ns", ns); xmlFree(ns); } } if (xmlStrEqual(cur->name, BAD_CAST "name")) { xmlChar *name, *local, *prefix; /* * Simplification: 4.10. QNames */ name = xmlNodeGetContent(cur); if (name != NULL) { local = xmlSplitQName2(name, &prefix); if (local != NULL) { xmlNsPtr ns; ns = xmlSearchNs(cur->doc, cur, prefix); if (ns == NULL) { xmlRngPErr(ctxt, cur, XML_RNGP_PREFIX_UNDEFINED, "xmlRelaxNGParse: no namespace for prefix %s\n", prefix, NULL); } else { xmlSetProp(cur, BAD_CAST "ns", ns->href); xmlNodeSetContent(cur, local); } xmlFree(local); xmlFree(prefix); } xmlFree(name); } } /* * 4.16 */ if (xmlStrEqual(cur->name, BAD_CAST "nsName")) { if (ctxt->flags & XML_RELAXNG_IN_NSEXCEPT) { xmlRngPErr(ctxt, cur, XML_RNGP_PAT_NSNAME_EXCEPT_NSNAME, "Found nsName/except//nsName forbidden construct\n", NULL, NULL); } } } else if ((xmlStrEqual(cur->name, BAD_CAST "except")) && (cur != root)) { int oldflags = ctxt->flags; /* * 4.16 */ if ((cur->parent != NULL) && (xmlStrEqual (cur->parent->name, BAD_CAST "anyName"))) { ctxt->flags |= XML_RELAXNG_IN_ANYEXCEPT; xmlRelaxNGCleanupTree(ctxt, cur); ctxt->flags = oldflags; goto skip_children; } else if ((cur->parent != NULL) && (xmlStrEqual (cur->parent->name, BAD_CAST "nsName"))) { ctxt->flags |= XML_RELAXNG_IN_NSEXCEPT; xmlRelaxNGCleanupTree(ctxt, cur); ctxt->flags = oldflags; goto skip_children; } } else if (xmlStrEqual(cur->name, BAD_CAST "anyName")) { /* * 4.16 */ if (ctxt->flags & XML_RELAXNG_IN_ANYEXCEPT) { xmlRngPErr(ctxt, cur, XML_RNGP_PAT_ANYNAME_EXCEPT_ANYNAME, "Found anyName/except//anyName forbidden construct\n", NULL, NULL); } else if (ctxt->flags & XML_RELAXNG_IN_NSEXCEPT) { xmlRngPErr(ctxt, cur, XML_RNGP_PAT_NSNAME_EXCEPT_ANYNAME, "Found nsName/except//anyName forbidden construct\n", NULL, NULL); } } /* * Thisd is not an else since "include" is transformed * into a div */ if (xmlStrEqual(cur->name, BAD_CAST "div")) { xmlChar *ns; xmlNodePtr child, ins, tmp; /* * implements rule 4.11 */ ns = xmlGetProp(cur, BAD_CAST "ns"); child = cur->children; ins = cur; while (child != NULL) { if (ns != NULL) { if (!xmlHasProp(child, BAD_CAST "ns")) { xmlSetProp(child, BAD_CAST "ns", ns); } } tmp = child->next; xmlUnlinkNode(child); ins = xmlAddNextSibling(ins, child); child = tmp; } if (ns != NULL) xmlFree(ns); /* * Since we are about to delete cur, if it's nsDef is non-NULL we * need to preserve it (it contains the ns definitions for the * children we just moved). We'll just stick it on to the end * of cur->parent's list, since it's never going to be re-serialized * (bug 143738). */ if (cur->nsDef != NULL) { xmlNsPtr parDef = (xmlNsPtr)&cur->parent->nsDef; while (parDef->next != NULL) parDef = parDef->next; parDef->next = cur->nsDef; cur->nsDef = NULL; } delete = cur; goto skip_children; } } } /* * Simplification 4.2 whitespaces */ else if ((cur->type == XML_TEXT_NODE) || (cur->type == XML_CDATA_SECTION_NODE)) { if (IS_BLANK_NODE(cur)) { if (cur->parent->type == XML_ELEMENT_NODE) { if ((!xmlStrEqual(cur->parent->name, BAD_CAST "value")) && (!xmlStrEqual (cur->parent->name, BAD_CAST "param"))) delete = cur; } else { delete = cur; goto skip_children; } } } else { delete = cur; goto skip_children; } /* * Skip to next node */ if (cur->children != NULL) { if ((cur->children->type != XML_ENTITY_DECL) && (cur->children->type != XML_ENTITY_REF_NODE) && (cur->children->type != XML_ENTITY_NODE)) { cur = cur->children; continue; } } skip_children: if (cur->next != NULL) { cur = cur->next; continue; } do { cur = cur->parent; if (cur == NULL) break; if (cur == root) { cur = NULL; break; } if (cur->next != NULL) { cur = cur->next; break; } } while (cur != NULL); } if (delete != NULL) { xmlUnlinkNode(delete); xmlFreeNode(delete); delete = NULL; } } /** * xmlRelaxNGCleanupDoc: * @ctxt: a Relax-NG parser context * @doc: an xmldocPtr document pointer * * Cleanup the document from unwanted nodes for parsing, resolve * Include and externalRef lookups. * * Returns the cleaned up document or NULL in case of error */ static xmlDocPtr xmlRelaxNGCleanupDoc(xmlRelaxNGParserCtxtPtr ctxt, xmlDocPtr doc) { xmlNodePtr root; /* * Extract the root */ root = xmlDocGetRootElement(doc); if (root == NULL) { xmlRngPErr(ctxt, (xmlNodePtr) doc, XML_RNGP_EMPTY, "xmlRelaxNGParse: %s is empty\n", ctxt->URL, NULL); return (NULL); } xmlRelaxNGCleanupTree(ctxt, root); return (doc); } /** * xmlRelaxNGParse: * @ctxt: a Relax-NG parser context * * parse a schema definition resource and build an internal * XML Shema struture which can be used to validate instances. * * Returns the internal XML RelaxNG structure built from the resource or * NULL in case of error */ xmlRelaxNGPtr xmlRelaxNGParse(xmlRelaxNGParserCtxtPtr ctxt) { xmlRelaxNGPtr ret = NULL; xmlDocPtr doc; xmlNodePtr root; xmlRelaxNGInitTypes(); if (ctxt == NULL) return (NULL); /* * First step is to parse the input document into an DOM/Infoset */ if (ctxt->URL != NULL) { doc = xmlReadFile((const char *) ctxt->URL,NULL,0); if (doc == NULL) { xmlRngPErr(ctxt, NULL, XML_RNGP_PARSE_ERROR, "xmlRelaxNGParse: could not load %s\n", ctxt->URL, NULL); return (NULL); } } else if (ctxt->buffer != NULL) { doc = xmlReadMemory(ctxt->buffer, ctxt->size,NULL,NULL,0); if (doc == NULL) { xmlRngPErr(ctxt, NULL, XML_RNGP_PARSE_ERROR, "xmlRelaxNGParse: could not parse schemas\n", NULL, NULL); return (NULL); } doc->URL = xmlStrdup(BAD_CAST "in_memory_buffer"); ctxt->URL = xmlStrdup(BAD_CAST "in_memory_buffer"); } else if (ctxt->document != NULL) { doc = ctxt->document; } else { xmlRngPErr(ctxt, NULL, XML_RNGP_EMPTY, "xmlRelaxNGParse: nothing to parse\n", NULL, NULL); return (NULL); } ctxt->document = doc; /* * Some preprocessing of the document content */ doc = xmlRelaxNGCleanupDoc(ctxt, doc); if (doc == NULL) { xmlFreeDoc(ctxt->document); ctxt->document = NULL; return (NULL); } /* * Then do the parsing for good */ root = xmlDocGetRootElement(doc); if (root == NULL) { xmlRngPErr(ctxt, (xmlNodePtr) doc, XML_RNGP_EMPTY, "xmlRelaxNGParse: %s is empty\n", (ctxt->URL ? ctxt->URL : BAD_CAST "schemas"), NULL); xmlFreeDoc(ctxt->document); ctxt->document = NULL; return (NULL); } ret = xmlRelaxNGParseDocument(ctxt, root); if (ret == NULL) { xmlFreeDoc(ctxt->document); ctxt->document = NULL; return (NULL); } /* * Check the ref/defines links */ /* * try to preprocess interleaves */ if (ctxt->interleaves != NULL) { xmlHashScan(ctxt->interleaves, (xmlHashScanner) xmlRelaxNGComputeInterleaves, ctxt); } /* * if there was a parsing error return NULL */ if (ctxt->nbErrors > 0) { xmlRelaxNGFree(ret); ctxt->document = NULL; xmlFreeDoc(doc); return (NULL); } /* * try to compile (parts of) the schemas */ if ((ret->topgrammar != NULL) && (ret->topgrammar->start != NULL)) { if (ret->topgrammar->start->type != XML_RELAXNG_START) { xmlRelaxNGDefinePtr def; def = xmlRelaxNGNewDefine(ctxt, NULL); if (def != NULL) { def->type = XML_RELAXNG_START; def->content = ret->topgrammar->start; ret->topgrammar->start = def; } } xmlRelaxNGTryCompile(ctxt, ret->topgrammar->start); } /* * Transfer the pointer for cleanup at the schema level. */ ret->doc = doc; ctxt->document = NULL; ret->documents = ctxt->documents; ctxt->documents = NULL; ret->includes = ctxt->includes; ctxt->includes = NULL; ret->defNr = ctxt->defNr; ret->defTab = ctxt->defTab; ctxt->defTab = NULL; if (ctxt->idref == 1) ret->idref = 1; return (ret); } /** * xmlRelaxNGSetParserErrors: * @ctxt: a Relax-NG validation context * @err: the error callback * @warn: the warning callback * @ctx: contextual data for the callbacks * * Set the callback functions used to handle errors for a validation context */ void xmlRelaxNGSetParserErrors(xmlRelaxNGParserCtxtPtr ctxt, xmlRelaxNGValidityErrorFunc err, xmlRelaxNGValidityWarningFunc warn, void *ctx) { if (ctxt == NULL) return; ctxt->error = err; ctxt->warning = warn; ctxt->serror = NULL; ctxt->userData = ctx; } /** * xmlRelaxNGGetParserErrors: * @ctxt: a Relax-NG validation context * @err: the error callback result * @warn: the warning callback result * @ctx: contextual data for the callbacks result * * Get the callback information used to handle errors for a validation context * * Returns -1 in case of failure, 0 otherwise. */ int xmlRelaxNGGetParserErrors(xmlRelaxNGParserCtxtPtr ctxt, xmlRelaxNGValidityErrorFunc * err, xmlRelaxNGValidityWarningFunc * warn, void **ctx) { if (ctxt == NULL) return (-1); if (err != NULL) *err = ctxt->error; if (warn != NULL) *warn = ctxt->warning; if (ctx != NULL) *ctx = ctxt->userData; return (0); } /** * xmlRelaxNGSetParserStructuredErrors: * @ctxt: a Relax-NG parser context * @serror: the error callback * @ctx: contextual data for the callbacks * * Set the callback functions used to handle errors for a parsing context */ void xmlRelaxNGSetParserStructuredErrors(xmlRelaxNGParserCtxtPtr ctxt, xmlStructuredErrorFunc serror, void *ctx) { if (ctxt == NULL) return; ctxt->serror = serror; ctxt->error = NULL; ctxt->warning = NULL; ctxt->userData = ctx; } #ifdef LIBXML_OUTPUT_ENABLED /************************************************************************ * * * Dump back a compiled form * * * ************************************************************************/ static void xmlRelaxNGDumpDefine(FILE * output, xmlRelaxNGDefinePtr define); /** * xmlRelaxNGDumpDefines: * @output: the file output * @defines: a list of define structures * * Dump a RelaxNG structure back */ static void xmlRelaxNGDumpDefines(FILE * output, xmlRelaxNGDefinePtr defines) { while (defines != NULL) { xmlRelaxNGDumpDefine(output, defines); defines = defines->next; } } /** * xmlRelaxNGDumpDefine: * @output: the file output * @define: a define structure * * Dump a RelaxNG structure back */ static void xmlRelaxNGDumpDefine(FILE * output, xmlRelaxNGDefinePtr define) { if (define == NULL) return; switch (define->type) { case XML_RELAXNG_EMPTY: fprintf(output, "\n"); break; case XML_RELAXNG_NOT_ALLOWED: fprintf(output, "\n"); break; case XML_RELAXNG_TEXT: fprintf(output, "\n"); break; case XML_RELAXNG_ELEMENT: fprintf(output, "\n"); if (define->name != NULL) { fprintf(output, "ns != NULL) fprintf(output, " ns=\"%s\"", define->ns); fprintf(output, ">%s\n", define->name); } xmlRelaxNGDumpDefines(output, define->attrs); xmlRelaxNGDumpDefines(output, define->content); fprintf(output, "\n"); break; case XML_RELAXNG_LIST: fprintf(output, "\n"); xmlRelaxNGDumpDefines(output, define->content); fprintf(output, "\n"); break; case XML_RELAXNG_ONEORMORE: fprintf(output, "\n"); xmlRelaxNGDumpDefines(output, define->content); fprintf(output, "\n"); break; case XML_RELAXNG_ZEROORMORE: fprintf(output, "\n"); xmlRelaxNGDumpDefines(output, define->content); fprintf(output, "\n"); break; case XML_RELAXNG_CHOICE: fprintf(output, "\n"); xmlRelaxNGDumpDefines(output, define->content); fprintf(output, "\n"); break; case XML_RELAXNG_GROUP: fprintf(output, "\n"); xmlRelaxNGDumpDefines(output, define->content); fprintf(output, "\n"); break; case XML_RELAXNG_INTERLEAVE: fprintf(output, "\n"); xmlRelaxNGDumpDefines(output, define->content); fprintf(output, "\n"); break; case XML_RELAXNG_OPTIONAL: fprintf(output, "\n"); xmlRelaxNGDumpDefines(output, define->content); fprintf(output, "\n"); break; case XML_RELAXNG_ATTRIBUTE: fprintf(output, "\n"); xmlRelaxNGDumpDefines(output, define->content); fprintf(output, "\n"); break; case XML_RELAXNG_DEF: fprintf(output, "name != NULL) fprintf(output, " name=\"%s\"", define->name); fprintf(output, ">\n"); xmlRelaxNGDumpDefines(output, define->content); fprintf(output, "\n"); break; case XML_RELAXNG_REF: fprintf(output, "name != NULL) fprintf(output, " name=\"%s\"", define->name); fprintf(output, ">\n"); xmlRelaxNGDumpDefines(output, define->content); fprintf(output, "\n"); break; case XML_RELAXNG_PARENTREF: fprintf(output, "name != NULL) fprintf(output, " name=\"%s\"", define->name); fprintf(output, ">\n"); xmlRelaxNGDumpDefines(output, define->content); fprintf(output, "\n"); break; case XML_RELAXNG_EXTERNALREF: fprintf(output, ""); xmlRelaxNGDumpDefines(output, define->content); fprintf(output, "\n"); break; case XML_RELAXNG_DATATYPE: case XML_RELAXNG_VALUE: TODO break; case XML_RELAXNG_START: case XML_RELAXNG_EXCEPT: case XML_RELAXNG_PARAM: TODO break; case XML_RELAXNG_NOOP: xmlRelaxNGDumpDefines(output, define->content); break; } } /** * xmlRelaxNGDumpGrammar: * @output: the file output * @grammar: a grammar structure * @top: is this a top grammar * * Dump a RelaxNG structure back */ static void xmlRelaxNGDumpGrammar(FILE * output, xmlRelaxNGGrammarPtr grammar, int top) { if (grammar == NULL) return; fprintf(output, "combine) { case XML_RELAXNG_COMBINE_UNDEFINED: break; case XML_RELAXNG_COMBINE_CHOICE: fprintf(output, " combine=\"choice\""); break; case XML_RELAXNG_COMBINE_INTERLEAVE: fprintf(output, " combine=\"interleave\""); break; default: fprintf(output, " "); } fprintf(output, ">\n"); if (grammar->start == NULL) { fprintf(output, " "); } else { fprintf(output, "\n"); xmlRelaxNGDumpDefine(output, grammar->start); fprintf(output, "\n"); } /* TODO ? Dump the defines ? */ fprintf(output, "\n"); } /** * xmlRelaxNGDump: * @output: the file output * @schema: a schema structure * * Dump a RelaxNG structure back */ void xmlRelaxNGDump(FILE * output, xmlRelaxNGPtr schema) { if (output == NULL) return; if (schema == NULL) { fprintf(output, "RelaxNG empty or failed to compile\n"); return; } fprintf(output, "RelaxNG: "); if (schema->doc == NULL) { fprintf(output, "no document\n"); } else if (schema->doc->URL != NULL) { fprintf(output, "%s\n", schema->doc->URL); } else { fprintf(output, "\n"); } if (schema->topgrammar == NULL) { fprintf(output, "RelaxNG has no top grammar\n"); return; } xmlRelaxNGDumpGrammar(output, schema->topgrammar, 1); } /** * xmlRelaxNGDumpTree: * @output: the file output * @schema: a schema structure * * Dump the transformed RelaxNG tree. */ void xmlRelaxNGDumpTree(FILE * output, xmlRelaxNGPtr schema) { if (output == NULL) return; if (schema == NULL) { fprintf(output, "RelaxNG empty or failed to compile\n"); return; } if (schema->doc == NULL) { fprintf(output, "no document\n"); } else { xmlDocDump(output, schema->doc); } } #endif /* LIBXML_OUTPUT_ENABLED */ /************************************************************************ * * * Validation of compiled content * * * ************************************************************************/ static int xmlRelaxNGValidateDefinition(xmlRelaxNGValidCtxtPtr ctxt, xmlRelaxNGDefinePtr define); /** * xmlRelaxNGValidateCompiledCallback: * @exec: the regular expression instance * @token: the token which matched * @transdata: callback data, the define for the subelement if available @ @inputdata: callback data, the Relax NG validation context * * Handle the callback and if needed validate the element children. */ static void xmlRelaxNGValidateCompiledCallback(xmlRegExecCtxtPtr exec ATTRIBUTE_UNUSED, const xmlChar * token, void *transdata, void *inputdata) { xmlRelaxNGValidCtxtPtr ctxt = (xmlRelaxNGValidCtxtPtr) inputdata; xmlRelaxNGDefinePtr define = (xmlRelaxNGDefinePtr) transdata; int ret; #ifdef DEBUG_COMPILE xmlGenericError(xmlGenericErrorContext, "Compiled callback for: '%s'\n", token); #endif if (ctxt == NULL) { fprintf(stderr, "callback on %s missing context\n", token); return; } if (define == NULL) { if (token[0] == '#') return; fprintf(stderr, "callback on %s missing define\n", token); if ((ctxt != NULL) && (ctxt->errNo == XML_RELAXNG_OK)) ctxt->errNo = XML_RELAXNG_ERR_INTERNAL; return; } if ((ctxt == NULL) || (define == NULL)) { fprintf(stderr, "callback on %s missing info\n", token); if ((ctxt != NULL) && (ctxt->errNo == XML_RELAXNG_OK)) ctxt->errNo = XML_RELAXNG_ERR_INTERNAL; return; } else if (define->type != XML_RELAXNG_ELEMENT) { fprintf(stderr, "callback on %s define is not element\n", token); if (ctxt->errNo == XML_RELAXNG_OK) ctxt->errNo = XML_RELAXNG_ERR_INTERNAL; return; } ret = xmlRelaxNGValidateDefinition(ctxt, define); if (ret != 0) ctxt->perr = ret; } /** * xmlRelaxNGValidateCompiledContent: * @ctxt: the RelaxNG validation context * @regexp: the regular expression as compiled * @content: list of children to test against the regexp * * Validate the content model of an element or start using the regexp * * Returns 0 in case of success, -1 in case of error. */ static int xmlRelaxNGValidateCompiledContent(xmlRelaxNGValidCtxtPtr ctxt, xmlRegexpPtr regexp, xmlNodePtr content) { xmlRegExecCtxtPtr exec; xmlNodePtr cur; int ret = 0; int oldperr; if ((ctxt == NULL) || (regexp == NULL)) return (-1); oldperr = ctxt->perr; exec = xmlRegNewExecCtxt(regexp, xmlRelaxNGValidateCompiledCallback, ctxt); ctxt->perr = 0; cur = content; while (cur != NULL) { ctxt->state->seq = cur; switch (cur->type) { case XML_TEXT_NODE: case XML_CDATA_SECTION_NODE: if (xmlIsBlankNode(cur)) break; ret = xmlRegExecPushString(exec, BAD_CAST "#text", ctxt); if (ret < 0) { VALID_ERR2(XML_RELAXNG_ERR_TEXTWRONG, cur->parent->name); } break; case XML_ELEMENT_NODE: if (cur->ns != NULL) { ret = xmlRegExecPushString2(exec, cur->name, cur->ns->href, ctxt); } else { ret = xmlRegExecPushString(exec, cur->name, ctxt); } if (ret < 0) { VALID_ERR2(XML_RELAXNG_ERR_ELEMWRONG, cur->name); } break; default: break; } if (ret < 0) break; /* * Switch to next element */ cur = cur->next; } ret = xmlRegExecPushString(exec, NULL, NULL); if (ret == 1) { ret = 0; ctxt->state->seq = NULL; } else if (ret == 0) { /* * TODO: get some of the names needed to exit the current state of exec */ VALID_ERR2(XML_RELAXNG_ERR_NOELEM, BAD_CAST ""); ret = -1; if ((ctxt->flags & FLAGS_IGNORABLE) == 0) xmlRelaxNGDumpValidError(ctxt); } else { ret = -1; } xmlRegFreeExecCtxt(exec); /* * There might be content model errors outside of the pure * regexp validation, e.g. for attribute values. */ if ((ret == 0) && (ctxt->perr != 0)) { ret = ctxt->perr; } ctxt->perr = oldperr; return (ret); } /************************************************************************ * * * Progressive validation of when possible * * * ************************************************************************/ static int xmlRelaxNGValidateAttributeList(xmlRelaxNGValidCtxtPtr ctxt, xmlRelaxNGDefinePtr defines); static int xmlRelaxNGValidateElementEnd(xmlRelaxNGValidCtxtPtr ctxt, int dolog); static void xmlRelaxNGLogBestError(xmlRelaxNGValidCtxtPtr ctxt); /** * xmlRelaxNGElemPush: * @ctxt: the validation context * @exec: the regexp runtime for the new content model * * Push a new regexp for the current node content model on the stack * * Returns 0 in case of success and -1 in case of error. */ static int xmlRelaxNGElemPush(xmlRelaxNGValidCtxtPtr ctxt, xmlRegExecCtxtPtr exec) { if (ctxt->elemTab == NULL) { ctxt->elemMax = 10; ctxt->elemTab = (xmlRegExecCtxtPtr *) xmlMalloc(ctxt->elemMax * sizeof (xmlRegExecCtxtPtr)); if (ctxt->elemTab == NULL) { xmlRngVErrMemory(ctxt, "validating\n"); return (-1); } } if (ctxt->elemNr >= ctxt->elemMax) { ctxt->elemMax *= 2; ctxt->elemTab = (xmlRegExecCtxtPtr *) xmlRealloc(ctxt->elemTab, ctxt->elemMax * sizeof (xmlRegExecCtxtPtr)); if (ctxt->elemTab == NULL) { xmlRngVErrMemory(ctxt, "validating\n"); return (-1); } } ctxt->elemTab[ctxt->elemNr++] = exec; ctxt->elem = exec; return (0); } /** * xmlRelaxNGElemPop: * @ctxt: the validation context * * Pop the regexp of the current node content model from the stack * * Returns the exec or NULL if empty */ static xmlRegExecCtxtPtr xmlRelaxNGElemPop(xmlRelaxNGValidCtxtPtr ctxt) { xmlRegExecCtxtPtr ret; if (ctxt->elemNr <= 0) return (NULL); ctxt->elemNr--; ret = ctxt->elemTab[ctxt->elemNr]; ctxt->elemTab[ctxt->elemNr] = NULL; if (ctxt->elemNr > 0) ctxt->elem = ctxt->elemTab[ctxt->elemNr - 1]; else ctxt->elem = NULL; return (ret); } /** * xmlRelaxNGValidateProgressiveCallback: * @exec: the regular expression instance * @token: the token which matched * @transdata: callback data, the define for the subelement if available @ @inputdata: callback data, the Relax NG validation context * * Handle the callback and if needed validate the element children. * some of the in/out informations are passed via the context in @inputdata. */ static void xmlRelaxNGValidateProgressiveCallback(xmlRegExecCtxtPtr exec ATTRIBUTE_UNUSED, const xmlChar * token, void *transdata, void *inputdata) { xmlRelaxNGValidCtxtPtr ctxt = (xmlRelaxNGValidCtxtPtr) inputdata; xmlRelaxNGDefinePtr define = (xmlRelaxNGDefinePtr) transdata; xmlRelaxNGValidStatePtr state, oldstate; xmlNodePtr node; int ret = 0, oldflags; #ifdef DEBUG_PROGRESSIVE xmlGenericError(xmlGenericErrorContext, "Progressive callback for: '%s'\n", token); #endif if (ctxt == NULL) { fprintf(stderr, "callback on %s missing context\n", token); return; } node = ctxt->pnode; ctxt->pstate = 1; if (define == NULL) { if (token[0] == '#') return; fprintf(stderr, "callback on %s missing define\n", token); if ((ctxt != NULL) && (ctxt->errNo == XML_RELAXNG_OK)) ctxt->errNo = XML_RELAXNG_ERR_INTERNAL; ctxt->pstate = -1; return; } if ((ctxt == NULL) || (define == NULL)) { fprintf(stderr, "callback on %s missing info\n", token); if ((ctxt != NULL) && (ctxt->errNo == XML_RELAXNG_OK)) ctxt->errNo = XML_RELAXNG_ERR_INTERNAL; ctxt->pstate = -1; return; } else if (define->type != XML_RELAXNG_ELEMENT) { fprintf(stderr, "callback on %s define is not element\n", token); if (ctxt->errNo == XML_RELAXNG_OK) ctxt->errNo = XML_RELAXNG_ERR_INTERNAL; ctxt->pstate = -1; return; } if (node->type != XML_ELEMENT_NODE) { VALID_ERR(XML_RELAXNG_ERR_NOTELEM); if ((ctxt->flags & FLAGS_IGNORABLE) == 0) xmlRelaxNGDumpValidError(ctxt); ctxt->pstate = -1; return; } if (define->contModel == NULL) { /* * this node cannot be validated in a streamable fashion */ #ifdef DEBUG_PROGRESSIVE xmlGenericError(xmlGenericErrorContext, "Element '%s' validation is not streamable\n", token); #endif ctxt->pstate = 0; ctxt->pdef = define; return; } exec = xmlRegNewExecCtxt(define->contModel, xmlRelaxNGValidateProgressiveCallback, ctxt); if (exec == NULL) { ctxt->pstate = -1; return; } xmlRelaxNGElemPush(ctxt, exec); /* * Validate the attributes part of the content. */ state = xmlRelaxNGNewValidState(ctxt, node); if (state == NULL) { ctxt->pstate = -1; return; } oldstate = ctxt->state; ctxt->state = state; if (define->attrs != NULL) { ret = xmlRelaxNGValidateAttributeList(ctxt, define->attrs); if (ret != 0) { ctxt->pstate = -1; VALID_ERR2(XML_RELAXNG_ERR_ATTRVALID, node->name); } } if (ctxt->state != NULL) { ctxt->state->seq = NULL; ret = xmlRelaxNGValidateElementEnd(ctxt, 1); if (ret != 0) { ctxt->pstate = -1; } xmlRelaxNGFreeValidState(ctxt, ctxt->state); } else if (ctxt->states != NULL) { int tmp = -1, i; oldflags = ctxt->flags; for (i = 0; i < ctxt->states->nbState; i++) { state = ctxt->states->tabState[i]; ctxt->state = state; ctxt->state->seq = NULL; if (xmlRelaxNGValidateElementEnd(ctxt, 0) == 0) { tmp = 0; break; } } if (tmp != 0) { /* * validation error, log the message for the "best" one */ ctxt->flags |= FLAGS_IGNORABLE; xmlRelaxNGLogBestError(ctxt); } for (i = 0; i < ctxt->states->nbState; i++) { xmlRelaxNGFreeValidState(ctxt, ctxt->states->tabState[i]); } xmlRelaxNGFreeStates(ctxt, ctxt->states); ctxt->states = NULL; if ((ret == 0) && (tmp == -1)) ctxt->pstate = -1; ctxt->flags = oldflags; } if (ctxt->pstate == -1) { if ((ctxt->flags & FLAGS_IGNORABLE) == 0) { xmlRelaxNGDumpValidError(ctxt); } } ctxt->state = oldstate; } /** * xmlRelaxNGValidatePushElement: * @ctxt: the validation context * @doc: a document instance * @elem: an element instance * * Push a new element start on the RelaxNG validation stack. * * returns 1 if no validation problem was found or 0 if validating the * element requires a full node, and -1 in case of error. */ int xmlRelaxNGValidatePushElement(xmlRelaxNGValidCtxtPtr ctxt, xmlDocPtr doc ATTRIBUTE_UNUSED, xmlNodePtr elem) { int ret = 1; if ((ctxt == NULL) || (elem == NULL)) return (-1); #ifdef DEBUG_PROGRESSIVE xmlGenericError(xmlGenericErrorContext, "PushElem %s\n", elem->name); #endif if (ctxt->elem == 0) { xmlRelaxNGPtr schema; xmlRelaxNGGrammarPtr grammar; xmlRegExecCtxtPtr exec; xmlRelaxNGDefinePtr define; schema = ctxt->schema; if (schema == NULL) { VALID_ERR(XML_RELAXNG_ERR_NOGRAMMAR); return (-1); } grammar = schema->topgrammar; if ((grammar == NULL) || (grammar->start == NULL)) { VALID_ERR(XML_RELAXNG_ERR_NOGRAMMAR); return (-1); } define = grammar->start; if (define->contModel == NULL) { ctxt->pdef = define; return (0); } exec = xmlRegNewExecCtxt(define->contModel, xmlRelaxNGValidateProgressiveCallback, ctxt); if (exec == NULL) { return (-1); } xmlRelaxNGElemPush(ctxt, exec); } ctxt->pnode = elem; ctxt->pstate = 0; if (elem->ns != NULL) { ret = xmlRegExecPushString2(ctxt->elem, elem->name, elem->ns->href, ctxt); } else { ret = xmlRegExecPushString(ctxt->elem, elem->name, ctxt); } if (ret < 0) { VALID_ERR2(XML_RELAXNG_ERR_ELEMWRONG, elem->name); } else { if (ctxt->pstate == 0) ret = 0; else if (ctxt->pstate < 0) ret = -1; else ret = 1; } #ifdef DEBUG_PROGRESSIVE if (ret < 0) xmlGenericError(xmlGenericErrorContext, "PushElem %s failed\n", elem->name); #endif return (ret); } /** * xmlRelaxNGValidatePushCData: * @ctxt: the RelaxNG validation context * @data: some character data read * @len: the lenght of the data * * check the CData parsed for validation in the current stack * * returns 1 if no validation problem was found or -1 otherwise */ int xmlRelaxNGValidatePushCData(xmlRelaxNGValidCtxtPtr ctxt, const xmlChar * data, int len ATTRIBUTE_UNUSED) { int ret = 1; if ((ctxt == NULL) || (ctxt->elem == NULL) || (data == NULL)) return (-1); #ifdef DEBUG_PROGRESSIVE xmlGenericError(xmlGenericErrorContext, "CDATA %s %d\n", data, len); #endif while (*data != 0) { if (!IS_BLANK_CH(*data)) break; data++; } if (*data == 0) return (1); ret = xmlRegExecPushString(ctxt->elem, BAD_CAST "#text", ctxt); if (ret < 0) { VALID_ERR2(XML_RELAXNG_ERR_TEXTWRONG, BAD_CAST " TODO "); #ifdef DEBUG_PROGRESSIVE xmlGenericError(xmlGenericErrorContext, "CDATA failed\n"); #endif return (-1); } return (1); } /** * xmlRelaxNGValidatePopElement: * @ctxt: the RelaxNG validation context * @doc: a document instance * @elem: an element instance * * Pop the element end from the RelaxNG validation stack. * * returns 1 if no validation problem was found or 0 otherwise */ int xmlRelaxNGValidatePopElement(xmlRelaxNGValidCtxtPtr ctxt, xmlDocPtr doc ATTRIBUTE_UNUSED, xmlNodePtr elem) { int ret; xmlRegExecCtxtPtr exec; if ((ctxt == NULL) || (ctxt->elem == NULL) || (elem == NULL)) return (-1); #ifdef DEBUG_PROGRESSIVE xmlGenericError(xmlGenericErrorContext, "PopElem %s\n", elem->name); #endif /* * verify that we reached a terminal state of the content model. */ exec = xmlRelaxNGElemPop(ctxt); ret = xmlRegExecPushString(exec, NULL, NULL); if (ret == 0) { /* * TODO: get some of the names needed to exit the current state of exec */ VALID_ERR2(XML_RELAXNG_ERR_NOELEM, BAD_CAST ""); ret = -1; } else if (ret < 0) { ret = -1; } else { ret = 1; } xmlRegFreeExecCtxt(exec); #ifdef DEBUG_PROGRESSIVE if (ret < 0) xmlGenericError(xmlGenericErrorContext, "PopElem %s failed\n", elem->name); #endif return (ret); } /** * xmlRelaxNGValidateFullElement: * @ctxt: the validation context * @doc: a document instance * @elem: an element instance * * Validate a full subtree when xmlRelaxNGValidatePushElement() returned * 0 and the content of the node has been expanded. * * returns 1 if no validation problem was found or -1 in case of error. */ int xmlRelaxNGValidateFullElement(xmlRelaxNGValidCtxtPtr ctxt, xmlDocPtr doc ATTRIBUTE_UNUSED, xmlNodePtr elem) { int ret; xmlRelaxNGValidStatePtr state; if ((ctxt == NULL) || (ctxt->pdef == NULL) || (elem == NULL)) return (-1); #ifdef DEBUG_PROGRESSIVE xmlGenericError(xmlGenericErrorContext, "FullElem %s\n", elem->name); #endif state = xmlRelaxNGNewValidState(ctxt, elem->parent); if (state == NULL) { return (-1); } state->seq = elem; ctxt->state = state; ctxt->errNo = XML_RELAXNG_OK; ret = xmlRelaxNGValidateDefinition(ctxt, ctxt->pdef); if ((ret != 0) || (ctxt->errNo != XML_RELAXNG_OK)) ret = -1; else ret = 1; xmlRelaxNGFreeValidState(ctxt, state); ctxt->state = NULL; #ifdef DEBUG_PROGRESSIVE if (ret < 0) xmlGenericError(xmlGenericErrorContext, "FullElem %s failed\n", elem->name); #endif return (ret); } /************************************************************************ * * * Generic interpreted validation implementation * * * ************************************************************************/ static int xmlRelaxNGValidateValue(xmlRelaxNGValidCtxtPtr ctxt, xmlRelaxNGDefinePtr define); /** * xmlRelaxNGSkipIgnored: * @ctxt: a schema validation context * @node: the top node. * * Skip ignorable nodes in that context * * Returns the new sibling or NULL in case of error. */ static xmlNodePtr xmlRelaxNGSkipIgnored(xmlRelaxNGValidCtxtPtr ctxt ATTRIBUTE_UNUSED, xmlNodePtr node) { /* * TODO complete and handle entities */ while ((node != NULL) && ((node->type == XML_COMMENT_NODE) || (node->type == XML_PI_NODE) || (node->type == XML_XINCLUDE_START) || (node->type == XML_XINCLUDE_END) || (((node->type == XML_TEXT_NODE) || (node->type == XML_CDATA_SECTION_NODE)) && ((ctxt->flags & FLAGS_MIXED_CONTENT) || (IS_BLANK_NODE(node)))))) { node = node->next; } return (node); } /** * xmlRelaxNGNormalize: * @ctxt: a schema validation context * @str: the string to normalize * * Implements the normalizeWhiteSpace( s ) function from * section 6.2.9 of the spec * * Returns the new string or NULL in case of error. */ static xmlChar * xmlRelaxNGNormalize(xmlRelaxNGValidCtxtPtr ctxt, const xmlChar * str) { xmlChar *ret, *p; const xmlChar *tmp; int len; if (str == NULL) return (NULL); tmp = str; while (*tmp != 0) tmp++; len = tmp - str; ret = (xmlChar *) xmlMallocAtomic((len + 1) * sizeof(xmlChar)); if (ret == NULL) { xmlRngVErrMemory(ctxt, "validating\n"); return (NULL); } p = ret; while (IS_BLANK_CH(*str)) str++; while (*str != 0) { if (IS_BLANK_CH(*str)) { while (IS_BLANK_CH(*str)) str++; if (*str == 0) break; *p++ = ' '; } else *p++ = *str++; } *p = 0; return (ret); } /** * xmlRelaxNGValidateDatatype: * @ctxt: a Relax-NG validation context * @value: the string value * @type: the datatype definition * @node: the node * * Validate the given value against the dataype * * Returns 0 if the validation succeeded or an error code. */ static int xmlRelaxNGValidateDatatype(xmlRelaxNGValidCtxtPtr ctxt, const xmlChar * value, xmlRelaxNGDefinePtr define, xmlNodePtr node) { int ret, tmp; xmlRelaxNGTypeLibraryPtr lib; void *result = NULL; xmlRelaxNGDefinePtr cur; if ((define == NULL) || (define->data == NULL)) { return (-1); } lib = (xmlRelaxNGTypeLibraryPtr) define->data; if (lib->check != NULL) { if ((define->attrs != NULL) && (define->attrs->type == XML_RELAXNG_PARAM)) { ret = lib->check(lib->data, define->name, value, &result, node); } else { ret = lib->check(lib->data, define->name, value, NULL, node); } } else ret = -1; if (ret < 0) { VALID_ERR2(XML_RELAXNG_ERR_TYPE, define->name); if ((result != NULL) && (lib != NULL) && (lib->freef != NULL)) lib->freef(lib->data, result); return (-1); } else if (ret == 1) { ret = 0; } else if (ret == 2) { VALID_ERR2P(XML_RELAXNG_ERR_DUPID, value); } else { VALID_ERR3P(XML_RELAXNG_ERR_TYPEVAL, define->name, value); ret = -1; } cur = define->attrs; while ((ret == 0) && (cur != NULL) && (cur->type == XML_RELAXNG_PARAM)) { if (lib->facet != NULL) { tmp = lib->facet(lib->data, define->name, cur->name, cur->value, value, result); if (tmp != 0) ret = -1; } cur = cur->next; } if ((ret == 0) && (define->content != NULL)) { const xmlChar *oldvalue, *oldendvalue; oldvalue = ctxt->state->value; oldendvalue = ctxt->state->endvalue; ctxt->state->value = (xmlChar *) value; ctxt->state->endvalue = NULL; ret = xmlRelaxNGValidateValue(ctxt, define->content); ctxt->state->value = (xmlChar *) oldvalue; ctxt->state->endvalue = (xmlChar *) oldendvalue; } if ((result != NULL) && (lib != NULL) && (lib->freef != NULL)) lib->freef(lib->data, result); return (ret); } /** * xmlRelaxNGNextValue: * @ctxt: a Relax-NG validation context * * Skip to the next value when validating within a list * * Returns 0 if the operation succeeded or an error code. */ static int xmlRelaxNGNextValue(xmlRelaxNGValidCtxtPtr ctxt) { xmlChar *cur; cur = ctxt->state->value; if ((cur == NULL) || (ctxt->state->endvalue == NULL)) { ctxt->state->value = NULL; ctxt->state->endvalue = NULL; return (0); } while (*cur != 0) cur++; while ((cur != ctxt->state->endvalue) && (*cur == 0)) cur++; if (cur == ctxt->state->endvalue) ctxt->state->value = NULL; else ctxt->state->value = cur; return (0); } /** * xmlRelaxNGValidateValueList: * @ctxt: a Relax-NG validation context * @defines: the list of definitions to verify * * Validate the given set of definitions for the current value * * Returns 0 if the validation succeeded or an error code. */ static int xmlRelaxNGValidateValueList(xmlRelaxNGValidCtxtPtr ctxt, xmlRelaxNGDefinePtr defines) { int ret = 0; while (defines != NULL) { ret = xmlRelaxNGValidateValue(ctxt, defines); if (ret != 0) break; defines = defines->next; } return (ret); } /** * xmlRelaxNGValidateValue: * @ctxt: a Relax-NG validation context * @define: the definition to verify * * Validate the given definition for the current value * * Returns 0 if the validation succeeded or an error code. */ static int xmlRelaxNGValidateValue(xmlRelaxNGValidCtxtPtr ctxt, xmlRelaxNGDefinePtr define) { int ret = 0, oldflags; xmlChar *value; value = ctxt->state->value; switch (define->type) { case XML_RELAXNG_EMPTY:{ if ((value != NULL) && (value[0] != 0)) { int idx = 0; while (IS_BLANK_CH(value[idx])) idx++; if (value[idx] != 0) ret = -1; } break; } case XML_RELAXNG_TEXT: break; case XML_RELAXNG_VALUE:{ if (!xmlStrEqual(value, define->value)) { if (define->name != NULL) { xmlRelaxNGTypeLibraryPtr lib; lib = (xmlRelaxNGTypeLibraryPtr) define->data; if ((lib != NULL) && (lib->comp != NULL)) { ret = lib->comp(lib->data, define->name, define->value, define->node, (void *) define->attrs, value, ctxt->state->node); } else ret = -1; if (ret < 0) { VALID_ERR2(XML_RELAXNG_ERR_TYPECMP, define->name); return (-1); } else if (ret == 1) { ret = 0; } else { ret = -1; } } else { xmlChar *nval, *nvalue; /* * TODO: trivial optimizations are possible by * computing at compile-time */ nval = xmlRelaxNGNormalize(ctxt, define->value); nvalue = xmlRelaxNGNormalize(ctxt, value); if ((nval == NULL) || (nvalue == NULL) || (!xmlStrEqual(nval, nvalue))) ret = -1; if (nval != NULL) xmlFree(nval); if (nvalue != NULL) xmlFree(nvalue); } } if (ret == 0) xmlRelaxNGNextValue(ctxt); break; } case XML_RELAXNG_DATATYPE:{ ret = xmlRelaxNGValidateDatatype(ctxt, value, define, ctxt->state->seq); if (ret == 0) xmlRelaxNGNextValue(ctxt); break; } case XML_RELAXNG_CHOICE:{ xmlRelaxNGDefinePtr list = define->content; xmlChar *oldvalue; oldflags = ctxt->flags; ctxt->flags |= FLAGS_IGNORABLE; oldvalue = ctxt->state->value; while (list != NULL) { ret = xmlRelaxNGValidateValue(ctxt, list); if (ret == 0) { break; } ctxt->state->value = oldvalue; list = list->next; } ctxt->flags = oldflags; if (ret != 0) { if ((ctxt->flags & FLAGS_IGNORABLE) == 0) xmlRelaxNGDumpValidError(ctxt); } else { if (ctxt->errNr > 0) xmlRelaxNGPopErrors(ctxt, 0); } break; } case XML_RELAXNG_LIST:{ xmlRelaxNGDefinePtr list = define->content; xmlChar *oldvalue, *oldend, *val, *cur; #ifdef DEBUG_LIST int nb_values = 0; #endif oldvalue = ctxt->state->value; oldend = ctxt->state->endvalue; val = xmlStrdup(oldvalue); if (val == NULL) { val = xmlStrdup(BAD_CAST ""); } if (val == NULL) { VALID_ERR(XML_RELAXNG_ERR_NOSTATE); return (-1); } cur = val; while (*cur != 0) { if (IS_BLANK_CH(*cur)) { *cur = 0; cur++; #ifdef DEBUG_LIST nb_values++; #endif while (IS_BLANK_CH(*cur)) *cur++ = 0; } else cur++; } #ifdef DEBUG_LIST xmlGenericError(xmlGenericErrorContext, "list value: '%s' found %d items\n", oldvalue, nb_values); nb_values = 0; #endif ctxt->state->endvalue = cur; cur = val; while ((*cur == 0) && (cur != ctxt->state->endvalue)) cur++; ctxt->state->value = cur; while (list != NULL) { if (ctxt->state->value == ctxt->state->endvalue) ctxt->state->value = NULL; ret = xmlRelaxNGValidateValue(ctxt, list); if (ret != 0) { #ifdef DEBUG_LIST xmlGenericError(xmlGenericErrorContext, "Failed to validate value: '%s' with %d rule\n", ctxt->state->value, nb_values); #endif break; } #ifdef DEBUG_LIST nb_values++; #endif list = list->next; } if ((ret == 0) && (ctxt->state->value != NULL) && (ctxt->state->value != ctxt->state->endvalue)) { VALID_ERR2(XML_RELAXNG_ERR_LISTEXTRA, ctxt->state->value); ret = -1; } xmlFree(val); ctxt->state->value = oldvalue; ctxt->state->endvalue = oldend; break; } case XML_RELAXNG_ONEORMORE: ret = xmlRelaxNGValidateValueList(ctxt, define->content); if (ret != 0) { break; } /* no break on purpose */ case XML_RELAXNG_ZEROORMORE:{ xmlChar *cur, *temp; oldflags = ctxt->flags; ctxt->flags |= FLAGS_IGNORABLE; cur = ctxt->state->value; temp = NULL; while ((cur != NULL) && (cur != ctxt->state->endvalue) && (temp != cur)) { temp = cur; ret = xmlRelaxNGValidateValueList(ctxt, define->content); if (ret != 0) { ctxt->state->value = temp; ret = 0; break; } cur = ctxt->state->value; } ctxt->flags = oldflags; if (ctxt->errNr > 0) xmlRelaxNGPopErrors(ctxt, 0); break; } case XML_RELAXNG_EXCEPT:{ xmlRelaxNGDefinePtr list; list = define->content; while (list != NULL) { ret = xmlRelaxNGValidateValue(ctxt, list); if (ret == 0) { ret = -1; break; } else ret = 0; list = list->next; } break; } case XML_RELAXNG_DEF: case XML_RELAXNG_GROUP:{ xmlRelaxNGDefinePtr list; list = define->content; while (list != NULL) { ret = xmlRelaxNGValidateValue(ctxt, list); if (ret != 0) { ret = -1; break; } else ret = 0; list = list->next; } break; } case XML_RELAXNG_REF: case XML_RELAXNG_PARENTREF: ret = xmlRelaxNGValidateValue(ctxt, define->content); break; default: TODO ret = -1; } return (ret); } /** * xmlRelaxNGValidateValueContent: * @ctxt: a Relax-NG validation context * @defines: the list of definitions to verify * * Validate the given definitions for the current value * * Returns 0 if the validation succeeded or an error code. */ static int xmlRelaxNGValidateValueContent(xmlRelaxNGValidCtxtPtr ctxt, xmlRelaxNGDefinePtr defines) { int ret = 0; while (defines != NULL) { ret = xmlRelaxNGValidateValue(ctxt, defines); if (ret != 0) break; defines = defines->next; } return (ret); } /** * xmlRelaxNGAttributeMatch: * @ctxt: a Relax-NG validation context * @define: the definition to check * @prop: the attribute * * Check if the attribute matches the definition nameClass * * Returns 1 if the attribute matches, 0 if no, or -1 in case of error */ static int xmlRelaxNGAttributeMatch(xmlRelaxNGValidCtxtPtr ctxt, xmlRelaxNGDefinePtr define, xmlAttrPtr prop) { int ret; if (define->name != NULL) { if (!xmlStrEqual(define->name, prop->name)) return (0); } if (define->ns != NULL) { if (define->ns[0] == 0) { if (prop->ns != NULL) return (0); } else { if ((prop->ns == NULL) || (!xmlStrEqual(define->ns, prop->ns->href))) return (0); } } if (define->nameClass == NULL) return (1); define = define->nameClass; if (define->type == XML_RELAXNG_EXCEPT) { xmlRelaxNGDefinePtr list; list = define->content; while (list != NULL) { ret = xmlRelaxNGAttributeMatch(ctxt, list, prop); if (ret == 1) return (0); if (ret < 0) return (ret); list = list->next; } } else { TODO} return (1); } /** * xmlRelaxNGValidateAttribute: * @ctxt: a Relax-NG validation context * @define: the definition to verify * * Validate the given attribute definition for that node * * Returns 0 if the validation succeeded or an error code. */ static int xmlRelaxNGValidateAttribute(xmlRelaxNGValidCtxtPtr ctxt, xmlRelaxNGDefinePtr define) { int ret = 0, i; xmlChar *value, *oldvalue; xmlAttrPtr prop = NULL, tmp; xmlNodePtr oldseq; if (ctxt->state->nbAttrLeft <= 0) return (-1); if (define->name != NULL) { for (i = 0; i < ctxt->state->nbAttrs; i++) { tmp = ctxt->state->attrs[i]; if ((tmp != NULL) && (xmlStrEqual(define->name, tmp->name))) { if ((((define->ns == NULL) || (define->ns[0] == 0)) && (tmp->ns == NULL)) || ((tmp->ns != NULL) && (xmlStrEqual(define->ns, tmp->ns->href)))) { prop = tmp; break; } } } if (prop != NULL) { value = xmlNodeListGetString(prop->doc, prop->children, 1); oldvalue = ctxt->state->value; oldseq = ctxt->state->seq; ctxt->state->seq = (xmlNodePtr) prop; ctxt->state->value = value; ctxt->state->endvalue = NULL; ret = xmlRelaxNGValidateValueContent(ctxt, define->content); if (ctxt->state->value != NULL) value = ctxt->state->value; if (value != NULL) xmlFree(value); ctxt->state->value = oldvalue; ctxt->state->seq = oldseq; if (ret == 0) { /* * flag the attribute as processed */ ctxt->state->attrs[i] = NULL; ctxt->state->nbAttrLeft--; } } else { ret = -1; } #ifdef DEBUG xmlGenericError(xmlGenericErrorContext, "xmlRelaxNGValidateAttribute(%s): %d\n", define->name, ret); #endif } else { for (i = 0; i < ctxt->state->nbAttrs; i++) { tmp = ctxt->state->attrs[i]; if ((tmp != NULL) && (xmlRelaxNGAttributeMatch(ctxt, define, tmp) == 1)) { prop = tmp; break; } } if (prop != NULL) { value = xmlNodeListGetString(prop->doc, prop->children, 1); oldvalue = ctxt->state->value; oldseq = ctxt->state->seq; ctxt->state->seq = (xmlNodePtr) prop; ctxt->state->value = value; ret = xmlRelaxNGValidateValueContent(ctxt, define->content); if (ctxt->state->value != NULL) value = ctxt->state->value; if (value != NULL) xmlFree(value); ctxt->state->value = oldvalue; ctxt->state->seq = oldseq; if (ret == 0) { /* * flag the attribute as processed */ ctxt->state->attrs[i] = NULL; ctxt->state->nbAttrLeft--; } } else { ret = -1; } #ifdef DEBUG if (define->ns != NULL) { xmlGenericError(xmlGenericErrorContext, "xmlRelaxNGValidateAttribute(nsName ns = %s): %d\n", define->ns, ret); } else { xmlGenericError(xmlGenericErrorContext, "xmlRelaxNGValidateAttribute(anyName): %d\n", ret); } #endif } return (ret); } /** * xmlRelaxNGValidateAttributeList: * @ctxt: a Relax-NG validation context * @define: the list of definition to verify * * Validate the given node against the list of attribute definitions * * Returns 0 if the validation succeeded or an error code. */ static int xmlRelaxNGValidateAttributeList(xmlRelaxNGValidCtxtPtr ctxt, xmlRelaxNGDefinePtr defines) { int ret = 0, res; int needmore = 0; xmlRelaxNGDefinePtr cur; cur = defines; while (cur != NULL) { if (cur->type == XML_RELAXNG_ATTRIBUTE) { if (xmlRelaxNGValidateAttribute(ctxt, cur) != 0) ret = -1; } else needmore = 1; cur = cur->next; } if (!needmore) return (ret); cur = defines; while (cur != NULL) { if (cur->type != XML_RELAXNG_ATTRIBUTE) { if ((ctxt->state != NULL) || (ctxt->states != NULL)) { res = xmlRelaxNGValidateDefinition(ctxt, cur); if (res < 0) ret = -1; } else { VALID_ERR(XML_RELAXNG_ERR_NOSTATE); return (-1); } if (res == -1) /* continues on -2 */ break; } cur = cur->next; } return (ret); } /** * xmlRelaxNGNodeMatchesList: * @node: the node * @list: a NULL terminated array of definitions * * Check if a node can be matched by one of the definitions * * Returns 1 if matches 0 otherwise */ static int xmlRelaxNGNodeMatchesList(xmlNodePtr node, xmlRelaxNGDefinePtr * list) { xmlRelaxNGDefinePtr cur; int i = 0, tmp; if ((node == NULL) || (list == NULL)) return (0); cur = list[i++]; while (cur != NULL) { if ((node->type == XML_ELEMENT_NODE) && (cur->type == XML_RELAXNG_ELEMENT)) { tmp = xmlRelaxNGElementMatch(NULL, cur, node); if (tmp == 1) return (1); } else if (((node->type == XML_TEXT_NODE) || (node->type == XML_CDATA_SECTION_NODE)) && (cur->type == XML_RELAXNG_TEXT)) { return (1); } cur = list[i++]; } return (0); } /** * xmlRelaxNGValidateInterleave: * @ctxt: a Relax-NG validation context * @define: the definition to verify * * Validate an interleave definition for a node. * * Returns 0 if the validation succeeded or an error code. */ static int xmlRelaxNGValidateInterleave(xmlRelaxNGValidCtxtPtr ctxt, xmlRelaxNGDefinePtr define) { int ret = 0, i, nbgroups; int errNr = ctxt->errNr; int oldflags; xmlRelaxNGValidStatePtr oldstate; xmlRelaxNGPartitionPtr partitions; xmlRelaxNGInterleaveGroupPtr group = NULL; xmlNodePtr cur, start, last = NULL, lastchg = NULL, lastelem; xmlNodePtr *list = NULL, *lasts = NULL; if (define->data != NULL) { partitions = (xmlRelaxNGPartitionPtr) define->data; nbgroups = partitions->nbgroups; } else { VALID_ERR(XML_RELAXNG_ERR_INTERNODATA); return (-1); } /* * Optimizations for MIXED */ oldflags = ctxt->flags; if (define->dflags & IS_MIXED) { ctxt->flags |= FLAGS_MIXED_CONTENT; if (nbgroups == 2) { /* * this is a pure case */ if (ctxt->state != NULL) ctxt->state->seq = xmlRelaxNGSkipIgnored(ctxt, ctxt->state->seq); if (partitions->groups[0]->rule->type == XML_RELAXNG_TEXT) ret = xmlRelaxNGValidateDefinition(ctxt, partitions->groups[1]-> rule); else ret = xmlRelaxNGValidateDefinition(ctxt, partitions->groups[0]-> rule); if (ret == 0) { if (ctxt->state != NULL) ctxt->state->seq = xmlRelaxNGSkipIgnored(ctxt, ctxt->state-> seq); } ctxt->flags = oldflags; return (ret); } } /* * Build arrays to store the first and last node of the chain * pertaining to each group */ list = (xmlNodePtr *) xmlMalloc(nbgroups * sizeof(xmlNodePtr)); if (list == NULL) { xmlRngVErrMemory(ctxt, "validating\n"); return (-1); } memset(list, 0, nbgroups * sizeof(xmlNodePtr)); lasts = (xmlNodePtr *) xmlMalloc(nbgroups * sizeof(xmlNodePtr)); if (lasts == NULL) { xmlRngVErrMemory(ctxt, "validating\n"); return (-1); } memset(lasts, 0, nbgroups * sizeof(xmlNodePtr)); /* * Walk the sequence of children finding the right group and * sorting them in sequences. */ cur = ctxt->state->seq; cur = xmlRelaxNGSkipIgnored(ctxt, cur); start = cur; while (cur != NULL) { ctxt->state->seq = cur; if ((partitions->triage != NULL) && (partitions->flags & IS_DETERMINIST)) { void *tmp = NULL; if ((cur->type == XML_TEXT_NODE) || (cur->type == XML_CDATA_SECTION_NODE)) { tmp = xmlHashLookup2(partitions->triage, BAD_CAST "#text", NULL); } else if (cur->type == XML_ELEMENT_NODE) { if (cur->ns != NULL) { tmp = xmlHashLookup2(partitions->triage, cur->name, cur->ns->href); if (tmp == NULL) tmp = xmlHashLookup2(partitions->triage, BAD_CAST "#any", cur->ns->href); } else tmp = xmlHashLookup2(partitions->triage, cur->name, NULL); if (tmp == NULL) tmp = xmlHashLookup2(partitions->triage, BAD_CAST "#any", NULL); } if (tmp == NULL) { i = nbgroups; } else { i = ((long) tmp) - 1; if (partitions->flags & IS_NEEDCHECK) { group = partitions->groups[i]; if (!xmlRelaxNGNodeMatchesList(cur, group->defs)) i = nbgroups; } } } else { for (i = 0; i < nbgroups; i++) { group = partitions->groups[i]; if (group == NULL) continue; if (xmlRelaxNGNodeMatchesList(cur, group->defs)) break; } } /* * We break as soon as an element not matched is found */ if (i >= nbgroups) { break; } if (lasts[i] != NULL) { lasts[i]->next = cur; lasts[i] = cur; } else { list[i] = cur; lasts[i] = cur; } if (cur->next != NULL) lastchg = cur->next; else lastchg = cur; cur = xmlRelaxNGSkipIgnored(ctxt, cur->next); } if (ret != 0) { VALID_ERR(XML_RELAXNG_ERR_INTERSEQ); ret = -1; goto done; } lastelem = cur; oldstate = ctxt->state; for (i = 0; i < nbgroups; i++) { ctxt->state = xmlRelaxNGCopyValidState(ctxt, oldstate); group = partitions->groups[i]; if (lasts[i] != NULL) { last = lasts[i]->next; lasts[i]->next = NULL; } ctxt->state->seq = list[i]; ret = xmlRelaxNGValidateDefinition(ctxt, group->rule); if (ret != 0) break; if (ctxt->state != NULL) { cur = ctxt->state->seq; cur = xmlRelaxNGSkipIgnored(ctxt, cur); xmlRelaxNGFreeValidState(ctxt, oldstate); oldstate = ctxt->state; ctxt->state = NULL; if (cur != NULL) { VALID_ERR2(XML_RELAXNG_ERR_INTEREXTRA, cur->name); ret = -1; ctxt->state = oldstate; goto done; } } else if (ctxt->states != NULL) { int j; int found = 0; int best = -1; int lowattr = -1; /* * PBM: what happen if there is attributes checks in the interleaves */ for (j = 0; j < ctxt->states->nbState; j++) { cur = ctxt->states->tabState[j]->seq; cur = xmlRelaxNGSkipIgnored(ctxt, cur); if (cur == NULL) { if (found == 0) { lowattr = ctxt->states->tabState[j]->nbAttrLeft; best = j; } found = 1; if (ctxt->states->tabState[j]->nbAttrLeft <= lowattr) { /* try to keep the latest one to mach old heuristic */ lowattr = ctxt->states->tabState[j]->nbAttrLeft; best = j; } if (lowattr == 0) break; } else if (found == 0) { if (lowattr == -1) { lowattr = ctxt->states->tabState[j]->nbAttrLeft; best = j; } else if (ctxt->states->tabState[j]->nbAttrLeft <= lowattr) { /* try to keep the latest one to mach old heuristic */ lowattr = ctxt->states->tabState[j]->nbAttrLeft; best = j; } } } /* * BIG PBM: here we pick only one restarting point :-( */ if (ctxt->states->nbState > 0) { xmlRelaxNGFreeValidState(ctxt, oldstate); if (best != -1) { oldstate = ctxt->states->tabState[best]; ctxt->states->tabState[best] = NULL; } else { oldstate = ctxt->states->tabState[ctxt->states->nbState - 1]; ctxt->states->tabState[ctxt->states->nbState - 1] = NULL; } } for (j = 0; j < ctxt->states->nbState ; j++) { xmlRelaxNGFreeValidState(ctxt, ctxt->states->tabState[j]); } xmlRelaxNGFreeStates(ctxt, ctxt->states); ctxt->states = NULL; if (found == 0) { VALID_ERR2(XML_RELAXNG_ERR_INTEREXTRA, cur->name); ret = -1; ctxt->state = oldstate; goto done; } } else { ret = -1; break; } if (lasts[i] != NULL) { lasts[i]->next = last; } } if (ctxt->state != NULL) xmlRelaxNGFreeValidState(ctxt, ctxt->state); ctxt->state = oldstate; ctxt->state->seq = lastelem; if (ret != 0) { VALID_ERR(XML_RELAXNG_ERR_INTERSEQ); ret = -1; goto done; } done: ctxt->flags = oldflags; /* * builds the next links chain from the prev one */ cur = lastchg; while (cur != NULL) { if ((cur == start) || (cur->prev == NULL)) break; cur->prev->next = cur; cur = cur->prev; } if (ret == 0) { if (ctxt->errNr > errNr) xmlRelaxNGPopErrors(ctxt, errNr); } xmlFree(list); xmlFree(lasts); return (ret); } /** * xmlRelaxNGValidateDefinitionList: * @ctxt: a Relax-NG validation context * @define: the list of definition to verify * * Validate the given node content against the (list) of definitions * * Returns 0 if the validation succeeded or an error code. */ static int xmlRelaxNGValidateDefinitionList(xmlRelaxNGValidCtxtPtr ctxt, xmlRelaxNGDefinePtr defines) { int ret = 0, res; if (defines == NULL) { VALID_ERR2(XML_RELAXNG_ERR_INTERNAL, BAD_CAST "NULL definition list"); return (-1); } while (defines != NULL) { if ((ctxt->state != NULL) || (ctxt->states != NULL)) { res = xmlRelaxNGValidateDefinition(ctxt, defines); if (res < 0) ret = -1; } else { VALID_ERR(XML_RELAXNG_ERR_NOSTATE); return (-1); } if (res == -1) /* continues on -2 */ break; defines = defines->next; } return (ret); } /** * xmlRelaxNGElementMatch: * @ctxt: a Relax-NG validation context * @define: the definition to check * @elem: the element * * Check if the element matches the definition nameClass * * Returns 1 if the element matches, 0 if no, or -1 in case of error */ static int xmlRelaxNGElementMatch(xmlRelaxNGValidCtxtPtr ctxt, xmlRelaxNGDefinePtr define, xmlNodePtr elem) { int ret = 0, oldflags = 0; if (define->name != NULL) { if (!xmlStrEqual(elem->name, define->name)) { VALID_ERR3(XML_RELAXNG_ERR_ELEMNAME, define->name, elem->name); return (0); } } if ((define->ns != NULL) && (define->ns[0] != 0)) { if (elem->ns == NULL) { VALID_ERR2(XML_RELAXNG_ERR_ELEMNONS, elem->name); return (0); } else if (!xmlStrEqual(elem->ns->href, define->ns)) { VALID_ERR3(XML_RELAXNG_ERR_ELEMWRONGNS, elem->name, define->ns); return (0); } } else if ((elem->ns != NULL) && (define->ns != NULL) && (define->name == NULL)) { VALID_ERR2(XML_RELAXNG_ERR_ELEMEXTRANS, elem->name); return (0); } else if ((elem->ns != NULL) && (define->name != NULL)) { VALID_ERR2(XML_RELAXNG_ERR_ELEMEXTRANS, define->name); return (0); } if (define->nameClass == NULL) return (1); define = define->nameClass; if (define->type == XML_RELAXNG_EXCEPT) { xmlRelaxNGDefinePtr list; if (ctxt != NULL) { oldflags = ctxt->flags; ctxt->flags |= FLAGS_IGNORABLE; } list = define->content; while (list != NULL) { ret = xmlRelaxNGElementMatch(ctxt, list, elem); if (ret == 1) { if (ctxt != NULL) ctxt->flags = oldflags; return (0); } if (ret < 0) { if (ctxt != NULL) ctxt->flags = oldflags; return (ret); } list = list->next; } ret = 1; if (ctxt != NULL) { ctxt->flags = oldflags; } } else if (define->type == XML_RELAXNG_CHOICE) { xmlRelaxNGDefinePtr list; if (ctxt != NULL) { oldflags = ctxt->flags; ctxt->flags |= FLAGS_IGNORABLE; } list = define->nameClass; while (list != NULL) { ret = xmlRelaxNGElementMatch(ctxt, list, elem); if (ret == 1) { if (ctxt != NULL) ctxt->flags = oldflags; return (1); } if (ret < 0) { if (ctxt != NULL) ctxt->flags = oldflags; return (ret); } list = list->next; } if (ctxt != NULL) { if (ret != 0) { if ((ctxt->flags & FLAGS_IGNORABLE) == 0) xmlRelaxNGDumpValidError(ctxt); } else { if (ctxt->errNr > 0) xmlRelaxNGPopErrors(ctxt, 0); } } ret = 0; if (ctxt != NULL) { ctxt->flags = oldflags; } } else { TODO ret = -1; } return (ret); } /** * xmlRelaxNGBestState: * @ctxt: a Relax-NG validation context * * Find the "best" state in the ctxt->states list of states to report * errors about. I.e. a state with no element left in the child list * or the one with the less attributes left. * This is called only if a falidation error was detected * * Returns the index of the "best" state or -1 in case of error */ static int xmlRelaxNGBestState(xmlRelaxNGValidCtxtPtr ctxt) { xmlRelaxNGValidStatePtr state; int i, tmp; int best = -1; int value = 1000000; if ((ctxt == NULL) || (ctxt->states == NULL) || (ctxt->states->nbState <= 0)) return (-1); for (i = 0; i < ctxt->states->nbState; i++) { state = ctxt->states->tabState[i]; if (state == NULL) continue; if (state->seq != NULL) { if ((best == -1) || (value > 100000)) { value = 100000; best = i; } } else { tmp = state->nbAttrLeft; if ((best == -1) || (value > tmp)) { value = tmp; best = i; } } } return (best); } /** * xmlRelaxNGLogBestError: * @ctxt: a Relax-NG validation context * * Find the "best" state in the ctxt->states list of states to report * errors about and log it. */ static void xmlRelaxNGLogBestError(xmlRelaxNGValidCtxtPtr ctxt) { int best; if ((ctxt == NULL) || (ctxt->states == NULL) || (ctxt->states->nbState <= 0)) return; best = xmlRelaxNGBestState(ctxt); if ((best >= 0) && (best < ctxt->states->nbState)) { ctxt->state = ctxt->states->tabState[best]; xmlRelaxNGValidateElementEnd(ctxt, 1); } } /** * xmlRelaxNGValidateElementEnd: * @ctxt: a Relax-NG validation context * @dolog: indicate that error logging should be done * * Validate the end of the element, implements check that * there is nothing left not consumed in the element content * or in the attribute list. * * Returns 0 if the validation succeeded or an error code. */ static int xmlRelaxNGValidateElementEnd(xmlRelaxNGValidCtxtPtr ctxt, int dolog) { int i; xmlRelaxNGValidStatePtr state; state = ctxt->state; if (state->seq != NULL) { state->seq = xmlRelaxNGSkipIgnored(ctxt, state->seq); if (state->seq != NULL) { if (dolog) { VALID_ERR3(XML_RELAXNG_ERR_EXTRACONTENT, state->node->name, state->seq->name); } return (-1); } } for (i = 0; i < state->nbAttrs; i++) { if (state->attrs[i] != NULL) { if (dolog) { VALID_ERR3(XML_RELAXNG_ERR_INVALIDATTR, state->attrs[i]->name, state->node->name); } return (-1 - i); } } return (0); } /** * xmlRelaxNGValidateState: * @ctxt: a Relax-NG validation context * @define: the definition to verify * * Validate the current state against the definition * * Returns 0 if the validation succeeded or an error code. */ static int xmlRelaxNGValidateState(xmlRelaxNGValidCtxtPtr ctxt, xmlRelaxNGDefinePtr define) { xmlNodePtr node; int ret = 0, i, tmp, oldflags, errNr; xmlRelaxNGValidStatePtr oldstate = NULL, state; if (define == NULL) { VALID_ERR(XML_RELAXNG_ERR_NODEFINE); return (-1); } if (ctxt->state != NULL) { node = ctxt->state->seq; } else { node = NULL; } #ifdef DEBUG for (i = 0; i < ctxt->depth; i++) xmlGenericError(xmlGenericErrorContext, " "); xmlGenericError(xmlGenericErrorContext, "Start validating %s ", xmlRelaxNGDefName(define)); if (define->name != NULL) xmlGenericError(xmlGenericErrorContext, "%s ", define->name); if ((node != NULL) && (node->name != NULL)) xmlGenericError(xmlGenericErrorContext, "on %s\n", node->name); else xmlGenericError(xmlGenericErrorContext, "\n"); #endif ctxt->depth++; switch (define->type) { case XML_RELAXNG_EMPTY: node = xmlRelaxNGSkipIgnored(ctxt, node); ret = 0; break; case XML_RELAXNG_NOT_ALLOWED: ret = -1; break; case XML_RELAXNG_TEXT: while ((node != NULL) && ((node->type == XML_TEXT_NODE) || (node->type == XML_COMMENT_NODE) || (node->type == XML_PI_NODE) || (node->type == XML_CDATA_SECTION_NODE))) node = node->next; ctxt->state->seq = node; break; case XML_RELAXNG_ELEMENT: errNr = ctxt->errNr; node = xmlRelaxNGSkipIgnored(ctxt, node); if (node == NULL) { VALID_ERR2(XML_RELAXNG_ERR_NOELEM, define->name); ret = -1; if ((ctxt->flags & FLAGS_IGNORABLE) == 0) xmlRelaxNGDumpValidError(ctxt); break; } if (node->type != XML_ELEMENT_NODE) { VALID_ERR(XML_RELAXNG_ERR_NOTELEM); ret = -1; if ((ctxt->flags & FLAGS_IGNORABLE) == 0) xmlRelaxNGDumpValidError(ctxt); break; } /* * This node was already validated successfully against * this definition. */ if (node->psvi == define) { ctxt->state->seq = xmlRelaxNGSkipIgnored(ctxt, node->next); if (ctxt->errNr > errNr) xmlRelaxNGPopErrors(ctxt, errNr); if (ctxt->errNr != 0) { while ((ctxt->err != NULL) && (((ctxt->err->err == XML_RELAXNG_ERR_ELEMNAME) && (xmlStrEqual(ctxt->err->arg2, node->name))) || ((ctxt->err->err == XML_RELAXNG_ERR_ELEMEXTRANS) && (xmlStrEqual(ctxt->err->arg1, node->name))) || (ctxt->err->err == XML_RELAXNG_ERR_NOELEM) || (ctxt->err->err == XML_RELAXNG_ERR_NOTELEM))) xmlRelaxNGValidErrorPop(ctxt); } break; } ret = xmlRelaxNGElementMatch(ctxt, define, node); if (ret <= 0) { ret = -1; if ((ctxt->flags & FLAGS_IGNORABLE) == 0) xmlRelaxNGDumpValidError(ctxt); break; } ret = 0; if (ctxt->errNr != 0) { if (ctxt->errNr > errNr) xmlRelaxNGPopErrors(ctxt, errNr); while ((ctxt->err != NULL) && (((ctxt->err->err == XML_RELAXNG_ERR_ELEMNAME) && (xmlStrEqual(ctxt->err->arg2, node->name))) || ((ctxt->err->err == XML_RELAXNG_ERR_ELEMEXTRANS) && (xmlStrEqual(ctxt->err->arg1, node->name))) || (ctxt->err->err == XML_RELAXNG_ERR_NOELEM) || (ctxt->err->err == XML_RELAXNG_ERR_NOTELEM))) xmlRelaxNGValidErrorPop(ctxt); } errNr = ctxt->errNr; oldflags = ctxt->flags; if (ctxt->flags & FLAGS_MIXED_CONTENT) { ctxt->flags -= FLAGS_MIXED_CONTENT; } state = xmlRelaxNGNewValidState(ctxt, node); if (state == NULL) { ret = -1; if ((ctxt->flags & FLAGS_IGNORABLE) == 0) xmlRelaxNGDumpValidError(ctxt); break; } oldstate = ctxt->state; ctxt->state = state; if (define->attrs != NULL) { tmp = xmlRelaxNGValidateAttributeList(ctxt, define->attrs); if (tmp != 0) { ret = -1; VALID_ERR2(XML_RELAXNG_ERR_ATTRVALID, node->name); } } if (define->contModel != NULL) { xmlRelaxNGValidStatePtr nstate, tmpstate = ctxt->state; xmlRelaxNGStatesPtr tmpstates = ctxt->states; xmlNodePtr nseq; nstate = xmlRelaxNGNewValidState(ctxt, node); ctxt->state = nstate; ctxt->states = NULL; tmp = xmlRelaxNGValidateCompiledContent(ctxt, define->contModel, ctxt->state->seq); nseq = ctxt->state->seq; ctxt->state = tmpstate; ctxt->states = tmpstates; xmlRelaxNGFreeValidState(ctxt, nstate); #ifdef DEBUG_COMPILE xmlGenericError(xmlGenericErrorContext, "Validating content of '%s' : %d\n", define->name, tmp); #endif if (tmp != 0) ret = -1; if (ctxt->states != NULL) { tmp = -1; for (i = 0; i < ctxt->states->nbState; i++) { state = ctxt->states->tabState[i]; ctxt->state = state; ctxt->state->seq = nseq; if (xmlRelaxNGValidateElementEnd(ctxt, 0) == 0) { tmp = 0; break; } } if (tmp != 0) { /* * validation error, log the message for the "best" one */ ctxt->flags |= FLAGS_IGNORABLE; xmlRelaxNGLogBestError(ctxt); } for (i = 0; i < ctxt->states->nbState; i++) { xmlRelaxNGFreeValidState(ctxt, ctxt->states-> tabState[i]); } xmlRelaxNGFreeStates(ctxt, ctxt->states); ctxt->flags = oldflags; ctxt->states = NULL; if ((ret == 0) && (tmp == -1)) ret = -1; } else { state = ctxt->state; ctxt->state->seq = nseq; if (ret == 0) ret = xmlRelaxNGValidateElementEnd(ctxt, 1); xmlRelaxNGFreeValidState(ctxt, state); } } else { if (define->content != NULL) { tmp = xmlRelaxNGValidateDefinitionList(ctxt, define-> content); if (tmp != 0) { ret = -1; if (ctxt->state == NULL) { ctxt->state = oldstate; VALID_ERR2(XML_RELAXNG_ERR_CONTENTVALID, node->name); ctxt->state = NULL; } else { VALID_ERR2(XML_RELAXNG_ERR_CONTENTVALID, node->name); } } } if (ctxt->states != NULL) { tmp = -1; for (i = 0; i < ctxt->states->nbState; i++) { state = ctxt->states->tabState[i]; ctxt->state = state; if (xmlRelaxNGValidateElementEnd(ctxt, 0) == 0) { tmp = 0; break; } } if (tmp != 0) { /* * validation error, log the message for the "best" one */ ctxt->flags |= FLAGS_IGNORABLE; xmlRelaxNGLogBestError(ctxt); } for (i = 0; i < ctxt->states->nbState; i++) { xmlRelaxNGFreeValidState(ctxt, ctxt->states-> tabState[i]); } xmlRelaxNGFreeStates(ctxt, ctxt->states); ctxt->flags = oldflags; ctxt->states = NULL; if ((ret == 0) && (tmp == -1)) ret = -1; } else { state = ctxt->state; if (ret == 0) ret = xmlRelaxNGValidateElementEnd(ctxt, 1); xmlRelaxNGFreeValidState(ctxt, state); } } if (ret == 0) { node->psvi = define; } ctxt->flags = oldflags; ctxt->state = oldstate; if (oldstate != NULL) oldstate->seq = xmlRelaxNGSkipIgnored(ctxt, node->next); if (ret != 0) { if ((ctxt->flags & FLAGS_IGNORABLE) == 0) { xmlRelaxNGDumpValidError(ctxt); ret = 0; #if 0 } else { ret = -2; #endif } } else { if (ctxt->errNr > errNr) xmlRelaxNGPopErrors(ctxt, errNr); } #ifdef DEBUG xmlGenericError(xmlGenericErrorContext, "xmlRelaxNGValidateDefinition(): validated %s : %d", node->name, ret); if (oldstate == NULL) xmlGenericError(xmlGenericErrorContext, ": no state\n"); else if (oldstate->seq == NULL) xmlGenericError(xmlGenericErrorContext, ": done\n"); else if (oldstate->seq->type == XML_ELEMENT_NODE) xmlGenericError(xmlGenericErrorContext, ": next elem %s\n", oldstate->seq->name); else xmlGenericError(xmlGenericErrorContext, ": next %s %d\n", oldstate->seq->name, oldstate->seq->type); #endif break; case XML_RELAXNG_OPTIONAL:{ errNr = ctxt->errNr; oldflags = ctxt->flags; ctxt->flags |= FLAGS_IGNORABLE; oldstate = xmlRelaxNGCopyValidState(ctxt, ctxt->state); ret = xmlRelaxNGValidateDefinitionList(ctxt, define->content); if (ret != 0) { if (ctxt->state != NULL) xmlRelaxNGFreeValidState(ctxt, ctxt->state); ctxt->state = oldstate; ctxt->flags = oldflags; ret = 0; if (ctxt->errNr > errNr) xmlRelaxNGPopErrors(ctxt, errNr); break; } if (ctxt->states != NULL) { xmlRelaxNGAddStates(ctxt, ctxt->states, oldstate); } else { ctxt->states = xmlRelaxNGNewStates(ctxt, 1); if (ctxt->states == NULL) { xmlRelaxNGFreeValidState(ctxt, oldstate); ctxt->flags = oldflags; ret = -1; if (ctxt->errNr > errNr) xmlRelaxNGPopErrors(ctxt, errNr); break; } xmlRelaxNGAddStates(ctxt, ctxt->states, oldstate); xmlRelaxNGAddStates(ctxt, ctxt->states, ctxt->state); ctxt->state = NULL; } ctxt->flags = oldflags; ret = 0; if (ctxt->errNr > errNr) xmlRelaxNGPopErrors(ctxt, errNr); break; } case XML_RELAXNG_ONEORMORE: errNr = ctxt->errNr; ret = xmlRelaxNGValidateDefinitionList(ctxt, define->content); if (ret != 0) { break; } if (ctxt->errNr > errNr) xmlRelaxNGPopErrors(ctxt, errNr); /* no break on purpose */ case XML_RELAXNG_ZEROORMORE:{ int progress; xmlRelaxNGStatesPtr states = NULL, res = NULL; int base, j; errNr = ctxt->errNr; res = xmlRelaxNGNewStates(ctxt, 1); if (res == NULL) { ret = -1; break; } /* * All the input states are also exit states */ if (ctxt->state != NULL) { xmlRelaxNGAddStates(ctxt, res, xmlRelaxNGCopyValidState(ctxt, ctxt-> state)); } else { for (j = 0; j < ctxt->states->nbState; j++) { xmlRelaxNGAddStates(ctxt, res, xmlRelaxNGCopyValidState(ctxt, ctxt-> states-> tabState [j])); } } oldflags = ctxt->flags; ctxt->flags |= FLAGS_IGNORABLE; do { progress = 0; base = res->nbState; if (ctxt->states != NULL) { states = ctxt->states; for (i = 0; i < states->nbState; i++) { ctxt->state = states->tabState[i]; ctxt->states = NULL; ret = xmlRelaxNGValidateDefinitionList(ctxt, define-> content); if (ret == 0) { if (ctxt->state != NULL) { tmp = xmlRelaxNGAddStates(ctxt, res, ctxt->state); ctxt->state = NULL; if (tmp == 1) progress = 1; } else if (ctxt->states != NULL) { for (j = 0; j < ctxt->states->nbState; j++) { tmp = xmlRelaxNGAddStates(ctxt, res, ctxt-> states-> tabState [j]); if (tmp == 1) progress = 1; } xmlRelaxNGFreeStates(ctxt, ctxt->states); ctxt->states = NULL; } } else { if (ctxt->state != NULL) { xmlRelaxNGFreeValidState(ctxt, ctxt->state); ctxt->state = NULL; } } } } else { ret = xmlRelaxNGValidateDefinitionList(ctxt, define-> content); if (ret != 0) { xmlRelaxNGFreeValidState(ctxt, ctxt->state); ctxt->state = NULL; } else { base = res->nbState; if (ctxt->state != NULL) { tmp = xmlRelaxNGAddStates(ctxt, res, ctxt->state); ctxt->state = NULL; if (tmp == 1) progress = 1; } else if (ctxt->states != NULL) { for (j = 0; j < ctxt->states->nbState; j++) { tmp = xmlRelaxNGAddStates(ctxt, res, ctxt-> states-> tabState[j]); if (tmp == 1) progress = 1; } if (states == NULL) { states = ctxt->states; } else { xmlRelaxNGFreeStates(ctxt, ctxt->states); } ctxt->states = NULL; } } } if (progress) { /* * Collect all the new nodes added at that step * and make them the new node set */ if (res->nbState - base == 1) { ctxt->state = xmlRelaxNGCopyValidState(ctxt, res-> tabState [base]); } else { if (states == NULL) { xmlRelaxNGNewStates(ctxt, res->nbState - base); states = ctxt->states; if (states == NULL) { progress = 0; break; } } states->nbState = 0; for (i = base; i < res->nbState; i++) xmlRelaxNGAddStates(ctxt, states, xmlRelaxNGCopyValidState (ctxt, res->tabState[i])); ctxt->states = states; } } } while (progress == 1); if (states != NULL) { xmlRelaxNGFreeStates(ctxt, states); } ctxt->states = res; ctxt->flags = oldflags; #if 0 /* * errors may have to be propagated back... */ if (ctxt->errNr > errNr) xmlRelaxNGPopErrors(ctxt, errNr); #endif ret = 0; break; } case XML_RELAXNG_CHOICE:{ xmlRelaxNGDefinePtr list = NULL; xmlRelaxNGStatesPtr states = NULL; node = xmlRelaxNGSkipIgnored(ctxt, node); errNr = ctxt->errNr; if ((define->dflags & IS_TRIABLE) && (define->data != NULL) && (node != NULL)) { /* * node == NULL can't be optimized since IS_TRIABLE * doesn't account for choice which may lead to * only attributes. */ xmlHashTablePtr triage = (xmlHashTablePtr) define->data; /* * Something we can optimize cleanly there is only one * possble branch out ! */ if ((node->type == XML_TEXT_NODE) || (node->type == XML_CDATA_SECTION_NODE)) { list = xmlHashLookup2(triage, BAD_CAST "#text", NULL); } else if (node->type == XML_ELEMENT_NODE) { if (node->ns != NULL) { list = xmlHashLookup2(triage, node->name, node->ns->href); if (list == NULL) list = xmlHashLookup2(triage, BAD_CAST "#any", node->ns->href); } else list = xmlHashLookup2(triage, node->name, NULL); if (list == NULL) list = xmlHashLookup2(triage, BAD_CAST "#any", NULL); } if (list == NULL) { ret = -1; VALID_ERR2(XML_RELAXNG_ERR_ELEMWRONG, node->name); break; } ret = xmlRelaxNGValidateDefinition(ctxt, list); if (ret == 0) { } break; } list = define->content; oldflags = ctxt->flags; ctxt->flags |= FLAGS_IGNORABLE; while (list != NULL) { oldstate = xmlRelaxNGCopyValidState(ctxt, ctxt->state); ret = xmlRelaxNGValidateDefinition(ctxt, list); if (ret == 0) { if (states == NULL) { states = xmlRelaxNGNewStates(ctxt, 1); } if (ctxt->state != NULL) { xmlRelaxNGAddStates(ctxt, states, ctxt->state); } else if (ctxt->states != NULL) { for (i = 0; i < ctxt->states->nbState; i++) { xmlRelaxNGAddStates(ctxt, states, ctxt->states-> tabState[i]); } xmlRelaxNGFreeStates(ctxt, ctxt->states); ctxt->states = NULL; } } else { xmlRelaxNGFreeValidState(ctxt, ctxt->state); } ctxt->state = oldstate; list = list->next; } if (states != NULL) { xmlRelaxNGFreeValidState(ctxt, oldstate); ctxt->states = states; ctxt->state = NULL; ret = 0; } else { ctxt->states = NULL; } ctxt->flags = oldflags; if (ret != 0) { if ((ctxt->flags & FLAGS_IGNORABLE) == 0) { xmlRelaxNGDumpValidError(ctxt); } } else { if (ctxt->errNr > errNr) xmlRelaxNGPopErrors(ctxt, errNr); } break; } case XML_RELAXNG_DEF: case XML_RELAXNG_GROUP: ret = xmlRelaxNGValidateDefinitionList(ctxt, define->content); break; case XML_RELAXNG_INTERLEAVE: ret = xmlRelaxNGValidateInterleave(ctxt, define); break; case XML_RELAXNG_ATTRIBUTE: ret = xmlRelaxNGValidateAttribute(ctxt, define); break; case XML_RELAXNG_START: case XML_RELAXNG_NOOP: case XML_RELAXNG_REF: case XML_RELAXNG_EXTERNALREF: case XML_RELAXNG_PARENTREF: ret = xmlRelaxNGValidateDefinition(ctxt, define->content); break; case XML_RELAXNG_DATATYPE:{ xmlNodePtr child; xmlChar *content = NULL; child = node; while (child != NULL) { if (child->type == XML_ELEMENT_NODE) { VALID_ERR2(XML_RELAXNG_ERR_DATAELEM, node->parent->name); ret = -1; break; } else if ((child->type == XML_TEXT_NODE) || (child->type == XML_CDATA_SECTION_NODE)) { content = xmlStrcat(content, child->content); } /* TODO: handle entities ... */ child = child->next; } if (ret == -1) { if (content != NULL) xmlFree(content); break; } if (content == NULL) { content = xmlStrdup(BAD_CAST ""); if (content == NULL) { xmlRngVErrMemory(ctxt, "validating\n"); ret = -1; break; } } ret = xmlRelaxNGValidateDatatype(ctxt, content, define, ctxt->state->seq); if (ret == -1) { VALID_ERR2(XML_RELAXNG_ERR_DATATYPE, define->name); } else if (ret == 0) { ctxt->state->seq = NULL; } if (content != NULL) xmlFree(content); break; } case XML_RELAXNG_VALUE:{ xmlChar *content = NULL; xmlChar *oldvalue; xmlNodePtr child; child = node; while (child != NULL) { if (child->type == XML_ELEMENT_NODE) { VALID_ERR2(XML_RELAXNG_ERR_VALELEM, node->parent->name); ret = -1; break; } else if ((child->type == XML_TEXT_NODE) || (child->type == XML_CDATA_SECTION_NODE)) { content = xmlStrcat(content, child->content); } /* TODO: handle entities ... */ child = child->next; } if (ret == -1) { if (content != NULL) xmlFree(content); break; } if (content == NULL) { content = xmlStrdup(BAD_CAST ""); if (content == NULL) { xmlRngVErrMemory(ctxt, "validating\n"); ret = -1; break; } } oldvalue = ctxt->state->value; ctxt->state->value = content; ret = xmlRelaxNGValidateValue(ctxt, define); ctxt->state->value = oldvalue; if (ret == -1) { VALID_ERR2(XML_RELAXNG_ERR_VALUE, define->name); } else if (ret == 0) { ctxt->state->seq = NULL; } if (content != NULL) xmlFree(content); break; } case XML_RELAXNG_LIST:{ xmlChar *content; xmlNodePtr child; xmlChar *oldvalue, *oldendvalue; int len; /* * Make sure it's only text nodes */ content = NULL; child = node; while (child != NULL) { if (child->type == XML_ELEMENT_NODE) { VALID_ERR2(XML_RELAXNG_ERR_LISTELEM, node->parent->name); ret = -1; break; } else if ((child->type == XML_TEXT_NODE) || (child->type == XML_CDATA_SECTION_NODE)) { content = xmlStrcat(content, child->content); } /* TODO: handle entities ... */ child = child->next; } if (ret == -1) { if (content != NULL) xmlFree(content); break; } if (content == NULL) { content = xmlStrdup(BAD_CAST ""); if (content == NULL) { xmlRngVErrMemory(ctxt, "validating\n"); ret = -1; break; } } len = xmlStrlen(content); oldvalue = ctxt->state->value; oldendvalue = ctxt->state->endvalue; ctxt->state->value = content; ctxt->state->endvalue = content + len; ret = xmlRelaxNGValidateValue(ctxt, define); ctxt->state->value = oldvalue; ctxt->state->endvalue = oldendvalue; if (ret == -1) { VALID_ERR(XML_RELAXNG_ERR_LIST); } else if ((ret == 0) && (node != NULL)) { ctxt->state->seq = node->next; } if (content != NULL) xmlFree(content); break; } case XML_RELAXNG_EXCEPT: case XML_RELAXNG_PARAM: TODO ret = -1; break; } ctxt->depth--; #ifdef DEBUG for (i = 0; i < ctxt->depth; i++) xmlGenericError(xmlGenericErrorContext, " "); xmlGenericError(xmlGenericErrorContext, "Validating %s ", xmlRelaxNGDefName(define)); if (define->name != NULL) xmlGenericError(xmlGenericErrorContext, "%s ", define->name); if (ret == 0) xmlGenericError(xmlGenericErrorContext, "suceeded\n"); else xmlGenericError(xmlGenericErrorContext, "failed\n"); #endif return (ret); } /** * xmlRelaxNGValidateDefinition: * @ctxt: a Relax-NG validation context * @define: the definition to verify * * Validate the current node lists against the definition * * Returns 0 if the validation succeeded or an error code. */ static int xmlRelaxNGValidateDefinition(xmlRelaxNGValidCtxtPtr ctxt, xmlRelaxNGDefinePtr define) { xmlRelaxNGStatesPtr states, res; int i, j, k, ret, oldflags; /* * We should NOT have both ctxt->state and ctxt->states */ if ((ctxt->state != NULL) && (ctxt->states != NULL)) { TODO xmlRelaxNGFreeValidState(ctxt, ctxt->state); ctxt->state = NULL; } if ((ctxt->states == NULL) || (ctxt->states->nbState == 1)) { if (ctxt->states != NULL) { ctxt->state = ctxt->states->tabState[0]; xmlRelaxNGFreeStates(ctxt, ctxt->states); ctxt->states = NULL; } ret = xmlRelaxNGValidateState(ctxt, define); if ((ctxt->state != NULL) && (ctxt->states != NULL)) { TODO xmlRelaxNGFreeValidState(ctxt, ctxt->state); ctxt->state = NULL; } if ((ctxt->states != NULL) && (ctxt->states->nbState == 1)) { ctxt->state = ctxt->states->tabState[0]; xmlRelaxNGFreeStates(ctxt, ctxt->states); ctxt->states = NULL; } return (ret); } states = ctxt->states; ctxt->states = NULL; res = NULL; j = 0; oldflags = ctxt->flags; ctxt->flags |= FLAGS_IGNORABLE; for (i = 0; i < states->nbState; i++) { ctxt->state = states->tabState[i]; ctxt->states = NULL; ret = xmlRelaxNGValidateState(ctxt, define); /* * We should NOT have both ctxt->state and ctxt->states */ if ((ctxt->state != NULL) && (ctxt->states != NULL)) { TODO xmlRelaxNGFreeValidState(ctxt, ctxt->state); ctxt->state = NULL; } if (ret == 0) { if (ctxt->states == NULL) { if (res != NULL) { /* add the state to the container */ xmlRelaxNGAddStates(ctxt, res, ctxt->state); ctxt->state = NULL; } else { /* add the state directly in states */ states->tabState[j++] = ctxt->state; ctxt->state = NULL; } } else { if (res == NULL) { /* make it the new container and copy other results */ res = ctxt->states; ctxt->states = NULL; for (k = 0; k < j; k++) xmlRelaxNGAddStates(ctxt, res, states->tabState[k]); } else { /* add all the new results to res and reff the container */ for (k = 0; k < ctxt->states->nbState; k++) xmlRelaxNGAddStates(ctxt, res, ctxt->states->tabState[k]); xmlRelaxNGFreeStates(ctxt, ctxt->states); ctxt->states = NULL; } } } else { if (ctxt->state != NULL) { xmlRelaxNGFreeValidState(ctxt, ctxt->state); ctxt->state = NULL; } else if (ctxt->states != NULL) { for (k = 0; k < ctxt->states->nbState; k++) xmlRelaxNGFreeValidState(ctxt, ctxt->states->tabState[k]); xmlRelaxNGFreeStates(ctxt, ctxt->states); ctxt->states = NULL; } } } ctxt->flags = oldflags; if (res != NULL) { xmlRelaxNGFreeStates(ctxt, states); ctxt->states = res; ret = 0; } else if (j > 1) { states->nbState = j; ctxt->states = states; ret = 0; } else if (j == 1) { ctxt->state = states->tabState[0]; xmlRelaxNGFreeStates(ctxt, states); ret = 0; } else { ret = -1; xmlRelaxNGFreeStates(ctxt, states); if (ctxt->states != NULL) { xmlRelaxNGFreeStates(ctxt, ctxt->states); ctxt->states = NULL; } } if ((ctxt->state != NULL) && (ctxt->states != NULL)) { TODO xmlRelaxNGFreeValidState(ctxt, ctxt->state); ctxt->state = NULL; } return (ret); } /** * xmlRelaxNGValidateDocument: * @ctxt: a Relax-NG validation context * @doc: the document * * Validate the given document * * Returns 0 if the validation succeeded or an error code. */ static int xmlRelaxNGValidateDocument(xmlRelaxNGValidCtxtPtr ctxt, xmlDocPtr doc) { int ret; xmlRelaxNGPtr schema; xmlRelaxNGGrammarPtr grammar; xmlRelaxNGValidStatePtr state; xmlNodePtr node; if ((ctxt == NULL) || (ctxt->schema == NULL) || (doc == NULL)) return (-1); ctxt->errNo = XML_RELAXNG_OK; schema = ctxt->schema; grammar = schema->topgrammar; if (grammar == NULL) { VALID_ERR(XML_RELAXNG_ERR_NOGRAMMAR); return (-1); } state = xmlRelaxNGNewValidState(ctxt, NULL); ctxt->state = state; ret = xmlRelaxNGValidateDefinition(ctxt, grammar->start); if ((ctxt->state != NULL) && (state->seq != NULL)) { state = ctxt->state; node = state->seq; node = xmlRelaxNGSkipIgnored(ctxt, node); if (node != NULL) { if (ret != -1) { VALID_ERR(XML_RELAXNG_ERR_EXTRADATA); ret = -1; } } } else if (ctxt->states != NULL) { int i; int tmp = -1; for (i = 0; i < ctxt->states->nbState; i++) { state = ctxt->states->tabState[i]; node = state->seq; node = xmlRelaxNGSkipIgnored(ctxt, node); if (node == NULL) tmp = 0; xmlRelaxNGFreeValidState(ctxt, state); } if (tmp == -1) { if (ret != -1) { VALID_ERR(XML_RELAXNG_ERR_EXTRADATA); ret = -1; } } } if (ctxt->state != NULL) { xmlRelaxNGFreeValidState(ctxt, ctxt->state); ctxt->state = NULL; } if (ret != 0) xmlRelaxNGDumpValidError(ctxt); #ifdef DEBUG else if (ctxt->errNr != 0) { ctxt->error(ctxt->userData, "%d Extra error messages left on stack !\n", ctxt->errNr); xmlRelaxNGDumpValidError(ctxt); } #endif #ifdef LIBXML_VALID_ENABLED if (ctxt->idref == 1) { xmlValidCtxt vctxt; memset(&vctxt, 0, sizeof(xmlValidCtxt)); vctxt.valid = 1; vctxt.error = ctxt->error; vctxt.warning = ctxt->warning; vctxt.userData = ctxt->userData; if (xmlValidateDocumentFinal(&vctxt, doc) != 1) ret = -1; } #endif /* LIBXML_VALID_ENABLED */ if ((ret == 0) && (ctxt->errNo != XML_RELAXNG_OK)) ret = -1; return (ret); } /************************************************************************ * * * Validation interfaces * * * ************************************************************************/ /** * xmlRelaxNGNewValidCtxt: * @schema: a precompiled XML RelaxNGs * * Create an XML RelaxNGs validation context based on the given schema * * Returns the validation context or NULL in case of error */ xmlRelaxNGValidCtxtPtr xmlRelaxNGNewValidCtxt(xmlRelaxNGPtr schema) { xmlRelaxNGValidCtxtPtr ret; ret = (xmlRelaxNGValidCtxtPtr) xmlMalloc(sizeof(xmlRelaxNGValidCtxt)); if (ret == NULL) { xmlRngVErrMemory(NULL, "building context\n"); return (NULL); } memset(ret, 0, sizeof(xmlRelaxNGValidCtxt)); ret->schema = schema; ret->error = xmlGenericError; ret->userData = xmlGenericErrorContext; ret->errNr = 0; ret->errMax = 0; ret->err = NULL; ret->errTab = NULL; if (schema != NULL) ret->idref = schema->idref; ret->states = NULL; ret->freeState = NULL; ret->freeStates = NULL; ret->errNo = XML_RELAXNG_OK; return (ret); } /** * xmlRelaxNGFreeValidCtxt: * @ctxt: the schema validation context * * Free the resources associated to the schema validation context */ void xmlRelaxNGFreeValidCtxt(xmlRelaxNGValidCtxtPtr ctxt) { int k; if (ctxt == NULL) return; if (ctxt->states != NULL) xmlRelaxNGFreeStates(NULL, ctxt->states); if (ctxt->freeState != NULL) { for (k = 0; k < ctxt->freeState->nbState; k++) { xmlRelaxNGFreeValidState(NULL, ctxt->freeState->tabState[k]); } xmlRelaxNGFreeStates(NULL, ctxt->freeState); } if (ctxt->freeStates != NULL) { for (k = 0; k < ctxt->freeStatesNr; k++) { xmlRelaxNGFreeStates(NULL, ctxt->freeStates[k]); } xmlFree(ctxt->freeStates); } if (ctxt->errTab != NULL) xmlFree(ctxt->errTab); if (ctxt->elemTab != NULL) { xmlRegExecCtxtPtr exec; exec = xmlRelaxNGElemPop(ctxt); while (exec != NULL) { xmlRegFreeExecCtxt(exec); exec = xmlRelaxNGElemPop(ctxt); } xmlFree(ctxt->elemTab); } xmlFree(ctxt); } /** * xmlRelaxNGSetValidErrors: * @ctxt: a Relax-NG validation context * @err: the error function * @warn: the warning function * @ctx: the functions context * * Set the error and warning callback informations */ void xmlRelaxNGSetValidErrors(xmlRelaxNGValidCtxtPtr ctxt, xmlRelaxNGValidityErrorFunc err, xmlRelaxNGValidityWarningFunc warn, void *ctx) { if (ctxt == NULL) return; ctxt->error = err; ctxt->warning = warn; ctxt->userData = ctx; ctxt->serror = NULL; } /** * xmlRelaxNGSetValidStructuredErrors: * @ctxt: a Relax-NG validation context * @serror: the structured error function * @ctx: the functions context * * Set the structured error callback */ void xmlRelaxNGSetValidStructuredErrors(xmlRelaxNGValidCtxtPtr ctxt, xmlStructuredErrorFunc serror, void *ctx) { if (ctxt == NULL) return; ctxt->serror = serror; ctxt->error = NULL; ctxt->warning = NULL; ctxt->userData = ctx; } /** * xmlRelaxNGGetValidErrors: * @ctxt: a Relax-NG validation context * @err: the error function result * @warn: the warning function result * @ctx: the functions context result * * Get the error and warning callback informations * * Returns -1 in case of error and 0 otherwise */ int xmlRelaxNGGetValidErrors(xmlRelaxNGValidCtxtPtr ctxt, xmlRelaxNGValidityErrorFunc * err, xmlRelaxNGValidityWarningFunc * warn, void **ctx) { if (ctxt == NULL) return (-1); if (err != NULL) *err = ctxt->error; if (warn != NULL) *warn = ctxt->warning; if (ctx != NULL) *ctx = ctxt->userData; return (0); } /** * xmlRelaxNGValidateDoc: * @ctxt: a Relax-NG validation context * @doc: a parsed document tree * * Validate a document tree in memory. * * Returns 0 if the document is valid, a positive error code * number otherwise and -1 in case of internal or API error. */ int xmlRelaxNGValidateDoc(xmlRelaxNGValidCtxtPtr ctxt, xmlDocPtr doc) { int ret; if ((ctxt == NULL) || (doc == NULL)) return (-1); ctxt->doc = doc; ret = xmlRelaxNGValidateDocument(ctxt, doc); /* * TODO: build error codes */ if (ret == -1) return (1); return (ret); } #define bottom_relaxng #include "elfgcchack.h" #endif /* LIBXML_SCHEMAS_ENABLED */ xdmf-3.0+git20160803/Utilities/vtklibxml2/vtk_libxml2_zlib.h0000640000175000017500000000025013003006557023566 0ustar alastairalastair#ifndef vtk_libxml2_zlib_h #define vtk_libxml2_zlib_h #if defined(HAVE_VTK_ZLIB_H) # include #elif defined(HAVE_ZLIB_H) # include #endif #endif xdmf-3.0+git20160803/Utilities/vtklibxml2/SAX2.c0000640000175000017500000026445713003006557021046 0ustar alastairalastair/* * SAX2.c : Default SAX2 handler to build a tree. * * See Copyright for the status of this software. * * Daniel Veillard */ #define IN_LIBXML #include "libxml.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* #define DEBUG_SAX2 */ /* #define DEBUG_SAX2_TREE */ /** * TODO: * * macro to flag unimplemented blocks * XML_CATALOG_PREFER user env to select between system/public prefered * option. C.f. Richard Tobin *> Just FYI, I am using an environment variable XML_CATALOG_PREFER with *> values "system" and "public". I have made the default be "system" to *> match yours. */ #define TODO \ xmlGenericError(xmlGenericErrorContext, \ "Unimplemented block at %s:%d\n", \ __FILE__, __LINE__); /* * xmlSAX2ErrMemory: * @ctxt: an XML validation parser context * @msg: a string to accompany the error message */ static void xmlSAX2ErrMemory(xmlParserCtxtPtr ctxt, const char *msg) { if (ctxt != NULL) { if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) ctxt->sax->error(ctxt->userData, "%s: out of memory\n", msg); ctxt->errNo = XML_ERR_NO_MEMORY; ctxt->instate = XML_PARSER_EOF; ctxt->disableSAX = 1; } } /** * xmlValidError: * @ctxt: an XML validation parser context * @error: the error number * @msg: the error message * @str1: extra data * @str2: extra data * * Handle a validation error */ static void xmlErrValid(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *msg, const char *str1, const char *str2) { xmlStructuredErrorFunc schannel = NULL; if ((ctxt != NULL) && (ctxt->disableSAX != 0) && (ctxt->instate == XML_PARSER_EOF)) return; if (ctxt != NULL) { ctxt->errNo = error; if ((ctxt->sax != NULL) && (ctxt->sax->initialized == XML_SAX2_MAGIC)) schannel = ctxt->sax->serror; __xmlRaiseError(schannel, ctxt->vctxt.error, ctxt->vctxt.userData, ctxt, NULL, XML_FROM_DTD, error, XML_ERR_ERROR, NULL, 0, (const char *) str1, (const char *) str2, NULL, 0, 0, msg, (const char *) str1, (const char *) str2); ctxt->valid = 0; } else { __xmlRaiseError(schannel, NULL, NULL, ctxt, NULL, XML_FROM_DTD, error, XML_ERR_ERROR, NULL, 0, (const char *) str1, (const char *) str2, NULL, 0, 0, msg, (const char *) str1, (const char *) str2); } } /** * xmlFatalErrMsg: * @ctxt: an XML parser context * @error: the error number * @msg: the error message * @str1: an error string * @str2: an error string * * Handle a fatal parser error, i.e. violating Well-Formedness constraints */ static void xmlFatalErrMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *msg, const xmlChar *str1, const xmlChar *str2) { if ((ctxt != NULL) && (ctxt->disableSAX != 0) && (ctxt->instate == XML_PARSER_EOF)) return; if (ctxt != NULL) ctxt->errNo = error; __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error, XML_ERR_FATAL, NULL, 0, (const char *) str1, (const char *) str2, NULL, 0, 0, msg, str1, str2); if (ctxt != NULL) { ctxt->wellFormed = 0; ctxt->valid = 0; if (ctxt->recovery == 0) ctxt->disableSAX = 1; } } /** * xmlWarnMsg: * @ctxt: an XML parser context * @error: the error number * @msg: the error message * @str1: an error string * @str2: an error string * * Handle a parser warning */ static void xmlWarnMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *msg, const xmlChar *str1) { if ((ctxt != NULL) && (ctxt->disableSAX != 0) && (ctxt->instate == XML_PARSER_EOF)) return; if (ctxt != NULL) ctxt->errNo = error; __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error, XML_ERR_WARNING, NULL, 0, (const char *) str1, NULL, NULL, 0, 0, msg, str1); } /** * xmlNsErrMsg: * @ctxt: an XML parser context * @error: the error number * @msg: the error message * @str1: an error string * @str2: an error string * * Handle a namespace error */ static void xmlNsErrMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *msg, const xmlChar *str1, const xmlChar *str2) { if ((ctxt != NULL) && (ctxt->disableSAX != 0) && (ctxt->instate == XML_PARSER_EOF)) return; if (ctxt != NULL) ctxt->errNo = error; __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_NAMESPACE, error, XML_ERR_ERROR, NULL, 0, (const char *) str1, (const char *) str2, NULL, 0, 0, msg, str1, str2); } /** * xmlNsWarnMsg: * @ctxt: an XML parser context * @error: the error number * @msg: the error message * @str1: an error string * * Handle a namespace warning */ static void xmlNsWarnMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *msg, const xmlChar *str1, const xmlChar *str2) { if ((ctxt != NULL) && (ctxt->disableSAX != 0) && (ctxt->instate == XML_PARSER_EOF)) return; if (ctxt != NULL) ctxt->errNo = error; __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_NAMESPACE, error, XML_ERR_WARNING, NULL, 0, (const char *) str1, (const char *) str2, NULL, 0, 0, msg, str1, str2); } /** * xmlSAX2GetPublicId: * @ctx: the user data (XML parser context) * * Provides the public ID e.g. "-//SGMLSOURCE//DTD DEMO//EN" * * Returns a xmlChar * */ const xmlChar * xmlSAX2GetPublicId(void *ctx ATTRIBUTE_UNUSED) { /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */ return(NULL); } /** * xmlSAX2GetSystemId: * @ctx: the user data (XML parser context) * * Provides the system ID, basically URL or filename e.g. * http://www.sgmlsource.com/dtds/memo.dtd * * Returns a xmlChar * */ const xmlChar * xmlSAX2GetSystemId(void *ctx) { xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; if ((ctx == NULL) || (ctxt->input == NULL)) return(NULL); return((const xmlChar *) ctxt->input->filename); } /** * xmlSAX2GetLineNumber: * @ctx: the user data (XML parser context) * * Provide the line number of the current parsing point. * * Returns an int */ int xmlSAX2GetLineNumber(void *ctx) { xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; if ((ctx == NULL) || (ctxt->input == NULL)) return(0); return(ctxt->input->line); } /** * xmlSAX2GetColumnNumber: * @ctx: the user data (XML parser context) * * Provide the column number of the current parsing point. * * Returns an int */ int xmlSAX2GetColumnNumber(void *ctx) { xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; if ((ctx == NULL) || (ctxt->input == NULL)) return(0); return(ctxt->input->col); } /** * xmlSAX2IsStandalone: * @ctx: the user data (XML parser context) * * Is this document tagged standalone ? * * Returns 1 if true */ int xmlSAX2IsStandalone(void *ctx) { xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; if ((ctx == NULL) || (ctxt->myDoc == NULL)) return(0); return(ctxt->myDoc->standalone == 1); } /** * xmlSAX2HasInternalSubset: * @ctx: the user data (XML parser context) * * Does this document has an internal subset * * Returns 1 if true */ int xmlSAX2HasInternalSubset(void *ctx) { xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; if ((ctxt == NULL) || (ctxt->myDoc == NULL)) return(0); return(ctxt->myDoc->intSubset != NULL); } /** * xmlSAX2HasExternalSubset: * @ctx: the user data (XML parser context) * * Does this document has an external subset * * Returns 1 if true */ int xmlSAX2HasExternalSubset(void *ctx) { xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; if ((ctxt == NULL) || (ctxt->myDoc == NULL)) return(0); return(ctxt->myDoc->extSubset != NULL); } /** * xmlSAX2InternalSubset: * @ctx: the user data (XML parser context) * @name: the root element name * @ExternalID: the external ID * @SystemID: the SYSTEM ID (e.g. filename or URL) * * Callback on internal subset declaration. */ void xmlSAX2InternalSubset(void *ctx, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID) { xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; xmlDtdPtr dtd; if (ctx == NULL) return; #ifdef DEBUG_SAX xmlGenericError(xmlGenericErrorContext, "SAX.xmlSAX2InternalSubset(%s, %s, %s)\n", name, ExternalID, SystemID); #endif if (ctxt->myDoc == NULL) return; dtd = xmlGetIntSubset(ctxt->myDoc); if (dtd != NULL) { if (ctxt->html) return; xmlUnlinkNode((xmlNodePtr) dtd); xmlFreeDtd(dtd); ctxt->myDoc->intSubset = NULL; } ctxt->myDoc->intSubset = xmlCreateIntSubset(ctxt->myDoc, name, ExternalID, SystemID); if (ctxt->myDoc->intSubset == NULL) xmlSAX2ErrMemory(ctxt, "xmlSAX2InternalSubset"); } /** * xmlSAX2ExternalSubset: * @ctx: the user data (XML parser context) * @name: the root element name * @ExternalID: the external ID * @SystemID: the SYSTEM ID (e.g. filename or URL) * * Callback on external subset declaration. */ void xmlSAX2ExternalSubset(void *ctx, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID) { xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; if (ctx == NULL) return; #ifdef DEBUG_SAX xmlGenericError(xmlGenericErrorContext, "SAX.xmlSAX2ExternalSubset(%s, %s, %s)\n", name, ExternalID, SystemID); #endif if (((ExternalID != NULL) || (SystemID != NULL)) && (((ctxt->validate) || (ctxt->loadsubset != 0)) && (ctxt->wellFormed && ctxt->myDoc))) { /* * Try to fetch and parse the external subset. */ xmlParserInputPtr oldinput; int oldinputNr; int oldinputMax; xmlParserInputPtr *oldinputTab; xmlParserInputPtr input = NULL; xmlCharEncoding enc; int oldcharset; /* * Ask the Entity resolver to load the damn thing */ if ((ctxt->sax != NULL) && (ctxt->sax->resolveEntity != NULL)) input = ctxt->sax->resolveEntity(ctxt->userData, ExternalID, SystemID); if (input == NULL) { return; } xmlNewDtd(ctxt->myDoc, name, ExternalID, SystemID); /* * make sure we won't destroy the main document context */ oldinput = ctxt->input; oldinputNr = ctxt->inputNr; oldinputMax = ctxt->inputMax; oldinputTab = ctxt->inputTab; oldcharset = ctxt->charset; ctxt->inputTab = (xmlParserInputPtr *) xmlMalloc(5 * sizeof(xmlParserInputPtr)); if (ctxt->inputTab == NULL) { xmlSAX2ErrMemory(ctxt, "xmlSAX2ExternalSubset"); ctxt->input = oldinput; ctxt->inputNr = oldinputNr; ctxt->inputMax = oldinputMax; ctxt->inputTab = oldinputTab; ctxt->charset = oldcharset; return; } ctxt->inputNr = 0; ctxt->inputMax = 5; ctxt->input = NULL; xmlPushInput(ctxt, input); /* * On the fly encoding conversion if needed */ if (ctxt->input->length >= 4) { enc = xmlDetectCharEncoding(ctxt->input->cur, 4); xmlSwitchEncoding(ctxt, enc); } if (input->filename == NULL) input->filename = (char *) xmlCanonicPath(SystemID); input->line = 1; input->col = 1; input->base = ctxt->input->cur; input->cur = ctxt->input->cur; input->free = NULL; /* * let's parse that entity knowing it's an external subset. */ xmlParseExternalSubset(ctxt, ExternalID, SystemID); /* * Free up the external entities */ while (ctxt->inputNr > 1) xmlPopInput(ctxt); xmlFreeInputStream(ctxt->input); xmlFree(ctxt->inputTab); /* * Restore the parsing context of the main entity */ ctxt->input = oldinput; ctxt->inputNr = oldinputNr; ctxt->inputMax = oldinputMax; ctxt->inputTab = oldinputTab; ctxt->charset = oldcharset; /* ctxt->wellFormed = oldwellFormed; */ } } /** * xmlSAX2ResolveEntity: * @ctx: the user data (XML parser context) * @publicId: The public ID of the entity * @systemId: The system ID of the entity * * The entity loader, to control the loading of external entities, * the application can either: * - override this xmlSAX2ResolveEntity() callback in the SAX block * - or better use the xmlSetExternalEntityLoader() function to * set up it's own entity resolution routine * * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour. */ xmlParserInputPtr xmlSAX2ResolveEntity(void *ctx, const xmlChar *publicId, const xmlChar *systemId) { xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; xmlParserInputPtr ret; xmlChar *URI; const char *base = NULL; if (ctx == NULL) return(NULL); if (ctxt->input != NULL) base = ctxt->input->filename; if (base == NULL) base = ctxt->directory; URI = xmlBuildURI(systemId, (const xmlChar *) base); #ifdef DEBUG_SAX xmlGenericError(xmlGenericErrorContext, "SAX.xmlSAX2ResolveEntity(%s, %s)\n", publicId, systemId); #endif ret = xmlLoadExternalEntity((const char *) URI, (const char *) publicId, ctxt); if (URI != NULL) xmlFree(URI); return(ret); } /** * xmlSAX2GetEntity: * @ctx: the user data (XML parser context) * @name: The entity name * * Get an entity by name * * Returns the xmlEntityPtr if found. */ xmlEntityPtr xmlSAX2GetEntity(void *ctx, const xmlChar *name) { xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; xmlEntityPtr ret = NULL; if (ctx == NULL) return(NULL); #ifdef DEBUG_SAX xmlGenericError(xmlGenericErrorContext, "SAX.xmlSAX2GetEntity(%s)\n", name); #endif if (ctxt->inSubset == 0) { ret = xmlGetPredefinedEntity(name); if (ret != NULL) return(ret); } if ((ctxt->myDoc != NULL) && (ctxt->myDoc->standalone == 1)) { if (ctxt->inSubset == 2) { ctxt->myDoc->standalone = 0; ret = xmlGetDocEntity(ctxt->myDoc, name); ctxt->myDoc->standalone = 1; } else { ret = xmlGetDocEntity(ctxt->myDoc, name); if (ret == NULL) { ctxt->myDoc->standalone = 0; ret = xmlGetDocEntity(ctxt->myDoc, name); if (ret != NULL) { xmlFatalErrMsg(ctxt, XML_ERR_NOT_STANDALONE, "Entity(%s) document marked standalone but requires external subset\n", name, NULL); } ctxt->myDoc->standalone = 1; } } } else { ret = xmlGetDocEntity(ctxt->myDoc, name); } if ((ret != NULL) && ((ctxt->validate) || (ctxt->replaceEntities)) && (ret->children == NULL) && (ret->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY)) { int val; /* * for validation purposes we really need to fetch and * parse the external entity */ xmlNodePtr children; val = xmlParseCtxtExternalEntity(ctxt, ret->URI, ret->ExternalID, &children); if (val == 0) { xmlAddChildList((xmlNodePtr) ret, children); } else { xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_PROCESSING, "Failure to process entity %s\n", name, NULL); ctxt->validate = 0; return(NULL); } ret->owner = 1; ret->checked = 1; } return(ret); } /** * xmlSAX2GetParameterEntity: * @ctx: the user data (XML parser context) * @name: The entity name * * Get a parameter entity by name * * Returns the xmlEntityPtr if found. */ xmlEntityPtr xmlSAX2GetParameterEntity(void *ctx, const xmlChar *name) { xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; xmlEntityPtr ret; if (ctx == NULL) return(NULL); #ifdef DEBUG_SAX xmlGenericError(xmlGenericErrorContext, "SAX.xmlSAX2GetParameterEntity(%s)\n", name); #endif ret = xmlGetParameterEntity(ctxt->myDoc, name); return(ret); } /** * xmlSAX2EntityDecl: * @ctx: the user data (XML parser context) * @name: the entity name * @type: the entity type * @publicId: The public ID of the entity * @systemId: The system ID of the entity * @content: the entity value (without processing). * * An entity definition has been parsed */ void xmlSAX2EntityDecl(void *ctx, const xmlChar *name, int type, const xmlChar *publicId, const xmlChar *systemId, xmlChar *content) { xmlEntityPtr ent; xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; if (ctx == NULL) return; #ifdef DEBUG_SAX xmlGenericError(xmlGenericErrorContext, "SAX.xmlSAX2EntityDecl(%s, %d, %s, %s, %s)\n", name, type, publicId, systemId, content); #endif if (ctxt->inSubset == 1) { ent = xmlAddDocEntity(ctxt->myDoc, name, type, publicId, systemId, content); if ((ent == NULL) && (ctxt->pedantic)) xmlWarnMsg(ctxt, XML_WAR_ENTITY_REDEFINED, "Entity(%s) already defined in the internal subset\n", name); if ((ent != NULL) && (ent->URI == NULL) && (systemId != NULL)) { xmlChar *URI; const char *base = NULL; if (ctxt->input != NULL) base = ctxt->input->filename; if (base == NULL) base = ctxt->directory; URI = xmlBuildURI(systemId, (const xmlChar *) base); ent->URI = URI; } } else if (ctxt->inSubset == 2) { ent = xmlAddDtdEntity(ctxt->myDoc, name, type, publicId, systemId, content); if ((ent == NULL) && (ctxt->pedantic) && (ctxt->sax != NULL) && (ctxt->sax->warning != NULL)) ctxt->sax->warning(ctxt->userData, "Entity(%s) already defined in the external subset\n", name); if ((ent != NULL) && (ent->URI == NULL) && (systemId != NULL)) { xmlChar *URI; const char *base = NULL; if (ctxt->input != NULL) base = ctxt->input->filename; if (base == NULL) base = ctxt->directory; URI = xmlBuildURI(systemId, (const xmlChar *) base); ent->URI = URI; } } else { xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_PROCESSING, "SAX.xmlSAX2EntityDecl(%s) called while not in subset\n", name, NULL); } } /** * xmlSAX2AttributeDecl: * @ctx: the user data (XML parser context) * @elem: the name of the element * @fullname: the attribute name * @type: the attribute type * @def: the type of default value * @defaultValue: the attribute default value * @tree: the tree of enumerated value set * * An attribute definition has been parsed */ void xmlSAX2AttributeDecl(void *ctx, const xmlChar *elem, const xmlChar *fullname, int type, int def, const xmlChar *defaultValue, xmlEnumerationPtr tree) { xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; xmlAttributePtr attr; xmlChar *name = NULL, *prefix = NULL; if ((ctxt == NULL) || (ctxt->myDoc == NULL)) return; #ifdef DEBUG_SAX xmlGenericError(xmlGenericErrorContext, "SAX.xmlSAX2AttributeDecl(%s, %s, %d, %d, %s, ...)\n", elem, fullname, type, def, defaultValue); #endif if ((xmlStrEqual(fullname, BAD_CAST "xml:id")) && (type != XML_ATTRIBUTE_ID)) { /* * Raise the error but keep the validity flag */ int tmp = ctxt->valid; xmlErrValid(ctxt, XML_DTD_XMLID_TYPE, "xml:id : attribute type should be ID\n", NULL, NULL); ctxt->valid = tmp; } /* TODO: optimize name/prefix allocation */ name = xmlSplitQName(ctxt, fullname, &prefix); ctxt->vctxt.valid = 1; if (ctxt->inSubset == 1) attr = xmlAddAttributeDecl(&ctxt->vctxt, ctxt->myDoc->intSubset, elem, name, prefix, (xmlAttributeType) type, (xmlAttributeDefault) def, defaultValue, tree); else if (ctxt->inSubset == 2) attr = xmlAddAttributeDecl(&ctxt->vctxt, ctxt->myDoc->extSubset, elem, name, prefix, (xmlAttributeType) type, (xmlAttributeDefault) def, defaultValue, tree); else { xmlFatalErrMsg(ctxt, XML_ERR_INTERNAL_ERROR, "SAX.xmlSAX2AttributeDecl(%s) called while not in subset\n", name, NULL); xmlFreeEnumeration(tree); return; } #ifdef LIBXML_VALID_ENABLED if (ctxt->vctxt.valid == 0) ctxt->valid = 0; if ((attr != NULL) && (ctxt->validate) && (ctxt->wellFormed) && (ctxt->myDoc->intSubset != NULL)) ctxt->valid &= xmlValidateAttributeDecl(&ctxt->vctxt, ctxt->myDoc, attr); #endif /* LIBXML_VALID_ENABLED */ if (prefix != NULL) xmlFree(prefix); if (name != NULL) xmlFree(name); } /** * xmlSAX2ElementDecl: * @ctx: the user data (XML parser context) * @name: the element name * @type: the element type * @content: the element value tree * * An element definition has been parsed */ void xmlSAX2ElementDecl(void *ctx, const xmlChar * name, int type, xmlElementContentPtr content) { xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; xmlElementPtr elem = NULL; if ((ctxt == NULL) || (ctxt->myDoc == NULL)) return; #ifdef DEBUG_SAX xmlGenericError(xmlGenericErrorContext, "SAX.xmlSAX2ElementDecl(%s, %d, ...)\n", name, type); #endif if (ctxt->inSubset == 1) elem = xmlAddElementDecl(&ctxt->vctxt, ctxt->myDoc->intSubset, name, (xmlElementTypeVal) type, content); else if (ctxt->inSubset == 2) elem = xmlAddElementDecl(&ctxt->vctxt, ctxt->myDoc->extSubset, name, (xmlElementTypeVal) type, content); else { xmlFatalErrMsg(ctxt, XML_ERR_INTERNAL_ERROR, "SAX.xmlSAX2ElementDecl(%s) called while not in subset\n", name, NULL); return; } #ifdef LIBXML_VALID_ENABLED if (elem == NULL) ctxt->valid = 0; if (ctxt->validate && ctxt->wellFormed && ctxt->myDoc && ctxt->myDoc->intSubset) ctxt->valid &= xmlValidateElementDecl(&ctxt->vctxt, ctxt->myDoc, elem); #endif /* LIBXML_VALID_ENABLED */ } /** * xmlSAX2NotationDecl: * @ctx: the user data (XML parser context) * @name: The name of the notation * @publicId: The public ID of the entity * @systemId: The system ID of the entity * * What to do when a notation declaration has been parsed. */ void xmlSAX2NotationDecl(void *ctx, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId) { xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; xmlNotationPtr nota = NULL; if ((ctxt == NULL) || (ctxt->myDoc == NULL)) return; #ifdef DEBUG_SAX xmlGenericError(xmlGenericErrorContext, "SAX.xmlSAX2NotationDecl(%s, %s, %s)\n", name, publicId, systemId); #endif if ((publicId == NULL) && (systemId == NULL)) { xmlFatalErrMsg(ctxt, XML_ERR_NOTATION_PROCESSING, "SAX.xmlSAX2NotationDecl(%s) externalID or PublicID missing\n", name, NULL); return; } else if (ctxt->inSubset == 1) nota = xmlAddNotationDecl(&ctxt->vctxt, ctxt->myDoc->intSubset, name, publicId, systemId); else if (ctxt->inSubset == 2) nota = xmlAddNotationDecl(&ctxt->vctxt, ctxt->myDoc->extSubset, name, publicId, systemId); else { xmlFatalErrMsg(ctxt, XML_ERR_NOTATION_PROCESSING, "SAX.xmlSAX2NotationDecl(%s) called while not in subset\n", name, NULL); return; } #ifdef LIBXML_VALID_ENABLED if (nota == NULL) ctxt->valid = 0; if ((ctxt->validate) && (ctxt->wellFormed) && (ctxt->myDoc->intSubset != NULL)) ctxt->valid &= xmlValidateNotationDecl(&ctxt->vctxt, ctxt->myDoc, nota); #endif /* LIBXML_VALID_ENABLED */ } /** * xmlSAX2UnparsedEntityDecl: * @ctx: the user data (XML parser context) * @name: The name of the entity * @publicId: The public ID of the entity * @systemId: The system ID of the entity * @notationName: the name of the notation * * What to do when an unparsed entity declaration is parsed */ void xmlSAX2UnparsedEntityDecl(void *ctx, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId, const xmlChar *notationName) { xmlEntityPtr ent; xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; if (ctx == NULL) return; #ifdef DEBUG_SAX xmlGenericError(xmlGenericErrorContext, "SAX.xmlSAX2UnparsedEntityDecl(%s, %s, %s, %s)\n", name, publicId, systemId, notationName); #endif if (ctxt->inSubset == 1) { ent = xmlAddDocEntity(ctxt->myDoc, name, XML_EXTERNAL_GENERAL_UNPARSED_ENTITY, publicId, systemId, notationName); if ((ent == NULL) && (ctxt->pedantic) && (ctxt->sax != NULL) && (ctxt->sax->warning != NULL)) ctxt->sax->warning(ctxt->userData, "Entity(%s) already defined in the internal subset\n", name); if ((ent != NULL) && (ent->URI == NULL) && (systemId != NULL)) { xmlChar *URI; const char *base = NULL; if (ctxt->input != NULL) base = ctxt->input->filename; if (base == NULL) base = ctxt->directory; URI = xmlBuildURI(systemId, (const xmlChar *) base); ent->URI = URI; } } else if (ctxt->inSubset == 2) { ent = xmlAddDtdEntity(ctxt->myDoc, name, XML_EXTERNAL_GENERAL_UNPARSED_ENTITY, publicId, systemId, notationName); if ((ent == NULL) && (ctxt->pedantic) && (ctxt->sax != NULL) && (ctxt->sax->warning != NULL)) ctxt->sax->warning(ctxt->userData, "Entity(%s) already defined in the external subset\n", name); if ((ent != NULL) && (ent->URI == NULL) && (systemId != NULL)) { xmlChar *URI; const char *base = NULL; if (ctxt->input != NULL) base = ctxt->input->filename; if (base == NULL) base = ctxt->directory; URI = xmlBuildURI(systemId, (const xmlChar *) base); ent->URI = URI; } } else { xmlFatalErrMsg(ctxt, XML_ERR_INTERNAL_ERROR, "SAX.xmlSAX2UnparsedEntityDecl(%s) called while not in subset\n", name, NULL); } } /** * xmlSAX2SetDocumentLocator: * @ctx: the user data (XML parser context) * @loc: A SAX Locator * * Receive the document locator at startup, actually xmlDefaultSAXLocator * Everything is available on the context, so this is useless in our case. */ void xmlSAX2SetDocumentLocator(void *ctx ATTRIBUTE_UNUSED, xmlSAXLocatorPtr loc ATTRIBUTE_UNUSED) { /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */ #ifdef DEBUG_SAX xmlGenericError(xmlGenericErrorContext, "SAX.xmlSAX2SetDocumentLocator()\n"); #endif } /** * xmlSAX2StartDocument: * @ctx: the user data (XML parser context) * * called when the document start being processed. */ void xmlSAX2StartDocument(void *ctx) { xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; xmlDocPtr doc; if (ctx == NULL) return; #ifdef DEBUG_SAX xmlGenericError(xmlGenericErrorContext, "SAX.xmlSAX2StartDocument()\n"); #endif if (ctxt->html) { #ifdef LIBXML_HTML_ENABLED if (ctxt->myDoc == NULL) ctxt->myDoc = htmlNewDocNoDtD(NULL, NULL); if (ctxt->myDoc == NULL) { xmlSAX2ErrMemory(ctxt, "xmlSAX2StartDocument"); return; } #else xmlGenericError(xmlGenericErrorContext, "libxml2 built without HTML support\n"); ctxt->errNo = XML_ERR_INTERNAL_ERROR; ctxt->instate = XML_PARSER_EOF; ctxt->disableSAX = 1; return; #endif } else { doc = ctxt->myDoc = xmlNewDoc(ctxt->version); if (doc != NULL) { if (ctxt->encoding != NULL) doc->encoding = xmlStrdup(ctxt->encoding); else doc->encoding = NULL; doc->standalone = ctxt->standalone; } else { xmlSAX2ErrMemory(ctxt, "xmlSAX2StartDocument"); return; } if ((ctxt->dictNames) && (doc != NULL)) { doc->dict = ctxt->dict; xmlDictReference(doc->dict); } } if ((ctxt->myDoc != NULL) && (ctxt->myDoc->URL == NULL) && (ctxt->input != NULL) && (ctxt->input->filename != NULL)) { ctxt->myDoc->URL = xmlPathToURI((const xmlChar *)ctxt->input->filename); if (ctxt->myDoc->URL == NULL) xmlSAX2ErrMemory(ctxt, "xmlSAX2StartDocument"); } } /** * xmlSAX2EndDocument: * @ctx: the user data (XML parser context) * * called when the document end has been detected. */ void xmlSAX2EndDocument(void *ctx) { xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; #ifdef DEBUG_SAX xmlGenericError(xmlGenericErrorContext, "SAX.xmlSAX2EndDocument()\n"); #endif if (ctx == NULL) return; #ifdef LIBXML_VALID_ENABLED if (ctxt->validate && ctxt->wellFormed && ctxt->myDoc && ctxt->myDoc->intSubset) ctxt->valid &= xmlValidateDocumentFinal(&ctxt->vctxt, ctxt->myDoc); #endif /* LIBXML_VALID_ENABLED */ /* * Grab the encoding if it was added on-the-fly */ if ((ctxt->encoding != NULL) && (ctxt->myDoc != NULL) && (ctxt->myDoc->encoding == NULL)) { ctxt->myDoc->encoding = ctxt->encoding; ctxt->encoding = NULL; } if ((ctxt->inputTab != NULL) && (ctxt->inputNr > 0) && (ctxt->inputTab[0] != NULL) && (ctxt->inputTab[0]->encoding != NULL) && (ctxt->myDoc != NULL) && (ctxt->myDoc->encoding == NULL)) { ctxt->myDoc->encoding = xmlStrdup(ctxt->inputTab[0]->encoding); } if ((ctxt->charset != XML_CHAR_ENCODING_NONE) && (ctxt->myDoc != NULL) && (ctxt->myDoc->charset == XML_CHAR_ENCODING_NONE)) { ctxt->myDoc->charset = ctxt->charset; } } #if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED) /** * xmlSAX2AttributeInternal: * @ctx: the user data (XML parser context) * @fullname: The attribute name, including namespace prefix * @value: The attribute value * @prefix: the prefix on the element node * * Handle an attribute that has been read by the parser. * The default handling is to convert the attribute into an * DOM subtree and past it in a new xmlAttr element added to * the element. */ static void xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname, const xmlChar *value, const xmlChar *prefix ATTRIBUTE_UNUSED) { xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; xmlAttrPtr ret; xmlChar *name; xmlChar *ns; xmlChar *nval; xmlNsPtr namespace; /* * Split the full name into a namespace prefix and the tag name */ name = xmlSplitQName(ctxt, fullname, &ns); if ((name != NULL) && (name[0] == 0)) { if (xmlStrEqual(ns, BAD_CAST "xmlns")) { xmlNsErrMsg(ctxt, XML_ERR_NS_DECL_ERROR, "invalid namespace declaration '%s'\n", fullname, NULL); } else { xmlNsWarnMsg(ctxt, XML_WAR_NS_COLUMN, "Avoid attribute ending with ':' like '%s'\n", fullname, NULL); } if (ns != NULL) xmlFree(ns); ns = NULL; xmlFree(name); name = xmlStrdup(fullname); } if (name == NULL) { xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElement"); if (ns != NULL) xmlFree(ns); return; } #ifdef LIBXML_VALID_ENABLED /* * Do the last stage of the attribute normalization * Needed for HTML too: * http://www.w3.org/TR/html4/types.html#h-6.2 */ ctxt->vctxt.valid = 1; nval = xmlValidCtxtNormalizeAttributeValue(&ctxt->vctxt, ctxt->myDoc, ctxt->node, fullname, value); if (ctxt->vctxt.valid != 1) { ctxt->valid = 0; } if (nval != NULL) value = nval; #else nval = NULL; #endif /* LIBXML_VALID_ENABLED */ /* * Check whether it's a namespace definition */ if ((!ctxt->html) && (ns == NULL) && (name[0] == 'x') && (name[1] == 'm') && (name[2] == 'l') && (name[3] == 'n') && (name[4] == 's') && (name[5] == 0)) { xmlNsPtr nsret; xmlChar *val; if (!ctxt->replaceEntities) { ctxt->depth++; val = xmlStringDecodeEntities(ctxt, value, XML_SUBSTITUTE_REF, 0,0,0); ctxt->depth--; } else { val = (xmlChar *) value; } if (val[0] != 0) { xmlURIPtr uri; uri = xmlParseURI((const char *)val); if (uri == NULL) { if ((ctxt->sax != NULL) && (ctxt->sax->warning != NULL)) ctxt->sax->warning(ctxt->userData, "xmlns: %s not a valid URI\n", val); } else { if (uri->scheme == NULL) { if ((ctxt->sax != NULL) && (ctxt->sax->warning != NULL)) ctxt->sax->warning(ctxt->userData, "xmlns: URI %s is not absolute\n", val); } xmlFreeURI(uri); } } /* a default namespace definition */ nsret = xmlNewNs(ctxt->node, val, NULL); #ifdef LIBXML_VALID_ENABLED /* * Validate also for namespace decls, they are attributes from * an XML-1.0 perspective */ if (nsret != NULL && ctxt->validate && ctxt->wellFormed && ctxt->myDoc && ctxt->myDoc->intSubset) ctxt->valid &= xmlValidateOneNamespace(&ctxt->vctxt, ctxt->myDoc, ctxt->node, prefix, nsret, val); #endif /* LIBXML_VALID_ENABLED */ if (name != NULL) xmlFree(name); if (nval != NULL) xmlFree(nval); if (val != value) xmlFree(val); return; } if ((!ctxt->html) && (ns != NULL) && (ns[0] == 'x') && (ns[1] == 'm') && (ns[2] == 'l') && (ns[3] == 'n') && (ns[4] == 's') && (ns[5] == 0)) { xmlNsPtr nsret; xmlChar *val; if (!ctxt->replaceEntities) { ctxt->depth++; val = xmlStringDecodeEntities(ctxt, value, XML_SUBSTITUTE_REF, 0,0,0); ctxt->depth--; if (val == NULL) { xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElement"); xmlFree(ns); if (name != NULL) xmlFree(name); return; } } else { val = (xmlChar *) value; } if (val[0] == 0) { xmlNsErrMsg(ctxt, XML_NS_ERR_EMPTY, "Empty namespace name for prefix %s\n", name, NULL); } if ((ctxt->pedantic != 0) && (val[0] != 0)) { xmlURIPtr uri; uri = xmlParseURI((const char *)val); if (uri == NULL) { xmlNsWarnMsg(ctxt, XML_WAR_NS_URI, "xmlns:%s: %s not a valid URI\n", name, value); } else { if (uri->scheme == NULL) { xmlNsWarnMsg(ctxt, XML_WAR_NS_URI_RELATIVE, "xmlns:%s: URI %s is not absolute\n", name, value); } xmlFreeURI(uri); } } /* a standard namespace definition */ nsret = xmlNewNs(ctxt->node, val, name); xmlFree(ns); #ifdef LIBXML_VALID_ENABLED /* * Validate also for namespace decls, they are attributes from * an XML-1.0 perspective */ if (nsret != NULL && ctxt->validate && ctxt->wellFormed && ctxt->myDoc && ctxt->myDoc->intSubset) ctxt->valid &= xmlValidateOneNamespace(&ctxt->vctxt, ctxt->myDoc, ctxt->node, prefix, nsret, value); #endif /* LIBXML_VALID_ENABLED */ if (name != NULL) xmlFree(name); if (nval != NULL) xmlFree(nval); if (val != value) xmlFree(val); return; } if (ns != NULL) { xmlAttrPtr prop; namespace = xmlSearchNs(ctxt->myDoc, ctxt->node, ns); if (namespace == NULL) { xmlNsErrMsg(ctxt, XML_NS_ERR_UNDEFINED_NAMESPACE, "Namespace prefix %s of attribute %s is not defined\n", ns, name); } prop = ctxt->node->properties; while (prop != NULL) { if (prop->ns != NULL) { if ((xmlStrEqual(name, prop->name)) && ((namespace == prop->ns) || (xmlStrEqual(namespace->href, prop->ns->href)))) { xmlNsErrMsg(ctxt, XML_ERR_ATTRIBUTE_REDEFINED, "Attribute %s in %s redefined\n", name, namespace->href); ctxt->wellFormed = 0; if (ctxt->recovery == 0) ctxt->disableSAX = 1; goto error; } } prop = prop->next; } } else { namespace = NULL; } /* !!!!!! */ ret = xmlNewNsPropEatName(ctxt->node, namespace, name, NULL); if (ret != NULL) { if ((ctxt->replaceEntities == 0) && (!ctxt->html)) { xmlNodePtr tmp; ret->children = xmlStringGetNodeList(ctxt->myDoc, value); tmp = ret->children; while (tmp != NULL) { tmp->parent = (xmlNodePtr) ret; if (tmp->next == NULL) ret->last = tmp; tmp = tmp->next; } } else if (value != NULL) { ret->children = xmlNewDocText(ctxt->myDoc, value); ret->last = ret->children; if (ret->children != NULL) ret->children->parent = (xmlNodePtr) ret; } } #ifdef LIBXML_VALID_ENABLED if ((!ctxt->html) && ctxt->validate && ctxt->wellFormed && ctxt->myDoc && ctxt->myDoc->intSubset) { /* * If we don't substitute entities, the validation should be * done on a value with replaced entities anyway. */ if (!ctxt->replaceEntities) { xmlChar *val; ctxt->depth++; val = xmlStringDecodeEntities(ctxt, value, XML_SUBSTITUTE_REF, 0,0,0); ctxt->depth--; if (val == NULL) ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt, ctxt->myDoc, ctxt->node, ret, value); else { xmlChar *nvalnorm; /* * Do the last stage of the attribute normalization * It need to be done twice ... it's an extra burden related * to the ability to keep xmlSAX2References in attributes */ nvalnorm = xmlValidNormalizeAttributeValue(ctxt->myDoc, ctxt->node, fullname, val); if (nvalnorm != NULL) { xmlFree(val); val = nvalnorm; } ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt, ctxt->myDoc, ctxt->node, ret, val); xmlFree(val); } } else { ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt, ctxt->myDoc, ctxt->node, ret, value); } } else #endif /* LIBXML_VALID_ENABLED */ if (((ctxt->loadsubset & XML_SKIP_IDS) == 0) && (((ctxt->replaceEntities == 0) && (ctxt->external != 2)) || ((ctxt->replaceEntities != 0) && (ctxt->inSubset == 0)))) { /* * when validating, the ID registration is done at the attribute * validation level. Otherwise we have to do specific handling here. */ if (xmlStrEqual(fullname, BAD_CAST "xml:id")) { /* * Add the xml:id value * * Open issue: normalization of the value. */ if (xmlValidateNCName(value, 1) != 0) { xmlErrValid(ctxt, XML_DTD_XMLID_VALUE, "xml:id : attribute value %s is not an NCName\n", (const char *) value, NULL); } xmlAddID(&ctxt->vctxt, ctxt->myDoc, value, ret); } else if (xmlIsID(ctxt->myDoc, ctxt->node, ret)) xmlAddID(&ctxt->vctxt, ctxt->myDoc, value, ret); else if (xmlIsRef(ctxt->myDoc, ctxt->node, ret)) xmlAddRef(&ctxt->vctxt, ctxt->myDoc, value, ret); } error: if (nval != NULL) xmlFree(nval); if (ns != NULL) xmlFree(ns); } /* * xmlCheckDefaultedAttributes: * * Check defaulted attributes from the DTD */ static void xmlCheckDefaultedAttributes(xmlParserCtxtPtr ctxt, const xmlChar *name, const xmlChar *prefix, const xmlChar **atts) { xmlElementPtr elemDecl; const xmlChar *att; int internal = 1; int i; elemDecl = xmlGetDtdQElementDesc(ctxt->myDoc->intSubset, name, prefix); if (elemDecl == NULL) { elemDecl = xmlGetDtdQElementDesc(ctxt->myDoc->extSubset, name, prefix); internal = 0; } process_external_subset: if (elemDecl != NULL) { xmlAttributePtr attr = elemDecl->attributes; /* * Check against defaulted attributes from the external subset * if the document is stamped as standalone */ if ((ctxt->myDoc->standalone == 1) && (ctxt->myDoc->extSubset != NULL) && (ctxt->validate)) { while (attr != NULL) { if ((attr->defaultValue != NULL) && (xmlGetDtdQAttrDesc(ctxt->myDoc->extSubset, attr->elem, attr->name, attr->prefix) == attr) && (xmlGetDtdQAttrDesc(ctxt->myDoc->intSubset, attr->elem, attr->name, attr->prefix) == NULL)) { xmlChar *fulln; if (attr->prefix != NULL) { fulln = xmlStrdup(attr->prefix); fulln = xmlStrcat(fulln, BAD_CAST ":"); fulln = xmlStrcat(fulln, attr->name); } else { fulln = xmlStrdup(attr->name); } /* * Check that the attribute is not declared in the * serialization */ att = NULL; if (atts != NULL) { i = 0; att = atts[i]; while (att != NULL) { if (xmlStrEqual(att, fulln)) break; i += 2; att = atts[i]; } } if (att == NULL) { xmlErrValid(ctxt, XML_DTD_STANDALONE_DEFAULTED, "standalone: attribute %s on %s defaulted from external subset\n", (const char *)fulln, (const char *)attr->elem); } } attr = attr->nexth; } } /* * Actually insert defaulted values when needed */ attr = elemDecl->attributes; while (attr != NULL) { /* * Make sure that attributes redefinition occuring in the * internal subset are not overriden by definitions in the * external subset. */ if (attr->defaultValue != NULL) { /* * the element should be instantiated in the tree if: * - this is a namespace prefix * - the user required for completion in the tree * like XSLT * - there isn't already an attribute definition * in the internal subset overriding it. */ if (((attr->prefix != NULL) && (xmlStrEqual(attr->prefix, BAD_CAST "xmlns"))) || ((attr->prefix == NULL) && (xmlStrEqual(attr->name, BAD_CAST "xmlns"))) || (ctxt->loadsubset & XML_COMPLETE_ATTRS)) { xmlAttributePtr tst; tst = xmlGetDtdQAttrDesc(ctxt->myDoc->intSubset, attr->elem, attr->name, attr->prefix); if ((tst == attr) || (tst == NULL)) { xmlChar fn[50]; xmlChar *fulln; fulln = xmlBuildQName(attr->name, attr->prefix, fn, 50); if (fulln == NULL) { xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElement"); return; } /* * Check that the attribute is not declared in the * serialization */ att = NULL; if (atts != NULL) { i = 0; att = atts[i]; while (att != NULL) { if (xmlStrEqual(att, fulln)) break; i += 2; att = atts[i]; } } if (att == NULL) { xmlSAX2AttributeInternal(ctxt, fulln, attr->defaultValue, prefix); } if ((fulln != fn) && (fulln != attr->name)) xmlFree(fulln); } } } attr = attr->nexth; } if (internal == 1) { elemDecl = xmlGetDtdQElementDesc(ctxt->myDoc->extSubset, name, prefix); internal = 0; goto process_external_subset; } } } /** * xmlSAX2StartElement: * @ctx: the user data (XML parser context) * @fullname: The element name, including namespace prefix * @atts: An array of name/value attributes pairs, NULL terminated * * called when an opening tag has been processed. */ void xmlSAX2StartElement(void *ctx, const xmlChar *fullname, const xmlChar **atts) { xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; xmlNodePtr ret; xmlNodePtr parent; xmlNsPtr ns; xmlChar *name; xmlChar *prefix; const xmlChar *att; const xmlChar *value; int i; if ((ctx == NULL) || (fullname == NULL) || (ctxt->myDoc == NULL)) return; parent = ctxt->node; #ifdef DEBUG_SAX xmlGenericError(xmlGenericErrorContext, "SAX.xmlSAX2StartElement(%s)\n", fullname); #endif /* * First check on validity: */ if (ctxt->validate && (ctxt->myDoc->extSubset == NULL) && ((ctxt->myDoc->intSubset == NULL) || ((ctxt->myDoc->intSubset->notations == NULL) && (ctxt->myDoc->intSubset->elements == NULL) && (ctxt->myDoc->intSubset->attributes == NULL) && (ctxt->myDoc->intSubset->entities == NULL)))) { xmlErrValid(ctxt, XML_ERR_NO_DTD, "Validation failed: no DTD found !", NULL, NULL); ctxt->validate = 0; } /* * Split the full name into a namespace prefix and the tag name */ name = xmlSplitQName(ctxt, fullname, &prefix); /* * Note : the namespace resolution is deferred until the end of the * attributes parsing, since local namespace can be defined as * an attribute at this level. */ ret = xmlNewDocNodeEatName(ctxt->myDoc, NULL, name, NULL); if (ret == NULL) { if (prefix != NULL) xmlFree(prefix); xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElement"); return; } if (ctxt->myDoc->children == NULL) { #ifdef DEBUG_SAX_TREE xmlGenericError(xmlGenericErrorContext, "Setting %s as root\n", name); #endif xmlAddChild((xmlNodePtr) ctxt->myDoc, (xmlNodePtr) ret); } else if (parent == NULL) { parent = ctxt->myDoc->children; } ctxt->nodemem = -1; if (ctxt->linenumbers) { if (ctxt->input != NULL) { if (ctxt->input->line < 65535) ret->line = (short) ctxt->input->line; else ret->line = 65535; } } /* * We are parsing a new node. */ #ifdef DEBUG_SAX_TREE xmlGenericError(xmlGenericErrorContext, "pushing(%s)\n", name); #endif nodePush(ctxt, ret); /* * Link the child element */ if (parent != NULL) { if (parent->type == XML_ELEMENT_NODE) { #ifdef DEBUG_SAX_TREE xmlGenericError(xmlGenericErrorContext, "adding child %s to %s\n", name, parent->name); #endif xmlAddChild(parent, ret); } else { #ifdef DEBUG_SAX_TREE xmlGenericError(xmlGenericErrorContext, "adding sibling %s to ", name); xmlDebugDumpOneNode(stderr, parent, 0); #endif xmlAddSibling(parent, ret); } } /* * Insert all the defaulted attributes from the DTD especially namespaces */ if ((!ctxt->html) && ((ctxt->myDoc->intSubset != NULL) || (ctxt->myDoc->extSubset != NULL))) { xmlCheckDefaultedAttributes(ctxt, name, prefix, atts); } /* * process all the attributes whose name start with "xmlns" */ if (atts != NULL) { i = 0; att = atts[i++]; value = atts[i++]; if (!ctxt->html) { while ((att != NULL) && (value != NULL)) { if ((att[0] == 'x') && (att[1] == 'm') && (att[2] == 'l') && (att[3] == 'n') && (att[4] == 's')) xmlSAX2AttributeInternal(ctxt, att, value, prefix); att = atts[i++]; value = atts[i++]; } } } /* * Search the namespace, note that since the attributes have been * processed, the local namespaces are available. */ ns = xmlSearchNs(ctxt->myDoc, ret, prefix); if ((ns == NULL) && (parent != NULL)) ns = xmlSearchNs(ctxt->myDoc, parent, prefix); if ((prefix != NULL) && (ns == NULL)) { ns = xmlNewNs(ret, NULL, prefix); xmlNsWarnMsg(ctxt, XML_NS_ERR_UNDEFINED_NAMESPACE, "Namespace prefix %s is not defined\n", prefix, NULL); } /* * set the namespace node, making sure that if the default namspace * is unbound on a parent we simply kee it NULL */ if ((ns != NULL) && (ns->href != NULL) && ((ns->href[0] != 0) || (ns->prefix != NULL))) xmlSetNs(ret, ns); /* * process all the other attributes */ if (atts != NULL) { i = 0; att = atts[i++]; value = atts[i++]; if (ctxt->html) { while (att != NULL) { xmlSAX2AttributeInternal(ctxt, att, value, NULL); att = atts[i++]; value = atts[i++]; } } else { while ((att != NULL) && (value != NULL)) { if ((att[0] != 'x') || (att[1] != 'm') || (att[2] != 'l') || (att[3] != 'n') || (att[4] != 's')) xmlSAX2AttributeInternal(ctxt, att, value, NULL); /* * Next ones */ att = atts[i++]; value = atts[i++]; } } } #ifdef LIBXML_VALID_ENABLED /* * If it's the Document root, finish the DTD validation and * check the document root element for validity */ if ((ctxt->validate) && (ctxt->vctxt.finishDtd == XML_CTXT_FINISH_DTD_0)) { int chk; chk = xmlValidateDtdFinal(&ctxt->vctxt, ctxt->myDoc); if (chk <= 0) ctxt->valid = 0; if (chk < 0) ctxt->wellFormed = 0; ctxt->valid &= xmlValidateRoot(&ctxt->vctxt, ctxt->myDoc); ctxt->vctxt.finishDtd = XML_CTXT_FINISH_DTD_1; } #endif /* LIBXML_VALID_ENABLED */ if (prefix != NULL) xmlFree(prefix); } /** * xmlSAX2EndElement: * @ctx: the user data (XML parser context) * @name: The element name * * called when the end of an element has been detected. */ void xmlSAX2EndElement(void *ctx, const xmlChar *name ATTRIBUTE_UNUSED) { xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; xmlParserNodeInfo node_info; xmlNodePtr cur; if (ctx == NULL) return; cur = ctxt->node; #ifdef DEBUG_SAX if (name == NULL) xmlGenericError(xmlGenericErrorContext, "SAX.xmlSAX2EndElement(NULL)\n"); else xmlGenericError(xmlGenericErrorContext, "SAX.xmlSAX2EndElement(%s)\n", name); #endif /* Capture end position and add node */ if (cur != NULL && ctxt->record_info) { node_info.end_pos = ctxt->input->cur - ctxt->input->base; node_info.end_line = ctxt->input->line; node_info.node = cur; xmlParserAddNodeInfo(ctxt, &node_info); } ctxt->nodemem = -1; #ifdef LIBXML_VALID_ENABLED if (ctxt->validate && ctxt->wellFormed && ctxt->myDoc && ctxt->myDoc->intSubset) ctxt->valid &= xmlValidateOneElement(&ctxt->vctxt, ctxt->myDoc, cur); #endif /* LIBXML_VALID_ENABLED */ /* * end of parsing of this node. */ #ifdef DEBUG_SAX_TREE xmlGenericError(xmlGenericErrorContext, "popping(%s)\n", cur->name); #endif nodePop(ctxt); } #endif /* LIBXML_SAX1_ENABLED || LIBXML_HTML_ENABLE */ /* * xmlSAX2TextNode: * @ctxt: the parser context * @str: the input string * @len: the string length * * Remove the entities from an attribute value * * Returns the newly allocated string or NULL if not needed or error */ static xmlNodePtr xmlSAX2TextNode(xmlParserCtxtPtr ctxt, const xmlChar *str, int len) { xmlNodePtr ret; const xmlChar *intern = NULL; /* * Allocate */ if (ctxt->freeElems != NULL) { ret = ctxt->freeElems; ctxt->freeElems = ret->next; ctxt->freeElemsNr--; } else { ret = (xmlNodePtr) xmlMalloc(sizeof(xmlNode)); } if (ret == NULL) { xmlErrMemory(ctxt, "xmlSAX2Characters"); return(NULL); } memset(ret, 0, sizeof(xmlNode)); /* * intern the formatting blanks found between tags, or the * very short strings */ if (ctxt->dictNames) { xmlChar cur = str[len]; if ((len < (int) (2 * sizeof(void *))) && (ctxt->options & XML_PARSE_COMPACT)) { /* store the string in the node overrithing properties and nsDef */ xmlChar *tmp = (xmlChar *) &(ret->properties); memcpy(tmp, str, len); tmp[len] = 0; intern = tmp; } else if ((len <= 3) && ((cur == '"') || (cur == '\'') || ((cur == '<') && (str[len + 1] != '!')))) { intern = xmlDictLookup(ctxt->dict, str, len); } else if (IS_BLANK_CH(*str) && (len < 60) && (cur == '<') && (str[len + 1] != '!')) { int i; for (i = 1;i < len;i++) { if (!IS_BLANK_CH(str[i])) goto skip; } intern = xmlDictLookup(ctxt->dict, str, len); } } skip: ret->type = XML_TEXT_NODE; ret->name = xmlStringText; if (intern == NULL) { ret->content = xmlStrndup(str, len); if (ret->content == NULL) { xmlSAX2ErrMemory(ctxt, "xmlSAX2TextNode"); xmlFree(ret); return(NULL); } } else ret->content = (xmlChar *) intern; if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue)) xmlRegisterNodeDefaultValue(ret); return(ret); } #ifdef LIBXML_VALID_ENABLED /* * xmlSAX2DecodeAttrEntities: * @ctxt: the parser context * @str: the input string * @len: the string length * * Remove the entities from an attribute value * * Returns the newly allocated string or NULL if not needed or error */ static xmlChar * xmlSAX2DecodeAttrEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, const xmlChar *end) { const xmlChar *in; xmlChar *ret; in = str; while (in < end) if (*in++ == '&') goto decode; return(NULL); decode: ctxt->depth++; ret = xmlStringLenDecodeEntities(ctxt, str, end - str, XML_SUBSTITUTE_REF, 0,0,0); ctxt->depth--; return(ret); } #endif /* LIBXML_VALID_ENABLED */ /** * xmlSAX2AttributeNs: * @ctx: the user data (XML parser context) * @localname: the local name of the attribute * @prefix: the attribute namespace prefix if available * @URI: the attribute namespace name if available * @value: Start of the attribute value * @valueend: end of the attribute value * * Handle an attribute that has been read by the parser. * The default handling is to convert the attribute into an * DOM subtree and past it in a new xmlAttr element added to * the element. */ static void xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt, const xmlChar * localname, const xmlChar * prefix, const xmlChar * value, const xmlChar * valueend) { xmlAttrPtr ret; xmlNsPtr namespace = NULL; xmlChar *dup = NULL; /* * Note: if prefix == NULL, the attribute is not in the default namespace */ if (prefix != NULL) namespace = xmlSearchNs(ctxt->myDoc, ctxt->node, prefix); /* * allocate the node */ if (ctxt->freeAttrs != NULL) { ret = ctxt->freeAttrs; ctxt->freeAttrs = ret->next; ctxt->freeAttrsNr--; memset(ret, 0, sizeof(xmlAttr)); ret->type = XML_ATTRIBUTE_NODE; ret->parent = ctxt->node; ret->doc = ctxt->myDoc; ret->ns = namespace; if (ctxt->dictNames) ret->name = localname; else ret->name = xmlStrdup(localname); /* link at the end to preserv order, TODO speed up with a last */ if (ctxt->node->properties == NULL) { ctxt->node->properties = ret; } else { xmlAttrPtr prev = ctxt->node->properties; while (prev->next != NULL) prev = prev->next; prev->next = ret; ret->prev = prev; } if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue)) xmlRegisterNodeDefaultValue((xmlNodePtr)ret); } else { if (ctxt->dictNames) ret = xmlNewNsPropEatName(ctxt->node, namespace, (xmlChar *) localname, NULL); else ret = xmlNewNsProp(ctxt->node, namespace, localname, NULL); if (ret == NULL) { xmlErrMemory(ctxt, "xmlSAX2AttributeNs"); return; } } if ((ctxt->replaceEntities == 0) && (!ctxt->html)) { xmlNodePtr tmp; /* * We know that if there is an entity reference, then * the string has been dup'ed and terminates with 0 * otherwise with ' or " */ if (*valueend != 0) { tmp = xmlSAX2TextNode(ctxt, value, valueend - value); ret->children = tmp; ret->last = tmp; if (tmp != NULL) { tmp->doc = ret->doc; tmp->parent = (xmlNodePtr) ret; } } else { ret->children = xmlStringLenGetNodeList(ctxt->myDoc, value, valueend - value); tmp = ret->children; while (tmp != NULL) { tmp->doc = ret->doc; tmp->parent = (xmlNodePtr) ret; if (tmp->next == NULL) ret->last = tmp; tmp = tmp->next; } } } else if (value != NULL) { xmlNodePtr tmp; tmp = xmlSAX2TextNode(ctxt, value, valueend - value); ret->children = tmp; ret->last = tmp; if (tmp != NULL) { tmp->doc = ret->doc; tmp->parent = (xmlNodePtr) ret; } } #ifdef LIBXML_VALID_ENABLED if ((!ctxt->html) && ctxt->validate && ctxt->wellFormed && ctxt->myDoc && ctxt->myDoc->intSubset) { /* * If we don't substitute entities, the validation should be * done on a value with replaced entities anyway. */ if (!ctxt->replaceEntities) { dup = xmlSAX2DecodeAttrEntities(ctxt, value, valueend); if (dup == NULL) { if (*valueend == 0) { ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt, ctxt->myDoc, ctxt->node, ret, value); } else { /* * That should already be normalized. * cheaper to finally allocate here than duplicate * entry points in the full validation code */ dup = xmlStrndup(value, valueend - value); ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt, ctxt->myDoc, ctxt->node, ret, dup); } } else { /* * dup now contains a string of the flattened attribute * content with entities substitued. Check if we need to * apply an extra layer of normalization. * It need to be done twice ... it's an extra burden related * to the ability to keep references in attributes */ if (ctxt->attsSpecial != NULL) { xmlChar *nvalnorm; xmlChar fn[50]; xmlChar *fullname; fullname = xmlBuildQName(localname, prefix, fn, 50); if (fullname != NULL) { ctxt->vctxt.valid = 1; nvalnorm = xmlValidCtxtNormalizeAttributeValue( &ctxt->vctxt, ctxt->myDoc, ctxt->node, fullname, dup); if (ctxt->vctxt.valid != 1) ctxt->valid = 0; if ((fullname != fn) && (fullname != localname)) xmlFree(fullname); if (nvalnorm != NULL) { xmlFree(dup); dup = nvalnorm; } } } ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt, ctxt->myDoc, ctxt->node, ret, dup); } } else { /* * if entities already have been substitued, then * the attribute as passed is already normalized */ dup = xmlStrndup(value, valueend - value); ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt, ctxt->myDoc, ctxt->node, ret, dup); } } else #endif /* LIBXML_VALID_ENABLED */ if (((ctxt->loadsubset & XML_SKIP_IDS) == 0) && (((ctxt->replaceEntities == 0) && (ctxt->external != 2)) || ((ctxt->replaceEntities != 0) && (ctxt->inSubset == 0)))) { /* * when validating, the ID registration is done at the attribute * validation level. Otherwise we have to do specific handling here. */ if ((prefix == ctxt->str_xml) && (localname[0] == 'i') && (localname[1] == 'd') && (localname[2] == 0)) { /* * Add the xml:id value * * Open issue: normalization of the value. */ if (dup == NULL) dup = xmlStrndup(value, valueend - value); #ifdef LIBXML_VALID_ENABLED if (xmlValidateNCName(dup, 1) != 0) { xmlErrValid(ctxt, XML_DTD_XMLID_VALUE, "xml:id : attribute value %s is not an NCName\n", (const char *) dup, NULL); } #endif xmlAddID(&ctxt->vctxt, ctxt->myDoc, dup, ret); } else if (xmlIsID(ctxt->myDoc, ctxt->node, ret)) { /* might be worth duplicate entry points and not copy */ if (dup == NULL) dup = xmlStrndup(value, valueend - value); xmlAddID(&ctxt->vctxt, ctxt->myDoc, dup, ret); } else if (xmlIsRef(ctxt->myDoc, ctxt->node, ret)) { if (dup == NULL) dup = xmlStrndup(value, valueend - value); xmlAddRef(&ctxt->vctxt, ctxt->myDoc, dup, ret); } } if (dup != NULL) xmlFree(dup); } /** * xmlSAX2StartElementNs: * @ctx: the user data (XML parser context) * @localname: the local name of the element * @prefix: the element namespace prefix if available * @URI: the element namespace name if available * @nb_namespaces: number of namespace definitions on that node * @namespaces: pointer to the array of prefix/URI pairs namespace definitions * @nb_attributes: the number of attributes on that node * @nb_defaulted: the number of defaulted attributes. * @attributes: pointer to the array of (localname/prefix/URI/value/end) * attribute values. * * SAX2 callback when an element start has been detected by the parser. * It provides the namespace informations for the element, as well as * the new namespace declarations on the element. */ void xmlSAX2StartElementNs(void *ctx, const xmlChar *localname, const xmlChar *prefix, const xmlChar *URI, int nb_namespaces, const xmlChar **namespaces, int nb_attributes, int nb_defaulted, const xmlChar **attributes) { xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; xmlNodePtr ret; xmlNodePtr parent; xmlNsPtr last = NULL, ns; const xmlChar *uri, *pref; int i, j; if (ctx == NULL) return; parent = ctxt->node; /* * First check on validity: */ if (ctxt->validate && (ctxt->myDoc->extSubset == NULL) && ((ctxt->myDoc->intSubset == NULL) || ((ctxt->myDoc->intSubset->notations == NULL) && (ctxt->myDoc->intSubset->elements == NULL) && (ctxt->myDoc->intSubset->attributes == NULL) && (ctxt->myDoc->intSubset->entities == NULL)))) { xmlErrValid(ctxt, XML_ERR_NO_DTD, "Validation failed: no DTD found !", NULL, NULL); ctxt->validate = 0; } /* * allocate the node */ if (ctxt->freeElems != NULL) { ret = ctxt->freeElems; ctxt->freeElems = ret->next; ctxt->freeElemsNr--; memset(ret, 0, sizeof(xmlNode)); ret->type = XML_ELEMENT_NODE; if (ctxt->dictNames) ret->name = localname; else { ret->name = xmlStrdup(localname); if (ret->name == NULL) { xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElementNs"); return; } } if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue)) xmlRegisterNodeDefaultValue(ret); } else { if (ctxt->dictNames) ret = xmlNewDocNodeEatName(ctxt->myDoc, NULL, (xmlChar *) localname, NULL); else ret = xmlNewDocNode(ctxt->myDoc, NULL, localname, NULL); if (ret == NULL) { xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElementNs"); return; } } if (ctxt->linenumbers) { if (ctxt->input != NULL) { if (ctxt->input->line < 65535) ret->line = (short) ctxt->input->line; else ret->line = 65535; } } if ((ctxt->myDoc->children == NULL) || (parent == NULL)) { xmlAddChild((xmlNodePtr) ctxt->myDoc, (xmlNodePtr) ret); } /* * Build the namespace list */ for (i = 0,j = 0;j < nb_namespaces;j++) { pref = namespaces[i++]; uri = namespaces[i++]; ns = xmlNewNs(NULL, uri, pref); if (ns != NULL) { if (last == NULL) { ret->nsDef = last = ns; } else { last->next = ns; last = ns; } if ((URI != NULL) && (prefix == pref)) ret->ns = ns; } else { xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElementNs"); return; } #ifdef LIBXML_VALID_ENABLED if ((!ctxt->html) && ctxt->validate && ctxt->wellFormed && ctxt->myDoc && ctxt->myDoc->intSubset) { ctxt->valid &= xmlValidateOneNamespace(&ctxt->vctxt, ctxt->myDoc, ret, prefix, ns, uri); } #endif /* LIBXML_VALID_ENABLED */ } ctxt->nodemem = -1; /* * We are parsing a new node. */ nodePush(ctxt, ret); /* * Link the child element */ if (parent != NULL) { if (parent->type == XML_ELEMENT_NODE) { xmlAddChild(parent, ret); } else { xmlAddSibling(parent, ret); } } /* * Insert the defaulted attributes from the DTD only if requested: */ if ((nb_defaulted != 0) && ((ctxt->loadsubset & XML_COMPLETE_ATTRS) == 0)) nb_attributes -= nb_defaulted; /* * Search the namespace if it wasn't already found * Note that, if prefix is NULL, this searches for the default Ns */ if ((URI != NULL) && (ret->ns == NULL)) { ret->ns = xmlSearchNs(ctxt->myDoc, parent, prefix); if ((ret->ns == NULL) && (xmlStrEqual(prefix, BAD_CAST "xml"))) { ret->ns = xmlSearchNs(ctxt->myDoc, ret, prefix); } if (ret->ns == NULL) { ns = xmlNewNs(ret, NULL, prefix); if (ns == NULL) { xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElementNs"); return; } xmlNsWarnMsg(ctxt, XML_NS_ERR_UNDEFINED_NAMESPACE, "Namespace prefix %s was not found\n", prefix, NULL); } } /* * process all the other attributes */ if (nb_attributes > 0) { for (j = 0,i = 0;i < nb_attributes;i++,j+=5) { xmlSAX2AttributeNs(ctxt, attributes[j], attributes[j+1], attributes[j+3], attributes[j+4]); } } #ifdef LIBXML_VALID_ENABLED /* * If it's the Document root, finish the DTD validation and * check the document root element for validity */ if ((ctxt->validate) && (ctxt->vctxt.finishDtd == XML_CTXT_FINISH_DTD_0)) { int chk; chk = xmlValidateDtdFinal(&ctxt->vctxt, ctxt->myDoc); if (chk <= 0) ctxt->valid = 0; if (chk < 0) ctxt->wellFormed = 0; ctxt->valid &= xmlValidateRoot(&ctxt->vctxt, ctxt->myDoc); ctxt->vctxt.finishDtd = XML_CTXT_FINISH_DTD_1; } #endif /* LIBXML_VALID_ENABLED */ } /** * xmlSAX2EndElementNs: * @ctx: the user data (XML parser context) * @localname: the local name of the element * @prefix: the element namespace prefix if available * @URI: the element namespace name if available * * SAX2 callback when an element end has been detected by the parser. * It provides the namespace informations for the element. */ void xmlSAX2EndElementNs(void *ctx, const xmlChar * localname ATTRIBUTE_UNUSED, const xmlChar * prefix ATTRIBUTE_UNUSED, const xmlChar * URI ATTRIBUTE_UNUSED) { xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; xmlParserNodeInfo node_info; xmlNodePtr cur; if (ctx == NULL) return; cur = ctxt->node; /* Capture end position and add node */ if ((ctxt->record_info) && (cur != NULL)) { node_info.end_pos = ctxt->input->cur - ctxt->input->base; node_info.end_line = ctxt->input->line; node_info.node = cur; xmlParserAddNodeInfo(ctxt, &node_info); } ctxt->nodemem = -1; #ifdef LIBXML_VALID_ENABLED if (ctxt->validate && ctxt->wellFormed && ctxt->myDoc && ctxt->myDoc->intSubset) ctxt->valid &= xmlValidateOneElement(&ctxt->vctxt, ctxt->myDoc, cur); #endif /* LIBXML_VALID_ENABLED */ /* * end of parsing of this node. */ nodePop(ctxt); } /** * xmlSAX2Reference: * @ctx: the user data (XML parser context) * @name: The entity name * * called when an entity xmlSAX2Reference is detected. */ void xmlSAX2Reference(void *ctx, const xmlChar *name) { xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; xmlNodePtr ret; if (ctx == NULL) return; #ifdef DEBUG_SAX xmlGenericError(xmlGenericErrorContext, "SAX.xmlSAX2Reference(%s)\n", name); #endif if (name[0] == '#') ret = xmlNewCharRef(ctxt->myDoc, name); else ret = xmlNewReference(ctxt->myDoc, name); #ifdef DEBUG_SAX_TREE xmlGenericError(xmlGenericErrorContext, "add xmlSAX2Reference %s to %s \n", name, ctxt->node->name); #endif xmlAddChild(ctxt->node, ret); } /** * xmlSAX2Characters: * @ctx: the user data (XML parser context) * @ch: a xmlChar string * @len: the number of xmlChar * * receiving some chars from the parser. */ void xmlSAX2Characters(void *ctx, const xmlChar *ch, int len) { xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; xmlNodePtr lastChild; if (ctx == NULL) return; #ifdef DEBUG_SAX xmlGenericError(xmlGenericErrorContext, "SAX.xmlSAX2Characters(%.30s, %d)\n", ch, len); #endif /* * Handle the data if any. If there is no child * add it as content, otherwise if the last child is text, * concatenate it, else create a new node of type text. */ if (ctxt->node == NULL) { #ifdef DEBUG_SAX_TREE xmlGenericError(xmlGenericErrorContext, "add chars: ctxt->node == NULL !\n"); #endif return; } lastChild = ctxt->node->last; #ifdef DEBUG_SAX_TREE xmlGenericError(xmlGenericErrorContext, "add chars to %s \n", ctxt->node->name); #endif /* * Here we needed an accelerator mechanism in case of very large * elements. Use an attribute in the structure !!! */ if (lastChild == NULL) { lastChild = xmlSAX2TextNode(ctxt, ch, len); if (lastChild != NULL) { ctxt->node->children = lastChild; ctxt->node->last = lastChild; lastChild->parent = ctxt->node; lastChild->doc = ctxt->node->doc; ctxt->nodelen = len; ctxt->nodemem = len + 1; } else { xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters"); return; } } else { int coalesceText = (lastChild != NULL) && (lastChild->type == XML_TEXT_NODE) && (lastChild->name == xmlStringText); if ((coalesceText) && (ctxt->nodemem != 0)) { /* * The whole point of maintaining nodelen and nodemem, * xmlTextConcat is too costly, i.e. compute length, * reallocate a new buffer, move data, append ch. Here * We try to minimaze realloc() uses and avoid copying * and recomputing length over and over. */ if (lastChild->content == (xmlChar *)&(lastChild->properties)) { lastChild->content = xmlStrdup(lastChild->content); lastChild->properties = NULL; } else if ((ctxt->nodemem == ctxt->nodelen + 1) && (xmlDictOwns(ctxt->dict, lastChild->content))) { lastChild->content = xmlStrdup(lastChild->content); } if (ctxt->nodelen + len >= ctxt->nodemem) { xmlChar *newbuf; int size; size = ctxt->nodemem + len; size *= 2; newbuf = (xmlChar *) xmlRealloc(lastChild->content,size); if (newbuf == NULL) { xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters"); return; } ctxt->nodemem = size; lastChild->content = newbuf; } memcpy(&lastChild->content[ctxt->nodelen], ch, len); ctxt->nodelen += len; lastChild->content[ctxt->nodelen] = 0; } else if (coalesceText) { if (xmlTextConcat(lastChild, ch, len)) { xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters"); } if (ctxt->node->children != NULL) { ctxt->nodelen = xmlStrlen(lastChild->content); ctxt->nodemem = ctxt->nodelen + 1; } } else { /* Mixed content, first time */ lastChild = xmlSAX2TextNode(ctxt, ch, len); if (lastChild != NULL) { xmlAddChild(ctxt->node, lastChild); if (ctxt->node->children != NULL) { ctxt->nodelen = len; ctxt->nodemem = len + 1; } } } } } /** * xmlSAX2IgnorableWhitespace: * @ctx: the user data (XML parser context) * @ch: a xmlChar string * @len: the number of xmlChar * * receiving some ignorable whitespaces from the parser. * UNUSED: by default the DOM building will use xmlSAX2Characters */ void xmlSAX2IgnorableWhitespace(void *ctx ATTRIBUTE_UNUSED, const xmlChar *ch ATTRIBUTE_UNUSED, int len ATTRIBUTE_UNUSED) { /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */ #ifdef DEBUG_SAX xmlGenericError(xmlGenericErrorContext, "SAX.xmlSAX2IgnorableWhitespace(%.30s, %d)\n", ch, len); #endif } /** * xmlSAX2ProcessingInstruction: * @ctx: the user data (XML parser context) * @target: the target name * @data: the PI data's * * A processing instruction has been parsed. */ void xmlSAX2ProcessingInstruction(void *ctx, const xmlChar *target, const xmlChar *data) { xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; xmlNodePtr ret; xmlNodePtr parent; if (ctx == NULL) return; parent = ctxt->node; #ifdef DEBUG_SAX xmlGenericError(xmlGenericErrorContext, "SAX.xmlSAX2ProcessingInstruction(%s, %s)\n", target, data); #endif ret = xmlNewDocPI(ctxt->myDoc, target, data); if (ret == NULL) return; parent = ctxt->node; if (ctxt->linenumbers) { if (ctxt->input != NULL) { if (ctxt->input->line < 65535) ret->line = (short) ctxt->input->line; else ret->line = 65535; } } if (ctxt->inSubset == 1) { xmlAddChild((xmlNodePtr) ctxt->myDoc->intSubset, ret); return; } else if (ctxt->inSubset == 2) { xmlAddChild((xmlNodePtr) ctxt->myDoc->extSubset, ret); return; } if ((ctxt->myDoc->children == NULL) || (parent == NULL)) { #ifdef DEBUG_SAX_TREE xmlGenericError(xmlGenericErrorContext, "Setting PI %s as root\n", target); #endif xmlAddChild((xmlNodePtr) ctxt->myDoc, (xmlNodePtr) ret); return; } if (parent->type == XML_ELEMENT_NODE) { #ifdef DEBUG_SAX_TREE xmlGenericError(xmlGenericErrorContext, "adding PI %s child to %s\n", target, parent->name); #endif xmlAddChild(parent, ret); } else { #ifdef DEBUG_SAX_TREE xmlGenericError(xmlGenericErrorContext, "adding PI %s sibling to ", target); xmlDebugDumpOneNode(stderr, parent, 0); #endif xmlAddSibling(parent, ret); } } /** * xmlSAX2Comment: * @ctx: the user data (XML parser context) * @value: the xmlSAX2Comment content * * A xmlSAX2Comment has been parsed. */ void xmlSAX2Comment(void *ctx, const xmlChar *value) { xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; xmlNodePtr ret; xmlNodePtr parent; if (ctx == NULL) return; parent = ctxt->node; #ifdef DEBUG_SAX xmlGenericError(xmlGenericErrorContext, "SAX.xmlSAX2Comment(%s)\n", value); #endif ret = xmlNewDocComment(ctxt->myDoc, value); if (ret == NULL) return; if (ctxt->linenumbers) { if (ctxt->input != NULL) { if (ctxt->input->line < 65535) ret->line = (short) ctxt->input->line; else ret->line = 65535; } } if (ctxt->inSubset == 1) { xmlAddChild((xmlNodePtr) ctxt->myDoc->intSubset, ret); return; } else if (ctxt->inSubset == 2) { xmlAddChild((xmlNodePtr) ctxt->myDoc->extSubset, ret); return; } if ((ctxt->myDoc->children == NULL) || (parent == NULL)) { #ifdef DEBUG_SAX_TREE xmlGenericError(xmlGenericErrorContext, "Setting xmlSAX2Comment as root\n"); #endif xmlAddChild((xmlNodePtr) ctxt->myDoc, (xmlNodePtr) ret); return; } if (parent->type == XML_ELEMENT_NODE) { #ifdef DEBUG_SAX_TREE xmlGenericError(xmlGenericErrorContext, "adding xmlSAX2Comment child to %s\n", parent->name); #endif xmlAddChild(parent, ret); } else { #ifdef DEBUG_SAX_TREE xmlGenericError(xmlGenericErrorContext, "adding xmlSAX2Comment sibling to "); xmlDebugDumpOneNode(stderr, parent, 0); #endif xmlAddSibling(parent, ret); } } /** * xmlSAX2CDataBlock: * @ctx: the user data (XML parser context) * @value: The pcdata content * @len: the block length * * called when a pcdata block has been parsed */ void xmlSAX2CDataBlock(void *ctx, const xmlChar *value, int len) { xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; xmlNodePtr ret, lastChild; if (ctx == NULL) return; #ifdef DEBUG_SAX xmlGenericError(xmlGenericErrorContext, "SAX.pcdata(%.10s, %d)\n", value, len); #endif lastChild = xmlGetLastChild(ctxt->node); #ifdef DEBUG_SAX_TREE xmlGenericError(xmlGenericErrorContext, "add chars to %s \n", ctxt->node->name); #endif if ((lastChild != NULL) && (lastChild->type == XML_CDATA_SECTION_NODE)) { xmlTextConcat(lastChild, value, len); } else { ret = xmlNewCDataBlock(ctxt->myDoc, value, len); xmlAddChild(ctxt->node, ret); } } static int xmlSAX2DefaultVersionValue = 2; #ifdef LIBXML_SAX1_ENABLED /** * xmlSAXDefaultVersion: * @version: the version, 1 or 2 * * Set the default version of SAX used globally by the library. * By default, during initialization the default is set to 2. * Note that it is generally a better coding style to use * xmlSAXVersion() to set up the version explicitly for a given * parsing context. * * Returns the previous value in case of success and -1 in case of error. */ int xmlSAXDefaultVersion(int version) { int ret = xmlSAX2DefaultVersionValue; if ((version != 1) && (version != 2)) return(-1); xmlSAX2DefaultVersionValue = version; return(ret); } #endif /* LIBXML_SAX1_ENABLED */ /** * xmlSAXVersion: * @hdlr: the SAX handler * @version: the version, 1 or 2 * * Initialize the default XML SAX handler according to the version * * Returns 0 in case of success and -1 in case of error. */ int xmlSAXVersion(xmlSAXHandler *hdlr, int version) { if (hdlr == NULL) return(-1); if (version == 2) { hdlr->startElement = NULL; hdlr->endElement = NULL; hdlr->startElementNs = xmlSAX2StartElementNs; hdlr->endElementNs = xmlSAX2EndElementNs; hdlr->serror = NULL; hdlr->initialized = XML_SAX2_MAGIC; #ifdef LIBXML_SAX1_ENABLED } else if (version == 1) { hdlr->startElement = xmlSAX2StartElement; hdlr->endElement = xmlSAX2EndElement; hdlr->initialized = 1; #endif /* LIBXML_SAX1_ENABLED */ } else return(-1); hdlr->internalSubset = xmlSAX2InternalSubset; hdlr->externalSubset = xmlSAX2ExternalSubset; hdlr->isStandalone = xmlSAX2IsStandalone; hdlr->hasInternalSubset = xmlSAX2HasInternalSubset; hdlr->hasExternalSubset = xmlSAX2HasExternalSubset; hdlr->resolveEntity = xmlSAX2ResolveEntity; hdlr->getEntity = xmlSAX2GetEntity; hdlr->getParameterEntity = xmlSAX2GetParameterEntity; hdlr->entityDecl = xmlSAX2EntityDecl; hdlr->attributeDecl = xmlSAX2AttributeDecl; hdlr->elementDecl = xmlSAX2ElementDecl; hdlr->notationDecl = xmlSAX2NotationDecl; hdlr->unparsedEntityDecl = xmlSAX2UnparsedEntityDecl; hdlr->setDocumentLocator = xmlSAX2SetDocumentLocator; hdlr->startDocument = xmlSAX2StartDocument; hdlr->endDocument = xmlSAX2EndDocument; hdlr->reference = xmlSAX2Reference; hdlr->characters = xmlSAX2Characters; hdlr->cdataBlock = xmlSAX2CDataBlock; hdlr->ignorableWhitespace = xmlSAX2Characters; hdlr->processingInstruction = xmlSAX2ProcessingInstruction; hdlr->comment = xmlSAX2Comment; hdlr->warning = xmlParserWarning; hdlr->error = xmlParserError; hdlr->fatalError = xmlParserError; return(0); } /** * xmlSAX2InitDefaultSAXHandler: * @hdlr: the SAX handler * @warning: flag if non-zero sets the handler warning procedure * * Initialize the default XML SAX2 handler */ void xmlSAX2InitDefaultSAXHandler(xmlSAXHandler *hdlr, int warning) { if ((hdlr == NULL) || (hdlr->initialized != 0)) return; xmlSAXVersion(hdlr, xmlSAX2DefaultVersionValue); if (warning == 0) hdlr->warning = NULL; else hdlr->warning = xmlParserWarning; } /** * xmlDefaultSAXHandlerInit: * * Initialize the default SAX2 handler */ void xmlDefaultSAXHandlerInit(void) { #ifdef LIBXML_SAX1_ENABLED xmlSAXVersion((xmlSAXHandlerPtr) &xmlDefaultSAXHandler, 1); #endif /* LIBXML_SAX1_ENABLED */ } #ifdef LIBXML_HTML_ENABLED /** * xmlSAX2InitHtmlDefaultSAXHandler: * @hdlr: the SAX handler * * Initialize the default HTML SAX2 handler */ void xmlSAX2InitHtmlDefaultSAXHandler(xmlSAXHandler *hdlr) { if ((hdlr == NULL) || (hdlr->initialized != 0)) return; hdlr->internalSubset = xmlSAX2InternalSubset; hdlr->externalSubset = NULL; hdlr->isStandalone = NULL; hdlr->hasInternalSubset = NULL; hdlr->hasExternalSubset = NULL; hdlr->resolveEntity = NULL; hdlr->getEntity = xmlSAX2GetEntity; hdlr->getParameterEntity = NULL; hdlr->entityDecl = NULL; hdlr->attributeDecl = NULL; hdlr->elementDecl = NULL; hdlr->notationDecl = NULL; hdlr->unparsedEntityDecl = NULL; hdlr->setDocumentLocator = xmlSAX2SetDocumentLocator; hdlr->startDocument = xmlSAX2StartDocument; hdlr->endDocument = xmlSAX2EndDocument; hdlr->startElement = xmlSAX2StartElement; hdlr->endElement = xmlSAX2EndElement; hdlr->reference = NULL; hdlr->characters = xmlSAX2Characters; hdlr->cdataBlock = xmlSAX2CDataBlock; hdlr->ignorableWhitespace = xmlSAX2IgnorableWhitespace; hdlr->processingInstruction = xmlSAX2ProcessingInstruction; hdlr->comment = xmlSAX2Comment; hdlr->warning = xmlParserWarning; hdlr->error = xmlParserError; hdlr->fatalError = xmlParserError; hdlr->initialized = 1; } /** * htmlDefaultSAXHandlerInit: * * Initialize the default SAX handler */ void htmlDefaultSAXHandlerInit(void) { xmlSAX2InitHtmlDefaultSAXHandler((xmlSAXHandlerPtr) &htmlDefaultSAXHandler); } #endif /* LIBXML_HTML_ENABLED */ #ifdef LIBXML_DOCB_ENABLED /** * xmlSAX2InitDocbDefaultSAXHandler: * @hdlr: the SAX handler * * Initialize the default DocBook SAX2 handler */ void xmlSAX2InitDocbDefaultSAXHandler(xmlSAXHandler *hdlr) { if ((hdlr == NULL) || (hdlr->initialized != 0)) return; hdlr->internalSubset = xmlSAX2InternalSubset; hdlr->externalSubset = NULL; hdlr->isStandalone = xmlSAX2IsStandalone; hdlr->hasInternalSubset = xmlSAX2HasInternalSubset; hdlr->hasExternalSubset = xmlSAX2HasExternalSubset; hdlr->resolveEntity = xmlSAX2ResolveEntity; hdlr->getEntity = xmlSAX2GetEntity; hdlr->getParameterEntity = NULL; hdlr->entityDecl = xmlSAX2EntityDecl; hdlr->attributeDecl = NULL; hdlr->elementDecl = NULL; hdlr->notationDecl = NULL; hdlr->unparsedEntityDecl = NULL; hdlr->setDocumentLocator = xmlSAX2SetDocumentLocator; hdlr->startDocument = xmlSAX2StartDocument; hdlr->endDocument = xmlSAX2EndDocument; hdlr->startElement = xmlSAX2StartElement; hdlr->endElement = xmlSAX2EndElement; hdlr->reference = xmlSAX2Reference; hdlr->characters = xmlSAX2Characters; hdlr->cdataBlock = NULL; hdlr->ignorableWhitespace = xmlSAX2IgnorableWhitespace; hdlr->processingInstruction = NULL; hdlr->comment = xmlSAX2Comment; hdlr->warning = xmlParserWarning; hdlr->error = xmlParserError; hdlr->fatalError = xmlParserError; hdlr->initialized = 1; } /** * docbDefaultSAXHandlerInit: * * Initialize the default SAX handler */ void docbDefaultSAXHandlerInit(void) { xmlSAX2InitDocbDefaultSAXHandler((xmlSAXHandlerPtr) &docbDefaultSAXHandler); } #endif /* LIBXML_DOCB_ENABLED */ #define bottom_SAX2 #include "elfgcchack.h" xdmf-3.0+git20160803/Utilities/vtklibxml2/c14n.c0000640000175000017500000017676413003006557021101 0ustar alastairalastair/* * "Canonical XML" implementation * http://www.w3.org/TR/xml-c14n * * "Exclusive XML Canonicalization" implementation * http://www.w3.org/TR/xml-exc-c14n * * See Copyright for the status of this software. * * Author: Aleksey Sanin */ #define IN_LIBXML #include "libxml.h" #ifdef LIBXML_C14N_ENABLED #ifdef LIBXML_OUTPUT_ENABLED #ifdef HAVE_STDLIB_H #include #endif #include #include #include #include #include #include #include #include /************************************************************************ * * * Some declaration better left private ATM * * * ************************************************************************/ typedef enum { XMLC14N_BEFORE_DOCUMENT_ELEMENT = 0, XMLC14N_INSIDE_DOCUMENT_ELEMENT = 1, XMLC14N_AFTER_DOCUMENT_ELEMENT = 2 } xmlC14NPosition; typedef struct _xmlC14NVisibleNsStack { int nsCurEnd; /* number of nodes in the set */ int nsPrevStart; /* the begginning of the stack for previous visible node */ int nsPrevEnd; /* the end of the stack for previous visible node */ int nsMax; /* size of the array as allocated */ xmlNsPtr *nsTab; /* array of ns in no particular order */ xmlNodePtr *nodeTab; /* array of nodes in no particular order */ } xmlC14NVisibleNsStack, *xmlC14NVisibleNsStackPtr; typedef struct _xmlC14NCtx { /* input parameters */ xmlDocPtr doc; xmlC14NIsVisibleCallback is_visible_callback; void* user_data; int with_comments; xmlOutputBufferPtr buf; /* position in the XML document */ xmlC14NPosition pos; int parent_is_doc; xmlC14NVisibleNsStackPtr ns_rendered; /* exclusive canonicalization */ int exclusive; xmlChar **inclusive_ns_prefixes; /* error number */ int error; } xmlC14NCtx, *xmlC14NCtxPtr; static xmlC14NVisibleNsStackPtr xmlC14NVisibleNsStackCreate (void); static void xmlC14NVisibleNsStackDestroy (xmlC14NVisibleNsStackPtr cur); static void xmlC14NVisibleNsStackAdd (xmlC14NVisibleNsStackPtr cur, xmlNsPtr ns, xmlNodePtr node); static void xmlC14NVisibleNsStackSave (xmlC14NVisibleNsStackPtr cur, xmlC14NVisibleNsStackPtr state); static void xmlC14NVisibleNsStackRestore (xmlC14NVisibleNsStackPtr cur, xmlC14NVisibleNsStackPtr state); static void xmlC14NVisibleNsStackShift (xmlC14NVisibleNsStackPtr cur); static int xmlC14NVisibleNsStackFind (xmlC14NVisibleNsStackPtr cur, xmlNsPtr ns); static int xmlExcC14NVisibleNsStackFind (xmlC14NVisibleNsStackPtr cur, xmlNsPtr ns, xmlC14NCtxPtr ctx); static int xmlC14NIsNodeInNodeset (xmlNodeSetPtr nodes, xmlNodePtr node, xmlNodePtr parent); static int xmlC14NProcessNode(xmlC14NCtxPtr ctx, xmlNodePtr cur); static int xmlC14NProcessNodeList(xmlC14NCtxPtr ctx, xmlNodePtr cur); typedef enum { XMLC14N_NORMALIZE_ATTR = 0, XMLC14N_NORMALIZE_COMMENT = 1, XMLC14N_NORMALIZE_PI = 2, XMLC14N_NORMALIZE_TEXT = 3 } xmlC14NNormalizationMode; static xmlChar *xmlC11NNormalizeString(const xmlChar * input, xmlC14NNormalizationMode mode); #define xmlC11NNormalizeAttr( a ) \ xmlC11NNormalizeString((a), XMLC14N_NORMALIZE_ATTR) #define xmlC11NNormalizeComment( a ) \ xmlC11NNormalizeString((a), XMLC14N_NORMALIZE_COMMENT) #define xmlC11NNormalizePI( a ) \ xmlC11NNormalizeString((a), XMLC14N_NORMALIZE_PI) #define xmlC11NNormalizeText( a ) \ xmlC11NNormalizeString((a), XMLC14N_NORMALIZE_TEXT) #define xmlC14NIsVisible( ctx, node, parent ) \ (((ctx)->is_visible_callback != NULL) ? \ (ctx)->is_visible_callback((ctx)->user_data, \ (xmlNodePtr)(node), (xmlNodePtr)(parent)) : 1) /************************************************************************ * * * Some factorized error routines * * * ************************************************************************/ /** * xmlC14NErrMemory: * @extra: extra informations * * Handle a redefinition of memory error */ static void xmlC14NErrMemory(const char *extra) { __xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_C14N, XML_ERR_NO_MEMORY, XML_ERR_ERROR, NULL, 0, extra, NULL, NULL, 0, 0, "Memory allocation failed : %s\n", extra); } /** * xmlC14NErrParam: * @extra: extra informations * * Handle a redefinition of param error */ static void xmlC14NErrParam(const char *extra) { __xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_C14N, XML_ERR_INTERNAL_ERROR, XML_ERR_ERROR, NULL, 0, extra, NULL, NULL, 0, 0, "Invalid parameter : %s\n", extra); } /** * xmlC14NErrInternal: * @extra: extra informations * * Handle a redefinition of internal error */ static void xmlC14NErrInternal(const char *extra) { __xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_C14N, XML_ERR_INTERNAL_ERROR, XML_ERR_ERROR, NULL, 0, extra, NULL, NULL, 0, 0, "Internal error : %s\n", extra); } /** * xmlC14NErrInvalidNode: * @extra: extra informations * * Handle a redefinition of invalid node error */ static void xmlC14NErrInvalidNode(const char *node_type, const char *extra) { __xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_C14N, XML_C14N_INVALID_NODE, XML_ERR_ERROR, NULL, 0, extra, NULL, NULL, 0, 0, "Node %s is invalid here : %s\n", node_type, extra); } /** * xmlC14NErrUnknownNode: * @extra: extra informations * * Handle a redefinition of unknown node error */ static void xmlC14NErrUnknownNode(int node_type, const char *extra) { __xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_C14N, XML_C14N_UNKNOW_NODE, XML_ERR_ERROR, NULL, 0, extra, NULL, NULL, 0, 0, "Unknown node type %d found : %s\n", node_type, extra); } /** * xmlC14NErrRelativeNamespace: * @extra: extra informations * * Handle a redefinition of relative namespace error */ static void xmlC14NErrRelativeNamespace(const char *ns_uri) { __xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_C14N, XML_C14N_RELATIVE_NAMESPACE, XML_ERR_ERROR, NULL, 0, NULL, NULL, NULL, 0, 0, "Relative namespace UR is invalid here : %s\n", ns_uri); } /** * xmlC14NErr: * @ctxt: a C14N evaluation context * @node: the context node * @error: the erorr code * @msg: the message * @extra: extra informations * * Handle a redefinition of attribute error */ static void xmlC14NErr(xmlC14NCtxPtr ctxt, xmlNodePtr node, int error, const char * msg) { if (ctxt != NULL) ctxt->error = error; __xmlRaiseError(NULL, NULL, NULL, ctxt, node, XML_FROM_C14N, error, XML_ERR_ERROR, NULL, 0, NULL, NULL, NULL, 0, 0, msg); } /************************************************************************ * * * The implementation internals * * * ************************************************************************/ #define XML_NAMESPACES_DEFAULT 16 static int xmlC14NIsNodeInNodeset(xmlNodeSetPtr nodes, xmlNodePtr node, xmlNodePtr parent) { if((nodes != NULL) && (node != NULL)) { if(node->type != XML_NAMESPACE_DECL) { return(xmlXPathNodeSetContains(nodes, node)); } else { xmlNs ns; memcpy(&ns, node, sizeof(ns)); /* this is a libxml hack! check xpath.c for details */ if((parent != NULL) && (parent->type == XML_ATTRIBUTE_NODE)) { ns.next = (xmlNsPtr)parent->parent; } else { ns.next = (xmlNsPtr)parent; } /* * If the input is an XPath node-set, then the node-set must explicitly * contain every node to be rendered to the canonical form. */ return(xmlXPathNodeSetContains(nodes, (xmlNodePtr)&ns)); } } return(1); } static xmlC14NVisibleNsStackPtr xmlC14NVisibleNsStackCreate(void) { xmlC14NVisibleNsStackPtr ret; ret = (xmlC14NVisibleNsStackPtr) xmlMalloc(sizeof(xmlC14NVisibleNsStack)); if (ret == NULL) { xmlC14NErrMemory("creating namespaces stack"); return(NULL); } memset(ret, 0 , (size_t) sizeof(xmlC14NVisibleNsStack)); return(ret); } static void xmlC14NVisibleNsStackDestroy(xmlC14NVisibleNsStackPtr cur) { if(cur == NULL) { xmlC14NErrParam("destroying namespaces stack"); return; } if(cur->nsTab != NULL) { memset(cur->nsTab, 0, cur->nsMax * sizeof(xmlNsPtr)); xmlFree(cur->nsTab); } if(cur->nodeTab != NULL) { memset(cur->nodeTab, 0, cur->nsMax * sizeof(xmlNodePtr)); xmlFree(cur->nodeTab); } memset(cur, 0, sizeof(xmlC14NVisibleNsStack)); xmlFree(cur); } static void xmlC14NVisibleNsStackAdd(xmlC14NVisibleNsStackPtr cur, xmlNsPtr ns, xmlNodePtr node) { if((cur == NULL) || ((cur->nsTab == NULL) && (cur->nodeTab != NULL)) || ((cur->nsTab != NULL) && (cur->nodeTab == NULL))) { xmlC14NErrParam("adding namespace to stack"); return; } if ((cur->nsTab == NULL) && (cur->nodeTab == NULL)) { cur->nsTab = (xmlNsPtr*) xmlMalloc(XML_NAMESPACES_DEFAULT * sizeof(xmlNsPtr)); cur->nodeTab = (xmlNodePtr*) xmlMalloc(XML_NAMESPACES_DEFAULT * sizeof(xmlNodePtr)); if ((cur->nsTab == NULL) || (cur->nodeTab == NULL)) { xmlC14NErrMemory("adding node to stack"); return; } memset(cur->nsTab, 0 , XML_NAMESPACES_DEFAULT * sizeof(xmlNsPtr)); memset(cur->nodeTab, 0 , XML_NAMESPACES_DEFAULT * sizeof(xmlNodePtr)); cur->nsMax = XML_NAMESPACES_DEFAULT; } else if(cur->nsMax == cur->nsCurEnd) { void *tmp; int tmpSize; tmpSize = 2 * cur->nsMax; tmp = xmlRealloc(cur->nsTab, tmpSize * sizeof(xmlNsPtr)); if (tmp == NULL) { xmlC14NErrMemory("adding node to stack"); return; } cur->nsTab = (xmlNsPtr*)tmp; tmp = xmlRealloc(cur->nodeTab, tmpSize * sizeof(xmlNodePtr)); if (tmp == NULL) { xmlC14NErrMemory("adding node to stack"); return; } cur->nodeTab = (xmlNodePtr*)tmp; cur->nsMax = tmpSize; } cur->nsTab[cur->nsCurEnd] = ns; cur->nodeTab[cur->nsCurEnd] = node; ++cur->nsCurEnd; } static void xmlC14NVisibleNsStackSave(xmlC14NVisibleNsStackPtr cur, xmlC14NVisibleNsStackPtr state) { if((cur == NULL) || (state == NULL)) { xmlC14NErrParam("saving namespaces stack"); return; } state->nsCurEnd = cur->nsCurEnd; state->nsPrevStart = cur->nsPrevStart; state->nsPrevEnd = cur->nsPrevEnd; } static void xmlC14NVisibleNsStackRestore(xmlC14NVisibleNsStackPtr cur, xmlC14NVisibleNsStackPtr state) { if((cur == NULL) || (state == NULL)) { xmlC14NErrParam("restoring namespaces stack"); return; } cur->nsCurEnd = state->nsCurEnd; cur->nsPrevStart = state->nsPrevStart; cur->nsPrevEnd = state->nsPrevEnd; } static void xmlC14NVisibleNsStackShift(xmlC14NVisibleNsStackPtr cur) { if(cur == NULL) { xmlC14NErrParam("shifting namespaces stack"); return; } cur->nsPrevStart = cur->nsPrevEnd; cur->nsPrevEnd = cur->nsCurEnd; } static int xmlC14NStrEqual(const xmlChar *str1, const xmlChar *str2) { if (str1 == str2) return(1); if (str1 == NULL) return((*str2) == '\0'); if (str2 == NULL) return((*str1) == '\0'); do { if (*str1++ != *str2) return(0); } while (*str2++); return(1); } /** * xmlC14NVisibleNsStackFind: * @ctx: the C14N context * @ns: the namespace to check * * Checks whether the given namespace was already rendered or not * * Returns 1 if we already wrote this namespace or 0 otherwise */ static int xmlC14NVisibleNsStackFind(xmlC14NVisibleNsStackPtr cur, xmlNsPtr ns) { int i; const xmlChar *prefix; const xmlChar *href; int has_empty_ns; if(cur == NULL) { xmlC14NErrParam("searching namespaces stack (c14n)"); return (0); } /* * if the default namespace xmlns="" is not defined yet then * we do not want to print it out */ prefix = ((ns == NULL) || (ns->prefix == NULL)) ? BAD_CAST "" : ns->prefix; href = ((ns == NULL) || (ns->href == NULL)) ? BAD_CAST "" : ns->href; has_empty_ns = (xmlC14NStrEqual(prefix, NULL) && xmlC14NStrEqual(href, NULL)); if (cur->nsTab != NULL) { int start = (has_empty_ns) ? 0 : cur->nsPrevStart; for (i = cur->nsCurEnd - 1; i >= start; --i) { xmlNsPtr ns1 = cur->nsTab[i]; if(xmlC14NStrEqual(prefix, (ns1 != NULL) ? ns1->prefix : NULL)) { return(xmlC14NStrEqual(href, (ns1 != NULL) ? ns1->href : NULL)); } } } return(has_empty_ns); } static int xmlExcC14NVisibleNsStackFind(xmlC14NVisibleNsStackPtr cur, xmlNsPtr ns, xmlC14NCtxPtr ctx) { int i; const xmlChar *prefix; const xmlChar *href; int has_empty_ns; if(cur == NULL) { xmlC14NErrParam("searching namespaces stack (exc c14n)"); return (0); } /* * if the default namespace xmlns="" is not defined yet then * we do not want to print it out */ prefix = ((ns == NULL) || (ns->prefix == NULL)) ? BAD_CAST "" : ns->prefix; href = ((ns == NULL) || (ns->href == NULL)) ? BAD_CAST "" : ns->href; has_empty_ns = (xmlC14NStrEqual(prefix, NULL) && xmlC14NStrEqual(href, NULL)); if (cur->nsTab != NULL) { int start = 0; for (i = cur->nsCurEnd - 1; i >= start; --i) { xmlNsPtr ns1 = cur->nsTab[i]; if(xmlC14NStrEqual(prefix, (ns1 != NULL) ? ns1->prefix : NULL)) { if(xmlC14NStrEqual(href, (ns1 != NULL) ? ns1->href : NULL)) { return(xmlC14NIsVisible(ctx, ns1, cur->nodeTab[i])); } else { return(0); } } } } return(has_empty_ns); } /** * xmlC14NIsXmlNs: * @ns: the namespace to check * * Checks whether the given namespace is a default "xml:" namespace * with href="http://www.w3.org/XML/1998/namespace" * * Returns 1 if the node is default or 0 otherwise */ /* todo: make it a define? */ static int xmlC14NIsXmlNs(xmlNsPtr ns) { return ((ns != NULL) && (xmlStrEqual(ns->prefix, BAD_CAST "xml")) && (xmlStrEqual(ns->href, BAD_CAST "http://www.w3.org/XML/1998/namespace"))); } /** * xmlC14NNsCompare: * @ns1: the pointer to first namespace * @ns2: the pointer to second namespace * * Compares the namespaces by names (prefixes). * * Returns -1 if ns1 < ns2, 0 if ns1 == ns2 or 1 if ns1 > ns2. */ static int xmlC14NNsCompare(xmlNsPtr ns1, xmlNsPtr ns2) { if (ns1 == ns2) return (0); if (ns1 == NULL) return (-1); if (ns2 == NULL) return (1); return (xmlStrcmp(ns1->prefix, ns2->prefix)); } /** * xmlC14NPrintNamespaces: * @ns: the pointer to namespace * @ctx: the C14N context * * Prints the given namespace to the output buffer from C14N context. * * Returns 1 on success or 0 on fail. */ static int xmlC14NPrintNamespaces(const xmlNsPtr ns, xmlC14NCtxPtr ctx) { if ((ns == NULL) || (ctx == NULL)) { xmlC14NErrParam("writing namespaces"); return 0; } if (ns->prefix != NULL) { xmlOutputBufferWriteString(ctx->buf, " xmlns:"); xmlOutputBufferWriteString(ctx->buf, (const char *) ns->prefix); xmlOutputBufferWriteString(ctx->buf, "=\""); } else { xmlOutputBufferWriteString(ctx->buf, " xmlns=\""); } if(ns->href != NULL) { xmlOutputBufferWriteString(ctx->buf, (const char *) ns->href); } xmlOutputBufferWriteString(ctx->buf, "\""); return (1); } /** * xmlC14NProcessNamespacesAxis: * @ctx: the C14N context * @node: the current node * * Prints out canonical namespace axis of the current node to the * buffer from C14N context as follows * * Canonical XML v 1.0 (http://www.w3.org/TR/xml-c14n) * * Namespace Axis * Consider a list L containing only namespace nodes in the * axis and in the node-set in lexicographic order (ascending). To begin * processing L, if the first node is not the default namespace node (a node * with no namespace URI and no local name), then generate a space followed * by xmlns="" if and only if the following conditions are met: * - the element E that owns the axis is in the node-set * - The nearest ancestor element of E in the node-set has a default * namespace node in the node-set (default namespace nodes always * have non-empty values in XPath) * The latter condition eliminates unnecessary occurrences of xmlns="" in * the canonical form since an element only receives an xmlns="" if its * default namespace is empty and if it has an immediate parent in the * canonical form that has a non-empty default namespace. To finish * processing L, simply process every namespace node in L, except omit * namespace node with local name xml, which defines the xml prefix, * if its string value is http://www.w3.org/XML/1998/namespace. * * Exclusive XML Canonicalization v 1.0 (http://www.w3.org/TR/xml-exc-c14n) * Canonical XML applied to a document subset requires the search of the * ancestor nodes of each orphan element node for attributes in the xml * namespace, such as xml:lang and xml:space. These are copied into the * element node except if a declaration of the same attribute is already * in the attribute axis of the element (whether or not it is included in * the document subset). This search and copying are omitted from the * Exclusive XML Canonicalization method. * * Returns 0 on success or -1 on fail. */ static int xmlC14NProcessNamespacesAxis(xmlC14NCtxPtr ctx, xmlNodePtr cur, int visible) { xmlNodePtr n; xmlNsPtr ns, tmp; xmlListPtr list; int already_rendered; int has_empty_ns = 0; if ((ctx == NULL) || (cur == NULL) || (cur->type != XML_ELEMENT_NODE)) { xmlC14NErrParam("processing namespaces axis (c14n)"); return (-1); } /* * Create a sorted list to store element namespaces */ list = xmlListCreate(NULL, (xmlListDataCompare) xmlC14NNsCompare); if (list == NULL) { xmlC14NErrInternal("creating namespaces list (c14n)"); return (-1); } /* check all namespaces */ for(n = cur; n != NULL; n = n->parent) { for(ns = n->nsDef; ns != NULL; ns = ns->next) { tmp = xmlSearchNs(cur->doc, cur, ns->prefix); if((tmp == ns) && !xmlC14NIsXmlNs(ns) && xmlC14NIsVisible(ctx, ns, cur)) { already_rendered = xmlC14NVisibleNsStackFind(ctx->ns_rendered, ns); if(visible) { xmlC14NVisibleNsStackAdd(ctx->ns_rendered, ns, cur); } if(!already_rendered) { xmlListInsert(list, ns); } if(xmlStrlen(ns->prefix) == 0) { has_empty_ns = 1; } } } } /** * if the first node is not the default namespace node (a node with no * namespace URI and no local name), then generate a space followed by * xmlns="" if and only if the following conditions are met: * - the element E that owns the axis is in the node-set * - the nearest ancestor element of E in the node-set has a default * namespace node in the node-set (default namespace nodes always * have non-empty values in XPath) */ if(visible && !has_empty_ns) { static xmlNs ns_default; memset(&ns_default, 0, sizeof(ns_default)); if(!xmlC14NVisibleNsStackFind(ctx->ns_rendered, &ns_default)) { xmlC14NPrintNamespaces(&ns_default, ctx); } } /* * print out all elements from list */ xmlListWalk(list, (xmlListWalker) xmlC14NPrintNamespaces, (const void *) ctx); /* * Cleanup */ xmlListDelete(list); return (0); } /** * xmlExcC14NProcessNamespacesAxis: * @ctx: the C14N context * @node: the current node * * Prints out exclusive canonical namespace axis of the current node to the * buffer from C14N context as follows * * Exclusive XML Canonicalization * http://www.w3.org/TR/xml-exc-c14n * * If the element node is in the XPath subset then output the node in * accordance with Canonical XML except for namespace nodes which are * rendered as follows: * * 1. Render each namespace node iff: * * it is visibly utilized by the immediate parent element or one of * its attributes, or is present in InclusiveNamespaces PrefixList, and * * its prefix and value do not appear in ns_rendered. ns_rendered is * obtained by popping the state stack in order to obtain a list of * prefixes and their values which have already been rendered by * an output ancestor of the namespace node's parent element. * 2. Append the rendered namespace node to the list ns_rendered of namespace * nodes rendered by output ancestors. Push ns_rendered on state stack and * recurse. * 3. After the recursion returns, pop thestate stack. * * * Returns 0 on success or -1 on fail. */ static int xmlExcC14NProcessNamespacesAxis(xmlC14NCtxPtr ctx, xmlNodePtr cur, int visible) { xmlNsPtr ns; xmlListPtr list; xmlAttrPtr attr; int already_rendered; int has_empty_ns = 0; int has_visibly_utilized_empty_ns = 0; int has_empty_ns_in_inclusive_list = 0; if ((ctx == NULL) || (cur == NULL) || (cur->type != XML_ELEMENT_NODE)) { xmlC14NErrParam("processing namespaces axis (exc c14n)"); return (-1); } if(!ctx->exclusive) { xmlC14NErrParam("processing namespaces axis (exc c14n)"); return (-1); } /* * Create a sorted list to store element namespaces */ list = xmlListCreate(NULL, (xmlListDataCompare) xmlC14NNsCompare); if (list == NULL) { xmlC14NErrInternal("creating namespaces list (exc c14n)"); return (-1); } /* * process inclusive namespaces: * All namespace nodes appearing on inclusive ns list are * handled as provided in Canonical XML */ if(ctx->inclusive_ns_prefixes != NULL) { xmlChar *prefix; int i; for (i = 0; ctx->inclusive_ns_prefixes[i] != NULL; ++i) { prefix = ctx->inclusive_ns_prefixes[i]; /* * Special values for namespace with empty prefix */ if (xmlStrEqual(prefix, BAD_CAST "#default") || xmlStrEqual(prefix, BAD_CAST "")) { prefix = NULL; has_empty_ns_in_inclusive_list = 1; } ns = xmlSearchNs(cur->doc, cur, prefix); if((ns != NULL) && !xmlC14NIsXmlNs(ns) && xmlC14NIsVisible(ctx, ns, cur)) { already_rendered = xmlC14NVisibleNsStackFind(ctx->ns_rendered, ns); if(visible) { xmlC14NVisibleNsStackAdd(ctx->ns_rendered, ns, cur); } if(!already_rendered) { xmlListInsert(list, ns); } if(xmlStrlen(ns->prefix) == 0) { has_empty_ns = 1; } } } } /* add node namespace */ if(cur->ns != NULL) { ns = cur->ns; } else { ns = xmlSearchNs(cur->doc, cur, NULL); has_visibly_utilized_empty_ns = 1; } if((ns != NULL) && !xmlC14NIsXmlNs(ns)) { if(visible && xmlC14NIsVisible(ctx, ns, cur)) { if(!xmlExcC14NVisibleNsStackFind(ctx->ns_rendered, ns, ctx)) { xmlListInsert(list, ns); } } if(visible) { xmlC14NVisibleNsStackAdd(ctx->ns_rendered, ns, cur); } if(xmlStrlen(ns->prefix) == 0) { has_empty_ns = 1; } } /* add attributes */ for(attr = cur->properties; attr != NULL; attr = attr->next) { /* * we need to check that attribute is visible and has non * default namespace (XML Namespaces: "default namespaces * do not apply directly to attributes") */ if((attr->ns != NULL) && !xmlC14NIsXmlNs(attr->ns) && xmlC14NIsVisible(ctx, attr, cur)) { already_rendered = xmlExcC14NVisibleNsStackFind(ctx->ns_rendered, attr->ns, ctx); xmlC14NVisibleNsStackAdd(ctx->ns_rendered, attr->ns, cur); if(!already_rendered && visible) { xmlListInsert(list, attr->ns); } if(xmlStrlen(attr->ns->prefix) == 0) { has_empty_ns = 1; } } else if((attr->ns != NULL) && (xmlStrlen(attr->ns->prefix) == 0) && (xmlStrlen(attr->ns->href) == 0)) { has_visibly_utilized_empty_ns = 1; } } /* * Process xmlns="" */ if(visible && has_visibly_utilized_empty_ns && !has_empty_ns && !has_empty_ns_in_inclusive_list) { static xmlNs ns_default; memset(&ns_default, 0, sizeof(ns_default)); already_rendered = xmlExcC14NVisibleNsStackFind(ctx->ns_rendered, &ns_default, ctx); if(!already_rendered) { xmlC14NPrintNamespaces(&ns_default, ctx); } } else if(visible && !has_empty_ns && has_empty_ns_in_inclusive_list) { static xmlNs ns_default; memset(&ns_default, 0, sizeof(ns_default)); if(!xmlC14NVisibleNsStackFind(ctx->ns_rendered, &ns_default)) { xmlC14NPrintNamespaces(&ns_default, ctx); } } /* * print out all elements from list */ xmlListWalk(list, (xmlListWalker) xmlC14NPrintNamespaces, (const void *) ctx); /* * Cleanup */ xmlListDelete(list); return (0); } /** * xmlC14NAttrsCompare: * @attr1: the pointer tls o first attr * @attr2: the pointer to second attr * * Prints the given attribute to the output buffer from C14N context. * * Returns -1 if attr1 < attr2, 0 if attr1 == attr2 or 1 if attr1 > attr2. */ static int xmlC14NAttrsCompare(xmlAttrPtr attr1, xmlAttrPtr attr2) { int ret = 0; /* * Simple cases */ if (attr1 == attr2) return (0); if (attr1 == NULL) return (-1); if (attr2 == NULL) return (1); if (attr1->ns == attr2->ns) { return (xmlStrcmp(attr1->name, attr2->name)); } /* * Attributes in the default namespace are first * because the default namespace is not applied to * unqualified attributes */ if (attr1->ns == NULL) return (-1); if (attr2->ns == NULL) return (1); if (attr1->ns->prefix == NULL) return (-1); if (attr2->ns->prefix == NULL) return (1); ret = xmlStrcmp(attr1->ns->href, attr2->ns->href); if (ret == 0) { ret = xmlStrcmp(attr1->name, attr2->name); } return (ret); } /** * xmlC14NPrintAttrs: * @attr: the pointer to attr * @ctx: the C14N context * * Prints out canonical attribute urrent node to the * buffer from C14N context as follows * * Canonical XML v 1.0 (http://www.w3.org/TR/xml-c14n) * * Returns 1 on success or 0 on fail. */ static int xmlC14NPrintAttrs(const xmlAttrPtr attr, xmlC14NCtxPtr ctx) { xmlChar *value; xmlChar *buffer; if ((attr == NULL) || (ctx == NULL)) { xmlC14NErrParam("writing attributes"); return (0); } xmlOutputBufferWriteString(ctx->buf, " "); if (attr->ns != NULL && xmlStrlen(attr->ns->prefix) > 0) { xmlOutputBufferWriteString(ctx->buf, (const char *) attr->ns->prefix); xmlOutputBufferWriteString(ctx->buf, ":"); } xmlOutputBufferWriteString(ctx->buf, (const char *) attr->name); xmlOutputBufferWriteString(ctx->buf, "=\""); value = xmlNodeListGetString(attr->doc, attr->children, 1); /* todo: should we log an error if value==NULL ? */ if (value != NULL) { buffer = xmlC11NNormalizeAttr(value); xmlFree(value); if (buffer != NULL) { xmlOutputBufferWriteString(ctx->buf, (const char *) buffer); xmlFree(buffer); } else { xmlC14NErrInternal("normalizing attributes axis"); return (0); } } xmlOutputBufferWriteString(ctx->buf, "\""); return (1); } /** * xmlC14NProcessAttrsAxis: * @ctx: the C14N context * @cur: the current node * @parent_visible: the visibility of parent node * * Prints out canonical attribute axis of the current node to the * buffer from C14N context as follows * * Canonical XML v 1.0 (http://www.w3.org/TR/xml-c14n) * * Attribute Axis * In lexicographic order (ascending), process each node that * is in the element's attribute axis and in the node-set. * * The processing of an element node E MUST be modified slightly * when an XPath node-set is given as input and the element's * parent is omitted from the node-set. * * * Exclusive XML Canonicalization v 1.0 (http://www.w3.org/TR/xml-exc-c14n) * * Canonical XML applied to a document subset requires the search of the * ancestor nodes of each orphan element node for attributes in the xml * namespace, such as xml:lang and xml:space. These are copied into the * element node except if a declaration of the same attribute is already * in the attribute axis of the element (whether or not it is included in * the document subset). This search and copying are omitted from the * Exclusive XML Canonicalization method. * * Returns 0 on success or -1 on fail. */ static int xmlC14NProcessAttrsAxis(xmlC14NCtxPtr ctx, xmlNodePtr cur, int parent_visible) { xmlAttrPtr attr; xmlListPtr list; if ((ctx == NULL) || (cur == NULL) || (cur->type != XML_ELEMENT_NODE)) { xmlC14NErrParam("processing attributes axis"); return (-1); } /* * Create a sorted list to store element attributes */ list = xmlListCreate(NULL, (xmlListDataCompare) xmlC14NAttrsCompare); if (list == NULL) { xmlC14NErrInternal("creating attributes list"); return (-1); } /* * Add all visible attributes from current node. */ attr = cur->properties; while (attr != NULL) { /* check that attribute is visible */ if (xmlC14NIsVisible(ctx, attr, cur)) { xmlListInsert(list, attr); } attr = attr->next; } /* * include attributes in "xml" namespace defined in ancestors * (only for non-exclusive XML Canonicalization) */ if (parent_visible && (!ctx->exclusive) && (cur->parent != NULL) && (!xmlC14NIsVisible(ctx, cur->parent, cur->parent->parent))) { /* * If XPath node-set is not specified then the parent is always * visible! */ cur = cur->parent; while (cur != NULL) { attr = cur->properties; while (attr != NULL) { if ((attr->ns != NULL) && (xmlStrEqual(attr->ns->prefix, BAD_CAST "xml"))) { if (xmlListSearch(list, attr) == NULL) { xmlListInsert(list, attr); } } attr = attr->next; } cur = cur->parent; } } /* * print out all elements from list */ xmlListWalk(list, (xmlListWalker) xmlC14NPrintAttrs, (const void *) ctx); /* * Cleanup */ xmlListDelete(list); return (0); } /** * xmlC14NCheckForRelativeNamespaces: * @ctx: the C14N context * @cur: the current element node * * Checks that current element node has no relative namespaces defined * * Returns 0 if the node has no relative namespaces or -1 otherwise. */ static int xmlC14NCheckForRelativeNamespaces(xmlC14NCtxPtr ctx, xmlNodePtr cur) { xmlNsPtr ns; if ((ctx == NULL) || (cur == NULL) || (cur->type != XML_ELEMENT_NODE)) { xmlC14NErrParam("checking for relative namespaces"); return (-1); } ns = cur->nsDef; while (ns != NULL) { if (xmlStrlen(ns->href) > 0) { xmlURIPtr uri; uri = xmlParseURI((const char *) ns->href); if (uri == NULL) { xmlC14NErrInternal("parsing namespace uri"); return (-1); } if (xmlStrlen((const xmlChar *) uri->scheme) == 0) { xmlC14NErrRelativeNamespace(uri->scheme); xmlFreeURI(uri); return (-1); } if ((xmlStrcasecmp((const xmlChar *) uri->scheme, BAD_CAST "urn") != 0) && (xmlStrcasecmp((const xmlChar *) uri->scheme, BAD_CAST "dav") !=0) && (xmlStrlen((const xmlChar *) uri->server) == 0)) { xmlC14NErrRelativeNamespace(uri->scheme); xmlFreeURI(uri); return (-1); } xmlFreeURI(uri); } ns = ns->next; } return (0); } /** * xmlC14NProcessElementNode: * @ctx: the pointer to C14N context object * @cur: the node to process * * Canonical XML v 1.0 (http://www.w3.org/TR/xml-c14n) * * Element Nodes * If the element is not in the node-set, then the result is obtained * by processing the namespace axis, then the attribute axis, then * processing the child nodes of the element that are in the node-set * (in document order). If the element is in the node-set, then the result * is an open angle bracket (<), the element QName, the result of * processing the namespace axis, the result of processing the attribute * axis, a close angle bracket (>), the result of processing the child * nodes of the element that are in the node-set (in document order), an * open angle bracket, a forward slash (/), the element QName, and a close * angle bracket. * * Returns non-negative value on success or negative value on fail */ static int xmlC14NProcessElementNode(xmlC14NCtxPtr ctx, xmlNodePtr cur, int visible) { int ret; xmlC14NVisibleNsStack state; int parent_is_doc = 0; if ((ctx == NULL) || (cur == NULL) || (cur->type != XML_ELEMENT_NODE)) { xmlC14NErrParam("processing element node"); return (-1); } /* * Check relative relative namespaces: * implementations of XML canonicalization MUST report an operation * failure on documents containing relative namespace URIs. */ if (xmlC14NCheckForRelativeNamespaces(ctx, cur) < 0) { xmlC14NErrInternal("checking for relative namespaces"); return (-1); } /* * Save ns_rendered stack position */ memset(&state, 0, sizeof(state)); xmlC14NVisibleNsStackSave(ctx->ns_rendered, &state); if (visible) { if (ctx->parent_is_doc) { /* save this flag into the stack */ parent_is_doc = ctx->parent_is_doc; ctx->parent_is_doc = 0; ctx->pos = XMLC14N_INSIDE_DOCUMENT_ELEMENT; } xmlOutputBufferWriteString(ctx->buf, "<"); if ((cur->ns != NULL) && (xmlStrlen(cur->ns->prefix) > 0)) { xmlOutputBufferWriteString(ctx->buf, (const char *) cur->ns->prefix); xmlOutputBufferWriteString(ctx->buf, ":"); } xmlOutputBufferWriteString(ctx->buf, (const char *) cur->name); } if (!ctx->exclusive) { ret = xmlC14NProcessNamespacesAxis(ctx, cur, visible); } else { ret = xmlExcC14NProcessNamespacesAxis(ctx, cur, visible); } if (ret < 0) { xmlC14NErrInternal("processing namespaces axis"); return (-1); } /* todo: shouldn't this go to "visible only"? */ if(visible) { xmlC14NVisibleNsStackShift(ctx->ns_rendered); } ret = xmlC14NProcessAttrsAxis(ctx, cur, visible); if (ret < 0) { xmlC14NErrInternal("processing attributes axis"); return (-1); } if (visible) { xmlOutputBufferWriteString(ctx->buf, ">"); } if (cur->children != NULL) { ret = xmlC14NProcessNodeList(ctx, cur->children); if (ret < 0) { xmlC14NErrInternal("processing childrens list"); return (-1); } } if (visible) { xmlOutputBufferWriteString(ctx->buf, "ns != NULL) && (xmlStrlen(cur->ns->prefix) > 0)) { xmlOutputBufferWriteString(ctx->buf, (const char *) cur->ns->prefix); xmlOutputBufferWriteString(ctx->buf, ":"); } xmlOutputBufferWriteString(ctx->buf, (const char *) cur->name); xmlOutputBufferWriteString(ctx->buf, ">"); if (parent_is_doc) { /* restore this flag from the stack for next node */ ctx->parent_is_doc = parent_is_doc; ctx->pos = XMLC14N_AFTER_DOCUMENT_ELEMENT; } } /* * Restore ns_rendered stack position */ xmlC14NVisibleNsStackRestore(ctx->ns_rendered, &state); return (0); } /** * xmlC14NProcessNode: * @ctx: the pointer to C14N context object * @cur: the node to process * * Processes the given node * * Returns non-negative value on success or negative value on fail */ static int xmlC14NProcessNode(xmlC14NCtxPtr ctx, xmlNodePtr cur) { int ret = 0; int visible; if ((ctx == NULL) || (cur == NULL)) { xmlC14NErrParam("processing node"); return (-1); } visible = xmlC14NIsVisible(ctx, cur, cur->parent); switch (cur->type) { case XML_ELEMENT_NODE: ret = xmlC14NProcessElementNode(ctx, cur, visible); break; case XML_CDATA_SECTION_NODE: case XML_TEXT_NODE: /* * Text Nodes * the string value, except all ampersands are replaced * by &, all open angle brackets (<) are replaced by <, all closing * angle brackets (>) are replaced by >, and all #xD characters are * replaced by . */ /* cdata sections are processed as text nodes */ /* todo: verify that cdata sections are included in XPath nodes set */ if ((visible) && (cur->content != NULL)) { xmlChar *buffer; buffer = xmlC11NNormalizeText(cur->content); if (buffer != NULL) { xmlOutputBufferWriteString(ctx->buf, (const char *) buffer); xmlFree(buffer); } else { xmlC14NErrInternal("normalizing text node"); return (-1); } } break; case XML_PI_NODE: /* * Processing Instruction (PI) Nodes- * The opening PI symbol (). If the string value is empty, * then the leading space is not added. Also, a trailing #xA is * rendered after the closing PI symbol for PI children of the * root node with a lesser document order than the document * element, and a leading #xA is rendered before the opening PI * symbol of PI children of the root node with a greater document * order than the document element. */ if (visible) { if (ctx->pos == XMLC14N_AFTER_DOCUMENT_ELEMENT) { xmlOutputBufferWriteString(ctx->buf, "\x0Abuf, "buf, (const char *) cur->name); if ((cur->content != NULL) && (*(cur->content) != '\0')) { xmlChar *buffer; xmlOutputBufferWriteString(ctx->buf, " "); /* todo: do we need to normalize pi? */ buffer = xmlC11NNormalizePI(cur->content); if (buffer != NULL) { xmlOutputBufferWriteString(ctx->buf, (const char *) buffer); xmlFree(buffer); } else { xmlC14NErrInternal("normalizing pi node"); return (-1); } } if (ctx->pos == XMLC14N_BEFORE_DOCUMENT_ELEMENT) { xmlOutputBufferWriteString(ctx->buf, "?>\x0A"); } else { xmlOutputBufferWriteString(ctx->buf, "?>"); } } break; case XML_COMMENT_NODE: /* * Comment Nodes * Nothing if generating canonical XML without comments. For * canonical XML with comments, generate the opening comment * symbol (). Also, a trailing #xA is rendered * after the closing comment symbol for comment children of the * root node with a lesser document order than the document * element, and a leading #xA is rendered before the opening * comment symbol of comment children of the root node with a * greater document order than the document element. (Comment * children of the root node represent comments outside of the * top-level document element and outside of the document type * declaration). */ if (visible && ctx->with_comments) { if (ctx->pos == XMLC14N_AFTER_DOCUMENT_ELEMENT) { xmlOutputBufferWriteString(ctx->buf, "\x0A\x0A"); } else { xmlOutputBufferWriteString(ctx->buf, "-->"); } } break; case XML_DOCUMENT_NODE: case XML_DOCUMENT_FRAG_NODE: /* should be processed as document? */ #ifdef LIBXML_DOCB_ENABLED case XML_DOCB_DOCUMENT_NODE: /* should be processed as document? */ #endif #ifdef LIBXML_HTML_ENABLED case XML_HTML_DOCUMENT_NODE: /* should be processed as document? */ #endif if (cur->children != NULL) { ctx->pos = XMLC14N_BEFORE_DOCUMENT_ELEMENT; ctx->parent_is_doc = 1; ret = xmlC14NProcessNodeList(ctx, cur->children); } break; case XML_ATTRIBUTE_NODE: xmlC14NErrInvalidNode("XML_ATTRIBUTE_NODE", "processing node"); return (-1); case XML_NAMESPACE_DECL: xmlC14NErrInvalidNode("XML_NAMESPACE_DECL", "processing node"); return (-1); case XML_ENTITY_REF_NODE: xmlC14NErrInvalidNode("XML_ENTITY_REF_NODE", "processing node"); return (-1); case XML_ENTITY_NODE: xmlC14NErrInvalidNode("XML_ENTITY_NODE", "processing node"); return (-1); case XML_DOCUMENT_TYPE_NODE: case XML_NOTATION_NODE: case XML_DTD_NODE: case XML_ELEMENT_DECL: case XML_ATTRIBUTE_DECL: case XML_ENTITY_DECL: #ifdef LIBXML_XINCLUDE_ENABLED case XML_XINCLUDE_START: case XML_XINCLUDE_END: #endif /* * should be ignored according to "W3C Canonical XML" */ break; default: xmlC14NErrUnknownNode(cur->type, "processing node"); return (-1); } return (ret); } /** * xmlC14NProcessNodeList: * @ctx: the pointer to C14N context object * @cur: the node to start from * * Processes all nodes in the row starting from cur. * * Returns non-negative value on success or negative value on fail */ static int xmlC14NProcessNodeList(xmlC14NCtxPtr ctx, xmlNodePtr cur) { int ret; if (ctx == NULL) { xmlC14NErrParam("processing node list"); return (-1); } for (ret = 0; cur != NULL && ret >= 0; cur = cur->next) { ret = xmlC14NProcessNode(ctx, cur); } return (ret); } /** * xmlC14NFreeCtx: * @ctx: the pointer to C14N context object * * Cleanups the C14N context object. */ static void xmlC14NFreeCtx(xmlC14NCtxPtr ctx) { if (ctx == NULL) { xmlC14NErrParam("freeing context"); return; } if (ctx->ns_rendered != NULL) { xmlC14NVisibleNsStackDestroy(ctx->ns_rendered); } xmlFree(ctx); } /** * xmlC14NNewCtx: * @doc: the XML document for canonization * @is_visible_callback:the function to use to determine is node visible * or not * @user_data: the first parameter for @is_visible_callback function * (in most cases, it is nodes set) * @inclusive_ns_prefixe the list of inclusive namespace prefixes * ended with a NULL or NULL if there is no * inclusive namespaces (only for exclusive * canonicalization) * @with_comments: include comments in the result (!=0) or not (==0) * @buf: the output buffer to store canonical XML; this * buffer MUST have encoder==NULL because C14N requires * UTF-8 output * * Creates new C14N context object to store C14N parameters. * * Returns pointer to newly created object (success) or NULL (fail) */ static xmlC14NCtxPtr xmlC14NNewCtx(xmlDocPtr doc, xmlC14NIsVisibleCallback is_visible_callback, void* user_data, int exclusive, xmlChar ** inclusive_ns_prefixes, int with_comments, xmlOutputBufferPtr buf) { xmlC14NCtxPtr ctx = NULL; if ((doc == NULL) || (buf == NULL)) { xmlC14NErrParam("creating new context"); return (NULL); } /* * Validate the encoding output buffer encoding */ if (buf->encoder != NULL) { xmlC14NErr(ctx, (xmlNodePtr) doc, XML_C14N_REQUIRES_UTF8, "xmlC14NNewCtx: output buffer encoder != NULL but C14N requires UTF8 output\n"); return (NULL); } /* * Validate the XML document encoding value, if provided. */ if (doc->charset != XML_CHAR_ENCODING_UTF8) { xmlC14NErr(ctx, (xmlNodePtr) doc, XML_C14N_REQUIRES_UTF8, "xmlC14NNewCtx: source document not in UTF8\n"); return (NULL); } /* * Allocate a new xmlC14NCtxPtr and fill the fields. */ ctx = (xmlC14NCtxPtr) xmlMalloc(sizeof(xmlC14NCtx)); if (ctx == NULL) { xmlC14NErrMemory("creating context"); return (NULL); } memset(ctx, 0, sizeof(xmlC14NCtx)); /* * initialize C14N context */ ctx->doc = doc; ctx->with_comments = with_comments; ctx->is_visible_callback = is_visible_callback; ctx->user_data = user_data; ctx->buf = buf; ctx->parent_is_doc = 1; ctx->pos = XMLC14N_BEFORE_DOCUMENT_ELEMENT; ctx->ns_rendered = xmlC14NVisibleNsStackCreate(); if(ctx->ns_rendered == NULL) { xmlC14NErr(ctx, (xmlNodePtr) doc, XML_C14N_CREATE_STACK, "xmlC14NNewCtx: xmlC14NVisibleNsStackCreate failed\n"); xmlC14NFreeCtx(ctx); return (NULL); } /* * Set "exclusive" flag, create a nodes set for namespaces * stack and remember list of incluseve prefixes */ if (exclusive) { ctx->exclusive = 1; ctx->inclusive_ns_prefixes = inclusive_ns_prefixes; } return (ctx); } /** * xmlC14NExecute: * @doc: the XML document for canonization * @is_visible_callback:the function to use to determine is node visible * or not * @user_data: the first parameter for @is_visible_callback function * (in most cases, it is nodes set) * @exclusive: the exclusive flag (0 - non-exclusive canonicalization; * otherwise - exclusive canonicalization) * @inclusive_ns_prefixes: the list of inclusive namespace prefixes * ended with a NULL or NULL if there is no * inclusive namespaces (only for exclusive * canonicalization, ignored otherwise) * @with_comments: include comments in the result (!=0) or not (==0) * @buf: the output buffer to store canonical XML; this * buffer MUST have encoder==NULL because C14N requires * UTF-8 output * * Dumps the canonized image of given XML document into the provided buffer. * For details see "Canonical XML" (http://www.w3.org/TR/xml-c14n) or * "Exclusive XML Canonicalization" (http://www.w3.org/TR/xml-exc-c14n) * * Returns non-negative value on success or a negative value on fail */ int xmlC14NExecute(xmlDocPtr doc, xmlC14NIsVisibleCallback is_visible_callback, void* user_data, int exclusive, xmlChar **inclusive_ns_prefixes, int with_comments, xmlOutputBufferPtr buf) { xmlC14NCtxPtr ctx; int ret; if ((buf == NULL) || (doc == NULL)) { xmlC14NErrParam("executing c14n"); return (-1); } /* * Validate the encoding output buffer encoding */ if (buf->encoder != NULL) { xmlC14NErr(NULL, (xmlNodePtr) doc, XML_C14N_REQUIRES_UTF8, "xmlC14NExecute: output buffer encoder != NULL but C14N requires UTF8 output\n"); return (-1); } ctx = xmlC14NNewCtx(doc, is_visible_callback, user_data, exclusive, inclusive_ns_prefixes, with_comments, buf); if (ctx == NULL) { xmlC14NErr(NULL, (xmlNodePtr) doc, XML_C14N_CREATE_CTXT, "xmlC14NExecute: unable to create C14N context\n"); return (-1); } /* * Root Node * The root node is the parent of the top-level document element. The * result of processing each of its child nodes that is in the node-set * in document order. The root node does not generate a byte order mark, * XML declaration, nor anything from within the document type * declaration. */ if (doc->children != NULL) { ret = xmlC14NProcessNodeList(ctx, doc->children); if (ret < 0) { xmlC14NErrInternal("processing docs children list"); xmlC14NFreeCtx(ctx); return (-1); } } /* * Flush buffer to get number of bytes written */ ret = xmlOutputBufferFlush(buf); if (ret < 0) { xmlC14NErrInternal("flushing output buffer"); xmlC14NFreeCtx(ctx); return (-1); } /* * Cleanup */ xmlC14NFreeCtx(ctx); return (ret); } /** * xmlC14NDocSaveTo: * @doc: the XML document for canonization * @nodes: the nodes set to be included in the canonized image * or NULL if all document nodes should be included * @exclusive: the exclusive flag (0 - non-exclusive canonicalization; * otherwise - exclusive canonicalization) * @inclusive_ns_prefixes: the list of inclusive namespace prefixes * ended with a NULL or NULL if there is no * inclusive namespaces (only for exclusive * canonicalization, ignored otherwise) * @with_comments: include comments in the result (!=0) or not (==0) * @buf: the output buffer to store canonical XML; this * buffer MUST have encoder==NULL because C14N requires * UTF-8 output * * Dumps the canonized image of given XML document into the provided buffer. * For details see "Canonical XML" (http://www.w3.org/TR/xml-c14n) or * "Exclusive XML Canonicalization" (http://www.w3.org/TR/xml-exc-c14n) * * Returns non-negative value on success or a negative value on fail */ int xmlC14NDocSaveTo(xmlDocPtr doc, xmlNodeSetPtr nodes, int exclusive, xmlChar ** inclusive_ns_prefixes, int with_comments, xmlOutputBufferPtr buf) { return(xmlC14NExecute(doc, (xmlC14NIsVisibleCallback)xmlC14NIsNodeInNodeset, nodes, exclusive, inclusive_ns_prefixes, with_comments, buf)); } /** * xmlC14NDocDumpMemory: * @doc: the XML document for canonization * @nodes: the nodes set to be included in the canonized image * or NULL if all document nodes should be included * @exclusive: the exclusive flag (0 - non-exclusive canonicalization; * otherwise - exclusive canonicalization) * @inclusive_ns_prefixes: the list of inclusive namespace prefixes * ended with a NULL or NULL if there is no * inclusive namespaces (only for exclusive * canonicalization, ignored otherwise) * @with_comments: include comments in the result (!=0) or not (==0) * @doc_txt_ptr: the memory pointer for allocated canonical XML text; * the caller of this functions is responsible for calling * xmlFree() to free allocated memory * * Dumps the canonized image of given XML document into memory. * For details see "Canonical XML" (http://www.w3.org/TR/xml-c14n) or * "Exclusive XML Canonicalization" (http://www.w3.org/TR/xml-exc-c14n) * * Returns the number of bytes written on success or a negative value on fail */ int xmlC14NDocDumpMemory(xmlDocPtr doc, xmlNodeSetPtr nodes, int exclusive, xmlChar ** inclusive_ns_prefixes, int with_comments, xmlChar ** doc_txt_ptr) { int ret; xmlOutputBufferPtr buf; if (doc_txt_ptr == NULL) { xmlC14NErrParam("dumping doc to memory"); return (-1); } *doc_txt_ptr = NULL; /* * create memory buffer with UTF8 (default) encoding */ buf = xmlAllocOutputBuffer(NULL); if (buf == NULL) { xmlC14NErrMemory("creating output buffer"); return (-1); } /* * canonize document and write to buffer */ ret = xmlC14NDocSaveTo(doc, nodes, exclusive, inclusive_ns_prefixes, with_comments, buf); if (ret < 0) { xmlC14NErrInternal("saving doc to output buffer"); (void) xmlOutputBufferClose(buf); return (-1); } ret = buf->buffer->use; if (ret > 0) { *doc_txt_ptr = xmlStrndup(buf->buffer->content, ret); } (void) xmlOutputBufferClose(buf); if ((*doc_txt_ptr == NULL) && (ret > 0)) { xmlC14NErrMemory("coping canonicanized document"); return (-1); } return (ret); } /** * xmlC14NDocSave: * @doc: the XML document for canonization * @nodes: the nodes set to be included in the canonized image * or NULL if all document nodes should be included * @exclusive: the exclusive flag (0 - non-exclusive canonicalization; * otherwise - exclusive canonicalization) * @inclusive_ns_prefixes: the list of inclusive namespace prefixes * ended with a NULL or NULL if there is no * inclusive namespaces (only for exclusive * canonicalization, ignored otherwise) * @with_comments: include comments in the result (!=0) or not (==0) * @filename: the filename to store canonical XML image * @compression: the compression level (zlib requred): * -1 - libxml default, * 0 - uncompressed, * >0 - compression level * * Dumps the canonized image of given XML document into the file. * For details see "Canonical XML" (http://www.w3.org/TR/xml-c14n) or * "Exclusive XML Canonicalization" (http://www.w3.org/TR/xml-exc-c14n) * * Returns the number of bytes written success or a negative value on fail */ int xmlC14NDocSave(xmlDocPtr doc, xmlNodeSetPtr nodes, int exclusive, xmlChar ** inclusive_ns_prefixes, int with_comments, const char *filename, int compression) { xmlOutputBufferPtr buf; int ret; if (filename == NULL) { xmlC14NErrParam("saving doc"); return (-1); } #ifdef HAVE_ZLIB_H if (compression < 0) compression = xmlGetCompressMode(); #endif /* * save the content to a temp buffer, use default UTF8 encoding. */ buf = xmlOutputBufferCreateFilename(filename, NULL, compression); if (buf == NULL) { xmlC14NErrInternal("creating temporary filename"); return (-1); } /* * canonize document and write to buffer */ ret = xmlC14NDocSaveTo(doc, nodes, exclusive, inclusive_ns_prefixes, with_comments, buf); if (ret < 0) { xmlC14NErrInternal("cannicanize document to buffer"); (void) xmlOutputBufferClose(buf); return (-1); } /* * get the numbers of bytes written */ ret = xmlOutputBufferClose(buf); return (ret); } /* * Macro used to grow the current buffer. */ #define growBufferReentrant() { \ buffer_size *= 2; \ buffer = (xmlChar *) \ xmlRealloc(buffer, buffer_size * sizeof(xmlChar)); \ if (buffer == NULL) { \ xmlC14NErrMemory("growing buffer"); \ return(NULL); \ } \ } /** * xmlC11NNormalizeString: * @input: the input string * @mode: the normalization mode (attribute, comment, PI or text) * * Converts a string to a canonical (normalized) format. The code is stolen * from xmlEncodeEntitiesReentrant(). Added normalization of \x09, \x0a, \x0A * and the @mode parameter * * Returns a normalized string (caller is responsible for calling xmlFree()) * or NULL if an error occurs */ static xmlChar * xmlC11NNormalizeString(const xmlChar * input, xmlC14NNormalizationMode mode) { const xmlChar *cur = input; xmlChar *buffer = NULL; xmlChar *out = NULL; int buffer_size = 0; if (input == NULL) return (NULL); /* * allocate an translation buffer. */ buffer_size = 1000; buffer = (xmlChar *) xmlMallocAtomic(buffer_size * sizeof(xmlChar)); if (buffer == NULL) { xmlC14NErrMemory("allocating buffer"); return (NULL); } out = buffer; while (*cur != '\0') { if ((out - buffer) > (buffer_size - 10)) { int indx = out - buffer; growBufferReentrant(); out = &buffer[indx]; } if ((*cur == '<') && ((mode == XMLC14N_NORMALIZE_ATTR) || (mode == XMLC14N_NORMALIZE_TEXT))) { *out++ = '&'; *out++ = 'l'; *out++ = 't'; *out++ = ';'; } else if ((*cur == '>') && (mode == XMLC14N_NORMALIZE_TEXT)) { *out++ = '&'; *out++ = 'g'; *out++ = 't'; *out++ = ';'; } else if ((*cur == '&') && ((mode == XMLC14N_NORMALIZE_ATTR) || (mode == XMLC14N_NORMALIZE_TEXT))) { *out++ = '&'; *out++ = 'a'; *out++ = 'm'; *out++ = 'p'; *out++ = ';'; } else if ((*cur == '"') && (mode == XMLC14N_NORMALIZE_ATTR)) { *out++ = '&'; *out++ = 'q'; *out++ = 'u'; *out++ = 'o'; *out++ = 't'; *out++ = ';'; } else if ((*cur == '\x09') && (mode == XMLC14N_NORMALIZE_ATTR)) { *out++ = '&'; *out++ = '#'; *out++ = 'x'; *out++ = '9'; *out++ = ';'; } else if ((*cur == '\x0A') && (mode == XMLC14N_NORMALIZE_ATTR)) { *out++ = '&'; *out++ = '#'; *out++ = 'x'; *out++ = 'A'; *out++ = ';'; } else if ((*cur == '\x0D') && ((mode == XMLC14N_NORMALIZE_ATTR) || (mode == XMLC14N_NORMALIZE_TEXT) || (mode == XMLC14N_NORMALIZE_COMMENT) || (mode == XMLC14N_NORMALIZE_PI))) { *out++ = '&'; *out++ = '#'; *out++ = 'x'; *out++ = 'D'; *out++ = ';'; } else { /* * Works because on UTF-8, all extended sequences cannot * result in bytes in the ASCII range. */ *out++ = *cur; } cur++; } *out++ = 0; return (buffer); } #endif /* LIBXML_OUTPUT_ENABLED */ #define bottom_c14n #include "elfgcchack.h" #endif /* LIBXML_C14N_ENABLED */ xdmf-3.0+git20160803/Utilities/vtklibxml2/xmlstring.c0000640000175000017500000006130313003006557022341 0ustar alastairalastair/* * string.c : an XML string utilities module * * This module provides various utility functions for manipulating * the xmlChar* type. All functions named xmlStr* have been moved here * from the parser.c file (their original home). * * See Copyright for the status of this software. * * UTF8 string routines from: * William Brack * * daniel@veillard.com */ #define IN_LIBXML #include "libxml.h" #include #include #include #include #include /************************************************************************ * * * Commodity functions to handle xmlChars * * * ************************************************************************/ /** * xmlStrndup: * @cur: the input xmlChar * * @len: the len of @cur * * a strndup for array of xmlChar's * * Returns a new xmlChar * or NULL */ xmlChar * xmlStrndup(const xmlChar *cur, int len) { xmlChar *ret; if ((cur == NULL) || (len < 0)) return(NULL); ret = (xmlChar *) xmlMallocAtomic((len + 1) * sizeof(xmlChar)); if (ret == NULL) { xmlErrMemory(NULL, NULL); return(NULL); } memcpy(ret, cur, len * sizeof(xmlChar)); ret[len] = 0; return(ret); } /** * xmlStrdup: * @cur: the input xmlChar * * * a strdup for array of xmlChar's. Since they are supposed to be * encoded in UTF-8 or an encoding with 8bit based chars, we assume * a termination mark of '0'. * * Returns a new xmlChar * or NULL */ xmlChar * xmlStrdup(const xmlChar *cur) { const xmlChar *p = cur; if (cur == NULL) return(NULL); while (*p != 0) p++; /* non input consuming */ return(xmlStrndup(cur, p - cur)); } /** * xmlCharStrndup: * @cur: the input char * * @len: the len of @cur * * a strndup for char's to xmlChar's * * Returns a new xmlChar * or NULL */ xmlChar * xmlCharStrndup(const char *cur, int len) { int i; xmlChar *ret; if ((cur == NULL) || (len < 0)) return(NULL); ret = (xmlChar *) xmlMallocAtomic((len + 1) * sizeof(xmlChar)); if (ret == NULL) { xmlErrMemory(NULL, NULL); return(NULL); } for (i = 0;i < len;i++) { ret[i] = (xmlChar) cur[i]; if (ret[i] == 0) return(ret); } ret[len] = 0; return(ret); } /** * xmlCharStrdup: * @cur: the input char * * * a strdup for char's to xmlChar's * * Returns a new xmlChar * or NULL */ xmlChar * xmlCharStrdup(const char *cur) { const char *p = cur; if (cur == NULL) return(NULL); while (*p != '\0') p++; /* non input consuming */ return(xmlCharStrndup(cur, p - cur)); } /** * xmlStrcmp: * @str1: the first xmlChar * * @str2: the second xmlChar * * * a strcmp for xmlChar's * * Returns the integer result of the comparison */ int xmlStrcmp(const xmlChar *str1, const xmlChar *str2) { register int tmp; if (str1 == str2) return(0); if (str1 == NULL) return(-1); if (str2 == NULL) return(1); do { tmp = *str1++ - *str2; if (tmp != 0) return(tmp); } while (*str2++ != 0); return 0; } /** * xmlStrEqual: * @str1: the first xmlChar * * @str2: the second xmlChar * * * Check if both strings are equal of have same content. * Should be a bit more readable and faster than xmlStrcmp() * * Returns 1 if they are equal, 0 if they are different */ int xmlStrEqual(const xmlChar *str1, const xmlChar *str2) { if (str1 == str2) return(1); if (str1 == NULL) return(0); if (str2 == NULL) return(0); do { if (*str1++ != *str2) return(0); } while (*str2++); return(1); } /** * xmlStrQEqual: * @pref: the prefix of the QName * @name: the localname of the QName * @str: the second xmlChar * * * Check if a QName is Equal to a given string * * Returns 1 if they are equal, 0 if they are different */ int xmlStrQEqual(const xmlChar *pref, const xmlChar *name, const xmlChar *str) { if (pref == NULL) return(xmlStrEqual(name, str)); if (name == NULL) return(0); if (str == NULL) return(0); do { if (*pref++ != *str) return(0); } while ((*str++) && (*pref)); if (*str++ != ':') return(0); do { if (*name++ != *str) return(0); } while (*str++); return(1); } /** * xmlStrncmp: * @str1: the first xmlChar * * @str2: the second xmlChar * * @len: the max comparison length * * a strncmp for xmlChar's * * Returns the integer result of the comparison */ int xmlStrncmp(const xmlChar *str1, const xmlChar *str2, int len) { register int tmp; if (len <= 0) return(0); if (str1 == str2) return(0); if (str1 == NULL) return(-1); if (str2 == NULL) return(1); #ifdef __GNUC__ tmp = strncmp((const char *)str1, (const char *)str2, len); return tmp; #else do { tmp = *str1++ - *str2; if (tmp != 0 || --len == 0) return(tmp); } while (*str2++ != 0); return 0; #endif } static const xmlChar casemap[256] = { 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, 0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F, 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, 0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F, 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27, 0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F, 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37, 0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F, 0x40,0x61,0x62,0x63,0x64,0x65,0x66,0x67, 0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F, 0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77, 0x78,0x79,0x7A,0x7B,0x5C,0x5D,0x5E,0x5F, 0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67, 0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F, 0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77, 0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F, 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87, 0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97, 0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7, 0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7, 0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7, 0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7, 0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7, 0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7, 0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF }; /** * xmlStrcasecmp: * @str1: the first xmlChar * * @str2: the second xmlChar * * * a strcasecmp for xmlChar's * * Returns the integer result of the comparison */ int xmlStrcasecmp(const xmlChar *str1, const xmlChar *str2) { register int tmp; if (str1 == str2) return(0); if (str1 == NULL) return(-1); if (str2 == NULL) return(1); do { tmp = casemap[*str1++] - casemap[*str2]; if (tmp != 0) return(tmp); } while (*str2++ != 0); return 0; } /** * xmlStrncasecmp: * @str1: the first xmlChar * * @str2: the second xmlChar * * @len: the max comparison length * * a strncasecmp for xmlChar's * * Returns the integer result of the comparison */ int xmlStrncasecmp(const xmlChar *str1, const xmlChar *str2, int len) { register int tmp; if (len <= 0) return(0); if (str1 == str2) return(0); if (str1 == NULL) return(-1); if (str2 == NULL) return(1); do { tmp = casemap[*str1++] - casemap[*str2]; if (tmp != 0 || --len == 0) return(tmp); } while (*str2++ != 0); return 0; } /** * xmlStrchr: * @str: the xmlChar * array * @val: the xmlChar to search * * a strchr for xmlChar's * * Returns the xmlChar * for the first occurrence or NULL. */ const xmlChar * xmlStrchr(const xmlChar *str, xmlChar val) { if (str == NULL) return(NULL); while (*str != 0) { /* non input consuming */ if (*str == val) return((xmlChar *) str); str++; } return(NULL); } /** * xmlStrstr: * @str: the xmlChar * array (haystack) * @val: the xmlChar to search (needle) * * a strstr for xmlChar's * * Returns the xmlChar * for the first occurrence or NULL. */ const xmlChar * xmlStrstr(const xmlChar *str, const xmlChar *val) { int n; if (str == NULL) return(NULL); if (val == NULL) return(NULL); n = xmlStrlen(val); if (n == 0) return(str); while (*str != 0) { /* non input consuming */ if (*str == *val) { if (!xmlStrncmp(str, val, n)) return((const xmlChar *) str); } str++; } return(NULL); } /** * xmlStrcasestr: * @str: the xmlChar * array (haystack) * @val: the xmlChar to search (needle) * * a case-ignoring strstr for xmlChar's * * Returns the xmlChar * for the first occurrence or NULL. */ const xmlChar * xmlStrcasestr(const xmlChar *str, xmlChar *val) { int n; if (str == NULL) return(NULL); if (val == NULL) return(NULL); n = xmlStrlen(val); if (n == 0) return(str); while (*str != 0) { /* non input consuming */ if (casemap[*str] == casemap[*val]) if (!xmlStrncasecmp(str, val, n)) return(str); str++; } return(NULL); } /** * xmlStrsub: * @str: the xmlChar * array (haystack) * @start: the index of the first char (zero based) * @len: the length of the substring * * Extract a substring of a given string * * Returns the xmlChar * for the first occurrence or NULL. */ xmlChar * xmlStrsub(const xmlChar *str, int start, int len) { int i; if (str == NULL) return(NULL); if (start < 0) return(NULL); if (len < 0) return(NULL); for (i = 0;i < start;i++) { if (*str == 0) return(NULL); str++; } if (*str == 0) return(NULL); return(xmlStrndup(str, len)); } /** * xmlStrlen: * @str: the xmlChar * array * * length of a xmlChar's string * * Returns the number of xmlChar contained in the ARRAY. */ int xmlStrlen(const xmlChar *str) { int len = 0; if (str == NULL) return(0); while (*str != 0) { /* non input consuming */ str++; len++; } return(len); } /** * xmlStrncat: * @cur: the original xmlChar * array * @add: the xmlChar * array added * @len: the length of @add * * a strncat for array of xmlChar's, it will extend @cur with the len * first bytes of @add. Note that if @len < 0 then this is an API error * and NULL will be returned. * * Returns a new xmlChar *, the original @cur is reallocated if needed * and should not be freed */ xmlChar * xmlStrncat(xmlChar *cur, const xmlChar *add, int len) { int size; xmlChar *ret; if ((add == NULL) || (len == 0)) return(cur); if (len < 0) return(NULL); if (cur == NULL) return(xmlStrndup(add, len)); size = xmlStrlen(cur); ret = (xmlChar *) xmlRealloc(cur, (size + len + 1) * sizeof(xmlChar)); if (ret == NULL) { xmlErrMemory(NULL, NULL); return(cur); } memcpy(&ret[size], add, len * sizeof(xmlChar)); ret[size + len] = 0; return(ret); } /** * xmlStrncatNew: * @str1: first xmlChar string * @str2: second xmlChar string * @len: the len of @str2 or < 0 * * same as xmlStrncat, but creates a new string. The original * two strings are not freed. If @len is < 0 then the length * will be calculated automatically. * * Returns a new xmlChar * or NULL */ xmlChar * xmlStrncatNew(const xmlChar *str1, const xmlChar *str2, int len) { int size; xmlChar *ret; if (len < 0) len = xmlStrlen(str2); if ((str2 == NULL) || (len == 0)) return(xmlStrdup(str1)); if (str1 == NULL) return(xmlStrndup(str2, len)); size = xmlStrlen(str1); ret = (xmlChar *) xmlMalloc((size + len + 1) * sizeof(xmlChar)); if (ret == NULL) { xmlErrMemory(NULL, NULL); return(xmlStrndup(str1, size)); } memcpy(ret, str1, size * sizeof(xmlChar)); memcpy(&ret[size], str2, len * sizeof(xmlChar)); ret[size + len] = 0; return(ret); } /** * xmlStrcat: * @cur: the original xmlChar * array * @add: the xmlChar * array added * * a strcat for array of xmlChar's. Since they are supposed to be * encoded in UTF-8 or an encoding with 8bit based chars, we assume * a termination mark of '0'. * * Returns a new xmlChar * containing the concatenated string. */ xmlChar * xmlStrcat(xmlChar *cur, const xmlChar *add) { const xmlChar *p = add; if (add == NULL) return(cur); if (cur == NULL) return(xmlStrdup(add)); while (*p != 0) p++; /* non input consuming */ return(xmlStrncat(cur, add, p - add)); } /** * xmlStrPrintf: * @buf: the result buffer. * @len: the result buffer length. * @msg: the message with printf formatting. * @...: extra parameters for the message. * * Formats @msg and places result into @buf. * * Returns the number of characters written to @buf or -1 if an error occurs. */ int XMLCDECL xmlStrPrintf(xmlChar *buf, int len, const xmlChar *msg, ...) { va_list args; int ret; if((buf == NULL) || (msg == NULL)) { return(-1); } va_start(args, msg); ret = vsnprintf((char *) buf, len, (const char *) msg, args); va_end(args); buf[len - 1] = 0; /* be safe ! */ return(ret); } /** * xmlStrVPrintf: * @buf: the result buffer. * @len: the result buffer length. * @msg: the message with printf formatting. * @ap: extra parameters for the message. * * Formats @msg and places result into @buf. * * Returns the number of characters written to @buf or -1 if an error occurs. */ int xmlStrVPrintf(xmlChar *buf, int len, const xmlChar *msg, va_list ap) { int ret; if((buf == NULL) || (msg == NULL)) { return(-1); } ret = vsnprintf((char *) buf, len, (const char *) msg, ap); buf[len - 1] = 0; /* be safe ! */ return(ret); } /************************************************************************ * * * Generic UTF8 handling routines * * * * From rfc2044: encoding of the Unicode values on UTF-8: * * * * UCS-4 range (hex.) UTF-8 octet sequence (binary) * * 0000 0000-0000 007F 0xxxxxxx * * 0000 0080-0000 07FF 110xxxxx 10xxxxxx * * 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx * * * * I hope we won't use values > 0xFFFF anytime soon ! * * * ************************************************************************/ /** * xmlUTF8Size: * @utf: pointer to the UTF8 character * * calculates the internal size of a UTF8 character * * returns the numbers of bytes in the character, -1 on format error */ int xmlUTF8Size(const xmlChar *utf) { xmlChar mask; int len; if (utf == NULL) return -1; if (*utf < 0x80) return 1; /* check valid UTF8 character */ if (!(*utf & 0x40)) return -1; /* determine number of bytes in char */ len = 2; for (mask=0x20; mask != 0; mask>>=1) { if (!(*utf & mask)) return len; len++; } return -1; } /** * xmlUTF8Charcmp: * @utf1: pointer to first UTF8 char * @utf2: pointer to second UTF8 char * * compares the two UCS4 values * * returns result of the compare as with xmlStrncmp */ int xmlUTF8Charcmp(const xmlChar *utf1, const xmlChar *utf2) { if (utf1 == NULL ) { if (utf2 == NULL) return 0; return -1; } return xmlStrncmp(utf1, utf2, xmlUTF8Size(utf1)); } /** * xmlUTF8Strlen: * @utf: a sequence of UTF-8 encoded bytes * * compute the length of an UTF8 string, it doesn't do a full UTF8 * checking of the content of the string. * * Returns the number of characters in the string or -1 in case of error */ int xmlUTF8Strlen(const xmlChar *utf) { int ret = 0; if (utf == NULL) return(-1); while (*utf != 0) { if (utf[0] & 0x80) { if ((utf[1] & 0xc0) != 0x80) return(-1); if ((utf[0] & 0xe0) == 0xe0) { if ((utf[2] & 0xc0) != 0x80) return(-1); if ((utf[0] & 0xf0) == 0xf0) { if ((utf[0] & 0xf8) != 0xf0 || (utf[3] & 0xc0) != 0x80) return(-1); utf += 4; } else { utf += 3; } } else { utf += 2; } } else { utf++; } ret++; } return(ret); } /** * xmlGetUTF8Char: * @utf: a sequence of UTF-8 encoded bytes * @len: a pointer to the minimum number of bytes present in * the sequence. This is used to assure the next character * is completely contained within the sequence. * * Read the first UTF8 character from @utf * * Returns the char value or -1 in case of error, and sets *len to * the actual number of bytes consumed (0 in case of error) */ int xmlGetUTF8Char(const unsigned char *utf, int *len) { unsigned int c; if (utf == NULL) goto error; if (len == NULL) goto error; if (*len < 1) goto error; c = utf[0]; if (c & 0x80) { if (*len < 2) goto error; if ((utf[1] & 0xc0) != 0x80) goto error; if ((c & 0xe0) == 0xe0) { if (*len < 3) goto error; if ((utf[2] & 0xc0) != 0x80) goto error; if ((c & 0xf0) == 0xf0) { if (*len < 4) goto error; if ((c & 0xf8) != 0xf0 || (utf[3] & 0xc0) != 0x80) goto error; *len = 4; /* 4-byte code */ c = (utf[0] & 0x7) << 18; c |= (utf[1] & 0x3f) << 12; c |= (utf[2] & 0x3f) << 6; c |= utf[3] & 0x3f; } else { /* 3-byte code */ *len = 3; c = (utf[0] & 0xf) << 12; c |= (utf[1] & 0x3f) << 6; c |= utf[2] & 0x3f; } } else { /* 2-byte code */ *len = 2; c = (utf[0] & 0x1f) << 6; c |= utf[1] & 0x3f; } } else { /* 1-byte code */ *len = 1; } return(c); error: if (len != NULL) *len = 0; return(-1); } /** * xmlCheckUTF8: * @utf: Pointer to putative UTF-8 encoded string. * * Checks @utf for being valid UTF-8. @utf is assumed to be * null-terminated. This function is not super-strict, as it will * allow longer UTF-8 sequences than necessary. Note that Java is * capable of producing these sequences if provoked. Also note, this * routine checks for the 4-byte maximum size, but does not check for * 0x10ffff maximum value. * * Return value: true if @utf is valid. **/ int xmlCheckUTF8(const unsigned char *utf) { int ix; unsigned char c; if (utf == NULL) return(0); /* * utf is a string of 1, 2, 3 or 4 bytes. The valid strings * are as follows (in "bit format"): * 0xxxxxxx valid 1-byte * 110xxxxx 10xxxxxx valid 2-byte * 1110xxxx 10xxxxxx 10xxxxxx valid 3-byte * 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx valid 4-byte */ for (ix = 0; (c = utf[ix]);) { /* string is 0-terminated */ if ((c & 0x80) == 0x00) { /* 1-byte code, starts with 10 */ ix++; } else if ((c & 0xe0) == 0xc0) {/* 2-byte code, starts with 110 */ if ((utf[ix+1] & 0xc0 ) != 0x80) return 0; ix += 2; } else if ((c & 0xf0) == 0xe0) {/* 3-byte code, starts with 1110 */ if (((utf[ix+1] & 0xc0) != 0x80) || ((utf[ix+2] & 0xc0) != 0x80)) return 0; ix += 3; } else if ((c & 0xf8) == 0xf0) {/* 4-byte code, starts with 11110 */ if (((utf[ix+1] & 0xc0) != 0x80) || ((utf[ix+2] & 0xc0) != 0x80) || ((utf[ix+3] & 0xc0) != 0x80)) return 0; ix += 4; } else /* unknown encoding */ return 0; } return(1); } /** * xmlUTF8Strsize: * @utf: a sequence of UTF-8 encoded bytes * @len: the number of characters in the array * * storage size of an UTF8 string * the behaviour is not garanteed if the input string is not UTF-8 * * Returns the storage size of * the first 'len' characters of ARRAY */ int xmlUTF8Strsize(const xmlChar *utf, int len) { const xmlChar *ptr=utf; xmlChar ch; if (utf == NULL) return(0); if (len <= 0) return(0); while ( len-- > 0) { if ( !*ptr ) break; if ( (ch = *ptr++) & 0x80) while ((ch<<=1) & 0x80 ) { ptr++; if (*ptr == 0) break; } } return (ptr - utf); } /** * xmlUTF8Strndup: * @utf: the input UTF8 * * @len: the len of @utf (in chars) * * a strndup for array of UTF8's * * Returns a new UTF8 * or NULL */ xmlChar * xmlUTF8Strndup(const xmlChar *utf, int len) { xmlChar *ret; int i; if ((utf == NULL) || (len < 0)) return(NULL); i = xmlUTF8Strsize(utf, len); ret = (xmlChar *) xmlMallocAtomic((i + 1) * sizeof(xmlChar)); if (ret == NULL) { xmlGenericError(xmlGenericErrorContext, "malloc of %ld byte failed\n", (len + 1) * (long)sizeof(xmlChar)); return(NULL); } memcpy(ret, utf, i * sizeof(xmlChar)); ret[i] = 0; return(ret); } /** * xmlUTF8Strpos: * @utf: the input UTF8 * * @pos: the position of the desired UTF8 char (in chars) * * a function to provide the equivalent of fetching a * character from a string array * * Returns a pointer to the UTF8 character or NULL */ const xmlChar * xmlUTF8Strpos(const xmlChar *utf, int pos) { xmlChar ch; if (utf == NULL) return(NULL); if (pos < 0) return(NULL); while (pos--) { if ((ch=*utf++) == 0) return(NULL); if ( ch & 0x80 ) { /* if not simple ascii, verify proper format */ if ( (ch & 0xc0) != 0xc0 ) return(NULL); /* then skip over remaining bytes for this char */ while ( (ch <<= 1) & 0x80 ) if ( (*utf++ & 0xc0) != 0x80 ) return(NULL); } } return((xmlChar *)utf); } /** * xmlUTF8Strloc: * @utf: the input UTF8 * * @utfchar: the UTF8 character to be found * * a function to provide the relative location of a UTF8 char * * Returns the relative character position of the desired char * or -1 if not found */ int xmlUTF8Strloc(const xmlChar *utf, const xmlChar *utfchar) { int i, size; xmlChar ch; if (utf==NULL || utfchar==NULL) return -1; size = xmlUTF8Strsize(utfchar, 1); for(i=0; (ch=*utf) != 0; i++) { if (xmlStrncmp(utf, utfchar, size)==0) return(i); utf++; if ( ch & 0x80 ) { /* if not simple ascii, verify proper format */ if ( (ch & 0xc0) != 0xc0 ) return(-1); /* then skip over remaining bytes for this char */ while ( (ch <<= 1) & 0x80 ) if ( (*utf++ & 0xc0) != 0x80 ) return(-1); } } return(-1); } /** * xmlUTF8Strsub: * @utf: a sequence of UTF-8 encoded bytes * @start: relative pos of first char * @len: total number to copy * * Create a substring from a given UTF-8 string * Note: positions are given in units of UTF-8 chars * * Returns a pointer to a newly created string * or NULL if any problem */ xmlChar * xmlUTF8Strsub(const xmlChar *utf, int start, int len) { int i; xmlChar ch; if (utf == NULL) return(NULL); if (start < 0) return(NULL); if (len < 0) return(NULL); /* * Skip over any leading chars */ for (i = 0;i < start;i++) { if ((ch=*utf++) == 0) return(NULL); if ( ch & 0x80 ) { /* if not simple ascii, verify proper format */ if ( (ch & 0xc0) != 0xc0 ) return(NULL); /* then skip over remaining bytes for this char */ while ( (ch <<= 1) & 0x80 ) if ( (*utf++ & 0xc0) != 0x80 ) return(NULL); } } return(xmlUTF8Strndup(utf, len)); } #define bottom_xmlstring #include "elfgcchack.h" xdmf-3.0+git20160803/Utilities/vtklibxml2/xmlmodule.c0000640000175000017500000002371513003006557022325 0ustar alastairalastair/* * xmlmodule.c : basic API for dynamic module loading added 2.6.17 * * See Copyright for the status of this software. * * joelwreed@comcast.net * * http://www.fortran-2000.com/ArnaudRecipes/sharedlib.html */ #define IN_LIBXML #include "libxml.h" #include #include #include #include #include #ifdef LIBXML_MODULES_ENABLED struct _xmlModule { unsigned char *name; void *handle; }; static void *xmlModulePlatformOpen(const char *name); static int xmlModulePlatformClose(void *handle); static int xmlModulePlatformSymbol(void *handle, const char *name, void **result); /************************************************************************ * * * module memory error handler * * * ************************************************************************/ /** * xmlModuleErrMemory: * @extra: extra information * * Handle an out of memory condition */ static void xmlModuleErrMemory(xmlModulePtr module, const char *extra) { const char *name = NULL; if (module != NULL) { name = (const char *) module->name; } __xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_MODULE, XML_ERR_NO_MEMORY, XML_ERR_FATAL, NULL, 0, extra, name, NULL, 0, 0, "Memory allocation failed : %s\n", extra); } /** * xmlModuleOpen: * @name: the module name * @options: a set of xmlModuleOption * * Opens a module/shared library given its name or path * TODO: options are not yet implemented. * * Returns a handle for the module or NULL in case of error */ xmlModulePtr xmlModuleOpen(const char *name, int options ATTRIBUTE_UNUSED) { xmlModulePtr module; module = (xmlModulePtr) xmlMalloc(sizeof(xmlModule)); if (module == NULL) { xmlModuleErrMemory(NULL, "creating module"); return (NULL); } memset(module, 0, sizeof(xmlModule)); module->handle = xmlModulePlatformOpen(name); if (module->handle == NULL) { xmlFree(module); __xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_MODULE, XML_MODULE_OPEN, XML_ERR_FATAL, NULL, 0, 0, name, NULL, 0, 0, "failed to open %s\n", name); return(NULL); } module->name = xmlStrdup((const xmlChar *) name); return (module); } /** * xmlModuleSymbol: * @module: the module * @name: the name of the symbol * @symbol: the resulting symbol address * * Lookup for a symbol address in the given module * * Returns 0 if the symbol was found, or -1 in case of error */ int xmlModuleSymbol(xmlModulePtr module, const char *name, void **symbol) { int rc = -1; if ((NULL == module) || (symbol == NULL)) { __xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_MODULE, XML_MODULE_OPEN, XML_ERR_FATAL, NULL, 0, 0, NULL, NULL, 0, 0, "null parameter\n"); return rc; } rc = xmlModulePlatformSymbol(module->handle, name, symbol); if (rc == -1) { __xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_MODULE, XML_MODULE_OPEN, XML_ERR_FATAL, NULL, 0, 0, name, NULL, 0, 0, "failed to find symbol: %s\n", (name == NULL ? "NULL" : name)); return rc; } return rc; } /** * xmlModuleClose: * @module: the module handle * * The close operations unload the associated module and free the * data associated to the module. * * Returns 0 in case of success, -1 in case of argument error and -2 * if the module could not be closed/unloaded. */ int xmlModuleClose(xmlModulePtr module) { int rc; if (NULL == module) { __xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_MODULE, XML_MODULE_CLOSE, XML_ERR_FATAL, NULL, 0, 0, NULL, NULL, 0, 0, "null module pointer\n"); return -1; } rc = xmlModulePlatformClose(module->handle); if (rc != 0) { __xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_MODULE, XML_MODULE_CLOSE, XML_ERR_FATAL, NULL, 0, 0, (const char *) module->name, NULL, 0, 0, "failed to close: %s\n", module->name); return -2; } rc = xmlModuleFree(module); return (rc); } /** * xmlModuleFree: * @module: the module handle * * The free operations free the data associated to the module * but does not unload the associated shared library which may still * be in use. * * Returns 0 in case of success, -1 in case of argument error */ int xmlModuleFree(xmlModulePtr module) { if (NULL == module) { __xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_MODULE, XML_MODULE_CLOSE, XML_ERR_FATAL, NULL, 0, NULL, NULL, NULL, 0, 0, "null module pointer\n"); return -1; } xmlFree(module->name); xmlFree(module); return (0); } #ifdef HAVE_DLOPEN #ifdef HAVE_DLFCN_H #include #endif #ifndef RTLD_GLOBAL /* For Tru64 UNIX 4.0 */ #define RTLD_GLOBAL 0 #endif /** * xmlModulePlatformOpen: * @name: path to the module * * returns a handle on success, and zero on error. */ static void * xmlModulePlatformOpen(const char *name) { return dlopen(name, RTLD_GLOBAL | RTLD_NOW); } /* * xmlModulePlatformClose: * @handle: handle to the module * * returns 0 on success, and non-zero on error. */ static int xmlModulePlatformClose(void *handle) { return dlclose(handle); } /* * xmlModulePlatformSymbol: * http://www.opengroup.org/onlinepubs/009695399/functions/dlsym.html * returns 0 on success and the loaded symbol in result, and -1 on error. */ static int xmlModulePlatformSymbol(void *handle, const char *name, void **symbol) { *symbol = dlsym(handle, name); if (dlerror() != NULL) { return -1; } return 0; } #else /* ! HAVE_DLOPEN */ #ifdef HAVE_SHLLOAD /* HAVE_SHLLOAD */ #ifdef HAVE_DL_H #include #endif /* * xmlModulePlatformOpen: * returns a handle on success, and zero on error. */ static void * xmlModulePlatformOpen(const char *name) { return shl_load(name, BIND_IMMEDIATE, 0L); } /* * xmlModulePlatformClose: * returns 0 on success, and non-zero on error. */ static int xmlModulePlatformClose(void *handle) { return shl_unload(handle); } /* * xmlModulePlatformSymbol: * http://docs.hp.com/en/B2355-90683/shl_load.3X.html * returns 0 on success and the loaded symbol in result, and -1 on error. */ static int xmlModulePlatformSymbol(void *handle, const char *name, void **symbol) { int rc; errno = 0; rc = shl_findsym((shl_t*)&handle, name, TYPE_UNDEFINED, symbol); return rc; } #endif /* HAVE_SHLLOAD */ #endif /* ! HAVE_DLOPEN */ #if defined(_WIN32) && !defined(HAVE_DLOPEN) #include /* * xmlModulePlatformOpen: * returns a handle on success, and zero on error. */ static void * xmlModulePlatformOpen(const char *name) { return LoadLibrary(name); } /* * xmlModulePlatformClose: * returns 0 on success, and non-zero on error. */ static int xmlModulePlatformClose(void *handle) { int rc; rc = FreeLibrary(handle); return (0 == rc); } /* * xmlModulePlatformSymbol: * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/getprocaddress.asp * returns 0 on success and the loaded symbol in result, and -1 on error. */ static int xmlModulePlatformSymbol(void *handle, const char *name, void **symbol) { *symbol = GetProcAddress(handle, name); return (NULL == *symbol) ? -1 : 0; } #endif /* _WIN32 */ #ifdef HAVE_BEOS #include /* * xmlModulePlatformOpen: * beos api info: http://www.beunited.org/bebook/The%20Kernel%20Kit/Images.html * returns a handle on success, and zero on error. */ static void * xmlModulePlatformOpen(const char *name) { return (void *) load_add_on(name); } /* * xmlModulePlatformClose: * beos api info: http://www.beunited.org/bebook/The%20Kernel%20Kit/Images.html * returns 0 on success, and non-zero on error. */ static int xmlModulePlatformClose(void *handle) { status_t rc; rc = unload_add_on((image_id) handle); if (rc == B_OK) return 0; else return -1; } /* * xmlModulePlatformSymbol: * beos api info: http://www.beunited.org/bebook/The%20Kernel%20Kit/Images.html * returns 0 on success and the loaded symbol in result, and -1 on error. */ static int xmlModulePlatformSymbol(void *handle, const char *name, void **symbol) { status_t rc; rc = get_image_symbol((image_id) handle, name, B_SYMBOL_TYPE_ANY, symbol); return (rc == B_OK) ? 0 : -1; } #endif /* HAVE_BEOS */ #ifdef HAVE_OS2 #include /* * xmlModulePlatformOpen: * os2 api info: http://www.edm2.com/os2api/Dos/DosLoadModule.html * returns a handle on success, and zero on error. */ static void * xmlModulePlatformOpen(const char *name) { char errbuf[256]; void *handle; int rc; rc = DosLoadModule(errbuf, sizeof(errbuf) - 1, name, &handle); if (rc) return 0; else return (handle); } /* * xmlModulePlatformClose: * os2 api info: http://www.edm2.com/os2api/Dos/DosFreeModule.html * returns 0 on success, and non-zero on error. */ static int xmlModulePlatformClose(void *handle) { return DosFreeModule(handle); } /* * xmlModulePlatformSymbol: * os2 api info: http://www.edm2.com/os2api/Dos/DosQueryProcAddr.html * returns 0 on success and the loaded symbol in result, and -1 on error. */ static int xmlModulePlatformSymbol(void *handle, const char *name, void **symbol) { int rc; rc = DosQueryProcAddr(handle, 0, name, symbol); return (rc == NO_ERROR) ? 0 : -1; } #endif /* HAVE_OS2 */ #define bottom_xmlmodule #include "elfgcchack.h" #endif /* LIBXML_MODULES_ENABLED */ xdmf-3.0+git20160803/Utilities/vtklibxml2/AUTHORS0000640000175000017500000000032013003006557021206 0ustar alastairalastairDaniel Veillard Bjorn Reese William Brack Igor Zlatkovic for the Windows port Aleksey Sanin xdmf-3.0+git20160803/Utilities/vtklibxml2/xinclude.c0000640000175000017500000023411513003006557022130 0ustar alastairalastair/* * xinclude.c : Code to implement XInclude processing * * World Wide Web Consortium W3C Last Call Working Draft 10 November 2003 * http://www.w3.org/TR/2003/WD-xinclude-20031110 * * See Copyright for the status of this software. * * daniel@veillard.com */ #define IN_LIBXML #include "libxml.h" #include #include #include #include #include #include #include #include #include #include #ifdef LIBXML_XINCLUDE_ENABLED #include #define XINCLUDE_MAX_DEPTH 40 /* #define DEBUG_XINCLUDE */ #ifdef DEBUG_XINCLUDE #ifdef LIBXML_DEBUG_ENABLED #include #endif #endif /************************************************************************ * * * XInclude context handling * * * ************************************************************************/ /* * An XInclude context */ typedef xmlChar *xmlURL; typedef struct _xmlXIncludeRef xmlXIncludeRef; typedef xmlXIncludeRef *xmlXIncludeRefPtr; struct _xmlXIncludeRef { xmlChar *URI; /* the fully resolved resource URL */ xmlChar *fragment; /* the fragment in the URI */ xmlDocPtr doc; /* the parsed document */ xmlNodePtr ref; /* the node making the reference in the source */ xmlNodePtr inc; /* the included copy */ int xml; /* xml or txt */ int count; /* how many refs use that specific doc */ xmlXPathObjectPtr xptr; /* the xpointer if needed */ int emptyFb; /* flag to show fallback empty */ }; struct _xmlXIncludeCtxt { xmlDocPtr doc; /* the source document */ int incBase; /* the first include for this document */ int incNr; /* number of includes */ int incMax; /* size of includes tab */ xmlXIncludeRefPtr *incTab; /* array of included references */ int txtNr; /* number of unparsed documents */ int txtMax; /* size of unparsed documents tab */ xmlNodePtr *txtTab; /* array of unparsed text nodes */ xmlURL *txturlTab; /* array of unparsed text URLs */ xmlChar * url; /* the current URL processed */ int urlNr; /* number of URLs stacked */ int urlMax; /* size of URL stack */ xmlChar * *urlTab; /* URL stack */ int nbErrors; /* the number of errors detected */ int legacy; /* using XINCLUDE_OLD_NS */ int parseFlags; /* the flags used for parsing XML documents */ xmlChar * base; /* the current xml:base */ void *_private; /* application data */ }; static int xmlXIncludeDoProcess(xmlXIncludeCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr tree); /************************************************************************ * * * XInclude error handler * * * ************************************************************************/ /** * xmlXIncludeErrMemory: * @extra: extra information * * Handle an out of memory condition */ static void xmlXIncludeErrMemory(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node, const char *extra) { if (ctxt != NULL) ctxt->nbErrors++; __xmlRaiseError(NULL, NULL, NULL, ctxt, node, XML_FROM_XINCLUDE, XML_ERR_NO_MEMORY, XML_ERR_ERROR, NULL, 0, extra, NULL, NULL, 0, 0, "Memory allocation failed : %s\n", extra); } /** * xmlXIncludeErr: * @ctxt: the XInclude context * @node: the context node * @msg: the error message * @extra: extra information * * Handle an XInclude error */ static void xmlXIncludeErr(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node, int error, const char *msg, const xmlChar *extra) { if (ctxt != NULL) ctxt->nbErrors++; __xmlRaiseError(NULL, NULL, NULL, ctxt, node, XML_FROM_XINCLUDE, error, XML_ERR_ERROR, NULL, 0, (const char *) extra, NULL, NULL, 0, 0, msg, (const char *) extra); } #if 0 /** * xmlXIncludeWarn: * @ctxt: the XInclude context * @node: the context node * @msg: the error message * @extra: extra information * * Emit an XInclude warning. */ static void xmlXIncludeWarn(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node, int error, const char *msg, const xmlChar *extra) { __xmlRaiseError(NULL, NULL, NULL, ctxt, node, XML_FROM_XINCLUDE, error, XML_ERR_WARNING, NULL, 0, (const char *) extra, NULL, NULL, 0, 0, msg, (const char *) extra); } #endif /** * xmlXIncludeGetProp: * @ctxt: the XInclude context * @cur: the node * @name: the attribute name * * Get an XInclude attribute * * Returns the value (to be freed) or NULL if not found */ static xmlChar * xmlXIncludeGetProp(xmlXIncludeCtxtPtr ctxt, xmlNodePtr cur, const xmlChar *name) { xmlChar *ret; ret = xmlGetNsProp(cur, XINCLUDE_NS, name); if (ret != NULL) return(ret); if (ctxt->legacy != 0) { ret = xmlGetNsProp(cur, XINCLUDE_OLD_NS, name); if (ret != NULL) return(ret); } ret = xmlGetProp(cur, name); return(ret); } /** * xmlXIncludeFreeRef: * @ref: the XInclude reference * * Free an XInclude reference */ static void xmlXIncludeFreeRef(xmlXIncludeRefPtr ref) { if (ref == NULL) return; #ifdef DEBUG_XINCLUDE xmlGenericError(xmlGenericErrorContext, "Freeing ref\n"); #endif if (ref->doc != NULL) { #ifdef DEBUG_XINCLUDE xmlGenericError(xmlGenericErrorContext, "Freeing doc %s\n", ref->URI); #endif xmlFreeDoc(ref->doc); } if (ref->URI != NULL) xmlFree(ref->URI); if (ref->fragment != NULL) xmlFree(ref->fragment); if (ref->xptr != NULL) xmlXPathFreeObject(ref->xptr); xmlFree(ref); } /** * xmlXIncludeNewRef: * @ctxt: the XInclude context * @URI: the resource URI * * Creates a new reference within an XInclude context * * Returns the new set */ static xmlXIncludeRefPtr xmlXIncludeNewRef(xmlXIncludeCtxtPtr ctxt, const xmlChar *URI, xmlNodePtr ref) { xmlXIncludeRefPtr ret; #ifdef DEBUG_XINCLUDE xmlGenericError(xmlGenericErrorContext, "New ref %s\n", URI); #endif ret = (xmlXIncludeRefPtr) xmlMalloc(sizeof(xmlXIncludeRef)); if (ret == NULL) { xmlXIncludeErrMemory(ctxt, ref, "growing XInclude context"); return(NULL); } memset(ret, 0, sizeof(xmlXIncludeRef)); if (URI == NULL) ret->URI = NULL; else ret->URI = xmlStrdup(URI); ret->fragment = NULL; ret->ref = ref; ret->doc = NULL; ret->count = 0; ret->xml = 0; ret->inc = NULL; if (ctxt->incMax == 0) { ctxt->incMax = 4; ctxt->incTab = (xmlXIncludeRefPtr *) xmlMalloc(ctxt->incMax * sizeof(ctxt->incTab[0])); if (ctxt->incTab == NULL) { xmlXIncludeErrMemory(ctxt, ref, "growing XInclude context"); xmlXIncludeFreeRef(ret); return(NULL); } } if (ctxt->incNr >= ctxt->incMax) { ctxt->incMax *= 2; ctxt->incTab = (xmlXIncludeRefPtr *) xmlRealloc(ctxt->incTab, ctxt->incMax * sizeof(ctxt->incTab[0])); if (ctxt->incTab == NULL) { xmlXIncludeErrMemory(ctxt, ref, "growing XInclude context"); xmlXIncludeFreeRef(ret); return(NULL); } } ctxt->incTab[ctxt->incNr++] = ret; return(ret); } /** * xmlXIncludeNewContext: * @doc: an XML Document * * Creates a new XInclude context * * Returns the new set */ xmlXIncludeCtxtPtr xmlXIncludeNewContext(xmlDocPtr doc) { xmlXIncludeCtxtPtr ret; #ifdef DEBUG_XINCLUDE xmlGenericError(xmlGenericErrorContext, "New context\n"); #endif if (doc == NULL) return(NULL); ret = (xmlXIncludeCtxtPtr) xmlMalloc(sizeof(xmlXIncludeCtxt)); if (ret == NULL) { xmlXIncludeErrMemory(NULL, (xmlNodePtr) doc, "creating XInclude context"); return(NULL); } memset(ret, 0, sizeof(xmlXIncludeCtxt)); ret->doc = doc; ret->incNr = 0; ret->incBase = 0; ret->incMax = 0; ret->incTab = NULL; ret->nbErrors = 0; return(ret); } /** * xmlXIncludeURLPush: * @ctxt: the parser context * @value: the url * * Pushes a new url on top of the url stack * * Returns -1 in case of error, the index in the stack otherwise */ static int xmlXIncludeURLPush(xmlXIncludeCtxtPtr ctxt, const xmlChar *value) { if (ctxt->urlNr > XINCLUDE_MAX_DEPTH) { xmlXIncludeErr(ctxt, NULL, XML_XINCLUDE_RECURSION, "detected a recursion in %s\n", value); return(-1); } if (ctxt->urlTab == NULL) { ctxt->urlMax = 4; ctxt->urlNr = 0; ctxt->urlTab = (xmlChar * *) xmlMalloc( ctxt->urlMax * sizeof(ctxt->urlTab[0])); if (ctxt->urlTab == NULL) { xmlXIncludeErrMemory(ctxt, NULL, "adding URL"); return (-1); } } if (ctxt->urlNr >= ctxt->urlMax) { ctxt->urlMax *= 2; ctxt->urlTab = (xmlChar * *) xmlRealloc(ctxt->urlTab, ctxt->urlMax * sizeof(ctxt->urlTab[0])); if (ctxt->urlTab == NULL) { xmlXIncludeErrMemory(ctxt, NULL, "adding URL"); return (-1); } } ctxt->url = ctxt->urlTab[ctxt->urlNr] = xmlStrdup(value); return (ctxt->urlNr++); } /** * xmlXIncludeURLPop: * @ctxt: the parser context * * Pops the top URL from the URL stack */ static void xmlXIncludeURLPop(xmlXIncludeCtxtPtr ctxt) { xmlChar * ret; if (ctxt->urlNr <= 0) return; ctxt->urlNr--; if (ctxt->urlNr > 0) ctxt->url = ctxt->urlTab[ctxt->urlNr - 1]; else ctxt->url = NULL; ret = ctxt->urlTab[ctxt->urlNr]; ctxt->urlTab[ctxt->urlNr] = NULL; if (ret != NULL) xmlFree(ret); } /** * xmlXIncludeFreeContext: * @ctxt: the XInclude context * * Free an XInclude context */ void xmlXIncludeFreeContext(xmlXIncludeCtxtPtr ctxt) { int i; #ifdef DEBUG_XINCLUDE xmlGenericError(xmlGenericErrorContext, "Freeing context\n"); #endif if (ctxt == NULL) return; while (ctxt->urlNr > 0) xmlXIncludeURLPop(ctxt); if (ctxt->urlTab != NULL) xmlFree(ctxt->urlTab); for (i = 0;i < ctxt->incNr;i++) { if (ctxt->incTab[i] != NULL) xmlXIncludeFreeRef(ctxt->incTab[i]); } if (ctxt->txturlTab != NULL) { for (i = 0;i < ctxt->txtNr;i++) { if (ctxt->txturlTab[i] != NULL) xmlFree(ctxt->txturlTab[i]); } } if (ctxt->incTab != NULL) xmlFree(ctxt->incTab); if (ctxt->txtTab != NULL) xmlFree(ctxt->txtTab); if (ctxt->txturlTab != NULL) xmlFree(ctxt->txturlTab); if (ctxt->base != NULL) { xmlFree(ctxt->base); } xmlFree(ctxt); } /** * xmlXIncludeParseFile: * @ctxt: the XInclude context * @URL: the URL or file path * * parse a document for XInclude */ static xmlDocPtr xmlXIncludeParseFile(xmlXIncludeCtxtPtr ctxt, const char *URL) { xmlDocPtr ret; xmlParserCtxtPtr pctxt; char *directory = NULL; xmlParserInputPtr inputStream; xmlInitParser(); pctxt = xmlNewParserCtxt(); if (pctxt == NULL) { xmlXIncludeErrMemory(ctxt, NULL, "cannot allocate parser context"); return(NULL); } /* * pass in the application data to the parser context. */ pctxt->_private = ctxt->_private; /* * try to ensure that new documents included are actually * built with the same dictionary as the including document. */ if ((ctxt->doc != NULL) && (ctxt->doc->dict != NULL) && (pctxt->dict != NULL)) { xmlDictFree(pctxt->dict); pctxt->dict = ctxt->doc->dict; xmlDictReference(pctxt->dict); } xmlCtxtUseOptions(pctxt, ctxt->parseFlags | XML_PARSE_DTDLOAD); inputStream = xmlLoadExternalEntity(URL, NULL, pctxt); if (inputStream == NULL) { xmlFreeParserCtxt(pctxt); return(NULL); } inputPush(pctxt, inputStream); if ((pctxt->directory == NULL) && (directory == NULL)) directory = xmlParserGetDirectory(URL); if ((pctxt->directory == NULL) && (directory != NULL)) pctxt->directory = (char *) xmlStrdup((xmlChar *) directory); pctxt->loadsubset |= XML_DETECT_IDS; xmlParseDocument(pctxt); if (pctxt->wellFormed) { ret = pctxt->myDoc; } else { ret = NULL; if (pctxt->myDoc != NULL) xmlFreeDoc(pctxt->myDoc); pctxt->myDoc = NULL; } xmlFreeParserCtxt(pctxt); return(ret); } /** * xmlXIncludeAddNode: * @ctxt: the XInclude context * @cur: the new node * * Add a new node to process to an XInclude context */ static int xmlXIncludeAddNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr cur) { xmlXIncludeRefPtr ref; xmlURIPtr uri; xmlChar *URL; xmlChar *fragment = NULL; xmlChar *href; xmlChar *parse; xmlChar *base; xmlChar *URI; int xml = 1, i; /* default Issue 64 */ int local = 0; if (ctxt == NULL) return(-1); if (cur == NULL) return(-1); #ifdef DEBUG_XINCLUDE xmlGenericError(xmlGenericErrorContext, "Add node\n"); #endif /* * read the attributes */ href = xmlXIncludeGetProp(ctxt, cur, XINCLUDE_HREF); if (href == NULL) { href = xmlStrdup(BAD_CAST ""); /* @@@@ href is now optional */ if (href == NULL) return(-1); local = 1; } if (href[0] == '#') local = 1; parse = xmlXIncludeGetProp(ctxt, cur, XINCLUDE_PARSE); if (parse != NULL) { if (xmlStrEqual(parse, XINCLUDE_PARSE_XML)) xml = 1; else if (xmlStrEqual(parse, XINCLUDE_PARSE_TEXT)) xml = 0; else { xmlXIncludeErr(ctxt, cur, XML_XINCLUDE_PARSE_VALUE, "invalid value %s for 'parse'\n", parse); if (href != NULL) xmlFree(href); if (parse != NULL) xmlFree(parse); return(-1); } } /* * compute the URI */ base = xmlNodeGetBase(ctxt->doc, cur); if (base == NULL) { URI = xmlBuildURI(href, ctxt->doc->URL); } else { URI = xmlBuildURI(href, base); } if (URI == NULL) { xmlChar *escbase; xmlChar *eschref; /* * Some escaping may be needed */ escbase = xmlURIEscape(base); eschref = xmlURIEscape(href); URI = xmlBuildURI(eschref, escbase); if (escbase != NULL) xmlFree(escbase); if (eschref != NULL) xmlFree(eschref); } if (parse != NULL) xmlFree(parse); if (href != NULL) xmlFree(href); if (base != NULL) xmlFree(base); if (URI == NULL) { xmlXIncludeErr(ctxt, cur, XML_XINCLUDE_HREF_URI, "failed build URL\n", NULL); return(-1); } fragment = xmlXIncludeGetProp(ctxt, cur, XINCLUDE_PARSE_XPOINTER); /* * Check the URL and remove any fragment identifier */ uri = xmlParseURI((const char *)URI); if (uri == NULL) { xmlXIncludeErr(ctxt, cur, XML_XINCLUDE_HREF_URI, "invalid value URI %s\n", URI); if (fragment != NULL) xmlFree(fragment); xmlFree(URI); return(-1); } if (uri->fragment != NULL) { if (ctxt->legacy != 0) { if (fragment == NULL) { fragment = (xmlChar *) uri->fragment; } else { xmlFree(uri->fragment); } } else { xmlXIncludeErr(ctxt, cur, XML_XINCLUDE_FRAGMENT_ID, "Invalid fragment identifier in URI %s use the xpointer attribute\n", URI); if (fragment != NULL) xmlFree(fragment); xmlFreeURI(uri); xmlFree(URI); return(-1); } uri->fragment = NULL; } URL = xmlSaveUri(uri); xmlFreeURI(uri); xmlFree(URI); if (URL == NULL) { xmlXIncludeErr(ctxt, cur, XML_XINCLUDE_HREF_URI, "invalid value URI %s\n", URI); if (fragment != NULL) xmlFree(fragment); return(-1); } /* * Check the URL against the stack for recursions */ if ((!local) && (xml == 1)) { for (i = 0;i < ctxt->urlNr;i++) { if (xmlStrEqual(URL, ctxt->urlTab[i])) { xmlXIncludeErr(ctxt, cur, XML_XINCLUDE_RECURSION, "detected a recursion in %s\n", URL); return(-1); } } } ref = xmlXIncludeNewRef(ctxt, URL, cur); if (ref == NULL) { return(-1); } ref->fragment = fragment; ref->doc = NULL; ref->xml = xml; ref->count = 1; xmlFree(URL); return(0); } /** * xmlXIncludeRecurseDoc: * @ctxt: the XInclude context * @doc: the new document * @url: the associated URL * * The XInclude recursive nature is handled at this point. */ static void xmlXIncludeRecurseDoc(xmlXIncludeCtxtPtr ctxt, xmlDocPtr doc, const xmlURL url ATTRIBUTE_UNUSED) { xmlXIncludeCtxtPtr newctxt; int i; /* * Avoid recursion in already substitued resources for (i = 0;i < ctxt->urlNr;i++) { if (xmlStrEqual(doc->URL, ctxt->urlTab[i])) return; } */ #ifdef DEBUG_XINCLUDE xmlGenericError(xmlGenericErrorContext, "Recursing in doc %s\n", doc->URL); #endif /* * Handle recursion here. */ newctxt = xmlXIncludeNewContext(doc); if (newctxt != NULL) { /* * Copy the existing document set */ newctxt->incMax = ctxt->incMax; newctxt->incNr = ctxt->incNr; newctxt->incTab = (xmlXIncludeRefPtr *) xmlMalloc(newctxt->incMax * sizeof(newctxt->incTab[0])); if (newctxt->incTab == NULL) { xmlXIncludeErrMemory(ctxt, (xmlNodePtr) doc, "processing doc"); xmlFree(newctxt); return; } /* * copy the urlTab */ newctxt->urlMax = ctxt->urlMax; newctxt->urlNr = ctxt->urlNr; newctxt->urlTab = ctxt->urlTab; /* * Inherit the existing base */ newctxt->base = xmlStrdup(ctxt->base); /* * Inherit the documents already in use by other includes */ newctxt->incBase = ctxt->incNr; for (i = 0;i < ctxt->incNr;i++) { newctxt->incTab[i] = ctxt->incTab[i]; newctxt->incTab[i]->count++; /* prevent the recursion from freeing it */ } /* * The new context should also inherit the Parse Flags * (bug 132597) */ newctxt->parseFlags = ctxt->parseFlags; xmlXIncludeDoProcess(newctxt, doc, xmlDocGetRootElement(doc)); for (i = 0;i < ctxt->incNr;i++) { newctxt->incTab[i]->count--; newctxt->incTab[i] = NULL; } /* urlTab may have been reallocated */ ctxt->urlTab = newctxt->urlTab; ctxt->urlMax = newctxt->urlMax; newctxt->urlMax = 0; newctxt->urlNr = 0; newctxt->urlTab = NULL; xmlXIncludeFreeContext(newctxt); } #ifdef DEBUG_XINCLUDE xmlGenericError(xmlGenericErrorContext, "Done recursing in doc %s\n", url); #endif } /** * xmlXIncludeAddTxt: * @ctxt: the XInclude context * @txt: the new text node * @url: the associated URL * * Add a new txtument to the list */ static void xmlXIncludeAddTxt(xmlXIncludeCtxtPtr ctxt, xmlNodePtr txt, const xmlURL url) { #ifdef DEBUG_XINCLUDE xmlGenericError(xmlGenericErrorContext, "Adding text %s\n", url); #endif if (ctxt->txtMax == 0) { ctxt->txtMax = 4; ctxt->txtTab = (xmlNodePtr *) xmlMalloc(ctxt->txtMax * sizeof(ctxt->txtTab[0])); if (ctxt->txtTab == NULL) { xmlXIncludeErrMemory(ctxt, NULL, "processing text"); return; } ctxt->txturlTab = (xmlURL *) xmlMalloc(ctxt->txtMax * sizeof(ctxt->txturlTab[0])); if (ctxt->txturlTab == NULL) { xmlXIncludeErrMemory(ctxt, NULL, "processing text"); return; } } if (ctxt->txtNr >= ctxt->txtMax) { ctxt->txtMax *= 2; ctxt->txtTab = (xmlNodePtr *) xmlRealloc(ctxt->txtTab, ctxt->txtMax * sizeof(ctxt->txtTab[0])); if (ctxt->txtTab == NULL) { xmlXIncludeErrMemory(ctxt, NULL, "processing text"); return; } ctxt->txturlTab = (xmlURL *) xmlRealloc(ctxt->txturlTab, ctxt->txtMax * sizeof(ctxt->txturlTab[0])); if (ctxt->txturlTab == NULL) { xmlXIncludeErrMemory(ctxt, NULL, "processing text"); return; } } ctxt->txtTab[ctxt->txtNr] = txt; ctxt->txturlTab[ctxt->txtNr] = xmlStrdup(url); ctxt->txtNr++; } /************************************************************************ * * * Node copy with specific semantic * * * ************************************************************************/ /** * xmlXIncludeCopyNode: * @ctxt: the XInclude context * @target: the document target * @source: the document source * @elem: the element * * Make a copy of the node while preserving the XInclude semantic * of the Infoset copy */ static xmlNodePtr xmlXIncludeCopyNode(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target, xmlDocPtr source, xmlNodePtr elem) { xmlNodePtr result = NULL; if ((ctxt == NULL) || (target == NULL) || (source == NULL) || (elem == NULL)) return(NULL); if (elem->type == XML_DTD_NODE) return(NULL); result = xmlDocCopyNode(elem, target, 1); return(result); } /** * xmlXIncludeCopyNodeList: * @ctxt: the XInclude context * @target: the document target * @source: the document source * @elem: the element list * * Make a copy of the node list while preserving the XInclude semantic * of the Infoset copy */ static xmlNodePtr xmlXIncludeCopyNodeList(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target, xmlDocPtr source, xmlNodePtr elem) { xmlNodePtr cur, res, result = NULL, last = NULL; if ((ctxt == NULL) || (target == NULL) || (source == NULL) || (elem == NULL)) return(NULL); cur = elem; while (cur != NULL) { res = xmlXIncludeCopyNode(ctxt, target, source, cur); if (res != NULL) { if (result == NULL) { result = last = res; } else { last->next = res; res->prev = last; last = res; } } cur = cur->next; } return(result); } /** * xmlXIncludeGetNthChild: * @cur: the node * @no: the child number * * Returns the @n'th element child of @cur or NULL */ static xmlNodePtr xmlXIncludeGetNthChild(xmlNodePtr cur, int no) { int i; if (cur == NULL) return(cur); cur = cur->children; for (i = 0;i <= no;cur = cur->next) { if (cur == NULL) return(cur); if ((cur->type == XML_ELEMENT_NODE) || (cur->type == XML_DOCUMENT_NODE) || (cur->type == XML_HTML_DOCUMENT_NODE)) { i++; if (i == no) break; } } return(cur); } xmlNodePtr xmlXPtrAdvanceNode(xmlNodePtr cur, int *level); /* in xpointer.c */ /** * xmlXIncludeCopyRange: * @ctxt: the XInclude context * @target: the document target * @source: the document source * @obj: the XPointer result from the evaluation. * * Build a node list tree copy of the XPointer result. * * Returns an xmlNodePtr list or NULL. * The caller has to free the node tree. */ static xmlNodePtr xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target, xmlDocPtr source, xmlXPathObjectPtr range) { /* pointers to generated nodes */ xmlNodePtr list = NULL, last = NULL, listParent = NULL; xmlNodePtr tmp, tmp2; /* pointers to traversal nodes */ xmlNodePtr start, cur, end; int index1, index2; int level = 0, lastLevel = 0, endLevel = 0, endFlag = 0; if ((ctxt == NULL) || (target == NULL) || (source == NULL) || (range == NULL)) return(NULL); if (range->type != XPATH_RANGE) return(NULL); start = (xmlNodePtr) range->user; if (start == NULL) return(NULL); end = range->user2; if (end == NULL) return(xmlDocCopyNode(start, target, 1)); cur = start; index1 = range->index; index2 = range->index2; /* * level is depth of the current node under consideration * list is the pointer to the root of the output tree * listParent is a pointer to the parent of output tree (within the included file) in case we need to add another level * last is a pointer to the last node added to the output tree * lastLevel is the depth of last (relative to the root) */ while (cur != NULL) { /* * Check if our output tree needs a parent */ if (level < 0) { while (level < 0) { /* copy must include namespaces and properties */ tmp2 = xmlDocCopyNode(listParent, target, 2); xmlAddChild(tmp2, list); list = tmp2; listParent = listParent->parent; level++; } last = list; lastLevel = 0; } /* * Check whether we need to change our insertion point */ while (level < lastLevel) { last = last->parent; lastLevel --; } if (cur == end) { /* Are we at the end of the range? */ if (cur->type == XML_TEXT_NODE) { const xmlChar *content = cur->content; int len; if (content == NULL) { tmp = xmlNewTextLen(NULL, 0); } else { len = index2; if ((cur == start) && (index1 > 1)) { content += (index1 - 1); len -= (index1 - 1); index1 = 0; } else { len = index2; } tmp = xmlNewTextLen(content, len); } /* single sub text node selection */ if (list == NULL) return(tmp); /* prune and return full set */ if (level == lastLevel) xmlAddNextSibling(last, tmp); else xmlAddChild(last, tmp); return(list); } else { /* ending node not a text node */ endLevel = level; /* remember the level of the end node */ endFlag = 1; /* last node - need to take care of properties + namespaces */ tmp = xmlDocCopyNode(cur, target, 2); if (list == NULL) { list = tmp; listParent = cur->parent; } else { if (level == lastLevel) xmlAddNextSibling(last, tmp); else { xmlAddChild(last, tmp); lastLevel = level; } } last = tmp; if (index2 > 1) { end = xmlXIncludeGetNthChild(cur, index2 - 1); index2 = 0; } if ((cur == start) && (index1 > 1)) { cur = xmlXIncludeGetNthChild(cur, index1 - 1); index1 = 0; } else { cur = cur->children; } level++; /* increment level to show change */ /* * Now gather the remaining nodes from cur to end */ continue; /* while */ } } else if (cur == start) { /* Not at the end, are we at start? */ if ((cur->type == XML_TEXT_NODE) || (cur->type == XML_CDATA_SECTION_NODE)) { const xmlChar *content = cur->content; if (content == NULL) { tmp = xmlNewTextLen(NULL, 0); } else { if (index1 > 1) { content += (index1 - 1); index1 = 0; } tmp = xmlNewText(content); } last = list = tmp; listParent = cur->parent; } else { /* Not text node */ /* * start of the range - need to take care of * properties and namespaces */ tmp = xmlDocCopyNode(cur, target, 2); list = last = tmp; listParent = cur->parent; if (index1 > 1) { /* Do we need to position? */ cur = xmlXIncludeGetNthChild(cur, index1 - 1); level = lastLevel = 1; index1 = 0; /* * Now gather the remaining nodes from cur to end */ continue; /* while */ } } } else { tmp = NULL; switch (cur->type) { case XML_DTD_NODE: case XML_ELEMENT_DECL: case XML_ATTRIBUTE_DECL: case XML_ENTITY_NODE: /* Do not copy DTD informations */ break; case XML_ENTITY_DECL: /* handle crossing entities -> stack needed */ break; case XML_XINCLUDE_START: case XML_XINCLUDE_END: /* don't consider it part of the tree content */ break; case XML_ATTRIBUTE_NODE: /* Humm, should not happen ! */ break; default: /* * Middle of the range - need to take care of * properties and namespaces */ tmp = xmlDocCopyNode(cur, target, 2); break; } if (tmp != NULL) { if (level == lastLevel) xmlAddNextSibling(last, tmp); else { xmlAddChild(last, tmp); lastLevel = level; } last = tmp; } } /* * Skip to next node in document order */ cur = xmlXPtrAdvanceNode(cur, &level); if (endFlag && (level >= endLevel)) break; } return(list); } /** * xmlXIncludeBuildNodeList: * @ctxt: the XInclude context * @target: the document target * @source: the document source * @obj: the XPointer result from the evaluation. * * Build a node list tree copy of the XPointer result. * This will drop Attributes and Namespace declarations. * * Returns an xmlNodePtr list or NULL. * the caller has to free the node tree. */ static xmlNodePtr xmlXIncludeCopyXPointer(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target, xmlDocPtr source, xmlXPathObjectPtr obj) { xmlNodePtr list = NULL, last = NULL; int i; if (source == NULL) source = ctxt->doc; if ((ctxt == NULL) || (target == NULL) || (source == NULL) || (obj == NULL)) return(NULL); switch (obj->type) { case XPATH_NODESET: { xmlNodeSetPtr set = obj->nodesetval; if (set == NULL) return(NULL); for (i = 0;i < set->nodeNr;i++) { if (set->nodeTab[i] == NULL) continue; switch (set->nodeTab[i]->type) { case XML_TEXT_NODE: case XML_CDATA_SECTION_NODE: case XML_ELEMENT_NODE: case XML_ENTITY_REF_NODE: case XML_ENTITY_NODE: case XML_PI_NODE: case XML_COMMENT_NODE: case XML_DOCUMENT_NODE: case XML_HTML_DOCUMENT_NODE: #ifdef LIBXML_DOCB_ENABLED case XML_DOCB_DOCUMENT_NODE: #endif case XML_XINCLUDE_END: break; case XML_XINCLUDE_START: { xmlNodePtr tmp, cur = set->nodeTab[i]; cur = cur->next; while (cur != NULL) { switch(cur->type) { case XML_TEXT_NODE: case XML_CDATA_SECTION_NODE: case XML_ELEMENT_NODE: case XML_ENTITY_REF_NODE: case XML_ENTITY_NODE: case XML_PI_NODE: case XML_COMMENT_NODE: tmp = xmlXIncludeCopyNode(ctxt, target, source, cur); if (last == NULL) { list = last = tmp; } else { xmlAddNextSibling(last, tmp); last = tmp; } cur = cur->next; continue; default: break; } break; } continue; } case XML_ATTRIBUTE_NODE: case XML_NAMESPACE_DECL: case XML_DOCUMENT_TYPE_NODE: case XML_DOCUMENT_FRAG_NODE: case XML_NOTATION_NODE: case XML_DTD_NODE: case XML_ELEMENT_DECL: case XML_ATTRIBUTE_DECL: case XML_ENTITY_DECL: continue; /* for */ } if (last == NULL) list = last = xmlXIncludeCopyNode(ctxt, target, source, set->nodeTab[i]); else { xmlAddNextSibling(last, xmlXIncludeCopyNode(ctxt, target, source, set->nodeTab[i])); if (last->next != NULL) last = last->next; } } break; } case XPATH_LOCATIONSET: { xmlLocationSetPtr set = (xmlLocationSetPtr) obj->user; if (set == NULL) return(NULL); for (i = 0;i < set->locNr;i++) { if (last == NULL) list = last = xmlXIncludeCopyXPointer(ctxt, target, source, set->locTab[i]); else xmlAddNextSibling(last, xmlXIncludeCopyXPointer(ctxt, target, source, set->locTab[i])); if (last != NULL) { while (last->next != NULL) last = last->next; } } break; } #ifdef LIBXML_XPTR_ENABLED case XPATH_RANGE: return(xmlXIncludeCopyRange(ctxt, target, source, obj)); #endif case XPATH_POINT: /* points are ignored in XInclude */ break; default: break; } return(list); } /************************************************************************ * * * XInclude I/O handling * * * ************************************************************************/ typedef struct _xmlXIncludeMergeData xmlXIncludeMergeData; typedef xmlXIncludeMergeData *xmlXIncludeMergeDataPtr; struct _xmlXIncludeMergeData { xmlDocPtr doc; xmlXIncludeCtxtPtr ctxt; }; /** * xmlXIncludeMergeOneEntity: * @ent: the entity * @doc: the including doc * @nr: the entity name * * Inplements the merge of one entity */ static void xmlXIncludeMergeEntity(xmlEntityPtr ent, xmlXIncludeMergeDataPtr data, xmlChar *name ATTRIBUTE_UNUSED) { xmlEntityPtr ret, prev; xmlDocPtr doc; xmlXIncludeCtxtPtr ctxt; if ((ent == NULL) || (data == NULL)) return; ctxt = data->ctxt; doc = data->doc; if ((ctxt == NULL) || (doc == NULL)) return; switch (ent->etype) { case XML_INTERNAL_PARAMETER_ENTITY: case XML_EXTERNAL_PARAMETER_ENTITY: case XML_INTERNAL_PREDEFINED_ENTITY: return; case XML_INTERNAL_GENERAL_ENTITY: case XML_EXTERNAL_GENERAL_PARSED_ENTITY: case XML_EXTERNAL_GENERAL_UNPARSED_ENTITY: break; } ret = xmlAddDocEntity(doc, ent->name, ent->etype, ent->ExternalID, ent->SystemID, ent->content); if (ret != NULL) { if (ent->URI != NULL) ret->URI = xmlStrdup(ent->URI); } else { prev = xmlGetDocEntity(doc, ent->name); if (prev != NULL) { if (ent->etype != prev->etype) goto error; if ((ent->SystemID != NULL) && (prev->SystemID != NULL)) { if (!xmlStrEqual(ent->SystemID, prev->SystemID)) goto error; } else if ((ent->ExternalID != NULL) && (prev->ExternalID != NULL)) { if (!xmlStrEqual(ent->ExternalID, prev->ExternalID)) goto error; } else if ((ent->content != NULL) && (prev->content != NULL)) { if (!xmlStrEqual(ent->content, prev->content)) goto error; } else { goto error; } } } return; error: switch (ent->etype) { case XML_INTERNAL_PARAMETER_ENTITY: case XML_EXTERNAL_PARAMETER_ENTITY: case XML_INTERNAL_PREDEFINED_ENTITY: case XML_INTERNAL_GENERAL_ENTITY: case XML_EXTERNAL_GENERAL_PARSED_ENTITY: return; case XML_EXTERNAL_GENERAL_UNPARSED_ENTITY: break; } xmlXIncludeErr(ctxt, (xmlNodePtr) ent, XML_XINCLUDE_ENTITY_DEF_MISMATCH, "mismatch in redefinition of entity %s\n", ent->name); } /** * xmlXIncludeMergeEntities: * @ctxt: an XInclude context * @doc: the including doc * @from: the included doc * * Inplements the entity merge * * Returns 0 if merge succeeded, -1 if some processing failed */ static int xmlXIncludeMergeEntities(xmlXIncludeCtxtPtr ctxt, xmlDocPtr doc, xmlDocPtr from) { xmlNodePtr cur; xmlDtdPtr target, source; if (ctxt == NULL) return(-1); if ((from == NULL) || (from->intSubset == NULL)) return(0); target = doc->intSubset; if (target == NULL) { cur = xmlDocGetRootElement(doc); if (cur == NULL) return(-1); target = xmlCreateIntSubset(doc, cur->name, NULL, NULL); if (target == NULL) return(-1); } source = from->intSubset; if ((source != NULL) && (source->entities != NULL)) { xmlXIncludeMergeData data; data.ctxt = ctxt; data.doc = doc; xmlHashScan((xmlHashTablePtr) source->entities, (xmlHashScanner) xmlXIncludeMergeEntity, &data); } source = from->extSubset; if ((source != NULL) && (source->entities != NULL)) { xmlXIncludeMergeData data; data.ctxt = ctxt; data.doc = doc; /* * don't duplicate existing stuff when external subsets are the same */ if ((!xmlStrEqual(target->ExternalID, source->ExternalID)) && (!xmlStrEqual(target->SystemID, source->SystemID))) { xmlHashScan((xmlHashTablePtr) source->entities, (xmlHashScanner) xmlXIncludeMergeEntity, &data); } } return(0); } /** * xmlXIncludeLoadDoc: * @ctxt: the XInclude context * @url: the associated URL * @nr: the xinclude node number * * Load the document, and store the result in the XInclude context * * Returns 0 in case of success, -1 in case of failure */ static int xmlXIncludeLoadDoc(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) { xmlDocPtr doc; xmlURIPtr uri; xmlChar *URL; xmlChar *fragment = NULL; int i = 0; #ifdef LIBXML_XPTR_ENABLED int saveFlags; #endif #ifdef DEBUG_XINCLUDE xmlGenericError(xmlGenericErrorContext, "Loading doc %s:%d\n", url, nr); #endif /* * Check the URL and remove any fragment identifier */ uri = xmlParseURI((const char *)url); if (uri == NULL) { xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, XML_XINCLUDE_HREF_URI, "invalid value URI %s\n", url); return(-1); } if (uri->fragment != NULL) { fragment = (xmlChar *) uri->fragment; uri->fragment = NULL; } if ((ctxt->incTab != NULL) && (ctxt->incTab[nr] != NULL) && (ctxt->incTab[nr]->fragment != NULL)) { if (fragment != NULL) xmlFree(fragment); fragment = xmlStrdup(ctxt->incTab[nr]->fragment); } URL = xmlSaveUri(uri); xmlFreeURI(uri); if (URL == NULL) { if (ctxt->incTab != NULL) xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, XML_XINCLUDE_HREF_URI, "invalid value URI %s\n", url); else xmlXIncludeErr(ctxt, NULL, XML_XINCLUDE_HREF_URI, "invalid value URI %s\n", url); if (fragment != NULL) xmlFree(fragment); return(-1); } /* * Handling of references to the local document are done * directly through ctxt->doc. */ if ((URL[0] == 0) || (URL[0] == '#') || ((ctxt->doc != NULL) && (xmlStrEqual(URL, ctxt->doc->URL)))) { doc = NULL; goto loaded; } /* * Prevent reloading twice the document. */ for (i = 0; i < ctxt->incNr; i++) { if ((xmlStrEqual(URL, ctxt->incTab[i]->URI)) && (ctxt->incTab[i]->doc != NULL)) { doc = ctxt->incTab[i]->doc; #ifdef DEBUG_XINCLUDE printf("Already loaded %s\n", URL); #endif goto loaded; } } /* * Load it. */ #ifdef DEBUG_XINCLUDE printf("loading %s\n", URL); #endif #ifdef LIBXML_XPTR_ENABLED /* * If this is an XPointer evaluation, we want to assure that * all entities have been resolved prior to processing the * referenced document */ saveFlags = ctxt->parseFlags; if (fragment != NULL) { /* if this is an XPointer eval */ ctxt->parseFlags |= XML_PARSE_NOENT; } #endif doc = xmlXIncludeParseFile(ctxt, (const char *)URL); #ifdef LIBXML_XPTR_ENABLED ctxt->parseFlags = saveFlags; #endif if (doc == NULL) { xmlFree(URL); if (fragment != NULL) xmlFree(fragment); return(-1); } ctxt->incTab[nr]->doc = doc; /* * It's possible that the requested URL has been mapped to a * completely different location (e.g. through a catalog entry). * To check for this, we compare the URL with that of the doc * and change it if they disagree (bug 146988). */ if (!xmlStrEqual(URL, doc->URL)) { xmlFree(URL); URL = xmlStrdup(doc->URL); } for (i = nr + 1; i < ctxt->incNr; i++) { if (xmlStrEqual(URL, ctxt->incTab[i]->URI)) { ctxt->incTab[nr]->count++; #ifdef DEBUG_XINCLUDE printf("Increasing %s count since reused\n", URL); #endif break; } } /* * Make sure we have all entities fixed up */ xmlXIncludeMergeEntities(ctxt, ctxt->doc, doc); /* * We don't need the DTD anymore, free up space if (doc->intSubset != NULL) { xmlUnlinkNode((xmlNodePtr) doc->intSubset); xmlFreeNode((xmlNodePtr) doc->intSubset); doc->intSubset = NULL; } if (doc->extSubset != NULL) { xmlUnlinkNode((xmlNodePtr) doc->extSubset); xmlFreeNode((xmlNodePtr) doc->extSubset); doc->extSubset = NULL; } */ xmlXIncludeRecurseDoc(ctxt, doc, URL); loaded: if (fragment == NULL) { /* * Add the top children list as the replacement copy. */ if (doc == NULL) { /* Hopefully a DTD declaration won't be copied from * the same document */ ctxt->incTab[nr]->inc = xmlCopyNodeList(ctxt->doc->children); } else { ctxt->incTab[nr]->inc = xmlXIncludeCopyNodeList(ctxt, ctxt->doc, doc, doc->children); } } #ifdef LIBXML_XPTR_ENABLED else { /* * Computes the XPointer expression and make a copy used * as the replacement copy. */ xmlXPathObjectPtr xptr; xmlXPathContextPtr xptrctxt; xmlNodeSetPtr set; if (doc == NULL) { xptrctxt = xmlXPtrNewContext(ctxt->doc, ctxt->incTab[nr]->ref, NULL); } else { xptrctxt = xmlXPtrNewContext(doc, NULL, NULL); } if (xptrctxt == NULL) { xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, XML_XINCLUDE_XPTR_FAILED, "could not create XPointer context\n", NULL); xmlFree(URL); xmlFree(fragment); return(-1); } xptr = xmlXPtrEval(fragment, xptrctxt); if (xptr == NULL) { xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, XML_XINCLUDE_XPTR_FAILED, "XPointer evaluation failed: #%s\n", fragment); xmlXPathFreeContext(xptrctxt); xmlFree(URL); xmlFree(fragment); return(-1); } switch (xptr->type) { case XPATH_UNDEFINED: case XPATH_BOOLEAN: case XPATH_NUMBER: case XPATH_STRING: case XPATH_POINT: case XPATH_USERS: case XPATH_XSLT_TREE: xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, XML_XINCLUDE_XPTR_RESULT, "XPointer is not a range: #%s\n", fragment); xmlXPathFreeContext(xptrctxt); xmlFree(URL); xmlFree(fragment); return(-1); case XPATH_NODESET: if ((xptr->nodesetval == NULL) || (xptr->nodesetval->nodeNr <= 0)) { xmlXPathFreeContext(xptrctxt); xmlFree(URL); xmlFree(fragment); return(-1); } case XPATH_RANGE: case XPATH_LOCATIONSET: break; } set = xptr->nodesetval; if (set != NULL) { for (i = 0;i < set->nodeNr;i++) { if (set->nodeTab[i] == NULL) continue; switch (set->nodeTab[i]->type) { case XML_TEXT_NODE: case XML_CDATA_SECTION_NODE: case XML_ENTITY_REF_NODE: case XML_ENTITY_NODE: case XML_PI_NODE: case XML_COMMENT_NODE: case XML_DOCUMENT_NODE: case XML_HTML_DOCUMENT_NODE: #ifdef LIBXML_DOCB_ENABLED case XML_DOCB_DOCUMENT_NODE: #endif continue; case XML_ELEMENT_NODE: { xmlChar *nodeBase; xmlNodePtr el = set->nodeTab[i]; nodeBase = xmlNodeGetBase(el->doc, el); if (nodeBase != NULL) { if (!xmlStrEqual(nodeBase, el->doc->URL)) xmlNodeSetBase(el, nodeBase); xmlFree(nodeBase); } continue; } case XML_ATTRIBUTE_NODE: xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, XML_XINCLUDE_XPTR_RESULT, "XPointer selects an attribute: #%s\n", fragment); set->nodeTab[i] = NULL; continue; case XML_NAMESPACE_DECL: xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, XML_XINCLUDE_XPTR_RESULT, "XPointer selects a namespace: #%s\n", fragment); set->nodeTab[i] = NULL; continue; case XML_DOCUMENT_TYPE_NODE: case XML_DOCUMENT_FRAG_NODE: case XML_NOTATION_NODE: case XML_DTD_NODE: case XML_ELEMENT_DECL: case XML_ATTRIBUTE_DECL: case XML_ENTITY_DECL: case XML_XINCLUDE_START: case XML_XINCLUDE_END: xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, XML_XINCLUDE_XPTR_RESULT, "XPointer selects unexpected nodes: #%s\n", fragment); set->nodeTab[i] = NULL; set->nodeTab[i] = NULL; continue; /* for */ } } } if (doc == NULL) { ctxt->incTab[nr]->xptr = xptr; ctxt->incTab[nr]->inc = NULL; } else { ctxt->incTab[nr]->inc = xmlXIncludeCopyXPointer(ctxt, ctxt->doc, doc, xptr); xmlXPathFreeObject(xptr); } xmlXPathFreeContext(xptrctxt); xmlFree(fragment); } #endif /* * Do the xml:base fixup if needed */ if ((doc != NULL) && (URL != NULL) && (xmlStrchr(URL, (xmlChar) '/'))) { xmlNodePtr node; xmlChar *base; xmlChar *curBase; /* * The base is only adjusted if "necessary", i.e. if the xinclude node * has a base specified, or the URL is relative */ base = xmlGetNsProp(ctxt->incTab[nr]->ref, BAD_CAST "base", XML_XML_NAMESPACE); if (base == NULL) { /* * No xml:base on the xinclude node, so we check whether the * URI base is different than (relative to) the context base */ curBase = xmlBuildRelativeURI(URL, ctxt->base); if (curBase == NULL) { /* Error return */ xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, XML_XINCLUDE_HREF_URI, "trying to build relative URI from %s\n", URL); } else { /* If the URI doesn't contain a slash, it's not relative */ if (!xmlStrchr(curBase, (xmlChar) '/')) xmlFree(curBase); else base = curBase; } } if (base != NULL) { /* Adjustment may be needed */ node = ctxt->incTab[nr]->inc; while (node != NULL) { /* Only work on element nodes */ if (node->type == XML_ELEMENT_NODE) { curBase = xmlNodeGetBase(node->doc, node); /* If no current base, set it */ if (curBase == NULL) { xmlNodeSetBase(node, base); } else { /* * If the current base is the same as the * URL of the document, then reset it to be * the specified xml:base or the relative URI */ if (xmlStrEqual(curBase, node->doc->URL)) { xmlNodeSetBase(node, base); } else { /* * If the element already has an xml:base * set, then relativise it if necessary */ xmlChar *xmlBase; xmlBase = xmlGetNsProp(node, BAD_CAST "base", XML_XML_NAMESPACE); if (xmlBase != NULL) { xmlChar *relBase; relBase = xmlBuildURI(xmlBase, base); if (relBase == NULL) { /* error */ xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, XML_XINCLUDE_HREF_URI, "trying to rebuild base from %s\n", xmlBase); } else { xmlNodeSetBase(node, relBase); xmlFree(relBase); } xmlFree(xmlBase); } } xmlFree(curBase); } } node = node->next; } xmlFree(base); } } if ((nr < ctxt->incNr) && (ctxt->incTab[nr]->doc != NULL) && (ctxt->incTab[nr]->count <= 1)) { #ifdef DEBUG_XINCLUDE printf("freeing %s\n", ctxt->incTab[nr]->doc->URL); #endif xmlFreeDoc(ctxt->incTab[nr]->doc); ctxt->incTab[nr]->doc = NULL; } xmlFree(URL); return(0); } /** * xmlXIncludeLoadTxt: * @ctxt: the XInclude context * @url: the associated URL * @nr: the xinclude node number * * Load the content, and store the result in the XInclude context * * Returns 0 in case of success, -1 in case of failure */ static int xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) { xmlParserInputBufferPtr buf; xmlNodePtr node; xmlURIPtr uri; xmlChar *URL; int i; xmlChar *encoding = NULL; xmlCharEncoding enc = (xmlCharEncoding) 0; /* * Check the URL and remove any fragment identifier */ uri = xmlParseURI((const char *)url); if (uri == NULL) { xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, XML_XINCLUDE_HREF_URI, "invalid value URI %s\n", url); return(-1); } if (uri->fragment != NULL) { xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, XML_XINCLUDE_TEXT_FRAGMENT, "fragment identifier forbidden for text: %s\n", (const xmlChar *) uri->fragment); xmlFreeURI(uri); return(-1); } URL = xmlSaveUri(uri); xmlFreeURI(uri); if (URL == NULL) { xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, XML_XINCLUDE_HREF_URI, "invalid value URI %s\n", url); return(-1); } /* * Handling of references to the local document are done * directly through ctxt->doc. */ if (URL[0] == 0) { xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, XML_XINCLUDE_TEXT_DOCUMENT, "text serialization of document not available\n", NULL); xmlFree(URL); return(-1); } /* * Prevent reloading twice the document. */ for (i = 0; i < ctxt->txtNr; i++) { if (xmlStrEqual(URL, ctxt->txturlTab[i])) { node = xmlCopyNode(ctxt->txtTab[i], 1); goto loaded; } } /* * Try to get the encoding if available */ if ((ctxt->incTab[nr] != NULL) && (ctxt->incTab[nr]->ref != NULL)) { encoding = xmlGetProp(ctxt->incTab[nr]->ref, XINCLUDE_PARSE_ENCODING); } if (encoding != NULL) { /* * TODO: we should not have to remap to the xmlCharEncoding * predefined set, a better interface than * xmlParserInputBufferCreateFilename should allow any * encoding supported by iconv */ enc = xmlParseCharEncoding((const char *) encoding); if (enc == XML_CHAR_ENCODING_ERROR) { xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, XML_XINCLUDE_UNKNOWN_ENCODING, "encoding %s not supported\n", encoding); xmlFree(encoding); xmlFree(URL); return(-1); } xmlFree(encoding); } /* * Load it. */ buf = xmlParserInputBufferCreateFilename((const char *)URL, enc); if (buf == NULL) { xmlFree(URL); return(-1); } node = xmlNewText(NULL); /* * Scan all chars from the resource and add the to the node */ while (xmlParserInputBufferRead(buf, 128) > 0) { int len; const xmlChar *content; content = xmlBufferContent(buf->buffer); len = xmlBufferLength(buf->buffer); for (i = 0;i < len;) { int cur; int l; cur = xmlStringCurrentChar(NULL, &content[i], &l); if (!IS_CHAR(cur)) { xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, XML_XINCLUDE_INVALID_CHAR, "%s contains invalid char\n", URL); } else { xmlNodeAddContentLen(node, &content[i], l); } i += l; } xmlBufferShrink(buf->buffer, len); } xmlFreeParserInputBuffer(buf); xmlXIncludeAddTxt(ctxt, node, URL); loaded: /* * Add the element as the replacement copy. */ ctxt->incTab[nr]->inc = node; xmlFree(URL); return(0); } /** * xmlXIncludeLoadFallback: * @ctxt: the XInclude context * @fallback: the fallback node * @nr: the xinclude node number * * Load the content of the fallback node, and store the result * in the XInclude context * * Returns 0 in case of success, -1 in case of failure */ static int xmlXIncludeLoadFallback(xmlXIncludeCtxtPtr ctxt, xmlNodePtr fallback, int nr) { xmlXIncludeCtxtPtr newctxt; int ret = 0; if ((fallback == NULL) || (ctxt == NULL)) return(-1); if (fallback->children != NULL) { /* * It's possible that the fallback also has 'includes' * (Bug 129969), so we re-process the fallback just in case */ newctxt = xmlXIncludeNewContext(ctxt->doc); if (newctxt == NULL) return (-1); newctxt->base = xmlStrdup(ctxt->base); /* Inherit the base from the existing context */ xmlXIncludeSetFlags(newctxt, ctxt->parseFlags); ret = xmlXIncludeDoProcess(newctxt, ctxt->doc, fallback->children); if (ctxt->nbErrors > 0) ret = -1; else if (ret > 0) ret = 0; /* xmlXIncludeDoProcess can return +ve number */ xmlXIncludeFreeContext(newctxt); ctxt->incTab[nr]->inc = xmlDocCopyNodeList(ctxt->doc, fallback->children); } else { ctxt->incTab[nr]->inc = NULL; ctxt->incTab[nr]->emptyFb = 1; /* flag empty callback */ } return(ret); } /************************************************************************ * * * XInclude Processing * * * ************************************************************************/ /** * xmlXIncludePreProcessNode: * @ctxt: an XInclude context * @node: an XInclude node * * Implement the XInclude preprocessing, currently just adding the element * for further processing. * * Returns the result list or NULL in case of error */ static xmlNodePtr xmlXIncludePreProcessNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node) { xmlXIncludeAddNode(ctxt, node); return(NULL); } /** * xmlXIncludeLoadNode: * @ctxt: an XInclude context * @nr: the node number * * Find and load the infoset replacement for the given node. * * Returns 0 if substitution succeeded, -1 if some processing failed */ static int xmlXIncludeLoadNode(xmlXIncludeCtxtPtr ctxt, int nr) { xmlNodePtr cur; xmlChar *href; xmlChar *parse; xmlChar *base; xmlChar *oldBase; xmlChar *URI; int xml = 1; /* default Issue 64 */ int ret; if (ctxt == NULL) return(-1); if ((nr < 0) || (nr >= ctxt->incNr)) return(-1); cur = ctxt->incTab[nr]->ref; if (cur == NULL) return(-1); /* * read the attributes */ href = xmlXIncludeGetProp(ctxt, cur, XINCLUDE_HREF); if (href == NULL) { href = xmlStrdup(BAD_CAST ""); /* @@@@ href is now optional */ if (href == NULL) return(-1); } parse = xmlXIncludeGetProp(ctxt, cur, XINCLUDE_PARSE); if (parse != NULL) { if (xmlStrEqual(parse, XINCLUDE_PARSE_XML)) xml = 1; else if (xmlStrEqual(parse, XINCLUDE_PARSE_TEXT)) xml = 0; else { xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, XML_XINCLUDE_PARSE_VALUE, "invalid value %s for 'parse'\n", parse); if (href != NULL) xmlFree(href); if (parse != NULL) xmlFree(parse); return(-1); } } /* * compute the URI */ base = xmlNodeGetBase(ctxt->doc, cur); if (base == NULL) { URI = xmlBuildURI(href, ctxt->doc->URL); } else { URI = xmlBuildURI(href, base); } if (URI == NULL) { xmlChar *escbase; xmlChar *eschref; /* * Some escaping may be needed */ escbase = xmlURIEscape(base); eschref = xmlURIEscape(href); URI = xmlBuildURI(eschref, escbase); if (escbase != NULL) xmlFree(escbase); if (eschref != NULL) xmlFree(eschref); } if (URI == NULL) { xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, XML_XINCLUDE_HREF_URI, "failed build URL\n", NULL); if (parse != NULL) xmlFree(parse); if (href != NULL) xmlFree(href); if (base != NULL) xmlFree(base); return(-1); } #ifdef DEBUG_XINCLUDE xmlGenericError(xmlGenericErrorContext, "parse: %s\n", xml ? "xml": "text"); xmlGenericError(xmlGenericErrorContext, "URI: %s\n", URI); #endif /* * Save the base for this include (saving the current one) */ oldBase = ctxt->base; ctxt->base = base; if (xml) { ret = xmlXIncludeLoadDoc(ctxt, URI, nr); /* xmlXIncludeGetFragment(ctxt, cur, URI); */ } else { ret = xmlXIncludeLoadTxt(ctxt, URI, nr); } /* * Restore the original base before checking for fallback */ ctxt->base = oldBase; if (ret < 0) { xmlNodePtr children; /* * Time to try a fallback if availble */ #ifdef DEBUG_XINCLUDE xmlGenericError(xmlGenericErrorContext, "error looking for fallback\n"); #endif children = cur->children; while (children != NULL) { if ((children->type == XML_ELEMENT_NODE) && (children->ns != NULL) && (xmlStrEqual(children->name, XINCLUDE_FALLBACK)) && ((xmlStrEqual(children->ns->href, XINCLUDE_NS)) || (xmlStrEqual(children->ns->href, XINCLUDE_OLD_NS)))) { ret = xmlXIncludeLoadFallback(ctxt, children, nr); if (ret == 0) break; } children = children->next; } } if (ret < 0) { xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, XML_XINCLUDE_NO_FALLBACK, "could not load %s, and no fallback was found\n", URI); } /* * Cleanup */ if (URI != NULL) xmlFree(URI); if (parse != NULL) xmlFree(parse); if (href != NULL) xmlFree(href); if (base != NULL) xmlFree(base); return(0); } /** * xmlXIncludeIncludeNode: * @ctxt: an XInclude context * @nr: the node number * * Inplement the infoset replacement for the given node * * Returns 0 if substitution succeeded, -1 if some processing failed */ static int xmlXIncludeIncludeNode(xmlXIncludeCtxtPtr ctxt, int nr) { xmlNodePtr cur, end, list, tmp; if (ctxt == NULL) return(-1); if ((nr < 0) || (nr >= ctxt->incNr)) return(-1); cur = ctxt->incTab[nr]->ref; if (cur == NULL) return(-1); /* * If we stored an XPointer a late computation may be needed */ if ((ctxt->incTab[nr]->inc == NULL) && (ctxt->incTab[nr]->xptr != NULL)) { ctxt->incTab[nr]->inc = xmlXIncludeCopyXPointer(ctxt, ctxt->doc, ctxt->doc, ctxt->incTab[nr]->xptr); xmlXPathFreeObject(ctxt->incTab[nr]->xptr); ctxt->incTab[nr]->xptr = NULL; } list = ctxt->incTab[nr]->inc; ctxt->incTab[nr]->inc = NULL; /* * Check against the risk of generating a multi-rooted document */ if ((cur->parent != NULL) && (cur->parent->type != XML_ELEMENT_NODE)) { int nb_elem = 0; tmp = list; while (tmp != NULL) { if (tmp->type == XML_ELEMENT_NODE) nb_elem++; tmp = tmp->next; } if (nb_elem > 1) { xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, XML_XINCLUDE_MULTIPLE_ROOT, "XInclude error: would result in multiple root nodes\n", NULL); return(-1); } } if (ctxt->parseFlags & XML_PARSE_NOXINCNODE) { /* * Add the list of nodes */ while (list != NULL) { end = list; list = list->next; xmlAddPrevSibling(cur, end); } xmlUnlinkNode(cur); xmlFreeNode(cur); } else { /* * Change the current node as an XInclude start one, and add an * XInclude end one */ cur->type = XML_XINCLUDE_START; end = xmlNewDocNode(cur->doc, cur->ns, cur->name, NULL); if (end == NULL) { xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, XML_XINCLUDE_BUILD_FAILED, "failed to build node\n", NULL); return(-1); } end->type = XML_XINCLUDE_END; xmlAddNextSibling(cur, end); /* * Add the list of nodes */ while (list != NULL) { cur = list; list = list->next; xmlAddPrevSibling(end, cur); } } return(0); } /** * xmlXIncludeTestNode: * @ctxt: the XInclude processing context * @node: an XInclude node * * test if the node is an XInclude node * * Returns 1 true, 0 otherwise */ static int xmlXIncludeTestNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node) { if (node == NULL) return(0); if (node->type != XML_ELEMENT_NODE) return(0); if (node->ns == NULL) return(0); if ((xmlStrEqual(node->ns->href, XINCLUDE_NS)) || (xmlStrEqual(node->ns->href, XINCLUDE_OLD_NS))) { if (xmlStrEqual(node->ns->href, XINCLUDE_OLD_NS)) { if (ctxt->legacy == 0) { #if 0 /* wait for the XML Core Working Group to get something stable ! */ xmlXIncludeWarn(ctxt, node, XML_XINCLUDE_DEPRECATED_NS, "Deprecated XInclude namespace found, use %s", XINCLUDE_NS); #endif ctxt->legacy = 1; } } if (xmlStrEqual(node->name, XINCLUDE_NODE)) { xmlNodePtr child = node->children; int nb_fallback = 0; while (child != NULL) { if ((child->type == XML_ELEMENT_NODE) && (child->ns != NULL) && ((xmlStrEqual(child->ns->href, XINCLUDE_NS)) || (xmlStrEqual(child->ns->href, XINCLUDE_OLD_NS)))) { if (xmlStrEqual(child->name, XINCLUDE_NODE)) { xmlXIncludeErr(ctxt, node, XML_XINCLUDE_INCLUDE_IN_INCLUDE, "%s has an 'include' child\n", XINCLUDE_NODE); return(0); } if (xmlStrEqual(child->name, XINCLUDE_FALLBACK)) { nb_fallback++; } } child = child->next; } if (nb_fallback > 1) { xmlXIncludeErr(ctxt, node, XML_XINCLUDE_FALLBACKS_IN_INCLUDE, "%s has multiple fallback children\n", XINCLUDE_NODE); return(0); } return(1); } if (xmlStrEqual(node->name, XINCLUDE_FALLBACK)) { if ((node->parent == NULL) || (node->parent->type != XML_ELEMENT_NODE) || (node->parent->ns == NULL) || ((!xmlStrEqual(node->parent->ns->href, XINCLUDE_NS)) && (!xmlStrEqual(node->parent->ns->href, XINCLUDE_OLD_NS))) || (!xmlStrEqual(node->parent->name, XINCLUDE_NODE))) { xmlXIncludeErr(ctxt, node, XML_XINCLUDE_FALLBACK_NOT_IN_INCLUDE, "%s is not the child of an 'include'\n", XINCLUDE_FALLBACK); } } } return(0); } /** * xmlXIncludeDoProcess: * @ctxt: the XInclude processing context * @doc: an XML document * @tree: the top of the tree to process * * Implement the XInclude substitution on the XML document @doc * * Returns 0 if no substitution were done, -1 if some processing failed * or the number of substitutions done. */ static int xmlXIncludeDoProcess(xmlXIncludeCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr tree) { xmlNodePtr cur; int ret = 0; int i, start; if ((doc == NULL) || (tree == NULL)) return(-1); if (ctxt == NULL) return(-1); if (doc->URL != NULL) { ret = xmlXIncludeURLPush(ctxt, doc->URL); if (ret < 0) return(-1); } start = ctxt->incNr; /* * First phase: lookup the elements in the document */ cur = tree; if (xmlXIncludeTestNode(ctxt, cur) == 1) xmlXIncludePreProcessNode(ctxt, cur); while ((cur != NULL) && (cur != tree->parent)) { /* TODO: need to work on entities -> stack */ if ((cur->children != NULL) && (cur->children->type != XML_ENTITY_DECL) && (cur->children->type != XML_XINCLUDE_START) && (cur->children->type != XML_XINCLUDE_END)) { cur = cur->children; if (xmlXIncludeTestNode(ctxt, cur)) xmlXIncludePreProcessNode(ctxt, cur); } else if (cur->next != NULL) { cur = cur->next; if (xmlXIncludeTestNode(ctxt, cur)) xmlXIncludePreProcessNode(ctxt, cur); } else { if (cur == tree) break; do { cur = cur->parent; if ((cur == NULL) || (cur == tree->parent)) break; /* do */ if (cur->next != NULL) { cur = cur->next; if (xmlXIncludeTestNode(ctxt, cur)) xmlXIncludePreProcessNode(ctxt, cur); break; /* do */ } } while (cur != NULL); } } /* * Second Phase : collect the infosets fragments */ for (i = start;i < ctxt->incNr; i++) { xmlXIncludeLoadNode(ctxt, i); ret++; } /* * Third phase: extend the original document infoset. * * Originally we bypassed the inclusion if there were any errors * encountered on any of the XIncludes. A bug was raised (bug * 132588) requesting that we output the XIncludes without error, * so the check for inc!=NULL || xptr!=NULL was put in. This may * give some other problems in the future, but for now it seems to * work ok. * */ for (i = ctxt->incBase;i < ctxt->incNr; i++) { if ((ctxt->incTab[i]->inc != NULL) || (ctxt->incTab[i]->xptr != NULL) || (ctxt->incTab[i]->emptyFb != 0)) /* (empty fallback) */ xmlXIncludeIncludeNode(ctxt, i); } if (doc->URL != NULL) xmlXIncludeURLPop(ctxt); return(ret); } /** * xmlXIncludeSetFlags: * @ctxt: an XInclude processing context * @flags: a set of xmlParserOption used for parsing XML includes * * Set the flags used for further processing of XML resources. * * Returns 0 in case of success and -1 in case of error. */ int xmlXIncludeSetFlags(xmlXIncludeCtxtPtr ctxt, int flags) { if (ctxt == NULL) return(-1); ctxt->parseFlags = flags; return(0); } /** * xmlXIncludeProcessFlagsData: * @doc: an XML document * @flags: a set of xmlParserOption used for parsing XML includes * @data: application data that will be passed to the parser context * in the _private field of the parser context(s) * * Implement the XInclude substitution on the XML document @doc * * Returns 0 if no substitution were done, -1 if some processing failed * or the number of substitutions done. */ int xmlXIncludeProcessFlagsData(xmlDocPtr doc, int flags, void *data) { xmlXIncludeCtxtPtr ctxt; xmlNodePtr tree; int ret = 0; if (doc == NULL) return(-1); tree = xmlDocGetRootElement(doc); if (tree == NULL) return(-1); ctxt = xmlXIncludeNewContext(doc); if (ctxt == NULL) return(-1); ctxt->_private = data; ctxt->base = xmlStrdup((xmlChar *)doc->URL); xmlXIncludeSetFlags(ctxt, flags); ret = xmlXIncludeDoProcess(ctxt, doc, tree); if ((ret >= 0) && (ctxt->nbErrors > 0)) ret = -1; xmlXIncludeFreeContext(ctxt); return(ret); } /** * xmlXIncludeProcessFlags: * @doc: an XML document * @flags: a set of xmlParserOption used for parsing XML includes * * Implement the XInclude substitution on the XML document @doc * * Returns 0 if no substitution were done, -1 if some processing failed * or the number of substitutions done. */ int xmlXIncludeProcessFlags(xmlDocPtr doc, int flags) { return xmlXIncludeProcessFlagsData(doc, flags, NULL); } /** * xmlXIncludeProcess: * @doc: an XML document * * Implement the XInclude substitution on the XML document @doc * * Returns 0 if no substitution were done, -1 if some processing failed * or the number of substitutions done. */ int xmlXIncludeProcess(xmlDocPtr doc) { return(xmlXIncludeProcessFlags(doc, 0)); } /** * xmlXIncludeProcessTreeFlags: * @tree: a node in an XML document * @flags: a set of xmlParserOption used for parsing XML includes * * Implement the XInclude substitution for the given subtree * * Returns 0 if no substitution were done, -1 if some processing failed * or the number of substitutions done. */ int xmlXIncludeProcessTreeFlags(xmlNodePtr tree, int flags) { xmlXIncludeCtxtPtr ctxt; int ret = 0; if ((tree == NULL) || (tree->doc == NULL)) return(-1); ctxt = xmlXIncludeNewContext(tree->doc); if (ctxt == NULL) return(-1); ctxt->base = xmlNodeGetBase(tree->doc, tree); xmlXIncludeSetFlags(ctxt, flags); ret = xmlXIncludeDoProcess(ctxt, tree->doc, tree); if ((ret >= 0) && (ctxt->nbErrors > 0)) ret = -1; xmlXIncludeFreeContext(ctxt); return(ret); } /** * xmlXIncludeProcessTree: * @tree: a node in an XML document * * Implement the XInclude substitution for the given subtree * * Returns 0 if no substitution were done, -1 if some processing failed * or the number of substitutions done. */ int xmlXIncludeProcessTree(xmlNodePtr tree) { return(xmlXIncludeProcessTreeFlags(tree, 0)); } /** * xmlXIncludeProcessNode: * @ctxt: an existing XInclude context * @node: a node in an XML document * * Implement the XInclude substitution for the given subtree reusing * the informations and data coming from the given context. * * Returns 0 if no substitution were done, -1 if some processing failed * or the number of substitutions done. */ int xmlXIncludeProcessNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node) { int ret = 0; if ((node == NULL) || (node->doc == NULL) || (ctxt == NULL)) return(-1); ret = xmlXIncludeDoProcess(ctxt, node->doc, node); if ((ret >= 0) && (ctxt->nbErrors > 0)) ret = -1; return(ret); } #else /* !LIBXML_XINCLUDE_ENABLED */ #endif #define bottom_xinclude #include "elfgcchack.h" xdmf-3.0+git20160803/Utilities/vtklibxml2/config_cmake.h.in0000640000175000017500000001636613003006557023342 0ustar alastairalastair/* Define if getaddrinfo is there */ #cmakedefine HAVE_GETADDRINFO /* Define to 1 if you have the header file. */ #cmakedefine HAVE_ANSIDECL_H 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_ARPA_INET_H 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_ARPA_NAMESER_H 1 /* Whether struct sockaddr::__ss_family exists */ #cmakedefine HAVE_BROKEN_SS_FAMILY /* Define to 1 if you have the `class' function. */ #cmakedefine HAVE_CLASS /* Define to 1 if you have the header file. */ #cmakedefine HAVE_CTYPE_H 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_DIRENT_H 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_DLFCN_H 1 /* Have dlopen based dso */ #cmakedefine HAVE_DLOPEN /* Define to 1 if you have the header file. */ #cmakedefine HAVE_DL_H 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_ERRNO_H 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_FCNTL_H 1 /* Define to 1 if you have the `finite' function. */ #cmakedefine HAVE_FINITE 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_FLOAT_H 1 /* Define to 1 if you have the `fpclass' function. */ #cmakedefine HAVE_FPCLASS 1 /* Define to 1 if you have the `fprintf' function. */ #cmakedefine HAVE_FPRINTF 1 /* Define to 1 if you have the `fp_class' function. */ #cmakedefine HAVE_FP_CLASS 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_FP_CLASS_H 1 /* Define to 1 if you have the `ftime' function. */ #cmakedefine HAVE_FTIME 1 /* Define to 1 if you have the `gettimeofday' function. */ #cmakedefine HAVE_GETTIMEOFDAY 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_IEEEFP_H 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_INTTYPES_H 1 /* Define if history library is there (-lhistory) */ #cmakedefine HAVE_LIBHISTORY /* Define if readline library is there (-lreadline) */ #cmakedefine HAVE_LIBREADLINE /* Have compression library */ #cmakedefine HAVE_LIBZ 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_LIMITS_H 1 /* Define to 1 if you have the `localtime' function. */ #cmakedefine HAVE_LOCALTIME 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_MALLOC_H 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_MATH_H 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_MEMORY_H 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_NAN_H 1 /* Define to 1 if you have the header file, and it defines `DIR'. */ #cmakedefine HAVE_NDIR_H 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_NETDB_H 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_NETINET_IN_H 1 /* Define to 1 if you have the `printf' function. */ #cmakedefine HAVE_PRINTF 1 /* Define if is there */ #cmakedefine HAVE_PTHREAD_H /* Define to 1 if you have the header file. */ #cmakedefine HAVE_RESOLV_H 1 /* Have shl_load based dso */ #cmakedefine HAVE_SHLLOAD 1 /* Define to 1 if you have the `signal' function. */ #cmakedefine HAVE_SIGNAL 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SIGNAL_H 1 /* Define to 1 if you have the `snprintf' function. */ #cmakedefine HAVE_SNPRINTF 1 /* Define to 1 if you have the `sprintf' function. */ #cmakedefine HAVE_SPRINTF 1 /* Define to 1 if you have the `sscanf' function. */ #cmakedefine HAVE_SSCANF 1 /* Define to 1 if you have the `stat' function. */ #cmakedefine HAVE_STAT 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_STDARG_H 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_STDINT_H 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_STDLIB_H 1 /* Define to 1 if you have the `strdup' function. */ #cmakedefine HAVE_STRDUP 1 /* Define to 1 if you have the `strerror' function. */ #cmakedefine HAVE_STRERROR 1 /* Define to 1 if you have the `strftime' function. */ #cmakedefine HAVE_STRFTIME 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_STRINGS_H 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_STRING_H 1 /* Define to 1 if you have the `strndup' function. */ #cmakedefine HAVE_STRNDUP 1 /* Define to 1 if you have the header file, and it defines `DIR'. */ #cmakedefine HAVE_SYS_DIR_H 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_MMAN_H 1 /* Define to 1 if you have the header file, and it defines `DIR'. */ #cmakedefine HAVE_SYS_NDIR_H 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_SELECT_H 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_SOCKET_H 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_STAT_H 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_TIMEB_H 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_TIME_H 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_TYPES_H 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_TIME_H 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_UNISTD_H 1 /* Whether va_copy() is available */ #cmakedefine HAVE_VA_COPY 1 /* Define to 1 if you have the `vfprintf' function. */ #cmakedefine HAVE_VFPRINTF 1 /* Define to 1 if you have the `vsnprintf' function. */ #cmakedefine HAVE_VSNPRINTF 1 /* Define to 1 if you have the `vsprintf' function. */ #cmakedefine HAVE_VSPRINTF 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_VTK_ZLIB_H /* Define to 1 if you have the header file. */ #cmakedefine HAVE_ZLIB_H 1 /* Define to 1 if you have the `_stat' function. */ #cmakedefine HAVE__STAT 1 /* Whether __va_copy() is available */ #cmakedefine HAVE___VA_COPY 1 /* Name of package */ #cmakedefine PACKAGE "@PACKAGE@" /* Define to the address where bug reports for this package should be sent. */ #define PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@" /* Define to the full name of this package. */ #define PACKAGE_NAME "@PACKAGE_NAME@" /* Define to the full name and version of this package. */ #define PACKAGE_STRING "@PACKAGE_STRING@" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "@PACKAGE_TARNAME@" /* Define to the version of this package. */ #define PACKAGE_VERSION "@PACKAGE_VERSION@" /* Support for IPv6 */ #cmakedefine SUPPORT_IP6 /* Version number of package */ #cmakedefine VERSION "@VERSION@" /* Determine what socket length (socklen_t) data type is */ #cmakedefine XML_SOCKLEN_T @XML_SOCKLEN_T@ /* Using the Win32 Socket implementation */ #cmakedefine _WINSOCKAPI_ /* Win32 Std C name mangling work-around */ #if defined(_MSC_VER) # define snprintf _snprintf #endif /* ss_family is not defined here, use __ss_family instead */ /* #undef ss_family */ /* Win32 Std C name mangling work-around */ #if defined(_MSC_VER) && (_MSC_VER < 1500) # define vsnprintf _vsnprintf #endif xdmf-3.0+git20160803/Utilities/vtklibxml2/pattern.c0000640000175000017500000023256113003006557021775 0ustar alastairalastair/* * pattern.c: Implemetation of selectors for nodes * * Reference: * http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/ * to some extent * http://www.w3.org/TR/1999/REC-xml-19991116 * * See Copyright for the status of this software. * * daniel@veillard.com */ /* * TODO: * - compilation flags to check for specific syntaxes * using flags of xmlPatterncompile() * - making clear how pattern starting with / or . need to be handled, * currently push(NULL, NULL) means a reset of the streaming context * and indicating we are on / (the document node), probably need * something similar for . * - get rid of the "compile" starting with lowercase * - DONE (2006-05-16): get rid of the Strdup/Strndup in case of dictionary */ #define IN_LIBXML #include "libxml.h" #include #include #include #include #include #include #include #include #ifdef LIBXML_PATTERN_ENABLED /* #define DEBUG_STREAMING */ #define ERROR(a, b, c, d) #define ERROR5(a, b, c, d, e) #define XML_STREAM_STEP_DESC 1 #define XML_STREAM_STEP_FINAL 2 #define XML_STREAM_STEP_ROOT 4 #define XML_STREAM_STEP_ATTR 8 #define XML_STREAM_STEP_NODE 16 #define XML_STREAM_STEP_IN_SET 32 /* * NOTE: Those private flags (XML_STREAM_xxx) are used * in _xmlStreamCtxt->flag. They extend the public * xmlPatternFlags, so be carefull not to interfere with the * reserved values for xmlPatternFlags. */ #define XML_STREAM_FINAL_IS_ANY_NODE 1<<14 #define XML_STREAM_FROM_ROOT 1<<15 #define XML_STREAM_DESC 1<<16 /* * XML_STREAM_ANY_NODE is used for comparison against * xmlElementType enums, to indicate a node of any type. */ #define XML_STREAM_ANY_NODE 100 #define XML_PATTERN_NOTPATTERN (XML_PATTERN_XPATH | \ XML_PATTERN_XSSEL | \ XML_PATTERN_XSFIELD) #define XML_STREAM_XS_IDC(c) ((c)->flags & \ (XML_PATTERN_XSSEL | XML_PATTERN_XSFIELD)) #define XML_STREAM_XS_IDC_SEL(c) ((c)->flags & XML_PATTERN_XSSEL) #define XML_STREAM_XS_IDC_FIELD(c) ((c)->flags & XML_PATTERN_XSFIELD) #define XML_PAT_COPY_NSNAME(c, r, nsname) \ if ((c)->comp->dict) \ r = (xmlChar *) xmlDictLookup((c)->comp->dict, BAD_CAST nsname, -1); \ else r = xmlStrdup(BAD_CAST nsname); #define XML_PAT_FREE_STRING(c, r) if ((c)->comp->dict == NULL) xmlFree(r); typedef struct _xmlStreamStep xmlStreamStep; typedef xmlStreamStep *xmlStreamStepPtr; struct _xmlStreamStep { int flags; /* properties of that step */ const xmlChar *name; /* first string value if NULL accept all */ const xmlChar *ns; /* second string value */ int nodeType; /* type of node */ }; typedef struct _xmlStreamComp xmlStreamComp; typedef xmlStreamComp *xmlStreamCompPtr; struct _xmlStreamComp { xmlDict *dict; /* the dictionary if any */ int nbStep; /* number of steps in the automata */ int maxStep; /* allocated number of steps */ xmlStreamStepPtr steps; /* the array of steps */ int flags; }; struct _xmlStreamCtxt { struct _xmlStreamCtxt *next;/* link to next sub pattern if | */ xmlStreamCompPtr comp; /* the compiled stream */ int nbState; /* number of states in the automata */ int maxState; /* allocated number of states */ int level; /* how deep are we ? */ int *states; /* the array of step indexes */ int flags; /* validation options */ int blockLevel; }; static void xmlFreeStreamComp(xmlStreamCompPtr comp); /* * Types are private: */ typedef enum { XML_OP_END=0, XML_OP_ROOT, XML_OP_ELEM, XML_OP_CHILD, XML_OP_ATTR, XML_OP_PARENT, XML_OP_ANCESTOR, XML_OP_NS, XML_OP_ALL } xmlPatOp; typedef struct _xmlStepState xmlStepState; typedef xmlStepState *xmlStepStatePtr; struct _xmlStepState { int step; xmlNodePtr node; }; typedef struct _xmlStepStates xmlStepStates; typedef xmlStepStates *xmlStepStatesPtr; struct _xmlStepStates { int nbstates; int maxstates; xmlStepStatePtr states; }; typedef struct _xmlStepOp xmlStepOp; typedef xmlStepOp *xmlStepOpPtr; struct _xmlStepOp { xmlPatOp op; const xmlChar *value; const xmlChar *value2; /* The namespace name */ }; #define PAT_FROM_ROOT (1<<8) #define PAT_FROM_CUR (1<<9) struct _xmlPattern { void *data; /* the associated template */ xmlDictPtr dict; /* the optional dictionary */ struct _xmlPattern *next; /* next pattern if | is used */ const xmlChar *pattern; /* the pattern */ int flags; /* flags */ int nbStep; int maxStep; xmlStepOpPtr steps; /* ops for computation */ xmlStreamCompPtr stream; /* the streaming data if any */ }; typedef struct _xmlPatParserContext xmlPatParserContext; typedef xmlPatParserContext *xmlPatParserContextPtr; struct _xmlPatParserContext { const xmlChar *cur; /* the current char being parsed */ const xmlChar *base; /* the full expression */ int error; /* error code */ xmlDictPtr dict; /* the dictionary if any */ xmlPatternPtr comp; /* the result */ xmlNodePtr elem; /* the current node if any */ const xmlChar **namespaces; /* the namespaces definitions */ int nb_namespaces; /* the number of namespaces */ }; /************************************************************************ * * * Type functions * * * ************************************************************************/ /** * xmlNewPattern: * * Create a new XSLT Pattern * * Returns the newly allocated xmlPatternPtr or NULL in case of error */ static xmlPatternPtr xmlNewPattern(void) { xmlPatternPtr cur; cur = (xmlPatternPtr) xmlMalloc(sizeof(xmlPattern)); if (cur == NULL) { ERROR(NULL, NULL, NULL, "xmlNewPattern : malloc failed\n"); return(NULL); } memset(cur, 0, sizeof(xmlPattern)); cur->maxStep = 10; cur->steps = (xmlStepOpPtr) xmlMalloc(cur->maxStep * sizeof(xmlStepOp)); if (cur->steps == NULL) { xmlFree(cur); ERROR(NULL, NULL, NULL, "xmlNewPattern : malloc failed\n"); return(NULL); } return(cur); } /** * xmlFreePattern: * @comp: an XSLT comp * * Free up the memory allocated by @comp */ void xmlFreePattern(xmlPatternPtr comp) { xmlStepOpPtr op; int i; if (comp == NULL) return; if (comp->next != NULL) xmlFreePattern(comp->next); if (comp->stream != NULL) xmlFreeStreamComp(comp->stream); if (comp->pattern != NULL) xmlFree((xmlChar *)comp->pattern); if (comp->steps != NULL) { if (comp->dict == NULL) { for (i = 0;i < comp->nbStep;i++) { op = &comp->steps[i]; if (op->value != NULL) xmlFree((xmlChar *) op->value); if (op->value2 != NULL) xmlFree((xmlChar *) op->value2); } } xmlFree(comp->steps); } if (comp->dict != NULL) xmlDictFree(comp->dict); memset(comp, -1, sizeof(xmlPattern)); xmlFree(comp); } /** * xmlFreePatternList: * @comp: an XSLT comp list * * Free up the memory allocated by all the elements of @comp */ void xmlFreePatternList(xmlPatternPtr comp) { xmlPatternPtr cur; while (comp != NULL) { cur = comp; comp = comp->next; cur->next = NULL; xmlFreePattern(cur); } } /** * xmlNewPatParserContext: * @pattern: the pattern context * @dict: the inherited dictionary or NULL * @namespaces: the prefix definitions, array of [URI, prefix] terminated * with [NULL, NULL] or NULL if no namespace is used * * Create a new XML pattern parser context * * Returns the newly allocated xmlPatParserContextPtr or NULL in case of error */ static xmlPatParserContextPtr xmlNewPatParserContext(const xmlChar *pattern, xmlDictPtr dict, const xmlChar **namespaces) { xmlPatParserContextPtr cur; if (pattern == NULL) return(NULL); cur = (xmlPatParserContextPtr) xmlMalloc(sizeof(xmlPatParserContext)); if (cur == NULL) { ERROR(NULL, NULL, NULL, "xmlNewPatParserContext : malloc failed\n"); return(NULL); } memset(cur, 0, sizeof(xmlPatParserContext)); cur->dict = dict; cur->cur = pattern; cur->base = pattern; if (namespaces != NULL) { int i; for (i = 0;namespaces[2 * i] != NULL;i++); cur->nb_namespaces = i; } else { cur->nb_namespaces = 0; } cur->namespaces = namespaces; return(cur); } /** * xmlFreePatParserContext: * @ctxt: an XSLT parser context * * Free up the memory allocated by @ctxt */ static void xmlFreePatParserContext(xmlPatParserContextPtr ctxt) { if (ctxt == NULL) return; memset(ctxt, -1, sizeof(xmlPatParserContext)); xmlFree(ctxt); } /** * xmlPatternAdd: * @comp: the compiled match expression * @op: an op * @value: the first value * @value2: the second value * * Add a step to an XSLT Compiled Match * * Returns -1 in case of failure, 0 otherwise. */ static int xmlPatternAdd(xmlPatParserContextPtr ctxt ATTRIBUTE_UNUSED, xmlPatternPtr comp, xmlPatOp op, xmlChar * value, xmlChar * value2) { if (comp->nbStep >= comp->maxStep) { xmlStepOpPtr temp; temp = (xmlStepOpPtr) xmlRealloc(comp->steps, comp->maxStep * 2 * sizeof(xmlStepOp)); if (temp == NULL) { ERROR(ctxt, NULL, NULL, "xmlPatternAdd: realloc failed\n"); return (-1); } comp->steps = temp; comp->maxStep *= 2; } comp->steps[comp->nbStep].op = op; comp->steps[comp->nbStep].value = value; comp->steps[comp->nbStep].value2 = value2; comp->nbStep++; return (0); } #if 0 /** * xsltSwapTopPattern: * @comp: the compiled match expression * * reverse the two top steps. */ static void xsltSwapTopPattern(xmlPatternPtr comp) { int i; int j = comp->nbStep - 1; if (j > 0) { register const xmlChar *tmp; register xmlPatOp op; i = j - 1; tmp = comp->steps[i].value; comp->steps[i].value = comp->steps[j].value; comp->steps[j].value = tmp; tmp = comp->steps[i].value2; comp->steps[i].value2 = comp->steps[j].value2; comp->steps[j].value2 = tmp; op = comp->steps[i].op; comp->steps[i].op = comp->steps[j].op; comp->steps[j].op = op; } } #endif /** * xmlReversePattern: * @comp: the compiled match expression * * reverse all the stack of expressions * * returns 0 in case of success and -1 in case of error. */ static int xmlReversePattern(xmlPatternPtr comp) { int i, j; /* * remove the leading // for //a or .//a */ if ((comp->nbStep > 0) && (comp->steps[0].op == XML_OP_ANCESTOR)) { for (i = 0, j = 1;j < comp->nbStep;i++,j++) { comp->steps[i].value = comp->steps[j].value; comp->steps[i].value2 = comp->steps[j].value2; comp->steps[i].op = comp->steps[j].op; } comp->nbStep--; } if (comp->nbStep >= comp->maxStep) { xmlStepOpPtr temp; temp = (xmlStepOpPtr) xmlRealloc(comp->steps, comp->maxStep * 2 * sizeof(xmlStepOp)); if (temp == NULL) { ERROR(ctxt, NULL, NULL, "xmlReversePattern: realloc failed\n"); return (-1); } comp->steps = temp; comp->maxStep *= 2; } i = 0; j = comp->nbStep - 1; while (j > i) { register const xmlChar *tmp; register xmlPatOp op; tmp = comp->steps[i].value; comp->steps[i].value = comp->steps[j].value; comp->steps[j].value = tmp; tmp = comp->steps[i].value2; comp->steps[i].value2 = comp->steps[j].value2; comp->steps[j].value2 = tmp; op = comp->steps[i].op; comp->steps[i].op = comp->steps[j].op; comp->steps[j].op = op; j--; i++; } comp->steps[comp->nbStep].value = NULL; comp->steps[comp->nbStep].value2 = NULL; comp->steps[comp->nbStep++].op = XML_OP_END; return(0); } /************************************************************************ * * * The interpreter for the precompiled patterns * * * ************************************************************************/ static int xmlPatPushState(xmlStepStates *states, int step, xmlNodePtr node) { if ((states->states == NULL) || (states->maxstates <= 0)) { states->maxstates = 4; states->nbstates = 0; states->states = xmlMalloc(4 * sizeof(xmlStepState)); } else if (states->maxstates <= states->nbstates) { xmlStepState *tmp; tmp = (xmlStepStatePtr) xmlRealloc(states->states, 2 * states->maxstates * sizeof(xmlStepState)); if (tmp == NULL) return(-1); states->states = tmp; states->maxstates *= 2; } states->states[states->nbstates].step = step; states->states[states->nbstates++].node = node; #if 0 fprintf(stderr, "Push: %d, %s\n", step, node->name); #endif return(0); } /** * xmlPatMatch: * @comp: the precompiled pattern * @node: a node * * Test whether the node matches the pattern * * Returns 1 if it matches, 0 if it doesn't and -1 in case of failure */ static int xmlPatMatch(xmlPatternPtr comp, xmlNodePtr node) { int i; xmlStepOpPtr step; xmlStepStates states = {0, 0, NULL}; /* // may require backtrack */ if ((comp == NULL) || (node == NULL)) return(-1); i = 0; restart: for (;i < comp->nbStep;i++) { step = &comp->steps[i]; switch (step->op) { case XML_OP_END: goto found; case XML_OP_ROOT: if (node->type == XML_NAMESPACE_DECL) goto rollback; node = node->parent; if ((node->type == XML_DOCUMENT_NODE) || #ifdef LIBXML_DOCB_ENABLED (node->type == XML_DOCB_DOCUMENT_NODE) || #endif (node->type == XML_HTML_DOCUMENT_NODE)) continue; goto rollback; case XML_OP_ELEM: if (node->type != XML_ELEMENT_NODE) goto rollback; if (step->value == NULL) continue; if (step->value[0] != node->name[0]) goto rollback; if (!xmlStrEqual(step->value, node->name)) goto rollback; /* Namespace test */ if (node->ns == NULL) { if (step->value2 != NULL) goto rollback; } else if (node->ns->href != NULL) { if (step->value2 == NULL) goto rollback; if (!xmlStrEqual(step->value2, node->ns->href)) goto rollback; } continue; case XML_OP_CHILD: { xmlNodePtr lst; if ((node->type != XML_ELEMENT_NODE) && (node->type != XML_DOCUMENT_NODE) && #ifdef LIBXML_DOCB_ENABLED (node->type != XML_DOCB_DOCUMENT_NODE) && #endif (node->type != XML_HTML_DOCUMENT_NODE)) goto rollback; lst = node->children; if (step->value != NULL) { while (lst != NULL) { if ((lst->type == XML_ELEMENT_NODE) && (step->value[0] == lst->name[0]) && (xmlStrEqual(step->value, lst->name))) break; lst = lst->next; } if (lst != NULL) continue; } goto rollback; } case XML_OP_ATTR: if (node->type != XML_ATTRIBUTE_NODE) goto rollback; if (step->value != NULL) { if (step->value[0] != node->name[0]) goto rollback; if (!xmlStrEqual(step->value, node->name)) goto rollback; } /* Namespace test */ if (node->ns == NULL) { if (step->value2 != NULL) goto rollback; } else if (step->value2 != NULL) { if (!xmlStrEqual(step->value2, node->ns->href)) goto rollback; } continue; case XML_OP_PARENT: if ((node->type == XML_DOCUMENT_NODE) || (node->type == XML_HTML_DOCUMENT_NODE) || #ifdef LIBXML_DOCB_ENABLED (node->type == XML_DOCB_DOCUMENT_NODE) || #endif (node->type == XML_NAMESPACE_DECL)) goto rollback; node = node->parent; if (node == NULL) goto rollback; if (step->value == NULL) continue; if (step->value[0] != node->name[0]) goto rollback; if (!xmlStrEqual(step->value, node->name)) goto rollback; /* Namespace test */ if (node->ns == NULL) { if (step->value2 != NULL) goto rollback; } else if (node->ns->href != NULL) { if (step->value2 == NULL) goto rollback; if (!xmlStrEqual(step->value2, node->ns->href)) goto rollback; } continue; case XML_OP_ANCESTOR: /* TODO: implement coalescing of ANCESTOR/NODE ops */ if (step->value == NULL) { i++; step = &comp->steps[i]; if (step->op == XML_OP_ROOT) goto found; if (step->op != XML_OP_ELEM) goto rollback; if (step->value == NULL) return(-1); } if (node == NULL) goto rollback; if ((node->type == XML_DOCUMENT_NODE) || (node->type == XML_HTML_DOCUMENT_NODE) || #ifdef LIBXML_DOCB_ENABLED (node->type == XML_DOCB_DOCUMENT_NODE) || #endif (node->type == XML_NAMESPACE_DECL)) goto rollback; node = node->parent; while (node != NULL) { if ((node->type == XML_ELEMENT_NODE) && (step->value[0] == node->name[0]) && (xmlStrEqual(step->value, node->name))) { /* Namespace test */ if (node->ns == NULL) { if (step->value2 == NULL) break; } else if (node->ns->href != NULL) { if ((step->value2 != NULL) && (xmlStrEqual(step->value2, node->ns->href))) break; } } node = node->parent; } if (node == NULL) goto rollback; /* * prepare a potential rollback from here * for ancestors of that node. */ if (step->op == XML_OP_ANCESTOR) xmlPatPushState(&states, i, node); else xmlPatPushState(&states, i - 1, node); continue; case XML_OP_NS: if (node->type != XML_ELEMENT_NODE) goto rollback; if (node->ns == NULL) { if (step->value != NULL) goto rollback; } else if (node->ns->href != NULL) { if (step->value == NULL) goto rollback; if (!xmlStrEqual(step->value, node->ns->href)) goto rollback; } break; case XML_OP_ALL: if (node->type != XML_ELEMENT_NODE) goto rollback; break; } } found: if (states.states != NULL) { /* Free the rollback states */ xmlFree(states.states); } return(1); rollback: /* got an error try to rollback */ if (states.states == NULL) return(0); if (states.nbstates <= 0) { xmlFree(states.states); return(0); } states.nbstates--; i = states.states[states.nbstates].step; node = states.states[states.nbstates].node; #if 0 fprintf(stderr, "Pop: %d, %s\n", i, node->name); #endif goto restart; } /************************************************************************ * * * Dedicated parser for templates * * * ************************************************************************/ #define TODO \ xmlGenericError(xmlGenericErrorContext, \ "Unimplemented block at %s:%d\n", \ __FILE__, __LINE__); #define CUR (*ctxt->cur) #define SKIP(val) ctxt->cur += (val) #define NXT(val) ctxt->cur[(val)] #define PEEKPREV(val) ctxt->cur[-(val)] #define CUR_PTR ctxt->cur #define SKIP_BLANKS \ while (IS_BLANK_CH(CUR)) NEXT #define CURRENT (*ctxt->cur) #define NEXT ((*ctxt->cur) ? ctxt->cur++: ctxt->cur) #define PUSH(op, val, val2) \ if (xmlPatternAdd(ctxt, ctxt->comp, (op), (val), (val2))) goto error; #define XSLT_ERROR(X) \ { xsltError(ctxt, __FILE__, __LINE__, X); \ ctxt->error = (X); return; } #define XSLT_ERROR0(X) \ { xsltError(ctxt, __FILE__, __LINE__, X); \ ctxt->error = (X); return(0); } #if 0 /** * xmlPatScanLiteral: * @ctxt: the XPath Parser context * * Parse an XPath Litteral: * * [29] Literal ::= '"' [^"]* '"' * | "'" [^']* "'" * * Returns the Literal parsed or NULL */ static xmlChar * xmlPatScanLiteral(xmlPatParserContextPtr ctxt) { const xmlChar *q, *cur; xmlChar *ret = NULL; int val, len; SKIP_BLANKS; if (CUR == '"') { NEXT; cur = q = CUR_PTR; val = xmlStringCurrentChar(NULL, cur, &len); while ((IS_CHAR(val)) && (val != '"')) { cur += len; val = xmlStringCurrentChar(NULL, cur, &len); } if (!IS_CHAR(val)) { ctxt->error = 1; return(NULL); } else { if (ctxt->dict) ret = (xmlChar *) xmlDictLookup(ctxt->dict, q, cur - q); else ret = xmlStrndup(q, cur - q); } cur += len; CUR_PTR = cur; } else if (CUR == '\'') { NEXT; cur = q = CUR_PTR; val = xmlStringCurrentChar(NULL, cur, &len); while ((IS_CHAR(val)) && (val != '\'')) { cur += len; val = xmlStringCurrentChar(NULL, cur, &len); } if (!IS_CHAR(val)) { ctxt->error = 1; return(NULL); } else { if (ctxt->dict) ret = (xmlChar *) xmlDictLookup(ctxt->dict, q, cur - q); else ret = xmlStrndup(q, cur - q); } cur += len; CUR_PTR = cur; } else { /* XP_ERROR(XPATH_START_LITERAL_ERROR); */ ctxt->error = 1; return(NULL); } return(ret); } #endif /** * xmlPatScanName: * @ctxt: the XPath Parser context * * [4] NameChar ::= Letter | Digit | '.' | '-' | '_' | * CombiningChar | Extender * * [5] Name ::= (Letter | '_' | ':') (NameChar)* * * [6] Names ::= Name (S Name)* * * Returns the Name parsed or NULL */ static xmlChar * xmlPatScanName(xmlPatParserContextPtr ctxt) { const xmlChar *q, *cur; xmlChar *ret = NULL; int val, len; SKIP_BLANKS; cur = q = CUR_PTR; val = xmlStringCurrentChar(NULL, cur, &len); if (!IS_LETTER(val) && (val != '_') && (val != ':')) return(NULL); while ((IS_LETTER(val)) || (IS_DIGIT(val)) || (val == '.') || (val == '-') || (val == '_') || (IS_COMBINING(val)) || (IS_EXTENDER(val))) { cur += len; val = xmlStringCurrentChar(NULL, cur, &len); } if (ctxt->dict) ret = (xmlChar *) xmlDictLookup(ctxt->dict, q, cur - q); else ret = xmlStrndup(q, cur - q); CUR_PTR = cur; return(ret); } /** * xmlPatScanNCName: * @ctxt: the XPath Parser context * * Parses a non qualified name * * Returns the Name parsed or NULL */ static xmlChar * xmlPatScanNCName(xmlPatParserContextPtr ctxt) { const xmlChar *q, *cur; xmlChar *ret = NULL; int val, len; SKIP_BLANKS; cur = q = CUR_PTR; val = xmlStringCurrentChar(NULL, cur, &len); if (!IS_LETTER(val) && (val != '_')) return(NULL); while ((IS_LETTER(val)) || (IS_DIGIT(val)) || (val == '.') || (val == '-') || (val == '_') || (IS_COMBINING(val)) || (IS_EXTENDER(val))) { cur += len; val = xmlStringCurrentChar(NULL, cur, &len); } if (ctxt->dict) ret = (xmlChar *) xmlDictLookup(ctxt->dict, q, cur - q); else ret = xmlStrndup(q, cur - q); CUR_PTR = cur; return(ret); } #if 0 /** * xmlPatScanQName: * @ctxt: the XPath Parser context * @prefix: the place to store the prefix * * Parse a qualified name * * Returns the Name parsed or NULL */ static xmlChar * xmlPatScanQName(xmlPatParserContextPtr ctxt, xmlChar **prefix) { xmlChar *ret = NULL; *prefix = NULL; ret = xmlPatScanNCName(ctxt); if (CUR == ':') { *prefix = ret; NEXT; ret = xmlPatScanNCName(ctxt); } return(ret); } #endif /** * xmlCompileAttributeTest: * @ctxt: the compilation context * * Compile an attribute test. */ static void xmlCompileAttributeTest(xmlPatParserContextPtr ctxt) { xmlChar *token = NULL; xmlChar *name = NULL; xmlChar *URL = NULL; SKIP_BLANKS; name = xmlPatScanNCName(ctxt); if (name == NULL) { if (CUR == '*') { PUSH(XML_OP_ATTR, NULL, NULL); NEXT; } else { ERROR(NULL, NULL, NULL, "xmlCompileAttributeTest : Name expected\n"); ctxt->error = 1; } return; } if (CUR == ':') { int i; xmlChar *prefix = name; NEXT; if (IS_BLANK_CH(CUR)) { ERROR5(NULL, NULL, NULL, "Invalid QName.\n", NULL); XML_PAT_FREE_STRING(ctxt, prefix); ctxt->error = 1; goto error; } /* * This is a namespace match */ token = xmlPatScanName(ctxt); if ((prefix[0] == 'x') && (prefix[1] == 'm') && (prefix[2] == 'l') && (prefix[3] == 0)) { XML_PAT_COPY_NSNAME(ctxt, URL, XML_XML_NAMESPACE); } else { for (i = 0;i < ctxt->nb_namespaces;i++) { if (xmlStrEqual(ctxt->namespaces[2 * i + 1], prefix)) { XML_PAT_COPY_NSNAME(ctxt, URL, ctxt->namespaces[2 * i]) break; } } if (i >= ctxt->nb_namespaces) { ERROR5(NULL, NULL, NULL, "xmlCompileAttributeTest : no namespace bound to prefix %s\n", prefix); ctxt->error = 1; goto error; } } XML_PAT_FREE_STRING(ctxt, prefix); if (token == NULL) { if (CUR == '*') { NEXT; PUSH(XML_OP_ATTR, NULL, URL); } else { ERROR(NULL, NULL, NULL, "xmlCompileAttributeTest : Name expected\n"); ctxt->error = 1; goto error; } } else { PUSH(XML_OP_ATTR, token, URL); } } else { PUSH(XML_OP_ATTR, name, NULL); } return; error: if (URL != NULL) XML_PAT_FREE_STRING(ctxt, URL) if (token != NULL) XML_PAT_FREE_STRING(ctxt, token); } /** * xmlCompileStepPattern: * @ctxt: the compilation context * * Compile the Step Pattern and generates a precompiled * form suitable for fast matching. * * [3] Step ::= '.' | NameTest * [4] NameTest ::= QName | '*' | NCName ':' '*' */ static void xmlCompileStepPattern(xmlPatParserContextPtr ctxt) { xmlChar *token = NULL; xmlChar *name = NULL; xmlChar *URL = NULL; int hasBlanks = 0; SKIP_BLANKS; if (CUR == '.') { /* * Context node. */ NEXT; PUSH(XML_OP_ELEM, NULL, NULL); return; } if (CUR == '@') { /* * Attribute test. */ if (XML_STREAM_XS_IDC_SEL(ctxt->comp)) { ERROR5(NULL, NULL, NULL, "Unexpected attribute axis in '%s'.\n", ctxt->base); ctxt->error = 1; return; } NEXT; xmlCompileAttributeTest(ctxt); if (ctxt->error != 0) goto error; return; } name = xmlPatScanNCName(ctxt); if (name == NULL) { if (CUR == '*') { NEXT; PUSH(XML_OP_ALL, NULL, NULL); return; } else { ERROR(NULL, NULL, NULL, "xmlCompileStepPattern : Name expected\n"); ctxt->error = 1; return; } } if (IS_BLANK_CH(CUR)) { hasBlanks = 1; SKIP_BLANKS; } if (CUR == ':') { NEXT; if (CUR != ':') { xmlChar *prefix = name; int i; if (hasBlanks || IS_BLANK_CH(CUR)) { ERROR5(NULL, NULL, NULL, "Invalid QName.\n", NULL); ctxt->error = 1; goto error; } /* * This is a namespace match */ token = xmlPatScanName(ctxt); if ((prefix[0] == 'x') && (prefix[1] == 'm') && (prefix[2] == 'l') && (prefix[3] == 0)) { XML_PAT_COPY_NSNAME(ctxt, URL, XML_XML_NAMESPACE) } else { for (i = 0;i < ctxt->nb_namespaces;i++) { if (xmlStrEqual(ctxt->namespaces[2 * i + 1], prefix)) { XML_PAT_COPY_NSNAME(ctxt, URL, ctxt->namespaces[2 * i]) break; } } if (i >= ctxt->nb_namespaces) { ERROR5(NULL, NULL, NULL, "xmlCompileStepPattern : no namespace bound to prefix %s\n", prefix); ctxt->error = 1; goto error; } } XML_PAT_FREE_STRING(ctxt, prefix); if (token == NULL) { if (CUR == '*') { NEXT; PUSH(XML_OP_NS, URL, NULL); } else { ERROR(NULL, NULL, NULL, "xmlCompileStepPattern : Name expected\n"); ctxt->error = 1; goto error; } } else { PUSH(XML_OP_ELEM, token, URL); } } else { NEXT; if (xmlStrEqual(name, (const xmlChar *) "child")) { XML_PAT_FREE_STRING(ctxt, name); name = xmlPatScanName(ctxt); if (name == NULL) { if (CUR == '*') { NEXT; PUSH(XML_OP_ALL, NULL, NULL); return; } else { ERROR(NULL, NULL, NULL, "xmlCompileStepPattern : QName expected\n"); ctxt->error = 1; goto error; } } if (CUR == ':') { xmlChar *prefix = name; int i; NEXT; if (IS_BLANK_CH(CUR)) { ERROR5(NULL, NULL, NULL, "Invalid QName.\n", NULL); ctxt->error = 1; goto error; } /* * This is a namespace match */ token = xmlPatScanName(ctxt); if ((prefix[0] == 'x') && (prefix[1] == 'm') && (prefix[2] == 'l') && (prefix[3] == 0)) { XML_PAT_COPY_NSNAME(ctxt, URL, XML_XML_NAMESPACE) } else { for (i = 0;i < ctxt->nb_namespaces;i++) { if (xmlStrEqual(ctxt->namespaces[2 * i + 1], prefix)) { XML_PAT_COPY_NSNAME(ctxt, URL, ctxt->namespaces[2 * i]) break; } } if (i >= ctxt->nb_namespaces) { ERROR5(NULL, NULL, NULL, "xmlCompileStepPattern : no namespace bound " "to prefix %s\n", prefix); ctxt->error = 1; goto error; } } XML_PAT_FREE_STRING(ctxt, prefix); if (token == NULL) { if (CUR == '*') { NEXT; PUSH(XML_OP_NS, URL, NULL); } else { ERROR(NULL, NULL, NULL, "xmlCompileStepPattern : Name expected\n"); ctxt->error = 1; goto error; } } else { PUSH(XML_OP_CHILD, token, URL); } } else PUSH(XML_OP_CHILD, name, NULL); return; } else if (xmlStrEqual(name, (const xmlChar *) "attribute")) { XML_PAT_FREE_STRING(ctxt, name) name = NULL; if (XML_STREAM_XS_IDC_SEL(ctxt->comp)) { ERROR5(NULL, NULL, NULL, "Unexpected attribute axis in '%s'.\n", ctxt->base); ctxt->error = 1; goto error; } xmlCompileAttributeTest(ctxt); if (ctxt->error != 0) goto error; return; } else { ERROR5(NULL, NULL, NULL, "The 'element' or 'attribute' axis is expected.\n", NULL); ctxt->error = 1; goto error; } } } else if (CUR == '*') { if (name != NULL) { ctxt->error = 1; goto error; } NEXT; PUSH(XML_OP_ALL, token, NULL); } else { PUSH(XML_OP_ELEM, name, NULL); } return; error: if (URL != NULL) XML_PAT_FREE_STRING(ctxt, URL) if (token != NULL) XML_PAT_FREE_STRING(ctxt, token) if (name != NULL) XML_PAT_FREE_STRING(ctxt, name) } /** * xmlCompilePathPattern: * @ctxt: the compilation context * * Compile the Path Pattern and generates a precompiled * form suitable for fast matching. * * [5] Path ::= ('.//')? ( Step '/' )* ( Step | '@' NameTest ) */ static void xmlCompilePathPattern(xmlPatParserContextPtr ctxt) { SKIP_BLANKS; if (CUR == '/') { ctxt->comp->flags |= PAT_FROM_ROOT; } else if ((CUR == '.') || (ctxt->comp->flags & XML_PATTERN_NOTPATTERN)) { ctxt->comp->flags |= PAT_FROM_CUR; } if ((CUR == '/') && (NXT(1) == '/')) { PUSH(XML_OP_ANCESTOR, NULL, NULL); NEXT; NEXT; } else if ((CUR == '.') && (NXT(1) == '/') && (NXT(2) == '/')) { PUSH(XML_OP_ANCESTOR, NULL, NULL); NEXT; NEXT; NEXT; /* Check for incompleteness. */ SKIP_BLANKS; if (CUR == 0) { ERROR5(NULL, NULL, NULL, "Incomplete expression '%s'.\n", ctxt->base); ctxt->error = 1; goto error; } } if (CUR == '@') { NEXT; xmlCompileAttributeTest(ctxt); SKIP_BLANKS; /* TODO: check for incompleteness */ if (CUR != 0) { xmlCompileStepPattern(ctxt); if (ctxt->error != 0) goto error; } } else { if (CUR == '/') { PUSH(XML_OP_ROOT, NULL, NULL); NEXT; /* Check for incompleteness. */ SKIP_BLANKS; if (CUR == 0) { ERROR5(NULL, NULL, NULL, "Incomplete expression '%s'.\n", ctxt->base); ctxt->error = 1; goto error; } } xmlCompileStepPattern(ctxt); if (ctxt->error != 0) goto error; SKIP_BLANKS; while (CUR == '/') { if (NXT(1) == '/') { PUSH(XML_OP_ANCESTOR, NULL, NULL); NEXT; NEXT; SKIP_BLANKS; xmlCompileStepPattern(ctxt); if (ctxt->error != 0) goto error; } else { PUSH(XML_OP_PARENT, NULL, NULL); NEXT; SKIP_BLANKS; if (CUR == 0) { ERROR5(NULL, NULL, NULL, "Incomplete expression '%s'.\n", ctxt->base); ctxt->error = 1; goto error; } xmlCompileStepPattern(ctxt); if (ctxt->error != 0) goto error; } } } if (CUR != 0) { ERROR5(NULL, NULL, NULL, "Failed to compile pattern %s\n", ctxt->base); ctxt->error = 1; } error: return; } /** * xmlCompileIDCXPathPath: * @ctxt: the compilation context * * Compile the Path Pattern and generates a precompiled * form suitable for fast matching. * * [5] Path ::= ('.//')? ( Step '/' )* ( Step | '@' NameTest ) */ static void xmlCompileIDCXPathPath(xmlPatParserContextPtr ctxt) { SKIP_BLANKS; if (CUR == '/') { ERROR5(NULL, NULL, NULL, "Unexpected selection of the document root in '%s'.\n", ctxt->base); goto error; } ctxt->comp->flags |= PAT_FROM_CUR; if (CUR == '.') { /* "." - "self::node()" */ NEXT; SKIP_BLANKS; if (CUR == 0) { /* * Selection of the context node. */ PUSH(XML_OP_ELEM, NULL, NULL); return; } if (CUR != '/') { /* TODO: A more meaningful error message. */ ERROR5(NULL, NULL, NULL, "Unexpected token after '.' in '%s'.\n", ctxt->base); goto error; } /* "./" - "self::node()/" */ NEXT; SKIP_BLANKS; if (CUR == '/') { if (IS_BLANK_CH(PEEKPREV(1))) { /* * Disallow "./ /" */ ERROR5(NULL, NULL, NULL, "Unexpected '/' token in '%s'.\n", ctxt->base); goto error; } /* ".//" - "self:node()/descendant-or-self::node()/" */ PUSH(XML_OP_ANCESTOR, NULL, NULL); NEXT; SKIP_BLANKS; } if (CUR == 0) goto error_unfinished; } /* * Process steps. */ do { xmlCompileStepPattern(ctxt); if (ctxt->error != 0) goto error; SKIP_BLANKS; if (CUR != '/') break; PUSH(XML_OP_PARENT, NULL, NULL); NEXT; SKIP_BLANKS; if (CUR == '/') { /* * Disallow subsequent '//'. */ ERROR5(NULL, NULL, NULL, "Unexpected subsequent '//' in '%s'.\n", ctxt->base); goto error; } if (CUR == 0) goto error_unfinished; } while (CUR != 0); if (CUR != 0) { ERROR5(NULL, NULL, NULL, "Failed to compile expression '%s'.\n", ctxt->base); ctxt->error = 1; } return; error: ctxt->error = 1; return; error_unfinished: ctxt->error = 1; ERROR5(NULL, NULL, NULL, "Unfinished expression '%s'.\n", ctxt->base); return; } /************************************************************************ * * * The streaming code * * * ************************************************************************/ #ifdef DEBUG_STREAMING static void xmlDebugStreamComp(xmlStreamCompPtr stream) { int i; if (stream == NULL) { printf("Stream: NULL\n"); return; } printf("Stream: %d steps\n", stream->nbStep); for (i = 0;i < stream->nbStep;i++) { if (stream->steps[i].ns != NULL) { printf("{%s}", stream->steps[i].ns); } if (stream->steps[i].name == NULL) { printf("* "); } else { printf("%s ", stream->steps[i].name); } if (stream->steps[i].flags & XML_STREAM_STEP_ROOT) printf("root "); if (stream->steps[i].flags & XML_STREAM_STEP_DESC) printf("// "); if (stream->steps[i].flags & XML_STREAM_STEP_FINAL) printf("final "); printf("\n"); } } static void xmlDebugStreamCtxt(xmlStreamCtxtPtr ctxt, int match) { int i; if (ctxt == NULL) { printf("Stream: NULL\n"); return; } printf("Stream: level %d, %d states: ", ctxt->level, ctxt->nbState); if (match) printf("matches\n"); else printf("\n"); for (i = 0;i < ctxt->nbState;i++) { if (ctxt->states[2 * i] < 0) printf(" %d: free\n", i); else { printf(" %d: step %d, level %d", i, ctxt->states[2 * i], ctxt->states[(2 * i) + 1]); if (ctxt->comp->steps[ctxt->states[2 * i]].flags & XML_STREAM_STEP_DESC) printf(" //\n"); else printf("\n"); } } } #endif /** * xmlNewStreamComp: * @size: the number of expected steps * * build a new compiled pattern for streaming * * Returns the new structure or NULL in case of error. */ static xmlStreamCompPtr xmlNewStreamComp(int size) { xmlStreamCompPtr cur; if (size < 4) size = 4; cur = (xmlStreamCompPtr) xmlMalloc(sizeof(xmlStreamComp)); if (cur == NULL) { ERROR(NULL, NULL, NULL, "xmlNewStreamComp: malloc failed\n"); return(NULL); } memset(cur, 0, sizeof(xmlStreamComp)); cur->steps = (xmlStreamStepPtr) xmlMalloc(size * sizeof(xmlStreamStep)); if (cur->steps == NULL) { xmlFree(cur); ERROR(NULL, NULL, NULL, "xmlNewStreamComp: malloc failed\n"); return(NULL); } cur->nbStep = 0; cur->maxStep = size; return(cur); } /** * xmlFreeStreamComp: * @comp: the compiled pattern for streaming * * Free the compiled pattern for streaming */ static void xmlFreeStreamComp(xmlStreamCompPtr comp) { if (comp != NULL) { if (comp->steps != NULL) xmlFree(comp->steps); if (comp->dict != NULL) xmlDictFree(comp->dict); xmlFree(comp); } } /** * xmlStreamCompAddStep: * @comp: the compiled pattern for streaming * @name: the first string, the name, or NULL for * * @ns: the second step, the namespace name * @flags: the flags for that step * * Add a new step to the compiled pattern * * Returns -1 in case of error or the step index if successful */ static int xmlStreamCompAddStep(xmlStreamCompPtr comp, const xmlChar *name, const xmlChar *ns, int nodeType, int flags) { xmlStreamStepPtr cur; if (comp->nbStep >= comp->maxStep) { cur = (xmlStreamStepPtr) xmlRealloc(comp->steps, comp->maxStep * 2 * sizeof(xmlStreamStep)); if (cur == NULL) { ERROR(NULL, NULL, NULL, "xmlNewStreamComp: malloc failed\n"); return(-1); } comp->steps = cur; comp->maxStep *= 2; } cur = &comp->steps[comp->nbStep++]; cur->flags = flags; cur->name = name; cur->ns = ns; cur->nodeType = nodeType; return(comp->nbStep - 1); } /** * xmlStreamCompile: * @comp: the precompiled pattern * * Tries to stream compile a pattern * * Returns -1 in case of failure and 0 in case of success. */ static int xmlStreamCompile(xmlPatternPtr comp) { xmlStreamCompPtr stream; int i, s = 0, root = 0, flags = 0, prevs = -1; xmlStepOp step; if ((comp == NULL) || (comp->steps == NULL)) return(-1); /* * special case for . */ if ((comp->nbStep == 1) && (comp->steps[0].op == XML_OP_ELEM) && (comp->steps[0].value == NULL) && (comp->steps[0].value2 == NULL)) { stream = xmlNewStreamComp(0); if (stream == NULL) return(-1); /* Note that the stream will have no steps in this case. */ stream->flags |= XML_STREAM_FINAL_IS_ANY_NODE; comp->stream = stream; return(0); } stream = xmlNewStreamComp((comp->nbStep / 2) + 1); if (stream == NULL) return(-1); if (comp->dict != NULL) { stream->dict = comp->dict; xmlDictReference(stream->dict); } i = 0; if (comp->flags & PAT_FROM_ROOT) stream->flags |= XML_STREAM_FROM_ROOT; for (;i < comp->nbStep;i++) { step = comp->steps[i]; switch (step.op) { case XML_OP_END: break; case XML_OP_ROOT: if (i != 0) goto error; root = 1; break; case XML_OP_NS: s = xmlStreamCompAddStep(stream, NULL, step.value, XML_ELEMENT_NODE, flags); if (s < 0) goto error; prevs = s; flags = 0; break; case XML_OP_ATTR: flags |= XML_STREAM_STEP_ATTR; prevs = -1; s = xmlStreamCompAddStep(stream, step.value, step.value2, XML_ATTRIBUTE_NODE, flags); flags = 0; if (s < 0) goto error; break; case XML_OP_ELEM: if ((step.value == NULL) && (step.value2 == NULL)) { /* * We have a "." or "self::node()" here. * Eliminate redundant self::node() tests like in "/./." * or "//./" * The only case we won't eliminate is "//.", i.e. if * self::node() is the last node test and we had * continuation somewhere beforehand. */ if ((comp->nbStep == i + 1) && (flags & XML_STREAM_STEP_DESC)) { /* * Mark the special case where the expression resolves * to any type of node. */ if (comp->nbStep == i + 1) { stream->flags |= XML_STREAM_FINAL_IS_ANY_NODE; } flags |= XML_STREAM_STEP_NODE; s = xmlStreamCompAddStep(stream, NULL, NULL, XML_STREAM_ANY_NODE, flags); if (s < 0) goto error; flags = 0; /* * If there was a previous step, mark it to be added to * the result node-set; this is needed since only * the last step will be marked as "final" and only * "final" nodes are added to the resulting set. */ if (prevs != -1) { stream->steps[prevs].flags |= XML_STREAM_STEP_IN_SET; prevs = -1; } break; } else { /* Just skip this one. */ continue; } } /* An element node. */ s = xmlStreamCompAddStep(stream, step.value, step.value2, XML_ELEMENT_NODE, flags); if (s < 0) goto error; prevs = s; flags = 0; break; case XML_OP_CHILD: /* An element node child. */ s = xmlStreamCompAddStep(stream, step.value, step.value2, XML_ELEMENT_NODE, flags); if (s < 0) goto error; prevs = s; flags = 0; break; case XML_OP_ALL: s = xmlStreamCompAddStep(stream, NULL, NULL, XML_ELEMENT_NODE, flags); if (s < 0) goto error; prevs = s; flags = 0; break; case XML_OP_PARENT: break; case XML_OP_ANCESTOR: /* Skip redundant continuations. */ if (flags & XML_STREAM_STEP_DESC) break; flags |= XML_STREAM_STEP_DESC; /* * Mark the expression as having "//". */ if ((stream->flags & XML_STREAM_DESC) == 0) stream->flags |= XML_STREAM_DESC; break; } } if ((! root) && (comp->flags & XML_PATTERN_NOTPATTERN) == 0) { /* * If this should behave like a real pattern, we will mark * the first step as having "//", to be reentrant on every * tree level. */ if ((stream->flags & XML_STREAM_DESC) == 0) stream->flags |= XML_STREAM_DESC; if (stream->nbStep > 0) { if ((stream->steps[0].flags & XML_STREAM_STEP_DESC) == 0) stream->steps[0].flags |= XML_STREAM_STEP_DESC; } } if (stream->nbStep <= s) goto error; stream->steps[s].flags |= XML_STREAM_STEP_FINAL; if (root) stream->steps[0].flags |= XML_STREAM_STEP_ROOT; #ifdef DEBUG_STREAMING xmlDebugStreamComp(stream); #endif comp->stream = stream; return(0); error: xmlFreeStreamComp(stream); return(0); } /** * xmlNewStreamCtxt: * @size: the number of expected states * * build a new stream context * * Returns the new structure or NULL in case of error. */ static xmlStreamCtxtPtr xmlNewStreamCtxt(xmlStreamCompPtr stream) { xmlStreamCtxtPtr cur; cur = (xmlStreamCtxtPtr) xmlMalloc(sizeof(xmlStreamCtxt)); if (cur == NULL) { ERROR(NULL, NULL, NULL, "xmlNewStreamCtxt: malloc failed\n"); return(NULL); } memset(cur, 0, sizeof(xmlStreamCtxt)); cur->states = (int *) xmlMalloc(4 * 2 * sizeof(int)); if (cur->states == NULL) { xmlFree(cur); ERROR(NULL, NULL, NULL, "xmlNewStreamCtxt: malloc failed\n"); return(NULL); } cur->nbState = 0; cur->maxState = 4; cur->level = 0; cur->comp = stream; cur->blockLevel = -1; return(cur); } /** * xmlFreeStreamCtxt: * @stream: the stream context * * Free the stream context */ void xmlFreeStreamCtxt(xmlStreamCtxtPtr stream) { xmlStreamCtxtPtr next; while (stream != NULL) { next = stream->next; if (stream->states != NULL) xmlFree(stream->states); xmlFree(stream); stream = next; } } /** * xmlStreamCtxtAddState: * @comp: the stream context * @idx: the step index for that streaming state * * Add a new state to the stream context * * Returns -1 in case of error or the state index if successful */ static int xmlStreamCtxtAddState(xmlStreamCtxtPtr comp, int idx, int level) { int i; for (i = 0;i < comp->nbState;i++) { if (comp->states[2 * i] < 0) { comp->states[2 * i] = idx; comp->states[2 * i + 1] = level; return(i); } } if (comp->nbState >= comp->maxState) { int *cur; cur = (int *) xmlRealloc(comp->states, comp->maxState * 4 * sizeof(int)); if (cur == NULL) { ERROR(NULL, NULL, NULL, "xmlNewStreamCtxt: malloc failed\n"); return(-1); } comp->states = cur; comp->maxState *= 2; } comp->states[2 * comp->nbState] = idx; comp->states[2 * comp->nbState++ + 1] = level; return(comp->nbState - 1); } /** * xmlStreamPushInternal: * @stream: the stream context * @name: the current name * @ns: the namespace name * @nodeType: the type of the node * * Push new data onto the stream. NOTE: if the call xmlPatterncompile() * indicated a dictionary, then strings for name and ns will be expected * to come from the dictionary. * Both @name and @ns being NULL means the / i.e. the root of the document. * This can also act as a reset. * * Returns: -1 in case of error, 1 if the current state in the stream is a * match and 0 otherwise. */ static int xmlStreamPushInternal(xmlStreamCtxtPtr stream, const xmlChar *name, const xmlChar *ns, int nodeType) { int ret = 0, err = 0, final = 0, tmp, i, m, match, stepNr, desc; xmlStreamCompPtr comp; xmlStreamStep step; #ifdef DEBUG_STREAMING xmlStreamCtxtPtr orig = stream; #endif if ((stream == NULL) || (stream->nbState < 0)) return(-1); while (stream != NULL) { comp = stream->comp; if ((nodeType == XML_ELEMENT_NODE) && (name == NULL) && (ns == NULL)) { /* We have a document node here (or a reset). */ stream->nbState = 0; stream->level = 0; stream->blockLevel = -1; if (comp->flags & XML_STREAM_FROM_ROOT) { if (comp->nbStep == 0) { /* TODO: We have a "/." here? */ ret = 1; } else { if ((comp->nbStep == 1) && (comp->steps[0].nodeType == XML_STREAM_ANY_NODE) && (comp->steps[0].flags & XML_STREAM_STEP_DESC)) { /* * In the case of "//." the document node will match * as well. */ ret = 1; } else if (comp->steps[0].flags & XML_STREAM_STEP_ROOT) { /* TODO: Do we need this ? */ tmp = xmlStreamCtxtAddState(stream, 0, 0); if (tmp < 0) err++; } } } stream = stream->next; continue; /* while */ } /* * Fast check for ".". */ if (comp->nbStep == 0) { /* * / and . are handled at the XPath node set creation * level by checking min depth */ if (stream->flags & XML_PATTERN_XPATH) { stream = stream->next; continue; /* while */ } /* * For non-pattern like evaluation like XML Schema IDCs * or traditional XPath expressions, this will match if * we are at the first level only, otherwise on every level. */ if ((nodeType != XML_ATTRIBUTE_NODE) && (((stream->flags & XML_PATTERN_NOTPATTERN) == 0) || (stream->level == 0))) { ret = 1; } stream->level++; goto stream_next; } if (stream->blockLevel != -1) { /* * Skip blocked expressions. */ stream->level++; goto stream_next; } if ((nodeType != XML_ELEMENT_NODE) && (nodeType != XML_ATTRIBUTE_NODE) && ((comp->flags & XML_STREAM_FINAL_IS_ANY_NODE) == 0)) { /* * No need to process nodes of other types if we don't * resolve to those types. * TODO: Do we need to block the context here? */ stream->level++; goto stream_next; } /* * Check evolution of existing states */ i = 0; m = stream->nbState; while (i < m) { if ((comp->flags & XML_STREAM_DESC) == 0) { /* * If there is no "//", then only the last * added state is of interest. */ stepNr = stream->states[2 * (stream->nbState -1)]; /* * TODO: Security check, should not happen, remove it. */ if (stream->states[(2 * (stream->nbState -1)) + 1] < stream->level) { return (-1); } desc = 0; /* loop-stopper */ i = m; } else { /* * If there are "//", then we need to process every "//" * occuring in the states, plus any other state for this * level. */ stepNr = stream->states[2 * i]; /* TODO: should not happen anymore: dead states */ if (stepNr < 0) goto next_state; tmp = stream->states[(2 * i) + 1]; /* skip new states just added */ if (tmp > stream->level) goto next_state; /* skip states at ancestor levels, except if "//" */ desc = comp->steps[stepNr].flags & XML_STREAM_STEP_DESC; if ((tmp < stream->level) && (!desc)) goto next_state; } /* * Check for correct node-type. */ step = comp->steps[stepNr]; if (step.nodeType != nodeType) { if (step.nodeType == XML_ATTRIBUTE_NODE) { /* * Block this expression for deeper evaluation. */ if ((comp->flags & XML_STREAM_DESC) == 0) stream->blockLevel = stream->level +1; goto next_state; } else if (step.nodeType != XML_STREAM_ANY_NODE) goto next_state; } /* * Compare local/namespace-name. */ match = 0; if (step.nodeType == XML_STREAM_ANY_NODE) { match = 1; } else if (step.name == NULL) { if (step.ns == NULL) { /* * This lets through all elements/attributes. */ match = 1; } else if (ns != NULL) match = xmlStrEqual(step.ns, ns); } else if (((step.ns != NULL) == (ns != NULL)) && (name != NULL) && (step.name[0] == name[0]) && xmlStrEqual(step.name, name) && ((step.ns == ns) || xmlStrEqual(step.ns, ns))) { match = 1; } #if 0 /* * TODO: Pointer comparison won't work, since not guaranteed that the given * values are in the same dict; especially if it's the namespace name, * normally coming from ns->href. We need a namespace dict mechanism ! */ } else if (comp->dict) { if (step.name == NULL) { if (step.ns == NULL) match = 1; else match = (step.ns == ns); } else { match = ((step.name == name) && (step.ns == ns)); } #endif /* if 0 ------------------------------------------------------- */ if (match) { final = step.flags & XML_STREAM_STEP_FINAL; if (desc) { if (final) { ret = 1; } else { /* descending match create a new state */ xmlStreamCtxtAddState(stream, stepNr + 1, stream->level + 1); } } else { if (final) { ret = 1; } else { xmlStreamCtxtAddState(stream, stepNr + 1, stream->level + 1); } } if ((ret != 1) && (step.flags & XML_STREAM_STEP_IN_SET)) { /* * Check if we have a special case like "foo/bar//.", where * "foo" is selected as well. */ ret = 1; } } if (((comp->flags & XML_STREAM_DESC) == 0) && ((! match) || final)) { /* * Mark this expression as blocked for any evaluation at * deeper levels. Note that this includes "/foo" * expressions if the *pattern* behaviour is used. */ stream->blockLevel = stream->level +1; } next_state: i++; } stream->level++; /* * Re/enter the expression. * Don't reenter if it's an absolute expression like "/foo", * except "//foo". */ step = comp->steps[0]; if (step.flags & XML_STREAM_STEP_ROOT) goto stream_next; desc = step.flags & XML_STREAM_STEP_DESC; if (stream->flags & XML_PATTERN_NOTPATTERN) { /* * Re/enter the expression if it is a "descendant" one, * or if we are at the 1st level of evaluation. */ if (stream->level == 1) { if (XML_STREAM_XS_IDC(stream)) { /* * XS-IDC: The missing "self::node()" will always * match the first given node. */ goto stream_next; } else goto compare; } /* * A "//" is always reentrant. */ if (desc) goto compare; /* * XS-IDC: Process the 2nd level, since the missing * "self::node()" is responsible for the 2nd level being * the real start level. */ if ((stream->level == 2) && XML_STREAM_XS_IDC(stream)) goto compare; goto stream_next; } compare: /* * Check expected node-type. */ if (step.nodeType != nodeType) { if (nodeType == XML_ATTRIBUTE_NODE) goto stream_next; else if (step.nodeType != XML_STREAM_ANY_NODE) goto stream_next; } /* * Compare local/namespace-name. */ match = 0; if (step.nodeType == XML_STREAM_ANY_NODE) { match = 1; } else if (step.name == NULL) { if (step.ns == NULL) { /* * This lets through all elements/attributes. */ match = 1; } else if (ns != NULL) match = xmlStrEqual(step.ns, ns); } else if (((step.ns != NULL) == (ns != NULL)) && (name != NULL) && (step.name[0] == name[0]) && xmlStrEqual(step.name, name) && ((step.ns == ns) || xmlStrEqual(step.ns, ns))) { match = 1; } final = step.flags & XML_STREAM_STEP_FINAL; if (match) { if (final) ret = 1; else xmlStreamCtxtAddState(stream, 1, stream->level); if ((ret != 1) && (step.flags & XML_STREAM_STEP_IN_SET)) { /* * Check if we have a special case like "foo//.", where * "foo" is selected as well. */ ret = 1; } } if (((comp->flags & XML_STREAM_DESC) == 0) && ((! match) || final)) { /* * Mark this expression as blocked for any evaluation at * deeper levels. */ stream->blockLevel = stream->level; } stream_next: stream = stream->next; } /* while stream != NULL */ if (err > 0) ret = -1; #ifdef DEBUG_STREAMING xmlDebugStreamCtxt(orig, ret); #endif return(ret); } /** * xmlStreamPush: * @stream: the stream context * @name: the current name * @ns: the namespace name * * Push new data onto the stream. NOTE: if the call xmlPatterncompile() * indicated a dictionary, then strings for name and ns will be expected * to come from the dictionary. * Both @name and @ns being NULL means the / i.e. the root of the document. * This can also act as a reset. * Otherwise the function will act as if it has been given an element-node. * * Returns: -1 in case of error, 1 if the current state in the stream is a * match and 0 otherwise. */ int xmlStreamPush(xmlStreamCtxtPtr stream, const xmlChar *name, const xmlChar *ns) { return (xmlStreamPushInternal(stream, name, ns, (int) XML_ELEMENT_NODE)); } /** * xmlStreamPushNode: * @stream: the stream context * @name: the current name * @ns: the namespace name * @nodeType: the type of the node being pushed * * Push new data onto the stream. NOTE: if the call xmlPatterncompile() * indicated a dictionary, then strings for name and ns will be expected * to come from the dictionary. * Both @name and @ns being NULL means the / i.e. the root of the document. * This can also act as a reset. * Different from xmlStreamPush() this function can be fed with nodes of type: * element-, attribute-, text-, cdata-section-, comment- and * processing-instruction-node. * * Returns: -1 in case of error, 1 if the current state in the stream is a * match and 0 otherwise. */ int xmlStreamPushNode(xmlStreamCtxtPtr stream, const xmlChar *name, const xmlChar *ns, int nodeType) { return (xmlStreamPushInternal(stream, name, ns, nodeType)); } /** * xmlStreamPushAttr: * @stream: the stream context * @name: the current name * @ns: the namespace name * * Push new attribute data onto the stream. NOTE: if the call xmlPatterncompile() * indicated a dictionary, then strings for name and ns will be expected * to come from the dictionary. * Both @name and @ns being NULL means the / i.e. the root of the document. * This can also act as a reset. * Otherwise the function will act as if it has been given an attribute-node. * * Returns: -1 in case of error, 1 if the current state in the stream is a * match and 0 otherwise. */ int xmlStreamPushAttr(xmlStreamCtxtPtr stream, const xmlChar *name, const xmlChar *ns) { return (xmlStreamPushInternal(stream, name, ns, (int) XML_ATTRIBUTE_NODE)); } /** * xmlStreamPop: * @stream: the stream context * * push one level from the stream. * * Returns: -1 in case of error, 0 otherwise. */ int xmlStreamPop(xmlStreamCtxtPtr stream) { int i, lev; if (stream == NULL) return(-1); while (stream != NULL) { /* * Reset block-level. */ if (stream->blockLevel == stream->level) stream->blockLevel = -1; stream->level--; if (stream->level < 0) return(-1); /* * Check evolution of existing states */ for (i = stream->nbState -1; i >= 0; i--) { /* discard obsoleted states */ lev = stream->states[(2 * i) + 1]; if (lev > stream->level) stream->nbState--; if (lev <= stream->level) break; } stream = stream->next; } return(0); } /** * xmlStreamWantsAnyNode: * @streamCtxt: the stream context * * Query if the streaming pattern additionally needs to be fed with * text-, cdata-section-, comment- and processing-instruction-nodes. * If the result is 0 then only element-nodes and attribute-nodes * need to be pushed. * * Returns: 1 in case of need of nodes of the above described types, * 0 otherwise. -1 on API errors. */ int xmlStreamWantsAnyNode(xmlStreamCtxtPtr streamCtxt) { if (streamCtxt == NULL) return(-1); while (streamCtxt != NULL) { if (streamCtxt->comp->flags & XML_STREAM_FINAL_IS_ANY_NODE) return(1); streamCtxt = streamCtxt->next; } return(0); } /************************************************************************ * * * The public interfaces * * * ************************************************************************/ /** * xmlPatterncompile: * @pattern: the pattern to compile * @dict: an optional dictionary for interned strings * @flags: compilation flags, see xmlPatternFlags * @namespaces: the prefix definitions, array of [URI, prefix] or NULL * * Compile a pattern. * * Returns the compiled form of the pattern or NULL in case of error */ xmlPatternPtr xmlPatterncompile(const xmlChar *pattern, xmlDict *dict, int flags, const xmlChar **namespaces) { xmlPatternPtr ret = NULL, cur; xmlPatParserContextPtr ctxt = NULL; const xmlChar *or, *start; xmlChar *tmp = NULL; int type = 0; int streamable = 1; if (pattern == NULL) return(NULL); start = pattern; or = start; while (*or != 0) { tmp = NULL; while ((*or != 0) && (*or != '|')) or++; if (*or == 0) ctxt = xmlNewPatParserContext(start, dict, namespaces); else { tmp = xmlStrndup(start, or - start); if (tmp != NULL) { ctxt = xmlNewPatParserContext(tmp, dict, namespaces); } or++; } if (ctxt == NULL) goto error; cur = xmlNewPattern(); if (cur == NULL) goto error; /* * Assign string dict. */ if (dict) { cur->dict = dict; xmlDictReference(dict); } if (ret == NULL) ret = cur; else { cur->next = ret->next; ret->next = cur; } cur->flags = flags; ctxt->comp = cur; if (XML_STREAM_XS_IDC(cur)) xmlCompileIDCXPathPath(ctxt); else xmlCompilePathPattern(ctxt); if (ctxt->error != 0) goto error; xmlFreePatParserContext(ctxt); ctxt = NULL; if (streamable) { if (type == 0) { type = cur->flags & (PAT_FROM_ROOT | PAT_FROM_CUR); } else if (type == PAT_FROM_ROOT) { if (cur->flags & PAT_FROM_CUR) streamable = 0; } else if (type == PAT_FROM_CUR) { if (cur->flags & PAT_FROM_ROOT) streamable = 0; } } if (streamable) xmlStreamCompile(cur); if (xmlReversePattern(cur) < 0) goto error; if (tmp != NULL) { xmlFree(tmp); tmp = NULL; } start = or; } if (streamable == 0) { cur = ret; while (cur != NULL) { if (cur->stream != NULL) { xmlFreeStreamComp(cur->stream); cur->stream = NULL; } cur = cur->next; } } return(ret); error: if (ctxt != NULL) xmlFreePatParserContext(ctxt); if (ret != NULL) xmlFreePattern(ret); if (tmp != NULL) xmlFree(tmp); return(NULL); } /** * xmlPatternMatch: * @comp: the precompiled pattern * @node: a node * * Test whether the node matches the pattern * * Returns 1 if it matches, 0 if it doesn't and -1 in case of failure */ int xmlPatternMatch(xmlPatternPtr comp, xmlNodePtr node) { int ret = 0; if ((comp == NULL) || (node == NULL)) return(-1); while (comp != NULL) { ret = xmlPatMatch(comp, node); if (ret != 0) return(ret); comp = comp->next; } return(ret); } /** * xmlPatternGetStreamCtxt: * @comp: the precompiled pattern * * Get a streaming context for that pattern * Use xmlFreeStreamCtxt to free the context. * * Returns a pointer to the context or NULL in case of failure */ xmlStreamCtxtPtr xmlPatternGetStreamCtxt(xmlPatternPtr comp) { xmlStreamCtxtPtr ret = NULL, cur; if ((comp == NULL) || (comp->stream == NULL)) return(NULL); while (comp != NULL) { if (comp->stream == NULL) goto failed; cur = xmlNewStreamCtxt(comp->stream); if (cur == NULL) goto failed; if (ret == NULL) ret = cur; else { cur->next = ret->next; ret->next = cur; } cur->flags = comp->flags; comp = comp->next; } return(ret); failed: xmlFreeStreamCtxt(ret); return(NULL); } /** * xmlPatternStreamable: * @comp: the precompiled pattern * * Check if the pattern is streamable i.e. xmlPatternGetStreamCtxt() * should work. * * Returns 1 if streamable, 0 if not and -1 in case of error. */ int xmlPatternStreamable(xmlPatternPtr comp) { if (comp == NULL) return(-1); while (comp != NULL) { if (comp->stream == NULL) return(0); comp = comp->next; } return(1); } /** * xmlPatternMaxDepth: * @comp: the precompiled pattern * * Check the maximum depth reachable by a pattern * * Returns -2 if no limit (using //), otherwise the depth, * and -1 in case of error */ int xmlPatternMaxDepth(xmlPatternPtr comp) { int ret = 0, i; if (comp == NULL) return(-1); while (comp != NULL) { if (comp->stream == NULL) return(-1); for (i = 0;i < comp->stream->nbStep;i++) if (comp->stream->steps[i].flags & XML_STREAM_STEP_DESC) return(-2); if (comp->stream->nbStep > ret) ret = comp->stream->nbStep; comp = comp->next; } return(ret); } /** * xmlPatternMinDepth: * @comp: the precompiled pattern * * Check the minimum depth reachable by a pattern, 0 mean the / or . are * part of the set. * * Returns -1 in case of error otherwise the depth, * */ int xmlPatternMinDepth(xmlPatternPtr comp) { int ret = 12345678; if (comp == NULL) return(-1); while (comp != NULL) { if (comp->stream == NULL) return(-1); if (comp->stream->nbStep < ret) ret = comp->stream->nbStep; if (ret == 0) return(0); comp = comp->next; } return(ret); } /** * xmlPatternFromRoot: * @comp: the precompiled pattern * * Check if the pattern must be looked at from the root. * * Returns 1 if true, 0 if false and -1 in case of error */ int xmlPatternFromRoot(xmlPatternPtr comp) { if (comp == NULL) return(-1); while (comp != NULL) { if (comp->stream == NULL) return(-1); if (comp->flags & PAT_FROM_ROOT) return(1); comp = comp->next; } return(0); } #define bottom_pattern #include "elfgcchack.h" #endif /* LIBXML_PATTERN_ENABLED */ xdmf-3.0+git20160803/Utilities/vtklibxml2/catalog.c0000640000175000017500000034230013003006557021723 0ustar alastairalastair/** * catalog.c: set of generic Catalog related routines * * Reference: SGML Open Technical Resolution TR9401:1997. * http://www.jclark.com/sp/catalog.htm * * XML Catalogs Working Draft 06 August 2001 * http://www.oasis-open.org/committees/entity/spec-2001-08-06.html * * See Copyright for the status of this software. * * Daniel.Veillard@imag.fr */ #define IN_LIBXML #include "libxml.h" #ifdef LIBXML_CATALOG_ENABLED #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_STAT_H #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_FCNTL_H #include #endif #ifdef HAVE_STDLIB_H #include #endif #include #include #include #include #include #include #include #include #include #define MAX_DELEGATE 50 #define MAX_CATAL_DEPTH 50 /** * TODO: * * macro to flag unimplemented blocks * XML_CATALOG_PREFER user env to select between system/public prefered * option. C.f. Richard Tobin *> Just FYI, I am using an environment variable XML_CATALOG_PREFER with *> values "system" and "public". I have made the default be "system" to *> match yours. */ #define TODO \ xmlGenericError(xmlGenericErrorContext, \ "Unimplemented block at %s:%d\n", \ __FILE__, __LINE__); #define XML_URN_PUBID "urn:publicid:" #define XML_CATAL_BREAK ((xmlChar *) -1) #ifndef XML_XML_DEFAULT_CATALOG #define XML_XML_DEFAULT_CATALOG "file:///etc/xml/catalog" #endif #ifndef XML_SGML_DEFAULT_CATALOG #define XML_SGML_DEFAULT_CATALOG "file:///etc/sgml/catalog" #endif #if defined(_WIN32) && defined(_MSC_VER) #undef XML_XML_DEFAULT_CATALOG static char XML_XML_DEFAULT_CATALOG[256] = "file:///etc/xml/catalog"; void* __stdcall GetModuleHandleA(const char*); unsigned long __stdcall GetModuleFileNameA(void*, char*, unsigned long); #endif static xmlChar *xmlCatalogNormalizePublic(const xmlChar *pubID); static int xmlExpandCatalog(xmlCatalogPtr catal, const char *filename); /************************************************************************ * * * Types, all private * * * ************************************************************************/ typedef enum { XML_CATA_REMOVED = -1, XML_CATA_NONE = 0, XML_CATA_CATALOG, XML_CATA_BROKEN_CATALOG, XML_CATA_NEXT_CATALOG, XML_CATA_GROUP, XML_CATA_PUBLIC, XML_CATA_SYSTEM, XML_CATA_REWRITE_SYSTEM, XML_CATA_DELEGATE_PUBLIC, XML_CATA_DELEGATE_SYSTEM, XML_CATA_URI, XML_CATA_REWRITE_URI, XML_CATA_DELEGATE_URI, SGML_CATA_SYSTEM, SGML_CATA_PUBLIC, SGML_CATA_ENTITY, SGML_CATA_PENTITY, SGML_CATA_DOCTYPE, SGML_CATA_LINKTYPE, SGML_CATA_NOTATION, SGML_CATA_DELEGATE, SGML_CATA_BASE, SGML_CATA_CATALOG, SGML_CATA_DOCUMENT, SGML_CATA_SGMLDECL } xmlCatalogEntryType; typedef struct _xmlCatalogEntry xmlCatalogEntry; typedef xmlCatalogEntry *xmlCatalogEntryPtr; struct _xmlCatalogEntry { struct _xmlCatalogEntry *next; struct _xmlCatalogEntry *parent; struct _xmlCatalogEntry *children; xmlCatalogEntryType type; xmlChar *name; xmlChar *value; xmlChar *URL; /* The expanded URL using the base */ xmlCatalogPrefer prefer; int dealloc; int depth; struct _xmlCatalogEntry *group; }; typedef enum { XML_XML_CATALOG_TYPE = 1, XML_SGML_CATALOG_TYPE } xmlCatalogType; #define XML_MAX_SGML_CATA_DEPTH 10 struct _xmlCatalog { xmlCatalogType type; /* either XML or SGML */ /* * SGML Catalogs are stored as a simple hash table of catalog entries * Catalog stack to check against overflows when building the * SGML catalog */ char *catalTab[XML_MAX_SGML_CATA_DEPTH]; /* stack of catals */ int catalNr; /* Number of current catal streams */ int catalMax; /* Max number of catal streams */ xmlHashTablePtr sgml; /* * XML Catalogs are stored as a tree of Catalog entries */ xmlCatalogPrefer prefer; xmlCatalogEntryPtr xml; }; /************************************************************************ * * * Global variables * * * ************************************************************************/ /* * Those are preferences */ static int xmlDebugCatalogs = 0; /* used for debugging */ static xmlCatalogAllow xmlCatalogDefaultAllow = XML_CATA_ALLOW_ALL; static xmlCatalogPrefer xmlCatalogDefaultPrefer = XML_CATA_PREFER_PUBLIC; /* * Hash table containing all the trees of XML catalogs parsed by * the application. */ static xmlHashTablePtr xmlCatalogXMLFiles = NULL; /* * The default catalog in use by the application */ static xmlCatalogPtr xmlDefaultCatalog = NULL; /* * A mutex for modifying the shared global catalog(s) * xmlDefaultCatalog tree. * It also protects xmlCatalogXMLFiles * The core of this readers/writer scheme is in xmlFetchXMLCatalogFile() */ static xmlRMutexPtr xmlCatalogMutex = NULL; /* * Whether the catalog support was initialized. */ static int xmlCatalogInitialized = 0; /************************************************************************ * * * Catalog error handlers * * * ************************************************************************/ /** * xmlCatalogErrMemory: * @extra: extra informations * * Handle an out of memory condition */ static void xmlCatalogErrMemory(const char *extra) { __xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_CATALOG, XML_ERR_NO_MEMORY, XML_ERR_ERROR, NULL, 0, extra, NULL, NULL, 0, 0, "Memory allocation failed : %s\n", extra); } /** * xmlCatalogErr: * @catal: the Catalog entry * @node: the context node * @msg: the error message * @extra: extra informations * * Handle a catalog error */ static void xmlCatalogErr(xmlCatalogEntryPtr catal, xmlNodePtr node, int error, const char *msg, const xmlChar *str1, const xmlChar *str2, const xmlChar *str3) { __xmlRaiseError(NULL, NULL, NULL, catal, node, XML_FROM_CATALOG, error, XML_ERR_ERROR, NULL, 0, (const char *) str1, (const char *) str2, (const char *) str3, 0, 0, msg, str1, str2, str3); } /************************************************************************ * * * Allocation and Freeing * * * ************************************************************************/ /** * xmlNewCatalogEntry: * @type: type of entry * @name: name of the entry * @value: value of the entry * @prefer: the PUBLIC vs. SYSTEM current preference value * @group: for members of a group, the group entry * * create a new Catalog entry, this type is shared both by XML and * SGML catalogs, but the acceptable types values differs. * * Returns the xmlCatalogEntryPtr or NULL in case of error */ static xmlCatalogEntryPtr xmlNewCatalogEntry(xmlCatalogEntryType type, const xmlChar *name, const xmlChar *value, const xmlChar *URL, xmlCatalogPrefer prefer, xmlCatalogEntryPtr group) { xmlCatalogEntryPtr ret; xmlChar *normid = NULL; ret = (xmlCatalogEntryPtr) xmlMalloc(sizeof(xmlCatalogEntry)); if (ret == NULL) { xmlCatalogErrMemory("allocating catalog entry"); return(NULL); } ret->next = NULL; ret->parent = NULL; ret->children = NULL; ret->type = type; if (type == XML_CATA_PUBLIC || type == XML_CATA_DELEGATE_PUBLIC) { normid = xmlCatalogNormalizePublic(name); if (normid != NULL) name = (*normid != 0 ? normid : NULL); } if (name != NULL) ret->name = xmlStrdup(name); else ret->name = NULL; if (normid != NULL) xmlFree(normid); if (value != NULL) ret->value = xmlStrdup(value); else ret->value = NULL; if (URL == NULL) URL = value; if (URL != NULL) ret->URL = xmlStrdup(URL); else ret->URL = NULL; ret->prefer = prefer; ret->dealloc = 0; ret->depth = 0; ret->group = group; return(ret); } static void xmlFreeCatalogEntryList(xmlCatalogEntryPtr ret); /** * xmlFreeCatalogEntry: * @ret: a Catalog entry * * Free the memory allocated to a Catalog entry */ static void xmlFreeCatalogEntry(xmlCatalogEntryPtr ret) { if (ret == NULL) return; /* * Entries stored in the file hash must be deallocated * only by the file hash cleaner ! */ if (ret->dealloc == 1) return; if (xmlDebugCatalogs) { if (ret->name != NULL) xmlGenericError(xmlGenericErrorContext, "Free catalog entry %s\n", ret->name); else if (ret->value != NULL) xmlGenericError(xmlGenericErrorContext, "Free catalog entry %s\n", ret->value); else xmlGenericError(xmlGenericErrorContext, "Free catalog entry\n"); } if (ret->name != NULL) xmlFree(ret->name); if (ret->value != NULL) xmlFree(ret->value); if (ret->URL != NULL) xmlFree(ret->URL); xmlFree(ret); } /** * xmlFreeCatalogEntryList: * @ret: a Catalog entry list * * Free the memory allocated to a full chained list of Catalog entries */ static void xmlFreeCatalogEntryList(xmlCatalogEntryPtr ret) { xmlCatalogEntryPtr next; while (ret != NULL) { next = ret->next; xmlFreeCatalogEntry(ret); ret = next; } } /** * xmlFreeCatalogHashEntryList: * @ret: a Catalog entry list * * Free the memory allocated to list of Catalog entries from the * catalog file hash. */ static void xmlFreeCatalogHashEntryList(xmlCatalogEntryPtr catal) { xmlCatalogEntryPtr children, next; if (catal == NULL) return; children = catal->children; while (children != NULL) { next = children->next; children->dealloc = 0; children->children = NULL; xmlFreeCatalogEntry(children); children = next; } catal->dealloc = 0; xmlFreeCatalogEntry(catal); } /** * xmlCreateNewCatalog: * @type: type of catalog * @prefer: the PUBLIC vs. SYSTEM current preference value * * create a new Catalog, this type is shared both by XML and * SGML catalogs, but the acceptable types values differs. * * Returns the xmlCatalogPtr or NULL in case of error */ static xmlCatalogPtr xmlCreateNewCatalog(xmlCatalogType type, xmlCatalogPrefer prefer) { xmlCatalogPtr ret; ret = (xmlCatalogPtr) xmlMalloc(sizeof(xmlCatalog)); if (ret == NULL) { xmlCatalogErrMemory("allocating catalog"); return(NULL); } memset(ret, 0, sizeof(xmlCatalog)); ret->type = type; ret->catalNr = 0; ret->catalMax = XML_MAX_SGML_CATA_DEPTH; ret->prefer = prefer; if (ret->type == XML_SGML_CATALOG_TYPE) ret->sgml = xmlHashCreate(10); return(ret); } /** * xmlFreeCatalog: * @catal: a Catalog * * Free the memory allocated to a Catalog */ void xmlFreeCatalog(xmlCatalogPtr catal) { if (catal == NULL) return; if (catal->xml != NULL) xmlFreeCatalogEntryList(catal->xml); if (catal->sgml != NULL) xmlHashFree(catal->sgml, (xmlHashDeallocator) xmlFreeCatalogEntry); xmlFree(catal); } /************************************************************************ * * * Serializing Catalogs * * * ************************************************************************/ #ifdef LIBXML_OUTPUT_ENABLED /** * xmlCatalogDumpEntry: * @entry: the catalog entry * @out: the file. * * Serialize an SGML Catalog entry */ static void xmlCatalogDumpEntry(xmlCatalogEntryPtr entry, FILE *out) { if ((entry == NULL) || (out == NULL)) return; switch (entry->type) { case SGML_CATA_ENTITY: fprintf(out, "ENTITY "); break; case SGML_CATA_PENTITY: fprintf(out, "ENTITY %%"); break; case SGML_CATA_DOCTYPE: fprintf(out, "DOCTYPE "); break; case SGML_CATA_LINKTYPE: fprintf(out, "LINKTYPE "); break; case SGML_CATA_NOTATION: fprintf(out, "NOTATION "); break; case SGML_CATA_PUBLIC: fprintf(out, "PUBLIC "); break; case SGML_CATA_SYSTEM: fprintf(out, "SYSTEM "); break; case SGML_CATA_DELEGATE: fprintf(out, "DELEGATE "); break; case SGML_CATA_BASE: fprintf(out, "BASE "); break; case SGML_CATA_CATALOG: fprintf(out, "CATALOG "); break; case SGML_CATA_DOCUMENT: fprintf(out, "DOCUMENT "); break; case SGML_CATA_SGMLDECL: fprintf(out, "SGMLDECL "); break; default: return; } switch (entry->type) { case SGML_CATA_ENTITY: case SGML_CATA_PENTITY: case SGML_CATA_DOCTYPE: case SGML_CATA_LINKTYPE: case SGML_CATA_NOTATION: fprintf(out, "%s", (const char *) entry->name); break; case SGML_CATA_PUBLIC: case SGML_CATA_SYSTEM: case SGML_CATA_SGMLDECL: case SGML_CATA_DOCUMENT: case SGML_CATA_CATALOG: case SGML_CATA_BASE: case SGML_CATA_DELEGATE: fprintf(out, "\"%s\"", entry->name); break; default: break; } switch (entry->type) { case SGML_CATA_ENTITY: case SGML_CATA_PENTITY: case SGML_CATA_DOCTYPE: case SGML_CATA_LINKTYPE: case SGML_CATA_NOTATION: case SGML_CATA_PUBLIC: case SGML_CATA_SYSTEM: case SGML_CATA_DELEGATE: fprintf(out, " \"%s\"", entry->value); break; default: break; } fprintf(out, "\n"); } /** * xmlDumpXMLCatalogNode: * @catal: top catalog entry * @catalog: pointer to the xml tree * @doc: the containing document * @ns: the current namespace * @cgroup: group node for group members * * Serializes a Catalog entry, called by xmlDumpXMLCatalog and recursively * for group entries */ static void xmlDumpXMLCatalogNode(xmlCatalogEntryPtr catal, xmlNodePtr catalog, xmlDocPtr doc, xmlNsPtr ns, xmlCatalogEntryPtr cgroup) { xmlNodePtr node; xmlCatalogEntryPtr cur; /* * add all the catalog entries */ cur = catal; while (cur != NULL) { if (cur->group == cgroup) { switch (cur->type) { case XML_CATA_REMOVED: break; case XML_CATA_BROKEN_CATALOG: case XML_CATA_CATALOG: if (cur == catal) { cur = cur->children; continue; } break; case XML_CATA_NEXT_CATALOG: node = xmlNewDocNode(doc, ns, BAD_CAST "nextCatalog", NULL); xmlSetProp(node, BAD_CAST "catalog", cur->value); xmlAddChild(catalog, node); break; case XML_CATA_NONE: break; case XML_CATA_GROUP: node = xmlNewDocNode(doc, ns, BAD_CAST "group", NULL); xmlSetProp(node, BAD_CAST "id", cur->name); if (cur->value != NULL) { xmlNsPtr xns; xns = xmlSearchNsByHref(doc, node, XML_XML_NAMESPACE); if (xns != NULL) xmlSetNsProp(node, xns, BAD_CAST "base", cur->value); } switch (cur->prefer) { case XML_CATA_PREFER_NONE: break; case XML_CATA_PREFER_PUBLIC: xmlSetProp(node, BAD_CAST "prefer", BAD_CAST "public"); break; case XML_CATA_PREFER_SYSTEM: xmlSetProp(node, BAD_CAST "prefer", BAD_CAST "system"); break; } xmlDumpXMLCatalogNode(cur->next, node, doc, ns, cur); xmlAddChild(catalog, node); break; case XML_CATA_PUBLIC: node = xmlNewDocNode(doc, ns, BAD_CAST "public", NULL); xmlSetProp(node, BAD_CAST "publicId", cur->name); xmlSetProp(node, BAD_CAST "uri", cur->value); xmlAddChild(catalog, node); break; case XML_CATA_SYSTEM: node = xmlNewDocNode(doc, ns, BAD_CAST "system", NULL); xmlSetProp(node, BAD_CAST "systemId", cur->name); xmlSetProp(node, BAD_CAST "uri", cur->value); xmlAddChild(catalog, node); break; case XML_CATA_REWRITE_SYSTEM: node = xmlNewDocNode(doc, ns, BAD_CAST "rewriteSystem", NULL); xmlSetProp(node, BAD_CAST "systemIdStartString", cur->name); xmlSetProp(node, BAD_CAST "rewritePrefix", cur->value); xmlAddChild(catalog, node); break; case XML_CATA_DELEGATE_PUBLIC: node = xmlNewDocNode(doc, ns, BAD_CAST "delegatePublic", NULL); xmlSetProp(node, BAD_CAST "publicIdStartString", cur->name); xmlSetProp(node, BAD_CAST "catalog", cur->value); xmlAddChild(catalog, node); break; case XML_CATA_DELEGATE_SYSTEM: node = xmlNewDocNode(doc, ns, BAD_CAST "delegateSystem", NULL); xmlSetProp(node, BAD_CAST "systemIdStartString", cur->name); xmlSetProp(node, BAD_CAST "catalog", cur->value); xmlAddChild(catalog, node); break; case XML_CATA_URI: node = xmlNewDocNode(doc, ns, BAD_CAST "uri", NULL); xmlSetProp(node, BAD_CAST "name", cur->name); xmlSetProp(node, BAD_CAST "uri", cur->value); xmlAddChild(catalog, node); break; case XML_CATA_REWRITE_URI: node = xmlNewDocNode(doc, ns, BAD_CAST "rewriteURI", NULL); xmlSetProp(node, BAD_CAST "uriStartString", cur->name); xmlSetProp(node, BAD_CAST "rewritePrefix", cur->value); xmlAddChild(catalog, node); break; case XML_CATA_DELEGATE_URI: node = xmlNewDocNode(doc, ns, BAD_CAST "delegateURI", NULL); xmlSetProp(node, BAD_CAST "uriStartString", cur->name); xmlSetProp(node, BAD_CAST "catalog", cur->value); xmlAddChild(catalog, node); break; case SGML_CATA_SYSTEM: case SGML_CATA_PUBLIC: case SGML_CATA_ENTITY: case SGML_CATA_PENTITY: case SGML_CATA_DOCTYPE: case SGML_CATA_LINKTYPE: case SGML_CATA_NOTATION: case SGML_CATA_DELEGATE: case SGML_CATA_BASE: case SGML_CATA_CATALOG: case SGML_CATA_DOCUMENT: case SGML_CATA_SGMLDECL: break; } } cur = cur->next; } } static int xmlDumpXMLCatalog(FILE *out, xmlCatalogEntryPtr catal) { int ret; xmlDocPtr doc; xmlNsPtr ns; xmlDtdPtr dtd; xmlNodePtr catalog; xmlOutputBufferPtr buf; /* * Rebuild a catalog */ doc = xmlNewDoc(NULL); if (doc == NULL) return(-1); dtd = xmlNewDtd(doc, BAD_CAST "catalog", BAD_CAST "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN", BAD_CAST "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd"); xmlAddChild((xmlNodePtr) doc, (xmlNodePtr) dtd); ns = xmlNewNs(NULL, XML_CATALOGS_NAMESPACE, NULL); if (ns == NULL) { xmlFreeDoc(doc); return(-1); } catalog = xmlNewDocNode(doc, ns, BAD_CAST "catalog", NULL); if (catalog == NULL) { xmlFreeNs(ns); xmlFreeDoc(doc); return(-1); } catalog->nsDef = ns; xmlAddChild((xmlNodePtr) doc, catalog); xmlDumpXMLCatalogNode(catal, catalog, doc, ns, NULL); /* * reserialize it */ buf = xmlOutputBufferCreateFile(out, NULL); if (buf == NULL) { xmlFreeDoc(doc); return(-1); } ret = xmlSaveFormatFileTo(buf, doc, NULL, 1); /* * Free it */ xmlFreeDoc(doc); return(ret); } #endif /* LIBXML_OUTPUT_ENABLED */ /************************************************************************ * * * Converting SGML Catalogs to XML * * * ************************************************************************/ /** * xmlCatalogConvertEntry: * @entry: the entry * @catal: pointer to the catalog being converted * * Convert one entry from the catalog */ static void xmlCatalogConvertEntry(xmlCatalogEntryPtr entry, xmlCatalogPtr catal) { if ((entry == NULL) || (catal == NULL) || (catal->sgml == NULL) || (catal->xml == NULL)) return; switch (entry->type) { case SGML_CATA_ENTITY: entry->type = XML_CATA_PUBLIC; break; case SGML_CATA_PENTITY: entry->type = XML_CATA_PUBLIC; break; case SGML_CATA_DOCTYPE: entry->type = XML_CATA_PUBLIC; break; case SGML_CATA_LINKTYPE: entry->type = XML_CATA_PUBLIC; break; case SGML_CATA_NOTATION: entry->type = XML_CATA_PUBLIC; break; case SGML_CATA_PUBLIC: entry->type = XML_CATA_PUBLIC; break; case SGML_CATA_SYSTEM: entry->type = XML_CATA_SYSTEM; break; case SGML_CATA_DELEGATE: entry->type = XML_CATA_DELEGATE_PUBLIC; break; case SGML_CATA_CATALOG: entry->type = XML_CATA_CATALOG; break; default: xmlHashRemoveEntry(catal->sgml, entry->name, (xmlHashDeallocator) xmlFreeCatalogEntry); return; } /* * Conversion successful, remove from the SGML catalog * and add it to the default XML one */ xmlHashRemoveEntry(catal->sgml, entry->name, NULL); entry->parent = catal->xml; entry->next = NULL; if (catal->xml->children == NULL) catal->xml->children = entry; else { xmlCatalogEntryPtr prev; prev = catal->xml->children; while (prev->next != NULL) prev = prev->next; prev->next = entry; } } /** * xmlConvertSGMLCatalog: * @catal: the catalog * * Convert all the SGML catalog entries as XML ones * * Returns the number of entries converted if successful, -1 otherwise */ int xmlConvertSGMLCatalog(xmlCatalogPtr catal) { if ((catal == NULL) || (catal->type != XML_SGML_CATALOG_TYPE)) return(-1); if (xmlDebugCatalogs) { xmlGenericError(xmlGenericErrorContext, "Converting SGML catalog to XML\n"); } xmlHashScan(catal->sgml, (xmlHashScanner) xmlCatalogConvertEntry, &catal); return(0); } /************************************************************************ * * * Helper function * * * ************************************************************************/ /** * xmlCatalogUnWrapURN: * @urn: an "urn:publicid:" to unwrap * * Expand the URN into the equivalent Public Identifier * * Returns the new identifier or NULL, the string must be deallocated * by the caller. */ static xmlChar * xmlCatalogUnWrapURN(const xmlChar *urn) { xmlChar result[2000]; unsigned int i = 0; if (xmlStrncmp(urn, BAD_CAST XML_URN_PUBID, sizeof(XML_URN_PUBID) - 1)) return(NULL); urn += sizeof(XML_URN_PUBID) - 1; while (*urn != 0) { if (i > sizeof(result) - 4) break; if (*urn == '+') { result[i++] = ' '; urn++; } else if (*urn == ':') { result[i++] = '/'; result[i++] = '/'; urn++; } else if (*urn == ';') { result[i++] = ':'; result[i++] = ':'; urn++; } else if (*urn == '%') { if ((urn[1] == '2') && (urn[2] == 'B')) result[i++] = '+'; else if ((urn[1] == '3') && (urn[2] == 'A')) result[i++] = ':'; else if ((urn[1] == '2') && (urn[2] == 'F')) result[i++] = '/'; else if ((urn[1] == '3') && (urn[2] == 'B')) result[i++] = ';'; else if ((urn[1] == '2') && (urn[2] == '7')) result[i++] = '\''; else if ((urn[1] == '3') && (urn[2] == 'F')) result[i++] = '?'; else if ((urn[1] == '2') && (urn[2] == '3')) result[i++] = '#'; else if ((urn[1] == '2') && (urn[2] == '5')) result[i++] = '%'; else { result[i++] = *urn; urn++; continue; } urn += 3; } else { result[i++] = *urn; urn++; } } result[i] = 0; return(xmlStrdup(result)); } /** * xmlParseCatalogFile: * @filename: the filename * * parse an XML file and build a tree. It's like xmlParseFile() * except it bypass all catalog lookups. * * Returns the resulting document tree or NULL in case of error */ xmlDocPtr xmlParseCatalogFile(const char *filename) { xmlDocPtr ret; xmlParserCtxtPtr ctxt; char *directory = NULL; xmlParserInputPtr inputStream; xmlParserInputBufferPtr buf; ctxt = xmlNewParserCtxt(); if (ctxt == NULL) { #ifdef LIBXML_SAX1_ENABLED if (xmlDefaultSAXHandler.error != NULL) { xmlDefaultSAXHandler.error(NULL, "out of memory\n"); } #endif return(NULL); } buf = xmlParserInputBufferCreateFilename(filename, XML_CHAR_ENCODING_NONE); if (buf == NULL) { xmlFreeParserCtxt(ctxt); return(NULL); } inputStream = xmlNewInputStream(ctxt); if (inputStream == NULL) { xmlFreeParserCtxt(ctxt); return(NULL); } inputStream->filename = (char *) xmlCanonicPath((const xmlChar *)filename); inputStream->buf = buf; inputStream->base = inputStream->buf->buffer->content; inputStream->cur = inputStream->buf->buffer->content; inputStream->end = &inputStream->buf->buffer->content[inputStream->buf->buffer->use]; inputPush(ctxt, inputStream); if ((ctxt->directory == NULL) && (directory == NULL)) directory = xmlParserGetDirectory(filename); if ((ctxt->directory == NULL) && (directory != NULL)) ctxt->directory = directory; ctxt->valid = 0; ctxt->validate = 0; ctxt->loadsubset = 0; ctxt->pedantic = 0; ctxt->dictNames = 1; xmlParseDocument(ctxt); if (ctxt->wellFormed) ret = ctxt->myDoc; else { ret = NULL; xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL; } xmlFreeParserCtxt(ctxt); return(ret); } /** * xmlLoadFileContent: * @filename: a file path * * Load a file content into memory. * * Returns a pointer to the 0 terminated string or NULL in case of error */ static xmlChar * xmlLoadFileContent(const char *filename) { #ifdef HAVE_STAT int fd; #else FILE *fd; #endif int len; long size; #ifdef HAVE_STAT struct stat info; #endif xmlChar *content; if (filename == NULL) return (NULL); #ifdef HAVE_STAT if (stat(filename, &info) < 0) return (NULL); #endif #ifdef HAVE_STAT if ((fd = open(filename, O_RDONLY)) < 0) #else if ((fd = fopen(filename, "rb")) == NULL) #endif { return (NULL); } #ifdef HAVE_STAT size = info.st_size; #else if (fseek(fd, 0, SEEK_END) || (size = ftell(fd)) == EOF || fseek(fd, 0, SEEK_SET)) { /* File operations denied? ok, just close and return failure */ fclose(fd); return (NULL); } #endif content = xmlMallocAtomic(size + 10); if (content == NULL) { xmlCatalogErrMemory("allocating catalog data"); return (NULL); } #ifdef HAVE_STAT len = read(fd, content, size); #else len = fread(content, 1, size, fd); #endif if (len < 0) { xmlFree(content); return (NULL); } #ifdef HAVE_STAT close(fd); #else fclose(fd); #endif content[len] = 0; return(content); } /** * xmlCatalogNormalizePublic: * @pubID: the public ID string * * Normalizes the Public Identifier * * Implements 6.2. Public Identifier Normalization * from http://www.oasis-open.org/committees/entity/spec-2001-08-06.html * * Returns the new string or NULL, the string must be deallocated * by the caller. */ static xmlChar * xmlCatalogNormalizePublic(const xmlChar *pubID) { int ok = 1; int white; const xmlChar *p; xmlChar *ret; xmlChar *q; if (pubID == NULL) return(NULL); white = 1; for (p = pubID;*p != 0 && ok;p++) { if (!xmlIsBlank_ch(*p)) white = 0; else if (*p == 0x20 && !white) white = 1; else ok = 0; } if (ok && !white) /* is normalized */ return(NULL); ret = xmlStrdup(pubID); q = ret; white = 0; for (p = pubID;*p != 0;p++) { if (xmlIsBlank_ch(*p)) { if (q != ret) white = 1; } else { if (white) { *(q++) = 0x20; white = 0; } *(q++) = *p; } } *q = 0; return(ret); } /************************************************************************ * * * The XML Catalog parser * * * ************************************************************************/ static xmlCatalogEntryPtr xmlParseXMLCatalogFile(xmlCatalogPrefer prefer, const xmlChar *filename); static void xmlParseXMLCatalogNodeList(xmlNodePtr cur, xmlCatalogPrefer prefer, xmlCatalogEntryPtr parent, xmlCatalogEntryPtr cgroup); static xmlChar * xmlCatalogListXMLResolve(xmlCatalogEntryPtr catal, const xmlChar *pubID, const xmlChar *sysID); static xmlChar * xmlCatalogListXMLResolveURI(xmlCatalogEntryPtr catal, const xmlChar *URI); /** * xmlGetXMLCatalogEntryType: * @name: the name * * lookup the internal type associated to an XML catalog entry name * * Returns the type associated with that name */ static xmlCatalogEntryType xmlGetXMLCatalogEntryType(const xmlChar *name) { xmlCatalogEntryType type = XML_CATA_NONE; if (xmlStrEqual(name, (const xmlChar *) "system")) type = XML_CATA_SYSTEM; else if (xmlStrEqual(name, (const xmlChar *) "public")) type = XML_CATA_PUBLIC; else if (xmlStrEqual(name, (const xmlChar *) "rewriteSystem")) type = XML_CATA_REWRITE_SYSTEM; else if (xmlStrEqual(name, (const xmlChar *) "delegatePublic")) type = XML_CATA_DELEGATE_PUBLIC; else if (xmlStrEqual(name, (const xmlChar *) "delegateSystem")) type = XML_CATA_DELEGATE_SYSTEM; else if (xmlStrEqual(name, (const xmlChar *) "uri")) type = XML_CATA_URI; else if (xmlStrEqual(name, (const xmlChar *) "rewriteURI")) type = XML_CATA_REWRITE_URI; else if (xmlStrEqual(name, (const xmlChar *) "delegateURI")) type = XML_CATA_DELEGATE_URI; else if (xmlStrEqual(name, (const xmlChar *) "nextCatalog")) type = XML_CATA_NEXT_CATALOG; else if (xmlStrEqual(name, (const xmlChar *) "catalog")) type = XML_CATA_CATALOG; return(type); } /** * xmlParseXMLCatalogOneNode: * @cur: the XML node * @type: the type of Catalog entry * @name: the name of the node * @attrName: the attribute holding the value * @uriAttrName: the attribute holding the URI-Reference * @prefer: the PUBLIC vs. SYSTEM current preference value * @cgroup: the group which includes this node * * Finishes the examination of an XML tree node of a catalog and build * a Catalog entry from it. * * Returns the new Catalog entry node or NULL in case of error. */ static xmlCatalogEntryPtr xmlParseXMLCatalogOneNode(xmlNodePtr cur, xmlCatalogEntryType type, const xmlChar *name, const xmlChar *attrName, const xmlChar *uriAttrName, xmlCatalogPrefer prefer, xmlCatalogEntryPtr cgroup) { int ok = 1; xmlChar *uriValue; xmlChar *nameValue = NULL; xmlChar *base = NULL; xmlChar *URL = NULL; xmlCatalogEntryPtr ret = NULL; if (attrName != NULL) { nameValue = xmlGetProp(cur, attrName); if (nameValue == NULL) { xmlCatalogErr(ret, cur, XML_CATALOG_MISSING_ATTR, "%s entry lacks '%s'\n", name, attrName, NULL); ok = 0; } } uriValue = xmlGetProp(cur, uriAttrName); if (uriValue == NULL) { xmlCatalogErr(ret, cur, XML_CATALOG_MISSING_ATTR, "%s entry lacks '%s'\n", name, uriAttrName, NULL); ok = 0; } if (!ok) { if (nameValue != NULL) xmlFree(nameValue); if (uriValue != NULL) xmlFree(uriValue); return(NULL); } base = xmlNodeGetBase(cur->doc, cur); URL = xmlBuildURI(uriValue, base); if (URL != NULL) { if (xmlDebugCatalogs > 1) { if (nameValue != NULL) xmlGenericError(xmlGenericErrorContext, "Found %s: '%s' '%s'\n", name, nameValue, URL); else xmlGenericError(xmlGenericErrorContext, "Found %s: '%s'\n", name, URL); } ret = xmlNewCatalogEntry(type, nameValue, uriValue, URL, prefer, cgroup); } else { xmlCatalogErr(ret, cur, XML_CATALOG_ENTRY_BROKEN, "%s entry '%s' broken ?: %s\n", name, uriAttrName, uriValue); } if (nameValue != NULL) xmlFree(nameValue); if (uriValue != NULL) xmlFree(uriValue); if (base != NULL) xmlFree(base); if (URL != NULL) xmlFree(URL); return(ret); } /** * xmlParseXMLCatalogNode: * @cur: the XML node * @prefer: the PUBLIC vs. SYSTEM current preference value * @parent: the parent Catalog entry * @cgroup: the group which includes this node * * Examines an XML tree node of a catalog and build * a Catalog entry from it adding it to its parent. The examination can * be recursive. */ static void xmlParseXMLCatalogNode(xmlNodePtr cur, xmlCatalogPrefer prefer, xmlCatalogEntryPtr parent, xmlCatalogEntryPtr cgroup) { xmlChar *base = NULL; xmlCatalogEntryPtr entry = NULL; if (cur == NULL) return; if (xmlStrEqual(cur->name, BAD_CAST "group")) { xmlChar *prop; xmlCatalogPrefer pref = XML_CATA_PREFER_NONE; prop = xmlGetProp(cur, BAD_CAST "prefer"); if (prop != NULL) { if (xmlStrEqual(prop, BAD_CAST "system")) { prefer = XML_CATA_PREFER_SYSTEM; } else if (xmlStrEqual(prop, BAD_CAST "public")) { prefer = XML_CATA_PREFER_PUBLIC; } else { xmlCatalogErr(parent, cur, XML_CATALOG_PREFER_VALUE, "Invalid value for prefer: '%s'\n", prop, NULL, NULL); } xmlFree(prop); pref = prefer; } prop = xmlGetProp(cur, BAD_CAST "id"); base = xmlGetNsProp(cur, BAD_CAST "base", XML_XML_NAMESPACE); entry = xmlNewCatalogEntry(XML_CATA_GROUP, prop, base, NULL, pref, cgroup); xmlFree(prop); } else if (xmlStrEqual(cur->name, BAD_CAST "public")) { entry = xmlParseXMLCatalogOneNode(cur, XML_CATA_PUBLIC, BAD_CAST "public", BAD_CAST "publicId", BAD_CAST "uri", prefer, cgroup); } else if (xmlStrEqual(cur->name, BAD_CAST "system")) { entry = xmlParseXMLCatalogOneNode(cur, XML_CATA_SYSTEM, BAD_CAST "system", BAD_CAST "systemId", BAD_CAST "uri", prefer, cgroup); } else if (xmlStrEqual(cur->name, BAD_CAST "rewriteSystem")) { entry = xmlParseXMLCatalogOneNode(cur, XML_CATA_REWRITE_SYSTEM, BAD_CAST "rewriteSystem", BAD_CAST "systemIdStartString", BAD_CAST "rewritePrefix", prefer, cgroup); } else if (xmlStrEqual(cur->name, BAD_CAST "delegatePublic")) { entry = xmlParseXMLCatalogOneNode(cur, XML_CATA_DELEGATE_PUBLIC, BAD_CAST "delegatePublic", BAD_CAST "publicIdStartString", BAD_CAST "catalog", prefer, cgroup); } else if (xmlStrEqual(cur->name, BAD_CAST "delegateSystem")) { entry = xmlParseXMLCatalogOneNode(cur, XML_CATA_DELEGATE_SYSTEM, BAD_CAST "delegateSystem", BAD_CAST "systemIdStartString", BAD_CAST "catalog", prefer, cgroup); } else if (xmlStrEqual(cur->name, BAD_CAST "uri")) { entry = xmlParseXMLCatalogOneNode(cur, XML_CATA_URI, BAD_CAST "uri", BAD_CAST "name", BAD_CAST "uri", prefer, cgroup); } else if (xmlStrEqual(cur->name, BAD_CAST "rewriteURI")) { entry = xmlParseXMLCatalogOneNode(cur, XML_CATA_REWRITE_URI, BAD_CAST "rewriteURI", BAD_CAST "uriStartString", BAD_CAST "rewritePrefix", prefer, cgroup); } else if (xmlStrEqual(cur->name, BAD_CAST "delegateURI")) { entry = xmlParseXMLCatalogOneNode(cur, XML_CATA_DELEGATE_URI, BAD_CAST "delegateURI", BAD_CAST "uriStartString", BAD_CAST "catalog", prefer, cgroup); } else if (xmlStrEqual(cur->name, BAD_CAST "nextCatalog")) { entry = xmlParseXMLCatalogOneNode(cur, XML_CATA_NEXT_CATALOG, BAD_CAST "nextCatalog", NULL, BAD_CAST "catalog", prefer, cgroup); } if (entry != NULL) { if (parent != NULL) { entry->parent = parent; if (parent->children == NULL) parent->children = entry; else { xmlCatalogEntryPtr prev; prev = parent->children; while (prev->next != NULL) prev = prev->next; prev->next = entry; } } if (entry->type == XML_CATA_GROUP) { /* * Recurse to propagate prefer to the subtree * (xml:base handling is automated) */ xmlParseXMLCatalogNodeList(cur->children, prefer, parent, entry); } } if (base != NULL) xmlFree(base); } /** * xmlParseXMLCatalogNodeList: * @cur: the XML node list of siblings * @prefer: the PUBLIC vs. SYSTEM current preference value * @parent: the parent Catalog entry * @cgroup: the group which includes this list * * Examines a list of XML sibling nodes of a catalog and build * a list of Catalog entry from it adding it to the parent. * The examination will recurse to examine node subtrees. */ static void xmlParseXMLCatalogNodeList(xmlNodePtr cur, xmlCatalogPrefer prefer, xmlCatalogEntryPtr parent, xmlCatalogEntryPtr cgroup) { while (cur != NULL) { if ((cur->ns != NULL) && (cur->ns->href != NULL) && (xmlStrEqual(cur->ns->href, XML_CATALOGS_NAMESPACE))) { xmlParseXMLCatalogNode(cur, prefer, parent, cgroup); } cur = cur->next; } /* TODO: sort the list according to REWRITE lengths and prefer value */ } /** * xmlParseXMLCatalogFile: * @prefer: the PUBLIC vs. SYSTEM current preference value * @filename: the filename for the catalog * * Parses the catalog file to extract the XML tree and then analyze the * tree to build a list of Catalog entries corresponding to this catalog * * Returns the resulting Catalog entries list */ static xmlCatalogEntryPtr xmlParseXMLCatalogFile(xmlCatalogPrefer prefer, const xmlChar *filename) { xmlDocPtr doc; xmlNodePtr cur; xmlChar *prop; xmlCatalogEntryPtr parent = NULL; if (filename == NULL) return(NULL); doc = xmlParseCatalogFile((const char *) filename); if (doc == NULL) { if (xmlDebugCatalogs) xmlGenericError(xmlGenericErrorContext, "Failed to parse catalog %s\n", filename); return(NULL); } if (xmlDebugCatalogs) xmlGenericError(xmlGenericErrorContext, "%d Parsing catalog %s\n", xmlGetThreadId(), filename); cur = xmlDocGetRootElement(doc); if ((cur != NULL) && (xmlStrEqual(cur->name, BAD_CAST "catalog")) && (cur->ns != NULL) && (cur->ns->href != NULL) && (xmlStrEqual(cur->ns->href, XML_CATALOGS_NAMESPACE))) { parent = xmlNewCatalogEntry(XML_CATA_CATALOG, NULL, (const xmlChar *)filename, NULL, prefer, NULL); if (parent == NULL) { xmlFreeDoc(doc); return(NULL); } prop = xmlGetProp(cur, BAD_CAST "prefer"); if (prop != NULL) { if (xmlStrEqual(prop, BAD_CAST "system")) { prefer = XML_CATA_PREFER_SYSTEM; } else if (xmlStrEqual(prop, BAD_CAST "public")) { prefer = XML_CATA_PREFER_PUBLIC; } else { xmlCatalogErr(NULL, cur, XML_CATALOG_PREFER_VALUE, "Invalid value for prefer: '%s'\n", prop, NULL, NULL); } xmlFree(prop); } cur = cur->children; xmlParseXMLCatalogNodeList(cur, prefer, parent, NULL); } else { xmlCatalogErr(NULL, (xmlNodePtr) doc, XML_CATALOG_NOT_CATALOG, "File %s is not an XML Catalog\n", filename, NULL, NULL); xmlFreeDoc(doc); return(NULL); } xmlFreeDoc(doc); return(parent); } /** * xmlFetchXMLCatalogFile: * @catal: an existing but incomplete catalog entry * * Fetch and parse the subcatalog referenced by an entry * * Returns 0 in case of success, -1 otherwise */ static int xmlFetchXMLCatalogFile(xmlCatalogEntryPtr catal) { xmlCatalogEntryPtr doc; if (catal == NULL) return(-1); if (catal->URL == NULL) return(-1); if (catal->children != NULL) return(-1); /* * lock the whole catalog for modification */ xmlRMutexLock(xmlCatalogMutex); if (catal->children != NULL) { /* Okay someone else did it in the meantime */ xmlRMutexUnlock(xmlCatalogMutex); return(0); } if (xmlCatalogXMLFiles != NULL) { doc = (xmlCatalogEntryPtr) xmlHashLookup(xmlCatalogXMLFiles, catal->URL); if (doc != NULL) { if (xmlDebugCatalogs) xmlGenericError(xmlGenericErrorContext, "Found %s in file hash\n", catal->URL); if (catal->type == XML_CATA_CATALOG) catal->children = doc->children; else catal->children = doc; catal->dealloc = 0; xmlRMutexUnlock(xmlCatalogMutex); return(0); } if (xmlDebugCatalogs) xmlGenericError(xmlGenericErrorContext, "%s not found in file hash\n", catal->URL); } /* * Fetch and parse. Note that xmlParseXMLCatalogFile does not * use the existing catalog, there is no recursion allowed at * that level. */ doc = xmlParseXMLCatalogFile(catal->prefer, catal->URL); if (doc == NULL) { catal->type = XML_CATA_BROKEN_CATALOG; xmlRMutexUnlock(xmlCatalogMutex); return(-1); } if (catal->type == XML_CATA_CATALOG) catal->children = doc->children; else catal->children = doc; doc->dealloc = 1; if (xmlCatalogXMLFiles == NULL) xmlCatalogXMLFiles = xmlHashCreate(10); if (xmlCatalogXMLFiles != NULL) { if (xmlDebugCatalogs) xmlGenericError(xmlGenericErrorContext, "%s added to file hash\n", catal->URL); xmlHashAddEntry(xmlCatalogXMLFiles, catal->URL, doc); } xmlRMutexUnlock(xmlCatalogMutex); return(0); } /************************************************************************ * * * XML Catalog handling * * * ************************************************************************/ /** * xmlAddXMLCatalog: * @catal: top of an XML catalog * @type: the type of record to add to the catalog * @orig: the system, public or prefix to match (or NULL) * @replace: the replacement value for the match * * Add an entry in the XML catalog, it may overwrite existing but * different entries. * * Returns 0 if successful, -1 otherwise */ static int xmlAddXMLCatalog(xmlCatalogEntryPtr catal, const xmlChar *type, const xmlChar *orig, const xmlChar *replace) { xmlCatalogEntryPtr cur; xmlCatalogEntryType typ; int doregister = 0; if ((catal == NULL) || ((catal->type != XML_CATA_CATALOG) && (catal->type != XML_CATA_BROKEN_CATALOG))) return(-1); if (catal->children == NULL) { xmlFetchXMLCatalogFile(catal); } if (catal->children == NULL) doregister = 1; typ = xmlGetXMLCatalogEntryType(type); if (typ == XML_CATA_NONE) { if (xmlDebugCatalogs) xmlGenericError(xmlGenericErrorContext, "Failed to add unknown element %s to catalog\n", type); return(-1); } cur = catal->children; /* * Might be a simple "update in place" */ if (cur != NULL) { while (cur != NULL) { if ((orig != NULL) && (cur->type == typ) && (xmlStrEqual(orig, cur->name))) { if (xmlDebugCatalogs) xmlGenericError(xmlGenericErrorContext, "Updating element %s to catalog\n", type); if (cur->value != NULL) xmlFree(cur->value); if (cur->URL != NULL) xmlFree(cur->URL); cur->value = xmlStrdup(replace); cur->URL = xmlStrdup(replace); return(0); } if (cur->next == NULL) break; cur = cur->next; } } if (xmlDebugCatalogs) xmlGenericError(xmlGenericErrorContext, "Adding element %s to catalog\n", type); if (cur == NULL) catal->children = xmlNewCatalogEntry(typ, orig, replace, NULL, catal->prefer, NULL); else cur->next = xmlNewCatalogEntry(typ, orig, replace, NULL, catal->prefer, NULL); if (doregister) { catal->type = XML_CATA_CATALOG; cur = xmlHashLookup(xmlCatalogXMLFiles, catal->URL); if (cur != NULL) cur->children = catal->children; } return(0); } /** * xmlDelXMLCatalog: * @catal: top of an XML catalog * @value: the value to remove from the catalog * * Remove entries in the XML catalog where the value or the URI * is equal to @value * * Returns the number of entries removed if successful, -1 otherwise */ static int xmlDelXMLCatalog(xmlCatalogEntryPtr catal, const xmlChar *value) { xmlCatalogEntryPtr cur; int ret = 0; if ((catal == NULL) || ((catal->type != XML_CATA_CATALOG) && (catal->type != XML_CATA_BROKEN_CATALOG))) return(-1); if (value == NULL) return(-1); if (catal->children == NULL) { xmlFetchXMLCatalogFile(catal); } /* * Scan the children */ cur = catal->children; while (cur != NULL) { if (((cur->name != NULL) && (xmlStrEqual(value, cur->name))) || (xmlStrEqual(value, cur->value))) { if (xmlDebugCatalogs) { if (cur->name != NULL) xmlGenericError(xmlGenericErrorContext, "Removing element %s from catalog\n", cur->name); else xmlGenericError(xmlGenericErrorContext, "Removing element %s from catalog\n", cur->value); } cur->type = XML_CATA_REMOVED; } cur = cur->next; } return(ret); } /** * xmlCatalogXMLResolve: * @catal: a catalog list * @pubID: the public ID string * @sysID: the system ID string * * Do a complete resolution lookup of an External Identifier for a * list of catalog entries. * * Implements (or tries to) 7.1. External Identifier Resolution * from http://www.oasis-open.org/committees/entity/spec-2001-08-06.html * * Returns the URI of the resource or NULL if not found */ static xmlChar * xmlCatalogXMLResolve(xmlCatalogEntryPtr catal, const xmlChar *pubID, const xmlChar *sysID) { xmlChar *ret = NULL; xmlCatalogEntryPtr cur; int haveDelegate = 0; int haveNext = 0; /* * protection against loops */ if (catal->depth > MAX_CATAL_DEPTH) { xmlCatalogErr(catal, NULL, XML_CATALOG_RECURSION, "Detected recursion in catalog %s\n", catal->name, NULL, NULL); return(NULL); } catal->depth++; /* * First tries steps 2/ 3/ 4/ if a system ID is provided. */ if (sysID != NULL) { xmlCatalogEntryPtr rewrite = NULL; int lenrewrite = 0, len; cur = catal; haveDelegate = 0; while (cur != NULL) { switch (cur->type) { case XML_CATA_SYSTEM: if (xmlStrEqual(sysID, cur->name)) { if (xmlDebugCatalogs) xmlGenericError(xmlGenericErrorContext, "Found system match %s, using %s\n", cur->name, cur->URL); catal->depth--; return(xmlStrdup(cur->URL)); } break; case XML_CATA_REWRITE_SYSTEM: len = xmlStrlen(cur->name); if ((len > lenrewrite) && (!xmlStrncmp(sysID, cur->name, len))) { lenrewrite = len; rewrite = cur; } break; case XML_CATA_DELEGATE_SYSTEM: if (!xmlStrncmp(sysID, cur->name, xmlStrlen(cur->name))) haveDelegate++; break; case XML_CATA_NEXT_CATALOG: haveNext++; break; default: break; } cur = cur->next; } if (rewrite != NULL) { if (xmlDebugCatalogs) xmlGenericError(xmlGenericErrorContext, "Using rewriting rule %s\n", rewrite->name); ret = xmlStrdup(rewrite->URL); if (ret != NULL) ret = xmlStrcat(ret, &sysID[lenrewrite]); catal->depth--; return(ret); } if (haveDelegate) { const xmlChar *delegates[MAX_DELEGATE]; int nbList = 0, i; /* * Assume the entries have been sorted by decreasing substring * matches when the list was produced. */ cur = catal; while (cur != NULL) { if ((cur->type == XML_CATA_DELEGATE_SYSTEM) && (!xmlStrncmp(sysID, cur->name, xmlStrlen(cur->name)))) { for (i = 0;i < nbList;i++) if (xmlStrEqual(cur->URL, delegates[i])) break; if (i < nbList) { cur = cur->next; continue; } if (nbList < MAX_DELEGATE) delegates[nbList++] = cur->URL; if (cur->children == NULL) { xmlFetchXMLCatalogFile(cur); } if (cur->children != NULL) { if (xmlDebugCatalogs) xmlGenericError(xmlGenericErrorContext, "Trying system delegate %s\n", cur->URL); ret = xmlCatalogListXMLResolve( cur->children, NULL, sysID); if (ret != NULL) { catal->depth--; return(ret); } } } cur = cur->next; } /* * Apply the cut algorithm explained in 4/ */ catal->depth--; return(XML_CATAL_BREAK); } } /* * Then tries 5/ 6/ if a public ID is provided */ if (pubID != NULL) { cur = catal; haveDelegate = 0; while (cur != NULL) { switch (cur->type) { case XML_CATA_PUBLIC: if (xmlStrEqual(pubID, cur->name)) { if (xmlDebugCatalogs) xmlGenericError(xmlGenericErrorContext, "Found public match %s\n", cur->name); catal->depth--; return(xmlStrdup(cur->URL)); } break; case XML_CATA_DELEGATE_PUBLIC: if (!xmlStrncmp(pubID, cur->name, xmlStrlen(cur->name)) && (cur->prefer == XML_CATA_PREFER_PUBLIC)) haveDelegate++; break; case XML_CATA_NEXT_CATALOG: if (sysID == NULL) haveNext++; break; default: break; } cur = cur->next; } if (haveDelegate) { const xmlChar *delegates[MAX_DELEGATE]; int nbList = 0, i; /* * Assume the entries have been sorted by decreasing substring * matches when the list was produced. */ cur = catal; while (cur != NULL) { if ((cur->type == XML_CATA_DELEGATE_PUBLIC) && (cur->prefer == XML_CATA_PREFER_PUBLIC) && (!xmlStrncmp(pubID, cur->name, xmlStrlen(cur->name)))) { for (i = 0;i < nbList;i++) if (xmlStrEqual(cur->URL, delegates[i])) break; if (i < nbList) { cur = cur->next; continue; } if (nbList < MAX_DELEGATE) delegates[nbList++] = cur->URL; if (cur->children == NULL) { xmlFetchXMLCatalogFile(cur); } if (cur->children != NULL) { if (xmlDebugCatalogs) xmlGenericError(xmlGenericErrorContext, "Trying public delegate %s\n", cur->URL); ret = xmlCatalogListXMLResolve( cur->children, pubID, NULL); if (ret != NULL) { catal->depth--; return(ret); } } } cur = cur->next; } /* * Apply the cut algorithm explained in 4/ */ catal->depth--; return(XML_CATAL_BREAK); } } if (haveNext) { cur = catal; while (cur != NULL) { if (cur->type == XML_CATA_NEXT_CATALOG) { if (cur->children == NULL) { xmlFetchXMLCatalogFile(cur); } if (cur->children != NULL) { ret = xmlCatalogListXMLResolve(cur->children, pubID, sysID); if (ret != NULL) { catal->depth--; return(ret); } } } cur = cur->next; } } catal->depth--; return(NULL); } /** * xmlCatalogXMLResolveURI: * @catal: a catalog list * @URI: the URI * @sysID: the system ID string * * Do a complete resolution lookup of an External Identifier for a * list of catalog entries. * * Implements (or tries to) 7.2.2. URI Resolution * from http://www.oasis-open.org/committees/entity/spec-2001-08-06.html * * Returns the URI of the resource or NULL if not found */ static xmlChar * xmlCatalogXMLResolveURI(xmlCatalogEntryPtr catal, const xmlChar *URI) { xmlChar *ret = NULL; xmlCatalogEntryPtr cur; int haveDelegate = 0; int haveNext = 0; xmlCatalogEntryPtr rewrite = NULL; int lenrewrite = 0, len; if (catal == NULL) return(NULL); if (URI == NULL) return(NULL); /* * First tries steps 2/ 3/ 4/ if a system ID is provided. */ cur = catal; haveDelegate = 0; while (cur != NULL) { switch (cur->type) { case XML_CATA_URI: if (xmlStrEqual(URI, cur->name)) { if (xmlDebugCatalogs) xmlGenericError(xmlGenericErrorContext, "Found URI match %s\n", cur->name); return(xmlStrdup(cur->URL)); } break; case XML_CATA_REWRITE_URI: len = xmlStrlen(cur->name); if ((len > lenrewrite) && (!xmlStrncmp(URI, cur->name, len))) { lenrewrite = len; rewrite = cur; } break; case XML_CATA_DELEGATE_URI: if (!xmlStrncmp(URI, cur->name, xmlStrlen(cur->name))) haveDelegate++; break; case XML_CATA_NEXT_CATALOG: haveNext++; break; default: break; } cur = cur->next; } if (rewrite != NULL) { if (xmlDebugCatalogs) xmlGenericError(xmlGenericErrorContext, "Using rewriting rule %s\n", rewrite->name); ret = xmlStrdup(rewrite->URL); if (ret != NULL) ret = xmlStrcat(ret, &URI[lenrewrite]); return(ret); } if (haveDelegate) { const xmlChar *delegates[MAX_DELEGATE]; int nbList = 0, i; /* * Assume the entries have been sorted by decreasing substring * matches when the list was produced. */ cur = catal; while (cur != NULL) { if (((cur->type == XML_CATA_DELEGATE_SYSTEM) || (cur->type == XML_CATA_DELEGATE_URI)) && (!xmlStrncmp(URI, cur->name, xmlStrlen(cur->name)))) { for (i = 0;i < nbList;i++) if (xmlStrEqual(cur->URL, delegates[i])) break; if (i < nbList) { cur = cur->next; continue; } if (nbList < MAX_DELEGATE) delegates[nbList++] = cur->URL; if (cur->children == NULL) { xmlFetchXMLCatalogFile(cur); } if (cur->children != NULL) { if (xmlDebugCatalogs) xmlGenericError(xmlGenericErrorContext, "Trying URI delegate %s\n", cur->URL); ret = xmlCatalogListXMLResolveURI( cur->children, URI); if (ret != NULL) return(ret); } } cur = cur->next; } /* * Apply the cut algorithm explained in 4/ */ return(XML_CATAL_BREAK); } if (haveNext) { cur = catal; while (cur != NULL) { if (cur->type == XML_CATA_NEXT_CATALOG) { if (cur->children == NULL) { xmlFetchXMLCatalogFile(cur); } if (cur->children != NULL) { ret = xmlCatalogListXMLResolveURI(cur->children, URI); if (ret != NULL) return(ret); } } cur = cur->next; } } return(NULL); } /** * xmlCatalogListXMLResolve: * @catal: a catalog list * @pubID: the public ID string * @sysID: the system ID string * * Do a complete resolution lookup of an External Identifier for a * list of catalogs * * Implements (or tries to) 7.1. External Identifier Resolution * from http://www.oasis-open.org/committees/entity/spec-2001-08-06.html * * Returns the URI of the resource or NULL if not found */ static xmlChar * xmlCatalogListXMLResolve(xmlCatalogEntryPtr catal, const xmlChar *pubID, const xmlChar *sysID) { xmlChar *ret = NULL; xmlChar *urnID = NULL; xmlChar *normid; if (catal == NULL) return(NULL); if ((pubID == NULL) && (sysID == NULL)) return(NULL); normid = xmlCatalogNormalizePublic(pubID); if (normid != NULL) pubID = (*normid != 0 ? normid : NULL); if (!xmlStrncmp(pubID, BAD_CAST XML_URN_PUBID, sizeof(XML_URN_PUBID) - 1)) { urnID = xmlCatalogUnWrapURN(pubID); if (xmlDebugCatalogs) { if (urnID == NULL) xmlGenericError(xmlGenericErrorContext, "Public URN ID %s expanded to NULL\n", pubID); else xmlGenericError(xmlGenericErrorContext, "Public URN ID expanded to %s\n", urnID); } ret = xmlCatalogListXMLResolve(catal, urnID, sysID); if (urnID != NULL) xmlFree(urnID); if (normid != NULL) xmlFree(normid); return(ret); } if (!xmlStrncmp(sysID, BAD_CAST XML_URN_PUBID, sizeof(XML_URN_PUBID) - 1)) { urnID = xmlCatalogUnWrapURN(sysID); if (xmlDebugCatalogs) { if (urnID == NULL) xmlGenericError(xmlGenericErrorContext, "System URN ID %s expanded to NULL\n", sysID); else xmlGenericError(xmlGenericErrorContext, "System URN ID expanded to %s\n", urnID); } if (pubID == NULL) ret = xmlCatalogListXMLResolve(catal, urnID, NULL); else if (xmlStrEqual(pubID, urnID)) ret = xmlCatalogListXMLResolve(catal, pubID, NULL); else { ret = xmlCatalogListXMLResolve(catal, pubID, urnID); } if (urnID != NULL) xmlFree(urnID); if (normid != NULL) xmlFree(normid); return(ret); } while (catal != NULL) { if (catal->type == XML_CATA_CATALOG) { if (catal->children == NULL) { xmlFetchXMLCatalogFile(catal); } if (catal->children != NULL) { ret = xmlCatalogXMLResolve(catal->children, pubID, sysID); if (ret != NULL) { if (normid != NULL) xmlFree(normid); return(ret); } } } catal = catal->next; } if (normid != NULL) xmlFree(normid); return(ret); } /** * xmlCatalogListXMLResolveURI: * @catal: a catalog list * @URI: the URI * * Do a complete resolution lookup of an URI for a list of catalogs * * Implements (or tries to) 7.2. URI Resolution * from http://www.oasis-open.org/committees/entity/spec-2001-08-06.html * * Returns the URI of the resource or NULL if not found */ static xmlChar * xmlCatalogListXMLResolveURI(xmlCatalogEntryPtr catal, const xmlChar *URI) { xmlChar *ret = NULL; xmlChar *urnID = NULL; if (catal == NULL) return(NULL); if (URI == NULL) return(NULL); if (!xmlStrncmp(URI, BAD_CAST XML_URN_PUBID, sizeof(XML_URN_PUBID) - 1)) { urnID = xmlCatalogUnWrapURN(URI); if (xmlDebugCatalogs) { if (urnID == NULL) xmlGenericError(xmlGenericErrorContext, "URN ID %s expanded to NULL\n", URI); else xmlGenericError(xmlGenericErrorContext, "URN ID expanded to %s\n", urnID); } ret = xmlCatalogListXMLResolve(catal, urnID, NULL); if (urnID != NULL) xmlFree(urnID); return(ret); } while (catal != NULL) { if (catal->type == XML_CATA_CATALOG) { if (catal->children == NULL) { xmlFetchXMLCatalogFile(catal); } if (catal->children != NULL) { ret = xmlCatalogXMLResolveURI(catal->children, URI); if (ret != NULL) return(ret); } } catal = catal->next; } return(ret); } /************************************************************************ * * * The SGML Catalog parser * * * ************************************************************************/ #define RAW *cur #define NEXT cur++; #define SKIP(x) cur += x; #define SKIP_BLANKS while (IS_BLANK_CH(*cur)) NEXT; /** * xmlParseSGMLCatalogComment: * @cur: the current character * * Skip a comment in an SGML catalog * * Returns new current character */ static const xmlChar * xmlParseSGMLCatalogComment(const xmlChar *cur) { if ((cur[0] != '-') || (cur[1] != '-')) return(cur); SKIP(2); while ((cur[0] != 0) && ((cur[0] != '-') || ((cur[1] != '-')))) NEXT; if (cur[0] == 0) { return(NULL); } return(cur + 2); } /** * xmlParseSGMLCatalogPubid: * @cur: the current character * @id: the return location * * Parse an SGML catalog ID * * Returns new current character and store the value in @id */ static const xmlChar * xmlParseSGMLCatalogPubid(const xmlChar *cur, xmlChar **id) { xmlChar *buf = NULL, *tmp; int len = 0; int size = 50; xmlChar stop; int count = 0; *id = NULL; if (RAW == '"') { NEXT; stop = '"'; } else if (RAW == '\'') { NEXT; stop = '\''; } else { stop = ' '; } buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar)); if (buf == NULL) { xmlCatalogErrMemory("allocating public ID"); return(NULL); } while (IS_PUBIDCHAR_CH(*cur) || (*cur == '?')) { if ((*cur == stop) && (stop != ' ')) break; if ((stop == ' ') && (IS_BLANK_CH(*cur))) break; if (len + 1 >= size) { size *= 2; tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar)); if (tmp == NULL) { xmlCatalogErrMemory("allocating public ID"); xmlFree(buf); return(NULL); } buf = tmp; } buf[len++] = *cur; count++; NEXT; } buf[len] = 0; if (stop == ' ') { if (!IS_BLANK_CH(*cur)) { xmlFree(buf); return(NULL); } } else { if (*cur != stop) { xmlFree(buf); return(NULL); } NEXT; } *id = buf; return(cur); } /** * xmlParseSGMLCatalogName: * @cur: the current character * @name: the return location * * Parse an SGML catalog name * * Returns new current character and store the value in @name */ static const xmlChar * xmlParseSGMLCatalogName(const xmlChar *cur, xmlChar **name) { xmlChar buf[XML_MAX_NAMELEN + 5]; int len = 0; int c; *name = NULL; /* * Handler for more complex cases */ c = *cur; if ((!IS_LETTER(c) && (c != '_') && (c != ':'))) { return(NULL); } while (((IS_LETTER(c)) || (IS_DIGIT(c)) || (c == '.') || (c == '-') || (c == '_') || (c == ':'))) { buf[len++] = c; cur++; c = *cur; if (len >= XML_MAX_NAMELEN) return(NULL); } *name = xmlStrndup(buf, len); return(cur); } /** * xmlGetSGMLCatalogEntryType: * @name: the entry name * * Get the Catalog entry type for a given SGML Catalog name * * Returns Catalog entry type */ static xmlCatalogEntryType xmlGetSGMLCatalogEntryType(const xmlChar *name) { xmlCatalogEntryType type = XML_CATA_NONE; if (xmlStrEqual(name, (const xmlChar *) "SYSTEM")) type = SGML_CATA_SYSTEM; else if (xmlStrEqual(name, (const xmlChar *) "PUBLIC")) type = SGML_CATA_PUBLIC; else if (xmlStrEqual(name, (const xmlChar *) "DELEGATE")) type = SGML_CATA_DELEGATE; else if (xmlStrEqual(name, (const xmlChar *) "ENTITY")) type = SGML_CATA_ENTITY; else if (xmlStrEqual(name, (const xmlChar *) "DOCTYPE")) type = SGML_CATA_DOCTYPE; else if (xmlStrEqual(name, (const xmlChar *) "LINKTYPE")) type = SGML_CATA_LINKTYPE; else if (xmlStrEqual(name, (const xmlChar *) "NOTATION")) type = SGML_CATA_NOTATION; else if (xmlStrEqual(name, (const xmlChar *) "SGMLDECL")) type = SGML_CATA_SGMLDECL; else if (xmlStrEqual(name, (const xmlChar *) "DOCUMENT")) type = SGML_CATA_DOCUMENT; else if (xmlStrEqual(name, (const xmlChar *) "CATALOG")) type = SGML_CATA_CATALOG; else if (xmlStrEqual(name, (const xmlChar *) "BASE")) type = SGML_CATA_BASE; return(type); } /** * xmlParseSGMLCatalog: * @catal: the SGML Catalog * @value: the content of the SGML Catalog serialization * @file: the filepath for the catalog * @super: should this be handled as a Super Catalog in which case * parsing is not recursive * * Parse an SGML catalog content and fill up the @catal hash table with * the new entries found. * * Returns 0 in case of success, -1 in case of error. */ static int xmlParseSGMLCatalog(xmlCatalogPtr catal, const xmlChar *value, const char *file, int super) { const xmlChar *cur = value; xmlChar *base = NULL; int res; if ((cur == NULL) || (file == NULL)) return(-1); base = xmlStrdup((const xmlChar *) file); while ((cur != NULL) && (cur[0] != 0)) { SKIP_BLANKS; if (cur[0] == 0) break; if ((cur[0] == '-') && (cur[1] == '-')) { cur = xmlParseSGMLCatalogComment(cur); if (cur == NULL) { /* error */ break; } } else { xmlChar *sysid = NULL; xmlChar *name = NULL; xmlCatalogEntryType type = XML_CATA_NONE; cur = xmlParseSGMLCatalogName(cur, &name); if (name == NULL) { /* error */ break; } if (!IS_BLANK_CH(*cur)) { /* error */ break; } SKIP_BLANKS; if (xmlStrEqual(name, (const xmlChar *) "SYSTEM")) type = SGML_CATA_SYSTEM; else if (xmlStrEqual(name, (const xmlChar *) "PUBLIC")) type = SGML_CATA_PUBLIC; else if (xmlStrEqual(name, (const xmlChar *) "DELEGATE")) type = SGML_CATA_DELEGATE; else if (xmlStrEqual(name, (const xmlChar *) "ENTITY")) type = SGML_CATA_ENTITY; else if (xmlStrEqual(name, (const xmlChar *) "DOCTYPE")) type = SGML_CATA_DOCTYPE; else if (xmlStrEqual(name, (const xmlChar *) "LINKTYPE")) type = SGML_CATA_LINKTYPE; else if (xmlStrEqual(name, (const xmlChar *) "NOTATION")) type = SGML_CATA_NOTATION; else if (xmlStrEqual(name, (const xmlChar *) "SGMLDECL")) type = SGML_CATA_SGMLDECL; else if (xmlStrEqual(name, (const xmlChar *) "DOCUMENT")) type = SGML_CATA_DOCUMENT; else if (xmlStrEqual(name, (const xmlChar *) "CATALOG")) type = SGML_CATA_CATALOG; else if (xmlStrEqual(name, (const xmlChar *) "BASE")) type = SGML_CATA_BASE; else if (xmlStrEqual(name, (const xmlChar *) "OVERRIDE")) { xmlFree(name); cur = xmlParseSGMLCatalogName(cur, &name); if (name == NULL) { /* error */ break; } xmlFree(name); continue; } xmlFree(name); name = NULL; switch(type) { case SGML_CATA_ENTITY: if (*cur == '%') type = SGML_CATA_PENTITY; case SGML_CATA_PENTITY: case SGML_CATA_DOCTYPE: case SGML_CATA_LINKTYPE: case SGML_CATA_NOTATION: cur = xmlParseSGMLCatalogName(cur, &name); if (cur == NULL) { /* error */ break; } if (!IS_BLANK_CH(*cur)) { /* error */ break; } SKIP_BLANKS; cur = xmlParseSGMLCatalogPubid(cur, &sysid); if (cur == NULL) { /* error */ break; } break; case SGML_CATA_PUBLIC: case SGML_CATA_SYSTEM: case SGML_CATA_DELEGATE: cur = xmlParseSGMLCatalogPubid(cur, &name); if (cur == NULL) { /* error */ break; } if (type != SGML_CATA_SYSTEM) { xmlChar *normid; normid = xmlCatalogNormalizePublic(name); if (normid != NULL) { if (name != NULL) xmlFree(name); if (*normid != 0) name = normid; else { xmlFree(normid); name = NULL; } } } if (!IS_BLANK_CH(*cur)) { /* error */ break; } SKIP_BLANKS; cur = xmlParseSGMLCatalogPubid(cur, &sysid); if (cur == NULL) { /* error */ break; } break; case SGML_CATA_BASE: case SGML_CATA_CATALOG: case SGML_CATA_DOCUMENT: case SGML_CATA_SGMLDECL: cur = xmlParseSGMLCatalogPubid(cur, &sysid); if (cur == NULL) { /* error */ break; } break; default: break; } if (cur == NULL) { if (name != NULL) xmlFree(name); if (sysid != NULL) xmlFree(sysid); break; } else if (type == SGML_CATA_BASE) { if (base != NULL) xmlFree(base); base = xmlStrdup(sysid); } else if ((type == SGML_CATA_PUBLIC) || (type == SGML_CATA_SYSTEM)) { xmlChar *filename; filename = xmlBuildURI(sysid, base); if (filename != NULL) { xmlCatalogEntryPtr entry; entry = xmlNewCatalogEntry(type, name, filename, NULL, XML_CATA_PREFER_NONE, NULL); res = xmlHashAddEntry(catal->sgml, name, entry); if (res < 0) { xmlFreeCatalogEntry(entry); } xmlFree(filename); } } else if (type == SGML_CATA_CATALOG) { if (super) { xmlCatalogEntryPtr entry; entry = xmlNewCatalogEntry(type, sysid, NULL, NULL, XML_CATA_PREFER_NONE, NULL); res = xmlHashAddEntry(catal->sgml, sysid, entry); if (res < 0) { xmlFreeCatalogEntry(entry); } } else { xmlChar *filename; filename = xmlBuildURI(sysid, base); if (filename != NULL) { xmlExpandCatalog(catal, (const char *)filename); xmlFree(filename); } } } /* * drop anything else we won't handle it */ if (name != NULL) xmlFree(name); if (sysid != NULL) xmlFree(sysid); } } if (base != NULL) xmlFree(base); if (cur == NULL) return(-1); return(0); } /************************************************************************ * * * SGML Catalog handling * * * ************************************************************************/ /** * xmlCatalogGetSGMLPublic: * @catal: an SGML catalog hash * @pubID: the public ID string * * Try to lookup the catalog local reference associated to a public ID * * Returns the local resource if found or NULL otherwise. */ static const xmlChar * xmlCatalogGetSGMLPublic(xmlHashTablePtr catal, const xmlChar *pubID) { xmlCatalogEntryPtr entry; xmlChar *normid; if (catal == NULL) return(NULL); normid = xmlCatalogNormalizePublic(pubID); if (normid != NULL) pubID = (*normid != 0 ? normid : NULL); entry = (xmlCatalogEntryPtr) xmlHashLookup(catal, pubID); if (entry == NULL) { if (normid != NULL) xmlFree(normid); return(NULL); } if (entry->type == SGML_CATA_PUBLIC) { if (normid != NULL) xmlFree(normid); return(entry->URL); } if (normid != NULL) xmlFree(normid); return(NULL); } /** * xmlCatalogGetSGMLSystem: * @catal: an SGML catalog hash * @sysID: the system ID string * * Try to lookup the catalog local reference for a system ID * * Returns the local resource if found or NULL otherwise. */ static const xmlChar * xmlCatalogGetSGMLSystem(xmlHashTablePtr catal, const xmlChar *sysID) { xmlCatalogEntryPtr entry; if (catal == NULL) return(NULL); entry = (xmlCatalogEntryPtr) xmlHashLookup(catal, sysID); if (entry == NULL) return(NULL); if (entry->type == SGML_CATA_SYSTEM) return(entry->URL); return(NULL); } /** * xmlCatalogSGMLResolve: * @catal: the SGML catalog * @pubID: the public ID string * @sysID: the system ID string * * Do a complete resolution lookup of an External Identifier * * Returns the URI of the resource or NULL if not found */ static const xmlChar * xmlCatalogSGMLResolve(xmlCatalogPtr catal, const xmlChar *pubID, const xmlChar *sysID) { const xmlChar *ret = NULL; if (catal->sgml == NULL) return(NULL); if (pubID != NULL) ret = xmlCatalogGetSGMLPublic(catal->sgml, pubID); if (ret != NULL) return(ret); if (sysID != NULL) ret = xmlCatalogGetSGMLSystem(catal->sgml, sysID); return(NULL); } /************************************************************************ * * * Specific Public interfaces * * * ************************************************************************/ /** * xmlLoadSGMLSuperCatalog: * @filename: a file path * * Load an SGML super catalog. It won't expand CATALOG or DELEGATE * references. This is only needed for manipulating SGML Super Catalogs * like adding and removing CATALOG or DELEGATE entries. * * Returns the catalog parsed or NULL in case of error */ xmlCatalogPtr xmlLoadSGMLSuperCatalog(const char *filename) { xmlChar *content; xmlCatalogPtr catal; int ret; content = xmlLoadFileContent(filename); if (content == NULL) return(NULL); catal = xmlCreateNewCatalog(XML_SGML_CATALOG_TYPE, xmlCatalogDefaultPrefer); if (catal == NULL) { xmlFree(content); return(NULL); } ret = xmlParseSGMLCatalog(catal, content, filename, 1); xmlFree(content); if (ret < 0) { xmlFreeCatalog(catal); return(NULL); } return (catal); } /** * xmlLoadACatalog: * @filename: a file path * * Load the catalog and build the associated data structures. * This can be either an XML Catalog or an SGML Catalog * It will recurse in SGML CATALOG entries. On the other hand XML * Catalogs are not handled recursively. * * Returns the catalog parsed or NULL in case of error */ xmlCatalogPtr xmlLoadACatalog(const char *filename) { xmlChar *content; xmlChar *first; xmlCatalogPtr catal; int ret; content = xmlLoadFileContent(filename); if (content == NULL) return(NULL); first = content; while ((*first != 0) && (*first != '-') && (*first != '<') && (!(((*first >= 'A') && (*first <= 'Z')) || ((*first >= 'a') && (*first <= 'z'))))) first++; if (*first != '<') { catal = xmlCreateNewCatalog(XML_SGML_CATALOG_TYPE, xmlCatalogDefaultPrefer); if (catal == NULL) { xmlFree(content); return(NULL); } ret = xmlParseSGMLCatalog(catal, content, filename, 0); if (ret < 0) { xmlFreeCatalog(catal); xmlFree(content); return(NULL); } } else { catal = xmlCreateNewCatalog(XML_XML_CATALOG_TYPE, xmlCatalogDefaultPrefer); if (catal == NULL) { xmlFree(content); return(NULL); } catal->xml = xmlNewCatalogEntry(XML_CATA_CATALOG, NULL, NULL, BAD_CAST filename, xmlCatalogDefaultPrefer, NULL); } xmlFree(content); return (catal); } /** * xmlExpandCatalog: * @catal: a catalog * @filename: a file path * * Load the catalog and expand the existing catal structure. * This can be either an XML Catalog or an SGML Catalog * * Returns 0 in case of success, -1 in case of error */ static int xmlExpandCatalog(xmlCatalogPtr catal, const char *filename) { int ret; if ((catal == NULL) || (filename == NULL)) return(-1); if (catal->type == XML_SGML_CATALOG_TYPE) { xmlChar *content; content = xmlLoadFileContent(filename); if (content == NULL) return(-1); ret = xmlParseSGMLCatalog(catal, content, filename, 0); if (ret < 0) { xmlFree(content); return(-1); } xmlFree(content); } else { xmlCatalogEntryPtr tmp, cur; tmp = xmlNewCatalogEntry(XML_CATA_CATALOG, NULL, NULL, BAD_CAST filename, xmlCatalogDefaultPrefer, NULL); cur = catal->xml; if (cur == NULL) { catal->xml = tmp; } else { while (cur->next != NULL) cur = cur->next; cur->next = tmp; } } return (0); } /** * xmlACatalogResolveSystem: * @catal: a Catalog * @sysID: the system ID string * * Try to lookup the catalog resource for a system ID * * Returns the resource if found or NULL otherwise, the value returned * must be freed by the caller. */ xmlChar * xmlACatalogResolveSystem(xmlCatalogPtr catal, const xmlChar *sysID) { xmlChar *ret = NULL; if ((sysID == NULL) || (catal == NULL)) return(NULL); if (xmlDebugCatalogs) xmlGenericError(xmlGenericErrorContext, "Resolve sysID %s\n", sysID); if (catal->type == XML_XML_CATALOG_TYPE) { ret = xmlCatalogListXMLResolve(catal->xml, NULL, sysID); if (ret == XML_CATAL_BREAK) ret = NULL; } else { const xmlChar *sgml; sgml = xmlCatalogGetSGMLSystem(catal->sgml, sysID); if (sgml != NULL) ret = xmlStrdup(sgml); } return(ret); } /** * xmlACatalogResolvePublic: * @catal: a Catalog * @pubID: the public ID string * * Try to lookup the catalog local reference associated to a public ID in that catalog * * Returns the local resource if found or NULL otherwise, the value returned * must be freed by the caller. */ xmlChar * xmlACatalogResolvePublic(xmlCatalogPtr catal, const xmlChar *pubID) { xmlChar *ret = NULL; if ((pubID == NULL) || (catal == NULL)) return(NULL); if (xmlDebugCatalogs) xmlGenericError(xmlGenericErrorContext, "Resolve pubID %s\n", pubID); if (catal->type == XML_XML_CATALOG_TYPE) { ret = xmlCatalogListXMLResolve(catal->xml, pubID, NULL); if (ret == XML_CATAL_BREAK) ret = NULL; } else { const xmlChar *sgml; sgml = xmlCatalogGetSGMLPublic(catal->sgml, pubID); if (sgml != NULL) ret = xmlStrdup(sgml); } return(ret); } /** * xmlACatalogResolve: * @catal: a Catalog * @pubID: the public ID string * @sysID: the system ID string * * Do a complete resolution lookup of an External Identifier * * Returns the URI of the resource or NULL if not found, it must be freed * by the caller. */ xmlChar * xmlACatalogResolve(xmlCatalogPtr catal, const xmlChar * pubID, const xmlChar * sysID) { xmlChar *ret = NULL; if (((pubID == NULL) && (sysID == NULL)) || (catal == NULL)) return (NULL); if (xmlDebugCatalogs) { if ((pubID != NULL) && (sysID != NULL)) { xmlGenericError(xmlGenericErrorContext, "Resolve: pubID %s sysID %s\n", pubID, sysID); } else if (pubID != NULL) { xmlGenericError(xmlGenericErrorContext, "Resolve: pubID %s\n", pubID); } else { xmlGenericError(xmlGenericErrorContext, "Resolve: sysID %s\n", sysID); } } if (catal->type == XML_XML_CATALOG_TYPE) { ret = xmlCatalogListXMLResolve(catal->xml, pubID, sysID); if (ret == XML_CATAL_BREAK) ret = NULL; } else { const xmlChar *sgml; sgml = xmlCatalogSGMLResolve(catal, pubID, sysID); if (sgml != NULL) ret = xmlStrdup(sgml); } return (ret); } /** * xmlACatalogResolveURI: * @catal: a Catalog * @URI: the URI * * Do a complete resolution lookup of an URI * * Returns the URI of the resource or NULL if not found, it must be freed * by the caller. */ xmlChar * xmlACatalogResolveURI(xmlCatalogPtr catal, const xmlChar *URI) { xmlChar *ret = NULL; if ((URI == NULL) || (catal == NULL)) return(NULL); if (xmlDebugCatalogs) xmlGenericError(xmlGenericErrorContext, "Resolve URI %s\n", URI); if (catal->type == XML_XML_CATALOG_TYPE) { ret = xmlCatalogListXMLResolveURI(catal->xml, URI); if (ret == XML_CATAL_BREAK) ret = NULL; } else { const xmlChar *sgml; sgml = xmlCatalogSGMLResolve(catal, NULL, URI); if (sgml != NULL) sgml = xmlStrdup(sgml); } return(ret); } #ifdef LIBXML_OUTPUT_ENABLED /** * xmlACatalogDump: * @catal: a Catalog * @out: the file. * * Dump the given catalog to the given file. */ void xmlACatalogDump(xmlCatalogPtr catal, FILE *out) { if ((out == NULL) || (catal == NULL)) return; if (catal->type == XML_XML_CATALOG_TYPE) { xmlDumpXMLCatalog(out, catal->xml); } else { xmlHashScan(catal->sgml, (xmlHashScanner) xmlCatalogDumpEntry, out); } } #endif /* LIBXML_OUTPUT_ENABLED */ /** * xmlACatalogAdd: * @catal: a Catalog * @type: the type of record to add to the catalog * @orig: the system, public or prefix to match * @replace: the replacement value for the match * * Add an entry in the catalog, it may overwrite existing but * different entries. * * Returns 0 if successful, -1 otherwise */ int xmlACatalogAdd(xmlCatalogPtr catal, const xmlChar * type, const xmlChar * orig, const xmlChar * replace) { int res = -1; if (catal == NULL) return(-1); if (catal->type == XML_XML_CATALOG_TYPE) { res = xmlAddXMLCatalog(catal->xml, type, orig, replace); } else { xmlCatalogEntryType cattype; cattype = xmlGetSGMLCatalogEntryType(type); if (cattype != XML_CATA_NONE) { xmlCatalogEntryPtr entry; entry = xmlNewCatalogEntry(cattype, orig, replace, NULL, XML_CATA_PREFER_NONE, NULL); if (catal->sgml == NULL) catal->sgml = xmlHashCreate(10); res = xmlHashAddEntry(catal->sgml, orig, entry); } } return (res); } /** * xmlACatalogRemove: * @catal: a Catalog * @value: the value to remove * * Remove an entry from the catalog * * Returns the number of entries removed if successful, -1 otherwise */ int xmlACatalogRemove(xmlCatalogPtr catal, const xmlChar *value) { int res = -1; if ((catal == NULL) || (value == NULL)) return(-1); if (catal->type == XML_XML_CATALOG_TYPE) { res = xmlDelXMLCatalog(catal->xml, value); } else { res = xmlHashRemoveEntry(catal->sgml, value, (xmlHashDeallocator) xmlFreeCatalogEntry); if (res == 0) res = 1; } return(res); } /** * xmlNewCatalog: * @sgml: should this create an SGML catalog * * create a new Catalog. * * Returns the xmlCatalogPtr or NULL in case of error */ xmlCatalogPtr xmlNewCatalog(int sgml) { xmlCatalogPtr catal = NULL; if (sgml) { catal = xmlCreateNewCatalog(XML_SGML_CATALOG_TYPE, xmlCatalogDefaultPrefer); if ((catal != NULL) && (catal->sgml == NULL)) catal->sgml = xmlHashCreate(10); } else catal = xmlCreateNewCatalog(XML_XML_CATALOG_TYPE, xmlCatalogDefaultPrefer); return(catal); } /** * xmlCatalogIsEmpty: * @catal: should this create an SGML catalog * * Check is a catalog is empty * * Returns 1 if the catalog is empty, 0 if not, amd -1 in case of error. */ int xmlCatalogIsEmpty(xmlCatalogPtr catal) { if (catal == NULL) return(-1); if (catal->type == XML_XML_CATALOG_TYPE) { if (catal->xml == NULL) return(1); if ((catal->xml->type != XML_CATA_CATALOG) && (catal->xml->type != XML_CATA_BROKEN_CATALOG)) return(-1); if (catal->xml->children == NULL) return(1); return(0); } else { int res; if (catal->sgml == NULL) return(1); res = xmlHashSize(catal->sgml); if (res == 0) return(1); if (res < 0) return(-1); } return(0); } /************************************************************************ * * * Public interfaces manipulating the global shared default catalog * * * ************************************************************************/ /** * xmlInitializeCatalogData: * * Do the catalog initialization only of global data, doesn't try to load * any catalog actually. * this function is not thread safe, catalog initialization should * preferably be done once at startup */ static void xmlInitializeCatalogData(void) { if (xmlCatalogInitialized != 0) return; if (getenv("XML_DEBUG_CATALOG")) xmlDebugCatalogs = 1; xmlCatalogMutex = xmlNewRMutex(); xmlCatalogInitialized = 1; } /** * xmlInitializeCatalog: * * Do the catalog initialization. * this function is not thread safe, catalog initialization should * preferably be done once at startup */ void xmlInitializeCatalog(void) { if (xmlCatalogInitialized != 0) return; xmlInitializeCatalogData(); xmlRMutexLock(xmlCatalogMutex); if (getenv("XML_DEBUG_CATALOG")) xmlDebugCatalogs = 1; if (xmlDefaultCatalog == NULL) { const char *catalogs; char *path; const char *cur, *paths; xmlCatalogPtr catal; xmlCatalogEntryPtr *nextent; catalogs = (const char *) getenv("XML_CATALOG_FILES"); if (catalogs == NULL) #if defined(_WIN32) && defined(_MSC_VER) { void* hmodule; hmodule = GetModuleHandleA("libxml2.dll"); if (hmodule == NULL) hmodule = GetModuleHandleA(NULL); if (hmodule != NULL) { char buf[256]; unsigned long len = GetModuleFileNameA(hmodule, buf, 255); if (len != 0) { char* p = &(buf[len]); while (*p != '\\' && p > buf) p--; if (p != buf) { xmlChar* uri; strncpy(p, "\\..\\etc\\catalog", 255 - (p - buf)); uri = xmlCanonicPath(buf); if (uri != NULL) { strncpy(XML_XML_DEFAULT_CATALOG, uri, 255); xmlFree(uri); } } } } catalogs = XML_XML_DEFAULT_CATALOG; } #else catalogs = XML_XML_DEFAULT_CATALOG; #endif catal = xmlCreateNewCatalog(XML_XML_CATALOG_TYPE, xmlCatalogDefaultPrefer); if (catal != NULL) { /* the XML_CATALOG_FILES envvar is allowed to contain a space-separated list of entries. */ cur = catalogs; nextent = &catal->xml; while (*cur != '\0') { while (xmlIsBlank_ch(*cur)) cur++; if (*cur != 0) { paths = cur; while ((*cur != 0) && (!xmlIsBlank_ch(*cur))) cur++; path = (char *) xmlStrndup((const xmlChar *)paths, cur - paths); if (path != NULL) { *nextent = xmlNewCatalogEntry(XML_CATA_CATALOG, NULL, NULL, BAD_CAST path, xmlCatalogDefaultPrefer, NULL); if (*nextent != NULL) nextent = &((*nextent)->next); xmlFree(path); } } } xmlDefaultCatalog = catal; } } xmlRMutexUnlock(xmlCatalogMutex); } /** * xmlLoadCatalog: * @filename: a file path * * Load the catalog and makes its definitions effective for the default * external entity loader. It will recurse in SGML CATALOG entries. * this function is not thread safe, catalog initialization should * preferably be done once at startup * * Returns 0 in case of success -1 in case of error */ int xmlLoadCatalog(const char *filename) { int ret; xmlCatalogPtr catal; if (!xmlCatalogInitialized) xmlInitializeCatalogData(); xmlRMutexLock(xmlCatalogMutex); if (xmlDefaultCatalog == NULL) { catal = xmlLoadACatalog(filename); if (catal == NULL) { xmlRMutexUnlock(xmlCatalogMutex); return(-1); } xmlDefaultCatalog = catal; xmlRMutexUnlock(xmlCatalogMutex); return(0); } ret = xmlExpandCatalog(xmlDefaultCatalog, filename); xmlRMutexUnlock(xmlCatalogMutex); return(ret); } /** * xmlLoadCatalogs: * @pathss: a list of directories separated by a colon or a space. * * Load the catalogs and makes their definitions effective for the default * external entity loader. * this function is not thread safe, catalog initialization should * preferably be done once at startup */ void xmlLoadCatalogs(const char *pathss) { const char *cur; const char *paths; xmlChar *path; if (pathss == NULL) return; cur = pathss; while (*cur != 0) { while (xmlIsBlank_ch(*cur)) cur++; if (*cur != 0) { paths = cur; while ((*cur != 0) && (*cur != ':') && (!xmlIsBlank_ch(*cur))) cur++; path = xmlStrndup((const xmlChar *)paths, cur - paths); if (path != NULL) { xmlLoadCatalog((const char *) path); xmlFree(path); } } while (*cur == ':') cur++; } } /** * xmlCatalogCleanup: * * Free up all the memory associated with catalogs */ void xmlCatalogCleanup(void) { if (xmlCatalogInitialized == 0) return; xmlRMutexLock(xmlCatalogMutex); if (xmlDebugCatalogs) xmlGenericError(xmlGenericErrorContext, "Catalogs cleanup\n"); if (xmlCatalogXMLFiles != NULL) xmlHashFree(xmlCatalogXMLFiles, (xmlHashDeallocator)xmlFreeCatalogHashEntryList); xmlCatalogXMLFiles = NULL; if (xmlDefaultCatalog != NULL) xmlFreeCatalog(xmlDefaultCatalog); xmlDefaultCatalog = NULL; xmlDebugCatalogs = 0; xmlCatalogInitialized = 0; xmlRMutexUnlock(xmlCatalogMutex); xmlFreeRMutex(xmlCatalogMutex); } /** * xmlCatalogResolveSystem: * @sysID: the system ID string * * Try to lookup the catalog resource for a system ID * * Returns the resource if found or NULL otherwise, the value returned * must be freed by the caller. */ xmlChar * xmlCatalogResolveSystem(const xmlChar *sysID) { xmlChar *ret; if (!xmlCatalogInitialized) xmlInitializeCatalog(); ret = xmlACatalogResolveSystem(xmlDefaultCatalog, sysID); return(ret); } /** * xmlCatalogResolvePublic: * @pubID: the public ID string * * Try to lookup the catalog reference associated to a public ID * * Returns the resource if found or NULL otherwise, the value returned * must be freed by the caller. */ xmlChar * xmlCatalogResolvePublic(const xmlChar *pubID) { xmlChar *ret; if (!xmlCatalogInitialized) xmlInitializeCatalog(); ret = xmlACatalogResolvePublic(xmlDefaultCatalog, pubID); return(ret); } /** * xmlCatalogResolve: * @pubID: the public ID string * @sysID: the system ID string * * Do a complete resolution lookup of an External Identifier * * Returns the URI of the resource or NULL if not found, it must be freed * by the caller. */ xmlChar * xmlCatalogResolve(const xmlChar *pubID, const xmlChar *sysID) { xmlChar *ret; if (!xmlCatalogInitialized) xmlInitializeCatalog(); ret = xmlACatalogResolve(xmlDefaultCatalog, pubID, sysID); return(ret); } /** * xmlCatalogResolveURI: * @URI: the URI * * Do a complete resolution lookup of an URI * * Returns the URI of the resource or NULL if not found, it must be freed * by the caller. */ xmlChar * xmlCatalogResolveURI(const xmlChar *URI) { xmlChar *ret; if (!xmlCatalogInitialized) xmlInitializeCatalog(); ret = xmlACatalogResolveURI(xmlDefaultCatalog, URI); return(ret); } #ifdef LIBXML_OUTPUT_ENABLED /** * xmlCatalogDump: * @out: the file. * * Dump all the global catalog content to the given file. */ void xmlCatalogDump(FILE *out) { if (out == NULL) return; if (!xmlCatalogInitialized) xmlInitializeCatalog(); xmlACatalogDump(xmlDefaultCatalog, out); } #endif /* LIBXML_OUTPUT_ENABLED */ /** * xmlCatalogAdd: * @type: the type of record to add to the catalog * @orig: the system, public or prefix to match * @replace: the replacement value for the match * * Add an entry in the catalog, it may overwrite existing but * different entries. * If called before any other catalog routine, allows to override the * default shared catalog put in place by xmlInitializeCatalog(); * * Returns 0 if successful, -1 otherwise */ int xmlCatalogAdd(const xmlChar *type, const xmlChar *orig, const xmlChar *replace) { int res = -1; if (!xmlCatalogInitialized) xmlInitializeCatalogData(); xmlRMutexLock(xmlCatalogMutex); /* * Specific case where one want to override the default catalog * put in place by xmlInitializeCatalog(); */ if ((xmlDefaultCatalog == NULL) && (xmlStrEqual(type, BAD_CAST "catalog"))) { xmlDefaultCatalog = xmlCreateNewCatalog(XML_XML_CATALOG_TYPE, xmlCatalogDefaultPrefer); xmlDefaultCatalog->xml = xmlNewCatalogEntry(XML_CATA_CATALOG, NULL, orig, NULL, xmlCatalogDefaultPrefer, NULL); xmlRMutexUnlock(xmlCatalogMutex); return(0); } res = xmlACatalogAdd(xmlDefaultCatalog, type, orig, replace); xmlRMutexUnlock(xmlCatalogMutex); return(res); } /** * xmlCatalogRemove: * @value: the value to remove * * Remove an entry from the catalog * * Returns the number of entries removed if successful, -1 otherwise */ int xmlCatalogRemove(const xmlChar *value) { int res; if (!xmlCatalogInitialized) xmlInitializeCatalog(); xmlRMutexLock(xmlCatalogMutex); res = xmlACatalogRemove(xmlDefaultCatalog, value); xmlRMutexUnlock(xmlCatalogMutex); return(res); } /** * xmlCatalogConvert: * * Convert all the SGML catalog entries as XML ones * * Returns the number of entries converted if successful, -1 otherwise */ int xmlCatalogConvert(void) { int res = -1; if (!xmlCatalogInitialized) xmlInitializeCatalog(); xmlRMutexLock(xmlCatalogMutex); res = xmlConvertSGMLCatalog(xmlDefaultCatalog); xmlRMutexUnlock(xmlCatalogMutex); return(res); } /************************************************************************ * * * Public interface manipulating the common preferences * * * ************************************************************************/ /** * xmlCatalogGetDefaults: * * Used to get the user preference w.r.t. to what catalogs should * be accepted * * Returns the current xmlCatalogAllow value */ xmlCatalogAllow xmlCatalogGetDefaults(void) { return(xmlCatalogDefaultAllow); } /** * xmlCatalogSetDefaults: * @allow: what catalogs should be accepted * * Used to set the user preference w.r.t. to what catalogs should * be accepted */ void xmlCatalogSetDefaults(xmlCatalogAllow allow) { if (xmlDebugCatalogs) { switch (allow) { case XML_CATA_ALLOW_NONE: xmlGenericError(xmlGenericErrorContext, "Disabling catalog usage\n"); break; case XML_CATA_ALLOW_GLOBAL: xmlGenericError(xmlGenericErrorContext, "Allowing only global catalogs\n"); break; case XML_CATA_ALLOW_DOCUMENT: xmlGenericError(xmlGenericErrorContext, "Allowing only catalogs from the document\n"); break; case XML_CATA_ALLOW_ALL: xmlGenericError(xmlGenericErrorContext, "Allowing all catalogs\n"); break; } } xmlCatalogDefaultAllow = allow; } /** * xmlCatalogSetDefaultPrefer: * @prefer: the default preference for delegation * * Allows to set the preference between public and system for deletion * in XML Catalog resolution. C.f. section 4.1.1 of the spec * Values accepted are XML_CATA_PREFER_PUBLIC or XML_CATA_PREFER_SYSTEM * * Returns the previous value of the default preference for delegation */ xmlCatalogPrefer xmlCatalogSetDefaultPrefer(xmlCatalogPrefer prefer) { xmlCatalogPrefer ret = xmlCatalogDefaultPrefer; if (prefer == XML_CATA_PREFER_NONE) return(ret); if (xmlDebugCatalogs) { switch (prefer) { case XML_CATA_PREFER_PUBLIC: xmlGenericError(xmlGenericErrorContext, "Setting catalog preference to PUBLIC\n"); break; case XML_CATA_PREFER_SYSTEM: xmlGenericError(xmlGenericErrorContext, "Setting catalog preference to SYSTEM\n"); break; case XML_CATA_PREFER_NONE: break; } } xmlCatalogDefaultPrefer = prefer; return(ret); } /** * xmlCatalogSetDebug: * @level: the debug level of catalogs required * * Used to set the debug level for catalog operation, 0 disable * debugging, 1 enable it * * Returns the previous value of the catalog debugging level */ int xmlCatalogSetDebug(int level) { int ret = xmlDebugCatalogs; if (level <= 0) xmlDebugCatalogs = 0; else xmlDebugCatalogs = level; return(ret); } /************************************************************************ * * * Minimal interfaces used for per-document catalogs by the parser * * * ************************************************************************/ /** * xmlCatalogFreeLocal: * @catalogs: a document's list of catalogs * * Free up the memory associated to the catalog list */ void xmlCatalogFreeLocal(void *catalogs) { xmlCatalogEntryPtr catal; if (!xmlCatalogInitialized) xmlInitializeCatalog(); catal = (xmlCatalogEntryPtr) catalogs; if (catal != NULL) xmlFreeCatalogEntryList(catal); } /** * xmlCatalogAddLocal: * @catalogs: a document's list of catalogs * @URL: the URL to a new local catalog * * Add the new entry to the catalog list * * Returns the updated list */ void * xmlCatalogAddLocal(void *catalogs, const xmlChar *URL) { xmlCatalogEntryPtr catal, add; if (!xmlCatalogInitialized) xmlInitializeCatalog(); if (URL == NULL) return(catalogs); if (xmlDebugCatalogs) xmlGenericError(xmlGenericErrorContext, "Adding document catalog %s\n", URL); add = xmlNewCatalogEntry(XML_CATA_CATALOG, NULL, URL, NULL, xmlCatalogDefaultPrefer, NULL); if (add == NULL) return(catalogs); catal = (xmlCatalogEntryPtr) catalogs; if (catal == NULL) return((void *) add); while (catal->next != NULL) catal = catal->next; catal->next = add; return(catalogs); } /** * xmlCatalogLocalResolve: * @catalogs: a document's list of catalogs * @pubID: the public ID string * @sysID: the system ID string * * Do a complete resolution lookup of an External Identifier using a * document's private catalog list * * Returns the URI of the resource or NULL if not found, it must be freed * by the caller. */ xmlChar * xmlCatalogLocalResolve(void *catalogs, const xmlChar *pubID, const xmlChar *sysID) { xmlCatalogEntryPtr catal; xmlChar *ret; if (!xmlCatalogInitialized) xmlInitializeCatalog(); if ((pubID == NULL) && (sysID == NULL)) return(NULL); if (xmlDebugCatalogs) { if ((pubID != NULL) && (sysID != NULL)) { xmlGenericError(xmlGenericErrorContext, "Local Resolve: pubID %s sysID %s\n", pubID, sysID); } else if (pubID != NULL) { xmlGenericError(xmlGenericErrorContext, "Local Resolve: pubID %s\n", pubID); } else { xmlGenericError(xmlGenericErrorContext, "Local Resolve: sysID %s\n", sysID); } } catal = (xmlCatalogEntryPtr) catalogs; if (catal == NULL) return(NULL); ret = xmlCatalogListXMLResolve(catal, pubID, sysID); if ((ret != NULL) && (ret != XML_CATAL_BREAK)) return(ret); return(NULL); } /** * xmlCatalogLocalResolveURI: * @catalogs: a document's list of catalogs * @URI: the URI * * Do a complete resolution lookup of an URI using a * document's private catalog list * * Returns the URI of the resource or NULL if not found, it must be freed * by the caller. */ xmlChar * xmlCatalogLocalResolveURI(void *catalogs, const xmlChar *URI) { xmlCatalogEntryPtr catal; xmlChar *ret; if (!xmlCatalogInitialized) xmlInitializeCatalog(); if (URI == NULL) return(NULL); if (xmlDebugCatalogs) xmlGenericError(xmlGenericErrorContext, "Resolve URI %s\n", URI); catal = (xmlCatalogEntryPtr) catalogs; if (catal == NULL) return(NULL); ret = xmlCatalogListXMLResolveURI(catal, URI); if ((ret != NULL) && (ret != XML_CATAL_BREAK)) return(ret); return(NULL); } /************************************************************************ * * * Deprecated interfaces * * * ************************************************************************/ /** * xmlCatalogGetSystem: * @sysID: the system ID string * * Try to lookup the catalog reference associated to a system ID * DEPRECATED, use xmlCatalogResolveSystem() * * Returns the resource if found or NULL otherwise. */ const xmlChar * xmlCatalogGetSystem(const xmlChar *sysID) { xmlChar *ret; static xmlChar result[1000]; static int msg = 0; if (!xmlCatalogInitialized) xmlInitializeCatalog(); if (msg == 0) { xmlGenericError(xmlGenericErrorContext, "Use of deprecated xmlCatalogGetSystem() call\n"); msg++; } if (sysID == NULL) return(NULL); /* * Check first the XML catalogs */ if (xmlDefaultCatalog != NULL) { ret = xmlCatalogListXMLResolve(xmlDefaultCatalog->xml, NULL, sysID); if ((ret != NULL) && (ret != XML_CATAL_BREAK)) { snprintf((char *) result, sizeof(result) - 1, "%s", (char *) ret); result[sizeof(result) - 1] = 0; return(result); } } if (xmlDefaultCatalog != NULL) return(xmlCatalogGetSGMLSystem(xmlDefaultCatalog->sgml, sysID)); return(NULL); } /** * xmlCatalogGetPublic: * @pubID: the public ID string * * Try to lookup the catalog reference associated to a public ID * DEPRECATED, use xmlCatalogResolvePublic() * * Returns the resource if found or NULL otherwise. */ const xmlChar * xmlCatalogGetPublic(const xmlChar *pubID) { xmlChar *ret; static xmlChar result[1000]; static int msg = 0; if (!xmlCatalogInitialized) xmlInitializeCatalog(); if (msg == 0) { xmlGenericError(xmlGenericErrorContext, "Use of deprecated xmlCatalogGetPublic() call\n"); msg++; } if (pubID == NULL) return(NULL); /* * Check first the XML catalogs */ if (xmlDefaultCatalog != NULL) { ret = xmlCatalogListXMLResolve(xmlDefaultCatalog->xml, pubID, NULL); if ((ret != NULL) && (ret != XML_CATAL_BREAK)) { snprintf((char *) result, sizeof(result) - 1, "%s", (char *) ret); result[sizeof(result) - 1] = 0; return(result); } } if (xmlDefaultCatalog != NULL) return(xmlCatalogGetSGMLPublic(xmlDefaultCatalog->sgml, pubID)); return(NULL); } #define bottom_catalog #include "elfgcchack.h" #endif /* LIBXML_CATALOG_ENABLED */ xdmf-3.0+git20160803/Utilities/vtklibxml2/schematron.c0000640000175000017500000014512213003006557022457 0ustar alastairalastair/* * schematron.c : implementation of the Schematron schema validity checking * * See Copyright for the status of this software. * * Daniel Veillard */ /* * TODO: * + double check the semantic, especially * - multiple rules applying in a single pattern/node * - the semantic of libxml2 patterns vs. XSLT production referenced * by the spec. * + export of results in SVRL * + full parsing and coverage of the spec, conformance of the input to the * spec * + divergences between the draft and the ISO proposed standard :-( * + hook and test include * + try and compare with the XSLT version */ #define IN_LIBXML #include "libxml.h" #ifdef LIBXML_SCHEMATRON_ENABLED #include #include #include #include #include #include #include #include #define SCHEMATRON_PARSE_OPTIONS XML_PARSE_NOENT #define SCT_OLD_NS BAD_CAST "http://www.ascc.net/xml/schematron" #define XML_SCHEMATRON_NS BAD_CAST "http://purl.oclc.org/dsdl/schematron" static const xmlChar *xmlSchematronNs = XML_SCHEMATRON_NS; static const xmlChar *xmlOldSchematronNs = SCT_OLD_NS; #define IS_SCHEMATRON(node, elem) \ ((node != NULL) && (node->type == XML_ELEMENT_NODE ) && \ (node->ns != NULL) && \ (xmlStrEqual(node->name, (const xmlChar *) elem)) && \ ((xmlStrEqual(node->ns->href, xmlSchematronNs)) || \ (xmlStrEqual(node->ns->href, xmlOldSchematronNs)))) #define NEXT_SCHEMATRON(node) \ while (node != NULL) { \ if ((node->type == XML_ELEMENT_NODE ) && (node->ns != NULL) && \ ((xmlStrEqual(node->ns->href, xmlSchematronNs)) || \ (xmlStrEqual(node->ns->href, xmlOldSchematronNs)))) \ break; \ node = node->next; \ } /** * TODO: * * macro to flag unimplemented blocks */ #define TODO \ xmlGenericError(xmlGenericErrorContext, \ "Unimplemented block at %s:%d\n", \ __FILE__, __LINE__); typedef enum { XML_SCHEMATRON_ASSERT=1, XML_SCHEMATRON_REPORT=2 } xmlSchematronTestType; /** * _xmlSchematronTest: * * A Schematrons test, either an assert or a report */ typedef struct _xmlSchematronTest xmlSchematronTest; typedef xmlSchematronTest *xmlSchematronTestPtr; struct _xmlSchematronTest { xmlSchematronTestPtr next; /* the next test in the list */ xmlSchematronTestType type; /* the test type */ xmlNodePtr node; /* the node in the tree */ xmlChar *test; /* the expression to test */ xmlXPathCompExprPtr comp; /* the compiled expression */ xmlChar *report; /* the message to report */ }; /** * _xmlSchematronRule: * * A Schematrons rule */ typedef struct _xmlSchematronRule xmlSchematronRule; typedef xmlSchematronRule *xmlSchematronRulePtr; struct _xmlSchematronRule { xmlSchematronRulePtr next; /* the next rule in the list */ xmlSchematronRulePtr patnext;/* the next rule in the pattern list */ xmlNodePtr node; /* the node in the tree */ xmlChar *context; /* the context evaluation rule */ xmlSchematronTestPtr tests; /* the list of tests */ xmlPatternPtr pattern; /* the compiled pattern associated */ xmlChar *report; /* the message to report */ }; /** * _xmlSchematronPattern: * * A Schematrons pattern */ typedef struct _xmlSchematronPattern xmlSchematronPattern; typedef xmlSchematronPattern *xmlSchematronPatternPtr; struct _xmlSchematronPattern { xmlSchematronPatternPtr next;/* the next pattern in the list */ xmlSchematronRulePtr rules; /* the list of rules */ xmlChar *name; /* the name of the pattern */ }; /** * _xmlSchematron: * * A Schematrons definition */ struct _xmlSchematron { const xmlChar *name; /* schema name */ int preserve; /* was the document passed by the user */ xmlDocPtr doc; /* pointer to the parsed document */ int flags; /* specific to this schematron */ void *_private; /* unused by the library */ xmlDictPtr dict; /* the dictionnary used internally */ const xmlChar *title; /* the title if any */ int nbNs; /* the number of namespaces */ int nbPattern; /* the number of patterns */ xmlSchematronPatternPtr patterns;/* the patterns found */ xmlSchematronRulePtr rules; /* the rules gathered */ int nbNamespaces; /* number of namespaces in the array */ int maxNamespaces; /* size of the array */ const xmlChar **namespaces; /* the array of namespaces */ }; /** * xmlSchematronValidCtxt: * * A Schematrons validation context */ struct _xmlSchematronValidCtxt { int type; int flags; /* an or of xmlSchematronValidOptions */ xmlDictPtr dict; int nberrors; int err; xmlSchematronPtr schema; xmlXPathContextPtr xctxt; FILE *outputFile; /* if using XML_SCHEMATRON_OUT_FILE */ xmlBufferPtr outputBuffer; /* if using XML_SCHEMATRON_OUT_BUFFER */ xmlOutputWriteCallback iowrite; /* if using XML_SCHEMATRON_OUT_IO */ xmlOutputCloseCallback ioclose; void *ioctx; }; struct _xmlSchematronParserCtxt { int type; const xmlChar *URL; xmlDocPtr doc; int preserve; /* Whether the doc should be freed */ const char *buffer; int size; xmlDictPtr dict; /* dictionnary for interned string names */ int nberrors; int err; xmlXPathContextPtr xctxt; /* the XPath context used for compilation */ xmlSchematronPtr schema; int nbNamespaces; /* number of namespaces in the array */ int maxNamespaces; /* size of the array */ const xmlChar **namespaces; /* the array of namespaces */ int nbIncludes; /* number of includes in the array */ int maxIncludes; /* size of the array */ xmlNodePtr *includes; /* the array of includes */ /* error rreporting data */ void *userData; /* user specific data block */ xmlSchematronValidityErrorFunc error;/* the callback in case of errors */ xmlSchematronValidityWarningFunc warning;/* callback in case of warning */ xmlStructuredErrorFunc serror; /* the structured function */ }; #define XML_STRON_CTXT_PARSER 1 #define XML_STRON_CTXT_VALIDATOR 2 /************************************************************************ * * * Error reporting * * * ************************************************************************/ /** * xmlSchematronPErrMemory: * @node: a context node * @extra: extra informations * * Handle an out of memory condition */ static void xmlSchematronPErrMemory(xmlSchematronParserCtxtPtr ctxt, const char *extra, xmlNodePtr node) { if (ctxt != NULL) ctxt->nberrors++; __xmlSimpleError(XML_FROM_SCHEMASP, XML_ERR_NO_MEMORY, node, NULL, extra); } /** * xmlSchematronPErr: * @ctxt: the parsing context * @node: the context node * @error: the error code * @msg: the error message * @str1: extra data * @str2: extra data * * Handle a parser error */ static void xmlSchematronPErr(xmlSchematronParserCtxtPtr ctxt, xmlNodePtr node, int error, const char *msg, const xmlChar * str1, const xmlChar * str2) { xmlGenericErrorFunc channel = NULL; xmlStructuredErrorFunc schannel = NULL; void *data = NULL; if (ctxt != NULL) { ctxt->nberrors++; channel = ctxt->error; data = ctxt->userData; schannel = ctxt->serror; } __xmlRaiseError(schannel, channel, data, ctxt, node, XML_FROM_SCHEMASP, error, XML_ERR_ERROR, NULL, 0, (const char *) str1, (const char *) str2, NULL, 0, 0, msg, str1, str2); } /** * xmlSchematronVTypeErrMemory: * @node: a context node * @extra: extra informations * * Handle an out of memory condition */ static void xmlSchematronVErrMemory(xmlSchematronValidCtxtPtr ctxt, const char *extra, xmlNodePtr node) { if (ctxt != NULL) { ctxt->nberrors++; ctxt->err = XML_SCHEMAV_INTERNAL; } __xmlSimpleError(XML_FROM_SCHEMASV, XML_ERR_NO_MEMORY, node, NULL, extra); } /************************************************************************ * * * Parsing and compilation of the Schematrontrons * * * ************************************************************************/ /** * xmlSchematronAddTest: * @ctxt: the schema parsing context * @type: the type of test * @rule: the parent rule * @node: the node hosting the test * @test: the associated test * @report: the associated report string * * Add a test to a schematron * * Returns the new pointer or NULL in case of error */ static xmlSchematronTestPtr xmlSchematronAddTest(xmlSchematronParserCtxtPtr ctxt, xmlSchematronTestType type, xmlSchematronRulePtr rule, xmlNodePtr node, xmlChar *test, xmlChar *report) { xmlSchematronTestPtr ret; xmlXPathCompExprPtr comp; if ((ctxt == NULL) || (rule == NULL) || (node == NULL) || (test == NULL)) return(NULL); /* * try first to compile the test expression */ comp = xmlXPathCtxtCompile(ctxt->xctxt, test); if (comp == NULL) { xmlSchematronPErr(ctxt, node, XML_SCHEMAP_NOROOT, "Failed to compile test expression %s", test, NULL); return(NULL); } ret = (xmlSchematronTestPtr) xmlMalloc(sizeof(xmlSchematronTest)); if (ret == NULL) { xmlSchematronPErrMemory(ctxt, "allocating schema test", node); return (NULL); } memset(ret, 0, sizeof(xmlSchematronTest)); ret->type = type; ret->node = node; ret->test = test; ret->comp = comp; ret->report = report; ret->next = NULL; if (rule->tests == NULL) { rule->tests = ret; } else { xmlSchematronTestPtr prev = rule->tests; while (prev->next != NULL) prev = prev->next; prev->next = ret; } return (ret); } /** * xmlSchematronFreeTests: * @tests: a list of tests * * Free a list of tests. */ static void xmlSchematronFreeTests(xmlSchematronTestPtr tests) { xmlSchematronTestPtr next; while (tests != NULL) { next = tests->next; if (tests->test != NULL) xmlFree(tests->test); if (tests->comp != NULL) xmlXPathFreeCompExpr(tests->comp); if (tests->report != NULL) xmlFree(tests->report); xmlFree(tests); tests = next; } } /** * xmlSchematronAddRule: * @ctxt: the schema parsing context * @schema: a schema structure * @node: the node hosting the rule * @context: the associated context string * @report: the associated report string * * Add a rule to a schematron * * Returns the new pointer or NULL in case of error */ static xmlSchematronRulePtr xmlSchematronAddRule(xmlSchematronParserCtxtPtr ctxt, xmlSchematronPtr schema, xmlSchematronPatternPtr pat, xmlNodePtr node, xmlChar *context, xmlChar *report) { xmlSchematronRulePtr ret; xmlPatternPtr pattern; if ((ctxt == NULL) || (schema == NULL) || (node == NULL) || (context == NULL)) return(NULL); /* * Try first to compile the pattern */ pattern = xmlPatterncompile(context, ctxt->dict, XML_PATTERN_XPATH, ctxt->namespaces); if (pattern == NULL) { xmlSchematronPErr(ctxt, node, XML_SCHEMAP_NOROOT, "Failed to compile context expression %s", context, NULL); } ret = (xmlSchematronRulePtr) xmlMalloc(sizeof(xmlSchematronRule)); if (ret == NULL) { xmlSchematronPErrMemory(ctxt, "allocating schema rule", node); return (NULL); } memset(ret, 0, sizeof(xmlSchematronRule)); ret->node = node; ret->context = context; ret->pattern = pattern; ret->report = report; ret->next = NULL; if (schema->rules == NULL) { schema->rules = ret; } else { xmlSchematronRulePtr prev = schema->rules; while (prev->next != NULL) prev = prev->next; prev->next = ret; } ret->patnext = NULL; if (pat->rules == NULL) { pat->rules = ret; } else { xmlSchematronRulePtr prev = pat->rules; while (prev->patnext != NULL) prev = prev->patnext; prev->patnext = ret; } return (ret); } /** * xmlSchematronFreeRules: * @rules: a list of rules * * Free a list of rules. */ static void xmlSchematronFreeRules(xmlSchematronRulePtr rules) { xmlSchematronRulePtr next; while (rules != NULL) { next = rules->next; if (rules->tests) xmlSchematronFreeTests(rules->tests); if (rules->context != NULL) xmlFree(rules->context); if (rules->pattern) xmlFreePattern(rules->pattern); if (rules->report != NULL) xmlFree(rules->report); xmlFree(rules); rules = next; } } /** * xmlSchematronAddPattern: * @ctxt: the schema parsing context * @schema: a schema structure * @node: the node hosting the pattern * @id: the id or name of the pattern * * Add a pattern to a schematron * * Returns the new pointer or NULL in case of error */ static xmlSchematronPatternPtr xmlSchematronAddPattern(xmlSchematronParserCtxtPtr ctxt, xmlSchematronPtr schema, xmlNodePtr node, xmlChar *name) { xmlSchematronPatternPtr ret; if ((ctxt == NULL) || (schema == NULL) || (node == NULL) || (name == NULL)) return(NULL); ret = (xmlSchematronPatternPtr) xmlMalloc(sizeof(xmlSchematronPattern)); if (ret == NULL) { xmlSchematronPErrMemory(ctxt, "allocating schema pattern", node); return (NULL); } memset(ret, 0, sizeof(xmlSchematronPattern)); ret->name = name; ret->next = NULL; if (schema->patterns == NULL) { schema->patterns = ret; } else { xmlSchematronPatternPtr prev = schema->patterns; while (prev->next != NULL) prev = prev->next; prev->next = ret; } return (ret); } /** * xmlSchematronFreePatterns: * @patterns: a list of patterns * * Free a list of patterns. */ static void xmlSchematronFreePatterns(xmlSchematronPatternPtr patterns) { xmlSchematronPatternPtr next; while (patterns != NULL) { next = patterns->next; if (patterns->name != NULL) xmlFree(patterns->name); xmlFree(patterns); patterns = next; } } /** * xmlSchematronNewSchematron: * @ctxt: a schema validation context * * Allocate a new Schematron structure. * * Returns the newly allocated structure or NULL in case or error */ static xmlSchematronPtr xmlSchematronNewSchematron(xmlSchematronParserCtxtPtr ctxt) { xmlSchematronPtr ret; ret = (xmlSchematronPtr) xmlMalloc(sizeof(xmlSchematron)); if (ret == NULL) { xmlSchematronPErrMemory(ctxt, "allocating schema", NULL); return (NULL); } memset(ret, 0, sizeof(xmlSchematron)); ret->dict = ctxt->dict; xmlDictReference(ret->dict); return (ret); } /** * xmlSchematronFree: * @schema: a schema structure * * Deallocate a Schematron structure. */ void xmlSchematronFree(xmlSchematronPtr schema) { if (schema == NULL) return; if ((schema->doc != NULL) && (!(schema->preserve))) xmlFreeDoc(schema->doc); if (schema->namespaces != NULL) xmlFree((char **) schema->namespaces); xmlSchematronFreeRules(schema->rules); xmlSchematronFreePatterns(schema->patterns); xmlDictFree(schema->dict); xmlFree(schema); } /** * xmlSchematronNewParserCtxt: * @URL: the location of the schema * * Create an XML Schematrons parse context for that file/resource expected * to contain an XML Schematrons file. * * Returns the parser context or NULL in case of error */ xmlSchematronParserCtxtPtr xmlSchematronNewParserCtxt(const char *URL) { xmlSchematronParserCtxtPtr ret; if (URL == NULL) return (NULL); ret = (xmlSchematronParserCtxtPtr) xmlMalloc(sizeof(xmlSchematronParserCtxt)); if (ret == NULL) { xmlSchematronPErrMemory(NULL, "allocating schema parser context", NULL); return (NULL); } memset(ret, 0, sizeof(xmlSchematronParserCtxt)); ret->type = XML_STRON_CTXT_PARSER; ret->dict = xmlDictCreate(); ret->URL = xmlDictLookup(ret->dict, (const xmlChar *) URL, -1); ret->includes = NULL; ret->xctxt = xmlXPathNewContext(NULL); if (ret->xctxt == NULL) { xmlSchematronPErrMemory(NULL, "allocating schema parser XPath context", NULL); xmlSchematronFreeParserCtxt(ret); return (NULL); } ret->xctxt->flags = XML_XPATH_CHECKNS; return (ret); } /** * xmlSchematronNewMemParserCtxt: * @buffer: a pointer to a char array containing the schemas * @size: the size of the array * * Create an XML Schematrons parse context for that memory buffer expected * to contain an XML Schematrons file. * * Returns the parser context or NULL in case of error */ xmlSchematronParserCtxtPtr xmlSchematronNewMemParserCtxt(const char *buffer, int size) { xmlSchematronParserCtxtPtr ret; if ((buffer == NULL) || (size <= 0)) return (NULL); ret = (xmlSchematronParserCtxtPtr) xmlMalloc(sizeof(xmlSchematronParserCtxt)); if (ret == NULL) { xmlSchematronPErrMemory(NULL, "allocating schema parser context", NULL); return (NULL); } memset(ret, 0, sizeof(xmlSchematronParserCtxt)); ret->buffer = buffer; ret->size = size; ret->dict = xmlDictCreate(); ret->xctxt = xmlXPathNewContext(NULL); if (ret->xctxt == NULL) { xmlSchematronPErrMemory(NULL, "allocating schema parser XPath context", NULL); xmlSchematronFreeParserCtxt(ret); return (NULL); } return (ret); } /** * xmlSchematronNewDocParserCtxt: * @doc: a preparsed document tree * * Create an XML Schematrons parse context for that document. * NB. The document may be modified during the parsing process. * * Returns the parser context or NULL in case of error */ xmlSchematronParserCtxtPtr xmlSchematronNewDocParserCtxt(xmlDocPtr doc) { xmlSchematronParserCtxtPtr ret; if (doc == NULL) return (NULL); ret = (xmlSchematronParserCtxtPtr) xmlMalloc(sizeof(xmlSchematronParserCtxt)); if (ret == NULL) { xmlSchematronPErrMemory(NULL, "allocating schema parser context", NULL); return (NULL); } memset(ret, 0, sizeof(xmlSchematronParserCtxt)); ret->doc = doc; ret->dict = xmlDictCreate(); /* The application has responsibility for the document */ ret->preserve = 1; ret->xctxt = xmlXPathNewContext(doc); if (ret->xctxt == NULL) { xmlSchematronPErrMemory(NULL, "allocating schema parser XPath context", NULL); xmlSchematronFreeParserCtxt(ret); return (NULL); } return (ret); } /** * xmlSchematronFreeParserCtxt: * @ctxt: the schema parser context * * Free the resources associated to the schema parser context */ void xmlSchematronFreeParserCtxt(xmlSchematronParserCtxtPtr ctxt) { if (ctxt == NULL) return; if (ctxt->doc != NULL && !ctxt->preserve) xmlFreeDoc(ctxt->doc); if (ctxt->xctxt != NULL) { xmlXPathFreeContext(ctxt->xctxt); } if (ctxt->namespaces != NULL) xmlFree((char **) ctxt->namespaces); xmlDictFree(ctxt->dict); xmlFree(ctxt); } #if 0 /** * xmlSchematronPushInclude: * @ctxt: the schema parser context * @doc: the included document * @cur: the current include node * * Add an included document */ static void xmlSchematronPushInclude(xmlSchematronParserCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr cur) { if (ctxt->includes == NULL) { ctxt->maxIncludes = 10; ctxt->includes = (xmlNodePtr *) xmlMalloc(ctxt->maxIncludes * 2 * sizeof(xmlNodePtr)); if (ctxt->includes == NULL) { xmlSchematronPErrMemory(NULL, "allocating parser includes", NULL); return; } ctxt->nbIncludes = 0; } else if (ctxt->nbIncludes + 2 >= ctxt->maxIncludes) { xmlNodePtr *tmp; tmp = (xmlNodePtr *) xmlRealloc(ctxt->includes, ctxt->maxIncludes * 4 * sizeof(xmlNodePtr)); if (tmp == NULL) { xmlSchematronPErrMemory(NULL, "allocating parser includes", NULL); return; } ctxt->includes = tmp; ctxt->maxIncludes *= 2; } ctxt->includes[2 * ctxt->nbIncludes] = cur; ctxt->includes[2 * ctxt->nbIncludes + 1] = (xmlNodePtr) doc; ctxt->nbIncludes++; } #endif /** * xmlSchematronPopInclude: * @ctxt: the schema parser context * * Pop an include level. The included document is being freed * * Returns the node immediately following the include or NULL if the * include list was empty. */ static xmlNodePtr xmlSchematronPopInclude(xmlSchematronParserCtxtPtr ctxt) { xmlDocPtr doc; xmlNodePtr ret; if (ctxt->nbIncludes <= 0) return(NULL); ctxt->nbIncludes--; doc = (xmlDocPtr) ctxt->includes[2 * ctxt->nbIncludes + 1]; ret = ctxt->includes[2 * ctxt->nbIncludes]; xmlFreeDoc(doc); if (ret != NULL) ret = ret->next; if (ret == NULL) return(xmlSchematronPopInclude(ctxt)); return(ret); } /** * xmlSchematronAddNamespace: * @ctxt: the schema parser context * @prefix: the namespace prefix * @ns: the namespace name * * Add a namespace definition in the context */ static void xmlSchematronAddNamespace(xmlSchematronParserCtxtPtr ctxt, const xmlChar *prefix, const xmlChar *ns) { if (ctxt->namespaces == NULL) { ctxt->maxNamespaces = 10; ctxt->namespaces = (const xmlChar **) xmlMalloc(ctxt->maxNamespaces * 2 * sizeof(const xmlChar *)); if (ctxt->namespaces == NULL) { xmlSchematronPErrMemory(NULL, "allocating parser namespaces", NULL); return; } ctxt->nbNamespaces = 0; } else if (ctxt->nbNamespaces + 2 >= ctxt->maxNamespaces) { const xmlChar **tmp; tmp = (const xmlChar **) xmlRealloc((xmlChar **) ctxt->namespaces, ctxt->maxNamespaces * 4 * sizeof(const xmlChar *)); if (tmp == NULL) { xmlSchematronPErrMemory(NULL, "allocating parser namespaces", NULL); return; } ctxt->namespaces = tmp; ctxt->maxNamespaces *= 2; } ctxt->namespaces[2 * ctxt->nbNamespaces] = xmlDictLookup(ctxt->dict, ns, -1); ctxt->namespaces[2 * ctxt->nbNamespaces + 1] = xmlDictLookup(ctxt->dict, prefix, -1); ctxt->nbNamespaces++; ctxt->namespaces[2 * ctxt->nbNamespaces] = NULL; ctxt->namespaces[2 * ctxt->nbNamespaces + 1] = NULL; } /** * xmlSchematronParseRule: * @ctxt: a schema validation context * @rule: the rule node * * parse a rule element */ static void xmlSchematronParseRule(xmlSchematronParserCtxtPtr ctxt, xmlSchematronPatternPtr pattern, xmlNodePtr rule) { xmlNodePtr cur; int nbChecks = 0; xmlChar *test; xmlChar *context; xmlChar *report; xmlSchematronRulePtr ruleptr; xmlSchematronTestPtr testptr; if ((ctxt == NULL) || (rule == NULL)) return; context = xmlGetNoNsProp(rule, BAD_CAST "context"); if (context == NULL) { xmlSchematronPErr(ctxt, rule, XML_SCHEMAP_NOROOT, "rule has no context attribute", NULL, NULL); return; } else if (context[0] == 0) { xmlSchematronPErr(ctxt, rule, XML_SCHEMAP_NOROOT, "rule has an empty context attribute", NULL, NULL); xmlFree(context); return; } else { ruleptr = xmlSchematronAddRule(ctxt, ctxt->schema, pattern, rule, context, NULL); if (ruleptr == NULL) { xmlFree(context); return; } } cur = rule->children; NEXT_SCHEMATRON(cur); while (cur != NULL) { if (IS_SCHEMATRON(cur, "assert")) { nbChecks++; test = xmlGetNoNsProp(cur, BAD_CAST "test"); if (test == NULL) { xmlSchematronPErr(ctxt, cur, XML_SCHEMAP_NOROOT, "assert has no test attribute", NULL, NULL); } else if (test[0] == 0) { xmlSchematronPErr(ctxt, cur, XML_SCHEMAP_NOROOT, "assert has an empty test attribute", NULL, NULL); xmlFree(test); } else { /* TODO will need dynamic processing instead */ report = xmlNodeGetContent(cur); testptr = xmlSchematronAddTest(ctxt, XML_SCHEMATRON_ASSERT, ruleptr, cur, test, report); if (testptr == NULL) xmlFree(test); } } else if (IS_SCHEMATRON(cur, "report")) { nbChecks++; test = xmlGetNoNsProp(cur, BAD_CAST "test"); if (test == NULL) { xmlSchematronPErr(ctxt, cur, XML_SCHEMAP_NOROOT, "assert has no test attribute", NULL, NULL); } else if (test[0] == 0) { xmlSchematronPErr(ctxt, cur, XML_SCHEMAP_NOROOT, "assert has an empty test attribute", NULL, NULL); xmlFree(test); } else { /* TODO will need dynamic processing instead */ report = xmlNodeGetContent(cur); testptr = xmlSchematronAddTest(ctxt, XML_SCHEMATRON_REPORT, ruleptr, cur, test, report); if (testptr == NULL) xmlFree(test); } } else { xmlSchematronPErr(ctxt, cur, XML_SCHEMAP_NOROOT, "Expecting an assert or a report element instead of %s", cur->name, NULL); } cur = cur->next; NEXT_SCHEMATRON(cur); } if (nbChecks == 0) { xmlSchematronPErr(ctxt, rule, XML_SCHEMAP_NOROOT, "rule has no assert nor report element", NULL, NULL); } } /** * xmlSchematronParsePattern: * @ctxt: a schema validation context * @pat: the pattern node * * parse a pattern element */ static void xmlSchematronParsePattern(xmlSchematronParserCtxtPtr ctxt, xmlNodePtr pat) { xmlNodePtr cur; xmlSchematronPatternPtr pattern; int nbRules = 0; xmlChar *id; if ((ctxt == NULL) || (pat == NULL)) return; id = xmlGetNoNsProp(pat, BAD_CAST "id"); if (id == NULL) { id = xmlGetNoNsProp(pat, BAD_CAST "name"); } pattern = xmlSchematronAddPattern(ctxt, ctxt->schema, pat, id); if (pattern == NULL) { if (id != NULL) xmlFree(id); return; } cur = pat->children; NEXT_SCHEMATRON(cur); while (cur != NULL) { if (IS_SCHEMATRON(cur, "rule")) { xmlSchematronParseRule(ctxt, pattern, cur); nbRules++; } else { xmlSchematronPErr(ctxt, cur, XML_SCHEMAP_NOROOT, "Expecting a rule element instead of %s", cur->name, NULL); } cur = cur->next; NEXT_SCHEMATRON(cur); } if (nbRules == 0) { xmlSchematronPErr(ctxt, pat, XML_SCHEMAP_NOROOT, "Pattern has no rule element", NULL, NULL); } } #if 0 /** * xmlSchematronLoadInclude: * @ctxt: a schema validation context * @cur: the include element * * Load the include document, Push the current pointer * * Returns the updated node pointer */ static xmlNodePtr xmlSchematronLoadInclude(xmlSchematronParserCtxtPtr ctxt, xmlNodePtr cur) { xmlNodePtr ret = NULL; xmlDocPtr doc = NULL; xmlChar *href = NULL; xmlChar *base = NULL; xmlChar *URI = NULL; if ((ctxt == NULL) || (cur == NULL)) return(NULL); href = xmlGetNoNsProp(cur, BAD_CAST "href"); if (href == NULL) { xmlSchematronPErr(ctxt, cur, XML_SCHEMAP_NOROOT, "Include has no href attribute", NULL, NULL); return(cur->next); } /* do the URI base composition, load and find the root */ base = xmlNodeGetBase(cur->doc, cur); URI = xmlBuildURI(href, base); doc = xmlReadFile((const char *) URI, NULL, SCHEMATRON_PARSE_OPTIONS); if (doc == NULL) { xmlSchematronPErr(ctxt, cur, XML_SCHEMAP_FAILED_LOAD, "could not load include '%s'.\n", URI, NULL); goto done; } ret = xmlDocGetRootElement(doc); if (ret == NULL) { xmlSchematronPErr(ctxt, cur, XML_SCHEMAP_FAILED_LOAD, "could not find root from include '%s'.\n", URI, NULL); goto done; } /* Success, push the include for rollback on exit */ xmlSchematronPushInclude(ctxt, doc, cur); done: if (ret == NULL) { if (doc != NULL) xmlFreeDoc(doc); } xmlFree(href); if (base != NULL) xmlFree(base); if (URI != NULL) xmlFree(URI); return(ret); } #endif /** * xmlSchematronParse: * @ctxt: a schema validation context * * parse a schema definition resource and build an internal * XML Shema struture which can be used to validate instances. * * Returns the internal XML Schematron structure built from the resource or * NULL in case of error */ xmlSchematronPtr xmlSchematronParse(xmlSchematronParserCtxtPtr ctxt) { xmlSchematronPtr ret = NULL; xmlDocPtr doc; xmlNodePtr root, cur; int preserve = 0; if (ctxt == NULL) return (NULL); ctxt->nberrors = 0; /* * First step is to parse the input document into an DOM/Infoset */ if (ctxt->URL != NULL) { doc = xmlReadFile((const char *) ctxt->URL, NULL, SCHEMATRON_PARSE_OPTIONS); if (doc == NULL) { xmlSchematronPErr(ctxt, NULL, XML_SCHEMAP_FAILED_LOAD, "xmlSchematronParse: could not load '%s'.\n", ctxt->URL, NULL); return (NULL); } ctxt->preserve = 0; } else if (ctxt->buffer != NULL) { doc = xmlReadMemory(ctxt->buffer, ctxt->size, NULL, NULL, SCHEMATRON_PARSE_OPTIONS); if (doc == NULL) { xmlSchematronPErr(ctxt, NULL, XML_SCHEMAP_FAILED_PARSE, "xmlSchematronParse: could not parse.\n", NULL, NULL); return (NULL); } doc->URL = xmlStrdup(BAD_CAST "in_memory_buffer"); ctxt->URL = xmlDictLookup(ctxt->dict, BAD_CAST "in_memory_buffer", -1); ctxt->preserve = 0; } else if (ctxt->doc != NULL) { doc = ctxt->doc; preserve = 1; ctxt->preserve = 1; } else { xmlSchematronPErr(ctxt, NULL, XML_SCHEMAP_NOTHING_TO_PARSE, "xmlSchematronParse: could not parse.\n", NULL, NULL); return (NULL); } /* * Then extract the root and Schematron parse it */ root = xmlDocGetRootElement(doc); if (root == NULL) { xmlSchematronPErr(ctxt, (xmlNodePtr) doc, XML_SCHEMAP_NOROOT, "The schema has no document element.\n", NULL, NULL); if (!preserve) { xmlFreeDoc(doc); } return (NULL); } if (!IS_SCHEMATRON(root, "schema")) { xmlSchematronPErr(ctxt, root, XML_SCHEMAP_NOROOT, "The XML document '%s' is not a XML schematron document", ctxt->URL, NULL); goto exit; } ret = xmlSchematronNewSchematron(ctxt); if (ret == NULL) goto exit; ctxt->schema = ret; /* * scan the schema elements */ cur = root->children; NEXT_SCHEMATRON(cur); if (IS_SCHEMATRON(cur, "title")) { xmlChar *title = xmlNodeGetContent(cur); if (title != NULL) { ret->title = xmlDictLookup(ret->dict, title, -1); xmlFree(title); } cur = cur->next; NEXT_SCHEMATRON(cur); } while (IS_SCHEMATRON(cur, "ns")) { xmlChar *prefix = xmlGetNoNsProp(cur, BAD_CAST "prefix"); xmlChar *uri = xmlGetNoNsProp(cur, BAD_CAST "uri"); if ((uri == NULL) || (uri[0] == 0)) { xmlSchematronPErr(ctxt, cur, XML_SCHEMAP_NOROOT, "ns element has no uri", NULL, NULL); } if ((prefix == NULL) || (prefix[0] == 0)) { xmlSchematronPErr(ctxt, cur, XML_SCHEMAP_NOROOT, "ns element has no prefix", NULL, NULL); } if ((prefix) && (uri)) { xmlXPathRegisterNs(ctxt->xctxt, prefix, uri); xmlSchematronAddNamespace(ctxt, prefix, uri); ret->nbNs++; } if (uri) xmlFree(uri); if (prefix) xmlFree(prefix); cur = cur->next; NEXT_SCHEMATRON(cur); } while (cur != NULL) { if (IS_SCHEMATRON(cur, "pattern")) { xmlSchematronParsePattern(ctxt, cur); ret->nbPattern++; } else { xmlSchematronPErr(ctxt, cur, XML_SCHEMAP_NOROOT, "Expecting a pattern element instead of %s", cur->name, NULL); } cur = cur->next; NEXT_SCHEMATRON(cur); } if (ret->nbPattern == 0) { xmlSchematronPErr(ctxt, root, XML_SCHEMAP_NOROOT, "The schematron document '%s' has no pattern", ctxt->URL, NULL); goto exit; } /* the original document must be kept for reporting */ ret->doc = doc; preserve = 1; exit: if (!preserve) { xmlFreeDoc(doc); } if (ret != NULL) { if (ctxt->nberrors != 0) { xmlSchematronFree(ret); ret = NULL; } else { ret->namespaces = ctxt->namespaces; ret->nbNamespaces = ctxt->nbNamespaces; ctxt->namespaces = NULL; } } return (ret); } /************************************************************************ * * * Schematrontron Reports handler * * * ************************************************************************/ static xmlNodePtr xmlSchematronGetNode(xmlSchematronValidCtxtPtr ctxt, xmlNodePtr cur, const xmlChar *xpath) { xmlNodePtr node = NULL; xmlXPathObjectPtr ret; if ((ctxt == NULL) || (cur == NULL) || (xpath == NULL)) return(NULL); ctxt->xctxt->doc = cur->doc; ctxt->xctxt->node = cur; ret = xmlXPathEval(xpath, ctxt->xctxt); if (ret == NULL) return(NULL); if ((ret->type == XPATH_NODESET) && (ret->nodesetval != NULL) && (ret->nodesetval->nodeNr > 0)) node = ret->nodesetval->nodeTab[0]; xmlXPathFreeObject(ret); return(node); } /** * xmlSchematronReportOutput: * @ctxt: the validation context * @cur: the current node tested * @msg: the message output * * Output part of the report to whatever channel the user selected */ static void xmlSchematronReportOutput(xmlSchematronValidCtxtPtr ctxt ATTRIBUTE_UNUSED, xmlNodePtr cur ATTRIBUTE_UNUSED, const char *msg) { /* TODO */ fprintf(stderr, "%s", msg); } /** * xmlSchematronFormatReport: * @ctxt: the validation context * @test: the test node * @cur: the current node tested * * Build the string being reported to the user. * * Returns a report string or NULL in case of error. The string needs * to be deallocated by teh caller */ static xmlChar * xmlSchematronFormatReport(xmlSchematronValidCtxtPtr ctxt, xmlNodePtr test, xmlNodePtr cur) { xmlChar *ret = NULL; xmlNodePtr child, node; if ((test == NULL) || (cur == NULL)) return(ret); child = test->children; while (child != NULL) { if ((child->type == XML_TEXT_NODE) || (child->type == XML_CDATA_SECTION_NODE)) ret = xmlStrcat(ret, child->content); else if (IS_SCHEMATRON(child, "name")) { xmlChar *path; path = xmlGetNoNsProp(child, BAD_CAST "path"); node = cur; if (path != NULL) { node = xmlSchematronGetNode(ctxt, cur, path); if (node == NULL) node = cur; xmlFree(path); } if ((node->ns == NULL) || (node->ns->prefix == NULL)) ret = xmlStrcat(ret, node->name); else { ret = xmlStrcat(ret, node->ns->prefix); ret = xmlStrcat(ret, BAD_CAST ":"); ret = xmlStrcat(ret, node->name); } } else { child = child->next; continue; } /* * remove superfluous \n */ if (ret != NULL) { int len = xmlStrlen(ret); xmlChar c; if (len > 0) { c = ret[len - 1]; if ((c == ' ') || (c == '\n') || (c == '\r') || (c == '\t')) { while ((c == ' ') || (c == '\n') || (c == '\r') || (c == '\t')) { len--; if (len == 0) break; c = ret[len - 1]; } ret[len] = ' '; ret[len + 1] = 0; } } } child = child->next; } return(ret); } /** * xmlSchematronReportSuccess: * @ctxt: the validation context * @test: the compiled test * @cur: the current node tested * @success: boolean value for the result * * called from the validation engine when an assert or report test have * been done. */ static void xmlSchematronReportSuccess(xmlSchematronValidCtxtPtr ctxt, xmlSchematronTestPtr test, xmlNodePtr cur, int success) { if ((ctxt == NULL) || (cur == NULL) || (test == NULL)) return; /* if quiet and not SVRL report only failures */ if ((ctxt->flags & XML_SCHEMATRON_OUT_QUIET) && ((ctxt->flags & XML_SCHEMATRON_OUT_XML) == 0) && (test->type == XML_SCHEMATRON_REPORT)) return; if (ctxt->flags & XML_SCHEMATRON_OUT_XML) { TODO } else { xmlChar *path; char msg[1000]; long line; const xmlChar *report = NULL; if (((test->type == XML_SCHEMATRON_REPORT) & (!success)) || ((test->type == XML_SCHEMATRON_ASSERT) & (success))) return; line = xmlGetLineNo(cur); path = xmlGetNodePath(cur); if (path == NULL) path = (xmlChar *) cur->name; #if 0 if ((test->report != NULL) && (test->report[0] != 0)) report = test->report; #endif if (test->node != NULL) report = xmlSchematronFormatReport(ctxt, test->node, cur); if (report == NULL) { if (test->type == XML_SCHEMATRON_ASSERT) { snprintf(msg, 999, "%s line %ld: node failed assert\n", (const char *) path, line); } else { snprintf(msg, 999, "%s line %ld: node failed report\n", (const char *) path, line); } } else { snprintf(msg, 999, "%s line %ld: %s\n", (const char *) path, line, (const char *) report); xmlFree((char *) report); } xmlSchematronReportOutput(ctxt, cur, &msg[0]); if ((path != NULL) && (path != (xmlChar *) cur->name)) xmlFree(path); } } /** * xmlSchematronReportPattern: * @ctxt: the validation context * @pattern: the current pattern * * called from the validation engine when starting to check a pattern */ static void xmlSchematronReportPattern(xmlSchematronValidCtxtPtr ctxt, xmlSchematronPatternPtr pattern) { if ((ctxt == NULL) || (pattern == NULL)) return; if (ctxt->flags & XML_SCHEMATRON_OUT_QUIET) return; if (ctxt->flags & XML_SCHEMATRON_OUT_XML) { TODO } else { char msg[1000]; if (pattern->name == NULL) return; snprintf(msg, 999, "Pattern: %s\n", (const char *) pattern->name); xmlSchematronReportOutput(ctxt, NULL, &msg[0]); } } /************************************************************************ * * * Validation against a Schematrontron * * * ************************************************************************/ /** * xmlSchematronNewValidCtxt: * @schema: a precompiled XML Schematrons * @options: a set of xmlSchematronValidOptions * * Create an XML Schematrons validation context based on the given schema. * * Returns the validation context or NULL in case of error */ xmlSchematronValidCtxtPtr xmlSchematronNewValidCtxt(xmlSchematronPtr schema, int options) { int i; xmlSchematronValidCtxtPtr ret; ret = (xmlSchematronValidCtxtPtr) xmlMalloc(sizeof(xmlSchematronValidCtxt)); if (ret == NULL) { xmlSchematronVErrMemory(NULL, "allocating validation context", NULL); return (NULL); } memset(ret, 0, sizeof(xmlSchematronValidCtxt)); ret->type = XML_STRON_CTXT_VALIDATOR; ret->schema = schema; ret->xctxt = xmlXPathNewContext(NULL); ret->flags = options; if (ret->xctxt == NULL) { xmlSchematronPErrMemory(NULL, "allocating schema parser XPath context", NULL); xmlSchematronFreeValidCtxt(ret); return (NULL); } for (i = 0;i < schema->nbNamespaces;i++) { if ((schema->namespaces[2 * i] == NULL) || (schema->namespaces[2 * i + 1] == NULL)) break; xmlXPathRegisterNs(ret->xctxt, schema->namespaces[2 * i + 1], schema->namespaces[2 * i]); } return (ret); } /** * xmlSchematronFreeValidCtxt: * @ctxt: the schema validation context * * Free the resources associated to the schema validation context */ void xmlSchematronFreeValidCtxt(xmlSchematronValidCtxtPtr ctxt) { if (ctxt == NULL) return; if (ctxt->xctxt != NULL) xmlXPathFreeContext(ctxt->xctxt); if (ctxt->dict != NULL) xmlDictFree(ctxt->dict); xmlFree(ctxt); } static xmlNodePtr xmlSchematronNextNode(xmlNodePtr cur) { if (cur->children != NULL) { /* * Do not descend on entities declarations */ if (cur->children->type != XML_ENTITY_DECL) { cur = cur->children; /* * Skip DTDs */ if (cur->type != XML_DTD_NODE) return(cur); } } while (cur->next != NULL) { cur = cur->next; if ((cur->type != XML_ENTITY_DECL) && (cur->type != XML_DTD_NODE)) return(cur); } do { cur = cur->parent; if (cur == NULL) break; if (cur->type == XML_DOCUMENT_NODE) return(NULL); if (cur->next != NULL) { cur = cur->next; return(cur); } } while (cur != NULL); return(cur); } /** * xmlSchematronRunTest: * @ctxt: the schema validation context * @test: the current test * @instance: the document instace tree * @cur: the current node in the instance * * Validate a rule against a tree instance at a given position * * Returns 1 in case of success, 0 if error and -1 in case of internal error */ static int xmlSchematronRunTest(xmlSchematronValidCtxtPtr ctxt, xmlSchematronTestPtr test, xmlDocPtr instance, xmlNodePtr cur) { xmlXPathObjectPtr ret; int failed; failed = 0; ctxt->xctxt->doc = instance; ctxt->xctxt->node = cur; ret = xmlXPathCompiledEval(test->comp, ctxt->xctxt); if (ret == NULL) { failed = 1; } else { switch (ret->type) { case XPATH_XSLT_TREE: case XPATH_NODESET: if ((ret->nodesetval == NULL) || (ret->nodesetval->nodeNr == 0)) failed = 1; break; case XPATH_BOOLEAN: failed = !ret->boolval; break; case XPATH_NUMBER: if ((xmlXPathIsNaN(ret->floatval)) || (ret->floatval == 0.0)) failed = 1; break; case XPATH_STRING: if ((ret->stringval == NULL) || (ret->stringval[0] == 0)) failed = 1; break; case XPATH_UNDEFINED: case XPATH_POINT: case XPATH_RANGE: case XPATH_LOCATIONSET: case XPATH_USERS: failed = 1; break; } xmlXPathFreeObject(ret); } if ((failed) && (test->type == XML_SCHEMATRON_ASSERT)) ctxt->nberrors++; else if ((!failed) && (test->type == XML_SCHEMATRON_REPORT)) ctxt->nberrors++; xmlSchematronReportSuccess(ctxt, test, cur, !failed); return(!failed); } /** * xmlSchematronValidateDoc: * @ctxt: the schema validation context * @instance: the document instace tree * * Validate a tree instance against the schematron * * Returns 0 in case of success, -1 in case of internal error * and an error count otherwise. */ int xmlSchematronValidateDoc(xmlSchematronValidCtxtPtr ctxt, xmlDocPtr instance) { xmlNodePtr cur, root; xmlSchematronPatternPtr pattern; xmlSchematronRulePtr rule; xmlSchematronTestPtr test; if ((ctxt == NULL) || (ctxt->schema == NULL) || (ctxt->schema->rules == NULL) || (instance == NULL)) return(-1); ctxt->nberrors = 0; root = xmlDocGetRootElement(instance); if (root == NULL) { TODO ctxt->nberrors++; return(1); } if ((ctxt->flags & XML_SCHEMATRON_OUT_QUIET) || (ctxt->flags == 0)) { /* * we are just trying to assert the validity of the document, * speed primes over the output, run in a single pass */ cur = root; while (cur != NULL) { rule = ctxt->schema->rules; while (rule != NULL) { if (xmlPatternMatch(rule->pattern, cur) == 1) { test = rule->tests; while (test != NULL) { xmlSchematronRunTest(ctxt, test, instance, cur); test = test->next; } } rule = rule->next; } cur = xmlSchematronNextNode(cur); } } else { /* * Process all contexts one at a time */ pattern = ctxt->schema->patterns; while (pattern != NULL) { xmlSchematronReportPattern(ctxt, pattern); /* * TODO convert the pattern rule to a direct XPath and * compute directly instead of using the pattern matching * over the full document... * Check the exact semantic */ cur = root; while (cur != NULL) { rule = pattern->rules; while (rule != NULL) { if (xmlPatternMatch(rule->pattern, cur) == 1) { test = rule->tests; while (test != NULL) { xmlSchematronRunTest(ctxt, test, instance, cur); test = test->next; } } rule = rule->patnext; } cur = xmlSchematronNextNode(cur); } pattern = pattern->next; } } return(ctxt->nberrors); } #ifdef STANDALONE int main(void) { int ret; xmlDocPtr instance; xmlSchematronParserCtxtPtr pctxt; xmlSchematronValidCtxtPtr vctxt; xmlSchematronPtr schema = NULL; pctxt = xmlSchematronNewParserCtxt("tst.sct"); if (pctxt == NULL) { fprintf(stderr, "failed to build schematron parser\n"); } else { schema = xmlSchematronParse(pctxt); if (schema == NULL) { fprintf(stderr, "failed to compile schematron\n"); } xmlSchematronFreeParserCtxt(pctxt); } instance = xmlReadFile("tst.sct", NULL, XML_PARSE_NOENT | XML_PARSE_NOCDATA); if (instance == NULL) { fprintf(stderr, "failed to parse instance\n"); } if ((schema != NULL) && (instance != NULL)) { vctxt = xmlSchematronNewValidCtxt(schema); if (vctxt == NULL) { fprintf(stderr, "failed to build schematron validator\n"); } else { ret = xmlSchematronValidateDoc(vctxt, instance); xmlSchematronFreeValidCtxt(vctxt); } } xmlSchematronFree(schema); xmlFreeDoc(instance); xmlCleanupParser(); xmlMemoryDump(); return (0); } #endif #define bottom_schematron #include "elfgcchack.h" #endif /* LIBXML_SCHEMATRON_ENABLED */ xdmf-3.0+git20160803/Utilities/vtklibxml2/tree.c0000640000175000017500000106314313003006557021256 0ustar alastairalastair/* * tree.c : implementation of access function for an XML tree. * * References: * XHTML 1.0 W3C REC: http://www.w3.org/TR/2002/REC-xhtml1-20020801/ * * See Copyright for the status of this software. * * daniel@veillard.com * */ #define IN_LIBXML #include "libxml.h" #include /* for memset() only ! */ #ifdef HAVE_CTYPE_H #include #endif #ifdef HAVE_STDLIB_H #include #endif #include "vtk_libxml2_zlib.h" #include #include #include #include #include #include #include #include #include #ifdef LIBXML_HTML_ENABLED #include #endif #ifdef LIBXML_DEBUG_ENABLED #include #endif int __xmlRegisterCallbacks = 0; /************************************************************************ * * * Forward declarations * * * ************************************************************************/ xmlNsPtr xmlNewReconciliedNs(xmlDocPtr doc, xmlNodePtr tree, xmlNsPtr ns); static xmlChar* xmlGetPropNodeValueInternal(xmlAttrPtr prop); /************************************************************************ * * * Tree memory error handler * * * ************************************************************************/ /** * xmlTreeErrMemory: * @extra: extra informations * * Handle an out of memory condition */ static void xmlTreeErrMemory(const char *extra) { __xmlSimpleError(XML_FROM_TREE, XML_ERR_NO_MEMORY, NULL, NULL, extra); } /** * xmlTreeErr: * @code: the error number * @extra: extra informations * * Handle an out of memory condition */ static void xmlTreeErr(int code, xmlNodePtr node, const char *extra) { const char *msg = NULL; switch(code) { case XML_TREE_INVALID_HEX: msg = "invalid hexadecimal character value\n"; break; case XML_TREE_INVALID_DEC: msg = "invalid decimal character value\n"; break; case XML_TREE_UNTERMINATED_ENTITY: msg = "unterminated entity reference %15s\n"; break; default: msg = "unexpected error number\n"; } __xmlSimpleError(XML_FROM_TREE, code, node, msg, extra); } /************************************************************************ * * * A few static variables and macros * * * ************************************************************************/ /* #undef xmlStringText */ const xmlChar xmlStringText[] = { 't', 'e', 'x', 't', 0 }; /* #undef xmlStringTextNoenc */ const xmlChar xmlStringTextNoenc[] = { 't', 'e', 'x', 't', 'n', 'o', 'e', 'n', 'c', 0 }; /* #undef xmlStringComment */ const xmlChar xmlStringComment[] = { 'c', 'o', 'm', 'm', 'e', 'n', 't', 0 }; static int xmlCompressMode = 0; static int xmlCheckDTD = 1; #define UPDATE_LAST_CHILD_AND_PARENT(n) if ((n) != NULL) { \ xmlNodePtr ulccur = (n)->children; \ if (ulccur == NULL) { \ (n)->last = NULL; \ } else { \ while (ulccur->next != NULL) { \ ulccur->parent = (n); \ ulccur = ulccur->next; \ } \ ulccur->parent = (n); \ (n)->last = ulccur; \ }} #define IS_STR_XML(str) ((str != NULL) && (str[0] == 'x') && \ (str[1] == 'm') && (str[2] == 'l') && (str[3] == 0)) /* #define DEBUG_BUFFER */ /* #define DEBUG_TREE */ /************************************************************************ * * * Functions to move to entities.c once the * * API freeze is smoothen and they can be made public. * * * ************************************************************************/ #include #ifdef LIBXML_TREE_ENABLED /** * xmlGetEntityFromDtd: * @dtd: A pointer to the DTD to search * @name: The entity name * * Do an entity lookup in the DTD entity hash table and * return the corresponding entity, if found. * * Returns A pointer to the entity structure or NULL if not found. */ static xmlEntityPtr xmlGetEntityFromDtd(xmlDtdPtr dtd, const xmlChar *name) { xmlEntitiesTablePtr table; if((dtd != NULL) && (dtd->entities != NULL)) { table = (xmlEntitiesTablePtr) dtd->entities; return((xmlEntityPtr) xmlHashLookup(table, name)); /* return(xmlGetEntityFromTable(table, name)); */ } return(NULL); } /** * xmlGetParameterEntityFromDtd: * @dtd: A pointer to the DTD to search * @name: The entity name * * Do an entity lookup in the DTD pararmeter entity hash table and * return the corresponding entity, if found. * * Returns A pointer to the entity structure or NULL if not found. */ static xmlEntityPtr xmlGetParameterEntityFromDtd(xmlDtdPtr dtd, const xmlChar *name) { xmlEntitiesTablePtr table; if ((dtd != NULL) && (dtd->pentities != NULL)) { table = (xmlEntitiesTablePtr) dtd->pentities; return((xmlEntityPtr) xmlHashLookup(table, name)); /* return(xmlGetEntityFromTable(table, name)); */ } return(NULL); } #endif /* LIBXML_TREE_ENABLED */ /************************************************************************ * * * QName handling helper * * * ************************************************************************/ /** * xmlBuildQName: * @ncname: the Name * @prefix: the prefix * @memory: preallocated memory * @len: preallocated memory length * * Builds the QName @prefix:@ncname in @memory if there is enough space * and prefix is not NULL nor empty, otherwise allocate a new string. * If prefix is NULL or empty it returns ncname. * * Returns the new string which must be freed by the caller if different from * @memory and @ncname or NULL in case of error */ xmlChar * xmlBuildQName(const xmlChar *ncname, const xmlChar *prefix, xmlChar *memory, int len) { int lenn, lenp; xmlChar *ret; if (ncname == NULL) return(NULL); if (prefix == NULL) return((xmlChar *) ncname); lenn = strlen((char *) ncname); lenp = strlen((char *) prefix); if ((memory == NULL) || (len < lenn + lenp + 2)) { ret = (xmlChar *) xmlMallocAtomic(lenn + lenp + 2); if (ret == NULL) { xmlTreeErrMemory("building QName"); return(NULL); } } else { ret = memory; } memcpy(&ret[0], prefix, lenp); ret[lenp] = ':'; memcpy(&ret[lenp + 1], ncname, lenn); ret[lenn + lenp + 1] = 0; return(ret); } /** * xmlSplitQName2: * @name: the full QName * @prefix: a xmlChar ** * * parse an XML qualified name string * * [NS 5] QName ::= (Prefix ':')? LocalPart * * [NS 6] Prefix ::= NCName * * [NS 7] LocalPart ::= NCName * * Returns NULL if not a QName, otherwise the local part, and prefix * is updated to get the Prefix if any. */ xmlChar * xmlSplitQName2(const xmlChar *name, xmlChar **prefix) { int len = 0; xmlChar *ret = NULL; if (prefix == NULL) return(NULL); *prefix = NULL; if (name == NULL) return(NULL); #ifndef XML_XML_NAMESPACE /* xml: prefix is not really a namespace */ if ((name[0] == 'x') && (name[1] == 'm') && (name[2] == 'l') && (name[3] == ':')) return(NULL); #endif /* nasty but valid */ if (name[0] == ':') return(NULL); /* * we are not trying to validate but just to cut, and yes it will * work even if this is as set of UTF-8 encoded chars */ while ((name[len] != 0) && (name[len] != ':')) len++; if (name[len] == 0) return(NULL); *prefix = xmlStrndup(name, len); if (*prefix == NULL) { xmlTreeErrMemory("QName split"); return(NULL); } ret = xmlStrdup(&name[len + 1]); if (ret == NULL) { xmlTreeErrMemory("QName split"); if (*prefix != NULL) { xmlFree(*prefix); *prefix = NULL; } return(NULL); } return(ret); } /** * xmlSplitQName3: * @name: the full QName * @len: an int * * * parse an XML qualified name string,i * * returns NULL if it is not a Qualified Name, otherwise, update len * with the lenght in byte of the prefix and return a pointer * to the start of the name without the prefix */ const xmlChar * xmlSplitQName3(const xmlChar *name, int *len) { int l = 0; if (name == NULL) return(NULL); if (len == NULL) return(NULL); /* nasty but valid */ if (name[0] == ':') return(NULL); /* * we are not trying to validate but just to cut, and yes it will * work even if this is as set of UTF-8 encoded chars */ while ((name[l] != 0) && (name[l] != ':')) l++; if (name[l] == 0) return(NULL); *len = l; return(&name[l+1]); } /************************************************************************ * * * Check Name, NCName and QName strings * * * ************************************************************************/ #define CUR_SCHAR(s, l) xmlStringCurrentChar(NULL, s, &l) #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_DEBUG_ENABLED) || defined (LIBXML_HTML_ENABLED) || defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED) /** * xmlValidateNCName: * @value: the value to check * @space: allow spaces in front and end of the string * * Check that a value conforms to the lexical space of NCName * * Returns 0 if this validates, a positive error code number otherwise * and -1 in case of internal or API error. */ int xmlValidateNCName(const xmlChar *value, int space) { const xmlChar *cur = value; int c,l; if (value == NULL) return(-1); /* * First quick algorithm for ASCII range */ if (space) while (IS_BLANK_CH(*cur)) cur++; if (((*cur >= 'a') && (*cur <= 'z')) || ((*cur >= 'A') && (*cur <= 'Z')) || (*cur == '_')) cur++; else goto try_complex; while (((*cur >= 'a') && (*cur <= 'z')) || ((*cur >= 'A') && (*cur <= 'Z')) || ((*cur >= '0') && (*cur <= '9')) || (*cur == '_') || (*cur == '-') || (*cur == '.')) cur++; if (space) while (IS_BLANK_CH(*cur)) cur++; if (*cur == 0) return(0); try_complex: /* * Second check for chars outside the ASCII range */ cur = value; c = CUR_SCHAR(cur, l); if (space) { while (IS_BLANK(c)) { cur += l; c = CUR_SCHAR(cur, l); } } if ((!IS_LETTER(c)) && (c != '_')) return(1); cur += l; c = CUR_SCHAR(cur, l); while (IS_LETTER(c) || IS_DIGIT(c) || (c == '.') || (c == '-') || (c == '_') || IS_COMBINING(c) || IS_EXTENDER(c)) { cur += l; c = CUR_SCHAR(cur, l); } if (space) { while (IS_BLANK(c)) { cur += l; c = CUR_SCHAR(cur, l); } } if (c != 0) return(1); return(0); } #endif #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) /** * xmlValidateQName: * @value: the value to check * @space: allow spaces in front and end of the string * * Check that a value conforms to the lexical space of QName * * Returns 0 if this validates, a positive error code number otherwise * and -1 in case of internal or API error. */ int xmlValidateQName(const xmlChar *value, int space) { const xmlChar *cur = value; int c,l; if (value == NULL) return(-1); /* * First quick algorithm for ASCII range */ if (space) while (IS_BLANK_CH(*cur)) cur++; if (((*cur >= 'a') && (*cur <= 'z')) || ((*cur >= 'A') && (*cur <= 'Z')) || (*cur == '_')) cur++; else goto try_complex; while (((*cur >= 'a') && (*cur <= 'z')) || ((*cur >= 'A') && (*cur <= 'Z')) || ((*cur >= '0') && (*cur <= '9')) || (*cur == '_') || (*cur == '-') || (*cur == '.')) cur++; if (*cur == ':') { cur++; if (((*cur >= 'a') && (*cur <= 'z')) || ((*cur >= 'A') && (*cur <= 'Z')) || (*cur == '_')) cur++; else goto try_complex; while (((*cur >= 'a') && (*cur <= 'z')) || ((*cur >= 'A') && (*cur <= 'Z')) || ((*cur >= '0') && (*cur <= '9')) || (*cur == '_') || (*cur == '-') || (*cur == '.')) cur++; } if (space) while (IS_BLANK_CH(*cur)) cur++; if (*cur == 0) return(0); try_complex: /* * Second check for chars outside the ASCII range */ cur = value; c = CUR_SCHAR(cur, l); if (space) { while (IS_BLANK(c)) { cur += l; c = CUR_SCHAR(cur, l); } } if ((!IS_LETTER(c)) && (c != '_')) return(1); cur += l; c = CUR_SCHAR(cur, l); while (IS_LETTER(c) || IS_DIGIT(c) || (c == '.') || (c == '-') || (c == '_') || IS_COMBINING(c) || IS_EXTENDER(c)) { cur += l; c = CUR_SCHAR(cur, l); } if (c == ':') { cur += l; c = CUR_SCHAR(cur, l); if ((!IS_LETTER(c)) && (c != '_')) return(1); cur += l; c = CUR_SCHAR(cur, l); while (IS_LETTER(c) || IS_DIGIT(c) || (c == '.') || (c == '-') || (c == '_') || IS_COMBINING(c) || IS_EXTENDER(c)) { cur += l; c = CUR_SCHAR(cur, l); } } if (space) { while (IS_BLANK(c)) { cur += l; c = CUR_SCHAR(cur, l); } } if (c != 0) return(1); return(0); } /** * xmlValidateName: * @value: the value to check * @space: allow spaces in front and end of the string * * Check that a value conforms to the lexical space of Name * * Returns 0 if this validates, a positive error code number otherwise * and -1 in case of internal or API error. */ int xmlValidateName(const xmlChar *value, int space) { const xmlChar *cur = value; int c,l; if (value == NULL) return(-1); /* * First quick algorithm for ASCII range */ if (space) while (IS_BLANK_CH(*cur)) cur++; if (((*cur >= 'a') && (*cur <= 'z')) || ((*cur >= 'A') && (*cur <= 'Z')) || (*cur == '_') || (*cur == ':')) cur++; else goto try_complex; while (((*cur >= 'a') && (*cur <= 'z')) || ((*cur >= 'A') && (*cur <= 'Z')) || ((*cur >= '0') && (*cur <= '9')) || (*cur == '_') || (*cur == '-') || (*cur == '.') || (*cur == ':')) cur++; if (space) while (IS_BLANK_CH(*cur)) cur++; if (*cur == 0) return(0); try_complex: /* * Second check for chars outside the ASCII range */ cur = value; c = CUR_SCHAR(cur, l); if (space) { while (IS_BLANK(c)) { cur += l; c = CUR_SCHAR(cur, l); } } if ((!IS_LETTER(c)) && (c != '_') && (c != ':')) return(1); cur += l; c = CUR_SCHAR(cur, l); while (IS_LETTER(c) || IS_DIGIT(c) || (c == '.') || (c == ':') || (c == '-') || (c == '_') || IS_COMBINING(c) || IS_EXTENDER(c)) { cur += l; c = CUR_SCHAR(cur, l); } if (space) { while (IS_BLANK(c)) { cur += l; c = CUR_SCHAR(cur, l); } } if (c != 0) return(1); return(0); } /** * xmlValidateNMToken: * @value: the value to check * @space: allow spaces in front and end of the string * * Check that a value conforms to the lexical space of NMToken * * Returns 0 if this validates, a positive error code number otherwise * and -1 in case of internal or API error. */ int xmlValidateNMToken(const xmlChar *value, int space) { const xmlChar *cur = value; int c,l; if (value == NULL) return(-1); /* * First quick algorithm for ASCII range */ if (space) while (IS_BLANK_CH(*cur)) cur++; if (((*cur >= 'a') && (*cur <= 'z')) || ((*cur >= 'A') && (*cur <= 'Z')) || ((*cur >= '0') && (*cur <= '9')) || (*cur == '_') || (*cur == '-') || (*cur == '.') || (*cur == ':')) cur++; else goto try_complex; while (((*cur >= 'a') && (*cur <= 'z')) || ((*cur >= 'A') && (*cur <= 'Z')) || ((*cur >= '0') && (*cur <= '9')) || (*cur == '_') || (*cur == '-') || (*cur == '.') || (*cur == ':')) cur++; if (space) while (IS_BLANK_CH(*cur)) cur++; if (*cur == 0) return(0); try_complex: /* * Second check for chars outside the ASCII range */ cur = value; c = CUR_SCHAR(cur, l); if (space) { while (IS_BLANK(c)) { cur += l; c = CUR_SCHAR(cur, l); } } if (!(IS_LETTER(c) || IS_DIGIT(c) || (c == '.') || (c == ':') || (c == '-') || (c == '_') || IS_COMBINING(c) || IS_EXTENDER(c))) return(1); cur += l; c = CUR_SCHAR(cur, l); while (IS_LETTER(c) || IS_DIGIT(c) || (c == '.') || (c == ':') || (c == '-') || (c == '_') || IS_COMBINING(c) || IS_EXTENDER(c)) { cur += l; c = CUR_SCHAR(cur, l); } if (space) { while (IS_BLANK(c)) { cur += l; c = CUR_SCHAR(cur, l); } } if (c != 0) return(1); return(0); } #endif /* LIBXML_TREE_ENABLED */ /************************************************************************ * * * Allocation and deallocation of basic structures * * * ************************************************************************/ /** * xmlSetBufferAllocationScheme: * @scheme: allocation method to use * * Set the buffer allocation method. Types are * XML_BUFFER_ALLOC_EXACT - use exact sizes, keeps memory usage down * XML_BUFFER_ALLOC_DOUBLEIT - double buffer when extra needed, * improves performance */ void xmlSetBufferAllocationScheme(xmlBufferAllocationScheme scheme) { xmlBufferAllocScheme = scheme; } /** * xmlGetBufferAllocationScheme: * * Types are * XML_BUFFER_ALLOC_EXACT - use exact sizes, keeps memory usage down * XML_BUFFER_ALLOC_DOUBLEIT - double buffer when extra needed, * improves performance * * Returns the current allocation scheme */ xmlBufferAllocationScheme xmlGetBufferAllocationScheme(void) { return(xmlBufferAllocScheme); } /** * xmlNewNs: * @node: the element carrying the namespace * @href: the URI associated * @prefix: the prefix for the namespace * * Creation of a new Namespace. This function will refuse to create * a namespace with a similar prefix than an existing one present on this * node. * We use href==NULL in the case of an element creation where the namespace * was not defined. * Returns a new namespace pointer or NULL */ xmlNsPtr xmlNewNs(xmlNodePtr node, const xmlChar *href, const xmlChar *prefix) { xmlNsPtr cur; if ((node != NULL) && (node->type != XML_ELEMENT_NODE)) return(NULL); if ((prefix != NULL) && (xmlStrEqual(prefix, BAD_CAST "xml"))) return(NULL); /* * Allocate a new Namespace and fill the fields. */ cur = (xmlNsPtr) xmlMalloc(sizeof(xmlNs)); if (cur == NULL) { xmlTreeErrMemory("building namespace"); return(NULL); } memset(cur, 0, sizeof(xmlNs)); cur->type = XML_LOCAL_NAMESPACE; if (href != NULL) cur->href = xmlStrdup(href); if (prefix != NULL) cur->prefix = xmlStrdup(prefix); /* * Add it at the end to preserve parsing order ... * and checks for existing use of the prefix */ if (node != NULL) { if (node->nsDef == NULL) { node->nsDef = cur; } else { xmlNsPtr prev = node->nsDef; if (((prev->prefix == NULL) && (cur->prefix == NULL)) || (xmlStrEqual(prev->prefix, cur->prefix))) { xmlFreeNs(cur); return(NULL); } while (prev->next != NULL) { prev = prev->next; if (((prev->prefix == NULL) && (cur->prefix == NULL)) || (xmlStrEqual(prev->prefix, cur->prefix))) { xmlFreeNs(cur); return(NULL); } } prev->next = cur; } } return(cur); } /** * xmlSetNs: * @node: a node in the document * @ns: a namespace pointer * * Associate a namespace to a node, a posteriori. */ void xmlSetNs(xmlNodePtr node, xmlNsPtr ns) { if (node == NULL) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlSetNs: node == NULL\n"); #endif return; } node->ns = ns; } /** * xmlFreeNs: * @cur: the namespace pointer * * Free up the structures associated to a namespace */ void xmlFreeNs(xmlNsPtr cur) { if (cur == NULL) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlFreeNs : ns == NULL\n"); #endif return; } if (cur->href != NULL) xmlFree((char *) cur->href); if (cur->prefix != NULL) xmlFree((char *) cur->prefix); xmlFree(cur); } /** * xmlFreeNsList: * @cur: the first namespace pointer * * Free up all the structures associated to the chained namespaces. */ void xmlFreeNsList(xmlNsPtr cur) { xmlNsPtr next; if (cur == NULL) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlFreeNsList : ns == NULL\n"); #endif return; } while (cur != NULL) { next = cur->next; xmlFreeNs(cur); cur = next; } } /** * xmlNewDtd: * @doc: the document pointer * @name: the DTD name * @ExternalID: the external ID * @SystemID: the system ID * * Creation of a new DTD for the external subset. To create an * internal subset, use xmlCreateIntSubset(). * * Returns a pointer to the new DTD structure */ xmlDtdPtr xmlNewDtd(xmlDocPtr doc, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID) { xmlDtdPtr cur; if ((doc != NULL) && (doc->extSubset != NULL)) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlNewDtd(%s): document %s already have a DTD %s\n", /* !!! */ (char *) name, doc->name, /* !!! */ (char *)doc->extSubset->name); #endif return(NULL); } /* * Allocate a new DTD and fill the fields. */ cur = (xmlDtdPtr) xmlMalloc(sizeof(xmlDtd)); if (cur == NULL) { xmlTreeErrMemory("building DTD"); return(NULL); } memset(cur, 0 , sizeof(xmlDtd)); cur->type = XML_DTD_NODE; if (name != NULL) cur->name = xmlStrdup(name); if (ExternalID != NULL) cur->ExternalID = xmlStrdup(ExternalID); if (SystemID != NULL) cur->SystemID = xmlStrdup(SystemID); if (doc != NULL) doc->extSubset = cur; cur->doc = doc; if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue)) xmlRegisterNodeDefaultValue((xmlNodePtr)cur); return(cur); } /** * xmlGetIntSubset: * @doc: the document pointer * * Get the internal subset of a document * Returns a pointer to the DTD structure or NULL if not found */ xmlDtdPtr xmlGetIntSubset(xmlDocPtr doc) { xmlNodePtr cur; if (doc == NULL) return(NULL); cur = doc->children; while (cur != NULL) { if (cur->type == XML_DTD_NODE) return((xmlDtdPtr) cur); cur = cur->next; } return((xmlDtdPtr) doc->intSubset); } /** * xmlCreateIntSubset: * @doc: the document pointer * @name: the DTD name * @ExternalID: the external (PUBLIC) ID * @SystemID: the system ID * * Create the internal subset of a document * Returns a pointer to the new DTD structure */ xmlDtdPtr xmlCreateIntSubset(xmlDocPtr doc, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID) { xmlDtdPtr cur; if ((doc != NULL) && (xmlGetIntSubset(doc) != NULL)) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlCreateIntSubset(): document %s already have an internal subset\n", doc->name); #endif return(NULL); } /* * Allocate a new DTD and fill the fields. */ cur = (xmlDtdPtr) xmlMalloc(sizeof(xmlDtd)); if (cur == NULL) { xmlTreeErrMemory("building internal subset"); return(NULL); } memset(cur, 0, sizeof(xmlDtd)); cur->type = XML_DTD_NODE; if (name != NULL) { cur->name = xmlStrdup(name); if (cur->name == NULL) { xmlTreeErrMemory("building internal subset"); xmlFree(cur); return(NULL); } } if (ExternalID != NULL) { cur->ExternalID = xmlStrdup(ExternalID); if (cur->ExternalID == NULL) { xmlTreeErrMemory("building internal subset"); if (cur->name != NULL) xmlFree((char *)cur->name); xmlFree(cur); return(NULL); } } if (SystemID != NULL) { cur->SystemID = xmlStrdup(SystemID); if (cur->SystemID == NULL) { xmlTreeErrMemory("building internal subset"); if (cur->name != NULL) xmlFree((char *)cur->name); if (cur->ExternalID != NULL) xmlFree((char *)cur->ExternalID); xmlFree(cur); return(NULL); } } if (doc != NULL) { doc->intSubset = cur; cur->parent = doc; cur->doc = doc; if (doc->children == NULL) { doc->children = (xmlNodePtr) cur; doc->last = (xmlNodePtr) cur; } else { if (doc->type == XML_HTML_DOCUMENT_NODE) { xmlNodePtr prev; prev = doc->children; prev->prev = (xmlNodePtr) cur; cur->next = prev; doc->children = (xmlNodePtr) cur; } else { xmlNodePtr next; next = doc->children; while ((next != NULL) && (next->type != XML_ELEMENT_NODE)) next = next->next; if (next == NULL) { cur->prev = doc->last; cur->prev->next = (xmlNodePtr) cur; cur->next = NULL; doc->last = (xmlNodePtr) cur; } else { cur->next = next; cur->prev = next->prev; if (cur->prev == NULL) doc->children = (xmlNodePtr) cur; else cur->prev->next = (xmlNodePtr) cur; next->prev = (xmlNodePtr) cur; } } } } if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue)) xmlRegisterNodeDefaultValue((xmlNodePtr)cur); return(cur); } /** * DICT_FREE: * @str: a string * * Free a string if it is not owned by the "dict" dictionnary in the * current scope */ #define DICT_FREE(str) \ if ((str) && ((!dict) || \ (xmlDictOwns(dict, (const xmlChar *)(str)) == 0))) \ xmlFree((char *)(str)); /** * DICT_COPY: * @str: a string * * Copy a string using a "dict" dictionnary in the current scope, * if availabe. */ #define DICT_COPY(str, cpy) \ if (str) { \ if (dict) { \ if (xmlDictOwns(dict, (const xmlChar *)(str))) \ cpy = (xmlChar *) (str); \ else \ cpy = (xmlChar *) xmlDictLookup((dict), (const xmlChar *)(str), -1); \ } else \ cpy = xmlStrdup((const xmlChar *)(str)); } /** * DICT_CONST_COPY: * @str: a string * * Copy a string using a "dict" dictionnary in the current scope, * if availabe. */ #define DICT_CONST_COPY(str, cpy) \ if (str) { \ if (dict) { \ if (xmlDictOwns(dict, (const xmlChar *)(str))) \ cpy = (const xmlChar *) (str); \ else \ cpy = xmlDictLookup((dict), (const xmlChar *)(str), -1); \ } else \ cpy = (const xmlChar *) xmlStrdup((const xmlChar *)(str)); } /** * xmlFreeDtd: * @cur: the DTD structure to free up * * Free a DTD structure. */ void xmlFreeDtd(xmlDtdPtr cur) { xmlDictPtr dict = NULL; if (cur == NULL) { return; } if (cur->doc != NULL) dict = cur->doc->dict; if ((__xmlRegisterCallbacks) && (xmlDeregisterNodeDefaultValue)) xmlDeregisterNodeDefaultValue((xmlNodePtr)cur); if (cur->children != NULL) { xmlNodePtr next, c = cur->children; /* * Cleanup all nodes which are not part of the specific lists * of notations, elements, attributes and entities. */ while (c != NULL) { next = c->next; if ((c->type != XML_NOTATION_NODE) && (c->type != XML_ELEMENT_DECL) && (c->type != XML_ATTRIBUTE_DECL) && (c->type != XML_ENTITY_DECL)) { xmlUnlinkNode(c); xmlFreeNode(c); } c = next; } } DICT_FREE(cur->name) DICT_FREE(cur->SystemID) DICT_FREE(cur->ExternalID) /* TODO !!! */ if (cur->notations != NULL) xmlFreeNotationTable((xmlNotationTablePtr) cur->notations); if (cur->elements != NULL) xmlFreeElementTable((xmlElementTablePtr) cur->elements); if (cur->attributes != NULL) xmlFreeAttributeTable((xmlAttributeTablePtr) cur->attributes); if (cur->entities != NULL) xmlFreeEntitiesTable((xmlEntitiesTablePtr) cur->entities); if (cur->pentities != NULL) xmlFreeEntitiesTable((xmlEntitiesTablePtr) cur->pentities); xmlFree(cur); } /** * xmlNewDoc: * @version: xmlChar string giving the version of XML "1.0" * * Creates a new XML document * * Returns a new document */ xmlDocPtr xmlNewDoc(const xmlChar *version) { xmlDocPtr cur; if (version == NULL) version = (const xmlChar *) "1.0"; /* * Allocate a new document and fill the fields. */ cur = (xmlDocPtr) xmlMalloc(sizeof(xmlDoc)); if (cur == NULL) { xmlTreeErrMemory("building doc"); return(NULL); } memset(cur, 0, sizeof(xmlDoc)); cur->type = XML_DOCUMENT_NODE; cur->version = xmlStrdup(version); if (cur->version == NULL) { xmlTreeErrMemory("building doc"); xmlFree(cur); return(NULL); } cur->standalone = -1; cur->compression = -1; /* not initialized */ cur->doc = cur; /* * The in memory encoding is always UTF8 * This field will never change and would * be obsolete if not for binary compatibility. */ cur->charset = XML_CHAR_ENCODING_UTF8; if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue)) xmlRegisterNodeDefaultValue((xmlNodePtr)cur); return(cur); } /** * xmlFreeDoc: * @cur: pointer to the document * * Free up all the structures used by a document, tree included. */ void xmlFreeDoc(xmlDocPtr cur) { xmlDtdPtr extSubset, intSubset; xmlDictPtr dict = NULL; if (cur == NULL) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlFreeDoc : document == NULL\n"); #endif return; } #ifdef LIBXML_DEBUG_RUNTIME #ifdef LIBXML_DEBUG_ENABLED xmlDebugCheckDocument(stderr, cur); #endif #endif if (cur != NULL) dict = cur->dict; if ((__xmlRegisterCallbacks) && (xmlDeregisterNodeDefaultValue)) xmlDeregisterNodeDefaultValue((xmlNodePtr)cur); /* * Do this before freeing the children list to avoid ID lookups */ if (cur->ids != NULL) xmlFreeIDTable((xmlIDTablePtr) cur->ids); cur->ids = NULL; if (cur->refs != NULL) xmlFreeRefTable((xmlRefTablePtr) cur->refs); cur->refs = NULL; extSubset = cur->extSubset; intSubset = cur->intSubset; if (intSubset == extSubset) extSubset = NULL; if (extSubset != NULL) { xmlUnlinkNode((xmlNodePtr) cur->extSubset); cur->extSubset = NULL; xmlFreeDtd(extSubset); } if (intSubset != NULL) { xmlUnlinkNode((xmlNodePtr) cur->intSubset); cur->intSubset = NULL; xmlFreeDtd(intSubset); } if (cur->children != NULL) xmlFreeNodeList(cur->children); if (cur->oldNs != NULL) xmlFreeNsList(cur->oldNs); DICT_FREE(cur->version) DICT_FREE(cur->name) DICT_FREE(cur->encoding) DICT_FREE(cur->URL) xmlFree(cur); if (dict) xmlDictFree(dict); } /** * xmlStringLenGetNodeList: * @doc: the document * @value: the value of the text * @len: the length of the string value * * Parse the value string and build the node list associated. Should * produce a flat tree with only TEXTs and ENTITY_REFs. * Returns a pointer to the first child */ xmlNodePtr xmlStringLenGetNodeList(xmlDocPtr doc, const xmlChar *value, int len) { xmlNodePtr ret = NULL, last = NULL; xmlNodePtr node; xmlChar *val; const xmlChar *cur = value, *end = cur + len; const xmlChar *q; xmlEntityPtr ent; if (value == NULL) return(NULL); q = cur; while ((cur < end) && (*cur != 0)) { if (cur[0] == '&') { int charval = 0; xmlChar tmp; /* * Save the current text. */ if (cur != q) { if ((last != NULL) && (last->type == XML_TEXT_NODE)) { xmlNodeAddContentLen(last, q, cur - q); } else { node = xmlNewDocTextLen(doc, q, cur - q); if (node == NULL) return(ret); if (last == NULL) last = ret = node; else { last->next = node; node->prev = last; last = node; } } } q = cur; if ((cur + 2 < end) && (cur[1] == '#') && (cur[2] == 'x')) { cur += 3; if (cur < end) tmp = *cur; else tmp = 0; while (tmp != ';') { /* Non input consuming loop */ if ((tmp >= '0') && (tmp <= '9')) charval = charval * 16 + (tmp - '0'); else if ((tmp >= 'a') && (tmp <= 'f')) charval = charval * 16 + (tmp - 'a') + 10; else if ((tmp >= 'A') && (tmp <= 'F')) charval = charval * 16 + (tmp - 'A') + 10; else { xmlTreeErr(XML_TREE_INVALID_HEX, (xmlNodePtr) doc, NULL); charval = 0; break; } cur++; if (cur < end) tmp = *cur; else tmp = 0; } if (tmp == ';') cur++; q = cur; } else if ((cur + 1 < end) && (cur[1] == '#')) { cur += 2; if (cur < end) tmp = *cur; else tmp = 0; while (tmp != ';') { /* Non input consuming loops */ if ((tmp >= '0') && (tmp <= '9')) charval = charval * 10 + (tmp - '0'); else { xmlTreeErr(XML_TREE_INVALID_DEC, (xmlNodePtr) doc, NULL); charval = 0; break; } cur++; if (cur < end) tmp = *cur; else tmp = 0; } if (tmp == ';') cur++; q = cur; } else { /* * Read the entity string */ cur++; q = cur; while ((cur < end) && (*cur != 0) && (*cur != ';')) cur++; if ((cur >= end) || (*cur == 0)) { xmlTreeErr(XML_TREE_UNTERMINATED_ENTITY, (xmlNodePtr) doc, (const char *) q); return(ret); } if (cur != q) { /* * Predefined entities don't generate nodes */ val = xmlStrndup(q, cur - q); ent = xmlGetDocEntity(doc, val); if ((ent != NULL) && (ent->etype == XML_INTERNAL_PREDEFINED_ENTITY)) { if (last == NULL) { node = xmlNewDocText(doc, ent->content); last = ret = node; } else if (last->type != XML_TEXT_NODE) { node = xmlNewDocText(doc, ent->content); last = xmlAddNextSibling(last, node); } else xmlNodeAddContent(last, ent->content); } else { /* * Create a new REFERENCE_REF node */ node = xmlNewReference(doc, val); if (node == NULL) { if (val != NULL) xmlFree(val); return(ret); } else if ((ent != NULL) && (ent->children == NULL)) { xmlNodePtr temp; ent->children = xmlStringGetNodeList(doc, (const xmlChar*)node->content); ent->owner = 1; temp = ent->children; while (temp) { temp->parent = (xmlNodePtr)ent; ent->last = temp; temp = temp->next; } } if (last == NULL) { last = ret = node; } else { last = xmlAddNextSibling(last, node); } } xmlFree(val); } cur++; q = cur; } if (charval != 0) { xmlChar buf[10]; int l; l = xmlCopyCharMultiByte(buf, charval); buf[l] = 0; node = xmlNewDocText(doc, buf); if (node != NULL) { if (last == NULL) { last = ret = node; } else { last = xmlAddNextSibling(last, node); } } charval = 0; } } else cur++; } if ((cur != q) || (ret == NULL)) { /* * Handle the last piece of text. */ if ((last != NULL) && (last->type == XML_TEXT_NODE)) { xmlNodeAddContentLen(last, q, cur - q); } else { node = xmlNewDocTextLen(doc, q, cur - q); if (node == NULL) return(ret); if (last == NULL) { last = ret = node; } else { last = xmlAddNextSibling(last, node); } } } return(ret); } /** * xmlStringGetNodeList: * @doc: the document * @value: the value of the attribute * * Parse the value string and build the node list associated. Should * produce a flat tree with only TEXTs and ENTITY_REFs. * Returns a pointer to the first child */ xmlNodePtr xmlStringGetNodeList(xmlDocPtr doc, const xmlChar *value) { xmlNodePtr ret = NULL, last = NULL; xmlNodePtr node; xmlChar *val; const xmlChar *cur = value; const xmlChar *q; xmlEntityPtr ent; if (value == NULL) return(NULL); q = cur; while (*cur != 0) { if (cur[0] == '&') { int charval = 0; xmlChar tmp; /* * Save the current text. */ if (cur != q) { if ((last != NULL) && (last->type == XML_TEXT_NODE)) { xmlNodeAddContentLen(last, q, cur - q); } else { node = xmlNewDocTextLen(doc, q, cur - q); if (node == NULL) return(ret); if (last == NULL) last = ret = node; else { last->next = node; node->prev = last; last = node; } } } q = cur; if ((cur[1] == '#') && (cur[2] == 'x')) { cur += 3; tmp = *cur; while (tmp != ';') { /* Non input consuming loop */ if ((tmp >= '0') && (tmp <= '9')) charval = charval * 16 + (tmp - '0'); else if ((tmp >= 'a') && (tmp <= 'f')) charval = charval * 16 + (tmp - 'a') + 10; else if ((tmp >= 'A') && (tmp <= 'F')) charval = charval * 16 + (tmp - 'A') + 10; else { xmlTreeErr(XML_TREE_INVALID_HEX, (xmlNodePtr) doc, NULL); charval = 0; break; } cur++; tmp = *cur; } if (tmp == ';') cur++; q = cur; } else if (cur[1] == '#') { cur += 2; tmp = *cur; while (tmp != ';') { /* Non input consuming loops */ if ((tmp >= '0') && (tmp <= '9')) charval = charval * 10 + (tmp - '0'); else { xmlTreeErr(XML_TREE_INVALID_DEC, (xmlNodePtr) doc, NULL); charval = 0; break; } cur++; tmp = *cur; } if (tmp == ';') cur++; q = cur; } else { /* * Read the entity string */ cur++; q = cur; while ((*cur != 0) && (*cur != ';')) cur++; if (*cur == 0) { xmlTreeErr(XML_TREE_UNTERMINATED_ENTITY, (xmlNodePtr) doc, (const char *) q); return(ret); } if (cur != q) { /* * Predefined entities don't generate nodes */ val = xmlStrndup(q, cur - q); ent = xmlGetDocEntity(doc, val); if ((ent != NULL) && (ent->etype == XML_INTERNAL_PREDEFINED_ENTITY)) { if (last == NULL) { node = xmlNewDocText(doc, ent->content); last = ret = node; } else if (last->type != XML_TEXT_NODE) { node = xmlNewDocText(doc, ent->content); last = xmlAddNextSibling(last, node); } else xmlNodeAddContent(last, ent->content); } else { /* * Create a new REFERENCE_REF node */ node = xmlNewReference(doc, val); if (node == NULL) { if (val != NULL) xmlFree(val); return(ret); } else if ((ent != NULL) && (ent->children == NULL)) { xmlNodePtr temp; ent->children = xmlStringGetNodeList(doc, (const xmlChar*)node->content); ent->owner = 1; temp = ent->children; while (temp) { temp->parent = (xmlNodePtr)ent; temp = temp->next; } } if (last == NULL) { last = ret = node; } else { last = xmlAddNextSibling(last, node); } } xmlFree(val); } cur++; q = cur; } if (charval != 0) { xmlChar buf[10]; int len; len = xmlCopyCharMultiByte(buf, charval); buf[len] = 0; node = xmlNewDocText(doc, buf); if (node != NULL) { if (last == NULL) { last = ret = node; } else { last = xmlAddNextSibling(last, node); } } charval = 0; } } else cur++; } if ((cur != q) || (ret == NULL)) { /* * Handle the last piece of text. */ if ((last != NULL) && (last->type == XML_TEXT_NODE)) { xmlNodeAddContentLen(last, q, cur - q); } else { node = xmlNewDocTextLen(doc, q, cur - q); if (node == NULL) return(ret); if (last == NULL) { last = ret = node; } else { last = xmlAddNextSibling(last, node); } } } return(ret); } /** * xmlNodeListGetString: * @doc: the document * @list: a Node list * @inLine: should we replace entity contents or show their external form * * Build the string equivalent to the text contained in the Node list * made of TEXTs and ENTITY_REFs * * Returns a pointer to the string copy, the caller must free it with xmlFree(). */ xmlChar * xmlNodeListGetString(xmlDocPtr doc, xmlNodePtr list, int inLine) { xmlNodePtr node = list; xmlChar *ret = NULL; xmlEntityPtr ent; if (list == NULL) return (NULL); while (node != NULL) { if ((node->type == XML_TEXT_NODE) || (node->type == XML_CDATA_SECTION_NODE)) { if (inLine) { ret = xmlStrcat(ret, node->content); } else { xmlChar *buffer; buffer = xmlEncodeEntitiesReentrant(doc, node->content); if (buffer != NULL) { ret = xmlStrcat(ret, buffer); xmlFree(buffer); } } } else if (node->type == XML_ENTITY_REF_NODE) { if (inLine) { ent = xmlGetDocEntity(doc, node->name); if (ent != NULL) { xmlChar *buffer; /* an entity content can be any "well balanced chunk", * i.e. the result of the content [43] production: * http://www.w3.org/TR/REC-xml#NT-content. * So it can contain text, CDATA section or nested * entity reference nodes (among others). * -> we recursive call xmlNodeListGetString() * which handles these types */ buffer = xmlNodeListGetString(doc, ent->children, 1); if (buffer != NULL) { ret = xmlStrcat(ret, buffer); xmlFree(buffer); } } else { ret = xmlStrcat(ret, node->content); } } else { xmlChar buf[2]; buf[0] = '&'; buf[1] = 0; ret = xmlStrncat(ret, buf, 1); ret = xmlStrcat(ret, node->name); buf[0] = ';'; buf[1] = 0; ret = xmlStrncat(ret, buf, 1); } } #if 0 else { xmlGenericError(xmlGenericErrorContext, "xmlGetNodeListString : invalid node type %d\n", node->type); } #endif node = node->next; } return (ret); } #ifdef LIBXML_TREE_ENABLED /** * xmlNodeListGetRawString: * @doc: the document * @list: a Node list * @inLine: should we replace entity contents or show their external form * * Builds the string equivalent to the text contained in the Node list * made of TEXTs and ENTITY_REFs, contrary to xmlNodeListGetString() * this function doesn't do any character encoding handling. * * Returns a pointer to the string copy, the caller must free it with xmlFree(). */ xmlChar * xmlNodeListGetRawString(xmlDocPtr doc, xmlNodePtr list, int inLine) { xmlNodePtr node = list; xmlChar *ret = NULL; xmlEntityPtr ent; if (list == NULL) return (NULL); while (node != NULL) { if ((node->type == XML_TEXT_NODE) || (node->type == XML_CDATA_SECTION_NODE)) { if (inLine) { ret = xmlStrcat(ret, node->content); } else { xmlChar *buffer; buffer = xmlEncodeSpecialChars(doc, node->content); if (buffer != NULL) { ret = xmlStrcat(ret, buffer); xmlFree(buffer); } } } else if (node->type == XML_ENTITY_REF_NODE) { if (inLine) { ent = xmlGetDocEntity(doc, node->name); if (ent != NULL) { xmlChar *buffer; /* an entity content can be any "well balanced chunk", * i.e. the result of the content [43] production: * http://www.w3.org/TR/REC-xml#NT-content. * So it can contain text, CDATA section or nested * entity reference nodes (among others). * -> we recursive call xmlNodeListGetRawString() * which handles these types */ buffer = xmlNodeListGetRawString(doc, ent->children, 1); if (buffer != NULL) { ret = xmlStrcat(ret, buffer); xmlFree(buffer); } } else { ret = xmlStrcat(ret, node->content); } } else { xmlChar buf[2]; buf[0] = '&'; buf[1] = 0; ret = xmlStrncat(ret, buf, 1); ret = xmlStrcat(ret, node->name); buf[0] = ';'; buf[1] = 0; ret = xmlStrncat(ret, buf, 1); } } #if 0 else { xmlGenericError(xmlGenericErrorContext, "xmlGetNodeListString : invalid node type %d\n", node->type); } #endif node = node->next; } return (ret); } #endif /* LIBXML_TREE_ENABLED */ static xmlAttrPtr xmlNewPropInternal(xmlNodePtr node, xmlNsPtr ns, const xmlChar * name, const xmlChar * value, int eatname) { xmlAttrPtr cur; xmlDocPtr doc = NULL; if ((node != NULL) && (node->type != XML_ELEMENT_NODE)) { if (eatname == 1) xmlFree((xmlChar *) name); return (NULL); } /* * Allocate a new property and fill the fields. */ cur = (xmlAttrPtr) xmlMalloc(sizeof(xmlAttr)); if (cur == NULL) { if (eatname == 1) xmlFree((xmlChar *) name); xmlTreeErrMemory("building attribute"); return (NULL); } memset(cur, 0, sizeof(xmlAttr)); cur->type = XML_ATTRIBUTE_NODE; cur->parent = node; if (node != NULL) { doc = node->doc; cur->doc = doc; } cur->ns = ns; if (eatname == 0) { if ((doc != NULL) && (doc->dict != NULL)) cur->name = (xmlChar *) xmlDictLookup(doc->dict, name, -1); else cur->name = xmlStrdup(name); } else cur->name = name; if (value != NULL) { xmlChar *buffer; xmlNodePtr tmp; buffer = xmlEncodeEntitiesReentrant(doc, value); cur->children = xmlStringGetNodeList(doc, buffer); cur->last = NULL; tmp = cur->children; while (tmp != NULL) { tmp->parent = (xmlNodePtr) cur; if (tmp->next == NULL) cur->last = tmp; tmp = tmp->next; } xmlFree(buffer); } /* * Add it at the end to preserve parsing order ... */ if (node != NULL) { if (node->properties == NULL) { node->properties = cur; } else { xmlAttrPtr prev = node->properties; while (prev->next != NULL) prev = prev->next; prev->next = cur; cur->prev = prev; } } if (xmlIsID((node == NULL) ? NULL : node->doc, node, cur) == 1) xmlAddID(NULL, node->doc, value, cur); if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue)) xmlRegisterNodeDefaultValue((xmlNodePtr) cur); return (cur); } #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_HTML_ENABLED) || \ defined(LIBXML_SCHEMAS_ENABLED) /** * xmlNewProp: * @node: the holding node * @name: the name of the attribute * @value: the value of the attribute * * Create a new property carried by a node. * Returns a pointer to the attribute */ xmlAttrPtr xmlNewProp(xmlNodePtr node, const xmlChar *name, const xmlChar *value) { if (name == NULL) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlNewProp : name == NULL\n"); #endif return(NULL); } return xmlNewPropInternal(node, NULL, name, value, 0); } #endif /* LIBXML_TREE_ENABLED */ /** * xmlNewNsProp: * @node: the holding node * @ns: the namespace * @name: the name of the attribute * @value: the value of the attribute * * Create a new property tagged with a namespace and carried by a node. * Returns a pointer to the attribute */ xmlAttrPtr xmlNewNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name, const xmlChar *value) { if (name == NULL) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlNewNsProp : name == NULL\n"); #endif return(NULL); } return xmlNewPropInternal(node, ns, name, value, 0); } /** * xmlNewNsPropEatName: * @node: the holding node * @ns: the namespace * @name: the name of the attribute * @value: the value of the attribute * * Create a new property tagged with a namespace and carried by a node. * Returns a pointer to the attribute */ xmlAttrPtr xmlNewNsPropEatName(xmlNodePtr node, xmlNsPtr ns, xmlChar *name, const xmlChar *value) { if (name == NULL) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlNewNsPropEatName : name == NULL\n"); #endif return(NULL); } return xmlNewPropInternal(node, ns, name, value, 1); } /** * xmlNewDocProp: * @doc: the document * @name: the name of the attribute * @value: the value of the attribute * * Create a new property carried by a document. * Returns a pointer to the attribute */ xmlAttrPtr xmlNewDocProp(xmlDocPtr doc, const xmlChar *name, const xmlChar *value) { xmlAttrPtr cur; if (name == NULL) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlNewDocProp : name == NULL\n"); #endif return(NULL); } /* * Allocate a new property and fill the fields. */ cur = (xmlAttrPtr) xmlMalloc(sizeof(xmlAttr)); if (cur == NULL) { xmlTreeErrMemory("building attribute"); return(NULL); } memset(cur, 0, sizeof(xmlAttr)); cur->type = XML_ATTRIBUTE_NODE; if ((doc != NULL) && (doc->dict != NULL)) cur->name = xmlDictLookup(doc->dict, name, -1); else cur->name = xmlStrdup(name); cur->doc = doc; if (value != NULL) { xmlNodePtr tmp; cur->children = xmlStringGetNodeList(doc, value); cur->last = NULL; tmp = cur->children; while (tmp != NULL) { tmp->parent = (xmlNodePtr) cur; if (tmp->next == NULL) cur->last = tmp; tmp = tmp->next; } } if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue)) xmlRegisterNodeDefaultValue((xmlNodePtr)cur); return(cur); } /** * xmlFreePropList: * @cur: the first property in the list * * Free a property and all its siblings, all the children are freed too. */ void xmlFreePropList(xmlAttrPtr cur) { xmlAttrPtr next; if (cur == NULL) return; while (cur != NULL) { next = cur->next; xmlFreeProp(cur); cur = next; } } /** * xmlFreeProp: * @cur: an attribute * * Free one attribute, all the content is freed too */ void xmlFreeProp(xmlAttrPtr cur) { xmlDictPtr dict = NULL; if (cur == NULL) return; if (cur->doc != NULL) dict = cur->doc->dict; if ((__xmlRegisterCallbacks) && (xmlDeregisterNodeDefaultValue)) xmlDeregisterNodeDefaultValue((xmlNodePtr)cur); /* Check for ID removal -> leading to invalid references ! */ if ((cur->doc != NULL) && (cur->atype == XML_ATTRIBUTE_ID)) { xmlRemoveID(cur->doc, cur); } if (cur->children != NULL) xmlFreeNodeList(cur->children); DICT_FREE(cur->name) xmlFree(cur); } /** * xmlRemoveProp: * @cur: an attribute * * Unlink and free one attribute, all the content is freed too * Note this doesn't work for namespace definition attributes * * Returns 0 if success and -1 in case of error. */ int xmlRemoveProp(xmlAttrPtr cur) { xmlAttrPtr tmp; if (cur == NULL) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlRemoveProp : cur == NULL\n"); #endif return(-1); } if (cur->parent == NULL) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlRemoveProp : cur->parent == NULL\n"); #endif return(-1); } tmp = cur->parent->properties; if (tmp == cur) { cur->parent->properties = cur->next; if (cur->next != NULL) cur->next->prev = NULL; xmlFreeProp(cur); return(0); } while (tmp != NULL) { if (tmp->next == cur) { tmp->next = cur->next; if (tmp->next != NULL) tmp->next->prev = tmp; xmlFreeProp(cur); return(0); } tmp = tmp->next; } #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlRemoveProp : attribute not owned by its node\n"); #endif return(-1); } /** * xmlNewDocPI: * @doc: the target document * @name: the processing instruction name * @content: the PI content * * Creation of a processing instruction element. * Returns a pointer to the new node object. */ xmlNodePtr xmlNewDocPI(xmlDocPtr doc, const xmlChar *name, const xmlChar *content) { xmlNodePtr cur; if (name == NULL) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlNewPI : name == NULL\n"); #endif return(NULL); } /* * Allocate a new node and fill the fields. */ cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode)); if (cur == NULL) { xmlTreeErrMemory("building PI"); return(NULL); } memset(cur, 0, sizeof(xmlNode)); cur->type = XML_PI_NODE; if ((doc != NULL) && (doc->dict != NULL)) cur->name = xmlDictLookup(doc->dict, name, -1); else cur->name = xmlStrdup(name); if (content != NULL) { cur->content = xmlStrdup(content); } cur->doc = doc; if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue)) xmlRegisterNodeDefaultValue((xmlNodePtr)cur); return(cur); } /** * xmlNewPI: * @name: the processing instruction name * @content: the PI content * * Creation of a processing instruction element. * Use xmlDocNewPI preferably to get string interning * * Returns a pointer to the new node object. */ xmlNodePtr xmlNewPI(const xmlChar *name, const xmlChar *content) { return(xmlNewDocPI(NULL, name, content)); } /** * xmlNewNode: * @ns: namespace if any * @name: the node name * * Creation of a new node element. @ns is optional (NULL). * * Returns a pointer to the new node object. Uses xmlStrdup() to make * copy of @name. */ xmlNodePtr xmlNewNode(xmlNsPtr ns, const xmlChar *name) { xmlNodePtr cur; if (name == NULL) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlNewNode : name == NULL\n"); #endif return(NULL); } /* * Allocate a new node and fill the fields. */ cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode)); if (cur == NULL) { xmlTreeErrMemory("building node"); return(NULL); } memset(cur, 0, sizeof(xmlNode)); cur->type = XML_ELEMENT_NODE; cur->name = xmlStrdup(name); cur->ns = ns; if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue)) xmlRegisterNodeDefaultValue(cur); return(cur); } /** * xmlNewNodeEatName: * @ns: namespace if any * @name: the node name * * Creation of a new node element. @ns is optional (NULL). * * Returns a pointer to the new node object, with pointer @name as * new node's name. Use xmlNewNode() if a copy of @name string is * is needed as new node's name. */ xmlNodePtr xmlNewNodeEatName(xmlNsPtr ns, xmlChar *name) { xmlNodePtr cur; if (name == NULL) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlNewNode : name == NULL\n"); #endif return(NULL); } /* * Allocate a new node and fill the fields. */ cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode)); if (cur == NULL) { xmlFree(name); xmlTreeErrMemory("building node"); return(NULL); } memset(cur, 0, sizeof(xmlNode)); cur->type = XML_ELEMENT_NODE; cur->name = name; cur->ns = ns; if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue)) xmlRegisterNodeDefaultValue((xmlNodePtr)cur); return(cur); } /** * xmlNewDocNode: * @doc: the document * @ns: namespace if any * @name: the node name * @content: the XML text content if any * * Creation of a new node element within a document. @ns and @content * are optional (NULL). * NOTE: @content is supposed to be a piece of XML CDATA, so it allow entities * references, but XML special chars need to be escaped first by using * xmlEncodeEntitiesReentrant(). Use xmlNewDocRawNode() if you don't * need entities support. * * Returns a pointer to the new node object. */ xmlNodePtr xmlNewDocNode(xmlDocPtr doc, xmlNsPtr ns, const xmlChar *name, const xmlChar *content) { xmlNodePtr cur; if ((doc != NULL) && (doc->dict != NULL)) cur = xmlNewNodeEatName(ns, (xmlChar *) xmlDictLookup(doc->dict, name, -1)); else cur = xmlNewNode(ns, name); if (cur != NULL) { cur->doc = doc; if (content != NULL) { cur->children = xmlStringGetNodeList(doc, content); UPDATE_LAST_CHILD_AND_PARENT(cur) } } return(cur); } /** * xmlNewDocNodeEatName: * @doc: the document * @ns: namespace if any * @name: the node name * @content: the XML text content if any * * Creation of a new node element within a document. @ns and @content * are optional (NULL). * NOTE: @content is supposed to be a piece of XML CDATA, so it allow entities * references, but XML special chars need to be escaped first by using * xmlEncodeEntitiesReentrant(). Use xmlNewDocRawNode() if you don't * need entities support. * * Returns a pointer to the new node object. */ xmlNodePtr xmlNewDocNodeEatName(xmlDocPtr doc, xmlNsPtr ns, xmlChar *name, const xmlChar *content) { xmlNodePtr cur; cur = xmlNewNodeEatName(ns, name); if (cur != NULL) { cur->doc = doc; if (content != NULL) { cur->children = xmlStringGetNodeList(doc, content); UPDATE_LAST_CHILD_AND_PARENT(cur) } } return(cur); } #ifdef LIBXML_TREE_ENABLED /** * xmlNewDocRawNode: * @doc: the document * @ns: namespace if any * @name: the node name * @content: the text content if any * * Creation of a new node element within a document. @ns and @content * are optional (NULL). * * Returns a pointer to the new node object. */ xmlNodePtr xmlNewDocRawNode(xmlDocPtr doc, xmlNsPtr ns, const xmlChar *name, const xmlChar *content) { xmlNodePtr cur; cur = xmlNewDocNode(doc, ns, name, NULL); if (cur != NULL) { cur->doc = doc; if (content != NULL) { cur->children = xmlNewDocText(doc, content); UPDATE_LAST_CHILD_AND_PARENT(cur) } } return(cur); } /** * xmlNewDocFragment: * @doc: the document owning the fragment * * Creation of a new Fragment node. * Returns a pointer to the new node object. */ xmlNodePtr xmlNewDocFragment(xmlDocPtr doc) { xmlNodePtr cur; /* * Allocate a new DocumentFragment node and fill the fields. */ cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode)); if (cur == NULL) { xmlTreeErrMemory("building fragment"); return(NULL); } memset(cur, 0, sizeof(xmlNode)); cur->type = XML_DOCUMENT_FRAG_NODE; cur->doc = doc; if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue)) xmlRegisterNodeDefaultValue(cur); return(cur); } #endif /* LIBXML_TREE_ENABLED */ /** * xmlNewText: * @content: the text content * * Creation of a new text node. * Returns a pointer to the new node object. */ xmlNodePtr xmlNewText(const xmlChar *content) { xmlNodePtr cur; /* * Allocate a new node and fill the fields. */ cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode)); if (cur == NULL) { xmlTreeErrMemory("building text"); return(NULL); } memset(cur, 0, sizeof(xmlNode)); cur->type = XML_TEXT_NODE; cur->name = xmlStringText; if (content != NULL) { cur->content = xmlStrdup(content); } if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue)) xmlRegisterNodeDefaultValue(cur); return(cur); } #ifdef LIBXML_TREE_ENABLED /** * xmlNewTextChild: * @parent: the parent node * @ns: a namespace if any * @name: the name of the child * @content: the text content of the child if any. * * Creation of a new child element, added at the end of @parent children list. * @ns and @content parameters are optional (NULL). If @ns is NULL, the newly * created element inherits the namespace of @parent. If @content is non NULL, * a child TEXT node will be created containing the string @content. * NOTE: Use xmlNewChild() if @content will contain entities that need to be * preserved. Use this function, xmlNewTextChild(), if you need to ensure that * reserved XML chars that might appear in @content, such as the ampersand, * greater-than or less-than signs, are automatically replaced by their XML * escaped entity representations. * * Returns a pointer to the new node object. */ xmlNodePtr xmlNewTextChild(xmlNodePtr parent, xmlNsPtr ns, const xmlChar *name, const xmlChar *content) { xmlNodePtr cur, prev; if (parent == NULL) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlNewTextChild : parent == NULL\n"); #endif return(NULL); } if (name == NULL) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlNewTextChild : name == NULL\n"); #endif return(NULL); } /* * Allocate a new node */ if (parent->type == XML_ELEMENT_NODE) { if (ns == NULL) cur = xmlNewDocRawNode(parent->doc, parent->ns, name, content); else cur = xmlNewDocRawNode(parent->doc, ns, name, content); } else if ((parent->type == XML_DOCUMENT_NODE) || (parent->type == XML_HTML_DOCUMENT_NODE)) { if (ns == NULL) cur = xmlNewDocRawNode((xmlDocPtr) parent, NULL, name, content); else cur = xmlNewDocRawNode((xmlDocPtr) parent, ns, name, content); } else if (parent->type == XML_DOCUMENT_FRAG_NODE) { cur = xmlNewDocRawNode( parent->doc, ns, name, content); } else { return(NULL); } if (cur == NULL) return(NULL); /* * add the new element at the end of the children list. */ cur->type = XML_ELEMENT_NODE; cur->parent = parent; cur->doc = parent->doc; if (parent->children == NULL) { parent->children = cur; parent->last = cur; } else { prev = parent->last; prev->next = cur; cur->prev = prev; parent->last = cur; } return(cur); } #endif /* LIBXML_TREE_ENABLED */ /** * xmlNewCharRef: * @doc: the document * @name: the char ref string, starting with # or "&# ... ;" * * Creation of a new character reference node. * Returns a pointer to the new node object. */ xmlNodePtr xmlNewCharRef(xmlDocPtr doc, const xmlChar *name) { xmlNodePtr cur; if (name == NULL) return(NULL); /* * Allocate a new node and fill the fields. */ cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode)); if (cur == NULL) { xmlTreeErrMemory("building character reference"); return(NULL); } memset(cur, 0, sizeof(xmlNode)); cur->type = XML_ENTITY_REF_NODE; cur->doc = doc; if (name[0] == '&') { int len; name++; len = xmlStrlen(name); if (name[len - 1] == ';') cur->name = xmlStrndup(name, len - 1); else cur->name = xmlStrndup(name, len); } else cur->name = xmlStrdup(name); if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue)) xmlRegisterNodeDefaultValue(cur); return(cur); } /** * xmlNewReference: * @doc: the document * @name: the reference name, or the reference string with & and ; * * Creation of a new reference node. * Returns a pointer to the new node object. */ xmlNodePtr xmlNewReference(xmlDocPtr doc, const xmlChar *name) { xmlNodePtr cur; xmlEntityPtr ent; if (name == NULL) return(NULL); /* * Allocate a new node and fill the fields. */ cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode)); if (cur == NULL) { xmlTreeErrMemory("building reference"); return(NULL); } memset(cur, 0, sizeof(xmlNode)); cur->type = XML_ENTITY_REF_NODE; cur->doc = doc; if (name[0] == '&') { int len; name++; len = xmlStrlen(name); if (name[len - 1] == ';') cur->name = xmlStrndup(name, len - 1); else cur->name = xmlStrndup(name, len); } else cur->name = xmlStrdup(name); ent = xmlGetDocEntity(doc, cur->name); if (ent != NULL) { cur->content = ent->content; /* * The parent pointer in entity is a DTD pointer and thus is NOT * updated. Not sure if this is 100% correct. * -George */ cur->children = (xmlNodePtr) ent; cur->last = (xmlNodePtr) ent; } if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue)) xmlRegisterNodeDefaultValue(cur); return(cur); } /** * xmlNewDocText: * @doc: the document * @content: the text content * * Creation of a new text node within a document. * Returns a pointer to the new node object. */ xmlNodePtr xmlNewDocText(xmlDocPtr doc, const xmlChar *content) { xmlNodePtr cur; cur = xmlNewText(content); if (cur != NULL) cur->doc = doc; return(cur); } /** * xmlNewTextLen: * @content: the text content * @len: the text len. * * Creation of a new text node with an extra parameter for the content's length * Returns a pointer to the new node object. */ xmlNodePtr xmlNewTextLen(const xmlChar *content, int len) { xmlNodePtr cur; /* * Allocate a new node and fill the fields. */ cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode)); if (cur == NULL) { xmlTreeErrMemory("building text"); return(NULL); } memset(cur, 0, sizeof(xmlNode)); cur->type = XML_TEXT_NODE; cur->name = xmlStringText; if (content != NULL) { cur->content = xmlStrndup(content, len); } if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue)) xmlRegisterNodeDefaultValue(cur); return(cur); } /** * xmlNewDocTextLen: * @doc: the document * @content: the text content * @len: the text len. * * Creation of a new text node with an extra content length parameter. The * text node pertain to a given document. * Returns a pointer to the new node object. */ xmlNodePtr xmlNewDocTextLen(xmlDocPtr doc, const xmlChar *content, int len) { xmlNodePtr cur; cur = xmlNewTextLen(content, len); if (cur != NULL) cur->doc = doc; return(cur); } /** * xmlNewComment: * @content: the comment content * * Creation of a new node containing a comment. * Returns a pointer to the new node object. */ xmlNodePtr xmlNewComment(const xmlChar *content) { xmlNodePtr cur; /* * Allocate a new node and fill the fields. */ cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode)); if (cur == NULL) { xmlTreeErrMemory("building comment"); return(NULL); } memset(cur, 0, sizeof(xmlNode)); cur->type = XML_COMMENT_NODE; cur->name = xmlStringComment; if (content != NULL) { cur->content = xmlStrdup(content); } if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue)) xmlRegisterNodeDefaultValue(cur); return(cur); } /** * xmlNewCDataBlock: * @doc: the document * @content: the CDATA block content content * @len: the length of the block * * Creation of a new node containing a CDATA block. * Returns a pointer to the new node object. */ xmlNodePtr xmlNewCDataBlock(xmlDocPtr doc, const xmlChar *content, int len) { xmlNodePtr cur; /* * Allocate a new node and fill the fields. */ cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode)); if (cur == NULL) { xmlTreeErrMemory("building CDATA"); return(NULL); } memset(cur, 0, sizeof(xmlNode)); cur->type = XML_CDATA_SECTION_NODE; cur->doc = doc; if (content != NULL) { cur->content = xmlStrndup(content, len); } if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue)) xmlRegisterNodeDefaultValue(cur); return(cur); } /** * xmlNewDocComment: * @doc: the document * @content: the comment content * * Creation of a new node containing a comment within a document. * Returns a pointer to the new node object. */ xmlNodePtr xmlNewDocComment(xmlDocPtr doc, const xmlChar *content) { xmlNodePtr cur; cur = xmlNewComment(content); if (cur != NULL) cur->doc = doc; return(cur); } /** * xmlSetTreeDoc: * @tree: the top element * @doc: the document * * update all nodes under the tree to point to the right document */ void xmlSetTreeDoc(xmlNodePtr tree, xmlDocPtr doc) { xmlAttrPtr prop; if (tree == NULL) return; if (tree->doc != doc) { if(tree->type == XML_ELEMENT_NODE) { prop = tree->properties; while (prop != NULL) { prop->doc = doc; xmlSetListDoc(prop->children, doc); prop = prop->next; } } if (tree->children != NULL) xmlSetListDoc(tree->children, doc); tree->doc = doc; } } /** * xmlSetListDoc: * @list: the first element * @doc: the document * * update all nodes in the list to point to the right document */ void xmlSetListDoc(xmlNodePtr list, xmlDocPtr doc) { xmlNodePtr cur; if (list == NULL) return; cur = list; while (cur != NULL) { if (cur->doc != doc) xmlSetTreeDoc(cur, doc); cur = cur->next; } } #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) /** * xmlNewChild: * @parent: the parent node * @ns: a namespace if any * @name: the name of the child * @content: the XML content of the child if any. * * Creation of a new child element, added at the end of @parent children list. * @ns and @content parameters are optional (NULL). If @ns is NULL, the newly * created element inherits the namespace of @parent. If @content is non NULL, * a child list containing the TEXTs and ENTITY_REFs node will be created. * NOTE: @content is supposed to be a piece of XML CDATA, so it allows entity * references. XML special chars must be escaped first by using * xmlEncodeEntitiesReentrant(), or xmlNewTextChild() should be used. * * Returns a pointer to the new node object. */ xmlNodePtr xmlNewChild(xmlNodePtr parent, xmlNsPtr ns, const xmlChar *name, const xmlChar *content) { xmlNodePtr cur, prev; if (parent == NULL) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlNewChild : parent == NULL\n"); #endif return(NULL); } if (name == NULL) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlNewChild : name == NULL\n"); #endif return(NULL); } /* * Allocate a new node */ if (parent->type == XML_ELEMENT_NODE) { if (ns == NULL) cur = xmlNewDocNode(parent->doc, parent->ns, name, content); else cur = xmlNewDocNode(parent->doc, ns, name, content); } else if ((parent->type == XML_DOCUMENT_NODE) || (parent->type == XML_HTML_DOCUMENT_NODE)) { if (ns == NULL) cur = xmlNewDocNode((xmlDocPtr) parent, NULL, name, content); else cur = xmlNewDocNode((xmlDocPtr) parent, ns, name, content); } else if (parent->type == XML_DOCUMENT_FRAG_NODE) { cur = xmlNewDocNode( parent->doc, ns, name, content); } else { return(NULL); } if (cur == NULL) return(NULL); /* * add the new element at the end of the children list. */ cur->type = XML_ELEMENT_NODE; cur->parent = parent; cur->doc = parent->doc; if (parent->children == NULL) { parent->children = cur; parent->last = cur; } else { prev = parent->last; prev->next = cur; cur->prev = prev; parent->last = cur; } return(cur); } #endif /* LIBXML_TREE_ENABLED */ /** * xmlAddPropSibling: * @prev: the attribute to which @prop is added after * @cur: the base attribute passed to calling function * @prop: the new attribute * * Add a new attribute after @prev using @cur as base attribute. * When inserting before @cur, @prev is passed as @cur->prev. * When inserting after @cur, @prev is passed as @cur. * If an existing attribute is found it is detroyed prior to adding @prop. * * Returns the attribute being inserted or NULL in case of error. */ static xmlNodePtr xmlAddPropSibling(xmlNodePtr prev, xmlNodePtr cur, xmlNodePtr prop) { xmlAttrPtr attr; if (cur->type != XML_ATTRIBUTE_NODE) return(NULL); /* check if an attribute with the same name exists */ if (prop->ns == NULL) attr = xmlHasNsProp(cur->parent, prop->name, NULL); else attr = xmlHasNsProp(cur->parent, prop->name, prop->ns->href); if (prop->doc != cur->doc) { xmlSetTreeDoc(prop, cur->doc); } prop->parent = cur->parent; prop->prev = prev; if (prev != NULL) { prop->next = prev->next; prev->next = prop; if (prop->next) prop->next->prev = prop; } else { prop->next = cur; cur->prev = prop; } if (prop->prev == NULL && prop->parent != NULL) prop->parent->properties = (xmlAttrPtr) prop; if ((attr != NULL) && (attr->type != XML_ATTRIBUTE_DECL)) { /* different instance, destroy it (attributes must be unique) */ xmlRemoveProp((xmlAttrPtr) attr); } return prop; } /** * xmlAddNextSibling: * @cur: the child node * @elem: the new node * * Add a new node @elem as the next sibling of @cur * If the new node was already inserted in a document it is * first unlinked from its existing context. * As a result of text merging @elem may be freed. * If the new node is ATTRIBUTE, it is added into properties instead of children. * If there is an attribute with equal name, it is first destroyed. * * Returns the new node or NULL in case of error. */ xmlNodePtr xmlAddNextSibling(xmlNodePtr cur, xmlNodePtr elem) { if (cur == NULL) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlAddNextSibling : cur == NULL\n"); #endif return(NULL); } if (elem == NULL) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlAddNextSibling : elem == NULL\n"); #endif return(NULL); } if (cur == elem) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlAddNextSibling : cur == elem\n"); #endif return(NULL); } xmlUnlinkNode(elem); if (elem->type == XML_TEXT_NODE) { if (cur->type == XML_TEXT_NODE) { xmlNodeAddContent(cur, elem->content); xmlFreeNode(elem); return(cur); } if ((cur->next != NULL) && (cur->next->type == XML_TEXT_NODE) && (cur->name == cur->next->name)) { xmlChar *tmp; tmp = xmlStrdup(elem->content); tmp = xmlStrcat(tmp, cur->next->content); xmlNodeSetContent(cur->next, tmp); xmlFree(tmp); xmlFreeNode(elem); return(cur->next); } } else if (elem->type == XML_ATTRIBUTE_NODE) { return xmlAddPropSibling(cur, cur, elem); } if (elem->doc != cur->doc) { xmlSetTreeDoc(elem, cur->doc); } elem->parent = cur->parent; elem->prev = cur; elem->next = cur->next; cur->next = elem; if (elem->next != NULL) elem->next->prev = elem; if ((elem->parent != NULL) && (elem->parent->last == cur)) elem->parent->last = elem; return(elem); } #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_HTML_ENABLED) || \ defined(LIBXML_SCHEMAS_ENABLED) /** * xmlAddPrevSibling: * @cur: the child node * @elem: the new node * * Add a new node @elem as the previous sibling of @cur * merging adjacent TEXT nodes (@elem may be freed) * If the new node was already inserted in a document it is * first unlinked from its existing context. * If the new node is ATTRIBUTE, it is added into properties instead of children. * If there is an attribute with equal name, it is first destroyed. * * Returns the new node or NULL in case of error. */ xmlNodePtr xmlAddPrevSibling(xmlNodePtr cur, xmlNodePtr elem) { if (cur == NULL) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlAddPrevSibling : cur == NULL\n"); #endif return(NULL); } if (elem == NULL) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlAddPrevSibling : elem == NULL\n"); #endif return(NULL); } if (cur == elem) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlAddPrevSibling : cur == elem\n"); #endif return(NULL); } xmlUnlinkNode(elem); if (elem->type == XML_TEXT_NODE) { if (cur->type == XML_TEXT_NODE) { xmlChar *tmp; tmp = xmlStrdup(elem->content); tmp = xmlStrcat(tmp, cur->content); xmlNodeSetContent(cur, tmp); xmlFree(tmp); xmlFreeNode(elem); return(cur); } if ((cur->prev != NULL) && (cur->prev->type == XML_TEXT_NODE) && (cur->name == cur->prev->name)) { xmlNodeAddContent(cur->prev, elem->content); xmlFreeNode(elem); return(cur->prev); } } else if (elem->type == XML_ATTRIBUTE_NODE) { return xmlAddPropSibling(cur->prev, cur, elem); } if (elem->doc != cur->doc) { xmlSetTreeDoc(elem, cur->doc); } elem->parent = cur->parent; elem->next = cur; elem->prev = cur->prev; cur->prev = elem; if (elem->prev != NULL) elem->prev->next = elem; if ((elem->parent != NULL) && (elem->parent->children == cur)) { elem->parent->children = elem; } return(elem); } #endif /* LIBXML_TREE_ENABLED */ /** * xmlAddSibling: * @cur: the child node * @elem: the new node * * Add a new element @elem to the list of siblings of @cur * merging adjacent TEXT nodes (@elem may be freed) * If the new element was already inserted in a document it is * first unlinked from its existing context. * * Returns the new element or NULL in case of error. */ xmlNodePtr xmlAddSibling(xmlNodePtr cur, xmlNodePtr elem) { xmlNodePtr parent; if (cur == NULL) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlAddSibling : cur == NULL\n"); #endif return(NULL); } if (elem == NULL) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlAddSibling : elem == NULL\n"); #endif return(NULL); } /* * Constant time is we can rely on the ->parent->last to find * the last sibling. */ if ((cur->type != XML_ATTRIBUTE_NODE) && (cur->parent != NULL) && (cur->parent->children != NULL) && (cur->parent->last != NULL) && (cur->parent->last->next == NULL)) { cur = cur->parent->last; } else { while (cur->next != NULL) cur = cur->next; } xmlUnlinkNode(elem); if ((cur->type == XML_TEXT_NODE) && (elem->type == XML_TEXT_NODE) && (cur->name == elem->name)) { xmlNodeAddContent(cur, elem->content); xmlFreeNode(elem); return(cur); } else if (elem->type == XML_ATTRIBUTE_NODE) { return xmlAddPropSibling(cur, cur, elem); } if (elem->doc != cur->doc) { xmlSetTreeDoc(elem, cur->doc); } parent = cur->parent; elem->prev = cur; elem->next = NULL; elem->parent = parent; cur->next = elem; if (parent != NULL) parent->last = elem; return(elem); } /** * xmlAddChildList: * @parent: the parent node * @cur: the first node in the list * * Add a list of node at the end of the child list of the parent * merging adjacent TEXT nodes (@cur may be freed) * * Returns the last child or NULL in case of error. */ xmlNodePtr xmlAddChildList(xmlNodePtr parent, xmlNodePtr cur) { xmlNodePtr prev; if (parent == NULL) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlAddChildList : parent == NULL\n"); #endif return(NULL); } if (cur == NULL) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlAddChildList : child == NULL\n"); #endif return(NULL); } if ((cur->doc != NULL) && (parent->doc != NULL) && (cur->doc != parent->doc)) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "Elements moved to a different document\n"); #endif } /* * add the first element at the end of the children list. */ if (parent->children == NULL) { parent->children = cur; } else { /* * If cur and parent->last both are TEXT nodes, then merge them. */ if ((cur->type == XML_TEXT_NODE) && (parent->last->type == XML_TEXT_NODE) && (cur->name == parent->last->name)) { xmlNodeAddContent(parent->last, cur->content); /* * if it's the only child, nothing more to be done. */ if (cur->next == NULL) { xmlFreeNode(cur); return(parent->last); } prev = cur; cur = cur->next; xmlFreeNode(prev); } prev = parent->last; prev->next = cur; cur->prev = prev; } while (cur->next != NULL) { cur->parent = parent; if (cur->doc != parent->doc) { xmlSetTreeDoc(cur, parent->doc); } cur = cur->next; } cur->parent = parent; cur->doc = parent->doc; /* the parent may not be linked to a doc ! */ parent->last = cur; return(cur); } /** * xmlAddChild: * @parent: the parent node * @cur: the child node * * Add a new node to @parent, at the end of the child (or property) list * merging adjacent TEXT nodes (in which case @cur is freed) * If the new node is ATTRIBUTE, it is added into properties instead of children. * If there is an attribute with equal name, it is first destroyed. * * Returns the child or NULL in case of error. */ xmlNodePtr xmlAddChild(xmlNodePtr parent, xmlNodePtr cur) { xmlNodePtr prev; if (parent == NULL) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlAddChild : parent == NULL\n"); #endif return(NULL); } if (cur == NULL) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlAddChild : child == NULL\n"); #endif return(NULL); } if (parent == cur) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlAddChild : parent == cur\n"); #endif return(NULL); } /* * If cur is a TEXT node, merge its content with adjacent TEXT nodes * cur is then freed. */ if (cur->type == XML_TEXT_NODE) { if ((parent->type == XML_TEXT_NODE) && (parent->content != NULL) && (parent->name == cur->name)) { xmlNodeAddContent(parent, cur->content); xmlFreeNode(cur); return(parent); } if ((parent->last != NULL) && (parent->last->type == XML_TEXT_NODE) && (parent->last->name == cur->name) && (parent->last != cur)) { xmlNodeAddContent(parent->last, cur->content); xmlFreeNode(cur); return(parent->last); } } /* * add the new element at the end of the children list. */ prev = cur->parent; cur->parent = parent; if (cur->doc != parent->doc) { xmlSetTreeDoc(cur, parent->doc); } /* this check prevents a loop on tree-traversions if a developer * tries to add a node to its parent multiple times */ if (prev == parent) return(cur); /* * Coalescing */ if ((parent->type == XML_TEXT_NODE) && (parent->content != NULL) && (parent != cur)) { xmlNodeAddContent(parent, cur->content); xmlFreeNode(cur); return(parent); } if (cur->type == XML_ATTRIBUTE_NODE) { if (parent->type != XML_ELEMENT_NODE) return(NULL); if (parent->properties == NULL) { parent->properties = (xmlAttrPtr) cur; } else { /* check if an attribute with the same name exists */ xmlAttrPtr lastattr; if (cur->ns == NULL) lastattr = xmlHasNsProp(parent, cur->name, NULL); else lastattr = xmlHasNsProp(parent, cur->name, cur->ns->href); if ((lastattr != NULL) && (lastattr != (xmlAttrPtr) cur) && (lastattr->type != XML_ATTRIBUTE_DECL)) { /* different instance, destroy it (attributes must be unique) */ xmlUnlinkNode((xmlNodePtr) lastattr); xmlFreeProp(lastattr); } if (lastattr == (xmlAttrPtr) cur) return(cur); /* find the end */ lastattr = parent->properties; while (lastattr->next != NULL) { lastattr = lastattr->next; } lastattr->next = (xmlAttrPtr) cur; ((xmlAttrPtr) cur)->prev = lastattr; } } else { if (parent->children == NULL) { parent->children = cur; parent->last = cur; } else { prev = parent->last; prev->next = cur; cur->prev = prev; parent->last = cur; } } return(cur); } /** * xmlGetLastChild: * @parent: the parent node * * Search the last child of a node. * Returns the last child or NULL if none. */ xmlNodePtr xmlGetLastChild(xmlNodePtr parent) { if (parent == NULL) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlGetLastChild : parent == NULL\n"); #endif return(NULL); } return(parent->last); } /** * xmlFreeNodeList: * @cur: the first node in the list * * Free a node and all its siblings, this is a recursive behaviour, all * the children are freed too. */ void xmlFreeNodeList(xmlNodePtr cur) { xmlNodePtr next; xmlDictPtr dict = NULL; if (cur == NULL) return; if (cur->type == XML_NAMESPACE_DECL) { xmlFreeNsList((xmlNsPtr) cur); return; } if ((cur->type == XML_DOCUMENT_NODE) || #ifdef LIBXML_DOCB_ENABLED (cur->type == XML_DOCB_DOCUMENT_NODE) || #endif (cur->type == XML_HTML_DOCUMENT_NODE)) { xmlFreeDoc((xmlDocPtr) cur); return; } if (cur->doc != NULL) dict = cur->doc->dict; while (cur != NULL) { next = cur->next; if (cur->type != XML_DTD_NODE) { if ((__xmlRegisterCallbacks) && (xmlDeregisterNodeDefaultValue)) xmlDeregisterNodeDefaultValue(cur); if ((cur->children != NULL) && (cur->type != XML_ENTITY_REF_NODE)) xmlFreeNodeList(cur->children); if (((cur->type == XML_ELEMENT_NODE) || (cur->type == XML_XINCLUDE_START) || (cur->type == XML_XINCLUDE_END)) && (cur->properties != NULL)) xmlFreePropList(cur->properties); if ((cur->type != XML_ELEMENT_NODE) && (cur->type != XML_XINCLUDE_START) && (cur->type != XML_XINCLUDE_END) && (cur->type != XML_ENTITY_REF_NODE) && (cur->content != (xmlChar *) &(cur->properties))) { DICT_FREE(cur->content) } if (((cur->type == XML_ELEMENT_NODE) || (cur->type == XML_XINCLUDE_START) || (cur->type == XML_XINCLUDE_END)) && (cur->nsDef != NULL)) xmlFreeNsList(cur->nsDef); /* * When a node is a text node or a comment, it uses a global static * variable for the name of the node. * Otherwise the node name might come from the document's * dictionnary */ if ((cur->name != NULL) && (cur->type != XML_TEXT_NODE) && (cur->type != XML_COMMENT_NODE)) DICT_FREE(cur->name) xmlFree(cur); } cur = next; } } /** * xmlFreeNode: * @cur: the node * * Free a node, this is a recursive behaviour, all the children are freed too. * This doesn't unlink the child from the list, use xmlUnlinkNode() first. */ void xmlFreeNode(xmlNodePtr cur) { xmlDictPtr dict = NULL; if (cur == NULL) return; /* use xmlFreeDtd for DTD nodes */ if (cur->type == XML_DTD_NODE) { xmlFreeDtd((xmlDtdPtr) cur); return; } if (cur->type == XML_NAMESPACE_DECL) { xmlFreeNs((xmlNsPtr) cur); return; } if (cur->type == XML_ATTRIBUTE_NODE) { xmlFreeProp((xmlAttrPtr) cur); return; } if ((__xmlRegisterCallbacks) && (xmlDeregisterNodeDefaultValue)) xmlDeregisterNodeDefaultValue(cur); if (cur->doc != NULL) dict = cur->doc->dict; if ((cur->children != NULL) && (cur->type != XML_ENTITY_REF_NODE)) xmlFreeNodeList(cur->children); if (((cur->type == XML_ELEMENT_NODE) || (cur->type == XML_XINCLUDE_START) || (cur->type == XML_XINCLUDE_END)) && (cur->properties != NULL)) xmlFreePropList(cur->properties); if ((cur->type != XML_ELEMENT_NODE) && (cur->content != NULL) && (cur->type != XML_ENTITY_REF_NODE) && (cur->type != XML_XINCLUDE_END) && (cur->type != XML_XINCLUDE_START) && (cur->content != (xmlChar *) &(cur->properties))) { DICT_FREE(cur->content) } /* * When a node is a text node or a comment, it uses a global static * variable for the name of the node. * Otherwise the node name might come from the document's dictionnary */ if ((cur->name != NULL) && (cur->type != XML_TEXT_NODE) && (cur->type != XML_COMMENT_NODE)) DICT_FREE(cur->name) if (((cur->type == XML_ELEMENT_NODE) || (cur->type == XML_XINCLUDE_START) || (cur->type == XML_XINCLUDE_END)) && (cur->nsDef != NULL)) xmlFreeNsList(cur->nsDef); xmlFree(cur); } /** * xmlUnlinkNode: * @cur: the node * * Unlink a node from it's current context, the node is not freed */ void xmlUnlinkNode(xmlNodePtr cur) { if (cur == NULL) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlUnlinkNode : node == NULL\n"); #endif return; } if (cur->type == XML_DTD_NODE) { xmlDocPtr doc; doc = cur->doc; if (doc != NULL) { if (doc->intSubset == (xmlDtdPtr) cur) doc->intSubset = NULL; if (doc->extSubset == (xmlDtdPtr) cur) doc->extSubset = NULL; } } if (cur->parent != NULL) { xmlNodePtr parent; parent = cur->parent; if (cur->type == XML_ATTRIBUTE_NODE) { if (parent->properties == (xmlAttrPtr) cur) parent->properties = ((xmlAttrPtr) cur)->next; } else { if (parent->children == cur) parent->children = cur->next; if (parent->last == cur) parent->last = cur->prev; } cur->parent = NULL; } if (cur->next != NULL) cur->next->prev = cur->prev; if (cur->prev != NULL) cur->prev->next = cur->next; cur->next = cur->prev = NULL; } #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) /** * xmlReplaceNode: * @old: the old node * @cur: the node * * Unlink the old node from its current context, prune the new one * at the same place. If @cur was already inserted in a document it is * first unlinked from its existing context. * * Returns the @old node */ xmlNodePtr xmlReplaceNode(xmlNodePtr old, xmlNodePtr cur) { if (old == cur) return(NULL); if ((old == NULL) || (old->parent == NULL)) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlReplaceNode : old == NULL or without parent\n"); #endif return(NULL); } if (cur == NULL) { xmlUnlinkNode(old); return(old); } if (cur == old) { return(old); } if ((old->type==XML_ATTRIBUTE_NODE) && (cur->type!=XML_ATTRIBUTE_NODE)) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlReplaceNode : Trying to replace attribute node with other node type\n"); #endif return(old); } if ((cur->type==XML_ATTRIBUTE_NODE) && (old->type!=XML_ATTRIBUTE_NODE)) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlReplaceNode : Trying to replace a non-attribute node with attribute node\n"); #endif return(old); } xmlUnlinkNode(cur); xmlSetTreeDoc(cur, old->doc); cur->parent = old->parent; cur->next = old->next; if (cur->next != NULL) cur->next->prev = cur; cur->prev = old->prev; if (cur->prev != NULL) cur->prev->next = cur; if (cur->parent != NULL) { if (cur->type == XML_ATTRIBUTE_NODE) { if (cur->parent->properties == (xmlAttrPtr)old) cur->parent->properties = ((xmlAttrPtr) cur); } else { if (cur->parent->children == old) cur->parent->children = cur; if (cur->parent->last == old) cur->parent->last = cur; } } old->next = old->prev = NULL; old->parent = NULL; return(old); } #endif /* LIBXML_TREE_ENABLED */ /************************************************************************ * * * Copy operations * * * ************************************************************************/ /** * xmlCopyNamespace: * @cur: the namespace * * Do a copy of the namespace. * * Returns: a new #xmlNsPtr, or NULL in case of error. */ xmlNsPtr xmlCopyNamespace(xmlNsPtr cur) { xmlNsPtr ret; if (cur == NULL) return(NULL); switch (cur->type) { case XML_LOCAL_NAMESPACE: ret = xmlNewNs(NULL, cur->href, cur->prefix); break; default: #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlCopyNamespace: invalid type %d\n", cur->type); #endif return(NULL); } return(ret); } /** * xmlCopyNamespaceList: * @cur: the first namespace * * Do a copy of an namespace list. * * Returns: a new #xmlNsPtr, or NULL in case of error. */ xmlNsPtr xmlCopyNamespaceList(xmlNsPtr cur) { xmlNsPtr ret = NULL; xmlNsPtr p = NULL,q; while (cur != NULL) { q = xmlCopyNamespace(cur); if (p == NULL) { ret = p = q; } else { p->next = q; p = q; } cur = cur->next; } return(ret); } static xmlNodePtr xmlStaticCopyNodeList(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent); static xmlAttrPtr xmlCopyPropInternal(xmlDocPtr doc, xmlNodePtr target, xmlAttrPtr cur) { xmlAttrPtr ret; if (cur == NULL) return(NULL); if (target != NULL) ret = xmlNewDocProp(target->doc, cur->name, NULL); else if (doc != NULL) ret = xmlNewDocProp(doc, cur->name, NULL); else if (cur->parent != NULL) ret = xmlNewDocProp(cur->parent->doc, cur->name, NULL); else if (cur->children != NULL) ret = xmlNewDocProp(cur->children->doc, cur->name, NULL); else ret = xmlNewDocProp(NULL, cur->name, NULL); if (ret == NULL) return(NULL); ret->parent = target; if ((cur->ns != NULL) && (target != NULL)) { xmlNsPtr ns; ns = xmlSearchNs(target->doc, target, cur->ns->prefix); if (ns == NULL) { /* * Humm, we are copying an element whose namespace is defined * out of the new tree scope. Search it in the original tree * and add it at the top of the new tree */ ns = xmlSearchNs(cur->doc, cur->parent, cur->ns->prefix); if (ns != NULL) { xmlNodePtr root = target; xmlNodePtr pred = NULL; while (root->parent != NULL) { pred = root; root = root->parent; } if (root == (xmlNodePtr) target->doc) { /* correct possibly cycling above the document elt */ root = pred; } ret->ns = xmlNewNs(root, ns->href, ns->prefix); } } else { /* * we have to find something appropriate here since * we cant be sure, that the namespce we found is identified * by the prefix */ if (xmlStrEqual(ns->href, cur->ns->href)) { /* this is the nice case */ ret->ns = ns; } else { /* * we are in trouble: we need a new reconcilied namespace. * This is expensive */ ret->ns = xmlNewReconciliedNs(target->doc, target, cur->ns); } } } else ret->ns = NULL; if (cur->children != NULL) { xmlNodePtr tmp; ret->children = xmlStaticCopyNodeList(cur->children, ret->doc, (xmlNodePtr) ret); ret->last = NULL; tmp = ret->children; while (tmp != NULL) { /* tmp->parent = (xmlNodePtr)ret; */ if (tmp->next == NULL) ret->last = tmp; tmp = tmp->next; } } /* * Try to handle IDs */ if ((target!= NULL) && (cur!= NULL) && (target->doc != NULL) && (cur->doc != NULL) && (cur->doc->ids != NULL) && (cur->parent != NULL)) { if (xmlIsID(cur->doc, cur->parent, cur)) { xmlChar *id; id = xmlNodeListGetString(cur->doc, cur->children, 1); if (id != NULL) { xmlAddID(NULL, target->doc, id, ret); xmlFree(id); } } } return(ret); } /** * xmlCopyProp: * @target: the element where the attribute will be grafted * @cur: the attribute * * Do a copy of the attribute. * * Returns: a new #xmlAttrPtr, or NULL in case of error. */ xmlAttrPtr xmlCopyProp(xmlNodePtr target, xmlAttrPtr cur) { return xmlCopyPropInternal(NULL, target, cur); } /** * xmlCopyPropList: * @target: the element where the attributes will be grafted * @cur: the first attribute * * Do a copy of an attribute list. * * Returns: a new #xmlAttrPtr, or NULL in case of error. */ xmlAttrPtr xmlCopyPropList(xmlNodePtr target, xmlAttrPtr cur) { xmlAttrPtr ret = NULL; xmlAttrPtr p = NULL,q; while (cur != NULL) { q = xmlCopyProp(target, cur); if (q == NULL) return(NULL); if (p == NULL) { ret = p = q; } else { p->next = q; q->prev = p; p = q; } cur = cur->next; } return(ret); } /* * NOTE about the CopyNode operations ! * * They are split into external and internal parts for one * tricky reason: namespaces. Doing a direct copy of a node * say RPM:Copyright without changing the namespace pointer to * something else can produce stale links. One way to do it is * to keep a reference counter but this doesn't work as soon * as one move the element or the subtree out of the scope of * the existing namespace. The actual solution seems to add * a copy of the namespace at the top of the copied tree if * not available in the subtree. * Hence two functions, the public front-end call the inner ones * The argument "recursive" normally indicates a recursive copy * of the node with values 0 (no) and 1 (yes). For XInclude, * however, we allow a value of 2 to indicate copy properties and * namespace info, but don't recurse on children. */ static xmlNodePtr xmlStaticCopyNode(const xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent, int extended) { xmlNodePtr ret; if (node == NULL) return(NULL); switch (node->type) { case XML_TEXT_NODE: case XML_CDATA_SECTION_NODE: case XML_ELEMENT_NODE: case XML_DOCUMENT_FRAG_NODE: case XML_ENTITY_REF_NODE: case XML_ENTITY_NODE: case XML_PI_NODE: case XML_COMMENT_NODE: case XML_XINCLUDE_START: case XML_XINCLUDE_END: break; case XML_ATTRIBUTE_NODE: return((xmlNodePtr) xmlCopyPropInternal(doc, parent, (xmlAttrPtr) node)); case XML_NAMESPACE_DECL: return((xmlNodePtr) xmlCopyNamespaceList((xmlNsPtr) node)); case XML_DOCUMENT_NODE: case XML_HTML_DOCUMENT_NODE: #ifdef LIBXML_DOCB_ENABLED case XML_DOCB_DOCUMENT_NODE: #endif #ifdef LIBXML_TREE_ENABLED return((xmlNodePtr) xmlCopyDoc((xmlDocPtr) node, extended)); #endif /* LIBXML_TREE_ENABLED */ case XML_DOCUMENT_TYPE_NODE: case XML_NOTATION_NODE: case XML_DTD_NODE: case XML_ELEMENT_DECL: case XML_ATTRIBUTE_DECL: case XML_ENTITY_DECL: return(NULL); } /* * Allocate a new node and fill the fields. */ ret = (xmlNodePtr) xmlMalloc(sizeof(xmlNode)); if (ret == NULL) { xmlTreeErrMemory("copying node"); return(NULL); } memset(ret, 0, sizeof(xmlNode)); ret->type = node->type; ret->doc = doc; ret->parent = parent; if (node->name == xmlStringText) ret->name = xmlStringText; else if (node->name == xmlStringTextNoenc) ret->name = xmlStringTextNoenc; else if (node->name == xmlStringComment) ret->name = xmlStringComment; else if (node->name != NULL) { if ((doc != NULL) && (doc->dict != NULL)) ret->name = xmlDictLookup(doc->dict, node->name, -1); else ret->name = xmlStrdup(node->name); } if ((node->type != XML_ELEMENT_NODE) && (node->content != NULL) && (node->type != XML_ENTITY_REF_NODE) && (node->type != XML_XINCLUDE_END) && (node->type != XML_XINCLUDE_START)) { ret->content = xmlStrdup(node->content); }else{ if (node->type == XML_ELEMENT_NODE) ret->line = node->line; } if (parent != NULL) { xmlNodePtr tmp; /* * this is a tricky part for the node register thing: * in case ret does get coalesced in xmlAddChild * the deregister-node callback is called; so we register ret now already */ if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue)) xmlRegisterNodeDefaultValue((xmlNodePtr)ret); tmp = xmlAddChild(parent, ret); /* node could have coalesced */ if (tmp != ret) return(tmp); } if (!extended) goto out; if ((node->type == XML_ELEMENT_NODE) && (node->nsDef != NULL)) ret->nsDef = xmlCopyNamespaceList(node->nsDef); if (node->ns != NULL) { xmlNsPtr ns; ns = xmlSearchNs(doc, ret, node->ns->prefix); if (ns == NULL) { /* * Humm, we are copying an element whose namespace is defined * out of the new tree scope. Search it in the original tree * and add it at the top of the new tree */ ns = xmlSearchNs(node->doc, node, node->ns->prefix); if (ns != NULL) { xmlNodePtr root = ret; while (root->parent != NULL) root = root->parent; ret->ns = xmlNewNs(root, ns->href, ns->prefix); } } else { /* * reference the existing namespace definition in our own tree. */ ret->ns = ns; } } if ((node->type == XML_ELEMENT_NODE) && (node->properties != NULL)) ret->properties = xmlCopyPropList(ret, node->properties); if (node->type == XML_ENTITY_REF_NODE) { if ((doc == NULL) || (node->doc != doc)) { /* * The copied node will go into a separate document, so * to avoid dangling references to the ENTITY_DECL node * we cannot keep the reference. Try to find it in the * target document. */ ret->children = (xmlNodePtr) xmlGetDocEntity(doc, ret->name); } else { ret->children = node->children; } ret->last = ret->children; } else if ((node->children != NULL) && (extended != 2)) { ret->children = xmlStaticCopyNodeList(node->children, doc, ret); UPDATE_LAST_CHILD_AND_PARENT(ret) } out: /* if parent != NULL we already registered the node above */ if ((parent == NULL) && ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue))) xmlRegisterNodeDefaultValue((xmlNodePtr)ret); return(ret); } static xmlNodePtr xmlStaticCopyNodeList(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent) { xmlNodePtr ret = NULL; xmlNodePtr p = NULL,q; while (node != NULL) { #ifdef LIBXML_TREE_ENABLED if (node->type == XML_DTD_NODE ) { if (doc == NULL) { node = node->next; continue; } if (doc->intSubset == NULL) { q = (xmlNodePtr) xmlCopyDtd( (xmlDtdPtr) node ); q->doc = doc; q->parent = parent; doc->intSubset = (xmlDtdPtr) q; xmlAddChild(parent, q); } else { q = (xmlNodePtr) doc->intSubset; xmlAddChild(parent, q); } } else #endif /* LIBXML_TREE_ENABLED */ q = xmlStaticCopyNode(node, doc, parent, 1); if (ret == NULL) { q->prev = NULL; ret = p = q; } else if (p != q) { /* the test is required if xmlStaticCopyNode coalesced 2 text nodes */ p->next = q; q->prev = p; p = q; } node = node->next; } return(ret); } /** * xmlCopyNode: * @node: the node * @extended: if 1 do a recursive copy (properties, namespaces and children * when applicable) * if 2 copy properties and namespaces (when applicable) * * Do a copy of the node. * * Returns: a new #xmlNodePtr, or NULL in case of error. */ xmlNodePtr xmlCopyNode(const xmlNodePtr node, int extended) { xmlNodePtr ret; ret = xmlStaticCopyNode(node, NULL, NULL, extended); return(ret); } /** * xmlDocCopyNode: * @node: the node * @doc: the document * @extended: if 1 do a recursive copy (properties, namespaces and children * when applicable) * if 2 copy properties and namespaces (when applicable) * * Do a copy of the node to a given document. * * Returns: a new #xmlNodePtr, or NULL in case of error. */ xmlNodePtr xmlDocCopyNode(const xmlNodePtr node, xmlDocPtr doc, int extended) { xmlNodePtr ret; ret = xmlStaticCopyNode(node, doc, NULL, extended); return(ret); } /** * xmlDocCopyNodeList: * @doc: the target document * @node: the first node in the list. * * Do a recursive copy of the node list. * * Returns: a new #xmlNodePtr, or NULL in case of error. */ xmlNodePtr xmlDocCopyNodeList(xmlDocPtr doc, const xmlNodePtr node) { xmlNodePtr ret = xmlStaticCopyNodeList(node, doc, NULL); return(ret); } /** * xmlCopyNodeList: * @node: the first node in the list. * * Do a recursive copy of the node list. * Use xmlDocCopyNodeList() if possible to ensure string interning. * * Returns: a new #xmlNodePtr, or NULL in case of error. */ xmlNodePtr xmlCopyNodeList(const xmlNodePtr node) { xmlNodePtr ret = xmlStaticCopyNodeList(node, NULL, NULL); return(ret); } #if defined(LIBXML_TREE_ENABLED) /** * xmlCopyDtd: * @dtd: the dtd * * Do a copy of the dtd. * * Returns: a new #xmlDtdPtr, or NULL in case of error. */ xmlDtdPtr xmlCopyDtd(xmlDtdPtr dtd) { xmlDtdPtr ret; xmlNodePtr cur, p = NULL, q; if (dtd == NULL) return(NULL); ret = xmlNewDtd(NULL, dtd->name, dtd->ExternalID, dtd->SystemID); if (ret == NULL) return(NULL); if (dtd->entities != NULL) ret->entities = (void *) xmlCopyEntitiesTable( (xmlEntitiesTablePtr) dtd->entities); if (dtd->notations != NULL) ret->notations = (void *) xmlCopyNotationTable( (xmlNotationTablePtr) dtd->notations); if (dtd->elements != NULL) ret->elements = (void *) xmlCopyElementTable( (xmlElementTablePtr) dtd->elements); if (dtd->attributes != NULL) ret->attributes = (void *) xmlCopyAttributeTable( (xmlAttributeTablePtr) dtd->attributes); if (dtd->pentities != NULL) ret->pentities = (void *) xmlCopyEntitiesTable( (xmlEntitiesTablePtr) dtd->pentities); cur = dtd->children; while (cur != NULL) { q = NULL; if (cur->type == XML_ENTITY_DECL) { xmlEntityPtr tmp = (xmlEntityPtr) cur; switch (tmp->etype) { case XML_INTERNAL_GENERAL_ENTITY: case XML_EXTERNAL_GENERAL_PARSED_ENTITY: case XML_EXTERNAL_GENERAL_UNPARSED_ENTITY: q = (xmlNodePtr) xmlGetEntityFromDtd(ret, tmp->name); break; case XML_INTERNAL_PARAMETER_ENTITY: case XML_EXTERNAL_PARAMETER_ENTITY: q = (xmlNodePtr) xmlGetParameterEntityFromDtd(ret, tmp->name); break; case XML_INTERNAL_PREDEFINED_ENTITY: break; } } else if (cur->type == XML_ELEMENT_DECL) { xmlElementPtr tmp = (xmlElementPtr) cur; q = (xmlNodePtr) xmlGetDtdQElementDesc(ret, tmp->name, tmp->prefix); } else if (cur->type == XML_ATTRIBUTE_DECL) { xmlAttributePtr tmp = (xmlAttributePtr) cur; q = (xmlNodePtr) xmlGetDtdQAttrDesc(ret, tmp->elem, tmp->name, tmp->prefix); } else if (cur->type == XML_COMMENT_NODE) { q = xmlCopyNode(cur, 0); } if (q == NULL) { cur = cur->next; continue; } if (p == NULL) ret->children = q; else p->next = q; q->prev = p; q->parent = (xmlNodePtr) ret; q->next = NULL; ret->last = q; p = q; cur = cur->next; } return(ret); } #endif #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) /** * xmlCopyDoc: * @doc: the document * @recursive: if not zero do a recursive copy. * * Do a copy of the document info. If recursive, the content tree will * be copied too as well as DTD, namespaces and entities. * * Returns: a new #xmlDocPtr, or NULL in case of error. */ xmlDocPtr xmlCopyDoc(xmlDocPtr doc, int recursive) { xmlDocPtr ret; if (doc == NULL) return(NULL); ret = xmlNewDoc(doc->version); if (ret == NULL) return(NULL); if (doc->name != NULL) ret->name = xmlMemStrdup(doc->name); if (doc->encoding != NULL) ret->encoding = xmlStrdup(doc->encoding); if (doc->URL != NULL) ret->URL = xmlStrdup(doc->URL); ret->charset = doc->charset; ret->compression = doc->compression; ret->standalone = doc->standalone; if (!recursive) return(ret); ret->last = NULL; ret->children = NULL; #ifdef LIBXML_TREE_ENABLED if (doc->intSubset != NULL) { ret->intSubset = xmlCopyDtd(doc->intSubset); xmlSetTreeDoc((xmlNodePtr)ret->intSubset, ret); ret->intSubset->parent = ret; } #endif if (doc->oldNs != NULL) ret->oldNs = xmlCopyNamespaceList(doc->oldNs); if (doc->children != NULL) { xmlNodePtr tmp; ret->children = xmlStaticCopyNodeList(doc->children, ret, (xmlNodePtr)ret); ret->last = NULL; tmp = ret->children; while (tmp != NULL) { if (tmp->next == NULL) ret->last = tmp; tmp = tmp->next; } } return(ret); } #endif /* LIBXML_TREE_ENABLED */ /************************************************************************ * * * Content access functions * * * ************************************************************************/ /** * xmlGetLineNo: * @node: valid node * * Get line number of @node. This requires activation of this option * before invoking the parser by calling xmlLineNumbersDefault(1) * * Returns the line number if successful, -1 otherwise */ long xmlGetLineNo(xmlNodePtr node) { long result = -1; if (!node) return result; if ((node->type == XML_ELEMENT_NODE) || (node->type == XML_TEXT_NODE) || (node->type == XML_COMMENT_NODE) || (node->type == XML_PI_NODE)) result = (long) node->line; else if ((node->prev != NULL) && ((node->prev->type == XML_ELEMENT_NODE) || (node->prev->type == XML_TEXT_NODE) || (node->prev->type == XML_COMMENT_NODE) || (node->prev->type == XML_PI_NODE))) result = xmlGetLineNo(node->prev); else if ((node->parent != NULL) && (node->parent->type == XML_ELEMENT_NODE)) result = xmlGetLineNo(node->parent); return result; } #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_DEBUG_ENABLED) /** * xmlGetNodePath: * @node: a node * * Build a structure based Path for the given node * * Returns the new path or NULL in case of error. The caller must free * the returned string */ xmlChar * xmlGetNodePath(xmlNodePtr node) { xmlNodePtr cur, tmp, next; xmlChar *buffer = NULL, *temp; size_t buf_len; xmlChar *buf; const char *sep; const char *name; char nametemp[100]; int occur = 0, generic; if (node == NULL) return (NULL); buf_len = 500; buffer = (xmlChar *) xmlMallocAtomic(buf_len * sizeof(xmlChar)); if (buffer == NULL) { xmlTreeErrMemory("getting node path"); return (NULL); } buf = (xmlChar *) xmlMallocAtomic(buf_len * sizeof(xmlChar)); if (buf == NULL) { xmlTreeErrMemory("getting node path"); xmlFree(buffer); return (NULL); } buffer[0] = 0; cur = node; do { name = ""; sep = "?"; occur = 0; if ((cur->type == XML_DOCUMENT_NODE) || (cur->type == XML_HTML_DOCUMENT_NODE)) { if (buffer[0] == '/') break; sep = "/"; next = NULL; } else if (cur->type == XML_ELEMENT_NODE) { generic = 0; sep = "/"; name = (const char *) cur->name; if (cur->ns) { if (cur->ns->prefix != NULL) { snprintf(nametemp, sizeof(nametemp) - 1, "%s:%s", (char *)cur->ns->prefix, (char *)cur->name); nametemp[sizeof(nametemp) - 1] = 0; name = nametemp; } else { /* * We cannot express named elements in the default * namespace, so use "*". */ generic = 1; name = "*"; } } next = cur->parent; /* * Thumbler index computation * TODO: the ocurence test seems bogus for namespaced names */ tmp = cur->prev; while (tmp != NULL) { if ((tmp->type == XML_ELEMENT_NODE) && (generic || (xmlStrEqual(cur->name, tmp->name) && ((tmp->ns == cur->ns) || ((tmp->ns != NULL) && (cur->ns != NULL) && (xmlStrEqual(cur->ns->prefix, tmp->ns->prefix))))))) occur++; tmp = tmp->prev; } if (occur == 0) { tmp = cur->next; while (tmp != NULL && occur == 0) { if ((tmp->type == XML_ELEMENT_NODE) && (generic || (xmlStrEqual(cur->name, tmp->name) && ((tmp->ns == cur->ns) || ((tmp->ns != NULL) && (cur->ns != NULL) && (xmlStrEqual(cur->ns->prefix, tmp->ns->prefix))))))) occur++; tmp = tmp->next; } if (occur != 0) occur = 1; } else occur++; } else if (cur->type == XML_COMMENT_NODE) { sep = "/"; name = "comment()"; next = cur->parent; /* * Thumbler index computation */ tmp = cur->prev; while (tmp != NULL) { if (tmp->type == XML_COMMENT_NODE) occur++; tmp = tmp->prev; } if (occur == 0) { tmp = cur->next; while (tmp != NULL && occur == 0) { if (tmp->type == XML_COMMENT_NODE) occur++; tmp = tmp->next; } if (occur != 0) occur = 1; } else occur++; } else if ((cur->type == XML_TEXT_NODE) || (cur->type == XML_CDATA_SECTION_NODE)) { sep = "/"; name = "text()"; next = cur->parent; /* * Thumbler index computation */ tmp = cur->prev; while (tmp != NULL) { if ((tmp->type == XML_TEXT_NODE) || (tmp->type == XML_CDATA_SECTION_NODE)) occur++; tmp = tmp->prev; } /* * Evaluate if this is the only text- or CDATA-section-node; * if yes, then we'll get "text()", otherwise "text()[1]". */ if (occur == 0) { tmp = cur->next; while (tmp != NULL) { if ((tmp->type == XML_TEXT_NODE) || (tmp->type == XML_CDATA_SECTION_NODE)) { occur = 1; break; } tmp = tmp->next; } } else occur++; } else if (cur->type == XML_PI_NODE) { sep = "/"; snprintf(nametemp, sizeof(nametemp) - 1, "processing-instruction('%s')", (char *)cur->name); nametemp[sizeof(nametemp) - 1] = 0; name = nametemp; next = cur->parent; /* * Thumbler index computation */ tmp = cur->prev; while (tmp != NULL) { if ((tmp->type == XML_PI_NODE) && (xmlStrEqual(cur->name, tmp->name))) occur++; tmp = tmp->prev; } if (occur == 0) { tmp = cur->next; while (tmp != NULL && occur == 0) { if ((tmp->type == XML_PI_NODE) && (xmlStrEqual(cur->name, tmp->name))) occur++; tmp = tmp->next; } if (occur != 0) occur = 1; } else occur++; } else if (cur->type == XML_ATTRIBUTE_NODE) { sep = "/@"; name = (const char *) (((xmlAttrPtr) cur)->name); if (cur->ns) { if (cur->ns->prefix != NULL) snprintf(nametemp, sizeof(nametemp) - 1, "%s:%s", (char *)cur->ns->prefix, (char *)cur->name); else snprintf(nametemp, sizeof(nametemp) - 1, "%s", (char *)cur->name); nametemp[sizeof(nametemp) - 1] = 0; name = nametemp; } next = ((xmlAttrPtr) cur)->parent; } else { next = cur->parent; } /* * Make sure there is enough room */ if (xmlStrlen(buffer) + sizeof(nametemp) + 20 > buf_len) { buf_len = 2 * buf_len + xmlStrlen(buffer) + sizeof(nametemp) + 20; temp = (xmlChar *) xmlRealloc(buffer, buf_len); if (temp == NULL) { xmlTreeErrMemory("getting node path"); xmlFree(buf); xmlFree(buffer); return (NULL); } buffer = temp; temp = (xmlChar *) xmlRealloc(buf, buf_len); if (temp == NULL) { xmlTreeErrMemory("getting node path"); xmlFree(buf); xmlFree(buffer); return (NULL); } buf = temp; } if (occur == 0) snprintf((char *) buf, buf_len, "%s%s%s", sep, name, (char *) buffer); else snprintf((char *) buf, buf_len, "%s%s[%d]%s", sep, name, occur, (char *) buffer); snprintf((char *) buffer, buf_len, "%s", (char *)buf); cur = next; } while (cur != NULL); xmlFree(buf); return (buffer); } #endif /* LIBXML_TREE_ENABLED */ /** * xmlDocGetRootElement: * @doc: the document * * Get the root element of the document (doc->children is a list * containing possibly comments, PIs, etc ...). * * Returns the #xmlNodePtr for the root or NULL */ xmlNodePtr xmlDocGetRootElement(xmlDocPtr doc) { xmlNodePtr ret; if (doc == NULL) return(NULL); ret = doc->children; while (ret != NULL) { if (ret->type == XML_ELEMENT_NODE) return(ret); ret = ret->next; } return(ret); } #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) /** * xmlDocSetRootElement: * @doc: the document * @root: the new document root element, if root is NULL no action is taken, * to remove a node from a document use xmlUnlinkNode(root) instead. * * Set the root element of the document (doc->children is a list * containing possibly comments, PIs, etc ...). * * Returns the old root element if any was found, NULL if root was NULL */ xmlNodePtr xmlDocSetRootElement(xmlDocPtr doc, xmlNodePtr root) { xmlNodePtr old = NULL; if (doc == NULL) return(NULL); if (root == NULL) return(NULL); xmlUnlinkNode(root); xmlSetTreeDoc(root, doc); root->parent = (xmlNodePtr) doc; old = doc->children; while (old != NULL) { if (old->type == XML_ELEMENT_NODE) break; old = old->next; } if (old == NULL) { if (doc->children == NULL) { doc->children = root; doc->last = root; } else { xmlAddSibling(doc->children, root); } } else { xmlReplaceNode(old, root); } return(old); } #endif #if defined(LIBXML_TREE_ENABLED) /** * xmlNodeSetLang: * @cur: the node being changed * @lang: the language description * * Set the language of a node, i.e. the values of the xml:lang * attribute. */ void xmlNodeSetLang(xmlNodePtr cur, const xmlChar *lang) { xmlNsPtr ns; if (cur == NULL) return; switch(cur->type) { case XML_TEXT_NODE: case XML_CDATA_SECTION_NODE: case XML_COMMENT_NODE: case XML_DOCUMENT_NODE: case XML_DOCUMENT_TYPE_NODE: case XML_DOCUMENT_FRAG_NODE: case XML_NOTATION_NODE: case XML_HTML_DOCUMENT_NODE: case XML_DTD_NODE: case XML_ELEMENT_DECL: case XML_ATTRIBUTE_DECL: case XML_ENTITY_DECL: case XML_PI_NODE: case XML_ENTITY_REF_NODE: case XML_ENTITY_NODE: case XML_NAMESPACE_DECL: #ifdef LIBXML_DOCB_ENABLED case XML_DOCB_DOCUMENT_NODE: #endif case XML_XINCLUDE_START: case XML_XINCLUDE_END: return; case XML_ELEMENT_NODE: case XML_ATTRIBUTE_NODE: break; } ns = xmlSearchNsByHref(cur->doc, cur, XML_XML_NAMESPACE); if (ns == NULL) return; xmlSetNsProp(cur, ns, BAD_CAST "lang", lang); } #endif /* LIBXML_TREE_ENABLED */ /** * xmlNodeGetLang: * @cur: the node being checked * * Searches the language of a node, i.e. the values of the xml:lang * attribute or the one carried by the nearest ancestor. * * Returns a pointer to the lang value, or NULL if not found * It's up to the caller to free the memory with xmlFree(). */ xmlChar * xmlNodeGetLang(xmlNodePtr cur) { xmlChar *lang; while (cur != NULL) { lang = xmlGetNsProp(cur, BAD_CAST "lang", XML_XML_NAMESPACE); if (lang != NULL) return(lang); cur = cur->parent; } return(NULL); } #ifdef LIBXML_TREE_ENABLED /** * xmlNodeSetSpacePreserve: * @cur: the node being changed * @val: the xml:space value ("0": default, 1: "preserve") * * Set (or reset) the space preserving behaviour of a node, i.e. the * value of the xml:space attribute. */ void xmlNodeSetSpacePreserve(xmlNodePtr cur, int val) { xmlNsPtr ns; if (cur == NULL) return; switch(cur->type) { case XML_TEXT_NODE: case XML_CDATA_SECTION_NODE: case XML_COMMENT_NODE: case XML_DOCUMENT_NODE: case XML_DOCUMENT_TYPE_NODE: case XML_DOCUMENT_FRAG_NODE: case XML_NOTATION_NODE: case XML_HTML_DOCUMENT_NODE: case XML_DTD_NODE: case XML_ELEMENT_DECL: case XML_ATTRIBUTE_DECL: case XML_ENTITY_DECL: case XML_PI_NODE: case XML_ENTITY_REF_NODE: case XML_ENTITY_NODE: case XML_NAMESPACE_DECL: case XML_XINCLUDE_START: case XML_XINCLUDE_END: #ifdef LIBXML_DOCB_ENABLED case XML_DOCB_DOCUMENT_NODE: #endif return; case XML_ELEMENT_NODE: case XML_ATTRIBUTE_NODE: break; } ns = xmlSearchNsByHref(cur->doc, cur, XML_XML_NAMESPACE); if (ns == NULL) return; switch (val) { case 0: xmlSetNsProp(cur, ns, BAD_CAST "space", BAD_CAST "default"); break; case 1: xmlSetNsProp(cur, ns, BAD_CAST "space", BAD_CAST "preserve"); break; } } #endif /* LIBXML_TREE_ENABLED */ /** * xmlNodeGetSpacePreserve: * @cur: the node being checked * * Searches the space preserving behaviour of a node, i.e. the values * of the xml:space attribute or the one carried by the nearest * ancestor. * * Returns -1 if xml:space is not inherited, 0 if "default", 1 if "preserve" */ int xmlNodeGetSpacePreserve(xmlNodePtr cur) { xmlChar *space; while (cur != NULL) { space = xmlGetNsProp(cur, BAD_CAST "space", XML_XML_NAMESPACE); if (space != NULL) { if (xmlStrEqual(space, BAD_CAST "preserve")) { xmlFree(space); return(1); } if (xmlStrEqual(space, BAD_CAST "default")) { xmlFree(space); return(0); } xmlFree(space); } cur = cur->parent; } return(-1); } #ifdef LIBXML_TREE_ENABLED /** * xmlNodeSetName: * @cur: the node being changed * @name: the new tag name * * Set (or reset) the name of a node. */ void xmlNodeSetName(xmlNodePtr cur, const xmlChar *name) { xmlDocPtr doc; xmlDictPtr dict; if (cur == NULL) return; if (name == NULL) return; switch(cur->type) { case XML_TEXT_NODE: case XML_CDATA_SECTION_NODE: case XML_COMMENT_NODE: case XML_DOCUMENT_TYPE_NODE: case XML_DOCUMENT_FRAG_NODE: case XML_NOTATION_NODE: case XML_HTML_DOCUMENT_NODE: case XML_NAMESPACE_DECL: case XML_XINCLUDE_START: case XML_XINCLUDE_END: #ifdef LIBXML_DOCB_ENABLED case XML_DOCB_DOCUMENT_NODE: #endif return; case XML_ELEMENT_NODE: case XML_ATTRIBUTE_NODE: case XML_PI_NODE: case XML_ENTITY_REF_NODE: case XML_ENTITY_NODE: case XML_DTD_NODE: case XML_DOCUMENT_NODE: case XML_ELEMENT_DECL: case XML_ATTRIBUTE_DECL: case XML_ENTITY_DECL: break; } doc = cur->doc; if (doc != NULL) dict = doc->dict; else dict = NULL; if (dict != NULL) { if ((cur->name != NULL) && (!xmlDictOwns(dict, cur->name))) xmlFree((xmlChar *) cur->name); cur->name = xmlDictLookup(dict, name, -1); } else { if (cur->name != NULL) xmlFree((xmlChar *) cur->name); cur->name = xmlStrdup(name); } } #endif #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) /** * xmlNodeSetBase: * @cur: the node being changed * @uri: the new base URI * * Set (or reset) the base URI of a node, i.e. the value of the * xml:base attribute. */ void xmlNodeSetBase(xmlNodePtr cur, const xmlChar* uri) { xmlNsPtr ns; const xmlChar* fixed; if (cur == NULL) return; switch(cur->type) { case XML_TEXT_NODE: case XML_CDATA_SECTION_NODE: case XML_COMMENT_NODE: case XML_DOCUMENT_TYPE_NODE: case XML_DOCUMENT_FRAG_NODE: case XML_NOTATION_NODE: case XML_DTD_NODE: case XML_ELEMENT_DECL: case XML_ATTRIBUTE_DECL: case XML_ENTITY_DECL: case XML_PI_NODE: case XML_ENTITY_REF_NODE: case XML_ENTITY_NODE: case XML_NAMESPACE_DECL: case XML_XINCLUDE_START: case XML_XINCLUDE_END: return; case XML_ELEMENT_NODE: case XML_ATTRIBUTE_NODE: break; case XML_DOCUMENT_NODE: #ifdef LIBXML_DOCB_ENABLED case XML_DOCB_DOCUMENT_NODE: #endif case XML_HTML_DOCUMENT_NODE: { xmlDocPtr doc = (xmlDocPtr) cur; if (doc->URL != NULL) xmlFree((xmlChar *) doc->URL); if (uri == NULL) doc->URL = NULL; else doc->URL = xmlPathToURI(uri); return; } } ns = xmlSearchNsByHref(cur->doc, cur, XML_XML_NAMESPACE); if (ns == NULL) return; fixed = xmlPathToURI(uri); if (fixed != NULL) { xmlSetNsProp(cur, ns, BAD_CAST "base", fixed); xmlFree((xmlChar*)fixed); } else { xmlSetNsProp(cur, ns, BAD_CAST "base", uri); } } #endif /* LIBXML_TREE_ENABLED */ /** * xmlNodeGetBase: * @doc: the document the node pertains to * @cur: the node being checked * * Searches for the BASE URL. The code should work on both XML * and HTML document even if base mechanisms are completely different. * It returns the base as defined in RFC 2396 sections * 5.1.1. Base URI within Document Content * and * 5.1.2. Base URI from the Encapsulating Entity * However it does not return the document base (5.1.3), use * xmlDocumentGetBase() for this * * Returns a pointer to the base URL, or NULL if not found * It's up to the caller to free the memory with xmlFree(). */ xmlChar * xmlNodeGetBase(xmlDocPtr doc, xmlNodePtr cur) { xmlChar *oldbase = NULL; xmlChar *base, *newbase; if ((cur == NULL) && (doc == NULL)) return(NULL); if (doc == NULL) doc = cur->doc; if ((doc != NULL) && (doc->type == XML_HTML_DOCUMENT_NODE)) { cur = doc->children; while ((cur != NULL) && (cur->name != NULL)) { if (cur->type != XML_ELEMENT_NODE) { cur = cur->next; continue; } if (!xmlStrcasecmp(cur->name, BAD_CAST "html")) { cur = cur->children; continue; } if (!xmlStrcasecmp(cur->name, BAD_CAST "head")) { cur = cur->children; continue; } if (!xmlStrcasecmp(cur->name, BAD_CAST "base")) { return(xmlGetProp(cur, BAD_CAST "href")); } cur = cur->next; } return(NULL); } while (cur != NULL) { if (cur->type == XML_ENTITY_DECL) { xmlEntityPtr ent = (xmlEntityPtr) cur; return(xmlStrdup(ent->URI)); } if (cur->type == XML_ELEMENT_NODE) { base = xmlGetNsProp(cur, BAD_CAST "base", XML_XML_NAMESPACE); if (base != NULL) { if (oldbase != NULL) { newbase = xmlBuildURI(oldbase, base); if (newbase != NULL) { xmlFree(oldbase); xmlFree(base); oldbase = newbase; } else { xmlFree(oldbase); xmlFree(base); return(NULL); } } else { oldbase = base; } if ((!xmlStrncmp(oldbase, BAD_CAST "http://", 7)) || (!xmlStrncmp(oldbase, BAD_CAST "ftp://", 6)) || (!xmlStrncmp(oldbase, BAD_CAST "urn:", 4))) return(oldbase); } } cur = cur->parent; } if ((doc != NULL) && (doc->URL != NULL)) { if (oldbase == NULL) return(xmlStrdup(doc->URL)); newbase = xmlBuildURI(oldbase, doc->URL); xmlFree(oldbase); return(newbase); } return(oldbase); } /** * xmlNodeBufGetContent: * @buffer: a buffer * @cur: the node being read * * Read the value of a node @cur, this can be either the text carried * directly by this node if it's a TEXT node or the aggregate string * of the values carried by this node child's (TEXT and ENTITY_REF). * Entity references are substituted. * Fills up the buffer @buffer with this value * * Returns 0 in case of success and -1 in case of error. */ int xmlNodeBufGetContent(xmlBufferPtr buffer, xmlNodePtr cur) { if ((cur == NULL) || (buffer == NULL)) return(-1); switch (cur->type) { case XML_CDATA_SECTION_NODE: case XML_TEXT_NODE: xmlBufferCat(buffer, cur->content); break; case XML_DOCUMENT_FRAG_NODE: case XML_ELEMENT_NODE:{ xmlNodePtr tmp = cur; while (tmp != NULL) { switch (tmp->type) { case XML_CDATA_SECTION_NODE: case XML_TEXT_NODE: if (tmp->content != NULL) xmlBufferCat(buffer, tmp->content); break; case XML_ENTITY_REF_NODE: xmlNodeBufGetContent(buffer, tmp); break; default: break; } /* * Skip to next node */ if (tmp->children != NULL) { if (tmp->children->type != XML_ENTITY_DECL) { tmp = tmp->children; continue; } } if (tmp == cur) break; if (tmp->next != NULL) { tmp = tmp->next; continue; } do { tmp = tmp->parent; if (tmp == NULL) break; if (tmp == cur) { tmp = NULL; break; } if (tmp->next != NULL) { tmp = tmp->next; break; } } while (tmp != NULL); } break; } case XML_ATTRIBUTE_NODE:{ xmlAttrPtr attr = (xmlAttrPtr) cur; xmlNodePtr tmp = attr->children; while (tmp != NULL) { if (tmp->type == XML_TEXT_NODE) xmlBufferCat(buffer, tmp->content); else xmlNodeBufGetContent(buffer, tmp); tmp = tmp->next; } break; } case XML_COMMENT_NODE: case XML_PI_NODE: xmlBufferCat(buffer, cur->content); break; case XML_ENTITY_REF_NODE:{ xmlEntityPtr ent; xmlNodePtr tmp; /* lookup entity declaration */ ent = xmlGetDocEntity(cur->doc, cur->name); if (ent == NULL) return(-1); /* an entity content can be any "well balanced chunk", * i.e. the result of the content [43] production: * http://www.w3.org/TR/REC-xml#NT-content * -> we iterate through child nodes and recursive call * xmlNodeGetContent() which handles all possible node types */ tmp = ent->children; while (tmp) { xmlNodeBufGetContent(buffer, tmp); tmp = tmp->next; } break; } case XML_ENTITY_NODE: case XML_DOCUMENT_TYPE_NODE: case XML_NOTATION_NODE: case XML_DTD_NODE: case XML_XINCLUDE_START: case XML_XINCLUDE_END: break; case XML_DOCUMENT_NODE: #ifdef LIBXML_DOCB_ENABLED case XML_DOCB_DOCUMENT_NODE: #endif case XML_HTML_DOCUMENT_NODE: cur = cur->children; while (cur!= NULL) { if ((cur->type == XML_ELEMENT_NODE) || (cur->type == XML_TEXT_NODE) || (cur->type == XML_CDATA_SECTION_NODE)) { xmlNodeBufGetContent(buffer, cur); } cur = cur->next; } break; case XML_NAMESPACE_DECL: xmlBufferCat(buffer, ((xmlNsPtr) cur)->href); break; case XML_ELEMENT_DECL: case XML_ATTRIBUTE_DECL: case XML_ENTITY_DECL: break; } return(0); } /** * xmlNodeGetContent: * @cur: the node being read * * Read the value of a node, this can be either the text carried * directly by this node if it's a TEXT node or the aggregate string * of the values carried by this node child's (TEXT and ENTITY_REF). * Entity references are substituted. * Returns a new #xmlChar * or NULL if no content is available. * It's up to the caller to free the memory with xmlFree(). */ xmlChar * xmlNodeGetContent(xmlNodePtr cur) { if (cur == NULL) return (NULL); switch (cur->type) { case XML_DOCUMENT_FRAG_NODE: case XML_ELEMENT_NODE:{ xmlBufferPtr buffer; xmlChar *ret; buffer = xmlBufferCreateSize(64); if (buffer == NULL) return (NULL); xmlNodeBufGetContent(buffer, cur); ret = buffer->content; buffer->content = NULL; xmlBufferFree(buffer); return (ret); } case XML_ATTRIBUTE_NODE: return(xmlGetPropNodeValueInternal((xmlAttrPtr) cur)); case XML_COMMENT_NODE: case XML_PI_NODE: if (cur->content != NULL) return (xmlStrdup(cur->content)); return (NULL); case XML_ENTITY_REF_NODE:{ xmlEntityPtr ent; xmlBufferPtr buffer; xmlChar *ret; /* lookup entity declaration */ ent = xmlGetDocEntity(cur->doc, cur->name); if (ent == NULL) return (NULL); buffer = xmlBufferCreate(); if (buffer == NULL) return (NULL); xmlNodeBufGetContent(buffer, cur); ret = buffer->content; buffer->content = NULL; xmlBufferFree(buffer); return (ret); } case XML_ENTITY_NODE: case XML_DOCUMENT_TYPE_NODE: case XML_NOTATION_NODE: case XML_DTD_NODE: case XML_XINCLUDE_START: case XML_XINCLUDE_END: return (NULL); case XML_DOCUMENT_NODE: #ifdef LIBXML_DOCB_ENABLED case XML_DOCB_DOCUMENT_NODE: #endif case XML_HTML_DOCUMENT_NODE: { xmlBufferPtr buffer; xmlChar *ret; buffer = xmlBufferCreate(); if (buffer == NULL) return (NULL); xmlNodeBufGetContent(buffer, (xmlNodePtr) cur); ret = buffer->content; buffer->content = NULL; xmlBufferFree(buffer); return (ret); } case XML_NAMESPACE_DECL: { xmlChar *tmp; tmp = xmlStrdup(((xmlNsPtr) cur)->href); return (tmp); } case XML_ELEMENT_DECL: /* TODO !!! */ return (NULL); case XML_ATTRIBUTE_DECL: /* TODO !!! */ return (NULL); case XML_ENTITY_DECL: /* TODO !!! */ return (NULL); case XML_CDATA_SECTION_NODE: case XML_TEXT_NODE: if (cur->content != NULL) return (xmlStrdup(cur->content)); return (NULL); } return (NULL); } /** * xmlNodeSetContent: * @cur: the node being modified * @content: the new value of the content * * Replace the content of a node. */ void xmlNodeSetContent(xmlNodePtr cur, const xmlChar *content) { if (cur == NULL) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlNodeSetContent : node == NULL\n"); #endif return; } switch (cur->type) { case XML_DOCUMENT_FRAG_NODE: case XML_ELEMENT_NODE: case XML_ATTRIBUTE_NODE: if (cur->children != NULL) xmlFreeNodeList(cur->children); cur->children = xmlStringGetNodeList(cur->doc, content); UPDATE_LAST_CHILD_AND_PARENT(cur) break; case XML_TEXT_NODE: case XML_CDATA_SECTION_NODE: case XML_ENTITY_REF_NODE: case XML_ENTITY_NODE: case XML_PI_NODE: case XML_COMMENT_NODE: if ((cur->content != NULL) && (cur->content != (xmlChar *) &(cur->properties))) { if (!((cur->doc != NULL) && (cur->doc->dict != NULL) && (xmlDictOwns(cur->doc->dict, cur->content)))) xmlFree(cur->content); } if (cur->children != NULL) xmlFreeNodeList(cur->children); cur->last = cur->children = NULL; if (content != NULL) { cur->content = xmlStrdup(content); } else cur->content = NULL; cur->properties = NULL; cur->nsDef = NULL; break; case XML_DOCUMENT_NODE: case XML_HTML_DOCUMENT_NODE: case XML_DOCUMENT_TYPE_NODE: case XML_XINCLUDE_START: case XML_XINCLUDE_END: #ifdef LIBXML_DOCB_ENABLED case XML_DOCB_DOCUMENT_NODE: #endif break; case XML_NOTATION_NODE: break; case XML_DTD_NODE: break; case XML_NAMESPACE_DECL: break; case XML_ELEMENT_DECL: /* TODO !!! */ break; case XML_ATTRIBUTE_DECL: /* TODO !!! */ break; case XML_ENTITY_DECL: /* TODO !!! */ break; } } #ifdef LIBXML_TREE_ENABLED /** * xmlNodeSetContentLen: * @cur: the node being modified * @content: the new value of the content * @len: the size of @content * * Replace the content of a node. */ void xmlNodeSetContentLen(xmlNodePtr cur, const xmlChar *content, int len) { if (cur == NULL) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlNodeSetContentLen : node == NULL\n"); #endif return; } switch (cur->type) { case XML_DOCUMENT_FRAG_NODE: case XML_ELEMENT_NODE: case XML_ATTRIBUTE_NODE: if (cur->children != NULL) xmlFreeNodeList(cur->children); cur->children = xmlStringLenGetNodeList(cur->doc, content, len); UPDATE_LAST_CHILD_AND_PARENT(cur) break; case XML_TEXT_NODE: case XML_CDATA_SECTION_NODE: case XML_ENTITY_REF_NODE: case XML_ENTITY_NODE: case XML_PI_NODE: case XML_COMMENT_NODE: case XML_NOTATION_NODE: if ((cur->content != NULL) && (cur->content != (xmlChar *) &(cur->properties))) { if (!((cur->doc != NULL) && (cur->doc->dict != NULL) && (xmlDictOwns(cur->doc->dict, cur->content)))) xmlFree(cur->content); } if (cur->children != NULL) xmlFreeNodeList(cur->children); cur->children = cur->last = NULL; if (content != NULL) { cur->content = xmlStrndup(content, len); } else cur->content = NULL; cur->properties = NULL; cur->nsDef = NULL; break; case XML_DOCUMENT_NODE: case XML_DTD_NODE: case XML_HTML_DOCUMENT_NODE: case XML_DOCUMENT_TYPE_NODE: case XML_NAMESPACE_DECL: case XML_XINCLUDE_START: case XML_XINCLUDE_END: #ifdef LIBXML_DOCB_ENABLED case XML_DOCB_DOCUMENT_NODE: #endif break; case XML_ELEMENT_DECL: /* TODO !!! */ break; case XML_ATTRIBUTE_DECL: /* TODO !!! */ break; case XML_ENTITY_DECL: /* TODO !!! */ break; } } #endif /* LIBXML_TREE_ENABLED */ /** * xmlNodeAddContentLen: * @cur: the node being modified * @content: extra content * @len: the size of @content * * Append the extra substring to the node content. */ void xmlNodeAddContentLen(xmlNodePtr cur, const xmlChar *content, int len) { if (cur == NULL) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlNodeAddContentLen : node == NULL\n"); #endif return; } if (len <= 0) return; switch (cur->type) { case XML_DOCUMENT_FRAG_NODE: case XML_ELEMENT_NODE: { xmlNodePtr last, newNode, tmp; last = cur->last; newNode = xmlNewTextLen(content, len); if (newNode != NULL) { tmp = xmlAddChild(cur, newNode); if (tmp != newNode) return; if ((last != NULL) && (last->next == newNode)) { xmlTextMerge(last, newNode); } } break; } case XML_ATTRIBUTE_NODE: break; case XML_TEXT_NODE: case XML_CDATA_SECTION_NODE: case XML_ENTITY_REF_NODE: case XML_ENTITY_NODE: case XML_PI_NODE: case XML_COMMENT_NODE: case XML_NOTATION_NODE: if (content != NULL) { if ((cur->content == (xmlChar *) &(cur->properties)) || ((cur->doc != NULL) && (cur->doc->dict != NULL) && xmlDictOwns(cur->doc->dict, cur->content))) { cur->content = xmlStrncatNew(cur->content, content, len); cur->properties = NULL; cur->nsDef = NULL; break; } cur->content = xmlStrncat(cur->content, content, len); } case XML_DOCUMENT_NODE: case XML_DTD_NODE: case XML_HTML_DOCUMENT_NODE: case XML_DOCUMENT_TYPE_NODE: case XML_NAMESPACE_DECL: case XML_XINCLUDE_START: case XML_XINCLUDE_END: #ifdef LIBXML_DOCB_ENABLED case XML_DOCB_DOCUMENT_NODE: #endif break; case XML_ELEMENT_DECL: case XML_ATTRIBUTE_DECL: case XML_ENTITY_DECL: break; } } /** * xmlNodeAddContent: * @cur: the node being modified * @content: extra content * * Append the extra substring to the node content. */ void xmlNodeAddContent(xmlNodePtr cur, const xmlChar *content) { int len; if (cur == NULL) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlNodeAddContent : node == NULL\n"); #endif return; } if (content == NULL) return; len = xmlStrlen(content); xmlNodeAddContentLen(cur, content, len); } /** * xmlTextMerge: * @first: the first text node * @second: the second text node being merged * * Merge two text nodes into one * Returns the first text node augmented */ xmlNodePtr xmlTextMerge(xmlNodePtr first, xmlNodePtr second) { if (first == NULL) return(second); if (second == NULL) return(first); if (first->type != XML_TEXT_NODE) return(first); if (second->type != XML_TEXT_NODE) return(first); if (second->name != first->name) return(first); xmlNodeAddContent(first, second->content); xmlUnlinkNode(second); xmlFreeNode(second); return(first); } #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) /** * xmlGetNsList: * @doc: the document * @node: the current node * * Search all the namespace applying to a given element. * Returns an NULL terminated array of all the #xmlNsPtr found * that need to be freed by the caller or NULL if no * namespace if defined */ xmlNsPtr * xmlGetNsList(xmlDocPtr doc ATTRIBUTE_UNUSED, xmlNodePtr node) { xmlNsPtr cur; xmlNsPtr *ret = NULL; int nbns = 0; int maxns = 10; int i; while (node != NULL) { if (node->type == XML_ELEMENT_NODE) { cur = node->nsDef; while (cur != NULL) { if (ret == NULL) { ret = (xmlNsPtr *) xmlMalloc((maxns + 1) * sizeof(xmlNsPtr)); if (ret == NULL) { xmlTreeErrMemory("getting namespace list"); return (NULL); } ret[nbns] = NULL; } for (i = 0; i < nbns; i++) { if ((cur->prefix == ret[i]->prefix) || (xmlStrEqual(cur->prefix, ret[i]->prefix))) break; } if (i >= nbns) { if (nbns >= maxns) { maxns *= 2; ret = (xmlNsPtr *) xmlRealloc(ret, (maxns + 1) * sizeof(xmlNsPtr)); if (ret == NULL) { xmlTreeErrMemory("getting namespace list"); return (NULL); } } ret[nbns++] = cur; ret[nbns] = NULL; } cur = cur->next; } } node = node->parent; } return (ret); } #endif /* LIBXML_TREE_ENABLED */ /* * xmlTreeEnsureXMLDecl: * @doc: the doc * * Ensures that there is an XML namespace declaration on the doc. * * Returns the XML ns-struct or NULL on API and internal errors. */ static xmlNsPtr xmlTreeEnsureXMLDecl(xmlDocPtr doc) { if (doc == NULL) return (NULL); if (doc->oldNs != NULL) return (doc->oldNs); { xmlNsPtr ns; ns = (xmlNsPtr) xmlMalloc(sizeof(xmlNs)); if (ns == NULL) { xmlTreeErrMemory( "allocating the XML namespace"); return (NULL); } memset(ns, 0, sizeof(xmlNs)); ns->type = XML_LOCAL_NAMESPACE; ns->href = xmlStrdup(XML_XML_NAMESPACE); ns->prefix = xmlStrdup((const xmlChar *)"xml"); doc->oldNs = ns; return (ns); } } /** * xmlSearchNs: * @doc: the document * @node: the current node * @nameSpace: the namespace prefix * * Search a Ns registered under a given name space for a document. * recurse on the parents until it finds the defined namespace * or return NULL otherwise. * @nameSpace can be NULL, this is a search for the default namespace. * We don't allow to cross entities boundaries. If you don't declare * the namespace within those you will be in troubles !!! A warning * is generated to cover this case. * * Returns the namespace pointer or NULL. */ xmlNsPtr xmlSearchNs(xmlDocPtr doc, xmlNodePtr node, const xmlChar *nameSpace) { xmlNsPtr cur; xmlNodePtr orig = node; if (node == NULL) return(NULL); if ((nameSpace != NULL) && (xmlStrEqual(nameSpace, (const xmlChar *)"xml"))) { if ((doc == NULL) && (node->type == XML_ELEMENT_NODE)) { /* * The XML-1.0 namespace is normally held on the root * element. In this case exceptionally create it on the * node element. */ cur = (xmlNsPtr) xmlMalloc(sizeof(xmlNs)); if (cur == NULL) { xmlTreeErrMemory("searching namespace"); return(NULL); } memset(cur, 0, sizeof(xmlNs)); cur->type = XML_LOCAL_NAMESPACE; cur->href = xmlStrdup(XML_XML_NAMESPACE); cur->prefix = xmlStrdup((const xmlChar *)"xml"); cur->next = node->nsDef; node->nsDef = cur; return(cur); } if (doc == NULL) { doc = node->doc; if (doc == NULL) return(NULL); } /* * Return the XML namespace declaration held by the doc. */ if (doc->oldNs == NULL) return(xmlTreeEnsureXMLDecl(doc)); else return(doc->oldNs); } while (node != NULL) { if ((node->type == XML_ENTITY_REF_NODE) || (node->type == XML_ENTITY_NODE) || (node->type == XML_ENTITY_DECL)) return(NULL); if (node->type == XML_ELEMENT_NODE) { cur = node->nsDef; while (cur != NULL) { if ((cur->prefix == NULL) && (nameSpace == NULL) && (cur->href != NULL)) return(cur); if ((cur->prefix != NULL) && (nameSpace != NULL) && (cur->href != NULL) && (xmlStrEqual(cur->prefix, nameSpace))) return(cur); cur = cur->next; } if (orig != node) { cur = node->ns; if (cur != NULL) { if ((cur->prefix == NULL) && (nameSpace == NULL) && (cur->href != NULL)) return(cur); if ((cur->prefix != NULL) && (nameSpace != NULL) && (cur->href != NULL) && (xmlStrEqual(cur->prefix, nameSpace))) return(cur); } } } node = node->parent; } return(NULL); } /** * xmlNsInScope: * @doc: the document * @node: the current node * @ancestor: the ancestor carrying the namespace * @prefix: the namespace prefix * * Verify that the given namespace held on @ancestor is still in scope * on node. * * Returns 1 if true, 0 if false and -1 in case of error. */ static int xmlNsInScope(xmlDocPtr doc ATTRIBUTE_UNUSED, xmlNodePtr node, xmlNodePtr ancestor, const xmlChar * prefix) { xmlNsPtr tst; while ((node != NULL) && (node != ancestor)) { if ((node->type == XML_ENTITY_REF_NODE) || (node->type == XML_ENTITY_NODE) || (node->type == XML_ENTITY_DECL)) return (-1); if (node->type == XML_ELEMENT_NODE) { tst = node->nsDef; while (tst != NULL) { if ((tst->prefix == NULL) && (prefix == NULL)) return (0); if ((tst->prefix != NULL) && (prefix != NULL) && (xmlStrEqual(tst->prefix, prefix))) return (0); tst = tst->next; } } node = node->parent; } if (node != ancestor) return (-1); return (1); } /** * xmlSearchNsByHref: * @doc: the document * @node: the current node * @href: the namespace value * * Search a Ns aliasing a given URI. Recurse on the parents until it finds * the defined namespace or return NULL otherwise. * Returns the namespace pointer or NULL. */ xmlNsPtr xmlSearchNsByHref(xmlDocPtr doc, xmlNodePtr node, const xmlChar * href) { xmlNsPtr cur; xmlNodePtr orig = node; int is_attr; if ((node == NULL) || (href == NULL)) return (NULL); if (xmlStrEqual(href, XML_XML_NAMESPACE)) { /* * Only the document can hold the XML spec namespace. */ if ((doc == NULL) && (node->type == XML_ELEMENT_NODE)) { /* * The XML-1.0 namespace is normally held on the root * element. In this case exceptionally create it on the * node element. */ cur = (xmlNsPtr) xmlMalloc(sizeof(xmlNs)); if (cur == NULL) { xmlTreeErrMemory("searching namespace"); return (NULL); } memset(cur, 0, sizeof(xmlNs)); cur->type = XML_LOCAL_NAMESPACE; cur->href = xmlStrdup(XML_XML_NAMESPACE); cur->prefix = xmlStrdup((const xmlChar *) "xml"); cur->next = node->nsDef; node->nsDef = cur; return (cur); } if (doc == NULL) { doc = node->doc; if (doc == NULL) return(NULL); } /* * Return the XML namespace declaration held by the doc. */ if (doc->oldNs == NULL) return(xmlTreeEnsureXMLDecl(doc)); else return(doc->oldNs); } is_attr = (node->type == XML_ATTRIBUTE_NODE); while (node != NULL) { if ((node->type == XML_ENTITY_REF_NODE) || (node->type == XML_ENTITY_NODE) || (node->type == XML_ENTITY_DECL)) return (NULL); if (node->type == XML_ELEMENT_NODE) { cur = node->nsDef; while (cur != NULL) { if ((cur->href != NULL) && (href != NULL) && (xmlStrEqual(cur->href, href))) { if (((!is_attr) || (cur->prefix != NULL)) && (xmlNsInScope(doc, orig, node, cur->prefix) == 1)) return (cur); } cur = cur->next; } if (orig != node) { cur = node->ns; if (cur != NULL) { if ((cur->href != NULL) && (href != NULL) && (xmlStrEqual(cur->href, href))) { if (((!is_attr) || (cur->prefix != NULL)) && (xmlNsInScope(doc, orig, node, cur->prefix) == 1)) return (cur); } } } } node = node->parent; } return (NULL); } /** * xmlNewReconciliedNs: * @doc: the document * @tree: a node expected to hold the new namespace * @ns: the original namespace * * This function tries to locate a namespace definition in a tree * ancestors, or create a new namespace definition node similar to * @ns trying to reuse the same prefix. However if the given prefix is * null (default namespace) or reused within the subtree defined by * @tree or on one of its ancestors then a new prefix is generated. * Returns the (new) namespace definition or NULL in case of error */ xmlNsPtr xmlNewReconciliedNs(xmlDocPtr doc, xmlNodePtr tree, xmlNsPtr ns) { xmlNsPtr def; xmlChar prefix[50]; int counter = 1; if (tree == NULL) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlNewReconciliedNs : tree == NULL\n"); #endif return(NULL); } if ((ns == NULL) || (ns->type != XML_NAMESPACE_DECL)) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlNewReconciliedNs : ns == NULL\n"); #endif return(NULL); } /* * Search an existing namespace definition inherited. */ def = xmlSearchNsByHref(doc, tree, ns->href); if (def != NULL) return(def); /* * Find a close prefix which is not already in use. * Let's strip namespace prefixes longer than 20 chars ! */ if (ns->prefix == NULL) snprintf((char *) prefix, sizeof(prefix), "default"); else snprintf((char *) prefix, sizeof(prefix), "%.20s", (char *)ns->prefix); def = xmlSearchNs(doc, tree, prefix); while (def != NULL) { if (counter > 1000) return(NULL); if (ns->prefix == NULL) snprintf((char *) prefix, sizeof(prefix), "default%d", counter++); else snprintf((char *) prefix, sizeof(prefix), "%.20s%d", (char *)ns->prefix, counter++); def = xmlSearchNs(doc, tree, prefix); } /* * OK, now we are ready to create a new one. */ def = xmlNewNs(tree, ns->href, prefix); return(def); } #ifdef LIBXML_TREE_ENABLED /** * xmlReconciliateNs: * @doc: the document * @tree: a node defining the subtree to reconciliate * * This function checks that all the namespaces declared within the given * tree are properly declared. This is needed for example after Copy or Cut * and then paste operations. The subtree may still hold pointers to * namespace declarations outside the subtree or invalid/masked. As much * as possible the function try to reuse the existing namespaces found in * the new environment. If not possible the new namespaces are redeclared * on @tree at the top of the given subtree. * Returns the number of namespace declarations created or -1 in case of error. */ int xmlReconciliateNs(xmlDocPtr doc, xmlNodePtr tree) { xmlNsPtr *oldNs = NULL; xmlNsPtr *newNs = NULL; int sizeCache = 0; int nbCache = 0; xmlNsPtr n; xmlNodePtr node = tree; xmlAttrPtr attr; int ret = 0, i; if ((node == NULL) || (node->type != XML_ELEMENT_NODE)) return(-1); if ((doc == NULL) || (doc->type != XML_DOCUMENT_NODE)) return(-1); if (node->doc != doc) return(-1); while (node != NULL) { /* * Reconciliate the node namespace */ if (node->ns != NULL) { /* * initialize the cache if needed */ if (sizeCache == 0) { sizeCache = 10; oldNs = (xmlNsPtr *) xmlMalloc(sizeCache * sizeof(xmlNsPtr)); if (oldNs == NULL) { xmlTreeErrMemory("fixing namespaces"); return(-1); } newNs = (xmlNsPtr *) xmlMalloc(sizeCache * sizeof(xmlNsPtr)); if (newNs == NULL) { xmlTreeErrMemory("fixing namespaces"); xmlFree(oldNs); return(-1); } } for (i = 0;i < nbCache;i++) { if (oldNs[i] == node->ns) { node->ns = newNs[i]; break; } } if (i == nbCache) { /* * OK we need to recreate a new namespace definition */ n = xmlNewReconciliedNs(doc, tree, node->ns); if (n != NULL) { /* :-( what if else ??? */ /* * check if we need to grow the cache buffers. */ if (sizeCache <= nbCache) { sizeCache *= 2; oldNs = (xmlNsPtr *) xmlRealloc(oldNs, sizeCache * sizeof(xmlNsPtr)); if (oldNs == NULL) { xmlTreeErrMemory("fixing namespaces"); xmlFree(newNs); return(-1); } newNs = (xmlNsPtr *) xmlRealloc(newNs, sizeCache * sizeof(xmlNsPtr)); if (newNs == NULL) { xmlTreeErrMemory("fixing namespaces"); xmlFree(oldNs); return(-1); } } newNs[nbCache] = n; oldNs[nbCache++] = node->ns; node->ns = n; } } } /* * now check for namespace hold by attributes on the node. */ if (node->type == XML_ELEMENT_NODE) { attr = node->properties; while (attr != NULL) { if (attr->ns != NULL) { /* * initialize the cache if needed */ if (sizeCache == 0) { sizeCache = 10; oldNs = (xmlNsPtr *) xmlMalloc(sizeCache * sizeof(xmlNsPtr)); if (oldNs == NULL) { xmlTreeErrMemory("fixing namespaces"); return(-1); } newNs = (xmlNsPtr *) xmlMalloc(sizeCache * sizeof(xmlNsPtr)); if (newNs == NULL) { xmlTreeErrMemory("fixing namespaces"); xmlFree(oldNs); return(-1); } } for (i = 0;i < nbCache;i++) { if (oldNs[i] == attr->ns) { attr->ns = newNs[i]; break; } } if (i == nbCache) { /* * OK we need to recreate a new namespace definition */ n = xmlNewReconciliedNs(doc, tree, attr->ns); if (n != NULL) { /* :-( what if else ??? */ /* * check if we need to grow the cache buffers. */ if (sizeCache <= nbCache) { sizeCache *= 2; oldNs = (xmlNsPtr *) xmlRealloc(oldNs, sizeCache * sizeof(xmlNsPtr)); if (oldNs == NULL) { xmlTreeErrMemory("fixing namespaces"); xmlFree(newNs); return(-1); } newNs = (xmlNsPtr *) xmlRealloc(newNs, sizeCache * sizeof(xmlNsPtr)); if (newNs == NULL) { xmlTreeErrMemory("fixing namespaces"); xmlFree(oldNs); return(-1); } } newNs[nbCache] = n; oldNs[nbCache++] = attr->ns; attr->ns = n; } } } attr = attr->next; } } /* * Browse the full subtree, deep first */ if ((node->children != NULL) && (node->type != XML_ENTITY_REF_NODE)) { /* deep first */ node = node->children; } else if ((node != tree) && (node->next != NULL)) { /* then siblings */ node = node->next; } else if (node != tree) { /* go up to parents->next if needed */ while (node != tree) { if (node->parent != NULL) node = node->parent; if ((node != tree) && (node->next != NULL)) { node = node->next; break; } if (node->parent == NULL) { node = NULL; break; } } /* exit condition */ if (node == tree) node = NULL; } else break; } if (oldNs != NULL) xmlFree(oldNs); if (newNs != NULL) xmlFree(newNs); return(ret); } #endif /* LIBXML_TREE_ENABLED */ static xmlAttrPtr xmlGetPropNodeInternal(xmlNodePtr node, const xmlChar *name, const xmlChar *nsName, int useDTD) { xmlAttrPtr prop; if ((node == NULL) || (node->type != XML_ELEMENT_NODE) || (name == NULL)) return(NULL); if (node->properties != NULL) { prop = node->properties; if (nsName == NULL) { /* * We want the attr to be in no namespace. */ do { if ((prop->ns == NULL) && xmlStrEqual(prop->name, name)) { return(prop); } prop = prop->next; } while (prop != NULL); } else { /* * We want the attr to be in the specified namespace. */ do { if ((prop->ns != NULL) && xmlStrEqual(prop->name, name) && ((prop->ns->href == nsName) || xmlStrEqual(prop->ns->href, nsName))) { return(prop); } prop = prop->next; } while (prop != NULL); } } #ifdef LIBXML_TREE_ENABLED if (! useDTD) return(NULL); /* * Check if there is a default/fixed attribute declaration in * the internal or external subset. */ if ((node->doc != NULL) && (node->doc->intSubset != NULL)) { xmlDocPtr doc = node->doc; xmlAttributePtr attrDecl = NULL; xmlChar *elemQName, *tmpstr = NULL; /* * We need the QName of the element for the DTD-lookup. */ if ((node->ns != NULL) && (node->ns->prefix != NULL)) { tmpstr = xmlStrdup(node->ns->prefix); tmpstr = xmlStrcat(tmpstr, BAD_CAST ":"); tmpstr = xmlStrcat(tmpstr, node->name); if (tmpstr == NULL) return(NULL); elemQName = tmpstr; } else elemQName = (xmlChar *) node->name; if (nsName == NULL) { /* * The common and nice case: Attr in no namespace. */ attrDecl = xmlGetDtdQAttrDesc(doc->intSubset, elemQName, name, NULL); if ((attrDecl == NULL) && (doc->extSubset != NULL)) { attrDecl = xmlGetDtdQAttrDesc(doc->extSubset, elemQName, name, NULL); } } else { xmlNsPtr *nsList, *cur; /* * The ugly case: Search using the prefixes of in-scope * ns-decls corresponding to @nsName. */ nsList = xmlGetNsList(node->doc, node); if (nsList == NULL) { if (tmpstr != NULL) xmlFree(tmpstr); return(NULL); } cur = nsList; while (*cur != NULL) { if (xmlStrEqual((*cur)->href, nsName)) { attrDecl = xmlGetDtdQAttrDesc(doc->intSubset, elemQName, name, (*cur)->prefix); if (attrDecl) break; if (doc->extSubset != NULL) { attrDecl = xmlGetDtdQAttrDesc(doc->extSubset, elemQName, name, (*cur)->prefix); if (attrDecl) break; } } cur++; } xmlFree(nsList); } if (tmpstr != NULL) xmlFree(tmpstr); /* * Only default/fixed attrs are relevant. */ if ((attrDecl != NULL) && (attrDecl->defaultValue != NULL)) return((xmlAttrPtr) attrDecl); } #endif /* LIBXML_TREE_ENABLED */ return(NULL); } static xmlChar* xmlGetPropNodeValueInternal(xmlAttrPtr prop) { if (prop == NULL) return(NULL); if (prop->type == XML_ATTRIBUTE_NODE) { /* * Note that we return at least the empty string. * TODO: Do we really always want that? */ if (prop->children != NULL) { if ((prop->children->next == NULL) && ((prop->children->type == XML_TEXT_NODE) || (prop->children->type == XML_CDATA_SECTION_NODE))) { /* * Optimization for the common case: only 1 text node. */ return(xmlStrdup(prop->children->content)); } else { xmlChar *ret; ret = xmlNodeListGetString(prop->doc, prop->children, 1); if (ret != NULL) return(ret); } } return(xmlStrdup((xmlChar *)"")); } else if (prop->type == XML_ATTRIBUTE_DECL) { return(xmlStrdup(((xmlAttributePtr)prop)->defaultValue)); } return(NULL); } /** * xmlHasProp: * @node: the node * @name: the attribute name * * Search an attribute associated to a node * This function also looks in DTD attribute declaration for #FIXED or * default declaration values unless DTD use has been turned off. * * Returns the attribute or the attribute declaration or NULL if * neither was found. */ xmlAttrPtr xmlHasProp(xmlNodePtr node, const xmlChar *name) { xmlAttrPtr prop; xmlDocPtr doc; if ((node == NULL) || (node->type != XML_ELEMENT_NODE) || (name == NULL)) return(NULL); /* * Check on the properties attached to the node */ prop = node->properties; while (prop != NULL) { if (xmlStrEqual(prop->name, name)) { return(prop); } prop = prop->next; } if (!xmlCheckDTD) return(NULL); /* * Check if there is a default declaration in the internal * or external subsets */ doc = node->doc; if (doc != NULL) { xmlAttributePtr attrDecl; if (doc->intSubset != NULL) { attrDecl = xmlGetDtdAttrDesc(doc->intSubset, node->name, name); if ((attrDecl == NULL) && (doc->extSubset != NULL)) attrDecl = xmlGetDtdAttrDesc(doc->extSubset, node->name, name); if ((attrDecl != NULL) && (attrDecl->defaultValue != NULL)) /* return attribute declaration only if a default value is given (that includes #FIXED declarations) */ return((xmlAttrPtr) attrDecl); } } return(NULL); } /** * xmlHasNsProp: * @node: the node * @name: the attribute name * @nameSpace: the URI of the namespace * * Search for an attribute associated to a node * This attribute has to be anchored in the namespace specified. * This does the entity substitution. * This function looks in DTD attribute declaration for #FIXED or * default declaration values unless DTD use has been turned off. * Note that a namespace of NULL indicates to use the default namespace. * * Returns the attribute or the attribute declaration or NULL * if neither was found. */ xmlAttrPtr xmlHasNsProp(xmlNodePtr node, const xmlChar *name, const xmlChar *nameSpace) { return(xmlGetPropNodeInternal(node, name, nameSpace, xmlCheckDTD)); } /** * xmlGetProp: * @node: the node * @name: the attribute name * * Search and get the value of an attribute associated to a node * This does the entity substitution. * This function looks in DTD attribute declaration for #FIXED or * default declaration values unless DTD use has been turned off. * NOTE: this function acts independently of namespaces associated * to the attribute. Use xmlGetNsProp() or xmlGetNoNsProp() * for namespace aware processing. * * Returns the attribute value or NULL if not found. * It's up to the caller to free the memory with xmlFree(). */ xmlChar * xmlGetProp(xmlNodePtr node, const xmlChar *name) { xmlAttrPtr prop; prop = xmlHasProp(node, name); if (prop == NULL) return(NULL); return(xmlGetPropNodeValueInternal(prop)); } /** * xmlGetNoNsProp: * @node: the node * @name: the attribute name * * Search and get the value of an attribute associated to a node * This does the entity substitution. * This function looks in DTD attribute declaration for #FIXED or * default declaration values unless DTD use has been turned off. * This function is similar to xmlGetProp except it will accept only * an attribute in no namespace. * * Returns the attribute value or NULL if not found. * It's up to the caller to free the memory with xmlFree(). */ xmlChar * xmlGetNoNsProp(xmlNodePtr node, const xmlChar *name) { xmlAttrPtr prop; prop = xmlGetPropNodeInternal(node, name, NULL, xmlCheckDTD); if (prop == NULL) return(NULL); return(xmlGetPropNodeValueInternal(prop)); } /** * xmlGetNsProp: * @node: the node * @name: the attribute name * @nameSpace: the URI of the namespace * * Search and get the value of an attribute associated to a node * This attribute has to be anchored in the namespace specified. * This does the entity substitution. * This function looks in DTD attribute declaration for #FIXED or * default declaration values unless DTD use has been turned off. * * Returns the attribute value or NULL if not found. * It's up to the caller to free the memory with xmlFree(). */ xmlChar * xmlGetNsProp(xmlNodePtr node, const xmlChar *name, const xmlChar *nameSpace) { xmlAttrPtr prop; prop = xmlGetPropNodeInternal(node, name, nameSpace, xmlCheckDTD); if (prop == NULL) return(NULL); return(xmlGetPropNodeValueInternal(prop)); } #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) /** * xmlUnsetProp: * @node: the node * @name: the attribute name * * Remove an attribute carried by a node. * This handles only attributes in no namespace. * Returns 0 if successful, -1 if not found */ int xmlUnsetProp(xmlNodePtr node, const xmlChar *name) { xmlAttrPtr prop; prop = xmlGetPropNodeInternal(node, name, NULL, 0); if (prop == NULL) return(-1); xmlUnlinkNode((xmlNodePtr) prop); xmlFreeProp(prop); return(0); } /** * xmlUnsetNsProp: * @node: the node * @ns: the namespace definition * @name: the attribute name * * Remove an attribute carried by a node. * Returns 0 if successful, -1 if not found */ int xmlUnsetNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name) { xmlAttrPtr prop; prop = xmlGetPropNodeInternal(node, name, (ns != NULL) ? ns->href : NULL, 0); if (prop == NULL) return(-1); xmlUnlinkNode((xmlNodePtr) prop); xmlFreeProp(prop); return(0); } #endif #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_HTML_ENABLED) /** * xmlSetProp: * @node: the node * @name: the attribute name (a QName) * @value: the attribute value * * Set (or reset) an attribute carried by a node. * If @name has a prefix, then the corresponding * namespace-binding will be used, if in scope; it is an * error it there's no such ns-binding for the prefix in * scope. * Returns the attribute pointer. * */ xmlAttrPtr xmlSetProp(xmlNodePtr node, const xmlChar *name, const xmlChar *value) { int len; const xmlChar *nqname; if ((node == NULL) || (name == NULL) || (node->type != XML_ELEMENT_NODE)) return(NULL); /* * handle QNames */ nqname = xmlSplitQName3(name, &len); if (nqname != NULL) { xmlNsPtr ns; xmlChar *prefix = xmlStrndup(name, len); ns = xmlSearchNs(node->doc, node, prefix); if (prefix != NULL) xmlFree(prefix); if (ns != NULL) return(xmlSetNsProp(node, ns, nqname, value)); } return(xmlSetNsProp(node, NULL, name, value)); } /** * xmlSetNsProp: * @node: the node * @ns: the namespace definition * @name: the attribute name * @value: the attribute value * * Set (or reset) an attribute carried by a node. * The ns structure must be in scope, this is not checked * * Returns the attribute pointer. */ xmlAttrPtr xmlSetNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name, const xmlChar *value) { xmlAttrPtr prop; if (ns && (ns->href == NULL)) return(NULL); prop = xmlGetPropNodeInternal(node, name, (ns != NULL) ? ns->href : NULL, 0); if (prop != NULL) { /* * Modify the attribute's value. */ if (prop->atype == XML_ATTRIBUTE_ID) { xmlRemoveID(node->doc, prop); prop->atype = XML_ATTRIBUTE_ID; } if (prop->children != NULL) xmlFreeNodeList(prop->children); prop->children = NULL; prop->last = NULL; prop->ns = ns; if (value != NULL) { xmlChar *buffer; xmlNodePtr tmp; buffer = xmlEncodeEntitiesReentrant(node->doc, value); prop->children = xmlStringGetNodeList(node->doc, buffer); prop->last = NULL; tmp = prop->children; while (tmp != NULL) { tmp->parent = (xmlNodePtr) prop; if (tmp->next == NULL) prop->last = tmp; tmp = tmp->next; } xmlFree(buffer); } if (prop->atype == XML_ATTRIBUTE_ID) xmlAddID(NULL, node->doc, value, prop); return(prop); } /* * No equal attr found; create a new one. */ return(xmlNewPropInternal(node, ns, name, value, 0)); } #endif /* LIBXML_TREE_ENABLED */ /** * xmlNodeIsText: * @node: the node * * Is this node a Text node ? * Returns 1 yes, 0 no */ int xmlNodeIsText(xmlNodePtr node) { if (node == NULL) return(0); if (node->type == XML_TEXT_NODE) return(1); return(0); } /** * xmlIsBlankNode: * @node: the node * * Checks whether this node is an empty or whitespace only * (and possibly ignorable) text-node. * * Returns 1 yes, 0 no */ int xmlIsBlankNode(xmlNodePtr node) { const xmlChar *cur; if (node == NULL) return(0); if ((node->type != XML_TEXT_NODE) && (node->type != XML_CDATA_SECTION_NODE)) return(0); if (node->content == NULL) return(1); cur = node->content; while (*cur != 0) { if (!IS_BLANK_CH(*cur)) return(0); cur++; } return(1); } /** * xmlTextConcat: * @node: the node * @content: the content * @len: @content length * * Concat the given string at the end of the existing node content * * Returns -1 in case of error, 0 otherwise */ int xmlTextConcat(xmlNodePtr node, const xmlChar *content, int len) { if (node == NULL) return(-1); if ((node->type != XML_TEXT_NODE) && (node->type != XML_CDATA_SECTION_NODE) && (node->type != XML_COMMENT_NODE) && (node->type != XML_PI_NODE)) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlTextConcat: node is not text nor CDATA\n"); #endif return(-1); } /* need to check if content is currently in the dictionary */ if ((node->content == (xmlChar *) &(node->properties)) || ((node->doc != NULL) && (node->doc->dict != NULL) && xmlDictOwns(node->doc->dict, node->content))) { node->content = xmlStrncatNew(node->content, content, len); } else { node->content = xmlStrncat(node->content, content, len); } node->properties = NULL; if (node->content == NULL) return(-1); return(0); } /************************************************************************ * * * Output : to a FILE or in memory * * * ************************************************************************/ /** * xmlBufferCreate: * * routine to create an XML buffer. * returns the new structure. */ xmlBufferPtr xmlBufferCreate(void) { xmlBufferPtr ret; ret = (xmlBufferPtr) xmlMalloc(sizeof(xmlBuffer)); if (ret == NULL) { xmlTreeErrMemory("creating buffer"); return(NULL); } ret->use = 0; ret->size = xmlDefaultBufferSize; ret->alloc = xmlBufferAllocScheme; ret->content = (xmlChar *) xmlMallocAtomic(ret->size * sizeof(xmlChar)); if (ret->content == NULL) { xmlTreeErrMemory("creating buffer"); xmlFree(ret); return(NULL); } ret->content[0] = 0; return(ret); } /** * xmlBufferCreateSize: * @size: initial size of buffer * * routine to create an XML buffer. * returns the new structure. */ xmlBufferPtr xmlBufferCreateSize(size_t size) { xmlBufferPtr ret; ret = (xmlBufferPtr) xmlMalloc(sizeof(xmlBuffer)); if (ret == NULL) { xmlTreeErrMemory("creating buffer"); return(NULL); } ret->use = 0; ret->alloc = xmlBufferAllocScheme; ret->size = (size ? size+2 : 0); /* +1 for ending null */ if (ret->size){ ret->content = (xmlChar *) xmlMallocAtomic(ret->size * sizeof(xmlChar)); if (ret->content == NULL) { xmlTreeErrMemory("creating buffer"); xmlFree(ret); return(NULL); } ret->content[0] = 0; } else ret->content = NULL; return(ret); } /** * xmlBufferCreateStatic: * @mem: the memory area * @size: the size in byte * * routine to create an XML buffer from an immutable memory area. * The area won't be modified nor copied, and is expected to be * present until the end of the buffer lifetime. * * returns the new structure. */ xmlBufferPtr xmlBufferCreateStatic(void *mem, size_t size) { xmlBufferPtr ret; if ((mem == NULL) || (size == 0)) return(NULL); ret = (xmlBufferPtr) xmlMalloc(sizeof(xmlBuffer)); if (ret == NULL) { xmlTreeErrMemory("creating buffer"); return(NULL); } ret->use = size; ret->size = size; ret->alloc = XML_BUFFER_ALLOC_IMMUTABLE; ret->content = (xmlChar *) mem; return(ret); } /** * xmlBufferSetAllocationScheme: * @buf: the buffer to tune * @scheme: allocation scheme to use * * Sets the allocation scheme for this buffer */ void xmlBufferSetAllocationScheme(xmlBufferPtr buf, xmlBufferAllocationScheme scheme) { if (buf == NULL) { #ifdef DEBUG_BUFFER xmlGenericError(xmlGenericErrorContext, "xmlBufferSetAllocationScheme: buf == NULL\n"); #endif return; } if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return; buf->alloc = scheme; } /** * xmlBufferFree: * @buf: the buffer to free * * Frees an XML buffer. It frees both the content and the structure which * encapsulate it. */ void xmlBufferFree(xmlBufferPtr buf) { if (buf == NULL) { #ifdef DEBUG_BUFFER xmlGenericError(xmlGenericErrorContext, "xmlBufferFree: buf == NULL\n"); #endif return; } if ((buf->content != NULL) && (buf->alloc != XML_BUFFER_ALLOC_IMMUTABLE)) { xmlFree(buf->content); } xmlFree(buf); } /** * xmlBufferEmpty: * @buf: the buffer * * empty a buffer. */ void xmlBufferEmpty(xmlBufferPtr buf) { if (buf == NULL) return; if (buf->content == NULL) return; buf->use = 0; if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) { buf->content = BAD_CAST ""; } else { memset(buf->content, 0, buf->size); } } /** * xmlBufferShrink: * @buf: the buffer to dump * @len: the number of xmlChar to remove * * Remove the beginning of an XML buffer. * * Returns the number of #xmlChar removed, or -1 in case of failure. */ int xmlBufferShrink(xmlBufferPtr buf, unsigned int len) { if (buf == NULL) return(-1); if (len == 0) return(0); if (len > buf->use) return(-1); buf->use -= len; if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) { buf->content += len; } else { memmove(buf->content, &buf->content[len], buf->use * sizeof(xmlChar)); buf->content[buf->use] = 0; } return(len); } /** * xmlBufferGrow: * @buf: the buffer * @len: the minimum free size to allocate * * Grow the available space of an XML buffer. * * Returns the new available space or -1 in case of error */ int xmlBufferGrow(xmlBufferPtr buf, unsigned int len) { int size; xmlChar *newbuf; if (buf == NULL) return(-1); if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return(0); if (len + buf->use < buf->size) return(0); /* * Windows has a BIG problem on realloc timing, so we try to double * the buffer size (if that's enough) (bug 146697) */ #ifdef WIN32 if (buf->size > len) size = buf->size * 2; else size = buf->use + len + 100; #else size = buf->use + len + 100; #endif newbuf = (xmlChar *) xmlRealloc(buf->content, size); if (newbuf == NULL) { xmlTreeErrMemory("growing buffer"); return(-1); } buf->content = newbuf; buf->size = size; return(buf->size - buf->use); } /** * xmlBufferDump: * @file: the file output * @buf: the buffer to dump * * Dumps an XML buffer to a FILE *. * Returns the number of #xmlChar written */ int xmlBufferDump(FILE *file, xmlBufferPtr buf) { int ret; if (buf == NULL) { #ifdef DEBUG_BUFFER xmlGenericError(xmlGenericErrorContext, "xmlBufferDump: buf == NULL\n"); #endif return(0); } if (buf->content == NULL) { #ifdef DEBUG_BUFFER xmlGenericError(xmlGenericErrorContext, "xmlBufferDump: buf->content == NULL\n"); #endif return(0); } if (file == NULL) file = stdout; ret = fwrite(buf->content, sizeof(xmlChar), buf->use, file); return(ret); } /** * xmlBufferContent: * @buf: the buffer * * Function to extract the content of a buffer * * Returns the internal content */ const xmlChar * xmlBufferContent(const xmlBufferPtr buf) { if(!buf) return NULL; return buf->content; } /** * xmlBufferLength: * @buf: the buffer * * Function to get the length of a buffer * * Returns the length of data in the internal content */ int xmlBufferLength(const xmlBufferPtr buf) { if(!buf) return 0; return buf->use; } /** * xmlBufferResize: * @buf: the buffer to resize * @size: the desired size * * Resize a buffer to accommodate minimum size of @size. * * Returns 0 in case of problems, 1 otherwise */ int xmlBufferResize(xmlBufferPtr buf, unsigned int size) { unsigned int newSize; xmlChar* rebuf = NULL; if (buf == NULL) return(0); if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return(0); /* Don't resize if we don't have to */ if (size < buf->size) return 1; /* figure out new size */ switch (buf->alloc){ case XML_BUFFER_ALLOC_DOUBLEIT: /*take care of empty case*/ newSize = (buf->size ? buf->size*2 : size + 10); while (size > newSize) newSize *= 2; break; case XML_BUFFER_ALLOC_EXACT: newSize = size+10; break; default: newSize = size+10; break; } if (buf->content == NULL) rebuf = (xmlChar *) xmlMallocAtomic(newSize * sizeof(xmlChar)); else if (buf->size - buf->use < 100) { rebuf = (xmlChar *) xmlRealloc(buf->content, newSize * sizeof(xmlChar)); } else { /* * if we are reallocating a buffer far from being full, it's * better to make a new allocation and copy only the used range * and free the old one. */ rebuf = (xmlChar *) xmlMallocAtomic(newSize * sizeof(xmlChar)); if (rebuf != NULL) { memcpy(rebuf, buf->content, buf->use); xmlFree(buf->content); rebuf[buf->use] = 0; } } if (rebuf == NULL) { xmlTreeErrMemory("growing buffer"); return 0; } buf->content = rebuf; buf->size = newSize; return 1; } /** * xmlBufferAdd: * @buf: the buffer to dump * @str: the #xmlChar string * @len: the number of #xmlChar to add * * Add a string range to an XML buffer. if len == -1, the length of * str is recomputed. * * Returns 0 successful, a positive error code number otherwise * and -1 in case of internal or API error. */ int xmlBufferAdd(xmlBufferPtr buf, const xmlChar *str, int len) { unsigned int needSize; if ((str == NULL) || (buf == NULL)) { return -1; } if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return -1; if (len < -1) { #ifdef DEBUG_BUFFER xmlGenericError(xmlGenericErrorContext, "xmlBufferAdd: len < 0\n"); #endif return -1; } if (len == 0) return 0; if (len < 0) len = xmlStrlen(str); if (len <= 0) return -1; needSize = buf->use + len + 2; if (needSize > buf->size){ if (!xmlBufferResize(buf, needSize)){ xmlTreeErrMemory("growing buffer"); return XML_ERR_NO_MEMORY; } } memmove(&buf->content[buf->use], str, len*sizeof(xmlChar)); buf->use += len; buf->content[buf->use] = 0; return 0; } /** * xmlBufferAddHead: * @buf: the buffer * @str: the #xmlChar string * @len: the number of #xmlChar to add * * Add a string range to the beginning of an XML buffer. * if len == -1, the length of @str is recomputed. * * Returns 0 successful, a positive error code number otherwise * and -1 in case of internal or API error. */ int xmlBufferAddHead(xmlBufferPtr buf, const xmlChar *str, int len) { unsigned int needSize; if (buf == NULL) return(-1); if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return -1; if (str == NULL) { #ifdef DEBUG_BUFFER xmlGenericError(xmlGenericErrorContext, "xmlBufferAddHead: str == NULL\n"); #endif return -1; } if (len < -1) { #ifdef DEBUG_BUFFER xmlGenericError(xmlGenericErrorContext, "xmlBufferAddHead: len < 0\n"); #endif return -1; } if (len == 0) return 0; if (len < 0) len = xmlStrlen(str); if (len <= 0) return -1; needSize = buf->use + len + 2; if (needSize > buf->size){ if (!xmlBufferResize(buf, needSize)){ xmlTreeErrMemory("growing buffer"); return XML_ERR_NO_MEMORY; } } memmove(&buf->content[len], &buf->content[0], buf->use * sizeof(xmlChar)); memmove(&buf->content[0], str, len * sizeof(xmlChar)); buf->use += len; buf->content[buf->use] = 0; return 0; } /** * xmlBufferCat: * @buf: the buffer to add to * @str: the #xmlChar string * * Append a zero terminated string to an XML buffer. * * Returns 0 successful, a positive error code number otherwise * and -1 in case of internal or API error. */ int xmlBufferCat(xmlBufferPtr buf, const xmlChar *str) { if (buf == NULL) return(-1); if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return -1; if (str == NULL) return -1; return xmlBufferAdd(buf, str, -1); } /** * xmlBufferCCat: * @buf: the buffer to dump * @str: the C char string * * Append a zero terminated C string to an XML buffer. * * Returns 0 successful, a positive error code number otherwise * and -1 in case of internal or API error. */ int xmlBufferCCat(xmlBufferPtr buf, const char *str) { const char *cur; if (buf == NULL) return(-1); if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return -1; if (str == NULL) { #ifdef DEBUG_BUFFER xmlGenericError(xmlGenericErrorContext, "xmlBufferCCat: str == NULL\n"); #endif return -1; } for (cur = str;*cur != 0;cur++) { if (buf->use + 10 >= buf->size) { if (!xmlBufferResize(buf, buf->use+10)){ xmlTreeErrMemory("growing buffer"); return XML_ERR_NO_MEMORY; } } buf->content[buf->use++] = *cur; } buf->content[buf->use] = 0; return 0; } /** * xmlBufferWriteCHAR: * @buf: the XML buffer * @string: the string to add * * routine which manages and grows an output buffer. This one adds * xmlChars at the end of the buffer. */ void xmlBufferWriteCHAR(xmlBufferPtr buf, const xmlChar *string) { if (buf == NULL) return; if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return; xmlBufferCat(buf, string); } /** * xmlBufferWriteChar: * @buf: the XML buffer output * @string: the string to add * * routine which manage and grows an output buffer. This one add * C chars at the end of the array. */ void xmlBufferWriteChar(xmlBufferPtr buf, const char *string) { if (buf == NULL) return; if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return; xmlBufferCCat(buf, string); } /** * xmlBufferWriteQuotedString: * @buf: the XML buffer output * @string: the string to add * * routine which manage and grows an output buffer. This one writes * a quoted or double quoted #xmlChar string, checking first if it holds * quote or double-quotes internally */ void xmlBufferWriteQuotedString(xmlBufferPtr buf, const xmlChar *string) { const xmlChar *cur, *base; if (buf == NULL) return; if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return; if (xmlStrchr(string, '\"')) { if (xmlStrchr(string, '\'')) { #ifdef DEBUG_BUFFER xmlGenericError(xmlGenericErrorContext, "xmlBufferWriteQuotedString: string contains quote and double-quotes !\n"); #endif xmlBufferCCat(buf, "\""); base = cur = string; while(*cur != 0){ if(*cur == '"'){ if (base != cur) xmlBufferAdd(buf, base, cur - base); xmlBufferAdd(buf, BAD_CAST """, 6); cur++; base = cur; } else { cur++; } } if (base != cur) xmlBufferAdd(buf, base, cur - base); xmlBufferCCat(buf, "\""); } else{ xmlBufferCCat(buf, "\'"); xmlBufferCat(buf, string); xmlBufferCCat(buf, "\'"); } } else { xmlBufferCCat(buf, "\""); xmlBufferCat(buf, string); xmlBufferCCat(buf, "\""); } } /** * xmlGetDocCompressMode: * @doc: the document * * get the compression ratio for a document, ZLIB based * Returns 0 (uncompressed) to 9 (max compression) */ int xmlGetDocCompressMode (xmlDocPtr doc) { if (doc == NULL) return(-1); return(doc->compression); } /** * xmlSetDocCompressMode: * @doc: the document * @mode: the compression ratio * * set the compression ratio for a document, ZLIB based * Correct values: 0 (uncompressed) to 9 (max compression) */ void xmlSetDocCompressMode (xmlDocPtr doc, int mode) { if (doc == NULL) return; if (mode < 0) doc->compression = 0; else if (mode > 9) doc->compression = 9; else doc->compression = mode; } /** * xmlGetCompressMode: * * get the default compression mode used, ZLIB based. * Returns 0 (uncompressed) to 9 (max compression) */ int xmlGetCompressMode(void) { return (xmlCompressMode); } /** * xmlSetCompressMode: * @mode: the compression ratio * * set the default compression mode used, ZLIB based * Correct values: 0 (uncompressed) to 9 (max compression) */ void xmlSetCompressMode(int mode) { if (mode < 0) xmlCompressMode = 0; else if (mode > 9) xmlCompressMode = 9; else xmlCompressMode = mode; } #define XML_TREE_NSMAP_PARENT -1 #define XML_TREE_NSMAP_XML -2 #define XML_TREE_NSMAP_DOC -3 #define XML_TREE_NSMAP_CUSTOM -4 typedef struct xmlNsMapItem *xmlNsMapItemPtr; struct xmlNsMapItem { xmlNsMapItemPtr next; xmlNsMapItemPtr prev; xmlNsPtr oldNs; /* old ns decl reference */ xmlNsPtr newNs; /* new ns decl reference */ int shadowDepth; /* Shadowed at this depth */ /* * depth: * >= 0 == @node's ns-decls * -1 == @parent's ns-decls * -2 == the doc->oldNs XML ns-decl * -3 == the doc->oldNs storage ns-decls * -4 == ns-decls provided via custom ns-handling */ int depth; }; typedef struct xmlNsMap *xmlNsMapPtr; struct xmlNsMap { xmlNsMapItemPtr first; xmlNsMapItemPtr last; xmlNsMapItemPtr pool; }; #define XML_NSMAP_NOTEMPTY(m) (((m) != NULL) && ((m)->first != NULL)) #define XML_NSMAP_FOREACH(m, i) for (i = (m)->first; i != NULL; i = (i)->next) #define XML_NSMAP_POP(m, i) \ i = (m)->last; \ (m)->last = (i)->prev; \ if ((m)->last == NULL) \ (m)->first = NULL; \ else \ (m)->last->next = NULL; \ (i)->next = (m)->pool; \ (m)->pool = i; /* * xmlDOMWrapNsMapFree: * @map: the ns-map * * Frees the ns-map */ static void xmlDOMWrapNsMapFree(xmlNsMapPtr nsmap) { xmlNsMapItemPtr cur, tmp; if (nsmap == NULL) return; cur = nsmap->pool; while (cur != NULL) { tmp = cur; cur = cur->next; xmlFree(tmp); } cur = nsmap->first; while (cur != NULL) { tmp = cur; cur = cur->next; xmlFree(tmp); } xmlFree(nsmap); } /* * xmlDOMWrapNsMapAddItem: * @map: the ns-map * @oldNs: the old ns-struct * @newNs: the new ns-struct * @depth: depth and ns-kind information * * Adds an ns-mapping item. */ static xmlNsMapItemPtr xmlDOMWrapNsMapAddItem(xmlNsMapPtr *nsmap, int position, xmlNsPtr oldNs, xmlNsPtr newNs, int depth) { xmlNsMapItemPtr ret; xmlNsMapPtr map; if (nsmap == NULL) return(NULL); if ((position != -1) && (position != 0)) return(NULL); map = *nsmap; if (map == NULL) { /* * Create the ns-map. */ map = (xmlNsMapPtr) xmlMalloc(sizeof(struct xmlNsMap)); if (map == NULL) { xmlTreeErrMemory("allocating namespace map"); return (NULL); } memset(map, 0, sizeof(struct xmlNsMap)); *nsmap = map; } if (map->pool != NULL) { /* * Reuse an item from the pool. */ ret = map->pool; map->pool = ret->next; memset(ret, 0, sizeof(struct xmlNsMapItem)); } else { /* * Create a new item. */ ret = (xmlNsMapItemPtr) xmlMalloc(sizeof(struct xmlNsMapItem)); if (ret == NULL) { xmlTreeErrMemory("allocating namespace map item"); return (NULL); } memset(ret, 0, sizeof(struct xmlNsMapItem)); } if (map->first == NULL) { /* * First ever. */ map->first = ret; map->last = ret; } else if (position == -1) { /* * Append. */ ret->prev = map->last; map->last->next = ret; map->last = ret; } else if (position == 0) { /* * Set on first position. */ map->first->prev = ret; ret->next = map->first; map->first = ret; } else return(NULL); ret->oldNs = oldNs; ret->newNs = newNs; ret->shadowDepth = -1; ret->depth = depth; return (ret); } /* * xmlDOMWrapStoreNs: * @doc: the doc * @nsName: the namespace name * @prefix: the prefix * * Creates or reuses an xmlNs struct on doc->oldNs with * the given prefix and namespace name. * * Returns the aquired ns struct or NULL in case of an API * or internal error. */ static xmlNsPtr xmlDOMWrapStoreNs(xmlDocPtr doc, const xmlChar *nsName, const xmlChar *prefix) { xmlNsPtr ns; if (doc == NULL) return (NULL); ns = xmlTreeEnsureXMLDecl(doc); if (ns == NULL) return (NULL); if (ns->next != NULL) { /* Reuse. */ ns = ns->next; while (ns != NULL) { if (((ns->prefix == prefix) || xmlStrEqual(ns->prefix, prefix)) && xmlStrEqual(ns->href, nsName)) { return (ns); } if (ns->next == NULL) break; ns = ns->next; } } /* Create. */ ns->next = xmlNewNs(NULL, nsName, prefix); return (ns->next); } /* * xmlDOMWrapNewCtxt: * * Allocates and initializes a new DOM-wrapper context. * * Returns the xmlDOMWrapCtxtPtr or NULL in case of an internal errror. */ xmlDOMWrapCtxtPtr xmlDOMWrapNewCtxt(void) { xmlDOMWrapCtxtPtr ret; ret = xmlMalloc(sizeof(xmlDOMWrapCtxt)); if (ret == NULL) { xmlTreeErrMemory("allocating DOM-wrapper context"); return (NULL); } memset(ret, 0, sizeof(xmlDOMWrapCtxt)); return (ret); } /* * xmlDOMWrapFreeCtxt: * @ctxt: the DOM-wrapper context * * Frees the DOM-wrapper context. */ void xmlDOMWrapFreeCtxt(xmlDOMWrapCtxtPtr ctxt) { if (ctxt == NULL) return; if (ctxt->namespaceMap != NULL) xmlDOMWrapNsMapFree((xmlNsMapPtr) ctxt->namespaceMap); /* * TODO: Store the namespace map in the context. */ xmlFree(ctxt); } /* * xmlTreeLookupNsListByPrefix: * @nsList: a list of ns-structs * @prefix: the searched prefix * * Searches for a ns-decl with the given prefix in @nsList. * * Returns the ns-decl if found, NULL if not found and on * API errors. */ static xmlNsPtr xmlTreeNSListLookupByPrefix(xmlNsPtr nsList, const xmlChar *prefix) { if (nsList == NULL) return (NULL); { xmlNsPtr ns; ns = nsList; do { if ((prefix == ns->prefix) || xmlStrEqual(prefix, ns->prefix)) { return (ns); } ns = ns->next; } while (ns != NULL); } return (NULL); } /* * * xmlDOMWrapNSNormGatherInScopeNs: * @map: the namespace map * @node: the node to start with * * Puts in-scope namespaces into the ns-map. * * Returns 0 on success, -1 on API or internal errors. */ static int xmlDOMWrapNSNormGatherInScopeNs(xmlNsMapPtr *map, xmlNodePtr node) { xmlNodePtr cur; xmlNsPtr ns; xmlNsMapItemPtr mi; int shadowed; if ((map == NULL) || (*map != NULL)) return (-1); /* * Get in-scope ns-decls of @parent. */ cur = node; while ((cur != NULL) && (cur != (xmlNodePtr) cur->doc)) { if (cur->type == XML_ELEMENT_NODE) { if (cur->nsDef != NULL) { ns = cur->nsDef; do { shadowed = 0; if (XML_NSMAP_NOTEMPTY(*map)) { /* * Skip shadowed prefixes. */ XML_NSMAP_FOREACH(*map, mi) { if ((ns->prefix == mi->newNs->prefix) || xmlStrEqual(ns->prefix, mi->newNs->prefix)) { shadowed = 1; break; } } } /* * Insert mapping. */ mi = xmlDOMWrapNsMapAddItem(map, 0, NULL, ns, XML_TREE_NSMAP_PARENT); if (mi == NULL) return (-1); if (shadowed) mi->shadowDepth = 0; ns = ns->next; } while (ns != NULL); } } cur = cur->parent; } return (0); } /* * XML_TREE_ADOPT_STR: If we have a dest-dict, put @str in the dict; * otherwise copy it, when it was in the source-dict. */ #define XML_TREE_ADOPT_STR(str) \ if (adoptStr && (str != NULL)) { \ if (destDoc->dict) { \ const xmlChar *old = str; \ str = xmlDictLookup(destDoc->dict, str, -1); \ if ((sourceDoc == NULL) || (sourceDoc->dict == NULL) || \ (!xmlDictOwns(sourceDoc->dict, old))) \ xmlFree((char *)old); \ } else if ((sourceDoc) && (sourceDoc->dict) && \ xmlDictOwns(sourceDoc->dict, str)) { \ str = BAD_CAST xmlStrdup(str); \ } \ } /* * XML_TREE_ADOPT_STR_2: If @str was in the source-dict, then * put it in dest-dict or copy it. */ #define XML_TREE_ADOPT_STR_2(str) \ if (adoptStr && (str != NULL) && (sourceDoc != NULL) && \ (sourceDoc->dict != NULL) && \ xmlDictOwns(sourceDoc->dict, cur->content)) { \ if (destDoc->dict) \ cur->content = (xmlChar *) \ xmlDictLookup(destDoc->dict, cur->content, -1); \ else \ cur->content = xmlStrdup(BAD_CAST cur->content); \ } /* * xmlDOMWrapNSNormAddNsMapItem2: * * For internal use. Adds a ns-decl mapping. * * Returns 0 on success, -1 on internal errors. */ static int xmlDOMWrapNSNormAddNsMapItem2(xmlNsPtr **list, int *size, int *number, xmlNsPtr oldNs, xmlNsPtr newNs) { if (*list == NULL) { *list = (xmlNsPtr *) xmlMalloc(6 * sizeof(xmlNsPtr)); if (*list == NULL) { xmlTreeErrMemory("alloc ns map item"); return(-1); } *size = 3; *number = 0; } else if ((*number) >= (*size)) { *size *= 2; *list = (xmlNsPtr *) xmlRealloc(*list, (*size) * 2 * sizeof(xmlNsPtr)); if (*list == NULL) { xmlTreeErrMemory("realloc ns map item"); return(-1); } } (*list)[2 * (*number)] = oldNs; (*list)[2 * (*number) +1] = newNs; (*number)++; return (0); } /* * xmlDOMWrapRemoveNode: * @ctxt: a DOM wrapper context * @doc: the doc * @node: the node to be removed. * @options: set of options, unused at the moment * * Unlinks the given node from its owner. * This will substitute ns-references to node->nsDef for * ns-references to doc->oldNs, thus ensuring the removed * branch to be autark wrt ns-references. * * NOTE: This function was not intensively tested. * * Returns 0 on success, 1 if the node is not supported, * -1 on API and internal errors. */ int xmlDOMWrapRemoveNode(xmlDOMWrapCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr node, int options ATTRIBUTE_UNUSED) { xmlNsPtr *list = NULL; int sizeList, nbList, i, j; xmlNsPtr ns; if ((node == NULL) || (doc == NULL) || (node->doc != doc)) return (-1); /* TODO: 0 or -1 ? */ if (node->parent == NULL) return (0); switch (node->type) { case XML_TEXT_NODE: case XML_CDATA_SECTION_NODE: case XML_ENTITY_REF_NODE: case XML_PI_NODE: case XML_COMMENT_NODE: xmlUnlinkNode(node); return (0); case XML_ELEMENT_NODE: case XML_ATTRIBUTE_NODE: break; default: return (1); } xmlUnlinkNode(node); /* * Save out-of-scope ns-references in doc->oldNs. */ do { switch (node->type) { case XML_ELEMENT_NODE: if ((ctxt == NULL) && (node->nsDef != NULL)) { ns = node->nsDef; do { if (xmlDOMWrapNSNormAddNsMapItem2(&list, &sizeList, &nbList, ns, ns) == -1) goto internal_error; ns = ns->next; } while (ns != NULL); } /* No break on purpose. */ case XML_ATTRIBUTE_NODE: if (node->ns != NULL) { /* * Find a mapping. */ if (list != NULL) { for (i = 0, j = 0; i < nbList; i++, j += 2) { if (node->ns == list[j]) { node->ns = list[++j]; goto next_node; } } } ns = NULL; if (ctxt != NULL) { /* * User defined. */ } else { /* * Add to doc's oldNs. */ ns = xmlDOMWrapStoreNs(doc, node->ns->href, node->ns->prefix); if (ns == NULL) goto internal_error; } if (ns != NULL) { /* * Add mapping. */ if (xmlDOMWrapNSNormAddNsMapItem2(&list, &sizeList, &nbList, node->ns, ns) == -1) goto internal_error; } node->ns = ns; } if ((node->type == XML_ELEMENT_NODE) && (node->properties != NULL)) { node = (xmlNodePtr) node->properties; continue; } break; default: goto next_sibling; } next_node: if ((node->type == XML_ELEMENT_NODE) && (node->children != NULL)) { node = node->children; continue; } next_sibling: if (node == NULL) break; if (node->next != NULL) node = node->next; else { node = node->parent; goto next_sibling; } } while (node != NULL); if (list != NULL) xmlFree(list); return (0); internal_error: if (list != NULL) xmlFree(list); return (-1); } /* * xmlSearchNsByNamespaceStrict: * @doc: the document * @node: the start node * @nsName: the searched namespace name * @retNs: the resulting ns-decl * @prefixed: if the found ns-decl must have a prefix (for attributes) * * Dynamically searches for a ns-declaration which matches * the given @nsName in the ancestor-or-self axis of @node. * * Returns 1 if a ns-decl was found, 0 if not and -1 on API * and internal errors. */ static int xmlSearchNsByNamespaceStrict(xmlDocPtr doc, xmlNodePtr node, const xmlChar* nsName, xmlNsPtr *retNs, int prefixed) { xmlNodePtr cur, prev = NULL, out = NULL; xmlNsPtr ns, prevns; if ((doc == NULL) || (nsName == NULL) || (retNs == NULL)) return (-1); *retNs = NULL; if (xmlStrEqual(nsName, XML_XML_NAMESPACE)) { *retNs = xmlTreeEnsureXMLDecl(doc); if (*retNs == NULL) return (-1); return (1); } cur = node; do { if (cur->type == XML_ELEMENT_NODE) { if (cur->nsDef != NULL) { for (ns = cur->nsDef; ns != NULL; ns = ns->next) { if (prefixed && (ns->prefix == NULL)) continue; if (prev != NULL) { /* * Check the last level of ns-decls for a * shadowing prefix. */ prevns = prev->nsDef; do { if ((prevns->prefix == ns->prefix) || ((prevns->prefix != NULL) && (ns->prefix != NULL) && xmlStrEqual(prevns->prefix, ns->prefix))) { /* * Shadowed. */ break; } prevns = prevns->next; } while (prevns != NULL); if (prevns != NULL) continue; } /* * Ns-name comparison. */ if ((nsName == ns->href) || xmlStrEqual(nsName, ns->href)) { /* * At this point the prefix can only be shadowed, * if we are the the (at least) 3rd level of * ns-decls. */ if (out) { int ret; ret = xmlNsInScope(doc, node, prev, ns->prefix); if (ret < 0) return (-1); /* * TODO: Should we try to find a matching ns-name * only once? This here keeps on searching. * I think we should try further since, there might * be an other matching ns-decl with an unshadowed * prefix. */ if (! ret) continue; } *retNs = ns; return (1); } } out = prev; prev = cur; } } else if ((cur->type == XML_ENTITY_NODE) || (cur->type == XML_ENTITY_DECL)) return (0); cur = cur->parent; } while ((cur != NULL) && (cur->doc != (xmlDocPtr) cur)); return (0); } /* * xmlSearchNsByPrefixStrict: * @doc: the document * @node: the start node * @prefix: the searched namespace prefix * @retNs: the resulting ns-decl * * Dynamically searches for a ns-declaration which matches * the given @nsName in the ancestor-or-self axis of @node. * * Returns 1 if a ns-decl was found, 0 if not and -1 on API * and internal errors. */ static int xmlSearchNsByPrefixStrict(xmlDocPtr doc, xmlNodePtr node, const xmlChar* prefix, xmlNsPtr *retNs) { xmlNodePtr cur; xmlNsPtr ns; if ((doc == NULL) || (node == NULL)) return (-1); if (retNs) *retNs = NULL; if (IS_STR_XML(prefix)) { if (retNs) { *retNs = xmlTreeEnsureXMLDecl(doc); if (*retNs == NULL) return (-1); } return (1); } cur = node; do { if (cur->type == XML_ELEMENT_NODE) { if (cur->nsDef != NULL) { ns = cur->nsDef; do { if ((prefix == ns->prefix) || xmlStrEqual(prefix, ns->prefix)) { /* * Disabled namespaces, e.g. xmlns:abc="". */ if (ns->href == NULL) return(0); if (retNs) *retNs = ns; return (1); } ns = ns->next; } while (ns != NULL); } } else if ((cur->type == XML_ENTITY_NODE) || (cur->type == XML_ENTITY_DECL)) return (0); cur = cur->parent; } while ((cur != NULL) && (cur->doc != (xmlDocPtr) cur)); return (0); } /* * xmlDOMWrapNSNormDeclareNsForced: * @doc: the doc * @elem: the element-node to declare on * @nsName: the namespace-name of the ns-decl * @prefix: the preferred prefix of the ns-decl * @checkShadow: ensure that the new ns-decl doesn't shadow ancestor ns-decls * * Declares a new namespace on @elem. It tries to use the * given @prefix; if a ns-decl with the given prefix is already existent * on @elem, it will generate an other prefix. * * Returns 1 if a ns-decl was found, 0 if not and -1 on API * and internal errors. */ static xmlNsPtr xmlDOMWrapNSNormDeclareNsForced(xmlDocPtr doc, xmlNodePtr elem, const xmlChar *nsName, const xmlChar *prefix, int checkShadow) { xmlNsPtr ret; char buf[50]; const xmlChar *pref; int counter = 0; /* * Create a ns-decl on @anchor. */ pref = prefix; while (1) { /* * Lookup whether the prefix is unused in elem's ns-decls. */ if ((elem->nsDef != NULL) && (xmlTreeNSListLookupByPrefix(elem->nsDef, pref) != NULL)) goto ns_next_prefix; if (checkShadow && elem->parent && ((xmlNodePtr) elem->parent->doc != elem->parent)) { /* * Does it shadow ancestor ns-decls? */ if (xmlSearchNsByPrefixStrict(doc, elem->parent, pref, NULL) == 1) goto ns_next_prefix; } ret = xmlNewNs(NULL, nsName, pref); if (ret == NULL) return (NULL); if (elem->nsDef == NULL) elem->nsDef = ret; else { xmlNsPtr ns2 = elem->nsDef; while (ns2->next != NULL) ns2 = ns2->next; ns2->next = ret; } return (ret); ns_next_prefix: counter++; if (counter > 1000) return (NULL); if (prefix == NULL) { snprintf((char *) buf, sizeof(buf), "ns_%d", counter); } else snprintf((char *) buf, sizeof(buf), "%.30s_%d", (char *)prefix, counter); pref = BAD_CAST buf; } } /* * xmlDOMWrapNSNormAquireNormalizedNs: * @doc: the doc * @elem: the element-node to declare namespaces on * @ns: the ns-struct to use for the search * @retNs: the found/created ns-struct * @nsMap: the ns-map * @depth: the current tree depth * @ancestorsOnly: search in ancestor ns-decls only * @prefixed: if the searched ns-decl must have a prefix (for attributes) * * Searches for a matching ns-name in the ns-decls of @nsMap, if not * found it will either declare it on @elem, or store it in doc->oldNs. * If a new ns-decl needs to be declared on @elem, it tries to use the * @ns->prefix for it, if this prefix is already in use on @elem, it will * change the prefix or the new ns-decl. * * Returns 0 if succeeded, -1 otherwise and on API/internal errors. */ static int xmlDOMWrapNSNormAquireNormalizedNs(xmlDocPtr doc, xmlNodePtr elem, xmlNsPtr ns, xmlNsPtr *retNs, xmlNsMapPtr *nsMap, int depth, int ancestorsOnly, int prefixed) { xmlNsMapItemPtr mi; if ((doc == NULL) || (ns == NULL) || (retNs == NULL) || (nsMap == NULL)) return (-1); *retNs = NULL; /* * Handle XML namespace. */ if (IS_STR_XML(ns->prefix)) { /* * Insert XML namespace mapping. */ *retNs = xmlTreeEnsureXMLDecl(doc); if (*retNs == NULL) return (-1); return (0); } /* * If the search should be done in ancestors only and no * @elem (the first ancestor) was specified, then skip the search. */ if ((XML_NSMAP_NOTEMPTY(*nsMap)) && (! (ancestorsOnly && (elem == NULL)))) { /* * Try to find an equal ns-name in in-scope ns-decls. */ XML_NSMAP_FOREACH(*nsMap, mi) { if ((mi->depth >= XML_TREE_NSMAP_PARENT) && /* * ancestorsOnly: This should be turned on to gain speed, * if one knows that the branch itself was already * ns-wellformed and no stale references existed. * I.e. it searches in the ancestor axis only. */ ((! ancestorsOnly) || (mi->depth == XML_TREE_NSMAP_PARENT)) && /* Skip shadowed prefixes. */ (mi->shadowDepth == -1) && /* Skip xmlns="" or xmlns:foo="". */ ((mi->newNs->href != NULL) && (mi->newNs->href[0] != 0)) && /* Ensure a prefix if wanted. */ ((! prefixed) || (mi->newNs->prefix != NULL)) && /* Equal ns name */ ((mi->newNs->href == ns->href) || xmlStrEqual(mi->newNs->href, ns->href))) { /* Set the mapping. */ mi->oldNs = ns; *retNs = mi->newNs; return (0); } } } /* * No luck, the namespace is out of scope or shadowed. */ if (elem == NULL) { xmlNsPtr tmpns; /* * Store ns-decls in "oldNs" of the document-node. */ tmpns = xmlDOMWrapStoreNs(doc, ns->href, ns->prefix); if (tmpns == NULL) return (-1); /* * Insert mapping. */ if (xmlDOMWrapNsMapAddItem(nsMap, -1, ns, tmpns, XML_TREE_NSMAP_DOC) == NULL) { xmlFreeNs(tmpns); return (-1); } *retNs = tmpns; } else { xmlNsPtr tmpns; tmpns = xmlDOMWrapNSNormDeclareNsForced(doc, elem, ns->href, ns->prefix, 0); if (tmpns == NULL) return (-1); if (*nsMap != NULL) { /* * Does it shadow ancestor ns-decls? */ XML_NSMAP_FOREACH(*nsMap, mi) { if ((mi->depth < depth) && (mi->shadowDepth == -1) && ((ns->prefix == mi->newNs->prefix) || xmlStrEqual(ns->prefix, mi->newNs->prefix))) { /* * Shadows. */ mi->shadowDepth = depth; break; } } } if (xmlDOMWrapNsMapAddItem(nsMap, -1, ns, tmpns, depth) == NULL) { xmlFreeNs(tmpns); return (-1); } *retNs = tmpns; } return (0); } typedef enum { XML_DOM_RECONNS_REMOVEREDUND = 1<<0 } xmlDOMReconcileNSOptions; /* * xmlDOMWrapReconcileNamespaces: * @ctxt: DOM wrapper context, unused at the moment * @elem: the element-node * @options: option flags * * Ensures that ns-references point to ns-decls hold on element-nodes. * Ensures that the tree is namespace wellformed by creating additional * ns-decls where needed. Note that, since prefixes of already existent * ns-decls can be shadowed by this process, it could break QNames in * attribute values or element content. * * NOTE: This function was not intensively tested. * * Returns 0 if succeeded, -1 otherwise and on API/internal errors. */ int xmlDOMWrapReconcileNamespaces(xmlDOMWrapCtxtPtr ctxt ATTRIBUTE_UNUSED, xmlNodePtr elem, int options) { int depth = -1, adoptns = 0, parnsdone = 0; xmlNsPtr ns, prevns; xmlDocPtr doc; xmlNodePtr cur, curElem = NULL; xmlNsMapPtr nsMap = NULL; xmlNsMapItemPtr /* topmi = NULL, */ mi; /* @ancestorsOnly should be set by an option flag. */ int ancestorsOnly = 0; int optRemoveRedundantNS = ((xmlDOMReconcileNSOptions) options & XML_DOM_RECONNS_REMOVEREDUND) ? 1 : 0; xmlNsPtr *listRedund = NULL; int sizeRedund = 0, nbRedund = 0, ret, i, j; if ((elem == NULL) || (elem->doc == NULL) || (elem->type != XML_ELEMENT_NODE)) return (-1); doc = elem->doc; cur = elem; do { switch (cur->type) { case XML_ELEMENT_NODE: adoptns = 1; curElem = cur; depth++; /* * Namespace declarations. */ if (cur->nsDef != NULL) { prevns = NULL; ns = cur->nsDef; while (ns != NULL) { if (! parnsdone) { if ((elem->parent) && ((xmlNodePtr) elem->parent->doc != elem->parent)) { /* * Gather ancestor in-scope ns-decls. */ if (xmlDOMWrapNSNormGatherInScopeNs(&nsMap, elem->parent) == -1) goto internal_error; } parnsdone = 1; } /* * Lookup the ns ancestor-axis for equal ns-decls in scope. */ if (optRemoveRedundantNS && XML_NSMAP_NOTEMPTY(nsMap)) { XML_NSMAP_FOREACH(nsMap, mi) { if ((mi->depth >= XML_TREE_NSMAP_PARENT) && (mi->shadowDepth == -1) && ((ns->prefix == mi->newNs->prefix) || xmlStrEqual(ns->prefix, mi->newNs->prefix)) && ((ns->href == mi->newNs->href) || xmlStrEqual(ns->href, mi->newNs->href))) { /* * A redundant ns-decl was found. * Add it to the list of redundant ns-decls. */ if (xmlDOMWrapNSNormAddNsMapItem2(&listRedund, &sizeRedund, &nbRedund, ns, mi->newNs) == -1) goto internal_error; /* * Remove the ns-decl from the element-node. */ if (prevns) prevns->next = ns->next; else cur->nsDef = ns->next; goto next_ns_decl; } } } /* * Skip ns-references handling if the referenced * ns-decl is declared on the same element. */ if ((cur->ns != NULL) && adoptns && (cur->ns == ns)) adoptns = 0; /* * Does it shadow any ns-decl? */ if (XML_NSMAP_NOTEMPTY(nsMap)) { XML_NSMAP_FOREACH(nsMap, mi) { if ((mi->depth >= XML_TREE_NSMAP_PARENT) && (mi->shadowDepth == -1) && ((ns->prefix == mi->newNs->prefix) || xmlStrEqual(ns->prefix, mi->newNs->prefix))) { mi->shadowDepth = depth; } } } /* * Push mapping. */ if (xmlDOMWrapNsMapAddItem(&nsMap, -1, ns, ns, depth) == NULL) goto internal_error; prevns = ns; next_ns_decl: ns = ns->next; } } if (! adoptns) goto ns_end; /* No break on purpose. */ case XML_ATTRIBUTE_NODE: /* No ns, no fun. */ if (cur->ns == NULL) goto ns_end; if (! parnsdone) { if ((elem->parent) && ((xmlNodePtr) elem->parent->doc != elem->parent)) { if (xmlDOMWrapNSNormGatherInScopeNs(&nsMap, elem->parent) == -1) goto internal_error; } parnsdone = 1; } /* * Adjust the reference if this was a redundant ns-decl. */ if (listRedund) { for (i = 0, j = 0; i < nbRedund; i++, j += 2) { if (cur->ns == listRedund[j]) { cur->ns = listRedund[++j]; break; } } } /* * Adopt ns-references. */ if (XML_NSMAP_NOTEMPTY(nsMap)) { /* * Search for a mapping. */ XML_NSMAP_FOREACH(nsMap, mi) { if ((mi->shadowDepth == -1) && (cur->ns == mi->oldNs)) { cur->ns = mi->newNs; goto ns_end; } } } /* * Aquire a normalized ns-decl and add it to the map. */ if (xmlDOMWrapNSNormAquireNormalizedNs(doc, curElem, cur->ns, &ns, &nsMap, depth, ancestorsOnly, (cur->type == XML_ATTRIBUTE_NODE) ? 1 : 0) == -1) goto internal_error; cur->ns = ns; ns_end: if ((cur->type == XML_ELEMENT_NODE) && (cur->properties != NULL)) { /* * Process attributes. */ cur = (xmlNodePtr) cur->properties; continue; } break; default: goto next_sibling; } into_content: if ((cur->type == XML_ELEMENT_NODE) && (cur->children != NULL)) { /* * Process content of element-nodes only. */ cur = cur->children; continue; } next_sibling: if (cur == elem) break; if (cur->type == XML_ELEMENT_NODE) { if (XML_NSMAP_NOTEMPTY(nsMap)) { /* * Pop mappings. */ while ((nsMap->last != NULL) && (nsMap->last->depth >= depth)) { XML_NSMAP_POP(nsMap, mi) } /* * Unshadow. */ XML_NSMAP_FOREACH(nsMap, mi) { if (mi->shadowDepth >= depth) mi->shadowDepth = -1; } } depth--; } if (cur->next != NULL) cur = cur->next; else { if (cur->type == XML_ATTRIBUTE_NODE) { cur = cur->parent; goto into_content; } cur = cur->parent; goto next_sibling; } } while (cur != NULL); ret = 0; goto exit; internal_error: ret = -1; exit: if (listRedund) { for (i = 0, j = 0; i < nbRedund; i++, j += 2) { xmlFreeNs(listRedund[j]); } xmlFree(listRedund); } if (nsMap != NULL) xmlDOMWrapNsMapFree(nsMap); return (ret); } /* * xmlDOMWrapAdoptBranch: * @ctxt: the optional context for custom processing * @sourceDoc: the optional sourceDoc * @node: the element-node to start with * @destDoc: the destination doc for adoption * @destParent: the optional new parent of @node in @destDoc * @options: option flags * * Ensures that ns-references point to @destDoc: either to * elements->nsDef entries if @destParent is given, or to * @destDoc->oldNs otherwise. * If @destParent is given, it ensures that the tree is namespace * wellformed by creating additional ns-decls where needed. * Note that, since prefixes of already existent ns-decls can be * shadowed by this process, it could break QNames in attribute * values or element content. * * NOTE: This function was not intensively tested. * * Returns 0 if succeeded, -1 otherwise and on API/internal errors. */ static int xmlDOMWrapAdoptBranch(xmlDOMWrapCtxtPtr ctxt, xmlDocPtr sourceDoc, xmlNodePtr node, xmlDocPtr destDoc, xmlNodePtr destParent, int options ATTRIBUTE_UNUSED) { int ret = 0; xmlNodePtr cur, curElem = NULL; xmlNsMapPtr nsMap = NULL; xmlNsMapItemPtr mi; xmlNsPtr ns = NULL; int depth = -1, adoptStr = 1; /* gather @parent's ns-decls. */ int parnsdone; /* @ancestorsOnly should be set per option. */ int ancestorsOnly = 0; /* * Optimize string adoption for equal or none dicts. */ if ((sourceDoc != NULL) && (sourceDoc->dict == destDoc->dict)) adoptStr = 0; else adoptStr = 1; /* * Get the ns-map from the context if available. */ if (ctxt) nsMap = (xmlNsMapPtr) ctxt->namespaceMap; /* * Disable search for ns-decls in the parent-axis of the * desination element, if: * 1) there's no destination parent * 2) custom ns-reference handling is used */ if ((destParent == NULL) || (ctxt && ctxt->getNsForNodeFunc)) { parnsdone = 1; } else parnsdone = 0; cur = node; while (cur != NULL) { /* * Paranoid source-doc sanity check. */ if (cur->doc != sourceDoc) { /* * We'll assume XIncluded nodes if the doc differs. * TODO: Do we need to reconciliate XIncluded nodes? * This here skips XIncluded nodes and tries to handle * broken sequences. */ if (cur->next == NULL) goto leave_node; do { cur = cur->next; if ((cur->type == XML_XINCLUDE_END) || (cur->doc == node->doc)) break; } while (cur->next != NULL); if (cur->doc != node->doc) goto leave_node; } cur->doc = destDoc; switch (cur->type) { case XML_XINCLUDE_START: case XML_XINCLUDE_END: /* * TODO */ return (-1); case XML_ELEMENT_NODE: curElem = cur; depth++; /* * Namespace declarations. * - ns->href and ns->prefix are never in the dict, so * we need not move the values over to the destination dict. * - Note that for custom handling of ns-references, * the ns-decls need not be stored in the ns-map, * since they won't be referenced by node->ns. */ if ((cur->nsDef) && ((ctxt == NULL) || (ctxt->getNsForNodeFunc == NULL))) { if (! parnsdone) { /* * Gather @parent's in-scope ns-decls. */ if (xmlDOMWrapNSNormGatherInScopeNs(&nsMap, destParent) == -1) goto internal_error; parnsdone = 1; } for (ns = cur->nsDef; ns != NULL; ns = ns->next) { /* * NOTE: ns->prefix and ns->href are never in the dict. * XML_TREE_ADOPT_STR(ns->prefix) * XML_TREE_ADOPT_STR(ns->href) */ /* * Does it shadow any ns-decl? */ if (XML_NSMAP_NOTEMPTY(nsMap)) { XML_NSMAP_FOREACH(nsMap, mi) { if ((mi->depth >= XML_TREE_NSMAP_PARENT) && (mi->shadowDepth == -1) && ((ns->prefix == mi->newNs->prefix) || xmlStrEqual(ns->prefix, mi->newNs->prefix))) { mi->shadowDepth = depth; } } } /* * Push mapping. */ if (xmlDOMWrapNsMapAddItem(&nsMap, -1, ns, ns, depth) == NULL) goto internal_error; } } /* No break on purpose. */ case XML_ATTRIBUTE_NODE: /* No namespace, no fun. */ if (cur->ns == NULL) goto ns_end; if (! parnsdone) { if (xmlDOMWrapNSNormGatherInScopeNs(&nsMap, destParent) == -1) goto internal_error; parnsdone = 1; } /* * Adopt ns-references. */ if (XML_NSMAP_NOTEMPTY(nsMap)) { /* * Search for a mapping. */ XML_NSMAP_FOREACH(nsMap, mi) { if ((mi->shadowDepth == -1) && (cur->ns == mi->oldNs)) { cur->ns = mi->newNs; goto ns_end; } } } /* * No matching namespace in scope. We need a new one. */ if ((ctxt) && (ctxt->getNsForNodeFunc)) { /* * User-defined behaviour. */ ns = ctxt->getNsForNodeFunc(ctxt, cur, cur->ns->href, cur->ns->prefix); /* * Insert mapping if ns is available; it's the users fault * if not. */ if (xmlDOMWrapNsMapAddItem(&nsMap, -1, cur->ns, ns, XML_TREE_NSMAP_CUSTOM) == NULL) goto internal_error; cur->ns = ns; } else { /* * Aquire a normalized ns-decl and add it to the map. */ if (xmlDOMWrapNSNormAquireNormalizedNs(destDoc, /* ns-decls on curElem or on destDoc->oldNs */ destParent ? curElem : NULL, cur->ns, &ns, &nsMap, depth, ancestorsOnly, /* ns-decls must be prefixed for attributes. */ (cur->type == XML_ATTRIBUTE_NODE) ? 1 : 0) == -1) goto internal_error; cur->ns = ns; } ns_end: /* * Further node properties. * TODO: Is this all? */ XML_TREE_ADOPT_STR(cur->name) if (cur->type == XML_ELEMENT_NODE) { cur->psvi = NULL; cur->line = 0; cur->extra = 0; /* * Walk attributes. */ if (cur->properties != NULL) { /* * Process first attribute node. */ cur = (xmlNodePtr) cur->properties; continue; } } else { /* * Attributes. */ if ((sourceDoc != NULL) && (((xmlAttrPtr) cur)->atype == XML_ATTRIBUTE_ID)) { xmlRemoveID(sourceDoc, (xmlAttrPtr) cur); } ((xmlAttrPtr) cur)->atype = 0; ((xmlAttrPtr) cur)->psvi = NULL; } break; case XML_TEXT_NODE: case XML_CDATA_SECTION_NODE: /* * This puts the content in the dest dict, only if * it was previously in the source dict. */ XML_TREE_ADOPT_STR_2(cur->content) goto leave_node; case XML_ENTITY_REF_NODE: /* * Remove reference to the entitity-node. */ cur->content = NULL; cur->children = NULL; cur->last = NULL; if ((destDoc->intSubset) || (destDoc->extSubset)) { xmlEntityPtr ent; /* * Assign new entity-node if available. */ ent = xmlGetDocEntity(destDoc, cur->name); if (ent != NULL) { cur->content = ent->content; cur->children = (xmlNodePtr) ent; cur->last = (xmlNodePtr) ent; } } goto leave_node; case XML_PI_NODE: XML_TREE_ADOPT_STR(cur->name) XML_TREE_ADOPT_STR_2(cur->content) break; case XML_COMMENT_NODE: break; default: goto internal_error; } /* * Walk the tree. */ if (cur->children != NULL) { cur = cur->children; continue; } leave_node: if (cur == node) break; if ((cur->type == XML_ELEMENT_NODE) || (cur->type == XML_XINCLUDE_START) || (cur->type == XML_XINCLUDE_END)) { /* * TODO: Do we expect nsDefs on XML_XINCLUDE_START? */ if (XML_NSMAP_NOTEMPTY(nsMap)) { /* * Pop mappings. */ while ((nsMap->last != NULL) && (nsMap->last->depth >= depth)) { XML_NSMAP_POP(nsMap, mi) } /* * Unshadow. */ XML_NSMAP_FOREACH(nsMap, mi) { if (mi->shadowDepth >= depth) mi->shadowDepth = -1; } } depth--; } if (cur->next != NULL) cur = cur->next; else if ((cur->type == XML_ATTRIBUTE_NODE) && (cur->parent->children != NULL)) { cur = cur->parent->children; } else { cur = cur->parent; goto leave_node; } } goto exit; internal_error: ret = -1; exit: /* * Cleanup. */ if (nsMap != NULL) { if ((ctxt) && (ctxt->namespaceMap == nsMap)) { /* * Just cleanup the map but don't free. */ if (nsMap->first) { if (nsMap->pool) nsMap->last->next = nsMap->pool; nsMap->pool = nsMap->first; nsMap->first = NULL; } } else xmlDOMWrapNsMapFree(nsMap); } return(ret); } /* * xmlDOMWrapCloneNode: * @ctxt: the optional context for custom processing * @sourceDoc: the optional sourceDoc * @node: the node to start with * @resNode: the clone of the given @node * @destDoc: the destination doc * @destParent: the optional new parent of @node in @destDoc * @deep: descend into child if set * @options: option flags * * References of out-of scope ns-decls are remapped to point to @destDoc: * 1) If @destParent is given, then nsDef entries on element-nodes are used * 2) If *no* @destParent is given, then @destDoc->oldNs entries are used. * This is the case when you don't know already where the cloned branch * will be added to. * * If @destParent is given, it ensures that the tree is namespace * wellformed by creating additional ns-decls where needed. * Note that, since prefixes of already existent ns-decls can be * shadowed by this process, it could break QNames in attribute * values or element content. * TODO: * 1) What to do with XInclude? Currently this returns an error for XInclude. * * Returns 0 if the operation succeeded, * 1 if a node of unsupported (or not yet supported) type was given, * -1 on API/internal errors. */ int xmlDOMWrapCloneNode(xmlDOMWrapCtxtPtr ctxt, xmlDocPtr sourceDoc, xmlNodePtr node, xmlNodePtr *resNode, xmlDocPtr destDoc, xmlNodePtr destParent, int deep, int options ATTRIBUTE_UNUSED) { int ret = 0; xmlNodePtr cur, curElem = NULL; xmlNsMapPtr nsMap = NULL; xmlNsMapItemPtr mi; xmlNsPtr ns; int depth = -1; /* int adoptStr = 1; */ /* gather @parent's ns-decls. */ int parnsdone = 0; /* * @ancestorsOnly: * TODO: @ancestorsOnly should be set per option. * */ int ancestorsOnly = 0; xmlNodePtr resultClone = NULL, clone = NULL, parentClone = NULL, prevClone = NULL; xmlNsPtr cloneNs = NULL, *cloneNsDefSlot = NULL; xmlDictPtr dict; /* The destination dict */ if ((node == NULL) || (resNode == NULL) || (destDoc == NULL)) return(-1); /* * TODO: Initially we support only element-nodes. */ if (node->type != XML_ELEMENT_NODE) return(1); /* * Check node->doc sanity. */ if ((node->doc != NULL) && (sourceDoc != NULL) && (node->doc != sourceDoc)) { /* * Might be an XIncluded node. */ return (-1); } if (sourceDoc == NULL) sourceDoc = node->doc; if (sourceDoc == NULL) return (-1); dict = destDoc->dict; /* * Reuse the namespace map of the context. */ if (ctxt) nsMap = (xmlNsMapPtr) ctxt->namespaceMap; *resNode = NULL; cur = node; while (cur != NULL) { if (cur->doc != sourceDoc) { /* * We'll assume XIncluded nodes if the doc differs. * TODO: Do we need to reconciliate XIncluded nodes? * TODO: This here returns -1 in this case. */ goto internal_error; } /* * Create a new node. */ switch (cur->type) { case XML_XINCLUDE_START: case XML_XINCLUDE_END: /* * TODO: What to do with XInclude? */ goto internal_error; break; case XML_ELEMENT_NODE: case XML_TEXT_NODE: case XML_CDATA_SECTION_NODE: case XML_COMMENT_NODE: case XML_PI_NODE: case XML_DOCUMENT_FRAG_NODE: case XML_ENTITY_REF_NODE: case XML_ENTITY_NODE: /* * Nodes of xmlNode structure. */ clone = (xmlNodePtr) xmlMalloc(sizeof(xmlNode)); if (clone == NULL) { xmlTreeErrMemory("xmlDOMWrapCloneNode(): allocating a node"); goto internal_error; } memset(clone, 0, sizeof(xmlNode)); /* * Set hierarchical links. */ if (resultClone != NULL) { clone->parent = parentClone; if (prevClone) { prevClone->next = clone; clone->prev = prevClone; } else parentClone->children = clone; } else resultClone = clone; break; case XML_ATTRIBUTE_NODE: /* * Attributes (xmlAttr). */ clone = (xmlNodePtr) xmlMalloc(sizeof(xmlAttr)); if (clone == NULL) { xmlTreeErrMemory("xmlDOMWrapCloneNode(): allocating an attr-node"); goto internal_error; } memset(clone, 0, sizeof(xmlAttr)); /* * Set hierarchical links. * TODO: Change this to add to the end of attributes. */ if (resultClone != NULL) { clone->parent = parentClone; if (prevClone) { prevClone->next = clone; clone->prev = prevClone; } else parentClone->properties = (xmlAttrPtr) clone; } else resultClone = clone; break; default: /* * TODO QUESTION: Any other nodes expected? */ goto internal_error; } clone->type = cur->type; clone->doc = destDoc; /* * Clone the name of the node if any. */ if (cur->name == xmlStringText) clone->name = xmlStringText; else if (cur->name == xmlStringTextNoenc) /* * NOTE: Although xmlStringTextNoenc is never assigned to a node * in tree.c, it might be set in Libxslt via * "xsl:disable-output-escaping". */ clone->name = xmlStringTextNoenc; else if (cur->name == xmlStringComment) clone->name = xmlStringComment; else if (cur->name != NULL) { DICT_CONST_COPY(cur->name, clone->name); } switch (cur->type) { case XML_XINCLUDE_START: case XML_XINCLUDE_END: /* * TODO */ return (-1); case XML_ELEMENT_NODE: curElem = cur; depth++; /* * Namespace declarations. */ if (cur->nsDef != NULL) { if (! parnsdone) { if (destParent && (ctxt == NULL)) { /* * Gather @parent's in-scope ns-decls. */ if (xmlDOMWrapNSNormGatherInScopeNs(&nsMap, destParent) == -1) goto internal_error; } parnsdone = 1; } /* * Clone namespace declarations. */ cloneNsDefSlot = &(clone->nsDef); for (ns = cur->nsDef; ns != NULL; ns = ns->next) { /* * Create a new xmlNs. */ cloneNs = (xmlNsPtr) xmlMalloc(sizeof(xmlNs)); if (cloneNs == NULL) { xmlTreeErrMemory("xmlDOMWrapCloneNode(): " "allocating namespace"); return(-1); } memset(cloneNs, 0, sizeof(xmlNs)); cloneNs->type = XML_LOCAL_NAMESPACE; if (ns->href != NULL) cloneNs->href = xmlStrdup(ns->href); if (ns->prefix != NULL) cloneNs->prefix = xmlStrdup(ns->prefix); *cloneNsDefSlot = cloneNs; cloneNsDefSlot = &(cloneNs->next); /* * Note that for custom handling of ns-references, * the ns-decls need not be stored in the ns-map, * since they won't be referenced by node->ns. */ if ((ctxt == NULL) || (ctxt->getNsForNodeFunc == NULL)) { /* * Does it shadow any ns-decl? */ if (XML_NSMAP_NOTEMPTY(nsMap)) { XML_NSMAP_FOREACH(nsMap, mi) { if ((mi->depth >= XML_TREE_NSMAP_PARENT) && (mi->shadowDepth == -1) && ((ns->prefix == mi->newNs->prefix) || xmlStrEqual(ns->prefix, mi->newNs->prefix))) { /* * Mark as shadowed at the current * depth. */ mi->shadowDepth = depth; } } } /* * Push mapping. */ if (xmlDOMWrapNsMapAddItem(&nsMap, -1, ns, cloneNs, depth) == NULL) goto internal_error; } } } /* cur->ns will be processed further down. */ break; case XML_ATTRIBUTE_NODE: /* IDs will be processed further down. */ /* cur->ns will be processed further down. */ break; case XML_TEXT_NODE: case XML_CDATA_SECTION_NODE: /* * Note that this will also cover the values of attributes. */ DICT_COPY(cur->content, clone->content); goto leave_node; case XML_ENTITY_NODE: /* TODO: What to do here? */ goto leave_node; case XML_ENTITY_REF_NODE: if (sourceDoc != destDoc) { if ((destDoc->intSubset) || (destDoc->extSubset)) { xmlEntityPtr ent; /* * Different doc: Assign new entity-node if available. */ ent = xmlGetDocEntity(destDoc, cur->name); if (ent != NULL) { clone->content = ent->content; clone->children = (xmlNodePtr) ent; clone->last = (xmlNodePtr) ent; } } } else { /* * Same doc: Use the current node's entity declaration * and value. */ clone->content = cur->content; clone->children = cur->children; clone->last = cur->last; } goto leave_node; case XML_PI_NODE: DICT_COPY(cur->content, clone->content); goto leave_node; case XML_COMMENT_NODE: DICT_COPY(cur->content, clone->content); goto leave_node; default: goto internal_error; } if (cur->ns == NULL) goto end_ns_reference; /* handle_ns_reference: */ /* ** The following will take care of references to ns-decls ******** ** and is intended only for element- and attribute-nodes. ** */ if (! parnsdone) { if (destParent && (ctxt == NULL)) { if (xmlDOMWrapNSNormGatherInScopeNs(&nsMap, destParent) == -1) goto internal_error; } parnsdone = 1; } /* * Adopt ns-references. */ if (XML_NSMAP_NOTEMPTY(nsMap)) { /* * Search for a mapping. */ XML_NSMAP_FOREACH(nsMap, mi) { if ((mi->shadowDepth == -1) && (cur->ns == mi->oldNs)) { /* * This is the nice case: a mapping was found. */ clone->ns = mi->newNs; goto end_ns_reference; } } } /* * No matching namespace in scope. We need a new one. */ if ((ctxt != NULL) && (ctxt->getNsForNodeFunc != NULL)) { /* * User-defined behaviour. */ ns = ctxt->getNsForNodeFunc(ctxt, cur, cur->ns->href, cur->ns->prefix); /* * Add user's mapping. */ if (xmlDOMWrapNsMapAddItem(&nsMap, -1, cur->ns, ns, XML_TREE_NSMAP_CUSTOM) == NULL) goto internal_error; clone->ns = ns; } else { /* * Aquire a normalized ns-decl and add it to the map. */ if (xmlDOMWrapNSNormAquireNormalizedNs(destDoc, /* ns-decls on curElem or on destDoc->oldNs */ destParent ? curElem : NULL, cur->ns, &ns, &nsMap, depth, /* if we need to search only in the ancestor-axis */ ancestorsOnly, /* ns-decls must be prefixed for attributes. */ (cur->type == XML_ATTRIBUTE_NODE) ? 1 : 0) == -1) goto internal_error; clone->ns = ns; } end_ns_reference: /* * Some post-processing. * * Handle ID attributes. */ if ((clone->type == XML_ATTRIBUTE_NODE) && (clone->parent != NULL)) { if (xmlIsID(destDoc, clone->parent, (xmlAttrPtr) clone)) { xmlChar *idVal; idVal = xmlNodeListGetString(cur->doc, cur->children, 1); if (idVal != NULL) { if (xmlAddID(NULL, destDoc, idVal, (xmlAttrPtr) cur) == NULL) { /* TODO: error message. */ xmlFree(idVal); goto internal_error; } xmlFree(idVal); } } } /* ** ** The following will traverse the tree ************************** ** * * Walk the element's attributes before descending into child-nodes. */ if ((cur->type == XML_ELEMENT_NODE) && (cur->properties != NULL)) { prevClone = NULL; parentClone = clone; cur = (xmlNodePtr) cur->properties; continue; } into_content: /* * Descend into child-nodes. */ if (cur->children != NULL) { if (deep || (cur->type == XML_ATTRIBUTE_NODE)) { prevClone = NULL; parentClone = clone; cur = cur->children; continue; } } leave_node: /* * At this point we are done with the node, its content * and an element-nodes's attribute-nodes. */ if (cur == node) break; if ((cur->type == XML_ELEMENT_NODE) || (cur->type == XML_XINCLUDE_START) || (cur->type == XML_XINCLUDE_END)) { /* * TODO: Do we expect nsDefs on XML_XINCLUDE_START? */ if (XML_NSMAP_NOTEMPTY(nsMap)) { /* * Pop mappings. */ while ((nsMap->last != NULL) && (nsMap->last->depth >= depth)) { XML_NSMAP_POP(nsMap, mi) } /* * Unshadow. */ XML_NSMAP_FOREACH(nsMap, mi) { if (mi->shadowDepth >= depth) mi->shadowDepth = -1; } } depth--; } if (cur->next != NULL) { prevClone = clone; cur = cur->next; } else if (cur->type != XML_ATTRIBUTE_NODE) { /* * Set clone->last. */ if (clone->parent != NULL) clone->parent->last = clone; clone = clone->parent; parentClone = clone->parent; /* * Process parent --> next; */ cur = cur->parent; goto leave_node; } else { /* This is for attributes only. */ clone = clone->parent; parentClone = clone->parent; /* * Process parent-element --> children. */ cur = cur->parent; goto into_content; } } goto exit; internal_error: ret = -1; exit: /* * Cleanup. */ if (nsMap != NULL) { if ((ctxt) && (ctxt->namespaceMap == nsMap)) { /* * Just cleanup the map but don't free. */ if (nsMap->first) { if (nsMap->pool) nsMap->last->next = nsMap->pool; nsMap->pool = nsMap->first; nsMap->first = NULL; } } else xmlDOMWrapNsMapFree(nsMap); } /* * TODO: Should we try a cleanup of the cloned node in case of a * fatal error? */ *resNode = resultClone; return (ret); } /* * xmlDOMWrapAdoptAttr: * @ctxt: the optional context for custom processing * @sourceDoc: the optional source document of attr * @attr: the attribute-node to be adopted * @destDoc: the destination doc for adoption * @destParent: the optional new parent of @attr in @destDoc * @options: option flags * * @attr is adopted by @destDoc. * Ensures that ns-references point to @destDoc: either to * elements->nsDef entries if @destParent is given, or to * @destDoc->oldNs otherwise. * * Returns 0 if succeeded, -1 otherwise and on API/internal errors. */ static int xmlDOMWrapAdoptAttr(xmlDOMWrapCtxtPtr ctxt, xmlDocPtr sourceDoc, xmlAttrPtr attr, xmlDocPtr destDoc, xmlNodePtr destParent, int options ATTRIBUTE_UNUSED) { xmlNodePtr cur; int adoptStr = 1; if ((attr == NULL) || (destDoc == NULL)) return (-1); attr->doc = destDoc; if (attr->ns != NULL) { xmlNsPtr ns = NULL; if (ctxt != NULL) { /* TODO: User defined. */ } /* XML Namespace. */ if (IS_STR_XML(attr->ns->prefix)) { ns = xmlTreeEnsureXMLDecl(destDoc); } else if (destParent == NULL) { /* * Store in @destDoc->oldNs. */ ns = xmlDOMWrapStoreNs(destDoc, attr->ns->href, attr->ns->prefix); } else { /* * Declare on @destParent. */ if (xmlSearchNsByNamespaceStrict(destDoc, destParent, attr->ns->href, &ns, 1) == -1) goto internal_error; if (ns == NULL) { ns = xmlDOMWrapNSNormDeclareNsForced(destDoc, destParent, attr->ns->href, attr->ns->prefix, 1); } } if (ns == NULL) goto internal_error; attr->ns = ns; } XML_TREE_ADOPT_STR(attr->name); attr->atype = 0; attr->psvi = NULL; /* * Walk content. */ if (attr->children == NULL) return (0); cur = attr->children; while (cur != NULL) { cur->doc = destDoc; switch (cur->type) { case XML_TEXT_NODE: case XML_CDATA_SECTION_NODE: XML_TREE_ADOPT_STR_2(cur->content) break; case XML_ENTITY_REF_NODE: /* * Remove reference to the entitity-node. */ cur->content = NULL; cur->children = NULL; cur->last = NULL; if ((destDoc->intSubset) || (destDoc->extSubset)) { xmlEntityPtr ent; /* * Assign new entity-node if available. */ ent = xmlGetDocEntity(destDoc, cur->name); if (ent != NULL) { cur->content = ent->content; cur->children = (xmlNodePtr) ent; cur->last = (xmlNodePtr) ent; } } break; default: break; } if (cur->children != NULL) { cur = cur->children; continue; } next_sibling: if (cur == (xmlNodePtr) attr) break; if (cur->next != NULL) cur = cur->next; else { cur = cur->parent; goto next_sibling; } } return (0); internal_error: return (-1); } /* * xmlDOMWrapAdoptNode: * @ctxt: the optional context for custom processing * @sourceDoc: the optional sourceDoc * @node: the node to start with * @destDoc: the destination doc * @destParent: the optional new parent of @node in @destDoc * @options: option flags * * References of out-of scope ns-decls are remapped to point to @destDoc: * 1) If @destParent is given, then nsDef entries on element-nodes are used * 2) If *no* @destParent is given, then @destDoc->oldNs entries are used * This is the case when you have an unliked node and just want to move it * to the context of * * If @destParent is given, it ensures that the tree is namespace * wellformed by creating additional ns-decls where needed. * Note that, since prefixes of already existent ns-decls can be * shadowed by this process, it could break QNames in attribute * values or element content. * NOTE: This function was not intensively tested. * * Returns 0 if the operation succeeded, * 1 if a node of unsupported type was given, * 2 if a node of not yet supported type was given and * -1 on API/internal errors. */ int xmlDOMWrapAdoptNode(xmlDOMWrapCtxtPtr ctxt, xmlDocPtr sourceDoc, xmlNodePtr node, xmlDocPtr destDoc, xmlNodePtr destParent, int options) { if ((node == NULL) || (destDoc == NULL) || ((destParent != NULL) && (destParent->doc != destDoc))) return(-1); /* * Check node->doc sanity. */ if ((node->doc != NULL) && (sourceDoc != NULL) && (node->doc != sourceDoc)) { /* * Might be an XIncluded node. */ return (-1); } if (sourceDoc == NULL) sourceDoc = node->doc; if (sourceDoc == destDoc) return (-1); switch (node->type) { case XML_ELEMENT_NODE: case XML_ATTRIBUTE_NODE: case XML_TEXT_NODE: case XML_CDATA_SECTION_NODE: case XML_ENTITY_REF_NODE: case XML_PI_NODE: case XML_COMMENT_NODE: break; case XML_DOCUMENT_FRAG_NODE: /* TODO: Support document-fragment-nodes. */ return (2); default: return (1); } /* * Unlink only if @node was not already added to @destParent. */ if ((node->parent != NULL) && (destParent != node->parent)) xmlUnlinkNode(node); if (node->type == XML_ELEMENT_NODE) { return (xmlDOMWrapAdoptBranch(ctxt, sourceDoc, node, destDoc, destParent, options)); } else if (node->type == XML_ATTRIBUTE_NODE) { return (xmlDOMWrapAdoptAttr(ctxt, sourceDoc, (xmlAttrPtr) node, destDoc, destParent, options)); } else { xmlNodePtr cur = node; int adoptStr = 1; cur->doc = destDoc; /* * Optimize string adoption. */ if ((sourceDoc != NULL) && (sourceDoc->dict == destDoc->dict)) adoptStr = 0; switch (node->type) { case XML_TEXT_NODE: case XML_CDATA_SECTION_NODE: XML_TREE_ADOPT_STR_2(node->content) break; case XML_ENTITY_REF_NODE: /* * Remove reference to the entitity-node. */ node->content = NULL; node->children = NULL; node->last = NULL; if ((destDoc->intSubset) || (destDoc->extSubset)) { xmlEntityPtr ent; /* * Assign new entity-node if available. */ ent = xmlGetDocEntity(destDoc, node->name); if (ent != NULL) { node->content = ent->content; node->children = (xmlNodePtr) ent; node->last = (xmlNodePtr) ent; } } XML_TREE_ADOPT_STR(node->name) break; case XML_PI_NODE: { XML_TREE_ADOPT_STR(node->name) XML_TREE_ADOPT_STR_2(node->content) break; } default: break; } } return (0); } #define bottom_tree #include "elfgcchack.h" xdmf-3.0+git20160803/Utilities/vtklibxml2/.NoDartCoverage0000640000175000017500000000004713003006557023010 0ustar alastairalastair# do not do coverage in this directory xdmf-3.0+git20160803/Utilities/vtklibxml2/uri.c0000640000175000017500000021572713003006557021124 0ustar alastairalastair/** * uri.c: set of generic URI related routines * * Reference: RFCs 2396, 2732 and 2373 * * See Copyright for the status of this software. * * daniel@veillard.com */ #define IN_LIBXML #include "libxml.h" #include #include #include #include #include /************************************************************************ * * * Macros to differentiate various character type * * directly extracted from RFC 2396 * * * ************************************************************************/ /* * alpha = lowalpha | upalpha */ #define IS_ALPHA(x) (IS_LOWALPHA(x) || IS_UPALPHA(x)) /* * lowalpha = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | * "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | * "u" | "v" | "w" | "x" | "y" | "z" */ #define IS_LOWALPHA(x) (((x) >= 'a') && ((x) <= 'z')) /* * upalpha = "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | * "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | * "U" | "V" | "W" | "X" | "Y" | "Z" */ #define IS_UPALPHA(x) (((x) >= 'A') && ((x) <= 'Z')) #ifdef IS_DIGIT #undef IS_DIGIT #endif /* * digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" */ #define IS_DIGIT(x) (((x) >= '0') && ((x) <= '9')) /* * alphanum = alpha | digit */ #define IS_ALPHANUM(x) (IS_ALPHA(x) || IS_DIGIT(x)) /* * hex = digit | "A" | "B" | "C" | "D" | "E" | "F" | * "a" | "b" | "c" | "d" | "e" | "f" */ #define IS_HEX(x) ((IS_DIGIT(x)) || (((x) >= 'a') && ((x) <= 'f')) || \ (((x) >= 'A') && ((x) <= 'F'))) /* * mark = "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")" */ #define IS_MARK(x) (((x) == '-') || ((x) == '_') || ((x) == '.') || \ ((x) == '!') || ((x) == '~') || ((x) == '*') || ((x) == '\'') || \ ((x) == '(') || ((x) == ')')) /* * reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | "$" | "," | * "[" | "]" */ #define IS_RESERVED(x) (((x) == ';') || ((x) == '/') || ((x) == '?') || \ ((x) == ':') || ((x) == '@') || ((x) == '&') || ((x) == '=') || \ ((x) == '+') || ((x) == '$') || ((x) == ',') || ((x) == '[') || \ ((x) == ']')) /* * unreserved = alphanum | mark */ #define IS_UNRESERVED(x) (IS_ALPHANUM(x) || IS_MARK(x)) /* * escaped = "%" hex hex */ #define IS_ESCAPED(p) ((*(p) == '%') && (IS_HEX((p)[1])) && \ (IS_HEX((p)[2]))) /* * uric_no_slash = unreserved | escaped | ";" | "?" | ":" | "@" | * "&" | "=" | "+" | "$" | "," */ #define IS_URIC_NO_SLASH(p) ((IS_UNRESERVED(*(p))) || (IS_ESCAPED(p)) ||\ ((*(p) == ';')) || ((*(p) == '?')) || ((*(p) == ':')) ||\ ((*(p) == '@')) || ((*(p) == '&')) || ((*(p) == '=')) ||\ ((*(p) == '+')) || ((*(p) == '$')) || ((*(p) == ','))) /* * pchar = unreserved | escaped | ":" | "@" | "&" | "=" | "+" | "$" | "," */ #define IS_PCHAR(p) ((IS_UNRESERVED(*(p))) || (IS_ESCAPED(p)) || \ ((*(p) == ':')) || ((*(p) == '@')) || ((*(p) == '&')) ||\ ((*(p) == '=')) || ((*(p) == '+')) || ((*(p) == '$')) ||\ ((*(p) == ','))) /* * rel_segment = 1*( unreserved | escaped | * ";" | "@" | "&" | "=" | "+" | "$" | "," ) */ #define IS_SEGMENT(p) ((IS_UNRESERVED(*(p))) || (IS_ESCAPED(p)) || \ ((*(p) == ';')) || ((*(p) == '@')) || ((*(p) == '&')) || \ ((*(p) == '=')) || ((*(p) == '+')) || ((*(p) == '$')) || \ ((*(p) == ','))) /* * scheme = alpha *( alpha | digit | "+" | "-" | "." ) */ #define IS_SCHEME(x) ((IS_ALPHA(x)) || (IS_DIGIT(x)) || \ ((x) == '+') || ((x) == '-') || ((x) == '.')) /* * reg_name = 1*( unreserved | escaped | "$" | "," | * ";" | ":" | "@" | "&" | "=" | "+" ) */ #define IS_REG_NAME(p) ((IS_UNRESERVED(*(p))) || (IS_ESCAPED(p)) || \ ((*(p) == '$')) || ((*(p) == ',')) || ((*(p) == ';')) || \ ((*(p) == ':')) || ((*(p) == '@')) || ((*(p) == '&')) || \ ((*(p) == '=')) || ((*(p) == '+'))) /* * userinfo = *( unreserved | escaped | ";" | ":" | "&" | "=" | * "+" | "$" | "," ) */ #define IS_USERINFO(p) ((IS_UNRESERVED(*(p))) || (IS_ESCAPED(p)) || \ ((*(p) == ';')) || ((*(p) == ':')) || ((*(p) == '&')) || \ ((*(p) == '=')) || ((*(p) == '+')) || ((*(p) == '$')) || \ ((*(p) == ','))) /* * uric = reserved | unreserved | escaped */ #define IS_URIC(p) ((IS_UNRESERVED(*(p))) || (IS_ESCAPED(p)) || \ (IS_RESERVED(*(p)))) /* * unwise = "{" | "}" | "|" | "\" | "^" | "`" */ #define IS_UNWISE(p) \ (((*(p) == '{')) || ((*(p) == '}')) || ((*(p) == '|')) || \ ((*(p) == '\\')) || ((*(p) == '^')) || ((*(p) == '[')) || \ ((*(p) == ']')) || ((*(p) == '`'))) /* * Skip to next pointer char, handle escaped sequences */ #define NEXT(p) ((*p == '%')? p += 3 : p++) /* * Productions from the spec. * * authority = server | reg_name * reg_name = 1*( unreserved | escaped | "$" | "," | * ";" | ":" | "@" | "&" | "=" | "+" ) * * path = [ abs_path | opaque_part ] */ #define STRNDUP(s, n) (char *) xmlStrndup((const xmlChar *)(s), (n)) /************************************************************************ * * * Generic URI structure functions * * * ************************************************************************/ /** * xmlCreateURI: * * Simply creates an empty xmlURI * * Returns the new structure or NULL in case of error */ xmlURIPtr xmlCreateURI(void) { xmlURIPtr ret; ret = (xmlURIPtr) xmlMalloc(sizeof(xmlURI)); if (ret == NULL) { xmlGenericError(xmlGenericErrorContext, "xmlCreateURI: out of memory\n"); return(NULL); } memset(ret, 0, sizeof(xmlURI)); return(ret); } /** * xmlSaveUri: * @uri: pointer to an xmlURI * * Save the URI as an escaped string * * Returns a new string (to be deallocated by caller) */ xmlChar * xmlSaveUri(xmlURIPtr uri) { xmlChar *ret = NULL; const char *p; int len; int max; if (uri == NULL) return(NULL); max = 80; ret = (xmlChar *) xmlMallocAtomic((max + 1) * sizeof(xmlChar)); if (ret == NULL) { xmlGenericError(xmlGenericErrorContext, "xmlSaveUri: out of memory\n"); return(NULL); } len = 0; if (uri->scheme != NULL) { p = uri->scheme; while (*p != 0) { if (len >= max) { max *= 2; ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar)); if (ret == NULL) { xmlGenericError(xmlGenericErrorContext, "xmlSaveUri: out of memory\n"); return(NULL); } } ret[len++] = *p++; } if (len >= max) { max *= 2; ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar)); if (ret == NULL) { xmlGenericError(xmlGenericErrorContext, "xmlSaveUri: out of memory\n"); return(NULL); } } ret[len++] = ':'; } if (uri->opaque != NULL) { p = uri->opaque; while (*p != 0) { if (len + 3 >= max) { max *= 2; ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar)); if (ret == NULL) { xmlGenericError(xmlGenericErrorContext, "xmlSaveUri: out of memory\n"); return(NULL); } } if (IS_RESERVED(*(p)) || IS_UNRESERVED(*(p))) ret[len++] = *p++; else { int val = *(unsigned char *)p++; int hi = val / 0x10, lo = val % 0x10; ret[len++] = '%'; ret[len++] = hi + (hi > 9? 'A'-10 : '0'); ret[len++] = lo + (lo > 9? 'A'-10 : '0'); } } } else { if (uri->server != NULL) { if (len + 3 >= max) { max *= 2; ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar)); if (ret == NULL) { xmlGenericError(xmlGenericErrorContext, "xmlSaveUri: out of memory\n"); return(NULL); } } ret[len++] = '/'; ret[len++] = '/'; if (uri->user != NULL) { p = uri->user; while (*p != 0) { if (len + 3 >= max) { max *= 2; ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar)); if (ret == NULL) { xmlGenericError(xmlGenericErrorContext, "xmlSaveUri: out of memory\n"); return(NULL); } } if ((IS_UNRESERVED(*(p))) || ((*(p) == ';')) || ((*(p) == ':')) || ((*(p) == '&')) || ((*(p) == '=')) || ((*(p) == '+')) || ((*(p) == '$')) || ((*(p) == ','))) ret[len++] = *p++; else { int val = *(unsigned char *)p++; int hi = val / 0x10, lo = val % 0x10; ret[len++] = '%'; ret[len++] = hi + (hi > 9? 'A'-10 : '0'); ret[len++] = lo + (lo > 9? 'A'-10 : '0'); } } if (len + 3 >= max) { max *= 2; ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar)); if (ret == NULL) { xmlGenericError(xmlGenericErrorContext, "xmlSaveUri: out of memory\n"); return(NULL); } } ret[len++] = '@'; } p = uri->server; while (*p != 0) { if (len >= max) { max *= 2; ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar)); if (ret == NULL) { xmlGenericError(xmlGenericErrorContext, "xmlSaveUri: out of memory\n"); return(NULL); } } ret[len++] = *p++; } if (uri->port > 0) { if (len + 10 >= max) { max *= 2; ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar)); if (ret == NULL) { xmlGenericError(xmlGenericErrorContext, "xmlSaveUri: out of memory\n"); return(NULL); } } len += snprintf((char *) &ret[len], max - len, ":%d", uri->port); } } else if (uri->authority != NULL) { if (len + 3 >= max) { max *= 2; ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar)); if (ret == NULL) { xmlGenericError(xmlGenericErrorContext, "xmlSaveUri: out of memory\n"); return(NULL); } } ret[len++] = '/'; ret[len++] = '/'; p = uri->authority; while (*p != 0) { if (len + 3 >= max) { max *= 2; ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar)); if (ret == NULL) { xmlGenericError(xmlGenericErrorContext, "xmlSaveUri: out of memory\n"); return(NULL); } } if ((IS_UNRESERVED(*(p))) || ((*(p) == '$')) || ((*(p) == ',')) || ((*(p) == ';')) || ((*(p) == ':')) || ((*(p) == '@')) || ((*(p) == '&')) || ((*(p) == '=')) || ((*(p) == '+'))) ret[len++] = *p++; else { int val = *(unsigned char *)p++; int hi = val / 0x10, lo = val % 0x10; ret[len++] = '%'; ret[len++] = hi + (hi > 9? 'A'-10 : '0'); ret[len++] = lo + (lo > 9? 'A'-10 : '0'); } } } else if (uri->scheme != NULL) { if (len + 3 >= max) { max *= 2; ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar)); if (ret == NULL) { xmlGenericError(xmlGenericErrorContext, "xmlSaveUri: out of memory\n"); return(NULL); } } ret[len++] = '/'; ret[len++] = '/'; } if (uri->path != NULL) { p = uri->path; while (*p != 0) { if (len + 3 >= max) { max *= 2; ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar)); if (ret == NULL) { xmlGenericError(xmlGenericErrorContext, "xmlSaveUri: out of memory\n"); return(NULL); } } if ((IS_UNRESERVED(*(p))) || ((*(p) == '/')) || ((*(p) == ';')) || ((*(p) == '@')) || ((*(p) == '&')) || ((*(p) == '=')) || ((*(p) == '+')) || ((*(p) == '$')) || ((*(p) == ','))) ret[len++] = *p++; else { int val = *(unsigned char *)p++; int hi = val / 0x10, lo = val % 0x10; ret[len++] = '%'; ret[len++] = hi + (hi > 9? 'A'-10 : '0'); ret[len++] = lo + (lo > 9? 'A'-10 : '0'); } } } if (uri->query != NULL) { if (len + 3 >= max) { max *= 2; ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar)); if (ret == NULL) { xmlGenericError(xmlGenericErrorContext, "xmlSaveUri: out of memory\n"); return(NULL); } } ret[len++] = '?'; p = uri->query; while (*p != 0) { if (len + 3 >= max) { max *= 2; ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar)); if (ret == NULL) { xmlGenericError(xmlGenericErrorContext, "xmlSaveUri: out of memory\n"); return(NULL); } } if ((IS_UNRESERVED(*(p))) || (IS_RESERVED(*(p)))) ret[len++] = *p++; else { int val = *(unsigned char *)p++; int hi = val / 0x10, lo = val % 0x10; ret[len++] = '%'; ret[len++] = hi + (hi > 9? 'A'-10 : '0'); ret[len++] = lo + (lo > 9? 'A'-10 : '0'); } } } } if (uri->fragment != NULL) { if (len + 3 >= max) { max *= 2; ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar)); if (ret == NULL) { xmlGenericError(xmlGenericErrorContext, "xmlSaveUri: out of memory\n"); return(NULL); } } ret[len++] = '#'; p = uri->fragment; while (*p != 0) { if (len + 3 >= max) { max *= 2; ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar)); if (ret == NULL) { xmlGenericError(xmlGenericErrorContext, "xmlSaveUri: out of memory\n"); return(NULL); } } if ((IS_UNRESERVED(*(p))) || (IS_RESERVED(*(p)))) ret[len++] = *p++; else { int val = *(unsigned char *)p++; int hi = val / 0x10, lo = val % 0x10; ret[len++] = '%'; ret[len++] = hi + (hi > 9? 'A'-10 : '0'); ret[len++] = lo + (lo > 9? 'A'-10 : '0'); } } } if (len >= max) { max *= 2; ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar)); if (ret == NULL) { xmlGenericError(xmlGenericErrorContext, "xmlSaveUri: out of memory\n"); return(NULL); } } ret[len++] = 0; return(ret); } /** * xmlPrintURI: * @stream: a FILE* for the output * @uri: pointer to an xmlURI * * Prints the URI in the stream @stream. */ void xmlPrintURI(FILE *stream, xmlURIPtr uri) { xmlChar *out; out = xmlSaveUri(uri); if (out != NULL) { fprintf(stream, "%s", (char *) out); xmlFree(out); } } /** * xmlCleanURI: * @uri: pointer to an xmlURI * * Make sure the xmlURI struct is free of content */ static void xmlCleanURI(xmlURIPtr uri) { if (uri == NULL) return; if (uri->scheme != NULL) xmlFree(uri->scheme); uri->scheme = NULL; if (uri->server != NULL) xmlFree(uri->server); uri->server = NULL; if (uri->user != NULL) xmlFree(uri->user); uri->user = NULL; if (uri->path != NULL) xmlFree(uri->path); uri->path = NULL; if (uri->fragment != NULL) xmlFree(uri->fragment); uri->fragment = NULL; if (uri->opaque != NULL) xmlFree(uri->opaque); uri->opaque = NULL; if (uri->authority != NULL) xmlFree(uri->authority); uri->authority = NULL; if (uri->query != NULL) xmlFree(uri->query); uri->query = NULL; } /** * xmlFreeURI: * @uri: pointer to an xmlURI * * Free up the xmlURI struct */ void xmlFreeURI(xmlURIPtr uri) { if (uri == NULL) return; if (uri->scheme != NULL) xmlFree(uri->scheme); if (uri->server != NULL) xmlFree(uri->server); if (uri->user != NULL) xmlFree(uri->user); if (uri->path != NULL) xmlFree(uri->path); if (uri->fragment != NULL) xmlFree(uri->fragment); if (uri->opaque != NULL) xmlFree(uri->opaque); if (uri->authority != NULL) xmlFree(uri->authority); if (uri->query != NULL) xmlFree(uri->query); xmlFree(uri); } /************************************************************************ * * * Helper functions * * * ************************************************************************/ /** * xmlNormalizeURIPath: * @path: pointer to the path string * * Applies the 5 normalization steps to a path string--that is, RFC 2396 * Section 5.2, steps 6.c through 6.g. * * Normalization occurs directly on the string, no new allocation is done * * Returns 0 or an error code */ int xmlNormalizeURIPath(char *path) { char *cur, *out; if (path == NULL) return(-1); /* Skip all initial "/" chars. We want to get to the beginning of the * first non-empty segment. */ cur = path; while (cur[0] == '/') ++cur; if (cur[0] == '\0') return(0); /* Keep everything we've seen so far. */ out = cur; /* * Analyze each segment in sequence for cases (c) and (d). */ while (cur[0] != '\0') { /* * c) All occurrences of "./", where "." is a complete path segment, * are removed from the buffer string. */ if ((cur[0] == '.') && (cur[1] == '/')) { cur += 2; /* '//' normalization should be done at this point too */ while (cur[0] == '/') cur++; continue; } /* * d) If the buffer string ends with "." as a complete path segment, * that "." is removed. */ if ((cur[0] == '.') && (cur[1] == '\0')) break; /* Otherwise keep the segment. */ while (cur[0] != '/') { if (cur[0] == '\0') goto done_cd; (out++)[0] = (cur++)[0]; } /* nomalize // */ while ((cur[0] == '/') && (cur[1] == '/')) cur++; (out++)[0] = (cur++)[0]; } done_cd: out[0] = '\0'; /* Reset to the beginning of the first segment for the next sequence. */ cur = path; while (cur[0] == '/') ++cur; if (cur[0] == '\0') return(0); /* * Analyze each segment in sequence for cases (e) and (f). * * e) All occurrences of "/../", where is a * complete path segment not equal to "..", are removed from the * buffer string. Removal of these path segments is performed * iteratively, removing the leftmost matching pattern on each * iteration, until no matching pattern remains. * * f) If the buffer string ends with "/..", where * is a complete path segment not equal to "..", that * "/.." is removed. * * To satisfy the "iterative" clause in (e), we need to collapse the * string every time we find something that needs to be removed. Thus, * we don't need to keep two pointers into the string: we only need a * "current position" pointer. */ while (1) { char *segp, *tmp; /* At the beginning of each iteration of this loop, "cur" points to * the first character of the segment we want to examine. */ /* Find the end of the current segment. */ segp = cur; while ((segp[0] != '/') && (segp[0] != '\0')) ++segp; /* If this is the last segment, we're done (we need at least two * segments to meet the criteria for the (e) and (f) cases). */ if (segp[0] == '\0') break; /* If the first segment is "..", or if the next segment _isn't_ "..", * keep this segment and try the next one. */ ++segp; if (((cur[0] == '.') && (cur[1] == '.') && (segp == cur+3)) || ((segp[0] != '.') || (segp[1] != '.') || ((segp[2] != '/') && (segp[2] != '\0')))) { cur = segp; continue; } /* If we get here, remove this segment and the next one and back up * to the previous segment (if there is one), to implement the * "iteratively" clause. It's pretty much impossible to back up * while maintaining two pointers into the buffer, so just compact * the whole buffer now. */ /* If this is the end of the buffer, we're done. */ if (segp[2] == '\0') { cur[0] = '\0'; break; } /* Valgrind complained, strcpy(cur, segp + 3); */ /* string will overlap, do not use strcpy */ tmp = cur; segp += 3; while ((*tmp++ = *segp++) != 0); /* If there are no previous segments, then keep going from here. */ segp = cur; while ((segp > path) && ((--segp)[0] == '/')) ; if (segp == path) continue; /* "segp" is pointing to the end of a previous segment; find it's * start. We need to back up to the previous segment and start * over with that to handle things like "foo/bar/../..". If we * don't do this, then on the first pass we'll remove the "bar/..", * but be pointing at the second ".." so we won't realize we can also * remove the "foo/..". */ cur = segp; while ((cur > path) && (cur[-1] != '/')) --cur; } out[0] = '\0'; /* * g) If the resulting buffer string still begins with one or more * complete path segments of "..", then the reference is * considered to be in error. Implementations may handle this * error by retaining these components in the resolved path (i.e., * treating them as part of the final URI), by removing them from * the resolved path (i.e., discarding relative levels above the * root), or by avoiding traversal of the reference. * * We discard them from the final path. */ if (path[0] == '/') { cur = path; while ((cur[0] == '/') && (cur[1] == '.') && (cur[2] == '.') && ((cur[3] == '/') || (cur[3] == '\0'))) cur += 3; if (cur != path) { out = path; while (cur[0] != '\0') (out++)[0] = (cur++)[0]; out[0] = 0; } } return(0); } static int is_hex(char c) { if (((c >= '0') && (c <= '9')) || ((c >= 'a') && (c <= 'f')) || ((c >= 'A') && (c <= 'F'))) return(1); return(0); } /** * xmlURIUnescapeString: * @str: the string to unescape * @len: the length in bytes to unescape (or <= 0 to indicate full string) * @target: optional destination buffer * * Unescaping routine, does not do validity checks ! * Output is direct unsigned char translation of %XX values (no encoding) * * Returns an copy of the string, but unescaped */ char * xmlURIUnescapeString(const char *str, int len, char *target) { char *ret, *out; const char *in; if (str == NULL) return(NULL); if (len <= 0) len = strlen(str); if (len < 0) return(NULL); if (target == NULL) { ret = (char *) xmlMallocAtomic(len + 1); if (ret == NULL) { xmlGenericError(xmlGenericErrorContext, "xmlURIUnescapeString: out of memory\n"); return(NULL); } } else ret = target; in = str; out = ret; while(len > 0) { if ((len > 2) && (*in == '%') && (is_hex(in[1])) && (is_hex(in[2]))) { in++; if ((*in >= '0') && (*in <= '9')) *out = (*in - '0'); else if ((*in >= 'a') && (*in <= 'f')) *out = (*in - 'a') + 10; else if ((*in >= 'A') && (*in <= 'F')) *out = (*in - 'A') + 10; in++; if ((*in >= '0') && (*in <= '9')) *out = *out * 16 + (*in - '0'); else if ((*in >= 'a') && (*in <= 'f')) *out = *out * 16 + (*in - 'a') + 10; else if ((*in >= 'A') && (*in <= 'F')) *out = *out * 16 + (*in - 'A') + 10; in++; len -= 3; out++; } else { *out++ = *in++; len--; } } *out = 0; return(ret); } /** * xmlURIEscapeStr: * @str: string to escape * @list: exception list string of chars not to escape * * This routine escapes a string to hex, ignoring reserved characters (a-z) * and the characters in the exception list. * * Returns a new escaped string or NULL in case of error. */ xmlChar * xmlURIEscapeStr(const xmlChar *str, const xmlChar *list) { xmlChar *ret, ch; const xmlChar *in; unsigned int len, out; if (str == NULL) return(NULL); if (str[0] == 0) return(xmlStrdup(str)); len = xmlStrlen(str); if (!(len > 0)) return(NULL); len += 20; ret = (xmlChar *) xmlMallocAtomic(len); if (ret == NULL) { xmlGenericError(xmlGenericErrorContext, "xmlURIEscapeStr: out of memory\n"); return(NULL); } in = (const xmlChar *) str; out = 0; while(*in != 0) { if (len - out <= 3) { len += 20; ret = (xmlChar *) xmlRealloc(ret, len); if (ret == NULL) { xmlGenericError(xmlGenericErrorContext, "xmlURIEscapeStr: out of memory\n"); return(NULL); } } ch = *in; if ((ch != '@') && (!IS_UNRESERVED(ch)) && (!xmlStrchr(list, ch))) { unsigned char val; ret[out++] = '%'; val = ch >> 4; if (val <= 9) ret[out++] = '0' + val; else ret[out++] = 'A' + val - 0xA; val = ch & 0xF; if (val <= 9) ret[out++] = '0' + val; else ret[out++] = 'A' + val - 0xA; in++; } else { ret[out++] = *in++; } } ret[out] = 0; return(ret); } /** * xmlURIEscape: * @str: the string of the URI to escape * * Escaping routine, does not do validity checks ! * It will try to escape the chars needing this, but this is heuristic * based it's impossible to be sure. * * Returns an copy of the string, but escaped * * 25 May 2001 * Uses xmlParseURI and xmlURIEscapeStr to try to escape correctly * according to RFC2396. * - Carl Douglas */ xmlChar * xmlURIEscape(const xmlChar * str) { xmlChar *ret, *segment = NULL; xmlURIPtr uri; int ret2; #define NULLCHK(p) if(!p) { \ xmlGenericError(xmlGenericErrorContext, \ "xmlURIEscape: out of memory\n"); \ return NULL; } if (str == NULL) return (NULL); uri = xmlCreateURI(); if (uri != NULL) { /* * Allow escaping errors in the unescaped form */ uri->cleanup = 1; ret2 = xmlParseURIReference(uri, (const char *)str); if (ret2) { xmlFreeURI(uri); return (NULL); } } if (!uri) return NULL; ret = NULL; if (uri->scheme) { segment = xmlURIEscapeStr(BAD_CAST uri->scheme, BAD_CAST "+-."); NULLCHK(segment) ret = xmlStrcat(ret, segment); ret = xmlStrcat(ret, BAD_CAST ":"); xmlFree(segment); } if (uri->authority) { segment = xmlURIEscapeStr(BAD_CAST uri->authority, BAD_CAST "/?;:@"); NULLCHK(segment) ret = xmlStrcat(ret, BAD_CAST "//"); ret = xmlStrcat(ret, segment); xmlFree(segment); } if (uri->user) { segment = xmlURIEscapeStr(BAD_CAST uri->user, BAD_CAST ";:&=+$,"); NULLCHK(segment) ret = xmlStrcat(ret,BAD_CAST "//"); ret = xmlStrcat(ret, segment); ret = xmlStrcat(ret, BAD_CAST "@"); xmlFree(segment); } if (uri->server) { segment = xmlURIEscapeStr(BAD_CAST uri->server, BAD_CAST "/?;:@"); NULLCHK(segment) if (uri->user == NULL) ret = xmlStrcat(ret, BAD_CAST "//"); ret = xmlStrcat(ret, segment); xmlFree(segment); } if (uri->port) { xmlChar port[10]; snprintf((char *) port, 10, "%d", uri->port); ret = xmlStrcat(ret, BAD_CAST ":"); ret = xmlStrcat(ret, port); } if (uri->path) { segment = xmlURIEscapeStr(BAD_CAST uri->path, BAD_CAST ":@&=+$,/?;"); NULLCHK(segment) ret = xmlStrcat(ret, segment); xmlFree(segment); } if (uri->query) { segment = xmlURIEscapeStr(BAD_CAST uri->query, BAD_CAST ";/?:@&=+,$"); NULLCHK(segment) ret = xmlStrcat(ret, BAD_CAST "?"); ret = xmlStrcat(ret, segment); xmlFree(segment); } if (uri->opaque) { segment = xmlURIEscapeStr(BAD_CAST uri->opaque, BAD_CAST ""); NULLCHK(segment) ret = xmlStrcat(ret, segment); xmlFree(segment); } if (uri->fragment) { segment = xmlURIEscapeStr(BAD_CAST uri->fragment, BAD_CAST "#"); NULLCHK(segment) ret = xmlStrcat(ret, BAD_CAST "#"); ret = xmlStrcat(ret, segment); xmlFree(segment); } xmlFreeURI(uri); #undef NULLCHK return (ret); } /************************************************************************ * * * Escaped URI parsing * * * ************************************************************************/ /** * xmlParseURIFragment: * @uri: pointer to an URI structure * @str: pointer to the string to analyze * * Parse an URI fragment string and fills in the appropriate fields * of the @uri structure. * * fragment = *uric * * Returns 0 or the error code */ static int xmlParseURIFragment(xmlURIPtr uri, const char **str) { const char *cur; if (str == NULL) return (-1); cur = *str; while (IS_URIC(cur) || IS_UNWISE(cur)) NEXT(cur); if (uri != NULL) { if (uri->fragment != NULL) xmlFree(uri->fragment); if (uri->cleanup & 2) uri->fragment = STRNDUP(*str, cur - *str); else uri->fragment = xmlURIUnescapeString(*str, cur - *str, NULL); } *str = cur; return (0); } /** * xmlParseURIQuery: * @uri: pointer to an URI structure * @str: pointer to the string to analyze * * Parse the query part of an URI * * query = *uric * * Returns 0 or the error code */ static int xmlParseURIQuery(xmlURIPtr uri, const char **str) { const char *cur; if (str == NULL) return (-1); cur = *str; while ((IS_URIC(cur)) || ((uri != NULL) && (uri->cleanup & 1) && (IS_UNWISE(cur)))) NEXT(cur); if (uri != NULL) { if (uri->query != NULL) xmlFree(uri->query); if (uri->cleanup & 2) uri->query = STRNDUP(*str, cur - *str); else uri->query = xmlURIUnescapeString(*str, cur - *str, NULL); } *str = cur; return (0); } /** * xmlParseURIScheme: * @uri: pointer to an URI structure * @str: pointer to the string to analyze * * Parse an URI scheme * * scheme = alpha *( alpha | digit | "+" | "-" | "." ) * * Returns 0 or the error code */ static int xmlParseURIScheme(xmlURIPtr uri, const char **str) { const char *cur; if (str == NULL) return(-1); cur = *str; if (!IS_ALPHA(*cur)) return(2); cur++; while (IS_SCHEME(*cur)) cur++; if (uri != NULL) { if (uri->scheme != NULL) xmlFree(uri->scheme); uri->scheme = STRNDUP(*str, cur - *str); } *str = cur; return(0); } /** * xmlParseURIOpaquePart: * @uri: pointer to an URI structure * @str: pointer to the string to analyze * * Parse an URI opaque part * * opaque_part = uric_no_slash *uric * * Returns 0 or the error code */ static int xmlParseURIOpaquePart(xmlURIPtr uri, const char **str) { const char *cur; if (str == NULL) return (-1); cur = *str; if (!((IS_URIC_NO_SLASH(cur)) || ((uri != NULL) && (uri->cleanup & 1) && (IS_UNWISE(cur))))) { return (3); } NEXT(cur); while ((IS_URIC(cur)) || ((uri != NULL) && (uri->cleanup & 1) && (IS_UNWISE(cur)))) NEXT(cur); if (uri != NULL) { if (uri->opaque != NULL) xmlFree(uri->opaque); if (uri->cleanup & 2) uri->opaque = STRNDUP(*str, cur - *str); else uri->opaque = xmlURIUnescapeString(*str, cur - *str, NULL); } *str = cur; return (0); } /** * xmlParseURIServer: * @uri: pointer to an URI structure * @str: pointer to the string to analyze * * Parse a server subpart of an URI, it's a finer grain analysis * of the authority part. * * server = [ [ userinfo "@" ] hostport ] * userinfo = *( unreserved | escaped | * ";" | ":" | "&" | "=" | "+" | "$" | "," ) * hostport = host [ ":" port ] * host = hostname | IPv4address | IPv6reference * hostname = *( domainlabel "." ) toplabel [ "." ] * domainlabel = alphanum | alphanum *( alphanum | "-" ) alphanum * toplabel = alpha | alpha *( alphanum | "-" ) alphanum * IPv6reference = "[" IPv6address "]" * IPv6address = hexpart [ ":" IPv4address ] * IPv4address = 1*3digit "." 1*3digit "." 1*3digit "." 1*3digit * hexpart = hexseq | hexseq "::" [ hexseq ]| "::" [ hexseq ] * hexseq = hex4 *( ":" hex4) * hex4 = 1*4hexdig * port = *digit * * Returns 0 or the error code */ static int xmlParseURIServer(xmlURIPtr uri, const char **str) { const char *cur; const char *host, *tmp; const int IPV4max = 4; const int IPV6max = 8; int oct; if (str == NULL) return(-1); cur = *str; /* * is there a userinfo ? */ while (IS_USERINFO(cur)) NEXT(cur); if (*cur == '@') { if (uri != NULL) { if (uri->user != NULL) xmlFree(uri->user); if (uri->cleanup & 2) uri->path = STRNDUP(*str, cur - *str); else uri->user = xmlURIUnescapeString(*str, cur - *str, NULL); } cur++; } else { if (uri != NULL) { if (uri->user != NULL) xmlFree(uri->user); uri->user = NULL; } cur = *str; } /* * This can be empty in the case where there is no server */ host = cur; if (*cur == '/') { if (uri != NULL) { if (uri->authority != NULL) xmlFree(uri->authority); uri->authority = NULL; if (uri->server != NULL) xmlFree(uri->server); uri->server = NULL; uri->port = 0; } return(0); } /* * host part of hostport can denote an IPV4 address, an IPV6 address * or an unresolved name. Check the IP first, its easier to detect * errors if wrong one. * An IPV6 address must start with a '[' and end with a ']'. */ if (*cur == '[') { int compress=0; cur++; for (oct = 0; oct < IPV6max; ++oct) { if (*cur == ':') { if (compress) return(3); /* multiple compression attempted */ if (!oct) { /* initial char is compression */ if (*++cur != ':') return(3); } compress = 1; /* set compression-encountered flag */ cur++; /* skip over the second ':' */ continue; } while(IS_HEX(*cur)) cur++; if (oct == (IPV6max-1)) continue; if (*cur != ':') break; cur++; } if ((!compress) && (oct != IPV6max)) return(3); if (*cur != ']') return(3); if (uri != NULL) { if (uri->server != NULL) xmlFree(uri->server); uri->server = (char *)xmlStrndup((xmlChar *)host+1, (cur-host)-1); } cur++; } else { /* * Not IPV6, maybe IPV4 */ for (oct = 0; oct < IPV4max; ++oct) { if (*cur == '.') return(3); /* e.g. http://.xml/ or http://18.29..30/ */ while(IS_DIGIT(*cur)) cur++; if (oct == (IPV4max-1)) continue; if (*cur != '.') break; cur++; } } if ((host[0] != '[') && (oct < IPV4max || (*cur == '.' && cur++) || IS_ALPHA(*cur))) { /* maybe host_name */ if (!IS_ALPHANUM(*cur)) return(4); /* e.g. http://xml.$oft */ do { do ++cur; while (IS_ALPHANUM(*cur)); if (*cur == '-') { --cur; if (*cur == '.') return(5); /* e.g. http://xml.-soft */ ++cur; continue; } if (*cur == '.') { --cur; if (*cur == '-') return(6); /* e.g. http://xml-.soft */ if (*cur == '.') return(7); /* e.g. http://xml..soft */ ++cur; continue; } break; } while (1); tmp = cur; if (tmp[-1] == '.') --tmp; /* e.g. http://xml.$Oft/ */ do --tmp; while (tmp >= host && IS_ALPHANUM(*tmp)); if ((++tmp == host || tmp[-1] == '.') && !IS_ALPHA(*tmp)) return(8); /* e.g. http://xmlsOft.0rg/ */ } if (uri != NULL) { if (uri->authority != NULL) xmlFree(uri->authority); uri->authority = NULL; if (host[0] != '[') { /* it's not an IPV6 addr */ if (uri->server != NULL) xmlFree(uri->server); if (uri->cleanup & 2) uri->server = STRNDUP(host, cur - host); else uri->server = xmlURIUnescapeString(host, cur - host, NULL); } } /* * finish by checking for a port presence. */ if (*cur == ':') { cur++; if (IS_DIGIT(*cur)) { if (uri != NULL) uri->port = 0; while (IS_DIGIT(*cur)) { if (uri != NULL) uri->port = uri->port * 10 + (*cur - '0'); cur++; } } } *str = cur; return(0); } /** * xmlParseURIRelSegment: * @uri: pointer to an URI structure * @str: pointer to the string to analyze * * Parse an URI relative segment * * rel_segment = 1*( unreserved | escaped | ";" | "@" | "&" | "=" | * "+" | "$" | "," ) * * Returns 0 or the error code */ static int xmlParseURIRelSegment(xmlURIPtr uri, const char **str) { const char *cur; if (str == NULL) return (-1); cur = *str; if (!((IS_SEGMENT(cur)) || ((uri != NULL) && (uri->cleanup & 1) && (IS_UNWISE(cur))))) { return (3); } NEXT(cur); while ((IS_SEGMENT(cur)) || ((uri != NULL) && (uri->cleanup & 1) && (IS_UNWISE(cur)))) NEXT(cur); if (uri != NULL) { if (uri->path != NULL) xmlFree(uri->path); if (uri->cleanup & 2) uri->path = STRNDUP(*str, cur - *str); else uri->path = xmlURIUnescapeString(*str, cur - *str, NULL); } *str = cur; return (0); } /** * xmlParseURIPathSegments: * @uri: pointer to an URI structure * @str: pointer to the string to analyze * @slash: should we add a leading slash * * Parse an URI set of path segments * * path_segments = segment *( "/" segment ) * segment = *pchar *( ";" param ) * param = *pchar * * Returns 0 or the error code */ static int xmlParseURIPathSegments(xmlURIPtr uri, const char **str, int slash) { const char *cur; if (str == NULL) return (-1); cur = *str; do { while ((IS_PCHAR(cur)) || ((uri != NULL) && (uri->cleanup & 1) && (IS_UNWISE(cur)))) NEXT(cur); while (*cur == ';') { cur++; while ((IS_PCHAR(cur)) || ((uri != NULL) && (uri->cleanup & 1) && (IS_UNWISE(cur)))) NEXT(cur); } if (*cur != '/') break; cur++; } while (1); if (uri != NULL) { int len, len2 = 0; char *path; /* * Concat the set of path segments to the current path */ len = cur - *str; if (slash) len++; if (uri->path != NULL) { len2 = strlen(uri->path); len += len2; } path = (char *) xmlMallocAtomic(len + 1); if (path == NULL) { xmlGenericError(xmlGenericErrorContext, "xmlParseURIPathSegments: out of memory\n"); *str = cur; return (-1); } if (uri->path != NULL) memcpy(path, uri->path, len2); if (slash) { path[len2] = '/'; len2++; } path[len2] = 0; if (cur - *str > 0) { if (uri->cleanup & 2) { memcpy(&path[len2], *str, cur - *str); path[len2 + (cur - *str)] = 0; } else xmlURIUnescapeString(*str, cur - *str, &path[len2]); } if (uri->path != NULL) xmlFree(uri->path); uri->path = path; } *str = cur; return (0); } /** * xmlParseURIAuthority: * @uri: pointer to an URI structure * @str: pointer to the string to analyze * * Parse the authority part of an URI. * * authority = server | reg_name * server = [ [ userinfo "@" ] hostport ] * reg_name = 1*( unreserved | escaped | "$" | "," | ";" | ":" | * "@" | "&" | "=" | "+" ) * * Note : this is completely ambiguous since reg_name is allowed to * use the full set of chars in use by server: * * 3.2.1. Registry-based Naming Authority * * The structure of a registry-based naming authority is specific * to the URI scheme, but constrained to the allowed characters * for an authority component. * * Returns 0 or the error code */ static int xmlParseURIAuthority(xmlURIPtr uri, const char **str) { const char *cur; int ret; if (str == NULL) return(-1); cur = *str; /* * try first to parse it as a server string. */ ret = xmlParseURIServer(uri, str); if ((ret == 0) && (*str != NULL) && ((**str == 0) || (**str == '/') || (**str == '?'))) return(0); *str = cur; /* * failed, fallback to reg_name */ if (!IS_REG_NAME(cur)) { return(5); } NEXT(cur); while (IS_REG_NAME(cur)) NEXT(cur); if (uri != NULL) { if (uri->server != NULL) xmlFree(uri->server); uri->server = NULL; if (uri->user != NULL) xmlFree(uri->user); uri->user = NULL; if (uri->authority != NULL) xmlFree(uri->authority); if (uri->cleanup & 2) uri->authority = STRNDUP(*str, cur - *str); else uri->authority = xmlURIUnescapeString(*str, cur - *str, NULL); } *str = cur; return(0); } /** * xmlParseURIHierPart: * @uri: pointer to an URI structure * @str: pointer to the string to analyze * * Parse an URI hierarchical part * * hier_part = ( net_path | abs_path ) [ "?" query ] * abs_path = "/" path_segments * net_path = "//" authority [ abs_path ] * * Returns 0 or the error code */ static int xmlParseURIHierPart(xmlURIPtr uri, const char **str) { int ret; const char *cur; if (str == NULL) return(-1); cur = *str; if ((cur[0] == '/') && (cur[1] == '/')) { cur += 2; ret = xmlParseURIAuthority(uri, &cur); if (ret != 0) return(ret); if (cur[0] == '/') { cur++; ret = xmlParseURIPathSegments(uri, &cur, 1); } } else if (cur[0] == '/') { cur++; ret = xmlParseURIPathSegments(uri, &cur, 1); } else { return(4); } if (ret != 0) return(ret); if (*cur == '?') { cur++; ret = xmlParseURIQuery(uri, &cur); if (ret != 0) return(ret); } *str = cur; return(0); } /** * xmlParseAbsoluteURI: * @uri: pointer to an URI structure * @str: pointer to the string to analyze * * Parse an URI reference string and fills in the appropriate fields * of the @uri structure * * absoluteURI = scheme ":" ( hier_part | opaque_part ) * * Returns 0 or the error code */ static int xmlParseAbsoluteURI(xmlURIPtr uri, const char **str) { int ret; const char *cur; if (str == NULL) return(-1); cur = *str; ret = xmlParseURIScheme(uri, str); if (ret != 0) return(ret); if (**str != ':') { *str = cur; return(1); } (*str)++; if (**str == '/') return(xmlParseURIHierPart(uri, str)); return(xmlParseURIOpaquePart(uri, str)); } /** * xmlParseRelativeURI: * @uri: pointer to an URI structure * @str: pointer to the string to analyze * * Parse an relative URI string and fills in the appropriate fields * of the @uri structure * * relativeURI = ( net_path | abs_path | rel_path ) [ "?" query ] * abs_path = "/" path_segments * net_path = "//" authority [ abs_path ] * rel_path = rel_segment [ abs_path ] * * Returns 0 or the error code */ static int xmlParseRelativeURI(xmlURIPtr uri, const char **str) { int ret = 0; const char *cur; if (str == NULL) return(-1); cur = *str; if ((cur[0] == '/') && (cur[1] == '/')) { cur += 2; ret = xmlParseURIAuthority(uri, &cur); if (ret != 0) return(ret); if (cur[0] == '/') { cur++; ret = xmlParseURIPathSegments(uri, &cur, 1); } } else if (cur[0] == '/') { cur++; ret = xmlParseURIPathSegments(uri, &cur, 1); } else if (cur[0] != '#' && cur[0] != '?') { ret = xmlParseURIRelSegment(uri, &cur); if (ret != 0) return(ret); if (cur[0] == '/') { cur++; ret = xmlParseURIPathSegments(uri, &cur, 1); } } if (ret != 0) return(ret); if (*cur == '?') { cur++; ret = xmlParseURIQuery(uri, &cur); if (ret != 0) return(ret); } *str = cur; return(ret); } /** * xmlParseURIReference: * @uri: pointer to an URI structure * @str: the string to analyze * * Parse an URI reference string and fills in the appropriate fields * of the @uri structure * * URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ] * * Returns 0 or the error code */ int xmlParseURIReference(xmlURIPtr uri, const char *str) { int ret; const char *tmp = str; if (str == NULL) return(-1); xmlCleanURI(uri); /* * Try first to parse absolute refs, then fallback to relative if * it fails. */ ret = xmlParseAbsoluteURI(uri, &str); if (ret != 0) { xmlCleanURI(uri); str = tmp; ret = xmlParseRelativeURI(uri, &str); } if (ret != 0) { xmlCleanURI(uri); return(ret); } if (*str == '#') { str++; ret = xmlParseURIFragment(uri, &str); if (ret != 0) return(ret); } if (*str != 0) { xmlCleanURI(uri); return(1); } return(0); } /** * xmlParseURI: * @str: the URI string to analyze * * Parse an URI * * URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ] * * Returns a newly built xmlURIPtr or NULL in case of error */ xmlURIPtr xmlParseURI(const char *str) { xmlURIPtr uri; int ret; if (str == NULL) return(NULL); uri = xmlCreateURI(); if (uri != NULL) { ret = xmlParseURIReference(uri, str); if (ret) { xmlFreeURI(uri); return(NULL); } } return(uri); } /** * xmlParseURIRaw: * @str: the URI string to analyze * @raw: if 1 unescaping of URI pieces are disabled * * Parse an URI but allows to keep intact the original fragments. * * URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ] * * Returns a newly built xmlURIPtr or NULL in case of error */ xmlURIPtr xmlParseURIRaw(const char *str, int raw) { xmlURIPtr uri; int ret; if (str == NULL) return(NULL); uri = xmlCreateURI(); if (uri != NULL) { if (raw) { uri->cleanup |= 2; } ret = xmlParseURIReference(uri, str); if (ret) { xmlFreeURI(uri); return(NULL); } } return(uri); } /************************************************************************ * * * Public functions * * * ************************************************************************/ /** * xmlBuildURI: * @URI: the URI instance found in the document * @base: the base value * * Computes he final URI of the reference done by checking that * the given URI is valid, and building the final URI using the * base URI. This is processed according to section 5.2 of the * RFC 2396 * * 5.2. Resolving Relative References to Absolute Form * * Returns a new URI string (to be freed by the caller) or NULL in case * of error. */ xmlChar * xmlBuildURI(const xmlChar *URI, const xmlChar *base) { xmlChar *val = NULL; int ret, len, indx, cur, out; xmlURIPtr ref = NULL; xmlURIPtr bas = NULL; xmlURIPtr res = NULL; /* * 1) The URI reference is parsed into the potential four components and * fragment identifier, as described in Section 4.3. * * NOTE that a completely empty URI is treated by modern browsers * as a reference to "." rather than as a synonym for the current * URI. Should we do that here? */ if (URI == NULL) ret = -1; else { if (*URI) { ref = xmlCreateURI(); if (ref == NULL) goto done; ret = xmlParseURIReference(ref, (const char *) URI); } else ret = 0; } if (ret != 0) goto done; if ((ref != NULL) && (ref->scheme != NULL)) { /* * The URI is absolute don't modify. */ val = xmlStrdup(URI); goto done; } if (base == NULL) ret = -1; else { bas = xmlCreateURI(); if (bas == NULL) goto done; ret = xmlParseURIReference(bas, (const char *) base); } if (ret != 0) { if (ref) val = xmlSaveUri(ref); goto done; } if (ref == NULL) { /* * the base fragment must be ignored */ if (bas->fragment != NULL) { xmlFree(bas->fragment); bas->fragment = NULL; } val = xmlSaveUri(bas); goto done; } /* * 2) If the path component is empty and the scheme, authority, and * query components are undefined, then it is a reference to the * current document and we are done. Otherwise, the reference URI's * query and fragment components are defined as found (or not found) * within the URI reference and not inherited from the base URI. * * NOTE that in modern browsers, the parsing differs from the above * in the following aspect: the query component is allowed to be * defined while still treating this as a reference to the current * document. */ res = xmlCreateURI(); if (res == NULL) goto done; if ((ref->scheme == NULL) && (ref->path == NULL) && ((ref->authority == NULL) && (ref->server == NULL))) { if (bas->scheme != NULL) res->scheme = xmlMemStrdup(bas->scheme); if (bas->authority != NULL) res->authority = xmlMemStrdup(bas->authority); else if (bas->server != NULL) { res->server = xmlMemStrdup(bas->server); if (bas->user != NULL) res->user = xmlMemStrdup(bas->user); res->port = bas->port; } if (bas->path != NULL) res->path = xmlMemStrdup(bas->path); if (ref->query != NULL) res->query = xmlMemStrdup(ref->query); else if (bas->query != NULL) res->query = xmlMemStrdup(bas->query); if (ref->fragment != NULL) res->fragment = xmlMemStrdup(ref->fragment); goto step_7; } /* * 3) If the scheme component is defined, indicating that the reference * starts with a scheme name, then the reference is interpreted as an * absolute URI and we are done. Otherwise, the reference URI's * scheme is inherited from the base URI's scheme component. */ if (ref->scheme != NULL) { val = xmlSaveUri(ref); goto done; } if (bas->scheme != NULL) res->scheme = xmlMemStrdup(bas->scheme); if (ref->query != NULL) res->query = xmlMemStrdup(ref->query); if (ref->fragment != NULL) res->fragment = xmlMemStrdup(ref->fragment); /* * 4) If the authority component is defined, then the reference is a * network-path and we skip to step 7. Otherwise, the reference * URI's authority is inherited from the base URI's authority * component, which will also be undefined if the URI scheme does not * use an authority component. */ if ((ref->authority != NULL) || (ref->server != NULL)) { if (ref->authority != NULL) res->authority = xmlMemStrdup(ref->authority); else { res->server = xmlMemStrdup(ref->server); if (ref->user != NULL) res->user = xmlMemStrdup(ref->user); res->port = ref->port; } if (ref->path != NULL) res->path = xmlMemStrdup(ref->path); goto step_7; } if (bas->authority != NULL) res->authority = xmlMemStrdup(bas->authority); else if (bas->server != NULL) { res->server = xmlMemStrdup(bas->server); if (bas->user != NULL) res->user = xmlMemStrdup(bas->user); res->port = bas->port; } /* * 5) If the path component begins with a slash character ("/"), then * the reference is an absolute-path and we skip to step 7. */ if ((ref->path != NULL) && (ref->path[0] == '/')) { res->path = xmlMemStrdup(ref->path); goto step_7; } /* * 6) If this step is reached, then we are resolving a relative-path * reference. The relative path needs to be merged with the base * URI's path. Although there are many ways to do this, we will * describe a simple method using a separate string buffer. * * Allocate a buffer large enough for the result string. */ len = 2; /* extra / and 0 */ if (ref->path != NULL) len += strlen(ref->path); if (bas->path != NULL) len += strlen(bas->path); res->path = (char *) xmlMallocAtomic(len); if (res->path == NULL) { xmlGenericError(xmlGenericErrorContext, "xmlBuildURI: out of memory\n"); goto done; } res->path[0] = 0; /* * a) All but the last segment of the base URI's path component is * copied to the buffer. In other words, any characters after the * last (right-most) slash character, if any, are excluded. */ cur = 0; out = 0; if (bas->path != NULL) { while (bas->path[cur] != 0) { while ((bas->path[cur] != 0) && (bas->path[cur] != '/')) cur++; if (bas->path[cur] == 0) break; cur++; while (out < cur) { res->path[out] = bas->path[out]; out++; } } } res->path[out] = 0; /* * b) The reference's path component is appended to the buffer * string. */ if (ref->path != NULL && ref->path[0] != 0) { indx = 0; /* * Ensure the path includes a '/' */ if ((out == 0) && (bas->server != NULL)) res->path[out++] = '/'; while (ref->path[indx] != 0) { res->path[out++] = ref->path[indx++]; } } res->path[out] = 0; /* * Steps c) to h) are really path normalization steps */ xmlNormalizeURIPath(res->path); step_7: /* * 7) The resulting URI components, including any inherited from the * base URI, are recombined to give the absolute form of the URI * reference. */ val = xmlSaveUri(res); done: if (ref != NULL) xmlFreeURI(ref); if (bas != NULL) xmlFreeURI(bas); if (res != NULL) xmlFreeURI(res); return(val); } /** * xmlBuildRelativeURI: * @URI: the URI reference under consideration * @base: the base value * * Expresses the URI of the reference in terms relative to the * base. Some examples of this operation include: * base = "http://site1.com/docs/book1.html" * URI input URI returned * docs/pic1.gif pic1.gif * docs/img/pic1.gif img/pic1.gif * img/pic1.gif ../img/pic1.gif * http://site1.com/docs/pic1.gif pic1.gif * http://site2.com/docs/pic1.gif http://site2.com/docs/pic1.gif * * base = "docs/book1.html" * URI input URI returned * docs/pic1.gif pic1.gif * docs/img/pic1.gif img/pic1.gif * img/pic1.gif ../img/pic1.gif * http://site1.com/docs/pic1.gif http://site1.com/docs/pic1.gif * * * Note: if the URI reference is really wierd or complicated, it may be * worthwhile to first convert it into a "nice" one by calling * xmlBuildURI (using 'base') before calling this routine, * since this routine (for reasonable efficiency) assumes URI has * already been through some validation. * * Returns a new URI string (to be freed by the caller) or NULL in case * error. */ xmlChar * xmlBuildRelativeURI (const xmlChar * URI, const xmlChar * base) { xmlChar *val = NULL; int ret; int ix; int pos = 0; int nbslash = 0; int len; xmlURIPtr ref = NULL; xmlURIPtr bas = NULL; xmlChar *bptr, *uptr, *vptr; int remove_path = 0; if ((URI == NULL) || (*URI == 0)) return NULL; /* * First parse URI into a standard form */ ref = xmlCreateURI (); if (ref == NULL) return NULL; /* If URI not already in "relative" form */ if (URI[0] != '.') { ret = xmlParseURIReference (ref, (const char *) URI); if (ret != 0) goto done; /* Error in URI, return NULL */ } else ref->path = (char *)xmlStrdup(URI); /* * Next parse base into the same standard form */ if ((base == NULL) || (*base == 0)) { val = xmlStrdup (URI); goto done; } bas = xmlCreateURI (); if (bas == NULL) goto done; if (base[0] != '.') { ret = xmlParseURIReference (bas, (const char *) base); if (ret != 0) goto done; /* Error in base, return NULL */ } else bas->path = (char *)xmlStrdup(base); /* * If the scheme / server on the URI differs from the base, * just return the URI */ if ((ref->scheme != NULL) && ((bas->scheme == NULL) || (xmlStrcmp ((xmlChar *)bas->scheme, (xmlChar *)ref->scheme)) || (xmlStrcmp ((xmlChar *)bas->server, (xmlChar *)ref->server)))) { val = xmlStrdup (URI); goto done; } if (xmlStrEqual((xmlChar *)bas->path, (xmlChar *)ref->path)) { val = xmlStrdup(BAD_CAST ""); goto done; } if (bas->path == NULL) { val = xmlStrdup((xmlChar *)ref->path); goto done; } if (ref->path == NULL) { ref->path = (char *) "/"; remove_path = 1; } /* * At this point (at last!) we can compare the two paths * * First we take care of the special case where either of the * two path components may be missing (bug 316224) */ if (bas->path == NULL) { if (ref->path != NULL) { uptr = (xmlChar *) ref->path; if (*uptr == '/') uptr++; val = xmlStrdup(uptr); } goto done; } bptr = (xmlChar *)bas->path; if (ref->path == NULL) { for (ix = 0; bptr[ix] != 0; ix++) { if (bptr[ix] == '/') nbslash++; } uptr = NULL; len = 1; /* this is for a string terminator only */ } else { /* * Next we compare the two strings and find where they first differ */ if ((ref->path[pos] == '.') && (ref->path[pos+1] == '/')) pos += 2; if ((*bptr == '.') && (bptr[1] == '/')) bptr += 2; else if ((*bptr == '/') && (ref->path[pos] != '/')) bptr++; while ((bptr[pos] == ref->path[pos]) && (bptr[pos] != 0)) pos++; if (bptr[pos] == ref->path[pos]) { val = xmlStrdup(BAD_CAST ""); goto done; /* (I can't imagine why anyone would do this) */ } /* * In URI, "back up" to the last '/' encountered. This will be the * beginning of the "unique" suffix of URI */ ix = pos; if ((ref->path[ix] == '/') && (ix > 0)) ix--; else if ((ref->path[ix] == 0) && (ix > 1) && (ref->path[ix - 1] == '/')) ix -= 2; for (; ix > 0; ix--) { if (ref->path[ix] == '/') break; } if (ix == 0) { uptr = (xmlChar *)ref->path; } else { ix++; uptr = (xmlChar *)&ref->path[ix]; } /* * In base, count the number of '/' from the differing point */ if (bptr[pos] != ref->path[pos]) {/* check for trivial URI == base */ for (; bptr[ix] != 0; ix++) { if (bptr[ix] == '/') nbslash++; } } len = xmlStrlen (uptr) + 1; } if (nbslash == 0) { if (uptr != NULL) val = xmlStrdup (uptr); goto done; } /* * Allocate just enough space for the returned string - * length of the remainder of the URI, plus enough space * for the "../" groups, plus one for the terminator */ val = (xmlChar *) xmlMalloc (len + 3 * nbslash); if (val == NULL) { xmlGenericError(xmlGenericErrorContext, "xmlBuildRelativeURI: out of memory\n"); goto done; } vptr = val; /* * Put in as many "../" as needed */ for (; nbslash>0; nbslash--) { *vptr++ = '.'; *vptr++ = '.'; *vptr++ = '/'; } /* * Finish up with the end of the URI */ if (uptr != NULL) { if ((vptr > val) && (len > 0) && (uptr[0] == '/') && (vptr[-1] == '/')) { memcpy (vptr, uptr + 1, len - 1); vptr[len - 2] = 0; } else { memcpy (vptr, uptr, len); vptr[len - 1] = 0; } } else { vptr[len - 1] = 0; } done: /* * Free the working variables */ if (remove_path != 0) ref->path = NULL; if (ref != NULL) xmlFreeURI (ref); if (bas != NULL) xmlFreeURI (bas); return val; } /** * xmlCanonicPath: * @path: the resource locator in a filesystem notation * * Constructs a canonic path from the specified path. * * Returns a new canonic path, or a duplicate of the path parameter if the * construction fails. The caller is responsible for freeing the memory occupied * by the returned string. If there is insufficient memory available, or the * argument is NULL, the function returns NULL. */ #define IS_WINDOWS_PATH(p) \ ((p != NULL) && \ (((p[0] >= 'a') && (p[0] <= 'z')) || \ ((p[0] >= 'A') && (p[0] <= 'Z'))) && \ (p[1] == ':') && ((p[2] == '/') || (p[2] == '\\'))) xmlChar * xmlCanonicPath(const xmlChar *path) { #if defined(_WIN32) && !defined(__CYGWIN__) int len = 0; /*int i = 0;*/ xmlChar *p = NULL; #endif xmlURIPtr uri; xmlChar *ret; const xmlChar *absuri; if (path == NULL) return(NULL); if ((uri = xmlParseURI((const char *) path)) != NULL) { xmlFreeURI(uri); return xmlStrdup(path); } absuri = xmlStrstr(path, BAD_CAST "://"); if (absuri != NULL) { int l, j; unsigned char c; xmlChar *escURI; /* * this looks like an URI where some parts have not been * escaped leading to a parsing problem check that the first * part matches a protocol. */ l = absuri - path; if ((l <= 0) || (l > 20)) goto path_processing; for (j = 0;j < l;j++) { c = path[j]; if (!(((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z')))) goto path_processing; } escURI = xmlURIEscapeStr(path, BAD_CAST ":/?_.#&;="); if (escURI != NULL) { uri = xmlParseURI((const char *) escURI); if (uri != NULL) { xmlFreeURI(uri); return escURI; } xmlFreeURI(uri); } } path_processing: #if defined(_WIN32) && !defined(__CYGWIN__) /* * This really need to be cleaned up by someone with a Windows box */ uri = xmlCreateURI(); if (uri == NULL) { return(NULL); } len = xmlStrlen(path); if ((len > 2) && IS_WINDOWS_PATH(path)) { uri->scheme = xmlStrdup(BAD_CAST "file"); uri->path = xmlMallocAtomic(len + 2); if (uri->path == NULL) { xmlFreeURI(uri); return(NULL); } uri->path[0] = '/'; p = uri->path + 1; strncpy(p, path, len + 1); } else { uri->path = xmlStrdup(path); if (uri->path == NULL) { xmlFreeURI(uri); return(NULL); } p = uri->path; } while (*p != '\0') { if (*p == '\\') *p = '/'; p++; } if (uri->path == NULL) { xmlFreeURI(uri); return(NULL); } if (uri->scheme == NULL) { ret = xmlStrdup((const xmlChar *) path); } else { ret = xmlSaveUri(uri); } xmlFreeURI(uri); #else ret = xmlStrdup((const xmlChar *) path); #endif return(ret); } /** * xmlPathToURI: * @path: the resource locator in a filesystem notation * * Constructs an URI expressing the existing path * * Returns a new URI, or a duplicate of the path parameter if the * construction fails. The caller is responsible for freeing the memory * occupied by the returned string. If there is insufficient memory available, * or the argument is NULL, the function returns NULL. */ xmlChar * xmlPathToURI(const xmlChar *path) { xmlURIPtr uri; xmlURI temp; xmlChar *ret, *cal; if (path == NULL) return(NULL); if ((uri = xmlParseURI((const char *) path)) != NULL) { xmlFreeURI(uri); return xmlStrdup(path); } cal = xmlCanonicPath(path); if (cal == NULL) return(NULL); memset(&temp, 0, sizeof(temp)); temp.path = (char *) cal; ret = xmlSaveUri(&temp); xmlFree(cal); return(ret); } #define bottom_uri #include "elfgcchack.h" xdmf-3.0+git20160803/Utilities/vtklibxml2/nanoftp.c0000640000175000017500000016102413003006557021760 0ustar alastairalastair/* * nanoftp.c: basic FTP client support * * Reference: RFC 959 */ #ifdef TESTING #define STANDALONE #define HAVE_STDLIB_H #define HAVE_UNISTD_H #define HAVE_SYS_SOCKET_H #define HAVE_NETINET_IN_H #define HAVE_NETDB_H #define HAVE_SYS_TIME_H #else /* TESTING */ #define NEED_SOCKETS #endif /* TESTING */ #define IN_LIBXML #include "libxml.h" #ifdef LIBXML_FTP_ENABLED #include #ifdef HAVE_STDLIB_H #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_ARPA_INET_H #include #endif #ifdef HAVE_NETDB_H #include #endif #ifdef HAVE_FCNTL_H #include #endif #ifdef HAVE_ERRNO_H #include #endif #ifdef HAVE_SYS_TIME_H #include #endif #ifdef HAVE_SYS_SELECT_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_STRINGS_H #include #endif #include #include #include #include #include #include /* #define DEBUG_FTP 1 */ #ifdef STANDALONE #ifndef DEBUG_FTP #define DEBUG_FTP 1 #endif #endif #ifdef __MINGW32__ #define _WINSOCKAPI_ #include #include #undef XML_SOCKLEN_T #define XML_SOCKLEN_T unsigned int #endif /** * A couple portability macros */ #ifndef _WINSOCKAPI_ #ifndef __BEOS__ #define closesocket(s) close(s) #endif #define SOCKET int #endif #ifdef __BEOS__ #ifndef PF_INET #define PF_INET AF_INET #endif #endif #ifdef _AIX #define ss_family __ss_family #endif #ifndef XML_SOCKLEN_T #define XML_SOCKLEN_T unsigned int #endif #define FTP_COMMAND_OK 200 #define FTP_SYNTAX_ERROR 500 #define FTP_GET_PASSWD 331 #define FTP_BUF_SIZE 1024 #define XML_NANO_MAX_URLBUF 4096 typedef struct xmlNanoFTPCtxt { char *protocol; /* the protocol name */ char *hostname; /* the host name */ int port; /* the port */ char *path; /* the path within the URL */ char *user; /* user string */ char *passwd; /* passwd string */ #ifdef SUPPORT_IP6 struct sockaddr_storage ftpAddr; /* this is large enough to hold IPv6 address*/ #else struct sockaddr_in ftpAddr; /* the socket address struct */ #endif int passive; /* currently we support only passive !!! */ SOCKET controlFd; /* the file descriptor for the control socket */ SOCKET dataFd; /* the file descriptor for the data socket */ int state; /* WRITE / READ / CLOSED */ int returnValue; /* the protocol return value */ /* buffer for data received from the control connection */ char controlBuf[FTP_BUF_SIZE + 1]; int controlBufIndex; int controlBufUsed; int controlBufAnswer; } xmlNanoFTPCtxt, *xmlNanoFTPCtxtPtr; static int initialized = 0; static char *proxy = NULL; /* the proxy name if any */ static int proxyPort = 0; /* the proxy port if any */ static char *proxyUser = NULL; /* user for proxy authentication */ static char *proxyPasswd = NULL;/* passwd for proxy authentication */ static int proxyType = 0; /* uses TYPE or a@b ? */ #ifdef SUPPORT_IP6 static int have_ipv6(void) { int s; s = socket (AF_INET6, SOCK_STREAM, 0); if (s != -1) { close (s); return (1); } return (0); } #endif /** * xmlFTPErrMemory: * @extra: extra informations * * Handle an out of memory condition */ static void xmlFTPErrMemory(const char *extra) { __xmlSimpleError(XML_FROM_FTP, XML_ERR_NO_MEMORY, NULL, NULL, extra); } /** * xmlNanoFTPInit: * * Initialize the FTP protocol layer. * Currently it just checks for proxy informations, * and get the hostname */ void xmlNanoFTPInit(void) { const char *env; #ifdef _WINSOCKAPI_ WSADATA wsaData; #endif if (initialized) return; #ifdef _WINSOCKAPI_ if (WSAStartup(MAKEWORD(1, 1), &wsaData) != 0) return; #endif proxyPort = 21; env = getenv("no_proxy"); if (env && ((env[0] == '*' ) && (env[1] == 0))) return; env = getenv("ftp_proxy"); if (env != NULL) { xmlNanoFTPScanProxy(env); } else { env = getenv("FTP_PROXY"); if (env != NULL) { xmlNanoFTPScanProxy(env); } } env = getenv("ftp_proxy_user"); if (env != NULL) { proxyUser = xmlMemStrdup(env); } env = getenv("ftp_proxy_password"); if (env != NULL) { proxyPasswd = xmlMemStrdup(env); } initialized = 1; } /** * xmlNanoFTPCleanup: * * Cleanup the FTP protocol layer. This cleanup proxy informations. */ void xmlNanoFTPCleanup(void) { if (proxy != NULL) { xmlFree(proxy); proxy = NULL; } if (proxyUser != NULL) { xmlFree(proxyUser); proxyUser = NULL; } if (proxyPasswd != NULL) { xmlFree(proxyPasswd); proxyPasswd = NULL; } #ifdef _WINSOCKAPI_ if (initialized) WSACleanup(); #endif initialized = 0; } /** * xmlNanoFTPProxy: * @host: the proxy host name * @port: the proxy port * @user: the proxy user name * @passwd: the proxy password * @type: the type of proxy 1 for using SITE, 2 for USER a@b * * Setup the FTP proxy informations. * This can also be done by using ftp_proxy ftp_proxy_user and * ftp_proxy_password environment variables. */ void xmlNanoFTPProxy(const char *host, int port, const char *user, const char *passwd, int type) { if (proxy != NULL) { xmlFree(proxy); proxy = NULL; } if (proxyUser != NULL) { xmlFree(proxyUser); proxyUser = NULL; } if (proxyPasswd != NULL) { xmlFree(proxyPasswd); proxyPasswd = NULL; } if (host) proxy = xmlMemStrdup(host); if (user) proxyUser = xmlMemStrdup(user); if (passwd) proxyPasswd = xmlMemStrdup(passwd); proxyPort = port; proxyType = type; } /** * xmlNanoFTPScanURL: * @ctx: an FTP context * @URL: The URL used to initialize the context * * (Re)Initialize an FTP context by parsing the URL and finding * the protocol host port and path it indicates. */ static void xmlNanoFTPScanURL(void *ctx, const char *URL) { xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; xmlURIPtr uri; /* * Clear any existing data from the context */ if (ctxt->protocol != NULL) { xmlFree(ctxt->protocol); ctxt->protocol = NULL; } if (ctxt->hostname != NULL) { xmlFree(ctxt->hostname); ctxt->hostname = NULL; } if (ctxt->path != NULL) { xmlFree(ctxt->path); ctxt->path = NULL; } if (URL == NULL) return; uri = xmlParseURIRaw(URL, 1); if (uri == NULL) return; if ((uri->scheme == NULL) || (uri->server == NULL)) { xmlFreeURI(uri); return; } ctxt->protocol = xmlMemStrdup(uri->scheme); ctxt->hostname = xmlMemStrdup(uri->server); if (uri->path != NULL) ctxt->path = xmlMemStrdup(uri->path); else ctxt->path = xmlMemStrdup("/"); if (uri->port != 0) ctxt->port = uri->port; if (uri->user != NULL) { char *cptr; if ((cptr=strchr(uri->user, ':')) == NULL) ctxt->user = xmlMemStrdup(uri->user); else { ctxt->user = (char *)xmlStrndup((xmlChar *)uri->user, (cptr - uri->user)); ctxt->passwd = xmlMemStrdup(cptr+1); } } xmlFreeURI(uri); } /** * xmlNanoFTPUpdateURL: * @ctx: an FTP context * @URL: The URL used to update the context * * Update an FTP context by parsing the URL and finding * new path it indicates. If there is an error in the * protocol, hostname, port or other information, the * error is raised. It indicates a new connection has to * be established. * * Returns 0 if Ok, -1 in case of error (other host). */ int xmlNanoFTPUpdateURL(void *ctx, const char *URL) { xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; xmlURIPtr uri; if (URL == NULL) return(-1); if (ctxt == NULL) return(-1); if (ctxt->protocol == NULL) return(-1); if (ctxt->hostname == NULL) return(-1); uri = xmlParseURIRaw(URL, 1); if (uri == NULL) return(-1); if ((uri->scheme == NULL) || (uri->server == NULL)) { xmlFreeURI(uri); return(-1); } if ((strcmp(ctxt->protocol, uri->scheme)) || (strcmp(ctxt->hostname, uri->server)) || ((uri->port != 0) && (ctxt->port != uri->port))) { xmlFreeURI(uri); return(-1); } if (uri->port != 0) ctxt->port = uri->port; if (ctxt->path != NULL) { xmlFree(ctxt->path); ctxt->path = NULL; } if (uri->path == NULL) ctxt->path = xmlMemStrdup("/"); else ctxt->path = xmlMemStrdup(uri->path); xmlFreeURI(uri); return(0); } /** * xmlNanoFTPScanProxy: * @URL: The proxy URL used to initialize the proxy context * * (Re)Initialize the FTP Proxy context by parsing the URL and finding * the protocol host port it indicates. * Should be like ftp://myproxy/ or ftp://myproxy:3128/ * A NULL URL cleans up proxy informations. */ void xmlNanoFTPScanProxy(const char *URL) { xmlURIPtr uri; if (proxy != NULL) { xmlFree(proxy); proxy = NULL; } proxyPort = 0; #ifdef DEBUG_FTP if (URL == NULL) xmlGenericError(xmlGenericErrorContext, "Removing FTP proxy info\n"); else xmlGenericError(xmlGenericErrorContext, "Using FTP proxy %s\n", URL); #endif if (URL == NULL) return; uri = xmlParseURIRaw(URL, 1); if ((uri == NULL) || (uri->scheme == NULL) || (strcmp(uri->scheme, "ftp")) || (uri->server == NULL)) { __xmlIOErr(XML_FROM_FTP, XML_FTP_URL_SYNTAX, "Syntax Error\n"); if (uri != NULL) xmlFreeURI(uri); return; } proxy = xmlMemStrdup(uri->server); if (uri->port != 0) proxyPort = uri->port; xmlFreeURI(uri); } /** * xmlNanoFTPNewCtxt: * @URL: The URL used to initialize the context * * Allocate and initialize a new FTP context. * * Returns an FTP context or NULL in case of error. */ void* xmlNanoFTPNewCtxt(const char *URL) { xmlNanoFTPCtxtPtr ret; char *unescaped; ret = (xmlNanoFTPCtxtPtr) xmlMalloc(sizeof(xmlNanoFTPCtxt)); if (ret == NULL) { xmlFTPErrMemory("allocating FTP context"); return(NULL); } memset(ret, 0, sizeof(xmlNanoFTPCtxt)); ret->port = 21; ret->passive = 1; ret->returnValue = 0; ret->controlBufIndex = 0; ret->controlBufUsed = 0; ret->controlFd = -1; unescaped = xmlURIUnescapeString(URL, 0, NULL); if (unescaped != NULL) { xmlNanoFTPScanURL(ret, unescaped); xmlFree(unescaped); } else if (URL != NULL) xmlNanoFTPScanURL(ret, URL); return(ret); } /** * xmlNanoFTPFreeCtxt: * @ctx: an FTP context * * Frees the context after closing the connection. */ void xmlNanoFTPFreeCtxt(void * ctx) { xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; if (ctxt == NULL) return; if (ctxt->hostname != NULL) xmlFree(ctxt->hostname); if (ctxt->protocol != NULL) xmlFree(ctxt->protocol); if (ctxt->path != NULL) xmlFree(ctxt->path); ctxt->passive = 1; if (ctxt->controlFd >= 0) closesocket(ctxt->controlFd); ctxt->controlFd = -1; ctxt->controlBufIndex = -1; ctxt->controlBufUsed = -1; xmlFree(ctxt); } /** * xmlNanoFTPParseResponse: * @buf: the buffer containing the response * @len: the buffer length * * Parsing of the server answer, we just extract the code. * * returns 0 for errors * +XXX for last line of response * -XXX for response to be continued */ static int xmlNanoFTPParseResponse(char *buf, int len) { int val = 0; if (len < 3) return(-1); if ((*buf >= '0') && (*buf <= '9')) val = val * 10 + (*buf - '0'); else return(0); buf++; if ((*buf >= '0') && (*buf <= '9')) val = val * 10 + (*buf - '0'); else return(0); buf++; if ((*buf >= '0') && (*buf <= '9')) val = val * 10 + (*buf - '0'); else return(0); buf++; if (*buf == '-') return(-val); return(val); } /** * xmlNanoFTPGetMore: * @ctx: an FTP context * * Read more information from the FTP control connection * Returns the number of bytes read, < 0 indicates an error */ static int xmlNanoFTPGetMore(void *ctx) { xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; int len; int size; if ((ctxt == NULL) || (ctxt->controlFd < 0)) return(-1); if ((ctxt->controlBufIndex < 0) || (ctxt->controlBufIndex > FTP_BUF_SIZE)) { #ifdef DEBUG_FTP xmlGenericError(xmlGenericErrorContext, "xmlNanoFTPGetMore : controlBufIndex = %d\n", ctxt->controlBufIndex); #endif return(-1); } if ((ctxt->controlBufUsed < 0) || (ctxt->controlBufUsed > FTP_BUF_SIZE)) { #ifdef DEBUG_FTP xmlGenericError(xmlGenericErrorContext, "xmlNanoFTPGetMore : controlBufUsed = %d\n", ctxt->controlBufUsed); #endif return(-1); } if (ctxt->controlBufIndex > ctxt->controlBufUsed) { #ifdef DEBUG_FTP xmlGenericError(xmlGenericErrorContext, "xmlNanoFTPGetMore : controlBufIndex > controlBufUsed %d > %d\n", ctxt->controlBufIndex, ctxt->controlBufUsed); #endif return(-1); } /* * First pack the control buffer */ if (ctxt->controlBufIndex > 0) { memmove(&ctxt->controlBuf[0], &ctxt->controlBuf[ctxt->controlBufIndex], ctxt->controlBufUsed - ctxt->controlBufIndex); ctxt->controlBufUsed -= ctxt->controlBufIndex; ctxt->controlBufIndex = 0; } size = FTP_BUF_SIZE - ctxt->controlBufUsed; if (size == 0) { #ifdef DEBUG_FTP xmlGenericError(xmlGenericErrorContext, "xmlNanoFTPGetMore : buffer full %d \n", ctxt->controlBufUsed); #endif return(0); } /* * Read the amount left on the control connection */ if ((len = recv(ctxt->controlFd, &ctxt->controlBuf[ctxt->controlBufIndex], size, 0)) < 0) { __xmlIOErr(XML_FROM_FTP, 0, "recv failed"); closesocket(ctxt->controlFd); ctxt->controlFd = -1; ctxt->controlFd = -1; return(-1); } #ifdef DEBUG_FTP xmlGenericError(xmlGenericErrorContext, "xmlNanoFTPGetMore : read %d [%d - %d]\n", len, ctxt->controlBufUsed, ctxt->controlBufUsed + len); #endif ctxt->controlBufUsed += len; ctxt->controlBuf[ctxt->controlBufUsed] = 0; return(len); } /** * xmlNanoFTPReadResponse: * @ctx: an FTP context * * Read the response from the FTP server after a command. * Returns the code number */ static int xmlNanoFTPReadResponse(void *ctx) { xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; char *ptr, *end; int len; int res = -1, cur = -1; if ((ctxt == NULL) || (ctxt->controlFd < 0)) return(-1); get_more: /* * Assumes everything up to controlBuf[controlBufIndex] has been read * and analyzed. */ len = xmlNanoFTPGetMore(ctx); if (len < 0) { return(-1); } if ((ctxt->controlBufUsed == 0) && (len == 0)) { return(-1); } ptr = &ctxt->controlBuf[ctxt->controlBufIndex]; end = &ctxt->controlBuf[ctxt->controlBufUsed]; #ifdef DEBUG_FTP xmlGenericError(xmlGenericErrorContext, "\n<<<\n%s\n--\n", ptr); #endif while (ptr < end) { cur = xmlNanoFTPParseResponse(ptr, end - ptr); if (cur > 0) { /* * Successfully scanned the control code, scratch * till the end of the line, but keep the index to be * able to analyze the result if needed. */ res = cur; ptr += 3; ctxt->controlBufAnswer = ptr - ctxt->controlBuf; while ((ptr < end) && (*ptr != '\n')) ptr++; if (*ptr == '\n') ptr++; if (*ptr == '\r') ptr++; break; } while ((ptr < end) && (*ptr != '\n')) ptr++; if (ptr >= end) { ctxt->controlBufIndex = ctxt->controlBufUsed; goto get_more; } if (*ptr != '\r') ptr++; } if (res < 0) goto get_more; ctxt->controlBufIndex = ptr - ctxt->controlBuf; #ifdef DEBUG_FTP ptr = &ctxt->controlBuf[ctxt->controlBufIndex]; xmlGenericError(xmlGenericErrorContext, "\n---\n%s\n--\n", ptr); #endif #ifdef DEBUG_FTP xmlGenericError(xmlGenericErrorContext, "Got %d\n", res); #endif return(res / 100); } /** * xmlNanoFTPGetResponse: * @ctx: an FTP context * * Get the response from the FTP server after a command. * Returns the code number */ int xmlNanoFTPGetResponse(void *ctx) { int res; res = xmlNanoFTPReadResponse(ctx); return(res); } /** * xmlNanoFTPCheckResponse: * @ctx: an FTP context * * Check if there is a response from the FTP server after a command. * Returns the code number, or 0 */ int xmlNanoFTPCheckResponse(void *ctx) { xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; fd_set rfd; struct timeval tv; if ((ctxt == NULL) || (ctxt->controlFd < 0)) return(-1); tv.tv_sec = 0; tv.tv_usec = 0; FD_ZERO(&rfd); FD_SET(ctxt->controlFd, &rfd); switch(select(ctxt->controlFd + 1, &rfd, NULL, NULL, &tv)) { case 0: return(0); case -1: __xmlIOErr(XML_FROM_FTP, 0, "select"); return(-1); } return(xmlNanoFTPReadResponse(ctx)); } /** * Send the user authentication */ static int xmlNanoFTPSendUser(void *ctx) { xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; char buf[200]; int len; int res; if (ctxt->user == NULL) snprintf(buf, sizeof(buf), "USER anonymous\r\n"); else snprintf(buf, sizeof(buf), "USER %s\r\n", ctxt->user); buf[sizeof(buf) - 1] = 0; len = strlen(buf); #ifdef DEBUG_FTP xmlGenericError(xmlGenericErrorContext, "%s", buf); #endif res = send(ctxt->controlFd, buf, len, 0); if (res < 0) { __xmlIOErr(XML_FROM_FTP, 0, "send failed"); return(res); } return(0); } /** * Send the password authentication */ static int xmlNanoFTPSendPasswd(void *ctx) { xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; char buf[200]; int len; int res; if (ctxt->passwd == NULL) snprintf(buf, sizeof(buf), "PASS anonymous@\r\n"); else snprintf(buf, sizeof(buf), "PASS %s\r\n", ctxt->passwd); buf[sizeof(buf) - 1] = 0; len = strlen(buf); #ifdef DEBUG_FTP xmlGenericError(xmlGenericErrorContext, "%s", buf); #endif res = send(ctxt->controlFd, buf, len, 0); if (res < 0) { __xmlIOErr(XML_FROM_FTP, 0, "send failed"); return(res); } return(0); } /** * xmlNanoFTPQuit: * @ctx: an FTP context * * Send a QUIT command to the server * * Returns -1 in case of error, 0 otherwise */ int xmlNanoFTPQuit(void *ctx) { xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; char buf[200]; int len, res; if ((ctxt == NULL) || (ctxt->controlFd < 0)) return(-1); snprintf(buf, sizeof(buf), "QUIT\r\n"); len = strlen(buf); #ifdef DEBUG_FTP xmlGenericError(xmlGenericErrorContext, "%s", buf); /* Just to be consistent, even though we know it can't have a % in it */ #endif res = send(ctxt->controlFd, buf, len, 0); if (res < 0) { __xmlIOErr(XML_FROM_FTP, 0, "send failed"); return(res); } return(0); } /** * xmlNanoFTPConnect: * @ctx: an FTP context * * Tries to open a control connection * * Returns -1 in case of error, 0 otherwise */ int xmlNanoFTPConnect(void *ctx) { xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; struct hostent *hp; int port; int res; int addrlen = sizeof (struct sockaddr_in); if (ctxt == NULL) return(-1); if (ctxt->hostname == NULL) return(-1); /* * do the blocking DNS query. */ if (proxy) { port = proxyPort; } else { port = ctxt->port; } if (port == 0) port = 21; memset (&ctxt->ftpAddr, 0, sizeof(ctxt->ftpAddr)); #ifdef SUPPORT_IP6 if (have_ipv6 ()) { struct addrinfo hints, *tmp, *result; result = NULL; memset (&hints, 0, sizeof(hints)); hints.ai_socktype = SOCK_STREAM; if (proxy) { if (getaddrinfo (proxy, NULL, &hints, &result) != 0) { __xmlIOErr(XML_FROM_FTP, 0, "getaddrinfo failed"); return (-1); } } else if (getaddrinfo (ctxt->hostname, NULL, &hints, &result) != 0) { __xmlIOErr(XML_FROM_FTP, 0, "getaddrinfo failed"); return (-1); } for (tmp = result; tmp; tmp = tmp->ai_next) if (tmp->ai_family == AF_INET || tmp->ai_family == AF_INET6) break; if (!tmp) { if (result) freeaddrinfo (result); __xmlIOErr(XML_FROM_FTP, 0, "getaddrinfo failed"); return (-1); } if (tmp->ai_addrlen > sizeof(ctxt->ftpAddr)) { __xmlIOErr(XML_FROM_FTP, 0, "gethostbyname address mismatch"); return (-1); } if (tmp->ai_family == AF_INET6) { memcpy (&ctxt->ftpAddr, tmp->ai_addr, tmp->ai_addrlen); ((struct sockaddr_in6 *) &ctxt->ftpAddr)->sin6_port = htons (port); ctxt->controlFd = socket (AF_INET6, SOCK_STREAM, 0); } else { memcpy (&ctxt->ftpAddr, tmp->ai_addr, tmp->ai_addrlen); ((struct sockaddr_in *) &ctxt->ftpAddr)->sin_port = htons (port); ctxt->controlFd = socket (AF_INET, SOCK_STREAM, 0); } addrlen = tmp->ai_addrlen; freeaddrinfo (result); } else #endif { if (proxy) hp = gethostbyname (proxy); else hp = gethostbyname (ctxt->hostname); if (hp == NULL) { __xmlIOErr(XML_FROM_FTP, 0, "gethostbyname failed"); return (-1); } if ((unsigned int) hp->h_length > sizeof(((struct sockaddr_in *)&ctxt->ftpAddr)->sin_addr)) { __xmlIOErr(XML_FROM_FTP, 0, "gethostbyname address mismatch"); return (-1); } /* * Prepare the socket */ ((struct sockaddr_in *)&ctxt->ftpAddr)->sin_family = AF_INET; memcpy (&((struct sockaddr_in *)&ctxt->ftpAddr)->sin_addr, hp->h_addr_list[0], hp->h_length); ((struct sockaddr_in *)&ctxt->ftpAddr)->sin_port = (u_short)htons ((unsigned short)port); ctxt->controlFd = socket (AF_INET, SOCK_STREAM, 0); addrlen = sizeof (struct sockaddr_in); } if (ctxt->controlFd < 0) { __xmlIOErr(XML_FROM_FTP, 0, "socket failed"); return(-1); } /* * Do the connect. */ if (connect(ctxt->controlFd, (struct sockaddr *) &ctxt->ftpAddr, addrlen) < 0) { __xmlIOErr(XML_FROM_FTP, 0, "Failed to create a connection"); closesocket(ctxt->controlFd); ctxt->controlFd = -1; ctxt->controlFd = -1; return(-1); } /* * Wait for the HELLO from the server. */ res = xmlNanoFTPGetResponse(ctxt); if (res != 2) { closesocket(ctxt->controlFd); ctxt->controlFd = -1; ctxt->controlFd = -1; return(-1); } /* * State diagram for the login operation on the FTP server * * Reference: RFC 959 * * 1 * +---+ USER +---+------------->+---+ * | B |---------->| W | 2 ---->| E | * +---+ +---+------ | -->+---+ * | | | | | * 3 | | 4,5 | | | * -------------- ----- | | | * | | | | | * | | | | | * | --------- | * | 1| | | | * V | | | | * +---+ PASS +---+ 2 | ------>+---+ * | |---------->| W |------------->| S | * +---+ +---+ ---------->+---+ * | | | | | * 3 | |4,5| | | * -------------- -------- | * | | | | | * | | | | | * | ----------- * | 1,3| | | | * V | 2| | | * +---+ ACCT +---+-- | ----->+---+ * | |---------->| W | 4,5 -------->| F | * +---+ +---+------------->+---+ * * Of course in case of using a proxy this get really nasty and is not * standardized at all :-( */ if (proxy) { int len; char buf[400]; if (proxyUser != NULL) { /* * We need proxy auth */ snprintf(buf, sizeof(buf), "USER %s\r\n", proxyUser); buf[sizeof(buf) - 1] = 0; len = strlen(buf); #ifdef DEBUG_FTP xmlGenericError(xmlGenericErrorContext, "%s", buf); #endif res = send(ctxt->controlFd, buf, len, 0); if (res < 0) { __xmlIOErr(XML_FROM_FTP, 0, "send failed"); closesocket(ctxt->controlFd); ctxt->controlFd = -1; return(res); } res = xmlNanoFTPGetResponse(ctxt); switch (res) { case 2: if (proxyPasswd == NULL) break; case 3: if (proxyPasswd != NULL) snprintf(buf, sizeof(buf), "PASS %s\r\n", proxyPasswd); else snprintf(buf, sizeof(buf), "PASS anonymous@\r\n"); buf[sizeof(buf) - 1] = 0; len = strlen(buf); #ifdef DEBUG_FTP xmlGenericError(xmlGenericErrorContext, "%s", buf); #endif res = send(ctxt->controlFd, buf, len, 0); if (res < 0) { __xmlIOErr(XML_FROM_FTP, 0, "send failed"); closesocket(ctxt->controlFd); ctxt->controlFd = -1; return(res); } res = xmlNanoFTPGetResponse(ctxt); if (res > 3) { closesocket(ctxt->controlFd); ctxt->controlFd = -1; return(-1); } break; case 1: break; case 4: case 5: case -1: default: closesocket(ctxt->controlFd); ctxt->controlFd = -1; return(-1); } } /* * We assume we don't need more authentication to the proxy * and that it succeeded :-\ */ switch (proxyType) { case 0: /* we will try in sequence */ case 1: /* Using SITE command */ snprintf(buf, sizeof(buf), "SITE %s\r\n", ctxt->hostname); buf[sizeof(buf) - 1] = 0; len = strlen(buf); #ifdef DEBUG_FTP xmlGenericError(xmlGenericErrorContext, "%s", buf); #endif res = send(ctxt->controlFd, buf, len, 0); if (res < 0) { __xmlIOErr(XML_FROM_FTP, 0, "send failed"); closesocket(ctxt->controlFd); ctxt->controlFd = -1; ctxt->controlFd = -1; return(res); } res = xmlNanoFTPGetResponse(ctxt); if (res == 2) { /* we assume it worked :-\ 1 is error for SITE command */ proxyType = 1; break; } if (proxyType == 1) { closesocket(ctxt->controlFd); ctxt->controlFd = -1; ctxt->controlFd = -1; return(-1); } case 2: /* USER user@host command */ if (ctxt->user == NULL) snprintf(buf, sizeof(buf), "USER anonymous@%s\r\n", ctxt->hostname); else snprintf(buf, sizeof(buf), "USER %s@%s\r\n", ctxt->user, ctxt->hostname); buf[sizeof(buf) - 1] = 0; len = strlen(buf); #ifdef DEBUG_FTP xmlGenericError(xmlGenericErrorContext, "%s", buf); #endif res = send(ctxt->controlFd, buf, len, 0); if (res < 0) { __xmlIOErr(XML_FROM_FTP, 0, "send failed"); closesocket(ctxt->controlFd); ctxt->controlFd = -1; ctxt->controlFd = -1; return(res); } res = xmlNanoFTPGetResponse(ctxt); if ((res == 1) || (res == 2)) { /* we assume it worked :-\ */ proxyType = 2; return(0); } if (ctxt->passwd == NULL) snprintf(buf, sizeof(buf), "PASS anonymous@\r\n"); else snprintf(buf, sizeof(buf), "PASS %s\r\n", ctxt->passwd); buf[sizeof(buf) - 1] = 0; len = strlen(buf); #ifdef DEBUG_FTP xmlGenericError(xmlGenericErrorContext, "%s", buf); #endif res = send(ctxt->controlFd, buf, len, 0); if (res < 0) { __xmlIOErr(XML_FROM_FTP, 0, "send failed"); closesocket(ctxt->controlFd); ctxt->controlFd = -1; ctxt->controlFd = -1; return(res); } res = xmlNanoFTPGetResponse(ctxt); if ((res == 1) || (res == 2)) { /* we assume it worked :-\ */ proxyType = 2; return(0); } if (proxyType == 2) { closesocket(ctxt->controlFd); ctxt->controlFd = -1; ctxt->controlFd = -1; return(-1); } case 3: /* * If you need support for other Proxy authentication scheme * send the code or at least the sequence in use. */ default: closesocket(ctxt->controlFd); ctxt->controlFd = -1; ctxt->controlFd = -1; return(-1); } } /* * Non-proxy handling. */ res = xmlNanoFTPSendUser(ctxt); if (res < 0) { closesocket(ctxt->controlFd); ctxt->controlFd = -1; ctxt->controlFd = -1; return(-1); } res = xmlNanoFTPGetResponse(ctxt); switch (res) { case 2: return(0); case 3: break; case 1: case 4: case 5: case -1: default: closesocket(ctxt->controlFd); ctxt->controlFd = -1; ctxt->controlFd = -1; return(-1); } res = xmlNanoFTPSendPasswd(ctxt); if (res < 0) { closesocket(ctxt->controlFd); ctxt->controlFd = -1; ctxt->controlFd = -1; return(-1); } res = xmlNanoFTPGetResponse(ctxt); switch (res) { case 2: break; case 3: __xmlIOErr(XML_FROM_FTP, XML_FTP_ACCNT, "FTP server asking for ACCNT on anonymous\n"); case 1: case 4: case 5: case -1: default: closesocket(ctxt->controlFd); ctxt->controlFd = -1; ctxt->controlFd = -1; return(-1); } return(0); } /** * xmlNanoFTPConnectTo: * @server: an FTP server name * @port: the port (use 21 if 0) * * Tries to open a control connection to the given server/port * * Returns an fTP context or NULL if it failed */ void* xmlNanoFTPConnectTo(const char *server, int port) { xmlNanoFTPCtxtPtr ctxt; int res; xmlNanoFTPInit(); if (server == NULL) return(NULL); if (port <= 0) return(NULL); ctxt = (xmlNanoFTPCtxtPtr) xmlNanoFTPNewCtxt(NULL); ctxt->hostname = xmlMemStrdup(server); if (port != 0) ctxt->port = port; res = xmlNanoFTPConnect(ctxt); if (res < 0) { xmlNanoFTPFreeCtxt(ctxt); return(NULL); } return(ctxt); } /** * xmlNanoFTPCwd: * @ctx: an FTP context * @directory: a directory on the server * * Tries to change the remote directory * * Returns -1 incase of error, 1 if CWD worked, 0 if it failed */ int xmlNanoFTPCwd(void *ctx, const char *directory) { xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; char buf[400]; int len; int res; if ((ctxt == NULL) || (ctxt->controlFd < 0)) return(-1); if (directory == NULL) return 0; /* * Expected response code for CWD: * * CWD * 250 * 500, 501, 502, 421, 530, 550 */ snprintf(buf, sizeof(buf), "CWD %s\r\n", directory); buf[sizeof(buf) - 1] = 0; len = strlen(buf); #ifdef DEBUG_FTP xmlGenericError(xmlGenericErrorContext, "%s", buf); #endif res = send(ctxt->controlFd, buf, len, 0); if (res < 0) { __xmlIOErr(XML_FROM_FTP, 0, "send failed"); return(res); } res = xmlNanoFTPGetResponse(ctxt); if (res == 4) { return(-1); } if (res == 2) return(1); if (res == 5) { return(0); } return(0); } /** * xmlNanoFTPDele: * @ctx: an FTP context * @file: a file or directory on the server * * Tries to delete an item (file or directory) from server * * Returns -1 incase of error, 1 if DELE worked, 0 if it failed */ int xmlNanoFTPDele(void *ctx, const char *file) { xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; char buf[400]; int len; int res; if ((ctxt == NULL) || (ctxt->controlFd < 0) || (file == NULL)) return(-1); if (file == NULL) return (0); /* * Expected response code for DELE: * * DELE * 250 * 450, 550 * 500, 501, 502, 421, 530 */ snprintf(buf, sizeof(buf), "DELE %s\r\n", file); buf[sizeof(buf) - 1] = 0; len = strlen(buf); #ifdef DEBUG_FTP xmlGenericError(xmlGenericErrorContext, "%s", buf); #endif res = send(ctxt->controlFd, buf, len, 0); if (res < 0) { __xmlIOErr(XML_FROM_FTP, 0, "send failed"); return(res); } res = xmlNanoFTPGetResponse(ctxt); if (res == 4) { return(-1); } if (res == 2) return(1); if (res == 5) { return(0); } return(0); } /** * xmlNanoFTPGetConnection: * @ctx: an FTP context * * Try to open a data connection to the server. Currently only * passive mode is supported. * * Returns -1 incase of error, 0 otherwise */ int xmlNanoFTPGetConnection(void *ctx) { xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; char buf[200], *cur; int len, i; int res; unsigned char ad[6], *adp, *portp; unsigned int temp[6]; #ifdef SUPPORT_IP6 struct sockaddr_storage dataAddr; #else struct sockaddr_in dataAddr; #endif XML_SOCKLEN_T dataAddrLen; if (ctxt == NULL) return(-1); memset (&dataAddr, 0, sizeof(dataAddr)); #ifdef SUPPORT_IP6 if ((ctxt->ftpAddr).ss_family == AF_INET6) { ctxt->dataFd = socket (AF_INET6, SOCK_STREAM, IPPROTO_TCP); ((struct sockaddr_in6 *)&dataAddr)->sin6_family = AF_INET6; dataAddrLen = sizeof(struct sockaddr_in6); } else #endif { ctxt->dataFd = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); ((struct sockaddr_in *)&dataAddr)->sin_family = AF_INET; dataAddrLen = sizeof (struct sockaddr_in); } if (ctxt->dataFd < 0) { __xmlIOErr(XML_FROM_FTP, 0, "socket failed"); return (-1); } if (ctxt->passive) { #ifdef SUPPORT_IP6 if ((ctxt->ftpAddr).ss_family == AF_INET6) snprintf (buf, sizeof(buf), "EPSV\r\n"); else #endif snprintf (buf, sizeof(buf), "PASV\r\n"); len = strlen (buf); #ifdef DEBUG_FTP xmlGenericError(xmlGenericErrorContext, "%s", buf); #endif res = send(ctxt->controlFd, buf, len, 0); if (res < 0) { __xmlIOErr(XML_FROM_FTP, 0, "send failed"); closesocket(ctxt->dataFd); ctxt->dataFd = -1; return(res); } res = xmlNanoFTPReadResponse(ctx); if (res != 2) { if (res == 5) { closesocket(ctxt->dataFd); ctxt->dataFd = -1; return(-1); } else { /* * retry with an active connection */ closesocket(ctxt->dataFd); ctxt->dataFd = -1; ctxt->passive = 0; } } cur = &ctxt->controlBuf[ctxt->controlBufAnswer]; while (((*cur < '0') || (*cur > '9')) && *cur != '\0') cur++; #ifdef SUPPORT_IP6 if ((ctxt->ftpAddr).ss_family == AF_INET6) { if (sscanf (cur, "%u", &temp[0]) != 1) { __xmlIOErr(XML_FROM_FTP, XML_FTP_EPSV_ANSWER, "Invalid answer to EPSV\n"); if (ctxt->dataFd != -1) { closesocket (ctxt->dataFd); ctxt->dataFd = -1; } return (-1); } memcpy (&((struct sockaddr_in6 *)&dataAddr)->sin6_addr, &((struct sockaddr_in6 *)&ctxt->ftpAddr)->sin6_addr, sizeof(struct in6_addr)); ((struct sockaddr_in6 *)&dataAddr)->sin6_port = htons (temp[0]); } else #endif { if (sscanf (cur, "%u,%u,%u,%u,%u,%u", &temp[0], &temp[1], &temp[2], &temp[3], &temp[4], &temp[5]) != 6) { __xmlIOErr(XML_FROM_FTP, XML_FTP_PASV_ANSWER, "Invalid answer to PASV\n"); if (ctxt->dataFd != -1) { closesocket (ctxt->dataFd); ctxt->dataFd = -1; } return (-1); } for (i=0; i<6; i++) ad[i] = (unsigned char) (temp[i] & 0xff); memcpy (&((struct sockaddr_in *)&dataAddr)->sin_addr, &ad[0], 4); memcpy (&((struct sockaddr_in *)&dataAddr)->sin_port, &ad[4], 2); } if (connect(ctxt->dataFd, (struct sockaddr *) &dataAddr, dataAddrLen) < 0) { __xmlIOErr(XML_FROM_FTP, 0, "Failed to create a data connection"); closesocket(ctxt->dataFd); ctxt->dataFd = -1; return (-1); } } else { getsockname(ctxt->dataFd, (struct sockaddr *) &dataAddr, &dataAddrLen); #ifdef SUPPORT_IP6 if ((ctxt->ftpAddr).ss_family == AF_INET6) ((struct sockaddr_in6 *)&dataAddr)->sin6_port = 0; else #endif ((struct sockaddr_in *)&dataAddr)->sin_port = 0; if (bind(ctxt->dataFd, (struct sockaddr *) &dataAddr, dataAddrLen) < 0) { __xmlIOErr(XML_FROM_FTP, 0, "bind failed"); closesocket(ctxt->dataFd); ctxt->dataFd = -1; return (-1); } getsockname(ctxt->dataFd, (struct sockaddr *) &dataAddr, &dataAddrLen); if (listen(ctxt->dataFd, 1) < 0) { __xmlIOErr(XML_FROM_FTP, 0, "listen failed"); closesocket(ctxt->dataFd); ctxt->dataFd = -1; return (-1); } #ifdef SUPPORT_IP6 if ((ctxt->ftpAddr).ss_family == AF_INET6) { char buf6[INET6_ADDRSTRLEN]; inet_ntop (AF_INET6, &((struct sockaddr_in6 *)&dataAddr)->sin6_addr, buf6, INET6_ADDRSTRLEN); adp = (unsigned char *) buf6; portp = (unsigned char *) &((struct sockaddr_in6 *)&dataAddr)->sin6_port; snprintf (buf, sizeof(buf), "EPRT |2|%s|%s|\r\n", adp, portp); } else #endif { adp = (unsigned char *) &((struct sockaddr_in *)&dataAddr)->sin_addr; portp = (unsigned char *) &((struct sockaddr_in *)&dataAddr)->sin_port; snprintf (buf, sizeof(buf), "PORT %d,%d,%d,%d,%d,%d\r\n", adp[0] & 0xff, adp[1] & 0xff, adp[2] & 0xff, adp[3] & 0xff, portp[0] & 0xff, portp[1] & 0xff); } buf[sizeof(buf) - 1] = 0; len = strlen(buf); #ifdef DEBUG_FTP xmlGenericError(xmlGenericErrorContext, "%s", buf); #endif res = send(ctxt->controlFd, buf, len, 0); if (res < 0) { __xmlIOErr(XML_FROM_FTP, 0, "send failed"); closesocket(ctxt->dataFd); ctxt->dataFd = -1; return(res); } res = xmlNanoFTPGetResponse(ctxt); if (res != 2) { closesocket(ctxt->dataFd); ctxt->dataFd = -1; return(-1); } } return(ctxt->dataFd); } /** * xmlNanoFTPCloseConnection: * @ctx: an FTP context * * Close the data connection from the server * * Returns -1 incase of error, 0 otherwise */ int xmlNanoFTPCloseConnection(void *ctx) { xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; int res; fd_set rfd, efd; struct timeval tv; if ((ctxt == NULL) || (ctxt->controlFd < 0)) return(-1); closesocket(ctxt->dataFd); ctxt->dataFd = -1; tv.tv_sec = 15; tv.tv_usec = 0; FD_ZERO(&rfd); FD_SET(ctxt->controlFd, &rfd); FD_ZERO(&efd); FD_SET(ctxt->controlFd, &efd); res = select(ctxt->controlFd + 1, &rfd, NULL, &efd, &tv); if (res < 0) { #ifdef DEBUG_FTP perror("select"); #endif closesocket(ctxt->controlFd); ctxt->controlFd = -1; return(-1); } if (res == 0) { #ifdef DEBUG_FTP xmlGenericError(xmlGenericErrorContext, "xmlNanoFTPCloseConnection: timeout\n"); #endif closesocket(ctxt->controlFd); ctxt->controlFd = -1; } else { res = xmlNanoFTPGetResponse(ctxt); if (res != 2) { closesocket(ctxt->controlFd); ctxt->controlFd = -1; return(-1); } } return(0); } /** * xmlNanoFTPParseList: * @list: some data listing received from the server * @callback: the user callback * @userData: the user callback data * * Parse at most one entry from the listing. * * Returns -1 incase of error, the length of data parsed otherwise */ static int xmlNanoFTPParseList(const char *list, ftpListCallback callback, void *userData) { const char *cur = list; char filename[151]; char attrib[11]; char owner[11]; char group[11]; char month[4]; int year = 0; int minute = 0; int hour = 0; int day = 0; unsigned long size = 0; int links = 0; int i; if (!strncmp(cur, "total", 5)) { cur += 5; while (*cur == ' ') cur++; while ((*cur >= '0') && (*cur <= '9')) links = (links * 10) + (*cur++ - '0'); while ((*cur == ' ') || (*cur == '\n') || (*cur == '\r')) cur++; return(cur - list); } else if (*list == '+') { return(0); } else { while ((*cur == ' ') || (*cur == '\n') || (*cur == '\r')) cur++; if (*cur == 0) return(0); i = 0; while (*cur != ' ') { if (i < 10) attrib[i++] = *cur; cur++; if (*cur == 0) return(0); } attrib[10] = 0; while (*cur == ' ') cur++; if (*cur == 0) return(0); while ((*cur >= '0') && (*cur <= '9')) links = (links * 10) + (*cur++ - '0'); while (*cur == ' ') cur++; if (*cur == 0) return(0); i = 0; while (*cur != ' ') { if (i < 10) owner[i++] = *cur; cur++; if (*cur == 0) return(0); } owner[i] = 0; while (*cur == ' ') cur++; if (*cur == 0) return(0); i = 0; while (*cur != ' ') { if (i < 10) group[i++] = *cur; cur++; if (*cur == 0) return(0); } group[i] = 0; while (*cur == ' ') cur++; if (*cur == 0) return(0); while ((*cur >= '0') && (*cur <= '9')) size = (size * 10) + (*cur++ - '0'); while (*cur == ' ') cur++; if (*cur == 0) return(0); i = 0; while (*cur != ' ') { if (i < 3) month[i++] = *cur; cur++; if (*cur == 0) return(0); } month[i] = 0; while (*cur == ' ') cur++; if (*cur == 0) return(0); while ((*cur >= '0') && (*cur <= '9')) day = (day * 10) + (*cur++ - '0'); while (*cur == ' ') cur++; if (*cur == 0) return(0); if ((cur[1] == 0) || (cur[2] == 0)) return(0); if ((cur[1] == ':') || (cur[2] == ':')) { while ((*cur >= '0') && (*cur <= '9')) hour = (hour * 10) + (*cur++ - '0'); if (*cur == ':') cur++; while ((*cur >= '0') && (*cur <= '9')) minute = (minute * 10) + (*cur++ - '0'); } else { while ((*cur >= '0') && (*cur <= '9')) year = (year * 10) + (*cur++ - '0'); } while (*cur == ' ') cur++; if (*cur == 0) return(0); i = 0; while ((*cur != '\n') && (*cur != '\r')) { if (i < 150) filename[i++] = *cur; cur++; if (*cur == 0) return(0); } filename[i] = 0; if ((*cur != '\n') && (*cur != '\r')) return(0); while ((*cur == '\n') || (*cur == '\r')) cur++; } if (callback != NULL) { callback(userData, filename, attrib, owner, group, size, links, year, month, day, hour, minute); } return(cur - list); } /** * xmlNanoFTPList: * @ctx: an FTP context * @callback: the user callback * @userData: the user callback data * @filename: optional files to list * * Do a listing on the server. All files info are passed back * in the callbacks. * * Returns -1 incase of error, 0 otherwise */ int xmlNanoFTPList(void *ctx, ftpListCallback callback, void *userData, const char *filename) { xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; char buf[4096 + 1]; int len, res; int indx = 0, base; fd_set rfd, efd; struct timeval tv; if (ctxt == NULL) return (-1); if (filename == NULL) { if (xmlNanoFTPCwd(ctxt, ctxt->path) < 1) return(-1); ctxt->dataFd = xmlNanoFTPGetConnection(ctxt); if (ctxt->dataFd == -1) return(-1); snprintf(buf, sizeof(buf), "LIST -L\r\n"); } else { if (filename[0] != '/') { if (xmlNanoFTPCwd(ctxt, ctxt->path) < 1) return(-1); } ctxt->dataFd = xmlNanoFTPGetConnection(ctxt); if (ctxt->dataFd == -1) return(-1); snprintf(buf, sizeof(buf), "LIST -L %s\r\n", filename); } buf[sizeof(buf) - 1] = 0; len = strlen(buf); #ifdef DEBUG_FTP xmlGenericError(xmlGenericErrorContext, "%s", buf); #endif res = send(ctxt->controlFd, buf, len, 0); if (res < 0) { __xmlIOErr(XML_FROM_FTP, 0, "send failed"); closesocket(ctxt->dataFd); ctxt->dataFd = -1; return(res); } res = xmlNanoFTPReadResponse(ctxt); if (res != 1) { closesocket(ctxt->dataFd); ctxt->dataFd = -1; return(-res); } do { tv.tv_sec = 1; tv.tv_usec = 0; FD_ZERO(&rfd); FD_SET(ctxt->dataFd, &rfd); FD_ZERO(&efd); FD_SET(ctxt->dataFd, &efd); res = select(ctxt->dataFd + 1, &rfd, NULL, &efd, &tv); if (res < 0) { #ifdef DEBUG_FTP perror("select"); #endif closesocket(ctxt->dataFd); ctxt->dataFd = -1; return(-1); } if (res == 0) { res = xmlNanoFTPCheckResponse(ctxt); if (res < 0) { closesocket(ctxt->dataFd); ctxt->dataFd = -1; ctxt->dataFd = -1; return(-1); } if (res == 2) { closesocket(ctxt->dataFd); ctxt->dataFd = -1; return(0); } continue; } if ((len = recv(ctxt->dataFd, &buf[indx], sizeof(buf) - (indx + 1), 0)) < 0) { __xmlIOErr(XML_FROM_FTP, 0, "recv"); closesocket(ctxt->dataFd); ctxt->dataFd = -1; ctxt->dataFd = -1; return(-1); } #ifdef DEBUG_FTP write(1, &buf[indx], len); #endif indx += len; buf[indx] = 0; base = 0; do { res = xmlNanoFTPParseList(&buf[base], callback, userData); base += res; } while (res > 0); memmove(&buf[0], &buf[base], indx - base); indx -= base; } while (len != 0); xmlNanoFTPCloseConnection(ctxt); return(0); } /** * xmlNanoFTPGetSocket: * @ctx: an FTP context * @filename: the file to retrieve (or NULL if path is in context). * * Initiate fetch of the given file from the server. * * Returns the socket for the data connection, or <0 in case of error */ int xmlNanoFTPGetSocket(void *ctx, const char *filename) { xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; char buf[300]; int res, len; if (ctx == NULL) return(-1); if ((filename == NULL) && (ctxt->path == NULL)) return(-1); ctxt->dataFd = xmlNanoFTPGetConnection(ctxt); if (ctxt->dataFd == -1) return(-1); snprintf(buf, sizeof(buf), "TYPE I\r\n"); len = strlen(buf); #ifdef DEBUG_FTP xmlGenericError(xmlGenericErrorContext, "%s", buf); #endif res = send(ctxt->controlFd, buf, len, 0); if (res < 0) { __xmlIOErr(XML_FROM_FTP, 0, "send failed"); closesocket(ctxt->dataFd); ctxt->dataFd = -1; return(res); } res = xmlNanoFTPReadResponse(ctxt); if (res != 2) { closesocket(ctxt->dataFd); ctxt->dataFd = -1; return(-res); } if (filename == NULL) snprintf(buf, sizeof(buf), "RETR %s\r\n", ctxt->path); else snprintf(buf, sizeof(buf), "RETR %s\r\n", filename); buf[sizeof(buf) - 1] = 0; len = strlen(buf); #ifdef DEBUG_FTP xmlGenericError(xmlGenericErrorContext, "%s", buf); #endif res = send(ctxt->controlFd, buf, len, 0); if (res < 0) { __xmlIOErr(XML_FROM_FTP, 0, "send failed"); closesocket(ctxt->dataFd); ctxt->dataFd = -1; return(res); } res = xmlNanoFTPReadResponse(ctxt); if (res != 1) { closesocket(ctxt->dataFd); ctxt->dataFd = -1; return(-res); } return(ctxt->dataFd); } /** * xmlNanoFTPGet: * @ctx: an FTP context * @callback: the user callback * @userData: the user callback data * @filename: the file to retrieve * * Fetch the given file from the server. All data are passed back * in the callbacks. The last callback has a size of 0 block. * * Returns -1 incase of error, 0 otherwise */ int xmlNanoFTPGet(void *ctx, ftpDataCallback callback, void *userData, const char *filename) { xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; char buf[4096]; int len = 0, res; fd_set rfd; struct timeval tv; if (ctxt == NULL) return(-1); if ((filename == NULL) && (ctxt->path == NULL)) return(-1); if (callback == NULL) return(-1); if (xmlNanoFTPGetSocket(ctxt, filename) < 0) return(-1); do { tv.tv_sec = 1; tv.tv_usec = 0; FD_ZERO(&rfd); FD_SET(ctxt->dataFd, &rfd); res = select(ctxt->dataFd + 1, &rfd, NULL, NULL, &tv); if (res < 0) { #ifdef DEBUG_FTP perror("select"); #endif closesocket(ctxt->dataFd); ctxt->dataFd = -1; return(-1); } if (res == 0) { res = xmlNanoFTPCheckResponse(ctxt); if (res < 0) { closesocket(ctxt->dataFd); ctxt->dataFd = -1; ctxt->dataFd = -1; return(-1); } if (res == 2) { closesocket(ctxt->dataFd); ctxt->dataFd = -1; return(0); } continue; } if ((len = recv(ctxt->dataFd, buf, sizeof(buf), 0)) < 0) { __xmlIOErr(XML_FROM_FTP, 0, "recv failed"); callback(userData, buf, len); closesocket(ctxt->dataFd); ctxt->dataFd = -1; return(-1); } callback(userData, buf, len); } while (len != 0); return(xmlNanoFTPCloseConnection(ctxt)); } /** * xmlNanoFTPRead: * @ctx: the FTP context * @dest: a buffer * @len: the buffer length * * This function tries to read @len bytes from the existing FTP connection * and saves them in @dest. This is a blocking call. * * Returns the number of byte read. 0 is an indication of an end of connection. * -1 indicates a parameter error. */ int xmlNanoFTPRead(void *ctx, void *dest, int len) { xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; if (ctx == NULL) return(-1); if (ctxt->dataFd < 0) return(0); if (dest == NULL) return(-1); if (len <= 0) return(0); len = recv(ctxt->dataFd, dest, len, 0); if (len <= 0) { if (len < 0) __xmlIOErr(XML_FROM_FTP, 0, "recv failed"); xmlNanoFTPCloseConnection(ctxt); } #ifdef DEBUG_FTP xmlGenericError(xmlGenericErrorContext, "Recvd %d bytes\n", len); #endif return(len); } /** * xmlNanoFTPOpen: * @URL: the URL to the resource * * Start to fetch the given ftp:// resource * * Returns an FTP context, or NULL */ void* xmlNanoFTPOpen(const char *URL) { xmlNanoFTPCtxtPtr ctxt; int sock; xmlNanoFTPInit(); if (URL == NULL) return(NULL); if (strncmp("ftp://", URL, 6)) return(NULL); ctxt = (xmlNanoFTPCtxtPtr) xmlNanoFTPNewCtxt(URL); if (ctxt == NULL) return(NULL); if (xmlNanoFTPConnect(ctxt) < 0) { xmlNanoFTPFreeCtxt(ctxt); return(NULL); } sock = xmlNanoFTPGetSocket(ctxt, ctxt->path); if (sock < 0) { xmlNanoFTPFreeCtxt(ctxt); return(NULL); } return(ctxt); } /** * xmlNanoFTPClose: * @ctx: an FTP context * * Close the connection and both control and transport * * Returns -1 incase of error, 0 otherwise */ int xmlNanoFTPClose(void *ctx) { xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; if (ctxt == NULL) return(-1); if (ctxt->dataFd >= 0) { closesocket(ctxt->dataFd); ctxt->dataFd = -1; } if (ctxt->controlFd >= 0) { xmlNanoFTPQuit(ctxt); closesocket(ctxt->controlFd); ctxt->controlFd = -1; } xmlNanoFTPFreeCtxt(ctxt); return(0); } #ifdef STANDALONE /************************************************************************ * * * Basic test in Standalone mode * * * ************************************************************************/ static void ftpList(void *userData, const char *filename, const char* attrib, const char *owner, const char *group, unsigned long size, int links, int year, const char *month, int day, int hour, int minute) { xmlGenericError(xmlGenericErrorContext, "%s %s %s %ld %s\n", attrib, owner, group, size, filename); } static void ftpData(void *userData, const char *data, int len) { if (userData == NULL) return; if (len <= 0) { fclose((FILE*)userData); return; } fwrite(data, len, 1, (FILE*)userData); } int main(int argc, char **argv) { void *ctxt; FILE *output; char *tstfile = NULL; xmlNanoFTPInit(); if (argc > 1) { ctxt = xmlNanoFTPNewCtxt(argv[1]); if (xmlNanoFTPConnect(ctxt) < 0) { xmlGenericError(xmlGenericErrorContext, "Couldn't connect to %s\n", argv[1]); exit(1); } if (argc > 2) tstfile = argv[2]; } else ctxt = xmlNanoFTPConnectTo("localhost", 0); if (ctxt == NULL) { xmlGenericError(xmlGenericErrorContext, "Couldn't connect to localhost\n"); exit(1); } xmlNanoFTPList(ctxt, ftpList, NULL, tstfile); output = fopen("/tmp/tstdata", "w"); if (output != NULL) { if (xmlNanoFTPGet(ctxt, ftpData, (void *) output, tstfile) < 0) xmlGenericError(xmlGenericErrorContext, "Failed to get file\n"); } xmlNanoFTPClose(ctxt); xmlMemoryDump(); exit(0); } #endif /* STANDALONE */ #else /* !LIBXML_FTP_ENABLED */ #ifdef STANDALONE #include int main(int argc, char **argv) { xmlGenericError(xmlGenericErrorContext, "%s : FTP support not compiled in\n", argv[0]); return(0); } #endif /* STANDALONE */ #endif /* LIBXML_FTP_ENABLED */ #define bottom_nanoftp #include "elfgcchack.h" xdmf-3.0+git20160803/Utilities/vtklibxml2/xmlregexp.c0000640000175000017500000076070513003006557022341 0ustar alastairalastair/* * regexp.c: generic and extensible Regular Expression engine * * Basically designed with the purpose of compiling regexps for * the variety of validation/shemas mechanisms now available in * XML related specifications these include: * - XML-1.0 DTD validation * - XML Schemas structure part 1 * - XML Schemas Datatypes part 2 especially Appendix F * - RELAX-NG/TREX i.e. the counter proposal * * See Copyright for the status of this software. * * Daniel Veillard */ #define IN_LIBXML #include "libxml.h" #ifdef LIBXML_REGEXP_ENABLED /* #define DEBUG_ERR */ #include #include #ifdef HAVE_LIMITS_H #include #endif #include #include #include #include #include #ifndef INT_MAX #define INT_MAX 123456789 /* easy to flag and big enough for our needs */ #endif /* #define DEBUG_REGEXP_GRAPH */ /* #define DEBUG_REGEXP_EXEC */ /* #define DEBUG_PUSH */ /* #define DEBUG_COMPACTION */ #define MAX_PUSH 10000000 #define ERROR(str) \ ctxt->error = XML_REGEXP_COMPILE_ERROR; \ xmlRegexpErrCompile(ctxt, str); #define NEXT ctxt->cur++ #define CUR (*(ctxt->cur)) #define NXT(index) (ctxt->cur[index]) #define CUR_SCHAR(s, l) xmlStringCurrentChar(NULL, s, &l) #define NEXTL(l) ctxt->cur += l; #define XML_REG_STRING_SEPARATOR '|' /** * TODO: * * macro to flag unimplemented blocks */ #define TODO \ xmlGenericError(xmlGenericErrorContext, \ "Unimplemented block at %s:%d\n", \ __FILE__, __LINE__); /************************************************************************ * * * Datatypes and structures * * * ************************************************************************/ /* * Note: the order of the enums below is significant, do not shuffle */ typedef enum { XML_REGEXP_EPSILON = 1, XML_REGEXP_CHARVAL, XML_REGEXP_RANGES, XML_REGEXP_SUBREG, /* used for () sub regexps */ XML_REGEXP_STRING, XML_REGEXP_ANYCHAR, /* . */ XML_REGEXP_ANYSPACE, /* \s */ XML_REGEXP_NOTSPACE, /* \S */ XML_REGEXP_INITNAME, /* \l */ XML_REGEXP_NOTINITNAME, /* \L */ XML_REGEXP_NAMECHAR, /* \c */ XML_REGEXP_NOTNAMECHAR, /* \C */ XML_REGEXP_DECIMAL, /* \d */ XML_REGEXP_NOTDECIMAL, /* \D */ XML_REGEXP_REALCHAR, /* \w */ XML_REGEXP_NOTREALCHAR, /* \W */ XML_REGEXP_LETTER = 100, XML_REGEXP_LETTER_UPPERCASE, XML_REGEXP_LETTER_LOWERCASE, XML_REGEXP_LETTER_TITLECASE, XML_REGEXP_LETTER_MODIFIER, XML_REGEXP_LETTER_OTHERS, XML_REGEXP_MARK, XML_REGEXP_MARK_NONSPACING, XML_REGEXP_MARK_SPACECOMBINING, XML_REGEXP_MARK_ENCLOSING, XML_REGEXP_NUMBER, XML_REGEXP_NUMBER_DECIMAL, XML_REGEXP_NUMBER_LETTER, XML_REGEXP_NUMBER_OTHERS, XML_REGEXP_PUNCT, XML_REGEXP_PUNCT_CONNECTOR, XML_REGEXP_PUNCT_DASH, XML_REGEXP_PUNCT_OPEN, XML_REGEXP_PUNCT_CLOSE, XML_REGEXP_PUNCT_INITQUOTE, XML_REGEXP_PUNCT_FINQUOTE, XML_REGEXP_PUNCT_OTHERS, XML_REGEXP_SEPAR, XML_REGEXP_SEPAR_SPACE, XML_REGEXP_SEPAR_LINE, XML_REGEXP_SEPAR_PARA, XML_REGEXP_SYMBOL, XML_REGEXP_SYMBOL_MATH, XML_REGEXP_SYMBOL_CURRENCY, XML_REGEXP_SYMBOL_MODIFIER, XML_REGEXP_SYMBOL_OTHERS, XML_REGEXP_OTHER, XML_REGEXP_OTHER_CONTROL, XML_REGEXP_OTHER_FORMAT, XML_REGEXP_OTHER_PRIVATE, XML_REGEXP_OTHER_NA, XML_REGEXP_BLOCK_NAME } xmlRegAtomType; typedef enum { XML_REGEXP_QUANT_EPSILON = 1, XML_REGEXP_QUANT_ONCE, XML_REGEXP_QUANT_OPT, XML_REGEXP_QUANT_MULT, XML_REGEXP_QUANT_PLUS, XML_REGEXP_QUANT_ONCEONLY, XML_REGEXP_QUANT_ALL, XML_REGEXP_QUANT_RANGE } xmlRegQuantType; typedef enum { XML_REGEXP_START_STATE = 1, XML_REGEXP_FINAL_STATE, XML_REGEXP_TRANS_STATE, XML_REGEXP_SINK_STATE } xmlRegStateType; typedef enum { XML_REGEXP_MARK_NORMAL = 0, XML_REGEXP_MARK_START, XML_REGEXP_MARK_VISITED } xmlRegMarkedType; typedef struct _xmlRegRange xmlRegRange; typedef xmlRegRange *xmlRegRangePtr; struct _xmlRegRange { int neg; /* 0 normal, 1 not, 2 exclude */ xmlRegAtomType type; int start; int end; xmlChar *blockName; }; typedef struct _xmlRegAtom xmlRegAtom; typedef xmlRegAtom *xmlRegAtomPtr; typedef struct _xmlAutomataState xmlRegState; typedef xmlRegState *xmlRegStatePtr; struct _xmlRegAtom { int no; xmlRegAtomType type; xmlRegQuantType quant; int min; int max; void *valuep; void *valuep2; int neg; int codepoint; xmlRegStatePtr start; xmlRegStatePtr stop; int maxRanges; int nbRanges; xmlRegRangePtr *ranges; void *data; }; typedef struct _xmlRegCounter xmlRegCounter; typedef xmlRegCounter *xmlRegCounterPtr; struct _xmlRegCounter { int min; int max; }; typedef struct _xmlRegTrans xmlRegTrans; typedef xmlRegTrans *xmlRegTransPtr; struct _xmlRegTrans { xmlRegAtomPtr atom; int to; int counter; int count; int nd; }; struct _xmlAutomataState { xmlRegStateType type; xmlRegMarkedType mark; xmlRegMarkedType reached; int no; int maxTrans; int nbTrans; xmlRegTrans *trans; /* knowing states ponting to us can speed things up */ int maxTransTo; int nbTransTo; int *transTo; }; typedef struct _xmlAutomata xmlRegParserCtxt; typedef xmlRegParserCtxt *xmlRegParserCtxtPtr; struct _xmlAutomata { xmlChar *string; xmlChar *cur; int error; int neg; xmlRegStatePtr start; xmlRegStatePtr end; xmlRegStatePtr state; xmlRegAtomPtr atom; int maxAtoms; int nbAtoms; xmlRegAtomPtr *atoms; int maxStates; int nbStates; xmlRegStatePtr *states; int maxCounters; int nbCounters; xmlRegCounter *counters; int determinist; int negs; }; struct _xmlRegexp { xmlChar *string; int nbStates; xmlRegStatePtr *states; int nbAtoms; xmlRegAtomPtr *atoms; int nbCounters; xmlRegCounter *counters; int determinist; /* * That's the compact form for determinists automatas */ int nbstates; int *compact; void **transdata; int nbstrings; xmlChar **stringMap; }; typedef struct _xmlRegExecRollback xmlRegExecRollback; typedef xmlRegExecRollback *xmlRegExecRollbackPtr; struct _xmlRegExecRollback { xmlRegStatePtr state;/* the current state */ int index; /* the index in the input stack */ int nextbranch; /* the next transition to explore in that state */ int *counts; /* save the automata state if it has some */ }; typedef struct _xmlRegInputToken xmlRegInputToken; typedef xmlRegInputToken *xmlRegInputTokenPtr; struct _xmlRegInputToken { xmlChar *value; void *data; }; struct _xmlRegExecCtxt { int status; /* execution status != 0 indicate an error */ int determinist; /* did we find an indeterministic behaviour */ xmlRegexpPtr comp; /* the compiled regexp */ xmlRegExecCallbacks callback; void *data; xmlRegStatePtr state;/* the current state */ int transno; /* the current transition on that state */ int transcount; /* the number of chars in char counted transitions */ /* * A stack of rollback states */ int maxRollbacks; int nbRollbacks; xmlRegExecRollback *rollbacks; /* * The state of the automata if any */ int *counts; /* * The input stack */ int inputStackMax; int inputStackNr; int index; int *charStack; const xmlChar *inputString; /* when operating on characters */ xmlRegInputTokenPtr inputStack;/* when operating on strings */ /* * error handling */ int errStateNo; /* the error state number */ xmlRegStatePtr errState; /* the error state */ xmlChar *errString; /* the string raising the error */ int *errCounts; /* counters at the error state */ int nbPush; }; #define REGEXP_ALL_COUNTER 0x123456 #define REGEXP_ALL_LAX_COUNTER 0x123457 static void xmlFAParseRegExp(xmlRegParserCtxtPtr ctxt, int top); static void xmlRegFreeState(xmlRegStatePtr state); static void xmlRegFreeAtom(xmlRegAtomPtr atom); static int xmlRegStrEqualWildcard(const xmlChar *expStr, const xmlChar *valStr); static int xmlRegCheckCharacter(xmlRegAtomPtr atom, int codepoint); static int xmlRegCheckCharacterRange(xmlRegAtomType type, int codepoint, int neg, int start, int end, const xmlChar *blockName); /************************************************************************ * * * Regexp memory error handler * * * ************************************************************************/ /** * xmlRegexpErrMemory: * @extra: extra information * * Handle an out of memory condition */ static void xmlRegexpErrMemory(xmlRegParserCtxtPtr ctxt, const char *extra) { const char *regexp = NULL; if (ctxt != NULL) { regexp = (const char *) ctxt->string; ctxt->error = XML_ERR_NO_MEMORY; } __xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_REGEXP, XML_ERR_NO_MEMORY, XML_ERR_FATAL, NULL, 0, extra, regexp, NULL, 0, 0, "Memory allocation failed : %s\n", extra); } /** * xmlRegexpErrCompile: * @extra: extra information * * Handle a compilation failure */ static void xmlRegexpErrCompile(xmlRegParserCtxtPtr ctxt, const char *extra) { const char *regexp = NULL; int idx = 0; if (ctxt != NULL) { regexp = (const char *) ctxt->string; idx = ctxt->cur - ctxt->string; ctxt->error = XML_REGEXP_COMPILE_ERROR; } __xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_REGEXP, XML_REGEXP_COMPILE_ERROR, XML_ERR_FATAL, NULL, 0, extra, regexp, NULL, idx, 0, "failed to compile: %s\n", extra); } /************************************************************************ * * * Allocation/Deallocation * * * ************************************************************************/ static int xmlFAComputesDeterminism(xmlRegParserCtxtPtr ctxt); /** * xmlRegEpxFromParse: * @ctxt: the parser context used to build it * * Allocate a new regexp and fill it with the result from the parser * * Returns the new regexp or NULL in case of error */ static xmlRegexpPtr xmlRegEpxFromParse(xmlRegParserCtxtPtr ctxt) { xmlRegexpPtr ret; ret = (xmlRegexpPtr) xmlMalloc(sizeof(xmlRegexp)); if (ret == NULL) { xmlRegexpErrMemory(ctxt, "compiling regexp"); return(NULL); } memset(ret, 0, sizeof(xmlRegexp)); ret->string = ctxt->string; ret->nbStates = ctxt->nbStates; ret->states = ctxt->states; ret->nbAtoms = ctxt->nbAtoms; ret->atoms = ctxt->atoms; ret->nbCounters = ctxt->nbCounters; ret->counters = ctxt->counters; ret->determinist = ctxt->determinist; if (ret->determinist == -1) { xmlRegexpIsDeterminist(ret); } if ((ret->determinist != 0) && (ret->nbCounters == 0) && (ctxt->negs == 0) && (ret->atoms != NULL) && (ret->atoms[0] != NULL) && (ret->atoms[0]->type == XML_REGEXP_STRING)) { int i, j, nbstates = 0, nbatoms = 0; int *stateRemap; int *stringRemap; int *transitions; void **transdata; xmlChar **stringMap; xmlChar *value; /* * Switch to a compact representation * 1/ counting the effective number of states left * 2/ counting the unique number of atoms, and check that * they are all of the string type * 3/ build a table state x atom for the transitions */ stateRemap = xmlMalloc(ret->nbStates * sizeof(int)); if (stateRemap == NULL) { xmlRegexpErrMemory(ctxt, "compiling regexp"); xmlFree(ret); return(NULL); } for (i = 0;i < ret->nbStates;i++) { if (ret->states[i] != NULL) { stateRemap[i] = nbstates; nbstates++; } else { stateRemap[i] = -1; } } #ifdef DEBUG_COMPACTION printf("Final: %d states\n", nbstates); #endif stringMap = xmlMalloc(ret->nbAtoms * sizeof(char *)); if (stringMap == NULL) { xmlRegexpErrMemory(ctxt, "compiling regexp"); xmlFree(stateRemap); xmlFree(ret); return(NULL); } stringRemap = xmlMalloc(ret->nbAtoms * sizeof(int)); if (stringRemap == NULL) { xmlRegexpErrMemory(ctxt, "compiling regexp"); xmlFree(stringMap); xmlFree(stateRemap); xmlFree(ret); return(NULL); } for (i = 0;i < ret->nbAtoms;i++) { if ((ret->atoms[i]->type == XML_REGEXP_STRING) && (ret->atoms[i]->quant == XML_REGEXP_QUANT_ONCE)) { value = ret->atoms[i]->valuep; for (j = 0;j < nbatoms;j++) { if (xmlStrEqual(stringMap[j], value)) { stringRemap[i] = j; break; } } if (j >= nbatoms) { stringRemap[i] = nbatoms; stringMap[nbatoms] = xmlStrdup(value); if (stringMap[nbatoms] == NULL) { for (i = 0;i < nbatoms;i++) xmlFree(stringMap[i]); xmlFree(stringRemap); xmlFree(stringMap); xmlFree(stateRemap); xmlFree(ret); return(NULL); } nbatoms++; } } else { xmlFree(stateRemap); xmlFree(stringRemap); for (i = 0;i < nbatoms;i++) xmlFree(stringMap[i]); xmlFree(stringMap); xmlFree(ret); return(NULL); } } #ifdef DEBUG_COMPACTION printf("Final: %d atoms\n", nbatoms); #endif transitions = (int *) xmlMalloc((nbstates + 1) * (nbatoms + 1) * sizeof(int)); if (transitions == NULL) { xmlFree(stateRemap); xmlFree(stringRemap); xmlFree(stringMap); xmlFree(ret); return(NULL); } memset(transitions, 0, (nbstates + 1) * (nbatoms + 1) * sizeof(int)); /* * Allocate the transition table. The first entry for each * state corresponds to the state type. */ transdata = NULL; for (i = 0;i < ret->nbStates;i++) { int stateno, atomno, targetno, prev; xmlRegStatePtr state; xmlRegTransPtr trans; stateno = stateRemap[i]; if (stateno == -1) continue; state = ret->states[i]; transitions[stateno * (nbatoms + 1)] = state->type; for (j = 0;j < state->nbTrans;j++) { trans = &(state->trans[j]); if ((trans->to == -1) || (trans->atom == NULL)) continue; atomno = stringRemap[trans->atom->no]; if ((trans->atom->data != NULL) && (transdata == NULL)) { transdata = (void **) xmlMalloc(nbstates * nbatoms * sizeof(void *)); if (transdata != NULL) memset(transdata, 0, nbstates * nbatoms * sizeof(void *)); else { xmlRegexpErrMemory(ctxt, "compiling regexp"); break; } } targetno = stateRemap[trans->to]; /* * if the same atom can generate transitions to 2 different * states then it means the automata is not determinist and * the compact form can't be used ! */ prev = transitions[stateno * (nbatoms + 1) + atomno + 1]; if (prev != 0) { if (prev != targetno + 1) { ret->determinist = 0; #ifdef DEBUG_COMPACTION printf("Indet: state %d trans %d, atom %d to %d : %d to %d\n", i, j, trans->atom->no, trans->to, atomno, targetno); printf(" previous to is %d\n", prev); #endif if (transdata != NULL) xmlFree(transdata); xmlFree(transitions); xmlFree(stateRemap); xmlFree(stringRemap); for (i = 0;i < nbatoms;i++) xmlFree(stringMap[i]); xmlFree(stringMap); goto not_determ; } } else { #if 0 printf("State %d trans %d: atom %d to %d : %d to %d\n", i, j, trans->atom->no, trans->to, atomno, targetno); #endif transitions[stateno * (nbatoms + 1) + atomno + 1] = targetno + 1; /* to avoid 0 */ if (transdata != NULL) transdata[stateno * nbatoms + atomno] = trans->atom->data; } } } ret->determinist = 1; #ifdef DEBUG_COMPACTION /* * Debug */ for (i = 0;i < nbstates;i++) { for (j = 0;j < nbatoms + 1;j++) { printf("%02d ", transitions[i * (nbatoms + 1) + j]); } printf("\n"); } printf("\n"); #endif /* * Cleanup of the old data */ if (ret->states != NULL) { for (i = 0;i < ret->nbStates;i++) xmlRegFreeState(ret->states[i]); xmlFree(ret->states); } ret->states = NULL; ret->nbStates = 0; if (ret->atoms != NULL) { for (i = 0;i < ret->nbAtoms;i++) xmlRegFreeAtom(ret->atoms[i]); xmlFree(ret->atoms); } ret->atoms = NULL; ret->nbAtoms = 0; ret->compact = transitions; ret->transdata = transdata; ret->stringMap = stringMap; ret->nbstrings = nbatoms; ret->nbstates = nbstates; xmlFree(stateRemap); xmlFree(stringRemap); } not_determ: ctxt->string = NULL; ctxt->nbStates = 0; ctxt->states = NULL; ctxt->nbAtoms = 0; ctxt->atoms = NULL; ctxt->nbCounters = 0; ctxt->counters = NULL; return(ret); } /** * xmlRegNewParserCtxt: * @string: the string to parse * * Allocate a new regexp parser context * * Returns the new context or NULL in case of error */ static xmlRegParserCtxtPtr xmlRegNewParserCtxt(const xmlChar *string) { xmlRegParserCtxtPtr ret; ret = (xmlRegParserCtxtPtr) xmlMalloc(sizeof(xmlRegParserCtxt)); if (ret == NULL) return(NULL); memset(ret, 0, sizeof(xmlRegParserCtxt)); if (string != NULL) ret->string = xmlStrdup(string); ret->cur = ret->string; ret->neg = 0; ret->negs = 0; ret->error = 0; ret->determinist = -1; return(ret); } /** * xmlRegNewRange: * @ctxt: the regexp parser context * @neg: is that negative * @type: the type of range * @start: the start codepoint * @end: the end codepoint * * Allocate a new regexp range * * Returns the new range or NULL in case of error */ static xmlRegRangePtr xmlRegNewRange(xmlRegParserCtxtPtr ctxt, int neg, xmlRegAtomType type, int start, int end) { xmlRegRangePtr ret; ret = (xmlRegRangePtr) xmlMalloc(sizeof(xmlRegRange)); if (ret == NULL) { xmlRegexpErrMemory(ctxt, "allocating range"); return(NULL); } ret->neg = neg; ret->type = type; ret->start = start; ret->end = end; return(ret); } /** * xmlRegFreeRange: * @range: the regexp range * * Free a regexp range */ static void xmlRegFreeRange(xmlRegRangePtr range) { if (range == NULL) return; if (range->blockName != NULL) xmlFree(range->blockName); xmlFree(range); } /** * xmlRegNewAtom: * @ctxt: the regexp parser context * @type: the type of atom * * Allocate a new regexp range * * Returns the new atom or NULL in case of error */ static xmlRegAtomPtr xmlRegNewAtom(xmlRegParserCtxtPtr ctxt, xmlRegAtomType type) { xmlRegAtomPtr ret; ret = (xmlRegAtomPtr) xmlMalloc(sizeof(xmlRegAtom)); if (ret == NULL) { xmlRegexpErrMemory(ctxt, "allocating atom"); return(NULL); } memset(ret, 0, sizeof(xmlRegAtom)); ret->type = type; ret->quant = XML_REGEXP_QUANT_ONCE; ret->min = 0; ret->max = 0; return(ret); } /** * xmlRegFreeAtom: * @atom: the regexp atom * * Free a regexp atom */ static void xmlRegFreeAtom(xmlRegAtomPtr atom) { int i; if (atom == NULL) return; for (i = 0;i < atom->nbRanges;i++) xmlRegFreeRange(atom->ranges[i]); if (atom->ranges != NULL) xmlFree(atom->ranges); if ((atom->type == XML_REGEXP_STRING) && (atom->valuep != NULL)) xmlFree(atom->valuep); if ((atom->type == XML_REGEXP_STRING) && (atom->valuep2 != NULL)) xmlFree(atom->valuep2); if ((atom->type == XML_REGEXP_BLOCK_NAME) && (atom->valuep != NULL)) xmlFree(atom->valuep); xmlFree(atom); } static xmlRegStatePtr xmlRegNewState(xmlRegParserCtxtPtr ctxt) { xmlRegStatePtr ret; ret = (xmlRegStatePtr) xmlMalloc(sizeof(xmlRegState)); if (ret == NULL) { xmlRegexpErrMemory(ctxt, "allocating state"); return(NULL); } memset(ret, 0, sizeof(xmlRegState)); ret->type = XML_REGEXP_TRANS_STATE; ret->mark = XML_REGEXP_MARK_NORMAL; return(ret); } /** * xmlRegFreeState: * @state: the regexp state * * Free a regexp state */ static void xmlRegFreeState(xmlRegStatePtr state) { if (state == NULL) return; if (state->trans != NULL) xmlFree(state->trans); if (state->transTo != NULL) xmlFree(state->transTo); xmlFree(state); } /** * xmlRegFreeParserCtxt: * @ctxt: the regexp parser context * * Free a regexp parser context */ static void xmlRegFreeParserCtxt(xmlRegParserCtxtPtr ctxt) { int i; if (ctxt == NULL) return; if (ctxt->string != NULL) xmlFree(ctxt->string); if (ctxt->states != NULL) { for (i = 0;i < ctxt->nbStates;i++) xmlRegFreeState(ctxt->states[i]); xmlFree(ctxt->states); } if (ctxt->atoms != NULL) { for (i = 0;i < ctxt->nbAtoms;i++) xmlRegFreeAtom(ctxt->atoms[i]); xmlFree(ctxt->atoms); } if (ctxt->counters != NULL) xmlFree(ctxt->counters); xmlFree(ctxt); } /************************************************************************ * * * Display of Data structures * * * ************************************************************************/ static void xmlRegPrintAtomType(FILE *output, xmlRegAtomType type) { switch (type) { case XML_REGEXP_EPSILON: fprintf(output, "epsilon "); break; case XML_REGEXP_CHARVAL: fprintf(output, "charval "); break; case XML_REGEXP_RANGES: fprintf(output, "ranges "); break; case XML_REGEXP_SUBREG: fprintf(output, "subexpr "); break; case XML_REGEXP_STRING: fprintf(output, "string "); break; case XML_REGEXP_ANYCHAR: fprintf(output, "anychar "); break; case XML_REGEXP_ANYSPACE: fprintf(output, "anyspace "); break; case XML_REGEXP_NOTSPACE: fprintf(output, "notspace "); break; case XML_REGEXP_INITNAME: fprintf(output, "initname "); break; case XML_REGEXP_NOTINITNAME: fprintf(output, "notinitname "); break; case XML_REGEXP_NAMECHAR: fprintf(output, "namechar "); break; case XML_REGEXP_NOTNAMECHAR: fprintf(output, "notnamechar "); break; case XML_REGEXP_DECIMAL: fprintf(output, "decimal "); break; case XML_REGEXP_NOTDECIMAL: fprintf(output, "notdecimal "); break; case XML_REGEXP_REALCHAR: fprintf(output, "realchar "); break; case XML_REGEXP_NOTREALCHAR: fprintf(output, "notrealchar "); break; case XML_REGEXP_LETTER: fprintf(output, "LETTER "); break; case XML_REGEXP_LETTER_UPPERCASE: fprintf(output, "LETTER_UPPERCASE "); break; case XML_REGEXP_LETTER_LOWERCASE: fprintf(output, "LETTER_LOWERCASE "); break; case XML_REGEXP_LETTER_TITLECASE: fprintf(output, "LETTER_TITLECASE "); break; case XML_REGEXP_LETTER_MODIFIER: fprintf(output, "LETTER_MODIFIER "); break; case XML_REGEXP_LETTER_OTHERS: fprintf(output, "LETTER_OTHERS "); break; case XML_REGEXP_MARK: fprintf(output, "MARK "); break; case XML_REGEXP_MARK_NONSPACING: fprintf(output, "MARK_NONSPACING "); break; case XML_REGEXP_MARK_SPACECOMBINING: fprintf(output, "MARK_SPACECOMBINING "); break; case XML_REGEXP_MARK_ENCLOSING: fprintf(output, "MARK_ENCLOSING "); break; case XML_REGEXP_NUMBER: fprintf(output, "NUMBER "); break; case XML_REGEXP_NUMBER_DECIMAL: fprintf(output, "NUMBER_DECIMAL "); break; case XML_REGEXP_NUMBER_LETTER: fprintf(output, "NUMBER_LETTER "); break; case XML_REGEXP_NUMBER_OTHERS: fprintf(output, "NUMBER_OTHERS "); break; case XML_REGEXP_PUNCT: fprintf(output, "PUNCT "); break; case XML_REGEXP_PUNCT_CONNECTOR: fprintf(output, "PUNCT_CONNECTOR "); break; case XML_REGEXP_PUNCT_DASH: fprintf(output, "PUNCT_DASH "); break; case XML_REGEXP_PUNCT_OPEN: fprintf(output, "PUNCT_OPEN "); break; case XML_REGEXP_PUNCT_CLOSE: fprintf(output, "PUNCT_CLOSE "); break; case XML_REGEXP_PUNCT_INITQUOTE: fprintf(output, "PUNCT_INITQUOTE "); break; case XML_REGEXP_PUNCT_FINQUOTE: fprintf(output, "PUNCT_FINQUOTE "); break; case XML_REGEXP_PUNCT_OTHERS: fprintf(output, "PUNCT_OTHERS "); break; case XML_REGEXP_SEPAR: fprintf(output, "SEPAR "); break; case XML_REGEXP_SEPAR_SPACE: fprintf(output, "SEPAR_SPACE "); break; case XML_REGEXP_SEPAR_LINE: fprintf(output, "SEPAR_LINE "); break; case XML_REGEXP_SEPAR_PARA: fprintf(output, "SEPAR_PARA "); break; case XML_REGEXP_SYMBOL: fprintf(output, "SYMBOL "); break; case XML_REGEXP_SYMBOL_MATH: fprintf(output, "SYMBOL_MATH "); break; case XML_REGEXP_SYMBOL_CURRENCY: fprintf(output, "SYMBOL_CURRENCY "); break; case XML_REGEXP_SYMBOL_MODIFIER: fprintf(output, "SYMBOL_MODIFIER "); break; case XML_REGEXP_SYMBOL_OTHERS: fprintf(output, "SYMBOL_OTHERS "); break; case XML_REGEXP_OTHER: fprintf(output, "OTHER "); break; case XML_REGEXP_OTHER_CONTROL: fprintf(output, "OTHER_CONTROL "); break; case XML_REGEXP_OTHER_FORMAT: fprintf(output, "OTHER_FORMAT "); break; case XML_REGEXP_OTHER_PRIVATE: fprintf(output, "OTHER_PRIVATE "); break; case XML_REGEXP_OTHER_NA: fprintf(output, "OTHER_NA "); break; case XML_REGEXP_BLOCK_NAME: fprintf(output, "BLOCK "); break; } } static void xmlRegPrintQuantType(FILE *output, xmlRegQuantType type) { switch (type) { case XML_REGEXP_QUANT_EPSILON: fprintf(output, "epsilon "); break; case XML_REGEXP_QUANT_ONCE: fprintf(output, "once "); break; case XML_REGEXP_QUANT_OPT: fprintf(output, "? "); break; case XML_REGEXP_QUANT_MULT: fprintf(output, "* "); break; case XML_REGEXP_QUANT_PLUS: fprintf(output, "+ "); break; case XML_REGEXP_QUANT_RANGE: fprintf(output, "range "); break; case XML_REGEXP_QUANT_ONCEONLY: fprintf(output, "onceonly "); break; case XML_REGEXP_QUANT_ALL: fprintf(output, "all "); break; } } static void xmlRegPrintRange(FILE *output, xmlRegRangePtr range) { fprintf(output, " range: "); if (range->neg) fprintf(output, "negative "); xmlRegPrintAtomType(output, range->type); fprintf(output, "%c - %c\n", range->start, range->end); } static void xmlRegPrintAtom(FILE *output, xmlRegAtomPtr atom) { fprintf(output, " atom: "); if (atom == NULL) { fprintf(output, "NULL\n"); return; } if (atom->neg) fprintf(output, "not "); xmlRegPrintAtomType(output, atom->type); xmlRegPrintQuantType(output, atom->quant); if (atom->quant == XML_REGEXP_QUANT_RANGE) fprintf(output, "%d-%d ", atom->min, atom->max); if (atom->type == XML_REGEXP_STRING) fprintf(output, "'%s' ", (char *) atom->valuep); if (atom->type == XML_REGEXP_CHARVAL) fprintf(output, "char %c\n", atom->codepoint); else if (atom->type == XML_REGEXP_RANGES) { int i; fprintf(output, "%d entries\n", atom->nbRanges); for (i = 0; i < atom->nbRanges;i++) xmlRegPrintRange(output, atom->ranges[i]); } else if (atom->type == XML_REGEXP_SUBREG) { fprintf(output, "start %d end %d\n", atom->start->no, atom->stop->no); } else { fprintf(output, "\n"); } } static void xmlRegPrintTrans(FILE *output, xmlRegTransPtr trans) { fprintf(output, " trans: "); if (trans == NULL) { fprintf(output, "NULL\n"); return; } if (trans->to < 0) { fprintf(output, "removed\n"); return; } if (trans->nd != 0) { if (trans->nd == 2) fprintf(output, "last not determinist, "); else fprintf(output, "not determinist, "); } if (trans->counter >= 0) { fprintf(output, "counted %d, ", trans->counter); } if (trans->count == REGEXP_ALL_COUNTER) { fprintf(output, "all transition, "); } else if (trans->count >= 0) { fprintf(output, "count based %d, ", trans->count); } if (trans->atom == NULL) { fprintf(output, "epsilon to %d\n", trans->to); return; } if (trans->atom->type == XML_REGEXP_CHARVAL) fprintf(output, "char %c ", trans->atom->codepoint); fprintf(output, "atom %d, to %d\n", trans->atom->no, trans->to); } static void xmlRegPrintState(FILE *output, xmlRegStatePtr state) { int i; fprintf(output, " state: "); if (state == NULL) { fprintf(output, "NULL\n"); return; } if (state->type == XML_REGEXP_START_STATE) fprintf(output, "START "); if (state->type == XML_REGEXP_FINAL_STATE) fprintf(output, "FINAL "); fprintf(output, "%d, %d transitions:\n", state->no, state->nbTrans); for (i = 0;i < state->nbTrans; i++) { xmlRegPrintTrans(output, &(state->trans[i])); } } #ifdef DEBUG_REGEXP_GRAPH static void xmlRegPrintCtxt(FILE *output, xmlRegParserCtxtPtr ctxt) { int i; fprintf(output, " ctxt: "); if (ctxt == NULL) { fprintf(output, "NULL\n"); return; } fprintf(output, "'%s' ", ctxt->string); if (ctxt->error) fprintf(output, "error "); if (ctxt->neg) fprintf(output, "neg "); fprintf(output, "\n"); fprintf(output, "%d atoms:\n", ctxt->nbAtoms); for (i = 0;i < ctxt->nbAtoms; i++) { fprintf(output, " %02d ", i); xmlRegPrintAtom(output, ctxt->atoms[i]); } if (ctxt->atom != NULL) { fprintf(output, "current atom:\n"); xmlRegPrintAtom(output, ctxt->atom); } fprintf(output, "%d states:", ctxt->nbStates); if (ctxt->start != NULL) fprintf(output, " start: %d", ctxt->start->no); if (ctxt->end != NULL) fprintf(output, " end: %d", ctxt->end->no); fprintf(output, "\n"); for (i = 0;i < ctxt->nbStates; i++) { xmlRegPrintState(output, ctxt->states[i]); } fprintf(output, "%d counters:\n", ctxt->nbCounters); for (i = 0;i < ctxt->nbCounters; i++) { fprintf(output, " %d: min %d max %d\n", i, ctxt->counters[i].min, ctxt->counters[i].max); } } #endif /************************************************************************ * * * Finite Automata structures manipulations * * * ************************************************************************/ static void xmlRegAtomAddRange(xmlRegParserCtxtPtr ctxt, xmlRegAtomPtr atom, int neg, xmlRegAtomType type, int start, int end, xmlChar *blockName) { xmlRegRangePtr range; if (atom == NULL) { ERROR("add range: atom is NULL"); return; } if (atom->type != XML_REGEXP_RANGES) { ERROR("add range: atom is not ranges"); return; } if (atom->maxRanges == 0) { atom->maxRanges = 4; atom->ranges = (xmlRegRangePtr *) xmlMalloc(atom->maxRanges * sizeof(xmlRegRangePtr)); if (atom->ranges == NULL) { xmlRegexpErrMemory(ctxt, "adding ranges"); atom->maxRanges = 0; return; } } else if (atom->nbRanges >= atom->maxRanges) { xmlRegRangePtr *tmp; atom->maxRanges *= 2; tmp = (xmlRegRangePtr *) xmlRealloc(atom->ranges, atom->maxRanges * sizeof(xmlRegRangePtr)); if (tmp == NULL) { xmlRegexpErrMemory(ctxt, "adding ranges"); atom->maxRanges /= 2; return; } atom->ranges = tmp; } range = xmlRegNewRange(ctxt, neg, type, start, end); if (range == NULL) return; range->blockName = blockName; atom->ranges[atom->nbRanges++] = range; } static int xmlRegGetCounter(xmlRegParserCtxtPtr ctxt) { if (ctxt->maxCounters == 0) { ctxt->maxCounters = 4; ctxt->counters = (xmlRegCounter *) xmlMalloc(ctxt->maxCounters * sizeof(xmlRegCounter)); if (ctxt->counters == NULL) { xmlRegexpErrMemory(ctxt, "allocating counter"); ctxt->maxCounters = 0; return(-1); } } else if (ctxt->nbCounters >= ctxt->maxCounters) { xmlRegCounter *tmp; ctxt->maxCounters *= 2; tmp = (xmlRegCounter *) xmlRealloc(ctxt->counters, ctxt->maxCounters * sizeof(xmlRegCounter)); if (tmp == NULL) { xmlRegexpErrMemory(ctxt, "allocating counter"); ctxt->maxCounters /= 2; return(-1); } ctxt->counters = tmp; } ctxt->counters[ctxt->nbCounters].min = -1; ctxt->counters[ctxt->nbCounters].max = -1; return(ctxt->nbCounters++); } static int xmlRegAtomPush(xmlRegParserCtxtPtr ctxt, xmlRegAtomPtr atom) { if (atom == NULL) { ERROR("atom push: atom is NULL"); return(-1); } if (ctxt->maxAtoms == 0) { ctxt->maxAtoms = 4; ctxt->atoms = (xmlRegAtomPtr *) xmlMalloc(ctxt->maxAtoms * sizeof(xmlRegAtomPtr)); if (ctxt->atoms == NULL) { xmlRegexpErrMemory(ctxt, "pushing atom"); ctxt->maxAtoms = 0; return(-1); } } else if (ctxt->nbAtoms >= ctxt->maxAtoms) { xmlRegAtomPtr *tmp; ctxt->maxAtoms *= 2; tmp = (xmlRegAtomPtr *) xmlRealloc(ctxt->atoms, ctxt->maxAtoms * sizeof(xmlRegAtomPtr)); if (tmp == NULL) { xmlRegexpErrMemory(ctxt, "allocating counter"); ctxt->maxAtoms /= 2; return(-1); } ctxt->atoms = tmp; } atom->no = ctxt->nbAtoms; ctxt->atoms[ctxt->nbAtoms++] = atom; return(0); } static void xmlRegStateAddTransTo(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr target, int from) { if (target->maxTransTo == 0) { target->maxTransTo = 8; target->transTo = (int *) xmlMalloc(target->maxTransTo * sizeof(int)); if (target->transTo == NULL) { xmlRegexpErrMemory(ctxt, "adding transition"); target->maxTransTo = 0; return; } } else if (target->nbTransTo >= target->maxTransTo) { int *tmp; target->maxTransTo *= 2; tmp = (int *) xmlRealloc(target->transTo, target->maxTransTo * sizeof(int)); if (tmp == NULL) { xmlRegexpErrMemory(ctxt, "adding transition"); target->maxTransTo /= 2; return; } target->transTo = tmp; } target->transTo[target->nbTransTo] = from; target->nbTransTo++; } static void xmlRegStateAddTrans(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr state, xmlRegAtomPtr atom, xmlRegStatePtr target, int counter, int count) { int nrtrans; if (state == NULL) { ERROR("add state: state is NULL"); return; } if (target == NULL) { ERROR("add state: target is NULL"); return; } /* * Other routines follow the philosophy 'When in doubt, add a transition' * so we check here whether such a transition is already present and, if * so, silently ignore this request. */ for (nrtrans = state->nbTrans - 1; nrtrans >= 0; nrtrans--) { xmlRegTransPtr trans = &(state->trans[nrtrans]); if ((trans->atom == atom) && (trans->to == target->no) && (trans->counter == counter) && (trans->count == count)) { #ifdef DEBUG_REGEXP_GRAPH printf("Ignoring duplicate transition from %d to %d\n", state->no, target->no); #endif return; } } if (state->maxTrans == 0) { state->maxTrans = 8; state->trans = (xmlRegTrans *) xmlMalloc(state->maxTrans * sizeof(xmlRegTrans)); if (state->trans == NULL) { xmlRegexpErrMemory(ctxt, "adding transition"); state->maxTrans = 0; return; } } else if (state->nbTrans >= state->maxTrans) { xmlRegTrans *tmp; state->maxTrans *= 2; tmp = (xmlRegTrans *) xmlRealloc(state->trans, state->maxTrans * sizeof(xmlRegTrans)); if (tmp == NULL) { xmlRegexpErrMemory(ctxt, "adding transition"); state->maxTrans /= 2; return; } state->trans = tmp; } #ifdef DEBUG_REGEXP_GRAPH printf("Add trans from %d to %d ", state->no, target->no); if (count == REGEXP_ALL_COUNTER) printf("all transition\n"); else if (count >= 0) printf("count based %d\n", count); else if (counter >= 0) printf("counted %d\n", counter); else if (atom == NULL) printf("epsilon transition\n"); else if (atom != NULL) xmlRegPrintAtom(stdout, atom); #endif state->trans[state->nbTrans].atom = atom; state->trans[state->nbTrans].to = target->no; state->trans[state->nbTrans].counter = counter; state->trans[state->nbTrans].count = count; state->trans[state->nbTrans].nd = 0; state->nbTrans++; xmlRegStateAddTransTo(ctxt, target, state->no); } static int xmlRegStatePush(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr state) { if (state == NULL) return(-1); if (ctxt->maxStates == 0) { ctxt->maxStates = 4; ctxt->states = (xmlRegStatePtr *) xmlMalloc(ctxt->maxStates * sizeof(xmlRegStatePtr)); if (ctxt->states == NULL) { xmlRegexpErrMemory(ctxt, "adding state"); ctxt->maxStates = 0; return(-1); } } else if (ctxt->nbStates >= ctxt->maxStates) { xmlRegStatePtr *tmp; ctxt->maxStates *= 2; tmp = (xmlRegStatePtr *) xmlRealloc(ctxt->states, ctxt->maxStates * sizeof(xmlRegStatePtr)); if (tmp == NULL) { xmlRegexpErrMemory(ctxt, "adding state"); ctxt->maxStates /= 2; return(-1); } ctxt->states = tmp; } state->no = ctxt->nbStates; ctxt->states[ctxt->nbStates++] = state; return(0); } /** * xmlFAGenerateAllTransition: * @ctxt: a regexp parser context * @from: the from state * @to: the target state or NULL for building a new one * @lax: * */ static void xmlFAGenerateAllTransition(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from, xmlRegStatePtr to, int lax) { if (to == NULL) { to = xmlRegNewState(ctxt); xmlRegStatePush(ctxt, to); ctxt->state = to; } if (lax) xmlRegStateAddTrans(ctxt, from, NULL, to, -1, REGEXP_ALL_LAX_COUNTER); else xmlRegStateAddTrans(ctxt, from, NULL, to, -1, REGEXP_ALL_COUNTER); } /** * xmlFAGenerateEpsilonTransition: * @ctxt: a regexp parser context * @from: the from state * @to: the target state or NULL for building a new one * */ static void xmlFAGenerateEpsilonTransition(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from, xmlRegStatePtr to) { if (to == NULL) { to = xmlRegNewState(ctxt); xmlRegStatePush(ctxt, to); ctxt->state = to; } xmlRegStateAddTrans(ctxt, from, NULL, to, -1, -1); } /** * xmlFAGenerateCountedEpsilonTransition: * @ctxt: a regexp parser context * @from: the from state * @to: the target state or NULL for building a new one * counter: the counter for that transition * */ static void xmlFAGenerateCountedEpsilonTransition(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from, xmlRegStatePtr to, int counter) { if (to == NULL) { to = xmlRegNewState(ctxt); xmlRegStatePush(ctxt, to); ctxt->state = to; } xmlRegStateAddTrans(ctxt, from, NULL, to, counter, -1); } /** * xmlFAGenerateCountedTransition: * @ctxt: a regexp parser context * @from: the from state * @to: the target state or NULL for building a new one * counter: the counter for that transition * */ static void xmlFAGenerateCountedTransition(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from, xmlRegStatePtr to, int counter) { if (to == NULL) { to = xmlRegNewState(ctxt); xmlRegStatePush(ctxt, to); ctxt->state = to; } xmlRegStateAddTrans(ctxt, from, NULL, to, -1, counter); } /** * xmlFAGenerateTransitions: * @ctxt: a regexp parser context * @from: the from state * @to: the target state or NULL for building a new one * @atom: the atom generating the transition * * Returns 0 if success and -1 in case of error. */ static int xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from, xmlRegStatePtr to, xmlRegAtomPtr atom) { if (atom == NULL) { ERROR("genrate transition: atom == NULL"); return(-1); } if (atom->type == XML_REGEXP_SUBREG) { /* * this is a subexpression handling one should not need to * create a new node except for XML_REGEXP_QUANT_RANGE. */ if (xmlRegAtomPush(ctxt, atom) < 0) { return(-1); } if ((to != NULL) && (atom->stop != to) && (atom->quant != XML_REGEXP_QUANT_RANGE)) { /* * Generate an epsilon transition to link to the target */ xmlFAGenerateEpsilonTransition(ctxt, atom->stop, to); #ifdef DV } else if ((to == NULL) && (atom->quant != XML_REGEXP_QUANT_RANGE) && (atom->quant != XML_REGEXP_QUANT_ONCE)) { to = xmlRegNewState(ctxt); xmlRegStatePush(ctxt, to); ctxt->state = to; xmlFAGenerateEpsilonTransition(ctxt, atom->stop, to); #endif } switch (atom->quant) { case XML_REGEXP_QUANT_OPT: atom->quant = XML_REGEXP_QUANT_ONCE; /* * transition done to the state after end of atom. * 1. set transition from atom start to new state * 2. set transition from atom end to this state. */ xmlFAGenerateEpsilonTransition(ctxt, atom->start, 0); xmlFAGenerateEpsilonTransition(ctxt, atom->stop, ctxt->state); break; case XML_REGEXP_QUANT_MULT: atom->quant = XML_REGEXP_QUANT_ONCE; xmlFAGenerateEpsilonTransition(ctxt, atom->start, atom->stop); xmlFAGenerateEpsilonTransition(ctxt, atom->stop, atom->start); break; case XML_REGEXP_QUANT_PLUS: atom->quant = XML_REGEXP_QUANT_ONCE; xmlFAGenerateEpsilonTransition(ctxt, atom->stop, atom->start); break; case XML_REGEXP_QUANT_RANGE: { int counter; xmlRegStatePtr newstate; /* * This one is nasty: * 1/ if range has minOccurs == 0, create a new state * and create epsilon transitions from atom->start * to atom->stop, as well as atom->start to the new * state * 2/ register a new counter * 3/ register an epsilon transition associated to * this counter going from atom->stop to atom->start * 4/ create a new state * 5/ generate a counted transition from atom->stop to * that state */ if (atom->min == 0) { xmlFAGenerateEpsilonTransition(ctxt, atom->start, atom->stop); newstate = xmlRegNewState(ctxt); xmlRegStatePush(ctxt, newstate); ctxt->state = newstate; xmlFAGenerateEpsilonTransition(ctxt, atom->start, newstate); } counter = xmlRegGetCounter(ctxt); ctxt->counters[counter].min = atom->min - 1; ctxt->counters[counter].max = atom->max - 1; atom->min = 0; atom->max = 0; atom->quant = XML_REGEXP_QUANT_ONCE; if (to != NULL) { newstate = to; } else { newstate = xmlRegNewState(ctxt); xmlRegStatePush(ctxt, newstate); } ctxt->state = newstate; xmlFAGenerateCountedTransition(ctxt, atom->stop, newstate, counter); /* * first check count and if OK jump forward; * if checking fail increment count and jump back */ xmlFAGenerateCountedEpsilonTransition(ctxt, atom->stop, atom->start, counter); } default: break; } return(0); } if ((atom->min == 0) && (atom->max == 0) && (atom->quant == XML_REGEXP_QUANT_RANGE)) { /* * we can discard the atom and generate an epsilon transition instead */ if (to == NULL) { to = xmlRegNewState(ctxt); if (to != NULL) xmlRegStatePush(ctxt, to); else { return(-1); } } xmlFAGenerateEpsilonTransition(ctxt, from, to); ctxt->state = to; xmlRegFreeAtom(atom); return(0); } if (to == NULL) { to = xmlRegNewState(ctxt); if (to != NULL) xmlRegStatePush(ctxt, to); else { return(-1); } } if (xmlRegAtomPush(ctxt, atom) < 0) { return(-1); } xmlRegStateAddTrans(ctxt, from, atom, to, -1, -1); ctxt->state = to; switch (atom->quant) { case XML_REGEXP_QUANT_OPT: atom->quant = XML_REGEXP_QUANT_ONCE; xmlFAGenerateEpsilonTransition(ctxt, from, to); break; case XML_REGEXP_QUANT_MULT: atom->quant = XML_REGEXP_QUANT_ONCE; xmlFAGenerateEpsilonTransition(ctxt, from, to); xmlRegStateAddTrans(ctxt, to, atom, to, -1, -1); break; case XML_REGEXP_QUANT_PLUS: atom->quant = XML_REGEXP_QUANT_ONCE; xmlRegStateAddTrans(ctxt, to, atom, to, -1, -1); break; default: break; } return(0); } /** * xmlFAReduceEpsilonTransitions: * @ctxt: a regexp parser context * @fromnr: the from state * @tonr: the to state * @counter: should that transition be associated to a counted * */ static void xmlFAReduceEpsilonTransitions(xmlRegParserCtxtPtr ctxt, int fromnr, int tonr, int counter) { int transnr; xmlRegStatePtr from; xmlRegStatePtr to; #ifdef DEBUG_REGEXP_GRAPH printf("xmlFAReduceEpsilonTransitions(%d, %d)\n", fromnr, tonr); #endif from = ctxt->states[fromnr]; if (from == NULL) return; to = ctxt->states[tonr]; if (to == NULL) return; if ((to->mark == XML_REGEXP_MARK_START) || (to->mark == XML_REGEXP_MARK_VISITED)) return; to->mark = XML_REGEXP_MARK_VISITED; if (to->type == XML_REGEXP_FINAL_STATE) { #ifdef DEBUG_REGEXP_GRAPH printf("State %d is final, so %d becomes final\n", tonr, fromnr); #endif from->type = XML_REGEXP_FINAL_STATE; } for (transnr = 0;transnr < to->nbTrans;transnr++) { if (to->trans[transnr].to < 0) continue; if (to->trans[transnr].atom == NULL) { /* * Don't remove counted transitions * Don't loop either */ if (to->trans[transnr].to != fromnr) { if (to->trans[transnr].count >= 0) { int newto = to->trans[transnr].to; xmlRegStateAddTrans(ctxt, from, NULL, ctxt->states[newto], -1, to->trans[transnr].count); } else { #ifdef DEBUG_REGEXP_GRAPH printf("Found epsilon trans %d from %d to %d\n", transnr, tonr, to->trans[transnr].to); #endif if (to->trans[transnr].counter >= 0) { xmlFAReduceEpsilonTransitions(ctxt, fromnr, to->trans[transnr].to, to->trans[transnr].counter); } else { xmlFAReduceEpsilonTransitions(ctxt, fromnr, to->trans[transnr].to, counter); } } } } else { int newto = to->trans[transnr].to; if (to->trans[transnr].counter >= 0) { xmlRegStateAddTrans(ctxt, from, to->trans[transnr].atom, ctxt->states[newto], to->trans[transnr].counter, -1); } else { xmlRegStateAddTrans(ctxt, from, to->trans[transnr].atom, ctxt->states[newto], counter, -1); } } } to->mark = XML_REGEXP_MARK_NORMAL; } /** * xmlFAEliminateSimpleEpsilonTransitions: * @ctxt: a regexp parser context * * Eliminating general epsilon transitions can get costly in the general * algorithm due to the large amount of generated new transitions and * associated comparisons. However for simple epsilon transition used just * to separate building blocks when generating the automata this can be * reduced to state elimination: * - if there exists an epsilon from X to Y * - if there is no other transition from X * then X and Y are semantically equivalent and X can be eliminated * If X is the start state then make Y the start state, else replace the * target of all transitions to X by transitions to Y. */ static void xmlFAEliminateSimpleEpsilonTransitions(xmlRegParserCtxtPtr ctxt) { int statenr, i, j, newto; xmlRegStatePtr state, tmp; for (statenr = 0;statenr < ctxt->nbStates;statenr++) { state = ctxt->states[statenr]; if (state == NULL) continue; if (state->nbTrans != 1) continue; /* is the only transition out a basic transition */ if ((state->trans[0].atom == NULL) && (state->trans[0].to >= 0) && (state->trans[0].to != statenr) && (state->trans[0].counter < 0) && (state->trans[0].count < 0)) { newto = state->trans[0].to; if (state->type == XML_REGEXP_START_STATE) { #ifdef DEBUG_REGEXP_GRAPH printf("Found simple epsilon trans from start %d to %d\n", statenr, newto); #endif } else { #ifdef DEBUG_REGEXP_GRAPH printf("Found simple epsilon trans from %d to %d\n", statenr, newto); #endif for (i = 0;i < state->nbTransTo;i++) { tmp = ctxt->states[state->transTo[i]]; for (j = 0;j < tmp->nbTrans;j++) { if (tmp->trans[j].to == statenr) { tmp->trans[j].to = newto; #ifdef DEBUG_REGEXP_GRAPH printf("Changed transition %d on %d to go to %d\n", j, tmp->no, newto); #endif xmlRegStateAddTransTo(ctxt, ctxt->states[newto], tmp->no); } } } #if 0 for (i = 0;i < ctxt->nbStates;i++) { tmp = ctxt->states[i]; for (j = 0;j < tmp->nbTrans;j++) { if (tmp->trans[j].to == statenr) { tmp->trans[j].to = newto; #ifdef DEBUG_REGEXP_GRAPH printf("Changed transition %d on %d to go to %d\n", j, tmp->no, newto); #endif } } } #endif if (state->type == XML_REGEXP_FINAL_STATE) ctxt->states[newto]->type = XML_REGEXP_FINAL_STATE; /* eliminate the transition completely */ state->nbTrans = 0; } } } } /** * xmlFAEliminateEpsilonTransitions: * @ctxt: a regexp parser context * */ static void xmlFAEliminateEpsilonTransitions(xmlRegParserCtxtPtr ctxt) { int statenr, transnr; xmlRegStatePtr state; int has_epsilon; if (ctxt->states == NULL) return; xmlFAEliminateSimpleEpsilonTransitions(ctxt); has_epsilon = 0; /* * build the completed transitions bypassing the epsilons * Use a marking algorithm to avoid loops * mark sink states too. */ for (statenr = 0;statenr < ctxt->nbStates;statenr++) { state = ctxt->states[statenr]; if (state == NULL) continue; if ((state->nbTrans == 0) && (state->type != XML_REGEXP_FINAL_STATE)) { state->type = XML_REGEXP_SINK_STATE; } for (transnr = 0;transnr < state->nbTrans;transnr++) { if ((state->trans[transnr].atom == NULL) && (state->trans[transnr].to >= 0)) { if (state->trans[transnr].to == statenr) { state->trans[transnr].to = -1; #ifdef DEBUG_REGEXP_GRAPH printf("Removed loopback epsilon trans %d on %d\n", transnr, statenr); #endif } else if (state->trans[transnr].count < 0) { int newto = state->trans[transnr].to; #ifdef DEBUG_REGEXP_GRAPH printf("Found epsilon trans %d from %d to %d\n", transnr, statenr, newto); #endif state->mark = XML_REGEXP_MARK_START; has_epsilon = 1; xmlFAReduceEpsilonTransitions(ctxt, statenr, newto, state->trans[transnr].counter); state->mark = XML_REGEXP_MARK_NORMAL; #ifdef DEBUG_REGEXP_GRAPH } else { printf("Found counted transition %d on %d\n", transnr, statenr); #endif } } } } /* * Eliminate the epsilon transitions */ if (has_epsilon) { for (statenr = 0;statenr < ctxt->nbStates;statenr++) { state = ctxt->states[statenr]; if (state == NULL) continue; for (transnr = 0;transnr < state->nbTrans;transnr++) { xmlRegTransPtr trans = &(state->trans[transnr]); if ((trans->atom == NULL) && (trans->count < 0) && (trans->to >= 0)) { trans->to = -1; } } } } /* * Use this pass to detect unreachable states too */ for (statenr = 0;statenr < ctxt->nbStates;statenr++) { state = ctxt->states[statenr]; if (state != NULL) state->reached = XML_REGEXP_MARK_NORMAL; } state = ctxt->states[0]; if (state != NULL) state->reached = XML_REGEXP_MARK_START; while (state != NULL) { xmlRegStatePtr target = NULL; state->reached = XML_REGEXP_MARK_VISITED; /* * Mark all states reachable from the current reachable state */ for (transnr = 0;transnr < state->nbTrans;transnr++) { if ((state->trans[transnr].to >= 0) && ((state->trans[transnr].atom != NULL) || (state->trans[transnr].count >= 0))) { int newto = state->trans[transnr].to; if (ctxt->states[newto] == NULL) continue; if (ctxt->states[newto]->reached == XML_REGEXP_MARK_NORMAL) { ctxt->states[newto]->reached = XML_REGEXP_MARK_START; target = ctxt->states[newto]; } } } /* * find the next accessible state not explored */ if (target == NULL) { for (statenr = 1;statenr < ctxt->nbStates;statenr++) { state = ctxt->states[statenr]; if ((state != NULL) && (state->reached == XML_REGEXP_MARK_START)) { target = state; break; } } } state = target; } for (statenr = 0;statenr < ctxt->nbStates;statenr++) { state = ctxt->states[statenr]; if ((state != NULL) && (state->reached == XML_REGEXP_MARK_NORMAL)) { #ifdef DEBUG_REGEXP_GRAPH printf("Removed unreachable state %d\n", statenr); #endif xmlRegFreeState(state); ctxt->states[statenr] = NULL; } } } static int xmlFACompareRanges(xmlRegRangePtr range1, xmlRegRangePtr range2) { int ret = 0; if ((range1->type == XML_REGEXP_RANGES) || (range2->type == XML_REGEXP_RANGES) || (range2->type == XML_REGEXP_SUBREG) || (range1->type == XML_REGEXP_SUBREG) || (range1->type == XML_REGEXP_STRING) || (range2->type == XML_REGEXP_STRING)) return(-1); /* put them in order */ if (range1->type > range2->type) { xmlRegRangePtr tmp; tmp = range1; range1 = range2; range2 = tmp; } if ((range1->type == XML_REGEXP_ANYCHAR) || (range2->type == XML_REGEXP_ANYCHAR)) { ret = 1; } else if ((range1->type == XML_REGEXP_EPSILON) || (range2->type == XML_REGEXP_EPSILON)) { return(0); } else if (range1->type == range2->type) { if ((range1->type != XML_REGEXP_CHARVAL) || (range1->end < range2->start) || (range2->end < range1->start)) ret = 1; else ret = 0; } else if (range1->type == XML_REGEXP_CHARVAL) { int codepoint; int neg = 0; /* * just check all codepoints in the range for acceptance, * this is usually way cheaper since done only once at * compilation than testing over and over at runtime or * pushing too many states when evaluating. */ if (((range1->neg == 0) && (range2->neg != 0)) || ((range1->neg != 0) && (range2->neg == 0))) neg = 1; for (codepoint = range1->start;codepoint <= range1->end ;codepoint++) { ret = xmlRegCheckCharacterRange(range2->type, codepoint, 0, range2->start, range2->end, range2->blockName); if (ret < 0) return(-1); if (((neg == 1) && (ret == 0)) || ((neg == 0) && (ret == 1))) return(1); } return(0); } else if ((range1->type == XML_REGEXP_BLOCK_NAME) || (range2->type == XML_REGEXP_BLOCK_NAME)) { if (range1->type == range2->type) { ret = xmlStrEqual(range1->blockName, range2->blockName); } else { /* * comparing a block range with anything else is way * too costly, and maintining the table is like too much * memory too, so let's force the automata to save state * here. */ return(1); } } else if ((range1->type < XML_REGEXP_LETTER) || (range2->type < XML_REGEXP_LETTER)) { if ((range1->type == XML_REGEXP_ANYSPACE) && (range2->type == XML_REGEXP_NOTSPACE)) ret = 0; else if ((range1->type == XML_REGEXP_INITNAME) && (range2->type == XML_REGEXP_NOTINITNAME)) ret = 0; else if ((range1->type == XML_REGEXP_NAMECHAR) && (range2->type == XML_REGEXP_NOTNAMECHAR)) ret = 0; else if ((range1->type == XML_REGEXP_DECIMAL) && (range2->type == XML_REGEXP_NOTDECIMAL)) ret = 0; else if ((range1->type == XML_REGEXP_REALCHAR) && (range2->type == XML_REGEXP_NOTREALCHAR)) ret = 0; else { /* same thing to limit complexity */ return(1); } } else { ret = 0; /* range1->type < range2->type here */ switch (range1->type) { case XML_REGEXP_LETTER: /* all disjoint except in the subgroups */ if ((range2->type == XML_REGEXP_LETTER_UPPERCASE) || (range2->type == XML_REGEXP_LETTER_LOWERCASE) || (range2->type == XML_REGEXP_LETTER_TITLECASE) || (range2->type == XML_REGEXP_LETTER_MODIFIER) || (range2->type == XML_REGEXP_LETTER_OTHERS)) ret = 1; break; case XML_REGEXP_MARK: if ((range2->type == XML_REGEXP_MARK_NONSPACING) || (range2->type == XML_REGEXP_MARK_SPACECOMBINING) || (range2->type == XML_REGEXP_MARK_ENCLOSING)) ret = 1; break; case XML_REGEXP_NUMBER: if ((range2->type == XML_REGEXP_NUMBER_DECIMAL) || (range2->type == XML_REGEXP_NUMBER_LETTER) || (range2->type == XML_REGEXP_NUMBER_OTHERS)) ret = 1; break; case XML_REGEXP_PUNCT: if ((range2->type == XML_REGEXP_PUNCT_CONNECTOR) || (range2->type == XML_REGEXP_PUNCT_DASH) || (range2->type == XML_REGEXP_PUNCT_OPEN) || (range2->type == XML_REGEXP_PUNCT_CLOSE) || (range2->type == XML_REGEXP_PUNCT_INITQUOTE) || (range2->type == XML_REGEXP_PUNCT_FINQUOTE) || (range2->type == XML_REGEXP_PUNCT_OTHERS)) ret = 1; break; case XML_REGEXP_SEPAR: if ((range2->type == XML_REGEXP_SEPAR_SPACE) || (range2->type == XML_REGEXP_SEPAR_LINE) || (range2->type == XML_REGEXP_SEPAR_PARA)) ret = 1; break; case XML_REGEXP_SYMBOL: if ((range2->type == XML_REGEXP_SYMBOL_MATH) || (range2->type == XML_REGEXP_SYMBOL_CURRENCY) || (range2->type == XML_REGEXP_SYMBOL_MODIFIER) || (range2->type == XML_REGEXP_SYMBOL_OTHERS)) ret = 1; break; case XML_REGEXP_OTHER: if ((range2->type == XML_REGEXP_OTHER_CONTROL) || (range2->type == XML_REGEXP_OTHER_FORMAT) || (range2->type == XML_REGEXP_OTHER_PRIVATE)) ret = 1; break; default: if ((range2->type >= XML_REGEXP_LETTER) && (range2->type < XML_REGEXP_BLOCK_NAME)) ret = 0; else { /* safety net ! */ return(1); } } } if (((range1->neg == 0) && (range2->neg != 0)) || ((range1->neg != 0) && (range2->neg == 0))) ret = !ret; return(1); } /** * xmlFACompareAtomTypes: * @type1: an atom type * @type2: an atom type * * Compares two atoms type to check whether they intersect in some ways, * this is used by xmlFACompareAtoms only * * Returns 1 if they may intersect and 0 otherwise */ static int xmlFACompareAtomTypes(xmlRegAtomType type1, xmlRegAtomType type2) { if ((type1 == XML_REGEXP_EPSILON) || (type1 == XML_REGEXP_CHARVAL) || (type1 == XML_REGEXP_RANGES) || (type1 == XML_REGEXP_SUBREG) || (type1 == XML_REGEXP_STRING) || (type1 == XML_REGEXP_ANYCHAR)) return(1); if ((type2 == XML_REGEXP_EPSILON) || (type2 == XML_REGEXP_CHARVAL) || (type2 == XML_REGEXP_RANGES) || (type2 == XML_REGEXP_SUBREG) || (type2 == XML_REGEXP_STRING) || (type2 == XML_REGEXP_ANYCHAR)) return(1); if (type1 == type2) return(1); /* simplify subsequent compares by making sure type1 < type2 */ if (type1 > type2) { xmlRegAtomType tmp = type1; type1 = type2; type2 = tmp; } switch (type1) { case XML_REGEXP_ANYSPACE: /* \s */ /* can't be a letter, number, mark, pontuation, symbol */ if ((type2 == XML_REGEXP_NOTSPACE) || ((type2 >= XML_REGEXP_LETTER) && (type2 <= XML_REGEXP_LETTER_OTHERS)) || ((type2 >= XML_REGEXP_NUMBER) && (type2 <= XML_REGEXP_NUMBER_OTHERS)) || ((type2 >= XML_REGEXP_MARK) && (type2 <= XML_REGEXP_MARK_ENCLOSING)) || ((type2 >= XML_REGEXP_PUNCT) && (type2 <= XML_REGEXP_PUNCT_OTHERS)) || ((type2 >= XML_REGEXP_SYMBOL) && (type2 <= XML_REGEXP_SYMBOL_OTHERS)) ) return(0); break; case XML_REGEXP_NOTSPACE: /* \S */ break; case XML_REGEXP_INITNAME: /* \l */ /* can't be a number, mark, separator, pontuation, symbol or other */ if ((type2 == XML_REGEXP_NOTINITNAME) || ((type2 >= XML_REGEXP_NUMBER) && (type2 <= XML_REGEXP_NUMBER_OTHERS)) || ((type2 >= XML_REGEXP_MARK) && (type2 <= XML_REGEXP_MARK_ENCLOSING)) || ((type2 >= XML_REGEXP_SEPAR) && (type2 <= XML_REGEXP_SEPAR_PARA)) || ((type2 >= XML_REGEXP_PUNCT) && (type2 <= XML_REGEXP_PUNCT_OTHERS)) || ((type2 >= XML_REGEXP_SYMBOL) && (type2 <= XML_REGEXP_SYMBOL_OTHERS)) || ((type2 >= XML_REGEXP_OTHER) && (type2 <= XML_REGEXP_OTHER_NA)) ) return(0); break; case XML_REGEXP_NOTINITNAME: /* \L */ break; case XML_REGEXP_NAMECHAR: /* \c */ /* can't be a mark, separator, pontuation, symbol or other */ if ((type2 == XML_REGEXP_NOTNAMECHAR) || ((type2 >= XML_REGEXP_MARK) && (type2 <= XML_REGEXP_MARK_ENCLOSING)) || ((type2 >= XML_REGEXP_PUNCT) && (type2 <= XML_REGEXP_PUNCT_OTHERS)) || ((type2 >= XML_REGEXP_SEPAR) && (type2 <= XML_REGEXP_SEPAR_PARA)) || ((type2 >= XML_REGEXP_SYMBOL) && (type2 <= XML_REGEXP_SYMBOL_OTHERS)) || ((type2 >= XML_REGEXP_OTHER) && (type2 <= XML_REGEXP_OTHER_NA)) ) return(0); break; case XML_REGEXP_NOTNAMECHAR: /* \C */ break; case XML_REGEXP_DECIMAL: /* \d */ /* can't be a letter, mark, separator, pontuation, symbol or other */ if ((type2 == XML_REGEXP_NOTDECIMAL) || (type2 == XML_REGEXP_REALCHAR) || ((type2 >= XML_REGEXP_LETTER) && (type2 <= XML_REGEXP_LETTER_OTHERS)) || ((type2 >= XML_REGEXP_MARK) && (type2 <= XML_REGEXP_MARK_ENCLOSING)) || ((type2 >= XML_REGEXP_PUNCT) && (type2 <= XML_REGEXP_PUNCT_OTHERS)) || ((type2 >= XML_REGEXP_SEPAR) && (type2 <= XML_REGEXP_SEPAR_PARA)) || ((type2 >= XML_REGEXP_SYMBOL) && (type2 <= XML_REGEXP_SYMBOL_OTHERS)) || ((type2 >= XML_REGEXP_OTHER) && (type2 <= XML_REGEXP_OTHER_NA)) )return(0); break; case XML_REGEXP_NOTDECIMAL: /* \D */ break; case XML_REGEXP_REALCHAR: /* \w */ /* can't be a mark, separator, pontuation, symbol or other */ if ((type2 == XML_REGEXP_NOTDECIMAL) || ((type2 >= XML_REGEXP_MARK) && (type2 <= XML_REGEXP_MARK_ENCLOSING)) || ((type2 >= XML_REGEXP_PUNCT) && (type2 <= XML_REGEXP_PUNCT_OTHERS)) || ((type2 >= XML_REGEXP_SEPAR) && (type2 <= XML_REGEXP_SEPAR_PARA)) || ((type2 >= XML_REGEXP_SYMBOL) && (type2 <= XML_REGEXP_SYMBOL_OTHERS)) || ((type2 >= XML_REGEXP_OTHER) && (type2 <= XML_REGEXP_OTHER_NA)) )return(0); break; case XML_REGEXP_NOTREALCHAR: /* \W */ break; /* * at that point we know both type 1 and type2 are from * character categories are ordered and are different, * it becomes simple because this is a partition */ case XML_REGEXP_LETTER: if (type2 <= XML_REGEXP_LETTER_OTHERS) return(1); return(0); case XML_REGEXP_LETTER_UPPERCASE: case XML_REGEXP_LETTER_LOWERCASE: case XML_REGEXP_LETTER_TITLECASE: case XML_REGEXP_LETTER_MODIFIER: case XML_REGEXP_LETTER_OTHERS: return(0); case XML_REGEXP_MARK: if (type2 <= XML_REGEXP_MARK_ENCLOSING) return(1); return(0); case XML_REGEXP_MARK_NONSPACING: case XML_REGEXP_MARK_SPACECOMBINING: case XML_REGEXP_MARK_ENCLOSING: return(0); case XML_REGEXP_NUMBER: if (type2 <= XML_REGEXP_NUMBER_OTHERS) return(1); return(0); case XML_REGEXP_NUMBER_DECIMAL: case XML_REGEXP_NUMBER_LETTER: case XML_REGEXP_NUMBER_OTHERS: return(0); case XML_REGEXP_PUNCT: if (type2 <= XML_REGEXP_PUNCT_OTHERS) return(1); return(0); case XML_REGEXP_PUNCT_CONNECTOR: case XML_REGEXP_PUNCT_DASH: case XML_REGEXP_PUNCT_OPEN: case XML_REGEXP_PUNCT_CLOSE: case XML_REGEXP_PUNCT_INITQUOTE: case XML_REGEXP_PUNCT_FINQUOTE: case XML_REGEXP_PUNCT_OTHERS: return(0); case XML_REGEXP_SEPAR: if (type2 <= XML_REGEXP_SEPAR_PARA) return(1); return(0); case XML_REGEXP_SEPAR_SPACE: case XML_REGEXP_SEPAR_LINE: case XML_REGEXP_SEPAR_PARA: return(0); case XML_REGEXP_SYMBOL: if (type2 <= XML_REGEXP_SYMBOL_OTHERS) return(1); return(0); case XML_REGEXP_SYMBOL_MATH: case XML_REGEXP_SYMBOL_CURRENCY: case XML_REGEXP_SYMBOL_MODIFIER: case XML_REGEXP_SYMBOL_OTHERS: return(0); case XML_REGEXP_OTHER: if (type2 <= XML_REGEXP_OTHER_NA) return(1); return(0); case XML_REGEXP_OTHER_CONTROL: case XML_REGEXP_OTHER_FORMAT: case XML_REGEXP_OTHER_PRIVATE: case XML_REGEXP_OTHER_NA: return(0); default: break; } return(1); } /** * xmlFAEqualAtoms: * @atom1: an atom * @atom2: an atom * * Compares two atoms to check whether they are the same exactly * this is used to remove equivalent transitions * * Returns 1 if same and 0 otherwise */ static int xmlFAEqualAtoms(xmlRegAtomPtr atom1, xmlRegAtomPtr atom2) { int ret = 0; if (atom1 == atom2) return(1); if ((atom1 == NULL) || (atom2 == NULL)) return(0); if (atom1->type != atom2->type) return(0); switch (atom1->type) { case XML_REGEXP_EPSILON: ret = 0; break; case XML_REGEXP_STRING: ret = xmlStrEqual((xmlChar *)atom1->valuep, (xmlChar *)atom2->valuep); break; case XML_REGEXP_CHARVAL: ret = (atom1->codepoint == atom2->codepoint); break; case XML_REGEXP_RANGES: /* too hard to do in the general case */ ret = 0; default: break; } return(ret); } /** * xmlFACompareAtoms: * @atom1: an atom * @atom2: an atom * * Compares two atoms to check whether they intersect in some ways, * this is used by xmlFAComputesDeterminism and xmlFARecurseDeterminism only * * Returns 1 if yes and 0 otherwise */ static int xmlFACompareAtoms(xmlRegAtomPtr atom1, xmlRegAtomPtr atom2) { int ret = 1; if (atom1 == atom2) return(1); if ((atom1 == NULL) || (atom2 == NULL)) return(0); if ((atom1->type == XML_REGEXP_ANYCHAR) || (atom2->type == XML_REGEXP_ANYCHAR)) return(1); if (atom1->type > atom2->type) { xmlRegAtomPtr tmp; tmp = atom1; atom1 = atom2; atom2 = tmp; } if (atom1->type != atom2->type) { ret = xmlFACompareAtomTypes(atom1->type, atom2->type); /* if they can't intersect at the type level break now */ if (ret == 0) return(0); } switch (atom1->type) { case XML_REGEXP_STRING: ret = xmlRegStrEqualWildcard((xmlChar *)atom1->valuep, (xmlChar *)atom2->valuep); break; case XML_REGEXP_EPSILON: goto not_determinist; case XML_REGEXP_CHARVAL: if (atom2->type == XML_REGEXP_CHARVAL) { ret = (atom1->codepoint == atom2->codepoint); } else { ret = xmlRegCheckCharacter(atom2, atom1->codepoint); if (ret < 0) ret = 1; } break; case XML_REGEXP_RANGES: if (atom2->type == XML_REGEXP_RANGES) { int i, j, res; xmlRegRangePtr r1, r2; /* * need to check that none of the ranges eventually matches */ for (i = 0;i < atom1->nbRanges;i++) { for (j = 0;j < atom2->nbRanges;j++) { r1 = atom1->ranges[i]; r2 = atom2->ranges[j]; res = xmlFACompareRanges(r1, r2); if (res == 1) { ret = 1; goto done; } } } ret = 0; } break; default: goto not_determinist; } done: if (atom1->neg != atom2->neg) { ret = !ret; } if (ret == 0) return(0); not_determinist: return(1); } /** * xmlFARecurseDeterminism: * @ctxt: a regexp parser context * * Check whether the associated regexp is determinist, * should be called after xmlFAEliminateEpsilonTransitions() * */ static int xmlFARecurseDeterminism(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr state, int to, xmlRegAtomPtr atom) { int ret = 1; int res; int transnr, nbTrans; xmlRegTransPtr t1; if (state == NULL) return(ret); /* * don't recurse on transitions potentially added in the course of * the elimination. */ nbTrans = state->nbTrans; for (transnr = 0;transnr < nbTrans;transnr++) { t1 = &(state->trans[transnr]); /* * check transitions conflicting with the one looked at */ if (t1->atom == NULL) { if (t1->to == -1) continue; res = xmlFARecurseDeterminism(ctxt, ctxt->states[t1->to], to, atom); if (res == 0) { ret = 0; /* t1->nd = 1; */ } continue; } if (t1->to != to) continue; if (xmlFACompareAtoms(t1->atom, atom)) { ret = 0; /* mark the transition as non-deterministic */ t1->nd = 1; } } return(ret); } /** * xmlFAComputesDeterminism: * @ctxt: a regexp parser context * * Check whether the associated regexp is determinist, * should be called after xmlFAEliminateEpsilonTransitions() * */ static int xmlFAComputesDeterminism(xmlRegParserCtxtPtr ctxt) { int statenr, transnr; xmlRegStatePtr state; xmlRegTransPtr t1, t2, last; int i; int ret = 1; #ifdef DEBUG_REGEXP_GRAPH printf("xmlFAComputesDeterminism\n"); xmlRegPrintCtxt(stdout, ctxt); #endif if (ctxt->determinist != -1) return(ctxt->determinist); /* * First cleanup the automata removing cancelled transitions */ for (statenr = 0;statenr < ctxt->nbStates;statenr++) { state = ctxt->states[statenr]; if (state == NULL) continue; if (state->nbTrans < 2) continue; for (transnr = 0;transnr < state->nbTrans;transnr++) { t1 = &(state->trans[transnr]); /* * Determinism checks in case of counted or all transitions * will have to be handled separately */ if (t1->atom == NULL) { /* t1->nd = 1; */ continue; } if (t1->to == -1) /* eliminated */ continue; for (i = 0;i < transnr;i++) { t2 = &(state->trans[i]); if (t2->to == -1) /* eliminated */ continue; if (t2->atom != NULL) { if (t1->to == t2->to) { if (xmlFAEqualAtoms(t1->atom, t2->atom)) t2->to = -1; /* eliminated */ } } } } } /* * Check for all states that there aren't 2 transitions * with the same atom and a different target. */ for (statenr = 0;statenr < ctxt->nbStates;statenr++) { state = ctxt->states[statenr]; if (state == NULL) continue; if (state->nbTrans < 2) continue; last = NULL; for (transnr = 0;transnr < state->nbTrans;transnr++) { t1 = &(state->trans[transnr]); /* * Determinism checks in case of counted or all transitions * will have to be handled separately */ if (t1->atom == NULL) { continue; } if (t1->to == -1) /* eliminated */ continue; for (i = 0;i < transnr;i++) { t2 = &(state->trans[i]); if (t2->to == -1) /* eliminated */ continue; if (t2->atom != NULL) { /* not determinist ! */ if (xmlFACompareAtoms(t1->atom, t2->atom)) { ret = 0; /* mark the transitions as non-deterministic ones */ t1->nd = 1; t2->nd = 1; last = t1; } } else if (t1->to != -1) { /* * do the closure in case of remaining specific * epsilon transitions like choices or all */ ret = xmlFARecurseDeterminism(ctxt, ctxt->states[t1->to], t2->to, t2->atom); /* don't shortcut the computation so all non deterministic transition get marked down if (ret == 0) return(0); */ if (ret == 0) { t1->nd = 1; /* t2->nd = 1; */ last = t1; } } } /* don't shortcut the computation so all non deterministic transition get marked down if (ret == 0) break; */ } /* * mark specifically the last non-deterministic transition * from a state since there is no need to set-up rollback * from it */ if (last != NULL) { last->nd = 2; } /* don't shortcut the computation so all non deterministic transition get marked down if (ret == 0) break; */ } ctxt->determinist = ret; return(ret); } /************************************************************************ * * * Routines to check input against transition atoms * * * ************************************************************************/ static int xmlRegCheckCharacterRange(xmlRegAtomType type, int codepoint, int neg, int start, int end, const xmlChar *blockName) { int ret = 0; switch (type) { case XML_REGEXP_STRING: case XML_REGEXP_SUBREG: case XML_REGEXP_RANGES: case XML_REGEXP_EPSILON: return(-1); case XML_REGEXP_ANYCHAR: ret = ((codepoint != '\n') && (codepoint != '\r')); break; case XML_REGEXP_CHARVAL: ret = ((codepoint >= start) && (codepoint <= end)); break; case XML_REGEXP_NOTSPACE: neg = !neg; case XML_REGEXP_ANYSPACE: ret = ((codepoint == '\n') || (codepoint == '\r') || (codepoint == '\t') || (codepoint == ' ')); break; case XML_REGEXP_NOTINITNAME: neg = !neg; case XML_REGEXP_INITNAME: ret = (IS_LETTER(codepoint) || (codepoint == '_') || (codepoint == ':')); break; case XML_REGEXP_NOTNAMECHAR: neg = !neg; case XML_REGEXP_NAMECHAR: ret = (IS_LETTER(codepoint) || IS_DIGIT(codepoint) || (codepoint == '.') || (codepoint == '-') || (codepoint == '_') || (codepoint == ':') || IS_COMBINING(codepoint) || IS_EXTENDER(codepoint)); break; case XML_REGEXP_NOTDECIMAL: neg = !neg; case XML_REGEXP_DECIMAL: ret = xmlUCSIsCatNd(codepoint); break; case XML_REGEXP_REALCHAR: neg = !neg; case XML_REGEXP_NOTREALCHAR: ret = xmlUCSIsCatP(codepoint); if (ret == 0) ret = xmlUCSIsCatZ(codepoint); if (ret == 0) ret = xmlUCSIsCatC(codepoint); break; case XML_REGEXP_LETTER: ret = xmlUCSIsCatL(codepoint); break; case XML_REGEXP_LETTER_UPPERCASE: ret = xmlUCSIsCatLu(codepoint); break; case XML_REGEXP_LETTER_LOWERCASE: ret = xmlUCSIsCatLl(codepoint); break; case XML_REGEXP_LETTER_TITLECASE: ret = xmlUCSIsCatLt(codepoint); break; case XML_REGEXP_LETTER_MODIFIER: ret = xmlUCSIsCatLm(codepoint); break; case XML_REGEXP_LETTER_OTHERS: ret = xmlUCSIsCatLo(codepoint); break; case XML_REGEXP_MARK: ret = xmlUCSIsCatM(codepoint); break; case XML_REGEXP_MARK_NONSPACING: ret = xmlUCSIsCatMn(codepoint); break; case XML_REGEXP_MARK_SPACECOMBINING: ret = xmlUCSIsCatMc(codepoint); break; case XML_REGEXP_MARK_ENCLOSING: ret = xmlUCSIsCatMe(codepoint); break; case XML_REGEXP_NUMBER: ret = xmlUCSIsCatN(codepoint); break; case XML_REGEXP_NUMBER_DECIMAL: ret = xmlUCSIsCatNd(codepoint); break; case XML_REGEXP_NUMBER_LETTER: ret = xmlUCSIsCatNl(codepoint); break; case XML_REGEXP_NUMBER_OTHERS: ret = xmlUCSIsCatNo(codepoint); break; case XML_REGEXP_PUNCT: ret = xmlUCSIsCatP(codepoint); break; case XML_REGEXP_PUNCT_CONNECTOR: ret = xmlUCSIsCatPc(codepoint); break; case XML_REGEXP_PUNCT_DASH: ret = xmlUCSIsCatPd(codepoint); break; case XML_REGEXP_PUNCT_OPEN: ret = xmlUCSIsCatPs(codepoint); break; case XML_REGEXP_PUNCT_CLOSE: ret = xmlUCSIsCatPe(codepoint); break; case XML_REGEXP_PUNCT_INITQUOTE: ret = xmlUCSIsCatPi(codepoint); break; case XML_REGEXP_PUNCT_FINQUOTE: ret = xmlUCSIsCatPf(codepoint); break; case XML_REGEXP_PUNCT_OTHERS: ret = xmlUCSIsCatPo(codepoint); break; case XML_REGEXP_SEPAR: ret = xmlUCSIsCatZ(codepoint); break; case XML_REGEXP_SEPAR_SPACE: ret = xmlUCSIsCatZs(codepoint); break; case XML_REGEXP_SEPAR_LINE: ret = xmlUCSIsCatZl(codepoint); break; case XML_REGEXP_SEPAR_PARA: ret = xmlUCSIsCatZp(codepoint); break; case XML_REGEXP_SYMBOL: ret = xmlUCSIsCatS(codepoint); break; case XML_REGEXP_SYMBOL_MATH: ret = xmlUCSIsCatSm(codepoint); break; case XML_REGEXP_SYMBOL_CURRENCY: ret = xmlUCSIsCatSc(codepoint); break; case XML_REGEXP_SYMBOL_MODIFIER: ret = xmlUCSIsCatSk(codepoint); break; case XML_REGEXP_SYMBOL_OTHERS: ret = xmlUCSIsCatSo(codepoint); break; case XML_REGEXP_OTHER: ret = xmlUCSIsCatC(codepoint); break; case XML_REGEXP_OTHER_CONTROL: ret = xmlUCSIsCatCc(codepoint); break; case XML_REGEXP_OTHER_FORMAT: ret = xmlUCSIsCatCf(codepoint); break; case XML_REGEXP_OTHER_PRIVATE: ret = xmlUCSIsCatCo(codepoint); break; case XML_REGEXP_OTHER_NA: /* ret = xmlUCSIsCatCn(codepoint); */ /* Seems it doesn't exist anymore in recent Unicode releases */ ret = 0; break; case XML_REGEXP_BLOCK_NAME: ret = xmlUCSIsBlock(codepoint, (const char *) blockName); break; } if (neg) return(!ret); return(ret); } static int xmlRegCheckCharacter(xmlRegAtomPtr atom, int codepoint) { int i, ret = 0; xmlRegRangePtr range; if ((atom == NULL) || (!IS_CHAR(codepoint))) return(-1); switch (atom->type) { case XML_REGEXP_SUBREG: case XML_REGEXP_EPSILON: return(-1); case XML_REGEXP_CHARVAL: return(codepoint == atom->codepoint); case XML_REGEXP_RANGES: { int accept = 0; for (i = 0;i < atom->nbRanges;i++) { range = atom->ranges[i]; if (range->neg == 2) { ret = xmlRegCheckCharacterRange(range->type, codepoint, 0, range->start, range->end, range->blockName); if (ret != 0) return(0); /* excluded char */ } else if (range->neg) { ret = xmlRegCheckCharacterRange(range->type, codepoint, 0, range->start, range->end, range->blockName); if (ret == 0) accept = 1; else return(0); } else { ret = xmlRegCheckCharacterRange(range->type, codepoint, 0, range->start, range->end, range->blockName); if (ret != 0) accept = 1; /* might still be excluded */ } } return(accept); } case XML_REGEXP_STRING: printf("TODO: XML_REGEXP_STRING\n"); return(-1); case XML_REGEXP_ANYCHAR: case XML_REGEXP_ANYSPACE: case XML_REGEXP_NOTSPACE: case XML_REGEXP_INITNAME: case XML_REGEXP_NOTINITNAME: case XML_REGEXP_NAMECHAR: case XML_REGEXP_NOTNAMECHAR: case XML_REGEXP_DECIMAL: case XML_REGEXP_NOTDECIMAL: case XML_REGEXP_REALCHAR: case XML_REGEXP_NOTREALCHAR: case XML_REGEXP_LETTER: case XML_REGEXP_LETTER_UPPERCASE: case XML_REGEXP_LETTER_LOWERCASE: case XML_REGEXP_LETTER_TITLECASE: case XML_REGEXP_LETTER_MODIFIER: case XML_REGEXP_LETTER_OTHERS: case XML_REGEXP_MARK: case XML_REGEXP_MARK_NONSPACING: case XML_REGEXP_MARK_SPACECOMBINING: case XML_REGEXP_MARK_ENCLOSING: case XML_REGEXP_NUMBER: case XML_REGEXP_NUMBER_DECIMAL: case XML_REGEXP_NUMBER_LETTER: case XML_REGEXP_NUMBER_OTHERS: case XML_REGEXP_PUNCT: case XML_REGEXP_PUNCT_CONNECTOR: case XML_REGEXP_PUNCT_DASH: case XML_REGEXP_PUNCT_OPEN: case XML_REGEXP_PUNCT_CLOSE: case XML_REGEXP_PUNCT_INITQUOTE: case XML_REGEXP_PUNCT_FINQUOTE: case XML_REGEXP_PUNCT_OTHERS: case XML_REGEXP_SEPAR: case XML_REGEXP_SEPAR_SPACE: case XML_REGEXP_SEPAR_LINE: case XML_REGEXP_SEPAR_PARA: case XML_REGEXP_SYMBOL: case XML_REGEXP_SYMBOL_MATH: case XML_REGEXP_SYMBOL_CURRENCY: case XML_REGEXP_SYMBOL_MODIFIER: case XML_REGEXP_SYMBOL_OTHERS: case XML_REGEXP_OTHER: case XML_REGEXP_OTHER_CONTROL: case XML_REGEXP_OTHER_FORMAT: case XML_REGEXP_OTHER_PRIVATE: case XML_REGEXP_OTHER_NA: case XML_REGEXP_BLOCK_NAME: ret = xmlRegCheckCharacterRange(atom->type, codepoint, 0, 0, 0, (const xmlChar *)atom->valuep); if (atom->neg) ret = !ret; break; } return(ret); } /************************************************************************ * * * Saving and restoring state of an execution context * * * ************************************************************************/ #ifdef DEBUG_REGEXP_EXEC static void xmlFARegDebugExec(xmlRegExecCtxtPtr exec) { printf("state: %d:%d:idx %d", exec->state->no, exec->transno, exec->index); if (exec->inputStack != NULL) { int i; printf(": "); for (i = 0;(i < 3) && (i < exec->inputStackNr);i++) printf("%s ", exec->inputStack[exec->inputStackNr - (i + 1)]); } else { printf(": %s", &(exec->inputString[exec->index])); } printf("\n"); } #endif static void xmlFARegExecSave(xmlRegExecCtxtPtr exec) { #ifdef DEBUG_REGEXP_EXEC printf("saving "); exec->transno++; xmlFARegDebugExec(exec); exec->transno--; #endif #ifdef MAX_PUSH if (exec->nbPush > MAX_PUSH) { return; } exec->nbPush++; #endif if (exec->maxRollbacks == 0) { exec->maxRollbacks = 4; exec->rollbacks = (xmlRegExecRollback *) xmlMalloc(exec->maxRollbacks * sizeof(xmlRegExecRollback)); if (exec->rollbacks == NULL) { xmlRegexpErrMemory(NULL, "saving regexp"); exec->maxRollbacks = 0; return; } memset(exec->rollbacks, 0, exec->maxRollbacks * sizeof(xmlRegExecRollback)); } else if (exec->nbRollbacks >= exec->maxRollbacks) { xmlRegExecRollback *tmp; int len = exec->maxRollbacks; exec->maxRollbacks *= 2; tmp = (xmlRegExecRollback *) xmlRealloc(exec->rollbacks, exec->maxRollbacks * sizeof(xmlRegExecRollback)); if (tmp == NULL) { xmlRegexpErrMemory(NULL, "saving regexp"); exec->maxRollbacks /= 2; return; } exec->rollbacks = tmp; tmp = &exec->rollbacks[len]; memset(tmp, 0, (exec->maxRollbacks - len) * sizeof(xmlRegExecRollback)); } exec->rollbacks[exec->nbRollbacks].state = exec->state; exec->rollbacks[exec->nbRollbacks].index = exec->index; exec->rollbacks[exec->nbRollbacks].nextbranch = exec->transno + 1; if (exec->comp->nbCounters > 0) { if (exec->rollbacks[exec->nbRollbacks].counts == NULL) { exec->rollbacks[exec->nbRollbacks].counts = (int *) xmlMalloc(exec->comp->nbCounters * sizeof(int)); if (exec->rollbacks[exec->nbRollbacks].counts == NULL) { xmlRegexpErrMemory(NULL, "saving regexp"); exec->status = -5; return; } } memcpy(exec->rollbacks[exec->nbRollbacks].counts, exec->counts, exec->comp->nbCounters * sizeof(int)); } exec->nbRollbacks++; } static void xmlFARegExecRollBack(xmlRegExecCtxtPtr exec) { if (exec->nbRollbacks <= 0) { exec->status = -1; #ifdef DEBUG_REGEXP_EXEC printf("rollback failed on empty stack\n"); #endif return; } exec->nbRollbacks--; exec->state = exec->rollbacks[exec->nbRollbacks].state; exec->index = exec->rollbacks[exec->nbRollbacks].index; exec->transno = exec->rollbacks[exec->nbRollbacks].nextbranch; if (exec->comp->nbCounters > 0) { if (exec->rollbacks[exec->nbRollbacks].counts == NULL) { fprintf(stderr, "exec save: allocation failed"); exec->status = -6; return; } memcpy(exec->counts, exec->rollbacks[exec->nbRollbacks].counts, exec->comp->nbCounters * sizeof(int)); } #ifdef DEBUG_REGEXP_EXEC printf("restored "); xmlFARegDebugExec(exec); #endif } /************************************************************************ * * * Verifier, running an input against a compiled regexp * * * ************************************************************************/ static int xmlFARegExec(xmlRegexpPtr comp, const xmlChar *content) { xmlRegExecCtxt execval; xmlRegExecCtxtPtr exec = &execval; int ret, codepoint = 0, len, deter; exec->inputString = content; exec->index = 0; exec->nbPush = 0; exec->determinist = 1; exec->maxRollbacks = 0; exec->nbRollbacks = 0; exec->rollbacks = NULL; exec->status = 0; exec->comp = comp; exec->state = comp->states[0]; exec->transno = 0; exec->transcount = 0; exec->inputStack = NULL; exec->inputStackMax = 0; if (comp->nbCounters > 0) { exec->counts = (int *) xmlMalloc(comp->nbCounters * sizeof(int)); if (exec->counts == NULL) { xmlRegexpErrMemory(NULL, "running regexp"); return(-1); } memset(exec->counts, 0, comp->nbCounters * sizeof(int)); } else exec->counts = NULL; while ((exec->status == 0) && ((exec->inputString[exec->index] != 0) || (exec->state->type != XML_REGEXP_FINAL_STATE))) { xmlRegTransPtr trans; xmlRegAtomPtr atom; /* * If end of input on non-terminal state, rollback, however we may * still have epsilon like transition for counted transitions * on counters, in that case don't break too early. Additionally, * if we are working on a range like "AB{0,2}", where B is not present, * we don't want to break. */ len = 1; if ((exec->inputString[exec->index] == 0) && (exec->counts == NULL)) { /* * if there is a transition, we must check if * atom allows minOccurs of 0 */ if (exec->transno < exec->state->nbTrans) { trans = &exec->state->trans[exec->transno]; if (trans->to >=0) { atom = trans->atom; if (!((atom->min == 0) && (atom->max > 0))) goto rollback; } } else goto rollback; } exec->transcount = 0; for (;exec->transno < exec->state->nbTrans;exec->transno++) { trans = &exec->state->trans[exec->transno]; if (trans->to < 0) continue; atom = trans->atom; ret = 0; deter = 1; if (trans->count >= 0) { int count; xmlRegCounterPtr counter; if (exec->counts == NULL) { exec->status = -1; goto error; } /* * A counted transition. */ count = exec->counts[trans->count]; counter = &exec->comp->counters[trans->count]; #ifdef DEBUG_REGEXP_EXEC printf("testing count %d: val %d, min %d, max %d\n", trans->count, count, counter->min, counter->max); #endif ret = ((count >= counter->min) && (count <= counter->max)); if ((ret) && (counter->min != counter->max)) deter = 0; } else if (atom == NULL) { fprintf(stderr, "epsilon transition left at runtime\n"); exec->status = -2; break; } else if (exec->inputString[exec->index] != 0) { codepoint = CUR_SCHAR(&(exec->inputString[exec->index]), len); ret = xmlRegCheckCharacter(atom, codepoint); if ((ret == 1) && (atom->min >= 0) && (atom->max > 0)) { xmlRegStatePtr to = comp->states[trans->to]; /* * this is a multiple input sequence * If there is a counter associated increment it now. * before potentially saving and rollback */ if (trans->counter >= 0) { if (exec->counts == NULL) { exec->status = -1; goto error; } #ifdef DEBUG_REGEXP_EXEC printf("Increasing count %d\n", trans->counter); #endif exec->counts[trans->counter]++; } if (exec->state->nbTrans > exec->transno + 1) { xmlFARegExecSave(exec); } exec->transcount = 1; do { /* * Try to progress as much as possible on the input */ if (exec->transcount == atom->max) { break; } exec->index += len; /* * End of input: stop here */ if (exec->inputString[exec->index] == 0) { exec->index -= len; break; } if (exec->transcount >= atom->min) { int transno = exec->transno; xmlRegStatePtr state = exec->state; /* * The transition is acceptable save it */ exec->transno = -1; /* trick */ exec->state = to; xmlFARegExecSave(exec); exec->transno = transno; exec->state = state; } codepoint = CUR_SCHAR(&(exec->inputString[exec->index]), len); ret = xmlRegCheckCharacter(atom, codepoint); exec->transcount++; } while (ret == 1); if (exec->transcount < atom->min) ret = 0; /* * If the last check failed but one transition was found * possible, rollback */ if (ret < 0) ret = 0; if (ret == 0) { goto rollback; } if (trans->counter >= 0) { if (exec->counts == NULL) { exec->status = -1; goto error; } #ifdef DEBUG_REGEXP_EXEC printf("Decreasing count %d\n", trans->counter); #endif exec->counts[trans->counter]--; } } else if ((ret == 0) && (atom->min == 0) && (atom->max > 0)) { /* * we don't match on the codepoint, but minOccurs of 0 * says that's ok. Setting len to 0 inhibits stepping * over the codepoint. */ exec->transcount = 1; len = 0; ret = 1; } } else if ((atom->min == 0) && (atom->max > 0)) { /* another spot to match when minOccurs is 0 */ exec->transcount = 1; len = 0; ret = 1; } if (ret == 1) { if ((trans->nd == 1) || ((trans->count >= 0) && (deter == 0) && (exec->state->nbTrans > exec->transno + 1))) { #ifdef DEBUG_REGEXP_EXEC if (trans->nd == 1) printf("Saving on nd transition atom %d for %c at %d\n", trans->atom->no, codepoint, exec->index); else printf("Saving on counted transition count %d for %c at %d\n", trans->count, codepoint, exec->index); #endif xmlFARegExecSave(exec); } if (trans->counter >= 0) { if (exec->counts == NULL) { exec->status = -1; goto error; } #ifdef DEBUG_REGEXP_EXEC printf("Increasing count %d\n", trans->counter); #endif exec->counts[trans->counter]++; } if ((trans->count >= 0) && (trans->count < REGEXP_ALL_COUNTER)) { if (exec->counts == NULL) { exec->status = -1; goto error; } #ifdef DEBUG_REGEXP_EXEC printf("resetting count %d on transition\n", trans->count); #endif exec->counts[trans->count] = 0; } #ifdef DEBUG_REGEXP_EXEC printf("entering state %d\n", trans->to); #endif exec->state = comp->states[trans->to]; exec->transno = 0; if (trans->atom != NULL) { exec->index += len; } goto progress; } else if (ret < 0) { exec->status = -4; break; } } if ((exec->transno != 0) || (exec->state->nbTrans == 0)) { rollback: /* * Failed to find a way out */ exec->determinist = 0; #ifdef DEBUG_REGEXP_EXEC printf("rollback from state %d on %d:%c\n", exec->state->no, codepoint,codepoint); #endif xmlFARegExecRollBack(exec); } progress: continue; } error: if (exec->rollbacks != NULL) { if (exec->counts != NULL) { int i; for (i = 0;i < exec->maxRollbacks;i++) if (exec->rollbacks[i].counts != NULL) xmlFree(exec->rollbacks[i].counts); } xmlFree(exec->rollbacks); } if (exec->counts != NULL) xmlFree(exec->counts); if (exec->status == 0) return(1); if (exec->status == -1) { if (exec->nbPush > MAX_PUSH) return(-1); return(0); } return(exec->status); } /************************************************************************ * * * Progressive interface to the verifier one atom at a time * * * ************************************************************************/ #ifdef DEBUG_ERR static void testerr(xmlRegExecCtxtPtr exec); #endif /** * xmlRegNewExecCtxt: * @comp: a precompiled regular expression * @callback: a callback function used for handling progresses in the * automata matching phase * @data: the context data associated to the callback in this context * * Build a context used for progressive evaluation of a regexp. * * Returns the new context */ xmlRegExecCtxtPtr xmlRegNewExecCtxt(xmlRegexpPtr comp, xmlRegExecCallbacks callback, void *data) { xmlRegExecCtxtPtr exec; if (comp == NULL) return(NULL); if ((comp->compact == NULL) && (comp->states == NULL)) return(NULL); exec = (xmlRegExecCtxtPtr) xmlMalloc(sizeof(xmlRegExecCtxt)); if (exec == NULL) { xmlRegexpErrMemory(NULL, "creating execution context"); return(NULL); } memset(exec, 0, sizeof(xmlRegExecCtxt)); exec->inputString = NULL; exec->index = 0; exec->determinist = 1; exec->maxRollbacks = 0; exec->nbRollbacks = 0; exec->rollbacks = NULL; exec->status = 0; exec->comp = comp; if (comp->compact == NULL) exec->state = comp->states[0]; exec->transno = 0; exec->transcount = 0; exec->callback = callback; exec->data = data; if (comp->nbCounters > 0) { /* * For error handling, exec->counts is allocated twice the size * the second half is used to store the data in case of rollback */ exec->counts = (int *) xmlMalloc(comp->nbCounters * sizeof(int) * 2); if (exec->counts == NULL) { xmlRegexpErrMemory(NULL, "creating execution context"); xmlFree(exec); return(NULL); } memset(exec->counts, 0, comp->nbCounters * sizeof(int) * 2); exec->errCounts = &exec->counts[comp->nbCounters]; } else { exec->counts = NULL; exec->errCounts = NULL; } exec->inputStackMax = 0; exec->inputStackNr = 0; exec->inputStack = NULL; exec->errStateNo = -1; exec->errString = NULL; exec->nbPush = 0; return(exec); } /** * xmlRegFreeExecCtxt: * @exec: a regular expression evaulation context * * Free the structures associated to a regular expression evaulation context. */ void xmlRegFreeExecCtxt(xmlRegExecCtxtPtr exec) { if (exec == NULL) return; if (exec->rollbacks != NULL) { if (exec->counts != NULL) { int i; for (i = 0;i < exec->maxRollbacks;i++) if (exec->rollbacks[i].counts != NULL) xmlFree(exec->rollbacks[i].counts); } xmlFree(exec->rollbacks); } if (exec->counts != NULL) xmlFree(exec->counts); if (exec->inputStack != NULL) { int i; for (i = 0;i < exec->inputStackNr;i++) { if (exec->inputStack[i].value != NULL) xmlFree(exec->inputStack[i].value); } xmlFree(exec->inputStack); } if (exec->errString != NULL) xmlFree(exec->errString); xmlFree(exec); } static void xmlFARegExecSaveInputString(xmlRegExecCtxtPtr exec, const xmlChar *value, void *data) { #ifdef DEBUG_PUSH printf("saving value: %d:%s\n", exec->inputStackNr, value); #endif if (exec->inputStackMax == 0) { exec->inputStackMax = 4; exec->inputStack = (xmlRegInputTokenPtr) xmlMalloc(exec->inputStackMax * sizeof(xmlRegInputToken)); if (exec->inputStack == NULL) { xmlRegexpErrMemory(NULL, "pushing input string"); exec->inputStackMax = 0; return; } } else if (exec->inputStackNr + 1 >= exec->inputStackMax) { xmlRegInputTokenPtr tmp; exec->inputStackMax *= 2; tmp = (xmlRegInputTokenPtr) xmlRealloc(exec->inputStack, exec->inputStackMax * sizeof(xmlRegInputToken)); if (tmp == NULL) { xmlRegexpErrMemory(NULL, "pushing input string"); exec->inputStackMax /= 2; return; } exec->inputStack = tmp; } exec->inputStack[exec->inputStackNr].value = xmlStrdup(value); exec->inputStack[exec->inputStackNr].data = data; exec->inputStackNr++; exec->inputStack[exec->inputStackNr].value = NULL; exec->inputStack[exec->inputStackNr].data = NULL; } /** * xmlRegStrEqualWildcard: * @expStr: the string to be evaluated * @valStr: the validation string * * Checks if both strings are equal or have the same content. "*" * can be used as a wildcard in @valStr; "|" is used as a seperator of * substrings in both @expStr and @valStr. * * Returns 1 if the comparison is satisfied and the number of substrings * is equal, 0 otherwise. */ static int xmlRegStrEqualWildcard(const xmlChar *expStr, const xmlChar *valStr) { if (expStr == valStr) return(1); if (expStr == NULL) return(0); if (valStr == NULL) return(0); do { /* * Eval if we have a wildcard for the current item. */ if (*expStr != *valStr) { /* if one of them starts with a wildcard make valStr be it */ if (*valStr == '*') { const xmlChar *tmp; tmp = valStr; valStr = expStr; expStr = tmp; } if ((*valStr != 0) && (*expStr != 0) && (*expStr++ == '*')) { do { if (*valStr == XML_REG_STRING_SEPARATOR) break; valStr++; } while (*valStr != 0); continue; } else return(0); } expStr++; valStr++; } while (*valStr != 0); if (*expStr != 0) return (0); else return (1); } /** * xmlRegCompactPushString: * @exec: a regexp execution context * @comp: the precompiled exec with a compact table * @value: a string token input * @data: data associated to the token to reuse in callbacks * * Push one input token in the execution context * * Returns: 1 if the regexp reached a final state, 0 if non-final, and * a negative value in case of error. */ static int xmlRegCompactPushString(xmlRegExecCtxtPtr exec, xmlRegexpPtr comp, const xmlChar *value, void *data) { int state = exec->index; int i, target; if ((comp == NULL) || (comp->compact == NULL) || (comp->stringMap == NULL)) return(-1); if (value == NULL) { /* * are we at a final state ? */ if (comp->compact[state * (comp->nbstrings + 1)] == XML_REGEXP_FINAL_STATE) return(1); return(0); } #ifdef DEBUG_PUSH printf("value pushed: %s\n", value); #endif /* * Examine all outside transitions from current state */ for (i = 0;i < comp->nbstrings;i++) { target = comp->compact[state * (comp->nbstrings + 1) + i + 1]; if ((target > 0) && (target <= comp->nbstates)) { target--; /* to avoid 0 */ if (xmlRegStrEqualWildcard(comp->stringMap[i], value)) { exec->index = target; if ((exec->callback != NULL) && (comp->transdata != NULL)) { exec->callback(exec->data, value, comp->transdata[state * comp->nbstrings + i], data); } #ifdef DEBUG_PUSH printf("entering state %d\n", target); #endif if (comp->compact[target * (comp->nbstrings + 1)] == XML_REGEXP_SINK_STATE) goto error; if (comp->compact[target * (comp->nbstrings + 1)] == XML_REGEXP_FINAL_STATE) return(1); return(0); } } } /* * Failed to find an exit transition out from current state for the * current token */ #ifdef DEBUG_PUSH printf("failed to find a transition for %s on state %d\n", value, state); #endif error: if (exec->errString != NULL) xmlFree(exec->errString); exec->errString = xmlStrdup(value); exec->errStateNo = state; exec->status = -1; #ifdef DEBUG_ERR testerr(exec); #endif return(-1); } /** * xmlRegExecPushStringInternal: * @exec: a regexp execution context or NULL to indicate the end * @value: a string token input * @data: data associated to the token to reuse in callbacks * @compound: value was assembled from 2 strings * * Push one input token in the execution context * * Returns: 1 if the regexp reached a final state, 0 if non-final, and * a negative value in case of error. */ static int xmlRegExecPushStringInternal(xmlRegExecCtxtPtr exec, const xmlChar *value, void *data, int compound) { xmlRegTransPtr trans; xmlRegAtomPtr atom; int ret; int final = 0; int progress = 1; if (exec == NULL) return(-1); if (exec->comp == NULL) return(-1); if (exec->status != 0) return(exec->status); if (exec->comp->compact != NULL) return(xmlRegCompactPushString(exec, exec->comp, value, data)); if (value == NULL) { if (exec->state->type == XML_REGEXP_FINAL_STATE) return(1); final = 1; } #ifdef DEBUG_PUSH printf("value pushed: %s\n", value); #endif /* * If we have an active rollback stack push the new value there * and get back to where we were left */ if ((value != NULL) && (exec->inputStackNr > 0)) { xmlFARegExecSaveInputString(exec, value, data); value = exec->inputStack[exec->index].value; data = exec->inputStack[exec->index].data; #ifdef DEBUG_PUSH printf("value loaded: %s\n", value); #endif } while ((exec->status == 0) && ((value != NULL) || ((final == 1) && (exec->state->type != XML_REGEXP_FINAL_STATE)))) { /* * End of input on non-terminal state, rollback, however we may * still have epsilon like transition for counted transitions * on counters, in that case don't break too early. */ if ((value == NULL) && (exec->counts == NULL)) goto rollback; exec->transcount = 0; for (;exec->transno < exec->state->nbTrans;exec->transno++) { trans = &exec->state->trans[exec->transno]; if (trans->to < 0) continue; atom = trans->atom; ret = 0; if (trans->count == REGEXP_ALL_LAX_COUNTER) { int i; int count; xmlRegTransPtr t; xmlRegCounterPtr counter; ret = 0; #ifdef DEBUG_PUSH printf("testing all lax %d\n", trans->count); #endif /* * Check all counted transitions from the current state */ if ((value == NULL) && (final)) { ret = 1; } else if (value != NULL) { for (i = 0;i < exec->state->nbTrans;i++) { t = &exec->state->trans[i]; if ((t->counter < 0) || (t == trans)) continue; counter = &exec->comp->counters[t->counter]; count = exec->counts[t->counter]; if ((count < counter->max) && (t->atom != NULL) && (xmlStrEqual(value, t->atom->valuep))) { ret = 0; break; } if ((count >= counter->min) && (count < counter->max) && (t->atom != NULL) && (xmlStrEqual(value, t->atom->valuep))) { ret = 1; break; } } } } else if (trans->count == REGEXP_ALL_COUNTER) { int i; int count; xmlRegTransPtr t; xmlRegCounterPtr counter; ret = 1; #ifdef DEBUG_PUSH printf("testing all %d\n", trans->count); #endif /* * Check all counted transitions from the current state */ for (i = 0;i < exec->state->nbTrans;i++) { t = &exec->state->trans[i]; if ((t->counter < 0) || (t == trans)) continue; counter = &exec->comp->counters[t->counter]; count = exec->counts[t->counter]; if ((count < counter->min) || (count > counter->max)) { ret = 0; break; } } } else if (trans->count >= 0) { int count; xmlRegCounterPtr counter; /* * A counted transition. */ count = exec->counts[trans->count]; counter = &exec->comp->counters[trans->count]; #ifdef DEBUG_PUSH printf("testing count %d: val %d, min %d, max %d\n", trans->count, count, counter->min, counter->max); #endif ret = ((count >= counter->min) && (count <= counter->max)); } else if (atom == NULL) { fprintf(stderr, "epsilon transition left at runtime\n"); exec->status = -2; break; } else if (value != NULL) { ret = xmlRegStrEqualWildcard(atom->valuep, value); if (atom->neg) { ret = !ret; if (!compound) ret = 0; } if ((ret == 1) && (trans->counter >= 0)) { xmlRegCounterPtr counter; int count; count = exec->counts[trans->counter]; counter = &exec->comp->counters[trans->counter]; if (count >= counter->max) ret = 0; } if ((ret == 1) && (atom->min > 0) && (atom->max > 0)) { xmlRegStatePtr to = exec->comp->states[trans->to]; /* * this is a multiple input sequence */ if (exec->state->nbTrans > exec->transno + 1) { if (exec->inputStackNr <= 0) { xmlFARegExecSaveInputString(exec, value, data); } xmlFARegExecSave(exec); } exec->transcount = 1; do { /* * Try to progress as much as possible on the input */ if (exec->transcount == atom->max) { break; } exec->index++; value = exec->inputStack[exec->index].value; data = exec->inputStack[exec->index].data; #ifdef DEBUG_PUSH printf("value loaded: %s\n", value); #endif /* * End of input: stop here */ if (value == NULL) { exec->index --; break; } if (exec->transcount >= atom->min) { int transno = exec->transno; xmlRegStatePtr state = exec->state; /* * The transition is acceptable save it */ exec->transno = -1; /* trick */ exec->state = to; if (exec->inputStackNr <= 0) { xmlFARegExecSaveInputString(exec, value, data); } xmlFARegExecSave(exec); exec->transno = transno; exec->state = state; } ret = xmlStrEqual(value, atom->valuep); exec->transcount++; } while (ret == 1); if (exec->transcount < atom->min) ret = 0; /* * If the last check failed but one transition was found * possible, rollback */ if (ret < 0) ret = 0; if (ret == 0) { goto rollback; } } } if (ret == 1) { if ((exec->callback != NULL) && (atom != NULL) && (data != NULL)) { exec->callback(exec->data, atom->valuep, atom->data, data); } if (exec->state->nbTrans > exec->transno + 1) { if (exec->inputStackNr <= 0) { xmlFARegExecSaveInputString(exec, value, data); } xmlFARegExecSave(exec); } if (trans->counter >= 0) { #ifdef DEBUG_PUSH printf("Increasing count %d\n", trans->counter); #endif exec->counts[trans->counter]++; } if ((trans->count >= 0) && (trans->count < REGEXP_ALL_COUNTER)) { #ifdef DEBUG_REGEXP_EXEC printf("resetting count %d on transition\n", trans->count); #endif exec->counts[trans->count] = 0; } #ifdef DEBUG_PUSH printf("entering state %d\n", trans->to); #endif if ((exec->comp->states[trans->to] != NULL) && (exec->comp->states[trans->to]->type == XML_REGEXP_SINK_STATE)) { /* * entering a sink state, save the current state as error * state. */ if (exec->errString != NULL) xmlFree(exec->errString); exec->errString = xmlStrdup(value); exec->errState = exec->state; memcpy(exec->errCounts, exec->counts, exec->comp->nbCounters * sizeof(int)); } exec->state = exec->comp->states[trans->to]; exec->transno = 0; if (trans->atom != NULL) { if (exec->inputStack != NULL) { exec->index++; if (exec->index < exec->inputStackNr) { value = exec->inputStack[exec->index].value; data = exec->inputStack[exec->index].data; #ifdef DEBUG_PUSH printf("value loaded: %s\n", value); #endif } else { value = NULL; data = NULL; #ifdef DEBUG_PUSH printf("end of input\n"); #endif } } else { value = NULL; data = NULL; #ifdef DEBUG_PUSH printf("end of input\n"); #endif } } goto progress; } else if (ret < 0) { exec->status = -4; break; } } if ((exec->transno != 0) || (exec->state->nbTrans == 0)) { rollback: /* * if we didn't yet rollback on the current input * store the current state as the error state. */ if ((progress) && (exec->state != NULL) && (exec->state->type != XML_REGEXP_SINK_STATE)) { progress = 0; if (exec->errString != NULL) xmlFree(exec->errString); exec->errString = xmlStrdup(value); exec->errState = exec->state; memcpy(exec->errCounts, exec->counts, exec->comp->nbCounters * sizeof(int)); } /* * Failed to find a way out */ exec->determinist = 0; xmlFARegExecRollBack(exec); if (exec->status == 0) { value = exec->inputStack[exec->index].value; data = exec->inputStack[exec->index].data; #ifdef DEBUG_PUSH printf("value loaded: %s\n", value); #endif } } continue; progress: progress = 1; continue; } if (exec->status == 0) { return(exec->state->type == XML_REGEXP_FINAL_STATE); } #ifdef DEBUG_ERR if (exec->status < 0) { testerr(exec); } #endif return(exec->status); } /** * xmlRegExecPushString: * @exec: a regexp execution context or NULL to indicate the end * @value: a string token input * @data: data associated to the token to reuse in callbacks * * Push one input token in the execution context * * Returns: 1 if the regexp reached a final state, 0 if non-final, and * a negative value in case of error. */ int xmlRegExecPushString(xmlRegExecCtxtPtr exec, const xmlChar *value, void *data) { return(xmlRegExecPushStringInternal(exec, value, data, 0)); } /** * xmlRegExecPushString2: * @exec: a regexp execution context or NULL to indicate the end * @value: the first string token input * @value2: the second string token input * @data: data associated to the token to reuse in callbacks * * Push one input token in the execution context * * Returns: 1 if the regexp reached a final state, 0 if non-final, and * a negative value in case of error. */ int xmlRegExecPushString2(xmlRegExecCtxtPtr exec, const xmlChar *value, const xmlChar *value2, void *data) { xmlChar buf[150]; int lenn, lenp, ret; xmlChar *str; if (exec == NULL) return(-1); if (exec->comp == NULL) return(-1); if (exec->status != 0) return(exec->status); if (value2 == NULL) return(xmlRegExecPushString(exec, value, data)); lenn = strlen((char *) value2); lenp = strlen((char *) value); if (150 < lenn + lenp + 2) { str = (xmlChar *) xmlMallocAtomic(lenn + lenp + 2); if (str == NULL) { exec->status = -1; return(-1); } } else { str = buf; } memcpy(&str[0], value, lenp); str[lenp] = XML_REG_STRING_SEPARATOR; memcpy(&str[lenp + 1], value2, lenn); str[lenn + lenp + 1] = 0; if (exec->comp->compact != NULL) ret = xmlRegCompactPushString(exec, exec->comp, str, data); else ret = xmlRegExecPushStringInternal(exec, str, data, 1); if (str != buf) xmlFree(str); return(ret); } /** * xmlRegExecGetValues: * @exec: a regexp execution context * @err: error extraction or normal one * @nbval: pointer to the number of accepted values IN/OUT * @nbneg: return number of negative transitions * @values: pointer to the array of acceptable values * @terminal: return value if this was a terminal state * * Extract informations from the regexp execution, internal routine to * implement xmlRegExecNextValues() and xmlRegExecErrInfo() * * Returns: 0 in case of success or -1 in case of error. */ static int xmlRegExecGetValues(xmlRegExecCtxtPtr exec, int err, int *nbval, int *nbneg, xmlChar **values, int *terminal) { int maxval; int nb = 0; if ((exec == NULL) || (nbval == NULL) || (nbneg == NULL) || (values == NULL) || (*nbval <= 0)) return(-1); maxval = *nbval; *nbval = 0; *nbneg = 0; if ((exec->comp != NULL) && (exec->comp->compact != NULL)) { xmlRegexpPtr comp; int target, i, state; comp = exec->comp; if (err) { if (exec->errStateNo == -1) return(-1); state = exec->errStateNo; } else { state = exec->index; } if (terminal != NULL) { if (comp->compact[state * (comp->nbstrings + 1)] == XML_REGEXP_FINAL_STATE) *terminal = 1; else *terminal = 0; } for (i = 0;(i < comp->nbstrings) && (nb < maxval);i++) { target = comp->compact[state * (comp->nbstrings + 1) + i + 1]; if ((target > 0) && (target <= comp->nbstates) && (comp->compact[(target - 1) * (comp->nbstrings + 1)] != XML_REGEXP_SINK_STATE)) { values[nb++] = comp->stringMap[i]; (*nbval)++; } } for (i = 0;(i < comp->nbstrings) && (nb < maxval);i++) { target = comp->compact[state * (comp->nbstrings + 1) + i + 1]; if ((target > 0) && (target <= comp->nbstates) && (comp->compact[(target - 1) * (comp->nbstrings + 1)] == XML_REGEXP_SINK_STATE)) { values[nb++] = comp->stringMap[i]; (*nbneg)++; } } } else { int transno; xmlRegTransPtr trans; xmlRegAtomPtr atom; xmlRegStatePtr state; if (terminal != NULL) { if (exec->state->type == XML_REGEXP_FINAL_STATE) *terminal = 1; else *terminal = 0; } if (err) { if (exec->errState == NULL) return(-1); state = exec->errState; } else { if (exec->state == NULL) return(-1); state = exec->state; } for (transno = 0; (transno < state->nbTrans) && (nb < maxval); transno++) { trans = &state->trans[transno]; if (trans->to < 0) continue; atom = trans->atom; if ((atom == NULL) || (atom->valuep == NULL)) continue; if (trans->count == REGEXP_ALL_LAX_COUNTER) { /* this should not be reached but ... */ TODO; } else if (trans->count == REGEXP_ALL_COUNTER) { /* this should not be reached but ... */ TODO; } else if (trans->counter >= 0) { xmlRegCounterPtr counter = NULL; int count; if (err) count = exec->errCounts[trans->counter]; else count = exec->counts[trans->counter]; if (exec->comp != NULL) counter = &exec->comp->counters[trans->counter]; if ((counter == NULL) || (count < counter->max)) { if (atom->neg) values[nb++] = (xmlChar *) atom->valuep2; else values[nb++] = (xmlChar *) atom->valuep; (*nbval)++; } } else { if ((exec->comp->states[trans->to] != NULL) && (exec->comp->states[trans->to]->type != XML_REGEXP_SINK_STATE)) { if (atom->neg) values[nb++] = (xmlChar *) atom->valuep2; else values[nb++] = (xmlChar *) atom->valuep; (*nbval)++; } } } for (transno = 0; (transno < state->nbTrans) && (nb < maxval); transno++) { trans = &state->trans[transno]; if (trans->to < 0) continue; atom = trans->atom; if ((atom == NULL) || (atom->valuep == NULL)) continue; if (trans->count == REGEXP_ALL_LAX_COUNTER) { continue; } else if (trans->count == REGEXP_ALL_COUNTER) { continue; } else if (trans->counter >= 0) { continue; } else { if ((exec->comp->states[trans->to] != NULL) && (exec->comp->states[trans->to]->type == XML_REGEXP_SINK_STATE)) { if (atom->neg) values[nb++] = (xmlChar *) atom->valuep2; else values[nb++] = (xmlChar *) atom->valuep; (*nbneg)++; } } } } return(0); } /** * xmlRegExecNextValues: * @exec: a regexp execution context * @nbval: pointer to the number of accepted values IN/OUT * @nbneg: return number of negative transitions * @values: pointer to the array of acceptable values * @terminal: return value if this was a terminal state * * Extract informations from the regexp execution, * the parameter @values must point to an array of @nbval string pointers * on return nbval will contain the number of possible strings in that * state and the @values array will be updated with them. The string values * returned will be freed with the @exec context and don't need to be * deallocated. * * Returns: 0 in case of success or -1 in case of error. */ int xmlRegExecNextValues(xmlRegExecCtxtPtr exec, int *nbval, int *nbneg, xmlChar **values, int *terminal) { return(xmlRegExecGetValues(exec, 0, nbval, nbneg, values, terminal)); } /** * xmlRegExecErrInfo: * @exec: a regexp execution context generating an error * @string: return value for the error string * @nbval: pointer to the number of accepted values IN/OUT * @nbneg: return number of negative transitions * @values: pointer to the array of acceptable values * @terminal: return value if this was a terminal state * * Extract error informations from the regexp execution, the parameter * @string will be updated with the value pushed and not accepted, * the parameter @values must point to an array of @nbval string pointers * on return nbval will contain the number of possible strings in that * state and the @values array will be updated with them. The string values * returned will be freed with the @exec context and don't need to be * deallocated. * * Returns: 0 in case of success or -1 in case of error. */ int xmlRegExecErrInfo(xmlRegExecCtxtPtr exec, const xmlChar **string, int *nbval, int *nbneg, xmlChar **values, int *terminal) { if (exec == NULL) return(-1); if (string != NULL) { if (exec->status != 0) *string = exec->errString; else *string = NULL; } return(xmlRegExecGetValues(exec, 1, nbval, nbneg, values, terminal)); } #ifdef DEBUG_ERR static void testerr(xmlRegExecCtxtPtr exec) { const xmlChar *string; xmlChar *values[5]; int nb = 5; int nbneg; int terminal; xmlRegExecErrInfo(exec, &string, &nb, &nbneg, &values[0], &terminal); } #endif #if 0 static int xmlRegExecPushChar(xmlRegExecCtxtPtr exec, int UCS) { xmlRegTransPtr trans; xmlRegAtomPtr atom; int ret; int codepoint, len; if (exec == NULL) return(-1); if (exec->status != 0) return(exec->status); while ((exec->status == 0) && ((exec->inputString[exec->index] != 0) || (exec->state->type != XML_REGEXP_FINAL_STATE))) { /* * End of input on non-terminal state, rollback, however we may * still have epsilon like transition for counted transitions * on counters, in that case don't break too early. */ if ((exec->inputString[exec->index] == 0) && (exec->counts == NULL)) goto rollback; exec->transcount = 0; for (;exec->transno < exec->state->nbTrans;exec->transno++) { trans = &exec->state->trans[exec->transno]; if (trans->to < 0) continue; atom = trans->atom; ret = 0; if (trans->count >= 0) { int count; xmlRegCounterPtr counter; /* * A counted transition. */ count = exec->counts[trans->count]; counter = &exec->comp->counters[trans->count]; #ifdef DEBUG_REGEXP_EXEC printf("testing count %d: val %d, min %d, max %d\n", trans->count, count, counter->min, counter->max); #endif ret = ((count >= counter->min) && (count <= counter->max)); } else if (atom == NULL) { fprintf(stderr, "epsilon transition left at runtime\n"); exec->status = -2; break; } else if (exec->inputString[exec->index] != 0) { codepoint = CUR_SCHAR(&(exec->inputString[exec->index]), len); ret = xmlRegCheckCharacter(atom, codepoint); if ((ret == 1) && (atom->min > 0) && (atom->max > 0)) { xmlRegStatePtr to = exec->comp->states[trans->to]; /* * this is a multiple input sequence */ if (exec->state->nbTrans > exec->transno + 1) { xmlFARegExecSave(exec); } exec->transcount = 1; do { /* * Try to progress as much as possible on the input */ if (exec->transcount == atom->max) { break; } exec->index += len; /* * End of input: stop here */ if (exec->inputString[exec->index] == 0) { exec->index -= len; break; } if (exec->transcount >= atom->min) { int transno = exec->transno; xmlRegStatePtr state = exec->state; /* * The transition is acceptable save it */ exec->transno = -1; /* trick */ exec->state = to; xmlFARegExecSave(exec); exec->transno = transno; exec->state = state; } codepoint = CUR_SCHAR(&(exec->inputString[exec->index]), len); ret = xmlRegCheckCharacter(atom, codepoint); exec->transcount++; } while (ret == 1); if (exec->transcount < atom->min) ret = 0; /* * If the last check failed but one transition was found * possible, rollback */ if (ret < 0) ret = 0; if (ret == 0) { goto rollback; } } } if (ret == 1) { if (exec->state->nbTrans > exec->transno + 1) { xmlFARegExecSave(exec); } /* * restart count for expressions like this ((abc){2})* */ if (trans->count >= 0) { #ifdef DEBUG_REGEXP_EXEC printf("Reset count %d\n", trans->count); #endif exec->counts[trans->count] = 0; } if (trans->counter >= 0) { #ifdef DEBUG_REGEXP_EXEC printf("Increasing count %d\n", trans->counter); #endif exec->counts[trans->counter]++; } #ifdef DEBUG_REGEXP_EXEC printf("entering state %d\n", trans->to); #endif exec->state = exec->comp->states[trans->to]; exec->transno = 0; if (trans->atom != NULL) { exec->index += len; } goto progress; } else if (ret < 0) { exec->status = -4; break; } } if ((exec->transno != 0) || (exec->state->nbTrans == 0)) { rollback: /* * Failed to find a way out */ exec->determinist = 0; xmlFARegExecRollBack(exec); } progress: continue; } } #endif /************************************************************************ * * * Parser for the Schemas Datatype Regular Expressions * * http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/#regexs * * * ************************************************************************/ /** * xmlFAIsChar: * @ctxt: a regexp parser context * * [10] Char ::= [^.\?*+()|#x5B#x5D] */ static int xmlFAIsChar(xmlRegParserCtxtPtr ctxt) { int cur; int len; cur = CUR_SCHAR(ctxt->cur, len); if ((cur == '.') || (cur == '\\') || (cur == '?') || (cur == '*') || (cur == '+') || (cur == '(') || (cur == ')') || (cur == '|') || (cur == 0x5B) || (cur == 0x5D) || (cur == 0)) return(-1); return(cur); } /** * xmlFAParseCharProp: * @ctxt: a regexp parser context * * [27] charProp ::= IsCategory | IsBlock * [28] IsCategory ::= Letters | Marks | Numbers | Punctuation | * Separators | Symbols | Others * [29] Letters ::= 'L' [ultmo]? * [30] Marks ::= 'M' [nce]? * [31] Numbers ::= 'N' [dlo]? * [32] Punctuation ::= 'P' [cdseifo]? * [33] Separators ::= 'Z' [slp]? * [34] Symbols ::= 'S' [mcko]? * [35] Others ::= 'C' [cfon]? * [36] IsBlock ::= 'Is' [a-zA-Z0-9#x2D]+ */ static void xmlFAParseCharProp(xmlRegParserCtxtPtr ctxt) { int cur; xmlRegAtomType type = (xmlRegAtomType) 0; xmlChar *blockName = NULL; cur = CUR; if (cur == 'L') { NEXT; cur = CUR; if (cur == 'u') { NEXT; type = XML_REGEXP_LETTER_UPPERCASE; } else if (cur == 'l') { NEXT; type = XML_REGEXP_LETTER_LOWERCASE; } else if (cur == 't') { NEXT; type = XML_REGEXP_LETTER_TITLECASE; } else if (cur == 'm') { NEXT; type = XML_REGEXP_LETTER_MODIFIER; } else if (cur == 'o') { NEXT; type = XML_REGEXP_LETTER_OTHERS; } else { type = XML_REGEXP_LETTER; } } else if (cur == 'M') { NEXT; cur = CUR; if (cur == 'n') { NEXT; /* nonspacing */ type = XML_REGEXP_MARK_NONSPACING; } else if (cur == 'c') { NEXT; /* spacing combining */ type = XML_REGEXP_MARK_SPACECOMBINING; } else if (cur == 'e') { NEXT; /* enclosing */ type = XML_REGEXP_MARK_ENCLOSING; } else { /* all marks */ type = XML_REGEXP_MARK; } } else if (cur == 'N') { NEXT; cur = CUR; if (cur == 'd') { NEXT; /* digital */ type = XML_REGEXP_NUMBER_DECIMAL; } else if (cur == 'l') { NEXT; /* letter */ type = XML_REGEXP_NUMBER_LETTER; } else if (cur == 'o') { NEXT; /* other */ type = XML_REGEXP_NUMBER_OTHERS; } else { /* all numbers */ type = XML_REGEXP_NUMBER; } } else if (cur == 'P') { NEXT; cur = CUR; if (cur == 'c') { NEXT; /* connector */ type = XML_REGEXP_PUNCT_CONNECTOR; } else if (cur == 'd') { NEXT; /* dash */ type = XML_REGEXP_PUNCT_DASH; } else if (cur == 's') { NEXT; /* open */ type = XML_REGEXP_PUNCT_OPEN; } else if (cur == 'e') { NEXT; /* close */ type = XML_REGEXP_PUNCT_CLOSE; } else if (cur == 'i') { NEXT; /* initial quote */ type = XML_REGEXP_PUNCT_INITQUOTE; } else if (cur == 'f') { NEXT; /* final quote */ type = XML_REGEXP_PUNCT_FINQUOTE; } else if (cur == 'o') { NEXT; /* other */ type = XML_REGEXP_PUNCT_OTHERS; } else { /* all punctuation */ type = XML_REGEXP_PUNCT; } } else if (cur == 'Z') { NEXT; cur = CUR; if (cur == 's') { NEXT; /* space */ type = XML_REGEXP_SEPAR_SPACE; } else if (cur == 'l') { NEXT; /* line */ type = XML_REGEXP_SEPAR_LINE; } else if (cur == 'p') { NEXT; /* paragraph */ type = XML_REGEXP_SEPAR_PARA; } else { /* all separators */ type = XML_REGEXP_SEPAR; } } else if (cur == 'S') { NEXT; cur = CUR; if (cur == 'm') { NEXT; type = XML_REGEXP_SYMBOL_MATH; /* math */ } else if (cur == 'c') { NEXT; type = XML_REGEXP_SYMBOL_CURRENCY; /* currency */ } else if (cur == 'k') { NEXT; type = XML_REGEXP_SYMBOL_MODIFIER; /* modifiers */ } else if (cur == 'o') { NEXT; type = XML_REGEXP_SYMBOL_OTHERS; /* other */ } else { /* all symbols */ type = XML_REGEXP_SYMBOL; } } else if (cur == 'C') { NEXT; cur = CUR; if (cur == 'c') { NEXT; /* control */ type = XML_REGEXP_OTHER_CONTROL; } else if (cur == 'f') { NEXT; /* format */ type = XML_REGEXP_OTHER_FORMAT; } else if (cur == 'o') { NEXT; /* private use */ type = XML_REGEXP_OTHER_PRIVATE; } else if (cur == 'n') { NEXT; /* not assigned */ type = XML_REGEXP_OTHER_NA; } else { /* all others */ type = XML_REGEXP_OTHER; } } else if (cur == 'I') { const xmlChar *start; NEXT; cur = CUR; if (cur != 's') { ERROR("IsXXXX expected"); return; } NEXT; start = ctxt->cur; cur = CUR; if (((cur >= 'a') && (cur <= 'z')) || ((cur >= 'A') && (cur <= 'Z')) || ((cur >= '0') && (cur <= '9')) || (cur == 0x2D)) { NEXT; cur = CUR; while (((cur >= 'a') && (cur <= 'z')) || ((cur >= 'A') && (cur <= 'Z')) || ((cur >= '0') && (cur <= '9')) || (cur == 0x2D)) { NEXT; cur = CUR; } } type = XML_REGEXP_BLOCK_NAME; blockName = xmlStrndup(start, ctxt->cur - start); } else { ERROR("Unknown char property"); return; } if (ctxt->atom == NULL) { ctxt->atom = xmlRegNewAtom(ctxt, type); if (ctxt->atom != NULL) ctxt->atom->valuep = blockName; } else if (ctxt->atom->type == XML_REGEXP_RANGES) { xmlRegAtomAddRange(ctxt, ctxt->atom, ctxt->neg, type, 0, 0, blockName); } } /** * xmlFAParseCharClassEsc: * @ctxt: a regexp parser context * * [23] charClassEsc ::= ( SingleCharEsc | MultiCharEsc | catEsc | complEsc ) * [24] SingleCharEsc ::= '\' [nrt\|.?*+(){}#x2D#x5B#x5D#x5E] * [25] catEsc ::= '\p{' charProp '}' * [26] complEsc ::= '\P{' charProp '}' * [37] MultiCharEsc ::= '.' | ('\' [sSiIcCdDwW]) */ static void xmlFAParseCharClassEsc(xmlRegParserCtxtPtr ctxt) { int cur; if (CUR == '.') { if (ctxt->atom == NULL) { ctxt->atom = xmlRegNewAtom(ctxt, XML_REGEXP_ANYCHAR); } else if (ctxt->atom->type == XML_REGEXP_RANGES) { xmlRegAtomAddRange(ctxt, ctxt->atom, ctxt->neg, XML_REGEXP_ANYCHAR, 0, 0, NULL); } NEXT; return; } if (CUR != '\\') { ERROR("Escaped sequence: expecting \\"); return; } NEXT; cur = CUR; if (cur == 'p') { NEXT; if (CUR != '{') { ERROR("Expecting '{'"); return; } NEXT; xmlFAParseCharProp(ctxt); if (CUR != '}') { ERROR("Expecting '}'"); return; } NEXT; } else if (cur == 'P') { NEXT; if (CUR != '{') { ERROR("Expecting '{'"); return; } NEXT; xmlFAParseCharProp(ctxt); ctxt->atom->neg = 1; if (CUR != '}') { ERROR("Expecting '}'"); return; } NEXT; } else if ((cur == 'n') || (cur == 'r') || (cur == 't') || (cur == '\\') || (cur == '|') || (cur == '.') || (cur == '?') || (cur == '*') || (cur == '+') || (cur == '(') || (cur == ')') || (cur == '{') || (cur == '}') || (cur == 0x2D) || (cur == 0x5B) || (cur == 0x5D) || (cur == 0x5E)) { if (ctxt->atom == NULL) { ctxt->atom = xmlRegNewAtom(ctxt, XML_REGEXP_CHARVAL); if (ctxt->atom != NULL) { switch (cur) { case 'n': ctxt->atom->codepoint = '\n'; break; case 'r': ctxt->atom->codepoint = '\r'; break; case 't': ctxt->atom->codepoint = '\t'; break; default: ctxt->atom->codepoint = cur; } } } else if (ctxt->atom->type == XML_REGEXP_RANGES) { xmlRegAtomAddRange(ctxt, ctxt->atom, ctxt->neg, XML_REGEXP_CHARVAL, cur, cur, NULL); } NEXT; } else if ((cur == 's') || (cur == 'S') || (cur == 'i') || (cur == 'I') || (cur == 'c') || (cur == 'C') || (cur == 'd') || (cur == 'D') || (cur == 'w') || (cur == 'W')) { xmlRegAtomType type = XML_REGEXP_ANYSPACE; switch (cur) { case 's': type = XML_REGEXP_ANYSPACE; break; case 'S': type = XML_REGEXP_NOTSPACE; break; case 'i': type = XML_REGEXP_INITNAME; break; case 'I': type = XML_REGEXP_NOTINITNAME; break; case 'c': type = XML_REGEXP_NAMECHAR; break; case 'C': type = XML_REGEXP_NOTNAMECHAR; break; case 'd': type = XML_REGEXP_DECIMAL; break; case 'D': type = XML_REGEXP_NOTDECIMAL; break; case 'w': type = XML_REGEXP_REALCHAR; break; case 'W': type = XML_REGEXP_NOTREALCHAR; break; } NEXT; if (ctxt->atom == NULL) { ctxt->atom = xmlRegNewAtom(ctxt, type); } else if (ctxt->atom->type == XML_REGEXP_RANGES) { xmlRegAtomAddRange(ctxt, ctxt->atom, ctxt->neg, type, 0, 0, NULL); } } } /** * xmlFAParseCharRef: * @ctxt: a regexp parser context * * [19] XmlCharRef ::= ( '&#' [0-9]+ ';' ) | (' &#x' [0-9a-fA-F]+ ';' ) */ static int xmlFAParseCharRef(xmlRegParserCtxtPtr ctxt) { int ret = 0, cur; if ((CUR != '&') || (NXT(1) != '#')) return(-1); NEXT; NEXT; cur = CUR; if (cur == 'x') { NEXT; cur = CUR; if (((cur >= '0') && (cur <= '9')) || ((cur >= 'a') && (cur <= 'f')) || ((cur >= 'A') && (cur <= 'F'))) { while (((cur >= '0') && (cur <= '9')) || ((cur >= 'a') && (cur <= 'f')) || ((cur >= 'A') && (cur <= 'F'))) { if ((cur >= '0') && (cur <= '9')) ret = ret * 16 + cur - '0'; else if ((cur >= 'a') && (cur <= 'f')) ret = ret * 16 + 10 + (cur - 'a'); else ret = ret * 16 + 10 + (cur - 'A'); NEXT; cur = CUR; } } else { ERROR("Char ref: expecting [0-9A-F]"); return(-1); } } else { if ((cur >= '0') && (cur <= '9')) { while ((cur >= '0') && (cur <= '9')) { ret = ret * 10 + cur - '0'; NEXT; cur = CUR; } } else { ERROR("Char ref: expecting [0-9]"); return(-1); } } if (cur != ';') { ERROR("Char ref: expecting ';'"); return(-1); } else { NEXT; } return(ret); } /** * xmlFAParseCharRange: * @ctxt: a regexp parser context * * [17] charRange ::= seRange | XmlCharRef | XmlCharIncDash * [18] seRange ::= charOrEsc '-' charOrEsc * [20] charOrEsc ::= XmlChar | SingleCharEsc * [21] XmlChar ::= [^\#x2D#x5B#x5D] * [22] XmlCharIncDash ::= [^\#x5B#x5D] */ static void xmlFAParseCharRange(xmlRegParserCtxtPtr ctxt) { int cur, len; int start = -1; int end = -1; if (CUR == '\0') { ERROR("Expecting ']'"); return; } if ((CUR == '&') && (NXT(1) == '#')) { end = start = xmlFAParseCharRef(ctxt); xmlRegAtomAddRange(ctxt, ctxt->atom, ctxt->neg, XML_REGEXP_CHARVAL, start, end, NULL); return; } cur = CUR; if (cur == '\\') { NEXT; cur = CUR; switch (cur) { case 'n': start = 0xA; break; case 'r': start = 0xD; break; case 't': start = 0x9; break; case '\\': case '|': case '.': case '-': case '^': case '?': case '*': case '+': case '{': case '}': case '(': case ')': case '[': case ']': start = cur; break; default: ERROR("Invalid escape value"); return; } end = start; len = 1; } else if ((cur != 0x5B) && (cur != 0x5D)) { end = start = CUR_SCHAR(ctxt->cur, len); } else { ERROR("Expecting a char range"); return; } NEXTL(len); if (start == '-') { return; } cur = CUR; if ((cur != '-') || (NXT(1) == ']')) { xmlRegAtomAddRange(ctxt, ctxt->atom, ctxt->neg, XML_REGEXP_CHARVAL, start, end, NULL); return; } NEXT; cur = CUR; if (cur == '\\') { NEXT; cur = CUR; switch (cur) { case 'n': end = 0xA; break; case 'r': end = 0xD; break; case 't': end = 0x9; break; case '\\': case '|': case '.': case '-': case '^': case '?': case '*': case '+': case '{': case '}': case '(': case ')': case '[': case ']': end = cur; break; default: ERROR("Invalid escape value"); return; } len = 1; } else if ((cur != 0x5B) && (cur != 0x5D)) { end = CUR_SCHAR(ctxt->cur, len); } else { ERROR("Expecting the end of a char range"); return; } NEXTL(len); /* TODO check that the values are acceptable character ranges for XML */ if (end < start) { ERROR("End of range is before start of range"); } else { xmlRegAtomAddRange(ctxt, ctxt->atom, ctxt->neg, XML_REGEXP_CHARVAL, start, end, NULL); } return; } /** * xmlFAParsePosCharGroup: * @ctxt: a regexp parser context * * [14] posCharGroup ::= ( charRange | charClassEsc )+ */ static void xmlFAParsePosCharGroup(xmlRegParserCtxtPtr ctxt) { do { if ((CUR == '\\') || (CUR == '.')) { xmlFAParseCharClassEsc(ctxt); } else { xmlFAParseCharRange(ctxt); } } while ((CUR != ']') && (CUR != '^') && (CUR != '-') && (CUR != 0) && (ctxt->error == 0)); } /** * xmlFAParseCharGroup: * @ctxt: a regexp parser context * * [13] charGroup ::= posCharGroup | negCharGroup | charClassSub * [15] negCharGroup ::= '^' posCharGroup * [16] charClassSub ::= ( posCharGroup | negCharGroup ) '-' charClassExpr * [12] charClassExpr ::= '[' charGroup ']' */ static void xmlFAParseCharGroup(xmlRegParserCtxtPtr ctxt) { int n = ctxt->neg; while ((CUR != ']') && (ctxt->error == 0)) { if (CUR == '^') { int neg = ctxt->neg; NEXT; ctxt->neg = !ctxt->neg; xmlFAParsePosCharGroup(ctxt); ctxt->neg = neg; } else if ((CUR == '-') && (NXT(1) == '[')) { int neg = ctxt->neg; ctxt->neg = 2; NEXT; /* eat the '-' */ NEXT; /* eat the '[' */ xmlFAParseCharGroup(ctxt); if (CUR == ']') { NEXT; } else { ERROR("charClassExpr: ']' expected"); break; } ctxt->neg = neg; break; } else if (CUR != ']') { xmlFAParsePosCharGroup(ctxt); } } ctxt->neg = n; } /** * xmlFAParseCharClass: * @ctxt: a regexp parser context * * [11] charClass ::= charClassEsc | charClassExpr * [12] charClassExpr ::= '[' charGroup ']' */ static void xmlFAParseCharClass(xmlRegParserCtxtPtr ctxt) { if (CUR == '[') { NEXT; ctxt->atom = xmlRegNewAtom(ctxt, XML_REGEXP_RANGES); if (ctxt->atom == NULL) return; xmlFAParseCharGroup(ctxt); if (CUR == ']') { NEXT; } else { ERROR("xmlFAParseCharClass: ']' expected"); } } else { xmlFAParseCharClassEsc(ctxt); } } /** * xmlFAParseQuantExact: * @ctxt: a regexp parser context * * [8] QuantExact ::= [0-9]+ * * Returns 0 if success or -1 in case of error */ static int xmlFAParseQuantExact(xmlRegParserCtxtPtr ctxt) { int ret = 0; int ok = 0; while ((CUR >= '0') && (CUR <= '9')) { ret = ret * 10 + (CUR - '0'); ok = 1; NEXT; } if (ok != 1) { return(-1); } return(ret); } /** * xmlFAParseQuantifier: * @ctxt: a regexp parser context * * [4] quantifier ::= [?*+] | ( '{' quantity '}' ) * [5] quantity ::= quantRange | quantMin | QuantExact * [6] quantRange ::= QuantExact ',' QuantExact * [7] quantMin ::= QuantExact ',' * [8] QuantExact ::= [0-9]+ */ static int xmlFAParseQuantifier(xmlRegParserCtxtPtr ctxt) { int cur; cur = CUR; if ((cur == '?') || (cur == '*') || (cur == '+')) { if (ctxt->atom != NULL) { if (cur == '?') ctxt->atom->quant = XML_REGEXP_QUANT_OPT; else if (cur == '*') ctxt->atom->quant = XML_REGEXP_QUANT_MULT; else if (cur == '+') ctxt->atom->quant = XML_REGEXP_QUANT_PLUS; } NEXT; return(1); } if (cur == '{') { int min = 0, max = 0; NEXT; cur = xmlFAParseQuantExact(ctxt); if (cur >= 0) min = cur; if (CUR == ',') { NEXT; if (CUR == '}') max = INT_MAX; else { cur = xmlFAParseQuantExact(ctxt); if (cur >= 0) max = cur; else { ERROR("Improper quantifier"); } } } if (CUR == '}') { NEXT; } else { ERROR("Unterminated quantifier"); } if (max == 0) max = min; if (ctxt->atom != NULL) { ctxt->atom->quant = XML_REGEXP_QUANT_RANGE; ctxt->atom->min = min; ctxt->atom->max = max; } return(1); } return(0); } /** * xmlFAParseAtom: * @ctxt: a regexp parser context * * [9] atom ::= Char | charClass | ( '(' regExp ')' ) */ static int xmlFAParseAtom(xmlRegParserCtxtPtr ctxt) { int codepoint, len; codepoint = xmlFAIsChar(ctxt); if (codepoint > 0) { ctxt->atom = xmlRegNewAtom(ctxt, XML_REGEXP_CHARVAL); if (ctxt->atom == NULL) return(-1); codepoint = CUR_SCHAR(ctxt->cur, len); ctxt->atom->codepoint = codepoint; NEXTL(len); return(1); } else if (CUR == '|') { return(0); } else if (CUR == 0) { return(0); } else if (CUR == ')') { return(0); } else if (CUR == '(') { xmlRegStatePtr start, oldend; NEXT; xmlFAGenerateEpsilonTransition(ctxt, ctxt->state, NULL); start = ctxt->state; oldend = ctxt->end; ctxt->end = NULL; ctxt->atom = NULL; xmlFAParseRegExp(ctxt, 0); if (CUR == ')') { NEXT; } else { ERROR("xmlFAParseAtom: expecting ')'"); } ctxt->atom = xmlRegNewAtom(ctxt, XML_REGEXP_SUBREG); if (ctxt->atom == NULL) return(-1); ctxt->atom->start = start; ctxt->atom->stop = ctxt->state; ctxt->end = oldend; return(1); } else if ((CUR == '[') || (CUR == '\\') || (CUR == '.')) { xmlFAParseCharClass(ctxt); return(1); } return(0); } /** * xmlFAParsePiece: * @ctxt: a regexp parser context * * [3] piece ::= atom quantifier? */ static int xmlFAParsePiece(xmlRegParserCtxtPtr ctxt) { int ret; ctxt->atom = NULL; ret = xmlFAParseAtom(ctxt); if (ret == 0) return(0); if (ctxt->atom == NULL) { ERROR("internal: no atom generated"); } xmlFAParseQuantifier(ctxt); return(1); } /** * xmlFAParseBranch: * @ctxt: a regexp parser context * @to: optional target to the end of the branch * * @to is used to optimize by removing duplicate path in automata * in expressions like (a|b)(c|d) * * [2] branch ::= piece* */ static int xmlFAParseBranch(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr to) { xmlRegStatePtr previous; int ret; previous = ctxt->state; ret = xmlFAParsePiece(ctxt); if (ret != 0) { if (xmlFAGenerateTransitions(ctxt, previous, (CUR=='|' || CUR==')') ? to : NULL, ctxt->atom) < 0) return(-1); previous = ctxt->state; ctxt->atom = NULL; } while ((ret != 0) && (ctxt->error == 0)) { ret = xmlFAParsePiece(ctxt); if (ret != 0) { if (xmlFAGenerateTransitions(ctxt, previous, (CUR=='|' || CUR==')') ? to : NULL, ctxt->atom) < 0) return(-1); previous = ctxt->state; ctxt->atom = NULL; } } return(0); } /** * xmlFAParseRegExp: * @ctxt: a regexp parser context * @top: is this the top-level expression ? * * [1] regExp ::= branch ( '|' branch )* */ static void xmlFAParseRegExp(xmlRegParserCtxtPtr ctxt, int top) { xmlRegStatePtr start, end; /* if not top start should have been generated by an epsilon trans */ start = ctxt->state; ctxt->end = NULL; xmlFAParseBranch(ctxt, NULL); if (top) { #ifdef DEBUG_REGEXP_GRAPH printf("State %d is final\n", ctxt->state->no); #endif ctxt->state->type = XML_REGEXP_FINAL_STATE; } if (CUR != '|') { ctxt->end = ctxt->state; return; } end = ctxt->state; while ((CUR == '|') && (ctxt->error == 0)) { NEXT; ctxt->state = start; ctxt->end = NULL; xmlFAParseBranch(ctxt, end); } if (!top) { ctxt->state = end; ctxt->end = end; } } /************************************************************************ * * * The basic API * * * ************************************************************************/ /** * xmlRegexpPrint: * @output: the file for the output debug * @regexp: the compiled regexp * * Print the content of the compiled regular expression */ void xmlRegexpPrint(FILE *output, xmlRegexpPtr regexp) { int i; if (output == NULL) return; fprintf(output, " regexp: "); if (regexp == NULL) { fprintf(output, "NULL\n"); return; } fprintf(output, "'%s' ", regexp->string); fprintf(output, "\n"); fprintf(output, "%d atoms:\n", regexp->nbAtoms); for (i = 0;i < regexp->nbAtoms; i++) { fprintf(output, " %02d ", i); xmlRegPrintAtom(output, regexp->atoms[i]); } fprintf(output, "%d states:", regexp->nbStates); fprintf(output, "\n"); for (i = 0;i < regexp->nbStates; i++) { xmlRegPrintState(output, regexp->states[i]); } fprintf(output, "%d counters:\n", regexp->nbCounters); for (i = 0;i < regexp->nbCounters; i++) { fprintf(output, " %d: min %d max %d\n", i, regexp->counters[i].min, regexp->counters[i].max); } } /** * xmlRegexpCompile: * @regexp: a regular expression string * * Parses a regular expression conforming to XML Schemas Part 2 Datatype * Appendix F and builds an automata suitable for testing strings against * that regular expression * * Returns the compiled expression or NULL in case of error */ xmlRegexpPtr xmlRegexpCompile(const xmlChar *regexp) { xmlRegexpPtr ret; xmlRegParserCtxtPtr ctxt; ctxt = xmlRegNewParserCtxt(regexp); if (ctxt == NULL) return(NULL); /* initialize the parser */ ctxt->end = NULL; ctxt->start = ctxt->state = xmlRegNewState(ctxt); xmlRegStatePush(ctxt, ctxt->start); /* parse the expression building an automata */ xmlFAParseRegExp(ctxt, 1); if (CUR != 0) { ERROR("xmlFAParseRegExp: extra characters"); } ctxt->end = ctxt->state; ctxt->start->type = XML_REGEXP_START_STATE; ctxt->end->type = XML_REGEXP_FINAL_STATE; /* remove the Epsilon except for counted transitions */ xmlFAEliminateEpsilonTransitions(ctxt); if (ctxt->error != 0) { xmlRegFreeParserCtxt(ctxt); return(NULL); } ret = xmlRegEpxFromParse(ctxt); xmlRegFreeParserCtxt(ctxt); return(ret); } /** * xmlRegexpExec: * @comp: the compiled regular expression * @content: the value to check against the regular expression * * Check if the regular expression generates the value * * Returns 1 if it matches, 0 if not and a negative value in case of error */ int xmlRegexpExec(xmlRegexpPtr comp, const xmlChar *content) { if ((comp == NULL) || (content == NULL)) return(-1); return(xmlFARegExec(comp, content)); } /** * xmlRegexpIsDeterminist: * @comp: the compiled regular expression * * Check if the regular expression is determinist * * Returns 1 if it yes, 0 if not and a negative value in case of error */ int xmlRegexpIsDeterminist(xmlRegexpPtr comp) { xmlAutomataPtr am; int ret; if (comp == NULL) return(-1); if (comp->determinist != -1) return(comp->determinist); am = xmlNewAutomata(); if (am->states != NULL) { int i; for (i = 0;i < am->nbStates;i++) xmlRegFreeState(am->states[i]); xmlFree(am->states); } am->nbAtoms = comp->nbAtoms; am->atoms = comp->atoms; am->nbStates = comp->nbStates; am->states = comp->states; am->determinist = -1; ret = xmlFAComputesDeterminism(am); am->atoms = NULL; am->states = NULL; xmlFreeAutomata(am); return(ret); } /** * xmlRegFreeRegexp: * @regexp: the regexp * * Free a regexp */ void xmlRegFreeRegexp(xmlRegexpPtr regexp) { int i; if (regexp == NULL) return; if (regexp->string != NULL) xmlFree(regexp->string); if (regexp->states != NULL) { for (i = 0;i < regexp->nbStates;i++) xmlRegFreeState(regexp->states[i]); xmlFree(regexp->states); } if (regexp->atoms != NULL) { for (i = 0;i < regexp->nbAtoms;i++) xmlRegFreeAtom(regexp->atoms[i]); xmlFree(regexp->atoms); } if (regexp->counters != NULL) xmlFree(regexp->counters); if (regexp->compact != NULL) xmlFree(regexp->compact); if (regexp->transdata != NULL) xmlFree(regexp->transdata); if (regexp->stringMap != NULL) { for (i = 0; i < regexp->nbstrings;i++) xmlFree(regexp->stringMap[i]); xmlFree(regexp->stringMap); } xmlFree(regexp); } #ifdef LIBXML_AUTOMATA_ENABLED /************************************************************************ * * * The Automata interface * * * ************************************************************************/ /** * xmlNewAutomata: * * Create a new automata * * Returns the new object or NULL in case of failure */ xmlAutomataPtr xmlNewAutomata(void) { xmlAutomataPtr ctxt; ctxt = xmlRegNewParserCtxt(NULL); if (ctxt == NULL) return(NULL); /* initialize the parser */ ctxt->end = NULL; ctxt->start = ctxt->state = xmlRegNewState(ctxt); if (ctxt->start == NULL) { xmlFreeAutomata(ctxt); return(NULL); } ctxt->start->type = XML_REGEXP_START_STATE; if (xmlRegStatePush(ctxt, ctxt->start) < 0) { xmlRegFreeState(ctxt->start); xmlFreeAutomata(ctxt); return(NULL); } return(ctxt); } /** * xmlFreeAutomata: * @am: an automata * * Free an automata */ void xmlFreeAutomata(xmlAutomataPtr am) { if (am == NULL) return; xmlRegFreeParserCtxt(am); } /** * xmlAutomataGetInitState: * @am: an automata * * Initial state lookup * * Returns the initial state of the automata */ xmlAutomataStatePtr xmlAutomataGetInitState(xmlAutomataPtr am) { if (am == NULL) return(NULL); return(am->start); } /** * xmlAutomataSetFinalState: * @am: an automata * @state: a state in this automata * * Makes that state a final state * * Returns 0 or -1 in case of error */ int xmlAutomataSetFinalState(xmlAutomataPtr am, xmlAutomataStatePtr state) { if ((am == NULL) || (state == NULL)) return(-1); state->type = XML_REGEXP_FINAL_STATE; return(0); } /** * xmlAutomataNewTransition: * @am: an automata * @from: the starting point of the transition * @to: the target point of the transition or NULL * @token: the input string associated to that transition * @data: data passed to the callback function if the transition is activated * * If @to is NULL, this creates first a new target state in the automata * and then adds a transition from the @from state to the target state * activated by the value of @token * * Returns the target state or NULL in case of error */ xmlAutomataStatePtr xmlAutomataNewTransition(xmlAutomataPtr am, xmlAutomataStatePtr from, xmlAutomataStatePtr to, const xmlChar *token, void *data) { xmlRegAtomPtr atom; if ((am == NULL) || (from == NULL) || (token == NULL)) return(NULL); atom = xmlRegNewAtom(am, XML_REGEXP_STRING); if (atom == NULL) return(NULL); atom->data = data; if (atom == NULL) return(NULL); atom->valuep = xmlStrdup(token); if (xmlFAGenerateTransitions(am, from, to, atom) < 0) { xmlRegFreeAtom(atom); return(NULL); } if (to == NULL) return(am->state); return(to); } /** * xmlAutomataNewTransition2: * @am: an automata * @from: the starting point of the transition * @to: the target point of the transition or NULL * @token: the first input string associated to that transition * @token2: the second input string associated to that transition * @data: data passed to the callback function if the transition is activated * * If @to is NULL, this creates first a new target state in the automata * and then adds a transition from the @from state to the target state * activated by the value of @token * * Returns the target state or NULL in case of error */ xmlAutomataStatePtr xmlAutomataNewTransition2(xmlAutomataPtr am, xmlAutomataStatePtr from, xmlAutomataStatePtr to, const xmlChar *token, const xmlChar *token2, void *data) { xmlRegAtomPtr atom; if ((am == NULL) || (from == NULL) || (token == NULL)) return(NULL); atom = xmlRegNewAtom(am, XML_REGEXP_STRING); if (atom == NULL) return(NULL); atom->data = data; if ((token2 == NULL) || (*token2 == 0)) { atom->valuep = xmlStrdup(token); } else { int lenn, lenp; xmlChar *str; lenn = strlen((char *) token2); lenp = strlen((char *) token); str = (xmlChar *) xmlMallocAtomic(lenn + lenp + 2); if (str == NULL) { xmlRegFreeAtom(atom); return(NULL); } memcpy(&str[0], token, lenp); str[lenp] = '|'; memcpy(&str[lenp + 1], token2, lenn); str[lenn + lenp + 1] = 0; atom->valuep = str; } if (xmlFAGenerateTransitions(am, from, to, atom) < 0) { xmlRegFreeAtom(atom); return(NULL); } if (to == NULL) return(am->state); return(to); } /** * xmlAutomataNewNegTrans: * @am: an automata * @from: the starting point of the transition * @to: the target point of the transition or NULL * @token: the first input string associated to that transition * @token2: the second input string associated to that transition * @data: data passed to the callback function if the transition is activated * * If @to is NULL, this creates first a new target state in the automata * and then adds a transition from the @from state to the target state * activated by any value except (@token,@token2) * Note that if @token2 is not NULL, then (X, NULL) won't match to follow # the semantic of XSD ##other * * Returns the target state or NULL in case of error */ xmlAutomataStatePtr xmlAutomataNewNegTrans(xmlAutomataPtr am, xmlAutomataStatePtr from, xmlAutomataStatePtr to, const xmlChar *token, const xmlChar *token2, void *data) { xmlRegAtomPtr atom; xmlChar err_msg[200]; if ((am == NULL) || (from == NULL) || (token == NULL)) return(NULL); atom = xmlRegNewAtom(am, XML_REGEXP_STRING); if (atom == NULL) return(NULL); atom->data = data; atom->neg = 1; if ((token2 == NULL) || (*token2 == 0)) { atom->valuep = xmlStrdup(token); } else { int lenn, lenp; xmlChar *str; lenn = strlen((char *) token2); lenp = strlen((char *) token); str = (xmlChar *) xmlMallocAtomic(lenn + lenp + 2); if (str == NULL) { xmlRegFreeAtom(atom); return(NULL); } memcpy(&str[0], token, lenp); str[lenp] = '|'; memcpy(&str[lenp + 1], token2, lenn); str[lenn + lenp + 1] = 0; atom->valuep = str; } snprintf((char *) err_msg, 199, "not %s", (const char *) atom->valuep); err_msg[199] = 0; atom->valuep2 = xmlStrdup(err_msg); if (xmlFAGenerateTransitions(am, from, to, atom) < 0) { xmlRegFreeAtom(atom); return(NULL); } am->negs++; if (to == NULL) return(am->state); return(to); } /** * xmlAutomataNewCountTrans2: * @am: an automata * @from: the starting point of the transition * @to: the target point of the transition or NULL * @token: the input string associated to that transition * @token2: the second input string associated to that transition * @min: the minimum successive occurences of token * @max: the maximum successive occurences of token * @data: data associated to the transition * * If @to is NULL, this creates first a new target state in the automata * and then adds a transition from the @from state to the target state * activated by a succession of input of value @token and @token2 and * whose number is between @min and @max * * Returns the target state or NULL in case of error */ xmlAutomataStatePtr xmlAutomataNewCountTrans2(xmlAutomataPtr am, xmlAutomataStatePtr from, xmlAutomataStatePtr to, const xmlChar *token, const xmlChar *token2, int min, int max, void *data) { xmlRegAtomPtr atom; int counter; if ((am == NULL) || (from == NULL) || (token == NULL)) return(NULL); if (min < 0) return(NULL); if ((max < min) || (max < 1)) return(NULL); atom = xmlRegNewAtom(am, XML_REGEXP_STRING); if (atom == NULL) return(NULL); if ((token2 == NULL) || (*token2 == 0)) { atom->valuep = xmlStrdup(token); } else { int lenn, lenp; xmlChar *str; lenn = strlen((char *) token2); lenp = strlen((char *) token); str = (xmlChar *) xmlMallocAtomic(lenn + lenp + 2); if (str == NULL) { xmlRegFreeAtom(atom); return(NULL); } memcpy(&str[0], token, lenp); str[lenp] = '|'; memcpy(&str[lenp + 1], token2, lenn); str[lenn + lenp + 1] = 0; atom->valuep = str; } atom->data = data; if (min == 0) atom->min = 1; else atom->min = min; atom->max = max; /* * associate a counter to the transition. */ counter = xmlRegGetCounter(am); am->counters[counter].min = min; am->counters[counter].max = max; /* xmlFAGenerateTransitions(am, from, to, atom); */ if (to == NULL) { to = xmlRegNewState(am); xmlRegStatePush(am, to); } xmlRegStateAddTrans(am, from, atom, to, counter, -1); xmlRegAtomPush(am, atom); am->state = to; if (to == NULL) to = am->state; if (to == NULL) return(NULL); if (min == 0) xmlFAGenerateEpsilonTransition(am, from, to); return(to); } /** * xmlAutomataNewCountTrans: * @am: an automata * @from: the starting point of the transition * @to: the target point of the transition or NULL * @token: the input string associated to that transition * @min: the minimum successive occurences of token * @max: the maximum successive occurences of token * @data: data associated to the transition * * If @to is NULL, this creates first a new target state in the automata * and then adds a transition from the @from state to the target state * activated by a succession of input of value @token and whose number * is between @min and @max * * Returns the target state or NULL in case of error */ xmlAutomataStatePtr xmlAutomataNewCountTrans(xmlAutomataPtr am, xmlAutomataStatePtr from, xmlAutomataStatePtr to, const xmlChar *token, int min, int max, void *data) { xmlRegAtomPtr atom; int counter; if ((am == NULL) || (from == NULL) || (token == NULL)) return(NULL); if (min < 0) return(NULL); if ((max < min) || (max < 1)) return(NULL); atom = xmlRegNewAtom(am, XML_REGEXP_STRING); if (atom == NULL) return(NULL); atom->valuep = xmlStrdup(token); atom->data = data; if (min == 0) atom->min = 1; else atom->min = min; atom->max = max; /* * associate a counter to the transition. */ counter = xmlRegGetCounter(am); am->counters[counter].min = min; am->counters[counter].max = max; /* xmlFAGenerateTransitions(am, from, to, atom); */ if (to == NULL) { to = xmlRegNewState(am); xmlRegStatePush(am, to); } xmlRegStateAddTrans(am, from, atom, to, counter, -1); xmlRegAtomPush(am, atom); am->state = to; if (to == NULL) to = am->state; if (to == NULL) return(NULL); if (min == 0) xmlFAGenerateEpsilonTransition(am, from, to); return(to); } /** * xmlAutomataNewOnceTrans2: * @am: an automata * @from: the starting point of the transition * @to: the target point of the transition or NULL * @token: the input string associated to that transition * @token2: the second input string associated to that transition * @min: the minimum successive occurences of token * @max: the maximum successive occurences of token * @data: data associated to the transition * * If @to is NULL, this creates first a new target state in the automata * and then adds a transition from the @from state to the target state * activated by a succession of input of value @token and @token2 and whose * number is between @min and @max, moreover that transition can only be * crossed once. * * Returns the target state or NULL in case of error */ xmlAutomataStatePtr xmlAutomataNewOnceTrans2(xmlAutomataPtr am, xmlAutomataStatePtr from, xmlAutomataStatePtr to, const xmlChar *token, const xmlChar *token2, int min, int max, void *data) { xmlRegAtomPtr atom; int counter; if ((am == NULL) || (from == NULL) || (token == NULL)) return(NULL); if (min < 1) return(NULL); if ((max < min) || (max < 1)) return(NULL); atom = xmlRegNewAtom(am, XML_REGEXP_STRING); if (atom == NULL) return(NULL); if ((token2 == NULL) || (*token2 == 0)) { atom->valuep = xmlStrdup(token); } else { int lenn, lenp; xmlChar *str; lenn = strlen((char *) token2); lenp = strlen((char *) token); str = (xmlChar *) xmlMallocAtomic(lenn + lenp + 2); if (str == NULL) { xmlRegFreeAtom(atom); return(NULL); } memcpy(&str[0], token, lenp); str[lenp] = '|'; memcpy(&str[lenp + 1], token2, lenn); str[lenn + lenp + 1] = 0; atom->valuep = str; } atom->data = data; atom->quant = XML_REGEXP_QUANT_ONCEONLY; atom->min = min; atom->max = max; /* * associate a counter to the transition. */ counter = xmlRegGetCounter(am); am->counters[counter].min = 1; am->counters[counter].max = 1; /* xmlFAGenerateTransitions(am, from, to, atom); */ if (to == NULL) { to = xmlRegNewState(am); xmlRegStatePush(am, to); } xmlRegStateAddTrans(am, from, atom, to, counter, -1); xmlRegAtomPush(am, atom); am->state = to; return(to); } /** * xmlAutomataNewOnceTrans: * @am: an automata * @from: the starting point of the transition * @to: the target point of the transition or NULL * @token: the input string associated to that transition * @min: the minimum successive occurences of token * @max: the maximum successive occurences of token * @data: data associated to the transition * * If @to is NULL, this creates first a new target state in the automata * and then adds a transition from the @from state to the target state * activated by a succession of input of value @token and whose number * is between @min and @max, moreover that transition can only be crossed * once. * * Returns the target state or NULL in case of error */ xmlAutomataStatePtr xmlAutomataNewOnceTrans(xmlAutomataPtr am, xmlAutomataStatePtr from, xmlAutomataStatePtr to, const xmlChar *token, int min, int max, void *data) { xmlRegAtomPtr atom; int counter; if ((am == NULL) || (from == NULL) || (token == NULL)) return(NULL); if (min < 1) return(NULL); if ((max < min) || (max < 1)) return(NULL); atom = xmlRegNewAtom(am, XML_REGEXP_STRING); if (atom == NULL) return(NULL); atom->valuep = xmlStrdup(token); atom->data = data; atom->quant = XML_REGEXP_QUANT_ONCEONLY; atom->min = min; atom->max = max; /* * associate a counter to the transition. */ counter = xmlRegGetCounter(am); am->counters[counter].min = 1; am->counters[counter].max = 1; /* xmlFAGenerateTransitions(am, from, to, atom); */ if (to == NULL) { to = xmlRegNewState(am); xmlRegStatePush(am, to); } xmlRegStateAddTrans(am, from, atom, to, counter, -1); xmlRegAtomPush(am, atom); am->state = to; return(to); } /** * xmlAutomataNewState: * @am: an automata * * Create a new disconnected state in the automata * * Returns the new state or NULL in case of error */ xmlAutomataStatePtr xmlAutomataNewState(xmlAutomataPtr am) { xmlAutomataStatePtr to; if (am == NULL) return(NULL); to = xmlRegNewState(am); xmlRegStatePush(am, to); return(to); } /** * xmlAutomataNewEpsilon: * @am: an automata * @from: the starting point of the transition * @to: the target point of the transition or NULL * * If @to is NULL, this creates first a new target state in the automata * and then adds an epsilon transition from the @from state to the * target state * * Returns the target state or NULL in case of error */ xmlAutomataStatePtr xmlAutomataNewEpsilon(xmlAutomataPtr am, xmlAutomataStatePtr from, xmlAutomataStatePtr to) { if ((am == NULL) || (from == NULL)) return(NULL); xmlFAGenerateEpsilonTransition(am, from, to); if (to == NULL) return(am->state); return(to); } /** * xmlAutomataNewAllTrans: * @am: an automata * @from: the starting point of the transition * @to: the target point of the transition or NULL * @lax: allow to transition if not all all transitions have been activated * * If @to is NULL, this creates first a new target state in the automata * and then adds a an ALL transition from the @from state to the * target state. That transition is an epsilon transition allowed only when * all transitions from the @from node have been activated. * * Returns the target state or NULL in case of error */ xmlAutomataStatePtr xmlAutomataNewAllTrans(xmlAutomataPtr am, xmlAutomataStatePtr from, xmlAutomataStatePtr to, int lax) { if ((am == NULL) || (from == NULL)) return(NULL); xmlFAGenerateAllTransition(am, from, to, lax); if (to == NULL) return(am->state); return(to); } /** * xmlAutomataNewCounter: * @am: an automata * @min: the minimal value on the counter * @max: the maximal value on the counter * * Create a new counter * * Returns the counter number or -1 in case of error */ int xmlAutomataNewCounter(xmlAutomataPtr am, int min, int max) { int ret; if (am == NULL) return(-1); ret = xmlRegGetCounter(am); if (ret < 0) return(-1); am->counters[ret].min = min; am->counters[ret].max = max; return(ret); } /** * xmlAutomataNewCountedTrans: * @am: an automata * @from: the starting point of the transition * @to: the target point of the transition or NULL * @counter: the counter associated to that transition * * If @to is NULL, this creates first a new target state in the automata * and then adds an epsilon transition from the @from state to the target state * which will increment the counter provided * * Returns the target state or NULL in case of error */ xmlAutomataStatePtr xmlAutomataNewCountedTrans(xmlAutomataPtr am, xmlAutomataStatePtr from, xmlAutomataStatePtr to, int counter) { if ((am == NULL) || (from == NULL) || (counter < 0)) return(NULL); xmlFAGenerateCountedEpsilonTransition(am, from, to, counter); if (to == NULL) return(am->state); return(to); } /** * xmlAutomataNewCounterTrans: * @am: an automata * @from: the starting point of the transition * @to: the target point of the transition or NULL * @counter: the counter associated to that transition * * If @to is NULL, this creates first a new target state in the automata * and then adds an epsilon transition from the @from state to the target state * which will be allowed only if the counter is within the right range. * * Returns the target state or NULL in case of error */ xmlAutomataStatePtr xmlAutomataNewCounterTrans(xmlAutomataPtr am, xmlAutomataStatePtr from, xmlAutomataStatePtr to, int counter) { if ((am == NULL) || (from == NULL) || (counter < 0)) return(NULL); xmlFAGenerateCountedTransition(am, from, to, counter); if (to == NULL) return(am->state); return(to); } /** * xmlAutomataCompile: * @am: an automata * * Compile the automata into a Reg Exp ready for being executed. * The automata should be free after this point. * * Returns the compiled regexp or NULL in case of error */ xmlRegexpPtr xmlAutomataCompile(xmlAutomataPtr am) { xmlRegexpPtr ret; if ((am == NULL) || (am->error != 0)) return(NULL); xmlFAEliminateEpsilonTransitions(am); /* xmlFAComputesDeterminism(am); */ ret = xmlRegEpxFromParse(am); return(ret); } /** * xmlAutomataIsDeterminist: * @am: an automata * * Checks if an automata is determinist. * * Returns 1 if true, 0 if not, and -1 in case of error */ int xmlAutomataIsDeterminist(xmlAutomataPtr am) { int ret; if (am == NULL) return(-1); ret = xmlFAComputesDeterminism(am); return(ret); } #endif /* LIBXML_AUTOMATA_ENABLED */ #ifdef LIBXML_EXPR_ENABLED /************************************************************************ * * * Formal Expression handling code * * * ************************************************************************/ /************************************************************************ * * * Expression handling context * * * ************************************************************************/ struct _xmlExpCtxt { xmlDictPtr dict; xmlExpNodePtr *table; int size; int nbElems; int nb_nodes; const char *expr; const char *cur; int nb_cons; int tabSize; }; /** * xmlExpNewCtxt: * @maxNodes: the maximum number of nodes * @dict: optional dictionnary to use internally * * Creates a new context for manipulating expressions * * Returns the context or NULL in case of error */ xmlExpCtxtPtr xmlExpNewCtxt(int maxNodes, xmlDictPtr dict) { xmlExpCtxtPtr ret; int size = 256; if (maxNodes <= 4096) maxNodes = 4096; ret = (xmlExpCtxtPtr) xmlMalloc(sizeof(xmlExpCtxt)); if (ret == NULL) return(NULL); memset(ret, 0, sizeof(xmlExpCtxt)); ret->size = size; ret->nbElems = 0; ret->table = xmlMalloc(size * sizeof(xmlExpNodePtr)); if (ret->table == NULL) { xmlFree(ret); return(NULL); } memset(ret->table, 0, size * sizeof(xmlExpNodePtr)); if (dict == NULL) { ret->dict = xmlDictCreate(); if (ret->dict == NULL) { xmlFree(ret->table); xmlFree(ret); return(NULL); } } else { ret->dict = dict; xmlDictReference(ret->dict); } return(ret); } /** * xmlExpFreeCtxt: * @ctxt: an expression context * * Free an expression context */ void xmlExpFreeCtxt(xmlExpCtxtPtr ctxt) { if (ctxt == NULL) return; xmlDictFree(ctxt->dict); if (ctxt->table != NULL) xmlFree(ctxt->table); xmlFree(ctxt); } /************************************************************************ * * * Structure associated to an expression node * * * ************************************************************************/ #define MAX_NODES 10000 /* #define DEBUG_DERIV */ /* * TODO: * - Wildcards * - public API for creation * * Started * - regression testing * * Done * - split into module and test tool * - memleaks */ typedef enum { XML_EXP_NILABLE = (1 << 0) } xmlExpNodeInfo; #define IS_NILLABLE(node) ((node)->info & XML_EXP_NILABLE) struct _xmlExpNode { unsigned char type;/* xmlExpNodeType */ unsigned char info;/* OR of xmlExpNodeInfo */ unsigned short key; /* the hash key */ unsigned int ref; /* The number of references */ int c_max; /* the maximum length it can consume */ xmlExpNodePtr exp_left; xmlExpNodePtr next;/* the next node in the hash table or free list */ union { struct { int f_min; int f_max; } count; struct { xmlExpNodePtr f_right; } children; const xmlChar *f_str; } field; }; #define exp_min field.count.f_min #define exp_max field.count.f_max /* #define exp_left field.children.f_left */ #define exp_right field.children.f_right #define exp_str field.f_str static xmlExpNodePtr xmlExpNewNode(xmlExpCtxtPtr ctxt, xmlExpNodeType type); static xmlExpNode forbiddenExpNode = { XML_EXP_FORBID, 0, 0, 0, 0, NULL, NULL, {{ 0, 0}} }; xmlExpNodePtr forbiddenExp = &forbiddenExpNode; static xmlExpNode emptyExpNode = { XML_EXP_EMPTY, 1, 0, 0, 0, NULL, NULL, {{ 0, 0}} }; xmlExpNodePtr emptyExp = &emptyExpNode; /************************************************************************ * * * The custom hash table for unicity and canonicalization * * of sub-expressions pointers * * * ************************************************************************/ /* * xmlExpHashNameComputeKey: * Calculate the hash key for a token */ static unsigned short xmlExpHashNameComputeKey(const xmlChar *name) { unsigned short value = 0L; char ch; if (name != NULL) { value += 30 * (*name); while ((ch = *name++) != 0) { value = value ^ ((value << 5) + (value >> 3) + (unsigned long)ch); } } return (value); } /* * xmlExpHashComputeKey: * Calculate the hash key for a compound expression */ static unsigned short xmlExpHashComputeKey(xmlExpNodeType type, xmlExpNodePtr left, xmlExpNodePtr right) { unsigned long value; unsigned short ret; switch (type) { case XML_EXP_SEQ: value = left->key; value += right->key; value *= 3; ret = (unsigned short) value; break; case XML_EXP_OR: value = left->key; value += right->key; value *= 7; ret = (unsigned short) value; break; case XML_EXP_COUNT: value = left->key; value += right->key; ret = (unsigned short) value; break; default: ret = 0; } return(ret); } static xmlExpNodePtr xmlExpNewNode(xmlExpCtxtPtr ctxt, xmlExpNodeType type) { xmlExpNodePtr ret; if (ctxt->nb_nodes >= MAX_NODES) return(NULL); ret = (xmlExpNodePtr) xmlMalloc(sizeof(xmlExpNode)); if (ret == NULL) return(NULL); memset(ret, 0, sizeof(xmlExpNode)); ret->type = type; ret->next = NULL; ctxt->nb_nodes++; ctxt->nb_cons++; return(ret); } /** * xmlExpHashGetEntry: * @table: the hash table * * Get the unique entry from the hash table. The entry is created if * needed. @left and @right are consumed, i.e. their ref count will * be decremented by the operation. * * Returns the pointer or NULL in case of error */ static xmlExpNodePtr xmlExpHashGetEntry(xmlExpCtxtPtr ctxt, xmlExpNodeType type, xmlExpNodePtr left, xmlExpNodePtr right, const xmlChar *name, int min, int max) { unsigned short kbase, key; xmlExpNodePtr entry; xmlExpNodePtr insert; if (ctxt == NULL) return(NULL); /* * Check for duplicate and insertion location. */ if (type == XML_EXP_ATOM) { kbase = xmlExpHashNameComputeKey(name); } else if (type == XML_EXP_COUNT) { /* COUNT reduction rule 1 */ /* a{1} -> a */ if (min == max) { if (min == 1) { return(left); } if (min == 0) { xmlExpFree(ctxt, left); return(emptyExp); } } if (min < 0) { xmlExpFree(ctxt, left); return(forbiddenExp); } if (max == -1) kbase = min + 79; else kbase = max - min; kbase += left->key; } else if (type == XML_EXP_OR) { /* Forbid reduction rules */ if (left->type == XML_EXP_FORBID) { xmlExpFree(ctxt, left); return(right); } if (right->type == XML_EXP_FORBID) { xmlExpFree(ctxt, right); return(left); } /* OR reduction rule 1 */ /* a | a reduced to a */ if (left == right) { left->ref--; return(left); } /* OR canonicalization rule 1 */ /* linearize (a | b) | c into a | (b | c) */ if ((left->type == XML_EXP_OR) && (right->type != XML_EXP_OR)) { xmlExpNodePtr tmp = left; left = right; right = tmp; } /* OR reduction rule 2 */ /* a | (a | b) and b | (a | b) are reduced to a | b */ if (right->type == XML_EXP_OR) { if ((left == right->exp_left) || (left == right->exp_right)) { xmlExpFree(ctxt, left); return(right); } } /* OR canonicalization rule 2 */ /* linearize (a | b) | c into a | (b | c) */ if (left->type == XML_EXP_OR) { xmlExpNodePtr tmp; /* OR canonicalization rule 2 */ if ((left->exp_right->type != XML_EXP_OR) && (left->exp_right->key < left->exp_left->key)) { tmp = left->exp_right; left->exp_right = left->exp_left; left->exp_left = tmp; } left->exp_right->ref++; tmp = xmlExpHashGetEntry(ctxt, XML_EXP_OR, left->exp_right, right, NULL, 0, 0); left->exp_left->ref++; tmp = xmlExpHashGetEntry(ctxt, XML_EXP_OR, left->exp_left, tmp, NULL, 0, 0); xmlExpFree(ctxt, left); return(tmp); } if (right->type == XML_EXP_OR) { /* Ordering in the tree */ /* C | (A | B) -> A | (B | C) */ if (left->key > right->exp_right->key) { xmlExpNodePtr tmp; right->exp_right->ref++; tmp = xmlExpHashGetEntry(ctxt, XML_EXP_OR, right->exp_right, left, NULL, 0, 0); right->exp_left->ref++; tmp = xmlExpHashGetEntry(ctxt, XML_EXP_OR, right->exp_left, tmp, NULL, 0, 0); xmlExpFree(ctxt, right); return(tmp); } /* Ordering in the tree */ /* B | (A | C) -> A | (B | C) */ if (left->key > right->exp_left->key) { xmlExpNodePtr tmp; right->exp_right->ref++; tmp = xmlExpHashGetEntry(ctxt, XML_EXP_OR, left, right->exp_right, NULL, 0, 0); right->exp_left->ref++; tmp = xmlExpHashGetEntry(ctxt, XML_EXP_OR, right->exp_left, tmp, NULL, 0, 0); xmlExpFree(ctxt, right); return(tmp); } } /* we know both types are != XML_EXP_OR here */ else if (left->key > right->key) { xmlExpNodePtr tmp = left; left = right; right = tmp; } kbase = xmlExpHashComputeKey(type, left, right); } else if (type == XML_EXP_SEQ) { /* Forbid reduction rules */ if (left->type == XML_EXP_FORBID) { xmlExpFree(ctxt, right); return(left); } if (right->type == XML_EXP_FORBID) { xmlExpFree(ctxt, left); return(right); } /* Empty reduction rules */ if (right->type == XML_EXP_EMPTY) { return(left); } if (left->type == XML_EXP_EMPTY) { return(right); } kbase = xmlExpHashComputeKey(type, left, right); } else return(NULL); key = kbase % ctxt->size; if (ctxt->table[key] != NULL) { for (insert = ctxt->table[key]; insert != NULL; insert = insert->next) { if ((insert->key == kbase) && (insert->type == type)) { if (type == XML_EXP_ATOM) { if (name == insert->exp_str) { insert->ref++; return(insert); } } else if (type == XML_EXP_COUNT) { if ((insert->exp_min == min) && (insert->exp_max == max) && (insert->exp_left == left)) { insert->ref++; left->ref--; return(insert); } } else if ((insert->exp_left == left) && (insert->exp_right == right)) { insert->ref++; left->ref--; right->ref--; return(insert); } } } } entry = xmlExpNewNode(ctxt, type); if (entry == NULL) return(NULL); entry->key = kbase; if (type == XML_EXP_ATOM) { entry->exp_str = name; entry->c_max = 1; } else if (type == XML_EXP_COUNT) { entry->exp_min = min; entry->exp_max = max; entry->exp_left = left; if ((min == 0) || (IS_NILLABLE(left))) entry->info |= XML_EXP_NILABLE; if (max < 0) entry->c_max = -1; else entry->c_max = max * entry->exp_left->c_max; } else { entry->exp_left = left; entry->exp_right = right; if (type == XML_EXP_OR) { if ((IS_NILLABLE(left)) || (IS_NILLABLE(right))) entry->info |= XML_EXP_NILABLE; if ((entry->exp_left->c_max == -1) || (entry->exp_right->c_max == -1)) entry->c_max = -1; else if (entry->exp_left->c_max > entry->exp_right->c_max) entry->c_max = entry->exp_left->c_max; else entry->c_max = entry->exp_right->c_max; } else { if ((IS_NILLABLE(left)) && (IS_NILLABLE(right))) entry->info |= XML_EXP_NILABLE; if ((entry->exp_left->c_max == -1) || (entry->exp_right->c_max == -1)) entry->c_max = -1; else entry->c_max = entry->exp_left->c_max + entry->exp_right->c_max; } } entry->ref = 1; if (ctxt->table[key] != NULL) entry->next = ctxt->table[key]; ctxt->table[key] = entry; ctxt->nbElems++; return(entry); } /** * xmlExpFree: * @ctxt: the expression context * @exp: the expression * * Dereference the expression */ void xmlExpFree(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp) { if ((exp == NULL) || (exp == forbiddenExp) || (exp == emptyExp)) return; exp->ref--; if (exp->ref == 0) { unsigned short key; /* Unlink it first from the hash table */ key = exp->key % ctxt->size; if (ctxt->table[key] == exp) { ctxt->table[key] = exp->next; } else { xmlExpNodePtr tmp; tmp = ctxt->table[key]; while (tmp != NULL) { if (tmp->next == exp) { tmp->next = exp->next; break; } tmp = tmp->next; } } if ((exp->type == XML_EXP_SEQ) || (exp->type == XML_EXP_OR)) { xmlExpFree(ctxt, exp->exp_left); xmlExpFree(ctxt, exp->exp_right); } else if (exp->type == XML_EXP_COUNT) { xmlExpFree(ctxt, exp->exp_left); } xmlFree(exp); ctxt->nb_nodes--; } } /** * xmlExpRef: * @exp: the expression * * Increase the reference count of the expression */ void xmlExpRef(xmlExpNodePtr exp) { if (exp != NULL) exp->ref++; } /** * xmlExpNewAtom: * @ctxt: the expression context * @name: the atom name * @len: the atom name lenght in byte (or -1); * * Get the atom associated to this name from that context * * Returns the node or NULL in case of error */ xmlExpNodePtr xmlExpNewAtom(xmlExpCtxtPtr ctxt, const xmlChar *name, int len) { if ((ctxt == NULL) || (name == NULL)) return(NULL); name = xmlDictLookup(ctxt->dict, name, len); if (name == NULL) return(NULL); return(xmlExpHashGetEntry(ctxt, XML_EXP_ATOM, NULL, NULL, name, 0, 0)); } /** * xmlExpNewOr: * @ctxt: the expression context * @left: left expression * @right: right expression * * Get the atom associated to the choice @left | @right * Note that @left and @right are consumed in the operation, to keep * an handle on them use xmlExpRef() and use xmlExpFree() to release them, * this is true even in case of failure (unless ctxt == NULL). * * Returns the node or NULL in case of error */ xmlExpNodePtr xmlExpNewOr(xmlExpCtxtPtr ctxt, xmlExpNodePtr left, xmlExpNodePtr right) { if (ctxt == NULL) return(NULL); if ((left == NULL) || (right == NULL)) { xmlExpFree(ctxt, left); xmlExpFree(ctxt, right); return(NULL); } return(xmlExpHashGetEntry(ctxt, XML_EXP_OR, left, right, NULL, 0, 0)); } /** * xmlExpNewSeq: * @ctxt: the expression context * @left: left expression * @right: right expression * * Get the atom associated to the sequence @left , @right * Note that @left and @right are consumed in the operation, to keep * an handle on them use xmlExpRef() and use xmlExpFree() to release them, * this is true even in case of failure (unless ctxt == NULL). * * Returns the node or NULL in case of error */ xmlExpNodePtr xmlExpNewSeq(xmlExpCtxtPtr ctxt, xmlExpNodePtr left, xmlExpNodePtr right) { if (ctxt == NULL) return(NULL); if ((left == NULL) || (right == NULL)) { xmlExpFree(ctxt, left); xmlExpFree(ctxt, right); return(NULL); } return(xmlExpHashGetEntry(ctxt, XML_EXP_SEQ, left, right, NULL, 0, 0)); } /** * xmlExpNewRange: * @ctxt: the expression context * @subset: the expression to be repeated * @min: the lower bound for the repetition * @max: the upper bound for the repetition, -1 means infinite * * Get the atom associated to the range (@subset){@min, @max} * Note that @subset is consumed in the operation, to keep * an handle on it use xmlExpRef() and use xmlExpFree() to release it, * this is true even in case of failure (unless ctxt == NULL). * * Returns the node or NULL in case of error */ xmlExpNodePtr xmlExpNewRange(xmlExpCtxtPtr ctxt, xmlExpNodePtr subset, int min, int max) { if (ctxt == NULL) return(NULL); if ((subset == NULL) || (min < 0) || (max < -1) || ((max >= 0) && (min > max))) { xmlExpFree(ctxt, subset); return(NULL); } return(xmlExpHashGetEntry(ctxt, XML_EXP_COUNT, subset, NULL, NULL, min, max)); } /************************************************************************ * * * Public API for operations on expressions * * * ************************************************************************/ static int xmlExpGetLanguageInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, const xmlChar**list, int len, int nb) { int tmp, tmp2; tail: switch (exp->type) { case XML_EXP_EMPTY: return(0); case XML_EXP_ATOM: for (tmp = 0;tmp < nb;tmp++) if (list[tmp] == exp->exp_str) return(0); if (nb >= len) return(-2); list[nb++] = exp->exp_str; return(1); case XML_EXP_COUNT: exp = exp->exp_left; goto tail; case XML_EXP_SEQ: case XML_EXP_OR: tmp = xmlExpGetLanguageInt(ctxt, exp->exp_left, list, len, nb); if (tmp < 0) return(tmp); tmp2 = xmlExpGetLanguageInt(ctxt, exp->exp_right, list, len, nb + tmp); if (tmp2 < 0) return(tmp2); return(tmp + tmp2); } return(-1); } /** * xmlExpGetLanguage: * @ctxt: the expression context * @exp: the expression * @langList: where to store the tokens * @len: the allocated lenght of @list * * Find all the strings used in @exp and store them in @list * * Returns the number of unique strings found, -1 in case of errors and * -2 if there is more than @len strings */ int xmlExpGetLanguage(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, const xmlChar**langList, int len) { if ((ctxt == NULL) || (exp == NULL) || (langList == NULL) || (len <= 0)) return(-1); return(xmlExpGetLanguageInt(ctxt, exp, langList, len, 0)); } static int xmlExpGetStartInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, const xmlChar**list, int len, int nb) { int tmp, tmp2; tail: switch (exp->type) { case XML_EXP_FORBID: return(0); case XML_EXP_EMPTY: return(0); case XML_EXP_ATOM: for (tmp = 0;tmp < nb;tmp++) if (list[tmp] == exp->exp_str) return(0); if (nb >= len) return(-2); list[nb++] = exp->exp_str; return(1); case XML_EXP_COUNT: exp = exp->exp_left; goto tail; case XML_EXP_SEQ: tmp = xmlExpGetStartInt(ctxt, exp->exp_left, list, len, nb); if (tmp < 0) return(tmp); if (IS_NILLABLE(exp->exp_left)) { tmp2 = xmlExpGetStartInt(ctxt, exp->exp_right, list, len, nb + tmp); if (tmp2 < 0) return(tmp2); tmp += tmp2; } return(tmp); case XML_EXP_OR: tmp = xmlExpGetStartInt(ctxt, exp->exp_left, list, len, nb); if (tmp < 0) return(tmp); tmp2 = xmlExpGetStartInt(ctxt, exp->exp_right, list, len, nb + tmp); if (tmp2 < 0) return(tmp2); return(tmp + tmp2); } return(-1); } /** * xmlExpGetStart: * @ctxt: the expression context * @exp: the expression * @tokList: where to store the tokens * @len: the allocated lenght of @list * * Find all the strings that appears at the start of the languages * accepted by @exp and store them in @list. E.g. for (a, b) | c * it will return the list [a, c] * * Returns the number of unique strings found, -1 in case of errors and * -2 if there is more than @len strings */ int xmlExpGetStart(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, const xmlChar**tokList, int len) { if ((ctxt == NULL) || (exp == NULL) || (tokList == NULL) || (len <= 0)) return(-1); return(xmlExpGetStartInt(ctxt, exp, tokList, len, 0)); } /** * xmlExpIsNillable: * @exp: the expression * * Finds if the expression is nillable, i.e. if it accepts the empty sequqnce * * Returns 1 if nillable, 0 if not and -1 in case of error */ int xmlExpIsNillable(xmlExpNodePtr exp) { if (exp == NULL) return(-1); return(IS_NILLABLE(exp) != 0); } static xmlExpNodePtr xmlExpStringDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, const xmlChar *str) { xmlExpNodePtr ret; switch (exp->type) { case XML_EXP_EMPTY: return(forbiddenExp); case XML_EXP_FORBID: return(forbiddenExp); case XML_EXP_ATOM: if (exp->exp_str == str) { #ifdef DEBUG_DERIV printf("deriv atom: equal => Empty\n"); #endif ret = emptyExp; } else { #ifdef DEBUG_DERIV printf("deriv atom: mismatch => forbid\n"); #endif /* TODO wildcards here */ ret = forbiddenExp; } return(ret); case XML_EXP_OR: { xmlExpNodePtr tmp; #ifdef DEBUG_DERIV printf("deriv or: => or(derivs)\n"); #endif tmp = xmlExpStringDeriveInt(ctxt, exp->exp_left, str); if (tmp == NULL) { return(NULL); } ret = xmlExpStringDeriveInt(ctxt, exp->exp_right, str); if (ret == NULL) { xmlExpFree(ctxt, tmp); return(NULL); } ret = xmlExpHashGetEntry(ctxt, XML_EXP_OR, tmp, ret, NULL, 0, 0); return(ret); } case XML_EXP_SEQ: #ifdef DEBUG_DERIV printf("deriv seq: starting with left\n"); #endif ret = xmlExpStringDeriveInt(ctxt, exp->exp_left, str); if (ret == NULL) { return(NULL); } else if (ret == forbiddenExp) { if (IS_NILLABLE(exp->exp_left)) { #ifdef DEBUG_DERIV printf("deriv seq: left failed but nillable\n"); #endif ret = xmlExpStringDeriveInt(ctxt, exp->exp_right, str); } } else { #ifdef DEBUG_DERIV printf("deriv seq: left match => sequence\n"); #endif exp->exp_right->ref++; ret = xmlExpHashGetEntry(ctxt, XML_EXP_SEQ, ret, exp->exp_right, NULL, 0, 0); } return(ret); case XML_EXP_COUNT: { int min, max; xmlExpNodePtr tmp; if (exp->exp_max == 0) return(forbiddenExp); ret = xmlExpStringDeriveInt(ctxt, exp->exp_left, str); if (ret == NULL) return(NULL); if (ret == forbiddenExp) { #ifdef DEBUG_DERIV printf("deriv count: pattern mismatch => forbid\n"); #endif return(ret); } if (exp->exp_max == 1) return(ret); if (exp->exp_max < 0) /* unbounded */ max = -1; else max = exp->exp_max - 1; if (exp->exp_min > 0) min = exp->exp_min - 1; else min = 0; exp->exp_left->ref++; tmp = xmlExpHashGetEntry(ctxt, XML_EXP_COUNT, exp->exp_left, NULL, NULL, min, max); if (ret == emptyExp) { #ifdef DEBUG_DERIV printf("deriv count: match to empty => new count\n"); #endif return(tmp); } #ifdef DEBUG_DERIV printf("deriv count: match => sequence with new count\n"); #endif return(xmlExpHashGetEntry(ctxt, XML_EXP_SEQ, ret, tmp, NULL, 0, 0)); } } return(NULL); } /** * xmlExpStringDerive: * @ctxt: the expression context * @exp: the expression * @str: the string * @len: the string len in bytes if available * * Do one step of Brzozowski derivation of the expression @exp with * respect to the input string * * Returns the resulting expression or NULL in case of internal error */ xmlExpNodePtr xmlExpStringDerive(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, const xmlChar *str, int len) { const xmlChar *input; if ((exp == NULL) || (ctxt == NULL) || (str == NULL)) { return(NULL); } /* * check the string is in the dictionnary, if yes use an interned * copy, otherwise we know it's not an acceptable input */ input = xmlDictExists(ctxt->dict, str, len); if (input == NULL) { return(forbiddenExp); } return(xmlExpStringDeriveInt(ctxt, exp, input)); } static int xmlExpCheckCard(xmlExpNodePtr exp, xmlExpNodePtr sub) { int ret = 1; if (sub->c_max == -1) { if (exp->c_max != -1) ret = 0; } else if ((exp->c_max >= 0) && (exp->c_max < sub->c_max)) { ret = 0; } #if 0 if ((IS_NILLABLE(sub)) && (!IS_NILLABLE(exp))) ret = 0; #endif return(ret); } static xmlExpNodePtr xmlExpExpDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub); /** * xmlExpDivide: * @ctxt: the expressions context * @exp: the englobing expression * @sub: the subexpression * @mult: the multiple expression * @remain: the remain from the derivation of the multiple * * Check if exp is a multiple of sub, i.e. if there is a finite number n * so that sub{n} subsume exp * * Returns the multiple value if successful, 0 if it is not a multiple * and -1 in case of internel error. */ static int xmlExpDivide(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub, xmlExpNodePtr *mult, xmlExpNodePtr *remain) { int i; xmlExpNodePtr tmp, tmp2; if (mult != NULL) *mult = NULL; if (remain != NULL) *remain = NULL; if (exp->c_max == -1) return(0); if (IS_NILLABLE(exp) && (!IS_NILLABLE(sub))) return(0); for (i = 1;i <= exp->c_max;i++) { sub->ref++; tmp = xmlExpHashGetEntry(ctxt, XML_EXP_COUNT, sub, NULL, NULL, i, i); if (tmp == NULL) { return(-1); } if (!xmlExpCheckCard(tmp, exp)) { xmlExpFree(ctxt, tmp); continue; } tmp2 = xmlExpExpDeriveInt(ctxt, tmp, exp); if (tmp2 == NULL) { xmlExpFree(ctxt, tmp); return(-1); } if ((tmp2 != forbiddenExp) && (IS_NILLABLE(tmp2))) { if (remain != NULL) *remain = tmp2; else xmlExpFree(ctxt, tmp2); if (mult != NULL) *mult = tmp; else xmlExpFree(ctxt, tmp); #ifdef DEBUG_DERIV printf("Divide succeeded %d\n", i); #endif return(i); } xmlExpFree(ctxt, tmp); xmlExpFree(ctxt, tmp2); } #ifdef DEBUG_DERIV printf("Divide failed\n"); #endif return(0); } /** * xmlExpExpDeriveInt: * @ctxt: the expressions context * @exp: the englobing expression * @sub: the subexpression * * Try to do a step of Brzozowski derivation but at a higher level * the input being a subexpression. * * Returns the resulting expression or NULL in case of internal error */ static xmlExpNodePtr xmlExpExpDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) { xmlExpNodePtr ret, tmp, tmp2, tmp3; const xmlChar **tab; int len, i; /* * In case of equality and if the expression can only consume a finite * amount, then the derivation is empty */ if ((exp == sub) && (exp->c_max >= 0)) { #ifdef DEBUG_DERIV printf("Equal(exp, sub) and finite -> Empty\n"); #endif return(emptyExp); } /* * decompose sub sequence first */ if (sub->type == XML_EXP_EMPTY) { #ifdef DEBUG_DERIV printf("Empty(sub) -> Empty\n"); #endif exp->ref++; return(exp); } if (sub->type == XML_EXP_SEQ) { #ifdef DEBUG_DERIV printf("Seq(sub) -> decompose\n"); #endif tmp = xmlExpExpDeriveInt(ctxt, exp, sub->exp_left); if (tmp == NULL) return(NULL); if (tmp == forbiddenExp) return(tmp); ret = xmlExpExpDeriveInt(ctxt, tmp, sub->exp_right); xmlExpFree(ctxt, tmp); return(ret); } if (sub->type == XML_EXP_OR) { #ifdef DEBUG_DERIV printf("Or(sub) -> decompose\n"); #endif tmp = xmlExpExpDeriveInt(ctxt, exp, sub->exp_left); if (tmp == forbiddenExp) return(tmp); if (tmp == NULL) return(NULL); ret = xmlExpExpDeriveInt(ctxt, exp, sub->exp_right); if ((ret == NULL) || (ret == forbiddenExp)) { xmlExpFree(ctxt, tmp); return(ret); } return(xmlExpHashGetEntry(ctxt, XML_EXP_OR, tmp, ret, NULL, 0, 0)); } if (!xmlExpCheckCard(exp, sub)) { #ifdef DEBUG_DERIV printf("CheckCard(exp, sub) failed -> Forbid\n"); #endif return(forbiddenExp); } switch (exp->type) { case XML_EXP_EMPTY: if (sub == emptyExp) return(emptyExp); #ifdef DEBUG_DERIV printf("Empty(exp) -> Forbid\n"); #endif return(forbiddenExp); case XML_EXP_FORBID: #ifdef DEBUG_DERIV printf("Forbid(exp) -> Forbid\n"); #endif return(forbiddenExp); case XML_EXP_ATOM: if (sub->type == XML_EXP_ATOM) { /* TODO: handle wildcards */ if (exp->exp_str == sub->exp_str) { #ifdef DEBUG_DERIV printf("Atom match -> Empty\n"); #endif return(emptyExp); } #ifdef DEBUG_DERIV printf("Atom mismatch -> Forbid\n"); #endif return(forbiddenExp); } if ((sub->type == XML_EXP_COUNT) && (sub->exp_max == 1) && (sub->exp_left->type == XML_EXP_ATOM)) { /* TODO: handle wildcards */ if (exp->exp_str == sub->exp_left->exp_str) { #ifdef DEBUG_DERIV printf("Atom match -> Empty\n"); #endif return(emptyExp); } #ifdef DEBUG_DERIV printf("Atom mismatch -> Forbid\n"); #endif return(forbiddenExp); } #ifdef DEBUG_DERIV printf("Compex exp vs Atom -> Forbid\n"); #endif return(forbiddenExp); case XML_EXP_SEQ: /* try to get the sequence consumed only if possible */ if (xmlExpCheckCard(exp->exp_left, sub)) { /* See if the sequence can be consumed directly */ #ifdef DEBUG_DERIV printf("Seq trying left only\n"); #endif ret = xmlExpExpDeriveInt(ctxt, exp->exp_left, sub); if ((ret != forbiddenExp) && (ret != NULL)) { #ifdef DEBUG_DERIV printf("Seq trying left only worked\n"); #endif /* * TODO: assumption here that we are determinist * i.e. we won't get to a nillable exp left * subset which could be matched by the right * part too. * e.g.: (a | b)+,(a | c) and 'a+,a' */ exp->exp_right->ref++; return(xmlExpHashGetEntry(ctxt, XML_EXP_SEQ, ret, exp->exp_right, NULL, 0, 0)); } #ifdef DEBUG_DERIV } else { printf("Seq: left too short\n"); #endif } /* Try instead to decompose */ if (sub->type == XML_EXP_COUNT) { int min, max; #ifdef DEBUG_DERIV printf("Seq: sub is a count\n"); #endif ret = xmlExpExpDeriveInt(ctxt, exp->exp_left, sub->exp_left); if (ret == NULL) return(NULL); if (ret != forbiddenExp) { #ifdef DEBUG_DERIV printf("Seq , Count match on left\n"); #endif if (sub->exp_max < 0) max = -1; else max = sub->exp_max -1; if (sub->exp_min > 0) min = sub->exp_min -1; else min = 0; exp->exp_right->ref++; tmp = xmlExpHashGetEntry(ctxt, XML_EXP_SEQ, ret, exp->exp_right, NULL, 0, 0); if (tmp == NULL) return(NULL); sub->exp_left->ref++; tmp2 = xmlExpHashGetEntry(ctxt, XML_EXP_COUNT, sub->exp_left, NULL, NULL, min, max); if (tmp2 == NULL) { xmlExpFree(ctxt, tmp); return(NULL); } ret = xmlExpExpDeriveInt(ctxt, tmp, tmp2); xmlExpFree(ctxt, tmp); xmlExpFree(ctxt, tmp2); return(ret); } } /* we made no progress on structured operations */ break; case XML_EXP_OR: #ifdef DEBUG_DERIV printf("Or , trying both side\n"); #endif ret = xmlExpExpDeriveInt(ctxt, exp->exp_left, sub); if (ret == NULL) return(NULL); tmp = xmlExpExpDeriveInt(ctxt, exp->exp_right, sub); if (tmp == NULL) { xmlExpFree(ctxt, ret); return(NULL); } return(xmlExpHashGetEntry(ctxt, XML_EXP_OR, ret, tmp, NULL, 0, 0)); case XML_EXP_COUNT: { int min, max; if (sub->type == XML_EXP_COUNT) { /* * Try to see if the loop is completely subsumed */ tmp = xmlExpExpDeriveInt(ctxt, exp->exp_left, sub->exp_left); if (tmp == NULL) return(NULL); if (tmp == forbiddenExp) { int mult; #ifdef DEBUG_DERIV printf("Count, Count inner don't subsume\n"); #endif mult = xmlExpDivide(ctxt, sub->exp_left, exp->exp_left, NULL, &tmp); if (mult <= 0) { #ifdef DEBUG_DERIV printf("Count, Count not multiple => forbidden\n"); #endif return(forbiddenExp); } if (sub->exp_max == -1) { max = -1; if (exp->exp_max == -1) { if (exp->exp_min <= sub->exp_min * mult) min = 0; else min = exp->exp_min - sub->exp_min * mult; } else { #ifdef DEBUG_DERIV printf("Count, Count finite can't subsume infinite\n"); #endif xmlExpFree(ctxt, tmp); return(forbiddenExp); } } else { if (exp->exp_max == -1) { #ifdef DEBUG_DERIV printf("Infinite loop consume mult finite loop\n"); #endif if (exp->exp_min > sub->exp_min * mult) { max = -1; min = exp->exp_min - sub->exp_min * mult; } else { max = -1; min = 0; } } else { if (exp->exp_max < sub->exp_max * mult) { #ifdef DEBUG_DERIV printf("loops max mult mismatch => forbidden\n"); #endif xmlExpFree(ctxt, tmp); return(forbiddenExp); } if (sub->exp_max * mult > exp->exp_min) min = 0; else min = exp->exp_min - sub->exp_max * mult; max = exp->exp_max - sub->exp_max * mult; } } } else if (!IS_NILLABLE(tmp)) { /* * TODO: loop here to try to grow if working on finite * blocks. */ #ifdef DEBUG_DERIV printf("Count, Count remain not nillable => forbidden\n"); #endif xmlExpFree(ctxt, tmp); return(forbiddenExp); } else if (sub->exp_max == -1) { if (exp->exp_max == -1) { if (exp->exp_min <= sub->exp_min) { #ifdef DEBUG_DERIV printf("Infinite loops Okay => COUNT(0,Inf)\n"); #endif max = -1; min = 0; } else { #ifdef DEBUG_DERIV printf("Infinite loops min => Count(X,Inf)\n"); #endif max = -1; min = exp->exp_min - sub->exp_min; } } else if (exp->exp_min > sub->exp_min) { #ifdef DEBUG_DERIV printf("loops min mismatch 1 => forbidden ???\n"); #endif xmlExpFree(ctxt, tmp); return(forbiddenExp); } else { max = -1; min = 0; } } else { if (exp->exp_max == -1) { #ifdef DEBUG_DERIV printf("Infinite loop consume finite loop\n"); #endif if (exp->exp_min > sub->exp_min) { max = -1; min = exp->exp_min - sub->exp_min; } else { max = -1; min = 0; } } else { if (exp->exp_max < sub->exp_max) { #ifdef DEBUG_DERIV printf("loops max mismatch => forbidden\n"); #endif xmlExpFree(ctxt, tmp); return(forbiddenExp); } if (sub->exp_max > exp->exp_min) min = 0; else min = exp->exp_min - sub->exp_max; max = exp->exp_max - sub->exp_max; } } #ifdef DEBUG_DERIV printf("loops match => SEQ(COUNT())\n"); #endif exp->exp_left->ref++; tmp2 = xmlExpHashGetEntry(ctxt, XML_EXP_COUNT, exp->exp_left, NULL, NULL, min, max); if (tmp2 == NULL) { return(NULL); } ret = xmlExpHashGetEntry(ctxt, XML_EXP_SEQ, tmp, tmp2, NULL, 0, 0); return(ret); } tmp = xmlExpExpDeriveInt(ctxt, exp->exp_left, sub); if (tmp == NULL) return(NULL); if (tmp == forbiddenExp) { #ifdef DEBUG_DERIV printf("loop mismatch => forbidden\n"); #endif return(forbiddenExp); } if (exp->exp_min > 0) min = exp->exp_min - 1; else min = 0; if (exp->exp_max < 0) max = -1; else max = exp->exp_max - 1; #ifdef DEBUG_DERIV printf("loop match => SEQ(COUNT())\n"); #endif exp->exp_left->ref++; tmp2 = xmlExpHashGetEntry(ctxt, XML_EXP_COUNT, exp->exp_left, NULL, NULL, min, max); if (tmp2 == NULL) return(NULL); ret = xmlExpHashGetEntry(ctxt, XML_EXP_SEQ, tmp, tmp2, NULL, 0, 0); return(ret); } } #ifdef DEBUG_DERIV printf("Fallback to derivative\n"); #endif if (IS_NILLABLE(sub)) { if (!(IS_NILLABLE(exp))) return(forbiddenExp); else ret = emptyExp; } else ret = NULL; /* * here the structured derivation made no progress so * we use the default token based derivation to force one more step */ if (ctxt->tabSize == 0) ctxt->tabSize = 40; tab = (const xmlChar **) xmlMalloc(ctxt->tabSize * sizeof(const xmlChar *)); if (tab == NULL) { return(NULL); } /* * collect all the strings accepted by the subexpression on input */ len = xmlExpGetStartInt(ctxt, sub, tab, ctxt->tabSize, 0); while (len < 0) { const xmlChar **temp; temp = (const xmlChar **) xmlRealloc((xmlChar **) tab, ctxt->tabSize * 2 * sizeof(const xmlChar *)); if (temp == NULL) { xmlFree((xmlChar **) tab); return(NULL); } tab = temp; ctxt->tabSize *= 2; len = xmlExpGetStartInt(ctxt, sub, tab, ctxt->tabSize, 0); } for (i = 0;i < len;i++) { tmp = xmlExpStringDeriveInt(ctxt, exp, tab[i]); if ((tmp == NULL) || (tmp == forbiddenExp)) { xmlExpFree(ctxt, ret); xmlFree((xmlChar **) tab); return(tmp); } tmp2 = xmlExpStringDeriveInt(ctxt, sub, tab[i]); if ((tmp2 == NULL) || (tmp2 == forbiddenExp)) { xmlExpFree(ctxt, tmp); xmlExpFree(ctxt, ret); xmlFree((xmlChar **) tab); return(tmp); } tmp3 = xmlExpExpDeriveInt(ctxt, tmp, tmp2); xmlExpFree(ctxt, tmp); xmlExpFree(ctxt, tmp2); if ((tmp3 == NULL) || (tmp3 == forbiddenExp)) { xmlExpFree(ctxt, ret); xmlFree((xmlChar **) tab); return(tmp3); } if (ret == NULL) ret = tmp3; else { ret = xmlExpHashGetEntry(ctxt, XML_EXP_OR, ret, tmp3, NULL, 0, 0); if (ret == NULL) { xmlFree((xmlChar **) tab); return(NULL); } } } xmlFree((xmlChar **) tab); return(ret); } /** * xmlExpExpDerive: * @ctxt: the expressions context * @exp: the englobing expression * @sub: the subexpression * * Evaluates the expression resulting from @exp consuming a sub expression @sub * Based on algebraic derivation and sometimes direct Brzozowski derivation * it usually tatkes less than linear time and can handle expressions generating * infinite languages. * * Returns the resulting expression or NULL in case of internal error, the * result must be freed */ xmlExpNodePtr xmlExpExpDerive(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) { if ((exp == NULL) || (ctxt == NULL) || (sub == NULL)) return(NULL); /* * O(1) speedups */ if (IS_NILLABLE(sub) && (!IS_NILLABLE(exp))) { #ifdef DEBUG_DERIV printf("Sub nillable and not exp : can't subsume\n"); #endif return(forbiddenExp); } if (xmlExpCheckCard(exp, sub) == 0) { #ifdef DEBUG_DERIV printf("sub generate longuer sequances than exp : can't subsume\n"); #endif return(forbiddenExp); } return(xmlExpExpDeriveInt(ctxt, exp, sub)); } /** * xmlExpSubsume: * @ctxt: the expressions context * @exp: the englobing expression * @sub: the subexpression * * Check whether @exp accepts all the languages accexpted by @sub * the input being a subexpression. * * Returns 1 if true 0 if false and -1 in case of failure. */ int xmlExpSubsume(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) { xmlExpNodePtr tmp; if ((exp == NULL) || (ctxt == NULL) || (sub == NULL)) return(-1); /* * TODO: speedup by checking the language of sub is a subset of the * language of exp */ /* * O(1) speedups */ if (IS_NILLABLE(sub) && (!IS_NILLABLE(exp))) { #ifdef DEBUG_DERIV printf("Sub nillable and not exp : can't subsume\n"); #endif return(0); } if (xmlExpCheckCard(exp, sub) == 0) { #ifdef DEBUG_DERIV printf("sub generate longuer sequances than exp : can't subsume\n"); #endif return(0); } tmp = xmlExpExpDeriveInt(ctxt, exp, sub); #ifdef DEBUG_DERIV printf("Result derivation :\n"); PRINT_EXP(tmp); #endif if (tmp == NULL) return(-1); if (tmp == forbiddenExp) return(0); if (tmp == emptyExp) return(1); if ((tmp != NULL) && (IS_NILLABLE(tmp))) { xmlExpFree(ctxt, tmp); return(1); } xmlExpFree(ctxt, tmp); return(0); } /************************************************************************ * * * Parsing expression * * * ************************************************************************/ static xmlExpNodePtr xmlExpParseExpr(xmlExpCtxtPtr ctxt); #undef CUR #define CUR (*ctxt->cur) #undef NEXT #define NEXT ctxt->cur++; #undef IS_BLANK #define IS_BLANK(c) ((c == ' ') || (c == '\n') || (c == '\r') || (c == '\t')) #define SKIP_BLANKS while (IS_BLANK(*ctxt->cur)) ctxt->cur++; static int xmlExpParseNumber(xmlExpCtxtPtr ctxt) { int ret = 0; SKIP_BLANKS if (CUR == '*') { NEXT return(-1); } if ((CUR < '0') || (CUR > '9')) return(-1); while ((CUR >= '0') && (CUR <= '9')) { ret = ret * 10 + (CUR - '0'); NEXT } return(ret); } static xmlExpNodePtr xmlExpParseOr(xmlExpCtxtPtr ctxt) { const char *base; xmlExpNodePtr ret; const xmlChar *val; SKIP_BLANKS base = ctxt->cur; if (*ctxt->cur == '(') { NEXT ret = xmlExpParseExpr(ctxt); SKIP_BLANKS if (*ctxt->cur != ')') { fprintf(stderr, "unbalanced '(' : %s\n", base); xmlExpFree(ctxt, ret); return(NULL); } NEXT; SKIP_BLANKS goto parse_quantifier; } while ((CUR != 0) && (!(IS_BLANK(CUR))) && (CUR != '(') && (CUR != ')') && (CUR != '|') && (CUR != ',') && (CUR != '{') && (CUR != '*') && (CUR != '+') && (CUR != '?') && (CUR != '}')) NEXT; val = xmlDictLookup(ctxt->dict, BAD_CAST base, ctxt->cur - base); if (val == NULL) return(NULL); ret = xmlExpHashGetEntry(ctxt, XML_EXP_ATOM, NULL, NULL, val, 0, 0); if (ret == NULL) return(NULL); SKIP_BLANKS parse_quantifier: if (CUR == '{') { int min, max; NEXT min = xmlExpParseNumber(ctxt); if (min < 0) { xmlExpFree(ctxt, ret); return(NULL); } SKIP_BLANKS if (CUR == ',') { NEXT max = xmlExpParseNumber(ctxt); SKIP_BLANKS } else max = min; if (CUR != '}') { xmlExpFree(ctxt, ret); return(NULL); } NEXT ret = xmlExpHashGetEntry(ctxt, XML_EXP_COUNT, ret, NULL, NULL, min, max); SKIP_BLANKS } else if (CUR == '?') { NEXT ret = xmlExpHashGetEntry(ctxt, XML_EXP_COUNT, ret, NULL, NULL, 0, 1); SKIP_BLANKS } else if (CUR == '+') { NEXT ret = xmlExpHashGetEntry(ctxt, XML_EXP_COUNT, ret, NULL, NULL, 1, -1); SKIP_BLANKS } else if (CUR == '*') { NEXT ret = xmlExpHashGetEntry(ctxt, XML_EXP_COUNT, ret, NULL, NULL, 0, -1); SKIP_BLANKS } return(ret); } static xmlExpNodePtr xmlExpParseSeq(xmlExpCtxtPtr ctxt) { xmlExpNodePtr ret, right; ret = xmlExpParseOr(ctxt); SKIP_BLANKS while (CUR == '|') { NEXT right = xmlExpParseOr(ctxt); if (right == NULL) { xmlExpFree(ctxt, ret); return(NULL); } ret = xmlExpHashGetEntry(ctxt, XML_EXP_OR, ret, right, NULL, 0, 0); if (ret == NULL) return(NULL); } return(ret); } static xmlExpNodePtr xmlExpParseExpr(xmlExpCtxtPtr ctxt) { xmlExpNodePtr ret, right; ret = xmlExpParseSeq(ctxt); SKIP_BLANKS while (CUR == ',') { NEXT right = xmlExpParseSeq(ctxt); if (right == NULL) { xmlExpFree(ctxt, ret); return(NULL); } ret = xmlExpHashGetEntry(ctxt, XML_EXP_SEQ, ret, right, NULL, 0, 0); if (ret == NULL) return(NULL); } return(ret); } /** * xmlExpParse: * @ctxt: the expressions context * @expr: the 0 terminated string * * Minimal parser for regexps, it understand the following constructs * - string terminals * - choice operator | * - sequence operator , * - subexpressions (...) * - usual cardinality operators + * and ? * - finite sequences { min, max } * - infinite sequences { min, * } * There is minimal checkings made especially no checking on strings values * * Returns a new expression or NULL in case of failure */ xmlExpNodePtr xmlExpParse(xmlExpCtxtPtr ctxt, const char *expr) { xmlExpNodePtr ret; ctxt->expr = expr; ctxt->cur = expr; ret = xmlExpParseExpr(ctxt); SKIP_BLANKS if (*ctxt->cur != 0) { xmlExpFree(ctxt, ret); return(NULL); } return(ret); } static void xmlExpDumpInt(xmlBufferPtr buf, xmlExpNodePtr expr, int glob) { xmlExpNodePtr c; if (expr == NULL) return; if (glob) xmlBufferWriteChar(buf, "("); switch (expr->type) { case XML_EXP_EMPTY: xmlBufferWriteChar(buf, "empty"); break; case XML_EXP_FORBID: xmlBufferWriteChar(buf, "forbidden"); break; case XML_EXP_ATOM: xmlBufferWriteCHAR(buf, expr->exp_str); break; case XML_EXP_SEQ: c = expr->exp_left; if ((c->type == XML_EXP_SEQ) || (c->type == XML_EXP_OR)) xmlExpDumpInt(buf, c, 1); else xmlExpDumpInt(buf, c, 0); xmlBufferWriteChar(buf, " , "); c = expr->exp_right; if ((c->type == XML_EXP_SEQ) || (c->type == XML_EXP_OR)) xmlExpDumpInt(buf, c, 1); else xmlExpDumpInt(buf, c, 0); break; case XML_EXP_OR: c = expr->exp_left; if ((c->type == XML_EXP_SEQ) || (c->type == XML_EXP_OR)) xmlExpDumpInt(buf, c, 1); else xmlExpDumpInt(buf, c, 0); xmlBufferWriteChar(buf, " | "); c = expr->exp_right; if ((c->type == XML_EXP_SEQ) || (c->type == XML_EXP_OR)) xmlExpDumpInt(buf, c, 1); else xmlExpDumpInt(buf, c, 0); break; case XML_EXP_COUNT: { char rep[40]; c = expr->exp_left; if ((c->type == XML_EXP_SEQ) || (c->type == XML_EXP_OR)) xmlExpDumpInt(buf, c, 1); else xmlExpDumpInt(buf, c, 0); if ((expr->exp_min == 0) && (expr->exp_max == 1)) { rep[0] = '?'; rep[1] = 0; } else if ((expr->exp_min == 0) && (expr->exp_max == -1)) { rep[0] = '*'; rep[1] = 0; } else if ((expr->exp_min == 1) && (expr->exp_max == -1)) { rep[0] = '+'; rep[1] = 0; } else if (expr->exp_max == expr->exp_min) { snprintf(rep, 39, "{%d}", expr->exp_min); } else if (expr->exp_max < 0) { snprintf(rep, 39, "{%d,inf}", expr->exp_min); } else { snprintf(rep, 39, "{%d,%d}", expr->exp_min, expr->exp_max); } rep[39] = 0; xmlBufferWriteChar(buf, rep); break; } default: fprintf(stderr, "Error in tree\n"); } if (glob) xmlBufferWriteChar(buf, ")"); } /** * xmlExpDump: * @buf: a buffer to receive the output * @expr: the compiled expression * * Serialize the expression as compiled to the buffer */ void xmlExpDump(xmlBufferPtr buf, xmlExpNodePtr expr) { if ((buf == NULL) || (expr == NULL)) return; xmlExpDumpInt(buf, expr, 0); } /** * xmlExpMaxToken: * @expr: a compiled expression * * Indicate the maximum number of input a expression can accept * * Returns the maximum length or -1 in case of error */ int xmlExpMaxToken(xmlExpNodePtr expr) { if (expr == NULL) return(-1); return(expr->c_max); } /** * xmlExpCtxtNbNodes: * @ctxt: an expression context * * Debugging facility provides the number of allocated nodes at a that point * * Returns the number of nodes in use or -1 in case of error */ int xmlExpCtxtNbNodes(xmlExpCtxtPtr ctxt) { if (ctxt == NULL) return(-1); return(ctxt->nb_nodes); } /** * xmlExpCtxtNbCons: * @ctxt: an expression context * * Debugging facility provides the number of allocated nodes over lifetime * * Returns the number of nodes ever allocated or -1 in case of error */ int xmlExpCtxtNbCons(xmlExpCtxtPtr ctxt) { if (ctxt == NULL) return(-1); return(ctxt->nb_cons); } #endif /* LIBXML_EXPR_ENABLED */ #define bottom_xmlregexp #include "elfgcchack.h" #endif /* LIBXML_REGEXP_ENABLED */ xdmf-3.0+git20160803/Utilities/vtklibxml2/xmlschemastypes.c0000640000175000017500000062335413003006557023555 0ustar alastairalastair/* * schemastypes.c : implementation of the XML Schema Datatypes * definition and validity checking * * See Copyright for the status of this software. * * Daniel Veillard */ #define IN_LIBXML #include "libxml.h" #ifdef LIBXML_SCHEMAS_ENABLED #include #include #include #include #include #include #include #include #include #include #include #ifdef HAVE_MATH_H #include #endif #ifdef HAVE_FLOAT_H #include #endif #define DEBUG #ifndef LIBXML_XPATH_ENABLED extern double xmlXPathNAN; extern double xmlXPathPINF; extern double xmlXPathNINF; #endif #define TODO \ xmlGenericError(xmlGenericErrorContext, \ "Unimplemented block at %s:%d\n", \ __FILE__, __LINE__); #define XML_SCHEMAS_NAMESPACE_NAME \ (const xmlChar *)"http://www.w3.org/2001/XMLSchema" #define IS_WSP_REPLACE_CH(c) ((((c) == 0x9) || ((c) == 0xa)) || \ ((c) == 0xd)) #define IS_WSP_SPACE_CH(c) ((c) == 0x20) #define IS_WSP_BLANK_CH(c) IS_BLANK_CH(c) /* Date value */ typedef struct _xmlSchemaValDate xmlSchemaValDate; typedef xmlSchemaValDate *xmlSchemaValDatePtr; struct _xmlSchemaValDate { long year; unsigned int mon :4; /* 1 <= mon <= 12 */ unsigned int day :5; /* 1 <= day <= 31 */ unsigned int hour :5; /* 0 <= hour <= 23 */ unsigned int min :6; /* 0 <= min <= 59 */ double sec; unsigned int tz_flag :1; /* is tzo explicitely set? */ signed int tzo :12; /* -1440 <= tzo <= 1440; currently only -840 to +840 are needed */ }; /* Duration value */ typedef struct _xmlSchemaValDuration xmlSchemaValDuration; typedef xmlSchemaValDuration *xmlSchemaValDurationPtr; struct _xmlSchemaValDuration { long mon; /* mon stores years also */ long day; double sec; /* sec stores min and hour also */ }; typedef struct _xmlSchemaValDecimal xmlSchemaValDecimal; typedef xmlSchemaValDecimal *xmlSchemaValDecimalPtr; struct _xmlSchemaValDecimal { /* would use long long but not portable */ unsigned long lo; unsigned long mi; unsigned long hi; unsigned int extra; unsigned int sign:1; unsigned int frac:7; unsigned int total:8; }; typedef struct _xmlSchemaValQName xmlSchemaValQName; typedef xmlSchemaValQName *xmlSchemaValQNamePtr; struct _xmlSchemaValQName { xmlChar *name; xmlChar *uri; }; typedef struct _xmlSchemaValHex xmlSchemaValHex; typedef xmlSchemaValHex *xmlSchemaValHexPtr; struct _xmlSchemaValHex { xmlChar *str; unsigned int total; }; typedef struct _xmlSchemaValBase64 xmlSchemaValBase64; typedef xmlSchemaValBase64 *xmlSchemaValBase64Ptr; struct _xmlSchemaValBase64 { xmlChar *str; unsigned int total; }; struct _xmlSchemaVal { xmlSchemaValType type; struct _xmlSchemaVal *next; union { xmlSchemaValDecimal decimal; xmlSchemaValDate date; xmlSchemaValDuration dur; xmlSchemaValQName qname; xmlSchemaValHex hex; xmlSchemaValBase64 base64; float f; double d; int b; xmlChar *str; } value; }; static int xmlSchemaTypesInitialized = 0; static xmlHashTablePtr xmlSchemaTypesBank = NULL; /* * Basic types */ static xmlSchemaTypePtr xmlSchemaTypeStringDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeAnyTypeDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeAnySimpleTypeDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeDecimalDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeDatetimeDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeDateDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeTimeDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeGYearDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeGYearMonthDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeGDayDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeGMonthDayDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeGMonthDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeDurationDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeFloatDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeBooleanDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeDoubleDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeHexBinaryDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeBase64BinaryDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeAnyURIDef = NULL; /* * Derived types */ static xmlSchemaTypePtr xmlSchemaTypePositiveIntegerDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeNonPositiveIntegerDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeNegativeIntegerDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeNonNegativeIntegerDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeIntegerDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeLongDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeIntDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeShortDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeByteDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeUnsignedLongDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeUnsignedIntDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeUnsignedShortDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeUnsignedByteDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeNormStringDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeTokenDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeLanguageDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeNameDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeQNameDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeNCNameDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeIdDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeIdrefDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeIdrefsDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeEntityDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeEntitiesDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeNotationDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeNmtokenDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeNmtokensDef = NULL; /************************************************************************ * * * Datatype error handlers * * * ************************************************************************/ /** * xmlSchemaTypeErrMemory: * @extra: extra informations * * Handle an out of memory condition */ static void xmlSchemaTypeErrMemory(xmlNodePtr node, const char *extra) { __xmlSimpleError(XML_FROM_DATATYPE, XML_ERR_NO_MEMORY, node, NULL, extra); } /************************************************************************ * * * Base types support * * * ************************************************************************/ /** * xmlSchemaNewValue: * @type: the value type * * Allocate a new simple type value * * Returns a pointer to the new value or NULL in case of error */ static xmlSchemaValPtr xmlSchemaNewValue(xmlSchemaValType type) { xmlSchemaValPtr value; value = (xmlSchemaValPtr) xmlMalloc(sizeof(xmlSchemaVal)); if (value == NULL) { return(NULL); } memset(value, 0, sizeof(xmlSchemaVal)); value->type = type; return(value); } static xmlSchemaFacetPtr xmlSchemaNewMinLengthFacet(int value) { xmlSchemaFacetPtr ret; ret = xmlSchemaNewFacet(); if (ret == NULL) { return(NULL); } ret->type = XML_SCHEMA_FACET_MINLENGTH; ret->val = xmlSchemaNewValue(XML_SCHEMAS_NNINTEGER); ret->val->value.decimal.lo = value; return (ret); } /* * xmlSchemaInitBasicType: * @name: the type name * @type: the value type associated * * Initialize one primitive built-in type */ static xmlSchemaTypePtr xmlSchemaInitBasicType(const char *name, xmlSchemaValType type, xmlSchemaTypePtr baseType) { xmlSchemaTypePtr ret; ret = (xmlSchemaTypePtr) xmlMalloc(sizeof(xmlSchemaType)); if (ret == NULL) { xmlSchemaTypeErrMemory(NULL, "could not initialize basic types"); return(NULL); } memset(ret, 0, sizeof(xmlSchemaType)); ret->name = (const xmlChar *)name; ret->targetNamespace = XML_SCHEMAS_NAMESPACE_NAME; ret->type = XML_SCHEMA_TYPE_BASIC; ret->baseType = baseType; ret->contentType = XML_SCHEMA_CONTENT_BASIC; /* * Primitive types. */ switch (type) { case XML_SCHEMAS_STRING: case XML_SCHEMAS_DECIMAL: case XML_SCHEMAS_DATE: case XML_SCHEMAS_DATETIME: case XML_SCHEMAS_TIME: case XML_SCHEMAS_GYEAR: case XML_SCHEMAS_GYEARMONTH: case XML_SCHEMAS_GMONTH: case XML_SCHEMAS_GMONTHDAY: case XML_SCHEMAS_GDAY: case XML_SCHEMAS_DURATION: case XML_SCHEMAS_FLOAT: case XML_SCHEMAS_DOUBLE: case XML_SCHEMAS_BOOLEAN: case XML_SCHEMAS_ANYURI: case XML_SCHEMAS_HEXBINARY: case XML_SCHEMAS_BASE64BINARY: case XML_SCHEMAS_QNAME: case XML_SCHEMAS_NOTATION: ret->flags |= XML_SCHEMAS_TYPE_BUILTIN_PRIMITIVE; break; default: break; } /* * Set variety. */ switch (type) { case XML_SCHEMAS_ANYTYPE: case XML_SCHEMAS_ANYSIMPLETYPE: break; case XML_SCHEMAS_IDREFS: case XML_SCHEMAS_NMTOKENS: case XML_SCHEMAS_ENTITIES: ret->flags |= XML_SCHEMAS_TYPE_VARIETY_LIST; ret->facets = xmlSchemaNewMinLengthFacet(1); ret->flags |= XML_SCHEMAS_TYPE_HAS_FACETS; break; default: ret->flags |= XML_SCHEMAS_TYPE_VARIETY_ATOMIC; break; } xmlHashAddEntry2(xmlSchemaTypesBank, ret->name, XML_SCHEMAS_NAMESPACE_NAME, ret); ret->builtInType = type; return(ret); } /* * WARNING: Those type reside normally in xmlschemas.c but are * redefined here locally in oder of being able to use them for xs:anyType- * TODO: Remove those definition if we move the types to a header file. * TODO: Always keep those structs up-to-date with the originals. */ #define UNBOUNDED (1 << 30) typedef struct _xmlSchemaTreeItem xmlSchemaTreeItem; typedef xmlSchemaTreeItem *xmlSchemaTreeItemPtr; struct _xmlSchemaTreeItem { xmlSchemaTypeType type; xmlSchemaAnnotPtr annot; xmlSchemaTreeItemPtr next; xmlSchemaTreeItemPtr children; }; typedef struct _xmlSchemaParticle xmlSchemaParticle; typedef xmlSchemaParticle *xmlSchemaParticlePtr; struct _xmlSchemaParticle { xmlSchemaTypeType type; xmlSchemaAnnotPtr annot; xmlSchemaTreeItemPtr next; xmlSchemaTreeItemPtr children; int minOccurs; int maxOccurs; xmlNodePtr node; }; typedef struct _xmlSchemaModelGroup xmlSchemaModelGroup; typedef xmlSchemaModelGroup *xmlSchemaModelGroupPtr; struct _xmlSchemaModelGroup { xmlSchemaTypeType type; xmlSchemaAnnotPtr annot; xmlSchemaTreeItemPtr next; xmlSchemaTreeItemPtr children; xmlNodePtr node; }; static xmlSchemaParticlePtr xmlSchemaAddParticle(void) { xmlSchemaParticlePtr ret = NULL; ret = (xmlSchemaParticlePtr) xmlMalloc(sizeof(xmlSchemaParticle)); if (ret == NULL) { xmlSchemaTypeErrMemory(NULL, "allocating particle component"); return (NULL); } memset(ret, 0, sizeof(xmlSchemaParticle)); ret->type = XML_SCHEMA_TYPE_PARTICLE; ret->minOccurs = 1; ret->maxOccurs = 1; return (ret); } /* * xmlSchemaInitTypes: * * Initialize the default XML Schemas type library */ void xmlSchemaInitTypes(void) { if (xmlSchemaTypesInitialized != 0) return; xmlSchemaTypesBank = xmlHashCreate(40); /* * 3.4.7 Built-in Complex Type Definition */ xmlSchemaTypeAnyTypeDef = xmlSchemaInitBasicType("anyType", XML_SCHEMAS_ANYTYPE, NULL); xmlSchemaTypeAnyTypeDef->baseType = xmlSchemaTypeAnyTypeDef; xmlSchemaTypeAnyTypeDef->contentType = XML_SCHEMA_CONTENT_MIXED; /* * Init the content type. */ xmlSchemaTypeAnyTypeDef->contentType = XML_SCHEMA_CONTENT_MIXED; { xmlSchemaParticlePtr particle; xmlSchemaModelGroupPtr sequence; xmlSchemaWildcardPtr wild; /* First particle. */ particle = xmlSchemaAddParticle(); if (particle == NULL) return; xmlSchemaTypeAnyTypeDef->subtypes = (xmlSchemaTypePtr) particle; /* Sequence model group. */ sequence = (xmlSchemaModelGroupPtr) xmlMalloc(sizeof(xmlSchemaModelGroup)); if (sequence == NULL) { xmlSchemaTypeErrMemory(NULL, "allocating model group component"); return; } memset(sequence, 0, sizeof(xmlSchemaModelGroup)); sequence->type = XML_SCHEMA_TYPE_SEQUENCE; particle->children = (xmlSchemaTreeItemPtr) sequence; /* Second particle. */ particle = xmlSchemaAddParticle(); if (particle == NULL) return; particle->minOccurs = 0; particle->maxOccurs = UNBOUNDED; sequence->children = (xmlSchemaTreeItemPtr) particle; /* The wildcard */ wild = (xmlSchemaWildcardPtr) xmlMalloc(sizeof(xmlSchemaWildcard)); if (wild == NULL) { xmlSchemaTypeErrMemory(NULL, "allocating wildcard component"); return; } memset(wild, 0, sizeof(xmlSchemaWildcard)); wild->type = XML_SCHEMA_TYPE_ANY; wild->any = 1; wild->processContents = XML_SCHEMAS_ANY_LAX; particle->children = (xmlSchemaTreeItemPtr) wild; /* * Create the attribute wildcard. */ wild = (xmlSchemaWildcardPtr) xmlMalloc(sizeof(xmlSchemaWildcard)); if (wild == NULL) { xmlSchemaTypeErrMemory(NULL, "could not create an attribute " "wildcard on anyType"); return; } memset(wild, 0, sizeof(xmlSchemaWildcard)); wild->any = 1; wild->processContents = XML_SCHEMAS_ANY_LAX; xmlSchemaTypeAnyTypeDef->attributeWildcard = wild; } xmlSchemaTypeAnySimpleTypeDef = xmlSchemaInitBasicType("anySimpleType", XML_SCHEMAS_ANYSIMPLETYPE, xmlSchemaTypeAnyTypeDef); /* * primitive datatypes */ xmlSchemaTypeStringDef = xmlSchemaInitBasicType("string", XML_SCHEMAS_STRING, xmlSchemaTypeAnySimpleTypeDef); xmlSchemaTypeDecimalDef = xmlSchemaInitBasicType("decimal", XML_SCHEMAS_DECIMAL, xmlSchemaTypeAnySimpleTypeDef); xmlSchemaTypeDateDef = xmlSchemaInitBasicType("date", XML_SCHEMAS_DATE, xmlSchemaTypeAnySimpleTypeDef); xmlSchemaTypeDatetimeDef = xmlSchemaInitBasicType("dateTime", XML_SCHEMAS_DATETIME, xmlSchemaTypeAnySimpleTypeDef); xmlSchemaTypeTimeDef = xmlSchemaInitBasicType("time", XML_SCHEMAS_TIME, xmlSchemaTypeAnySimpleTypeDef); xmlSchemaTypeGYearDef = xmlSchemaInitBasicType("gYear", XML_SCHEMAS_GYEAR, xmlSchemaTypeAnySimpleTypeDef); xmlSchemaTypeGYearMonthDef = xmlSchemaInitBasicType("gYearMonth", XML_SCHEMAS_GYEARMONTH, xmlSchemaTypeAnySimpleTypeDef); xmlSchemaTypeGMonthDef = xmlSchemaInitBasicType("gMonth", XML_SCHEMAS_GMONTH, xmlSchemaTypeAnySimpleTypeDef); xmlSchemaTypeGMonthDayDef = xmlSchemaInitBasicType("gMonthDay", XML_SCHEMAS_GMONTHDAY, xmlSchemaTypeAnySimpleTypeDef); xmlSchemaTypeGDayDef = xmlSchemaInitBasicType("gDay", XML_SCHEMAS_GDAY, xmlSchemaTypeAnySimpleTypeDef); xmlSchemaTypeDurationDef = xmlSchemaInitBasicType("duration", XML_SCHEMAS_DURATION, xmlSchemaTypeAnySimpleTypeDef); xmlSchemaTypeFloatDef = xmlSchemaInitBasicType("float", XML_SCHEMAS_FLOAT, xmlSchemaTypeAnySimpleTypeDef); xmlSchemaTypeDoubleDef = xmlSchemaInitBasicType("double", XML_SCHEMAS_DOUBLE, xmlSchemaTypeAnySimpleTypeDef); xmlSchemaTypeBooleanDef = xmlSchemaInitBasicType("boolean", XML_SCHEMAS_BOOLEAN, xmlSchemaTypeAnySimpleTypeDef); xmlSchemaTypeAnyURIDef = xmlSchemaInitBasicType("anyURI", XML_SCHEMAS_ANYURI, xmlSchemaTypeAnySimpleTypeDef); xmlSchemaTypeHexBinaryDef = xmlSchemaInitBasicType("hexBinary", XML_SCHEMAS_HEXBINARY, xmlSchemaTypeAnySimpleTypeDef); xmlSchemaTypeBase64BinaryDef = xmlSchemaInitBasicType("base64Binary", XML_SCHEMAS_BASE64BINARY, xmlSchemaTypeAnySimpleTypeDef); xmlSchemaTypeNotationDef = xmlSchemaInitBasicType("NOTATION", XML_SCHEMAS_NOTATION, xmlSchemaTypeAnySimpleTypeDef); xmlSchemaTypeQNameDef = xmlSchemaInitBasicType("QName", XML_SCHEMAS_QNAME, xmlSchemaTypeAnySimpleTypeDef); /* * derived datatypes */ xmlSchemaTypeIntegerDef = xmlSchemaInitBasicType("integer", XML_SCHEMAS_INTEGER, xmlSchemaTypeDecimalDef); xmlSchemaTypeNonPositiveIntegerDef = xmlSchemaInitBasicType("nonPositiveInteger", XML_SCHEMAS_NPINTEGER, xmlSchemaTypeIntegerDef); xmlSchemaTypeNegativeIntegerDef = xmlSchemaInitBasicType("negativeInteger", XML_SCHEMAS_NINTEGER, xmlSchemaTypeNonPositiveIntegerDef); xmlSchemaTypeLongDef = xmlSchemaInitBasicType("long", XML_SCHEMAS_LONG, xmlSchemaTypeIntegerDef); xmlSchemaTypeIntDef = xmlSchemaInitBasicType("int", XML_SCHEMAS_INT, xmlSchemaTypeLongDef); xmlSchemaTypeShortDef = xmlSchemaInitBasicType("short", XML_SCHEMAS_SHORT, xmlSchemaTypeIntDef); xmlSchemaTypeByteDef = xmlSchemaInitBasicType("byte", XML_SCHEMAS_BYTE, xmlSchemaTypeShortDef); xmlSchemaTypeNonNegativeIntegerDef = xmlSchemaInitBasicType("nonNegativeInteger", XML_SCHEMAS_NNINTEGER, xmlSchemaTypeIntegerDef); xmlSchemaTypeUnsignedLongDef = xmlSchemaInitBasicType("unsignedLong", XML_SCHEMAS_ULONG, xmlSchemaTypeNonNegativeIntegerDef); xmlSchemaTypeUnsignedIntDef = xmlSchemaInitBasicType("unsignedInt", XML_SCHEMAS_UINT, xmlSchemaTypeUnsignedLongDef); xmlSchemaTypeUnsignedShortDef = xmlSchemaInitBasicType("unsignedShort", XML_SCHEMAS_USHORT, xmlSchemaTypeUnsignedIntDef); xmlSchemaTypeUnsignedByteDef = xmlSchemaInitBasicType("unsignedByte", XML_SCHEMAS_UBYTE, xmlSchemaTypeUnsignedShortDef); xmlSchemaTypePositiveIntegerDef = xmlSchemaInitBasicType("positiveInteger", XML_SCHEMAS_PINTEGER, xmlSchemaTypeNonNegativeIntegerDef); xmlSchemaTypeNormStringDef = xmlSchemaInitBasicType("normalizedString", XML_SCHEMAS_NORMSTRING, xmlSchemaTypeStringDef); xmlSchemaTypeTokenDef = xmlSchemaInitBasicType("token", XML_SCHEMAS_TOKEN, xmlSchemaTypeNormStringDef); xmlSchemaTypeLanguageDef = xmlSchemaInitBasicType("language", XML_SCHEMAS_LANGUAGE, xmlSchemaTypeTokenDef); xmlSchemaTypeNameDef = xmlSchemaInitBasicType("Name", XML_SCHEMAS_NAME, xmlSchemaTypeTokenDef); xmlSchemaTypeNmtokenDef = xmlSchemaInitBasicType("NMTOKEN", XML_SCHEMAS_NMTOKEN, xmlSchemaTypeTokenDef); xmlSchemaTypeNCNameDef = xmlSchemaInitBasicType("NCName", XML_SCHEMAS_NCNAME, xmlSchemaTypeNameDef); xmlSchemaTypeIdDef = xmlSchemaInitBasicType("ID", XML_SCHEMAS_ID, xmlSchemaTypeNCNameDef); xmlSchemaTypeIdrefDef = xmlSchemaInitBasicType("IDREF", XML_SCHEMAS_IDREF, xmlSchemaTypeNCNameDef); xmlSchemaTypeEntityDef = xmlSchemaInitBasicType("ENTITY", XML_SCHEMAS_ENTITY, xmlSchemaTypeNCNameDef); /* * Derived list types. */ /* ENTITIES */ xmlSchemaTypeEntitiesDef = xmlSchemaInitBasicType("ENTITIES", XML_SCHEMAS_ENTITIES, xmlSchemaTypeAnySimpleTypeDef); xmlSchemaTypeEntitiesDef->subtypes = xmlSchemaTypeEntityDef; /* IDREFS */ xmlSchemaTypeIdrefsDef = xmlSchemaInitBasicType("IDREFS", XML_SCHEMAS_IDREFS, xmlSchemaTypeAnySimpleTypeDef); xmlSchemaTypeIdrefsDef->subtypes = xmlSchemaTypeIdrefDef; /* NMTOKENS */ xmlSchemaTypeNmtokensDef = xmlSchemaInitBasicType("NMTOKENS", XML_SCHEMAS_NMTOKENS, xmlSchemaTypeAnySimpleTypeDef); xmlSchemaTypeNmtokensDef->subtypes = xmlSchemaTypeNmtokenDef; xmlSchemaTypesInitialized = 1; } /** * xmlSchemaCleanupTypes: * * Cleanup the default XML Schemas type library */ void xmlSchemaCleanupTypes(void) { if (xmlSchemaTypesInitialized == 0) return; /* * Free xs:anyType. */ { xmlSchemaParticlePtr particle; /* Attribute wildcard. */ xmlSchemaFreeWildcard(xmlSchemaTypeAnyTypeDef->attributeWildcard); /* Content type. */ particle = (xmlSchemaParticlePtr) xmlSchemaTypeAnyTypeDef->subtypes; /* Wildcard. */ xmlSchemaFreeWildcard((xmlSchemaWildcardPtr) particle->children->children->children); xmlFree((xmlSchemaParticlePtr) particle->children->children); /* Sequence model group. */ xmlFree((xmlSchemaModelGroupPtr) particle->children); xmlFree((xmlSchemaParticlePtr) particle); xmlSchemaTypeAnyTypeDef->subtypes = NULL; } xmlHashFree(xmlSchemaTypesBank, (xmlHashDeallocator) xmlSchemaFreeType); xmlSchemaTypesInitialized = 0; } /** * xmlSchemaIsBuiltInTypeFacet: * @type: the built-in type * @facetType: the facet type * * Evaluates if a specific facet can be * used in conjunction with a type. * * Returns 1 if the facet can be used with the given built-in type, * 0 otherwise and -1 in case the type is not a built-in type. */ int xmlSchemaIsBuiltInTypeFacet(xmlSchemaTypePtr type, int facetType) { if (type == NULL) return (-1); if (type->type != XML_SCHEMA_TYPE_BASIC) return (-1); switch (type->builtInType) { case XML_SCHEMAS_BOOLEAN: if ((facetType == XML_SCHEMA_FACET_PATTERN) || (facetType == XML_SCHEMA_FACET_WHITESPACE)) return (1); else return (0); case XML_SCHEMAS_STRING: case XML_SCHEMAS_NOTATION: case XML_SCHEMAS_QNAME: case XML_SCHEMAS_ANYURI: case XML_SCHEMAS_BASE64BINARY: case XML_SCHEMAS_HEXBINARY: if ((facetType == XML_SCHEMA_FACET_LENGTH) || (facetType == XML_SCHEMA_FACET_MINLENGTH) || (facetType == XML_SCHEMA_FACET_MAXLENGTH) || (facetType == XML_SCHEMA_FACET_PATTERN) || (facetType == XML_SCHEMA_FACET_ENUMERATION) || (facetType == XML_SCHEMA_FACET_WHITESPACE)) return (1); else return (0); case XML_SCHEMAS_DECIMAL: if ((facetType == XML_SCHEMA_FACET_TOTALDIGITS) || (facetType == XML_SCHEMA_FACET_FRACTIONDIGITS) || (facetType == XML_SCHEMA_FACET_PATTERN) || (facetType == XML_SCHEMA_FACET_WHITESPACE) || (facetType == XML_SCHEMA_FACET_ENUMERATION) || (facetType == XML_SCHEMA_FACET_MAXINCLUSIVE) || (facetType == XML_SCHEMA_FACET_MAXEXCLUSIVE) || (facetType == XML_SCHEMA_FACET_MININCLUSIVE) || (facetType == XML_SCHEMA_FACET_MINEXCLUSIVE)) return (1); else return (0); case XML_SCHEMAS_TIME: case XML_SCHEMAS_GDAY: case XML_SCHEMAS_GMONTH: case XML_SCHEMAS_GMONTHDAY: case XML_SCHEMAS_GYEAR: case XML_SCHEMAS_GYEARMONTH: case XML_SCHEMAS_DATE: case XML_SCHEMAS_DATETIME: case XML_SCHEMAS_DURATION: case XML_SCHEMAS_FLOAT: case XML_SCHEMAS_DOUBLE: if ((facetType == XML_SCHEMA_FACET_PATTERN) || (facetType == XML_SCHEMA_FACET_ENUMERATION) || (facetType == XML_SCHEMA_FACET_WHITESPACE) || (facetType == XML_SCHEMA_FACET_MAXINCLUSIVE) || (facetType == XML_SCHEMA_FACET_MAXEXCLUSIVE) || (facetType == XML_SCHEMA_FACET_MININCLUSIVE) || (facetType == XML_SCHEMA_FACET_MINEXCLUSIVE)) return (1); else return (0); default: break; } return (0); } /** * xmlSchemaGetBuiltInType: * @type: the type of the built in type * * Gives you the type struct for a built-in * type by its type id. * * Returns the type if found, NULL otherwise. */ xmlSchemaTypePtr xmlSchemaGetBuiltInType(xmlSchemaValType type) { if (xmlSchemaTypesInitialized == 0) xmlSchemaInitTypes(); switch (type) { case XML_SCHEMAS_ANYSIMPLETYPE: return (xmlSchemaTypeAnySimpleTypeDef); case XML_SCHEMAS_STRING: return (xmlSchemaTypeStringDef); case XML_SCHEMAS_NORMSTRING: return (xmlSchemaTypeNormStringDef); case XML_SCHEMAS_DECIMAL: return (xmlSchemaTypeDecimalDef); case XML_SCHEMAS_TIME: return (xmlSchemaTypeTimeDef); case XML_SCHEMAS_GDAY: return (xmlSchemaTypeGDayDef); case XML_SCHEMAS_GMONTH: return (xmlSchemaTypeGMonthDef); case XML_SCHEMAS_GMONTHDAY: return (xmlSchemaTypeGMonthDayDef); case XML_SCHEMAS_GYEAR: return (xmlSchemaTypeGYearDef); case XML_SCHEMAS_GYEARMONTH: return (xmlSchemaTypeGYearMonthDef); case XML_SCHEMAS_DATE: return (xmlSchemaTypeDateDef); case XML_SCHEMAS_DATETIME: return (xmlSchemaTypeDatetimeDef); case XML_SCHEMAS_DURATION: return (xmlSchemaTypeDurationDef); case XML_SCHEMAS_FLOAT: return (xmlSchemaTypeFloatDef); case XML_SCHEMAS_DOUBLE: return (xmlSchemaTypeDoubleDef); case XML_SCHEMAS_BOOLEAN: return (xmlSchemaTypeBooleanDef); case XML_SCHEMAS_TOKEN: return (xmlSchemaTypeTokenDef); case XML_SCHEMAS_LANGUAGE: return (xmlSchemaTypeLanguageDef); case XML_SCHEMAS_NMTOKEN: return (xmlSchemaTypeNmtokenDef); case XML_SCHEMAS_NMTOKENS: return (xmlSchemaTypeNmtokensDef); case XML_SCHEMAS_NAME: return (xmlSchemaTypeNameDef); case XML_SCHEMAS_QNAME: return (xmlSchemaTypeQNameDef); case XML_SCHEMAS_NCNAME: return (xmlSchemaTypeNCNameDef); case XML_SCHEMAS_ID: return (xmlSchemaTypeIdDef); case XML_SCHEMAS_IDREF: return (xmlSchemaTypeIdrefDef); case XML_SCHEMAS_IDREFS: return (xmlSchemaTypeIdrefsDef); case XML_SCHEMAS_ENTITY: return (xmlSchemaTypeEntityDef); case XML_SCHEMAS_ENTITIES: return (xmlSchemaTypeEntitiesDef); case XML_SCHEMAS_NOTATION: return (xmlSchemaTypeNotationDef); case XML_SCHEMAS_ANYURI: return (xmlSchemaTypeAnyURIDef); case XML_SCHEMAS_INTEGER: return (xmlSchemaTypeIntegerDef); case XML_SCHEMAS_NPINTEGER: return (xmlSchemaTypeNonPositiveIntegerDef); case XML_SCHEMAS_NINTEGER: return (xmlSchemaTypeNegativeIntegerDef); case XML_SCHEMAS_NNINTEGER: return (xmlSchemaTypeNonNegativeIntegerDef); case XML_SCHEMAS_PINTEGER: return (xmlSchemaTypePositiveIntegerDef); case XML_SCHEMAS_INT: return (xmlSchemaTypeIntDef); case XML_SCHEMAS_UINT: return (xmlSchemaTypeUnsignedIntDef); case XML_SCHEMAS_LONG: return (xmlSchemaTypeLongDef); case XML_SCHEMAS_ULONG: return (xmlSchemaTypeUnsignedLongDef); case XML_SCHEMAS_SHORT: return (xmlSchemaTypeShortDef); case XML_SCHEMAS_USHORT: return (xmlSchemaTypeUnsignedShortDef); case XML_SCHEMAS_BYTE: return (xmlSchemaTypeByteDef); case XML_SCHEMAS_UBYTE: return (xmlSchemaTypeUnsignedByteDef); case XML_SCHEMAS_HEXBINARY: return (xmlSchemaTypeHexBinaryDef); case XML_SCHEMAS_BASE64BINARY: return (xmlSchemaTypeBase64BinaryDef); case XML_SCHEMAS_ANYTYPE: return (xmlSchemaTypeAnyTypeDef); default: return (NULL); } } /** * xmlSchemaValueAppend: * @prev: the value * @cur: the value to be appended * * Appends a next sibling to a list of computed values. * * Returns 0 if succeeded and -1 on API errors. */ int xmlSchemaValueAppend(xmlSchemaValPtr prev, xmlSchemaValPtr cur) { if ((prev == NULL) || (cur == NULL)) return (-1); prev->next = cur; return (0); } /** * xmlSchemaValueGetNext: * @cur: the value * * Accessor for the next sibling of a list of computed values. * * Returns the next value or NULL if there was none, or on * API errors. */ xmlSchemaValPtr xmlSchemaValueGetNext(xmlSchemaValPtr cur) { if (cur == NULL) return (NULL); return (cur->next); } /** * xmlSchemaValueGetAsString: * @val: the value * * Accessor for the string value of a computed value. * * Returns the string value or NULL if there was none, or on * API errors. */ const xmlChar * xmlSchemaValueGetAsString(xmlSchemaValPtr val) { if (val == NULL) return (NULL); switch (val->type) { case XML_SCHEMAS_STRING: case XML_SCHEMAS_NORMSTRING: case XML_SCHEMAS_ANYSIMPLETYPE: case XML_SCHEMAS_TOKEN: case XML_SCHEMAS_LANGUAGE: case XML_SCHEMAS_NMTOKEN: case XML_SCHEMAS_NAME: case XML_SCHEMAS_NCNAME: case XML_SCHEMAS_ID: case XML_SCHEMAS_IDREF: case XML_SCHEMAS_ENTITY: case XML_SCHEMAS_ANYURI: return (BAD_CAST val->value.str); default: break; } return (NULL); } /** * xmlSchemaValueGetAsBoolean: * @val: the value * * Accessor for the boolean value of a computed value. * * Returns 1 if true and 0 if false, or in case of an error. Hmm. */ int xmlSchemaValueGetAsBoolean(xmlSchemaValPtr val) { if ((val == NULL) || (val->type != XML_SCHEMAS_BOOLEAN)) return (0); return (val->value.b); } /** * xmlSchemaNewStringValue: * @type: the value type * @value: the value * * Allocate a new simple type value. The type can be * of XML_SCHEMAS_STRING. * WARNING: This one is intended to be expanded for other * string based types. We need this for anySimpleType as well. * The given value is consumed and freed with the struct. * * Returns a pointer to the new value or NULL in case of error */ xmlSchemaValPtr xmlSchemaNewStringValue(xmlSchemaValType type, const xmlChar *value) { xmlSchemaValPtr val; if (type != XML_SCHEMAS_STRING) return(NULL); val = (xmlSchemaValPtr) xmlMalloc(sizeof(xmlSchemaVal)); if (val == NULL) { return(NULL); } memset(val, 0, sizeof(xmlSchemaVal)); val->type = type; val->value.str = (xmlChar *) value; return(val); } /** * xmlSchemaNewNOTATIONValue: * @name: the notation name * @ns: the notation namespace name or NULL * * Allocate a new NOTATION value. * The given values are consumed and freed with the struct. * * Returns a pointer to the new value or NULL in case of error */ xmlSchemaValPtr xmlSchemaNewNOTATIONValue(const xmlChar *name, const xmlChar *ns) { xmlSchemaValPtr val; val = xmlSchemaNewValue(XML_SCHEMAS_NOTATION); if (val == NULL) return (NULL); val->value.qname.name = (xmlChar *)name; if (ns != NULL) val->value.qname.uri = (xmlChar *)ns; return(val); } /** * xmlSchemaNewQNameValue: * @namespaceName: the namespace name * @localName: the local name * * Allocate a new QName value. * The given values are consumed and freed with the struct. * * Returns a pointer to the new value or NULL in case of an error. */ xmlSchemaValPtr xmlSchemaNewQNameValue(const xmlChar *namespaceName, const xmlChar *localName) { xmlSchemaValPtr val; val = xmlSchemaNewValue(XML_SCHEMAS_QNAME); if (val == NULL) return (NULL); val->value.qname.name = (xmlChar *) localName; val->value.qname.uri = (xmlChar *) namespaceName; return(val); } /** * xmlSchemaFreeValue: * @value: the value to free * * Cleanup the default XML Schemas type library */ void xmlSchemaFreeValue(xmlSchemaValPtr value) { xmlSchemaValPtr prev; while (value != NULL) { switch (value->type) { case XML_SCHEMAS_STRING: case XML_SCHEMAS_NORMSTRING: case XML_SCHEMAS_TOKEN: case XML_SCHEMAS_LANGUAGE: case XML_SCHEMAS_NMTOKEN: case XML_SCHEMAS_NMTOKENS: case XML_SCHEMAS_NAME: case XML_SCHEMAS_NCNAME: case XML_SCHEMAS_ID: case XML_SCHEMAS_IDREF: case XML_SCHEMAS_IDREFS: case XML_SCHEMAS_ENTITY: case XML_SCHEMAS_ENTITIES: case XML_SCHEMAS_ANYURI: case XML_SCHEMAS_ANYSIMPLETYPE: if (value->value.str != NULL) xmlFree(value->value.str); break; case XML_SCHEMAS_NOTATION: case XML_SCHEMAS_QNAME: if (value->value.qname.uri != NULL) xmlFree(value->value.qname.uri); if (value->value.qname.name != NULL) xmlFree(value->value.qname.name); break; case XML_SCHEMAS_HEXBINARY: if (value->value.hex.str != NULL) xmlFree(value->value.hex.str); break; case XML_SCHEMAS_BASE64BINARY: if (value->value.base64.str != NULL) xmlFree(value->value.base64.str); break; default: break; } prev = value; value = value->next; xmlFree(prev); } } /** * xmlSchemaGetPredefinedType: * @name: the type name * @ns: the URI of the namespace usually "http://www.w3.org/2001/XMLSchema" * * Lookup a type in the default XML Schemas type library * * Returns the type if found, NULL otherwise */ xmlSchemaTypePtr xmlSchemaGetPredefinedType(const xmlChar *name, const xmlChar *ns) { if (xmlSchemaTypesInitialized == 0) xmlSchemaInitTypes(); if (name == NULL) return(NULL); return((xmlSchemaTypePtr) xmlHashLookup2(xmlSchemaTypesBank, name, ns)); } /** * xmlSchemaGetBuiltInListSimpleTypeItemType: * @type: the built-in simple type. * * Lookup function * * Returns the item type of @type as defined by the built-in datatype * hierarchy of XML Schema Part 2: Datatypes, or NULL in case of an error. */ xmlSchemaTypePtr xmlSchemaGetBuiltInListSimpleTypeItemType(xmlSchemaTypePtr type) { if ((type == NULL) || (type->type != XML_SCHEMA_TYPE_BASIC)) return (NULL); switch (type->builtInType) { case XML_SCHEMAS_NMTOKENS: return (xmlSchemaTypeNmtokenDef ); case XML_SCHEMAS_IDREFS: return (xmlSchemaTypeIdrefDef); case XML_SCHEMAS_ENTITIES: return (xmlSchemaTypeEntityDef); default: return (NULL); } } /**************************************************************** * * * Convenience macros and functions * * * ****************************************************************/ #define IS_TZO_CHAR(c) \ ((c == 0) || (c == 'Z') || (c == '+') || (c == '-')) #define VALID_YEAR(yr) (yr != 0) #define VALID_MONTH(mon) ((mon >= 1) && (mon <= 12)) /* VALID_DAY should only be used when month is unknown */ #define VALID_DAY(day) ((day >= 1) && (day <= 31)) #define VALID_HOUR(hr) ((hr >= 0) && (hr <= 23)) #define VALID_MIN(min) ((min >= 0) && (min <= 59)) #define VALID_SEC(sec) ((sec >= 0) && (sec < 60)) #define VALID_TZO(tzo) ((tzo > -840) && (tzo < 840)) #define IS_LEAP(y) \ (((y % 4 == 0) && (y % 100 != 0)) || (y % 400 == 0)) static const unsigned int daysInMonth[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; static const unsigned int daysInMonthLeap[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; #define MAX_DAYINMONTH(yr,mon) \ (IS_LEAP(yr) ? daysInMonthLeap[mon - 1] : daysInMonth[mon - 1]) #define VALID_MDAY(dt) \ (IS_LEAP(dt->year) ? \ (dt->day <= daysInMonthLeap[dt->mon - 1]) : \ (dt->day <= daysInMonth[dt->mon - 1])) #define VALID_DATE(dt) \ (VALID_YEAR(dt->year) && VALID_MONTH(dt->mon) && VALID_MDAY(dt)) #define VALID_TIME(dt) \ (VALID_HOUR(dt->hour) && VALID_MIN(dt->min) && \ VALID_SEC(dt->sec) && VALID_TZO(dt->tzo)) #define VALID_DATETIME(dt) \ (VALID_DATE(dt) && VALID_TIME(dt)) #define SECS_PER_MIN (60) #define SECS_PER_HOUR (60 * SECS_PER_MIN) #define SECS_PER_DAY (24 * SECS_PER_HOUR) static const long dayInYearByMonth[12] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 }; static const long dayInLeapYearByMonth[12] = { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335 }; #define DAY_IN_YEAR(day, month, year) \ ((IS_LEAP(year) ? \ dayInLeapYearByMonth[month - 1] : \ dayInYearByMonth[month - 1]) + day) #ifdef DEBUG #define DEBUG_DATE(dt) \ xmlGenericError(xmlGenericErrorContext, \ "type=%o %04ld-%02u-%02uT%02u:%02u:%03f", \ dt->type,dt->value.date.year,dt->value.date.mon, \ dt->value.date.day,dt->value.date.hour,dt->value.date.min, \ dt->value.date.sec); \ if (dt->value.date.tz_flag) \ if (dt->value.date.tzo != 0) \ xmlGenericError(xmlGenericErrorContext, \ "%+05d\n",dt->value.date.tzo); \ else \ xmlGenericError(xmlGenericErrorContext, "Z\n"); \ else \ xmlGenericError(xmlGenericErrorContext,"\n") #else #define DEBUG_DATE(dt) #endif /** * _xmlSchemaParseGYear: * @dt: pointer to a date structure * @str: pointer to the string to analyze * * Parses a xs:gYear without time zone and fills in the appropriate * field of the @dt structure. @str is updated to point just after the * xs:gYear. It is supposed that @dt->year is big enough to contain * the year. * * Returns 0 or the error code */ static int _xmlSchemaParseGYear (xmlSchemaValDatePtr dt, const xmlChar **str) { const xmlChar *cur = *str, *firstChar; int isneg = 0, digcnt = 0; if (((*cur < '0') || (*cur > '9')) && (*cur != '-') && (*cur != '+')) return -1; if (*cur == '-') { isneg = 1; cur++; } firstChar = cur; while ((*cur >= '0') && (*cur <= '9')) { dt->year = dt->year * 10 + (*cur - '0'); cur++; digcnt++; } /* year must be at least 4 digits (CCYY); over 4 * digits cannot have a leading zero. */ if ((digcnt < 4) || ((digcnt > 4) && (*firstChar == '0'))) return 1; if (isneg) dt->year = - dt->year; if (!VALID_YEAR(dt->year)) return 2; *str = cur; return 0; } /** * PARSE_2_DIGITS: * @num: the integer to fill in * @cur: an #xmlChar * * @invalid: an integer * * Parses a 2-digits integer and updates @num with the value. @cur is * updated to point just after the integer. * In case of error, @invalid is set to %TRUE, values of @num and * @cur are undefined. */ #define PARSE_2_DIGITS(num, cur, invalid) \ if ((cur[0] < '0') || (cur[0] > '9') || \ (cur[1] < '0') || (cur[1] > '9')) \ invalid = 1; \ else \ num = (cur[0] - '0') * 10 + (cur[1] - '0'); \ cur += 2; /** * PARSE_FLOAT: * @num: the double to fill in * @cur: an #xmlChar * * @invalid: an integer * * Parses a float and updates @num with the value. @cur is * updated to point just after the float. The float must have a * 2-digits integer part and may or may not have a decimal part. * In case of error, @invalid is set to %TRUE, values of @num and * @cur are undefined. */ #define PARSE_FLOAT(num, cur, invalid) \ PARSE_2_DIGITS(num, cur, invalid); \ if (!invalid && (*cur == '.')) { \ double mult = 1; \ cur++; \ if ((*cur < '0') || (*cur > '9')) \ invalid = 1; \ while ((*cur >= '0') && (*cur <= '9')) { \ mult /= 10; \ num += (*cur - '0') * mult; \ cur++; \ } \ } /** * _xmlSchemaParseGMonth: * @dt: pointer to a date structure * @str: pointer to the string to analyze * * Parses a xs:gMonth without time zone and fills in the appropriate * field of the @dt structure. @str is updated to point just after the * xs:gMonth. * * Returns 0 or the error code */ static int _xmlSchemaParseGMonth (xmlSchemaValDatePtr dt, const xmlChar **str) { const xmlChar *cur = *str; int ret = 0; unsigned int value = 0; PARSE_2_DIGITS(value, cur, ret); if (ret != 0) return ret; if (!VALID_MONTH(value)) return 2; dt->mon = value; *str = cur; return 0; } /** * _xmlSchemaParseGDay: * @dt: pointer to a date structure * @str: pointer to the string to analyze * * Parses a xs:gDay without time zone and fills in the appropriate * field of the @dt structure. @str is updated to point just after the * xs:gDay. * * Returns 0 or the error code */ static int _xmlSchemaParseGDay (xmlSchemaValDatePtr dt, const xmlChar **str) { const xmlChar *cur = *str; int ret = 0; unsigned int value = 0; PARSE_2_DIGITS(value, cur, ret); if (ret != 0) return ret; if (!VALID_DAY(value)) return 2; dt->day = value; *str = cur; return 0; } /** * _xmlSchemaParseTime: * @dt: pointer to a date structure * @str: pointer to the string to analyze * * Parses a xs:time without time zone and fills in the appropriate * fields of the @dt structure. @str is updated to point just after the * xs:time. * In case of error, values of @dt fields are undefined. * * Returns 0 or the error code */ static int _xmlSchemaParseTime (xmlSchemaValDatePtr dt, const xmlChar **str) { const xmlChar *cur = *str; int ret = 0; int value = 0; PARSE_2_DIGITS(value, cur, ret); if (ret != 0) return ret; if (*cur != ':') return 1; if (!VALID_HOUR(value)) return 2; cur++; /* the ':' insures this string is xs:time */ dt->hour = value; PARSE_2_DIGITS(value, cur, ret); if (ret != 0) return ret; if (!VALID_MIN(value)) return 2; dt->min = value; if (*cur != ':') return 1; cur++; PARSE_FLOAT(dt->sec, cur, ret); if (ret != 0) return ret; if ((!VALID_SEC(dt->sec)) || (!VALID_TZO(dt->tzo))) return 2; *str = cur; return 0; } /** * _xmlSchemaParseTimeZone: * @dt: pointer to a date structure * @str: pointer to the string to analyze * * Parses a time zone without time zone and fills in the appropriate * field of the @dt structure. @str is updated to point just after the * time zone. * * Returns 0 or the error code */ static int _xmlSchemaParseTimeZone (xmlSchemaValDatePtr dt, const xmlChar **str) { const xmlChar *cur; int ret = 0; if (str == NULL) return -1; cur = *str; switch (*cur) { case 0: dt->tz_flag = 0; dt->tzo = 0; break; case 'Z': dt->tz_flag = 1; dt->tzo = 0; cur++; break; case '+': case '-': { int isneg = 0, tmp = 0; isneg = (*cur == '-'); cur++; PARSE_2_DIGITS(tmp, cur, ret); if (ret != 0) return ret; if (!VALID_HOUR(tmp)) return 2; if (*cur != ':') return 1; cur++; dt->tzo = tmp * 60; PARSE_2_DIGITS(tmp, cur, ret); if (ret != 0) return ret; if (!VALID_MIN(tmp)) return 2; dt->tzo += tmp; if (isneg) dt->tzo = - dt->tzo; if (!VALID_TZO(dt->tzo)) return 2; dt->tz_flag = 1; break; } default: return 1; } *str = cur; return 0; } /** * _xmlSchemaBase64Decode: * @ch: a character * * Converts a base64 encoded character to its base 64 value. * * Returns 0-63 (value), 64 (pad), or -1 (not recognized) */ static int _xmlSchemaBase64Decode (const xmlChar ch) { if (('A' <= ch) && (ch <= 'Z')) return ch - 'A'; if (('a' <= ch) && (ch <= 'z')) return ch - 'a' + 26; if (('0' <= ch) && (ch <= '9')) return ch - '0' + 52; if ('+' == ch) return 62; if ('/' == ch) return 63; if ('=' == ch) return 64; return -1; } /**************************************************************** * * * XML Schema Dates/Times Datatypes Handling * * * ****************************************************************/ /** * PARSE_DIGITS: * @num: the integer to fill in * @cur: an #xmlChar * * @num_type: an integer flag * * Parses a digits integer and updates @num with the value. @cur is * updated to point just after the integer. * In case of error, @num_type is set to -1, values of @num and * @cur are undefined. */ #define PARSE_DIGITS(num, cur, num_type) \ if ((*cur < '0') || (*cur > '9')) \ num_type = -1; \ else \ while ((*cur >= '0') && (*cur <= '9')) { \ num = num * 10 + (*cur - '0'); \ cur++; \ } /** * PARSE_NUM: * @num: the double to fill in * @cur: an #xmlChar * * @num_type: an integer flag * * Parses a float or integer and updates @num with the value. @cur is * updated to point just after the number. If the number is a float, * then it must have an integer part and a decimal part; @num_type will * be set to 1. If there is no decimal part, @num_type is set to zero. * In case of error, @num_type is set to -1, values of @num and * @cur are undefined. */ #define PARSE_NUM(num, cur, num_type) \ num = 0; \ PARSE_DIGITS(num, cur, num_type); \ if (!num_type && (*cur == '.')) { \ double mult = 1; \ cur++; \ if ((*cur < '0') || (*cur > '9')) \ num_type = -1; \ else \ num_type = 1; \ while ((*cur >= '0') && (*cur <= '9')) { \ mult /= 10; \ num += (*cur - '0') * mult; \ cur++; \ } \ } /** * xmlSchemaValidateDates: * @type: the expected type or XML_SCHEMAS_UNKNOWN * @dateTime: string to analyze * @val: the return computed value * * Check that @dateTime conforms to the lexical space of one of the date types. * if true a value is computed and returned in @val. * * Returns 0 if this validates, a positive error code number otherwise * and -1 in case of internal or API error. */ static int xmlSchemaValidateDates (xmlSchemaValType type, const xmlChar *dateTime, xmlSchemaValPtr *val, int collapse) { xmlSchemaValPtr dt; int ret; const xmlChar *cur = dateTime; #define RETURN_TYPE_IF_VALID(t) \ if (IS_TZO_CHAR(*cur)) { \ ret = _xmlSchemaParseTimeZone(&(dt->value.date), &cur); \ if (ret == 0) { \ if (*cur != 0) \ goto error; \ dt->type = t; \ goto done; \ } \ } if (dateTime == NULL) return -1; if (collapse) while IS_WSP_BLANK_CH(*cur) cur++; if ((*cur != '-') && (*cur < '0') && (*cur > '9')) return 1; dt = xmlSchemaNewValue(XML_SCHEMAS_UNKNOWN); if (dt == NULL) return -1; if ((cur[0] == '-') && (cur[1] == '-')) { /* * It's an incomplete date (xs:gMonthDay, xs:gMonth or * xs:gDay) */ cur += 2; /* is it an xs:gDay? */ if (*cur == '-') { if (type == XML_SCHEMAS_GMONTH) goto error; ++cur; ret = _xmlSchemaParseGDay(&(dt->value.date), &cur); if (ret != 0) goto error; RETURN_TYPE_IF_VALID(XML_SCHEMAS_GDAY); goto error; } /* * it should be an xs:gMonthDay or xs:gMonth */ ret = _xmlSchemaParseGMonth(&(dt->value.date), &cur); if (ret != 0) goto error; /* * a '-' char could indicate this type is xs:gMonthDay or * a negative time zone offset. Check for xs:gMonthDay first. * Also the first three char's of a negative tzo (-MM:SS) can * appear to be a valid day; so even if the day portion * of the xs:gMonthDay verifies, we must insure it was not * a tzo. */ if (*cur == '-') { const xmlChar *rewnd = cur; cur++; ret = _xmlSchemaParseGDay(&(dt->value.date), &cur); if ((ret == 0) && ((*cur == 0) || (*cur != ':'))) { /* * we can use the VALID_MDAY macro to validate the month * and day because the leap year test will flag year zero * as a leap year (even though zero is an invalid year). * FUTURE TODO: Zero will become valid in XML Schema 1.1 * probably. */ if (VALID_MDAY((&(dt->value.date)))) { RETURN_TYPE_IF_VALID(XML_SCHEMAS_GMONTHDAY); goto error; } } /* * not xs:gMonthDay so rewind and check if just xs:gMonth * with an optional time zone. */ cur = rewnd; } RETURN_TYPE_IF_VALID(XML_SCHEMAS_GMONTH); goto error; } /* * It's a right-truncated date or an xs:time. * Try to parse an xs:time then fallback on right-truncated dates. */ if ((*cur >= '0') && (*cur <= '9')) { ret = _xmlSchemaParseTime(&(dt->value.date), &cur); if (ret == 0) { /* it's an xs:time */ RETURN_TYPE_IF_VALID(XML_SCHEMAS_TIME); } } /* fallback on date parsing */ cur = dateTime; ret = _xmlSchemaParseGYear(&(dt->value.date), &cur); if (ret != 0) goto error; /* is it an xs:gYear? */ RETURN_TYPE_IF_VALID(XML_SCHEMAS_GYEAR); if (*cur != '-') goto error; cur++; ret = _xmlSchemaParseGMonth(&(dt->value.date), &cur); if (ret != 0) goto error; /* is it an xs:gYearMonth? */ RETURN_TYPE_IF_VALID(XML_SCHEMAS_GYEARMONTH); if (*cur != '-') goto error; cur++; ret = _xmlSchemaParseGDay(&(dt->value.date), &cur); if ((ret != 0) || !VALID_DATE((&(dt->value.date)))) goto error; /* is it an xs:date? */ RETURN_TYPE_IF_VALID(XML_SCHEMAS_DATE); if (*cur != 'T') goto error; cur++; /* it should be an xs:dateTime */ ret = _xmlSchemaParseTime(&(dt->value.date), &cur); if (ret != 0) goto error; ret = _xmlSchemaParseTimeZone(&(dt->value.date), &cur); if (collapse) while IS_WSP_BLANK_CH(*cur) cur++; if ((ret != 0) || (*cur != 0) || (!(VALID_DATETIME((&(dt->value.date)))))) goto error; dt->type = XML_SCHEMAS_DATETIME; done: #if 1 if ((type != XML_SCHEMAS_UNKNOWN) && (type != dt->type)) goto error; #else /* * insure the parsed type is equal to or less significant (right * truncated) than the desired type. */ if ((type != XML_SCHEMAS_UNKNOWN) && (type != dt->type)) { /* time only matches time */ if ((type == XML_SCHEMAS_TIME) && (dt->type == XML_SCHEMAS_TIME)) goto error; if ((type == XML_SCHEMAS_DATETIME) && ((dt->type != XML_SCHEMAS_DATE) || (dt->type != XML_SCHEMAS_GYEARMONTH) || (dt->type != XML_SCHEMAS_GYEAR))) goto error; if ((type == XML_SCHEMAS_DATE) && ((dt->type != XML_SCHEMAS_GYEAR) || (dt->type != XML_SCHEMAS_GYEARMONTH))) goto error; if ((type == XML_SCHEMAS_GYEARMONTH) && (dt->type != XML_SCHEMAS_GYEAR)) goto error; if ((type == XML_SCHEMAS_GMONTHDAY) && (dt->type != XML_SCHEMAS_GMONTH)) goto error; } #endif if (val != NULL) *val = dt; else xmlSchemaFreeValue(dt); return 0; error: if (dt != NULL) xmlSchemaFreeValue(dt); return 1; } /** * xmlSchemaValidateDuration: * @type: the predefined type * @duration: string to analyze * @val: the return computed value * * Check that @duration conforms to the lexical space of the duration type. * if true a value is computed and returned in @val. * * Returns 0 if this validates, a positive error code number otherwise * and -1 in case of internal or API error. */ static int xmlSchemaValidateDuration (xmlSchemaTypePtr type ATTRIBUTE_UNUSED, const xmlChar *duration, xmlSchemaValPtr *val, int collapse) { const xmlChar *cur = duration; xmlSchemaValPtr dur; int isneg = 0; unsigned int seq = 0; double num; int num_type = 0; /* -1 = invalid, 0 = int, 1 = floating */ const xmlChar desig[] = {'Y', 'M', 'D', 'H', 'M', 'S'}; const double multi[] = { 0.0, 0.0, 86400.0, 3600.0, 60.0, 1.0, 0.0}; if (duration == NULL) return -1; if (collapse) while IS_WSP_BLANK_CH(*cur) cur++; if (*cur == '-') { isneg = 1; cur++; } /* duration must start with 'P' (after sign) */ if (*cur++ != 'P') return 1; if (*cur == 0) return 1; dur = xmlSchemaNewValue(XML_SCHEMAS_DURATION); if (dur == NULL) return -1; while (*cur != 0) { /* input string should be empty or invalid date/time item */ if (seq >= sizeof(desig)) goto error; /* T designator must be present for time items */ if (*cur == 'T') { if (seq <= 3) { seq = 3; cur++; } else return 1; } else if (seq == 3) goto error; /* parse the number portion of the item */ PARSE_NUM(num, cur, num_type); if ((num_type == -1) || (*cur == 0)) goto error; /* update duration based on item type */ while (seq < sizeof(desig)) { if (*cur == desig[seq]) { /* verify numeric type; only seconds can be float */ if ((num_type != 0) && (seq < (sizeof(desig)-1))) goto error; switch (seq) { case 0: dur->value.dur.mon = (long)num * 12; break; case 1: dur->value.dur.mon += (long)num; break; default: /* convert to seconds using multiplier */ dur->value.dur.sec += num * multi[seq]; seq++; break; } break; /* exit loop */ } /* no date designators found? */ if ((++seq == 3) || (seq == 6)) goto error; } cur++; if (collapse) while IS_WSP_BLANK_CH(*cur) cur++; } if (isneg) { dur->value.dur.mon = -dur->value.dur.mon; dur->value.dur.day = -dur->value.dur.day; dur->value.dur.sec = -dur->value.dur.sec; } if (val != NULL) *val = dur; else xmlSchemaFreeValue(dur); return 0; error: if (dur != NULL) xmlSchemaFreeValue(dur); return 1; } /** * xmlSchemaStrip: * @value: a value * * Removes the leading and ending spaces of a string * * Returns the new string or NULL if no change was required. */ static xmlChar * xmlSchemaStrip(const xmlChar *value) { const xmlChar *start = value, *end, *f; if (value == NULL) return(NULL); while ((*start != 0) && (IS_BLANK_CH(*start))) start++; end = start; while (*end != 0) end++; f = end; end--; while ((end > start) && (IS_BLANK_CH(*end))) end--; end++; if ((start == value) && (f == end)) return(NULL); return(xmlStrndup(start, end - start)); } /** * xmlSchemaWhiteSpaceReplace: * @value: a value * * Replaces 0xd, 0x9 and 0xa with a space. * * Returns the new string or NULL if no change was required. */ xmlChar * xmlSchemaWhiteSpaceReplace(const xmlChar *value) { const xmlChar *cur = value; xmlChar *ret = NULL, *mcur; if (value == NULL) return(NULL); while ((*cur != 0) && (((*cur) != 0xd) && ((*cur) != 0x9) && ((*cur) != 0xa))) { cur++; } if (*cur == 0) return (NULL); ret = xmlStrdup(value); /* TODO FIXME: I guess gcc will bark at this. */ mcur = (xmlChar *) (ret + (cur - value)); do { if ( ((*mcur) == 0xd) || ((*mcur) == 0x9) || ((*mcur) == 0xa) ) *mcur = ' '; mcur++; } while (*mcur != 0); return(ret); } /** * xmlSchemaCollapseString: * @value: a value * * Removes and normalize white spaces in the string * * Returns the new string or NULL if no change was required. */ xmlChar * xmlSchemaCollapseString(const xmlChar *value) { const xmlChar *start = value, *end, *f; xmlChar *g; int col = 0; if (value == NULL) return(NULL); while ((*start != 0) && (IS_BLANK_CH(*start))) start++; end = start; while (*end != 0) { if ((*end == ' ') && (IS_BLANK_CH(end[1]))) { col = end - start; break; } else if ((*end == 0xa) || (*end == 0x9) || (*end == 0xd)) { col = end - start; break; } end++; } if (col == 0) { f = end; end--; while ((end > start) && (IS_BLANK_CH(*end))) end--; end++; if ((start == value) && (f == end)) return(NULL); return(xmlStrndup(start, end - start)); } start = xmlStrdup(start); if (start == NULL) return(NULL); g = (xmlChar *) (start + col); end = g; while (*end != 0) { if (IS_BLANK_CH(*end)) { end++; while (IS_BLANK_CH(*end)) end++; if (*end != 0) *g++ = ' '; } else *g++ = *end++; } *g = 0; return((xmlChar *) start); } /** * xmlSchemaValAtomicListNode: * @type: the predefined atomic type for a token in the list * @value: the list value to check * @ret: the return computed value * @node: the node containing the value * * Check that a value conforms to the lexical space of the predefined * list type. if true a value is computed and returned in @ret. * * Returns the number of items if this validates, a negative error code * number otherwise */ static int xmlSchemaValAtomicListNode(xmlSchemaTypePtr type, const xmlChar *value, xmlSchemaValPtr *ret, xmlNodePtr node) { xmlChar *val, *cur, *endval; int nb_values = 0; int tmp = 0; if (value == NULL) { return(-1); } val = xmlStrdup(value); if (val == NULL) { return(-1); } if (ret != NULL) { *ret = NULL; } cur = val; /* * Split the list */ while (IS_BLANK_CH(*cur)) *cur++ = 0; while (*cur != 0) { if (IS_BLANK_CH(*cur)) { *cur = 0; cur++; while (IS_BLANK_CH(*cur)) *cur++ = 0; } else { nb_values++; cur++; while ((*cur != 0) && (!IS_BLANK_CH(*cur))) cur++; } } if (nb_values == 0) { xmlFree(val); return(nb_values); } endval = cur; cur = val; while ((*cur == 0) && (cur != endval)) cur++; while (cur != endval) { tmp = xmlSchemaValPredefTypeNode(type, cur, NULL, node); if (tmp != 0) break; while (*cur != 0) cur++; while ((*cur == 0) && (cur != endval)) cur++; } /* TODO what return value ? c.f. bug #158628 if (ret != NULL) { TODO } */ xmlFree(val); if (tmp == 0) return(nb_values); return(-1); } /** * xmlSchemaParseUInt: * @str: pointer to the string R/W * @llo: pointer to the low result * @lmi: pointer to the mid result * @lhi: pointer to the high result * * Parse an unsigned long into 3 fields. * * Returns the number of significant digits in the number or * -1 if overflow of the capacity */ static int xmlSchemaParseUInt(const xmlChar **str, unsigned long *llo, unsigned long *lmi, unsigned long *lhi) { unsigned long lo = 0, mi = 0, hi = 0; const xmlChar *tmp, *cur = *str; int ret = 0, i = 0; while (*cur == '0') { /* ignore leading zeroes */ cur++; } tmp = cur; while ((*tmp != 0) && (*tmp >= '0') && (*tmp <= '9')) { i++;tmp++;ret++; } if (i > 24) { *str = tmp; return(-1); } while (i > 16) { hi = hi * 10 + (*cur++ - '0'); i--; } while (i > 8) { mi = mi * 10 + (*cur++ - '0'); i--; } while (i > 0) { lo = lo * 10 + (*cur++ - '0'); i--; } *str = cur; *llo = lo; *lmi = mi; *lhi = hi; return(ret); } /** * xmlSchemaValAtomicType: * @type: the predefined type * @value: the value to check * @val: the return computed value * @node: the node containing the value * flags: flags to control the vlidation * * Check that a value conforms to the lexical space of the atomic type. * if true a value is computed and returned in @val. * This checks the value space for list types as well (IDREFS, NMTOKENS). * * Returns 0 if this validates, a positive error code number otherwise * and -1 in case of internal or API error. */ static int xmlSchemaValAtomicType(xmlSchemaTypePtr type, const xmlChar * value, xmlSchemaValPtr * val, xmlNodePtr node, int flags, xmlSchemaWhitespaceValueType ws, int normOnTheFly, int applyNorm, int createStringValue) { xmlSchemaValPtr v; xmlChar *norm = NULL; int ret = 0; if (xmlSchemaTypesInitialized == 0) xmlSchemaInitTypes(); if (type == NULL) return (-1); /* * validating a non existant text node is similar to validating * an empty one. */ if (value == NULL) value = BAD_CAST ""; if (val != NULL) *val = NULL; if ((flags == 0) && (value != NULL)) { if ((type->builtInType != XML_SCHEMAS_STRING) && (type->builtInType != XML_SCHEMAS_ANYTYPE) && (type->builtInType != XML_SCHEMAS_ANYSIMPLETYPE)) { if (type->builtInType == XML_SCHEMAS_NORMSTRING) norm = xmlSchemaWhiteSpaceReplace(value); else norm = xmlSchemaCollapseString(value); if (norm != NULL) value = norm; } } switch (type->builtInType) { case XML_SCHEMAS_UNKNOWN: goto error; case XML_SCHEMAS_ANYTYPE: case XML_SCHEMAS_ANYSIMPLETYPE: if ((createStringValue) && (val != NULL)) { v = xmlSchemaNewValue(XML_SCHEMAS_ANYSIMPLETYPE); if (v != NULL) { v->value.str = xmlStrdup(value); *val = v; } else { goto error; } } goto return0; case XML_SCHEMAS_STRING: if (! normOnTheFly) { const xmlChar *cur = value; if (ws == XML_SCHEMA_WHITESPACE_REPLACE) { while (*cur != 0) { if ((*cur == 0xd) || (*cur == 0xa) || (*cur == 0x9)) { goto return1; } else { cur++; } } } else if (ws == XML_SCHEMA_WHITESPACE_COLLAPSE) { while (*cur != 0) { if ((*cur == 0xd) || (*cur == 0xa) || (*cur == 0x9)) { goto return1; } else if IS_WSP_SPACE_CH(*cur) { cur++; if IS_WSP_SPACE_CH(*cur) goto return1; } else { cur++; } } } } if (createStringValue && (val != NULL)) { if (applyNorm) { if (ws == XML_SCHEMA_WHITESPACE_COLLAPSE) norm = xmlSchemaCollapseString(value); else if (ws == XML_SCHEMA_WHITESPACE_REPLACE) norm = xmlSchemaWhiteSpaceReplace(value); if (norm != NULL) value = norm; } v = xmlSchemaNewValue(XML_SCHEMAS_STRING); if (v != NULL) { v->value.str = xmlStrdup(value); *val = v; } else { goto error; } } goto return0; case XML_SCHEMAS_NORMSTRING:{ if (normOnTheFly) { if (applyNorm) { if (ws == XML_SCHEMA_WHITESPACE_COLLAPSE) norm = xmlSchemaCollapseString(value); else norm = xmlSchemaWhiteSpaceReplace(value); if (norm != NULL) value = norm; } } else { const xmlChar *cur = value; while (*cur != 0) { if ((*cur == 0xd) || (*cur == 0xa) || (*cur == 0x9)) { goto return1; } else { cur++; } } } if (val != NULL) { v = xmlSchemaNewValue(XML_SCHEMAS_NORMSTRING); if (v != NULL) { v->value.str = xmlStrdup(value); *val = v; } else { goto error; } } goto return0; } case XML_SCHEMAS_DECIMAL:{ const xmlChar *cur = value; unsigned int len, neg, integ, hasLeadingZeroes; xmlChar cval[25]; xmlChar *cptr = cval; if ((cur == NULL) || (*cur == 0)) goto return1; /* * xs:decimal has a whitespace-facet value of 'collapse'. */ if (normOnTheFly) while IS_WSP_BLANK_CH(*cur) cur++; /* * First we handle an optional sign. */ neg = 0; if (*cur == '-') { neg = 1; cur++; } else if (*cur == '+') cur++; /* * Disallow: "", "-", "- " */ if (*cur == 0) goto return1; /* * Next we "pre-parse" the number, in preparation for calling * the common routine xmlSchemaParseUInt. We get rid of any * leading zeroes (because we have reserved only 25 chars), * and note the position of a decimal point. */ len = 0; integ = ~0u; hasLeadingZeroes = 0; /* * Skip leading zeroes. */ while (*cur == '0') { cur++; hasLeadingZeroes = 1; } if (*cur != 0) { do { if ((*cur >= '0') && (*cur <= '9')) { *cptr++ = *cur++; len++; } else if (*cur == '.') { cur++; integ = len; do { if ((*cur >= '0') && (*cur <= '9')) { *cptr++ = *cur++; len++; } else break; } while (len < 24); /* * Disallow "." but allow "00." */ if ((len == 0) && (!hasLeadingZeroes)) goto return1; break; } else break; } while (len < 24); } if (normOnTheFly) while IS_WSP_BLANK_CH(*cur) cur++; if (*cur != 0) goto return1; /* error if any extraneous chars */ if (val != NULL) { v = xmlSchemaNewValue(XML_SCHEMAS_DECIMAL); if (v != NULL) { /* * Now evaluate the significant digits of the number */ if (len != 0) { if (integ != ~0u) { /* * Get rid of trailing zeroes in the * fractional part. */ while ((len != integ) && (*(cptr-1) == '0')) { cptr--; len--; } } /* * Terminate the (preparsed) string. */ if (len != 0) { *cptr = 0; cptr = cval; xmlSchemaParseUInt((const xmlChar **)&cptr, &v->value.decimal.lo, &v->value.decimal.mi, &v->value.decimal.hi); } } /* * Set the total digits to 1 if a zero value. */ v->value.decimal.sign = neg; if (len == 0) { /* Speedup for zero values. */ v->value.decimal.total = 1; } else { v->value.decimal.total = len; if (integ == ~0u) v->value.decimal.frac = 0; else v->value.decimal.frac = len - integ; } *val = v; } } goto return0; } case XML_SCHEMAS_TIME: case XML_SCHEMAS_GDAY: case XML_SCHEMAS_GMONTH: case XML_SCHEMAS_GMONTHDAY: case XML_SCHEMAS_GYEAR: case XML_SCHEMAS_GYEARMONTH: case XML_SCHEMAS_DATE: case XML_SCHEMAS_DATETIME: ret = xmlSchemaValidateDates(type->builtInType, value, val, normOnTheFly); break; case XML_SCHEMAS_DURATION: ret = xmlSchemaValidateDuration(type, value, val, normOnTheFly); break; case XML_SCHEMAS_FLOAT: case XML_SCHEMAS_DOUBLE:{ const xmlChar *cur = value; int neg = 0; if (normOnTheFly) while IS_WSP_BLANK_CH(*cur) cur++; if ((cur[0] == 'N') && (cur[1] == 'a') && (cur[2] == 'N')) { cur += 3; if (*cur != 0) goto return1; if (val != NULL) { if (type == xmlSchemaTypeFloatDef) { v = xmlSchemaNewValue(XML_SCHEMAS_FLOAT); if (v != NULL) { v->value.f = (float) xmlXPathNAN; } else { xmlSchemaFreeValue(v); goto error; } } else { v = xmlSchemaNewValue(XML_SCHEMAS_DOUBLE); if (v != NULL) { v->value.d = xmlXPathNAN; } else { xmlSchemaFreeValue(v); goto error; } } *val = v; } goto return0; } if (*cur == '-') { neg = 1; cur++; } if ((cur[0] == 'I') && (cur[1] == 'N') && (cur[2] == 'F')) { cur += 3; if (*cur != 0) goto return1; if (val != NULL) { if (type == xmlSchemaTypeFloatDef) { v = xmlSchemaNewValue(XML_SCHEMAS_FLOAT); if (v != NULL) { if (neg) v->value.f = (float) xmlXPathNINF; else v->value.f = (float) xmlXPathPINF; } else { xmlSchemaFreeValue(v); goto error; } } else { v = xmlSchemaNewValue(XML_SCHEMAS_DOUBLE); if (v != NULL) { if (neg) v->value.d = xmlXPathNINF; else v->value.d = xmlXPathPINF; } else { xmlSchemaFreeValue(v); goto error; } } *val = v; } goto return0; } if ((neg == 0) && (*cur == '+')) cur++; if ((cur[0] == 0) || (cur[0] == '+') || (cur[0] == '-')) goto return1; while ((*cur >= '0') && (*cur <= '9')) { cur++; } if (*cur == '.') { cur++; while ((*cur >= '0') && (*cur <= '9')) cur++; } if ((*cur == 'e') || (*cur == 'E')) { cur++; if ((*cur == '-') || (*cur == '+')) cur++; while ((*cur >= '0') && (*cur <= '9')) cur++; } if (normOnTheFly) while IS_WSP_BLANK_CH(*cur) cur++; if (*cur != 0) goto return1; if (val != NULL) { if (type == xmlSchemaTypeFloatDef) { v = xmlSchemaNewValue(XML_SCHEMAS_FLOAT); if (v != NULL) { /* * TODO: sscanf seems not to give the correct * value for extremely high/low values. * E.g. "1E-149" results in zero. */ if (sscanf((const char *) value, "%f", &(v->value.f)) == 1) { *val = v; } else { xmlSchemaFreeValue(v); goto return1; } } else { goto error; } } else { v = xmlSchemaNewValue(XML_SCHEMAS_DOUBLE); if (v != NULL) { /* * TODO: sscanf seems not to give the correct * value for extremely high/low values. */ if (sscanf((const char *) value, "%lf", &(v->value.d)) == 1) { *val = v; } else { xmlSchemaFreeValue(v); goto return1; } } else { goto error; } } } goto return0; } case XML_SCHEMAS_BOOLEAN:{ const xmlChar *cur = value; if (normOnTheFly) { while IS_WSP_BLANK_CH(*cur) cur++; if (*cur == '0') { ret = 0; cur++; } else if (*cur == '1') { ret = 1; cur++; } else if (*cur == 't') { cur++; if ((*cur++ == 'r') && (*cur++ == 'u') && (*cur++ == 'e')) { ret = 1; } else goto return1; } else if (*cur == 'f') { cur++; if ((*cur++ == 'a') && (*cur++ == 'l') && (*cur++ == 's') && (*cur++ == 'e')) { ret = 0; } else goto return1; } else goto return1; if (*cur != 0) { while IS_WSP_BLANK_CH(*cur) cur++; if (*cur != 0) goto return1; } } else { if ((cur[0] == '0') && (cur[1] == 0)) ret = 0; else if ((cur[0] == '1') && (cur[1] == 0)) ret = 1; else if ((cur[0] == 't') && (cur[1] == 'r') && (cur[2] == 'u') && (cur[3] == 'e') && (cur[4] == 0)) ret = 1; else if ((cur[0] == 'f') && (cur[1] == 'a') && (cur[2] == 'l') && (cur[3] == 's') && (cur[4] == 'e') && (cur[5] == 0)) ret = 0; else goto return1; } if (val != NULL) { v = xmlSchemaNewValue(XML_SCHEMAS_BOOLEAN); if (v != NULL) { v->value.b = ret; *val = v; } else { goto error; } } goto return0; } case XML_SCHEMAS_TOKEN:{ const xmlChar *cur = value; if (! normOnTheFly) { while (*cur != 0) { if ((*cur == 0xd) || (*cur == 0xa) || (*cur == 0x9)) { goto return1; } else if (*cur == ' ') { cur++; if (*cur == 0) goto return1; if (*cur == ' ') goto return1; } else { cur++; } } } if (val != NULL) { v = xmlSchemaNewValue(XML_SCHEMAS_TOKEN); if (v != NULL) { v->value.str = xmlStrdup(value); *val = v; } else { goto error; } } goto return0; } case XML_SCHEMAS_LANGUAGE: if (normOnTheFly) { norm = xmlSchemaCollapseString(value); if (norm != NULL) value = norm; } if (xmlCheckLanguageID(value) == 1) { if (val != NULL) { v = xmlSchemaNewValue(XML_SCHEMAS_LANGUAGE); if (v != NULL) { v->value.str = xmlStrdup(value); *val = v; } else { goto error; } } goto return0; } goto return1; case XML_SCHEMAS_NMTOKEN: if (xmlValidateNMToken(value, 1) == 0) { if (val != NULL) { v = xmlSchemaNewValue(XML_SCHEMAS_NMTOKEN); if (v != NULL) { v->value.str = xmlStrdup(value); *val = v; } else { goto error; } } goto return0; } goto return1; case XML_SCHEMAS_NMTOKENS: ret = xmlSchemaValAtomicListNode(xmlSchemaTypeNmtokenDef, value, val, node); if (ret > 0) ret = 0; else ret = 1; goto done; case XML_SCHEMAS_NAME: ret = xmlValidateName(value, 1); if ((ret == 0) && (val != NULL) && (value != NULL)) { v = xmlSchemaNewValue(XML_SCHEMAS_NAME); if (v != NULL) { const xmlChar *start = value, *end; while (IS_BLANK_CH(*start)) start++; end = start; while ((*end != 0) && (!IS_BLANK_CH(*end))) end++; v->value.str = xmlStrndup(start, end - start); *val = v; } else { goto error; } } goto done; case XML_SCHEMAS_QNAME:{ const xmlChar *uri = NULL; xmlChar *local = NULL; ret = xmlValidateQName(value, 1); if (ret != 0) goto done; if (node != NULL) { xmlChar *prefix; xmlNsPtr ns; local = xmlSplitQName2(value, &prefix); ns = xmlSearchNs(node->doc, node, prefix); if ((ns == NULL) && (prefix != NULL)) { xmlFree(prefix); if (local != NULL) xmlFree(local); goto return1; } if (ns != NULL) uri = ns->href; if (prefix != NULL) xmlFree(prefix); } if (val != NULL) { v = xmlSchemaNewValue(XML_SCHEMAS_QNAME); if (v == NULL) { if (local != NULL) xmlFree(local); goto error; } if (local != NULL) v->value.qname.name = local; else v->value.qname.name = xmlStrdup(value); if (uri != NULL) v->value.qname.uri = xmlStrdup(uri); *val = v; } else if (local != NULL) xmlFree(local); goto done; } case XML_SCHEMAS_NCNAME: ret = xmlValidateNCName(value, 1); if ((ret == 0) && (val != NULL)) { v = xmlSchemaNewValue(XML_SCHEMAS_NCNAME); if (v != NULL) { v->value.str = xmlStrdup(value); *val = v; } else { goto error; } } goto done; case XML_SCHEMAS_ID: ret = xmlValidateNCName(value, 1); if ((ret == 0) && (val != NULL)) { v = xmlSchemaNewValue(XML_SCHEMAS_ID); if (v != NULL) { v->value.str = xmlStrdup(value); *val = v; } else { goto error; } } if ((ret == 0) && (node != NULL) && (node->type == XML_ATTRIBUTE_NODE)) { xmlAttrPtr attr = (xmlAttrPtr) node; /* * NOTE: the IDness might have already be declared in the DTD */ if (attr->atype != XML_ATTRIBUTE_ID) { xmlIDPtr res; xmlChar *strip; strip = xmlSchemaStrip(value); if (strip != NULL) { res = xmlAddID(NULL, node->doc, strip, attr); xmlFree(strip); } else res = xmlAddID(NULL, node->doc, value, attr); if (res == NULL) { ret = 2; } else { attr->atype = XML_ATTRIBUTE_ID; } } } goto done; case XML_SCHEMAS_IDREF: ret = xmlValidateNCName(value, 1); if ((ret == 0) && (val != NULL)) { v = xmlSchemaNewValue(XML_SCHEMAS_IDREF); if (v == NULL) goto error; v->value.str = xmlStrdup(value); *val = v; } if ((ret == 0) && (node != NULL) && (node->type == XML_ATTRIBUTE_NODE)) { xmlAttrPtr attr = (xmlAttrPtr) node; xmlChar *strip; strip = xmlSchemaStrip(value); if (strip != NULL) { xmlAddRef(NULL, node->doc, strip, attr); xmlFree(strip); } else xmlAddRef(NULL, node->doc, value, attr); attr->atype = XML_ATTRIBUTE_IDREF; } goto done; case XML_SCHEMAS_IDREFS: ret = xmlSchemaValAtomicListNode(xmlSchemaTypeIdrefDef, value, val, node); if (ret < 0) ret = 2; else ret = 0; if ((ret == 0) && (node != NULL) && (node->type == XML_ATTRIBUTE_NODE)) { xmlAttrPtr attr = (xmlAttrPtr) node; attr->atype = XML_ATTRIBUTE_IDREFS; } goto done; case XML_SCHEMAS_ENTITY:{ xmlChar *strip; ret = xmlValidateNCName(value, 1); if ((node == NULL) || (node->doc == NULL)) ret = 3; if (ret == 0) { xmlEntityPtr ent; strip = xmlSchemaStrip(value); if (strip != NULL) { ent = xmlGetDocEntity(node->doc, strip); xmlFree(strip); } else { ent = xmlGetDocEntity(node->doc, value); } if ((ent == NULL) || (ent->etype != XML_EXTERNAL_GENERAL_UNPARSED_ENTITY)) ret = 4; } if ((ret == 0) && (val != NULL)) { TODO; } if ((ret == 0) && (node != NULL) && (node->type == XML_ATTRIBUTE_NODE)) { xmlAttrPtr attr = (xmlAttrPtr) node; attr->atype = XML_ATTRIBUTE_ENTITY; } goto done; } case XML_SCHEMAS_ENTITIES: if ((node == NULL) || (node->doc == NULL)) goto return3; ret = xmlSchemaValAtomicListNode(xmlSchemaTypeEntityDef, value, val, node); if (ret <= 0) ret = 1; else ret = 0; if ((ret == 0) && (node != NULL) && (node->type == XML_ATTRIBUTE_NODE)) { xmlAttrPtr attr = (xmlAttrPtr) node; attr->atype = XML_ATTRIBUTE_ENTITIES; } goto done; case XML_SCHEMAS_NOTATION:{ xmlChar *uri = NULL; xmlChar *local = NULL; ret = xmlValidateQName(value, 1); if ((ret == 0) && (node != NULL)) { xmlChar *prefix; local = xmlSplitQName2(value, &prefix); if (prefix != NULL) { xmlNsPtr ns; ns = xmlSearchNs(node->doc, node, prefix); if (ns == NULL) ret = 1; else if (val != NULL) uri = xmlStrdup(ns->href); } if ((local != NULL) && ((val == NULL) || (ret != 0))) xmlFree(local); if (prefix != NULL) xmlFree(prefix); } if ((node == NULL) || (node->doc == NULL)) ret = 3; if (ret == 0) { ret = xmlValidateNotationUse(NULL, node->doc, value); if (ret == 1) ret = 0; else ret = 1; } if ((ret == 0) && (val != NULL)) { v = xmlSchemaNewValue(XML_SCHEMAS_NOTATION); if (v != NULL) { if (local != NULL) v->value.qname.name = local; else v->value.qname.name = xmlStrdup(value); if (uri != NULL) v->value.qname.uri = uri; *val = v; } else { if (local != NULL) xmlFree(local); if (uri != NULL) xmlFree(uri); goto error; } } goto done; } case XML_SCHEMAS_ANYURI:{ if (*value != 0) { xmlURIPtr uri; if (normOnTheFly) { norm = xmlSchemaCollapseString(value); if (norm != NULL) value = norm; } uri = xmlParseURI((const char *) value); if (uri == NULL) goto return1; xmlFreeURI(uri); } if (val != NULL) { v = xmlSchemaNewValue(XML_SCHEMAS_ANYURI); if (v == NULL) goto error; v->value.str = xmlStrdup(value); *val = v; } goto return0; } case XML_SCHEMAS_HEXBINARY:{ const xmlChar *cur = value, *start; xmlChar *base; int total, i = 0; if (cur == NULL) goto return1; if (normOnTheFly) while IS_WSP_BLANK_CH(*cur) cur++; start = cur; while (((*cur >= '0') && (*cur <= '9')) || ((*cur >= 'A') && (*cur <= 'F')) || ((*cur >= 'a') && (*cur <= 'f'))) { i++; cur++; } if (normOnTheFly) while IS_WSP_BLANK_CH(*cur) cur++; if (*cur != 0) goto return1; if ((i % 2) != 0) goto return1; if (val != NULL) { v = xmlSchemaNewValue(XML_SCHEMAS_HEXBINARY); if (v == NULL) goto error; /* * Copy only the normalized piece. * CRITICAL TODO: Check this. */ cur = xmlStrndup(start, i); if (cur == NULL) { xmlSchemaTypeErrMemory(node, "allocating hexbin data"); xmlFree(v); goto return1; } total = i / 2; /* number of octets */ base = (xmlChar *) cur; while (i-- > 0) { if (*base >= 'a') *base = *base - ('a' - 'A'); base++; } v->value.hex.str = (xmlChar *) cur; v->value.hex.total = total; *val = v; } goto return0; } case XML_SCHEMAS_BASE64BINARY:{ /* ISSUE: * * Ignore all stray characters? (yes, currently) * Worry about long lines? (no, currently) * * rfc2045.txt: * * "The encoded output stream must be represented in lines of * no more than 76 characters each. All line breaks or other * characters not found in Table 1 must be ignored by decoding * software. In base64 data, characters other than those in * Table 1, line breaks, and other white space probably * indicate a transmission error, about which a warning * message or even a message rejection might be appropriate * under some circumstances." */ const xmlChar *cur = value; xmlChar *base; int total, i = 0, pad = 0; if (cur == NULL) goto return1; for (; *cur; ++cur) { int decc; decc = _xmlSchemaBase64Decode(*cur); if (decc < 0) ; else if (decc < 64) i++; else break; } for (; *cur; ++cur) { int decc; decc = _xmlSchemaBase64Decode(*cur); if (decc < 0) ; else if (decc < 64) goto return1; if (decc == 64) pad++; } /* rfc2045.txt: "Special processing is performed if fewer than * 24 bits are available at the end of the data being encoded. * A full encoding quantum is always completed at the end of a * body. When fewer than 24 input bits are available in an * input group, zero bits are added (on the right) to form an * integral number of 6-bit groups. Padding at the end of the * data is performed using the "=" character. Since all * base64 input is an integral number of octets, only the * following cases can arise: (1) the final quantum of * encoding input is an integral multiple of 24 bits; here, * the final unit of encoded output will be an integral * multiple ofindent: Standard input:701: Warning:old style * assignment ambiguity in "=*". Assuming "= *" 4 characters * with no "=" padding, (2) the final * quantum of encoding input is exactly 8 bits; here, the * final unit of encoded output will be two characters * followed by two "=" padding characters, or (3) the final * quantum of encoding input is exactly 16 bits; here, the * final unit of encoded output will be three characters * followed by one "=" padding character." */ total = 3 * (i / 4); if (pad == 0) { if (i % 4 != 0) goto return1; } else if (pad == 1) { int decc; if (i % 4 != 3) goto return1; for (decc = _xmlSchemaBase64Decode(*cur); (decc < 0) || (decc > 63); decc = _xmlSchemaBase64Decode(*cur)) --cur; /* 16bits in 24bits means 2 pad bits: nnnnnn nnmmmm mmmm00*/ /* 00111100 -> 0x3c */ if (decc & ~0x3c) goto return1; total += 2; } else if (pad == 2) { int decc; if (i % 4 != 2) goto return1; for (decc = _xmlSchemaBase64Decode(*cur); (decc < 0) || (decc > 63); decc = _xmlSchemaBase64Decode(*cur)) --cur; /* 8bits in 12bits means 4 pad bits: nnnnnn nn0000 */ /* 00110000 -> 0x30 */ if (decc & ~0x30) goto return1; total += 1; } else goto return1; if (val != NULL) { v = xmlSchemaNewValue(XML_SCHEMAS_BASE64BINARY); if (v == NULL) goto error; base = (xmlChar *) xmlMallocAtomic((i + pad + 1) * sizeof(xmlChar)); if (base == NULL) { xmlSchemaTypeErrMemory(node, "allocating base64 data"); xmlFree(v); goto return1; } v->value.base64.str = base; for (cur = value; *cur; ++cur) if (_xmlSchemaBase64Decode(*cur) >= 0) { *base = *cur; ++base; } *base = 0; v->value.base64.total = total; *val = v; } goto return0; } case XML_SCHEMAS_INTEGER: case XML_SCHEMAS_PINTEGER: case XML_SCHEMAS_NPINTEGER: case XML_SCHEMAS_NINTEGER: case XML_SCHEMAS_NNINTEGER:{ const xmlChar *cur = value; unsigned long lo, mi, hi; int sign = 0; if (cur == NULL) goto return1; if (normOnTheFly) while IS_WSP_BLANK_CH(*cur) cur++; if (*cur == '-') { sign = 1; cur++; } else if (*cur == '+') cur++; ret = xmlSchemaParseUInt(&cur, &lo, &mi, &hi); if (ret == -1) goto return1; if (normOnTheFly) while IS_WSP_BLANK_CH(*cur) cur++; if (*cur != 0) goto return1; if (type->builtInType == XML_SCHEMAS_NPINTEGER) { if ((sign == 0) && ((hi != 0) || (mi != 0) || (lo != 0))) goto return1; } else if (type->builtInType == XML_SCHEMAS_PINTEGER) { if (sign == 1) goto return1; if ((hi == 0) && (mi == 0) && (lo == 0)) goto return1; } else if (type->builtInType == XML_SCHEMAS_NINTEGER) { if (sign == 0) goto return1; if ((hi == 0) && (mi == 0) && (lo == 0)) goto return1; } else if (type->builtInType == XML_SCHEMAS_NNINTEGER) { if ((sign == 1) && ((hi != 0) || (mi != 0) || (lo != 0))) goto return1; } if (val != NULL) { v = xmlSchemaNewValue(type->builtInType); if (v != NULL) { if (ret == 0) ret++; v->value.decimal.lo = lo; v->value.decimal.mi = mi; v->value.decimal.hi = hi; v->value.decimal.sign = sign; v->value.decimal.frac = 0; v->value.decimal.total = ret; *val = v; } } goto return0; } case XML_SCHEMAS_LONG: case XML_SCHEMAS_BYTE: case XML_SCHEMAS_SHORT: case XML_SCHEMAS_INT:{ const xmlChar *cur = value; unsigned long lo, mi, hi; int sign = 0; if (cur == NULL) goto return1; if (*cur == '-') { sign = 1; cur++; } else if (*cur == '+') cur++; ret = xmlSchemaParseUInt(&cur, &lo, &mi, &hi); if (ret < 0) goto return1; if (*cur != 0) goto return1; if (type->builtInType == XML_SCHEMAS_LONG) { if (hi >= 922) { if (hi > 922) goto return1; if (mi >= 33720368) { if (mi > 33720368) goto return1; if ((sign == 0) && (lo > 54775807)) goto return1; if ((sign == 1) && (lo > 54775808)) goto return1; } } } else if (type->builtInType == XML_SCHEMAS_INT) { if (hi != 0) goto return1; if (mi >= 21) { if (mi > 21) goto return1; if ((sign == 0) && (lo > 47483647)) goto return1; if ((sign == 1) && (lo > 47483648)) goto return1; } } else if (type->builtInType == XML_SCHEMAS_SHORT) { if ((mi != 0) || (hi != 0)) goto return1; if ((sign == 1) && (lo > 32768)) goto return1; if ((sign == 0) && (lo > 32767)) goto return1; } else if (type->builtInType == XML_SCHEMAS_BYTE) { if ((mi != 0) || (hi != 0)) goto return1; if ((sign == 1) && (lo > 128)) goto return1; if ((sign == 0) && (lo > 127)) goto return1; } if (val != NULL) { v = xmlSchemaNewValue(type->builtInType); if (v != NULL) { v->value.decimal.lo = lo; v->value.decimal.mi = mi; v->value.decimal.hi = hi; v->value.decimal.sign = sign; v->value.decimal.frac = 0; v->value.decimal.total = ret; *val = v; } } goto return0; } case XML_SCHEMAS_UINT: case XML_SCHEMAS_ULONG: case XML_SCHEMAS_USHORT: case XML_SCHEMAS_UBYTE:{ const xmlChar *cur = value; unsigned long lo, mi, hi; if (cur == NULL) goto return1; ret = xmlSchemaParseUInt(&cur, &lo, &mi, &hi); if (ret < 0) goto return1; if (*cur != 0) goto return1; if (type->builtInType == XML_SCHEMAS_ULONG) { if (hi >= 1844) { if (hi > 1844) goto return1; if (mi >= 67440737) { if (mi > 67440737) goto return1; if (lo > 9551615) goto return1; } } } else if (type->builtInType == XML_SCHEMAS_UINT) { if (hi != 0) goto return1; if (mi >= 42) { if (mi > 42) goto return1; if (lo > 94967295) goto return1; } } else if (type->builtInType == XML_SCHEMAS_USHORT) { if ((mi != 0) || (hi != 0)) goto return1; if (lo > 65535) goto return1; } else if (type->builtInType == XML_SCHEMAS_UBYTE) { if ((mi != 0) || (hi != 0)) goto return1; if (lo > 255) goto return1; } if (val != NULL) { v = xmlSchemaNewValue(type->builtInType); if (v != NULL) { v->value.decimal.lo = lo; v->value.decimal.mi = mi; v->value.decimal.hi = hi; v->value.decimal.sign = 0; v->value.decimal.frac = 0; v->value.decimal.total = ret; *val = v; } } goto return0; } } done: if (norm != NULL) xmlFree(norm); return (ret); return3: if (norm != NULL) xmlFree(norm); return (3); return1: if (norm != NULL) xmlFree(norm); return (1); return0: if (norm != NULL) xmlFree(norm); return (0); error: if (norm != NULL) xmlFree(norm); return (-1); } /** * xmlSchemaValPredefTypeNode: * @type: the predefined type * @value: the value to check * @val: the return computed value * @node: the node containing the value * * Check that a value conforms to the lexical space of the predefined type. * if true a value is computed and returned in @val. * * Returns 0 if this validates, a positive error code number otherwise * and -1 in case of internal or API error. */ int xmlSchemaValPredefTypeNode(xmlSchemaTypePtr type, const xmlChar *value, xmlSchemaValPtr *val, xmlNodePtr node) { return(xmlSchemaValAtomicType(type, value, val, node, 0, XML_SCHEMA_WHITESPACE_UNKNOWN, 1, 1, 0)); } /** * xmlSchemaValPredefTypeNodeNoNorm: * @type: the predefined type * @value: the value to check * @val: the return computed value * @node: the node containing the value * * Check that a value conforms to the lexical space of the predefined type. * if true a value is computed and returned in @val. * This one does apply any normalization to the value. * * Returns 0 if this validates, a positive error code number otherwise * and -1 in case of internal or API error. */ int xmlSchemaValPredefTypeNodeNoNorm(xmlSchemaTypePtr type, const xmlChar *value, xmlSchemaValPtr *val, xmlNodePtr node) { return(xmlSchemaValAtomicType(type, value, val, node, 1, XML_SCHEMA_WHITESPACE_UNKNOWN, 1, 0, 1)); } /** * xmlSchemaValidatePredefinedType: * @type: the predefined type * @value: the value to check * @val: the return computed value * * Check that a value conforms to the lexical space of the predefined type. * if true a value is computed and returned in @val. * * Returns 0 if this validates, a positive error code number otherwise * and -1 in case of internal or API error. */ int xmlSchemaValidatePredefinedType(xmlSchemaTypePtr type, const xmlChar *value, xmlSchemaValPtr *val) { return(xmlSchemaValPredefTypeNode(type, value, val, NULL)); } /** * xmlSchemaCompareDecimals: * @x: a first decimal value * @y: a second decimal value * * Compare 2 decimals * * Returns -1 if x < y, 0 if x == y, 1 if x > y and -2 in case of error */ static int xmlSchemaCompareDecimals(xmlSchemaValPtr x, xmlSchemaValPtr y) { xmlSchemaValPtr swp; int order = 1, integx, integy, dlen; unsigned long hi, mi, lo; /* * First test: If x is -ve and not zero */ if ((x->value.decimal.sign) && ((x->value.decimal.lo != 0) || (x->value.decimal.mi != 0) || (x->value.decimal.hi != 0))) { /* * Then if y is -ve and not zero reverse the compare */ if ((y->value.decimal.sign) && ((y->value.decimal.lo != 0) || (y->value.decimal.mi != 0) || (y->value.decimal.hi != 0))) order = -1; /* * Otherwise (y >= 0) we have the answer */ else return (-1); /* * If x is not -ve and y is -ve we have the answer */ } else if ((y->value.decimal.sign) && ((y->value.decimal.lo != 0) || (y->value.decimal.mi != 0) || (y->value.decimal.hi != 0))) { return (1); } /* * If it's not simply determined by a difference in sign, * then we need to compare the actual values of the two nums. * To do this, we start by looking at the integral parts. * If the number of integral digits differ, then we have our * answer. */ integx = x->value.decimal.total - x->value.decimal.frac; integy = y->value.decimal.total - y->value.decimal.frac; /* * NOTE: We changed the "total" for values like "0.1" * (or "-0.1" or ".1") to be 1, which was 2 previously. * Therefore the special case, when such values are * compared with 0, needs to be handled separately; * otherwise a zero would be recognized incorrectly as * greater than those values. This has the nice side effect * that we gain an overall optimized comparison with zeroes. * Note that a "0" has a "total" of 1 already. */ if (integx == 1) { if (x->value.decimal.lo == 0) { if (integy != 1) return -order; else if (y->value.decimal.lo != 0) return -order; else return(0); } } if (integy == 1) { if (y->value.decimal.lo == 0) { if (integx != 1) return order; else if (x->value.decimal.lo != 0) return order; else return(0); } } if (integx > integy) return order; else if (integy > integx) return -order; /* * If the number of integral digits is the same for both numbers, * then things get a little more complicated. We need to "normalize" * the numbers in order to properly compare them. To do this, we * look at the total length of each number (length => number of * significant digits), and divide the "shorter" by 10 (decreasing * the length) until they are of equal length. */ dlen = x->value.decimal.total - y->value.decimal.total; if (dlen < 0) { /* y has more digits than x */ swp = x; hi = y->value.decimal.hi; mi = y->value.decimal.mi; lo = y->value.decimal.lo; dlen = -dlen; order = -order; } else { /* x has more digits than y */ swp = y; hi = x->value.decimal.hi; mi = x->value.decimal.mi; lo = x->value.decimal.lo; } while (dlen > 8) { /* in effect, right shift by 10**8 */ lo = mi; mi = hi; hi = 0; dlen -= 8; } while (dlen > 0) { unsigned long rem1, rem2; rem1 = (hi % 10) * 100000000L; hi = hi / 10; rem2 = (mi % 10) * 100000000L; mi = (mi + rem1) / 10; lo = (lo + rem2) / 10; dlen--; } if (hi > swp->value.decimal.hi) { return order; } else if (hi == swp->value.decimal.hi) { if (mi > swp->value.decimal.mi) { return order; } else if (mi == swp->value.decimal.mi) { if (lo > swp->value.decimal.lo) { return order; } else if (lo == swp->value.decimal.lo) { if (x->value.decimal.total == y->value.decimal.total) { return 0; } else { return order; } } } } return -order; } /** * xmlSchemaCompareDurations: * @x: a first duration value * @y: a second duration value * * Compare 2 durations * * Returns -1 if x < y, 0 if x == y, 1 if x > y, 2 if x <> y, and -2 in * case of error */ static int xmlSchemaCompareDurations(xmlSchemaValPtr x, xmlSchemaValPtr y) { long carry, mon, day; double sec; int invert = 1; long xmon, xday, myear, minday, maxday; static const long dayRange [2][12] = { { 0, 28, 59, 89, 120, 150, 181, 212, 242, 273, 303, 334, }, { 0, 31, 62, 92, 123, 153, 184, 215, 245, 276, 306, 337} }; if ((x == NULL) || (y == NULL)) return -2; /* months */ mon = x->value.dur.mon - y->value.dur.mon; /* seconds */ sec = x->value.dur.sec - y->value.dur.sec; carry = (long)sec / SECS_PER_DAY; sec -= (double)(carry * SECS_PER_DAY); /* days */ day = x->value.dur.day - y->value.dur.day + carry; /* easy test */ if (mon == 0) { if (day == 0) if (sec == 0.0) return 0; else if (sec < 0.0) return -1; else return 1; else if (day < 0) return -1; else return 1; } if (mon > 0) { if ((day >= 0) && (sec >= 0.0)) return 1; else { xmon = mon; xday = -day; } } else if ((day <= 0) && (sec <= 0.0)) { return -1; } else { invert = -1; xmon = -mon; xday = day; } myear = xmon / 12; if (myear == 0) { minday = 0; maxday = 0; } else { maxday = 366 * ((myear + 3) / 4) + 365 * ((myear - 1) % 4); minday = maxday - 1; } xmon = xmon % 12; minday += dayRange[0][xmon]; maxday += dayRange[1][xmon]; if ((maxday == minday) && (maxday == xday)) return(0); /* can this really happen ? */ if (maxday < xday) return(-invert); if (minday > xday) return(invert); /* indeterminate */ return 2; } /* * macros for adding date/times and durations */ #define FQUOTIENT(a,b) (floor(((double)a/(double)b))) #define MODULO(a,b) (a - FQUOTIENT(a,b) * b) #define FQUOTIENT_RANGE(a,low,high) (FQUOTIENT((a-low),(high-low))) #define MODULO_RANGE(a,low,high) ((MODULO((a-low),(high-low)))+low) /** * xmlSchemaDupVal: * @v: the #xmlSchemaValPtr value to duplicate * * Makes a copy of @v. The calling program is responsible for freeing * the returned value. * * returns a pointer to a duplicated #xmlSchemaValPtr or NULL if error. */ static xmlSchemaValPtr xmlSchemaDupVal (xmlSchemaValPtr v) { xmlSchemaValPtr ret = xmlSchemaNewValue(v->type); if (ret == NULL) return NULL; memcpy(ret, v, sizeof(xmlSchemaVal)); ret->next = NULL; return ret; } /** * xmlSchemaCopyValue: * @val: the precomputed value to be copied * * Copies the precomputed value. This duplicates any string within. * * Returns the copy or NULL if a copy for a data-type is not implemented. */ xmlSchemaValPtr xmlSchemaCopyValue(xmlSchemaValPtr val) { xmlSchemaValPtr ret = NULL, prev = NULL, cur; /* * Copy the string values. */ while (val != NULL) { switch (val->type) { case XML_SCHEMAS_ANYTYPE: case XML_SCHEMAS_IDREFS: case XML_SCHEMAS_ENTITIES: case XML_SCHEMAS_NMTOKENS: xmlSchemaFreeValue(ret); return (NULL); case XML_SCHEMAS_ANYSIMPLETYPE: case XML_SCHEMAS_STRING: case XML_SCHEMAS_NORMSTRING: case XML_SCHEMAS_TOKEN: case XML_SCHEMAS_LANGUAGE: case XML_SCHEMAS_NAME: case XML_SCHEMAS_NCNAME: case XML_SCHEMAS_ID: case XML_SCHEMAS_IDREF: case XML_SCHEMAS_ENTITY: case XML_SCHEMAS_NMTOKEN: case XML_SCHEMAS_ANYURI: cur = xmlSchemaDupVal(val); if (val->value.str != NULL) cur->value.str = xmlStrdup(BAD_CAST val->value.str); break; case XML_SCHEMAS_QNAME: case XML_SCHEMAS_NOTATION: cur = xmlSchemaDupVal(val); if (val->value.qname.name != NULL) cur->value.qname.name = xmlStrdup(BAD_CAST val->value.qname.name); if (val->value.qname.uri != NULL) cur->value.qname.uri = xmlStrdup(BAD_CAST val->value.qname.uri); break; case XML_SCHEMAS_HEXBINARY: cur = xmlSchemaDupVal(val); if (val->value.hex.str != NULL) cur->value.hex.str = xmlStrdup(BAD_CAST val->value.hex.str); break; case XML_SCHEMAS_BASE64BINARY: cur = xmlSchemaDupVal(val); if (val->value.base64.str != NULL) cur->value.base64.str = xmlStrdup(BAD_CAST val->value.base64.str); break; default: cur = xmlSchemaDupVal(val); break; } if (ret == NULL) ret = cur; else prev->next = cur; prev = cur; val = val->next; } return (ret); } /** * _xmlSchemaDateAdd: * @dt: an #xmlSchemaValPtr * @dur: an #xmlSchemaValPtr of type #XS_DURATION * * Compute a new date/time from @dt and @dur. This function assumes @dt * is either #XML_SCHEMAS_DATETIME, #XML_SCHEMAS_DATE, #XML_SCHEMAS_GYEARMONTH, * or #XML_SCHEMAS_GYEAR. The returned #xmlSchemaVal is the same type as * @dt. The calling program is responsible for freeing the returned value. * * Returns a pointer to a new #xmlSchemaVal or NULL if error. */ static xmlSchemaValPtr _xmlSchemaDateAdd (xmlSchemaValPtr dt, xmlSchemaValPtr dur) { xmlSchemaValPtr ret, tmp; long carry, tempdays, temp; xmlSchemaValDatePtr r, d; xmlSchemaValDurationPtr u; if ((dt == NULL) || (dur == NULL)) return NULL; ret = xmlSchemaNewValue(dt->type); if (ret == NULL) return NULL; /* make a copy so we don't alter the original value */ tmp = xmlSchemaDupVal(dt); if (tmp == NULL) { xmlSchemaFreeValue(ret); return NULL; } r = &(ret->value.date); d = &(tmp->value.date); u = &(dur->value.dur); /* normalization */ if (d->mon == 0) d->mon = 1; /* normalize for time zone offset */ u->sec -= (d->tzo * 60); d->tzo = 0; /* normalization */ if (d->day == 0) d->day = 1; /* month */ carry = d->mon + u->mon; r->mon = (unsigned int) MODULO_RANGE(carry, 1, 13); carry = (long) FQUOTIENT_RANGE(carry, 1, 13); /* year (may be modified later) */ r->year = d->year + carry; if (r->year == 0) { if (d->year > 0) r->year--; else r->year++; } /* time zone */ r->tzo = d->tzo; r->tz_flag = d->tz_flag; /* seconds */ r->sec = d->sec + u->sec; carry = (long) FQUOTIENT((long)r->sec, 60); if (r->sec != 0.0) { r->sec = MODULO(r->sec, 60.0); } /* minute */ carry += d->min; r->min = (unsigned int) MODULO(carry, 60); carry = (long) FQUOTIENT(carry, 60); /* hours */ carry += d->hour; r->hour = (unsigned int) MODULO(carry, 24); carry = (long)FQUOTIENT(carry, 24); /* * days * Note we use tempdays because the temporary values may need more * than 5 bits */ if ((VALID_YEAR(r->year)) && (VALID_MONTH(r->mon)) && (d->day > MAX_DAYINMONTH(r->year, r->mon))) tempdays = MAX_DAYINMONTH(r->year, r->mon); else if (d->day < 1) tempdays = 1; else tempdays = d->day; tempdays += u->day + carry; while (1) { if (tempdays < 1) { long tmon = (long) MODULO_RANGE((int)r->mon-1, 1, 13); long tyr = r->year + (long)FQUOTIENT_RANGE((int)r->mon-1, 1, 13); if (tyr == 0) tyr--; /* * Coverity detected an overrun in daysInMonth * of size 12 at position 12 with index variable "((r)->mon - 1)" */ if (tmon < 0) tmon = 0; if (tmon > 12) tmon = 12; tempdays += MAX_DAYINMONTH(tyr, tmon); carry = -1; } else if (tempdays > (long) MAX_DAYINMONTH(r->year, r->mon)) { tempdays = tempdays - MAX_DAYINMONTH(r->year, r->mon); carry = 1; } else break; temp = r->mon + carry; r->mon = (unsigned int) MODULO_RANGE(temp, 1, 13); r->year = r->year + (unsigned int) FQUOTIENT_RANGE(temp, 1, 13); if (r->year == 0) { if (temp < 1) r->year--; else r->year++; } } r->day = tempdays; /* * adjust the date/time type to the date values */ if (ret->type != XML_SCHEMAS_DATETIME) { if ((r->hour) || (r->min) || (r->sec)) ret->type = XML_SCHEMAS_DATETIME; else if (ret->type != XML_SCHEMAS_DATE) { if ((r->mon != 1) && (r->day != 1)) ret->type = XML_SCHEMAS_DATE; else if ((ret->type != XML_SCHEMAS_GYEARMONTH) && (r->mon != 1)) ret->type = XML_SCHEMAS_GYEARMONTH; } } xmlSchemaFreeValue(tmp); return ret; } /** * xmlSchemaDateNormalize: * @dt: an #xmlSchemaValPtr of a date/time type value. * @offset: number of seconds to adjust @dt by. * * Normalize @dt to GMT time. The @offset parameter is subtracted from * the return value is a time-zone offset is present on @dt. * * Returns a normalized copy of @dt or NULL if error. */ static xmlSchemaValPtr xmlSchemaDateNormalize (xmlSchemaValPtr dt, double offset) { xmlSchemaValPtr dur, ret; if (dt == NULL) return NULL; if (((dt->type != XML_SCHEMAS_TIME) && (dt->type != XML_SCHEMAS_DATETIME) && (dt->type != XML_SCHEMAS_DATE)) || (dt->value.date.tzo == 0)) return xmlSchemaDupVal(dt); dur = xmlSchemaNewValue(XML_SCHEMAS_DURATION); if (dur == NULL) return NULL; dur->value.date.sec -= offset; ret = _xmlSchemaDateAdd(dt, dur); if (ret == NULL) return NULL; xmlSchemaFreeValue(dur); /* ret->value.date.tzo = 0; */ return ret; } /** * _xmlSchemaDateCastYMToDays: * @dt: an #xmlSchemaValPtr * * Convert mon and year of @dt to total number of days. Take the * number of years since (or before) 1 AD and add the number of leap * years. This is a function because negative * years must be handled a little differently and there is no zero year. * * Returns number of days. */ static long _xmlSchemaDateCastYMToDays (const xmlSchemaValPtr dt) { long ret; int mon; mon = dt->value.date.mon; if (mon <= 0) mon = 1; /* normalization */ if (dt->value.date.year <= 0) ret = (dt->value.date.year * 365) + (((dt->value.date.year+1)/4)-((dt->value.date.year+1)/100)+ ((dt->value.date.year+1)/400)) + DAY_IN_YEAR(0, mon, dt->value.date.year); else ret = ((dt->value.date.year-1) * 365) + (((dt->value.date.year-1)/4)-((dt->value.date.year-1)/100)+ ((dt->value.date.year-1)/400)) + DAY_IN_YEAR(0, mon, dt->value.date.year); return ret; } /** * TIME_TO_NUMBER: * @dt: an #xmlSchemaValPtr * * Calculates the number of seconds in the time portion of @dt. * * Returns seconds. */ #define TIME_TO_NUMBER(dt) \ ((double)((dt->value.date.hour * SECS_PER_HOUR) + \ (dt->value.date.min * SECS_PER_MIN) + \ (dt->value.date.tzo * SECS_PER_MIN)) + \ dt->value.date.sec) /** * xmlSchemaCompareDates: * @x: a first date/time value * @y: a second date/time value * * Compare 2 date/times * * Returns -1 if x < y, 0 if x == y, 1 if x > y, 2 if x <> y, and -2 in * case of error */ static int xmlSchemaCompareDates (xmlSchemaValPtr x, xmlSchemaValPtr y) { unsigned char xmask, ymask, xor_mask, and_mask; xmlSchemaValPtr p1, p2, q1, q2; long p1d, p2d, q1d, q2d; if ((x == NULL) || (y == NULL)) return -2; if (x->value.date.tz_flag) { if (!y->value.date.tz_flag) { p1 = xmlSchemaDateNormalize(x, 0); p1d = _xmlSchemaDateCastYMToDays(p1) + p1->value.date.day; /* normalize y + 14:00 */ q1 = xmlSchemaDateNormalize(y, (14 * SECS_PER_HOUR)); q1d = _xmlSchemaDateCastYMToDays(q1) + q1->value.date.day; if (p1d < q1d) { xmlSchemaFreeValue(p1); xmlSchemaFreeValue(q1); return -1; } else if (p1d == q1d) { double sec; sec = TIME_TO_NUMBER(p1) - TIME_TO_NUMBER(q1); if (sec < 0.0) { xmlSchemaFreeValue(p1); xmlSchemaFreeValue(q1); return -1; } else { int ret = 0; /* normalize y - 14:00 */ q2 = xmlSchemaDateNormalize(y, -(14 * SECS_PER_HOUR)); q2d = _xmlSchemaDateCastYMToDays(q2) + q2->value.date.day; if (p1d > q2d) ret = 1; else if (p1d == q2d) { sec = TIME_TO_NUMBER(p1) - TIME_TO_NUMBER(q2); if (sec > 0.0) ret = 1; else ret = 2; /* indeterminate */ } xmlSchemaFreeValue(p1); xmlSchemaFreeValue(q1); xmlSchemaFreeValue(q2); if (ret != 0) return(ret); } } else { xmlSchemaFreeValue(p1); xmlSchemaFreeValue(q1); } } } else if (y->value.date.tz_flag) { q1 = xmlSchemaDateNormalize(y, 0); q1d = _xmlSchemaDateCastYMToDays(q1) + q1->value.date.day; /* normalize x - 14:00 */ p1 = xmlSchemaDateNormalize(x, -(14 * SECS_PER_HOUR)); p1d = _xmlSchemaDateCastYMToDays(p1) + p1->value.date.day; if (p1d < q1d) { xmlSchemaFreeValue(p1); xmlSchemaFreeValue(q1); return -1; } else if (p1d == q1d) { double sec; sec = TIME_TO_NUMBER(p1) - TIME_TO_NUMBER(q1); if (sec < 0.0) { xmlSchemaFreeValue(p1); xmlSchemaFreeValue(q1); return -1; } else { int ret = 0; /* normalize x + 14:00 */ p2 = xmlSchemaDateNormalize(x, (14 * SECS_PER_HOUR)); p2d = _xmlSchemaDateCastYMToDays(p2) + p2->value.date.day; if (p2d > q1d) { ret = 1; } else if (p2d == q1d) { sec = TIME_TO_NUMBER(p2) - TIME_TO_NUMBER(q1); if (sec > 0.0) ret = 1; else ret = 2; /* indeterminate */ } xmlSchemaFreeValue(p1); xmlSchemaFreeValue(q1); xmlSchemaFreeValue(p2); if (ret != 0) return(ret); } } else { xmlSchemaFreeValue(p1); xmlSchemaFreeValue(q1); } } /* * if the same type then calculate the difference */ if (x->type == y->type) { int ret = 0; q1 = xmlSchemaDateNormalize(y, 0); q1d = _xmlSchemaDateCastYMToDays(q1) + q1->value.date.day; p1 = xmlSchemaDateNormalize(x, 0); p1d = _xmlSchemaDateCastYMToDays(p1) + p1->value.date.day; if (p1d < q1d) { ret = -1; } else if (p1d > q1d) { ret = 1; } else { double sec; sec = TIME_TO_NUMBER(p1) - TIME_TO_NUMBER(q1); if (sec < 0.0) ret = -1; else if (sec > 0.0) ret = 1; } xmlSchemaFreeValue(p1); xmlSchemaFreeValue(q1); return(ret); } switch (x->type) { case XML_SCHEMAS_DATETIME: xmask = 0xf; break; case XML_SCHEMAS_DATE: xmask = 0x7; break; case XML_SCHEMAS_GYEAR: xmask = 0x1; break; case XML_SCHEMAS_GMONTH: xmask = 0x2; break; case XML_SCHEMAS_GDAY: xmask = 0x3; break; case XML_SCHEMAS_GYEARMONTH: xmask = 0x3; break; case XML_SCHEMAS_GMONTHDAY: xmask = 0x6; break; case XML_SCHEMAS_TIME: xmask = 0x8; break; default: xmask = 0; break; } switch (y->type) { case XML_SCHEMAS_DATETIME: ymask = 0xf; break; case XML_SCHEMAS_DATE: ymask = 0x7; break; case XML_SCHEMAS_GYEAR: ymask = 0x1; break; case XML_SCHEMAS_GMONTH: ymask = 0x2; break; case XML_SCHEMAS_GDAY: ymask = 0x3; break; case XML_SCHEMAS_GYEARMONTH: ymask = 0x3; break; case XML_SCHEMAS_GMONTHDAY: ymask = 0x6; break; case XML_SCHEMAS_TIME: ymask = 0x8; break; default: ymask = 0; break; } xor_mask = xmask ^ ymask; /* mark type differences */ and_mask = xmask & ymask; /* mark field specification */ /* year */ if (xor_mask & 1) return 2; /* indeterminate */ else if (and_mask & 1) { if (x->value.date.year < y->value.date.year) return -1; else if (x->value.date.year > y->value.date.year) return 1; } /* month */ if (xor_mask & 2) return 2; /* indeterminate */ else if (and_mask & 2) { if (x->value.date.mon < y->value.date.mon) return -1; else if (x->value.date.mon > y->value.date.mon) return 1; } /* day */ if (xor_mask & 4) return 2; /* indeterminate */ else if (and_mask & 4) { if (x->value.date.day < y->value.date.day) return -1; else if (x->value.date.day > y->value.date.day) return 1; } /* time */ if (xor_mask & 8) return 2; /* indeterminate */ else if (and_mask & 8) { if (x->value.date.hour < y->value.date.hour) return -1; else if (x->value.date.hour > y->value.date.hour) return 1; else if (x->value.date.min < y->value.date.min) return -1; else if (x->value.date.min > y->value.date.min) return 1; else if (x->value.date.sec < y->value.date.sec) return -1; else if (x->value.date.sec > y->value.date.sec) return 1; } return 0; } /** * xmlSchemaComparePreserveReplaceStrings: * @x: a first string value * @y: a second string value * @invert: inverts the result if x < y or x > y. * * Compare 2 string for their normalized values. * @x is a string with whitespace of "preserve", @y is * a string with a whitespace of "replace". I.e. @x could * be an "xsd:string" and @y an "xsd:normalizedString". * * Returns -1 if x < y, 0 if x == y, 1 if x > y, and -2 in * case of error */ static int xmlSchemaComparePreserveReplaceStrings(const xmlChar *x, const xmlChar *y, int invert) { int tmp; while ((*x != 0) && (*y != 0)) { if (IS_WSP_REPLACE_CH(*y)) { if (! IS_WSP_SPACE_CH(*x)) { if ((*x - 0x20) < 0) { if (invert) return(1); else return(-1); } else { if (invert) return(-1); else return(1); } } } else { tmp = *x - *y; if (tmp < 0) { if (invert) return(1); else return(-1); } if (tmp > 0) { if (invert) return(-1); else return(1); } } x++; y++; } if (*x != 0) { if (invert) return(-1); else return(1); } if (*y != 0) { if (invert) return(1); else return(-1); } return(0); } /** * xmlSchemaComparePreserveCollapseStrings: * @x: a first string value * @y: a second string value * * Compare 2 string for their normalized values. * @x is a string with whitespace of "preserve", @y is * a string with a whitespace of "collapse". I.e. @x could * be an "xsd:string" and @y an "xsd:normalizedString". * * Returns -1 if x < y, 0 if x == y, 1 if x > y, and -2 in * case of error */ static int xmlSchemaComparePreserveCollapseStrings(const xmlChar *x, const xmlChar *y, int invert) { int tmp; /* * Skip leading blank chars of the collapsed string. */ while IS_WSP_BLANK_CH(*y) y++; while ((*x != 0) && (*y != 0)) { if IS_WSP_BLANK_CH(*y) { if (! IS_WSP_SPACE_CH(*x)) { /* * The yv character would have been replaced to 0x20. */ if ((*x - 0x20) < 0) { if (invert) return(1); else return(-1); } else { if (invert) return(-1); else return(1); } } x++; y++; /* * Skip contiguous blank chars of the collapsed string. */ while IS_WSP_BLANK_CH(*y) y++; } else { tmp = *x++ - *y++; if (tmp < 0) { if (invert) return(1); else return(-1); } if (tmp > 0) { if (invert) return(-1); else return(1); } } } if (*x != 0) { if (invert) return(-1); else return(1); } if (*y != 0) { /* * Skip trailing blank chars of the collapsed string. */ while IS_WSP_BLANK_CH(*y) y++; if (*y != 0) { if (invert) return(1); else return(-1); } } return(0); } /** * xmlSchemaComparePreserveCollapseStrings: * @x: a first string value * @y: a second string value * * Compare 2 string for their normalized values. * @x is a string with whitespace of "preserve", @y is * a string with a whitespace of "collapse". I.e. @x could * be an "xsd:string" and @y an "xsd:normalizedString". * * Returns -1 if x < y, 0 if x == y, 1 if x > y, and -2 in * case of error */ static int xmlSchemaCompareReplaceCollapseStrings(const xmlChar *x, const xmlChar *y, int invert) { int tmp; /* * Skip leading blank chars of the collapsed string. */ while IS_WSP_BLANK_CH(*y) y++; while ((*x != 0) && (*y != 0)) { if IS_WSP_BLANK_CH(*y) { if (! IS_WSP_BLANK_CH(*x)) { /* * The yv character would have been replaced to 0x20. */ if ((*x - 0x20) < 0) { if (invert) return(1); else return(-1); } else { if (invert) return(-1); else return(1); } } x++; y++; /* * Skip contiguous blank chars of the collapsed string. */ while IS_WSP_BLANK_CH(*y) y++; } else { if IS_WSP_BLANK_CH(*x) { /* * The xv character would have been replaced to 0x20. */ if ((0x20 - *y) < 0) { if (invert) return(1); else return(-1); } else { if (invert) return(-1); else return(1); } } tmp = *x++ - *y++; if (tmp < 0) return(-1); if (tmp > 0) return(1); } } if (*x != 0) { if (invert) return(-1); else return(1); } if (*y != 0) { /* * Skip trailing blank chars of the collapsed string. */ while IS_WSP_BLANK_CH(*y) y++; if (*y != 0) { if (invert) return(1); else return(-1); } } return(0); } /** * xmlSchemaCompareReplacedStrings: * @x: a first string value * @y: a second string value * * Compare 2 string for their normalized values. * * Returns -1 if x < y, 0 if x == y, 1 if x > y, and -2 in * case of error */ static int xmlSchemaCompareReplacedStrings(const xmlChar *x, const xmlChar *y) { int tmp; while ((*x != 0) && (*y != 0)) { if IS_WSP_BLANK_CH(*y) { if (! IS_WSP_BLANK_CH(*x)) { if ((*x - 0x20) < 0) return(-1); else return(1); } } else { if IS_WSP_BLANK_CH(*x) { if ((0x20 - *y) < 0) return(-1); else return(1); } tmp = *x - *y; if (tmp < 0) return(-1); if (tmp > 0) return(1); } x++; y++; } if (*x != 0) return(1); if (*y != 0) return(-1); return(0); } /** * xmlSchemaCompareNormStrings: * @x: a first string value * @y: a second string value * * Compare 2 string for their normalized values. * * Returns -1 if x < y, 0 if x == y, 1 if x > y, and -2 in * case of error */ static int xmlSchemaCompareNormStrings(const xmlChar *x, const xmlChar *y) { int tmp; while (IS_BLANK_CH(*x)) x++; while (IS_BLANK_CH(*y)) y++; while ((*x != 0) && (*y != 0)) { if (IS_BLANK_CH(*x)) { if (!IS_BLANK_CH(*y)) { tmp = *x - *y; return(tmp); } while (IS_BLANK_CH(*x)) x++; while (IS_BLANK_CH(*y)) y++; } else { tmp = *x++ - *y++; if (tmp < 0) return(-1); if (tmp > 0) return(1); } } if (*x != 0) { while (IS_BLANK_CH(*x)) x++; if (*x != 0) return(1); } if (*y != 0) { while (IS_BLANK_CH(*y)) y++; if (*y != 0) return(-1); } return(0); } /** * xmlSchemaCompareFloats: * @x: a first float or double value * @y: a second float or double value * * Compare 2 values * * Returns -1 if x < y, 0 if x == y, 1 if x > y, 2 if x <> y, and -2 in * case of error */ static int xmlSchemaCompareFloats(xmlSchemaValPtr x, xmlSchemaValPtr y) { double d1, d2; if ((x == NULL) || (y == NULL)) return(-2); /* * Cast everything to doubles. */ if (x->type == XML_SCHEMAS_DOUBLE) d1 = x->value.d; else if (x->type == XML_SCHEMAS_FLOAT) d1 = x->value.f; else return(-2); if (y->type == XML_SCHEMAS_DOUBLE) d2 = y->value.d; else if (y->type == XML_SCHEMAS_FLOAT) d2 = y->value.f; else return(-2); /* * Check for special cases. */ if (xmlXPathIsNaN(d1)) { if (xmlXPathIsNaN(d2)) return(0); return(1); } if (xmlXPathIsNaN(d2)) return(-1); if (d1 == xmlXPathPINF) { if (d2 == xmlXPathPINF) return(0); return(1); } if (d2 == xmlXPathPINF) return(-1); if (d1 == xmlXPathNINF) { if (d2 == xmlXPathNINF) return(0); return(-1); } if (d2 == xmlXPathNINF) return(1); /* * basic tests, the last one we should have equality, but * portability is more important than speed and handling * NaN or Inf in a portable way is always a challenge, so ... */ if (d1 < d2) return(-1); if (d1 > d2) return(1); if (d1 == d2) return(0); return(2); } /** * xmlSchemaCompareValues: * @x: a first value * @xvalue: the first value as a string (optional) * @xwtsp: the whitespace type * @y: a second value * @xvalue: the second value as a string (optional) * @ywtsp: the whitespace type * * Compare 2 values * * Returns -1 if x < y, 0 if x == y, 1 if x > y, 2 if x <> y, 3 if not * comparable and -2 in case of error */ static int xmlSchemaCompareValuesInternal(xmlSchemaValType xtype, xmlSchemaValPtr x, const xmlChar *xvalue, xmlSchemaWhitespaceValueType xws, xmlSchemaValType ytype, xmlSchemaValPtr y, const xmlChar *yvalue, xmlSchemaWhitespaceValueType yws) { switch (xtype) { case XML_SCHEMAS_UNKNOWN: case XML_SCHEMAS_ANYTYPE: return(-2); case XML_SCHEMAS_INTEGER: case XML_SCHEMAS_NPINTEGER: case XML_SCHEMAS_NINTEGER: case XML_SCHEMAS_NNINTEGER: case XML_SCHEMAS_PINTEGER: case XML_SCHEMAS_INT: case XML_SCHEMAS_UINT: case XML_SCHEMAS_LONG: case XML_SCHEMAS_ULONG: case XML_SCHEMAS_SHORT: case XML_SCHEMAS_USHORT: case XML_SCHEMAS_BYTE: case XML_SCHEMAS_UBYTE: case XML_SCHEMAS_DECIMAL: if ((x == NULL) || (y == NULL)) return(-2); if (ytype == xtype) return(xmlSchemaCompareDecimals(x, y)); if ((ytype == XML_SCHEMAS_DECIMAL) || (ytype == XML_SCHEMAS_INTEGER) || (ytype == XML_SCHEMAS_NPINTEGER) || (ytype == XML_SCHEMAS_NINTEGER) || (ytype == XML_SCHEMAS_NNINTEGER) || (ytype == XML_SCHEMAS_PINTEGER) || (ytype == XML_SCHEMAS_INT) || (ytype == XML_SCHEMAS_UINT) || (ytype == XML_SCHEMAS_LONG) || (ytype == XML_SCHEMAS_ULONG) || (ytype == XML_SCHEMAS_SHORT) || (ytype == XML_SCHEMAS_USHORT) || (ytype == XML_SCHEMAS_BYTE) || (ytype == XML_SCHEMAS_UBYTE)) return(xmlSchemaCompareDecimals(x, y)); return(-2); case XML_SCHEMAS_DURATION: if ((x == NULL) || (y == NULL)) return(-2); if (ytype == XML_SCHEMAS_DURATION) return(xmlSchemaCompareDurations(x, y)); return(-2); case XML_SCHEMAS_TIME: case XML_SCHEMAS_GDAY: case XML_SCHEMAS_GMONTH: case XML_SCHEMAS_GMONTHDAY: case XML_SCHEMAS_GYEAR: case XML_SCHEMAS_GYEARMONTH: case XML_SCHEMAS_DATE: case XML_SCHEMAS_DATETIME: if ((x == NULL) || (y == NULL)) return(-2); if ((ytype == XML_SCHEMAS_DATETIME) || (ytype == XML_SCHEMAS_TIME) || (ytype == XML_SCHEMAS_GDAY) || (ytype == XML_SCHEMAS_GMONTH) || (ytype == XML_SCHEMAS_GMONTHDAY) || (ytype == XML_SCHEMAS_GYEAR) || (ytype == XML_SCHEMAS_DATE) || (ytype == XML_SCHEMAS_GYEARMONTH)) return (xmlSchemaCompareDates(x, y)); return (-2); /* * Note that we will support comparison of string types against * anySimpleType as well. */ case XML_SCHEMAS_ANYSIMPLETYPE: case XML_SCHEMAS_STRING: case XML_SCHEMAS_NORMSTRING: case XML_SCHEMAS_TOKEN: case XML_SCHEMAS_LANGUAGE: case XML_SCHEMAS_NMTOKEN: case XML_SCHEMAS_NAME: case XML_SCHEMAS_NCNAME: case XML_SCHEMAS_ID: case XML_SCHEMAS_IDREF: case XML_SCHEMAS_ENTITY: case XML_SCHEMAS_ANYURI: { const xmlChar *xv, *yv; if (x == NULL) xv = xvalue; else xv = x->value.str; if (y == NULL) yv = yvalue; else yv = y->value.str; /* * TODO: Compare those against QName. */ if (ytype == XML_SCHEMAS_QNAME) { TODO if (y == NULL) return(-2); return (-2); } if ((ytype == XML_SCHEMAS_ANYSIMPLETYPE) || (ytype == XML_SCHEMAS_STRING) || (ytype == XML_SCHEMAS_NORMSTRING) || (ytype == XML_SCHEMAS_TOKEN) || (ytype == XML_SCHEMAS_LANGUAGE) || (ytype == XML_SCHEMAS_NMTOKEN) || (ytype == XML_SCHEMAS_NAME) || (ytype == XML_SCHEMAS_NCNAME) || (ytype == XML_SCHEMAS_ID) || (ytype == XML_SCHEMAS_IDREF) || (ytype == XML_SCHEMAS_ENTITY) || (ytype == XML_SCHEMAS_ANYURI)) { if (xws == XML_SCHEMA_WHITESPACE_PRESERVE) { if (yws == XML_SCHEMA_WHITESPACE_PRESERVE) { /* TODO: What about x < y or x > y. */ if (xmlStrEqual(xv, yv)) return (0); else return (2); } else if (yws == XML_SCHEMA_WHITESPACE_REPLACE) return (xmlSchemaComparePreserveReplaceStrings(xv, yv, 0)); else if (yws == XML_SCHEMA_WHITESPACE_COLLAPSE) return (xmlSchemaComparePreserveCollapseStrings(xv, yv, 0)); } else if (xws == XML_SCHEMA_WHITESPACE_REPLACE) { if (yws == XML_SCHEMA_WHITESPACE_PRESERVE) return (xmlSchemaComparePreserveReplaceStrings(yv, xv, 1)); if (yws == XML_SCHEMA_WHITESPACE_REPLACE) return (xmlSchemaCompareReplacedStrings(xv, yv)); if (yws == XML_SCHEMA_WHITESPACE_COLLAPSE) return (xmlSchemaCompareReplaceCollapseStrings(xv, yv, 0)); } else if (xws == XML_SCHEMA_WHITESPACE_COLLAPSE) { if (yws == XML_SCHEMA_WHITESPACE_PRESERVE) return (xmlSchemaComparePreserveCollapseStrings(yv, xv, 1)); if (yws == XML_SCHEMA_WHITESPACE_REPLACE) return (xmlSchemaCompareReplaceCollapseStrings(yv, xv, 1)); if (yws == XML_SCHEMA_WHITESPACE_COLLAPSE) return (xmlSchemaCompareNormStrings(xv, yv)); } else return (-2); } return (-2); } case XML_SCHEMAS_QNAME: case XML_SCHEMAS_NOTATION: if ((x == NULL) || (y == NULL)) return(-2); if ((ytype == XML_SCHEMAS_QNAME) || (ytype == XML_SCHEMAS_NOTATION)) { if ((xmlStrEqual(x->value.qname.name, y->value.qname.name)) && (xmlStrEqual(x->value.qname.uri, y->value.qname.uri))) return(0); return(2); } return (-2); case XML_SCHEMAS_FLOAT: case XML_SCHEMAS_DOUBLE: if ((x == NULL) || (y == NULL)) return(-2); if ((ytype == XML_SCHEMAS_FLOAT) || (ytype == XML_SCHEMAS_DOUBLE)) return (xmlSchemaCompareFloats(x, y)); return (-2); case XML_SCHEMAS_BOOLEAN: if ((x == NULL) || (y == NULL)) return(-2); if (ytype == XML_SCHEMAS_BOOLEAN) { if (x->value.b == y->value.b) return(0); if (x->value.b == 0) return(-1); return(1); } return (-2); case XML_SCHEMAS_HEXBINARY: if ((x == NULL) || (y == NULL)) return(-2); if (ytype == XML_SCHEMAS_HEXBINARY) { if (x->value.hex.total == y->value.hex.total) { int ret = xmlStrcmp(x->value.hex.str, y->value.hex.str); if (ret > 0) return(1); else if (ret == 0) return(0); } else if (x->value.hex.total > y->value.hex.total) return(1); return(-1); } return (-2); case XML_SCHEMAS_BASE64BINARY: if ((x == NULL) || (y == NULL)) return(-2); if (ytype == XML_SCHEMAS_BASE64BINARY) { if (x->value.base64.total == y->value.base64.total) { int ret = xmlStrcmp(x->value.base64.str, y->value.base64.str); if (ret > 0) return(1); else if (ret == 0) return(0); else return(-1); } else if (x->value.base64.total > y->value.base64.total) return(1); else return(-1); } return (-2); case XML_SCHEMAS_IDREFS: case XML_SCHEMAS_ENTITIES: case XML_SCHEMAS_NMTOKENS: TODO break; } return -2; } /** * xmlSchemaCompareValues: * @x: a first value * @y: a second value * * Compare 2 values * * Returns -1 if x < y, 0 if x == y, 1 if x > y, 2 if x <> y, and -2 in * case of error */ int xmlSchemaCompareValues(xmlSchemaValPtr x, xmlSchemaValPtr y) { xmlSchemaWhitespaceValueType xws, yws; if ((x == NULL) || (y == NULL)) return(-2); if (x->type == XML_SCHEMAS_STRING) xws = XML_SCHEMA_WHITESPACE_PRESERVE; else if (x->type == XML_SCHEMAS_NORMSTRING) xws = XML_SCHEMA_WHITESPACE_REPLACE; else xws = XML_SCHEMA_WHITESPACE_COLLAPSE; if (y->type == XML_SCHEMAS_STRING) yws = XML_SCHEMA_WHITESPACE_PRESERVE; else if (x->type == XML_SCHEMAS_NORMSTRING) yws = XML_SCHEMA_WHITESPACE_REPLACE; else yws = XML_SCHEMA_WHITESPACE_COLLAPSE; return(xmlSchemaCompareValuesInternal(x->type, x, NULL, xws, y->type, y, NULL, yws)); } /** * xmlSchemaCompareValuesWhtsp: * @x: a first value * @xws: the whitespace value of x * @y: a second value * @yws: the whitespace value of y * * Compare 2 values * * Returns -1 if x < y, 0 if x == y, 1 if x > y, 2 if x <> y, and -2 in * case of error */ int xmlSchemaCompareValuesWhtsp(xmlSchemaValPtr x, xmlSchemaWhitespaceValueType xws, xmlSchemaValPtr y, xmlSchemaWhitespaceValueType yws) { if ((x == NULL) || (y == NULL)) return(-2); return(xmlSchemaCompareValuesInternal(x->type, x, NULL, xws, y->type, y, NULL, yws)); } /** * xmlSchemaCompareValuesWhtspExt: * @x: a first value * @xws: the whitespace value of x * @y: a second value * @yws: the whitespace value of y * * Compare 2 values * * Returns -1 if x < y, 0 if x == y, 1 if x > y, 2 if x <> y, and -2 in * case of error */ static int xmlSchemaCompareValuesWhtspExt(xmlSchemaValType xtype, xmlSchemaValPtr x, const xmlChar *xvalue, xmlSchemaWhitespaceValueType xws, xmlSchemaValType ytype, xmlSchemaValPtr y, const xmlChar *yvalue, xmlSchemaWhitespaceValueType yws) { return(xmlSchemaCompareValuesInternal(xtype, x, xvalue, xws, ytype, y, yvalue, yws)); } /** * xmlSchemaNormLen: * @value: a string * * Computes the UTF8 length of the normalized value of the string * * Returns the length or -1 in case of error. */ static int xmlSchemaNormLen(const xmlChar *value) { const xmlChar *utf; int ret = 0; if (value == NULL) return(-1); utf = value; while (IS_BLANK_CH(*utf)) utf++; while (*utf != 0) { if (utf[0] & 0x80) { if ((utf[1] & 0xc0) != 0x80) return(-1); if ((utf[0] & 0xe0) == 0xe0) { if ((utf[2] & 0xc0) != 0x80) return(-1); if ((utf[0] & 0xf0) == 0xf0) { if ((utf[0] & 0xf8) != 0xf0 || (utf[3] & 0xc0) != 0x80) return(-1); utf += 4; } else { utf += 3; } } else { utf += 2; } } else if (IS_BLANK_CH(*utf)) { while (IS_BLANK_CH(*utf)) utf++; if (*utf == 0) break; } else { utf++; } ret++; } return(ret); } /** * xmlSchemaGetFacetValueAsULong: * @facet: an schemas type facet * * Extract the value of a facet * * Returns the value as a long */ unsigned long xmlSchemaGetFacetValueAsULong(xmlSchemaFacetPtr facet) { /* * TODO: Check if this is a decimal. */ if (facet == NULL) return 0; return ((unsigned long) facet->val->value.decimal.lo); } /** * xmlSchemaValidateListSimpleTypeFacet: * @facet: the facet to check * @value: the lexical repr of the value to validate * @actualLen: the number of list items * @expectedLen: the resulting expected number of list items * * Checks the value of a list simple type against a facet. * * Returns 0 if the value is valid, a positive error code * number otherwise and -1 in case of an internal error. */ int xmlSchemaValidateListSimpleTypeFacet(xmlSchemaFacetPtr facet, const xmlChar *value, unsigned long actualLen, unsigned long *expectedLen) { if (facet == NULL) return(-1); /* * TODO: Check if this will work with large numbers. * (compare value.decimal.mi and value.decimal.hi as well?). */ if (facet->type == XML_SCHEMA_FACET_LENGTH) { if (actualLen != facet->val->value.decimal.lo) { if (expectedLen != NULL) *expectedLen = facet->val->value.decimal.lo; return (XML_SCHEMAV_CVC_LENGTH_VALID); } } else if (facet->type == XML_SCHEMA_FACET_MINLENGTH) { if (actualLen < facet->val->value.decimal.lo) { if (expectedLen != NULL) *expectedLen = facet->val->value.decimal.lo; return (XML_SCHEMAV_CVC_MINLENGTH_VALID); } } else if (facet->type == XML_SCHEMA_FACET_MAXLENGTH) { if (actualLen > facet->val->value.decimal.lo) { if (expectedLen != NULL) *expectedLen = facet->val->value.decimal.lo; return (XML_SCHEMAV_CVC_MAXLENGTH_VALID); } } else /* * NOTE: That we can pass NULL as xmlSchemaValPtr to * xmlSchemaValidateFacet, since the remaining facet types * are: XML_SCHEMA_FACET_PATTERN, XML_SCHEMA_FACET_ENUMERATION. */ return(xmlSchemaValidateFacet(NULL, facet, value, NULL)); return (0); } /** * xmlSchemaValidateLengthFacet: * @type: the built-in type * @facet: the facet to check * @value: the lexical repr. of the value to be validated * @val: the precomputed value * @ws: the whitespace type of the value * @length: the actual length of the value * * Checka a value against a "length", "minLength" and "maxLength" * facet; sets @length to the computed length of @value. * * Returns 0 if the value is valid, a positive error code * otherwise and -1 in case of an internal or API error. */ static int xmlSchemaValidateLengthFacetInternal(xmlSchemaFacetPtr facet, xmlSchemaTypeType valType, const xmlChar *value, xmlSchemaValPtr val, unsigned long *length, xmlSchemaWhitespaceValueType ws) { unsigned int len = 0; if ((length == NULL) || (facet == NULL)) return (-1); *length = 0; if ((facet->type != XML_SCHEMA_FACET_LENGTH) && (facet->type != XML_SCHEMA_FACET_MAXLENGTH) && (facet->type != XML_SCHEMA_FACET_MINLENGTH)) return (-1); /* * TODO: length, maxLength and minLength must be of type * nonNegativeInteger only. Check if decimal is used somehow. */ if ((facet->val == NULL) || ((facet->val->type != XML_SCHEMAS_DECIMAL) && (facet->val->type != XML_SCHEMAS_NNINTEGER)) || (facet->val->value.decimal.frac != 0)) { return(-1); } if ((val != NULL) && (val->type == XML_SCHEMAS_HEXBINARY)) len = val->value.hex.total; else if ((val != NULL) && (val->type == XML_SCHEMAS_BASE64BINARY)) len = val->value.base64.total; else { switch (valType) { case XML_SCHEMAS_STRING: case XML_SCHEMAS_NORMSTRING: if (ws == XML_SCHEMA_WHITESPACE_UNKNOWN) { /* * This is to ensure API compatibility with the old * xmlSchemaValidateLengthFacet(). Anyway, this was and * is not the correct handling. * TODO: Get rid of this case somehow. */ if (valType == XML_SCHEMAS_STRING) len = xmlUTF8Strlen(value); else len = xmlSchemaNormLen(value); } else if (value != NULL) { if (ws == XML_SCHEMA_WHITESPACE_COLLAPSE) len = xmlSchemaNormLen(value); else /* * Should be OK for "preserve" as well. */ len = xmlUTF8Strlen(value); } break; case XML_SCHEMAS_IDREF: case XML_SCHEMAS_TOKEN: case XML_SCHEMAS_LANGUAGE: case XML_SCHEMAS_NMTOKEN: case XML_SCHEMAS_NAME: case XML_SCHEMAS_NCNAME: case XML_SCHEMAS_ID: /* * FIXME: What exactly to do with anyURI? */ case XML_SCHEMAS_ANYURI: if (value != NULL) len = xmlSchemaNormLen(value); break; case XML_SCHEMAS_QNAME: case XML_SCHEMAS_NOTATION: /* * For QName and NOTATION, those facets are * deprecated and should be ignored. */ return (0); default: TODO } } *length = (unsigned long) len; /* * TODO: Return the whole expected value, i.e. "lo", "mi" and "hi". */ if (facet->type == XML_SCHEMA_FACET_LENGTH) { if (len != facet->val->value.decimal.lo) return(XML_SCHEMAV_CVC_LENGTH_VALID); } else if (facet->type == XML_SCHEMA_FACET_MINLENGTH) { if (len < facet->val->value.decimal.lo) return(XML_SCHEMAV_CVC_MINLENGTH_VALID); } else { if (len > facet->val->value.decimal.lo) return(XML_SCHEMAV_CVC_MAXLENGTH_VALID); } return (0); } /** * xmlSchemaValidateLengthFacet: * @type: the built-in type * @facet: the facet to check * @value: the lexical repr. of the value to be validated * @val: the precomputed value * @length: the actual length of the value * * Checka a value against a "length", "minLength" and "maxLength" * facet; sets @length to the computed length of @value. * * Returns 0 if the value is valid, a positive error code * otherwise and -1 in case of an internal or API error. */ int xmlSchemaValidateLengthFacet(xmlSchemaTypePtr type, xmlSchemaFacetPtr facet, const xmlChar *value, xmlSchemaValPtr val, unsigned long *length) { if (type == NULL) return(-1); return (xmlSchemaValidateLengthFacetInternal(facet, type->builtInType, value, val, length, XML_SCHEMA_WHITESPACE_UNKNOWN)); } /** * xmlSchemaValidateLengthFacetWhtsp: * @facet: the facet to check * @valType: the built-in type * @value: the lexical repr. of the value to be validated * @val: the precomputed value * @ws: the whitespace type of the value * @length: the actual length of the value * * Checka a value against a "length", "minLength" and "maxLength" * facet; sets @length to the computed length of @value. * * Returns 0 if the value is valid, a positive error code * otherwise and -1 in case of an internal or API error. */ int xmlSchemaValidateLengthFacetWhtsp(xmlSchemaFacetPtr facet, xmlSchemaValType valType, const xmlChar *value, xmlSchemaValPtr val, unsigned long *length, xmlSchemaWhitespaceValueType ws) { return (xmlSchemaValidateLengthFacetInternal(facet, valType, value, val, length, ws)); } /** * xmlSchemaValidateFacetInternal: * @facet: the facet to check * @fws: the whitespace type of the facet's value * @valType: the built-in type of the value * @value: the lexical repr of the value to validate * @val: the precomputed value * @ws: the whitespace type of the value * * Check a value against a facet condition * * Returns 0 if the element is schemas valid, a positive error code * number otherwise and -1 in case of internal or API error. */ static int xmlSchemaValidateFacetInternal(xmlSchemaFacetPtr facet, xmlSchemaWhitespaceValueType fws, xmlSchemaValType valType, const xmlChar *value, xmlSchemaValPtr val, xmlSchemaWhitespaceValueType ws) { int ret; if (facet == NULL) return(-1); switch (facet->type) { case XML_SCHEMA_FACET_PATTERN: /* * NOTE that for patterns, the @value needs to be the normalized * value, *not* the lexical initial value or the canonical value. */ if (value == NULL) return(-1); ret = xmlRegexpExec(facet->regexp, value); if (ret == 1) return(0); if (ret == 0) return(XML_SCHEMAV_CVC_PATTERN_VALID); return(ret); case XML_SCHEMA_FACET_MAXEXCLUSIVE: ret = xmlSchemaCompareValues(val, facet->val); if (ret == -2) return(-1); if (ret == -1) return(0); return(XML_SCHEMAV_CVC_MAXEXCLUSIVE_VALID); case XML_SCHEMA_FACET_MAXINCLUSIVE: ret = xmlSchemaCompareValues(val, facet->val); if (ret == -2) return(-1); if ((ret == -1) || (ret == 0)) return(0); return(XML_SCHEMAV_CVC_MAXINCLUSIVE_VALID); case XML_SCHEMA_FACET_MINEXCLUSIVE: ret = xmlSchemaCompareValues(val, facet->val); if (ret == -2) return(-1); if (ret == 1) return(0); return(XML_SCHEMAV_CVC_MINEXCLUSIVE_VALID); case XML_SCHEMA_FACET_MININCLUSIVE: ret = xmlSchemaCompareValues(val, facet->val); if (ret == -2) return(-1); if ((ret == 1) || (ret == 0)) return(0); return(XML_SCHEMAV_CVC_MININCLUSIVE_VALID); case XML_SCHEMA_FACET_WHITESPACE: /* TODO whitespaces */ /* * NOTE: Whitespace should be handled to normalize * the value to be validated against a the facets; * not to normalize the value in-between. */ return(0); case XML_SCHEMA_FACET_ENUMERATION: if (ws == XML_SCHEMA_WHITESPACE_UNKNOWN) { /* * This is to ensure API compatibility with the old * xmlSchemaValidateFacet(). * TODO: Get rid of this case. */ if ((facet->value != NULL) && (xmlStrEqual(facet->value, value))) return(0); } else { ret = xmlSchemaCompareValuesWhtspExt(facet->val->type, facet->val, facet->value, fws, valType, val, value, ws); if (ret == -2) return(-1); if (ret == 0) return(0); } return(XML_SCHEMAV_CVC_ENUMERATION_VALID); case XML_SCHEMA_FACET_LENGTH: /* * SPEC (1.3) "if {primitive type definition} is QName or NOTATION, * then any {value} is facet-valid." */ if ((valType == XML_SCHEMAS_QNAME) || (valType == XML_SCHEMAS_NOTATION)) return (0); /* No break on purpose. */ case XML_SCHEMA_FACET_MAXLENGTH: case XML_SCHEMA_FACET_MINLENGTH: { unsigned int len = 0; if ((valType == XML_SCHEMAS_QNAME) || (valType == XML_SCHEMAS_NOTATION)) return (0); /* * TODO: length, maxLength and minLength must be of type * nonNegativeInteger only. Check if decimal is used somehow. */ if ((facet->val == NULL) || ((facet->val->type != XML_SCHEMAS_DECIMAL) && (facet->val->type != XML_SCHEMAS_NNINTEGER)) || (facet->val->value.decimal.frac != 0)) { return(-1); } if ((val != NULL) && (val->type == XML_SCHEMAS_HEXBINARY)) len = val->value.hex.total; else if ((val != NULL) && (val->type == XML_SCHEMAS_BASE64BINARY)) len = val->value.base64.total; else { switch (valType) { case XML_SCHEMAS_STRING: case XML_SCHEMAS_NORMSTRING: if (ws == XML_SCHEMA_WHITESPACE_UNKNOWN) { /* * This is to ensure API compatibility with the old * xmlSchemaValidateFacet(). Anyway, this was and * is not the correct handling. * TODO: Get rid of this case somehow. */ if (valType == XML_SCHEMAS_STRING) len = xmlUTF8Strlen(value); else len = xmlSchemaNormLen(value); } else if (value != NULL) { if (ws == XML_SCHEMA_WHITESPACE_COLLAPSE) len = xmlSchemaNormLen(value); else /* * Should be OK for "preserve" as well. */ len = xmlUTF8Strlen(value); } break; case XML_SCHEMAS_IDREF: case XML_SCHEMAS_TOKEN: case XML_SCHEMAS_LANGUAGE: case XML_SCHEMAS_NMTOKEN: case XML_SCHEMAS_NAME: case XML_SCHEMAS_NCNAME: case XML_SCHEMAS_ID: case XML_SCHEMAS_ANYURI: if (value != NULL) len = xmlSchemaNormLen(value); break; default: TODO } } if (facet->type == XML_SCHEMA_FACET_LENGTH) { if (len != facet->val->value.decimal.lo) return(XML_SCHEMAV_CVC_LENGTH_VALID); } else if (facet->type == XML_SCHEMA_FACET_MINLENGTH) { if (len < facet->val->value.decimal.lo) return(XML_SCHEMAV_CVC_MINLENGTH_VALID); } else { if (len > facet->val->value.decimal.lo) return(XML_SCHEMAV_CVC_MAXLENGTH_VALID); } break; } case XML_SCHEMA_FACET_TOTALDIGITS: case XML_SCHEMA_FACET_FRACTIONDIGITS: if ((facet->val == NULL) || ((facet->val->type != XML_SCHEMAS_PINTEGER) && (facet->val->type != XML_SCHEMAS_NNINTEGER)) || (facet->val->value.decimal.frac != 0)) { return(-1); } if ((val == NULL) || ((val->type != XML_SCHEMAS_DECIMAL) && (val->type != XML_SCHEMAS_INTEGER) && (val->type != XML_SCHEMAS_NPINTEGER) && (val->type != XML_SCHEMAS_NINTEGER) && (val->type != XML_SCHEMAS_NNINTEGER) && (val->type != XML_SCHEMAS_PINTEGER) && (val->type != XML_SCHEMAS_INT) && (val->type != XML_SCHEMAS_UINT) && (val->type != XML_SCHEMAS_LONG) && (val->type != XML_SCHEMAS_ULONG) && (val->type != XML_SCHEMAS_SHORT) && (val->type != XML_SCHEMAS_USHORT) && (val->type != XML_SCHEMAS_BYTE) && (val->type != XML_SCHEMAS_UBYTE))) { return(-1); } if (facet->type == XML_SCHEMA_FACET_TOTALDIGITS) { if (val->value.decimal.total > facet->val->value.decimal.lo) return(XML_SCHEMAV_CVC_TOTALDIGITS_VALID); } else if (facet->type == XML_SCHEMA_FACET_FRACTIONDIGITS) { if (val->value.decimal.frac > facet->val->value.decimal.lo) return(XML_SCHEMAV_CVC_FRACTIONDIGITS_VALID); } break; default: TODO } return(0); } /** * xmlSchemaValidateFacet: * @base: the base type * @facet: the facet to check * @value: the lexical repr of the value to validate * @val: the precomputed value * * Check a value against a facet condition * * Returns 0 if the element is schemas valid, a positive error code * number otherwise and -1 in case of internal or API error. */ int xmlSchemaValidateFacet(xmlSchemaTypePtr base, xmlSchemaFacetPtr facet, const xmlChar *value, xmlSchemaValPtr val) { /* * This tries to ensure API compatibility regarding the old * xmlSchemaValidateFacet() and the new xmlSchemaValidateFacetInternal() and * xmlSchemaValidateFacetWhtsp(). */ if (val != NULL) return(xmlSchemaValidateFacetInternal(facet, XML_SCHEMA_WHITESPACE_UNKNOWN, val->type, value, val, XML_SCHEMA_WHITESPACE_UNKNOWN)); else if (base != NULL) return(xmlSchemaValidateFacetInternal(facet, XML_SCHEMA_WHITESPACE_UNKNOWN, base->builtInType, value, val, XML_SCHEMA_WHITESPACE_UNKNOWN)); return(-1); } /** * xmlSchemaValidateFacetWhtsp: * @facet: the facet to check * @fws: the whitespace type of the facet's value * @valType: the built-in type of the value * @value: the lexical (or normalized for pattern) repr of the value to validate * @val: the precomputed value * @ws: the whitespace type of the value * * Check a value against a facet condition. This takes value normalization * according to the specified whitespace types into account. * Note that @value needs to be the *normalized* value if the facet * is of type "pattern". * * Returns 0 if the element is schemas valid, a positive error code * number otherwise and -1 in case of internal or API error. */ int xmlSchemaValidateFacetWhtsp(xmlSchemaFacetPtr facet, xmlSchemaWhitespaceValueType fws, xmlSchemaValType valType, const xmlChar *value, xmlSchemaValPtr val, xmlSchemaWhitespaceValueType ws) { return(xmlSchemaValidateFacetInternal(facet, fws, valType, value, val, ws)); } #if 0 #ifndef DBL_DIG #define DBL_DIG 16 #endif #ifndef DBL_EPSILON #define DBL_EPSILON 1E-9 #endif #define INTEGER_DIGITS DBL_DIG #define FRACTION_DIGITS (DBL_DIG + 1) #define EXPONENT_DIGITS (3 + 2) /** * xmlXPathFormatNumber: * @number: number to format * @buffer: output buffer * @buffersize: size of output buffer * * Convert the number into a string representation. */ static void xmlSchemaFormatFloat(double number, char buffer[], int buffersize) { switch (xmlXPathIsInf(number)) { case 1: if (buffersize > (int)sizeof("INF")) snprintf(buffer, buffersize, "INF"); break; case -1: if (buffersize > (int)sizeof("-INF")) snprintf(buffer, buffersize, "-INF"); break; default: if (xmlXPathIsNaN(number)) { if (buffersize > (int)sizeof("NaN")) snprintf(buffer, buffersize, "NaN"); } else if (number == 0) { snprintf(buffer, buffersize, "0.0E0"); } else { /* 3 is sign, decimal point, and terminating zero */ char work[DBL_DIG + EXPONENT_DIGITS + 3]; int integer_place, fraction_place; char *ptr; char *after_fraction; double absolute_value; int size; absolute_value = fabs(number); /* * Result is in work, and after_fraction points * just past the fractional part. * Use scientific notation */ integer_place = DBL_DIG + EXPONENT_DIGITS + 1; fraction_place = DBL_DIG - 1; snprintf(work, sizeof(work),"%*.*e", integer_place, fraction_place, number); after_fraction = strchr(work + DBL_DIG, 'e'); /* Remove fractional trailing zeroes */ ptr = after_fraction; while (*(--ptr) == '0') ; if (*ptr != '.') ptr++; while ((*ptr++ = *after_fraction++) != 0); /* Finally copy result back to caller */ size = strlen(work) + 1; if (size > buffersize) { work[buffersize - 1] = 0; size = buffersize; } memmove(buffer, work, size); } break; } } #endif /** * xmlSchemaGetCanonValue: * @val: the precomputed value * @retValue: the returned value * * Get a the cononical lexical representation of the value. * The caller has to FREE the returned retValue. * * WARNING: Some value types are not supported yet, resulting * in a @retValue of "???". * * TODO: XML Schema 1.0 does not define canonical representations * for: duration, gYearMonth, gYear, gMonthDay, gMonth, gDay, * anyURI, QName, NOTATION. This will be fixed in XML Schema 1.1. * * * Returns 0 if the value could be built, 1 if the value type is * not supported yet and -1 in case of API errors. */ int xmlSchemaGetCanonValue(xmlSchemaValPtr val, const xmlChar **retValue) { if ((retValue == NULL) || (val == NULL)) return (-1); *retValue = NULL; switch (val->type) { case XML_SCHEMAS_STRING: if (val->value.str == NULL) *retValue = BAD_CAST xmlStrdup(BAD_CAST ""); else *retValue = BAD_CAST xmlStrdup((const xmlChar *) val->value.str); break; case XML_SCHEMAS_NORMSTRING: if (val->value.str == NULL) *retValue = BAD_CAST xmlStrdup(BAD_CAST ""); else { *retValue = xmlSchemaWhiteSpaceReplace( (const xmlChar *) val->value.str); if ((*retValue) == NULL) *retValue = BAD_CAST xmlStrdup( (const xmlChar *) val->value.str); } break; case XML_SCHEMAS_TOKEN: case XML_SCHEMAS_LANGUAGE: case XML_SCHEMAS_NMTOKEN: case XML_SCHEMAS_NAME: case XML_SCHEMAS_NCNAME: case XML_SCHEMAS_ID: case XML_SCHEMAS_IDREF: case XML_SCHEMAS_ENTITY: case XML_SCHEMAS_NOTATION: /* Unclear */ case XML_SCHEMAS_ANYURI: /* Unclear */ if (val->value.str == NULL) return (-1); *retValue = BAD_CAST xmlSchemaCollapseString(BAD_CAST val->value.str); if (*retValue == NULL) *retValue = BAD_CAST xmlStrdup((const xmlChar *) val->value.str); break; case XML_SCHEMAS_QNAME: /* TODO: Unclear in XML Schema 1.0. */ if (val->value.qname.uri == NULL) { *retValue = BAD_CAST xmlStrdup(BAD_CAST val->value.qname.name); return (0); } else { *retValue = BAD_CAST xmlStrdup(BAD_CAST "{"); *retValue = BAD_CAST xmlStrcat((xmlChar *) (*retValue), BAD_CAST val->value.qname.uri); *retValue = BAD_CAST xmlStrcat((xmlChar *) (*retValue), BAD_CAST "}"); *retValue = BAD_CAST xmlStrcat((xmlChar *) (*retValue), BAD_CAST val->value.qname.uri); } break; case XML_SCHEMAS_DECIMAL: /* * TODO: Lookout for a more simple implementation. */ if ((val->value.decimal.total == 1) && (val->value.decimal.lo == 0)) { *retValue = xmlStrdup(BAD_CAST "0.0"); } else { xmlSchemaValDecimal dec = val->value.decimal; int bufsize; char *buf = NULL, *offs; /* Add room for the decimal point as well. */ bufsize = dec.total + 2; if (dec.sign) bufsize++; /* Add room for leading/trailing zero. */ if ((dec.frac == 0) || (dec.frac == dec.total)) bufsize++; buf = xmlMalloc(bufsize); if (buf == NULL) return(-1); offs = buf; if (dec.sign) *offs++ = '-'; if (dec.frac == dec.total) { *offs++ = '0'; *offs++ = '.'; } if (dec.hi != 0) snprintf(offs, bufsize - (offs - buf), "%lu%lu%lu", dec.hi, dec.mi, dec.lo); else if (dec.mi != 0) snprintf(offs, bufsize - (offs - buf), "%lu%lu", dec.mi, dec.lo); else snprintf(offs, bufsize - (offs - buf), "%lu", dec.lo); if (dec.frac != 0) { if (dec.frac != dec.total) { int diff = dec.total - dec.frac; /* * Insert the decimal point. */ memmove(offs + diff + 1, offs + diff, dec.frac +1); offs[diff] = '.'; } else { unsigned int i = 0; /* * Insert missing zeroes behind the decimal point. */ while (*(offs + i) != 0) i++; if (i < dec.total) { memmove(offs + (dec.total - i), offs, i +1); memset(offs, '0', dec.total - i); } } } else { /* * Append decimal point and zero. */ offs = buf + bufsize - 1; *offs-- = 0; *offs-- = '0'; *offs-- = '.'; } *retValue = BAD_CAST buf; } break; case XML_SCHEMAS_INTEGER: case XML_SCHEMAS_PINTEGER: case XML_SCHEMAS_NPINTEGER: case XML_SCHEMAS_NINTEGER: case XML_SCHEMAS_NNINTEGER: case XML_SCHEMAS_LONG: case XML_SCHEMAS_BYTE: case XML_SCHEMAS_SHORT: case XML_SCHEMAS_INT: case XML_SCHEMAS_UINT: case XML_SCHEMAS_ULONG: case XML_SCHEMAS_USHORT: case XML_SCHEMAS_UBYTE: if ((val->value.decimal.total == 1) && (val->value.decimal.lo == 0)) *retValue = xmlStrdup(BAD_CAST "0"); else { xmlSchemaValDecimal dec = val->value.decimal; int bufsize = dec.total + 1; /* Add room for the decimal point as well. */ if (dec.sign) bufsize++; *retValue = xmlMalloc(bufsize); if (*retValue == NULL) return(-1); if (dec.hi != 0) { if (dec.sign) snprintf((char *) *retValue, bufsize, "-%lu%lu%lu", dec.hi, dec.mi, dec.lo); else snprintf((char *) *retValue, bufsize, "%lu%lu%lu", dec.hi, dec.mi, dec.lo); } else if (dec.mi != 0) { if (dec.sign) snprintf((char *) *retValue, bufsize, "-%lu%lu", dec.mi, dec.lo); else snprintf((char *) *retValue, bufsize, "%lu%lu", dec.mi, dec.lo); } else { if (dec.sign) snprintf((char *) *retValue, bufsize, "-%lu", dec.lo); else snprintf((char *) *retValue, bufsize, "%lu", dec.lo); } } break; case XML_SCHEMAS_BOOLEAN: if (val->value.b) *retValue = BAD_CAST xmlStrdup(BAD_CAST "true"); else *retValue = BAD_CAST xmlStrdup(BAD_CAST "false"); break; case XML_SCHEMAS_DURATION: { char buf[100]; unsigned long year; unsigned long mon, day, hour = 0, min = 0; double sec = 0, left; /* TODO: Unclear in XML Schema 1.0 */ /* * TODO: This results in a normalized output of the value * - which is NOT conformant to the spec - * since the exact values of each property are not * recoverable. Think about extending the structure to * provide a field for every property. */ year = (unsigned long) FQUOTIENT(labs(val->value.dur.mon), 12); mon = labs(val->value.dur.mon) - 12 * year; day = (unsigned long) FQUOTIENT(fabs(val->value.dur.sec), 86400); left = fabs(val->value.dur.sec) - day * 86400; if (left > 0) { hour = (unsigned long) FQUOTIENT(left, 3600); left = left - (hour * 3600); if (left > 0) { min = (unsigned long) FQUOTIENT(left, 60); sec = left - (min * 60); } } if ((val->value.dur.mon < 0) || (val->value.dur.sec < 0)) snprintf(buf, 100, "P%luY%luM%luDT%luH%luM%.14gS", year, mon, day, hour, min, sec); else snprintf(buf, 100, "-P%luY%luM%luDT%luH%luM%.14gS", year, mon, day, hour, min, sec); *retValue = BAD_CAST xmlStrdup(BAD_CAST buf); } break; case XML_SCHEMAS_GYEAR: { char buf[30]; /* TODO: Unclear in XML Schema 1.0 */ /* TODO: What to do with the timezone? */ snprintf(buf, 30, "%04ld", val->value.date.year); *retValue = BAD_CAST xmlStrdup(BAD_CAST buf); } break; case XML_SCHEMAS_GMONTH: { /* TODO: Unclear in XML Schema 1.0 */ /* TODO: What to do with the timezone? */ *retValue = xmlMalloc(6); if (*retValue == NULL) return(-1); snprintf((char *) *retValue, 6, "--%02u", val->value.date.mon); } break; case XML_SCHEMAS_GDAY: { /* TODO: Unclear in XML Schema 1.0 */ /* TODO: What to do with the timezone? */ *retValue = xmlMalloc(6); if (*retValue == NULL) return(-1); snprintf((char *) *retValue, 6, "---%02u", val->value.date.day); } break; case XML_SCHEMAS_GMONTHDAY: { /* TODO: Unclear in XML Schema 1.0 */ /* TODO: What to do with the timezone? */ *retValue = xmlMalloc(8); if (*retValue == NULL) return(-1); snprintf((char *) *retValue, 8, "--%02u-%02u", val->value.date.mon, val->value.date.day); } break; case XML_SCHEMAS_GYEARMONTH: { char buf[35]; /* TODO: Unclear in XML Schema 1.0 */ /* TODO: What to do with the timezone? */ if (val->value.date.year < 0) snprintf(buf, 35, "-%04ld-%02u", labs(val->value.date.year), val->value.date.mon); else snprintf(buf, 35, "%04ld-%02u", val->value.date.year, val->value.date.mon); *retValue = BAD_CAST xmlStrdup(BAD_CAST buf); } break; case XML_SCHEMAS_TIME: { char buf[30]; if (val->value.date.tz_flag) { xmlSchemaValPtr norm; norm = xmlSchemaDateNormalize(val, 0); if (norm == NULL) return (-1); /* * TODO: Check if "%.14g" is portable. */ snprintf(buf, 30, "%02u:%02u:%02.14gZ", norm->value.date.hour, norm->value.date.min, norm->value.date.sec); xmlSchemaFreeValue(norm); } else { snprintf(buf, 30, "%02u:%02u:%02.14g", val->value.date.hour, val->value.date.min, val->value.date.sec); } *retValue = BAD_CAST xmlStrdup(BAD_CAST buf); } break; case XML_SCHEMAS_DATE: { char buf[30]; if (val->value.date.tz_flag) { xmlSchemaValPtr norm; norm = xmlSchemaDateNormalize(val, 0); if (norm == NULL) return (-1); /* * TODO: Append the canonical value of the * recoverable timezone and not "Z". */ snprintf(buf, 30, "%04ld:%02u:%02uZ", norm->value.date.year, norm->value.date.mon, norm->value.date.day); xmlSchemaFreeValue(norm); } else { snprintf(buf, 30, "%04ld:%02u:%02u", val->value.date.year, val->value.date.mon, val->value.date.day); } *retValue = BAD_CAST xmlStrdup(BAD_CAST buf); } break; case XML_SCHEMAS_DATETIME: { char buf[50]; if (val->value.date.tz_flag) { xmlSchemaValPtr norm; norm = xmlSchemaDateNormalize(val, 0); if (norm == NULL) return (-1); /* * TODO: Check if "%.14g" is portable. */ snprintf(buf, 50, "%04ld:%02u:%02uT%02u:%02u:%02.14gZ", norm->value.date.year, norm->value.date.mon, norm->value.date.day, norm->value.date.hour, norm->value.date.min, norm->value.date.sec); xmlSchemaFreeValue(norm); } else { snprintf(buf, 50, "%04ld:%02u:%02uT%02u:%02u:%02.14g", val->value.date.year, val->value.date.mon, val->value.date.day, val->value.date.hour, val->value.date.min, val->value.date.sec); } *retValue = BAD_CAST xmlStrdup(BAD_CAST buf); } break; case XML_SCHEMAS_HEXBINARY: *retValue = BAD_CAST xmlStrdup(BAD_CAST val->value.hex.str); break; case XML_SCHEMAS_BASE64BINARY: /* * TODO: Is the following spec piece implemented?: * SPEC: "Note: For some values the canonical form defined * above does not conform to [RFC 2045], which requires breaking * with linefeeds at appropriate intervals." */ *retValue = BAD_CAST xmlStrdup(BAD_CAST val->value.base64.str); break; case XML_SCHEMAS_FLOAT: { char buf[30]; /* * |m| < 16777216, -149 <= e <= 104. * TODO: Handle, NaN, INF, -INF. The format is not * yet conformant. The c type float does not cover * the whole range. */ snprintf(buf, 30, "%01.14e", val->value.f); *retValue = BAD_CAST xmlStrdup(BAD_CAST buf); } break; case XML_SCHEMAS_DOUBLE: { char buf[40]; /* |m| < 9007199254740992, -1075 <= e <= 970 */ /* * TODO: Handle, NaN, INF, -INF. The format is not * yet conformant. The c type float does not cover * the whole range. */ snprintf(buf, 40, "%01.14e", val->value.d); *retValue = BAD_CAST xmlStrdup(BAD_CAST buf); } break; default: *retValue = BAD_CAST xmlStrdup(BAD_CAST "???"); return (1); } if (*retValue == NULL) return(-1); return (0); } /** * xmlSchemaGetCanonValueWhtsp: * @val: the precomputed value * @retValue: the returned value * @ws: the whitespace type of the value * * Get a the cononical representation of the value. * The caller has to free the returned @retValue. * * Returns 0 if the value could be built, 1 if the value type is * not supported yet and -1 in case of API errors. */ int xmlSchemaGetCanonValueWhtsp(xmlSchemaValPtr val, const xmlChar **retValue, xmlSchemaWhitespaceValueType ws) { if ((retValue == NULL) || (val == NULL)) return (-1); if ((ws == XML_SCHEMA_WHITESPACE_UNKNOWN) || (ws > XML_SCHEMA_WHITESPACE_COLLAPSE)) return (-1); *retValue = NULL; switch (val->type) { case XML_SCHEMAS_STRING: if (val->value.str == NULL) *retValue = BAD_CAST xmlStrdup(BAD_CAST ""); else if (ws == XML_SCHEMA_WHITESPACE_COLLAPSE) *retValue = xmlSchemaCollapseString(val->value.str); else if (ws == XML_SCHEMA_WHITESPACE_REPLACE) *retValue = xmlSchemaWhiteSpaceReplace(val->value.str); if ((*retValue) == NULL) *retValue = BAD_CAST xmlStrdup(val->value.str); break; case XML_SCHEMAS_NORMSTRING: if (val->value.str == NULL) *retValue = BAD_CAST xmlStrdup(BAD_CAST ""); else { if (ws == XML_SCHEMA_WHITESPACE_COLLAPSE) *retValue = xmlSchemaCollapseString(val->value.str); else *retValue = xmlSchemaWhiteSpaceReplace(val->value.str); if ((*retValue) == NULL) *retValue = BAD_CAST xmlStrdup(val->value.str); } break; default: return (xmlSchemaGetCanonValue(val, retValue)); } return (0); } /** * xmlSchemaGetValType: * @val: a schemas value * * Accessor for the type of a value * * Returns the xmlSchemaValType of the value */ xmlSchemaValType xmlSchemaGetValType(xmlSchemaValPtr val) { if (val == NULL) return(XML_SCHEMAS_UNKNOWN); return (val->type); } #define bottom_xmlschemastypes #include "elfgcchack.h" #endif /* LIBXML_SCHEMAS_ENABLED */ xdmf-3.0+git20160803/Utilities/vtklibxml2/triop.h0000640000175000017500000001315013003006557021451 0ustar alastairalastair/************************************************************************* * * Id: triop.h 1886 2003-04-03 15:28:28Z veillard * * Copyright (C) 2000 Bjorn Reese and Daniel Stenberg. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. * ************************************************************************ * * Private functions, types, etc. used for callback functions. * * The ref pointer is an opaque type and should remain as such. * Private data must only be accessible through the getter and * setter functions. * ************************************************************************/ #ifndef TRIO_TRIOP_H #define TRIO_TRIOP_H #include "triodef.h" #include #if defined(TRIO_COMPILER_ANCIENT) # include #else # include #endif #ifdef __cplusplus extern "C" { #endif #ifndef TRIO_C99 # define TRIO_C99 1 #endif #ifndef TRIO_BSD # define TRIO_BSD 1 #endif #ifndef TRIO_GNU # define TRIO_GNU 1 #endif #ifndef TRIO_MISC # define TRIO_MISC 1 #endif #ifndef TRIO_UNIX98 # define TRIO_UNIX98 1 #endif #ifndef TRIO_MICROSOFT # define TRIO_MICROSOFT 1 #endif #ifndef TRIO_EXTENSION # define TRIO_EXTENSION 1 #endif #ifndef TRIO_WIDECHAR /* Does not work yet. Do not enable */ # define TRIO_WIDECHAR 0 #endif #ifndef TRIO_ERRORS # define TRIO_ERRORS 1 #endif #ifndef TRIO_MALLOC # define TRIO_MALLOC(n) malloc(n) #endif #ifndef TRIO_REALLOC # define TRIO_REALLOC(x,n) realloc((x),(n)) #endif #ifndef TRIO_FREE # define TRIO_FREE(x) free(x) #endif /************************************************************************* * User-defined specifiers */ typedef int (*trio_callback_t) TRIO_PROTO((trio_pointer_t)); trio_pointer_t trio_register TRIO_PROTO((trio_callback_t callback, const char *name)); void trio_unregister TRIO_PROTO((trio_pointer_t handle)); TRIO_CONST char *trio_get_format TRIO_PROTO((trio_pointer_t ref)); trio_pointer_t trio_get_argument TRIO_PROTO((trio_pointer_t ref)); /* Modifiers */ int trio_get_width TRIO_PROTO((trio_pointer_t ref)); void trio_set_width TRIO_PROTO((trio_pointer_t ref, int width)); int trio_get_precision TRIO_PROTO((trio_pointer_t ref)); void trio_set_precision TRIO_PROTO((trio_pointer_t ref, int precision)); int trio_get_base TRIO_PROTO((trio_pointer_t ref)); void trio_set_base TRIO_PROTO((trio_pointer_t ref, int base)); int trio_get_padding TRIO_PROTO((trio_pointer_t ref)); void trio_set_padding TRIO_PROTO((trio_pointer_t ref, int is_padding)); int trio_get_short TRIO_PROTO((trio_pointer_t ref)); /* h */ void trio_set_shortshort TRIO_PROTO((trio_pointer_t ref, int is_shortshort)); int trio_get_shortshort TRIO_PROTO((trio_pointer_t ref)); /* hh */ void trio_set_short TRIO_PROTO((trio_pointer_t ref, int is_short)); int trio_get_long TRIO_PROTO((trio_pointer_t ref)); /* l */ void trio_set_long TRIO_PROTO((trio_pointer_t ref, int is_long)); int trio_get_longlong TRIO_PROTO((trio_pointer_t ref)); /* ll */ void trio_set_longlong TRIO_PROTO((trio_pointer_t ref, int is_longlong)); int trio_get_longdouble TRIO_PROTO((trio_pointer_t ref)); /* L */ void trio_set_longdouble TRIO_PROTO((trio_pointer_t ref, int is_longdouble)); int trio_get_alternative TRIO_PROTO((trio_pointer_t ref)); /* # */ void trio_set_alternative TRIO_PROTO((trio_pointer_t ref, int is_alternative)); int trio_get_alignment TRIO_PROTO((trio_pointer_t ref)); /* - */ void trio_set_alignment TRIO_PROTO((trio_pointer_t ref, int is_leftaligned)); int trio_get_spacing TRIO_PROTO((trio_pointer_t ref)); /* TRIO_PROTO((space) */ void trio_set_spacing TRIO_PROTO((trio_pointer_t ref, int is_space)); int trio_get_sign TRIO_PROTO((trio_pointer_t ref)); /* + */ void trio_set_sign TRIO_PROTO((trio_pointer_t ref, int is_showsign)); int trio_get_quote TRIO_PROTO((trio_pointer_t ref)); /* ' */ void trio_set_quote TRIO_PROTO((trio_pointer_t ref, int is_quote)); int trio_get_upper TRIO_PROTO((trio_pointer_t ref)); void trio_set_upper TRIO_PROTO((trio_pointer_t ref, int is_upper)); #if TRIO_C99 int trio_get_largest TRIO_PROTO((trio_pointer_t ref)); /* j */ void trio_set_largest TRIO_PROTO((trio_pointer_t ref, int is_largest)); int trio_get_ptrdiff TRIO_PROTO((trio_pointer_t ref)); /* t */ void trio_set_ptrdiff TRIO_PROTO((trio_pointer_t ref, int is_ptrdiff)); int trio_get_size TRIO_PROTO((trio_pointer_t ref)); /* z / Z */ void trio_set_size TRIO_PROTO((trio_pointer_t ref, int is_size)); #endif /* Printing */ int trio_print_ref TRIO_PROTO((trio_pointer_t ref, const char *format, ...)); int trio_vprint_ref TRIO_PROTO((trio_pointer_t ref, const char *format, va_list args)); int trio_printv_ref TRIO_PROTO((trio_pointer_t ref, const char *format, trio_pointer_t *args)); void trio_print_int TRIO_PROTO((trio_pointer_t ref, int number)); void trio_print_uint TRIO_PROTO((trio_pointer_t ref, unsigned int number)); /* void trio_print_long TRIO_PROTO((trio_pointer_t ref, long number)); */ /* void trio_print_ulong TRIO_PROTO((trio_pointer_t ref, unsigned long number)); */ void trio_print_double TRIO_PROTO((trio_pointer_t ref, double number)); void trio_print_string TRIO_PROTO((trio_pointer_t ref, char *string)); void trio_print_pointer TRIO_PROTO((trio_pointer_t ref, trio_pointer_t pointer)); #ifdef __cplusplus } /* extern "C" */ #endif #endif /* TRIO_TRIOP_H */ xdmf-3.0+git20160803/Utilities/vtklibxml2/legacy.c0000640000175000017500000011442613003006557021563 0ustar alastairalastair/* * legacy.c: set of deprecated routines, not to be used anymore but * kept purely for ABI compatibility * * See Copyright for the status of this software. * * daniel@veillard.com */ #define IN_LIBXML #include "libxml.h" #ifdef LIBXML_LEGACY_ENABLED #include #include #include #include #include #include void xmlUpgradeOldNs(xmlDocPtr doc); /************************************************************************ * * * Deprecated functions kept for compatibility * * * ************************************************************************/ #ifdef LIBXML_HTML_ENABLED xmlChar *htmlDecodeEntities(htmlParserCtxtPtr ctxt, int len, xmlChar end, xmlChar end2, xmlChar end3); /** * htmlDecodeEntities: * @ctxt: the parser context * @len: the len to decode (in bytes !), -1 for no size limit * @end: an end marker xmlChar, 0 if none * @end2: an end marker xmlChar, 0 if none * @end3: an end marker xmlChar, 0 if none * * Substitute the HTML entities by their value * * DEPRECATED !!!! * * Returns A newly allocated string with the substitution done. The caller * must deallocate it ! */ xmlChar * htmlDecodeEntities(htmlParserCtxtPtr ctxt ATTRIBUTE_UNUSED, int len ATTRIBUTE_UNUSED, xmlChar end ATTRIBUTE_UNUSED, xmlChar end2 ATTRIBUTE_UNUSED, xmlChar end3 ATTRIBUTE_UNUSED) { static int deprecated = 0; if (!deprecated) { xmlGenericError(xmlGenericErrorContext, "htmlDecodeEntities() deprecated function reached\n"); deprecated = 1; } return (NULL); } #endif /** * xmlInitializePredefinedEntities: * * Set up the predefined entities. * Deprecated call */ void xmlInitializePredefinedEntities(void) { } /** * xmlCleanupPredefinedEntities: * * Cleanup up the predefined entities table. * Deprecated call */ void xmlCleanupPredefinedEntities(void) { } static const char *xmlFeaturesList[] = { "validate", "load subset", "keep blanks", "disable SAX", "fetch external entities", "substitute entities", "gather line info", "user data", "is html", "is standalone", "stop parser", "document", "is well formed", "is valid", "SAX block", "SAX function internalSubset", "SAX function isStandalone", "SAX function hasInternalSubset", "SAX function hasExternalSubset", "SAX function resolveEntity", "SAX function getEntity", "SAX function entityDecl", "SAX function notationDecl", "SAX function attributeDecl", "SAX function elementDecl", "SAX function unparsedEntityDecl", "SAX function setDocumentLocator", "SAX function startDocument", "SAX function endDocument", "SAX function startElement", "SAX function endElement", "SAX function reference", "SAX function characters", "SAX function ignorableWhitespace", "SAX function processingInstruction", "SAX function comment", "SAX function warning", "SAX function error", "SAX function fatalError", "SAX function getParameterEntity", "SAX function cdataBlock", "SAX function externalSubset", }; /** * xmlGetFeaturesList: * @len: the length of the features name array (input/output) * @result: an array of string to be filled with the features name. * * Copy at most *@len feature names into the @result array * * Returns -1 in case or error, or the total number of features, * len is updated with the number of strings copied, * strings must not be deallocated */ int xmlGetFeaturesList(int *len, const char **result) { int ret, i; ret = sizeof(xmlFeaturesList) / sizeof(xmlFeaturesList[0]); if ((len == NULL) || (result == NULL)) return (ret); if ((*len < 0) || (*len >= 1000)) return (-1); if (*len > ret) *len = ret; for (i = 0; i < *len; i++) result[i] = xmlFeaturesList[i]; return (ret); } /** * xmlGetFeature: * @ctxt: an XML/HTML parser context * @name: the feature name * @result: location to store the result * * Read the current value of one feature of this parser instance * * Returns -1 in case or error, 0 otherwise */ int xmlGetFeature(xmlParserCtxtPtr ctxt, const char *name, void *result) { if ((ctxt == NULL) || (name == NULL) || (result == NULL)) return (-1); if (!strcmp(name, "validate")) { *((int *) result) = ctxt->validate; } else if (!strcmp(name, "keep blanks")) { *((int *) result) = ctxt->keepBlanks; } else if (!strcmp(name, "disable SAX")) { *((int *) result) = ctxt->disableSAX; } else if (!strcmp(name, "fetch external entities")) { *((int *) result) = ctxt->loadsubset; } else if (!strcmp(name, "substitute entities")) { *((int *) result) = ctxt->replaceEntities; } else if (!strcmp(name, "gather line info")) { *((int *) result) = ctxt->record_info; } else if (!strcmp(name, "user data")) { *((void **) result) = ctxt->userData; } else if (!strcmp(name, "is html")) { *((int *) result) = ctxt->html; } else if (!strcmp(name, "is standalone")) { *((int *) result) = ctxt->standalone; } else if (!strcmp(name, "document")) { *((xmlDocPtr *) result) = ctxt->myDoc; } else if (!strcmp(name, "is well formed")) { *((int *) result) = ctxt->wellFormed; } else if (!strcmp(name, "is valid")) { *((int *) result) = ctxt->valid; } else if (!strcmp(name, "SAX block")) { *((xmlSAXHandlerPtr *) result) = ctxt->sax; } else if (!strcmp(name, "SAX function internalSubset")) { *((internalSubsetSAXFunc *) result) = ctxt->sax->internalSubset; } else if (!strcmp(name, "SAX function isStandalone")) { *((isStandaloneSAXFunc *) result) = ctxt->sax->isStandalone; } else if (!strcmp(name, "SAX function hasInternalSubset")) { *((hasInternalSubsetSAXFunc *) result) = ctxt->sax->hasInternalSubset; } else if (!strcmp(name, "SAX function hasExternalSubset")) { *((hasExternalSubsetSAXFunc *) result) = ctxt->sax->hasExternalSubset; } else if (!strcmp(name, "SAX function resolveEntity")) { *((resolveEntitySAXFunc *) result) = ctxt->sax->resolveEntity; } else if (!strcmp(name, "SAX function getEntity")) { *((getEntitySAXFunc *) result) = ctxt->sax->getEntity; } else if (!strcmp(name, "SAX function entityDecl")) { *((entityDeclSAXFunc *) result) = ctxt->sax->entityDecl; } else if (!strcmp(name, "SAX function notationDecl")) { *((notationDeclSAXFunc *) result) = ctxt->sax->notationDecl; } else if (!strcmp(name, "SAX function attributeDecl")) { *((attributeDeclSAXFunc *) result) = ctxt->sax->attributeDecl; } else if (!strcmp(name, "SAX function elementDecl")) { *((elementDeclSAXFunc *) result) = ctxt->sax->elementDecl; } else if (!strcmp(name, "SAX function unparsedEntityDecl")) { *((unparsedEntityDeclSAXFunc *) result) = ctxt->sax->unparsedEntityDecl; } else if (!strcmp(name, "SAX function setDocumentLocator")) { *((setDocumentLocatorSAXFunc *) result) = ctxt->sax->setDocumentLocator; } else if (!strcmp(name, "SAX function startDocument")) { *((startDocumentSAXFunc *) result) = ctxt->sax->startDocument; } else if (!strcmp(name, "SAX function endDocument")) { *((endDocumentSAXFunc *) result) = ctxt->sax->endDocument; } else if (!strcmp(name, "SAX function startElement")) { *((startElementSAXFunc *) result) = ctxt->sax->startElement; } else if (!strcmp(name, "SAX function endElement")) { *((endElementSAXFunc *) result) = ctxt->sax->endElement; } else if (!strcmp(name, "SAX function reference")) { *((referenceSAXFunc *) result) = ctxt->sax->reference; } else if (!strcmp(name, "SAX function characters")) { *((charactersSAXFunc *) result) = ctxt->sax->characters; } else if (!strcmp(name, "SAX function ignorableWhitespace")) { *((ignorableWhitespaceSAXFunc *) result) = ctxt->sax->ignorableWhitespace; } else if (!strcmp(name, "SAX function processingInstruction")) { *((processingInstructionSAXFunc *) result) = ctxt->sax->processingInstruction; } else if (!strcmp(name, "SAX function comment")) { *((commentSAXFunc *) result) = ctxt->sax->comment; } else if (!strcmp(name, "SAX function warning")) { *((warningSAXFunc *) result) = ctxt->sax->warning; } else if (!strcmp(name, "SAX function error")) { *((errorSAXFunc *) result) = ctxt->sax->error; } else if (!strcmp(name, "SAX function fatalError")) { *((fatalErrorSAXFunc *) result) = ctxt->sax->fatalError; } else if (!strcmp(name, "SAX function getParameterEntity")) { *((getParameterEntitySAXFunc *) result) = ctxt->sax->getParameterEntity; } else if (!strcmp(name, "SAX function cdataBlock")) { *((cdataBlockSAXFunc *) result) = ctxt->sax->cdataBlock; } else if (!strcmp(name, "SAX function externalSubset")) { *((externalSubsetSAXFunc *) result) = ctxt->sax->externalSubset; } else { return (-1); } return (0); } /** * xmlSetFeature: * @ctxt: an XML/HTML parser context * @name: the feature name * @value: pointer to the location of the new value * * Change the current value of one feature of this parser instance * * Returns -1 in case or error, 0 otherwise */ int xmlSetFeature(xmlParserCtxtPtr ctxt, const char *name, void *value) { if ((ctxt == NULL) || (name == NULL) || (value == NULL)) return (-1); if (!strcmp(name, "validate")) { int newvalidate = *((int *) value); if ((!ctxt->validate) && (newvalidate != 0)) { if (ctxt->vctxt.warning == NULL) ctxt->vctxt.warning = xmlParserValidityWarning; if (ctxt->vctxt.error == NULL) ctxt->vctxt.error = xmlParserValidityError; ctxt->vctxt.nodeMax = 0; } ctxt->validate = newvalidate; } else if (!strcmp(name, "keep blanks")) { ctxt->keepBlanks = *((int *) value); } else if (!strcmp(name, "disable SAX")) { ctxt->disableSAX = *((int *) value); } else if (!strcmp(name, "fetch external entities")) { ctxt->loadsubset = *((int *) value); } else if (!strcmp(name, "substitute entities")) { ctxt->replaceEntities = *((int *) value); } else if (!strcmp(name, "gather line info")) { ctxt->record_info = *((int *) value); } else if (!strcmp(name, "user data")) { ctxt->userData = *((void **) value); } else if (!strcmp(name, "is html")) { ctxt->html = *((int *) value); } else if (!strcmp(name, "is standalone")) { ctxt->standalone = *((int *) value); } else if (!strcmp(name, "document")) { ctxt->myDoc = *((xmlDocPtr *) value); } else if (!strcmp(name, "is well formed")) { ctxt->wellFormed = *((int *) value); } else if (!strcmp(name, "is valid")) { ctxt->valid = *((int *) value); } else if (!strcmp(name, "SAX block")) { ctxt->sax = *((xmlSAXHandlerPtr *) value); } else if (!strcmp(name, "SAX function internalSubset")) { ctxt->sax->internalSubset = *((internalSubsetSAXFunc *) value); } else if (!strcmp(name, "SAX function isStandalone")) { ctxt->sax->isStandalone = *((isStandaloneSAXFunc *) value); } else if (!strcmp(name, "SAX function hasInternalSubset")) { ctxt->sax->hasInternalSubset = *((hasInternalSubsetSAXFunc *) value); } else if (!strcmp(name, "SAX function hasExternalSubset")) { ctxt->sax->hasExternalSubset = *((hasExternalSubsetSAXFunc *) value); } else if (!strcmp(name, "SAX function resolveEntity")) { ctxt->sax->resolveEntity = *((resolveEntitySAXFunc *) value); } else if (!strcmp(name, "SAX function getEntity")) { ctxt->sax->getEntity = *((getEntitySAXFunc *) value); } else if (!strcmp(name, "SAX function entityDecl")) { ctxt->sax->entityDecl = *((entityDeclSAXFunc *) value); } else if (!strcmp(name, "SAX function notationDecl")) { ctxt->sax->notationDecl = *((notationDeclSAXFunc *) value); } else if (!strcmp(name, "SAX function attributeDecl")) { ctxt->sax->attributeDecl = *((attributeDeclSAXFunc *) value); } else if (!strcmp(name, "SAX function elementDecl")) { ctxt->sax->elementDecl = *((elementDeclSAXFunc *) value); } else if (!strcmp(name, "SAX function unparsedEntityDecl")) { ctxt->sax->unparsedEntityDecl = *((unparsedEntityDeclSAXFunc *) value); } else if (!strcmp(name, "SAX function setDocumentLocator")) { ctxt->sax->setDocumentLocator = *((setDocumentLocatorSAXFunc *) value); } else if (!strcmp(name, "SAX function startDocument")) { ctxt->sax->startDocument = *((startDocumentSAXFunc *) value); } else if (!strcmp(name, "SAX function endDocument")) { ctxt->sax->endDocument = *((endDocumentSAXFunc *) value); } else if (!strcmp(name, "SAX function startElement")) { ctxt->sax->startElement = *((startElementSAXFunc *) value); } else if (!strcmp(name, "SAX function endElement")) { ctxt->sax->endElement = *((endElementSAXFunc *) value); } else if (!strcmp(name, "SAX function reference")) { ctxt->sax->reference = *((referenceSAXFunc *) value); } else if (!strcmp(name, "SAX function characters")) { ctxt->sax->characters = *((charactersSAXFunc *) value); } else if (!strcmp(name, "SAX function ignorableWhitespace")) { ctxt->sax->ignorableWhitespace = *((ignorableWhitespaceSAXFunc *) value); } else if (!strcmp(name, "SAX function processingInstruction")) { ctxt->sax->processingInstruction = *((processingInstructionSAXFunc *) value); } else if (!strcmp(name, "SAX function comment")) { ctxt->sax->comment = *((commentSAXFunc *) value); } else if (!strcmp(name, "SAX function warning")) { ctxt->sax->warning = *((warningSAXFunc *) value); } else if (!strcmp(name, "SAX function error")) { ctxt->sax->error = *((errorSAXFunc *) value); } else if (!strcmp(name, "SAX function fatalError")) { ctxt->sax->fatalError = *((fatalErrorSAXFunc *) value); } else if (!strcmp(name, "SAX function getParameterEntity")) { ctxt->sax->getParameterEntity = *((getParameterEntitySAXFunc *) value); } else if (!strcmp(name, "SAX function cdataBlock")) { ctxt->sax->cdataBlock = *((cdataBlockSAXFunc *) value); } else if (!strcmp(name, "SAX function externalSubset")) { ctxt->sax->externalSubset = *((externalSubsetSAXFunc *) value); } else { return (-1); } return (0); } /** * xmlDecodeEntities: * @ctxt: the parser context * @len: the len to decode (in bytes !), -1 for no size limit * @what: combination of XML_SUBSTITUTE_REF and XML_SUBSTITUTE_PEREF * @end: an end marker xmlChar, 0 if none * @end2: an end marker xmlChar, 0 if none * @end3: an end marker xmlChar, 0 if none * * This function is deprecated, we now always process entities content * through xmlStringDecodeEntities * * TODO: remove it in next major release. * * [67] Reference ::= EntityRef | CharRef * * [69] PEReference ::= '%' Name ';' * * Returns A newly allocated string with the substitution done. The caller * must deallocate it ! */ xmlChar * xmlDecodeEntities(xmlParserCtxtPtr ctxt ATTRIBUTE_UNUSED, int len ATTRIBUTE_UNUSED, int what ATTRIBUTE_UNUSED, xmlChar end ATTRIBUTE_UNUSED, xmlChar end2 ATTRIBUTE_UNUSED, xmlChar end3 ATTRIBUTE_UNUSED) { static int deprecated = 0; if (!deprecated) { xmlGenericError(xmlGenericErrorContext, "xmlDecodeEntities() deprecated function reached\n"); deprecated = 1; } return (NULL); } /** * xmlNamespaceParseNCName: * @ctxt: an XML parser context * * parse an XML namespace name. * * TODO: this seems not in use anymore, the namespace handling is done on * top of the SAX interfaces, i.e. not on raw input. * * [NS 3] NCName ::= (Letter | '_') (NCNameChar)* * * [NS 4] NCNameChar ::= Letter | Digit | '.' | '-' | '_' | * CombiningChar | Extender * * Returns the namespace name or NULL */ xmlChar * xmlNamespaceParseNCName(xmlParserCtxtPtr ctxt ATTRIBUTE_UNUSED) { static int deprecated = 0; if (!deprecated) { xmlGenericError(xmlGenericErrorContext, "xmlNamespaceParseNCName() deprecated function reached\n"); deprecated = 1; } return (NULL); } /** * xmlNamespaceParseQName: * @ctxt: an XML parser context * @prefix: a xmlChar ** * * TODO: this seems not in use anymore, the namespace handling is done on * top of the SAX interfaces, i.e. not on raw input. * * parse an XML qualified name * * [NS 5] QName ::= (Prefix ':')? LocalPart * * [NS 6] Prefix ::= NCName * * [NS 7] LocalPart ::= NCName * * Returns the local part, and prefix is updated * to get the Prefix if any. */ xmlChar * xmlNamespaceParseQName(xmlParserCtxtPtr ctxt ATTRIBUTE_UNUSED, xmlChar ** prefix ATTRIBUTE_UNUSED) { static int deprecated = 0; if (!deprecated) { xmlGenericError(xmlGenericErrorContext, "xmlNamespaceParseQName() deprecated function reached\n"); deprecated = 1; } return (NULL); } /** * xmlNamespaceParseNSDef: * @ctxt: an XML parser context * * parse a namespace prefix declaration * * TODO: this seems not in use anymore, the namespace handling is done on * top of the SAX interfaces, i.e. not on raw input. * * [NS 1] NSDef ::= PrefixDef Eq SystemLiteral * * [NS 2] PrefixDef ::= 'xmlns' (':' NCName)? * * Returns the namespace name */ xmlChar * xmlNamespaceParseNSDef(xmlParserCtxtPtr ctxt ATTRIBUTE_UNUSED) { static int deprecated = 0; if (!deprecated) { xmlGenericError(xmlGenericErrorContext, "xmlNamespaceParseNSDef() deprecated function reached\n"); deprecated = 1; } return (NULL); } /** * xmlParseQuotedString: * @ctxt: an XML parser context * * Parse and return a string between quotes or doublequotes * * TODO: Deprecated, to be removed at next drop of binary compatibility * * Returns the string parser or NULL. */ xmlChar * xmlParseQuotedString(xmlParserCtxtPtr ctxt ATTRIBUTE_UNUSED) { static int deprecated = 0; if (!deprecated) { xmlGenericError(xmlGenericErrorContext, "xmlParseQuotedString() deprecated function reached\n"); deprecated = 1; } return (NULL); } /** * xmlParseNamespace: * @ctxt: an XML parser context * * xmlParseNamespace: parse specific PI ' #include #include #include #include #include "triodef.h" #include "triostr.h" /************************************************************************* * Definitions */ #if !defined(TRIO_STRING_PUBLIC) # define TRIO_STRING_PUBLIC TRIO_PUBLIC #endif #if !defined(TRIO_STRING_PRIVATE) # define TRIO_STRING_PRIVATE TRIO_PRIVATE #endif #if !defined(NULL) # define NULL 0 #endif #if !defined(NIL) # define NIL ((char)0) #endif #if !defined(FALSE) # define FALSE (1 == 0) # define TRUE (! FALSE) #endif #if !defined(BOOLEAN_T) # define BOOLEAN_T int #endif #if defined(TRIO_COMPILER_SUPPORTS_C99) # define USE_STRTOD # define USE_STRTOF #elif defined(TRIO_COMPILER_MSVC) # define USE_STRTOD #endif #if defined(TRIO_PLATFORM_UNIX) # define USE_STRCASECMP # define USE_STRNCASECMP # if defined(TRIO_PLATFORM_SUNOS) # define USE_SYS_ERRLIST # else # define USE_STRERROR # endif # if defined(TRIO_PLATFORM_QNX) # define strcasecmp(x,y) stricmp(x,y) # define strncasecmp(x,y,n) strnicmp(x,y,n) # endif #elif defined(TRIO_PLATFORM_WIN32) # define USE_STRCASECMP # define strcasecmp(x,y) strcmpi(x,y) #endif #if !(defined(TRIO_PLATFORM_SUNOS)) # define USE_TOLOWER # define USE_TOUPPER #endif /************************************************************************* * Structures */ struct _trio_string_t { char *content; size_t length; size_t allocated; }; /************************************************************************* * Constants */ #if !defined(TRIO_MINIMAL) static TRIO_CONST char rcsid[] = "@(#)$Id: triostr.c,v 1.2 2007-04-24 17:23:33 king Exp $"; #endif /************************************************************************* * Static String Functions */ #if defined(TRIO_DOCUMENTATION) # include "doc/doc_static.h" #endif /** @addtogroup StaticStrings @{ */ /** Create new string. @param size Size of new string. @return Pointer to string, or NULL if allocation failed. */ TRIO_STRING_PUBLIC char * trio_create TRIO_ARGS1((size), size_t size) { return (char *)TRIO_MALLOC(size); } /** Destroy string. @param string String to be freed. */ TRIO_STRING_PUBLIC void trio_destroy TRIO_ARGS1((string), char *string) { if (string) { TRIO_FREE(string); } } /** Count the number of characters in a string. @param string String to measure. @return Number of characters in @string. */ TRIO_STRING_PUBLIC size_t trio_length TRIO_ARGS1((string), TRIO_CONST char *string) { return strlen(string); } #if !defined(TRIO_MINIMAL) /** Append @p source at the end of @p target. @param target Target string. @param source Source string. @return Boolean value indicating success or failure. @pre @p target must point to a memory chunk with sufficient room to contain the @p target string and @p source string. @pre No boundary checking is performed, so insufficient memory will result in a buffer overrun. @post @p target will be zero terminated. */ TRIO_STRING_PUBLIC int trio_append TRIO_ARGS2((target, source), char *target, TRIO_CONST char *source) { assert(target); assert(source); return (strcat(target, source) != NULL); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /** Append at most @p max characters from @p source to @p target. @param target Target string. @param max Maximum number of characters to append. @param source Source string. @return Boolean value indicating success or failure. @pre @p target must point to a memory chuck with sufficient room to contain the @p target string and the @p source string (at most @p max characters). @pre No boundary checking is performed, so insufficient memory will result in a buffer overrun. @post @p target will be zero terminated. */ TRIO_STRING_PUBLIC int trio_append_max TRIO_ARGS3((target, max, source), char *target, size_t max, TRIO_CONST char *source) { size_t length; assert(target); assert(source); length = trio_length(target); if (max > length) { strncat(target, source, max - length - 1); } return TRUE; } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /** Determine if a string contains a substring. @param string String to be searched. @param substring String to be found. @return Boolean value indicating success or failure. */ TRIO_STRING_PUBLIC int trio_contains TRIO_ARGS2((string, substring), TRIO_CONST char *string, TRIO_CONST char *substring) { assert(string); assert(substring); return (0 != strstr(string, substring)); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /** Copy @p source to @p target. @param target Target string. @param source Source string. @return Boolean value indicating success or failure. @pre @p target must point to a memory chunk with sufficient room to contain the @p source string. @pre No boundary checking is performed, so insufficient memory will result in a buffer overrun. @post @p target will be zero terminated. */ TRIO_STRING_PUBLIC int trio_copy TRIO_ARGS2((target, source), char *target, TRIO_CONST char *source) { assert(target); assert(source); (void)strcpy(target, source); return TRUE; } #endif /* !defined(TRIO_MINIMAL) */ /** Copy at most @p max characters from @p source to @p target. @param target Target string. @param max Maximum number of characters to append. @param source Source string. @return Boolean value indicating success or failure. @pre @p target must point to a memory chunk with sufficient room to contain the @p source string (at most @p max characters). @pre No boundary checking is performed, so insufficient memory will result in a buffer overrun. @post @p target will be zero terminated. */ TRIO_STRING_PUBLIC int trio_copy_max TRIO_ARGS3((target, max, source), char *target, size_t max, TRIO_CONST char *source) { assert(target); assert(source); assert(max > 0); /* Includes != 0 */ (void)strncpy(target, source, max - 1); target[max - 1] = (char)0; return TRUE; } /* * TrioDuplicateMax */ TRIO_STRING_PRIVATE char * TrioDuplicateMax TRIO_ARGS2((source, size), TRIO_CONST char *source, size_t size) { char *target; assert(source); /* Make room for string plus a terminating zero */ size++; target = trio_create(size); if (target) { trio_copy_max(target, size, source); } return target; } /** Duplicate @p source. @param source Source string. @return A copy of the @p source string. @post @p target will be zero terminated. */ TRIO_STRING_PUBLIC char * trio_duplicate TRIO_ARGS1((source), TRIO_CONST char *source) { return TrioDuplicateMax(source, trio_length(source)); } #if !defined(TRIO_MINIMAL) /** Duplicate at most @p max characters of @p source. @param source Source string. @param max Maximum number of characters to duplicate. @return A copy of the @p source string. @post @p target will be zero terminated. */ TRIO_STRING_PUBLIC char * trio_duplicate_max TRIO_ARGS2((source, max), TRIO_CONST char *source, size_t max) { size_t length; assert(source); assert(max > 0); length = trio_length(source); if (length > max) { length = max; } return TrioDuplicateMax(source, length); } #endif /* !defined(TRIO_MINIMAL) */ /** Compare if two strings are equal. @param first First string. @param second Second string. @return Boolean indicating whether the two strings are equal or not. Case-insensitive comparison. */ TRIO_STRING_PUBLIC int trio_equal TRIO_ARGS2((first, second), TRIO_CONST char *first, TRIO_CONST char *second) { assert(first); assert(second); if ((first != NULL) && (second != NULL)) { #if defined(USE_STRCASECMP) return (0 == strcasecmp(first, second)); #else while ((*first != NIL) && (*second != NIL)) { if (trio_to_upper(*first) != trio_to_upper(*second)) { break; } first++; second++; } return ((*first == NIL) && (*second == NIL)); #endif } return FALSE; } /** Compare if two strings are equal. @param first First string. @param second Second string. @return Boolean indicating whether the two strings are equal or not. Case-sensitive comparison. */ TRIO_STRING_PUBLIC int trio_equal_case TRIO_ARGS2((first, second), TRIO_CONST char *first, TRIO_CONST char *second) { assert(first); assert(second); if ((first != NULL) && (second != NULL)) { return (0 == strcmp(first, second)); } return FALSE; } #if !defined(TRIO_MINIMAL) /** Compare if two strings up until the first @p max characters are equal. @param first First string. @param max Maximum number of characters to compare. @param second Second string. @return Boolean indicating whether the two strings are equal or not. Case-sensitive comparison. */ TRIO_STRING_PUBLIC int trio_equal_case_max TRIO_ARGS3((first, max, second), TRIO_CONST char *first, size_t max, TRIO_CONST char *second) { assert(first); assert(second); if ((first != NULL) && (second != NULL)) { return (0 == strncmp(first, second, max)); } return FALSE; } #endif /* !defined(TRIO_MINIMAL) */ /** Compare if two strings are equal. @param first First string. @param second Second string. @return Boolean indicating whether the two strings are equal or not. Collating characters are considered equal. */ TRIO_STRING_PUBLIC int trio_equal_locale TRIO_ARGS2((first, second), TRIO_CONST char *first, TRIO_CONST char *second) { assert(first); assert(second); #if defined(LC_COLLATE) return (strcoll(first, second) == 0); #else return trio_equal(first, second); #endif } /** Compare if two strings up until the first @p max characters are equal. @param first First string. @param max Maximum number of characters to compare. @param second Second string. @return Boolean indicating whether the two strings are equal or not. Case-insensitive comparison. */ TRIO_STRING_PUBLIC int trio_equal_max TRIO_ARGS3((first, max, second), TRIO_CONST char *first, size_t max, TRIO_CONST char *second) { assert(first); assert(second); if ((first != NULL) && (second != NULL)) { #if defined(USE_STRNCASECMP) return (0 == strncasecmp(first, second, max)); #else /* Not adequately tested yet */ size_t cnt = 0; while ((*first != NIL) && (*second != NIL) && (cnt <= max)) { if (trio_to_upper(*first) != trio_to_upper(*second)) { break; } first++; second++; cnt++; } return ((cnt == max) || ((*first == NIL) && (*second == NIL))); #endif } return FALSE; } /** Provide a textual description of an error code (errno). @param error_number Error number. @return Textual description of @p error_number. */ TRIO_STRING_PUBLIC TRIO_CONST char * trio_error TRIO_ARGS1((error_number), int error_number) { #if defined(USE_STRERROR) return strerror(error_number); #elif defined(USE_SYS_ERRLIST) extern char *sys_errlist[]; extern int sys_nerr; return ((error_number < 0) || (error_number >= sys_nerr)) ? "unknown" : sys_errlist[error_number]; #else return "unknown"; #endif } #if !defined(TRIO_MINIMAL) /** Format the date/time according to @p format. @param target Target string. @param max Maximum number of characters to format. @param format Formatting string. @param datetime Date/time structure. @return Number of formatted characters. The formatting string accepts the same specifiers as the standard C function strftime. */ TRIO_STRING_PUBLIC size_t trio_format_date_max TRIO_ARGS4((target, max, format, datetime), char *target, size_t max, TRIO_CONST char *format, TRIO_CONST struct tm *datetime) { assert(target); assert(format); assert(datetime); assert(max > 0); return strftime(target, max, format, datetime); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /** Calculate a hash value for a string. @param string String to be calculated on. @param type Hash function. @return Calculated hash value. @p type can be one of the following @li @c TRIO_HASH_PLAIN Plain hash function. */ TRIO_STRING_PUBLIC unsigned long trio_hash TRIO_ARGS2((string, type), TRIO_CONST char *string, int type) { unsigned long value = 0L; char ch; assert(string); switch (type) { case TRIO_HASH_PLAIN: while ( (ch = *string++) != NIL ) { value *= 31; value += (unsigned long)ch; } break; default: assert(FALSE); break; } return value; } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /** Find first occurrence of a character in a string. @param string String to be searched. @param character Character to be found. @param A pointer to the found character, or NULL if character was not found. */ TRIO_STRING_PUBLIC char * trio_index TRIO_ARGS2((string, character), TRIO_CONST char *string, int character) { assert(string); return strchr(string, character); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /** Find last occurrence of a character in a string. @param string String to be searched. @param character Character to be found. @param A pointer to the found character, or NULL if character was not found. */ TRIO_STRING_PUBLIC char * trio_index_last TRIO_ARGS2((string, character), TRIO_CONST char *string, int character) { assert(string); return strchr(string, character); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /** Convert the alphabetic letters in the string to lower-case. @param target String to be converted. @return Number of processed characters (converted or not). */ TRIO_STRING_PUBLIC int trio_lower TRIO_ARGS1((target), char *target) { assert(target); return trio_span_function(target, target, trio_to_lower); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /** Compare two strings using wildcards. @param string String to be searched. @param pattern Pattern, including wildcards, to search for. @return Boolean value indicating success or failure. Case-insensitive comparison. The following wildcards can be used @li @c * Match any number of characters. @li @c ? Match a single character. */ TRIO_STRING_PUBLIC int trio_match TRIO_ARGS2((string, pattern), TRIO_CONST char *string, TRIO_CONST char *pattern) { assert(string); assert(pattern); for (; ('*' != *pattern); ++pattern, ++string) { if (NIL == *string) { return (NIL == *pattern); } if ((trio_to_upper((int)*string) != trio_to_upper((int)*pattern)) && ('?' != *pattern)) { return FALSE; } } /* two-line patch to prevent *too* much recursiveness: */ while ('*' == pattern[1]) pattern++; do { if ( trio_match(string, &pattern[1]) ) { return TRUE; } } while (*string++); return FALSE; } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /** Compare two strings using wildcards. @param string String to be searched. @param pattern Pattern, including wildcards, to search for. @return Boolean value indicating success or failure. Case-sensitive comparison. The following wildcards can be used @li @c * Match any number of characters. @li @c ? Match a single character. */ TRIO_STRING_PUBLIC int trio_match_case TRIO_ARGS2((string, pattern), TRIO_CONST char *string, TRIO_CONST char *pattern) { assert(string); assert(pattern); for (; ('*' != *pattern); ++pattern, ++string) { if (NIL == *string) { return (NIL == *pattern); } if ((*string != *pattern) && ('?' != *pattern)) { return FALSE; } } /* two-line patch to prevent *too* much recursiveness: */ while ('*' == pattern[1]) pattern++; do { if ( trio_match_case(string, &pattern[1]) ) { return TRUE; } } while (*string++); return FALSE; } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /** Execute a function on each character in string. @param target Target string. @param source Source string. @param Function Function to be executed. @return Number of processed characters. */ TRIO_STRING_PUBLIC size_t trio_span_function TRIO_ARGS3((target, source, Function), char *target, TRIO_CONST char *source, int (*Function) TRIO_PROTO((int))) { size_t count = 0; assert(target); assert(source); assert(Function); while (*source != NIL) { *target++ = Function(*source++); count++; } return count; } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /** Search for a substring in a string. @param string String to be searched. @param substring String to be found. @return Pointer to first occurrence of @p substring in @p string, or NULL if no match was found. */ TRIO_STRING_PUBLIC char * trio_substring TRIO_ARGS2((string, substring), TRIO_CONST char *string, TRIO_CONST char *substring) { assert(string); assert(substring); return strstr(string, substring); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /** Search for a substring in the first @p max characters of a string. @param string String to be searched. @param max Maximum characters to be searched. @param substring String to be found. @return Pointer to first occurrence of @p substring in @p string, or NULL if no match was found. */ TRIO_STRING_PUBLIC char * trio_substring_max TRIO_ARGS3((string, max, substring), TRIO_CONST char *string, size_t max, TRIO_CONST char *substring) { size_t count; size_t size; char *result = NULL; assert(string); assert(substring); size = trio_length(substring); if (size <= max) { for (count = 0; count <= max - size; count++) { if (trio_equal_max(substring, size, &string[count])) { result = (char *)&string[count]; break; } } } return result; } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /** Tokenize string. @param string String to be tokenized. @param tokens String containing list of delimiting characters. @return Start of new token. @warning @p string will be destroyed. */ TRIO_STRING_PUBLIC char * trio_tokenize TRIO_ARGS2((string, delimiters), char *string, TRIO_CONST char *delimiters) { assert(delimiters); return strtok(string, delimiters); } #endif /* !defined(TRIO_MINIMAL) */ /** Convert string to floating-point number. @param source String to be converted. @param endp Pointer to end of the converted string. @return A floating-point number. The following Extended Backus-Naur form is used @verbatim double ::= [ ] ( | | ) [ [ ] ] number ::= 1*( ) digit ::= ( '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' ) exponential ::= ( 'e' | 'E' ) sign ::= ( '-' | '+' ) decimal_point ::= '.' @endverbatim */ /* FIXME: Add EBNF for hex-floats */ TRIO_STRING_PUBLIC trio_long_double_t trio_to_long_double TRIO_ARGS2((source, endp), TRIO_CONST char *source, char **endp) { #if defined(USE_STRTOLD) return strtold(source, endp); #else int isNegative = FALSE; int isExponentNegative = FALSE; trio_long_double_t integer = 0.0; trio_long_double_t fraction = 0.0; unsigned long exponent = 0; trio_long_double_t base; trio_long_double_t fracdiv = 1.0; trio_long_double_t value = 0.0; /* First try hex-floats */ if ((source[0] == '0') && ((source[1] == 'x') || (source[1] == 'X'))) { base = 16.0; source += 2; while (isxdigit((int)*source)) { integer *= base; integer += (isdigit((int)*source) ? (*source - '0') : 10 + (trio_to_upper((int)*source) - 'A')); source++; } if (*source == '.') { source++; while (isxdigit((int)*source)) { fracdiv /= base; fraction += fracdiv * (isdigit((int)*source) ? (*source - '0') : 10 + (trio_to_upper((int)*source) - 'A')); source++; } if ((*source == 'p') || (*source == 'P')) { source++; if ((*source == '+') || (*source == '-')) { isExponentNegative = (*source == '-'); source++; } while (isdigit((int)*source)) { exponent *= 10; exponent += (*source - '0'); source++; } } } /* For later use with exponent */ base = 2.0; } else /* Then try normal decimal floats */ { base = 10.0; isNegative = (*source == '-'); /* Skip sign */ if ((*source == '+') || (*source == '-')) source++; /* Integer part */ while (isdigit((int)*source)) { integer *= base; integer += (*source - '0'); source++; } if (*source == '.') { source++; /* skip decimal point */ while (isdigit((int)*source)) { fracdiv /= base; fraction += (*source - '0') * fracdiv; source++; } } if ((*source == 'e') || (*source == 'E') #if TRIO_MICROSOFT || (*source == 'd') || (*source == 'D') #endif ) { source++; /* Skip exponential indicator */ isExponentNegative = (*source == '-'); if ((*source == '+') || (*source == '-')) source++; while (isdigit((int)*source)) { exponent *= (int)base; exponent += (*source - '0'); source++; } } } value = integer + fraction; if (exponent != 0) { if (isExponentNegative) value /= pow(base, (double)exponent); else value *= pow(base, (double)exponent); } if (isNegative) value = -value; if (endp) *endp = (char *)source; return value; #endif } /** Convert string to floating-point number. @param source String to be converted. @param endp Pointer to end of the converted string. @return A floating-point number. See @ref trio_to_long_double. */ TRIO_STRING_PUBLIC double trio_to_double TRIO_ARGS2((source, endp), TRIO_CONST char *source, char **endp) { #if defined(USE_STRTOD) return strtod(source, endp); #else return (double)trio_to_long_double(source, endp); #endif } #if !defined(TRIO_MINIMAL) /** Convert string to floating-point number. @param source String to be converted. @param endp Pointer to end of the converted string. @return A floating-point number. See @ref trio_to_long_double. */ TRIO_STRING_PUBLIC float trio_to_float TRIO_ARGS2((source, endp), TRIO_CONST char *source, char **endp) { #if defined(USE_STRTOF) return strtof(source, endp); #else return (float)trio_to_long_double(source, endp); #endif } #endif /* !defined(TRIO_MINIMAL) */ /** Convert string to signed integer. @param string String to be converted. @param endp Pointer to end of converted string. @param base Radix number of number. */ TRIO_STRING_PUBLIC long trio_to_long TRIO_ARGS3((string, endp, base), TRIO_CONST char *string, char **endp, int base) { assert(string); assert((base >= 2) && (base <= 36)); return strtol(string, endp, base); } #if !defined(TRIO_MINIMAL) /** Convert one alphabetic letter to lower-case. @param source The letter to be converted. @return The converted letter. */ TRIO_STRING_PUBLIC int trio_to_lower TRIO_ARGS1((source), int source) { #if defined(USE_TOLOWER) return tolower(source); #else /* Does not handle locales or non-contiguous alphabetic characters */ return ((source >= (int)'A') && (source <= (int)'Z')) ? source - 'A' + 'a' : source; #endif } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /** Convert string to unsigned integer. @param string String to be converted. @param endp Pointer to end of converted string. @param base Radix number of number. */ TRIO_STRING_PUBLIC unsigned long trio_to_unsigned_long TRIO_ARGS3((string, endp, base), TRIO_CONST char *string, char **endp, int base) { assert(string); assert((base >= 2) && (base <= 36)); return strtoul(string, endp, base); } #endif /* !defined(TRIO_MINIMAL) */ /** Convert one alphabetic letter to upper-case. @param source The letter to be converted. @return The converted letter. */ TRIO_STRING_PUBLIC int trio_to_upper TRIO_ARGS1((source), int source) { #if defined(USE_TOUPPER) return toupper(source); #else /* Does not handle locales or non-contiguous alphabetic characters */ return ((source >= (int)'a') && (source <= (int)'z')) ? source - 'a' + 'A' : source; #endif } #if !defined(TRIO_MINIMAL) /** Convert the alphabetic letters in the string to upper-case. @param target The string to be converted. @return The number of processed characters (converted or not). */ TRIO_STRING_PUBLIC int trio_upper TRIO_ARGS1((target), char *target) { assert(target); return trio_span_function(target, target, trio_to_upper); } #endif /* !defined(TRIO_MINIMAL) */ /** @} End of StaticStrings */ /************************************************************************* * Dynamic String Functions */ #if defined(TRIO_DOCUMENTATION) # include "doc/doc_dynamic.h" #endif /** @addtogroup DynamicStrings @{ */ /* * TrioStringAlloc */ TRIO_STRING_PRIVATE trio_string_t * TrioStringAlloc(TRIO_NOARGS) { trio_string_t *self; self = (trio_string_t *)TRIO_MALLOC(sizeof(trio_string_t)); if (self) { self->content = NULL; self->length = 0; self->allocated = 0; } return self; } /* * TrioStringGrow * * The size of the string will be increased by 'delta' characters. If * 'delta' is zero, the size will be doubled. */ TRIO_STRING_PRIVATE BOOLEAN_T TrioStringGrow TRIO_ARGS2((self, delta), trio_string_t *self, size_t delta) { BOOLEAN_T status = FALSE; char *new_content; size_t new_size; new_size = (delta == 0) ? ( (self->allocated == 0) ? 1 : self->allocated * 2 ) : self->allocated + delta; new_content = (char *)TRIO_REALLOC(self->content, new_size); if (new_content) { self->content = new_content; self->allocated = new_size; status = TRUE; } return status; } #if !defined(TRIO_MINIMAL) /* * TrioStringGrowTo * * The size of the string will be increased to 'length' plus one characters. * If 'length' is less than the original size, the original size will be * used (that is, the size of the string is never decreased). */ TRIO_STRING_PRIVATE BOOLEAN_T TrioStringGrowTo TRIO_ARGS2((self, length), trio_string_t *self, size_t length) { length++; /* Room for terminating zero */ return (self->allocated < length) ? TrioStringGrow(self, length - self->allocated) : TRUE; } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /** Create a new dynamic string. @param initial_size Initial size of the buffer. @return Newly allocated dynamic string, or NULL if memory allocation failed. */ TRIO_STRING_PUBLIC trio_string_t * trio_string_create TRIO_ARGS1((initial_size), int initial_size) { trio_string_t *self; self = TrioStringAlloc(); if (self) { if (TrioStringGrow(self, (size_t)((initial_size > 0) ? initial_size : 1))) { self->content[0] = (char)0; self->allocated = initial_size; } else { trio_string_destroy(self); self = NULL; } } return self; } #endif /* !defined(TRIO_MINIMAL) */ /** Deallocate the dynamic string and its contents. @param self Dynamic string */ TRIO_STRING_PUBLIC void trio_string_destroy TRIO_ARGS1((self), trio_string_t *self) { assert(self); if (self) { trio_destroy(self->content); TRIO_FREE(self); } } #if !defined(TRIO_MINIMAL) /** Get a pointer to the content. @param self Dynamic string. @param offset Offset into content. @return Pointer to the content. @p Offset can be zero, positive, or negative. If @p offset is zero, then the start of the content will be returned. If @p offset is positive, then a pointer to @p offset number of characters from the beginning of the content is returned. If @p offset is negative, then a pointer to @p offset number of characters from the ending of the string, starting at the terminating zero, is returned. */ TRIO_STRING_PUBLIC char * trio_string_get TRIO_ARGS2((self, offset), trio_string_t *self, int offset) { char *result = NULL; assert(self); if (self->content != NULL) { if (self->length == 0) { (void)trio_string_length(self); } if (offset >= 0) { if (offset > (int)self->length) { offset = self->length; } } else { offset += self->length + 1; if (offset < 0) { offset = 0; } } result = &(self->content[offset]); } return result; } #endif /* !defined(TRIO_MINIMAL) */ /** Extract the content. @param self Dynamic String @return Content of dynamic string. The content is removed from the dynamic string. This enables destruction of the dynamic string without deallocation of the content. */ TRIO_STRING_PUBLIC char * trio_string_extract TRIO_ARGS1((self), trio_string_t *self) { char *result; assert(self); result = self->content; /* FIXME: Allocate new empty buffer? */ self->content = NULL; self->length = self->allocated = 0; return result; } #if !defined(TRIO_MINIMAL) /** Set the content of the dynamic string. @param self Dynamic String @param buffer The new content. Sets the content of the dynamic string to a copy @p buffer. An existing content will be deallocated first, if necessary. @remark This function will make a copy of @p buffer. You are responsible for deallocating @p buffer yourself. */ TRIO_STRING_PUBLIC void trio_xstring_set TRIO_ARGS2((self, buffer), trio_string_t *self, char *buffer) { assert(self); trio_destroy(self->content); self->content = trio_duplicate(buffer); } #endif /* !defined(TRIO_MINIMAL) */ /* * trio_string_size */ TRIO_STRING_PUBLIC int trio_string_size TRIO_ARGS1((self), trio_string_t *self) { assert(self); return self->allocated; } /* * trio_string_terminate */ TRIO_STRING_PUBLIC void trio_string_terminate TRIO_ARGS1((self), trio_string_t *self) { trio_xstring_append_char(self, 0); } #if !defined(TRIO_MINIMAL) /** Append the second string to the first. @param self Dynamic string to be modified. @param other Dynamic string to copy from. @return Boolean value indicating success or failure. */ TRIO_STRING_PUBLIC int trio_string_append TRIO_ARGS2((self, other), trio_string_t *self, trio_string_t *other) { size_t length; assert(self); assert(other); length = self->length + other->length; if (!TrioStringGrowTo(self, length)) goto error; trio_copy(&self->content[self->length], other->content); self->length = length; return TRUE; error: return FALSE; } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_xstring_append */ TRIO_STRING_PUBLIC int trio_xstring_append TRIO_ARGS2((self, other), trio_string_t *self, TRIO_CONST char *other) { size_t length; assert(self); assert(other); length = self->length + trio_length(other); if (!TrioStringGrowTo(self, length)) goto error; trio_copy(&self->content[self->length], other); self->length = length; return TRUE; error: return FALSE; } #endif /* !defined(TRIO_MINIMAL) */ /* * trio_xstring_append_char */ TRIO_STRING_PUBLIC int trio_xstring_append_char TRIO_ARGS2((self, character), trio_string_t *self, char character) { assert(self); if ((int)self->length >= trio_string_size(self)) { if (!TrioStringGrow(self, 0)) goto error; } self->content[self->length] = character; self->length++; return TRUE; error: return FALSE; } #if !defined(TRIO_MINIMAL) /** Search for the first occurrence of second parameter in the first. @param self Dynamic string to be modified. @param other Dynamic string to copy from. @return Boolean value indicating success or failure. */ TRIO_STRING_PUBLIC int trio_string_contains TRIO_ARGS2((self, other), trio_string_t *self, trio_string_t *other) { assert(self); assert(other); return trio_contains(self->content, other->content); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_xstring_contains */ TRIO_STRING_PUBLIC int trio_xstring_contains TRIO_ARGS2((self, other), trio_string_t *self, TRIO_CONST char *other) { assert(self); assert(other); return trio_contains(self->content, other); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_string_copy */ TRIO_STRING_PUBLIC int trio_string_copy TRIO_ARGS2((self, other), trio_string_t *self, trio_string_t *other) { assert(self); assert(other); self->length = 0; return trio_string_append(self, other); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_xstring_copy */ TRIO_STRING_PUBLIC int trio_xstring_copy TRIO_ARGS2((self, other), trio_string_t *self, TRIO_CONST char *other) { assert(self); assert(other); self->length = 0; return trio_xstring_append(self, other); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_string_duplicate */ TRIO_STRING_PUBLIC trio_string_t * trio_string_duplicate TRIO_ARGS1((other), trio_string_t *other) { trio_string_t *self; assert(other); self = TrioStringAlloc(); if (self) { self->content = TrioDuplicateMax(other->content, other->length); if (self->content) { self->length = other->length; self->allocated = self->length + 1; } else { self->length = self->allocated = 0; } } return self; } #endif /* !defined(TRIO_MINIMAL) */ /* * trio_xstring_duplicate */ TRIO_STRING_PUBLIC trio_string_t * trio_xstring_duplicate TRIO_ARGS1((other), TRIO_CONST char *other) { trio_string_t *self; assert(other); self = TrioStringAlloc(); if (self) { self->content = TrioDuplicateMax(other, trio_length(other)); if (self->content) { self->length = trio_length(self->content); self->allocated = self->length + 1; } else { self->length = self->allocated = 0; } } return self; } #if !defined(TRIO_MINIMAL) /* * trio_string_equal */ TRIO_STRING_PUBLIC int trio_string_equal TRIO_ARGS2((self, other), trio_string_t *self, trio_string_t *other) { assert(self); assert(other); return trio_equal(self->content, other->content); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_xstring_equal */ TRIO_STRING_PUBLIC int trio_xstring_equal TRIO_ARGS2((self, other), trio_string_t *self, TRIO_CONST char *other) { assert(self); assert(other); return trio_equal(self->content, other); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_string_equal_max */ TRIO_STRING_PUBLIC int trio_string_equal_max TRIO_ARGS3((self, max, other), trio_string_t *self, size_t max, trio_string_t *other) { assert(self); assert(other); return trio_equal_max(self->content, max, other->content); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_xstring_equal_max */ TRIO_STRING_PUBLIC int trio_xstring_equal_max TRIO_ARGS3((self, max, other), trio_string_t *self, size_t max, TRIO_CONST char *other) { assert(self); assert(other); return trio_equal_max(self->content, max, other); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_string_equal_case */ TRIO_STRING_PUBLIC int trio_string_equal_case TRIO_ARGS2((self, other), trio_string_t *self, trio_string_t *other) { assert(self); assert(other); return trio_equal_case(self->content, other->content); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_xstring_equal_case */ TRIO_STRING_PUBLIC int trio_xstring_equal_case TRIO_ARGS2((self, other), trio_string_t *self, TRIO_CONST char *other) { assert(self); assert(other); return trio_equal_case(self->content, other); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_string_equal_case_max */ TRIO_STRING_PUBLIC int trio_string_equal_case_max TRIO_ARGS3((self, max, other), trio_string_t *self, size_t max, trio_string_t *other) { assert(self); assert(other); return trio_equal_case_max(self->content, max, other->content); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_xstring_equal_case_max */ TRIO_STRING_PUBLIC int trio_xstring_equal_case_max TRIO_ARGS3((self, max, other), trio_string_t *self, size_t max, TRIO_CONST char *other) { assert(self); assert(other); return trio_equal_case_max(self->content, max, other); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_string_format_data_max */ TRIO_STRING_PUBLIC size_t trio_string_format_date_max TRIO_ARGS4((self, max, format, datetime), trio_string_t *self, size_t max, TRIO_CONST char *format, TRIO_CONST struct tm *datetime) { assert(self); return trio_format_date_max(self->content, max, format, datetime); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_string_index */ TRIO_STRING_PUBLIC char * trio_string_index TRIO_ARGS2((self, character), trio_string_t *self, int character) { assert(self); return trio_index(self->content, character); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_string_index_last */ TRIO_STRING_PUBLIC char * trio_string_index_last TRIO_ARGS2((self, character), trio_string_t *self, int character) { assert(self); return trio_index_last(self->content, character); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_string_length */ TRIO_STRING_PUBLIC int trio_string_length TRIO_ARGS1((self), trio_string_t *self) { assert(self); if (self->length == 0) { self->length = trio_length(self->content); } return self->length; } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_string_lower */ TRIO_STRING_PUBLIC int trio_string_lower TRIO_ARGS1((self), trio_string_t *self) { assert(self); return trio_lower(self->content); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_string_match */ TRIO_STRING_PUBLIC int trio_string_match TRIO_ARGS2((self, other), trio_string_t *self, trio_string_t *other) { assert(self); assert(other); return trio_match(self->content, other->content); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_xstring_match */ TRIO_STRING_PUBLIC int trio_xstring_match TRIO_ARGS2((self, other), trio_string_t *self, TRIO_CONST char *other) { assert(self); assert(other); return trio_match(self->content, other); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_string_match_case */ TRIO_STRING_PUBLIC int trio_string_match_case TRIO_ARGS2((self, other), trio_string_t *self, trio_string_t *other) { assert(self); assert(other); return trio_match_case(self->content, other->content); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_xstring_match_case */ TRIO_STRING_PUBLIC int trio_xstring_match_case TRIO_ARGS2((self, other), trio_string_t *self, TRIO_CONST char *other) { assert(self); assert(other); return trio_match_case(self->content, other); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_string_substring */ TRIO_STRING_PUBLIC char * trio_string_substring TRIO_ARGS2((self, other), trio_string_t *self, trio_string_t *other) { assert(self); assert(other); return trio_substring(self->content, other->content); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_xstring_substring */ TRIO_STRING_PUBLIC char * trio_xstring_substring TRIO_ARGS2((self, other), trio_string_t *self, TRIO_CONST char *other) { assert(self); assert(other); return trio_substring(self->content, other); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_string_upper */ TRIO_STRING_PUBLIC int trio_string_upper TRIO_ARGS1((self), trio_string_t *self) { assert(self); return trio_upper(self->content); } #endif /* !defined(TRIO_MINIMAL) */ /** @} End of DynamicStrings */ xdmf-3.0+git20160803/Utilities/vtklibxml2/vtk_README.txt0000640000175000017500000000424713003006557022534 0ustar alastairalastairIn order to update VTK's libxml2 version, see below. MOST RECENTLY MERGED TAG: VTK-libxml2-upstream-2-6-27 ------------------------------------------------------------------------------ This libxml2 was converted from upstream as follows: 1.) Export libxml2 source from SVN: svn export http://svn.gnome.org/svn/libxml2/tags/LIBXML2_2_6_27 \ libxml2-2.6.27 2.) Fix trio*.h files: "$Id: vtk_README.txt,v 1.2 2007-04-24 17:23:33 king Exp $" --> "Id: ..." 3.) Remove extra directories and files, fix permissions: rm -rf doc result python optim bakefile xstc vms macos example test win32 rm *.py *.pl *.sh install-sh test*.c test*.h ac* missing mkinstalldirs TODO* rm README* NEWS MAINTAINERS INSTALL HACKING rm global.data ChangeLog chvalid.def configure.in rm Makefile* include/Makefile* include/libxml/Makefile* rm libxml-2.0* libxml.3 libxml.spec.in libxml.m4 xml2* include/win32config.h chmod 644 chvalid.c 4.) Checkin files to VTK-libxml2-upstream branch. Create the tag VTK-libxml2-upstream-2-6-27 on the branch. VTK-specific changes are then performed on the main tree. 5.) Mangle with vtk_libxml2_mangle.h included in include/libxml/xmlexports.h. Hack up globals.c and include/libxml/globals.h to fix some mangling. 6.) Hack up include/libxml/*.h to use double-quote includes without libxml/ prefix. This should cause each header to include the other headers it needs from the same directory. ------------------------------------------------------------------------------ To upgrade to a newer libxml2 version: 1.) Follow steps 1-3 above. 2.) Commit the new upstream version on the VTK-libxml2-upstream branch. Create the tag VTK-libxml2-upstream- to indicate the version. 3.) Merge the changes between the previous and current versions to the main tree: cvs update -dAP cvs tag VTK-libxml2--merge-pre cvs update -d -j VTK-libxml2-upstream- -j VTK-libxml2-upstream- 4.) Manually resolve conflicts and commit. cvs commit -m "ENH: Updating libxml2 to " cvs tag VTK-libxml2--merge-post 5.) Update the tag at the top of this file indicating the most recently merged version. xdmf-3.0+git20160803/Utilities/vtklibxml2/CVS/0000740000175000017500000000000013003006557020574 5ustar alastairalastairxdmf-3.0+git20160803/Utilities/vtklibxml2/CVS/Repository0000640000175000017500000000003213003006557022673 0ustar alastairalastairXdmf/Utilities/vtklibxml2 xdmf-3.0+git20160803/Utilities/vtklibxml2/CVS/Root0000640000175000017500000000006413003006557021444 0ustar alastairalastair:pserver:anonymous@public.kitware.com:/cvsroot/Xdmf xdmf-3.0+git20160803/Utilities/vtklibxml2/CVS/Entries0000640000175000017500000000560013003006557022133 0ustar alastairalastair/.NoDartCoverage/1.1/Thu May 17 15:37:50 2007// /AUTHORS/1.2/Tue Apr 24 17:23:33 2007// /CMakeLists.txt/1.15/Mon Nov 24 16:50:27 2008// /Copyright/1.2/Tue Apr 24 17:23:33 2007// /DOCBparser.c/1.2/Tue Apr 24 17:23:33 2007// /HTMLparser.c/1.5/Wed Apr 25 14:14:56 2007// /HTMLtree.c/1.2/Tue Apr 24 17:23:33 2007// /SAX.c/1.2/Tue Apr 24 17:23:33 2007// /SAX2.c/1.2/Tue Apr 24 17:23:33 2007// /c14n.c/1.2/Tue Apr 24 17:23:33 2007// /catalog.c/1.2/Tue Apr 24 17:23:33 2007// /chvalid.c/1.2/Tue Apr 24 17:23:33 2007// /config_cmake.h.in/1.3/Fri Dec 21 19:45:41 2007// /debugXML.c/1.2/Tue Apr 24 17:23:33 2007// /dict.c/1.2/Tue Apr 24 17:23:33 2007// /elfgcchack.h/1.3/Tue Apr 24 19:01:29 2007// /encoding.c/1.2/Tue Apr 24 17:23:33 2007// /entities.c/1.2/Tue Apr 24 17:23:33 2007// /error.c/1.2/Tue Apr 24 17:23:33 2007// /globals.c/1.6/Wed Apr 25 21:07:17 2007// /hash.c/1.2/Tue Apr 24 17:23:33 2007// /legacy.c/1.2/Tue Apr 24 17:23:33 2007// /libxml.h/1.2/Tue Apr 24 17:23:33 2007// /libxml2PlatformTests.cmake/1.1/Tue Apr 24 17:37:20 2007// /list.c/1.2/Tue Apr 24 17:23:33 2007// /nanoftp.c/1.2/Tue Apr 24 17:23:33 2007// /nanohttp.c/1.3/Wed Apr 25 14:14:56 2007// /parser.c/1.3/Wed Apr 25 14:14:56 2007// /parserInternals.c/1.3/Wed Apr 25 14:14:56 2007// /pattern.c/1.2/Tue Apr 24 17:23:33 2007// /platformTestsC.c/1.2/Tue Apr 24 17:47:43 2007// /regressions.xml/1.2/Tue Apr 24 17:23:33 2007// /relaxng.c/1.2/Tue Apr 24 17:23:33 2007// /rngparser.c/1.2/Tue Apr 24 17:23:33 2007// /runsuite.c/1.2/Tue Apr 24 17:23:33 2007// /runtest.c/1.2/Tue Apr 24 17:23:33 2007// /schematron.c/1.3/Tue Apr 24 18:55:38 2007// /threads.c/1.2/Tue Apr 24 17:23:33 2007// /tree.c/1.5/Tue Nov 10 13:01:41 2009// /trio.c/1.2/Tue Apr 24 17:23:33 2007// /trio.h/1.2/Tue Apr 24 17:23:33 2007// /triodef.h/1.2/Tue Apr 24 17:23:33 2007// /trionan.c/1.5/Tue Apr 24 19:17:13 2007// /trionan.h/1.2/Tue Apr 24 17:23:33 2007// /triop.h/1.2/Tue Apr 24 17:23:33 2007// /triostr.c/1.2/Tue Apr 24 17:23:33 2007// /triostr.h/1.2/Tue Apr 24 17:23:33 2007// /uri.c/1.3/Tue Apr 24 18:55:38 2007// /valid.c/1.2/Tue Apr 24 17:23:33 2007// /vtk_README.txt/1.2/Tue Apr 24 17:23:33 2007// /vtk_libxml2_zlib.h/1.1/Wed Apr 25 14:14:56 2007// /xinclude.c/1.2/Tue Apr 24 17:23:33 2007// /xlink.c/1.3/Wed Apr 25 14:14:56 2007// /xmlIO.c/1.5/Sat Apr 28 14:02:02 2007// /xmlcatalog.c/1.2/Tue Apr 24 17:23:33 2007// /xmllint.c/1.2/Tue Apr 24 17:23:33 2007// /xmlmemory.c/1.2/Tue Apr 24 17:23:33 2007// /xmlmodule.c/1.4/Thu Apr 26 18:25:38 2007// /xmlreader.c/1.2/Tue Apr 24 17:23:33 2007// /xmlregexp.c/1.2/Tue Apr 24 17:23:33 2007// /xmlsave.c/1.3/Tue Apr 24 18:55:38 2007// /xmlschemas.c/1.2/Tue Apr 24 17:23:33 2007// /xmlschemastypes.c/1.2/Tue Apr 24 17:23:34 2007// /xmlstring.c/1.2/Tue Apr 24 17:23:34 2007// /xmlunicode.c/1.2/Tue Apr 24 17:23:34 2007// /xmlwriter.c/1.2/Tue Apr 24 17:23:34 2007// /xpath.c/1.4/Tue Apr 24 20:24:00 2007// /xpointer.c/1.2/Tue Apr 24 17:23:34 2007// D/include//// xdmf-3.0+git20160803/Utilities/vtklibxml2/CMakeLists.txt0000640000175000017500000002603113003006557022705 0ustar alastairalastairPROJECT(vtklibxml2 C) INCLUDE_REGULAR_EXPRESSION("^.*$") SET(PACKAGE "vtklibxml2") SET(VERSION "2.6.27") SET(LIBXML_VERSION_NUMBER 20627) SET(LIBXML_VERSION_EXTRA "") SET(MODULE_EXTENSION ${CMAKE_SHARED_MODULE_SUFFIX}) SET(PACKAGE_TARNAME "") SET(PACKAGE_BUGREPORT " ") SET(PACKAGE_NAME "") SET(PACKAGE_VERSION "") SET(PACKAGE_STRING "") SET(PACKAGE_BUGREPORT "") INCLUDE(CheckLibraryExists) INCLUDE(CheckIncludeFile) INCLUDE(CheckIncludeFiles) INCLUDE(CheckSymbolExists) INCLUDE(libxml2PlatformTests.cmake) SET(LIBXML2_PLATFORM_TEST_FILE_C platformTestsC.c) FIND_PACKAGE(Threads) SET(CMAKE_THREAD_LIBS "${CMAKE_THREAD_LIBS_INIT}" CACHE STRING "Thread library used.") # This macro checks if the symbol exists in the library and if it # does, it appends library to the list. SET(LIBXML2_LIBS "") MACRO(CHECK_LIBRARY_EXISTS_CONCAT LIBRARY SYMBOL VARIABLE) CHECK_LIBRARY_EXISTS("${LIBRARY};${LIBXML2_LIBS}" ${SYMBOL} "" ${VARIABLE}) IF(${VARIABLE}) SET(LIBXML2_LIBS ${LIBXML2_LIBS} ${LIBRARY}) ENDIF(${VARIABLE}) ENDMACRO(CHECK_LIBRARY_EXISTS_CONCAT) CHECK_LIBRARY_EXISTS_CONCAT("dl" dlopen HAVE_LIBDL) CHECK_LIBRARY_EXISTS_CONCAT("dld" shl_load HAVE_SHLLOAD) # VTK does not use the read line functionality of libxml2, so don't # try and find these libraries. It creates extra dependencies on # executables and libraries. This might cause trouble when creating # packages or rpm's. #CHECK_LIBRARY_EXISTS_CONCAT("history" append_history HAVE_LIBHISTORY) #CHECK_LIBRARY_EXISTS_CONCAT("readline" readline HAVE_LIBREADLINE) IF(NOT VTK_ZLIB_LIBRARIES) CHECK_LIBRARY_EXISTS_CONCAT("z" inflateEnd HAVE_LIBZ) ENDIF(NOT VTK_ZLIB_LIBRARIES) # Use needed system libraries. SET(LIBXML2_LIBS ${LIBXML2_LIBS} ${CMAKE_THREAD_LIBS} ${CMAKE_DL_LIBS}) IF(UNIX) SET(LIBXML2_LIBS ${LIBXML2_LIBS} m) ENDIF(UNIX) # Check for symbol dlopen separately from the dl library. CHECK_LIBRARY_EXISTS("${LIBXML2_LIBS}" dlopen "" HAVE_DLOPEN) # For other tests to use the same libraries SET(CMAKE_REQUIRED_LIBRARIES ${LIBXML2_LIBS}) SET(CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE") # Use VTK's zlib if we are building in the tree. IF(VTK_ZLIB_LIBRARIES) SET(HAVE_LIBZ 1) SET(LIBXML2_LIBS ${VTK_ZLIB_LIBRARIES} ${LIBXML2_LIBS}) ENDIF(VTK_ZLIB_LIBRARIES) # Check if header file exists and add it to the list. MACRO(CHECK_INCLUDE_FILE_CONCAT FILE VARIABLE) CHECK_INCLUDE_FILES("${LIBXML2_INCLUDES};${FILE}" ${VARIABLE}) IF(${VARIABLE}) SET(LIBXML2_INCLUDES ${LIBXML2_INCLUDES} ${FILE}) ENDIF(${VARIABLE}) ENDMACRO(CHECK_INCLUDE_FILE_CONCAT) # Check for headers not actually needed for the configured header but # that may be needed to include the other headers tested. CHECK_INCLUDE_FILE_CONCAT("stdio.h" HAVE_STDIO_H) CHECK_INCLUDE_FILE_CONCAT("stddef.h" HAVE_STDDEF_H) CHECK_INCLUDE_FILE_CONCAT("sys/types.h" HAVE_SYS_TYPES_H) CHECK_INCLUDE_FILE_CONCAT("inttypes.h" HAVE_INTTYPES_H) CHECK_INCLUDE_FILE_CONCAT("dlfcn.h" HAVE_DLFCN_H) CHECK_INCLUDE_FILE_CONCAT("fcntl.h" HAVE_FCNTL_H) CHECK_INCLUDE_FILE_CONCAT("malloc.h" HAVE_MALLOC_H) CHECK_INCLUDE_FILE_CONCAT("memory.h" HAVE_MEMORY_H) CHECK_INCLUDE_FILE_CONCAT("netdb.h" HAVE_NETDB_H) CHECK_INCLUDE_FILE_CONCAT("limits.h" HAVE_LIMITS_H) CHECK_INCLUDE_FILE_CONCAT("sys/socket.h" HAVE_SYS_SOCKET_H) CHECK_INCLUDE_FILE_CONCAT("netinet/in.h" HAVE_NETINET_IN_H) CHECK_INCLUDE_FILE_CONCAT("sys/select.h" HAVE_SYS_SELECT_H) CHECK_INCLUDE_FILE_CONCAT("stdint.h" HAVE_STDINT_H) CHECK_INCLUDE_FILE_CONCAT("stdlib.h" HAVE_STDLIB_H) CHECK_INCLUDE_FILE_CONCAT("string.h" HAVE_STRING_H) CHECK_INCLUDE_FILE_CONCAT("strings.h" HAVE_STRINGS_H) CHECK_INCLUDE_FILE_CONCAT("sys/stat.h" HAVE_SYS_STAT_H) CHECK_INCLUDE_FILE_CONCAT("sys/time.h" HAVE_SYS_TIME_H) CHECK_INCLUDE_FILE_CONCAT("time.h" HAVE_TIME_H) CHECK_INCLUDE_FILE_CONCAT("unistd.h" HAVE_UNISTD_H) CHECK_INCLUDE_FILE_CONCAT("signal.h" HAVE_SIGNAL_H) CHECK_INCLUDE_FILE_CONCAT("errno.h" HAVE_ERRNO_H) CHECK_INCLUDE_FILE_CONCAT("ansidecl.h" HAVE_ANSIDECL_H) CHECK_INCLUDE_FILE_CONCAT("arpa/inet.h" HAVE_ARPA_INET_H) CHECK_INCLUDE_FILE_CONCAT("arpa/nameser.h" HAVE_ARPA_NAMESER_H) CHECK_INCLUDE_FILE_CONCAT("ctype.h" HAVE_CTYPE_H) CHECK_INCLUDE_FILE_CONCAT("dirent.h" HAVE_DIRENT_H) CHECK_INCLUDE_FILE_CONCAT("dl.h" HAVE_DL_H) CHECK_INCLUDE_FILE_CONCAT("float.h" HAVE_FLOAT_H) CHECK_INCLUDE_FILE_CONCAT("fp_class.h" HAVE_FP_CLASS_H) CHECK_INCLUDE_FILE_CONCAT("ieeefp.h" HAVE_IEEEFP_H) CHECK_INCLUDE_FILE_CONCAT("math.h" HAVE_MATH_H) CHECK_INCLUDE_FILE_CONCAT("nan.h" HAVE_NAN_H) CHECK_INCLUDE_FILE_CONCAT("ndir.h" HAVE_NDIR_H) CHECK_INCLUDE_FILE_CONCAT("pthread.h" HAVE_PTHREAD_H) CHECK_INCLUDE_FILE_CONCAT("resolv.h" HAVE_RESOLV_H) CHECK_INCLUDE_FILE_CONCAT("stdarg.h" HAVE_STDARG_H) CHECK_INCLUDE_FILE_CONCAT("sys/mman.h" HAVE_SYS_MMAN_H) CHECK_INCLUDE_FILE_CONCAT("sys/timeb.h" HAVE_SYS_TIMEB_H) CHECK_SYMBOL_EXISTS(finite "${LIBXML2_INCLUDES}" HAVE_FINITE) CHECK_SYMBOL_EXISTS(fpclass "${LIBXML2_INCLUDES}" HAVE_FPCLASS) CHECK_SYMBOL_EXISTS(fp_class "${LIBXML2_INCLUDES}" HAVE_FP_CLASS) CHECK_SYMBOL_EXISTS(fprintf "${LIBXML2_INCLUDES}" HAVE_FPRINTF) CHECK_SYMBOL_EXISTS(ftime "${LIBXML2_INCLUDES}" HAVE_FTIME) CHECK_SYMBOL_EXISTS(gettimeofday "${LIBXML2_INCLUDES}" HAVE_GETTIMEOFDAY) CHECK_SYMBOL_EXISTS(localtime "${LIBXML2_INCLUDES}" HAVE_LOCALTIME) CHECK_SYMBOL_EXISTS(printf "${LIBXML2_INCLUDES}" HAVE_PRINTF) CHECK_SYMBOL_EXISTS(sscanf "${LIBXML2_INCLUDES}" HAVE_SSCANF) CHECK_SYMBOL_EXISTS(sprintf "${LIBXML2_INCLUDES}" HAVE_SPRINTF) CHECK_SYMBOL_EXISTS(snprintf "${LIBXML2_INCLUDES}" HAVE_SNPRINTF) CHECK_SYMBOL_EXISTS(signal "${LIBXML2_INCLUDES}" HAVE_SIGNAL) CHECK_SYMBOL_EXISTS(strdup "${LIBXML2_INCLUDES}" HAVE_STRDUP) CHECK_SYMBOL_EXISTS(strndup "${LIBXML2_INCLUDES}" HAVE_STRNDUP) CHECK_SYMBOL_EXISTS(strerror "${LIBXML2_INCLUDES}" HAVE_STRERROR) CHECK_SYMBOL_EXISTS(strftime "${LIBXML2_INCLUDES}" HAVE_STRFTIME) CHECK_SYMBOL_EXISTS(stat "${LIBXML2_INCLUDES}" HAVE_STAT) CHECK_SYMBOL_EXISTS(_stat "${LIBXML2_INCLUDES}" HAVE__STAT) CHECK_SYMBOL_EXISTS(vfprintf "${LIBXML2_INCLUDES}" HAVE_VFPRINTF) CHECK_SYMBOL_EXISTS(vsnprintf "${LIBXML2_INCLUDES}" HAVE_VSNPRINTF) CHECK_SYMBOL_EXISTS(vsprintf "${LIBXML2_INCLUDES}" HAVE_VSPRINTF) LIBXML2_PLATFORM_C_TEST(HAVE_GETADDRINFO "Checking for getaddrinfo." DIRECT) LIBXML2_PLATFORM_C_TEST(HAVE_SOCKLEN_T "Checking for socklen_t" DIRECT) LIBXML2_PLATFORM_C_TEST(HAVE_SYS_DIR_H "Checking for DIR in sys/dir.h" DIRECT) LIBXML2_PLATFORM_C_TEST(HAVE_SYS_NDIR_H "Checking for DIR in sys/ndir.h" DIRECT) LIBXML2_PLATFORM_C_TEST(HAVE_VA_COPY "Checking for va_copy" DIRECT) LIBXML2_PLATFORM_C_TEST(HAVE___VA_COPY "Checking for __va_copy" DIRECT) LIBXML2_PLATFORM_C_TEST(SUPPORT_IP6 "Checking for ipv6 support." DIRECT) # Use VTK's zlib if we are building in the tree. IF(VTK_ZLIB_LIBRARIES) SET(HAVE_VTK_ZLIB_H 1) SET(HAVE_ZLIB_H 1) ELSE(VTK_ZLIB_LIBRARIES) CHECK_INCLUDE_FILE_CONCAT("zlib.h" HAVE_ZLIB_H) ENDIF(VTK_ZLIB_LIBRARIES) IF(HAVE_SOCKLEN_T) SET(XML_SOCKLEN_T "socklen_t") ELSE(HAVE_SOCKLEN_T) SET(XML_SOCKLEN_T) ENDIF(HAVE_SOCKLEN_T) SET(_WINSOCKAPI_) SET(WITH_TRIO 0) # some kind of 3rd party library SET(WITH_THREADS 1) SET(WITH_TREE 1) SET(WITH_OUTPUT 1) SET(WITH_PUSH 1) SET(WITH_READER 1) SET(WITH_PATTERN 1) SET(WITH_WRITER 1) SET(WITH_SAX1 1) SET(WITH_FTP 0) # fix socket API SET(WITH_HTTP 0) # fix socket API SET(WITH_VALID 1) SET(WITH_HTML 1) SET(WITH_LEGACY 1) SET(WITH_C14N 1) SET(WITH_CATALOG 1) SET(WITH_DOCB 1) SET(WITH_XPATH 1) SET(WITH_XPTR 1) SET(WITH_XINCLUDE 1) SET(WITH_ICONV 0) SET(WITH_ISO8859X 1) SET(WITH_DEBUG 0) SET(WITH_MEM_DEBUG 0) SET(WITH_RUN_DEBUG 0) SET(WITH_REGEXPS 1) SET(WITH_REGEXPS 1) SET(WITH_REGEXPS 1) SET(WITH_SCHEMAS 1) SET(WITH_SCHEMAS 1) SET(WITH_SCHEMATRON 1) SET(WITH_MODULES 1) IF(HAVE_ZLIB_H AND HAVE_LIBZ) SET(WITH_ZLIB 1) ELSE(HAVE_ZLIB_H AND HAVE_LIBZ) SET(WITH_ZLIB 0) ENDIF(HAVE_ZLIB_H AND HAVE_LIBZ) # not building VTK with pthreads IF(NOT CMAKE_USE_PTHREADS AND HAVE_PTHREAD_H) SET(HAVE_PTHREAD_H 0) ENDIF(NOT CMAKE_USE_PTHREADS AND HAVE_PTHREAD_H) # Create the platform configuration header. CONFIGURE_FILE(${vtklibxml2_SOURCE_DIR}/config_cmake.h.in ${vtklibxml2_BINARY_DIR}/config.h @ONLY) # Create the build configuration header. CONFIGURE_FILE(${vtklibxml2_SOURCE_DIR}/include/libxml/xmlversion.h.in ${vtklibxml2_BINARY_DIR}/libxml/xmlversion.h @ONLY) SET(vtklibxml2_HEADER_FILES ${vtklibxml2_BINARY_DIR}/libxml/xmlversion.h) # Copy all the source headers over to the same directory as the build # configuration header so that headers can include each other with # double quotes. FILE(GLOB vtklibxml2_HEADERS RELATIVE ${vtklibxml2_SOURCE_DIR}/include/libxml include/libxml/*.h) FOREACH(f ${vtklibxml2_HEADERS}) CONFIGURE_FILE(${vtklibxml2_SOURCE_DIR}/include/libxml/${f} ${vtklibxml2_BINARY_DIR}/libxml/${f} COPYONLY) SET(vtklibxml2_HEADER_FILES ${vtklibxml2_HEADER_FILES} ${vtklibxml2_BINARY_DIR}/libxml/${f}) ENDFOREACH(f) # Block warnings unless we are instructed to allow them. # SET(VTKLIBXML2_WARNINGS_ALLOW 1) VTK_THIRD_PARTY_WARNING_SUPPRESS(VTKLIBXML2 C) ADD_DEFINITIONS(-DHAVE_CONFIG_H -D_GNU_SOURCE -DPIC -D_REENTRANT) IF(WIN32 AND NOT CYGWIN) # threads.c looks for this ADD_DEFINITIONS(-DHAVE_WIN32_THREADS) ENDIF(WIN32 AND NOT CYGWIN) SET(vtklibxml2_la_SOURCES DOCBparser.c HTMLparser.c HTMLtree.c SAX.c SAX2.c c14n.c catalog.c chvalid.c debugXML.c dict.c encoding.c entities.c error.c globals.c hash.c legacy.c list.c nanoftp.c nanohttp.c parser.c parserInternals.c pattern.c relaxng.c schematron.c threads.c tree.c uri.c valid.c xinclude.c xlink.c xmlIO.c xmlmemory.c xmlmodule.c xmlreader.c xmlregexp.c xmlsave.c xmlschemas.c xmlschemastypes.c xmlstring.c xmlunicode.c xmlwriter.c xpath.c xpointer.c ) INCLUDE_DIRECTORIES(BEFORE ${vtklibxml2_BINARY_DIR}) IF(NOT BUILD_SHARED_LIBS) ADD_DEFINITIONS(-DLIBXML_STATIC) ENDIF(NOT BUILD_SHARED_LIBS) ADD_LIBRARY(vtklibxml2 ${vtklibxml2_la_SOURCES}) TARGET_LINK_LIBRARIES(vtklibxml2 ${LIBXML2_LIBS}) # Apply user-defined properties to the library target. IF(VTK_LIBRARY_PROPERTIES) SET_TARGET_PROPERTIES(vtklibxml2 PROPERTIES ${VTK_LIBRARY_PROPERTIES}) ENDIF(VTK_LIBRARY_PROPERTIES) IF(NOT VTK_INSTALL_NO_LIBRARIES) INSTALL(TARGETS vtklibxml2 RUNTIME DESTINATION ${VTK_INSTALL_BIN_DIR_CM24} COMPONENT RuntimeLibraries LIBRARY DESTINATION ${VTK_INSTALL_LIB_DIR_CM24} COMPONENT RuntimeLibraries ARCHIVE DESTINATION ${VTK_INSTALL_LIB_DIR_CM24} COMPONENT Development) ENDIF(NOT VTK_INSTALL_NO_LIBRARIES) IF(NOT VTK_INSTALL_NO_DEVELOPMENT) INSTALL(FILES ${vtklibxml2_HEADER_FILES} DESTINATION ${VTK_INSTALL_INCLUDE_DIR_CM24}/vtklibxml2/libxml COMPONENT Development) ENDIF(NOT VTK_INSTALL_NO_DEVELOPMENT) xdmf-3.0+git20160803/Utilities/vtklibxml2/triodef.h0000640000175000017500000001520413003006557021752 0ustar alastairalastair/************************************************************************* * * Id: triodef.h 3473 2006-05-31 13:35:28Z veillard * * Copyright (C) 2001 Bjorn Reese * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. * ************************************************************************/ #ifndef TRIO_TRIODEF_H #define TRIO_TRIODEF_H /************************************************************************* * Platform and compiler support detection */ #if defined(__GNUC__) # define TRIO_COMPILER_GCC #elif defined(__SUNPRO_C) # define TRIO_COMPILER_SUNPRO #elif defined(__SUNPRO_CC) # define TRIO_COMPILER_SUNPRO # define __SUNPRO_C __SUNPRO_CC #elif defined(__xlC__) || defined(__IBMC__) || defined(__IBMCPP__) # define TRIO_COMPILER_XLC #elif defined(_AIX) && !defined(__GNUC__) # define TRIO_COMPILER_XLC /* Workaround for old xlc */ #elif defined(__DECC) || defined(__DECCXX) # define TRIO_COMPILER_DECC #elif defined(__osf__) && defined(__LANGUAGE_C__) # define TRIO_COMPILER_DECC /* Workaround for old DEC C compilers */ #elif defined(_MSC_VER) # define TRIO_COMPILER_MSVC #elif defined(__BORLANDC__) # define TRIO_COMPILER_BCB #endif #if defined(VMS) || defined(__VMS) /* * VMS is placed first to avoid identifying the platform as Unix * based on the DECC compiler later on. */ # define TRIO_PLATFORM_VMS #elif defined(unix) || defined(__unix) || defined(__unix__) # define TRIO_PLATFORM_UNIX #elif defined(TRIO_COMPILER_XLC) || defined(_AIX) # define TRIO_PLATFORM_UNIX #elif defined(TRIO_COMPILER_DECC) || defined(__osf___) # define TRIO_PLATFORM_UNIX #elif defined(__NetBSD__) # define TRIO_PLATFORM_UNIX #elif defined(__Lynx__) # define TRIO_PLATFORM_UNIX #elif defined(__QNX__) # define TRIO_PLATFORM_UNIX # define TRIO_PLATFORM_QNX #elif defined(__CYGWIN__) # define TRIO_PLATFORM_UNIX #elif defined(AMIGA) && defined(TRIO_COMPILER_GCC) # define TRIO_PLATFORM_UNIX #elif defined(TRIO_COMPILER_MSVC) || defined(WIN32) || defined(_WIN32) # define TRIO_PLATFORM_WIN32 #elif defined(mpeix) || defined(__mpexl) # define TRIO_PLATFORM_MPEIX #endif #if defined(_AIX) # define TRIO_PLATFORM_AIX #elif defined(__hpux) # define TRIO_PLATFORM_HPUX #elif defined(sun) || defined(__sun__) # if defined(__SVR4) || defined(__svr4__) # define TRIO_PLATFORM_SOLARIS # else # define TRIO_PLATFORM_SUNOS # endif #endif #if defined(__STDC__) || defined(TRIO_COMPILER_MSVC) || defined(TRIO_COMPILER_BCB) # define TRIO_COMPILER_SUPPORTS_C89 # if defined(__STDC_VERSION__) # define TRIO_COMPILER_SUPPORTS_C90 # if (__STDC_VERSION__ >= 199409L) # define TRIO_COMPILER_SUPPORTS_C94 # endif # if (__STDC_VERSION__ >= 199901L) # define TRIO_COMPILER_SUPPORTS_C99 # endif # elif defined(TRIO_COMPILER_SUNPRO) # if (__SUNPRO_C >= 0x420) # define TRIO_COMPILER_SUPPORTS_C94 # endif # endif #endif #if defined(_XOPEN_SOURCE) # if defined(_XOPEN_SOURCE_EXTENDED) # define TRIO_COMPILER_SUPPORTS_UNIX95 # endif # if (_XOPEN_VERSION >= 500) # define TRIO_COMPILER_SUPPORTS_UNIX98 # endif # if (_XOPEN_VERSION >= 600) # define TRIO_COMPILER_SUPPORTS_UNIX01 # endif #endif /************************************************************************* * Generic defines */ #if !defined(TRIO_PUBLIC) # define TRIO_PUBLIC #endif #if !defined(TRIO_PRIVATE) # define TRIO_PRIVATE static #endif #if !(defined(TRIO_COMPILER_SUPPORTS_C89) || defined(__cplusplus)) # define TRIO_COMPILER_ANCIENT #endif #if defined(TRIO_COMPILER_ANCIENT) # define TRIO_CONST # define TRIO_VOLATILE # define TRIO_SIGNED typedef double trio_long_double_t; typedef char * trio_pointer_t; # define TRIO_SUFFIX_LONG(x) x # define TRIO_PROTO(x) () # define TRIO_NOARGS # define TRIO_ARGS1(list,a1) list a1; # define TRIO_ARGS2(list,a1,a2) list a1; a2; # define TRIO_ARGS3(list,a1,a2,a3) list a1; a2; a3; # define TRIO_ARGS4(list,a1,a2,a3,a4) list a1; a2; a3; a4; # define TRIO_ARGS5(list,a1,a2,a3,a4,a5) list a1; a2; a3; a4; a5; # define TRIO_ARGS6(list,a1,a2,a3,a4,a5,a6) list a1; a2; a3; a4; a5; a6; # define TRIO_VARGS2(list,a1,a2) list a1; a2 # define TRIO_VARGS3(list,a1,a2,a3) list a1; a2; a3 # define TRIO_VARGS4(list,a1,a2,a3,a4) list a1; a2; a3; a4 # define TRIO_VARGS5(list,a1,a2,a3,a4,a5) list a1; a2; a3; a4; a5 # define TRIO_VA_DECL va_dcl # define TRIO_VA_START(x,y) va_start(x) # define TRIO_VA_END(x) va_end(x) #else /* ANSI C */ # define TRIO_CONST const # define TRIO_VOLATILE volatile # define TRIO_SIGNED signed typedef long double trio_long_double_t; typedef void * trio_pointer_t; # define TRIO_SUFFIX_LONG(x) x ## L # define TRIO_PROTO(x) x # define TRIO_NOARGS void # define TRIO_ARGS1(list,a1) (a1) # define TRIO_ARGS2(list,a1,a2) (a1,a2) # define TRIO_ARGS3(list,a1,a2,a3) (a1,a2,a3) # define TRIO_ARGS4(list,a1,a2,a3,a4) (a1,a2,a3,a4) # define TRIO_ARGS5(list,a1,a2,a3,a4,a5) (a1,a2,a3,a4,a5) # define TRIO_ARGS6(list,a1,a2,a3,a4,a5,a6) (a1,a2,a3,a4,a5,a6) # define TRIO_VARGS2 TRIO_ARGS2 # define TRIO_VARGS3 TRIO_ARGS3 # define TRIO_VARGS4 TRIO_ARGS4 # define TRIO_VARGS5 TRIO_ARGS5 # define TRIO_VA_DECL ... # define TRIO_VA_START(x,y) va_start(x,y) # define TRIO_VA_END(x) va_end(x) #endif #if defined(TRIO_COMPILER_SUPPORTS_C99) || defined(__cplusplus) # define TRIO_INLINE inline #elif defined(TRIO_COMPILER_GCC) # define TRIO_INLINE __inline__ #elif defined(TRIO_COMPILER_MSVC) # define TRIO_INLINE _inline #elif defined(TRIO_COMPILER_BCB) # define TRIO_INLINE __inline #else # define TRIO_INLINE #endif /************************************************************************* * Workarounds */ #if defined(TRIO_PLATFORM_VMS) /* * Computations done with constants at compile time can trigger these * even when compiling with IEEE enabled. */ # pragma message disable (UNDERFLOW, FLOATOVERFL) # if (__CRTL_VER < 80000000) /* * Although the compiler supports C99 language constructs, the C * run-time library does not contain all C99 functions. * * This was the case for 70300022. Update the 80000000 value when * it has been accurately determined what version of the library * supports C99. */ # if defined(TRIO_COMPILER_SUPPORTS_C99) # undef TRIO_COMPILER_SUPPORTS_C99 # endif # endif #endif /* * Not all preprocessors supports the LL token. */ #if defined(TRIO_COMPILER_BCB) #else # define TRIO_COMPILER_SUPPORTS_LL #endif #endif /* TRIO_TRIODEF_H */ xdmf-3.0+git20160803/Utilities/vtklibxml2/triostr.h0000640000175000017500000002001713003006557022022 0ustar alastairalastair/************************************************************************* * * Id: triostr.h 1886 2003-04-03 15:28:28Z veillard * * Copyright (C) 2001 Bjorn Reese and Daniel Stenberg. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. * ************************************************************************/ #ifndef TRIO_TRIOSTR_H #define TRIO_TRIOSTR_H #include #include #include #include #include "triodef.h" #include "triop.h" enum { TRIO_HASH_NONE = 0, TRIO_HASH_PLAIN, TRIO_HASH_TWOSIGNED }; #if !defined(TRIO_STRING_PUBLIC) # if !defined(TRIO_PUBLIC) # define TRIO_PUBLIC # endif # define TRIO_STRING_PUBLIC TRIO_PUBLIC #endif /************************************************************************* * String functions */ TRIO_STRING_PUBLIC int trio_copy_max TRIO_PROTO((char *target, size_t max, const char *source)); TRIO_STRING_PUBLIC char *trio_create TRIO_PROTO((size_t size)); TRIO_STRING_PUBLIC void trio_destroy TRIO_PROTO((char *string)); TRIO_STRING_PUBLIC char *trio_duplicate TRIO_PROTO((const char *source)); TRIO_STRING_PUBLIC int trio_equal TRIO_PROTO((const char *first, const char *second)); TRIO_STRING_PUBLIC int trio_equal_case TRIO_PROTO((const char *first, const char *second)); TRIO_STRING_PUBLIC int trio_equal_locale TRIO_PROTO((const char *first, const char *second)); TRIO_STRING_PUBLIC int trio_equal_max TRIO_PROTO((const char *first, size_t max, const char *second)); TRIO_STRING_PUBLIC TRIO_CONST char *trio_error TRIO_PROTO((int)); TRIO_STRING_PUBLIC size_t trio_length TRIO_PROTO((const char *string)); TRIO_STRING_PUBLIC double trio_to_double TRIO_PROTO((const char *source, char **endp)); TRIO_STRING_PUBLIC long trio_to_long TRIO_PROTO((const char *source, char **endp, int base)); TRIO_STRING_PUBLIC trio_long_double_t trio_to_long_double TRIO_PROTO((const char *source, char **endp)); TRIO_STRING_PUBLIC int trio_to_upper TRIO_PROTO((int source)); #if !defined(TRIO_MINIMAL) TRIO_STRING_PUBLIC int trio_append TRIO_PROTO((char *target, const char *source)); TRIO_STRING_PUBLIC int trio_append_max TRIO_PROTO((char *target, size_t max, const char *source)); TRIO_STRING_PUBLIC int trio_contains TRIO_PROTO((const char *string, const char *substring)); TRIO_STRING_PUBLIC int trio_copy TRIO_PROTO((char *target, const char *source)); TRIO_STRING_PUBLIC char *trio_duplicate_max TRIO_PROTO((const char *source, size_t max)); TRIO_STRING_PUBLIC int trio_equal_case_max TRIO_PROTO((const char *first, size_t max, const char *second)); TRIO_STRING_PUBLIC size_t trio_format_date_max TRIO_PROTO((char *target, size_t max, const char *format, const struct tm *datetime)); TRIO_STRING_PUBLIC unsigned long trio_hash TRIO_PROTO((const char *string, int type)); TRIO_STRING_PUBLIC char *trio_index TRIO_PROTO((const char *string, int character)); TRIO_STRING_PUBLIC char *trio_index_last TRIO_PROTO((const char *string, int character)); TRIO_STRING_PUBLIC int trio_lower TRIO_PROTO((char *target)); TRIO_STRING_PUBLIC int trio_match TRIO_PROTO((const char *string, const char *pattern)); TRIO_STRING_PUBLIC int trio_match_case TRIO_PROTO((const char *string, const char *pattern)); TRIO_STRING_PUBLIC size_t trio_span_function TRIO_PROTO((char *target, const char *source, int (*Function) TRIO_PROTO((int)))); TRIO_STRING_PUBLIC char *trio_substring TRIO_PROTO((const char *string, const char *substring)); TRIO_STRING_PUBLIC char *trio_substring_max TRIO_PROTO((const char *string, size_t max, const char *substring)); TRIO_STRING_PUBLIC float trio_to_float TRIO_PROTO((const char *source, char **endp)); TRIO_STRING_PUBLIC int trio_to_lower TRIO_PROTO((int source)); TRIO_STRING_PUBLIC unsigned long trio_to_unsigned_long TRIO_PROTO((const char *source, char **endp, int base)); TRIO_STRING_PUBLIC char *trio_tokenize TRIO_PROTO((char *string, const char *delimiters)); TRIO_STRING_PUBLIC int trio_upper TRIO_PROTO((char *target)); #endif /* !defined(TRIO_MINIMAL) */ /************************************************************************* * Dynamic string functions */ /* * Opaque type for dynamic strings */ typedef struct _trio_string_t trio_string_t; TRIO_STRING_PUBLIC void trio_string_destroy TRIO_PROTO((trio_string_t *self)); TRIO_STRING_PUBLIC char *trio_string_extract TRIO_PROTO((trio_string_t *self)); TRIO_STRING_PUBLIC int trio_string_size TRIO_PROTO((trio_string_t *self)); TRIO_STRING_PUBLIC void trio_string_terminate TRIO_PROTO((trio_string_t *self)); TRIO_STRING_PUBLIC int trio_xstring_append_char TRIO_PROTO((trio_string_t *self, char character)); TRIO_STRING_PUBLIC trio_string_t *trio_xstring_duplicate TRIO_PROTO((const char *other)); #if !defined(TRIO_MINIMAL) TRIO_STRING_PUBLIC trio_string_t *trio_string_create TRIO_PROTO((int initial_size)); TRIO_STRING_PUBLIC char *trio_string_get TRIO_PROTO((trio_string_t *self, int offset)); TRIO_STRING_PUBLIC void trio_xstring_set TRIO_PROTO((trio_string_t *self, char *buffer)); TRIO_STRING_PUBLIC int trio_string_append TRIO_PROTO((trio_string_t *self, trio_string_t *other)); TRIO_STRING_PUBLIC int trio_string_contains TRIO_PROTO((trio_string_t *self, trio_string_t *other)); TRIO_STRING_PUBLIC int trio_string_copy TRIO_PROTO((trio_string_t *self, trio_string_t *other)); TRIO_STRING_PUBLIC trio_string_t *trio_string_duplicate TRIO_PROTO((trio_string_t *other)); TRIO_STRING_PUBLIC int trio_string_equal TRIO_PROTO((trio_string_t *self, trio_string_t *other)); TRIO_STRING_PUBLIC int trio_string_equal_max TRIO_PROTO((trio_string_t *self, size_t max, trio_string_t *second)); TRIO_STRING_PUBLIC int trio_string_equal_case TRIO_PROTO((trio_string_t *self, trio_string_t *other)); TRIO_STRING_PUBLIC int trio_string_equal_case_max TRIO_PROTO((trio_string_t *self, size_t max, trio_string_t *other)); TRIO_STRING_PUBLIC size_t trio_string_format_date_max TRIO_PROTO((trio_string_t *self, size_t max, const char *format, const struct tm *datetime)); TRIO_STRING_PUBLIC char *trio_string_index TRIO_PROTO((trio_string_t *self, int character)); TRIO_STRING_PUBLIC char *trio_string_index_last TRIO_PROTO((trio_string_t *self, int character)); TRIO_STRING_PUBLIC int trio_string_length TRIO_PROTO((trio_string_t *self)); TRIO_STRING_PUBLIC int trio_string_lower TRIO_PROTO((trio_string_t *self)); TRIO_STRING_PUBLIC int trio_string_match TRIO_PROTO((trio_string_t *self, trio_string_t *other)); TRIO_STRING_PUBLIC int trio_string_match_case TRIO_PROTO((trio_string_t *self, trio_string_t *other)); TRIO_STRING_PUBLIC char *trio_string_substring TRIO_PROTO((trio_string_t *self, trio_string_t *other)); TRIO_STRING_PUBLIC int trio_string_upper TRIO_PROTO((trio_string_t *self)); TRIO_STRING_PUBLIC int trio_xstring_append TRIO_PROTO((trio_string_t *self, const char *other)); TRIO_STRING_PUBLIC int trio_xstring_contains TRIO_PROTO((trio_string_t *self, const char *other)); TRIO_STRING_PUBLIC int trio_xstring_copy TRIO_PROTO((trio_string_t *self, const char *other)); TRIO_STRING_PUBLIC int trio_xstring_equal TRIO_PROTO((trio_string_t *self, const char *other)); TRIO_STRING_PUBLIC int trio_xstring_equal_max TRIO_PROTO((trio_string_t *self, size_t max, const char *other)); TRIO_STRING_PUBLIC int trio_xstring_equal_case TRIO_PROTO((trio_string_t *self, const char *other)); TRIO_STRING_PUBLIC int trio_xstring_equal_case_max TRIO_PROTO((trio_string_t *self, size_t max, const char *other)); TRIO_STRING_PUBLIC int trio_xstring_match TRIO_PROTO((trio_string_t *self, const char *other)); TRIO_STRING_PUBLIC int trio_xstring_match_case TRIO_PROTO((trio_string_t *self, const char *other)); TRIO_STRING_PUBLIC char *trio_xstring_substring TRIO_PROTO((trio_string_t *self, const char *other)); #endif /* !defined(TRIO_MINIMAL) */ #endif /* TRIO_TRIOSTR_H */ xdmf-3.0+git20160803/Utilities/vtklibxml2/xpath.c0000640000175000017500000165416613003006557021456 0ustar alastairalastair/* * xpath.c: XML Path Language implementation * XPath is a language for addressing parts of an XML document, * designed to be used by both XSLT and XPointer *f * Reference: W3C Recommendation 16 November 1999 * http://www.w3.org/TR/1999/REC-xpath-19991116 * Public reference: * http://www.w3.org/TR/xpath * * See Copyright for the status of this software * * Author: daniel@veillard.com * */ #define IN_LIBXML #include "libxml.h" #include #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_MATH_H #include #endif #ifdef HAVE_FLOAT_H #include #endif #ifdef HAVE_CTYPE_H #include #endif #ifdef HAVE_SIGNAL_H #include #endif #include #include #include #include #include #include #include #ifdef LIBXML_XPTR_ENABLED #include #endif #ifdef LIBXML_DEBUG_ENABLED #include #endif #include #include #include #ifdef LIBXML_PATTERN_ENABLED #include #endif #ifdef LIBXML_PATTERN_ENABLED #define XPATH_STREAMING #endif #define TODO \ xmlGenericError(xmlGenericErrorContext, \ "Unimplemented block at %s:%d\n", \ __FILE__, __LINE__); /* * XP_OPTIMIZED_NON_ELEM_COMPARISON: * If defined, this will use xmlXPathCmpNodesExt() instead of * xmlXPathCmpNodes(). The new function is optimized comparison of * non-element nodes; actually it will speed up comparison only if * xmlXPathOrderDocElems() was called in order to index the elements of * a tree in document order; Libxslt does such an indexing, thus it will * benefit from this optimization. */ #define XP_OPTIMIZED_NON_ELEM_COMPARISON /* * XP_OPTIMIZED_FILTER_FIRST: * If defined, this will optimize expressions like "key('foo', 'val')[b][1]" * in a way, that it stop evaluation at the first node. */ #define XP_OPTIMIZED_FILTER_FIRST /* * XP_DEBUG_OBJ_USAGE: * Internal flag to enable tracking of how much XPath objects have been * created. */ /* #define XP_DEBUG_OBJ_USAGE */ /* * TODO: * There are a few spots where some tests are done which depend upon ascii * data. These should be enhanced for full UTF8 support (see particularly * any use of the macros IS_ASCII_CHARACTER and IS_ASCII_DIGIT) */ #if defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) /************************************************************************ * * * Floating point stuff * * * ************************************************************************/ #ifndef TRIO_REPLACE_STDIO #define TRIO_PUBLIC static #endif #include "trionan.c" /* * The lack of portability of this section of the libc is annoying ! */ double xmlXPathNAN = 0; double xmlXPathPINF = 1; double xmlXPathNINF = -1; static double xmlXPathNZERO = 0; /* not exported from headers */ static int xmlXPathInitialized = 0; /** * xmlXPathInit: * * Initialize the XPath environment */ void xmlXPathInit(void) { if (xmlXPathInitialized) return; xmlXPathPINF = trio_pinf(); xmlXPathNINF = trio_ninf(); xmlXPathNAN = trio_nan(); xmlXPathNZERO = trio_nzero(); xmlXPathInitialized = 1; } /** * xmlXPathIsNaN: * @val: a double value * * Provides a portable isnan() function to detect whether a double * is a NotaNumber. Based on trio code * http://sourceforge.net/projects/ctrio/ * * Returns 1 if the value is a NaN, 0 otherwise */ int xmlXPathIsNaN(double val) { return(trio_isnan(val)); } /** * xmlXPathIsInf: * @val: a double value * * Provides a portable isinf() function to detect whether a double * is a +Infinite or -Infinite. Based on trio code * http://sourceforge.net/projects/ctrio/ * * Returns 1 vi the value is +Infinite, -1 if -Infinite, 0 otherwise */ int xmlXPathIsInf(double val) { return(trio_isinf(val)); } #endif /* SCHEMAS or XPATH */ #ifdef LIBXML_XPATH_ENABLED /** * xmlXPathGetSign: * @val: a double value * * Provides a portable function to detect the sign of a double * Modified from trio code * http://sourceforge.net/projects/ctrio/ * * Returns 1 if the value is Negative, 0 if positive */ static int xmlXPathGetSign(double val) { return(trio_signbit(val)); } /* * TODO: when compatibility allows remove all "fake node libxslt" strings * the test should just be name[0] = ' ' */ /* #define DEBUG */ /* #define DEBUG_STEP */ /* #define DEBUG_STEP_NTH */ /* #define DEBUG_EXPR */ /* #define DEBUG_EVAL_COUNTS */ static xmlNs xmlXPathXMLNamespaceStruct = { NULL, XML_NAMESPACE_DECL, XML_XML_NAMESPACE, BAD_CAST "xml", NULL, NULL }; static xmlNsPtr xmlXPathXMLNamespace = &xmlXPathXMLNamespaceStruct; #ifndef LIBXML_THREAD_ENABLED /* * Optimizer is disabled only when threaded apps are detected while * the library ain't compiled for thread safety. */ static int xmlXPathDisableOptimizer = 0; #endif /************************************************************************ * * * Error handling routines * * * ************************************************************************/ /** * XP_ERRORNULL: * @X: the error code * * Macro to raise an XPath error and return NULL. */ #define XP_ERRORNULL(X) \ { xmlXPathErr(ctxt, X); return(NULL); } /* * The array xmlXPathErrorMessages corresponds to the enum xmlXPathError */ static const char *xmlXPathErrorMessages[] = { "Ok\n", "Number encoding\n", "Unfinished literal\n", "Start of literal\n", "Expected $ for variable reference\n", "Undefined variable\n", "Invalid predicate\n", "Invalid expression\n", "Missing closing curly brace\n", "Unregistered function\n", "Invalid operand\n", "Invalid type\n", "Invalid number of arguments\n", "Invalid context size\n", "Invalid context position\n", "Memory allocation error\n", "Syntax error\n", "Resource error\n", "Sub resource error\n", "Undefined namespace prefix\n", "Encoding error\n", "Char out of XML range\n", "Invalid or incomplete context\n", "?? Unknown error ??\n" /* Must be last in the list! */ }; #define MAXERRNO ((int)(sizeof(xmlXPathErrorMessages) / \ sizeof(xmlXPathErrorMessages[0])) - 1) /** * xmlXPathErrMemory: * @ctxt: an XPath context * @extra: extra informations * * Handle a redefinition of attribute error */ static void xmlXPathErrMemory(xmlXPathContextPtr ctxt, const char *extra) { if (ctxt != NULL) { if (extra) { xmlChar buf[200]; xmlStrPrintf(buf, 200, BAD_CAST "Memory allocation failed : %s\n", extra); ctxt->lastError.message = (char *) xmlStrdup(buf); } else { ctxt->lastError.message = (char *) xmlStrdup(BAD_CAST "Memory allocation failed\n"); } ctxt->lastError.domain = XML_FROM_XPATH; ctxt->lastError.code = XML_ERR_NO_MEMORY; if (ctxt->error != NULL) ctxt->error(ctxt->userData, &ctxt->lastError); } else { if (extra) __xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_XPATH, XML_ERR_NO_MEMORY, XML_ERR_FATAL, NULL, 0, extra, NULL, NULL, 0, 0, "Memory allocation failed : %s\n", extra); else __xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_XPATH, XML_ERR_NO_MEMORY, XML_ERR_FATAL, NULL, 0, NULL, NULL, NULL, 0, 0, "Memory allocation failed\n"); } } /** * xmlXPathPErrMemory: * @ctxt: an XPath parser context * @extra: extra informations * * Handle a redefinition of attribute error */ static void xmlXPathPErrMemory(xmlXPathParserContextPtr ctxt, const char *extra) { if (ctxt == NULL) xmlXPathErrMemory(NULL, extra); else { ctxt->error = XPATH_MEMORY_ERROR; xmlXPathErrMemory(ctxt->context, extra); } } /** * xmlXPathErr: * @ctxt: a XPath parser context * @error: the error code * * Handle an XPath error */ void xmlXPathErr(xmlXPathParserContextPtr ctxt, int error) { if ((error < 0) || (error > MAXERRNO)) error = MAXERRNO; if (ctxt == NULL) { __xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_XPATH, error + XML_XPATH_EXPRESSION_OK - XPATH_EXPRESSION_OK, XML_ERR_ERROR, NULL, 0, NULL, NULL, NULL, 0, 0, xmlXPathErrorMessages[error]); return; } ctxt->error = error; if (ctxt->context == NULL) { __xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_XPATH, error + XML_XPATH_EXPRESSION_OK - XPATH_EXPRESSION_OK, XML_ERR_ERROR, NULL, 0, (const char *) ctxt->base, NULL, NULL, ctxt->cur - ctxt->base, 0, xmlXPathErrorMessages[error]); return; } /* cleanup current last error */ xmlResetError(&ctxt->context->lastError); ctxt->context->lastError.domain = XML_FROM_XPATH; ctxt->context->lastError.code = error + XML_XPATH_EXPRESSION_OK - XPATH_EXPRESSION_OK; ctxt->context->lastError.level = XML_ERR_ERROR; ctxt->context->lastError.str1 = (char *) xmlStrdup(ctxt->base); ctxt->context->lastError.int1 = ctxt->cur - ctxt->base; ctxt->context->lastError.node = ctxt->context->debugNode; if (ctxt->context->error != NULL) { ctxt->context->error(ctxt->context->userData, &ctxt->context->lastError); } else { __xmlRaiseError(NULL, NULL, NULL, NULL, ctxt->context->debugNode, XML_FROM_XPATH, error + XML_XPATH_EXPRESSION_OK - XPATH_EXPRESSION_OK, XML_ERR_ERROR, NULL, 0, (const char *) ctxt->base, NULL, NULL, ctxt->cur - ctxt->base, 0, xmlXPathErrorMessages[error]); } } /** * xmlXPatherror: * @ctxt: the XPath Parser context * @file: the file name * @line: the line number * @no: the error number * * Formats an error message. */ void xmlXPatherror(xmlXPathParserContextPtr ctxt, const char *file ATTRIBUTE_UNUSED, int line ATTRIBUTE_UNUSED, int no) { xmlXPathErr(ctxt, no); } /************************************************************************ * * * Utilities * * * ************************************************************************/ /** * xsltPointerList: * * Pointer-list for various purposes. */ typedef struct _xmlPointerList xmlPointerList; typedef xmlPointerList *xmlPointerListPtr; struct _xmlPointerList { void **items; int number; int size; }; /* * TODO: Since such a list-handling is used in xmlschemas.c and libxslt * and here, we should make the functions public. */ static int xmlPointerListAddSize(xmlPointerListPtr list, void *item, int initialSize) { if (list->items == NULL) { if (initialSize <= 0) initialSize = 1; list->items = (void **) xmlMalloc( initialSize * sizeof(void *)); if (list->items == NULL) { xmlXPathErrMemory(NULL, "xmlPointerListCreate: allocating item\n"); return(-1); } list->number = 0; list->size = initialSize; } else if (list->size <= list->number) { list->size *= 2; list->items = (void **) xmlRealloc(list->items, list->size * sizeof(void *)); if (list->items == NULL) { xmlXPathErrMemory(NULL, "xmlPointerListCreate: re-allocating item\n"); list->size = 0; return(-1); } } list->items[list->number++] = item; return(0); } /** * xsltPointerListCreate: * * Creates an xsltPointerList structure. * * Returns a xsltPointerList structure or NULL in case of an error. */ static xmlPointerListPtr xmlPointerListCreate(int initialSize) { xmlPointerListPtr ret; ret = xmlMalloc(sizeof(xmlPointerList)); if (ret == NULL) { xmlXPathErrMemory(NULL, "xmlPointerListCreate: allocating item\n"); return (NULL); } memset(ret, 0, sizeof(xmlPointerList)); if (initialSize > 0) { xmlPointerListAddSize(ret, NULL, initialSize); ret->number = 0; } return (ret); } /** * xsltPointerListFree: * * Frees the xsltPointerList structure. This does not free * the content of the list. */ static void xmlPointerListFree(xmlPointerListPtr list) { if (list == NULL) return; if (list->items != NULL) xmlFree(list->items); xmlFree(list); } /************************************************************************ * * * Parser Types * * * ************************************************************************/ /* * Types are private: */ typedef enum { XPATH_OP_END=0, XPATH_OP_AND, XPATH_OP_OR, XPATH_OP_EQUAL, XPATH_OP_CMP, XPATH_OP_PLUS, XPATH_OP_MULT, XPATH_OP_UNION, XPATH_OP_ROOT, XPATH_OP_NODE, XPATH_OP_RESET, /* 10 */ XPATH_OP_COLLECT, XPATH_OP_VALUE, /* 12 */ XPATH_OP_VARIABLE, XPATH_OP_FUNCTION, XPATH_OP_ARG, XPATH_OP_PREDICATE, XPATH_OP_FILTER, /* 17 */ XPATH_OP_SORT /* 18 */ #ifdef LIBXML_XPTR_ENABLED ,XPATH_OP_RANGETO #endif } xmlXPathOp; typedef enum { AXIS_ANCESTOR = 1, AXIS_ANCESTOR_OR_SELF, AXIS_ATTRIBUTE, AXIS_CHILD, AXIS_DESCENDANT, AXIS_DESCENDANT_OR_SELF, AXIS_FOLLOWING, AXIS_FOLLOWING_SIBLING, AXIS_NAMESPACE, AXIS_PARENT, AXIS_PRECEDING, AXIS_PRECEDING_SIBLING, AXIS_SELF } xmlXPathAxisVal; typedef enum { NODE_TEST_NONE = 0, NODE_TEST_TYPE = 1, NODE_TEST_PI = 2, NODE_TEST_ALL = 3, NODE_TEST_NS = 4, NODE_TEST_NAME = 5 } xmlXPathTestVal; typedef enum { NODE_TYPE_NODE = 0, NODE_TYPE_COMMENT = XML_COMMENT_NODE, NODE_TYPE_TEXT = XML_TEXT_NODE, NODE_TYPE_PI = XML_PI_NODE } xmlXPathTypeVal; #define XP_REWRITE_DOS_CHILD_ELEM 1 typedef struct _xmlXPathStepOp xmlXPathStepOp; typedef xmlXPathStepOp *xmlXPathStepOpPtr; struct _xmlXPathStepOp { xmlXPathOp op; /* The identifier of the operation */ int ch1; /* First child */ int ch2; /* Second child */ int value; int value2; int value3; void *value4; void *value5; void *cache; void *cacheURI; int rewriteType; }; struct _xmlXPathCompExpr { int nbStep; /* Number of steps in this expression */ int maxStep; /* Maximum number of steps allocated */ xmlXPathStepOp *steps; /* ops for computation of this expression */ int last; /* index of last step in expression */ xmlChar *expr; /* the expression being computed */ xmlDictPtr dict; /* the dictionnary to use if any */ #ifdef DEBUG_EVAL_COUNTS int nb; xmlChar *string; #endif #ifdef XPATH_STREAMING xmlPatternPtr stream; #endif }; /************************************************************************ * * * Forward declarations * * * ************************************************************************/ static void xmlXPathFreeValueTree(xmlNodeSetPtr obj); static void xmlXPathReleaseObject(xmlXPathContextPtr ctxt, xmlXPathObjectPtr obj); static int xmlXPathCompOpEvalFirst(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op, xmlNodePtr *first); static int xmlXPathCompOpEvalToBoolean(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op, int isPredicate); /************************************************************************ * * * Parser Type functions * * * ************************************************************************/ /** * xmlXPathNewCompExpr: * * Create a new Xpath component * * Returns the newly allocated xmlXPathCompExprPtr or NULL in case of error */ static xmlXPathCompExprPtr xmlXPathNewCompExpr(void) { xmlXPathCompExprPtr cur; cur = (xmlXPathCompExprPtr) xmlMalloc(sizeof(xmlXPathCompExpr)); if (cur == NULL) { xmlXPathErrMemory(NULL, "allocating component\n"); return(NULL); } memset(cur, 0, sizeof(xmlXPathCompExpr)); cur->maxStep = 10; cur->nbStep = 0; cur->steps = (xmlXPathStepOp *) xmlMalloc(cur->maxStep * sizeof(xmlXPathStepOp)); if (cur->steps == NULL) { xmlXPathErrMemory(NULL, "allocating steps\n"); xmlFree(cur); return(NULL); } memset(cur->steps, 0, cur->maxStep * sizeof(xmlXPathStepOp)); cur->last = -1; #ifdef DEBUG_EVAL_COUNTS cur->nb = 0; #endif return(cur); } /** * xmlXPathFreeCompExpr: * @comp: an XPATH comp * * Free up the memory allocated by @comp */ void xmlXPathFreeCompExpr(xmlXPathCompExprPtr comp) { xmlXPathStepOpPtr op; int i; if (comp == NULL) return; if (comp->dict == NULL) { for (i = 0; i < comp->nbStep; i++) { op = &comp->steps[i]; if (op->value4 != NULL) { if (op->op == XPATH_OP_VALUE) xmlXPathFreeObject(op->value4); else xmlFree(op->value4); } if (op->value5 != NULL) xmlFree(op->value5); } } else { for (i = 0; i < comp->nbStep; i++) { op = &comp->steps[i]; if (op->value4 != NULL) { if (op->op == XPATH_OP_VALUE) xmlXPathFreeObject(op->value4); } } xmlDictFree(comp->dict); } if (comp->steps != NULL) { xmlFree(comp->steps); } #ifdef DEBUG_EVAL_COUNTS if (comp->string != NULL) { xmlFree(comp->string); } #endif #ifdef XPATH_STREAMING if (comp->stream != NULL) { xmlFreePatternList(comp->stream); } #endif if (comp->expr != NULL) { xmlFree(comp->expr); } xmlFree(comp); } /** * xmlXPathCompExprAdd: * @comp: the compiled expression * @ch1: first child index * @ch2: second child index * @op: an op * @value: the first int value * @value2: the second int value * @value3: the third int value * @value4: the first string value * @value5: the second string value * * Add a step to an XPath Compiled Expression * * Returns -1 in case of failure, the index otherwise */ static int xmlXPathCompExprAdd(xmlXPathCompExprPtr comp, int ch1, int ch2, xmlXPathOp op, int value, int value2, int value3, void *value4, void *value5) { if (comp->nbStep >= comp->maxStep) { xmlXPathStepOp *real; comp->maxStep *= 2; real = (xmlXPathStepOp *) xmlRealloc(comp->steps, comp->maxStep * sizeof(xmlXPathStepOp)); if (real == NULL) { comp->maxStep /= 2; xmlXPathErrMemory(NULL, "adding step\n"); return(-1); } comp->steps = real; } comp->last = comp->nbStep; comp->steps[comp->nbStep].rewriteType = 0; comp->steps[comp->nbStep].ch1 = ch1; comp->steps[comp->nbStep].ch2 = ch2; comp->steps[comp->nbStep].op = op; comp->steps[comp->nbStep].value = value; comp->steps[comp->nbStep].value2 = value2; comp->steps[comp->nbStep].value3 = value3; if ((comp->dict != NULL) && ((op == XPATH_OP_FUNCTION) || (op == XPATH_OP_VARIABLE) || (op == XPATH_OP_COLLECT))) { if (value4 != NULL) { comp->steps[comp->nbStep].value4 = (xmlChar *) (void *)xmlDictLookup(comp->dict, value4, -1); xmlFree(value4); } else comp->steps[comp->nbStep].value4 = NULL; if (value5 != NULL) { comp->steps[comp->nbStep].value5 = (xmlChar *) (void *)xmlDictLookup(comp->dict, value5, -1); xmlFree(value5); } else comp->steps[comp->nbStep].value5 = NULL; } else { comp->steps[comp->nbStep].value4 = value4; comp->steps[comp->nbStep].value5 = value5; } comp->steps[comp->nbStep].cache = NULL; return(comp->nbStep++); } /** * xmlXPathCompSwap: * @comp: the compiled expression * @op: operation index * * Swaps 2 operations in the compiled expression */ static void xmlXPathCompSwap(xmlXPathStepOpPtr op) { int tmp; #ifndef LIBXML_THREAD_ENABLED /* * Since this manipulates possibly shared variables, this is * disabled if one detects that the library is used in a multithreaded * application */ if (xmlXPathDisableOptimizer) return; #endif tmp = op->ch1; op->ch1 = op->ch2; op->ch2 = tmp; } #define PUSH_FULL_EXPR(op, op1, op2, val, val2, val3, val4, val5) \ xmlXPathCompExprAdd(ctxt->comp, (op1), (op2), \ (op), (val), (val2), (val3), (val4), (val5)) #define PUSH_LONG_EXPR(op, val, val2, val3, val4, val5) \ xmlXPathCompExprAdd(ctxt->comp, ctxt->comp->last, -1, \ (op), (val), (val2), (val3), (val4), (val5)) #define PUSH_LEAVE_EXPR(op, val, val2) \ xmlXPathCompExprAdd(ctxt->comp, -1, -1, (op), (val), (val2), 0 ,NULL ,NULL) #define PUSH_UNARY_EXPR(op, ch, val, val2) \ xmlXPathCompExprAdd(ctxt->comp, (ch), -1, (op), (val), (val2), 0 ,NULL ,NULL) #define PUSH_BINARY_EXPR(op, ch1, ch2, val, val2) \ xmlXPathCompExprAdd(ctxt->comp, (ch1), (ch2), (op), \ (val), (val2), 0 ,NULL ,NULL) /************************************************************************ * * * XPath object cache structures * * * ************************************************************************/ /* #define XP_DEFAULT_CACHE_ON */ #define XP_HAS_CACHE(c) ((c != NULL) && ((c)->cache != NULL)) typedef struct _xmlXPathContextCache xmlXPathContextCache; typedef xmlXPathContextCache *xmlXPathContextCachePtr; struct _xmlXPathContextCache { xmlPointerListPtr nodesetObjs; /* contains xmlXPathObjectPtr */ xmlPointerListPtr stringObjs; /* contains xmlXPathObjectPtr */ xmlPointerListPtr booleanObjs; /* contains xmlXPathObjectPtr */ xmlPointerListPtr numberObjs; /* contains xmlXPathObjectPtr */ xmlPointerListPtr miscObjs; /* contains xmlXPathObjectPtr */ int maxNodeset; int maxString; int maxBoolean; int maxNumber; int maxMisc; #ifdef XP_DEBUG_OBJ_USAGE int dbgCachedAll; int dbgCachedNodeset; int dbgCachedString; int dbgCachedBool; int dbgCachedNumber; int dbgCachedPoint; int dbgCachedRange; int dbgCachedLocset; int dbgCachedUsers; int dbgCachedXSLTTree; int dbgCachedUndefined; int dbgReusedAll; int dbgReusedNodeset; int dbgReusedString; int dbgReusedBool; int dbgReusedNumber; int dbgReusedPoint; int dbgReusedRange; int dbgReusedLocset; int dbgReusedUsers; int dbgReusedXSLTTree; int dbgReusedUndefined; #endif }; /************************************************************************ * * * Debugging related functions * * * ************************************************************************/ #define STRANGE \ xmlGenericError(xmlGenericErrorContext, \ "Internal error at %s:%d\n", \ __FILE__, __LINE__); #ifdef LIBXML_DEBUG_ENABLED static void xmlXPathDebugDumpNode(FILE *output, xmlNodePtr cur, int depth) { int i; char shift[100]; for (i = 0;((i < depth) && (i < 25));i++) shift[2 * i] = shift[2 * i + 1] = ' '; shift[2 * i] = shift[2 * i + 1] = 0; if (cur == NULL) { fprintf(output, shift); fprintf(output, "Node is NULL !\n"); return; } if ((cur->type == XML_DOCUMENT_NODE) || (cur->type == XML_HTML_DOCUMENT_NODE)) { fprintf(output, shift); fprintf(output, " /\n"); } else if (cur->type == XML_ATTRIBUTE_NODE) xmlDebugDumpAttr(output, (xmlAttrPtr)cur, depth); else xmlDebugDumpOneNode(output, cur, depth); } static void xmlXPathDebugDumpNodeList(FILE *output, xmlNodePtr cur, int depth) { xmlNodePtr tmp; int i; char shift[100]; for (i = 0;((i < depth) && (i < 25));i++) shift[2 * i] = shift[2 * i + 1] = ' '; shift[2 * i] = shift[2 * i + 1] = 0; if (cur == NULL) { fprintf(output, shift); fprintf(output, "Node is NULL !\n"); return; } while (cur != NULL) { tmp = cur; cur = cur->next; xmlDebugDumpOneNode(output, tmp, depth); } } static void xmlXPathDebugDumpNodeSet(FILE *output, xmlNodeSetPtr cur, int depth) { int i; char shift[100]; for (i = 0;((i < depth) && (i < 25));i++) shift[2 * i] = shift[2 * i + 1] = ' '; shift[2 * i] = shift[2 * i + 1] = 0; if (cur == NULL) { fprintf(output, shift); fprintf(output, "NodeSet is NULL !\n"); return; } if (cur != NULL) { fprintf(output, "Set contains %d nodes:\n", cur->nodeNr); for (i = 0;i < cur->nodeNr;i++) { fprintf(output, shift); fprintf(output, "%d", i + 1); xmlXPathDebugDumpNode(output, cur->nodeTab[i], depth + 1); } } } static void xmlXPathDebugDumpValueTree(FILE *output, xmlNodeSetPtr cur, int depth) { int i; char shift[100]; for (i = 0;((i < depth) && (i < 25));i++) shift[2 * i] = shift[2 * i + 1] = ' '; shift[2 * i] = shift[2 * i + 1] = 0; if ((cur == NULL) || (cur->nodeNr == 0) || (cur->nodeTab[0] == NULL)) { fprintf(output, shift); fprintf(output, "Value Tree is NULL !\n"); return; } fprintf(output, shift); fprintf(output, "%d", i + 1); xmlXPathDebugDumpNodeList(output, cur->nodeTab[0]->children, depth + 1); } #if defined(LIBXML_XPTR_ENABLED) static void xmlXPathDebugDumpLocationSet(FILE *output, xmlLocationSetPtr cur, int depth) { int i; char shift[100]; for (i = 0;((i < depth) && (i < 25));i++) shift[2 * i] = shift[2 * i + 1] = ' '; shift[2 * i] = shift[2 * i + 1] = 0; if (cur == NULL) { fprintf(output, shift); fprintf(output, "LocationSet is NULL !\n"); return; } for (i = 0;i < cur->locNr;i++) { fprintf(output, shift); fprintf(output, "%d : ", i + 1); xmlXPathDebugDumpObject(output, cur->locTab[i], depth + 1); } } #endif /* LIBXML_XPTR_ENABLED */ /** * xmlXPathDebugDumpObject: * @output: the FILE * to dump the output * @cur: the object to inspect * @depth: indentation level * * Dump the content of the object for debugging purposes */ void xmlXPathDebugDumpObject(FILE *output, xmlXPathObjectPtr cur, int depth) { int i; char shift[100]; if (output == NULL) return; for (i = 0;((i < depth) && (i < 25));i++) shift[2 * i] = shift[2 * i + 1] = ' '; shift[2 * i] = shift[2 * i + 1] = 0; fprintf(output, shift); if (cur == NULL) { fprintf(output, "Object is empty (NULL)\n"); return; } switch(cur->type) { case XPATH_UNDEFINED: fprintf(output, "Object is uninitialized\n"); break; case XPATH_NODESET: fprintf(output, "Object is a Node Set :\n"); xmlXPathDebugDumpNodeSet(output, cur->nodesetval, depth); break; case XPATH_XSLT_TREE: fprintf(output, "Object is an XSLT value tree :\n"); xmlXPathDebugDumpValueTree(output, cur->nodesetval, depth); break; case XPATH_BOOLEAN: fprintf(output, "Object is a Boolean : "); if (cur->boolval) fprintf(output, "true\n"); else fprintf(output, "false\n"); break; case XPATH_NUMBER: switch (xmlXPathIsInf(cur->floatval)) { case 1: fprintf(output, "Object is a number : Infinity\n"); break; case -1: fprintf(output, "Object is a number : -Infinity\n"); break; default: if (xmlXPathIsNaN(cur->floatval)) { fprintf(output, "Object is a number : NaN\n"); } else if (cur->floatval == 0 && xmlXPathGetSign(cur->floatval) != 0) { fprintf(output, "Object is a number : 0\n"); } else { fprintf(output, "Object is a number : %0g\n", cur->floatval); } } break; case XPATH_STRING: fprintf(output, "Object is a string : "); xmlDebugDumpString(output, cur->stringval); fprintf(output, "\n"); break; case XPATH_POINT: fprintf(output, "Object is a point : index %d in node", cur->index); xmlXPathDebugDumpNode(output, (xmlNodePtr) cur->user, depth + 1); fprintf(output, "\n"); break; case XPATH_RANGE: if ((cur->user2 == NULL) || ((cur->user2 == cur->user) && (cur->index == cur->index2))) { fprintf(output, "Object is a collapsed range :\n"); fprintf(output, shift); if (cur->index >= 0) fprintf(output, "index %d in ", cur->index); fprintf(output, "node\n"); xmlXPathDebugDumpNode(output, (xmlNodePtr) cur->user, depth + 1); } else { fprintf(output, "Object is a range :\n"); fprintf(output, shift); fprintf(output, "From "); if (cur->index >= 0) fprintf(output, "index %d in ", cur->index); fprintf(output, "node\n"); xmlXPathDebugDumpNode(output, (xmlNodePtr) cur->user, depth + 1); fprintf(output, shift); fprintf(output, "To "); if (cur->index2 >= 0) fprintf(output, "index %d in ", cur->index2); fprintf(output, "node\n"); xmlXPathDebugDumpNode(output, (xmlNodePtr) cur->user2, depth + 1); fprintf(output, "\n"); } break; case XPATH_LOCATIONSET: #if defined(LIBXML_XPTR_ENABLED) fprintf(output, "Object is a Location Set:\n"); xmlXPathDebugDumpLocationSet(output, (xmlLocationSetPtr) cur->user, depth); #endif break; case XPATH_USERS: fprintf(output, "Object is user defined\n"); break; } } static void xmlXPathDebugDumpStepOp(FILE *output, xmlXPathCompExprPtr comp, xmlXPathStepOpPtr op, int depth) { int i; char shift[100]; for (i = 0;((i < depth) && (i < 25));i++) shift[2 * i] = shift[2 * i + 1] = ' '; shift[2 * i] = shift[2 * i + 1] = 0; fprintf(output, shift); if (op == NULL) { fprintf(output, "Step is NULL\n"); return; } switch (op->op) { case XPATH_OP_END: fprintf(output, "END"); break; case XPATH_OP_AND: fprintf(output, "AND"); break; case XPATH_OP_OR: fprintf(output, "OR"); break; case XPATH_OP_EQUAL: if (op->value) fprintf(output, "EQUAL ="); else fprintf(output, "EQUAL !="); break; case XPATH_OP_CMP: if (op->value) fprintf(output, "CMP <"); else fprintf(output, "CMP >"); if (!op->value2) fprintf(output, "="); break; case XPATH_OP_PLUS: if (op->value == 0) fprintf(output, "PLUS -"); else if (op->value == 1) fprintf(output, "PLUS +"); else if (op->value == 2) fprintf(output, "PLUS unary -"); else if (op->value == 3) fprintf(output, "PLUS unary - -"); break; case XPATH_OP_MULT: if (op->value == 0) fprintf(output, "MULT *"); else if (op->value == 1) fprintf(output, "MULT div"); else fprintf(output, "MULT mod"); break; case XPATH_OP_UNION: fprintf(output, "UNION"); break; case XPATH_OP_ROOT: fprintf(output, "ROOT"); break; case XPATH_OP_NODE: fprintf(output, "NODE"); break; case XPATH_OP_RESET: fprintf(output, "RESET"); break; case XPATH_OP_SORT: fprintf(output, "SORT"); break; case XPATH_OP_COLLECT: { xmlXPathAxisVal axis = (xmlXPathAxisVal)op->value; xmlXPathTestVal test = (xmlXPathTestVal)op->value2; xmlXPathTypeVal type = (xmlXPathTypeVal)op->value3; const xmlChar *prefix = op->value4; const xmlChar *name = op->value5; fprintf(output, "COLLECT "); switch (axis) { case AXIS_ANCESTOR: fprintf(output, " 'ancestors' "); break; case AXIS_ANCESTOR_OR_SELF: fprintf(output, " 'ancestors-or-self' "); break; case AXIS_ATTRIBUTE: fprintf(output, " 'attributes' "); break; case AXIS_CHILD: fprintf(output, " 'child' "); break; case AXIS_DESCENDANT: fprintf(output, " 'descendant' "); break; case AXIS_DESCENDANT_OR_SELF: fprintf(output, " 'descendant-or-self' "); break; case AXIS_FOLLOWING: fprintf(output, " 'following' "); break; case AXIS_FOLLOWING_SIBLING: fprintf(output, " 'following-siblings' "); break; case AXIS_NAMESPACE: fprintf(output, " 'namespace' "); break; case AXIS_PARENT: fprintf(output, " 'parent' "); break; case AXIS_PRECEDING: fprintf(output, " 'preceding' "); break; case AXIS_PRECEDING_SIBLING: fprintf(output, " 'preceding-sibling' "); break; case AXIS_SELF: fprintf(output, " 'self' "); break; } switch (test) { case NODE_TEST_NONE: fprintf(output, "'none' "); break; case NODE_TEST_TYPE: fprintf(output, "'type' "); break; case NODE_TEST_PI: fprintf(output, "'PI' "); break; case NODE_TEST_ALL: fprintf(output, "'all' "); break; case NODE_TEST_NS: fprintf(output, "'namespace' "); break; case NODE_TEST_NAME: fprintf(output, "'name' "); break; } switch (type) { case NODE_TYPE_NODE: fprintf(output, "'node' "); break; case NODE_TYPE_COMMENT: fprintf(output, "'comment' "); break; case NODE_TYPE_TEXT: fprintf(output, "'text' "); break; case NODE_TYPE_PI: fprintf(output, "'PI' "); break; } if (prefix != NULL) fprintf(output, "%s:", prefix); if (name != NULL) fprintf(output, "%s", (const char *) name); break; } case XPATH_OP_VALUE: { xmlXPathObjectPtr object = (xmlXPathObjectPtr) op->value4; fprintf(output, "ELEM "); xmlXPathDebugDumpObject(output, object, 0); goto finish; } case XPATH_OP_VARIABLE: { const xmlChar *prefix = op->value5; const xmlChar *name = op->value4; if (prefix != NULL) fprintf(output, "VARIABLE %s:%s", prefix, name); else fprintf(output, "VARIABLE %s", name); break; } case XPATH_OP_FUNCTION: { int nbargs = op->value; const xmlChar *prefix = op->value5; const xmlChar *name = op->value4; if (prefix != NULL) fprintf(output, "FUNCTION %s:%s(%d args)", prefix, name, nbargs); else fprintf(output, "FUNCTION %s(%d args)", name, nbargs); break; } case XPATH_OP_ARG: fprintf(output, "ARG"); break; case XPATH_OP_PREDICATE: fprintf(output, "PREDICATE"); break; case XPATH_OP_FILTER: fprintf(output, "FILTER"); break; #ifdef LIBXML_XPTR_ENABLED case XPATH_OP_RANGETO: fprintf(output, "RANGETO"); break; #endif default: fprintf(output, "UNKNOWN %d\n", op->op); return; } fprintf(output, "\n"); finish: if (op->ch1 >= 0) xmlXPathDebugDumpStepOp(output, comp, &comp->steps[op->ch1], depth + 1); if (op->ch2 >= 0) xmlXPathDebugDumpStepOp(output, comp, &comp->steps[op->ch2], depth + 1); } /** * xmlXPathDebugDumpCompExpr: * @output: the FILE * for the output * @comp: the precompiled XPath expression * @depth: the indentation level. * * Dumps the tree of the compiled XPath expression. */ void xmlXPathDebugDumpCompExpr(FILE *output, xmlXPathCompExprPtr comp, int depth) { int i; char shift[100]; if ((output == NULL) || (comp == NULL)) return; for (i = 0;((i < depth) && (i < 25));i++) shift[2 * i] = shift[2 * i + 1] = ' '; shift[2 * i] = shift[2 * i + 1] = 0; fprintf(output, shift); fprintf(output, "Compiled Expression : %d elements\n", comp->nbStep); i = comp->last; xmlXPathDebugDumpStepOp(output, comp, &comp->steps[i], depth + 1); } #ifdef XP_DEBUG_OBJ_USAGE /* * XPath object usage related debugging variables. */ static int xmlXPathDebugObjCounterUndefined = 0; static int xmlXPathDebugObjCounterNodeset = 0; static int xmlXPathDebugObjCounterBool = 0; static int xmlXPathDebugObjCounterNumber = 0; static int xmlXPathDebugObjCounterString = 0; static int xmlXPathDebugObjCounterPoint = 0; static int xmlXPathDebugObjCounterRange = 0; static int xmlXPathDebugObjCounterLocset = 0; static int xmlXPathDebugObjCounterUsers = 0; static int xmlXPathDebugObjCounterXSLTTree = 0; static int xmlXPathDebugObjCounterAll = 0; static int xmlXPathDebugObjTotalUndefined = 0; static int xmlXPathDebugObjTotalNodeset = 0; static int xmlXPathDebugObjTotalBool = 0; static int xmlXPathDebugObjTotalNumber = 0; static int xmlXPathDebugObjTotalString = 0; static int xmlXPathDebugObjTotalPoint = 0; static int xmlXPathDebugObjTotalRange = 0; static int xmlXPathDebugObjTotalLocset = 0; static int xmlXPathDebugObjTotalUsers = 0; static int xmlXPathDebugObjTotalXSLTTree = 0; static int xmlXPathDebugObjTotalAll = 0; static int xmlXPathDebugObjMaxUndefined = 0; static int xmlXPathDebugObjMaxNodeset = 0; static int xmlXPathDebugObjMaxBool = 0; static int xmlXPathDebugObjMaxNumber = 0; static int xmlXPathDebugObjMaxString = 0; static int xmlXPathDebugObjMaxPoint = 0; static int xmlXPathDebugObjMaxRange = 0; static int xmlXPathDebugObjMaxLocset = 0; static int xmlXPathDebugObjMaxUsers = 0; static int xmlXPathDebugObjMaxXSLTTree = 0; static int xmlXPathDebugObjMaxAll = 0; /* REVISIT TODO: Make this static when committing */ static void xmlXPathDebugObjUsageReset(xmlXPathContextPtr ctxt) { if (ctxt != NULL) { if (ctxt->cache != NULL) { xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache; cache->dbgCachedAll = 0; cache->dbgCachedNodeset = 0; cache->dbgCachedString = 0; cache->dbgCachedBool = 0; cache->dbgCachedNumber = 0; cache->dbgCachedPoint = 0; cache->dbgCachedRange = 0; cache->dbgCachedLocset = 0; cache->dbgCachedUsers = 0; cache->dbgCachedXSLTTree = 0; cache->dbgCachedUndefined = 0; cache->dbgReusedAll = 0; cache->dbgReusedNodeset = 0; cache->dbgReusedString = 0; cache->dbgReusedBool = 0; cache->dbgReusedNumber = 0; cache->dbgReusedPoint = 0; cache->dbgReusedRange = 0; cache->dbgReusedLocset = 0; cache->dbgReusedUsers = 0; cache->dbgReusedXSLTTree = 0; cache->dbgReusedUndefined = 0; } } xmlXPathDebugObjCounterUndefined = 0; xmlXPathDebugObjCounterNodeset = 0; xmlXPathDebugObjCounterBool = 0; xmlXPathDebugObjCounterNumber = 0; xmlXPathDebugObjCounterString = 0; xmlXPathDebugObjCounterPoint = 0; xmlXPathDebugObjCounterRange = 0; xmlXPathDebugObjCounterLocset = 0; xmlXPathDebugObjCounterUsers = 0; xmlXPathDebugObjCounterXSLTTree = 0; xmlXPathDebugObjCounterAll = 0; xmlXPathDebugObjTotalUndefined = 0; xmlXPathDebugObjTotalNodeset = 0; xmlXPathDebugObjTotalBool = 0; xmlXPathDebugObjTotalNumber = 0; xmlXPathDebugObjTotalString = 0; xmlXPathDebugObjTotalPoint = 0; xmlXPathDebugObjTotalRange = 0; xmlXPathDebugObjTotalLocset = 0; xmlXPathDebugObjTotalUsers = 0; xmlXPathDebugObjTotalXSLTTree = 0; xmlXPathDebugObjTotalAll = 0; xmlXPathDebugObjMaxUndefined = 0; xmlXPathDebugObjMaxNodeset = 0; xmlXPathDebugObjMaxBool = 0; xmlXPathDebugObjMaxNumber = 0; xmlXPathDebugObjMaxString = 0; xmlXPathDebugObjMaxPoint = 0; xmlXPathDebugObjMaxRange = 0; xmlXPathDebugObjMaxLocset = 0; xmlXPathDebugObjMaxUsers = 0; xmlXPathDebugObjMaxXSLTTree = 0; xmlXPathDebugObjMaxAll = 0; } static void xmlXPathDebugObjUsageRequested(xmlXPathContextPtr ctxt, xmlXPathObjectType objType) { int isCached = 0; if (ctxt != NULL) { if (ctxt->cache != NULL) { xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache; isCached = 1; cache->dbgReusedAll++; switch (objType) { case XPATH_UNDEFINED: cache->dbgReusedUndefined++; break; case XPATH_NODESET: cache->dbgReusedNodeset++; break; case XPATH_BOOLEAN: cache->dbgReusedBool++; break; case XPATH_NUMBER: cache->dbgReusedNumber++; break; case XPATH_STRING: cache->dbgReusedString++; break; case XPATH_POINT: cache->dbgReusedPoint++; break; case XPATH_RANGE: cache->dbgReusedRange++; break; case XPATH_LOCATIONSET: cache->dbgReusedLocset++; break; case XPATH_USERS: cache->dbgReusedUsers++; break; case XPATH_XSLT_TREE: cache->dbgReusedXSLTTree++; break; default: break; } } } switch (objType) { case XPATH_UNDEFINED: if (! isCached) xmlXPathDebugObjTotalUndefined++; xmlXPathDebugObjCounterUndefined++; if (xmlXPathDebugObjCounterUndefined > xmlXPathDebugObjMaxUndefined) xmlXPathDebugObjMaxUndefined = xmlXPathDebugObjCounterUndefined; break; case XPATH_NODESET: if (! isCached) xmlXPathDebugObjTotalNodeset++; xmlXPathDebugObjCounterNodeset++; if (xmlXPathDebugObjCounterNodeset > xmlXPathDebugObjMaxNodeset) xmlXPathDebugObjMaxNodeset = xmlXPathDebugObjCounterNodeset; break; case XPATH_BOOLEAN: if (! isCached) xmlXPathDebugObjTotalBool++; xmlXPathDebugObjCounterBool++; if (xmlXPathDebugObjCounterBool > xmlXPathDebugObjMaxBool) xmlXPathDebugObjMaxBool = xmlXPathDebugObjCounterBool; break; case XPATH_NUMBER: if (! isCached) xmlXPathDebugObjTotalNumber++; xmlXPathDebugObjCounterNumber++; if (xmlXPathDebugObjCounterNumber > xmlXPathDebugObjMaxNumber) xmlXPathDebugObjMaxNumber = xmlXPathDebugObjCounterNumber; break; case XPATH_STRING: if (! isCached) xmlXPathDebugObjTotalString++; xmlXPathDebugObjCounterString++; if (xmlXPathDebugObjCounterString > xmlXPathDebugObjMaxString) xmlXPathDebugObjMaxString = xmlXPathDebugObjCounterString; break; case XPATH_POINT: if (! isCached) xmlXPathDebugObjTotalPoint++; xmlXPathDebugObjCounterPoint++; if (xmlXPathDebugObjCounterPoint > xmlXPathDebugObjMaxPoint) xmlXPathDebugObjMaxPoint = xmlXPathDebugObjCounterPoint; break; case XPATH_RANGE: if (! isCached) xmlXPathDebugObjTotalRange++; xmlXPathDebugObjCounterRange++; if (xmlXPathDebugObjCounterRange > xmlXPathDebugObjMaxRange) xmlXPathDebugObjMaxRange = xmlXPathDebugObjCounterRange; break; case XPATH_LOCATIONSET: if (! isCached) xmlXPathDebugObjTotalLocset++; xmlXPathDebugObjCounterLocset++; if (xmlXPathDebugObjCounterLocset > xmlXPathDebugObjMaxLocset) xmlXPathDebugObjMaxLocset = xmlXPathDebugObjCounterLocset; break; case XPATH_USERS: if (! isCached) xmlXPathDebugObjTotalUsers++; xmlXPathDebugObjCounterUsers++; if (xmlXPathDebugObjCounterUsers > xmlXPathDebugObjMaxUsers) xmlXPathDebugObjMaxUsers = xmlXPathDebugObjCounterUsers; break; case XPATH_XSLT_TREE: if (! isCached) xmlXPathDebugObjTotalXSLTTree++; xmlXPathDebugObjCounterXSLTTree++; if (xmlXPathDebugObjCounterXSLTTree > xmlXPathDebugObjMaxXSLTTree) xmlXPathDebugObjMaxXSLTTree = xmlXPathDebugObjCounterXSLTTree; break; default: break; } if (! isCached) xmlXPathDebugObjTotalAll++; xmlXPathDebugObjCounterAll++; if (xmlXPathDebugObjCounterAll > xmlXPathDebugObjMaxAll) xmlXPathDebugObjMaxAll = xmlXPathDebugObjCounterAll; } static void xmlXPathDebugObjUsageReleased(xmlXPathContextPtr ctxt, xmlXPathObjectType objType) { int isCached = 0; if (ctxt != NULL) { if (ctxt->cache != NULL) { xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache; isCached = 1; cache->dbgCachedAll++; switch (objType) { case XPATH_UNDEFINED: cache->dbgCachedUndefined++; break; case XPATH_NODESET: cache->dbgCachedNodeset++; break; case XPATH_BOOLEAN: cache->dbgCachedBool++; break; case XPATH_NUMBER: cache->dbgCachedNumber++; break; case XPATH_STRING: cache->dbgCachedString++; break; case XPATH_POINT: cache->dbgCachedPoint++; break; case XPATH_RANGE: cache->dbgCachedRange++; break; case XPATH_LOCATIONSET: cache->dbgCachedLocset++; break; case XPATH_USERS: cache->dbgCachedUsers++; break; case XPATH_XSLT_TREE: cache->dbgCachedXSLTTree++; break; default: break; } } } switch (objType) { case XPATH_UNDEFINED: xmlXPathDebugObjCounterUndefined--; break; case XPATH_NODESET: xmlXPathDebugObjCounterNodeset--; break; case XPATH_BOOLEAN: xmlXPathDebugObjCounterBool--; break; case XPATH_NUMBER: xmlXPathDebugObjCounterNumber--; break; case XPATH_STRING: xmlXPathDebugObjCounterString--; break; case XPATH_POINT: xmlXPathDebugObjCounterPoint--; break; case XPATH_RANGE: xmlXPathDebugObjCounterRange--; break; case XPATH_LOCATIONSET: xmlXPathDebugObjCounterLocset--; break; case XPATH_USERS: xmlXPathDebugObjCounterUsers--; break; case XPATH_XSLT_TREE: xmlXPathDebugObjCounterXSLTTree--; break; default: break; } xmlXPathDebugObjCounterAll--; } /* REVISIT TODO: Make this static when committing */ static void xmlXPathDebugObjUsageDisplay(xmlXPathContextPtr ctxt) { int reqAll, reqNodeset, reqString, reqBool, reqNumber, reqXSLTTree, reqUndefined; int caAll = 0, caNodeset = 0, caString = 0, caBool = 0, caNumber = 0, caXSLTTree = 0, caUndefined = 0; int reAll = 0, reNodeset = 0, reString = 0, reBool = 0, reNumber = 0, reXSLTTree = 0, reUndefined = 0; int leftObjs = xmlXPathDebugObjCounterAll; reqAll = xmlXPathDebugObjTotalAll; reqNodeset = xmlXPathDebugObjTotalNodeset; reqString = xmlXPathDebugObjTotalString; reqBool = xmlXPathDebugObjTotalBool; reqNumber = xmlXPathDebugObjTotalNumber; reqXSLTTree = xmlXPathDebugObjTotalXSLTTree; reqUndefined = xmlXPathDebugObjTotalUndefined; printf("# XPath object usage:\n"); if (ctxt != NULL) { if (ctxt->cache != NULL) { xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache; reAll = cache->dbgReusedAll; reqAll += reAll; reNodeset = cache->dbgReusedNodeset; reqNodeset += reNodeset; reString = cache->dbgReusedString; reqString += reString; reBool = cache->dbgReusedBool; reqBool += reBool; reNumber = cache->dbgReusedNumber; reqNumber += reNumber; reXSLTTree = cache->dbgReusedXSLTTree; reqXSLTTree += reXSLTTree; reUndefined = cache->dbgReusedUndefined; reqUndefined += reUndefined; caAll = cache->dbgCachedAll; caBool = cache->dbgCachedBool; caNodeset = cache->dbgCachedNodeset; caString = cache->dbgCachedString; caNumber = cache->dbgCachedNumber; caXSLTTree = cache->dbgCachedXSLTTree; caUndefined = cache->dbgCachedUndefined; if (cache->nodesetObjs) leftObjs -= cache->nodesetObjs->number; if (cache->stringObjs) leftObjs -= cache->stringObjs->number; if (cache->booleanObjs) leftObjs -= cache->booleanObjs->number; if (cache->numberObjs) leftObjs -= cache->numberObjs->number; if (cache->miscObjs) leftObjs -= cache->miscObjs->number; } } printf("# all\n"); printf("# total : %d\n", reqAll); printf("# left : %d\n", leftObjs); printf("# created: %d\n", xmlXPathDebugObjTotalAll); printf("# reused : %d\n", reAll); printf("# max : %d\n", xmlXPathDebugObjMaxAll); printf("# node-sets\n"); printf("# total : %d\n", reqNodeset); printf("# created: %d\n", xmlXPathDebugObjTotalNodeset); printf("# reused : %d\n", reNodeset); printf("# max : %d\n", xmlXPathDebugObjMaxNodeset); printf("# strings\n"); printf("# total : %d\n", reqString); printf("# created: %d\n", xmlXPathDebugObjTotalString); printf("# reused : %d\n", reString); printf("# max : %d\n", xmlXPathDebugObjMaxString); printf("# booleans\n"); printf("# total : %d\n", reqBool); printf("# created: %d\n", xmlXPathDebugObjTotalBool); printf("# reused : %d\n", reBool); printf("# max : %d\n", xmlXPathDebugObjMaxBool); printf("# numbers\n"); printf("# total : %d\n", reqNumber); printf("# created: %d\n", xmlXPathDebugObjTotalNumber); printf("# reused : %d\n", reNumber); printf("# max : %d\n", xmlXPathDebugObjMaxNumber); printf("# XSLT result tree fragments\n"); printf("# total : %d\n", reqXSLTTree); printf("# created: %d\n", xmlXPathDebugObjTotalXSLTTree); printf("# reused : %d\n", reXSLTTree); printf("# max : %d\n", xmlXPathDebugObjMaxXSLTTree); printf("# undefined\n"); printf("# total : %d\n", reqUndefined); printf("# created: %d\n", xmlXPathDebugObjTotalUndefined); printf("# reused : %d\n", reUndefined); printf("# max : %d\n", xmlXPathDebugObjMaxUndefined); } #endif /* XP_DEBUG_OBJ_USAGE */ #endif /* LIBXML_DEBUG_ENABLED */ /************************************************************************ * * * XPath object caching * * * ************************************************************************/ /** * xmlXPathNewCache: * * Create a new object cache * * Returns the xmlXPathCache just allocated. */ static xmlXPathContextCachePtr xmlXPathNewCache(void) { xmlXPathContextCachePtr ret; ret = (xmlXPathContextCachePtr) xmlMalloc(sizeof(xmlXPathContextCache)); if (ret == NULL) { xmlXPathErrMemory(NULL, "creating object cache\n"); return(NULL); } memset(ret, 0 , (size_t) sizeof(xmlXPathContextCache)); ret->maxNodeset = 100; ret->maxString = 100; ret->maxBoolean = 100; ret->maxNumber = 100; ret->maxMisc = 100; return(ret); } static void xmlXPathCacheFreeObjectList(xmlPointerListPtr list) { int i; xmlXPathObjectPtr obj; if (list == NULL) return; for (i = 0; i < list->number; i++) { obj = list->items[i]; /* * Note that it is already assured that we don't need to * look out for namespace nodes in the node-set. */ if (obj->nodesetval != NULL) { if (obj->nodesetval->nodeTab != NULL) xmlFree(obj->nodesetval->nodeTab); xmlFree(obj->nodesetval); } xmlFree(obj); #ifdef XP_DEBUG_OBJ_USAGE xmlXPathDebugObjCounterAll--; #endif } xmlPointerListFree(list); } static void xmlXPathFreeCache(xmlXPathContextCachePtr cache) { if (cache == NULL) return; if (cache->nodesetObjs) xmlXPathCacheFreeObjectList(cache->nodesetObjs); if (cache->stringObjs) xmlXPathCacheFreeObjectList(cache->stringObjs); if (cache->booleanObjs) xmlXPathCacheFreeObjectList(cache->booleanObjs); if (cache->numberObjs) xmlXPathCacheFreeObjectList(cache->numberObjs); if (cache->miscObjs) xmlXPathCacheFreeObjectList(cache->miscObjs); xmlFree(cache); } /** * xmlXPathContextSetCache: * * @ctxt: the XPath context * @active: enables/disables (creates/frees) the cache * @value: a value with semantics dependant on @options * @options: options (currently only the value 0 is used) * * Creates/frees an object cache on the XPath context. * If activates XPath objects (xmlXPathObject) will be cached internally * to be reused. * @options: * 0: This will set the XPath object caching: * @value: * This will set the maximum number of XPath objects * to be cached per slot * There are 5 slots for: node-set, string, number, boolean, and * misc objects. Use <0 for the default number (100). * Other values for @options have currently no effect. * * Returns 0 if the setting succeeded, and -1 on API or internal errors. */ int xmlXPathContextSetCache(xmlXPathContextPtr ctxt, int active, int value, int options) { if (ctxt == NULL) return(-1); if (active) { xmlXPathContextCachePtr cache; if (ctxt->cache == NULL) { ctxt->cache = xmlXPathNewCache(); if (ctxt->cache == NULL) return(-1); } cache = (xmlXPathContextCachePtr) ctxt->cache; if (options == 0) { if (value < 0) value = 100; cache->maxNodeset = value; cache->maxString = value; cache->maxNumber = value; cache->maxBoolean = value; cache->maxMisc = value; } } else if (ctxt->cache != NULL) { xmlXPathFreeCache((xmlXPathContextCachePtr) ctxt->cache); ctxt->cache = NULL; } return(0); } /** * xmlXPathCacheWrapNodeSet: * @ctxt: the XPath context * @val: the NodePtr value * * This is the cached version of xmlXPathWrapNodeSet(). * Wrap the Nodeset @val in a new xmlXPathObjectPtr * * Returns the created or reused object. */ static xmlXPathObjectPtr xmlXPathCacheWrapNodeSet(xmlXPathContextPtr ctxt, xmlNodeSetPtr val) { if ((ctxt != NULL) && (ctxt->cache != NULL)) { xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache; if ((cache->miscObjs != NULL) && (cache->miscObjs->number != 0)) { xmlXPathObjectPtr ret; ret = (xmlXPathObjectPtr) cache->miscObjs->items[--cache->miscObjs->number]; ret->type = XPATH_NODESET; ret->nodesetval = val; #ifdef XP_DEBUG_OBJ_USAGE xmlXPathDebugObjUsageRequested(ctxt, XPATH_NODESET); #endif return(ret); } } return(xmlXPathWrapNodeSet(val)); } /** * xmlXPathCacheWrapString: * @ctxt: the XPath context * @val: the xmlChar * value * * This is the cached version of xmlXPathWrapString(). * Wraps the @val string into an XPath object. * * Returns the created or reused object. */ static xmlXPathObjectPtr xmlXPathCacheWrapString(xmlXPathContextPtr ctxt, xmlChar *val) { if ((ctxt != NULL) && (ctxt->cache != NULL)) { xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache; if ((cache->stringObjs != NULL) && (cache->stringObjs->number != 0)) { xmlXPathObjectPtr ret; ret = (xmlXPathObjectPtr) cache->stringObjs->items[--cache->stringObjs->number]; ret->type = XPATH_STRING; ret->stringval = val; #ifdef XP_DEBUG_OBJ_USAGE xmlXPathDebugObjUsageRequested(ctxt, XPATH_STRING); #endif return(ret); } else if ((cache->miscObjs != NULL) && (cache->miscObjs->number != 0)) { xmlXPathObjectPtr ret; /* * Fallback to misc-cache. */ ret = (xmlXPathObjectPtr) cache->miscObjs->items[--cache->miscObjs->number]; ret->type = XPATH_STRING; ret->stringval = val; #ifdef XP_DEBUG_OBJ_USAGE xmlXPathDebugObjUsageRequested(ctxt, XPATH_STRING); #endif return(ret); } } return(xmlXPathWrapString(val)); } /** * xmlXPathCacheNewNodeSet: * @ctxt: the XPath context * @val: the NodePtr value * * This is the cached version of xmlXPathNewNodeSet(). * Acquire an xmlXPathObjectPtr of type NodeSet and initialize * it with the single Node @val * * Returns the created or reused object. */ static xmlXPathObjectPtr xmlXPathCacheNewNodeSet(xmlXPathContextPtr ctxt, xmlNodePtr val) { if ((ctxt != NULL) && (ctxt->cache)) { xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache; if ((cache->nodesetObjs != NULL) && (cache->nodesetObjs->number != 0)) { xmlXPathObjectPtr ret; /* * Use the nodset-cache. */ ret = (xmlXPathObjectPtr) cache->nodesetObjs->items[--cache->nodesetObjs->number]; ret->type = XPATH_NODESET; ret->boolval = 0; if (val) { if ((ret->nodesetval->nodeMax == 0) || (val->type == XML_NAMESPACE_DECL)) { xmlXPathNodeSetAddUnique(ret->nodesetval, val); } else { ret->nodesetval->nodeTab[0] = val; ret->nodesetval->nodeNr = 1; } } #ifdef XP_DEBUG_OBJ_USAGE xmlXPathDebugObjUsageRequested(ctxt, XPATH_NODESET); #endif return(ret); } else if ((cache->miscObjs != NULL) && (cache->miscObjs->number != 0)) { xmlXPathObjectPtr ret; /* * Fallback to misc-cache. */ ret = (xmlXPathObjectPtr) cache->miscObjs->items[--cache->miscObjs->number]; ret->type = XPATH_NODESET; ret->boolval = 0; ret->nodesetval = xmlXPathNodeSetCreate(val); #ifdef XP_DEBUG_OBJ_USAGE xmlXPathDebugObjUsageRequested(ctxt, XPATH_NODESET); #endif return(ret); } } return(xmlXPathNewNodeSet(val)); } /** * xmlXPathCacheNewCString: * @ctxt: the XPath context * @val: the char * value * * This is the cached version of xmlXPathNewCString(). * Acquire an xmlXPathObjectPtr of type string and of value @val * * Returns the created or reused object. */ static xmlXPathObjectPtr xmlXPathCacheNewCString(xmlXPathContextPtr ctxt, const char *val) { if ((ctxt != NULL) && (ctxt->cache)) { xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache; if ((cache->stringObjs != NULL) && (cache->stringObjs->number != 0)) { xmlXPathObjectPtr ret; ret = (xmlXPathObjectPtr) cache->stringObjs->items[--cache->stringObjs->number]; ret->type = XPATH_STRING; ret->stringval = xmlStrdup(BAD_CAST val); #ifdef XP_DEBUG_OBJ_USAGE xmlXPathDebugObjUsageRequested(ctxt, XPATH_STRING); #endif return(ret); } else if ((cache->miscObjs != NULL) && (cache->miscObjs->number != 0)) { xmlXPathObjectPtr ret; ret = (xmlXPathObjectPtr) cache->miscObjs->items[--cache->miscObjs->number]; ret->type = XPATH_STRING; ret->stringval = xmlStrdup(BAD_CAST val); #ifdef XP_DEBUG_OBJ_USAGE xmlXPathDebugObjUsageRequested(ctxt, XPATH_STRING); #endif return(ret); } } return(xmlXPathNewCString(val)); } /** * xmlXPathCacheNewString: * @ctxt: the XPath context * @val: the xmlChar * value * * This is the cached version of xmlXPathNewString(). * Acquire an xmlXPathObjectPtr of type string and of value @val * * Returns the created or reused object. */ static xmlXPathObjectPtr xmlXPathCacheNewString(xmlXPathContextPtr ctxt, const xmlChar *val) { if ((ctxt != NULL) && (ctxt->cache)) { xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache; if ((cache->stringObjs != NULL) && (cache->stringObjs->number != 0)) { xmlXPathObjectPtr ret; ret = (xmlXPathObjectPtr) cache->stringObjs->items[--cache->stringObjs->number]; ret->type = XPATH_STRING; if (val != NULL) ret->stringval = xmlStrdup(val); else ret->stringval = xmlStrdup((const xmlChar *)""); #ifdef XP_DEBUG_OBJ_USAGE xmlXPathDebugObjUsageRequested(ctxt, XPATH_STRING); #endif return(ret); } else if ((cache->miscObjs != NULL) && (cache->miscObjs->number != 0)) { xmlXPathObjectPtr ret; ret = (xmlXPathObjectPtr) cache->miscObjs->items[--cache->miscObjs->number]; ret->type = XPATH_STRING; if (val != NULL) ret->stringval = xmlStrdup(val); else ret->stringval = xmlStrdup((const xmlChar *)""); #ifdef XP_DEBUG_OBJ_USAGE xmlXPathDebugObjUsageRequested(ctxt, XPATH_STRING); #endif return(ret); } } return(xmlXPathNewString(val)); } /** * xmlXPathCacheNewBoolean: * @ctxt: the XPath context * @val: the boolean value * * This is the cached version of xmlXPathNewBoolean(). * Acquires an xmlXPathObjectPtr of type boolean and of value @val * * Returns the created or reused object. */ static xmlXPathObjectPtr xmlXPathCacheNewBoolean(xmlXPathContextPtr ctxt, int val) { if ((ctxt != NULL) && (ctxt->cache)) { xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache; if ((cache->booleanObjs != NULL) && (cache->booleanObjs->number != 0)) { xmlXPathObjectPtr ret; ret = (xmlXPathObjectPtr) cache->booleanObjs->items[--cache->booleanObjs->number]; ret->type = XPATH_BOOLEAN; ret->boolval = (val != 0); #ifdef XP_DEBUG_OBJ_USAGE xmlXPathDebugObjUsageRequested(ctxt, XPATH_BOOLEAN); #endif return(ret); } else if ((cache->miscObjs != NULL) && (cache->miscObjs->number != 0)) { xmlXPathObjectPtr ret; ret = (xmlXPathObjectPtr) cache->miscObjs->items[--cache->miscObjs->number]; ret->type = XPATH_BOOLEAN; ret->boolval = (val != 0); #ifdef XP_DEBUG_OBJ_USAGE xmlXPathDebugObjUsageRequested(ctxt, XPATH_BOOLEAN); #endif return(ret); } } return(xmlXPathNewBoolean(val)); } /** * xmlXPathCacheNewFloat: * @ctxt: the XPath context * @val: the double value * * This is the cached version of xmlXPathNewFloat(). * Acquires an xmlXPathObjectPtr of type double and of value @val * * Returns the created or reused object. */ static xmlXPathObjectPtr xmlXPathCacheNewFloat(xmlXPathContextPtr ctxt, double val) { if ((ctxt != NULL) && (ctxt->cache)) { xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache; if ((cache->numberObjs != NULL) && (cache->numberObjs->number != 0)) { xmlXPathObjectPtr ret; ret = (xmlXPathObjectPtr) cache->numberObjs->items[--cache->numberObjs->number]; ret->type = XPATH_NUMBER; ret->floatval = val; #ifdef XP_DEBUG_OBJ_USAGE xmlXPathDebugObjUsageRequested(ctxt, XPATH_NUMBER); #endif return(ret); } else if ((cache->miscObjs != NULL) && (cache->miscObjs->number != 0)) { xmlXPathObjectPtr ret; ret = (xmlXPathObjectPtr) cache->miscObjs->items[--cache->miscObjs->number]; ret->type = XPATH_NUMBER; ret->floatval = val; #ifdef XP_DEBUG_OBJ_USAGE xmlXPathDebugObjUsageRequested(ctxt, XPATH_NUMBER); #endif return(ret); } } return(xmlXPathNewFloat(val)); } /** * xmlXPathCacheConvertString: * @ctxt: the XPath context * @val: an XPath object * * This is the cached version of xmlXPathConvertString(). * Converts an existing object to its string() equivalent * * Returns a created or reused object, the old one is freed (cached) * (or the operation is done directly on @val) */ static xmlXPathObjectPtr xmlXPathCacheConvertString(xmlXPathContextPtr ctxt, xmlXPathObjectPtr val) { xmlChar *res = NULL; if (val == NULL) return(xmlXPathCacheNewCString(ctxt, "")); switch (val->type) { case XPATH_UNDEFINED: #ifdef DEBUG_EXPR xmlGenericError(xmlGenericErrorContext, "STRING: undefined\n"); #endif break; case XPATH_NODESET: case XPATH_XSLT_TREE: res = xmlXPathCastNodeSetToString(val->nodesetval); break; case XPATH_STRING: return(val); case XPATH_BOOLEAN: res = xmlXPathCastBooleanToString(val->boolval); break; case XPATH_NUMBER: res = xmlXPathCastNumberToString(val->floatval); break; case XPATH_USERS: case XPATH_POINT: case XPATH_RANGE: case XPATH_LOCATIONSET: TODO; break; } xmlXPathReleaseObject(ctxt, val); if (res == NULL) return(xmlXPathCacheNewCString(ctxt, "")); return(xmlXPathCacheWrapString(ctxt, res)); } /** * xmlXPathCacheObjectCopy: * @ctxt: the XPath context * @val: the original object * * This is the cached version of xmlXPathObjectCopy(). * Acquire a copy of a given object * * Returns a created or reused created object. */ static xmlXPathObjectPtr xmlXPathCacheObjectCopy(xmlXPathContextPtr ctxt, xmlXPathObjectPtr val) { if (val == NULL) return(NULL); if (XP_HAS_CACHE(ctxt)) { switch (val->type) { case XPATH_NODESET: return(xmlXPathCacheWrapNodeSet(ctxt, xmlXPathNodeSetMerge(NULL, val->nodesetval))); case XPATH_STRING: return(xmlXPathCacheNewString(ctxt, val->stringval)); case XPATH_BOOLEAN: return(xmlXPathCacheNewBoolean(ctxt, val->boolval)); case XPATH_NUMBER: return(xmlXPathCacheNewFloat(ctxt, val->floatval)); default: break; } } return(xmlXPathObjectCopy(val)); } /** * xmlXPathCacheConvertBoolean: * @ctxt: the XPath context * @val: an XPath object * * This is the cached version of xmlXPathConvertBoolean(). * Converts an existing object to its boolean() equivalent * * Returns a created or reused object, the old one is freed (or the operation * is done directly on @val) */ static xmlXPathObjectPtr xmlXPathCacheConvertBoolean(xmlXPathContextPtr ctxt, xmlXPathObjectPtr val) { xmlXPathObjectPtr ret; if (val == NULL) return(xmlXPathCacheNewBoolean(ctxt, 0)); if (val->type == XPATH_BOOLEAN) return(val); ret = xmlXPathCacheNewBoolean(ctxt, xmlXPathCastToBoolean(val)); xmlXPathReleaseObject(ctxt, val); return(ret); } /** * xmlXPathCacheConvertNumber: * @ctxt: the XPath context * @val: an XPath object * * This is the cached version of xmlXPathConvertNumber(). * Converts an existing object to its number() equivalent * * Returns a created or reused object, the old one is freed (or the operation * is done directly on @val) */ static xmlXPathObjectPtr xmlXPathCacheConvertNumber(xmlXPathContextPtr ctxt, xmlXPathObjectPtr val) { xmlXPathObjectPtr ret; if (val == NULL) return(xmlXPathCacheNewFloat(ctxt, 0.0)); if (val->type == XPATH_NUMBER) return(val); ret = xmlXPathCacheNewFloat(ctxt, xmlXPathCastToNumber(val)); xmlXPathReleaseObject(ctxt, val); return(ret); } /************************************************************************ * * * Parser stacks related functions and macros * * * ************************************************************************/ /** * valuePop: * @ctxt: an XPath evaluation context * * Pops the top XPath object from the value stack * * Returns the XPath object just removed */ xmlXPathObjectPtr valuePop(xmlXPathParserContextPtr ctxt) { xmlXPathObjectPtr ret; if ((ctxt == NULL) || (ctxt->valueNr <= 0)) return (NULL); ctxt->valueNr--; if (ctxt->valueNr > 0) ctxt->value = ctxt->valueTab[ctxt->valueNr - 1]; else ctxt->value = NULL; ret = ctxt->valueTab[ctxt->valueNr]; ctxt->valueTab[ctxt->valueNr] = NULL; return (ret); } /** * valuePush: * @ctxt: an XPath evaluation context * @value: the XPath object * * Pushes a new XPath object on top of the value stack * * returns the number of items on the value stack */ int valuePush(xmlXPathParserContextPtr ctxt, xmlXPathObjectPtr value) { if ((ctxt == NULL) || (value == NULL)) return(-1); if (ctxt->valueNr >= ctxt->valueMax) { xmlXPathObjectPtr *tmp; tmp = (xmlXPathObjectPtr *) xmlRealloc(ctxt->valueTab, 2 * ctxt->valueMax * sizeof(ctxt->valueTab[0])); if (tmp == NULL) { xmlGenericError(xmlGenericErrorContext, "realloc failed !\n"); return (0); } ctxt->valueMax *= 2; ctxt->valueTab = tmp; } ctxt->valueTab[ctxt->valueNr] = value; ctxt->value = value; return (ctxt->valueNr++); } /** * xmlXPathPopBoolean: * @ctxt: an XPath parser context * * Pops a boolean from the stack, handling conversion if needed. * Check error with #xmlXPathCheckError. * * Returns the boolean */ int xmlXPathPopBoolean (xmlXPathParserContextPtr ctxt) { xmlXPathObjectPtr obj; int ret; obj = valuePop(ctxt); if (obj == NULL) { xmlXPathSetError(ctxt, XPATH_INVALID_OPERAND); return(0); } if (obj->type != XPATH_BOOLEAN) ret = xmlXPathCastToBoolean(obj); else ret = obj->boolval; xmlXPathReleaseObject(ctxt->context, obj); return(ret); } /** * xmlXPathPopNumber: * @ctxt: an XPath parser context * * Pops a number from the stack, handling conversion if needed. * Check error with #xmlXPathCheckError. * * Returns the number */ double xmlXPathPopNumber (xmlXPathParserContextPtr ctxt) { xmlXPathObjectPtr obj; double ret; obj = valuePop(ctxt); if (obj == NULL) { xmlXPathSetError(ctxt, XPATH_INVALID_OPERAND); return(0); } if (obj->type != XPATH_NUMBER) ret = xmlXPathCastToNumber(obj); else ret = obj->floatval; xmlXPathReleaseObject(ctxt->context, obj); return(ret); } /** * xmlXPathPopString: * @ctxt: an XPath parser context * * Pops a string from the stack, handling conversion if needed. * Check error with #xmlXPathCheckError. * * Returns the string */ xmlChar * xmlXPathPopString (xmlXPathParserContextPtr ctxt) { xmlXPathObjectPtr obj; xmlChar * ret; obj = valuePop(ctxt); if (obj == NULL) { xmlXPathSetError(ctxt, XPATH_INVALID_OPERAND); return(NULL); } ret = xmlXPathCastToString(obj); /* this does required strdup */ /* TODO: needs refactoring somewhere else */ if (obj->stringval == ret) obj->stringval = NULL; xmlXPathReleaseObject(ctxt->context, obj); return(ret); } /** * xmlXPathPopNodeSet: * @ctxt: an XPath parser context * * Pops a node-set from the stack, handling conversion if needed. * Check error with #xmlXPathCheckError. * * Returns the node-set */ xmlNodeSetPtr xmlXPathPopNodeSet (xmlXPathParserContextPtr ctxt) { xmlXPathObjectPtr obj; xmlNodeSetPtr ret; if (ctxt == NULL) return(NULL); if (ctxt->value == NULL) { xmlXPathSetError(ctxt, XPATH_INVALID_OPERAND); return(NULL); } if (!xmlXPathStackIsNodeSet(ctxt)) { xmlXPathSetTypeError(ctxt); return(NULL); } obj = valuePop(ctxt); ret = obj->nodesetval; #if 0 /* to fix memory leak of not clearing obj->user */ if (obj->boolval && obj->user != NULL) xmlFreeNodeList((xmlNodePtr) obj->user); #endif obj->nodesetval = NULL; xmlXPathReleaseObject(ctxt->context, obj); return(ret); } /** * xmlXPathPopExternal: * @ctxt: an XPath parser context * * Pops an external object from the stack, handling conversion if needed. * Check error with #xmlXPathCheckError. * * Returns the object */ void * xmlXPathPopExternal (xmlXPathParserContextPtr ctxt) { xmlXPathObjectPtr obj; void * ret; if ((ctxt == NULL) || (ctxt->value == NULL)) { xmlXPathSetError(ctxt, XPATH_INVALID_OPERAND); return(NULL); } if (ctxt->value->type != XPATH_USERS) { xmlXPathSetTypeError(ctxt); return(NULL); } obj = valuePop(ctxt); ret = obj->user; obj->user = NULL; xmlXPathReleaseObject(ctxt->context, obj); return(ret); } /* * Macros for accessing the content. Those should be used only by the parser, * and not exported. * * Dirty macros, i.e. one need to make assumption on the context to use them * * CUR_PTR return the current pointer to the xmlChar to be parsed. * CUR returns the current xmlChar value, i.e. a 8 bit value * in ISO-Latin or UTF-8. * This should be used internally by the parser * only to compare to ASCII values otherwise it would break when * running with UTF-8 encoding. * NXT(n) returns the n'th next xmlChar. Same as CUR is should be used only * to compare on ASCII based substring. * SKIP(n) Skip n xmlChar, and must also be used only to skip ASCII defined * strings within the parser. * CURRENT Returns the current char value, with the full decoding of * UTF-8 if we are using this mode. It returns an int. * NEXT Skip to the next character, this does the proper decoding * in UTF-8 mode. It also pop-up unfinished entities on the fly. * It returns the pointer to the current xmlChar. */ #define CUR (*ctxt->cur) #define SKIP(val) ctxt->cur += (val) #define NXT(val) ctxt->cur[(val)] #define CUR_PTR ctxt->cur #define CUR_CHAR(l) xmlXPathCurrentChar(ctxt, &l) #define COPY_BUF(l,b,i,v) \ if (l == 1) b[i++] = (xmlChar) v; \ else i += xmlCopyChar(l,&b[i],v) #define NEXTL(l) ctxt->cur += l #define SKIP_BLANKS \ while (IS_BLANK_CH(*(ctxt->cur))) NEXT #define CURRENT (*ctxt->cur) #define NEXT ((*ctxt->cur) ? ctxt->cur++: ctxt->cur) #ifndef DBL_DIG #define DBL_DIG 16 #endif #ifndef DBL_EPSILON #define DBL_EPSILON 1E-9 #endif #define UPPER_DOUBLE 1E9 #define LOWER_DOUBLE 1E-5 #define INTEGER_DIGITS DBL_DIG #define FRACTION_DIGITS (DBL_DIG + 1) #define EXPONENT_DIGITS (3 + 2) /** * xmlXPathFormatNumber: * @number: number to format * @buffer: output buffer * @buffersize: size of output buffer * * Convert the number into a string representation. */ static void xmlXPathFormatNumber(double number, char buffer[], int buffersize) { switch (xmlXPathIsInf(number)) { case 1: if (buffersize > (int)sizeof("Infinity")) snprintf(buffer, buffersize, "Infinity"); break; case -1: if (buffersize > (int)sizeof("-Infinity")) snprintf(buffer, buffersize, "-Infinity"); break; default: if (xmlXPathIsNaN(number)) { if (buffersize > (int)sizeof("NaN")) snprintf(buffer, buffersize, "NaN"); } else if (number == 0 && xmlXPathGetSign(number) != 0) { snprintf(buffer, buffersize, "0"); } else if (number == ((int) number)) { char work[30]; char *ptr, *cur; int value = (int) number; ptr = &buffer[0]; if (value == 0) { *ptr++ = '0'; } else { snprintf(work, 29, "%d", value); cur = &work[0]; while ((*cur) && (ptr - buffer < buffersize)) { *ptr++ = *cur++; } } if (ptr - buffer < buffersize) { *ptr = 0; } else if (buffersize > 0) { ptr--; *ptr = 0; } } else { /* 3 is sign, decimal point, and terminating zero */ char work[DBL_DIG + EXPONENT_DIGITS + 3]; int integer_place, fraction_place; char *ptr; char *after_fraction; double absolute_value; int size; absolute_value = fabs(number); /* * First choose format - scientific or regular floating point. * In either case, result is in work, and after_fraction points * just past the fractional part. */ if ( ((absolute_value > UPPER_DOUBLE) || (absolute_value < LOWER_DOUBLE)) && (absolute_value != 0.0) ) { /* Use scientific notation */ integer_place = DBL_DIG + EXPONENT_DIGITS + 1; fraction_place = DBL_DIG - 1; size = snprintf(work, sizeof(work),"%*.*e", integer_place, fraction_place, number); while ((size > 0) && (work[size] != 'e')) size--; after_fraction = work + size; } else { /* Use regular notation */ if (absolute_value > 0.0) integer_place = 1 + (int)log10(absolute_value); else integer_place = 0; fraction_place = (integer_place > 0) ? DBL_DIG - integer_place : DBL_DIG; size = snprintf(work, sizeof(work), "%0.*f", fraction_place, number); after_fraction = work + size; } /* Remove fractional trailing zeroes */ ptr = after_fraction; while (*(--ptr) == '0') ; if (*ptr != '.') ptr++; while ((*ptr++ = *after_fraction++) != 0); /* Finally copy result back to caller */ size = strlen(work) + 1; if (size > buffersize) { work[buffersize - 1] = 0; size = buffersize; } memmove(buffer, work, size); } break; } } /************************************************************************ * * * Routines to handle NodeSets * * * ************************************************************************/ /** * xmlXPathOrderDocElems: * @doc: an input document * * Call this routine to speed up XPath computation on static documents. * This stamps all the element nodes with the document order * Like for line information, the order is kept in the element->content * field, the value stored is actually - the node number (starting at -1) * to be able to differentiate from line numbers. * * Returns the number of elements found in the document or -1 in case * of error. */ long xmlXPathOrderDocElems(xmlDocPtr doc) { long count = 0; xmlNodePtr cur; if (doc == NULL) return(-1); cur = doc->children; while (cur != NULL) { if (cur->type == XML_ELEMENT_NODE) { cur->content = (void *) (-(++count)); if (cur->children != NULL) { cur = cur->children; continue; } } if (cur->next != NULL) { cur = cur->next; continue; } do { cur = cur->parent; if (cur == NULL) break; if (cur == (xmlNodePtr) doc) { cur = NULL; break; } if (cur->next != NULL) { cur = cur->next; break; } } while (cur != NULL); } return(count); } /** * xmlXPathCmpNodes: * @node1: the first node * @node2: the second node * * Compare two nodes w.r.t document order * * Returns -2 in case of error 1 if first point < second point, 0 if * it's the same node, -1 otherwise */ int xmlXPathCmpNodes(xmlNodePtr node1, xmlNodePtr node2) { int depth1, depth2; int attr1 = 0, attr2 = 0; xmlNodePtr attrNode1 = NULL, attrNode2 = NULL; xmlNodePtr cur, root; if ((node1 == NULL) || (node2 == NULL)) return(-2); /* * a couple of optimizations which will avoid computations in most cases */ if (node1->type == XML_ATTRIBUTE_NODE) { attr1 = 1; attrNode1 = node1; node1 = node1->parent; } if (node2->type == XML_ATTRIBUTE_NODE) { attr2 = 1; attrNode2 = node2; node2 = node2->parent; } if (node1 == node2) { if (attr1 == attr2) { /* not required, but we keep attributes in order */ if (attr1 != 0) { cur = attrNode2->prev; while (cur != NULL) { if (cur == attrNode1) return (1); cur = cur->prev; } return (-1); } return(0); } if (attr2 == 1) return(1); return(-1); } if ((node1->type == XML_NAMESPACE_DECL) || (node2->type == XML_NAMESPACE_DECL)) return(1); if (node1 == node2->prev) return(1); if (node1 == node2->next) return(-1); /* * Speedup using document order if availble. */ if ((node1->type == XML_ELEMENT_NODE) && (node2->type == XML_ELEMENT_NODE) && (0 > (long) node1->content) && (0 > (long) node2->content) && (node1->doc == node2->doc)) { long l1, l2; l1 = -((long) node1->content); l2 = -((long) node2->content); if (l1 < l2) return(1); if (l1 > l2) return(-1); } /* * compute depth to root */ for (depth2 = 0, cur = node2;cur->parent != NULL;cur = cur->parent) { if (cur == node1) return(1); depth2++; } root = cur; for (depth1 = 0, cur = node1;cur->parent != NULL;cur = cur->parent) { if (cur == node2) return(-1); depth1++; } /* * Distinct document (or distinct entities :-( ) case. */ if (root != cur) { return(-2); } /* * get the nearest common ancestor. */ while (depth1 > depth2) { depth1--; node1 = node1->parent; } while (depth2 > depth1) { depth2--; node2 = node2->parent; } while (node1->parent != node2->parent) { node1 = node1->parent; node2 = node2->parent; /* should not happen but just in case ... */ if ((node1 == NULL) || (node2 == NULL)) return(-2); } /* * Find who's first. */ if (node1 == node2->prev) return(1); if (node1 == node2->next) return(-1); /* * Speedup using document order if availble. */ if ((node1->type == XML_ELEMENT_NODE) && (node2->type == XML_ELEMENT_NODE) && (0 > (long) node1->content) && (0 > (long) node2->content) && (node1->doc == node2->doc)) { long l1, l2; l1 = -((long) node1->content); l2 = -((long) node2->content); if (l1 < l2) return(1); if (l1 > l2) return(-1); } for (cur = node1->next;cur != NULL;cur = cur->next) if (cur == node2) return(1); return(-1); /* assume there is no sibling list corruption */ } #ifdef XP_OPTIMIZED_NON_ELEM_COMPARISON /** * xmlXPathCmpNodesExt: * @node1: the first node * @node2: the second node * * Compare two nodes w.r.t document order. * This one is optimized for handling of non-element nodes. * * Returns -2 in case of error 1 if first point < second point, 0 if * it's the same node, -1 otherwise */ static int xmlXPathCmpNodesExt(xmlNodePtr node1, xmlNodePtr node2) { int depth1, depth2; int misc = 0, precedence1 = 0, precedence2 = 0; xmlNodePtr miscNode1 = NULL, miscNode2 = NULL; xmlNodePtr cur, root; long l1, l2; if ((node1 == NULL) || (node2 == NULL)) return(-2); if (node1 == node2) return(0); /* * a couple of optimizations which will avoid computations in most cases */ switch (node1->type) { case XML_ELEMENT_NODE: if (node2->type == XML_ELEMENT_NODE) { if ((0 > (long) node1->content) && /* TODO: Would a != 0 suffice here? */ (0 > (long) node2->content) && (node1->doc == node2->doc)) { l1 = -((long) node1->content); l2 = -((long) node2->content); if (l1 < l2) return(1); if (l1 > l2) return(-1); } else goto turtle_comparison; } break; case XML_ATTRIBUTE_NODE: precedence1 = 1; /* element is owner */ miscNode1 = node1; node1 = node1->parent; misc = 1; break; case XML_TEXT_NODE: case XML_CDATA_SECTION_NODE: case XML_COMMENT_NODE: case XML_PI_NODE: { miscNode1 = node1; /* * Find nearest element node. */ if (node1->prev != NULL) { do { node1 = node1->prev; if (node1->type == XML_ELEMENT_NODE) { precedence1 = 3; /* element in prev-sibl axis */ break; } if (node1->prev == NULL) { precedence1 = 2; /* element is parent */ /* * URGENT TODO: Are there any cases, where the * parent of such a node is not an element node? */ node1 = node1->parent; break; } } while (1); } else { precedence1 = 2; /* element is parent */ node1 = node1->parent; } if ((node1 == NULL) || (node1->type != XML_ELEMENT_NODE)) { /* * Fallback for whatever case. */ node1 = miscNode1; precedence1 = 0; } else misc = 1; } break; case XML_NAMESPACE_DECL: /* * TODO: why do we return 1 for namespace nodes? */ return(1); default: break; } switch (node2->type) { case XML_ELEMENT_NODE: break; case XML_ATTRIBUTE_NODE: precedence2 = 1; /* element is owner */ miscNode2 = node2; node2 = node2->parent; misc = 1; break; case XML_TEXT_NODE: case XML_CDATA_SECTION_NODE: case XML_COMMENT_NODE: case XML_PI_NODE: { miscNode2 = node2; if (node2->prev != NULL) { do { node2 = node2->prev; if (node2->type == XML_ELEMENT_NODE) { precedence2 = 3; /* element in prev-sibl axis */ break; } if (node2->prev == NULL) { precedence2 = 2; /* element is parent */ node2 = node2->parent; break; } } while (1); } else { precedence2 = 2; /* element is parent */ node2 = node2->parent; } if ((node2 == NULL) || (node2->type != XML_ELEMENT_NODE) || (0 <= (long) node1->content)) { node2 = miscNode2; precedence2 = 0; } else misc = 1; } break; case XML_NAMESPACE_DECL: return(1); default: break; } if (misc) { if (node1 == node2) { if (precedence1 == precedence2) { /* * The ugly case; but normally there aren't many * adjacent non-element nodes around. */ cur = miscNode2->prev; while (cur != NULL) { if (cur == miscNode1) return(1); if (cur->type == XML_ELEMENT_NODE) return(-1); cur = cur->prev; } return (-1); } else { /* * Evaluate based on higher precedence wrt to the element. * TODO: This assumes attributes are sorted before content. * Is this 100% correct? */ if (precedence1 < precedence2) return(1); else return(-1); } } /* * Special case: One of the helper-elements is contained by the other. * * * Text-1(precedence1 == 2) * * Text-6(precedence2 == 3) * */ if ((precedence2 == 3) && (precedence1 > 1)) { cur = node1->parent; while (cur) { if (cur == node2) return(1); cur = cur->parent; } } if ((precedence1 == 3) && (precedence2 > 1)) { cur = node2->parent; while (cur) { if (cur == node1) return(-1); cur = cur->parent; } } } /* * Speedup using document order if availble. */ if ((node1->type == XML_ELEMENT_NODE) && (node2->type == XML_ELEMENT_NODE) && (0 > (long) node1->content) && (0 > (long) node2->content) && (node1->doc == node2->doc)) { l1 = -((long) node1->content); l2 = -((long) node2->content); if (l1 < l2) return(1); if (l1 > l2) return(-1); } turtle_comparison: if (node1 == node2->prev) return(1); if (node1 == node2->next) return(-1); /* * compute depth to root */ for (depth2 = 0, cur = node2;cur->parent != NULL;cur = cur->parent) { if (cur == node1) return(1); depth2++; } root = cur; for (depth1 = 0, cur = node1;cur->parent != NULL;cur = cur->parent) { if (cur == node2) return(-1); depth1++; } /* * Distinct document (or distinct entities :-( ) case. */ if (root != cur) { return(-2); } /* * get the nearest common ancestor. */ while (depth1 > depth2) { depth1--; node1 = node1->parent; } while (depth2 > depth1) { depth2--; node2 = node2->parent; } while (node1->parent != node2->parent) { node1 = node1->parent; node2 = node2->parent; /* should not happen but just in case ... */ if ((node1 == NULL) || (node2 == NULL)) return(-2); } /* * Find who's first. */ if (node1 == node2->prev) return(1); if (node1 == node2->next) return(-1); /* * Speedup using document order if availble. */ if ((node1->type == XML_ELEMENT_NODE) && (node2->type == XML_ELEMENT_NODE) && (0 > (long) node1->content) && (0 > (long) node2->content) && (node1->doc == node2->doc)) { l1 = -((long) node1->content); l2 = -((long) node2->content); if (l1 < l2) return(1); if (l1 > l2) return(-1); } for (cur = node1->next;cur != NULL;cur = cur->next) if (cur == node2) return(1); return(-1); /* assume there is no sibling list corruption */ } #endif /* XP_OPTIMIZED_NON_ELEM_COMPARISON */ /** * xmlXPathNodeSetSort: * @set: the node set * * Sort the node set in document order */ void xmlXPathNodeSetSort(xmlNodeSetPtr set) { int i, j, incr, len; xmlNodePtr tmp; if (set == NULL) return; /* Use Shell's sort to sort the node-set */ len = set->nodeNr; for (incr = len / 2; incr > 0; incr /= 2) { for (i = incr; i < len; i++) { j = i - incr; while (j >= 0) { #ifdef XP_OPTIMIZED_NON_ELEM_COMPARISON if (xmlXPathCmpNodesExt(set->nodeTab[j], set->nodeTab[j + incr]) == -1) #else if (xmlXPathCmpNodes(set->nodeTab[j], set->nodeTab[j + incr]) == -1) #endif { tmp = set->nodeTab[j]; set->nodeTab[j] = set->nodeTab[j + incr]; set->nodeTab[j + incr] = tmp; j -= incr; } else break; } } } } #define XML_NODESET_DEFAULT 10 /** * xmlXPathNodeSetDupNs: * @node: the parent node of the namespace XPath node * @ns: the libxml namespace declaration node. * * Namespace node in libxml don't match the XPath semantic. In a node set * the namespace nodes are duplicated and the next pointer is set to the * parent node in the XPath semantic. * * Returns the newly created object. */ static xmlNodePtr xmlXPathNodeSetDupNs(xmlNodePtr node, xmlNsPtr ns) { xmlNsPtr cur; if ((ns == NULL) || (ns->type != XML_NAMESPACE_DECL)) return(NULL); if ((node == NULL) || (node->type == XML_NAMESPACE_DECL)) return((xmlNodePtr) ns); /* * Allocate a new Namespace and fill the fields. */ cur = (xmlNsPtr) xmlMalloc(sizeof(xmlNs)); if (cur == NULL) { xmlXPathErrMemory(NULL, "duplicating namespace\n"); return(NULL); } memset(cur, 0, sizeof(xmlNs)); cur->type = XML_NAMESPACE_DECL; if (ns->href != NULL) cur->href = xmlStrdup(ns->href); if (ns->prefix != NULL) cur->prefix = xmlStrdup(ns->prefix); cur->next = (xmlNsPtr) node; return((xmlNodePtr) cur); } /** * xmlXPathNodeSetFreeNs: * @ns: the XPath namespace node found in a nodeset. * * Namespace nodes in libxml don't match the XPath semantic. In a node set * the namespace nodes are duplicated and the next pointer is set to the * parent node in the XPath semantic. Check if such a node needs to be freed */ void xmlXPathNodeSetFreeNs(xmlNsPtr ns) { if ((ns == NULL) || (ns->type != XML_NAMESPACE_DECL)) return; if ((ns->next != NULL) && (ns->next->type != XML_NAMESPACE_DECL)) { if (ns->href != NULL) xmlFree((xmlChar *)ns->href); if (ns->prefix != NULL) xmlFree((xmlChar *)ns->prefix); xmlFree(ns); } } /** * xmlXPathNodeSetCreate: * @val: an initial xmlNodePtr, or NULL * * Create a new xmlNodeSetPtr of type double and of value @val * * Returns the newly created object. */ xmlNodeSetPtr xmlXPathNodeSetCreate(xmlNodePtr val) { xmlNodeSetPtr ret; ret = (xmlNodeSetPtr) xmlMalloc(sizeof(xmlNodeSet)); if (ret == NULL) { xmlXPathErrMemory(NULL, "creating nodeset\n"); return(NULL); } memset(ret, 0 , (size_t) sizeof(xmlNodeSet)); if (val != NULL) { ret->nodeTab = (xmlNodePtr *) xmlMalloc(XML_NODESET_DEFAULT * sizeof(xmlNodePtr)); if (ret->nodeTab == NULL) { xmlXPathErrMemory(NULL, "creating nodeset\n"); xmlFree(ret); return(NULL); } memset(ret->nodeTab, 0 , XML_NODESET_DEFAULT * (size_t) sizeof(xmlNodePtr)); ret->nodeMax = XML_NODESET_DEFAULT; if (val->type == XML_NAMESPACE_DECL) { xmlNsPtr ns = (xmlNsPtr) val; ret->nodeTab[ret->nodeNr++] = xmlXPathNodeSetDupNs((xmlNodePtr) ns->next, ns); } else ret->nodeTab[ret->nodeNr++] = val; } return(ret); } /** * xmlXPathNodeSetCreateSize: * @size: the initial size of the set * * Create a new xmlNodeSetPtr of type double and of value @val * * Returns the newly created object. */ static xmlNodeSetPtr xmlXPathNodeSetCreateSize(int size) { xmlNodeSetPtr ret; ret = (xmlNodeSetPtr) xmlMalloc(sizeof(xmlNodeSet)); if (ret == NULL) { xmlXPathErrMemory(NULL, "creating nodeset\n"); return(NULL); } memset(ret, 0 , (size_t) sizeof(xmlNodeSet)); if (size < XML_NODESET_DEFAULT) size = XML_NODESET_DEFAULT; ret->nodeTab = (xmlNodePtr *) xmlMalloc(size * sizeof(xmlNodePtr)); if (ret->nodeTab == NULL) { xmlXPathErrMemory(NULL, "creating nodeset\n"); xmlFree(ret); return(NULL); } memset(ret->nodeTab, 0 , size * (size_t) sizeof(xmlNodePtr)); ret->nodeMax = size; return(ret); } /** * xmlXPathNodeSetContains: * @cur: the node-set * @val: the node * * checks whether @cur contains @val * * Returns true (1) if @cur contains @val, false (0) otherwise */ int xmlXPathNodeSetContains (xmlNodeSetPtr cur, xmlNodePtr val) { int i; if ((cur == NULL) || (val == NULL)) return(0); if (val->type == XML_NAMESPACE_DECL) { for (i = 0; i < cur->nodeNr; i++) { if (cur->nodeTab[i]->type == XML_NAMESPACE_DECL) { xmlNsPtr ns1, ns2; ns1 = (xmlNsPtr) val; ns2 = (xmlNsPtr) cur->nodeTab[i]; if (ns1 == ns2) return(1); if ((ns1->next != NULL) && (ns2->next == ns1->next) && (xmlStrEqual(ns1->prefix, ns2->prefix))) return(1); } } } else { for (i = 0; i < cur->nodeNr; i++) { if (cur->nodeTab[i] == val) return(1); } } return(0); } /** * xmlXPathNodeSetAddNs: * @cur: the initial node set * @node: the hosting node * @ns: a the namespace node * * add a new namespace node to an existing NodeSet */ void xmlXPathNodeSetAddNs(xmlNodeSetPtr cur, xmlNodePtr node, xmlNsPtr ns) { int i; if ((cur == NULL) || (ns == NULL) || (node == NULL) || (ns->type != XML_NAMESPACE_DECL) || (node->type != XML_ELEMENT_NODE)) return; /* @@ with_ns to check whether namespace nodes should be looked at @@ */ /* * prevent duplicates */ for (i = 0;i < cur->nodeNr;i++) { if ((cur->nodeTab[i] != NULL) && (cur->nodeTab[i]->type == XML_NAMESPACE_DECL) && (((xmlNsPtr)cur->nodeTab[i])->next == (xmlNsPtr) node) && (xmlStrEqual(ns->prefix, ((xmlNsPtr)cur->nodeTab[i])->prefix))) return; } /* * grow the nodeTab if needed */ if (cur->nodeMax == 0) { cur->nodeTab = (xmlNodePtr *) xmlMalloc(XML_NODESET_DEFAULT * sizeof(xmlNodePtr)); if (cur->nodeTab == NULL) { xmlXPathErrMemory(NULL, "growing nodeset\n"); return; } memset(cur->nodeTab, 0 , XML_NODESET_DEFAULT * (size_t) sizeof(xmlNodePtr)); cur->nodeMax = XML_NODESET_DEFAULT; } else if (cur->nodeNr == cur->nodeMax) { xmlNodePtr *temp; cur->nodeMax *= 2; temp = (xmlNodePtr *) xmlRealloc(cur->nodeTab, cur->nodeMax * sizeof(xmlNodePtr)); if (temp == NULL) { xmlXPathErrMemory(NULL, "growing nodeset\n"); return; } cur->nodeTab = temp; } cur->nodeTab[cur->nodeNr++] = xmlXPathNodeSetDupNs(node, ns); } /** * xmlXPathNodeSetAdd: * @cur: the initial node set * @val: a new xmlNodePtr * * add a new xmlNodePtr to an existing NodeSet */ void xmlXPathNodeSetAdd(xmlNodeSetPtr cur, xmlNodePtr val) { int i; if ((cur == NULL) || (val == NULL)) return; #if 0 if ((val->type == XML_ELEMENT_NODE) && (val->name[0] == ' ')) return; /* an XSLT fake node */ #endif /* @@ with_ns to check whether namespace nodes should be looked at @@ */ /* * prevent duplcates */ for (i = 0;i < cur->nodeNr;i++) if (cur->nodeTab[i] == val) return; /* * grow the nodeTab if needed */ if (cur->nodeMax == 0) { cur->nodeTab = (xmlNodePtr *) xmlMalloc(XML_NODESET_DEFAULT * sizeof(xmlNodePtr)); if (cur->nodeTab == NULL) { xmlXPathErrMemory(NULL, "growing nodeset\n"); return; } memset(cur->nodeTab, 0 , XML_NODESET_DEFAULT * (size_t) sizeof(xmlNodePtr)); cur->nodeMax = XML_NODESET_DEFAULT; } else if (cur->nodeNr == cur->nodeMax) { xmlNodePtr *temp; cur->nodeMax *= 2; temp = (xmlNodePtr *) xmlRealloc(cur->nodeTab, cur->nodeMax * sizeof(xmlNodePtr)); if (temp == NULL) { xmlXPathErrMemory(NULL, "growing nodeset\n"); return; } cur->nodeTab = temp; } if (val->type == XML_NAMESPACE_DECL) { xmlNsPtr ns = (xmlNsPtr) val; cur->nodeTab[cur->nodeNr++] = xmlXPathNodeSetDupNs((xmlNodePtr) ns->next, ns); } else cur->nodeTab[cur->nodeNr++] = val; } /** * xmlXPathNodeSetAddUnique: * @cur: the initial node set * @val: a new xmlNodePtr * * add a new xmlNodePtr to an existing NodeSet, optimized version * when we are sure the node is not already in the set. */ void xmlXPathNodeSetAddUnique(xmlNodeSetPtr cur, xmlNodePtr val) { if ((cur == NULL) || (val == NULL)) return; #if 0 if ((val->type == XML_ELEMENT_NODE) && (val->name[0] == ' ')) return; /* an XSLT fake node */ #endif /* @@ with_ns to check whether namespace nodes should be looked at @@ */ /* * grow the nodeTab if needed */ if (cur->nodeMax == 0) { cur->nodeTab = (xmlNodePtr *) xmlMalloc(XML_NODESET_DEFAULT * sizeof(xmlNodePtr)); if (cur->nodeTab == NULL) { xmlXPathErrMemory(NULL, "growing nodeset\n"); return; } memset(cur->nodeTab, 0 , XML_NODESET_DEFAULT * (size_t) sizeof(xmlNodePtr)); cur->nodeMax = XML_NODESET_DEFAULT; } else if (cur->nodeNr == cur->nodeMax) { xmlNodePtr *temp; cur->nodeMax *= 2; temp = (xmlNodePtr *) xmlRealloc(cur->nodeTab, cur->nodeMax * sizeof(xmlNodePtr)); if (temp == NULL) { xmlXPathErrMemory(NULL, "growing nodeset\n"); return; } cur->nodeTab = temp; } if (val->type == XML_NAMESPACE_DECL) { xmlNsPtr ns = (xmlNsPtr) val; cur->nodeTab[cur->nodeNr++] = xmlXPathNodeSetDupNs((xmlNodePtr) ns->next, ns); } else cur->nodeTab[cur->nodeNr++] = val; } /** * xmlXPathNodeSetMerge: * @val1: the first NodeSet or NULL * @val2: the second NodeSet * * Merges two nodesets, all nodes from @val2 are added to @val1 * if @val1 is NULL, a new set is created and copied from @val2 * * Returns @val1 once extended or NULL in case of error. */ xmlNodeSetPtr xmlXPathNodeSetMerge(xmlNodeSetPtr val1, xmlNodeSetPtr val2) { int i, j, initNr, skip; xmlNodePtr n1, n2; if (val2 == NULL) return(val1); if (val1 == NULL) { val1 = xmlXPathNodeSetCreate(NULL); #if 0 /* * TODO: The optimization won't work in every case, since * those nasty namespace nodes need to be added with * xmlXPathNodeSetDupNs() to the set; thus a pure * memcpy is not possible. * If there was a flag on the nodesetval, indicating that * some temporary nodes are in, that would be helpfull. */ /* * Optimization: Create an equally sized node-set * and memcpy the content. */ val1 = xmlXPathNodeSetCreateSize(val2->nodeNr); if (val1 == NULL) return(NULL); if (val2->nodeNr != 0) { if (val2->nodeNr == 1) *(val1->nodeTab) = *(val2->nodeTab); else { memcpy(val1->nodeTab, val2->nodeTab, val2->nodeNr * sizeof(xmlNodePtr)); } val1->nodeNr = val2->nodeNr; } return(val1); #endif } /* @@ with_ns to check whether namespace nodes should be looked at @@ */ initNr = val1->nodeNr; for (i = 0;i < val2->nodeNr;i++) { n2 = val2->nodeTab[i]; /* * check against duplicates */ skip = 0; for (j = 0; j < initNr; j++) { n1 = val1->nodeTab[j]; if (n1 == n2) { skip = 1; break; } else if ((n1->type == XML_NAMESPACE_DECL) && (n2->type == XML_NAMESPACE_DECL)) { if ((((xmlNsPtr) n1)->next == ((xmlNsPtr) n2)->next) && (xmlStrEqual(((xmlNsPtr) n1)->prefix, ((xmlNsPtr) n2)->prefix))) { skip = 1; break; } } } if (skip) continue; /* * grow the nodeTab if needed */ if (val1->nodeMax == 0) { val1->nodeTab = (xmlNodePtr *) xmlMalloc(XML_NODESET_DEFAULT * sizeof(xmlNodePtr)); if (val1->nodeTab == NULL) { xmlXPathErrMemory(NULL, "merging nodeset\n"); return(NULL); } memset(val1->nodeTab, 0 , XML_NODESET_DEFAULT * (size_t) sizeof(xmlNodePtr)); val1->nodeMax = XML_NODESET_DEFAULT; } else if (val1->nodeNr == val1->nodeMax) { xmlNodePtr *temp; val1->nodeMax *= 2; temp = (xmlNodePtr *) xmlRealloc(val1->nodeTab, val1->nodeMax * sizeof(xmlNodePtr)); if (temp == NULL) { xmlXPathErrMemory(NULL, "merging nodeset\n"); return(NULL); } val1->nodeTab = temp; } if (n2->type == XML_NAMESPACE_DECL) { xmlNsPtr ns = (xmlNsPtr) n2; val1->nodeTab[val1->nodeNr++] = xmlXPathNodeSetDupNs((xmlNodePtr) ns->next, ns); } else val1->nodeTab[val1->nodeNr++] = n2; } return(val1); } #if 0 /* xmlXPathNodeSetMergeUnique() is currently not used anymore */ /** * xmlXPathNodeSetMergeUnique: * @val1: the first NodeSet or NULL * @val2: the second NodeSet * * Merges two nodesets, all nodes from @val2 are added to @val1 * if @val1 is NULL, a new set is created and copied from @val2 * * Returns @val1 once extended or NULL in case of error. */ static xmlNodeSetPtr xmlXPathNodeSetMergeUnique(xmlNodeSetPtr val1, xmlNodeSetPtr val2) { int i; if (val2 == NULL) return(val1); if (val1 == NULL) { val1 = xmlXPathNodeSetCreate(NULL); } /* @@ with_ns to check whether namespace nodes should be looked at @@ */ for (i = 0;i < val2->nodeNr;i++) { /* * grow the nodeTab if needed */ if (val1->nodeMax == 0) { val1->nodeTab = (xmlNodePtr *) xmlMalloc(XML_NODESET_DEFAULT * sizeof(xmlNodePtr)); if (val1->nodeTab == NULL) { xmlXPathErrMemory(NULL, "merging nodeset\n"); return(NULL); } memset(val1->nodeTab, 0 , XML_NODESET_DEFAULT * (size_t) sizeof(xmlNodePtr)); val1->nodeMax = XML_NODESET_DEFAULT; } else if (val1->nodeNr == val1->nodeMax) { xmlNodePtr *temp; val1->nodeMax *= 2; temp = (xmlNodePtr *) xmlRealloc(val1->nodeTab, val1->nodeMax * sizeof(xmlNodePtr)); if (temp == NULL) { xmlXPathErrMemory(NULL, "merging nodeset\n"); return(NULL); } val1->nodeTab = temp; } if (val2->nodeTab[i]->type == XML_NAMESPACE_DECL) { xmlNsPtr ns = (xmlNsPtr) val2->nodeTab[i]; val1->nodeTab[val1->nodeNr++] = xmlXPathNodeSetDupNs((xmlNodePtr) ns->next, ns); } else val1->nodeTab[val1->nodeNr++] = val2->nodeTab[i]; } return(val1); } #endif /* xmlXPathNodeSetMergeUnique() is currently not used anymore */ /** * xmlXPathNodeSetMergeAndClear: * @set1: the first NodeSet or NULL * @set2: the second NodeSet * @hasSet2NsNodes: 1 if set2 contains namespaces nodes * * Merges two nodesets, all nodes from @set2 are added to @set1 * if @set1 is NULL, a new set is created and copied from @set2. * Checks for duplicate nodes. Clears set2. * * Returns @set1 once extended or NULL in case of error. */ static xmlNodeSetPtr xmlXPathNodeSetMergeAndClear(xmlNodeSetPtr set1, xmlNodeSetPtr set2, int hasNullEntries) { if ((set1 == NULL) && (hasNullEntries == 0)) { /* * Note that doing a memcpy of the list, namespace nodes are * just assigned to set1, since set2 is cleared anyway. */ set1 = xmlXPathNodeSetCreateSize(set2->nodeNr); if (set1 == NULL) return(NULL); if (set2->nodeNr != 0) { memcpy(set1->nodeTab, set2->nodeTab, set2->nodeNr * sizeof(xmlNodePtr)); set1->nodeNr = set2->nodeNr; } } else { int i, j, initNbSet1; xmlNodePtr n1, n2; if (set1 == NULL) set1 = xmlXPathNodeSetCreate(NULL); initNbSet1 = set1->nodeNr; for (i = 0;i < set2->nodeNr;i++) { n2 = set2->nodeTab[i]; /* * Skip NULLed entries. */ if (n2 == NULL) continue; /* * Skip duplicates. */ for (j = 0; j < initNbSet1; j++) { n1 = set1->nodeTab[j]; if (n1 == n2) { goto skip_node; } else if ((n1->type == XML_NAMESPACE_DECL) && (n2->type == XML_NAMESPACE_DECL)) { if ((((xmlNsPtr) n1)->next == ((xmlNsPtr) n2)->next) && (xmlStrEqual(((xmlNsPtr) n1)->prefix, ((xmlNsPtr) n2)->prefix))) { /* * Free the namespace node. */ set2->nodeTab[i] = NULL; xmlXPathNodeSetFreeNs((xmlNsPtr) n2); goto skip_node; } } } /* * grow the nodeTab if needed */ if (set1->nodeMax == 0) { set1->nodeTab = (xmlNodePtr *) xmlMalloc( XML_NODESET_DEFAULT * sizeof(xmlNodePtr)); if (set1->nodeTab == NULL) { xmlXPathErrMemory(NULL, "merging nodeset\n"); return(NULL); } memset(set1->nodeTab, 0, XML_NODESET_DEFAULT * (size_t) sizeof(xmlNodePtr)); set1->nodeMax = XML_NODESET_DEFAULT; } else if (set1->nodeNr >= set1->nodeMax) { xmlNodePtr *temp; set1->nodeMax *= 2; temp = (xmlNodePtr *) xmlRealloc( set1->nodeTab, set1->nodeMax * sizeof(xmlNodePtr)); if (temp == NULL) { xmlXPathErrMemory(NULL, "merging nodeset\n"); return(NULL); } set1->nodeTab = temp; } if (n2->type == XML_NAMESPACE_DECL) { xmlNsPtr ns = (xmlNsPtr) n2; set1->nodeTab[set1->nodeNr++] = xmlXPathNodeSetDupNs((xmlNodePtr) ns->next, ns); } else set1->nodeTab[set1->nodeNr++] = n2; skip_node: {} } } set2->nodeNr = 0; return(set1); } /** * xmlXPathNodeSetMergeAndClearNoDupls: * @set1: the first NodeSet or NULL * @set2: the second NodeSet * @hasSet2NsNodes: 1 if set2 contains namespaces nodes * * Merges two nodesets, all nodes from @set2 are added to @set1 * if @set1 is NULL, a new set is created and copied from @set2. * Doesn't chack for duplicate nodes. Clears set2. * * Returns @set1 once extended or NULL in case of error. */ static xmlNodeSetPtr xmlXPathNodeSetMergeAndClearNoDupls(xmlNodeSetPtr set1, xmlNodeSetPtr set2, int hasNullEntries) { if (set2 == NULL) return(set1); if ((set1 == NULL) && (hasNullEntries == 0)) { /* * Note that doing a memcpy of the list, namespace nodes are * just assigned to set1, since set2 is cleared anyway. */ set1 = xmlXPathNodeSetCreateSize(set2->nodeNr); if (set1 == NULL) return(NULL); if (set2->nodeNr != 0) { memcpy(set1->nodeTab, set2->nodeTab, set2->nodeNr * sizeof(xmlNodePtr)); set1->nodeNr = set2->nodeNr; } } else { int i; xmlNodePtr n2; if (set1 == NULL) set1 = xmlXPathNodeSetCreate(NULL); for (i = 0;i < set2->nodeNr;i++) { n2 = set2->nodeTab[i]; /* * Skip NULLed entries. */ if (n2 == NULL) continue; if (set1->nodeMax == 0) { set1->nodeTab = (xmlNodePtr *) xmlMalloc( XML_NODESET_DEFAULT * sizeof(xmlNodePtr)); if (set1->nodeTab == NULL) { xmlXPathErrMemory(NULL, "merging nodeset\n"); return(NULL); } memset(set1->nodeTab, 0, XML_NODESET_DEFAULT * (size_t) sizeof(xmlNodePtr)); set1->nodeMax = XML_NODESET_DEFAULT; } else if (set1->nodeNr >= set1->nodeMax) { xmlNodePtr *temp; set1->nodeMax *= 2; temp = (xmlNodePtr *) xmlRealloc( set1->nodeTab, set1->nodeMax * sizeof(xmlNodePtr)); if (temp == NULL) { xmlXPathErrMemory(NULL, "merging nodeset\n"); return(NULL); } set1->nodeTab = temp; } set1->nodeTab[set1->nodeNr++] = n2; } } set2->nodeNr = 0; return(set1); } /** * xmlXPathNodeSetDel: * @cur: the initial node set * @val: an xmlNodePtr * * Removes an xmlNodePtr from an existing NodeSet */ void xmlXPathNodeSetDel(xmlNodeSetPtr cur, xmlNodePtr val) { int i; if (cur == NULL) return; if (val == NULL) return; /* * find node in nodeTab */ for (i = 0;i < cur->nodeNr;i++) if (cur->nodeTab[i] == val) break; if (i >= cur->nodeNr) { /* not found */ #ifdef DEBUG xmlGenericError(xmlGenericErrorContext, "xmlXPathNodeSetDel: Node %s wasn't found in NodeList\n", val->name); #endif return; } if ((cur->nodeTab[i] != NULL) && (cur->nodeTab[i]->type == XML_NAMESPACE_DECL)) xmlXPathNodeSetFreeNs((xmlNsPtr) cur->nodeTab[i]); cur->nodeNr--; for (;i < cur->nodeNr;i++) cur->nodeTab[i] = cur->nodeTab[i + 1]; cur->nodeTab[cur->nodeNr] = NULL; } /** * xmlXPathNodeSetRemove: * @cur: the initial node set * @val: the index to remove * * Removes an entry from an existing NodeSet list. */ void xmlXPathNodeSetRemove(xmlNodeSetPtr cur, int val) { if (cur == NULL) return; if (val >= cur->nodeNr) return; if ((cur->nodeTab[val] != NULL) && (cur->nodeTab[val]->type == XML_NAMESPACE_DECL)) xmlXPathNodeSetFreeNs((xmlNsPtr) cur->nodeTab[val]); cur->nodeNr--; for (;val < cur->nodeNr;val++) cur->nodeTab[val] = cur->nodeTab[val + 1]; cur->nodeTab[cur->nodeNr] = NULL; } /** * xmlXPathFreeNodeSet: * @obj: the xmlNodeSetPtr to free * * Free the NodeSet compound (not the actual nodes !). */ void xmlXPathFreeNodeSet(xmlNodeSetPtr obj) { if (obj == NULL) return; if (obj->nodeTab != NULL) { int i; /* @@ with_ns to check whether namespace nodes should be looked at @@ */ for (i = 0;i < obj->nodeNr;i++) if ((obj->nodeTab[i] != NULL) && (obj->nodeTab[i]->type == XML_NAMESPACE_DECL)) xmlXPathNodeSetFreeNs((xmlNsPtr) obj->nodeTab[i]); xmlFree(obj->nodeTab); } xmlFree(obj); } /** * xmlXPathNodeSetClear: * @set: the node set to clear * * Clears the list from all temporary XPath objects (e.g. namespace nodes * are feed), but does *not* free the list itself. Sets the length of the * list to 0. */ static void xmlXPathNodeSetClear(xmlNodeSetPtr set, int hasNsNodes) { if ((set == NULL) || (set->nodeNr <= 0)) return; else if (hasNsNodes) { int i; xmlNodePtr node; for (i = 0; i < set->nodeNr; i++) { node = set->nodeTab[i]; if ((node != NULL) && (node->type == XML_NAMESPACE_DECL)) xmlXPathNodeSetFreeNs((xmlNsPtr) node); } } set->nodeNr = 0; } /** * xmlXPathNodeSetClearFromPos: * @set: the node set to be cleared * @pos: the start position to clear from * * Clears the list from temporary XPath objects (e.g. namespace nodes * are feed) starting with the entry at @pos, but does *not* free the list * itself. Sets the length of the list to @pos. */ static void xmlXPathNodeSetClearFromPos(xmlNodeSetPtr set, int pos, int hasNsNodes) { if ((set == NULL) || (set->nodeNr <= 0) || (pos >= set->nodeNr)) return; else if ((hasNsNodes)) { int i; xmlNodePtr node; for (i = pos; i < set->nodeNr; i++) { node = set->nodeTab[i]; if ((node != NULL) && (node->type == XML_NAMESPACE_DECL)) xmlXPathNodeSetFreeNs((xmlNsPtr) node); } } set->nodeNr = pos; } /** * xmlXPathFreeValueTree: * @obj: the xmlNodeSetPtr to free * * Free the NodeSet compound and the actual tree, this is different * from xmlXPathFreeNodeSet() */ static void xmlXPathFreeValueTree(xmlNodeSetPtr obj) { int i; if (obj == NULL) return; if (obj->nodeTab != NULL) { for (i = 0;i < obj->nodeNr;i++) { if (obj->nodeTab[i] != NULL) { if (obj->nodeTab[i]->type == XML_NAMESPACE_DECL) { xmlXPathNodeSetFreeNs((xmlNsPtr) obj->nodeTab[i]); } else { xmlFreeNodeList(obj->nodeTab[i]); } } } xmlFree(obj->nodeTab); } xmlFree(obj); } #if defined(DEBUG) || defined(DEBUG_STEP) /** * xmlGenericErrorContextNodeSet: * @output: a FILE * for the output * @obj: the xmlNodeSetPtr to display * * Quick display of a NodeSet */ void xmlGenericErrorContextNodeSet(FILE *output, xmlNodeSetPtr obj) { int i; if (output == NULL) output = xmlGenericErrorContext; if (obj == NULL) { fprintf(output, "NodeSet == NULL !\n"); return; } if (obj->nodeNr == 0) { fprintf(output, "NodeSet is empty\n"); return; } if (obj->nodeTab == NULL) { fprintf(output, " nodeTab == NULL !\n"); return; } for (i = 0; i < obj->nodeNr; i++) { if (obj->nodeTab[i] == NULL) { fprintf(output, " NULL !\n"); return; } if ((obj->nodeTab[i]->type == XML_DOCUMENT_NODE) || (obj->nodeTab[i]->type == XML_HTML_DOCUMENT_NODE)) fprintf(output, " /"); else if (obj->nodeTab[i]->name == NULL) fprintf(output, " noname!"); else fprintf(output, " %s", obj->nodeTab[i]->name); } fprintf(output, "\n"); } #endif /** * xmlXPathNewNodeSet: * @val: the NodePtr value * * Create a new xmlXPathObjectPtr of type NodeSet and initialize * it with the single Node @val * * Returns the newly created object. */ xmlXPathObjectPtr xmlXPathNewNodeSet(xmlNodePtr val) { xmlXPathObjectPtr ret; ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject)); if (ret == NULL) { xmlXPathErrMemory(NULL, "creating nodeset\n"); return(NULL); } memset(ret, 0 , (size_t) sizeof(xmlXPathObject)); ret->type = XPATH_NODESET; ret->boolval = 0; ret->nodesetval = xmlXPathNodeSetCreate(val); /* @@ with_ns to check whether namespace nodes should be looked at @@ */ #ifdef XP_DEBUG_OBJ_USAGE xmlXPathDebugObjUsageRequested(NULL, XPATH_NODESET); #endif return(ret); } /** * xmlXPathNewValueTree: * @val: the NodePtr value * * Create a new xmlXPathObjectPtr of type Value Tree (XSLT) and initialize * it with the tree root @val * * Returns the newly created object. */ xmlXPathObjectPtr xmlXPathNewValueTree(xmlNodePtr val) { xmlXPathObjectPtr ret; ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject)); if (ret == NULL) { xmlXPathErrMemory(NULL, "creating result value tree\n"); return(NULL); } memset(ret, 0 , (size_t) sizeof(xmlXPathObject)); ret->type = XPATH_XSLT_TREE; ret->boolval = 1; ret->user = (void *) val; ret->nodesetval = xmlXPathNodeSetCreate(val); #ifdef XP_DEBUG_OBJ_USAGE xmlXPathDebugObjUsageRequested(NULL, XPATH_XSLT_TREE); #endif return(ret); } /** * xmlXPathNewNodeSetList: * @val: an existing NodeSet * * Create a new xmlXPathObjectPtr of type NodeSet and initialize * it with the Nodeset @val * * Returns the newly created object. */ xmlXPathObjectPtr xmlXPathNewNodeSetList(xmlNodeSetPtr val) { xmlXPathObjectPtr ret; int i; if (val == NULL) ret = NULL; else if (val->nodeTab == NULL) ret = xmlXPathNewNodeSet(NULL); else { ret = xmlXPathNewNodeSet(val->nodeTab[0]); for (i = 1; i < val->nodeNr; ++i) xmlXPathNodeSetAddUnique(ret->nodesetval, val->nodeTab[i]); } return (ret); } /** * xmlXPathWrapNodeSet: * @val: the NodePtr value * * Wrap the Nodeset @val in a new xmlXPathObjectPtr * * Returns the newly created object. */ xmlXPathObjectPtr xmlXPathWrapNodeSet(xmlNodeSetPtr val) { xmlXPathObjectPtr ret; ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject)); if (ret == NULL) { xmlXPathErrMemory(NULL, "creating node set object\n"); return(NULL); } memset(ret, 0 , (size_t) sizeof(xmlXPathObject)); ret->type = XPATH_NODESET; ret->nodesetval = val; #ifdef XP_DEBUG_OBJ_USAGE xmlXPathDebugObjUsageRequested(NULL, XPATH_NODESET); #endif return(ret); } /** * xmlXPathFreeNodeSetList: * @obj: an existing NodeSetList object * * Free up the xmlXPathObjectPtr @obj but don't deallocate the objects in * the list contrary to xmlXPathFreeObject(). */ void xmlXPathFreeNodeSetList(xmlXPathObjectPtr obj) { if (obj == NULL) return; #ifdef XP_DEBUG_OBJ_USAGE xmlXPathDebugObjUsageReleased(NULL, obj->type); #endif xmlFree(obj); } /** * xmlXPathDifference: * @nodes1: a node-set * @nodes2: a node-set * * Implements the EXSLT - Sets difference() function: * node-set set:difference (node-set, node-set) * * Returns the difference between the two node sets, or nodes1 if * nodes2 is empty */ xmlNodeSetPtr xmlXPathDifference (xmlNodeSetPtr nodes1, xmlNodeSetPtr nodes2) { xmlNodeSetPtr ret; int i, l1; xmlNodePtr cur; if (xmlXPathNodeSetIsEmpty(nodes2)) return(nodes1); ret = xmlXPathNodeSetCreate(NULL); if (xmlXPathNodeSetIsEmpty(nodes1)) return(ret); l1 = xmlXPathNodeSetGetLength(nodes1); for (i = 0; i < l1; i++) { cur = xmlXPathNodeSetItem(nodes1, i); if (!xmlXPathNodeSetContains(nodes2, cur)) xmlXPathNodeSetAddUnique(ret, cur); } return(ret); } /** * xmlXPathIntersection: * @nodes1: a node-set * @nodes2: a node-set * * Implements the EXSLT - Sets intersection() function: * node-set set:intersection (node-set, node-set) * * Returns a node set comprising the nodes that are within both the * node sets passed as arguments */ xmlNodeSetPtr xmlXPathIntersection (xmlNodeSetPtr nodes1, xmlNodeSetPtr nodes2) { xmlNodeSetPtr ret = xmlXPathNodeSetCreate(NULL); int i, l1; xmlNodePtr cur; if (xmlXPathNodeSetIsEmpty(nodes1)) return(ret); if (xmlXPathNodeSetIsEmpty(nodes2)) return(ret); l1 = xmlXPathNodeSetGetLength(nodes1); for (i = 0; i < l1; i++) { cur = xmlXPathNodeSetItem(nodes1, i); if (xmlXPathNodeSetContains(nodes2, cur)) xmlXPathNodeSetAddUnique(ret, cur); } return(ret); } /** * xmlXPathDistinctSorted: * @nodes: a node-set, sorted by document order * * Implements the EXSLT - Sets distinct() function: * node-set set:distinct (node-set) * * Returns a subset of the nodes contained in @nodes, or @nodes if * it is empty */ xmlNodeSetPtr xmlXPathDistinctSorted (xmlNodeSetPtr nodes) { xmlNodeSetPtr ret; xmlHashTablePtr hash; int i, l; xmlChar * strval; xmlNodePtr cur; if (xmlXPathNodeSetIsEmpty(nodes)) return(nodes); ret = xmlXPathNodeSetCreate(NULL); l = xmlXPathNodeSetGetLength(nodes); hash = xmlHashCreate (l); for (i = 0; i < l; i++) { cur = xmlXPathNodeSetItem(nodes, i); strval = xmlXPathCastNodeToString(cur); if (xmlHashLookup(hash, strval) == NULL) { xmlHashAddEntry(hash, strval, strval); xmlXPathNodeSetAddUnique(ret, cur); } else { xmlFree(strval); } } xmlHashFree(hash, (xmlHashDeallocator) xmlFree); return(ret); } /** * xmlXPathDistinct: * @nodes: a node-set * * Implements the EXSLT - Sets distinct() function: * node-set set:distinct (node-set) * @nodes is sorted by document order, then #exslSetsDistinctSorted * is called with the sorted node-set * * Returns a subset of the nodes contained in @nodes, or @nodes if * it is empty */ xmlNodeSetPtr xmlXPathDistinct (xmlNodeSetPtr nodes) { if (xmlXPathNodeSetIsEmpty(nodes)) return(nodes); xmlXPathNodeSetSort(nodes); return(xmlXPathDistinctSorted(nodes)); } /** * xmlXPathHasSameNodes: * @nodes1: a node-set * @nodes2: a node-set * * Implements the EXSLT - Sets has-same-nodes function: * boolean set:has-same-node(node-set, node-set) * * Returns true (1) if @nodes1 shares any node with @nodes2, false (0) * otherwise */ int xmlXPathHasSameNodes (xmlNodeSetPtr nodes1, xmlNodeSetPtr nodes2) { int i, l; xmlNodePtr cur; if (xmlXPathNodeSetIsEmpty(nodes1) || xmlXPathNodeSetIsEmpty(nodes2)) return(0); l = xmlXPathNodeSetGetLength(nodes1); for (i = 0; i < l; i++) { cur = xmlXPathNodeSetItem(nodes1, i); if (xmlXPathNodeSetContains(nodes2, cur)) return(1); } return(0); } /** * xmlXPathNodeLeadingSorted: * @nodes: a node-set, sorted by document order * @node: a node * * Implements the EXSLT - Sets leading() function: * node-set set:leading (node-set, node-set) * * Returns the nodes in @nodes that precede @node in document order, * @nodes if @node is NULL or an empty node-set if @nodes * doesn't contain @node */ xmlNodeSetPtr xmlXPathNodeLeadingSorted (xmlNodeSetPtr nodes, xmlNodePtr node) { int i, l; xmlNodePtr cur; xmlNodeSetPtr ret; if (node == NULL) return(nodes); ret = xmlXPathNodeSetCreate(NULL); if (xmlXPathNodeSetIsEmpty(nodes) || (!xmlXPathNodeSetContains(nodes, node))) return(ret); l = xmlXPathNodeSetGetLength(nodes); for (i = 0; i < l; i++) { cur = xmlXPathNodeSetItem(nodes, i); if (cur == node) break; xmlXPathNodeSetAddUnique(ret, cur); } return(ret); } /** * xmlXPathNodeLeading: * @nodes: a node-set * @node: a node * * Implements the EXSLT - Sets leading() function: * node-set set:leading (node-set, node-set) * @nodes is sorted by document order, then #exslSetsNodeLeadingSorted * is called. * * Returns the nodes in @nodes that precede @node in document order, * @nodes if @node is NULL or an empty node-set if @nodes * doesn't contain @node */ xmlNodeSetPtr xmlXPathNodeLeading (xmlNodeSetPtr nodes, xmlNodePtr node) { xmlXPathNodeSetSort(nodes); return(xmlXPathNodeLeadingSorted(nodes, node)); } /** * xmlXPathLeadingSorted: * @nodes1: a node-set, sorted by document order * @nodes2: a node-set, sorted by document order * * Implements the EXSLT - Sets leading() function: * node-set set:leading (node-set, node-set) * * Returns the nodes in @nodes1 that precede the first node in @nodes2 * in document order, @nodes1 if @nodes2 is NULL or empty or * an empty node-set if @nodes1 doesn't contain @nodes2 */ xmlNodeSetPtr xmlXPathLeadingSorted (xmlNodeSetPtr nodes1, xmlNodeSetPtr nodes2) { if (xmlXPathNodeSetIsEmpty(nodes2)) return(nodes1); return(xmlXPathNodeLeadingSorted(nodes1, xmlXPathNodeSetItem(nodes2, 1))); } /** * xmlXPathLeading: * @nodes1: a node-set * @nodes2: a node-set * * Implements the EXSLT - Sets leading() function: * node-set set:leading (node-set, node-set) * @nodes1 and @nodes2 are sorted by document order, then * #exslSetsLeadingSorted is called. * * Returns the nodes in @nodes1 that precede the first node in @nodes2 * in document order, @nodes1 if @nodes2 is NULL or empty or * an empty node-set if @nodes1 doesn't contain @nodes2 */ xmlNodeSetPtr xmlXPathLeading (xmlNodeSetPtr nodes1, xmlNodeSetPtr nodes2) { if (xmlXPathNodeSetIsEmpty(nodes2)) return(nodes1); if (xmlXPathNodeSetIsEmpty(nodes1)) return(xmlXPathNodeSetCreate(NULL)); xmlXPathNodeSetSort(nodes1); xmlXPathNodeSetSort(nodes2); return(xmlXPathNodeLeadingSorted(nodes1, xmlXPathNodeSetItem(nodes2, 1))); } /** * xmlXPathNodeTrailingSorted: * @nodes: a node-set, sorted by document order * @node: a node * * Implements the EXSLT - Sets trailing() function: * node-set set:trailing (node-set, node-set) * * Returns the nodes in @nodes that follow @node in document order, * @nodes if @node is NULL or an empty node-set if @nodes * doesn't contain @node */ xmlNodeSetPtr xmlXPathNodeTrailingSorted (xmlNodeSetPtr nodes, xmlNodePtr node) { int i, l; xmlNodePtr cur; xmlNodeSetPtr ret; if (node == NULL) return(nodes); ret = xmlXPathNodeSetCreate(NULL); if (xmlXPathNodeSetIsEmpty(nodes) || (!xmlXPathNodeSetContains(nodes, node))) return(ret); l = xmlXPathNodeSetGetLength(nodes); for (i = l; i > 0; i--) { cur = xmlXPathNodeSetItem(nodes, i); if (cur == node) break; xmlXPathNodeSetAddUnique(ret, cur); } return(ret); } /** * xmlXPathNodeTrailing: * @nodes: a node-set * @node: a node * * Implements the EXSLT - Sets trailing() function: * node-set set:trailing (node-set, node-set) * @nodes is sorted by document order, then #xmlXPathNodeTrailingSorted * is called. * * Returns the nodes in @nodes that follow @node in document order, * @nodes if @node is NULL or an empty node-set if @nodes * doesn't contain @node */ xmlNodeSetPtr xmlXPathNodeTrailing (xmlNodeSetPtr nodes, xmlNodePtr node) { xmlXPathNodeSetSort(nodes); return(xmlXPathNodeTrailingSorted(nodes, node)); } /** * xmlXPathTrailingSorted: * @nodes1: a node-set, sorted by document order * @nodes2: a node-set, sorted by document order * * Implements the EXSLT - Sets trailing() function: * node-set set:trailing (node-set, node-set) * * Returns the nodes in @nodes1 that follow the first node in @nodes2 * in document order, @nodes1 if @nodes2 is NULL or empty or * an empty node-set if @nodes1 doesn't contain @nodes2 */ xmlNodeSetPtr xmlXPathTrailingSorted (xmlNodeSetPtr nodes1, xmlNodeSetPtr nodes2) { if (xmlXPathNodeSetIsEmpty(nodes2)) return(nodes1); return(xmlXPathNodeTrailingSorted(nodes1, xmlXPathNodeSetItem(nodes2, 0))); } /** * xmlXPathTrailing: * @nodes1: a node-set * @nodes2: a node-set * * Implements the EXSLT - Sets trailing() function: * node-set set:trailing (node-set, node-set) * @nodes1 and @nodes2 are sorted by document order, then * #xmlXPathTrailingSorted is called. * * Returns the nodes in @nodes1 that follow the first node in @nodes2 * in document order, @nodes1 if @nodes2 is NULL or empty or * an empty node-set if @nodes1 doesn't contain @nodes2 */ xmlNodeSetPtr xmlXPathTrailing (xmlNodeSetPtr nodes1, xmlNodeSetPtr nodes2) { if (xmlXPathNodeSetIsEmpty(nodes2)) return(nodes1); if (xmlXPathNodeSetIsEmpty(nodes1)) return(xmlXPathNodeSetCreate(NULL)); xmlXPathNodeSetSort(nodes1); xmlXPathNodeSetSort(nodes2); return(xmlXPathNodeTrailingSorted(nodes1, xmlXPathNodeSetItem(nodes2, 0))); } /************************************************************************ * * * Routines to handle extra functions * * * ************************************************************************/ /** * xmlXPathRegisterFunc: * @ctxt: the XPath context * @name: the function name * @f: the function implementation or NULL * * Register a new function. If @f is NULL it unregisters the function * * Returns 0 in case of success, -1 in case of error */ int xmlXPathRegisterFunc(xmlXPathContextPtr ctxt, const xmlChar *name, xmlXPathFunction f) { return(xmlXPathRegisterFuncNS(ctxt, name, NULL, f)); } /** * xmlXPathRegisterFuncNS: * @ctxt: the XPath context * @name: the function name * @ns_uri: the function namespace URI * @f: the function implementation or NULL * * Register a new function. If @f is NULL it unregisters the function * * Returns 0 in case of success, -1 in case of error */ int xmlXPathRegisterFuncNS(xmlXPathContextPtr ctxt, const xmlChar *name, const xmlChar *ns_uri, xmlXPathFunction f) { if (ctxt == NULL) return(-1); if (name == NULL) return(-1); if (ctxt->funcHash == NULL) ctxt->funcHash = xmlHashCreate(0); if (ctxt->funcHash == NULL) return(-1); if (f == NULL) return(xmlHashRemoveEntry2(ctxt->funcHash, name, ns_uri, NULL)); return(xmlHashAddEntry2(ctxt->funcHash, name, ns_uri, (void*)XML_CAST_FPTR(f))); } /** * xmlXPathRegisterFuncLookup: * @ctxt: the XPath context * @f: the lookup function * @funcCtxt: the lookup data * * Registers an external mechanism to do function lookup. */ void xmlXPathRegisterFuncLookup (xmlXPathContextPtr ctxt, xmlXPathFuncLookupFunc f, void *funcCtxt) { if (ctxt == NULL) return; ctxt->funcLookupFunc = f; ctxt->funcLookupData = funcCtxt; } /** * xmlXPathFunctionLookup: * @ctxt: the XPath context * @name: the function name * * Search in the Function array of the context for the given * function. * * Returns the xmlXPathFunction or NULL if not found */ xmlXPathFunction xmlXPathFunctionLookup(xmlXPathContextPtr ctxt, const xmlChar *name) { if (ctxt == NULL) return (NULL); if (ctxt->funcLookupFunc != NULL) { xmlXPathFunction ret; xmlXPathFuncLookupFunc f; f = ctxt->funcLookupFunc; ret = f(ctxt->funcLookupData, name, NULL); if (ret != NULL) return(ret); } return(xmlXPathFunctionLookupNS(ctxt, name, NULL)); } /** * xmlXPathFunctionLookupNS: * @ctxt: the XPath context * @name: the function name * @ns_uri: the function namespace URI * * Search in the Function array of the context for the given * function. * * Returns the xmlXPathFunction or NULL if not found */ xmlXPathFunction xmlXPathFunctionLookupNS(xmlXPathContextPtr ctxt, const xmlChar *name, const xmlChar *ns_uri) { xmlXPathFunction ret; if (ctxt == NULL) return(NULL); if (name == NULL) return(NULL); if (ctxt->funcLookupFunc != NULL) { xmlXPathFuncLookupFunc f; f = ctxt->funcLookupFunc; ret = f(ctxt->funcLookupData, name, ns_uri); if (ret != NULL) return(ret); } if (ctxt->funcHash == NULL) return(NULL); XML_CAST_FPTR(ret) = (xmlXPathFunction)xmlHashLookup2(ctxt->funcHash, name, ns_uri); return(ret); } /** * xmlXPathRegisteredFuncsCleanup: * @ctxt: the XPath context * * Cleanup the XPath context data associated to registered functions */ void xmlXPathRegisteredFuncsCleanup(xmlXPathContextPtr ctxt) { if (ctxt == NULL) return; xmlHashFree(ctxt->funcHash, NULL); ctxt->funcHash = NULL; } /************************************************************************ * * * Routines to handle Variables * * * ************************************************************************/ /** * xmlXPathRegisterVariable: * @ctxt: the XPath context * @name: the variable name * @value: the variable value or NULL * * Register a new variable value. If @value is NULL it unregisters * the variable * * Returns 0 in case of success, -1 in case of error */ int xmlXPathRegisterVariable(xmlXPathContextPtr ctxt, const xmlChar *name, xmlXPathObjectPtr value) { return(xmlXPathRegisterVariableNS(ctxt, name, NULL, value)); } /** * xmlXPathRegisterVariableNS: * @ctxt: the XPath context * @name: the variable name * @ns_uri: the variable namespace URI * @value: the variable value or NULL * * Register a new variable value. If @value is NULL it unregisters * the variable * * Returns 0 in case of success, -1 in case of error */ int xmlXPathRegisterVariableNS(xmlXPathContextPtr ctxt, const xmlChar *name, const xmlChar *ns_uri, xmlXPathObjectPtr value) { if (ctxt == NULL) return(-1); if (name == NULL) return(-1); if (ctxt->varHash == NULL) ctxt->varHash = xmlHashCreate(0); if (ctxt->varHash == NULL) return(-1); if (value == NULL) return(xmlHashRemoveEntry2(ctxt->varHash, name, ns_uri, (xmlHashDeallocator)xmlXPathFreeObject)); return(xmlHashUpdateEntry2(ctxt->varHash, name, ns_uri, (void *) value, (xmlHashDeallocator)xmlXPathFreeObject)); } /** * xmlXPathRegisterVariableLookup: * @ctxt: the XPath context * @f: the lookup function * @data: the lookup data * * register an external mechanism to do variable lookup */ void xmlXPathRegisterVariableLookup(xmlXPathContextPtr ctxt, xmlXPathVariableLookupFunc f, void *data) { if (ctxt == NULL) return; ctxt->varLookupFunc = f; ctxt->varLookupData = data; } /** * xmlXPathVariableLookup: * @ctxt: the XPath context * @name: the variable name * * Search in the Variable array of the context for the given * variable value. * * Returns a copy of the value or NULL if not found */ xmlXPathObjectPtr xmlXPathVariableLookup(xmlXPathContextPtr ctxt, const xmlChar *name) { if (ctxt == NULL) return(NULL); if (ctxt->varLookupFunc != NULL) { xmlXPathObjectPtr ret; ret = ((xmlXPathVariableLookupFunc)ctxt->varLookupFunc) (ctxt->varLookupData, name, NULL); return(ret); } return(xmlXPathVariableLookupNS(ctxt, name, NULL)); } /** * xmlXPathVariableLookupNS: * @ctxt: the XPath context * @name: the variable name * @ns_uri: the variable namespace URI * * Search in the Variable array of the context for the given * variable value. * * Returns the a copy of the value or NULL if not found */ xmlXPathObjectPtr xmlXPathVariableLookupNS(xmlXPathContextPtr ctxt, const xmlChar *name, const xmlChar *ns_uri) { if (ctxt == NULL) return(NULL); if (ctxt->varLookupFunc != NULL) { xmlXPathObjectPtr ret; ret = ((xmlXPathVariableLookupFunc)ctxt->varLookupFunc) (ctxt->varLookupData, name, ns_uri); if (ret != NULL) return(ret); } if (ctxt->varHash == NULL) return(NULL); if (name == NULL) return(NULL); return(xmlXPathCacheObjectCopy(ctxt, (xmlXPathObjectPtr) xmlHashLookup2(ctxt->varHash, name, ns_uri))); } /** * xmlXPathRegisteredVariablesCleanup: * @ctxt: the XPath context * * Cleanup the XPath context data associated to registered variables */ void xmlXPathRegisteredVariablesCleanup(xmlXPathContextPtr ctxt) { if (ctxt == NULL) return; xmlHashFree(ctxt->varHash, (xmlHashDeallocator)xmlXPathFreeObject); ctxt->varHash = NULL; } /** * xmlXPathRegisterNs: * @ctxt: the XPath context * @prefix: the namespace prefix * @ns_uri: the namespace name * * Register a new namespace. If @ns_uri is NULL it unregisters * the namespace * * Returns 0 in case of success, -1 in case of error */ int xmlXPathRegisterNs(xmlXPathContextPtr ctxt, const xmlChar *prefix, const xmlChar *ns_uri) { if (ctxt == NULL) return(-1); if (prefix == NULL) return(-1); if (ctxt->nsHash == NULL) ctxt->nsHash = xmlHashCreate(10); if (ctxt->nsHash == NULL) return(-1); if (ns_uri == NULL) return(xmlHashRemoveEntry(ctxt->nsHash, prefix, (xmlHashDeallocator)xmlFree)); return(xmlHashUpdateEntry(ctxt->nsHash, prefix, (void *) xmlStrdup(ns_uri), (xmlHashDeallocator)xmlFree)); } /** * xmlXPathNsLookup: * @ctxt: the XPath context * @prefix: the namespace prefix value * * Search in the namespace declaration array of the context for the given * namespace name associated to the given prefix * * Returns the value or NULL if not found */ const xmlChar * xmlXPathNsLookup(xmlXPathContextPtr ctxt, const xmlChar *prefix) { if (ctxt == NULL) return(NULL); if (prefix == NULL) return(NULL); #ifdef XML_XML_NAMESPACE if (xmlStrEqual(prefix, (const xmlChar *) "xml")) return(XML_XML_NAMESPACE); #endif if (ctxt->namespaces != NULL) { int i; for (i = 0;i < ctxt->nsNr;i++) { if ((ctxt->namespaces[i] != NULL) && (xmlStrEqual(ctxt->namespaces[i]->prefix, prefix))) return(ctxt->namespaces[i]->href); } } return((const xmlChar *) xmlHashLookup(ctxt->nsHash, prefix)); } /** * xmlXPathRegisteredNsCleanup: * @ctxt: the XPath context * * Cleanup the XPath context data associated to registered variables */ void xmlXPathRegisteredNsCleanup(xmlXPathContextPtr ctxt) { if (ctxt == NULL) return; xmlHashFree(ctxt->nsHash, (xmlHashDeallocator)xmlFree); ctxt->nsHash = NULL; } /************************************************************************ * * * Routines to handle Values * * * ************************************************************************/ /* Allocations are terrible, one needs to optimize all this !!! */ /** * xmlXPathNewFloat: * @val: the double value * * Create a new xmlXPathObjectPtr of type double and of value @val * * Returns the newly created object. */ xmlXPathObjectPtr xmlXPathNewFloat(double val) { xmlXPathObjectPtr ret; ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject)); if (ret == NULL) { xmlXPathErrMemory(NULL, "creating float object\n"); return(NULL); } memset(ret, 0 , (size_t) sizeof(xmlXPathObject)); ret->type = XPATH_NUMBER; ret->floatval = val; #ifdef XP_DEBUG_OBJ_USAGE xmlXPathDebugObjUsageRequested(NULL, XPATH_NUMBER); #endif return(ret); } /** * xmlXPathNewBoolean: * @val: the boolean value * * Create a new xmlXPathObjectPtr of type boolean and of value @val * * Returns the newly created object. */ xmlXPathObjectPtr xmlXPathNewBoolean(int val) { xmlXPathObjectPtr ret; ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject)); if (ret == NULL) { xmlXPathErrMemory(NULL, "creating boolean object\n"); return(NULL); } memset(ret, 0 , (size_t) sizeof(xmlXPathObject)); ret->type = XPATH_BOOLEAN; ret->boolval = (val != 0); #ifdef XP_DEBUG_OBJ_USAGE xmlXPathDebugObjUsageRequested(NULL, XPATH_BOOLEAN); #endif return(ret); } /** * xmlXPathNewString: * @val: the xmlChar * value * * Create a new xmlXPathObjectPtr of type string and of value @val * * Returns the newly created object. */ xmlXPathObjectPtr xmlXPathNewString(const xmlChar *val) { xmlXPathObjectPtr ret; ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject)); if (ret == NULL) { xmlXPathErrMemory(NULL, "creating string object\n"); return(NULL); } memset(ret, 0 , (size_t) sizeof(xmlXPathObject)); ret->type = XPATH_STRING; if (val != NULL) ret->stringval = xmlStrdup(val); else ret->stringval = xmlStrdup((const xmlChar *)""); #ifdef XP_DEBUG_OBJ_USAGE xmlXPathDebugObjUsageRequested(NULL, XPATH_STRING); #endif return(ret); } /** * xmlXPathWrapString: * @val: the xmlChar * value * * Wraps the @val string into an XPath object. * * Returns the newly created object. */ xmlXPathObjectPtr xmlXPathWrapString (xmlChar *val) { xmlXPathObjectPtr ret; ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject)); if (ret == NULL) { xmlXPathErrMemory(NULL, "creating string object\n"); return(NULL); } memset(ret, 0 , (size_t) sizeof(xmlXPathObject)); ret->type = XPATH_STRING; ret->stringval = val; #ifdef XP_DEBUG_OBJ_USAGE xmlXPathDebugObjUsageRequested(NULL, XPATH_STRING); #endif return(ret); } /** * xmlXPathNewCString: * @val: the char * value * * Create a new xmlXPathObjectPtr of type string and of value @val * * Returns the newly created object. */ xmlXPathObjectPtr xmlXPathNewCString(const char *val) { xmlXPathObjectPtr ret; ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject)); if (ret == NULL) { xmlXPathErrMemory(NULL, "creating string object\n"); return(NULL); } memset(ret, 0 , (size_t) sizeof(xmlXPathObject)); ret->type = XPATH_STRING; ret->stringval = xmlStrdup(BAD_CAST val); #ifdef XP_DEBUG_OBJ_USAGE xmlXPathDebugObjUsageRequested(NULL, XPATH_STRING); #endif return(ret); } /** * xmlXPathWrapCString: * @val: the char * value * * Wraps a string into an XPath object. * * Returns the newly created object. */ xmlXPathObjectPtr xmlXPathWrapCString (char * val) { return(xmlXPathWrapString((xmlChar *)(val))); } /** * xmlXPathWrapExternal: * @val: the user data * * Wraps the @val data into an XPath object. * * Returns the newly created object. */ xmlXPathObjectPtr xmlXPathWrapExternal (void *val) { xmlXPathObjectPtr ret; ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject)); if (ret == NULL) { xmlXPathErrMemory(NULL, "creating user object\n"); return(NULL); } memset(ret, 0 , (size_t) sizeof(xmlXPathObject)); ret->type = XPATH_USERS; ret->user = val; #ifdef XP_DEBUG_OBJ_USAGE xmlXPathDebugObjUsageRequested(NULL, XPATH_USERS); #endif return(ret); } /** * xmlXPathObjectCopy: * @val: the original object * * allocate a new copy of a given object * * Returns the newly created object. */ xmlXPathObjectPtr xmlXPathObjectCopy(xmlXPathObjectPtr val) { xmlXPathObjectPtr ret; if (val == NULL) return(NULL); ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject)); if (ret == NULL) { xmlXPathErrMemory(NULL, "copying object\n"); return(NULL); } memcpy(ret, val , (size_t) sizeof(xmlXPathObject)); #ifdef XP_DEBUG_OBJ_USAGE xmlXPathDebugObjUsageRequested(NULL, val->type); #endif switch (val->type) { case XPATH_BOOLEAN: case XPATH_NUMBER: case XPATH_POINT: case XPATH_RANGE: break; case XPATH_STRING: ret->stringval = xmlStrdup(val->stringval); break; case XPATH_XSLT_TREE: #if 0 /* Removed 11 July 2004 - the current handling of xslt tmpRVT nodes means that this previous handling is no longer correct, and can cause some serious problems (ref. bug 145547) */ if ((val->nodesetval != NULL) && (val->nodesetval->nodeTab != NULL)) { xmlNodePtr cur, tmp; xmlDocPtr top; ret->boolval = 1; top = xmlNewDoc(NULL); top->name = (char *) xmlStrdup(val->nodesetval->nodeTab[0]->name); ret->user = top; if (top != NULL) { top->doc = top; cur = val->nodesetval->nodeTab[0]->children; while (cur != NULL) { tmp = xmlDocCopyNode(cur, top, 1); xmlAddChild((xmlNodePtr) top, tmp); cur = cur->next; } } ret->nodesetval = xmlXPathNodeSetCreate((xmlNodePtr) top); } else ret->nodesetval = xmlXPathNodeSetCreate(NULL); /* Deallocate the copied tree value */ break; #endif case XPATH_NODESET: ret->nodesetval = xmlXPathNodeSetMerge(NULL, val->nodesetval); /* Do not deallocate the copied tree value */ ret->boolval = 0; break; case XPATH_LOCATIONSET: #ifdef LIBXML_XPTR_ENABLED { xmlLocationSetPtr loc = val->user; ret->user = (void *) xmlXPtrLocationSetMerge(NULL, loc); break; } #endif case XPATH_USERS: ret->user = val->user; break; case XPATH_UNDEFINED: xmlGenericError(xmlGenericErrorContext, "xmlXPathObjectCopy: unsupported type %d\n", val->type); break; } return(ret); } /** * xmlXPathFreeObject: * @obj: the object to free * * Free up an xmlXPathObjectPtr object. */ void xmlXPathFreeObject(xmlXPathObjectPtr obj) { if (obj == NULL) return; if ((obj->type == XPATH_NODESET) || (obj->type == XPATH_XSLT_TREE)) { if (obj->boolval) { #if 0 if (obj->user != NULL) { xmlXPathFreeNodeSet(obj->nodesetval); xmlFreeNodeList((xmlNodePtr) obj->user); } else #endif obj->type = XPATH_XSLT_TREE; /* TODO: Just for debugging. */ if (obj->nodesetval != NULL) xmlXPathFreeValueTree(obj->nodesetval); } else { if (obj->nodesetval != NULL) xmlXPathFreeNodeSet(obj->nodesetval); } #ifdef LIBXML_XPTR_ENABLED } else if (obj->type == XPATH_LOCATIONSET) { if (obj->user != NULL) xmlXPtrFreeLocationSet(obj->user); #endif } else if (obj->type == XPATH_STRING) { if (obj->stringval != NULL) xmlFree(obj->stringval); } #ifdef XP_DEBUG_OBJ_USAGE xmlXPathDebugObjUsageReleased(NULL, obj->type); #endif xmlFree(obj); } /** * xmlXPathReleaseObject: * @obj: the xmlXPathObjectPtr to free or to cache * * Depending on the state of the cache this frees the given * XPath object or stores it in the cache. */ static void xmlXPathReleaseObject(xmlXPathContextPtr ctxt, xmlXPathObjectPtr obj) { #define XP_CACHE_ADD(sl, o) if (sl == NULL) { \ sl = xmlPointerListCreate(10); if (sl == NULL) goto free_obj; } \ if (xmlPointerListAddSize(sl, obj, 0) == -1) goto free_obj; #define XP_CACHE_WANTS(sl, n) ((sl == NULL) || ((sl)->number < n)) if (obj == NULL) return; if ((ctxt == NULL) || (ctxt->cache == NULL)) { xmlXPathFreeObject(obj); } else { xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache; switch (obj->type) { case XPATH_NODESET: case XPATH_XSLT_TREE: if (obj->nodesetval != NULL) { if (obj->boolval) { /* * It looks like the @boolval is used for * evaluation if this an XSLT Result Tree Fragment. * TODO: Check if this assumption is correct. */ obj->type = XPATH_XSLT_TREE; /* just for debugging */ xmlXPathFreeValueTree(obj->nodesetval); obj->nodesetval = NULL; } else if ((obj->nodesetval->nodeMax <= 40) && (XP_CACHE_WANTS(cache->nodesetObjs, cache->maxNodeset))) { XP_CACHE_ADD(cache->nodesetObjs, obj); goto obj_cached; } else { xmlXPathFreeNodeSet(obj->nodesetval); obj->nodesetval = NULL; } } break; case XPATH_STRING: if (obj->stringval != NULL) xmlFree(obj->stringval); if (XP_CACHE_WANTS(cache->stringObjs, cache->maxString)) { XP_CACHE_ADD(cache->stringObjs, obj); goto obj_cached; } break; case XPATH_BOOLEAN: if (XP_CACHE_WANTS(cache->booleanObjs, cache->maxBoolean)) { XP_CACHE_ADD(cache->booleanObjs, obj); goto obj_cached; } break; case XPATH_NUMBER: if (XP_CACHE_WANTS(cache->numberObjs, cache->maxNumber)) { XP_CACHE_ADD(cache->numberObjs, obj); goto obj_cached; } break; #ifdef LIBXML_XPTR_ENABLED case XPATH_LOCATIONSET: if (obj->user != NULL) { xmlXPtrFreeLocationSet(obj->user); } goto free_obj; #endif default: goto free_obj; } /* * Fallback to adding to the misc-objects slot. */ if (XP_CACHE_WANTS(cache->miscObjs, cache->maxMisc)) { XP_CACHE_ADD(cache->miscObjs, obj); } else goto free_obj; obj_cached: #ifdef XP_DEBUG_OBJ_USAGE xmlXPathDebugObjUsageReleased(ctxt, obj->type); #endif if (obj->nodesetval != NULL) { xmlNodeSetPtr tmpset = obj->nodesetval; /* * TODO: Due to those nasty ns-nodes, we need to traverse * the list and free the ns-nodes. * URGENT TODO: Check if it's actually slowing things down. * Maybe we shouldn't try to preserve the list. */ if (tmpset->nodeNr > 1) { int i; xmlNodePtr node; for (i = 0; i < tmpset->nodeNr; i++) { node = tmpset->nodeTab[i]; if ((node != NULL) && (node->type == XML_NAMESPACE_DECL)) { xmlXPathNodeSetFreeNs((xmlNsPtr) node); } } } else if (tmpset->nodeNr == 1) { if ((tmpset->nodeTab[0] != NULL) && (tmpset->nodeTab[0]->type == XML_NAMESPACE_DECL)) xmlXPathNodeSetFreeNs((xmlNsPtr) tmpset->nodeTab[0]); } tmpset->nodeNr = 0; memset(obj, 0, sizeof(xmlXPathObject)); obj->nodesetval = tmpset; } else memset(obj, 0, sizeof(xmlXPathObject)); return; free_obj: /* * Cache is full; free the object. */ if (obj->nodesetval != NULL) xmlXPathFreeNodeSet(obj->nodesetval); #ifdef XP_DEBUG_OBJ_USAGE xmlXPathDebugObjUsageReleased(NULL, obj->type); #endif xmlFree(obj); } return; } /************************************************************************ * * * Type Casting Routines * * * ************************************************************************/ /** * xmlXPathCastBooleanToString: * @val: a boolean * * Converts a boolean to its string value. * * Returns a newly allocated string. */ xmlChar * xmlXPathCastBooleanToString (int val) { xmlChar *ret; if (val) ret = xmlStrdup((const xmlChar *) "true"); else ret = xmlStrdup((const xmlChar *) "false"); return(ret); } /** * xmlXPathCastNumberToString: * @val: a number * * Converts a number to its string value. * * Returns a newly allocated string. */ xmlChar * xmlXPathCastNumberToString (double val) { xmlChar *ret; switch (xmlXPathIsInf(val)) { case 1: ret = xmlStrdup((const xmlChar *) "Infinity"); break; case -1: ret = xmlStrdup((const xmlChar *) "-Infinity"); break; default: if (xmlXPathIsNaN(val)) { ret = xmlStrdup((const xmlChar *) "NaN"); } else if (val == 0 && xmlXPathGetSign(val) != 0) { ret = xmlStrdup((const xmlChar *) "0"); } else { /* could be improved */ char buf[100]; xmlXPathFormatNumber(val, buf, 99); buf[99] = 0; ret = xmlStrdup((const xmlChar *) buf); } } return(ret); } /** * xmlXPathCastNodeToString: * @node: a node * * Converts a node to its string value. * * Returns a newly allocated string. */ xmlChar * xmlXPathCastNodeToString (xmlNodePtr node) { return(xmlNodeGetContent(node)); } /** * xmlXPathCastNodeSetToString: * @ns: a node-set * * Converts a node-set to its string value. * * Returns a newly allocated string. */ xmlChar * xmlXPathCastNodeSetToString (xmlNodeSetPtr ns) { if ((ns == NULL) || (ns->nodeNr == 0) || (ns->nodeTab == NULL)) return(xmlStrdup((const xmlChar *) "")); if (ns->nodeNr > 1) xmlXPathNodeSetSort(ns); return(xmlXPathCastNodeToString(ns->nodeTab[0])); } /** * xmlXPathCastToString: * @val: an XPath object * * Converts an existing object to its string() equivalent * * Returns the allocated string value of the object, NULL in case of error. * It's up to the caller to free the string memory with xmlFree(). */ xmlChar * xmlXPathCastToString(xmlXPathObjectPtr val) { xmlChar *ret = NULL; if (val == NULL) return(xmlStrdup((const xmlChar *) "")); switch (val->type) { case XPATH_UNDEFINED: #ifdef DEBUG_EXPR xmlGenericError(xmlGenericErrorContext, "String: undefined\n"); #endif ret = xmlStrdup((const xmlChar *) ""); break; case XPATH_NODESET: case XPATH_XSLT_TREE: ret = xmlXPathCastNodeSetToString(val->nodesetval); break; case XPATH_STRING: return(xmlStrdup(val->stringval)); case XPATH_BOOLEAN: ret = xmlXPathCastBooleanToString(val->boolval); break; case XPATH_NUMBER: { ret = xmlXPathCastNumberToString(val->floatval); break; } case XPATH_USERS: case XPATH_POINT: case XPATH_RANGE: case XPATH_LOCATIONSET: TODO ret = xmlStrdup((const xmlChar *) ""); break; } return(ret); } /** * xmlXPathConvertString: * @val: an XPath object * * Converts an existing object to its string() equivalent * * Returns the new object, the old one is freed (or the operation * is done directly on @val) */ xmlXPathObjectPtr xmlXPathConvertString(xmlXPathObjectPtr val) { xmlChar *res = NULL; if (val == NULL) return(xmlXPathNewCString("")); switch (val->type) { case XPATH_UNDEFINED: #ifdef DEBUG_EXPR xmlGenericError(xmlGenericErrorContext, "STRING: undefined\n"); #endif break; case XPATH_NODESET: case XPATH_XSLT_TREE: res = xmlXPathCastNodeSetToString(val->nodesetval); break; case XPATH_STRING: return(val); case XPATH_BOOLEAN: res = xmlXPathCastBooleanToString(val->boolval); break; case XPATH_NUMBER: res = xmlXPathCastNumberToString(val->floatval); break; case XPATH_USERS: case XPATH_POINT: case XPATH_RANGE: case XPATH_LOCATIONSET: TODO; break; } xmlXPathFreeObject(val); if (res == NULL) return(xmlXPathNewCString("")); return(xmlXPathWrapString(res)); } /** * xmlXPathCastBooleanToNumber: * @val: a boolean * * Converts a boolean to its number value * * Returns the number value */ double xmlXPathCastBooleanToNumber(int val) { if (val) return(1.0); return(0.0); } /** * xmlXPathCastStringToNumber: * @val: a string * * Converts a string to its number value * * Returns the number value */ double xmlXPathCastStringToNumber(const xmlChar * val) { return(xmlXPathStringEvalNumber(val)); } /** * xmlXPathCastNodeToNumber: * @node: a node * * Converts a node to its number value * * Returns the number value */ double xmlXPathCastNodeToNumber (xmlNodePtr node) { xmlChar *strval; double ret; if (node == NULL) return(xmlXPathNAN); strval = xmlXPathCastNodeToString(node); if (strval == NULL) return(xmlXPathNAN); ret = xmlXPathCastStringToNumber(strval); xmlFree(strval); return(ret); } /** * xmlXPathCastNodeSetToNumber: * @ns: a node-set * * Converts a node-set to its number value * * Returns the number value */ double xmlXPathCastNodeSetToNumber (xmlNodeSetPtr ns) { xmlChar *str; double ret; if (ns == NULL) return(xmlXPathNAN); str = xmlXPathCastNodeSetToString(ns); ret = xmlXPathCastStringToNumber(str); xmlFree(str); return(ret); } /** * xmlXPathCastToNumber: * @val: an XPath object * * Converts an XPath object to its number value * * Returns the number value */ double xmlXPathCastToNumber(xmlXPathObjectPtr val) { double ret = 0.0; if (val == NULL) return(xmlXPathNAN); switch (val->type) { case XPATH_UNDEFINED: #ifdef DEGUB_EXPR xmlGenericError(xmlGenericErrorContext, "NUMBER: undefined\n"); #endif ret = xmlXPathNAN; break; case XPATH_NODESET: case XPATH_XSLT_TREE: ret = xmlXPathCastNodeSetToNumber(val->nodesetval); break; case XPATH_STRING: ret = xmlXPathCastStringToNumber(val->stringval); break; case XPATH_NUMBER: ret = val->floatval; break; case XPATH_BOOLEAN: ret = xmlXPathCastBooleanToNumber(val->boolval); break; case XPATH_USERS: case XPATH_POINT: case XPATH_RANGE: case XPATH_LOCATIONSET: TODO; ret = xmlXPathNAN; break; } return(ret); } /** * xmlXPathConvertNumber: * @val: an XPath object * * Converts an existing object to its number() equivalent * * Returns the new object, the old one is freed (or the operation * is done directly on @val) */ xmlXPathObjectPtr xmlXPathConvertNumber(xmlXPathObjectPtr val) { xmlXPathObjectPtr ret; if (val == NULL) return(xmlXPathNewFloat(0.0)); if (val->type == XPATH_NUMBER) return(val); ret = xmlXPathNewFloat(xmlXPathCastToNumber(val)); xmlXPathFreeObject(val); return(ret); } /** * xmlXPathCastNumberToBoolean: * @val: a number * * Converts a number to its boolean value * * Returns the boolean value */ int xmlXPathCastNumberToBoolean (double val) { if (xmlXPathIsNaN(val) || (val == 0.0)) return(0); return(1); } /** * xmlXPathCastStringToBoolean: * @val: a string * * Converts a string to its boolean value * * Returns the boolean value */ int xmlXPathCastStringToBoolean (const xmlChar *val) { if ((val == NULL) || (xmlStrlen(val) == 0)) return(0); return(1); } /** * xmlXPathCastNodeSetToBoolean: * @ns: a node-set * * Converts a node-set to its boolean value * * Returns the boolean value */ int xmlXPathCastNodeSetToBoolean (xmlNodeSetPtr ns) { if ((ns == NULL) || (ns->nodeNr == 0)) return(0); return(1); } /** * xmlXPathCastToBoolean: * @val: an XPath object * * Converts an XPath object to its boolean value * * Returns the boolean value */ int xmlXPathCastToBoolean (xmlXPathObjectPtr val) { int ret = 0; if (val == NULL) return(0); switch (val->type) { case XPATH_UNDEFINED: #ifdef DEBUG_EXPR xmlGenericError(xmlGenericErrorContext, "BOOLEAN: undefined\n"); #endif ret = 0; break; case XPATH_NODESET: case XPATH_XSLT_TREE: ret = xmlXPathCastNodeSetToBoolean(val->nodesetval); break; case XPATH_STRING: ret = xmlXPathCastStringToBoolean(val->stringval); break; case XPATH_NUMBER: ret = xmlXPathCastNumberToBoolean(val->floatval); break; case XPATH_BOOLEAN: ret = val->boolval; break; case XPATH_USERS: case XPATH_POINT: case XPATH_RANGE: case XPATH_LOCATIONSET: TODO; ret = 0; break; } return(ret); } /** * xmlXPathConvertBoolean: * @val: an XPath object * * Converts an existing object to its boolean() equivalent * * Returns the new object, the old one is freed (or the operation * is done directly on @val) */ xmlXPathObjectPtr xmlXPathConvertBoolean(xmlXPathObjectPtr val) { xmlXPathObjectPtr ret; if (val == NULL) return(xmlXPathNewBoolean(0)); if (val->type == XPATH_BOOLEAN) return(val); ret = xmlXPathNewBoolean(xmlXPathCastToBoolean(val)); xmlXPathFreeObject(val); return(ret); } /************************************************************************ * * * Routines to handle XPath contexts * * * ************************************************************************/ /** * xmlXPathNewContext: * @doc: the XML document * * Create a new xmlXPathContext * * Returns the xmlXPathContext just allocated. The caller will need to free it. */ xmlXPathContextPtr xmlXPathNewContext(xmlDocPtr doc) { xmlXPathContextPtr ret; ret = (xmlXPathContextPtr) xmlMalloc(sizeof(xmlXPathContext)); if (ret == NULL) { xmlXPathErrMemory(NULL, "creating context\n"); return(NULL); } memset(ret, 0 , (size_t) sizeof(xmlXPathContext)); ret->doc = doc; ret->node = NULL; ret->varHash = NULL; ret->nb_types = 0; ret->max_types = 0; ret->types = NULL; ret->funcHash = xmlHashCreate(0); ret->nb_axis = 0; ret->max_axis = 0; ret->axis = NULL; ret->nsHash = NULL; ret->user = NULL; ret->contextSize = -1; ret->proximityPosition = -1; #ifdef XP_DEFAULT_CACHE_ON if (xmlXPathContextSetCache(ret, 1, -1, 0) == -1) { xmlXPathFreeContext(ret); return(NULL); } #endif xmlXPathRegisterAllFunctions(ret); return(ret); } /** * xmlXPathFreeContext: * @ctxt: the context to free * * Free up an xmlXPathContext */ void xmlXPathFreeContext(xmlXPathContextPtr ctxt) { if (ctxt == NULL) return; if (ctxt->cache != NULL) xmlXPathFreeCache((xmlXPathContextCachePtr) ctxt->cache); xmlXPathRegisteredNsCleanup(ctxt); xmlXPathRegisteredFuncsCleanup(ctxt); xmlXPathRegisteredVariablesCleanup(ctxt); xmlResetError(&ctxt->lastError); xmlFree(ctxt); } /************************************************************************ * * * Routines to handle XPath parser contexts * * * ************************************************************************/ #define CHECK_CTXT(ctxt) \ if (ctxt == NULL) { \ __xmlRaiseError(NULL, NULL, NULL, \ NULL, NULL, XML_FROM_XPATH, \ XML_ERR_INTERNAL_ERROR, XML_ERR_FATAL, \ __FILE__, __LINE__, \ NULL, NULL, NULL, 0, 0, \ "NULL context pointer\n"); \ return(NULL); \ } \ #define CHECK_CTXT_NEG(ctxt) \ if (ctxt == NULL) { \ __xmlRaiseError(NULL, NULL, NULL, \ NULL, NULL, XML_FROM_XPATH, \ XML_ERR_INTERNAL_ERROR, XML_ERR_FATAL, \ __FILE__, __LINE__, \ NULL, NULL, NULL, 0, 0, \ "NULL context pointer\n"); \ return(-1); \ } \ #define CHECK_CONTEXT(ctxt) \ if ((ctxt == NULL) || (ctxt->doc == NULL) || \ (ctxt->doc->children == NULL)) { \ xmlXPatherror(ctxt, __FILE__, __LINE__, XPATH_INVALID_CTXT); \ return(NULL); \ } /** * xmlXPathNewParserContext: * @str: the XPath expression * @ctxt: the XPath context * * Create a new xmlXPathParserContext * * Returns the xmlXPathParserContext just allocated. */ xmlXPathParserContextPtr xmlXPathNewParserContext(const xmlChar *str, xmlXPathContextPtr ctxt) { xmlXPathParserContextPtr ret; ret = (xmlXPathParserContextPtr) xmlMalloc(sizeof(xmlXPathParserContext)); if (ret == NULL) { xmlXPathErrMemory(ctxt, "creating parser context\n"); return(NULL); } memset(ret, 0 , (size_t) sizeof(xmlXPathParserContext)); ret->cur = ret->base = str; ret->context = ctxt; ret->comp = xmlXPathNewCompExpr(); if (ret->comp == NULL) { xmlFree(ret->valueTab); xmlFree(ret); return(NULL); } if ((ctxt != NULL) && (ctxt->dict != NULL)) { ret->comp->dict = ctxt->dict; xmlDictReference(ret->comp->dict); } return(ret); } /** * xmlXPathCompParserContext: * @comp: the XPath compiled expression * @ctxt: the XPath context * * Create a new xmlXPathParserContext when processing a compiled expression * * Returns the xmlXPathParserContext just allocated. */ static xmlXPathParserContextPtr xmlXPathCompParserContext(xmlXPathCompExprPtr comp, xmlXPathContextPtr ctxt) { xmlXPathParserContextPtr ret; ret = (xmlXPathParserContextPtr) xmlMalloc(sizeof(xmlXPathParserContext)); if (ret == NULL) { xmlXPathErrMemory(ctxt, "creating evaluation context\n"); return(NULL); } memset(ret, 0 , (size_t) sizeof(xmlXPathParserContext)); /* Allocate the value stack */ ret->valueTab = (xmlXPathObjectPtr *) xmlMalloc(10 * sizeof(xmlXPathObjectPtr)); if (ret->valueTab == NULL) { xmlFree(ret); xmlXPathErrMemory(ctxt, "creating evaluation context\n"); return(NULL); } ret->valueNr = 0; ret->valueMax = 10; ret->value = NULL; ret->context = ctxt; ret->comp = comp; return(ret); } /** * xmlXPathFreeParserContext: * @ctxt: the context to free * * Free up an xmlXPathParserContext */ void xmlXPathFreeParserContext(xmlXPathParserContextPtr ctxt) { if (ctxt->valueTab != NULL) { xmlFree(ctxt->valueTab); } if (ctxt->comp != NULL) { #ifdef XPATH_STREAMING if (ctxt->comp->stream != NULL) { xmlFreePatternList(ctxt->comp->stream); ctxt->comp->stream = NULL; } #endif xmlXPathFreeCompExpr(ctxt->comp); } xmlFree(ctxt); } /************************************************************************ * * * The implicit core function library * * * ************************************************************************/ /** * xmlXPathNodeValHash: * @node: a node pointer * * Function computing the beginning of the string value of the node, * used to speed up comparisons * * Returns an int usable as a hash */ static unsigned int xmlXPathNodeValHash(xmlNodePtr node) { int len = 2; const xmlChar * string = NULL; xmlNodePtr tmp = NULL; unsigned int ret = 0; if (node == NULL) return(0); if (node->type == XML_DOCUMENT_NODE) { tmp = xmlDocGetRootElement((xmlDocPtr) node); if (tmp == NULL) node = node->children; else node = tmp; if (node == NULL) return(0); } switch (node->type) { case XML_COMMENT_NODE: case XML_PI_NODE: case XML_CDATA_SECTION_NODE: case XML_TEXT_NODE: string = node->content; if (string == NULL) return(0); if (string[0] == 0) return(0); return(((unsigned int) string[0]) + (((unsigned int) string[1]) << 8)); case XML_NAMESPACE_DECL: string = ((xmlNsPtr)node)->href; if (string == NULL) return(0); if (string[0] == 0) return(0); return(((unsigned int) string[0]) + (((unsigned int) string[1]) << 8)); case XML_ATTRIBUTE_NODE: tmp = ((xmlAttrPtr) node)->children; break; case XML_ELEMENT_NODE: tmp = node->children; break; default: return(0); } while (tmp != NULL) { switch (tmp->type) { case XML_COMMENT_NODE: case XML_PI_NODE: case XML_CDATA_SECTION_NODE: case XML_TEXT_NODE: string = tmp->content; break; case XML_NAMESPACE_DECL: string = ((xmlNsPtr)tmp)->href; break; default: break; } if ((string != NULL) && (string[0] != 0)) { if (len == 1) { return(ret + (((unsigned int) string[0]) << 8)); } if (string[1] == 0) { len = 1; ret = (unsigned int) string[0]; } else { return(((unsigned int) string[0]) + (((unsigned int) string[1]) << 8)); } } /* * Skip to next node */ if ((tmp->children != NULL) && (tmp->type != XML_DTD_NODE)) { if (tmp->children->type != XML_ENTITY_DECL) { tmp = tmp->children; continue; } } if (tmp == node) break; if (tmp->next != NULL) { tmp = tmp->next; continue; } do { tmp = tmp->parent; if (tmp == NULL) break; if (tmp == node) { tmp = NULL; break; } if (tmp->next != NULL) { tmp = tmp->next; break; } } while (tmp != NULL); } return(ret); } /** * xmlXPathStringHash: * @string: a string * * Function computing the beginning of the string value of the node, * used to speed up comparisons * * Returns an int usable as a hash */ static unsigned int xmlXPathStringHash(const xmlChar * string) { if (string == NULL) return((unsigned int) 0); if (string[0] == 0) return(0); return(((unsigned int) string[0]) + (((unsigned int) string[1]) << 8)); } /** * xmlXPathCompareNodeSetFloat: * @ctxt: the XPath Parser context * @inf: less than (1) or greater than (0) * @strict: is the comparison strict * @arg: the node set * @f: the value * * Implement the compare operation between a nodeset and a number * @ns < @val (1, 1, ... * @ns <= @val (1, 0, ... * @ns > @val (0, 1, ... * @ns >= @val (0, 0, ... * * If one object to be compared is a node-set and the other is a number, * then the comparison will be true if and only if there is a node in the * node-set such that the result of performing the comparison on the number * to be compared and on the result of converting the string-value of that * node to a number using the number function is true. * * Returns 0 or 1 depending on the results of the test. */ static int xmlXPathCompareNodeSetFloat(xmlXPathParserContextPtr ctxt, int inf, int strict, xmlXPathObjectPtr arg, xmlXPathObjectPtr f) { int i, ret = 0; xmlNodeSetPtr ns; xmlChar *str2; if ((f == NULL) || (arg == NULL) || ((arg->type != XPATH_NODESET) && (arg->type != XPATH_XSLT_TREE))) { xmlXPathReleaseObject(ctxt->context, arg); xmlXPathReleaseObject(ctxt->context, f); return(0); } ns = arg->nodesetval; if (ns != NULL) { for (i = 0;i < ns->nodeNr;i++) { str2 = xmlXPathCastNodeToString(ns->nodeTab[i]); if (str2 != NULL) { valuePush(ctxt, xmlXPathCacheNewString(ctxt->context, str2)); xmlFree(str2); xmlXPathNumberFunction(ctxt, 1); valuePush(ctxt, xmlXPathCacheObjectCopy(ctxt->context, f)); ret = xmlXPathCompareValues(ctxt, inf, strict); if (ret) break; } } } xmlXPathReleaseObject(ctxt->context, arg); xmlXPathReleaseObject(ctxt->context, f); return(ret); } /** * xmlXPathCompareNodeSetString: * @ctxt: the XPath Parser context * @inf: less than (1) or greater than (0) * @strict: is the comparison strict * @arg: the node set * @s: the value * * Implement the compare operation between a nodeset and a string * @ns < @val (1, 1, ... * @ns <= @val (1, 0, ... * @ns > @val (0, 1, ... * @ns >= @val (0, 0, ... * * If one object to be compared is a node-set and the other is a string, * then the comparison will be true if and only if there is a node in * the node-set such that the result of performing the comparison on the * string-value of the node and the other string is true. * * Returns 0 or 1 depending on the results of the test. */ static int xmlXPathCompareNodeSetString(xmlXPathParserContextPtr ctxt, int inf, int strict, xmlXPathObjectPtr arg, xmlXPathObjectPtr s) { int i, ret = 0; xmlNodeSetPtr ns; xmlChar *str2; if ((s == NULL) || (arg == NULL) || ((arg->type != XPATH_NODESET) && (arg->type != XPATH_XSLT_TREE))) { xmlXPathReleaseObject(ctxt->context, arg); xmlXPathReleaseObject(ctxt->context, s); return(0); } ns = arg->nodesetval; if (ns != NULL) { for (i = 0;i < ns->nodeNr;i++) { str2 = xmlXPathCastNodeToString(ns->nodeTab[i]); if (str2 != NULL) { valuePush(ctxt, xmlXPathCacheNewString(ctxt->context, str2)); xmlFree(str2); valuePush(ctxt, xmlXPathCacheObjectCopy(ctxt->context, s)); ret = xmlXPathCompareValues(ctxt, inf, strict); if (ret) break; } } } xmlXPathReleaseObject(ctxt->context, arg); xmlXPathReleaseObject(ctxt->context, s); return(ret); } /** * xmlXPathCompareNodeSets: * @inf: less than (1) or greater than (0) * @strict: is the comparison strict * @arg1: the first node set object * @arg2: the second node set object * * Implement the compare operation on nodesets: * * If both objects to be compared are node-sets, then the comparison * will be true if and only if there is a node in the first node-set * and a node in the second node-set such that the result of performing * the comparison on the string-values of the two nodes is true. * .... * When neither object to be compared is a node-set and the operator * is <=, <, >= or >, then the objects are compared by converting both * objects to numbers and comparing the numbers according to IEEE 754. * .... * The number function converts its argument to a number as follows: * - a string that consists of optional whitespace followed by an * optional minus sign followed by a Number followed by whitespace * is converted to the IEEE 754 number that is nearest (according * to the IEEE 754 round-to-nearest rule) to the mathematical value * represented by the string; any other string is converted to NaN * * Conclusion all nodes need to be converted first to their string value * and then the comparison must be done when possible */ static int xmlXPathCompareNodeSets(int inf, int strict, xmlXPathObjectPtr arg1, xmlXPathObjectPtr arg2) { int i, j, init = 0; double val1; double *values2; int ret = 0; xmlNodeSetPtr ns1; xmlNodeSetPtr ns2; if ((arg1 == NULL) || ((arg1->type != XPATH_NODESET) && (arg1->type != XPATH_XSLT_TREE))) { xmlXPathFreeObject(arg2); return(0); } if ((arg2 == NULL) || ((arg2->type != XPATH_NODESET) && (arg2->type != XPATH_XSLT_TREE))) { xmlXPathFreeObject(arg1); xmlXPathFreeObject(arg2); return(0); } ns1 = arg1->nodesetval; ns2 = arg2->nodesetval; if ((ns1 == NULL) || (ns1->nodeNr <= 0)) { xmlXPathFreeObject(arg1); xmlXPathFreeObject(arg2); return(0); } if ((ns2 == NULL) || (ns2->nodeNr <= 0)) { xmlXPathFreeObject(arg1); xmlXPathFreeObject(arg2); return(0); } values2 = (double *) xmlMalloc(ns2->nodeNr * sizeof(double)); if (values2 == NULL) { xmlXPathErrMemory(NULL, "comparing nodesets\n"); xmlXPathFreeObject(arg1); xmlXPathFreeObject(arg2); return(0); } for (i = 0;i < ns1->nodeNr;i++) { val1 = xmlXPathCastNodeToNumber(ns1->nodeTab[i]); if (xmlXPathIsNaN(val1)) continue; for (j = 0;j < ns2->nodeNr;j++) { if (init == 0) { values2[j] = xmlXPathCastNodeToNumber(ns2->nodeTab[j]); } if (xmlXPathIsNaN(values2[j])) continue; if (inf && strict) ret = (val1 < values2[j]); else if (inf && !strict) ret = (val1 <= values2[j]); else if (!inf && strict) ret = (val1 > values2[j]); else if (!inf && !strict) ret = (val1 >= values2[j]); if (ret) break; } if (ret) break; init = 1; } xmlFree(values2); xmlXPathFreeObject(arg1); xmlXPathFreeObject(arg2); return(ret); } /** * xmlXPathCompareNodeSetValue: * @ctxt: the XPath Parser context * @inf: less than (1) or greater than (0) * @strict: is the comparison strict * @arg: the node set * @val: the value * * Implement the compare operation between a nodeset and a value * @ns < @val (1, 1, ... * @ns <= @val (1, 0, ... * @ns > @val (0, 1, ... * @ns >= @val (0, 0, ... * * If one object to be compared is a node-set and the other is a boolean, * then the comparison will be true if and only if the result of performing * the comparison on the boolean and on the result of converting * the node-set to a boolean using the boolean function is true. * * Returns 0 or 1 depending on the results of the test. */ static int xmlXPathCompareNodeSetValue(xmlXPathParserContextPtr ctxt, int inf, int strict, xmlXPathObjectPtr arg, xmlXPathObjectPtr val) { if ((val == NULL) || (arg == NULL) || ((arg->type != XPATH_NODESET) && (arg->type != XPATH_XSLT_TREE))) return(0); switch(val->type) { case XPATH_NUMBER: return(xmlXPathCompareNodeSetFloat(ctxt, inf, strict, arg, val)); case XPATH_NODESET: case XPATH_XSLT_TREE: return(xmlXPathCompareNodeSets(inf, strict, arg, val)); case XPATH_STRING: return(xmlXPathCompareNodeSetString(ctxt, inf, strict, arg, val)); case XPATH_BOOLEAN: valuePush(ctxt, arg); xmlXPathBooleanFunction(ctxt, 1); valuePush(ctxt, val); return(xmlXPathCompareValues(ctxt, inf, strict)); default: TODO } return(0); } /** * xmlXPathEqualNodeSetString: * @arg: the nodeset object argument * @str: the string to compare to. * @neq: flag to show whether for '=' (0) or '!=' (1) * * Implement the equal operation on XPath objects content: @arg1 == @arg2 * If one object to be compared is a node-set and the other is a string, * then the comparison will be true if and only if there is a node in * the node-set such that the result of performing the comparison on the * string-value of the node and the other string is true. * * Returns 0 or 1 depending on the results of the test. */ static int xmlXPathEqualNodeSetString(xmlXPathObjectPtr arg, const xmlChar * str, int neq) { int i; xmlNodeSetPtr ns; xmlChar *str2; unsigned int hash; if ((str == NULL) || (arg == NULL) || ((arg->type != XPATH_NODESET) && (arg->type != XPATH_XSLT_TREE))) return (0); ns = arg->nodesetval; /* * A NULL nodeset compared with a string is always false * (since there is no node equal, and no node not equal) */ if ((ns == NULL) || (ns->nodeNr <= 0) ) return (0); hash = xmlXPathStringHash(str); for (i = 0; i < ns->nodeNr; i++) { if (xmlXPathNodeValHash(ns->nodeTab[i]) == hash) { str2 = xmlNodeGetContent(ns->nodeTab[i]); if ((str2 != NULL) && (xmlStrEqual(str, str2))) { xmlFree(str2); if (neq) continue; return (1); } else if ((str2 == NULL) && (xmlStrEqual(str, BAD_CAST ""))) { if (neq) continue; return (1); } else if (neq) { if (str2 != NULL) xmlFree(str2); return (1); } if (str2 != NULL) xmlFree(str2); } else if (neq) return (1); } return (0); } /** * xmlXPathEqualNodeSetFloat: * @arg: the nodeset object argument * @f: the float to compare to * @neq: flag to show whether to compare '=' (0) or '!=' (1) * * Implement the equal operation on XPath objects content: @arg1 == @arg2 * If one object to be compared is a node-set and the other is a number, * then the comparison will be true if and only if there is a node in * the node-set such that the result of performing the comparison on the * number to be compared and on the result of converting the string-value * of that node to a number using the number function is true. * * Returns 0 or 1 depending on the results of the test. */ static int xmlXPathEqualNodeSetFloat(xmlXPathParserContextPtr ctxt, xmlXPathObjectPtr arg, double f, int neq) { int i, ret=0; xmlNodeSetPtr ns; xmlChar *str2; xmlXPathObjectPtr val; double v; if ((arg == NULL) || ((arg->type != XPATH_NODESET) && (arg->type != XPATH_XSLT_TREE))) return(0); ns = arg->nodesetval; if (ns != NULL) { for (i=0;inodeNr;i++) { str2 = xmlXPathCastNodeToString(ns->nodeTab[i]); if (str2 != NULL) { valuePush(ctxt, xmlXPathCacheNewString(ctxt->context, str2)); xmlFree(str2); xmlXPathNumberFunction(ctxt, 1); val = valuePop(ctxt); v = val->floatval; xmlXPathReleaseObject(ctxt->context, val); if (!xmlXPathIsNaN(v)) { if ((!neq) && (v==f)) { ret = 1; break; } else if ((neq) && (v!=f)) { ret = 1; break; } } else { /* NaN is unequal to any value */ if (neq) ret = 1; } } } } return(ret); } /** * xmlXPathEqualNodeSets: * @arg1: first nodeset object argument * @arg2: second nodeset object argument * @neq: flag to show whether to test '=' (0) or '!=' (1) * * Implement the equal / not equal operation on XPath nodesets: * @arg1 == @arg2 or @arg1 != @arg2 * If both objects to be compared are node-sets, then the comparison * will be true if and only if there is a node in the first node-set and * a node in the second node-set such that the result of performing the * comparison on the string-values of the two nodes is true. * * (needless to say, this is a costly operation) * * Returns 0 or 1 depending on the results of the test. */ static int xmlXPathEqualNodeSets(xmlXPathObjectPtr arg1, xmlXPathObjectPtr arg2, int neq) { int i, j; unsigned int *hashs1; unsigned int *hashs2; xmlChar **values1; xmlChar **values2; int ret = 0; xmlNodeSetPtr ns1; xmlNodeSetPtr ns2; if ((arg1 == NULL) || ((arg1->type != XPATH_NODESET) && (arg1->type != XPATH_XSLT_TREE))) return(0); if ((arg2 == NULL) || ((arg2->type != XPATH_NODESET) && (arg2->type != XPATH_XSLT_TREE))) return(0); ns1 = arg1->nodesetval; ns2 = arg2->nodesetval; if ((ns1 == NULL) || (ns1->nodeNr <= 0)) return(0); if ((ns2 == NULL) || (ns2->nodeNr <= 0)) return(0); /* * for equal, check if there is a node pertaining to both sets */ if (neq == 0) for (i = 0;i < ns1->nodeNr;i++) for (j = 0;j < ns2->nodeNr;j++) if (ns1->nodeTab[i] == ns2->nodeTab[j]) return(1); values1 = (xmlChar **) xmlMalloc(ns1->nodeNr * sizeof(xmlChar *)); if (values1 == NULL) { xmlXPathErrMemory(NULL, "comparing nodesets\n"); return(0); } hashs1 = (unsigned int *) xmlMalloc(ns1->nodeNr * sizeof(unsigned int)); if (hashs1 == NULL) { xmlXPathErrMemory(NULL, "comparing nodesets\n"); xmlFree(values1); return(0); } memset(values1, 0, ns1->nodeNr * sizeof(xmlChar *)); values2 = (xmlChar **) xmlMalloc(ns2->nodeNr * sizeof(xmlChar *)); if (values2 == NULL) { xmlXPathErrMemory(NULL, "comparing nodesets\n"); xmlFree(hashs1); xmlFree(values1); return(0); } hashs2 = (unsigned int *) xmlMalloc(ns2->nodeNr * sizeof(unsigned int)); if (hashs2 == NULL) { xmlXPathErrMemory(NULL, "comparing nodesets\n"); xmlFree(hashs1); xmlFree(values1); xmlFree(values2); return(0); } memset(values2, 0, ns2->nodeNr * sizeof(xmlChar *)); for (i = 0;i < ns1->nodeNr;i++) { hashs1[i] = xmlXPathNodeValHash(ns1->nodeTab[i]); for (j = 0;j < ns2->nodeNr;j++) { if (i == 0) hashs2[j] = xmlXPathNodeValHash(ns2->nodeTab[j]); if (hashs1[i] != hashs2[j]) { if (neq) { ret = 1; break; } } else { if (values1[i] == NULL) values1[i] = xmlNodeGetContent(ns1->nodeTab[i]); if (values2[j] == NULL) values2[j] = xmlNodeGetContent(ns2->nodeTab[j]); ret = xmlStrEqual(values1[i], values2[j]) ^ neq; if (ret) break; } } if (ret) break; } for (i = 0;i < ns1->nodeNr;i++) if (values1[i] != NULL) xmlFree(values1[i]); for (j = 0;j < ns2->nodeNr;j++) if (values2[j] != NULL) xmlFree(values2[j]); xmlFree(values1); xmlFree(values2); xmlFree(hashs1); xmlFree(hashs2); return(ret); } static int xmlXPathEqualValuesCommon(xmlXPathParserContextPtr ctxt, xmlXPathObjectPtr arg1, xmlXPathObjectPtr arg2) { int ret = 0; /* *At this point we are assured neither arg1 nor arg2 *is a nodeset, so we can just pick the appropriate routine. */ switch (arg1->type) { case XPATH_UNDEFINED: #ifdef DEBUG_EXPR xmlGenericError(xmlGenericErrorContext, "Equal: undefined\n"); #endif break; case XPATH_BOOLEAN: switch (arg2->type) { case XPATH_UNDEFINED: #ifdef DEBUG_EXPR xmlGenericError(xmlGenericErrorContext, "Equal: undefined\n"); #endif break; case XPATH_BOOLEAN: #ifdef DEBUG_EXPR xmlGenericError(xmlGenericErrorContext, "Equal: %d boolean %d \n", arg1->boolval, arg2->boolval); #endif ret = (arg1->boolval == arg2->boolval); break; case XPATH_NUMBER: ret = (arg1->boolval == xmlXPathCastNumberToBoolean(arg2->floatval)); break; case XPATH_STRING: if ((arg2->stringval == NULL) || (arg2->stringval[0] == 0)) ret = 0; else ret = 1; ret = (arg1->boolval == ret); break; case XPATH_USERS: case XPATH_POINT: case XPATH_RANGE: case XPATH_LOCATIONSET: TODO break; case XPATH_NODESET: case XPATH_XSLT_TREE: break; } break; case XPATH_NUMBER: switch (arg2->type) { case XPATH_UNDEFINED: #ifdef DEBUG_EXPR xmlGenericError(xmlGenericErrorContext, "Equal: undefined\n"); #endif break; case XPATH_BOOLEAN: ret = (arg2->boolval== xmlXPathCastNumberToBoolean(arg1->floatval)); break; case XPATH_STRING: valuePush(ctxt, arg2); xmlXPathNumberFunction(ctxt, 1); arg2 = valuePop(ctxt); /* no break on purpose */ case XPATH_NUMBER: /* Hand check NaN and Infinity equalities */ if (xmlXPathIsNaN(arg1->floatval) || xmlXPathIsNaN(arg2->floatval)) { ret = 0; } else if (xmlXPathIsInf(arg1->floatval) == 1) { if (xmlXPathIsInf(arg2->floatval) == 1) ret = 1; else ret = 0; } else if (xmlXPathIsInf(arg1->floatval) == -1) { if (xmlXPathIsInf(arg2->floatval) == -1) ret = 1; else ret = 0; } else if (xmlXPathIsInf(arg2->floatval) == 1) { if (xmlXPathIsInf(arg1->floatval) == 1) ret = 1; else ret = 0; } else if (xmlXPathIsInf(arg2->floatval) == -1) { if (xmlXPathIsInf(arg1->floatval) == -1) ret = 1; else ret = 0; } else { ret = (arg1->floatval == arg2->floatval); } break; case XPATH_USERS: case XPATH_POINT: case XPATH_RANGE: case XPATH_LOCATIONSET: TODO break; case XPATH_NODESET: case XPATH_XSLT_TREE: break; } break; case XPATH_STRING: switch (arg2->type) { case XPATH_UNDEFINED: #ifdef DEBUG_EXPR xmlGenericError(xmlGenericErrorContext, "Equal: undefined\n"); #endif break; case XPATH_BOOLEAN: if ((arg1->stringval == NULL) || (arg1->stringval[0] == 0)) ret = 0; else ret = 1; ret = (arg2->boolval == ret); break; case XPATH_STRING: ret = xmlStrEqual(arg1->stringval, arg2->stringval); break; case XPATH_NUMBER: valuePush(ctxt, arg1); xmlXPathNumberFunction(ctxt, 1); arg1 = valuePop(ctxt); /* Hand check NaN and Infinity equalities */ if (xmlXPathIsNaN(arg1->floatval) || xmlXPathIsNaN(arg2->floatval)) { ret = 0; } else if (xmlXPathIsInf(arg1->floatval) == 1) { if (xmlXPathIsInf(arg2->floatval) == 1) ret = 1; else ret = 0; } else if (xmlXPathIsInf(arg1->floatval) == -1) { if (xmlXPathIsInf(arg2->floatval) == -1) ret = 1; else ret = 0; } else if (xmlXPathIsInf(arg2->floatval) == 1) { if (xmlXPathIsInf(arg1->floatval) == 1) ret = 1; else ret = 0; } else if (xmlXPathIsInf(arg2->floatval) == -1) { if (xmlXPathIsInf(arg1->floatval) == -1) ret = 1; else ret = 0; } else { ret = (arg1->floatval == arg2->floatval); } break; case XPATH_USERS: case XPATH_POINT: case XPATH_RANGE: case XPATH_LOCATIONSET: TODO break; case XPATH_NODESET: case XPATH_XSLT_TREE: break; } break; case XPATH_USERS: case XPATH_POINT: case XPATH_RANGE: case XPATH_LOCATIONSET: TODO break; case XPATH_NODESET: case XPATH_XSLT_TREE: break; } xmlXPathReleaseObject(ctxt->context, arg1); xmlXPathReleaseObject(ctxt->context, arg2); return(ret); } /** * xmlXPathEqualValues: * @ctxt: the XPath Parser context * * Implement the equal operation on XPath objects content: @arg1 == @arg2 * * Returns 0 or 1 depending on the results of the test. */ int xmlXPathEqualValues(xmlXPathParserContextPtr ctxt) { xmlXPathObjectPtr arg1, arg2, argtmp; int ret = 0; if ((ctxt == NULL) || (ctxt->context == NULL)) return(0); arg2 = valuePop(ctxt); arg1 = valuePop(ctxt); if ((arg1 == NULL) || (arg2 == NULL)) { if (arg1 != NULL) xmlXPathReleaseObject(ctxt->context, arg1); else xmlXPathReleaseObject(ctxt->context, arg2); XP_ERROR0(XPATH_INVALID_OPERAND); } if (arg1 == arg2) { #ifdef DEBUG_EXPR xmlGenericError(xmlGenericErrorContext, "Equal: by pointer\n"); #endif xmlXPathFreeObject(arg1); return(1); } /* *If either argument is a nodeset, it's a 'special case' */ if ((arg2->type == XPATH_NODESET) || (arg2->type == XPATH_XSLT_TREE) || (arg1->type == XPATH_NODESET) || (arg1->type == XPATH_XSLT_TREE)) { /* *Hack it to assure arg1 is the nodeset */ if ((arg1->type != XPATH_NODESET) && (arg1->type != XPATH_XSLT_TREE)) { argtmp = arg2; arg2 = arg1; arg1 = argtmp; } switch (arg2->type) { case XPATH_UNDEFINED: #ifdef DEBUG_EXPR xmlGenericError(xmlGenericErrorContext, "Equal: undefined\n"); #endif break; case XPATH_NODESET: case XPATH_XSLT_TREE: ret = xmlXPathEqualNodeSets(arg1, arg2, 0); break; case XPATH_BOOLEAN: if ((arg1->nodesetval == NULL) || (arg1->nodesetval->nodeNr == 0)) ret = 0; else ret = 1; ret = (ret == arg2->boolval); break; case XPATH_NUMBER: ret = xmlXPathEqualNodeSetFloat(ctxt, arg1, arg2->floatval, 0); break; case XPATH_STRING: ret = xmlXPathEqualNodeSetString(arg1, arg2->stringval, 0); break; case XPATH_USERS: case XPATH_POINT: case XPATH_RANGE: case XPATH_LOCATIONSET: TODO break; } xmlXPathReleaseObject(ctxt->context, arg1); xmlXPathReleaseObject(ctxt->context, arg2); return(ret); } return (xmlXPathEqualValuesCommon(ctxt, arg1, arg2)); } /** * xmlXPathNotEqualValues: * @ctxt: the XPath Parser context * * Implement the equal operation on XPath objects content: @arg1 == @arg2 * * Returns 0 or 1 depending on the results of the test. */ int xmlXPathNotEqualValues(xmlXPathParserContextPtr ctxt) { xmlXPathObjectPtr arg1, arg2, argtmp; int ret = 0; if ((ctxt == NULL) || (ctxt->context == NULL)) return(0); arg2 = valuePop(ctxt); arg1 = valuePop(ctxt); if ((arg1 == NULL) || (arg2 == NULL)) { if (arg1 != NULL) xmlXPathReleaseObject(ctxt->context, arg1); else xmlXPathReleaseObject(ctxt->context, arg2); XP_ERROR0(XPATH_INVALID_OPERAND); } if (arg1 == arg2) { #ifdef DEBUG_EXPR xmlGenericError(xmlGenericErrorContext, "NotEqual: by pointer\n"); #endif xmlXPathReleaseObject(ctxt->context, arg1); return(0); } /* *If either argument is a nodeset, it's a 'special case' */ if ((arg2->type == XPATH_NODESET) || (arg2->type == XPATH_XSLT_TREE) || (arg1->type == XPATH_NODESET) || (arg1->type == XPATH_XSLT_TREE)) { /* *Hack it to assure arg1 is the nodeset */ if ((arg1->type != XPATH_NODESET) && (arg1->type != XPATH_XSLT_TREE)) { argtmp = arg2; arg2 = arg1; arg1 = argtmp; } switch (arg2->type) { case XPATH_UNDEFINED: #ifdef DEBUG_EXPR xmlGenericError(xmlGenericErrorContext, "NotEqual: undefined\n"); #endif break; case XPATH_NODESET: case XPATH_XSLT_TREE: ret = xmlXPathEqualNodeSets(arg1, arg2, 1); break; case XPATH_BOOLEAN: if ((arg1->nodesetval == NULL) || (arg1->nodesetval->nodeNr == 0)) ret = 0; else ret = 1; ret = (ret != arg2->boolval); break; case XPATH_NUMBER: ret = xmlXPathEqualNodeSetFloat(ctxt, arg1, arg2->floatval, 1); break; case XPATH_STRING: ret = xmlXPathEqualNodeSetString(arg1, arg2->stringval,1); break; case XPATH_USERS: case XPATH_POINT: case XPATH_RANGE: case XPATH_LOCATIONSET: TODO break; } xmlXPathReleaseObject(ctxt->context, arg1); xmlXPathReleaseObject(ctxt->context, arg2); return(ret); } return (!xmlXPathEqualValuesCommon(ctxt, arg1, arg2)); } /** * xmlXPathCompareValues: * @ctxt: the XPath Parser context * @inf: less than (1) or greater than (0) * @strict: is the comparison strict * * Implement the compare operation on XPath objects: * @arg1 < @arg2 (1, 1, ... * @arg1 <= @arg2 (1, 0, ... * @arg1 > @arg2 (0, 1, ... * @arg1 >= @arg2 (0, 0, ... * * When neither object to be compared is a node-set and the operator is * <=, <, >=, >, then the objects are compared by converted both objects * to numbers and comparing the numbers according to IEEE 754. The < * comparison will be true if and only if the first number is less than the * second number. The <= comparison will be true if and only if the first * number is less than or equal to the second number. The > comparison * will be true if and only if the first number is greater than the second * number. The >= comparison will be true if and only if the first number * is greater than or equal to the second number. * * Returns 1 if the comparison succeeded, 0 if it failed */ int xmlXPathCompareValues(xmlXPathParserContextPtr ctxt, int inf, int strict) { int ret = 0, arg1i = 0, arg2i = 0; xmlXPathObjectPtr arg1, arg2; if ((ctxt == NULL) || (ctxt->context == NULL)) return(0); arg2 = valuePop(ctxt); arg1 = valuePop(ctxt); if ((arg1 == NULL) || (arg2 == NULL)) { if (arg1 != NULL) xmlXPathReleaseObject(ctxt->context, arg1); else xmlXPathReleaseObject(ctxt->context, arg2); XP_ERROR0(XPATH_INVALID_OPERAND); } if ((arg2->type == XPATH_NODESET) || (arg2->type == XPATH_XSLT_TREE) || (arg1->type == XPATH_NODESET) || (arg1->type == XPATH_XSLT_TREE)) { /* * If either argument is a XPATH_NODESET or XPATH_XSLT_TREE the two arguments * are not freed from within this routine; they will be freed from the * called routine, e.g. xmlXPathCompareNodeSets or xmlXPathCompareNodeSetValue */ if (((arg2->type == XPATH_NODESET) || (arg2->type == XPATH_XSLT_TREE)) && ((arg1->type == XPATH_NODESET) || (arg1->type == XPATH_XSLT_TREE))){ ret = xmlXPathCompareNodeSets(inf, strict, arg1, arg2); } else { if ((arg1->type == XPATH_NODESET) || (arg1->type == XPATH_XSLT_TREE)) { ret = xmlXPathCompareNodeSetValue(ctxt, inf, strict, arg1, arg2); } else { ret = xmlXPathCompareNodeSetValue(ctxt, !inf, strict, arg2, arg1); } } return(ret); } if (arg1->type != XPATH_NUMBER) { valuePush(ctxt, arg1); xmlXPathNumberFunction(ctxt, 1); arg1 = valuePop(ctxt); } if (arg1->type != XPATH_NUMBER) { xmlXPathFreeObject(arg1); xmlXPathFreeObject(arg2); XP_ERROR0(XPATH_INVALID_OPERAND); } if (arg2->type != XPATH_NUMBER) { valuePush(ctxt, arg2); xmlXPathNumberFunction(ctxt, 1); arg2 = valuePop(ctxt); } if (arg2->type != XPATH_NUMBER) { xmlXPathReleaseObject(ctxt->context, arg1); xmlXPathReleaseObject(ctxt->context, arg2); XP_ERROR0(XPATH_INVALID_OPERAND); } /* * Add tests for infinity and nan * => feedback on 3.4 for Inf and NaN */ /* Hand check NaN and Infinity comparisons */ if (xmlXPathIsNaN(arg1->floatval) || xmlXPathIsNaN(arg2->floatval)) { ret=0; } else { arg1i=xmlXPathIsInf(arg1->floatval); arg2i=xmlXPathIsInf(arg2->floatval); if (inf && strict) { if ((arg1i == -1 && arg2i != -1) || (arg2i == 1 && arg1i != 1)) { ret = 1; } else if (arg1i == 0 && arg2i == 0) { ret = (arg1->floatval < arg2->floatval); } else { ret = 0; } } else if (inf && !strict) { if (arg1i == -1 || arg2i == 1) { ret = 1; } else if (arg1i == 0 && arg2i == 0) { ret = (arg1->floatval <= arg2->floatval); } else { ret = 0; } } else if (!inf && strict) { if ((arg1i == 1 && arg2i != 1) || (arg2i == -1 && arg1i != -1)) { ret = 1; } else if (arg1i == 0 && arg2i == 0) { ret = (arg1->floatval > arg2->floatval); } else { ret = 0; } } else if (!inf && !strict) { if (arg1i == 1 || arg2i == -1) { ret = 1; } else if (arg1i == 0 && arg2i == 0) { ret = (arg1->floatval >= arg2->floatval); } else { ret = 0; } } } xmlXPathReleaseObject(ctxt->context, arg1); xmlXPathReleaseObject(ctxt->context, arg2); return(ret); } /** * xmlXPathValueFlipSign: * @ctxt: the XPath Parser context * * Implement the unary - operation on an XPath object * The numeric operators convert their operands to numbers as if * by calling the number function. */ void xmlXPathValueFlipSign(xmlXPathParserContextPtr ctxt) { if ((ctxt == NULL) || (ctxt->context == NULL)) return; CAST_TO_NUMBER; CHECK_TYPE(XPATH_NUMBER); if (xmlXPathIsNaN(ctxt->value->floatval)) ctxt->value->floatval=xmlXPathNAN; else if (xmlXPathIsInf(ctxt->value->floatval) == 1) ctxt->value->floatval=xmlXPathNINF; else if (xmlXPathIsInf(ctxt->value->floatval) == -1) ctxt->value->floatval=xmlXPathPINF; else if (ctxt->value->floatval == 0) { if (xmlXPathGetSign(ctxt->value->floatval) == 0) ctxt->value->floatval = xmlXPathNZERO; else ctxt->value->floatval = 0; } else ctxt->value->floatval = - ctxt->value->floatval; } /** * xmlXPathAddValues: * @ctxt: the XPath Parser context * * Implement the add operation on XPath objects: * The numeric operators convert their operands to numbers as if * by calling the number function. */ void xmlXPathAddValues(xmlXPathParserContextPtr ctxt) { xmlXPathObjectPtr arg; double val; arg = valuePop(ctxt); if (arg == NULL) XP_ERROR(XPATH_INVALID_OPERAND); val = xmlXPathCastToNumber(arg); xmlXPathReleaseObject(ctxt->context, arg); CAST_TO_NUMBER; CHECK_TYPE(XPATH_NUMBER); ctxt->value->floatval += val; } /** * xmlXPathSubValues: * @ctxt: the XPath Parser context * * Implement the subtraction operation on XPath objects: * The numeric operators convert their operands to numbers as if * by calling the number function. */ void xmlXPathSubValues(xmlXPathParserContextPtr ctxt) { xmlXPathObjectPtr arg; double val; arg = valuePop(ctxt); if (arg == NULL) XP_ERROR(XPATH_INVALID_OPERAND); val = xmlXPathCastToNumber(arg); xmlXPathReleaseObject(ctxt->context, arg); CAST_TO_NUMBER; CHECK_TYPE(XPATH_NUMBER); ctxt->value->floatval -= val; } /** * xmlXPathMultValues: * @ctxt: the XPath Parser context * * Implement the multiply operation on XPath objects: * The numeric operators convert their operands to numbers as if * by calling the number function. */ void xmlXPathMultValues(xmlXPathParserContextPtr ctxt) { xmlXPathObjectPtr arg; double val; arg = valuePop(ctxt); if (arg == NULL) XP_ERROR(XPATH_INVALID_OPERAND); val = xmlXPathCastToNumber(arg); xmlXPathReleaseObject(ctxt->context, arg); CAST_TO_NUMBER; CHECK_TYPE(XPATH_NUMBER); ctxt->value->floatval *= val; } /** * xmlXPathDivValues: * @ctxt: the XPath Parser context * * Implement the div operation on XPath objects @arg1 / @arg2: * The numeric operators convert their operands to numbers as if * by calling the number function. */ void xmlXPathDivValues(xmlXPathParserContextPtr ctxt) { xmlXPathObjectPtr arg; double val; arg = valuePop(ctxt); if (arg == NULL) XP_ERROR(XPATH_INVALID_OPERAND); val = xmlXPathCastToNumber(arg); xmlXPathReleaseObject(ctxt->context, arg); CAST_TO_NUMBER; CHECK_TYPE(XPATH_NUMBER); if (xmlXPathIsNaN(val) || xmlXPathIsNaN(ctxt->value->floatval)) ctxt->value->floatval = xmlXPathNAN; else if (val == 0 && xmlXPathGetSign(val) != 0) { if (ctxt->value->floatval == 0) ctxt->value->floatval = xmlXPathNAN; else if (ctxt->value->floatval > 0) ctxt->value->floatval = xmlXPathNINF; else if (ctxt->value->floatval < 0) ctxt->value->floatval = xmlXPathPINF; } else if (val == 0) { if (ctxt->value->floatval == 0) ctxt->value->floatval = xmlXPathNAN; else if (ctxt->value->floatval > 0) ctxt->value->floatval = xmlXPathPINF; else if (ctxt->value->floatval < 0) ctxt->value->floatval = xmlXPathNINF; } else ctxt->value->floatval /= val; } /** * xmlXPathModValues: * @ctxt: the XPath Parser context * * Implement the mod operation on XPath objects: @arg1 / @arg2 * The numeric operators convert their operands to numbers as if * by calling the number function. */ void xmlXPathModValues(xmlXPathParserContextPtr ctxt) { xmlXPathObjectPtr arg; double arg1, arg2; arg = valuePop(ctxt); if (arg == NULL) XP_ERROR(XPATH_INVALID_OPERAND); arg2 = xmlXPathCastToNumber(arg); xmlXPathReleaseObject(ctxt->context, arg); CAST_TO_NUMBER; CHECK_TYPE(XPATH_NUMBER); arg1 = ctxt->value->floatval; if (arg2 == 0) ctxt->value->floatval = xmlXPathNAN; else { ctxt->value->floatval = fmod(arg1, arg2); } } /************************************************************************ * * * The traversal functions * * * ************************************************************************/ /* * A traversal function enumerates nodes along an axis. * Initially it must be called with NULL, and it indicates * termination on the axis by returning NULL. */ typedef xmlNodePtr (*xmlXPathTraversalFunction) (xmlXPathParserContextPtr ctxt, xmlNodePtr cur); /* * xmlXPathTraversalFunctionExt: * A traversal function enumerates nodes along an axis. * Initially it must be called with NULL, and it indicates * termination on the axis by returning NULL. * The context node of the traversal is specified via @contextNode. */ typedef xmlNodePtr (*xmlXPathTraversalFunctionExt) (xmlNodePtr cur, xmlNodePtr contextNode); /* * xmlXPathNodeSetMergeFunction: * Used for merging node sets in xmlXPathCollectAndTest(). */ typedef xmlNodeSetPtr (*xmlXPathNodeSetMergeFunction) (xmlNodeSetPtr, xmlNodeSetPtr, int); /** * xmlXPathNextSelf: * @ctxt: the XPath Parser context * @cur: the current node in the traversal * * Traversal function for the "self" direction * The self axis contains just the context node itself * * Returns the next element following that axis */ xmlNodePtr xmlXPathNextSelf(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) { if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL); if (cur == NULL) return(ctxt->context->node); return(NULL); } /** * xmlXPathNextChild: * @ctxt: the XPath Parser context * @cur: the current node in the traversal * * Traversal function for the "child" direction * The child axis contains the children of the context node in document order. * * Returns the next element following that axis */ xmlNodePtr xmlXPathNextChild(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) { if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL); if (cur == NULL) { if (ctxt->context->node == NULL) return(NULL); switch (ctxt->context->node->type) { case XML_ELEMENT_NODE: case XML_TEXT_NODE: case XML_CDATA_SECTION_NODE: case XML_ENTITY_REF_NODE: case XML_ENTITY_NODE: case XML_PI_NODE: case XML_COMMENT_NODE: case XML_NOTATION_NODE: case XML_DTD_NODE: return(ctxt->context->node->children); case XML_DOCUMENT_NODE: case XML_DOCUMENT_TYPE_NODE: case XML_DOCUMENT_FRAG_NODE: case XML_HTML_DOCUMENT_NODE: #ifdef LIBXML_DOCB_ENABLED case XML_DOCB_DOCUMENT_NODE: #endif return(((xmlDocPtr) ctxt->context->node)->children); case XML_ELEMENT_DECL: case XML_ATTRIBUTE_DECL: case XML_ENTITY_DECL: case XML_ATTRIBUTE_NODE: case XML_NAMESPACE_DECL: case XML_XINCLUDE_START: case XML_XINCLUDE_END: return(NULL); } return(NULL); } if ((cur->type == XML_DOCUMENT_NODE) || (cur->type == XML_HTML_DOCUMENT_NODE)) return(NULL); return(cur->next); } /** * xmlXPathNextChildElement: * @ctxt: the XPath Parser context * @cur: the current node in the traversal * * Traversal function for the "child" direction and nodes of type element. * The child axis contains the children of the context node in document order. * * Returns the next element following that axis */ static xmlNodePtr xmlXPathNextChildElement(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) { if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL); if (cur == NULL) { cur = ctxt->context->node; if (cur == NULL) return(NULL); /* * Get the first element child. */ switch (cur->type) { case XML_ELEMENT_NODE: case XML_DOCUMENT_FRAG_NODE: case XML_ENTITY_REF_NODE: /* URGENT TODO: entify-refs as well? */ case XML_ENTITY_NODE: cur = cur->children; if (cur != NULL) { if (cur->type == XML_ELEMENT_NODE) return(cur); do { cur = cur->next; } while ((cur != NULL) && (cur->type != XML_ELEMENT_NODE)); return(cur); } return(NULL); case XML_DOCUMENT_NODE: case XML_HTML_DOCUMENT_NODE: #ifdef LIBXML_DOCB_ENABLED case XML_DOCB_DOCUMENT_NODE: #endif return(xmlDocGetRootElement((xmlDocPtr) cur)); default: return(NULL); } return(NULL); } /* * Get the next sibling element node. */ switch (cur->type) { case XML_ELEMENT_NODE: case XML_TEXT_NODE: case XML_ENTITY_REF_NODE: case XML_ENTITY_NODE: case XML_CDATA_SECTION_NODE: case XML_PI_NODE: case XML_COMMENT_NODE: case XML_XINCLUDE_END: break; /* case XML_DTD_NODE: */ /* URGENT TODO: DTD-node as well? */ default: return(NULL); } if (cur->next != NULL) { if (cur->next->type == XML_ELEMENT_NODE) return(cur->next); cur = cur->next; do { cur = cur->next; } while ((cur != NULL) && (cur->type != XML_ELEMENT_NODE)); return(cur); } return(NULL); } /** * xmlXPathNextDescendantOrSelfElemParent: * @ctxt: the XPath Parser context * @cur: the current node in the traversal * * Traversal function for the "descendant-or-self" axis. * Additionally it returns only nodes which can be parents of * element nodes. * * * Returns the next element following that axis */ static xmlNodePtr xmlXPathNextDescendantOrSelfElemParent(xmlNodePtr cur, xmlNodePtr contextNode) { if (cur == NULL) { if (contextNode == NULL) return(NULL); switch (contextNode->type) { case XML_ELEMENT_NODE: case XML_XINCLUDE_START: case XML_DOCUMENT_FRAG_NODE: case XML_DOCUMENT_NODE: #ifdef LIBXML_DOCB_ENABLED case XML_DOCB_DOCUMENT_NODE: #endif case XML_HTML_DOCUMENT_NODE: return(contextNode); default: return(NULL); } return(NULL); } else { xmlNodePtr start = cur; while (cur != NULL) { switch (cur->type) { case XML_ELEMENT_NODE: /* TODO: OK to have XInclude here? */ case XML_XINCLUDE_START: case XML_DOCUMENT_FRAG_NODE: if (cur != start) return(cur); if (cur->children != NULL) { cur = cur->children; continue; } break; #ifdef LIBXML_DOCB_ENABLED /* Not sure if we need those here. */ case XML_DOCUMENT_NODE: case XML_DOCB_DOCUMENT_NODE: #endif case XML_HTML_DOCUMENT_NODE: if (cur != start) return(cur); return(xmlDocGetRootElement((xmlDocPtr) cur)); default: break; } next_sibling: if ((cur == NULL) || (cur == contextNode)) return(NULL); if (cur->next != NULL) { cur = cur->next; } else { cur = cur->parent; goto next_sibling; } } } return(NULL); } /** * xmlXPathNextDescendant: * @ctxt: the XPath Parser context * @cur: the current node in the traversal * * Traversal function for the "descendant" direction * the descendant axis contains the descendants of the context node in document * order; a descendant is a child or a child of a child and so on. * * Returns the next element following that axis */ xmlNodePtr xmlXPathNextDescendant(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) { if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL); if (cur == NULL) { if (ctxt->context->node == NULL) return(NULL); if ((ctxt->context->node->type == XML_ATTRIBUTE_NODE) || (ctxt->context->node->type == XML_NAMESPACE_DECL)) return(NULL); if (ctxt->context->node == (xmlNodePtr) ctxt->context->doc) return(ctxt->context->doc->children); return(ctxt->context->node->children); } if (cur->children != NULL) { /* * Do not descend on entities declarations */ if (cur->children->type != XML_ENTITY_DECL) { cur = cur->children; /* * Skip DTDs */ if (cur->type != XML_DTD_NODE) return(cur); } } if (cur == ctxt->context->node) return(NULL); while (cur->next != NULL) { cur = cur->next; if ((cur->type != XML_ENTITY_DECL) && (cur->type != XML_DTD_NODE)) return(cur); } do { cur = cur->parent; if (cur == NULL) break; if (cur == ctxt->context->node) return(NULL); if (cur->next != NULL) { cur = cur->next; return(cur); } } while (cur != NULL); return(cur); } /** * xmlXPathNextDescendantOrSelf: * @ctxt: the XPath Parser context * @cur: the current node in the traversal * * Traversal function for the "descendant-or-self" direction * the descendant-or-self axis contains the context node and the descendants * of the context node in document order; thus the context node is the first * node on the axis, and the first child of the context node is the second node * on the axis * * Returns the next element following that axis */ xmlNodePtr xmlXPathNextDescendantOrSelf(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) { if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL); if (cur == NULL) { if (ctxt->context->node == NULL) return(NULL); if ((ctxt->context->node->type == XML_ATTRIBUTE_NODE) || (ctxt->context->node->type == XML_NAMESPACE_DECL)) return(NULL); return(ctxt->context->node); } return(xmlXPathNextDescendant(ctxt, cur)); } /** * xmlXPathNextParent: * @ctxt: the XPath Parser context * @cur: the current node in the traversal * * Traversal function for the "parent" direction * The parent axis contains the parent of the context node, if there is one. * * Returns the next element following that axis */ xmlNodePtr xmlXPathNextParent(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) { if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL); /* * the parent of an attribute or namespace node is the element * to which the attribute or namespace node is attached * Namespace handling !!! */ if (cur == NULL) { if (ctxt->context->node == NULL) return(NULL); switch (ctxt->context->node->type) { case XML_ELEMENT_NODE: case XML_TEXT_NODE: case XML_CDATA_SECTION_NODE: case XML_ENTITY_REF_NODE: case XML_ENTITY_NODE: case XML_PI_NODE: case XML_COMMENT_NODE: case XML_NOTATION_NODE: case XML_DTD_NODE: case XML_ELEMENT_DECL: case XML_ATTRIBUTE_DECL: case XML_XINCLUDE_START: case XML_XINCLUDE_END: case XML_ENTITY_DECL: if (ctxt->context->node->parent == NULL) return((xmlNodePtr) ctxt->context->doc); if ((ctxt->context->node->parent->type == XML_ELEMENT_NODE) && ((ctxt->context->node->parent->name[0] == ' ') || (xmlStrEqual(ctxt->context->node->parent->name, BAD_CAST "fake node libxslt")))) return(NULL); return(ctxt->context->node->parent); case XML_ATTRIBUTE_NODE: { xmlAttrPtr att = (xmlAttrPtr) ctxt->context->node; return(att->parent); } case XML_DOCUMENT_NODE: case XML_DOCUMENT_TYPE_NODE: case XML_DOCUMENT_FRAG_NODE: case XML_HTML_DOCUMENT_NODE: #ifdef LIBXML_DOCB_ENABLED case XML_DOCB_DOCUMENT_NODE: #endif return(NULL); case XML_NAMESPACE_DECL: { xmlNsPtr ns = (xmlNsPtr) ctxt->context->node; if ((ns->next != NULL) && (ns->next->type != XML_NAMESPACE_DECL)) return((xmlNodePtr) ns->next); return(NULL); } } } return(NULL); } /** * xmlXPathNextAncestor: * @ctxt: the XPath Parser context * @cur: the current node in the traversal * * Traversal function for the "ancestor" direction * the ancestor axis contains the ancestors of the context node; the ancestors * of the context node consist of the parent of context node and the parent's * parent and so on; the nodes are ordered in reverse document order; thus the * parent is the first node on the axis, and the parent's parent is the second * node on the axis * * Returns the next element following that axis */ xmlNodePtr xmlXPathNextAncestor(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) { if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL); /* * the parent of an attribute or namespace node is the element * to which the attribute or namespace node is attached * !!!!!!!!!!!!! */ if (cur == NULL) { if (ctxt->context->node == NULL) return(NULL); switch (ctxt->context->node->type) { case XML_ELEMENT_NODE: case XML_TEXT_NODE: case XML_CDATA_SECTION_NODE: case XML_ENTITY_REF_NODE: case XML_ENTITY_NODE: case XML_PI_NODE: case XML_COMMENT_NODE: case XML_DTD_NODE: case XML_ELEMENT_DECL: case XML_ATTRIBUTE_DECL: case XML_ENTITY_DECL: case XML_NOTATION_NODE: case XML_XINCLUDE_START: case XML_XINCLUDE_END: if (ctxt->context->node->parent == NULL) return((xmlNodePtr) ctxt->context->doc); if ((ctxt->context->node->parent->type == XML_ELEMENT_NODE) && ((ctxt->context->node->parent->name[0] == ' ') || (xmlStrEqual(ctxt->context->node->parent->name, BAD_CAST "fake node libxslt")))) return(NULL); return(ctxt->context->node->parent); case XML_ATTRIBUTE_NODE: { xmlAttrPtr tmp = (xmlAttrPtr) ctxt->context->node; return(tmp->parent); } case XML_DOCUMENT_NODE: case XML_DOCUMENT_TYPE_NODE: case XML_DOCUMENT_FRAG_NODE: case XML_HTML_DOCUMENT_NODE: #ifdef LIBXML_DOCB_ENABLED case XML_DOCB_DOCUMENT_NODE: #endif return(NULL); case XML_NAMESPACE_DECL: { xmlNsPtr ns = (xmlNsPtr) ctxt->context->node; if ((ns->next != NULL) && (ns->next->type != XML_NAMESPACE_DECL)) return((xmlNodePtr) ns->next); /* Bad, how did that namespace end up here ? */ return(NULL); } } return(NULL); } if (cur == ctxt->context->doc->children) return((xmlNodePtr) ctxt->context->doc); if (cur == (xmlNodePtr) ctxt->context->doc) return(NULL); switch (cur->type) { case XML_ELEMENT_NODE: case XML_TEXT_NODE: case XML_CDATA_SECTION_NODE: case XML_ENTITY_REF_NODE: case XML_ENTITY_NODE: case XML_PI_NODE: case XML_COMMENT_NODE: case XML_NOTATION_NODE: case XML_DTD_NODE: case XML_ELEMENT_DECL: case XML_ATTRIBUTE_DECL: case XML_ENTITY_DECL: case XML_XINCLUDE_START: case XML_XINCLUDE_END: if (cur->parent == NULL) return(NULL); if ((cur->parent->type == XML_ELEMENT_NODE) && ((cur->parent->name[0] == ' ') || (xmlStrEqual(cur->parent->name, BAD_CAST "fake node libxslt")))) return(NULL); return(cur->parent); case XML_ATTRIBUTE_NODE: { xmlAttrPtr att = (xmlAttrPtr) ctxt->context->node; return(att->parent); } case XML_NAMESPACE_DECL: { xmlNsPtr ns = (xmlNsPtr) ctxt->context->node; if ((ns->next != NULL) && (ns->next->type != XML_NAMESPACE_DECL)) return((xmlNodePtr) ns->next); /* Bad, how did that namespace end up here ? */ return(NULL); } case XML_DOCUMENT_NODE: case XML_DOCUMENT_TYPE_NODE: case XML_DOCUMENT_FRAG_NODE: case XML_HTML_DOCUMENT_NODE: #ifdef LIBXML_DOCB_ENABLED case XML_DOCB_DOCUMENT_NODE: #endif return(NULL); } return(NULL); } /** * xmlXPathNextAncestorOrSelf: * @ctxt: the XPath Parser context * @cur: the current node in the traversal * * Traversal function for the "ancestor-or-self" direction * he ancestor-or-self axis contains the context node and ancestors of * the context node in reverse document order; thus the context node is * the first node on the axis, and the context node's parent the second; * parent here is defined the same as with the parent axis. * * Returns the next element following that axis */ xmlNodePtr xmlXPathNextAncestorOrSelf(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) { if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL); if (cur == NULL) return(ctxt->context->node); return(xmlXPathNextAncestor(ctxt, cur)); } /** * xmlXPathNextFollowingSibling: * @ctxt: the XPath Parser context * @cur: the current node in the traversal * * Traversal function for the "following-sibling" direction * The following-sibling axis contains the following siblings of the context * node in document order. * * Returns the next element following that axis */ xmlNodePtr xmlXPathNextFollowingSibling(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) { if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL); if ((ctxt->context->node->type == XML_ATTRIBUTE_NODE) || (ctxt->context->node->type == XML_NAMESPACE_DECL)) return(NULL); if (cur == (xmlNodePtr) ctxt->context->doc) return(NULL); if (cur == NULL) return(ctxt->context->node->next); return(cur->next); } /** * xmlXPathNextPrecedingSibling: * @ctxt: the XPath Parser context * @cur: the current node in the traversal * * Traversal function for the "preceding-sibling" direction * The preceding-sibling axis contains the preceding siblings of the context * node in reverse document order; the first preceding sibling is first on the * axis; the sibling preceding that node is the second on the axis and so on. * * Returns the next element following that axis */ xmlNodePtr xmlXPathNextPrecedingSibling(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) { if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL); if ((ctxt->context->node->type == XML_ATTRIBUTE_NODE) || (ctxt->context->node->type == XML_NAMESPACE_DECL)) return(NULL); if (cur == (xmlNodePtr) ctxt->context->doc) return(NULL); if (cur == NULL) return(ctxt->context->node->prev); if ((cur->prev != NULL) && (cur->prev->type == XML_DTD_NODE)) { cur = cur->prev; if (cur == NULL) return(ctxt->context->node->prev); } return(cur->prev); } /** * xmlXPathNextFollowing: * @ctxt: the XPath Parser context * @cur: the current node in the traversal * * Traversal function for the "following" direction * The following axis contains all nodes in the same document as the context * node that are after the context node in document order, excluding any * descendants and excluding attribute nodes and namespace nodes; the nodes * are ordered in document order * * Returns the next element following that axis */ xmlNodePtr xmlXPathNextFollowing(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) { if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL); if (cur != NULL && cur->children != NULL) return cur->children ; if (cur == NULL) cur = ctxt->context->node; if (cur == NULL) return(NULL) ; /* ERROR */ if (cur->next != NULL) return(cur->next) ; do { cur = cur->parent; if (cur == NULL) break; if (cur == (xmlNodePtr) ctxt->context->doc) return(NULL); if (cur->next != NULL) return(cur->next); } while (cur != NULL); return(cur); } /* * xmlXPathIsAncestor: * @ancestor: the ancestor node * @node: the current node * * Check that @ancestor is a @node's ancestor * * returns 1 if @ancestor is a @node's ancestor, 0 otherwise. */ static int xmlXPathIsAncestor(xmlNodePtr ancestor, xmlNodePtr node) { if ((ancestor == NULL) || (node == NULL)) return(0); /* nodes need to be in the same document */ if (ancestor->doc != node->doc) return(0); /* avoid searching if ancestor or node is the root node */ if (ancestor == (xmlNodePtr) node->doc) return(1); if (node == (xmlNodePtr) ancestor->doc) return(0); while (node->parent != NULL) { if (node->parent == ancestor) return(1); node = node->parent; } return(0); } /** * xmlXPathNextPreceding: * @ctxt: the XPath Parser context * @cur: the current node in the traversal * * Traversal function for the "preceding" direction * the preceding axis contains all nodes in the same document as the context * node that are before the context node in document order, excluding any * ancestors and excluding attribute nodes and namespace nodes; the nodes are * ordered in reverse document order * * Returns the next element following that axis */ xmlNodePtr xmlXPathNextPreceding(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) { if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL); if (cur == NULL) cur = ctxt->context->node; if (cur == NULL) return (NULL); if ((cur->prev != NULL) && (cur->prev->type == XML_DTD_NODE)) cur = cur->prev; do { if (cur->prev != NULL) { for (cur = cur->prev; cur->last != NULL; cur = cur->last) ; return (cur); } cur = cur->parent; if (cur == NULL) return (NULL); if (cur == ctxt->context->doc->children) return (NULL); } while (xmlXPathIsAncestor(cur, ctxt->context->node)); return (cur); } /** * xmlXPathNextPrecedingInternal: * @ctxt: the XPath Parser context * @cur: the current node in the traversal * * Traversal function for the "preceding" direction * the preceding axis contains all nodes in the same document as the context * node that are before the context node in document order, excluding any * ancestors and excluding attribute nodes and namespace nodes; the nodes are * ordered in reverse document order * This is a faster implementation but internal only since it requires a * state kept in the parser context: ctxt->ancestor. * * Returns the next element following that axis */ static xmlNodePtr xmlXPathNextPrecedingInternal(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) { if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL); if (cur == NULL) { cur = ctxt->context->node; if (cur == NULL) return (NULL); if (cur->type == XML_NAMESPACE_DECL) cur = (xmlNodePtr)((xmlNsPtr)cur)->next; ctxt->ancestor = cur->parent; } if ((cur->prev != NULL) && (cur->prev->type == XML_DTD_NODE)) cur = cur->prev; while (cur->prev == NULL) { cur = cur->parent; if (cur == NULL) return (NULL); if (cur == ctxt->context->doc->children) return (NULL); if (cur != ctxt->ancestor) return (cur); ctxt->ancestor = cur->parent; } cur = cur->prev; while (cur->last != NULL) cur = cur->last; return (cur); } /** * xmlXPathNextNamespace: * @ctxt: the XPath Parser context * @cur: the current attribute in the traversal * * Traversal function for the "namespace" direction * the namespace axis contains the namespace nodes of the context node; * the order of nodes on this axis is implementation-defined; the axis will * be empty unless the context node is an element * * We keep the XML namespace node at the end of the list. * * Returns the next element following that axis */ xmlNodePtr xmlXPathNextNamespace(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) { if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL); if (ctxt->context->node->type != XML_ELEMENT_NODE) return(NULL); if (ctxt->context->tmpNsList == NULL && cur != (xmlNodePtr) xmlXPathXMLNamespace) { if (ctxt->context->tmpNsList != NULL) xmlFree(ctxt->context->tmpNsList); ctxt->context->tmpNsList = xmlGetNsList(ctxt->context->doc, ctxt->context->node); ctxt->context->tmpNsNr = 0; if (ctxt->context->tmpNsList != NULL) { while (ctxt->context->tmpNsList[ctxt->context->tmpNsNr] != NULL) { ctxt->context->tmpNsNr++; } } return((xmlNodePtr) xmlXPathXMLNamespace); } if (ctxt->context->tmpNsNr > 0) { return (xmlNodePtr)ctxt->context->tmpNsList[--ctxt->context->tmpNsNr]; } else { if (ctxt->context->tmpNsList != NULL) xmlFree(ctxt->context->tmpNsList); ctxt->context->tmpNsList = NULL; return(NULL); } } /** * xmlXPathNextAttribute: * @ctxt: the XPath Parser context * @cur: the current attribute in the traversal * * Traversal function for the "attribute" direction * TODO: support DTD inherited default attributes * * Returns the next element following that axis */ xmlNodePtr xmlXPathNextAttribute(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) { if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL); if (ctxt->context->node == NULL) return(NULL); if (ctxt->context->node->type != XML_ELEMENT_NODE) return(NULL); if (cur == NULL) { if (ctxt->context->node == (xmlNodePtr) ctxt->context->doc) return(NULL); return((xmlNodePtr)ctxt->context->node->properties); } return((xmlNodePtr)cur->next); } /************************************************************************ * * * NodeTest Functions * * * ************************************************************************/ #define IS_FUNCTION 200 /************************************************************************ * * * Implicit tree core function library * * * ************************************************************************/ /** * xmlXPathRoot: * @ctxt: the XPath Parser context * * Initialize the context to the root of the document */ void xmlXPathRoot(xmlXPathParserContextPtr ctxt) { if ((ctxt == NULL) || (ctxt->context == NULL)) return; ctxt->context->node = (xmlNodePtr) ctxt->context->doc; valuePush(ctxt, xmlXPathCacheNewNodeSet(ctxt->context, ctxt->context->node)); } /************************************************************************ * * * The explicit core function library * *http://www.w3.org/Style/XSL/Group/1999/07/xpath-19990705.html#corelib * * * ************************************************************************/ /** * xmlXPathLastFunction: * @ctxt: the XPath Parser context * @nargs: the number of arguments * * Implement the last() XPath function * number last() * The last function returns the number of nodes in the context node list. */ void xmlXPathLastFunction(xmlXPathParserContextPtr ctxt, int nargs) { CHECK_ARITY(0); if (ctxt->context->contextSize >= 0) { valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context, (double) ctxt->context->contextSize)); #ifdef DEBUG_EXPR xmlGenericError(xmlGenericErrorContext, "last() : %d\n", ctxt->context->contextSize); #endif } else { XP_ERROR(XPATH_INVALID_CTXT_SIZE); } } /** * xmlXPathPositionFunction: * @ctxt: the XPath Parser context * @nargs: the number of arguments * * Implement the position() XPath function * number position() * The position function returns the position of the context node in the * context node list. The first position is 1, and so the last position * will be equal to last(). */ void xmlXPathPositionFunction(xmlXPathParserContextPtr ctxt, int nargs) { CHECK_ARITY(0); if (ctxt->context->proximityPosition >= 0) { valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context, (double) ctxt->context->proximityPosition)); #ifdef DEBUG_EXPR xmlGenericError(xmlGenericErrorContext, "position() : %d\n", ctxt->context->proximityPosition); #endif } else { XP_ERROR(XPATH_INVALID_CTXT_POSITION); } } /** * xmlXPathCountFunction: * @ctxt: the XPath Parser context * @nargs: the number of arguments * * Implement the count() XPath function * number count(node-set) */ void xmlXPathCountFunction(xmlXPathParserContextPtr ctxt, int nargs) { xmlXPathObjectPtr cur; CHECK_ARITY(1); if ((ctxt->value == NULL) || ((ctxt->value->type != XPATH_NODESET) && (ctxt->value->type != XPATH_XSLT_TREE))) XP_ERROR(XPATH_INVALID_TYPE); cur = valuePop(ctxt); if ((cur == NULL) || (cur->nodesetval == NULL)) valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context, (double) 0)); else if ((cur->type == XPATH_NODESET) || (cur->type == XPATH_XSLT_TREE)) { valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context, (double) cur->nodesetval->nodeNr)); } else { if ((cur->nodesetval->nodeNr != 1) || (cur->nodesetval->nodeTab == NULL)) { valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context, (double) 0)); } else { xmlNodePtr tmp; int i = 0; tmp = cur->nodesetval->nodeTab[0]; if (tmp != NULL) { tmp = tmp->children; while (tmp != NULL) { tmp = tmp->next; i++; } } valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context, (double) i)); } } xmlXPathReleaseObject(ctxt->context, cur); } /** * xmlXPathGetElementsByIds: * @doc: the document * @ids: a whitespace separated list of IDs * * Selects elements by their unique ID. * * Returns a node-set of selected elements. */ static xmlNodeSetPtr xmlXPathGetElementsByIds (xmlDocPtr doc, const xmlChar *ids) { xmlNodeSetPtr ret; const xmlChar *cur = ids; xmlChar *ID; xmlAttrPtr attr; xmlNodePtr elem = NULL; if (ids == NULL) return(NULL); ret = xmlXPathNodeSetCreate(NULL); while (IS_BLANK_CH(*cur)) cur++; while (*cur != 0) { while ((!IS_BLANK_CH(*cur)) && (*cur != 0)) cur++; ID = xmlStrndup(ids, cur - ids); if (ID != NULL) { /* * We used to check the fact that the value passed * was an NCName, but this generated much troubles for * me and Aleksey Sanin, people blatantly violated that * constaint, like Visa3D spec. * if (xmlValidateNCName(ID, 1) == 0) */ attr = xmlGetID(doc, ID); if (attr != NULL) { if (attr->type == XML_ATTRIBUTE_NODE) elem = attr->parent; else if (attr->type == XML_ELEMENT_NODE) elem = (xmlNodePtr) attr; else elem = NULL; if (elem != NULL) xmlXPathNodeSetAdd(ret, elem); } xmlFree(ID); } while (IS_BLANK_CH(*cur)) cur++; ids = cur; } return(ret); } /** * xmlXPathIdFunction: * @ctxt: the XPath Parser context * @nargs: the number of arguments * * Implement the id() XPath function * node-set id(object) * The id function selects elements by their unique ID * (see [5.2.1 Unique IDs]). When the argument to id is of type node-set, * then the result is the union of the result of applying id to the * string value of each of the nodes in the argument node-set. When the * argument to id is of any other type, the argument is converted to a * string as if by a call to the string function; the string is split * into a whitespace-separated list of tokens (whitespace is any sequence * of characters matching the production S); the result is a node-set * containing the elements in the same document as the context node that * have a unique ID equal to any of the tokens in the list. */ void xmlXPathIdFunction(xmlXPathParserContextPtr ctxt, int nargs) { xmlChar *tokens; xmlNodeSetPtr ret; xmlXPathObjectPtr obj; CHECK_ARITY(1); obj = valuePop(ctxt); if (obj == NULL) XP_ERROR(XPATH_INVALID_OPERAND); if ((obj->type == XPATH_NODESET) || (obj->type == XPATH_XSLT_TREE)) { xmlNodeSetPtr ns; int i; ret = xmlXPathNodeSetCreate(NULL); if (obj->nodesetval != NULL) { for (i = 0; i < obj->nodesetval->nodeNr; i++) { tokens = xmlXPathCastNodeToString(obj->nodesetval->nodeTab[i]); ns = xmlXPathGetElementsByIds(ctxt->context->doc, tokens); ret = xmlXPathNodeSetMerge(ret, ns); xmlXPathFreeNodeSet(ns); if (tokens != NULL) xmlFree(tokens); } } xmlXPathReleaseObject(ctxt->context, obj); valuePush(ctxt, xmlXPathCacheWrapNodeSet(ctxt->context, ret)); return; } obj = xmlXPathCacheConvertString(ctxt->context, obj); ret = xmlXPathGetElementsByIds(ctxt->context->doc, obj->stringval); valuePush(ctxt, xmlXPathCacheWrapNodeSet(ctxt->context, ret)); xmlXPathReleaseObject(ctxt->context, obj); return; } /** * xmlXPathLocalNameFunction: * @ctxt: the XPath Parser context * @nargs: the number of arguments * * Implement the local-name() XPath function * string local-name(node-set?) * The local-name function returns a string containing the local part * of the name of the node in the argument node-set that is first in * document order. If the node-set is empty or the first node has no * name, an empty string is returned. If the argument is omitted it * defaults to the context node. */ void xmlXPathLocalNameFunction(xmlXPathParserContextPtr ctxt, int nargs) { xmlXPathObjectPtr cur; if (ctxt == NULL) return; if (nargs == 0) { valuePush(ctxt, xmlXPathCacheNewNodeSet(ctxt->context, ctxt->context->node)); nargs = 1; } CHECK_ARITY(1); if ((ctxt->value == NULL) || ((ctxt->value->type != XPATH_NODESET) && (ctxt->value->type != XPATH_XSLT_TREE))) XP_ERROR(XPATH_INVALID_TYPE); cur = valuePop(ctxt); if ((cur->nodesetval == NULL) || (cur->nodesetval->nodeNr == 0)) { valuePush(ctxt, xmlXPathCacheNewCString(ctxt->context, "")); } else { int i = 0; /* Should be first in document order !!!!! */ switch (cur->nodesetval->nodeTab[i]->type) { case XML_ELEMENT_NODE: case XML_ATTRIBUTE_NODE: case XML_PI_NODE: if (cur->nodesetval->nodeTab[i]->name[0] == ' ') valuePush(ctxt, xmlXPathCacheNewCString(ctxt->context, "")); else valuePush(ctxt, xmlXPathCacheNewString(ctxt->context, cur->nodesetval->nodeTab[i]->name)); break; case XML_NAMESPACE_DECL: valuePush(ctxt, xmlXPathCacheNewString(ctxt->context, ((xmlNsPtr)cur->nodesetval->nodeTab[i])->prefix)); break; default: valuePush(ctxt, xmlXPathCacheNewCString(ctxt->context, "")); } } xmlXPathReleaseObject(ctxt->context, cur); } /** * xmlXPathNamespaceURIFunction: * @ctxt: the XPath Parser context * @nargs: the number of arguments * * Implement the namespace-uri() XPath function * string namespace-uri(node-set?) * The namespace-uri function returns a string containing the * namespace URI of the expanded name of the node in the argument * node-set that is first in document order. If the node-set is empty, * the first node has no name, or the expanded name has no namespace * URI, an empty string is returned. If the argument is omitted it * defaults to the context node. */ void xmlXPathNamespaceURIFunction(xmlXPathParserContextPtr ctxt, int nargs) { xmlXPathObjectPtr cur; if (ctxt == NULL) return; if (nargs == 0) { valuePush(ctxt, xmlXPathCacheNewNodeSet(ctxt->context, ctxt->context->node)); nargs = 1; } CHECK_ARITY(1); if ((ctxt->value == NULL) || ((ctxt->value->type != XPATH_NODESET) && (ctxt->value->type != XPATH_XSLT_TREE))) XP_ERROR(XPATH_INVALID_TYPE); cur = valuePop(ctxt); if ((cur->nodesetval == NULL) || (cur->nodesetval->nodeNr == 0)) { valuePush(ctxt, xmlXPathCacheNewCString(ctxt->context, "")); } else { int i = 0; /* Should be first in document order !!!!! */ switch (cur->nodesetval->nodeTab[i]->type) { case XML_ELEMENT_NODE: case XML_ATTRIBUTE_NODE: if (cur->nodesetval->nodeTab[i]->ns == NULL) valuePush(ctxt, xmlXPathCacheNewCString(ctxt->context, "")); else valuePush(ctxt, xmlXPathCacheNewString(ctxt->context, cur->nodesetval->nodeTab[i]->ns->href)); break; default: valuePush(ctxt, xmlXPathCacheNewCString(ctxt->context, "")); } } xmlXPathReleaseObject(ctxt->context, cur); } /** * xmlXPathNameFunction: * @ctxt: the XPath Parser context * @nargs: the number of arguments * * Implement the name() XPath function * string name(node-set?) * The name function returns a string containing a QName representing * the name of the node in the argument node-set that is first in document * order. The QName must represent the name with respect to the namespace * declarations in effect on the node whose name is being represented. * Typically, this will be the form in which the name occurred in the XML * source. This need not be the case if there are namespace declarations * in effect on the node that associate multiple prefixes with the same * namespace. However, an implementation may include information about * the original prefix in its representation of nodes; in this case, an * implementation can ensure that the returned string is always the same * as the QName used in the XML source. If the argument it omitted it * defaults to the context node. * Libxml keep the original prefix so the "real qualified name" used is * returned. */ static void xmlXPathNameFunction(xmlXPathParserContextPtr ctxt, int nargs) { xmlXPathObjectPtr cur; if (nargs == 0) { valuePush(ctxt, xmlXPathCacheNewNodeSet(ctxt->context, ctxt->context->node)); nargs = 1; } CHECK_ARITY(1); if ((ctxt->value == NULL) || ((ctxt->value->type != XPATH_NODESET) && (ctxt->value->type != XPATH_XSLT_TREE))) XP_ERROR(XPATH_INVALID_TYPE); cur = valuePop(ctxt); if ((cur->nodesetval == NULL) || (cur->nodesetval->nodeNr == 0)) { valuePush(ctxt, xmlXPathCacheNewCString(ctxt->context, "")); } else { int i = 0; /* Should be first in document order !!!!! */ switch (cur->nodesetval->nodeTab[i]->type) { case XML_ELEMENT_NODE: case XML_ATTRIBUTE_NODE: if (cur->nodesetval->nodeTab[i]->name[0] == ' ') valuePush(ctxt, xmlXPathCacheNewCString(ctxt->context, "")); else if ((cur->nodesetval->nodeTab[i]->ns == NULL) || (cur->nodesetval->nodeTab[i]->ns->prefix == NULL)) { valuePush(ctxt, xmlXPathCacheNewString(ctxt->context, cur->nodesetval->nodeTab[i]->name)); } else { xmlChar *fullname; fullname = xmlBuildQName(cur->nodesetval->nodeTab[i]->name, cur->nodesetval->nodeTab[i]->ns->prefix, NULL, 0); if (fullname == cur->nodesetval->nodeTab[i]->name) fullname = xmlStrdup(cur->nodesetval->nodeTab[i]->name); if (fullname == NULL) { XP_ERROR(XPATH_MEMORY_ERROR); } valuePush(ctxt, xmlXPathCacheWrapString( ctxt->context, fullname)); } break; default: valuePush(ctxt, xmlXPathCacheNewNodeSet(ctxt->context, cur->nodesetval->nodeTab[i])); xmlXPathLocalNameFunction(ctxt, 1); } } xmlXPathReleaseObject(ctxt->context, cur); } /** * xmlXPathStringFunction: * @ctxt: the XPath Parser context * @nargs: the number of arguments * * Implement the string() XPath function * string string(object?) * The string function converts an object to a string as follows: * - A node-set is converted to a string by returning the value of * the node in the node-set that is first in document order. * If the node-set is empty, an empty string is returned. * - A number is converted to a string as follows * + NaN is converted to the string NaN * + positive zero is converted to the string 0 * + negative zero is converted to the string 0 * + positive infinity is converted to the string Infinity * + negative infinity is converted to the string -Infinity * + if the number is an integer, the number is represented in * decimal form as a Number with no decimal point and no leading * zeros, preceded by a minus sign (-) if the number is negative * + otherwise, the number is represented in decimal form as a * Number including a decimal point with at least one digit * before the decimal point and at least one digit after the * decimal point, preceded by a minus sign (-) if the number * is negative; there must be no leading zeros before the decimal * point apart possibly from the one required digit immediately * before the decimal point; beyond the one required digit * after the decimal point there must be as many, but only as * many, more digits as are needed to uniquely distinguish the * number from all other IEEE 754 numeric values. * - The boolean false value is converted to the string false. * The boolean true value is converted to the string true. * * If the argument is omitted, it defaults to a node-set with the * context node as its only member. */ void xmlXPathStringFunction(xmlXPathParserContextPtr ctxt, int nargs) { xmlXPathObjectPtr cur; if (ctxt == NULL) return; if (nargs == 0) { valuePush(ctxt, xmlXPathCacheWrapString(ctxt->context, xmlXPathCastNodeToString(ctxt->context->node))); return; } CHECK_ARITY(1); cur = valuePop(ctxt); if (cur == NULL) XP_ERROR(XPATH_INVALID_OPERAND); valuePush(ctxt, xmlXPathCacheConvertString(ctxt->context, cur)); } /** * xmlXPathStringLengthFunction: * @ctxt: the XPath Parser context * @nargs: the number of arguments * * Implement the string-length() XPath function * number string-length(string?) * The string-length returns the number of characters in the string * (see [3.6 Strings]). If the argument is omitted, it defaults to * the context node converted to a string, in other words the value * of the context node. */ void xmlXPathStringLengthFunction(xmlXPathParserContextPtr ctxt, int nargs) { xmlXPathObjectPtr cur; if (nargs == 0) { if ((ctxt == NULL) || (ctxt->context == NULL)) return; if (ctxt->context->node == NULL) { valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context, 0)); } else { xmlChar *content; content = xmlXPathCastNodeToString(ctxt->context->node); valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context, xmlUTF8Strlen(content))); xmlFree(content); } return; } CHECK_ARITY(1); CAST_TO_STRING; CHECK_TYPE(XPATH_STRING); cur = valuePop(ctxt); valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context, xmlUTF8Strlen(cur->stringval))); xmlXPathReleaseObject(ctxt->context, cur); } /** * xmlXPathConcatFunction: * @ctxt: the XPath Parser context * @nargs: the number of arguments * * Implement the concat() XPath function * string concat(string, string, string*) * The concat function returns the concatenation of its arguments. */ void xmlXPathConcatFunction(xmlXPathParserContextPtr ctxt, int nargs) { xmlXPathObjectPtr cur, newobj; xmlChar *tmp; if (ctxt == NULL) return; if (nargs < 2) { CHECK_ARITY(2); } CAST_TO_STRING; cur = valuePop(ctxt); if ((cur == NULL) || (cur->type != XPATH_STRING)) { xmlXPathReleaseObject(ctxt->context, cur); return; } nargs--; while (nargs > 0) { CAST_TO_STRING; newobj = valuePop(ctxt); if ((newobj == NULL) || (newobj->type != XPATH_STRING)) { xmlXPathReleaseObject(ctxt->context, newobj); xmlXPathReleaseObject(ctxt->context, cur); XP_ERROR(XPATH_INVALID_TYPE); } tmp = xmlStrcat(newobj->stringval, cur->stringval); newobj->stringval = cur->stringval; cur->stringval = tmp; xmlXPathReleaseObject(ctxt->context, newobj); nargs--; } valuePush(ctxt, cur); } /** * xmlXPathContainsFunction: * @ctxt: the XPath Parser context * @nargs: the number of arguments * * Implement the contains() XPath function * boolean contains(string, string) * The contains function returns true if the first argument string * contains the second argument string, and otherwise returns false. */ void xmlXPathContainsFunction(xmlXPathParserContextPtr ctxt, int nargs) { xmlXPathObjectPtr hay, needle; CHECK_ARITY(2); CAST_TO_STRING; CHECK_TYPE(XPATH_STRING); needle = valuePop(ctxt); CAST_TO_STRING; hay = valuePop(ctxt); if ((hay == NULL) || (hay->type != XPATH_STRING)) { xmlXPathReleaseObject(ctxt->context, hay); xmlXPathReleaseObject(ctxt->context, needle); XP_ERROR(XPATH_INVALID_TYPE); } if (xmlStrstr(hay->stringval, needle->stringval)) valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt->context, 1)); else valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt->context, 0)); xmlXPathReleaseObject(ctxt->context, hay); xmlXPathReleaseObject(ctxt->context, needle); } /** * xmlXPathStartsWithFunction: * @ctxt: the XPath Parser context * @nargs: the number of arguments * * Implement the starts-with() XPath function * boolean starts-with(string, string) * The starts-with function returns true if the first argument string * starts with the second argument string, and otherwise returns false. */ void xmlXPathStartsWithFunction(xmlXPathParserContextPtr ctxt, int nargs) { xmlXPathObjectPtr hay, needle; int n; CHECK_ARITY(2); CAST_TO_STRING; CHECK_TYPE(XPATH_STRING); needle = valuePop(ctxt); CAST_TO_STRING; hay = valuePop(ctxt); if ((hay == NULL) || (hay->type != XPATH_STRING)) { xmlXPathReleaseObject(ctxt->context, hay); xmlXPathReleaseObject(ctxt->context, needle); XP_ERROR(XPATH_INVALID_TYPE); } n = xmlStrlen(needle->stringval); if (xmlStrncmp(hay->stringval, needle->stringval, n)) valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt->context, 0)); else valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt->context, 1)); xmlXPathReleaseObject(ctxt->context, hay); xmlXPathReleaseObject(ctxt->context, needle); } /** * xmlXPathSubstringFunction: * @ctxt: the XPath Parser context * @nargs: the number of arguments * * Implement the substring() XPath function * string substring(string, number, number?) * The substring function returns the substring of the first argument * starting at the position specified in the second argument with * length specified in the third argument. For example, * substring("12345",2,3) returns "234". If the third argument is not * specified, it returns the substring starting at the position specified * in the second argument and continuing to the end of the string. For * example, substring("12345",2) returns "2345". More precisely, each * character in the string (see [3.6 Strings]) is considered to have a * numeric position: the position of the first character is 1, the position * of the second character is 2 and so on. The returned substring contains * those characters for which the position of the character is greater than * or equal to the second argument and, if the third argument is specified, * less than the sum of the second and third arguments; the comparisons * and addition used for the above follow the standard IEEE 754 rules. Thus: * - substring("12345", 1.5, 2.6) returns "234" * - substring("12345", 0, 3) returns "12" * - substring("12345", 0 div 0, 3) returns "" * - substring("12345", 1, 0 div 0) returns "" * - substring("12345", -42, 1 div 0) returns "12345" * - substring("12345", -1 div 0, 1 div 0) returns "" */ void xmlXPathSubstringFunction(xmlXPathParserContextPtr ctxt, int nargs) { xmlXPathObjectPtr str, start, len; double le=0, in; int i, l, m; xmlChar *ret; if (nargs < 2) { CHECK_ARITY(2); } if (nargs > 3) { CHECK_ARITY(3); } /* * take care of possible last (position) argument */ if (nargs == 3) { CAST_TO_NUMBER; CHECK_TYPE(XPATH_NUMBER); len = valuePop(ctxt); le = len->floatval; xmlXPathReleaseObject(ctxt->context, len); } CAST_TO_NUMBER; CHECK_TYPE(XPATH_NUMBER); start = valuePop(ctxt); in = start->floatval; xmlXPathReleaseObject(ctxt->context, start); CAST_TO_STRING; CHECK_TYPE(XPATH_STRING); str = valuePop(ctxt); m = xmlUTF8Strlen((const unsigned char *)str->stringval); /* * If last pos not present, calculate last position */ if (nargs != 3) { le = (double)m; if (in < 1.0) in = 1.0; } /* Need to check for the special cases where either * the index is NaN, the length is NaN, or both * arguments are infinity (relying on Inf + -Inf = NaN) */ if (!xmlXPathIsNaN(in + le) && !xmlXPathIsInf(in)) { /* * To meet the requirements of the spec, the arguments * must be converted to integer format before * initial index calculations are done * * First we go to integer form, rounding up * and checking for special cases */ i = (int) in; if (((double)i)+0.5 <= in) i++; if (xmlXPathIsInf(le) == 1) { l = m; if (i < 1) i = 1; } else if (xmlXPathIsInf(le) == -1 || le < 0.0) l = 0; else { l = (int) le; if (((double)l)+0.5 <= le) l++; } /* Now we normalize inidices */ i -= 1; l += i; if (i < 0) i = 0; if (l > m) l = m; /* number of chars to copy */ l -= i; ret = xmlUTF8Strsub(str->stringval, i, l); } else { ret = NULL; } if (ret == NULL) valuePush(ctxt, xmlXPathCacheNewCString(ctxt->context, "")); else { valuePush(ctxt, xmlXPathCacheNewString(ctxt->context, ret)); xmlFree(ret); } xmlXPathReleaseObject(ctxt->context, str); } /** * xmlXPathSubstringBeforeFunction: * @ctxt: the XPath Parser context * @nargs: the number of arguments * * Implement the substring-before() XPath function * string substring-before(string, string) * The substring-before function returns the substring of the first * argument string that precedes the first occurrence of the second * argument string in the first argument string, or the empty string * if the first argument string does not contain the second argument * string. For example, substring-before("1999/04/01","/") returns 1999. */ void xmlXPathSubstringBeforeFunction(xmlXPathParserContextPtr ctxt, int nargs) { xmlXPathObjectPtr str; xmlXPathObjectPtr find; xmlBufferPtr target; const xmlChar *point; int offset; CHECK_ARITY(2); CAST_TO_STRING; find = valuePop(ctxt); CAST_TO_STRING; str = valuePop(ctxt); target = xmlBufferCreate(); if (target) { point = xmlStrstr(str->stringval, find->stringval); if (point) { offset = (int)(point - str->stringval); xmlBufferAdd(target, str->stringval, offset); } valuePush(ctxt, xmlXPathCacheNewString(ctxt->context, xmlBufferContent(target))); xmlBufferFree(target); } xmlXPathReleaseObject(ctxt->context, str); xmlXPathReleaseObject(ctxt->context, find); } /** * xmlXPathSubstringAfterFunction: * @ctxt: the XPath Parser context * @nargs: the number of arguments * * Implement the substring-after() XPath function * string substring-after(string, string) * The substring-after function returns the substring of the first * argument string that follows the first occurrence of the second * argument string in the first argument string, or the empty stringi * if the first argument string does not contain the second argument * string. For example, substring-after("1999/04/01","/") returns 04/01, * and substring-after("1999/04/01","19") returns 99/04/01. */ void xmlXPathSubstringAfterFunction(xmlXPathParserContextPtr ctxt, int nargs) { xmlXPathObjectPtr str; xmlXPathObjectPtr find; xmlBufferPtr target; const xmlChar *point; int offset; CHECK_ARITY(2); CAST_TO_STRING; find = valuePop(ctxt); CAST_TO_STRING; str = valuePop(ctxt); target = xmlBufferCreate(); if (target) { point = xmlStrstr(str->stringval, find->stringval); if (point) { offset = (int)(point - str->stringval) + xmlStrlen(find->stringval); xmlBufferAdd(target, &str->stringval[offset], xmlStrlen(str->stringval) - offset); } valuePush(ctxt, xmlXPathCacheNewString(ctxt->context, xmlBufferContent(target))); xmlBufferFree(target); } xmlXPathReleaseObject(ctxt->context, str); xmlXPathReleaseObject(ctxt->context, find); } /** * xmlXPathNormalizeFunction: * @ctxt: the XPath Parser context * @nargs: the number of arguments * * Implement the normalize-space() XPath function * string normalize-space(string?) * The normalize-space function returns the argument string with white * space normalized by stripping leading and trailing whitespace * and replacing sequences of whitespace characters by a single * space. Whitespace characters are the same allowed by the S production * in XML. If the argument is omitted, it defaults to the context * node converted to a string, in other words the value of the context node. */ void xmlXPathNormalizeFunction(xmlXPathParserContextPtr ctxt, int nargs) { xmlXPathObjectPtr obj = NULL; xmlChar *source = NULL; xmlBufferPtr target; xmlChar blank; if (ctxt == NULL) return; if (nargs == 0) { /* Use current context node */ valuePush(ctxt, xmlXPathCacheWrapString(ctxt->context, xmlXPathCastNodeToString(ctxt->context->node))); nargs = 1; } CHECK_ARITY(1); CAST_TO_STRING; CHECK_TYPE(XPATH_STRING); obj = valuePop(ctxt); source = obj->stringval; target = xmlBufferCreate(); if (target && source) { /* Skip leading whitespaces */ while (IS_BLANK_CH(*source)) source++; /* Collapse intermediate whitespaces, and skip trailing whitespaces */ blank = 0; while (*source) { if (IS_BLANK_CH(*source)) { blank = 0x20; } else { if (blank) { xmlBufferAdd(target, &blank, 1); blank = 0; } xmlBufferAdd(target, source, 1); } source++; } valuePush(ctxt, xmlXPathCacheNewString(ctxt->context, xmlBufferContent(target))); xmlBufferFree(target); } xmlXPathReleaseObject(ctxt->context, obj); } /** * xmlXPathTranslateFunction: * @ctxt: the XPath Parser context * @nargs: the number of arguments * * Implement the translate() XPath function * string translate(string, string, string) * The translate function returns the first argument string with * occurrences of characters in the second argument string replaced * by the character at the corresponding position in the third argument * string. For example, translate("bar","abc","ABC") returns the string * BAr. If there is a character in the second argument string with no * character at a corresponding position in the third argument string * (because the second argument string is longer than the third argument * string), then occurrences of that character in the first argument * string are removed. For example, translate("--aaa--","abc-","ABC") * returns "AAA". If a character occurs more than once in second * argument string, then the first occurrence determines the replacement * character. If the third argument string is longer than the second * argument string, then excess characters are ignored. */ void xmlXPathTranslateFunction(xmlXPathParserContextPtr ctxt, int nargs) { xmlXPathObjectPtr str; xmlXPathObjectPtr from; xmlXPathObjectPtr to; xmlBufferPtr target; int offset, max; xmlChar ch; const xmlChar *point; xmlChar *cptr; CHECK_ARITY(3); CAST_TO_STRING; to = valuePop(ctxt); CAST_TO_STRING; from = valuePop(ctxt); CAST_TO_STRING; str = valuePop(ctxt); target = xmlBufferCreate(); if (target) { max = xmlUTF8Strlen(to->stringval); for (cptr = str->stringval; (ch=*cptr); ) { offset = xmlUTF8Strloc(from->stringval, cptr); if (offset >= 0) { if (offset < max) { point = xmlUTF8Strpos(to->stringval, offset); if (point) xmlBufferAdd(target, point, xmlUTF8Strsize(point, 1)); } } else xmlBufferAdd(target, cptr, xmlUTF8Strsize(cptr, 1)); /* Step to next character in input */ cptr++; if ( ch & 0x80 ) { /* if not simple ascii, verify proper format */ if ( (ch & 0xc0) != 0xc0 ) { xmlGenericError(xmlGenericErrorContext, "xmlXPathTranslateFunction: Invalid UTF8 string\n"); break; } /* then skip over remaining bytes for this char */ while ( (ch <<= 1) & 0x80 ) if ( (*cptr++ & 0xc0) != 0x80 ) { xmlGenericError(xmlGenericErrorContext, "xmlXPathTranslateFunction: Invalid UTF8 string\n"); break; } if (ch & 0x80) /* must have had error encountered */ break; } } } valuePush(ctxt, xmlXPathCacheNewString(ctxt->context, xmlBufferContent(target))); xmlBufferFree(target); xmlXPathReleaseObject(ctxt->context, str); xmlXPathReleaseObject(ctxt->context, from); xmlXPathReleaseObject(ctxt->context, to); } /** * xmlXPathBooleanFunction: * @ctxt: the XPath Parser context * @nargs: the number of arguments * * Implement the boolean() XPath function * boolean boolean(object) * The boolean function converts its argument to a boolean as follows: * - a number is true if and only if it is neither positive or * negative zero nor NaN * - a node-set is true if and only if it is non-empty * - a string is true if and only if its length is non-zero */ void xmlXPathBooleanFunction(xmlXPathParserContextPtr ctxt, int nargs) { xmlXPathObjectPtr cur; CHECK_ARITY(1); cur = valuePop(ctxt); if (cur == NULL) XP_ERROR(XPATH_INVALID_OPERAND); cur = xmlXPathCacheConvertBoolean(ctxt->context, cur); valuePush(ctxt, cur); } /** * xmlXPathNotFunction: * @ctxt: the XPath Parser context * @nargs: the number of arguments * * Implement the not() XPath function * boolean not(boolean) * The not function returns true if its argument is false, * and false otherwise. */ void xmlXPathNotFunction(xmlXPathParserContextPtr ctxt, int nargs) { CHECK_ARITY(1); CAST_TO_BOOLEAN; CHECK_TYPE(XPATH_BOOLEAN); ctxt->value->boolval = ! ctxt->value->boolval; } /** * xmlXPathTrueFunction: * @ctxt: the XPath Parser context * @nargs: the number of arguments * * Implement the true() XPath function * boolean true() */ void xmlXPathTrueFunction(xmlXPathParserContextPtr ctxt, int nargs) { CHECK_ARITY(0); valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt->context, 1)); } /** * xmlXPathFalseFunction: * @ctxt: the XPath Parser context * @nargs: the number of arguments * * Implement the false() XPath function * boolean false() */ void xmlXPathFalseFunction(xmlXPathParserContextPtr ctxt, int nargs) { CHECK_ARITY(0); valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt->context, 0)); } /** * xmlXPathLangFunction: * @ctxt: the XPath Parser context * @nargs: the number of arguments * * Implement the lang() XPath function * boolean lang(string) * The lang function returns true or false depending on whether the * language of the context node as specified by xml:lang attributes * is the same as or is a sublanguage of the language specified by * the argument string. The language of the context node is determined * by the value of the xml:lang attribute on the context node, or, if * the context node has no xml:lang attribute, by the value of the * xml:lang attribute on the nearest ancestor of the context node that * has an xml:lang attribute. If there is no such attribute, then lang * returns false. If there is such an attribute, then lang returns * true if the attribute value is equal to the argument ignoring case, * or if there is some suffix starting with - such that the attribute * value is equal to the argument ignoring that suffix of the attribute * value and ignoring case. */ void xmlXPathLangFunction(xmlXPathParserContextPtr ctxt, int nargs) { xmlXPathObjectPtr val = NULL; const xmlChar *theLang = NULL; const xmlChar *lang; int ret = 0; int i; CHECK_ARITY(1); CAST_TO_STRING; CHECK_TYPE(XPATH_STRING); val = valuePop(ctxt); lang = val->stringval; theLang = xmlNodeGetLang(ctxt->context->node); if ((theLang != NULL) && (lang != NULL)) { for (i = 0;lang[i] != 0;i++) if (toupper(lang[i]) != toupper(theLang[i])) goto not_equal; if ((theLang[i] == 0) || (theLang[i] == '-')) ret = 1; } not_equal: if (theLang != NULL) xmlFree((void *)theLang); xmlXPathReleaseObject(ctxt->context, val); valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt->context, ret)); } /** * xmlXPathNumberFunction: * @ctxt: the XPath Parser context * @nargs: the number of arguments * * Implement the number() XPath function * number number(object?) */ void xmlXPathNumberFunction(xmlXPathParserContextPtr ctxt, int nargs) { xmlXPathObjectPtr cur; double res; if (ctxt == NULL) return; if (nargs == 0) { if (ctxt->context->node == NULL) { valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context, 0.0)); } else { xmlChar* content = xmlNodeGetContent(ctxt->context->node); res = xmlXPathStringEvalNumber(content); valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context, res)); xmlFree(content); } return; } CHECK_ARITY(1); cur = valuePop(ctxt); valuePush(ctxt, xmlXPathCacheConvertNumber(ctxt->context, cur)); } /** * xmlXPathSumFunction: * @ctxt: the XPath Parser context * @nargs: the number of arguments * * Implement the sum() XPath function * number sum(node-set) * The sum function returns the sum of the values of the nodes in * the argument node-set. */ void xmlXPathSumFunction(xmlXPathParserContextPtr ctxt, int nargs) { xmlXPathObjectPtr cur; int i; double res = 0.0; CHECK_ARITY(1); if ((ctxt->value == NULL) || ((ctxt->value->type != XPATH_NODESET) && (ctxt->value->type != XPATH_XSLT_TREE))) XP_ERROR(XPATH_INVALID_TYPE); cur = valuePop(ctxt); if ((cur->nodesetval != NULL) && (cur->nodesetval->nodeNr != 0)) { for (i = 0; i < cur->nodesetval->nodeNr; i++) { res += xmlXPathCastNodeToNumber(cur->nodesetval->nodeTab[i]); } } valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context, res)); xmlXPathReleaseObject(ctxt->context, cur); } /* * To assure working code on multiple platforms, we want to only depend * upon the characteristic truncation of converting a floating point value * to an integer. Unfortunately, because of the different storage sizes * of our internal floating point value (double) and integer (int), we * can't directly convert (see bug 301162). This macro is a messy * 'workaround' */ #define XTRUNC(f, v) \ f = fmod((v), INT_MAX); \ f = (v) - (f) + (double)((int)(f)); /** * xmlXPathFloorFunction: * @ctxt: the XPath Parser context * @nargs: the number of arguments * * Implement the floor() XPath function * number floor(number) * The floor function returns the largest (closest to positive infinity) * number that is not greater than the argument and that is an integer. */ void xmlXPathFloorFunction(xmlXPathParserContextPtr ctxt, int nargs) { double f; CHECK_ARITY(1); CAST_TO_NUMBER; CHECK_TYPE(XPATH_NUMBER); XTRUNC(f, ctxt->value->floatval); if (f != ctxt->value->floatval) { if (ctxt->value->floatval > 0) ctxt->value->floatval = f; else ctxt->value->floatval = f - 1; } } /** * xmlXPathCeilingFunction: * @ctxt: the XPath Parser context * @nargs: the number of arguments * * Implement the ceiling() XPath function * number ceiling(number) * The ceiling function returns the smallest (closest to negative infinity) * number that is not less than the argument and that is an integer. */ void xmlXPathCeilingFunction(xmlXPathParserContextPtr ctxt, int nargs) { double f; CHECK_ARITY(1); CAST_TO_NUMBER; CHECK_TYPE(XPATH_NUMBER); #if 0 ctxt->value->floatval = ceil(ctxt->value->floatval); #else XTRUNC(f, ctxt->value->floatval); if (f != ctxt->value->floatval) { if (ctxt->value->floatval > 0) ctxt->value->floatval = f + 1; else { if (ctxt->value->floatval < 0 && f == 0) ctxt->value->floatval = xmlXPathNZERO; else ctxt->value->floatval = f; } } #endif } /** * xmlXPathRoundFunction: * @ctxt: the XPath Parser context * @nargs: the number of arguments * * Implement the round() XPath function * number round(number) * The round function returns the number that is closest to the * argument and that is an integer. If there are two such numbers, * then the one that is even is returned. */ void xmlXPathRoundFunction(xmlXPathParserContextPtr ctxt, int nargs) { double f; CHECK_ARITY(1); CAST_TO_NUMBER; CHECK_TYPE(XPATH_NUMBER); if ((xmlXPathIsNaN(ctxt->value->floatval)) || (xmlXPathIsInf(ctxt->value->floatval) == 1) || (xmlXPathIsInf(ctxt->value->floatval) == -1) || (ctxt->value->floatval == 0.0)) return; XTRUNC(f, ctxt->value->floatval); if (ctxt->value->floatval < 0) { if (ctxt->value->floatval < f - 0.5) ctxt->value->floatval = f - 1; else ctxt->value->floatval = f; if (ctxt->value->floatval == 0) ctxt->value->floatval = xmlXPathNZERO; } else { if (ctxt->value->floatval < f + 0.5) ctxt->value->floatval = f; else ctxt->value->floatval = f + 1; } } /************************************************************************ * * * The Parser * * * ************************************************************************/ /* * a few forward declarations since we use a recursive call based * implementation. */ static void xmlXPathCompileExpr(xmlXPathParserContextPtr ctxt, int sort); static void xmlXPathCompPredicate(xmlXPathParserContextPtr ctxt, int filter); static void xmlXPathCompLocationPath(xmlXPathParserContextPtr ctxt); static void xmlXPathCompRelativeLocationPath(xmlXPathParserContextPtr ctxt); static xmlChar * xmlXPathParseNameComplex(xmlXPathParserContextPtr ctxt, int qualified); /** * xmlXPathCurrentChar: * @ctxt: the XPath parser context * @cur: pointer to the beginning of the char * @len: pointer to the length of the char read * * The current char value, if using UTF-8 this may actually span multiple * bytes in the input buffer. * * Returns the current char value and its length */ static int xmlXPathCurrentChar(xmlXPathParserContextPtr ctxt, int *len) { unsigned char c; unsigned int val; const xmlChar *cur; if (ctxt == NULL) return(0); cur = ctxt->cur; /* * We are supposed to handle UTF8, check it's valid * From rfc2044: encoding of the Unicode values on UTF-8: * * UCS-4 range (hex.) UTF-8 octet sequence (binary) * 0000 0000-0000 007F 0xxxxxxx * 0000 0080-0000 07FF 110xxxxx 10xxxxxx * 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx * * Check for the 0x110000 limit too */ c = *cur; if (c & 0x80) { if ((cur[1] & 0xc0) != 0x80) goto encoding_error; if ((c & 0xe0) == 0xe0) { if ((cur[2] & 0xc0) != 0x80) goto encoding_error; if ((c & 0xf0) == 0xf0) { if (((c & 0xf8) != 0xf0) || ((cur[3] & 0xc0) != 0x80)) goto encoding_error; /* 4-byte code */ *len = 4; val = (cur[0] & 0x7) << 18; val |= (cur[1] & 0x3f) << 12; val |= (cur[2] & 0x3f) << 6; val |= cur[3] & 0x3f; } else { /* 3-byte code */ *len = 3; val = (cur[0] & 0xf) << 12; val |= (cur[1] & 0x3f) << 6; val |= cur[2] & 0x3f; } } else { /* 2-byte code */ *len = 2; val = (cur[0] & 0x1f) << 6; val |= cur[1] & 0x3f; } if (!IS_CHAR(val)) { XP_ERROR0(XPATH_INVALID_CHAR_ERROR); } return(val); } else { /* 1-byte code */ *len = 1; return((int) *cur); } encoding_error: /* * If we detect an UTF8 error that probably means that the * input encoding didn't get properly advertised in the * declaration header. Report the error and switch the encoding * to ISO-Latin-1 (if you don't like this policy, just declare the * encoding !) */ *len = 0; XP_ERROR0(XPATH_ENCODING_ERROR); } /** * xmlXPathParseNCName: * @ctxt: the XPath Parser context * * parse an XML namespace non qualified name. * * [NS 3] NCName ::= (Letter | '_') (NCNameChar)* * * [NS 4] NCNameChar ::= Letter | Digit | '.' | '-' | '_' | * CombiningChar | Extender * * Returns the namespace name or NULL */ xmlChar * xmlXPathParseNCName(xmlXPathParserContextPtr ctxt) { const xmlChar *in; xmlChar *ret; int count = 0; if ((ctxt == NULL) || (ctxt->cur == NULL)) return(NULL); /* * Accelerator for simple ASCII names */ in = ctxt->cur; if (((*in >= 0x61) && (*in <= 0x7A)) || ((*in >= 0x41) && (*in <= 0x5A)) || (*in == '_')) { in++; while (((*in >= 0x61) && (*in <= 0x7A)) || ((*in >= 0x41) && (*in <= 0x5A)) || ((*in >= 0x30) && (*in <= 0x39)) || (*in == '_') || (*in == '.') || (*in == '-')) in++; if ((*in == ' ') || (*in == '>') || (*in == '/') || (*in == '[') || (*in == ']') || (*in == ':') || (*in == '@') || (*in == '*')) { count = in - ctxt->cur; if (count == 0) return(NULL); ret = xmlStrndup(ctxt->cur, count); ctxt->cur = in; return(ret); } } return(xmlXPathParseNameComplex(ctxt, 0)); } /** * xmlXPathParseQName: * @ctxt: the XPath Parser context * @prefix: a xmlChar ** * * parse an XML qualified name * * [NS 5] QName ::= (Prefix ':')? LocalPart * * [NS 6] Prefix ::= NCName * * [NS 7] LocalPart ::= NCName * * Returns the function returns the local part, and prefix is updated * to get the Prefix if any. */ static xmlChar * xmlXPathParseQName(xmlXPathParserContextPtr ctxt, xmlChar **prefix) { xmlChar *ret = NULL; *prefix = NULL; ret = xmlXPathParseNCName(ctxt); if (CUR == ':') { *prefix = ret; NEXT; ret = xmlXPathParseNCName(ctxt); } return(ret); } /** * xmlXPathParseName: * @ctxt: the XPath Parser context * * parse an XML name * * [4] NameChar ::= Letter | Digit | '.' | '-' | '_' | ':' | * CombiningChar | Extender * * [5] Name ::= (Letter | '_' | ':') (NameChar)* * * Returns the namespace name or NULL */ xmlChar * xmlXPathParseName(xmlXPathParserContextPtr ctxt) { const xmlChar *in; xmlChar *ret; int count = 0; if ((ctxt == NULL) || (ctxt->cur == NULL)) return(NULL); /* * Accelerator for simple ASCII names */ in = ctxt->cur; if (((*in >= 0x61) && (*in <= 0x7A)) || ((*in >= 0x41) && (*in <= 0x5A)) || (*in == '_') || (*in == ':')) { in++; while (((*in >= 0x61) && (*in <= 0x7A)) || ((*in >= 0x41) && (*in <= 0x5A)) || ((*in >= 0x30) && (*in <= 0x39)) || (*in == '_') || (*in == '-') || (*in == ':') || (*in == '.')) in++; if ((*in > 0) && (*in < 0x80)) { count = in - ctxt->cur; ret = xmlStrndup(ctxt->cur, count); ctxt->cur = in; return(ret); } } return(xmlXPathParseNameComplex(ctxt, 1)); } static xmlChar * xmlXPathParseNameComplex(xmlXPathParserContextPtr ctxt, int qualified) { xmlChar buf[XML_MAX_NAMELEN + 5]; int len = 0, l; int c; /* * Handler for more complex cases */ c = CUR_CHAR(l); if ((c == ' ') || (c == '>') || (c == '/') || /* accelerators */ (c == '[') || (c == ']') || (c == '@') || /* accelerators */ (c == '*') || /* accelerators */ (!IS_LETTER(c) && (c != '_') && ((qualified) && (c != ':')))) { return(NULL); } while ((c != ' ') && (c != '>') && (c != '/') && /* test bigname.xml */ ((IS_LETTER(c)) || (IS_DIGIT(c)) || (c == '.') || (c == '-') || (c == '_') || ((qualified) && (c == ':')) || (IS_COMBINING(c)) || (IS_EXTENDER(c)))) { COPY_BUF(l,buf,len,c); NEXTL(l); c = CUR_CHAR(l); if (len >= XML_MAX_NAMELEN) { /* * Okay someone managed to make a huge name, so he's ready to pay * for the processing speed. */ xmlChar *buffer; int max = len * 2; buffer = (xmlChar *) xmlMallocAtomic(max * sizeof(xmlChar)); if (buffer == NULL) { XP_ERRORNULL(XPATH_MEMORY_ERROR); } memcpy(buffer, buf, len); while ((IS_LETTER(c)) || (IS_DIGIT(c)) || /* test bigname.xml */ (c == '.') || (c == '-') || (c == '_') || ((qualified) && (c == ':')) || (IS_COMBINING(c)) || (IS_EXTENDER(c))) { if (len + 10 > max) { max *= 2; buffer = (xmlChar *) xmlRealloc(buffer, max * sizeof(xmlChar)); if (buffer == NULL) { XP_ERRORNULL(XPATH_MEMORY_ERROR); } } COPY_BUF(l,buffer,len,c); NEXTL(l); c = CUR_CHAR(l); } buffer[len] = 0; return(buffer); } } if (len == 0) return(NULL); return(xmlStrndup(buf, len)); } #define MAX_FRAC 20 /* * These are used as divisors for the fractional part of a number. * Since the table includes 1.0 (representing '0' fractional digits), * it must be dimensioned at MAX_FRAC+1 (bug 133921) */ static double my_pow10[MAX_FRAC+1] = { 1.0, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, 10000000.0, 100000000.0, 1000000000.0, 10000000000.0, 100000000000.0, 1000000000000.0, 10000000000000.0, 100000000000000.0, 1000000000000000.0, 10000000000000000.0, 100000000000000000.0, 1000000000000000000.0, 10000000000000000000.0, 100000000000000000000.0 }; /** * xmlXPathStringEvalNumber: * @str: A string to scan * * [30a] Float ::= Number ('e' Digits?)? * * [30] Number ::= Digits ('.' Digits?)? * | '.' Digits * [31] Digits ::= [0-9]+ * * Compile a Number in the string * In complement of the Number expression, this function also handles * negative values : '-' Number. * * Returns the double value. */ double xmlXPathStringEvalNumber(const xmlChar *str) { const xmlChar *cur = str; double ret; int ok = 0; int isneg = 0; int exponent = 0; int is_exponent_negative = 0; #ifdef __GNUC__ unsigned long tmp = 0; double temp; #endif if (cur == NULL) return(0); while (IS_BLANK_CH(*cur)) cur++; if ((*cur != '.') && ((*cur < '0') || (*cur > '9')) && (*cur != '-')) { return(xmlXPathNAN); } if (*cur == '-') { isneg = 1; cur++; } #ifdef __GNUC__ /* * tmp/temp is a workaround against a gcc compiler bug * http://veillard.com/gcc.bug */ ret = 0; while ((*cur >= '0') && (*cur <= '9')) { ret = ret * 10; tmp = (*cur - '0'); ok = 1; cur++; temp = (double) tmp; ret = ret + temp; } #else ret = 0; while ((*cur >= '0') && (*cur <= '9')) { ret = ret * 10 + (*cur - '0'); ok = 1; cur++; } #endif if (*cur == '.') { int v, frac = 0; double fraction = 0; cur++; if (((*cur < '0') || (*cur > '9')) && (!ok)) { return(xmlXPathNAN); } while (((*cur >= '0') && (*cur <= '9')) && (frac < MAX_FRAC)) { v = (*cur - '0'); fraction = fraction * 10 + v; frac = frac + 1; cur++; } fraction /= my_pow10[frac]; ret = ret + fraction; while ((*cur >= '0') && (*cur <= '9')) cur++; } if ((*cur == 'e') || (*cur == 'E')) { cur++; if (*cur == '-') { is_exponent_negative = 1; cur++; } else if (*cur == '+') { cur++; } while ((*cur >= '0') && (*cur <= '9')) { exponent = exponent * 10 + (*cur - '0'); cur++; } } while (IS_BLANK_CH(*cur)) cur++; if (*cur != 0) return(xmlXPathNAN); if (isneg) ret = -ret; if (is_exponent_negative) exponent = -exponent; ret *= pow(10.0, (double)exponent); return(ret); } /** * xmlXPathCompNumber: * @ctxt: the XPath Parser context * * [30] Number ::= Digits ('.' Digits?)? * | '.' Digits * [31] Digits ::= [0-9]+ * * Compile a Number, then push it on the stack * */ static void xmlXPathCompNumber(xmlXPathParserContextPtr ctxt) { double ret = 0.0; double mult = 1; int ok = 0; int exponent = 0; int is_exponent_negative = 0; #ifdef __GNUC__ unsigned long tmp = 0; double temp; #endif CHECK_ERROR; if ((CUR != '.') && ((CUR < '0') || (CUR > '9'))) { XP_ERROR(XPATH_NUMBER_ERROR); } #ifdef __GNUC__ /* * tmp/temp is a workaround against a gcc compiler bug * http://veillard.com/gcc.bug */ ret = 0; while ((CUR >= '0') && (CUR <= '9')) { ret = ret * 10; tmp = (CUR - '0'); ok = 1; NEXT; temp = (double) tmp; ret = ret + temp; } #else ret = 0; while ((CUR >= '0') && (CUR <= '9')) { ret = ret * 10 + (CUR - '0'); ok = 1; NEXT; } #endif if (CUR == '.') { NEXT; if (((CUR < '0') || (CUR > '9')) && (!ok)) { XP_ERROR(XPATH_NUMBER_ERROR); } while ((CUR >= '0') && (CUR <= '9')) { mult /= 10; ret = ret + (CUR - '0') * mult; NEXT; } } if ((CUR == 'e') || (CUR == 'E')) { NEXT; if (CUR == '-') { is_exponent_negative = 1; NEXT; } else if (CUR == '+') { NEXT; } while ((CUR >= '0') && (CUR <= '9')) { exponent = exponent * 10 + (CUR - '0'); NEXT; } if (is_exponent_negative) exponent = -exponent; ret *= pow(10.0, (double) exponent); } PUSH_LONG_EXPR(XPATH_OP_VALUE, XPATH_NUMBER, 0, 0, xmlXPathCacheNewFloat(ctxt->context, ret), NULL); } /** * xmlXPathParseLiteral: * @ctxt: the XPath Parser context * * Parse a Literal * * [29] Literal ::= '"' [^"]* '"' * | "'" [^']* "'" * * Returns the value found or NULL in case of error */ static xmlChar * xmlXPathParseLiteral(xmlXPathParserContextPtr ctxt) { const xmlChar *q; xmlChar *ret = NULL; if (CUR == '"') { NEXT; q = CUR_PTR; while ((IS_CHAR_CH(CUR)) && (CUR != '"')) NEXT; if (!IS_CHAR_CH(CUR)) { XP_ERRORNULL(XPATH_UNFINISHED_LITERAL_ERROR); } else { ret = xmlStrndup(q, CUR_PTR - q); NEXT; } } else if (CUR == '\'') { NEXT; q = CUR_PTR; while ((IS_CHAR_CH(CUR)) && (CUR != '\'')) NEXT; if (!IS_CHAR_CH(CUR)) { XP_ERRORNULL(XPATH_UNFINISHED_LITERAL_ERROR); } else { ret = xmlStrndup(q, CUR_PTR - q); NEXT; } } else { XP_ERRORNULL(XPATH_START_LITERAL_ERROR); } return(ret); } /** * xmlXPathCompLiteral: * @ctxt: the XPath Parser context * * Parse a Literal and push it on the stack. * * [29] Literal ::= '"' [^"]* '"' * | "'" [^']* "'" * * TODO: xmlXPathCompLiteral memory allocation could be improved. */ static void xmlXPathCompLiteral(xmlXPathParserContextPtr ctxt) { const xmlChar *q; xmlChar *ret = NULL; if (CUR == '"') { NEXT; q = CUR_PTR; while ((IS_CHAR_CH(CUR)) && (CUR != '"')) NEXT; if (!IS_CHAR_CH(CUR)) { XP_ERROR(XPATH_UNFINISHED_LITERAL_ERROR); } else { ret = xmlStrndup(q, CUR_PTR - q); NEXT; } } else if (CUR == '\'') { NEXT; q = CUR_PTR; while ((IS_CHAR_CH(CUR)) && (CUR != '\'')) NEXT; if (!IS_CHAR_CH(CUR)) { XP_ERROR(XPATH_UNFINISHED_LITERAL_ERROR); } else { ret = xmlStrndup(q, CUR_PTR - q); NEXT; } } else { XP_ERROR(XPATH_START_LITERAL_ERROR); } if (ret == NULL) return; PUSH_LONG_EXPR(XPATH_OP_VALUE, XPATH_STRING, 0, 0, xmlXPathCacheNewString(ctxt->context, ret), NULL); xmlFree(ret); } /** * xmlXPathCompVariableReference: * @ctxt: the XPath Parser context * * Parse a VariableReference, evaluate it and push it on the stack. * * The variable bindings consist of a mapping from variable names * to variable values. The value of a variable is an object, which can be * of any of the types that are possible for the value of an expression, * and may also be of additional types not specified here. * * Early evaluation is possible since: * The variable bindings [...] used to evaluate a subexpression are * always the same as those used to evaluate the containing expression. * * [36] VariableReference ::= '$' QName */ static void xmlXPathCompVariableReference(xmlXPathParserContextPtr ctxt) { xmlChar *name; xmlChar *prefix; SKIP_BLANKS; if (CUR != '$') { XP_ERROR(XPATH_VARIABLE_REF_ERROR); } NEXT; name = xmlXPathParseQName(ctxt, &prefix); if (name == NULL) { XP_ERROR(XPATH_VARIABLE_REF_ERROR); } ctxt->comp->last = -1; PUSH_LONG_EXPR(XPATH_OP_VARIABLE, 0, 0, 0, name, prefix); SKIP_BLANKS; if ((ctxt->context != NULL) && (ctxt->context->flags & XML_XPATH_NOVAR)) { XP_ERROR(XPATH_UNDEF_VARIABLE_ERROR); } } /** * xmlXPathIsNodeType: * @name: a name string * * Is the name given a NodeType one. * * [38] NodeType ::= 'comment' * | 'text' * | 'processing-instruction' * | 'node' * * Returns 1 if true 0 otherwise */ int xmlXPathIsNodeType(const xmlChar *name) { if (name == NULL) return(0); if (xmlStrEqual(name, BAD_CAST "node")) return(1); if (xmlStrEqual(name, BAD_CAST "text")) return(1); if (xmlStrEqual(name, BAD_CAST "comment")) return(1); if (xmlStrEqual(name, BAD_CAST "processing-instruction")) return(1); return(0); } /** * xmlXPathCompFunctionCall: * @ctxt: the XPath Parser context * * [16] FunctionCall ::= FunctionName '(' ( Argument ( ',' Argument)*)? ')' * [17] Argument ::= Expr * * Compile a function call, the evaluation of all arguments are * pushed on the stack */ static void xmlXPathCompFunctionCall(xmlXPathParserContextPtr ctxt) { xmlChar *name; xmlChar *prefix; int nbargs = 0; int sort = 1; name = xmlXPathParseQName(ctxt, &prefix); if (name == NULL) { XP_ERROR(XPATH_EXPR_ERROR); } SKIP_BLANKS; #ifdef DEBUG_EXPR if (prefix == NULL) xmlGenericError(xmlGenericErrorContext, "Calling function %s\n", name); else xmlGenericError(xmlGenericErrorContext, "Calling function %s:%s\n", prefix, name); #endif if (CUR != '(') { XP_ERROR(XPATH_EXPR_ERROR); } NEXT; SKIP_BLANKS; /* * Optimization for count(): we don't need the node-set to be sorted. */ if ((prefix == NULL) && (name[0] == 'c') && xmlStrEqual(name, BAD_CAST "count")) { sort = 0; } ctxt->comp->last = -1; if (CUR != ')') { while (CUR != 0) { int op1 = ctxt->comp->last; ctxt->comp->last = -1; xmlXPathCompileExpr(ctxt, sort); CHECK_ERROR; PUSH_BINARY_EXPR(XPATH_OP_ARG, op1, ctxt->comp->last, 0, 0); nbargs++; if (CUR == ')') break; if (CUR != ',') { XP_ERROR(XPATH_EXPR_ERROR); } NEXT; SKIP_BLANKS; } } PUSH_LONG_EXPR(XPATH_OP_FUNCTION, nbargs, 0, 0, name, prefix); NEXT; SKIP_BLANKS; } /** * xmlXPathCompPrimaryExpr: * @ctxt: the XPath Parser context * * [15] PrimaryExpr ::= VariableReference * | '(' Expr ')' * | Literal * | Number * | FunctionCall * * Compile a primary expression. */ static void xmlXPathCompPrimaryExpr(xmlXPathParserContextPtr ctxt) { SKIP_BLANKS; if (CUR == '$') xmlXPathCompVariableReference(ctxt); else if (CUR == '(') { NEXT; SKIP_BLANKS; xmlXPathCompileExpr(ctxt, 1); CHECK_ERROR; if (CUR != ')') { XP_ERROR(XPATH_EXPR_ERROR); } NEXT; SKIP_BLANKS; } else if (IS_ASCII_DIGIT(CUR) || (CUR == '.' && IS_ASCII_DIGIT(NXT(1)))) { xmlXPathCompNumber(ctxt); } else if ((CUR == '\'') || (CUR == '"')) { xmlXPathCompLiteral(ctxt); } else { xmlXPathCompFunctionCall(ctxt); } SKIP_BLANKS; } /** * xmlXPathCompFilterExpr: * @ctxt: the XPath Parser context * * [20] FilterExpr ::= PrimaryExpr * | FilterExpr Predicate * * Compile a filter expression. * Square brackets are used to filter expressions in the same way that * they are used in location paths. It is an error if the expression to * be filtered does not evaluate to a node-set. The context node list * used for evaluating the expression in square brackets is the node-set * to be filtered listed in document order. */ static void xmlXPathCompFilterExpr(xmlXPathParserContextPtr ctxt) { xmlXPathCompPrimaryExpr(ctxt); CHECK_ERROR; SKIP_BLANKS; while (CUR == '[') { xmlXPathCompPredicate(ctxt, 1); SKIP_BLANKS; } } /** * xmlXPathScanName: * @ctxt: the XPath Parser context * * Trickery: parse an XML name but without consuming the input flow * Needed to avoid insanity in the parser state. * * [4] NameChar ::= Letter | Digit | '.' | '-' | '_' | ':' | * CombiningChar | Extender * * [5] Name ::= (Letter | '_' | ':') (NameChar)* * * [6] Names ::= Name (S Name)* * * Returns the Name parsed or NULL */ static xmlChar * xmlXPathScanName(xmlXPathParserContextPtr ctxt) { int len = 0, l; int c; const xmlChar *cur; xmlChar *ret; cur = ctxt->cur; c = CUR_CHAR(l); if ((c == ' ') || (c == '>') || (c == '/') || /* accelerators */ (!IS_LETTER(c) && (c != '_') && (c != ':'))) { return(NULL); } while ((c != ' ') && (c != '>') && (c != '/') && /* test bigname.xml */ ((IS_LETTER(c)) || (IS_DIGIT(c)) || (c == '.') || (c == '-') || (c == '_') || (c == ':') || (IS_COMBINING(c)) || (IS_EXTENDER(c)))) { len += l; NEXTL(l); c = CUR_CHAR(l); } ret = xmlStrndup(cur, ctxt->cur - cur); ctxt->cur = cur; return(ret); } /** * xmlXPathCompPathExpr: * @ctxt: the XPath Parser context * * [19] PathExpr ::= LocationPath * | FilterExpr * | FilterExpr '/' RelativeLocationPath * | FilterExpr '//' RelativeLocationPath * * Compile a path expression. * The / operator and // operators combine an arbitrary expression * and a relative location path. It is an error if the expression * does not evaluate to a node-set. * The / operator does composition in the same way as when / is * used in a location path. As in location paths, // is short for * /descendant-or-self::node()/. */ static void xmlXPathCompPathExpr(xmlXPathParserContextPtr ctxt) { int lc = 1; /* Should we branch to LocationPath ? */ xmlChar *name = NULL; /* we may have to preparse a name to find out */ SKIP_BLANKS; if ((CUR == '$') || (CUR == '(') || (IS_ASCII_DIGIT(CUR)) || (CUR == '\'') || (CUR == '"') || (CUR == '.' && IS_ASCII_DIGIT(NXT(1)))) { lc = 0; } else if (CUR == '*') { /* relative or absolute location path */ lc = 1; } else if (CUR == '/') { /* relative or absolute location path */ lc = 1; } else if (CUR == '@') { /* relative abbreviated attribute location path */ lc = 1; } else if (CUR == '.') { /* relative abbreviated attribute location path */ lc = 1; } else { /* * Problem is finding if we have a name here whether it's: * - a nodetype * - a function call in which case it's followed by '(' * - an axis in which case it's followed by ':' * - a element name * We do an a priori analysis here rather than having to * maintain parsed token content through the recursive function * calls. This looks uglier but makes the code easier to * read/write/debug. */ SKIP_BLANKS; name = xmlXPathScanName(ctxt); if ((name != NULL) && (xmlStrstr(name, (xmlChar *) "::") != NULL)) { #ifdef DEBUG_STEP xmlGenericError(xmlGenericErrorContext, "PathExpr: Axis\n"); #endif lc = 1; xmlFree(name); } else if (name != NULL) { int len =xmlStrlen(name); while (NXT(len) != 0) { if (NXT(len) == '/') { /* element name */ #ifdef DEBUG_STEP xmlGenericError(xmlGenericErrorContext, "PathExpr: AbbrRelLocation\n"); #endif lc = 1; break; } else if (IS_BLANK_CH(NXT(len))) { /* ignore blanks */ ; } else if (NXT(len) == ':') { #ifdef DEBUG_STEP xmlGenericError(xmlGenericErrorContext, "PathExpr: AbbrRelLocation\n"); #endif lc = 1; break; } else if ((NXT(len) == '(')) { /* Note Type or Function */ if (xmlXPathIsNodeType(name)) { #ifdef DEBUG_STEP xmlGenericError(xmlGenericErrorContext, "PathExpr: Type search\n"); #endif lc = 1; } else { #ifdef DEBUG_STEP xmlGenericError(xmlGenericErrorContext, "PathExpr: function call\n"); #endif lc = 0; } break; } else if ((NXT(len) == '[')) { /* element name */ #ifdef DEBUG_STEP xmlGenericError(xmlGenericErrorContext, "PathExpr: AbbrRelLocation\n"); #endif lc = 1; break; } else if ((NXT(len) == '<') || (NXT(len) == '>') || (NXT(len) == '=')) { lc = 1; break; } else { lc = 1; break; } len++; } if (NXT(len) == 0) { #ifdef DEBUG_STEP xmlGenericError(xmlGenericErrorContext, "PathExpr: AbbrRelLocation\n"); #endif /* element name */ lc = 1; } xmlFree(name); } else { /* make sure all cases are covered explicitly */ XP_ERROR(XPATH_EXPR_ERROR); } } if (lc) { if (CUR == '/') { PUSH_LEAVE_EXPR(XPATH_OP_ROOT, 0, 0); } else { PUSH_LEAVE_EXPR(XPATH_OP_NODE, 0, 0); } xmlXPathCompLocationPath(ctxt); } else { xmlXPathCompFilterExpr(ctxt); CHECK_ERROR; if ((CUR == '/') && (NXT(1) == '/')) { SKIP(2); SKIP_BLANKS; PUSH_LONG_EXPR(XPATH_OP_COLLECT, AXIS_DESCENDANT_OR_SELF, NODE_TEST_TYPE, NODE_TYPE_NODE, NULL, NULL); PUSH_UNARY_EXPR(XPATH_OP_RESET, ctxt->comp->last, 1, 0); xmlXPathCompRelativeLocationPath(ctxt); } else if (CUR == '/') { xmlXPathCompRelativeLocationPath(ctxt); } } SKIP_BLANKS; } /** * xmlXPathCompUnionExpr: * @ctxt: the XPath Parser context * * [18] UnionExpr ::= PathExpr * | UnionExpr '|' PathExpr * * Compile an union expression. */ static void xmlXPathCompUnionExpr(xmlXPathParserContextPtr ctxt) { xmlXPathCompPathExpr(ctxt); CHECK_ERROR; SKIP_BLANKS; while (CUR == '|') { int op1 = ctxt->comp->last; PUSH_LEAVE_EXPR(XPATH_OP_NODE, 0, 0); NEXT; SKIP_BLANKS; xmlXPathCompPathExpr(ctxt); PUSH_BINARY_EXPR(XPATH_OP_UNION, op1, ctxt->comp->last, 0, 0); SKIP_BLANKS; } } /** * xmlXPathCompUnaryExpr: * @ctxt: the XPath Parser context * * [27] UnaryExpr ::= UnionExpr * | '-' UnaryExpr * * Compile an unary expression. */ static void xmlXPathCompUnaryExpr(xmlXPathParserContextPtr ctxt) { int minus = 0; int found = 0; SKIP_BLANKS; while (CUR == '-') { minus = 1 - minus; found = 1; NEXT; SKIP_BLANKS; } xmlXPathCompUnionExpr(ctxt); CHECK_ERROR; if (found) { if (minus) PUSH_UNARY_EXPR(XPATH_OP_PLUS, ctxt->comp->last, 2, 0); else PUSH_UNARY_EXPR(XPATH_OP_PLUS, ctxt->comp->last, 3, 0); } } /** * xmlXPathCompMultiplicativeExpr: * @ctxt: the XPath Parser context * * [26] MultiplicativeExpr ::= UnaryExpr * | MultiplicativeExpr MultiplyOperator UnaryExpr * | MultiplicativeExpr 'div' UnaryExpr * | MultiplicativeExpr 'mod' UnaryExpr * [34] MultiplyOperator ::= '*' * * Compile an Additive expression. */ static void xmlXPathCompMultiplicativeExpr(xmlXPathParserContextPtr ctxt) { xmlXPathCompUnaryExpr(ctxt); CHECK_ERROR; SKIP_BLANKS; while ((CUR == '*') || ((CUR == 'd') && (NXT(1) == 'i') && (NXT(2) == 'v')) || ((CUR == 'm') && (NXT(1) == 'o') && (NXT(2) == 'd'))) { int op = -1; int op1 = ctxt->comp->last; if (CUR == '*') { op = 0; NEXT; } else if (CUR == 'd') { op = 1; SKIP(3); } else if (CUR == 'm') { op = 2; SKIP(3); } SKIP_BLANKS; xmlXPathCompUnaryExpr(ctxt); CHECK_ERROR; PUSH_BINARY_EXPR(XPATH_OP_MULT, op1, ctxt->comp->last, op, 0); SKIP_BLANKS; } } /** * xmlXPathCompAdditiveExpr: * @ctxt: the XPath Parser context * * [25] AdditiveExpr ::= MultiplicativeExpr * | AdditiveExpr '+' MultiplicativeExpr * | AdditiveExpr '-' MultiplicativeExpr * * Compile an Additive expression. */ static void xmlXPathCompAdditiveExpr(xmlXPathParserContextPtr ctxt) { xmlXPathCompMultiplicativeExpr(ctxt); CHECK_ERROR; SKIP_BLANKS; while ((CUR == '+') || (CUR == '-')) { int plus; int op1 = ctxt->comp->last; if (CUR == '+') plus = 1; else plus = 0; NEXT; SKIP_BLANKS; xmlXPathCompMultiplicativeExpr(ctxt); CHECK_ERROR; PUSH_BINARY_EXPR(XPATH_OP_PLUS, op1, ctxt->comp->last, plus, 0); SKIP_BLANKS; } } /** * xmlXPathCompRelationalExpr: * @ctxt: the XPath Parser context * * [24] RelationalExpr ::= AdditiveExpr * | RelationalExpr '<' AdditiveExpr * | RelationalExpr '>' AdditiveExpr * | RelationalExpr '<=' AdditiveExpr * | RelationalExpr '>=' AdditiveExpr * * A <= B > C is allowed ? Answer from James, yes with * (AdditiveExpr <= AdditiveExpr) > AdditiveExpr * which is basically what got implemented. * * Compile a Relational expression, then push the result * on the stack */ static void xmlXPathCompRelationalExpr(xmlXPathParserContextPtr ctxt) { xmlXPathCompAdditiveExpr(ctxt); CHECK_ERROR; SKIP_BLANKS; while ((CUR == '<') || (CUR == '>') || ((CUR == '<') && (NXT(1) == '=')) || ((CUR == '>') && (NXT(1) == '='))) { int inf, strict; int op1 = ctxt->comp->last; if (CUR == '<') inf = 1; else inf = 0; if (NXT(1) == '=') strict = 0; else strict = 1; NEXT; if (!strict) NEXT; SKIP_BLANKS; xmlXPathCompAdditiveExpr(ctxt); CHECK_ERROR; PUSH_BINARY_EXPR(XPATH_OP_CMP, op1, ctxt->comp->last, inf, strict); SKIP_BLANKS; } } /** * xmlXPathCompEqualityExpr: * @ctxt: the XPath Parser context * * [23] EqualityExpr ::= RelationalExpr * | EqualityExpr '=' RelationalExpr * | EqualityExpr '!=' RelationalExpr * * A != B != C is allowed ? Answer from James, yes with * (RelationalExpr = RelationalExpr) = RelationalExpr * (RelationalExpr != RelationalExpr) != RelationalExpr * which is basically what got implemented. * * Compile an Equality expression. * */ static void xmlXPathCompEqualityExpr(xmlXPathParserContextPtr ctxt) { xmlXPathCompRelationalExpr(ctxt); CHECK_ERROR; SKIP_BLANKS; while ((CUR == '=') || ((CUR == '!') && (NXT(1) == '='))) { int eq; int op1 = ctxt->comp->last; if (CUR == '=') eq = 1; else eq = 0; NEXT; if (!eq) NEXT; SKIP_BLANKS; xmlXPathCompRelationalExpr(ctxt); CHECK_ERROR; PUSH_BINARY_EXPR(XPATH_OP_EQUAL, op1, ctxt->comp->last, eq, 0); SKIP_BLANKS; } } /** * xmlXPathCompAndExpr: * @ctxt: the XPath Parser context * * [22] AndExpr ::= EqualityExpr * | AndExpr 'and' EqualityExpr * * Compile an AND expression. * */ static void xmlXPathCompAndExpr(xmlXPathParserContextPtr ctxt) { xmlXPathCompEqualityExpr(ctxt); CHECK_ERROR; SKIP_BLANKS; while ((CUR == 'a') && (NXT(1) == 'n') && (NXT(2) == 'd')) { int op1 = ctxt->comp->last; SKIP(3); SKIP_BLANKS; xmlXPathCompEqualityExpr(ctxt); CHECK_ERROR; PUSH_BINARY_EXPR(XPATH_OP_AND, op1, ctxt->comp->last, 0, 0); SKIP_BLANKS; } } /** * xmlXPathCompileExpr: * @ctxt: the XPath Parser context * * [14] Expr ::= OrExpr * [21] OrExpr ::= AndExpr * | OrExpr 'or' AndExpr * * Parse and compile an expression */ static void xmlXPathCompileExpr(xmlXPathParserContextPtr ctxt, int sort) { xmlXPathCompAndExpr(ctxt); CHECK_ERROR; SKIP_BLANKS; while ((CUR == 'o') && (NXT(1) == 'r')) { int op1 = ctxt->comp->last; SKIP(2); SKIP_BLANKS; xmlXPathCompAndExpr(ctxt); CHECK_ERROR; PUSH_BINARY_EXPR(XPATH_OP_OR, op1, ctxt->comp->last, 0, 0); op1 = ctxt->comp->nbStep; SKIP_BLANKS; } if ((sort) && (ctxt->comp->steps[ctxt->comp->last].op != XPATH_OP_VALUE)) { /* more ops could be optimized too */ /* * This is the main place to eliminate sorting for * operations which don't require a sorted node-set. * E.g. count(). */ PUSH_UNARY_EXPR(XPATH_OP_SORT, ctxt->comp->last , 0, 0); } } /** * xmlXPathCompPredicate: * @ctxt: the XPath Parser context * @filter: act as a filter * * [8] Predicate ::= '[' PredicateExpr ']' * [9] PredicateExpr ::= Expr * * Compile a predicate expression */ static void xmlXPathCompPredicate(xmlXPathParserContextPtr ctxt, int filter) { int op1 = ctxt->comp->last; SKIP_BLANKS; if (CUR != '[') { XP_ERROR(XPATH_INVALID_PREDICATE_ERROR); } NEXT; SKIP_BLANKS; ctxt->comp->last = -1; /* * This call to xmlXPathCompileExpr() will deactivate sorting * of the predicate result. * TODO: Sorting is still activated for filters, since I'm not * sure if needed. Normally sorting should not be needed, since * a filter can only diminish the number of items in a sequence, * but won't change its order; so if the initial sequence is sorted, * subsequent sorting is not needed. */ if (! filter) xmlXPathCompileExpr(ctxt, 0); else xmlXPathCompileExpr(ctxt, 1); CHECK_ERROR; if (CUR != ']') { XP_ERROR(XPATH_INVALID_PREDICATE_ERROR); } if (filter) PUSH_BINARY_EXPR(XPATH_OP_FILTER, op1, ctxt->comp->last, 0, 0); else PUSH_BINARY_EXPR(XPATH_OP_PREDICATE, op1, ctxt->comp->last, 0, 0); NEXT; SKIP_BLANKS; } /** * xmlXPathCompNodeTest: * @ctxt: the XPath Parser context * @test: pointer to a xmlXPathTestVal * @type: pointer to a xmlXPathTypeVal * @prefix: placeholder for a possible name prefix * * [7] NodeTest ::= NameTest * | NodeType '(' ')' * | 'processing-instruction' '(' Literal ')' * * [37] NameTest ::= '*' * | NCName ':' '*' * | QName * [38] NodeType ::= 'comment' * | 'text' * | 'processing-instruction' * | 'node' * * Returns the name found and updates @test, @type and @prefix appropriately */ static xmlChar * xmlXPathCompNodeTest(xmlXPathParserContextPtr ctxt, xmlXPathTestVal *test, xmlXPathTypeVal *type, const xmlChar **prefix, xmlChar *name) { int blanks; if ((test == NULL) || (type == NULL) || (prefix == NULL)) { STRANGE; return(NULL); } *type = (xmlXPathTypeVal) 0; *test = (xmlXPathTestVal) 0; *prefix = NULL; SKIP_BLANKS; if ((name == NULL) && (CUR == '*')) { /* * All elements */ NEXT; *test = NODE_TEST_ALL; return(NULL); } if (name == NULL) name = xmlXPathParseNCName(ctxt); if (name == NULL) { XP_ERRORNULL(XPATH_EXPR_ERROR); } blanks = IS_BLANK_CH(CUR); SKIP_BLANKS; if (CUR == '(') { NEXT; /* * NodeType or PI search */ if (xmlStrEqual(name, BAD_CAST "comment")) *type = NODE_TYPE_COMMENT; else if (xmlStrEqual(name, BAD_CAST "node")) *type = NODE_TYPE_NODE; else if (xmlStrEqual(name, BAD_CAST "processing-instruction")) *type = NODE_TYPE_PI; else if (xmlStrEqual(name, BAD_CAST "text")) *type = NODE_TYPE_TEXT; else { if (name != NULL) xmlFree(name); XP_ERRORNULL(XPATH_EXPR_ERROR); } *test = NODE_TEST_TYPE; SKIP_BLANKS; if (*type == NODE_TYPE_PI) { /* * Specific case: search a PI by name. */ if (name != NULL) xmlFree(name); name = NULL; if (CUR != ')') { name = xmlXPathParseLiteral(ctxt); CHECK_ERROR NULL; *test = NODE_TEST_PI; SKIP_BLANKS; } } if (CUR != ')') { if (name != NULL) xmlFree(name); XP_ERRORNULL(XPATH_UNCLOSED_ERROR); } NEXT; return(name); } *test = NODE_TEST_NAME; if ((!blanks) && (CUR == ':')) { NEXT; /* * Since currently the parser context don't have a * namespace list associated: * The namespace name for this prefix can be computed * only at evaluation time. The compilation is done * outside of any context. */ #if 0 *prefix = xmlXPathNsLookup(ctxt->context, name); if (name != NULL) xmlFree(name); if (*prefix == NULL) { XP_ERROR0(XPATH_UNDEF_PREFIX_ERROR); } #else *prefix = name; #endif if (CUR == '*') { /* * All elements */ NEXT; *test = NODE_TEST_ALL; return(NULL); } name = xmlXPathParseNCName(ctxt); if (name == NULL) { XP_ERRORNULL(XPATH_EXPR_ERROR); } } return(name); } /** * xmlXPathIsAxisName: * @name: a preparsed name token * * [6] AxisName ::= 'ancestor' * | 'ancestor-or-self' * | 'attribute' * | 'child' * | 'descendant' * | 'descendant-or-self' * | 'following' * | 'following-sibling' * | 'namespace' * | 'parent' * | 'preceding' * | 'preceding-sibling' * | 'self' * * Returns the axis or 0 */ static xmlXPathAxisVal xmlXPathIsAxisName(const xmlChar *name) { xmlXPathAxisVal ret = (xmlXPathAxisVal) 0; switch (name[0]) { case 'a': if (xmlStrEqual(name, BAD_CAST "ancestor")) ret = AXIS_ANCESTOR; if (xmlStrEqual(name, BAD_CAST "ancestor-or-self")) ret = AXIS_ANCESTOR_OR_SELF; if (xmlStrEqual(name, BAD_CAST "attribute")) ret = AXIS_ATTRIBUTE; break; case 'c': if (xmlStrEqual(name, BAD_CAST "child")) ret = AXIS_CHILD; break; case 'd': if (xmlStrEqual(name, BAD_CAST "descendant")) ret = AXIS_DESCENDANT; if (xmlStrEqual(name, BAD_CAST "descendant-or-self")) ret = AXIS_DESCENDANT_OR_SELF; break; case 'f': if (xmlStrEqual(name, BAD_CAST "following")) ret = AXIS_FOLLOWING; if (xmlStrEqual(name, BAD_CAST "following-sibling")) ret = AXIS_FOLLOWING_SIBLING; break; case 'n': if (xmlStrEqual(name, BAD_CAST "namespace")) ret = AXIS_NAMESPACE; break; case 'p': if (xmlStrEqual(name, BAD_CAST "parent")) ret = AXIS_PARENT; if (xmlStrEqual(name, BAD_CAST "preceding")) ret = AXIS_PRECEDING; if (xmlStrEqual(name, BAD_CAST "preceding-sibling")) ret = AXIS_PRECEDING_SIBLING; break; case 's': if (xmlStrEqual(name, BAD_CAST "self")) ret = AXIS_SELF; break; } return(ret); } /** * xmlXPathCompStep: * @ctxt: the XPath Parser context * * [4] Step ::= AxisSpecifier NodeTest Predicate* * | AbbreviatedStep * * [12] AbbreviatedStep ::= '.' | '..' * * [5] AxisSpecifier ::= AxisName '::' * | AbbreviatedAxisSpecifier * * [13] AbbreviatedAxisSpecifier ::= '@'? * * Modified for XPtr range support as: * * [4xptr] Step ::= AxisSpecifier NodeTest Predicate* * | AbbreviatedStep * | 'range-to' '(' Expr ')' Predicate* * * Compile one step in a Location Path * A location step of . is short for self::node(). This is * particularly useful in conjunction with //. For example, the * location path .//para is short for * self::node()/descendant-or-self::node()/child::para * and so will select all para descendant elements of the context * node. * Similarly, a location step of .. is short for parent::node(). * For example, ../title is short for parent::node()/child::title * and so will select the title children of the parent of the context * node. */ static void xmlXPathCompStep(xmlXPathParserContextPtr ctxt) { #ifdef LIBXML_XPTR_ENABLED int rangeto = 0; int op2 = -1; #endif SKIP_BLANKS; if ((CUR == '.') && (NXT(1) == '.')) { SKIP(2); SKIP_BLANKS; PUSH_LONG_EXPR(XPATH_OP_COLLECT, AXIS_PARENT, NODE_TEST_TYPE, NODE_TYPE_NODE, NULL, NULL); } else if (CUR == '.') { NEXT; SKIP_BLANKS; } else { xmlChar *name = NULL; const xmlChar *prefix = NULL; xmlXPathTestVal test = (xmlXPathTestVal) 0; xmlXPathAxisVal axis = (xmlXPathAxisVal) 0; xmlXPathTypeVal type = (xmlXPathTypeVal) 0; int op1; /* * The modification needed for XPointer change to the production */ #ifdef LIBXML_XPTR_ENABLED if (ctxt->xptr) { name = xmlXPathParseNCName(ctxt); if ((name != NULL) && (xmlStrEqual(name, BAD_CAST "range-to"))) { op2 = ctxt->comp->last; xmlFree(name); SKIP_BLANKS; if (CUR != '(') { XP_ERROR(XPATH_EXPR_ERROR); } NEXT; SKIP_BLANKS; xmlXPathCompileExpr(ctxt, 1); /* PUSH_BINARY_EXPR(XPATH_OP_RANGETO, op2, ctxt->comp->last, 0, 0); */ CHECK_ERROR; SKIP_BLANKS; if (CUR != ')') { XP_ERROR(XPATH_EXPR_ERROR); } NEXT; rangeto = 1; goto eval_predicates; } } #endif if (CUR == '*') { axis = AXIS_CHILD; } else { if (name == NULL) name = xmlXPathParseNCName(ctxt); if (name != NULL) { axis = xmlXPathIsAxisName(name); if (axis != 0) { SKIP_BLANKS; if ((CUR == ':') && (NXT(1) == ':')) { SKIP(2); xmlFree(name); name = NULL; } else { /* an element name can conflict with an axis one :-\ */ axis = AXIS_CHILD; } } else { axis = AXIS_CHILD; } } else if (CUR == '@') { NEXT; axis = AXIS_ATTRIBUTE; } else { axis = AXIS_CHILD; } } CHECK_ERROR; name = xmlXPathCompNodeTest(ctxt, &test, &type, &prefix, name); if (test == 0) return; if ((prefix != NULL) && (ctxt->context != NULL) && (ctxt->context->flags & XML_XPATH_CHECKNS)) { if (xmlXPathNsLookup(ctxt->context, prefix) == NULL) { xmlXPathErr(ctxt, XPATH_UNDEF_PREFIX_ERROR); } } #ifdef DEBUG_STEP xmlGenericError(xmlGenericErrorContext, "Basis : computing new set\n"); #endif #ifdef DEBUG_STEP xmlGenericError(xmlGenericErrorContext, "Basis : "); if (ctxt->value == NULL) xmlGenericError(xmlGenericErrorContext, "no value\n"); else if (ctxt->value->nodesetval == NULL) xmlGenericError(xmlGenericErrorContext, "Empty\n"); else xmlGenericErrorContextNodeSet(stdout, ctxt->value->nodesetval); #endif #ifdef LIBXML_XPTR_ENABLED eval_predicates: #endif op1 = ctxt->comp->last; ctxt->comp->last = -1; SKIP_BLANKS; while (CUR == '[') { xmlXPathCompPredicate(ctxt, 0); } #ifdef LIBXML_XPTR_ENABLED if (rangeto) { PUSH_BINARY_EXPR(XPATH_OP_RANGETO, op2, op1, 0, 0); } else #endif PUSH_FULL_EXPR(XPATH_OP_COLLECT, op1, ctxt->comp->last, axis, test, type, (void *)prefix, (void *)name); } #ifdef DEBUG_STEP xmlGenericError(xmlGenericErrorContext, "Step : "); if (ctxt->value == NULL) xmlGenericError(xmlGenericErrorContext, "no value\n"); else if (ctxt->value->nodesetval == NULL) xmlGenericError(xmlGenericErrorContext, "Empty\n"); else xmlGenericErrorContextNodeSet(xmlGenericErrorContext, ctxt->value->nodesetval); #endif } /** * xmlXPathCompRelativeLocationPath: * @ctxt: the XPath Parser context * * [3] RelativeLocationPath ::= Step * | RelativeLocationPath '/' Step * | AbbreviatedRelativeLocationPath * [11] AbbreviatedRelativeLocationPath ::= RelativeLocationPath '//' Step * * Compile a relative location path. */ static void xmlXPathCompRelativeLocationPath (xmlXPathParserContextPtr ctxt) { SKIP_BLANKS; if ((CUR == '/') && (NXT(1) == '/')) { SKIP(2); SKIP_BLANKS; PUSH_LONG_EXPR(XPATH_OP_COLLECT, AXIS_DESCENDANT_OR_SELF, NODE_TEST_TYPE, NODE_TYPE_NODE, NULL, NULL); } else if (CUR == '/') { NEXT; SKIP_BLANKS; } xmlXPathCompStep(ctxt); SKIP_BLANKS; while (CUR == '/') { if ((CUR == '/') && (NXT(1) == '/')) { SKIP(2); SKIP_BLANKS; PUSH_LONG_EXPR(XPATH_OP_COLLECT, AXIS_DESCENDANT_OR_SELF, NODE_TEST_TYPE, NODE_TYPE_NODE, NULL, NULL); xmlXPathCompStep(ctxt); } else if (CUR == '/') { NEXT; SKIP_BLANKS; xmlXPathCompStep(ctxt); } SKIP_BLANKS; } } /** * xmlXPathCompLocationPath: * @ctxt: the XPath Parser context * * [1] LocationPath ::= RelativeLocationPath * | AbsoluteLocationPath * [2] AbsoluteLocationPath ::= '/' RelativeLocationPath? * | AbbreviatedAbsoluteLocationPath * [10] AbbreviatedAbsoluteLocationPath ::= * '//' RelativeLocationPath * * Compile a location path * * // is short for /descendant-or-self::node()/. For example, * //para is short for /descendant-or-self::node()/child::para and * so will select any para element in the document (even a para element * that is a document element will be selected by //para since the * document element node is a child of the root node); div//para is * short for div/descendant-or-self::node()/child::para and so will * select all para descendants of div children. */ static void xmlXPathCompLocationPath(xmlXPathParserContextPtr ctxt) { SKIP_BLANKS; if (CUR != '/') { xmlXPathCompRelativeLocationPath(ctxt); } else { while (CUR == '/') { if ((CUR == '/') && (NXT(1) == '/')) { SKIP(2); SKIP_BLANKS; PUSH_LONG_EXPR(XPATH_OP_COLLECT, AXIS_DESCENDANT_OR_SELF, NODE_TEST_TYPE, NODE_TYPE_NODE, NULL, NULL); xmlXPathCompRelativeLocationPath(ctxt); } else if (CUR == '/') { NEXT; SKIP_BLANKS; if ((CUR != 0 ) && ((IS_ASCII_LETTER(CUR)) || (CUR == '_') || (CUR == '.') || (CUR == '@') || (CUR == '*'))) xmlXPathCompRelativeLocationPath(ctxt); } } } } /************************************************************************ * * * XPath precompiled expression evaluation * * * ************************************************************************/ static int xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op); #ifdef DEBUG_STEP static void xmlXPathDebugDumpStepAxis(xmlXPathAxisVal axis, xmlXPathTestVal test, int nbNodes) { xmlGenericError(xmlGenericErrorContext, "new step : "); switch (axis) { case AXIS_ANCESTOR: xmlGenericError(xmlGenericErrorContext, "axis 'ancestors' "); break; case AXIS_ANCESTOR_OR_SELF: xmlGenericError(xmlGenericErrorContext, "axis 'ancestors-or-self' "); break; case AXIS_ATTRIBUTE: xmlGenericError(xmlGenericErrorContext, "axis 'attributes' "); break; case AXIS_CHILD: xmlGenericError(xmlGenericErrorContext, "axis 'child' "); break; case AXIS_DESCENDANT: xmlGenericError(xmlGenericErrorContext, "axis 'descendant' "); break; case AXIS_DESCENDANT_OR_SELF: xmlGenericError(xmlGenericErrorContext, "axis 'descendant-or-self' "); break; case AXIS_FOLLOWING: xmlGenericError(xmlGenericErrorContext, "axis 'following' "); break; case AXIS_FOLLOWING_SIBLING: xmlGenericError(xmlGenericErrorContext, "axis 'following-siblings' "); break; case AXIS_NAMESPACE: xmlGenericError(xmlGenericErrorContext, "axis 'namespace' "); break; case AXIS_PARENT: xmlGenericError(xmlGenericErrorContext, "axis 'parent' "); break; case AXIS_PRECEDING: xmlGenericError(xmlGenericErrorContext, "axis 'preceding' "); break; case AXIS_PRECEDING_SIBLING: xmlGenericError(xmlGenericErrorContext, "axis 'preceding-sibling' "); break; case AXIS_SELF: xmlGenericError(xmlGenericErrorContext, "axis 'self' "); break; } xmlGenericError(xmlGenericErrorContext, " context contains %d nodes\n", nbNodes); switch (test) { case NODE_TEST_NONE: xmlGenericError(xmlGenericErrorContext, " searching for none !!!\n"); break; case NODE_TEST_TYPE: xmlGenericError(xmlGenericErrorContext, " searching for type %d\n", type); break; case NODE_TEST_PI: xmlGenericError(xmlGenericErrorContext, " searching for PI !!!\n"); break; case NODE_TEST_ALL: xmlGenericError(xmlGenericErrorContext, " searching for *\n"); break; case NODE_TEST_NS: xmlGenericError(xmlGenericErrorContext, " searching for namespace %s\n", prefix); break; case NODE_TEST_NAME: xmlGenericError(xmlGenericErrorContext, " searching for name %s\n", name); if (prefix != NULL) xmlGenericError(xmlGenericErrorContext, " with namespace %s\n", prefix); break; } xmlGenericError(xmlGenericErrorContext, "Testing : "); } #endif /* DEBUG_STEP */ static int xmlXPathCompOpEvalPredicate(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op, xmlNodeSetPtr set, int contextSize, int hasNsNodes) { if (op->ch1 != -1) { xmlXPathCompExprPtr comp = ctxt->comp; /* * Process inner predicates first. */ if (comp->steps[op->ch1].op != XPATH_OP_PREDICATE) { /* * TODO: raise an internal error. */ } contextSize = xmlXPathCompOpEvalPredicate(ctxt, &comp->steps[op->ch1], set, contextSize, hasNsNodes); CHECK_ERROR0; if (contextSize <= 0) return(0); } if (op->ch2 != -1) { xmlXPathContextPtr xpctxt = ctxt->context; xmlNodePtr contextNode, oldContextNode; xmlDocPtr oldContextDoc; int i, res, contextPos = 0, newContextSize; xmlXPathStepOpPtr exprOp; xmlXPathObjectPtr contextObj = NULL, exprRes = NULL; #ifdef LIBXML_XPTR_ENABLED /* * URGENT TODO: Check the following: * We don't expect location sets if evaluating prediates, right? * Only filters should expect location sets, right? */ #endif /* * SPEC XPath 1.0: * "For each node in the node-set to be filtered, the * PredicateExpr is evaluated with that node as the * context node, with the number of nodes in the * node-set as the context size, and with the proximity * position of the node in the node-set with respect to * the axis as the context position;" * @oldset is the node-set" to be filtered. * * SPEC XPath 1.0: * "only predicates change the context position and * context size (see [2.4 Predicates])." * Example: * node-set context pos * nA 1 * nB 2 * nC 3 * After applying predicate [position() > 1] : * node-set context pos * nB 1 * nC 2 */ oldContextNode = xpctxt->node; oldContextDoc = xpctxt->doc; /* * Get the expression of this predicate. */ exprOp = &ctxt->comp->steps[op->ch2]; newContextSize = 0; for (i = 0; i < set->nodeNr; i++) { if (set->nodeTab[i] == NULL) continue; contextNode = set->nodeTab[i]; xpctxt->node = contextNode; xpctxt->contextSize = contextSize; xpctxt->proximityPosition = ++contextPos; /* * Also set the xpath document in case things like * key() are evaluated in the predicate. */ if ((contextNode->type != XML_NAMESPACE_DECL) && (contextNode->doc != NULL)) xpctxt->doc = contextNode->doc; /* * Evaluate the predicate expression with 1 context node * at a time; this node is packaged into a node set; this * node set is handed over to the evaluation mechanism. */ if (contextObj == NULL) contextObj = xmlXPathCacheNewNodeSet(xpctxt, contextNode); else xmlXPathNodeSetAddUnique(contextObj->nodesetval, contextNode); valuePush(ctxt, contextObj); res = xmlXPathCompOpEvalToBoolean(ctxt, exprOp, 1); if ((ctxt->error != XPATH_EXPRESSION_OK) || (res == -1)) goto evaluation_error; if (res != 0) { newContextSize++; } else { /* * Remove the entry from the initial node set. */ set->nodeTab[i] = NULL; if (contextNode->type == XML_NAMESPACE_DECL) xmlXPathNodeSetFreeNs((xmlNsPtr) contextNode); } if (ctxt->value == contextObj) { /* * Don't free the temporary XPath object holding the * context node, in order to avoid massive recreation * inside this loop. */ valuePop(ctxt); xmlXPathNodeSetClear(contextObj->nodesetval, hasNsNodes); } else { /* * TODO: The object was lost in the evaluation machinery. * Can this happen? Maybe in internal-error cases. */ contextObj = NULL; } } goto evaluation_exit; evaluation_error: xmlXPathNodeSetClear(set, hasNsNodes); newContextSize = 0; evaluation_exit: if (contextObj != NULL) { if (ctxt->value == contextObj) valuePop(ctxt); xmlXPathReleaseObject(xpctxt, contextObj); } if (exprRes != NULL) xmlXPathReleaseObject(ctxt->context, exprRes); /* * Reset/invalidate the context. */ xpctxt->node = oldContextNode; xpctxt->doc = oldContextDoc; xpctxt->contextSize = -1; xpctxt->proximityPosition = -1; return(newContextSize); } return(contextSize); } static int xmlXPathCompOpEvalPositionalPredicate(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op, xmlNodeSetPtr set, int contextSize, int minPos, int maxPos, int hasNsNodes) { if (op->ch1 != -1) { xmlXPathCompExprPtr comp = ctxt->comp; if (comp->steps[op->ch1].op != XPATH_OP_PREDICATE) { /* * TODO: raise an internal error. */ } contextSize = xmlXPathCompOpEvalPredicate(ctxt, &comp->steps[op->ch1], set, contextSize, hasNsNodes); CHECK_ERROR0; if (contextSize <= 0) return(0); } /* * Check if the node set contains a sufficient number of nodes for * the requested range. */ if (contextSize < minPos) { xmlXPathNodeSetClear(set, hasNsNodes); return(0); } if (op->ch2 == -1) { /* * TODO: Can this ever happen? */ return (contextSize); } else { xmlDocPtr oldContextDoc; int i, pos = 0, newContextSize = 0, contextPos = 0, res; xmlXPathStepOpPtr exprOp; xmlXPathObjectPtr contextObj = NULL, exprRes = NULL; xmlNodePtr oldContextNode, contextNode = NULL; xmlXPathContextPtr xpctxt = ctxt->context; #ifdef LIBXML_XPTR_ENABLED /* * URGENT TODO: Check the following: * We don't expect location sets if evaluating prediates, right? * Only filters should expect location sets, right? */ #endif /* LIBXML_XPTR_ENABLED */ /* * Save old context. */ oldContextNode = xpctxt->node; oldContextDoc = xpctxt->doc; /* * Get the expression of this predicate. */ exprOp = &ctxt->comp->steps[op->ch2]; for (i = 0; i < set->nodeNr; i++) { if (set->nodeTab[i] == NULL) continue; contextNode = set->nodeTab[i]; xpctxt->node = contextNode; xpctxt->contextSize = contextSize; xpctxt->proximityPosition = ++contextPos; /* * Initialize the new set. * Also set the xpath document in case things like * key() evaluation are attempted on the predicate */ if ((contextNode->type != XML_NAMESPACE_DECL) && (contextNode->doc != NULL)) xpctxt->doc = contextNode->doc; /* * Evaluate the predicate expression with 1 context node * at a time; this node is packaged into a node set; this * node set is handed over to the evaluation mechanism. */ if (contextObj == NULL) contextObj = xmlXPathCacheNewNodeSet(xpctxt, contextNode); else xmlXPathNodeSetAddUnique(contextObj->nodesetval, contextNode); valuePush(ctxt, contextObj); res = xmlXPathCompOpEvalToBoolean(ctxt, exprOp, 1); if ((ctxt->error != XPATH_EXPRESSION_OK) || (res == -1)) goto evaluation_error; if (res) pos++; if (res && (pos >= minPos) && (pos <= maxPos)) { /* * Fits in the requested range. */ newContextSize++; if (minPos == maxPos) { /* * Only 1 node was requested. */ if (contextNode->type == XML_NAMESPACE_DECL) { /* * As always: take care of those nasty * namespace nodes. */ set->nodeTab[i] = NULL; } xmlXPathNodeSetClear(set, hasNsNodes); set->nodeNr = 1; set->nodeTab[0] = contextNode; goto evaluation_exit; } if (pos == maxPos) { /* * We are done. */ xmlXPathNodeSetClearFromPos(set, i +1, hasNsNodes); goto evaluation_exit; } } else { /* * Remove the entry from the initial node set. */ set->nodeTab[i] = NULL; if (contextNode->type == XML_NAMESPACE_DECL) xmlXPathNodeSetFreeNs((xmlNsPtr) contextNode); } if (exprRes != NULL) { xmlXPathReleaseObject(ctxt->context, exprRes); exprRes = NULL; } if (ctxt->value == contextObj) { /* * Don't free the temporary XPath object holding the * context node, in order to avoid massive recreation * inside this loop. */ valuePop(ctxt); xmlXPathNodeSetClear(contextObj->nodesetval, hasNsNodes); } else { /* * The object was lost in the evaluation machinery. * Can this happen? Maybe in case of internal-errors. */ contextObj = NULL; } } goto evaluation_exit; evaluation_error: xmlXPathNodeSetClear(set, hasNsNodes); newContextSize = 0; evaluation_exit: if (contextObj != NULL) { if (ctxt->value == contextObj) valuePop(ctxt); xmlXPathReleaseObject(xpctxt, contextObj); } if (exprRes != NULL) xmlXPathReleaseObject(ctxt->context, exprRes); /* * Reset/invalidate the context. */ xpctxt->node = oldContextNode; xpctxt->doc = oldContextDoc; xpctxt->contextSize = -1; xpctxt->proximityPosition = -1; return(newContextSize); } return(contextSize); } static int xmlXPathIsPositionalPredicate(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op, int *maxPos) { xmlXPathStepOpPtr exprOp; /* * BIG NOTE: This is not intended for XPATH_OP_FILTER yet! */ /* * If not -1, then ch1 will point to: * 1) For predicates (XPATH_OP_PREDICATE): * - an inner predicate operator * 2) For filters (XPATH_OP_FILTER): * - an inner filter operater OR * - an expression selecting the node set. * E.g. "key('a', 'b')" or "(//foo | //bar)". */ if ((op->op != XPATH_OP_PREDICATE) && (op->op != XPATH_OP_FILTER)) return(0); if (op->ch2 != -1) { exprOp = &ctxt->comp->steps[op->ch2]; } else return(0); if ((exprOp != NULL) && (exprOp->op == XPATH_OP_VALUE) && (exprOp->value4 != NULL) && (((xmlXPathObjectPtr) exprOp->value4)->type == XPATH_NUMBER)) { /* * We have a "[n]" predicate here. * TODO: Unfortunately this simplistic test here is not * able to detect a position() predicate in compound * expressions like "[@attr = 'a" and position() = 1], * and even not the usage of position() in * "[position() = 1]"; thus - obviously - a position-range, * like it "[position() < 5]", is also not detected. * Maybe we could rewrite the AST to ease the optimization. */ *maxPos = (int) ((xmlXPathObjectPtr) exprOp->value4)->floatval; if (((xmlXPathObjectPtr) exprOp->value4)->floatval == (float) *maxPos) { return(1); } } return(0); } static int xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op, xmlNodePtr * first, xmlNodePtr * last, int toBool) { #define XP_TEST_HIT \ if (hasAxisRange != 0) { \ if (++pos == maxPos) { \ addNode(seq, cur); \ goto axis_range_end; } \ } else { \ addNode(seq, cur); \ if (breakOnFirstHit) goto first_hit; } #define XP_TEST_HIT_NS \ if (hasAxisRange != 0) { \ if (++pos == maxPos) { \ hasNsNodes = 1; \ xmlXPathNodeSetAddNs(seq, xpctxt->node, (xmlNsPtr) cur); \ goto axis_range_end; } \ } else { \ hasNsNodes = 1; \ xmlXPathNodeSetAddNs(seq, \ xpctxt->node, (xmlNsPtr) cur); \ if (breakOnFirstHit) goto first_hit; } xmlXPathAxisVal axis = (xmlXPathAxisVal) op->value; xmlXPathTestVal test = (xmlXPathTestVal) op->value2; xmlXPathTypeVal type = (xmlXPathTypeVal) op->value3; const xmlChar *prefix = op->value4; const xmlChar *name = op->value5; const xmlChar *URI = NULL; #ifdef DEBUG_STEP int nbMatches = 0, prevMatches = 0; #endif int total = 0, hasNsNodes = 0; /* The popped object holding the context nodes */ xmlXPathObjectPtr obj; /* The set of context nodes for the node tests */ xmlNodeSetPtr contextSeq; int contextIdx; xmlNodePtr contextNode; /* The context node for a compound traversal */ xmlNodePtr outerContextNode; /* The final resulting node set wrt to all context nodes */ xmlNodeSetPtr outSeq; /* * The temporary resulting node set wrt 1 context node. * Used to feed predicate evaluation. */ xmlNodeSetPtr seq; xmlNodePtr cur; /* First predicate operator */ xmlXPathStepOpPtr predOp; int maxPos; /* The requested position() (when a "[n]" predicate) */ int hasPredicateRange, hasAxisRange, pos, size, newSize; int breakOnFirstHit; xmlXPathTraversalFunction next = NULL; /* compound axis traversal */ xmlXPathTraversalFunctionExt outerNext = NULL; void (*addNode) (xmlNodeSetPtr, xmlNodePtr); xmlXPathNodeSetMergeFunction mergeAndClear; xmlNodePtr oldContextNode; xmlXPathContextPtr xpctxt = ctxt->context; CHECK_TYPE0(XPATH_NODESET); obj = valuePop(ctxt); /* * Setup namespaces. */ if (prefix != NULL) { URI = xmlXPathNsLookup(xpctxt, prefix); if (URI == NULL) { xmlXPathReleaseObject(xpctxt, obj); XP_ERROR0(XPATH_UNDEF_PREFIX_ERROR); } } /* * Setup axis. * * MAYBE FUTURE TODO: merging optimizations: * - If the nodes to be traversed wrt to the initial nodes and * the current axis cannot overlap, then we could avoid searching * for duplicates during the merge. * But the question is how/when to evaluate if they cannot overlap. * Example: if we know that for two initial nodes, the one is * not in the ancestor-or-self axis of the other, then we could safely * avoid a duplicate-aware merge, if the axis to be traversed is e.g. * the descendant-or-self axis. */ addNode = xmlXPathNodeSetAdd; mergeAndClear = xmlXPathNodeSetMergeAndClear; switch (axis) { case AXIS_ANCESTOR: first = NULL; next = xmlXPathNextAncestor; break; case AXIS_ANCESTOR_OR_SELF: first = NULL; next = xmlXPathNextAncestorOrSelf; break; case AXIS_ATTRIBUTE: first = NULL; last = NULL; next = xmlXPathNextAttribute; mergeAndClear = xmlXPathNodeSetMergeAndClearNoDupls; break; case AXIS_CHILD: last = NULL; if (op->rewriteType == XP_REWRITE_DOS_CHILD_ELEM) { /* * This iterator will give us only nodes which can * hold element nodes. */ outerNext = xmlXPathNextDescendantOrSelfElemParent; } if (((test == NODE_TEST_NAME) || (test == NODE_TEST_ALL)) && (type == NODE_TYPE_NODE)) { /* * Optimization if an element node type is 'element'. */ next = xmlXPathNextChildElement; } else next = xmlXPathNextChild; mergeAndClear = xmlXPathNodeSetMergeAndClearNoDupls; break; case AXIS_DESCENDANT: last = NULL; next = xmlXPathNextDescendant; break; case AXIS_DESCENDANT_OR_SELF: last = NULL; next = xmlXPathNextDescendantOrSelf; break; case AXIS_FOLLOWING: last = NULL; next = xmlXPathNextFollowing; break; case AXIS_FOLLOWING_SIBLING: last = NULL; next = xmlXPathNextFollowingSibling; break; case AXIS_NAMESPACE: first = NULL; last = NULL; next = (xmlXPathTraversalFunction) xmlXPathNextNamespace; mergeAndClear = xmlXPathNodeSetMergeAndClearNoDupls; break; case AXIS_PARENT: first = NULL; next = xmlXPathNextParent; break; case AXIS_PRECEDING: first = NULL; next = xmlXPathNextPrecedingInternal; break; case AXIS_PRECEDING_SIBLING: first = NULL; next = xmlXPathNextPrecedingSibling; break; case AXIS_SELF: first = NULL; last = NULL; next = xmlXPathNextSelf; mergeAndClear = xmlXPathNodeSetMergeAndClearNoDupls; break; } #ifdef DEBUG_STEP xmlXPathDebugDumpStepAxis(axis, test, (obj->nodesetval != NULL) ? obj->nodsetval->nodeNr : 0); #endif if (next == NULL) { xmlXPathReleaseObject(xpctxt, obj); return(0); } contextSeq = obj->nodesetval; if ((contextSeq == NULL) || (contextSeq->nodeNr <= 0)) { xmlXPathReleaseObject(xpctxt, obj); valuePush(ctxt, xmlXPathCacheWrapNodeSet(xpctxt, NULL)); return(0); } /* * Predicate optimization --------------------------------------------- * If this step has a last predicate, which contains a position(), * then we'll optimize (although not exactly "position()", but only * the short-hand form, i.e., "[n]". * * Example - expression "/foo[parent::bar][1]": * * COLLECT 'child' 'name' 'node' foo -- op (we are here) * ROOT -- op->ch1 * PREDICATE -- op->ch2 (predOp) * PREDICATE -- predOp->ch1 = [parent::bar] * SORT * COLLECT 'parent' 'name' 'node' bar * NODE * ELEM Object is a number : 1 -- predOp->ch2 = [1] * */ maxPos = 0; predOp = NULL; hasPredicateRange = 0; hasAxisRange = 0; if (op->ch2 != -1) { /* * There's at least one predicate. 16 == XPATH_OP_PREDICATE */ predOp = &ctxt->comp->steps[op->ch2]; if (xmlXPathIsPositionalPredicate(ctxt, predOp, &maxPos)) { if (predOp->ch1 != -1) { /* * Use the next inner predicate operator. */ predOp = &ctxt->comp->steps[predOp->ch1]; hasPredicateRange = 1; } else { /* * There's no other predicate than the [n] predicate. */ predOp = NULL; hasAxisRange = 1; } } } breakOnFirstHit = ((toBool) && (predOp == NULL)) ? 1 : 0; /* * Axis traversal ----------------------------------------------------- */ /* * 2.3 Node Tests * - For the attribute axis, the principal node type is attribute. * - For the namespace axis, the principal node type is namespace. * - For other axes, the principal node type is element. * * A node test * is true for any node of the * principal node type. For example, child::* will * select all element children of the context node */ oldContextNode = xpctxt->node; addNode = xmlXPathNodeSetAddUnique; outSeq = NULL; seq = NULL; outerContextNode = NULL; contextNode = NULL; contextIdx = 0; while ((contextIdx < contextSeq->nodeNr) || (contextNode != NULL)) { if (outerNext != NULL) { /* * This is a compound traversal. */ if (contextNode == NULL) { /* * Set the context for the outer traversal. */ outerContextNode = contextSeq->nodeTab[contextIdx++]; contextNode = outerNext(NULL, outerContextNode); } else contextNode = outerNext(contextNode, outerContextNode); if (contextNode == NULL) continue; /* * Set the context for the main traversal. */ xpctxt->node = contextNode; } else xpctxt->node = contextSeq->nodeTab[contextIdx++]; if (seq == NULL) { seq = xmlXPathNodeSetCreate(NULL); if (seq == NULL) { total = 0; goto error; } } /* * Traverse the axis and test the nodes. */ pos = 0; cur = NULL; hasNsNodes = 0; do { cur = next(ctxt, cur); if (cur == NULL) break; /* * QUESTION TODO: What does the "first" and "last" stuff do? */ if ((first != NULL) && (*first != NULL)) { if (*first == cur) break; if (((total % 256) == 0) && #ifdef XP_OPTIMIZED_NON_ELEM_COMPARISON (xmlXPathCmpNodesExt(*first, cur) >= 0)) #else (xmlXPathCmpNodes(*first, cur) >= 0)) #endif { break; } } if ((last != NULL) && (*last != NULL)) { if (*last == cur) break; if (((total % 256) == 0) && #ifdef XP_OPTIMIZED_NON_ELEM_COMPARISON (xmlXPathCmpNodesExt(cur, *last) >= 0)) #else (xmlXPathCmpNodes(cur, *last) >= 0)) #endif { break; } } total++; #ifdef DEBUG_STEP xmlGenericError(xmlGenericErrorContext, " %s", cur->name); #endif switch (test) { case NODE_TEST_NONE: total = 0; STRANGE goto error; case NODE_TEST_TYPE: /* * TODO: Don't we need to use * xmlXPathNodeSetAddNs() for namespace nodes here? * Surprisingly, some c14n tests fail, if we do this. */ if (type == NODE_TYPE_NODE) { switch (cur->type) { case XML_DOCUMENT_NODE: case XML_HTML_DOCUMENT_NODE: #ifdef LIBXML_DOCB_ENABLED case XML_DOCB_DOCUMENT_NODE: #endif case XML_ELEMENT_NODE: case XML_ATTRIBUTE_NODE: case XML_PI_NODE: case XML_COMMENT_NODE: case XML_CDATA_SECTION_NODE: case XML_TEXT_NODE: case XML_NAMESPACE_DECL: XP_TEST_HIT break; default: break; } } else if (cur->type == type) { if (type == XML_NAMESPACE_DECL) XP_TEST_HIT_NS else XP_TEST_HIT } else if ((type == NODE_TYPE_TEXT) && (cur->type == XML_CDATA_SECTION_NODE)) { XP_TEST_HIT } break; case NODE_TEST_PI: if ((cur->type == XML_PI_NODE) && ((name == NULL) || xmlStrEqual(name, cur->name))) { XP_TEST_HIT } break; case NODE_TEST_ALL: if (axis == AXIS_ATTRIBUTE) { if (cur->type == XML_ATTRIBUTE_NODE) { XP_TEST_HIT } } else if (axis == AXIS_NAMESPACE) { if (cur->type == XML_NAMESPACE_DECL) { XP_TEST_HIT_NS } } else { if (cur->type == XML_ELEMENT_NODE) { if (prefix == NULL) { XP_TEST_HIT } else if ((cur->ns != NULL) && (xmlStrEqual(URI, cur->ns->href))) { XP_TEST_HIT } } } break; case NODE_TEST_NS:{ TODO; break; } case NODE_TEST_NAME: switch (cur->type) { case XML_ELEMENT_NODE: if (xmlStrEqual(name, cur->name)) { if (prefix == NULL) { if (cur->ns == NULL) { XP_TEST_HIT } } else { if ((cur->ns != NULL) && (xmlStrEqual(URI, cur->ns->href))) { XP_TEST_HIT } } } break; case XML_ATTRIBUTE_NODE:{ xmlAttrPtr attr = (xmlAttrPtr) cur; if (xmlStrEqual(name, attr->name)) { if (prefix == NULL) { if ((attr->ns == NULL) || (attr->ns->prefix == NULL)) { XP_TEST_HIT } } else { if ((attr->ns != NULL) && (xmlStrEqual(URI, attr->ns->href))) { XP_TEST_HIT } } } break; } case XML_NAMESPACE_DECL: if (cur->type == XML_NAMESPACE_DECL) { xmlNsPtr ns = (xmlNsPtr) cur; if ((ns->prefix != NULL) && (name != NULL) && (xmlStrEqual(ns->prefix, name))) { XP_TEST_HIT_NS } } break; default: break; } break; } /* switch(test) */ } while (cur != NULL); goto apply_predicates; axis_range_end: /* ----------------------------------------------------- */ /* * We have a "/foo[n]", and position() = n was reached. * Note that we can have as well "/foo/::parent::foo[1]", so * a duplicate-aware merge is still needed. * Merge with the result. */ if (outSeq == NULL) { outSeq = seq; seq = NULL; } else outSeq = mergeAndClear(outSeq, seq, 0); /* * Break if only a true/false result was requested. */ if (toBool) break; continue; first_hit: /* ---------------------------------------------------------- */ /* * Break if only a true/false result was requested and * no predicates existed and a node test succeeded. */ if (outSeq == NULL) { outSeq = seq; seq = NULL; } else outSeq = mergeAndClear(outSeq, seq, 0); break; #ifdef DEBUG_STEP if (seq != NULL) nbMatches += seq->nodeNr; #endif apply_predicates: /* --------------------------------------------------- */ /* * Apply predicates. */ if ((predOp != NULL) && (seq->nodeNr > 0)) { /* * E.g. when we have a "/foo[some expression][n]". */ /* * QUESTION TODO: The old predicate evaluation took into * account location-sets. * (E.g. ctxt->value->type == XPATH_LOCATIONSET) * Do we expect such a set here? * All what I learned now from the evaluation semantics * does not indicate that a location-set will be processed * here, so this looks OK. */ /* * Iterate over all predicates, starting with the outermost * predicate. * TODO: Problem: we cannot execute the inner predicates first * since we cannot go back *up* the operator tree! * Options we have: * 1) Use of recursive functions (like is it currently done * via xmlXPathCompOpEval()) * 2) Add a predicate evaluation information stack to the * context struct * 3) Change the way the operators are linked; we need a * "parent" field on xmlXPathStepOp * * For the moment, I'll try to solve this with a recursive * function: xmlXPathCompOpEvalPredicate(). */ size = seq->nodeNr; if (hasPredicateRange != 0) newSize = xmlXPathCompOpEvalPositionalPredicate(ctxt, predOp, seq, size, maxPos, maxPos, hasNsNodes); else newSize = xmlXPathCompOpEvalPredicate(ctxt, predOp, seq, size, hasNsNodes); if (ctxt->error != XPATH_EXPRESSION_OK) { total = 0; goto error; } /* * Add the filtered set of nodes to the result node set. */ if (newSize == 0) { /* * The predicates filtered all nodes out. */ xmlXPathNodeSetClear(seq, hasNsNodes); } else if (seq->nodeNr > 0) { /* * Add to result set. */ if (outSeq == NULL) { if (size != newSize) { /* * We need to merge and clear here, since * the sequence will contained NULLed entries. */ outSeq = mergeAndClear(NULL, seq, 1); } else { outSeq = seq; seq = NULL; } } else outSeq = mergeAndClear(outSeq, seq, (size != newSize) ? 1: 0); /* * Break if only a true/false result was requested. */ if (toBool) break; } } else if (seq->nodeNr > 0) { /* * Add to result set. */ if (outSeq == NULL) { outSeq = seq; seq = NULL; } else { outSeq = mergeAndClear(outSeq, seq, 0); } } } error: if ((obj->boolval) && (obj->user != NULL)) { /* * QUESTION TODO: What does this do and why? * TODO: Do we have to do this also for the "error" * cleanup further down? */ ctxt->value->boolval = 1; ctxt->value->user = obj->user; obj->user = NULL; obj->boolval = 0; } xmlXPathReleaseObject(xpctxt, obj); /* * Ensure we return at least an emtpy set. */ if (outSeq == NULL) { if ((seq != NULL) && (seq->nodeNr == 0)) outSeq = seq; else outSeq = xmlXPathNodeSetCreate(NULL); } if ((seq != NULL) && (seq != outSeq)) { xmlXPathFreeNodeSet(seq); } /* * Hand over the result. Better to push the set also in * case of errors. */ valuePush(ctxt, xmlXPathCacheWrapNodeSet(xpctxt, outSeq)); /* * Reset the context node. */ xpctxt->node = oldContextNode; #ifdef DEBUG_STEP xmlGenericError(xmlGenericErrorContext, "\nExamined %d nodes, found %d nodes at that step\n", total, nbMatches); #endif return(total); } static int xmlXPathCompOpEvalFilterFirst(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op, xmlNodePtr * first); /** * xmlXPathCompOpEvalFirst: * @ctxt: the XPath parser context with the compiled expression * @op: an XPath compiled operation * @first: the first elem found so far * * Evaluate the Precompiled XPath operation searching only the first * element in document order * * Returns the number of examined objects. */ static int xmlXPathCompOpEvalFirst(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op, xmlNodePtr * first) { int total = 0, cur; xmlXPathCompExprPtr comp; xmlXPathObjectPtr arg1, arg2; CHECK_ERROR0; comp = ctxt->comp; switch (op->op) { case XPATH_OP_END: return (0); case XPATH_OP_UNION: total = xmlXPathCompOpEvalFirst(ctxt, &comp->steps[op->ch1], first); CHECK_ERROR0; if ((ctxt->value != NULL) && (ctxt->value->type == XPATH_NODESET) && (ctxt->value->nodesetval != NULL) && (ctxt->value->nodesetval->nodeNr >= 1)) { /* * limit tree traversing to first node in the result */ /* * OPTIMIZE TODO: This implicitely sorts * the result, even if not needed. E.g. if the argument * of the count() function, no sorting is needed. * OPTIMIZE TODO: How do we know if the node-list wasn't * aready sorted? */ if (ctxt->value->nodesetval->nodeNr > 1) xmlXPathNodeSetSort(ctxt->value->nodesetval); *first = ctxt->value->nodesetval->nodeTab[0]; } cur = xmlXPathCompOpEvalFirst(ctxt, &comp->steps[op->ch2], first); CHECK_ERROR0; CHECK_TYPE0(XPATH_NODESET); arg2 = valuePop(ctxt); CHECK_TYPE0(XPATH_NODESET); arg1 = valuePop(ctxt); arg1->nodesetval = xmlXPathNodeSetMerge(arg1->nodesetval, arg2->nodesetval); valuePush(ctxt, arg1); xmlXPathReleaseObject(ctxt->context, arg2); /* optimizer */ if (total > cur) xmlXPathCompSwap(op); return (total + cur); case XPATH_OP_ROOT: xmlXPathRoot(ctxt); return (0); case XPATH_OP_NODE: if (op->ch1 != -1) total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]); CHECK_ERROR0; if (op->ch2 != -1) total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]); CHECK_ERROR0; valuePush(ctxt, xmlXPathCacheNewNodeSet(ctxt->context, ctxt->context->node)); return (total); case XPATH_OP_RESET: if (op->ch1 != -1) total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]); CHECK_ERROR0; if (op->ch2 != -1) total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]); CHECK_ERROR0; ctxt->context->node = NULL; return (total); case XPATH_OP_COLLECT:{ if (op->ch1 == -1) return (total); total = xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]); CHECK_ERROR0; total += xmlXPathNodeCollectAndTest(ctxt, op, first, NULL, 0); return (total); } case XPATH_OP_VALUE: valuePush(ctxt, xmlXPathCacheObjectCopy(ctxt->context, (xmlXPathObjectPtr) op->value4)); return (0); case XPATH_OP_SORT: if (op->ch1 != -1) total += xmlXPathCompOpEvalFirst(ctxt, &comp->steps[op->ch1], first); CHECK_ERROR0; if ((ctxt->value != NULL) && (ctxt->value->type == XPATH_NODESET) && (ctxt->value->nodesetval != NULL) && (ctxt->value->nodesetval->nodeNr > 1)) xmlXPathNodeSetSort(ctxt->value->nodesetval); return (total); #ifdef XP_OPTIMIZED_FILTER_FIRST case XPATH_OP_FILTER: total =+ xmlXPathCompOpEvalFilterFirst(ctxt, op, first); return (total); #endif default: return (xmlXPathCompOpEval(ctxt, op)); } } /** * xmlXPathCompOpEvalLast: * @ctxt: the XPath parser context with the compiled expression * @op: an XPath compiled operation * @last: the last elem found so far * * Evaluate the Precompiled XPath operation searching only the last * element in document order * * Returns the number of nodes traversed */ static int xmlXPathCompOpEvalLast(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op, xmlNodePtr * last) { int total = 0, cur; xmlXPathCompExprPtr comp; xmlXPathObjectPtr arg1, arg2; xmlNodePtr bak; xmlDocPtr bakd; int pp; int cs; CHECK_ERROR0; comp = ctxt->comp; switch (op->op) { case XPATH_OP_END: return (0); case XPATH_OP_UNION: bakd = ctxt->context->doc; bak = ctxt->context->node; pp = ctxt->context->proximityPosition; cs = ctxt->context->contextSize; total = xmlXPathCompOpEvalLast(ctxt, &comp->steps[op->ch1], last); CHECK_ERROR0; if ((ctxt->value != NULL) && (ctxt->value->type == XPATH_NODESET) && (ctxt->value->nodesetval != NULL) && (ctxt->value->nodesetval->nodeNr >= 1)) { /* * limit tree traversing to first node in the result */ if (ctxt->value->nodesetval->nodeNr > 1) xmlXPathNodeSetSort(ctxt->value->nodesetval); *last = ctxt->value->nodesetval->nodeTab[ctxt->value-> nodesetval->nodeNr - 1]; } ctxt->context->doc = bakd; ctxt->context->node = bak; ctxt->context->proximityPosition = pp; ctxt->context->contextSize = cs; cur = xmlXPathCompOpEvalLast(ctxt, &comp->steps[op->ch2], last); CHECK_ERROR0; if ((ctxt->value != NULL) && (ctxt->value->type == XPATH_NODESET) && (ctxt->value->nodesetval != NULL) && (ctxt->value->nodesetval->nodeNr >= 1)) { /* TODO: NOP ? */ } CHECK_TYPE0(XPATH_NODESET); arg2 = valuePop(ctxt); CHECK_TYPE0(XPATH_NODESET); arg1 = valuePop(ctxt); arg1->nodesetval = xmlXPathNodeSetMerge(arg1->nodesetval, arg2->nodesetval); valuePush(ctxt, arg1); xmlXPathReleaseObject(ctxt->context, arg2); /* optimizer */ if (total > cur) xmlXPathCompSwap(op); return (total + cur); case XPATH_OP_ROOT: xmlXPathRoot(ctxt); return (0); case XPATH_OP_NODE: if (op->ch1 != -1) total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]); CHECK_ERROR0; if (op->ch2 != -1) total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]); CHECK_ERROR0; valuePush(ctxt, xmlXPathCacheNewNodeSet(ctxt->context, ctxt->context->node)); return (total); case XPATH_OP_RESET: if (op->ch1 != -1) total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]); CHECK_ERROR0; if (op->ch2 != -1) total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]); CHECK_ERROR0; ctxt->context->node = NULL; return (total); case XPATH_OP_COLLECT:{ if (op->ch1 == -1) return (0); total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]); CHECK_ERROR0; total += xmlXPathNodeCollectAndTest(ctxt, op, NULL, last, 0); return (total); } case XPATH_OP_VALUE: valuePush(ctxt, xmlXPathCacheObjectCopy(ctxt->context, (xmlXPathObjectPtr) op->value4)); return (0); case XPATH_OP_SORT: if (op->ch1 != -1) total += xmlXPathCompOpEvalLast(ctxt, &comp->steps[op->ch1], last); CHECK_ERROR0; if ((ctxt->value != NULL) && (ctxt->value->type == XPATH_NODESET) && (ctxt->value->nodesetval != NULL) && (ctxt->value->nodesetval->nodeNr > 1)) xmlXPathNodeSetSort(ctxt->value->nodesetval); return (total); default: return (xmlXPathCompOpEval(ctxt, op)); } } #ifdef XP_OPTIMIZED_FILTER_FIRST static int xmlXPathCompOpEvalFilterFirst(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op, xmlNodePtr * first) { int total = 0; xmlXPathCompExprPtr comp; xmlXPathObjectPtr res; xmlXPathObjectPtr obj; xmlNodeSetPtr oldset; xmlNodePtr oldnode; xmlDocPtr oldDoc; int i; CHECK_ERROR0; comp = ctxt->comp; /* * Optimization for ()[last()] selection i.e. the last elem */ if ((op->ch1 != -1) && (op->ch2 != -1) && (comp->steps[op->ch1].op == XPATH_OP_SORT) && (comp->steps[op->ch2].op == XPATH_OP_SORT)) { int f = comp->steps[op->ch2].ch1; if ((f != -1) && (comp->steps[f].op == XPATH_OP_FUNCTION) && (comp->steps[f].value5 == NULL) && (comp->steps[f].value == 0) && (comp->steps[f].value4 != NULL) && (xmlStrEqual (comp->steps[f].value4, BAD_CAST "last"))) { xmlNodePtr last = NULL; total += xmlXPathCompOpEvalLast(ctxt, &comp->steps[op->ch1], &last); CHECK_ERROR0; /* * The nodeset should be in document order, * Keep only the last value */ if ((ctxt->value != NULL) && (ctxt->value->type == XPATH_NODESET) && (ctxt->value->nodesetval != NULL) && (ctxt->value->nodesetval->nodeTab != NULL) && (ctxt->value->nodesetval->nodeNr > 1)) { ctxt->value->nodesetval->nodeTab[0] = ctxt->value->nodesetval->nodeTab[ctxt-> value-> nodesetval-> nodeNr - 1]; ctxt->value->nodesetval->nodeNr = 1; *first = *(ctxt->value->nodesetval->nodeTab); } return (total); } } if (op->ch1 != -1) total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]); CHECK_ERROR0; if (op->ch2 == -1) return (total); if (ctxt->value == NULL) return (total); #ifdef LIBXML_XPTR_ENABLED oldnode = ctxt->context->node; /* * Hum are we filtering the result of an XPointer expression */ if (ctxt->value->type == XPATH_LOCATIONSET) { xmlXPathObjectPtr tmp = NULL; xmlLocationSetPtr newlocset = NULL; xmlLocationSetPtr oldlocset; /* * Extract the old locset, and then evaluate the result of the * expression for all the element in the locset. use it to grow * up a new locset. */ CHECK_TYPE0(XPATH_LOCATIONSET); obj = valuePop(ctxt); oldlocset = obj->user; ctxt->context->node = NULL; if ((oldlocset == NULL) || (oldlocset->locNr == 0)) { ctxt->context->contextSize = 0; ctxt->context->proximityPosition = 0; if (op->ch2 != -1) total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]); res = valuePop(ctxt); if (res != NULL) { xmlXPathReleaseObject(ctxt->context, res); } valuePush(ctxt, obj); CHECK_ERROR0; return (total); } newlocset = xmlXPtrLocationSetCreate(NULL); for (i = 0; i < oldlocset->locNr; i++) { /* * Run the evaluation with a node list made of a * single item in the nodelocset. */ ctxt->context->node = oldlocset->locTab[i]->user; ctxt->context->contextSize = oldlocset->locNr; ctxt->context->proximityPosition = i + 1; if (tmp == NULL) { tmp = xmlXPathCacheNewNodeSet(ctxt->context, ctxt->context->node); } else { xmlXPathNodeSetAddUnique(tmp->nodesetval, ctxt->context->node); } valuePush(ctxt, tmp); if (op->ch2 != -1) total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]); if (ctxt->error != XPATH_EXPRESSION_OK) { xmlXPathFreeObject(obj); return(0); } /* * The result of the evaluation need to be tested to * decided whether the filter succeeded or not */ res = valuePop(ctxt); if (xmlXPathEvaluatePredicateResult(ctxt, res)) { xmlXPtrLocationSetAdd(newlocset, xmlXPathCacheObjectCopy(ctxt->context, oldlocset->locTab[i])); } /* * Cleanup */ if (res != NULL) { xmlXPathReleaseObject(ctxt->context, res); } if (ctxt->value == tmp) { valuePop(ctxt); xmlXPathNodeSetClear(tmp->nodesetval, 1); /* * REVISIT TODO: Don't create a temporary nodeset * for everly iteration. */ /* OLD: xmlXPathFreeObject(res); */ } else tmp = NULL; ctxt->context->node = NULL; /* * Only put the first node in the result, then leave. */ if (newlocset->locNr > 0) { *first = (xmlNodePtr) oldlocset->locTab[i]->user; break; } } if (tmp != NULL) { xmlXPathReleaseObject(ctxt->context, tmp); } /* * The result is used as the new evaluation locset. */ xmlXPathReleaseObject(ctxt->context, obj); ctxt->context->node = NULL; ctxt->context->contextSize = -1; ctxt->context->proximityPosition = -1; valuePush(ctxt, xmlXPtrWrapLocationSet(newlocset)); ctxt->context->node = oldnode; return (total); } #endif /* LIBXML_XPTR_ENABLED */ /* * Extract the old set, and then evaluate the result of the * expression for all the element in the set. use it to grow * up a new set. */ CHECK_TYPE0(XPATH_NODESET); obj = valuePop(ctxt); oldset = obj->nodesetval; oldnode = ctxt->context->node; oldDoc = ctxt->context->doc; ctxt->context->node = NULL; if ((oldset == NULL) || (oldset->nodeNr == 0)) { ctxt->context->contextSize = 0; ctxt->context->proximityPosition = 0; /* QUESTION TODO: Why was this code commented out? if (op->ch2 != -1) total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]); CHECK_ERROR0; res = valuePop(ctxt); if (res != NULL) xmlXPathFreeObject(res); */ valuePush(ctxt, obj); ctxt->context->node = oldnode; CHECK_ERROR0; } else { xmlNodeSetPtr newset; xmlXPathObjectPtr tmp = NULL; /* * Initialize the new set. * Also set the xpath document in case things like * key() evaluation are attempted on the predicate */ newset = xmlXPathNodeSetCreate(NULL); for (i = 0; i < oldset->nodeNr; i++) { /* * Run the evaluation with a node list made of * a single item in the nodeset. */ ctxt->context->node = oldset->nodeTab[i]; if ((oldset->nodeTab[i]->type != XML_NAMESPACE_DECL) && (oldset->nodeTab[i]->doc != NULL)) ctxt->context->doc = oldset->nodeTab[i]->doc; if (tmp == NULL) { tmp = xmlXPathCacheNewNodeSet(ctxt->context, ctxt->context->node); } else { xmlXPathNodeSetAddUnique(tmp->nodesetval, ctxt->context->node); } valuePush(ctxt, tmp); ctxt->context->contextSize = oldset->nodeNr; ctxt->context->proximityPosition = i + 1; if (op->ch2 != -1) total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]); if (ctxt->error != XPATH_EXPRESSION_OK) { xmlXPathFreeNodeSet(newset); xmlXPathFreeObject(obj); return(0); } /* * The result of the evaluation needs to be tested to * decide whether the filter succeeded or not */ res = valuePop(ctxt); if (xmlXPathEvaluatePredicateResult(ctxt, res)) { xmlXPathNodeSetAdd(newset, oldset->nodeTab[i]); } /* * Cleanup */ if (res != NULL) { xmlXPathReleaseObject(ctxt->context, res); } if (ctxt->value == tmp) { valuePop(ctxt); /* * Don't free the temporary nodeset * in order to avoid massive recreation inside this * loop. */ xmlXPathNodeSetClear(tmp->nodesetval, 1); } else tmp = NULL; ctxt->context->node = NULL; /* * Only put the first node in the result, then leave. */ if (newset->nodeNr > 0) { *first = *(newset->nodeTab); break; } } if (tmp != NULL) { xmlXPathReleaseObject(ctxt->context, tmp); } /* * The result is used as the new evaluation set. */ xmlXPathReleaseObject(ctxt->context, obj); ctxt->context->node = NULL; ctxt->context->contextSize = -1; ctxt->context->proximityPosition = -1; /* may want to move this past the '}' later */ ctxt->context->doc = oldDoc; valuePush(ctxt, xmlXPathCacheWrapNodeSet(ctxt->context, newset)); } ctxt->context->node = oldnode; return(total); } #endif /* XP_OPTIMIZED_FILTER_FIRST */ /** * xmlXPathCompOpEval: * @ctxt: the XPath parser context with the compiled expression * @op: an XPath compiled operation * * Evaluate the Precompiled XPath operation * Returns the number of nodes traversed */ static int xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op) { int total = 0; int equal, ret; xmlXPathCompExprPtr comp; xmlXPathObjectPtr arg1, arg2; xmlNodePtr bak; xmlDocPtr bakd; int pp; int cs; CHECK_ERROR0; comp = ctxt->comp; switch (op->op) { case XPATH_OP_END: return (0); case XPATH_OP_AND: bakd = ctxt->context->doc; bak = ctxt->context->node; pp = ctxt->context->proximityPosition; cs = ctxt->context->contextSize; total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]); CHECK_ERROR0; xmlXPathBooleanFunction(ctxt, 1); if ((ctxt->value == NULL) || (ctxt->value->boolval == 0)) return (total); arg2 = valuePop(ctxt); ctxt->context->doc = bakd; ctxt->context->node = bak; ctxt->context->proximityPosition = pp; ctxt->context->contextSize = cs; total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]); if (ctxt->error) { xmlXPathFreeObject(arg2); return(0); } xmlXPathBooleanFunction(ctxt, 1); arg1 = valuePop(ctxt); arg1->boolval &= arg2->boolval; valuePush(ctxt, arg1); xmlXPathReleaseObject(ctxt->context, arg2); return (total); case XPATH_OP_OR: bakd = ctxt->context->doc; bak = ctxt->context->node; pp = ctxt->context->proximityPosition; cs = ctxt->context->contextSize; total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]); CHECK_ERROR0; xmlXPathBooleanFunction(ctxt, 1); if ((ctxt->value == NULL) || (ctxt->value->boolval == 1)) return (total); arg2 = valuePop(ctxt); ctxt->context->doc = bakd; ctxt->context->node = bak; ctxt->context->proximityPosition = pp; ctxt->context->contextSize = cs; total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]); if (ctxt->error) { xmlXPathFreeObject(arg2); return(0); } xmlXPathBooleanFunction(ctxt, 1); arg1 = valuePop(ctxt); arg1->boolval |= arg2->boolval; valuePush(ctxt, arg1); xmlXPathReleaseObject(ctxt->context, arg2); return (total); case XPATH_OP_EQUAL: bakd = ctxt->context->doc; bak = ctxt->context->node; pp = ctxt->context->proximityPosition; cs = ctxt->context->contextSize; total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]); CHECK_ERROR0; ctxt->context->doc = bakd; ctxt->context->node = bak; ctxt->context->proximityPosition = pp; ctxt->context->contextSize = cs; total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]); CHECK_ERROR0; if (op->value) equal = xmlXPathEqualValues(ctxt); else equal = xmlXPathNotEqualValues(ctxt); valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt->context, equal)); return (total); case XPATH_OP_CMP: bakd = ctxt->context->doc; bak = ctxt->context->node; pp = ctxt->context->proximityPosition; cs = ctxt->context->contextSize; total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]); CHECK_ERROR0; ctxt->context->doc = bakd; ctxt->context->node = bak; ctxt->context->proximityPosition = pp; ctxt->context->contextSize = cs; total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]); CHECK_ERROR0; ret = xmlXPathCompareValues(ctxt, op->value, op->value2); valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt->context, ret)); return (total); case XPATH_OP_PLUS: bakd = ctxt->context->doc; bak = ctxt->context->node; pp = ctxt->context->proximityPosition; cs = ctxt->context->contextSize; total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]); CHECK_ERROR0; if (op->ch2 != -1) { ctxt->context->doc = bakd; ctxt->context->node = bak; ctxt->context->proximityPosition = pp; ctxt->context->contextSize = cs; total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]); } CHECK_ERROR0; if (op->value == 0) xmlXPathSubValues(ctxt); else if (op->value == 1) xmlXPathAddValues(ctxt); else if (op->value == 2) xmlXPathValueFlipSign(ctxt); else if (op->value == 3) { CAST_TO_NUMBER; CHECK_TYPE0(XPATH_NUMBER); } return (total); case XPATH_OP_MULT: bakd = ctxt->context->doc; bak = ctxt->context->node; pp = ctxt->context->proximityPosition; cs = ctxt->context->contextSize; total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]); CHECK_ERROR0; ctxt->context->doc = bakd; ctxt->context->node = bak; ctxt->context->proximityPosition = pp; ctxt->context->contextSize = cs; total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]); CHECK_ERROR0; if (op->value == 0) xmlXPathMultValues(ctxt); else if (op->value == 1) xmlXPathDivValues(ctxt); else if (op->value == 2) xmlXPathModValues(ctxt); return (total); case XPATH_OP_UNION: bakd = ctxt->context->doc; bak = ctxt->context->node; pp = ctxt->context->proximityPosition; cs = ctxt->context->contextSize; total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]); CHECK_ERROR0; ctxt->context->doc = bakd; ctxt->context->node = bak; ctxt->context->proximityPosition = pp; ctxt->context->contextSize = cs; total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]); CHECK_ERROR0; CHECK_TYPE0(XPATH_NODESET); arg2 = valuePop(ctxt); CHECK_TYPE0(XPATH_NODESET); arg1 = valuePop(ctxt); if ((arg1->nodesetval == NULL) || ((arg2->nodesetval != NULL) && (arg2->nodesetval->nodeNr != 0))) { arg1->nodesetval = xmlXPathNodeSetMerge(arg1->nodesetval, arg2->nodesetval); } valuePush(ctxt, arg1); xmlXPathReleaseObject(ctxt->context, arg2); return (total); case XPATH_OP_ROOT: xmlXPathRoot(ctxt); return (total); case XPATH_OP_NODE: if (op->ch1 != -1) total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]); CHECK_ERROR0; if (op->ch2 != -1) total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]); CHECK_ERROR0; valuePush(ctxt, xmlXPathCacheNewNodeSet(ctxt->context, ctxt->context->node)); return (total); case XPATH_OP_RESET: if (op->ch1 != -1) total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]); CHECK_ERROR0; if (op->ch2 != -1) total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]); CHECK_ERROR0; ctxt->context->node = NULL; return (total); case XPATH_OP_COLLECT:{ if (op->ch1 == -1) return (total); total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]); CHECK_ERROR0; total += xmlXPathNodeCollectAndTest(ctxt, op, NULL, NULL, 0); return (total); } case XPATH_OP_VALUE: valuePush(ctxt, xmlXPathCacheObjectCopy(ctxt->context, (xmlXPathObjectPtr) op->value4)); return (total); case XPATH_OP_VARIABLE:{ xmlXPathObjectPtr val; if (op->ch1 != -1) total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]); if (op->value5 == NULL) { val = xmlXPathVariableLookup(ctxt->context, op->value4); if (val == NULL) { ctxt->error = XPATH_UNDEF_VARIABLE_ERROR; return(0); } valuePush(ctxt, val); } else { const xmlChar *URI; URI = xmlXPathNsLookup(ctxt->context, op->value5); if (URI == NULL) { xmlGenericError(xmlGenericErrorContext, "xmlXPathCompOpEval: variable %s bound to undefined prefix %s\n", op->value4, op->value5); return (total); } val = xmlXPathVariableLookupNS(ctxt->context, op->value4, URI); if (val == NULL) { ctxt->error = XPATH_UNDEF_VARIABLE_ERROR; return(0); } valuePush(ctxt, val); } return (total); } case XPATH_OP_FUNCTION:{ xmlXPathFunction func; const xmlChar *oldFunc, *oldFuncURI; int i; if (op->ch1 != -1) total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]); if (ctxt->valueNr < op->value) { xmlGenericError(xmlGenericErrorContext, "xmlXPathCompOpEval: parameter error\n"); ctxt->error = XPATH_INVALID_OPERAND; return (total); } for (i = 0; i < op->value; i++) if (ctxt->valueTab[(ctxt->valueNr - 1) - i] == NULL) { xmlGenericError(xmlGenericErrorContext, "xmlXPathCompOpEval: parameter error\n"); ctxt->error = XPATH_INVALID_OPERAND; return (total); } if (op->cache != NULL) XML_CAST_FPTR(func) = (xmlXPathFunction)op->cache; else { const xmlChar *URI = NULL; if (op->value5 == NULL) func = xmlXPathFunctionLookup(ctxt->context, op->value4); else { URI = xmlXPathNsLookup(ctxt->context, op->value5); if (URI == NULL) { xmlGenericError(xmlGenericErrorContext, "xmlXPathCompOpEval: function %s bound to undefined prefix %s\n", op->value4, op->value5); return (total); } func = xmlXPathFunctionLookupNS(ctxt->context, op->value4, URI); } if (func == NULL) { xmlGenericError(xmlGenericErrorContext, "xmlXPathCompOpEval: function %s not found\n", op->value4); XP_ERROR0(XPATH_UNKNOWN_FUNC_ERROR); } op->cache = (void*)XML_CAST_FPTR(func); op->cacheURI = (void *) URI; } oldFunc = ctxt->context->function; oldFuncURI = ctxt->context->functionURI; ctxt->context->function = op->value4; ctxt->context->functionURI = op->cacheURI; func(ctxt, op->value); ctxt->context->function = oldFunc; ctxt->context->functionURI = oldFuncURI; return (total); } case XPATH_OP_ARG: bakd = ctxt->context->doc; bak = ctxt->context->node; pp = ctxt->context->proximityPosition; cs = ctxt->context->contextSize; if (op->ch1 != -1) total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]); ctxt->context->contextSize = cs; ctxt->context->proximityPosition = pp; ctxt->context->node = bak; ctxt->context->doc = bakd; CHECK_ERROR0; if (op->ch2 != -1) { total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]); ctxt->context->doc = bakd; ctxt->context->node = bak; CHECK_ERROR0; } return (total); case XPATH_OP_PREDICATE: case XPATH_OP_FILTER:{ xmlXPathObjectPtr res; xmlXPathObjectPtr obj, tmp; xmlNodeSetPtr newset = NULL; xmlNodeSetPtr oldset; xmlNodePtr oldnode; xmlDocPtr oldDoc; int i; /* * Optimization for ()[1] selection i.e. the first elem */ if ((op->ch1 != -1) && (op->ch2 != -1) && #ifdef XP_OPTIMIZED_FILTER_FIRST /* * FILTER TODO: Can we assume that the inner processing * will result in an ordered list if we have an * XPATH_OP_FILTER? * What about an additional field or flag on * xmlXPathObject like @sorted ? This way we wouln'd need * to assume anything, so it would be more robust and * easier to optimize. */ ((comp->steps[op->ch1].op == XPATH_OP_SORT) || /* 18 */ (comp->steps[op->ch1].op == XPATH_OP_FILTER)) && /* 17 */ #else (comp->steps[op->ch1].op == XPATH_OP_SORT) && #endif (comp->steps[op->ch2].op == XPATH_OP_VALUE)) { /* 12 */ xmlXPathObjectPtr val; val = comp->steps[op->ch2].value4; if ((val != NULL) && (val->type == XPATH_NUMBER) && (val->floatval == 1.0)) { xmlNodePtr first = NULL; total += xmlXPathCompOpEvalFirst(ctxt, &comp->steps[op->ch1], &first); CHECK_ERROR0; /* * The nodeset should be in document order, * Keep only the first value */ if ((ctxt->value != NULL) && (ctxt->value->type == XPATH_NODESET) && (ctxt->value->nodesetval != NULL) && (ctxt->value->nodesetval->nodeNr > 1)) ctxt->value->nodesetval->nodeNr = 1; return (total); } } /* * Optimization for ()[last()] selection i.e. the last elem */ if ((op->ch1 != -1) && (op->ch2 != -1) && (comp->steps[op->ch1].op == XPATH_OP_SORT) && (comp->steps[op->ch2].op == XPATH_OP_SORT)) { int f = comp->steps[op->ch2].ch1; if ((f != -1) && (comp->steps[f].op == XPATH_OP_FUNCTION) && (comp->steps[f].value5 == NULL) && (comp->steps[f].value == 0) && (comp->steps[f].value4 != NULL) && (xmlStrEqual (comp->steps[f].value4, BAD_CAST "last"))) { xmlNodePtr last = NULL; total += xmlXPathCompOpEvalLast(ctxt, &comp->steps[op->ch1], &last); CHECK_ERROR0; /* * The nodeset should be in document order, * Keep only the last value */ if ((ctxt->value != NULL) && (ctxt->value->type == XPATH_NODESET) && (ctxt->value->nodesetval != NULL) && (ctxt->value->nodesetval->nodeTab != NULL) && (ctxt->value->nodesetval->nodeNr > 1)) { ctxt->value->nodesetval->nodeTab[0] = ctxt->value->nodesetval->nodeTab[ctxt-> value-> nodesetval-> nodeNr - 1]; ctxt->value->nodesetval->nodeNr = 1; } return (total); } } /* * Process inner predicates first. * Example "index[parent::book][1]": * ... * PREDICATE <-- we are here "[1]" * PREDICATE <-- process "[parent::book]" first * SORT * COLLECT 'parent' 'name' 'node' book * NODE * ELEM Object is a number : 1 */ if (op->ch1 != -1) total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]); CHECK_ERROR0; if (op->ch2 == -1) return (total); if (ctxt->value == NULL) return (total); oldnode = ctxt->context->node; #ifdef LIBXML_XPTR_ENABLED /* * Hum are we filtering the result of an XPointer expression */ if (ctxt->value->type == XPATH_LOCATIONSET) { xmlLocationSetPtr newlocset = NULL; xmlLocationSetPtr oldlocset; /* * Extract the old locset, and then evaluate the result of the * expression for all the element in the locset. use it to grow * up a new locset. */ CHECK_TYPE0(XPATH_LOCATIONSET); obj = valuePop(ctxt); oldlocset = obj->user; ctxt->context->node = NULL; if ((oldlocset == NULL) || (oldlocset->locNr == 0)) { ctxt->context->contextSize = 0; ctxt->context->proximityPosition = 0; if (op->ch2 != -1) total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]); res = valuePop(ctxt); if (res != NULL) { xmlXPathReleaseObject(ctxt->context, res); } valuePush(ctxt, obj); CHECK_ERROR0; return (total); } newlocset = xmlXPtrLocationSetCreate(NULL); for (i = 0; i < oldlocset->locNr; i++) { /* * Run the evaluation with a node list made of a * single item in the nodelocset. */ ctxt->context->node = oldlocset->locTab[i]->user; ctxt->context->contextSize = oldlocset->locNr; ctxt->context->proximityPosition = i + 1; tmp = xmlXPathCacheNewNodeSet(ctxt->context, ctxt->context->node); valuePush(ctxt, tmp); if (op->ch2 != -1) total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]); if (ctxt->error != XPATH_EXPRESSION_OK) { xmlXPathFreeObject(obj); return(0); } /* * The result of the evaluation need to be tested to * decided whether the filter succeeded or not */ res = valuePop(ctxt); if (xmlXPathEvaluatePredicateResult(ctxt, res)) { xmlXPtrLocationSetAdd(newlocset, xmlXPathObjectCopy (oldlocset->locTab[i])); } /* * Cleanup */ if (res != NULL) { xmlXPathReleaseObject(ctxt->context, res); } if (ctxt->value == tmp) { res = valuePop(ctxt); xmlXPathReleaseObject(ctxt->context, res); } ctxt->context->node = NULL; } /* * The result is used as the new evaluation locset. */ xmlXPathReleaseObject(ctxt->context, obj); ctxt->context->node = NULL; ctxt->context->contextSize = -1; ctxt->context->proximityPosition = -1; valuePush(ctxt, xmlXPtrWrapLocationSet(newlocset)); ctxt->context->node = oldnode; return (total); } #endif /* LIBXML_XPTR_ENABLED */ /* * Extract the old set, and then evaluate the result of the * expression for all the element in the set. use it to grow * up a new set. */ CHECK_TYPE0(XPATH_NODESET); obj = valuePop(ctxt); oldset = obj->nodesetval; oldnode = ctxt->context->node; oldDoc = ctxt->context->doc; ctxt->context->node = NULL; if ((oldset == NULL) || (oldset->nodeNr == 0)) { ctxt->context->contextSize = 0; ctxt->context->proximityPosition = 0; /* if (op->ch2 != -1) total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]); CHECK_ERROR0; res = valuePop(ctxt); if (res != NULL) xmlXPathFreeObject(res); */ valuePush(ctxt, obj); ctxt->context->node = oldnode; CHECK_ERROR0; } else { tmp = NULL; /* * Initialize the new set. * Also set the xpath document in case things like * key() evaluation are attempted on the predicate */ newset = xmlXPathNodeSetCreate(NULL); /* * SPEC XPath 1.0: * "For each node in the node-set to be filtered, the * PredicateExpr is evaluated with that node as the * context node, with the number of nodes in the * node-set as the context size, and with the proximity * position of the node in the node-set with respect to * the axis as the context position;" * @oldset is the node-set" to be filtered. * * SPEC XPath 1.0: * "only predicates change the context position and * context size (see [2.4 Predicates])." * Example: * node-set context pos * nA 1 * nB 2 * nC 3 * After applying predicate [position() > 1] : * node-set context pos * nB 1 * nC 2 * * removed the first node in the node-set, then * the context position of the */ for (i = 0; i < oldset->nodeNr; i++) { /* * Run the evaluation with a node list made of * a single item in the nodeset. */ ctxt->context->node = oldset->nodeTab[i]; if ((oldset->nodeTab[i]->type != XML_NAMESPACE_DECL) && (oldset->nodeTab[i]->doc != NULL)) ctxt->context->doc = oldset->nodeTab[i]->doc; if (tmp == NULL) { tmp = xmlXPathCacheNewNodeSet(ctxt->context, ctxt->context->node); } else { xmlXPathNodeSetAddUnique(tmp->nodesetval, ctxt->context->node); } valuePush(ctxt, tmp); ctxt->context->contextSize = oldset->nodeNr; ctxt->context->proximityPosition = i + 1; /* * Evaluate the predicate against the context node. * Can/should we optimize position() predicates * here (e.g. "[1]")? */ if (op->ch2 != -1) total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]); if (ctxt->error != XPATH_EXPRESSION_OK) { xmlXPathFreeNodeSet(newset); xmlXPathFreeObject(obj); return(0); } /* * The result of the evaluation needs to be tested to * decide whether the filter succeeded or not */ /* * OPTIMIZE TODO: Can we use * xmlXPathNodeSetAdd*Unique()* instead? */ res = valuePop(ctxt); if (xmlXPathEvaluatePredicateResult(ctxt, res)) { xmlXPathNodeSetAdd(newset, oldset->nodeTab[i]); } /* * Cleanup */ if (res != NULL) { xmlXPathReleaseObject(ctxt->context, res); } if (ctxt->value == tmp) { valuePop(ctxt); xmlXPathNodeSetClear(tmp->nodesetval, 1); /* * Don't free the temporary nodeset * in order to avoid massive recreation inside this * loop. */ } else tmp = NULL; ctxt->context->node = NULL; } if (tmp != NULL) xmlXPathReleaseObject(ctxt->context, tmp); /* * The result is used as the new evaluation set. */ xmlXPathReleaseObject(ctxt->context, obj); ctxt->context->node = NULL; ctxt->context->contextSize = -1; ctxt->context->proximityPosition = -1; /* may want to move this past the '}' later */ ctxt->context->doc = oldDoc; valuePush(ctxt, xmlXPathCacheWrapNodeSet(ctxt->context, newset)); } ctxt->context->node = oldnode; return (total); } case XPATH_OP_SORT: if (op->ch1 != -1) total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]); CHECK_ERROR0; if ((ctxt->value != NULL) && (ctxt->value->type == XPATH_NODESET) && (ctxt->value->nodesetval != NULL) && (ctxt->value->nodesetval->nodeNr > 1)) { xmlXPathNodeSetSort(ctxt->value->nodesetval); } return (total); #ifdef LIBXML_XPTR_ENABLED case XPATH_OP_RANGETO:{ xmlXPathObjectPtr range; xmlXPathObjectPtr res, obj; xmlXPathObjectPtr tmp; xmlLocationSetPtr newlocset = NULL; xmlLocationSetPtr oldlocset; xmlNodeSetPtr oldset; int i, j; if (op->ch1 != -1) total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]); if (op->ch2 == -1) return (total); if (ctxt->value->type == XPATH_LOCATIONSET) { /* * Extract the old locset, and then evaluate the result of the * expression for all the element in the locset. use it to grow * up a new locset. */ CHECK_TYPE0(XPATH_LOCATIONSET); obj = valuePop(ctxt); oldlocset = obj->user; if ((oldlocset == NULL) || (oldlocset->locNr == 0)) { ctxt->context->node = NULL; ctxt->context->contextSize = 0; ctxt->context->proximityPosition = 0; total += xmlXPathCompOpEval(ctxt,&comp->steps[op->ch2]); res = valuePop(ctxt); if (res != NULL) { xmlXPathReleaseObject(ctxt->context, res); } valuePush(ctxt, obj); CHECK_ERROR0; return (total); } newlocset = xmlXPtrLocationSetCreate(NULL); for (i = 0; i < oldlocset->locNr; i++) { /* * Run the evaluation with a node list made of a * single item in the nodelocset. */ ctxt->context->node = oldlocset->locTab[i]->user; ctxt->context->contextSize = oldlocset->locNr; ctxt->context->proximityPosition = i + 1; tmp = xmlXPathCacheNewNodeSet(ctxt->context, ctxt->context->node); valuePush(ctxt, tmp); if (op->ch2 != -1) total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]); if (ctxt->error != XPATH_EXPRESSION_OK) { xmlXPathFreeObject(obj); return(0); } res = valuePop(ctxt); if (res->type == XPATH_LOCATIONSET) { xmlLocationSetPtr rloc = (xmlLocationSetPtr)res->user; for (j=0; jlocNr; j++) { range = xmlXPtrNewRange( oldlocset->locTab[i]->user, oldlocset->locTab[i]->index, rloc->locTab[j]->user2, rloc->locTab[j]->index2); if (range != NULL) { xmlXPtrLocationSetAdd(newlocset, range); } } } else { range = xmlXPtrNewRangeNodeObject( (xmlNodePtr)oldlocset->locTab[i]->user, res); if (range != NULL) { xmlXPtrLocationSetAdd(newlocset,range); } } /* * Cleanup */ if (res != NULL) { xmlXPathReleaseObject(ctxt->context, res); } if (ctxt->value == tmp) { res = valuePop(ctxt); xmlXPathReleaseObject(ctxt->context, res); } ctxt->context->node = NULL; } } else { /* Not a location set */ CHECK_TYPE0(XPATH_NODESET); obj = valuePop(ctxt); oldset = obj->nodesetval; ctxt->context->node = NULL; newlocset = xmlXPtrLocationSetCreate(NULL); if (oldset != NULL) { for (i = 0; i < oldset->nodeNr; i++) { /* * Run the evaluation with a node list made of a single item * in the nodeset. */ ctxt->context->node = oldset->nodeTab[i]; /* * OPTIMIZE TODO: Avoid recreation for every iteration. */ tmp = xmlXPathCacheNewNodeSet(ctxt->context, ctxt->context->node); valuePush(ctxt, tmp); if (op->ch2 != -1) total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]); if (ctxt->error != XPATH_EXPRESSION_OK) { xmlXPathFreeObject(obj); return(0); } res = valuePop(ctxt); range = xmlXPtrNewRangeNodeObject(oldset->nodeTab[i], res); if (range != NULL) { xmlXPtrLocationSetAdd(newlocset, range); } /* * Cleanup */ if (res != NULL) { xmlXPathReleaseObject(ctxt->context, res); } if (ctxt->value == tmp) { res = valuePop(ctxt); xmlXPathReleaseObject(ctxt->context, res); } ctxt->context->node = NULL; } } } /* * The result is used as the new evaluation set. */ xmlXPathReleaseObject(ctxt->context, obj); ctxt->context->node = NULL; ctxt->context->contextSize = -1; ctxt->context->proximityPosition = -1; valuePush(ctxt, xmlXPtrWrapLocationSet(newlocset)); return (total); } #endif /* LIBXML_XPTR_ENABLED */ } xmlGenericError(xmlGenericErrorContext, "XPath: unknown precompiled operation %d\n", op->op); return (total); } /** * xmlXPathCompOpEvalToBoolean: * @ctxt: the XPath parser context * * Evaluates if the expression evaluates to true. * * Returns 1 if true, 0 if false and -1 on API or internal errors. */ static int xmlXPathCompOpEvalToBoolean(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op, int isPredicate) { xmlXPathObjectPtr resObj = NULL; start: /* comp = ctxt->comp; */ switch (op->op) { case XPATH_OP_END: return (0); case XPATH_OP_VALUE: resObj = (xmlXPathObjectPtr) op->value4; if (isPredicate) return(xmlXPathEvaluatePredicateResult(ctxt, resObj)); return(xmlXPathCastToBoolean(resObj)); case XPATH_OP_SORT: /* * We don't need sorting for boolean results. Skip this one. */ if (op->ch1 != -1) { op = &ctxt->comp->steps[op->ch1]; goto start; } return(0); case XPATH_OP_COLLECT: if (op->ch1 == -1) return(0); xmlXPathCompOpEval(ctxt, &ctxt->comp->steps[op->ch1]); if (ctxt->error != XPATH_EXPRESSION_OK) return(-1); xmlXPathNodeCollectAndTest(ctxt, op, NULL, NULL, 1); if (ctxt->error != XPATH_EXPRESSION_OK) return(-1); resObj = valuePop(ctxt); if (resObj == NULL) return(-1); break; default: /* * Fallback to call xmlXPathCompOpEval(). */ xmlXPathCompOpEval(ctxt, op); if (ctxt->error != XPATH_EXPRESSION_OK) return(-1); resObj = valuePop(ctxt); if (resObj == NULL) return(-1); break; } if (resObj) { int res; if (resObj->type == XPATH_BOOLEAN) { res = resObj->boolval; } else if (isPredicate) { /* * For predicates a result of type "number" is handled * differently: * SPEC XPath 1.0: * "If the result is a number, the result will be converted * to true if the number is equal to the context position * and will be converted to false otherwise;" */ res = xmlXPathEvaluatePredicateResult(ctxt, resObj); } else { res = xmlXPathCastToBoolean(resObj); } xmlXPathReleaseObject(ctxt->context, resObj); return(res); } return(0); } #ifdef XPATH_STREAMING /** * xmlXPathRunStreamEval: * @ctxt: the XPath parser context with the compiled expression * * Evaluate the Precompiled Streamable XPath expression in the given context. */ static int xmlXPathRunStreamEval(xmlXPathContextPtr ctxt, xmlPatternPtr comp, xmlXPathObjectPtr *resultSeq, int toBool) { int max_depth, min_depth; int from_root; int ret, depth; int eval_all_nodes; xmlNodePtr cur = NULL, limit = NULL; xmlStreamCtxtPtr patstream = NULL; int nb_nodes = 0; if ((ctxt == NULL) || (comp == NULL)) return(-1); max_depth = xmlPatternMaxDepth(comp); if (max_depth == -1) return(-1); if (max_depth == -2) max_depth = 10000; min_depth = xmlPatternMinDepth(comp); if (min_depth == -1) return(-1); from_root = xmlPatternFromRoot(comp); if (from_root < 0) return(-1); #if 0 printf("stream eval: depth %d from root %d\n", max_depth, from_root); #endif if (! toBool) { if (resultSeq == NULL) return(-1); *resultSeq = xmlXPathCacheNewNodeSet(ctxt, NULL); if (*resultSeq == NULL) return(-1); } /* * handle the special cases of "/" amd "." being matched */ if (min_depth == 0) { if (from_root) { /* Select "/" */ if (toBool) return(1); xmlXPathNodeSetAddUnique((*resultSeq)->nodesetval, (xmlNodePtr) ctxt->doc); } else { /* Select "self::node()" */ if (toBool) return(1); xmlXPathNodeSetAddUnique((*resultSeq)->nodesetval, ctxt->node); } } if (max_depth == 0) { return(0); } if (from_root) { cur = (xmlNodePtr)ctxt->doc; } else if (ctxt->node != NULL) { switch (ctxt->node->type) { case XML_ELEMENT_NODE: case XML_DOCUMENT_NODE: case XML_DOCUMENT_FRAG_NODE: case XML_HTML_DOCUMENT_NODE: #ifdef LIBXML_DOCB_ENABLED case XML_DOCB_DOCUMENT_NODE: #endif cur = ctxt->node; break; case XML_ATTRIBUTE_NODE: case XML_TEXT_NODE: case XML_CDATA_SECTION_NODE: case XML_ENTITY_REF_NODE: case XML_ENTITY_NODE: case XML_PI_NODE: case XML_COMMENT_NODE: case XML_NOTATION_NODE: case XML_DTD_NODE: case XML_DOCUMENT_TYPE_NODE: case XML_ELEMENT_DECL: case XML_ATTRIBUTE_DECL: case XML_ENTITY_DECL: case XML_NAMESPACE_DECL: case XML_XINCLUDE_START: case XML_XINCLUDE_END: break; } limit = cur; } if (cur == NULL) { return(0); } patstream = xmlPatternGetStreamCtxt(comp); if (patstream == NULL) { /* * QUESTION TODO: Is this an error? */ return(0); } eval_all_nodes = xmlStreamWantsAnyNode(patstream); if (from_root) { ret = xmlStreamPush(patstream, NULL, NULL); if (ret < 0) { } else if (ret == 1) { if (toBool) goto return_1; xmlXPathNodeSetAddUnique((*resultSeq)->nodesetval, cur); } } depth = 0; goto scan_children; next_node: do { nb_nodes++; switch (cur->type) { case XML_ELEMENT_NODE: case XML_TEXT_NODE: case XML_CDATA_SECTION_NODE: case XML_COMMENT_NODE: case XML_PI_NODE: if (cur->type == XML_ELEMENT_NODE) { ret = xmlStreamPush(patstream, cur->name, (cur->ns ? cur->ns->href : NULL)); } else if (eval_all_nodes) ret = xmlStreamPushNode(patstream, NULL, NULL, cur->type); else break; if (ret < 0) { /* NOP. */ } else if (ret == 1) { if (toBool) goto return_1; xmlXPathNodeSetAddUnique((*resultSeq)->nodesetval, cur); } if ((cur->children == NULL) || (depth >= max_depth)) { ret = xmlStreamPop(patstream); while (cur->next != NULL) { cur = cur->next; if ((cur->type != XML_ENTITY_DECL) && (cur->type != XML_DTD_NODE)) goto next_node; } } default: break; } scan_children: if ((cur->children != NULL) && (depth < max_depth)) { /* * Do not descend on entities declarations */ if (cur->children->type != XML_ENTITY_DECL) { cur = cur->children; depth++; /* * Skip DTDs */ if (cur->type != XML_DTD_NODE) continue; } } if (cur == limit) break; while (cur->next != NULL) { cur = cur->next; if ((cur->type != XML_ENTITY_DECL) && (cur->type != XML_DTD_NODE)) goto next_node; } do { cur = cur->parent; depth--; if ((cur == NULL) || (cur == limit)) goto done; if (cur->type == XML_ELEMENT_NODE) { ret = xmlStreamPop(patstream); } else if ((eval_all_nodes) && ((cur->type == XML_TEXT_NODE) || (cur->type == XML_CDATA_SECTION_NODE) || (cur->type == XML_COMMENT_NODE) || (cur->type == XML_PI_NODE))) { ret = xmlStreamPop(patstream); } if (cur->next != NULL) { cur = cur->next; break; } } while (cur != NULL); } while ((cur != NULL) && (depth >= 0)); done: #if 0 printf("stream eval: checked %d nodes selected %d\n", nb_nodes, retObj->nodesetval->nodeNr); #endif if (patstream) xmlFreeStreamCtxt(patstream); return(0); return_1: if (patstream) xmlFreeStreamCtxt(patstream); return(1); } #endif /* XPATH_STREAMING */ /** * xmlXPathRunEval: * @ctxt: the XPath parser context with the compiled expression * @toBool: evaluate to a boolean result * * Evaluate the Precompiled XPath expression in the given context. */ static int xmlXPathRunEval(xmlXPathParserContextPtr ctxt, int toBool) { xmlXPathCompExprPtr comp; if ((ctxt == NULL) || (ctxt->comp == NULL)) return(-1); if (ctxt->valueTab == NULL) { /* Allocate the value stack */ ctxt->valueTab = (xmlXPathObjectPtr *) xmlMalloc(10 * sizeof(xmlXPathObjectPtr)); if (ctxt->valueTab == NULL) { xmlXPathPErrMemory(ctxt, "creating evaluation context\n"); xmlFree(ctxt); } ctxt->valueNr = 0; ctxt->valueMax = 10; ctxt->value = NULL; } #ifdef XPATH_STREAMING if (ctxt->comp->stream) { int res; if (toBool) { /* * Evaluation to boolean result. */ res = xmlXPathRunStreamEval(ctxt->context, ctxt->comp->stream, NULL, 1); if (res != -1) return(res); } else { xmlXPathObjectPtr resObj = NULL; /* * Evaluation to a sequence. */ res = xmlXPathRunStreamEval(ctxt->context, ctxt->comp->stream, &resObj, 0); if ((res != -1) && (resObj != NULL)) { valuePush(ctxt, resObj); return(0); } if (resObj != NULL) xmlXPathReleaseObject(ctxt->context, resObj); } /* * QUESTION TODO: This falls back to normal XPath evaluation * if res == -1. Is this intended? */ } #endif comp = ctxt->comp; if (comp->last < 0) { xmlGenericError(xmlGenericErrorContext, "xmlXPathRunEval: last is less than zero\n"); return(-1); } if (toBool) return(xmlXPathCompOpEvalToBoolean(ctxt, &comp->steps[comp->last], 0)); else xmlXPathCompOpEval(ctxt, &comp->steps[comp->last]); return(0); } /************************************************************************ * * * Public interfaces * * * ************************************************************************/ /** * xmlXPathEvalPredicate: * @ctxt: the XPath context * @res: the Predicate Expression evaluation result * * Evaluate a predicate result for the current node. * A PredicateExpr is evaluated by evaluating the Expr and converting * the result to a boolean. If the result is a number, the result will * be converted to true if the number is equal to the position of the * context node in the context node list (as returned by the position * function) and will be converted to false otherwise; if the result * is not a number, then the result will be converted as if by a call * to the boolean function. * * Returns 1 if predicate is true, 0 otherwise */ int xmlXPathEvalPredicate(xmlXPathContextPtr ctxt, xmlXPathObjectPtr res) { if ((ctxt == NULL) || (res == NULL)) return(0); switch (res->type) { case XPATH_BOOLEAN: return(res->boolval); case XPATH_NUMBER: return(res->floatval == ctxt->proximityPosition); case XPATH_NODESET: case XPATH_XSLT_TREE: if (res->nodesetval == NULL) return(0); return(res->nodesetval->nodeNr != 0); case XPATH_STRING: return((res->stringval != NULL) && (xmlStrlen(res->stringval) != 0)); default: STRANGE } return(0); } /** * xmlXPathEvaluatePredicateResult: * @ctxt: the XPath Parser context * @res: the Predicate Expression evaluation result * * Evaluate a predicate result for the current node. * A PredicateExpr is evaluated by evaluating the Expr and converting * the result to a boolean. If the result is a number, the result will * be converted to true if the number is equal to the position of the * context node in the context node list (as returned by the position * function) and will be converted to false otherwise; if the result * is not a number, then the result will be converted as if by a call * to the boolean function. * * Returns 1 if predicate is true, 0 otherwise */ int xmlXPathEvaluatePredicateResult(xmlXPathParserContextPtr ctxt, xmlXPathObjectPtr res) { if ((ctxt == NULL) || (res == NULL)) return(0); switch (res->type) { case XPATH_BOOLEAN: return(res->boolval); case XPATH_NUMBER: #if defined(__BORLANDC__) || (defined(_MSC_VER) && (_MSC_VER == 1200)) return((res->floatval == ctxt->context->proximityPosition) && (!xmlXPathIsNaN(res->floatval))); /* MSC pbm Mark Vakoc !*/ #else return(res->floatval == ctxt->context->proximityPosition); #endif case XPATH_NODESET: case XPATH_XSLT_TREE: if (res->nodesetval == NULL) return(0); return(res->nodesetval->nodeNr != 0); case XPATH_STRING: return((res->stringval != NULL) && (res->stringval[0] != 0)); #ifdef LIBXML_XPTR_ENABLED case XPATH_LOCATIONSET:{ xmlLocationSetPtr ptr = res->user; if (ptr == NULL) return(0); return (ptr->locNr != 0); } #endif default: STRANGE } return(0); } #ifdef XPATH_STREAMING /** * xmlXPathTryStreamCompile: * @ctxt: an XPath context * @str: the XPath expression * * Try to compile the XPath expression as a streamable subset. * * Returns the compiled expression or NULL if failed to compile. */ static xmlXPathCompExprPtr xmlXPathTryStreamCompile(xmlXPathContextPtr ctxt, const xmlChar *str) { /* * Optimization: use streaming patterns when the XPath expression can * be compiled to a stream lookup */ xmlPatternPtr stream; xmlXPathCompExprPtr comp; xmlDictPtr dict = NULL; const xmlChar **namespaces = NULL; xmlNsPtr ns; int i, j; if ((!xmlStrchr(str, '[')) && (!xmlStrchr(str, '(')) && (!xmlStrchr(str, '@'))) { const xmlChar *tmp; /* * We don't try to handle expressions using the verbose axis * specifiers ("::"), just the simplied form at this point. * Additionally, if there is no list of namespaces available and * there's a ":" in the expression, indicating a prefixed QName, * then we won't try to compile either. xmlPatterncompile() needs * to have a list of namespaces at compilation time in order to * compile prefixed name tests. */ tmp = xmlStrchr(str, ':'); if ((tmp != NULL) && ((ctxt == NULL) || (ctxt->nsNr == 0) || (tmp[1] == ':'))) return(NULL); if (ctxt != NULL) { dict = ctxt->dict; if (ctxt->nsNr > 0) { namespaces = xmlMalloc(2 * (ctxt->nsNr + 1) * sizeof(xmlChar*)); if (namespaces == NULL) { xmlXPathErrMemory(ctxt, "allocating namespaces array\n"); return(NULL); } for (i = 0, j = 0; (j < ctxt->nsNr); j++) { ns = ctxt->namespaces[j]; namespaces[i++] = ns->href; namespaces[i++] = ns->prefix; } namespaces[i++] = NULL; namespaces[i++] = NULL; } } stream = xmlPatterncompile(str, dict, XML_PATTERN_XPATH, &namespaces[0]); if (namespaces != NULL) { xmlFree((xmlChar **)namespaces); } if ((stream != NULL) && (xmlPatternStreamable(stream) == 1)) { comp = xmlXPathNewCompExpr(); if (comp == NULL) { xmlXPathErrMemory(ctxt, "allocating streamable expression\n"); return(NULL); } comp->stream = stream; comp->dict = dict; if (comp->dict) xmlDictReference(comp->dict); return(comp); } xmlFreePattern(stream); } return(NULL); } #endif /* XPATH_STREAMING */ static int xmlXPathCanRewriteDosExpression(xmlChar *expr) { if (expr == NULL) return(0); do { if ((*expr == '/') && (*(++expr) == '/')) return(1); } while (*expr++); return(0); } static void xmlXPathRewriteDOSExpression(xmlXPathCompExprPtr comp, xmlXPathStepOpPtr op) { /* * Try to rewrite "descendant-or-self::node()/foo" to an optimized * internal representation. */ if (op->ch1 != -1) { if ((op->op == XPATH_OP_COLLECT /* 11 */) && ((xmlXPathAxisVal) op->value == AXIS_CHILD /* 4 */) && ((xmlXPathTestVal) op->value2 == NODE_TEST_NAME /* 5 */) && ((xmlXPathTypeVal) op->value3 == NODE_TYPE_NODE /* 0 */)) { /* * This is a "child::foo" */ xmlXPathStepOpPtr prevop = &comp->steps[op->ch1]; if ((prevop->op == XPATH_OP_COLLECT /* 11 */) && (prevop->ch1 != -1) && ((xmlXPathAxisVal) prevop->value == AXIS_DESCENDANT_OR_SELF) && (prevop->ch2 == -1) && ((xmlXPathTestVal) prevop->value2 == NODE_TEST_TYPE) && ((xmlXPathTypeVal) prevop->value3 == NODE_TYPE_NODE) && (comp->steps[prevop->ch1].op == XPATH_OP_ROOT)) { /* * This is a "/descendant-or-self::node()" without predicates. * Eliminate it. */ op->ch1 = prevop->ch1; op->rewriteType = XP_REWRITE_DOS_CHILD_ELEM; } } if (op->ch1 != -1) xmlXPathRewriteDOSExpression(comp, &comp->steps[op->ch1]); } if (op->ch2 != -1) xmlXPathRewriteDOSExpression(comp, &comp->steps[op->ch2]); } /** * xmlXPathCtxtCompile: * @ctxt: an XPath context * @str: the XPath expression * * Compile an XPath expression * * Returns the xmlXPathCompExprPtr resulting from the compilation or NULL. * the caller has to free the object. */ xmlXPathCompExprPtr xmlXPathCtxtCompile(xmlXPathContextPtr ctxt, const xmlChar *str) { xmlXPathParserContextPtr pctxt; xmlXPathCompExprPtr comp; #ifdef XPATH_STREAMING comp = xmlXPathTryStreamCompile(ctxt, str); if (comp != NULL) return(comp); #endif xmlXPathInit(); pctxt = xmlXPathNewParserContext(str, ctxt); xmlXPathCompileExpr(pctxt, 1); if( pctxt->error != XPATH_EXPRESSION_OK ) { xmlXPathFreeParserContext(pctxt); return(NULL); } if (*pctxt->cur != 0) { /* * aleksey: in some cases this line prints *second* error message * (see bug #78858) and probably this should be fixed. * However, we are not sure that all error messages are printed * out in other places. It's not critical so we leave it as-is for now */ xmlXPatherror(pctxt, __FILE__, __LINE__, XPATH_EXPR_ERROR); comp = NULL; } else { comp = pctxt->comp; pctxt->comp = NULL; } xmlXPathFreeParserContext(pctxt); if (comp != NULL) { comp->expr = xmlStrdup(str); #ifdef DEBUG_EVAL_COUNTS comp->string = xmlStrdup(str); comp->nb = 0; #endif if ((comp->expr != NULL) && (comp->nbStep > 2) && (comp->last >= 0) && (xmlXPathCanRewriteDosExpression(comp->expr) == 1)) { xmlXPathRewriteDOSExpression(comp, &comp->steps[comp->last]); } } return(comp); } /** * xmlXPathCompile: * @str: the XPath expression * * Compile an XPath expression * * Returns the xmlXPathCompExprPtr resulting from the compilation or NULL. * the caller has to free the object. */ xmlXPathCompExprPtr xmlXPathCompile(const xmlChar *str) { return(xmlXPathCtxtCompile(NULL, str)); } /** * xmlXPathCompiledEvalInternal: * @comp: the compiled XPath expression * @ctxt: the XPath context * @resObj: the resulting XPath object or NULL * @toBool: 1 if only a boolean result is requested * * Evaluate the Precompiled XPath expression in the given context. * The caller has to free @resObj. * * Returns the xmlXPathObjectPtr resulting from the evaluation or NULL. * the caller has to free the object. */ static int xmlXPathCompiledEvalInternal(xmlXPathCompExprPtr comp, xmlXPathContextPtr ctxt, xmlXPathObjectPtr *resObj, int toBool) { xmlXPathParserContextPtr pctxt; #ifndef LIBXML_THREAD_ENABLED static int reentance = 0; #endif int res; CHECK_CTXT_NEG(ctxt) if (comp == NULL) return(-1); xmlXPathInit(); #ifndef LIBXML_THREAD_ENABLED reentance++; if (reentance > 1) xmlXPathDisableOptimizer = 1; #endif #ifdef DEBUG_EVAL_COUNTS comp->nb++; if ((comp->string != NULL) && (comp->nb > 100)) { fprintf(stderr, "100 x %s\n", comp->string); comp->nb = 0; } #endif pctxt = xmlXPathCompParserContext(comp, ctxt); res = xmlXPathRunEval(pctxt, toBool); if (resObj) { if (pctxt->value == NULL) { xmlGenericError(xmlGenericErrorContext, "xmlXPathCompiledEval: evaluation failed\n"); *resObj = NULL; } else { *resObj = valuePop(pctxt); } } /* * Pop all remaining objects from the stack. */ if (pctxt->valueNr > 0) { xmlXPathObjectPtr tmp; int stack = 0; do { tmp = valuePop(pctxt); if (tmp != NULL) { if (tmp != NULL) stack++; xmlXPathReleaseObject(ctxt, tmp); } } while (tmp != NULL); if ((stack != 0) && ((toBool) || ((resObj) && (*resObj)))) { xmlGenericError(xmlGenericErrorContext, "xmlXPathCompiledEval: %d objects left on the stack.\n", stack); } } if ((pctxt->error != XPATH_EXPRESSION_OK) && (resObj) && (*resObj)) { xmlXPathFreeObject(*resObj); *resObj = NULL; } pctxt->comp = NULL; xmlXPathFreeParserContext(pctxt); #ifndef LIBXML_THREAD_ENABLED reentance--; #endif return(res); } /** * xmlXPathCompiledEval: * @comp: the compiled XPath expression * @ctx: the XPath context * * Evaluate the Precompiled XPath expression in the given context. * * Returns the xmlXPathObjectPtr resulting from the evaluation or NULL. * the caller has to free the object. */ xmlXPathObjectPtr xmlXPathCompiledEval(xmlXPathCompExprPtr comp, xmlXPathContextPtr ctx) { xmlXPathObjectPtr res = NULL; xmlXPathCompiledEvalInternal(comp, ctx, &res, 0); return(res); } /** * xmlXPathCompiledEvalToBoolean: * @comp: the compiled XPath expression * @ctxt: the XPath context * * Applies the XPath boolean() function on the result of the given * compiled expression. * * Returns 1 if the expression evaluated to true, 0 if to false and * -1 in API and internal errors. */ int xmlXPathCompiledEvalToBoolean(xmlXPathCompExprPtr comp, xmlXPathContextPtr ctxt) { return(xmlXPathCompiledEvalInternal(comp, ctxt, NULL, 1)); } /** * xmlXPathEvalExpr: * @ctxt: the XPath Parser context * * Parse and evaluate an XPath expression in the given context, * then push the result on the context stack */ void xmlXPathEvalExpr(xmlXPathParserContextPtr ctxt) { #ifdef XPATH_STREAMING xmlXPathCompExprPtr comp; #endif if (ctxt == NULL) return; #ifdef XPATH_STREAMING comp = xmlXPathTryStreamCompile(ctxt->context, ctxt->base); if (comp != NULL) { if (ctxt->comp != NULL) xmlXPathFreeCompExpr(ctxt->comp); ctxt->comp = comp; if (ctxt->cur != NULL) while (*ctxt->cur != 0) ctxt->cur++; } else #endif { xmlXPathCompileExpr(ctxt, 1); /* * In this scenario the expression string will sit in ctxt->base. */ if ((ctxt->error == XPATH_EXPRESSION_OK) && (ctxt->comp != NULL) && (ctxt->base != NULL) && (ctxt->comp->nbStep > 2) && (ctxt->comp->last >= 0) && (xmlXPathCanRewriteDosExpression((xmlChar *) ctxt->base) == 1)) { xmlXPathRewriteDOSExpression(ctxt->comp, &ctxt->comp->steps[ctxt->comp->last]); } } CHECK_ERROR; xmlXPathRunEval(ctxt, 0); } /** * xmlXPathEval: * @str: the XPath expression * @ctx: the XPath context * * Evaluate the XPath Location Path in the given context. * * Returns the xmlXPathObjectPtr resulting from the evaluation or NULL. * the caller has to free the object. */ xmlXPathObjectPtr xmlXPathEval(const xmlChar *str, xmlXPathContextPtr ctx) { xmlXPathParserContextPtr ctxt; xmlXPathObjectPtr res, tmp, init = NULL; int stack = 0; CHECK_CTXT(ctx) xmlXPathInit(); ctxt = xmlXPathNewParserContext(str, ctx); xmlXPathEvalExpr(ctxt); if (ctxt->value == NULL) { xmlGenericError(xmlGenericErrorContext, "xmlXPathEval: evaluation failed\n"); res = NULL; } else if ((*ctxt->cur != 0) && (ctxt->comp != NULL) #ifdef XPATH_STREAMING && (ctxt->comp->stream == NULL) #endif ) { xmlXPatherror(ctxt, __FILE__, __LINE__, XPATH_EXPR_ERROR); res = NULL; } else { res = valuePop(ctxt); } do { tmp = valuePop(ctxt); if (tmp != NULL) { if (tmp != init) stack++; xmlXPathReleaseObject(ctx, tmp); } } while (tmp != NULL); if ((stack != 0) && (res != NULL)) { xmlGenericError(xmlGenericErrorContext, "xmlXPathEval: %d object left on the stack\n", stack); } if (ctxt->error != XPATH_EXPRESSION_OK) { xmlXPathFreeObject(res); res = NULL; } xmlXPathFreeParserContext(ctxt); return(res); } /** * xmlXPathEvalExpression: * @str: the XPath expression * @ctxt: the XPath context * * Evaluate the XPath expression in the given context. * * Returns the xmlXPathObjectPtr resulting from the evaluation or NULL. * the caller has to free the object. */ xmlXPathObjectPtr xmlXPathEvalExpression(const xmlChar *str, xmlXPathContextPtr ctxt) { xmlXPathParserContextPtr pctxt; xmlXPathObjectPtr res, tmp; int stack = 0; CHECK_CTXT(ctxt) xmlXPathInit(); pctxt = xmlXPathNewParserContext(str, ctxt); xmlXPathEvalExpr(pctxt); if ((*pctxt->cur != 0) || (pctxt->error != XPATH_EXPRESSION_OK)) { xmlXPatherror(pctxt, __FILE__, __LINE__, XPATH_EXPR_ERROR); res = NULL; } else { res = valuePop(pctxt); } do { tmp = valuePop(pctxt); if (tmp != NULL) { xmlXPathReleaseObject(ctxt, tmp); stack++; } } while (tmp != NULL); if ((stack != 0) && (res != NULL)) { xmlGenericError(xmlGenericErrorContext, "xmlXPathEvalExpression: %d object left on the stack\n", stack); } xmlXPathFreeParserContext(pctxt); return(res); } /************************************************************************ * * * Extra functions not pertaining to the XPath spec * * * ************************************************************************/ /** * xmlXPathEscapeUriFunction: * @ctxt: the XPath Parser context * @nargs: the number of arguments * * Implement the escape-uri() XPath function * string escape-uri(string $str, bool $escape-reserved) * * This function applies the URI escaping rules defined in section 2 of [RFC * 2396] to the string supplied as $uri-part, which typically represents all * or part of a URI. The effect of the function is to replace any special * character in the string by an escape sequence of the form %xx%yy..., * where xxyy... is the hexadecimal representation of the octets used to * represent the character in UTF-8. * * The set of characters that are escaped depends on the setting of the * boolean argument $escape-reserved. * * If $escape-reserved is true, all characters are escaped other than lower * case letters a-z, upper case letters A-Z, digits 0-9, and the characters * referred to in [RFC 2396] as "marks": specifically, "-" | "_" | "." | "!" * | "~" | "*" | "'" | "(" | ")". The "%" character itself is escaped only * if it is not followed by two hexadecimal digits (that is, 0-9, a-f, and * A-F). * * If $escape-reserved is false, the behavior differs in that characters * referred to in [RFC 2396] as reserved characters are not escaped. These * characters are ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | "$" | ",". * * [RFC 2396] does not define whether escaped URIs should use lower case or * upper case for hexadecimal digits. To ensure that escaped URIs can be * compared using string comparison functions, this function must always use * the upper-case letters A-F. * * Generally, $escape-reserved should be set to true when escaping a string * that is to form a single part of a URI, and to false when escaping an * entire URI or URI reference. * * In the case of non-ascii characters, the string is encoded according to * utf-8 and then converted according to RFC 2396. * * Examples * xf:escape-uri ("gopher://spinaltap.micro.umn.edu/00/Weather/California/Los%20Angeles#ocean"), true()) * returns "gopher%3A%2F%2Fspinaltap.micro.umn.edu%2F00%2FWeather%2FCalifornia%2FLos%20Angeles%23ocean" * xf:escape-uri ("gopher://spinaltap.micro.umn.edu/00/Weather/California/Los%20Angeles#ocean"), false()) * returns "gopher://spinaltap.micro.umn.edu/00/Weather/California/Los%20Angeles%23ocean" * */ static void xmlXPathEscapeUriFunction(xmlXPathParserContextPtr ctxt, int nargs) { xmlXPathObjectPtr str; int escape_reserved; xmlBufferPtr target; xmlChar *cptr; xmlChar escape[4]; CHECK_ARITY(2); escape_reserved = xmlXPathPopBoolean(ctxt); CAST_TO_STRING; str = valuePop(ctxt); target = xmlBufferCreate(); escape[0] = '%'; escape[3] = 0; if (target) { for (cptr = str->stringval; *cptr; cptr++) { if ((*cptr >= 'A' && *cptr <= 'Z') || (*cptr >= 'a' && *cptr <= 'z') || (*cptr >= '0' && *cptr <= '9') || *cptr == '-' || *cptr == '_' || *cptr == '.' || *cptr == '!' || *cptr == '~' || *cptr == '*' || *cptr == '\''|| *cptr == '(' || *cptr == ')' || (*cptr == '%' && ((cptr[1] >= 'A' && cptr[1] <= 'F') || (cptr[1] >= 'a' && cptr[1] <= 'f') || (cptr[1] >= '0' && cptr[1] <= '9')) && ((cptr[2] >= 'A' && cptr[2] <= 'F') || (cptr[2] >= 'a' && cptr[2] <= 'f') || (cptr[2] >= '0' && cptr[2] <= '9'))) || (!escape_reserved && (*cptr == ';' || *cptr == '/' || *cptr == '?' || *cptr == ':' || *cptr == '@' || *cptr == '&' || *cptr == '=' || *cptr == '+' || *cptr == '$' || *cptr == ','))) { xmlBufferAdd(target, cptr, 1); } else { if ((*cptr >> 4) < 10) escape[1] = '0' + (*cptr >> 4); else escape[1] = 'A' - 10 + (*cptr >> 4); if ((*cptr & 0xF) < 10) escape[2] = '0' + (*cptr & 0xF); else escape[2] = 'A' - 10 + (*cptr & 0xF); xmlBufferAdd(target, &escape[0], 3); } } } valuePush(ctxt, xmlXPathCacheNewString(ctxt->context, xmlBufferContent(target))); xmlBufferFree(target); xmlXPathReleaseObject(ctxt->context, str); } /** * xmlXPathRegisterAllFunctions: * @ctxt: the XPath context * * Registers all default XPath functions in this context */ void xmlXPathRegisterAllFunctions(xmlXPathContextPtr ctxt) { xmlXPathRegisterFunc(ctxt, (const xmlChar *)"boolean", xmlXPathBooleanFunction); xmlXPathRegisterFunc(ctxt, (const xmlChar *)"ceiling", xmlXPathCeilingFunction); xmlXPathRegisterFunc(ctxt, (const xmlChar *)"count", xmlXPathCountFunction); xmlXPathRegisterFunc(ctxt, (const xmlChar *)"concat", xmlXPathConcatFunction); xmlXPathRegisterFunc(ctxt, (const xmlChar *)"contains", xmlXPathContainsFunction); xmlXPathRegisterFunc(ctxt, (const xmlChar *)"id", xmlXPathIdFunction); xmlXPathRegisterFunc(ctxt, (const xmlChar *)"false", xmlXPathFalseFunction); xmlXPathRegisterFunc(ctxt, (const xmlChar *)"floor", xmlXPathFloorFunction); xmlXPathRegisterFunc(ctxt, (const xmlChar *)"last", xmlXPathLastFunction); xmlXPathRegisterFunc(ctxt, (const xmlChar *)"lang", xmlXPathLangFunction); xmlXPathRegisterFunc(ctxt, (const xmlChar *)"local-name", xmlXPathLocalNameFunction); xmlXPathRegisterFunc(ctxt, (const xmlChar *)"not", xmlXPathNotFunction); xmlXPathRegisterFunc(ctxt, (const xmlChar *)"name", xmlXPathNameFunction); xmlXPathRegisterFunc(ctxt, (const xmlChar *)"namespace-uri", xmlXPathNamespaceURIFunction); xmlXPathRegisterFunc(ctxt, (const xmlChar *)"normalize-space", xmlXPathNormalizeFunction); xmlXPathRegisterFunc(ctxt, (const xmlChar *)"number", xmlXPathNumberFunction); xmlXPathRegisterFunc(ctxt, (const xmlChar *)"position", xmlXPathPositionFunction); xmlXPathRegisterFunc(ctxt, (const xmlChar *)"round", xmlXPathRoundFunction); xmlXPathRegisterFunc(ctxt, (const xmlChar *)"string", xmlXPathStringFunction); xmlXPathRegisterFunc(ctxt, (const xmlChar *)"string-length", xmlXPathStringLengthFunction); xmlXPathRegisterFunc(ctxt, (const xmlChar *)"starts-with", xmlXPathStartsWithFunction); xmlXPathRegisterFunc(ctxt, (const xmlChar *)"substring", xmlXPathSubstringFunction); xmlXPathRegisterFunc(ctxt, (const xmlChar *)"substring-before", xmlXPathSubstringBeforeFunction); xmlXPathRegisterFunc(ctxt, (const xmlChar *)"substring-after", xmlXPathSubstringAfterFunction); xmlXPathRegisterFunc(ctxt, (const xmlChar *)"sum", xmlXPathSumFunction); xmlXPathRegisterFunc(ctxt, (const xmlChar *)"true", xmlXPathTrueFunction); xmlXPathRegisterFunc(ctxt, (const xmlChar *)"translate", xmlXPathTranslateFunction); xmlXPathRegisterFuncNS(ctxt, (const xmlChar *)"escape-uri", (const xmlChar *)"http://www.w3.org/2002/08/xquery-functions", xmlXPathEscapeUriFunction); } #endif /* LIBXML_XPATH_ENABLED */ #define bottom_xpath #include "elfgcchack.h" xdmf-3.0+git20160803/Utilities/vtklibxml2/xmlmemory.c0000640000175000017500000006207013003006557022345 0ustar alastairalastair/* * xmlmemory.c: libxml memory allocator wrapper. * * daniel@veillard.com */ #define IN_LIBXML #include "libxml.h" #include #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_TIME_H #include #endif #ifdef HAVE_STDLIB_H #include #else #ifdef HAVE_MALLOC_H #include #endif #endif #ifdef HAVE_CTYPE_H #include #endif /* #define DEBUG_MEMORY */ /** * MEM_LIST: * * keep track of all allocated blocks for error reporting * Always build the memory list ! */ #ifdef DEBUG_MEMORY_LOCATION #ifndef MEM_LIST #define MEM_LIST /* keep a list of all the allocated memory blocks */ #endif #endif #include /* must come before xmlmemory.h */ #include #include #include static int xmlMemInitialized = 0; static unsigned long debugMemSize = 0; static unsigned long debugMemBlocks = 0; static unsigned long debugMaxMemSize = 0; static xmlMutexPtr xmlMemMutex = NULL; void xmlMallocBreakpoint(void); /************************************************************************ * * * Macros, variables and associated types * * * ************************************************************************/ #if !defined(LIBXML_THREAD_ENABLED) && !defined(LIBXML_THREAD_ALLOC_ENABLED) #ifdef xmlMalloc #undef xmlMalloc #endif #ifdef xmlRealloc #undef xmlRealloc #endif #ifdef xmlMemStrdup #undef xmlMemStrdup #endif #endif /* * Each of the blocks allocated begin with a header containing informations */ #define MEMTAG 0x5aa5 #define MALLOC_TYPE 1 #define REALLOC_TYPE 2 #define STRDUP_TYPE 3 #define MALLOC_ATOMIC_TYPE 4 #define REALLOC_ATOMIC_TYPE 5 typedef struct memnod { unsigned int mh_tag; unsigned int mh_type; unsigned long mh_number; size_t mh_size; #ifdef MEM_LIST struct memnod *mh_next; struct memnod *mh_prev; #endif const char *mh_file; unsigned int mh_line; } MEMHDR; #ifdef SUN4 #define ALIGN_SIZE 16 #else #define ALIGN_SIZE sizeof(double) #endif #define HDR_SIZE sizeof(MEMHDR) #define RESERVE_SIZE (((HDR_SIZE + (ALIGN_SIZE-1)) \ / ALIGN_SIZE ) * ALIGN_SIZE) #define CLIENT_2_HDR(a) ((MEMHDR *) (((char *) (a)) - RESERVE_SIZE)) #define HDR_2_CLIENT(a) ((void *) (((char *) (a)) + RESERVE_SIZE)) static unsigned int block=0; static unsigned int xmlMemStopAtBlock = 0; static void *xmlMemTraceBlockAt = NULL; #ifdef MEM_LIST static MEMHDR *memlist = NULL; #endif static void debugmem_tag_error(void *addr); #ifdef MEM_LIST static void debugmem_list_add(MEMHDR *); static void debugmem_list_delete(MEMHDR *); #endif #define Mem_Tag_Err(a) debugmem_tag_error(a); #ifndef TEST_POINT #define TEST_POINT #endif /** * xmlMallocBreakpoint: * * Breakpoint to use in conjunction with xmlMemStopAtBlock. When the block * number reaches the specified value this function is called. One need to add a breakpoint * to it to get the context in which the given block is allocated. */ void xmlMallocBreakpoint(void) { xmlGenericError(xmlGenericErrorContext, "xmlMallocBreakpoint reached on block %d\n", xmlMemStopAtBlock); } /** * xmlMallocLoc: * @size: an int specifying the size in byte to allocate. * @file: the file name or NULL * @line: the line number * * a malloc() equivalent, with logging of the allocation info. * * Returns a pointer to the allocated area or NULL in case of lack of memory. */ void * xmlMallocLoc(size_t size, const char * file, int line) { MEMHDR *p; void *ret; if (!xmlMemInitialized) xmlInitMemory(); #ifdef DEBUG_MEMORY xmlGenericError(xmlGenericErrorContext, "Malloc(%d)\n",size); #endif TEST_POINT p = (MEMHDR *) malloc(RESERVE_SIZE+size); if (!p) { xmlGenericError(xmlGenericErrorContext, "xmlMallocLoc : Out of free space\n"); xmlMemoryDump(); return(NULL); } p->mh_tag = MEMTAG; p->mh_size = size; p->mh_type = MALLOC_TYPE; p->mh_file = file; p->mh_line = line; xmlMutexLock(xmlMemMutex); p->mh_number = ++block; debugMemSize += size; debugMemBlocks++; if (debugMemSize > debugMaxMemSize) debugMaxMemSize = debugMemSize; #ifdef MEM_LIST debugmem_list_add(p); #endif xmlMutexUnlock(xmlMemMutex); #ifdef DEBUG_MEMORY xmlGenericError(xmlGenericErrorContext, "Malloc(%d) Ok\n",size); #endif if (xmlMemStopAtBlock == p->mh_number) xmlMallocBreakpoint(); ret = HDR_2_CLIENT(p); if (xmlMemTraceBlockAt == ret) { xmlGenericError(xmlGenericErrorContext, "%p : Malloc(%d) Ok\n", xmlMemTraceBlockAt, size); xmlMallocBreakpoint(); } TEST_POINT return(ret); } /** * xmlMallocAtomicLoc: * @size: an int specifying the size in byte to allocate. * @file: the file name or NULL * @line: the line number * * a malloc() equivalent, with logging of the allocation info. * * Returns a pointer to the allocated area or NULL in case of lack of memory. */ void * xmlMallocAtomicLoc(size_t size, const char * file, int line) { MEMHDR *p; void *ret; if (!xmlMemInitialized) xmlInitMemory(); #ifdef DEBUG_MEMORY xmlGenericError(xmlGenericErrorContext, "Malloc(%d)\n",size); #endif TEST_POINT p = (MEMHDR *) malloc(RESERVE_SIZE+size); if (!p) { xmlGenericError(xmlGenericErrorContext, "xmlMallocLoc : Out of free space\n"); xmlMemoryDump(); return(NULL); } p->mh_tag = MEMTAG; p->mh_size = size; p->mh_type = MALLOC_ATOMIC_TYPE; p->mh_file = file; p->mh_line = line; xmlMutexLock(xmlMemMutex); p->mh_number = ++block; debugMemSize += size; debugMemBlocks++; if (debugMemSize > debugMaxMemSize) debugMaxMemSize = debugMemSize; #ifdef MEM_LIST debugmem_list_add(p); #endif xmlMutexUnlock(xmlMemMutex); #ifdef DEBUG_MEMORY xmlGenericError(xmlGenericErrorContext, "Malloc(%d) Ok\n",size); #endif if (xmlMemStopAtBlock == p->mh_number) xmlMallocBreakpoint(); ret = HDR_2_CLIENT(p); if (xmlMemTraceBlockAt == ret) { xmlGenericError(xmlGenericErrorContext, "%p : Malloc(%d) Ok\n", xmlMemTraceBlockAt, size); xmlMallocBreakpoint(); } TEST_POINT return(ret); } /** * xmlMemMalloc: * @size: an int specifying the size in byte to allocate. * * a malloc() equivalent, with logging of the allocation info. * * Returns a pointer to the allocated area or NULL in case of lack of memory. */ void * xmlMemMalloc(size_t size) { return(xmlMallocLoc(size, "none", 0)); } /** * xmlReallocLoc: * @ptr: the initial memory block pointer * @size: an int specifying the size in byte to allocate. * @file: the file name or NULL * @line: the line number * * a realloc() equivalent, with logging of the allocation info. * * Returns a pointer to the allocated area or NULL in case of lack of memory. */ void * xmlReallocLoc(void *ptr,size_t size, const char * file, int line) { MEMHDR *p; unsigned long number; #ifdef DEBUG_MEMORY size_t oldsize; #endif if (ptr == NULL) return(xmlMallocLoc(size, file, line)); if (!xmlMemInitialized) xmlInitMemory(); TEST_POINT p = CLIENT_2_HDR(ptr); number = p->mh_number; if (xmlMemStopAtBlock == number) xmlMallocBreakpoint(); if (p->mh_tag != MEMTAG) { Mem_Tag_Err(p); goto error; } p->mh_tag = ~MEMTAG; xmlMutexLock(xmlMemMutex); debugMemSize -= p->mh_size; debugMemBlocks--; #ifdef DEBUG_MEMORY oldsize = p->mh_size; #endif #ifdef MEM_LIST debugmem_list_delete(p); #endif xmlMutexUnlock(xmlMemMutex); p = (MEMHDR *) realloc(p,RESERVE_SIZE+size); if (!p) { goto error; } if (xmlMemTraceBlockAt == ptr) { xmlGenericError(xmlGenericErrorContext, "%p : Realloced(%d -> %d) Ok\n", xmlMemTraceBlockAt, p->mh_size, size); xmlMallocBreakpoint(); } p->mh_tag = MEMTAG; p->mh_number = number; p->mh_type = REALLOC_TYPE; p->mh_size = size; p->mh_file = file; p->mh_line = line; xmlMutexLock(xmlMemMutex); debugMemSize += size; debugMemBlocks++; if (debugMemSize > debugMaxMemSize) debugMaxMemSize = debugMemSize; #ifdef MEM_LIST debugmem_list_add(p); #endif xmlMutexUnlock(xmlMemMutex); TEST_POINT #ifdef DEBUG_MEMORY xmlGenericError(xmlGenericErrorContext, "Realloced(%d to %d) Ok\n", oldsize, size); #endif return(HDR_2_CLIENT(p)); error: return(NULL); } /** * xmlMemRealloc: * @ptr: the initial memory block pointer * @size: an int specifying the size in byte to allocate. * * a realloc() equivalent, with logging of the allocation info. * * Returns a pointer to the allocated area or NULL in case of lack of memory. */ void * xmlMemRealloc(void *ptr,size_t size) { return(xmlReallocLoc(ptr, size, "none", 0)); } /** * xmlMemFree: * @ptr: the memory block pointer * * a free() equivalent, with error checking. */ void xmlMemFree(void *ptr) { MEMHDR *p; char *target; #ifdef DEBUG_MEMORY size_t size; #endif if (ptr == (void *) -1) { xmlGenericError(xmlGenericErrorContext, "trying to free pointer from freed area\n"); goto error; } if (xmlMemTraceBlockAt == ptr) { xmlGenericError(xmlGenericErrorContext, "%p : Freed()\n", xmlMemTraceBlockAt); xmlMallocBreakpoint(); } TEST_POINT target = (char *) ptr; p = CLIENT_2_HDR(ptr); if (p->mh_tag != MEMTAG) { Mem_Tag_Err(p); goto error; } if (xmlMemStopAtBlock == p->mh_number) xmlMallocBreakpoint(); p->mh_tag = ~MEMTAG; memset(target, -1, p->mh_size); xmlMutexLock(xmlMemMutex); debugMemSize -= p->mh_size; debugMemBlocks--; #ifdef DEBUG_MEMORY size = p->mh_size; #endif #ifdef MEM_LIST debugmem_list_delete(p); #endif xmlMutexUnlock(xmlMemMutex); free(p); TEST_POINT #ifdef DEBUG_MEMORY xmlGenericError(xmlGenericErrorContext, "Freed(%d) Ok\n", size); #endif return; error: xmlGenericError(xmlGenericErrorContext, "xmlMemFree(%lX) error\n", (unsigned long) ptr); xmlMallocBreakpoint(); return; } /** * xmlMemStrdupLoc: * @str: the initial string pointer * @file: the file name or NULL * @line: the line number * * a strdup() equivalent, with logging of the allocation info. * * Returns a pointer to the new string or NULL if allocation error occurred. */ char * xmlMemStrdupLoc(const char *str, const char *file, int line) { char *s; size_t size = strlen(str) + 1; MEMHDR *p; if (!xmlMemInitialized) xmlInitMemory(); TEST_POINT p = (MEMHDR *) malloc(RESERVE_SIZE+size); if (!p) { goto error; } p->mh_tag = MEMTAG; p->mh_size = size; p->mh_type = STRDUP_TYPE; p->mh_file = file; p->mh_line = line; xmlMutexLock(xmlMemMutex); p->mh_number = ++block; debugMemSize += size; debugMemBlocks++; if (debugMemSize > debugMaxMemSize) debugMaxMemSize = debugMemSize; #ifdef MEM_LIST debugmem_list_add(p); #endif xmlMutexUnlock(xmlMemMutex); s = (char *) HDR_2_CLIENT(p); if (xmlMemStopAtBlock == p->mh_number) xmlMallocBreakpoint(); if (s != NULL) strcpy(s,str); else goto error; TEST_POINT if (xmlMemTraceBlockAt == s) { xmlGenericError(xmlGenericErrorContext, "%p : Strdup() Ok\n", xmlMemTraceBlockAt); xmlMallocBreakpoint(); } return(s); error: return(NULL); } /** * xmlMemoryStrdup: * @str: the initial string pointer * * a strdup() equivalent, with logging of the allocation info. * * Returns a pointer to the new string or NULL if allocation error occurred. */ char * xmlMemoryStrdup(const char *str) { return(xmlMemStrdupLoc(str, "none", 0)); } /** * xmlMemUsed: * * Provides the amount of memory currently allocated * * Returns an int representing the amount of memory allocated. */ int xmlMemUsed(void) { return(debugMemSize); } /** * xmlMemBlocks: * * Provides the number of memory areas currently allocated * * Returns an int representing the number of blocks */ int xmlMemBlocks(void) { return(debugMemBlocks); } #ifdef MEM_LIST /** * xmlMemContentShow: * @fp: a FILE descriptor used as the output file * @p: a memory block header * * tries to show some content from the memory block */ static void xmlMemContentShow(FILE *fp, MEMHDR *p) { int i,j,k,len = p->mh_size; const char *buf = (const char *) HDR_2_CLIENT(p); if (p == NULL) { fprintf(fp, " NULL"); return; } for (i = 0;i < len;i++) { if (buf[i] == 0) break; if (!isprint((unsigned char) buf[i])) break; } if ((i < 4) && ((buf[i] != 0) || (i == 0))) { if (len >= 4) { MEMHDR *q; void *cur; for (j = 0;(j < len -3) && (j < 40);j += 4) { cur = *((void **) &buf[j]); q = CLIENT_2_HDR(cur); p = memlist; k = 0; while (p != NULL) { if (p == q) break; p = p->mh_next; if (k++ > 100) break; } if ((p != NULL) && (p == q)) { fprintf(fp, " pointer to #%lu at index %d", p->mh_number, j); return; } } } } else if ((i == 0) && (buf[i] == 0)) { fprintf(fp," null"); } else { if (buf[i] == 0) fprintf(fp," \"%.25s\"", buf); else { fprintf(fp," ["); for (j = 0;j < i;j++) fprintf(fp,"%c", buf[j]); fprintf(fp,"]"); } } } #endif /** * xmlMemDisplay: * @fp: a FILE descriptor used as the output file, if NULL, the result is * written to the file .memorylist * * show in-extenso the memory blocks allocated */ void xmlMemDisplay(FILE *fp) { #ifdef MEM_LIST MEMHDR *p; unsigned idx; int nb = 0; #if defined(HAVE_LOCALTIME) && defined(HAVE_STRFTIME) time_t currentTime; char buf[500]; struct tm * tstruct; #endif #endif FILE *old_fp = fp; if (fp == NULL) { fp = fopen(".memorylist", "w"); if (fp == NULL) return; } #ifdef MEM_LIST #if defined(HAVE_LOCALTIME) && defined(HAVE_STRFTIME) currentTime = time(NULL); tstruct = localtime(¤tTime); strftime(buf, sizeof(buf) - 1, "%I:%M:%S %p", tstruct); fprintf(fp," %s\n\n", buf); #endif fprintf(fp," MEMORY ALLOCATED : %lu, MAX was %lu\n", debugMemSize, debugMaxMemSize); fprintf(fp,"BLOCK NUMBER SIZE TYPE\n"); idx = 0; xmlMutexLock(xmlMemMutex); p = memlist; while (p) { fprintf(fp,"%-5u %6lu %6lu ",idx++,p->mh_number, (unsigned long)p->mh_size); switch (p->mh_type) { case STRDUP_TYPE:fprintf(fp,"strdup() in ");break; case MALLOC_TYPE:fprintf(fp,"malloc() in ");break; case REALLOC_TYPE:fprintf(fp,"realloc() in ");break; case MALLOC_ATOMIC_TYPE:fprintf(fp,"atomicmalloc() in ");break; case REALLOC_ATOMIC_TYPE:fprintf(fp,"atomicrealloc() in ");break; default: fprintf(fp,"Unknown memory block, may be corrupted"); xmlMutexUnlock(xmlMemMutex); if (old_fp == NULL) fclose(fp); return; } if (p->mh_file != NULL) fprintf(fp,"%s(%u)", p->mh_file, p->mh_line); if (p->mh_tag != MEMTAG) fprintf(fp," INVALID"); nb++; if (nb < 100) xmlMemContentShow(fp, p); else fprintf(fp," skip"); fprintf(fp,"\n"); p = p->mh_next; } xmlMutexUnlock(xmlMemMutex); #else fprintf(fp,"Memory list not compiled (MEM_LIST not defined !)\n"); #endif if (old_fp == NULL) fclose(fp); } #ifdef MEM_LIST static void debugmem_list_add(MEMHDR *p) { p->mh_next = memlist; p->mh_prev = NULL; if (memlist) memlist->mh_prev = p; memlist = p; #ifdef MEM_LIST_DEBUG if (stderr) Mem_Display(stderr); #endif } static void debugmem_list_delete(MEMHDR *p) { if (p->mh_next) p->mh_next->mh_prev = p->mh_prev; if (p->mh_prev) p->mh_prev->mh_next = p->mh_next; else memlist = p->mh_next; #ifdef MEM_LIST_DEBUG if (stderr) Mem_Display(stderr); #endif } #endif /* * debugmem_tag_error: * * internal error function. */ static void debugmem_tag_error(void *p) { xmlGenericError(xmlGenericErrorContext, "Memory tag error occurs :%p \n\t bye\n", p); #ifdef MEM_LIST if (stderr) xmlMemDisplay(stderr); #endif } #ifdef MEM_LIST static FILE *xmlMemoryDumpFile = NULL; #endif /** * xmlMemShow: * @fp: a FILE descriptor used as the output file * @nr: number of entries to dump * * show a show display of the memory allocated, and dump * the @nr last allocated areas which were not freed */ void xmlMemShow(FILE *fp, int nr ATTRIBUTE_UNUSED) { #ifdef MEM_LIST MEMHDR *p; #endif if (fp != NULL) fprintf(fp," MEMORY ALLOCATED : %lu, MAX was %lu\n", debugMemSize, debugMaxMemSize); #ifdef MEM_LIST xmlMutexLock(xmlMemMutex); if (nr > 0) { fprintf(fp,"NUMBER SIZE TYPE WHERE\n"); p = memlist; while ((p) && nr > 0) { fprintf(fp,"%6lu %6lu ",p->mh_number,(unsigned long)p->mh_size); switch (p->mh_type) { case STRDUP_TYPE:fprintf(fp,"strdup() in ");break; case MALLOC_TYPE:fprintf(fp,"malloc() in ");break; case MALLOC_ATOMIC_TYPE:fprintf(fp,"atomicmalloc() in ");break; case REALLOC_TYPE:fprintf(fp,"realloc() in ");break; case REALLOC_ATOMIC_TYPE:fprintf(fp,"atomicrealloc() in ");break; default:fprintf(fp," ??? in ");break; } if (p->mh_file != NULL) fprintf(fp,"%s(%u)", p->mh_file, p->mh_line); if (p->mh_tag != MEMTAG) fprintf(fp," INVALID"); xmlMemContentShow(fp, p); fprintf(fp,"\n"); nr--; p = p->mh_next; } } xmlMutexUnlock(xmlMemMutex); #endif /* MEM_LIST */ } /** * xmlMemoryDump: * * Dump in-extenso the memory blocks allocated to the file .memorylist */ void xmlMemoryDump(void) { #ifdef MEM_LIST FILE *dump; if (debugMaxMemSize == 0) return; dump = fopen(".memdump", "w"); if (dump == NULL) xmlMemoryDumpFile = stderr; else xmlMemoryDumpFile = dump; xmlMemDisplay(xmlMemoryDumpFile); if (dump != NULL) fclose(dump); #endif /* MEM_LIST */ } /**************************************************************** * * * Initialization Routines * * * ****************************************************************/ /** * xmlInitMemory: * * Initialize the memory layer. * * Returns 0 on success */ int xmlInitMemory(void) { #ifdef HAVE_STDLIB_H char *breakpoint; #endif #ifdef DEBUG_MEMORY xmlGenericError(xmlGenericErrorContext, "xmlInitMemory()\n"); #endif /* This is really not good code (see Bug 130419). Suggestions for improvement will be welcome! */ if (xmlMemInitialized) return(-1); xmlMemInitialized = 1; xmlMemMutex = xmlNewMutex(); #ifdef HAVE_STDLIB_H breakpoint = getenv("XML_MEM_BREAKPOINT"); if (breakpoint != NULL) { sscanf(breakpoint, "%ud", &xmlMemStopAtBlock); } #endif #ifdef HAVE_STDLIB_H breakpoint = getenv("XML_MEM_TRACE"); if (breakpoint != NULL) { sscanf(breakpoint, "%p", &xmlMemTraceBlockAt); } #endif #ifdef DEBUG_MEMORY xmlGenericError(xmlGenericErrorContext, "xmlInitMemory() Ok\n"); #endif return(0); } /** * xmlCleanupMemory: * * Free up all the memory allocated by the library for its own * use. This should not be called by user level code. */ void xmlCleanupMemory(void) { #ifdef DEBUG_MEMORY xmlGenericError(xmlGenericErrorContext, "xmlCleanupMemory()\n"); #endif if (xmlMemInitialized == 0) return; xmlFreeMutex(xmlMemMutex); xmlMemMutex = NULL; xmlMemInitialized = 0; #ifdef DEBUG_MEMORY xmlGenericError(xmlGenericErrorContext, "xmlCleanupMemory() Ok\n"); #endif } /** * xmlMemSetup: * @freeFunc: the free() function to use * @mallocFunc: the malloc() function to use * @reallocFunc: the realloc() function to use * @strdupFunc: the strdup() function to use * * Override the default memory access functions with a new set * This has to be called before any other libxml routines ! * * Should this be blocked if there was already some allocations * done ? * * Returns 0 on success */ int xmlMemSetup(xmlFreeFunc freeFunc, xmlMallocFunc mallocFunc, xmlReallocFunc reallocFunc, xmlStrdupFunc strdupFunc) { #ifdef DEBUG_MEMORY xmlGenericError(xmlGenericErrorContext, "xmlMemSetup()\n"); #endif if (freeFunc == NULL) return(-1); if (mallocFunc == NULL) return(-1); if (reallocFunc == NULL) return(-1); if (strdupFunc == NULL) return(-1); xmlFree = freeFunc; xmlMalloc = mallocFunc; xmlMallocAtomic = mallocFunc; xmlRealloc = reallocFunc; xmlMemStrdup = strdupFunc; #ifdef DEBUG_MEMORY xmlGenericError(xmlGenericErrorContext, "xmlMemSetup() Ok\n"); #endif return(0); } /** * xmlMemGet: * @freeFunc: place to save the free() function in use * @mallocFunc: place to save the malloc() function in use * @reallocFunc: place to save the realloc() function in use * @strdupFunc: place to save the strdup() function in use * * Provides the memory access functions set currently in use * * Returns 0 on success */ int xmlMemGet(xmlFreeFunc *freeFunc, xmlMallocFunc *mallocFunc, xmlReallocFunc *reallocFunc, xmlStrdupFunc *strdupFunc) { if (freeFunc != NULL) *freeFunc = xmlFree; if (mallocFunc != NULL) *mallocFunc = xmlMalloc; if (reallocFunc != NULL) *reallocFunc = xmlRealloc; if (strdupFunc != NULL) *strdupFunc = xmlMemStrdup; return(0); } /** * xmlGcMemSetup: * @freeFunc: the free() function to use * @mallocFunc: the malloc() function to use * @mallocAtomicFunc: the malloc() function to use for atomic allocations * @reallocFunc: the realloc() function to use * @strdupFunc: the strdup() function to use * * Override the default memory access functions with a new set * This has to be called before any other libxml routines ! * The mallocAtomicFunc is specialized for atomic block * allocations (i.e. of areas useful for garbage collected memory allocators * * Should this be blocked if there was already some allocations * done ? * * Returns 0 on success */ int xmlGcMemSetup(xmlFreeFunc freeFunc, xmlMallocFunc mallocFunc, xmlMallocFunc mallocAtomicFunc, xmlReallocFunc reallocFunc, xmlStrdupFunc strdupFunc) { #ifdef DEBUG_MEMORY xmlGenericError(xmlGenericErrorContext, "xmlGcMemSetup()\n"); #endif if (freeFunc == NULL) return(-1); if (mallocFunc == NULL) return(-1); if (mallocAtomicFunc == NULL) return(-1); if (reallocFunc == NULL) return(-1); if (strdupFunc == NULL) return(-1); xmlFree = freeFunc; xmlMalloc = mallocFunc; xmlMallocAtomic = mallocAtomicFunc; xmlRealloc = reallocFunc; xmlMemStrdup = strdupFunc; #ifdef DEBUG_MEMORY xmlGenericError(xmlGenericErrorContext, "xmlGcMemSetup() Ok\n"); #endif return(0); } /** * xmlGcMemGet: * @freeFunc: place to save the free() function in use * @mallocFunc: place to save the malloc() function in use * @mallocAtomicFunc: place to save the atomic malloc() function in use * @reallocFunc: place to save the realloc() function in use * @strdupFunc: place to save the strdup() function in use * * Provides the memory access functions set currently in use * The mallocAtomicFunc is specialized for atomic block * allocations (i.e. of areas useful for garbage collected memory allocators * * Returns 0 on success */ int xmlGcMemGet(xmlFreeFunc *freeFunc, xmlMallocFunc *mallocFunc, xmlMallocFunc *mallocAtomicFunc, xmlReallocFunc *reallocFunc, xmlStrdupFunc *strdupFunc) { if (freeFunc != NULL) *freeFunc = xmlFree; if (mallocFunc != NULL) *mallocFunc = xmlMalloc; if (mallocAtomicFunc != NULL) *mallocAtomicFunc = xmlMallocAtomic; if (reallocFunc != NULL) *reallocFunc = xmlRealloc; if (strdupFunc != NULL) *strdupFunc = xmlMemStrdup; return(0); } #define bottom_xmlmemory #include "elfgcchack.h" xdmf-3.0+git20160803/Utilities/vtklibxml2/list.c0000640000175000017500000004016413003006557021267 0ustar alastairalastair/* * list.c: lists handling implementation * * Copyright (C) 2000 Gary Pennington and Daniel Veillard. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. * * Author: Gary.Pennington@uk.sun.com */ #define IN_LIBXML #include "libxml.h" #include #include #include #include #include /* * Type definition are kept internal */ struct _xmlLink { struct _xmlLink *next; struct _xmlLink *prev; void *data; }; struct _xmlList { xmlLinkPtr sentinel; void (*linkDeallocator)(xmlLinkPtr ); int (*linkCompare)(const void *, const void*); }; /************************************************************************ * * * Interfaces * * * ************************************************************************/ /** * xmlLinkDeallocator: * @l: a list * @lk: a link * * Unlink and deallocate @lk from list @l */ static void xmlLinkDeallocator(xmlListPtr l, xmlLinkPtr lk) { (lk->prev)->next = lk->next; (lk->next)->prev = lk->prev; if(l->linkDeallocator) l->linkDeallocator(lk); xmlFree(lk); } /** * xmlLinkCompare: * @data0: first data * @data1: second data * * Compares two arbitrary data * * Returns -1, 0 or 1 depending on whether data1 is greater equal or smaller * than data0 */ static int xmlLinkCompare(const void *data0, const void *data1) { if (data0 < data1) return (-1); else if (data0 == data1) return (0); return (1); } /** * xmlListLowerSearch: * @l: a list * @data: a data * * Search data in the ordered list walking from the beginning * * Returns the link containing the data or NULL */ static xmlLinkPtr xmlListLowerSearch(xmlListPtr l, void *data) { xmlLinkPtr lk; if (l == NULL) return(NULL); for(lk = l->sentinel->next;lk != l->sentinel && l->linkCompare(lk->data, data) <0 ;lk = lk->next); return lk; } /** * xmlListHigherSearch: * @l: a list * @data: a data * * Search data in the ordered list walking backward from the end * * Returns the link containing the data or NULL */ static xmlLinkPtr xmlListHigherSearch(xmlListPtr l, void *data) { xmlLinkPtr lk; if (l == NULL) return(NULL); for(lk = l->sentinel->prev;lk != l->sentinel && l->linkCompare(lk->data, data) >0 ;lk = lk->prev); return lk; } /** * xmlListSearch: * @l: a list * @data: a data * * Search data in the list * * Returns the link containing the data or NULL */ static xmlLinkPtr xmlListLinkSearch(xmlListPtr l, void *data) { xmlLinkPtr lk; if (l == NULL) return(NULL); lk = xmlListLowerSearch(l, data); if (lk == l->sentinel) return NULL; else { if (l->linkCompare(lk->data, data) ==0) return lk; return NULL; } } /** * xmlListLinkReverseSearch: * @l: a list * @data: a data * * Search data in the list processing backward * * Returns the link containing the data or NULL */ static xmlLinkPtr xmlListLinkReverseSearch(xmlListPtr l, void *data) { xmlLinkPtr lk; if (l == NULL) return(NULL); lk = xmlListHigherSearch(l, data); if (lk == l->sentinel) return NULL; else { if (l->linkCompare(lk->data, data) ==0) return lk; return NULL; } } /** * xmlListCreate: * @deallocator: an optional deallocator function * @compare: an optional comparison function * * Create a new list * * Returns the new list or NULL in case of error */ xmlListPtr xmlListCreate(xmlListDeallocator deallocator, xmlListDataCompare compare) { xmlListPtr l; if (NULL == (l = (xmlListPtr )xmlMalloc( sizeof(xmlList)))) { xmlGenericError(xmlGenericErrorContext, "Cannot initialize memory for list"); return (NULL); } /* Initialize the list to NULL */ memset(l, 0, sizeof(xmlList)); /* Add the sentinel */ if (NULL ==(l->sentinel = (xmlLinkPtr )xmlMalloc(sizeof(xmlLink)))) { xmlGenericError(xmlGenericErrorContext, "Cannot initialize memory for sentinel"); xmlFree(l); return (NULL); } l->sentinel->next = l->sentinel; l->sentinel->prev = l->sentinel; l->sentinel->data = NULL; /* If there is a link deallocator, use it */ if (deallocator != NULL) l->linkDeallocator = deallocator; /* If there is a link comparator, use it */ if (compare != NULL) l->linkCompare = compare; else /* Use our own */ l->linkCompare = xmlLinkCompare; return l; } /** * xmlListSearch: * @l: a list * @data: a search value * * Search the list for an existing value of @data * * Returns the value associated to @data or NULL in case of error */ void * xmlListSearch(xmlListPtr l, void *data) { xmlLinkPtr lk; if (l == NULL) return(NULL); lk = xmlListLinkSearch(l, data); if (lk) return (lk->data); return NULL; } /** * xmlListReverseSearch: * @l: a list * @data: a search value * * Search the list in reverse order for an existing value of @data * * Returns the value associated to @data or NULL in case of error */ void * xmlListReverseSearch(xmlListPtr l, void *data) { xmlLinkPtr lk; if (l == NULL) return(NULL); lk = xmlListLinkReverseSearch(l, data); if (lk) return (lk->data); return NULL; } /** * xmlListInsert: * @l: a list * @data: the data * * Insert data in the ordered list at the beginning for this value * * Returns 0 in case of success, 1 in case of failure */ int xmlListInsert(xmlListPtr l, void *data) { xmlLinkPtr lkPlace, lkNew; if (l == NULL) return(1); lkPlace = xmlListLowerSearch(l, data); /* Add the new link */ lkNew = (xmlLinkPtr) xmlMalloc(sizeof(xmlLink)); if (lkNew == NULL) { xmlGenericError(xmlGenericErrorContext, "Cannot initialize memory for new link"); return (1); } lkNew->data = data; lkPlace = lkPlace->prev; lkNew->next = lkPlace->next; (lkPlace->next)->prev = lkNew; lkPlace->next = lkNew; lkNew->prev = lkPlace; return 0; } /** * xmlListAppend: * @l: a list * @data: the data * * Insert data in the ordered list at the end for this value * * Returns 0 in case of success, 1 in case of failure */ int xmlListAppend(xmlListPtr l, void *data) { xmlLinkPtr lkPlace, lkNew; if (l == NULL) return(1); lkPlace = xmlListHigherSearch(l, data); /* Add the new link */ lkNew = (xmlLinkPtr) xmlMalloc(sizeof(xmlLink)); if (lkNew == NULL) { xmlGenericError(xmlGenericErrorContext, "Cannot initialize memory for new link"); return (0); } lkNew->data = data; lkNew->next = lkPlace->next; (lkPlace->next)->prev = lkNew; lkPlace->next = lkNew; lkNew->prev = lkPlace; return 1; } /** * xmlListDelete: * @l: a list * * Deletes the list and its associated data */ void xmlListDelete(xmlListPtr l) { if (l == NULL) return; xmlListClear(l); xmlFree(l->sentinel); xmlFree(l); } /** * xmlListRemoveFirst: * @l: a list * @data: list data * * Remove the first instance associated to data in the list * * Returns 1 if a deallocation occured, or 0 if not found */ int xmlListRemoveFirst(xmlListPtr l, void *data) { xmlLinkPtr lk; if (l == NULL) return(0); /*Find the first instance of this data */ lk = xmlListLinkSearch(l, data); if (lk != NULL) { xmlLinkDeallocator(l, lk); return 1; } return 0; } /** * xmlListRemoveLast: * @l: a list * @data: list data * * Remove the last instance associated to data in the list * * Returns 1 if a deallocation occured, or 0 if not found */ int xmlListRemoveLast(xmlListPtr l, void *data) { xmlLinkPtr lk; if (l == NULL) return(0); /*Find the last instance of this data */ lk = xmlListLinkReverseSearch(l, data); if (lk != NULL) { xmlLinkDeallocator(l, lk); return 1; } return 0; } /** * xmlListRemoveAll: * @l: a list * @data: list data * * Remove the all instance associated to data in the list * * Returns the number of deallocation, or 0 if not found */ int xmlListRemoveAll(xmlListPtr l, void *data) { int count=0; if (l == NULL) return(0); while(xmlListRemoveFirst(l, data)) count++; return count; } /** * xmlListClear: * @l: a list * * Remove the all data in the list */ void xmlListClear(xmlListPtr l) { xmlLinkPtr lk; if (l == NULL) return; lk = l->sentinel->next; while(lk != l->sentinel) { xmlLinkPtr next = lk->next; xmlLinkDeallocator(l, lk); lk = next; } } /** * xmlListEmpty: * @l: a list * * Is the list empty ? * * Returns 1 if the list is empty, 0 if not empty and -1 in case of error */ int xmlListEmpty(xmlListPtr l) { if (l == NULL) return(-1); return (l->sentinel->next == l->sentinel); } /** * xmlListFront: * @l: a list * * Get the first element in the list * * Returns the first element in the list, or NULL */ xmlLinkPtr xmlListFront(xmlListPtr l) { if (l == NULL) return(NULL); return (l->sentinel->next); } /** * xmlListEnd: * @l: a list * * Get the last element in the list * * Returns the last element in the list, or NULL */ xmlLinkPtr xmlListEnd(xmlListPtr l) { if (l == NULL) return(NULL); return (l->sentinel->prev); } /** * xmlListSize: * @l: a list * * Get the number of elements in the list * * Returns the number of elements in the list or -1 in case of error */ int xmlListSize(xmlListPtr l) { xmlLinkPtr lk; int count=0; if (l == NULL) return(-1); /* TODO: keep a counter in xmlList instead */ for(lk = l->sentinel->next; lk != l->sentinel; lk = lk->next, count++); return count; } /** * xmlListPopFront: * @l: a list * * Removes the first element in the list */ void xmlListPopFront(xmlListPtr l) { if(!xmlListEmpty(l)) xmlLinkDeallocator(l, l->sentinel->next); } /** * xmlListPopBack: * @l: a list * * Removes the last element in the list */ void xmlListPopBack(xmlListPtr l) { if(!xmlListEmpty(l)) xmlLinkDeallocator(l, l->sentinel->prev); } /** * xmlListPushFront: * @l: a list * @data: new data * * add the new data at the beginning of the list * * Returns 1 if successful, 0 otherwise */ int xmlListPushFront(xmlListPtr l, void *data) { xmlLinkPtr lkPlace, lkNew; if (l == NULL) return(0); lkPlace = l->sentinel; /* Add the new link */ lkNew = (xmlLinkPtr) xmlMalloc(sizeof(xmlLink)); if (lkNew == NULL) { xmlGenericError(xmlGenericErrorContext, "Cannot initialize memory for new link"); return (0); } lkNew->data = data; lkNew->next = lkPlace->next; (lkPlace->next)->prev = lkNew; lkPlace->next = lkNew; lkNew->prev = lkPlace; return 1; } /** * xmlListPushBack: * @l: a list * @data: new data * * add the new data at the end of the list * * Returns 1 if successful, 0 otherwise */ int xmlListPushBack(xmlListPtr l, void *data) { xmlLinkPtr lkPlace, lkNew; if (l == NULL) return(0); lkPlace = l->sentinel->prev; /* Add the new link */ if (NULL ==(lkNew = (xmlLinkPtr )xmlMalloc(sizeof(xmlLink)))) { xmlGenericError(xmlGenericErrorContext, "Cannot initialize memory for new link"); return (0); } lkNew->data = data; lkNew->next = lkPlace->next; (lkPlace->next)->prev = lkNew; lkPlace->next = lkNew; lkNew->prev = lkPlace; return 1; } /** * xmlLinkGetData: * @lk: a link * * See Returns. * * Returns a pointer to the data referenced from this link */ void * xmlLinkGetData(xmlLinkPtr lk) { if (lk == NULL) return(NULL); return lk->data; } /** * xmlListReverse: * @l: a list * * Reverse the order of the elements in the list */ void xmlListReverse(xmlListPtr l) { xmlLinkPtr lk; xmlLinkPtr lkPrev; if (l == NULL) return; lkPrev = l->sentinel; for (lk = l->sentinel->next; lk != l->sentinel; lk = lk->next) { lkPrev->next = lkPrev->prev; lkPrev->prev = lk; lkPrev = lk; } /* Fix up the last node */ lkPrev->next = lkPrev->prev; lkPrev->prev = lk; } /** * xmlListSort: * @l: a list * * Sort all the elements in the list */ void xmlListSort(xmlListPtr l) { xmlListPtr lTemp; if (l == NULL) return; if(xmlListEmpty(l)) return; /* I think that the real answer is to implement quicksort, the * alternative is to implement some list copying procedure which * would be based on a list copy followed by a clear followed by * an insert. This is slow... */ if (NULL ==(lTemp = xmlListDup(l))) return; xmlListClear(l); xmlListMerge(l, lTemp); xmlListDelete(lTemp); return; } /** * xmlListWalk: * @l: a list * @walker: a processing function * @user: a user parameter passed to the walker function * * Walk all the element of the first from first to last and * apply the walker function to it */ void xmlListWalk(xmlListPtr l, xmlListWalker walker, const void *user) { xmlLinkPtr lk; if ((l == NULL) || (walker == NULL)) return; for(lk = l->sentinel->next; lk != l->sentinel; lk = lk->next) { if((walker(lk->data, user)) == 0) break; } } /** * xmlListReverseWalk: * @l: a list * @walker: a processing function * @user: a user parameter passed to the walker function * * Walk all the element of the list in reverse order and * apply the walker function to it */ void xmlListReverseWalk(xmlListPtr l, xmlListWalker walker, const void *user) { xmlLinkPtr lk; if ((l == NULL) || (walker == NULL)) return; for(lk = l->sentinel->prev; lk != l->sentinel; lk = lk->prev) { if((walker(lk->data, user)) == 0) break; } } /** * xmlListMerge: * @l1: the original list * @l2: the new list * * include all the elements of the second list in the first one and * clear the second list */ void xmlListMerge(xmlListPtr l1, xmlListPtr l2) { xmlListCopy(l1, l2); xmlListClear(l2); } /** * xmlListDup: * @old: the list * * Duplicate the list * * Returns a new copy of the list or NULL in case of error */ xmlListPtr xmlListDup(const xmlListPtr old) { xmlListPtr cur; if (old == NULL) return(NULL); /* Hmmm, how to best deal with allocation issues when copying * lists. If there is a de-allocator, should responsibility lie with * the new list or the old list. Surely not both. I'll arbitrarily * set it to be the old list for the time being whilst I work out * the answer */ if (NULL ==(cur = xmlListCreate(NULL, old->linkCompare))) return (NULL); if (0 != xmlListCopy(cur, old)) return NULL; return cur; } /** * xmlListCopy: * @cur: the new list * @old: the old list * * Move all the element from the old list in the new list * * Returns 0 in case of success 1 in case of error */ int xmlListCopy(xmlListPtr cur, const xmlListPtr old) { /* Walk the old tree and insert the data into the new one */ xmlLinkPtr lk; if ((old == NULL) || (cur == NULL)) return(1); for(lk = old->sentinel->next; lk != old->sentinel; lk = lk->next) { if (0 !=xmlListInsert(cur, lk->data)) { xmlListDelete(cur); return (1); } } return (0); } /* xmlListUnique() */ /* xmlListSwap */ #define bottom_list #include "elfgcchack.h" xdmf-3.0+git20160803/Utilities/vtklibxml2/chvalid.c0000640000175000017500000003064313003006557021727 0ustar alastairalastair/* * chvalid.c: this module implements the character range * validation APIs * * This file is automatically generated from the cvs source * definition files using the genChRanges.py Python script * * Generation date: Mon Mar 27 11:09:48 2006 * Sources: chvalid.def * William Brack */ #define IN_LIBXML #include "libxml.h" #include /* * The initial tables ({func_name}_tab) are used to validate whether a * single-byte character is within the specified group. Each table * contains 256 bytes, with each byte representing one of the 256 * possible characters. If the table byte is set, the character is * allowed. * */ const unsigned char xmlIsPubidChar_tab[256] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; static const xmlChSRange xmlIsBaseChar_srng[] = { {0x100, 0x131}, {0x134, 0x13e}, {0x141, 0x148}, {0x14a, 0x17e}, {0x180, 0x1c3}, {0x1cd, 0x1f0}, {0x1f4, 0x1f5}, {0x1fa, 0x217}, {0x250, 0x2a8}, {0x2bb, 0x2c1}, {0x386, 0x386}, {0x388, 0x38a}, {0x38c, 0x38c}, {0x38e, 0x3a1}, {0x3a3, 0x3ce}, {0x3d0, 0x3d6}, {0x3da, 0x3da}, {0x3dc, 0x3dc}, {0x3de, 0x3de}, {0x3e0, 0x3e0}, {0x3e2, 0x3f3}, {0x401, 0x40c}, {0x40e, 0x44f}, {0x451, 0x45c}, {0x45e, 0x481}, {0x490, 0x4c4}, {0x4c7, 0x4c8}, {0x4cb, 0x4cc}, {0x4d0, 0x4eb}, {0x4ee, 0x4f5}, {0x4f8, 0x4f9}, {0x531, 0x556}, {0x559, 0x559}, {0x561, 0x586}, {0x5d0, 0x5ea}, {0x5f0, 0x5f2}, {0x621, 0x63a}, {0x641, 0x64a}, {0x671, 0x6b7}, {0x6ba, 0x6be}, {0x6c0, 0x6ce}, {0x6d0, 0x6d3}, {0x6d5, 0x6d5}, {0x6e5, 0x6e6}, {0x905, 0x939}, {0x93d, 0x93d}, {0x958, 0x961}, {0x985, 0x98c}, {0x98f, 0x990}, {0x993, 0x9a8}, {0x9aa, 0x9b0}, {0x9b2, 0x9b2}, {0x9b6, 0x9b9}, {0x9dc, 0x9dd}, {0x9df, 0x9e1}, {0x9f0, 0x9f1}, {0xa05, 0xa0a}, {0xa0f, 0xa10}, {0xa13, 0xa28}, {0xa2a, 0xa30}, {0xa32, 0xa33}, {0xa35, 0xa36}, {0xa38, 0xa39}, {0xa59, 0xa5c}, {0xa5e, 0xa5e}, {0xa72, 0xa74}, {0xa85, 0xa8b}, {0xa8d, 0xa8d}, {0xa8f, 0xa91}, {0xa93, 0xaa8}, {0xaaa, 0xab0}, {0xab2, 0xab3}, {0xab5, 0xab9}, {0xabd, 0xabd}, {0xae0, 0xae0}, {0xb05, 0xb0c}, {0xb0f, 0xb10}, {0xb13, 0xb28}, {0xb2a, 0xb30}, {0xb32, 0xb33}, {0xb36, 0xb39}, {0xb3d, 0xb3d}, {0xb5c, 0xb5d}, {0xb5f, 0xb61}, {0xb85, 0xb8a}, {0xb8e, 0xb90}, {0xb92, 0xb95}, {0xb99, 0xb9a}, {0xb9c, 0xb9c}, {0xb9e, 0xb9f}, {0xba3, 0xba4}, {0xba8, 0xbaa}, {0xbae, 0xbb5}, {0xbb7, 0xbb9}, {0xc05, 0xc0c}, {0xc0e, 0xc10}, {0xc12, 0xc28}, {0xc2a, 0xc33}, {0xc35, 0xc39}, {0xc60, 0xc61}, {0xc85, 0xc8c}, {0xc8e, 0xc90}, {0xc92, 0xca8}, {0xcaa, 0xcb3}, {0xcb5, 0xcb9}, {0xcde, 0xcde}, {0xce0, 0xce1}, {0xd05, 0xd0c}, {0xd0e, 0xd10}, {0xd12, 0xd28}, {0xd2a, 0xd39}, {0xd60, 0xd61}, {0xe01, 0xe2e}, {0xe30, 0xe30}, {0xe32, 0xe33}, {0xe40, 0xe45}, {0xe81, 0xe82}, {0xe84, 0xe84}, {0xe87, 0xe88}, {0xe8a, 0xe8a}, {0xe8d, 0xe8d}, {0xe94, 0xe97}, {0xe99, 0xe9f}, {0xea1, 0xea3}, {0xea5, 0xea5}, {0xea7, 0xea7}, {0xeaa, 0xeab}, {0xead, 0xeae}, {0xeb0, 0xeb0}, {0xeb2, 0xeb3}, {0xebd, 0xebd}, {0xec0, 0xec4}, {0xf40, 0xf47}, {0xf49, 0xf69}, {0x10a0, 0x10c5}, {0x10d0, 0x10f6}, {0x1100, 0x1100}, {0x1102, 0x1103}, {0x1105, 0x1107}, {0x1109, 0x1109}, {0x110b, 0x110c}, {0x110e, 0x1112}, {0x113c, 0x113c}, {0x113e, 0x113e}, {0x1140, 0x1140}, {0x114c, 0x114c}, {0x114e, 0x114e}, {0x1150, 0x1150}, {0x1154, 0x1155}, {0x1159, 0x1159}, {0x115f, 0x1161}, {0x1163, 0x1163}, {0x1165, 0x1165}, {0x1167, 0x1167}, {0x1169, 0x1169}, {0x116d, 0x116e}, {0x1172, 0x1173}, {0x1175, 0x1175}, {0x119e, 0x119e}, {0x11a8, 0x11a8}, {0x11ab, 0x11ab}, {0x11ae, 0x11af}, {0x11b7, 0x11b8}, {0x11ba, 0x11ba}, {0x11bc, 0x11c2}, {0x11eb, 0x11eb}, {0x11f0, 0x11f0}, {0x11f9, 0x11f9}, {0x1e00, 0x1e9b}, {0x1ea0, 0x1ef9}, {0x1f00, 0x1f15}, {0x1f18, 0x1f1d}, {0x1f20, 0x1f45}, {0x1f48, 0x1f4d}, {0x1f50, 0x1f57}, {0x1f59, 0x1f59}, {0x1f5b, 0x1f5b}, {0x1f5d, 0x1f5d}, {0x1f5f, 0x1f7d}, {0x1f80, 0x1fb4}, {0x1fb6, 0x1fbc}, {0x1fbe, 0x1fbe}, {0x1fc2, 0x1fc4}, {0x1fc6, 0x1fcc}, {0x1fd0, 0x1fd3}, {0x1fd6, 0x1fdb}, {0x1fe0, 0x1fec}, {0x1ff2, 0x1ff4}, {0x1ff6, 0x1ffc}, {0x2126, 0x2126}, {0x212a, 0x212b}, {0x212e, 0x212e}, {0x2180, 0x2182}, {0x3041, 0x3094}, {0x30a1, 0x30fa}, {0x3105, 0x312c}, {0xac00, 0xd7a3}}; const xmlChRangeGroup xmlIsBaseCharGroup = {197, 0, xmlIsBaseChar_srng, (xmlChLRangePtr)0}; static const xmlChSRange xmlIsChar_srng[] = { {0x100, 0xd7ff}, {0xe000, 0xfffd}}; static const xmlChLRange xmlIsChar_lrng[] = { {0x10000, 0x10ffff}}; const xmlChRangeGroup xmlIsCharGroup = {2, 1, xmlIsChar_srng, xmlIsChar_lrng}; static const xmlChSRange xmlIsCombining_srng[] = { {0x300, 0x345}, {0x360, 0x361}, {0x483, 0x486}, {0x591, 0x5a1}, {0x5a3, 0x5b9}, {0x5bb, 0x5bd}, {0x5bf, 0x5bf}, {0x5c1, 0x5c2}, {0x5c4, 0x5c4}, {0x64b, 0x652}, {0x670, 0x670}, {0x6d6, 0x6dc}, {0x6dd, 0x6df}, {0x6e0, 0x6e4}, {0x6e7, 0x6e8}, {0x6ea, 0x6ed}, {0x901, 0x903}, {0x93c, 0x93c}, {0x93e, 0x94c}, {0x94d, 0x94d}, {0x951, 0x954}, {0x962, 0x963}, {0x981, 0x983}, {0x9bc, 0x9bc}, {0x9be, 0x9be}, {0x9bf, 0x9bf}, {0x9c0, 0x9c4}, {0x9c7, 0x9c8}, {0x9cb, 0x9cd}, {0x9d7, 0x9d7}, {0x9e2, 0x9e3}, {0xa02, 0xa02}, {0xa3c, 0xa3c}, {0xa3e, 0xa3e}, {0xa3f, 0xa3f}, {0xa40, 0xa42}, {0xa47, 0xa48}, {0xa4b, 0xa4d}, {0xa70, 0xa71}, {0xa81, 0xa83}, {0xabc, 0xabc}, {0xabe, 0xac5}, {0xac7, 0xac9}, {0xacb, 0xacd}, {0xb01, 0xb03}, {0xb3c, 0xb3c}, {0xb3e, 0xb43}, {0xb47, 0xb48}, {0xb4b, 0xb4d}, {0xb56, 0xb57}, {0xb82, 0xb83}, {0xbbe, 0xbc2}, {0xbc6, 0xbc8}, {0xbca, 0xbcd}, {0xbd7, 0xbd7}, {0xc01, 0xc03}, {0xc3e, 0xc44}, {0xc46, 0xc48}, {0xc4a, 0xc4d}, {0xc55, 0xc56}, {0xc82, 0xc83}, {0xcbe, 0xcc4}, {0xcc6, 0xcc8}, {0xcca, 0xccd}, {0xcd5, 0xcd6}, {0xd02, 0xd03}, {0xd3e, 0xd43}, {0xd46, 0xd48}, {0xd4a, 0xd4d}, {0xd57, 0xd57}, {0xe31, 0xe31}, {0xe34, 0xe3a}, {0xe47, 0xe4e}, {0xeb1, 0xeb1}, {0xeb4, 0xeb9}, {0xebb, 0xebc}, {0xec8, 0xecd}, {0xf18, 0xf19}, {0xf35, 0xf35}, {0xf37, 0xf37}, {0xf39, 0xf39}, {0xf3e, 0xf3e}, {0xf3f, 0xf3f}, {0xf71, 0xf84}, {0xf86, 0xf8b}, {0xf90, 0xf95}, {0xf97, 0xf97}, {0xf99, 0xfad}, {0xfb1, 0xfb7}, {0xfb9, 0xfb9}, {0x20d0, 0x20dc}, {0x20e1, 0x20e1}, {0x302a, 0x302f}, {0x3099, 0x3099}, {0x309a, 0x309a}}; const xmlChRangeGroup xmlIsCombiningGroup = {95, 0, xmlIsCombining_srng, (xmlChLRangePtr)0}; static const xmlChSRange xmlIsDigit_srng[] = { {0x660, 0x669}, {0x6f0, 0x6f9}, {0x966, 0x96f}, {0x9e6, 0x9ef}, {0xa66, 0xa6f}, {0xae6, 0xaef}, {0xb66, 0xb6f}, {0xbe7, 0xbef}, {0xc66, 0xc6f}, {0xce6, 0xcef}, {0xd66, 0xd6f}, {0xe50, 0xe59}, {0xed0, 0xed9}, {0xf20, 0xf29}}; const xmlChRangeGroup xmlIsDigitGroup = {14, 0, xmlIsDigit_srng, (xmlChLRangePtr)0}; static const xmlChSRange xmlIsExtender_srng[] = { {0x2d0, 0x2d0}, {0x2d1, 0x2d1}, {0x387, 0x387}, {0x640, 0x640}, {0xe46, 0xe46}, {0xec6, 0xec6}, {0x3005, 0x3005}, {0x3031, 0x3035}, {0x309d, 0x309e}, {0x30fc, 0x30fe}}; const xmlChRangeGroup xmlIsExtenderGroup = {10, 0, xmlIsExtender_srng, (xmlChLRangePtr)0}; static const xmlChSRange xmlIsIdeographic_srng[] = { {0x3007, 0x3007}, {0x3021, 0x3029}, {0x4e00, 0x9fa5}}; const xmlChRangeGroup xmlIsIdeographicGroup = {3, 0, xmlIsIdeographic_srng, (xmlChLRangePtr)0}; /** * xmlCharInRange: * @val: character to be validated * @rptr: pointer to range to be used to validate * * Does a binary search of the range table to determine if char * is valid * * Returns: true if character valid, false otherwise */ int xmlCharInRange (unsigned int val, const xmlChRangeGroup *rptr) { int low, high, mid; const xmlChSRange *sptr; const xmlChLRange *lptr; if (rptr == NULL) return(0); if (val < 0x10000) { /* is val in 'short' or 'long' array? */ if (rptr->nbShortRange == 0) return 0; low = 0; high = rptr->nbShortRange - 1; sptr = rptr->shortRange; while (low <= high) { mid = (low + high) / 2; if ((unsigned short) val < sptr[mid].low) { high = mid - 1; } else { if ((unsigned short) val > sptr[mid].high) { low = mid + 1; } else { return 1; } } } } else { if (rptr->nbLongRange == 0) { return 0; } low = 0; high = rptr->nbLongRange - 1; lptr = rptr->longRange; while (low <= high) { mid = (low + high) / 2; if (val < lptr[mid].low) { high = mid - 1; } else { if (val > lptr[mid].high) { low = mid + 1; } else { return 1; } } } } return 0; } /** * xmlIsBaseChar: * @ch: character to validate * * This function is DEPRECATED. * Use xmlIsBaseChar_ch or xmlIsBaseCharQ instead * * Returns true if argument valid, false otherwise */ int xmlIsBaseChar(unsigned int ch) { return(xmlIsBaseCharQ(ch)); } /** * xmlIsBlank: * @ch: character to validate * * This function is DEPRECATED. * Use xmlIsBlank_ch or xmlIsBlankQ instead * * Returns true if argument valid, false otherwise */ int xmlIsBlank(unsigned int ch) { return(xmlIsBlankQ(ch)); } /** * xmlIsChar: * @ch: character to validate * * This function is DEPRECATED. * Use xmlIsChar_ch or xmlIsCharQ instead * * Returns true if argument valid, false otherwise */ int xmlIsChar(unsigned int ch) { return(xmlIsCharQ(ch)); } /** * xmlIsCombining: * @ch: character to validate * * This function is DEPRECATED. * Use xmlIsCombiningQ instead * * Returns true if argument valid, false otherwise */ int xmlIsCombining(unsigned int ch) { return(xmlIsCombiningQ(ch)); } /** * xmlIsDigit: * @ch: character to validate * * This function is DEPRECATED. * Use xmlIsDigit_ch or xmlIsDigitQ instead * * Returns true if argument valid, false otherwise */ int xmlIsDigit(unsigned int ch) { return(xmlIsDigitQ(ch)); } /** * xmlIsExtender: * @ch: character to validate * * This function is DEPRECATED. * Use xmlIsExtender_ch or xmlIsExtenderQ instead * * Returns true if argument valid, false otherwise */ int xmlIsExtender(unsigned int ch) { return(xmlIsExtenderQ(ch)); } /** * xmlIsIdeographic: * @ch: character to validate * * This function is DEPRECATED. * Use xmlIsIdeographicQ instead * * Returns true if argument valid, false otherwise */ int xmlIsIdeographic(unsigned int ch) { return(xmlIsIdeographicQ(ch)); } /** * xmlIsPubidChar: * @ch: character to validate * * This function is DEPRECATED. * Use xmlIsPubidChar_ch or xmlIsPubidCharQ instead * * Returns true if argument valid, false otherwise */ int xmlIsPubidChar(unsigned int ch) { return(xmlIsPubidCharQ(ch)); } #define bottom_chvalid #include "elfgcchack.h" xdmf-3.0+git20160803/Utilities/vtklibxml2/nanohttp.c0000640000175000017500000014042013003006557022143 0ustar alastairalastair/* * nanohttp.c: minimalist HTTP GET implementation to fetch external subsets. * focuses on size, streamability, reentrancy and portability * * This is clearly not a general purpose HTTP implementation * If you look for one, check: * http://www.w3.org/Library/ * * See Copyright for the status of this software. * * daniel@veillard.com */ #define NEED_SOCKETS #define IN_LIBXML #include "libxml.h" #ifdef LIBXML_HTTP_ENABLED #include #ifdef HAVE_STDLIB_H #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_ARPA_INET_H #include #endif #ifdef HAVE_NETDB_H #include #endif #ifdef HAVE_RESOLV_H #ifdef HAVE_ARPA_NAMESER_H #include #endif #include #endif #ifdef HAVE_FCNTL_H #include #endif #ifdef HAVE_ERRNO_H #include #endif #ifdef HAVE_SYS_TIME_H #include #endif #ifdef HAVE_SYS_SELECT_H #include #endif #ifdef HAVE_STRINGS_H #include #endif #ifdef SUPPORT_IP6 #include #endif #include "vtk_libxml2_zlib.h" #ifdef VMS #include #define XML_SOCKLEN_T unsigned int #define SOCKET int #endif #ifdef __MINGW32__ #define _WINSOCKAPI_ #include #include #undef XML_SOCKLEN_T #define XML_SOCKLEN_T unsigned int #endif #include #include #include #include /* for xmlStr(n)casecmp() */ #include #include #include /** * A couple portability macros */ #ifndef _WINSOCKAPI_ #ifndef __BEOS__ #define closesocket(s) close(s) #endif #define SOCKET int #endif #ifdef __BEOS__ #ifndef PF_INET #define PF_INET AF_INET #endif #endif #ifndef XML_SOCKLEN_T #define XML_SOCKLEN_T unsigned int #endif #ifndef SOCKET #define SOCKET int #endif #ifdef STANDALONE #define DEBUG_HTTP #define xmlStrncasecmp(a, b, n) strncasecmp((char *)a, (char *)b, n) #define xmlStrcasecmpi(a, b) strcasecmp((char *)a, (char *)b) #endif #define XML_NANO_HTTP_MAX_REDIR 10 #define XML_NANO_HTTP_CHUNK 4096 #define XML_NANO_HTTP_CLOSED 0 #define XML_NANO_HTTP_WRITE 1 #define XML_NANO_HTTP_READ 2 #define XML_NANO_HTTP_NONE 4 typedef struct xmlNanoHTTPCtxt { char *protocol; /* the protocol name */ char *hostname; /* the host name */ int port; /* the port */ char *path; /* the path within the URL */ char *query; /* the query string */ SOCKET fd; /* the file descriptor for the socket */ int state; /* WRITE / READ / CLOSED */ char *out; /* buffer sent (zero terminated) */ char *outptr; /* index within the buffer sent */ char *in; /* the receiving buffer */ char *content; /* the start of the content */ char *inptr; /* the next byte to read from network */ char *inrptr; /* the next byte to give back to the client */ int inlen; /* len of the input buffer */ int last; /* return code for last operation */ int returnValue; /* the protocol return value */ int ContentLength; /* specified content length from HTTP header */ char *contentType; /* the MIME type for the input */ char *location; /* the new URL in case of redirect */ char *authHeader; /* contents of {WWW,Proxy}-Authenticate header */ char *encoding; /* encoding extracted from the contentType */ char *mimeType; /* Mime-Type extracted from the contentType */ #ifdef HAVE_ZLIB_H z_stream *strm; /* Zlib stream object */ int usesGzip; /* "Content-Encoding: gzip" was detected */ #endif } xmlNanoHTTPCtxt, *xmlNanoHTTPCtxtPtr; static int initialized = 0; static char *proxy = NULL; /* the proxy name if any */ static int proxyPort; /* the proxy port if any */ static unsigned int timeout = 60;/* the select() timeout in seconds */ static int xmlNanoHTTPFetchContent( void * ctx, char ** ptr, int * len ); /** * xmlHTTPErrMemory: * @extra: extra informations * * Handle an out of memory condition */ static void xmlHTTPErrMemory(const char *extra) { __xmlSimpleError(XML_FROM_HTTP, XML_ERR_NO_MEMORY, NULL, NULL, extra); } /** * A portability function */ static int socket_errno(void) { #ifdef _WINSOCKAPI_ return(WSAGetLastError()); #else return(errno); #endif } #ifdef SUPPORT_IP6 static int have_ipv6(void) { int s; s = socket (AF_INET6, SOCK_STREAM, 0); if (s != -1) { close (s); return (1); } return (0); } #endif /** * xmlNanoHTTPInit: * * Initialize the HTTP protocol layer. * Currently it just checks for proxy informations */ void xmlNanoHTTPInit(void) { const char *env; #ifdef _WINSOCKAPI_ WSADATA wsaData; #endif if (initialized) return; #ifdef _WINSOCKAPI_ if (WSAStartup(MAKEWORD(1, 1), &wsaData) != 0) return; #endif if (proxy == NULL) { proxyPort = 80; env = getenv("no_proxy"); if (env && ((env[0] == '*') && (env[1] == 0))) goto done; env = getenv("http_proxy"); if (env != NULL) { xmlNanoHTTPScanProxy(env); goto done; } env = getenv("HTTP_PROXY"); if (env != NULL) { xmlNanoHTTPScanProxy(env); goto done; } } done: initialized = 1; } /** * xmlNanoHTTPCleanup: * * Cleanup the HTTP protocol layer. */ void xmlNanoHTTPCleanup(void) { if (proxy != NULL) { xmlFree(proxy); proxy = NULL; } #ifdef _WINSOCKAPI_ if (initialized) WSACleanup(); #endif initialized = 0; return; } /** * xmlNanoHTTPScanURL: * @ctxt: an HTTP context * @URL: The URL used to initialize the context * * (Re)Initialize an HTTP context by parsing the URL and finding * the protocol host port and path it indicates. */ static void xmlNanoHTTPScanURL(xmlNanoHTTPCtxtPtr ctxt, const char *URL) { xmlURIPtr uri; /* * Clear any existing data from the context */ if (ctxt->protocol != NULL) { xmlFree(ctxt->protocol); ctxt->protocol = NULL; } if (ctxt->hostname != NULL) { xmlFree(ctxt->hostname); ctxt->hostname = NULL; } if (ctxt->path != NULL) { xmlFree(ctxt->path); ctxt->path = NULL; } if (ctxt->query != NULL) { xmlFree(ctxt->query); ctxt->query = NULL; } if (URL == NULL) return; uri = xmlParseURIRaw(URL, 1); if (uri == NULL) return; if ((uri->scheme == NULL) || (uri->server == NULL)) { xmlFreeURI(uri); return; } ctxt->protocol = xmlMemStrdup(uri->scheme); ctxt->hostname = xmlMemStrdup(uri->server); if (uri->path != NULL) ctxt->path = xmlMemStrdup(uri->path); else ctxt->path = xmlMemStrdup("/"); if (uri->query != NULL) ctxt->query = xmlMemStrdup(uri->query); if (uri->port != 0) ctxt->port = uri->port; xmlFreeURI(uri); } /** * xmlNanoHTTPScanProxy: * @URL: The proxy URL used to initialize the proxy context * * (Re)Initialize the HTTP Proxy context by parsing the URL and finding * the protocol host port it indicates. * Should be like http://myproxy/ or http://myproxy:3128/ * A NULL URL cleans up proxy informations. */ void xmlNanoHTTPScanProxy(const char *URL) { xmlURIPtr uri; if (proxy != NULL) { xmlFree(proxy); proxy = NULL; } proxyPort = 0; #ifdef DEBUG_HTTP if (URL == NULL) xmlGenericError(xmlGenericErrorContext, "Removing HTTP proxy info\n"); else xmlGenericError(xmlGenericErrorContext, "Using HTTP proxy %s\n", URL); #endif if (URL == NULL) return; uri = xmlParseURIRaw(URL, 1); if ((uri == NULL) || (uri->scheme == NULL) || (strcmp(uri->scheme, "http")) || (uri->server == NULL)) { __xmlIOErr(XML_FROM_HTTP, XML_HTTP_URL_SYNTAX, "Syntax Error\n"); if (uri != NULL) xmlFreeURI(uri); return; } proxy = xmlMemStrdup(uri->server); if (uri->port != 0) proxyPort = uri->port; xmlFreeURI(uri); } /** * xmlNanoHTTPNewCtxt: * @URL: The URL used to initialize the context * * Allocate and initialize a new HTTP context. * * Returns an HTTP context or NULL in case of error. */ static xmlNanoHTTPCtxtPtr xmlNanoHTTPNewCtxt(const char *URL) { xmlNanoHTTPCtxtPtr ret; ret = (xmlNanoHTTPCtxtPtr) xmlMalloc(sizeof(xmlNanoHTTPCtxt)); if (ret == NULL) { xmlHTTPErrMemory("allocating context"); return(NULL); } memset(ret, 0, sizeof(xmlNanoHTTPCtxt)); ret->port = 80; ret->returnValue = 0; ret->fd = -1; ret->ContentLength = -1; xmlNanoHTTPScanURL(ret, URL); return(ret); } /** * xmlNanoHTTPFreeCtxt: * @ctxt: an HTTP context * * Frees the context after closing the connection. */ static void xmlNanoHTTPFreeCtxt(xmlNanoHTTPCtxtPtr ctxt) { if (ctxt == NULL) return; if (ctxt->hostname != NULL) xmlFree(ctxt->hostname); if (ctxt->protocol != NULL) xmlFree(ctxt->protocol); if (ctxt->path != NULL) xmlFree(ctxt->path); if (ctxt->query != NULL) xmlFree(ctxt->query); if (ctxt->out != NULL) xmlFree(ctxt->out); if (ctxt->in != NULL) xmlFree(ctxt->in); if (ctxt->contentType != NULL) xmlFree(ctxt->contentType); if (ctxt->encoding != NULL) xmlFree(ctxt->encoding); if (ctxt->mimeType != NULL) xmlFree(ctxt->mimeType); if (ctxt->location != NULL) xmlFree(ctxt->location); if (ctxt->authHeader != NULL) xmlFree(ctxt->authHeader); #ifdef HAVE_ZLIB_H if (ctxt->strm != NULL) { inflateEnd(ctxt->strm); xmlFree(ctxt->strm); } #endif ctxt->state = XML_NANO_HTTP_NONE; if (ctxt->fd >= 0) closesocket(ctxt->fd); ctxt->fd = -1; xmlFree(ctxt); } /** * xmlNanoHTTPSend: * @ctxt: an HTTP context * * Send the input needed to initiate the processing on the server side * Returns number of bytes sent or -1 on error. */ static int xmlNanoHTTPSend(xmlNanoHTTPCtxtPtr ctxt, const char * xmt_ptr, int outlen) { int total_sent = 0; if ( (ctxt->state & XML_NANO_HTTP_WRITE) && (xmt_ptr != NULL ) ) { while (total_sent < outlen) { int nsent = send(ctxt->fd, xmt_ptr + total_sent, outlen - total_sent, 0); if (nsent>0) total_sent += nsent; else if ( ( nsent == -1 ) && #if defined(EAGAIN) && EAGAIN != EWOULDBLOCK ( socket_errno( ) != EAGAIN ) && #endif ( socket_errno( ) != EWOULDBLOCK ) ) { __xmlIOErr(XML_FROM_HTTP, 0, "send failed\n"); if ( total_sent == 0 ) total_sent = -1; break; } else { /* ** No data sent ** Since non-blocking sockets are used, wait for ** socket to be writable or default timeout prior ** to retrying. */ struct timeval tv; fd_set wfd; tv.tv_sec = timeout; tv.tv_usec = 0; FD_ZERO( &wfd ); #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable: 4018) #endif FD_SET( ctxt->fd, &wfd ); #ifdef _MSC_VER #pragma warning(pop) #endif (void)select( ctxt->fd + 1, NULL, &wfd, NULL, &tv ); } } } return total_sent; } /** * xmlNanoHTTPRecv: * @ctxt: an HTTP context * * Read information coming from the HTTP connection. * This is a blocking call (but it blocks in select(), not read()). * * Returns the number of byte read or -1 in case of error. */ static int xmlNanoHTTPRecv(xmlNanoHTTPCtxtPtr ctxt) { fd_set rfd; struct timeval tv; while (ctxt->state & XML_NANO_HTTP_READ) { if (ctxt->in == NULL) { ctxt->in = (char *) xmlMallocAtomic(65000 * sizeof(char)); if (ctxt->in == NULL) { xmlHTTPErrMemory("allocating input"); ctxt->last = -1; return(-1); } ctxt->inlen = 65000; ctxt->inptr = ctxt->content = ctxt->inrptr = ctxt->in; } if (ctxt->inrptr > ctxt->in + XML_NANO_HTTP_CHUNK) { int delta = ctxt->inrptr - ctxt->in; int len = ctxt->inptr - ctxt->inrptr; memmove(ctxt->in, ctxt->inrptr, len); ctxt->inrptr -= delta; ctxt->content -= delta; ctxt->inptr -= delta; } if ((ctxt->in + ctxt->inlen) < (ctxt->inptr + XML_NANO_HTTP_CHUNK)) { int d_inptr = ctxt->inptr - ctxt->in; int d_content = ctxt->content - ctxt->in; int d_inrptr = ctxt->inrptr - ctxt->in; char * tmp_ptr = ctxt->in; ctxt->inlen *= 2; ctxt->in = (char *) xmlRealloc(tmp_ptr, ctxt->inlen); if (ctxt->in == NULL) { xmlHTTPErrMemory("allocating input buffer"); xmlFree( tmp_ptr ); ctxt->last = -1; return(-1); } ctxt->inptr = ctxt->in + d_inptr; ctxt->content = ctxt->in + d_content; ctxt->inrptr = ctxt->in + d_inrptr; } ctxt->last = recv(ctxt->fd, ctxt->inptr, XML_NANO_HTTP_CHUNK, 0); if (ctxt->last > 0) { ctxt->inptr += ctxt->last; return(ctxt->last); } if (ctxt->last == 0) { return(0); } if (ctxt->last == -1) { switch (socket_errno()) { case EINPROGRESS: case EWOULDBLOCK: #if defined(EAGAIN) && EAGAIN != EWOULDBLOCK case EAGAIN: #endif break; case ECONNRESET: case ESHUTDOWN: return ( 0 ); default: __xmlIOErr(XML_FROM_HTTP, 0, "recv failed\n"); return(-1); } } tv.tv_sec = timeout; tv.tv_usec = 0; FD_ZERO(&rfd); #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable: 4018) #endif FD_SET(ctxt->fd, &rfd); #ifdef _MSC_VER #pragma warning(pop) #endif if ( (select(ctxt->fd+1, &rfd, NULL, NULL, &tv)<1) #if defined(EINTR) && (errno != EINTR) #endif ) return(0); } return(0); } /** * xmlNanoHTTPReadLine: * @ctxt: an HTTP context * * Read one line in the HTTP server output, usually for extracting * the HTTP protocol informations from the answer header. * * Returns a newly allocated string with a copy of the line, or NULL * which indicate the end of the input. */ static char * xmlNanoHTTPReadLine(xmlNanoHTTPCtxtPtr ctxt) { char buf[4096]; char *bp = buf; int rc; while (bp - buf < 4095) { if (ctxt->inrptr == ctxt->inptr) { if ( (rc = xmlNanoHTTPRecv(ctxt)) == 0) { if (bp == buf) return(NULL); else *bp = 0; return(xmlMemStrdup(buf)); } else if ( rc == -1 ) { return ( NULL ); } } *bp = *ctxt->inrptr++; if (*bp == '\n') { *bp = 0; return(xmlMemStrdup(buf)); } if (*bp != '\r') bp++; } buf[4095] = 0; return(xmlMemStrdup(buf)); } /** * xmlNanoHTTPScanAnswer: * @ctxt: an HTTP context * @line: an HTTP header line * * Try to extract useful informations from the server answer. * We currently parse and process: * - The HTTP revision/ return code * - The Content-Type, Mime-Type and charset used * - The Location for redirect processing. * * Returns -1 in case of failure, the file descriptor number otherwise */ static void xmlNanoHTTPScanAnswer(xmlNanoHTTPCtxtPtr ctxt, const char *line) { const char *cur = line; if (line == NULL) return; if (!strncmp(line, "HTTP/", 5)) { int version = 0; int ret = 0; cur += 5; while ((*cur >= '0') && (*cur <= '9')) { version *= 10; version += *cur - '0'; cur++; } if (*cur == '.') { cur++; if ((*cur >= '0') && (*cur <= '9')) { version *= 10; version += *cur - '0'; cur++; } while ((*cur >= '0') && (*cur <= '9')) cur++; } else version *= 10; if ((*cur != ' ') && (*cur != '\t')) return; while ((*cur == ' ') || (*cur == '\t')) cur++; if ((*cur < '0') || (*cur > '9')) return; while ((*cur >= '0') && (*cur <= '9')) { ret *= 10; ret += *cur - '0'; cur++; } if ((*cur != 0) && (*cur != ' ') && (*cur != '\t')) return; ctxt->returnValue = ret; } else if (!xmlStrncasecmp(BAD_CAST line, BAD_CAST"Content-Type:", 13)) { const xmlChar *charset, *last, *mime; cur += 13; while ((*cur == ' ') || (*cur == '\t')) cur++; if (ctxt->contentType != NULL) xmlFree(ctxt->contentType); ctxt->contentType = xmlMemStrdup(cur); mime = (const xmlChar *) cur; last = mime; while ((*last != 0) && (*last != ' ') && (*last != '\t') && (*last != ';') && (*last != ',')) last++; if (ctxt->mimeType != NULL) xmlFree(ctxt->mimeType); ctxt->mimeType = (char *) xmlStrndup(mime, last - mime); charset = xmlStrstr(BAD_CAST ctxt->contentType, BAD_CAST "charset="); if (charset != NULL) { charset += 8; last = charset; while ((*last != 0) && (*last != ' ') && (*last != '\t') && (*last != ';') && (*last != ',')) last++; if (ctxt->encoding != NULL) xmlFree(ctxt->encoding); ctxt->encoding = (char *) xmlStrndup(charset, last - charset); } } else if (!xmlStrncasecmp(BAD_CAST line, BAD_CAST"ContentType:", 12)) { const xmlChar *charset, *last, *mime; cur += 12; if (ctxt->contentType != NULL) return; while ((*cur == ' ') || (*cur == '\t')) cur++; ctxt->contentType = xmlMemStrdup(cur); mime = (const xmlChar *) cur; last = mime; while ((*last != 0) && (*last != ' ') && (*last != '\t') && (*last != ';') && (*last != ',')) last++; if (ctxt->mimeType != NULL) xmlFree(ctxt->mimeType); ctxt->mimeType = (char *) xmlStrndup(mime, last - mime); charset = xmlStrstr(BAD_CAST ctxt->contentType, BAD_CAST "charset="); if (charset != NULL) { charset += 8; last = charset; while ((*last != 0) && (*last != ' ') && (*last != '\t') && (*last != ';') && (*last != ',')) last++; if (ctxt->encoding != NULL) xmlFree(ctxt->encoding); ctxt->encoding = (char *) xmlStrndup(charset, last - charset); } } else if (!xmlStrncasecmp(BAD_CAST line, BAD_CAST"Location:", 9)) { cur += 9; while ((*cur == ' ') || (*cur == '\t')) cur++; if (ctxt->location != NULL) xmlFree(ctxt->location); if (*cur == '/') { xmlChar *tmp_http = xmlStrdup(BAD_CAST "http://"); xmlChar *tmp_loc = xmlStrcat(tmp_http, (const xmlChar *) ctxt->hostname); ctxt->location = (char *) xmlStrcat (tmp_loc, (const xmlChar *) cur); } else { ctxt->location = xmlMemStrdup(cur); } } else if (!xmlStrncasecmp(BAD_CAST line, BAD_CAST"WWW-Authenticate:", 17)) { cur += 17; while ((*cur == ' ') || (*cur == '\t')) cur++; if (ctxt->authHeader != NULL) xmlFree(ctxt->authHeader); ctxt->authHeader = xmlMemStrdup(cur); } else if (!xmlStrncasecmp(BAD_CAST line, BAD_CAST"Proxy-Authenticate:", 19)) { cur += 19; while ((*cur == ' ') || (*cur == '\t')) cur++; if (ctxt->authHeader != NULL) xmlFree(ctxt->authHeader); ctxt->authHeader = xmlMemStrdup(cur); #ifdef HAVE_ZLIB_H } else if ( !xmlStrncasecmp( BAD_CAST line, BAD_CAST"Content-Encoding:", 17) ) { cur += 17; while ((*cur == ' ') || (*cur == '\t')) cur++; if ( !xmlStrncasecmp( BAD_CAST cur, BAD_CAST"gzip", 4) ) { ctxt->usesGzip = 1; ctxt->strm = xmlMalloc(sizeof(z_stream)); if (ctxt->strm != NULL) { ctxt->strm->zalloc = Z_NULL; ctxt->strm->zfree = Z_NULL; ctxt->strm->opaque = Z_NULL; ctxt->strm->avail_in = 0; ctxt->strm->next_in = Z_NULL; inflateInit2( ctxt->strm, 31 ); } } #endif } else if ( !xmlStrncasecmp( BAD_CAST line, BAD_CAST"Content-Length:", 15) ) { cur += 15; ctxt->ContentLength = strtol( cur, NULL, 10 ); } } /** * xmlNanoHTTPConnectAttempt: * @addr: a socket address structure * * Attempt a connection to the given IP:port endpoint. It forces * non-blocking semantic on the socket, and allow 60 seconds for * the host to answer. * * Returns -1 in case of failure, the file descriptor number otherwise */ static int xmlNanoHTTPConnectAttempt(struct sockaddr *addr) { fd_set wfd; #ifdef _WINSOCKAPI_ fd_set xfd; #endif struct timeval tv; int status; int addrlen; SOCKET s; #ifdef SUPPORT_IP6 if (addr->sa_family == AF_INET6) { s = socket (PF_INET6, SOCK_STREAM, IPPROTO_TCP); addrlen = sizeof (struct sockaddr_in6); } else #endif { s = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP); addrlen = sizeof (struct sockaddr_in); } if (s==-1) { #ifdef DEBUG_HTTP perror("socket"); #endif __xmlIOErr(XML_FROM_HTTP, 0, "socket failed\n"); return(-1); } #ifdef _WINSOCKAPI_ { u_long one = 1; status = ioctlsocket(s, FIONBIO, &one) == SOCKET_ERROR ? -1 : 0; } #else /* _WINSOCKAPI_ */ #if defined(VMS) { int enable = 1; status = ioctl(s, FIONBIO, &enable); } #else /* VMS */ #if defined(__BEOS__) { bool noblock = true; status = setsockopt(s, SOL_SOCKET, SO_NONBLOCK, &noblock, sizeof(noblock)); } #else /* __BEOS__ */ if ((status = fcntl(s, F_GETFL, 0)) != -1) { #ifdef O_NONBLOCK status |= O_NONBLOCK; #else /* O_NONBLOCK */ #ifdef F_NDELAY status |= F_NDELAY; #endif /* F_NDELAY */ #endif /* !O_NONBLOCK */ status = fcntl(s, F_SETFL, status); } if (status < 0) { #ifdef DEBUG_HTTP perror("nonblocking"); #endif __xmlIOErr(XML_FROM_HTTP, 0, "error setting non-blocking IO\n"); closesocket(s); return(-1); } #endif /* !__BEOS__ */ #endif /* !VMS */ #endif /* !_WINSOCKAPI_ */ if (connect (s, addr, addrlen) == -1) { switch (socket_errno()) { case EINPROGRESS: case EWOULDBLOCK: break; default: __xmlIOErr(XML_FROM_HTTP, 0, "error connecting to HTTP server"); closesocket(s); return(-1); } } tv.tv_sec = timeout; tv.tv_usec = 0; #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable: 4018) #endif FD_ZERO(&wfd); FD_SET(s, &wfd); #ifdef _WINSOCKAPI_ FD_ZERO(&xfd); FD_SET(s, &xfd); switch(select(s+1, NULL, &wfd, &xfd, &tv)) #else switch(select(s+1, NULL, &wfd, NULL, &tv)) #endif #ifdef _MSC_VER #pragma warning(pop) #endif { case 0: /* Time out */ __xmlIOErr(XML_FROM_HTTP, 0, "Connect attempt timed out"); closesocket(s); return(-1); case -1: /* Ermm.. ?? */ __xmlIOErr(XML_FROM_HTTP, 0, "Connect failed"); closesocket(s); return(-1); } if ( FD_ISSET(s, &wfd) #ifdef _WINSOCKAPI_ || FD_ISSET(s, &xfd) #endif ) { XML_SOCKLEN_T len; len = sizeof(status); #ifdef SO_ERROR if (getsockopt(s, SOL_SOCKET, SO_ERROR, (char*)&status, &len) < 0 ) { /* Solaris error code */ __xmlIOErr(XML_FROM_HTTP, 0, "getsockopt failed\n"); return (-1); } #endif if ( status ) { __xmlIOErr(XML_FROM_HTTP, 0, "Error connecting to remote host"); closesocket(s); errno = status; return (-1); } } else { /* pbm */ __xmlIOErr(XML_FROM_HTTP, 0, "select failed\n"); closesocket(s); return (-1); } return(s); } /** * xmlNanoHTTPConnectHost: * @host: the host name * @port: the port number * * Attempt a connection to the given host:port endpoint. It tries * the multiple IP provided by the DNS if available. * * Returns -1 in case of failure, the file descriptor number otherwise */ static int xmlNanoHTTPConnectHost(const char *host, int port) { struct hostent *h; struct sockaddr *addr = NULL; struct in_addr ia; struct sockaddr_in sockin; #ifdef SUPPORT_IP6 struct in6_addr ia6; struct sockaddr_in6 sockin6; #endif int i; int s; memset (&sockin, 0, sizeof(sockin)); #ifdef SUPPORT_IP6 memset (&sockin6, 0, sizeof(sockin6)); #endif #if !defined(HAVE_GETADDRINFO) && defined(SUPPORT_IP6) && defined(RES_USE_INET6) if (have_ipv6 ()) { if (!(_res.options & RES_INIT)) res_init(); _res.options |= RES_USE_INET6; } #endif #if defined(HAVE_GETADDRINFO) && defined(SUPPORT_IP6) && !defined(_WIN32) if (have_ipv6 ()) #endif #if defined(HAVE_GETADDRINFO) && (defined(SUPPORT_IP6) || defined(_WIN32)) { int status; struct addrinfo hints, *res, *result; result = NULL; memset (&hints, 0,sizeof(hints)); hints.ai_socktype = SOCK_STREAM; status = getaddrinfo (host, NULL, &hints, &result); if (status) { __xmlIOErr(XML_FROM_HTTP, 0, "getaddrinfo failed\n"); return (-1); } for (res = result; res; res = res->ai_next) { if (res->ai_family == AF_INET) { if (res->ai_addrlen > sizeof(sockin)) { __xmlIOErr(XML_FROM_HTTP, 0, "address size mismatch\n"); freeaddrinfo (result); return (-1); } memcpy (&sockin, res->ai_addr, res->ai_addrlen); sockin.sin_port = htons (port); addr = (struct sockaddr *)&sockin; #ifdef SUPPORT_IP6 } else if (have_ipv6 () && (res->ai_family == AF_INET6)) { if (res->ai_addrlen > sizeof(sockin6)) { __xmlIOErr(XML_FROM_HTTP, 0, "address size mismatch\n"); freeaddrinfo (result); return (-1); } memcpy (&sockin6, res->ai_addr, res->ai_addrlen); sockin6.sin6_port = htons (port); addr = (struct sockaddr *)&sockin6; #endif } else continue; /* for */ s = xmlNanoHTTPConnectAttempt (addr); if (s != -1) { freeaddrinfo (result); return (s); } } if (result) freeaddrinfo (result); } #endif #if defined(HAVE_GETADDRINFO) && defined(SUPPORT_IP6) && !defined(_WIN32) else #endif #if !defined(HAVE_GETADDRINFO) || !defined(_WIN32) { h = gethostbyname (host); if (h == NULL) { /* * Okay, I got fed up by the non-portability of this error message * extraction code. it work on Linux, if it work on your platform * and one want to enable it, send me the defined(foobar) needed */ #if defined(HAVE_NETDB_H) && defined(HOST_NOT_FOUND) && defined(linux) const char *h_err_txt = ""; switch (h_errno) { case HOST_NOT_FOUND: h_err_txt = "Authoritive host not found"; break; case TRY_AGAIN: h_err_txt = "Non-authoritive host not found or server failure."; break; case NO_RECOVERY: h_err_txt = "Non-recoverable errors: FORMERR, REFUSED, or NOTIMP."; break; case NO_ADDRESS: h_err_txt = "Valid name, no data record of requested type."; break; default: h_err_txt = "No error text defined."; break; } __xmlIOErr(XML_FROM_HTTP, 0, h_err_txt); #else __xmlIOErr(XML_FROM_HTTP, 0, "Failed to resolve host"); #endif return (-1); } for (i = 0; h->h_addr_list[i]; i++) { if (h->h_addrtype == AF_INET) { /* A records (IPv4) */ if ((unsigned int) h->h_length > sizeof(ia)) { __xmlIOErr(XML_FROM_HTTP, 0, "address size mismatch\n"); return (-1); } memcpy (&ia, h->h_addr_list[i], h->h_length); sockin.sin_family = h->h_addrtype; sockin.sin_addr = ia; sockin.sin_port = (u_short)htons ((unsigned short)port); addr = (struct sockaddr *) &sockin; #ifdef SUPPORT_IP6 } else if (have_ipv6 () && (h->h_addrtype == AF_INET6)) { /* AAAA records (IPv6) */ if ((unsigned int) h->h_length > sizeof(ia6)) { __xmlIOErr(XML_FROM_HTTP, 0, "address size mismatch\n"); return (-1); } memcpy (&ia6, h->h_addr_list[i], h->h_length); sockin6.sin6_family = h->h_addrtype; sockin6.sin6_addr = ia6; sockin6.sin6_port = htons (port); addr = (struct sockaddr *) &sockin6; #endif } else break; /* for */ s = xmlNanoHTTPConnectAttempt (addr); if (s != -1) return (s); } } #endif #ifdef DEBUG_HTTP xmlGenericError(xmlGenericErrorContext, "xmlNanoHTTPConnectHost: unable to connect to '%s'.\n", host); #endif return (-1); } /** * xmlNanoHTTPOpen: * @URL: The URL to load * @contentType: if available the Content-Type information will be * returned at that location * * This function try to open a connection to the indicated resource * via HTTP GET. * * Returns NULL in case of failure, otherwise a request handler. * The contentType, if provided must be freed by the caller */ void* xmlNanoHTTPOpen(const char *URL, char **contentType) { if (contentType != NULL) *contentType = NULL; return(xmlNanoHTTPMethod(URL, NULL, NULL, contentType, NULL, 0)); } /** * xmlNanoHTTPOpenRedir: * @URL: The URL to load * @contentType: if available the Content-Type information will be * returned at that location * @redir: if available the redirected URL will be returned * * This function try to open a connection to the indicated resource * via HTTP GET. * * Returns NULL in case of failure, otherwise a request handler. * The contentType, if provided must be freed by the caller */ void* xmlNanoHTTPOpenRedir(const char *URL, char **contentType, char **redir) { if (contentType != NULL) *contentType = NULL; if (redir != NULL) *redir = NULL; return(xmlNanoHTTPMethodRedir(URL, NULL, NULL, contentType, redir, NULL,0)); } /** * xmlNanoHTTPRead: * @ctx: the HTTP context * @dest: a buffer * @len: the buffer length * * This function tries to read @len bytes from the existing HTTP connection * and saves them in @dest. This is a blocking call. * * Returns the number of byte read. 0 is an indication of an end of connection. * -1 indicates a parameter error. */ int xmlNanoHTTPRead(void *ctx, void *dest, int len) { xmlNanoHTTPCtxtPtr ctxt = (xmlNanoHTTPCtxtPtr) ctx; #ifdef HAVE_ZLIB_H int bytes_read = 0; int orig_avail_in; int z_ret; #endif if (ctx == NULL) return(-1); if (dest == NULL) return(-1); if (len <= 0) return(0); #ifdef HAVE_ZLIB_H if (ctxt->usesGzip == 1) { if (ctxt->strm == NULL) return(0); ctxt->strm->next_out = dest; ctxt->strm->avail_out = len; do { orig_avail_in = ctxt->strm->avail_in = ctxt->inptr - ctxt->inrptr - bytes_read; ctxt->strm->next_in = BAD_CAST (ctxt->inrptr + bytes_read); z_ret = inflate(ctxt->strm, Z_NO_FLUSH); bytes_read += orig_avail_in - ctxt->strm->avail_in; if (z_ret != Z_OK) break; } while (ctxt->strm->avail_out > 0 && xmlNanoHTTPRecv(ctxt) > 0); ctxt->inrptr += bytes_read; return(len - ctxt->strm->avail_out); } #endif while (ctxt->inptr - ctxt->inrptr < len) { if (xmlNanoHTTPRecv(ctxt) <= 0) break; } if (ctxt->inptr - ctxt->inrptr < len) len = ctxt->inptr - ctxt->inrptr; memcpy(dest, ctxt->inrptr, len); ctxt->inrptr += len; return(len); } /** * xmlNanoHTTPClose: * @ctx: the HTTP context * * This function closes an HTTP context, it ends up the connection and * free all data related to it. */ void xmlNanoHTTPClose(void *ctx) { xmlNanoHTTPCtxtPtr ctxt = (xmlNanoHTTPCtxtPtr) ctx; if (ctx == NULL) return; xmlNanoHTTPFreeCtxt(ctxt); } /** * xmlNanoHTTPMethodRedir: * @URL: The URL to load * @method: the HTTP method to use * @input: the input string if any * @contentType: the Content-Type information IN and OUT * @redir: the redirected URL OUT * @headers: the extra headers * @ilen: input length * * This function try to open a connection to the indicated resource * via HTTP using the given @method, adding the given extra headers * and the input buffer for the request content. * * Returns NULL in case of failure, otherwise a request handler. * The contentType, or redir, if provided must be freed by the caller */ void* xmlNanoHTTPMethodRedir(const char *URL, const char *method, const char *input, char **contentType, char **redir, const char *headers, int ilen ) { xmlNanoHTTPCtxtPtr ctxt; char *bp, *p; int blen, ret; int head; int nbRedirects = 0; char *redirURL = NULL; #ifdef DEBUG_HTTP int xmt_bytes; #endif if (URL == NULL) return(NULL); if (method == NULL) method = "GET"; xmlNanoHTTPInit(); retry: if (redirURL == NULL) ctxt = xmlNanoHTTPNewCtxt(URL); else { ctxt = xmlNanoHTTPNewCtxt(redirURL); ctxt->location = xmlMemStrdup(redirURL); } if ( ctxt == NULL ) { return ( NULL ); } if ((ctxt->protocol == NULL) || (strcmp(ctxt->protocol, "http"))) { __xmlIOErr(XML_FROM_HTTP, XML_HTTP_URL_SYNTAX, "Not a valid HTTP URI"); xmlNanoHTTPFreeCtxt(ctxt); if (redirURL != NULL) xmlFree(redirURL); return(NULL); } if (ctxt->hostname == NULL) { __xmlIOErr(XML_FROM_HTTP, XML_HTTP_UNKNOWN_HOST, "Failed to identify host in URI"); xmlNanoHTTPFreeCtxt(ctxt); if (redirURL != NULL) xmlFree(redirURL); return(NULL); } if (proxy) { blen = strlen(ctxt->hostname) * 2 + 16; ret = xmlNanoHTTPConnectHost(proxy, proxyPort); } else { blen = strlen(ctxt->hostname); ret = xmlNanoHTTPConnectHost(ctxt->hostname, ctxt->port); } if (ret < 0) { xmlNanoHTTPFreeCtxt(ctxt); if (redirURL != NULL) xmlFree(redirURL); return(NULL); } ctxt->fd = ret; if (input == NULL) ilen = 0; else blen += 36; if (headers != NULL) blen += strlen(headers) + 2; if (contentType && *contentType) blen += strlen(*contentType) + 16; if (ctxt->query != NULL) blen += strlen(ctxt->query) + 1; blen += strlen(method) + strlen(ctxt->path) + 24; #ifdef HAVE_ZLIB_H blen += 23; #endif bp = (char*)xmlMallocAtomic(blen); if ( bp == NULL ) { xmlNanoHTTPFreeCtxt( ctxt ); xmlHTTPErrMemory("allocating header buffer"); return ( NULL ); } p = bp; if (proxy) { if (ctxt->port != 80) { p += snprintf( p, blen - (p - bp), "%s http://%s:%d%s", method, ctxt->hostname, ctxt->port, ctxt->path ); } else p += snprintf( p, blen - (p - bp), "%s http://%s%s", method, ctxt->hostname, ctxt->path); } else p += snprintf( p, blen - (p - bp), "%s %s", method, ctxt->path); if (ctxt->query != NULL) p += snprintf( p, blen - (p - bp), "?%s", ctxt->query); p += snprintf( p, blen - (p - bp), " HTTP/1.0\r\nHost: %s\r\n", ctxt->hostname); #ifdef HAVE_ZLIB_H p += snprintf(p, blen - (p - bp), "Accept-Encoding: gzip\r\n"); #endif if (contentType != NULL && *contentType) p += snprintf(p, blen - (p - bp), "Content-Type: %s\r\n", *contentType); if (headers != NULL) p += snprintf( p, blen - (p - bp), "%s", headers ); if (input != NULL) snprintf(p, blen - (p - bp), "Content-Length: %d\r\n\r\n", ilen ); else snprintf(p, blen - (p - bp), "\r\n"); #ifdef DEBUG_HTTP xmlGenericError(xmlGenericErrorContext, "-> %s%s", proxy? "(Proxy) " : "", bp); if ((blen -= strlen(bp)+1) < 0) xmlGenericError(xmlGenericErrorContext, "ERROR: overflowed buffer by %d bytes\n", -blen); #endif ctxt->outptr = ctxt->out = bp; ctxt->state = XML_NANO_HTTP_WRITE; blen = strlen( ctxt->out ); #ifdef DEBUG_HTTP xmt_bytes = xmlNanoHTTPSend(ctxt, ctxt->out, blen ); if ( xmt_bytes != blen ) xmlGenericError( xmlGenericErrorContext, "xmlNanoHTTPMethodRedir: Only %d of %d %s %s\n", xmt_bytes, blen, "bytes of HTTP headers sent to host", ctxt->hostname ); #else xmlNanoHTTPSend(ctxt, ctxt->out, blen ); #endif if ( input != NULL ) { #ifdef DEBUG_HTTP xmt_bytes = xmlNanoHTTPSend( ctxt, input, ilen ); if ( xmt_bytes != ilen ) xmlGenericError( xmlGenericErrorContext, "xmlNanoHTTPMethodRedir: Only %d of %d %s %s\n", xmt_bytes, ilen, "bytes of HTTP content sent to host", ctxt->hostname ); #else xmlNanoHTTPSend( ctxt, input, ilen ); #endif } ctxt->state = XML_NANO_HTTP_READ; head = 1; while ((p = xmlNanoHTTPReadLine(ctxt)) != NULL) { if (head && (*p == 0)) { head = 0; ctxt->content = ctxt->inrptr; xmlFree(p); break; } xmlNanoHTTPScanAnswer(ctxt, p); #ifdef DEBUG_HTTP xmlGenericError(xmlGenericErrorContext, "<- %s\n", p); #endif xmlFree(p); } if ((ctxt->location != NULL) && (ctxt->returnValue >= 300) && (ctxt->returnValue < 400)) { #ifdef DEBUG_HTTP xmlGenericError(xmlGenericErrorContext, "\nRedirect to: %s\n", ctxt->location); #endif while ( xmlNanoHTTPRecv(ctxt) > 0 ) ; if (nbRedirects < XML_NANO_HTTP_MAX_REDIR) { nbRedirects++; if (redirURL != NULL) xmlFree(redirURL); redirURL = xmlMemStrdup(ctxt->location); xmlNanoHTTPFreeCtxt(ctxt); goto retry; } xmlNanoHTTPFreeCtxt(ctxt); if (redirURL != NULL) xmlFree(redirURL); #ifdef DEBUG_HTTP xmlGenericError(xmlGenericErrorContext, "xmlNanoHTTPMethodRedir: Too many redirects, aborting ...\n"); #endif return(NULL); } if (contentType != NULL) { if (ctxt->contentType != NULL) *contentType = xmlMemStrdup(ctxt->contentType); else *contentType = NULL; } if ((redir != NULL) && (redirURL != NULL)) { *redir = redirURL; } else { if (redirURL != NULL) xmlFree(redirURL); if (redir != NULL) *redir = NULL; } #ifdef DEBUG_HTTP if (ctxt->contentType != NULL) xmlGenericError(xmlGenericErrorContext, "\nCode %d, content-type '%s'\n\n", ctxt->returnValue, ctxt->contentType); else xmlGenericError(xmlGenericErrorContext, "\nCode %d, no content-type\n\n", ctxt->returnValue); #endif return((void *) ctxt); } /** * xmlNanoHTTPMethod: * @URL: The URL to load * @method: the HTTP method to use * @input: the input string if any * @contentType: the Content-Type information IN and OUT * @headers: the extra headers * @ilen: input length * * This function try to open a connection to the indicated resource * via HTTP using the given @method, adding the given extra headers * and the input buffer for the request content. * * Returns NULL in case of failure, otherwise a request handler. * The contentType, if provided must be freed by the caller */ void* xmlNanoHTTPMethod(const char *URL, const char *method, const char *input, char **contentType, const char *headers, int ilen) { return(xmlNanoHTTPMethodRedir(URL, method, input, contentType, NULL, headers, ilen)); } /** * xmlNanoHTTPFetch: * @URL: The URL to load * @filename: the filename where the content should be saved * @contentType: if available the Content-Type information will be * returned at that location * * This function try to fetch the indicated resource via HTTP GET * and save it's content in the file. * * Returns -1 in case of failure, 0 incase of success. The contentType, * if provided must be freed by the caller */ int xmlNanoHTTPFetch(const char *URL, const char *filename, char **contentType) { void *ctxt = NULL; char *buf = NULL; int fd; int len; if (filename == NULL) return(-1); ctxt = xmlNanoHTTPOpen(URL, contentType); if (ctxt == NULL) return(-1); if (!strcmp(filename, "-")) fd = 0; else { fd = open(filename, O_CREAT | O_WRONLY, 00644); if (fd < 0) { xmlNanoHTTPClose(ctxt); if ((contentType != NULL) && (*contentType != NULL)) { xmlFree(*contentType); *contentType = NULL; } return(-1); } } xmlNanoHTTPFetchContent( ctxt, &buf, &len ); if ( len > 0 ) { write(fd, buf, len); } xmlNanoHTTPClose(ctxt); close(fd); return(0); } #ifdef LIBXML_OUTPUT_ENABLED /** * xmlNanoHTTPSave: * @ctxt: the HTTP context * @filename: the filename where the content should be saved * * This function saves the output of the HTTP transaction to a file * It closes and free the context at the end * * Returns -1 in case of failure, 0 incase of success. */ int xmlNanoHTTPSave(void *ctxt, const char *filename) { char *buf = NULL; int fd; int len; if ((ctxt == NULL) || (filename == NULL)) return(-1); if (!strcmp(filename, "-")) fd = 0; else { fd = open(filename, O_CREAT | O_WRONLY); if (fd < 0) { xmlNanoHTTPClose(ctxt); return(-1); } } xmlNanoHTTPFetchContent( ctxt, &buf, &len ); if ( len > 0 ) { write(fd, buf, len); } xmlNanoHTTPClose(ctxt); close(fd); return(0); } #endif /* LIBXML_OUTPUT_ENABLED */ /** * xmlNanoHTTPReturnCode: * @ctx: the HTTP context * * Get the latest HTTP return code received * * Returns the HTTP return code for the request. */ int xmlNanoHTTPReturnCode(void *ctx) { xmlNanoHTTPCtxtPtr ctxt = (xmlNanoHTTPCtxtPtr) ctx; if (ctxt == NULL) return(-1); return(ctxt->returnValue); } /** * xmlNanoHTTPAuthHeader: * @ctx: the HTTP context * * Get the authentication header of an HTTP context * * Returns the stashed value of the WWW-Authenticate or Proxy-Authenticate * header. */ const char * xmlNanoHTTPAuthHeader(void *ctx) { xmlNanoHTTPCtxtPtr ctxt = (xmlNanoHTTPCtxtPtr) ctx; if (ctxt == NULL) return(NULL); return(ctxt->authHeader); } /** * xmlNanoHTTPContentLength: * @ctx: the HTTP context * * Provides the specified content length from the HTTP header. * * Return the specified content length from the HTTP header. Note that * a value of -1 indicates that the content length element was not included in * the response header. */ int xmlNanoHTTPContentLength( void * ctx ) { xmlNanoHTTPCtxtPtr ctxt = (xmlNanoHTTPCtxtPtr)ctx; return ( ( ctxt == NULL ) ? -1 : ctxt->ContentLength ); } /** * xmlNanoHTTPRedir: * @ctx: the HTTP context * * Provides the specified redirection URL if available from the HTTP header. * * Return the specified redirection URL or NULL if not redirected. */ const char * xmlNanoHTTPRedir( void * ctx ) { xmlNanoHTTPCtxtPtr ctxt = (xmlNanoHTTPCtxtPtr)ctx; return ( ( ctxt == NULL ) ? NULL : ctxt->location ); } /** * xmlNanoHTTPEncoding: * @ctx: the HTTP context * * Provides the specified encoding if specified in the HTTP headers. * * Return the specified encoding or NULL if not available */ const char * xmlNanoHTTPEncoding( void * ctx ) { xmlNanoHTTPCtxtPtr ctxt = (xmlNanoHTTPCtxtPtr)ctx; return ( ( ctxt == NULL ) ? NULL : ctxt->encoding ); } /** * xmlNanoHTTPMimeType: * @ctx: the HTTP context * * Provides the specified Mime-Type if specified in the HTTP headers. * * Return the specified Mime-Type or NULL if not available */ const char * xmlNanoHTTPMimeType( void * ctx ) { xmlNanoHTTPCtxtPtr ctxt = (xmlNanoHTTPCtxtPtr)ctx; return ( ( ctxt == NULL ) ? NULL : ctxt->mimeType ); } /** * xmlNanoHTTPFetchContent: * @ctx: the HTTP context * @ptr: pointer to set to the content buffer. * @len: integer pointer to hold the length of the content * * Check if all the content was read * * Returns 0 if all the content was read and available, returns * -1 if received content length was less than specified or an error * occurred. */ static int xmlNanoHTTPFetchContent( void * ctx, char ** ptr, int * len ) { xmlNanoHTTPCtxtPtr ctxt = (xmlNanoHTTPCtxtPtr)ctx; int rc = 0; int cur_lgth; int rcvd_lgth; int dummy_int; char * dummy_ptr = NULL; /* Dummy up return input parameters if not provided */ if ( len == NULL ) len = &dummy_int; if ( ptr == NULL ) ptr = &dummy_ptr; /* But can't work without the context pointer */ if ( ( ctxt == NULL ) || ( ctxt->content == NULL ) ) { *len = 0; *ptr = NULL; return ( -1 ); } rcvd_lgth = ctxt->inptr - ctxt->content; while ( (cur_lgth = xmlNanoHTTPRecv( ctxt )) > 0 ) { rcvd_lgth += cur_lgth; if ( (ctxt->ContentLength > 0) && (rcvd_lgth >= ctxt->ContentLength) ) break; } *ptr = ctxt->content; *len = rcvd_lgth; if ( ( ctxt->ContentLength > 0 ) && ( rcvd_lgth < ctxt->ContentLength ) ) rc = -1; else if ( rcvd_lgth == 0 ) rc = -1; return ( rc ); } #ifdef STANDALONE int main(int argc, char **argv) { char *contentType = NULL; if (argv[1] != NULL) { if (argv[2] != NULL) xmlNanoHTTPFetch(argv[1], argv[2], &contentType); else xmlNanoHTTPFetch(argv[1], "-", &contentType); if (contentType != NULL) xmlFree(contentType); } else { xmlGenericError(xmlGenericErrorContext, "%s: minimal HTTP GET implementation\n", argv[0]); xmlGenericError(xmlGenericErrorContext, "\tusage %s [ URL [ filename ] ]\n", argv[0]); } xmlNanoHTTPCleanup(); xmlMemoryDump(); return(0); } #endif /* STANDALONE */ #else /* !LIBXML_HTTP_ENABLED */ #ifdef STANDALONE #include int main(int argc, char **argv) { xmlGenericError(xmlGenericErrorContext, "%s : HTTP support not compiled in\n", argv[0]); return(0); } #endif /* STANDALONE */ #endif /* LIBXML_HTTP_ENABLED */ #define bottom_nanohttp #include "elfgcchack.h" xdmf-3.0+git20160803/Utilities/vtklibxml2/libxml.h0000640000175000017500000000334513003006557021610 0ustar alastairalastair/* * libxml.h: internal header only used during the compilation of libxml * * See COPYRIGHT for the status of this software * * Author: breese@users.sourceforge.net */ #ifndef __XML_LIBXML_H__ #define __XML_LIBXML_H__ #ifndef NO_LARGEFILE_SOURCE #ifndef _LARGEFILE_SOURCE #define _LARGEFILE_SOURCE #endif #ifndef _FILE_OFFSET_BITS #define _FILE_OFFSET_BITS 64 #endif #endif #if defined(macintosh) #include "config-mac.h" #else #include "config.h" #include #endif #if defined(__Lynx__) #include /* pull definition of size_t */ #include int snprintf(char *, size_t, const char *, ...); int vfprintf(FILE *, const char *, va_list); #endif #ifndef WITH_TRIO #include #else /** * TRIO_REPLACE_STDIO: * * This macro is defined if teh trio string formatting functions are to * be used instead of the default stdio ones. */ #define TRIO_REPLACE_STDIO #include "trio.h" #endif /* * Internal variable indicating if a callback has been registered for * node creation/destruction. It avoids spending a lot of time in locking * function while checking if the callback exists. */ extern int __xmlRegisterCallbacks; /* * internal error reporting routines, shared but not partof the API. */ void __xmlIOErr(int domain, int code, const char *extra); void __xmlLoaderErr(void *ctx, const char *msg, const char *filename); #ifdef LIBXML_HTML_ENABLED /* * internal function of HTML parser needed for xmlParseInNodeContext * but not part of the API */ void __htmlParseContent(void *ctx); #endif #ifdef IN_LIBXML #ifdef __GNUC__ #ifdef PIC #ifdef linux #if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || (__GNUC__ > 3) #include "elfgcchack.h" #endif #endif #endif #endif #endif #endif /* ! __XML_LIBXML_H__ */ xdmf-3.0+git20160803/Utilities/vtklibxml2/trionan.h0000640000175000017500000000407513003006557021774 0ustar alastairalastair/************************************************************************* * * Id: trionan.h 2026 2003-08-06 04:43:55Z wbrack * * Copyright (C) 2001 Bjorn Reese * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. * ************************************************************************/ #ifndef TRIO_NAN_H #define TRIO_NAN_H #include "triodef.h" #ifdef __cplusplus extern "C" { #endif enum { TRIO_FP_INFINITE, TRIO_FP_NAN, TRIO_FP_NORMAL, TRIO_FP_SUBNORMAL, TRIO_FP_ZERO }; /* * Return NaN (Not-a-Number). */ TRIO_PUBLIC double trio_nan TRIO_PROTO((void)); /* * Return positive infinity. */ TRIO_PUBLIC double trio_pinf TRIO_PROTO((void)); /* * Return negative infinity. */ TRIO_PUBLIC double trio_ninf TRIO_PROTO((void)); /* * Return negative zero. */ TRIO_PUBLIC double trio_nzero TRIO_PROTO((TRIO_NOARGS)); /* * If number is a NaN return non-zero, otherwise return zero. */ TRIO_PUBLIC int trio_isnan TRIO_PROTO((double number)); /* * If number is positive infinity return 1, if number is negative * infinity return -1, otherwise return 0. */ TRIO_PUBLIC int trio_isinf TRIO_PROTO((double number)); /* * If number is finite return non-zero, otherwise return zero. */ #if 0 /* Temporary fix - these 2 routines not used in libxml */ TRIO_PUBLIC int trio_isfinite TRIO_PROTO((double number)); TRIO_PUBLIC int trio_fpclassify TRIO_PROTO((double number)); #endif TRIO_PUBLIC int trio_signbit TRIO_PROTO((double number)); TRIO_PUBLIC int trio_fpclassify_and_signbit TRIO_PROTO((double number, int *is_negative)); #ifdef __cplusplus } #endif #endif /* TRIO_NAN_H */ xdmf-3.0+git20160803/Utilities/vtklibxml2/xlink.c0000640000175000017500000001206013003006557021433 0ustar alastairalastair/* * xlink.c : implementation of the hyperlinks detection module * This version supports both XML XLinks and HTML simple links * * See Copyright for the status of this software. * * daniel@veillard.com */ #define IN_LIBXML #include "libxml.h" #ifdef LIBXML_XPTR_ENABLED #include /* for memset() only */ #ifdef HAVE_CTYPE_H #include #endif #ifdef HAVE_STDLIB_H #include #endif #ifdef HAVE_SYS_STAT_H #include #endif #ifdef HAVE_FCNTL_H #include #endif #ifdef HAVE_UNISTD_H #include #endif #include "vtk_libxml2_zlib.h" #include #include #include #include #include #include #define XLINK_NAMESPACE (BAD_CAST "http://www.w3.org/1999/xlink/namespace/") #define XHTML_NAMESPACE (BAD_CAST "http://www.w3.org/1999/xhtml/") /**************************************************************** * * * Default setting and related functions * * * ****************************************************************/ static xlinkHandlerPtr xlinkDefaultHandler = NULL; static xlinkNodeDetectFunc xlinkDefaultDetect = NULL; /** * xlinkGetDefaultHandler: * * Get the default xlink handler. * * Returns the current xlinkHandlerPtr value. */ xlinkHandlerPtr xlinkGetDefaultHandler(void) { return(xlinkDefaultHandler); } /** * xlinkSetDefaultHandler: * @handler: the new value for the xlink handler block * * Set the default xlink handlers */ void xlinkSetDefaultHandler(xlinkHandlerPtr handler) { xlinkDefaultHandler = handler; } /** * xlinkGetDefaultDetect: * * Get the default xlink detection routine * * Returns the current function or NULL; */ xlinkNodeDetectFunc xlinkGetDefaultDetect (void) { return(xlinkDefaultDetect); } /** * xlinkSetDefaultDetect: * @func: pointer to the new detection routine. * * Set the default xlink detection routine */ void xlinkSetDefaultDetect (xlinkNodeDetectFunc func) { xlinkDefaultDetect = func; } /**************************************************************** * * * The detection routines * * * ****************************************************************/ /** * xlinkIsLink: * @doc: the document containing the node * @node: the node pointer itself * * Check whether the given node carries the attributes needed * to be a link element (or is one of the linking elements issued * from the (X)HTML DtDs). * This routine don't try to do full checking of the link validity * but tries to detect and return the appropriate link type. * * Returns the xlinkType of the node (XLINK_TYPE_NONE if there is no * link detected. */ xlinkType xlinkIsLink (xmlDocPtr doc, xmlNodePtr node) { xmlChar *type = NULL, *role = NULL; xlinkType ret = XLINK_TYPE_NONE; if (node == NULL) return(XLINK_TYPE_NONE); if (doc == NULL) doc = node->doc; if ((doc != NULL) && (doc->type == XML_HTML_DOCUMENT_NODE)) { /* * This is an HTML document. */ } else if ((node->ns != NULL) && (xmlStrEqual(node->ns->href, XHTML_NAMESPACE))) { /* * !!!! We really need an IS_XHTML_ELEMENT function from HTMLtree.h @@@ */ /* * This is an XHTML element within an XML document * Check whether it's one of the element able to carry links * and in that case if it holds the attributes. */ } /* * We don't prevent a-priori having XML Linking constructs on * XHTML elements */ type = xmlGetNsProp(node, BAD_CAST"type", XLINK_NAMESPACE); if (type != NULL) { if (xmlStrEqual(type, BAD_CAST "simple")) { ret = XLINK_TYPE_SIMPLE; } if (xmlStrEqual(type, BAD_CAST "extended")) { role = xmlGetNsProp(node, BAD_CAST "role", XLINK_NAMESPACE); if (role != NULL) { xmlNsPtr xlink; xlink = xmlSearchNs(doc, node, XLINK_NAMESPACE); if (xlink == NULL) { /* Humm, fallback method */ if (xmlStrEqual(role, BAD_CAST"xlink:external-linkset")) ret = XLINK_TYPE_EXTENDED_SET; } else { xmlChar buf[200]; snprintf((char *) buf, sizeof(buf), "%s:external-linkset", (char *) xlink->prefix); buf[sizeof(buf) - 1] = 0; if (xmlStrEqual(role, buf)) ret = XLINK_TYPE_EXTENDED_SET; } } ret = XLINK_TYPE_EXTENDED; } } if (type != NULL) xmlFree(type); if (role != NULL) xmlFree(role); return(ret); } #endif /* LIBXML_XPTR_ENABLED */ #define bottom_xlink #include "elfgcchack.h" xdmf-3.0+git20160803/Utilities/vtklibxml2/elfgcchack.h0000640000175000017500000240254613003006557022403 0ustar alastairalastair/* * elfgcchack.h: hack by Arjan van de Ven to speed * up the code when using gcc for call within the library. * * Based on the analysis http://people.redhat.com/drepper/dsohowto.pdf * from Ulrich drepper. Rewritten to be generated from the XML description * file for libxml2 API * autogenerated with xsltproc doc/elfgcchack.xsl doc/libxml2-api.xml */ #if 0 /* Disable this feature in VTK until the mangling can be handled. */ #ifdef IN_LIBXML #ifdef __GNUC__ #ifdef PIC #ifdef linux #if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || (__GNUC__ > 3) #include "libxml/c14n.h" #include "libxml/catalog.h" #include "libxml/chvalid.h" #include "libxml/debugXML.h" #include "libxml/dict.h" #include "libxml/DOCBparser.h" #include "libxml/encoding.h" #include "libxml/entities.h" #include "libxml/globals.h" #include "libxml/hash.h" #include "libxml/HTMLparser.h" #include "libxml/HTMLtree.h" #include "libxml/list.h" #include "libxml/nanoftp.h" #include "libxml/nanohttp.h" #include "libxml/parser.h" #include "libxml/parserInternals.h" #include "libxml/pattern.h" #include "libxml/relaxng.h" #include "libxml/SAX2.h" #include "libxml/SAX.h" #include "libxml/schemasInternals.h" #include "libxml/schematron.h" #include "libxml/threads.h" #include "libxml/tree.h" #include "libxml/uri.h" #include "libxml/valid.h" #include "libxml/xinclude.h" #include "libxml/xlink.h" #include "libxml/xmlautomata.h" #include "libxml/xmlerror.h" #include "libxml/xmlexports.h" #include "libxml/xmlIO.h" #include "libxml/xmlmemory.h" #include "libxml/xmlreader.h" #include "libxml/xmlregexp.h" #include "libxml/xmlsave.h" #include "libxml/xmlschemas.h" #include "libxml/xmlschemastypes.h" #include "libxml/xmlstring.h" #include "libxml/xmlunicode.h" #include "libxml/xmlversion.h" #include "libxml/xmlwriter.h" #include "libxml/xpath.h" #include "libxml/xpathInternals.h" #include "libxml/xpointer.h" #include "libxml/xmlmodule.h" /* special hot spot not exported ones */ #ifdef bottom_globals #undef __xmlGenericError extern __typeof (__xmlGenericError) __xmlGenericError __attribute((alias("__xmlGenericError__internal_alias"))); #else #ifndef __xmlGenericError extern __typeof (__xmlGenericError) __xmlGenericError__internal_alias __attribute((visibility("hidden"))); #define __xmlGenericError __xmlGenericError__internal_alias #endif #endif #ifdef bottom_globals #undef __xmlGenericErrorContext extern __typeof (__xmlGenericErrorContext) __xmlGenericErrorContext __attribute((alias("__xmlGenericErrorContext__internal_alias"))); #else #ifndef __xmlGenericErrorContext extern __typeof (__xmlGenericErrorContext) __xmlGenericErrorContext__internal_alias __attribute((visibility("hidden"))); #define __xmlGenericErrorContext __xmlGenericErrorContext__internal_alias #endif #endif /* list generated from libxml2-api.xml */ #if defined(LIBXML_DOCB_ENABLED) #ifdef bottom_DOCBparser #undef docbCreatePushParserCtxt extern __typeof (docbCreatePushParserCtxt) docbCreatePushParserCtxt __attribute((alias("docbCreatePushParserCtxt__internal_alias"))); #else #ifndef docbCreatePushParserCtxt extern __typeof (docbCreatePushParserCtxt) docbCreatePushParserCtxt__internal_alias __attribute((visibility("hidden"))); #define docbCreatePushParserCtxt docbCreatePushParserCtxt__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) #ifdef bottom_HTMLparser #undef htmlAttrAllowed extern __typeof (htmlAttrAllowed) htmlAttrAllowed __attribute((alias("htmlAttrAllowed__internal_alias"))); #else #ifndef htmlAttrAllowed extern __typeof (htmlAttrAllowed) htmlAttrAllowed__internal_alias __attribute((visibility("hidden"))); #define htmlAttrAllowed htmlAttrAllowed__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) #ifdef bottom_HTMLparser #undef htmlAutoCloseTag extern __typeof (htmlAutoCloseTag) htmlAutoCloseTag __attribute((alias("htmlAutoCloseTag__internal_alias"))); #else #ifndef htmlAutoCloseTag extern __typeof (htmlAutoCloseTag) htmlAutoCloseTag__internal_alias __attribute((visibility("hidden"))); #define htmlAutoCloseTag htmlAutoCloseTag__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) #ifdef bottom_HTMLparser #undef htmlCreateFileParserCtxt extern __typeof (htmlCreateFileParserCtxt) htmlCreateFileParserCtxt __attribute((alias("htmlCreateFileParserCtxt__internal_alias"))); #else #ifndef htmlCreateFileParserCtxt extern __typeof (htmlCreateFileParserCtxt) htmlCreateFileParserCtxt__internal_alias __attribute((visibility("hidden"))); #define htmlCreateFileParserCtxt htmlCreateFileParserCtxt__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) #ifdef bottom_HTMLparser #undef htmlCreateMemoryParserCtxt extern __typeof (htmlCreateMemoryParserCtxt) htmlCreateMemoryParserCtxt __attribute((alias("htmlCreateMemoryParserCtxt__internal_alias"))); #else #ifndef htmlCreateMemoryParserCtxt extern __typeof (htmlCreateMemoryParserCtxt) htmlCreateMemoryParserCtxt__internal_alias __attribute((visibility("hidden"))); #define htmlCreateMemoryParserCtxt htmlCreateMemoryParserCtxt__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_PUSH_ENABLED) #ifdef bottom_HTMLparser #undef htmlCreatePushParserCtxt extern __typeof (htmlCreatePushParserCtxt) htmlCreatePushParserCtxt __attribute((alias("htmlCreatePushParserCtxt__internal_alias"))); #else #ifndef htmlCreatePushParserCtxt extern __typeof (htmlCreatePushParserCtxt) htmlCreatePushParserCtxt__internal_alias __attribute((visibility("hidden"))); #define htmlCreatePushParserCtxt htmlCreatePushParserCtxt__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) #ifdef bottom_HTMLparser #undef htmlCtxtReadDoc extern __typeof (htmlCtxtReadDoc) htmlCtxtReadDoc __attribute((alias("htmlCtxtReadDoc__internal_alias"))); #else #ifndef htmlCtxtReadDoc extern __typeof (htmlCtxtReadDoc) htmlCtxtReadDoc__internal_alias __attribute((visibility("hidden"))); #define htmlCtxtReadDoc htmlCtxtReadDoc__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) #ifdef bottom_HTMLparser #undef htmlCtxtReadFd extern __typeof (htmlCtxtReadFd) htmlCtxtReadFd __attribute((alias("htmlCtxtReadFd__internal_alias"))); #else #ifndef htmlCtxtReadFd extern __typeof (htmlCtxtReadFd) htmlCtxtReadFd__internal_alias __attribute((visibility("hidden"))); #define htmlCtxtReadFd htmlCtxtReadFd__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) #ifdef bottom_HTMLparser #undef htmlCtxtReadFile extern __typeof (htmlCtxtReadFile) htmlCtxtReadFile __attribute((alias("htmlCtxtReadFile__internal_alias"))); #else #ifndef htmlCtxtReadFile extern __typeof (htmlCtxtReadFile) htmlCtxtReadFile__internal_alias __attribute((visibility("hidden"))); #define htmlCtxtReadFile htmlCtxtReadFile__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) #ifdef bottom_HTMLparser #undef htmlCtxtReadIO extern __typeof (htmlCtxtReadIO) htmlCtxtReadIO __attribute((alias("htmlCtxtReadIO__internal_alias"))); #else #ifndef htmlCtxtReadIO extern __typeof (htmlCtxtReadIO) htmlCtxtReadIO__internal_alias __attribute((visibility("hidden"))); #define htmlCtxtReadIO htmlCtxtReadIO__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) #ifdef bottom_HTMLparser #undef htmlCtxtReadMemory extern __typeof (htmlCtxtReadMemory) htmlCtxtReadMemory __attribute((alias("htmlCtxtReadMemory__internal_alias"))); #else #ifndef htmlCtxtReadMemory extern __typeof (htmlCtxtReadMemory) htmlCtxtReadMemory__internal_alias __attribute((visibility("hidden"))); #define htmlCtxtReadMemory htmlCtxtReadMemory__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) #ifdef bottom_HTMLparser #undef htmlCtxtReset extern __typeof (htmlCtxtReset) htmlCtxtReset __attribute((alias("htmlCtxtReset__internal_alias"))); #else #ifndef htmlCtxtReset extern __typeof (htmlCtxtReset) htmlCtxtReset__internal_alias __attribute((visibility("hidden"))); #define htmlCtxtReset htmlCtxtReset__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) #ifdef bottom_HTMLparser #undef htmlCtxtUseOptions extern __typeof (htmlCtxtUseOptions) htmlCtxtUseOptions __attribute((alias("htmlCtxtUseOptions__internal_alias"))); #else #ifndef htmlCtxtUseOptions extern __typeof (htmlCtxtUseOptions) htmlCtxtUseOptions__internal_alias __attribute((visibility("hidden"))); #define htmlCtxtUseOptions htmlCtxtUseOptions__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) #ifdef bottom_SAX2 #undef htmlDefaultSAXHandlerInit extern __typeof (htmlDefaultSAXHandlerInit) htmlDefaultSAXHandlerInit __attribute((alias("htmlDefaultSAXHandlerInit__internal_alias"))); #else #ifndef htmlDefaultSAXHandlerInit extern __typeof (htmlDefaultSAXHandlerInit) htmlDefaultSAXHandlerInit__internal_alias __attribute((visibility("hidden"))); #define htmlDefaultSAXHandlerInit htmlDefaultSAXHandlerInit__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_HTMLtree #undef htmlDocContentDumpFormatOutput extern __typeof (htmlDocContentDumpFormatOutput) htmlDocContentDumpFormatOutput __attribute((alias("htmlDocContentDumpFormatOutput__internal_alias"))); #else #ifndef htmlDocContentDumpFormatOutput extern __typeof (htmlDocContentDumpFormatOutput) htmlDocContentDumpFormatOutput__internal_alias __attribute((visibility("hidden"))); #define htmlDocContentDumpFormatOutput htmlDocContentDumpFormatOutput__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_HTMLtree #undef htmlDocContentDumpOutput extern __typeof (htmlDocContentDumpOutput) htmlDocContentDumpOutput __attribute((alias("htmlDocContentDumpOutput__internal_alias"))); #else #ifndef htmlDocContentDumpOutput extern __typeof (htmlDocContentDumpOutput) htmlDocContentDumpOutput__internal_alias __attribute((visibility("hidden"))); #define htmlDocContentDumpOutput htmlDocContentDumpOutput__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_HTMLtree #undef htmlDocDump extern __typeof (htmlDocDump) htmlDocDump __attribute((alias("htmlDocDump__internal_alias"))); #else #ifndef htmlDocDump extern __typeof (htmlDocDump) htmlDocDump__internal_alias __attribute((visibility("hidden"))); #define htmlDocDump htmlDocDump__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_HTMLtree #undef htmlDocDumpMemory extern __typeof (htmlDocDumpMemory) htmlDocDumpMemory __attribute((alias("htmlDocDumpMemory__internal_alias"))); #else #ifndef htmlDocDumpMemory extern __typeof (htmlDocDumpMemory) htmlDocDumpMemory__internal_alias __attribute((visibility("hidden"))); #define htmlDocDumpMemory htmlDocDumpMemory__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_HTMLtree #undef htmlDocDumpMemoryFormat extern __typeof (htmlDocDumpMemoryFormat) htmlDocDumpMemoryFormat __attribute((alias("htmlDocDumpMemoryFormat__internal_alias"))); #else #ifndef htmlDocDumpMemoryFormat extern __typeof (htmlDocDumpMemoryFormat) htmlDocDumpMemoryFormat__internal_alias __attribute((visibility("hidden"))); #define htmlDocDumpMemoryFormat htmlDocDumpMemoryFormat__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) #ifdef bottom_HTMLparser #undef htmlElementAllowedHere extern __typeof (htmlElementAllowedHere) htmlElementAllowedHere __attribute((alias("htmlElementAllowedHere__internal_alias"))); #else #ifndef htmlElementAllowedHere extern __typeof (htmlElementAllowedHere) htmlElementAllowedHere__internal_alias __attribute((visibility("hidden"))); #define htmlElementAllowedHere htmlElementAllowedHere__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) #ifdef bottom_HTMLparser #undef htmlElementStatusHere extern __typeof (htmlElementStatusHere) htmlElementStatusHere __attribute((alias("htmlElementStatusHere__internal_alias"))); #else #ifndef htmlElementStatusHere extern __typeof (htmlElementStatusHere) htmlElementStatusHere__internal_alias __attribute((visibility("hidden"))); #define htmlElementStatusHere htmlElementStatusHere__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) #ifdef bottom_HTMLparser #undef htmlEncodeEntities extern __typeof (htmlEncodeEntities) htmlEncodeEntities __attribute((alias("htmlEncodeEntities__internal_alias"))); #else #ifndef htmlEncodeEntities extern __typeof (htmlEncodeEntities) htmlEncodeEntities__internal_alias __attribute((visibility("hidden"))); #define htmlEncodeEntities htmlEncodeEntities__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) #ifdef bottom_HTMLparser #undef htmlEntityLookup extern __typeof (htmlEntityLookup) htmlEntityLookup __attribute((alias("htmlEntityLookup__internal_alias"))); #else #ifndef htmlEntityLookup extern __typeof (htmlEntityLookup) htmlEntityLookup__internal_alias __attribute((visibility("hidden"))); #define htmlEntityLookup htmlEntityLookup__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) #ifdef bottom_HTMLparser #undef htmlEntityValueLookup extern __typeof (htmlEntityValueLookup) htmlEntityValueLookup __attribute((alias("htmlEntityValueLookup__internal_alias"))); #else #ifndef htmlEntityValueLookup extern __typeof (htmlEntityValueLookup) htmlEntityValueLookup__internal_alias __attribute((visibility("hidden"))); #define htmlEntityValueLookup htmlEntityValueLookup__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) #ifdef bottom_HTMLparser #undef htmlFreeParserCtxt extern __typeof (htmlFreeParserCtxt) htmlFreeParserCtxt __attribute((alias("htmlFreeParserCtxt__internal_alias"))); #else #ifndef htmlFreeParserCtxt extern __typeof (htmlFreeParserCtxt) htmlFreeParserCtxt__internal_alias __attribute((visibility("hidden"))); #define htmlFreeParserCtxt htmlFreeParserCtxt__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) #ifdef bottom_HTMLtree #undef htmlGetMetaEncoding extern __typeof (htmlGetMetaEncoding) htmlGetMetaEncoding __attribute((alias("htmlGetMetaEncoding__internal_alias"))); #else #ifndef htmlGetMetaEncoding extern __typeof (htmlGetMetaEncoding) htmlGetMetaEncoding__internal_alias __attribute((visibility("hidden"))); #define htmlGetMetaEncoding htmlGetMetaEncoding__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) #ifdef bottom_HTMLparser #undef htmlHandleOmittedElem extern __typeof (htmlHandleOmittedElem) htmlHandleOmittedElem __attribute((alias("htmlHandleOmittedElem__internal_alias"))); #else #ifndef htmlHandleOmittedElem extern __typeof (htmlHandleOmittedElem) htmlHandleOmittedElem__internal_alias __attribute((visibility("hidden"))); #define htmlHandleOmittedElem htmlHandleOmittedElem__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) #ifdef bottom_HTMLparser #undef htmlInitAutoClose extern __typeof (htmlInitAutoClose) htmlInitAutoClose __attribute((alias("htmlInitAutoClose__internal_alias"))); #else #ifndef htmlInitAutoClose extern __typeof (htmlInitAutoClose) htmlInitAutoClose__internal_alias __attribute((visibility("hidden"))); #define htmlInitAutoClose htmlInitAutoClose__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) #ifdef bottom_HTMLparser #undef htmlIsAutoClosed extern __typeof (htmlIsAutoClosed) htmlIsAutoClosed __attribute((alias("htmlIsAutoClosed__internal_alias"))); #else #ifndef htmlIsAutoClosed extern __typeof (htmlIsAutoClosed) htmlIsAutoClosed__internal_alias __attribute((visibility("hidden"))); #define htmlIsAutoClosed htmlIsAutoClosed__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) #ifdef bottom_HTMLtree #undef htmlIsBooleanAttr extern __typeof (htmlIsBooleanAttr) htmlIsBooleanAttr __attribute((alias("htmlIsBooleanAttr__internal_alias"))); #else #ifndef htmlIsBooleanAttr extern __typeof (htmlIsBooleanAttr) htmlIsBooleanAttr__internal_alias __attribute((visibility("hidden"))); #define htmlIsBooleanAttr htmlIsBooleanAttr__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) #ifdef bottom_HTMLparser #undef htmlIsScriptAttribute extern __typeof (htmlIsScriptAttribute) htmlIsScriptAttribute __attribute((alias("htmlIsScriptAttribute__internal_alias"))); #else #ifndef htmlIsScriptAttribute extern __typeof (htmlIsScriptAttribute) htmlIsScriptAttribute__internal_alias __attribute((visibility("hidden"))); #define htmlIsScriptAttribute htmlIsScriptAttribute__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) #ifdef bottom_HTMLparser #undef htmlNewDoc extern __typeof (htmlNewDoc) htmlNewDoc __attribute((alias("htmlNewDoc__internal_alias"))); #else #ifndef htmlNewDoc extern __typeof (htmlNewDoc) htmlNewDoc__internal_alias __attribute((visibility("hidden"))); #define htmlNewDoc htmlNewDoc__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) #ifdef bottom_HTMLparser #undef htmlNewDocNoDtD extern __typeof (htmlNewDocNoDtD) htmlNewDocNoDtD __attribute((alias("htmlNewDocNoDtD__internal_alias"))); #else #ifndef htmlNewDocNoDtD extern __typeof (htmlNewDocNoDtD) htmlNewDocNoDtD__internal_alias __attribute((visibility("hidden"))); #define htmlNewDocNoDtD htmlNewDocNoDtD__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_HTMLtree #undef htmlNodeDump extern __typeof (htmlNodeDump) htmlNodeDump __attribute((alias("htmlNodeDump__internal_alias"))); #else #ifndef htmlNodeDump extern __typeof (htmlNodeDump) htmlNodeDump__internal_alias __attribute((visibility("hidden"))); #define htmlNodeDump htmlNodeDump__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_HTMLtree #undef htmlNodeDumpFile extern __typeof (htmlNodeDumpFile) htmlNodeDumpFile __attribute((alias("htmlNodeDumpFile__internal_alias"))); #else #ifndef htmlNodeDumpFile extern __typeof (htmlNodeDumpFile) htmlNodeDumpFile__internal_alias __attribute((visibility("hidden"))); #define htmlNodeDumpFile htmlNodeDumpFile__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_HTMLtree #undef htmlNodeDumpFileFormat extern __typeof (htmlNodeDumpFileFormat) htmlNodeDumpFileFormat __attribute((alias("htmlNodeDumpFileFormat__internal_alias"))); #else #ifndef htmlNodeDumpFileFormat extern __typeof (htmlNodeDumpFileFormat) htmlNodeDumpFileFormat__internal_alias __attribute((visibility("hidden"))); #define htmlNodeDumpFileFormat htmlNodeDumpFileFormat__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_HTMLtree #undef htmlNodeDumpFormatOutput extern __typeof (htmlNodeDumpFormatOutput) htmlNodeDumpFormatOutput __attribute((alias("htmlNodeDumpFormatOutput__internal_alias"))); #else #ifndef htmlNodeDumpFormatOutput extern __typeof (htmlNodeDumpFormatOutput) htmlNodeDumpFormatOutput__internal_alias __attribute((visibility("hidden"))); #define htmlNodeDumpFormatOutput htmlNodeDumpFormatOutput__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_HTMLtree #undef htmlNodeDumpOutput extern __typeof (htmlNodeDumpOutput) htmlNodeDumpOutput __attribute((alias("htmlNodeDumpOutput__internal_alias"))); #else #ifndef htmlNodeDumpOutput extern __typeof (htmlNodeDumpOutput) htmlNodeDumpOutput__internal_alias __attribute((visibility("hidden"))); #define htmlNodeDumpOutput htmlNodeDumpOutput__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) #ifdef bottom_HTMLparser #undef htmlNodeStatus extern __typeof (htmlNodeStatus) htmlNodeStatus __attribute((alias("htmlNodeStatus__internal_alias"))); #else #ifndef htmlNodeStatus extern __typeof (htmlNodeStatus) htmlNodeStatus__internal_alias __attribute((visibility("hidden"))); #define htmlNodeStatus htmlNodeStatus__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) #ifdef bottom_HTMLparser #undef htmlParseCharRef extern __typeof (htmlParseCharRef) htmlParseCharRef __attribute((alias("htmlParseCharRef__internal_alias"))); #else #ifndef htmlParseCharRef extern __typeof (htmlParseCharRef) htmlParseCharRef__internal_alias __attribute((visibility("hidden"))); #define htmlParseCharRef htmlParseCharRef__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_PUSH_ENABLED) #ifdef bottom_HTMLparser #undef htmlParseChunk extern __typeof (htmlParseChunk) htmlParseChunk __attribute((alias("htmlParseChunk__internal_alias"))); #else #ifndef htmlParseChunk extern __typeof (htmlParseChunk) htmlParseChunk__internal_alias __attribute((visibility("hidden"))); #define htmlParseChunk htmlParseChunk__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) #ifdef bottom_HTMLparser #undef htmlParseDoc extern __typeof (htmlParseDoc) htmlParseDoc __attribute((alias("htmlParseDoc__internal_alias"))); #else #ifndef htmlParseDoc extern __typeof (htmlParseDoc) htmlParseDoc__internal_alias __attribute((visibility("hidden"))); #define htmlParseDoc htmlParseDoc__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) #ifdef bottom_HTMLparser #undef htmlParseDocument extern __typeof (htmlParseDocument) htmlParseDocument __attribute((alias("htmlParseDocument__internal_alias"))); #else #ifndef htmlParseDocument extern __typeof (htmlParseDocument) htmlParseDocument__internal_alias __attribute((visibility("hidden"))); #define htmlParseDocument htmlParseDocument__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) #ifdef bottom_HTMLparser #undef htmlParseElement extern __typeof (htmlParseElement) htmlParseElement __attribute((alias("htmlParseElement__internal_alias"))); #else #ifndef htmlParseElement extern __typeof (htmlParseElement) htmlParseElement__internal_alias __attribute((visibility("hidden"))); #define htmlParseElement htmlParseElement__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) #ifdef bottom_HTMLparser #undef htmlParseEntityRef extern __typeof (htmlParseEntityRef) htmlParseEntityRef __attribute((alias("htmlParseEntityRef__internal_alias"))); #else #ifndef htmlParseEntityRef extern __typeof (htmlParseEntityRef) htmlParseEntityRef__internal_alias __attribute((visibility("hidden"))); #define htmlParseEntityRef htmlParseEntityRef__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) #ifdef bottom_HTMLparser #undef htmlParseFile extern __typeof (htmlParseFile) htmlParseFile __attribute((alias("htmlParseFile__internal_alias"))); #else #ifndef htmlParseFile extern __typeof (htmlParseFile) htmlParseFile__internal_alias __attribute((visibility("hidden"))); #define htmlParseFile htmlParseFile__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) #ifdef bottom_HTMLparser #undef htmlReadDoc extern __typeof (htmlReadDoc) htmlReadDoc __attribute((alias("htmlReadDoc__internal_alias"))); #else #ifndef htmlReadDoc extern __typeof (htmlReadDoc) htmlReadDoc__internal_alias __attribute((visibility("hidden"))); #define htmlReadDoc htmlReadDoc__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) #ifdef bottom_HTMLparser #undef htmlReadFd extern __typeof (htmlReadFd) htmlReadFd __attribute((alias("htmlReadFd__internal_alias"))); #else #ifndef htmlReadFd extern __typeof (htmlReadFd) htmlReadFd__internal_alias __attribute((visibility("hidden"))); #define htmlReadFd htmlReadFd__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) #ifdef bottom_HTMLparser #undef htmlReadFile extern __typeof (htmlReadFile) htmlReadFile __attribute((alias("htmlReadFile__internal_alias"))); #else #ifndef htmlReadFile extern __typeof (htmlReadFile) htmlReadFile__internal_alias __attribute((visibility("hidden"))); #define htmlReadFile htmlReadFile__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) #ifdef bottom_HTMLparser #undef htmlReadIO extern __typeof (htmlReadIO) htmlReadIO __attribute((alias("htmlReadIO__internal_alias"))); #else #ifndef htmlReadIO extern __typeof (htmlReadIO) htmlReadIO__internal_alias __attribute((visibility("hidden"))); #define htmlReadIO htmlReadIO__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) #ifdef bottom_HTMLparser #undef htmlReadMemory extern __typeof (htmlReadMemory) htmlReadMemory __attribute((alias("htmlReadMemory__internal_alias"))); #else #ifndef htmlReadMemory extern __typeof (htmlReadMemory) htmlReadMemory__internal_alias __attribute((visibility("hidden"))); #define htmlReadMemory htmlReadMemory__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) #ifdef bottom_HTMLparser #undef htmlSAXParseDoc extern __typeof (htmlSAXParseDoc) htmlSAXParseDoc __attribute((alias("htmlSAXParseDoc__internal_alias"))); #else #ifndef htmlSAXParseDoc extern __typeof (htmlSAXParseDoc) htmlSAXParseDoc__internal_alias __attribute((visibility("hidden"))); #define htmlSAXParseDoc htmlSAXParseDoc__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) #ifdef bottom_HTMLparser #undef htmlSAXParseFile extern __typeof (htmlSAXParseFile) htmlSAXParseFile __attribute((alias("htmlSAXParseFile__internal_alias"))); #else #ifndef htmlSAXParseFile extern __typeof (htmlSAXParseFile) htmlSAXParseFile__internal_alias __attribute((visibility("hidden"))); #define htmlSAXParseFile htmlSAXParseFile__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_HTMLtree #undef htmlSaveFile extern __typeof (htmlSaveFile) htmlSaveFile __attribute((alias("htmlSaveFile__internal_alias"))); #else #ifndef htmlSaveFile extern __typeof (htmlSaveFile) htmlSaveFile__internal_alias __attribute((visibility("hidden"))); #define htmlSaveFile htmlSaveFile__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_HTMLtree #undef htmlSaveFileEnc extern __typeof (htmlSaveFileEnc) htmlSaveFileEnc __attribute((alias("htmlSaveFileEnc__internal_alias"))); #else #ifndef htmlSaveFileEnc extern __typeof (htmlSaveFileEnc) htmlSaveFileEnc__internal_alias __attribute((visibility("hidden"))); #define htmlSaveFileEnc htmlSaveFileEnc__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_HTMLtree #undef htmlSaveFileFormat extern __typeof (htmlSaveFileFormat) htmlSaveFileFormat __attribute((alias("htmlSaveFileFormat__internal_alias"))); #else #ifndef htmlSaveFileFormat extern __typeof (htmlSaveFileFormat) htmlSaveFileFormat__internal_alias __attribute((visibility("hidden"))); #define htmlSaveFileFormat htmlSaveFileFormat__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) #ifdef bottom_HTMLtree #undef htmlSetMetaEncoding extern __typeof (htmlSetMetaEncoding) htmlSetMetaEncoding __attribute((alias("htmlSetMetaEncoding__internal_alias"))); #else #ifndef htmlSetMetaEncoding extern __typeof (htmlSetMetaEncoding) htmlSetMetaEncoding__internal_alias __attribute((visibility("hidden"))); #define htmlSetMetaEncoding htmlSetMetaEncoding__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) #ifdef bottom_HTMLparser #undef htmlTagLookup extern __typeof (htmlTagLookup) htmlTagLookup __attribute((alias("htmlTagLookup__internal_alias"))); #else #ifndef htmlTagLookup extern __typeof (htmlTagLookup) htmlTagLookup__internal_alias __attribute((visibility("hidden"))); #define htmlTagLookup htmlTagLookup__internal_alias #endif #endif #endif #ifdef bottom_parser #undef inputPop extern __typeof (inputPop) inputPop __attribute((alias("inputPop__internal_alias"))); #else #ifndef inputPop extern __typeof (inputPop) inputPop__internal_alias __attribute((visibility("hidden"))); #define inputPop inputPop__internal_alias #endif #endif #ifdef bottom_parser #undef inputPush extern __typeof (inputPush) inputPush __attribute((alias("inputPush__internal_alias"))); #else #ifndef inputPush extern __typeof (inputPush) inputPush__internal_alias __attribute((visibility("hidden"))); #define inputPush inputPush__internal_alias #endif #endif #ifdef bottom_parser #undef namePop extern __typeof (namePop) namePop __attribute((alias("namePop__internal_alias"))); #else #ifndef namePop extern __typeof (namePop) namePop__internal_alias __attribute((visibility("hidden"))); #define namePop namePop__internal_alias #endif #endif #ifdef bottom_parser #undef namePush extern __typeof (namePush) namePush __attribute((alias("namePush__internal_alias"))); #else #ifndef namePush extern __typeof (namePush) namePush__internal_alias __attribute((visibility("hidden"))); #define namePush namePush__internal_alias #endif #endif #ifdef bottom_parser #undef nodePop extern __typeof (nodePop) nodePop __attribute((alias("nodePop__internal_alias"))); #else #ifndef nodePop extern __typeof (nodePop) nodePop__internal_alias __attribute((visibility("hidden"))); #define nodePop nodePop__internal_alias #endif #endif #ifdef bottom_parser #undef nodePush extern __typeof (nodePush) nodePush __attribute((alias("nodePush__internal_alias"))); #else #ifndef nodePush extern __typeof (nodePush) nodePush__internal_alias __attribute((visibility("hidden"))); #define nodePush nodePush__internal_alias #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef valuePop extern __typeof (valuePop) valuePop __attribute((alias("valuePop__internal_alias"))); #else #ifndef valuePop extern __typeof (valuePop) valuePop__internal_alias __attribute((visibility("hidden"))); #define valuePop valuePop__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef valuePush extern __typeof (valuePush) valuePush __attribute((alias("valuePush__internal_alias"))); #else #ifndef valuePush extern __typeof (valuePush) valuePush__internal_alias __attribute((visibility("hidden"))); #define valuePush valuePush__internal_alias #endif #endif #endif #if defined(LIBXML_CATALOG_ENABLED) #ifdef bottom_catalog #undef xmlACatalogAdd extern __typeof (xmlACatalogAdd) xmlACatalogAdd __attribute((alias("xmlACatalogAdd__internal_alias"))); #else #ifndef xmlACatalogAdd extern __typeof (xmlACatalogAdd) xmlACatalogAdd__internal_alias __attribute((visibility("hidden"))); #define xmlACatalogAdd xmlACatalogAdd__internal_alias #endif #endif #endif #if defined(LIBXML_CATALOG_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_catalog #undef xmlACatalogDump extern __typeof (xmlACatalogDump) xmlACatalogDump __attribute((alias("xmlACatalogDump__internal_alias"))); #else #ifndef xmlACatalogDump extern __typeof (xmlACatalogDump) xmlACatalogDump__internal_alias __attribute((visibility("hidden"))); #define xmlACatalogDump xmlACatalogDump__internal_alias #endif #endif #endif #if defined(LIBXML_CATALOG_ENABLED) #ifdef bottom_catalog #undef xmlACatalogRemove extern __typeof (xmlACatalogRemove) xmlACatalogRemove __attribute((alias("xmlACatalogRemove__internal_alias"))); #else #ifndef xmlACatalogRemove extern __typeof (xmlACatalogRemove) xmlACatalogRemove__internal_alias __attribute((visibility("hidden"))); #define xmlACatalogRemove xmlACatalogRemove__internal_alias #endif #endif #endif #if defined(LIBXML_CATALOG_ENABLED) #ifdef bottom_catalog #undef xmlACatalogResolve extern __typeof (xmlACatalogResolve) xmlACatalogResolve __attribute((alias("xmlACatalogResolve__internal_alias"))); #else #ifndef xmlACatalogResolve extern __typeof (xmlACatalogResolve) xmlACatalogResolve__internal_alias __attribute((visibility("hidden"))); #define xmlACatalogResolve xmlACatalogResolve__internal_alias #endif #endif #endif #if defined(LIBXML_CATALOG_ENABLED) #ifdef bottom_catalog #undef xmlACatalogResolvePublic extern __typeof (xmlACatalogResolvePublic) xmlACatalogResolvePublic __attribute((alias("xmlACatalogResolvePublic__internal_alias"))); #else #ifndef xmlACatalogResolvePublic extern __typeof (xmlACatalogResolvePublic) xmlACatalogResolvePublic__internal_alias __attribute((visibility("hidden"))); #define xmlACatalogResolvePublic xmlACatalogResolvePublic__internal_alias #endif #endif #endif #if defined(LIBXML_CATALOG_ENABLED) #ifdef bottom_catalog #undef xmlACatalogResolveSystem extern __typeof (xmlACatalogResolveSystem) xmlACatalogResolveSystem __attribute((alias("xmlACatalogResolveSystem__internal_alias"))); #else #ifndef xmlACatalogResolveSystem extern __typeof (xmlACatalogResolveSystem) xmlACatalogResolveSystem__internal_alias __attribute((visibility("hidden"))); #define xmlACatalogResolveSystem xmlACatalogResolveSystem__internal_alias #endif #endif #endif #if defined(LIBXML_CATALOG_ENABLED) #ifdef bottom_catalog #undef xmlACatalogResolveURI extern __typeof (xmlACatalogResolveURI) xmlACatalogResolveURI __attribute((alias("xmlACatalogResolveURI__internal_alias"))); #else #ifndef xmlACatalogResolveURI extern __typeof (xmlACatalogResolveURI) xmlACatalogResolveURI__internal_alias __attribute((visibility("hidden"))); #define xmlACatalogResolveURI xmlACatalogResolveURI__internal_alias #endif #endif #endif #ifdef bottom_valid #undef xmlAddAttributeDecl extern __typeof (xmlAddAttributeDecl) xmlAddAttributeDecl __attribute((alias("xmlAddAttributeDecl__internal_alias"))); #else #ifndef xmlAddAttributeDecl extern __typeof (xmlAddAttributeDecl) xmlAddAttributeDecl__internal_alias __attribute((visibility("hidden"))); #define xmlAddAttributeDecl xmlAddAttributeDecl__internal_alias #endif #endif #ifdef bottom_tree #undef xmlAddChild extern __typeof (xmlAddChild) xmlAddChild __attribute((alias("xmlAddChild__internal_alias"))); #else #ifndef xmlAddChild extern __typeof (xmlAddChild) xmlAddChild__internal_alias __attribute((visibility("hidden"))); #define xmlAddChild xmlAddChild__internal_alias #endif #endif #ifdef bottom_tree #undef xmlAddChildList extern __typeof (xmlAddChildList) xmlAddChildList __attribute((alias("xmlAddChildList__internal_alias"))); #else #ifndef xmlAddChildList extern __typeof (xmlAddChildList) xmlAddChildList__internal_alias __attribute((visibility("hidden"))); #define xmlAddChildList xmlAddChildList__internal_alias #endif #endif #ifdef bottom_entities #undef xmlAddDocEntity extern __typeof (xmlAddDocEntity) xmlAddDocEntity __attribute((alias("xmlAddDocEntity__internal_alias"))); #else #ifndef xmlAddDocEntity extern __typeof (xmlAddDocEntity) xmlAddDocEntity__internal_alias __attribute((visibility("hidden"))); #define xmlAddDocEntity xmlAddDocEntity__internal_alias #endif #endif #ifdef bottom_entities #undef xmlAddDtdEntity extern __typeof (xmlAddDtdEntity) xmlAddDtdEntity __attribute((alias("xmlAddDtdEntity__internal_alias"))); #else #ifndef xmlAddDtdEntity extern __typeof (xmlAddDtdEntity) xmlAddDtdEntity__internal_alias __attribute((visibility("hidden"))); #define xmlAddDtdEntity xmlAddDtdEntity__internal_alias #endif #endif #ifdef bottom_valid #undef xmlAddElementDecl extern __typeof (xmlAddElementDecl) xmlAddElementDecl __attribute((alias("xmlAddElementDecl__internal_alias"))); #else #ifndef xmlAddElementDecl extern __typeof (xmlAddElementDecl) xmlAddElementDecl__internal_alias __attribute((visibility("hidden"))); #define xmlAddElementDecl xmlAddElementDecl__internal_alias #endif #endif #ifdef bottom_encoding #undef xmlAddEncodingAlias extern __typeof (xmlAddEncodingAlias) xmlAddEncodingAlias __attribute((alias("xmlAddEncodingAlias__internal_alias"))); #else #ifndef xmlAddEncodingAlias extern __typeof (xmlAddEncodingAlias) xmlAddEncodingAlias__internal_alias __attribute((visibility("hidden"))); #define xmlAddEncodingAlias xmlAddEncodingAlias__internal_alias #endif #endif #ifdef bottom_valid #undef xmlAddID extern __typeof (xmlAddID) xmlAddID __attribute((alias("xmlAddID__internal_alias"))); #else #ifndef xmlAddID extern __typeof (xmlAddID) xmlAddID__internal_alias __attribute((visibility("hidden"))); #define xmlAddID xmlAddID__internal_alias #endif #endif #ifdef bottom_tree #undef xmlAddNextSibling extern __typeof (xmlAddNextSibling) xmlAddNextSibling __attribute((alias("xmlAddNextSibling__internal_alias"))); #else #ifndef xmlAddNextSibling extern __typeof (xmlAddNextSibling) xmlAddNextSibling__internal_alias __attribute((visibility("hidden"))); #define xmlAddNextSibling xmlAddNextSibling__internal_alias #endif #endif #ifdef bottom_valid #undef xmlAddNotationDecl extern __typeof (xmlAddNotationDecl) xmlAddNotationDecl __attribute((alias("xmlAddNotationDecl__internal_alias"))); #else #ifndef xmlAddNotationDecl extern __typeof (xmlAddNotationDecl) xmlAddNotationDecl__internal_alias __attribute((visibility("hidden"))); #define xmlAddNotationDecl xmlAddNotationDecl__internal_alias #endif #endif #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_tree #undef xmlAddPrevSibling extern __typeof (xmlAddPrevSibling) xmlAddPrevSibling __attribute((alias("xmlAddPrevSibling__internal_alias"))); #else #ifndef xmlAddPrevSibling extern __typeof (xmlAddPrevSibling) xmlAddPrevSibling__internal_alias __attribute((visibility("hidden"))); #define xmlAddPrevSibling xmlAddPrevSibling__internal_alias #endif #endif #endif #ifdef bottom_valid #undef xmlAddRef extern __typeof (xmlAddRef) xmlAddRef __attribute((alias("xmlAddRef__internal_alias"))); #else #ifndef xmlAddRef extern __typeof (xmlAddRef) xmlAddRef__internal_alias __attribute((visibility("hidden"))); #define xmlAddRef xmlAddRef__internal_alias #endif #endif #ifdef bottom_tree #undef xmlAddSibling extern __typeof (xmlAddSibling) xmlAddSibling __attribute((alias("xmlAddSibling__internal_alias"))); #else #ifndef xmlAddSibling extern __typeof (xmlAddSibling) xmlAddSibling__internal_alias __attribute((visibility("hidden"))); #define xmlAddSibling xmlAddSibling__internal_alias #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_xmlIO #undef xmlAllocOutputBuffer extern __typeof (xmlAllocOutputBuffer) xmlAllocOutputBuffer __attribute((alias("xmlAllocOutputBuffer__internal_alias"))); #else #ifndef xmlAllocOutputBuffer extern __typeof (xmlAllocOutputBuffer) xmlAllocOutputBuffer__internal_alias __attribute((visibility("hidden"))); #define xmlAllocOutputBuffer xmlAllocOutputBuffer__internal_alias #endif #endif #endif #ifdef bottom_xmlIO #undef xmlAllocParserInputBuffer extern __typeof (xmlAllocParserInputBuffer) xmlAllocParserInputBuffer __attribute((alias("xmlAllocParserInputBuffer__internal_alias"))); #else #ifndef xmlAllocParserInputBuffer extern __typeof (xmlAllocParserInputBuffer) xmlAllocParserInputBuffer__internal_alias __attribute((visibility("hidden"))); #define xmlAllocParserInputBuffer xmlAllocParserInputBuffer__internal_alias #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_xmlsave #undef xmlAttrSerializeTxtContent extern __typeof (xmlAttrSerializeTxtContent) xmlAttrSerializeTxtContent __attribute((alias("xmlAttrSerializeTxtContent__internal_alias"))); #else #ifndef xmlAttrSerializeTxtContent extern __typeof (xmlAttrSerializeTxtContent) xmlAttrSerializeTxtContent__internal_alias __attribute((visibility("hidden"))); #define xmlAttrSerializeTxtContent xmlAttrSerializeTxtContent__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED) #ifdef bottom_xmlregexp #undef xmlAutomataCompile extern __typeof (xmlAutomataCompile) xmlAutomataCompile __attribute((alias("xmlAutomataCompile__internal_alias"))); #else #ifndef xmlAutomataCompile extern __typeof (xmlAutomataCompile) xmlAutomataCompile__internal_alias __attribute((visibility("hidden"))); #define xmlAutomataCompile xmlAutomataCompile__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED) #ifdef bottom_xmlregexp #undef xmlAutomataGetInitState extern __typeof (xmlAutomataGetInitState) xmlAutomataGetInitState __attribute((alias("xmlAutomataGetInitState__internal_alias"))); #else #ifndef xmlAutomataGetInitState extern __typeof (xmlAutomataGetInitState) xmlAutomataGetInitState__internal_alias __attribute((visibility("hidden"))); #define xmlAutomataGetInitState xmlAutomataGetInitState__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED) #ifdef bottom_xmlregexp #undef xmlAutomataIsDeterminist extern __typeof (xmlAutomataIsDeterminist) xmlAutomataIsDeterminist __attribute((alias("xmlAutomataIsDeterminist__internal_alias"))); #else #ifndef xmlAutomataIsDeterminist extern __typeof (xmlAutomataIsDeterminist) xmlAutomataIsDeterminist__internal_alias __attribute((visibility("hidden"))); #define xmlAutomataIsDeterminist xmlAutomataIsDeterminist__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED) #ifdef bottom_xmlregexp #undef xmlAutomataNewAllTrans extern __typeof (xmlAutomataNewAllTrans) xmlAutomataNewAllTrans __attribute((alias("xmlAutomataNewAllTrans__internal_alias"))); #else #ifndef xmlAutomataNewAllTrans extern __typeof (xmlAutomataNewAllTrans) xmlAutomataNewAllTrans__internal_alias __attribute((visibility("hidden"))); #define xmlAutomataNewAllTrans xmlAutomataNewAllTrans__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED) #ifdef bottom_xmlregexp #undef xmlAutomataNewCountTrans extern __typeof (xmlAutomataNewCountTrans) xmlAutomataNewCountTrans __attribute((alias("xmlAutomataNewCountTrans__internal_alias"))); #else #ifndef xmlAutomataNewCountTrans extern __typeof (xmlAutomataNewCountTrans) xmlAutomataNewCountTrans__internal_alias __attribute((visibility("hidden"))); #define xmlAutomataNewCountTrans xmlAutomataNewCountTrans__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED) #ifdef bottom_xmlregexp #undef xmlAutomataNewCountTrans2 extern __typeof (xmlAutomataNewCountTrans2) xmlAutomataNewCountTrans2 __attribute((alias("xmlAutomataNewCountTrans2__internal_alias"))); #else #ifndef xmlAutomataNewCountTrans2 extern __typeof (xmlAutomataNewCountTrans2) xmlAutomataNewCountTrans2__internal_alias __attribute((visibility("hidden"))); #define xmlAutomataNewCountTrans2 xmlAutomataNewCountTrans2__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED) #ifdef bottom_xmlregexp #undef xmlAutomataNewCountedTrans extern __typeof (xmlAutomataNewCountedTrans) xmlAutomataNewCountedTrans __attribute((alias("xmlAutomataNewCountedTrans__internal_alias"))); #else #ifndef xmlAutomataNewCountedTrans extern __typeof (xmlAutomataNewCountedTrans) xmlAutomataNewCountedTrans__internal_alias __attribute((visibility("hidden"))); #define xmlAutomataNewCountedTrans xmlAutomataNewCountedTrans__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED) #ifdef bottom_xmlregexp #undef xmlAutomataNewCounter extern __typeof (xmlAutomataNewCounter) xmlAutomataNewCounter __attribute((alias("xmlAutomataNewCounter__internal_alias"))); #else #ifndef xmlAutomataNewCounter extern __typeof (xmlAutomataNewCounter) xmlAutomataNewCounter__internal_alias __attribute((visibility("hidden"))); #define xmlAutomataNewCounter xmlAutomataNewCounter__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED) #ifdef bottom_xmlregexp #undef xmlAutomataNewCounterTrans extern __typeof (xmlAutomataNewCounterTrans) xmlAutomataNewCounterTrans __attribute((alias("xmlAutomataNewCounterTrans__internal_alias"))); #else #ifndef xmlAutomataNewCounterTrans extern __typeof (xmlAutomataNewCounterTrans) xmlAutomataNewCounterTrans__internal_alias __attribute((visibility("hidden"))); #define xmlAutomataNewCounterTrans xmlAutomataNewCounterTrans__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED) #ifdef bottom_xmlregexp #undef xmlAutomataNewEpsilon extern __typeof (xmlAutomataNewEpsilon) xmlAutomataNewEpsilon __attribute((alias("xmlAutomataNewEpsilon__internal_alias"))); #else #ifndef xmlAutomataNewEpsilon extern __typeof (xmlAutomataNewEpsilon) xmlAutomataNewEpsilon__internal_alias __attribute((visibility("hidden"))); #define xmlAutomataNewEpsilon xmlAutomataNewEpsilon__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED) #ifdef bottom_xmlregexp #undef xmlAutomataNewNegTrans extern __typeof (xmlAutomataNewNegTrans) xmlAutomataNewNegTrans __attribute((alias("xmlAutomataNewNegTrans__internal_alias"))); #else #ifndef xmlAutomataNewNegTrans extern __typeof (xmlAutomataNewNegTrans) xmlAutomataNewNegTrans__internal_alias __attribute((visibility("hidden"))); #define xmlAutomataNewNegTrans xmlAutomataNewNegTrans__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED) #ifdef bottom_xmlregexp #undef xmlAutomataNewOnceTrans extern __typeof (xmlAutomataNewOnceTrans) xmlAutomataNewOnceTrans __attribute((alias("xmlAutomataNewOnceTrans__internal_alias"))); #else #ifndef xmlAutomataNewOnceTrans extern __typeof (xmlAutomataNewOnceTrans) xmlAutomataNewOnceTrans__internal_alias __attribute((visibility("hidden"))); #define xmlAutomataNewOnceTrans xmlAutomataNewOnceTrans__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED) #ifdef bottom_xmlregexp #undef xmlAutomataNewOnceTrans2 extern __typeof (xmlAutomataNewOnceTrans2) xmlAutomataNewOnceTrans2 __attribute((alias("xmlAutomataNewOnceTrans2__internal_alias"))); #else #ifndef xmlAutomataNewOnceTrans2 extern __typeof (xmlAutomataNewOnceTrans2) xmlAutomataNewOnceTrans2__internal_alias __attribute((visibility("hidden"))); #define xmlAutomataNewOnceTrans2 xmlAutomataNewOnceTrans2__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED) #ifdef bottom_xmlregexp #undef xmlAutomataNewState extern __typeof (xmlAutomataNewState) xmlAutomataNewState __attribute((alias("xmlAutomataNewState__internal_alias"))); #else #ifndef xmlAutomataNewState extern __typeof (xmlAutomataNewState) xmlAutomataNewState__internal_alias __attribute((visibility("hidden"))); #define xmlAutomataNewState xmlAutomataNewState__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED) #ifdef bottom_xmlregexp #undef xmlAutomataNewTransition extern __typeof (xmlAutomataNewTransition) xmlAutomataNewTransition __attribute((alias("xmlAutomataNewTransition__internal_alias"))); #else #ifndef xmlAutomataNewTransition extern __typeof (xmlAutomataNewTransition) xmlAutomataNewTransition__internal_alias __attribute((visibility("hidden"))); #define xmlAutomataNewTransition xmlAutomataNewTransition__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED) #ifdef bottom_xmlregexp #undef xmlAutomataNewTransition2 extern __typeof (xmlAutomataNewTransition2) xmlAutomataNewTransition2 __attribute((alias("xmlAutomataNewTransition2__internal_alias"))); #else #ifndef xmlAutomataNewTransition2 extern __typeof (xmlAutomataNewTransition2) xmlAutomataNewTransition2__internal_alias __attribute((visibility("hidden"))); #define xmlAutomataNewTransition2 xmlAutomataNewTransition2__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED) #ifdef bottom_xmlregexp #undef xmlAutomataSetFinalState extern __typeof (xmlAutomataSetFinalState) xmlAutomataSetFinalState __attribute((alias("xmlAutomataSetFinalState__internal_alias"))); #else #ifndef xmlAutomataSetFinalState extern __typeof (xmlAutomataSetFinalState) xmlAutomataSetFinalState__internal_alias __attribute((visibility("hidden"))); #define xmlAutomataSetFinalState xmlAutomataSetFinalState__internal_alias #endif #endif #endif #if defined(LIBXML_DEBUG_ENABLED) #ifdef bottom_debugXML #undef xmlBoolToText extern __typeof (xmlBoolToText) xmlBoolToText __attribute((alias("xmlBoolToText__internal_alias"))); #else #ifndef xmlBoolToText extern __typeof (xmlBoolToText) xmlBoolToText__internal_alias __attribute((visibility("hidden"))); #define xmlBoolToText xmlBoolToText__internal_alias #endif #endif #endif #ifdef bottom_tree #undef xmlBufferAdd extern __typeof (xmlBufferAdd) xmlBufferAdd __attribute((alias("xmlBufferAdd__internal_alias"))); #else #ifndef xmlBufferAdd extern __typeof (xmlBufferAdd) xmlBufferAdd__internal_alias __attribute((visibility("hidden"))); #define xmlBufferAdd xmlBufferAdd__internal_alias #endif #endif #ifdef bottom_tree #undef xmlBufferAddHead extern __typeof (xmlBufferAddHead) xmlBufferAddHead __attribute((alias("xmlBufferAddHead__internal_alias"))); #else #ifndef xmlBufferAddHead extern __typeof (xmlBufferAddHead) xmlBufferAddHead__internal_alias __attribute((visibility("hidden"))); #define xmlBufferAddHead xmlBufferAddHead__internal_alias #endif #endif #ifdef bottom_tree #undef xmlBufferCCat extern __typeof (xmlBufferCCat) xmlBufferCCat __attribute((alias("xmlBufferCCat__internal_alias"))); #else #ifndef xmlBufferCCat extern __typeof (xmlBufferCCat) xmlBufferCCat__internal_alias __attribute((visibility("hidden"))); #define xmlBufferCCat xmlBufferCCat__internal_alias #endif #endif #ifdef bottom_tree #undef xmlBufferCat extern __typeof (xmlBufferCat) xmlBufferCat __attribute((alias("xmlBufferCat__internal_alias"))); #else #ifndef xmlBufferCat extern __typeof (xmlBufferCat) xmlBufferCat__internal_alias __attribute((visibility("hidden"))); #define xmlBufferCat xmlBufferCat__internal_alias #endif #endif #ifdef bottom_tree #undef xmlBufferContent extern __typeof (xmlBufferContent) xmlBufferContent __attribute((alias("xmlBufferContent__internal_alias"))); #else #ifndef xmlBufferContent extern __typeof (xmlBufferContent) xmlBufferContent__internal_alias __attribute((visibility("hidden"))); #define xmlBufferContent xmlBufferContent__internal_alias #endif #endif #ifdef bottom_tree #undef xmlBufferCreate extern __typeof (xmlBufferCreate) xmlBufferCreate __attribute((alias("xmlBufferCreate__internal_alias"))); #else #ifndef xmlBufferCreate extern __typeof (xmlBufferCreate) xmlBufferCreate__internal_alias __attribute((visibility("hidden"))); #define xmlBufferCreate xmlBufferCreate__internal_alias #endif #endif #ifdef bottom_tree #undef xmlBufferCreateSize extern __typeof (xmlBufferCreateSize) xmlBufferCreateSize __attribute((alias("xmlBufferCreateSize__internal_alias"))); #else #ifndef xmlBufferCreateSize extern __typeof (xmlBufferCreateSize) xmlBufferCreateSize__internal_alias __attribute((visibility("hidden"))); #define xmlBufferCreateSize xmlBufferCreateSize__internal_alias #endif #endif #ifdef bottom_tree #undef xmlBufferCreateStatic extern __typeof (xmlBufferCreateStatic) xmlBufferCreateStatic __attribute((alias("xmlBufferCreateStatic__internal_alias"))); #else #ifndef xmlBufferCreateStatic extern __typeof (xmlBufferCreateStatic) xmlBufferCreateStatic__internal_alias __attribute((visibility("hidden"))); #define xmlBufferCreateStatic xmlBufferCreateStatic__internal_alias #endif #endif #ifdef bottom_tree #undef xmlBufferDump extern __typeof (xmlBufferDump) xmlBufferDump __attribute((alias("xmlBufferDump__internal_alias"))); #else #ifndef xmlBufferDump extern __typeof (xmlBufferDump) xmlBufferDump__internal_alias __attribute((visibility("hidden"))); #define xmlBufferDump xmlBufferDump__internal_alias #endif #endif #ifdef bottom_tree #undef xmlBufferEmpty extern __typeof (xmlBufferEmpty) xmlBufferEmpty __attribute((alias("xmlBufferEmpty__internal_alias"))); #else #ifndef xmlBufferEmpty extern __typeof (xmlBufferEmpty) xmlBufferEmpty__internal_alias __attribute((visibility("hidden"))); #define xmlBufferEmpty xmlBufferEmpty__internal_alias #endif #endif #ifdef bottom_tree #undef xmlBufferFree extern __typeof (xmlBufferFree) xmlBufferFree __attribute((alias("xmlBufferFree__internal_alias"))); #else #ifndef xmlBufferFree extern __typeof (xmlBufferFree) xmlBufferFree__internal_alias __attribute((visibility("hidden"))); #define xmlBufferFree xmlBufferFree__internal_alias #endif #endif #ifdef bottom_tree #undef xmlBufferGrow extern __typeof (xmlBufferGrow) xmlBufferGrow __attribute((alias("xmlBufferGrow__internal_alias"))); #else #ifndef xmlBufferGrow extern __typeof (xmlBufferGrow) xmlBufferGrow__internal_alias __attribute((visibility("hidden"))); #define xmlBufferGrow xmlBufferGrow__internal_alias #endif #endif #ifdef bottom_tree #undef xmlBufferLength extern __typeof (xmlBufferLength) xmlBufferLength __attribute((alias("xmlBufferLength__internal_alias"))); #else #ifndef xmlBufferLength extern __typeof (xmlBufferLength) xmlBufferLength__internal_alias __attribute((visibility("hidden"))); #define xmlBufferLength xmlBufferLength__internal_alias #endif #endif #ifdef bottom_tree #undef xmlBufferResize extern __typeof (xmlBufferResize) xmlBufferResize __attribute((alias("xmlBufferResize__internal_alias"))); #else #ifndef xmlBufferResize extern __typeof (xmlBufferResize) xmlBufferResize__internal_alias __attribute((visibility("hidden"))); #define xmlBufferResize xmlBufferResize__internal_alias #endif #endif #ifdef bottom_tree #undef xmlBufferSetAllocationScheme extern __typeof (xmlBufferSetAllocationScheme) xmlBufferSetAllocationScheme __attribute((alias("xmlBufferSetAllocationScheme__internal_alias"))); #else #ifndef xmlBufferSetAllocationScheme extern __typeof (xmlBufferSetAllocationScheme) xmlBufferSetAllocationScheme__internal_alias __attribute((visibility("hidden"))); #define xmlBufferSetAllocationScheme xmlBufferSetAllocationScheme__internal_alias #endif #endif #ifdef bottom_tree #undef xmlBufferShrink extern __typeof (xmlBufferShrink) xmlBufferShrink __attribute((alias("xmlBufferShrink__internal_alias"))); #else #ifndef xmlBufferShrink extern __typeof (xmlBufferShrink) xmlBufferShrink__internal_alias __attribute((visibility("hidden"))); #define xmlBufferShrink xmlBufferShrink__internal_alias #endif #endif #ifdef bottom_tree #undef xmlBufferWriteCHAR extern __typeof (xmlBufferWriteCHAR) xmlBufferWriteCHAR __attribute((alias("xmlBufferWriteCHAR__internal_alias"))); #else #ifndef xmlBufferWriteCHAR extern __typeof (xmlBufferWriteCHAR) xmlBufferWriteCHAR__internal_alias __attribute((visibility("hidden"))); #define xmlBufferWriteCHAR xmlBufferWriteCHAR__internal_alias #endif #endif #ifdef bottom_tree #undef xmlBufferWriteChar extern __typeof (xmlBufferWriteChar) xmlBufferWriteChar __attribute((alias("xmlBufferWriteChar__internal_alias"))); #else #ifndef xmlBufferWriteChar extern __typeof (xmlBufferWriteChar) xmlBufferWriteChar__internal_alias __attribute((visibility("hidden"))); #define xmlBufferWriteChar xmlBufferWriteChar__internal_alias #endif #endif #ifdef bottom_tree #undef xmlBufferWriteQuotedString extern __typeof (xmlBufferWriteQuotedString) xmlBufferWriteQuotedString __attribute((alias("xmlBufferWriteQuotedString__internal_alias"))); #else #ifndef xmlBufferWriteQuotedString extern __typeof (xmlBufferWriteQuotedString) xmlBufferWriteQuotedString__internal_alias __attribute((visibility("hidden"))); #define xmlBufferWriteQuotedString xmlBufferWriteQuotedString__internal_alias #endif #endif #ifdef bottom_tree #undef xmlBuildQName extern __typeof (xmlBuildQName) xmlBuildQName __attribute((alias("xmlBuildQName__internal_alias"))); #else #ifndef xmlBuildQName extern __typeof (xmlBuildQName) xmlBuildQName__internal_alias __attribute((visibility("hidden"))); #define xmlBuildQName xmlBuildQName__internal_alias #endif #endif #ifdef bottom_uri #undef xmlBuildRelativeURI extern __typeof (xmlBuildRelativeURI) xmlBuildRelativeURI __attribute((alias("xmlBuildRelativeURI__internal_alias"))); #else #ifndef xmlBuildRelativeURI extern __typeof (xmlBuildRelativeURI) xmlBuildRelativeURI__internal_alias __attribute((visibility("hidden"))); #define xmlBuildRelativeURI xmlBuildRelativeURI__internal_alias #endif #endif #ifdef bottom_uri #undef xmlBuildURI extern __typeof (xmlBuildURI) xmlBuildURI __attribute((alias("xmlBuildURI__internal_alias"))); #else #ifndef xmlBuildURI extern __typeof (xmlBuildURI) xmlBuildURI__internal_alias __attribute((visibility("hidden"))); #define xmlBuildURI xmlBuildURI__internal_alias #endif #endif #ifdef bottom_encoding #undef xmlByteConsumed extern __typeof (xmlByteConsumed) xmlByteConsumed __attribute((alias("xmlByteConsumed__internal_alias"))); #else #ifndef xmlByteConsumed extern __typeof (xmlByteConsumed) xmlByteConsumed__internal_alias __attribute((visibility("hidden"))); #define xmlByteConsumed xmlByteConsumed__internal_alias #endif #endif #if defined(LIBXML_C14N_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_c14n #undef xmlC14NDocDumpMemory extern __typeof (xmlC14NDocDumpMemory) xmlC14NDocDumpMemory __attribute((alias("xmlC14NDocDumpMemory__internal_alias"))); #else #ifndef xmlC14NDocDumpMemory extern __typeof (xmlC14NDocDumpMemory) xmlC14NDocDumpMemory__internal_alias __attribute((visibility("hidden"))); #define xmlC14NDocDumpMemory xmlC14NDocDumpMemory__internal_alias #endif #endif #endif #if defined(LIBXML_C14N_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_c14n #undef xmlC14NDocSave extern __typeof (xmlC14NDocSave) xmlC14NDocSave __attribute((alias("xmlC14NDocSave__internal_alias"))); #else #ifndef xmlC14NDocSave extern __typeof (xmlC14NDocSave) xmlC14NDocSave__internal_alias __attribute((visibility("hidden"))); #define xmlC14NDocSave xmlC14NDocSave__internal_alias #endif #endif #endif #if defined(LIBXML_C14N_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_c14n #undef xmlC14NDocSaveTo extern __typeof (xmlC14NDocSaveTo) xmlC14NDocSaveTo __attribute((alias("xmlC14NDocSaveTo__internal_alias"))); #else #ifndef xmlC14NDocSaveTo extern __typeof (xmlC14NDocSaveTo) xmlC14NDocSaveTo__internal_alias __attribute((visibility("hidden"))); #define xmlC14NDocSaveTo xmlC14NDocSaveTo__internal_alias #endif #endif #endif #if defined(LIBXML_C14N_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_c14n #undef xmlC14NExecute extern __typeof (xmlC14NExecute) xmlC14NExecute __attribute((alias("xmlC14NExecute__internal_alias"))); #else #ifndef xmlC14NExecute extern __typeof (xmlC14NExecute) xmlC14NExecute__internal_alias __attribute((visibility("hidden"))); #define xmlC14NExecute xmlC14NExecute__internal_alias #endif #endif #endif #ifdef bottom_uri #undef xmlCanonicPath extern __typeof (xmlCanonicPath) xmlCanonicPath __attribute((alias("xmlCanonicPath__internal_alias"))); #else #ifndef xmlCanonicPath extern __typeof (xmlCanonicPath) xmlCanonicPath__internal_alias __attribute((visibility("hidden"))); #define xmlCanonicPath xmlCanonicPath__internal_alias #endif #endif #if defined(LIBXML_CATALOG_ENABLED) #ifdef bottom_catalog #undef xmlCatalogAdd extern __typeof (xmlCatalogAdd) xmlCatalogAdd __attribute((alias("xmlCatalogAdd__internal_alias"))); #else #ifndef xmlCatalogAdd extern __typeof (xmlCatalogAdd) xmlCatalogAdd__internal_alias __attribute((visibility("hidden"))); #define xmlCatalogAdd xmlCatalogAdd__internal_alias #endif #endif #endif #if defined(LIBXML_CATALOG_ENABLED) #ifdef bottom_catalog #undef xmlCatalogAddLocal extern __typeof (xmlCatalogAddLocal) xmlCatalogAddLocal __attribute((alias("xmlCatalogAddLocal__internal_alias"))); #else #ifndef xmlCatalogAddLocal extern __typeof (xmlCatalogAddLocal) xmlCatalogAddLocal__internal_alias __attribute((visibility("hidden"))); #define xmlCatalogAddLocal xmlCatalogAddLocal__internal_alias #endif #endif #endif #if defined(LIBXML_CATALOG_ENABLED) #ifdef bottom_catalog #undef xmlCatalogCleanup extern __typeof (xmlCatalogCleanup) xmlCatalogCleanup __attribute((alias("xmlCatalogCleanup__internal_alias"))); #else #ifndef xmlCatalogCleanup extern __typeof (xmlCatalogCleanup) xmlCatalogCleanup__internal_alias __attribute((visibility("hidden"))); #define xmlCatalogCleanup xmlCatalogCleanup__internal_alias #endif #endif #endif #if defined(LIBXML_CATALOG_ENABLED) #ifdef bottom_catalog #undef xmlCatalogConvert extern __typeof (xmlCatalogConvert) xmlCatalogConvert __attribute((alias("xmlCatalogConvert__internal_alias"))); #else #ifndef xmlCatalogConvert extern __typeof (xmlCatalogConvert) xmlCatalogConvert__internal_alias __attribute((visibility("hidden"))); #define xmlCatalogConvert xmlCatalogConvert__internal_alias #endif #endif #endif #if defined(LIBXML_CATALOG_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_catalog #undef xmlCatalogDump extern __typeof (xmlCatalogDump) xmlCatalogDump __attribute((alias("xmlCatalogDump__internal_alias"))); #else #ifndef xmlCatalogDump extern __typeof (xmlCatalogDump) xmlCatalogDump__internal_alias __attribute((visibility("hidden"))); #define xmlCatalogDump xmlCatalogDump__internal_alias #endif #endif #endif #if defined(LIBXML_CATALOG_ENABLED) #ifdef bottom_catalog #undef xmlCatalogFreeLocal extern __typeof (xmlCatalogFreeLocal) xmlCatalogFreeLocal __attribute((alias("xmlCatalogFreeLocal__internal_alias"))); #else #ifndef xmlCatalogFreeLocal extern __typeof (xmlCatalogFreeLocal) xmlCatalogFreeLocal__internal_alias __attribute((visibility("hidden"))); #define xmlCatalogFreeLocal xmlCatalogFreeLocal__internal_alias #endif #endif #endif #if defined(LIBXML_CATALOG_ENABLED) #ifdef bottom_catalog #undef xmlCatalogGetDefaults extern __typeof (xmlCatalogGetDefaults) xmlCatalogGetDefaults __attribute((alias("xmlCatalogGetDefaults__internal_alias"))); #else #ifndef xmlCatalogGetDefaults extern __typeof (xmlCatalogGetDefaults) xmlCatalogGetDefaults__internal_alias __attribute((visibility("hidden"))); #define xmlCatalogGetDefaults xmlCatalogGetDefaults__internal_alias #endif #endif #endif #if defined(LIBXML_CATALOG_ENABLED) #ifdef bottom_catalog #undef xmlCatalogGetPublic extern __typeof (xmlCatalogGetPublic) xmlCatalogGetPublic __attribute((alias("xmlCatalogGetPublic__internal_alias"))); #else #ifndef xmlCatalogGetPublic extern __typeof (xmlCatalogGetPublic) xmlCatalogGetPublic__internal_alias __attribute((visibility("hidden"))); #define xmlCatalogGetPublic xmlCatalogGetPublic__internal_alias #endif #endif #endif #if defined(LIBXML_CATALOG_ENABLED) #ifdef bottom_catalog #undef xmlCatalogGetSystem extern __typeof (xmlCatalogGetSystem) xmlCatalogGetSystem __attribute((alias("xmlCatalogGetSystem__internal_alias"))); #else #ifndef xmlCatalogGetSystem extern __typeof (xmlCatalogGetSystem) xmlCatalogGetSystem__internal_alias __attribute((visibility("hidden"))); #define xmlCatalogGetSystem xmlCatalogGetSystem__internal_alias #endif #endif #endif #if defined(LIBXML_CATALOG_ENABLED) #ifdef bottom_catalog #undef xmlCatalogIsEmpty extern __typeof (xmlCatalogIsEmpty) xmlCatalogIsEmpty __attribute((alias("xmlCatalogIsEmpty__internal_alias"))); #else #ifndef xmlCatalogIsEmpty extern __typeof (xmlCatalogIsEmpty) xmlCatalogIsEmpty__internal_alias __attribute((visibility("hidden"))); #define xmlCatalogIsEmpty xmlCatalogIsEmpty__internal_alias #endif #endif #endif #if defined(LIBXML_CATALOG_ENABLED) #ifdef bottom_catalog #undef xmlCatalogLocalResolve extern __typeof (xmlCatalogLocalResolve) xmlCatalogLocalResolve __attribute((alias("xmlCatalogLocalResolve__internal_alias"))); #else #ifndef xmlCatalogLocalResolve extern __typeof (xmlCatalogLocalResolve) xmlCatalogLocalResolve__internal_alias __attribute((visibility("hidden"))); #define xmlCatalogLocalResolve xmlCatalogLocalResolve__internal_alias #endif #endif #endif #if defined(LIBXML_CATALOG_ENABLED) #ifdef bottom_catalog #undef xmlCatalogLocalResolveURI extern __typeof (xmlCatalogLocalResolveURI) xmlCatalogLocalResolveURI __attribute((alias("xmlCatalogLocalResolveURI__internal_alias"))); #else #ifndef xmlCatalogLocalResolveURI extern __typeof (xmlCatalogLocalResolveURI) xmlCatalogLocalResolveURI__internal_alias __attribute((visibility("hidden"))); #define xmlCatalogLocalResolveURI xmlCatalogLocalResolveURI__internal_alias #endif #endif #endif #if defined(LIBXML_CATALOG_ENABLED) #ifdef bottom_catalog #undef xmlCatalogRemove extern __typeof (xmlCatalogRemove) xmlCatalogRemove __attribute((alias("xmlCatalogRemove__internal_alias"))); #else #ifndef xmlCatalogRemove extern __typeof (xmlCatalogRemove) xmlCatalogRemove__internal_alias __attribute((visibility("hidden"))); #define xmlCatalogRemove xmlCatalogRemove__internal_alias #endif #endif #endif #if defined(LIBXML_CATALOG_ENABLED) #ifdef bottom_catalog #undef xmlCatalogResolve extern __typeof (xmlCatalogResolve) xmlCatalogResolve __attribute((alias("xmlCatalogResolve__internal_alias"))); #else #ifndef xmlCatalogResolve extern __typeof (xmlCatalogResolve) xmlCatalogResolve__internal_alias __attribute((visibility("hidden"))); #define xmlCatalogResolve xmlCatalogResolve__internal_alias #endif #endif #endif #if defined(LIBXML_CATALOG_ENABLED) #ifdef bottom_catalog #undef xmlCatalogResolvePublic extern __typeof (xmlCatalogResolvePublic) xmlCatalogResolvePublic __attribute((alias("xmlCatalogResolvePublic__internal_alias"))); #else #ifndef xmlCatalogResolvePublic extern __typeof (xmlCatalogResolvePublic) xmlCatalogResolvePublic__internal_alias __attribute((visibility("hidden"))); #define xmlCatalogResolvePublic xmlCatalogResolvePublic__internal_alias #endif #endif #endif #if defined(LIBXML_CATALOG_ENABLED) #ifdef bottom_catalog #undef xmlCatalogResolveSystem extern __typeof (xmlCatalogResolveSystem) xmlCatalogResolveSystem __attribute((alias("xmlCatalogResolveSystem__internal_alias"))); #else #ifndef xmlCatalogResolveSystem extern __typeof (xmlCatalogResolveSystem) xmlCatalogResolveSystem__internal_alias __attribute((visibility("hidden"))); #define xmlCatalogResolveSystem xmlCatalogResolveSystem__internal_alias #endif #endif #endif #if defined(LIBXML_CATALOG_ENABLED) #ifdef bottom_catalog #undef xmlCatalogResolveURI extern __typeof (xmlCatalogResolveURI) xmlCatalogResolveURI __attribute((alias("xmlCatalogResolveURI__internal_alias"))); #else #ifndef xmlCatalogResolveURI extern __typeof (xmlCatalogResolveURI) xmlCatalogResolveURI__internal_alias __attribute((visibility("hidden"))); #define xmlCatalogResolveURI xmlCatalogResolveURI__internal_alias #endif #endif #endif #if defined(LIBXML_CATALOG_ENABLED) #ifdef bottom_catalog #undef xmlCatalogSetDebug extern __typeof (xmlCatalogSetDebug) xmlCatalogSetDebug __attribute((alias("xmlCatalogSetDebug__internal_alias"))); #else #ifndef xmlCatalogSetDebug extern __typeof (xmlCatalogSetDebug) xmlCatalogSetDebug__internal_alias __attribute((visibility("hidden"))); #define xmlCatalogSetDebug xmlCatalogSetDebug__internal_alias #endif #endif #endif #if defined(LIBXML_CATALOG_ENABLED) #ifdef bottom_catalog #undef xmlCatalogSetDefaultPrefer extern __typeof (xmlCatalogSetDefaultPrefer) xmlCatalogSetDefaultPrefer __attribute((alias("xmlCatalogSetDefaultPrefer__internal_alias"))); #else #ifndef xmlCatalogSetDefaultPrefer extern __typeof (xmlCatalogSetDefaultPrefer) xmlCatalogSetDefaultPrefer__internal_alias __attribute((visibility("hidden"))); #define xmlCatalogSetDefaultPrefer xmlCatalogSetDefaultPrefer__internal_alias #endif #endif #endif #if defined(LIBXML_CATALOG_ENABLED) #ifdef bottom_catalog #undef xmlCatalogSetDefaults extern __typeof (xmlCatalogSetDefaults) xmlCatalogSetDefaults __attribute((alias("xmlCatalogSetDefaults__internal_alias"))); #else #ifndef xmlCatalogSetDefaults extern __typeof (xmlCatalogSetDefaults) xmlCatalogSetDefaults__internal_alias __attribute((visibility("hidden"))); #define xmlCatalogSetDefaults xmlCatalogSetDefaults__internal_alias #endif #endif #endif #ifdef bottom_encoding #undef xmlCharEncCloseFunc extern __typeof (xmlCharEncCloseFunc) xmlCharEncCloseFunc __attribute((alias("xmlCharEncCloseFunc__internal_alias"))); #else #ifndef xmlCharEncCloseFunc extern __typeof (xmlCharEncCloseFunc) xmlCharEncCloseFunc__internal_alias __attribute((visibility("hidden"))); #define xmlCharEncCloseFunc xmlCharEncCloseFunc__internal_alias #endif #endif #ifdef bottom_encoding #undef xmlCharEncFirstLine extern __typeof (xmlCharEncFirstLine) xmlCharEncFirstLine __attribute((alias("xmlCharEncFirstLine__internal_alias"))); #else #ifndef xmlCharEncFirstLine extern __typeof (xmlCharEncFirstLine) xmlCharEncFirstLine__internal_alias __attribute((visibility("hidden"))); #define xmlCharEncFirstLine xmlCharEncFirstLine__internal_alias #endif #endif #ifdef bottom_encoding #undef xmlCharEncInFunc extern __typeof (xmlCharEncInFunc) xmlCharEncInFunc __attribute((alias("xmlCharEncInFunc__internal_alias"))); #else #ifndef xmlCharEncInFunc extern __typeof (xmlCharEncInFunc) xmlCharEncInFunc__internal_alias __attribute((visibility("hidden"))); #define xmlCharEncInFunc xmlCharEncInFunc__internal_alias #endif #endif #ifdef bottom_encoding #undef xmlCharEncOutFunc extern __typeof (xmlCharEncOutFunc) xmlCharEncOutFunc __attribute((alias("xmlCharEncOutFunc__internal_alias"))); #else #ifndef xmlCharEncOutFunc extern __typeof (xmlCharEncOutFunc) xmlCharEncOutFunc__internal_alias __attribute((visibility("hidden"))); #define xmlCharEncOutFunc xmlCharEncOutFunc__internal_alias #endif #endif #ifdef bottom_chvalid #undef xmlCharInRange extern __typeof (xmlCharInRange) xmlCharInRange __attribute((alias("xmlCharInRange__internal_alias"))); #else #ifndef xmlCharInRange extern __typeof (xmlCharInRange) xmlCharInRange__internal_alias __attribute((visibility("hidden"))); #define xmlCharInRange xmlCharInRange__internal_alias #endif #endif #ifdef bottom_xmlstring #undef xmlCharStrdup extern __typeof (xmlCharStrdup) xmlCharStrdup __attribute((alias("xmlCharStrdup__internal_alias"))); #else #ifndef xmlCharStrdup extern __typeof (xmlCharStrdup) xmlCharStrdup__internal_alias __attribute((visibility("hidden"))); #define xmlCharStrdup xmlCharStrdup__internal_alias #endif #endif #ifdef bottom_xmlstring #undef xmlCharStrndup extern __typeof (xmlCharStrndup) xmlCharStrndup __attribute((alias("xmlCharStrndup__internal_alias"))); #else #ifndef xmlCharStrndup extern __typeof (xmlCharStrndup) xmlCharStrndup__internal_alias __attribute((visibility("hidden"))); #define xmlCharStrndup xmlCharStrndup__internal_alias #endif #endif #ifdef bottom_xmlIO #undef xmlCheckFilename extern __typeof (xmlCheckFilename) xmlCheckFilename __attribute((alias("xmlCheckFilename__internal_alias"))); #else #ifndef xmlCheckFilename extern __typeof (xmlCheckFilename) xmlCheckFilename__internal_alias __attribute((visibility("hidden"))); #define xmlCheckFilename xmlCheckFilename__internal_alias #endif #endif #ifdef bottom_xmlIO #undef xmlCheckHTTPInput extern __typeof (xmlCheckHTTPInput) xmlCheckHTTPInput __attribute((alias("xmlCheckHTTPInput__internal_alias"))); #else #ifndef xmlCheckHTTPInput extern __typeof (xmlCheckHTTPInput) xmlCheckHTTPInput__internal_alias __attribute((visibility("hidden"))); #define xmlCheckHTTPInput xmlCheckHTTPInput__internal_alias #endif #endif #ifdef bottom_parser #undef xmlCheckLanguageID extern __typeof (xmlCheckLanguageID) xmlCheckLanguageID __attribute((alias("xmlCheckLanguageID__internal_alias"))); #else #ifndef xmlCheckLanguageID extern __typeof (xmlCheckLanguageID) xmlCheckLanguageID__internal_alias __attribute((visibility("hidden"))); #define xmlCheckLanguageID xmlCheckLanguageID__internal_alias #endif #endif #ifdef bottom_xmlstring #undef xmlCheckUTF8 extern __typeof (xmlCheckUTF8) xmlCheckUTF8 __attribute((alias("xmlCheckUTF8__internal_alias"))); #else #ifndef xmlCheckUTF8 extern __typeof (xmlCheckUTF8) xmlCheckUTF8__internal_alias __attribute((visibility("hidden"))); #define xmlCheckUTF8 xmlCheckUTF8__internal_alias #endif #endif #ifdef bottom_parserInternals #undef xmlCheckVersion extern __typeof (xmlCheckVersion) xmlCheckVersion __attribute((alias("xmlCheckVersion__internal_alias"))); #else #ifndef xmlCheckVersion extern __typeof (xmlCheckVersion) xmlCheckVersion__internal_alias __attribute((visibility("hidden"))); #define xmlCheckVersion xmlCheckVersion__internal_alias #endif #endif #ifdef bottom_encoding #undef xmlCleanupCharEncodingHandlers extern __typeof (xmlCleanupCharEncodingHandlers) xmlCleanupCharEncodingHandlers __attribute((alias("xmlCleanupCharEncodingHandlers__internal_alias"))); #else #ifndef xmlCleanupCharEncodingHandlers extern __typeof (xmlCleanupCharEncodingHandlers) xmlCleanupCharEncodingHandlers__internal_alias __attribute((visibility("hidden"))); #define xmlCleanupCharEncodingHandlers xmlCleanupCharEncodingHandlers__internal_alias #endif #endif #ifdef bottom_encoding #undef xmlCleanupEncodingAliases extern __typeof (xmlCleanupEncodingAliases) xmlCleanupEncodingAliases __attribute((alias("xmlCleanupEncodingAliases__internal_alias"))); #else #ifndef xmlCleanupEncodingAliases extern __typeof (xmlCleanupEncodingAliases) xmlCleanupEncodingAliases__internal_alias __attribute((visibility("hidden"))); #define xmlCleanupEncodingAliases xmlCleanupEncodingAliases__internal_alias #endif #endif #ifdef bottom_globals #undef xmlCleanupGlobals extern __typeof (xmlCleanupGlobals) xmlCleanupGlobals __attribute((alias("xmlCleanupGlobals__internal_alias"))); #else #ifndef xmlCleanupGlobals extern __typeof (xmlCleanupGlobals) xmlCleanupGlobals__internal_alias __attribute((visibility("hidden"))); #define xmlCleanupGlobals xmlCleanupGlobals__internal_alias #endif #endif #ifdef bottom_xmlIO #undef xmlCleanupInputCallbacks extern __typeof (xmlCleanupInputCallbacks) xmlCleanupInputCallbacks __attribute((alias("xmlCleanupInputCallbacks__internal_alias"))); #else #ifndef xmlCleanupInputCallbacks extern __typeof (xmlCleanupInputCallbacks) xmlCleanupInputCallbacks__internal_alias __attribute((visibility("hidden"))); #define xmlCleanupInputCallbacks xmlCleanupInputCallbacks__internal_alias #endif #endif #ifdef bottom_xmlmemory #undef xmlCleanupMemory extern __typeof (xmlCleanupMemory) xmlCleanupMemory __attribute((alias("xmlCleanupMemory__internal_alias"))); #else #ifndef xmlCleanupMemory extern __typeof (xmlCleanupMemory) xmlCleanupMemory__internal_alias __attribute((visibility("hidden"))); #define xmlCleanupMemory xmlCleanupMemory__internal_alias #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_xmlIO #undef xmlCleanupOutputCallbacks extern __typeof (xmlCleanupOutputCallbacks) xmlCleanupOutputCallbacks __attribute((alias("xmlCleanupOutputCallbacks__internal_alias"))); #else #ifndef xmlCleanupOutputCallbacks extern __typeof (xmlCleanupOutputCallbacks) xmlCleanupOutputCallbacks__internal_alias __attribute((visibility("hidden"))); #define xmlCleanupOutputCallbacks xmlCleanupOutputCallbacks__internal_alias #endif #endif #endif #ifdef bottom_parser #undef xmlCleanupParser extern __typeof (xmlCleanupParser) xmlCleanupParser __attribute((alias("xmlCleanupParser__internal_alias"))); #else #ifndef xmlCleanupParser extern __typeof (xmlCleanupParser) xmlCleanupParser__internal_alias __attribute((visibility("hidden"))); #define xmlCleanupParser xmlCleanupParser__internal_alias #endif #endif #if defined(LIBXML_LEGACY_ENABLED) #ifdef bottom_legacy #undef xmlCleanupPredefinedEntities extern __typeof (xmlCleanupPredefinedEntities) xmlCleanupPredefinedEntities __attribute((alias("xmlCleanupPredefinedEntities__internal_alias"))); #else #ifndef xmlCleanupPredefinedEntities extern __typeof (xmlCleanupPredefinedEntities) xmlCleanupPredefinedEntities__internal_alias __attribute((visibility("hidden"))); #define xmlCleanupPredefinedEntities xmlCleanupPredefinedEntities__internal_alias #endif #endif #endif #ifdef bottom_threads #undef xmlCleanupThreads extern __typeof (xmlCleanupThreads) xmlCleanupThreads __attribute((alias("xmlCleanupThreads__internal_alias"))); #else #ifndef xmlCleanupThreads extern __typeof (xmlCleanupThreads) xmlCleanupThreads__internal_alias __attribute((visibility("hidden"))); #define xmlCleanupThreads xmlCleanupThreads__internal_alias #endif #endif #ifdef bottom_parserInternals #undef xmlClearNodeInfoSeq extern __typeof (xmlClearNodeInfoSeq) xmlClearNodeInfoSeq __attribute((alias("xmlClearNodeInfoSeq__internal_alias"))); #else #ifndef xmlClearNodeInfoSeq extern __typeof (xmlClearNodeInfoSeq) xmlClearNodeInfoSeq__internal_alias __attribute((visibility("hidden"))); #define xmlClearNodeInfoSeq xmlClearNodeInfoSeq__internal_alias #endif #endif #ifdef bottom_parserInternals #undef xmlClearParserCtxt extern __typeof (xmlClearParserCtxt) xmlClearParserCtxt __attribute((alias("xmlClearParserCtxt__internal_alias"))); #else #ifndef xmlClearParserCtxt extern __typeof (xmlClearParserCtxt) xmlClearParserCtxt__internal_alias __attribute((visibility("hidden"))); #define xmlClearParserCtxt xmlClearParserCtxt__internal_alias #endif #endif #if defined(LIBXML_CATALOG_ENABLED) #ifdef bottom_catalog #undef xmlConvertSGMLCatalog extern __typeof (xmlConvertSGMLCatalog) xmlConvertSGMLCatalog __attribute((alias("xmlConvertSGMLCatalog__internal_alias"))); #else #ifndef xmlConvertSGMLCatalog extern __typeof (xmlConvertSGMLCatalog) xmlConvertSGMLCatalog__internal_alias __attribute((visibility("hidden"))); #define xmlConvertSGMLCatalog xmlConvertSGMLCatalog__internal_alias #endif #endif #endif #if defined(LIBXML_TREE_ENABLED) #ifdef bottom_valid #undef xmlCopyAttributeTable extern __typeof (xmlCopyAttributeTable) xmlCopyAttributeTable __attribute((alias("xmlCopyAttributeTable__internal_alias"))); #else #ifndef xmlCopyAttributeTable extern __typeof (xmlCopyAttributeTable) xmlCopyAttributeTable__internal_alias __attribute((visibility("hidden"))); #define xmlCopyAttributeTable xmlCopyAttributeTable__internal_alias #endif #endif #endif #ifdef bottom_parserInternals #undef xmlCopyChar extern __typeof (xmlCopyChar) xmlCopyChar __attribute((alias("xmlCopyChar__internal_alias"))); #else #ifndef xmlCopyChar extern __typeof (xmlCopyChar) xmlCopyChar__internal_alias __attribute((visibility("hidden"))); #define xmlCopyChar xmlCopyChar__internal_alias #endif #endif #ifdef bottom_parserInternals #undef xmlCopyCharMultiByte extern __typeof (xmlCopyCharMultiByte) xmlCopyCharMultiByte __attribute((alias("xmlCopyCharMultiByte__internal_alias"))); #else #ifndef xmlCopyCharMultiByte extern __typeof (xmlCopyCharMultiByte) xmlCopyCharMultiByte__internal_alias __attribute((visibility("hidden"))); #define xmlCopyCharMultiByte xmlCopyCharMultiByte__internal_alias #endif #endif #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_tree #undef xmlCopyDoc extern __typeof (xmlCopyDoc) xmlCopyDoc __attribute((alias("xmlCopyDoc__internal_alias"))); #else #ifndef xmlCopyDoc extern __typeof (xmlCopyDoc) xmlCopyDoc__internal_alias __attribute((visibility("hidden"))); #define xmlCopyDoc xmlCopyDoc__internal_alias #endif #endif #endif #ifdef bottom_valid #undef xmlCopyDocElementContent extern __typeof (xmlCopyDocElementContent) xmlCopyDocElementContent __attribute((alias("xmlCopyDocElementContent__internal_alias"))); #else #ifndef xmlCopyDocElementContent extern __typeof (xmlCopyDocElementContent) xmlCopyDocElementContent__internal_alias __attribute((visibility("hidden"))); #define xmlCopyDocElementContent xmlCopyDocElementContent__internal_alias #endif #endif #if defined(LIBXML_TREE_ENABLED) #ifdef bottom_tree #undef xmlCopyDtd extern __typeof (xmlCopyDtd) xmlCopyDtd __attribute((alias("xmlCopyDtd__internal_alias"))); #else #ifndef xmlCopyDtd extern __typeof (xmlCopyDtd) xmlCopyDtd__internal_alias __attribute((visibility("hidden"))); #define xmlCopyDtd xmlCopyDtd__internal_alias #endif #endif #endif #ifdef bottom_valid #undef xmlCopyElementContent extern __typeof (xmlCopyElementContent) xmlCopyElementContent __attribute((alias("xmlCopyElementContent__internal_alias"))); #else #ifndef xmlCopyElementContent extern __typeof (xmlCopyElementContent) xmlCopyElementContent__internal_alias __attribute((visibility("hidden"))); #define xmlCopyElementContent xmlCopyElementContent__internal_alias #endif #endif #if defined(LIBXML_TREE_ENABLED) #ifdef bottom_valid #undef xmlCopyElementTable extern __typeof (xmlCopyElementTable) xmlCopyElementTable __attribute((alias("xmlCopyElementTable__internal_alias"))); #else #ifndef xmlCopyElementTable extern __typeof (xmlCopyElementTable) xmlCopyElementTable__internal_alias __attribute((visibility("hidden"))); #define xmlCopyElementTable xmlCopyElementTable__internal_alias #endif #endif #endif #if defined(LIBXML_TREE_ENABLED) #ifdef bottom_entities #undef xmlCopyEntitiesTable extern __typeof (xmlCopyEntitiesTable) xmlCopyEntitiesTable __attribute((alias("xmlCopyEntitiesTable__internal_alias"))); #else #ifndef xmlCopyEntitiesTable extern __typeof (xmlCopyEntitiesTable) xmlCopyEntitiesTable__internal_alias __attribute((visibility("hidden"))); #define xmlCopyEntitiesTable xmlCopyEntitiesTable__internal_alias #endif #endif #endif #if defined(LIBXML_TREE_ENABLED) #ifdef bottom_valid #undef xmlCopyEnumeration extern __typeof (xmlCopyEnumeration) xmlCopyEnumeration __attribute((alias("xmlCopyEnumeration__internal_alias"))); #else #ifndef xmlCopyEnumeration extern __typeof (xmlCopyEnumeration) xmlCopyEnumeration__internal_alias __attribute((visibility("hidden"))); #define xmlCopyEnumeration xmlCopyEnumeration__internal_alias #endif #endif #endif #ifdef bottom_error #undef xmlCopyError extern __typeof (xmlCopyError) xmlCopyError __attribute((alias("xmlCopyError__internal_alias"))); #else #ifndef xmlCopyError extern __typeof (xmlCopyError) xmlCopyError__internal_alias __attribute((visibility("hidden"))); #define xmlCopyError xmlCopyError__internal_alias #endif #endif #ifdef bottom_tree #undef xmlCopyNamespace extern __typeof (xmlCopyNamespace) xmlCopyNamespace __attribute((alias("xmlCopyNamespace__internal_alias"))); #else #ifndef xmlCopyNamespace extern __typeof (xmlCopyNamespace) xmlCopyNamespace__internal_alias __attribute((visibility("hidden"))); #define xmlCopyNamespace xmlCopyNamespace__internal_alias #endif #endif #ifdef bottom_tree #undef xmlCopyNamespaceList extern __typeof (xmlCopyNamespaceList) xmlCopyNamespaceList __attribute((alias("xmlCopyNamespaceList__internal_alias"))); #else #ifndef xmlCopyNamespaceList extern __typeof (xmlCopyNamespaceList) xmlCopyNamespaceList__internal_alias __attribute((visibility("hidden"))); #define xmlCopyNamespaceList xmlCopyNamespaceList__internal_alias #endif #endif #ifdef bottom_tree #undef xmlCopyNode extern __typeof (xmlCopyNode) xmlCopyNode __attribute((alias("xmlCopyNode__internal_alias"))); #else #ifndef xmlCopyNode extern __typeof (xmlCopyNode) xmlCopyNode__internal_alias __attribute((visibility("hidden"))); #define xmlCopyNode xmlCopyNode__internal_alias #endif #endif #ifdef bottom_tree #undef xmlCopyNodeList extern __typeof (xmlCopyNodeList) xmlCopyNodeList __attribute((alias("xmlCopyNodeList__internal_alias"))); #else #ifndef xmlCopyNodeList extern __typeof (xmlCopyNodeList) xmlCopyNodeList__internal_alias __attribute((visibility("hidden"))); #define xmlCopyNodeList xmlCopyNodeList__internal_alias #endif #endif #if defined(LIBXML_TREE_ENABLED) #ifdef bottom_valid #undef xmlCopyNotationTable extern __typeof (xmlCopyNotationTable) xmlCopyNotationTable __attribute((alias("xmlCopyNotationTable__internal_alias"))); #else #ifndef xmlCopyNotationTable extern __typeof (xmlCopyNotationTable) xmlCopyNotationTable__internal_alias __attribute((visibility("hidden"))); #define xmlCopyNotationTable xmlCopyNotationTable__internal_alias #endif #endif #endif #ifdef bottom_tree #undef xmlCopyProp extern __typeof (xmlCopyProp) xmlCopyProp __attribute((alias("xmlCopyProp__internal_alias"))); #else #ifndef xmlCopyProp extern __typeof (xmlCopyProp) xmlCopyProp__internal_alias __attribute((visibility("hidden"))); #define xmlCopyProp xmlCopyProp__internal_alias #endif #endif #ifdef bottom_tree #undef xmlCopyPropList extern __typeof (xmlCopyPropList) xmlCopyPropList __attribute((alias("xmlCopyPropList__internal_alias"))); #else #ifndef xmlCopyPropList extern __typeof (xmlCopyPropList) xmlCopyPropList__internal_alias __attribute((visibility("hidden"))); #define xmlCopyPropList xmlCopyPropList__internal_alias #endif #endif #ifdef bottom_parser #undef xmlCreateDocParserCtxt extern __typeof (xmlCreateDocParserCtxt) xmlCreateDocParserCtxt __attribute((alias("xmlCreateDocParserCtxt__internal_alias"))); #else #ifndef xmlCreateDocParserCtxt extern __typeof (xmlCreateDocParserCtxt) xmlCreateDocParserCtxt__internal_alias __attribute((visibility("hidden"))); #define xmlCreateDocParserCtxt xmlCreateDocParserCtxt__internal_alias #endif #endif #ifdef bottom_entities #undef xmlCreateEntitiesTable extern __typeof (xmlCreateEntitiesTable) xmlCreateEntitiesTable __attribute((alias("xmlCreateEntitiesTable__internal_alias"))); #else #ifndef xmlCreateEntitiesTable extern __typeof (xmlCreateEntitiesTable) xmlCreateEntitiesTable__internal_alias __attribute((visibility("hidden"))); #define xmlCreateEntitiesTable xmlCreateEntitiesTable__internal_alias #endif #endif #ifdef bottom_parser #undef xmlCreateEntityParserCtxt extern __typeof (xmlCreateEntityParserCtxt) xmlCreateEntityParserCtxt __attribute((alias("xmlCreateEntityParserCtxt__internal_alias"))); #else #ifndef xmlCreateEntityParserCtxt extern __typeof (xmlCreateEntityParserCtxt) xmlCreateEntityParserCtxt__internal_alias __attribute((visibility("hidden"))); #define xmlCreateEntityParserCtxt xmlCreateEntityParserCtxt__internal_alias #endif #endif #ifdef bottom_valid #undef xmlCreateEnumeration extern __typeof (xmlCreateEnumeration) xmlCreateEnumeration __attribute((alias("xmlCreateEnumeration__internal_alias"))); #else #ifndef xmlCreateEnumeration extern __typeof (xmlCreateEnumeration) xmlCreateEnumeration__internal_alias __attribute((visibility("hidden"))); #define xmlCreateEnumeration xmlCreateEnumeration__internal_alias #endif #endif #ifdef bottom_parser #undef xmlCreateFileParserCtxt extern __typeof (xmlCreateFileParserCtxt) xmlCreateFileParserCtxt __attribute((alias("xmlCreateFileParserCtxt__internal_alias"))); #else #ifndef xmlCreateFileParserCtxt extern __typeof (xmlCreateFileParserCtxt) xmlCreateFileParserCtxt__internal_alias __attribute((visibility("hidden"))); #define xmlCreateFileParserCtxt xmlCreateFileParserCtxt__internal_alias #endif #endif #ifdef bottom_parser #undef xmlCreateIOParserCtxt extern __typeof (xmlCreateIOParserCtxt) xmlCreateIOParserCtxt __attribute((alias("xmlCreateIOParserCtxt__internal_alias"))); #else #ifndef xmlCreateIOParserCtxt extern __typeof (xmlCreateIOParserCtxt) xmlCreateIOParserCtxt__internal_alias __attribute((visibility("hidden"))); #define xmlCreateIOParserCtxt xmlCreateIOParserCtxt__internal_alias #endif #endif #ifdef bottom_tree #undef xmlCreateIntSubset extern __typeof (xmlCreateIntSubset) xmlCreateIntSubset __attribute((alias("xmlCreateIntSubset__internal_alias"))); #else #ifndef xmlCreateIntSubset extern __typeof (xmlCreateIntSubset) xmlCreateIntSubset__internal_alias __attribute((visibility("hidden"))); #define xmlCreateIntSubset xmlCreateIntSubset__internal_alias #endif #endif #ifdef bottom_parser #undef xmlCreateMemoryParserCtxt extern __typeof (xmlCreateMemoryParserCtxt) xmlCreateMemoryParserCtxt __attribute((alias("xmlCreateMemoryParserCtxt__internal_alias"))); #else #ifndef xmlCreateMemoryParserCtxt extern __typeof (xmlCreateMemoryParserCtxt) xmlCreateMemoryParserCtxt__internal_alias __attribute((visibility("hidden"))); #define xmlCreateMemoryParserCtxt xmlCreateMemoryParserCtxt__internal_alias #endif #endif #if defined(LIBXML_PUSH_ENABLED) #ifdef bottom_parser #undef xmlCreatePushParserCtxt extern __typeof (xmlCreatePushParserCtxt) xmlCreatePushParserCtxt __attribute((alias("xmlCreatePushParserCtxt__internal_alias"))); #else #ifndef xmlCreatePushParserCtxt extern __typeof (xmlCreatePushParserCtxt) xmlCreatePushParserCtxt__internal_alias __attribute((visibility("hidden"))); #define xmlCreatePushParserCtxt xmlCreatePushParserCtxt__internal_alias #endif #endif #endif #ifdef bottom_uri #undef xmlCreateURI extern __typeof (xmlCreateURI) xmlCreateURI __attribute((alias("xmlCreateURI__internal_alias"))); #else #ifndef xmlCreateURI extern __typeof (xmlCreateURI) xmlCreateURI__internal_alias __attribute((visibility("hidden"))); #define xmlCreateURI xmlCreateURI__internal_alias #endif #endif #ifdef bottom_parser #undef xmlCreateURLParserCtxt extern __typeof (xmlCreateURLParserCtxt) xmlCreateURLParserCtxt __attribute((alias("xmlCreateURLParserCtxt__internal_alias"))); #else #ifndef xmlCreateURLParserCtxt extern __typeof (xmlCreateURLParserCtxt) xmlCreateURLParserCtxt__internal_alias __attribute((visibility("hidden"))); #define xmlCreateURLParserCtxt xmlCreateURLParserCtxt__internal_alias #endif #endif #ifdef bottom_error #undef xmlCtxtGetLastError extern __typeof (xmlCtxtGetLastError) xmlCtxtGetLastError __attribute((alias("xmlCtxtGetLastError__internal_alias"))); #else #ifndef xmlCtxtGetLastError extern __typeof (xmlCtxtGetLastError) xmlCtxtGetLastError__internal_alias __attribute((visibility("hidden"))); #define xmlCtxtGetLastError xmlCtxtGetLastError__internal_alias #endif #endif #ifdef bottom_parser #undef xmlCtxtReadDoc extern __typeof (xmlCtxtReadDoc) xmlCtxtReadDoc __attribute((alias("xmlCtxtReadDoc__internal_alias"))); #else #ifndef xmlCtxtReadDoc extern __typeof (xmlCtxtReadDoc) xmlCtxtReadDoc__internal_alias __attribute((visibility("hidden"))); #define xmlCtxtReadDoc xmlCtxtReadDoc__internal_alias #endif #endif #ifdef bottom_parser #undef xmlCtxtReadFd extern __typeof (xmlCtxtReadFd) xmlCtxtReadFd __attribute((alias("xmlCtxtReadFd__internal_alias"))); #else #ifndef xmlCtxtReadFd extern __typeof (xmlCtxtReadFd) xmlCtxtReadFd__internal_alias __attribute((visibility("hidden"))); #define xmlCtxtReadFd xmlCtxtReadFd__internal_alias #endif #endif #ifdef bottom_parser #undef xmlCtxtReadFile extern __typeof (xmlCtxtReadFile) xmlCtxtReadFile __attribute((alias("xmlCtxtReadFile__internal_alias"))); #else #ifndef xmlCtxtReadFile extern __typeof (xmlCtxtReadFile) xmlCtxtReadFile__internal_alias __attribute((visibility("hidden"))); #define xmlCtxtReadFile xmlCtxtReadFile__internal_alias #endif #endif #ifdef bottom_parser #undef xmlCtxtReadIO extern __typeof (xmlCtxtReadIO) xmlCtxtReadIO __attribute((alias("xmlCtxtReadIO__internal_alias"))); #else #ifndef xmlCtxtReadIO extern __typeof (xmlCtxtReadIO) xmlCtxtReadIO__internal_alias __attribute((visibility("hidden"))); #define xmlCtxtReadIO xmlCtxtReadIO__internal_alias #endif #endif #ifdef bottom_parser #undef xmlCtxtReadMemory extern __typeof (xmlCtxtReadMemory) xmlCtxtReadMemory __attribute((alias("xmlCtxtReadMemory__internal_alias"))); #else #ifndef xmlCtxtReadMemory extern __typeof (xmlCtxtReadMemory) xmlCtxtReadMemory__internal_alias __attribute((visibility("hidden"))); #define xmlCtxtReadMemory xmlCtxtReadMemory__internal_alias #endif #endif #ifdef bottom_parser #undef xmlCtxtReset extern __typeof (xmlCtxtReset) xmlCtxtReset __attribute((alias("xmlCtxtReset__internal_alias"))); #else #ifndef xmlCtxtReset extern __typeof (xmlCtxtReset) xmlCtxtReset__internal_alias __attribute((visibility("hidden"))); #define xmlCtxtReset xmlCtxtReset__internal_alias #endif #endif #ifdef bottom_error #undef xmlCtxtResetLastError extern __typeof (xmlCtxtResetLastError) xmlCtxtResetLastError __attribute((alias("xmlCtxtResetLastError__internal_alias"))); #else #ifndef xmlCtxtResetLastError extern __typeof (xmlCtxtResetLastError) xmlCtxtResetLastError__internal_alias __attribute((visibility("hidden"))); #define xmlCtxtResetLastError xmlCtxtResetLastError__internal_alias #endif #endif #ifdef bottom_parser #undef xmlCtxtResetPush extern __typeof (xmlCtxtResetPush) xmlCtxtResetPush __attribute((alias("xmlCtxtResetPush__internal_alias"))); #else #ifndef xmlCtxtResetPush extern __typeof (xmlCtxtResetPush) xmlCtxtResetPush__internal_alias __attribute((visibility("hidden"))); #define xmlCtxtResetPush xmlCtxtResetPush__internal_alias #endif #endif #ifdef bottom_parser #undef xmlCtxtUseOptions extern __typeof (xmlCtxtUseOptions) xmlCtxtUseOptions __attribute((alias("xmlCtxtUseOptions__internal_alias"))); #else #ifndef xmlCtxtUseOptions extern __typeof (xmlCtxtUseOptions) xmlCtxtUseOptions__internal_alias __attribute((visibility("hidden"))); #define xmlCtxtUseOptions xmlCtxtUseOptions__internal_alias #endif #endif #ifdef bottom_parserInternals #undef xmlCurrentChar extern __typeof (xmlCurrentChar) xmlCurrentChar __attribute((alias("xmlCurrentChar__internal_alias"))); #else #ifndef xmlCurrentChar extern __typeof (xmlCurrentChar) xmlCurrentChar__internal_alias __attribute((visibility("hidden"))); #define xmlCurrentChar xmlCurrentChar__internal_alias #endif #endif #ifdef bottom_tree #undef xmlDOMWrapAdoptNode extern __typeof (xmlDOMWrapAdoptNode) xmlDOMWrapAdoptNode __attribute((alias("xmlDOMWrapAdoptNode__internal_alias"))); #else #ifndef xmlDOMWrapAdoptNode extern __typeof (xmlDOMWrapAdoptNode) xmlDOMWrapAdoptNode__internal_alias __attribute((visibility("hidden"))); #define xmlDOMWrapAdoptNode xmlDOMWrapAdoptNode__internal_alias #endif #endif #ifdef bottom_tree #undef xmlDOMWrapCloneNode extern __typeof (xmlDOMWrapCloneNode) xmlDOMWrapCloneNode __attribute((alias("xmlDOMWrapCloneNode__internal_alias"))); #else #ifndef xmlDOMWrapCloneNode extern __typeof (xmlDOMWrapCloneNode) xmlDOMWrapCloneNode__internal_alias __attribute((visibility("hidden"))); #define xmlDOMWrapCloneNode xmlDOMWrapCloneNode__internal_alias #endif #endif #ifdef bottom_tree #undef xmlDOMWrapFreeCtxt extern __typeof (xmlDOMWrapFreeCtxt) xmlDOMWrapFreeCtxt __attribute((alias("xmlDOMWrapFreeCtxt__internal_alias"))); #else #ifndef xmlDOMWrapFreeCtxt extern __typeof (xmlDOMWrapFreeCtxt) xmlDOMWrapFreeCtxt__internal_alias __attribute((visibility("hidden"))); #define xmlDOMWrapFreeCtxt xmlDOMWrapFreeCtxt__internal_alias #endif #endif #ifdef bottom_tree #undef xmlDOMWrapNewCtxt extern __typeof (xmlDOMWrapNewCtxt) xmlDOMWrapNewCtxt __attribute((alias("xmlDOMWrapNewCtxt__internal_alias"))); #else #ifndef xmlDOMWrapNewCtxt extern __typeof (xmlDOMWrapNewCtxt) xmlDOMWrapNewCtxt__internal_alias __attribute((visibility("hidden"))); #define xmlDOMWrapNewCtxt xmlDOMWrapNewCtxt__internal_alias #endif #endif #ifdef bottom_tree #undef xmlDOMWrapReconcileNamespaces extern __typeof (xmlDOMWrapReconcileNamespaces) xmlDOMWrapReconcileNamespaces __attribute((alias("xmlDOMWrapReconcileNamespaces__internal_alias"))); #else #ifndef xmlDOMWrapReconcileNamespaces extern __typeof (xmlDOMWrapReconcileNamespaces) xmlDOMWrapReconcileNamespaces__internal_alias __attribute((visibility("hidden"))); #define xmlDOMWrapReconcileNamespaces xmlDOMWrapReconcileNamespaces__internal_alias #endif #endif #ifdef bottom_tree #undef xmlDOMWrapRemoveNode extern __typeof (xmlDOMWrapRemoveNode) xmlDOMWrapRemoveNode __attribute((alias("xmlDOMWrapRemoveNode__internal_alias"))); #else #ifndef xmlDOMWrapRemoveNode extern __typeof (xmlDOMWrapRemoveNode) xmlDOMWrapRemoveNode__internal_alias __attribute((visibility("hidden"))); #define xmlDOMWrapRemoveNode xmlDOMWrapRemoveNode__internal_alias #endif #endif #if defined(LIBXML_DEBUG_ENABLED) #ifdef bottom_debugXML #undef xmlDebugCheckDocument extern __typeof (xmlDebugCheckDocument) xmlDebugCheckDocument __attribute((alias("xmlDebugCheckDocument__internal_alias"))); #else #ifndef xmlDebugCheckDocument extern __typeof (xmlDebugCheckDocument) xmlDebugCheckDocument__internal_alias __attribute((visibility("hidden"))); #define xmlDebugCheckDocument xmlDebugCheckDocument__internal_alias #endif #endif #endif #if defined(LIBXML_DEBUG_ENABLED) #ifdef bottom_debugXML #undef xmlDebugDumpAttr extern __typeof (xmlDebugDumpAttr) xmlDebugDumpAttr __attribute((alias("xmlDebugDumpAttr__internal_alias"))); #else #ifndef xmlDebugDumpAttr extern __typeof (xmlDebugDumpAttr) xmlDebugDumpAttr__internal_alias __attribute((visibility("hidden"))); #define xmlDebugDumpAttr xmlDebugDumpAttr__internal_alias #endif #endif #endif #if defined(LIBXML_DEBUG_ENABLED) #ifdef bottom_debugXML #undef xmlDebugDumpAttrList extern __typeof (xmlDebugDumpAttrList) xmlDebugDumpAttrList __attribute((alias("xmlDebugDumpAttrList__internal_alias"))); #else #ifndef xmlDebugDumpAttrList extern __typeof (xmlDebugDumpAttrList) xmlDebugDumpAttrList__internal_alias __attribute((visibility("hidden"))); #define xmlDebugDumpAttrList xmlDebugDumpAttrList__internal_alias #endif #endif #endif #if defined(LIBXML_DEBUG_ENABLED) #ifdef bottom_debugXML #undef xmlDebugDumpDTD extern __typeof (xmlDebugDumpDTD) xmlDebugDumpDTD __attribute((alias("xmlDebugDumpDTD__internal_alias"))); #else #ifndef xmlDebugDumpDTD extern __typeof (xmlDebugDumpDTD) xmlDebugDumpDTD__internal_alias __attribute((visibility("hidden"))); #define xmlDebugDumpDTD xmlDebugDumpDTD__internal_alias #endif #endif #endif #if defined(LIBXML_DEBUG_ENABLED) #ifdef bottom_debugXML #undef xmlDebugDumpDocument extern __typeof (xmlDebugDumpDocument) xmlDebugDumpDocument __attribute((alias("xmlDebugDumpDocument__internal_alias"))); #else #ifndef xmlDebugDumpDocument extern __typeof (xmlDebugDumpDocument) xmlDebugDumpDocument__internal_alias __attribute((visibility("hidden"))); #define xmlDebugDumpDocument xmlDebugDumpDocument__internal_alias #endif #endif #endif #if defined(LIBXML_DEBUG_ENABLED) #ifdef bottom_debugXML #undef xmlDebugDumpDocumentHead extern __typeof (xmlDebugDumpDocumentHead) xmlDebugDumpDocumentHead __attribute((alias("xmlDebugDumpDocumentHead__internal_alias"))); #else #ifndef xmlDebugDumpDocumentHead extern __typeof (xmlDebugDumpDocumentHead) xmlDebugDumpDocumentHead__internal_alias __attribute((visibility("hidden"))); #define xmlDebugDumpDocumentHead xmlDebugDumpDocumentHead__internal_alias #endif #endif #endif #if defined(LIBXML_DEBUG_ENABLED) #ifdef bottom_debugXML #undef xmlDebugDumpEntities extern __typeof (xmlDebugDumpEntities) xmlDebugDumpEntities __attribute((alias("xmlDebugDumpEntities__internal_alias"))); #else #ifndef xmlDebugDumpEntities extern __typeof (xmlDebugDumpEntities) xmlDebugDumpEntities__internal_alias __attribute((visibility("hidden"))); #define xmlDebugDumpEntities xmlDebugDumpEntities__internal_alias #endif #endif #endif #if defined(LIBXML_DEBUG_ENABLED) #ifdef bottom_debugXML #undef xmlDebugDumpNode extern __typeof (xmlDebugDumpNode) xmlDebugDumpNode __attribute((alias("xmlDebugDumpNode__internal_alias"))); #else #ifndef xmlDebugDumpNode extern __typeof (xmlDebugDumpNode) xmlDebugDumpNode__internal_alias __attribute((visibility("hidden"))); #define xmlDebugDumpNode xmlDebugDumpNode__internal_alias #endif #endif #endif #if defined(LIBXML_DEBUG_ENABLED) #ifdef bottom_debugXML #undef xmlDebugDumpNodeList extern __typeof (xmlDebugDumpNodeList) xmlDebugDumpNodeList __attribute((alias("xmlDebugDumpNodeList__internal_alias"))); #else #ifndef xmlDebugDumpNodeList extern __typeof (xmlDebugDumpNodeList) xmlDebugDumpNodeList__internal_alias __attribute((visibility("hidden"))); #define xmlDebugDumpNodeList xmlDebugDumpNodeList__internal_alias #endif #endif #endif #if defined(LIBXML_DEBUG_ENABLED) #ifdef bottom_debugXML #undef xmlDebugDumpOneNode extern __typeof (xmlDebugDumpOneNode) xmlDebugDumpOneNode __attribute((alias("xmlDebugDumpOneNode__internal_alias"))); #else #ifndef xmlDebugDumpOneNode extern __typeof (xmlDebugDumpOneNode) xmlDebugDumpOneNode__internal_alias __attribute((visibility("hidden"))); #define xmlDebugDumpOneNode xmlDebugDumpOneNode__internal_alias #endif #endif #endif #if defined(LIBXML_DEBUG_ENABLED) #ifdef bottom_debugXML #undef xmlDebugDumpString extern __typeof (xmlDebugDumpString) xmlDebugDumpString __attribute((alias("xmlDebugDumpString__internal_alias"))); #else #ifndef xmlDebugDumpString extern __typeof (xmlDebugDumpString) xmlDebugDumpString__internal_alias __attribute((visibility("hidden"))); #define xmlDebugDumpString xmlDebugDumpString__internal_alias #endif #endif #endif #if defined(LIBXML_LEGACY_ENABLED) #ifdef bottom_legacy #undef xmlDecodeEntities extern __typeof (xmlDecodeEntities) xmlDecodeEntities __attribute((alias("xmlDecodeEntities__internal_alias"))); #else #ifndef xmlDecodeEntities extern __typeof (xmlDecodeEntities) xmlDecodeEntities__internal_alias __attribute((visibility("hidden"))); #define xmlDecodeEntities xmlDecodeEntities__internal_alias #endif #endif #endif #ifdef bottom_SAX2 #undef xmlDefaultSAXHandlerInit extern __typeof (xmlDefaultSAXHandlerInit) xmlDefaultSAXHandlerInit __attribute((alias("xmlDefaultSAXHandlerInit__internal_alias"))); #else #ifndef xmlDefaultSAXHandlerInit extern __typeof (xmlDefaultSAXHandlerInit) xmlDefaultSAXHandlerInit__internal_alias __attribute((visibility("hidden"))); #define xmlDefaultSAXHandlerInit xmlDefaultSAXHandlerInit__internal_alias #endif #endif #ifdef bottom_encoding #undef xmlDelEncodingAlias extern __typeof (xmlDelEncodingAlias) xmlDelEncodingAlias __attribute((alias("xmlDelEncodingAlias__internal_alias"))); #else #ifndef xmlDelEncodingAlias extern __typeof (xmlDelEncodingAlias) xmlDelEncodingAlias__internal_alias __attribute((visibility("hidden"))); #define xmlDelEncodingAlias xmlDelEncodingAlias__internal_alias #endif #endif #ifdef bottom_globals #undef xmlDeregisterNodeDefault extern __typeof (xmlDeregisterNodeDefault) xmlDeregisterNodeDefault __attribute((alias("xmlDeregisterNodeDefault__internal_alias"))); #else #ifndef xmlDeregisterNodeDefault extern __typeof (xmlDeregisterNodeDefault) xmlDeregisterNodeDefault__internal_alias __attribute((visibility("hidden"))); #define xmlDeregisterNodeDefault xmlDeregisterNodeDefault__internal_alias #endif #endif #ifdef bottom_encoding #undef xmlDetectCharEncoding extern __typeof (xmlDetectCharEncoding) xmlDetectCharEncoding __attribute((alias("xmlDetectCharEncoding__internal_alias"))); #else #ifndef xmlDetectCharEncoding extern __typeof (xmlDetectCharEncoding) xmlDetectCharEncoding__internal_alias __attribute((visibility("hidden"))); #define xmlDetectCharEncoding xmlDetectCharEncoding__internal_alias #endif #endif #ifdef bottom_dict #undef xmlDictCleanup extern __typeof (xmlDictCleanup) xmlDictCleanup __attribute((alias("xmlDictCleanup__internal_alias"))); #else #ifndef xmlDictCleanup extern __typeof (xmlDictCleanup) xmlDictCleanup__internal_alias __attribute((visibility("hidden"))); #define xmlDictCleanup xmlDictCleanup__internal_alias #endif #endif #ifdef bottom_dict #undef xmlDictCreate extern __typeof (xmlDictCreate) xmlDictCreate __attribute((alias("xmlDictCreate__internal_alias"))); #else #ifndef xmlDictCreate extern __typeof (xmlDictCreate) xmlDictCreate__internal_alias __attribute((visibility("hidden"))); #define xmlDictCreate xmlDictCreate__internal_alias #endif #endif #ifdef bottom_dict #undef xmlDictCreateSub extern __typeof (xmlDictCreateSub) xmlDictCreateSub __attribute((alias("xmlDictCreateSub__internal_alias"))); #else #ifndef xmlDictCreateSub extern __typeof (xmlDictCreateSub) xmlDictCreateSub__internal_alias __attribute((visibility("hidden"))); #define xmlDictCreateSub xmlDictCreateSub__internal_alias #endif #endif #ifdef bottom_dict #undef xmlDictExists extern __typeof (xmlDictExists) xmlDictExists __attribute((alias("xmlDictExists__internal_alias"))); #else #ifndef xmlDictExists extern __typeof (xmlDictExists) xmlDictExists__internal_alias __attribute((visibility("hidden"))); #define xmlDictExists xmlDictExists__internal_alias #endif #endif #ifdef bottom_dict #undef xmlDictFree extern __typeof (xmlDictFree) xmlDictFree __attribute((alias("xmlDictFree__internal_alias"))); #else #ifndef xmlDictFree extern __typeof (xmlDictFree) xmlDictFree__internal_alias __attribute((visibility("hidden"))); #define xmlDictFree xmlDictFree__internal_alias #endif #endif #ifdef bottom_dict #undef xmlDictLookup extern __typeof (xmlDictLookup) xmlDictLookup __attribute((alias("xmlDictLookup__internal_alias"))); #else #ifndef xmlDictLookup extern __typeof (xmlDictLookup) xmlDictLookup__internal_alias __attribute((visibility("hidden"))); #define xmlDictLookup xmlDictLookup__internal_alias #endif #endif #ifdef bottom_dict #undef xmlDictOwns extern __typeof (xmlDictOwns) xmlDictOwns __attribute((alias("xmlDictOwns__internal_alias"))); #else #ifndef xmlDictOwns extern __typeof (xmlDictOwns) xmlDictOwns__internal_alias __attribute((visibility("hidden"))); #define xmlDictOwns xmlDictOwns__internal_alias #endif #endif #ifdef bottom_dict #undef xmlDictQLookup extern __typeof (xmlDictQLookup) xmlDictQLookup __attribute((alias("xmlDictQLookup__internal_alias"))); #else #ifndef xmlDictQLookup extern __typeof (xmlDictQLookup) xmlDictQLookup__internal_alias __attribute((visibility("hidden"))); #define xmlDictQLookup xmlDictQLookup__internal_alias #endif #endif #ifdef bottom_dict #undef xmlDictReference extern __typeof (xmlDictReference) xmlDictReference __attribute((alias("xmlDictReference__internal_alias"))); #else #ifndef xmlDictReference extern __typeof (xmlDictReference) xmlDictReference__internal_alias __attribute((visibility("hidden"))); #define xmlDictReference xmlDictReference__internal_alias #endif #endif #ifdef bottom_dict #undef xmlDictSize extern __typeof (xmlDictSize) xmlDictSize __attribute((alias("xmlDictSize__internal_alias"))); #else #ifndef xmlDictSize extern __typeof (xmlDictSize) xmlDictSize__internal_alias __attribute((visibility("hidden"))); #define xmlDictSize xmlDictSize__internal_alias #endif #endif #ifdef bottom_tree #undef xmlDocCopyNode extern __typeof (xmlDocCopyNode) xmlDocCopyNode __attribute((alias("xmlDocCopyNode__internal_alias"))); #else #ifndef xmlDocCopyNode extern __typeof (xmlDocCopyNode) xmlDocCopyNode__internal_alias __attribute((visibility("hidden"))); #define xmlDocCopyNode xmlDocCopyNode__internal_alias #endif #endif #ifdef bottom_tree #undef xmlDocCopyNodeList extern __typeof (xmlDocCopyNodeList) xmlDocCopyNodeList __attribute((alias("xmlDocCopyNodeList__internal_alias"))); #else #ifndef xmlDocCopyNodeList extern __typeof (xmlDocCopyNodeList) xmlDocCopyNodeList__internal_alias __attribute((visibility("hidden"))); #define xmlDocCopyNodeList xmlDocCopyNodeList__internal_alias #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_xmlsave #undef xmlDocDump extern __typeof (xmlDocDump) xmlDocDump __attribute((alias("xmlDocDump__internal_alias"))); #else #ifndef xmlDocDump extern __typeof (xmlDocDump) xmlDocDump__internal_alias __attribute((visibility("hidden"))); #define xmlDocDump xmlDocDump__internal_alias #endif #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_xmlsave #undef xmlDocDumpFormatMemory extern __typeof (xmlDocDumpFormatMemory) xmlDocDumpFormatMemory __attribute((alias("xmlDocDumpFormatMemory__internal_alias"))); #else #ifndef xmlDocDumpFormatMemory extern __typeof (xmlDocDumpFormatMemory) xmlDocDumpFormatMemory__internal_alias __attribute((visibility("hidden"))); #define xmlDocDumpFormatMemory xmlDocDumpFormatMemory__internal_alias #endif #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_xmlsave #undef xmlDocDumpFormatMemoryEnc extern __typeof (xmlDocDumpFormatMemoryEnc) xmlDocDumpFormatMemoryEnc __attribute((alias("xmlDocDumpFormatMemoryEnc__internal_alias"))); #else #ifndef xmlDocDumpFormatMemoryEnc extern __typeof (xmlDocDumpFormatMemoryEnc) xmlDocDumpFormatMemoryEnc__internal_alias __attribute((visibility("hidden"))); #define xmlDocDumpFormatMemoryEnc xmlDocDumpFormatMemoryEnc__internal_alias #endif #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_xmlsave #undef xmlDocDumpMemory extern __typeof (xmlDocDumpMemory) xmlDocDumpMemory __attribute((alias("xmlDocDumpMemory__internal_alias"))); #else #ifndef xmlDocDumpMemory extern __typeof (xmlDocDumpMemory) xmlDocDumpMemory__internal_alias __attribute((visibility("hidden"))); #define xmlDocDumpMemory xmlDocDumpMemory__internal_alias #endif #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_xmlsave #undef xmlDocDumpMemoryEnc extern __typeof (xmlDocDumpMemoryEnc) xmlDocDumpMemoryEnc __attribute((alias("xmlDocDumpMemoryEnc__internal_alias"))); #else #ifndef xmlDocDumpMemoryEnc extern __typeof (xmlDocDumpMemoryEnc) xmlDocDumpMemoryEnc__internal_alias __attribute((visibility("hidden"))); #define xmlDocDumpMemoryEnc xmlDocDumpMemoryEnc__internal_alias #endif #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_xmlsave #undef xmlDocFormatDump extern __typeof (xmlDocFormatDump) xmlDocFormatDump __attribute((alias("xmlDocFormatDump__internal_alias"))); #else #ifndef xmlDocFormatDump extern __typeof (xmlDocFormatDump) xmlDocFormatDump__internal_alias __attribute((visibility("hidden"))); #define xmlDocFormatDump xmlDocFormatDump__internal_alias #endif #endif #endif #ifdef bottom_tree #undef xmlDocGetRootElement extern __typeof (xmlDocGetRootElement) xmlDocGetRootElement __attribute((alias("xmlDocGetRootElement__internal_alias"))); #else #ifndef xmlDocGetRootElement extern __typeof (xmlDocGetRootElement) xmlDocGetRootElement__internal_alias __attribute((visibility("hidden"))); #define xmlDocGetRootElement xmlDocGetRootElement__internal_alias #endif #endif #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) #ifdef bottom_tree #undef xmlDocSetRootElement extern __typeof (xmlDocSetRootElement) xmlDocSetRootElement __attribute((alias("xmlDocSetRootElement__internal_alias"))); #else #ifndef xmlDocSetRootElement extern __typeof (xmlDocSetRootElement) xmlDocSetRootElement__internal_alias __attribute((visibility("hidden"))); #define xmlDocSetRootElement xmlDocSetRootElement__internal_alias #endif #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_valid #undef xmlDumpAttributeDecl extern __typeof (xmlDumpAttributeDecl) xmlDumpAttributeDecl __attribute((alias("xmlDumpAttributeDecl__internal_alias"))); #else #ifndef xmlDumpAttributeDecl extern __typeof (xmlDumpAttributeDecl) xmlDumpAttributeDecl__internal_alias __attribute((visibility("hidden"))); #define xmlDumpAttributeDecl xmlDumpAttributeDecl__internal_alias #endif #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_valid #undef xmlDumpAttributeTable extern __typeof (xmlDumpAttributeTable) xmlDumpAttributeTable __attribute((alias("xmlDumpAttributeTable__internal_alias"))); #else #ifndef xmlDumpAttributeTable extern __typeof (xmlDumpAttributeTable) xmlDumpAttributeTable__internal_alias __attribute((visibility("hidden"))); #define xmlDumpAttributeTable xmlDumpAttributeTable__internal_alias #endif #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_valid #undef xmlDumpElementDecl extern __typeof (xmlDumpElementDecl) xmlDumpElementDecl __attribute((alias("xmlDumpElementDecl__internal_alias"))); #else #ifndef xmlDumpElementDecl extern __typeof (xmlDumpElementDecl) xmlDumpElementDecl__internal_alias __attribute((visibility("hidden"))); #define xmlDumpElementDecl xmlDumpElementDecl__internal_alias #endif #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_valid #undef xmlDumpElementTable extern __typeof (xmlDumpElementTable) xmlDumpElementTable __attribute((alias("xmlDumpElementTable__internal_alias"))); #else #ifndef xmlDumpElementTable extern __typeof (xmlDumpElementTable) xmlDumpElementTable__internal_alias __attribute((visibility("hidden"))); #define xmlDumpElementTable xmlDumpElementTable__internal_alias #endif #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_entities #undef xmlDumpEntitiesTable extern __typeof (xmlDumpEntitiesTable) xmlDumpEntitiesTable __attribute((alias("xmlDumpEntitiesTable__internal_alias"))); #else #ifndef xmlDumpEntitiesTable extern __typeof (xmlDumpEntitiesTable) xmlDumpEntitiesTable__internal_alias __attribute((visibility("hidden"))); #define xmlDumpEntitiesTable xmlDumpEntitiesTable__internal_alias #endif #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_entities #undef xmlDumpEntityDecl extern __typeof (xmlDumpEntityDecl) xmlDumpEntityDecl __attribute((alias("xmlDumpEntityDecl__internal_alias"))); #else #ifndef xmlDumpEntityDecl extern __typeof (xmlDumpEntityDecl) xmlDumpEntityDecl__internal_alias __attribute((visibility("hidden"))); #define xmlDumpEntityDecl xmlDumpEntityDecl__internal_alias #endif #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_valid #undef xmlDumpNotationDecl extern __typeof (xmlDumpNotationDecl) xmlDumpNotationDecl __attribute((alias("xmlDumpNotationDecl__internal_alias"))); #else #ifndef xmlDumpNotationDecl extern __typeof (xmlDumpNotationDecl) xmlDumpNotationDecl__internal_alias __attribute((visibility("hidden"))); #define xmlDumpNotationDecl xmlDumpNotationDecl__internal_alias #endif #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_valid #undef xmlDumpNotationTable extern __typeof (xmlDumpNotationTable) xmlDumpNotationTable __attribute((alias("xmlDumpNotationTable__internal_alias"))); #else #ifndef xmlDumpNotationTable extern __typeof (xmlDumpNotationTable) xmlDumpNotationTable__internal_alias __attribute((visibility("hidden"))); #define xmlDumpNotationTable xmlDumpNotationTable__internal_alias #endif #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_xmlsave #undef xmlElemDump extern __typeof (xmlElemDump) xmlElemDump __attribute((alias("xmlElemDump__internal_alias"))); #else #ifndef xmlElemDump extern __typeof (xmlElemDump) xmlElemDump__internal_alias __attribute((visibility("hidden"))); #define xmlElemDump xmlElemDump__internal_alias #endif #endif #endif #if defined(LIBXML_LEGACY_ENABLED) #ifdef bottom_legacy #undef xmlEncodeEntities extern __typeof (xmlEncodeEntities) xmlEncodeEntities __attribute((alias("xmlEncodeEntities__internal_alias"))); #else #ifndef xmlEncodeEntities extern __typeof (xmlEncodeEntities) xmlEncodeEntities__internal_alias __attribute((visibility("hidden"))); #define xmlEncodeEntities xmlEncodeEntities__internal_alias #endif #endif #endif #ifdef bottom_entities #undef xmlEncodeEntitiesReentrant extern __typeof (xmlEncodeEntitiesReentrant) xmlEncodeEntitiesReentrant __attribute((alias("xmlEncodeEntitiesReentrant__internal_alias"))); #else #ifndef xmlEncodeEntitiesReentrant extern __typeof (xmlEncodeEntitiesReentrant) xmlEncodeEntitiesReentrant__internal_alias __attribute((visibility("hidden"))); #define xmlEncodeEntitiesReentrant xmlEncodeEntitiesReentrant__internal_alias #endif #endif #ifdef bottom_entities #undef xmlEncodeSpecialChars extern __typeof (xmlEncodeSpecialChars) xmlEncodeSpecialChars __attribute((alias("xmlEncodeSpecialChars__internal_alias"))); #else #ifndef xmlEncodeSpecialChars extern __typeof (xmlEncodeSpecialChars) xmlEncodeSpecialChars__internal_alias __attribute((visibility("hidden"))); #define xmlEncodeSpecialChars xmlEncodeSpecialChars__internal_alias #endif #endif #ifdef bottom_parserInternals #undef xmlErrMemory extern __typeof (xmlErrMemory) xmlErrMemory __attribute((alias("xmlErrMemory__internal_alias"))); #else #ifndef xmlErrMemory extern __typeof (xmlErrMemory) xmlErrMemory__internal_alias __attribute((visibility("hidden"))); #define xmlErrMemory xmlErrMemory__internal_alias #endif #endif #if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED) #ifdef bottom_xmlregexp #undef xmlExpCtxtNbCons extern __typeof (xmlExpCtxtNbCons) xmlExpCtxtNbCons __attribute((alias("xmlExpCtxtNbCons__internal_alias"))); #else #ifndef xmlExpCtxtNbCons extern __typeof (xmlExpCtxtNbCons) xmlExpCtxtNbCons__internal_alias __attribute((visibility("hidden"))); #define xmlExpCtxtNbCons xmlExpCtxtNbCons__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED) #ifdef bottom_xmlregexp #undef xmlExpCtxtNbNodes extern __typeof (xmlExpCtxtNbNodes) xmlExpCtxtNbNodes __attribute((alias("xmlExpCtxtNbNodes__internal_alias"))); #else #ifndef xmlExpCtxtNbNodes extern __typeof (xmlExpCtxtNbNodes) xmlExpCtxtNbNodes__internal_alias __attribute((visibility("hidden"))); #define xmlExpCtxtNbNodes xmlExpCtxtNbNodes__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED) #ifdef bottom_xmlregexp #undef xmlExpDump extern __typeof (xmlExpDump) xmlExpDump __attribute((alias("xmlExpDump__internal_alias"))); #else #ifndef xmlExpDump extern __typeof (xmlExpDump) xmlExpDump__internal_alias __attribute((visibility("hidden"))); #define xmlExpDump xmlExpDump__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED) #ifdef bottom_xmlregexp #undef xmlExpExpDerive extern __typeof (xmlExpExpDerive) xmlExpExpDerive __attribute((alias("xmlExpExpDerive__internal_alias"))); #else #ifndef xmlExpExpDerive extern __typeof (xmlExpExpDerive) xmlExpExpDerive__internal_alias __attribute((visibility("hidden"))); #define xmlExpExpDerive xmlExpExpDerive__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED) #ifdef bottom_xmlregexp #undef xmlExpFree extern __typeof (xmlExpFree) xmlExpFree __attribute((alias("xmlExpFree__internal_alias"))); #else #ifndef xmlExpFree extern __typeof (xmlExpFree) xmlExpFree__internal_alias __attribute((visibility("hidden"))); #define xmlExpFree xmlExpFree__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED) #ifdef bottom_xmlregexp #undef xmlExpFreeCtxt extern __typeof (xmlExpFreeCtxt) xmlExpFreeCtxt __attribute((alias("xmlExpFreeCtxt__internal_alias"))); #else #ifndef xmlExpFreeCtxt extern __typeof (xmlExpFreeCtxt) xmlExpFreeCtxt__internal_alias __attribute((visibility("hidden"))); #define xmlExpFreeCtxt xmlExpFreeCtxt__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED) #ifdef bottom_xmlregexp #undef xmlExpGetLanguage extern __typeof (xmlExpGetLanguage) xmlExpGetLanguage __attribute((alias("xmlExpGetLanguage__internal_alias"))); #else #ifndef xmlExpGetLanguage extern __typeof (xmlExpGetLanguage) xmlExpGetLanguage__internal_alias __attribute((visibility("hidden"))); #define xmlExpGetLanguage xmlExpGetLanguage__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED) #ifdef bottom_xmlregexp #undef xmlExpGetStart extern __typeof (xmlExpGetStart) xmlExpGetStart __attribute((alias("xmlExpGetStart__internal_alias"))); #else #ifndef xmlExpGetStart extern __typeof (xmlExpGetStart) xmlExpGetStart__internal_alias __attribute((visibility("hidden"))); #define xmlExpGetStart xmlExpGetStart__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED) #ifdef bottom_xmlregexp #undef xmlExpIsNillable extern __typeof (xmlExpIsNillable) xmlExpIsNillable __attribute((alias("xmlExpIsNillable__internal_alias"))); #else #ifndef xmlExpIsNillable extern __typeof (xmlExpIsNillable) xmlExpIsNillable__internal_alias __attribute((visibility("hidden"))); #define xmlExpIsNillable xmlExpIsNillable__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED) #ifdef bottom_xmlregexp #undef xmlExpMaxToken extern __typeof (xmlExpMaxToken) xmlExpMaxToken __attribute((alias("xmlExpMaxToken__internal_alias"))); #else #ifndef xmlExpMaxToken extern __typeof (xmlExpMaxToken) xmlExpMaxToken__internal_alias __attribute((visibility("hidden"))); #define xmlExpMaxToken xmlExpMaxToken__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED) #ifdef bottom_xmlregexp #undef xmlExpNewAtom extern __typeof (xmlExpNewAtom) xmlExpNewAtom __attribute((alias("xmlExpNewAtom__internal_alias"))); #else #ifndef xmlExpNewAtom extern __typeof (xmlExpNewAtom) xmlExpNewAtom__internal_alias __attribute((visibility("hidden"))); #define xmlExpNewAtom xmlExpNewAtom__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED) #ifdef bottom_xmlregexp #undef xmlExpNewCtxt extern __typeof (xmlExpNewCtxt) xmlExpNewCtxt __attribute((alias("xmlExpNewCtxt__internal_alias"))); #else #ifndef xmlExpNewCtxt extern __typeof (xmlExpNewCtxt) xmlExpNewCtxt__internal_alias __attribute((visibility("hidden"))); #define xmlExpNewCtxt xmlExpNewCtxt__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED) #ifdef bottom_xmlregexp #undef xmlExpNewOr extern __typeof (xmlExpNewOr) xmlExpNewOr __attribute((alias("xmlExpNewOr__internal_alias"))); #else #ifndef xmlExpNewOr extern __typeof (xmlExpNewOr) xmlExpNewOr__internal_alias __attribute((visibility("hidden"))); #define xmlExpNewOr xmlExpNewOr__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED) #ifdef bottom_xmlregexp #undef xmlExpNewRange extern __typeof (xmlExpNewRange) xmlExpNewRange __attribute((alias("xmlExpNewRange__internal_alias"))); #else #ifndef xmlExpNewRange extern __typeof (xmlExpNewRange) xmlExpNewRange__internal_alias __attribute((visibility("hidden"))); #define xmlExpNewRange xmlExpNewRange__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED) #ifdef bottom_xmlregexp #undef xmlExpNewSeq extern __typeof (xmlExpNewSeq) xmlExpNewSeq __attribute((alias("xmlExpNewSeq__internal_alias"))); #else #ifndef xmlExpNewSeq extern __typeof (xmlExpNewSeq) xmlExpNewSeq__internal_alias __attribute((visibility("hidden"))); #define xmlExpNewSeq xmlExpNewSeq__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED) #ifdef bottom_xmlregexp #undef xmlExpParse extern __typeof (xmlExpParse) xmlExpParse __attribute((alias("xmlExpParse__internal_alias"))); #else #ifndef xmlExpParse extern __typeof (xmlExpParse) xmlExpParse__internal_alias __attribute((visibility("hidden"))); #define xmlExpParse xmlExpParse__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED) #ifdef bottom_xmlregexp #undef xmlExpRef extern __typeof (xmlExpRef) xmlExpRef __attribute((alias("xmlExpRef__internal_alias"))); #else #ifndef xmlExpRef extern __typeof (xmlExpRef) xmlExpRef__internal_alias __attribute((visibility("hidden"))); #define xmlExpRef xmlExpRef__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED) #ifdef bottom_xmlregexp #undef xmlExpStringDerive extern __typeof (xmlExpStringDerive) xmlExpStringDerive __attribute((alias("xmlExpStringDerive__internal_alias"))); #else #ifndef xmlExpStringDerive extern __typeof (xmlExpStringDerive) xmlExpStringDerive__internal_alias __attribute((visibility("hidden"))); #define xmlExpStringDerive xmlExpStringDerive__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED) #ifdef bottom_xmlregexp #undef xmlExpSubsume extern __typeof (xmlExpSubsume) xmlExpSubsume __attribute((alias("xmlExpSubsume__internal_alias"))); #else #ifndef xmlExpSubsume extern __typeof (xmlExpSubsume) xmlExpSubsume__internal_alias __attribute((visibility("hidden"))); #define xmlExpSubsume xmlExpSubsume__internal_alias #endif #endif #endif #ifdef bottom_xmlIO #undef xmlFileClose extern __typeof (xmlFileClose) xmlFileClose __attribute((alias("xmlFileClose__internal_alias"))); #else #ifndef xmlFileClose extern __typeof (xmlFileClose) xmlFileClose__internal_alias __attribute((visibility("hidden"))); #define xmlFileClose xmlFileClose__internal_alias #endif #endif #ifdef bottom_xmlIO #undef xmlFileMatch extern __typeof (xmlFileMatch) xmlFileMatch __attribute((alias("xmlFileMatch__internal_alias"))); #else #ifndef xmlFileMatch extern __typeof (xmlFileMatch) xmlFileMatch__internal_alias __attribute((visibility("hidden"))); #define xmlFileMatch xmlFileMatch__internal_alias #endif #endif #ifdef bottom_xmlIO #undef xmlFileOpen extern __typeof (xmlFileOpen) xmlFileOpen __attribute((alias("xmlFileOpen__internal_alias"))); #else #ifndef xmlFileOpen extern __typeof (xmlFileOpen) xmlFileOpen__internal_alias __attribute((visibility("hidden"))); #define xmlFileOpen xmlFileOpen__internal_alias #endif #endif #ifdef bottom_xmlIO #undef xmlFileRead extern __typeof (xmlFileRead) xmlFileRead __attribute((alias("xmlFileRead__internal_alias"))); #else #ifndef xmlFileRead extern __typeof (xmlFileRead) xmlFileRead__internal_alias __attribute((visibility("hidden"))); #define xmlFileRead xmlFileRead__internal_alias #endif #endif #ifdef bottom_encoding #undef xmlFindCharEncodingHandler extern __typeof (xmlFindCharEncodingHandler) xmlFindCharEncodingHandler __attribute((alias("xmlFindCharEncodingHandler__internal_alias"))); #else #ifndef xmlFindCharEncodingHandler extern __typeof (xmlFindCharEncodingHandler) xmlFindCharEncodingHandler__internal_alias __attribute((visibility("hidden"))); #define xmlFindCharEncodingHandler xmlFindCharEncodingHandler__internal_alias #endif #endif #ifdef bottom_valid #undef xmlFreeAttributeTable extern __typeof (xmlFreeAttributeTable) xmlFreeAttributeTable __attribute((alias("xmlFreeAttributeTable__internal_alias"))); #else #ifndef xmlFreeAttributeTable extern __typeof (xmlFreeAttributeTable) xmlFreeAttributeTable__internal_alias __attribute((visibility("hidden"))); #define xmlFreeAttributeTable xmlFreeAttributeTable__internal_alias #endif #endif #if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED) #ifdef bottom_xmlregexp #undef xmlFreeAutomata extern __typeof (xmlFreeAutomata) xmlFreeAutomata __attribute((alias("xmlFreeAutomata__internal_alias"))); #else #ifndef xmlFreeAutomata extern __typeof (xmlFreeAutomata) xmlFreeAutomata__internal_alias __attribute((visibility("hidden"))); #define xmlFreeAutomata xmlFreeAutomata__internal_alias #endif #endif #endif #if defined(LIBXML_CATALOG_ENABLED) #ifdef bottom_catalog #undef xmlFreeCatalog extern __typeof (xmlFreeCatalog) xmlFreeCatalog __attribute((alias("xmlFreeCatalog__internal_alias"))); #else #ifndef xmlFreeCatalog extern __typeof (xmlFreeCatalog) xmlFreeCatalog__internal_alias __attribute((visibility("hidden"))); #define xmlFreeCatalog xmlFreeCatalog__internal_alias #endif #endif #endif #ifdef bottom_tree #undef xmlFreeDoc extern __typeof (xmlFreeDoc) xmlFreeDoc __attribute((alias("xmlFreeDoc__internal_alias"))); #else #ifndef xmlFreeDoc extern __typeof (xmlFreeDoc) xmlFreeDoc__internal_alias __attribute((visibility("hidden"))); #define xmlFreeDoc xmlFreeDoc__internal_alias #endif #endif #ifdef bottom_valid #undef xmlFreeDocElementContent extern __typeof (xmlFreeDocElementContent) xmlFreeDocElementContent __attribute((alias("xmlFreeDocElementContent__internal_alias"))); #else #ifndef xmlFreeDocElementContent extern __typeof (xmlFreeDocElementContent) xmlFreeDocElementContent__internal_alias __attribute((visibility("hidden"))); #define xmlFreeDocElementContent xmlFreeDocElementContent__internal_alias #endif #endif #ifdef bottom_tree #undef xmlFreeDtd extern __typeof (xmlFreeDtd) xmlFreeDtd __attribute((alias("xmlFreeDtd__internal_alias"))); #else #ifndef xmlFreeDtd extern __typeof (xmlFreeDtd) xmlFreeDtd__internal_alias __attribute((visibility("hidden"))); #define xmlFreeDtd xmlFreeDtd__internal_alias #endif #endif #ifdef bottom_valid #undef xmlFreeElementContent extern __typeof (xmlFreeElementContent) xmlFreeElementContent __attribute((alias("xmlFreeElementContent__internal_alias"))); #else #ifndef xmlFreeElementContent extern __typeof (xmlFreeElementContent) xmlFreeElementContent__internal_alias __attribute((visibility("hidden"))); #define xmlFreeElementContent xmlFreeElementContent__internal_alias #endif #endif #ifdef bottom_valid #undef xmlFreeElementTable extern __typeof (xmlFreeElementTable) xmlFreeElementTable __attribute((alias("xmlFreeElementTable__internal_alias"))); #else #ifndef xmlFreeElementTable extern __typeof (xmlFreeElementTable) xmlFreeElementTable__internal_alias __attribute((visibility("hidden"))); #define xmlFreeElementTable xmlFreeElementTable__internal_alias #endif #endif #ifdef bottom_entities #undef xmlFreeEntitiesTable extern __typeof (xmlFreeEntitiesTable) xmlFreeEntitiesTable __attribute((alias("xmlFreeEntitiesTable__internal_alias"))); #else #ifndef xmlFreeEntitiesTable extern __typeof (xmlFreeEntitiesTable) xmlFreeEntitiesTable__internal_alias __attribute((visibility("hidden"))); #define xmlFreeEntitiesTable xmlFreeEntitiesTable__internal_alias #endif #endif #ifdef bottom_valid #undef xmlFreeEnumeration extern __typeof (xmlFreeEnumeration) xmlFreeEnumeration __attribute((alias("xmlFreeEnumeration__internal_alias"))); #else #ifndef xmlFreeEnumeration extern __typeof (xmlFreeEnumeration) xmlFreeEnumeration__internal_alias __attribute((visibility("hidden"))); #define xmlFreeEnumeration xmlFreeEnumeration__internal_alias #endif #endif #ifdef bottom_valid #undef xmlFreeIDTable extern __typeof (xmlFreeIDTable) xmlFreeIDTable __attribute((alias("xmlFreeIDTable__internal_alias"))); #else #ifndef xmlFreeIDTable extern __typeof (xmlFreeIDTable) xmlFreeIDTable__internal_alias __attribute((visibility("hidden"))); #define xmlFreeIDTable xmlFreeIDTable__internal_alias #endif #endif #ifdef bottom_parserInternals #undef xmlFreeInputStream extern __typeof (xmlFreeInputStream) xmlFreeInputStream __attribute((alias("xmlFreeInputStream__internal_alias"))); #else #ifndef xmlFreeInputStream extern __typeof (xmlFreeInputStream) xmlFreeInputStream__internal_alias __attribute((visibility("hidden"))); #define xmlFreeInputStream xmlFreeInputStream__internal_alias #endif #endif #ifdef bottom_threads #undef xmlFreeMutex extern __typeof (xmlFreeMutex) xmlFreeMutex __attribute((alias("xmlFreeMutex__internal_alias"))); #else #ifndef xmlFreeMutex extern __typeof (xmlFreeMutex) xmlFreeMutex__internal_alias __attribute((visibility("hidden"))); #define xmlFreeMutex xmlFreeMutex__internal_alias #endif #endif #ifdef bottom_tree #undef xmlFreeNode extern __typeof (xmlFreeNode) xmlFreeNode __attribute((alias("xmlFreeNode__internal_alias"))); #else #ifndef xmlFreeNode extern __typeof (xmlFreeNode) xmlFreeNode__internal_alias __attribute((visibility("hidden"))); #define xmlFreeNode xmlFreeNode__internal_alias #endif #endif #ifdef bottom_tree #undef xmlFreeNodeList extern __typeof (xmlFreeNodeList) xmlFreeNodeList __attribute((alias("xmlFreeNodeList__internal_alias"))); #else #ifndef xmlFreeNodeList extern __typeof (xmlFreeNodeList) xmlFreeNodeList__internal_alias __attribute((visibility("hidden"))); #define xmlFreeNodeList xmlFreeNodeList__internal_alias #endif #endif #ifdef bottom_valid #undef xmlFreeNotationTable extern __typeof (xmlFreeNotationTable) xmlFreeNotationTable __attribute((alias("xmlFreeNotationTable__internal_alias"))); #else #ifndef xmlFreeNotationTable extern __typeof (xmlFreeNotationTable) xmlFreeNotationTable__internal_alias __attribute((visibility("hidden"))); #define xmlFreeNotationTable xmlFreeNotationTable__internal_alias #endif #endif #ifdef bottom_tree #undef xmlFreeNs extern __typeof (xmlFreeNs) xmlFreeNs __attribute((alias("xmlFreeNs__internal_alias"))); #else #ifndef xmlFreeNs extern __typeof (xmlFreeNs) xmlFreeNs__internal_alias __attribute((visibility("hidden"))); #define xmlFreeNs xmlFreeNs__internal_alias #endif #endif #ifdef bottom_tree #undef xmlFreeNsList extern __typeof (xmlFreeNsList) xmlFreeNsList __attribute((alias("xmlFreeNsList__internal_alias"))); #else #ifndef xmlFreeNsList extern __typeof (xmlFreeNsList) xmlFreeNsList__internal_alias __attribute((visibility("hidden"))); #define xmlFreeNsList xmlFreeNsList__internal_alias #endif #endif #ifdef bottom_parserInternals #undef xmlFreeParserCtxt extern __typeof (xmlFreeParserCtxt) xmlFreeParserCtxt __attribute((alias("xmlFreeParserCtxt__internal_alias"))); #else #ifndef xmlFreeParserCtxt extern __typeof (xmlFreeParserCtxt) xmlFreeParserCtxt__internal_alias __attribute((visibility("hidden"))); #define xmlFreeParserCtxt xmlFreeParserCtxt__internal_alias #endif #endif #ifdef bottom_xmlIO #undef xmlFreeParserInputBuffer extern __typeof (xmlFreeParserInputBuffer) xmlFreeParserInputBuffer __attribute((alias("xmlFreeParserInputBuffer__internal_alias"))); #else #ifndef xmlFreeParserInputBuffer extern __typeof (xmlFreeParserInputBuffer) xmlFreeParserInputBuffer__internal_alias __attribute((visibility("hidden"))); #define xmlFreeParserInputBuffer xmlFreeParserInputBuffer__internal_alias #endif #endif #if defined(LIBXML_PATTERN_ENABLED) #ifdef bottom_pattern #undef xmlFreePattern extern __typeof (xmlFreePattern) xmlFreePattern __attribute((alias("xmlFreePattern__internal_alias"))); #else #ifndef xmlFreePattern extern __typeof (xmlFreePattern) xmlFreePattern__internal_alias __attribute((visibility("hidden"))); #define xmlFreePattern xmlFreePattern__internal_alias #endif #endif #endif #if defined(LIBXML_PATTERN_ENABLED) #ifdef bottom_pattern #undef xmlFreePatternList extern __typeof (xmlFreePatternList) xmlFreePatternList __attribute((alias("xmlFreePatternList__internal_alias"))); #else #ifndef xmlFreePatternList extern __typeof (xmlFreePatternList) xmlFreePatternList__internal_alias __attribute((visibility("hidden"))); #define xmlFreePatternList xmlFreePatternList__internal_alias #endif #endif #endif #ifdef bottom_tree #undef xmlFreeProp extern __typeof (xmlFreeProp) xmlFreeProp __attribute((alias("xmlFreeProp__internal_alias"))); #else #ifndef xmlFreeProp extern __typeof (xmlFreeProp) xmlFreeProp__internal_alias __attribute((visibility("hidden"))); #define xmlFreeProp xmlFreeProp__internal_alias #endif #endif #ifdef bottom_tree #undef xmlFreePropList extern __typeof (xmlFreePropList) xmlFreePropList __attribute((alias("xmlFreePropList__internal_alias"))); #else #ifndef xmlFreePropList extern __typeof (xmlFreePropList) xmlFreePropList__internal_alias __attribute((visibility("hidden"))); #define xmlFreePropList xmlFreePropList__internal_alias #endif #endif #ifdef bottom_threads #undef xmlFreeRMutex extern __typeof (xmlFreeRMutex) xmlFreeRMutex __attribute((alias("xmlFreeRMutex__internal_alias"))); #else #ifndef xmlFreeRMutex extern __typeof (xmlFreeRMutex) xmlFreeRMutex__internal_alias __attribute((visibility("hidden"))); #define xmlFreeRMutex xmlFreeRMutex__internal_alias #endif #endif #ifdef bottom_valid #undef xmlFreeRefTable extern __typeof (xmlFreeRefTable) xmlFreeRefTable __attribute((alias("xmlFreeRefTable__internal_alias"))); #else #ifndef xmlFreeRefTable extern __typeof (xmlFreeRefTable) xmlFreeRefTable__internal_alias __attribute((visibility("hidden"))); #define xmlFreeRefTable xmlFreeRefTable__internal_alias #endif #endif #if defined(LIBXML_PATTERN_ENABLED) #ifdef bottom_pattern #undef xmlFreeStreamCtxt extern __typeof (xmlFreeStreamCtxt) xmlFreeStreamCtxt __attribute((alias("xmlFreeStreamCtxt__internal_alias"))); #else #ifndef xmlFreeStreamCtxt extern __typeof (xmlFreeStreamCtxt) xmlFreeStreamCtxt__internal_alias __attribute((visibility("hidden"))); #define xmlFreeStreamCtxt xmlFreeStreamCtxt__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlFreeTextReader extern __typeof (xmlFreeTextReader) xmlFreeTextReader __attribute((alias("xmlFreeTextReader__internal_alias"))); #else #ifndef xmlFreeTextReader extern __typeof (xmlFreeTextReader) xmlFreeTextReader__internal_alias __attribute((visibility("hidden"))); #define xmlFreeTextReader xmlFreeTextReader__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlFreeTextWriter extern __typeof (xmlFreeTextWriter) xmlFreeTextWriter __attribute((alias("xmlFreeTextWriter__internal_alias"))); #else #ifndef xmlFreeTextWriter extern __typeof (xmlFreeTextWriter) xmlFreeTextWriter__internal_alias __attribute((visibility("hidden"))); #define xmlFreeTextWriter xmlFreeTextWriter__internal_alias #endif #endif #endif #ifdef bottom_uri #undef xmlFreeURI extern __typeof (xmlFreeURI) xmlFreeURI __attribute((alias("xmlFreeURI__internal_alias"))); #else #ifndef xmlFreeURI extern __typeof (xmlFreeURI) xmlFreeURI__internal_alias __attribute((visibility("hidden"))); #define xmlFreeURI xmlFreeURI__internal_alias #endif #endif #if defined(LIBXML_VALID_ENABLED) #ifdef bottom_valid #undef xmlFreeValidCtxt extern __typeof (xmlFreeValidCtxt) xmlFreeValidCtxt __attribute((alias("xmlFreeValidCtxt__internal_alias"))); #else #ifndef xmlFreeValidCtxt extern __typeof (xmlFreeValidCtxt) xmlFreeValidCtxt__internal_alias __attribute((visibility("hidden"))); #define xmlFreeValidCtxt xmlFreeValidCtxt__internal_alias #endif #endif #endif #ifdef bottom_xmlmemory #undef xmlGcMemGet extern __typeof (xmlGcMemGet) xmlGcMemGet __attribute((alias("xmlGcMemGet__internal_alias"))); #else #ifndef xmlGcMemGet extern __typeof (xmlGcMemGet) xmlGcMemGet__internal_alias __attribute((visibility("hidden"))); #define xmlGcMemGet xmlGcMemGet__internal_alias #endif #endif #ifdef bottom_xmlmemory #undef xmlGcMemSetup extern __typeof (xmlGcMemSetup) xmlGcMemSetup __attribute((alias("xmlGcMemSetup__internal_alias"))); #else #ifndef xmlGcMemSetup extern __typeof (xmlGcMemSetup) xmlGcMemSetup__internal_alias __attribute((visibility("hidden"))); #define xmlGcMemSetup xmlGcMemSetup__internal_alias #endif #endif #ifdef bottom_tree #undef xmlGetBufferAllocationScheme extern __typeof (xmlGetBufferAllocationScheme) xmlGetBufferAllocationScheme __attribute((alias("xmlGetBufferAllocationScheme__internal_alias"))); #else #ifndef xmlGetBufferAllocationScheme extern __typeof (xmlGetBufferAllocationScheme) xmlGetBufferAllocationScheme__internal_alias __attribute((visibility("hidden"))); #define xmlGetBufferAllocationScheme xmlGetBufferAllocationScheme__internal_alias #endif #endif #ifdef bottom_encoding #undef xmlGetCharEncodingHandler extern __typeof (xmlGetCharEncodingHandler) xmlGetCharEncodingHandler __attribute((alias("xmlGetCharEncodingHandler__internal_alias"))); #else #ifndef xmlGetCharEncodingHandler extern __typeof (xmlGetCharEncodingHandler) xmlGetCharEncodingHandler__internal_alias __attribute((visibility("hidden"))); #define xmlGetCharEncodingHandler xmlGetCharEncodingHandler__internal_alias #endif #endif #ifdef bottom_encoding #undef xmlGetCharEncodingName extern __typeof (xmlGetCharEncodingName) xmlGetCharEncodingName __attribute((alias("xmlGetCharEncodingName__internal_alias"))); #else #ifndef xmlGetCharEncodingName extern __typeof (xmlGetCharEncodingName) xmlGetCharEncodingName__internal_alias __attribute((visibility("hidden"))); #define xmlGetCharEncodingName xmlGetCharEncodingName__internal_alias #endif #endif #ifdef bottom_tree #undef xmlGetCompressMode extern __typeof (xmlGetCompressMode) xmlGetCompressMode __attribute((alias("xmlGetCompressMode__internal_alias"))); #else #ifndef xmlGetCompressMode extern __typeof (xmlGetCompressMode) xmlGetCompressMode__internal_alias __attribute((visibility("hidden"))); #define xmlGetCompressMode xmlGetCompressMode__internal_alias #endif #endif #ifdef bottom_tree #undef xmlGetDocCompressMode extern __typeof (xmlGetDocCompressMode) xmlGetDocCompressMode __attribute((alias("xmlGetDocCompressMode__internal_alias"))); #else #ifndef xmlGetDocCompressMode extern __typeof (xmlGetDocCompressMode) xmlGetDocCompressMode__internal_alias __attribute((visibility("hidden"))); #define xmlGetDocCompressMode xmlGetDocCompressMode__internal_alias #endif #endif #ifdef bottom_entities #undef xmlGetDocEntity extern __typeof (xmlGetDocEntity) xmlGetDocEntity __attribute((alias("xmlGetDocEntity__internal_alias"))); #else #ifndef xmlGetDocEntity extern __typeof (xmlGetDocEntity) xmlGetDocEntity__internal_alias __attribute((visibility("hidden"))); #define xmlGetDocEntity xmlGetDocEntity__internal_alias #endif #endif #ifdef bottom_valid #undef xmlGetDtdAttrDesc extern __typeof (xmlGetDtdAttrDesc) xmlGetDtdAttrDesc __attribute((alias("xmlGetDtdAttrDesc__internal_alias"))); #else #ifndef xmlGetDtdAttrDesc extern __typeof (xmlGetDtdAttrDesc) xmlGetDtdAttrDesc__internal_alias __attribute((visibility("hidden"))); #define xmlGetDtdAttrDesc xmlGetDtdAttrDesc__internal_alias #endif #endif #ifdef bottom_valid #undef xmlGetDtdElementDesc extern __typeof (xmlGetDtdElementDesc) xmlGetDtdElementDesc __attribute((alias("xmlGetDtdElementDesc__internal_alias"))); #else #ifndef xmlGetDtdElementDesc extern __typeof (xmlGetDtdElementDesc) xmlGetDtdElementDesc__internal_alias __attribute((visibility("hidden"))); #define xmlGetDtdElementDesc xmlGetDtdElementDesc__internal_alias #endif #endif #ifdef bottom_entities #undef xmlGetDtdEntity extern __typeof (xmlGetDtdEntity) xmlGetDtdEntity __attribute((alias("xmlGetDtdEntity__internal_alias"))); #else #ifndef xmlGetDtdEntity extern __typeof (xmlGetDtdEntity) xmlGetDtdEntity__internal_alias __attribute((visibility("hidden"))); #define xmlGetDtdEntity xmlGetDtdEntity__internal_alias #endif #endif #ifdef bottom_valid #undef xmlGetDtdNotationDesc extern __typeof (xmlGetDtdNotationDesc) xmlGetDtdNotationDesc __attribute((alias("xmlGetDtdNotationDesc__internal_alias"))); #else #ifndef xmlGetDtdNotationDesc extern __typeof (xmlGetDtdNotationDesc) xmlGetDtdNotationDesc__internal_alias __attribute((visibility("hidden"))); #define xmlGetDtdNotationDesc xmlGetDtdNotationDesc__internal_alias #endif #endif #ifdef bottom_valid #undef xmlGetDtdQAttrDesc extern __typeof (xmlGetDtdQAttrDesc) xmlGetDtdQAttrDesc __attribute((alias("xmlGetDtdQAttrDesc__internal_alias"))); #else #ifndef xmlGetDtdQAttrDesc extern __typeof (xmlGetDtdQAttrDesc) xmlGetDtdQAttrDesc__internal_alias __attribute((visibility("hidden"))); #define xmlGetDtdQAttrDesc xmlGetDtdQAttrDesc__internal_alias #endif #endif #ifdef bottom_valid #undef xmlGetDtdQElementDesc extern __typeof (xmlGetDtdQElementDesc) xmlGetDtdQElementDesc __attribute((alias("xmlGetDtdQElementDesc__internal_alias"))); #else #ifndef xmlGetDtdQElementDesc extern __typeof (xmlGetDtdQElementDesc) xmlGetDtdQElementDesc__internal_alias __attribute((visibility("hidden"))); #define xmlGetDtdQElementDesc xmlGetDtdQElementDesc__internal_alias #endif #endif #ifdef bottom_encoding #undef xmlGetEncodingAlias extern __typeof (xmlGetEncodingAlias) xmlGetEncodingAlias __attribute((alias("xmlGetEncodingAlias__internal_alias"))); #else #ifndef xmlGetEncodingAlias extern __typeof (xmlGetEncodingAlias) xmlGetEncodingAlias__internal_alias __attribute((visibility("hidden"))); #define xmlGetEncodingAlias xmlGetEncodingAlias__internal_alias #endif #endif #ifdef bottom_xmlIO #undef xmlGetExternalEntityLoader extern __typeof (xmlGetExternalEntityLoader) xmlGetExternalEntityLoader __attribute((alias("xmlGetExternalEntityLoader__internal_alias"))); #else #ifndef xmlGetExternalEntityLoader extern __typeof (xmlGetExternalEntityLoader) xmlGetExternalEntityLoader__internal_alias __attribute((visibility("hidden"))); #define xmlGetExternalEntityLoader xmlGetExternalEntityLoader__internal_alias #endif #endif #if defined(LIBXML_LEGACY_ENABLED) #ifdef bottom_legacy #undef xmlGetFeature extern __typeof (xmlGetFeature) xmlGetFeature __attribute((alias("xmlGetFeature__internal_alias"))); #else #ifndef xmlGetFeature extern __typeof (xmlGetFeature) xmlGetFeature__internal_alias __attribute((visibility("hidden"))); #define xmlGetFeature xmlGetFeature__internal_alias #endif #endif #endif #if defined(LIBXML_LEGACY_ENABLED) #ifdef bottom_legacy #undef xmlGetFeaturesList extern __typeof (xmlGetFeaturesList) xmlGetFeaturesList __attribute((alias("xmlGetFeaturesList__internal_alias"))); #else #ifndef xmlGetFeaturesList extern __typeof (xmlGetFeaturesList) xmlGetFeaturesList__internal_alias __attribute((visibility("hidden"))); #define xmlGetFeaturesList xmlGetFeaturesList__internal_alias #endif #endif #endif #ifdef bottom_threads #undef xmlGetGlobalState extern __typeof (xmlGetGlobalState) xmlGetGlobalState __attribute((alias("xmlGetGlobalState__internal_alias"))); #else #ifndef xmlGetGlobalState extern __typeof (xmlGetGlobalState) xmlGetGlobalState__internal_alias __attribute((visibility("hidden"))); #define xmlGetGlobalState xmlGetGlobalState__internal_alias #endif #endif #ifdef bottom_valid #undef xmlGetID extern __typeof (xmlGetID) xmlGetID __attribute((alias("xmlGetID__internal_alias"))); #else #ifndef xmlGetID extern __typeof (xmlGetID) xmlGetID__internal_alias __attribute((visibility("hidden"))); #define xmlGetID xmlGetID__internal_alias #endif #endif #ifdef bottom_tree #undef xmlGetIntSubset extern __typeof (xmlGetIntSubset) xmlGetIntSubset __attribute((alias("xmlGetIntSubset__internal_alias"))); #else #ifndef xmlGetIntSubset extern __typeof (xmlGetIntSubset) xmlGetIntSubset__internal_alias __attribute((visibility("hidden"))); #define xmlGetIntSubset xmlGetIntSubset__internal_alias #endif #endif #ifdef bottom_tree #undef xmlGetLastChild extern __typeof (xmlGetLastChild) xmlGetLastChild __attribute((alias("xmlGetLastChild__internal_alias"))); #else #ifndef xmlGetLastChild extern __typeof (xmlGetLastChild) xmlGetLastChild__internal_alias __attribute((visibility("hidden"))); #define xmlGetLastChild xmlGetLastChild__internal_alias #endif #endif #ifdef bottom_error #undef xmlGetLastError extern __typeof (xmlGetLastError) xmlGetLastError __attribute((alias("xmlGetLastError__internal_alias"))); #else #ifndef xmlGetLastError extern __typeof (xmlGetLastError) xmlGetLastError__internal_alias __attribute((visibility("hidden"))); #define xmlGetLastError xmlGetLastError__internal_alias #endif #endif #ifdef bottom_tree #undef xmlGetLineNo extern __typeof (xmlGetLineNo) xmlGetLineNo __attribute((alias("xmlGetLineNo__internal_alias"))); #else #ifndef xmlGetLineNo extern __typeof (xmlGetLineNo) xmlGetLineNo__internal_alias __attribute((visibility("hidden"))); #define xmlGetLineNo xmlGetLineNo__internal_alias #endif #endif #ifdef bottom_tree #undef xmlGetNoNsProp extern __typeof (xmlGetNoNsProp) xmlGetNoNsProp __attribute((alias("xmlGetNoNsProp__internal_alias"))); #else #ifndef xmlGetNoNsProp extern __typeof (xmlGetNoNsProp) xmlGetNoNsProp__internal_alias __attribute((visibility("hidden"))); #define xmlGetNoNsProp xmlGetNoNsProp__internal_alias #endif #endif #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_DEBUG_ENABLED) #ifdef bottom_tree #undef xmlGetNodePath extern __typeof (xmlGetNodePath) xmlGetNodePath __attribute((alias("xmlGetNodePath__internal_alias"))); #else #ifndef xmlGetNodePath extern __typeof (xmlGetNodePath) xmlGetNodePath__internal_alias __attribute((visibility("hidden"))); #define xmlGetNodePath xmlGetNodePath__internal_alias #endif #endif #endif #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) #ifdef bottom_tree #undef xmlGetNsList extern __typeof (xmlGetNsList) xmlGetNsList __attribute((alias("xmlGetNsList__internal_alias"))); #else #ifndef xmlGetNsList extern __typeof (xmlGetNsList) xmlGetNsList__internal_alias __attribute((visibility("hidden"))); #define xmlGetNsList xmlGetNsList__internal_alias #endif #endif #endif #ifdef bottom_tree #undef xmlGetNsProp extern __typeof (xmlGetNsProp) xmlGetNsProp __attribute((alias("xmlGetNsProp__internal_alias"))); #else #ifndef xmlGetNsProp extern __typeof (xmlGetNsProp) xmlGetNsProp__internal_alias __attribute((visibility("hidden"))); #define xmlGetNsProp xmlGetNsProp__internal_alias #endif #endif #ifdef bottom_entities #undef xmlGetParameterEntity extern __typeof (xmlGetParameterEntity) xmlGetParameterEntity __attribute((alias("xmlGetParameterEntity__internal_alias"))); #else #ifndef xmlGetParameterEntity extern __typeof (xmlGetParameterEntity) xmlGetParameterEntity__internal_alias __attribute((visibility("hidden"))); #define xmlGetParameterEntity xmlGetParameterEntity__internal_alias #endif #endif #ifdef bottom_entities #undef xmlGetPredefinedEntity extern __typeof (xmlGetPredefinedEntity) xmlGetPredefinedEntity __attribute((alias("xmlGetPredefinedEntity__internal_alias"))); #else #ifndef xmlGetPredefinedEntity extern __typeof (xmlGetPredefinedEntity) xmlGetPredefinedEntity__internal_alias __attribute((visibility("hidden"))); #define xmlGetPredefinedEntity xmlGetPredefinedEntity__internal_alias #endif #endif #ifdef bottom_tree #undef xmlGetProp extern __typeof (xmlGetProp) xmlGetProp __attribute((alias("xmlGetProp__internal_alias"))); #else #ifndef xmlGetProp extern __typeof (xmlGetProp) xmlGetProp__internal_alias __attribute((visibility("hidden"))); #define xmlGetProp xmlGetProp__internal_alias #endif #endif #ifdef bottom_valid #undef xmlGetRefs extern __typeof (xmlGetRefs) xmlGetRefs __attribute((alias("xmlGetRefs__internal_alias"))); #else #ifndef xmlGetRefs extern __typeof (xmlGetRefs) xmlGetRefs__internal_alias __attribute((visibility("hidden"))); #define xmlGetRefs xmlGetRefs__internal_alias #endif #endif #ifdef bottom_threads #undef xmlGetThreadId extern __typeof (xmlGetThreadId) xmlGetThreadId __attribute((alias("xmlGetThreadId__internal_alias"))); #else #ifndef xmlGetThreadId extern __typeof (xmlGetThreadId) xmlGetThreadId__internal_alias __attribute((visibility("hidden"))); #define xmlGetThreadId xmlGetThreadId__internal_alias #endif #endif #ifdef bottom_xmlstring #undef xmlGetUTF8Char extern __typeof (xmlGetUTF8Char) xmlGetUTF8Char __attribute((alias("xmlGetUTF8Char__internal_alias"))); #else #ifndef xmlGetUTF8Char extern __typeof (xmlGetUTF8Char) xmlGetUTF8Char__internal_alias __attribute((visibility("hidden"))); #define xmlGetUTF8Char xmlGetUTF8Char__internal_alias #endif #endif #if defined(LIBXML_LEGACY_ENABLED) #ifdef bottom_legacy #undef xmlHandleEntity extern __typeof (xmlHandleEntity) xmlHandleEntity __attribute((alias("xmlHandleEntity__internal_alias"))); #else #ifndef xmlHandleEntity extern __typeof (xmlHandleEntity) xmlHandleEntity__internal_alias __attribute((visibility("hidden"))); #define xmlHandleEntity xmlHandleEntity__internal_alias #endif #endif #endif #ifdef bottom_parser #undef xmlHasFeature extern __typeof (xmlHasFeature) xmlHasFeature __attribute((alias("xmlHasFeature__internal_alias"))); #else #ifndef xmlHasFeature extern __typeof (xmlHasFeature) xmlHasFeature__internal_alias __attribute((visibility("hidden"))); #define xmlHasFeature xmlHasFeature__internal_alias #endif #endif #ifdef bottom_tree #undef xmlHasNsProp extern __typeof (xmlHasNsProp) xmlHasNsProp __attribute((alias("xmlHasNsProp__internal_alias"))); #else #ifndef xmlHasNsProp extern __typeof (xmlHasNsProp) xmlHasNsProp__internal_alias __attribute((visibility("hidden"))); #define xmlHasNsProp xmlHasNsProp__internal_alias #endif #endif #ifdef bottom_tree #undef xmlHasProp extern __typeof (xmlHasProp) xmlHasProp __attribute((alias("xmlHasProp__internal_alias"))); #else #ifndef xmlHasProp extern __typeof (xmlHasProp) xmlHasProp__internal_alias __attribute((visibility("hidden"))); #define xmlHasProp xmlHasProp__internal_alias #endif #endif #ifdef bottom_hash #undef xmlHashAddEntry extern __typeof (xmlHashAddEntry) xmlHashAddEntry __attribute((alias("xmlHashAddEntry__internal_alias"))); #else #ifndef xmlHashAddEntry extern __typeof (xmlHashAddEntry) xmlHashAddEntry__internal_alias __attribute((visibility("hidden"))); #define xmlHashAddEntry xmlHashAddEntry__internal_alias #endif #endif #ifdef bottom_hash #undef xmlHashAddEntry2 extern __typeof (xmlHashAddEntry2) xmlHashAddEntry2 __attribute((alias("xmlHashAddEntry2__internal_alias"))); #else #ifndef xmlHashAddEntry2 extern __typeof (xmlHashAddEntry2) xmlHashAddEntry2__internal_alias __attribute((visibility("hidden"))); #define xmlHashAddEntry2 xmlHashAddEntry2__internal_alias #endif #endif #ifdef bottom_hash #undef xmlHashAddEntry3 extern __typeof (xmlHashAddEntry3) xmlHashAddEntry3 __attribute((alias("xmlHashAddEntry3__internal_alias"))); #else #ifndef xmlHashAddEntry3 extern __typeof (xmlHashAddEntry3) xmlHashAddEntry3__internal_alias __attribute((visibility("hidden"))); #define xmlHashAddEntry3 xmlHashAddEntry3__internal_alias #endif #endif #ifdef bottom_hash #undef xmlHashCopy extern __typeof (xmlHashCopy) xmlHashCopy __attribute((alias("xmlHashCopy__internal_alias"))); #else #ifndef xmlHashCopy extern __typeof (xmlHashCopy) xmlHashCopy__internal_alias __attribute((visibility("hidden"))); #define xmlHashCopy xmlHashCopy__internal_alias #endif #endif #ifdef bottom_hash #undef xmlHashCreate extern __typeof (xmlHashCreate) xmlHashCreate __attribute((alias("xmlHashCreate__internal_alias"))); #else #ifndef xmlHashCreate extern __typeof (xmlHashCreate) xmlHashCreate__internal_alias __attribute((visibility("hidden"))); #define xmlHashCreate xmlHashCreate__internal_alias #endif #endif #ifdef bottom_hash #undef xmlHashCreateDict extern __typeof (xmlHashCreateDict) xmlHashCreateDict __attribute((alias("xmlHashCreateDict__internal_alias"))); #else #ifndef xmlHashCreateDict extern __typeof (xmlHashCreateDict) xmlHashCreateDict__internal_alias __attribute((visibility("hidden"))); #define xmlHashCreateDict xmlHashCreateDict__internal_alias #endif #endif #ifdef bottom_hash #undef xmlHashFree extern __typeof (xmlHashFree) xmlHashFree __attribute((alias("xmlHashFree__internal_alias"))); #else #ifndef xmlHashFree extern __typeof (xmlHashFree) xmlHashFree__internal_alias __attribute((visibility("hidden"))); #define xmlHashFree xmlHashFree__internal_alias #endif #endif #ifdef bottom_hash #undef xmlHashLookup extern __typeof (xmlHashLookup) xmlHashLookup __attribute((alias("xmlHashLookup__internal_alias"))); #else #ifndef xmlHashLookup extern __typeof (xmlHashLookup) xmlHashLookup__internal_alias __attribute((visibility("hidden"))); #define xmlHashLookup xmlHashLookup__internal_alias #endif #endif #ifdef bottom_hash #undef xmlHashLookup2 extern __typeof (xmlHashLookup2) xmlHashLookup2 __attribute((alias("xmlHashLookup2__internal_alias"))); #else #ifndef xmlHashLookup2 extern __typeof (xmlHashLookup2) xmlHashLookup2__internal_alias __attribute((visibility("hidden"))); #define xmlHashLookup2 xmlHashLookup2__internal_alias #endif #endif #ifdef bottom_hash #undef xmlHashLookup3 extern __typeof (xmlHashLookup3) xmlHashLookup3 __attribute((alias("xmlHashLookup3__internal_alias"))); #else #ifndef xmlHashLookup3 extern __typeof (xmlHashLookup3) xmlHashLookup3__internal_alias __attribute((visibility("hidden"))); #define xmlHashLookup3 xmlHashLookup3__internal_alias #endif #endif #ifdef bottom_hash #undef xmlHashQLookup extern __typeof (xmlHashQLookup) xmlHashQLookup __attribute((alias("xmlHashQLookup__internal_alias"))); #else #ifndef xmlHashQLookup extern __typeof (xmlHashQLookup) xmlHashQLookup__internal_alias __attribute((visibility("hidden"))); #define xmlHashQLookup xmlHashQLookup__internal_alias #endif #endif #ifdef bottom_hash #undef xmlHashQLookup2 extern __typeof (xmlHashQLookup2) xmlHashQLookup2 __attribute((alias("xmlHashQLookup2__internal_alias"))); #else #ifndef xmlHashQLookup2 extern __typeof (xmlHashQLookup2) xmlHashQLookup2__internal_alias __attribute((visibility("hidden"))); #define xmlHashQLookup2 xmlHashQLookup2__internal_alias #endif #endif #ifdef bottom_hash #undef xmlHashQLookup3 extern __typeof (xmlHashQLookup3) xmlHashQLookup3 __attribute((alias("xmlHashQLookup3__internal_alias"))); #else #ifndef xmlHashQLookup3 extern __typeof (xmlHashQLookup3) xmlHashQLookup3__internal_alias __attribute((visibility("hidden"))); #define xmlHashQLookup3 xmlHashQLookup3__internal_alias #endif #endif #ifdef bottom_hash #undef xmlHashRemoveEntry extern __typeof (xmlHashRemoveEntry) xmlHashRemoveEntry __attribute((alias("xmlHashRemoveEntry__internal_alias"))); #else #ifndef xmlHashRemoveEntry extern __typeof (xmlHashRemoveEntry) xmlHashRemoveEntry__internal_alias __attribute((visibility("hidden"))); #define xmlHashRemoveEntry xmlHashRemoveEntry__internal_alias #endif #endif #ifdef bottom_hash #undef xmlHashRemoveEntry2 extern __typeof (xmlHashRemoveEntry2) xmlHashRemoveEntry2 __attribute((alias("xmlHashRemoveEntry2__internal_alias"))); #else #ifndef xmlHashRemoveEntry2 extern __typeof (xmlHashRemoveEntry2) xmlHashRemoveEntry2__internal_alias __attribute((visibility("hidden"))); #define xmlHashRemoveEntry2 xmlHashRemoveEntry2__internal_alias #endif #endif #ifdef bottom_hash #undef xmlHashRemoveEntry3 extern __typeof (xmlHashRemoveEntry3) xmlHashRemoveEntry3 __attribute((alias("xmlHashRemoveEntry3__internal_alias"))); #else #ifndef xmlHashRemoveEntry3 extern __typeof (xmlHashRemoveEntry3) xmlHashRemoveEntry3__internal_alias __attribute((visibility("hidden"))); #define xmlHashRemoveEntry3 xmlHashRemoveEntry3__internal_alias #endif #endif #ifdef bottom_hash #undef xmlHashScan extern __typeof (xmlHashScan) xmlHashScan __attribute((alias("xmlHashScan__internal_alias"))); #else #ifndef xmlHashScan extern __typeof (xmlHashScan) xmlHashScan__internal_alias __attribute((visibility("hidden"))); #define xmlHashScan xmlHashScan__internal_alias #endif #endif #ifdef bottom_hash #undef xmlHashScan3 extern __typeof (xmlHashScan3) xmlHashScan3 __attribute((alias("xmlHashScan3__internal_alias"))); #else #ifndef xmlHashScan3 extern __typeof (xmlHashScan3) xmlHashScan3__internal_alias __attribute((visibility("hidden"))); #define xmlHashScan3 xmlHashScan3__internal_alias #endif #endif #ifdef bottom_hash #undef xmlHashScanFull extern __typeof (xmlHashScanFull) xmlHashScanFull __attribute((alias("xmlHashScanFull__internal_alias"))); #else #ifndef xmlHashScanFull extern __typeof (xmlHashScanFull) xmlHashScanFull__internal_alias __attribute((visibility("hidden"))); #define xmlHashScanFull xmlHashScanFull__internal_alias #endif #endif #ifdef bottom_hash #undef xmlHashScanFull3 extern __typeof (xmlHashScanFull3) xmlHashScanFull3 __attribute((alias("xmlHashScanFull3__internal_alias"))); #else #ifndef xmlHashScanFull3 extern __typeof (xmlHashScanFull3) xmlHashScanFull3__internal_alias __attribute((visibility("hidden"))); #define xmlHashScanFull3 xmlHashScanFull3__internal_alias #endif #endif #ifdef bottom_hash #undef xmlHashSize extern __typeof (xmlHashSize) xmlHashSize __attribute((alias("xmlHashSize__internal_alias"))); #else #ifndef xmlHashSize extern __typeof (xmlHashSize) xmlHashSize__internal_alias __attribute((visibility("hidden"))); #define xmlHashSize xmlHashSize__internal_alias #endif #endif #ifdef bottom_hash #undef xmlHashUpdateEntry extern __typeof (xmlHashUpdateEntry) xmlHashUpdateEntry __attribute((alias("xmlHashUpdateEntry__internal_alias"))); #else #ifndef xmlHashUpdateEntry extern __typeof (xmlHashUpdateEntry) xmlHashUpdateEntry__internal_alias __attribute((visibility("hidden"))); #define xmlHashUpdateEntry xmlHashUpdateEntry__internal_alias #endif #endif #ifdef bottom_hash #undef xmlHashUpdateEntry2 extern __typeof (xmlHashUpdateEntry2) xmlHashUpdateEntry2 __attribute((alias("xmlHashUpdateEntry2__internal_alias"))); #else #ifndef xmlHashUpdateEntry2 extern __typeof (xmlHashUpdateEntry2) xmlHashUpdateEntry2__internal_alias __attribute((visibility("hidden"))); #define xmlHashUpdateEntry2 xmlHashUpdateEntry2__internal_alias #endif #endif #ifdef bottom_hash #undef xmlHashUpdateEntry3 extern __typeof (xmlHashUpdateEntry3) xmlHashUpdateEntry3 __attribute((alias("xmlHashUpdateEntry3__internal_alias"))); #else #ifndef xmlHashUpdateEntry3 extern __typeof (xmlHashUpdateEntry3) xmlHashUpdateEntry3__internal_alias __attribute((visibility("hidden"))); #define xmlHashUpdateEntry3 xmlHashUpdateEntry3__internal_alias #endif #endif #if defined(LIBXML_FTP_ENABLED) #ifdef bottom_xmlIO #undef xmlIOFTPClose extern __typeof (xmlIOFTPClose) xmlIOFTPClose __attribute((alias("xmlIOFTPClose__internal_alias"))); #else #ifndef xmlIOFTPClose extern __typeof (xmlIOFTPClose) xmlIOFTPClose__internal_alias __attribute((visibility("hidden"))); #define xmlIOFTPClose xmlIOFTPClose__internal_alias #endif #endif #endif #if defined(LIBXML_FTP_ENABLED) #ifdef bottom_xmlIO #undef xmlIOFTPMatch extern __typeof (xmlIOFTPMatch) xmlIOFTPMatch __attribute((alias("xmlIOFTPMatch__internal_alias"))); #else #ifndef xmlIOFTPMatch extern __typeof (xmlIOFTPMatch) xmlIOFTPMatch__internal_alias __attribute((visibility("hidden"))); #define xmlIOFTPMatch xmlIOFTPMatch__internal_alias #endif #endif #endif #if defined(LIBXML_FTP_ENABLED) #ifdef bottom_xmlIO #undef xmlIOFTPOpen extern __typeof (xmlIOFTPOpen) xmlIOFTPOpen __attribute((alias("xmlIOFTPOpen__internal_alias"))); #else #ifndef xmlIOFTPOpen extern __typeof (xmlIOFTPOpen) xmlIOFTPOpen__internal_alias __attribute((visibility("hidden"))); #define xmlIOFTPOpen xmlIOFTPOpen__internal_alias #endif #endif #endif #if defined(LIBXML_FTP_ENABLED) #ifdef bottom_xmlIO #undef xmlIOFTPRead extern __typeof (xmlIOFTPRead) xmlIOFTPRead __attribute((alias("xmlIOFTPRead__internal_alias"))); #else #ifndef xmlIOFTPRead extern __typeof (xmlIOFTPRead) xmlIOFTPRead__internal_alias __attribute((visibility("hidden"))); #define xmlIOFTPRead xmlIOFTPRead__internal_alias #endif #endif #endif #if defined(LIBXML_HTTP_ENABLED) #ifdef bottom_xmlIO #undef xmlIOHTTPClose extern __typeof (xmlIOHTTPClose) xmlIOHTTPClose __attribute((alias("xmlIOHTTPClose__internal_alias"))); #else #ifndef xmlIOHTTPClose extern __typeof (xmlIOHTTPClose) xmlIOHTTPClose__internal_alias __attribute((visibility("hidden"))); #define xmlIOHTTPClose xmlIOHTTPClose__internal_alias #endif #endif #endif #if defined(LIBXML_HTTP_ENABLED) #ifdef bottom_xmlIO #undef xmlIOHTTPMatch extern __typeof (xmlIOHTTPMatch) xmlIOHTTPMatch __attribute((alias("xmlIOHTTPMatch__internal_alias"))); #else #ifndef xmlIOHTTPMatch extern __typeof (xmlIOHTTPMatch) xmlIOHTTPMatch__internal_alias __attribute((visibility("hidden"))); #define xmlIOHTTPMatch xmlIOHTTPMatch__internal_alias #endif #endif #endif #if defined(LIBXML_HTTP_ENABLED) #ifdef bottom_xmlIO #undef xmlIOHTTPOpen extern __typeof (xmlIOHTTPOpen) xmlIOHTTPOpen __attribute((alias("xmlIOHTTPOpen__internal_alias"))); #else #ifndef xmlIOHTTPOpen extern __typeof (xmlIOHTTPOpen) xmlIOHTTPOpen__internal_alias __attribute((visibility("hidden"))); #define xmlIOHTTPOpen xmlIOHTTPOpen__internal_alias #endif #endif #endif #if defined(LIBXML_HTTP_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_xmlIO #undef xmlIOHTTPOpenW extern __typeof (xmlIOHTTPOpenW) xmlIOHTTPOpenW __attribute((alias("xmlIOHTTPOpenW__internal_alias"))); #else #ifndef xmlIOHTTPOpenW extern __typeof (xmlIOHTTPOpenW) xmlIOHTTPOpenW__internal_alias __attribute((visibility("hidden"))); #define xmlIOHTTPOpenW xmlIOHTTPOpenW__internal_alias #endif #endif #endif #if defined(LIBXML_HTTP_ENABLED) #ifdef bottom_xmlIO #undef xmlIOHTTPRead extern __typeof (xmlIOHTTPRead) xmlIOHTTPRead __attribute((alias("xmlIOHTTPRead__internal_alias"))); #else #ifndef xmlIOHTTPRead extern __typeof (xmlIOHTTPRead) xmlIOHTTPRead__internal_alias __attribute((visibility("hidden"))); #define xmlIOHTTPRead xmlIOHTTPRead__internal_alias #endif #endif #endif #if defined(LIBXML_VALID_ENABLED) #ifdef bottom_parser #undef xmlIOParseDTD extern __typeof (xmlIOParseDTD) xmlIOParseDTD __attribute((alias("xmlIOParseDTD__internal_alias"))); #else #ifndef xmlIOParseDTD extern __typeof (xmlIOParseDTD) xmlIOParseDTD__internal_alias __attribute((visibility("hidden"))); #define xmlIOParseDTD xmlIOParseDTD__internal_alias #endif #endif #endif #ifdef bottom_encoding #undef xmlInitCharEncodingHandlers extern __typeof (xmlInitCharEncodingHandlers) xmlInitCharEncodingHandlers __attribute((alias("xmlInitCharEncodingHandlers__internal_alias"))); #else #ifndef xmlInitCharEncodingHandlers extern __typeof (xmlInitCharEncodingHandlers) xmlInitCharEncodingHandlers__internal_alias __attribute((visibility("hidden"))); #define xmlInitCharEncodingHandlers xmlInitCharEncodingHandlers__internal_alias #endif #endif #ifdef bottom_globals #undef xmlInitGlobals extern __typeof (xmlInitGlobals) xmlInitGlobals __attribute((alias("xmlInitGlobals__internal_alias"))); #else #ifndef xmlInitGlobals extern __typeof (xmlInitGlobals) xmlInitGlobals__internal_alias __attribute((visibility("hidden"))); #define xmlInitGlobals xmlInitGlobals__internal_alias #endif #endif #ifdef bottom_xmlmemory #undef xmlInitMemory extern __typeof (xmlInitMemory) xmlInitMemory __attribute((alias("xmlInitMemory__internal_alias"))); #else #ifndef xmlInitMemory extern __typeof (xmlInitMemory) xmlInitMemory__internal_alias __attribute((visibility("hidden"))); #define xmlInitMemory xmlInitMemory__internal_alias #endif #endif #ifdef bottom_parserInternals #undef xmlInitNodeInfoSeq extern __typeof (xmlInitNodeInfoSeq) xmlInitNodeInfoSeq __attribute((alias("xmlInitNodeInfoSeq__internal_alias"))); #else #ifndef xmlInitNodeInfoSeq extern __typeof (xmlInitNodeInfoSeq) xmlInitNodeInfoSeq__internal_alias __attribute((visibility("hidden"))); #define xmlInitNodeInfoSeq xmlInitNodeInfoSeq__internal_alias #endif #endif #ifdef bottom_parser #undef xmlInitParser extern __typeof (xmlInitParser) xmlInitParser __attribute((alias("xmlInitParser__internal_alias"))); #else #ifndef xmlInitParser extern __typeof (xmlInitParser) xmlInitParser__internal_alias __attribute((visibility("hidden"))); #define xmlInitParser xmlInitParser__internal_alias #endif #endif #ifdef bottom_parserInternals #undef xmlInitParserCtxt extern __typeof (xmlInitParserCtxt) xmlInitParserCtxt __attribute((alias("xmlInitParserCtxt__internal_alias"))); #else #ifndef xmlInitParserCtxt extern __typeof (xmlInitParserCtxt) xmlInitParserCtxt__internal_alias __attribute((visibility("hidden"))); #define xmlInitParserCtxt xmlInitParserCtxt__internal_alias #endif #endif #ifdef bottom_threads #undef xmlInitThreads extern __typeof (xmlInitThreads) xmlInitThreads __attribute((alias("xmlInitThreads__internal_alias"))); #else #ifndef xmlInitThreads extern __typeof (xmlInitThreads) xmlInitThreads__internal_alias __attribute((visibility("hidden"))); #define xmlInitThreads xmlInitThreads__internal_alias #endif #endif #if defined(LIBXML_CATALOG_ENABLED) #ifdef bottom_catalog #undef xmlInitializeCatalog extern __typeof (xmlInitializeCatalog) xmlInitializeCatalog __attribute((alias("xmlInitializeCatalog__internal_alias"))); #else #ifndef xmlInitializeCatalog extern __typeof (xmlInitializeCatalog) xmlInitializeCatalog__internal_alias __attribute((visibility("hidden"))); #define xmlInitializeCatalog xmlInitializeCatalog__internal_alias #endif #endif #endif #ifdef bottom_globals #undef xmlInitializeGlobalState extern __typeof (xmlInitializeGlobalState) xmlInitializeGlobalState __attribute((alias("xmlInitializeGlobalState__internal_alias"))); #else #ifndef xmlInitializeGlobalState extern __typeof (xmlInitializeGlobalState) xmlInitializeGlobalState__internal_alias __attribute((visibility("hidden"))); #define xmlInitializeGlobalState xmlInitializeGlobalState__internal_alias #endif #endif #if defined(LIBXML_LEGACY_ENABLED) #ifdef bottom_legacy #undef xmlInitializePredefinedEntities extern __typeof (xmlInitializePredefinedEntities) xmlInitializePredefinedEntities __attribute((alias("xmlInitializePredefinedEntities__internal_alias"))); #else #ifndef xmlInitializePredefinedEntities extern __typeof (xmlInitializePredefinedEntities) xmlInitializePredefinedEntities__internal_alias __attribute((visibility("hidden"))); #define xmlInitializePredefinedEntities xmlInitializePredefinedEntities__internal_alias #endif #endif #endif #ifdef bottom_chvalid #undef xmlIsBaseChar extern __typeof (xmlIsBaseChar) xmlIsBaseChar __attribute((alias("xmlIsBaseChar__internal_alias"))); #else #ifndef xmlIsBaseChar extern __typeof (xmlIsBaseChar) xmlIsBaseChar__internal_alias __attribute((visibility("hidden"))); #define xmlIsBaseChar xmlIsBaseChar__internal_alias #endif #endif #ifdef bottom_chvalid #undef xmlIsBlank extern __typeof (xmlIsBlank) xmlIsBlank __attribute((alias("xmlIsBlank__internal_alias"))); #else #ifndef xmlIsBlank extern __typeof (xmlIsBlank) xmlIsBlank__internal_alias __attribute((visibility("hidden"))); #define xmlIsBlank xmlIsBlank__internal_alias #endif #endif #ifdef bottom_tree #undef xmlIsBlankNode extern __typeof (xmlIsBlankNode) xmlIsBlankNode __attribute((alias("xmlIsBlankNode__internal_alias"))); #else #ifndef xmlIsBlankNode extern __typeof (xmlIsBlankNode) xmlIsBlankNode__internal_alias __attribute((visibility("hidden"))); #define xmlIsBlankNode xmlIsBlankNode__internal_alias #endif #endif #ifdef bottom_chvalid #undef xmlIsChar extern __typeof (xmlIsChar) xmlIsChar __attribute((alias("xmlIsChar__internal_alias"))); #else #ifndef xmlIsChar extern __typeof (xmlIsChar) xmlIsChar__internal_alias __attribute((visibility("hidden"))); #define xmlIsChar xmlIsChar__internal_alias #endif #endif #ifdef bottom_chvalid #undef xmlIsCombining extern __typeof (xmlIsCombining) xmlIsCombining __attribute((alias("xmlIsCombining__internal_alias"))); #else #ifndef xmlIsCombining extern __typeof (xmlIsCombining) xmlIsCombining__internal_alias __attribute((visibility("hidden"))); #define xmlIsCombining xmlIsCombining__internal_alias #endif #endif #ifdef bottom_chvalid #undef xmlIsDigit extern __typeof (xmlIsDigit) xmlIsDigit __attribute((alias("xmlIsDigit__internal_alias"))); #else #ifndef xmlIsDigit extern __typeof (xmlIsDigit) xmlIsDigit__internal_alias __attribute((visibility("hidden"))); #define xmlIsDigit xmlIsDigit__internal_alias #endif #endif #ifdef bottom_chvalid #undef xmlIsExtender extern __typeof (xmlIsExtender) xmlIsExtender __attribute((alias("xmlIsExtender__internal_alias"))); #else #ifndef xmlIsExtender extern __typeof (xmlIsExtender) xmlIsExtender__internal_alias __attribute((visibility("hidden"))); #define xmlIsExtender xmlIsExtender__internal_alias #endif #endif #ifdef bottom_valid #undef xmlIsID extern __typeof (xmlIsID) xmlIsID __attribute((alias("xmlIsID__internal_alias"))); #else #ifndef xmlIsID extern __typeof (xmlIsID) xmlIsID__internal_alias __attribute((visibility("hidden"))); #define xmlIsID xmlIsID__internal_alias #endif #endif #ifdef bottom_chvalid #undef xmlIsIdeographic extern __typeof (xmlIsIdeographic) xmlIsIdeographic __attribute((alias("xmlIsIdeographic__internal_alias"))); #else #ifndef xmlIsIdeographic extern __typeof (xmlIsIdeographic) xmlIsIdeographic__internal_alias __attribute((visibility("hidden"))); #define xmlIsIdeographic xmlIsIdeographic__internal_alias #endif #endif #ifdef bottom_parserInternals #undef xmlIsLetter extern __typeof (xmlIsLetter) xmlIsLetter __attribute((alias("xmlIsLetter__internal_alias"))); #else #ifndef xmlIsLetter extern __typeof (xmlIsLetter) xmlIsLetter__internal_alias __attribute((visibility("hidden"))); #define xmlIsLetter xmlIsLetter__internal_alias #endif #endif #ifdef bottom_threads #undef xmlIsMainThread extern __typeof (xmlIsMainThread) xmlIsMainThread __attribute((alias("xmlIsMainThread__internal_alias"))); #else #ifndef xmlIsMainThread extern __typeof (xmlIsMainThread) xmlIsMainThread__internal_alias __attribute((visibility("hidden"))); #define xmlIsMainThread xmlIsMainThread__internal_alias #endif #endif #ifdef bottom_valid #undef xmlIsMixedElement extern __typeof (xmlIsMixedElement) xmlIsMixedElement __attribute((alias("xmlIsMixedElement__internal_alias"))); #else #ifndef xmlIsMixedElement extern __typeof (xmlIsMixedElement) xmlIsMixedElement__internal_alias __attribute((visibility("hidden"))); #define xmlIsMixedElement xmlIsMixedElement__internal_alias #endif #endif #ifdef bottom_chvalid #undef xmlIsPubidChar extern __typeof (xmlIsPubidChar) xmlIsPubidChar __attribute((alias("xmlIsPubidChar__internal_alias"))); #else #ifndef xmlIsPubidChar extern __typeof (xmlIsPubidChar) xmlIsPubidChar__internal_alias __attribute((visibility("hidden"))); #define xmlIsPubidChar xmlIsPubidChar__internal_alias #endif #endif #ifdef bottom_valid #undef xmlIsRef extern __typeof (xmlIsRef) xmlIsRef __attribute((alias("xmlIsRef__internal_alias"))); #else #ifndef xmlIsRef extern __typeof (xmlIsRef) xmlIsRef__internal_alias __attribute((visibility("hidden"))); #define xmlIsRef xmlIsRef__internal_alias #endif #endif #ifdef bottom_xmlsave #undef xmlIsXHTML extern __typeof (xmlIsXHTML) xmlIsXHTML __attribute((alias("xmlIsXHTML__internal_alias"))); #else #ifndef xmlIsXHTML extern __typeof (xmlIsXHTML) xmlIsXHTML__internal_alias __attribute((visibility("hidden"))); #define xmlIsXHTML xmlIsXHTML__internal_alias #endif #endif #ifdef bottom_parserInternals #undef xmlKeepBlanksDefault extern __typeof (xmlKeepBlanksDefault) xmlKeepBlanksDefault __attribute((alias("xmlKeepBlanksDefault__internal_alias"))); #else #ifndef xmlKeepBlanksDefault extern __typeof (xmlKeepBlanksDefault) xmlKeepBlanksDefault__internal_alias __attribute((visibility("hidden"))); #define xmlKeepBlanksDefault xmlKeepBlanksDefault__internal_alias #endif #endif #ifdef bottom_parserInternals #undef xmlLineNumbersDefault extern __typeof (xmlLineNumbersDefault) xmlLineNumbersDefault __attribute((alias("xmlLineNumbersDefault__internal_alias"))); #else #ifndef xmlLineNumbersDefault extern __typeof (xmlLineNumbersDefault) xmlLineNumbersDefault__internal_alias __attribute((visibility("hidden"))); #define xmlLineNumbersDefault xmlLineNumbersDefault__internal_alias #endif #endif #ifdef bottom_list #undef xmlLinkGetData extern __typeof (xmlLinkGetData) xmlLinkGetData __attribute((alias("xmlLinkGetData__internal_alias"))); #else #ifndef xmlLinkGetData extern __typeof (xmlLinkGetData) xmlLinkGetData__internal_alias __attribute((visibility("hidden"))); #define xmlLinkGetData xmlLinkGetData__internal_alias #endif #endif #ifdef bottom_list #undef xmlListAppend extern __typeof (xmlListAppend) xmlListAppend __attribute((alias("xmlListAppend__internal_alias"))); #else #ifndef xmlListAppend extern __typeof (xmlListAppend) xmlListAppend__internal_alias __attribute((visibility("hidden"))); #define xmlListAppend xmlListAppend__internal_alias #endif #endif #ifdef bottom_list #undef xmlListClear extern __typeof (xmlListClear) xmlListClear __attribute((alias("xmlListClear__internal_alias"))); #else #ifndef xmlListClear extern __typeof (xmlListClear) xmlListClear__internal_alias __attribute((visibility("hidden"))); #define xmlListClear xmlListClear__internal_alias #endif #endif #ifdef bottom_list #undef xmlListCopy extern __typeof (xmlListCopy) xmlListCopy __attribute((alias("xmlListCopy__internal_alias"))); #else #ifndef xmlListCopy extern __typeof (xmlListCopy) xmlListCopy__internal_alias __attribute((visibility("hidden"))); #define xmlListCopy xmlListCopy__internal_alias #endif #endif #ifdef bottom_list #undef xmlListCreate extern __typeof (xmlListCreate) xmlListCreate __attribute((alias("xmlListCreate__internal_alias"))); #else #ifndef xmlListCreate extern __typeof (xmlListCreate) xmlListCreate__internal_alias __attribute((visibility("hidden"))); #define xmlListCreate xmlListCreate__internal_alias #endif #endif #ifdef bottom_list #undef xmlListDelete extern __typeof (xmlListDelete) xmlListDelete __attribute((alias("xmlListDelete__internal_alias"))); #else #ifndef xmlListDelete extern __typeof (xmlListDelete) xmlListDelete__internal_alias __attribute((visibility("hidden"))); #define xmlListDelete xmlListDelete__internal_alias #endif #endif #ifdef bottom_list #undef xmlListDup extern __typeof (xmlListDup) xmlListDup __attribute((alias("xmlListDup__internal_alias"))); #else #ifndef xmlListDup extern __typeof (xmlListDup) xmlListDup__internal_alias __attribute((visibility("hidden"))); #define xmlListDup xmlListDup__internal_alias #endif #endif #ifdef bottom_list #undef xmlListEmpty extern __typeof (xmlListEmpty) xmlListEmpty __attribute((alias("xmlListEmpty__internal_alias"))); #else #ifndef xmlListEmpty extern __typeof (xmlListEmpty) xmlListEmpty__internal_alias __attribute((visibility("hidden"))); #define xmlListEmpty xmlListEmpty__internal_alias #endif #endif #ifdef bottom_list #undef xmlListEnd extern __typeof (xmlListEnd) xmlListEnd __attribute((alias("xmlListEnd__internal_alias"))); #else #ifndef xmlListEnd extern __typeof (xmlListEnd) xmlListEnd__internal_alias __attribute((visibility("hidden"))); #define xmlListEnd xmlListEnd__internal_alias #endif #endif #ifdef bottom_list #undef xmlListFront extern __typeof (xmlListFront) xmlListFront __attribute((alias("xmlListFront__internal_alias"))); #else #ifndef xmlListFront extern __typeof (xmlListFront) xmlListFront__internal_alias __attribute((visibility("hidden"))); #define xmlListFront xmlListFront__internal_alias #endif #endif #ifdef bottom_list #undef xmlListInsert extern __typeof (xmlListInsert) xmlListInsert __attribute((alias("xmlListInsert__internal_alias"))); #else #ifndef xmlListInsert extern __typeof (xmlListInsert) xmlListInsert__internal_alias __attribute((visibility("hidden"))); #define xmlListInsert xmlListInsert__internal_alias #endif #endif #ifdef bottom_list #undef xmlListMerge extern __typeof (xmlListMerge) xmlListMerge __attribute((alias("xmlListMerge__internal_alias"))); #else #ifndef xmlListMerge extern __typeof (xmlListMerge) xmlListMerge__internal_alias __attribute((visibility("hidden"))); #define xmlListMerge xmlListMerge__internal_alias #endif #endif #ifdef bottom_list #undef xmlListPopBack extern __typeof (xmlListPopBack) xmlListPopBack __attribute((alias("xmlListPopBack__internal_alias"))); #else #ifndef xmlListPopBack extern __typeof (xmlListPopBack) xmlListPopBack__internal_alias __attribute((visibility("hidden"))); #define xmlListPopBack xmlListPopBack__internal_alias #endif #endif #ifdef bottom_list #undef xmlListPopFront extern __typeof (xmlListPopFront) xmlListPopFront __attribute((alias("xmlListPopFront__internal_alias"))); #else #ifndef xmlListPopFront extern __typeof (xmlListPopFront) xmlListPopFront__internal_alias __attribute((visibility("hidden"))); #define xmlListPopFront xmlListPopFront__internal_alias #endif #endif #ifdef bottom_list #undef xmlListPushBack extern __typeof (xmlListPushBack) xmlListPushBack __attribute((alias("xmlListPushBack__internal_alias"))); #else #ifndef xmlListPushBack extern __typeof (xmlListPushBack) xmlListPushBack__internal_alias __attribute((visibility("hidden"))); #define xmlListPushBack xmlListPushBack__internal_alias #endif #endif #ifdef bottom_list #undef xmlListPushFront extern __typeof (xmlListPushFront) xmlListPushFront __attribute((alias("xmlListPushFront__internal_alias"))); #else #ifndef xmlListPushFront extern __typeof (xmlListPushFront) xmlListPushFront__internal_alias __attribute((visibility("hidden"))); #define xmlListPushFront xmlListPushFront__internal_alias #endif #endif #ifdef bottom_list #undef xmlListRemoveAll extern __typeof (xmlListRemoveAll) xmlListRemoveAll __attribute((alias("xmlListRemoveAll__internal_alias"))); #else #ifndef xmlListRemoveAll extern __typeof (xmlListRemoveAll) xmlListRemoveAll__internal_alias __attribute((visibility("hidden"))); #define xmlListRemoveAll xmlListRemoveAll__internal_alias #endif #endif #ifdef bottom_list #undef xmlListRemoveFirst extern __typeof (xmlListRemoveFirst) xmlListRemoveFirst __attribute((alias("xmlListRemoveFirst__internal_alias"))); #else #ifndef xmlListRemoveFirst extern __typeof (xmlListRemoveFirst) xmlListRemoveFirst__internal_alias __attribute((visibility("hidden"))); #define xmlListRemoveFirst xmlListRemoveFirst__internal_alias #endif #endif #ifdef bottom_list #undef xmlListRemoveLast extern __typeof (xmlListRemoveLast) xmlListRemoveLast __attribute((alias("xmlListRemoveLast__internal_alias"))); #else #ifndef xmlListRemoveLast extern __typeof (xmlListRemoveLast) xmlListRemoveLast__internal_alias __attribute((visibility("hidden"))); #define xmlListRemoveLast xmlListRemoveLast__internal_alias #endif #endif #ifdef bottom_list #undef xmlListReverse extern __typeof (xmlListReverse) xmlListReverse __attribute((alias("xmlListReverse__internal_alias"))); #else #ifndef xmlListReverse extern __typeof (xmlListReverse) xmlListReverse__internal_alias __attribute((visibility("hidden"))); #define xmlListReverse xmlListReverse__internal_alias #endif #endif #ifdef bottom_list #undef xmlListReverseSearch extern __typeof (xmlListReverseSearch) xmlListReverseSearch __attribute((alias("xmlListReverseSearch__internal_alias"))); #else #ifndef xmlListReverseSearch extern __typeof (xmlListReverseSearch) xmlListReverseSearch__internal_alias __attribute((visibility("hidden"))); #define xmlListReverseSearch xmlListReverseSearch__internal_alias #endif #endif #ifdef bottom_list #undef xmlListReverseWalk extern __typeof (xmlListReverseWalk) xmlListReverseWalk __attribute((alias("xmlListReverseWalk__internal_alias"))); #else #ifndef xmlListReverseWalk extern __typeof (xmlListReverseWalk) xmlListReverseWalk__internal_alias __attribute((visibility("hidden"))); #define xmlListReverseWalk xmlListReverseWalk__internal_alias #endif #endif #ifdef bottom_list #undef xmlListSearch extern __typeof (xmlListSearch) xmlListSearch __attribute((alias("xmlListSearch__internal_alias"))); #else #ifndef xmlListSearch extern __typeof (xmlListSearch) xmlListSearch__internal_alias __attribute((visibility("hidden"))); #define xmlListSearch xmlListSearch__internal_alias #endif #endif #ifdef bottom_list #undef xmlListSize extern __typeof (xmlListSize) xmlListSize __attribute((alias("xmlListSize__internal_alias"))); #else #ifndef xmlListSize extern __typeof (xmlListSize) xmlListSize__internal_alias __attribute((visibility("hidden"))); #define xmlListSize xmlListSize__internal_alias #endif #endif #ifdef bottom_list #undef xmlListSort extern __typeof (xmlListSort) xmlListSort __attribute((alias("xmlListSort__internal_alias"))); #else #ifndef xmlListSort extern __typeof (xmlListSort) xmlListSort__internal_alias __attribute((visibility("hidden"))); #define xmlListSort xmlListSort__internal_alias #endif #endif #ifdef bottom_list #undef xmlListWalk extern __typeof (xmlListWalk) xmlListWalk __attribute((alias("xmlListWalk__internal_alias"))); #else #ifndef xmlListWalk extern __typeof (xmlListWalk) xmlListWalk__internal_alias __attribute((visibility("hidden"))); #define xmlListWalk xmlListWalk__internal_alias #endif #endif #if defined(LIBXML_CATALOG_ENABLED) #ifdef bottom_catalog #undef xmlLoadACatalog extern __typeof (xmlLoadACatalog) xmlLoadACatalog __attribute((alias("xmlLoadACatalog__internal_alias"))); #else #ifndef xmlLoadACatalog extern __typeof (xmlLoadACatalog) xmlLoadACatalog__internal_alias __attribute((visibility("hidden"))); #define xmlLoadACatalog xmlLoadACatalog__internal_alias #endif #endif #endif #if defined(LIBXML_CATALOG_ENABLED) #ifdef bottom_catalog #undef xmlLoadCatalog extern __typeof (xmlLoadCatalog) xmlLoadCatalog __attribute((alias("xmlLoadCatalog__internal_alias"))); #else #ifndef xmlLoadCatalog extern __typeof (xmlLoadCatalog) xmlLoadCatalog__internal_alias __attribute((visibility("hidden"))); #define xmlLoadCatalog xmlLoadCatalog__internal_alias #endif #endif #endif #if defined(LIBXML_CATALOG_ENABLED) #ifdef bottom_catalog #undef xmlLoadCatalogs extern __typeof (xmlLoadCatalogs) xmlLoadCatalogs __attribute((alias("xmlLoadCatalogs__internal_alias"))); #else #ifndef xmlLoadCatalogs extern __typeof (xmlLoadCatalogs) xmlLoadCatalogs__internal_alias __attribute((visibility("hidden"))); #define xmlLoadCatalogs xmlLoadCatalogs__internal_alias #endif #endif #endif #ifdef bottom_xmlIO #undef xmlLoadExternalEntity extern __typeof (xmlLoadExternalEntity) xmlLoadExternalEntity __attribute((alias("xmlLoadExternalEntity__internal_alias"))); #else #ifndef xmlLoadExternalEntity extern __typeof (xmlLoadExternalEntity) xmlLoadExternalEntity__internal_alias __attribute((visibility("hidden"))); #define xmlLoadExternalEntity xmlLoadExternalEntity__internal_alias #endif #endif #if defined(LIBXML_CATALOG_ENABLED) #ifdef bottom_catalog #undef xmlLoadSGMLSuperCatalog extern __typeof (xmlLoadSGMLSuperCatalog) xmlLoadSGMLSuperCatalog __attribute((alias("xmlLoadSGMLSuperCatalog__internal_alias"))); #else #ifndef xmlLoadSGMLSuperCatalog extern __typeof (xmlLoadSGMLSuperCatalog) xmlLoadSGMLSuperCatalog__internal_alias __attribute((visibility("hidden"))); #define xmlLoadSGMLSuperCatalog xmlLoadSGMLSuperCatalog__internal_alias #endif #endif #endif #ifdef bottom_threads #undef xmlLockLibrary extern __typeof (xmlLockLibrary) xmlLockLibrary __attribute((alias("xmlLockLibrary__internal_alias"))); #else #ifndef xmlLockLibrary extern __typeof (xmlLockLibrary) xmlLockLibrary__internal_alias __attribute((visibility("hidden"))); #define xmlLockLibrary xmlLockLibrary__internal_alias #endif #endif #if defined(LIBXML_DEBUG_ENABLED) #ifdef bottom_debugXML #undef xmlLsCountNode extern __typeof (xmlLsCountNode) xmlLsCountNode __attribute((alias("xmlLsCountNode__internal_alias"))); #else #ifndef xmlLsCountNode extern __typeof (xmlLsCountNode) xmlLsCountNode__internal_alias __attribute((visibility("hidden"))); #define xmlLsCountNode xmlLsCountNode__internal_alias #endif #endif #endif #if defined(LIBXML_DEBUG_ENABLED) #ifdef bottom_debugXML #undef xmlLsOneNode extern __typeof (xmlLsOneNode) xmlLsOneNode __attribute((alias("xmlLsOneNode__internal_alias"))); #else #ifndef xmlLsOneNode extern __typeof (xmlLsOneNode) xmlLsOneNode__internal_alias __attribute((visibility("hidden"))); #define xmlLsOneNode xmlLsOneNode__internal_alias #endif #endif #endif #ifdef bottom_xmlmemory #undef xmlMallocAtomicLoc extern __typeof (xmlMallocAtomicLoc) xmlMallocAtomicLoc __attribute((alias("xmlMallocAtomicLoc__internal_alias"))); #else #ifndef xmlMallocAtomicLoc extern __typeof (xmlMallocAtomicLoc) xmlMallocAtomicLoc__internal_alias __attribute((visibility("hidden"))); #define xmlMallocAtomicLoc xmlMallocAtomicLoc__internal_alias #endif #endif #ifdef bottom_xmlmemory #undef xmlMallocLoc extern __typeof (xmlMallocLoc) xmlMallocLoc __attribute((alias("xmlMallocLoc__internal_alias"))); #else #ifndef xmlMallocLoc extern __typeof (xmlMallocLoc) xmlMallocLoc__internal_alias __attribute((visibility("hidden"))); #define xmlMallocLoc xmlMallocLoc__internal_alias #endif #endif #ifdef bottom_xmlmemory #undef xmlMemBlocks extern __typeof (xmlMemBlocks) xmlMemBlocks __attribute((alias("xmlMemBlocks__internal_alias"))); #else #ifndef xmlMemBlocks extern __typeof (xmlMemBlocks) xmlMemBlocks__internal_alias __attribute((visibility("hidden"))); #define xmlMemBlocks xmlMemBlocks__internal_alias #endif #endif #ifdef bottom_xmlmemory #undef xmlMemDisplay extern __typeof (xmlMemDisplay) xmlMemDisplay __attribute((alias("xmlMemDisplay__internal_alias"))); #else #ifndef xmlMemDisplay extern __typeof (xmlMemDisplay) xmlMemDisplay__internal_alias __attribute((visibility("hidden"))); #define xmlMemDisplay xmlMemDisplay__internal_alias #endif #endif #ifdef bottom_xmlmemory #undef xmlMemFree extern __typeof (xmlMemFree) xmlMemFree __attribute((alias("xmlMemFree__internal_alias"))); #else #ifndef xmlMemFree extern __typeof (xmlMemFree) xmlMemFree__internal_alias __attribute((visibility("hidden"))); #define xmlMemFree xmlMemFree__internal_alias #endif #endif #ifdef bottom_xmlmemory #undef xmlMemGet extern __typeof (xmlMemGet) xmlMemGet __attribute((alias("xmlMemGet__internal_alias"))); #else #ifndef xmlMemGet extern __typeof (xmlMemGet) xmlMemGet__internal_alias __attribute((visibility("hidden"))); #define xmlMemGet xmlMemGet__internal_alias #endif #endif #ifdef bottom_xmlmemory #undef xmlMemMalloc extern __typeof (xmlMemMalloc) xmlMemMalloc __attribute((alias("xmlMemMalloc__internal_alias"))); #else #ifndef xmlMemMalloc extern __typeof (xmlMemMalloc) xmlMemMalloc__internal_alias __attribute((visibility("hidden"))); #define xmlMemMalloc xmlMemMalloc__internal_alias #endif #endif #ifdef bottom_xmlmemory #undef xmlMemRealloc extern __typeof (xmlMemRealloc) xmlMemRealloc __attribute((alias("xmlMemRealloc__internal_alias"))); #else #ifndef xmlMemRealloc extern __typeof (xmlMemRealloc) xmlMemRealloc__internal_alias __attribute((visibility("hidden"))); #define xmlMemRealloc xmlMemRealloc__internal_alias #endif #endif #ifdef bottom_xmlmemory #undef xmlMemSetup extern __typeof (xmlMemSetup) xmlMemSetup __attribute((alias("xmlMemSetup__internal_alias"))); #else #ifndef xmlMemSetup extern __typeof (xmlMemSetup) xmlMemSetup__internal_alias __attribute((visibility("hidden"))); #define xmlMemSetup xmlMemSetup__internal_alias #endif #endif #ifdef bottom_xmlmemory #undef xmlMemShow extern __typeof (xmlMemShow) xmlMemShow __attribute((alias("xmlMemShow__internal_alias"))); #else #ifndef xmlMemShow extern __typeof (xmlMemShow) xmlMemShow__internal_alias __attribute((visibility("hidden"))); #define xmlMemShow xmlMemShow__internal_alias #endif #endif #ifdef bottom_xmlmemory #undef xmlMemStrdupLoc extern __typeof (xmlMemStrdupLoc) xmlMemStrdupLoc __attribute((alias("xmlMemStrdupLoc__internal_alias"))); #else #ifndef xmlMemStrdupLoc extern __typeof (xmlMemStrdupLoc) xmlMemStrdupLoc__internal_alias __attribute((visibility("hidden"))); #define xmlMemStrdupLoc xmlMemStrdupLoc__internal_alias #endif #endif #ifdef bottom_xmlmemory #undef xmlMemUsed extern __typeof (xmlMemUsed) xmlMemUsed __attribute((alias("xmlMemUsed__internal_alias"))); #else #ifndef xmlMemUsed extern __typeof (xmlMemUsed) xmlMemUsed__internal_alias __attribute((visibility("hidden"))); #define xmlMemUsed xmlMemUsed__internal_alias #endif #endif #ifdef bottom_xmlmemory #undef xmlMemoryDump extern __typeof (xmlMemoryDump) xmlMemoryDump __attribute((alias("xmlMemoryDump__internal_alias"))); #else #ifndef xmlMemoryDump extern __typeof (xmlMemoryDump) xmlMemoryDump__internal_alias __attribute((visibility("hidden"))); #define xmlMemoryDump xmlMemoryDump__internal_alias #endif #endif #ifdef bottom_xmlmemory #undef xmlMemoryStrdup extern __typeof (xmlMemoryStrdup) xmlMemoryStrdup __attribute((alias("xmlMemoryStrdup__internal_alias"))); #else #ifndef xmlMemoryStrdup extern __typeof (xmlMemoryStrdup) xmlMemoryStrdup__internal_alias __attribute((visibility("hidden"))); #define xmlMemoryStrdup xmlMemoryStrdup__internal_alias #endif #endif #if defined(LIBXML_MODULES_ENABLED) #ifdef bottom_xmlmodule #undef xmlModuleClose extern __typeof (xmlModuleClose) xmlModuleClose __attribute((alias("xmlModuleClose__internal_alias"))); #else #ifndef xmlModuleClose extern __typeof (xmlModuleClose) xmlModuleClose__internal_alias __attribute((visibility("hidden"))); #define xmlModuleClose xmlModuleClose__internal_alias #endif #endif #endif #if defined(LIBXML_MODULES_ENABLED) #ifdef bottom_xmlmodule #undef xmlModuleFree extern __typeof (xmlModuleFree) xmlModuleFree __attribute((alias("xmlModuleFree__internal_alias"))); #else #ifndef xmlModuleFree extern __typeof (xmlModuleFree) xmlModuleFree__internal_alias __attribute((visibility("hidden"))); #define xmlModuleFree xmlModuleFree__internal_alias #endif #endif #endif #if defined(LIBXML_MODULES_ENABLED) #ifdef bottom_xmlmodule #undef xmlModuleOpen extern __typeof (xmlModuleOpen) xmlModuleOpen __attribute((alias("xmlModuleOpen__internal_alias"))); #else #ifndef xmlModuleOpen extern __typeof (xmlModuleOpen) xmlModuleOpen__internal_alias __attribute((visibility("hidden"))); #define xmlModuleOpen xmlModuleOpen__internal_alias #endif #endif #endif #if defined(LIBXML_MODULES_ENABLED) #ifdef bottom_xmlmodule #undef xmlModuleSymbol extern __typeof (xmlModuleSymbol) xmlModuleSymbol __attribute((alias("xmlModuleSymbol__internal_alias"))); #else #ifndef xmlModuleSymbol extern __typeof (xmlModuleSymbol) xmlModuleSymbol__internal_alias __attribute((visibility("hidden"))); #define xmlModuleSymbol xmlModuleSymbol__internal_alias #endif #endif #endif #ifdef bottom_threads #undef xmlMutexLock extern __typeof (xmlMutexLock) xmlMutexLock __attribute((alias("xmlMutexLock__internal_alias"))); #else #ifndef xmlMutexLock extern __typeof (xmlMutexLock) xmlMutexLock__internal_alias __attribute((visibility("hidden"))); #define xmlMutexLock xmlMutexLock__internal_alias #endif #endif #ifdef bottom_threads #undef xmlMutexUnlock extern __typeof (xmlMutexUnlock) xmlMutexUnlock __attribute((alias("xmlMutexUnlock__internal_alias"))); #else #ifndef xmlMutexUnlock extern __typeof (xmlMutexUnlock) xmlMutexUnlock__internal_alias __attribute((visibility("hidden"))); #define xmlMutexUnlock xmlMutexUnlock__internal_alias #endif #endif #if defined(LIBXML_LEGACY_ENABLED) #ifdef bottom_legacy #undef xmlNamespaceParseNCName extern __typeof (xmlNamespaceParseNCName) xmlNamespaceParseNCName __attribute((alias("xmlNamespaceParseNCName__internal_alias"))); #else #ifndef xmlNamespaceParseNCName extern __typeof (xmlNamespaceParseNCName) xmlNamespaceParseNCName__internal_alias __attribute((visibility("hidden"))); #define xmlNamespaceParseNCName xmlNamespaceParseNCName__internal_alias #endif #endif #endif #if defined(LIBXML_LEGACY_ENABLED) #ifdef bottom_legacy #undef xmlNamespaceParseNSDef extern __typeof (xmlNamespaceParseNSDef) xmlNamespaceParseNSDef __attribute((alias("xmlNamespaceParseNSDef__internal_alias"))); #else #ifndef xmlNamespaceParseNSDef extern __typeof (xmlNamespaceParseNSDef) xmlNamespaceParseNSDef__internal_alias __attribute((visibility("hidden"))); #define xmlNamespaceParseNSDef xmlNamespaceParseNSDef__internal_alias #endif #endif #endif #if defined(LIBXML_LEGACY_ENABLED) #ifdef bottom_legacy #undef xmlNamespaceParseQName extern __typeof (xmlNamespaceParseQName) xmlNamespaceParseQName __attribute((alias("xmlNamespaceParseQName__internal_alias"))); #else #ifndef xmlNamespaceParseQName extern __typeof (xmlNamespaceParseQName) xmlNamespaceParseQName__internal_alias __attribute((visibility("hidden"))); #define xmlNamespaceParseQName xmlNamespaceParseQName__internal_alias #endif #endif #endif #if defined(LIBXML_FTP_ENABLED) #ifdef bottom_nanoftp #undef xmlNanoFTPCheckResponse extern __typeof (xmlNanoFTPCheckResponse) xmlNanoFTPCheckResponse __attribute((alias("xmlNanoFTPCheckResponse__internal_alias"))); #else #ifndef xmlNanoFTPCheckResponse extern __typeof (xmlNanoFTPCheckResponse) xmlNanoFTPCheckResponse__internal_alias __attribute((visibility("hidden"))); #define xmlNanoFTPCheckResponse xmlNanoFTPCheckResponse__internal_alias #endif #endif #endif #if defined(LIBXML_FTP_ENABLED) #ifdef bottom_nanoftp #undef xmlNanoFTPCleanup extern __typeof (xmlNanoFTPCleanup) xmlNanoFTPCleanup __attribute((alias("xmlNanoFTPCleanup__internal_alias"))); #else #ifndef xmlNanoFTPCleanup extern __typeof (xmlNanoFTPCleanup) xmlNanoFTPCleanup__internal_alias __attribute((visibility("hidden"))); #define xmlNanoFTPCleanup xmlNanoFTPCleanup__internal_alias #endif #endif #endif #if defined(LIBXML_FTP_ENABLED) #ifdef bottom_nanoftp #undef xmlNanoFTPClose extern __typeof (xmlNanoFTPClose) xmlNanoFTPClose __attribute((alias("xmlNanoFTPClose__internal_alias"))); #else #ifndef xmlNanoFTPClose extern __typeof (xmlNanoFTPClose) xmlNanoFTPClose__internal_alias __attribute((visibility("hidden"))); #define xmlNanoFTPClose xmlNanoFTPClose__internal_alias #endif #endif #endif #if defined(LIBXML_FTP_ENABLED) #ifdef bottom_nanoftp #undef xmlNanoFTPCloseConnection extern __typeof (xmlNanoFTPCloseConnection) xmlNanoFTPCloseConnection __attribute((alias("xmlNanoFTPCloseConnection__internal_alias"))); #else #ifndef xmlNanoFTPCloseConnection extern __typeof (xmlNanoFTPCloseConnection) xmlNanoFTPCloseConnection__internal_alias __attribute((visibility("hidden"))); #define xmlNanoFTPCloseConnection xmlNanoFTPCloseConnection__internal_alias #endif #endif #endif #if defined(LIBXML_FTP_ENABLED) #ifdef bottom_nanoftp #undef xmlNanoFTPConnect extern __typeof (xmlNanoFTPConnect) xmlNanoFTPConnect __attribute((alias("xmlNanoFTPConnect__internal_alias"))); #else #ifndef xmlNanoFTPConnect extern __typeof (xmlNanoFTPConnect) xmlNanoFTPConnect__internal_alias __attribute((visibility("hidden"))); #define xmlNanoFTPConnect xmlNanoFTPConnect__internal_alias #endif #endif #endif #if defined(LIBXML_FTP_ENABLED) #ifdef bottom_nanoftp #undef xmlNanoFTPConnectTo extern __typeof (xmlNanoFTPConnectTo) xmlNanoFTPConnectTo __attribute((alias("xmlNanoFTPConnectTo__internal_alias"))); #else #ifndef xmlNanoFTPConnectTo extern __typeof (xmlNanoFTPConnectTo) xmlNanoFTPConnectTo__internal_alias __attribute((visibility("hidden"))); #define xmlNanoFTPConnectTo xmlNanoFTPConnectTo__internal_alias #endif #endif #endif #if defined(LIBXML_FTP_ENABLED) #ifdef bottom_nanoftp #undef xmlNanoFTPCwd extern __typeof (xmlNanoFTPCwd) xmlNanoFTPCwd __attribute((alias("xmlNanoFTPCwd__internal_alias"))); #else #ifndef xmlNanoFTPCwd extern __typeof (xmlNanoFTPCwd) xmlNanoFTPCwd__internal_alias __attribute((visibility("hidden"))); #define xmlNanoFTPCwd xmlNanoFTPCwd__internal_alias #endif #endif #endif #if defined(LIBXML_FTP_ENABLED) #ifdef bottom_nanoftp #undef xmlNanoFTPDele extern __typeof (xmlNanoFTPDele) xmlNanoFTPDele __attribute((alias("xmlNanoFTPDele__internal_alias"))); #else #ifndef xmlNanoFTPDele extern __typeof (xmlNanoFTPDele) xmlNanoFTPDele__internal_alias __attribute((visibility("hidden"))); #define xmlNanoFTPDele xmlNanoFTPDele__internal_alias #endif #endif #endif #if defined(LIBXML_FTP_ENABLED) #ifdef bottom_nanoftp #undef xmlNanoFTPFreeCtxt extern __typeof (xmlNanoFTPFreeCtxt) xmlNanoFTPFreeCtxt __attribute((alias("xmlNanoFTPFreeCtxt__internal_alias"))); #else #ifndef xmlNanoFTPFreeCtxt extern __typeof (xmlNanoFTPFreeCtxt) xmlNanoFTPFreeCtxt__internal_alias __attribute((visibility("hidden"))); #define xmlNanoFTPFreeCtxt xmlNanoFTPFreeCtxt__internal_alias #endif #endif #endif #if defined(LIBXML_FTP_ENABLED) #ifdef bottom_nanoftp #undef xmlNanoFTPGet extern __typeof (xmlNanoFTPGet) xmlNanoFTPGet __attribute((alias("xmlNanoFTPGet__internal_alias"))); #else #ifndef xmlNanoFTPGet extern __typeof (xmlNanoFTPGet) xmlNanoFTPGet__internal_alias __attribute((visibility("hidden"))); #define xmlNanoFTPGet xmlNanoFTPGet__internal_alias #endif #endif #endif #if defined(LIBXML_FTP_ENABLED) #ifdef bottom_nanoftp #undef xmlNanoFTPGetConnection extern __typeof (xmlNanoFTPGetConnection) xmlNanoFTPGetConnection __attribute((alias("xmlNanoFTPGetConnection__internal_alias"))); #else #ifndef xmlNanoFTPGetConnection extern __typeof (xmlNanoFTPGetConnection) xmlNanoFTPGetConnection__internal_alias __attribute((visibility("hidden"))); #define xmlNanoFTPGetConnection xmlNanoFTPGetConnection__internal_alias #endif #endif #endif #if defined(LIBXML_FTP_ENABLED) #ifdef bottom_nanoftp #undef xmlNanoFTPGetResponse extern __typeof (xmlNanoFTPGetResponse) xmlNanoFTPGetResponse __attribute((alias("xmlNanoFTPGetResponse__internal_alias"))); #else #ifndef xmlNanoFTPGetResponse extern __typeof (xmlNanoFTPGetResponse) xmlNanoFTPGetResponse__internal_alias __attribute((visibility("hidden"))); #define xmlNanoFTPGetResponse xmlNanoFTPGetResponse__internal_alias #endif #endif #endif #if defined(LIBXML_FTP_ENABLED) #ifdef bottom_nanoftp #undef xmlNanoFTPGetSocket extern __typeof (xmlNanoFTPGetSocket) xmlNanoFTPGetSocket __attribute((alias("xmlNanoFTPGetSocket__internal_alias"))); #else #ifndef xmlNanoFTPGetSocket extern __typeof (xmlNanoFTPGetSocket) xmlNanoFTPGetSocket__internal_alias __attribute((visibility("hidden"))); #define xmlNanoFTPGetSocket xmlNanoFTPGetSocket__internal_alias #endif #endif #endif #if defined(LIBXML_FTP_ENABLED) #ifdef bottom_nanoftp #undef xmlNanoFTPInit extern __typeof (xmlNanoFTPInit) xmlNanoFTPInit __attribute((alias("xmlNanoFTPInit__internal_alias"))); #else #ifndef xmlNanoFTPInit extern __typeof (xmlNanoFTPInit) xmlNanoFTPInit__internal_alias __attribute((visibility("hidden"))); #define xmlNanoFTPInit xmlNanoFTPInit__internal_alias #endif #endif #endif #if defined(LIBXML_FTP_ENABLED) #ifdef bottom_nanoftp #undef xmlNanoFTPList extern __typeof (xmlNanoFTPList) xmlNanoFTPList __attribute((alias("xmlNanoFTPList__internal_alias"))); #else #ifndef xmlNanoFTPList extern __typeof (xmlNanoFTPList) xmlNanoFTPList__internal_alias __attribute((visibility("hidden"))); #define xmlNanoFTPList xmlNanoFTPList__internal_alias #endif #endif #endif #if defined(LIBXML_FTP_ENABLED) #ifdef bottom_nanoftp #undef xmlNanoFTPNewCtxt extern __typeof (xmlNanoFTPNewCtxt) xmlNanoFTPNewCtxt __attribute((alias("xmlNanoFTPNewCtxt__internal_alias"))); #else #ifndef xmlNanoFTPNewCtxt extern __typeof (xmlNanoFTPNewCtxt) xmlNanoFTPNewCtxt__internal_alias __attribute((visibility("hidden"))); #define xmlNanoFTPNewCtxt xmlNanoFTPNewCtxt__internal_alias #endif #endif #endif #if defined(LIBXML_FTP_ENABLED) #ifdef bottom_nanoftp #undef xmlNanoFTPOpen extern __typeof (xmlNanoFTPOpen) xmlNanoFTPOpen __attribute((alias("xmlNanoFTPOpen__internal_alias"))); #else #ifndef xmlNanoFTPOpen extern __typeof (xmlNanoFTPOpen) xmlNanoFTPOpen__internal_alias __attribute((visibility("hidden"))); #define xmlNanoFTPOpen xmlNanoFTPOpen__internal_alias #endif #endif #endif #if defined(LIBXML_FTP_ENABLED) #ifdef bottom_nanoftp #undef xmlNanoFTPProxy extern __typeof (xmlNanoFTPProxy) xmlNanoFTPProxy __attribute((alias("xmlNanoFTPProxy__internal_alias"))); #else #ifndef xmlNanoFTPProxy extern __typeof (xmlNanoFTPProxy) xmlNanoFTPProxy__internal_alias __attribute((visibility("hidden"))); #define xmlNanoFTPProxy xmlNanoFTPProxy__internal_alias #endif #endif #endif #if defined(LIBXML_FTP_ENABLED) #ifdef bottom_nanoftp #undef xmlNanoFTPQuit extern __typeof (xmlNanoFTPQuit) xmlNanoFTPQuit __attribute((alias("xmlNanoFTPQuit__internal_alias"))); #else #ifndef xmlNanoFTPQuit extern __typeof (xmlNanoFTPQuit) xmlNanoFTPQuit__internal_alias __attribute((visibility("hidden"))); #define xmlNanoFTPQuit xmlNanoFTPQuit__internal_alias #endif #endif #endif #if defined(LIBXML_FTP_ENABLED) #ifdef bottom_nanoftp #undef xmlNanoFTPRead extern __typeof (xmlNanoFTPRead) xmlNanoFTPRead __attribute((alias("xmlNanoFTPRead__internal_alias"))); #else #ifndef xmlNanoFTPRead extern __typeof (xmlNanoFTPRead) xmlNanoFTPRead__internal_alias __attribute((visibility("hidden"))); #define xmlNanoFTPRead xmlNanoFTPRead__internal_alias #endif #endif #endif #if defined(LIBXML_FTP_ENABLED) #ifdef bottom_nanoftp #undef xmlNanoFTPScanProxy extern __typeof (xmlNanoFTPScanProxy) xmlNanoFTPScanProxy __attribute((alias("xmlNanoFTPScanProxy__internal_alias"))); #else #ifndef xmlNanoFTPScanProxy extern __typeof (xmlNanoFTPScanProxy) xmlNanoFTPScanProxy__internal_alias __attribute((visibility("hidden"))); #define xmlNanoFTPScanProxy xmlNanoFTPScanProxy__internal_alias #endif #endif #endif #if defined(LIBXML_FTP_ENABLED) #ifdef bottom_nanoftp #undef xmlNanoFTPUpdateURL extern __typeof (xmlNanoFTPUpdateURL) xmlNanoFTPUpdateURL __attribute((alias("xmlNanoFTPUpdateURL__internal_alias"))); #else #ifndef xmlNanoFTPUpdateURL extern __typeof (xmlNanoFTPUpdateURL) xmlNanoFTPUpdateURL__internal_alias __attribute((visibility("hidden"))); #define xmlNanoFTPUpdateURL xmlNanoFTPUpdateURL__internal_alias #endif #endif #endif #if defined(LIBXML_HTTP_ENABLED) #ifdef bottom_nanohttp #undef xmlNanoHTTPAuthHeader extern __typeof (xmlNanoHTTPAuthHeader) xmlNanoHTTPAuthHeader __attribute((alias("xmlNanoHTTPAuthHeader__internal_alias"))); #else #ifndef xmlNanoHTTPAuthHeader extern __typeof (xmlNanoHTTPAuthHeader) xmlNanoHTTPAuthHeader__internal_alias __attribute((visibility("hidden"))); #define xmlNanoHTTPAuthHeader xmlNanoHTTPAuthHeader__internal_alias #endif #endif #endif #if defined(LIBXML_HTTP_ENABLED) #ifdef bottom_nanohttp #undef xmlNanoHTTPCleanup extern __typeof (xmlNanoHTTPCleanup) xmlNanoHTTPCleanup __attribute((alias("xmlNanoHTTPCleanup__internal_alias"))); #else #ifndef xmlNanoHTTPCleanup extern __typeof (xmlNanoHTTPCleanup) xmlNanoHTTPCleanup__internal_alias __attribute((visibility("hidden"))); #define xmlNanoHTTPCleanup xmlNanoHTTPCleanup__internal_alias #endif #endif #endif #if defined(LIBXML_HTTP_ENABLED) #ifdef bottom_nanohttp #undef xmlNanoHTTPClose extern __typeof (xmlNanoHTTPClose) xmlNanoHTTPClose __attribute((alias("xmlNanoHTTPClose__internal_alias"))); #else #ifndef xmlNanoHTTPClose extern __typeof (xmlNanoHTTPClose) xmlNanoHTTPClose__internal_alias __attribute((visibility("hidden"))); #define xmlNanoHTTPClose xmlNanoHTTPClose__internal_alias #endif #endif #endif #if defined(LIBXML_HTTP_ENABLED) #ifdef bottom_nanohttp #undef xmlNanoHTTPContentLength extern __typeof (xmlNanoHTTPContentLength) xmlNanoHTTPContentLength __attribute((alias("xmlNanoHTTPContentLength__internal_alias"))); #else #ifndef xmlNanoHTTPContentLength extern __typeof (xmlNanoHTTPContentLength) xmlNanoHTTPContentLength__internal_alias __attribute((visibility("hidden"))); #define xmlNanoHTTPContentLength xmlNanoHTTPContentLength__internal_alias #endif #endif #endif #if defined(LIBXML_HTTP_ENABLED) #ifdef bottom_nanohttp #undef xmlNanoHTTPEncoding extern __typeof (xmlNanoHTTPEncoding) xmlNanoHTTPEncoding __attribute((alias("xmlNanoHTTPEncoding__internal_alias"))); #else #ifndef xmlNanoHTTPEncoding extern __typeof (xmlNanoHTTPEncoding) xmlNanoHTTPEncoding__internal_alias __attribute((visibility("hidden"))); #define xmlNanoHTTPEncoding xmlNanoHTTPEncoding__internal_alias #endif #endif #endif #if defined(LIBXML_HTTP_ENABLED) #ifdef bottom_nanohttp #undef xmlNanoHTTPFetch extern __typeof (xmlNanoHTTPFetch) xmlNanoHTTPFetch __attribute((alias("xmlNanoHTTPFetch__internal_alias"))); #else #ifndef xmlNanoHTTPFetch extern __typeof (xmlNanoHTTPFetch) xmlNanoHTTPFetch__internal_alias __attribute((visibility("hidden"))); #define xmlNanoHTTPFetch xmlNanoHTTPFetch__internal_alias #endif #endif #endif #if defined(LIBXML_HTTP_ENABLED) #ifdef bottom_nanohttp #undef xmlNanoHTTPInit extern __typeof (xmlNanoHTTPInit) xmlNanoHTTPInit __attribute((alias("xmlNanoHTTPInit__internal_alias"))); #else #ifndef xmlNanoHTTPInit extern __typeof (xmlNanoHTTPInit) xmlNanoHTTPInit__internal_alias __attribute((visibility("hidden"))); #define xmlNanoHTTPInit xmlNanoHTTPInit__internal_alias #endif #endif #endif #if defined(LIBXML_HTTP_ENABLED) #ifdef bottom_nanohttp #undef xmlNanoHTTPMethod extern __typeof (xmlNanoHTTPMethod) xmlNanoHTTPMethod __attribute((alias("xmlNanoHTTPMethod__internal_alias"))); #else #ifndef xmlNanoHTTPMethod extern __typeof (xmlNanoHTTPMethod) xmlNanoHTTPMethod__internal_alias __attribute((visibility("hidden"))); #define xmlNanoHTTPMethod xmlNanoHTTPMethod__internal_alias #endif #endif #endif #if defined(LIBXML_HTTP_ENABLED) #ifdef bottom_nanohttp #undef xmlNanoHTTPMethodRedir extern __typeof (xmlNanoHTTPMethodRedir) xmlNanoHTTPMethodRedir __attribute((alias("xmlNanoHTTPMethodRedir__internal_alias"))); #else #ifndef xmlNanoHTTPMethodRedir extern __typeof (xmlNanoHTTPMethodRedir) xmlNanoHTTPMethodRedir__internal_alias __attribute((visibility("hidden"))); #define xmlNanoHTTPMethodRedir xmlNanoHTTPMethodRedir__internal_alias #endif #endif #endif #if defined(LIBXML_HTTP_ENABLED) #ifdef bottom_nanohttp #undef xmlNanoHTTPMimeType extern __typeof (xmlNanoHTTPMimeType) xmlNanoHTTPMimeType __attribute((alias("xmlNanoHTTPMimeType__internal_alias"))); #else #ifndef xmlNanoHTTPMimeType extern __typeof (xmlNanoHTTPMimeType) xmlNanoHTTPMimeType__internal_alias __attribute((visibility("hidden"))); #define xmlNanoHTTPMimeType xmlNanoHTTPMimeType__internal_alias #endif #endif #endif #if defined(LIBXML_HTTP_ENABLED) #ifdef bottom_nanohttp #undef xmlNanoHTTPOpen extern __typeof (xmlNanoHTTPOpen) xmlNanoHTTPOpen __attribute((alias("xmlNanoHTTPOpen__internal_alias"))); #else #ifndef xmlNanoHTTPOpen extern __typeof (xmlNanoHTTPOpen) xmlNanoHTTPOpen__internal_alias __attribute((visibility("hidden"))); #define xmlNanoHTTPOpen xmlNanoHTTPOpen__internal_alias #endif #endif #endif #if defined(LIBXML_HTTP_ENABLED) #ifdef bottom_nanohttp #undef xmlNanoHTTPOpenRedir extern __typeof (xmlNanoHTTPOpenRedir) xmlNanoHTTPOpenRedir __attribute((alias("xmlNanoHTTPOpenRedir__internal_alias"))); #else #ifndef xmlNanoHTTPOpenRedir extern __typeof (xmlNanoHTTPOpenRedir) xmlNanoHTTPOpenRedir__internal_alias __attribute((visibility("hidden"))); #define xmlNanoHTTPOpenRedir xmlNanoHTTPOpenRedir__internal_alias #endif #endif #endif #if defined(LIBXML_HTTP_ENABLED) #ifdef bottom_nanohttp #undef xmlNanoHTTPRead extern __typeof (xmlNanoHTTPRead) xmlNanoHTTPRead __attribute((alias("xmlNanoHTTPRead__internal_alias"))); #else #ifndef xmlNanoHTTPRead extern __typeof (xmlNanoHTTPRead) xmlNanoHTTPRead__internal_alias __attribute((visibility("hidden"))); #define xmlNanoHTTPRead xmlNanoHTTPRead__internal_alias #endif #endif #endif #if defined(LIBXML_HTTP_ENABLED) #ifdef bottom_nanohttp #undef xmlNanoHTTPRedir extern __typeof (xmlNanoHTTPRedir) xmlNanoHTTPRedir __attribute((alias("xmlNanoHTTPRedir__internal_alias"))); #else #ifndef xmlNanoHTTPRedir extern __typeof (xmlNanoHTTPRedir) xmlNanoHTTPRedir__internal_alias __attribute((visibility("hidden"))); #define xmlNanoHTTPRedir xmlNanoHTTPRedir__internal_alias #endif #endif #endif #if defined(LIBXML_HTTP_ENABLED) #ifdef bottom_nanohttp #undef xmlNanoHTTPReturnCode extern __typeof (xmlNanoHTTPReturnCode) xmlNanoHTTPReturnCode __attribute((alias("xmlNanoHTTPReturnCode__internal_alias"))); #else #ifndef xmlNanoHTTPReturnCode extern __typeof (xmlNanoHTTPReturnCode) xmlNanoHTTPReturnCode__internal_alias __attribute((visibility("hidden"))); #define xmlNanoHTTPReturnCode xmlNanoHTTPReturnCode__internal_alias #endif #endif #endif #if defined(LIBXML_HTTP_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_nanohttp #undef xmlNanoHTTPSave extern __typeof (xmlNanoHTTPSave) xmlNanoHTTPSave __attribute((alias("xmlNanoHTTPSave__internal_alias"))); #else #ifndef xmlNanoHTTPSave extern __typeof (xmlNanoHTTPSave) xmlNanoHTTPSave__internal_alias __attribute((visibility("hidden"))); #define xmlNanoHTTPSave xmlNanoHTTPSave__internal_alias #endif #endif #endif #if defined(LIBXML_HTTP_ENABLED) #ifdef bottom_nanohttp #undef xmlNanoHTTPScanProxy extern __typeof (xmlNanoHTTPScanProxy) xmlNanoHTTPScanProxy __attribute((alias("xmlNanoHTTPScanProxy__internal_alias"))); #else #ifndef xmlNanoHTTPScanProxy extern __typeof (xmlNanoHTTPScanProxy) xmlNanoHTTPScanProxy__internal_alias __attribute((visibility("hidden"))); #define xmlNanoHTTPScanProxy xmlNanoHTTPScanProxy__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED) #ifdef bottom_xmlregexp #undef xmlNewAutomata extern __typeof (xmlNewAutomata) xmlNewAutomata __attribute((alias("xmlNewAutomata__internal_alias"))); #else #ifndef xmlNewAutomata extern __typeof (xmlNewAutomata) xmlNewAutomata__internal_alias __attribute((visibility("hidden"))); #define xmlNewAutomata xmlNewAutomata__internal_alias #endif #endif #endif #ifdef bottom_tree #undef xmlNewCDataBlock extern __typeof (xmlNewCDataBlock) xmlNewCDataBlock __attribute((alias("xmlNewCDataBlock__internal_alias"))); #else #ifndef xmlNewCDataBlock extern __typeof (xmlNewCDataBlock) xmlNewCDataBlock__internal_alias __attribute((visibility("hidden"))); #define xmlNewCDataBlock xmlNewCDataBlock__internal_alias #endif #endif #if defined(LIBXML_CATALOG_ENABLED) #ifdef bottom_catalog #undef xmlNewCatalog extern __typeof (xmlNewCatalog) xmlNewCatalog __attribute((alias("xmlNewCatalog__internal_alias"))); #else #ifndef xmlNewCatalog extern __typeof (xmlNewCatalog) xmlNewCatalog__internal_alias __attribute((visibility("hidden"))); #define xmlNewCatalog xmlNewCatalog__internal_alias #endif #endif #endif #ifdef bottom_encoding #undef xmlNewCharEncodingHandler extern __typeof (xmlNewCharEncodingHandler) xmlNewCharEncodingHandler __attribute((alias("xmlNewCharEncodingHandler__internal_alias"))); #else #ifndef xmlNewCharEncodingHandler extern __typeof (xmlNewCharEncodingHandler) xmlNewCharEncodingHandler__internal_alias __attribute((visibility("hidden"))); #define xmlNewCharEncodingHandler xmlNewCharEncodingHandler__internal_alias #endif #endif #ifdef bottom_tree #undef xmlNewCharRef extern __typeof (xmlNewCharRef) xmlNewCharRef __attribute((alias("xmlNewCharRef__internal_alias"))); #else #ifndef xmlNewCharRef extern __typeof (xmlNewCharRef) xmlNewCharRef__internal_alias __attribute((visibility("hidden"))); #define xmlNewCharRef xmlNewCharRef__internal_alias #endif #endif #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_tree #undef xmlNewChild extern __typeof (xmlNewChild) xmlNewChild __attribute((alias("xmlNewChild__internal_alias"))); #else #ifndef xmlNewChild extern __typeof (xmlNewChild) xmlNewChild__internal_alias __attribute((visibility("hidden"))); #define xmlNewChild xmlNewChild__internal_alias #endif #endif #endif #ifdef bottom_tree #undef xmlNewComment extern __typeof (xmlNewComment) xmlNewComment __attribute((alias("xmlNewComment__internal_alias"))); #else #ifndef xmlNewComment extern __typeof (xmlNewComment) xmlNewComment__internal_alias __attribute((visibility("hidden"))); #define xmlNewComment xmlNewComment__internal_alias #endif #endif #ifdef bottom_tree #undef xmlNewDoc extern __typeof (xmlNewDoc) xmlNewDoc __attribute((alias("xmlNewDoc__internal_alias"))); #else #ifndef xmlNewDoc extern __typeof (xmlNewDoc) xmlNewDoc__internal_alias __attribute((visibility("hidden"))); #define xmlNewDoc xmlNewDoc__internal_alias #endif #endif #ifdef bottom_tree #undef xmlNewDocComment extern __typeof (xmlNewDocComment) xmlNewDocComment __attribute((alias("xmlNewDocComment__internal_alias"))); #else #ifndef xmlNewDocComment extern __typeof (xmlNewDocComment) xmlNewDocComment__internal_alias __attribute((visibility("hidden"))); #define xmlNewDocComment xmlNewDocComment__internal_alias #endif #endif #ifdef bottom_valid #undef xmlNewDocElementContent extern __typeof (xmlNewDocElementContent) xmlNewDocElementContent __attribute((alias("xmlNewDocElementContent__internal_alias"))); #else #ifndef xmlNewDocElementContent extern __typeof (xmlNewDocElementContent) xmlNewDocElementContent__internal_alias __attribute((visibility("hidden"))); #define xmlNewDocElementContent xmlNewDocElementContent__internal_alias #endif #endif #if defined(LIBXML_TREE_ENABLED) #ifdef bottom_tree #undef xmlNewDocFragment extern __typeof (xmlNewDocFragment) xmlNewDocFragment __attribute((alias("xmlNewDocFragment__internal_alias"))); #else #ifndef xmlNewDocFragment extern __typeof (xmlNewDocFragment) xmlNewDocFragment__internal_alias __attribute((visibility("hidden"))); #define xmlNewDocFragment xmlNewDocFragment__internal_alias #endif #endif #endif #ifdef bottom_tree #undef xmlNewDocNode extern __typeof (xmlNewDocNode) xmlNewDocNode __attribute((alias("xmlNewDocNode__internal_alias"))); #else #ifndef xmlNewDocNode extern __typeof (xmlNewDocNode) xmlNewDocNode__internal_alias __attribute((visibility("hidden"))); #define xmlNewDocNode xmlNewDocNode__internal_alias #endif #endif #ifdef bottom_tree #undef xmlNewDocNodeEatName extern __typeof (xmlNewDocNodeEatName) xmlNewDocNodeEatName __attribute((alias("xmlNewDocNodeEatName__internal_alias"))); #else #ifndef xmlNewDocNodeEatName extern __typeof (xmlNewDocNodeEatName) xmlNewDocNodeEatName__internal_alias __attribute((visibility("hidden"))); #define xmlNewDocNodeEatName xmlNewDocNodeEatName__internal_alias #endif #endif #ifdef bottom_tree #undef xmlNewDocPI extern __typeof (xmlNewDocPI) xmlNewDocPI __attribute((alias("xmlNewDocPI__internal_alias"))); #else #ifndef xmlNewDocPI extern __typeof (xmlNewDocPI) xmlNewDocPI__internal_alias __attribute((visibility("hidden"))); #define xmlNewDocPI xmlNewDocPI__internal_alias #endif #endif #ifdef bottom_tree #undef xmlNewDocProp extern __typeof (xmlNewDocProp) xmlNewDocProp __attribute((alias("xmlNewDocProp__internal_alias"))); #else #ifndef xmlNewDocProp extern __typeof (xmlNewDocProp) xmlNewDocProp__internal_alias __attribute((visibility("hidden"))); #define xmlNewDocProp xmlNewDocProp__internal_alias #endif #endif #if defined(LIBXML_TREE_ENABLED) #ifdef bottom_tree #undef xmlNewDocRawNode extern __typeof (xmlNewDocRawNode) xmlNewDocRawNode __attribute((alias("xmlNewDocRawNode__internal_alias"))); #else #ifndef xmlNewDocRawNode extern __typeof (xmlNewDocRawNode) xmlNewDocRawNode__internal_alias __attribute((visibility("hidden"))); #define xmlNewDocRawNode xmlNewDocRawNode__internal_alias #endif #endif #endif #ifdef bottom_tree #undef xmlNewDocText extern __typeof (xmlNewDocText) xmlNewDocText __attribute((alias("xmlNewDocText__internal_alias"))); #else #ifndef xmlNewDocText extern __typeof (xmlNewDocText) xmlNewDocText__internal_alias __attribute((visibility("hidden"))); #define xmlNewDocText xmlNewDocText__internal_alias #endif #endif #ifdef bottom_tree #undef xmlNewDocTextLen extern __typeof (xmlNewDocTextLen) xmlNewDocTextLen __attribute((alias("xmlNewDocTextLen__internal_alias"))); #else #ifndef xmlNewDocTextLen extern __typeof (xmlNewDocTextLen) xmlNewDocTextLen__internal_alias __attribute((visibility("hidden"))); #define xmlNewDocTextLen xmlNewDocTextLen__internal_alias #endif #endif #ifdef bottom_tree #undef xmlNewDtd extern __typeof (xmlNewDtd) xmlNewDtd __attribute((alias("xmlNewDtd__internal_alias"))); #else #ifndef xmlNewDtd extern __typeof (xmlNewDtd) xmlNewDtd__internal_alias __attribute((visibility("hidden"))); #define xmlNewDtd xmlNewDtd__internal_alias #endif #endif #ifdef bottom_valid #undef xmlNewElementContent extern __typeof (xmlNewElementContent) xmlNewElementContent __attribute((alias("xmlNewElementContent__internal_alias"))); #else #ifndef xmlNewElementContent extern __typeof (xmlNewElementContent) xmlNewElementContent__internal_alias __attribute((visibility("hidden"))); #define xmlNewElementContent xmlNewElementContent__internal_alias #endif #endif #ifdef bottom_parserInternals #undef xmlNewEntityInputStream extern __typeof (xmlNewEntityInputStream) xmlNewEntityInputStream __attribute((alias("xmlNewEntityInputStream__internal_alias"))); #else #ifndef xmlNewEntityInputStream extern __typeof (xmlNewEntityInputStream) xmlNewEntityInputStream__internal_alias __attribute((visibility("hidden"))); #define xmlNewEntityInputStream xmlNewEntityInputStream__internal_alias #endif #endif #if defined(LIBXML_LEGACY_ENABLED) #ifdef bottom_legacy #undef xmlNewGlobalNs extern __typeof (xmlNewGlobalNs) xmlNewGlobalNs __attribute((alias("xmlNewGlobalNs__internal_alias"))); #else #ifndef xmlNewGlobalNs extern __typeof (xmlNewGlobalNs) xmlNewGlobalNs__internal_alias __attribute((visibility("hidden"))); #define xmlNewGlobalNs xmlNewGlobalNs__internal_alias #endif #endif #endif #ifdef bottom_parserInternals #undef xmlNewIOInputStream extern __typeof (xmlNewIOInputStream) xmlNewIOInputStream __attribute((alias("xmlNewIOInputStream__internal_alias"))); #else #ifndef xmlNewIOInputStream extern __typeof (xmlNewIOInputStream) xmlNewIOInputStream__internal_alias __attribute((visibility("hidden"))); #define xmlNewIOInputStream xmlNewIOInputStream__internal_alias #endif #endif #ifdef bottom_parserInternals #undef xmlNewInputFromFile extern __typeof (xmlNewInputFromFile) xmlNewInputFromFile __attribute((alias("xmlNewInputFromFile__internal_alias"))); #else #ifndef xmlNewInputFromFile extern __typeof (xmlNewInputFromFile) xmlNewInputFromFile__internal_alias __attribute((visibility("hidden"))); #define xmlNewInputFromFile xmlNewInputFromFile__internal_alias #endif #endif #ifdef bottom_parserInternals #undef xmlNewInputStream extern __typeof (xmlNewInputStream) xmlNewInputStream __attribute((alias("xmlNewInputStream__internal_alias"))); #else #ifndef xmlNewInputStream extern __typeof (xmlNewInputStream) xmlNewInputStream__internal_alias __attribute((visibility("hidden"))); #define xmlNewInputStream xmlNewInputStream__internal_alias #endif #endif #ifdef bottom_threads #undef xmlNewMutex extern __typeof (xmlNewMutex) xmlNewMutex __attribute((alias("xmlNewMutex__internal_alias"))); #else #ifndef xmlNewMutex extern __typeof (xmlNewMutex) xmlNewMutex__internal_alias __attribute((visibility("hidden"))); #define xmlNewMutex xmlNewMutex__internal_alias #endif #endif #ifdef bottom_tree #undef xmlNewNode extern __typeof (xmlNewNode) xmlNewNode __attribute((alias("xmlNewNode__internal_alias"))); #else #ifndef xmlNewNode extern __typeof (xmlNewNode) xmlNewNode__internal_alias __attribute((visibility("hidden"))); #define xmlNewNode xmlNewNode__internal_alias #endif #endif #ifdef bottom_tree #undef xmlNewNodeEatName extern __typeof (xmlNewNodeEatName) xmlNewNodeEatName __attribute((alias("xmlNewNodeEatName__internal_alias"))); #else #ifndef xmlNewNodeEatName extern __typeof (xmlNewNodeEatName) xmlNewNodeEatName__internal_alias __attribute((visibility("hidden"))); #define xmlNewNodeEatName xmlNewNodeEatName__internal_alias #endif #endif #ifdef bottom_tree #undef xmlNewNs extern __typeof (xmlNewNs) xmlNewNs __attribute((alias("xmlNewNs__internal_alias"))); #else #ifndef xmlNewNs extern __typeof (xmlNewNs) xmlNewNs__internal_alias __attribute((visibility("hidden"))); #define xmlNewNs xmlNewNs__internal_alias #endif #endif #ifdef bottom_tree #undef xmlNewNsProp extern __typeof (xmlNewNsProp) xmlNewNsProp __attribute((alias("xmlNewNsProp__internal_alias"))); #else #ifndef xmlNewNsProp extern __typeof (xmlNewNsProp) xmlNewNsProp__internal_alias __attribute((visibility("hidden"))); #define xmlNewNsProp xmlNewNsProp__internal_alias #endif #endif #ifdef bottom_tree #undef xmlNewNsPropEatName extern __typeof (xmlNewNsPropEatName) xmlNewNsPropEatName __attribute((alias("xmlNewNsPropEatName__internal_alias"))); #else #ifndef xmlNewNsPropEatName extern __typeof (xmlNewNsPropEatName) xmlNewNsPropEatName__internal_alias __attribute((visibility("hidden"))); #define xmlNewNsPropEatName xmlNewNsPropEatName__internal_alias #endif #endif #ifdef bottom_tree #undef xmlNewPI extern __typeof (xmlNewPI) xmlNewPI __attribute((alias("xmlNewPI__internal_alias"))); #else #ifndef xmlNewPI extern __typeof (xmlNewPI) xmlNewPI__internal_alias __attribute((visibility("hidden"))); #define xmlNewPI xmlNewPI__internal_alias #endif #endif #ifdef bottom_parserInternals #undef xmlNewParserCtxt extern __typeof (xmlNewParserCtxt) xmlNewParserCtxt __attribute((alias("xmlNewParserCtxt__internal_alias"))); #else #ifndef xmlNewParserCtxt extern __typeof (xmlNewParserCtxt) xmlNewParserCtxt__internal_alias __attribute((visibility("hidden"))); #define xmlNewParserCtxt xmlNewParserCtxt__internal_alias #endif #endif #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_tree #undef xmlNewProp extern __typeof (xmlNewProp) xmlNewProp __attribute((alias("xmlNewProp__internal_alias"))); #else #ifndef xmlNewProp extern __typeof (xmlNewProp) xmlNewProp__internal_alias __attribute((visibility("hidden"))); #define xmlNewProp xmlNewProp__internal_alias #endif #endif #endif #ifdef bottom_threads #undef xmlNewRMutex extern __typeof (xmlNewRMutex) xmlNewRMutex __attribute((alias("xmlNewRMutex__internal_alias"))); #else #ifndef xmlNewRMutex extern __typeof (xmlNewRMutex) xmlNewRMutex__internal_alias __attribute((visibility("hidden"))); #define xmlNewRMutex xmlNewRMutex__internal_alias #endif #endif #ifdef bottom_tree #undef xmlNewReference extern __typeof (xmlNewReference) xmlNewReference __attribute((alias("xmlNewReference__internal_alias"))); #else #ifndef xmlNewReference extern __typeof (xmlNewReference) xmlNewReference__internal_alias __attribute((visibility("hidden"))); #define xmlNewReference xmlNewReference__internal_alias #endif #endif #ifdef bottom_parserInternals #undef xmlNewStringInputStream extern __typeof (xmlNewStringInputStream) xmlNewStringInputStream __attribute((alias("xmlNewStringInputStream__internal_alias"))); #else #ifndef xmlNewStringInputStream extern __typeof (xmlNewStringInputStream) xmlNewStringInputStream__internal_alias __attribute((visibility("hidden"))); #define xmlNewStringInputStream xmlNewStringInputStream__internal_alias #endif #endif #ifdef bottom_tree #undef xmlNewText extern __typeof (xmlNewText) xmlNewText __attribute((alias("xmlNewText__internal_alias"))); #else #ifndef xmlNewText extern __typeof (xmlNewText) xmlNewText__internal_alias __attribute((visibility("hidden"))); #define xmlNewText xmlNewText__internal_alias #endif #endif #if defined(LIBXML_TREE_ENABLED) #ifdef bottom_tree #undef xmlNewTextChild extern __typeof (xmlNewTextChild) xmlNewTextChild __attribute((alias("xmlNewTextChild__internal_alias"))); #else #ifndef xmlNewTextChild extern __typeof (xmlNewTextChild) xmlNewTextChild__internal_alias __attribute((visibility("hidden"))); #define xmlNewTextChild xmlNewTextChild__internal_alias #endif #endif #endif #ifdef bottom_tree #undef xmlNewTextLen extern __typeof (xmlNewTextLen) xmlNewTextLen __attribute((alias("xmlNewTextLen__internal_alias"))); #else #ifndef xmlNewTextLen extern __typeof (xmlNewTextLen) xmlNewTextLen__internal_alias __attribute((visibility("hidden"))); #define xmlNewTextLen xmlNewTextLen__internal_alias #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlNewTextReader extern __typeof (xmlNewTextReader) xmlNewTextReader __attribute((alias("xmlNewTextReader__internal_alias"))); #else #ifndef xmlNewTextReader extern __typeof (xmlNewTextReader) xmlNewTextReader__internal_alias __attribute((visibility("hidden"))); #define xmlNewTextReader xmlNewTextReader__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlNewTextReaderFilename extern __typeof (xmlNewTextReaderFilename) xmlNewTextReaderFilename __attribute((alias("xmlNewTextReaderFilename__internal_alias"))); #else #ifndef xmlNewTextReaderFilename extern __typeof (xmlNewTextReaderFilename) xmlNewTextReaderFilename__internal_alias __attribute((visibility("hidden"))); #define xmlNewTextReaderFilename xmlNewTextReaderFilename__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlNewTextWriter extern __typeof (xmlNewTextWriter) xmlNewTextWriter __attribute((alias("xmlNewTextWriter__internal_alias"))); #else #ifndef xmlNewTextWriter extern __typeof (xmlNewTextWriter) xmlNewTextWriter__internal_alias __attribute((visibility("hidden"))); #define xmlNewTextWriter xmlNewTextWriter__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlNewTextWriterDoc extern __typeof (xmlNewTextWriterDoc) xmlNewTextWriterDoc __attribute((alias("xmlNewTextWriterDoc__internal_alias"))); #else #ifndef xmlNewTextWriterDoc extern __typeof (xmlNewTextWriterDoc) xmlNewTextWriterDoc__internal_alias __attribute((visibility("hidden"))); #define xmlNewTextWriterDoc xmlNewTextWriterDoc__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlNewTextWriterFilename extern __typeof (xmlNewTextWriterFilename) xmlNewTextWriterFilename __attribute((alias("xmlNewTextWriterFilename__internal_alias"))); #else #ifndef xmlNewTextWriterFilename extern __typeof (xmlNewTextWriterFilename) xmlNewTextWriterFilename__internal_alias __attribute((visibility("hidden"))); #define xmlNewTextWriterFilename xmlNewTextWriterFilename__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlNewTextWriterMemory extern __typeof (xmlNewTextWriterMemory) xmlNewTextWriterMemory __attribute((alias("xmlNewTextWriterMemory__internal_alias"))); #else #ifndef xmlNewTextWriterMemory extern __typeof (xmlNewTextWriterMemory) xmlNewTextWriterMemory__internal_alias __attribute((visibility("hidden"))); #define xmlNewTextWriterMemory xmlNewTextWriterMemory__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlNewTextWriterPushParser extern __typeof (xmlNewTextWriterPushParser) xmlNewTextWriterPushParser __attribute((alias("xmlNewTextWriterPushParser__internal_alias"))); #else #ifndef xmlNewTextWriterPushParser extern __typeof (xmlNewTextWriterPushParser) xmlNewTextWriterPushParser__internal_alias __attribute((visibility("hidden"))); #define xmlNewTextWriterPushParser xmlNewTextWriterPushParser__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlNewTextWriterTree extern __typeof (xmlNewTextWriterTree) xmlNewTextWriterTree __attribute((alias("xmlNewTextWriterTree__internal_alias"))); #else #ifndef xmlNewTextWriterTree extern __typeof (xmlNewTextWriterTree) xmlNewTextWriterTree__internal_alias __attribute((visibility("hidden"))); #define xmlNewTextWriterTree xmlNewTextWriterTree__internal_alias #endif #endif #endif #if defined(LIBXML_VALID_ENABLED) #ifdef bottom_valid #undef xmlNewValidCtxt extern __typeof (xmlNewValidCtxt) xmlNewValidCtxt __attribute((alias("xmlNewValidCtxt__internal_alias"))); #else #ifndef xmlNewValidCtxt extern __typeof (xmlNewValidCtxt) xmlNewValidCtxt__internal_alias __attribute((visibility("hidden"))); #define xmlNewValidCtxt xmlNewValidCtxt__internal_alias #endif #endif #endif #ifdef bottom_parserInternals #undef xmlNextChar extern __typeof (xmlNextChar) xmlNextChar __attribute((alias("xmlNextChar__internal_alias"))); #else #ifndef xmlNextChar extern __typeof (xmlNextChar) xmlNextChar__internal_alias __attribute((visibility("hidden"))); #define xmlNextChar xmlNextChar__internal_alias #endif #endif #ifdef bottom_xmlIO #undef xmlNoNetExternalEntityLoader extern __typeof (xmlNoNetExternalEntityLoader) xmlNoNetExternalEntityLoader __attribute((alias("xmlNoNetExternalEntityLoader__internal_alias"))); #else #ifndef xmlNoNetExternalEntityLoader extern __typeof (xmlNoNetExternalEntityLoader) xmlNoNetExternalEntityLoader__internal_alias __attribute((visibility("hidden"))); #define xmlNoNetExternalEntityLoader xmlNoNetExternalEntityLoader__internal_alias #endif #endif #ifdef bottom_tree #undef xmlNodeAddContent extern __typeof (xmlNodeAddContent) xmlNodeAddContent __attribute((alias("xmlNodeAddContent__internal_alias"))); #else #ifndef xmlNodeAddContent extern __typeof (xmlNodeAddContent) xmlNodeAddContent__internal_alias __attribute((visibility("hidden"))); #define xmlNodeAddContent xmlNodeAddContent__internal_alias #endif #endif #ifdef bottom_tree #undef xmlNodeAddContentLen extern __typeof (xmlNodeAddContentLen) xmlNodeAddContentLen __attribute((alias("xmlNodeAddContentLen__internal_alias"))); #else #ifndef xmlNodeAddContentLen extern __typeof (xmlNodeAddContentLen) xmlNodeAddContentLen__internal_alias __attribute((visibility("hidden"))); #define xmlNodeAddContentLen xmlNodeAddContentLen__internal_alias #endif #endif #ifdef bottom_tree #undef xmlNodeBufGetContent extern __typeof (xmlNodeBufGetContent) xmlNodeBufGetContent __attribute((alias("xmlNodeBufGetContent__internal_alias"))); #else #ifndef xmlNodeBufGetContent extern __typeof (xmlNodeBufGetContent) xmlNodeBufGetContent__internal_alias __attribute((visibility("hidden"))); #define xmlNodeBufGetContent xmlNodeBufGetContent__internal_alias #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_xmlsave #undef xmlNodeDump extern __typeof (xmlNodeDump) xmlNodeDump __attribute((alias("xmlNodeDump__internal_alias"))); #else #ifndef xmlNodeDump extern __typeof (xmlNodeDump) xmlNodeDump__internal_alias __attribute((visibility("hidden"))); #define xmlNodeDump xmlNodeDump__internal_alias #endif #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_xmlsave #undef xmlNodeDumpOutput extern __typeof (xmlNodeDumpOutput) xmlNodeDumpOutput __attribute((alias("xmlNodeDumpOutput__internal_alias"))); #else #ifndef xmlNodeDumpOutput extern __typeof (xmlNodeDumpOutput) xmlNodeDumpOutput__internal_alias __attribute((visibility("hidden"))); #define xmlNodeDumpOutput xmlNodeDumpOutput__internal_alias #endif #endif #endif #ifdef bottom_tree #undef xmlNodeGetBase extern __typeof (xmlNodeGetBase) xmlNodeGetBase __attribute((alias("xmlNodeGetBase__internal_alias"))); #else #ifndef xmlNodeGetBase extern __typeof (xmlNodeGetBase) xmlNodeGetBase__internal_alias __attribute((visibility("hidden"))); #define xmlNodeGetBase xmlNodeGetBase__internal_alias #endif #endif #ifdef bottom_tree #undef xmlNodeGetContent extern __typeof (xmlNodeGetContent) xmlNodeGetContent __attribute((alias("xmlNodeGetContent__internal_alias"))); #else #ifndef xmlNodeGetContent extern __typeof (xmlNodeGetContent) xmlNodeGetContent__internal_alias __attribute((visibility("hidden"))); #define xmlNodeGetContent xmlNodeGetContent__internal_alias #endif #endif #ifdef bottom_tree #undef xmlNodeGetLang extern __typeof (xmlNodeGetLang) xmlNodeGetLang __attribute((alias("xmlNodeGetLang__internal_alias"))); #else #ifndef xmlNodeGetLang extern __typeof (xmlNodeGetLang) xmlNodeGetLang__internal_alias __attribute((visibility("hidden"))); #define xmlNodeGetLang xmlNodeGetLang__internal_alias #endif #endif #ifdef bottom_tree #undef xmlNodeGetSpacePreserve extern __typeof (xmlNodeGetSpacePreserve) xmlNodeGetSpacePreserve __attribute((alias("xmlNodeGetSpacePreserve__internal_alias"))); #else #ifndef xmlNodeGetSpacePreserve extern __typeof (xmlNodeGetSpacePreserve) xmlNodeGetSpacePreserve__internal_alias __attribute((visibility("hidden"))); #define xmlNodeGetSpacePreserve xmlNodeGetSpacePreserve__internal_alias #endif #endif #ifdef bottom_tree #undef xmlNodeIsText extern __typeof (xmlNodeIsText) xmlNodeIsText __attribute((alias("xmlNodeIsText__internal_alias"))); #else #ifndef xmlNodeIsText extern __typeof (xmlNodeIsText) xmlNodeIsText__internal_alias __attribute((visibility("hidden"))); #define xmlNodeIsText xmlNodeIsText__internal_alias #endif #endif #if defined(LIBXML_TREE_ENABLED) #ifdef bottom_tree #undef xmlNodeListGetRawString extern __typeof (xmlNodeListGetRawString) xmlNodeListGetRawString __attribute((alias("xmlNodeListGetRawString__internal_alias"))); #else #ifndef xmlNodeListGetRawString extern __typeof (xmlNodeListGetRawString) xmlNodeListGetRawString__internal_alias __attribute((visibility("hidden"))); #define xmlNodeListGetRawString xmlNodeListGetRawString__internal_alias #endif #endif #endif #ifdef bottom_tree #undef xmlNodeListGetString extern __typeof (xmlNodeListGetString) xmlNodeListGetString __attribute((alias("xmlNodeListGetString__internal_alias"))); #else #ifndef xmlNodeListGetString extern __typeof (xmlNodeListGetString) xmlNodeListGetString__internal_alias __attribute((visibility("hidden"))); #define xmlNodeListGetString xmlNodeListGetString__internal_alias #endif #endif #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) #ifdef bottom_tree #undef xmlNodeSetBase extern __typeof (xmlNodeSetBase) xmlNodeSetBase __attribute((alias("xmlNodeSetBase__internal_alias"))); #else #ifndef xmlNodeSetBase extern __typeof (xmlNodeSetBase) xmlNodeSetBase__internal_alias __attribute((visibility("hidden"))); #define xmlNodeSetBase xmlNodeSetBase__internal_alias #endif #endif #endif #ifdef bottom_tree #undef xmlNodeSetContent extern __typeof (xmlNodeSetContent) xmlNodeSetContent __attribute((alias("xmlNodeSetContent__internal_alias"))); #else #ifndef xmlNodeSetContent extern __typeof (xmlNodeSetContent) xmlNodeSetContent__internal_alias __attribute((visibility("hidden"))); #define xmlNodeSetContent xmlNodeSetContent__internal_alias #endif #endif #if defined(LIBXML_TREE_ENABLED) #ifdef bottom_tree #undef xmlNodeSetContentLen extern __typeof (xmlNodeSetContentLen) xmlNodeSetContentLen __attribute((alias("xmlNodeSetContentLen__internal_alias"))); #else #ifndef xmlNodeSetContentLen extern __typeof (xmlNodeSetContentLen) xmlNodeSetContentLen__internal_alias __attribute((visibility("hidden"))); #define xmlNodeSetContentLen xmlNodeSetContentLen__internal_alias #endif #endif #endif #if defined(LIBXML_TREE_ENABLED) #ifdef bottom_tree #undef xmlNodeSetLang extern __typeof (xmlNodeSetLang) xmlNodeSetLang __attribute((alias("xmlNodeSetLang__internal_alias"))); #else #ifndef xmlNodeSetLang extern __typeof (xmlNodeSetLang) xmlNodeSetLang__internal_alias __attribute((visibility("hidden"))); #define xmlNodeSetLang xmlNodeSetLang__internal_alias #endif #endif #endif #if defined(LIBXML_TREE_ENABLED) #ifdef bottom_tree #undef xmlNodeSetName extern __typeof (xmlNodeSetName) xmlNodeSetName __attribute((alias("xmlNodeSetName__internal_alias"))); #else #ifndef xmlNodeSetName extern __typeof (xmlNodeSetName) xmlNodeSetName__internal_alias __attribute((visibility("hidden"))); #define xmlNodeSetName xmlNodeSetName__internal_alias #endif #endif #endif #if defined(LIBXML_TREE_ENABLED) #ifdef bottom_tree #undef xmlNodeSetSpacePreserve extern __typeof (xmlNodeSetSpacePreserve) xmlNodeSetSpacePreserve __attribute((alias("xmlNodeSetSpacePreserve__internal_alias"))); #else #ifndef xmlNodeSetSpacePreserve extern __typeof (xmlNodeSetSpacePreserve) xmlNodeSetSpacePreserve__internal_alias __attribute((visibility("hidden"))); #define xmlNodeSetSpacePreserve xmlNodeSetSpacePreserve__internal_alias #endif #endif #endif #ifdef bottom_uri #undef xmlNormalizeURIPath extern __typeof (xmlNormalizeURIPath) xmlNormalizeURIPath __attribute((alias("xmlNormalizeURIPath__internal_alias"))); #else #ifndef xmlNormalizeURIPath extern __typeof (xmlNormalizeURIPath) xmlNormalizeURIPath__internal_alias __attribute((visibility("hidden"))); #define xmlNormalizeURIPath xmlNormalizeURIPath__internal_alias #endif #endif #ifdef bottom_xmlIO #undef xmlNormalizeWindowsPath extern __typeof (xmlNormalizeWindowsPath) xmlNormalizeWindowsPath __attribute((alias("xmlNormalizeWindowsPath__internal_alias"))); #else #ifndef xmlNormalizeWindowsPath extern __typeof (xmlNormalizeWindowsPath) xmlNormalizeWindowsPath__internal_alias __attribute((visibility("hidden"))); #define xmlNormalizeWindowsPath xmlNormalizeWindowsPath__internal_alias #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_xmlIO #undef xmlOutputBufferClose extern __typeof (xmlOutputBufferClose) xmlOutputBufferClose __attribute((alias("xmlOutputBufferClose__internal_alias"))); #else #ifndef xmlOutputBufferClose extern __typeof (xmlOutputBufferClose) xmlOutputBufferClose__internal_alias __attribute((visibility("hidden"))); #define xmlOutputBufferClose xmlOutputBufferClose__internal_alias #endif #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_xmlIO #undef xmlOutputBufferCreateBuffer extern __typeof (xmlOutputBufferCreateBuffer) xmlOutputBufferCreateBuffer __attribute((alias("xmlOutputBufferCreateBuffer__internal_alias"))); #else #ifndef xmlOutputBufferCreateBuffer extern __typeof (xmlOutputBufferCreateBuffer) xmlOutputBufferCreateBuffer__internal_alias __attribute((visibility("hidden"))); #define xmlOutputBufferCreateBuffer xmlOutputBufferCreateBuffer__internal_alias #endif #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_xmlIO #undef xmlOutputBufferCreateFd extern __typeof (xmlOutputBufferCreateFd) xmlOutputBufferCreateFd __attribute((alias("xmlOutputBufferCreateFd__internal_alias"))); #else #ifndef xmlOutputBufferCreateFd extern __typeof (xmlOutputBufferCreateFd) xmlOutputBufferCreateFd__internal_alias __attribute((visibility("hidden"))); #define xmlOutputBufferCreateFd xmlOutputBufferCreateFd__internal_alias #endif #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_xmlIO #undef xmlOutputBufferCreateFile extern __typeof (xmlOutputBufferCreateFile) xmlOutputBufferCreateFile __attribute((alias("xmlOutputBufferCreateFile__internal_alias"))); #else #ifndef xmlOutputBufferCreateFile extern __typeof (xmlOutputBufferCreateFile) xmlOutputBufferCreateFile__internal_alias __attribute((visibility("hidden"))); #define xmlOutputBufferCreateFile xmlOutputBufferCreateFile__internal_alias #endif #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_xmlIO #undef xmlOutputBufferCreateFilename extern __typeof (xmlOutputBufferCreateFilename) xmlOutputBufferCreateFilename __attribute((alias("xmlOutputBufferCreateFilename__internal_alias"))); #else #ifndef xmlOutputBufferCreateFilename extern __typeof (xmlOutputBufferCreateFilename) xmlOutputBufferCreateFilename__internal_alias __attribute((visibility("hidden"))); #define xmlOutputBufferCreateFilename xmlOutputBufferCreateFilename__internal_alias #endif #endif #endif #ifdef bottom_xmlIO #undef xmlOutputBufferCreateFilenameDefault extern __typeof (xmlOutputBufferCreateFilenameDefault) xmlOutputBufferCreateFilenameDefault __attribute((alias("xmlOutputBufferCreateFilenameDefault__internal_alias"))); #else #ifndef xmlOutputBufferCreateFilenameDefault extern __typeof (xmlOutputBufferCreateFilenameDefault) xmlOutputBufferCreateFilenameDefault__internal_alias __attribute((visibility("hidden"))); #define xmlOutputBufferCreateFilenameDefault xmlOutputBufferCreateFilenameDefault__internal_alias #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_xmlIO #undef xmlOutputBufferCreateIO extern __typeof (xmlOutputBufferCreateIO) xmlOutputBufferCreateIO __attribute((alias("xmlOutputBufferCreateIO__internal_alias"))); #else #ifndef xmlOutputBufferCreateIO extern __typeof (xmlOutputBufferCreateIO) xmlOutputBufferCreateIO__internal_alias __attribute((visibility("hidden"))); #define xmlOutputBufferCreateIO xmlOutputBufferCreateIO__internal_alias #endif #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_xmlIO #undef xmlOutputBufferFlush extern __typeof (xmlOutputBufferFlush) xmlOutputBufferFlush __attribute((alias("xmlOutputBufferFlush__internal_alias"))); #else #ifndef xmlOutputBufferFlush extern __typeof (xmlOutputBufferFlush) xmlOutputBufferFlush__internal_alias __attribute((visibility("hidden"))); #define xmlOutputBufferFlush xmlOutputBufferFlush__internal_alias #endif #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_xmlIO #undef xmlOutputBufferWrite extern __typeof (xmlOutputBufferWrite) xmlOutputBufferWrite __attribute((alias("xmlOutputBufferWrite__internal_alias"))); #else #ifndef xmlOutputBufferWrite extern __typeof (xmlOutputBufferWrite) xmlOutputBufferWrite__internal_alias __attribute((visibility("hidden"))); #define xmlOutputBufferWrite xmlOutputBufferWrite__internal_alias #endif #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_xmlIO #undef xmlOutputBufferWriteEscape extern __typeof (xmlOutputBufferWriteEscape) xmlOutputBufferWriteEscape __attribute((alias("xmlOutputBufferWriteEscape__internal_alias"))); #else #ifndef xmlOutputBufferWriteEscape extern __typeof (xmlOutputBufferWriteEscape) xmlOutputBufferWriteEscape__internal_alias __attribute((visibility("hidden"))); #define xmlOutputBufferWriteEscape xmlOutputBufferWriteEscape__internal_alias #endif #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_xmlIO #undef xmlOutputBufferWriteString extern __typeof (xmlOutputBufferWriteString) xmlOutputBufferWriteString __attribute((alias("xmlOutputBufferWriteString__internal_alias"))); #else #ifndef xmlOutputBufferWriteString extern __typeof (xmlOutputBufferWriteString) xmlOutputBufferWriteString__internal_alias __attribute((visibility("hidden"))); #define xmlOutputBufferWriteString xmlOutputBufferWriteString__internal_alias #endif #endif #endif #ifdef bottom_parser #undef xmlParseAttValue extern __typeof (xmlParseAttValue) xmlParseAttValue __attribute((alias("xmlParseAttValue__internal_alias"))); #else #ifndef xmlParseAttValue extern __typeof (xmlParseAttValue) xmlParseAttValue__internal_alias __attribute((visibility("hidden"))); #define xmlParseAttValue xmlParseAttValue__internal_alias #endif #endif #if defined(LIBXML_SAX1_ENABLED) #ifdef bottom_parser #undef xmlParseAttribute extern __typeof (xmlParseAttribute) xmlParseAttribute __attribute((alias("xmlParseAttribute__internal_alias"))); #else #ifndef xmlParseAttribute extern __typeof (xmlParseAttribute) xmlParseAttribute__internal_alias __attribute((visibility("hidden"))); #define xmlParseAttribute xmlParseAttribute__internal_alias #endif #endif #endif #ifdef bottom_parser #undef xmlParseAttributeListDecl extern __typeof (xmlParseAttributeListDecl) xmlParseAttributeListDecl __attribute((alias("xmlParseAttributeListDecl__internal_alias"))); #else #ifndef xmlParseAttributeListDecl extern __typeof (xmlParseAttributeListDecl) xmlParseAttributeListDecl__internal_alias __attribute((visibility("hidden"))); #define xmlParseAttributeListDecl xmlParseAttributeListDecl__internal_alias #endif #endif #ifdef bottom_parser #undef xmlParseAttributeType extern __typeof (xmlParseAttributeType) xmlParseAttributeType __attribute((alias("xmlParseAttributeType__internal_alias"))); #else #ifndef xmlParseAttributeType extern __typeof (xmlParseAttributeType) xmlParseAttributeType__internal_alias __attribute((visibility("hidden"))); #define xmlParseAttributeType xmlParseAttributeType__internal_alias #endif #endif #if defined(LIBXML_SAX1_ENABLED) #ifdef bottom_parser #undef xmlParseBalancedChunkMemory extern __typeof (xmlParseBalancedChunkMemory) xmlParseBalancedChunkMemory __attribute((alias("xmlParseBalancedChunkMemory__internal_alias"))); #else #ifndef xmlParseBalancedChunkMemory extern __typeof (xmlParseBalancedChunkMemory) xmlParseBalancedChunkMemory__internal_alias __attribute((visibility("hidden"))); #define xmlParseBalancedChunkMemory xmlParseBalancedChunkMemory__internal_alias #endif #endif #endif #if defined(LIBXML_SAX1_ENABLED) #ifdef bottom_parser #undef xmlParseBalancedChunkMemoryRecover extern __typeof (xmlParseBalancedChunkMemoryRecover) xmlParseBalancedChunkMemoryRecover __attribute((alias("xmlParseBalancedChunkMemoryRecover__internal_alias"))); #else #ifndef xmlParseBalancedChunkMemoryRecover extern __typeof (xmlParseBalancedChunkMemoryRecover) xmlParseBalancedChunkMemoryRecover__internal_alias __attribute((visibility("hidden"))); #define xmlParseBalancedChunkMemoryRecover xmlParseBalancedChunkMemoryRecover__internal_alias #endif #endif #endif #ifdef bottom_parser #undef xmlParseCDSect extern __typeof (xmlParseCDSect) xmlParseCDSect __attribute((alias("xmlParseCDSect__internal_alias"))); #else #ifndef xmlParseCDSect extern __typeof (xmlParseCDSect) xmlParseCDSect__internal_alias __attribute((visibility("hidden"))); #define xmlParseCDSect xmlParseCDSect__internal_alias #endif #endif #if defined(LIBXML_CATALOG_ENABLED) #ifdef bottom_catalog #undef xmlParseCatalogFile extern __typeof (xmlParseCatalogFile) xmlParseCatalogFile __attribute((alias("xmlParseCatalogFile__internal_alias"))); #else #ifndef xmlParseCatalogFile extern __typeof (xmlParseCatalogFile) xmlParseCatalogFile__internal_alias __attribute((visibility("hidden"))); #define xmlParseCatalogFile xmlParseCatalogFile__internal_alias #endif #endif #endif #ifdef bottom_parser #undef xmlParseCharData extern __typeof (xmlParseCharData) xmlParseCharData __attribute((alias("xmlParseCharData__internal_alias"))); #else #ifndef xmlParseCharData extern __typeof (xmlParseCharData) xmlParseCharData__internal_alias __attribute((visibility("hidden"))); #define xmlParseCharData xmlParseCharData__internal_alias #endif #endif #ifdef bottom_encoding #undef xmlParseCharEncoding extern __typeof (xmlParseCharEncoding) xmlParseCharEncoding __attribute((alias("xmlParseCharEncoding__internal_alias"))); #else #ifndef xmlParseCharEncoding extern __typeof (xmlParseCharEncoding) xmlParseCharEncoding__internal_alias __attribute((visibility("hidden"))); #define xmlParseCharEncoding xmlParseCharEncoding__internal_alias #endif #endif #ifdef bottom_parser #undef xmlParseCharRef extern __typeof (xmlParseCharRef) xmlParseCharRef __attribute((alias("xmlParseCharRef__internal_alias"))); #else #ifndef xmlParseCharRef extern __typeof (xmlParseCharRef) xmlParseCharRef__internal_alias __attribute((visibility("hidden"))); #define xmlParseCharRef xmlParseCharRef__internal_alias #endif #endif #if defined(LIBXML_PUSH_ENABLED) #ifdef bottom_parser #undef xmlParseChunk extern __typeof (xmlParseChunk) xmlParseChunk __attribute((alias("xmlParseChunk__internal_alias"))); #else #ifndef xmlParseChunk extern __typeof (xmlParseChunk) xmlParseChunk__internal_alias __attribute((visibility("hidden"))); #define xmlParseChunk xmlParseChunk__internal_alias #endif #endif #endif #ifdef bottom_parser #undef xmlParseComment extern __typeof (xmlParseComment) xmlParseComment __attribute((alias("xmlParseComment__internal_alias"))); #else #ifndef xmlParseComment extern __typeof (xmlParseComment) xmlParseComment__internal_alias __attribute((visibility("hidden"))); #define xmlParseComment xmlParseComment__internal_alias #endif #endif #ifdef bottom_parser #undef xmlParseContent extern __typeof (xmlParseContent) xmlParseContent __attribute((alias("xmlParseContent__internal_alias"))); #else #ifndef xmlParseContent extern __typeof (xmlParseContent) xmlParseContent__internal_alias __attribute((visibility("hidden"))); #define xmlParseContent xmlParseContent__internal_alias #endif #endif #ifdef bottom_parser #undef xmlParseCtxtExternalEntity extern __typeof (xmlParseCtxtExternalEntity) xmlParseCtxtExternalEntity __attribute((alias("xmlParseCtxtExternalEntity__internal_alias"))); #else #ifndef xmlParseCtxtExternalEntity extern __typeof (xmlParseCtxtExternalEntity) xmlParseCtxtExternalEntity__internal_alias __attribute((visibility("hidden"))); #define xmlParseCtxtExternalEntity xmlParseCtxtExternalEntity__internal_alias #endif #endif #if defined(LIBXML_VALID_ENABLED) #ifdef bottom_parser #undef xmlParseDTD extern __typeof (xmlParseDTD) xmlParseDTD __attribute((alias("xmlParseDTD__internal_alias"))); #else #ifndef xmlParseDTD extern __typeof (xmlParseDTD) xmlParseDTD__internal_alias __attribute((visibility("hidden"))); #define xmlParseDTD xmlParseDTD__internal_alias #endif #endif #endif #ifdef bottom_parser #undef xmlParseDefaultDecl extern __typeof (xmlParseDefaultDecl) xmlParseDefaultDecl __attribute((alias("xmlParseDefaultDecl__internal_alias"))); #else #ifndef xmlParseDefaultDecl extern __typeof (xmlParseDefaultDecl) xmlParseDefaultDecl__internal_alias __attribute((visibility("hidden"))); #define xmlParseDefaultDecl xmlParseDefaultDecl__internal_alias #endif #endif #if defined(LIBXML_SAX1_ENABLED) #ifdef bottom_parser #undef xmlParseDoc extern __typeof (xmlParseDoc) xmlParseDoc __attribute((alias("xmlParseDoc__internal_alias"))); #else #ifndef xmlParseDoc extern __typeof (xmlParseDoc) xmlParseDoc__internal_alias __attribute((visibility("hidden"))); #define xmlParseDoc xmlParseDoc__internal_alias #endif #endif #endif #ifdef bottom_parser #undef xmlParseDocTypeDecl extern __typeof (xmlParseDocTypeDecl) xmlParseDocTypeDecl __attribute((alias("xmlParseDocTypeDecl__internal_alias"))); #else #ifndef xmlParseDocTypeDecl extern __typeof (xmlParseDocTypeDecl) xmlParseDocTypeDecl__internal_alias __attribute((visibility("hidden"))); #define xmlParseDocTypeDecl xmlParseDocTypeDecl__internal_alias #endif #endif #ifdef bottom_parser #undef xmlParseDocument extern __typeof (xmlParseDocument) xmlParseDocument __attribute((alias("xmlParseDocument__internal_alias"))); #else #ifndef xmlParseDocument extern __typeof (xmlParseDocument) xmlParseDocument__internal_alias __attribute((visibility("hidden"))); #define xmlParseDocument xmlParseDocument__internal_alias #endif #endif #ifdef bottom_parser #undef xmlParseElement extern __typeof (xmlParseElement) xmlParseElement __attribute((alias("xmlParseElement__internal_alias"))); #else #ifndef xmlParseElement extern __typeof (xmlParseElement) xmlParseElement__internal_alias __attribute((visibility("hidden"))); #define xmlParseElement xmlParseElement__internal_alias #endif #endif #ifdef bottom_parser #undef xmlParseElementChildrenContentDecl extern __typeof (xmlParseElementChildrenContentDecl) xmlParseElementChildrenContentDecl __attribute((alias("xmlParseElementChildrenContentDecl__internal_alias"))); #else #ifndef xmlParseElementChildrenContentDecl extern __typeof (xmlParseElementChildrenContentDecl) xmlParseElementChildrenContentDecl__internal_alias __attribute((visibility("hidden"))); #define xmlParseElementChildrenContentDecl xmlParseElementChildrenContentDecl__internal_alias #endif #endif #ifdef bottom_parser #undef xmlParseElementContentDecl extern __typeof (xmlParseElementContentDecl) xmlParseElementContentDecl __attribute((alias("xmlParseElementContentDecl__internal_alias"))); #else #ifndef xmlParseElementContentDecl extern __typeof (xmlParseElementContentDecl) xmlParseElementContentDecl__internal_alias __attribute((visibility("hidden"))); #define xmlParseElementContentDecl xmlParseElementContentDecl__internal_alias #endif #endif #ifdef bottom_parser #undef xmlParseElementDecl extern __typeof (xmlParseElementDecl) xmlParseElementDecl __attribute((alias("xmlParseElementDecl__internal_alias"))); #else #ifndef xmlParseElementDecl extern __typeof (xmlParseElementDecl) xmlParseElementDecl__internal_alias __attribute((visibility("hidden"))); #define xmlParseElementDecl xmlParseElementDecl__internal_alias #endif #endif #ifdef bottom_parser #undef xmlParseElementMixedContentDecl extern __typeof (xmlParseElementMixedContentDecl) xmlParseElementMixedContentDecl __attribute((alias("xmlParseElementMixedContentDecl__internal_alias"))); #else #ifndef xmlParseElementMixedContentDecl extern __typeof (xmlParseElementMixedContentDecl) xmlParseElementMixedContentDecl__internal_alias __attribute((visibility("hidden"))); #define xmlParseElementMixedContentDecl xmlParseElementMixedContentDecl__internal_alias #endif #endif #ifdef bottom_parser #undef xmlParseEncName extern __typeof (xmlParseEncName) xmlParseEncName __attribute((alias("xmlParseEncName__internal_alias"))); #else #ifndef xmlParseEncName extern __typeof (xmlParseEncName) xmlParseEncName__internal_alias __attribute((visibility("hidden"))); #define xmlParseEncName xmlParseEncName__internal_alias #endif #endif #ifdef bottom_parser #undef xmlParseEncodingDecl extern __typeof (xmlParseEncodingDecl) xmlParseEncodingDecl __attribute((alias("xmlParseEncodingDecl__internal_alias"))); #else #ifndef xmlParseEncodingDecl extern __typeof (xmlParseEncodingDecl) xmlParseEncodingDecl__internal_alias __attribute((visibility("hidden"))); #define xmlParseEncodingDecl xmlParseEncodingDecl__internal_alias #endif #endif #if defined(LIBXML_SAX1_ENABLED) #ifdef bottom_parser #undef xmlParseEndTag extern __typeof (xmlParseEndTag) xmlParseEndTag __attribute((alias("xmlParseEndTag__internal_alias"))); #else #ifndef xmlParseEndTag extern __typeof (xmlParseEndTag) xmlParseEndTag__internal_alias __attribute((visibility("hidden"))); #define xmlParseEndTag xmlParseEndTag__internal_alias #endif #endif #endif #if defined(LIBXML_SAX1_ENABLED) #ifdef bottom_parser #undef xmlParseEntity extern __typeof (xmlParseEntity) xmlParseEntity __attribute((alias("xmlParseEntity__internal_alias"))); #else #ifndef xmlParseEntity extern __typeof (xmlParseEntity) xmlParseEntity__internal_alias __attribute((visibility("hidden"))); #define xmlParseEntity xmlParseEntity__internal_alias #endif #endif #endif #ifdef bottom_parser #undef xmlParseEntityDecl extern __typeof (xmlParseEntityDecl) xmlParseEntityDecl __attribute((alias("xmlParseEntityDecl__internal_alias"))); #else #ifndef xmlParseEntityDecl extern __typeof (xmlParseEntityDecl) xmlParseEntityDecl__internal_alias __attribute((visibility("hidden"))); #define xmlParseEntityDecl xmlParseEntityDecl__internal_alias #endif #endif #ifdef bottom_parser #undef xmlParseEntityRef extern __typeof (xmlParseEntityRef) xmlParseEntityRef __attribute((alias("xmlParseEntityRef__internal_alias"))); #else #ifndef xmlParseEntityRef extern __typeof (xmlParseEntityRef) xmlParseEntityRef__internal_alias __attribute((visibility("hidden"))); #define xmlParseEntityRef xmlParseEntityRef__internal_alias #endif #endif #ifdef bottom_parser #undef xmlParseEntityValue extern __typeof (xmlParseEntityValue) xmlParseEntityValue __attribute((alias("xmlParseEntityValue__internal_alias"))); #else #ifndef xmlParseEntityValue extern __typeof (xmlParseEntityValue) xmlParseEntityValue__internal_alias __attribute((visibility("hidden"))); #define xmlParseEntityValue xmlParseEntityValue__internal_alias #endif #endif #ifdef bottom_parser #undef xmlParseEnumeratedType extern __typeof (xmlParseEnumeratedType) xmlParseEnumeratedType __attribute((alias("xmlParseEnumeratedType__internal_alias"))); #else #ifndef xmlParseEnumeratedType extern __typeof (xmlParseEnumeratedType) xmlParseEnumeratedType__internal_alias __attribute((visibility("hidden"))); #define xmlParseEnumeratedType xmlParseEnumeratedType__internal_alias #endif #endif #ifdef bottom_parser #undef xmlParseEnumerationType extern __typeof (xmlParseEnumerationType) xmlParseEnumerationType __attribute((alias("xmlParseEnumerationType__internal_alias"))); #else #ifndef xmlParseEnumerationType extern __typeof (xmlParseEnumerationType) xmlParseEnumerationType__internal_alias __attribute((visibility("hidden"))); #define xmlParseEnumerationType xmlParseEnumerationType__internal_alias #endif #endif #ifdef bottom_parser #undef xmlParseExtParsedEnt extern __typeof (xmlParseExtParsedEnt) xmlParseExtParsedEnt __attribute((alias("xmlParseExtParsedEnt__internal_alias"))); #else #ifndef xmlParseExtParsedEnt extern __typeof (xmlParseExtParsedEnt) xmlParseExtParsedEnt__internal_alias __attribute((visibility("hidden"))); #define xmlParseExtParsedEnt xmlParseExtParsedEnt__internal_alias #endif #endif #if defined(LIBXML_SAX1_ENABLED) #ifdef bottom_parser #undef xmlParseExternalEntity extern __typeof (xmlParseExternalEntity) xmlParseExternalEntity __attribute((alias("xmlParseExternalEntity__internal_alias"))); #else #ifndef xmlParseExternalEntity extern __typeof (xmlParseExternalEntity) xmlParseExternalEntity__internal_alias __attribute((visibility("hidden"))); #define xmlParseExternalEntity xmlParseExternalEntity__internal_alias #endif #endif #endif #ifdef bottom_parser #undef xmlParseExternalID extern __typeof (xmlParseExternalID) xmlParseExternalID __attribute((alias("xmlParseExternalID__internal_alias"))); #else #ifndef xmlParseExternalID extern __typeof (xmlParseExternalID) xmlParseExternalID__internal_alias __attribute((visibility("hidden"))); #define xmlParseExternalID xmlParseExternalID__internal_alias #endif #endif #ifdef bottom_parser #undef xmlParseExternalSubset extern __typeof (xmlParseExternalSubset) xmlParseExternalSubset __attribute((alias("xmlParseExternalSubset__internal_alias"))); #else #ifndef xmlParseExternalSubset extern __typeof (xmlParseExternalSubset) xmlParseExternalSubset__internal_alias __attribute((visibility("hidden"))); #define xmlParseExternalSubset xmlParseExternalSubset__internal_alias #endif #endif #if defined(LIBXML_SAX1_ENABLED) #ifdef bottom_parser #undef xmlParseFile extern __typeof (xmlParseFile) xmlParseFile __attribute((alias("xmlParseFile__internal_alias"))); #else #ifndef xmlParseFile extern __typeof (xmlParseFile) xmlParseFile__internal_alias __attribute((visibility("hidden"))); #define xmlParseFile xmlParseFile__internal_alias #endif #endif #endif #ifdef bottom_parser #undef xmlParseInNodeContext extern __typeof (xmlParseInNodeContext) xmlParseInNodeContext __attribute((alias("xmlParseInNodeContext__internal_alias"))); #else #ifndef xmlParseInNodeContext extern __typeof (xmlParseInNodeContext) xmlParseInNodeContext__internal_alias __attribute((visibility("hidden"))); #define xmlParseInNodeContext xmlParseInNodeContext__internal_alias #endif #endif #ifdef bottom_parser #undef xmlParseMarkupDecl extern __typeof (xmlParseMarkupDecl) xmlParseMarkupDecl __attribute((alias("xmlParseMarkupDecl__internal_alias"))); #else #ifndef xmlParseMarkupDecl extern __typeof (xmlParseMarkupDecl) xmlParseMarkupDecl__internal_alias __attribute((visibility("hidden"))); #define xmlParseMarkupDecl xmlParseMarkupDecl__internal_alias #endif #endif #if defined(LIBXML_SAX1_ENABLED) #ifdef bottom_parser #undef xmlParseMemory extern __typeof (xmlParseMemory) xmlParseMemory __attribute((alias("xmlParseMemory__internal_alias"))); #else #ifndef xmlParseMemory extern __typeof (xmlParseMemory) xmlParseMemory__internal_alias __attribute((visibility("hidden"))); #define xmlParseMemory xmlParseMemory__internal_alias #endif #endif #endif #ifdef bottom_parser #undef xmlParseMisc extern __typeof (xmlParseMisc) xmlParseMisc __attribute((alias("xmlParseMisc__internal_alias"))); #else #ifndef xmlParseMisc extern __typeof (xmlParseMisc) xmlParseMisc__internal_alias __attribute((visibility("hidden"))); #define xmlParseMisc xmlParseMisc__internal_alias #endif #endif #ifdef bottom_parser #undef xmlParseName extern __typeof (xmlParseName) xmlParseName __attribute((alias("xmlParseName__internal_alias"))); #else #ifndef xmlParseName extern __typeof (xmlParseName) xmlParseName__internal_alias __attribute((visibility("hidden"))); #define xmlParseName xmlParseName__internal_alias #endif #endif #if defined(LIBXML_LEGACY_ENABLED) #ifdef bottom_legacy #undef xmlParseNamespace extern __typeof (xmlParseNamespace) xmlParseNamespace __attribute((alias("xmlParseNamespace__internal_alias"))); #else #ifndef xmlParseNamespace extern __typeof (xmlParseNamespace) xmlParseNamespace__internal_alias __attribute((visibility("hidden"))); #define xmlParseNamespace xmlParseNamespace__internal_alias #endif #endif #endif #ifdef bottom_parser #undef xmlParseNmtoken extern __typeof (xmlParseNmtoken) xmlParseNmtoken __attribute((alias("xmlParseNmtoken__internal_alias"))); #else #ifndef xmlParseNmtoken extern __typeof (xmlParseNmtoken) xmlParseNmtoken__internal_alias __attribute((visibility("hidden"))); #define xmlParseNmtoken xmlParseNmtoken__internal_alias #endif #endif #ifdef bottom_parser #undef xmlParseNotationDecl extern __typeof (xmlParseNotationDecl) xmlParseNotationDecl __attribute((alias("xmlParseNotationDecl__internal_alias"))); #else #ifndef xmlParseNotationDecl extern __typeof (xmlParseNotationDecl) xmlParseNotationDecl__internal_alias __attribute((visibility("hidden"))); #define xmlParseNotationDecl xmlParseNotationDecl__internal_alias #endif #endif #ifdef bottom_parser #undef xmlParseNotationType extern __typeof (xmlParseNotationType) xmlParseNotationType __attribute((alias("xmlParseNotationType__internal_alias"))); #else #ifndef xmlParseNotationType extern __typeof (xmlParseNotationType) xmlParseNotationType__internal_alias __attribute((visibility("hidden"))); #define xmlParseNotationType xmlParseNotationType__internal_alias #endif #endif #ifdef bottom_parser #undef xmlParsePEReference extern __typeof (xmlParsePEReference) xmlParsePEReference __attribute((alias("xmlParsePEReference__internal_alias"))); #else #ifndef xmlParsePEReference extern __typeof (xmlParsePEReference) xmlParsePEReference__internal_alias __attribute((visibility("hidden"))); #define xmlParsePEReference xmlParsePEReference__internal_alias #endif #endif #ifdef bottom_parser #undef xmlParsePI extern __typeof (xmlParsePI) xmlParsePI __attribute((alias("xmlParsePI__internal_alias"))); #else #ifndef xmlParsePI extern __typeof (xmlParsePI) xmlParsePI__internal_alias __attribute((visibility("hidden"))); #define xmlParsePI xmlParsePI__internal_alias #endif #endif #ifdef bottom_parser #undef xmlParsePITarget extern __typeof (xmlParsePITarget) xmlParsePITarget __attribute((alias("xmlParsePITarget__internal_alias"))); #else #ifndef xmlParsePITarget extern __typeof (xmlParsePITarget) xmlParsePITarget__internal_alias __attribute((visibility("hidden"))); #define xmlParsePITarget xmlParsePITarget__internal_alias #endif #endif #ifdef bottom_parser #undef xmlParsePubidLiteral extern __typeof (xmlParsePubidLiteral) xmlParsePubidLiteral __attribute((alias("xmlParsePubidLiteral__internal_alias"))); #else #ifndef xmlParsePubidLiteral extern __typeof (xmlParsePubidLiteral) xmlParsePubidLiteral__internal_alias __attribute((visibility("hidden"))); #define xmlParsePubidLiteral xmlParsePubidLiteral__internal_alias #endif #endif #if defined(LIBXML_LEGACY_ENABLED) #ifdef bottom_legacy #undef xmlParseQuotedString extern __typeof (xmlParseQuotedString) xmlParseQuotedString __attribute((alias("xmlParseQuotedString__internal_alias"))); #else #ifndef xmlParseQuotedString extern __typeof (xmlParseQuotedString) xmlParseQuotedString__internal_alias __attribute((visibility("hidden"))); #define xmlParseQuotedString xmlParseQuotedString__internal_alias #endif #endif #endif #ifdef bottom_parser #undef xmlParseReference extern __typeof (xmlParseReference) xmlParseReference __attribute((alias("xmlParseReference__internal_alias"))); #else #ifndef xmlParseReference extern __typeof (xmlParseReference) xmlParseReference__internal_alias __attribute((visibility("hidden"))); #define xmlParseReference xmlParseReference__internal_alias #endif #endif #ifdef bottom_parser #undef xmlParseSDDecl extern __typeof (xmlParseSDDecl) xmlParseSDDecl __attribute((alias("xmlParseSDDecl__internal_alias"))); #else #ifndef xmlParseSDDecl extern __typeof (xmlParseSDDecl) xmlParseSDDecl__internal_alias __attribute((visibility("hidden"))); #define xmlParseSDDecl xmlParseSDDecl__internal_alias #endif #endif #if defined(LIBXML_SAX1_ENABLED) #ifdef bottom_parser #undef xmlParseStartTag extern __typeof (xmlParseStartTag) xmlParseStartTag __attribute((alias("xmlParseStartTag__internal_alias"))); #else #ifndef xmlParseStartTag extern __typeof (xmlParseStartTag) xmlParseStartTag__internal_alias __attribute((visibility("hidden"))); #define xmlParseStartTag xmlParseStartTag__internal_alias #endif #endif #endif #ifdef bottom_parser #undef xmlParseSystemLiteral extern __typeof (xmlParseSystemLiteral) xmlParseSystemLiteral __attribute((alias("xmlParseSystemLiteral__internal_alias"))); #else #ifndef xmlParseSystemLiteral extern __typeof (xmlParseSystemLiteral) xmlParseSystemLiteral__internal_alias __attribute((visibility("hidden"))); #define xmlParseSystemLiteral xmlParseSystemLiteral__internal_alias #endif #endif #ifdef bottom_parser #undef xmlParseTextDecl extern __typeof (xmlParseTextDecl) xmlParseTextDecl __attribute((alias("xmlParseTextDecl__internal_alias"))); #else #ifndef xmlParseTextDecl extern __typeof (xmlParseTextDecl) xmlParseTextDecl__internal_alias __attribute((visibility("hidden"))); #define xmlParseTextDecl xmlParseTextDecl__internal_alias #endif #endif #ifdef bottom_uri #undef xmlParseURI extern __typeof (xmlParseURI) xmlParseURI __attribute((alias("xmlParseURI__internal_alias"))); #else #ifndef xmlParseURI extern __typeof (xmlParseURI) xmlParseURI__internal_alias __attribute((visibility("hidden"))); #define xmlParseURI xmlParseURI__internal_alias #endif #endif #ifdef bottom_uri #undef xmlParseURIRaw extern __typeof (xmlParseURIRaw) xmlParseURIRaw __attribute((alias("xmlParseURIRaw__internal_alias"))); #else #ifndef xmlParseURIRaw extern __typeof (xmlParseURIRaw) xmlParseURIRaw__internal_alias __attribute((visibility("hidden"))); #define xmlParseURIRaw xmlParseURIRaw__internal_alias #endif #endif #ifdef bottom_uri #undef xmlParseURIReference extern __typeof (xmlParseURIReference) xmlParseURIReference __attribute((alias("xmlParseURIReference__internal_alias"))); #else #ifndef xmlParseURIReference extern __typeof (xmlParseURIReference) xmlParseURIReference__internal_alias __attribute((visibility("hidden"))); #define xmlParseURIReference xmlParseURIReference__internal_alias #endif #endif #ifdef bottom_parser #undef xmlParseVersionInfo extern __typeof (xmlParseVersionInfo) xmlParseVersionInfo __attribute((alias("xmlParseVersionInfo__internal_alias"))); #else #ifndef xmlParseVersionInfo extern __typeof (xmlParseVersionInfo) xmlParseVersionInfo__internal_alias __attribute((visibility("hidden"))); #define xmlParseVersionInfo xmlParseVersionInfo__internal_alias #endif #endif #ifdef bottom_parser #undef xmlParseVersionNum extern __typeof (xmlParseVersionNum) xmlParseVersionNum __attribute((alias("xmlParseVersionNum__internal_alias"))); #else #ifndef xmlParseVersionNum extern __typeof (xmlParseVersionNum) xmlParseVersionNum__internal_alias __attribute((visibility("hidden"))); #define xmlParseVersionNum xmlParseVersionNum__internal_alias #endif #endif #ifdef bottom_parser #undef xmlParseXMLDecl extern __typeof (xmlParseXMLDecl) xmlParseXMLDecl __attribute((alias("xmlParseXMLDecl__internal_alias"))); #else #ifndef xmlParseXMLDecl extern __typeof (xmlParseXMLDecl) xmlParseXMLDecl__internal_alias __attribute((visibility("hidden"))); #define xmlParseXMLDecl xmlParseXMLDecl__internal_alias #endif #endif #ifdef bottom_parserInternals #undef xmlParserAddNodeInfo extern __typeof (xmlParserAddNodeInfo) xmlParserAddNodeInfo __attribute((alias("xmlParserAddNodeInfo__internal_alias"))); #else #ifndef xmlParserAddNodeInfo extern __typeof (xmlParserAddNodeInfo) xmlParserAddNodeInfo__internal_alias __attribute((visibility("hidden"))); #define xmlParserAddNodeInfo xmlParserAddNodeInfo__internal_alias #endif #endif #ifdef bottom_error #undef xmlParserError extern __typeof (xmlParserError) xmlParserError __attribute((alias("xmlParserError__internal_alias"))); #else #ifndef xmlParserError extern __typeof (xmlParserError) xmlParserError__internal_alias __attribute((visibility("hidden"))); #define xmlParserError xmlParserError__internal_alias #endif #endif #ifdef bottom_parserInternals #undef xmlParserFindNodeInfo extern __typeof (xmlParserFindNodeInfo) xmlParserFindNodeInfo __attribute((alias("xmlParserFindNodeInfo__internal_alias"))); #else #ifndef xmlParserFindNodeInfo extern __typeof (xmlParserFindNodeInfo) xmlParserFindNodeInfo__internal_alias __attribute((visibility("hidden"))); #define xmlParserFindNodeInfo xmlParserFindNodeInfo__internal_alias #endif #endif #ifdef bottom_parserInternals #undef xmlParserFindNodeInfoIndex extern __typeof (xmlParserFindNodeInfoIndex) xmlParserFindNodeInfoIndex __attribute((alias("xmlParserFindNodeInfoIndex__internal_alias"))); #else #ifndef xmlParserFindNodeInfoIndex extern __typeof (xmlParserFindNodeInfoIndex) xmlParserFindNodeInfoIndex__internal_alias __attribute((visibility("hidden"))); #define xmlParserFindNodeInfoIndex xmlParserFindNodeInfoIndex__internal_alias #endif #endif #ifdef bottom_xmlIO #undef xmlParserGetDirectory extern __typeof (xmlParserGetDirectory) xmlParserGetDirectory __attribute((alias("xmlParserGetDirectory__internal_alias"))); #else #ifndef xmlParserGetDirectory extern __typeof (xmlParserGetDirectory) xmlParserGetDirectory__internal_alias __attribute((visibility("hidden"))); #define xmlParserGetDirectory xmlParserGetDirectory__internal_alias #endif #endif #ifdef bottom_parser #undef xmlParserHandlePEReference extern __typeof (xmlParserHandlePEReference) xmlParserHandlePEReference __attribute((alias("xmlParserHandlePEReference__internal_alias"))); #else #ifndef xmlParserHandlePEReference extern __typeof (xmlParserHandlePEReference) xmlParserHandlePEReference__internal_alias __attribute((visibility("hidden"))); #define xmlParserHandlePEReference xmlParserHandlePEReference__internal_alias #endif #endif #if defined(LIBXML_LEGACY_ENABLED) #ifdef bottom_legacy #undef xmlParserHandleReference extern __typeof (xmlParserHandleReference) xmlParserHandleReference __attribute((alias("xmlParserHandleReference__internal_alias"))); #else #ifndef xmlParserHandleReference extern __typeof (xmlParserHandleReference) xmlParserHandleReference__internal_alias __attribute((visibility("hidden"))); #define xmlParserHandleReference xmlParserHandleReference__internal_alias #endif #endif #endif #ifdef bottom_xmlIO #undef xmlParserInputBufferCreateFd extern __typeof (xmlParserInputBufferCreateFd) xmlParserInputBufferCreateFd __attribute((alias("xmlParserInputBufferCreateFd__internal_alias"))); #else #ifndef xmlParserInputBufferCreateFd extern __typeof (xmlParserInputBufferCreateFd) xmlParserInputBufferCreateFd__internal_alias __attribute((visibility("hidden"))); #define xmlParserInputBufferCreateFd xmlParserInputBufferCreateFd__internal_alias #endif #endif #ifdef bottom_xmlIO #undef xmlParserInputBufferCreateFile extern __typeof (xmlParserInputBufferCreateFile) xmlParserInputBufferCreateFile __attribute((alias("xmlParserInputBufferCreateFile__internal_alias"))); #else #ifndef xmlParserInputBufferCreateFile extern __typeof (xmlParserInputBufferCreateFile) xmlParserInputBufferCreateFile__internal_alias __attribute((visibility("hidden"))); #define xmlParserInputBufferCreateFile xmlParserInputBufferCreateFile__internal_alias #endif #endif #ifdef bottom_xmlIO #undef xmlParserInputBufferCreateFilename extern __typeof (xmlParserInputBufferCreateFilename) xmlParserInputBufferCreateFilename __attribute((alias("xmlParserInputBufferCreateFilename__internal_alias"))); #else #ifndef xmlParserInputBufferCreateFilename extern __typeof (xmlParserInputBufferCreateFilename) xmlParserInputBufferCreateFilename__internal_alias __attribute((visibility("hidden"))); #define xmlParserInputBufferCreateFilename xmlParserInputBufferCreateFilename__internal_alias #endif #endif #ifdef bottom_xmlIO #undef xmlParserInputBufferCreateFilenameDefault extern __typeof (xmlParserInputBufferCreateFilenameDefault) xmlParserInputBufferCreateFilenameDefault __attribute((alias("xmlParserInputBufferCreateFilenameDefault__internal_alias"))); #else #ifndef xmlParserInputBufferCreateFilenameDefault extern __typeof (xmlParserInputBufferCreateFilenameDefault) xmlParserInputBufferCreateFilenameDefault__internal_alias __attribute((visibility("hidden"))); #define xmlParserInputBufferCreateFilenameDefault xmlParserInputBufferCreateFilenameDefault__internal_alias #endif #endif #ifdef bottom_xmlIO #undef xmlParserInputBufferCreateIO extern __typeof (xmlParserInputBufferCreateIO) xmlParserInputBufferCreateIO __attribute((alias("xmlParserInputBufferCreateIO__internal_alias"))); #else #ifndef xmlParserInputBufferCreateIO extern __typeof (xmlParserInputBufferCreateIO) xmlParserInputBufferCreateIO__internal_alias __attribute((visibility("hidden"))); #define xmlParserInputBufferCreateIO xmlParserInputBufferCreateIO__internal_alias #endif #endif #ifdef bottom_xmlIO #undef xmlParserInputBufferCreateMem extern __typeof (xmlParserInputBufferCreateMem) xmlParserInputBufferCreateMem __attribute((alias("xmlParserInputBufferCreateMem__internal_alias"))); #else #ifndef xmlParserInputBufferCreateMem extern __typeof (xmlParserInputBufferCreateMem) xmlParserInputBufferCreateMem__internal_alias __attribute((visibility("hidden"))); #define xmlParserInputBufferCreateMem xmlParserInputBufferCreateMem__internal_alias #endif #endif #ifdef bottom_xmlIO #undef xmlParserInputBufferCreateStatic extern __typeof (xmlParserInputBufferCreateStatic) xmlParserInputBufferCreateStatic __attribute((alias("xmlParserInputBufferCreateStatic__internal_alias"))); #else #ifndef xmlParserInputBufferCreateStatic extern __typeof (xmlParserInputBufferCreateStatic) xmlParserInputBufferCreateStatic__internal_alias __attribute((visibility("hidden"))); #define xmlParserInputBufferCreateStatic xmlParserInputBufferCreateStatic__internal_alias #endif #endif #ifdef bottom_xmlIO #undef xmlParserInputBufferGrow extern __typeof (xmlParserInputBufferGrow) xmlParserInputBufferGrow __attribute((alias("xmlParserInputBufferGrow__internal_alias"))); #else #ifndef xmlParserInputBufferGrow extern __typeof (xmlParserInputBufferGrow) xmlParserInputBufferGrow__internal_alias __attribute((visibility("hidden"))); #define xmlParserInputBufferGrow xmlParserInputBufferGrow__internal_alias #endif #endif #ifdef bottom_xmlIO #undef xmlParserInputBufferPush extern __typeof (xmlParserInputBufferPush) xmlParserInputBufferPush __attribute((alias("xmlParserInputBufferPush__internal_alias"))); #else #ifndef xmlParserInputBufferPush extern __typeof (xmlParserInputBufferPush) xmlParserInputBufferPush__internal_alias __attribute((visibility("hidden"))); #define xmlParserInputBufferPush xmlParserInputBufferPush__internal_alias #endif #endif #ifdef bottom_xmlIO #undef xmlParserInputBufferRead extern __typeof (xmlParserInputBufferRead) xmlParserInputBufferRead __attribute((alias("xmlParserInputBufferRead__internal_alias"))); #else #ifndef xmlParserInputBufferRead extern __typeof (xmlParserInputBufferRead) xmlParserInputBufferRead__internal_alias __attribute((visibility("hidden"))); #define xmlParserInputBufferRead xmlParserInputBufferRead__internal_alias #endif #endif #ifdef bottom_parserInternals #undef xmlParserInputGrow extern __typeof (xmlParserInputGrow) xmlParserInputGrow __attribute((alias("xmlParserInputGrow__internal_alias"))); #else #ifndef xmlParserInputGrow extern __typeof (xmlParserInputGrow) xmlParserInputGrow__internal_alias __attribute((visibility("hidden"))); #define xmlParserInputGrow xmlParserInputGrow__internal_alias #endif #endif #ifdef bottom_parserInternals #undef xmlParserInputRead extern __typeof (xmlParserInputRead) xmlParserInputRead __attribute((alias("xmlParserInputRead__internal_alias"))); #else #ifndef xmlParserInputRead extern __typeof (xmlParserInputRead) xmlParserInputRead__internal_alias __attribute((visibility("hidden"))); #define xmlParserInputRead xmlParserInputRead__internal_alias #endif #endif #ifdef bottom_parserInternals #undef xmlParserInputShrink extern __typeof (xmlParserInputShrink) xmlParserInputShrink __attribute((alias("xmlParserInputShrink__internal_alias"))); #else #ifndef xmlParserInputShrink extern __typeof (xmlParserInputShrink) xmlParserInputShrink__internal_alias __attribute((visibility("hidden"))); #define xmlParserInputShrink xmlParserInputShrink__internal_alias #endif #endif #ifdef bottom_error #undef xmlParserPrintFileContext extern __typeof (xmlParserPrintFileContext) xmlParserPrintFileContext __attribute((alias("xmlParserPrintFileContext__internal_alias"))); #else #ifndef xmlParserPrintFileContext extern __typeof (xmlParserPrintFileContext) xmlParserPrintFileContext__internal_alias __attribute((visibility("hidden"))); #define xmlParserPrintFileContext xmlParserPrintFileContext__internal_alias #endif #endif #ifdef bottom_error #undef xmlParserPrintFileInfo extern __typeof (xmlParserPrintFileInfo) xmlParserPrintFileInfo __attribute((alias("xmlParserPrintFileInfo__internal_alias"))); #else #ifndef xmlParserPrintFileInfo extern __typeof (xmlParserPrintFileInfo) xmlParserPrintFileInfo__internal_alias __attribute((visibility("hidden"))); #define xmlParserPrintFileInfo xmlParserPrintFileInfo__internal_alias #endif #endif #ifdef bottom_error #undef xmlParserValidityError extern __typeof (xmlParserValidityError) xmlParserValidityError __attribute((alias("xmlParserValidityError__internal_alias"))); #else #ifndef xmlParserValidityError extern __typeof (xmlParserValidityError) xmlParserValidityError__internal_alias __attribute((visibility("hidden"))); #define xmlParserValidityError xmlParserValidityError__internal_alias #endif #endif #ifdef bottom_error #undef xmlParserValidityWarning extern __typeof (xmlParserValidityWarning) xmlParserValidityWarning __attribute((alias("xmlParserValidityWarning__internal_alias"))); #else #ifndef xmlParserValidityWarning extern __typeof (xmlParserValidityWarning) xmlParserValidityWarning__internal_alias __attribute((visibility("hidden"))); #define xmlParserValidityWarning xmlParserValidityWarning__internal_alias #endif #endif #ifdef bottom_error #undef xmlParserWarning extern __typeof (xmlParserWarning) xmlParserWarning __attribute((alias("xmlParserWarning__internal_alias"))); #else #ifndef xmlParserWarning extern __typeof (xmlParserWarning) xmlParserWarning__internal_alias __attribute((visibility("hidden"))); #define xmlParserWarning xmlParserWarning__internal_alias #endif #endif #if defined(LIBXML_PATTERN_ENABLED) #ifdef bottom_pattern #undef xmlPatternFromRoot extern __typeof (xmlPatternFromRoot) xmlPatternFromRoot __attribute((alias("xmlPatternFromRoot__internal_alias"))); #else #ifndef xmlPatternFromRoot extern __typeof (xmlPatternFromRoot) xmlPatternFromRoot__internal_alias __attribute((visibility("hidden"))); #define xmlPatternFromRoot xmlPatternFromRoot__internal_alias #endif #endif #endif #if defined(LIBXML_PATTERN_ENABLED) #ifdef bottom_pattern #undef xmlPatternGetStreamCtxt extern __typeof (xmlPatternGetStreamCtxt) xmlPatternGetStreamCtxt __attribute((alias("xmlPatternGetStreamCtxt__internal_alias"))); #else #ifndef xmlPatternGetStreamCtxt extern __typeof (xmlPatternGetStreamCtxt) xmlPatternGetStreamCtxt__internal_alias __attribute((visibility("hidden"))); #define xmlPatternGetStreamCtxt xmlPatternGetStreamCtxt__internal_alias #endif #endif #endif #if defined(LIBXML_PATTERN_ENABLED) #ifdef bottom_pattern #undef xmlPatternMatch extern __typeof (xmlPatternMatch) xmlPatternMatch __attribute((alias("xmlPatternMatch__internal_alias"))); #else #ifndef xmlPatternMatch extern __typeof (xmlPatternMatch) xmlPatternMatch__internal_alias __attribute((visibility("hidden"))); #define xmlPatternMatch xmlPatternMatch__internal_alias #endif #endif #endif #if defined(LIBXML_PATTERN_ENABLED) #ifdef bottom_pattern #undef xmlPatternMaxDepth extern __typeof (xmlPatternMaxDepth) xmlPatternMaxDepth __attribute((alias("xmlPatternMaxDepth__internal_alias"))); #else #ifndef xmlPatternMaxDepth extern __typeof (xmlPatternMaxDepth) xmlPatternMaxDepth__internal_alias __attribute((visibility("hidden"))); #define xmlPatternMaxDepth xmlPatternMaxDepth__internal_alias #endif #endif #endif #if defined(LIBXML_PATTERN_ENABLED) #ifdef bottom_pattern #undef xmlPatternMinDepth extern __typeof (xmlPatternMinDepth) xmlPatternMinDepth __attribute((alias("xmlPatternMinDepth__internal_alias"))); #else #ifndef xmlPatternMinDepth extern __typeof (xmlPatternMinDepth) xmlPatternMinDepth__internal_alias __attribute((visibility("hidden"))); #define xmlPatternMinDepth xmlPatternMinDepth__internal_alias #endif #endif #endif #if defined(LIBXML_PATTERN_ENABLED) #ifdef bottom_pattern #undef xmlPatternStreamable extern __typeof (xmlPatternStreamable) xmlPatternStreamable __attribute((alias("xmlPatternStreamable__internal_alias"))); #else #ifndef xmlPatternStreamable extern __typeof (xmlPatternStreamable) xmlPatternStreamable__internal_alias __attribute((visibility("hidden"))); #define xmlPatternStreamable xmlPatternStreamable__internal_alias #endif #endif #endif #if defined(LIBXML_PATTERN_ENABLED) #ifdef bottom_pattern #undef xmlPatterncompile extern __typeof (xmlPatterncompile) xmlPatterncompile __attribute((alias("xmlPatterncompile__internal_alias"))); #else #ifndef xmlPatterncompile extern __typeof (xmlPatterncompile) xmlPatterncompile__internal_alias __attribute((visibility("hidden"))); #define xmlPatterncompile xmlPatterncompile__internal_alias #endif #endif #endif #ifdef bottom_parserInternals #undef xmlPedanticParserDefault extern __typeof (xmlPedanticParserDefault) xmlPedanticParserDefault __attribute((alias("xmlPedanticParserDefault__internal_alias"))); #else #ifndef xmlPedanticParserDefault extern __typeof (xmlPedanticParserDefault) xmlPedanticParserDefault__internal_alias __attribute((visibility("hidden"))); #define xmlPedanticParserDefault xmlPedanticParserDefault__internal_alias #endif #endif #ifdef bottom_parser #undef xmlPopInput extern __typeof (xmlPopInput) xmlPopInput __attribute((alias("xmlPopInput__internal_alias"))); #else #ifndef xmlPopInput extern __typeof (xmlPopInput) xmlPopInput__internal_alias __attribute((visibility("hidden"))); #define xmlPopInput xmlPopInput__internal_alias #endif #endif #ifdef bottom_xmlIO #undef xmlPopInputCallbacks extern __typeof (xmlPopInputCallbacks) xmlPopInputCallbacks __attribute((alias("xmlPopInputCallbacks__internal_alias"))); #else #ifndef xmlPopInputCallbacks extern __typeof (xmlPopInputCallbacks) xmlPopInputCallbacks__internal_alias __attribute((visibility("hidden"))); #define xmlPopInputCallbacks xmlPopInputCallbacks__internal_alias #endif #endif #ifdef bottom_uri #undef xmlPrintURI extern __typeof (xmlPrintURI) xmlPrintURI __attribute((alias("xmlPrintURI__internal_alias"))); #else #ifndef xmlPrintURI extern __typeof (xmlPrintURI) xmlPrintURI__internal_alias __attribute((visibility("hidden"))); #define xmlPrintURI xmlPrintURI__internal_alias #endif #endif #ifdef bottom_parser #undef xmlPushInput extern __typeof (xmlPushInput) xmlPushInput __attribute((alias("xmlPushInput__internal_alias"))); #else #ifndef xmlPushInput extern __typeof (xmlPushInput) xmlPushInput__internal_alias __attribute((visibility("hidden"))); #define xmlPushInput xmlPushInput__internal_alias #endif #endif #ifdef bottom_threads #undef xmlRMutexLock extern __typeof (xmlRMutexLock) xmlRMutexLock __attribute((alias("xmlRMutexLock__internal_alias"))); #else #ifndef xmlRMutexLock extern __typeof (xmlRMutexLock) xmlRMutexLock__internal_alias __attribute((visibility("hidden"))); #define xmlRMutexLock xmlRMutexLock__internal_alias #endif #endif #ifdef bottom_threads #undef xmlRMutexUnlock extern __typeof (xmlRMutexUnlock) xmlRMutexUnlock __attribute((alias("xmlRMutexUnlock__internal_alias"))); #else #ifndef xmlRMutexUnlock extern __typeof (xmlRMutexUnlock) xmlRMutexUnlock__internal_alias __attribute((visibility("hidden"))); #define xmlRMutexUnlock xmlRMutexUnlock__internal_alias #endif #endif #ifdef bottom_parser #undef xmlReadDoc extern __typeof (xmlReadDoc) xmlReadDoc __attribute((alias("xmlReadDoc__internal_alias"))); #else #ifndef xmlReadDoc extern __typeof (xmlReadDoc) xmlReadDoc__internal_alias __attribute((visibility("hidden"))); #define xmlReadDoc xmlReadDoc__internal_alias #endif #endif #ifdef bottom_parser #undef xmlReadFd extern __typeof (xmlReadFd) xmlReadFd __attribute((alias("xmlReadFd__internal_alias"))); #else #ifndef xmlReadFd extern __typeof (xmlReadFd) xmlReadFd__internal_alias __attribute((visibility("hidden"))); #define xmlReadFd xmlReadFd__internal_alias #endif #endif #ifdef bottom_parser #undef xmlReadFile extern __typeof (xmlReadFile) xmlReadFile __attribute((alias("xmlReadFile__internal_alias"))); #else #ifndef xmlReadFile extern __typeof (xmlReadFile) xmlReadFile__internal_alias __attribute((visibility("hidden"))); #define xmlReadFile xmlReadFile__internal_alias #endif #endif #ifdef bottom_parser #undef xmlReadIO extern __typeof (xmlReadIO) xmlReadIO __attribute((alias("xmlReadIO__internal_alias"))); #else #ifndef xmlReadIO extern __typeof (xmlReadIO) xmlReadIO__internal_alias __attribute((visibility("hidden"))); #define xmlReadIO xmlReadIO__internal_alias #endif #endif #ifdef bottom_parser #undef xmlReadMemory extern __typeof (xmlReadMemory) xmlReadMemory __attribute((alias("xmlReadMemory__internal_alias"))); #else #ifndef xmlReadMemory extern __typeof (xmlReadMemory) xmlReadMemory__internal_alias __attribute((visibility("hidden"))); #define xmlReadMemory xmlReadMemory__internal_alias #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlReaderForDoc extern __typeof (xmlReaderForDoc) xmlReaderForDoc __attribute((alias("xmlReaderForDoc__internal_alias"))); #else #ifndef xmlReaderForDoc extern __typeof (xmlReaderForDoc) xmlReaderForDoc__internal_alias __attribute((visibility("hidden"))); #define xmlReaderForDoc xmlReaderForDoc__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlReaderForFd extern __typeof (xmlReaderForFd) xmlReaderForFd __attribute((alias("xmlReaderForFd__internal_alias"))); #else #ifndef xmlReaderForFd extern __typeof (xmlReaderForFd) xmlReaderForFd__internal_alias __attribute((visibility("hidden"))); #define xmlReaderForFd xmlReaderForFd__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlReaderForFile extern __typeof (xmlReaderForFile) xmlReaderForFile __attribute((alias("xmlReaderForFile__internal_alias"))); #else #ifndef xmlReaderForFile extern __typeof (xmlReaderForFile) xmlReaderForFile__internal_alias __attribute((visibility("hidden"))); #define xmlReaderForFile xmlReaderForFile__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlReaderForIO extern __typeof (xmlReaderForIO) xmlReaderForIO __attribute((alias("xmlReaderForIO__internal_alias"))); #else #ifndef xmlReaderForIO extern __typeof (xmlReaderForIO) xmlReaderForIO__internal_alias __attribute((visibility("hidden"))); #define xmlReaderForIO xmlReaderForIO__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlReaderForMemory extern __typeof (xmlReaderForMemory) xmlReaderForMemory __attribute((alias("xmlReaderForMemory__internal_alias"))); #else #ifndef xmlReaderForMemory extern __typeof (xmlReaderForMemory) xmlReaderForMemory__internal_alias __attribute((visibility("hidden"))); #define xmlReaderForMemory xmlReaderForMemory__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlReaderNewDoc extern __typeof (xmlReaderNewDoc) xmlReaderNewDoc __attribute((alias("xmlReaderNewDoc__internal_alias"))); #else #ifndef xmlReaderNewDoc extern __typeof (xmlReaderNewDoc) xmlReaderNewDoc__internal_alias __attribute((visibility("hidden"))); #define xmlReaderNewDoc xmlReaderNewDoc__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlReaderNewFd extern __typeof (xmlReaderNewFd) xmlReaderNewFd __attribute((alias("xmlReaderNewFd__internal_alias"))); #else #ifndef xmlReaderNewFd extern __typeof (xmlReaderNewFd) xmlReaderNewFd__internal_alias __attribute((visibility("hidden"))); #define xmlReaderNewFd xmlReaderNewFd__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlReaderNewFile extern __typeof (xmlReaderNewFile) xmlReaderNewFile __attribute((alias("xmlReaderNewFile__internal_alias"))); #else #ifndef xmlReaderNewFile extern __typeof (xmlReaderNewFile) xmlReaderNewFile__internal_alias __attribute((visibility("hidden"))); #define xmlReaderNewFile xmlReaderNewFile__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlReaderNewIO extern __typeof (xmlReaderNewIO) xmlReaderNewIO __attribute((alias("xmlReaderNewIO__internal_alias"))); #else #ifndef xmlReaderNewIO extern __typeof (xmlReaderNewIO) xmlReaderNewIO__internal_alias __attribute((visibility("hidden"))); #define xmlReaderNewIO xmlReaderNewIO__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlReaderNewMemory extern __typeof (xmlReaderNewMemory) xmlReaderNewMemory __attribute((alias("xmlReaderNewMemory__internal_alias"))); #else #ifndef xmlReaderNewMemory extern __typeof (xmlReaderNewMemory) xmlReaderNewMemory__internal_alias __attribute((visibility("hidden"))); #define xmlReaderNewMemory xmlReaderNewMemory__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlReaderNewWalker extern __typeof (xmlReaderNewWalker) xmlReaderNewWalker __attribute((alias("xmlReaderNewWalker__internal_alias"))); #else #ifndef xmlReaderNewWalker extern __typeof (xmlReaderNewWalker) xmlReaderNewWalker__internal_alias __attribute((visibility("hidden"))); #define xmlReaderNewWalker xmlReaderNewWalker__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlReaderWalker extern __typeof (xmlReaderWalker) xmlReaderWalker __attribute((alias("xmlReaderWalker__internal_alias"))); #else #ifndef xmlReaderWalker extern __typeof (xmlReaderWalker) xmlReaderWalker__internal_alias __attribute((visibility("hidden"))); #define xmlReaderWalker xmlReaderWalker__internal_alias #endif #endif #endif #ifdef bottom_xmlmemory #undef xmlReallocLoc extern __typeof (xmlReallocLoc) xmlReallocLoc __attribute((alias("xmlReallocLoc__internal_alias"))); #else #ifndef xmlReallocLoc extern __typeof (xmlReallocLoc) xmlReallocLoc__internal_alias __attribute((visibility("hidden"))); #define xmlReallocLoc xmlReallocLoc__internal_alias #endif #endif #if defined(LIBXML_TREE_ENABLED) #ifdef bottom_tree #undef xmlReconciliateNs extern __typeof (xmlReconciliateNs) xmlReconciliateNs __attribute((alias("xmlReconciliateNs__internal_alias"))); #else #ifndef xmlReconciliateNs extern __typeof (xmlReconciliateNs) xmlReconciliateNs__internal_alias __attribute((visibility("hidden"))); #define xmlReconciliateNs xmlReconciliateNs__internal_alias #endif #endif #endif #if defined(LIBXML_SAX1_ENABLED) #ifdef bottom_parser #undef xmlRecoverDoc extern __typeof (xmlRecoverDoc) xmlRecoverDoc __attribute((alias("xmlRecoverDoc__internal_alias"))); #else #ifndef xmlRecoverDoc extern __typeof (xmlRecoverDoc) xmlRecoverDoc__internal_alias __attribute((visibility("hidden"))); #define xmlRecoverDoc xmlRecoverDoc__internal_alias #endif #endif #endif #if defined(LIBXML_SAX1_ENABLED) #ifdef bottom_parser #undef xmlRecoverFile extern __typeof (xmlRecoverFile) xmlRecoverFile __attribute((alias("xmlRecoverFile__internal_alias"))); #else #ifndef xmlRecoverFile extern __typeof (xmlRecoverFile) xmlRecoverFile__internal_alias __attribute((visibility("hidden"))); #define xmlRecoverFile xmlRecoverFile__internal_alias #endif #endif #endif #if defined(LIBXML_SAX1_ENABLED) #ifdef bottom_parser #undef xmlRecoverMemory extern __typeof (xmlRecoverMemory) xmlRecoverMemory __attribute((alias("xmlRecoverMemory__internal_alias"))); #else #ifndef xmlRecoverMemory extern __typeof (xmlRecoverMemory) xmlRecoverMemory__internal_alias __attribute((visibility("hidden"))); #define xmlRecoverMemory xmlRecoverMemory__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) #ifdef bottom_xmlregexp #undef xmlRegExecErrInfo extern __typeof (xmlRegExecErrInfo) xmlRegExecErrInfo __attribute((alias("xmlRegExecErrInfo__internal_alias"))); #else #ifndef xmlRegExecErrInfo extern __typeof (xmlRegExecErrInfo) xmlRegExecErrInfo__internal_alias __attribute((visibility("hidden"))); #define xmlRegExecErrInfo xmlRegExecErrInfo__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) #ifdef bottom_xmlregexp #undef xmlRegExecNextValues extern __typeof (xmlRegExecNextValues) xmlRegExecNextValues __attribute((alias("xmlRegExecNextValues__internal_alias"))); #else #ifndef xmlRegExecNextValues extern __typeof (xmlRegExecNextValues) xmlRegExecNextValues__internal_alias __attribute((visibility("hidden"))); #define xmlRegExecNextValues xmlRegExecNextValues__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) #ifdef bottom_xmlregexp #undef xmlRegExecPushString extern __typeof (xmlRegExecPushString) xmlRegExecPushString __attribute((alias("xmlRegExecPushString__internal_alias"))); #else #ifndef xmlRegExecPushString extern __typeof (xmlRegExecPushString) xmlRegExecPushString__internal_alias __attribute((visibility("hidden"))); #define xmlRegExecPushString xmlRegExecPushString__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) #ifdef bottom_xmlregexp #undef xmlRegExecPushString2 extern __typeof (xmlRegExecPushString2) xmlRegExecPushString2 __attribute((alias("xmlRegExecPushString2__internal_alias"))); #else #ifndef xmlRegExecPushString2 extern __typeof (xmlRegExecPushString2) xmlRegExecPushString2__internal_alias __attribute((visibility("hidden"))); #define xmlRegExecPushString2 xmlRegExecPushString2__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) #ifdef bottom_xmlregexp #undef xmlRegFreeExecCtxt extern __typeof (xmlRegFreeExecCtxt) xmlRegFreeExecCtxt __attribute((alias("xmlRegFreeExecCtxt__internal_alias"))); #else #ifndef xmlRegFreeExecCtxt extern __typeof (xmlRegFreeExecCtxt) xmlRegFreeExecCtxt__internal_alias __attribute((visibility("hidden"))); #define xmlRegFreeExecCtxt xmlRegFreeExecCtxt__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) #ifdef bottom_xmlregexp #undef xmlRegFreeRegexp extern __typeof (xmlRegFreeRegexp) xmlRegFreeRegexp __attribute((alias("xmlRegFreeRegexp__internal_alias"))); #else #ifndef xmlRegFreeRegexp extern __typeof (xmlRegFreeRegexp) xmlRegFreeRegexp__internal_alias __attribute((visibility("hidden"))); #define xmlRegFreeRegexp xmlRegFreeRegexp__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) #ifdef bottom_xmlregexp #undef xmlRegNewExecCtxt extern __typeof (xmlRegNewExecCtxt) xmlRegNewExecCtxt __attribute((alias("xmlRegNewExecCtxt__internal_alias"))); #else #ifndef xmlRegNewExecCtxt extern __typeof (xmlRegNewExecCtxt) xmlRegNewExecCtxt__internal_alias __attribute((visibility("hidden"))); #define xmlRegNewExecCtxt xmlRegNewExecCtxt__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) #ifdef bottom_xmlregexp #undef xmlRegexpCompile extern __typeof (xmlRegexpCompile) xmlRegexpCompile __attribute((alias("xmlRegexpCompile__internal_alias"))); #else #ifndef xmlRegexpCompile extern __typeof (xmlRegexpCompile) xmlRegexpCompile__internal_alias __attribute((visibility("hidden"))); #define xmlRegexpCompile xmlRegexpCompile__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) #ifdef bottom_xmlregexp #undef xmlRegexpExec extern __typeof (xmlRegexpExec) xmlRegexpExec __attribute((alias("xmlRegexpExec__internal_alias"))); #else #ifndef xmlRegexpExec extern __typeof (xmlRegexpExec) xmlRegexpExec__internal_alias __attribute((visibility("hidden"))); #define xmlRegexpExec xmlRegexpExec__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) #ifdef bottom_xmlregexp #undef xmlRegexpIsDeterminist extern __typeof (xmlRegexpIsDeterminist) xmlRegexpIsDeterminist __attribute((alias("xmlRegexpIsDeterminist__internal_alias"))); #else #ifndef xmlRegexpIsDeterminist extern __typeof (xmlRegexpIsDeterminist) xmlRegexpIsDeterminist__internal_alias __attribute((visibility("hidden"))); #define xmlRegexpIsDeterminist xmlRegexpIsDeterminist__internal_alias #endif #endif #endif #if defined(LIBXML_REGEXP_ENABLED) #ifdef bottom_xmlregexp #undef xmlRegexpPrint extern __typeof (xmlRegexpPrint) xmlRegexpPrint __attribute((alias("xmlRegexpPrint__internal_alias"))); #else #ifndef xmlRegexpPrint extern __typeof (xmlRegexpPrint) xmlRegexpPrint__internal_alias __attribute((visibility("hidden"))); #define xmlRegexpPrint xmlRegexpPrint__internal_alias #endif #endif #endif #ifdef bottom_encoding #undef xmlRegisterCharEncodingHandler extern __typeof (xmlRegisterCharEncodingHandler) xmlRegisterCharEncodingHandler __attribute((alias("xmlRegisterCharEncodingHandler__internal_alias"))); #else #ifndef xmlRegisterCharEncodingHandler extern __typeof (xmlRegisterCharEncodingHandler) xmlRegisterCharEncodingHandler__internal_alias __attribute((visibility("hidden"))); #define xmlRegisterCharEncodingHandler xmlRegisterCharEncodingHandler__internal_alias #endif #endif #ifdef bottom_xmlIO #undef xmlRegisterDefaultInputCallbacks extern __typeof (xmlRegisterDefaultInputCallbacks) xmlRegisterDefaultInputCallbacks __attribute((alias("xmlRegisterDefaultInputCallbacks__internal_alias"))); #else #ifndef xmlRegisterDefaultInputCallbacks extern __typeof (xmlRegisterDefaultInputCallbacks) xmlRegisterDefaultInputCallbacks__internal_alias __attribute((visibility("hidden"))); #define xmlRegisterDefaultInputCallbacks xmlRegisterDefaultInputCallbacks__internal_alias #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_xmlIO #undef xmlRegisterDefaultOutputCallbacks extern __typeof (xmlRegisterDefaultOutputCallbacks) xmlRegisterDefaultOutputCallbacks __attribute((alias("xmlRegisterDefaultOutputCallbacks__internal_alias"))); #else #ifndef xmlRegisterDefaultOutputCallbacks extern __typeof (xmlRegisterDefaultOutputCallbacks) xmlRegisterDefaultOutputCallbacks__internal_alias __attribute((visibility("hidden"))); #define xmlRegisterDefaultOutputCallbacks xmlRegisterDefaultOutputCallbacks__internal_alias #endif #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) && defined(LIBXML_HTTP_ENABLED) #ifdef bottom_xmlIO #undef xmlRegisterHTTPPostCallbacks extern __typeof (xmlRegisterHTTPPostCallbacks) xmlRegisterHTTPPostCallbacks __attribute((alias("xmlRegisterHTTPPostCallbacks__internal_alias"))); #else #ifndef xmlRegisterHTTPPostCallbacks extern __typeof (xmlRegisterHTTPPostCallbacks) xmlRegisterHTTPPostCallbacks__internal_alias __attribute((visibility("hidden"))); #define xmlRegisterHTTPPostCallbacks xmlRegisterHTTPPostCallbacks__internal_alias #endif #endif #endif #ifdef bottom_xmlIO #undef xmlRegisterInputCallbacks extern __typeof (xmlRegisterInputCallbacks) xmlRegisterInputCallbacks __attribute((alias("xmlRegisterInputCallbacks__internal_alias"))); #else #ifndef xmlRegisterInputCallbacks extern __typeof (xmlRegisterInputCallbacks) xmlRegisterInputCallbacks__internal_alias __attribute((visibility("hidden"))); #define xmlRegisterInputCallbacks xmlRegisterInputCallbacks__internal_alias #endif #endif #ifdef bottom_globals #undef xmlRegisterNodeDefault extern __typeof (xmlRegisterNodeDefault) xmlRegisterNodeDefault __attribute((alias("xmlRegisterNodeDefault__internal_alias"))); #else #ifndef xmlRegisterNodeDefault extern __typeof (xmlRegisterNodeDefault) xmlRegisterNodeDefault__internal_alias __attribute((visibility("hidden"))); #define xmlRegisterNodeDefault xmlRegisterNodeDefault__internal_alias #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_xmlIO #undef xmlRegisterOutputCallbacks extern __typeof (xmlRegisterOutputCallbacks) xmlRegisterOutputCallbacks __attribute((alias("xmlRegisterOutputCallbacks__internal_alias"))); #else #ifndef xmlRegisterOutputCallbacks extern __typeof (xmlRegisterOutputCallbacks) xmlRegisterOutputCallbacks__internal_alias __attribute((visibility("hidden"))); #define xmlRegisterOutputCallbacks xmlRegisterOutputCallbacks__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_relaxng #undef xmlRelaxNGCleanupTypes extern __typeof (xmlRelaxNGCleanupTypes) xmlRelaxNGCleanupTypes __attribute((alias("xmlRelaxNGCleanupTypes__internal_alias"))); #else #ifndef xmlRelaxNGCleanupTypes extern __typeof (xmlRelaxNGCleanupTypes) xmlRelaxNGCleanupTypes__internal_alias __attribute((visibility("hidden"))); #define xmlRelaxNGCleanupTypes xmlRelaxNGCleanupTypes__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_relaxng #undef xmlRelaxNGDump extern __typeof (xmlRelaxNGDump) xmlRelaxNGDump __attribute((alias("xmlRelaxNGDump__internal_alias"))); #else #ifndef xmlRelaxNGDump extern __typeof (xmlRelaxNGDump) xmlRelaxNGDump__internal_alias __attribute((visibility("hidden"))); #define xmlRelaxNGDump xmlRelaxNGDump__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_relaxng #undef xmlRelaxNGDumpTree extern __typeof (xmlRelaxNGDumpTree) xmlRelaxNGDumpTree __attribute((alias("xmlRelaxNGDumpTree__internal_alias"))); #else #ifndef xmlRelaxNGDumpTree extern __typeof (xmlRelaxNGDumpTree) xmlRelaxNGDumpTree__internal_alias __attribute((visibility("hidden"))); #define xmlRelaxNGDumpTree xmlRelaxNGDumpTree__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_relaxng #undef xmlRelaxNGFree extern __typeof (xmlRelaxNGFree) xmlRelaxNGFree __attribute((alias("xmlRelaxNGFree__internal_alias"))); #else #ifndef xmlRelaxNGFree extern __typeof (xmlRelaxNGFree) xmlRelaxNGFree__internal_alias __attribute((visibility("hidden"))); #define xmlRelaxNGFree xmlRelaxNGFree__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_relaxng #undef xmlRelaxNGFreeParserCtxt extern __typeof (xmlRelaxNGFreeParserCtxt) xmlRelaxNGFreeParserCtxt __attribute((alias("xmlRelaxNGFreeParserCtxt__internal_alias"))); #else #ifndef xmlRelaxNGFreeParserCtxt extern __typeof (xmlRelaxNGFreeParserCtxt) xmlRelaxNGFreeParserCtxt__internal_alias __attribute((visibility("hidden"))); #define xmlRelaxNGFreeParserCtxt xmlRelaxNGFreeParserCtxt__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_relaxng #undef xmlRelaxNGFreeValidCtxt extern __typeof (xmlRelaxNGFreeValidCtxt) xmlRelaxNGFreeValidCtxt __attribute((alias("xmlRelaxNGFreeValidCtxt__internal_alias"))); #else #ifndef xmlRelaxNGFreeValidCtxt extern __typeof (xmlRelaxNGFreeValidCtxt) xmlRelaxNGFreeValidCtxt__internal_alias __attribute((visibility("hidden"))); #define xmlRelaxNGFreeValidCtxt xmlRelaxNGFreeValidCtxt__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_relaxng #undef xmlRelaxNGGetParserErrors extern __typeof (xmlRelaxNGGetParserErrors) xmlRelaxNGGetParserErrors __attribute((alias("xmlRelaxNGGetParserErrors__internal_alias"))); #else #ifndef xmlRelaxNGGetParserErrors extern __typeof (xmlRelaxNGGetParserErrors) xmlRelaxNGGetParserErrors__internal_alias __attribute((visibility("hidden"))); #define xmlRelaxNGGetParserErrors xmlRelaxNGGetParserErrors__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_relaxng #undef xmlRelaxNGGetValidErrors extern __typeof (xmlRelaxNGGetValidErrors) xmlRelaxNGGetValidErrors __attribute((alias("xmlRelaxNGGetValidErrors__internal_alias"))); #else #ifndef xmlRelaxNGGetValidErrors extern __typeof (xmlRelaxNGGetValidErrors) xmlRelaxNGGetValidErrors__internal_alias __attribute((visibility("hidden"))); #define xmlRelaxNGGetValidErrors xmlRelaxNGGetValidErrors__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_relaxng #undef xmlRelaxNGInitTypes extern __typeof (xmlRelaxNGInitTypes) xmlRelaxNGInitTypes __attribute((alias("xmlRelaxNGInitTypes__internal_alias"))); #else #ifndef xmlRelaxNGInitTypes extern __typeof (xmlRelaxNGInitTypes) xmlRelaxNGInitTypes__internal_alias __attribute((visibility("hidden"))); #define xmlRelaxNGInitTypes xmlRelaxNGInitTypes__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_relaxng #undef xmlRelaxNGNewDocParserCtxt extern __typeof (xmlRelaxNGNewDocParserCtxt) xmlRelaxNGNewDocParserCtxt __attribute((alias("xmlRelaxNGNewDocParserCtxt__internal_alias"))); #else #ifndef xmlRelaxNGNewDocParserCtxt extern __typeof (xmlRelaxNGNewDocParserCtxt) xmlRelaxNGNewDocParserCtxt__internal_alias __attribute((visibility("hidden"))); #define xmlRelaxNGNewDocParserCtxt xmlRelaxNGNewDocParserCtxt__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_relaxng #undef xmlRelaxNGNewMemParserCtxt extern __typeof (xmlRelaxNGNewMemParserCtxt) xmlRelaxNGNewMemParserCtxt __attribute((alias("xmlRelaxNGNewMemParserCtxt__internal_alias"))); #else #ifndef xmlRelaxNGNewMemParserCtxt extern __typeof (xmlRelaxNGNewMemParserCtxt) xmlRelaxNGNewMemParserCtxt__internal_alias __attribute((visibility("hidden"))); #define xmlRelaxNGNewMemParserCtxt xmlRelaxNGNewMemParserCtxt__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_relaxng #undef xmlRelaxNGNewParserCtxt extern __typeof (xmlRelaxNGNewParserCtxt) xmlRelaxNGNewParserCtxt __attribute((alias("xmlRelaxNGNewParserCtxt__internal_alias"))); #else #ifndef xmlRelaxNGNewParserCtxt extern __typeof (xmlRelaxNGNewParserCtxt) xmlRelaxNGNewParserCtxt__internal_alias __attribute((visibility("hidden"))); #define xmlRelaxNGNewParserCtxt xmlRelaxNGNewParserCtxt__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_relaxng #undef xmlRelaxNGNewValidCtxt extern __typeof (xmlRelaxNGNewValidCtxt) xmlRelaxNGNewValidCtxt __attribute((alias("xmlRelaxNGNewValidCtxt__internal_alias"))); #else #ifndef xmlRelaxNGNewValidCtxt extern __typeof (xmlRelaxNGNewValidCtxt) xmlRelaxNGNewValidCtxt__internal_alias __attribute((visibility("hidden"))); #define xmlRelaxNGNewValidCtxt xmlRelaxNGNewValidCtxt__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_relaxng #undef xmlRelaxNGParse extern __typeof (xmlRelaxNGParse) xmlRelaxNGParse __attribute((alias("xmlRelaxNGParse__internal_alias"))); #else #ifndef xmlRelaxNGParse extern __typeof (xmlRelaxNGParse) xmlRelaxNGParse__internal_alias __attribute((visibility("hidden"))); #define xmlRelaxNGParse xmlRelaxNGParse__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_relaxng #undef xmlRelaxNGSetParserErrors extern __typeof (xmlRelaxNGSetParserErrors) xmlRelaxNGSetParserErrors __attribute((alias("xmlRelaxNGSetParserErrors__internal_alias"))); #else #ifndef xmlRelaxNGSetParserErrors extern __typeof (xmlRelaxNGSetParserErrors) xmlRelaxNGSetParserErrors__internal_alias __attribute((visibility("hidden"))); #define xmlRelaxNGSetParserErrors xmlRelaxNGSetParserErrors__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_relaxng #undef xmlRelaxNGSetParserStructuredErrors extern __typeof (xmlRelaxNGSetParserStructuredErrors) xmlRelaxNGSetParserStructuredErrors __attribute((alias("xmlRelaxNGSetParserStructuredErrors__internal_alias"))); #else #ifndef xmlRelaxNGSetParserStructuredErrors extern __typeof (xmlRelaxNGSetParserStructuredErrors) xmlRelaxNGSetParserStructuredErrors__internal_alias __attribute((visibility("hidden"))); #define xmlRelaxNGSetParserStructuredErrors xmlRelaxNGSetParserStructuredErrors__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_relaxng #undef xmlRelaxNGSetValidErrors extern __typeof (xmlRelaxNGSetValidErrors) xmlRelaxNGSetValidErrors __attribute((alias("xmlRelaxNGSetValidErrors__internal_alias"))); #else #ifndef xmlRelaxNGSetValidErrors extern __typeof (xmlRelaxNGSetValidErrors) xmlRelaxNGSetValidErrors__internal_alias __attribute((visibility("hidden"))); #define xmlRelaxNGSetValidErrors xmlRelaxNGSetValidErrors__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_relaxng #undef xmlRelaxNGSetValidStructuredErrors extern __typeof (xmlRelaxNGSetValidStructuredErrors) xmlRelaxNGSetValidStructuredErrors __attribute((alias("xmlRelaxNGSetValidStructuredErrors__internal_alias"))); #else #ifndef xmlRelaxNGSetValidStructuredErrors extern __typeof (xmlRelaxNGSetValidStructuredErrors) xmlRelaxNGSetValidStructuredErrors__internal_alias __attribute((visibility("hidden"))); #define xmlRelaxNGSetValidStructuredErrors xmlRelaxNGSetValidStructuredErrors__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_relaxng #undef xmlRelaxNGValidateDoc extern __typeof (xmlRelaxNGValidateDoc) xmlRelaxNGValidateDoc __attribute((alias("xmlRelaxNGValidateDoc__internal_alias"))); #else #ifndef xmlRelaxNGValidateDoc extern __typeof (xmlRelaxNGValidateDoc) xmlRelaxNGValidateDoc__internal_alias __attribute((visibility("hidden"))); #define xmlRelaxNGValidateDoc xmlRelaxNGValidateDoc__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_relaxng #undef xmlRelaxNGValidateFullElement extern __typeof (xmlRelaxNGValidateFullElement) xmlRelaxNGValidateFullElement __attribute((alias("xmlRelaxNGValidateFullElement__internal_alias"))); #else #ifndef xmlRelaxNGValidateFullElement extern __typeof (xmlRelaxNGValidateFullElement) xmlRelaxNGValidateFullElement__internal_alias __attribute((visibility("hidden"))); #define xmlRelaxNGValidateFullElement xmlRelaxNGValidateFullElement__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_relaxng #undef xmlRelaxNGValidatePopElement extern __typeof (xmlRelaxNGValidatePopElement) xmlRelaxNGValidatePopElement __attribute((alias("xmlRelaxNGValidatePopElement__internal_alias"))); #else #ifndef xmlRelaxNGValidatePopElement extern __typeof (xmlRelaxNGValidatePopElement) xmlRelaxNGValidatePopElement__internal_alias __attribute((visibility("hidden"))); #define xmlRelaxNGValidatePopElement xmlRelaxNGValidatePopElement__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_relaxng #undef xmlRelaxNGValidatePushCData extern __typeof (xmlRelaxNGValidatePushCData) xmlRelaxNGValidatePushCData __attribute((alias("xmlRelaxNGValidatePushCData__internal_alias"))); #else #ifndef xmlRelaxNGValidatePushCData extern __typeof (xmlRelaxNGValidatePushCData) xmlRelaxNGValidatePushCData__internal_alias __attribute((visibility("hidden"))); #define xmlRelaxNGValidatePushCData xmlRelaxNGValidatePushCData__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_relaxng #undef xmlRelaxNGValidatePushElement extern __typeof (xmlRelaxNGValidatePushElement) xmlRelaxNGValidatePushElement __attribute((alias("xmlRelaxNGValidatePushElement__internal_alias"))); #else #ifndef xmlRelaxNGValidatePushElement extern __typeof (xmlRelaxNGValidatePushElement) xmlRelaxNGValidatePushElement__internal_alias __attribute((visibility("hidden"))); #define xmlRelaxNGValidatePushElement xmlRelaxNGValidatePushElement__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_relaxng #undef xmlRelaxParserSetFlag extern __typeof (xmlRelaxParserSetFlag) xmlRelaxParserSetFlag __attribute((alias("xmlRelaxParserSetFlag__internal_alias"))); #else #ifndef xmlRelaxParserSetFlag extern __typeof (xmlRelaxParserSetFlag) xmlRelaxParserSetFlag__internal_alias __attribute((visibility("hidden"))); #define xmlRelaxParserSetFlag xmlRelaxParserSetFlag__internal_alias #endif #endif #endif #ifdef bottom_valid #undef xmlRemoveID extern __typeof (xmlRemoveID) xmlRemoveID __attribute((alias("xmlRemoveID__internal_alias"))); #else #ifndef xmlRemoveID extern __typeof (xmlRemoveID) xmlRemoveID__internal_alias __attribute((visibility("hidden"))); #define xmlRemoveID xmlRemoveID__internal_alias #endif #endif #if defined(LIBXML_TREE_ENABLED) #ifdef bottom_tree #undef xmlRemoveProp extern __typeof (xmlRemoveProp) xmlRemoveProp __attribute((alias("xmlRemoveProp__internal_alias"))); #else #ifndef xmlRemoveProp extern __typeof (xmlRemoveProp) xmlRemoveProp__internal_alias __attribute((visibility("hidden"))); #define xmlRemoveProp xmlRemoveProp__internal_alias #endif #endif #endif #ifdef bottom_valid #undef xmlRemoveRef extern __typeof (xmlRemoveRef) xmlRemoveRef __attribute((alias("xmlRemoveRef__internal_alias"))); #else #ifndef xmlRemoveRef extern __typeof (xmlRemoveRef) xmlRemoveRef__internal_alias __attribute((visibility("hidden"))); #define xmlRemoveRef xmlRemoveRef__internal_alias #endif #endif #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) #ifdef bottom_tree #undef xmlReplaceNode extern __typeof (xmlReplaceNode) xmlReplaceNode __attribute((alias("xmlReplaceNode__internal_alias"))); #else #ifndef xmlReplaceNode extern __typeof (xmlReplaceNode) xmlReplaceNode__internal_alias __attribute((visibility("hidden"))); #define xmlReplaceNode xmlReplaceNode__internal_alias #endif #endif #endif #ifdef bottom_error #undef xmlResetError extern __typeof (xmlResetError) xmlResetError __attribute((alias("xmlResetError__internal_alias"))); #else #ifndef xmlResetError extern __typeof (xmlResetError) xmlResetError__internal_alias __attribute((visibility("hidden"))); #define xmlResetError xmlResetError__internal_alias #endif #endif #ifdef bottom_error #undef xmlResetLastError extern __typeof (xmlResetLastError) xmlResetLastError __attribute((alias("xmlResetLastError__internal_alias"))); #else #ifndef xmlResetLastError extern __typeof (xmlResetLastError) xmlResetLastError__internal_alias __attribute((visibility("hidden"))); #define xmlResetLastError xmlResetLastError__internal_alias #endif #endif #ifdef bottom_SAX2 #undef xmlSAX2AttributeDecl extern __typeof (xmlSAX2AttributeDecl) xmlSAX2AttributeDecl __attribute((alias("xmlSAX2AttributeDecl__internal_alias"))); #else #ifndef xmlSAX2AttributeDecl extern __typeof (xmlSAX2AttributeDecl) xmlSAX2AttributeDecl__internal_alias __attribute((visibility("hidden"))); #define xmlSAX2AttributeDecl xmlSAX2AttributeDecl__internal_alias #endif #endif #ifdef bottom_SAX2 #undef xmlSAX2CDataBlock extern __typeof (xmlSAX2CDataBlock) xmlSAX2CDataBlock __attribute((alias("xmlSAX2CDataBlock__internal_alias"))); #else #ifndef xmlSAX2CDataBlock extern __typeof (xmlSAX2CDataBlock) xmlSAX2CDataBlock__internal_alias __attribute((visibility("hidden"))); #define xmlSAX2CDataBlock xmlSAX2CDataBlock__internal_alias #endif #endif #ifdef bottom_SAX2 #undef xmlSAX2Characters extern __typeof (xmlSAX2Characters) xmlSAX2Characters __attribute((alias("xmlSAX2Characters__internal_alias"))); #else #ifndef xmlSAX2Characters extern __typeof (xmlSAX2Characters) xmlSAX2Characters__internal_alias __attribute((visibility("hidden"))); #define xmlSAX2Characters xmlSAX2Characters__internal_alias #endif #endif #ifdef bottom_SAX2 #undef xmlSAX2Comment extern __typeof (xmlSAX2Comment) xmlSAX2Comment __attribute((alias("xmlSAX2Comment__internal_alias"))); #else #ifndef xmlSAX2Comment extern __typeof (xmlSAX2Comment) xmlSAX2Comment__internal_alias __attribute((visibility("hidden"))); #define xmlSAX2Comment xmlSAX2Comment__internal_alias #endif #endif #ifdef bottom_SAX2 #undef xmlSAX2ElementDecl extern __typeof (xmlSAX2ElementDecl) xmlSAX2ElementDecl __attribute((alias("xmlSAX2ElementDecl__internal_alias"))); #else #ifndef xmlSAX2ElementDecl extern __typeof (xmlSAX2ElementDecl) xmlSAX2ElementDecl__internal_alias __attribute((visibility("hidden"))); #define xmlSAX2ElementDecl xmlSAX2ElementDecl__internal_alias #endif #endif #ifdef bottom_SAX2 #undef xmlSAX2EndDocument extern __typeof (xmlSAX2EndDocument) xmlSAX2EndDocument __attribute((alias("xmlSAX2EndDocument__internal_alias"))); #else #ifndef xmlSAX2EndDocument extern __typeof (xmlSAX2EndDocument) xmlSAX2EndDocument__internal_alias __attribute((visibility("hidden"))); #define xmlSAX2EndDocument xmlSAX2EndDocument__internal_alias #endif #endif #if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED) #ifdef bottom_SAX2 #undef xmlSAX2EndElement extern __typeof (xmlSAX2EndElement) xmlSAX2EndElement __attribute((alias("xmlSAX2EndElement__internal_alias"))); #else #ifndef xmlSAX2EndElement extern __typeof (xmlSAX2EndElement) xmlSAX2EndElement__internal_alias __attribute((visibility("hidden"))); #define xmlSAX2EndElement xmlSAX2EndElement__internal_alias #endif #endif #endif #ifdef bottom_SAX2 #undef xmlSAX2EndElementNs extern __typeof (xmlSAX2EndElementNs) xmlSAX2EndElementNs __attribute((alias("xmlSAX2EndElementNs__internal_alias"))); #else #ifndef xmlSAX2EndElementNs extern __typeof (xmlSAX2EndElementNs) xmlSAX2EndElementNs__internal_alias __attribute((visibility("hidden"))); #define xmlSAX2EndElementNs xmlSAX2EndElementNs__internal_alias #endif #endif #ifdef bottom_SAX2 #undef xmlSAX2EntityDecl extern __typeof (xmlSAX2EntityDecl) xmlSAX2EntityDecl __attribute((alias("xmlSAX2EntityDecl__internal_alias"))); #else #ifndef xmlSAX2EntityDecl extern __typeof (xmlSAX2EntityDecl) xmlSAX2EntityDecl__internal_alias __attribute((visibility("hidden"))); #define xmlSAX2EntityDecl xmlSAX2EntityDecl__internal_alias #endif #endif #ifdef bottom_SAX2 #undef xmlSAX2ExternalSubset extern __typeof (xmlSAX2ExternalSubset) xmlSAX2ExternalSubset __attribute((alias("xmlSAX2ExternalSubset__internal_alias"))); #else #ifndef xmlSAX2ExternalSubset extern __typeof (xmlSAX2ExternalSubset) xmlSAX2ExternalSubset__internal_alias __attribute((visibility("hidden"))); #define xmlSAX2ExternalSubset xmlSAX2ExternalSubset__internal_alias #endif #endif #ifdef bottom_SAX2 #undef xmlSAX2GetColumnNumber extern __typeof (xmlSAX2GetColumnNumber) xmlSAX2GetColumnNumber __attribute((alias("xmlSAX2GetColumnNumber__internal_alias"))); #else #ifndef xmlSAX2GetColumnNumber extern __typeof (xmlSAX2GetColumnNumber) xmlSAX2GetColumnNumber__internal_alias __attribute((visibility("hidden"))); #define xmlSAX2GetColumnNumber xmlSAX2GetColumnNumber__internal_alias #endif #endif #ifdef bottom_SAX2 #undef xmlSAX2GetEntity extern __typeof (xmlSAX2GetEntity) xmlSAX2GetEntity __attribute((alias("xmlSAX2GetEntity__internal_alias"))); #else #ifndef xmlSAX2GetEntity extern __typeof (xmlSAX2GetEntity) xmlSAX2GetEntity__internal_alias __attribute((visibility("hidden"))); #define xmlSAX2GetEntity xmlSAX2GetEntity__internal_alias #endif #endif #ifdef bottom_SAX2 #undef xmlSAX2GetLineNumber extern __typeof (xmlSAX2GetLineNumber) xmlSAX2GetLineNumber __attribute((alias("xmlSAX2GetLineNumber__internal_alias"))); #else #ifndef xmlSAX2GetLineNumber extern __typeof (xmlSAX2GetLineNumber) xmlSAX2GetLineNumber__internal_alias __attribute((visibility("hidden"))); #define xmlSAX2GetLineNumber xmlSAX2GetLineNumber__internal_alias #endif #endif #ifdef bottom_SAX2 #undef xmlSAX2GetParameterEntity extern __typeof (xmlSAX2GetParameterEntity) xmlSAX2GetParameterEntity __attribute((alias("xmlSAX2GetParameterEntity__internal_alias"))); #else #ifndef xmlSAX2GetParameterEntity extern __typeof (xmlSAX2GetParameterEntity) xmlSAX2GetParameterEntity__internal_alias __attribute((visibility("hidden"))); #define xmlSAX2GetParameterEntity xmlSAX2GetParameterEntity__internal_alias #endif #endif #ifdef bottom_SAX2 #undef xmlSAX2GetPublicId extern __typeof (xmlSAX2GetPublicId) xmlSAX2GetPublicId __attribute((alias("xmlSAX2GetPublicId__internal_alias"))); #else #ifndef xmlSAX2GetPublicId extern __typeof (xmlSAX2GetPublicId) xmlSAX2GetPublicId__internal_alias __attribute((visibility("hidden"))); #define xmlSAX2GetPublicId xmlSAX2GetPublicId__internal_alias #endif #endif #ifdef bottom_SAX2 #undef xmlSAX2GetSystemId extern __typeof (xmlSAX2GetSystemId) xmlSAX2GetSystemId __attribute((alias("xmlSAX2GetSystemId__internal_alias"))); #else #ifndef xmlSAX2GetSystemId extern __typeof (xmlSAX2GetSystemId) xmlSAX2GetSystemId__internal_alias __attribute((visibility("hidden"))); #define xmlSAX2GetSystemId xmlSAX2GetSystemId__internal_alias #endif #endif #ifdef bottom_SAX2 #undef xmlSAX2HasExternalSubset extern __typeof (xmlSAX2HasExternalSubset) xmlSAX2HasExternalSubset __attribute((alias("xmlSAX2HasExternalSubset__internal_alias"))); #else #ifndef xmlSAX2HasExternalSubset extern __typeof (xmlSAX2HasExternalSubset) xmlSAX2HasExternalSubset__internal_alias __attribute((visibility("hidden"))); #define xmlSAX2HasExternalSubset xmlSAX2HasExternalSubset__internal_alias #endif #endif #ifdef bottom_SAX2 #undef xmlSAX2HasInternalSubset extern __typeof (xmlSAX2HasInternalSubset) xmlSAX2HasInternalSubset __attribute((alias("xmlSAX2HasInternalSubset__internal_alias"))); #else #ifndef xmlSAX2HasInternalSubset extern __typeof (xmlSAX2HasInternalSubset) xmlSAX2HasInternalSubset__internal_alias __attribute((visibility("hidden"))); #define xmlSAX2HasInternalSubset xmlSAX2HasInternalSubset__internal_alias #endif #endif #ifdef bottom_SAX2 #undef xmlSAX2IgnorableWhitespace extern __typeof (xmlSAX2IgnorableWhitespace) xmlSAX2IgnorableWhitespace __attribute((alias("xmlSAX2IgnorableWhitespace__internal_alias"))); #else #ifndef xmlSAX2IgnorableWhitespace extern __typeof (xmlSAX2IgnorableWhitespace) xmlSAX2IgnorableWhitespace__internal_alias __attribute((visibility("hidden"))); #define xmlSAX2IgnorableWhitespace xmlSAX2IgnorableWhitespace__internal_alias #endif #endif #ifdef bottom_SAX2 #undef xmlSAX2InitDefaultSAXHandler extern __typeof (xmlSAX2InitDefaultSAXHandler) xmlSAX2InitDefaultSAXHandler __attribute((alias("xmlSAX2InitDefaultSAXHandler__internal_alias"))); #else #ifndef xmlSAX2InitDefaultSAXHandler extern __typeof (xmlSAX2InitDefaultSAXHandler) xmlSAX2InitDefaultSAXHandler__internal_alias __attribute((visibility("hidden"))); #define xmlSAX2InitDefaultSAXHandler xmlSAX2InitDefaultSAXHandler__internal_alias #endif #endif #if defined(LIBXML_DOCB_ENABLED) #ifdef bottom_SAX2 #undef xmlSAX2InitDocbDefaultSAXHandler extern __typeof (xmlSAX2InitDocbDefaultSAXHandler) xmlSAX2InitDocbDefaultSAXHandler __attribute((alias("xmlSAX2InitDocbDefaultSAXHandler__internal_alias"))); #else #ifndef xmlSAX2InitDocbDefaultSAXHandler extern __typeof (xmlSAX2InitDocbDefaultSAXHandler) xmlSAX2InitDocbDefaultSAXHandler__internal_alias __attribute((visibility("hidden"))); #define xmlSAX2InitDocbDefaultSAXHandler xmlSAX2InitDocbDefaultSAXHandler__internal_alias #endif #endif #endif #if defined(LIBXML_HTML_ENABLED) #ifdef bottom_SAX2 #undef xmlSAX2InitHtmlDefaultSAXHandler extern __typeof (xmlSAX2InitHtmlDefaultSAXHandler) xmlSAX2InitHtmlDefaultSAXHandler __attribute((alias("xmlSAX2InitHtmlDefaultSAXHandler__internal_alias"))); #else #ifndef xmlSAX2InitHtmlDefaultSAXHandler extern __typeof (xmlSAX2InitHtmlDefaultSAXHandler) xmlSAX2InitHtmlDefaultSAXHandler__internal_alias __attribute((visibility("hidden"))); #define xmlSAX2InitHtmlDefaultSAXHandler xmlSAX2InitHtmlDefaultSAXHandler__internal_alias #endif #endif #endif #ifdef bottom_SAX2 #undef xmlSAX2InternalSubset extern __typeof (xmlSAX2InternalSubset) xmlSAX2InternalSubset __attribute((alias("xmlSAX2InternalSubset__internal_alias"))); #else #ifndef xmlSAX2InternalSubset extern __typeof (xmlSAX2InternalSubset) xmlSAX2InternalSubset__internal_alias __attribute((visibility("hidden"))); #define xmlSAX2InternalSubset xmlSAX2InternalSubset__internal_alias #endif #endif #ifdef bottom_SAX2 #undef xmlSAX2IsStandalone extern __typeof (xmlSAX2IsStandalone) xmlSAX2IsStandalone __attribute((alias("xmlSAX2IsStandalone__internal_alias"))); #else #ifndef xmlSAX2IsStandalone extern __typeof (xmlSAX2IsStandalone) xmlSAX2IsStandalone__internal_alias __attribute((visibility("hidden"))); #define xmlSAX2IsStandalone xmlSAX2IsStandalone__internal_alias #endif #endif #ifdef bottom_SAX2 #undef xmlSAX2NotationDecl extern __typeof (xmlSAX2NotationDecl) xmlSAX2NotationDecl __attribute((alias("xmlSAX2NotationDecl__internal_alias"))); #else #ifndef xmlSAX2NotationDecl extern __typeof (xmlSAX2NotationDecl) xmlSAX2NotationDecl__internal_alias __attribute((visibility("hidden"))); #define xmlSAX2NotationDecl xmlSAX2NotationDecl__internal_alias #endif #endif #ifdef bottom_SAX2 #undef xmlSAX2ProcessingInstruction extern __typeof (xmlSAX2ProcessingInstruction) xmlSAX2ProcessingInstruction __attribute((alias("xmlSAX2ProcessingInstruction__internal_alias"))); #else #ifndef xmlSAX2ProcessingInstruction extern __typeof (xmlSAX2ProcessingInstruction) xmlSAX2ProcessingInstruction__internal_alias __attribute((visibility("hidden"))); #define xmlSAX2ProcessingInstruction xmlSAX2ProcessingInstruction__internal_alias #endif #endif #ifdef bottom_SAX2 #undef xmlSAX2Reference extern __typeof (xmlSAX2Reference) xmlSAX2Reference __attribute((alias("xmlSAX2Reference__internal_alias"))); #else #ifndef xmlSAX2Reference extern __typeof (xmlSAX2Reference) xmlSAX2Reference__internal_alias __attribute((visibility("hidden"))); #define xmlSAX2Reference xmlSAX2Reference__internal_alias #endif #endif #ifdef bottom_SAX2 #undef xmlSAX2ResolveEntity extern __typeof (xmlSAX2ResolveEntity) xmlSAX2ResolveEntity __attribute((alias("xmlSAX2ResolveEntity__internal_alias"))); #else #ifndef xmlSAX2ResolveEntity extern __typeof (xmlSAX2ResolveEntity) xmlSAX2ResolveEntity__internal_alias __attribute((visibility("hidden"))); #define xmlSAX2ResolveEntity xmlSAX2ResolveEntity__internal_alias #endif #endif #ifdef bottom_SAX2 #undef xmlSAX2SetDocumentLocator extern __typeof (xmlSAX2SetDocumentLocator) xmlSAX2SetDocumentLocator __attribute((alias("xmlSAX2SetDocumentLocator__internal_alias"))); #else #ifndef xmlSAX2SetDocumentLocator extern __typeof (xmlSAX2SetDocumentLocator) xmlSAX2SetDocumentLocator__internal_alias __attribute((visibility("hidden"))); #define xmlSAX2SetDocumentLocator xmlSAX2SetDocumentLocator__internal_alias #endif #endif #ifdef bottom_SAX2 #undef xmlSAX2StartDocument extern __typeof (xmlSAX2StartDocument) xmlSAX2StartDocument __attribute((alias("xmlSAX2StartDocument__internal_alias"))); #else #ifndef xmlSAX2StartDocument extern __typeof (xmlSAX2StartDocument) xmlSAX2StartDocument__internal_alias __attribute((visibility("hidden"))); #define xmlSAX2StartDocument xmlSAX2StartDocument__internal_alias #endif #endif #if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED) #ifdef bottom_SAX2 #undef xmlSAX2StartElement extern __typeof (xmlSAX2StartElement) xmlSAX2StartElement __attribute((alias("xmlSAX2StartElement__internal_alias"))); #else #ifndef xmlSAX2StartElement extern __typeof (xmlSAX2StartElement) xmlSAX2StartElement__internal_alias __attribute((visibility("hidden"))); #define xmlSAX2StartElement xmlSAX2StartElement__internal_alias #endif #endif #endif #ifdef bottom_SAX2 #undef xmlSAX2StartElementNs extern __typeof (xmlSAX2StartElementNs) xmlSAX2StartElementNs __attribute((alias("xmlSAX2StartElementNs__internal_alias"))); #else #ifndef xmlSAX2StartElementNs extern __typeof (xmlSAX2StartElementNs) xmlSAX2StartElementNs__internal_alias __attribute((visibility("hidden"))); #define xmlSAX2StartElementNs xmlSAX2StartElementNs__internal_alias #endif #endif #ifdef bottom_SAX2 #undef xmlSAX2UnparsedEntityDecl extern __typeof (xmlSAX2UnparsedEntityDecl) xmlSAX2UnparsedEntityDecl __attribute((alias("xmlSAX2UnparsedEntityDecl__internal_alias"))); #else #ifndef xmlSAX2UnparsedEntityDecl extern __typeof (xmlSAX2UnparsedEntityDecl) xmlSAX2UnparsedEntityDecl__internal_alias __attribute((visibility("hidden"))); #define xmlSAX2UnparsedEntityDecl xmlSAX2UnparsedEntityDecl__internal_alias #endif #endif #if defined(LIBXML_SAX1_ENABLED) #ifdef bottom_SAX2 #undef xmlSAXDefaultVersion extern __typeof (xmlSAXDefaultVersion) xmlSAXDefaultVersion __attribute((alias("xmlSAXDefaultVersion__internal_alias"))); #else #ifndef xmlSAXDefaultVersion extern __typeof (xmlSAXDefaultVersion) xmlSAXDefaultVersion__internal_alias __attribute((visibility("hidden"))); #define xmlSAXDefaultVersion xmlSAXDefaultVersion__internal_alias #endif #endif #endif #if defined(LIBXML_VALID_ENABLED) #ifdef bottom_parser #undef xmlSAXParseDTD extern __typeof (xmlSAXParseDTD) xmlSAXParseDTD __attribute((alias("xmlSAXParseDTD__internal_alias"))); #else #ifndef xmlSAXParseDTD extern __typeof (xmlSAXParseDTD) xmlSAXParseDTD__internal_alias __attribute((visibility("hidden"))); #define xmlSAXParseDTD xmlSAXParseDTD__internal_alias #endif #endif #endif #if defined(LIBXML_SAX1_ENABLED) #ifdef bottom_parser #undef xmlSAXParseDoc extern __typeof (xmlSAXParseDoc) xmlSAXParseDoc __attribute((alias("xmlSAXParseDoc__internal_alias"))); #else #ifndef xmlSAXParseDoc extern __typeof (xmlSAXParseDoc) xmlSAXParseDoc__internal_alias __attribute((visibility("hidden"))); #define xmlSAXParseDoc xmlSAXParseDoc__internal_alias #endif #endif #endif #if defined(LIBXML_SAX1_ENABLED) #ifdef bottom_parser #undef xmlSAXParseEntity extern __typeof (xmlSAXParseEntity) xmlSAXParseEntity __attribute((alias("xmlSAXParseEntity__internal_alias"))); #else #ifndef xmlSAXParseEntity extern __typeof (xmlSAXParseEntity) xmlSAXParseEntity__internal_alias __attribute((visibility("hidden"))); #define xmlSAXParseEntity xmlSAXParseEntity__internal_alias #endif #endif #endif #if defined(LIBXML_SAX1_ENABLED) #ifdef bottom_parser #undef xmlSAXParseFile extern __typeof (xmlSAXParseFile) xmlSAXParseFile __attribute((alias("xmlSAXParseFile__internal_alias"))); #else #ifndef xmlSAXParseFile extern __typeof (xmlSAXParseFile) xmlSAXParseFile__internal_alias __attribute((visibility("hidden"))); #define xmlSAXParseFile xmlSAXParseFile__internal_alias #endif #endif #endif #if defined(LIBXML_SAX1_ENABLED) #ifdef bottom_parser #undef xmlSAXParseFileWithData extern __typeof (xmlSAXParseFileWithData) xmlSAXParseFileWithData __attribute((alias("xmlSAXParseFileWithData__internal_alias"))); #else #ifndef xmlSAXParseFileWithData extern __typeof (xmlSAXParseFileWithData) xmlSAXParseFileWithData__internal_alias __attribute((visibility("hidden"))); #define xmlSAXParseFileWithData xmlSAXParseFileWithData__internal_alias #endif #endif #endif #if defined(LIBXML_SAX1_ENABLED) #ifdef bottom_parser #undef xmlSAXParseMemory extern __typeof (xmlSAXParseMemory) xmlSAXParseMemory __attribute((alias("xmlSAXParseMemory__internal_alias"))); #else #ifndef xmlSAXParseMemory extern __typeof (xmlSAXParseMemory) xmlSAXParseMemory__internal_alias __attribute((visibility("hidden"))); #define xmlSAXParseMemory xmlSAXParseMemory__internal_alias #endif #endif #endif #if defined(LIBXML_SAX1_ENABLED) #ifdef bottom_parser #undef xmlSAXParseMemoryWithData extern __typeof (xmlSAXParseMemoryWithData) xmlSAXParseMemoryWithData __attribute((alias("xmlSAXParseMemoryWithData__internal_alias"))); #else #ifndef xmlSAXParseMemoryWithData extern __typeof (xmlSAXParseMemoryWithData) xmlSAXParseMemoryWithData__internal_alias __attribute((visibility("hidden"))); #define xmlSAXParseMemoryWithData xmlSAXParseMemoryWithData__internal_alias #endif #endif #endif #if defined(LIBXML_SAX1_ENABLED) #ifdef bottom_parser #undef xmlSAXUserParseFile extern __typeof (xmlSAXUserParseFile) xmlSAXUserParseFile __attribute((alias("xmlSAXUserParseFile__internal_alias"))); #else #ifndef xmlSAXUserParseFile extern __typeof (xmlSAXUserParseFile) xmlSAXUserParseFile__internal_alias __attribute((visibility("hidden"))); #define xmlSAXUserParseFile xmlSAXUserParseFile__internal_alias #endif #endif #endif #if defined(LIBXML_SAX1_ENABLED) #ifdef bottom_parser #undef xmlSAXUserParseMemory extern __typeof (xmlSAXUserParseMemory) xmlSAXUserParseMemory __attribute((alias("xmlSAXUserParseMemory__internal_alias"))); #else #ifndef xmlSAXUserParseMemory extern __typeof (xmlSAXUserParseMemory) xmlSAXUserParseMemory__internal_alias __attribute((visibility("hidden"))); #define xmlSAXUserParseMemory xmlSAXUserParseMemory__internal_alias #endif #endif #endif #ifdef bottom_SAX2 #undef xmlSAXVersion extern __typeof (xmlSAXVersion) xmlSAXVersion __attribute((alias("xmlSAXVersion__internal_alias"))); #else #ifndef xmlSAXVersion extern __typeof (xmlSAXVersion) xmlSAXVersion__internal_alias __attribute((visibility("hidden"))); #define xmlSAXVersion xmlSAXVersion__internal_alias #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_xmlsave #undef xmlSaveClose extern __typeof (xmlSaveClose) xmlSaveClose __attribute((alias("xmlSaveClose__internal_alias"))); #else #ifndef xmlSaveClose extern __typeof (xmlSaveClose) xmlSaveClose__internal_alias __attribute((visibility("hidden"))); #define xmlSaveClose xmlSaveClose__internal_alias #endif #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_xmlsave #undef xmlSaveDoc extern __typeof (xmlSaveDoc) xmlSaveDoc __attribute((alias("xmlSaveDoc__internal_alias"))); #else #ifndef xmlSaveDoc extern __typeof (xmlSaveDoc) xmlSaveDoc__internal_alias __attribute((visibility("hidden"))); #define xmlSaveDoc xmlSaveDoc__internal_alias #endif #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_xmlsave #undef xmlSaveFile extern __typeof (xmlSaveFile) xmlSaveFile __attribute((alias("xmlSaveFile__internal_alias"))); #else #ifndef xmlSaveFile extern __typeof (xmlSaveFile) xmlSaveFile__internal_alias __attribute((visibility("hidden"))); #define xmlSaveFile xmlSaveFile__internal_alias #endif #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_xmlsave #undef xmlSaveFileEnc extern __typeof (xmlSaveFileEnc) xmlSaveFileEnc __attribute((alias("xmlSaveFileEnc__internal_alias"))); #else #ifndef xmlSaveFileEnc extern __typeof (xmlSaveFileEnc) xmlSaveFileEnc__internal_alias __attribute((visibility("hidden"))); #define xmlSaveFileEnc xmlSaveFileEnc__internal_alias #endif #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_xmlsave #undef xmlSaveFileTo extern __typeof (xmlSaveFileTo) xmlSaveFileTo __attribute((alias("xmlSaveFileTo__internal_alias"))); #else #ifndef xmlSaveFileTo extern __typeof (xmlSaveFileTo) xmlSaveFileTo__internal_alias __attribute((visibility("hidden"))); #define xmlSaveFileTo xmlSaveFileTo__internal_alias #endif #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_xmlsave #undef xmlSaveFlush extern __typeof (xmlSaveFlush) xmlSaveFlush __attribute((alias("xmlSaveFlush__internal_alias"))); #else #ifndef xmlSaveFlush extern __typeof (xmlSaveFlush) xmlSaveFlush__internal_alias __attribute((visibility("hidden"))); #define xmlSaveFlush xmlSaveFlush__internal_alias #endif #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_xmlsave #undef xmlSaveFormatFile extern __typeof (xmlSaveFormatFile) xmlSaveFormatFile __attribute((alias("xmlSaveFormatFile__internal_alias"))); #else #ifndef xmlSaveFormatFile extern __typeof (xmlSaveFormatFile) xmlSaveFormatFile__internal_alias __attribute((visibility("hidden"))); #define xmlSaveFormatFile xmlSaveFormatFile__internal_alias #endif #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_xmlsave #undef xmlSaveFormatFileEnc extern __typeof (xmlSaveFormatFileEnc) xmlSaveFormatFileEnc __attribute((alias("xmlSaveFormatFileEnc__internal_alias"))); #else #ifndef xmlSaveFormatFileEnc extern __typeof (xmlSaveFormatFileEnc) xmlSaveFormatFileEnc__internal_alias __attribute((visibility("hidden"))); #define xmlSaveFormatFileEnc xmlSaveFormatFileEnc__internal_alias #endif #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_xmlsave #undef xmlSaveFormatFileTo extern __typeof (xmlSaveFormatFileTo) xmlSaveFormatFileTo __attribute((alias("xmlSaveFormatFileTo__internal_alias"))); #else #ifndef xmlSaveFormatFileTo extern __typeof (xmlSaveFormatFileTo) xmlSaveFormatFileTo__internal_alias __attribute((visibility("hidden"))); #define xmlSaveFormatFileTo xmlSaveFormatFileTo__internal_alias #endif #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_xmlsave #undef xmlSaveSetAttrEscape extern __typeof (xmlSaveSetAttrEscape) xmlSaveSetAttrEscape __attribute((alias("xmlSaveSetAttrEscape__internal_alias"))); #else #ifndef xmlSaveSetAttrEscape extern __typeof (xmlSaveSetAttrEscape) xmlSaveSetAttrEscape__internal_alias __attribute((visibility("hidden"))); #define xmlSaveSetAttrEscape xmlSaveSetAttrEscape__internal_alias #endif #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_xmlsave #undef xmlSaveSetEscape extern __typeof (xmlSaveSetEscape) xmlSaveSetEscape __attribute((alias("xmlSaveSetEscape__internal_alias"))); #else #ifndef xmlSaveSetEscape extern __typeof (xmlSaveSetEscape) xmlSaveSetEscape__internal_alias __attribute((visibility("hidden"))); #define xmlSaveSetEscape xmlSaveSetEscape__internal_alias #endif #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_xmlsave #undef xmlSaveToBuffer extern __typeof (xmlSaveToBuffer) xmlSaveToBuffer __attribute((alias("xmlSaveToBuffer__internal_alias"))); #else #ifndef xmlSaveToBuffer extern __typeof (xmlSaveToBuffer) xmlSaveToBuffer__internal_alias __attribute((visibility("hidden"))); #define xmlSaveToBuffer xmlSaveToBuffer__internal_alias #endif #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_xmlsave #undef xmlSaveToFd extern __typeof (xmlSaveToFd) xmlSaveToFd __attribute((alias("xmlSaveToFd__internal_alias"))); #else #ifndef xmlSaveToFd extern __typeof (xmlSaveToFd) xmlSaveToFd__internal_alias __attribute((visibility("hidden"))); #define xmlSaveToFd xmlSaveToFd__internal_alias #endif #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_xmlsave #undef xmlSaveToFilename extern __typeof (xmlSaveToFilename) xmlSaveToFilename __attribute((alias("xmlSaveToFilename__internal_alias"))); #else #ifndef xmlSaveToFilename extern __typeof (xmlSaveToFilename) xmlSaveToFilename__internal_alias __attribute((visibility("hidden"))); #define xmlSaveToFilename xmlSaveToFilename__internal_alias #endif #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_xmlsave #undef xmlSaveToIO extern __typeof (xmlSaveToIO) xmlSaveToIO __attribute((alias("xmlSaveToIO__internal_alias"))); #else #ifndef xmlSaveToIO extern __typeof (xmlSaveToIO) xmlSaveToIO__internal_alias __attribute((visibility("hidden"))); #define xmlSaveToIO xmlSaveToIO__internal_alias #endif #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_xmlsave #undef xmlSaveTree extern __typeof (xmlSaveTree) xmlSaveTree __attribute((alias("xmlSaveTree__internal_alias"))); #else #ifndef xmlSaveTree extern __typeof (xmlSaveTree) xmlSaveTree__internal_alias __attribute((visibility("hidden"))); #define xmlSaveTree xmlSaveTree__internal_alias #endif #endif #endif #ifdef bottom_uri #undef xmlSaveUri extern __typeof (xmlSaveUri) xmlSaveUri __attribute((alias("xmlSaveUri__internal_alias"))); #else #ifndef xmlSaveUri extern __typeof (xmlSaveUri) xmlSaveUri__internal_alias __attribute((visibility("hidden"))); #define xmlSaveUri xmlSaveUri__internal_alias #endif #endif #if defined(LIBXML_LEGACY_ENABLED) #ifdef bottom_legacy #undef xmlScanName extern __typeof (xmlScanName) xmlScanName __attribute((alias("xmlScanName__internal_alias"))); #else #ifndef xmlScanName extern __typeof (xmlScanName) xmlScanName__internal_alias __attribute((visibility("hidden"))); #define xmlScanName xmlScanName__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemas #undef xmlSchemaCheckFacet extern __typeof (xmlSchemaCheckFacet) xmlSchemaCheckFacet __attribute((alias("xmlSchemaCheckFacet__internal_alias"))); #else #ifndef xmlSchemaCheckFacet extern __typeof (xmlSchemaCheckFacet) xmlSchemaCheckFacet__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaCheckFacet xmlSchemaCheckFacet__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemastypes #undef xmlSchemaCleanupTypes extern __typeof (xmlSchemaCleanupTypes) xmlSchemaCleanupTypes __attribute((alias("xmlSchemaCleanupTypes__internal_alias"))); #else #ifndef xmlSchemaCleanupTypes extern __typeof (xmlSchemaCleanupTypes) xmlSchemaCleanupTypes__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaCleanupTypes xmlSchemaCleanupTypes__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemastypes #undef xmlSchemaCollapseString extern __typeof (xmlSchemaCollapseString) xmlSchemaCollapseString __attribute((alias("xmlSchemaCollapseString__internal_alias"))); #else #ifndef xmlSchemaCollapseString extern __typeof (xmlSchemaCollapseString) xmlSchemaCollapseString__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaCollapseString xmlSchemaCollapseString__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemastypes #undef xmlSchemaCompareValues extern __typeof (xmlSchemaCompareValues) xmlSchemaCompareValues __attribute((alias("xmlSchemaCompareValues__internal_alias"))); #else #ifndef xmlSchemaCompareValues extern __typeof (xmlSchemaCompareValues) xmlSchemaCompareValues__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaCompareValues xmlSchemaCompareValues__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemastypes #undef xmlSchemaCompareValuesWhtsp extern __typeof (xmlSchemaCompareValuesWhtsp) xmlSchemaCompareValuesWhtsp __attribute((alias("xmlSchemaCompareValuesWhtsp__internal_alias"))); #else #ifndef xmlSchemaCompareValuesWhtsp extern __typeof (xmlSchemaCompareValuesWhtsp) xmlSchemaCompareValuesWhtsp__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaCompareValuesWhtsp xmlSchemaCompareValuesWhtsp__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemastypes #undef xmlSchemaCopyValue extern __typeof (xmlSchemaCopyValue) xmlSchemaCopyValue __attribute((alias("xmlSchemaCopyValue__internal_alias"))); #else #ifndef xmlSchemaCopyValue extern __typeof (xmlSchemaCopyValue) xmlSchemaCopyValue__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaCopyValue xmlSchemaCopyValue__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_xmlschemas #undef xmlSchemaDump extern __typeof (xmlSchemaDump) xmlSchemaDump __attribute((alias("xmlSchemaDump__internal_alias"))); #else #ifndef xmlSchemaDump extern __typeof (xmlSchemaDump) xmlSchemaDump__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaDump xmlSchemaDump__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemas #undef xmlSchemaFree extern __typeof (xmlSchemaFree) xmlSchemaFree __attribute((alias("xmlSchemaFree__internal_alias"))); #else #ifndef xmlSchemaFree extern __typeof (xmlSchemaFree) xmlSchemaFree__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaFree xmlSchemaFree__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemas #undef xmlSchemaFreeFacet extern __typeof (xmlSchemaFreeFacet) xmlSchemaFreeFacet __attribute((alias("xmlSchemaFreeFacet__internal_alias"))); #else #ifndef xmlSchemaFreeFacet extern __typeof (xmlSchemaFreeFacet) xmlSchemaFreeFacet__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaFreeFacet xmlSchemaFreeFacet__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemas #undef xmlSchemaFreeParserCtxt extern __typeof (xmlSchemaFreeParserCtxt) xmlSchemaFreeParserCtxt __attribute((alias("xmlSchemaFreeParserCtxt__internal_alias"))); #else #ifndef xmlSchemaFreeParserCtxt extern __typeof (xmlSchemaFreeParserCtxt) xmlSchemaFreeParserCtxt__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaFreeParserCtxt xmlSchemaFreeParserCtxt__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemas #undef xmlSchemaFreeType extern __typeof (xmlSchemaFreeType) xmlSchemaFreeType __attribute((alias("xmlSchemaFreeType__internal_alias"))); #else #ifndef xmlSchemaFreeType extern __typeof (xmlSchemaFreeType) xmlSchemaFreeType__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaFreeType xmlSchemaFreeType__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemas #undef xmlSchemaFreeValidCtxt extern __typeof (xmlSchemaFreeValidCtxt) xmlSchemaFreeValidCtxt __attribute((alias("xmlSchemaFreeValidCtxt__internal_alias"))); #else #ifndef xmlSchemaFreeValidCtxt extern __typeof (xmlSchemaFreeValidCtxt) xmlSchemaFreeValidCtxt__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaFreeValidCtxt xmlSchemaFreeValidCtxt__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemastypes #undef xmlSchemaFreeValue extern __typeof (xmlSchemaFreeValue) xmlSchemaFreeValue __attribute((alias("xmlSchemaFreeValue__internal_alias"))); #else #ifndef xmlSchemaFreeValue extern __typeof (xmlSchemaFreeValue) xmlSchemaFreeValue__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaFreeValue xmlSchemaFreeValue__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemas #undef xmlSchemaFreeWildcard extern __typeof (xmlSchemaFreeWildcard) xmlSchemaFreeWildcard __attribute((alias("xmlSchemaFreeWildcard__internal_alias"))); #else #ifndef xmlSchemaFreeWildcard extern __typeof (xmlSchemaFreeWildcard) xmlSchemaFreeWildcard__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaFreeWildcard xmlSchemaFreeWildcard__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemastypes #undef xmlSchemaGetBuiltInListSimpleTypeItemType extern __typeof (xmlSchemaGetBuiltInListSimpleTypeItemType) xmlSchemaGetBuiltInListSimpleTypeItemType __attribute((alias("xmlSchemaGetBuiltInListSimpleTypeItemType__internal_alias"))); #else #ifndef xmlSchemaGetBuiltInListSimpleTypeItemType extern __typeof (xmlSchemaGetBuiltInListSimpleTypeItemType) xmlSchemaGetBuiltInListSimpleTypeItemType__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaGetBuiltInListSimpleTypeItemType xmlSchemaGetBuiltInListSimpleTypeItemType__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemastypes #undef xmlSchemaGetBuiltInType extern __typeof (xmlSchemaGetBuiltInType) xmlSchemaGetBuiltInType __attribute((alias("xmlSchemaGetBuiltInType__internal_alias"))); #else #ifndef xmlSchemaGetBuiltInType extern __typeof (xmlSchemaGetBuiltInType) xmlSchemaGetBuiltInType__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaGetBuiltInType xmlSchemaGetBuiltInType__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemastypes #undef xmlSchemaGetCanonValue extern __typeof (xmlSchemaGetCanonValue) xmlSchemaGetCanonValue __attribute((alias("xmlSchemaGetCanonValue__internal_alias"))); #else #ifndef xmlSchemaGetCanonValue extern __typeof (xmlSchemaGetCanonValue) xmlSchemaGetCanonValue__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaGetCanonValue xmlSchemaGetCanonValue__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemastypes #undef xmlSchemaGetCanonValueWhtsp extern __typeof (xmlSchemaGetCanonValueWhtsp) xmlSchemaGetCanonValueWhtsp __attribute((alias("xmlSchemaGetCanonValueWhtsp__internal_alias"))); #else #ifndef xmlSchemaGetCanonValueWhtsp extern __typeof (xmlSchemaGetCanonValueWhtsp) xmlSchemaGetCanonValueWhtsp__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaGetCanonValueWhtsp xmlSchemaGetCanonValueWhtsp__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemastypes #undef xmlSchemaGetFacetValueAsULong extern __typeof (xmlSchemaGetFacetValueAsULong) xmlSchemaGetFacetValueAsULong __attribute((alias("xmlSchemaGetFacetValueAsULong__internal_alias"))); #else #ifndef xmlSchemaGetFacetValueAsULong extern __typeof (xmlSchemaGetFacetValueAsULong) xmlSchemaGetFacetValueAsULong__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaGetFacetValueAsULong xmlSchemaGetFacetValueAsULong__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemas #undef xmlSchemaGetParserErrors extern __typeof (xmlSchemaGetParserErrors) xmlSchemaGetParserErrors __attribute((alias("xmlSchemaGetParserErrors__internal_alias"))); #else #ifndef xmlSchemaGetParserErrors extern __typeof (xmlSchemaGetParserErrors) xmlSchemaGetParserErrors__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaGetParserErrors xmlSchemaGetParserErrors__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemastypes #undef xmlSchemaGetPredefinedType extern __typeof (xmlSchemaGetPredefinedType) xmlSchemaGetPredefinedType __attribute((alias("xmlSchemaGetPredefinedType__internal_alias"))); #else #ifndef xmlSchemaGetPredefinedType extern __typeof (xmlSchemaGetPredefinedType) xmlSchemaGetPredefinedType__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaGetPredefinedType xmlSchemaGetPredefinedType__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemastypes #undef xmlSchemaGetValType extern __typeof (xmlSchemaGetValType) xmlSchemaGetValType __attribute((alias("xmlSchemaGetValType__internal_alias"))); #else #ifndef xmlSchemaGetValType extern __typeof (xmlSchemaGetValType) xmlSchemaGetValType__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaGetValType xmlSchemaGetValType__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemas #undef xmlSchemaGetValidErrors extern __typeof (xmlSchemaGetValidErrors) xmlSchemaGetValidErrors __attribute((alias("xmlSchemaGetValidErrors__internal_alias"))); #else #ifndef xmlSchemaGetValidErrors extern __typeof (xmlSchemaGetValidErrors) xmlSchemaGetValidErrors__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaGetValidErrors xmlSchemaGetValidErrors__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemastypes #undef xmlSchemaInitTypes extern __typeof (xmlSchemaInitTypes) xmlSchemaInitTypes __attribute((alias("xmlSchemaInitTypes__internal_alias"))); #else #ifndef xmlSchemaInitTypes extern __typeof (xmlSchemaInitTypes) xmlSchemaInitTypes__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaInitTypes xmlSchemaInitTypes__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemastypes #undef xmlSchemaIsBuiltInTypeFacet extern __typeof (xmlSchemaIsBuiltInTypeFacet) xmlSchemaIsBuiltInTypeFacet __attribute((alias("xmlSchemaIsBuiltInTypeFacet__internal_alias"))); #else #ifndef xmlSchemaIsBuiltInTypeFacet extern __typeof (xmlSchemaIsBuiltInTypeFacet) xmlSchemaIsBuiltInTypeFacet__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaIsBuiltInTypeFacet xmlSchemaIsBuiltInTypeFacet__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemas #undef xmlSchemaIsValid extern __typeof (xmlSchemaIsValid) xmlSchemaIsValid __attribute((alias("xmlSchemaIsValid__internal_alias"))); #else #ifndef xmlSchemaIsValid extern __typeof (xmlSchemaIsValid) xmlSchemaIsValid__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaIsValid xmlSchemaIsValid__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemas #undef xmlSchemaNewDocParserCtxt extern __typeof (xmlSchemaNewDocParserCtxt) xmlSchemaNewDocParserCtxt __attribute((alias("xmlSchemaNewDocParserCtxt__internal_alias"))); #else #ifndef xmlSchemaNewDocParserCtxt extern __typeof (xmlSchemaNewDocParserCtxt) xmlSchemaNewDocParserCtxt__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaNewDocParserCtxt xmlSchemaNewDocParserCtxt__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemas #undef xmlSchemaNewFacet extern __typeof (xmlSchemaNewFacet) xmlSchemaNewFacet __attribute((alias("xmlSchemaNewFacet__internal_alias"))); #else #ifndef xmlSchemaNewFacet extern __typeof (xmlSchemaNewFacet) xmlSchemaNewFacet__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaNewFacet xmlSchemaNewFacet__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemas #undef xmlSchemaNewMemParserCtxt extern __typeof (xmlSchemaNewMemParserCtxt) xmlSchemaNewMemParserCtxt __attribute((alias("xmlSchemaNewMemParserCtxt__internal_alias"))); #else #ifndef xmlSchemaNewMemParserCtxt extern __typeof (xmlSchemaNewMemParserCtxt) xmlSchemaNewMemParserCtxt__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaNewMemParserCtxt xmlSchemaNewMemParserCtxt__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemastypes #undef xmlSchemaNewNOTATIONValue extern __typeof (xmlSchemaNewNOTATIONValue) xmlSchemaNewNOTATIONValue __attribute((alias("xmlSchemaNewNOTATIONValue__internal_alias"))); #else #ifndef xmlSchemaNewNOTATIONValue extern __typeof (xmlSchemaNewNOTATIONValue) xmlSchemaNewNOTATIONValue__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaNewNOTATIONValue xmlSchemaNewNOTATIONValue__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemas #undef xmlSchemaNewParserCtxt extern __typeof (xmlSchemaNewParserCtxt) xmlSchemaNewParserCtxt __attribute((alias("xmlSchemaNewParserCtxt__internal_alias"))); #else #ifndef xmlSchemaNewParserCtxt extern __typeof (xmlSchemaNewParserCtxt) xmlSchemaNewParserCtxt__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaNewParserCtxt xmlSchemaNewParserCtxt__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemastypes #undef xmlSchemaNewQNameValue extern __typeof (xmlSchemaNewQNameValue) xmlSchemaNewQNameValue __attribute((alias("xmlSchemaNewQNameValue__internal_alias"))); #else #ifndef xmlSchemaNewQNameValue extern __typeof (xmlSchemaNewQNameValue) xmlSchemaNewQNameValue__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaNewQNameValue xmlSchemaNewQNameValue__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemastypes #undef xmlSchemaNewStringValue extern __typeof (xmlSchemaNewStringValue) xmlSchemaNewStringValue __attribute((alias("xmlSchemaNewStringValue__internal_alias"))); #else #ifndef xmlSchemaNewStringValue extern __typeof (xmlSchemaNewStringValue) xmlSchemaNewStringValue__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaNewStringValue xmlSchemaNewStringValue__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemas #undef xmlSchemaNewValidCtxt extern __typeof (xmlSchemaNewValidCtxt) xmlSchemaNewValidCtxt __attribute((alias("xmlSchemaNewValidCtxt__internal_alias"))); #else #ifndef xmlSchemaNewValidCtxt extern __typeof (xmlSchemaNewValidCtxt) xmlSchemaNewValidCtxt__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaNewValidCtxt xmlSchemaNewValidCtxt__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemas #undef xmlSchemaParse extern __typeof (xmlSchemaParse) xmlSchemaParse __attribute((alias("xmlSchemaParse__internal_alias"))); #else #ifndef xmlSchemaParse extern __typeof (xmlSchemaParse) xmlSchemaParse__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaParse xmlSchemaParse__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemas #undef xmlSchemaSAXPlug extern __typeof (xmlSchemaSAXPlug) xmlSchemaSAXPlug __attribute((alias("xmlSchemaSAXPlug__internal_alias"))); #else #ifndef xmlSchemaSAXPlug extern __typeof (xmlSchemaSAXPlug) xmlSchemaSAXPlug__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaSAXPlug xmlSchemaSAXPlug__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemas #undef xmlSchemaSAXUnplug extern __typeof (xmlSchemaSAXUnplug) xmlSchemaSAXUnplug __attribute((alias("xmlSchemaSAXUnplug__internal_alias"))); #else #ifndef xmlSchemaSAXUnplug extern __typeof (xmlSchemaSAXUnplug) xmlSchemaSAXUnplug__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaSAXUnplug xmlSchemaSAXUnplug__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemas #undef xmlSchemaSetParserErrors extern __typeof (xmlSchemaSetParserErrors) xmlSchemaSetParserErrors __attribute((alias("xmlSchemaSetParserErrors__internal_alias"))); #else #ifndef xmlSchemaSetParserErrors extern __typeof (xmlSchemaSetParserErrors) xmlSchemaSetParserErrors__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaSetParserErrors xmlSchemaSetParserErrors__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemas #undef xmlSchemaSetParserStructuredErrors extern __typeof (xmlSchemaSetParserStructuredErrors) xmlSchemaSetParserStructuredErrors __attribute((alias("xmlSchemaSetParserStructuredErrors__internal_alias"))); #else #ifndef xmlSchemaSetParserStructuredErrors extern __typeof (xmlSchemaSetParserStructuredErrors) xmlSchemaSetParserStructuredErrors__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaSetParserStructuredErrors xmlSchemaSetParserStructuredErrors__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemas #undef xmlSchemaSetValidErrors extern __typeof (xmlSchemaSetValidErrors) xmlSchemaSetValidErrors __attribute((alias("xmlSchemaSetValidErrors__internal_alias"))); #else #ifndef xmlSchemaSetValidErrors extern __typeof (xmlSchemaSetValidErrors) xmlSchemaSetValidErrors__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaSetValidErrors xmlSchemaSetValidErrors__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemas #undef xmlSchemaSetValidOptions extern __typeof (xmlSchemaSetValidOptions) xmlSchemaSetValidOptions __attribute((alias("xmlSchemaSetValidOptions__internal_alias"))); #else #ifndef xmlSchemaSetValidOptions extern __typeof (xmlSchemaSetValidOptions) xmlSchemaSetValidOptions__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaSetValidOptions xmlSchemaSetValidOptions__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemas #undef xmlSchemaSetValidStructuredErrors extern __typeof (xmlSchemaSetValidStructuredErrors) xmlSchemaSetValidStructuredErrors __attribute((alias("xmlSchemaSetValidStructuredErrors__internal_alias"))); #else #ifndef xmlSchemaSetValidStructuredErrors extern __typeof (xmlSchemaSetValidStructuredErrors) xmlSchemaSetValidStructuredErrors__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaSetValidStructuredErrors xmlSchemaSetValidStructuredErrors__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemastypes #undef xmlSchemaValPredefTypeNode extern __typeof (xmlSchemaValPredefTypeNode) xmlSchemaValPredefTypeNode __attribute((alias("xmlSchemaValPredefTypeNode__internal_alias"))); #else #ifndef xmlSchemaValPredefTypeNode extern __typeof (xmlSchemaValPredefTypeNode) xmlSchemaValPredefTypeNode__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaValPredefTypeNode xmlSchemaValPredefTypeNode__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemastypes #undef xmlSchemaValPredefTypeNodeNoNorm extern __typeof (xmlSchemaValPredefTypeNodeNoNorm) xmlSchemaValPredefTypeNodeNoNorm __attribute((alias("xmlSchemaValPredefTypeNodeNoNorm__internal_alias"))); #else #ifndef xmlSchemaValPredefTypeNodeNoNorm extern __typeof (xmlSchemaValPredefTypeNodeNoNorm) xmlSchemaValPredefTypeNodeNoNorm__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaValPredefTypeNodeNoNorm xmlSchemaValPredefTypeNodeNoNorm__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemas #undef xmlSchemaValidCtxtGetOptions extern __typeof (xmlSchemaValidCtxtGetOptions) xmlSchemaValidCtxtGetOptions __attribute((alias("xmlSchemaValidCtxtGetOptions__internal_alias"))); #else #ifndef xmlSchemaValidCtxtGetOptions extern __typeof (xmlSchemaValidCtxtGetOptions) xmlSchemaValidCtxtGetOptions__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaValidCtxtGetOptions xmlSchemaValidCtxtGetOptions__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemas #undef xmlSchemaValidateDoc extern __typeof (xmlSchemaValidateDoc) xmlSchemaValidateDoc __attribute((alias("xmlSchemaValidateDoc__internal_alias"))); #else #ifndef xmlSchemaValidateDoc extern __typeof (xmlSchemaValidateDoc) xmlSchemaValidateDoc__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaValidateDoc xmlSchemaValidateDoc__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemastypes #undef xmlSchemaValidateFacet extern __typeof (xmlSchemaValidateFacet) xmlSchemaValidateFacet __attribute((alias("xmlSchemaValidateFacet__internal_alias"))); #else #ifndef xmlSchemaValidateFacet extern __typeof (xmlSchemaValidateFacet) xmlSchemaValidateFacet__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaValidateFacet xmlSchemaValidateFacet__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemastypes #undef xmlSchemaValidateFacetWhtsp extern __typeof (xmlSchemaValidateFacetWhtsp) xmlSchemaValidateFacetWhtsp __attribute((alias("xmlSchemaValidateFacetWhtsp__internal_alias"))); #else #ifndef xmlSchemaValidateFacetWhtsp extern __typeof (xmlSchemaValidateFacetWhtsp) xmlSchemaValidateFacetWhtsp__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaValidateFacetWhtsp xmlSchemaValidateFacetWhtsp__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemas #undef xmlSchemaValidateFile extern __typeof (xmlSchemaValidateFile) xmlSchemaValidateFile __attribute((alias("xmlSchemaValidateFile__internal_alias"))); #else #ifndef xmlSchemaValidateFile extern __typeof (xmlSchemaValidateFile) xmlSchemaValidateFile__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaValidateFile xmlSchemaValidateFile__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemastypes #undef xmlSchemaValidateLengthFacet extern __typeof (xmlSchemaValidateLengthFacet) xmlSchemaValidateLengthFacet __attribute((alias("xmlSchemaValidateLengthFacet__internal_alias"))); #else #ifndef xmlSchemaValidateLengthFacet extern __typeof (xmlSchemaValidateLengthFacet) xmlSchemaValidateLengthFacet__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaValidateLengthFacet xmlSchemaValidateLengthFacet__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemastypes #undef xmlSchemaValidateLengthFacetWhtsp extern __typeof (xmlSchemaValidateLengthFacetWhtsp) xmlSchemaValidateLengthFacetWhtsp __attribute((alias("xmlSchemaValidateLengthFacetWhtsp__internal_alias"))); #else #ifndef xmlSchemaValidateLengthFacetWhtsp extern __typeof (xmlSchemaValidateLengthFacetWhtsp) xmlSchemaValidateLengthFacetWhtsp__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaValidateLengthFacetWhtsp xmlSchemaValidateLengthFacetWhtsp__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemastypes #undef xmlSchemaValidateListSimpleTypeFacet extern __typeof (xmlSchemaValidateListSimpleTypeFacet) xmlSchemaValidateListSimpleTypeFacet __attribute((alias("xmlSchemaValidateListSimpleTypeFacet__internal_alias"))); #else #ifndef xmlSchemaValidateListSimpleTypeFacet extern __typeof (xmlSchemaValidateListSimpleTypeFacet) xmlSchemaValidateListSimpleTypeFacet__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaValidateListSimpleTypeFacet xmlSchemaValidateListSimpleTypeFacet__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemas #undef xmlSchemaValidateOneElement extern __typeof (xmlSchemaValidateOneElement) xmlSchemaValidateOneElement __attribute((alias("xmlSchemaValidateOneElement__internal_alias"))); #else #ifndef xmlSchemaValidateOneElement extern __typeof (xmlSchemaValidateOneElement) xmlSchemaValidateOneElement__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaValidateOneElement xmlSchemaValidateOneElement__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemastypes #undef xmlSchemaValidatePredefinedType extern __typeof (xmlSchemaValidatePredefinedType) xmlSchemaValidatePredefinedType __attribute((alias("xmlSchemaValidatePredefinedType__internal_alias"))); #else #ifndef xmlSchemaValidatePredefinedType extern __typeof (xmlSchemaValidatePredefinedType) xmlSchemaValidatePredefinedType__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaValidatePredefinedType xmlSchemaValidatePredefinedType__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemas #undef xmlSchemaValidateStream extern __typeof (xmlSchemaValidateStream) xmlSchemaValidateStream __attribute((alias("xmlSchemaValidateStream__internal_alias"))); #else #ifndef xmlSchemaValidateStream extern __typeof (xmlSchemaValidateStream) xmlSchemaValidateStream__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaValidateStream xmlSchemaValidateStream__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemastypes #undef xmlSchemaValueAppend extern __typeof (xmlSchemaValueAppend) xmlSchemaValueAppend __attribute((alias("xmlSchemaValueAppend__internal_alias"))); #else #ifndef xmlSchemaValueAppend extern __typeof (xmlSchemaValueAppend) xmlSchemaValueAppend__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaValueAppend xmlSchemaValueAppend__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemastypes #undef xmlSchemaValueGetAsBoolean extern __typeof (xmlSchemaValueGetAsBoolean) xmlSchemaValueGetAsBoolean __attribute((alias("xmlSchemaValueGetAsBoolean__internal_alias"))); #else #ifndef xmlSchemaValueGetAsBoolean extern __typeof (xmlSchemaValueGetAsBoolean) xmlSchemaValueGetAsBoolean__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaValueGetAsBoolean xmlSchemaValueGetAsBoolean__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemastypes #undef xmlSchemaValueGetAsString extern __typeof (xmlSchemaValueGetAsString) xmlSchemaValueGetAsString __attribute((alias("xmlSchemaValueGetAsString__internal_alias"))); #else #ifndef xmlSchemaValueGetAsString extern __typeof (xmlSchemaValueGetAsString) xmlSchemaValueGetAsString__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaValueGetAsString xmlSchemaValueGetAsString__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemastypes #undef xmlSchemaValueGetNext extern __typeof (xmlSchemaValueGetNext) xmlSchemaValueGetNext __attribute((alias("xmlSchemaValueGetNext__internal_alias"))); #else #ifndef xmlSchemaValueGetNext extern __typeof (xmlSchemaValueGetNext) xmlSchemaValueGetNext__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaValueGetNext xmlSchemaValueGetNext__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlschemastypes #undef xmlSchemaWhiteSpaceReplace extern __typeof (xmlSchemaWhiteSpaceReplace) xmlSchemaWhiteSpaceReplace __attribute((alias("xmlSchemaWhiteSpaceReplace__internal_alias"))); #else #ifndef xmlSchemaWhiteSpaceReplace extern __typeof (xmlSchemaWhiteSpaceReplace) xmlSchemaWhiteSpaceReplace__internal_alias __attribute((visibility("hidden"))); #define xmlSchemaWhiteSpaceReplace xmlSchemaWhiteSpaceReplace__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMATRON_ENABLED) #ifdef bottom_schematron #undef xmlSchematronFree extern __typeof (xmlSchematronFree) xmlSchematronFree __attribute((alias("xmlSchematronFree__internal_alias"))); #else #ifndef xmlSchematronFree extern __typeof (xmlSchematronFree) xmlSchematronFree__internal_alias __attribute((visibility("hidden"))); #define xmlSchematronFree xmlSchematronFree__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMATRON_ENABLED) #ifdef bottom_schematron #undef xmlSchematronFreeParserCtxt extern __typeof (xmlSchematronFreeParserCtxt) xmlSchematronFreeParserCtxt __attribute((alias("xmlSchematronFreeParserCtxt__internal_alias"))); #else #ifndef xmlSchematronFreeParserCtxt extern __typeof (xmlSchematronFreeParserCtxt) xmlSchematronFreeParserCtxt__internal_alias __attribute((visibility("hidden"))); #define xmlSchematronFreeParserCtxt xmlSchematronFreeParserCtxt__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMATRON_ENABLED) #ifdef bottom_schematron #undef xmlSchematronFreeValidCtxt extern __typeof (xmlSchematronFreeValidCtxt) xmlSchematronFreeValidCtxt __attribute((alias("xmlSchematronFreeValidCtxt__internal_alias"))); #else #ifndef xmlSchematronFreeValidCtxt extern __typeof (xmlSchematronFreeValidCtxt) xmlSchematronFreeValidCtxt__internal_alias __attribute((visibility("hidden"))); #define xmlSchematronFreeValidCtxt xmlSchematronFreeValidCtxt__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMATRON_ENABLED) #ifdef bottom_schematron #undef xmlSchematronNewDocParserCtxt extern __typeof (xmlSchematronNewDocParserCtxt) xmlSchematronNewDocParserCtxt __attribute((alias("xmlSchematronNewDocParserCtxt__internal_alias"))); #else #ifndef xmlSchematronNewDocParserCtxt extern __typeof (xmlSchematronNewDocParserCtxt) xmlSchematronNewDocParserCtxt__internal_alias __attribute((visibility("hidden"))); #define xmlSchematronNewDocParserCtxt xmlSchematronNewDocParserCtxt__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMATRON_ENABLED) #ifdef bottom_schematron #undef xmlSchematronNewMemParserCtxt extern __typeof (xmlSchematronNewMemParserCtxt) xmlSchematronNewMemParserCtxt __attribute((alias("xmlSchematronNewMemParserCtxt__internal_alias"))); #else #ifndef xmlSchematronNewMemParserCtxt extern __typeof (xmlSchematronNewMemParserCtxt) xmlSchematronNewMemParserCtxt__internal_alias __attribute((visibility("hidden"))); #define xmlSchematronNewMemParserCtxt xmlSchematronNewMemParserCtxt__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMATRON_ENABLED) #ifdef bottom_schematron #undef xmlSchematronNewParserCtxt extern __typeof (xmlSchematronNewParserCtxt) xmlSchematronNewParserCtxt __attribute((alias("xmlSchematronNewParserCtxt__internal_alias"))); #else #ifndef xmlSchematronNewParserCtxt extern __typeof (xmlSchematronNewParserCtxt) xmlSchematronNewParserCtxt__internal_alias __attribute((visibility("hidden"))); #define xmlSchematronNewParserCtxt xmlSchematronNewParserCtxt__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMATRON_ENABLED) #ifdef bottom_schematron #undef xmlSchematronNewValidCtxt extern __typeof (xmlSchematronNewValidCtxt) xmlSchematronNewValidCtxt __attribute((alias("xmlSchematronNewValidCtxt__internal_alias"))); #else #ifndef xmlSchematronNewValidCtxt extern __typeof (xmlSchematronNewValidCtxt) xmlSchematronNewValidCtxt__internal_alias __attribute((visibility("hidden"))); #define xmlSchematronNewValidCtxt xmlSchematronNewValidCtxt__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMATRON_ENABLED) #ifdef bottom_schematron #undef xmlSchematronParse extern __typeof (xmlSchematronParse) xmlSchematronParse __attribute((alias("xmlSchematronParse__internal_alias"))); #else #ifndef xmlSchematronParse extern __typeof (xmlSchematronParse) xmlSchematronParse__internal_alias __attribute((visibility("hidden"))); #define xmlSchematronParse xmlSchematronParse__internal_alias #endif #endif #endif #if defined(LIBXML_SCHEMATRON_ENABLED) #ifdef bottom_schematron #undef xmlSchematronValidateDoc extern __typeof (xmlSchematronValidateDoc) xmlSchematronValidateDoc __attribute((alias("xmlSchematronValidateDoc__internal_alias"))); #else #ifndef xmlSchematronValidateDoc extern __typeof (xmlSchematronValidateDoc) xmlSchematronValidateDoc__internal_alias __attribute((visibility("hidden"))); #define xmlSchematronValidateDoc xmlSchematronValidateDoc__internal_alias #endif #endif #endif #ifdef bottom_tree #undef xmlSearchNs extern __typeof (xmlSearchNs) xmlSearchNs __attribute((alias("xmlSearchNs__internal_alias"))); #else #ifndef xmlSearchNs extern __typeof (xmlSearchNs) xmlSearchNs__internal_alias __attribute((visibility("hidden"))); #define xmlSearchNs xmlSearchNs__internal_alias #endif #endif #ifdef bottom_tree #undef xmlSearchNsByHref extern __typeof (xmlSearchNsByHref) xmlSearchNsByHref __attribute((alias("xmlSearchNsByHref__internal_alias"))); #else #ifndef xmlSearchNsByHref extern __typeof (xmlSearchNsByHref) xmlSearchNsByHref__internal_alias __attribute((visibility("hidden"))); #define xmlSearchNsByHref xmlSearchNsByHref__internal_alias #endif #endif #ifdef bottom_tree #undef xmlSetBufferAllocationScheme extern __typeof (xmlSetBufferAllocationScheme) xmlSetBufferAllocationScheme __attribute((alias("xmlSetBufferAllocationScheme__internal_alias"))); #else #ifndef xmlSetBufferAllocationScheme extern __typeof (xmlSetBufferAllocationScheme) xmlSetBufferAllocationScheme__internal_alias __attribute((visibility("hidden"))); #define xmlSetBufferAllocationScheme xmlSetBufferAllocationScheme__internal_alias #endif #endif #ifdef bottom_tree #undef xmlSetCompressMode extern __typeof (xmlSetCompressMode) xmlSetCompressMode __attribute((alias("xmlSetCompressMode__internal_alias"))); #else #ifndef xmlSetCompressMode extern __typeof (xmlSetCompressMode) xmlSetCompressMode__internal_alias __attribute((visibility("hidden"))); #define xmlSetCompressMode xmlSetCompressMode__internal_alias #endif #endif #ifdef bottom_tree #undef xmlSetDocCompressMode extern __typeof (xmlSetDocCompressMode) xmlSetDocCompressMode __attribute((alias("xmlSetDocCompressMode__internal_alias"))); #else #ifndef xmlSetDocCompressMode extern __typeof (xmlSetDocCompressMode) xmlSetDocCompressMode__internal_alias __attribute((visibility("hidden"))); #define xmlSetDocCompressMode xmlSetDocCompressMode__internal_alias #endif #endif #if defined(LIBXML_LEGACY_ENABLED) #ifdef bottom_parser #undef xmlSetEntityReferenceFunc extern __typeof (xmlSetEntityReferenceFunc) xmlSetEntityReferenceFunc __attribute((alias("xmlSetEntityReferenceFunc__internal_alias"))); #else #ifndef xmlSetEntityReferenceFunc extern __typeof (xmlSetEntityReferenceFunc) xmlSetEntityReferenceFunc__internal_alias __attribute((visibility("hidden"))); #define xmlSetEntityReferenceFunc xmlSetEntityReferenceFunc__internal_alias #endif #endif #endif #ifdef bottom_xmlIO #undef xmlSetExternalEntityLoader extern __typeof (xmlSetExternalEntityLoader) xmlSetExternalEntityLoader __attribute((alias("xmlSetExternalEntityLoader__internal_alias"))); #else #ifndef xmlSetExternalEntityLoader extern __typeof (xmlSetExternalEntityLoader) xmlSetExternalEntityLoader__internal_alias __attribute((visibility("hidden"))); #define xmlSetExternalEntityLoader xmlSetExternalEntityLoader__internal_alias #endif #endif #if defined(LIBXML_LEGACY_ENABLED) #ifdef bottom_legacy #undef xmlSetFeature extern __typeof (xmlSetFeature) xmlSetFeature __attribute((alias("xmlSetFeature__internal_alias"))); #else #ifndef xmlSetFeature extern __typeof (xmlSetFeature) xmlSetFeature__internal_alias __attribute((visibility("hidden"))); #define xmlSetFeature xmlSetFeature__internal_alias #endif #endif #endif #ifdef bottom_error #undef xmlSetGenericErrorFunc extern __typeof (xmlSetGenericErrorFunc) xmlSetGenericErrorFunc __attribute((alias("xmlSetGenericErrorFunc__internal_alias"))); #else #ifndef xmlSetGenericErrorFunc extern __typeof (xmlSetGenericErrorFunc) xmlSetGenericErrorFunc__internal_alias __attribute((visibility("hidden"))); #define xmlSetGenericErrorFunc xmlSetGenericErrorFunc__internal_alias #endif #endif #ifdef bottom_tree #undef xmlSetListDoc extern __typeof (xmlSetListDoc) xmlSetListDoc __attribute((alias("xmlSetListDoc__internal_alias"))); #else #ifndef xmlSetListDoc extern __typeof (xmlSetListDoc) xmlSetListDoc__internal_alias __attribute((visibility("hidden"))); #define xmlSetListDoc xmlSetListDoc__internal_alias #endif #endif #ifdef bottom_tree #undef xmlSetNs extern __typeof (xmlSetNs) xmlSetNs __attribute((alias("xmlSetNs__internal_alias"))); #else #ifndef xmlSetNs extern __typeof (xmlSetNs) xmlSetNs__internal_alias __attribute((visibility("hidden"))); #define xmlSetNs xmlSetNs__internal_alias #endif #endif #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_HTML_ENABLED) #ifdef bottom_tree #undef xmlSetNsProp extern __typeof (xmlSetNsProp) xmlSetNsProp __attribute((alias("xmlSetNsProp__internal_alias"))); #else #ifndef xmlSetNsProp extern __typeof (xmlSetNsProp) xmlSetNsProp__internal_alias __attribute((visibility("hidden"))); #define xmlSetNsProp xmlSetNsProp__internal_alias #endif #endif #endif #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_HTML_ENABLED) #ifdef bottom_tree #undef xmlSetProp extern __typeof (xmlSetProp) xmlSetProp __attribute((alias("xmlSetProp__internal_alias"))); #else #ifndef xmlSetProp extern __typeof (xmlSetProp) xmlSetProp__internal_alias __attribute((visibility("hidden"))); #define xmlSetProp xmlSetProp__internal_alias #endif #endif #endif #ifdef bottom_error #undef xmlSetStructuredErrorFunc extern __typeof (xmlSetStructuredErrorFunc) xmlSetStructuredErrorFunc __attribute((alias("xmlSetStructuredErrorFunc__internal_alias"))); #else #ifndef xmlSetStructuredErrorFunc extern __typeof (xmlSetStructuredErrorFunc) xmlSetStructuredErrorFunc__internal_alias __attribute((visibility("hidden"))); #define xmlSetStructuredErrorFunc xmlSetStructuredErrorFunc__internal_alias #endif #endif #ifdef bottom_tree #undef xmlSetTreeDoc extern __typeof (xmlSetTreeDoc) xmlSetTreeDoc __attribute((alias("xmlSetTreeDoc__internal_alias"))); #else #ifndef xmlSetTreeDoc extern __typeof (xmlSetTreeDoc) xmlSetTreeDoc__internal_alias __attribute((visibility("hidden"))); #define xmlSetTreeDoc xmlSetTreeDoc__internal_alias #endif #endif #if defined(LIBXML_SAX1_ENABLED) #ifdef bottom_parser #undef xmlSetupParserForBuffer extern __typeof (xmlSetupParserForBuffer) xmlSetupParserForBuffer __attribute((alias("xmlSetupParserForBuffer__internal_alias"))); #else #ifndef xmlSetupParserForBuffer extern __typeof (xmlSetupParserForBuffer) xmlSetupParserForBuffer__internal_alias __attribute((visibility("hidden"))); #define xmlSetupParserForBuffer xmlSetupParserForBuffer__internal_alias #endif #endif #endif #if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED) #ifdef bottom_debugXML #undef xmlShell extern __typeof (xmlShell) xmlShell __attribute((alias("xmlShell__internal_alias"))); #else #ifndef xmlShell extern __typeof (xmlShell) xmlShell__internal_alias __attribute((visibility("hidden"))); #define xmlShell xmlShell__internal_alias #endif #endif #endif #if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED) #ifdef bottom_debugXML #undef xmlShellBase extern __typeof (xmlShellBase) xmlShellBase __attribute((alias("xmlShellBase__internal_alias"))); #else #ifndef xmlShellBase extern __typeof (xmlShellBase) xmlShellBase__internal_alias __attribute((visibility("hidden"))); #define xmlShellBase xmlShellBase__internal_alias #endif #endif #endif #if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_debugXML #undef xmlShellCat extern __typeof (xmlShellCat) xmlShellCat __attribute((alias("xmlShellCat__internal_alias"))); #else #ifndef xmlShellCat extern __typeof (xmlShellCat) xmlShellCat__internal_alias __attribute((visibility("hidden"))); #define xmlShellCat xmlShellCat__internal_alias #endif #endif #endif #if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED) #ifdef bottom_debugXML #undef xmlShellDir extern __typeof (xmlShellDir) xmlShellDir __attribute((alias("xmlShellDir__internal_alias"))); #else #ifndef xmlShellDir extern __typeof (xmlShellDir) xmlShellDir__internal_alias __attribute((visibility("hidden"))); #define xmlShellDir xmlShellDir__internal_alias #endif #endif #endif #if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED) #ifdef bottom_debugXML #undef xmlShellDu extern __typeof (xmlShellDu) xmlShellDu __attribute((alias("xmlShellDu__internal_alias"))); #else #ifndef xmlShellDu extern __typeof (xmlShellDu) xmlShellDu__internal_alias __attribute((visibility("hidden"))); #define xmlShellDu xmlShellDu__internal_alias #endif #endif #endif #if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED) #ifdef bottom_debugXML #undef xmlShellList extern __typeof (xmlShellList) xmlShellList __attribute((alias("xmlShellList__internal_alias"))); #else #ifndef xmlShellList extern __typeof (xmlShellList) xmlShellList__internal_alias __attribute((visibility("hidden"))); #define xmlShellList xmlShellList__internal_alias #endif #endif #endif #if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED) #ifdef bottom_debugXML #undef xmlShellLoad extern __typeof (xmlShellLoad) xmlShellLoad __attribute((alias("xmlShellLoad__internal_alias"))); #else #ifndef xmlShellLoad extern __typeof (xmlShellLoad) xmlShellLoad__internal_alias __attribute((visibility("hidden"))); #define xmlShellLoad xmlShellLoad__internal_alias #endif #endif #endif #if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_debugXML #undef xmlShellPrintNode extern __typeof (xmlShellPrintNode) xmlShellPrintNode __attribute((alias("xmlShellPrintNode__internal_alias"))); #else #ifndef xmlShellPrintNode extern __typeof (xmlShellPrintNode) xmlShellPrintNode__internal_alias __attribute((visibility("hidden"))); #define xmlShellPrintNode xmlShellPrintNode__internal_alias #endif #endif #endif #if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED) #ifdef bottom_debugXML #undef xmlShellPrintXPathError extern __typeof (xmlShellPrintXPathError) xmlShellPrintXPathError __attribute((alias("xmlShellPrintXPathError__internal_alias"))); #else #ifndef xmlShellPrintXPathError extern __typeof (xmlShellPrintXPathError) xmlShellPrintXPathError__internal_alias __attribute((visibility("hidden"))); #define xmlShellPrintXPathError xmlShellPrintXPathError__internal_alias #endif #endif #endif #if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED) #ifdef bottom_debugXML #undef xmlShellPrintXPathResult extern __typeof (xmlShellPrintXPathResult) xmlShellPrintXPathResult __attribute((alias("xmlShellPrintXPathResult__internal_alias"))); #else #ifndef xmlShellPrintXPathResult extern __typeof (xmlShellPrintXPathResult) xmlShellPrintXPathResult__internal_alias __attribute((visibility("hidden"))); #define xmlShellPrintXPathResult xmlShellPrintXPathResult__internal_alias #endif #endif #endif #if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED) #ifdef bottom_debugXML #undef xmlShellPwd extern __typeof (xmlShellPwd) xmlShellPwd __attribute((alias("xmlShellPwd__internal_alias"))); #else #ifndef xmlShellPwd extern __typeof (xmlShellPwd) xmlShellPwd__internal_alias __attribute((visibility("hidden"))); #define xmlShellPwd xmlShellPwd__internal_alias #endif #endif #endif #if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_debugXML #undef xmlShellSave extern __typeof (xmlShellSave) xmlShellSave __attribute((alias("xmlShellSave__internal_alias"))); #else #ifndef xmlShellSave extern __typeof (xmlShellSave) xmlShellSave__internal_alias __attribute((visibility("hidden"))); #define xmlShellSave xmlShellSave__internal_alias #endif #endif #endif #if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED) && defined(LIBXML_VALID_ENABLED) #ifdef bottom_debugXML #undef xmlShellValidate extern __typeof (xmlShellValidate) xmlShellValidate __attribute((alias("xmlShellValidate__internal_alias"))); #else #ifndef xmlShellValidate extern __typeof (xmlShellValidate) xmlShellValidate__internal_alias __attribute((visibility("hidden"))); #define xmlShellValidate xmlShellValidate__internal_alias #endif #endif #endif #if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_debugXML #undef xmlShellWrite extern __typeof (xmlShellWrite) xmlShellWrite __attribute((alias("xmlShellWrite__internal_alias"))); #else #ifndef xmlShellWrite extern __typeof (xmlShellWrite) xmlShellWrite__internal_alias __attribute((visibility("hidden"))); #define xmlShellWrite xmlShellWrite__internal_alias #endif #endif #endif #ifdef bottom_parser #undef xmlSkipBlankChars extern __typeof (xmlSkipBlankChars) xmlSkipBlankChars __attribute((alias("xmlSkipBlankChars__internal_alias"))); #else #ifndef xmlSkipBlankChars extern __typeof (xmlSkipBlankChars) xmlSkipBlankChars__internal_alias __attribute((visibility("hidden"))); #define xmlSkipBlankChars xmlSkipBlankChars__internal_alias #endif #endif #ifdef bottom_valid #undef xmlSnprintfElementContent extern __typeof (xmlSnprintfElementContent) xmlSnprintfElementContent __attribute((alias("xmlSnprintfElementContent__internal_alias"))); #else #ifndef xmlSnprintfElementContent extern __typeof (xmlSnprintfElementContent) xmlSnprintfElementContent__internal_alias __attribute((visibility("hidden"))); #define xmlSnprintfElementContent xmlSnprintfElementContent__internal_alias #endif #endif #ifdef bottom_parser #undef xmlSplitQName extern __typeof (xmlSplitQName) xmlSplitQName __attribute((alias("xmlSplitQName__internal_alias"))); #else #ifndef xmlSplitQName extern __typeof (xmlSplitQName) xmlSplitQName__internal_alias __attribute((visibility("hidden"))); #define xmlSplitQName xmlSplitQName__internal_alias #endif #endif #ifdef bottom_tree #undef xmlSplitQName2 extern __typeof (xmlSplitQName2) xmlSplitQName2 __attribute((alias("xmlSplitQName2__internal_alias"))); #else #ifndef xmlSplitQName2 extern __typeof (xmlSplitQName2) xmlSplitQName2__internal_alias __attribute((visibility("hidden"))); #define xmlSplitQName2 xmlSplitQName2__internal_alias #endif #endif #ifdef bottom_tree #undef xmlSplitQName3 extern __typeof (xmlSplitQName3) xmlSplitQName3 __attribute((alias("xmlSplitQName3__internal_alias"))); #else #ifndef xmlSplitQName3 extern __typeof (xmlSplitQName3) xmlSplitQName3__internal_alias __attribute((visibility("hidden"))); #define xmlSplitQName3 xmlSplitQName3__internal_alias #endif #endif #if defined(LIBXML_OUTPUT_ENABLED) #ifdef bottom_valid #undef xmlSprintfElementContent extern __typeof (xmlSprintfElementContent) xmlSprintfElementContent __attribute((alias("xmlSprintfElementContent__internal_alias"))); #else #ifndef xmlSprintfElementContent extern __typeof (xmlSprintfElementContent) xmlSprintfElementContent__internal_alias __attribute((visibility("hidden"))); #define xmlSprintfElementContent xmlSprintfElementContent__internal_alias #endif #endif #endif #ifdef bottom_parser #undef xmlStopParser extern __typeof (xmlStopParser) xmlStopParser __attribute((alias("xmlStopParser__internal_alias"))); #else #ifndef xmlStopParser extern __typeof (xmlStopParser) xmlStopParser__internal_alias __attribute((visibility("hidden"))); #define xmlStopParser xmlStopParser__internal_alias #endif #endif #ifdef bottom_xmlstring #undef xmlStrEqual extern __typeof (xmlStrEqual) xmlStrEqual __attribute((alias("xmlStrEqual__internal_alias"))); #else #ifndef xmlStrEqual extern __typeof (xmlStrEqual) xmlStrEqual__internal_alias __attribute((visibility("hidden"))); #define xmlStrEqual xmlStrEqual__internal_alias #endif #endif #ifdef bottom_xmlstring #undef xmlStrPrintf extern __typeof (xmlStrPrintf) xmlStrPrintf __attribute((alias("xmlStrPrintf__internal_alias"))); #else #ifndef xmlStrPrintf extern __typeof (xmlStrPrintf) xmlStrPrintf__internal_alias __attribute((visibility("hidden"))); #define xmlStrPrintf xmlStrPrintf__internal_alias #endif #endif #ifdef bottom_xmlstring #undef xmlStrQEqual extern __typeof (xmlStrQEqual) xmlStrQEqual __attribute((alias("xmlStrQEqual__internal_alias"))); #else #ifndef xmlStrQEqual extern __typeof (xmlStrQEqual) xmlStrQEqual__internal_alias __attribute((visibility("hidden"))); #define xmlStrQEqual xmlStrQEqual__internal_alias #endif #endif #ifdef bottom_xmlstring #undef xmlStrVPrintf extern __typeof (xmlStrVPrintf) xmlStrVPrintf __attribute((alias("xmlStrVPrintf__internal_alias"))); #else #ifndef xmlStrVPrintf extern __typeof (xmlStrVPrintf) xmlStrVPrintf__internal_alias __attribute((visibility("hidden"))); #define xmlStrVPrintf xmlStrVPrintf__internal_alias #endif #endif #ifdef bottom_xmlstring #undef xmlStrcasecmp extern __typeof (xmlStrcasecmp) xmlStrcasecmp __attribute((alias("xmlStrcasecmp__internal_alias"))); #else #ifndef xmlStrcasecmp extern __typeof (xmlStrcasecmp) xmlStrcasecmp__internal_alias __attribute((visibility("hidden"))); #define xmlStrcasecmp xmlStrcasecmp__internal_alias #endif #endif #ifdef bottom_xmlstring #undef xmlStrcasestr extern __typeof (xmlStrcasestr) xmlStrcasestr __attribute((alias("xmlStrcasestr__internal_alias"))); #else #ifndef xmlStrcasestr extern __typeof (xmlStrcasestr) xmlStrcasestr__internal_alias __attribute((visibility("hidden"))); #define xmlStrcasestr xmlStrcasestr__internal_alias #endif #endif #ifdef bottom_xmlstring #undef xmlStrcat extern __typeof (xmlStrcat) xmlStrcat __attribute((alias("xmlStrcat__internal_alias"))); #else #ifndef xmlStrcat extern __typeof (xmlStrcat) xmlStrcat__internal_alias __attribute((visibility("hidden"))); #define xmlStrcat xmlStrcat__internal_alias #endif #endif #ifdef bottom_xmlstring #undef xmlStrchr extern __typeof (xmlStrchr) xmlStrchr __attribute((alias("xmlStrchr__internal_alias"))); #else #ifndef xmlStrchr extern __typeof (xmlStrchr) xmlStrchr__internal_alias __attribute((visibility("hidden"))); #define xmlStrchr xmlStrchr__internal_alias #endif #endif #ifdef bottom_xmlstring #undef xmlStrcmp extern __typeof (xmlStrcmp) xmlStrcmp __attribute((alias("xmlStrcmp__internal_alias"))); #else #ifndef xmlStrcmp extern __typeof (xmlStrcmp) xmlStrcmp__internal_alias __attribute((visibility("hidden"))); #define xmlStrcmp xmlStrcmp__internal_alias #endif #endif #ifdef bottom_xmlstring #undef xmlStrdup extern __typeof (xmlStrdup) xmlStrdup __attribute((alias("xmlStrdup__internal_alias"))); #else #ifndef xmlStrdup extern __typeof (xmlStrdup) xmlStrdup__internal_alias __attribute((visibility("hidden"))); #define xmlStrdup xmlStrdup__internal_alias #endif #endif #if defined(LIBXML_PATTERN_ENABLED) #ifdef bottom_pattern #undef xmlStreamPop extern __typeof (xmlStreamPop) xmlStreamPop __attribute((alias("xmlStreamPop__internal_alias"))); #else #ifndef xmlStreamPop extern __typeof (xmlStreamPop) xmlStreamPop__internal_alias __attribute((visibility("hidden"))); #define xmlStreamPop xmlStreamPop__internal_alias #endif #endif #endif #if defined(LIBXML_PATTERN_ENABLED) #ifdef bottom_pattern #undef xmlStreamPush extern __typeof (xmlStreamPush) xmlStreamPush __attribute((alias("xmlStreamPush__internal_alias"))); #else #ifndef xmlStreamPush extern __typeof (xmlStreamPush) xmlStreamPush__internal_alias __attribute((visibility("hidden"))); #define xmlStreamPush xmlStreamPush__internal_alias #endif #endif #endif #if defined(LIBXML_PATTERN_ENABLED) #ifdef bottom_pattern #undef xmlStreamPushAttr extern __typeof (xmlStreamPushAttr) xmlStreamPushAttr __attribute((alias("xmlStreamPushAttr__internal_alias"))); #else #ifndef xmlStreamPushAttr extern __typeof (xmlStreamPushAttr) xmlStreamPushAttr__internal_alias __attribute((visibility("hidden"))); #define xmlStreamPushAttr xmlStreamPushAttr__internal_alias #endif #endif #endif #if defined(LIBXML_PATTERN_ENABLED) #ifdef bottom_pattern #undef xmlStreamPushNode extern __typeof (xmlStreamPushNode) xmlStreamPushNode __attribute((alias("xmlStreamPushNode__internal_alias"))); #else #ifndef xmlStreamPushNode extern __typeof (xmlStreamPushNode) xmlStreamPushNode__internal_alias __attribute((visibility("hidden"))); #define xmlStreamPushNode xmlStreamPushNode__internal_alias #endif #endif #endif #if defined(LIBXML_PATTERN_ENABLED) #ifdef bottom_pattern #undef xmlStreamWantsAnyNode extern __typeof (xmlStreamWantsAnyNode) xmlStreamWantsAnyNode __attribute((alias("xmlStreamWantsAnyNode__internal_alias"))); #else #ifndef xmlStreamWantsAnyNode extern __typeof (xmlStreamWantsAnyNode) xmlStreamWantsAnyNode__internal_alias __attribute((visibility("hidden"))); #define xmlStreamWantsAnyNode xmlStreamWantsAnyNode__internal_alias #endif #endif #endif #ifdef bottom_parserInternals #undef xmlStringCurrentChar extern __typeof (xmlStringCurrentChar) xmlStringCurrentChar __attribute((alias("xmlStringCurrentChar__internal_alias"))); #else #ifndef xmlStringCurrentChar extern __typeof (xmlStringCurrentChar) xmlStringCurrentChar__internal_alias __attribute((visibility("hidden"))); #define xmlStringCurrentChar xmlStringCurrentChar__internal_alias #endif #endif #ifdef bottom_parser #undef xmlStringDecodeEntities extern __typeof (xmlStringDecodeEntities) xmlStringDecodeEntities __attribute((alias("xmlStringDecodeEntities__internal_alias"))); #else #ifndef xmlStringDecodeEntities extern __typeof (xmlStringDecodeEntities) xmlStringDecodeEntities__internal_alias __attribute((visibility("hidden"))); #define xmlStringDecodeEntities xmlStringDecodeEntities__internal_alias #endif #endif #ifdef bottom_tree #undef xmlStringGetNodeList extern __typeof (xmlStringGetNodeList) xmlStringGetNodeList __attribute((alias("xmlStringGetNodeList__internal_alias"))); #else #ifndef xmlStringGetNodeList extern __typeof (xmlStringGetNodeList) xmlStringGetNodeList__internal_alias __attribute((visibility("hidden"))); #define xmlStringGetNodeList xmlStringGetNodeList__internal_alias #endif #endif #ifdef bottom_parser #undef xmlStringLenDecodeEntities extern __typeof (xmlStringLenDecodeEntities) xmlStringLenDecodeEntities __attribute((alias("xmlStringLenDecodeEntities__internal_alias"))); #else #ifndef xmlStringLenDecodeEntities extern __typeof (xmlStringLenDecodeEntities) xmlStringLenDecodeEntities__internal_alias __attribute((visibility("hidden"))); #define xmlStringLenDecodeEntities xmlStringLenDecodeEntities__internal_alias #endif #endif #ifdef bottom_tree #undef xmlStringLenGetNodeList extern __typeof (xmlStringLenGetNodeList) xmlStringLenGetNodeList __attribute((alias("xmlStringLenGetNodeList__internal_alias"))); #else #ifndef xmlStringLenGetNodeList extern __typeof (xmlStringLenGetNodeList) xmlStringLenGetNodeList__internal_alias __attribute((visibility("hidden"))); #define xmlStringLenGetNodeList xmlStringLenGetNodeList__internal_alias #endif #endif #ifdef bottom_xmlstring #undef xmlStrlen extern __typeof (xmlStrlen) xmlStrlen __attribute((alias("xmlStrlen__internal_alias"))); #else #ifndef xmlStrlen extern __typeof (xmlStrlen) xmlStrlen__internal_alias __attribute((visibility("hidden"))); #define xmlStrlen xmlStrlen__internal_alias #endif #endif #ifdef bottom_xmlstring #undef xmlStrncasecmp extern __typeof (xmlStrncasecmp) xmlStrncasecmp __attribute((alias("xmlStrncasecmp__internal_alias"))); #else #ifndef xmlStrncasecmp extern __typeof (xmlStrncasecmp) xmlStrncasecmp__internal_alias __attribute((visibility("hidden"))); #define xmlStrncasecmp xmlStrncasecmp__internal_alias #endif #endif #ifdef bottom_xmlstring #undef xmlStrncat extern __typeof (xmlStrncat) xmlStrncat __attribute((alias("xmlStrncat__internal_alias"))); #else #ifndef xmlStrncat extern __typeof (xmlStrncat) xmlStrncat__internal_alias __attribute((visibility("hidden"))); #define xmlStrncat xmlStrncat__internal_alias #endif #endif #ifdef bottom_xmlstring #undef xmlStrncatNew extern __typeof (xmlStrncatNew) xmlStrncatNew __attribute((alias("xmlStrncatNew__internal_alias"))); #else #ifndef xmlStrncatNew extern __typeof (xmlStrncatNew) xmlStrncatNew__internal_alias __attribute((visibility("hidden"))); #define xmlStrncatNew xmlStrncatNew__internal_alias #endif #endif #ifdef bottom_xmlstring #undef xmlStrncmp extern __typeof (xmlStrncmp) xmlStrncmp __attribute((alias("xmlStrncmp__internal_alias"))); #else #ifndef xmlStrncmp extern __typeof (xmlStrncmp) xmlStrncmp__internal_alias __attribute((visibility("hidden"))); #define xmlStrncmp xmlStrncmp__internal_alias #endif #endif #ifdef bottom_xmlstring #undef xmlStrndup extern __typeof (xmlStrndup) xmlStrndup __attribute((alias("xmlStrndup__internal_alias"))); #else #ifndef xmlStrndup extern __typeof (xmlStrndup) xmlStrndup__internal_alias __attribute((visibility("hidden"))); #define xmlStrndup xmlStrndup__internal_alias #endif #endif #ifdef bottom_xmlstring #undef xmlStrstr extern __typeof (xmlStrstr) xmlStrstr __attribute((alias("xmlStrstr__internal_alias"))); #else #ifndef xmlStrstr extern __typeof (xmlStrstr) xmlStrstr__internal_alias __attribute((visibility("hidden"))); #define xmlStrstr xmlStrstr__internal_alias #endif #endif #ifdef bottom_xmlstring #undef xmlStrsub extern __typeof (xmlStrsub) xmlStrsub __attribute((alias("xmlStrsub__internal_alias"))); #else #ifndef xmlStrsub extern __typeof (xmlStrsub) xmlStrsub__internal_alias __attribute((visibility("hidden"))); #define xmlStrsub xmlStrsub__internal_alias #endif #endif #ifdef bottom_parserInternals #undef xmlSubstituteEntitiesDefault extern __typeof (xmlSubstituteEntitiesDefault) xmlSubstituteEntitiesDefault __attribute((alias("xmlSubstituteEntitiesDefault__internal_alias"))); #else #ifndef xmlSubstituteEntitiesDefault extern __typeof (xmlSubstituteEntitiesDefault) xmlSubstituteEntitiesDefault__internal_alias __attribute((visibility("hidden"))); #define xmlSubstituteEntitiesDefault xmlSubstituteEntitiesDefault__internal_alias #endif #endif #ifdef bottom_parserInternals #undef xmlSwitchEncoding extern __typeof (xmlSwitchEncoding) xmlSwitchEncoding __attribute((alias("xmlSwitchEncoding__internal_alias"))); #else #ifndef xmlSwitchEncoding extern __typeof (xmlSwitchEncoding) xmlSwitchEncoding__internal_alias __attribute((visibility("hidden"))); #define xmlSwitchEncoding xmlSwitchEncoding__internal_alias #endif #endif #ifdef bottom_parserInternals #undef xmlSwitchInputEncoding extern __typeof (xmlSwitchInputEncoding) xmlSwitchInputEncoding __attribute((alias("xmlSwitchInputEncoding__internal_alias"))); #else #ifndef xmlSwitchInputEncoding extern __typeof (xmlSwitchInputEncoding) xmlSwitchInputEncoding__internal_alias __attribute((visibility("hidden"))); #define xmlSwitchInputEncoding xmlSwitchInputEncoding__internal_alias #endif #endif #ifdef bottom_parserInternals #undef xmlSwitchToEncoding extern __typeof (xmlSwitchToEncoding) xmlSwitchToEncoding __attribute((alias("xmlSwitchToEncoding__internal_alias"))); #else #ifndef xmlSwitchToEncoding extern __typeof (xmlSwitchToEncoding) xmlSwitchToEncoding__internal_alias __attribute((visibility("hidden"))); #define xmlSwitchToEncoding xmlSwitchToEncoding__internal_alias #endif #endif #ifdef bottom_tree #undef xmlTextConcat extern __typeof (xmlTextConcat) xmlTextConcat __attribute((alias("xmlTextConcat__internal_alias"))); #else #ifndef xmlTextConcat extern __typeof (xmlTextConcat) xmlTextConcat__internal_alias __attribute((visibility("hidden"))); #define xmlTextConcat xmlTextConcat__internal_alias #endif #endif #ifdef bottom_tree #undef xmlTextMerge extern __typeof (xmlTextMerge) xmlTextMerge __attribute((alias("xmlTextMerge__internal_alias"))); #else #ifndef xmlTextMerge extern __typeof (xmlTextMerge) xmlTextMerge__internal_alias __attribute((visibility("hidden"))); #define xmlTextMerge xmlTextMerge__internal_alias #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderAttributeCount extern __typeof (xmlTextReaderAttributeCount) xmlTextReaderAttributeCount __attribute((alias("xmlTextReaderAttributeCount__internal_alias"))); #else #ifndef xmlTextReaderAttributeCount extern __typeof (xmlTextReaderAttributeCount) xmlTextReaderAttributeCount__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderAttributeCount xmlTextReaderAttributeCount__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderBaseUri extern __typeof (xmlTextReaderBaseUri) xmlTextReaderBaseUri __attribute((alias("xmlTextReaderBaseUri__internal_alias"))); #else #ifndef xmlTextReaderBaseUri extern __typeof (xmlTextReaderBaseUri) xmlTextReaderBaseUri__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderBaseUri xmlTextReaderBaseUri__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderByteConsumed extern __typeof (xmlTextReaderByteConsumed) xmlTextReaderByteConsumed __attribute((alias("xmlTextReaderByteConsumed__internal_alias"))); #else #ifndef xmlTextReaderByteConsumed extern __typeof (xmlTextReaderByteConsumed) xmlTextReaderByteConsumed__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderByteConsumed xmlTextReaderByteConsumed__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderClose extern __typeof (xmlTextReaderClose) xmlTextReaderClose __attribute((alias("xmlTextReaderClose__internal_alias"))); #else #ifndef xmlTextReaderClose extern __typeof (xmlTextReaderClose) xmlTextReaderClose__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderClose xmlTextReaderClose__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderConstBaseUri extern __typeof (xmlTextReaderConstBaseUri) xmlTextReaderConstBaseUri __attribute((alias("xmlTextReaderConstBaseUri__internal_alias"))); #else #ifndef xmlTextReaderConstBaseUri extern __typeof (xmlTextReaderConstBaseUri) xmlTextReaderConstBaseUri__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderConstBaseUri xmlTextReaderConstBaseUri__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderConstEncoding extern __typeof (xmlTextReaderConstEncoding) xmlTextReaderConstEncoding __attribute((alias("xmlTextReaderConstEncoding__internal_alias"))); #else #ifndef xmlTextReaderConstEncoding extern __typeof (xmlTextReaderConstEncoding) xmlTextReaderConstEncoding__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderConstEncoding xmlTextReaderConstEncoding__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderConstLocalName extern __typeof (xmlTextReaderConstLocalName) xmlTextReaderConstLocalName __attribute((alias("xmlTextReaderConstLocalName__internal_alias"))); #else #ifndef xmlTextReaderConstLocalName extern __typeof (xmlTextReaderConstLocalName) xmlTextReaderConstLocalName__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderConstLocalName xmlTextReaderConstLocalName__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderConstName extern __typeof (xmlTextReaderConstName) xmlTextReaderConstName __attribute((alias("xmlTextReaderConstName__internal_alias"))); #else #ifndef xmlTextReaderConstName extern __typeof (xmlTextReaderConstName) xmlTextReaderConstName__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderConstName xmlTextReaderConstName__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderConstNamespaceUri extern __typeof (xmlTextReaderConstNamespaceUri) xmlTextReaderConstNamespaceUri __attribute((alias("xmlTextReaderConstNamespaceUri__internal_alias"))); #else #ifndef xmlTextReaderConstNamespaceUri extern __typeof (xmlTextReaderConstNamespaceUri) xmlTextReaderConstNamespaceUri__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderConstNamespaceUri xmlTextReaderConstNamespaceUri__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderConstPrefix extern __typeof (xmlTextReaderConstPrefix) xmlTextReaderConstPrefix __attribute((alias("xmlTextReaderConstPrefix__internal_alias"))); #else #ifndef xmlTextReaderConstPrefix extern __typeof (xmlTextReaderConstPrefix) xmlTextReaderConstPrefix__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderConstPrefix xmlTextReaderConstPrefix__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderConstString extern __typeof (xmlTextReaderConstString) xmlTextReaderConstString __attribute((alias("xmlTextReaderConstString__internal_alias"))); #else #ifndef xmlTextReaderConstString extern __typeof (xmlTextReaderConstString) xmlTextReaderConstString__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderConstString xmlTextReaderConstString__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderConstValue extern __typeof (xmlTextReaderConstValue) xmlTextReaderConstValue __attribute((alias("xmlTextReaderConstValue__internal_alias"))); #else #ifndef xmlTextReaderConstValue extern __typeof (xmlTextReaderConstValue) xmlTextReaderConstValue__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderConstValue xmlTextReaderConstValue__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderConstXmlLang extern __typeof (xmlTextReaderConstXmlLang) xmlTextReaderConstXmlLang __attribute((alias("xmlTextReaderConstXmlLang__internal_alias"))); #else #ifndef xmlTextReaderConstXmlLang extern __typeof (xmlTextReaderConstXmlLang) xmlTextReaderConstXmlLang__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderConstXmlLang xmlTextReaderConstXmlLang__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderConstXmlVersion extern __typeof (xmlTextReaderConstXmlVersion) xmlTextReaderConstXmlVersion __attribute((alias("xmlTextReaderConstXmlVersion__internal_alias"))); #else #ifndef xmlTextReaderConstXmlVersion extern __typeof (xmlTextReaderConstXmlVersion) xmlTextReaderConstXmlVersion__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderConstXmlVersion xmlTextReaderConstXmlVersion__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderCurrentDoc extern __typeof (xmlTextReaderCurrentDoc) xmlTextReaderCurrentDoc __attribute((alias("xmlTextReaderCurrentDoc__internal_alias"))); #else #ifndef xmlTextReaderCurrentDoc extern __typeof (xmlTextReaderCurrentDoc) xmlTextReaderCurrentDoc__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderCurrentDoc xmlTextReaderCurrentDoc__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderCurrentNode extern __typeof (xmlTextReaderCurrentNode) xmlTextReaderCurrentNode __attribute((alias("xmlTextReaderCurrentNode__internal_alias"))); #else #ifndef xmlTextReaderCurrentNode extern __typeof (xmlTextReaderCurrentNode) xmlTextReaderCurrentNode__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderCurrentNode xmlTextReaderCurrentNode__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderDepth extern __typeof (xmlTextReaderDepth) xmlTextReaderDepth __attribute((alias("xmlTextReaderDepth__internal_alias"))); #else #ifndef xmlTextReaderDepth extern __typeof (xmlTextReaderDepth) xmlTextReaderDepth__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderDepth xmlTextReaderDepth__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderExpand extern __typeof (xmlTextReaderExpand) xmlTextReaderExpand __attribute((alias("xmlTextReaderExpand__internal_alias"))); #else #ifndef xmlTextReaderExpand extern __typeof (xmlTextReaderExpand) xmlTextReaderExpand__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderExpand xmlTextReaderExpand__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderGetAttribute extern __typeof (xmlTextReaderGetAttribute) xmlTextReaderGetAttribute __attribute((alias("xmlTextReaderGetAttribute__internal_alias"))); #else #ifndef xmlTextReaderGetAttribute extern __typeof (xmlTextReaderGetAttribute) xmlTextReaderGetAttribute__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderGetAttribute xmlTextReaderGetAttribute__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderGetAttributeNo extern __typeof (xmlTextReaderGetAttributeNo) xmlTextReaderGetAttributeNo __attribute((alias("xmlTextReaderGetAttributeNo__internal_alias"))); #else #ifndef xmlTextReaderGetAttributeNo extern __typeof (xmlTextReaderGetAttributeNo) xmlTextReaderGetAttributeNo__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderGetAttributeNo xmlTextReaderGetAttributeNo__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderGetAttributeNs extern __typeof (xmlTextReaderGetAttributeNs) xmlTextReaderGetAttributeNs __attribute((alias("xmlTextReaderGetAttributeNs__internal_alias"))); #else #ifndef xmlTextReaderGetAttributeNs extern __typeof (xmlTextReaderGetAttributeNs) xmlTextReaderGetAttributeNs__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderGetAttributeNs xmlTextReaderGetAttributeNs__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderGetErrorHandler extern __typeof (xmlTextReaderGetErrorHandler) xmlTextReaderGetErrorHandler __attribute((alias("xmlTextReaderGetErrorHandler__internal_alias"))); #else #ifndef xmlTextReaderGetErrorHandler extern __typeof (xmlTextReaderGetErrorHandler) xmlTextReaderGetErrorHandler__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderGetErrorHandler xmlTextReaderGetErrorHandler__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderGetParserColumnNumber extern __typeof (xmlTextReaderGetParserColumnNumber) xmlTextReaderGetParserColumnNumber __attribute((alias("xmlTextReaderGetParserColumnNumber__internal_alias"))); #else #ifndef xmlTextReaderGetParserColumnNumber extern __typeof (xmlTextReaderGetParserColumnNumber) xmlTextReaderGetParserColumnNumber__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderGetParserColumnNumber xmlTextReaderGetParserColumnNumber__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderGetParserLineNumber extern __typeof (xmlTextReaderGetParserLineNumber) xmlTextReaderGetParserLineNumber __attribute((alias("xmlTextReaderGetParserLineNumber__internal_alias"))); #else #ifndef xmlTextReaderGetParserLineNumber extern __typeof (xmlTextReaderGetParserLineNumber) xmlTextReaderGetParserLineNumber__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderGetParserLineNumber xmlTextReaderGetParserLineNumber__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderGetParserProp extern __typeof (xmlTextReaderGetParserProp) xmlTextReaderGetParserProp __attribute((alias("xmlTextReaderGetParserProp__internal_alias"))); #else #ifndef xmlTextReaderGetParserProp extern __typeof (xmlTextReaderGetParserProp) xmlTextReaderGetParserProp__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderGetParserProp xmlTextReaderGetParserProp__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderGetRemainder extern __typeof (xmlTextReaderGetRemainder) xmlTextReaderGetRemainder __attribute((alias("xmlTextReaderGetRemainder__internal_alias"))); #else #ifndef xmlTextReaderGetRemainder extern __typeof (xmlTextReaderGetRemainder) xmlTextReaderGetRemainder__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderGetRemainder xmlTextReaderGetRemainder__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderHasAttributes extern __typeof (xmlTextReaderHasAttributes) xmlTextReaderHasAttributes __attribute((alias("xmlTextReaderHasAttributes__internal_alias"))); #else #ifndef xmlTextReaderHasAttributes extern __typeof (xmlTextReaderHasAttributes) xmlTextReaderHasAttributes__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderHasAttributes xmlTextReaderHasAttributes__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderHasValue extern __typeof (xmlTextReaderHasValue) xmlTextReaderHasValue __attribute((alias("xmlTextReaderHasValue__internal_alias"))); #else #ifndef xmlTextReaderHasValue extern __typeof (xmlTextReaderHasValue) xmlTextReaderHasValue__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderHasValue xmlTextReaderHasValue__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderIsDefault extern __typeof (xmlTextReaderIsDefault) xmlTextReaderIsDefault __attribute((alias("xmlTextReaderIsDefault__internal_alias"))); #else #ifndef xmlTextReaderIsDefault extern __typeof (xmlTextReaderIsDefault) xmlTextReaderIsDefault__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderIsDefault xmlTextReaderIsDefault__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderIsEmptyElement extern __typeof (xmlTextReaderIsEmptyElement) xmlTextReaderIsEmptyElement __attribute((alias("xmlTextReaderIsEmptyElement__internal_alias"))); #else #ifndef xmlTextReaderIsEmptyElement extern __typeof (xmlTextReaderIsEmptyElement) xmlTextReaderIsEmptyElement__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderIsEmptyElement xmlTextReaderIsEmptyElement__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderIsNamespaceDecl extern __typeof (xmlTextReaderIsNamespaceDecl) xmlTextReaderIsNamespaceDecl __attribute((alias("xmlTextReaderIsNamespaceDecl__internal_alias"))); #else #ifndef xmlTextReaderIsNamespaceDecl extern __typeof (xmlTextReaderIsNamespaceDecl) xmlTextReaderIsNamespaceDecl__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderIsNamespaceDecl xmlTextReaderIsNamespaceDecl__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderIsValid extern __typeof (xmlTextReaderIsValid) xmlTextReaderIsValid __attribute((alias("xmlTextReaderIsValid__internal_alias"))); #else #ifndef xmlTextReaderIsValid extern __typeof (xmlTextReaderIsValid) xmlTextReaderIsValid__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderIsValid xmlTextReaderIsValid__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderLocalName extern __typeof (xmlTextReaderLocalName) xmlTextReaderLocalName __attribute((alias("xmlTextReaderLocalName__internal_alias"))); #else #ifndef xmlTextReaderLocalName extern __typeof (xmlTextReaderLocalName) xmlTextReaderLocalName__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderLocalName xmlTextReaderLocalName__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderLocatorBaseURI extern __typeof (xmlTextReaderLocatorBaseURI) xmlTextReaderLocatorBaseURI __attribute((alias("xmlTextReaderLocatorBaseURI__internal_alias"))); #else #ifndef xmlTextReaderLocatorBaseURI extern __typeof (xmlTextReaderLocatorBaseURI) xmlTextReaderLocatorBaseURI__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderLocatorBaseURI xmlTextReaderLocatorBaseURI__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderLocatorLineNumber extern __typeof (xmlTextReaderLocatorLineNumber) xmlTextReaderLocatorLineNumber __attribute((alias("xmlTextReaderLocatorLineNumber__internal_alias"))); #else #ifndef xmlTextReaderLocatorLineNumber extern __typeof (xmlTextReaderLocatorLineNumber) xmlTextReaderLocatorLineNumber__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderLocatorLineNumber xmlTextReaderLocatorLineNumber__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderLookupNamespace extern __typeof (xmlTextReaderLookupNamespace) xmlTextReaderLookupNamespace __attribute((alias("xmlTextReaderLookupNamespace__internal_alias"))); #else #ifndef xmlTextReaderLookupNamespace extern __typeof (xmlTextReaderLookupNamespace) xmlTextReaderLookupNamespace__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderLookupNamespace xmlTextReaderLookupNamespace__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderMoveToAttribute extern __typeof (xmlTextReaderMoveToAttribute) xmlTextReaderMoveToAttribute __attribute((alias("xmlTextReaderMoveToAttribute__internal_alias"))); #else #ifndef xmlTextReaderMoveToAttribute extern __typeof (xmlTextReaderMoveToAttribute) xmlTextReaderMoveToAttribute__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderMoveToAttribute xmlTextReaderMoveToAttribute__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderMoveToAttributeNo extern __typeof (xmlTextReaderMoveToAttributeNo) xmlTextReaderMoveToAttributeNo __attribute((alias("xmlTextReaderMoveToAttributeNo__internal_alias"))); #else #ifndef xmlTextReaderMoveToAttributeNo extern __typeof (xmlTextReaderMoveToAttributeNo) xmlTextReaderMoveToAttributeNo__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderMoveToAttributeNo xmlTextReaderMoveToAttributeNo__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderMoveToAttributeNs extern __typeof (xmlTextReaderMoveToAttributeNs) xmlTextReaderMoveToAttributeNs __attribute((alias("xmlTextReaderMoveToAttributeNs__internal_alias"))); #else #ifndef xmlTextReaderMoveToAttributeNs extern __typeof (xmlTextReaderMoveToAttributeNs) xmlTextReaderMoveToAttributeNs__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderMoveToAttributeNs xmlTextReaderMoveToAttributeNs__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderMoveToElement extern __typeof (xmlTextReaderMoveToElement) xmlTextReaderMoveToElement __attribute((alias("xmlTextReaderMoveToElement__internal_alias"))); #else #ifndef xmlTextReaderMoveToElement extern __typeof (xmlTextReaderMoveToElement) xmlTextReaderMoveToElement__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderMoveToElement xmlTextReaderMoveToElement__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderMoveToFirstAttribute extern __typeof (xmlTextReaderMoveToFirstAttribute) xmlTextReaderMoveToFirstAttribute __attribute((alias("xmlTextReaderMoveToFirstAttribute__internal_alias"))); #else #ifndef xmlTextReaderMoveToFirstAttribute extern __typeof (xmlTextReaderMoveToFirstAttribute) xmlTextReaderMoveToFirstAttribute__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderMoveToFirstAttribute xmlTextReaderMoveToFirstAttribute__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderMoveToNextAttribute extern __typeof (xmlTextReaderMoveToNextAttribute) xmlTextReaderMoveToNextAttribute __attribute((alias("xmlTextReaderMoveToNextAttribute__internal_alias"))); #else #ifndef xmlTextReaderMoveToNextAttribute extern __typeof (xmlTextReaderMoveToNextAttribute) xmlTextReaderMoveToNextAttribute__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderMoveToNextAttribute xmlTextReaderMoveToNextAttribute__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderName extern __typeof (xmlTextReaderName) xmlTextReaderName __attribute((alias("xmlTextReaderName__internal_alias"))); #else #ifndef xmlTextReaderName extern __typeof (xmlTextReaderName) xmlTextReaderName__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderName xmlTextReaderName__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderNamespaceUri extern __typeof (xmlTextReaderNamespaceUri) xmlTextReaderNamespaceUri __attribute((alias("xmlTextReaderNamespaceUri__internal_alias"))); #else #ifndef xmlTextReaderNamespaceUri extern __typeof (xmlTextReaderNamespaceUri) xmlTextReaderNamespaceUri__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderNamespaceUri xmlTextReaderNamespaceUri__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderNext extern __typeof (xmlTextReaderNext) xmlTextReaderNext __attribute((alias("xmlTextReaderNext__internal_alias"))); #else #ifndef xmlTextReaderNext extern __typeof (xmlTextReaderNext) xmlTextReaderNext__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderNext xmlTextReaderNext__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderNextSibling extern __typeof (xmlTextReaderNextSibling) xmlTextReaderNextSibling __attribute((alias("xmlTextReaderNextSibling__internal_alias"))); #else #ifndef xmlTextReaderNextSibling extern __typeof (xmlTextReaderNextSibling) xmlTextReaderNextSibling__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderNextSibling xmlTextReaderNextSibling__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderNodeType extern __typeof (xmlTextReaderNodeType) xmlTextReaderNodeType __attribute((alias("xmlTextReaderNodeType__internal_alias"))); #else #ifndef xmlTextReaderNodeType extern __typeof (xmlTextReaderNodeType) xmlTextReaderNodeType__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderNodeType xmlTextReaderNodeType__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderNormalization extern __typeof (xmlTextReaderNormalization) xmlTextReaderNormalization __attribute((alias("xmlTextReaderNormalization__internal_alias"))); #else #ifndef xmlTextReaderNormalization extern __typeof (xmlTextReaderNormalization) xmlTextReaderNormalization__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderNormalization xmlTextReaderNormalization__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderPrefix extern __typeof (xmlTextReaderPrefix) xmlTextReaderPrefix __attribute((alias("xmlTextReaderPrefix__internal_alias"))); #else #ifndef xmlTextReaderPrefix extern __typeof (xmlTextReaderPrefix) xmlTextReaderPrefix__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderPrefix xmlTextReaderPrefix__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderPreserve extern __typeof (xmlTextReaderPreserve) xmlTextReaderPreserve __attribute((alias("xmlTextReaderPreserve__internal_alias"))); #else #ifndef xmlTextReaderPreserve extern __typeof (xmlTextReaderPreserve) xmlTextReaderPreserve__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderPreserve xmlTextReaderPreserve__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) && defined(LIBXML_PATTERN_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderPreservePattern extern __typeof (xmlTextReaderPreservePattern) xmlTextReaderPreservePattern __attribute((alias("xmlTextReaderPreservePattern__internal_alias"))); #else #ifndef xmlTextReaderPreservePattern extern __typeof (xmlTextReaderPreservePattern) xmlTextReaderPreservePattern__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderPreservePattern xmlTextReaderPreservePattern__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderQuoteChar extern __typeof (xmlTextReaderQuoteChar) xmlTextReaderQuoteChar __attribute((alias("xmlTextReaderQuoteChar__internal_alias"))); #else #ifndef xmlTextReaderQuoteChar extern __typeof (xmlTextReaderQuoteChar) xmlTextReaderQuoteChar__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderQuoteChar xmlTextReaderQuoteChar__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderRead extern __typeof (xmlTextReaderRead) xmlTextReaderRead __attribute((alias("xmlTextReaderRead__internal_alias"))); #else #ifndef xmlTextReaderRead extern __typeof (xmlTextReaderRead) xmlTextReaderRead__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderRead xmlTextReaderRead__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderReadAttributeValue extern __typeof (xmlTextReaderReadAttributeValue) xmlTextReaderReadAttributeValue __attribute((alias("xmlTextReaderReadAttributeValue__internal_alias"))); #else #ifndef xmlTextReaderReadAttributeValue extern __typeof (xmlTextReaderReadAttributeValue) xmlTextReaderReadAttributeValue__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderReadAttributeValue xmlTextReaderReadAttributeValue__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) && defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderReadInnerXml extern __typeof (xmlTextReaderReadInnerXml) xmlTextReaderReadInnerXml __attribute((alias("xmlTextReaderReadInnerXml__internal_alias"))); #else #ifndef xmlTextReaderReadInnerXml extern __typeof (xmlTextReaderReadInnerXml) xmlTextReaderReadInnerXml__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderReadInnerXml xmlTextReaderReadInnerXml__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) && defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderReadOuterXml extern __typeof (xmlTextReaderReadOuterXml) xmlTextReaderReadOuterXml __attribute((alias("xmlTextReaderReadOuterXml__internal_alias"))); #else #ifndef xmlTextReaderReadOuterXml extern __typeof (xmlTextReaderReadOuterXml) xmlTextReaderReadOuterXml__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderReadOuterXml xmlTextReaderReadOuterXml__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderReadState extern __typeof (xmlTextReaderReadState) xmlTextReaderReadState __attribute((alias("xmlTextReaderReadState__internal_alias"))); #else #ifndef xmlTextReaderReadState extern __typeof (xmlTextReaderReadState) xmlTextReaderReadState__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderReadState xmlTextReaderReadState__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderReadString extern __typeof (xmlTextReaderReadString) xmlTextReaderReadString __attribute((alias("xmlTextReaderReadString__internal_alias"))); #else #ifndef xmlTextReaderReadString extern __typeof (xmlTextReaderReadString) xmlTextReaderReadString__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderReadString xmlTextReaderReadString__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) && defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderRelaxNGSetSchema extern __typeof (xmlTextReaderRelaxNGSetSchema) xmlTextReaderRelaxNGSetSchema __attribute((alias("xmlTextReaderRelaxNGSetSchema__internal_alias"))); #else #ifndef xmlTextReaderRelaxNGSetSchema extern __typeof (xmlTextReaderRelaxNGSetSchema) xmlTextReaderRelaxNGSetSchema__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderRelaxNGSetSchema xmlTextReaderRelaxNGSetSchema__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) && defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderRelaxNGValidate extern __typeof (xmlTextReaderRelaxNGValidate) xmlTextReaderRelaxNGValidate __attribute((alias("xmlTextReaderRelaxNGValidate__internal_alias"))); #else #ifndef xmlTextReaderRelaxNGValidate extern __typeof (xmlTextReaderRelaxNGValidate) xmlTextReaderRelaxNGValidate__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderRelaxNGValidate xmlTextReaderRelaxNGValidate__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) && defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderSchemaValidate extern __typeof (xmlTextReaderSchemaValidate) xmlTextReaderSchemaValidate __attribute((alias("xmlTextReaderSchemaValidate__internal_alias"))); #else #ifndef xmlTextReaderSchemaValidate extern __typeof (xmlTextReaderSchemaValidate) xmlTextReaderSchemaValidate__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderSchemaValidate xmlTextReaderSchemaValidate__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) && defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderSchemaValidateCtxt extern __typeof (xmlTextReaderSchemaValidateCtxt) xmlTextReaderSchemaValidateCtxt __attribute((alias("xmlTextReaderSchemaValidateCtxt__internal_alias"))); #else #ifndef xmlTextReaderSchemaValidateCtxt extern __typeof (xmlTextReaderSchemaValidateCtxt) xmlTextReaderSchemaValidateCtxt__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderSchemaValidateCtxt xmlTextReaderSchemaValidateCtxt__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderSetErrorHandler extern __typeof (xmlTextReaderSetErrorHandler) xmlTextReaderSetErrorHandler __attribute((alias("xmlTextReaderSetErrorHandler__internal_alias"))); #else #ifndef xmlTextReaderSetErrorHandler extern __typeof (xmlTextReaderSetErrorHandler) xmlTextReaderSetErrorHandler__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderSetErrorHandler xmlTextReaderSetErrorHandler__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderSetParserProp extern __typeof (xmlTextReaderSetParserProp) xmlTextReaderSetParserProp __attribute((alias("xmlTextReaderSetParserProp__internal_alias"))); #else #ifndef xmlTextReaderSetParserProp extern __typeof (xmlTextReaderSetParserProp) xmlTextReaderSetParserProp__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderSetParserProp xmlTextReaderSetParserProp__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) && defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderSetSchema extern __typeof (xmlTextReaderSetSchema) xmlTextReaderSetSchema __attribute((alias("xmlTextReaderSetSchema__internal_alias"))); #else #ifndef xmlTextReaderSetSchema extern __typeof (xmlTextReaderSetSchema) xmlTextReaderSetSchema__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderSetSchema xmlTextReaderSetSchema__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderSetStructuredErrorHandler extern __typeof (xmlTextReaderSetStructuredErrorHandler) xmlTextReaderSetStructuredErrorHandler __attribute((alias("xmlTextReaderSetStructuredErrorHandler__internal_alias"))); #else #ifndef xmlTextReaderSetStructuredErrorHandler extern __typeof (xmlTextReaderSetStructuredErrorHandler) xmlTextReaderSetStructuredErrorHandler__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderSetStructuredErrorHandler xmlTextReaderSetStructuredErrorHandler__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderStandalone extern __typeof (xmlTextReaderStandalone) xmlTextReaderStandalone __attribute((alias("xmlTextReaderStandalone__internal_alias"))); #else #ifndef xmlTextReaderStandalone extern __typeof (xmlTextReaderStandalone) xmlTextReaderStandalone__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderStandalone xmlTextReaderStandalone__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderValue extern __typeof (xmlTextReaderValue) xmlTextReaderValue __attribute((alias("xmlTextReaderValue__internal_alias"))); #else #ifndef xmlTextReaderValue extern __typeof (xmlTextReaderValue) xmlTextReaderValue__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderValue xmlTextReaderValue__internal_alias #endif #endif #endif #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderXmlLang extern __typeof (xmlTextReaderXmlLang) xmlTextReaderXmlLang __attribute((alias("xmlTextReaderXmlLang__internal_alias"))); #else #ifndef xmlTextReaderXmlLang extern __typeof (xmlTextReaderXmlLang) xmlTextReaderXmlLang__internal_alias __attribute((visibility("hidden"))); #define xmlTextReaderXmlLang xmlTextReaderXmlLang__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterEndAttribute extern __typeof (xmlTextWriterEndAttribute) xmlTextWriterEndAttribute __attribute((alias("xmlTextWriterEndAttribute__internal_alias"))); #else #ifndef xmlTextWriterEndAttribute extern __typeof (xmlTextWriterEndAttribute) xmlTextWriterEndAttribute__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterEndAttribute xmlTextWriterEndAttribute__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterEndCDATA extern __typeof (xmlTextWriterEndCDATA) xmlTextWriterEndCDATA __attribute((alias("xmlTextWriterEndCDATA__internal_alias"))); #else #ifndef xmlTextWriterEndCDATA extern __typeof (xmlTextWriterEndCDATA) xmlTextWriterEndCDATA__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterEndCDATA xmlTextWriterEndCDATA__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterEndComment extern __typeof (xmlTextWriterEndComment) xmlTextWriterEndComment __attribute((alias("xmlTextWriterEndComment__internal_alias"))); #else #ifndef xmlTextWriterEndComment extern __typeof (xmlTextWriterEndComment) xmlTextWriterEndComment__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterEndComment xmlTextWriterEndComment__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterEndDTD extern __typeof (xmlTextWriterEndDTD) xmlTextWriterEndDTD __attribute((alias("xmlTextWriterEndDTD__internal_alias"))); #else #ifndef xmlTextWriterEndDTD extern __typeof (xmlTextWriterEndDTD) xmlTextWriterEndDTD__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterEndDTD xmlTextWriterEndDTD__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterEndDTDAttlist extern __typeof (xmlTextWriterEndDTDAttlist) xmlTextWriterEndDTDAttlist __attribute((alias("xmlTextWriterEndDTDAttlist__internal_alias"))); #else #ifndef xmlTextWriterEndDTDAttlist extern __typeof (xmlTextWriterEndDTDAttlist) xmlTextWriterEndDTDAttlist__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterEndDTDAttlist xmlTextWriterEndDTDAttlist__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterEndDTDElement extern __typeof (xmlTextWriterEndDTDElement) xmlTextWriterEndDTDElement __attribute((alias("xmlTextWriterEndDTDElement__internal_alias"))); #else #ifndef xmlTextWriterEndDTDElement extern __typeof (xmlTextWriterEndDTDElement) xmlTextWriterEndDTDElement__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterEndDTDElement xmlTextWriterEndDTDElement__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterEndDTDEntity extern __typeof (xmlTextWriterEndDTDEntity) xmlTextWriterEndDTDEntity __attribute((alias("xmlTextWriterEndDTDEntity__internal_alias"))); #else #ifndef xmlTextWriterEndDTDEntity extern __typeof (xmlTextWriterEndDTDEntity) xmlTextWriterEndDTDEntity__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterEndDTDEntity xmlTextWriterEndDTDEntity__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterEndDocument extern __typeof (xmlTextWriterEndDocument) xmlTextWriterEndDocument __attribute((alias("xmlTextWriterEndDocument__internal_alias"))); #else #ifndef xmlTextWriterEndDocument extern __typeof (xmlTextWriterEndDocument) xmlTextWriterEndDocument__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterEndDocument xmlTextWriterEndDocument__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterEndElement extern __typeof (xmlTextWriterEndElement) xmlTextWriterEndElement __attribute((alias("xmlTextWriterEndElement__internal_alias"))); #else #ifndef xmlTextWriterEndElement extern __typeof (xmlTextWriterEndElement) xmlTextWriterEndElement__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterEndElement xmlTextWriterEndElement__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterEndPI extern __typeof (xmlTextWriterEndPI) xmlTextWriterEndPI __attribute((alias("xmlTextWriterEndPI__internal_alias"))); #else #ifndef xmlTextWriterEndPI extern __typeof (xmlTextWriterEndPI) xmlTextWriterEndPI__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterEndPI xmlTextWriterEndPI__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterFlush extern __typeof (xmlTextWriterFlush) xmlTextWriterFlush __attribute((alias("xmlTextWriterFlush__internal_alias"))); #else #ifndef xmlTextWriterFlush extern __typeof (xmlTextWriterFlush) xmlTextWriterFlush__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterFlush xmlTextWriterFlush__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterFullEndElement extern __typeof (xmlTextWriterFullEndElement) xmlTextWriterFullEndElement __attribute((alias("xmlTextWriterFullEndElement__internal_alias"))); #else #ifndef xmlTextWriterFullEndElement extern __typeof (xmlTextWriterFullEndElement) xmlTextWriterFullEndElement__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterFullEndElement xmlTextWriterFullEndElement__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterSetIndent extern __typeof (xmlTextWriterSetIndent) xmlTextWriterSetIndent __attribute((alias("xmlTextWriterSetIndent__internal_alias"))); #else #ifndef xmlTextWriterSetIndent extern __typeof (xmlTextWriterSetIndent) xmlTextWriterSetIndent__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterSetIndent xmlTextWriterSetIndent__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterSetIndentString extern __typeof (xmlTextWriterSetIndentString) xmlTextWriterSetIndentString __attribute((alias("xmlTextWriterSetIndentString__internal_alias"))); #else #ifndef xmlTextWriterSetIndentString extern __typeof (xmlTextWriterSetIndentString) xmlTextWriterSetIndentString__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterSetIndentString xmlTextWriterSetIndentString__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterStartAttribute extern __typeof (xmlTextWriterStartAttribute) xmlTextWriterStartAttribute __attribute((alias("xmlTextWriterStartAttribute__internal_alias"))); #else #ifndef xmlTextWriterStartAttribute extern __typeof (xmlTextWriterStartAttribute) xmlTextWriterStartAttribute__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterStartAttribute xmlTextWriterStartAttribute__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterStartAttributeNS extern __typeof (xmlTextWriterStartAttributeNS) xmlTextWriterStartAttributeNS __attribute((alias("xmlTextWriterStartAttributeNS__internal_alias"))); #else #ifndef xmlTextWriterStartAttributeNS extern __typeof (xmlTextWriterStartAttributeNS) xmlTextWriterStartAttributeNS__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterStartAttributeNS xmlTextWriterStartAttributeNS__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterStartCDATA extern __typeof (xmlTextWriterStartCDATA) xmlTextWriterStartCDATA __attribute((alias("xmlTextWriterStartCDATA__internal_alias"))); #else #ifndef xmlTextWriterStartCDATA extern __typeof (xmlTextWriterStartCDATA) xmlTextWriterStartCDATA__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterStartCDATA xmlTextWriterStartCDATA__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterStartComment extern __typeof (xmlTextWriterStartComment) xmlTextWriterStartComment __attribute((alias("xmlTextWriterStartComment__internal_alias"))); #else #ifndef xmlTextWriterStartComment extern __typeof (xmlTextWriterStartComment) xmlTextWriterStartComment__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterStartComment xmlTextWriterStartComment__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterStartDTD extern __typeof (xmlTextWriterStartDTD) xmlTextWriterStartDTD __attribute((alias("xmlTextWriterStartDTD__internal_alias"))); #else #ifndef xmlTextWriterStartDTD extern __typeof (xmlTextWriterStartDTD) xmlTextWriterStartDTD__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterStartDTD xmlTextWriterStartDTD__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterStartDTDAttlist extern __typeof (xmlTextWriterStartDTDAttlist) xmlTextWriterStartDTDAttlist __attribute((alias("xmlTextWriterStartDTDAttlist__internal_alias"))); #else #ifndef xmlTextWriterStartDTDAttlist extern __typeof (xmlTextWriterStartDTDAttlist) xmlTextWriterStartDTDAttlist__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterStartDTDAttlist xmlTextWriterStartDTDAttlist__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterStartDTDElement extern __typeof (xmlTextWriterStartDTDElement) xmlTextWriterStartDTDElement __attribute((alias("xmlTextWriterStartDTDElement__internal_alias"))); #else #ifndef xmlTextWriterStartDTDElement extern __typeof (xmlTextWriterStartDTDElement) xmlTextWriterStartDTDElement__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterStartDTDElement xmlTextWriterStartDTDElement__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterStartDTDEntity extern __typeof (xmlTextWriterStartDTDEntity) xmlTextWriterStartDTDEntity __attribute((alias("xmlTextWriterStartDTDEntity__internal_alias"))); #else #ifndef xmlTextWriterStartDTDEntity extern __typeof (xmlTextWriterStartDTDEntity) xmlTextWriterStartDTDEntity__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterStartDTDEntity xmlTextWriterStartDTDEntity__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterStartDocument extern __typeof (xmlTextWriterStartDocument) xmlTextWriterStartDocument __attribute((alias("xmlTextWriterStartDocument__internal_alias"))); #else #ifndef xmlTextWriterStartDocument extern __typeof (xmlTextWriterStartDocument) xmlTextWriterStartDocument__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterStartDocument xmlTextWriterStartDocument__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterStartElement extern __typeof (xmlTextWriterStartElement) xmlTextWriterStartElement __attribute((alias("xmlTextWriterStartElement__internal_alias"))); #else #ifndef xmlTextWriterStartElement extern __typeof (xmlTextWriterStartElement) xmlTextWriterStartElement__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterStartElement xmlTextWriterStartElement__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterStartElementNS extern __typeof (xmlTextWriterStartElementNS) xmlTextWriterStartElementNS __attribute((alias("xmlTextWriterStartElementNS__internal_alias"))); #else #ifndef xmlTextWriterStartElementNS extern __typeof (xmlTextWriterStartElementNS) xmlTextWriterStartElementNS__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterStartElementNS xmlTextWriterStartElementNS__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterStartPI extern __typeof (xmlTextWriterStartPI) xmlTextWriterStartPI __attribute((alias("xmlTextWriterStartPI__internal_alias"))); #else #ifndef xmlTextWriterStartPI extern __typeof (xmlTextWriterStartPI) xmlTextWriterStartPI__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterStartPI xmlTextWriterStartPI__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteAttribute extern __typeof (xmlTextWriterWriteAttribute) xmlTextWriterWriteAttribute __attribute((alias("xmlTextWriterWriteAttribute__internal_alias"))); #else #ifndef xmlTextWriterWriteAttribute extern __typeof (xmlTextWriterWriteAttribute) xmlTextWriterWriteAttribute__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteAttribute xmlTextWriterWriteAttribute__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteAttributeNS extern __typeof (xmlTextWriterWriteAttributeNS) xmlTextWriterWriteAttributeNS __attribute((alias("xmlTextWriterWriteAttributeNS__internal_alias"))); #else #ifndef xmlTextWriterWriteAttributeNS extern __typeof (xmlTextWriterWriteAttributeNS) xmlTextWriterWriteAttributeNS__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteAttributeNS xmlTextWriterWriteAttributeNS__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteBase64 extern __typeof (xmlTextWriterWriteBase64) xmlTextWriterWriteBase64 __attribute((alias("xmlTextWriterWriteBase64__internal_alias"))); #else #ifndef xmlTextWriterWriteBase64 extern __typeof (xmlTextWriterWriteBase64) xmlTextWriterWriteBase64__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteBase64 xmlTextWriterWriteBase64__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteBinHex extern __typeof (xmlTextWriterWriteBinHex) xmlTextWriterWriteBinHex __attribute((alias("xmlTextWriterWriteBinHex__internal_alias"))); #else #ifndef xmlTextWriterWriteBinHex extern __typeof (xmlTextWriterWriteBinHex) xmlTextWriterWriteBinHex__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteBinHex xmlTextWriterWriteBinHex__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteCDATA extern __typeof (xmlTextWriterWriteCDATA) xmlTextWriterWriteCDATA __attribute((alias("xmlTextWriterWriteCDATA__internal_alias"))); #else #ifndef xmlTextWriterWriteCDATA extern __typeof (xmlTextWriterWriteCDATA) xmlTextWriterWriteCDATA__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteCDATA xmlTextWriterWriteCDATA__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteComment extern __typeof (xmlTextWriterWriteComment) xmlTextWriterWriteComment __attribute((alias("xmlTextWriterWriteComment__internal_alias"))); #else #ifndef xmlTextWriterWriteComment extern __typeof (xmlTextWriterWriteComment) xmlTextWriterWriteComment__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteComment xmlTextWriterWriteComment__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteDTD extern __typeof (xmlTextWriterWriteDTD) xmlTextWriterWriteDTD __attribute((alias("xmlTextWriterWriteDTD__internal_alias"))); #else #ifndef xmlTextWriterWriteDTD extern __typeof (xmlTextWriterWriteDTD) xmlTextWriterWriteDTD__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteDTD xmlTextWriterWriteDTD__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteDTDAttlist extern __typeof (xmlTextWriterWriteDTDAttlist) xmlTextWriterWriteDTDAttlist __attribute((alias("xmlTextWriterWriteDTDAttlist__internal_alias"))); #else #ifndef xmlTextWriterWriteDTDAttlist extern __typeof (xmlTextWriterWriteDTDAttlist) xmlTextWriterWriteDTDAttlist__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteDTDAttlist xmlTextWriterWriteDTDAttlist__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteDTDElement extern __typeof (xmlTextWriterWriteDTDElement) xmlTextWriterWriteDTDElement __attribute((alias("xmlTextWriterWriteDTDElement__internal_alias"))); #else #ifndef xmlTextWriterWriteDTDElement extern __typeof (xmlTextWriterWriteDTDElement) xmlTextWriterWriteDTDElement__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteDTDElement xmlTextWriterWriteDTDElement__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteDTDEntity extern __typeof (xmlTextWriterWriteDTDEntity) xmlTextWriterWriteDTDEntity __attribute((alias("xmlTextWriterWriteDTDEntity__internal_alias"))); #else #ifndef xmlTextWriterWriteDTDEntity extern __typeof (xmlTextWriterWriteDTDEntity) xmlTextWriterWriteDTDEntity__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteDTDEntity xmlTextWriterWriteDTDEntity__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteDTDExternalEntity extern __typeof (xmlTextWriterWriteDTDExternalEntity) xmlTextWriterWriteDTDExternalEntity __attribute((alias("xmlTextWriterWriteDTDExternalEntity__internal_alias"))); #else #ifndef xmlTextWriterWriteDTDExternalEntity extern __typeof (xmlTextWriterWriteDTDExternalEntity) xmlTextWriterWriteDTDExternalEntity__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteDTDExternalEntity xmlTextWriterWriteDTDExternalEntity__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteDTDExternalEntityContents extern __typeof (xmlTextWriterWriteDTDExternalEntityContents) xmlTextWriterWriteDTDExternalEntityContents __attribute((alias("xmlTextWriterWriteDTDExternalEntityContents__internal_alias"))); #else #ifndef xmlTextWriterWriteDTDExternalEntityContents extern __typeof (xmlTextWriterWriteDTDExternalEntityContents) xmlTextWriterWriteDTDExternalEntityContents__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteDTDExternalEntityContents xmlTextWriterWriteDTDExternalEntityContents__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteDTDInternalEntity extern __typeof (xmlTextWriterWriteDTDInternalEntity) xmlTextWriterWriteDTDInternalEntity __attribute((alias("xmlTextWriterWriteDTDInternalEntity__internal_alias"))); #else #ifndef xmlTextWriterWriteDTDInternalEntity extern __typeof (xmlTextWriterWriteDTDInternalEntity) xmlTextWriterWriteDTDInternalEntity__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteDTDInternalEntity xmlTextWriterWriteDTDInternalEntity__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteDTDNotation extern __typeof (xmlTextWriterWriteDTDNotation) xmlTextWriterWriteDTDNotation __attribute((alias("xmlTextWriterWriteDTDNotation__internal_alias"))); #else #ifndef xmlTextWriterWriteDTDNotation extern __typeof (xmlTextWriterWriteDTDNotation) xmlTextWriterWriteDTDNotation__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteDTDNotation xmlTextWriterWriteDTDNotation__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteElement extern __typeof (xmlTextWriterWriteElement) xmlTextWriterWriteElement __attribute((alias("xmlTextWriterWriteElement__internal_alias"))); #else #ifndef xmlTextWriterWriteElement extern __typeof (xmlTextWriterWriteElement) xmlTextWriterWriteElement__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteElement xmlTextWriterWriteElement__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteElementNS extern __typeof (xmlTextWriterWriteElementNS) xmlTextWriterWriteElementNS __attribute((alias("xmlTextWriterWriteElementNS__internal_alias"))); #else #ifndef xmlTextWriterWriteElementNS extern __typeof (xmlTextWriterWriteElementNS) xmlTextWriterWriteElementNS__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteElementNS xmlTextWriterWriteElementNS__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteFormatAttribute extern __typeof (xmlTextWriterWriteFormatAttribute) xmlTextWriterWriteFormatAttribute __attribute((alias("xmlTextWriterWriteFormatAttribute__internal_alias"))); #else #ifndef xmlTextWriterWriteFormatAttribute extern __typeof (xmlTextWriterWriteFormatAttribute) xmlTextWriterWriteFormatAttribute__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteFormatAttribute xmlTextWriterWriteFormatAttribute__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteFormatAttributeNS extern __typeof (xmlTextWriterWriteFormatAttributeNS) xmlTextWriterWriteFormatAttributeNS __attribute((alias("xmlTextWriterWriteFormatAttributeNS__internal_alias"))); #else #ifndef xmlTextWriterWriteFormatAttributeNS extern __typeof (xmlTextWriterWriteFormatAttributeNS) xmlTextWriterWriteFormatAttributeNS__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteFormatAttributeNS xmlTextWriterWriteFormatAttributeNS__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteFormatCDATA extern __typeof (xmlTextWriterWriteFormatCDATA) xmlTextWriterWriteFormatCDATA __attribute((alias("xmlTextWriterWriteFormatCDATA__internal_alias"))); #else #ifndef xmlTextWriterWriteFormatCDATA extern __typeof (xmlTextWriterWriteFormatCDATA) xmlTextWriterWriteFormatCDATA__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteFormatCDATA xmlTextWriterWriteFormatCDATA__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteFormatComment extern __typeof (xmlTextWriterWriteFormatComment) xmlTextWriterWriteFormatComment __attribute((alias("xmlTextWriterWriteFormatComment__internal_alias"))); #else #ifndef xmlTextWriterWriteFormatComment extern __typeof (xmlTextWriterWriteFormatComment) xmlTextWriterWriteFormatComment__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteFormatComment xmlTextWriterWriteFormatComment__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteFormatDTD extern __typeof (xmlTextWriterWriteFormatDTD) xmlTextWriterWriteFormatDTD __attribute((alias("xmlTextWriterWriteFormatDTD__internal_alias"))); #else #ifndef xmlTextWriterWriteFormatDTD extern __typeof (xmlTextWriterWriteFormatDTD) xmlTextWriterWriteFormatDTD__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteFormatDTD xmlTextWriterWriteFormatDTD__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteFormatDTDAttlist extern __typeof (xmlTextWriterWriteFormatDTDAttlist) xmlTextWriterWriteFormatDTDAttlist __attribute((alias("xmlTextWriterWriteFormatDTDAttlist__internal_alias"))); #else #ifndef xmlTextWriterWriteFormatDTDAttlist extern __typeof (xmlTextWriterWriteFormatDTDAttlist) xmlTextWriterWriteFormatDTDAttlist__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteFormatDTDAttlist xmlTextWriterWriteFormatDTDAttlist__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteFormatDTDElement extern __typeof (xmlTextWriterWriteFormatDTDElement) xmlTextWriterWriteFormatDTDElement __attribute((alias("xmlTextWriterWriteFormatDTDElement__internal_alias"))); #else #ifndef xmlTextWriterWriteFormatDTDElement extern __typeof (xmlTextWriterWriteFormatDTDElement) xmlTextWriterWriteFormatDTDElement__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteFormatDTDElement xmlTextWriterWriteFormatDTDElement__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteFormatDTDInternalEntity extern __typeof (xmlTextWriterWriteFormatDTDInternalEntity) xmlTextWriterWriteFormatDTDInternalEntity __attribute((alias("xmlTextWriterWriteFormatDTDInternalEntity__internal_alias"))); #else #ifndef xmlTextWriterWriteFormatDTDInternalEntity extern __typeof (xmlTextWriterWriteFormatDTDInternalEntity) xmlTextWriterWriteFormatDTDInternalEntity__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteFormatDTDInternalEntity xmlTextWriterWriteFormatDTDInternalEntity__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteFormatElement extern __typeof (xmlTextWriterWriteFormatElement) xmlTextWriterWriteFormatElement __attribute((alias("xmlTextWriterWriteFormatElement__internal_alias"))); #else #ifndef xmlTextWriterWriteFormatElement extern __typeof (xmlTextWriterWriteFormatElement) xmlTextWriterWriteFormatElement__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteFormatElement xmlTextWriterWriteFormatElement__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteFormatElementNS extern __typeof (xmlTextWriterWriteFormatElementNS) xmlTextWriterWriteFormatElementNS __attribute((alias("xmlTextWriterWriteFormatElementNS__internal_alias"))); #else #ifndef xmlTextWriterWriteFormatElementNS extern __typeof (xmlTextWriterWriteFormatElementNS) xmlTextWriterWriteFormatElementNS__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteFormatElementNS xmlTextWriterWriteFormatElementNS__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteFormatPI extern __typeof (xmlTextWriterWriteFormatPI) xmlTextWriterWriteFormatPI __attribute((alias("xmlTextWriterWriteFormatPI__internal_alias"))); #else #ifndef xmlTextWriterWriteFormatPI extern __typeof (xmlTextWriterWriteFormatPI) xmlTextWriterWriteFormatPI__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteFormatPI xmlTextWriterWriteFormatPI__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteFormatRaw extern __typeof (xmlTextWriterWriteFormatRaw) xmlTextWriterWriteFormatRaw __attribute((alias("xmlTextWriterWriteFormatRaw__internal_alias"))); #else #ifndef xmlTextWriterWriteFormatRaw extern __typeof (xmlTextWriterWriteFormatRaw) xmlTextWriterWriteFormatRaw__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteFormatRaw xmlTextWriterWriteFormatRaw__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteFormatString extern __typeof (xmlTextWriterWriteFormatString) xmlTextWriterWriteFormatString __attribute((alias("xmlTextWriterWriteFormatString__internal_alias"))); #else #ifndef xmlTextWriterWriteFormatString extern __typeof (xmlTextWriterWriteFormatString) xmlTextWriterWriteFormatString__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteFormatString xmlTextWriterWriteFormatString__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWritePI extern __typeof (xmlTextWriterWritePI) xmlTextWriterWritePI __attribute((alias("xmlTextWriterWritePI__internal_alias"))); #else #ifndef xmlTextWriterWritePI extern __typeof (xmlTextWriterWritePI) xmlTextWriterWritePI__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWritePI xmlTextWriterWritePI__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteRaw extern __typeof (xmlTextWriterWriteRaw) xmlTextWriterWriteRaw __attribute((alias("xmlTextWriterWriteRaw__internal_alias"))); #else #ifndef xmlTextWriterWriteRaw extern __typeof (xmlTextWriterWriteRaw) xmlTextWriterWriteRaw__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteRaw xmlTextWriterWriteRaw__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteRawLen extern __typeof (xmlTextWriterWriteRawLen) xmlTextWriterWriteRawLen __attribute((alias("xmlTextWriterWriteRawLen__internal_alias"))); #else #ifndef xmlTextWriterWriteRawLen extern __typeof (xmlTextWriterWriteRawLen) xmlTextWriterWriteRawLen__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteRawLen xmlTextWriterWriteRawLen__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteString extern __typeof (xmlTextWriterWriteString) xmlTextWriterWriteString __attribute((alias("xmlTextWriterWriteString__internal_alias"))); #else #ifndef xmlTextWriterWriteString extern __typeof (xmlTextWriterWriteString) xmlTextWriterWriteString__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteString xmlTextWriterWriteString__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteVFormatAttribute extern __typeof (xmlTextWriterWriteVFormatAttribute) xmlTextWriterWriteVFormatAttribute __attribute((alias("xmlTextWriterWriteVFormatAttribute__internal_alias"))); #else #ifndef xmlTextWriterWriteVFormatAttribute extern __typeof (xmlTextWriterWriteVFormatAttribute) xmlTextWriterWriteVFormatAttribute__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteVFormatAttribute xmlTextWriterWriteVFormatAttribute__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteVFormatAttributeNS extern __typeof (xmlTextWriterWriteVFormatAttributeNS) xmlTextWriterWriteVFormatAttributeNS __attribute((alias("xmlTextWriterWriteVFormatAttributeNS__internal_alias"))); #else #ifndef xmlTextWriterWriteVFormatAttributeNS extern __typeof (xmlTextWriterWriteVFormatAttributeNS) xmlTextWriterWriteVFormatAttributeNS__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteVFormatAttributeNS xmlTextWriterWriteVFormatAttributeNS__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteVFormatCDATA extern __typeof (xmlTextWriterWriteVFormatCDATA) xmlTextWriterWriteVFormatCDATA __attribute((alias("xmlTextWriterWriteVFormatCDATA__internal_alias"))); #else #ifndef xmlTextWriterWriteVFormatCDATA extern __typeof (xmlTextWriterWriteVFormatCDATA) xmlTextWriterWriteVFormatCDATA__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteVFormatCDATA xmlTextWriterWriteVFormatCDATA__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteVFormatComment extern __typeof (xmlTextWriterWriteVFormatComment) xmlTextWriterWriteVFormatComment __attribute((alias("xmlTextWriterWriteVFormatComment__internal_alias"))); #else #ifndef xmlTextWriterWriteVFormatComment extern __typeof (xmlTextWriterWriteVFormatComment) xmlTextWriterWriteVFormatComment__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteVFormatComment xmlTextWriterWriteVFormatComment__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteVFormatDTD extern __typeof (xmlTextWriterWriteVFormatDTD) xmlTextWriterWriteVFormatDTD __attribute((alias("xmlTextWriterWriteVFormatDTD__internal_alias"))); #else #ifndef xmlTextWriterWriteVFormatDTD extern __typeof (xmlTextWriterWriteVFormatDTD) xmlTextWriterWriteVFormatDTD__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteVFormatDTD xmlTextWriterWriteVFormatDTD__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteVFormatDTDAttlist extern __typeof (xmlTextWriterWriteVFormatDTDAttlist) xmlTextWriterWriteVFormatDTDAttlist __attribute((alias("xmlTextWriterWriteVFormatDTDAttlist__internal_alias"))); #else #ifndef xmlTextWriterWriteVFormatDTDAttlist extern __typeof (xmlTextWriterWriteVFormatDTDAttlist) xmlTextWriterWriteVFormatDTDAttlist__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteVFormatDTDAttlist xmlTextWriterWriteVFormatDTDAttlist__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteVFormatDTDElement extern __typeof (xmlTextWriterWriteVFormatDTDElement) xmlTextWriterWriteVFormatDTDElement __attribute((alias("xmlTextWriterWriteVFormatDTDElement__internal_alias"))); #else #ifndef xmlTextWriterWriteVFormatDTDElement extern __typeof (xmlTextWriterWriteVFormatDTDElement) xmlTextWriterWriteVFormatDTDElement__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteVFormatDTDElement xmlTextWriterWriteVFormatDTDElement__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteVFormatDTDInternalEntity extern __typeof (xmlTextWriterWriteVFormatDTDInternalEntity) xmlTextWriterWriteVFormatDTDInternalEntity __attribute((alias("xmlTextWriterWriteVFormatDTDInternalEntity__internal_alias"))); #else #ifndef xmlTextWriterWriteVFormatDTDInternalEntity extern __typeof (xmlTextWriterWriteVFormatDTDInternalEntity) xmlTextWriterWriteVFormatDTDInternalEntity__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteVFormatDTDInternalEntity xmlTextWriterWriteVFormatDTDInternalEntity__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteVFormatElement extern __typeof (xmlTextWriterWriteVFormatElement) xmlTextWriterWriteVFormatElement __attribute((alias("xmlTextWriterWriteVFormatElement__internal_alias"))); #else #ifndef xmlTextWriterWriteVFormatElement extern __typeof (xmlTextWriterWriteVFormatElement) xmlTextWriterWriteVFormatElement__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteVFormatElement xmlTextWriterWriteVFormatElement__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteVFormatElementNS extern __typeof (xmlTextWriterWriteVFormatElementNS) xmlTextWriterWriteVFormatElementNS __attribute((alias("xmlTextWriterWriteVFormatElementNS__internal_alias"))); #else #ifndef xmlTextWriterWriteVFormatElementNS extern __typeof (xmlTextWriterWriteVFormatElementNS) xmlTextWriterWriteVFormatElementNS__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteVFormatElementNS xmlTextWriterWriteVFormatElementNS__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteVFormatPI extern __typeof (xmlTextWriterWriteVFormatPI) xmlTextWriterWriteVFormatPI __attribute((alias("xmlTextWriterWriteVFormatPI__internal_alias"))); #else #ifndef xmlTextWriterWriteVFormatPI extern __typeof (xmlTextWriterWriteVFormatPI) xmlTextWriterWriteVFormatPI__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteVFormatPI xmlTextWriterWriteVFormatPI__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteVFormatRaw extern __typeof (xmlTextWriterWriteVFormatRaw) xmlTextWriterWriteVFormatRaw __attribute((alias("xmlTextWriterWriteVFormatRaw__internal_alias"))); #else #ifndef xmlTextWriterWriteVFormatRaw extern __typeof (xmlTextWriterWriteVFormatRaw) xmlTextWriterWriteVFormatRaw__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteVFormatRaw xmlTextWriterWriteVFormatRaw__internal_alias #endif #endif #endif #if defined(LIBXML_WRITER_ENABLED) #ifdef bottom_xmlwriter #undef xmlTextWriterWriteVFormatString extern __typeof (xmlTextWriterWriteVFormatString) xmlTextWriterWriteVFormatString __attribute((alias("xmlTextWriterWriteVFormatString__internal_alias"))); #else #ifndef xmlTextWriterWriteVFormatString extern __typeof (xmlTextWriterWriteVFormatString) xmlTextWriterWriteVFormatString__internal_alias __attribute((visibility("hidden"))); #define xmlTextWriterWriteVFormatString xmlTextWriterWriteVFormatString__internal_alias #endif #endif #endif #ifdef bottom_globals #undef xmlThrDefBufferAllocScheme extern __typeof (xmlThrDefBufferAllocScheme) xmlThrDefBufferAllocScheme __attribute((alias("xmlThrDefBufferAllocScheme__internal_alias"))); #else #ifndef xmlThrDefBufferAllocScheme extern __typeof (xmlThrDefBufferAllocScheme) xmlThrDefBufferAllocScheme__internal_alias __attribute((visibility("hidden"))); #define xmlThrDefBufferAllocScheme xmlThrDefBufferAllocScheme__internal_alias #endif #endif #ifdef bottom_globals #undef xmlThrDefDefaultBufferSize extern __typeof (xmlThrDefDefaultBufferSize) xmlThrDefDefaultBufferSize __attribute((alias("xmlThrDefDefaultBufferSize__internal_alias"))); #else #ifndef xmlThrDefDefaultBufferSize extern __typeof (xmlThrDefDefaultBufferSize) xmlThrDefDefaultBufferSize__internal_alias __attribute((visibility("hidden"))); #define xmlThrDefDefaultBufferSize xmlThrDefDefaultBufferSize__internal_alias #endif #endif #ifdef bottom_globals #undef xmlThrDefDeregisterNodeDefault extern __typeof (xmlThrDefDeregisterNodeDefault) xmlThrDefDeregisterNodeDefault __attribute((alias("xmlThrDefDeregisterNodeDefault__internal_alias"))); #else #ifndef xmlThrDefDeregisterNodeDefault extern __typeof (xmlThrDefDeregisterNodeDefault) xmlThrDefDeregisterNodeDefault__internal_alias __attribute((visibility("hidden"))); #define xmlThrDefDeregisterNodeDefault xmlThrDefDeregisterNodeDefault__internal_alias #endif #endif #ifdef bottom_globals #undef xmlThrDefDoValidityCheckingDefaultValue extern __typeof (xmlThrDefDoValidityCheckingDefaultValue) xmlThrDefDoValidityCheckingDefaultValue __attribute((alias("xmlThrDefDoValidityCheckingDefaultValue__internal_alias"))); #else #ifndef xmlThrDefDoValidityCheckingDefaultValue extern __typeof (xmlThrDefDoValidityCheckingDefaultValue) xmlThrDefDoValidityCheckingDefaultValue__internal_alias __attribute((visibility("hidden"))); #define xmlThrDefDoValidityCheckingDefaultValue xmlThrDefDoValidityCheckingDefaultValue__internal_alias #endif #endif #ifdef bottom_globals #undef xmlThrDefGetWarningsDefaultValue extern __typeof (xmlThrDefGetWarningsDefaultValue) xmlThrDefGetWarningsDefaultValue __attribute((alias("xmlThrDefGetWarningsDefaultValue__internal_alias"))); #else #ifndef xmlThrDefGetWarningsDefaultValue extern __typeof (xmlThrDefGetWarningsDefaultValue) xmlThrDefGetWarningsDefaultValue__internal_alias __attribute((visibility("hidden"))); #define xmlThrDefGetWarningsDefaultValue xmlThrDefGetWarningsDefaultValue__internal_alias #endif #endif #ifdef bottom_globals #undef xmlThrDefIndentTreeOutput extern __typeof (xmlThrDefIndentTreeOutput) xmlThrDefIndentTreeOutput __attribute((alias("xmlThrDefIndentTreeOutput__internal_alias"))); #else #ifndef xmlThrDefIndentTreeOutput extern __typeof (xmlThrDefIndentTreeOutput) xmlThrDefIndentTreeOutput__internal_alias __attribute((visibility("hidden"))); #define xmlThrDefIndentTreeOutput xmlThrDefIndentTreeOutput__internal_alias #endif #endif #ifdef bottom_globals #undef xmlThrDefKeepBlanksDefaultValue extern __typeof (xmlThrDefKeepBlanksDefaultValue) xmlThrDefKeepBlanksDefaultValue __attribute((alias("xmlThrDefKeepBlanksDefaultValue__internal_alias"))); #else #ifndef xmlThrDefKeepBlanksDefaultValue extern __typeof (xmlThrDefKeepBlanksDefaultValue) xmlThrDefKeepBlanksDefaultValue__internal_alias __attribute((visibility("hidden"))); #define xmlThrDefKeepBlanksDefaultValue xmlThrDefKeepBlanksDefaultValue__internal_alias #endif #endif #ifdef bottom_globals #undef xmlThrDefLineNumbersDefaultValue extern __typeof (xmlThrDefLineNumbersDefaultValue) xmlThrDefLineNumbersDefaultValue __attribute((alias("xmlThrDefLineNumbersDefaultValue__internal_alias"))); #else #ifndef xmlThrDefLineNumbersDefaultValue extern __typeof (xmlThrDefLineNumbersDefaultValue) xmlThrDefLineNumbersDefaultValue__internal_alias __attribute((visibility("hidden"))); #define xmlThrDefLineNumbersDefaultValue xmlThrDefLineNumbersDefaultValue__internal_alias #endif #endif #ifdef bottom_globals #undef xmlThrDefLoadExtDtdDefaultValue extern __typeof (xmlThrDefLoadExtDtdDefaultValue) xmlThrDefLoadExtDtdDefaultValue __attribute((alias("xmlThrDefLoadExtDtdDefaultValue__internal_alias"))); #else #ifndef xmlThrDefLoadExtDtdDefaultValue extern __typeof (xmlThrDefLoadExtDtdDefaultValue) xmlThrDefLoadExtDtdDefaultValue__internal_alias __attribute((visibility("hidden"))); #define xmlThrDefLoadExtDtdDefaultValue xmlThrDefLoadExtDtdDefaultValue__internal_alias #endif #endif #ifdef bottom_globals #undef xmlThrDefOutputBufferCreateFilenameDefault extern __typeof (xmlThrDefOutputBufferCreateFilenameDefault) xmlThrDefOutputBufferCreateFilenameDefault __attribute((alias("xmlThrDefOutputBufferCreateFilenameDefault__internal_alias"))); #else #ifndef xmlThrDefOutputBufferCreateFilenameDefault extern __typeof (xmlThrDefOutputBufferCreateFilenameDefault) xmlThrDefOutputBufferCreateFilenameDefault__internal_alias __attribute((visibility("hidden"))); #define xmlThrDefOutputBufferCreateFilenameDefault xmlThrDefOutputBufferCreateFilenameDefault__internal_alias #endif #endif #ifdef bottom_globals #undef xmlThrDefParserDebugEntities extern __typeof (xmlThrDefParserDebugEntities) xmlThrDefParserDebugEntities __attribute((alias("xmlThrDefParserDebugEntities__internal_alias"))); #else #ifndef xmlThrDefParserDebugEntities extern __typeof (xmlThrDefParserDebugEntities) xmlThrDefParserDebugEntities__internal_alias __attribute((visibility("hidden"))); #define xmlThrDefParserDebugEntities xmlThrDefParserDebugEntities__internal_alias #endif #endif #ifdef bottom_globals #undef xmlThrDefParserInputBufferCreateFilenameDefault extern __typeof (xmlThrDefParserInputBufferCreateFilenameDefault) xmlThrDefParserInputBufferCreateFilenameDefault __attribute((alias("xmlThrDefParserInputBufferCreateFilenameDefault__internal_alias"))); #else #ifndef xmlThrDefParserInputBufferCreateFilenameDefault extern __typeof (xmlThrDefParserInputBufferCreateFilenameDefault) xmlThrDefParserInputBufferCreateFilenameDefault__internal_alias __attribute((visibility("hidden"))); #define xmlThrDefParserInputBufferCreateFilenameDefault xmlThrDefParserInputBufferCreateFilenameDefault__internal_alias #endif #endif #ifdef bottom_globals #undef xmlThrDefPedanticParserDefaultValue extern __typeof (xmlThrDefPedanticParserDefaultValue) xmlThrDefPedanticParserDefaultValue __attribute((alias("xmlThrDefPedanticParserDefaultValue__internal_alias"))); #else #ifndef xmlThrDefPedanticParserDefaultValue extern __typeof (xmlThrDefPedanticParserDefaultValue) xmlThrDefPedanticParserDefaultValue__internal_alias __attribute((visibility("hidden"))); #define xmlThrDefPedanticParserDefaultValue xmlThrDefPedanticParserDefaultValue__internal_alias #endif #endif #ifdef bottom_globals #undef xmlThrDefRegisterNodeDefault extern __typeof (xmlThrDefRegisterNodeDefault) xmlThrDefRegisterNodeDefault __attribute((alias("xmlThrDefRegisterNodeDefault__internal_alias"))); #else #ifndef xmlThrDefRegisterNodeDefault extern __typeof (xmlThrDefRegisterNodeDefault) xmlThrDefRegisterNodeDefault__internal_alias __attribute((visibility("hidden"))); #define xmlThrDefRegisterNodeDefault xmlThrDefRegisterNodeDefault__internal_alias #endif #endif #ifdef bottom_globals #undef xmlThrDefSaveNoEmptyTags extern __typeof (xmlThrDefSaveNoEmptyTags) xmlThrDefSaveNoEmptyTags __attribute((alias("xmlThrDefSaveNoEmptyTags__internal_alias"))); #else #ifndef xmlThrDefSaveNoEmptyTags extern __typeof (xmlThrDefSaveNoEmptyTags) xmlThrDefSaveNoEmptyTags__internal_alias __attribute((visibility("hidden"))); #define xmlThrDefSaveNoEmptyTags xmlThrDefSaveNoEmptyTags__internal_alias #endif #endif #ifdef bottom_globals #undef xmlThrDefSetGenericErrorFunc extern __typeof (xmlThrDefSetGenericErrorFunc) xmlThrDefSetGenericErrorFunc __attribute((alias("xmlThrDefSetGenericErrorFunc__internal_alias"))); #else #ifndef xmlThrDefSetGenericErrorFunc extern __typeof (xmlThrDefSetGenericErrorFunc) xmlThrDefSetGenericErrorFunc__internal_alias __attribute((visibility("hidden"))); #define xmlThrDefSetGenericErrorFunc xmlThrDefSetGenericErrorFunc__internal_alias #endif #endif #ifdef bottom_globals #undef xmlThrDefSetStructuredErrorFunc extern __typeof (xmlThrDefSetStructuredErrorFunc) xmlThrDefSetStructuredErrorFunc __attribute((alias("xmlThrDefSetStructuredErrorFunc__internal_alias"))); #else #ifndef xmlThrDefSetStructuredErrorFunc extern __typeof (xmlThrDefSetStructuredErrorFunc) xmlThrDefSetStructuredErrorFunc__internal_alias __attribute((visibility("hidden"))); #define xmlThrDefSetStructuredErrorFunc xmlThrDefSetStructuredErrorFunc__internal_alias #endif #endif #ifdef bottom_globals #undef xmlThrDefSubstituteEntitiesDefaultValue extern __typeof (xmlThrDefSubstituteEntitiesDefaultValue) xmlThrDefSubstituteEntitiesDefaultValue __attribute((alias("xmlThrDefSubstituteEntitiesDefaultValue__internal_alias"))); #else #ifndef xmlThrDefSubstituteEntitiesDefaultValue extern __typeof (xmlThrDefSubstituteEntitiesDefaultValue) xmlThrDefSubstituteEntitiesDefaultValue__internal_alias __attribute((visibility("hidden"))); #define xmlThrDefSubstituteEntitiesDefaultValue xmlThrDefSubstituteEntitiesDefaultValue__internal_alias #endif #endif #ifdef bottom_globals #undef xmlThrDefTreeIndentString extern __typeof (xmlThrDefTreeIndentString) xmlThrDefTreeIndentString __attribute((alias("xmlThrDefTreeIndentString__internal_alias"))); #else #ifndef xmlThrDefTreeIndentString extern __typeof (xmlThrDefTreeIndentString) xmlThrDefTreeIndentString__internal_alias __attribute((visibility("hidden"))); #define xmlThrDefTreeIndentString xmlThrDefTreeIndentString__internal_alias #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsAegeanNumbers extern __typeof (xmlUCSIsAegeanNumbers) xmlUCSIsAegeanNumbers __attribute((alias("xmlUCSIsAegeanNumbers__internal_alias"))); #else #ifndef xmlUCSIsAegeanNumbers extern __typeof (xmlUCSIsAegeanNumbers) xmlUCSIsAegeanNumbers__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsAegeanNumbers xmlUCSIsAegeanNumbers__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsAlphabeticPresentationForms extern __typeof (xmlUCSIsAlphabeticPresentationForms) xmlUCSIsAlphabeticPresentationForms __attribute((alias("xmlUCSIsAlphabeticPresentationForms__internal_alias"))); #else #ifndef xmlUCSIsAlphabeticPresentationForms extern __typeof (xmlUCSIsAlphabeticPresentationForms) xmlUCSIsAlphabeticPresentationForms__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsAlphabeticPresentationForms xmlUCSIsAlphabeticPresentationForms__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsArabic extern __typeof (xmlUCSIsArabic) xmlUCSIsArabic __attribute((alias("xmlUCSIsArabic__internal_alias"))); #else #ifndef xmlUCSIsArabic extern __typeof (xmlUCSIsArabic) xmlUCSIsArabic__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsArabic xmlUCSIsArabic__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsArabicPresentationFormsA extern __typeof (xmlUCSIsArabicPresentationFormsA) xmlUCSIsArabicPresentationFormsA __attribute((alias("xmlUCSIsArabicPresentationFormsA__internal_alias"))); #else #ifndef xmlUCSIsArabicPresentationFormsA extern __typeof (xmlUCSIsArabicPresentationFormsA) xmlUCSIsArabicPresentationFormsA__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsArabicPresentationFormsA xmlUCSIsArabicPresentationFormsA__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsArabicPresentationFormsB extern __typeof (xmlUCSIsArabicPresentationFormsB) xmlUCSIsArabicPresentationFormsB __attribute((alias("xmlUCSIsArabicPresentationFormsB__internal_alias"))); #else #ifndef xmlUCSIsArabicPresentationFormsB extern __typeof (xmlUCSIsArabicPresentationFormsB) xmlUCSIsArabicPresentationFormsB__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsArabicPresentationFormsB xmlUCSIsArabicPresentationFormsB__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsArmenian extern __typeof (xmlUCSIsArmenian) xmlUCSIsArmenian __attribute((alias("xmlUCSIsArmenian__internal_alias"))); #else #ifndef xmlUCSIsArmenian extern __typeof (xmlUCSIsArmenian) xmlUCSIsArmenian__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsArmenian xmlUCSIsArmenian__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsArrows extern __typeof (xmlUCSIsArrows) xmlUCSIsArrows __attribute((alias("xmlUCSIsArrows__internal_alias"))); #else #ifndef xmlUCSIsArrows extern __typeof (xmlUCSIsArrows) xmlUCSIsArrows__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsArrows xmlUCSIsArrows__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsBasicLatin extern __typeof (xmlUCSIsBasicLatin) xmlUCSIsBasicLatin __attribute((alias("xmlUCSIsBasicLatin__internal_alias"))); #else #ifndef xmlUCSIsBasicLatin extern __typeof (xmlUCSIsBasicLatin) xmlUCSIsBasicLatin__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsBasicLatin xmlUCSIsBasicLatin__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsBengali extern __typeof (xmlUCSIsBengali) xmlUCSIsBengali __attribute((alias("xmlUCSIsBengali__internal_alias"))); #else #ifndef xmlUCSIsBengali extern __typeof (xmlUCSIsBengali) xmlUCSIsBengali__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsBengali xmlUCSIsBengali__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsBlock extern __typeof (xmlUCSIsBlock) xmlUCSIsBlock __attribute((alias("xmlUCSIsBlock__internal_alias"))); #else #ifndef xmlUCSIsBlock extern __typeof (xmlUCSIsBlock) xmlUCSIsBlock__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsBlock xmlUCSIsBlock__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsBlockElements extern __typeof (xmlUCSIsBlockElements) xmlUCSIsBlockElements __attribute((alias("xmlUCSIsBlockElements__internal_alias"))); #else #ifndef xmlUCSIsBlockElements extern __typeof (xmlUCSIsBlockElements) xmlUCSIsBlockElements__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsBlockElements xmlUCSIsBlockElements__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsBopomofo extern __typeof (xmlUCSIsBopomofo) xmlUCSIsBopomofo __attribute((alias("xmlUCSIsBopomofo__internal_alias"))); #else #ifndef xmlUCSIsBopomofo extern __typeof (xmlUCSIsBopomofo) xmlUCSIsBopomofo__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsBopomofo xmlUCSIsBopomofo__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsBopomofoExtended extern __typeof (xmlUCSIsBopomofoExtended) xmlUCSIsBopomofoExtended __attribute((alias("xmlUCSIsBopomofoExtended__internal_alias"))); #else #ifndef xmlUCSIsBopomofoExtended extern __typeof (xmlUCSIsBopomofoExtended) xmlUCSIsBopomofoExtended__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsBopomofoExtended xmlUCSIsBopomofoExtended__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsBoxDrawing extern __typeof (xmlUCSIsBoxDrawing) xmlUCSIsBoxDrawing __attribute((alias("xmlUCSIsBoxDrawing__internal_alias"))); #else #ifndef xmlUCSIsBoxDrawing extern __typeof (xmlUCSIsBoxDrawing) xmlUCSIsBoxDrawing__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsBoxDrawing xmlUCSIsBoxDrawing__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsBraillePatterns extern __typeof (xmlUCSIsBraillePatterns) xmlUCSIsBraillePatterns __attribute((alias("xmlUCSIsBraillePatterns__internal_alias"))); #else #ifndef xmlUCSIsBraillePatterns extern __typeof (xmlUCSIsBraillePatterns) xmlUCSIsBraillePatterns__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsBraillePatterns xmlUCSIsBraillePatterns__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsBuhid extern __typeof (xmlUCSIsBuhid) xmlUCSIsBuhid __attribute((alias("xmlUCSIsBuhid__internal_alias"))); #else #ifndef xmlUCSIsBuhid extern __typeof (xmlUCSIsBuhid) xmlUCSIsBuhid__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsBuhid xmlUCSIsBuhid__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsByzantineMusicalSymbols extern __typeof (xmlUCSIsByzantineMusicalSymbols) xmlUCSIsByzantineMusicalSymbols __attribute((alias("xmlUCSIsByzantineMusicalSymbols__internal_alias"))); #else #ifndef xmlUCSIsByzantineMusicalSymbols extern __typeof (xmlUCSIsByzantineMusicalSymbols) xmlUCSIsByzantineMusicalSymbols__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsByzantineMusicalSymbols xmlUCSIsByzantineMusicalSymbols__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCJKCompatibility extern __typeof (xmlUCSIsCJKCompatibility) xmlUCSIsCJKCompatibility __attribute((alias("xmlUCSIsCJKCompatibility__internal_alias"))); #else #ifndef xmlUCSIsCJKCompatibility extern __typeof (xmlUCSIsCJKCompatibility) xmlUCSIsCJKCompatibility__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCJKCompatibility xmlUCSIsCJKCompatibility__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCJKCompatibilityForms extern __typeof (xmlUCSIsCJKCompatibilityForms) xmlUCSIsCJKCompatibilityForms __attribute((alias("xmlUCSIsCJKCompatibilityForms__internal_alias"))); #else #ifndef xmlUCSIsCJKCompatibilityForms extern __typeof (xmlUCSIsCJKCompatibilityForms) xmlUCSIsCJKCompatibilityForms__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCJKCompatibilityForms xmlUCSIsCJKCompatibilityForms__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCJKCompatibilityIdeographs extern __typeof (xmlUCSIsCJKCompatibilityIdeographs) xmlUCSIsCJKCompatibilityIdeographs __attribute((alias("xmlUCSIsCJKCompatibilityIdeographs__internal_alias"))); #else #ifndef xmlUCSIsCJKCompatibilityIdeographs extern __typeof (xmlUCSIsCJKCompatibilityIdeographs) xmlUCSIsCJKCompatibilityIdeographs__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCJKCompatibilityIdeographs xmlUCSIsCJKCompatibilityIdeographs__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCJKCompatibilityIdeographsSupplement extern __typeof (xmlUCSIsCJKCompatibilityIdeographsSupplement) xmlUCSIsCJKCompatibilityIdeographsSupplement __attribute((alias("xmlUCSIsCJKCompatibilityIdeographsSupplement__internal_alias"))); #else #ifndef xmlUCSIsCJKCompatibilityIdeographsSupplement extern __typeof (xmlUCSIsCJKCompatibilityIdeographsSupplement) xmlUCSIsCJKCompatibilityIdeographsSupplement__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCJKCompatibilityIdeographsSupplement xmlUCSIsCJKCompatibilityIdeographsSupplement__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCJKRadicalsSupplement extern __typeof (xmlUCSIsCJKRadicalsSupplement) xmlUCSIsCJKRadicalsSupplement __attribute((alias("xmlUCSIsCJKRadicalsSupplement__internal_alias"))); #else #ifndef xmlUCSIsCJKRadicalsSupplement extern __typeof (xmlUCSIsCJKRadicalsSupplement) xmlUCSIsCJKRadicalsSupplement__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCJKRadicalsSupplement xmlUCSIsCJKRadicalsSupplement__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCJKSymbolsandPunctuation extern __typeof (xmlUCSIsCJKSymbolsandPunctuation) xmlUCSIsCJKSymbolsandPunctuation __attribute((alias("xmlUCSIsCJKSymbolsandPunctuation__internal_alias"))); #else #ifndef xmlUCSIsCJKSymbolsandPunctuation extern __typeof (xmlUCSIsCJKSymbolsandPunctuation) xmlUCSIsCJKSymbolsandPunctuation__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCJKSymbolsandPunctuation xmlUCSIsCJKSymbolsandPunctuation__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCJKUnifiedIdeographs extern __typeof (xmlUCSIsCJKUnifiedIdeographs) xmlUCSIsCJKUnifiedIdeographs __attribute((alias("xmlUCSIsCJKUnifiedIdeographs__internal_alias"))); #else #ifndef xmlUCSIsCJKUnifiedIdeographs extern __typeof (xmlUCSIsCJKUnifiedIdeographs) xmlUCSIsCJKUnifiedIdeographs__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCJKUnifiedIdeographs xmlUCSIsCJKUnifiedIdeographs__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCJKUnifiedIdeographsExtensionA extern __typeof (xmlUCSIsCJKUnifiedIdeographsExtensionA) xmlUCSIsCJKUnifiedIdeographsExtensionA __attribute((alias("xmlUCSIsCJKUnifiedIdeographsExtensionA__internal_alias"))); #else #ifndef xmlUCSIsCJKUnifiedIdeographsExtensionA extern __typeof (xmlUCSIsCJKUnifiedIdeographsExtensionA) xmlUCSIsCJKUnifiedIdeographsExtensionA__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCJKUnifiedIdeographsExtensionA xmlUCSIsCJKUnifiedIdeographsExtensionA__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCJKUnifiedIdeographsExtensionB extern __typeof (xmlUCSIsCJKUnifiedIdeographsExtensionB) xmlUCSIsCJKUnifiedIdeographsExtensionB __attribute((alias("xmlUCSIsCJKUnifiedIdeographsExtensionB__internal_alias"))); #else #ifndef xmlUCSIsCJKUnifiedIdeographsExtensionB extern __typeof (xmlUCSIsCJKUnifiedIdeographsExtensionB) xmlUCSIsCJKUnifiedIdeographsExtensionB__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCJKUnifiedIdeographsExtensionB xmlUCSIsCJKUnifiedIdeographsExtensionB__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCat extern __typeof (xmlUCSIsCat) xmlUCSIsCat __attribute((alias("xmlUCSIsCat__internal_alias"))); #else #ifndef xmlUCSIsCat extern __typeof (xmlUCSIsCat) xmlUCSIsCat__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCat xmlUCSIsCat__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCatC extern __typeof (xmlUCSIsCatC) xmlUCSIsCatC __attribute((alias("xmlUCSIsCatC__internal_alias"))); #else #ifndef xmlUCSIsCatC extern __typeof (xmlUCSIsCatC) xmlUCSIsCatC__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCatC xmlUCSIsCatC__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCatCc extern __typeof (xmlUCSIsCatCc) xmlUCSIsCatCc __attribute((alias("xmlUCSIsCatCc__internal_alias"))); #else #ifndef xmlUCSIsCatCc extern __typeof (xmlUCSIsCatCc) xmlUCSIsCatCc__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCatCc xmlUCSIsCatCc__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCatCf extern __typeof (xmlUCSIsCatCf) xmlUCSIsCatCf __attribute((alias("xmlUCSIsCatCf__internal_alias"))); #else #ifndef xmlUCSIsCatCf extern __typeof (xmlUCSIsCatCf) xmlUCSIsCatCf__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCatCf xmlUCSIsCatCf__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCatCo extern __typeof (xmlUCSIsCatCo) xmlUCSIsCatCo __attribute((alias("xmlUCSIsCatCo__internal_alias"))); #else #ifndef xmlUCSIsCatCo extern __typeof (xmlUCSIsCatCo) xmlUCSIsCatCo__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCatCo xmlUCSIsCatCo__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCatCs extern __typeof (xmlUCSIsCatCs) xmlUCSIsCatCs __attribute((alias("xmlUCSIsCatCs__internal_alias"))); #else #ifndef xmlUCSIsCatCs extern __typeof (xmlUCSIsCatCs) xmlUCSIsCatCs__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCatCs xmlUCSIsCatCs__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCatL extern __typeof (xmlUCSIsCatL) xmlUCSIsCatL __attribute((alias("xmlUCSIsCatL__internal_alias"))); #else #ifndef xmlUCSIsCatL extern __typeof (xmlUCSIsCatL) xmlUCSIsCatL__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCatL xmlUCSIsCatL__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCatLl extern __typeof (xmlUCSIsCatLl) xmlUCSIsCatLl __attribute((alias("xmlUCSIsCatLl__internal_alias"))); #else #ifndef xmlUCSIsCatLl extern __typeof (xmlUCSIsCatLl) xmlUCSIsCatLl__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCatLl xmlUCSIsCatLl__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCatLm extern __typeof (xmlUCSIsCatLm) xmlUCSIsCatLm __attribute((alias("xmlUCSIsCatLm__internal_alias"))); #else #ifndef xmlUCSIsCatLm extern __typeof (xmlUCSIsCatLm) xmlUCSIsCatLm__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCatLm xmlUCSIsCatLm__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCatLo extern __typeof (xmlUCSIsCatLo) xmlUCSIsCatLo __attribute((alias("xmlUCSIsCatLo__internal_alias"))); #else #ifndef xmlUCSIsCatLo extern __typeof (xmlUCSIsCatLo) xmlUCSIsCatLo__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCatLo xmlUCSIsCatLo__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCatLt extern __typeof (xmlUCSIsCatLt) xmlUCSIsCatLt __attribute((alias("xmlUCSIsCatLt__internal_alias"))); #else #ifndef xmlUCSIsCatLt extern __typeof (xmlUCSIsCatLt) xmlUCSIsCatLt__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCatLt xmlUCSIsCatLt__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCatLu extern __typeof (xmlUCSIsCatLu) xmlUCSIsCatLu __attribute((alias("xmlUCSIsCatLu__internal_alias"))); #else #ifndef xmlUCSIsCatLu extern __typeof (xmlUCSIsCatLu) xmlUCSIsCatLu__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCatLu xmlUCSIsCatLu__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCatM extern __typeof (xmlUCSIsCatM) xmlUCSIsCatM __attribute((alias("xmlUCSIsCatM__internal_alias"))); #else #ifndef xmlUCSIsCatM extern __typeof (xmlUCSIsCatM) xmlUCSIsCatM__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCatM xmlUCSIsCatM__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCatMc extern __typeof (xmlUCSIsCatMc) xmlUCSIsCatMc __attribute((alias("xmlUCSIsCatMc__internal_alias"))); #else #ifndef xmlUCSIsCatMc extern __typeof (xmlUCSIsCatMc) xmlUCSIsCatMc__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCatMc xmlUCSIsCatMc__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCatMe extern __typeof (xmlUCSIsCatMe) xmlUCSIsCatMe __attribute((alias("xmlUCSIsCatMe__internal_alias"))); #else #ifndef xmlUCSIsCatMe extern __typeof (xmlUCSIsCatMe) xmlUCSIsCatMe__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCatMe xmlUCSIsCatMe__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCatMn extern __typeof (xmlUCSIsCatMn) xmlUCSIsCatMn __attribute((alias("xmlUCSIsCatMn__internal_alias"))); #else #ifndef xmlUCSIsCatMn extern __typeof (xmlUCSIsCatMn) xmlUCSIsCatMn__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCatMn xmlUCSIsCatMn__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCatN extern __typeof (xmlUCSIsCatN) xmlUCSIsCatN __attribute((alias("xmlUCSIsCatN__internal_alias"))); #else #ifndef xmlUCSIsCatN extern __typeof (xmlUCSIsCatN) xmlUCSIsCatN__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCatN xmlUCSIsCatN__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCatNd extern __typeof (xmlUCSIsCatNd) xmlUCSIsCatNd __attribute((alias("xmlUCSIsCatNd__internal_alias"))); #else #ifndef xmlUCSIsCatNd extern __typeof (xmlUCSIsCatNd) xmlUCSIsCatNd__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCatNd xmlUCSIsCatNd__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCatNl extern __typeof (xmlUCSIsCatNl) xmlUCSIsCatNl __attribute((alias("xmlUCSIsCatNl__internal_alias"))); #else #ifndef xmlUCSIsCatNl extern __typeof (xmlUCSIsCatNl) xmlUCSIsCatNl__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCatNl xmlUCSIsCatNl__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCatNo extern __typeof (xmlUCSIsCatNo) xmlUCSIsCatNo __attribute((alias("xmlUCSIsCatNo__internal_alias"))); #else #ifndef xmlUCSIsCatNo extern __typeof (xmlUCSIsCatNo) xmlUCSIsCatNo__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCatNo xmlUCSIsCatNo__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCatP extern __typeof (xmlUCSIsCatP) xmlUCSIsCatP __attribute((alias("xmlUCSIsCatP__internal_alias"))); #else #ifndef xmlUCSIsCatP extern __typeof (xmlUCSIsCatP) xmlUCSIsCatP__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCatP xmlUCSIsCatP__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCatPc extern __typeof (xmlUCSIsCatPc) xmlUCSIsCatPc __attribute((alias("xmlUCSIsCatPc__internal_alias"))); #else #ifndef xmlUCSIsCatPc extern __typeof (xmlUCSIsCatPc) xmlUCSIsCatPc__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCatPc xmlUCSIsCatPc__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCatPd extern __typeof (xmlUCSIsCatPd) xmlUCSIsCatPd __attribute((alias("xmlUCSIsCatPd__internal_alias"))); #else #ifndef xmlUCSIsCatPd extern __typeof (xmlUCSIsCatPd) xmlUCSIsCatPd__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCatPd xmlUCSIsCatPd__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCatPe extern __typeof (xmlUCSIsCatPe) xmlUCSIsCatPe __attribute((alias("xmlUCSIsCatPe__internal_alias"))); #else #ifndef xmlUCSIsCatPe extern __typeof (xmlUCSIsCatPe) xmlUCSIsCatPe__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCatPe xmlUCSIsCatPe__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCatPf extern __typeof (xmlUCSIsCatPf) xmlUCSIsCatPf __attribute((alias("xmlUCSIsCatPf__internal_alias"))); #else #ifndef xmlUCSIsCatPf extern __typeof (xmlUCSIsCatPf) xmlUCSIsCatPf__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCatPf xmlUCSIsCatPf__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCatPi extern __typeof (xmlUCSIsCatPi) xmlUCSIsCatPi __attribute((alias("xmlUCSIsCatPi__internal_alias"))); #else #ifndef xmlUCSIsCatPi extern __typeof (xmlUCSIsCatPi) xmlUCSIsCatPi__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCatPi xmlUCSIsCatPi__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCatPo extern __typeof (xmlUCSIsCatPo) xmlUCSIsCatPo __attribute((alias("xmlUCSIsCatPo__internal_alias"))); #else #ifndef xmlUCSIsCatPo extern __typeof (xmlUCSIsCatPo) xmlUCSIsCatPo__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCatPo xmlUCSIsCatPo__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCatPs extern __typeof (xmlUCSIsCatPs) xmlUCSIsCatPs __attribute((alias("xmlUCSIsCatPs__internal_alias"))); #else #ifndef xmlUCSIsCatPs extern __typeof (xmlUCSIsCatPs) xmlUCSIsCatPs__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCatPs xmlUCSIsCatPs__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCatS extern __typeof (xmlUCSIsCatS) xmlUCSIsCatS __attribute((alias("xmlUCSIsCatS__internal_alias"))); #else #ifndef xmlUCSIsCatS extern __typeof (xmlUCSIsCatS) xmlUCSIsCatS__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCatS xmlUCSIsCatS__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCatSc extern __typeof (xmlUCSIsCatSc) xmlUCSIsCatSc __attribute((alias("xmlUCSIsCatSc__internal_alias"))); #else #ifndef xmlUCSIsCatSc extern __typeof (xmlUCSIsCatSc) xmlUCSIsCatSc__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCatSc xmlUCSIsCatSc__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCatSk extern __typeof (xmlUCSIsCatSk) xmlUCSIsCatSk __attribute((alias("xmlUCSIsCatSk__internal_alias"))); #else #ifndef xmlUCSIsCatSk extern __typeof (xmlUCSIsCatSk) xmlUCSIsCatSk__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCatSk xmlUCSIsCatSk__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCatSm extern __typeof (xmlUCSIsCatSm) xmlUCSIsCatSm __attribute((alias("xmlUCSIsCatSm__internal_alias"))); #else #ifndef xmlUCSIsCatSm extern __typeof (xmlUCSIsCatSm) xmlUCSIsCatSm__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCatSm xmlUCSIsCatSm__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCatSo extern __typeof (xmlUCSIsCatSo) xmlUCSIsCatSo __attribute((alias("xmlUCSIsCatSo__internal_alias"))); #else #ifndef xmlUCSIsCatSo extern __typeof (xmlUCSIsCatSo) xmlUCSIsCatSo__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCatSo xmlUCSIsCatSo__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCatZ extern __typeof (xmlUCSIsCatZ) xmlUCSIsCatZ __attribute((alias("xmlUCSIsCatZ__internal_alias"))); #else #ifndef xmlUCSIsCatZ extern __typeof (xmlUCSIsCatZ) xmlUCSIsCatZ__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCatZ xmlUCSIsCatZ__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCatZl extern __typeof (xmlUCSIsCatZl) xmlUCSIsCatZl __attribute((alias("xmlUCSIsCatZl__internal_alias"))); #else #ifndef xmlUCSIsCatZl extern __typeof (xmlUCSIsCatZl) xmlUCSIsCatZl__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCatZl xmlUCSIsCatZl__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCatZp extern __typeof (xmlUCSIsCatZp) xmlUCSIsCatZp __attribute((alias("xmlUCSIsCatZp__internal_alias"))); #else #ifndef xmlUCSIsCatZp extern __typeof (xmlUCSIsCatZp) xmlUCSIsCatZp__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCatZp xmlUCSIsCatZp__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCatZs extern __typeof (xmlUCSIsCatZs) xmlUCSIsCatZs __attribute((alias("xmlUCSIsCatZs__internal_alias"))); #else #ifndef xmlUCSIsCatZs extern __typeof (xmlUCSIsCatZs) xmlUCSIsCatZs__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCatZs xmlUCSIsCatZs__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCherokee extern __typeof (xmlUCSIsCherokee) xmlUCSIsCherokee __attribute((alias("xmlUCSIsCherokee__internal_alias"))); #else #ifndef xmlUCSIsCherokee extern __typeof (xmlUCSIsCherokee) xmlUCSIsCherokee__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCherokee xmlUCSIsCherokee__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCombiningDiacriticalMarks extern __typeof (xmlUCSIsCombiningDiacriticalMarks) xmlUCSIsCombiningDiacriticalMarks __attribute((alias("xmlUCSIsCombiningDiacriticalMarks__internal_alias"))); #else #ifndef xmlUCSIsCombiningDiacriticalMarks extern __typeof (xmlUCSIsCombiningDiacriticalMarks) xmlUCSIsCombiningDiacriticalMarks__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCombiningDiacriticalMarks xmlUCSIsCombiningDiacriticalMarks__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCombiningDiacriticalMarksforSymbols extern __typeof (xmlUCSIsCombiningDiacriticalMarksforSymbols) xmlUCSIsCombiningDiacriticalMarksforSymbols __attribute((alias("xmlUCSIsCombiningDiacriticalMarksforSymbols__internal_alias"))); #else #ifndef xmlUCSIsCombiningDiacriticalMarksforSymbols extern __typeof (xmlUCSIsCombiningDiacriticalMarksforSymbols) xmlUCSIsCombiningDiacriticalMarksforSymbols__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCombiningDiacriticalMarksforSymbols xmlUCSIsCombiningDiacriticalMarksforSymbols__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCombiningHalfMarks extern __typeof (xmlUCSIsCombiningHalfMarks) xmlUCSIsCombiningHalfMarks __attribute((alias("xmlUCSIsCombiningHalfMarks__internal_alias"))); #else #ifndef xmlUCSIsCombiningHalfMarks extern __typeof (xmlUCSIsCombiningHalfMarks) xmlUCSIsCombiningHalfMarks__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCombiningHalfMarks xmlUCSIsCombiningHalfMarks__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCombiningMarksforSymbols extern __typeof (xmlUCSIsCombiningMarksforSymbols) xmlUCSIsCombiningMarksforSymbols __attribute((alias("xmlUCSIsCombiningMarksforSymbols__internal_alias"))); #else #ifndef xmlUCSIsCombiningMarksforSymbols extern __typeof (xmlUCSIsCombiningMarksforSymbols) xmlUCSIsCombiningMarksforSymbols__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCombiningMarksforSymbols xmlUCSIsCombiningMarksforSymbols__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsControlPictures extern __typeof (xmlUCSIsControlPictures) xmlUCSIsControlPictures __attribute((alias("xmlUCSIsControlPictures__internal_alias"))); #else #ifndef xmlUCSIsControlPictures extern __typeof (xmlUCSIsControlPictures) xmlUCSIsControlPictures__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsControlPictures xmlUCSIsControlPictures__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCurrencySymbols extern __typeof (xmlUCSIsCurrencySymbols) xmlUCSIsCurrencySymbols __attribute((alias("xmlUCSIsCurrencySymbols__internal_alias"))); #else #ifndef xmlUCSIsCurrencySymbols extern __typeof (xmlUCSIsCurrencySymbols) xmlUCSIsCurrencySymbols__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCurrencySymbols xmlUCSIsCurrencySymbols__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCypriotSyllabary extern __typeof (xmlUCSIsCypriotSyllabary) xmlUCSIsCypriotSyllabary __attribute((alias("xmlUCSIsCypriotSyllabary__internal_alias"))); #else #ifndef xmlUCSIsCypriotSyllabary extern __typeof (xmlUCSIsCypriotSyllabary) xmlUCSIsCypriotSyllabary__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCypriotSyllabary xmlUCSIsCypriotSyllabary__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCyrillic extern __typeof (xmlUCSIsCyrillic) xmlUCSIsCyrillic __attribute((alias("xmlUCSIsCyrillic__internal_alias"))); #else #ifndef xmlUCSIsCyrillic extern __typeof (xmlUCSIsCyrillic) xmlUCSIsCyrillic__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCyrillic xmlUCSIsCyrillic__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsCyrillicSupplement extern __typeof (xmlUCSIsCyrillicSupplement) xmlUCSIsCyrillicSupplement __attribute((alias("xmlUCSIsCyrillicSupplement__internal_alias"))); #else #ifndef xmlUCSIsCyrillicSupplement extern __typeof (xmlUCSIsCyrillicSupplement) xmlUCSIsCyrillicSupplement__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsCyrillicSupplement xmlUCSIsCyrillicSupplement__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsDeseret extern __typeof (xmlUCSIsDeseret) xmlUCSIsDeseret __attribute((alias("xmlUCSIsDeseret__internal_alias"))); #else #ifndef xmlUCSIsDeseret extern __typeof (xmlUCSIsDeseret) xmlUCSIsDeseret__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsDeseret xmlUCSIsDeseret__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsDevanagari extern __typeof (xmlUCSIsDevanagari) xmlUCSIsDevanagari __attribute((alias("xmlUCSIsDevanagari__internal_alias"))); #else #ifndef xmlUCSIsDevanagari extern __typeof (xmlUCSIsDevanagari) xmlUCSIsDevanagari__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsDevanagari xmlUCSIsDevanagari__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsDingbats extern __typeof (xmlUCSIsDingbats) xmlUCSIsDingbats __attribute((alias("xmlUCSIsDingbats__internal_alias"))); #else #ifndef xmlUCSIsDingbats extern __typeof (xmlUCSIsDingbats) xmlUCSIsDingbats__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsDingbats xmlUCSIsDingbats__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsEnclosedAlphanumerics extern __typeof (xmlUCSIsEnclosedAlphanumerics) xmlUCSIsEnclosedAlphanumerics __attribute((alias("xmlUCSIsEnclosedAlphanumerics__internal_alias"))); #else #ifndef xmlUCSIsEnclosedAlphanumerics extern __typeof (xmlUCSIsEnclosedAlphanumerics) xmlUCSIsEnclosedAlphanumerics__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsEnclosedAlphanumerics xmlUCSIsEnclosedAlphanumerics__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsEnclosedCJKLettersandMonths extern __typeof (xmlUCSIsEnclosedCJKLettersandMonths) xmlUCSIsEnclosedCJKLettersandMonths __attribute((alias("xmlUCSIsEnclosedCJKLettersandMonths__internal_alias"))); #else #ifndef xmlUCSIsEnclosedCJKLettersandMonths extern __typeof (xmlUCSIsEnclosedCJKLettersandMonths) xmlUCSIsEnclosedCJKLettersandMonths__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsEnclosedCJKLettersandMonths xmlUCSIsEnclosedCJKLettersandMonths__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsEthiopic extern __typeof (xmlUCSIsEthiopic) xmlUCSIsEthiopic __attribute((alias("xmlUCSIsEthiopic__internal_alias"))); #else #ifndef xmlUCSIsEthiopic extern __typeof (xmlUCSIsEthiopic) xmlUCSIsEthiopic__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsEthiopic xmlUCSIsEthiopic__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsGeneralPunctuation extern __typeof (xmlUCSIsGeneralPunctuation) xmlUCSIsGeneralPunctuation __attribute((alias("xmlUCSIsGeneralPunctuation__internal_alias"))); #else #ifndef xmlUCSIsGeneralPunctuation extern __typeof (xmlUCSIsGeneralPunctuation) xmlUCSIsGeneralPunctuation__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsGeneralPunctuation xmlUCSIsGeneralPunctuation__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsGeometricShapes extern __typeof (xmlUCSIsGeometricShapes) xmlUCSIsGeometricShapes __attribute((alias("xmlUCSIsGeometricShapes__internal_alias"))); #else #ifndef xmlUCSIsGeometricShapes extern __typeof (xmlUCSIsGeometricShapes) xmlUCSIsGeometricShapes__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsGeometricShapes xmlUCSIsGeometricShapes__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsGeorgian extern __typeof (xmlUCSIsGeorgian) xmlUCSIsGeorgian __attribute((alias("xmlUCSIsGeorgian__internal_alias"))); #else #ifndef xmlUCSIsGeorgian extern __typeof (xmlUCSIsGeorgian) xmlUCSIsGeorgian__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsGeorgian xmlUCSIsGeorgian__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsGothic extern __typeof (xmlUCSIsGothic) xmlUCSIsGothic __attribute((alias("xmlUCSIsGothic__internal_alias"))); #else #ifndef xmlUCSIsGothic extern __typeof (xmlUCSIsGothic) xmlUCSIsGothic__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsGothic xmlUCSIsGothic__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsGreek extern __typeof (xmlUCSIsGreek) xmlUCSIsGreek __attribute((alias("xmlUCSIsGreek__internal_alias"))); #else #ifndef xmlUCSIsGreek extern __typeof (xmlUCSIsGreek) xmlUCSIsGreek__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsGreek xmlUCSIsGreek__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsGreekExtended extern __typeof (xmlUCSIsGreekExtended) xmlUCSIsGreekExtended __attribute((alias("xmlUCSIsGreekExtended__internal_alias"))); #else #ifndef xmlUCSIsGreekExtended extern __typeof (xmlUCSIsGreekExtended) xmlUCSIsGreekExtended__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsGreekExtended xmlUCSIsGreekExtended__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsGreekandCoptic extern __typeof (xmlUCSIsGreekandCoptic) xmlUCSIsGreekandCoptic __attribute((alias("xmlUCSIsGreekandCoptic__internal_alias"))); #else #ifndef xmlUCSIsGreekandCoptic extern __typeof (xmlUCSIsGreekandCoptic) xmlUCSIsGreekandCoptic__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsGreekandCoptic xmlUCSIsGreekandCoptic__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsGujarati extern __typeof (xmlUCSIsGujarati) xmlUCSIsGujarati __attribute((alias("xmlUCSIsGujarati__internal_alias"))); #else #ifndef xmlUCSIsGujarati extern __typeof (xmlUCSIsGujarati) xmlUCSIsGujarati__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsGujarati xmlUCSIsGujarati__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsGurmukhi extern __typeof (xmlUCSIsGurmukhi) xmlUCSIsGurmukhi __attribute((alias("xmlUCSIsGurmukhi__internal_alias"))); #else #ifndef xmlUCSIsGurmukhi extern __typeof (xmlUCSIsGurmukhi) xmlUCSIsGurmukhi__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsGurmukhi xmlUCSIsGurmukhi__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsHalfwidthandFullwidthForms extern __typeof (xmlUCSIsHalfwidthandFullwidthForms) xmlUCSIsHalfwidthandFullwidthForms __attribute((alias("xmlUCSIsHalfwidthandFullwidthForms__internal_alias"))); #else #ifndef xmlUCSIsHalfwidthandFullwidthForms extern __typeof (xmlUCSIsHalfwidthandFullwidthForms) xmlUCSIsHalfwidthandFullwidthForms__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsHalfwidthandFullwidthForms xmlUCSIsHalfwidthandFullwidthForms__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsHangulCompatibilityJamo extern __typeof (xmlUCSIsHangulCompatibilityJamo) xmlUCSIsHangulCompatibilityJamo __attribute((alias("xmlUCSIsHangulCompatibilityJamo__internal_alias"))); #else #ifndef xmlUCSIsHangulCompatibilityJamo extern __typeof (xmlUCSIsHangulCompatibilityJamo) xmlUCSIsHangulCompatibilityJamo__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsHangulCompatibilityJamo xmlUCSIsHangulCompatibilityJamo__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsHangulJamo extern __typeof (xmlUCSIsHangulJamo) xmlUCSIsHangulJamo __attribute((alias("xmlUCSIsHangulJamo__internal_alias"))); #else #ifndef xmlUCSIsHangulJamo extern __typeof (xmlUCSIsHangulJamo) xmlUCSIsHangulJamo__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsHangulJamo xmlUCSIsHangulJamo__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsHangulSyllables extern __typeof (xmlUCSIsHangulSyllables) xmlUCSIsHangulSyllables __attribute((alias("xmlUCSIsHangulSyllables__internal_alias"))); #else #ifndef xmlUCSIsHangulSyllables extern __typeof (xmlUCSIsHangulSyllables) xmlUCSIsHangulSyllables__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsHangulSyllables xmlUCSIsHangulSyllables__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsHanunoo extern __typeof (xmlUCSIsHanunoo) xmlUCSIsHanunoo __attribute((alias("xmlUCSIsHanunoo__internal_alias"))); #else #ifndef xmlUCSIsHanunoo extern __typeof (xmlUCSIsHanunoo) xmlUCSIsHanunoo__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsHanunoo xmlUCSIsHanunoo__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsHebrew extern __typeof (xmlUCSIsHebrew) xmlUCSIsHebrew __attribute((alias("xmlUCSIsHebrew__internal_alias"))); #else #ifndef xmlUCSIsHebrew extern __typeof (xmlUCSIsHebrew) xmlUCSIsHebrew__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsHebrew xmlUCSIsHebrew__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsHighPrivateUseSurrogates extern __typeof (xmlUCSIsHighPrivateUseSurrogates) xmlUCSIsHighPrivateUseSurrogates __attribute((alias("xmlUCSIsHighPrivateUseSurrogates__internal_alias"))); #else #ifndef xmlUCSIsHighPrivateUseSurrogates extern __typeof (xmlUCSIsHighPrivateUseSurrogates) xmlUCSIsHighPrivateUseSurrogates__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsHighPrivateUseSurrogates xmlUCSIsHighPrivateUseSurrogates__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsHighSurrogates extern __typeof (xmlUCSIsHighSurrogates) xmlUCSIsHighSurrogates __attribute((alias("xmlUCSIsHighSurrogates__internal_alias"))); #else #ifndef xmlUCSIsHighSurrogates extern __typeof (xmlUCSIsHighSurrogates) xmlUCSIsHighSurrogates__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsHighSurrogates xmlUCSIsHighSurrogates__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsHiragana extern __typeof (xmlUCSIsHiragana) xmlUCSIsHiragana __attribute((alias("xmlUCSIsHiragana__internal_alias"))); #else #ifndef xmlUCSIsHiragana extern __typeof (xmlUCSIsHiragana) xmlUCSIsHiragana__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsHiragana xmlUCSIsHiragana__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsIPAExtensions extern __typeof (xmlUCSIsIPAExtensions) xmlUCSIsIPAExtensions __attribute((alias("xmlUCSIsIPAExtensions__internal_alias"))); #else #ifndef xmlUCSIsIPAExtensions extern __typeof (xmlUCSIsIPAExtensions) xmlUCSIsIPAExtensions__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsIPAExtensions xmlUCSIsIPAExtensions__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsIdeographicDescriptionCharacters extern __typeof (xmlUCSIsIdeographicDescriptionCharacters) xmlUCSIsIdeographicDescriptionCharacters __attribute((alias("xmlUCSIsIdeographicDescriptionCharacters__internal_alias"))); #else #ifndef xmlUCSIsIdeographicDescriptionCharacters extern __typeof (xmlUCSIsIdeographicDescriptionCharacters) xmlUCSIsIdeographicDescriptionCharacters__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsIdeographicDescriptionCharacters xmlUCSIsIdeographicDescriptionCharacters__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsKanbun extern __typeof (xmlUCSIsKanbun) xmlUCSIsKanbun __attribute((alias("xmlUCSIsKanbun__internal_alias"))); #else #ifndef xmlUCSIsKanbun extern __typeof (xmlUCSIsKanbun) xmlUCSIsKanbun__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsKanbun xmlUCSIsKanbun__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsKangxiRadicals extern __typeof (xmlUCSIsKangxiRadicals) xmlUCSIsKangxiRadicals __attribute((alias("xmlUCSIsKangxiRadicals__internal_alias"))); #else #ifndef xmlUCSIsKangxiRadicals extern __typeof (xmlUCSIsKangxiRadicals) xmlUCSIsKangxiRadicals__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsKangxiRadicals xmlUCSIsKangxiRadicals__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsKannada extern __typeof (xmlUCSIsKannada) xmlUCSIsKannada __attribute((alias("xmlUCSIsKannada__internal_alias"))); #else #ifndef xmlUCSIsKannada extern __typeof (xmlUCSIsKannada) xmlUCSIsKannada__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsKannada xmlUCSIsKannada__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsKatakana extern __typeof (xmlUCSIsKatakana) xmlUCSIsKatakana __attribute((alias("xmlUCSIsKatakana__internal_alias"))); #else #ifndef xmlUCSIsKatakana extern __typeof (xmlUCSIsKatakana) xmlUCSIsKatakana__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsKatakana xmlUCSIsKatakana__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsKatakanaPhoneticExtensions extern __typeof (xmlUCSIsKatakanaPhoneticExtensions) xmlUCSIsKatakanaPhoneticExtensions __attribute((alias("xmlUCSIsKatakanaPhoneticExtensions__internal_alias"))); #else #ifndef xmlUCSIsKatakanaPhoneticExtensions extern __typeof (xmlUCSIsKatakanaPhoneticExtensions) xmlUCSIsKatakanaPhoneticExtensions__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsKatakanaPhoneticExtensions xmlUCSIsKatakanaPhoneticExtensions__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsKhmer extern __typeof (xmlUCSIsKhmer) xmlUCSIsKhmer __attribute((alias("xmlUCSIsKhmer__internal_alias"))); #else #ifndef xmlUCSIsKhmer extern __typeof (xmlUCSIsKhmer) xmlUCSIsKhmer__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsKhmer xmlUCSIsKhmer__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsKhmerSymbols extern __typeof (xmlUCSIsKhmerSymbols) xmlUCSIsKhmerSymbols __attribute((alias("xmlUCSIsKhmerSymbols__internal_alias"))); #else #ifndef xmlUCSIsKhmerSymbols extern __typeof (xmlUCSIsKhmerSymbols) xmlUCSIsKhmerSymbols__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsKhmerSymbols xmlUCSIsKhmerSymbols__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsLao extern __typeof (xmlUCSIsLao) xmlUCSIsLao __attribute((alias("xmlUCSIsLao__internal_alias"))); #else #ifndef xmlUCSIsLao extern __typeof (xmlUCSIsLao) xmlUCSIsLao__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsLao xmlUCSIsLao__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsLatin1Supplement extern __typeof (xmlUCSIsLatin1Supplement) xmlUCSIsLatin1Supplement __attribute((alias("xmlUCSIsLatin1Supplement__internal_alias"))); #else #ifndef xmlUCSIsLatin1Supplement extern __typeof (xmlUCSIsLatin1Supplement) xmlUCSIsLatin1Supplement__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsLatin1Supplement xmlUCSIsLatin1Supplement__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsLatinExtendedA extern __typeof (xmlUCSIsLatinExtendedA) xmlUCSIsLatinExtendedA __attribute((alias("xmlUCSIsLatinExtendedA__internal_alias"))); #else #ifndef xmlUCSIsLatinExtendedA extern __typeof (xmlUCSIsLatinExtendedA) xmlUCSIsLatinExtendedA__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsLatinExtendedA xmlUCSIsLatinExtendedA__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsLatinExtendedAdditional extern __typeof (xmlUCSIsLatinExtendedAdditional) xmlUCSIsLatinExtendedAdditional __attribute((alias("xmlUCSIsLatinExtendedAdditional__internal_alias"))); #else #ifndef xmlUCSIsLatinExtendedAdditional extern __typeof (xmlUCSIsLatinExtendedAdditional) xmlUCSIsLatinExtendedAdditional__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsLatinExtendedAdditional xmlUCSIsLatinExtendedAdditional__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsLatinExtendedB extern __typeof (xmlUCSIsLatinExtendedB) xmlUCSIsLatinExtendedB __attribute((alias("xmlUCSIsLatinExtendedB__internal_alias"))); #else #ifndef xmlUCSIsLatinExtendedB extern __typeof (xmlUCSIsLatinExtendedB) xmlUCSIsLatinExtendedB__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsLatinExtendedB xmlUCSIsLatinExtendedB__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsLetterlikeSymbols extern __typeof (xmlUCSIsLetterlikeSymbols) xmlUCSIsLetterlikeSymbols __attribute((alias("xmlUCSIsLetterlikeSymbols__internal_alias"))); #else #ifndef xmlUCSIsLetterlikeSymbols extern __typeof (xmlUCSIsLetterlikeSymbols) xmlUCSIsLetterlikeSymbols__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsLetterlikeSymbols xmlUCSIsLetterlikeSymbols__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsLimbu extern __typeof (xmlUCSIsLimbu) xmlUCSIsLimbu __attribute((alias("xmlUCSIsLimbu__internal_alias"))); #else #ifndef xmlUCSIsLimbu extern __typeof (xmlUCSIsLimbu) xmlUCSIsLimbu__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsLimbu xmlUCSIsLimbu__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsLinearBIdeograms extern __typeof (xmlUCSIsLinearBIdeograms) xmlUCSIsLinearBIdeograms __attribute((alias("xmlUCSIsLinearBIdeograms__internal_alias"))); #else #ifndef xmlUCSIsLinearBIdeograms extern __typeof (xmlUCSIsLinearBIdeograms) xmlUCSIsLinearBIdeograms__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsLinearBIdeograms xmlUCSIsLinearBIdeograms__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsLinearBSyllabary extern __typeof (xmlUCSIsLinearBSyllabary) xmlUCSIsLinearBSyllabary __attribute((alias("xmlUCSIsLinearBSyllabary__internal_alias"))); #else #ifndef xmlUCSIsLinearBSyllabary extern __typeof (xmlUCSIsLinearBSyllabary) xmlUCSIsLinearBSyllabary__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsLinearBSyllabary xmlUCSIsLinearBSyllabary__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsLowSurrogates extern __typeof (xmlUCSIsLowSurrogates) xmlUCSIsLowSurrogates __attribute((alias("xmlUCSIsLowSurrogates__internal_alias"))); #else #ifndef xmlUCSIsLowSurrogates extern __typeof (xmlUCSIsLowSurrogates) xmlUCSIsLowSurrogates__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsLowSurrogates xmlUCSIsLowSurrogates__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsMalayalam extern __typeof (xmlUCSIsMalayalam) xmlUCSIsMalayalam __attribute((alias("xmlUCSIsMalayalam__internal_alias"))); #else #ifndef xmlUCSIsMalayalam extern __typeof (xmlUCSIsMalayalam) xmlUCSIsMalayalam__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsMalayalam xmlUCSIsMalayalam__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsMathematicalAlphanumericSymbols extern __typeof (xmlUCSIsMathematicalAlphanumericSymbols) xmlUCSIsMathematicalAlphanumericSymbols __attribute((alias("xmlUCSIsMathematicalAlphanumericSymbols__internal_alias"))); #else #ifndef xmlUCSIsMathematicalAlphanumericSymbols extern __typeof (xmlUCSIsMathematicalAlphanumericSymbols) xmlUCSIsMathematicalAlphanumericSymbols__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsMathematicalAlphanumericSymbols xmlUCSIsMathematicalAlphanumericSymbols__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsMathematicalOperators extern __typeof (xmlUCSIsMathematicalOperators) xmlUCSIsMathematicalOperators __attribute((alias("xmlUCSIsMathematicalOperators__internal_alias"))); #else #ifndef xmlUCSIsMathematicalOperators extern __typeof (xmlUCSIsMathematicalOperators) xmlUCSIsMathematicalOperators__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsMathematicalOperators xmlUCSIsMathematicalOperators__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsMiscellaneousMathematicalSymbolsA extern __typeof (xmlUCSIsMiscellaneousMathematicalSymbolsA) xmlUCSIsMiscellaneousMathematicalSymbolsA __attribute((alias("xmlUCSIsMiscellaneousMathematicalSymbolsA__internal_alias"))); #else #ifndef xmlUCSIsMiscellaneousMathematicalSymbolsA extern __typeof (xmlUCSIsMiscellaneousMathematicalSymbolsA) xmlUCSIsMiscellaneousMathematicalSymbolsA__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsMiscellaneousMathematicalSymbolsA xmlUCSIsMiscellaneousMathematicalSymbolsA__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsMiscellaneousMathematicalSymbolsB extern __typeof (xmlUCSIsMiscellaneousMathematicalSymbolsB) xmlUCSIsMiscellaneousMathematicalSymbolsB __attribute((alias("xmlUCSIsMiscellaneousMathematicalSymbolsB__internal_alias"))); #else #ifndef xmlUCSIsMiscellaneousMathematicalSymbolsB extern __typeof (xmlUCSIsMiscellaneousMathematicalSymbolsB) xmlUCSIsMiscellaneousMathematicalSymbolsB__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsMiscellaneousMathematicalSymbolsB xmlUCSIsMiscellaneousMathematicalSymbolsB__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsMiscellaneousSymbols extern __typeof (xmlUCSIsMiscellaneousSymbols) xmlUCSIsMiscellaneousSymbols __attribute((alias("xmlUCSIsMiscellaneousSymbols__internal_alias"))); #else #ifndef xmlUCSIsMiscellaneousSymbols extern __typeof (xmlUCSIsMiscellaneousSymbols) xmlUCSIsMiscellaneousSymbols__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsMiscellaneousSymbols xmlUCSIsMiscellaneousSymbols__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsMiscellaneousSymbolsandArrows extern __typeof (xmlUCSIsMiscellaneousSymbolsandArrows) xmlUCSIsMiscellaneousSymbolsandArrows __attribute((alias("xmlUCSIsMiscellaneousSymbolsandArrows__internal_alias"))); #else #ifndef xmlUCSIsMiscellaneousSymbolsandArrows extern __typeof (xmlUCSIsMiscellaneousSymbolsandArrows) xmlUCSIsMiscellaneousSymbolsandArrows__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsMiscellaneousSymbolsandArrows xmlUCSIsMiscellaneousSymbolsandArrows__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsMiscellaneousTechnical extern __typeof (xmlUCSIsMiscellaneousTechnical) xmlUCSIsMiscellaneousTechnical __attribute((alias("xmlUCSIsMiscellaneousTechnical__internal_alias"))); #else #ifndef xmlUCSIsMiscellaneousTechnical extern __typeof (xmlUCSIsMiscellaneousTechnical) xmlUCSIsMiscellaneousTechnical__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsMiscellaneousTechnical xmlUCSIsMiscellaneousTechnical__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsMongolian extern __typeof (xmlUCSIsMongolian) xmlUCSIsMongolian __attribute((alias("xmlUCSIsMongolian__internal_alias"))); #else #ifndef xmlUCSIsMongolian extern __typeof (xmlUCSIsMongolian) xmlUCSIsMongolian__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsMongolian xmlUCSIsMongolian__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsMusicalSymbols extern __typeof (xmlUCSIsMusicalSymbols) xmlUCSIsMusicalSymbols __attribute((alias("xmlUCSIsMusicalSymbols__internal_alias"))); #else #ifndef xmlUCSIsMusicalSymbols extern __typeof (xmlUCSIsMusicalSymbols) xmlUCSIsMusicalSymbols__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsMusicalSymbols xmlUCSIsMusicalSymbols__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsMyanmar extern __typeof (xmlUCSIsMyanmar) xmlUCSIsMyanmar __attribute((alias("xmlUCSIsMyanmar__internal_alias"))); #else #ifndef xmlUCSIsMyanmar extern __typeof (xmlUCSIsMyanmar) xmlUCSIsMyanmar__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsMyanmar xmlUCSIsMyanmar__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsNumberForms extern __typeof (xmlUCSIsNumberForms) xmlUCSIsNumberForms __attribute((alias("xmlUCSIsNumberForms__internal_alias"))); #else #ifndef xmlUCSIsNumberForms extern __typeof (xmlUCSIsNumberForms) xmlUCSIsNumberForms__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsNumberForms xmlUCSIsNumberForms__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsOgham extern __typeof (xmlUCSIsOgham) xmlUCSIsOgham __attribute((alias("xmlUCSIsOgham__internal_alias"))); #else #ifndef xmlUCSIsOgham extern __typeof (xmlUCSIsOgham) xmlUCSIsOgham__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsOgham xmlUCSIsOgham__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsOldItalic extern __typeof (xmlUCSIsOldItalic) xmlUCSIsOldItalic __attribute((alias("xmlUCSIsOldItalic__internal_alias"))); #else #ifndef xmlUCSIsOldItalic extern __typeof (xmlUCSIsOldItalic) xmlUCSIsOldItalic__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsOldItalic xmlUCSIsOldItalic__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsOpticalCharacterRecognition extern __typeof (xmlUCSIsOpticalCharacterRecognition) xmlUCSIsOpticalCharacterRecognition __attribute((alias("xmlUCSIsOpticalCharacterRecognition__internal_alias"))); #else #ifndef xmlUCSIsOpticalCharacterRecognition extern __typeof (xmlUCSIsOpticalCharacterRecognition) xmlUCSIsOpticalCharacterRecognition__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsOpticalCharacterRecognition xmlUCSIsOpticalCharacterRecognition__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsOriya extern __typeof (xmlUCSIsOriya) xmlUCSIsOriya __attribute((alias("xmlUCSIsOriya__internal_alias"))); #else #ifndef xmlUCSIsOriya extern __typeof (xmlUCSIsOriya) xmlUCSIsOriya__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsOriya xmlUCSIsOriya__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsOsmanya extern __typeof (xmlUCSIsOsmanya) xmlUCSIsOsmanya __attribute((alias("xmlUCSIsOsmanya__internal_alias"))); #else #ifndef xmlUCSIsOsmanya extern __typeof (xmlUCSIsOsmanya) xmlUCSIsOsmanya__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsOsmanya xmlUCSIsOsmanya__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsPhoneticExtensions extern __typeof (xmlUCSIsPhoneticExtensions) xmlUCSIsPhoneticExtensions __attribute((alias("xmlUCSIsPhoneticExtensions__internal_alias"))); #else #ifndef xmlUCSIsPhoneticExtensions extern __typeof (xmlUCSIsPhoneticExtensions) xmlUCSIsPhoneticExtensions__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsPhoneticExtensions xmlUCSIsPhoneticExtensions__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsPrivateUse extern __typeof (xmlUCSIsPrivateUse) xmlUCSIsPrivateUse __attribute((alias("xmlUCSIsPrivateUse__internal_alias"))); #else #ifndef xmlUCSIsPrivateUse extern __typeof (xmlUCSIsPrivateUse) xmlUCSIsPrivateUse__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsPrivateUse xmlUCSIsPrivateUse__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsPrivateUseArea extern __typeof (xmlUCSIsPrivateUseArea) xmlUCSIsPrivateUseArea __attribute((alias("xmlUCSIsPrivateUseArea__internal_alias"))); #else #ifndef xmlUCSIsPrivateUseArea extern __typeof (xmlUCSIsPrivateUseArea) xmlUCSIsPrivateUseArea__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsPrivateUseArea xmlUCSIsPrivateUseArea__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsRunic extern __typeof (xmlUCSIsRunic) xmlUCSIsRunic __attribute((alias("xmlUCSIsRunic__internal_alias"))); #else #ifndef xmlUCSIsRunic extern __typeof (xmlUCSIsRunic) xmlUCSIsRunic__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsRunic xmlUCSIsRunic__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsShavian extern __typeof (xmlUCSIsShavian) xmlUCSIsShavian __attribute((alias("xmlUCSIsShavian__internal_alias"))); #else #ifndef xmlUCSIsShavian extern __typeof (xmlUCSIsShavian) xmlUCSIsShavian__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsShavian xmlUCSIsShavian__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsSinhala extern __typeof (xmlUCSIsSinhala) xmlUCSIsSinhala __attribute((alias("xmlUCSIsSinhala__internal_alias"))); #else #ifndef xmlUCSIsSinhala extern __typeof (xmlUCSIsSinhala) xmlUCSIsSinhala__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsSinhala xmlUCSIsSinhala__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsSmallFormVariants extern __typeof (xmlUCSIsSmallFormVariants) xmlUCSIsSmallFormVariants __attribute((alias("xmlUCSIsSmallFormVariants__internal_alias"))); #else #ifndef xmlUCSIsSmallFormVariants extern __typeof (xmlUCSIsSmallFormVariants) xmlUCSIsSmallFormVariants__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsSmallFormVariants xmlUCSIsSmallFormVariants__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsSpacingModifierLetters extern __typeof (xmlUCSIsSpacingModifierLetters) xmlUCSIsSpacingModifierLetters __attribute((alias("xmlUCSIsSpacingModifierLetters__internal_alias"))); #else #ifndef xmlUCSIsSpacingModifierLetters extern __typeof (xmlUCSIsSpacingModifierLetters) xmlUCSIsSpacingModifierLetters__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsSpacingModifierLetters xmlUCSIsSpacingModifierLetters__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsSpecials extern __typeof (xmlUCSIsSpecials) xmlUCSIsSpecials __attribute((alias("xmlUCSIsSpecials__internal_alias"))); #else #ifndef xmlUCSIsSpecials extern __typeof (xmlUCSIsSpecials) xmlUCSIsSpecials__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsSpecials xmlUCSIsSpecials__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsSuperscriptsandSubscripts extern __typeof (xmlUCSIsSuperscriptsandSubscripts) xmlUCSIsSuperscriptsandSubscripts __attribute((alias("xmlUCSIsSuperscriptsandSubscripts__internal_alias"))); #else #ifndef xmlUCSIsSuperscriptsandSubscripts extern __typeof (xmlUCSIsSuperscriptsandSubscripts) xmlUCSIsSuperscriptsandSubscripts__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsSuperscriptsandSubscripts xmlUCSIsSuperscriptsandSubscripts__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsSupplementalArrowsA extern __typeof (xmlUCSIsSupplementalArrowsA) xmlUCSIsSupplementalArrowsA __attribute((alias("xmlUCSIsSupplementalArrowsA__internal_alias"))); #else #ifndef xmlUCSIsSupplementalArrowsA extern __typeof (xmlUCSIsSupplementalArrowsA) xmlUCSIsSupplementalArrowsA__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsSupplementalArrowsA xmlUCSIsSupplementalArrowsA__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsSupplementalArrowsB extern __typeof (xmlUCSIsSupplementalArrowsB) xmlUCSIsSupplementalArrowsB __attribute((alias("xmlUCSIsSupplementalArrowsB__internal_alias"))); #else #ifndef xmlUCSIsSupplementalArrowsB extern __typeof (xmlUCSIsSupplementalArrowsB) xmlUCSIsSupplementalArrowsB__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsSupplementalArrowsB xmlUCSIsSupplementalArrowsB__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsSupplementalMathematicalOperators extern __typeof (xmlUCSIsSupplementalMathematicalOperators) xmlUCSIsSupplementalMathematicalOperators __attribute((alias("xmlUCSIsSupplementalMathematicalOperators__internal_alias"))); #else #ifndef xmlUCSIsSupplementalMathematicalOperators extern __typeof (xmlUCSIsSupplementalMathematicalOperators) xmlUCSIsSupplementalMathematicalOperators__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsSupplementalMathematicalOperators xmlUCSIsSupplementalMathematicalOperators__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsSupplementaryPrivateUseAreaA extern __typeof (xmlUCSIsSupplementaryPrivateUseAreaA) xmlUCSIsSupplementaryPrivateUseAreaA __attribute((alias("xmlUCSIsSupplementaryPrivateUseAreaA__internal_alias"))); #else #ifndef xmlUCSIsSupplementaryPrivateUseAreaA extern __typeof (xmlUCSIsSupplementaryPrivateUseAreaA) xmlUCSIsSupplementaryPrivateUseAreaA__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsSupplementaryPrivateUseAreaA xmlUCSIsSupplementaryPrivateUseAreaA__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsSupplementaryPrivateUseAreaB extern __typeof (xmlUCSIsSupplementaryPrivateUseAreaB) xmlUCSIsSupplementaryPrivateUseAreaB __attribute((alias("xmlUCSIsSupplementaryPrivateUseAreaB__internal_alias"))); #else #ifndef xmlUCSIsSupplementaryPrivateUseAreaB extern __typeof (xmlUCSIsSupplementaryPrivateUseAreaB) xmlUCSIsSupplementaryPrivateUseAreaB__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsSupplementaryPrivateUseAreaB xmlUCSIsSupplementaryPrivateUseAreaB__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsSyriac extern __typeof (xmlUCSIsSyriac) xmlUCSIsSyriac __attribute((alias("xmlUCSIsSyriac__internal_alias"))); #else #ifndef xmlUCSIsSyriac extern __typeof (xmlUCSIsSyriac) xmlUCSIsSyriac__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsSyriac xmlUCSIsSyriac__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsTagalog extern __typeof (xmlUCSIsTagalog) xmlUCSIsTagalog __attribute((alias("xmlUCSIsTagalog__internal_alias"))); #else #ifndef xmlUCSIsTagalog extern __typeof (xmlUCSIsTagalog) xmlUCSIsTagalog__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsTagalog xmlUCSIsTagalog__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsTagbanwa extern __typeof (xmlUCSIsTagbanwa) xmlUCSIsTagbanwa __attribute((alias("xmlUCSIsTagbanwa__internal_alias"))); #else #ifndef xmlUCSIsTagbanwa extern __typeof (xmlUCSIsTagbanwa) xmlUCSIsTagbanwa__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsTagbanwa xmlUCSIsTagbanwa__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsTags extern __typeof (xmlUCSIsTags) xmlUCSIsTags __attribute((alias("xmlUCSIsTags__internal_alias"))); #else #ifndef xmlUCSIsTags extern __typeof (xmlUCSIsTags) xmlUCSIsTags__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsTags xmlUCSIsTags__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsTaiLe extern __typeof (xmlUCSIsTaiLe) xmlUCSIsTaiLe __attribute((alias("xmlUCSIsTaiLe__internal_alias"))); #else #ifndef xmlUCSIsTaiLe extern __typeof (xmlUCSIsTaiLe) xmlUCSIsTaiLe__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsTaiLe xmlUCSIsTaiLe__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsTaiXuanJingSymbols extern __typeof (xmlUCSIsTaiXuanJingSymbols) xmlUCSIsTaiXuanJingSymbols __attribute((alias("xmlUCSIsTaiXuanJingSymbols__internal_alias"))); #else #ifndef xmlUCSIsTaiXuanJingSymbols extern __typeof (xmlUCSIsTaiXuanJingSymbols) xmlUCSIsTaiXuanJingSymbols__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsTaiXuanJingSymbols xmlUCSIsTaiXuanJingSymbols__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsTamil extern __typeof (xmlUCSIsTamil) xmlUCSIsTamil __attribute((alias("xmlUCSIsTamil__internal_alias"))); #else #ifndef xmlUCSIsTamil extern __typeof (xmlUCSIsTamil) xmlUCSIsTamil__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsTamil xmlUCSIsTamil__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsTelugu extern __typeof (xmlUCSIsTelugu) xmlUCSIsTelugu __attribute((alias("xmlUCSIsTelugu__internal_alias"))); #else #ifndef xmlUCSIsTelugu extern __typeof (xmlUCSIsTelugu) xmlUCSIsTelugu__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsTelugu xmlUCSIsTelugu__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsThaana extern __typeof (xmlUCSIsThaana) xmlUCSIsThaana __attribute((alias("xmlUCSIsThaana__internal_alias"))); #else #ifndef xmlUCSIsThaana extern __typeof (xmlUCSIsThaana) xmlUCSIsThaana__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsThaana xmlUCSIsThaana__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsThai extern __typeof (xmlUCSIsThai) xmlUCSIsThai __attribute((alias("xmlUCSIsThai__internal_alias"))); #else #ifndef xmlUCSIsThai extern __typeof (xmlUCSIsThai) xmlUCSIsThai__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsThai xmlUCSIsThai__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsTibetan extern __typeof (xmlUCSIsTibetan) xmlUCSIsTibetan __attribute((alias("xmlUCSIsTibetan__internal_alias"))); #else #ifndef xmlUCSIsTibetan extern __typeof (xmlUCSIsTibetan) xmlUCSIsTibetan__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsTibetan xmlUCSIsTibetan__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsUgaritic extern __typeof (xmlUCSIsUgaritic) xmlUCSIsUgaritic __attribute((alias("xmlUCSIsUgaritic__internal_alias"))); #else #ifndef xmlUCSIsUgaritic extern __typeof (xmlUCSIsUgaritic) xmlUCSIsUgaritic__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsUgaritic xmlUCSIsUgaritic__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsUnifiedCanadianAboriginalSyllabics extern __typeof (xmlUCSIsUnifiedCanadianAboriginalSyllabics) xmlUCSIsUnifiedCanadianAboriginalSyllabics __attribute((alias("xmlUCSIsUnifiedCanadianAboriginalSyllabics__internal_alias"))); #else #ifndef xmlUCSIsUnifiedCanadianAboriginalSyllabics extern __typeof (xmlUCSIsUnifiedCanadianAboriginalSyllabics) xmlUCSIsUnifiedCanadianAboriginalSyllabics__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsUnifiedCanadianAboriginalSyllabics xmlUCSIsUnifiedCanadianAboriginalSyllabics__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsVariationSelectors extern __typeof (xmlUCSIsVariationSelectors) xmlUCSIsVariationSelectors __attribute((alias("xmlUCSIsVariationSelectors__internal_alias"))); #else #ifndef xmlUCSIsVariationSelectors extern __typeof (xmlUCSIsVariationSelectors) xmlUCSIsVariationSelectors__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsVariationSelectors xmlUCSIsVariationSelectors__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsVariationSelectorsSupplement extern __typeof (xmlUCSIsVariationSelectorsSupplement) xmlUCSIsVariationSelectorsSupplement __attribute((alias("xmlUCSIsVariationSelectorsSupplement__internal_alias"))); #else #ifndef xmlUCSIsVariationSelectorsSupplement extern __typeof (xmlUCSIsVariationSelectorsSupplement) xmlUCSIsVariationSelectorsSupplement__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsVariationSelectorsSupplement xmlUCSIsVariationSelectorsSupplement__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsYiRadicals extern __typeof (xmlUCSIsYiRadicals) xmlUCSIsYiRadicals __attribute((alias("xmlUCSIsYiRadicals__internal_alias"))); #else #ifndef xmlUCSIsYiRadicals extern __typeof (xmlUCSIsYiRadicals) xmlUCSIsYiRadicals__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsYiRadicals xmlUCSIsYiRadicals__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsYiSyllables extern __typeof (xmlUCSIsYiSyllables) xmlUCSIsYiSyllables __attribute((alias("xmlUCSIsYiSyllables__internal_alias"))); #else #ifndef xmlUCSIsYiSyllables extern __typeof (xmlUCSIsYiSyllables) xmlUCSIsYiSyllables__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsYiSyllables xmlUCSIsYiSyllables__internal_alias #endif #endif #endif #if defined(LIBXML_UNICODE_ENABLED) #ifdef bottom_xmlunicode #undef xmlUCSIsYijingHexagramSymbols extern __typeof (xmlUCSIsYijingHexagramSymbols) xmlUCSIsYijingHexagramSymbols __attribute((alias("xmlUCSIsYijingHexagramSymbols__internal_alias"))); #else #ifndef xmlUCSIsYijingHexagramSymbols extern __typeof (xmlUCSIsYijingHexagramSymbols) xmlUCSIsYijingHexagramSymbols__internal_alias __attribute((visibility("hidden"))); #define xmlUCSIsYijingHexagramSymbols xmlUCSIsYijingHexagramSymbols__internal_alias #endif #endif #endif #ifdef bottom_uri #undef xmlURIEscape extern __typeof (xmlURIEscape) xmlURIEscape __attribute((alias("xmlURIEscape__internal_alias"))); #else #ifndef xmlURIEscape extern __typeof (xmlURIEscape) xmlURIEscape__internal_alias __attribute((visibility("hidden"))); #define xmlURIEscape xmlURIEscape__internal_alias #endif #endif #ifdef bottom_uri #undef xmlURIEscapeStr extern __typeof (xmlURIEscapeStr) xmlURIEscapeStr __attribute((alias("xmlURIEscapeStr__internal_alias"))); #else #ifndef xmlURIEscapeStr extern __typeof (xmlURIEscapeStr) xmlURIEscapeStr__internal_alias __attribute((visibility("hidden"))); #define xmlURIEscapeStr xmlURIEscapeStr__internal_alias #endif #endif #ifdef bottom_uri #undef xmlURIUnescapeString extern __typeof (xmlURIUnescapeString) xmlURIUnescapeString __attribute((alias("xmlURIUnescapeString__internal_alias"))); #else #ifndef xmlURIUnescapeString extern __typeof (xmlURIUnescapeString) xmlURIUnescapeString__internal_alias __attribute((visibility("hidden"))); #define xmlURIUnescapeString xmlURIUnescapeString__internal_alias #endif #endif #ifdef bottom_xmlstring #undef xmlUTF8Charcmp extern __typeof (xmlUTF8Charcmp) xmlUTF8Charcmp __attribute((alias("xmlUTF8Charcmp__internal_alias"))); #else #ifndef xmlUTF8Charcmp extern __typeof (xmlUTF8Charcmp) xmlUTF8Charcmp__internal_alias __attribute((visibility("hidden"))); #define xmlUTF8Charcmp xmlUTF8Charcmp__internal_alias #endif #endif #ifdef bottom_xmlstring #undef xmlUTF8Size extern __typeof (xmlUTF8Size) xmlUTF8Size __attribute((alias("xmlUTF8Size__internal_alias"))); #else #ifndef xmlUTF8Size extern __typeof (xmlUTF8Size) xmlUTF8Size__internal_alias __attribute((visibility("hidden"))); #define xmlUTF8Size xmlUTF8Size__internal_alias #endif #endif #ifdef bottom_xmlstring #undef xmlUTF8Strlen extern __typeof (xmlUTF8Strlen) xmlUTF8Strlen __attribute((alias("xmlUTF8Strlen__internal_alias"))); #else #ifndef xmlUTF8Strlen extern __typeof (xmlUTF8Strlen) xmlUTF8Strlen__internal_alias __attribute((visibility("hidden"))); #define xmlUTF8Strlen xmlUTF8Strlen__internal_alias #endif #endif #ifdef bottom_xmlstring #undef xmlUTF8Strloc extern __typeof (xmlUTF8Strloc) xmlUTF8Strloc __attribute((alias("xmlUTF8Strloc__internal_alias"))); #else #ifndef xmlUTF8Strloc extern __typeof (xmlUTF8Strloc) xmlUTF8Strloc__internal_alias __attribute((visibility("hidden"))); #define xmlUTF8Strloc xmlUTF8Strloc__internal_alias #endif #endif #ifdef bottom_xmlstring #undef xmlUTF8Strndup extern __typeof (xmlUTF8Strndup) xmlUTF8Strndup __attribute((alias("xmlUTF8Strndup__internal_alias"))); #else #ifndef xmlUTF8Strndup extern __typeof (xmlUTF8Strndup) xmlUTF8Strndup__internal_alias __attribute((visibility("hidden"))); #define xmlUTF8Strndup xmlUTF8Strndup__internal_alias #endif #endif #ifdef bottom_xmlstring #undef xmlUTF8Strpos extern __typeof (xmlUTF8Strpos) xmlUTF8Strpos __attribute((alias("xmlUTF8Strpos__internal_alias"))); #else #ifndef xmlUTF8Strpos extern __typeof (xmlUTF8Strpos) xmlUTF8Strpos__internal_alias __attribute((visibility("hidden"))); #define xmlUTF8Strpos xmlUTF8Strpos__internal_alias #endif #endif #ifdef bottom_xmlstring #undef xmlUTF8Strsize extern __typeof (xmlUTF8Strsize) xmlUTF8Strsize __attribute((alias("xmlUTF8Strsize__internal_alias"))); #else #ifndef xmlUTF8Strsize extern __typeof (xmlUTF8Strsize) xmlUTF8Strsize__internal_alias __attribute((visibility("hidden"))); #define xmlUTF8Strsize xmlUTF8Strsize__internal_alias #endif #endif #ifdef bottom_xmlstring #undef xmlUTF8Strsub extern __typeof (xmlUTF8Strsub) xmlUTF8Strsub __attribute((alias("xmlUTF8Strsub__internal_alias"))); #else #ifndef xmlUTF8Strsub extern __typeof (xmlUTF8Strsub) xmlUTF8Strsub__internal_alias __attribute((visibility("hidden"))); #define xmlUTF8Strsub xmlUTF8Strsub__internal_alias #endif #endif #ifdef bottom_tree #undef xmlUnlinkNode extern __typeof (xmlUnlinkNode) xmlUnlinkNode __attribute((alias("xmlUnlinkNode__internal_alias"))); #else #ifndef xmlUnlinkNode extern __typeof (xmlUnlinkNode) xmlUnlinkNode__internal_alias __attribute((visibility("hidden"))); #define xmlUnlinkNode xmlUnlinkNode__internal_alias #endif #endif #ifdef bottom_threads #undef xmlUnlockLibrary extern __typeof (xmlUnlockLibrary) xmlUnlockLibrary __attribute((alias("xmlUnlockLibrary__internal_alias"))); #else #ifndef xmlUnlockLibrary extern __typeof (xmlUnlockLibrary) xmlUnlockLibrary__internal_alias __attribute((visibility("hidden"))); #define xmlUnlockLibrary xmlUnlockLibrary__internal_alias #endif #endif #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_tree #undef xmlUnsetNsProp extern __typeof (xmlUnsetNsProp) xmlUnsetNsProp __attribute((alias("xmlUnsetNsProp__internal_alias"))); #else #ifndef xmlUnsetNsProp extern __typeof (xmlUnsetNsProp) xmlUnsetNsProp__internal_alias __attribute((visibility("hidden"))); #define xmlUnsetNsProp xmlUnsetNsProp__internal_alias #endif #endif #endif #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_tree #undef xmlUnsetProp extern __typeof (xmlUnsetProp) xmlUnsetProp __attribute((alias("xmlUnsetProp__internal_alias"))); #else #ifndef xmlUnsetProp extern __typeof (xmlUnsetProp) xmlUnsetProp__internal_alias __attribute((visibility("hidden"))); #define xmlUnsetProp xmlUnsetProp__internal_alias #endif #endif #endif #if defined(LIBXML_VALID_ENABLED) && defined(LIBXML_REGEXP_ENABLED) #ifdef bottom_valid #undef xmlValidBuildContentModel extern __typeof (xmlValidBuildContentModel) xmlValidBuildContentModel __attribute((alias("xmlValidBuildContentModel__internal_alias"))); #else #ifndef xmlValidBuildContentModel extern __typeof (xmlValidBuildContentModel) xmlValidBuildContentModel__internal_alias __attribute((visibility("hidden"))); #define xmlValidBuildContentModel xmlValidBuildContentModel__internal_alias #endif #endif #endif #if defined(LIBXML_VALID_ENABLED) #ifdef bottom_valid #undef xmlValidCtxtNormalizeAttributeValue extern __typeof (xmlValidCtxtNormalizeAttributeValue) xmlValidCtxtNormalizeAttributeValue __attribute((alias("xmlValidCtxtNormalizeAttributeValue__internal_alias"))); #else #ifndef xmlValidCtxtNormalizeAttributeValue extern __typeof (xmlValidCtxtNormalizeAttributeValue) xmlValidCtxtNormalizeAttributeValue__internal_alias __attribute((visibility("hidden"))); #define xmlValidCtxtNormalizeAttributeValue xmlValidCtxtNormalizeAttributeValue__internal_alias #endif #endif #endif #if defined(LIBXML_VALID_ENABLED) #ifdef bottom_valid #undef xmlValidGetPotentialChildren extern __typeof (xmlValidGetPotentialChildren) xmlValidGetPotentialChildren __attribute((alias("xmlValidGetPotentialChildren__internal_alias"))); #else #ifndef xmlValidGetPotentialChildren extern __typeof (xmlValidGetPotentialChildren) xmlValidGetPotentialChildren__internal_alias __attribute((visibility("hidden"))); #define xmlValidGetPotentialChildren xmlValidGetPotentialChildren__internal_alias #endif #endif #endif #if defined(LIBXML_VALID_ENABLED) #ifdef bottom_valid #undef xmlValidGetValidElements extern __typeof (xmlValidGetValidElements) xmlValidGetValidElements __attribute((alias("xmlValidGetValidElements__internal_alias"))); #else #ifndef xmlValidGetValidElements extern __typeof (xmlValidGetValidElements) xmlValidGetValidElements__internal_alias __attribute((visibility("hidden"))); #define xmlValidGetValidElements xmlValidGetValidElements__internal_alias #endif #endif #endif #if defined(LIBXML_VALID_ENABLED) #ifdef bottom_valid #undef xmlValidNormalizeAttributeValue extern __typeof (xmlValidNormalizeAttributeValue) xmlValidNormalizeAttributeValue __attribute((alias("xmlValidNormalizeAttributeValue__internal_alias"))); #else #ifndef xmlValidNormalizeAttributeValue extern __typeof (xmlValidNormalizeAttributeValue) xmlValidNormalizeAttributeValue__internal_alias __attribute((visibility("hidden"))); #define xmlValidNormalizeAttributeValue xmlValidNormalizeAttributeValue__internal_alias #endif #endif #endif #if defined(LIBXML_VALID_ENABLED) #ifdef bottom_valid #undef xmlValidateAttributeDecl extern __typeof (xmlValidateAttributeDecl) xmlValidateAttributeDecl __attribute((alias("xmlValidateAttributeDecl__internal_alias"))); #else #ifndef xmlValidateAttributeDecl extern __typeof (xmlValidateAttributeDecl) xmlValidateAttributeDecl__internal_alias __attribute((visibility("hidden"))); #define xmlValidateAttributeDecl xmlValidateAttributeDecl__internal_alias #endif #endif #endif #if defined(LIBXML_VALID_ENABLED) #ifdef bottom_valid #undef xmlValidateAttributeValue extern __typeof (xmlValidateAttributeValue) xmlValidateAttributeValue __attribute((alias("xmlValidateAttributeValue__internal_alias"))); #else #ifndef xmlValidateAttributeValue extern __typeof (xmlValidateAttributeValue) xmlValidateAttributeValue__internal_alias __attribute((visibility("hidden"))); #define xmlValidateAttributeValue xmlValidateAttributeValue__internal_alias #endif #endif #endif #if defined(LIBXML_VALID_ENABLED) #ifdef bottom_valid #undef xmlValidateDocument extern __typeof (xmlValidateDocument) xmlValidateDocument __attribute((alias("xmlValidateDocument__internal_alias"))); #else #ifndef xmlValidateDocument extern __typeof (xmlValidateDocument) xmlValidateDocument__internal_alias __attribute((visibility("hidden"))); #define xmlValidateDocument xmlValidateDocument__internal_alias #endif #endif #endif #if defined(LIBXML_VALID_ENABLED) #ifdef bottom_valid #undef xmlValidateDocumentFinal extern __typeof (xmlValidateDocumentFinal) xmlValidateDocumentFinal __attribute((alias("xmlValidateDocumentFinal__internal_alias"))); #else #ifndef xmlValidateDocumentFinal extern __typeof (xmlValidateDocumentFinal) xmlValidateDocumentFinal__internal_alias __attribute((visibility("hidden"))); #define xmlValidateDocumentFinal xmlValidateDocumentFinal__internal_alias #endif #endif #endif #if defined(LIBXML_VALID_ENABLED) #ifdef bottom_valid #undef xmlValidateDtd extern __typeof (xmlValidateDtd) xmlValidateDtd __attribute((alias("xmlValidateDtd__internal_alias"))); #else #ifndef xmlValidateDtd extern __typeof (xmlValidateDtd) xmlValidateDtd__internal_alias __attribute((visibility("hidden"))); #define xmlValidateDtd xmlValidateDtd__internal_alias #endif #endif #endif #if defined(LIBXML_VALID_ENABLED) #ifdef bottom_valid #undef xmlValidateDtdFinal extern __typeof (xmlValidateDtdFinal) xmlValidateDtdFinal __attribute((alias("xmlValidateDtdFinal__internal_alias"))); #else #ifndef xmlValidateDtdFinal extern __typeof (xmlValidateDtdFinal) xmlValidateDtdFinal__internal_alias __attribute((visibility("hidden"))); #define xmlValidateDtdFinal xmlValidateDtdFinal__internal_alias #endif #endif #endif #if defined(LIBXML_VALID_ENABLED) #ifdef bottom_valid #undef xmlValidateElement extern __typeof (xmlValidateElement) xmlValidateElement __attribute((alias("xmlValidateElement__internal_alias"))); #else #ifndef xmlValidateElement extern __typeof (xmlValidateElement) xmlValidateElement__internal_alias __attribute((visibility("hidden"))); #define xmlValidateElement xmlValidateElement__internal_alias #endif #endif #endif #if defined(LIBXML_VALID_ENABLED) #ifdef bottom_valid #undef xmlValidateElementDecl extern __typeof (xmlValidateElementDecl) xmlValidateElementDecl __attribute((alias("xmlValidateElementDecl__internal_alias"))); #else #ifndef xmlValidateElementDecl extern __typeof (xmlValidateElementDecl) xmlValidateElementDecl__internal_alias __attribute((visibility("hidden"))); #define xmlValidateElementDecl xmlValidateElementDecl__internal_alias #endif #endif #endif #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_DEBUG_ENABLED) || defined (LIBXML_HTML_ENABLED) #ifdef bottom_tree #undef xmlValidateNCName extern __typeof (xmlValidateNCName) xmlValidateNCName __attribute((alias("xmlValidateNCName__internal_alias"))); #else #ifndef xmlValidateNCName extern __typeof (xmlValidateNCName) xmlValidateNCName__internal_alias __attribute((visibility("hidden"))); #define xmlValidateNCName xmlValidateNCName__internal_alias #endif #endif #endif #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_tree #undef xmlValidateNMToken extern __typeof (xmlValidateNMToken) xmlValidateNMToken __attribute((alias("xmlValidateNMToken__internal_alias"))); #else #ifndef xmlValidateNMToken extern __typeof (xmlValidateNMToken) xmlValidateNMToken__internal_alias __attribute((visibility("hidden"))); #define xmlValidateNMToken xmlValidateNMToken__internal_alias #endif #endif #endif #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_tree #undef xmlValidateName extern __typeof (xmlValidateName) xmlValidateName __attribute((alias("xmlValidateName__internal_alias"))); #else #ifndef xmlValidateName extern __typeof (xmlValidateName) xmlValidateName__internal_alias __attribute((visibility("hidden"))); #define xmlValidateName xmlValidateName__internal_alias #endif #endif #endif #if defined(LIBXML_VALID_ENABLED) #ifdef bottom_valid #undef xmlValidateNameValue extern __typeof (xmlValidateNameValue) xmlValidateNameValue __attribute((alias("xmlValidateNameValue__internal_alias"))); #else #ifndef xmlValidateNameValue extern __typeof (xmlValidateNameValue) xmlValidateNameValue__internal_alias __attribute((visibility("hidden"))); #define xmlValidateNameValue xmlValidateNameValue__internal_alias #endif #endif #endif #if defined(LIBXML_VALID_ENABLED) #ifdef bottom_valid #undef xmlValidateNamesValue extern __typeof (xmlValidateNamesValue) xmlValidateNamesValue __attribute((alias("xmlValidateNamesValue__internal_alias"))); #else #ifndef xmlValidateNamesValue extern __typeof (xmlValidateNamesValue) xmlValidateNamesValue__internal_alias __attribute((visibility("hidden"))); #define xmlValidateNamesValue xmlValidateNamesValue__internal_alias #endif #endif #endif #if defined(LIBXML_VALID_ENABLED) #ifdef bottom_valid #undef xmlValidateNmtokenValue extern __typeof (xmlValidateNmtokenValue) xmlValidateNmtokenValue __attribute((alias("xmlValidateNmtokenValue__internal_alias"))); #else #ifndef xmlValidateNmtokenValue extern __typeof (xmlValidateNmtokenValue) xmlValidateNmtokenValue__internal_alias __attribute((visibility("hidden"))); #define xmlValidateNmtokenValue xmlValidateNmtokenValue__internal_alias #endif #endif #endif #if defined(LIBXML_VALID_ENABLED) #ifdef bottom_valid #undef xmlValidateNmtokensValue extern __typeof (xmlValidateNmtokensValue) xmlValidateNmtokensValue __attribute((alias("xmlValidateNmtokensValue__internal_alias"))); #else #ifndef xmlValidateNmtokensValue extern __typeof (xmlValidateNmtokensValue) xmlValidateNmtokensValue__internal_alias __attribute((visibility("hidden"))); #define xmlValidateNmtokensValue xmlValidateNmtokensValue__internal_alias #endif #endif #endif #if defined(LIBXML_VALID_ENABLED) #ifdef bottom_valid #undef xmlValidateNotationDecl extern __typeof (xmlValidateNotationDecl) xmlValidateNotationDecl __attribute((alias("xmlValidateNotationDecl__internal_alias"))); #else #ifndef xmlValidateNotationDecl extern __typeof (xmlValidateNotationDecl) xmlValidateNotationDecl__internal_alias __attribute((visibility("hidden"))); #define xmlValidateNotationDecl xmlValidateNotationDecl__internal_alias #endif #endif #endif #if defined(LIBXML_VALID_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_valid #undef xmlValidateNotationUse extern __typeof (xmlValidateNotationUse) xmlValidateNotationUse __attribute((alias("xmlValidateNotationUse__internal_alias"))); #else #ifndef xmlValidateNotationUse extern __typeof (xmlValidateNotationUse) xmlValidateNotationUse__internal_alias __attribute((visibility("hidden"))); #define xmlValidateNotationUse xmlValidateNotationUse__internal_alias #endif #endif #endif #if defined(LIBXML_VALID_ENABLED) #ifdef bottom_valid #undef xmlValidateOneAttribute extern __typeof (xmlValidateOneAttribute) xmlValidateOneAttribute __attribute((alias("xmlValidateOneAttribute__internal_alias"))); #else #ifndef xmlValidateOneAttribute extern __typeof (xmlValidateOneAttribute) xmlValidateOneAttribute__internal_alias __attribute((visibility("hidden"))); #define xmlValidateOneAttribute xmlValidateOneAttribute__internal_alias #endif #endif #endif #if defined(LIBXML_VALID_ENABLED) #ifdef bottom_valid #undef xmlValidateOneElement extern __typeof (xmlValidateOneElement) xmlValidateOneElement __attribute((alias("xmlValidateOneElement__internal_alias"))); #else #ifndef xmlValidateOneElement extern __typeof (xmlValidateOneElement) xmlValidateOneElement__internal_alias __attribute((visibility("hidden"))); #define xmlValidateOneElement xmlValidateOneElement__internal_alias #endif #endif #endif #if defined(LIBXML_VALID_ENABLED) #ifdef bottom_valid #undef xmlValidateOneNamespace extern __typeof (xmlValidateOneNamespace) xmlValidateOneNamespace __attribute((alias("xmlValidateOneNamespace__internal_alias"))); #else #ifndef xmlValidateOneNamespace extern __typeof (xmlValidateOneNamespace) xmlValidateOneNamespace__internal_alias __attribute((visibility("hidden"))); #define xmlValidateOneNamespace xmlValidateOneNamespace__internal_alias #endif #endif #endif #if defined(LIBXML_VALID_ENABLED) && defined(LIBXML_REGEXP_ENABLED) #ifdef bottom_valid #undef xmlValidatePopElement extern __typeof (xmlValidatePopElement) xmlValidatePopElement __attribute((alias("xmlValidatePopElement__internal_alias"))); #else #ifndef xmlValidatePopElement extern __typeof (xmlValidatePopElement) xmlValidatePopElement__internal_alias __attribute((visibility("hidden"))); #define xmlValidatePopElement xmlValidatePopElement__internal_alias #endif #endif #endif #if defined(LIBXML_VALID_ENABLED) && defined(LIBXML_REGEXP_ENABLED) #ifdef bottom_valid #undef xmlValidatePushCData extern __typeof (xmlValidatePushCData) xmlValidatePushCData __attribute((alias("xmlValidatePushCData__internal_alias"))); #else #ifndef xmlValidatePushCData extern __typeof (xmlValidatePushCData) xmlValidatePushCData__internal_alias __attribute((visibility("hidden"))); #define xmlValidatePushCData xmlValidatePushCData__internal_alias #endif #endif #endif #if defined(LIBXML_VALID_ENABLED) && defined(LIBXML_REGEXP_ENABLED) #ifdef bottom_valid #undef xmlValidatePushElement extern __typeof (xmlValidatePushElement) xmlValidatePushElement __attribute((alias("xmlValidatePushElement__internal_alias"))); #else #ifndef xmlValidatePushElement extern __typeof (xmlValidatePushElement) xmlValidatePushElement__internal_alias __attribute((visibility("hidden"))); #define xmlValidatePushElement xmlValidatePushElement__internal_alias #endif #endif #endif #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_tree #undef xmlValidateQName extern __typeof (xmlValidateQName) xmlValidateQName __attribute((alias("xmlValidateQName__internal_alias"))); #else #ifndef xmlValidateQName extern __typeof (xmlValidateQName) xmlValidateQName__internal_alias __attribute((visibility("hidden"))); #define xmlValidateQName xmlValidateQName__internal_alias #endif #endif #endif #if defined(LIBXML_VALID_ENABLED) #ifdef bottom_valid #undef xmlValidateRoot extern __typeof (xmlValidateRoot) xmlValidateRoot __attribute((alias("xmlValidateRoot__internal_alias"))); #else #ifndef xmlValidateRoot extern __typeof (xmlValidateRoot) xmlValidateRoot__internal_alias __attribute((visibility("hidden"))); #define xmlValidateRoot xmlValidateRoot__internal_alias #endif #endif #endif #if defined(LIBXML_XINCLUDE_ENABLED) #ifdef bottom_xinclude #undef xmlXIncludeFreeContext extern __typeof (xmlXIncludeFreeContext) xmlXIncludeFreeContext __attribute((alias("xmlXIncludeFreeContext__internal_alias"))); #else #ifndef xmlXIncludeFreeContext extern __typeof (xmlXIncludeFreeContext) xmlXIncludeFreeContext__internal_alias __attribute((visibility("hidden"))); #define xmlXIncludeFreeContext xmlXIncludeFreeContext__internal_alias #endif #endif #endif #if defined(LIBXML_XINCLUDE_ENABLED) #ifdef bottom_xinclude #undef xmlXIncludeNewContext extern __typeof (xmlXIncludeNewContext) xmlXIncludeNewContext __attribute((alias("xmlXIncludeNewContext__internal_alias"))); #else #ifndef xmlXIncludeNewContext extern __typeof (xmlXIncludeNewContext) xmlXIncludeNewContext__internal_alias __attribute((visibility("hidden"))); #define xmlXIncludeNewContext xmlXIncludeNewContext__internal_alias #endif #endif #endif #if defined(LIBXML_XINCLUDE_ENABLED) #ifdef bottom_xinclude #undef xmlXIncludeProcess extern __typeof (xmlXIncludeProcess) xmlXIncludeProcess __attribute((alias("xmlXIncludeProcess__internal_alias"))); #else #ifndef xmlXIncludeProcess extern __typeof (xmlXIncludeProcess) xmlXIncludeProcess__internal_alias __attribute((visibility("hidden"))); #define xmlXIncludeProcess xmlXIncludeProcess__internal_alias #endif #endif #endif #if defined(LIBXML_XINCLUDE_ENABLED) #ifdef bottom_xinclude #undef xmlXIncludeProcessFlags extern __typeof (xmlXIncludeProcessFlags) xmlXIncludeProcessFlags __attribute((alias("xmlXIncludeProcessFlags__internal_alias"))); #else #ifndef xmlXIncludeProcessFlags extern __typeof (xmlXIncludeProcessFlags) xmlXIncludeProcessFlags__internal_alias __attribute((visibility("hidden"))); #define xmlXIncludeProcessFlags xmlXIncludeProcessFlags__internal_alias #endif #endif #endif #if defined(LIBXML_XINCLUDE_ENABLED) #ifdef bottom_xinclude #undef xmlXIncludeProcessNode extern __typeof (xmlXIncludeProcessNode) xmlXIncludeProcessNode __attribute((alias("xmlXIncludeProcessNode__internal_alias"))); #else #ifndef xmlXIncludeProcessNode extern __typeof (xmlXIncludeProcessNode) xmlXIncludeProcessNode__internal_alias __attribute((visibility("hidden"))); #define xmlXIncludeProcessNode xmlXIncludeProcessNode__internal_alias #endif #endif #endif #if defined(LIBXML_XINCLUDE_ENABLED) #ifdef bottom_xinclude #undef xmlXIncludeProcessTree extern __typeof (xmlXIncludeProcessTree) xmlXIncludeProcessTree __attribute((alias("xmlXIncludeProcessTree__internal_alias"))); #else #ifndef xmlXIncludeProcessTree extern __typeof (xmlXIncludeProcessTree) xmlXIncludeProcessTree__internal_alias __attribute((visibility("hidden"))); #define xmlXIncludeProcessTree xmlXIncludeProcessTree__internal_alias #endif #endif #endif #if defined(LIBXML_XINCLUDE_ENABLED) #ifdef bottom_xinclude #undef xmlXIncludeProcessTreeFlags extern __typeof (xmlXIncludeProcessTreeFlags) xmlXIncludeProcessTreeFlags __attribute((alias("xmlXIncludeProcessTreeFlags__internal_alias"))); #else #ifndef xmlXIncludeProcessTreeFlags extern __typeof (xmlXIncludeProcessTreeFlags) xmlXIncludeProcessTreeFlags__internal_alias __attribute((visibility("hidden"))); #define xmlXIncludeProcessTreeFlags xmlXIncludeProcessTreeFlags__internal_alias #endif #endif #endif #if defined(LIBXML_XINCLUDE_ENABLED) #ifdef bottom_xinclude #undef xmlXIncludeSetFlags extern __typeof (xmlXIncludeSetFlags) xmlXIncludeSetFlags __attribute((alias("xmlXIncludeSetFlags__internal_alias"))); #else #ifndef xmlXIncludeSetFlags extern __typeof (xmlXIncludeSetFlags) xmlXIncludeSetFlags__internal_alias __attribute((visibility("hidden"))); #define xmlXIncludeSetFlags xmlXIncludeSetFlags__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathAddValues extern __typeof (xmlXPathAddValues) xmlXPathAddValues __attribute((alias("xmlXPathAddValues__internal_alias"))); #else #ifndef xmlXPathAddValues extern __typeof (xmlXPathAddValues) xmlXPathAddValues__internal_alias __attribute((visibility("hidden"))); #define xmlXPathAddValues xmlXPathAddValues__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathBooleanFunction extern __typeof (xmlXPathBooleanFunction) xmlXPathBooleanFunction __attribute((alias("xmlXPathBooleanFunction__internal_alias"))); #else #ifndef xmlXPathBooleanFunction extern __typeof (xmlXPathBooleanFunction) xmlXPathBooleanFunction__internal_alias __attribute((visibility("hidden"))); #define xmlXPathBooleanFunction xmlXPathBooleanFunction__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathCastBooleanToNumber extern __typeof (xmlXPathCastBooleanToNumber) xmlXPathCastBooleanToNumber __attribute((alias("xmlXPathCastBooleanToNumber__internal_alias"))); #else #ifndef xmlXPathCastBooleanToNumber extern __typeof (xmlXPathCastBooleanToNumber) xmlXPathCastBooleanToNumber__internal_alias __attribute((visibility("hidden"))); #define xmlXPathCastBooleanToNumber xmlXPathCastBooleanToNumber__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathCastBooleanToString extern __typeof (xmlXPathCastBooleanToString) xmlXPathCastBooleanToString __attribute((alias("xmlXPathCastBooleanToString__internal_alias"))); #else #ifndef xmlXPathCastBooleanToString extern __typeof (xmlXPathCastBooleanToString) xmlXPathCastBooleanToString__internal_alias __attribute((visibility("hidden"))); #define xmlXPathCastBooleanToString xmlXPathCastBooleanToString__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathCastNodeSetToBoolean extern __typeof (xmlXPathCastNodeSetToBoolean) xmlXPathCastNodeSetToBoolean __attribute((alias("xmlXPathCastNodeSetToBoolean__internal_alias"))); #else #ifndef xmlXPathCastNodeSetToBoolean extern __typeof (xmlXPathCastNodeSetToBoolean) xmlXPathCastNodeSetToBoolean__internal_alias __attribute((visibility("hidden"))); #define xmlXPathCastNodeSetToBoolean xmlXPathCastNodeSetToBoolean__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathCastNodeSetToNumber extern __typeof (xmlXPathCastNodeSetToNumber) xmlXPathCastNodeSetToNumber __attribute((alias("xmlXPathCastNodeSetToNumber__internal_alias"))); #else #ifndef xmlXPathCastNodeSetToNumber extern __typeof (xmlXPathCastNodeSetToNumber) xmlXPathCastNodeSetToNumber__internal_alias __attribute((visibility("hidden"))); #define xmlXPathCastNodeSetToNumber xmlXPathCastNodeSetToNumber__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathCastNodeSetToString extern __typeof (xmlXPathCastNodeSetToString) xmlXPathCastNodeSetToString __attribute((alias("xmlXPathCastNodeSetToString__internal_alias"))); #else #ifndef xmlXPathCastNodeSetToString extern __typeof (xmlXPathCastNodeSetToString) xmlXPathCastNodeSetToString__internal_alias __attribute((visibility("hidden"))); #define xmlXPathCastNodeSetToString xmlXPathCastNodeSetToString__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathCastNodeToNumber extern __typeof (xmlXPathCastNodeToNumber) xmlXPathCastNodeToNumber __attribute((alias("xmlXPathCastNodeToNumber__internal_alias"))); #else #ifndef xmlXPathCastNodeToNumber extern __typeof (xmlXPathCastNodeToNumber) xmlXPathCastNodeToNumber__internal_alias __attribute((visibility("hidden"))); #define xmlXPathCastNodeToNumber xmlXPathCastNodeToNumber__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathCastNodeToString extern __typeof (xmlXPathCastNodeToString) xmlXPathCastNodeToString __attribute((alias("xmlXPathCastNodeToString__internal_alias"))); #else #ifndef xmlXPathCastNodeToString extern __typeof (xmlXPathCastNodeToString) xmlXPathCastNodeToString__internal_alias __attribute((visibility("hidden"))); #define xmlXPathCastNodeToString xmlXPathCastNodeToString__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathCastNumberToBoolean extern __typeof (xmlXPathCastNumberToBoolean) xmlXPathCastNumberToBoolean __attribute((alias("xmlXPathCastNumberToBoolean__internal_alias"))); #else #ifndef xmlXPathCastNumberToBoolean extern __typeof (xmlXPathCastNumberToBoolean) xmlXPathCastNumberToBoolean__internal_alias __attribute((visibility("hidden"))); #define xmlXPathCastNumberToBoolean xmlXPathCastNumberToBoolean__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathCastNumberToString extern __typeof (xmlXPathCastNumberToString) xmlXPathCastNumberToString __attribute((alias("xmlXPathCastNumberToString__internal_alias"))); #else #ifndef xmlXPathCastNumberToString extern __typeof (xmlXPathCastNumberToString) xmlXPathCastNumberToString__internal_alias __attribute((visibility("hidden"))); #define xmlXPathCastNumberToString xmlXPathCastNumberToString__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathCastStringToBoolean extern __typeof (xmlXPathCastStringToBoolean) xmlXPathCastStringToBoolean __attribute((alias("xmlXPathCastStringToBoolean__internal_alias"))); #else #ifndef xmlXPathCastStringToBoolean extern __typeof (xmlXPathCastStringToBoolean) xmlXPathCastStringToBoolean__internal_alias __attribute((visibility("hidden"))); #define xmlXPathCastStringToBoolean xmlXPathCastStringToBoolean__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathCastStringToNumber extern __typeof (xmlXPathCastStringToNumber) xmlXPathCastStringToNumber __attribute((alias("xmlXPathCastStringToNumber__internal_alias"))); #else #ifndef xmlXPathCastStringToNumber extern __typeof (xmlXPathCastStringToNumber) xmlXPathCastStringToNumber__internal_alias __attribute((visibility("hidden"))); #define xmlXPathCastStringToNumber xmlXPathCastStringToNumber__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathCastToBoolean extern __typeof (xmlXPathCastToBoolean) xmlXPathCastToBoolean __attribute((alias("xmlXPathCastToBoolean__internal_alias"))); #else #ifndef xmlXPathCastToBoolean extern __typeof (xmlXPathCastToBoolean) xmlXPathCastToBoolean__internal_alias __attribute((visibility("hidden"))); #define xmlXPathCastToBoolean xmlXPathCastToBoolean__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathCastToNumber extern __typeof (xmlXPathCastToNumber) xmlXPathCastToNumber __attribute((alias("xmlXPathCastToNumber__internal_alias"))); #else #ifndef xmlXPathCastToNumber extern __typeof (xmlXPathCastToNumber) xmlXPathCastToNumber__internal_alias __attribute((visibility("hidden"))); #define xmlXPathCastToNumber xmlXPathCastToNumber__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathCastToString extern __typeof (xmlXPathCastToString) xmlXPathCastToString __attribute((alias("xmlXPathCastToString__internal_alias"))); #else #ifndef xmlXPathCastToString extern __typeof (xmlXPathCastToString) xmlXPathCastToString__internal_alias __attribute((visibility("hidden"))); #define xmlXPathCastToString xmlXPathCastToString__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathCeilingFunction extern __typeof (xmlXPathCeilingFunction) xmlXPathCeilingFunction __attribute((alias("xmlXPathCeilingFunction__internal_alias"))); #else #ifndef xmlXPathCeilingFunction extern __typeof (xmlXPathCeilingFunction) xmlXPathCeilingFunction__internal_alias __attribute((visibility("hidden"))); #define xmlXPathCeilingFunction xmlXPathCeilingFunction__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathCmpNodes extern __typeof (xmlXPathCmpNodes) xmlXPathCmpNodes __attribute((alias("xmlXPathCmpNodes__internal_alias"))); #else #ifndef xmlXPathCmpNodes extern __typeof (xmlXPathCmpNodes) xmlXPathCmpNodes__internal_alias __attribute((visibility("hidden"))); #define xmlXPathCmpNodes xmlXPathCmpNodes__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathCompareValues extern __typeof (xmlXPathCompareValues) xmlXPathCompareValues __attribute((alias("xmlXPathCompareValues__internal_alias"))); #else #ifndef xmlXPathCompareValues extern __typeof (xmlXPathCompareValues) xmlXPathCompareValues__internal_alias __attribute((visibility("hidden"))); #define xmlXPathCompareValues xmlXPathCompareValues__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathCompile extern __typeof (xmlXPathCompile) xmlXPathCompile __attribute((alias("xmlXPathCompile__internal_alias"))); #else #ifndef xmlXPathCompile extern __typeof (xmlXPathCompile) xmlXPathCompile__internal_alias __attribute((visibility("hidden"))); #define xmlXPathCompile xmlXPathCompile__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathCompiledEval extern __typeof (xmlXPathCompiledEval) xmlXPathCompiledEval __attribute((alias("xmlXPathCompiledEval__internal_alias"))); #else #ifndef xmlXPathCompiledEval extern __typeof (xmlXPathCompiledEval) xmlXPathCompiledEval__internal_alias __attribute((visibility("hidden"))); #define xmlXPathCompiledEval xmlXPathCompiledEval__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathConcatFunction extern __typeof (xmlXPathConcatFunction) xmlXPathConcatFunction __attribute((alias("xmlXPathConcatFunction__internal_alias"))); #else #ifndef xmlXPathConcatFunction extern __typeof (xmlXPathConcatFunction) xmlXPathConcatFunction__internal_alias __attribute((visibility("hidden"))); #define xmlXPathConcatFunction xmlXPathConcatFunction__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathContainsFunction extern __typeof (xmlXPathContainsFunction) xmlXPathContainsFunction __attribute((alias("xmlXPathContainsFunction__internal_alias"))); #else #ifndef xmlXPathContainsFunction extern __typeof (xmlXPathContainsFunction) xmlXPathContainsFunction__internal_alias __attribute((visibility("hidden"))); #define xmlXPathContainsFunction xmlXPathContainsFunction__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathConvertBoolean extern __typeof (xmlXPathConvertBoolean) xmlXPathConvertBoolean __attribute((alias("xmlXPathConvertBoolean__internal_alias"))); #else #ifndef xmlXPathConvertBoolean extern __typeof (xmlXPathConvertBoolean) xmlXPathConvertBoolean__internal_alias __attribute((visibility("hidden"))); #define xmlXPathConvertBoolean xmlXPathConvertBoolean__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathConvertNumber extern __typeof (xmlXPathConvertNumber) xmlXPathConvertNumber __attribute((alias("xmlXPathConvertNumber__internal_alias"))); #else #ifndef xmlXPathConvertNumber extern __typeof (xmlXPathConvertNumber) xmlXPathConvertNumber__internal_alias __attribute((visibility("hidden"))); #define xmlXPathConvertNumber xmlXPathConvertNumber__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathConvertString extern __typeof (xmlXPathConvertString) xmlXPathConvertString __attribute((alias("xmlXPathConvertString__internal_alias"))); #else #ifndef xmlXPathConvertString extern __typeof (xmlXPathConvertString) xmlXPathConvertString__internal_alias __attribute((visibility("hidden"))); #define xmlXPathConvertString xmlXPathConvertString__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathCountFunction extern __typeof (xmlXPathCountFunction) xmlXPathCountFunction __attribute((alias("xmlXPathCountFunction__internal_alias"))); #else #ifndef xmlXPathCountFunction extern __typeof (xmlXPathCountFunction) xmlXPathCountFunction__internal_alias __attribute((visibility("hidden"))); #define xmlXPathCountFunction xmlXPathCountFunction__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathCtxtCompile extern __typeof (xmlXPathCtxtCompile) xmlXPathCtxtCompile __attribute((alias("xmlXPathCtxtCompile__internal_alias"))); #else #ifndef xmlXPathCtxtCompile extern __typeof (xmlXPathCtxtCompile) xmlXPathCtxtCompile__internal_alias __attribute((visibility("hidden"))); #define xmlXPathCtxtCompile xmlXPathCtxtCompile__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) && defined(LIBXML_DEBUG_ENABLED) #ifdef bottom_xpath #undef xmlXPathDebugDumpCompExpr extern __typeof (xmlXPathDebugDumpCompExpr) xmlXPathDebugDumpCompExpr __attribute((alias("xmlXPathDebugDumpCompExpr__internal_alias"))); #else #ifndef xmlXPathDebugDumpCompExpr extern __typeof (xmlXPathDebugDumpCompExpr) xmlXPathDebugDumpCompExpr__internal_alias __attribute((visibility("hidden"))); #define xmlXPathDebugDumpCompExpr xmlXPathDebugDumpCompExpr__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) && defined(LIBXML_DEBUG_ENABLED) #ifdef bottom_xpath #undef xmlXPathDebugDumpObject extern __typeof (xmlXPathDebugDumpObject) xmlXPathDebugDumpObject __attribute((alias("xmlXPathDebugDumpObject__internal_alias"))); #else #ifndef xmlXPathDebugDumpObject extern __typeof (xmlXPathDebugDumpObject) xmlXPathDebugDumpObject__internal_alias __attribute((visibility("hidden"))); #define xmlXPathDebugDumpObject xmlXPathDebugDumpObject__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathDifference extern __typeof (xmlXPathDifference) xmlXPathDifference __attribute((alias("xmlXPathDifference__internal_alias"))); #else #ifndef xmlXPathDifference extern __typeof (xmlXPathDifference) xmlXPathDifference__internal_alias __attribute((visibility("hidden"))); #define xmlXPathDifference xmlXPathDifference__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathDistinct extern __typeof (xmlXPathDistinct) xmlXPathDistinct __attribute((alias("xmlXPathDistinct__internal_alias"))); #else #ifndef xmlXPathDistinct extern __typeof (xmlXPathDistinct) xmlXPathDistinct__internal_alias __attribute((visibility("hidden"))); #define xmlXPathDistinct xmlXPathDistinct__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathDistinctSorted extern __typeof (xmlXPathDistinctSorted) xmlXPathDistinctSorted __attribute((alias("xmlXPathDistinctSorted__internal_alias"))); #else #ifndef xmlXPathDistinctSorted extern __typeof (xmlXPathDistinctSorted) xmlXPathDistinctSorted__internal_alias __attribute((visibility("hidden"))); #define xmlXPathDistinctSorted xmlXPathDistinctSorted__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathDivValues extern __typeof (xmlXPathDivValues) xmlXPathDivValues __attribute((alias("xmlXPathDivValues__internal_alias"))); #else #ifndef xmlXPathDivValues extern __typeof (xmlXPathDivValues) xmlXPathDivValues__internal_alias __attribute((visibility("hidden"))); #define xmlXPathDivValues xmlXPathDivValues__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathEqualValues extern __typeof (xmlXPathEqualValues) xmlXPathEqualValues __attribute((alias("xmlXPathEqualValues__internal_alias"))); #else #ifndef xmlXPathEqualValues extern __typeof (xmlXPathEqualValues) xmlXPathEqualValues__internal_alias __attribute((visibility("hidden"))); #define xmlXPathEqualValues xmlXPathEqualValues__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathErr extern __typeof (xmlXPathErr) xmlXPathErr __attribute((alias("xmlXPathErr__internal_alias"))); #else #ifndef xmlXPathErr extern __typeof (xmlXPathErr) xmlXPathErr__internal_alias __attribute((visibility("hidden"))); #define xmlXPathErr xmlXPathErr__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathEval extern __typeof (xmlXPathEval) xmlXPathEval __attribute((alias("xmlXPathEval__internal_alias"))); #else #ifndef xmlXPathEval extern __typeof (xmlXPathEval) xmlXPathEval__internal_alias __attribute((visibility("hidden"))); #define xmlXPathEval xmlXPathEval__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathEvalExpr extern __typeof (xmlXPathEvalExpr) xmlXPathEvalExpr __attribute((alias("xmlXPathEvalExpr__internal_alias"))); #else #ifndef xmlXPathEvalExpr extern __typeof (xmlXPathEvalExpr) xmlXPathEvalExpr__internal_alias __attribute((visibility("hidden"))); #define xmlXPathEvalExpr xmlXPathEvalExpr__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathEvalExpression extern __typeof (xmlXPathEvalExpression) xmlXPathEvalExpression __attribute((alias("xmlXPathEvalExpression__internal_alias"))); #else #ifndef xmlXPathEvalExpression extern __typeof (xmlXPathEvalExpression) xmlXPathEvalExpression__internal_alias __attribute((visibility("hidden"))); #define xmlXPathEvalExpression xmlXPathEvalExpression__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathEvalPredicate extern __typeof (xmlXPathEvalPredicate) xmlXPathEvalPredicate __attribute((alias("xmlXPathEvalPredicate__internal_alias"))); #else #ifndef xmlXPathEvalPredicate extern __typeof (xmlXPathEvalPredicate) xmlXPathEvalPredicate__internal_alias __attribute((visibility("hidden"))); #define xmlXPathEvalPredicate xmlXPathEvalPredicate__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathEvaluatePredicateResult extern __typeof (xmlXPathEvaluatePredicateResult) xmlXPathEvaluatePredicateResult __attribute((alias("xmlXPathEvaluatePredicateResult__internal_alias"))); #else #ifndef xmlXPathEvaluatePredicateResult extern __typeof (xmlXPathEvaluatePredicateResult) xmlXPathEvaluatePredicateResult__internal_alias __attribute((visibility("hidden"))); #define xmlXPathEvaluatePredicateResult xmlXPathEvaluatePredicateResult__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathFalseFunction extern __typeof (xmlXPathFalseFunction) xmlXPathFalseFunction __attribute((alias("xmlXPathFalseFunction__internal_alias"))); #else #ifndef xmlXPathFalseFunction extern __typeof (xmlXPathFalseFunction) xmlXPathFalseFunction__internal_alias __attribute((visibility("hidden"))); #define xmlXPathFalseFunction xmlXPathFalseFunction__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathFloorFunction extern __typeof (xmlXPathFloorFunction) xmlXPathFloorFunction __attribute((alias("xmlXPathFloorFunction__internal_alias"))); #else #ifndef xmlXPathFloorFunction extern __typeof (xmlXPathFloorFunction) xmlXPathFloorFunction__internal_alias __attribute((visibility("hidden"))); #define xmlXPathFloorFunction xmlXPathFloorFunction__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathFreeCompExpr extern __typeof (xmlXPathFreeCompExpr) xmlXPathFreeCompExpr __attribute((alias("xmlXPathFreeCompExpr__internal_alias"))); #else #ifndef xmlXPathFreeCompExpr extern __typeof (xmlXPathFreeCompExpr) xmlXPathFreeCompExpr__internal_alias __attribute((visibility("hidden"))); #define xmlXPathFreeCompExpr xmlXPathFreeCompExpr__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathFreeContext extern __typeof (xmlXPathFreeContext) xmlXPathFreeContext __attribute((alias("xmlXPathFreeContext__internal_alias"))); #else #ifndef xmlXPathFreeContext extern __typeof (xmlXPathFreeContext) xmlXPathFreeContext__internal_alias __attribute((visibility("hidden"))); #define xmlXPathFreeContext xmlXPathFreeContext__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathFreeNodeSet extern __typeof (xmlXPathFreeNodeSet) xmlXPathFreeNodeSet __attribute((alias("xmlXPathFreeNodeSet__internal_alias"))); #else #ifndef xmlXPathFreeNodeSet extern __typeof (xmlXPathFreeNodeSet) xmlXPathFreeNodeSet__internal_alias __attribute((visibility("hidden"))); #define xmlXPathFreeNodeSet xmlXPathFreeNodeSet__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathFreeNodeSetList extern __typeof (xmlXPathFreeNodeSetList) xmlXPathFreeNodeSetList __attribute((alias("xmlXPathFreeNodeSetList__internal_alias"))); #else #ifndef xmlXPathFreeNodeSetList extern __typeof (xmlXPathFreeNodeSetList) xmlXPathFreeNodeSetList__internal_alias __attribute((visibility("hidden"))); #define xmlXPathFreeNodeSetList xmlXPathFreeNodeSetList__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathFreeObject extern __typeof (xmlXPathFreeObject) xmlXPathFreeObject __attribute((alias("xmlXPathFreeObject__internal_alias"))); #else #ifndef xmlXPathFreeObject extern __typeof (xmlXPathFreeObject) xmlXPathFreeObject__internal_alias __attribute((visibility("hidden"))); #define xmlXPathFreeObject xmlXPathFreeObject__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathFreeParserContext extern __typeof (xmlXPathFreeParserContext) xmlXPathFreeParserContext __attribute((alias("xmlXPathFreeParserContext__internal_alias"))); #else #ifndef xmlXPathFreeParserContext extern __typeof (xmlXPathFreeParserContext) xmlXPathFreeParserContext__internal_alias __attribute((visibility("hidden"))); #define xmlXPathFreeParserContext xmlXPathFreeParserContext__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathFunctionLookup extern __typeof (xmlXPathFunctionLookup) xmlXPathFunctionLookup __attribute((alias("xmlXPathFunctionLookup__internal_alias"))); #else #ifndef xmlXPathFunctionLookup extern __typeof (xmlXPathFunctionLookup) xmlXPathFunctionLookup__internal_alias __attribute((visibility("hidden"))); #define xmlXPathFunctionLookup xmlXPathFunctionLookup__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathFunctionLookupNS extern __typeof (xmlXPathFunctionLookupNS) xmlXPathFunctionLookupNS __attribute((alias("xmlXPathFunctionLookupNS__internal_alias"))); #else #ifndef xmlXPathFunctionLookupNS extern __typeof (xmlXPathFunctionLookupNS) xmlXPathFunctionLookupNS__internal_alias __attribute((visibility("hidden"))); #define xmlXPathFunctionLookupNS xmlXPathFunctionLookupNS__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathHasSameNodes extern __typeof (xmlXPathHasSameNodes) xmlXPathHasSameNodes __attribute((alias("xmlXPathHasSameNodes__internal_alias"))); #else #ifndef xmlXPathHasSameNodes extern __typeof (xmlXPathHasSameNodes) xmlXPathHasSameNodes__internal_alias __attribute((visibility("hidden"))); #define xmlXPathHasSameNodes xmlXPathHasSameNodes__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathIdFunction extern __typeof (xmlXPathIdFunction) xmlXPathIdFunction __attribute((alias("xmlXPathIdFunction__internal_alias"))); #else #ifndef xmlXPathIdFunction extern __typeof (xmlXPathIdFunction) xmlXPathIdFunction__internal_alias __attribute((visibility("hidden"))); #define xmlXPathIdFunction xmlXPathIdFunction__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xpath #undef xmlXPathInit extern __typeof (xmlXPathInit) xmlXPathInit __attribute((alias("xmlXPathInit__internal_alias"))); #else #ifndef xmlXPathInit extern __typeof (xmlXPathInit) xmlXPathInit__internal_alias __attribute((visibility("hidden"))); #define xmlXPathInit xmlXPathInit__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathIntersection extern __typeof (xmlXPathIntersection) xmlXPathIntersection __attribute((alias("xmlXPathIntersection__internal_alias"))); #else #ifndef xmlXPathIntersection extern __typeof (xmlXPathIntersection) xmlXPathIntersection__internal_alias __attribute((visibility("hidden"))); #define xmlXPathIntersection xmlXPathIntersection__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xpath #undef xmlXPathIsInf extern __typeof (xmlXPathIsInf) xmlXPathIsInf __attribute((alias("xmlXPathIsInf__internal_alias"))); #else #ifndef xmlXPathIsInf extern __typeof (xmlXPathIsInf) xmlXPathIsInf__internal_alias __attribute((visibility("hidden"))); #define xmlXPathIsInf xmlXPathIsInf__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) #ifdef bottom_xpath #undef xmlXPathIsNaN extern __typeof (xmlXPathIsNaN) xmlXPathIsNaN __attribute((alias("xmlXPathIsNaN__internal_alias"))); #else #ifndef xmlXPathIsNaN extern __typeof (xmlXPathIsNaN) xmlXPathIsNaN__internal_alias __attribute((visibility("hidden"))); #define xmlXPathIsNaN xmlXPathIsNaN__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathIsNodeType extern __typeof (xmlXPathIsNodeType) xmlXPathIsNodeType __attribute((alias("xmlXPathIsNodeType__internal_alias"))); #else #ifndef xmlXPathIsNodeType extern __typeof (xmlXPathIsNodeType) xmlXPathIsNodeType__internal_alias __attribute((visibility("hidden"))); #define xmlXPathIsNodeType xmlXPathIsNodeType__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathLangFunction extern __typeof (xmlXPathLangFunction) xmlXPathLangFunction __attribute((alias("xmlXPathLangFunction__internal_alias"))); #else #ifndef xmlXPathLangFunction extern __typeof (xmlXPathLangFunction) xmlXPathLangFunction__internal_alias __attribute((visibility("hidden"))); #define xmlXPathLangFunction xmlXPathLangFunction__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathLastFunction extern __typeof (xmlXPathLastFunction) xmlXPathLastFunction __attribute((alias("xmlXPathLastFunction__internal_alias"))); #else #ifndef xmlXPathLastFunction extern __typeof (xmlXPathLastFunction) xmlXPathLastFunction__internal_alias __attribute((visibility("hidden"))); #define xmlXPathLastFunction xmlXPathLastFunction__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathLeading extern __typeof (xmlXPathLeading) xmlXPathLeading __attribute((alias("xmlXPathLeading__internal_alias"))); #else #ifndef xmlXPathLeading extern __typeof (xmlXPathLeading) xmlXPathLeading__internal_alias __attribute((visibility("hidden"))); #define xmlXPathLeading xmlXPathLeading__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathLeadingSorted extern __typeof (xmlXPathLeadingSorted) xmlXPathLeadingSorted __attribute((alias("xmlXPathLeadingSorted__internal_alias"))); #else #ifndef xmlXPathLeadingSorted extern __typeof (xmlXPathLeadingSorted) xmlXPathLeadingSorted__internal_alias __attribute((visibility("hidden"))); #define xmlXPathLeadingSorted xmlXPathLeadingSorted__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathLocalNameFunction extern __typeof (xmlXPathLocalNameFunction) xmlXPathLocalNameFunction __attribute((alias("xmlXPathLocalNameFunction__internal_alias"))); #else #ifndef xmlXPathLocalNameFunction extern __typeof (xmlXPathLocalNameFunction) xmlXPathLocalNameFunction__internal_alias __attribute((visibility("hidden"))); #define xmlXPathLocalNameFunction xmlXPathLocalNameFunction__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathModValues extern __typeof (xmlXPathModValues) xmlXPathModValues __attribute((alias("xmlXPathModValues__internal_alias"))); #else #ifndef xmlXPathModValues extern __typeof (xmlXPathModValues) xmlXPathModValues__internal_alias __attribute((visibility("hidden"))); #define xmlXPathModValues xmlXPathModValues__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathMultValues extern __typeof (xmlXPathMultValues) xmlXPathMultValues __attribute((alias("xmlXPathMultValues__internal_alias"))); #else #ifndef xmlXPathMultValues extern __typeof (xmlXPathMultValues) xmlXPathMultValues__internal_alias __attribute((visibility("hidden"))); #define xmlXPathMultValues xmlXPathMultValues__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathNamespaceURIFunction extern __typeof (xmlXPathNamespaceURIFunction) xmlXPathNamespaceURIFunction __attribute((alias("xmlXPathNamespaceURIFunction__internal_alias"))); #else #ifndef xmlXPathNamespaceURIFunction extern __typeof (xmlXPathNamespaceURIFunction) xmlXPathNamespaceURIFunction__internal_alias __attribute((visibility("hidden"))); #define xmlXPathNamespaceURIFunction xmlXPathNamespaceURIFunction__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathNewBoolean extern __typeof (xmlXPathNewBoolean) xmlXPathNewBoolean __attribute((alias("xmlXPathNewBoolean__internal_alias"))); #else #ifndef xmlXPathNewBoolean extern __typeof (xmlXPathNewBoolean) xmlXPathNewBoolean__internal_alias __attribute((visibility("hidden"))); #define xmlXPathNewBoolean xmlXPathNewBoolean__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathNewCString extern __typeof (xmlXPathNewCString) xmlXPathNewCString __attribute((alias("xmlXPathNewCString__internal_alias"))); #else #ifndef xmlXPathNewCString extern __typeof (xmlXPathNewCString) xmlXPathNewCString__internal_alias __attribute((visibility("hidden"))); #define xmlXPathNewCString xmlXPathNewCString__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathNewContext extern __typeof (xmlXPathNewContext) xmlXPathNewContext __attribute((alias("xmlXPathNewContext__internal_alias"))); #else #ifndef xmlXPathNewContext extern __typeof (xmlXPathNewContext) xmlXPathNewContext__internal_alias __attribute((visibility("hidden"))); #define xmlXPathNewContext xmlXPathNewContext__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathNewFloat extern __typeof (xmlXPathNewFloat) xmlXPathNewFloat __attribute((alias("xmlXPathNewFloat__internal_alias"))); #else #ifndef xmlXPathNewFloat extern __typeof (xmlXPathNewFloat) xmlXPathNewFloat__internal_alias __attribute((visibility("hidden"))); #define xmlXPathNewFloat xmlXPathNewFloat__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathNewNodeSet extern __typeof (xmlXPathNewNodeSet) xmlXPathNewNodeSet __attribute((alias("xmlXPathNewNodeSet__internal_alias"))); #else #ifndef xmlXPathNewNodeSet extern __typeof (xmlXPathNewNodeSet) xmlXPathNewNodeSet__internal_alias __attribute((visibility("hidden"))); #define xmlXPathNewNodeSet xmlXPathNewNodeSet__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathNewNodeSetList extern __typeof (xmlXPathNewNodeSetList) xmlXPathNewNodeSetList __attribute((alias("xmlXPathNewNodeSetList__internal_alias"))); #else #ifndef xmlXPathNewNodeSetList extern __typeof (xmlXPathNewNodeSetList) xmlXPathNewNodeSetList__internal_alias __attribute((visibility("hidden"))); #define xmlXPathNewNodeSetList xmlXPathNewNodeSetList__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathNewParserContext extern __typeof (xmlXPathNewParserContext) xmlXPathNewParserContext __attribute((alias("xmlXPathNewParserContext__internal_alias"))); #else #ifndef xmlXPathNewParserContext extern __typeof (xmlXPathNewParserContext) xmlXPathNewParserContext__internal_alias __attribute((visibility("hidden"))); #define xmlXPathNewParserContext xmlXPathNewParserContext__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathNewString extern __typeof (xmlXPathNewString) xmlXPathNewString __attribute((alias("xmlXPathNewString__internal_alias"))); #else #ifndef xmlXPathNewString extern __typeof (xmlXPathNewString) xmlXPathNewString__internal_alias __attribute((visibility("hidden"))); #define xmlXPathNewString xmlXPathNewString__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathNewValueTree extern __typeof (xmlXPathNewValueTree) xmlXPathNewValueTree __attribute((alias("xmlXPathNewValueTree__internal_alias"))); #else #ifndef xmlXPathNewValueTree extern __typeof (xmlXPathNewValueTree) xmlXPathNewValueTree__internal_alias __attribute((visibility("hidden"))); #define xmlXPathNewValueTree xmlXPathNewValueTree__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathNextAncestor extern __typeof (xmlXPathNextAncestor) xmlXPathNextAncestor __attribute((alias("xmlXPathNextAncestor__internal_alias"))); #else #ifndef xmlXPathNextAncestor extern __typeof (xmlXPathNextAncestor) xmlXPathNextAncestor__internal_alias __attribute((visibility("hidden"))); #define xmlXPathNextAncestor xmlXPathNextAncestor__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathNextAncestorOrSelf extern __typeof (xmlXPathNextAncestorOrSelf) xmlXPathNextAncestorOrSelf __attribute((alias("xmlXPathNextAncestorOrSelf__internal_alias"))); #else #ifndef xmlXPathNextAncestorOrSelf extern __typeof (xmlXPathNextAncestorOrSelf) xmlXPathNextAncestorOrSelf__internal_alias __attribute((visibility("hidden"))); #define xmlXPathNextAncestorOrSelf xmlXPathNextAncestorOrSelf__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathNextAttribute extern __typeof (xmlXPathNextAttribute) xmlXPathNextAttribute __attribute((alias("xmlXPathNextAttribute__internal_alias"))); #else #ifndef xmlXPathNextAttribute extern __typeof (xmlXPathNextAttribute) xmlXPathNextAttribute__internal_alias __attribute((visibility("hidden"))); #define xmlXPathNextAttribute xmlXPathNextAttribute__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathNextChild extern __typeof (xmlXPathNextChild) xmlXPathNextChild __attribute((alias("xmlXPathNextChild__internal_alias"))); #else #ifndef xmlXPathNextChild extern __typeof (xmlXPathNextChild) xmlXPathNextChild__internal_alias __attribute((visibility("hidden"))); #define xmlXPathNextChild xmlXPathNextChild__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathNextDescendant extern __typeof (xmlXPathNextDescendant) xmlXPathNextDescendant __attribute((alias("xmlXPathNextDescendant__internal_alias"))); #else #ifndef xmlXPathNextDescendant extern __typeof (xmlXPathNextDescendant) xmlXPathNextDescendant__internal_alias __attribute((visibility("hidden"))); #define xmlXPathNextDescendant xmlXPathNextDescendant__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathNextDescendantOrSelf extern __typeof (xmlXPathNextDescendantOrSelf) xmlXPathNextDescendantOrSelf __attribute((alias("xmlXPathNextDescendantOrSelf__internal_alias"))); #else #ifndef xmlXPathNextDescendantOrSelf extern __typeof (xmlXPathNextDescendantOrSelf) xmlXPathNextDescendantOrSelf__internal_alias __attribute((visibility("hidden"))); #define xmlXPathNextDescendantOrSelf xmlXPathNextDescendantOrSelf__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathNextFollowing extern __typeof (xmlXPathNextFollowing) xmlXPathNextFollowing __attribute((alias("xmlXPathNextFollowing__internal_alias"))); #else #ifndef xmlXPathNextFollowing extern __typeof (xmlXPathNextFollowing) xmlXPathNextFollowing__internal_alias __attribute((visibility("hidden"))); #define xmlXPathNextFollowing xmlXPathNextFollowing__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathNextFollowingSibling extern __typeof (xmlXPathNextFollowingSibling) xmlXPathNextFollowingSibling __attribute((alias("xmlXPathNextFollowingSibling__internal_alias"))); #else #ifndef xmlXPathNextFollowingSibling extern __typeof (xmlXPathNextFollowingSibling) xmlXPathNextFollowingSibling__internal_alias __attribute((visibility("hidden"))); #define xmlXPathNextFollowingSibling xmlXPathNextFollowingSibling__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathNextNamespace extern __typeof (xmlXPathNextNamespace) xmlXPathNextNamespace __attribute((alias("xmlXPathNextNamespace__internal_alias"))); #else #ifndef xmlXPathNextNamespace extern __typeof (xmlXPathNextNamespace) xmlXPathNextNamespace__internal_alias __attribute((visibility("hidden"))); #define xmlXPathNextNamespace xmlXPathNextNamespace__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathNextParent extern __typeof (xmlXPathNextParent) xmlXPathNextParent __attribute((alias("xmlXPathNextParent__internal_alias"))); #else #ifndef xmlXPathNextParent extern __typeof (xmlXPathNextParent) xmlXPathNextParent__internal_alias __attribute((visibility("hidden"))); #define xmlXPathNextParent xmlXPathNextParent__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathNextPreceding extern __typeof (xmlXPathNextPreceding) xmlXPathNextPreceding __attribute((alias("xmlXPathNextPreceding__internal_alias"))); #else #ifndef xmlXPathNextPreceding extern __typeof (xmlXPathNextPreceding) xmlXPathNextPreceding__internal_alias __attribute((visibility("hidden"))); #define xmlXPathNextPreceding xmlXPathNextPreceding__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathNextPrecedingSibling extern __typeof (xmlXPathNextPrecedingSibling) xmlXPathNextPrecedingSibling __attribute((alias("xmlXPathNextPrecedingSibling__internal_alias"))); #else #ifndef xmlXPathNextPrecedingSibling extern __typeof (xmlXPathNextPrecedingSibling) xmlXPathNextPrecedingSibling__internal_alias __attribute((visibility("hidden"))); #define xmlXPathNextPrecedingSibling xmlXPathNextPrecedingSibling__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathNextSelf extern __typeof (xmlXPathNextSelf) xmlXPathNextSelf __attribute((alias("xmlXPathNextSelf__internal_alias"))); #else #ifndef xmlXPathNextSelf extern __typeof (xmlXPathNextSelf) xmlXPathNextSelf__internal_alias __attribute((visibility("hidden"))); #define xmlXPathNextSelf xmlXPathNextSelf__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathNodeLeading extern __typeof (xmlXPathNodeLeading) xmlXPathNodeLeading __attribute((alias("xmlXPathNodeLeading__internal_alias"))); #else #ifndef xmlXPathNodeLeading extern __typeof (xmlXPathNodeLeading) xmlXPathNodeLeading__internal_alias __attribute((visibility("hidden"))); #define xmlXPathNodeLeading xmlXPathNodeLeading__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathNodeLeadingSorted extern __typeof (xmlXPathNodeLeadingSorted) xmlXPathNodeLeadingSorted __attribute((alias("xmlXPathNodeLeadingSorted__internal_alias"))); #else #ifndef xmlXPathNodeLeadingSorted extern __typeof (xmlXPathNodeLeadingSorted) xmlXPathNodeLeadingSorted__internal_alias __attribute((visibility("hidden"))); #define xmlXPathNodeLeadingSorted xmlXPathNodeLeadingSorted__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathNodeSetAdd extern __typeof (xmlXPathNodeSetAdd) xmlXPathNodeSetAdd __attribute((alias("xmlXPathNodeSetAdd__internal_alias"))); #else #ifndef xmlXPathNodeSetAdd extern __typeof (xmlXPathNodeSetAdd) xmlXPathNodeSetAdd__internal_alias __attribute((visibility("hidden"))); #define xmlXPathNodeSetAdd xmlXPathNodeSetAdd__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathNodeSetAddNs extern __typeof (xmlXPathNodeSetAddNs) xmlXPathNodeSetAddNs __attribute((alias("xmlXPathNodeSetAddNs__internal_alias"))); #else #ifndef xmlXPathNodeSetAddNs extern __typeof (xmlXPathNodeSetAddNs) xmlXPathNodeSetAddNs__internal_alias __attribute((visibility("hidden"))); #define xmlXPathNodeSetAddNs xmlXPathNodeSetAddNs__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathNodeSetAddUnique extern __typeof (xmlXPathNodeSetAddUnique) xmlXPathNodeSetAddUnique __attribute((alias("xmlXPathNodeSetAddUnique__internal_alias"))); #else #ifndef xmlXPathNodeSetAddUnique extern __typeof (xmlXPathNodeSetAddUnique) xmlXPathNodeSetAddUnique__internal_alias __attribute((visibility("hidden"))); #define xmlXPathNodeSetAddUnique xmlXPathNodeSetAddUnique__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathNodeSetContains extern __typeof (xmlXPathNodeSetContains) xmlXPathNodeSetContains __attribute((alias("xmlXPathNodeSetContains__internal_alias"))); #else #ifndef xmlXPathNodeSetContains extern __typeof (xmlXPathNodeSetContains) xmlXPathNodeSetContains__internal_alias __attribute((visibility("hidden"))); #define xmlXPathNodeSetContains xmlXPathNodeSetContains__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathNodeSetCreate extern __typeof (xmlXPathNodeSetCreate) xmlXPathNodeSetCreate __attribute((alias("xmlXPathNodeSetCreate__internal_alias"))); #else #ifndef xmlXPathNodeSetCreate extern __typeof (xmlXPathNodeSetCreate) xmlXPathNodeSetCreate__internal_alias __attribute((visibility("hidden"))); #define xmlXPathNodeSetCreate xmlXPathNodeSetCreate__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathNodeSetDel extern __typeof (xmlXPathNodeSetDel) xmlXPathNodeSetDel __attribute((alias("xmlXPathNodeSetDel__internal_alias"))); #else #ifndef xmlXPathNodeSetDel extern __typeof (xmlXPathNodeSetDel) xmlXPathNodeSetDel__internal_alias __attribute((visibility("hidden"))); #define xmlXPathNodeSetDel xmlXPathNodeSetDel__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathNodeSetFreeNs extern __typeof (xmlXPathNodeSetFreeNs) xmlXPathNodeSetFreeNs __attribute((alias("xmlXPathNodeSetFreeNs__internal_alias"))); #else #ifndef xmlXPathNodeSetFreeNs extern __typeof (xmlXPathNodeSetFreeNs) xmlXPathNodeSetFreeNs__internal_alias __attribute((visibility("hidden"))); #define xmlXPathNodeSetFreeNs xmlXPathNodeSetFreeNs__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathNodeSetMerge extern __typeof (xmlXPathNodeSetMerge) xmlXPathNodeSetMerge __attribute((alias("xmlXPathNodeSetMerge__internal_alias"))); #else #ifndef xmlXPathNodeSetMerge extern __typeof (xmlXPathNodeSetMerge) xmlXPathNodeSetMerge__internal_alias __attribute((visibility("hidden"))); #define xmlXPathNodeSetMerge xmlXPathNodeSetMerge__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathNodeSetRemove extern __typeof (xmlXPathNodeSetRemove) xmlXPathNodeSetRemove __attribute((alias("xmlXPathNodeSetRemove__internal_alias"))); #else #ifndef xmlXPathNodeSetRemove extern __typeof (xmlXPathNodeSetRemove) xmlXPathNodeSetRemove__internal_alias __attribute((visibility("hidden"))); #define xmlXPathNodeSetRemove xmlXPathNodeSetRemove__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathNodeSetSort extern __typeof (xmlXPathNodeSetSort) xmlXPathNodeSetSort __attribute((alias("xmlXPathNodeSetSort__internal_alias"))); #else #ifndef xmlXPathNodeSetSort extern __typeof (xmlXPathNodeSetSort) xmlXPathNodeSetSort__internal_alias __attribute((visibility("hidden"))); #define xmlXPathNodeSetSort xmlXPathNodeSetSort__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathNodeTrailing extern __typeof (xmlXPathNodeTrailing) xmlXPathNodeTrailing __attribute((alias("xmlXPathNodeTrailing__internal_alias"))); #else #ifndef xmlXPathNodeTrailing extern __typeof (xmlXPathNodeTrailing) xmlXPathNodeTrailing__internal_alias __attribute((visibility("hidden"))); #define xmlXPathNodeTrailing xmlXPathNodeTrailing__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathNodeTrailingSorted extern __typeof (xmlXPathNodeTrailingSorted) xmlXPathNodeTrailingSorted __attribute((alias("xmlXPathNodeTrailingSorted__internal_alias"))); #else #ifndef xmlXPathNodeTrailingSorted extern __typeof (xmlXPathNodeTrailingSorted) xmlXPathNodeTrailingSorted__internal_alias __attribute((visibility("hidden"))); #define xmlXPathNodeTrailingSorted xmlXPathNodeTrailingSorted__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathNormalizeFunction extern __typeof (xmlXPathNormalizeFunction) xmlXPathNormalizeFunction __attribute((alias("xmlXPathNormalizeFunction__internal_alias"))); #else #ifndef xmlXPathNormalizeFunction extern __typeof (xmlXPathNormalizeFunction) xmlXPathNormalizeFunction__internal_alias __attribute((visibility("hidden"))); #define xmlXPathNormalizeFunction xmlXPathNormalizeFunction__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathNotEqualValues extern __typeof (xmlXPathNotEqualValues) xmlXPathNotEqualValues __attribute((alias("xmlXPathNotEqualValues__internal_alias"))); #else #ifndef xmlXPathNotEqualValues extern __typeof (xmlXPathNotEqualValues) xmlXPathNotEqualValues__internal_alias __attribute((visibility("hidden"))); #define xmlXPathNotEqualValues xmlXPathNotEqualValues__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathNotFunction extern __typeof (xmlXPathNotFunction) xmlXPathNotFunction __attribute((alias("xmlXPathNotFunction__internal_alias"))); #else #ifndef xmlXPathNotFunction extern __typeof (xmlXPathNotFunction) xmlXPathNotFunction__internal_alias __attribute((visibility("hidden"))); #define xmlXPathNotFunction xmlXPathNotFunction__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathNsLookup extern __typeof (xmlXPathNsLookup) xmlXPathNsLookup __attribute((alias("xmlXPathNsLookup__internal_alias"))); #else #ifndef xmlXPathNsLookup extern __typeof (xmlXPathNsLookup) xmlXPathNsLookup__internal_alias __attribute((visibility("hidden"))); #define xmlXPathNsLookup xmlXPathNsLookup__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathNumberFunction extern __typeof (xmlXPathNumberFunction) xmlXPathNumberFunction __attribute((alias("xmlXPathNumberFunction__internal_alias"))); #else #ifndef xmlXPathNumberFunction extern __typeof (xmlXPathNumberFunction) xmlXPathNumberFunction__internal_alias __attribute((visibility("hidden"))); #define xmlXPathNumberFunction xmlXPathNumberFunction__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathObjectCopy extern __typeof (xmlXPathObjectCopy) xmlXPathObjectCopy __attribute((alias("xmlXPathObjectCopy__internal_alias"))); #else #ifndef xmlXPathObjectCopy extern __typeof (xmlXPathObjectCopy) xmlXPathObjectCopy__internal_alias __attribute((visibility("hidden"))); #define xmlXPathObjectCopy xmlXPathObjectCopy__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathOrderDocElems extern __typeof (xmlXPathOrderDocElems) xmlXPathOrderDocElems __attribute((alias("xmlXPathOrderDocElems__internal_alias"))); #else #ifndef xmlXPathOrderDocElems extern __typeof (xmlXPathOrderDocElems) xmlXPathOrderDocElems__internal_alias __attribute((visibility("hidden"))); #define xmlXPathOrderDocElems xmlXPathOrderDocElems__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathParseNCName extern __typeof (xmlXPathParseNCName) xmlXPathParseNCName __attribute((alias("xmlXPathParseNCName__internal_alias"))); #else #ifndef xmlXPathParseNCName extern __typeof (xmlXPathParseNCName) xmlXPathParseNCName__internal_alias __attribute((visibility("hidden"))); #define xmlXPathParseNCName xmlXPathParseNCName__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathParseName extern __typeof (xmlXPathParseName) xmlXPathParseName __attribute((alias("xmlXPathParseName__internal_alias"))); #else #ifndef xmlXPathParseName extern __typeof (xmlXPathParseName) xmlXPathParseName__internal_alias __attribute((visibility("hidden"))); #define xmlXPathParseName xmlXPathParseName__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathPopBoolean extern __typeof (xmlXPathPopBoolean) xmlXPathPopBoolean __attribute((alias("xmlXPathPopBoolean__internal_alias"))); #else #ifndef xmlXPathPopBoolean extern __typeof (xmlXPathPopBoolean) xmlXPathPopBoolean__internal_alias __attribute((visibility("hidden"))); #define xmlXPathPopBoolean xmlXPathPopBoolean__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathPopExternal extern __typeof (xmlXPathPopExternal) xmlXPathPopExternal __attribute((alias("xmlXPathPopExternal__internal_alias"))); #else #ifndef xmlXPathPopExternal extern __typeof (xmlXPathPopExternal) xmlXPathPopExternal__internal_alias __attribute((visibility("hidden"))); #define xmlXPathPopExternal xmlXPathPopExternal__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathPopNodeSet extern __typeof (xmlXPathPopNodeSet) xmlXPathPopNodeSet __attribute((alias("xmlXPathPopNodeSet__internal_alias"))); #else #ifndef xmlXPathPopNodeSet extern __typeof (xmlXPathPopNodeSet) xmlXPathPopNodeSet__internal_alias __attribute((visibility("hidden"))); #define xmlXPathPopNodeSet xmlXPathPopNodeSet__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathPopNumber extern __typeof (xmlXPathPopNumber) xmlXPathPopNumber __attribute((alias("xmlXPathPopNumber__internal_alias"))); #else #ifndef xmlXPathPopNumber extern __typeof (xmlXPathPopNumber) xmlXPathPopNumber__internal_alias __attribute((visibility("hidden"))); #define xmlXPathPopNumber xmlXPathPopNumber__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathPopString extern __typeof (xmlXPathPopString) xmlXPathPopString __attribute((alias("xmlXPathPopString__internal_alias"))); #else #ifndef xmlXPathPopString extern __typeof (xmlXPathPopString) xmlXPathPopString__internal_alias __attribute((visibility("hidden"))); #define xmlXPathPopString xmlXPathPopString__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathPositionFunction extern __typeof (xmlXPathPositionFunction) xmlXPathPositionFunction __attribute((alias("xmlXPathPositionFunction__internal_alias"))); #else #ifndef xmlXPathPositionFunction extern __typeof (xmlXPathPositionFunction) xmlXPathPositionFunction__internal_alias __attribute((visibility("hidden"))); #define xmlXPathPositionFunction xmlXPathPositionFunction__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathRegisterAllFunctions extern __typeof (xmlXPathRegisterAllFunctions) xmlXPathRegisterAllFunctions __attribute((alias("xmlXPathRegisterAllFunctions__internal_alias"))); #else #ifndef xmlXPathRegisterAllFunctions extern __typeof (xmlXPathRegisterAllFunctions) xmlXPathRegisterAllFunctions__internal_alias __attribute((visibility("hidden"))); #define xmlXPathRegisterAllFunctions xmlXPathRegisterAllFunctions__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathRegisterFunc extern __typeof (xmlXPathRegisterFunc) xmlXPathRegisterFunc __attribute((alias("xmlXPathRegisterFunc__internal_alias"))); #else #ifndef xmlXPathRegisterFunc extern __typeof (xmlXPathRegisterFunc) xmlXPathRegisterFunc__internal_alias __attribute((visibility("hidden"))); #define xmlXPathRegisterFunc xmlXPathRegisterFunc__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathRegisterFuncLookup extern __typeof (xmlXPathRegisterFuncLookup) xmlXPathRegisterFuncLookup __attribute((alias("xmlXPathRegisterFuncLookup__internal_alias"))); #else #ifndef xmlXPathRegisterFuncLookup extern __typeof (xmlXPathRegisterFuncLookup) xmlXPathRegisterFuncLookup__internal_alias __attribute((visibility("hidden"))); #define xmlXPathRegisterFuncLookup xmlXPathRegisterFuncLookup__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathRegisterFuncNS extern __typeof (xmlXPathRegisterFuncNS) xmlXPathRegisterFuncNS __attribute((alias("xmlXPathRegisterFuncNS__internal_alias"))); #else #ifndef xmlXPathRegisterFuncNS extern __typeof (xmlXPathRegisterFuncNS) xmlXPathRegisterFuncNS__internal_alias __attribute((visibility("hidden"))); #define xmlXPathRegisterFuncNS xmlXPathRegisterFuncNS__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathRegisterNs extern __typeof (xmlXPathRegisterNs) xmlXPathRegisterNs __attribute((alias("xmlXPathRegisterNs__internal_alias"))); #else #ifndef xmlXPathRegisterNs extern __typeof (xmlXPathRegisterNs) xmlXPathRegisterNs__internal_alias __attribute((visibility("hidden"))); #define xmlXPathRegisterNs xmlXPathRegisterNs__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathRegisterVariable extern __typeof (xmlXPathRegisterVariable) xmlXPathRegisterVariable __attribute((alias("xmlXPathRegisterVariable__internal_alias"))); #else #ifndef xmlXPathRegisterVariable extern __typeof (xmlXPathRegisterVariable) xmlXPathRegisterVariable__internal_alias __attribute((visibility("hidden"))); #define xmlXPathRegisterVariable xmlXPathRegisterVariable__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathRegisterVariableLookup extern __typeof (xmlXPathRegisterVariableLookup) xmlXPathRegisterVariableLookup __attribute((alias("xmlXPathRegisterVariableLookup__internal_alias"))); #else #ifndef xmlXPathRegisterVariableLookup extern __typeof (xmlXPathRegisterVariableLookup) xmlXPathRegisterVariableLookup__internal_alias __attribute((visibility("hidden"))); #define xmlXPathRegisterVariableLookup xmlXPathRegisterVariableLookup__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathRegisterVariableNS extern __typeof (xmlXPathRegisterVariableNS) xmlXPathRegisterVariableNS __attribute((alias("xmlXPathRegisterVariableNS__internal_alias"))); #else #ifndef xmlXPathRegisterVariableNS extern __typeof (xmlXPathRegisterVariableNS) xmlXPathRegisterVariableNS__internal_alias __attribute((visibility("hidden"))); #define xmlXPathRegisterVariableNS xmlXPathRegisterVariableNS__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathRegisteredFuncsCleanup extern __typeof (xmlXPathRegisteredFuncsCleanup) xmlXPathRegisteredFuncsCleanup __attribute((alias("xmlXPathRegisteredFuncsCleanup__internal_alias"))); #else #ifndef xmlXPathRegisteredFuncsCleanup extern __typeof (xmlXPathRegisteredFuncsCleanup) xmlXPathRegisteredFuncsCleanup__internal_alias __attribute((visibility("hidden"))); #define xmlXPathRegisteredFuncsCleanup xmlXPathRegisteredFuncsCleanup__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathRegisteredNsCleanup extern __typeof (xmlXPathRegisteredNsCleanup) xmlXPathRegisteredNsCleanup __attribute((alias("xmlXPathRegisteredNsCleanup__internal_alias"))); #else #ifndef xmlXPathRegisteredNsCleanup extern __typeof (xmlXPathRegisteredNsCleanup) xmlXPathRegisteredNsCleanup__internal_alias __attribute((visibility("hidden"))); #define xmlXPathRegisteredNsCleanup xmlXPathRegisteredNsCleanup__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathRegisteredVariablesCleanup extern __typeof (xmlXPathRegisteredVariablesCleanup) xmlXPathRegisteredVariablesCleanup __attribute((alias("xmlXPathRegisteredVariablesCleanup__internal_alias"))); #else #ifndef xmlXPathRegisteredVariablesCleanup extern __typeof (xmlXPathRegisteredVariablesCleanup) xmlXPathRegisteredVariablesCleanup__internal_alias __attribute((visibility("hidden"))); #define xmlXPathRegisteredVariablesCleanup xmlXPathRegisteredVariablesCleanup__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathRoot extern __typeof (xmlXPathRoot) xmlXPathRoot __attribute((alias("xmlXPathRoot__internal_alias"))); #else #ifndef xmlXPathRoot extern __typeof (xmlXPathRoot) xmlXPathRoot__internal_alias __attribute((visibility("hidden"))); #define xmlXPathRoot xmlXPathRoot__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathRoundFunction extern __typeof (xmlXPathRoundFunction) xmlXPathRoundFunction __attribute((alias("xmlXPathRoundFunction__internal_alias"))); #else #ifndef xmlXPathRoundFunction extern __typeof (xmlXPathRoundFunction) xmlXPathRoundFunction__internal_alias __attribute((visibility("hidden"))); #define xmlXPathRoundFunction xmlXPathRoundFunction__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathStartsWithFunction extern __typeof (xmlXPathStartsWithFunction) xmlXPathStartsWithFunction __attribute((alias("xmlXPathStartsWithFunction__internal_alias"))); #else #ifndef xmlXPathStartsWithFunction extern __typeof (xmlXPathStartsWithFunction) xmlXPathStartsWithFunction__internal_alias __attribute((visibility("hidden"))); #define xmlXPathStartsWithFunction xmlXPathStartsWithFunction__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathStringEvalNumber extern __typeof (xmlXPathStringEvalNumber) xmlXPathStringEvalNumber __attribute((alias("xmlXPathStringEvalNumber__internal_alias"))); #else #ifndef xmlXPathStringEvalNumber extern __typeof (xmlXPathStringEvalNumber) xmlXPathStringEvalNumber__internal_alias __attribute((visibility("hidden"))); #define xmlXPathStringEvalNumber xmlXPathStringEvalNumber__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathStringFunction extern __typeof (xmlXPathStringFunction) xmlXPathStringFunction __attribute((alias("xmlXPathStringFunction__internal_alias"))); #else #ifndef xmlXPathStringFunction extern __typeof (xmlXPathStringFunction) xmlXPathStringFunction__internal_alias __attribute((visibility("hidden"))); #define xmlXPathStringFunction xmlXPathStringFunction__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathStringLengthFunction extern __typeof (xmlXPathStringLengthFunction) xmlXPathStringLengthFunction __attribute((alias("xmlXPathStringLengthFunction__internal_alias"))); #else #ifndef xmlXPathStringLengthFunction extern __typeof (xmlXPathStringLengthFunction) xmlXPathStringLengthFunction__internal_alias __attribute((visibility("hidden"))); #define xmlXPathStringLengthFunction xmlXPathStringLengthFunction__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathSubValues extern __typeof (xmlXPathSubValues) xmlXPathSubValues __attribute((alias("xmlXPathSubValues__internal_alias"))); #else #ifndef xmlXPathSubValues extern __typeof (xmlXPathSubValues) xmlXPathSubValues__internal_alias __attribute((visibility("hidden"))); #define xmlXPathSubValues xmlXPathSubValues__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathSubstringAfterFunction extern __typeof (xmlXPathSubstringAfterFunction) xmlXPathSubstringAfterFunction __attribute((alias("xmlXPathSubstringAfterFunction__internal_alias"))); #else #ifndef xmlXPathSubstringAfterFunction extern __typeof (xmlXPathSubstringAfterFunction) xmlXPathSubstringAfterFunction__internal_alias __attribute((visibility("hidden"))); #define xmlXPathSubstringAfterFunction xmlXPathSubstringAfterFunction__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathSubstringBeforeFunction extern __typeof (xmlXPathSubstringBeforeFunction) xmlXPathSubstringBeforeFunction __attribute((alias("xmlXPathSubstringBeforeFunction__internal_alias"))); #else #ifndef xmlXPathSubstringBeforeFunction extern __typeof (xmlXPathSubstringBeforeFunction) xmlXPathSubstringBeforeFunction__internal_alias __attribute((visibility("hidden"))); #define xmlXPathSubstringBeforeFunction xmlXPathSubstringBeforeFunction__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathSubstringFunction extern __typeof (xmlXPathSubstringFunction) xmlXPathSubstringFunction __attribute((alias("xmlXPathSubstringFunction__internal_alias"))); #else #ifndef xmlXPathSubstringFunction extern __typeof (xmlXPathSubstringFunction) xmlXPathSubstringFunction__internal_alias __attribute((visibility("hidden"))); #define xmlXPathSubstringFunction xmlXPathSubstringFunction__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathSumFunction extern __typeof (xmlXPathSumFunction) xmlXPathSumFunction __attribute((alias("xmlXPathSumFunction__internal_alias"))); #else #ifndef xmlXPathSumFunction extern __typeof (xmlXPathSumFunction) xmlXPathSumFunction__internal_alias __attribute((visibility("hidden"))); #define xmlXPathSumFunction xmlXPathSumFunction__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathTrailing extern __typeof (xmlXPathTrailing) xmlXPathTrailing __attribute((alias("xmlXPathTrailing__internal_alias"))); #else #ifndef xmlXPathTrailing extern __typeof (xmlXPathTrailing) xmlXPathTrailing__internal_alias __attribute((visibility("hidden"))); #define xmlXPathTrailing xmlXPathTrailing__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathTrailingSorted extern __typeof (xmlXPathTrailingSorted) xmlXPathTrailingSorted __attribute((alias("xmlXPathTrailingSorted__internal_alias"))); #else #ifndef xmlXPathTrailingSorted extern __typeof (xmlXPathTrailingSorted) xmlXPathTrailingSorted__internal_alias __attribute((visibility("hidden"))); #define xmlXPathTrailingSorted xmlXPathTrailingSorted__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathTranslateFunction extern __typeof (xmlXPathTranslateFunction) xmlXPathTranslateFunction __attribute((alias("xmlXPathTranslateFunction__internal_alias"))); #else #ifndef xmlXPathTranslateFunction extern __typeof (xmlXPathTranslateFunction) xmlXPathTranslateFunction__internal_alias __attribute((visibility("hidden"))); #define xmlXPathTranslateFunction xmlXPathTranslateFunction__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathTrueFunction extern __typeof (xmlXPathTrueFunction) xmlXPathTrueFunction __attribute((alias("xmlXPathTrueFunction__internal_alias"))); #else #ifndef xmlXPathTrueFunction extern __typeof (xmlXPathTrueFunction) xmlXPathTrueFunction__internal_alias __attribute((visibility("hidden"))); #define xmlXPathTrueFunction xmlXPathTrueFunction__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathValueFlipSign extern __typeof (xmlXPathValueFlipSign) xmlXPathValueFlipSign __attribute((alias("xmlXPathValueFlipSign__internal_alias"))); #else #ifndef xmlXPathValueFlipSign extern __typeof (xmlXPathValueFlipSign) xmlXPathValueFlipSign__internal_alias __attribute((visibility("hidden"))); #define xmlXPathValueFlipSign xmlXPathValueFlipSign__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathVariableLookup extern __typeof (xmlXPathVariableLookup) xmlXPathVariableLookup __attribute((alias("xmlXPathVariableLookup__internal_alias"))); #else #ifndef xmlXPathVariableLookup extern __typeof (xmlXPathVariableLookup) xmlXPathVariableLookup__internal_alias __attribute((visibility("hidden"))); #define xmlXPathVariableLookup xmlXPathVariableLookup__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathVariableLookupNS extern __typeof (xmlXPathVariableLookupNS) xmlXPathVariableLookupNS __attribute((alias("xmlXPathVariableLookupNS__internal_alias"))); #else #ifndef xmlXPathVariableLookupNS extern __typeof (xmlXPathVariableLookupNS) xmlXPathVariableLookupNS__internal_alias __attribute((visibility("hidden"))); #define xmlXPathVariableLookupNS xmlXPathVariableLookupNS__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathWrapCString extern __typeof (xmlXPathWrapCString) xmlXPathWrapCString __attribute((alias("xmlXPathWrapCString__internal_alias"))); #else #ifndef xmlXPathWrapCString extern __typeof (xmlXPathWrapCString) xmlXPathWrapCString__internal_alias __attribute((visibility("hidden"))); #define xmlXPathWrapCString xmlXPathWrapCString__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathWrapExternal extern __typeof (xmlXPathWrapExternal) xmlXPathWrapExternal __attribute((alias("xmlXPathWrapExternal__internal_alias"))); #else #ifndef xmlXPathWrapExternal extern __typeof (xmlXPathWrapExternal) xmlXPathWrapExternal__internal_alias __attribute((visibility("hidden"))); #define xmlXPathWrapExternal xmlXPathWrapExternal__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathWrapNodeSet extern __typeof (xmlXPathWrapNodeSet) xmlXPathWrapNodeSet __attribute((alias("xmlXPathWrapNodeSet__internal_alias"))); #else #ifndef xmlXPathWrapNodeSet extern __typeof (xmlXPathWrapNodeSet) xmlXPathWrapNodeSet__internal_alias __attribute((visibility("hidden"))); #define xmlXPathWrapNodeSet xmlXPathWrapNodeSet__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPathWrapString extern __typeof (xmlXPathWrapString) xmlXPathWrapString __attribute((alias("xmlXPathWrapString__internal_alias"))); #else #ifndef xmlXPathWrapString extern __typeof (xmlXPathWrapString) xmlXPathWrapString__internal_alias __attribute((visibility("hidden"))); #define xmlXPathWrapString xmlXPathWrapString__internal_alias #endif #endif #endif #if defined(LIBXML_XPATH_ENABLED) #ifdef bottom_xpath #undef xmlXPatherror extern __typeof (xmlXPatherror) xmlXPatherror __attribute((alias("xmlXPatherror__internal_alias"))); #else #ifndef xmlXPatherror extern __typeof (xmlXPatherror) xmlXPatherror__internal_alias __attribute((visibility("hidden"))); #define xmlXPatherror xmlXPatherror__internal_alias #endif #endif #endif #if defined(LIBXML_XPTR_ENABLED) #ifdef bottom_xpointer #undef xmlXPtrBuildNodeList extern __typeof (xmlXPtrBuildNodeList) xmlXPtrBuildNodeList __attribute((alias("xmlXPtrBuildNodeList__internal_alias"))); #else #ifndef xmlXPtrBuildNodeList extern __typeof (xmlXPtrBuildNodeList) xmlXPtrBuildNodeList__internal_alias __attribute((visibility("hidden"))); #define xmlXPtrBuildNodeList xmlXPtrBuildNodeList__internal_alias #endif #endif #endif #if defined(LIBXML_XPTR_ENABLED) #ifdef bottom_xpointer #undef xmlXPtrEval extern __typeof (xmlXPtrEval) xmlXPtrEval __attribute((alias("xmlXPtrEval__internal_alias"))); #else #ifndef xmlXPtrEval extern __typeof (xmlXPtrEval) xmlXPtrEval__internal_alias __attribute((visibility("hidden"))); #define xmlXPtrEval xmlXPtrEval__internal_alias #endif #endif #endif #if defined(LIBXML_XPTR_ENABLED) #ifdef bottom_xpointer #undef xmlXPtrEvalRangePredicate extern __typeof (xmlXPtrEvalRangePredicate) xmlXPtrEvalRangePredicate __attribute((alias("xmlXPtrEvalRangePredicate__internal_alias"))); #else #ifndef xmlXPtrEvalRangePredicate extern __typeof (xmlXPtrEvalRangePredicate) xmlXPtrEvalRangePredicate__internal_alias __attribute((visibility("hidden"))); #define xmlXPtrEvalRangePredicate xmlXPtrEvalRangePredicate__internal_alias #endif #endif #endif #if defined(LIBXML_XPTR_ENABLED) #ifdef bottom_xpointer #undef xmlXPtrFreeLocationSet extern __typeof (xmlXPtrFreeLocationSet) xmlXPtrFreeLocationSet __attribute((alias("xmlXPtrFreeLocationSet__internal_alias"))); #else #ifndef xmlXPtrFreeLocationSet extern __typeof (xmlXPtrFreeLocationSet) xmlXPtrFreeLocationSet__internal_alias __attribute((visibility("hidden"))); #define xmlXPtrFreeLocationSet xmlXPtrFreeLocationSet__internal_alias #endif #endif #endif #if defined(LIBXML_XPTR_ENABLED) #ifdef bottom_xpointer #undef xmlXPtrLocationSetAdd extern __typeof (xmlXPtrLocationSetAdd) xmlXPtrLocationSetAdd __attribute((alias("xmlXPtrLocationSetAdd__internal_alias"))); #else #ifndef xmlXPtrLocationSetAdd extern __typeof (xmlXPtrLocationSetAdd) xmlXPtrLocationSetAdd__internal_alias __attribute((visibility("hidden"))); #define xmlXPtrLocationSetAdd xmlXPtrLocationSetAdd__internal_alias #endif #endif #endif #if defined(LIBXML_XPTR_ENABLED) #ifdef bottom_xpointer #undef xmlXPtrLocationSetCreate extern __typeof (xmlXPtrLocationSetCreate) xmlXPtrLocationSetCreate __attribute((alias("xmlXPtrLocationSetCreate__internal_alias"))); #else #ifndef xmlXPtrLocationSetCreate extern __typeof (xmlXPtrLocationSetCreate) xmlXPtrLocationSetCreate__internal_alias __attribute((visibility("hidden"))); #define xmlXPtrLocationSetCreate xmlXPtrLocationSetCreate__internal_alias #endif #endif #endif #if defined(LIBXML_XPTR_ENABLED) #ifdef bottom_xpointer #undef xmlXPtrLocationSetDel extern __typeof (xmlXPtrLocationSetDel) xmlXPtrLocationSetDel __attribute((alias("xmlXPtrLocationSetDel__internal_alias"))); #else #ifndef xmlXPtrLocationSetDel extern __typeof (xmlXPtrLocationSetDel) xmlXPtrLocationSetDel__internal_alias __attribute((visibility("hidden"))); #define xmlXPtrLocationSetDel xmlXPtrLocationSetDel__internal_alias #endif #endif #endif #if defined(LIBXML_XPTR_ENABLED) #ifdef bottom_xpointer #undef xmlXPtrLocationSetMerge extern __typeof (xmlXPtrLocationSetMerge) xmlXPtrLocationSetMerge __attribute((alias("xmlXPtrLocationSetMerge__internal_alias"))); #else #ifndef xmlXPtrLocationSetMerge extern __typeof (xmlXPtrLocationSetMerge) xmlXPtrLocationSetMerge__internal_alias __attribute((visibility("hidden"))); #define xmlXPtrLocationSetMerge xmlXPtrLocationSetMerge__internal_alias #endif #endif #endif #if defined(LIBXML_XPTR_ENABLED) #ifdef bottom_xpointer #undef xmlXPtrLocationSetRemove extern __typeof (xmlXPtrLocationSetRemove) xmlXPtrLocationSetRemove __attribute((alias("xmlXPtrLocationSetRemove__internal_alias"))); #else #ifndef xmlXPtrLocationSetRemove extern __typeof (xmlXPtrLocationSetRemove) xmlXPtrLocationSetRemove__internal_alias __attribute((visibility("hidden"))); #define xmlXPtrLocationSetRemove xmlXPtrLocationSetRemove__internal_alias #endif #endif #endif #if defined(LIBXML_XPTR_ENABLED) #ifdef bottom_xpointer #undef xmlXPtrNewCollapsedRange extern __typeof (xmlXPtrNewCollapsedRange) xmlXPtrNewCollapsedRange __attribute((alias("xmlXPtrNewCollapsedRange__internal_alias"))); #else #ifndef xmlXPtrNewCollapsedRange extern __typeof (xmlXPtrNewCollapsedRange) xmlXPtrNewCollapsedRange__internal_alias __attribute((visibility("hidden"))); #define xmlXPtrNewCollapsedRange xmlXPtrNewCollapsedRange__internal_alias #endif #endif #endif #if defined(LIBXML_XPTR_ENABLED) #ifdef bottom_xpointer #undef xmlXPtrNewContext extern __typeof (xmlXPtrNewContext) xmlXPtrNewContext __attribute((alias("xmlXPtrNewContext__internal_alias"))); #else #ifndef xmlXPtrNewContext extern __typeof (xmlXPtrNewContext) xmlXPtrNewContext__internal_alias __attribute((visibility("hidden"))); #define xmlXPtrNewContext xmlXPtrNewContext__internal_alias #endif #endif #endif #if defined(LIBXML_XPTR_ENABLED) #ifdef bottom_xpointer #undef xmlXPtrNewLocationSetNodeSet extern __typeof (xmlXPtrNewLocationSetNodeSet) xmlXPtrNewLocationSetNodeSet __attribute((alias("xmlXPtrNewLocationSetNodeSet__internal_alias"))); #else #ifndef xmlXPtrNewLocationSetNodeSet extern __typeof (xmlXPtrNewLocationSetNodeSet) xmlXPtrNewLocationSetNodeSet__internal_alias __attribute((visibility("hidden"))); #define xmlXPtrNewLocationSetNodeSet xmlXPtrNewLocationSetNodeSet__internal_alias #endif #endif #endif #if defined(LIBXML_XPTR_ENABLED) #ifdef bottom_xpointer #undef xmlXPtrNewLocationSetNodes extern __typeof (xmlXPtrNewLocationSetNodes) xmlXPtrNewLocationSetNodes __attribute((alias("xmlXPtrNewLocationSetNodes__internal_alias"))); #else #ifndef xmlXPtrNewLocationSetNodes extern __typeof (xmlXPtrNewLocationSetNodes) xmlXPtrNewLocationSetNodes__internal_alias __attribute((visibility("hidden"))); #define xmlXPtrNewLocationSetNodes xmlXPtrNewLocationSetNodes__internal_alias #endif #endif #endif #if defined(LIBXML_XPTR_ENABLED) #ifdef bottom_xpointer #undef xmlXPtrNewRange extern __typeof (xmlXPtrNewRange) xmlXPtrNewRange __attribute((alias("xmlXPtrNewRange__internal_alias"))); #else #ifndef xmlXPtrNewRange extern __typeof (xmlXPtrNewRange) xmlXPtrNewRange__internal_alias __attribute((visibility("hidden"))); #define xmlXPtrNewRange xmlXPtrNewRange__internal_alias #endif #endif #endif #if defined(LIBXML_XPTR_ENABLED) #ifdef bottom_xpointer #undef xmlXPtrNewRangeNodeObject extern __typeof (xmlXPtrNewRangeNodeObject) xmlXPtrNewRangeNodeObject __attribute((alias("xmlXPtrNewRangeNodeObject__internal_alias"))); #else #ifndef xmlXPtrNewRangeNodeObject extern __typeof (xmlXPtrNewRangeNodeObject) xmlXPtrNewRangeNodeObject__internal_alias __attribute((visibility("hidden"))); #define xmlXPtrNewRangeNodeObject xmlXPtrNewRangeNodeObject__internal_alias #endif #endif #endif #if defined(LIBXML_XPTR_ENABLED) #ifdef bottom_xpointer #undef xmlXPtrNewRangeNodePoint extern __typeof (xmlXPtrNewRangeNodePoint) xmlXPtrNewRangeNodePoint __attribute((alias("xmlXPtrNewRangeNodePoint__internal_alias"))); #else #ifndef xmlXPtrNewRangeNodePoint extern __typeof (xmlXPtrNewRangeNodePoint) xmlXPtrNewRangeNodePoint__internal_alias __attribute((visibility("hidden"))); #define xmlXPtrNewRangeNodePoint xmlXPtrNewRangeNodePoint__internal_alias #endif #endif #endif #if defined(LIBXML_XPTR_ENABLED) #ifdef bottom_xpointer #undef xmlXPtrNewRangeNodes extern __typeof (xmlXPtrNewRangeNodes) xmlXPtrNewRangeNodes __attribute((alias("xmlXPtrNewRangeNodes__internal_alias"))); #else #ifndef xmlXPtrNewRangeNodes extern __typeof (xmlXPtrNewRangeNodes) xmlXPtrNewRangeNodes__internal_alias __attribute((visibility("hidden"))); #define xmlXPtrNewRangeNodes xmlXPtrNewRangeNodes__internal_alias #endif #endif #endif #if defined(LIBXML_XPTR_ENABLED) #ifdef bottom_xpointer #undef xmlXPtrNewRangePointNode extern __typeof (xmlXPtrNewRangePointNode) xmlXPtrNewRangePointNode __attribute((alias("xmlXPtrNewRangePointNode__internal_alias"))); #else #ifndef xmlXPtrNewRangePointNode extern __typeof (xmlXPtrNewRangePointNode) xmlXPtrNewRangePointNode__internal_alias __attribute((visibility("hidden"))); #define xmlXPtrNewRangePointNode xmlXPtrNewRangePointNode__internal_alias #endif #endif #endif #if defined(LIBXML_XPTR_ENABLED) #ifdef bottom_xpointer #undef xmlXPtrNewRangePoints extern __typeof (xmlXPtrNewRangePoints) xmlXPtrNewRangePoints __attribute((alias("xmlXPtrNewRangePoints__internal_alias"))); #else #ifndef xmlXPtrNewRangePoints extern __typeof (xmlXPtrNewRangePoints) xmlXPtrNewRangePoints__internal_alias __attribute((visibility("hidden"))); #define xmlXPtrNewRangePoints xmlXPtrNewRangePoints__internal_alias #endif #endif #endif #if defined(LIBXML_XPTR_ENABLED) #ifdef bottom_xpointer #undef xmlXPtrRangeToFunction extern __typeof (xmlXPtrRangeToFunction) xmlXPtrRangeToFunction __attribute((alias("xmlXPtrRangeToFunction__internal_alias"))); #else #ifndef xmlXPtrRangeToFunction extern __typeof (xmlXPtrRangeToFunction) xmlXPtrRangeToFunction__internal_alias __attribute((visibility("hidden"))); #define xmlXPtrRangeToFunction xmlXPtrRangeToFunction__internal_alias #endif #endif #endif #if defined(LIBXML_XPTR_ENABLED) #ifdef bottom_xpointer #undef xmlXPtrWrapLocationSet extern __typeof (xmlXPtrWrapLocationSet) xmlXPtrWrapLocationSet __attribute((alias("xmlXPtrWrapLocationSet__internal_alias"))); #else #ifndef xmlXPtrWrapLocationSet extern __typeof (xmlXPtrWrapLocationSet) xmlXPtrWrapLocationSet__internal_alias __attribute((visibility("hidden"))); #define xmlXPtrWrapLocationSet xmlXPtrWrapLocationSet__internal_alias #endif #endif #endif #endif #endif #endif #endif #endif #endif xdmf-3.0+git20160803/Utilities/vtklibxml2/xmllint.c0000640000175000017500000031717213003006557022011 0ustar alastairalastair/* * xmllint.c : a small tester program for XML input. * * See Copyright for the status of this software. * * daniel@veillard.com */ #include "libxml.h" #include #include #include #if defined (_WIN32) && !defined(__CYGWIN__) #if defined (_MSC_VER) || defined(__BORLANDC__) #include #pragma comment(lib, "ws2_32.lib") #define gettimeofday(p1,p2) #endif /* _MSC_VER */ #endif /* _WIN32 */ #ifdef HAVE_SYS_TIME_H #include #endif #ifdef HAVE_TIME_H #include #endif #ifdef __MINGW32__ #define _WINSOCKAPI_ #include #include #undef XML_SOCKLEN_T #define XML_SOCKLEN_T unsigned int #endif #ifdef HAVE_SYS_TIMEB_H #include #endif #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_STAT_H #include #endif #ifdef HAVE_FCNTL_H #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_SYS_MMAN_H #include /* seems needed for Solaris */ #ifndef MAP_FAILED #define MAP_FAILED ((void *) -1) #endif #endif #ifdef HAVE_STDLIB_H #include #endif #ifdef HAVE_LIBREADLINE #include #ifdef HAVE_LIBHISTORY #include #endif #endif #include #include #include #include #include #include #include #include #include #ifdef LIBXML_XINCLUDE_ENABLED #include #endif #ifdef LIBXML_CATALOG_ENABLED #include #endif #include #include #ifdef LIBXML_SCHEMATRON_ENABLED #include #endif #ifdef LIBXML_SCHEMAS_ENABLED #include #include #endif #ifdef LIBXML_PATTERN_ENABLED #include #endif #ifdef LIBXML_C14N_ENABLED #include #endif #ifdef LIBXML_OUTPUT_ENABLED #include #endif #ifndef XML_XML_DEFAULT_CATALOG #define XML_XML_DEFAULT_CATALOG "file:///etc/xml/catalog" #endif typedef enum { XMLLINT_RETURN_OK = 0, /* No error */ XMLLINT_ERR_UNCLASS, /* Unclassified */ XMLLINT_ERR_DTD, /* Error in DTD */ XMLLINT_ERR_VALID, /* Validation error */ XMLLINT_ERR_RDFILE, /* CtxtReadFile error */ XMLLINT_ERR_SCHEMACOMP, /* Schema compilation */ XMLLINT_ERR_OUT, /* Error writing output */ XMLLINT_ERR_SCHEMAPAT, /* Error in schema pattern */ XMLLINT_ERR_RDREGIS, /* Error in Reader registration */ XMLLINT_ERR_MEM /* Out of memory error */ } xmllintReturnCode; #ifdef LIBXML_DEBUG_ENABLED static int shell = 0; static int debugent = 0; #endif static int debug = 0; static int maxmem = 0; #ifdef LIBXML_TREE_ENABLED static int copy = 0; #endif /* LIBXML_TREE_ENABLED */ static int recovery = 0; static int noent = 0; static int noblanks = 0; static int noout = 0; static int nowrap = 0; #ifdef LIBXML_OUTPUT_ENABLED static int format = 0; static const char *output = NULL; static int compress = 0; static int oldout = 0; #endif /* LIBXML_OUTPUT_ENABLED */ #ifdef LIBXML_VALID_ENABLED static int valid = 0; static int postvalid = 0; static char * dtdvalid = NULL; static char * dtdvalidfpi = NULL; #endif #ifdef LIBXML_SCHEMAS_ENABLED static char * relaxng = NULL; static xmlRelaxNGPtr relaxngschemas = NULL; static char * schema = NULL; static xmlSchemaPtr wxschemas = NULL; #endif #ifdef LIBXML_SCHEMATRON_ENABLED static char * schematron = NULL; static xmlSchematronPtr wxschematron = NULL; #endif static int repeat = 0; static int insert = 0; #if defined(LIBXML_HTML_ENABLED) || defined(LIBXML_VALID_ENABLED) static int html = 0; static int xmlout = 0; #endif static int htmlout = 0; #ifdef LIBXML_PUSH_ENABLED static int push = 0; #endif /* LIBXML_PUSH_ENABLED */ #ifdef HAVE_SYS_MMAN_H static int memory = 0; #endif static int testIO = 0; static char *encoding = NULL; #ifdef LIBXML_XINCLUDE_ENABLED static int xinclude = 0; #endif static int dtdattrs = 0; static int loaddtd = 0; static xmllintReturnCode progresult = XMLLINT_RETURN_OK; static int timing = 0; static int generate = 0; static int dropdtd = 0; #ifdef LIBXML_CATALOG_ENABLED static int catalogs = 0; static int nocatalogs = 0; #endif #ifdef LIBXML_C14N_ENABLED static int canonical = 0; static int exc_canonical = 0; #endif #ifdef LIBXML_READER_ENABLED static int stream = 0; static int walker = 0; #endif /* LIBXML_READER_ENABLED */ static int chkregister = 0; static int nbregister = 0; #ifdef LIBXML_SAX1_ENABLED static int sax1 = 0; #endif /* LIBXML_SAX1_ENABLED */ #ifdef LIBXML_PATTERN_ENABLED static const char *pattern = NULL; static xmlPatternPtr patternc = NULL; static xmlStreamCtxtPtr patstream = NULL; #endif static int options = XML_PARSE_COMPACT; static int sax = 0; /************************************************************************ * * * Entity loading control and customization. * * * ************************************************************************/ #define MAX_PATHS 64 static xmlChar *paths[MAX_PATHS + 1]; static int nbpaths = 0; static int load_trace = 0; static void parsePath(const xmlChar *path) { const xmlChar *cur; if (path == NULL) return; while (*path != 0) { if (nbpaths >= MAX_PATHS) { fprintf(stderr, "MAX_PATHS reached: too many paths\n"); return; } cur = path; while ((*cur == ' ') || (*cur == ':')) cur++; path = cur; while ((*cur != 0) && (*cur != ' ') && (*cur != ':')) cur++; if (cur != path) { paths[nbpaths] = xmlStrndup(path, cur - path); if (paths[nbpaths] != NULL) nbpaths++; path = cur; } } } static xmlExternalEntityLoader defaultEntityLoader = NULL; static xmlParserInputPtr xmllintExternalEntityLoader(const char *URL, const char *ID, xmlParserCtxtPtr ctxt) { xmlParserInputPtr ret; warningSAXFunc warning = NULL; errorSAXFunc err = NULL; int i; const char *lastsegment = URL; const char *iter = URL; if (nbpaths > 0) { while (*iter != 0) { if (*iter == '/') lastsegment = iter + 1; iter++; } } if ((ctxt != NULL) && (ctxt->sax != NULL)) { warning = ctxt->sax->warning; err = ctxt->sax->error; ctxt->sax->warning = NULL; ctxt->sax->error = NULL; } if (defaultEntityLoader != NULL) { ret = defaultEntityLoader(URL, ID, ctxt); if (ret != NULL) { if (warning != NULL) ctxt->sax->warning = warning; if (err != NULL) ctxt->sax->error = err; if (load_trace) { fprintf \ (stderr, "Loaded URL=\"%s\" ID=\"%s\"\n", URL ? URL : "(null)", ID ? ID : "(null)"); } return(ret); } } for (i = 0;i < nbpaths;i++) { xmlChar *newURL; newURL = xmlStrdup((const xmlChar *) paths[i]); newURL = xmlStrcat(newURL, (const xmlChar *) "/"); newURL = xmlStrcat(newURL, (const xmlChar *) lastsegment); if (newURL != NULL) { ret = defaultEntityLoader((const char *)newURL, ID, ctxt); if (ret != NULL) { if (warning != NULL) ctxt->sax->warning = warning; if (err != NULL) ctxt->sax->error = err; if (load_trace) { fprintf \ (stderr, "Loaded URL=\"%s\" ID=\"%s\"\n", newURL, ID ? ID : "(null)"); } xmlFree(newURL); return(ret); } xmlFree(newURL); } } if (err != NULL) ctxt->sax->error = err; if (warning != NULL) { ctxt->sax->warning = warning; if (URL != NULL) warning(ctxt, "failed to load external entity \"%s\"\n", URL); else if (ID != NULL) warning(ctxt, "failed to load external entity \"%s\"\n", ID); } return(NULL); } /************************************************************************ * * * Memory allocation consumption debugging * * * ************************************************************************/ static void OOM(void) { fprintf(stderr, "Ran out of memory needs > %d bytes\n", maxmem); progresult = XMLLINT_ERR_MEM; } static void myFreeFunc(void *mem) { xmlMemFree(mem); } static void * myMallocFunc(size_t size) { void *ret; ret = xmlMemMalloc(size); if (ret != NULL) { if (xmlMemUsed() > maxmem) { OOM(); xmlMemFree(ret); return (NULL); } } return (ret); } static void * myReallocFunc(void *mem, size_t size) { void *ret; ret = xmlMemRealloc(mem, size); if (ret != NULL) { if (xmlMemUsed() > maxmem) { OOM(); xmlMemFree(ret); return (NULL); } } return (ret); } static char * myStrdupFunc(const char *str) { char *ret; ret = xmlMemoryStrdup(str); if (ret != NULL) { if (xmlMemUsed() > maxmem) { OOM(); xmlFree(ret); return (NULL); } } return (ret); } /************************************************************************ * * * Internal timing routines to remove the necessity to have * * unix-specific function calls. * * * ************************************************************************/ #ifndef HAVE_GETTIMEOFDAY #ifdef HAVE_SYS_TIMEB_H #ifdef HAVE_SYS_TIME_H #ifdef HAVE_FTIME static int my_gettimeofday(struct timeval *tvp, void *tzp) { struct timeb timebuffer; ftime(&timebuffer); if (tvp) { tvp->tv_sec = timebuffer.time; tvp->tv_usec = timebuffer.millitm * 1000L; } return (0); } #define HAVE_GETTIMEOFDAY 1 #define gettimeofday my_gettimeofday #endif /* HAVE_FTIME */ #endif /* HAVE_SYS_TIME_H */ #endif /* HAVE_SYS_TIMEB_H */ #endif /* !HAVE_GETTIMEOFDAY */ #if defined(HAVE_GETTIMEOFDAY) static struct timeval begin, end; /* * startTimer: call where you want to start timing */ static void startTimer(void) { gettimeofday(&begin, NULL); } /* * endTimer: call where you want to stop timing and to print out a * message about the timing performed; format is a printf * type argument */ static void XMLCDECL endTimer(const char *fmt, ...) { long msec; va_list ap; gettimeofday(&end, NULL); msec = end.tv_sec - begin.tv_sec; msec *= 1000; msec += (end.tv_usec - begin.tv_usec) / 1000; #ifndef HAVE_STDARG_H #error "endTimer required stdarg functions" #endif va_start(ap, fmt); vfprintf(stderr, fmt, ap); va_end(ap); fprintf(stderr, " took %ld ms\n", msec); } #elif defined(HAVE_TIME_H) /* * No gettimeofday function, so we have to make do with calling clock. * This is obviously less accurate, but there's little we can do about * that. */ #ifndef CLOCKS_PER_SEC #define CLOCKS_PER_SEC 100 #endif static clock_t begin, end; static void startTimer(void) { begin = clock(); } static void XMLCDECL endTimer(const char *fmt, ...) { long msec; va_list ap; end = clock(); msec = ((end - begin) * 1000) / CLOCKS_PER_SEC; #ifndef HAVE_STDARG_H #error "endTimer required stdarg functions" #endif va_start(ap, fmt); vfprintf(stderr, fmt, ap); va_end(ap); fprintf(stderr, " took %ld ms\n", msec); } #else /* * We don't have a gettimeofday or time.h, so we just don't do timing */ static void startTimer(void) { /* * Do nothing */ } static void XMLCDECL endTimer(char *format, ...) { /* * We cannot do anything because we don't have a timing function */ #ifdef HAVE_STDARG_H va_start(ap, format); vfprintf(stderr, format, ap); va_end(ap); fprintf(stderr, " was not timed\n", msec); #else /* We don't have gettimeofday, time or stdarg.h, what crazy world is * this ?! */ #endif } #endif /************************************************************************ * * * HTML ouput * * * ************************************************************************/ static char buffer[50000]; static void xmlHTMLEncodeSend(void) { char *result; result = (char *) xmlEncodeEntitiesReentrant(NULL, BAD_CAST buffer); if (result) { xmlGenericError(xmlGenericErrorContext, "%s", result); xmlFree(result); } buffer[0] = 0; } /** * xmlHTMLPrintFileInfo: * @input: an xmlParserInputPtr input * * Displays the associated file and line informations for the current input */ static void xmlHTMLPrintFileInfo(xmlParserInputPtr input) { int len; xmlGenericError(xmlGenericErrorContext, "

"); len = strlen(buffer); if (input != NULL) { if (input->filename) { snprintf(&buffer[len], sizeof(buffer) - len, "%s:%d: ", input->filename, input->line); } else { snprintf(&buffer[len], sizeof(buffer) - len, "Entity: line %d: ", input->line); } } xmlHTMLEncodeSend(); } /** * xmlHTMLPrintFileContext: * @input: an xmlParserInputPtr input * * Displays current context within the input content for error tracking */ static void xmlHTMLPrintFileContext(xmlParserInputPtr input) { const xmlChar *cur, *base; int len; int n; if (input == NULL) return; xmlGenericError(xmlGenericErrorContext, "

\n");
    cur = input->cur;
    base = input->base;
    while ((cur > base) && ((*cur == '\n') || (*cur == '\r'))) {
        cur--;
    }
    n = 0;
    while ((n++ < 80) && (cur > base) && (*cur != '\n') && (*cur != '\r'))
        cur--;
    if ((*cur == '\n') || (*cur == '\r')) cur++;
    base = cur;
    n = 0;
    while ((*cur != 0) && (*cur != '\n') && (*cur != '\r') && (n < 79)) {
        len = strlen(buffer);
        snprintf(&buffer[len], sizeof(buffer) - len, "%c", 
                    (unsigned char) *cur++);
        n++;
    }
    len = strlen(buffer);
    snprintf(&buffer[len], sizeof(buffer) - len, "\n");
    cur = input->cur;
    while ((*cur == '\n') || (*cur == '\r'))
        cur--;
    n = 0;
    while ((cur != base) && (n++ < 80)) {
        len = strlen(buffer);
        snprintf(&buffer[len], sizeof(buffer) - len, " ");
        base++;
    }
    len = strlen(buffer);
    snprintf(&buffer[len], sizeof(buffer) - len, "^\n");
    xmlHTMLEncodeSend();
    xmlGenericError(xmlGenericErrorContext, "
"); } /** * xmlHTMLError: * @ctx: an XML parser context * @msg: the message to display/transmit * @...: extra parameters for the message display * * Display and format an error messages, gives file, line, position and * extra parameters. */ static void XMLCDECL xmlHTMLError(void *ctx, const char *msg, ...) { xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; xmlParserInputPtr input; va_list args; int len; buffer[0] = 0; input = ctxt->input; if ((input != NULL) && (input->filename == NULL) && (ctxt->inputNr > 1)) { input = ctxt->inputTab[ctxt->inputNr - 2]; } xmlHTMLPrintFileInfo(input); xmlGenericError(xmlGenericErrorContext, "error: "); va_start(args, msg); len = strlen(buffer); vsnprintf(&buffer[len], sizeof(buffer) - len, msg, args); va_end(args); xmlHTMLEncodeSend(); xmlGenericError(xmlGenericErrorContext, "

\n"); xmlHTMLPrintFileContext(input); xmlHTMLEncodeSend(); } /** * xmlHTMLWarning: * @ctx: an XML parser context * @msg: the message to display/transmit * @...: extra parameters for the message display * * Display and format a warning messages, gives file, line, position and * extra parameters. */ static void XMLCDECL xmlHTMLWarning(void *ctx, const char *msg, ...) { xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; xmlParserInputPtr input; va_list args; int len; buffer[0] = 0; input = ctxt->input; if ((input != NULL) && (input->filename == NULL) && (ctxt->inputNr > 1)) { input = ctxt->inputTab[ctxt->inputNr - 2]; } xmlHTMLPrintFileInfo(input); xmlGenericError(xmlGenericErrorContext, "warning: "); va_start(args, msg); len = strlen(buffer); vsnprintf(&buffer[len], sizeof(buffer) - len, msg, args); va_end(args); xmlHTMLEncodeSend(); xmlGenericError(xmlGenericErrorContext, "

\n"); xmlHTMLPrintFileContext(input); xmlHTMLEncodeSend(); } /** * xmlHTMLValidityError: * @ctx: an XML parser context * @msg: the message to display/transmit * @...: extra parameters for the message display * * Display and format an validity error messages, gives file, * line, position and extra parameters. */ static void XMLCDECL xmlHTMLValidityError(void *ctx, const char *msg, ...) { xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; xmlParserInputPtr input; va_list args; int len; buffer[0] = 0; input = ctxt->input; if ((input->filename == NULL) && (ctxt->inputNr > 1)) input = ctxt->inputTab[ctxt->inputNr - 2]; xmlHTMLPrintFileInfo(input); xmlGenericError(xmlGenericErrorContext, "validity error: "); len = strlen(buffer); va_start(args, msg); vsnprintf(&buffer[len], sizeof(buffer) - len, msg, args); va_end(args); xmlHTMLEncodeSend(); xmlGenericError(xmlGenericErrorContext, "

\n"); xmlHTMLPrintFileContext(input); xmlHTMLEncodeSend(); progresult = XMLLINT_ERR_VALID; } /** * xmlHTMLValidityWarning: * @ctx: an XML parser context * @msg: the message to display/transmit * @...: extra parameters for the message display * * Display and format a validity warning messages, gives file, line, * position and extra parameters. */ static void XMLCDECL xmlHTMLValidityWarning(void *ctx, const char *msg, ...) { xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; xmlParserInputPtr input; va_list args; int len; buffer[0] = 0; input = ctxt->input; if ((input->filename == NULL) && (ctxt->inputNr > 1)) input = ctxt->inputTab[ctxt->inputNr - 2]; xmlHTMLPrintFileInfo(input); xmlGenericError(xmlGenericErrorContext, "validity warning: "); va_start(args, msg); len = strlen(buffer); vsnprintf(&buffer[len], sizeof(buffer) - len, msg, args); va_end(args); xmlHTMLEncodeSend(); xmlGenericError(xmlGenericErrorContext, "

\n"); xmlHTMLPrintFileContext(input); xmlHTMLEncodeSend(); } /************************************************************************ * * * Shell Interface * * * ************************************************************************/ #ifdef LIBXML_DEBUG_ENABLED #ifdef LIBXML_XPATH_ENABLED /** * xmlShellReadline: * @prompt: the prompt value * * Read a string * * Returns a pointer to it or NULL on EOF the caller is expected to * free the returned string. */ static char * xmlShellReadline(char *prompt) { #ifdef HAVE_LIBREADLINE char *line_read; /* Get a line from the user. */ line_read = readline (prompt); /* If the line has any text in it, save it on the history. */ if (line_read && *line_read) add_history (line_read); return (line_read); #else char line_read[501]; char *ret; int len; if (prompt != NULL) fprintf(stdout, "%s", prompt); if (!fgets(line_read, 500, stdin)) return(NULL); line_read[500] = 0; len = strlen(line_read); ret = (char *) malloc(len + 1); if (ret != NULL) { memcpy (ret, line_read, len + 1); } return(ret); #endif } #endif /* LIBXML_XPATH_ENABLED */ #endif /* LIBXML_DEBUG_ENABLED */ /************************************************************************ * * * I/O Interfaces * * * ************************************************************************/ static int myRead(FILE *f, char * buf, int len) { return(fread(buf, 1, len, f)); } static void myClose(FILE *f) { if (f != stdin) { fclose(f); } } /************************************************************************ * * * SAX based tests * * * ************************************************************************/ /* * empty SAX block */ static xmlSAXHandler emptySAXHandlerStruct = { NULL, /* internalSubset */ NULL, /* isStandalone */ NULL, /* hasInternalSubset */ NULL, /* hasExternalSubset */ NULL, /* resolveEntity */ NULL, /* getEntity */ NULL, /* entityDecl */ NULL, /* notationDecl */ NULL, /* attributeDecl */ NULL, /* elementDecl */ NULL, /* unparsedEntityDecl */ NULL, /* setDocumentLocator */ NULL, /* startDocument */ NULL, /* endDocument */ NULL, /* startElement */ NULL, /* endElement */ NULL, /* reference */ NULL, /* characters */ NULL, /* ignorableWhitespace */ NULL, /* processingInstruction */ NULL, /* comment */ NULL, /* xmlParserWarning */ NULL, /* xmlParserError */ NULL, /* xmlParserError */ NULL, /* getParameterEntity */ NULL, /* cdataBlock; */ NULL, /* externalSubset; */ XML_SAX2_MAGIC, NULL, NULL, /* startElementNs */ NULL, /* endElementNs */ NULL /* xmlStructuredErrorFunc */ }; static xmlSAXHandlerPtr emptySAXHandler = &emptySAXHandlerStruct; extern xmlSAXHandlerPtr debugSAXHandler; static int callbacks; /** * isStandaloneDebug: * @ctxt: An XML parser context * * Is this document tagged standalone ? * * Returns 1 if true */ static int isStandaloneDebug(void *ctx ATTRIBUTE_UNUSED) { callbacks++; if (noout) return(0); fprintf(stdout, "SAX.isStandalone()\n"); return(0); } /** * hasInternalSubsetDebug: * @ctxt: An XML parser context * * Does this document has an internal subset * * Returns 1 if true */ static int hasInternalSubsetDebug(void *ctx ATTRIBUTE_UNUSED) { callbacks++; if (noout) return(0); fprintf(stdout, "SAX.hasInternalSubset()\n"); return(0); } /** * hasExternalSubsetDebug: * @ctxt: An XML parser context * * Does this document has an external subset * * Returns 1 if true */ static int hasExternalSubsetDebug(void *ctx ATTRIBUTE_UNUSED) { callbacks++; if (noout) return(0); fprintf(stdout, "SAX.hasExternalSubset()\n"); return(0); } /** * internalSubsetDebug: * @ctxt: An XML parser context * * Does this document has an internal subset */ static void internalSubsetDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID) { callbacks++; if (noout) return; fprintf(stdout, "SAX.internalSubset(%s,", name); if (ExternalID == NULL) fprintf(stdout, " ,"); else fprintf(stdout, " %s,", ExternalID); if (SystemID == NULL) fprintf(stdout, " )\n"); else fprintf(stdout, " %s)\n", SystemID); } /** * externalSubsetDebug: * @ctxt: An XML parser context * * Does this document has an external subset */ static void externalSubsetDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID) { callbacks++; if (noout) return; fprintf(stdout, "SAX.externalSubset(%s,", name); if (ExternalID == NULL) fprintf(stdout, " ,"); else fprintf(stdout, " %s,", ExternalID); if (SystemID == NULL) fprintf(stdout, " )\n"); else fprintf(stdout, " %s)\n", SystemID); } /** * resolveEntityDebug: * @ctxt: An XML parser context * @publicId: The public ID of the entity * @systemId: The system ID of the entity * * Special entity resolver, better left to the parser, it has * more context than the application layer. * The default behaviour is to NOT resolve the entities, in that case * the ENTITY_REF nodes are built in the structure (and the parameter * values). * * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour. */ static xmlParserInputPtr resolveEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *publicId, const xmlChar *systemId) { callbacks++; if (noout) return(NULL); /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */ fprintf(stdout, "SAX.resolveEntity("); if (publicId != NULL) fprintf(stdout, "%s", (char *)publicId); else fprintf(stdout, " "); if (systemId != NULL) fprintf(stdout, ", %s)\n", (char *)systemId); else fprintf(stdout, ", )\n"); return(NULL); } /** * getEntityDebug: * @ctxt: An XML parser context * @name: The entity name * * Get an entity by name * * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour. */ static xmlEntityPtr getEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name) { callbacks++; if (noout) return(NULL); fprintf(stdout, "SAX.getEntity(%s)\n", name); return(NULL); } /** * getParameterEntityDebug: * @ctxt: An XML parser context * @name: The entity name * * Get a parameter entity by name * * Returns the xmlParserInputPtr */ static xmlEntityPtr getParameterEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name) { callbacks++; if (noout) return(NULL); fprintf(stdout, "SAX.getParameterEntity(%s)\n", name); return(NULL); } /** * entityDeclDebug: * @ctxt: An XML parser context * @name: the entity name * @type: the entity type * @publicId: The public ID of the entity * @systemId: The system ID of the entity * @content: the entity value (without processing). * * An entity definition has been parsed */ static void entityDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, int type, const xmlChar *publicId, const xmlChar *systemId, xmlChar *content) { const xmlChar *nullstr = BAD_CAST "(null)"; /* not all libraries handle printing null pointers nicely */ if (publicId == NULL) publicId = nullstr; if (systemId == NULL) systemId = nullstr; if (content == NULL) content = (xmlChar *)nullstr; callbacks++; if (noout) return; fprintf(stdout, "SAX.entityDecl(%s, %d, %s, %s, %s)\n", name, type, publicId, systemId, content); } /** * attributeDeclDebug: * @ctxt: An XML parser context * @name: the attribute name * @type: the attribute type * * An attribute definition has been parsed */ static void attributeDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar * elem, const xmlChar * name, int type, int def, const xmlChar * defaultValue, xmlEnumerationPtr tree) { callbacks++; if (noout) return; if (defaultValue == NULL) fprintf(stdout, "SAX.attributeDecl(%s, %s, %d, %d, NULL, ...)\n", elem, name, type, def); else fprintf(stdout, "SAX.attributeDecl(%s, %s, %d, %d, %s, ...)\n", elem, name, type, def, defaultValue); xmlFreeEnumeration(tree); } /** * elementDeclDebug: * @ctxt: An XML parser context * @name: the element name * @type: the element type * @content: the element value (without processing). * * An element definition has been parsed */ static void elementDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, int type, xmlElementContentPtr content ATTRIBUTE_UNUSED) { callbacks++; if (noout) return; fprintf(stdout, "SAX.elementDecl(%s, %d, ...)\n", name, type); } /** * notationDeclDebug: * @ctxt: An XML parser context * @name: The name of the notation * @publicId: The public ID of the entity * @systemId: The system ID of the entity * * What to do when a notation declaration has been parsed. */ static void notationDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId) { callbacks++; if (noout) return; fprintf(stdout, "SAX.notationDecl(%s, %s, %s)\n", (char *) name, (char *) publicId, (char *) systemId); } /** * unparsedEntityDeclDebug: * @ctxt: An XML parser context * @name: The name of the entity * @publicId: The public ID of the entity * @systemId: The system ID of the entity * @notationName: the name of the notation * * What to do when an unparsed entity declaration is parsed */ static void unparsedEntityDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId, const xmlChar *notationName) { const xmlChar *nullstr = BAD_CAST "(null)"; if (publicId == NULL) publicId = nullstr; if (systemId == NULL) systemId = nullstr; if (notationName == NULL) notationName = nullstr; callbacks++; if (noout) return; fprintf(stdout, "SAX.unparsedEntityDecl(%s, %s, %s, %s)\n", (char *) name, (char *) publicId, (char *) systemId, (char *) notationName); } /** * setDocumentLocatorDebug: * @ctxt: An XML parser context * @loc: A SAX Locator * * Receive the document locator at startup, actually xmlDefaultSAXLocator * Everything is available on the context, so this is useless in our case. */ static void setDocumentLocatorDebug(void *ctx ATTRIBUTE_UNUSED, xmlSAXLocatorPtr loc ATTRIBUTE_UNUSED) { callbacks++; if (noout) return; fprintf(stdout, "SAX.setDocumentLocator()\n"); } /** * startDocumentDebug: * @ctxt: An XML parser context * * called when the document start being processed. */ static void startDocumentDebug(void *ctx ATTRIBUTE_UNUSED) { callbacks++; if (noout) return; fprintf(stdout, "SAX.startDocument()\n"); } /** * endDocumentDebug: * @ctxt: An XML parser context * * called when the document end has been detected. */ static void endDocumentDebug(void *ctx ATTRIBUTE_UNUSED) { callbacks++; if (noout) return; fprintf(stdout, "SAX.endDocument()\n"); } /** * startElementDebug: * @ctxt: An XML parser context * @name: The element name * * called when an opening tag has been processed. */ static void startElementDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, const xmlChar **atts) { int i; callbacks++; if (noout) return; fprintf(stdout, "SAX.startElement(%s", (char *) name); if (atts != NULL) { for (i = 0;(atts[i] != NULL);i++) { fprintf(stdout, ", %s='", atts[i++]); if (atts[i] != NULL) fprintf(stdout, "%s'", atts[i]); } } fprintf(stdout, ")\n"); } /** * endElementDebug: * @ctxt: An XML parser context * @name: The element name * * called when the end of an element has been detected. */ static void endElementDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name) { callbacks++; if (noout) return; fprintf(stdout, "SAX.endElement(%s)\n", (char *) name); } /** * charactersDebug: * @ctxt: An XML parser context * @ch: a xmlChar string * @len: the number of xmlChar * * receiving some chars from the parser. * Question: how much at a time ??? */ static void charactersDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *ch, int len) { char out[40]; int i; callbacks++; if (noout) return; for (i = 0;(i 0) { fprintf(stderr, "%s fails to validate\n", filename); progresult = XMLLINT_ERR_VALID; } else { fprintf(stderr, "%s validation generated an internal error\n", filename); progresult = XMLLINT_ERR_VALID; } } xmlSchemaFreeValidCtxt(vctxt); } else #endif { /* * Create the parser context amd hook the input */ ctxt = xmlNewParserCtxt(); if (ctxt == NULL) { xmlFreeParserInputBuffer(buf); goto error; } old_sax = ctxt->sax; ctxt->sax = handler; ctxt->userData = (void *) user_data; inputStream = xmlNewIOInputStream(ctxt, buf, XML_CHAR_ENCODING_NONE); if (inputStream == NULL) { xmlFreeParserInputBuffer(buf); goto error; } inputPush(ctxt, inputStream); /* do the parsing */ xmlParseDocument(ctxt); if (ctxt->myDoc != NULL) { fprintf(stderr, "SAX generated a doc !\n"); xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL; } } error: if (ctxt != NULL) { ctxt->sax = old_sax; xmlFreeParserCtxt(ctxt); } } /************************************************************************ * * * Stream Test processing * * * ************************************************************************/ #ifdef LIBXML_READER_ENABLED static void processNode(xmlTextReaderPtr reader) { const xmlChar *name, *value; int type, empty; type = xmlTextReaderNodeType(reader); empty = xmlTextReaderIsEmptyElement(reader); if (debug) { name = xmlTextReaderConstName(reader); if (name == NULL) name = BAD_CAST "--"; value = xmlTextReaderConstValue(reader); printf("%d %d %s %d %d", xmlTextReaderDepth(reader), type, name, empty, xmlTextReaderHasValue(reader)); if (value == NULL) printf("\n"); else { printf(" %s\n", value); } } #ifdef LIBXML_PATTERN_ENABLED if (patternc) { xmlChar *path = NULL; int match = -1; if (type == XML_READER_TYPE_ELEMENT) { /* do the check only on element start */ match = xmlPatternMatch(patternc, xmlTextReaderCurrentNode(reader)); if (match) { path = xmlGetNodePath(xmlTextReaderCurrentNode(reader)); printf("Node %s matches pattern %s\n", path, pattern); } } if (patstream != NULL) { int ret; if (type == XML_READER_TYPE_ELEMENT) { ret = xmlStreamPush(patstream, xmlTextReaderConstLocalName(reader), xmlTextReaderConstNamespaceUri(reader)); if (ret < 0) { fprintf(stderr, "xmlStreamPush() failure\n"); xmlFreeStreamCtxt(patstream); patstream = NULL; } else if (ret != match) { if (path == NULL) { path = xmlGetNodePath( xmlTextReaderCurrentNode(reader)); } fprintf(stderr, "xmlPatternMatch and xmlStreamPush disagree\n"); fprintf(stderr, " pattern %s node %s\n", pattern, path); } } if ((type == XML_READER_TYPE_END_ELEMENT) || ((type == XML_READER_TYPE_ELEMENT) && (empty))) { ret = xmlStreamPop(patstream); if (ret < 0) { fprintf(stderr, "xmlStreamPop() failure\n"); xmlFreeStreamCtxt(patstream); patstream = NULL; } } } if (path != NULL) xmlFree(path); } #endif } static void streamFile(char *filename) { xmlTextReaderPtr reader; int ret; #ifdef HAVE_SYS_MMAN_H int fd = -1; struct stat info; const char *base = NULL; xmlParserInputBufferPtr input = NULL; if (memory) { if (stat(filename, &info) < 0) return; if ((fd = open(filename, O_RDONLY)) < 0) return; base = mmap(NULL, info.st_size, PROT_READ, MAP_SHARED, fd, 0) ; if (base == (void *) MAP_FAILED) return; reader = xmlReaderForMemory(base, info.st_size, filename, NULL, options); } else #endif reader = xmlReaderForFile(filename, NULL, options); #ifdef LIBXML_PATTERN_ENABLED if (pattern != NULL) { patternc = xmlPatterncompile((const xmlChar *) pattern, NULL, 0, NULL); if (patternc == NULL) { xmlGenericError(xmlGenericErrorContext, "Pattern %s failed to compile\n", pattern); progresult = XMLLINT_ERR_SCHEMAPAT; pattern = NULL; } } if (patternc != NULL) { patstream = xmlPatternGetStreamCtxt(patternc); if (patstream != NULL) { ret = xmlStreamPush(patstream, NULL, NULL); if (ret < 0) { fprintf(stderr, "xmlStreamPush() failure\n"); xmlFreeStreamCtxt(patstream); patstream = NULL; } } } #endif if (reader != NULL) { #ifdef LIBXML_VALID_ENABLED if (valid) xmlTextReaderSetParserProp(reader, XML_PARSER_VALIDATE, 1); else #endif /* LIBXML_VALID_ENABLED */ xmlTextReaderSetParserProp(reader, XML_PARSER_LOADDTD, 1); #ifdef LIBXML_SCHEMAS_ENABLED if (relaxng != NULL) { if ((timing) && (!repeat)) { startTimer(); } ret = xmlTextReaderRelaxNGValidate(reader, relaxng); if (ret < 0) { xmlGenericError(xmlGenericErrorContext, "Relax-NG schema %s failed to compile\n", relaxng); progresult = XMLLINT_ERR_SCHEMACOMP; relaxng = NULL; } if ((timing) && (!repeat)) { endTimer("Compiling the schemas"); } } if (schema != NULL) { if ((timing) && (!repeat)) { startTimer(); } ret = xmlTextReaderSchemaValidate(reader, schema); if (ret < 0) { xmlGenericError(xmlGenericErrorContext, "XSD schema %s failed to compile\n", schema); progresult = XMLLINT_ERR_SCHEMACOMP; schema = NULL; } if ((timing) && (!repeat)) { endTimer("Compiling the schemas"); } } #endif /* * Process all nodes in sequence */ if ((timing) && (!repeat)) { startTimer(); } ret = xmlTextReaderRead(reader); while (ret == 1) { if ((debug) #ifdef LIBXML_PATTERN_ENABLED || (patternc) #endif ) processNode(reader); ret = xmlTextReaderRead(reader); } if ((timing) && (!repeat)) { #ifdef LIBXML_SCHEMAS_ENABLED if (relaxng != NULL) endTimer("Parsing and validating"); else #endif #ifdef LIBXML_VALID_ENABLED if (valid) endTimer("Parsing and validating"); else #endif endTimer("Parsing"); } #ifdef LIBXML_VALID_ENABLED if (valid) { if (xmlTextReaderIsValid(reader) != 1) { xmlGenericError(xmlGenericErrorContext, "Document %s does not validate\n", filename); progresult = XMLLINT_ERR_VALID; } } #endif /* LIBXML_VALID_ENABLED */ #ifdef LIBXML_SCHEMAS_ENABLED if ((relaxng != NULL) || (schema != NULL)) { if (xmlTextReaderIsValid(reader) != 1) { fprintf(stderr, "%s fails to validate\n", filename); progresult = XMLLINT_ERR_VALID; } else { fprintf(stderr, "%s validates\n", filename); } } #endif /* * Done, cleanup and status */ xmlFreeTextReader(reader); if (ret != 0) { fprintf(stderr, "%s : failed to parse\n", filename); progresult = XMLLINT_ERR_UNCLASS; } } else { fprintf(stderr, "Unable to open %s\n", filename); progresult = XMLLINT_ERR_UNCLASS; } #ifdef LIBXML_PATTERN_ENABLED if (patstream != NULL) { xmlFreeStreamCtxt(patstream); patstream = NULL; } #endif #ifdef HAVE_SYS_MMAN_H if (memory) { xmlFreeParserInputBuffer(input); munmap((char *) base, info.st_size); close(fd); } #endif } static void walkDoc(xmlDocPtr doc) { xmlTextReaderPtr reader; int ret; #ifdef LIBXML_PATTERN_ENABLED xmlNodePtr root; const xmlChar *namespaces[22]; int i; xmlNsPtr ns; root = xmlDocGetRootElement(doc); for (ns = root->nsDef, i = 0;ns != NULL && i < 20;ns=ns->next) { namespaces[i++] = ns->href; namespaces[i++] = ns->prefix; } namespaces[i++] = NULL; namespaces[i++] = NULL; if (pattern != NULL) { patternc = xmlPatterncompile((const xmlChar *) pattern, doc->dict, 0, &namespaces[0]); if (patternc == NULL) { xmlGenericError(xmlGenericErrorContext, "Pattern %s failed to compile\n", pattern); progresult = XMLLINT_ERR_SCHEMAPAT; pattern = NULL; } } if (patternc != NULL) { patstream = xmlPatternGetStreamCtxt(patternc); if (patstream != NULL) { ret = xmlStreamPush(patstream, NULL, NULL); if (ret < 0) { fprintf(stderr, "xmlStreamPush() failure\n"); xmlFreeStreamCtxt(patstream); patstream = NULL; } } } #endif /* LIBXML_PATTERN_ENABLED */ reader = xmlReaderWalker(doc); if (reader != NULL) { if ((timing) && (!repeat)) { startTimer(); } ret = xmlTextReaderRead(reader); while (ret == 1) { if ((debug) #ifdef LIBXML_PATTERN_ENABLED || (patternc) #endif ) processNode(reader); ret = xmlTextReaderRead(reader); } if ((timing) && (!repeat)) { endTimer("walking through the doc"); } xmlFreeTextReader(reader); if (ret != 0) { fprintf(stderr, "failed to walk through the doc\n"); progresult = XMLLINT_ERR_UNCLASS; } } else { fprintf(stderr, "Failed to crate a reader from the document\n"); progresult = XMLLINT_ERR_UNCLASS; } #ifdef LIBXML_PATTERN_ENABLED if (patstream != NULL) { xmlFreeStreamCtxt(patstream); patstream = NULL; } #endif } #endif /* LIBXML_READER_ENABLED */ /************************************************************************ * * * Tree Test processing * * * ************************************************************************/ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) { xmlDocPtr doc = NULL; #ifdef LIBXML_TREE_ENABLED xmlDocPtr tmp; #endif /* LIBXML_TREE_ENABLED */ if ((timing) && (!repeat)) startTimer(); #ifdef LIBXML_TREE_ENABLED if (filename == NULL) { if (generate) { xmlNodePtr n; doc = xmlNewDoc(BAD_CAST "1.0"); n = xmlNewDocNode(doc, NULL, BAD_CAST "info", NULL); xmlNodeSetContent(n, BAD_CAST "abc"); xmlDocSetRootElement(doc, n); } } #endif /* LIBXML_TREE_ENABLED */ #ifdef LIBXML_HTML_ENABLED #ifdef LIBXML_PUSH_ENABLED else if ((html) && (push)) { FILE *f; #if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__) f = fopen(filename, "rb"); #else f = fopen(filename, "r"); #endif if (f != NULL) { int res, size = 3; char chars[4096]; htmlParserCtxtPtr ctxt; /* if (repeat) */ size = 4096; res = fread(chars, 1, 4, f); if (res > 0) { ctxt = htmlCreatePushParserCtxt(NULL, NULL, chars, res, filename, XML_CHAR_ENCODING_NONE); while ((res = fread(chars, 1, size, f)) > 0) { htmlParseChunk(ctxt, chars, res, 0); } htmlParseChunk(ctxt, chars, 0, 1); doc = ctxt->myDoc; htmlFreeParserCtxt(ctxt); } fclose(f); } } #endif /* LIBXML_PUSH_ENABLED */ #ifdef HAVE_SYS_MMAN_H else if ((html) && (memory)) { int fd; struct stat info; const char *base; if (stat(filename, &info) < 0) return; if ((fd = open(filename, O_RDONLY)) < 0) return; base = mmap(NULL, info.st_size, PROT_READ, MAP_SHARED, fd, 0) ; if (base == (void *) MAP_FAILED) return; doc = htmlReadMemory((char *) base, info.st_size, filename, NULL, options); munmap((char *) base, info.st_size); close(fd); } #endif else if (html) { doc = htmlReadFile(filename, NULL, options); } #endif /* LIBXML_HTML_ENABLED */ else { #ifdef LIBXML_PUSH_ENABLED /* * build an XML tree from a string; */ if (push) { FILE *f; /* '-' Usually means stdin - */ if ((filename[0] == '-') && (filename[1] == 0)) { f = stdin; } else { #if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__) f = fopen(filename, "rb"); #else f = fopen(filename, "r"); #endif } if (f != NULL) { int ret; int res, size = 1024; char chars[1024]; xmlParserCtxtPtr ctxt; /* if (repeat) size = 1024; */ res = fread(chars, 1, 4, f); if (res > 0) { ctxt = xmlCreatePushParserCtxt(NULL, NULL, chars, res, filename); xmlCtxtUseOptions(ctxt, options); while ((res = fread(chars, 1, size, f)) > 0) { xmlParseChunk(ctxt, chars, res, 0); } xmlParseChunk(ctxt, chars, 0, 1); doc = ctxt->myDoc; ret = ctxt->wellFormed; xmlFreeParserCtxt(ctxt); if (!ret) { xmlFreeDoc(doc); doc = NULL; } } } } else #endif /* LIBXML_PUSH_ENABLED */ if (testIO) { if ((filename[0] == '-') && (filename[1] == 0)) { doc = xmlReadFd(0, NULL, NULL, options); } else { FILE *f; #if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__) f = fopen(filename, "rb"); #else f = fopen(filename, "r"); #endif if (f != NULL) { if (rectxt == NULL) doc = xmlReadIO((xmlInputReadCallback) myRead, (xmlInputCloseCallback) myClose, f, filename, NULL, options); else doc = xmlCtxtReadIO(rectxt, (xmlInputReadCallback) myRead, (xmlInputCloseCallback) myClose, f, filename, NULL, options); } else doc = NULL; } } else if (htmlout) { xmlParserCtxtPtr ctxt; if (rectxt == NULL) ctxt = xmlNewParserCtxt(); else ctxt = rectxt; if (ctxt == NULL) { doc = NULL; } else { ctxt->sax->error = xmlHTMLError; ctxt->sax->warning = xmlHTMLWarning; ctxt->vctxt.error = xmlHTMLValidityError; ctxt->vctxt.warning = xmlHTMLValidityWarning; doc = xmlCtxtReadFile(ctxt, filename, NULL, options); if (rectxt == NULL) xmlFreeParserCtxt(ctxt); } #ifdef HAVE_SYS_MMAN_H } else if (memory) { int fd; struct stat info; const char *base; if (stat(filename, &info) < 0) return; if ((fd = open(filename, O_RDONLY)) < 0) return; base = mmap(NULL, info.st_size, PROT_READ, MAP_SHARED, fd, 0) ; if (base == (void *) MAP_FAILED) return; if (rectxt == NULL) doc = xmlReadMemory((char *) base, info.st_size, filename, NULL, options); else doc = xmlCtxtReadMemory(rectxt, (char *) base, info.st_size, filename, NULL, options); munmap((char *) base, info.st_size); close(fd); #endif #ifdef LIBXML_VALID_ENABLED } else if (valid) { xmlParserCtxtPtr ctxt = NULL; if (rectxt == NULL) ctxt = xmlNewParserCtxt(); else ctxt = rectxt; if (ctxt == NULL) { doc = NULL; } else { doc = xmlCtxtReadFile(ctxt, filename, NULL, options); if (ctxt->valid == 0) progresult = XMLLINT_ERR_RDFILE; if (rectxt == NULL) xmlFreeParserCtxt(ctxt); } #endif /* LIBXML_VALID_ENABLED */ } else { if (rectxt != NULL) doc = xmlCtxtReadFile(rectxt, filename, NULL, options); else { #ifdef LIBXML_SAX1_ENABLED if (sax1) doc = xmlParseFile(filename); else #endif /* LIBXML_SAX1_ENABLED */ doc = xmlReadFile(filename, NULL, options); } } } /* * If we don't have a document we might as well give up. Do we * want an error message here? */ if (doc == NULL) { progresult = XMLLINT_ERR_UNCLASS; return; } if ((timing) && (!repeat)) { endTimer("Parsing"); } /* * Remove DOCTYPE nodes */ if (dropdtd) { xmlDtdPtr dtd; dtd = xmlGetIntSubset(doc); if (dtd != NULL) { xmlUnlinkNode((xmlNodePtr)dtd); xmlFreeDtd(dtd); } } #ifdef LIBXML_XINCLUDE_ENABLED if (xinclude) { if ((timing) && (!repeat)) { startTimer(); } if (xmlXIncludeProcessFlags(doc, options) < 0) progresult = XMLLINT_ERR_UNCLASS; if ((timing) && (!repeat)) { endTimer("Xinclude processing"); } } #endif #ifdef LIBXML_DEBUG_ENABLED #ifdef LIBXML_XPATH_ENABLED /* * shell interaction */ if (shell) { xmlXPathOrderDocElems(doc); xmlShell(doc, filename, xmlShellReadline, stdout); } #endif #endif #ifdef LIBXML_TREE_ENABLED /* * test intermediate copy if needed. */ if (copy) { tmp = doc; if (timing) { startTimer(); } doc = xmlCopyDoc(doc, 1); if (timing) { endTimer("Copying"); } if (timing) { startTimer(); } xmlFreeDoc(tmp); if (timing) { endTimer("Freeing original"); } } #endif /* LIBXML_TREE_ENABLED */ #ifdef LIBXML_VALID_ENABLED if ((insert) && (!html)) { const xmlChar* list[256]; int nb, i; xmlNodePtr node; if (doc->children != NULL) { node = doc->children; while ((node != NULL) && (node->last == NULL)) node = node->next; if (node != NULL) { nb = xmlValidGetValidElements(node->last, NULL, list, 256); if (nb < 0) { fprintf(stderr, "could not get valid list of elements\n"); } else if (nb == 0) { fprintf(stderr, "No element can be inserted under root\n"); } else { fprintf(stderr, "%d element types can be inserted under root:\n", nb); for (i = 0;i < nb;i++) { fprintf(stderr, "%s\n", (char *) list[i]); } } } } }else #endif /* LIBXML_VALID_ENABLED */ #ifdef LIBXML_READER_ENABLED if (walker) { walkDoc(doc); } #endif /* LIBXML_READER_ENABLED */ #ifdef LIBXML_OUTPUT_ENABLED if (noout == 0) { int ret; /* * print it. */ #ifdef LIBXML_DEBUG_ENABLED if (!debug) { #endif if ((timing) && (!repeat)) { startTimer(); } #ifdef LIBXML_HTML_ENABLED if ((html) && (!xmlout)) { if (compress) { htmlSaveFile(output ? output : "-", doc); } else if (encoding != NULL) { if ( format ) { htmlSaveFileFormat(output ? output : "-", doc, encoding, 1); } else { htmlSaveFileFormat(output ? output : "-", doc, encoding, 0); } } else if (format) { htmlSaveFileFormat(output ? output : "-", doc, NULL, 1); } else { FILE *out; if (output == NULL) out = stdout; else { out = fopen(output,"wb"); } if (out != NULL) { if (htmlDocDump(out, doc) < 0) progresult = XMLLINT_ERR_OUT; if (output != NULL) fclose(out); } else { fprintf(stderr, "failed to open %s\n", output); progresult = XMLLINT_ERR_OUT; } } if ((timing) && (!repeat)) { endTimer("Saving"); } } else #endif #ifdef LIBXML_C14N_ENABLED if (canonical) { xmlChar *result = NULL; int size; size = xmlC14NDocDumpMemory(doc, NULL, 0, NULL, 1, &result); if (size >= 0) { write(1, result, size); xmlFree(result); } else { fprintf(stderr, "Failed to canonicalize\n"); progresult = XMLLINT_ERR_OUT; } } else if (exc_canonical) { xmlChar *result = NULL; int size; size = xmlC14NDocDumpMemory(doc, NULL, 1, NULL, 1, &result); if (size >= 0) { write(1, result, size); xmlFree(result); } else { fprintf(stderr, "Failed to canonicalize\n"); progresult = XMLLINT_ERR_OUT; } } else #endif #ifdef HAVE_SYS_MMAN_H if (memory) { xmlChar *result; int len; if (encoding != NULL) { if ( format ) { xmlDocDumpFormatMemoryEnc(doc, &result, &len, encoding, 1); } else { xmlDocDumpMemoryEnc(doc, &result, &len, encoding); } } else { if (format) xmlDocDumpFormatMemory(doc, &result, &len, 1); else xmlDocDumpMemory(doc, &result, &len); } if (result == NULL) { fprintf(stderr, "Failed to save\n"); progresult = XMLLINT_ERR_OUT; } else { write(1, result, len); xmlFree(result); } } else #endif /* HAVE_SYS_MMAN_H */ if (compress) { xmlSaveFile(output ? output : "-", doc); } else if (oldout) { if (encoding != NULL) { if ( format ) { ret = xmlSaveFormatFileEnc(output ? output : "-", doc, encoding, 1); } else { ret = xmlSaveFileEnc(output ? output : "-", doc, encoding); } if (ret < 0) { fprintf(stderr, "failed save to %s\n", output ? output : "-"); progresult = XMLLINT_ERR_OUT; } } else if (format) { ret = xmlSaveFormatFile(output ? output : "-", doc, 1); if (ret < 0) { fprintf(stderr, "failed save to %s\n", output ? output : "-"); progresult = XMLLINT_ERR_OUT; } } else { FILE *out; if (output == NULL) out = stdout; else { out = fopen(output,"wb"); } if (out != NULL) { if (xmlDocDump(out, doc) < 0) progresult = XMLLINT_ERR_OUT; if (output != NULL) fclose(out); } else { fprintf(stderr, "failed to open %s\n", output); progresult = XMLLINT_ERR_OUT; } } } else { xmlSaveCtxtPtr ctxt; int saveOpts = 0; if (format) saveOpts |= XML_SAVE_FORMAT; if (output == NULL) ctxt = xmlSaveToFd(1, encoding, saveOpts); else ctxt = xmlSaveToFilename(output, encoding, saveOpts); if (ctxt != NULL) { if (xmlSaveDoc(ctxt, doc) < 0) { fprintf(stderr, "failed save to %s\n", output ? output : "-"); progresult = XMLLINT_ERR_OUT; } xmlSaveClose(ctxt); } else { progresult = XMLLINT_ERR_OUT; } } if ((timing) && (!repeat)) { endTimer("Saving"); } #ifdef LIBXML_DEBUG_ENABLED } else { FILE *out; if (output == NULL) out = stdout; else { out = fopen(output,"wb"); } if (out != NULL) { xmlDebugDumpDocument(out, doc); if (output != NULL) fclose(out); } else { fprintf(stderr, "failed to open %s\n", output); progresult = XMLLINT_ERR_OUT; } } #endif } #endif /* LIBXML_OUTPUT_ENABLED */ #ifdef LIBXML_VALID_ENABLED /* * A posteriori validation test */ if ((dtdvalid != NULL) || (dtdvalidfpi != NULL)) { xmlDtdPtr dtd; if ((timing) && (!repeat)) { startTimer(); } if (dtdvalid != NULL) dtd = xmlParseDTD(NULL, (const xmlChar *)dtdvalid); else dtd = xmlParseDTD((const xmlChar *)dtdvalidfpi, NULL); if ((timing) && (!repeat)) { endTimer("Parsing DTD"); } if (dtd == NULL) { if (dtdvalid != NULL) xmlGenericError(xmlGenericErrorContext, "Could not parse DTD %s\n", dtdvalid); else xmlGenericError(xmlGenericErrorContext, "Could not parse DTD %s\n", dtdvalidfpi); progresult = XMLLINT_ERR_DTD; } else { xmlValidCtxtPtr cvp; if ((cvp = xmlNewValidCtxt()) == NULL) { xmlGenericError(xmlGenericErrorContext, "Couldn't allocate validation context\n"); exit(-1); } cvp->userData = (void *) stderr; cvp->error = (xmlValidityErrorFunc) fprintf; cvp->warning = (xmlValidityWarningFunc) fprintf; if ((timing) && (!repeat)) { startTimer(); } if (!xmlValidateDtd(cvp, doc, dtd)) { if (dtdvalid != NULL) xmlGenericError(xmlGenericErrorContext, "Document %s does not validate against %s\n", filename, dtdvalid); else xmlGenericError(xmlGenericErrorContext, "Document %s does not validate against %s\n", filename, dtdvalidfpi); progresult = XMLLINT_ERR_VALID; } if ((timing) && (!repeat)) { endTimer("Validating against DTD"); } xmlFreeValidCtxt(cvp); xmlFreeDtd(dtd); } } else if (postvalid) { xmlValidCtxtPtr cvp; if ((cvp = xmlNewValidCtxt()) == NULL) { xmlGenericError(xmlGenericErrorContext, "Couldn't allocate validation context\n"); exit(-1); } if ((timing) && (!repeat)) { startTimer(); } cvp->userData = (void *) stderr; cvp->error = (xmlValidityErrorFunc) fprintf; cvp->warning = (xmlValidityWarningFunc) fprintf; if (!xmlValidateDocument(cvp, doc)) { xmlGenericError(xmlGenericErrorContext, "Document %s does not validate\n", filename); progresult = XMLLINT_ERR_VALID; } if ((timing) && (!repeat)) { endTimer("Validating"); } xmlFreeValidCtxt(cvp); } #endif /* LIBXML_VALID_ENABLED */ #ifdef LIBXML_SCHEMATRON_ENABLED if (wxschematron != NULL) { xmlSchematronValidCtxtPtr ctxt; int ret; int flag; if ((timing) && (!repeat)) { startTimer(); } if (debug) flag = XML_SCHEMATRON_OUT_XML; else flag = XML_SCHEMATRON_OUT_TEXT; if (noout) flag |= XML_SCHEMATRON_OUT_QUIET; ctxt = xmlSchematronNewValidCtxt(wxschematron, flag); #if 0 xmlSchematronSetValidErrors(ctxt, (xmlSchematronValidityErrorFunc) fprintf, (xmlSchematronValidityWarningFunc) fprintf, stderr); #endif ret = xmlSchematronValidateDoc(ctxt, doc); if (ret == 0) { fprintf(stderr, "%s validates\n", filename); } else if (ret > 0) { fprintf(stderr, "%s fails to validate\n", filename); progresult = XMLLINT_ERR_VALID; } else { fprintf(stderr, "%s validation generated an internal error\n", filename); progresult = XMLLINT_ERR_VALID; } xmlSchematronFreeValidCtxt(ctxt); if ((timing) && (!repeat)) { endTimer("Validating"); } } #endif #ifdef LIBXML_SCHEMAS_ENABLED if (relaxngschemas != NULL) { xmlRelaxNGValidCtxtPtr ctxt; int ret; if ((timing) && (!repeat)) { startTimer(); } ctxt = xmlRelaxNGNewValidCtxt(relaxngschemas); xmlRelaxNGSetValidErrors(ctxt, (xmlRelaxNGValidityErrorFunc) fprintf, (xmlRelaxNGValidityWarningFunc) fprintf, stderr); ret = xmlRelaxNGValidateDoc(ctxt, doc); if (ret == 0) { fprintf(stderr, "%s validates\n", filename); } else if (ret > 0) { fprintf(stderr, "%s fails to validate\n", filename); progresult = XMLLINT_ERR_VALID; } else { fprintf(stderr, "%s validation generated an internal error\n", filename); progresult = XMLLINT_ERR_VALID; } xmlRelaxNGFreeValidCtxt(ctxt); if ((timing) && (!repeat)) { endTimer("Validating"); } } else if (wxschemas != NULL) { xmlSchemaValidCtxtPtr ctxt; int ret; if ((timing) && (!repeat)) { startTimer(); } ctxt = xmlSchemaNewValidCtxt(wxschemas); xmlSchemaSetValidErrors(ctxt, (xmlSchemaValidityErrorFunc) fprintf, (xmlSchemaValidityWarningFunc) fprintf, stderr); ret = xmlSchemaValidateDoc(ctxt, doc); if (ret == 0) { fprintf(stderr, "%s validates\n", filename); } else if (ret > 0) { fprintf(stderr, "%s fails to validate\n", filename); progresult = XMLLINT_ERR_VALID; } else { fprintf(stderr, "%s validation generated an internal error\n", filename); progresult = XMLLINT_ERR_VALID; } xmlSchemaFreeValidCtxt(ctxt); if ((timing) && (!repeat)) { endTimer("Validating"); } } #endif #ifdef LIBXML_DEBUG_ENABLED if ((debugent) && (!html)) xmlDebugDumpEntities(stderr, doc); #endif /* * free it. */ if ((timing) && (!repeat)) { startTimer(); } xmlFreeDoc(doc); if ((timing) && (!repeat)) { endTimer("Freeing"); } } /************************************************************************ * * * Usage and Main * * * ************************************************************************/ static void showVersion(const char *name) { fprintf(stderr, "%s: using libxml version %s\n", name, xmlParserVersion); fprintf(stderr, " compiled with: "); if (xmlHasFeature(XML_WITH_THREAD)) fprintf(stderr, "Threads "); if (xmlHasFeature(XML_WITH_TREE)) fprintf(stderr, "Tree "); if (xmlHasFeature(XML_WITH_OUTPUT)) fprintf(stderr, "Output "); if (xmlHasFeature(XML_WITH_PUSH)) fprintf(stderr, "Push "); if (xmlHasFeature(XML_WITH_READER)) fprintf(stderr, "Reader "); if (xmlHasFeature(XML_WITH_PATTERN)) fprintf(stderr, "Patterns "); if (xmlHasFeature(XML_WITH_WRITER)) fprintf(stderr, "Writer "); if (xmlHasFeature(XML_WITH_SAX1)) fprintf(stderr, "SAXv1 "); if (xmlHasFeature(XML_WITH_FTP)) fprintf(stderr, "FTP "); if (xmlHasFeature(XML_WITH_HTTP)) fprintf(stderr, "HTTP "); if (xmlHasFeature(XML_WITH_VALID)) fprintf(stderr, "DTDValid "); if (xmlHasFeature(XML_WITH_HTML)) fprintf(stderr, "HTML "); if (xmlHasFeature(XML_WITH_LEGACY)) fprintf(stderr, "Legacy "); if (xmlHasFeature(XML_WITH_C14N)) fprintf(stderr, "C14N "); if (xmlHasFeature(XML_WITH_CATALOG)) fprintf(stderr, "Catalog "); if (xmlHasFeature(XML_WITH_XPATH)) fprintf(stderr, "XPath "); if (xmlHasFeature(XML_WITH_XPTR)) fprintf(stderr, "XPointer "); if (xmlHasFeature(XML_WITH_XINCLUDE)) fprintf(stderr, "XInclude "); if (xmlHasFeature(XML_WITH_ICONV)) fprintf(stderr, "Iconv "); if (xmlHasFeature(XML_WITH_ISO8859X)) fprintf(stderr, "ISO8859X "); if (xmlHasFeature(XML_WITH_UNICODE)) fprintf(stderr, "Unicode "); if (xmlHasFeature(XML_WITH_REGEXP)) fprintf(stderr, "Regexps "); if (xmlHasFeature(XML_WITH_AUTOMATA)) fprintf(stderr, "Automata "); if (xmlHasFeature(XML_WITH_EXPR)) fprintf(stderr, "Expr "); if (xmlHasFeature(XML_WITH_SCHEMAS)) fprintf(stderr, "Schemas "); if (xmlHasFeature(XML_WITH_SCHEMATRON)) fprintf(stderr, "Schematron "); if (xmlHasFeature(XML_WITH_MODULES)) fprintf(stderr, "Modules "); if (xmlHasFeature(XML_WITH_DEBUG)) fprintf(stderr, "Debug "); if (xmlHasFeature(XML_WITH_DEBUG_MEM)) fprintf(stderr, "MemDebug "); if (xmlHasFeature(XML_WITH_DEBUG_RUN)) fprintf(stderr, "RunDebug "); if (xmlHasFeature(XML_WITH_ZLIB)) fprintf(stderr, "Zlib "); fprintf(stderr, "\n"); } static void usage(const char *name) { printf("Usage : %s [options] XMLfiles ...\n", name); #ifdef LIBXML_OUTPUT_ENABLED printf("\tParse the XML files and output the result of the parsing\n"); #else printf("\tParse the XML files\n"); #endif /* LIBXML_OUTPUT_ENABLED */ printf("\t--version : display the version of the XML library used\n"); #ifdef LIBXML_DEBUG_ENABLED printf("\t--debug : dump a debug tree of the in-memory document\n"); printf("\t--shell : run a navigating shell\n"); printf("\t--debugent : debug the entities defined in the document\n"); #else #ifdef LIBXML_READER_ENABLED printf("\t--debug : dump the nodes content when using --stream\n"); #endif /* LIBXML_READER_ENABLED */ #endif #ifdef LIBXML_TREE_ENABLED printf("\t--copy : used to test the internal copy implementation\n"); #endif /* LIBXML_TREE_ENABLED */ printf("\t--recover : output what was parsable on broken XML documents\n"); printf("\t--noent : substitute entity references by their value\n"); printf("\t--noout : don't output the result tree\n"); printf("\t--path 'paths': provide a set of paths for resources\n"); printf("\t--load-trace : print trace of all external entites loaded\n"); printf("\t--nonet : refuse to fetch DTDs or entities over network\n"); printf("\t--nocompact : do not generate compact text nodes\n"); printf("\t--htmlout : output results as HTML\n"); printf("\t--nowrap : do not put HTML doc wrapper\n"); #ifdef LIBXML_VALID_ENABLED printf("\t--valid : validate the document in addition to std well-formed check\n"); printf("\t--postvalid : do a posteriori validation, i.e after parsing\n"); printf("\t--dtdvalid URL : do a posteriori validation against a given DTD\n"); printf("\t--dtdvalidfpi FPI : same but name the DTD with a Public Identifier\n"); #endif /* LIBXML_VALID_ENABLED */ printf("\t--timing : print some timings\n"); printf("\t--output file or -o file: save to a given file\n"); printf("\t--repeat : repeat 100 times, for timing or profiling\n"); printf("\t--insert : ad-hoc test for valid insertions\n"); #ifdef LIBXML_OUTPUT_ENABLED #ifdef HAVE_ZLIB_H printf("\t--compress : turn on gzip compression of output\n"); #endif #endif /* LIBXML_OUTPUT_ENABLED */ #ifdef LIBXML_HTML_ENABLED printf("\t--html : use the HTML parser\n"); printf("\t--xmlout : force to use the XML serializer when using --html\n"); #endif #ifdef LIBXML_PUSH_ENABLED printf("\t--push : use the push mode of the parser\n"); #endif /* LIBXML_PUSH_ENABLED */ #ifdef HAVE_SYS_MMAN_H printf("\t--memory : parse from memory\n"); #endif printf("\t--maxmem nbbytes : limits memory allocation to nbbytes bytes\n"); printf("\t--nowarning : do not emit warnings from parser/validator\n"); printf("\t--noblanks : drop (ignorable?) blanks spaces\n"); printf("\t--nocdata : replace cdata section with text nodes\n"); #ifdef LIBXML_OUTPUT_ENABLED printf("\t--format : reformat/reindent the input\n"); printf("\t--encode encoding : output in the given encoding\n"); printf("\t--dropdtd : remove the DOCTYPE of the input docs\n"); #endif /* LIBXML_OUTPUT_ENABLED */ printf("\t--c14n : save in W3C canonical format (with comments)\n"); printf("\t--exc-c14n : save in W3C exclusive canonical format (with comments)\n"); #ifdef LIBXML_C14N_ENABLED #endif /* LIBXML_C14N_ENABLED */ printf("\t--nsclean : remove redundant namespace declarations\n"); printf("\t--testIO : test user I/O support\n"); #ifdef LIBXML_CATALOG_ENABLED printf("\t--catalogs : use SGML catalogs from $SGML_CATALOG_FILES\n"); printf("\t otherwise XML Catalogs starting from \n"); printf("\t %s are activated by default\n", XML_XML_DEFAULT_CATALOG); printf("\t--nocatalogs: deactivate all catalogs\n"); #endif printf("\t--auto : generate a small doc on the fly\n"); #ifdef LIBXML_XINCLUDE_ENABLED printf("\t--xinclude : do XInclude processing\n"); printf("\t--noxincludenode : same but do not generate XInclude nodes\n"); #endif printf("\t--loaddtd : fetch external DTD\n"); printf("\t--dtdattr : loaddtd + populate the tree with inherited attributes \n"); #ifdef LIBXML_READER_ENABLED printf("\t--stream : use the streaming interface to process very large files\n"); printf("\t--walker : create a reader and walk though the resulting doc\n"); #endif /* LIBXML_READER_ENABLED */ #ifdef LIBXML_PATTERN_ENABLED printf("\t--pattern pattern_value : test the pattern support\n"); #endif printf("\t--chkregister : verify the node registration code\n"); #ifdef LIBXML_SCHEMAS_ENABLED printf("\t--relaxng schema : do RelaxNG validation against the schema\n"); printf("\t--schema schema : do validation against the WXS schema\n"); #endif #ifdef LIBXML_SCHEMATRON_ENABLED printf("\t--schematron schema : do validation against a schematron\n"); #endif #ifdef LIBXML_SAX1_ENABLED printf("\t--sax1: use the old SAX1 interfaces for processing\n"); #endif printf("\t--sax: do not build a tree but work just at the SAX level\n"); printf("\nLibxml project home page: http://xmlsoft.org/\n"); printf("To report bugs or get some help check: http://xmlsoft.org/bugs.html\n"); } static void registerNode(xmlNodePtr node) { node->_private = malloc(sizeof(long)); *(long*)node->_private = (long) 0x81726354; nbregister++; } static void deregisterNode(xmlNodePtr node) { assert(node->_private != NULL); assert(*(long*)node->_private == (long) 0x81726354); free(node->_private); nbregister--; } int main(int argc, char **argv) { int i, acount; int files = 0; int version = 0; const char* indent; if (argc <= 1) { usage(argv[0]); return(1); } LIBXML_TEST_VERSION for (i = 1; i < argc ; i++) { if (!strcmp(argv[i], "-")) break; if (argv[i][0] != '-') continue; if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug"))) debug++; else #ifdef LIBXML_DEBUG_ENABLED if ((!strcmp(argv[i], "-shell")) || (!strcmp(argv[i], "--shell"))) { shell++; noout = 1; } else #endif #ifdef LIBXML_TREE_ENABLED if ((!strcmp(argv[i], "-copy")) || (!strcmp(argv[i], "--copy"))) copy++; else #endif /* LIBXML_TREE_ENABLED */ if ((!strcmp(argv[i], "-recover")) || (!strcmp(argv[i], "--recover"))) { recovery++; options |= XML_PARSE_RECOVER; } else if ((!strcmp(argv[i], "-noent")) || (!strcmp(argv[i], "--noent"))) { noent++; options |= XML_PARSE_NOENT; } else if ((!strcmp(argv[i], "-nsclean")) || (!strcmp(argv[i], "--nsclean"))) { options |= XML_PARSE_NSCLEAN; } else if ((!strcmp(argv[i], "-nocdata")) || (!strcmp(argv[i], "--nocdata"))) { options |= XML_PARSE_NOCDATA; } else if ((!strcmp(argv[i], "-nodict")) || (!strcmp(argv[i], "--nodict"))) { options |= XML_PARSE_NODICT; } else if ((!strcmp(argv[i], "-version")) || (!strcmp(argv[i], "--version"))) { showVersion(argv[0]); version = 1; } else if ((!strcmp(argv[i], "-noout")) || (!strcmp(argv[i], "--noout"))) noout++; #ifdef LIBXML_OUTPUT_ENABLED else if ((!strcmp(argv[i], "-o")) || (!strcmp(argv[i], "-output")) || (!strcmp(argv[i], "--output"))) { i++; output = argv[i]; } #endif /* LIBXML_OUTPUT_ENABLED */ else if ((!strcmp(argv[i], "-htmlout")) || (!strcmp(argv[i], "--htmlout"))) htmlout++; else if ((!strcmp(argv[i], "-nowrap")) || (!strcmp(argv[i], "--nowrap"))) nowrap++; #ifdef LIBXML_HTML_ENABLED else if ((!strcmp(argv[i], "-html")) || (!strcmp(argv[i], "--html"))) { html++; } else if ((!strcmp(argv[i], "-xmlout")) || (!strcmp(argv[i], "--xmlout"))) { xmlout++; } #endif /* LIBXML_HTML_ENABLED */ else if ((!strcmp(argv[i], "-loaddtd")) || (!strcmp(argv[i], "--loaddtd"))) { loaddtd++; options |= XML_PARSE_DTDLOAD; } else if ((!strcmp(argv[i], "-dtdattr")) || (!strcmp(argv[i], "--dtdattr"))) { loaddtd++; dtdattrs++; options |= XML_PARSE_DTDATTR; } #ifdef LIBXML_VALID_ENABLED else if ((!strcmp(argv[i], "-valid")) || (!strcmp(argv[i], "--valid"))) { valid++; options |= XML_PARSE_DTDVALID; } else if ((!strcmp(argv[i], "-postvalid")) || (!strcmp(argv[i], "--postvalid"))) { postvalid++; loaddtd++; options |= XML_PARSE_DTDLOAD; } else if ((!strcmp(argv[i], "-dtdvalid")) || (!strcmp(argv[i], "--dtdvalid"))) { i++; dtdvalid = argv[i]; loaddtd++; options |= XML_PARSE_DTDLOAD; } else if ((!strcmp(argv[i], "-dtdvalidfpi")) || (!strcmp(argv[i], "--dtdvalidfpi"))) { i++; dtdvalidfpi = argv[i]; loaddtd++; options |= XML_PARSE_DTDLOAD; } #endif /* LIBXML_VALID_ENABLED */ else if ((!strcmp(argv[i], "-dropdtd")) || (!strcmp(argv[i], "--dropdtd"))) dropdtd++; else if ((!strcmp(argv[i], "-insert")) || (!strcmp(argv[i], "--insert"))) insert++; else if ((!strcmp(argv[i], "-timing")) || (!strcmp(argv[i], "--timing"))) timing++; else if ((!strcmp(argv[i], "-auto")) || (!strcmp(argv[i], "--auto"))) generate++; else if ((!strcmp(argv[i], "-repeat")) || (!strcmp(argv[i], "--repeat"))) { if (repeat) repeat *= 10; else repeat = 100; } #ifdef LIBXML_PUSH_ENABLED else if ((!strcmp(argv[i], "-push")) || (!strcmp(argv[i], "--push"))) push++; #endif /* LIBXML_PUSH_ENABLED */ #ifdef HAVE_SYS_MMAN_H else if ((!strcmp(argv[i], "-memory")) || (!strcmp(argv[i], "--memory"))) memory++; #endif else if ((!strcmp(argv[i], "-testIO")) || (!strcmp(argv[i], "--testIO"))) testIO++; #ifdef LIBXML_XINCLUDE_ENABLED else if ((!strcmp(argv[i], "-xinclude")) || (!strcmp(argv[i], "--xinclude"))) { xinclude++; options |= XML_PARSE_XINCLUDE; } else if ((!strcmp(argv[i], "-noxincludenode")) || (!strcmp(argv[i], "--noxincludenode"))) { xinclude++; options |= XML_PARSE_XINCLUDE; options |= XML_PARSE_NOXINCNODE; } #endif #ifdef LIBXML_OUTPUT_ENABLED #ifdef HAVE_ZLIB_H else if ((!strcmp(argv[i], "-compress")) || (!strcmp(argv[i], "--compress"))) { compress++; xmlSetCompressMode(9); } #endif #endif /* LIBXML_OUTPUT_ENABLED */ else if ((!strcmp(argv[i], "-nowarning")) || (!strcmp(argv[i], "--nowarning"))) { xmlGetWarningsDefaultValue = 0; xmlPedanticParserDefault(0); options |= XML_PARSE_NOWARNING; } else if ((!strcmp(argv[i], "-pedantic")) || (!strcmp(argv[i], "--pedantic"))) { xmlGetWarningsDefaultValue = 1; xmlPedanticParserDefault(1); options |= XML_PARSE_PEDANTIC; } #ifdef LIBXML_DEBUG_ENABLED else if ((!strcmp(argv[i], "-debugent")) || (!strcmp(argv[i], "--debugent"))) { debugent++; xmlParserDebugEntities = 1; } #endif #ifdef LIBXML_C14N_ENABLED else if ((!strcmp(argv[i], "-c14n")) || (!strcmp(argv[i], "--c14n"))) { canonical++; options |= XML_PARSE_NOENT | XML_PARSE_DTDATTR | XML_PARSE_DTDLOAD; } else if ((!strcmp(argv[i], "-exc-c14n")) || (!strcmp(argv[i], "--exc-c14n"))) { exc_canonical++; options |= XML_PARSE_NOENT | XML_PARSE_DTDATTR | XML_PARSE_DTDLOAD; } #endif #ifdef LIBXML_CATALOG_ENABLED else if ((!strcmp(argv[i], "-catalogs")) || (!strcmp(argv[i], "--catalogs"))) { catalogs++; } else if ((!strcmp(argv[i], "-nocatalogs")) || (!strcmp(argv[i], "--nocatalogs"))) { nocatalogs++; } #endif else if ((!strcmp(argv[i], "-encode")) || (!strcmp(argv[i], "--encode"))) { i++; encoding = argv[i]; /* * OK it's for testing purposes */ xmlAddEncodingAlias("UTF-8", "DVEnc"); } else if ((!strcmp(argv[i], "-noblanks")) || (!strcmp(argv[i], "--noblanks"))) { noblanks++; xmlKeepBlanksDefault(0); } else if ((!strcmp(argv[i], "-maxmem")) || (!strcmp(argv[i], "--maxmem"))) { i++; if (sscanf(argv[i], "%d", &maxmem) == 1) { xmlMemSetup(myFreeFunc, myMallocFunc, myReallocFunc, myStrdupFunc); } else { maxmem = 0; } } else if ((!strcmp(argv[i], "-format")) || (!strcmp(argv[i], "--format"))) { noblanks++; #ifdef LIBXML_OUTPUT_ENABLED format++; #endif /* LIBXML_OUTPUT_ENABLED */ xmlKeepBlanksDefault(0); } #ifdef LIBXML_READER_ENABLED else if ((!strcmp(argv[i], "-stream")) || (!strcmp(argv[i], "--stream"))) { stream++; } else if ((!strcmp(argv[i], "-walker")) || (!strcmp(argv[i], "--walker"))) { walker++; noout++; } #endif /* LIBXML_READER_ENABLED */ #ifdef LIBXML_SAX1_ENABLED else if ((!strcmp(argv[i], "-sax1")) || (!strcmp(argv[i], "--sax1"))) { sax1++; } #endif /* LIBXML_SAX1_ENABLED */ else if ((!strcmp(argv[i], "-sax")) || (!strcmp(argv[i], "--sax"))) { sax++; } else if ((!strcmp(argv[i], "-chkregister")) || (!strcmp(argv[i], "--chkregister"))) { chkregister++; #ifdef LIBXML_SCHEMAS_ENABLED } else if ((!strcmp(argv[i], "-relaxng")) || (!strcmp(argv[i], "--relaxng"))) { i++; relaxng = argv[i]; noent++; options |= XML_PARSE_NOENT; } else if ((!strcmp(argv[i], "-schema")) || (!strcmp(argv[i], "--schema"))) { i++; schema = argv[i]; noent++; #endif #ifdef LIBXML_SCHEMATRON_ENABLED } else if ((!strcmp(argv[i], "-schematron")) || (!strcmp(argv[i], "--schematron"))) { i++; schematron = argv[i]; noent++; #endif } else if ((!strcmp(argv[i], "-nonet")) || (!strcmp(argv[i], "--nonet"))) { options |= XML_PARSE_NONET; xmlSetExternalEntityLoader(xmlNoNetExternalEntityLoader); } else if ((!strcmp(argv[i], "-nocompact")) || (!strcmp(argv[i], "--nocompact"))) { options &= ~XML_PARSE_COMPACT; } else if ((!strcmp(argv[i], "-load-trace")) || (!strcmp(argv[i], "--load-trace"))) { load_trace++; } else if ((!strcmp(argv[i], "-path")) || (!strcmp(argv[i], "--path"))) { i++; parsePath(BAD_CAST argv[i]); #ifdef LIBXML_PATTERN_ENABLED } else if ((!strcmp(argv[i], "-pattern")) || (!strcmp(argv[i], "--pattern"))) { i++; pattern = argv[i]; #endif } else { fprintf(stderr, "Unknown option %s\n", argv[i]); usage(argv[0]); return(1); } } #ifdef LIBXML_CATALOG_ENABLED if (nocatalogs == 0) { if (catalogs) { const char *catal; catal = getenv("SGML_CATALOG_FILES"); if (catal != NULL) { xmlLoadCatalogs(catal); } else { fprintf(stderr, "Variable $SGML_CATALOG_FILES not set\n"); } } } #endif #ifdef LIBXML_SAX1_ENABLED if (sax1) xmlSAXDefaultVersion(1); else xmlSAXDefaultVersion(2); #endif /* LIBXML_SAX1_ENABLED */ if (chkregister) { xmlRegisterNodeDefault(registerNode); xmlDeregisterNodeDefault(deregisterNode); } indent = getenv("XMLLINT_INDENT"); if(indent != NULL) { xmlTreeIndentString = indent; } defaultEntityLoader = xmlGetExternalEntityLoader(); xmlSetExternalEntityLoader(xmllintExternalEntityLoader); xmlLineNumbersDefault(1); if (loaddtd != 0) xmlLoadExtDtdDefaultValue |= XML_DETECT_IDS; if (dtdattrs) xmlLoadExtDtdDefaultValue |= XML_COMPLETE_ATTRS; if (noent != 0) xmlSubstituteEntitiesDefault(1); #ifdef LIBXML_VALID_ENABLED if (valid != 0) xmlDoValidityCheckingDefaultValue = 1; #endif /* LIBXML_VALID_ENABLED */ if ((htmlout) && (!nowrap)) { xmlGenericError(xmlGenericErrorContext, "\n"); xmlGenericError(xmlGenericErrorContext, "%s output\n", argv[0]); xmlGenericError(xmlGenericErrorContext, "

%s output

\n", argv[0]); } #ifdef LIBXML_SCHEMATRON_ENABLED if ((schematron != NULL) && (sax == 0) #ifdef LIBXML_READER_ENABLED && (stream == 0) #endif /* LIBXML_READER_ENABLED */ ) { xmlSchematronParserCtxtPtr ctxt; /* forces loading the DTDs */ xmlLoadExtDtdDefaultValue |= 1; options |= XML_PARSE_DTDLOAD; if (timing) { startTimer(); } ctxt = xmlSchematronNewParserCtxt(schematron); #if 0 xmlSchematronSetParserErrors(ctxt, (xmlSchematronValidityErrorFunc) fprintf, (xmlSchematronValidityWarningFunc) fprintf, stderr); #endif wxschematron = xmlSchematronParse(ctxt); if (wxschematron == NULL) { xmlGenericError(xmlGenericErrorContext, "Schematron schema %s failed to compile\n", schematron); progresult = XMLLINT_ERR_SCHEMACOMP; schematron = NULL; } xmlSchematronFreeParserCtxt(ctxt); if (timing) { endTimer("Compiling the schemas"); } } #endif #ifdef LIBXML_SCHEMAS_ENABLED if ((relaxng != NULL) && (sax == 0) #ifdef LIBXML_READER_ENABLED && (stream == 0) #endif /* LIBXML_READER_ENABLED */ ) { xmlRelaxNGParserCtxtPtr ctxt; /* forces loading the DTDs */ xmlLoadExtDtdDefaultValue |= 1; options |= XML_PARSE_DTDLOAD; if (timing) { startTimer(); } ctxt = xmlRelaxNGNewParserCtxt(relaxng); xmlRelaxNGSetParserErrors(ctxt, (xmlRelaxNGValidityErrorFunc) fprintf, (xmlRelaxNGValidityWarningFunc) fprintf, stderr); relaxngschemas = xmlRelaxNGParse(ctxt); if (relaxngschemas == NULL) { xmlGenericError(xmlGenericErrorContext, "Relax-NG schema %s failed to compile\n", relaxng); progresult = XMLLINT_ERR_SCHEMACOMP; relaxng = NULL; } xmlRelaxNGFreeParserCtxt(ctxt); if (timing) { endTimer("Compiling the schemas"); } } else if ((schema != NULL) #ifdef LIBXML_READER_ENABLED && (stream == 0) #endif ) { xmlSchemaParserCtxtPtr ctxt; if (timing) { startTimer(); } ctxt = xmlSchemaNewParserCtxt(schema); xmlSchemaSetParserErrors(ctxt, (xmlSchemaValidityErrorFunc) fprintf, (xmlSchemaValidityWarningFunc) fprintf, stderr); wxschemas = xmlSchemaParse(ctxt); if (wxschemas == NULL) { xmlGenericError(xmlGenericErrorContext, "WXS schema %s failed to compile\n", schema); progresult = XMLLINT_ERR_SCHEMACOMP; schema = NULL; } xmlSchemaFreeParserCtxt(ctxt); if (timing) { endTimer("Compiling the schemas"); } } #endif /* LIBXML_SCHEMAS_ENABLED */ #ifdef LIBXML_PATTERN_ENABLED if ((pattern != NULL) #ifdef LIBXML_READER_ENABLED && (walker == 0) #endif ) { patternc = xmlPatterncompile((const xmlChar *) pattern, NULL, 0, NULL); if (patternc == NULL) { xmlGenericError(xmlGenericErrorContext, "Pattern %s failed to compile\n", pattern); progresult = XMLLINT_ERR_SCHEMAPAT; pattern = NULL; } } #endif /* LIBXML_PATTERN_ENABLED */ for (i = 1; i < argc ; i++) { if ((!strcmp(argv[i], "-encode")) || (!strcmp(argv[i], "--encode"))) { i++; continue; } else if ((!strcmp(argv[i], "-o")) || (!strcmp(argv[i], "-output")) || (!strcmp(argv[i], "--output"))) { i++; continue; } #ifdef LIBXML_VALID_ENABLED if ((!strcmp(argv[i], "-dtdvalid")) || (!strcmp(argv[i], "--dtdvalid"))) { i++; continue; } if ((!strcmp(argv[i], "-path")) || (!strcmp(argv[i], "--path"))) { i++; continue; } if ((!strcmp(argv[i], "-dtdvalidfpi")) || (!strcmp(argv[i], "--dtdvalidfpi"))) { i++; continue; } #endif /* LIBXML_VALID_ENABLED */ if ((!strcmp(argv[i], "-relaxng")) || (!strcmp(argv[i], "--relaxng"))) { i++; continue; } if ((!strcmp(argv[i], "-maxmem")) || (!strcmp(argv[i], "--maxmem"))) { i++; continue; } if ((!strcmp(argv[i], "-schema")) || (!strcmp(argv[i], "--schema"))) { i++; continue; } if ((!strcmp(argv[i], "-schematron")) || (!strcmp(argv[i], "--schematron"))) { i++; continue; } #ifdef LIBXML_PATTERN_ENABLED if ((!strcmp(argv[i], "-pattern")) || (!strcmp(argv[i], "--pattern"))) { i++; continue; } #endif if ((timing) && (repeat)) startTimer(); /* Remember file names. "-" means stdin. */ if ((argv[i][0] != '-') || (strcmp(argv[i], "-") == 0)) { if (repeat) { xmlParserCtxtPtr ctxt = NULL; for (acount = 0;acount < repeat;acount++) { #ifdef LIBXML_READER_ENABLED if (stream != 0) { streamFile(argv[i]); } else { #endif /* LIBXML_READER_ENABLED */ if (sax) { testSAX(argv[i]); } else { if (ctxt == NULL) ctxt = xmlNewParserCtxt(); parseAndPrintFile(argv[i], ctxt); } #ifdef LIBXML_READER_ENABLED } #endif /* LIBXML_READER_ENABLED */ } if (ctxt != NULL) xmlFreeParserCtxt(ctxt); } else { nbregister = 0; #ifdef LIBXML_READER_ENABLED if (stream != 0) streamFile(argv[i]); else #endif /* LIBXML_READER_ENABLED */ if (sax) { testSAX(argv[i]); } else { parseAndPrintFile(argv[i], NULL); } if ((chkregister) && (nbregister != 0)) { fprintf(stderr, "Registration count off: %d\n", nbregister); progresult = XMLLINT_ERR_RDREGIS; } } files ++; if ((timing) && (repeat)) { endTimer("%d iterations", repeat); } } } if (generate) parseAndPrintFile(NULL, NULL); if ((htmlout) && (!nowrap)) { xmlGenericError(xmlGenericErrorContext, "\n"); } if ((files == 0) && (!generate) && (version == 0)) { usage(argv[0]); } #ifdef LIBXML_SCHEMATRON_ENABLED if (wxschematron != NULL) xmlSchematronFree(wxschematron); #endif #ifdef LIBXML_SCHEMAS_ENABLED if (relaxngschemas != NULL) xmlRelaxNGFree(relaxngschemas); if (wxschemas != NULL) xmlSchemaFree(wxschemas); xmlRelaxNGCleanupTypes(); #endif #ifdef LIBXML_PATTERN_ENABLED if (patternc != NULL) xmlFreePattern(patternc); #endif xmlCleanupParser(); xmlMemoryDump(); return(progresult); } xdmf-3.0+git20160803/Utilities/vtklibxml2/parserInternals.c0000640000175000017500000020015513003006557023466 0ustar alastairalastair/* * parserInternals.c : Internal routines (and obsolete ones) needed for the * XML and HTML parsers. * * See Copyright for the status of this software. * * daniel@veillard.com */ #define IN_LIBXML #include "libxml.h" #if defined(WIN32) && !defined (__CYGWIN__) #define XML_DIR_SEP '\\' #else #define XML_DIR_SEP '/' #endif #include #ifdef HAVE_CTYPE_H #include #endif #ifdef HAVE_STDLIB_H #include #endif #ifdef HAVE_SYS_STAT_H #include #endif #ifdef HAVE_FCNTL_H #include #endif #ifdef HAVE_UNISTD_H #include #endif #include "vtk_libxml2_zlib.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef LIBXML_CATALOG_ENABLED #include #endif #include #include /* * Various global defaults for parsing */ /** * xmlCheckVersion: * @version: the include version number * * check the compiled lib version against the include one. * This can warn or immediately kill the application */ void xmlCheckVersion(int version) { int myversion = (int) LIBXML_VERSION; xmlInitParser(); if ((myversion / 10000) != (version / 10000)) { xmlGenericError(xmlGenericErrorContext, "Fatal: program compiled against libxml %d using libxml %d\n", (version / 10000), (myversion / 10000)); fprintf(stderr, "Fatal: program compiled against libxml %d using libxml %d\n", (version / 10000), (myversion / 10000)); } if ((myversion / 100) < (version / 100)) { xmlGenericError(xmlGenericErrorContext, "Warning: program compiled against libxml %d using older %d\n", (version / 100), (myversion / 100)); } } /************************************************************************ * * * Some factorized error routines * * * ************************************************************************/ /** * xmlErrMemory: * @ctxt: an XML parser context * @extra: extra informations * * Handle a redefinition of attribute error */ void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra) { if ((ctxt != NULL) && (ctxt->disableSAX != 0) && (ctxt->instate == XML_PARSER_EOF)) return; if (ctxt != NULL) { ctxt->errNo = XML_ERR_NO_MEMORY; ctxt->instate = XML_PARSER_EOF; ctxt->disableSAX = 1; } if (extra) __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, XML_ERR_NO_MEMORY, XML_ERR_FATAL, NULL, 0, extra, NULL, NULL, 0, 0, "Memory allocation failed : %s\n", extra); else __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, XML_ERR_NO_MEMORY, XML_ERR_FATAL, NULL, 0, NULL, NULL, NULL, 0, 0, "Memory allocation failed\n"); } /** * __xmlErrEncoding: * @ctxt: an XML parser context * @xmlerr: the error number * @msg: the error message * @str1: an string info * @str2: an string info * * Handle an encoding error */ void __xmlErrEncoding(xmlParserCtxtPtr ctxt, xmlParserErrors xmlerr, const char *msg, const xmlChar * str1, const xmlChar * str2) { if ((ctxt != NULL) && (ctxt->disableSAX != 0) && (ctxt->instate == XML_PARSER_EOF)) return; if (ctxt != NULL) ctxt->errNo = xmlerr; __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, xmlerr, XML_ERR_FATAL, NULL, 0, (const char *) str1, (const char *) str2, NULL, 0, 0, msg, str1, str2); if (ctxt != NULL) { ctxt->wellFormed = 0; if (ctxt->recovery == 0) ctxt->disableSAX = 1; } } /** * xmlErrInternal: * @ctxt: an XML parser context * @msg: the error message * @str: error informations * * Handle an internal error */ static void xmlErrInternal(xmlParserCtxtPtr ctxt, const char *msg, const xmlChar * str) { if ((ctxt != NULL) && (ctxt->disableSAX != 0) && (ctxt->instate == XML_PARSER_EOF)) return; if (ctxt != NULL) ctxt->errNo = XML_ERR_INTERNAL_ERROR; __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, XML_ERR_INTERNAL_ERROR, XML_ERR_FATAL, NULL, 0, (const char *) str, NULL, NULL, 0, 0, msg, str); if (ctxt != NULL) { ctxt->wellFormed = 0; if (ctxt->recovery == 0) ctxt->disableSAX = 1; } } /** * xmlErrEncodingInt: * @ctxt: an XML parser context * @error: the error number * @msg: the error message * @val: an integer value * * n encoding error */ static void xmlErrEncodingInt(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *msg, int val) { if ((ctxt != NULL) && (ctxt->disableSAX != 0) && (ctxt->instate == XML_PARSER_EOF)) return; if (ctxt != NULL) ctxt->errNo = error; __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error, XML_ERR_FATAL, NULL, 0, NULL, NULL, NULL, val, 0, msg, val); if (ctxt != NULL) { ctxt->wellFormed = 0; if (ctxt->recovery == 0) ctxt->disableSAX = 1; } } /** * xmlIsLetter: * @c: an unicode character (int) * * Check whether the character is allowed by the production * [84] Letter ::= BaseChar | Ideographic * * Returns 0 if not, non-zero otherwise */ int xmlIsLetter(int c) { return(IS_BASECHAR(c) || IS_IDEOGRAPHIC(c)); } /************************************************************************ * * * Input handling functions for progressive parsing * * * ************************************************************************/ /* #define DEBUG_INPUT */ /* #define DEBUG_STACK */ /* #define DEBUG_PUSH */ /* we need to keep enough input to show errors in context */ #define LINE_LEN 80 #ifdef DEBUG_INPUT #define CHECK_BUFFER(in) check_buffer(in) static void check_buffer(xmlParserInputPtr in) { if (in->base != in->buf->buffer->content) { xmlGenericError(xmlGenericErrorContext, "xmlParserInput: base mismatch problem\n"); } if (in->cur < in->base) { xmlGenericError(xmlGenericErrorContext, "xmlParserInput: cur < base problem\n"); } if (in->cur > in->base + in->buf->buffer->use) { xmlGenericError(xmlGenericErrorContext, "xmlParserInput: cur > base + use problem\n"); } xmlGenericError(xmlGenericErrorContext,"buffer %x : content %x, cur %d, use %d, size %d\n", (int) in, (int) in->buf->buffer->content, in->cur - in->base, in->buf->buffer->use, in->buf->buffer->size); } #else #define CHECK_BUFFER(in) #endif /** * xmlParserInputRead: * @in: an XML parser input * @len: an indicative size for the lookahead * * This function refresh the input for the parser. It doesn't try to * preserve pointers to the input buffer, and discard already read data * * Returns the number of xmlChars read, or -1 in case of error, 0 indicate the * end of this entity */ int xmlParserInputRead(xmlParserInputPtr in, int len) { int ret; int used; int indx; if (in == NULL) return(-1); #ifdef DEBUG_INPUT xmlGenericError(xmlGenericErrorContext, "Read\n"); #endif if (in->buf == NULL) return(-1); if (in->base == NULL) return(-1); if (in->cur == NULL) return(-1); if (in->buf->buffer == NULL) return(-1); if (in->buf->readcallback == NULL) return(-1); CHECK_BUFFER(in); used = in->cur - in->buf->buffer->content; ret = xmlBufferShrink(in->buf->buffer, used); if (ret > 0) { in->cur -= ret; in->consumed += ret; } ret = xmlParserInputBufferRead(in->buf, len); if (in->base != in->buf->buffer->content) { /* * the buffer has been reallocated */ indx = in->cur - in->base; in->base = in->buf->buffer->content; in->cur = &in->buf->buffer->content[indx]; } in->end = &in->buf->buffer->content[in->buf->buffer->use]; CHECK_BUFFER(in); return(ret); } /** * xmlParserInputGrow: * @in: an XML parser input * @len: an indicative size for the lookahead * * This function increase the input for the parser. It tries to * preserve pointers to the input buffer, and keep already read data * * Returns the number of xmlChars read, or -1 in case of error, 0 indicate the * end of this entity */ int xmlParserInputGrow(xmlParserInputPtr in, int len) { int ret; int indx; if (in == NULL) return(-1); #ifdef DEBUG_INPUT xmlGenericError(xmlGenericErrorContext, "Grow\n"); #endif if (in->buf == NULL) return(-1); if (in->base == NULL) return(-1); if (in->cur == NULL) return(-1); if (in->buf->buffer == NULL) return(-1); CHECK_BUFFER(in); indx = in->cur - in->base; if (in->buf->buffer->use > (unsigned int) indx + INPUT_CHUNK) { CHECK_BUFFER(in); return(0); } if (in->buf->readcallback != NULL) ret = xmlParserInputBufferGrow(in->buf, len); else return(0); /* * NOTE : in->base may be a "dangling" i.e. freed pointer in this * block, but we use it really as an integer to do some * pointer arithmetic. Insure will raise it as a bug but in * that specific case, that's not ! */ if (in->base != in->buf->buffer->content) { /* * the buffer has been reallocated */ indx = in->cur - in->base; in->base = in->buf->buffer->content; in->cur = &in->buf->buffer->content[indx]; } in->end = &in->buf->buffer->content[in->buf->buffer->use]; CHECK_BUFFER(in); return(ret); } /** * xmlParserInputShrink: * @in: an XML parser input * * This function removes used input for the parser. */ void xmlParserInputShrink(xmlParserInputPtr in) { int used; int ret; int indx; #ifdef DEBUG_INPUT xmlGenericError(xmlGenericErrorContext, "Shrink\n"); #endif if (in == NULL) return; if (in->buf == NULL) return; if (in->base == NULL) return; if (in->cur == NULL) return; if (in->buf->buffer == NULL) return; CHECK_BUFFER(in); used = in->cur - in->buf->buffer->content; /* * Do not shrink on large buffers whose only a tiny fraction * was consumed */ if (used > INPUT_CHUNK) { ret = xmlBufferShrink(in->buf->buffer, used - LINE_LEN); if (ret > 0) { in->cur -= ret; in->consumed += ret; } in->end = &in->buf->buffer->content[in->buf->buffer->use]; } CHECK_BUFFER(in); if (in->buf->buffer->use > INPUT_CHUNK) { return; } xmlParserInputBufferRead(in->buf, 2 * INPUT_CHUNK); if (in->base != in->buf->buffer->content) { /* * the buffer has been reallocated */ indx = in->cur - in->base; in->base = in->buf->buffer->content; in->cur = &in->buf->buffer->content[indx]; } in->end = &in->buf->buffer->content[in->buf->buffer->use]; CHECK_BUFFER(in); } /************************************************************************ * * * UTF8 character input and related functions * * * ************************************************************************/ /** * xmlNextChar: * @ctxt: the XML parser context * * Skip to the next char input char. */ void xmlNextChar(xmlParserCtxtPtr ctxt) { if ((ctxt == NULL) || (ctxt->instate == XML_PARSER_EOF) || (ctxt->input == NULL)) return; if (ctxt->charset == XML_CHAR_ENCODING_UTF8) { if ((*ctxt->input->cur == 0) && (xmlParserInputGrow(ctxt->input, INPUT_CHUNK) <= 0) && (ctxt->instate != XML_PARSER_COMMENT)) { /* * If we are at the end of the current entity and * the context allows it, we pop consumed entities * automatically. * the auto closing should be blocked in other cases */ xmlPopInput(ctxt); } else { const unsigned char *cur; unsigned char c; /* * 2.11 End-of-Line Handling * the literal two-character sequence "#xD#xA" or a standalone * literal #xD, an XML processor must pass to the application * the single character #xA. */ if (*(ctxt->input->cur) == '\n') { ctxt->input->line++; ctxt->input->col = 1; } else ctxt->input->col++; /* * We are supposed to handle UTF8, check it's valid * From rfc2044: encoding of the Unicode values on UTF-8: * * UCS-4 range (hex.) UTF-8 octet sequence (binary) * 0000 0000-0000 007F 0xxxxxxx * 0000 0080-0000 07FF 110xxxxx 10xxxxxx * 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx * * Check for the 0x110000 limit too */ cur = ctxt->input->cur; c = *cur; if (c & 0x80) { if (c == 0xC0) goto encoding_error; if (cur[1] == 0) xmlParserInputGrow(ctxt->input, INPUT_CHUNK); if ((cur[1] & 0xc0) != 0x80) goto encoding_error; if ((c & 0xe0) == 0xe0) { unsigned int val; if (cur[2] == 0) xmlParserInputGrow(ctxt->input, INPUT_CHUNK); if ((cur[2] & 0xc0) != 0x80) goto encoding_error; if ((c & 0xf0) == 0xf0) { if (cur[3] == 0) xmlParserInputGrow(ctxt->input, INPUT_CHUNK); if (((c & 0xf8) != 0xf0) || ((cur[3] & 0xc0) != 0x80)) goto encoding_error; /* 4-byte code */ ctxt->input->cur += 4; val = (cur[0] & 0x7) << 18; val |= (cur[1] & 0x3f) << 12; val |= (cur[2] & 0x3f) << 6; val |= cur[3] & 0x3f; } else { /* 3-byte code */ ctxt->input->cur += 3; val = (cur[0] & 0xf) << 12; val |= (cur[1] & 0x3f) << 6; val |= cur[2] & 0x3f; } if (((val > 0xd7ff) && (val < 0xe000)) || ((val > 0xfffd) && (val < 0x10000)) || (val >= 0x110000)) { xmlErrEncodingInt(ctxt, XML_ERR_INVALID_CHAR, "Char 0x%X out of allowed range\n", val); } } else /* 2-byte code */ ctxt->input->cur += 2; } else /* 1-byte code */ ctxt->input->cur++; ctxt->nbChars++; if (*ctxt->input->cur == 0) xmlParserInputGrow(ctxt->input, INPUT_CHUNK); } } else { /* * Assume it's a fixed length encoding (1) with * a compatible encoding for the ASCII set, since * XML constructs only use < 128 chars */ if (*(ctxt->input->cur) == '\n') { ctxt->input->line++; ctxt->input->col = 1; } else ctxt->input->col++; ctxt->input->cur++; ctxt->nbChars++; if (*ctxt->input->cur == 0) xmlParserInputGrow(ctxt->input, INPUT_CHUNK); } if ((*ctxt->input->cur == '%') && (!ctxt->html)) xmlParserHandlePEReference(ctxt); if ((*ctxt->input->cur == 0) && (xmlParserInputGrow(ctxt->input, INPUT_CHUNK) <= 0)) xmlPopInput(ctxt); return; encoding_error: /* * If we detect an UTF8 error that probably mean that the * input encoding didn't get properly advertised in the * declaration header. Report the error and switch the encoding * to ISO-Latin-1 (if you don't like this policy, just declare the * encoding !) */ if ((ctxt == NULL) || (ctxt->input == NULL) || (ctxt->input->end - ctxt->input->cur < 4)) { __xmlErrEncoding(ctxt, XML_ERR_INVALID_CHAR, "Input is not proper UTF-8, indicate encoding !\n", NULL, NULL); } else { char buffer[150]; snprintf(buffer, 149, "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n", ctxt->input->cur[0], ctxt->input->cur[1], ctxt->input->cur[2], ctxt->input->cur[3]); __xmlErrEncoding(ctxt, XML_ERR_INVALID_CHAR, "Input is not proper UTF-8, indicate encoding !\n%s", BAD_CAST buffer, NULL); } ctxt->charset = XML_CHAR_ENCODING_8859_1; ctxt->input->cur++; return; } /** * xmlCurrentChar: * @ctxt: the XML parser context * @len: pointer to the length of the char read * * The current char value, if using UTF-8 this may actually span multiple * bytes in the input buffer. Implement the end of line normalization: * 2.11 End-of-Line Handling * Wherever an external parsed entity or the literal entity value * of an internal parsed entity contains either the literal two-character * sequence "#xD#xA" or a standalone literal #xD, an XML processor * must pass to the application the single character #xA. * This behavior can conveniently be produced by normalizing all * line breaks to #xA on input, before parsing.) * * Returns the current char value and its length */ int xmlCurrentChar(xmlParserCtxtPtr ctxt, int *len) { if ((ctxt == NULL) || (len == NULL) || (ctxt->input == NULL)) return(0); if (ctxt->instate == XML_PARSER_EOF) return(0); if ((*ctxt->input->cur >= 0x20) && (*ctxt->input->cur <= 0x7F)) { *len = 1; return((int) *ctxt->input->cur); } if (ctxt->charset == XML_CHAR_ENCODING_UTF8) { /* * We are supposed to handle UTF8, check it's valid * From rfc2044: encoding of the Unicode values on UTF-8: * * UCS-4 range (hex.) UTF-8 octet sequence (binary) * 0000 0000-0000 007F 0xxxxxxx * 0000 0080-0000 07FF 110xxxxx 10xxxxxx * 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx * * Check for the 0x110000 limit too */ const unsigned char *cur = ctxt->input->cur; unsigned char c; unsigned int val; c = *cur; if (c & 0x80) { if (c == 0xC0) goto encoding_error; if (cur[1] == 0) xmlParserInputGrow(ctxt->input, INPUT_CHUNK); if ((cur[1] & 0xc0) != 0x80) goto encoding_error; if ((c & 0xe0) == 0xe0) { if (cur[2] == 0) xmlParserInputGrow(ctxt->input, INPUT_CHUNK); if ((cur[2] & 0xc0) != 0x80) goto encoding_error; if ((c & 0xf0) == 0xf0) { if (cur[3] == 0) xmlParserInputGrow(ctxt->input, INPUT_CHUNK); if (((c & 0xf8) != 0xf0) || ((cur[3] & 0xc0) != 0x80)) goto encoding_error; /* 4-byte code */ *len = 4; val = (cur[0] & 0x7) << 18; val |= (cur[1] & 0x3f) << 12; val |= (cur[2] & 0x3f) << 6; val |= cur[3] & 0x3f; } else { /* 3-byte code */ *len = 3; val = (cur[0] & 0xf) << 12; val |= (cur[1] & 0x3f) << 6; val |= cur[2] & 0x3f; } } else { /* 2-byte code */ *len = 2; val = (cur[0] & 0x1f) << 6; val |= cur[1] & 0x3f; } if (!IS_CHAR(val)) { xmlErrEncodingInt(ctxt, XML_ERR_INVALID_CHAR, "Char 0x%X out of allowed range\n", val); } return(val); } else { /* 1-byte code */ *len = 1; if (*ctxt->input->cur == 0xD) { if (ctxt->input->cur[1] == 0xA) { ctxt->nbChars++; ctxt->input->cur++; } return(0xA); } return((int) *ctxt->input->cur); } } /* * Assume it's a fixed length encoding (1) with * a compatible encoding for the ASCII set, since * XML constructs only use < 128 chars */ *len = 1; if (*ctxt->input->cur == 0xD) { if (ctxt->input->cur[1] == 0xA) { ctxt->nbChars++; ctxt->input->cur++; } return(0xA); } return((int) *ctxt->input->cur); encoding_error: /* * An encoding problem may arise from a truncated input buffer * splitting a character in the middle. In that case do not raise * an error but return 0 to endicate an end of stream problem */ if (ctxt->input->end - ctxt->input->cur < 4) { *len = 0; return(0); } /* * If we detect an UTF8 error that probably mean that the * input encoding didn't get properly advertised in the * declaration header. Report the error and switch the encoding * to ISO-Latin-1 (if you don't like this policy, just declare the * encoding !) */ { char buffer[150]; snprintf(&buffer[0], 149, "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n", ctxt->input->cur[0], ctxt->input->cur[1], ctxt->input->cur[2], ctxt->input->cur[3]); __xmlErrEncoding(ctxt, XML_ERR_INVALID_CHAR, "Input is not proper UTF-8, indicate encoding !\n%s", BAD_CAST buffer, NULL); } ctxt->charset = XML_CHAR_ENCODING_8859_1; *len = 1; return((int) *ctxt->input->cur); } /** * xmlStringCurrentChar: * @ctxt: the XML parser context * @cur: pointer to the beginning of the char * @len: pointer to the length of the char read * * The current char value, if using UTF-8 this may actually span multiple * bytes in the input buffer. * * Returns the current char value and its length */ int xmlStringCurrentChar(xmlParserCtxtPtr ctxt, const xmlChar * cur, int *len) { if ((len == NULL) || (cur == NULL)) return(0); if ((ctxt == NULL) || (ctxt->charset == XML_CHAR_ENCODING_UTF8)) { /* * We are supposed to handle UTF8, check it's valid * From rfc2044: encoding of the Unicode values on UTF-8: * * UCS-4 range (hex.) UTF-8 octet sequence (binary) * 0000 0000-0000 007F 0xxxxxxx * 0000 0080-0000 07FF 110xxxxx 10xxxxxx * 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx * * Check for the 0x110000 limit too */ unsigned char c; unsigned int val; c = *cur; if (c & 0x80) { if ((cur[1] & 0xc0) != 0x80) goto encoding_error; if ((c & 0xe0) == 0xe0) { if ((cur[2] & 0xc0) != 0x80) goto encoding_error; if ((c & 0xf0) == 0xf0) { if (((c & 0xf8) != 0xf0) || ((cur[3] & 0xc0) != 0x80)) goto encoding_error; /* 4-byte code */ *len = 4; val = (cur[0] & 0x7) << 18; val |= (cur[1] & 0x3f) << 12; val |= (cur[2] & 0x3f) << 6; val |= cur[3] & 0x3f; } else { /* 3-byte code */ *len = 3; val = (cur[0] & 0xf) << 12; val |= (cur[1] & 0x3f) << 6; val |= cur[2] & 0x3f; } } else { /* 2-byte code */ *len = 2; val = (cur[0] & 0x1f) << 6; val |= cur[1] & 0x3f; } if (!IS_CHAR(val)) { xmlErrEncodingInt(ctxt, XML_ERR_INVALID_CHAR, "Char 0x%X out of allowed range\n", val); } return (val); } else { /* 1-byte code */ *len = 1; return ((int) *cur); } } /* * Assume it's a fixed length encoding (1) with * a compatible encoding for the ASCII set, since * XML constructs only use < 128 chars */ *len = 1; return ((int) *cur); encoding_error: /* * An encoding problem may arise from a truncated input buffer * splitting a character in the middle. In that case do not raise * an error but return 0 to endicate an end of stream problem */ if ((ctxt == NULL) || (ctxt->input == NULL) || (ctxt->input->end - ctxt->input->cur < 4)) { *len = 0; return(0); } /* * If we detect an UTF8 error that probably mean that the * input encoding didn't get properly advertised in the * declaration header. Report the error and switch the encoding * to ISO-Latin-1 (if you don't like this policy, just declare the * encoding !) */ { char buffer[150]; snprintf(buffer, 149, "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n", ctxt->input->cur[0], ctxt->input->cur[1], ctxt->input->cur[2], ctxt->input->cur[3]); __xmlErrEncoding(ctxt, XML_ERR_INVALID_CHAR, "Input is not proper UTF-8, indicate encoding !\n%s", BAD_CAST buffer, NULL); } *len = 1; return ((int) *cur); } /** * xmlCopyCharMultiByte: * @out: pointer to an array of xmlChar * @val: the char value * * append the char value in the array * * Returns the number of xmlChar written */ int xmlCopyCharMultiByte(xmlChar *out, int val) { if (out == NULL) return(0); /* * We are supposed to handle UTF8, check it's valid * From rfc2044: encoding of the Unicode values on UTF-8: * * UCS-4 range (hex.) UTF-8 octet sequence (binary) * 0000 0000-0000 007F 0xxxxxxx * 0000 0080-0000 07FF 110xxxxx 10xxxxxx * 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx */ if (val >= 0x80) { xmlChar *savedout = out; int bits; if (val < 0x800) { *out++= (val >> 6) | 0xC0; bits= 0; } else if (val < 0x10000) { *out++= (val >> 12) | 0xE0; bits= 6;} else if (val < 0x110000) { *out++= (val >> 18) | 0xF0; bits= 12; } else { xmlErrEncodingInt(NULL, XML_ERR_INVALID_CHAR, "Internal error, xmlCopyCharMultiByte 0x%X out of bound\n", val); return(0); } for ( ; bits >= 0; bits-= 6) *out++= ((val >> bits) & 0x3F) | 0x80 ; return (out - savedout); } *out = (xmlChar) val; return 1; } /** * xmlCopyChar: * @len: Ignored, compatibility * @out: pointer to an array of xmlChar * @val: the char value * * append the char value in the array * * Returns the number of xmlChar written */ int xmlCopyChar(int len ATTRIBUTE_UNUSED, xmlChar *out, int val) { if (out == NULL) return(0); /* the len parameter is ignored */ if (val >= 0x80) { return(xmlCopyCharMultiByte (out, val)); } *out = (xmlChar) val; return 1; } /************************************************************************ * * * Commodity functions to switch encodings * * * ************************************************************************/ /** * xmlSwitchEncoding: * @ctxt: the parser context * @enc: the encoding value (number) * * change the input functions when discovering the character encoding * of a given entity. * * Returns 0 in case of success, -1 otherwise */ int xmlSwitchEncoding(xmlParserCtxtPtr ctxt, xmlCharEncoding enc) { xmlCharEncodingHandlerPtr handler; if (ctxt == NULL) return(-1); switch (enc) { case XML_CHAR_ENCODING_ERROR: __xmlErrEncoding(ctxt, XML_ERR_UNKNOWN_ENCODING, "encoding unknown\n", NULL, NULL); return(-1); case XML_CHAR_ENCODING_NONE: /* let's assume it's UTF-8 without the XML decl */ ctxt->charset = XML_CHAR_ENCODING_UTF8; return(0); case XML_CHAR_ENCODING_UTF8: /* default encoding, no conversion should be needed */ ctxt->charset = XML_CHAR_ENCODING_UTF8; /* * Errata on XML-1.0 June 20 2001 * Specific handling of the Byte Order Mark for * UTF-8 */ if ((ctxt->input != NULL) && (ctxt->input->cur[0] == 0xEF) && (ctxt->input->cur[1] == 0xBB) && (ctxt->input->cur[2] == 0xBF)) { ctxt->input->cur += 3; } return(0); case XML_CHAR_ENCODING_UTF16LE: case XML_CHAR_ENCODING_UTF16BE: /*The raw input characters are encoded *in UTF-16. As we expect this function *to be called after xmlCharEncInFunc, we expect *ctxt->input->cur to contain UTF-8 encoded characters. *So the raw UTF16 Byte Order Mark *has also been converted into *an UTF-8 BOM. Let's skip that BOM. */ if ((ctxt->input != NULL) && (ctxt->input->cur != NULL) && (ctxt->input->cur[0] == 0xEF) && (ctxt->input->cur[1] == 0xBB) && (ctxt->input->cur[2] == 0xBF)) { ctxt->input->cur += 3; } break ; default: break; } handler = xmlGetCharEncodingHandler(enc); if (handler == NULL) { /* * Default handlers. */ switch (enc) { case XML_CHAR_ENCODING_ASCII: /* default encoding, no conversion should be needed */ ctxt->charset = XML_CHAR_ENCODING_UTF8; return(0); case XML_CHAR_ENCODING_UTF16LE: break; case XML_CHAR_ENCODING_UTF16BE: break; case XML_CHAR_ENCODING_UCS4LE: __xmlErrEncoding(ctxt, XML_ERR_UNSUPPORTED_ENCODING, "encoding not supported %s\n", BAD_CAST "USC4 little endian", NULL); break; case XML_CHAR_ENCODING_UCS4BE: __xmlErrEncoding(ctxt, XML_ERR_UNSUPPORTED_ENCODING, "encoding not supported %s\n", BAD_CAST "USC4 big endian", NULL); break; case XML_CHAR_ENCODING_EBCDIC: __xmlErrEncoding(ctxt, XML_ERR_UNSUPPORTED_ENCODING, "encoding not supported %s\n", BAD_CAST "EBCDIC", NULL); break; case XML_CHAR_ENCODING_UCS4_2143: __xmlErrEncoding(ctxt, XML_ERR_UNSUPPORTED_ENCODING, "encoding not supported %s\n", BAD_CAST "UCS4 2143", NULL); break; case XML_CHAR_ENCODING_UCS4_3412: __xmlErrEncoding(ctxt, XML_ERR_UNSUPPORTED_ENCODING, "encoding not supported %s\n", BAD_CAST "UCS4 3412", NULL); break; case XML_CHAR_ENCODING_UCS2: __xmlErrEncoding(ctxt, XML_ERR_UNSUPPORTED_ENCODING, "encoding not supported %s\n", BAD_CAST "UCS2", NULL); break; case XML_CHAR_ENCODING_8859_1: case XML_CHAR_ENCODING_8859_2: case XML_CHAR_ENCODING_8859_3: case XML_CHAR_ENCODING_8859_4: case XML_CHAR_ENCODING_8859_5: case XML_CHAR_ENCODING_8859_6: case XML_CHAR_ENCODING_8859_7: case XML_CHAR_ENCODING_8859_8: case XML_CHAR_ENCODING_8859_9: /* * We used to keep the internal content in the * document encoding however this turns being unmaintainable * So xmlGetCharEncodingHandler() will return non-null * values for this now. */ if ((ctxt->inputNr == 1) && (ctxt->encoding == NULL) && (ctxt->input != NULL) && (ctxt->input->encoding != NULL)) { ctxt->encoding = xmlStrdup(ctxt->input->encoding); } ctxt->charset = enc; return(0); case XML_CHAR_ENCODING_2022_JP: __xmlErrEncoding(ctxt, XML_ERR_UNSUPPORTED_ENCODING, "encoding not supported %s\n", BAD_CAST "ISO-2022-JP", NULL); break; case XML_CHAR_ENCODING_SHIFT_JIS: __xmlErrEncoding(ctxt, XML_ERR_UNSUPPORTED_ENCODING, "encoding not supported %s\n", BAD_CAST "Shift_JIS", NULL); break; case XML_CHAR_ENCODING_EUC_JP: __xmlErrEncoding(ctxt, XML_ERR_UNSUPPORTED_ENCODING, "encoding not supported %s\n", BAD_CAST "EUC-JP", NULL); break; default: break; } } if (handler == NULL) return(-1); ctxt->charset = XML_CHAR_ENCODING_UTF8; return(xmlSwitchToEncoding(ctxt, handler)); } /** * xmlSwitchInputEncoding: * @ctxt: the parser context * @input: the input stream * @handler: the encoding handler * * change the input functions when discovering the character encoding * of a given entity. * * Returns 0 in case of success, -1 otherwise */ int xmlSwitchInputEncoding(xmlParserCtxtPtr ctxt, xmlParserInputPtr input, xmlCharEncodingHandlerPtr handler) { int nbchars; if (handler == NULL) return (-1); if (input == NULL) return (-1); if (input->buf != NULL) { if (input->buf->encoder != NULL) { /* * Check in case the auto encoding detetection triggered * in already. */ if (input->buf->encoder == handler) return (0); /* * "UTF-16" can be used for both LE and BE if ((!xmlStrncmp(BAD_CAST input->buf->encoder->name, BAD_CAST "UTF-16", 6)) && (!xmlStrncmp(BAD_CAST handler->name, BAD_CAST "UTF-16", 6))) { return(0); } */ /* * Note: this is a bit dangerous, but that's what it * takes to use nearly compatible signature for different * encodings. */ xmlCharEncCloseFunc(input->buf->encoder); input->buf->encoder = handler; return (0); } input->buf->encoder = handler; /* * Is there already some content down the pipe to convert ? */ if ((input->buf->buffer != NULL) && (input->buf->buffer->use > 0)) { int processed; unsigned int use; /* * Specific handling of the Byte Order Mark for * UTF-16 */ if ((handler->name != NULL) && (!strcmp(handler->name, "UTF-16LE") || !strcmp(handler->name, "UTF-16")) && (input->cur[0] == 0xFF) && (input->cur[1] == 0xFE)) { input->cur += 2; } if ((handler->name != NULL) && (!strcmp(handler->name, "UTF-16BE")) && (input->cur[0] == 0xFE) && (input->cur[1] == 0xFF)) { input->cur += 2; } /* * Errata on XML-1.0 June 20 2001 * Specific handling of the Byte Order Mark for * UTF-8 */ if ((handler->name != NULL) && (!strcmp(handler->name, "UTF-8")) && (input->cur[0] == 0xEF) && (input->cur[1] == 0xBB) && (input->cur[2] == 0xBF)) { input->cur += 3; } /* * Shrink the current input buffer. * Move it as the raw buffer and create a new input buffer */ processed = input->cur - input->base; xmlBufferShrink(input->buf->buffer, processed); input->buf->raw = input->buf->buffer; input->buf->buffer = xmlBufferCreate(); input->buf->rawconsumed = processed; use = input->buf->raw->use; if (ctxt->html) { /* * convert as much as possible of the buffer */ nbchars = xmlCharEncInFunc(input->buf->encoder, input->buf->buffer, input->buf->raw); } else { /* * convert just enough to get * '' * parsed with the autodetected encoding * into the parser reading buffer. */ nbchars = xmlCharEncFirstLine(input->buf->encoder, input->buf->buffer, input->buf->raw); } if (nbchars < 0) { xmlErrInternal(ctxt, "switching encoding: encoder error\n", NULL); return (-1); } input->buf->rawconsumed += use - input->buf->raw->use; input->base = input->cur = input->buf->buffer->content; input->end = &input->base[input->buf->buffer->use]; } return (0); } else if (input->length == 0) { /* * When parsing a static memory array one must know the * size to be able to convert the buffer. */ xmlErrInternal(ctxt, "switching encoding : no input\n", NULL); return (-1); } return (0); } /** * xmlSwitchToEncoding: * @ctxt: the parser context * @handler: the encoding handler * * change the input functions when discovering the character encoding * of a given entity. * * Returns 0 in case of success, -1 otherwise */ int xmlSwitchToEncoding(xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr handler) { int ret = 0; if (handler != NULL) { if (ctxt->input != NULL) { ret = xmlSwitchInputEncoding(ctxt, ctxt->input, handler); } else { xmlErrInternal(ctxt, "xmlSwitchToEncoding : no input\n", NULL); return(-1); } /* * The parsing is now done in UTF8 natively */ ctxt->charset = XML_CHAR_ENCODING_UTF8; } else return(-1); return(ret); } /************************************************************************ * * * Commodity functions to handle entities processing * * * ************************************************************************/ /** * xmlFreeInputStream: * @input: an xmlParserInputPtr * * Free up an input stream. */ void xmlFreeInputStream(xmlParserInputPtr input) { if (input == NULL) return; if (input->filename != NULL) xmlFree((char *) input->filename); if (input->directory != NULL) xmlFree((char *) input->directory); if (input->encoding != NULL) xmlFree((char *) input->encoding); if (input->version != NULL) xmlFree((char *) input->version); if ((input->free != NULL) && (input->base != NULL)) input->free((xmlChar *) input->base); if (input->buf != NULL) xmlFreeParserInputBuffer(input->buf); xmlFree(input); } /** * xmlNewInputStream: * @ctxt: an XML parser context * * Create a new input stream structure * Returns the new input stream or NULL */ xmlParserInputPtr xmlNewInputStream(xmlParserCtxtPtr ctxt) { xmlParserInputPtr input; static int id = 0; input = (xmlParserInputPtr) xmlMalloc(sizeof(xmlParserInput)); if (input == NULL) { xmlErrMemory(ctxt, "couldn't allocate a new input stream\n"); return(NULL); } memset(input, 0, sizeof(xmlParserInput)); input->line = 1; input->col = 1; input->standalone = -1; /* * we don't care about thread reentrancy unicity for a single * parser context (and hence thread) is sufficient. */ input->id = id++; return(input); } /** * xmlNewIOInputStream: * @ctxt: an XML parser context * @input: an I/O Input * @enc: the charset encoding if known * * Create a new input stream structure encapsulating the @input into * a stream suitable for the parser. * * Returns the new input stream or NULL */ xmlParserInputPtr xmlNewIOInputStream(xmlParserCtxtPtr ctxt, xmlParserInputBufferPtr input, xmlCharEncoding enc) { xmlParserInputPtr inputStream; if (input == NULL) return(NULL); if (xmlParserDebugEntities) xmlGenericError(xmlGenericErrorContext, "new input from I/O\n"); inputStream = xmlNewInputStream(ctxt); if (inputStream == NULL) { return(NULL); } inputStream->filename = NULL; inputStream->buf = input; inputStream->base = inputStream->buf->buffer->content; inputStream->cur = inputStream->buf->buffer->content; inputStream->end = &inputStream->base[inputStream->buf->buffer->use]; if (enc != XML_CHAR_ENCODING_NONE) { xmlSwitchEncoding(ctxt, enc); } return(inputStream); } /** * xmlNewEntityInputStream: * @ctxt: an XML parser context * @entity: an Entity pointer * * Create a new input stream based on an xmlEntityPtr * * Returns the new input stream or NULL */ xmlParserInputPtr xmlNewEntityInputStream(xmlParserCtxtPtr ctxt, xmlEntityPtr entity) { xmlParserInputPtr input; if (entity == NULL) { xmlErrInternal(ctxt, "xmlNewEntityInputStream entity = NULL\n", NULL); return(NULL); } if (xmlParserDebugEntities) xmlGenericError(xmlGenericErrorContext, "new input from entity: %s\n", entity->name); if (entity->content == NULL) { switch (entity->etype) { case XML_EXTERNAL_GENERAL_UNPARSED_ENTITY: xmlErrInternal(ctxt, "Cannot parse entity %s\n", entity->name); break; case XML_EXTERNAL_GENERAL_PARSED_ENTITY: case XML_EXTERNAL_PARAMETER_ENTITY: return(xmlLoadExternalEntity((char *) entity->URI, (char *) entity->ExternalID, ctxt)); case XML_INTERNAL_GENERAL_ENTITY: xmlErrInternal(ctxt, "Internal entity %s without content !\n", entity->name); break; case XML_INTERNAL_PARAMETER_ENTITY: xmlErrInternal(ctxt, "Internal parameter entity %s without content !\n", entity->name); break; case XML_INTERNAL_PREDEFINED_ENTITY: xmlErrInternal(ctxt, "Predefined entity %s without content !\n", entity->name); break; } return(NULL); } input = xmlNewInputStream(ctxt); if (input == NULL) { return(NULL); } input->filename = (char *) entity->URI; input->base = entity->content; input->cur = entity->content; input->length = entity->length; input->end = &entity->content[input->length]; return(input); } /** * xmlNewStringInputStream: * @ctxt: an XML parser context * @buffer: an memory buffer * * Create a new input stream based on a memory buffer. * Returns the new input stream */ xmlParserInputPtr xmlNewStringInputStream(xmlParserCtxtPtr ctxt, const xmlChar *buffer) { xmlParserInputPtr input; if (buffer == NULL) { xmlErrInternal(ctxt, "xmlNewStringInputStream string = NULL\n", NULL); return(NULL); } if (xmlParserDebugEntities) xmlGenericError(xmlGenericErrorContext, "new fixed input: %.30s\n", buffer); input = xmlNewInputStream(ctxt); if (input == NULL) { xmlErrMemory(ctxt, "couldn't allocate a new input stream\n"); return(NULL); } input->base = buffer; input->cur = buffer; input->length = xmlStrlen(buffer); input->end = &buffer[input->length]; return(input); } /** * xmlNewInputFromFile: * @ctxt: an XML parser context * @filename: the filename to use as entity * * Create a new input stream based on a file or an URL. * * Returns the new input stream or NULL in case of error */ xmlParserInputPtr xmlNewInputFromFile(xmlParserCtxtPtr ctxt, const char *filename) { xmlParserInputBufferPtr buf; xmlParserInputPtr inputStream; char *directory = NULL; xmlChar *URI = NULL; if (xmlParserDebugEntities) xmlGenericError(xmlGenericErrorContext, "new input from file: %s\n", filename); if (ctxt == NULL) return(NULL); buf = xmlParserInputBufferCreateFilename(filename, XML_CHAR_ENCODING_NONE); if (buf == NULL) { if (filename == NULL) __xmlLoaderErr(ctxt, "failed to load external entity: NULL filename \n", NULL); else __xmlLoaderErr(ctxt, "failed to load external entity \"%s\"\n", (const char *) filename); return(NULL); } inputStream = xmlNewInputStream(ctxt); if (inputStream == NULL) return(NULL); inputStream->buf = buf; inputStream = xmlCheckHTTPInput(ctxt, inputStream); if (inputStream == NULL) return(NULL); if (inputStream->filename == NULL) URI = xmlStrdup((xmlChar *) filename); else URI = xmlStrdup((xmlChar *) inputStream->filename); directory = xmlParserGetDirectory((const char *) URI); if (inputStream->filename != NULL) xmlFree((char *)inputStream->filename); inputStream->filename = (char *) xmlCanonicPath((const xmlChar *) URI); if (URI != NULL) xmlFree((char *) URI); inputStream->directory = directory; inputStream->base = inputStream->buf->buffer->content; inputStream->cur = inputStream->buf->buffer->content; inputStream->end = &inputStream->base[inputStream->buf->buffer->use]; if ((ctxt->directory == NULL) && (directory != NULL)) ctxt->directory = (char *) xmlStrdup((const xmlChar *) directory); return(inputStream); } /************************************************************************ * * * Commodity functions to handle parser contexts * * * ************************************************************************/ /** * xmlInitParserCtxt: * @ctxt: an XML parser context * * Initialize a parser context * * Returns 0 in case of success and -1 in case of error */ int xmlInitParserCtxt(xmlParserCtxtPtr ctxt) { xmlParserInputPtr input; if(ctxt==NULL) { xmlErrInternal(NULL, "Got NULL parser context\n", NULL); return(-1); } xmlDefaultSAXHandlerInit(); if (ctxt->dict == NULL) ctxt->dict = xmlDictCreate(); if (ctxt->dict == NULL) { xmlErrMemory(NULL, "cannot initialize parser context\n"); return(-1); } if (ctxt->sax == NULL) ctxt->sax = (xmlSAXHandler *) xmlMalloc(sizeof(xmlSAXHandler)); if (ctxt->sax == NULL) { xmlErrMemory(NULL, "cannot initialize parser context\n"); return(-1); } else xmlSAXVersion(ctxt->sax, 2); ctxt->maxatts = 0; ctxt->atts = NULL; /* Allocate the Input stack */ if (ctxt->inputTab == NULL) { ctxt->inputTab = (xmlParserInputPtr *) xmlMalloc(5 * sizeof(xmlParserInputPtr)); ctxt->inputMax = 5; } if (ctxt->inputTab == NULL) { xmlErrMemory(NULL, "cannot initialize parser context\n"); ctxt->inputNr = 0; ctxt->inputMax = 0; ctxt->input = NULL; return(-1); } while ((input = inputPop(ctxt)) != NULL) { /* Non consuming */ xmlFreeInputStream(input); } ctxt->inputNr = 0; ctxt->input = NULL; ctxt->version = NULL; ctxt->encoding = NULL; ctxt->standalone = -1; ctxt->hasExternalSubset = 0; ctxt->hasPErefs = 0; ctxt->html = 0; ctxt->external = 0; ctxt->instate = XML_PARSER_START; ctxt->token = 0; ctxt->directory = NULL; /* Allocate the Node stack */ if (ctxt->nodeTab == NULL) { ctxt->nodeTab = (xmlNodePtr *) xmlMalloc(10 * sizeof(xmlNodePtr)); ctxt->nodeMax = 10; } if (ctxt->nodeTab == NULL) { xmlErrMemory(NULL, "cannot initialize parser context\n"); ctxt->nodeNr = 0; ctxt->nodeMax = 0; ctxt->node = NULL; ctxt->inputNr = 0; ctxt->inputMax = 0; ctxt->input = NULL; return(-1); } ctxt->nodeNr = 0; ctxt->node = NULL; /* Allocate the Name stack */ if (ctxt->nameTab == NULL) { ctxt->nameTab = (const xmlChar **) xmlMalloc(10 * sizeof(xmlChar *)); ctxt->nameMax = 10; } if (ctxt->nameTab == NULL) { xmlErrMemory(NULL, "cannot initialize parser context\n"); ctxt->nodeNr = 0; ctxt->nodeMax = 0; ctxt->node = NULL; ctxt->inputNr = 0; ctxt->inputMax = 0; ctxt->input = NULL; ctxt->nameNr = 0; ctxt->nameMax = 0; ctxt->name = NULL; return(-1); } ctxt->nameNr = 0; ctxt->name = NULL; /* Allocate the space stack */ if (ctxt->spaceTab == NULL) { ctxt->spaceTab = (int *) xmlMalloc(10 * sizeof(int)); ctxt->spaceMax = 10; } if (ctxt->spaceTab == NULL) { xmlErrMemory(NULL, "cannot initialize parser context\n"); ctxt->nodeNr = 0; ctxt->nodeMax = 0; ctxt->node = NULL; ctxt->inputNr = 0; ctxt->inputMax = 0; ctxt->input = NULL; ctxt->nameNr = 0; ctxt->nameMax = 0; ctxt->name = NULL; ctxt->spaceNr = 0; ctxt->spaceMax = 0; ctxt->space = NULL; return(-1); } ctxt->spaceNr = 1; ctxt->spaceMax = 10; ctxt->spaceTab[0] = -1; ctxt->space = &ctxt->spaceTab[0]; ctxt->userData = ctxt; ctxt->myDoc = NULL; ctxt->wellFormed = 1; ctxt->nsWellFormed = 1; ctxt->valid = 1; ctxt->loadsubset = xmlLoadExtDtdDefaultValue; ctxt->validate = xmlDoValidityCheckingDefaultValue; ctxt->pedantic = xmlPedanticParserDefaultValue; ctxt->linenumbers = xmlLineNumbersDefaultValue; ctxt->keepBlanks = xmlKeepBlanksDefaultValue; if (ctxt->keepBlanks == 0) ctxt->sax->ignorableWhitespace = xmlSAX2IgnorableWhitespace; ctxt->vctxt.finishDtd = XML_CTXT_FINISH_DTD_0; ctxt->vctxt.userData = ctxt; ctxt->vctxt.error = xmlParserValidityError; ctxt->vctxt.warning = xmlParserValidityWarning; if (ctxt->validate) { if (xmlGetWarningsDefaultValue == 0) ctxt->vctxt.warning = NULL; else ctxt->vctxt.warning = xmlParserValidityWarning; ctxt->vctxt.nodeMax = 0; } ctxt->replaceEntities = xmlSubstituteEntitiesDefaultValue; ctxt->record_info = 0; ctxt->nbChars = 0; ctxt->checkIndex = 0; ctxt->inSubset = 0; ctxt->errNo = XML_ERR_OK; ctxt->depth = 0; ctxt->charset = XML_CHAR_ENCODING_UTF8; ctxt->catalogs = NULL; xmlInitNodeInfoSeq(&ctxt->node_seq); return(0); } /** * xmlFreeParserCtxt: * @ctxt: an XML parser context * * Free all the memory used by a parser context. However the parsed * document in ctxt->myDoc is not freed. */ void xmlFreeParserCtxt(xmlParserCtxtPtr ctxt) { xmlParserInputPtr input; if (ctxt == NULL) return; while ((input = inputPop(ctxt)) != NULL) { /* Non consuming */ xmlFreeInputStream(input); } if (ctxt->spaceTab != NULL) xmlFree(ctxt->spaceTab); if (ctxt->nameTab != NULL) xmlFree((xmlChar * *)ctxt->nameTab); if (ctxt->nodeTab != NULL) xmlFree(ctxt->nodeTab); if (ctxt->inputTab != NULL) xmlFree(ctxt->inputTab); if (ctxt->version != NULL) xmlFree((char *) ctxt->version); if (ctxt->encoding != NULL) xmlFree((char *) ctxt->encoding); if (ctxt->extSubURI != NULL) xmlFree((char *) ctxt->extSubURI); if (ctxt->extSubSystem != NULL) xmlFree((char *) ctxt->extSubSystem); #ifdef LIBXML_SAX1_ENABLED if ((ctxt->sax != NULL) && (ctxt->sax != (xmlSAXHandlerPtr) &xmlDefaultSAXHandler)) #else if (ctxt->sax != NULL) #endif /* LIBXML_SAX1_ENABLED */ xmlFree(ctxt->sax); if (ctxt->directory != NULL) xmlFree((char *) ctxt->directory); if (ctxt->vctxt.nodeTab != NULL) xmlFree(ctxt->vctxt.nodeTab); if (ctxt->atts != NULL) xmlFree((xmlChar * *)ctxt->atts); if (ctxt->dict != NULL) xmlDictFree(ctxt->dict); if (ctxt->nsTab != NULL) xmlFree((char *) ctxt->nsTab); if (ctxt->pushTab != NULL) xmlFree(ctxt->pushTab); if (ctxt->attallocs != NULL) xmlFree(ctxt->attallocs); if (ctxt->attsDefault != NULL) xmlHashFree(ctxt->attsDefault, (xmlHashDeallocator) xmlFree); if (ctxt->attsSpecial != NULL) xmlHashFree(ctxt->attsSpecial, NULL); if (ctxt->freeElems != NULL) { xmlNodePtr cur, next; cur = ctxt->freeElems; while (cur != NULL) { next = cur->next; xmlFree(cur); cur = next; } } if (ctxt->freeAttrs != NULL) { xmlAttrPtr cur, next; cur = ctxt->freeAttrs; while (cur != NULL) { next = cur->next; xmlFree(cur); cur = next; } } /* * cleanup the error strings */ if (ctxt->lastError.message != NULL) xmlFree(ctxt->lastError.message); if (ctxt->lastError.file != NULL) xmlFree(ctxt->lastError.file); if (ctxt->lastError.str1 != NULL) xmlFree(ctxt->lastError.str1); if (ctxt->lastError.str2 != NULL) xmlFree(ctxt->lastError.str2); if (ctxt->lastError.str3 != NULL) xmlFree(ctxt->lastError.str3); #ifdef LIBXML_CATALOG_ENABLED if (ctxt->catalogs != NULL) xmlCatalogFreeLocal(ctxt->catalogs); #endif xmlFree(ctxt); } /** * xmlNewParserCtxt: * * Allocate and initialize a new parser context. * * Returns the xmlParserCtxtPtr or NULL */ xmlParserCtxtPtr xmlNewParserCtxt(void) { xmlParserCtxtPtr ctxt; ctxt = (xmlParserCtxtPtr) xmlMalloc(sizeof(xmlParserCtxt)); if (ctxt == NULL) { xmlErrMemory(NULL, "cannot allocate parser context\n"); return(NULL); } memset(ctxt, 0, sizeof(xmlParserCtxt)); if (xmlInitParserCtxt(ctxt) < 0) { xmlFreeParserCtxt(ctxt); return(NULL); } return(ctxt); } /************************************************************************ * * * Handling of node informations * * * ************************************************************************/ /** * xmlClearParserCtxt: * @ctxt: an XML parser context * * Clear (release owned resources) and reinitialize a parser context */ void xmlClearParserCtxt(xmlParserCtxtPtr ctxt) { if (ctxt==NULL) return; xmlClearNodeInfoSeq(&ctxt->node_seq); xmlCtxtReset(ctxt); } /** * xmlParserFindNodeInfo: * @ctx: an XML parser context * @node: an XML node within the tree * * Find the parser node info struct for a given node * * Returns an xmlParserNodeInfo block pointer or NULL */ const xmlParserNodeInfo * xmlParserFindNodeInfo(const xmlParserCtxtPtr ctx, const xmlNodePtr node) { unsigned long pos; if ((ctx == NULL) || (node == NULL)) return (NULL); /* Find position where node should be at */ pos = xmlParserFindNodeInfoIndex(&ctx->node_seq, node); if (pos < ctx->node_seq.length && ctx->node_seq.buffer[pos].node == node) return &ctx->node_seq.buffer[pos]; else return NULL; } /** * xmlInitNodeInfoSeq: * @seq: a node info sequence pointer * * -- Initialize (set to initial state) node info sequence */ void xmlInitNodeInfoSeq(xmlParserNodeInfoSeqPtr seq) { if (seq == NULL) return; seq->length = 0; seq->maximum = 0; seq->buffer = NULL; } /** * xmlClearNodeInfoSeq: * @seq: a node info sequence pointer * * -- Clear (release memory and reinitialize) node * info sequence */ void xmlClearNodeInfoSeq(xmlParserNodeInfoSeqPtr seq) { if (seq == NULL) return; if (seq->buffer != NULL) xmlFree(seq->buffer); xmlInitNodeInfoSeq(seq); } /** * xmlParserFindNodeInfoIndex: * @seq: a node info sequence pointer * @node: an XML node pointer * * * xmlParserFindNodeInfoIndex : Find the index that the info record for * the given node is or should be at in a sorted sequence * * Returns a long indicating the position of the record */ unsigned long xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq, const xmlNodePtr node) { unsigned long upper, lower, middle; int found = 0; if ((seq == NULL) || (node == NULL)) return ((unsigned long) -1); /* Do a binary search for the key */ lower = 1; upper = seq->length; middle = 0; while (lower <= upper && !found) { middle = lower + (upper - lower) / 2; if (node == seq->buffer[middle - 1].node) found = 1; else if (node < seq->buffer[middle - 1].node) upper = middle - 1; else lower = middle + 1; } /* Return position */ if (middle == 0 || seq->buffer[middle - 1].node < node) return middle; else return middle - 1; } /** * xmlParserAddNodeInfo: * @ctxt: an XML parser context * @info: a node info sequence pointer * * Insert node info record into the sorted sequence */ void xmlParserAddNodeInfo(xmlParserCtxtPtr ctxt, const xmlParserNodeInfoPtr info) { unsigned long pos; if ((ctxt == NULL) || (info == NULL)) return; /* Find pos and check to see if node is already in the sequence */ pos = xmlParserFindNodeInfoIndex(&ctxt->node_seq, (xmlNodePtr) info->node); if ((pos < ctxt->node_seq.length) && (ctxt->node_seq.buffer != NULL) && (ctxt->node_seq.buffer[pos].node == info->node)) { ctxt->node_seq.buffer[pos] = *info; } /* Otherwise, we need to add new node to buffer */ else { if (ctxt->node_seq.length + 1 > ctxt->node_seq.maximum) { xmlParserNodeInfo *tmp_buffer; unsigned int byte_size; if (ctxt->node_seq.maximum == 0) ctxt->node_seq.maximum = 2; byte_size = (sizeof(*ctxt->node_seq.buffer) * (2 * ctxt->node_seq.maximum)); if (ctxt->node_seq.buffer == NULL) tmp_buffer = (xmlParserNodeInfo *) xmlMalloc(byte_size); else tmp_buffer = (xmlParserNodeInfo *) xmlRealloc(ctxt->node_seq.buffer, byte_size); if (tmp_buffer == NULL) { xmlErrMemory(ctxt, "failed to allocate buffer\n"); return; } ctxt->node_seq.buffer = tmp_buffer; ctxt->node_seq.maximum *= 2; } /* If position is not at end, move elements out of the way */ if (pos != ctxt->node_seq.length) { unsigned long i; for (i = ctxt->node_seq.length; i > pos; i--) ctxt->node_seq.buffer[i] = ctxt->node_seq.buffer[i - 1]; } /* Copy element and increase length */ ctxt->node_seq.buffer[pos] = *info; ctxt->node_seq.length++; } } /************************************************************************ * * * Defaults settings * * * ************************************************************************/ /** * xmlPedanticParserDefault: * @val: int 0 or 1 * * Set and return the previous value for enabling pedantic warnings. * * Returns the last value for 0 for no substitution, 1 for substitution. */ int xmlPedanticParserDefault(int val) { int old = xmlPedanticParserDefaultValue; xmlPedanticParserDefaultValue = val; return(old); } /** * xmlLineNumbersDefault: * @val: int 0 or 1 * * Set and return the previous value for enabling line numbers in elements * contents. This may break on old application and is turned off by default. * * Returns the last value for 0 for no substitution, 1 for substitution. */ int xmlLineNumbersDefault(int val) { int old = xmlLineNumbersDefaultValue; xmlLineNumbersDefaultValue = val; return(old); } /** * xmlSubstituteEntitiesDefault: * @val: int 0 or 1 * * Set and return the previous value for default entity support. * Initially the parser always keep entity references instead of substituting * entity values in the output. This function has to be used to change the * default parser behavior * SAX::substituteEntities() has to be used for changing that on a file by * file basis. * * Returns the last value for 0 for no substitution, 1 for substitution. */ int xmlSubstituteEntitiesDefault(int val) { int old = xmlSubstituteEntitiesDefaultValue; xmlSubstituteEntitiesDefaultValue = val; return(old); } /** * xmlKeepBlanksDefault: * @val: int 0 or 1 * * Set and return the previous value for default blanks text nodes support. * The 1.x version of the parser used an heuristic to try to detect * ignorable white spaces. As a result the SAX callback was generating * xmlSAX2IgnorableWhitespace() callbacks instead of characters() one, and when * using the DOM output text nodes containing those blanks were not generated. * The 2.x and later version will switch to the XML standard way and * ignorableWhitespace() are only generated when running the parser in * validating mode and when the current element doesn't allow CDATA or * mixed content. * This function is provided as a way to force the standard behavior * on 1.X libs and to switch back to the old mode for compatibility when * running 1.X client code on 2.X . Upgrade of 1.X code should be done * by using xmlIsBlankNode() commodity function to detect the "empty" * nodes generated. * This value also affect autogeneration of indentation when saving code * if blanks sections are kept, indentation is not generated. * * Returns the last value for 0 for no substitution, 1 for substitution. */ int xmlKeepBlanksDefault(int val) { int old = xmlKeepBlanksDefaultValue; xmlKeepBlanksDefaultValue = val; xmlIndentTreeOutput = !val; return(old); } #define bottom_parserInternals #include "elfgcchack.h" xdmf-3.0+git20160803/Utilities/vtklibxml2/HTMLtree.c0000640000175000017500000010644313003006557021743 0ustar alastairalastair/* * HTMLtree.c : implementation of access function for an HTML tree. * * See Copyright for the status of this software. * * daniel@veillard.com */ #define IN_LIBXML #include "libxml.h" #ifdef LIBXML_HTML_ENABLED #include /* for memset() only ! */ #ifdef HAVE_CTYPE_H #include #endif #ifdef HAVE_STDLIB_H #include #endif #include #include #include #include #include #include #include #include #include /************************************************************************ * * * Getting/Setting encoding meta tags * * * ************************************************************************/ /** * htmlGetMetaEncoding: * @doc: the document * * Encoding definition lookup in the Meta tags * * Returns the current encoding as flagged in the HTML source */ const xmlChar * htmlGetMetaEncoding(htmlDocPtr doc) { htmlNodePtr cur; const xmlChar *content; const xmlChar *encoding; if (doc == NULL) return(NULL); cur = doc->children; /* * Search the html */ while (cur != NULL) { if ((cur->type == XML_ELEMENT_NODE) && (cur->name != NULL)) { if (xmlStrEqual(cur->name, BAD_CAST"html")) break; if (xmlStrEqual(cur->name, BAD_CAST"head")) goto found_head; if (xmlStrEqual(cur->name, BAD_CAST"meta")) goto found_meta; } cur = cur->next; } if (cur == NULL) return(NULL); cur = cur->children; /* * Search the head */ while (cur != NULL) { if ((cur->type == XML_ELEMENT_NODE) && (cur->name != NULL)) { if (xmlStrEqual(cur->name, BAD_CAST"head")) break; if (xmlStrEqual(cur->name, BAD_CAST"meta")) goto found_meta; } cur = cur->next; } if (cur == NULL) return(NULL); found_head: cur = cur->children; /* * Search the meta elements */ found_meta: while (cur != NULL) { if ((cur->type == XML_ELEMENT_NODE) && (cur->name != NULL)) { if (xmlStrEqual(cur->name, BAD_CAST"meta")) { xmlAttrPtr attr = cur->properties; int http; const xmlChar *value; content = NULL; http = 0; while (attr != NULL) { if ((attr->children != NULL) && (attr->children->type == XML_TEXT_NODE) && (attr->children->next == NULL)) { value = attr->children->content; if ((!xmlStrcasecmp(attr->name, BAD_CAST"http-equiv")) && (!xmlStrcasecmp(value, BAD_CAST"Content-Type"))) http = 1; else if ((value != NULL) && (!xmlStrcasecmp(attr->name, BAD_CAST"content"))) content = value; if ((http != 0) && (content != NULL)) goto found_content; } attr = attr->next; } } } cur = cur->next; } return(NULL); found_content: encoding = xmlStrstr(content, BAD_CAST"charset="); if (encoding == NULL) encoding = xmlStrstr(content, BAD_CAST"Charset="); if (encoding == NULL) encoding = xmlStrstr(content, BAD_CAST"CHARSET="); if (encoding != NULL) { encoding += 8; } else { encoding = xmlStrstr(content, BAD_CAST"charset ="); if (encoding == NULL) encoding = xmlStrstr(content, BAD_CAST"Charset ="); if (encoding == NULL) encoding = xmlStrstr(content, BAD_CAST"CHARSET ="); if (encoding != NULL) encoding += 9; } if (encoding != NULL) { while ((*encoding == ' ') || (*encoding == '\t')) encoding++; } return(encoding); } /** * htmlSetMetaEncoding: * @doc: the document * @encoding: the encoding string * * Sets the current encoding in the Meta tags * NOTE: this will not change the document content encoding, just * the META flag associated. * * Returns 0 in case of success and -1 in case of error */ int htmlSetMetaEncoding(htmlDocPtr doc, const xmlChar *encoding) { htmlNodePtr cur, meta; const xmlChar *content; char newcontent[100]; if (doc == NULL) return(-1); if (encoding != NULL) { snprintf(newcontent, sizeof(newcontent), "text/html; charset=%s", (char *)encoding); newcontent[sizeof(newcontent) - 1] = 0; } cur = doc->children; /* * Search the html */ while (cur != NULL) { if ((cur->type == XML_ELEMENT_NODE) && (cur->name != NULL)) { if (xmlStrcasecmp(cur->name, BAD_CAST"html") == 0) break; if (xmlStrcasecmp(cur->name, BAD_CAST"head") == 0) goto found_head; if (xmlStrcasecmp(cur->name, BAD_CAST"meta") == 0) goto found_meta; } cur = cur->next; } if (cur == NULL) return(-1); cur = cur->children; /* * Search the head */ while (cur != NULL) { if ((cur->type == XML_ELEMENT_NODE) && (cur->name != NULL)) { if (xmlStrcasecmp(cur->name, BAD_CAST"head") == 0) break; if (xmlStrcasecmp(cur->name, BAD_CAST"meta") == 0) goto found_meta; } cur = cur->next; } if (cur == NULL) return(-1); found_head: if (cur->children == NULL) { if (encoding == NULL) return(0); meta = xmlNewDocNode(doc, NULL, BAD_CAST"meta", NULL); xmlAddChild(cur, meta); xmlNewProp(meta, BAD_CAST"http-equiv", BAD_CAST"Content-Type"); xmlNewProp(meta, BAD_CAST"content", BAD_CAST newcontent); return(0); } cur = cur->children; found_meta: if (encoding != NULL) { /* * Create a new Meta element with the right attributes */ meta = xmlNewDocNode(doc, NULL, BAD_CAST"meta", NULL); xmlAddPrevSibling(cur, meta); xmlNewProp(meta, BAD_CAST"http-equiv", BAD_CAST"Content-Type"); xmlNewProp(meta, BAD_CAST"content", BAD_CAST newcontent); } /* * Search and destroy all the remaining the meta elements carrying * encoding informations */ while (cur != NULL) { if ((cur->type == XML_ELEMENT_NODE) && (cur->name != NULL)) { if (xmlStrcasecmp(cur->name, BAD_CAST"meta") == 0) { xmlAttrPtr attr = cur->properties; int http; const xmlChar *value; content = NULL; http = 0; while (attr != NULL) { if ((attr->children != NULL) && (attr->children->type == XML_TEXT_NODE) && (attr->children->next == NULL)) { value = attr->children->content; if ((!xmlStrcasecmp(attr->name, BAD_CAST"http-equiv")) && (!xmlStrcasecmp(value, BAD_CAST"Content-Type"))) http = 1; else { if ((value != NULL) && (!xmlStrcasecmp(attr->name, BAD_CAST"content"))) content = value; } if ((http != 0) && (content != NULL)) break; } attr = attr->next; } if ((http != 0) && (content != NULL)) { meta = cur; cur = cur->next; xmlUnlinkNode(meta); xmlFreeNode(meta); continue; } } } cur = cur->next; } return(0); } /** * booleanHTMLAttrs: * * These are the HTML attributes which will be output * in minimized form, i.e.
6-#(N_nƒƒqN?`v‹’•–•‘ !(0>' ,I^nx~~ #9L[fnrrp 2CP[bfhe /=IRY^_]/:DLRVWV 7?EJNON 5:>A8992463455!()&!-,//013d) $3750(!'#++,,;Q4CE@8/% (() %EQPH>3( @U[WMA5)  ,AU__XMA4) 1BR\`]UJ>2&  )9HSYZVMC8- +8DLPOKD;1'  )33)$K[ZQE8,!?^faUG:-! *D]jjaUG9,  (9K[gkg]PC6)  1BR]cc^UI=0#  #2AMUYWRJ?5*#.:CIKIE>5," (17;=;71*$  !',//.+&#  !##"#              )9Mf„¥ÄÜàÇŒ4Cu“ ³´´µ·  '4DUfvІpF 'NiƒŽ”—™™ %-5<LX_dfe,:FPW[\[ .8BIOSTS 7>CHJKJ6:=@ABA%&$4567777=$264/( 0.--,,{· 2DGB90&*&$"""g@TUNB6+ %RcaVH;."  FfmgZKGMOMH@7-#  "+4:>@>93,%  #).120,'$   #%%#%!            (6H_x“ªºµ’NQv˜£¨¬¯²  &1?M[fsjO 6^uƒŒ‘•– ").' .J_nx~ (?R`iprr(;JW`ehf+9FQY]_^ .9CLRVWV9@FKNON 8<@C998 %))% 6785554,7:70)!1/110/93+$  $*/120,'$   #%%(%!           HEAP(l} TREEÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿD|  hy @y  $$$20040108210108 @ $$$xSNOD4{ €7 UnnamedNodeArray0scalarsø qÏC           !!!  !"###"  "$$%$#"  #%%&%$"  $%&&%$#! #%%%%$"  "$$%$#"  !"###"   !!!                 !!!  "$$$$#! %''('&$" ()***(&$! *+,,,*(&#  +,-.-+)'$  +-..-,*'$! +,---+)'$! )+,,+*(&#  ')**)(&$! %&'''&$"  "#$$$#!  !!               !"""! $&'''%#! )++,+*'%" -/00/-+(%! 023331.+'# 3566530-)%! 4688752.*&" 5788752/+'" 4677652.*&" 2456530-)%! 023320.+'$  ,.//.-+(%" (*+++)'%" $%&'&%#! !""!!           !"""! %'(((&$" +-...,*'#  134442/+'# 69::9740+'" :=??>;83/)$ >ABCA?;61,&! @CEECA=83-'" @CEEDA=83.(# ?BDDC@<83-(" =@AB@>:61,'! :<>>=:73.*%  5899863/+'# 023331.+($  *,-.-+)'$  %&'''&$"  !!!           $&'''%#! +.//.-*'# 3677641-)$ :=??>;83.)# AEGGEB>93-'! HKMNLHC>71*$ LPRRQMHA;3,&  OSUUSOJD=5.'! PTVVTPKD=6/(! NRTTROJC<5.'! KOQQOLGA:3-&  FJKLJGB=71+% @CEEDA=83-(" 9<>>=:73.)$ 2566530-)%! +-...,*'$  $%&'&%#!        !#$$$"  )+--,+(%! 2577640,(# <@BB@=94/)# FJMMKGB<6/(" PUWWUQKD<4-% X^``^YRJB91)" _dggd_XOF=4+$ bhkkhc[RI?6-% cillid\SI@6.& agjjgaZRH?6-% ]bddb]VNE=4,$ VZ]][VPIA91*# NRTTRNIC<5-'  EHJJIEA<60)# ;>@@?<94/*%  2466530-)$  )+,,,*(%"  "###"        $&(('&#  .13320-)$  :>@@?<72,'! GLNOMIC<5.'  UZ99[VOG>5-% >DGGCc[QG<3*" IPSSOHeZNC8.% QY\\XPm`TG<1( V]aa\TqdWJ>3)! V]aa\}reXK?4*! zY\\zocWJ>3*! sz~~zsj_SG<2)  jpsspjaXMC8/& _dggd_XOF=4+$ RWYYWSMF>6/'! FJLLJGB=60)# :=??>;83.)$ /13320.*&" %&(('&$"       &)+++)&" 3799851,'" B(**(D?81*# 4:==:4NE<3*# FMQQMF=SH<2(  X`dd_WL>SE9.$ gputofYJ]M?3( s|{qcRdTD7+" yƒ‰ˆ‚whWiWH:-# z„ЉƒxiWjYI;.$ u„„~sdyhWH:.$ ktyxsh[rcSE8-# ]eiic‚vi[M@5*! sz~~zsi^RF;0' cillic[RH>4+# SXZZXTMF>6.& DGIJHE@:4.'! 69::974/+&! )+,-,+(%"         '+--,*'#  "#!5/)# /47750)>5-% DKOOLE<1C8-$ [diid\QC4C6+! r|‚‚|rdTCO?2& †’˜˜’†vcO;G8+  –£ª©¢•ƒoYCN=/#  ­´´¬ž‹u^GR@1% ¢¯¶¶® v_hSA2& ª°¯¨š‡r[fRA2& ‘¢¢›Ž}huaN>0% ŠŽˆ|mZkYI:.# jsxwrg~o_PB5*  v~‚‚~vl`SF:/& agjjgbZPF<2)! NSUUSOIB:2+# <@BBA>:5/)# -/111/,)%  !"#""     '" !&()'#)" 8>AB?:2).% RZ^_[TJ=0#/$ ny~zpcSB1:,! ‹˜žŸ˜Œ|hT?E5' ¦´¼¼´¦’|dL6<- »ËÓÓʺ¤‹pV>B1# ÈÙâáØÆ¯”x\BF4& ÌÝæåÛʲ–z^CH6' Æ×ßÞÕì’vZ]G5' ¸ÇÏÎŵŸ‡lRXD4& £°·¶® v_fQ?0$ Š•›š“‡vcnZI9,! ox}|vl^n^N@3' qy^}yqg[OB7," Y^ab_ZRJ@7.% CGJJHE@:3,% 1456530,'"  "$$$#"      "')*)&   ;BFGD?7.## Ychie]RE7)# |ˆŽŠp_L:(, Ÿ®¶¶°¢ybK66& ÀÑÛÛÓ«‘u[B,- Üïùùïܤ…gL32" îÿÿÿÿíѱoR76%ôÿÿÿÿóÖµ“rTM7'ïÿÿÿÿìаoQL7'ßñûúïܤ…gJI5&Æ×ßÞÕì‘vZYC2#©·½½µ¦’{cdO=- ‰”š™’†vbiVE5( irwvqfufWH:-" cjnnkd[QF:0& JNQRPKF>6.& 3799863.)#  "$%%$"      !$%$" 7>BDB=6-#Ybhif_TG9+ Œ“•†weQ>,¨·À¼®›ƒjR<(# ÏáëìåÕ½ ‚eJ2*ñÿÿÿÿõÙ¸•tV;0ÿÿÿÿÿÿìÈ¢~]A4" ÿÿÿÿÿÿôϨ‚aC7$ ÿÿÿÿÿÿðË¥€_A7$ ÿÿÿÿÿþྚxXK5# æùÿÿ÷ãÈ©‰jME1! ÄÕÝÜÓ«uYS>,  ®´´¬ž‹u]\H6' }‡ŒŒ†zkY]L<.![cggbYcWJ=1& OTWXVQJB90' 58:;;840*$  "###"   )/4663-& KTZ\[VMB5( t†‰‡rbO=, Ÿ«²µ³ªš„kS=)ÈÔÚÞÞÔÀ¥†hM5!íùÿÿÿùâÁz[?( ÿÿÿÿÿÿúÕ­‡dF- ÿÿÿÿÿÿÿßµiI/ÿÿÿÿÿÿÿÝ´ŒhH3ÿÿÿÿÿÿ÷Ñ©„bD1þÿÿÿÿûÞ»˜vWD.Úìõõê×¾¡‚dI=) ³ÁÉÈÀ°›ƒjPH4$ Œ˜–ŠyePN<, hquuoeX[L>0$RX\\ZTMD:0& 48:;;950*#  !   06;?A?;3* V\afig`TE5& |~†ŽˆwbL8&ž•—¬·°›€dJ3 ¿«š¨ÉÛÔ»šxY>(æÖÈÕñÿóÔ®‡eG.ÿÿÿÿÿÿÿâ¹kK1ÿÿÿÿÿÿÿä¹kK0ÿÿÿÿÿÿÿÚ±‰fG*ÿÿÿÿÿÿéÅ |\?'åùÿÿøäɪŠkN8#½ÍÕÕÌ»¥ŒqVE0•¢¨§ “‚mWM9' oy~}xn`OL<-  NUXXTVND9.#159974/(!     '(*08??:1&C6-6N`e]O>.QI{Š‚nV@,]@•¯¤ŠmQ8$‡%n¾ÒÁ¡~^B*ËvÉððÕ°‰fH.ÿýøÿÿÿÿÜ´ŒhI/ÿÿÿÿÿÿûÖ®‡dF-ÿÿÿÿÿÿçÄŸ{[?äøÿÿøäɪŠkN5¾Î××ν§rX?'—¤ªª£•„oYC2 r{€€{pbRI8( PW[[VOLA6* 1,&        (683) 5W[QA0!>yoXB.fŸŸˆlP8$pN¬Æ¸šyZ?)Ǭ”¤ÍåàÆ£^B*î÷ûÿÿüåÅ }\@)îÿÿÿÿóØ·•tU; ÖéóôêØ¿¡ƒeJ2 µÄÍÍŵ ‡mT<¤£kVA(nw||wm_P>0 !YTMB=1%   !"          -  +—*$.-& DQK=.)jsfR=* /o”{aH2ŽiJ\±µ£‡jO7"ÁÄÅÌÔÒ¨ŠkO7"ËÛãæáÓ½¡‚eJ3¼ÍÖ×ÐÀªtZB,¡°¸¸±£zbK6 ‚Ž””ŽƒsaN:dmrrmdWI9&!&)7* !                R-ºÿÿ% ¶ÿÿ "#;D?4& IccVE3#aK9Fh…yfP;(”–œ£¢—„lT>*Ÿ­´·´ª™‚jR<(™§°±«ŸwaJ6#†“𛕉ygS?,ny~zpcSB1U]bb^VK>0#'+0" $' #          7§i_æ’ 5  '350'8318GRTNB4% ^dhmqqi\L;+q{‚…„|p`N<+r}„†‚yk[J8(grxytl_P@0!W_deaYNA4&DJNNKE<1% "!!$'+.0   %*+  !&'            #&$ .48<@@<6," CKQTSOH>2&JSXZXRI>2%GOTUSLC9- >DHIGA9/$169:72+# ))*,/244").11.&-/-)    !!   !!!  !!!            $'('$ '-132/*# */343/)"&+./-*$#%&$ 34579;:8))+/48:961!*38:83, !#%'''&$" "%')))(&$!  #&(*+*)'$! #&(*++)'$  !$')*)(%" !$&'&%" !"!         =?@@@> =?ABCB@<:ILPRRPLF>MRW[\ZVNE; #(-158:;;973/* %*059=?@@>;72- %+2780( !)06<@A@=81)!  '-*-..,('!"!    @CDDB.HLNNMID QVYZYUOG=[bgihc[QF: $*06;@DGHHFB>93 &,3:@FKNPOMID=6 &.5=ELQUWVTOIA9 &.7?HPV[]\YSLC: $,6?IRY^``\VMC9  )3=GPLRTTPJK@5 #-7AAHNPPLF>9- #-08?CFEB<5,!$*03541-'  PTSK>) TYYSF3HLMMKGA SX[\YTMD_fklicZOD $*19@GMRUWWTPJD= %-5=FNV\`bb_ZSKB &.7AKU^fknmic[QF %.9DO[foehhskaUI #-8DQ^]gnrqldZWJ )5BPS_jqutog\OF #.;BO[fmpokbWK=$-9EPY`cb]VL@4 ",5>EJLLHA90& &*-/.+'!     2  ghcZK4  dfc[L6  bfe]P<  CGHHEE+ OTWWTNG\bffc]TI> ")19BKT[bfhhe`YPG #+4>IS^hpuxxtmdZO $,7BN[ht†xw„{pcV #,8ESbrq}†Š‰„znk[  +7EUZl{‰’––…wgV '3CK]o—œ›”‰ziW  -, q];DQC2" £™…yfH 4=MA3%—ˆ~q[6'EC;/$ ‰†€vhR/561)  }}xpaL,%(&!  svsk^J-   osrk_L3   HLNMJE<SY\[XRJ@ '/8BLWaksy{{wqh^S  (29B UPMNRW[w`6ukfgmv~›L˜‰‚Зľž]»§œ¦¶àÙ³a0.ܾåòè¹PPcYA' ô×ÅÎìöæ©'<‚_F' ÿãÒÎÕçëÑ…^¦°šu]/#  ™–ˆ{iK.?NH>2' ‡‡ƒ|p]B-32,% z|{tiX?  swwrgWA% HLNNKFG/ #+4?JWcp|†Œ‹ƒyl_ $-8DRbr‚’Œ•š™”ŠŽ}m $/;IZm†™©´º¹²¦•{ $/-  µ¯¨¡˜‹fA\|€~kWD4& š˜”ƒt]/2MSUK?3' …†„ufP1&02/)"  w{zul^J/ ottph[I2 &/9ER`o~Œ˜ ¥¤Ÿ•‰zk (2>L\n‚••¥°µµ®¢’| (4BSf}…ž´ÇÕÜÛÓݘ€ (4DXo}š¶Ñèøÿÿõã˯“ %3EZl‰©ÉèÿÿÿÿÿüàÁ !/AToްÓõÿÿÿÿÿÿìɦ(:Ql‹­ÐòÿÿÿÿÿÿçÅ¡2G`|œ¼Ûôÿÿÿþëа'8Ld}—¯ÀÉËÉ÷£Šp$2BSdqy{ywupeVF  !&*)'#!!!  ,---.-+&BBBCDED@7'`]\^aehg_K'†}…Ž˜¦ž…X´§¢¥°ÁÞíëÓžLèÓËÏàýÿÿÿÿü’-/"ÿÿõûÿÿÿÿÿÿÿéQ‰•…hDÿÿÿÿÿÿÿÿÿÿÿÿYõÿÿï¸)ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ»d+ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿð›U$ÿÿÿÿÿÿÿÿÿÿÿ,ÿÿÿÿÿÿÿ¶t@ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÁ‡S-ÿÿÿÿÿÿÿÿÿÿgÿÿÿÿÿÿÿÑ\8 ÿÿÿÿÿÿÿÿÿ¿ÿÿÿÿÿÿÿĈ\<$ ÿÿÿÿÿ÷ÿõÀNÈÿÿÿÿÿ׬|V;&ùéßÚÛÄër añÿÿÿ༎iL5$ Ξºµ¯‘vA"‹ÂÑãŽoT?-  ª§£ž—{S&Iv‡‚wdQ?0$ ‰ubG!BQMI@5+!  {~~zrfT< $! nrsoh]M8  )2>KYiz‹œ•Ÿ££¦˜‡v !+6CSez•ª»ÈÎÍÆ¸¦Š !,8H[q|˜´ÎãóûúðßÈ®’  +:Kap¯Ðïÿÿÿÿÿÿèɧ )9L]{ÂçÿÿÿÿÿÿÿÿÞ¸ %5J`€£Ëôÿÿÿÿÿÿÿÿé¿ -C]| Èòÿÿÿÿÿÿÿÿä» ";So‘µÛþÿÿÿÿÿÿñͧ.BYu“°ÈÓÎÃÂÉÉ»¡ƒ+;Nbt}lZYitreR    (--'!$%%%%$! 78888861(RPPQRTTQH8tpnptzzd? Ÿ–“–ž«¹Çį„CÓýÂÐçÿÿÿÿëš.ÿõìóÿÿÿÿÿÿÿÿŠ"JVN9ÿÿÿÿÿÿÿÿÿÿÿÿÿ mÌëÞ¹Œ]ÿÿÿÿÿÿÿÿÿÿÿÿÿvÿÿÿÿÿí£4ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿê”4ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ¿d+ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÞˆJÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿë_3ÿÿÿÿÿÿÿÿÿÿÿåÿÿÿÿÿÿÿÿç¤i?" ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿèžiC) ÿÿÿÿÿÿÿÿÿÿ]ñÿÿÿÿÿÿÿËŽbB*ÿþõõüîûõÑ^ÿÿÿÿÿÿЧyV<( ÞÕÏÍÎϺª:¤ÿÿÿýͪ‚aG2# µ²¯¬¨£˜vQN’µºª“x_H6( •–•‘Œƒu^6 Ojsf[M?1& ~~xn_J. '.)" nrrpi`R?(  "+5AO_qƒ–¨£®³³¬ ¥’ #-9GXlƒŠ£ºÎÜãâÙʶž… #.>>>>=;6- ZXWXZ\\ZQ?~yxy~…‹Ž…oI¬¢Ÿ¢«ºËØÙÅ™VãÒÌÑâýÿÿÿÿÿÄPÿÿýÿÿÿÿÿÿÿÿÿÚ4[cW@ÿÿÿÿÿÿÿÿÿÿÿÿÿž­ÿÿýÏšfÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ²ÿÿÿÿÿÿÿÿÿÿÿÿÿÿçÿÿÿÿÿÿÿÿ¢4ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÑi+ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿòMÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ§d5ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿý¯nB" ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿæ©oF*ÿÿÿÿÿÿÿÿÿÿÿQ†ÿÿÿÿÿÿÿÿÛ˜hE,ÿÿÿÿÿÿÿÿÿè{ÿÿÿÿÿÿÿæµ[>) äÜØÙßçÚÓ¶}%†ÿÿÿÿÿ绌gK5$ ¹·µ´´³ “uC4ŒÇàÜÄ¥„fM9) —™™—”ŽƒiN' Fp†ŠvfUD4' ~‚ƒ|tgU<<5-% mqrpkcWF1  #,7CRcu‰­¸¾½¶ª™š… $.;J\q‰“­ÆÚéðïæÖÁ¨ $0>Pf€‘±Òðÿÿÿÿÿÿê˪ #0@Uo„§ÍôÿÿÿÿÿÿÿÿëÄ !.?Wm¸äÿÿÿÿÿÿÿÿÿÿÙ )>>>>=:5+ZXWXZ[[XN;~yxy~„Š‚jA «¢Ÿ¢¬ºÌ×ÖÀ‘HâÑÌÒãÿÿÿÿÿÿµ7ÿÿýÿÿÿÿÿÿÿÿÿ½ ;LF3ÿÿÿÿÿÿÿÿÿÿÿÿÿ]cÎð⼌\ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ°ÿÿÿÿÿ÷¨ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿö›+ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿËb%ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿíŠHÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþ£`1ÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿú¬k? ÿÿÿÿÿÿÿÿÿÿÿÿøÿÿÿÿÿÿÿÿÿå§mD(ÿÿÿÿÿÿÿÿÿÿÿòÿÿÿÿÿÿÿÿÿÚ—fC* ÿÿÿÿÿÿÿÿÿÿÈ<}ÿÿÿÿÿÿÿç´€Z=(ßÙØÜäðééÔ¤X#¸ÿÿÿÿÿ꼌gJ4# ´´µ·¹º¬£Š_$U¥Ùìäȧ„fM8( ”—™™—“‹t]:"V|yhUC4' |ƒ‚~xm\F( *D5-% kprqmeZK7  #,7DSdwŒ  ±¼ÂÁº®œˆ $/;K]sŒ–±ÊßîöõìÛŬ $0?Qhƒ”µ×öÿÿÿÿÿÿðÏ® #0AVq‡«ÒûÿÿÿÿÿÿÿÿñÉ !.@Xp”½êÿÿÿÿÿÿÿÿÿÿÞ );71,&  %&'''&$"  !!!       7.(  QHC=1$pgbYK:* ˆ~q`L9) £œ‘€lWC2% ¦¡•„p\H7) ˜ŽmZH8+ ‹ˆsdTD6)  wundXJ=1& ca\TJ@5-# POKE=5/' ?>?:4.'! +-...,*'$  $%&'&%#!       ! + 2?:- j`a`TC1" –Ž…ygR>-  ¦Ÿ“‚nYE4&  ›€mYF6) ŒƒueTD5( |yqfYK>1& gd_VLA6+# SRMG?6/' A@=85.(! 2466530-)$  )+,,,*(%"  "###"      #.CA3$xnlfYF4% š’‡xeQ>-  ›•ŠzgTA1% މraP@2& zwodWI;/$ fd^UK?4*" SQMF>5,& A@=82.'  :=??>;83.)$ /13320.*&" %&(('&$"    El.5­i  &*  VLOOE6& †~tgVD2$ Žˆ|m[I8* „€vhYH9,! tph^QC6+! a_YPF;1' PNIC;2*# ?>;60,% DGIJHE@:4.'! 69::974/+&! )+,-,+(%"     w­GÿÿÚ¡p C:;9/" og^RC3% zti[K;-! upgZL=0% hd]SG;/% YVPH?5+" IGC=6.&  ;962,(" NSUUSOIB:2+# <@BBA>:5/)# -/111/,)%  !"#""    %>žçia§W 8/*#WOF:-! c\SF9,  a\TI=1& YUNE;0' MJE>6-% A?;5/(! 430,'# Y^ab_ZRJ@7.% CGJJHE@:3,% 1456530,'"  "$$$#"   % =6-"IC;1& LG@7-# HD>7.& @=93,$ 751-'! -,)%# cjnnkd[QF:0& JNQRPKF>6.& 3799863.)#  "$%%$"     $ 1,% 73,% 63.(" 20,'" ,+($ %$#  [cggbYcWJ=1& OTWXVQJB90' 58:;;840*$  "###"      $! '$  &$! "!  hquuoeX[L>0$RX\\ZTMD:0& 48:;;950*#  !          oy~}xn`OL<-  NUXXTVND9.#159974/(!          r{€€{pbRI8( PW[[VOLA6* 1,&     #$  "      nw||wm_P>0 !YTMB=1%   !"     ;DC:+Q`bU@)HWXM:#.8:2# dmrrmdWI9&!&)7* !      *$ „››…dC* ž½Á¨}S1 …ž¡jE'Wgh[C*(12* U]bb^VK>0#'+0" $' #      f`K@<5+! ïÿÿú²sH, ÿÿÿÿÄ}J)ÄëïÍ—a8 yŽ{[9 9CC8'  DJNNKE<1% "!!$'+.0   %*+  !&'!$#!   %# ¼º‹~w`H5'  ÿÿÿÿüš^:$  ÿÿÿÿí‘U1äÿÿã e:€”‘xV5 8@=0 169:72+# ))*,/244").11.&-/-) (-,)$+,(" #,,' '.,&#22,$9D>4*  ÿÿi®­]D2% ÿÿÿÿç[=)  ÿÿÿÿ¬lC+  ¶ËºŽ_<$  Y]R<%    #%&$ 34579;:8))+/48:961!*38:83, ,7;:5. %6=<7/&$:A?80&3FHB9/$>XYPD8," OJûå¡~eQA3' Ì–c‹sZG7+  ºL;:1'  o*   0            =?@@@> =?ABCB@<:6-#                      @BCDB@DGIJJHC>ILPRRPLF>MRW[\ZVNE;RZagigaXMA4[gs|~ynbTF8+j• œ}kYI:,~§Í×Ã¥ˆo[I:,…ÁþÿÓ¥ƒiUD6) EUzˆ}obTG;/$ &11,%                      @CDDB.HLNNMID QVYZYUOG=[bgihc[QF:gpx{ysi\OA4uƒ“…wgWG8ƒš«°¨—ƒn\J;-Š©ÁƸ †o[J:,rލ¯¢xeTD6* !/COPLC:/% (-+%    #$#!  #&((%!#'**($ #')*)%!  $'('%   #%$" !             TYYSF3HLMMKGA SX[\YTMD_fklicZODlv|~{sh[M?y†’‚tdTE6‚“Ÿ¢›|jXH9}ž¢šŒzhWG8+ ]iu{zsh[NA5) 0>DD?7.% $**%  %'(&! %*-/-*#  '-1430*"(.3664.' '.36750*" $+0343/*# &+/0/,'!%(**'$  "##!            bfe]P<  CGHHEE+ OTWWTNG\bffc]TI>hpuvrk`TG9r|ƒ„vj\N? u‰‹†|o`QB4 lx€ƒvj]OB5 PV\ab`ZRH=2 #.8=>:4- %))%#&('# ).11.( .49:83* 29>A@;3)*3:@DDA:0$ )29@DEB<3) &.6 emrrng]QE8foturj`TH; ^ejljd\RG;0 HLPSTSOIA8(%&+17::72!## !(*)$)-/-(  *17::6.!/8?DFC;0! 2GNSSND8)  '22% )3;BGIHC;1&  ,3:>@?;5-$ "*04653.'  "')++)&!  #%!            ‡‡ƒ|p]B-32,% z|{tiX?  swwrgWA% HLNNKFG/QVYYVPH?! W]``]WOE;X^ab_ZRI>& RWZ[ZVOG>4 CFIJKJFA;3 .-/147874/!%''""'++")/452+"(19?CB;0  ,7AIOPK@1 /;FPX[XN@/  0;5-$  !(-1320,&   %%''%"   !!          š˜”ƒt]/2MSUK?3' …†„ufP1&02/)"  w{zul^J/ ottph[I2DHJIGBK7" JNPPMIB=+KPRRPKE=2# HKNNMJD>6 ?ACDDB?;5123567751$(*(" "!!#&*,-,&-4894)"%',6?FIF;*  '2=HRWVL9&)5BNZbc[K7&)6CQ^gkg[J9'  (4BO\gmleWG5" 1>KWahje[M<* ,7CNX^a^VK<- !0:DLRTSMD8,  &08?DGFB;2'  '-379860*"  %'*,,*&!   #%%           ª§£ž—{S&Iv‡‚wdQ?0$ ‰ubG!BQMI@5+!  {~~zrfT< $! nrsoh]M8ejkhbWJ8$_@BA^TH:*@CEDB?G>><9;34566652 %)+( **+,.//. (06::2#"!"#%().%/9CJLD1"%)5AMW[U?$,9GTahdQ/  -:IWeopeN5&+9GVdotpdRA0  (5CQ^jpqj^N;)  0- )4?JRY[YSH;-  +4=EJLKF>4)  ")17;==94,#  "(*.0/-)#  #&##"           µ²¯¬¨£˜vQN’µºª“x_H6( •–•‘Œƒu^6 Ojsf[M?1& ~~xn_J. '.)" nrrpi`R?( bfhe`WJ;(Y^_]YQF9+RVWVRLC9. JNONKF@9A899C@<8 34555876 %))% //011/1!)07:7,++,,-&*&0;DJI<(()$ +7COXZL! ".;IWch]7  $/@?;5-$  $',021/*$  !%(%%#            ¹·µ´´³ “uC4ŒÇàÜÄ¥„fM9) —™™—”ŽƒiN' Fp†ŠvfUD4' ~‚ƒ|tgU<<5-% mqrpkcWF1 `efd_XL>-W[\[WPF:,OSTSOIB8. HJKJHC>7 ?ABA@=:667777654$&%-,,--.0 (/462$=#"""$&*&09BGD2 ·{% +6BNUT@g ".;HVacR "/3' %,39>@>:4+"  $',021.)#  !%#%%#            ´´µ·¹º¬£Š_$U¥Ùìäȧ„fM8( ”—™™—“‹t]:"V|yhUC4' |ƒ‚~xm\F( *D5-% kprqmeZK7 _dfe`YNA0 W[\[WPG;.OSTSOJB9.HJKJHC=7  @ABA?=95 77776543 "  --,,--/%+/0*&M$"""#&)$-6=@<*Fÿ™$)3>HOM8Θ!,8EQZ[K !-:GUaf^?   ,9GUajj]D* )6CP]gkg[K9( #0=IU^cc]RB1 *5?JRWYUMA2#  ",5>EIKIC:.# $*17;=;71( #&+.//,'!   #"##!           ¨¬¯²µ·«¤d-J’ÃÖз™z^G4% Œ‘•–•’‹v`?Nqƒƒn_N>/# x~~xn^I, '>0(! iprrnf[L9# `ehfb[PC2 Y]_^YRI=/ RVWVRLD:/KNONJE?7 C998A>:5 55543642110//,-!&)(!-,,++#'!(0573$ )d3)(( %/8@EC4Q; (3>HPQE%   )5AMW[U@ )4AMX__UA, &2>JU]`\RB1 -8CMVZYSH9)  '1;DKOPLD8+ (19?CDB<3)  !'.37862,$   #(+,+(#  !#!          HEAP(ìù TREEÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÄø  èõ Àõ  $$$20040108210108 Àý $$$xSNOD´÷ ´ UnnamedNodeArray0scalarsð øx               $ 84-& NIB8.$ a]TJ>2' pldXK=0% yvmaTE8+! |yqeXI:3+$ >=:61+&  320-)%            71)  RLC8,! ke[N@2& yoaQA2& ‹†|n]L;." ‹scRA3& ŒˆrcSC5( ‚wl^OA4( sqkaVI<0' ca\UKA6-$ SQMG@70(  CB?=70)# 9862.)# !""!!        .' ME;0$ jbXK=.! ƒ|qcR@0# –„tbN<-! Ÿ™Ž~jWD4' œ˜~lYG7* ‘Ž…wgVF7*  ~wl^PA4( omg^SG;/& \[VOF<2+" JIF@94-% ?>;71,&  %&'''&$"  !!!       7.(  QHC=1$pgbYK:* ˆ~q`L9) £œ‘€lWC2% ¦¡•„p\H7) ˜ŽmZH8+ ‹ˆsdTD6)  wundXJ=1& ca\TJ@5-# POKE=5/' ?>?:4.'! +-...,*'$  $%&'&%#!       ! + 2?:- j`a`TC1" –Ž…ygR>-  ¦Ÿ“‚nYE4&  ›€mYF6) ŒƒueTD5( |yqfYK>1& gd_VLA6+# SRMG?6/' A@=85.(! 2466530-)$  )+,,,*(%"  "###"      #.CA3$xnlfYF4% š’‡xeQ>-  ›•ŠzgTA1% މraP@2& zwodWI;/$ fd^UK?4*" SQMF>5,& A@=82.'  :=??>;83.)$ /13320.*&" %&(('&$"    El.5­i  &*  VLOOE6& †~tgVD2$ Žˆ|m[I8* „€vhYH9,! tph^QC6+! a_YPF;1' PNIC;2*# ?>;60,% DGIJHE@:4.'! 69::974/+&! )+,-,+(%"     w­GÿÿÚ¡p C:;9/" og^RC3% zti[K;-! upgZL=0% hd]SG;/% YVPH?5+" IGC=6.&  ;962,(" NSUUSOIB:2+# <@BBA>:5/)# -/111/,)%  !"#""    %>žçia§W 8/*#WOF:-! c\SF9,  a\TI=1& YUNE;0' MJE>6-% A?;5/(! 430,'# Y^ab_ZRJ@7.% CGJJHE@:3,% 1456530,'"  "$$$#"   % =6-"IC;1& LG@7-# HD>7.& @=93,$ 751-'! -,)%# cjnnkd[QF:0& JNQRPKF>6.& 3799863.)#  "$%%$"     $ 1,% 73,% 63.(" 20,'" ,+($ %$#  [cggbYcWJ=1& OTWXVQJB90' 58:;;840*$  "###"      $! '$  &$! "!  hquuoeX[L>0$RX\\ZTMD:0& 48:;;950*#  !          oy~}xn`OL<-  NUXXTVND9.#159974/(!          r{€€{pbRI8( PW[[VOLA6* 1,&     #$  "      nw||wm_P>0 !YTMB=1%   !"     ;DC:+Q`bU@)HWXM:#.8:2# dmrrmdWI9&!&)7* !      *$ „››…dC* ž½Á¨}S1 …ž¡jE'Wgh[C*(12* U]bb^VK>0#'+0" $' #      f`K@<5+! ïÿÿú²sH, ÿÿÿÿÄ}J)ÄëïÍ—a8 yŽ{[9 9CC8'  DJNNKE<1% "!!$'+.0   %*+  !&'!$#!   %# ¼º‹~w`H5'  ÿÿÿÿüš^:$  ÿÿÿÿí‘U1äÿÿã e:€”‘xV5 8@=0 169:72+# ))*,/244").11.&-/-) (-,)$+,(" #,,' '.,&#22,$9D>4*  ÿÿi®­]D2% ÿÿÿÿç[=)  ÿÿÿÿ¬lC+  ¶ËºŽ_<$  Y]R<%    #%&$ 34579;:8))+/48:961!*38:83, ,7;:5. %6=<7/&$:A?80&3FHB9/$>XYPD8," OJûå¡~eQA3' Ì–c‹sZG7+  ºL;:1'  o*   0            =?@@@> =?ABCB@<:6-#                      @BCDB@DGIJJHC>ILPRRPLF>MRW[\ZVNE;RZagigaXMA4[gs|~ynbTF8+j• œ}kYI:,~§Í×Ã¥ˆo[I:,…ÁþÿÓ¥ƒiUD6) EUzˆ}obTG;/$ &11,%                      @CDDB.HLNNMID QVYZYUOG=[bgihc[QF:gpx{ysi\OA4uƒ“…wgWG8ƒš«°¨—ƒn\J;-Š©ÁƸ †o[J:,rލ¯¢xeTD6* !/COPLC:/% (-+%    #$#!  #&((%!#'**($ #')*)%!  $'('%   #%$" !             TYYSF3HLMMKGA SX[\YTMD_fklicZODlv|~{sh[M?y†’‚tdTE6‚“Ÿ¢›|jXH9}ž¢šŒzhWG8+ ]iu{zsh[NA5) 0>DD?7.% $**%  %'(&! %*-/-*#  '-1430*"(.3664.' '.36750*" $+0343/*# &+/0/,'!%(**'$  "##!            bfe]P<  CGHHEE+ OTWWTNG\bffc]TI>hpuvrk`TG9r|ƒ„vj\N? u‰‹†|o`QB4 lx€ƒvj]OB5 PV\ab`ZRH=2 #.8=>:4- %))%#&('# ).11.( .49:83* 29>A@;3)*3:@DDA:0$ )29@DEB<3) &.6 emrrng]QE8foturj`TH; ^ejljd\RG;0 HLPSTSOIA8(%&+17::72!## !(*)$)-/-(  *17::6.!/8?DFC;0! 2GNSSND8)  '22% )3;BGIHC;1&  ,3:>@?;5-$ "*04653.'  "')++)&!  #%!            ‡‡ƒ|p]B-32,% z|{tiX?  swwrgWA% HLNNKFG/QVYYVPH?! W]``]WOE;X^ab_ZRI>& RWZ[ZVOG>4 CFIJKJFA;3 .-/147874/!%''""'++")/452+"(19?CB;0  ,7AIOPK@1 /;FPX[XN@/  0;5-$  !(-1320,&   %%''%"   !!          š˜”ƒt]/2MSUK?3' …†„ufP1&02/)"  w{zul^J/ ottph[I2DHJIGBK7" JNPPMIB=+KPRRPKE=2# HKNNMJD>6 ?ACDDB?;5123567751$(*(" "!!#&*,-,&-4894)"%',6?FIF;*  '2=HRWVL9&)5BNZbc[K7&)6CQ^gkg[J9'  (4BO\gmleWG5" 1>KWahje[M<* ,7CNX^a^VK<- !0:DLRTSMD8,  &08?DGFB;2'  '-379860*"  %'*,,*&!   #%%           ª§£ž—{S&Iv‡‚wdQ?0$ ‰ubG!BQMI@5+!  {~~zrfT< $! nrsoh]M8ejkhbWJ8$_@BA^TH:*@CEDB?G>><9;34566652 %)+( **+,.//. (06::2#"!"#%().%/9CJLD1"%)5AMW[U?$,9GTahdQ/  -:IWeopeN5&+9GVdotpdRA0  (5CQ^jpqj^N;)  0- )4?JRY[YSH;-  +4=EJLKF>4)  ")17;==94,#  "(*.0/-)#  #&##"           µ²¯¬¨£˜vQN’µºª“x_H6( •–•‘Œƒu^6 Ojsf[M?1& ~~xn_J. '.)" nrrpi`R?( bfhe`WJ;(Y^_]YQF9+RVWVRLC9. JNONKF@9A899C@<8 34555876 %))% //011/1!)07:7,++,,-&*&0;DJI<(()$ +7COXZL! ".;IWch]7  $/@?;5-$  $',021/*$  !%(%%#            ¹·µ´´³ “uC4ŒÇàÜÄ¥„fM9) —™™—”ŽƒiN' Fp†ŠvfUD4' ~‚ƒ|tgU<<5-% mqrpkcWF1 `efd_XL>-W[\[WPF:,OSTSOIB8. HJKJHC>7 ?ABA@=:667777654$&%-,,--.0 (/462$=#"""$&*&09BGD2 ·{% +6BNUT@g ".;HVacR "/3' %,39>@>:4+"  $',021.)#  !%#%%#            ´´µ·¹º¬£Š_$U¥Ùìäȧ„fM8( ”—™™—“‹t]:"V|yhUC4' |ƒ‚~xm\F( *D5-% kprqmeZK7 _dfe`YNA0 W[\[WPG;.OSTSOJB9.HJKJHC=7  @ABA?=95 77776543 "  --,,--/%+/0*&M$"""#&)$-6=@<*Fÿ™$)3>HOM8Θ!,8EQZ[K !-:GUaf^?   ,9GUajj]D* )6CP]gkg[K9( #0=IU^cc]RB1 *5?JRWYUMA2#  ",5>EIKIC:.# $*17;=;71( #&+.//,'!   #"##!           ¨¬¯²µ·«¤d-J’ÃÖз™z^G4% Œ‘•–•’‹v`?Nqƒƒn_N>/# x~~xn^I, '>0(! iprrnf[L9# `ehfb[PC2 Y]_^YRI=/ RVWVRLD:/KNONJE?7 C998A>:5 55543642110//,-!&)(!-,,++#'!(0573$ )d3)(( %/8@EC4Q; (3>HPQE%   )5AMW[U@ )4AMX__UA, &2>JU]`\RB1 -8CMVZYSH9)  '1;DKOPLD8+ (19?CDB<3)  !'.37862,$   #(+,+(#  !#!           $$$20040108210108 ¼ $$$xtˆœ®ºÁ¼±  ŒwdSD7,# ‡¬ÅÛìõöîßʱ–Œs]K;/$ ®Ïðÿÿÿÿÿÿö×µ”ƒhQ?0$ ¢ÉñÿÿÿÿÿÿÿÿûÒ«‡qVA0# ²Þÿÿÿÿÿÿÿÿÿÿê½”pX@.! ¹êÿÿÿÿÿÿÿÿÿÿ÷ÆštT<) µæÿÿÿÿÿÿÿÿÿÿöÄ—qR4! ¢ÏüÿÿúÆÄûÿÿÿ᳉fI2 €¤ÄÍš™ÙÕ·’oR:'Rhxn w‰{cL7&"%%64," ÇÿÿÎ 4ÿÿ@"$%%%!,367888+@LQRRPPQ'Tp|}ytpnpj ¼Ã¹«Ÿ–“–nÔÿÿÿÿëÓýÂ7ûÿÿÿÿÿÿÿõìód‚‘€8Çÿÿÿÿÿÿÿÿÿÿÿ†Åÿÿÿÿyÿÿÿÿÿÿÿÿÿÿÿÿ€ÏÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿN®ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ;wÏÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ )Sáÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ7`›ßÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ"=c—âÿÿÿÿÿÿÿÿÿzÿÿÿÿÿÿÿÿÿÿÿ %=]ŠÈÿÿÿÿÿÿÿÿ¶Úÿÿÿÿÿÿÿÿÿÿ $7Rv¦ÒÿÿÿÿÿÿÿODÇÿÿÿÿÿÿþõõ /D_­Õÿÿÿÿÿš`§ÔçæëÞÕÏÍ %4G^z™·ÐÖÃ’J-d¤«·µ²¯¬ #/>N_nƒƒqN?`v‹’•–•‘ !(0>' ,I^nx~~ #9L[fnrrpq…š™ª¶½¾¸­‰ucRC7,# „¨ÁÖæïðéÚÆ­“‰q\J;.$ ŠªËêÿÿÿÿÿÿðÒ±‘€fP>0$ žÄëÿÿÿÿÿÿÿÿôͧ„oU@0# ­Ùÿÿÿÿÿÿÿÿÿÿä¸mW?.! ´ãÿÿÿÿÿÿÿÿÿÿñÁ–qR<) °ßÿÿÿÿÿÿÿÿÿÿモnP4" ÉõÿÿÿçæÿÿÿÿÚ­…cG0 |Ÿ¿Í«<3®ÙбlO8%Nduq3/|†v`I5$  #'42*   `ÿÿd‚‡$'))**+5:=>>>>;NX[[ZXWX Aj‚Š„~yxyH‘ÀÖ×̺¬¢Ÿ¢7µÿÿÿÿÿÿãÒÌÑ3FL; ½ÿÿÿÿÿÿÿÿÿýÿ\Œ¼âðÎc]ÿÿÿÿÿÿÿÿÿÿÿÿ¨÷ÿÿÿÿÿ°ÿÿÿÿÿÿÿÿÿÿÿÿÿ+›öÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ%bËÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿHŠíÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ1`£þÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ?k¬úÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿ(Dm§åÿÿÿÿÿÿÿÿÿøÿÿÿÿÿÿÿÿÿÿÿ *Cf—Úÿÿÿÿÿÿÿÿÿòÿÿÿÿÿÿÿÿÿÿ(=Z€´çÿÿÿÿÿÿÿ}<Èÿÿÿÿÿÿÿÿÿ #4JgŒ¼êÿÿÿÿÿ¸#X¤ÔééðäÜØÙ (8Mf„§ÈäìÙ¥U$_Š£¬º¹·µ´ '4CUhy|V":]t‹“—™™— %-5D* (F\mx~‚ƒ 7KZemqrpl’¥ ¬³³®£¨–ƒq_OA5+" ~…ž¶ÊÙâãÜκ£ŠƒlXG9-# ‚ ¿ÜöÿÿÿÿûâÆ§ˆzaM<.# •¸ÝÿÿÿÿÿÿÿÿæÁ|iQ=." £ËöÿÿÿÿÿÿÿÿÿÖ­ˆgR=, ©ÕÿÿÿÿÿÿÿÿÿÿáµjM9( ¤Ðÿÿÿÿÿÿÿÿÿÿß²ŠgJ2  ’»åÿÿÿÿÿÿÿÿõË¡|\B% s“³ÉÅžkjžÍÖĤƒdJ4"H]ov`e‚nXC1! ! ,1-%  %'  %()**) -6;=>>>>?QZ\\ZXWXIo…Ž‹…~yxyV™ÅÙØËº«¢Ÿ¢PÄÿÿÿÿÿýâÑÌÒ@Wc[4ÚÿÿÿÿÿÿÿÿÿýÿfšÏýÿÿ­žÿÿÿÿÿÿÿÿÿÿÿÿ²ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ4¢ÿÿÿÿÿÿÿÿçÿÿÿÿÿÿÿÿÿÿÿÿÿ+iÑÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿMòÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ5d§ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ "Bn¯ýÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ*Fo©æÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ,Eh˜Ûÿÿÿÿÿÿÿÿ†Qÿÿÿÿÿÿÿÿÿÿ )>[µæÿÿÿÿÿÿÿ{èÿÿÿÿÿÿÿÿ  $5KgŒ»çÿÿÿÿÿ†%}¶ÓÚçßÙØÜ  )9Mf„¥ÄÜàÇŒ4Cu“ ³´´µ·  '4DUfvІpF 'NiƒŽ”—™™ %-5<2)  tЦ¸ÆÍÎÈ»ª•zeSC6+! v’®Èßðúûóãδ˜|q[H8,! ‡§ÉèÿÿÿÿÿÿïЯpaK:+  ”¸ÞÿÿÿÿÿÿÿÿçÂ{]L9) ™¿éÿÿÿÿÿÿÿÿôË£€`J5% “»äÿÿÿÿÿÿÿÿòÈ |]C- ƒ§ÍñÿÿÿÿÿÿþÛµ‘oS;" fƒ¡»ÉÉÂÃÎÓȰ“uYB.?RertiYZl}tbN;+!'--(     !$%%%%(16888888HQTTRQPP ?dzztpnpC„¯Äǹ«ž–“–.šëÿÿÿÿçнÃ9NVJ"Šÿÿÿÿÿÿÿÿóìõ]Œ¹ÞëÌm ÿÿÿÿÿÿÿÿÿÿÿÿ4£íÿÿÿÿÿvÿÿÿÿÿÿÿÿÿÿÿÿ4”êÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ+d¿ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿJˆÞÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ3_ëÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ "?i¤çÿÿÿÿÿÿÿÿåÿÿÿÿÿÿÿÿÿÿ )Cižèÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ*BbŽËÿÿÿÿÿÿÿñ]ÿÿÿÿÿÿÿÿÿ  (2( v€˜°ÄÓÛÜÕÇ´ž…}fSB4( v“¯ËãõÿÿøèѶš}oXD4(  ÁàüÿÿÿÿÿèÉ©‰lZE3% …¦ÉìÿÿÿÿÿÿõÓ°ŽoTA/!€¡ÅçÿÿÿÿÿÿòЭ‹lQ:(q°ÐëþÿÿÿôÛ¼œ|`G2WpŠ£·ÃÉËÉÀ¯—}dL8'5FVepuwy{yqdSB2$!!!#')*&!    &+-.---'7@DEDCBB'K_ghea^\]X…ž¦˜Ž…}LžÓëíÞÁ°¥¢§"/-’üÿÿÿÿýàÏËÓDh…•‰Qéÿÿÿÿÿÿÿûõÿ)¸ïÿÿõYÿÿÿÿÿÿÿÿÿÿÿ+d»ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ$U›ðÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ@t¶ÿÿÿÿÿÿÿ,ÿÿÿÿÿÿÿÿÿÿ-S‡Áÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 8\Ñÿÿÿÿÿÿÿgÿÿÿÿÿÿÿÿÿ $<\ˆÄÿÿÿÿÿÿÿ¿ÿÿÿÿÿÿÿÿ&;V|¬×ÿÿÿÿÿÈNÀõÿ÷ÿÿÿÿ  $5Li޼àÿÿÿña r«ÃÄÛÚßé  -?ToŽ£ÃÑ‹"Av‘¯µº¾Å $0?Qdw‚‡vI&S{—ž£§  !+5@IMQB!Gbu‰  !$ Up޶¹—?aˆª³ºÁÊ &4DWk~€|\Af‹˜¡¨¯ '3?KUSM2/]tƒ”˜  ")/20&1Pfu„†  /J^luz{2I[hpttHS^hqw{{yskaWLB8/' P]kxƒŒ‘‘ކ|pbUH<2(  Whyz‡’—˜“Š}~n]N@4)  \eyŒœ¨®¯ªŸ~jdRB4) Xn„˜ª¸ÀÁ»®‰t^TB3' Zp‡ž±ÀÈÉö¤ŽwaK?/" Uk‚˜¬»ÄÅ¿²ŸŠs]H9( J^s‡™§¯±«Ÿ{gR?. 8HYjx„ŠŒˆrbQ@1# +6AKSWYWQI?4)   !&'&%$$ B9>=:8786`w[WRNMPL›~vmgfk]ž¾Ä—Š‚‰.0a³Ùඦœ§ 'AYcPP¹èòå¾ 'F_‚<'©æöìÎÅ× !<]uš°¦^…ÑëçÕÎÒã.Jk€¦½´kT­ÒÖÒÏÔå!6Po~¢·«d"ƒ±½ÅÇÎÞ %8Oj‰‘¡’NZ¡³ºÂÏ  %5I_vx‚p29m‘Ÿ©²¼  #/>O`Z_M"SzŒ— ¨ '2>HN?.Ki{ˆ– %,23-B]p|ƒ‡  ?Xit{|  %AWgrww/GFKNNL>GPY`ehhfb[TKB91)" DOZdmtxxuph^SI>4+# IVcp{„wx†th[NB7,$ L[knz„‰Š†}qrbSE8,# LVgw…––’‰{lZUE7+  EWiz‰”›œ—o]KC3' BSeu„–—’‰{kYH<-  8HXgu…†‚ym^O?0# )6CP[chjf`VJ=0$ '08=ABA<6.&   '3W/:f8pŠ +p‘!/'f!2B90R„ ,>NC;9r "2CQD;]q%3AM=4 Hfy…™  $/;CE'6[q~ˆ   )165/Rhv€†  !&(%,Lapx}   -J^ksv   3L_krs 5,"  !'+./-*&         2   4KZch  6L[cf  IT]cffb-39>BFHHGD@;60*$ /6=DIMOPNKF@:3,& 19AIOTVWUQLE=5.& 1:CLSY\][VPH?7.& /9CMV\``^YRI?6,$ *5@KJPTTRLPG=3)  "-9>FLPPNHAA7-# !,5KST 3FSYY  AGKMMLDMTY\[XDOZcilkf%*/379;;:851-(# '-27;>@@?=950*% (.4:?BDECA<72+% '.5;AEGHFC?92,% %,4;AEHIGD?81*#  (08>CFGEB<6.' !)18=@A@<60)! '(,..-*-'    !"!     .BDDC DIMNNL=GOUYZYV:FQ[chigb#'*-/00/.+(%!  $),023431.+'"  %*.2466530,(# $).2577641,(" "(-1577640+&! $).24431-(# #(,./.+(#   #&'&#        @BDCB>CHJJIG>FLPRRPL;ENVZ\[WR"$&'''%#! !$&()))'%" !$')*+*(&#   $')++*(&# "%()*)'$! "%&'&$!   !"!          >@@@?<@BCBA?4;ADFEB?</8@FIIFA;7   !!   !!!   !!!            $'('$  #*/231-")/343/$*-/.+ $&%#8:;9754169:84/+),38:83*!             $&#  ",6<@@<84&2>HOSTQK%2>IRXZXS -9CLSUTO$/9AGIHD #+27:96442/,*).11.)")-/-&            i§7 ’æ_ 5'053' %4BNTRG813+;L\iqqmhd+Tl„—¢£œ–”(KV^bb]"0+'#'$ #         -  &-.$*—+.=KQD  *=Rfsj)2Ha{”o"7Oj‡£µ±\Ji"7OkЍÂÒÔÌÅÄ3Je‚¡½ÓáæãÛ,BZtªÀÐ×ÖÍ 6Kbz£±¸¸°:NasƒŽ””Ž&9IWdmrrm*7)&! !          )386(!0AQ[W5.BXoy>$8PlˆŸŸf)?Zyš¸Æ¬N*B^£Æàåͤ”¬)@\} Ååüÿÿû÷ ;Ut•·Øóÿÿÿÿ 2Jeƒ¡¿ØêôóéP_mw||w %1=BMTY "!     &1:??80*(.>O]e`N6-6,@Vn‚Š{I$8QmФ¯•@*B^~¡ÁÒ¾n%.Hf‰°ÕððÉv/IhŒ´Üÿÿÿÿøý-Fd‡®Öûÿÿÿÿÿ?[{ŸÄçÿÿÿÿÿ5NkŠªÉäøÿÿø'?Xr§½Î××Î 2CYo„•£ªª¤ (8IRbp{€€{ *6ALOV[[W&,1   *3;?A?;6 &5ET`gifa\&8LbwˆŽ†~ 3Jd€›°·¬—•(>Yxš»ÔÛɨš«.Ge‡®ÔóÿñÕÈÖ1Kk¹âÿÿÿÿÿÿ0Kk¹äÿÿÿÿÿÿ*Gf‰±Úÿÿÿÿÿÿ'?\| Åéÿÿÿÿÿ#8NkŠªÉäøÿÿù0EVqŒ¥»ÌÕÕÍ '9MWm‚“ §¨¢  -L[Xeouuq &0:DMTZ\\X #*059;;:8  !      "$%$!#-6=BDB> +9GT_fihb,>Qew†•“Œ #(SYu«ÂÓÜÝÕ '6H\]u‹ž¬´´®!.FKPRQN #).368997  "$%%$"    "' ")#')(& %.)2:?BA> $/#0=JT[_^Z !,:1BScpz~y '5E?Th|Œ˜Ÿž˜ -<6Ld|’¦´¼¼´ #1B>Vp‹¤ºÊÓÓË &4FB\x”¯ÆØáâÙ '6HC^z–²ÊÛåæÝ '5G]Zv’¬ÃÕÞß× &4DXRl‡ŸµÅÎÏÇ $0?Qf_v ®¶·° !,9IZncv‡“𛕠'3@N^n^lv|}x ",7BO[gqy}^y %.7@JRZ_ba^ %,3:@EHJJG "',035654 "#$$$"       #'*,--+ #)/5!#"  %-5>)05774 $-8C1Nauh}Ž›¢¢ #.:IYkZm|ˆŽŠ  *5BP_o~grwxs &/:FS`lv~‚‚~ !)2ABB@  %),/111/  ""#"!      "&)+++) "',158997 #*18?D(**( #*3LW_dd` (3?M]JYfotup "+7DTdRcq{| #-:HWiWhw‚ˆ‰ƒ $.;IYjWixƒ‰Š„ $.:HWhyds~„„ #-8EScr[hsxyt !*5@M[iv‚ciie '0;FR^isz~~z #+4>HR[cilli &.6>FMTXZZX !'.4:@EHJIG !&+/479::9 "%(+,-,+         #&'((&  $)-02331 !',27  '.5GOV[99Z "*3JWdqT\aa] !*4?KXer}\aa] !*3>JWcoz\\Y  )2FMSWYYW #)06=BGJLLJ $).38;>??= "&*.02331 "$&'((&        "$$$# !%(+,--+ #(,046775 #)/49=@BB@ "(/6  $)-035664 "%(*,,,+  "###"         !#%'''& #'*-.//. $)-146776 #).38;>??= !'-39>BEGGE $*17>CHLNMK  &,3;AHMQRRP !'.5=DJOSUUS !(/6=DKPTVVT !'.5>< !%)-035665  $'*,...- !#%&'&%         !"""! "$&((('  #'*,...- #'+/24443 "'+0479::9 $)/38;>??= !&,16;?ACBA "'-38=ACEEC #(.38=ADEEC "(-38<@CDDB !',16:>@BA@  %*.37:=>>< #'+/368998  $(+.13332  $')+-.-, "$&'''&  !!!           !"""! !#%'''& "%'*+,++ !%(+-/00/ #'+.13332 !%)-035665 "&*.257886 "'+/257887 "&*.256776 !%)-035654  $'+.02332 "%(+-.//. "%')+++* !#%&'&% !!""!             !!!  !#$$$$ "$&'('' !$&(***)  #&(*,,,+  $')+-.-, !$'*,-..- !$')+---,  #&(*+,,+ !$&()**)  "$&'''& !#$$$#  !!                !!!   "###"  "#$%$$  "$%&%% !#$%&&%  "$%%%%  "#$%$$  "###"  !!!       HEAP(lv TREEÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿDu  hr @r  $$$20040108210108 @z $$$xSNOD4t €0 UnnamedNodeArray0scalarsð øx               $ 84-& NIB8.$ a]TJ>2' pldXK=0% yvmaTE8+! |yqeXI:3+$ >=:61+&  320-)%            71)  RLC8,! ke[N@2& yoaQA2& ‹†|n]L;." ‹scRA3& ŒˆrcSC5( ‚wl^OA4( sqkaVI<0' ca\UKA6-$ SQMG@70(  CB?=70)# 9862.)# !""!!        .' ME;0$ jbXK=.! ƒ|qcR@0# –„tbN<-! Ÿ™Ž~jWD4' œ˜~lYG7* ‘Ž…wgVF7*  ~wl^PA4( omg^SG;/& \[VOF<2+" JIF@94-% ?>;71,&  %&'''&$"  !!!       7.(  QHC=1$pgbYK:* ˆ~q`L9) £œ‘€lWC2% ¦¡•„p\H7) ˜ŽmZH8+ ‹ˆsdTD6)  wundXJ=1& ca\TJ@5-# POKE=5/' ?>?:4.'! +-...,*'$  $%&'&%#!       ! + 2?:- j`a`TC1" –Ž…ygR>-  ¦Ÿ“‚nYE4&  ›€mYF6) ŒƒueTD5( |yqfYK>1& gd_VLA6+# SRMG?6/' A@=85.(! 2466530-)$  )+,,,*(%"  "###"      #.CA3$xnlfYF4% š’‡xeQ>-  ›•ŠzgTA1% މraP@2& zwodWI;/$ fd^UK?4*" SQMF>5,& A@=82.'  :=??>;83.)$ /13320.*&" %&(('&$"    El.5­i  &*  VLOOE6& †~tgVD2$ Žˆ|m[I8* „€vhYH9,! tph^QC6+! a_YPF;1' PNIC;2*# ?>;60,% DGIJHE@:4.'! 69::974/+&! )+,-,+(%"     w­GÿÿÚ¡p C:;9/" og^RC3% zti[K;-! upgZL=0% hd]SG;/% YVPH?5+" IGC=6.&  ;962,(" NSUUSOIB:2+# <@BBA>:5/)# -/111/,)%  !"#""    %>žçia§W 8/*#WOF:-! c\SF9,  a\TI=1& YUNE;0' MJE>6-% A?;5/(! 430,'# Y^ab_ZRJ@7.% CGJJHE@:3,% 1456530,'"  "$$$#"   % =6-"IC;1& LG@7-# HD>7.& @=93,$ 751-'! -,)%# cjnnkd[QF:0& JNQRPKF>6.& 3799863.)#  "$%%$"     $ 1,% 73,% 63.(" 20,'" ,+($ %$#  [cggbYcWJ=1& OTWXVQJB90' 58:;;840*$  "###"      $! '$  &$! "!  hquuoeX[L>0$RX\\ZTMD:0& 48:;;950*#  !          oy~}xn`OL<-  NUXXTVND9.#159974/(!          r{€€{pbRI8( PW[[VOLA6* 1,&     #$  "      nw||wm_P>0 !YTMB=1%   !"     ;DC:+Q`bU@)HWXM:#.8:2# dmrrmdWI9&!&)7* !      *$ „››…dC* ž½Á¨}S1 …ž¡jE'Wgh[C*(12* U]bb^VK>0#'+0" $' #      f`K@<5+! ïÿÿú²sH, ÿÿÿÿÄ}J)ÄëïÍ—a8 yŽ{[9 9CC8'  DJNNKE<1% "!!$'+.0   %*+  !&'!$#!   %# ¼º‹~w`H5'  ÿÿÿÿüš^:$  ÿÿÿÿí‘U1äÿÿã e:€”‘xV5 8@=0 169:72+# ))*,/244").11.&-/-) (-,)$+,(" #,,' '.,&#22,$9D>4*  ÿÿi®­]D2% ÿÿÿÿç[=)  ÿÿÿÿ¬lC+  ¶ËºŽ_<$  Y]R<%    #%&$ 34579;:8))+/48:961!*38:83, ,7;:5. %6=<7/&$:A?80&3FHB9/$>XYPD8," OJûå¡~eQA3' Ì–c‹sZG7+  ºL;:1'  o*   0            =?@@@> =?ABCB@<:6-#                      @BCDB@DGIJJHC>ILPRRPLF>MRW[\ZVNE;RZagigaXMA4[gs|~ynbTF8+j• œ}kYI:,~§Í×Ã¥ˆo[I:,…ÁþÿÓ¥ƒiUD6) EUzˆ}obTG;/$ &11,%                      @CDDB.HLNNMID QVYZYUOG=[bgihc[QF:gpx{ysi\OA4uƒ“…wgWG8ƒš«°¨—ƒn\J;-Š©ÁƸ †o[J:,rލ¯¢xeTD6* !/COPLC:/% (-+%    #$#!  #&((%!#'**($ #')*)%!  $'('%   #%$" !             TYYSF3HLMMKGA SX[\YTMD_fklicZODlv|~{sh[M?y†’‚tdTE6‚“Ÿ¢›|jXH9}ž¢šŒzhWG8+ ]iu{zsh[NA5) 0>DD?7.% $**%  %'(&! %*-/-*#  '-1430*"(.3664.' '.36750*" $+0343/*# &+/0/,'!%(**'$  "##!            bfe]P<  CGHHEE+ OTWWTNG\bffc]TI>hpuvrk`TG9r|ƒ„vj\N? u‰‹†|o`QB4 lx€ƒvj]OB5 PV\ab`ZRH=2 #.8=>:4- %))%#&('# ).11.( .49:83* 29>A@;3)*3:@DDA:0$ )29@DEB<3) &.6 emrrng]QE8foturj`TH; ^ejljd\RG;0 HLPSTSOIA8(%&+17::72!## !(*)$)-/-(  *17::6.!/8?DFC;0! 2GNSSND8)  '22% )3;BGIHC;1&  ,3:>@?;5-$ "*04653.'  "')++)&!  #%!            ‡‡ƒ|p]B-32,% z|{tiX?  swwrgWA% HLNNKFG/QVYYVPH?! W]``]WOE;X^ab_ZRI>& RWZ[ZVOG>4 CFIJKJFA;3 .-/147874/!%''""'++")/452+"(19?CB;0  ,7AIOPK@1 /;FPX[XN@/  0;5-$  !(-1320,&   %%''%"   !!          š˜”ƒt]/2MSUK?3' …†„ufP1&02/)"  w{zul^J/ ottph[I2DHJIGBK7" JNPPMIB=+KPRRPKE=2# HKNNMJD>6 ?ACDDB?;5123567751$(*(" "!!#&*,-,&-4894)"%',6?FIF;*  '2=HRWVL9&)5BNZbc[K7&)6CQ^gkg[J9'  (4BO\gmleWG5" 1>KWahje[M<* ,7CNX^a^VK<- !0:DLRTSMD8,  &08?DGFB;2'  '-379860*"  %'*,,*&!   #%%           ª§£ž—{S&Iv‡‚wdQ?0$ ‰ubG!BQMI@5+!  {~~zrfT< $! nrsoh]M8ejkhbWJ8$_@BA^TH:*@CEDB?G>><9;34566652 %)+( **+,.//. (06::2#"!"#%().%/9CJLD1"%)5AMW[U?$,9GTahdQ/  -:IWeopeN5&+9GVdotpdRA0  (5CQ^jpqj^N;)  0- )4?JRY[YSH;-  +4=EJLKF>4)  ")17;==94,#  "(*.0/-)#  #&##"           µ²¯¬¨£˜vQN’µºª“x_H6( •–•‘Œƒu^6 Ojsf[M?1& ~~xn_J. '.)" nrrpi`R?( bfhe`WJ;(Y^_]YQF9+RVWVRLC9. JNONKF@9A899C@<8 34555876 %))% //011/1!)07:7,++,,-&*&0;DJI<(()$ +7COXZL! ".;IWch]7  $/@?;5-$  $',021/*$  !%(%%#            ¹·µ´´³ “uC4ŒÇàÜÄ¥„fM9) —™™—”ŽƒiN' Fp†ŠvfUD4' ~‚ƒ|tgU<<5-% mqrpkcWF1 `efd_XL>-W[\[WPF:,OSTSOIB8. HJKJHC>7 ?ABA@=:667777654$&%-,,--.0 (/462$=#"""$&*&09BGD2 ·{% +6BNUT@g ".;HVacR "/3' %,39>@>:4+"  $',021.)#  !%#%%#            ´´µ·¹º¬£Š_$U¥Ùìäȧ„fM8( ”—™™—“‹t]:"V|yhUC4' |ƒ‚~xm\F( *D5-% kprqmeZK7 _dfe`YNA0 W[\[WPG;.OSTSOJB9.HJKJHC=7  @ABA?=95 77776543 "  --,,--/%+/0*&M$"""#&)$-6=@<*Fÿ™$)3>HOM8Θ!,8EQZ[K !-:GUaf^?   ,9GUajj]D* )6CP]gkg[K9( #0=IU^cc]RB1 *5?JRWYUMA2#  ",5>EIKIC:.# $*17;=;71( #&+.//,'!   #"##!           ¨¬¯²µ·«¤d-J’ÃÖз™z^G4% Œ‘•–•’‹v`?Nqƒƒn_N>/# x~~xn^I, '>0(! iprrnf[L9# `ehfb[PC2 Y]_^YRI=/ RVWVRLD:/KNONJE?7 C998A>:5 55543642110//,-!&)(!-,,++#'!(0573$ )d3)(( %/8@EC4Q; (3>HPQE%   )5AMW[U@ )4AMX__UA, &2>JU]`\RB1 -8CMVZYSH9)  '1;DKOPLD8+ (19?CDB<3)  !'.37862,$   #(+,+(#  !#!           $$$20040108210108 €8 $$$x  )2>KYiz‹œ•Ÿ££¦˜‡v !+6CSez•ª»ÈÎÍÆ¸¦Š !,8H[q|˜´ÎãóûúðßÈ®’  +:Kap¯Ðïÿÿÿÿÿÿèɧ )9L]{ÂçÿÿÿÿÿÿÿÿÞ¸ %5J`€£Ëôÿÿÿÿÿÿÿÿé¿ -C]| Èòÿÿÿÿÿÿÿÿä» ";So‘µÛþÿÿÿÿÿÿñͧ.BYu“°ÈÓÎÃÂÉÉ»¡ƒ+;Nbt}lZYitreR    (--'!$%%%%$! 78888861(RPPQRTTQH8tpnptzzd? Ÿ–“–ž«¹Çį„CÓýÂÐçÿÿÿÿëš.ÿõìóÿÿÿÿÿÿÿÿŠ"JVN9ÿÿÿÿÿÿÿÿÿÿÿÿÿ mÌëÞ¹Œ]ÿÿÿÿÿÿÿÿÿÿÿÿÿvÿÿÿÿÿí£4ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿê”4ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ¿d+ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÞˆJÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿë_3ÿÿÿÿÿÿÿÿÿÿÿåÿÿÿÿÿÿÿÿç¤i?" ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿèžiC) ÿÿÿÿÿÿÿÿÿÿ]ñÿÿÿÿÿÿÿËŽbB*ÿþõõüîûõÑ^ÿÿÿÿÿÿЧyV<( ÞÕÏÍÎϺª:¤ÿÿÿýͪ‚aG2# µ²¯¬¨£˜vQN’µºª“x_H6( •–•‘Œƒu^6 Ojsf[M?1& ~~xn_J. '.)" nrrpi`R?(  "+5AO_qƒ–¨£®³³¬ ¥’ #-9GXlƒŠ£ºÎÜãâÙʶž… #.>>>>=;6- ZXWXZ\\ZQ?~yxy~…‹Ž…oI¬¢Ÿ¢«ºËØÙÅ™VãÒÌÑâýÿÿÿÿÿÄPÿÿýÿÿÿÿÿÿÿÿÿÚ4[cW@ÿÿÿÿÿÿÿÿÿÿÿÿÿž­ÿÿýÏšfÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ²ÿÿÿÿÿÿÿÿÿÿÿÿÿÿçÿÿÿÿÿÿÿÿ¢4ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÑi+ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿòMÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ§d5ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿý¯nB" ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿæ©oF*ÿÿÿÿÿÿÿÿÿÿÿQ†ÿÿÿÿÿÿÿÿÛ˜hE,ÿÿÿÿÿÿÿÿÿè{ÿÿÿÿÿÿÿæµ[>) äÜØÙßçÚÓ¶}%†ÿÿÿÿÿ绌gK5$ ¹·µ´´³ “uC4ŒÇàÜÄ¥„fM9) —™™—”ŽƒiN' Fp†ŠvfUD4' ~‚ƒ|tgU<<5-% mqrpkcWF1  #,7CRcu‰­¸¾½¶ª™š… $.;J\q‰“­ÆÚéðïæÖÁ¨ $0>Pf€‘±Òðÿÿÿÿÿÿê˪ #0@Uo„§ÍôÿÿÿÿÿÿÿÿëÄ !.?Wm¸äÿÿÿÿÿÿÿÿÿÿÙ )>>>>=:5+ZXWXZ[[XN;~yxy~„Š‚jA «¢Ÿ¢¬ºÌ×ÖÀ‘HâÑÌÒãÿÿÿÿÿÿµ7ÿÿýÿÿÿÿÿÿÿÿÿ½ ;LF3ÿÿÿÿÿÿÿÿÿÿÿÿÿ]cÎð⼌\ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ°ÿÿÿÿÿ÷¨ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿö›+ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿËb%ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿíŠHÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþ£`1ÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿú¬k? ÿÿÿÿÿÿÿÿÿÿÿÿøÿÿÿÿÿÿÿÿÿå§mD(ÿÿÿÿÿÿÿÿÿÿÿòÿÿÿÿÿÿÿÿÿÚ—fC* ÿÿÿÿÿÿÿÿÿÿÈ<}ÿÿÿÿÿÿÿç´€Z=(ßÙØÜäðééÔ¤X#¸ÿÿÿÿÿ꼌gJ4# ´´µ·¹º¬£Š_$U¥Ùìäȧ„fM8( ”—™™—“‹t]:"V|yhUC4' |ƒ‚~xm\F( *D5-% kprqmeZK7  #,7DSdwŒ  ±¼ÂÁº®œˆ $/;K]sŒ–±ÊßîöõìÛŬ $0?Qhƒ”µ×öÿÿÿÿÿÿðÏ® #0AVq‡«ÒûÿÿÿÿÿÿÿÿñÉ !.@Xp”½êÿÿÿÿÿÿÿÿÿÿÞ ), ƒ”˜š˜’|b9Hdle\L<.! u„†…€veG(';C<7/& luz{wpdS=! hpttofYI5  (2>K[k}Ÿ™£¨¨¢—ž{  *6CTg|“š¯ÁÎÕÔ̾«•‘  +8H\s€ºÕëûÿÿùçÏ´— *9Kbu”¶ØøÿÿÿÿÿÿñЮ '7La€£Éñÿÿÿÿÿÿÿÿç¿ "3Ie…«ÔÿÿÿÿÿÿÿÿÿôÈ *Gb‚¨ÒþÿÿÿÿÿÿÿÿñÅ ?Xv™ÁéÿÿÿÿÿÿÿÿÚ² 2G`~ž¾×áÙÊÉÔØÊ¯!0BWm‰rYYo€r] )2:;3# +.+#  &%$$%#:878:<9/'RNMPU[]oMmgfkuª }6Š‚‰˜¬ÜØ´b¦œ§»õÿÿÜÿÿÿÿÃÎÅ×ôÿÿÿÿâ,3% ÕÎÒãÿÿÿÿÿéDb\E.ÒÏÔåÿÿÿÿÿÔ*yŠyZG)ÅÇÎÞöÿÿÿÿ¬Z–œ†cT7 ³ºÂÏâõÿÿÛ~k˜šƒaX<&Ÿ©²¼É×ÚϧUd‡ˆtmR;' Œ— ¨°¶°¡z6Plm\[G4$ {ˆ–™™’{Y" 8NOSF8* p|ƒ‡‡‚xeB"2:81(it{|zsfS9 grwwsj\J2KNNLHBWE0 %/9FTcr‚‘¦««¦œq '2>M^q…šœ¬·½¼¶©˜™„ '3BTh€Œ¥½ÑßæåÜ͸ † &4DYr„¡¿ÛóÿÿÿÿîÕ¸š#1D[r‘²ÔõÿÿÿÿÿÿíÌ© ,@Yv—»àÿÿÿÿÿÿÿúÖ° $8Vs”¹ÞÿÿÿÿÿÿÿøÓ­7Nh‡©Ìíÿÿÿÿÿÿ⿜,>Un‹¨ÂÔÝßÝ×˵š}*:L`tƒŒŠˆˆƒwfR $-5;;84232/(  7T%Œu@¬–\DzuÙÅ…ÙàËŠÕÚăÇɱs/#y…™£«±˜^ &6*q~ˆ—š–}I "$5+ hv€†‰ˆ~e8 2.& apx}}xlP+ %# ^ksvsl^H# _krsoeWB& JMNLHBT@( X[\YSLD;, "+4?LYgt‹“——“‹€tf #-8ETevˆ˜”ž¢¢œ‘—‡v #.;J\p†Ž¢³¿Åļ¯ž‰† !.KSTPE3FSYYTI7 KMMLHC=' Y\[XSME=ilkf_WMD:  ")2;DNX`gloomhaXO #+5@KWcnw~~wndY #,8DR`n|ˆ~‚}ˆ}pb !,8GWhy{ˆ‘–•…x{j *7GYdvˆ– ¥¤ž’ƒq^%3DTg{§­¬¥™ˆua+=QexŠš¥ª©¢•…r^8I[m~Œ–›š“‡xfT,;JYgs{~xn`RB'2=GOUWVRJA6+ !%(('$ 6$ BDDC@=,MNNLHD>YZYVQKE=6higb[SKC:1 $+3;CJQW[^^\XRLD %-6@IS[chjkhc\TL %/9DO[entxxuof]R $/:GTanxpssnyodX "-9GVehs{~ypdi[ (6EU^lw€„ƒ~thY[ !.>L[iu}€{qeVG #7DR_iqttnfZM?+7BMV\_^YRH=1%-5;?A@<70'  BDCB@=%JJIGDA=8RRPLID@:5\[WRMHB=60 %+28?DILNNMJE@: &.5=EKQUWWURMG@ '/8AJRX]``^ZTLD &/9CNW_dhhe`YQH $.8DOZci]]je]SI *5ANOX^a`\U]SH#.;BMU[^]ZSI?D$0;ELRTTPJA7< '/7=BDC@;3+"%),.-*&!     @@@?=;#CBA?=;85EB?<:9741-FA;755430,' $*/49BEGGFC?;5  '.5;BGJMMKHD>8 &.6=DJOQQPLGA:$,5=ELQSTRNIB;  )2;CJPSSQMHA9 ",5>E@BAMIC<5",459;:73;5. %*-..+'"*%   ('$ 231-'  343/*# -/.+& $&%#8975433214/+))*,-,**!#&('$ #'+/2455430-) $).2589:9740, %*048;==<:73. $*06:=?@?<94/ ")/5:>@@?=94/ %,28<>?>;73-  '-379:973/* %+/2220,($$&('&#    @<84.'STQKC9." XZXSJ?3'SUTOG=1%GIHD>5+ 7:961)!/,*))+,-"!%''!   $&)*+,+*(%# !%(+-./.,*(% "&*-/010/,)& !&*-01210-*& $)-/121/-)& !&*-/0/-+($ !%(+++)'$! "$%%$"  i§7 ’æ_5 G813871'qmhd^UG8)„…‚{qbR@/‚†„}rcR@/ tyxrgZJ:*aed_WK>0"KNNJD:/$'$!!"%'*   " !##$#"! !#$%&%$#  !$%&'&%$! !#%'''&$" "$&&&%#! "#$$#!     -R %ÿÿº ÿÿ¶   <@7)hF9Kah_N;) £œ–”„q[E0´·´­Ÿv^G2 «±°§™†pYC/•›š“†ubN;)z~ynaP@/ ^bb]UJ=0 #!%               - *—+&% 7KE6% /ip`J5"\JiŽ™ŒtY@* ÔÌÅÄÁ²™|_D.áæãÛË´˜z]C-Ð×Öͼ¥‹oU=)±¸¸°¡Žw`I4!Ž””Ž‚s`M:(mrrmdWI9%!!%%                -5/$ GYO>,n}nU=) Np ž†hK3ͤ”¬ÇÉ´”rS9#ÿÿû÷îÙ»—tU:$ÿÿÿÿîÓ²oQ7"êôóéÖ½Ÿ€cH1ÅÍÍĵŸ†lS<'£¤kVA.w||wn`Q@. TY!D7+              80*('$N6-6CG@4&IQhdT@-@]‰ˆsY@* n%‡¯©ŽnP6!ÉvË×Ä¢}\?(ÿÿøýÿñÒ«„aC+ÿÿÿÿÿõЩ‚`C*ÿÿÿÿÿåÂyY>'øÿÿøäɪŠkN5Î××ξ¨ŽsY@#£ªª¤—…q[E0 {€€{rdTB4$V[[WPF<0%#               A?;60( ifa\VL?1# ކ~|scO;) ¬—•ž™‡nT<' É¨š«¿¾©‹kN5 ñÕÈÖæàÆ¢}\?(ÿÿÿÿÿúÙ±‰eF-ÿÿÿÿÿÿൌhH.ÿÿÿÿÿÿدˆdF- ÿÿÿÿÿêÆ |\@ øÿÿùåˬ‹lP6 ÌÕÕͽ§ŽsY@+ §¨¢•„pZD6#x}~yobRI9)TXXUNI?4( 9951,'!           664/)" [\ZTKA4(‡‰†teTB0!³µ²«Ÿv^G2 ÞÞÚÔÈ´™{^D-ÿÿÿùí׸•rS9#ÿÿÿÿÿóϨ_B* ÿÿÿÿÿÿܲŠfG-ÿÿÿÿÿÿݳ‹gH.ÿÿÿÿÿøÒ«…bD+ÿÿÿÿþྛxY='êõõìÚÁ¤…gL8#ÀÈÉÁ³ž†mTE0–˜Œ|iTL8' ouuqh[LJ:, Z\\XRI@5* ;;:84/)#       $%$! BDB>7.%fihbYL>0" •“Œo\I6% ¼ÂÀ·¨“{cK5#åìëáÏ·š|_E. ÿÿÿÿñÕ´‘pR8#ÿÿÿÿÿëÆ |[?(ÿÿÿÿÿõϨ‚`C* ÿÿÿÿÿòͦ`C/ ÿÿÿÿÿãÁzZ>. ÷ÿÿùæÌ­nQA+ ÓÜÝÕÄ®”y]D:' ¬´´® ŽybJE2! †ŒŒ‡}n]\I8)bggc[bUG9,! VXWTOG>5+! ;;:850*$ ##"      )*)'" DGFB;2( eihcYM@1$ ŠŽˆ|lZG5$ °¶¶®Ÿ‹u^G2 ÓÛÛÑÀ©ŽsX@*"ïùùïÜ£„fK3( ÿÿÿÿîÒ±pR8- ÿÿÿÿôØ·•tU:0ÿÿÿÿïÓ³’rT90ïúûñßŨ‰jND/ÕÞßׯ°–z^D?,µ½½·©–gOM9(’™š”‰yfRTB1# qvwri\eUE6) knnjcZOC7,!PRQNJC;3*! 89973/*$ %%$"       ')(&!" ?BA>8/&% [_^ZRG:- & z~yn`P@/# ˜Ÿž˜‹zgR>+, ´¼¼´¦’{cL64$ ÊÓÓË»¥‹qW?;)ØáâÙȱ–z^D@-ÛåæÝ̵™}aFC/ ÕÞßׯ°•z^DC/  ÅÎÏǸ£‹qWV@. ®¶·°£‘{cLO;+ “š›•ŠzgSYF6' v|}xoan]L=/"y}^yqfZM@3( _ba^YQH>3*  HJJGC>70(  56541-(# $$$"       ,--+'# !#" *# 5774/(/& LOOKD;0%1& diid[PB4%0# |‚‚|rdTC19+ ’˜˜’†wdP1& z~~zsi]QD8-# illic[QG<1( XZZXSLE<3+" HJIGD?82*# 9::962-(" ,-,+)&"        '((&$! 2331.*&! ?@@>:5/)" MONLGA92*" [99ZUMD;1(  CGGD>YOD9.% OSSPIdXL?4)  X\\YQG_RE8-# \aa]VqdVH;/$ \aa]VreWI<0%\\YzocUH;0% z~~zsi^RE9.$ psspjaWLA6," dggd_WNE;1(  WYYWRLE=4,$ JLLJFA;4-& >??=:61,&  2331/,(# '((&%"       $$$#! ,--+)&" 67752.*% @BB@<72,% KMMJFA:3+$ UWWUPIB91)! ^``^XQI?6-% dggd_WND:0' hkkhb[QG=3)! illic[RH=3*! gjjgaZQG=3*! bddb]VMD:1)! []]ZVPH@7.& RTTRNHA:2+# IJJHE@:4-&  ?@@>;73-'" 56642/+&! ,,,+)&# ###"          '''&$" .//.+(%! 67763/+&! >??=:61,&  EGGEA=71*$ LNMKHB<5.'  QRRPLG@91*" SUUSOIB;3+$ TVVTPJC;4,% RTTRNIB;3,$ OQQOKF@91*# JLKJFA<5/(! DEEC@<71+% =>><961,'! 56652/+'" ...-+(%! &'&%$!         """!  ((('%#  ...-+(%! 44431-*%! 9::962.)$ >??=:72-'" ACBA>:5/)$ CEEC@<71+% DEEC@<71+%  CDDB?;61+% @BA@=95/*$ =>><:62-(" 899852.)%  33320-*&! -.-,*(%! '''&%#  !!!           """!  '''&$"  +,++)&#  /00/-*'# 33320-*&! 56653/,(# 788641-)$  788751.)%  677641-)$  56542/,(# 23320-)&" .//.,*'# +++*(&#  &'&%$" !""!            !!!  $$$$"  '(''%#! ***)(%#  ,,,+*'$! -.-,+(%" -..-+)&" ---,+(%" +,,+)'$! )**)'%#  '''&%#! $$$#"   !!               !!!  ###"! $%$$"! %&%%#! %&&%$" %%%%#! $%$$"! ###"! !!!        HEAP(ìò TREEÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÄñ  èî Àî  $$$20040108210108 Àö $$$xSNOD´ð ­UnnamedNodeArray0scalars¨  Á  )2>KYiz‹œ•Ÿ££¦˜‡v !+6CSez•ª»ÈÎÍÆ¸¦Š !,8H[q|˜´ÎãóûúðßÈ®’  +:Kap¯Ðïÿÿÿÿÿÿèɧ )9L]{ÂçÿÿÿÿÿÿÿÿÞ¸ %5J`€£Ëôÿÿÿÿÿÿÿÿé¿ -C]| Èòÿÿÿÿÿÿÿÿä» ";So‘µÛþÿÿÿÿÿÿñͧ.BYu“°ÈÓÎÃÂÉÉ»¡ƒ+;Nbt}lZYitreR    (--'!$%%%%$! 78888861(RPPQRTTQH8tpnptzzd? Ÿ–“–ž«¹Çį„CÓýÂÐçÿÿÿÿëš.ÿõìóÿÿÿÿÿÿÿÿŠ"JVN9ÿÿÿÿÿÿÿÿÿÿÿÿÿ mÌëÞ¹Œ]ÿÿÿÿÿÿÿÿÿÿÿÿÿvÿÿÿÿÿí£4ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿê”4ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ¿d+ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÞˆJÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿë_3ÿÿÿÿÿÿÿÿÿÿÿåÿÿÿÿÿÿÿÿç¤i?" ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿèžiC) ÿÿÿÿÿÿÿÿÿÿ]ñÿÿÿÿÿÿÿËŽbB*ÿþõõüîûõÑ^ÿÿÿÿÿÿЧyV<( ÞÕÏÍÎϺª:¤ÿÿÿýͪ‚aG2# µ²¯¬¨£˜vQN’µºª“x_H6( •–•‘Œƒu^6 Ojsf[M?1& ~~xn_J. '.)" nrrpi`R?(  "+5AO_qƒ–¨£®³³¬ ¥’ #-9GXlƒŠ£ºÎÜãâÙʶž… #.>>>>=;6- ZXWXZ\\ZQ?~yxy~…‹Ž…oI¬¢Ÿ¢«ºËØÙÅ™VãÒÌÑâýÿÿÿÿÿÄPÿÿýÿÿÿÿÿÿÿÿÿÚ4[cW@ÿÿÿÿÿÿÿÿÿÿÿÿÿž­ÿÿýÏšfÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ²ÿÿÿÿÿÿÿÿÿÿÿÿÿÿçÿÿÿÿÿÿÿÿ¢4ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÑi+ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿòMÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ§d5ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿý¯nB" ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿæ©oF*ÿÿÿÿÿÿÿÿÿÿÿQ†ÿÿÿÿÿÿÿÿÛ˜hE,ÿÿÿÿÿÿÿÿÿè{ÿÿÿÿÿÿÿæµ[>) äÜØÙßçÚÓ¶}%†ÿÿÿÿÿ绌gK5$ ¹·µ´´³ “uC4ŒÇàÜÄ¥„fM9) —™™—”ŽƒiN' Fp†ŠvfUD4' ~‚ƒ|tgU<<5-% mqrpkcWF1  #,7CRcu‰­¸¾½¶ª™š… $.;J\q‰“­ÆÚéðïæÖÁ¨ $0>Pf€‘±Òðÿÿÿÿÿÿê˪ #0@Uo„§ÍôÿÿÿÿÿÿÿÿëÄ !.?Wm¸äÿÿÿÿÿÿÿÿÿÿÙ )>>>>=:5+ZXWXZ[[XN;~yxy~„Š‚jA «¢Ÿ¢¬ºÌ×ÖÀ‘HâÑÌÒãÿÿÿÿÿÿµ7ÿÿýÿÿÿÿÿÿÿÿÿ½ ;LF3ÿÿÿÿÿÿÿÿÿÿÿÿÿ]cÎð⼌\ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ°ÿÿÿÿÿ÷¨ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿö›+ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿËb%ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿíŠHÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþ£`1ÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿú¬k? ÿÿÿÿÿÿÿÿÿÿÿÿøÿÿÿÿÿÿÿÿÿå§mD(ÿÿÿÿÿÿÿÿÿÿÿòÿÿÿÿÿÿÿÿÿÚ—fC* ÿÿÿÿÿÿÿÿÿÿÈ<}ÿÿÿÿÿÿÿç´€Z=(ßÙØÜäðééÔ¤X#¸ÿÿÿÿÿ꼌gJ4# ´´µ·¹º¬£Š_$U¥Ùìäȧ„fM8( ”—™™—“‹t]:"V|yhUC4' |ƒ‚~xm\F( *D5-% kprqmeZK7  #,7DSdwŒ  ±¼ÂÁº®œˆ $/;K]sŒ–±ÊßîöõìÛŬ $0?Qhƒ”µ×öÿÿÿÿÿÿðÏ® #0AVq‡«ÒûÿÿÿÿÿÿÿÿñÉ !.@Xp”½êÿÿÿÿÿÿÿÿÿÿÞ ), ƒ”˜š˜’|b9Hdle\L<.! u„†…€veG(';C<7/& luz{wpdS=! hpttofYI5  (2>K[k}Ÿ™£¨¨¢—ž{  *6CTg|“š¯ÁÎÕÔ̾«•‘  +8H\s€ºÕëûÿÿùçÏ´— *9Kbu”¶ØøÿÿÿÿÿÿñЮ '7La€£Éñÿÿÿÿÿÿÿÿç¿ "3Ie…«ÔÿÿÿÿÿÿÿÿÿôÈ *Gb‚¨ÒþÿÿÿÿÿÿÿÿñÅ ?Xv™ÁéÿÿÿÿÿÿÿÿÚ² 2G`~ž¾×áÙÊÉÔØÊ¯!0BWm‰rYYo€r] )2:;3# +.+#  &%$$%#:878:<9/'RNMPU[]oMmgfkuª }6Š‚‰˜¬ÜØ´b¦œ§»õÿÿÜÿÿÿÿÃÎÅ×ôÿÿÿÿâ,3% ÕÎÒãÿÿÿÿÿéDb\E.ÒÏÔåÿÿÿÿÿÔ*yŠyZG)ÅÇÎÞöÿÿÿÿ¬Z–œ†cT7 ³ºÂÏâõÿÿÛ~k˜šƒaX<&Ÿ©²¼É×ÚϧUd‡ˆtmR;' Œ— ¨°¶°¡z6Plm\[G4$ {ˆ–™™’{Y" 8NOSF8* p|ƒ‡‡‚xeB"2:81(it{|zsfS9 grwwsj\J2KNNLHBWE0 %/9FTcr‚‘¦««¦œq '2>M^q…šœ¬·½¼¶©˜™„ '3BTh€Œ¥½ÑßæåÜ͸ † &4DYr„¡¿ÛóÿÿÿÿîÕ¸š#1D[r‘²ÔõÿÿÿÿÿÿíÌ© ,@Yv—»àÿÿÿÿÿÿÿúÖ° $8Vs”¹ÞÿÿÿÿÿÿÿøÓ­7Nh‡©Ìíÿÿÿÿÿÿ⿜,>Un‹¨ÂÔÝßÝ×˵š}*:L`tƒŒŠˆˆƒwfR $-5;;84232/(  7T%Œu@¬–\DzuÙÅ…ÙàËŠÕÚăÇɱs/#y…™£«±˜^ &6*q~ˆ—š–}I "$5+ hv€†‰ˆ~e8 2.& apx}}xlP+ %# ^ksvsl^H# _krsoeWB& JMNLHBT@( X[\YSLD;, "+4?LYgt‹“——“‹€tf #-8ETevˆ˜”ž¢¢œ‘—‡v #.;J\p†Ž¢³¿Åļ¯ž‰† !.KSTPE3FSYYTI7 KMMLHC=' Y\[XSME=ilkf_WMD:  ")2;DNX`gloomhaXO #+5@KWcnw~~wndY #,8DR`n|ˆ~‚}ˆ}pb !,8GWhy{ˆ‘–•…x{j *7GYdvˆ– ¥¤ž’ƒq^%3DTg{§­¬¥™ˆua+=QexŠš¥ª©¢•…r^8I[m~Œ–›š“‡xfT,;JYgs{~xn`RB'2=GOUWVRJA6+ !%(('$ 6$ BDDC@=,MNNLHD>YZYVQKE=6higb[SKC:1 $+3;CJQW[^^\XRLD %-6@IS[chjkhc\TL %/9DO[entxxuof]R $/:GTanxpssnyodX "-9GVehs{~ypdi[ (6EU^lw€„ƒ~thY[ !.>L[iu}€{qeVG #7DR_iqttnfZM?+7BMV\_^YRH=1%-5;?A@<70'  BDCB@=%JJIGDA=8RRPLID@:5\[WRMHB=60 %+28?DILNNMJE@: &.5=EKQUWWURMG@ '/8AJRX]``^ZTLD &/9CNW_dhhe`YQH $.8DOZci]]je]SI *5ANOX^a`\U]SH#.;BMU[^]ZSI?D$0;ELRTTPJA7< '/7=BDC@;3+"%),.-*&!     @@@?=;#CBA?=;85EB?<:9741-FA;755430,' $*/49BEGGFC?;5  '.5;BGJMMKHD>8 &.6=DJOQQPLGA:$,5=ELQSTRNIB;  )2;CJPSSQMHA9 ",5>E@BAMIC<5",459;:73;5. %*-..+'"*%   ('$ 231-'  343/*# -/.+& $&%#8975433214/+))*,-,**!#&('$ #'+/2455430-) $).2589:9740, %*048;==<:73. $*06:=?@?<94/ ")/5:>@@?=94/ %,28<>?>;73-  '-379:973/* %+/2220,($$&('&#    @<84.'STQKC9." XZXSJ?3'SUTOG=1%GIHD>5+ 7:961)!/,*))+,-"!%''!   $&)*+,+*(%# !%(+-./.,*(% "&*-/010/,)& !&*-01210-*& $)-/121/-)& !&*-/0/-+($ !%(+++)'$! "$%%$"  i§7 ’æ_5 G813871'qmhd^UG8)„…‚{qbR@/‚†„}rcR@/ tyxrgZJ:*aed_WK>0"KNNJD:/$'$!!"%'*   " !##$#"! !#$%&%$#  !$%&'&%$! !#%'''&$" "$&&&%#! "#$$#!     -R %ÿÿº ÿÿ¶   <@7)hF9Kah_N;) £œ–”„q[E0´·´­Ÿv^G2 «±°§™†pYC/•›š“†ubN;)z~ynaP@/ ^bb]UJ=0 #!%               - *—+&% 7KE6% /ip`J5"\JiŽ™ŒtY@* ÔÌÅÄÁ²™|_D.áæãÛË´˜z]C-Ð×Öͼ¥‹oU=)±¸¸°¡Žw`I4!Ž””Ž‚s`M:(mrrmdWI9%!!%%                -5/$ GYO>,n}nU=) Np ž†hK3ͤ”¬ÇÉ´”rS9#ÿÿû÷îÙ»—tU:$ÿÿÿÿîÓ²oQ7"êôóéÖ½Ÿ€cH1ÅÍÍĵŸ†lS<'£¤kVA.w||wn`Q@. TY!D7+              80*('$N6-6CG@4&IQhdT@-@]‰ˆsY@* n%‡¯©ŽnP6!ÉvË×Ä¢}\?(ÿÿøýÿñÒ«„aC+ÿÿÿÿÿõЩ‚`C*ÿÿÿÿÿåÂyY>'øÿÿøäɪŠkN5Î××ξ¨ŽsY@#£ªª¤—…q[E0 {€€{rdTB4$V[[WPF<0%#               A?;60( ifa\VL?1# ކ~|scO;) ¬—•ž™‡nT<' É¨š«¿¾©‹kN5 ñÕÈÖæàÆ¢}\?(ÿÿÿÿÿúÙ±‰eF-ÿÿÿÿÿÿൌhH.ÿÿÿÿÿÿدˆdF- ÿÿÿÿÿêÆ |\@ øÿÿùåˬ‹lP6 ÌÕÕͽ§ŽsY@+ §¨¢•„pZD6#x}~yobRI9)TXXUNI?4( 9951,'!           664/)" [\ZTKA4(‡‰†teTB0!³µ²«Ÿv^G2 ÞÞÚÔÈ´™{^D-ÿÿÿùí׸•rS9#ÿÿÿÿÿóϨ_B* ÿÿÿÿÿÿܲŠfG-ÿÿÿÿÿÿݳ‹gH.ÿÿÿÿÿøÒ«…bD+ÿÿÿÿþྛxY='êõõìÚÁ¤…gL8#ÀÈÉÁ³ž†mTE0–˜Œ|iTL8' ouuqh[LJ:, Z\\XRI@5* ;;:84/)#       $%$! BDB>7.%fihbYL>0" •“Œo\I6% ¼ÂÀ·¨“{cK5#åìëáÏ·š|_E. ÿÿÿÿñÕ´‘pR8#ÿÿÿÿÿëÆ |[?(ÿÿÿÿÿõϨ‚`C* ÿÿÿÿÿòͦ`C/ ÿÿÿÿÿãÁzZ>. ÷ÿÿùæÌ­nQA+ ÓÜÝÕÄ®”y]D:' ¬´´® ŽybJE2! †ŒŒ‡}n]\I8)bggc[bUG9,! VXWTOG>5+! ;;:850*$ ##"      )*)'" DGFB;2( eihcYM@1$ ŠŽˆ|lZG5$ °¶¶®Ÿ‹u^G2 ÓÛÛÑÀ©ŽsX@*"ïùùïÜ£„fK3( ÿÿÿÿîÒ±pR8- ÿÿÿÿôØ·•tU:0ÿÿÿÿïÓ³’rT90ïúûñßŨ‰jND/ÕÞßׯ°–z^D?,µ½½·©–gOM9(’™š”‰yfRTB1# qvwri\eUE6) knnjcZOC7,!PRQNJC;3*! 89973/*$ %%$"       ')(&!" ?BA>8/&% [_^ZRG:- & z~yn`P@/# ˜Ÿž˜‹zgR>+, ´¼¼´¦’{cL64$ ÊÓÓË»¥‹qW?;)ØáâÙȱ–z^D@-ÛåæÝ̵™}aFC/ ÕÞßׯ°•z^DC/  ÅÎÏǸ£‹qWV@. ®¶·°£‘{cLO;+ “š›•ŠzgSYF6' v|}xoan]L=/"y}^yqfZM@3( _ba^YQH>3*  HJJGC>70(  56541-(# $$$"       ,--+'# !#" *# 5774/(/& LOOKD;0%1& diid[PB4%0# |‚‚|rdTC19+ ’˜˜’†wdP1& z~~zsi]QD8-# illic[QG<1( XZZXSLE<3+" HJIGD?82*# 9::962-(" ,-,+)&"        '((&$! 2331.*&! ?@@>:5/)" MONLGA92*" [99ZUMD;1(  CGGD>YOD9.% OSSPIdXL?4)  X\\YQG_RE8-# \aa]VqdVH;/$ \aa]VreWI<0%\\YzocUH;0% z~~zsi^RE9.$ psspjaWLA6," dggd_WNE;1(  WYYWRLE=4,$ JLLJFA;4-& >??=:61,&  2331/,(# '((&%"       $$$#! ,--+)&" 67752.*% @BB@<72,% KMMJFA:3+$ UWWUPIB91)! ^``^XQI?6-% dggd_WND:0' hkkhb[QG=3)! illic[RH=3*! gjjgaZQG=3*! bddb]VMD:1)! []]ZVPH@7.& RTTRNHA:2+# IJJHE@:4-&  ?@@>;73-'" 56642/+&! ,,,+)&# ###"          '''&$" .//.+(%! 67763/+&! >??=:61,&  EGGEA=71*$ LNMKHB<5.'  QRRPLG@91*" SUUSOIB;3+$ TVVTPJC;4,% RTTRNIB;3,$ OQQOKF@91*# JLKJFA<5/(! DEEC@<71+% =>><961,'! 56652/+'" ...-+(%! &'&%$!         """!  ((('%#  ...-+(%! 44431-*%! 9::962.)$ >??=:72-'" ACBA>:5/)$ CEEC@<71+% DEEC@<71+%  CDDB?;61+% @BA@=95/*$ =>><:62-(" 899852.)%  33320-*&! -.-,*(%! '''&%#  !!!           """!  '''&$"  +,++)&#  /00/-*'# 33320-*&! 56653/,(# 788641-)$  788751.)%  677641-)$  56542/,(# 23320-)&" .//.,*'# +++*(&#  &'&%$" !""!            !!!  $$$$"  '(''%#! ***)(%#  ,,,+*'$! -.-,+(%" -..-+)&" ---,+(%" +,,+)'$! )**)'%#  '''&%#! $$$#"   !!               !!!  ###"! $%$$"! %&%%#! %&&%$" %%%%#! $%$$"! ###"! !!!         $$$20040108210108 µ$$$x %4G^z™·ÐÖÃ’J-d¤«·µ²¯¬ #/>N_nƒƒqN?`v‹’•–•‘ !(0>' ,I^nx~~ #9L[fnrrp 2CP[bfhe /=IRY^_]/:DLRVWV 7?EJNON 5:>A8992463455!()&!-,//013d) $3750(!'#++,,;Q4CE@8/% (() %EQPH>3( @U[WMA5)  ,AU__XMA4) 1BR\`]UJ>2&  )9HSYZVMC8- +8DLPOKD;1'  )33)$K[ZQE8,!?^faUG:-! *D]jjaUG9,  (9K[gkg]PC6)  1BR]cc^UI=0#  #2AMUYWRJ?5*#.:CIKIE>5," (17;=;71*$  !',//.+&#  !##"#              )9Mf„¥ÄÜàÇŒ4Cu“ ³´´µ·  '4DUfvІpF 'NiƒŽ”—™™ %-5<LX_dfe,:FPW[\[ .8BIOSTS 7>CHJKJ6:=@ABA%&$4567777=$264/( 0.--,,{· 2DGB90&*&$"""g@TUNB6+ %RcaVH;."  FfmgZKGMOMH@7-#  "+4:>@>93,%  #).120,'$   #%%#%!            (6H_x“ªºµ’NQv˜£¨¬¯²  &1?M[fsjO 6^uƒŒ‘•– ").' .J_nx~ (?R`iprr(;JW`ehf+9FQY]_^ .9CLRVWV9@FKNON 8<@C998 %))% 6785554,7:70)!1/110/93+$  $*/120,'$   #%%(%!            $0?Qdw‚‡vI&S{—ž£§  !+5@IMQB!Gbu‰  !$ >>< (+)% 2566654#2::60( .//.,+*1DLJC9/%.)(%#"!?U[WMA5)%" /QdhaTG9,$&5NepoeWI:-  0ARdptodVG9+);N^jqpj^QC5( ->N\ehf_UI<0   -;HSY[YRJ?4)  )4>FKLJE=4+  #,49==;71)"  #)-/0.*("  "##&#            '3?KUSM2/]tƒ”˜  ")/20&1Pfu„†  /J^luz{2I[hptt "7KBGIJH+=BIMPPN #2=EKPRRP 6>DJMNNK5;?BDDCA "(*($15776532)4984-&,-,*&#!!*;FIF?6,'%"&9LVWRH=2' &7K[cbZNB5)'9J[gkg^QC6)"5GWelmg\OB4(  *1 -IRZ_ba^ 4>GOVZ[ZW 3;AFJKJIF"''%!/478741/-+254/)"++'" 0;BC?91(" 1@KPOIA7, /@NX[XPF;/ +?=82*  &,0231-(!  "%''%%    !!             -J^ksv   3L_krs JU^ehhd8EQ]gnrrm ;HT`jruto 0;GR\djlje8AIOSTSPL ##!27::71+&%(-/-)$)*(!!.6::71*  !0;CFD?8/.3  !/=HPTSNF<2' %2>GNPOIB9/  &1;CHIGB;3)  $-5;?@>:3,   '.35640*" !&)++)'"  !%#             IT]cffb9GT`krvup ?N\jv„ƒ| 4BQ`o|†‹‰ 5BO]jvƒ€x2=HRZ`ba\V -4:>=8.# #'(&#%))% (.11.) *38:94. )3;@A>92  $0:ADD@:3* )30  %**$ !&('% #*-/-*%"*0341-'  '.4663.( "*05763.' #*/3430+$!',/0/+& $'**(% !##"             .BDDC DIMNNL=GOUYZYV:FQ[chigb4AO\isy{xp8GWgw…“ƒ-;J\nƒ—¨°«š,:J[o† ¸ÆÁ© *6DTex¢¯¨Ž %/:CLPOC/ %+-(  !#$#  !%((&#  $(**'# !%)*)'#  %'('$  "$%#   !           @BDCB>CHJJIG>FLPRRPL;ENVZ\[WR4AMXagigaZ+8FTbny~|sg,:IYk}œ •,:I[oˆ¥Ã×ͧ )6DUiƒ¥ÓÿþÁ $/;GTbo}ˆzU %,11&                      >@@@?<@BCBA?4;ADFEB?</8@FIIFA;72A6                      $&%#8:;9754169:84/+),38:83*!.5:;7, &/7<=6% &08?A:$$/9BHF3 ",8DPYX> '3AQe~¡åûJ  +7GZs‹c–  '1:;L   *             #+27:96442/,*).11.)")-/-&),-( "(,+$ ',,# &,.'$,22#  *4>D9 %2D]­®iÿ  )=[çÿÿÿ  +Cl¬ÿÿÿ  $<_ŽºË %KV^bb]"0+'#'$ #        !+5<@K` ,Hs²úÿÿ)J}Äÿÿÿ 8a—Íïë 9[{Ž'8CC &9IWdmrrm*7)&! !       $ *Cd…›› 1S}¨Á½'Ej¡ž*C[hg *21 0>P_mw||w %1=BMTY "!     +:CD)@Ub`#:MXW#2:8 (8IRbp{€€{ *6ALOV[[W&,1      $#"       -L[Xeouuq &0:DMTZ\\X #*059;;:8  !          &1=JWcYbggc '09BJQVXWT $*048;;:8  "###"      !  $ !$ !  &0:FQ[dknnj &.6>FKPRQN #).368997  "$%%$"    %, %,3 "(.3 "',0 $(+  #$ %.7@JRZ_ba^ %,3:@EHJJG "',035654 "#$$$"   "-6 &1;C #-7@G &.7>D $,39= !'-15 #%), #+2:BIOSUUS #)/5:>ABB@  %),/111/  ""#"!  >içW§ #*/ !-:FO  ,9FS\ &1=IT\ '0;ENU %-6>EJ !(/5;? #',03 !'.4:@EHJIG !&+/479::9 "%(+,-,+    G­Úÿp¡  "/9;: %3CR^g !-??= "&*.02331 "$&'((&   .l i­   *& &6EOOL $2DVgt~ *8I[m|ˆ !,9HYhv€ !+6CQ^hp '1;FPY_ #*2;CIN %,06;>  $)-035664 "%(*,,,+  "###"    #$3AC. %4FYfln !->Qex‡’ %1ATgzŠ• &2@Par‰ $/;IWdow "*4?KU^d &,5>FMQ  '.28=@  $'*,...- !#%&'&%      ! -:?2  "1CT`a`  ->Rgy…Ž &4EYn‚“Ÿ )6GYm€› (5DTeuƒŒ &1>KYfqy #+6ALV_d '/6?GMR !(.58=@ "$&'''&  !!!        (.$1=CH *:KYbg )9L`q~ˆ %2CWl€‘œ )7H\p„•¡ +8HZmŽ˜  )6DTdsˆ &1=JXdnu #-5@JT\a '/5=EKO !'.4:?> !!""!       ' $0;E !.=KXb #0@Rcq| !-            )1 !,8CL &2@N[d &2AQaoy ".;L]n|† &3ARcs‹ (5CScrˆ (4AO^lw '0JT] %0=KXdl !+8ETamv $/CG  &+16:=  %)-02HEAP(loTREEÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿDn  hk@k $$$20040108210108 @s$$$xSNOD4m €)UnnamedNodeArray0scalarsÈ qÏC  )2>KYiz‹œ•Ÿ££¦˜‡v !+6CSez•ª»ÈÎÍÆ¸¦Š !,8H[q|˜´ÎãóûúðßÈ®’  +:Kap¯Ðïÿÿÿÿÿÿèɧ )9L]{ÂçÿÿÿÿÿÿÿÿÞ¸ %5J`€£Ëôÿÿÿÿÿÿÿÿé¿ -C]| Èòÿÿÿÿÿÿÿÿä» ";So‘µÛþÿÿÿÿÿÿñͧ.BYu“°ÈÓÎÃÂÉÉ»¡ƒ+;Nbt}lZYitreR    (--'!$%%%%$! 78888861(RPPQRTTQH8tpnptzzd? Ÿ–“–ž«¹Çį„CÓýÂÐçÿÿÿÿëš.ÿõìóÿÿÿÿÿÿÿÿŠ"JVN9ÿÿÿÿÿÿÿÿÿÿÿÿÿ mÌëÞ¹Œ]ÿÿÿÿÿÿÿÿÿÿÿÿÿvÿÿÿÿÿí£4ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿê”4ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ¿d+ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÞˆJÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿë_3ÿÿÿÿÿÿÿÿÿÿÿåÿÿÿÿÿÿÿÿç¤i?" ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿèžiC) ÿÿÿÿÿÿÿÿÿÿ]ñÿÿÿÿÿÿÿËŽbB*ÿþõõüîûõÑ^ÿÿÿÿÿÿЧyV<( ÞÕÏÍÎϺª:¤ÿÿÿýͪ‚aG2# µ²¯¬¨£˜vQN’µºª“x_H6( •–•‘Œƒu^6 Ojsf[M?1& ~~xn_J. '.)" nrrpi`R?(  "+5AO_qƒ–¨£®³³¬ ¥’ #-9GXlƒŠ£ºÎÜãâÙʶž… #.>>>>=;6- ZXWXZ\\ZQ?~yxy~…‹Ž…oI¬¢Ÿ¢«ºËØÙÅ™VãÒÌÑâýÿÿÿÿÿÄPÿÿýÿÿÿÿÿÿÿÿÿÚ4[cW@ÿÿÿÿÿÿÿÿÿÿÿÿÿž­ÿÿýÏšfÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ²ÿÿÿÿÿÿÿÿÿÿÿÿÿÿçÿÿÿÿÿÿÿÿ¢4ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÑi+ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿòMÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ§d5ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿý¯nB" ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿæ©oF*ÿÿÿÿÿÿÿÿÿÿÿQ†ÿÿÿÿÿÿÿÿÛ˜hE,ÿÿÿÿÿÿÿÿÿè{ÿÿÿÿÿÿÿæµ[>) äÜØÙßçÚÓ¶}%†ÿÿÿÿÿ绌gK5$ ¹·µ´´³ “uC4ŒÇàÜÄ¥„fM9) —™™—”ŽƒiN' Fp†ŠvfUD4' ~‚ƒ|tgU<<5-% mqrpkcWF1  #,7CRcu‰­¸¾½¶ª™š… $.;J\q‰“­ÆÚéðïæÖÁ¨ $0>Pf€‘±Òðÿÿÿÿÿÿê˪ #0@Uo„§ÍôÿÿÿÿÿÿÿÿëÄ !.?Wm¸äÿÿÿÿÿÿÿÿÿÿÙ )>>>>=:5+ZXWXZ[[XN;~yxy~„Š‚jA «¢Ÿ¢¬ºÌ×ÖÀ‘HâÑÌÒãÿÿÿÿÿÿµ7ÿÿýÿÿÿÿÿÿÿÿÿ½ ;LF3ÿÿÿÿÿÿÿÿÿÿÿÿÿ]cÎð⼌\ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ°ÿÿÿÿÿ÷¨ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿö›+ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿËb%ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿíŠHÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþ£`1ÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿú¬k? ÿÿÿÿÿÿÿÿÿÿÿÿøÿÿÿÿÿÿÿÿÿå§mD(ÿÿÿÿÿÿÿÿÿÿÿòÿÿÿÿÿÿÿÿÿÚ—fC* ÿÿÿÿÿÿÿÿÿÿÈ<}ÿÿÿÿÿÿÿç´€Z=(ßÙØÜäðééÔ¤X#¸ÿÿÿÿÿ꼌gJ4# ´´µ·¹º¬£Š_$U¥Ùìäȧ„fM8( ”—™™—“‹t]:"V|yhUC4' |ƒ‚~xm\F( *D5-% kprqmeZK7  #,7DSdwŒ  ±¼ÂÁº®œˆ $/;K]sŒ–±ÊßîöõìÛŬ $0?Qhƒ”µ×öÿÿÿÿÿÿðÏ® #0AVq‡«ÒûÿÿÿÿÿÿÿÿñÉ !.@Xp”½êÿÿÿÿÿÿÿÿÿÿÞ ), ƒ”˜š˜’|b9Hdle\L<.! u„†…€veG(';C<7/& luz{wpdS=! hpttofYI5  (2>K[k}Ÿ™£¨¨¢—ž{  *6CTg|“š¯ÁÎÕÔ̾«•‘  +8H\s€ºÕëûÿÿùçÏ´— *9Kbu”¶ØøÿÿÿÿÿÿñЮ '7La€£Éñÿÿÿÿÿÿÿÿç¿ "3Ie…«ÔÿÿÿÿÿÿÿÿÿôÈ *Gb‚¨ÒþÿÿÿÿÿÿÿÿñÅ ?Xv™ÁéÿÿÿÿÿÿÿÿÚ² 2G`~ž¾×áÙÊÉÔØÊ¯!0BWm‰rYYo€r] )2:;3# +.+#  &%$$%#:878:<9/'RNMPU[]oMmgfkuª }6Š‚‰˜¬ÜØ´b¦œ§»õÿÿÜÿÿÿÿÃÎÅ×ôÿÿÿÿâ,3% ÕÎÒãÿÿÿÿÿéDb\E.ÒÏÔåÿÿÿÿÿÔ*yŠyZG)ÅÇÎÞöÿÿÿÿ¬Z–œ†cT7 ³ºÂÏâõÿÿÛ~k˜šƒaX<&Ÿ©²¼É×ÚϧUd‡ˆtmR;' Œ— ¨°¶°¡z6Plm\[G4$ {ˆ–™™’{Y" 8NOSF8* p|ƒ‡‡‚xeB"2:81(it{|zsfS9 grwwsj\J2KNNLHBWE0 %/9FTcr‚‘¦««¦œq '2>M^q…šœ¬·½¼¶©˜™„ '3BTh€Œ¥½ÑßæåÜ͸ † &4DYr„¡¿ÛóÿÿÿÿîÕ¸š#1D[r‘²ÔõÿÿÿÿÿÿíÌ© ,@Yv—»àÿÿÿÿÿÿÿúÖ° $8Vs”¹ÞÿÿÿÿÿÿÿøÓ­7Nh‡©Ìíÿÿÿÿÿÿ⿜,>Un‹¨ÂÔÝßÝ×˵š}*:L`tƒŒŠˆˆƒwfR $-5;;84232/(  7T%Œu@¬–\DzuÙÅ…ÙàËŠÕÚăÇɱs/#y…™£«±˜^ &6*q~ˆ—š–}I "$5+ hv€†‰ˆ~e8 2.& apx}}xlP+ %# ^ksvsl^H# _krsoeWB& JMNLHBT@( X[\YSLD;, "+4?LYgt‹“——“‹€tf #-8ETevˆ˜”ž¢¢œ‘—‡v #.;J\p†Ž¢³¿Åļ¯ž‰† !.KSTPE3FSYYTI7 KMMLHC=' Y\[XSME=ilkf_WMD:  ")2;DNX`gloomhaXO #+5@KWcnw~~wndY #,8DR`n|ˆ~‚}ˆ}pb !,8GWhy{ˆ‘–•…x{j *7GYdvˆ– ¥¤ž’ƒq^%3DTg{§­¬¥™ˆua+=QexŠš¥ª©¢•…r^8I[m~Œ–›š“‡xfT,;JYgs{~xn`RB'2=GOUWVRJA6+ !%(('$ 6$ BDDC@=,MNNLHD>YZYVQKE=6higb[SKC:1 $+3;CJQW[^^\XRLD %-6@IS[chjkhc\TL %/9DO[entxxuof]R $/:GTanxpssnyodX "-9GVehs{~ypdi[ (6EU^lw€„ƒ~thY[ !.>L[iu}€{qeVG #7DR_iqttnfZM?+7BMV\_^YRH=1%-5;?A@<70'  BDCB@=%JJIGDA=8RRPLID@:5\[WRMHB=60 %+28?DILNNMJE@: &.5=EKQUWWURMG@ '/8AJRX]``^ZTLD &/9CNW_dhhe`YQH $.8DOZci]]je]SI *5ANOX^a`\U]SH#.;BMU[^]ZSI?D$0;ELRTTPJA7< '/7=BDC@;3+"%),.-*&!     @@@?=;#CBA?=;85EB?<:9741-FA;755430,' $*/49BEGGFC?;5  '.5;BGJMMKHD>8 &.6=DJOQQPLGA:$,5=ELQSTRNIB;  )2;CJPSSQMHA9 ",5>E@BAMIC<5",459;:73;5. %*-..+'"*%   ('$ 231-'  343/*# -/.+& $&%#8975433214/+))*,-,**!#&('$ #'+/2455430-) $).2589:9740, %*048;==<:73. $*06:=?@?<94/ ")/5:>@@?=94/ %,28<>?>;73-  '-379:973/* %+/2220,($$&('&#    @<84.'STQKC9." XZXSJ?3'SUTOG=1%GIHD>5+ 7:961)!/,*))+,-"!%''!   $&)*+,+*(%# !%(+-./.,*(% "&*-/010/,)& !&*-01210-*& $)-/121/-)& !&*-/0/-+($ !%(+++)'$! "$%%$"  i§7 ’æ_5 G813871'qmhd^UG8)„…‚{qbR@/‚†„}rcR@/ tyxrgZJ:*aed_WK>0"KNNJD:/$'$!!"%'*   " !##$#"! !#$%&%$#  !$%&'&%$! !#%'''&$" "$&&&%#! "#$$#!     -R %ÿÿº ÿÿ¶   <@7)hF9Kah_N;) £œ–”„q[E0´·´­Ÿv^G2 «±°§™†pYC/•›š“†ubN;)z~ynaP@/ ^bb]UJ=0 #!%               - *—+&% 7KE6% /ip`J5"\JiŽ™ŒtY@* ÔÌÅÄÁ²™|_D.áæãÛË´˜z]C-Ð×Öͼ¥‹oU=)±¸¸°¡Žw`I4!Ž””Ž‚s`M:(mrrmdWI9%!!%%                -5/$ GYO>,n}nU=) Np ž†hK3ͤ”¬ÇÉ´”rS9#ÿÿû÷îÙ»—tU:$ÿÿÿÿîÓ²oQ7"êôóéÖ½Ÿ€cH1ÅÍÍĵŸ†lS<'£¤kVA.w||wn`Q@. TY!D7+              80*('$N6-6CG@4&IQhdT@-@]‰ˆsY@* n%‡¯©ŽnP6!ÉvË×Ä¢}\?(ÿÿøýÿñÒ«„aC+ÿÿÿÿÿõЩ‚`C*ÿÿÿÿÿåÂyY>'øÿÿøäɪŠkN5Î××ξ¨ŽsY@#£ªª¤—…q[E0 {€€{rdTB4$V[[WPF<0%#               A?;60( ifa\VL?1# ކ~|scO;) ¬—•ž™‡nT<' É¨š«¿¾©‹kN5 ñÕÈÖæàÆ¢}\?(ÿÿÿÿÿúÙ±‰eF-ÿÿÿÿÿÿൌhH.ÿÿÿÿÿÿدˆdF- ÿÿÿÿÿêÆ |\@ øÿÿùåˬ‹lP6 ÌÕÕͽ§ŽsY@+ §¨¢•„pZD6#x}~yobRI9)TXXUNI?4( 9951,'!           664/)" [\ZTKA4(‡‰†teTB0!³µ²«Ÿv^G2 ÞÞÚÔÈ´™{^D-ÿÿÿùí׸•rS9#ÿÿÿÿÿóϨ_B* ÿÿÿÿÿÿܲŠfG-ÿÿÿÿÿÿݳ‹gH.ÿÿÿÿÿøÒ«…bD+ÿÿÿÿþྛxY='êõõìÚÁ¤…gL8#ÀÈÉÁ³ž†mTE0–˜Œ|iTL8' ouuqh[LJ:, Z\\XRI@5* ;;:84/)#       $%$! BDB>7.%fihbYL>0" •“Œo\I6% ¼ÂÀ·¨“{cK5#åìëáÏ·š|_E. ÿÿÿÿñÕ´‘pR8#ÿÿÿÿÿëÆ |[?(ÿÿÿÿÿõϨ‚`C* ÿÿÿÿÿòͦ`C/ ÿÿÿÿÿãÁzZ>. ÷ÿÿùæÌ­nQA+ ÓÜÝÕÄ®”y]D:' ¬´´® ŽybJE2! †ŒŒ‡}n]\I8)bggc[bUG9,! VXWTOG>5+! ;;:850*$ ##"      )*)'" DGFB;2( eihcYM@1$ ŠŽˆ|lZG5$ °¶¶®Ÿ‹u^G2 ÓÛÛÑÀ©ŽsX@*"ïùùïÜ£„fK3( ÿÿÿÿîÒ±pR8- ÿÿÿÿôØ·•tU:0ÿÿÿÿïÓ³’rT90ïúûñßŨ‰jND/ÕÞßׯ°–z^D?,µ½½·©–gOM9(’™š”‰yfRTB1# qvwri\eUE6) knnjcZOC7,!PRQNJC;3*! 89973/*$ %%$"       ')(&!" ?BA>8/&% [_^ZRG:- & z~yn`P@/# ˜Ÿž˜‹zgR>+, ´¼¼´¦’{cL64$ ÊÓÓË»¥‹qW?;)ØáâÙȱ–z^D@-ÛåæÝ̵™}aFC/ ÕÞßׯ°•z^DC/  ÅÎÏǸ£‹qWV@. ®¶·°£‘{cLO;+ “š›•ŠzgSYF6' v|}xoan]L=/"y}^yqfZM@3( _ba^YQH>3*  HJJGC>70(  56541-(# $$$"       ,--+'# !#" *# 5774/(/& LOOKD;0%1& diid[PB4%0# |‚‚|rdTC19+ ’˜˜’†wdP1& z~~zsi]QD8-# illic[QG<1( XZZXSLE<3+" HJIGD?82*# 9::962-(" ,-,+)&"        '((&$! 2331.*&! ?@@>:5/)" MONLGA92*" [99ZUMD;1(  CGGD>YOD9.% OSSPIdXL?4)  X\\YQG_RE8-# \aa]VqdVH;/$ \aa]VreWI<0%\\YzocUH;0% z~~zsi^RE9.$ psspjaWLA6," dggd_WNE;1(  WYYWRLE=4,$ JLLJFA;4-& >??=:61,&  2331/,(# '((&%"       $$$#! ,--+)&" 67752.*% @BB@<72,% KMMJFA:3+$ UWWUPIB91)! ^``^XQI?6-% dggd_WND:0' hkkhb[QG=3)! illic[RH=3*! gjjgaZQG=3*! bddb]VMD:1)! []]ZVPH@7.& RTTRNHA:2+# IJJHE@:4-&  ?@@>;73-'" 56642/+&! ,,,+)&# ###"          '''&$" .//.+(%! 67763/+&! >??=:61,&  EGGEA=71*$ LNMKHB<5.'  QRRPLG@91*" SUUSOIB;3+$ TVVTPJC;4,% RTTRNIB;3,$ OQQOKF@91*# JLKJFA<5/(! DEEC@<71+% =>><961,'! 56652/+'" ...-+(%! &'&%$!         """!  ((('%#  ...-+(%! 44431-*%! 9::962.)$ >??=:72-'" ACBA>:5/)$ CEEC@<71+% DEEC@<71+%  CDDB?;61+% @BA@=95/*$ =>><:62-(" 899852.)%  33320-*&! -.-,*(%! '''&%#  !!!           """!  '''&$"  +,++)&#  /00/-*'# 33320-*&! 56653/,(# 788641-)$  788751.)%  677641-)$  56542/,(# 23320-)&" .//.,*'# +++*(&#  &'&%$" !""!            !!!  $$$$"  '(''%#! ***)(%#  ,,,+*'$! -.-,+(%" -..-+)&" ---,+(%" +,,+)'$! )**)'%#  '''&%#! $$$#"   !!               !!!  ###"! $%$$"! %&%%#! %&&%$" %%%%#! $%$$"! ###"! !!!         $$$20040108210108 €1$$$xµ²¯¬¨£˜vQN’µºª“x_H6( •–•‘Œƒu^6 Ojsf[M?1& ~~xn_J. '.)" nrrpi`R?( bfhe`WJ;(Y^_]YQF9+RVWVRLC9. JNONKF@9A899C@<8 34555876 %))% //011/1!)07:7,++,,-&*&0;DJI<(()$ +7COXZL! ".;IWch]7  $/@?;5-$  $',021/*$  !%(%%#            ¹·µ´´³ “uC4ŒÇàÜÄ¥„fM9) —™™—”ŽƒiN' Fp†ŠvfUD4' ~‚ƒ|tgU<<5-% mqrpkcWF1 `efd_XL>-W[\[WPF:,OSTSOIB8. HJKJHC>7 ?ABA@=:667777654$&%-,,--.0 (/462$=#"""$&*&09BGD2 ·{% +6BNUT@g ".;HVacR "/3' %,39>@>:4+"  $',021.)#  !%#%%#            ´´µ·¹º¬£Š_$U¥Ùìäȧ„fM8( ”—™™—“‹t]:"V|yhUC4' |ƒ‚~xm\F( *D5-% kprqmeZK7 _dfe`YNA0 W[\[WPG;.OSTSOJB9.HJKJHC=7  @ABA?=95 77776543 "  --,,--/%+/0*&M$"""#&)$-6=@<*Fÿ™$)3>HOM8Θ!,8EQZ[K !-:GUaf^?   ,9GUajj]D* )6CP]gkg[K9( #0=IU^cc]RB1 *5?JRWYUMA2#  ",5>EIKIC:.# $*17;=;71( #&+.//,'!   #"##!           ¨¬¯²µ·«¤d-J’ÃÖз™z^G4% Œ‘•–•’‹v`?Nqƒƒn_N>/# x~~xn^I, '>0(! iprrnf[L9# `ehfb[PC2 Y]_^YRI=/ RVWVRLD:/KNONJE?7 C998A>:5 55543642110//,-!&)(!-,,++#'!(0573$ )d3)(( %/8@EC4Q; (3>HPQE%   )5AMW[U@ )4AMX__UA, &2>JU]`\RB1 -8CMVZYSH9)  '1;DKOPLD8+ (19?CDB<3)  !'.37862,$   #(+,+(#  !#!          —ž£§ª«©•}U]¤¤“~fO<, ‰‹ƒtX81RdgXM@3' rz~~{uj[E) ,%  hosrnf[L8" bhkje]RC3 ^AB@_VL?0!BDEC@;G<0BCCB?;690 >>><:736  665431/, .,+***)( ! %#"!"#$'#),-(  !)06:7,#-6>DD<*%/9CJMI<( $.9CLRQJ;* ",6AJPROE7'(2;DJNLF<."+4;1#   '08?BB;0!  &.7=BC?7+  "*29>@>8/#  %,37:95.$%+/22/*#  #'))($   !           p|ƒ‡‡‚xeB"2:81(it{|zsfS9 grwwsj\J2KNNLHBWE0VYYVQJB91]``]WPG>4!_ba^XQH?5$Z[ZWRKD<4,KJIFC@;60)41/-...,)% !! "" $(*(#  &,/0,$  '-242," &,1440) #).220+# $)-.-)#  #'((%!   !!            ^ksvsl^H# _krsoeWB& JMNLHBT@( X[\YSLD;,ehhd^ULA7nrrme[QE:0rutof\QF;1jlje^ULC9/&TSPLHD?:3+1+&%(+-,*%       !## #&&$ "&''#   $&&$  ##"            P]efbYH1EHHGCYI3TWWTOIB8cffb\TKA7rvuph^SG<1„ƒ|reXL?4†‹‰uhZL@4*ƒ€xl`TH=2(ba\VPJD>6.%.# ',-+&                   FSYYTI7 KMMLHC=' Y\[XSME=ilkf_WMD: {~|vlaUJ?4’†yj\NB6+›¢Ÿ“‚p_PB6+š¢ž}jZL@4)z{ui]SJB8/&0&.0-'                 BDDC@=,MNNLHD>YZYVQKE=6higb[SKC:1y{xpg\QG=4*“ƒufXK@5+¨°«šƒn\NA5+!¸ÆÁ©Šp\M@4)¢¯¨Žr^PE:/%C/!.550(!      BDCB@=%JJIGDA=8RRPLID@:5\[WRMHB=60igaZRKE?81)~|sg[QIA91) œ •jYND;1(Ã×ͧ~cRF;0&ÓÿþÁ…cRE9.#}ˆzUEEC<3) $+(!  @@@?=;#CBA?=;85EB?<:9741-FA;755430,'H?60./11/+%OA1'&*.0.*$bQ9'$)/1/*#ŒnF43651*"Òÿÿ§`LD=3) ËÿÿÞw^PB4( JK?0# 41&$&%#8975433214/+))*,-,**!#&('$  ##! ! ! >$+)" ¡åûJOXO@1$‹c–ÌŸqN5# Lº¡sM1*oqW<% 0;2# 7:961)!/,*))+,-"!%''!    )93( ­®iÿÿº{P3çÿÿÿÿø˜\6 ¬ÿÿÿÿÓ‡Q-_ŽºË¶Š]8 % 0=@8) ^bb]UJ=0 #!%      <@K`fXA+ ²úÿÿï©l@! Äÿÿÿÿ´rA—ÍïëÄŽ[2[{ŽyY7'8CC9'  mrrmdWI9%!!%%      $*'d…››„b@$}¨Á½žtJ(j¡ž…a=C[hgW># *21(w||wn`Q@. TY!D7+     +:CD;, @Ub`Q;# :MXWH3#2:8.   {€€{rdTB4$V[[WPF<0%#    $#"         x}~yobRI9)TXXUNI?4( 9951,'!               ouuqh[LJ:, Z\\XRI@5* ;;:84/)#            bggc[bUG9,! VXWTOG>5+! ;;:850*$ ##"        ""  !$''&$   $'((&$  !$&'&$! !"#"!  knnjcZOC7,!PRQNJC;3*! 89973/*$ %%$"        $)++)&! %,14530+% %,379851,&  "(.36864/*$ "',0232/+&" $(+,,+)'#  #$%'&$! _ba^YQH>3*  HJJGC>70(  56541-(# $$$"      !   %-342-(" "-6=BDB=6.'  &1;CILKGA91(! -7@GLMKG@80(! .7>DHHFB;4,%  ,39=@@>:5.'# '-157751-*$ #%),--++($ SUUSNH@8/' ABB@<82,% 111/-)%! "#"!   >%içžW§a     .773,% #*/8DLMH?6-$ -:FOW]^YQF;1' 9FS\cec\RG<2(  =IT\ab_XOD:0&  ;ENUYYVOG>5+% 6>EJMMJE>6.)" /5;?A@>:40*$ ',034422-)$ HJIGD?82*# 9::962-(" ,-,+)&"     G­w Úÿÿ2 p¡ 174-& ?ONE;0' /9;:CVce]QD7,# CR^gouvodVG:.$ K[itz|xocUG:.% LZgpuupg\OB6+$ GS]dhhc\RG<1*" ?HPVYXTNF=4-% 6=CGIIFA:3.'! ,269;:872-'" >??=:61,&  2331/,(# '((&%"    .lE  i­5 *20*$  #HLE;1' *& TebVH:.$ EOOLVlzzo_O@3' Vgt~†‹Š‚sbQB4(  [m|ˆŽ‰~o_O@3)  Yhv€„„~sfXI?><;60*$ 56642/+&! ,,,+)&# ###"       %*($ &BE?6-% #F_^SF9-# AC.NqyqbQA4( Yflnx‡Š|jWF7+" ex‡’š™Ž}jXG8+# gzŠ•››”‡weTD6," ar‰ŽŒ…zl\M?2)! Wdowzysj^QD7/& KU^dfe`YOE:3*# >FMQSRNHA<4,% 28=@AA>=71+%  ...-+(%! &'&%$!          2::5.'  !-MWTJ?3)! :?2 +Plrj\L>1& T`a`j~ЇzhVE7*! gy…Ž–“‚n[I9,# n‚“Ÿ¦¦ “mZI9,$ m€› Ÿ—ŠygVE7-# euƒŒŽ‡{m]N?5*" Yfqy|ztj^RD80' LV_dge`YOE:3*# ?GMRSRNHA<4,% 58=@A@A=82+&  '''&%#  !!!          $*-,($  (.7AHID=4+# 1=CHQ^fd\PC6," KYbgp{€{o_O@2' `q~ˆ–•‹{iWF7+" l€‘œ£¥Ÿ’€mZH9,# p„•¡¦¥~kYH9.$ mŽ˜›’†vdTD6,# dsˆ‹‰‚wi[L>4*! Xdnuwvpg[OB9/& JT\acb]VLB<2*# =EKOPOKEB:3+% 4:?>?B?;60+%  !""!           '/4763.(" $0;EMRSOH?6,$ =KXbjnmg\OC6," Rcq|ƒ†ƒzl\M>1& bt„–—‘†vdSC5)! j~Ž™Ÿž–‰ygUE7,# l~˜œ›“†veTD6,# gw…Ž‘ˆ|n^N@5+" ^lw~yobUG:2(  S^gmomh_UI>6-% FOV[\[VPGB80(! 9@FIJIFE>70)# 17;>?>;83.)$           "$%#   )17;;95/)" ,8CLRTSNG>5,# @N[dkliaWK?4*! QaoyzpdVG:.% ]n|†‹‹„yk\L>1(  cs‹Ž‡{m]N?2)! crˆŒŠƒxj[L>4)! ^lw‚€yocUG:1(  VakqsrlcXL@8.& KU\acb]VLB<2*# @GMQSQMGD<4,&  7=?BCFC>93-'! .2689973/+&"          $&''$! &-48;:73-'! .8BINOMHA91)! >JT]ab^WND9/& KXdlppkcXL@4+" Tamvyysj^QD7.% Xeqy|{uk_RE8/& Wdnuxwqh\OC9.& S^gmpnh`VJ>6-% KU]bdb]VMB;2*# BJPUVUQJB=5-&  :>CGHGCB<5/(# 16:=>=;73.)$ )-02331.+'# xdmf-3.0+git20160803/Data/Data/Test2.xmf0000640000175000017500000000246313003006557017336 0ustar alastairalastair 0 0 0 1 0 0 0 1 0 1 1 0 0 0 1 1 0 1 0 1 1 1 1 1 0 0 2 1 0 2 0 1 2 1 1 2 0 0 3 1 0 3 0 1 3 1 1 3 100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600 1100 1200 1300 1400 1500 1600 1700 1800 1900 11000 11100 11200 11300 11400 11500 11600 100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600 xdmf-3.0+git20160803/Data/Data/Test1.xmf0000640000175000017500000000321413003006557017330 0ustar alastairalastair ]> 0 1 2 3 4 5 6 7 1 8 9 2 5 10 11 6 4 5 6 7 12 13 14 15 0 0 0 1 0 0 1 0 -1 0 0 -1 0 1 0 1 1 0 1 1 -1 0 1 -1 3 0 0 3 0 -1 3 1 0 3 1 -1 0 2 0 1 2 0 1 2 -2 0 2 -2 100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600 1100 1200 1300 1400 1500 1600 1700 1800 1900 11000 11100 11200 11300 11400 11500 11600 100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600 xdmf-3.0+git20160803/Data/Data/IronRectProtein.xmf0000640000175000017500000003737713003006557021437 0ustar alastairalastair ]> 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 IronRectProtein.h5:/IronRectProtein0/UnnamedNodeArray0 IronRectProtein.h5:/IronRectProtein0/scalars 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 IronRectProtein.h5:/IronRectProtein1/UnnamedNodeArray0 IronRectProtein.h5:/IronRectProtein1/scalars 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 IronRectProtein.h5:/IronRectProtein2/UnnamedNodeArray0 IronRectProtein.h5:/IronRectProtein2/scalars 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 IronRectProtein.h5:/IronRectProtein3/UnnamedNodeArray0 IronRectProtein.h5:/IronRectProtein3/scalars 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 IronRectProtein.h5:/IronRectProtein4/UnnamedNodeArray0 IronRectProtein.h5:/IronRectProtein4/scalars 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 IronRectProtein.h5:/IronRectProtein5/UnnamedNodeArray0 IronRectProtein.h5:/IronRectProtein5/scalars 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 IronRectProtein.h5:/IronRectProtein6/UnnamedNodeArray0 IronRectProtein.h5:/IronRectProtein6/scalars 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 IronRectProtein.h5:/IronRectProtein7/UnnamedNodeArray0 IronRectProtein.h5:/IronRectProtein7/scalars xdmf-3.0+git20160803/Data/Baseline/0000740000175000017500000000000013003006557016463 5ustar alastairalastairxdmf-3.0+git20160803/Data/Baseline/IronMagicStride.png0000640000175000017500000001564513003006557022231 0ustar alastairalastair‰PNG  IHDR,,ö"lIDATxœíÝ{p”å½ðß^²—ÜÙÜHB@@Á ‚1BµG§£V0ÅuNÛQ+:ö8LZëÁmQÑÚÎxÊôÔšA‹#bOÛ9zŠPhÀ€A$@¹_–ìf³—óÇ<>y÷öæÏ^¾Ÿñ÷}óîî³ø~÷÷¼×ǰjÍuŒªìBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅBÅ̪ìÕm•CCC&“‰gŸü÷_«mDeXµfƒê6Àxu[%O ‘!ëììüÅ–ÿRÐ,ÐÝÑD I`HÏUþÛµjŒB÷6>½NçšÈalBG„2( ‡1!Œo¢ êI Cc ŽŽÆ±'[ív»‰¨¿¿_^n0 ä%¼Ä&TÂ8öÊ뻂 "ºtéÒ5oŒBßä N`dŸ}åj¶F !Œ{œÃàø¡Æ œ¬O[~ñDðBÞ9looçY”Á„J˜8*Ÿ{µò¹W#¬€Æ&„0Ñh¢ˆNiìCw4ÁqÕh4¢ Æ,œ'Lp\½ùIÕ °P Ã>a\ºÿÞEª›ÝѸ!/77÷áÕwòôÎ]ÿ§¤=0QP ãÃM7æˆéÜÜ\ùO¬»÷š7&B"$Ðf³Ñò¥×_ë6ÁÄAc]Ô2ä0~aŸ0¦ÝtcNvv6O—––Šåuuu@ ··—g4&*aL;öUgÔu,Ë5h \=a¬ûäàÍ’ºº:1-øÙ®]›`B¡;Ç8»?8¤º!0.aøäà™e·ÍäiQ- â—ÂøðÝï~÷ܹs"ü­Fm{`aŸ0><þÔ <ñÁßjÀƒ ¸C%P !P !P !P !P !P !P !P !P !P !P !P !P !P !P wÖǽò%Ó³²²ä%þ㨪ÆÀ „q©|Ét1­I Ïç[07ŸˆŽ~Ùv­›c‚îhü)pøÄtpÅ4GbBgt&!‡q!Œ'£J Ccö ã‰Çãá §Óét:í&ƨ`ù“¼mÝø»P ãIAAÁh_’ŸŸÆ8„0nÜ83Óf³M›6Mçúùùùg[<‡4_ÕVÁøá72nX,¿ßït:'MšuåÞÞÞÞÞ^"û5hŒ*aܨ=Ñ!öûûû#¬Éû„ÝN$0> „ñ¤¡ÉÝÐäÖ³&GÐ? Mî%¶àå_ÔµO"ñ!ŒK Mn"]%bº£Š!„Š!„Š!„Š!„ŠáèhüYµâö´´4yÉïü‡ªÆÀø!„ñdÕŠÛ5KΟ?ODKo½rAiuuõÔ©S.v¢7ÂøðÓgÖ×××ËK8~‹/&¢ÆÆÆÉ9~"BãB\.WII‰˜u8×_=Oûýþövq­ ååå½óÎ;ÃÓÔÙÙy¡ –á—2>¼ôZUÈå~¿_žÍËËûüóÏmÃrss‘À؇Æ—^«ÒD1dÅlzzúÇûO^£ÆÁ8 „qFä Laüyéµ*MÏœ9#'°úh G «ÖlPÝ€¤†J B B NÖÇ¥Ë=§ˆè³Ï>Ó,¿õÖ[‰(##Ãoš¬ Y0&aÜ0ú.j–päˆhëÖ­òòŽŽŽ×_§‘ÆØ‡ÆU+nÿôÓO]]]š?mܸÑlñ?‘Ÿ†øØcÑÛo¿Mä±Z­-mkÖZ-Óœ›ÊT·!޵_ø¢¿ç‚#;Ådàÿn˜9¹£{p¢ÞÕŠÛ{»››››‰ÈçóÙív—ËEÃRˆÚlW¾Æ ƒÃÌ›7oÞ¼yÕÕÕ³®/\^~KÝɦ‰jXNæ ÏÓc2 ¤˜Ü†€ÓDäëo»x&-…wÔ±àì¹Ú C[[Û¥K—.^¼h±X\.WQQQÀ×—jõ¹ÇÛËà(f9Z6›Ín·?ÿüóóçÏ5Ðf³õ÷÷‹ábxM—Ëåõz½^¯Á`ðx<¹©ÅœÌÁùóçŸ;wŽˆ555edd¤§§NCÀÙ|þDfvñ8?%yàdýè4œÜoµZ­VëäÉ_ÿ䋈è¯ý+ïªÍŸ?ÿ£O¾Û§Ì›í˜6mÚñãǽ^¯XXZZzäÈ"Z±bEjjªÜ 5™LòË{zzäÙºººùóçÑŒF£Ïç;~RÛ­Õï›Ënä‰Ó§O>|Xô322Ä:©©©D”3ù¦1JRAG¡ål5Ùl6ÞȈˆïpoii™6mZYYYff&qQm9DÔÜÜÜÓÓc0ˆ¨««+%%…ˆV¬Xñç?ÿÙhqn‰ËÛ¼y3ÿµ±±‘—ÈI&¢¦¦&.b£¢ˆmݺÕápˆÙ'žxÂçóññ¡É“'r9Ô!ÔK$†é—ŽÍÝwßMRˆèÓO?5XtõÍæÍvˆ·""Þäö÷÷‹ñ'€¦ôÉ!äY—ËõòË/såöôôðûŒ6‡OËÒ¥Kù‹sØÇ#)šÊ¼í¶Û¦M›vîܹ€§EçàfddÈ ”=óÌ3f³ùOúÏúýþ†“ûg̾Cÿ§$\1£ oú~¿¿¢¢â‡?ü!õôôˆÍzáÂ…×R !Œî¡‡â M¹ ѳÏ>˹¹¹+®#h' Ù)Ór1¤áŸƒ¨ÅPøùÏ®Y2âÒ…’’’£Õê|ó¤‚FÒÔb‹Ô³‡#÷H­Vkp1ämý7Þ¾ð b&ÿè)˧OŸ¦ .[¶ìÛßþú%çPS 594ÚäY¹G¡#*s¹\Á§O@À)аÀ”)Sˆ¨¦¦æßø†Xá@_eeå† ˆ¨¸¸˜OR3«Õê¹ò…5r騻w¯¸Ú“BuD£–AÑlþh.†Á–-[&.Ÿimmmii—ûÈg5ye«ÕÚ××ÇK8Qf³YÞUæ+Aþúµµµ£íÌ'T°r oŽºNð&o‚‘É;iöa¿úÕ¯RGêêê’g5o’?R^^??-----­¼¼&éñxäÛØ5… È ä'òlÈ#½¤£ šl%Gkþ¦Y¸cÇŽGyÄf³¹Ýîà»"‘@ÐÕ+;oÝ|óÍÏ=÷œæO¿ùÍoªªªªªª&Mštlé|¦—A~¢!ÓœßÛ¿¿iXÔw“‹'PÌÊ Ãm7-¼gÁ‚Ü)½é¦+PRù:žóçÏ#ú¡Ž×Ã¥K—rÆÄ H¼¸oß>±æºuëœN§=sf„wã.Ü»ï¾ËñkkkËÏÏ//////ß¾}»¼¦œOÁëõ?Ó…F^Úª3QË àt:ÓÓÓ×­[wìØ1¿ß¿|ùrù[§¦¦ ìÙ³Çív#ú¡ŽNvÞ®o©©©Ë—/_¾|9/—·Åx j9`ååå<ÁW³Y³fч~ÈO£ižêK#Ÿ³øÞ{ï‰ép½ÐѲgÎt:¢Âó·Åpß¾}õõõ÷ß¿¨“ þ;×Oq µæ¹c555Qwù8‡æ†ŒýèGbº¼¼\D±±±±¨¨ˆˆ>ùä“-[¶tƒ‹!ï¶µµ‰7ܶmOÔ×××××ËŸ¢)ƒuuu·®³ñâADtøða’ž=súÜÄ{ùÚk¯iNcº\.¾ö€:tHÞ—koo×y$iþœúè#¯×û­o}K¾¢%$y¤N ?Û¿µµ•ˆ õŸPÑYíAtG+̽’æ¦&‰ÈáôéÓE)ƒò,÷`Å ŸÏœÀàŽ(O´´´ˆÇõÛl6‘ÀžËã­ê06¨„еv s)))%%%N§óÂ… !ë!I dœ@qæòåËÏ<óŒøk¸’4` ×@{æÌž—©Â5…J sCCC|èÿìÙ³‹¥¢¢BÆçóÙl6ÍóÑ(è‚5ÑMåÄòƒë9âÚT^'==½±±±´´P9„0†ø¯<Ê©µµÕd2ñ5Wþä÷“t‹ &{ò¬ßïwBðýšgæóþgkkë]wÝU߈qZÔCw4†­SfMOÿꫯ [[[ÅnŸEàh™L&MWS“@y9?pM¬ÀiäÓ†Å×-FcB[êFëÿ`saa¡¸Ûû“"`F£1ˆÁ=åûÿ Do+Å%Q¼°¿¿ŸÏ%_·øš|Ð!ŒE\ÅYu»Ýîr¹(¥H¬áŠs¡Qú¿Ê]\£õÊCAÓ­”>)äë@„0FÕ7:‰¤yMc|¾“ˆÄ,\À  B B B B B B B B B B B¨×¾ÿ}[u 1%×Ü­ç??~ü¸ÉdâQ»ôŸríu牾¾>­ "{ç­+Ï}“o,æG‰[–;;;å—<ðÐãתu±"Yî¬o=ÿ9 &ž\ÆxœÝo¼ñá‡&"y¨ 1o7.\ "‡Ã1oÞ<":zôè7ïY{mÚ_ø×ê½÷Þ{ôÑG‰¨»»ûøñãDtüøqÍmþÁ×ܲœ ™LürüN:uà 7È7¡×ÖÖ>ñÄbVdÏh4ò¦ðË_þ’ˆf̘ÁÛŠxæô¾}ûxÐ%ÀX×¥ã}ôQEE…Ãá »»»ùöâ/¿üR,” KJÂ>j±££cÆì;®NccE‚‡°öóÿ)..#‡qËÊÊŒF£x^ !äuäßcŸÏçr¹øAIœÃ¾¾¾šš1‹2‘@"!ìîî¦ágsP˜ò_§NªyC~î¸sPûLä“àfxÐ<‹Åb±XŒFcYYÙÒ¥K# j«I Ïçãу>HDœ="Z¸páÂ… kjj ƒÁÛzµ¿Hì{ç­íyyyš‡5resçÎCVˆÁÞøðüùóòš<5œÜ•Ú#¼Î(±Ñ‘#GfÍše·ÛåøÉ•Ð`0h—$w–ä‡vÒÈ‘!X{{{À\HI,'sP3H¨ÃáÐ$PCvË-·ˆiþ±Û¹s'ÏrIœ>}úàà ÕÖÖ&v4)ŽŽ®]»6%%…Çc7Üpƒ¼‚湺òx×4<äpæÌMŸ*%%Å3bKFsæÌ‘gëêê‚Dz/++ÓüÛÊ?v|`Œµ´´p“AR„0²½S úý¯sÏž=wÞyç„·*Þ-Y²DóÏ’““#Ï˳|ŒZ¨««+((àiƒÁðÓÿxíª´26$ø>!…™HsHf<Äy2ïw͸‹ô[ù‡/ø¯-g«ÇÚº8ø!ÔÐ$pœe˜ü¯2šI=.]º4ÞfʼnD¡¸\#œq&PÞŸIæ|Êß=\åËbF[^‚a¿ß/Ÿ>QQq¢gG4øèNâI–3CCCÛå2èõz‡††®\{eš–ÆqéYpŒ±)ÁCèv»CŽ=†ŠáyœÞò<Ͻ÷Þ;88è7Mž¨6Ç#¯×ë÷ûûúú促“3æŽèv)ãH"‡pÕš DþcÇŽqT í@DšdŠ¡W˜æ\–ˆ oXÇŽ#"q5\’ó›&;‡£««‹ccýýýòjcØÙ;{ö,_1uæmãogÌJäjL™2¥¹¹9x¹tšiî±(((àál5ä&y$¢S§NåççsÅÂÇ/Y²„§Ýn·œO¿ß¯ÙÙÓ\–ijœÀ†††«×òXàf."š2E;:JÔʳ~¿Ÿo/ôx<¾aš­'iiζknYâKØüÃ"¿•|SÂ'’$„2ΡæFR=ĦóÙgŸ‰¬z<yIJ¤å7Mìíí•ï`¢‘Wüé¼ M$°¨¨ˆû /¼ðÂĵ4%x/v^ù‚{÷î þë¨Ê {ë­·Ä4ö e'úOœ89‡bìápÄÿN`’ô2<„4œCù^µàN)éèˆÊ³ܹs'¥¡ ÓôK5"çPœ ’˜ØGe(IÌpŸÿÏ7Þyk{iiiii)ýìg?Óùr¿ßÿæ›oÑ‘#GΜ9CD«ÖlXXvÕš·†(¯öDÝ\š+/—ÐÑÐÐPÈ Œ¸ &aÿ")B(È7O.Z´hÑ¢EbV~؉|àÎétž>}š_xË’¢[¾Þ– ,Ž" ?[„Ý}÷Ýb:¸šL¦@ ÈeðÅ_,™‘à?x ~S/Ä‚ÖóŸ›L&ù<¡æüŸ‹gä@2dOH®JJN]}¥$–øfbB B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B ØÿL£Ü‚Ó8J IEND®B`‚xdmf-3.0+git20160803/Data/Baseline/CVS/0000740000175000017500000000000013003006557017116 5ustar alastairalastairxdmf-3.0+git20160803/Data/Baseline/CVS/Repository0000640000175000017500000000002313003006557021215 0ustar alastairalastairXdmf/Data/Baseline xdmf-3.0+git20160803/Data/Baseline/CVS/Root0000640000175000017500000000006413003006557017766 0ustar alastairalastair:pserver:anonymous@public.kitware.com:/cvsroot/Xdmf xdmf-3.0+git20160803/Data/Baseline/CVS/Entries0000640000175000017500000000015213003006557020452 0ustar alastairalastair/IronMagic.png/1.1/Sat Jan 10 00:09:06 2004/-kb/ /IronMagicStride.png/1.1/Fri Jan 16 21:08:07 2004/-kb/ D xdmf-3.0+git20160803/Data/Baseline/IronMagic.png0000640000175000017500000003013613003006557021046 0ustar alastairalastair‰PNG  IHDR,,ö" IDATxœí{p÷uïÏ. ,O‚ !ð-ŠE½_–,Ùjd»rüh“(¾vܤ“8×¹µçæ¶“™¦™d:õ¤3M;­=nÓëLnãI¦²8‰í8­"ɶdK¢^¤¨—iI|H"E|‚ÄsìãþqÂ_QêEÚ’y>£Ñ,ÀîËýî9¿s~¿óyüO ~ˆ¼@ó!Ap†DHœ!gH„Á!Ap†DHœ!gH„Á!Ap†DHœ!gH„Á!Ap†DHœ!gH„Á!Ap†DHœ!gH„Á!Ap†DHœ!gH„Á!Ap†DHœ!gH„Á!Ap†DHœ!gH„Á!Ap†DHœ!gH„Á!Ap†DHœ!gH„Á!Ap†DHœ!gH„Á!Ap†DHœ!gH„Á!Ap†DHœ!gH„Á!Ap†DHœ!gH„Á!Ap†DHœ!gH„Á!Ap†DHœ!gH„Á!Ap†DHœ!gH„Á!Ap†DHœ!gH„sŠ‹-;[*ËEüw©ëï7Fxäñ?åÝâ& 8N»Ý^[[+Âùóç ŸÏÀjÝÉ·…ĵx7€ø¸ôvÞ²e ¬X±BUU˲@„ 6@.—€|>ïñ¨S|›J\rG‹žæææõëׯX±_ ‚ Bá$IZ½zu"‘h¨Uy4¸d ‹›Ú yíÚû«ªªðeuu5˜¦)Š"†Ç‰„,Ë÷Þ{ïùóçË“Ã1ú£ß^%,bãç@×u|éõzÀ4M|iH’äñx$IE±±±Ñãñ„üyNí%®‰°¸Y¹r%n\Uˆ$I~¿DQ¬««ûÄÛHÜòLŠQ].ÔÔÔ€¦i¡P,˲Ùlø™x<.†g •J9΀;K*œZML‡,aqÇqCÓ4ÜÀè(ƒiÜn7“"q[A",zâñx:6MÓ4MÃ0pc¤’$Ùl6›Í&Š"†j`ýúõ|LLƒÜÑ"Fõ7LLL@:F¿´æ‘†!‚eYÌ*ö î%,n½û÷ïO§Ó…û ÈvbçpÇŽ»wïþ$I\²„EÏÁ£ì0rìØ±ÏþóÑhTU•eßÍd2J¥ð­‘‘Øx÷v~í%¦C–p.‡ÐÀÀÀ/ùKUUUuú°—ËÕÙÙ™H$‰Ä[o½¥xë¹4’¸4€{N‘Œ€ï}ï{̶¶¶ÂTõ‡?üaóÊû86¸*$Â9Èéã»AÀä!,X° —Ëå¬R¾­"®õ ‹ ;ŒààEQ.™WýÌò5÷¾Lf?‰†aÑ YÃ=ô`¯G¨íÞ½ûرcõMwsnñ1 5ûýÑ7 ò,;Ž\.'B}}ýÚµkýë_S¸¥x!5û<€ ‡ÃãÑàÁÄQ£|ðÁçc¼ÚI|4lÍË7ðnq=/ô|éK_r»ÝK–,ñx<ªªÚíöT*e†¦iÉd²±±1™LŠ¢hYV (ñÙû&x·š˜”'¼­¹ÔuÈçó@$©~ UÃÑØ^¯÷Å_ÄK’”N§ËËË7­¯]³<Ì­ÑÄ,!wô¶æ‹_ü"¸\®ŽŽI’àÈ‘#]]]‰DLÓÔ4-ö÷÷?ýôÓÑhTUÕÎÎÎd2yüt”s뉙AyÂÛ¿šþìg?‹3w;;;@Ó4}VSSc·Û÷ `q'xùµ}¼ÚL̲„·5©Tª··=Ï .Àùóç-Z„s”¢Ñ(NPÒuÝn·‹¢899 èÁʼnð¶F„L&sùòå@ àóù,ËZ·nö =$“Ièïï?~ü¸Ã]×y±s‹‰ÙC™ÛšœUjY–ßïgÕDÀn·ÛívÜ£ªj$Arn+ñQ!Kx»óÜsÏamßõë×—••€eYÕÕÕ‚ ìÙ³'•J)°¨¡ÀLq°~UÎÓ-++ëêêEQ’É乞零„ÅÁ±ýíGÿ~ÿ÷õêÕ{ö}@ù9YÂbå{ßý:Øíö–––×s„wsˆfŠA€ †ñw÷w¼›C|,hìhñ!èƒ<òˆÝnºÿþû/_ú0•¡çi±B}ÂâÃ’¼ÿþû555[¶l9zô( Ûx7ŠøèÐã³(·†±wï^AÚÏ ñnñ± KX¬´äÝâæ@– 8C"$Î ‚3$B‚à ‰ 8C"$Î ‚3$B‚à ‰ 8C#fŠ˜KJN'ȲŒS~óù<¾Õrì"dž³‚DX”¬Xò_ëœmÞ¼K’ ‚ÍfOŸ>­iÚ¦õµ¯½öZEíz~m$f Mê->šê½°páÂ;î¸EÁ·°øZkkkgg'üøÇ?¦›nh>a‘ÑòÞ/¶oß¾hÑ¢Õ«Wû|>\š«ÂTm|Y–eY.--]³fÍñÖ÷$G€k“‰@™bb|èÌóÏ?ïv»KKçŽbî+©ªªr¹\°}ûvE¢ušnk¨OXLx½^\ÍçóáZèâNQ±.0–$•eYQEQš››iÞÓí Y›†C{ü‘ß{ü‘ß»¥gÁuaj½^˜ª̵¹ñ^A"¼i¼ð ÷Þ{¯¢(¿·©áVÿ_ 7P‡¢(ªªz¥qËß"Ú¶º¦¦æé§Ÿ~ànÝYæäŽÞLZZZnÑ‘ßçÕÿóÔç+++ñ‹_ø|>EQ²Ù,L©n||<çÖuE‰ÇãÉdrllìV4 Ÿ!>>d oÛ¶mSUUUÕ={öÜôƒýë_€x<>888<<Fc±ØñãÇÛÚÚÆÇÇ=zžÕÕÕøù|>ÇGFF–,YòÎ;ïÜÜÆô÷÷À¾}ûöíÛwsñÄßüæ7ûûûÑÿÔ4-ŸÏ/]ºÔ²,Ì×ã~LT@<?zôèÊu7ßi\µ´ìÄÃ7ý°óaÑí;þ›ßüÆív¿þúëÿðÿ°{÷î‘‘At]¿|ùòÖ­[W­Z…R˲°OXR¾Œw«‰C",¢}Çÿýßÿ=€¦i€"<{öìØØØÙ³g@UÕ-[¶TUU=ûì³TŒ´X ÀLѰcÇŽçŸþ+_ùŠ,˘ ĵ{‘t:ý­o}kpp~ûÛß’‹ Ì¡P(—ËY–FEEQÅ|>ÿ­o}‹}fÿþý²0ʱ‘Ĭ ïÀ7¾ñ ˜Ê–——€Óét:>ø ~Ìçóýô§?]²d‰ßïo¨Uùµ—˜Ô',žüòƒuuuPZZÊ& bDthh'Z–ÕÛÛ ?ûÙÏ`jðZB»Uƒfˆ›Y¢{€W*çõž>}úÌ™3££££££O<ñÄg?ûYUU·mÛ&Y”H¸Ý¡ÀLpÿ=Ëq# N\Ò4M×õh4ªªjCCCYYY:€gŸ}vóæÍMMMôûý£4²åö†DXìz÷ô“_®R¥££Ããñd³YAÐÍf³¡P(N³Á¢Ç€û§§gõêÕo¼ñÆèd–gë‰Aîhq`Yœ— À© Í4ÞsÏ=€CF»ººx´—˜d ‹ƒú§úÞ÷¾^¯W’$¤,ˆa(Š‚Åöööl6»lÙ2UU‡††`J‡ÄmYÂâÀh|饗^zé%ŒÇ€,Ë0U]æÕW_moo€eË–ýñÿ1D£ÑD"ñ—ù—6g¿V3‚,aÑ00õÕÊ«¯¾ XÞ" ¢SÚÜÜ ~¿ÿÑG=pà —~Š[s‰CyÂâcë]‹Ng0Ã0ÊËË3™Ì×¾öµ;vœ:u 2™ŒÍfÛ¸›wK‰A",bïÿ•Óéܾ}»Ãá`JC¡Ð;ïÈ»iÄ, g(0Cœ!gH„ÁJQ7{þó'n··'''?ý_åÛâ#@",2δïöù|€åÕ{ì1˜ªï400€syÛÚÚ% ‹aqpáüA§ÓYQQ±|ùò †ãEEQÄe'p f)¶lÙòî»ï–t8}útyåj¾'®­ÊôÑIMtæµq3?iê“N9/˜IÑJµÝ· ò&‡ïúðýªªªP(TYYYRR"IÒÂ… EY·nßïw:>ŸK?år9Ã0DQlhhðûýƒƒƒ¡P(à“ö½ûV¤rñMlRë¡_G:W­¨÷{lЬ«Šé”óGZÞ.,º‰g™'PžpÖôõ‘$iëÖ­6› =CQC¡P&“éèèMÓΞ={SÊ ŽžÚ°aÔÖÖâµŠŠŠÁÁA]×—.]šJ¥pF…Íf[¼xq,Ñ¥ù|¾µµUÓ´ÒÒR˲^ýõM›6%“ÉýèGëîüÃÙ¤sgöbõ{<56OÓ4Ã0víÚ…¦øÈ‘#Í+ïû˜'š?gGÈŸ‡©ûÏçómÞ¼FFF ÃÈår~¿zzz,ËzóÍ7?N`3{ÙëõVUU麮(J( ŽÛ.--M¥Ràr¹Âá0.Æ8ÉP×uÃ02™ÌåË—aj.E,€C‡9= ?r«NßõÄO¸\® à¹dYF#ŒÇÇ üíííù|ž¤8C¨O8S.uZ¿~=€°zõj\(×f³¹\®|>¿hÑ"H&“àóùúûû?ýéO···÷ööÖ5nží¹üjºvé\{Íarr²ªªêá‡njjÂ[»‚øIÃ0>üðÃ>ø€-Š lU]]ÝÙ³g׬Y“Ëå:::dµv¶­:qì?·oß®ëú¦M›&&&pY¨X,†½S—Ë•ËåR©”×ë­¬¬4MS’¤“'W×oœí‰æd gÄ…óW­ZµaüéE)))a¦\..xàÀ†††D"±wïÞæææöööÙN&ò«éÚÚZX°`¸ÝªñññÇ|ùòåPWW‡áPA ã1’$¡ILͯ·, ?l\Óuýܹs–e½öÚk(¿ . Q=þ<š©'NL¦gZqãÚj¯×ÛØØ˜Íf± x8N¥Rèê?ŸÏŽŽz—.]áÔ©S£“ò O4!wôÆ,]ºtÙ²e–e…ÃᆆßÉ)‹‰¢ˆb@sät:™‹hY–¢(¸˜î yëWÿï©§žª©©±, kŠ€¢(û·ûÐC9ÎÚÚZŒ»†~æ‚ Ð$¢ìûúú$IÂær9I’²Ùì¾ð…Ÿüä'£££ýýý¡P¨ººÚãñ|øá‡«V­š¡Ï´ïÞ¸öÉÂ=v»ˆ/ Ã'ø»Ýîd2¹páBèïï×u=N\:u+ÖÉ™PŠâHÖð²eËdY®©©Y¶l‚€AA ÃeY’$I’òù¼$I(¼\.§ëºªªgÏžmnnNNæ ÇõOÔX¿`ãÆ²,Ü£ªêßÿýß×ÔÔÔÕÕ±…AËËË@ À.+<^¯×ívã2i‰D"ø|>Ó4ßÿý|0‘Hx½Þ`0899™Ëåâñ8„Ãá‘hOÞt^§a}=Gp¶>:Ã’$y½Þl6Ë– Ɔdp£5¦iÚl¶X,VYY™N§uS™õÕŸ;z=:N¾ýÕ¯~U–åµk׺\®H$ÂÊ~:,y†^(ŒŽŽºÝî\.‡ž˜aÃÃÃv»ýðáÃñxܲ¬TÎwÕ³,ªq¹\. ½` Eñ¹çžkhh¨¯¯EQÂá0@°ÛíkÖ¬©p(Jñرc¬y8¯÷âÅ‹ÐÑÑašæ·¿ýmôŸívûððp"‘H§Ó>Ÿï7¿ùMsss˱‹×ºÎ|úé§`ñâÅP[[{úôéÚÚZŒÇØív‡Ã‘Ëå°mº®çr9MÓl6› CCCÉdòÂ… ©TêàÁƒT‰øªÐîë±bÅ À!)PPx—‰»d ŒÍTVV@WW+‚æõz¯¢i«[WWW?÷Üs555‹-!‰`< ƒ>Ÿ¯»»ûÂ… ======@ ¤¤)I’ah?›››³Ùìw¿û],H388Èâ™°nݺ\.·´1pÕ†]8ðÏÿüÏm6[II `Ĩ®®®0*Ë–C„ÏœíÁÌŠ®ë,BLƒDx=.\h·ÛN§$I¦iš¦éóùœN§¢(Š¢¸\.»ÝŽ ôb¬2˲¼páÂÚÚZ·Ûíõz·mÛæõzYÅÞ駨rš¦‰Góz½x»?ýôÓ‘H»U#›Í†òCÇoÚ™_ZRR ý~?ZTÔá’%K,ËúÎw¾ãóùЀWTT˜¦éõz-˪©©EñªkȘ¦év»E‘e¨ª*ºßN§Óf³Y–…NÝn·Ûí²,+Šâp8t]w8Øk]¹r%:íѾã7é/3§ >á5±ÃHEE…Ãჹ\NQ”êêj´xÇ›¦‰ªÃÛ³}}}¸=::êt:qeùÒÒÒÆÆÆ3^švŠ-w.r»Ý555`³Ù€(ŠÏ<óÌÂ… W­Ze·ÛëëëeY¶Ûíáp%Íäêr¹\.—ªª¸Ï‡ÃKÄ€×ëÅðŒßïO¥R‘Hdppð…^xì±ÇFFFp°Ûäädii)Á±Û퓱˖è.lá7þôI˜²üápû¸,”ÇãÁdž…dYF[‡/5Mó»ÝîT*uùòåP($Ër"}‹ÿlEYÂk"Š¢ÍfkjjÚ´iS¡§W 1 Ã0 ›Í†#6+**$I²Ûí“““˜[Ç1a²åÎEhÓét&“‰Çã>ŸÏ²¬êêꦦ¦\.W^^ŽËîb^ŽùÀ ¡ r8‡ƒ¹|è(bN°*Tcc#®*ã÷ûqMµP(ät:›››—.]êv»ñc…°T$°H Øl6‰A ½M¼t,vZ^^žÍf¯å t]® æ°×WWW'Ër:v:x»nÀTw‘ÝvÑht&§ÀN˜¦ùðÃÀ·¿ýmÔOUÕïRüÓˆz¶ÛíxÓ3… «ŒÊÄ=x¦+ÜX¶lÙ£>*Š"V€‰‰ Œ”À§>õ©«¶³P?‡—"egÑu}Xøu”ë´þ3Á <áõ( 9LLL¸\®ñññ@ Ph  •Jɲ<íλ!˜N!N?òÈ#`YVCCCmm-*Mt8Ñ©mËO²RÜÌ åóy¼ã1fkY–aªªvvvb‡-N¯]»£( ÆK ~^|`:¾¤¤uš¦1;É.Èʾ.Š"…g¦C"¼&Ø·);PYY‰ÌÔ ‹Çœ‚FÙw¯Å½[–`Ð5Nßyç°k×®¿ú«¿Z¿~=D"¼w}>žN–ºÀ#LkC’$]×ÙÇÐU‡ÃÑh´¼¼×WC'SE]×Ù³U´õ®Å{œcGcŸÇí§žz i³Ù؃ “É`eš¦(Šx t&''óù¼Óé¼áe™Ÿ;zMм 1ÄøÊ ¿rC¶Þµ}3r »ví¯WVV²^$ñx<†ñûý˜q»Ýn·ÛçóaH_z¦À—øa·ÛUUU çà\ÄÆÆÆk¹¬yWÝ/ÂøCÜFcÈè“ãEIø ÀޱÓéìíí=qâÄL®Ï|ƒ,á5‘”êL&cÆîÝ»ï¾ûn˜2¬oSh*1B3mÿµ@­¢‘A0‘ˆCRæÅÙív6Zލpµ¦+q8ÙlÖ4Mv´E‹Âéæ<$ÂëQØïºR‡ÓLÐÌÈÌ *ñûýØOCG’$Y–…1Y–N§<f17X¸“Ål1™îñx0ÓÈxSR+W®dÛ¬W‰ÂÆã3¢Îívû‘#G>þyç$$Âë¡xë Ã`üD"‘Ëå2™L>ŸÏçó¹\£‘ù|SÕÌ"]™p›F]]N üþ÷¿Ç{{{qŒ(Ö‰(ü$K0²{}šø áµL"@œq?Dá9ó«UUU¦iŽŸ;w.—Ëñè©jš¦iZ<?sæŒÝnokk«mØ4«sÍH„7 ½½½§§gdd_b„ïi&†Âa4³âÿñ±7¸uëV¸šsÈNw}^¹Í`U戦Óé¥d©Ë%K–àÆÎ; ?À¦²SbžsZfŸ(„37ÀWº$™L¾ûî»›7oF72‘HȲÌâ¥6›-›ÍºÝn¼×5M ƒ‡ºáÁaj–p[[,‹ÍŒØÝÂÎ'J{_ìì…dûÙ¦ ðhlþñ+¯¼ÒÑÑa³ÙpLÙuZØÑÑÁFŒÛíöÑÑQ»Ý¾bŊÇ744ìܹsñâÅ‘H½qfƉÄÀÀü½÷Þ›H¹nx5æ-d oÌÄÄ&µÇÇÇqO.—{_05Qpêν(¤0'~UÚÚÚ@&“±,ëÊI P`åfnÄØ' ýÛ|>ö kìºJ6’(„,áLé蜀)s‡#]Ø j¼é1Ì‹K§Ó{÷î¦@t§ÍŠÃ0ZZZðh—/_ÆCøVa¼pãJï”)_bºÜ4ÍÎÎNö.Ê’%'o˜\ùÙÏ~†˜!D±á|b˜†Î¼Öt:ÍNG œ d gÁ¡C‡V®\yøða¼}ƒÁà‚ òù|4 xßã½8<<ìt:/]ºÔÑÑ‘Îû§G×õŽŽŽ7²—¸aYÖ[o½õÌ3ÏàX–L&ƒkØÀQ†ÁûÞ²,ÜÏ$ŠmÐ4 ›jAkœÉdöïßÿãÿžhNÓét>ŸgCà7Þøâ¿øƒ½QØàª…žyæÌjjš&Bcc£ªªÑh´³³]t좩€|>êÔ)€«Wô !K8 &R®“'O=z_&‰ÁÁAT îÁ|Þ”û÷ïÿùÏ>ž¸f ¥t:­( ¦Ù¨€l6û×ý×'Ož€K—.€eY8©Ÿ}±0KQh ñ3…yŽññqTxww7Z?Ti2™¬®®F{.Ë2[[æ:¿½¾éîÝ{ϼ÷Þ{øÁ`íC¬|ÑßßßÝÝï¾÷Þ{mmmת©CLƒ,áì˜H¹\o¿ý6lÛ¶ Ë®% ǃ¾hšÖÒÒ"«µ×*ò÷Úë«MÓDQÄéH†a˜¦‰ q:ÉdòàÁƒK—.eÓXϰP…•§)Ð4MÔX>Ÿïéé‰ÅbGý·û7H&“¥¥¥“““¨O¯×‹1Q³Ùl6›f ÉšÁÀÆOž<‹ÅX{ÐïÅœDÎ*ý¨x>B"ü(à3ž™D4·üÕ¯~Õ´üž™™Çã^¯×ãñÔÖÖâ–|>ÿüóÏc¹ë¶¶6LNæóy˲"‘~‹ê.,7È&ÂTß5‘HôôôèºþöÛo¿üòËétšy¡øIÓ4S©”a¨Ø‹/:thõ]§Á¦- -Ç.ž>¾Ëï÷³RÈ¿þõ¯MÓ\¹îþp‚A%¹!YßûÜç`ª:›ÇãÑ4Íétb‡SÅ?/È~.IDATû³?Û°aC>Ÿollt»Ý–eá”?ŸÏ‡);ŠqÎ|>/Šb.—C‹„AÚ#GŽèº¾k×®;wNLLÉd2ÃÃÃ¥¥¥===Š¢àdù±±±3çÆy]y ‰'‚>xÏ=÷(Š‚3'°èñx$IÂ:k/¾ø"¾ÕØØÈÆ‘¢üJKKÙhiT3‰š¦uttär¹'Ÿ|¿…²´Ùlhôb±X(Êd2©T*›ÍŽŽŽ~p>Æã2Ìw¨ÚWDÏšVËee±^“×ëu:†a444üË¿üKyyy4F£(WÌþ%‰D"‹Å&''q`šÄÖÖÖ·ß~ûÙgŸmmm ƒ8±ƒ«ù|Þívã@˜št»ÿþèEéø@–?ÖTåóùH$‚Ž(È‚ n+W®üò—¿¼mÛ6ÀÉM«W¯†‚aàèÑ£88æÍ7ßܹs'[ƒqQ7ÂyúØiÏårýýýƒ£³}NÜ,H„·k–‡»»»Qc6›mxx¸±±zÙlvÕªU8hûâÅ‹h-ÿäOþäþûé믿þÓŸþÇmâTA°\/ê-—ËÕ××_¼x=Øl6‹©” .ùB"¼]è9w`Û¶m–ea­§ááá@ ÀFœá„ ˜Rã"±cÇ—¦ÀÁß…Ãb`ÊZbWÐåráÒh–e $“IŒv¡ÅíÂÂÅwu]J÷õAñTUUa©ÎÂj™=z”…gìv;KÖc %Ó4Ù`·\.‡.++‹–ÍfÛÛÛ1xÓÑÑá 6íÆc¸‰[ YÂÛ¿šf:ÇÃòû÷ïÇ ª×^õ‹—ZqcÆ߅Ü0ƒoš¦Çãiii¡uo7H„ÁŠJgH„Á!Ap†DHœ¡Å ý.Ï6:9ëBÚñ‘!Kø;p±hY–/_¾,YW/zOÜD{ÛRùô¥øØYÞmá YB€HþàžÀØ/^|óÍ7MÓ¤Á\·Yý‹¿ø‹M›6ÀÎ;ûÛßÎçyÀd Á«$Ù6ŽJùÌg>>×õªâUž|ê©§°&ˆa8Àu>C–â·e%:;;±Ö=NŠÍf³“iõF_%fC Ëq› zê©§vìØ1o˓҈â“F‘b°nÝ:¬‹ÇÛÚÚ®¬I7 KH|Òdôì?Ü]°oþ*H„Œ_¼ò}øÎw¾SÛÛÛMÓÜ·o~à?üŸüZGÌeæ;ú‹W¾‡MÓܺuëÄÄÎúÙ¸q£ªªçÎÃÙzøÿÒ¥K‰Dkk«a'NœÐu=cA>÷èÿæüKˆ¹Â|!jÕ…å=ý~ÿúõë³ÙìŠ+TUD"¢(z<Q±øÊÀÀÀw¿û],ü‰Dººº     GFFæÉÕ›-¿|õŸ±›Xü™Ï|¦¯¯ï¡‡þ«˜".‡s‘ ›Í¾óÎ;páÂ…»ï¾{ïÞ½Ùlvž\Þy!“­;E))) CCC¸<ÂVÿ\·n¬%nƒÁ ~Ø0Œ3gÎ`Áéîîn¿ßF=ω'æÃœ9¿|õŸKKKËËËu]Çr¬¢(–••áãottÜn· l8#íììd ‰ëºŽ+Õ¤Óéñññ‡?÷¿>ùßò‰1÷E8ÜBE¯×Ël¡¼¼«tâÍ¡ë:[Ò‡eY.— ËZ‹¢ˆ%Éð“““†aôõõáò ===wm}”Ïo»ÍøÕÏþoeeeee¥Ïç“$) ÁTêµ¼¼ý ¬pÃVA¯Ä4M¶¨†×ëÅË~éÒ%]×Ãá0®o®ZÃçWÝzæ¸õLoYY™,ËápØápƒA6EÝáptwwO[}oV3¢¦¦¦ª³@4Å ,ÁÔÑÑašæÐÐPkkëܾŒ3áõŸ¿pß}÷™¦‰ÞV4ƒ’$¡Ñ³Ùl¥¥¥lMQ W˜*\ã ÆÆÆ@×õ3gΠEÃ9Œ9-++3 «è†B!Ó4E1MSUUY–׬Yƒ÷J¦\¦L_:–$ ý+¬Pæv»“Éd]]]ww7[Pe>óÆk?hhhÐ4­ººZ–åÊÊJ—Ë…®.¡ár¹|>8NvµàðáÃxì0]±±±ÆÆÆL&344„KÓÍIæxñßʈoÉ’%ét:ØívQý~?ÖÇ…>ñyÌ ² ÜÏß”$ ëê*Š‹ÅpYˆ\.çõzqñZ·w×ÊR¥¥¥¸:ZUU•eYXËØ²,¼àN§«†Ûl6¼þXꦦ¦ººº²²ß²ÙlØEÄåm6[.—ǦËaŒŒk7hGq2Ç-aUU¬\¹Ò²¬’’I’°´®ÃáÀ'4vQð¶€)GT×u\(K$¥R©L&c³ÙÆÆÆ,Ëòx<###(HìçÀûZåÞ/ðø‰üù7~ÔÐÐàr¹<Ouuµ¢(¡P#^8&ËÃáTv»ùœ¬†?¾dË0bÍ8UU³Ù¬ÛíVUutt´¼¼|®Ã9.BtopÕh|Ôñ‰‹à+¿(Ë2FkP–Š¢d2§Ó‰² …BÃÃÃ(c¨««Ãµ£ç'555555:fݼP(äóùÜn7Ô–e¥(^7ˆÆ? sDq#‹¢XRR‚ò©µÏ}’¿ëcŽÏ¢p»Ýµµµ>ŸÏãñ`ŸD–e˲XXüª DÐ#bÏé²²2|Ø;UUUUUE–åúúzvÍOð'IúÇúxÁY¬ð²£nÙ2©L›Í†½VûxN2Ç-!Ÿ¾>ŸÏëõ²©(ŠX—ÝÓjW³È࿯Îy%óy>³~v»]—Ë…’ÃkŽúÁaFø±B†!îÁè{ ûðØ!d‹¥ÎIæ¸ •ƒ. ó0¯¿:ôuŽº®ãíÂî§ .T-œË!®ëP˜Z˜fú˜r\.>øÐ¸áxšÂ?;‚¦iL–#…ë:,s€9ðæ4˜§í¿êApáªñÓŽsý.¹>…a-–Ý2ð*áþkY¶kýØbUs9n Ó4 GfÏʲ#à× #{¸ÝÕÕ•L&7êÜÌÌ¿@™awN×u4‰ÌÁ+†ÿ3î„+$Šy#Ë²Ø ›¹Ç·„Ùl6›Íf2™L&“Ëåp{VG°,+NkSd2<¦¦iÙl©¾E/†‡‡Ñ?/ ƒÿ£SzU'â:\i*¯ß!/væ¾%ŒÅb8ÀEUU ‹g2L߀a, ÿ=0£ëz&“aËçó™L»‚˜cƒ¿}>_æ/wßóØÈÀIÓ4³ÙìÒ¥KûúúØyQq™nQ1:}%ÓV¨@MÓPÀø'»¥¿‚#sü)~ñâEMÓ0…ÍfY.Áårµ··CA t(¶B²’$)Š¢(Цi%%%½½½---·þ§ÜÖ0¸|ùr¶Ç²¸1ÎAòù|jŠd2™J¥Òét:Æ UUAxë­·P‘H$‘HÌacÎþ°Búûû³Ù¬išñxüôéÓ²,†±jÕªááaÌøãKÌz<|9:::99ÙÜÜìr¹Ø0Ѿ¾>¹dÉœ 0Ÿ}øá‡EQt:ccc˜šßµkÔÖÖš¦ÙÓÓƒ:œ–Ve–­K3Þ{iD@E64bî1ÇE811‘H$OI’<ØÖÖfœ aš&NÄìÎxå•WàÎ;ï„‚]__ßË/¿‡Ãáp2™¤©L½½½°}ûöW_}•ít¹\Ÿþô§± ‡·nÝšËå:::ÐЧÈçóhÓétoo/¦÷îÝ‹<]×Ýn7á4'™ã¸›+Àçó¹\®X,V[[{×]w•——ïÛ·obb¢¤¤¤¯¯Ïáp444@ Ð×××ÛÛ›J¥ÆÇÇÿõ_ÿuttÔét>øàƒ‚ ìÙ³'‘H$“ÉË—/ŽŽÞqÇÇŽÛ³g§d1ï_ÉŸ… +[쪯¯¨¨¨Úît:ý~?š¸={ö¬[·n||¼²²òÃ?Ô4 3‡8Áײ,ì8 —••1Ãï÷ŠóøÉN~?ñ2ÇEIU.ð¹\.Y–+**ºººpžÛ¥K—î¸ãŽd2©ëúòåËY#†aFSS“×ëÅbË—/ß½{7X–uéÒ%˜rœÎŸ? /¿öÉç_¤r/þà?XµjÆ¢GFFr¹œ(Šétº¥¥% ʲ<44¤ªjccc*•ÂK 6›-‰ d2™þþþX,‹Å‚Á`6›mii¹|ùr<ïº0ÄûWÞæø¤^¤¶B…B‡#¸Ýî;ætã´]6p#íííiÀáÚ¿{G£Q,»Édz{{ÝF¿æ¶&=ÙµvíZI’dYÆ©Ïçóûýååå¹\.‹y½ÞL&³fÍì㱉K###¥¥¥™LæÜ¹sñx|hhhÕªU@ ­­m``OvŒðýu·ˆy!B¨(êêê°s¢ª*æ÷“벌†aà^Ð4mhh(ŸÏcá“Kš×¯EÇÉ·«ªª***ªªªLÓ,++s»Ý^¯×n·£’L&±¸!þ 0§YÜsçΡ§zþüùX,Ç£Ñ蹞Ïv+™/"d¬YVUµ¼¼‡nÃTâƒrX‰w:NÌLôõõišÖ~fnúB·‚Äø¹úúú`0˜Ïç/^ º®›¦‰EF`Jr‚ Øív¼þ胠a´Ûí™Lfll ßêîî›Ã«Ì;Ÿ0Ë›‚‰DÐô™¦ çÑco\×u Іa·Û‡††4M³Ùl}}}gÎómÿ'ÀÜ1CðåôÙ1ö?qUæxž nH„Á!Ap†DHœ!gH„Á!Ap†DHœ!gH„Á!Ap†DHœ!gH„Á!Ap†DHœ!gH„Á!Ap†DHœ!gH„Á!Ap†DHœ!gH„Á!Ap†DHœ!gH„Á!Ap†DHœ!gH„Á!Ap†DHœ!gH„Á!Ap†DHœ!gH„Á!Ap†DHœ!gH„Á!Ap†DHœ!gH„Á!Ap†DHœ!gH„Á!Ap†DHœ!gH„Á!Ap†DHœ!gH„Á!Ap†DHœ!gH„Á!Ap†DHœ!gH„Á!ApæÿÛêWõ=§oIEND®B`‚xdmf-3.0+git20160803/XdmfRectilinearGrid.hpp0000640000175000017500000003302013003006557020467 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfRectilinearGrid.hpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef XDMFRECTILINEARGRID_HPP_ #define XDMFRECTILINEARGRID_HPP_ // C Compatible Includes #include "Xdmf.hpp" #include "XdmfGrid.hpp" #ifdef __cplusplus // Forward Declarations class XdmfArray; /** * @brief A rectilinear grid consists of cells and points arranged on * a regular lattice in space. * * XdmfRectilinearGrid represents a mesh of cells and points arranged * on a regular lattice in space. Points are arranged along coordinate * axes, but the spacing between points may vary. * * In order to define a rectilinear grid, the coordinates along each * axis direction must be specified. * */ class XDMF_EXPORT XdmfRectilinearGrid : public XdmfGrid { public: /** * Create a new rectilinear grid (Two dimensional). * * Example of use: * * C++ * * @dontinclude ExampleXdmfRectilinearGrid.cpp * @skipline //#initvalues * @until //#initvalues * @skipline //#initialization2 * @until //#initialization2 * * Python * * @dontinclude XdmfExampleRectilinearGrid.py * @skipline #//initvalues * @until #//initvalues * @skipline #//initialization2 * @until #//initialization2 * * @param xCoordinates The coordinates of points along the x axis * @param yCoordinates The coordinates of points along the y axis. * * @return Constructed rectilinear grid. */ static shared_ptr New(const shared_ptr xCoordinates, const shared_ptr yCoordinates); /** * Create a new rectilinear grid (Three dimensional). * * Example of use: * * C++ * * @dontinclude ExampleXdmfRectilinearGrid.cpp * @skipline //#initvalues * @until //#initvalues * @skipline //#initialization3 * @until //#initialization3 * * Python * * @dontinclude XdmfExampleRectilinearGrid.py * @skipline #//initvalues * @until #//initvalues * @skipline #//initialization3 * @until #//initialization3 * * @param xCoordinates The coordinates of points along the x axis * @param yCoordinates The coordinates of points along the y axis. * @param zCoordinates The coordinates of points along the z axis. * * @return Constructed rectilinear grid. */ static shared_ptr New(const shared_ptr xCoordinates, const shared_ptr yCoordinates, const shared_ptr zCoordinates); /** * Create a new rectilinear grid (N dimensional). * * Example of use: * * C++ * * @dontinclude ExampleXdmfRectilinearGrid.cpp * @skipline //#initvalues * @until //#initvalues * @skipline //#initializationvector * @until //#initializationvector * * Python * * @dontinclude XdmfExampleRectilinearGrid.py * @skipline #//initvalues * @until #//initvalues * @skipline #//initializationvector * @until #//initializationvector * * @param axesCoordinates The coordinates of points along each axis. * * @return Constructed rectilinear grid. */ static shared_ptr New(const std::vector > & axesCoordinates); virtual ~XdmfRectilinearGrid(); LOKI_DEFINE_VISITABLE(XdmfRectilinearGrid, XdmfGrid) static const std::string ItemTag; /** * Get the coordinates of the grid along a single axis. * * Example of use: * * C++ * * @dontinclude ExampleXdmfRectilinearGrid.cpp * @skipline //#initvalues * @until //#initvalues * @skipline //#initialization2 * @until //#initialization2 * @skipline //#getCoodinatessingle * @until //#getCoodinatessingle * * Python * * @dontinclude XdmfExampleRectilinearGrid.py * @skipline #//initvalues * @until #//initvalues * @skipline #//initialization2 * @until #//initialization2 * @skipline #//getCoodinatessingle * @until #//getCoodinatessingle * * @param axisIndex The index of the axis to retrieve, (i.e. 0 for * x-axis). If no array exists at the index, * return NULL. * * @return Array of coordinates along requested axis */ shared_ptr getCoordinates(const unsigned int axisIndex); /** * Get the coordinates of the grid along a single axis (const * version). * * Example of use: * * C++ * * @dontinclude ExampleXdmfRectilinearGrid.cpp * @skipline //#initvalues * @until //#initvalues * @skipline //#initialization2 * @until //#initialization2 * @skipline //#getCoodinatessingleconst * @until //#getCoodinatessingleconst * * Python: does not support a constant version of this function * * @param axisIndex The index of the axis to retrieve (i.e. 0 for * x-axis). If no array exists at the index, * return NULL. * * @return Array of coordinates along requeste axis */ shared_ptr getCoordinates(const unsigned int axisIndex) const; /** * Get the coordinates of the grid along all axes. * * Example of use: * * C++ * * @dontinclude ExampleXdmfRectilinearGrid.cpp * @skipline //#initvalues * @until //#initvalues * @skipline //#initializationvector * @until //#initializationvector * @skipline //#getCoodinatesvector * @until //#getCoodinatesvector * * Python * * @dontinclude XdmfExampleRectilinearGrid.py * @skipline #//initvalues * @until #//initvalues * @skipline #//initializationvector * @until #//initializationvector * @skipline #//getCoodinatesvector * @until #//getCoodinatesvector * * @return Vector containing an array of coordinates along each * direction. */ std::vector > getCoordinates(); /** * Get the coordinates of the grid along all axes (const version). * * Example of use: * * C++ * * @dontinclude ExampleXdmfRectilinearGrid.cpp * @skipline //#initvalues * @until //#initvalues * @skipline //#initializationvector * @until //#initializationvector * @skipline //#getCoodinatesvectorconst * @until //#getCoodinatesvectorconst * * Python: does not support a constant version of this function * * @return Vector containing an array of coordinates along each * direction. */ const std::vector > getCoordinates() const; /** * Get the dimensions of the grid, the number of points in each * direction. * * Example of use: * * C++ * * @dontinclude ExampleXdmfRectilinearGrid.cpp * @skipline //#initvalues * @until //#initvalues * @skipline //#initializationvector * @until //#initializationvector * @skipline //#getDimensions * @until //#getDimensions * * Python * * @dontinclude XdmfExampleRectilinearGrid.py * @skipline #//initvalues * @until #//initvalues * @skipline #//initializationvector * @until #//initializationvector * @skipline #//getDimensions * @until #//getDimensions * * @return XdmfArray containing dimensions of this grid. */ shared_ptr getDimensions(); /** * Get the dimensions of the grid, the number of points in each * direction (const version). * * Example of use: * * C++ * * @dontinclude ExampleXdmfRectilinearGrid.cpp * @skipline //#initvalues * @until //#initvalues * @skipline //#initializationvector * @until //#initializationvector * @skipline //#getDimensionsconst * @until //#getDimensionsconst * * Python: Doesn't support a constant version of this function * * @return XdmfArray containing the dimensions of this grid. */ shared_ptr getDimensions() const; virtual void read(); virtual void release(); /** * Set the coordinates of the grid along a single axis. * * Example of use: * * C++ * * @dontinclude ExampleXdmfRectilinearGrid.cpp * @skipline //#initvalues * @until //#initvalues * @skipline //#initialization3 * @until //#initialization3 * @skipline //#setCoordinatessingle * @until //#setCoordinatessingle * * Python * * @dontinclude XdmfExampleRectilinearGrid.py * @skipline #//initvalues * @until #//initvalues * @skipline #//initialization3 * @until #//initialization3 * @skipline #//setCoordinatessingle * @until #//setCoordinatessingle * * @param axisIndex The index of the axis to set * (i.e. 0 for x-axis). * @param axisCoordinates The coordinates of points along * a single axis to set. */ void setCoordinates(const unsigned int axisIndex, const shared_ptr axisCoordinates); /** * Set the coordinates of the grid along all axes. * * Example of use: * * C++ * * @dontinclude ExampleXdmfRectilinearGrid.cpp * @skipline //#initvalues * @until //#initvalues * @skipline //#initializationvector * @until //#initializationvector * @skipline //#setCoordinatesvector * @until //#setCoordinatesvector * * Python * * @dontinclude XdmfExampleRectilinearGrid.py * @skipline #//initvalues * @until #//initvalues * @skipline #//initializationvector * @until #//initializationvector * @skipline #//setCoordinatesvector * @until #//setCoordinatesvector * * @param axesCoordinates The coordinates of points * along each axis. */ void setCoordinates(const std::vector > axesCoordinates); XdmfRectilinearGrid(XdmfRectilinearGrid &); protected: XdmfRectilinearGrid(const std::vector > & axesCoordinates); void copyGrid(shared_ptr sourceGrid); void populateItem(const std::map & itemProperties, const std::vector > & childItems, const XdmfCoreReader * const reader); private: /** * PIMPL */ class XdmfRectilinearGridImpl; XdmfRectilinearGrid(const XdmfRectilinearGrid &); // Not implemented. void operator=(const XdmfRectilinearGrid &); // Not implemented. }; #endif #ifdef __cplusplus extern "C" { #endif // C wrappers go here struct XDMFRECTILINEARGRID; // Simply as a typedef to ensure correct typing typedef struct XDMFRECTILINEARGRID XDMFRECTILINEARGRID; XDMF_EXPORT XDMFRECTILINEARGRID * XdmfRectilinearGridNew(XDMFARRAY ** axesCoordinates, unsigned int numCoordinates, int passControl); XDMF_EXPORT XDMFRECTILINEARGRID * XdmfRectilinearGridNew2D(XDMFARRAY * xCoordinates, XDMFARRAY * yCoordinates, int passControl); XDMF_EXPORT XDMFRECTILINEARGRID * XdmfRectilinearGridNew3D(XDMFARRAY * xCoordinates, XDMFARRAY * yCoordinates, XDMFARRAY * zCoordinates, int passControl); XDMF_EXPORT XDMFARRAY * XdmfRectilinearGridGetCoordinatesByIndex(XDMFRECTILINEARGRID * grid, unsigned int axisIndex, int * status); XDMF_EXPORT XDMFARRAY ** XdmfRectilinearGridGetCoordinates(XDMFRECTILINEARGRID * grid, int * status); XDMF_EXPORT int XdmfRectilinearGridGetNumberCoordinates(XDMFRECTILINEARGRID * grid, int * status); XDMF_EXPORT XDMFARRAY * XdmfRectilinearGridGetDimensions(XDMFRECTILINEARGRID * grid, int * status); XDMF_EXPORT void XdmfRectilinearGridSetCoordinates(XDMFRECTILINEARGRID * grid, XDMFARRAY ** axesCoordinates, unsigned int numCoordinates, int passControl, int * status); XDMF_EXPORT void XdmfRectilinearGridSetCoordinatesByIndex(XDMFRECTILINEARGRID * grid, unsigned int index, XDMFARRAY * coordinates, int passControl, int * status); XDMF_ITEM_C_CHILD_DECLARE(XdmfRectilinearGrid, XDMFRECTILINEARGRID, XDMF) XDMF_GRID_C_CHILD_DECLARE(XdmfRectilinearGrid, XDMFRECTILINEARGRID, XDMF) #ifdef __cplusplus } #endif #endif /* XDMFRECTILINEARGRID_HPP_ */ xdmf-3.0+git20160803/doc/0000740000175000017500000000000013003006557014635 5ustar alastairalastairxdmf-3.0+git20160803/doc/CMakeLists.txt0000640000175000017500000000002413003006557017373 0ustar alastairalastairinclude(UseDoxygen) xdmf-3.0+git20160803/doc/Doxyfile.in0000640000175000017500000017360513003006557016766 0ustar alastairalastair# Doxyfile 1.5.8 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project # # All text after a hash (#) is considered a comment and will be ignored # The format is: # TAG = value [value, ...] # For lists items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (" ") #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- # This tag specifies the encoding used for all characters in the config file # that follow. The default is UTF-8 which is also the encoding used for all # text before the first occurrence of this tag. Doxygen uses libiconv (or the # iconv built into libc) for the transcoding. See # http://www.gnu.org/software/libiconv for the list of possible encodings. DOXYFILE_ENCODING = UTF-8 # The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. PROJECT_NAME = "@PROJECT_NAME@" # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or # if some version control system is used. PROJECT_NUMBER = "@PROJECT_VERSION@" # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. OUTPUT_DIRECTORY = "@DOXYFILE_OUTPUT_DIR@" # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output # format and will distribute the generated files over these directories. # Enabling this option can be useful when feeding doxygen a huge amount of # source files, where putting all generated files in the same directory would # otherwise cause performance problems for the file system. CREATE_SUBDIRS = NO # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # The default language is English, other supported languages are: # Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, # Croatian, Czech, Danish, Dutch, Farsi, Finnish, French, German, Greek, # Hungarian, Italian, Japanese, Japanese-en (Japanese with English messages), # Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, Polish, # Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, Slovene, # Spanish, Swedish, and Ukrainian. OUTPUT_LANGUAGE = English # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will # include brief member descriptions after the members that are listed in # the file and class documentation (similar to JavaDoc). # Set to NO to disable this. BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend # the brief description of a member or function before the detailed description. # Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. REPEAT_BRIEF = YES # This tag implements a quasi-intelligent brief description abbreviator # that is used to form the text in various listings. Each string # in this list, if found as the leading text of the brief description, will be # stripped from the text and the result after processing the whole list, is # used as the annotated text. Otherwise, the brief description is used as-is. # If left blank, the following values are used ("$name" is automatically # replaced with the name of the entity): "The $name class" "The $name widget" # "The $name file" "is" "provides" "specifies" "contains" # "represents" "a" "an" "the" ABBREVIATE_BRIEF = # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # Doxygen will generate a detailed section even if there is only a brief # description. ALWAYS_DETAILED_SEC = NO # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all # inherited members of a class in the documentation of that class as if those # members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. INLINE_INHERITED_MEMB = NO # If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full # path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = NO # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag # can be used to strip a user-defined part of the path. Stripping is # only done if one of the specified strings matches the left-hand part of # the path. The tag can be used to show relative paths in the file list. # If left blank the directory from which doxygen is run is used as the # path to strip. STRIP_FROM_PATH = # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of # the path mentioned in the documentation of a class, which tells # the reader which header file to include in order to use a class. # If left blank only the name of the header file containing the class # definition is used. Otherwise one should specify the include paths that # are normally passed to the compiler using the -I flag. STRIP_FROM_INC_PATH = # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter # (but less readable) file names. This can be useful is your file systems # doesn't support long names like on DOS, Mac, or CD-ROM. SHORT_NAMES = NO # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen # will interpret the first line (until the first dot) of a JavaDoc-style # comment as the brief description. If set to NO, the JavaDoc # comments will behave just like regular Qt-style comments # (thus requiring an explicit @brief command for a brief description.) JAVADOC_AUTOBRIEF = NO # If the QT_AUTOBRIEF tag is set to YES then Doxygen will # interpret the first line (until the first dot) of a Qt-style # comment as the brief description. If set to NO, the comments # will behave just like regular Qt-style comments (thus requiring # an explicit \brief command for a brief description.) QT_AUTOBRIEF = NO # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen # treat a multi-line C++ special comment block (i.e. a block of //! or /// # comments) as a brief description. This used to be the default behaviour. # The new default is to treat a multi-line C++ comment block as a detailed # description. Set this tag to YES if you prefer the old behaviour instead. MULTILINE_CPP_IS_BRIEF = NO # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented # member inherits the documentation from any documented member that it # re-implements. INHERIT_DOCS = YES # If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce # a new page for each member. If set to NO, the documentation of a member will # be part of the file/class/namespace that contains it. SEPARATE_MEMBER_PAGES = NO # The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. TAB_SIZE = 8 # This tag can be used to specify a number of aliases that acts # as commands in the documentation. An alias has the form "name=value". # For example adding "sideeffect=\par Side Effects:\n" will allow you to # put the command \sideeffect (or @sideeffect) in the documentation, which # will result in a user-defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. ALIASES = # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C # sources only. Doxygen will then generate output that is more tailored for C. # For instance, some of the names that are used will be different. The list # of all members will be omitted, etc. OPTIMIZE_OUTPUT_FOR_C = NO # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java # sources only. Doxygen will then generate output that is more tailored for # Java. For instance, namespaces will be presented as packages, qualified # scopes will look different, etc. OPTIMIZE_OUTPUT_JAVA = NO # Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran # sources only. Doxygen will then generate output that is more tailored for # Fortran. OPTIMIZE_FOR_FORTRAN = NO # Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL # sources. Doxygen will then generate output that is tailored for # VHDL. OPTIMIZE_OUTPUT_VHDL = NO # Doxygen selects the parser to use depending on the extension of the files it parses. # With this tag you can assign which parser to use for a given extension. # Doxygen has a built-in mapping, but you can override or extend it using this tag. # The format is ext=language, where ext is a file extension, and language is one of # the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP, # Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat # .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran), # use: inc=Fortran f=C EXTENSION_MAPPING = # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want # to include (a tag file for) the STL sources as input, then you should # set this tag to YES in order to let doxygen match functions declarations and # definitions whose arguments contain STL classes (e.g. func(std::string); v.s. # func(std::string) {}). This also make the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. BUILTIN_STL_SUPPORT = NO # If you use Microsoft's C++/CLI language, you should set this option to YES to # enable parsing support. CPP_CLI_SUPPORT = NO # Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. # Doxygen will parse them like normal C++ but will assume all classes use public # instead of private inheritance when no explicit protection keyword is present. SIP_SUPPORT = NO # For Microsoft's IDL there are propget and propput attributes to indicate getter # and setter methods for a property. Setting this option to YES (the default) # will make doxygen to replace the get and set methods by a property in the # documentation. This will only work if the methods are indeed getting or # setting a simple type. If this is not the case, or you want to show the # methods anyway, you should set this option to NO. IDL_PROPERTY_SUPPORT = YES # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES, then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. DISTRIBUTE_GROUP_DOC = NO # Set the SUBGROUPING tag to YES (the default) to allow class member groups of # the same type (for instance a group of public functions) to be put as a # subgroup of that type (e.g. under the Public Functions section). Set it to # NO to prevent subgrouping. Alternatively, this can be done per class using # the \nosubgrouping command. SUBGROUPING = YES # When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum # is documented as struct, union, or enum with the name of the typedef. So # typedef struct TypeS {} TypeT, will appear in the documentation as a struct # with name TypeT. When disabled the typedef will appear as a member of a file, # namespace, or class. And the struct will be named TypeS. This can typically # be useful for C code in case the coding convention dictates that all compound # types are typedef'ed and only the typedef is referenced, never the tag name. TYPEDEF_HIDES_STRUCT = NO # The SYMBOL_CACHE_SIZE determines the size of the internal cache use to # determine which symbols to keep in memory and which to flush to disk. # When the cache is full, less often used symbols will be written to disk. # For small to medium size projects (<1000 input files) the default value is # probably good enough. For larger projects a too small cache size can cause # doxygen to be busy swapping symbols to and from disk most of the time # causing a significant performance penality. # If the system has enough physical memory increasing the cache will improve the # performance by keeping more symbols in memory. Note that the value works on # a logarithmic scale so increasing the size by one will rougly double the # memory usage. The cache size is given by this formula: # 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, # corresponding to a cache size of 2^16 = 65536 symbols SYMBOL_CACHE_SIZE = 0 #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in # documentation are documented, even if no documentation was available. # Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES EXTRACT_ALL = YES # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. EXTRACT_PRIVATE = NO # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. EXTRACT_STATIC = NO # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) # defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. EXTRACT_LOCAL_CLASSES = YES # This flag is only useful for Objective-C code. When set to YES local # methods, which are defined in the implementation section but not in # the interface are included in the documentation. # If set to NO (the default) only methods in the interface are included. EXTRACT_LOCAL_METHODS = NO # If this flag is set to YES, the members of anonymous namespaces will be # extracted and appear in the documentation as a namespace called # 'anonymous_namespace{file}', where file will be replaced with the base # name of the file that contains the anonymous namespace. By default # anonymous namespace are hidden. EXTRACT_ANON_NSPACES = NO # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all # undocumented members of documented classes, files or namespaces. # If set to NO (the default) these members will be included in the # various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_MEMBERS = NO # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. # If set to NO (the default) these classes will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all # friend (class|struct|union) declarations. # If set to NO (the default) these declarations will be included in the # documentation. HIDE_FRIEND_COMPOUNDS = NO # If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any # documentation blocks found inside the body of a function. # If set to NO (the default) these blocks will be appended to the # function's detailed documentation block. HIDE_IN_BODY_DOCS = NO # The INTERNAL_DOCS tag determines if documentation # that is typed after a \internal command is included. If the tag is set # to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. INTERNAL_DOCS = NO # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate # file names in lower-case letters. If set to YES upper-case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. CASE_SENSE_NAMES = YES # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen # will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. HIDE_SCOPE_NAMES = NO # If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen # will put a list of the files that are included by a file in the documentation # of that file. SHOW_INCLUDE_FILES = YES # If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. INLINE_INFO = YES # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen # will sort the (detailed) documentation of file and class members # alphabetically by member name. If set to NO the members will appear in # declaration order. SORT_MEMBER_DOCS = YES # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the # brief documentation of file, namespace and class members alphabetically # by member name. If set to NO (the default) the members will appear in # declaration order. SORT_BRIEF_DOCS = NO # If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the # hierarchy of group names into alphabetical order. If set to NO (the default) # the group names will appear in their defined order. SORT_GROUP_NAMES = NO # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be # sorted by fully-qualified names, including namespaces. If set to # NO (the default), the class list will be sorted only by class name, # not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. # Note: This option applies only to the class list, not to the # alphabetical list. SORT_BY_SCOPE_NAME = NO # The GENERATE_TODOLIST tag can be used to enable (YES) or # disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. GENERATE_TODOLIST = YES # The GENERATE_TESTLIST tag can be used to enable (YES) or # disable (NO) the test list. This list is created by putting \test # commands in the documentation. GENERATE_TESTLIST = YES # The GENERATE_BUGLIST tag can be used to enable (YES) or # disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. GENERATE_BUGLIST = YES # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or # disable (NO) the deprecated list. This list is created by putting # \deprecated commands in the documentation. GENERATE_DEPRECATEDLIST= YES # The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if sectionname ... \endif. ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines # the initial value of a variable or define consists of for it to appear in # the documentation. If the initializer consists of more lines than specified # here it will be hidden. Use a value of 0 to hide initializers completely. # The appearance of the initializer of individual variables and defines in the # documentation can be controlled using \showinitializer or \hideinitializer # command in the documentation regardless of this setting. MAX_INITIALIZER_LINES = 30 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated # at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. SHOW_USED_FILES = YES # If the sources in your project are distributed over multiple directories # then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy # in the documentation. The default is NO. SHOW_DIRECTORIES = NO # Set the SHOW_FILES tag to NO to disable the generation of the Files page. # This will remove the Files entry from the Quick Index and from the # Folder Tree View (if specified). The default is YES. SHOW_FILES = YES # Set the SHOW_NAMESPACES tag to NO to disable the generation of the # Namespaces page. # This will remove the Namespaces entry from the Quick Index # and from the Folder Tree View (if specified). The default is YES. SHOW_NAMESPACES = YES # The FILE_VERSION_FILTER tag can be used to specify a program or script that # doxygen should invoke to get the current version for each file (typically from # the version control system). Doxygen will invoke the program by executing (via # popen()) the command , where is the value of # the FILE_VERSION_FILTER tag, and is the name of an input file # provided by doxygen. Whatever the program writes to standard output # is used as the file version. See the manual for examples. FILE_VERSION_FILTER = # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by # doxygen. The layout file controls the global structure of the generated output files # in an output format independent way. The create the layout file that represents # doxygen's defaults, run doxygen with the -l option. You can optionally specify a # file name after the option, if omitted DoxygenLayout.xml will be used as the name # of the layout file. LAYOUT_FILE = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- # The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. QUIET = NO # The WARNINGS tag can be used to turn on/off the warning messages that are # generated by doxygen. Possible values are YES and NO. If left blank # NO is used. WARNINGS = YES # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings # for undocumented members. If EXTRACT_ALL is set to YES then this flag will # automatically be disabled. WARN_IF_UNDOCUMENTED = YES # If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for # potential errors in the documentation, such as not documenting some # parameters in a documented function, or documenting parameters that # don't exist or using markup commands wrongly. WARN_IF_DOC_ERROR = YES # This WARN_NO_PARAMDOC option can be abled to get warnings for # functions that are documented, but have no documentation for their parameters # or return value. If set to NO (the default) doxygen will only warn about # wrong or incomplete parameter documentation, but not about the absence of # documentation. WARN_NO_PARAMDOC = NO # The WARN_FORMAT tag determines the format of the warning messages that # doxygen can produce. The string should contain the $file, $line, and $text # tags, which will be replaced by the file and line number from which the # warning originated and the warning text. Optionally the format may contain # $version, which will be replaced by the version of the file (if it could # be obtained via FILE_VERSION_FILTER) WARN_FORMAT = "$file:$line: $text" # The WARN_LOGFILE tag can be used to specify a file to which warning # and error messages should be written. If left blank the output is written # to stderr. WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag can be used to specify the files and/or directories that contain # documented source files. You may enter file names like "myfile.cpp" or # directories like "/usr/src/myproject". Separate the files or directories # with spaces. INPUT = "@CMAKE_SOURCE_DIR@" \ "@CMAKE_SOURCE_DIR@/core" \ "@CMAKE_SOURCE_DIR@/core/loki" \ "@CMAKE_SOURCE_DIR@/core/dsm" \ "@CMAKE_BINARY_DIR@" # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is # also the default input encoding. Doxygen uses libiconv (or the iconv built # into libc) for the transcoding. See http://www.gnu.org/software/libiconv for # the list of possible encodings. INPUT_ENCODING = UTF-8 # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank the following patterns are tested: # *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx # *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 FILE_PATTERNS = *.hpp *.h # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = NO # The EXCLUDE tag can be used to specify files and/or directories that should # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. EXCLUDE = _darcs # The EXCLUDE_SYMLINKS tag can be used select whether or not files or # directories that are symbolic links (a Unix filesystem feature) are excluded # from the input. EXCLUDE_SYMLINKS = NO # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. Note that the wildcards are matched # against the file with absolute path, so to exclude all test directories # for example use the pattern */test/* EXCLUDE_PATTERNS = */tests/* *.git # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the # output. The symbol name can be a fully qualified name, a word, or if the # wildcard * is used, a substring. Examples: ANamespace, AClass, # AClass::ANamespace, ANamespace::*Test EXCLUDE_SYMBOLS = Loki::* Unit Visitor # The EXAMPLE_PATH tag can be used to specify one or more files or # directories that contain example code fragments that are included (see # the \include command). EXAMPLE_PATH = "@CMAKE_SOURCE_DIR@/examples" # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. EXAMPLE_PATTERNS = # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude # commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. EXAMPLE_RECURSIVE = YES # The IMAGE_PATH tag can be used to specify one or more files or # directories that contain image that are included in the documentation (see # the \image command). IMAGE_PATH = "@CMAKE_SOURCE_DIR@" # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program # by executing (via popen()) the command , where # is the value of the INPUT_FILTER tag, and is the name of an # input file. Doxygen will then use the output that the filter program writes # to standard output. # If FILTER_PATTERNS is specified, this tag will be # ignored. INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # basis. # Doxygen will compare the file name with each pattern and apply the # filter if there is a match. # The filters are a list of the form: # pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further # info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER # is applied to all files. FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will be used to filter the input files when producing source # files to browse (i.e. when SOURCE_BROWSER is set to YES). FILTER_SOURCE_FILES = NO #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- # If the SOURCE_BROWSER tag is set to YES then a list of source files will # be generated. Documented entities will be cross-referenced with these sources. # Note: To get rid of all source code in the generated output, make sure also # VERBATIM_HEADERS is set to NO. SOURCE_BROWSER = NO # Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. INLINE_SOURCES = NO # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct # doxygen to hide any special comment blocks from generated source code # fragments. Normal C and C++ comments will always remain visible. STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES # then for each documented function all documented # functions referencing it will be listed. REFERENCED_BY_RELATION = NO # If the REFERENCES_RELATION tag is set to YES # then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = NO # If the REFERENCES_LINK_SOURCE tag is set to YES (the default) # and SOURCE_BROWSER tag is set to YES, then the hyperlinks from # functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will # link to the source code. # Otherwise they will link to the documentation. REFERENCES_LINK_SOURCE = YES # If the USE_HTAGS tag is set to YES then the references to source code # will point to the HTML generated by the htags(1) tool instead of doxygen # built-in source browser. The htags tool is part of GNU's global source # tagging system (see http://www.gnu.org/software/global/global.html). You # will need version 4.8.6 or higher. USE_HTAGS = NO # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen # will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = YES #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index # of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. ALPHABETICAL_INDEX = NO # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) COLS_IN_ALPHA_INDEX = 5 # In case all classes in a project start with a common prefix, all # classes will be put under the same header in the alphabetical index. # The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = "@DOXYFILE_HTML_DIR@" # The HTML_FILE_EXTENSION tag can be used to specify the file extension for # each generated HTML page (for example: .htm,.php,.asp). If it is left blank # doxygen will generate files with .html extension. HTML_FILE_EXTENSION = .html # The HTML_HEADER tag can be used to specify a personal HTML header for # each generated HTML page. If it is left blank doxygen will generate a # standard header. HTML_HEADER = # The HTML_FOOTER tag can be used to specify a personal HTML footer for # each generated HTML page. If it is left blank doxygen will generate a # standard footer. HTML_FOOTER = # The HTML_STYLESHEET tag can be used to specify a user-defined cascading # style sheet that is used by each HTML page. It can be used to # fine-tune the look of the HTML output. If the tag is left blank doxygen # will generate a default style sheet. Note that doxygen will try to copy # the style sheet file to the HTML output directory, so don't put your own # stylesheet in the HTML output directory as well, or it will be erased! HTML_STYLESHEET = # If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, # files or namespaces will be aligned in HTML using tables. If set to # NO a bullet list will be used. HTML_ALIGN_MEMBERS = YES # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the # page has loaded. For this to work a browser that supports # JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox # Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). HTML_DYNAMIC_SECTIONS = NO # If the GENERATE_DOCSET tag is set to YES, additional index files # will be generated that can be used as input for Apple's Xcode 3 # integrated development environment, introduced with OSX 10.5 (Leopard). # To create a documentation set, doxygen will generate a Makefile in the # HTML output directory. Running make will produce the docset in that # directory and running "make install" will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find # it at startup. # See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information. GENERATE_DOCSET = NO # When GENERATE_DOCSET tag is set to YES, this tag determines the name of the # feed. A documentation feed provides an umbrella under which multiple # documentation sets from a single provider (such as a company or product suite) # can be grouped. DOCSET_FEEDNAME = "Doxygen generated docs" # When GENERATE_DOCSET tag is set to YES, this tag specifies a string that # should uniquely identify the documentation set bundle. This should be a # reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen # will append .docset to the name. DOCSET_BUNDLE_ID = org.doxygen.Project # If the GENERATE_HTMLHELP tag is set to YES, additional index files # will be generated that can be used as input for tools like the # Microsoft HTML help workshop to generate a compiled HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can # be used to specify the file name of the resulting .chm file. You # can add a path in front of the file if the result should not be # written to the html output directory. CHM_FILE = # If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can # be used to specify the location (absolute path including file name) of # the HTML help compiler (hhc.exe). If non-empty doxygen will try to run # the HTML help compiler on the generated index.hhp. HHC_LOCATION = # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag # controls if a separate .chi index file is generated (YES) or that # it should be included in the master .chm file (NO). GENERATE_CHI = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING # is used to encode HtmlHelp index (hhk), content (hhc) and project file # content. CHM_INDEX_ENCODING = # If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag # controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. BINARY_TOC = NO # The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the HTML help documentation and to the tree view. TOC_EXPAND = NO # If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER # are set, an additional index file will be generated that can be used as input for # Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated # HTML documentation. GENERATE_QHP = NO # If the QHG_LOCATION tag is specified, the QCH_FILE tag can # be used to specify the file name of the resulting .qch file. # The path specified is relative to the HTML output folder. QCH_FILE = # The QHP_NAMESPACE tag specifies the namespace to use when generating # Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#namespace QHP_NAMESPACE = # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating # Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#virtual-folders QHP_VIRTUAL_FOLDER = doc # If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add. # For more information please see # http://doc.trolltech.com/qthelpproject.html#custom-filters QHP_CUST_FILTER_NAME = # The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see # Qt Help Project / Custom Filters. QHP_CUST_FILTER_ATTRS = # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's # filter section matches. # Qt Help Project / Filter Attributes. QHP_SECT_FILTER_ATTRS = # If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can # be used to specify the location of Qt's qhelpgenerator. # If non-empty doxygen will try to run qhelpgenerator on the generated # .qhp file. QHG_LOCATION = # The DISABLE_INDEX tag can be used to turn on/off the condensed index at # top of each HTML page. The value NO (the default) enables the index and # the value YES disables it. DISABLE_INDEX = NO # This tag can be used to set the number of enum values (range [1..20]) # that doxygen will group on one line in the generated HTML documentation. ENUM_VALUES_PER_LINE = 4 # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index # structure should be generated to display hierarchical information. # If the tag value is set to FRAME, a side panel will be generated # containing a tree-like index structure (just like the one that # is generated for HTML Help). For this to work a browser that supports # JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, # Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are # probably better off using the HTML help feature. Other possible values # for this tag are: HIERARCHIES, which will generate the Groups, Directories, # and Class Hierarchy pages using a tree view instead of an ordered list; # ALL, which combines the behavior of FRAME and HIERARCHIES; and NONE, which # disables this behavior completely. For backwards compatibility with previous # releases of Doxygen, the values YES and NO are equivalent to FRAME and NONE # respectively. GENERATE_TREEVIEW = NONE # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be # used to set the initial width (in pixels) of the frame in which the tree # is shown. TREEVIEW_WIDTH = 250 # Use this tag to change the font size of Latex formulas included # as images in the HTML documentation. The default is 10. Note that # when you change the font size after a successful doxygen run you need # to manually remove any form_*.png images from the HTML output directory # to force them to be regenerated. FORMULA_FONTSIZE = 10 #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. GENERATE_LATEX = @DOXYFILE_LATEX@ # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. LATEX_OUTPUT = "@DOXYFILE_LATEX_DIR@" # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. If left blank `latex' will be used as the default command name. LATEX_CMD_NAME = "@LATEX_COMPILER@" # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to # generate index for LaTeX. If left blank `makeindex' will be used as the # default command name. MAKEINDEX_CMD_NAME = "@MAKEINDEX_COMPILER@" # If the COMPACT_LATEX tag is set to YES Doxygen generates more compact # LaTeX documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_LATEX = NO # The PAPER_TYPE tag can be used to set the paper type that is used # by the printer. Possible values are: a4, a4wide, letter, legal and # executive. If left blank a4wide will be used. PAPER_TYPE = a4wide # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. EXTRA_PACKAGES = # The LATEX_HEADER tag can be used to specify a personal LaTeX header for # the generated latex document. The header should contain everything until # the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! LATEX_HEADER = # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated # is prepared for conversion to pdf (using ps2pdf). The pdf file will # contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. PDF_HYPERLINKS = YES # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of # plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. USE_PDFLATEX = @DOXYFILE_PDFLATEX@ # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. # command to the generated LaTeX files. This will instruct LaTeX to keep # running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. LATEX_BATCHMODE = NO # If LATEX_HIDE_INDICES is set to YES then doxygen will not # include the index chapters (such as File Index, Compound Index, etc.) # in the output. LATEX_HIDE_INDICES = NO #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- # If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output # The RTF output is optimized for Word 97 and may not look very pretty with # other RTF readers or editors. GENERATE_RTF = NO # The RTF_OUTPUT tag is used to specify where the RTF docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `rtf' will be used as the default path. RTF_OUTPUT = rtf # If the COMPACT_RTF tag is set to YES Doxygen generates more compact # RTF documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_RTF = NO # If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated # will contain hyperlink fields. The RTF file will # contain links (just like the HTML output) instead of page references. # This makes the output suitable for online browsing using WORD or other # programs which support those fields. # Note: wordpad (write) and others do not support links. RTF_HYPERLINKS = NO # Load stylesheet definitions from file. Syntax is similar to doxygen's # config file, i.e. a series of assignments. You only have to provide # replacements, missing definitions are set to their default value. RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an rtf document. # Syntax is similar to doxygen's config file. RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- # If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages GENERATE_MAN = NO # The MAN_OUTPUT tag is used to specify where the man pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. MAN_OUTPUT = man # The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) MAN_EXTENSION = .3 # If the MAN_LINKS tag is set to YES and Doxygen generates man output, # then it will generate one additional man file for each entity # documented in the real man page(s). These additional files # only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- # If the GENERATE_XML tag is set to YES Doxygen will # generate an XML file that captures the structure of # the code including all documentation. GENERATE_XML = NO # The XML_OUTPUT tag is used to specify where the XML pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `xml' will be used as the default path. XML_OUTPUT = xml # The XML_SCHEMA tag can be used to specify an XML schema, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_SCHEMA = # The XML_DTD tag can be used to specify an XML DTD, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_DTD = # If the XML_PROGRAMLISTING tag is set to YES Doxygen will # dump the program listings (including syntax highlighting # and cross-referencing information) to the XML output. Note that # enabling this will significantly increase the size of the XML output. XML_PROGRAMLISTING = YES #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will # generate an AutoGen Definitions (see autogen.sf.net) file # that captures the structure of the code including all # documentation. Note that this feature is still experimental # and incomplete at the moment. GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # configuration options related to the Perl module output #--------------------------------------------------------------------------- # If the GENERATE_PERLMOD tag is set to YES Doxygen will # generate a Perl module file that captures the structure of # the code including all documentation. Note that this # feature is still experimental and incomplete at the # moment. GENERATE_PERLMOD = NO # If the PERLMOD_LATEX tag is set to YES Doxygen will generate # the necessary Makefile rules, Perl scripts and LaTeX code to be able # to generate PDF and DVI output from the Perl module output. PERLMOD_LATEX = NO # If the PERLMOD_PRETTY tag is set to YES the Perl module output will be # nicely formatted so it can be parsed by a human reader. # This is useful # if you want to understand what is going on. # On the other hand, if this # tag is set to NO the size of the Perl module output will be much smaller # and Perl will parse it just the same. PERLMOD_PRETTY = YES # The names of the make variables in the generated doxyrules.make file # are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. # This is useful so different doxyrules.make files included by the same # Makefile don't overwrite each other's variables. PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- # If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will # evaluate all C-preprocessor directives found in the sources and include # files. ENABLE_PREPROCESSING = YES # If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro # names in the source code. If set to NO (the default) only conditional # compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. MACRO_EXPANSION = YES # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES # then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_DEFINED tags. EXPAND_ONLY_PREDEF = NO # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # in the INCLUDE_PATH (see below) will be search if a #include is found. SEARCH_INCLUDES = YES # The INCLUDE_PATH tag can be used to specify one or more directories that # contain include files that are not input files but should be processed by # the preprocessor. INCLUDE_PATH = "@CMAKE_SOURCE_DIR@/core/loki" \ "@CMAKE_SOURCE_DIR@/core" # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the # directories. If left blank, the patterns specified with FILE_PATTERNS will # be used. INCLUDE_FILE_PATTERNS = *.h *.hpp # The PREDEFINED tag can be used to specify one or more macro names that # are defined before the preprocessor is started (similar to the -D option of # gcc). The argument of the tag is a list of macros of the form: name # or name=definition (no spaces). If the definition and the = are # omitted =1 is assumed. To prevent a macro definition from being # undefined via #undef or recursively expanded use the := operator # instead of the = operator. PREDEFINED = __cplusplus # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. # The macro definition that is found in the sources will be used. # Use the PREDEFINED tag if you want to use a different macro definition. EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then # doxygen's preprocessor will remove all function-like macros that are alone # on a line, have an all uppercase name, and do not end with a semicolon. Such # function macros are typically used for boiler-plate code, and will confuse # the parser if not removed. SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration::additions related to external references #--------------------------------------------------------------------------- # The TAGFILES option can be used to specify one or more tagfiles. # Optionally an initial location of the external documentation # can be added for each tagfile. The format of a tag file without # this location is as follows: # # TAGFILES = file1 file2 ... # Adding location for the tag files is done as follows: # # TAGFILES = file1=loc1 "file2 = loc2" ... # where "loc1" and "loc2" can be relative or absolute paths or # URLs. If a location is present for each tag, the installdox tool # does not have to be run to correct the links. # Note that each tag file must have a unique name # (where the name does NOT include the path) # If a tag file is not located in the directory in which doxygen # is run, you must also specify the path to the tagfile here. TAGFILES = # When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. GENERATE_TAGFILE = # If the ALLEXTERNALS tag is set to YES all external classes will be listed # in the class index. If set to NO only the inherited external classes # will be listed. ALLEXTERNALS = NO # If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed # in the modules index. If set to NO, only the current project's groups will # be listed. EXTERNAL_GROUPS = YES # The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will # generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base # or super classes. Setting the tag to NO turns the diagrams off. Note that # this option is superseded by the HAVE_DOT option below. This is only a # fallback. It is recommended to install and use dot, since it yields more # powerful graphs. CLASS_DIAGRAMS = YES # You can define message sequence charts within doxygen comments using the \msc # command. Doxygen will then run the mscgen tool (see # http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the # documentation. The MSCGEN_PATH tag allows you to specify the directory where # the mscgen tool resides. If left empty the tool is assumed to be found in the # default search path. MSCGEN_PATH = # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented # or is not a class. HIDE_UNDOC_RELATIONS = YES # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is # available from the path. This tool is part of Graphviz, a graph visualization # toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) HAVE_DOT = @DOXYFILE_DOT@ # By default doxygen will write a font called FreeSans.ttf to the output # directory and reference it in all dot files that doxygen generates. This # font does not include all possible unicode characters however, so when you need # these (or just want a differently looking font) you can specify the font name # using DOT_FONTNAME. You need need to make sure dot is able to find the font, # which can be done by putting it in a standard location or by setting the # DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory # containing the font. DOT_FONTNAME = FreeSans # The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. # The default size is 10pt. DOT_FONTSIZE = 10 # By default doxygen will tell dot to use the output directory to look for the # FreeSans.ttf font (which doxygen will put there itself). If you specify a # different font using DOT_FONTNAME you can set the path where dot # can find it using this tag. DOT_FONTPATH = # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect inheritance relations. Setting this tag to YES will force the # the CLASS_DIAGRAMS tag to NO. CLASS_GRAPH = YES # If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. COLLABORATION_GRAPH = YES # If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen # will generate a graph for groups, showing the direct groups dependencies GROUP_GRAPHS = YES # If the UML_LOOK tag is set to YES doxygen will generate inheritance and # collaboration diagrams in a style similar to the OMG's Unified Modeling # Language. UML_LOOK = NO # If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. TEMPLATE_RELATIONS = NO # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT # tags are set to YES then doxygen will generate a graph for each documented # file showing the direct and indirect include dependencies of the file with # other documented files. INCLUDE_GRAPH = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and # HAVE_DOT tags are set to YES then doxygen will generate a graph for each # documented header file showing the documented files that directly or # indirectly include this file. INCLUDED_BY_GRAPH = YES # If the CALL_GRAPH and HAVE_DOT options are set to YES then # doxygen will generate a call dependency graph for every global function # or class method. Note that enabling this option will significantly increase # the time of a run. So in most cases it will be better to enable call graphs # for selected functions only using the \callgraph command. CALL_GRAPH = NO # If the CALLER_GRAPH and HAVE_DOT tags are set to YES then # doxygen will generate a caller dependency graph for every global function # or class method. Note that enabling this option will significantly increase # the time of a run. So in most cases it will be better to enable caller # graphs for selected functions only using the \callergraph command. CALLER_GRAPH = NO # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will graphical hierarchy of all classes instead of a textual one. GRAPHICAL_HIERARCHY = YES # If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES # then doxygen will show the dependencies a directory has on other directories # in a graphical way. The dependency relations are determined by the #include # relations between the files in the directories. DIRECTORY_GRAPH = YES # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # generated by dot. Possible values are png, jpg, or gif # If left blank png will be used. DOT_IMAGE_FORMAT = png # The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found in the path. DOT_PATH = "@DOXYGEN_DOT_PATH@" # The DOTFILE_DIRS tag can be used to specify one or more directories that # contain dot files that are included in the documentation (see the # \dotfile command). DOTFILE_DIRS = # The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of # nodes that will be shown in the graph. If the number of nodes in a graph # becomes larger than this value, doxygen will truncate the graph, which is # visualized by representing a node as a red box. Note that doxygen if the # number of direct children of the root node in a graph is already larger than # DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note # that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. DOT_GRAPH_MAX_NODES = 50 # The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the # graphs generated by dot. A depth value of 3 means that only nodes reachable # from the root by following a path via at most 3 edges will be shown. Nodes # that lay further from the root node will be omitted. Note that setting this # option to 1 or 2 may greatly reduce the computation time needed for large # code bases. Also note that the size of a graph can be further restricted by # DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. MAX_DOT_GRAPH_DEPTH = 0 # Set the DOT_TRANSPARENT tag to YES to generate images with a transparent # background. This is disabled by default, because dot on Windows does not # seem to support this out of the box. Warning: Depending on the platform used, # enabling this option may lead to badly anti-aliased labels on the edges of # a graph (i.e. they become hard to read). DOT_TRANSPARENT = YES # Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output # files in one run (i.e. multiple -o and -T options on the command line). This # makes dot run faster, but since only newer versions of dot (>1.8.10) # support this, this feature is disabled by default. DOT_MULTI_TARGETS = NO # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will # generate a legend page explaining the meaning of the various boxes and # arrows in the dot generated graphs. GENERATE_LEGEND = YES # If the DOT_CLEANUP tag is set to YES (the default) Doxygen will # remove the intermediate dot files that are used to generate # the various graphs. DOT_CLEANUP = YES #--------------------------------------------------------------------------- # Options related to the search engine #--------------------------------------------------------------------------- # The SEARCHENGINE tag specifies whether or not a search engine should be # used. If set to NO the values of all tags below this one will be ignored. SEARCHENGINE = NO xdmf-3.0+git20160803/XdmfMap.hpp0000640000175000017500000003334013003006557016142 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfMap.hpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef XDMFMAP_HPP_ #define XDMFMAP_HPP_ // C Compatible Includes #include "Xdmf.hpp" #include "XdmfItem.hpp" #ifdef __cplusplus // Forward Declarations class XdmfArray; class XdmfAttribute; class XdmfHeavyDataController; // Includes #include /** * @brief Boundary communicator map for partitioned spatial * collections. * * Provides mechanism for mapping nodes across partition * boundaries. Each partitioned grid contains its own map, mapping its * own nodes to all other nodes in the global system. * * There are two methods for constructing XdmfMaps: * * Calling New() with no parameters will construct an empty map. The * map can be filled manually with subsequent insert commands. * * Calling New(const std::vector > & * globalNodeIds) will construct XdmfMaps for each grid in an entire * global system. Each entry in the vector contains the globalNodeIds * for that partition. The constructor accepts global node ids for * each partition to construct the proper XdmfMaps. */ class XDMF_EXPORT XdmfMap : public XdmfItem { public: typedef int node_id; typedef int task_id; typedef std::map > node_id_map; /** * Create a new XdmfMap. * * Example of use: * * C++ * * @dontinclude ExampleXdmfMap.cpp * @skipline //#initialization * @until //#initialization * * Python * * @dontinclude XdmfExampleMap.py * @skipline #//initialization * @until #//initialization * * @return Constructed XdmfMap. */ static shared_ptr New(); /** * Create XdmfMaps for each grid in a domain decomposed mesh. Each * entry in the globalNodeIds vector contains the global node ids * for that partition. * * Example of use: * * C++ * * @dontinclude ExampleXdmfMap.cpp * @skipline //#initializationnode * @until //#initializationnode * * Python * * @dontinclude XdmfExampleMap.py * @skipline #//initializationnode * @until #//initializationnode * * @param globalNodeIds A vector of attributes containing globalNodeId * values for each partition to be mapped. * * @return Constructed XdmfMaps for each partition. The * size of the vector will be the same as the * globalNodeIds vector. */ static std::vector > New(const std::vector > & globalNodeIds); virtual ~XdmfMap(); LOKI_DEFINE_VISITABLE(XdmfMap, XdmfItem) static const std::string ItemTag; std::map getItemProperties() const; /** * Get stored boundary communicator map. * * Example of use: * * C++ * * @dontinclude ExampleXdmfMap.cpp * @skipline //#initialization * @until //#initialization * @skipline //#getMap * @until //#getMap * * Python * * @dontinclude XdmfExampleMap.py * @skipline #//initialization * @until #//initialization * @skipline #//getMap * @until #//getMap * * @return Stored boundary communicator map. */ std::map getMap() const; /** * Get name of boundary communicator map. * * Example of use: * * C++ * * @dontinclude ExampleXdmfMap.cpp * @skipline //#initialization * @until //#initialization * @skipline //#setName * @until //#setName * @skipline //#getName * @until //#getName * * Python * * @dontinclude XdmfExampleMap.py * @skipline #//initialization * @until #//initialization * @skipline #//setName * @until #//setName * @skipline #//getName * @until #//getName * * @return Name of boundary communicator map. */ std::string getName() const; /** * Given a remote task id return a map of local node ids to remote * node ids * * Example of use: * * C++ * * @dontinclude ExampleXdmfMap.cpp * @skipline //#initialization * @until //#initialization * @skipline //#getRemoteNodeIds * @until //#getRemoteNodeIds * * Python * * @dontinclude XdmfExampleMap.py * @skipline #//initialization * @until #//initialization * @skipline #//getRemoteNodeIds * @until #//getRemoteNodeIds * * @param remoteTaskId Task id to retrieve mapping for. * * @return A map of local node ids to a vector of * remote node ids on remoteTaskId. */ node_id_map getRemoteNodeIds(const task_id remoteTaskId); std::string getItemTag() const; using XdmfItem::insert; /** * Insert a new entry in map. * * Example of use: * * C++ * * @dontinclude ExampleXdmfMap.cpp * @skipline //#initialization * @until //#initialization * @skipline //#inserttuple * @until //#inserttuple * * Python * * @dontinclude XdmfExampleMap.py * @skipline #//initialization * @until #//initialization * @skipline #//inserttuple * @until #//inserttuple * * @param remoteTaskId task id where the remoteLoalNodeId is * located. * @param localNodeId The node id of the node being mapped. * @param remoteLocalNodeId A node id on the remoteTaskId that the * localNodeId is mapped to. */ void insert(const task_id remoteTaskId, const node_id localNodeId, const node_id remoteLocalNodeId); /** * Returns whether the map is initialized (contains values in * memory). * * Example of use: * * C++ * * @dontinclude ExampleXdmfMap.cpp * @skipline //#initialization * @until //#initialization * @skipline //#isInitialized * @until //#isInitialized * * Python * * @dontinclude XdmfExampleMap.py * @skipline //#initialization * @until //#initialization * @skipline #//isInitialized * @until #//isInitialized * * @return bool true if map contains values in memory. */ bool isInitialized() const; /** * Read data from disk into memory. * * Example of use: * * C++ * * @dontinclude ExampleXdmfMap.cpp * @skipline //#initialization * @until //#initialization * @skipline //#isInitialized * @until //#isInitialized * * Python * * @dontinclude XdmfExampleMap.py * @skipline //#initialization * @until //#initialization * @skipline #//isInitialized * @until #//isInitialized */ void read(); /** * Release all data held in memory. The heavy data remain attached. * * Example of use: * * C++ * * @dontinclude ExampleXdmfMap.cpp * @skipline //#initialization * @until //#initialization * @skipline //#release * @until //#release * * Python * * @dontinclude XdmfExampleMap.py * @skipline //#initialization * @until //#initialization * @skipline #//release * @until #//release */ void release(); /** * Set the heavy data controllers for this map. * * Example of use: * * C++ * * @dontinclude ExampleXdmfMap.cpp * @skipline //#initialization * @until //#initialization * @skipline //#setHeavyDataController * @until //#setHeavyDataController * * Python * * @dontinclude XdmfExampleMap.py * @skipline //#initialization * @until //#initialization * @skipline #//setHeavyDataController * @until #//setHeavyDataController * * @param remoteTaskIdsControllers A vector of XdmfHeavyDataControllers * to the remote task ids dataset. * @param localNodeIdsControllers A vector of XdmfHeavyDataControllers * to the local node ids dataset. * @param remoteLocalNodeIdsControllers A vector of XdmfHeavyDataControllers * to the remote local node ids dataset. */ void setHeavyDataControllers(std::vector > remoteTaskIdsControllers, std::vector > localNodeIdsControllers, std::vector > remoteLocalNodeIdsControllers); /** * Set the boundary communicator map. * * Example of use: * * C++ * * @dontinclude ExampleXdmfMap.cpp * @skipline //#initialization * @until //#initialization * @skipline //#setMap * @until //#setMap * * Python * * @dontinclude XdmfExampleMap.py * @skipline #//initialization * @until #//initialization * @skipline #//setMap * @until #//setMap * * @param map The boundary communicator map to store. */ void setMap(std::map map); /** * Set the name of the boundary communicator map. * * Example of use: * * C++ * * @dontinclude ExampleXdmfMap.cpp * @skipline //#initialization * @until //#initialization * @skipline //#setName * @until //#setName * * Python * * @dontinclude XdmfExampleMap.py * @skipline #//initialization * @until #//initialization * @skipline #//setName * @until #//setName * * @param name The name of the boundary communicator map to set. */ void setName(const std::string & name); void traverse(const shared_ptr visitor); XdmfMap(XdmfMap & map); protected: XdmfMap(); virtual void populateItem(const std::map & itemProperties, const std::vector > & childItems, const XdmfCoreReader * const reader); private: XdmfMap(const XdmfMap & map); // Not implemented. void operator=(const XdmfMap & map); // Not implemented. std::vector > mLocalNodeIdsControllers; // remoteTaskId | localNodeId | remoteLocalNodeId std::map mMap; std::string mName; std::vector > mRemoteLocalNodeIdsControllers; std::vector > mRemoteTaskIdsControllers; }; #endif #ifdef __cplusplus extern "C" { #endif // C wrappers go here struct XDMFMAP; // Simply as a typedef to ensure correct typing typedef struct XDMFMAP XDMFMAP; XDMF_EXPORT XDMFMAP * XdmfMapNew(); XDMF_EXPORT XDMFMAP ** XdmfMapNewFromIdVector(int ** globalNodeIds, int * numIdsOnNode, int numIds); XDMF_EXPORT char * XdmfMapGetName(XDMFMAP * map); XDMF_EXPORT void XdmfMapInsert(XDMFMAP * map, int remoteTaskId, int localNodeId, int remoteLocalNodeId); XDMF_EXPORT int XdmfMapIsInitialized(XDMFMAP * map); XDMF_EXPORT void XdmfMapRead(XDMFMAP * map, int * status); XDMF_EXPORT void XdmfMapRelease(XDMFMAP * map); XDMF_EXPORT int * XdmfMapRetrieveLocalNodeIds(XDMFMAP * map, int remoteTaskId); XDMF_EXPORT int XdmfMapRetrieveNumberLocalNodeIds(XDMFMAP * map, int remoteTaskId); XDMF_EXPORT int XdmfMapRetrieveNumberRemoteTaskIds(XDMFMAP * map); XDMF_EXPORT int XdmfMapRetrieveNumberRemoteNodeIds(XDMFMAP * map, int remoteTaskId, int localNodeId); XDMF_EXPORT int * XdmfMapRetrieveRemoteTaskIds(XDMFMAP * map); XDMF_EXPORT int * XdmfMapRetrieveRemoteNodeIds(XDMFMAP * map, int remoteTaskId, int localNodeId); XDMF_EXPORT void XdmfMapSetHeavyDataControllers(XDMFMAP * map, XDMFHEAVYDATACONTROLLER ** remoteTaskControllers, int numRemoteTaskControllers, XDMFHEAVYDATACONTROLLER ** localNodeControllers, int numberLocalNodeControllers, XDMFHEAVYDATACONTROLLER ** remoteLocalNodeControllers, int numRemoteLocalNodeControllers, int passControl, int * status); XDMF_EXPORT void XdmfMapSetName(XDMFMAP * map, char * newName); XDMF_ITEM_C_CHILD_DECLARE(XdmfMap, XDMFMAP, XDMF) #ifdef __cplusplus } #endif #endif /* XDMFMAP_HPP_ */ xdmf-3.0+git20160803/XdmfCurvilinearGrid.hpp0000640000175000017500000002432313003006557020517 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfCurvilinearGrid.hpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef XDMFCURVILINEARGRID_HPP_ #define XDMFCURVILINEARGRID_HPP_ // C Compatible Includes #include "Xdmf.hpp" #include "XdmfGrid.hpp" #ifdef __cplusplus // Forward Declarations class XdmfArray; /** * @brief A curvilinear (or structured) grid consisting of cells and * points arranged on a regular lattice in space. * * XdmfCurvilinearGrid represents a mesh of cells and points arranged * with regular topology and irregular geometry. * * In order to define a curvilinear grid, the dimensions of the grid * must be supplied along with the coordinates of each point. * */ class XDMF_EXPORT XdmfCurvilinearGrid : public XdmfGrid { public: /** * Create a new curvilinear grid (Two dimensional). * * Example of use: * * C++ * * @dontinclude ExampleXdmfCurvilinearGrid.cpp * @skipline //#initializationdim2 * @until //#initializationdim2 * * Python * * @dontinclude XdmfExampleCurvilinearGrid.py * @skipline #//initialization * @until #//initialization * @skipline #//constructor2 * @until #//constructor2 * * @param xNumPoints The number of points in the x direction. * @param yNumPoints The number of points in the y direction. * * @return Constructed curvilinear grid. */ static shared_ptr New(const unsigned int xNumPoints, const unsigned int yNumPoints); /** * Create a new curvilinear grid (Three dimensional). * * Example of use: * * C++ * * @dontinclude ExampleXdmfCurvilinearGrid.cpp * @skipline //#initializationdim3 * @until //#initializationdim3 * * Python * * @dontinclude XdmfExampleCurvilinearGrid.py * @skipline #//initialization * @until #//initialization * @skipline #//constructor3 * @until #//constructor3 * * @param xNumPoints The number of points in the x direction. * @param yNumPoints The number of points in the y direction. * @param zNumPoints The number of points in the z direction. * * @return Constructed curvilinear grid. */ static shared_ptr New(const unsigned int xNumPoints, const unsigned int yNumPoints, const unsigned int zNumPoints); /** * Create a new curvilinear grid (N dimensional). * * Example of use: * * C++ * * @dontinclude ExampleXdmfCurvilinearGrid.cpp * @skipline //#initializationvector * @until //#initializationvector * * Python * * @dontinclude XdmfExampleCurvilinearGrid.py * @skipline #//initialization * @until #//initialization * @skipline #//constructorvector * @until #//constructorvector * * @param numPoints The number of points in each direction. * * @return Constructed curvilinear grid. */ static shared_ptr New(const shared_ptr numPoints); virtual ~XdmfCurvilinearGrid(); LOKI_DEFINE_VISITABLE(XdmfCurvilinearGrid, XdmfGrid) static const std::string ItemTag; /** * Get the dimensions of the grid, the number of points in each * direction. * * Example of use: * * C++ * * @dontinclude ExampleXdmfCurvilinearGrid.cpp * @skipline //#initializationdim3 * @until //#initializationdim3 * @skipline //#setDimensions * @until //#setDimensions * @skipline //#getDimensions * @until //#getDimensions * * Python * * @dontinclude XdmfExampleCurvilinearGrid.py * @skipline #//initialization * @until #//initialization * @skipline #//constructorvector * @until #//constructorvector * @skipline #//setDimensions * @until #//setDimensions * @skipline #//getDimensions * @until #//getDimensions * * @return XdmfArray containing dimensions of this grid. */ shared_ptr getDimensions(); /** * Get the dimensions of the grid, the number of points in each * direction (const version). * * Example of use: * * C++ * * @dontinclude ExampleXdmfCurvilinearGrid.cpp * @skipline //#initializationdim3 * @until //#initializationdim3 * @skipline //#setDimensions * @until //#setDimensions * @skipline //#getDimensionsconst * @until //#getDimensionsconst * * Python: Python doesn't have a constant version * * @return XdmfArray containing the dimensions of this grid. */ shared_ptr getDimensions() const; /** * Get the geometry associated with this grid. * * Example of use: * * C++ * * @dontinclude ExampleXdmfCurvilinearGrid.cpp * @skipline //#initializationdim3 * @until //#initializationdim3 * @skipline //#setGeometry * @until //#setGeometry * @skipline //#getGeometry * @until //#getGeometry * * Python * * @dontinclude XdmfExampleCurvilinearGrid.py * @skipline #//initialization * @until #//initialization * @skipline #//constructorvector * @until #//constructorvector * @skipline #//setGeometry * @until #//setGeometry * @skipline #//getGeometry * @until #//getGeometry * * @return The geometry associated with this grid. */ shared_ptr getGeometry(); using XdmfGrid::getGeometry; virtual void read(); virtual void release(); /** * Set the dimensions of the grid, the number of points in each * direction. * * Example of use: * * C++ * * @dontinclude ExampleXdmfCurvilinearGrid.cpp * @skipline //#initializationdim3 * @until //#initializationdim3 * @skipline //#setDimensions * @until //#setDimensions * * Python * * @dontinclude XdmfExampleCurvilinearGrid.py * @skipline #//initialization * @until #//initialization * @skipline #//constructorvector * @until #//constructorvector * @skipline #//setDimensions * @until #//setDimensions * * @param dimensions The dimension of the grid. */ void setDimensions(const shared_ptr dimensions); /** * Set the geometry associated with this grid. * * Example of use: * * C++ * * @dontinclude ExampleXdmfCurvilinearGrid.cpp * @skipline //#initializationdim3 * @until //#initializationdim3 * @skipline //#setGeometry * @until //#setGeometry * * Python * * @dontinclude XdmfExampleCurvilinearGrid.py * @skipline #//initialization * @until #//initialization * @skipline #//constructorvector * @until #//constructorvector * @skipline #//setGeometry * @until #//setGeometry * * @param geometry An XdmfGeometry to associate with this grid. */ void setGeometry(const shared_ptr geometry); XdmfCurvilinearGrid(XdmfCurvilinearGrid &); protected: XdmfCurvilinearGrid(const shared_ptr numPoints); void populateItem(const std::map & itemProperties, const std::vector > & childItems, const XdmfCoreReader * const reader); private: /** * PIMPL */ class XdmfCurvilinearGridImpl; XdmfCurvilinearGrid(const XdmfCurvilinearGrid &); // Not implemented. void operator=(const XdmfCurvilinearGrid &); // Not implemented. void copyGrid(shared_ptr sourceGrid); }; #endif #ifdef __cplusplus extern "C" { #endif // C wrappers go here struct XDMFCURVILINEARGRID; // Simply as a typedef to ensure correct typing typedef struct XDMFCURVILINEARGRID XDMFCURVILINEARGRID; XDMF_EXPORT XDMFCURVILINEARGRID * XdmfCurvilinearGridNew2D(unsigned int xNumPoints, unsigned int yNumPoints); XDMF_EXPORT XDMFCURVILINEARGRID * XdmfCurvilinearGridNew3D(unsigned int xNumPoints, unsigned int yNumPoints, unsigned int zNumPoints); XDMF_EXPORT XDMFCURVILINEARGRID * XdmfCurvilinearGridNew(XDMFARRAY * numPoints, int * status); XDMF_EXPORT XDMFARRAY * XdmfCurvilinearGridGetDimensions(XDMFCURVILINEARGRID * grid, int * status); XDMF_EXPORT XDMFGEOMETRY * XdmfCurvilinearGridGetGeometry(XDMFCURVILINEARGRID * grid); XDMF_EXPORT void XdmfCurvilinearGridSetDimensions(XDMFCURVILINEARGRID * grid, XDMFARRAY * dimensions, int passControl, int * status); XDMF_EXPORT void XdmfCurvilinearGridSetGeometry(XDMFCURVILINEARGRID * grid, XDMFGEOMETRY * geometry, int passControl); XDMF_ITEM_C_CHILD_DECLARE(XdmfCurvilinearGrid, XDMFCURVILINEARGRID, XDMF) XDMF_GRID_C_CHILD_DECLARE(XdmfCurvilinearGrid, XDMFCURVILINEARGRID, XDMF) #ifdef __cplusplus } #endif #endif /* XDMFCURVILINEARGRID_HPP_ */ xdmf-3.0+git20160803/XdmfMap.cpp0000640000175000017500000005652013003006557016142 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfMap.cpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #include #include #include "XdmfAttribute.hpp" #include "XdmfError.hpp" #include "XdmfGridCollection.hpp" #include "XdmfGridCollectionType.hpp" #include "XdmfHeavyDataController.hpp" #include "XdmfMap.hpp" #include "XdmfWriter.hpp" shared_ptr XdmfMap::New() { shared_ptr p(new XdmfMap()); return p; } std::vector > XdmfMap::New(const std::vector > & globalNodeIds) { // globalNodeId | taskId | localNodeId at taskId std::map > globalNodeIdMap; // fill globalNodeIdMap using globalNodeIds std::vector releaseGlobalNodeIds(globalNodeIds.size(), false); for(unsigned int i=0; i currGlobalNodeIds = globalNodeIds[i]; if(!currGlobalNodeIds->isInitialized()) { currGlobalNodeIds->read(); releaseGlobalNodeIds[i] = true; } for(unsigned int j=0; jgetSize(); ++j) { const node_id currGlobalNodeId = currGlobalNodeIds->getValue(j); globalNodeIdMap[currGlobalNodeId][i] = j; } } std::vector > returnValue; returnValue.resize(globalNodeIds.size()); // fill maps for each partition for(unsigned int i=0; i map = XdmfMap::New(); returnValue[i] = map; const shared_ptr currGlobalNodeIds = globalNodeIds[i]; for(unsigned int j=0; jgetSize(); ++j) { const node_id currGlobalNodeId = currGlobalNodeIds->getValue(j); const std::map & currMap = globalNodeIdMap[currGlobalNodeId]; if(currMap.size() > 1) { for(std::map::const_iterator iter = currMap.begin(); iter != currMap.end(); ++iter) { if(iter->first != (int)i) { map->insert(iter->first, j, iter->second); } } } } if(releaseGlobalNodeIds[i]) { currGlobalNodeIds->release(); } } return returnValue; } XdmfMap::XdmfMap() : mName("") { } XdmfMap::XdmfMap(XdmfMap & refMap): mLocalNodeIdsControllers(refMap.mLocalNodeIdsControllers), mMap(refMap.mMap), mName(refMap.mName), mRemoteLocalNodeIdsControllers(refMap.mRemoteLocalNodeIdsControllers), mRemoteTaskIdsControllers(refMap.mRemoteTaskIdsControllers) { } XdmfMap::~XdmfMap() { } const std::string XdmfMap::ItemTag = "Map"; std::map XdmfMap::getItemProperties() const { std::map mapProperties; mapProperties.insert(std::make_pair("Name", mName)); return mapProperties; } std::string XdmfMap::getItemTag() const { return ItemTag; } std::map XdmfMap::getMap() const { return mMap; } std::string XdmfMap::getName() const { return mName; } XdmfMap::node_id_map XdmfMap::getRemoteNodeIds(const task_id remoteTaskId) { std::map::const_iterator iter = mMap.find(remoteTaskId); if(iter != mMap.end()) { return iter->second; } // No entry, return empty map. return node_id_map(); } void XdmfMap::insert(const task_id remoteTaskId, const node_id localNodeId, const node_id remoteLocalNodeId) { mMap[remoteTaskId][localNodeId].insert(remoteLocalNodeId); this->setIsChanged(true); } bool XdmfMap::isInitialized() const { return mMap.size() > 0; } void XdmfMap::populateItem(const std::map & itemProperties, const std::vector > & childItems, const XdmfCoreReader * const reader) { XdmfItem::populateItem(itemProperties, childItems, reader); std::map::const_iterator name = itemProperties.find("Name"); if(name != itemProperties.end()) { mName = name->second; } else { mName = ""; } std::vector > arrayVector; arrayVector.reserve(3); for(std::vector >::const_iterator iter = childItems.begin(); iter != childItems.end(); ++iter) { if(shared_ptr array = shared_dynamic_cast(*iter)) { arrayVector.push_back(array); } } if(arrayVector.size() != 0) { if(arrayVector.size() != 3) { XdmfError::message(XdmfError::FATAL, "Expected 3 arrays attached to " "XdmfMap::populateItem"); } if(!(arrayVector[0]->getSize() == arrayVector[1]->getSize() && arrayVector[0]->getSize() == arrayVector[2]->getSize())) { XdmfError::message(XdmfError::FATAL, "Arrays must be of equal size in " "XdmfMap:: populateItem"); } // check if any arrays have values in memory - if so, they need to be // read into map bool needToRead = false; for(std::vector >::const_iterator iter = arrayVector.begin(); iter != arrayVector.end(); ++iter) { if((*iter)->isInitialized()) { needToRead = true; break; } } if(needToRead) { for(std::vector >::const_iterator iter = arrayVector.begin(); iter != arrayVector.end(); ++iter) { if(!(*iter)->isInitialized()) { (*iter)->read(); } } for(unsigned int i=0; igetSize(); ++i) { this->insert(arrayVector[0]->getValue(i), arrayVector[1]->getValue(i), arrayVector[2]->getValue(i)); } } else { mRemoteTaskIdsControllers.clear(); for (unsigned int i = 0; i < arrayVector[0]->getNumberHeavyDataControllers(); ++i) { mRemoteTaskIdsControllers.push_back(arrayVector[0]->getHeavyDataController(i)); } mLocalNodeIdsControllers.clear(); for (unsigned int i = 0; i < arrayVector[1]->getNumberHeavyDataControllers(); ++i) { mLocalNodeIdsControllers.push_back(arrayVector[1]->getHeavyDataController(i)); } mRemoteLocalNodeIdsControllers.clear(); for (unsigned int i = 0; i < arrayVector[2]->getNumberHeavyDataControllers(); ++i) { mRemoteLocalNodeIdsControllers.push_back(arrayVector[2]->getHeavyDataController(i)); } } } } void XdmfMap::read() { if(mLocalNodeIdsControllers.size() > 0 && mRemoteTaskIdsControllers.size() > 0 && mRemoteLocalNodeIdsControllers.size() > 0) { unsigned int localNodeCount = 0; for (unsigned int i = 0; i< mLocalNodeIdsControllers.size(); ++i) { localNodeCount += mLocalNodeIdsControllers[i]->getSize(); } unsigned int remoteTaskCount = 0; for (unsigned int i = 0; i< mRemoteTaskIdsControllers.size(); ++i) { remoteTaskCount += mRemoteTaskIdsControllers[i]->getSize(); } unsigned int remoteNodeCount = 0; for (unsigned int i = 0; i< mRemoteLocalNodeIdsControllers.size(); ++i) { remoteNodeCount += mRemoteLocalNodeIdsControllers[i]->getSize(); } if(!(localNodeCount == remoteTaskCount && localNodeCount == remoteNodeCount)){ XdmfError::message(XdmfError::FATAL, "Arrays must be of equal size in XdmfMap::read"); } shared_ptr remoteTaskIds = XdmfArray::New(); shared_ptr localNodeIds = XdmfArray::New(); shared_ptr remoteLocalNodeIds = XdmfArray::New(); mRemoteTaskIdsControllers[0]->read(remoteTaskIds.get()); for (unsigned int i = 1; i < mRemoteTaskIdsControllers.size(); ++i) { shared_ptr tempArray = XdmfArray::New(); mRemoteTaskIdsControllers[i]->read(tempArray.get()); remoteTaskIds->insert(remoteTaskIds->getSize(), tempArray, 0, tempArray->getSize()); } mLocalNodeIdsControllers[0]->read(localNodeIds.get()); for (unsigned int i = 1; i < mLocalNodeIdsControllers.size(); ++i) { shared_ptr tempArray = XdmfArray::New(); mLocalNodeIdsControllers[i]->read(tempArray.get()); localNodeIds->insert(localNodeIds->getSize(), tempArray, 0, tempArray->getSize()); } mRemoteLocalNodeIdsControllers[0]->read(remoteLocalNodeIds.get()); for (unsigned int i = 1; i < mRemoteLocalNodeIdsControllers.size(); ++i) { shared_ptr tempArray = XdmfArray::New(); mRemoteLocalNodeIdsControllers[i]->read(tempArray.get()); remoteLocalNodeIds->insert(remoteLocalNodeIds->getSize(), tempArray, 0, tempArray->getSize()); } for(unsigned int i=0; igetSize(); ++i) { const unsigned int remoteTaskId = remoteTaskIds->getValue(i); const unsigned int localNodeId = localNodeIds->getValue(i); const unsigned int remoteLocalNodeId = remoteLocalNodeIds->getValue(i); mMap[remoteTaskId][localNodeId].insert(remoteLocalNodeId); } } } void XdmfMap::release() { mMap.clear(); } void XdmfMap::setHeavyDataControllers(std::vector > remoteTaskIdsControllers, std::vector > localNodeIdsControllers, std::vector > remoteLocalNodeIdsControllers) { unsigned int localNodeCount = 0; for (unsigned int i = 0; i< localNodeIdsControllers.size(); ++i) { localNodeCount += localNodeIdsControllers[i]->getSize(); } unsigned int remoteTaskCount = 0; for (unsigned int i = 0; i< remoteTaskIdsControllers.size(); ++i) { remoteTaskCount += remoteTaskIdsControllers[i]->getSize(); } unsigned int remoteNodeCount = 0; for (unsigned int i = 0; i< remoteLocalNodeIdsControllers.size(); ++i) { remoteNodeCount += remoteLocalNodeIdsControllers[i]->getSize(); } if(!(localNodeCount == remoteTaskCount && localNodeCount == remoteNodeCount)) { XdmfError::message(XdmfError::FATAL, "Arrays must be of equal size in " "XdmfMap::setHeavyDataControllers"); } mRemoteTaskIdsControllers = remoteTaskIdsControllers; mLocalNodeIdsControllers = localNodeIdsControllers; mRemoteLocalNodeIdsControllers = remoteLocalNodeIdsControllers; this->setIsChanged(true); } void XdmfMap::setMap(std::map map) { mMap = map; this->setIsChanged(true); } void XdmfMap::setName(const std::string & name) { mName = name; this->setIsChanged(true); } void XdmfMap::traverse(const shared_ptr visitor) { XdmfItem::traverse(visitor); shared_ptr remoteTaskIds = XdmfArray::New(); shared_ptr localNodeIds = XdmfArray::New(); shared_ptr remoteLocalNodeIds = XdmfArray::New(); for(std::map::const_iterator iter = mMap.begin(); iter != mMap.end(); ++iter) { for(node_id_map::const_iterator iter2 = iter->second.begin(); iter2 != iter->second.end(); ++iter2) { for(node_id_map::mapped_type::const_iterator iter3 = iter2->second.begin(); iter3 != iter2->second.end(); ++iter3) { remoteTaskIds->pushBack(iter->first); localNodeIds->pushBack(iter2->first); remoteLocalNodeIds->pushBack(*iter3); } } } for (unsigned int i = 0; i < mRemoteTaskIdsControllers.size(); ++i) { remoteTaskIds->insert(mRemoteTaskIdsControllers[i]); } for (unsigned int i = 0; i < mLocalNodeIdsControllers.size(); ++i) { localNodeIds->insert(mLocalNodeIdsControllers[i]); } for (unsigned int i = 0; i < mRemoteLocalNodeIdsControllers.size(); ++i) { remoteLocalNodeIds->insert(mRemoteLocalNodeIdsControllers[i]); } bool originalXPath; if (shared_ptr writer = shared_dynamic_cast(visitor)) { originalXPath = writer->getWriteXPaths(); writer->setWriteXPaths(false); } remoteTaskIds->accept(visitor); localNodeIds->accept(visitor); remoteLocalNodeIds->accept(visitor); if (shared_ptr writer = shared_dynamic_cast(visitor)) { writer->setWriteXPaths(originalXPath); } mLocalNodeIdsControllers.clear(); mRemoteTaskIdsControllers.clear(); mRemoteLocalNodeIdsControllers.clear(); for (unsigned int i = 0; i < remoteTaskIds->getNumberHeavyDataControllers(); ++i) { mRemoteTaskIdsControllers.push_back(remoteTaskIds->getHeavyDataController(i)); } for (unsigned int i = 0; i < localNodeIds->getNumberHeavyDataControllers(); ++i) { mLocalNodeIdsControllers.push_back(localNodeIds->getHeavyDataController(i)); } for (unsigned int i = 0; i < remoteLocalNodeIds->getNumberHeavyDataControllers(); ++i) { mRemoteLocalNodeIdsControllers.push_back(remoteLocalNodeIds->getHeavyDataController(i)); } remoteTaskIds.reset(); localNodeIds.reset(); remoteLocalNodeIds.reset(); } // C Wrappers XDMFMAP * XdmfMapNew() { try { shared_ptr generatedMap = XdmfMap::New(); return (XDMFMAP *)((void *)(new XdmfMap(*generatedMap.get()))); } catch (...) { shared_ptr generatedMap = XdmfMap::New(); return (XDMFMAP *)((void *)(new XdmfMap(*generatedMap.get()))); } } XDMFMAP ** XdmfMapNewFromIdVector(int ** globalNodeIds, int * numIdsOnNode, int numIds) { try { std::vector > insertedAttributeVector; for (int i = 0; i < numIds; ++i) { shared_ptr insertedAttribute = XdmfAttribute::New(); insertedAttribute->insert(0, globalNodeIds[i], numIdsOnNode[i], 1, 1); insertedAttributeVector.push_back(insertedAttribute); } std::vector > generatedMaps = XdmfMap::New(insertedAttributeVector); unsigned int returnSize = generatedMaps.size(); XDMFMAP ** returnArray = new XDMFMAP *[returnSize](); for (unsigned int i = 0; i < returnSize; ++i) { returnArray[i] = (XDMFMAP *)((void *)(new XdmfMap(*generatedMaps[i].get()))); } return returnArray; } catch (...) { std::vector > insertedAttributeVector; for (int i = 0; i < numIds; ++i) { shared_ptr insertedAttribute = XdmfAttribute::New(); insertedAttribute->insert(0, globalNodeIds[i], numIdsOnNode[i], 1, 1); insertedAttributeVector.push_back(insertedAttribute); } std::vector > generatedMaps = XdmfMap::New(insertedAttributeVector); unsigned int returnSize = generatedMaps.size(); XDMFMAP ** returnArray = new XDMFMAP *[returnSize](); for (unsigned int i = 0; i < returnSize; ++i) { returnArray[i] = (XDMFMAP *)((void *)(new XdmfMap(*generatedMaps[i].get()))); } return returnArray; } } char * XdmfMapGetName(XDMFMAP * map) { try { char * returnPointer = strdup(((XdmfMap *)(map))->getName().c_str()); return returnPointer; } catch (...) { char * returnPointer = strdup(((XdmfMap *)(map))->getName().c_str()); return returnPointer; } } void XdmfMapInsert(XDMFMAP * map, int remoteTaskId, int localNodeId, int remoteLocalNodeId) { ((XdmfMap *)(map))->insert(remoteTaskId, localNodeId, remoteLocalNodeId); } int XdmfMapIsInitialized(XDMFMAP * map) { return ((XdmfMap *)(map))->isInitialized(); } void XdmfMapRead(XDMFMAP * map, int * status) { XDMF_ERROR_WRAP_START(status) ((XdmfMap *)(map))->read(); XDMF_ERROR_WRAP_END(status) } void XdmfMapRelease(XDMFMAP * map) { ((XdmfMap *)(map))->release(); } int * XdmfMapRetrieveLocalNodeIds(XDMFMAP * map, int remoteTaskId) { try { int * returnPointer = new int[XdmfMapRetrieveNumberLocalNodeIds(map, remoteTaskId)](); std::map > > testMap = ((XdmfMap *)(map))->getMap(); std::map > >::const_iterator iter = testMap.find(remoteTaskId); unsigned int i = 0; for(std::map >::const_iterator iter2 = iter->second.begin(); iter2 != iter->second.end(); ++iter2) { returnPointer[i] = iter2->first; ++i; } return returnPointer; } catch (...) { int * returnPointer = new int[XdmfMapRetrieveNumberLocalNodeIds(map, remoteTaskId)](); std::map > > testMap = ((XdmfMap *)(map))->getMap(); std::map > >::const_iterator iter = testMap.find(remoteTaskId); unsigned int i = 0; for(std::map >::const_iterator iter2 = iter->second.begin(); iter2 != iter->second.end(); ++iter2) { returnPointer[i] = iter2->first; ++i; } return returnPointer; } } int XdmfMapRetrieveNumberLocalNodeIds(XDMFMAP * map, int remoteTaskId) { return ((XdmfMap *)(map))->getMap()[remoteTaskId].size(); } int XdmfMapRetrieveNumberRemoteTaskIds(XDMFMAP * map) { return ((XdmfMap *)(map))->getMap().size(); } int XdmfMapRetrieveNumberRemoteNodeIds(XDMFMAP * map, int remoteTaskId, int localNodeId) { return ((XdmfMap *)(map))->getMap()[remoteTaskId][localNodeId].size(); } int * XdmfMapRetrieveRemoteTaskIds(XDMFMAP * map) { try { int * returnPointer = new int[((XdmfMap *)(map))->getMap().size()](); std::map > > testMap = ((XdmfMap *)(map))->getMap(); unsigned int i = 0; for(std::map > >::const_iterator iter = testMap.begin(); iter != testMap.end(); ++iter) { returnPointer[i] = iter->first; ++i; } return returnPointer; } catch (...) { int * returnPointer = new int[((XdmfMap *)(map))->getMap().size()](); std::map > > testMap = ((XdmfMap *)(map))->getMap(); unsigned int i = 0; for(std::map > >::const_iterator iter = testMap.begin(); iter != testMap.end(); ++iter) { returnPointer[i] = iter->first; ++i; } return returnPointer; } } int * XdmfMapRetrieveRemoteNodeIds(XDMFMAP * map, int remoteTaskId, int localNodeId) { try { int * returnPointer = new int[XdmfMapRetrieveNumberRemoteNodeIds(map, remoteTaskId, localNodeId)](); std::map > > testMap = ((XdmfMap *)(map))->getMap(); std::map > >::const_iterator iter = testMap.find(remoteTaskId); std::map >::const_iterator iter2 = iter->second.find(localNodeId); unsigned int i = 0; for(std::map >::mapped_type::const_iterator iter3 = iter2->second.begin(); iter3 != iter2->second.end(); ++iter3) { returnPointer[i] = *iter3; i++; } return returnPointer; } catch (...) { int * returnPointer = new int[XdmfMapRetrieveNumberRemoteNodeIds(map, remoteTaskId, localNodeId)](); std::map > > testMap = ((XdmfMap *)(map))->getMap(); std::map > >::const_iterator iter = testMap.find(remoteTaskId); std::map >::const_iterator iter2 = iter->second.find(localNodeId); unsigned int i = 0; for(std::map >::mapped_type::const_iterator iter3 = iter2->second.begin(); iter3 != iter2->second.end(); ++iter3) { returnPointer[i] = *iter3; i++; } return returnPointer; } } void XdmfMapSetHeavyDataControllers(XDMFMAP * map, XDMFHEAVYDATACONTROLLER ** remoteTaskControllers, int numRemoteTaskControllers, XDMFHEAVYDATACONTROLLER ** localNodeControllers, int numLocalNodeControllers, XDMFHEAVYDATACONTROLLER ** remoteLocalNodeControllers, int numRemoteLocalNodeControllers, int passControl, int * status) { XDMF_ERROR_WRAP_START(status) std::vector > insertRemoteTaskControllers; for (int i = 0; i < numRemoteTaskControllers; ++i) { if (passControl) { insertRemoteTaskControllers.push_back(shared_ptr(((XdmfHeavyDataController *)remoteTaskControllers[i]))); } else { insertRemoteTaskControllers.push_back(shared_ptr(((XdmfHeavyDataController *)remoteTaskControllers[i]), XdmfNullDeleter())); } } std::vector > insertLocalNodeControllers; for (int i = 0; i < numLocalNodeControllers; ++i) { if (passControl) { insertLocalNodeControllers.push_back(shared_ptr(((XdmfHeavyDataController *)localNodeControllers[i]))); } else { insertLocalNodeControllers.push_back(shared_ptr(((XdmfHeavyDataController *)localNodeControllers[i]), XdmfNullDeleter())); } } std::vector > insertRemoteLocalNodeControllers; for (int i = 0; i < numRemoteLocalNodeControllers; ++i) { if (passControl) { insertRemoteLocalNodeControllers.push_back(shared_ptr(((XdmfHeavyDataController *)remoteLocalNodeControllers[i]))); } else { insertRemoteLocalNodeControllers.push_back(shared_ptr(((XdmfHeavyDataController *)remoteLocalNodeControllers[i]), XdmfNullDeleter())); } } ((XdmfMap *)(map))->setHeavyDataControllers(insertRemoteTaskControllers, insertLocalNodeControllers, insertRemoteLocalNodeControllers); XDMF_ERROR_WRAP_END(status) } void XdmfMapSetName(XDMFMAP * map, char * newName) { ((XdmfMap *)(map))->setName(std::string(newName)); } XDMF_ITEM_C_CHILD_WRAPPER(XdmfMap, XDMFMAP) xdmf-3.0+git20160803/XDMFConfig.cmake.in0000640000175000017500000000541013003006557017365 0ustar alastairalastair#----------------------------------------------------------------------------- # # XDMFConfig.cmake - XDMF CMake configuration file for external projects. # # This file is configured by XDMF and used by the UseXDMF.cmake module # to load XDMF's settings for an external project. # Top level for development or install SET(XDMF_INSTALL_DIR "@XDMF_INSTALL_DIR_CONFIG@") # The XDMF include file directories. SET(XDMF_INCLUDE_DIRS "@XDMF_INCLUDE_DIRS_CONFIG@") # The XDMF library directories. SET(XDMF_LIBRARY_DIRS "@XDMF_LIBRARY_DIRS_CONFIG@") # The location of the UseXDMF.cmake file. SET(XDMF_USE_FILE "@XDMF_USE_FILE@") # The build settings file. SET(XDMF_BUILD_SETTINGS_FILE "@XDMF_BUILD_SETTINGS_FILE@") # The directory containing class list files for each kit. SET(XDMF_KITS_DIR "@XDMF_KITS_DIR@") # Utility libraries used by XDMF. # To include a utility library in another project: # LINK_DIRECTORIES(${XDMF_***_LIBRARY_PATH}) # TARGET_LINK_LIBRARIES(target ${XDMF_***_LIBRARIES}) SET(XDMF_HDF5_INCLUDE "@XDMF_HDF5_INCLUDE_CONFIG@") SET(XDMF_HDF5_LIBRARY_PATH "@XDMF_HDF5_LIBRARY_PATH_CONFIG@") SET(XDMF_HDF5_LIBRARIES "@XDMF_HDF5_LIBRARIES@") SET(XDMF_SYSTEM_HDF5 "@XDMF_SYSTEM_HDF5@") SET(XDMF_LIBXML2_INCLUDE "@XDMF_LIBXML2_INCLUDE_DIR_CONFIG@") SET(XDMF_LIBXML2_LIBRARY_PATH "@XDMF_LIBXML2_LIBRARY_DIR_CONFIG@") SET(XDMF_LIBXML2_LIBRARIES "@XDMF_LIBXML2_LIBRARIES@") SET(XDMF_SYSTEM_LIBXML2 "@XDMF_SYSTEM_HDF5@") SET(XDMF_ZLIB_INCLUDE "@XDMF_ZLIB_INCLUDE_DIR_CONFIG@") SET(XDMF_ZLIB_LIBRARY_PATH "@XDMF_ZLIB_LIBRARY_DIR_CONFIG@") SET(XDMF_ZLIB_LIBRARIES "@XDMF_ZLIB_LIBRARIES@") SET(XDMF_SYSTEM_ZLIB "@XDMF_SYSTEM_ZLIB@") # The XDMF library dependencies. IF(NOT XDMF_NO_LIBRARY_DEPENDS) INCLUDE("@XDMF_LIBRARY_DEPENDS_FILE@") ENDIF(NOT XDMF_NO_LIBRARY_DEPENDS) # Information about this particular XDMF Installation SET(XDMF_BUILD_MPI "@XDMF_BUILD_MPI@") SET(XDMF_BUILD_UTILS "@XDMF_BUILD_UTILS@") SET(XDMF_BUILD_VTK "@XDMF_BUILD_VTK@") SET(XDMF_WRAP_PYTHON "@XDMF_WRAP_PYTHON@") IF(XDMF_BUILD_MPI) SET(XDMF_MPI_LIBRARIES "@XDMF_MPI_LIBRARIES@") SET(XDMF_MPI_INCLUDE_PATH "@XDMF_MPI_INCLUDE_PATH@") ENDIF(XDMF_BUILD_MPI) IF(XDMF_BUILD_UTILS) SET(XDMF_EXODUSII_INCLUDE "@XDMF_EXODUSII_INCLUDE_DIR_CONFIG@") SET(XDMF_EXODUSII_LIBRARY_PATH "@XDMF_EXODUSII_LIBRARY_DIR_CONFIG@") SET(XDMF_EXODUSII_LIBRARIES "@XDMF_EXODUSII_LIBRARIES@") SET(XDMF_METIS_INCLUDE "@XDMF_METIS_INCLUDE_DIR_CONFIG@") SET(XDMF_METIS_LIBRARY_PATH "@XDMF_METIS_LIBRARY_DIR_CONFIG@") SET(XDMF_METIS_LIBRARIES "@XDMF_METIS_LIBRARIES@") SET(XDMF_NETCDF_INCLUDE "@XDMF_NETCDF_INCLUDE_DIR_CONFIG@") SET(XDMF_NETCDF_LIBRARY_PATH "@XDMF_NETCDF_LIBRARY_DIR_CONFIG@") SET(XDMF_NETCDF_LIBRARIES "@XDMF_NETCDF_LIBRARIES@") ENDIF(XDMF_BUILD_UTILS) IF(XDMF_BUILD_VTK) SET(XDMF_VTK_DIR "@VTK_DIR@") ENDIF(XDMF_BUILD_VTK) xdmf-3.0+git20160803/XdmfGridCollectionType.cpp0000640000175000017500000001101213003006557021153 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfGridCollectionType.cpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #include #include "XdmfError.hpp" #include "XdmfGridCollectionType.hpp" std::map(*)()> XdmfGridCollectionType::mGridCollectionDefinitions; // Supported XdmfGridCollectionTypes shared_ptr XdmfGridCollectionType::NoCollectionType() { static shared_ptr p(new XdmfGridCollectionType("None")); return p; } shared_ptr XdmfGridCollectionType::Spatial() { static shared_ptr p(new XdmfGridCollectionType("Spatial")); return p; } shared_ptr XdmfGridCollectionType::Temporal() { static shared_ptr p(new XdmfGridCollectionType("Temporal")); return p; } void XdmfGridCollectionType::InitTypes() { mGridCollectionDefinitions["NONE"] = NoCollectionType; mGridCollectionDefinitions["SPATIAL"] = Spatial; mGridCollectionDefinitions["TEMPORAL"] = Temporal; } XdmfGridCollectionType::XdmfGridCollectionType(const std::string & name) : mName(name) { } XdmfGridCollectionType::~XdmfGridCollectionType() { } shared_ptr XdmfGridCollectionType::New(const std::map & itemProperties) { InitTypes(); std::map::const_iterator type = itemProperties.find("CollectionType"); if(type == itemProperties.end()) { XdmfError::message(XdmfError::FATAL, "'CollectionType' not in itemProperties in " "XdmfGridCollectionType::New"); } const std::string & typeVal = ConvertToUpper(type->second); std::map(*)()>::const_iterator returnType = mGridCollectionDefinitions.find(typeVal); if (returnType == mGridCollectionDefinitions.end()) { XdmfError::message(XdmfError::FATAL, "'CollectionType' not of 'None', 'Spatial', or " "'Temporal' in XdmfGridCollectionType::New"); } else { return (*(returnType->second))(); } XdmfError::message(XdmfError::FATAL, "'CollectionType' not of 'None', 'Spatial', or " "'Temporal' in XdmfGridCollectionType::New"); // unreachable return shared_ptr(); } void XdmfGridCollectionType::getProperties(std::map & collectedProperties) const { collectedProperties.insert(std::make_pair("CollectionType", mName)); } // C Wrappers int XdmfGridCollectionTypeNoCollectionType() { return XDMF_GRID_COLLECTION_TYPE_NO_COLLECTION_TYPE; } int XdmfGridCollectionTypeSpatial() { return XDMF_GRID_COLLECTION_TYPE_SPATIAL; } int XdmfGridCollectionTypeTemporal() { return XDMF_GRID_COLLECTION_TYPE_TEMPORAL; } xdmf-3.0+git20160803/XdmfReader.hpp0000640000175000017500000000741013003006557016626 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfReader.hpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef XDMFREADER_HPP_ #define XDMFREADER_HPP_ // C Compatible Includes #include "Xdmf.hpp" #include "XdmfCoreReader.hpp" #ifdef __cplusplus /** * @brief Reads an Xdmf file stored on disk into memory. * * Reads an Xdmf file stored on disk into an Xdmf structure in * memory. All light data is parsed in order to create appropriate * Xdmf objects. Heavy data controllers are created and attached to * XdmfArrays but no heavy data is read into memory. */ class XDMF_EXPORT XdmfReader : public XdmfCoreReader { public: /** * Create a new XdmfReader. * * Example of use: * * C++ * * @dontinclude ExampleXdmfReader.cpp * @skipline //#initialization * @until //#initialization * * Python * * @dontinclude XdmfExampleReader.py * @skipline #//initialization * @until #//initialization * * @return Constructed XdmfReader. */ static shared_ptr New(); virtual ~XdmfReader(); /** * Uses the internal item factory to create a copy of the internal pointer * of the provided shared pointer. Primarily used for C wrapping. * * @param original The source shared pointer that the pointer will be pulled from. * @return A duplicate of the object contained in the pointer. */ virtual XdmfItem * DuplicatePointer(shared_ptr original) const; shared_ptr read(const std::string & filePath) const; std::vector > read(const std::string & filePath, const std::string & xPath) const; XdmfReader(const XdmfReader &); protected: XdmfReader(); private: void operator=(const XdmfReader &); // Not implemented. }; #endif #ifdef __cplusplus extern "C" { #endif // C wrappers go here struct XDMFREADER; // Simply as a typedef to ensure correct typing typedef struct XDMFREADER XDMFREADER; XDMF_EXPORT XDMFREADER * XdmfReaderNew(); XDMF_EXPORT void XdmfReaderFree(XDMFREADER * item); XDMF_CORE_READER_C_CHILD_DECLARE(XdmfReader, XDMFREADER, XDMF) #ifdef __cplusplus } #endif #endif /* XDMFREADER_HPP_ */ xdmf-3.0+git20160803/Examples/0000740000175000017500000000000013003006557015646 5ustar alastairalastairxdmf-3.0+git20160803/Examples/Cxx/0000740000175000017500000000000013003006557016410 5ustar alastairalastairxdmf-3.0+git20160803/Examples/Cxx/XdmfFortranExampleTriMesh.f900000640000175000017500000000525513003006557024003 0ustar alastairalastair!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! !! AUTHOR: Kenneth Leiter (kenneth.leiter@arl.army.mil) !! !! Use the Xdmf Fortran Bindings to write out a simple mesh consisting of !! two hexahedrons. Link against the XdmfFortran library to compile. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! PROGRAM XdmfFortranExample !DEC$ ATTRIBUTES DLLIMPORT, ALIAS:'_XdmfInit'::XdmfInit !DEC$ ATTRIBUTES DLLIMPORT, ALIAS:'_XdmfSetGridTopology'::XdmfSetGridTopology !DEC$ ATTRIBUTES DLLIMPORT, ALIAS:'_XdmfSetGridGeometry'::XdmfSetGridGeometry !DEC$ ATTRIBUTES DLLIMPORT, ALIAS:'_XdmfSetGridAttribute'::XdmfSetGridAttribute !DEC$ ATTRIBUTES DLLIMPORT, ALIAS:'_XdmfAddGridAttribute'::XdmfAddGridAttribute !DEC$ ATTRIBUTES DLLIMPORT, ALIAS:'_XdmfWriteGrid'::XdmfWriteGrid !DEC$ ATTRIBUTES DLLIMPORT, ALIAS:'_XdmfWriteToFile'::XdmfWriteToFile !DEC$ ATTRIBUTES DLLIMPORT, ALIAS:'_XdmfSerialize'::XdmfSerialize !DEC$ ATTRIBUTES DLLIMPORT, ALIAS:'_XdmfClose'::XdmfClose INTEGER*8 obj character*256 filename REAL*4 myPoints(3,5) INTEGER myConnections(3,3) REAL*8 myNodeAttribute(5) filename = 'my_output'//CHAR(0) myPoints(1,1) = 0 myPoints(2,1) = 0 myPoints(3,1) = 0 myPoints(1,2) = 1 myPoints(2,2) = 2 myPoints(3,2) = 0 myPoints(1,3) = 2 myPoints(2,3) = 0 myPoints(3,3) = 0 myPoints(1,4) = 3 myPoints(2,4) = 2 myPoints(3,4) = 0 myPoints(1,5) = 4 myPoints(2,5) = 0 myPoints(3,5) = 0 myConnections(1,1) = 0 myConnections(2,1) = 1 myConnections(3,1) = 2 myConnections(1,2) = 2 myConnections(2,2) = 1 myConnections(3,2) = 3 myConnections(1,3) = 2 myConnections(2,3) = 3 myConnections(3,3) = 4 myNodeAttribute(1) = 100 myNodeAttribute(2) = 300 myNodeAttribute(3) = 300 myNodeAttribute(4) = 500 myNodeAttribute(5) = 200 CALL XDMFINIT(obj, filename) CALL XDMFSETGRIDTOPOLOGY(obj, 'Triangle'//CHAR(0), 3, myConnections) CALL XDMFSETGRIDGEOMETRY(obj, 'XYZ'//CHAR(0), 'XDMF_FLOAT32_TYPE'//CHAR(0), 5, myPoints) CALL XDMFADDGRIDATTRIBUTE(obj, 'NodeValues'//CHAR(0),'XDMF_FLOAT64_TYPE'//CHAR(0), 'NODE'//CHAR(0), & 'SCALAR'//CHAR(0), 5, myNodeAttribute) CALL XDMFWRITEGRID(obj, 'TestGrid'//CHAR(0)) CALL XDMFWRITETOFILE(obj) CALL XDMFSERIALIZE(obj) CALL XDMFCLOSE(obj) END xdmf-3.0+git20160803/Examples/Cxx/XdmfFormatExample.cxx0000640000175000017500000001334513003006557022527 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : $Id: XdmfFormatExample.cxx,v 1.1 2007-10-19 18:55:10 dave.demarle Exp $ */ /* Date : $Date: 2007-10-19 18:55:10 $ */ /* Version : $Revision: 1.1 $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2002 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #include //using namespace std; // Usage : XdmfFormatExample [ DataSetName ] int main( int argc, char **argv ) { XdmfHDF *ExternalDataSet; XdmfArray *InCoreData; XdmfArray *InCoreSection; XdmfArray *InCoreCoordinates; XdmfInt32 Rank = 3; // All Dimenions are "slowest changing first" : K,J,I // and zero based XdmfInt64 Dimensions[] = { 10, 20, 30 }; const char *DataSetNameConst; char *DataSetName; int i, k; double *DataFromSomewhereElse; if(argc > 1 ) { // i.e. NDGM:TestFile.h5:/TestDataSets/Values1 DataSetNameConst = argv[1]; } else { // Domain:FileName:/HDF5Directory/..../HDF5DataSetName // Domains : FILE, NDGM, GASS (Globus), CORE (malloc) DataSetNameConst = "SERIAL:TestFile.h5:/TestDataSets/Values1"; } DataSetName = new char[ strlen(DataSetNameConst) + 1 ]; strcpy(DataSetName, DataSetNameConst); // Create Some Data // XdmfArray and XdmfHDF ( and some others ) are derived // classes from XdmfDataDesc. XdmfDataDesc has number type, // number shape (rank and dimensions), and number selection. // Selection is which "part" of the entire dataset we're // dealing with. i.e WE could have a shape of [ 100, 200, 300 ] // but just dealing with a block of [10, 20, 30 ] somewhere in // the middle. By default Selction == Shape ... the whole thing. InCoreData = new XdmfArray(); InCoreData->SetGlobalDebug(1); InCoreData->SetNumberType( XDMF_FLOAT64_TYPE ); InCoreData->SetShape( Rank, Dimensions ); InCoreData->Generate( 0, 5999 ); // Convenience for : // for( i = 0 ; i < InCoreData->GetNumberOfElements() ; i++ ){ // InCoreData->SetValue( i, i ); // } // // Create an external dataset if it doesn't exist ExternalDataSet = new XdmfHDF(); ExternalDataSet->SetDebug(1); // ExternalDataSet->SetCompression(9); ExternalDataSet->CopyType( InCoreData ); ExternalDataSet->CopyShape( InCoreData ); // In am MPI app the External Dataset would // probable be much bigger that each node's InCore. // i.e. ExternalDataSet->SetShape( 3, GloablDomainDimensions ) // but here we'll deal with just the InCore dataset size. if(ExternalDataSet->Open( DataSetName, "rw" ) == XDMF_FAIL){ ExternalDataSet->CreateDataset(DataSetName); } // Write the Data ExternalDataSet->Write( InCoreData ); ExternalDataSet->Close(); // exit(1); // Now Read in 4 values from the "corners" InCoreCoordinates = new XdmfArray(); // Most Methods have a "FromString" convenience method. // This makes wrapping for Python/Tcl/Java easier InCoreCoordinates->SetNumberTypeFromString( "XDMF_FLOAT64_TYPE" ); InCoreCoordinates->SetShapeFromString("4"); // This is just the same dataset we wrote // number type and shape get (re)set on Open // ExternalDataSet->Open( DataSetName, "r" ); // Selections can be : // HyperSlab - Start, Stride, Count for Each Dimension // Coordinate - Parametric Coordinates // Function - Lex/Yacc stuff .... $0 * $1 / 1.2 ExternalDataSet->Open( DataSetName, "r" ); ExternalDataSet->SelectCoordinatesFromString("0 0 0 0 0 29 9 19 0 9 19 29"); ExternalDataSet->Read( InCoreCoordinates ); ExternalDataSet->Close(); cout << endl; cout << "4 of the Corners == "; DataFromSomewhereElse = (double *)InCoreCoordinates->GetDataPointer(); for( k = 0 ; k < 4 ; k++ ){ cout << " " << *DataFromSomewhereElse++; } cout << endl; InCoreSection = new XdmfArray(); // Instead of allocating itself, use // an external pointer : core dumps are // your fault !! DataFromSomewhereElse = new double[ 150 ]; InCoreSection->SetDataPointer( DataFromSomewhereElse ); InCoreSection->SetNumberTypeFromString( "XDMF_FLOAT64_TYPE" ); // Make a 2D array to read back a section of the data // We'll read in one "J" PLane InCoreSection->SetShapeFromString("10 15"); ExternalDataSet->Open( DataSetName, "r" ); ExternalDataSet->SelectHyperSlabFromString("0 9 0", "1 1 2", "10 1 15"); // So from a 10x20x30 data set, start at 0,9,0. Stride 2 in Idim // and read in 10 K x 1 J x ( 30 / 2 ) = 15 I ... a slice ExternalDataSet->Read( InCoreSection ); ExternalDataSet->Close(); cout << endl; for( k = 0 ; k < 10 ; k++ ){ cout << "k = " << k << ":"; for( i = 0 ; i < 15 ; i++ ){ cout << " " << *DataFromSomewhereElse++; } cout << endl; } delete [] DataSetName; return 0; } xdmf-3.0+git20160803/Examples/Cxx/Modified.f0000640000175000017500000001211313003006557020277 0ustar alastairalastairCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C C Create a Grid of Hexahedron Centered at 0,0,0 C CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC SUBROUTINE CreateGrid( IDIM, JDIM, KDIM, XYZ, ICONN ) INTEGER IDIM, JDIM, KDIM REAL*8 XYZ DIMENSION XYZ( 3, IDIM, JDIM, KDIM ) INTEGER ICONN DIMENSION ICONN ( 8, ( IDIM - 1 ) * ( JDIM - 1 ) * ( KDIM - 1 )) INTEGER I, J, K, IDX REAL*8 X, Y, Z, DX, DY, DZ C Print *, 'Size = ', IDIM, JDIM, KDIM PRINT *, 'Initialze Problem' C XYZ Values of Nodes C From -1 to 1 DX = 2.0 / ( IDIM - 1 ) DY = 2.0 / ( JDIM - 1 ) DZ = 2.0 / ( KDIM - 1 ) Z = -1.0 DO 112 K= 1, KDIM Y = -1.0 DO 111 J= 1, JDIM X = -1.0 DO 110 I= 1, IDIM XYZ( 1, I, J, K ) = X XYZ( 2, I, J, K ) = Y XYZ( 3, I, J, K ) = Z X = X + DX 110 CONTINUE Y = Y + DY 111 CONTINUE Z = Z + DZ 112 CONTINUE C Connections IDX = 1 DO 122 K= 0, KDIM - 2 DO 121 J= 0, JDIM - 2 DO 120 I= 1, IDIM - 1 ICONN( 1, IDX ) = ( K * JDIM * IDIM ) + ( J * IDIM ) + I ICONN( 2, IDX ) = ( K * JDIM * IDIM ) + ( J * IDIM ) + I + 1 ICONN( 3, IDX ) = ( ( K + 1 ) * JDIM * IDIM ) + ( J * IDIM ) + I + 1 ICONN( 4, IDX ) = ( ( K + 1 ) * JDIM * IDIM ) + ( J * IDIM ) + I ICONN( 5, IDX ) = ( K * JDIM * IDIM ) + ( ( J + 1 ) * IDIM ) + I ICONN( 6, IDX ) = ( K * JDIM * IDIM ) + ( ( J + 1 ) * IDIM ) + I + 1 ICONN( 7, IDX ) = ( ( K + 1 ) * JDIM * IDIM ) + C ( ( J + 1 ) * IDIM ) + I + 1 ICONN( 8, IDX ) = ( ( K + 1 ) * JDIM * IDIM ) + C ( ( J + 1 ) * IDIM ) + I IDX = IDX + 1 120 CONTINUE 121 CONTINUE 122 CONTINUE RETURN END CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C C Create a Node Centered Solution Field C CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC SUBROUTINE NodeData( IDIM, JDIM, KDIM, XYZ, NCVALUES) INTEGER IDIM, JDIM, KDIM REAL*8 XYZ DIMENSION XYZ( 3, IDIM, JDIM, KDIM ) REAL*8 NCVALUES DIMENSION NCVALUES( IDIM, JDIM, KDIM ) INTEGER I, J, K REAL*8 X, Y, Z PRINT *, 'Calculating Node Centered Data' DO 212, K=1, KDIM DO 211, J=1, JDIM DO 210, I=1, IDIM X = XYZ( 1, I, J, K ) Y = XYZ( 2, I, J, K ) Z = XYZ( 3, I, J, K ) NCVALUES( I, J, K ) = SQRT( ( X * X ) + ( Y * Y ) + ( Z * Z )) 210 CONTINUE 211 CONTINUE 212 CONTINUE RETURN END CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C C Create a Cell Centered Solution Field C CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC SUBROUTINE CellData( IDIM, JDIM, KDIM, ITER, KICKER, XYZ, CCVALUES) INTEGER IDIM, JDIM, KDIM, ITER, KICKER REAL*8 XYZ DIMENSION XYZ( 3, IDIM, JDIM, KDIM ) REAL*8 CCVALUES DIMENSION CCVALUES( IDIM - 1, JDIM - 1, KDIM - 1 ) INTEGER I, J, K PRINT *, 'Calculating Cell Centered Data for Iteration ', ITER DO 312, K=1, KDIM - 1 DO 311, J=1, JDIM - 1 DO 310, I=1, IDIM - 1 X = XYZ( 1, I, J, K ) CCVALUES( I, J, K ) = C SIN( ( ( X + 1 ) * IDIM * KICKER ) / 3 * ITER ) / C EXP( X / ( 1.0 * ITER ) ) 310 CONTINUE 311 CONTINUE 312 CONTINUE C Waste Time DO 313 I=1, 1000000 X = 0.1 * ITER / I Y = SQRT( X * X ) Z = EXP( Y ) 313 CONTINUE RETURN END CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C C Main Program : C Initialize Grid C Initialize Node Centered Data C For Iteration = 1 to 10 C Generate Cell Centered Data C Done C CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC PROGRAM HexMesh PARAMETER ( IDIM = 11 ) PARAMETER ( JDIM = 13 ) PARAMETER ( KDIM = 15 ) REAL*8 XYZ DIMENSION XYZ( 3, IDIM, JDIM, KDIM ) REAL*8 NCVALUES DIMENSION NCVALUES( IDIM, JDIM, KDIM ) REAL*8 CCVALUES DIMENSION CCVALUES( IDIM - 1, JDIM - 1, KDIM - 1 ) INTEGER ICONN DIMENSION ICONN ( 8, ( IDIM - 1 ) * ( JDIM - 1 ) * ( KDIM - 1 )) INTEGER ITER, KICKER, NITER, NARG INTEGER IUNIT CHARACTER*80 ARGIN NARG = IARGC() IF( NARG .GE. 1 ) THEN CALL GETARG( 1, ARGIN ) READ( ARGIN, '(I)') NITER ELSE NITER = 10 ENDIF CALL CreateGrid ( IDIM, JDIM, KDIM, XYZ, ICONN ) CALL NodeData( IDIM, JDIM, KDIM, XYZ, NCVALUES) CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C C Added Routines to Write Out HDF5 via XDMF C CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC IUNIT = 14 OPEN( IUNIT, FILE='XYZ.dat', STATUS='unknown' ) REWIND IUNIT WRITE ( IUNIT, * ) IDIM * JDIM * KDIM WRITE ( IUNIT, * ) XYZ CLOSE ( IUNIT ) IUNIT = 14 OPEN( IUNIT, FILE='CONN.dat', STATUS='unknown' ) REWIND IUNIT WRITE ( IUNIT, * ) 'Hex', ( IDIM - 1 ) * ( JDIM - 1 ) * ( KDIM - 1 ) WRITE ( IUNIT, * ) ICONN CLOSE ( IUNIT ) IUNIT = 14 OPEN( IUNIT, FILE='NodeValues.dat', STATUS='unknown' ) REWIND IUNIT WRITE ( IUNIT, * ) NCVALUES CLOSE ( IUNIT ) IUNIT = 14 OPEN( IUNIT, FILE='CellValues.dat', STATUS='unknown' ) REWIND IUNIT INHEX = ( IDIM - 1 ) * ( JDIM - 1 ) * ( KDIM - 1 ) INPNT = IDIM * JDIM * KDIM KICKER = NITER DO 1000 ITER = 1, NITER CALL CellData( IDIM, JDIM, KDIM, ITER, KICKER, XYZ, CCVALUES) WRITE ( IUNIT, * ) CCVALUES CALL XDMFWRITE( 'Demo', ITER, INPNT, INHEX, XYZ, ICONN, NCVALUES, CCVALUES) 1000 CONTINUE CLOSE ( IUNIT ) END xdmf-3.0+git20160803/Examples/Cxx/XdmfMpiExample.cxx0000640000175000017500000001253413003006557022023 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : $Id: XdmfMpiExample.cxx,v 1.1 2007-10-19 18:55:10 dave.demarle Exp $ */ /* Date : $Date: 2007-10-19 18:55:10 $ */ /* Version : $Revision: 1.1 $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2002 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #include #include "mpi.h" //using namespace std; // Usage : XdmfFormatExample [ DataSetName ] int main( int argc, char **argv ) { XdmfHDF *ExternalDataSet; XdmfArray *InCoreData; XdmfArray *InCoreSection; XdmfInt32 Rank = 3; // All Dimenions are "slowest changing first" : K,J,I // and zero based XdmfInt64 Dimensions[] = { 0, 20, 30 }; XdmfInt64 Start[] = { 0, 0, 0 }; XdmfInt64 Stride[] = { 1, 1, 1 }; XdmfInt64 Count[] = { 0, 20, 30 }; XdmfInt64 NumKPlanes = 10; const char *DataSetNameConst; char *DataSetName; int i, k; double *DataFromSomewhereElse; int size, rank; if(argc > 1 ) { // i.e. NDGM:TestFile.h5:/TestDataSets/Values1 DataSetNameConst = argv[1]; } else { // Domain:FileName:/HDF5Directory/..../HDF5DataSetName // Domains : FILE, NDGM, GASS (Globus), CORE (malloc) DataSetNameConst = "FILE:TestFile.h5:/TestDataSets/Values1"; } DataSetName = new char[ strlen(DataSetNameConst) + 1 ]; strcpy(DataSetName, DataSetNameConst); MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &size); MPI_Comm_rank(MPI_COMM_WORLD, &rank); cout << "Hello from Id " << rank << " of " << size << endl; NumKPlanes = 2 * size; Dimensions[0] = NumKPlanes; Count[0] = 2; Start[0] = rank * 2; // Create Some Data // XdmfArray and XdmfHDF ( and some others ) are derived // classes from XdmfDataDesc. XdmfDataDesc has number type, // number shape (rank and dimensions), and number selection. // Selection is which "part" of the entire dataset we're // dealing with. i.e WE could have a shape of [ 100, 200, 300 ] // but just dealing with a block of [10, 20, 30 ] somewhere in // the middle. By default Selction == Shape ... the whole thing. InCoreData = new XdmfArray(); // InCoreData->SetGlobalDebug(rank); InCoreData->SetNumberType( XDMF_FLOAT64_TYPE ); // InCoreData->SetShape( Rank, Dimensions ); InCoreData->SetShape( Rank, Count); InCoreData->Generate( rank + 1, rank + 1); // InCoreData->SelectHyperSlab(Start, Stride, Count); // Convenience for : // for( i = 0 ; i < InCoreData->GetNumberOfElements() ; i++ ){ // InCoreData->SetValue( i, i ); // } // // Create an external dataset if it doesn't exist ExternalDataSet = new XdmfHDF(); // ExternalDataSet->SetDebug(rank); // ExternalDataSet->SetCompression(9); ExternalDataSet->SetNumberType( XDMF_FLOAT64_TYPE ); ExternalDataSet->SetShape( Rank, Dimensions ); // ExternalDataSet->CopyShape( InCoreData ); // In am MPI app the External Dataset would // probable be much bigger that each node's InCore. // i.e. ExternalDataSet->SetShape( 3, GloablDomainDimensions ) // but here we'll deal with just the InCore dataset size. // ExternalDataSet->Open( DataSetName, "rw" ); if(ExternalDataSet->Open( DataSetName, "rw" ) == XDMF_FAIL){ ExternalDataSet->CreateDataset(DataSetName); } ExternalDataSet->SelectHyperSlab(Start, Stride, Count); // InCoreData->SelectHyperSlab(Start, Stride, Count); // Write the Data ExternalDataSet->Write( InCoreData ); ExternalDataSet->Close(); // Read a J Plane down the middle InCoreSection = new XdmfArray(); // Instead of allocating itself, use // an external pointer : core dumps are // your fault !! DataFromSomewhereElse = new double[ NumKPlanes * 30 ]; InCoreSection->SetDataPointer( DataFromSomewhereElse ); InCoreSection->SetNumberTypeFromString( "XDMF_FLOAT64_TYPE" ); InCoreSection->SetNumberOfElements(NumKPlanes * 30); ExternalDataSet->Open( DataSetName, "r" ); Count[0] = NumKPlanes; Count[1] = 1; Start[0] = 0; ExternalDataSet->SelectHyperSlab(Start, Stride, Count); ExternalDataSet->Read( InCoreSection ); ExternalDataSet->Close(); if(rank == 0){ cout << endl; for( k = 0 ; k < NumKPlanes ; k++ ){ cout << "k = " << k << ":"; for( i = 0 ; i < 30 ; i++ ){ cout << " " << *DataFromSomewhereElse++; } cout << endl; } } delete [] DataSetName; MPI_Finalize(); return 0; } xdmf-3.0+git20160803/Examples/Cxx/XdmfDsmH5.cxx0000640000175000017500000001175013003006557020701 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : $Id: XdmfDsmH5.cxx,v 1.1 2007-10-19 18:55:10 dave.demarle Exp $ */ /* Date : $Date: 2007-10-19 18:55:10 $ */ /* Version : $Revision: 1.1 $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2007 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #include "Xdmf.h" #include "mpi.h" #include "pthread.h" int DsmReady = 0; void *DoServer(void *ptr){ XdmfDsmBuffer *MyDsm, *OrigDsm = (XdmfDsmBuffer *)ptr; XdmfInt32 op = 0; int rank; MyDsm = new XdmfDsmBuffer; MyDsm->Copy(OrigDsm); rank = MyDsm->GetComm()->GetId(); cout << " Starting DSM Service on node " << MyDsm->GetComm()->GetId() << endl; DsmReady = 1; while(op != XDMF_DSM_OPCODE_DONE){ op = 0; MyDsm->ServiceOnce(&op); } cout << " Ending DSM Service on node " << MyDsm->GetComm()->GetId() << endl; } void WaitForAll(int rank, int value, MPI_Comm comm){ cout << "(" << rank << ") in barrier " << value << endl; MPI_Barrier(comm); cout << "(" << rank << ") out of barrier " << value << endl; } int main( int argc, char **argv ) { MPI_Comm XdmfComm; XdmfInt32 rank, status; XdmfArray Data; XdmfDsmCommMpi *MyComm = new XdmfDsmCommMpi; XdmfDsmBuffer *MyDsm = new XdmfDsmBuffer; pthread_t thread1; const char *DataSetNameConst = "DSM:TestFile.h5:/TestDataSets/Values1"; XdmfInt32 Rank = 3; XdmfInt64 Dimensions[] = { 10, 20, 30 }; XdmfHDF *ExternalDataSet; XdmfArray *InCoreCoordinates; char *DataSetName; int i, k, provided; double *DataFromSomewhereElse; // MPI_Init(&argc, &argv); MPI_Init_thread(&argc, &argv, MPI_THREAD_SERIALIZED, &provided); MyComm->Init(); // New Communicator for Xdmf Transactions MyComm->DupComm( MPI_COMM_WORLD ); cout << "Hello from " << MyComm->GetId() << " of " << MyComm->GetTotalSize() << endl; rank = MyComm->GetId(); // Uniform Dsm : every node has a buffer of 1000000. Addresses are sequential MyDsm->ConfigureUniform(MyComm, 1000000); pthread_create( &thread1, NULL, DoServer, MyDsm); // pthread_create( &thread1, NULL, DoServer, &td); while(!DsmReady){ // Spin } cout << "Service Ready on " << rank << endl; WaitForAll(rank, 1, MPI_COMM_WORLD); // Begin HDF5 ExternalDataSet = new XdmfHDF(); // ExternalDataSet->SetDebug(1); ExternalDataSet->SetDsmBuffer(MyDsm); Data.SetNumberType( XDMF_FLOAT64_TYPE ); Data.SetShape( Rank, Dimensions ); Data.Generate( 0, 5999 ); DataSetName = new char[ strlen(DataSetNameConst) + 1 ]; strcpy(DataSetName, DataSetNameConst); if(rank == 0){ ExternalDataSet->CopyType(&Data); ExternalDataSet->CopyShape(&Data); if(ExternalDataSet->Open( DataSetName, "rw" ) == XDMF_FAIL){ ExternalDataSet->CreateDataset(DataSetName); } ExternalDataSet->Write(&Data); ExternalDataSet->Close(); } WaitForAll(rank, 2, MPI_COMM_WORLD); if(rank == 1){ // cout << "(" << rank << ") Sleeping" << endl; // sleep(10); // cout << "(" << rank << ") Sending Done" << endl; InCoreCoordinates = new XdmfArray(); InCoreCoordinates->SetNumberTypeFromString( "XDMF_FLOAT64_TYPE" ); InCoreCoordinates->SetShapeFromString("4"); ExternalDataSet->Open( DataSetName, "r" ); ExternalDataSet->SelectCoordinatesFromString("0 0 0 0 0 29 9 19 0 9 19 29"); ExternalDataSet->Read( InCoreCoordinates ); ExternalDataSet->Close(); cout << endl; cout << "4 of the Corners == "; DataFromSomewhereElse = (double *)InCoreCoordinates->GetDataPointer(); for( k = 0 ; k < 4 ; k++ ){ cout << " " << *DataFromSomewhereElse++; } cout << endl; MyDsm->SendDone(); } WaitForAll(rank, 3, MPI_COMM_WORLD); pthread_join( thread1, NULL); delete MyDsm; delete MyComm; MPI_Finalize(); return 0; } xdmf-3.0+git20160803/Examples/Cxx/CVS/0000740000175000017500000000000013003006557017043 5ustar alastairalastairxdmf-3.0+git20160803/Examples/Cxx/CVS/Repository0000640000175000017500000000002213003006557021141 0ustar alastairalastairXdmf/Examples/Cxx xdmf-3.0+git20160803/Examples/Cxx/CVS/Root0000640000175000017500000000006413003006557017713 0ustar alastairalastair:pserver:anonymous@public.kitware.com:/cvsroot/Xdmf xdmf-3.0+git20160803/Examples/Cxx/CVS/Entries0000640000175000017500000000131313003006557020377 0ustar alastairalastair/CMakeLists.txt/1.1/Fri Oct 19 18:55:10 2007// /DemoAllTimes.xmf/1.1/Fri May 2 15:33:38 2008// /DemoXdmfF77IO.cxx/1.2/Fri May 2 19:54:49 2008// /Modified.f/1.1/Fri May 2 15:33:38 2008// /Original.f/1.1/Fri May 2 15:33:38 2008// /XdmfDsmExample.cxx/1.1/Fri Oct 19 18:55:10 2007// /XdmfDsmH5.cxx/1.1/Fri Oct 19 18:55:10 2007// /XdmfDsmH5Slice.cxx/1.1/Fri Oct 19 18:55:10 2007// /XdmfDsmThreads.cxx/1.1/Fri Oct 19 18:55:10 2007// /XdmfFormatExample.cxx/1.1/Fri Oct 19 18:55:10 2007// /XdmfFortranExample.f90/1.3/Fri Oct 2 12:57:18 2009// /XdmfFortranExampleTriMesh.f90/1.1/Fri Oct 2 12:57:19 2009// /XdmfMpiExample.cxx/1.1/Fri Oct 19 18:55:10 2007// /XdmfSTLConverterExample.cxx/1.3/Wed Oct 7 19:52:34 2009// D xdmf-3.0+git20160803/Examples/Cxx/CMakeLists.txt0000640000175000017500000000141313003006557021151 0ustar alastairalastairADD_EXECUTABLE(XdmfFormatExample XdmfFormatExample.cxx) TARGET_LINK_LIBRARIES(XdmfFormatExample Xdmf) IF (XDMF_BUILD_MPI) ADD_EXECUTABLE(XdmfDsmH5 XdmfDsmH5.cxx) TARGET_LINK_LIBRARIES(XdmfDsmH5 Xdmf ${XDMF_MPI_LIBRARIES}) ADD_EXECUTABLE(XdmfDsmH5Slice XdmfDsmH5Slice.cxx) TARGET_LINK_LIBRARIES(XdmfDsmH5Slice Xdmf ${XDMF_MPI_LIBRARIES}) ADD_EXECUTABLE(XdmfDsmThreads XdmfDsmThreads.cxx) TARGET_LINK_LIBRARIES(XdmfDsmThreads Xdmf ${XDMF_MPI_LIBRARIES}) ADD_EXECUTABLE(XdmfDsmExample XdmfDsmExample.cxx) TARGET_LINK_LIBRARIES(XdmfDsmExample Xdmf ${XDMF_MPI_LIBRARIES}) ENDIF (XDMF_BUILD_MPI) IF (XDMF_SYSTEM_HDF5_IS_PARALLEL) ADD_EXECUTABLE(XdmfMpiExample XdmfMpiExample.cxx) TARGET_LINK_LIBRARIES(XdmfMpiExample Xdmf) ENDIF (XDMF_SYSTEM_HDF5_IS_PARALLEL) xdmf-3.0+git20160803/Examples/Cxx/DemoAllTimes.xmf0000740000175000017500000000206313003006557021447 0ustar alastairalastair xdmf-3.0+git20160803/Examples/Cxx/DemoXdmfF77IO.cxx0000640000175000017500000000767513003006557021374 0ustar alastairalastair#include // We want the filenames to be based on the iteration // and padded with zeros using std::setw; using std::setfill; // This works with g77. Different compilers require different // name mangling. #define XdmfWrite xdmfwrite_ // // C/C++ expect NULL terminated strings. Here is a conversion subroutine. char * DemoConvertFortranString( char *FtnName ) { static char Name[80]; char *np; memcpy(Name, FtnName, 79 ); Name[79] = '\0'; np = &Name[78]; while( ( np > Name ) && ( *np <= ' ') ) { np--; } *np = '\0'; return( Name ); } // // C++ will mangle the name based on the argument list. This tells the // compiler not to mangle the name so we can call it from 'C' (but // really Fortran in this case) // extern "C" { // void XdmfWrite( char *FtnName, int *Iteration, int *NumberOfPoints, int *NumberOfHex, XdmfFloat64 *Points, XdmfInt32 *Conns, XdmfFloat64 *NodeData, XdmfFloat64 *CellData){ char *Name; char FullName[80]; ostrstream DataName(FullName, 80); XdmfDOM dom; XdmfRoot root; XdmfDomain domain; XdmfGrid grid; XdmfTime time; XdmfTopology *topology; XdmfGeometry *geometry; XdmfAttribute nodedata; XdmfAttribute celldata; XdmfArray *array; // Name = DemoConvertFortranString( FtnName ); // root.SetDOM(&dom); root.SetVersion(2.0); root.Build(); // Domain root.Insert(&domain); // Grid grid.SetName("Demonstration Grid"); domain.Insert(&grid); time.SetTimeType(XDMF_TIME_SINGLE); time.SetValue(0.001 * *Iteration); grid.Insert(&time); // Topology topology = grid.GetTopology(); topology->SetTopologyType(XDMF_HEX); topology->SetNumberOfElements(*NumberOfHex); // Fortran is 1 based while c++ is 0 based so // Either subtract 1 from all connections or specify a BaseOffset topology->SetBaseOffset(1); // If you haven't assigned an XdmfArray, GetConnectivity() will create one. array = topology->GetConnectivity(); array->SetNumberOfElements(*NumberOfHex * 8); array->SetValues(0, Conns, *NumberOfHex * 8); // C++ string hocus pocus. // We're actually building the string in FullName[] but were using streams. // the DatasetName will be Demo_00001.h5:/Conns. DataName.seekp(0); DataName << Name << "_" << setw(5) << setfill('0') << *Iteration << ".h5:/Conns" << ends; // Where the data will actually be written array->SetHeavyDataSetName(FullName); // Geometry geometry = grid.GetGeometry(); geometry->SetGeometryType(XDMF_GEOMETRY_XYZ); geometry->SetNumberOfPoints(*NumberOfPoints); array = geometry->GetPoints(); array->SetNumberType(XDMF_FLOAT64_TYPE); array->SetValues(0, Points, *NumberOfPoints * 3); DataName.seekp(0); DataName << Name << "_" << setw(5) << setfill('0') << *Iteration << ".h5:/Points" << ends; array->SetHeavyDataSetName(FullName); // Node Data nodedata.SetName("Node Scalar"); nodedata.SetAttributeCenter(XDMF_ATTRIBUTE_CENTER_NODE); nodedata.SetAttributeType(XDMF_ATTRIBUTE_TYPE_SCALAR); array = nodedata.GetValues(); array->SetNumberType(XDMF_FLOAT64_TYPE); array->SetNumberOfElements(*NumberOfPoints); array->SetValues(0, NodeData, *NumberOfPoints); DataName.seekp(0); DataName << Name << "_" << setw(5) << setfill('0') << *Iteration << ".h5:/NodeData" << ends; array->SetHeavyDataSetName(FullName); // Cell Data celldata.SetName("Cell Scalar"); celldata.SetAttributeCenter(XDMF_ATTRIBUTE_CENTER_CELL); celldata.SetAttributeType(XDMF_ATTRIBUTE_TYPE_SCALAR); array = celldata.GetValues(); array->SetNumberType(XDMF_FLOAT64_TYPE); array->SetNumberOfElements(*NumberOfHex); array->SetValues(0, CellData, *NumberOfHex); DataName.seekp(0); DataName << Name << "_" << setw(5) << setfill('0') << *Iteration << ".h5:/CellData" << ends; array->SetHeavyDataSetName(FullName); // Attach and Write grid.Insert(&nodedata); grid.Insert(&celldata); // Build is recursive ... it will be called on all of the child nodes. // This updates the DOM and writes the HDF5 root.Build(); // Write the XML DataName.seekp(0); DataName << Name << "_" << setw(5) << setfill('0') << *Iteration << ".xmf" << ends; dom.Write(FullName); } } xdmf-3.0+git20160803/Examples/Cxx/XdmfDsmExample.cxx0000640000175000017500000001111213003006557022010 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : $Id: XdmfDsmExample.cxx,v 1.1 2007-10-19 18:55:10 dave.demarle Exp $ */ /* Date : $Date: 2007-10-19 18:55:10 $ */ /* Version : $Revision: 1.1 $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2007 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #include "Xdmf.h" #include "mpi.h" #include "pthread.h" //using namespace std; void *DoServer(void *ptr){ XdmfDsmBuffer *MyDsm = (XdmfDsmBuffer *)ptr; XdmfInt32 op = 0; while(op != XDMF_DSM_OPCODE_DONE){ op = 0; MyDsm->ServiceUntilIdle(&op); if(op){ cout << endl << "MyServer Data = " << MyDsm->GetStorage()->GetValues(0, 100) << endl; } } } int main( int argc, char **argv ) { int i, Data[256]; XdmfInt32 rank, status, who; XdmfInt64 start, end; XdmfDsmCommMpi *MyComm = new XdmfDsmCommMpi; XdmfDsmBuffer *MyDsm = new XdmfDsmBuffer; MPI_Init(&argc, &argv); // New Communicator MyComm->Init(); cout << "Hello from " << MyComm->GetId() << " of " << MyComm->GetTotalSize() << endl; rank = MyComm->GetId(); // MyDsm->ConfigureUniform(MyComm, 1000000, 2, 50); MyDsm->ConfigureUniform(MyComm, 1000000); who = MyDsm->AddressToId(1500000); MyDsm->GetAddressRangeForId(who, &start, &end); // cout << "Address Range for " << who << " = " << start << " - " << end << endl; // MyDsm->Put(0, 5000000, Data); if(rank == 0){ pthread_t thread1; cout << "Starting Thread" << endl; pthread_create( &thread1, NULL, DoServer, MyDsm); pthread_join( thread1, NULL); cout << "Thread Returned" << endl; } if(rank == 1000){ XdmfArray Data; XdmfInt32 op = 0; Data.SetNumberType(XDMF_INT64_TYPE); Data.SetNumberOfElements(100); Data.Generate(rank + 10, rank + 110); status = MyDsm->Put(0, Data.GetCoreLength(), Data.GetDataPointer()); cout << endl << "MyServer Data = " << MyDsm->GetStorage()->GetValues(0, 100) << endl; while(op != XDMF_DSM_OPCODE_DONE){ op = 0; MyDsm->ServiceUntilIdle(&op); if(op){ cout << endl << "MyServer Data = " << MyDsm->GetStorage()->GetValues(0, 100) << endl; } } /* XdmfInt32 i, Opcode, Source; XdmfInt64 Address, Length; for(i=1;iGetTotalSize();i++){ status = MyDsm->ReceiveCommandHeader(&Opcode, &Source, &Address, &Length); if(status = XDMF_SUCCESS){ cout << "Receive From " << Source << " Address " << Address << " Length " << Length << endl; }else{ cout << "Receive Failed" << endl; } } */ }else{ XdmfArray Data; if(rank == (MyComm->GetTotalSize() - 1)){ sleep(1); MyDsm->SendDone(); }else{ Data.SetNumberType(XDMF_INT64_TYPE); Data.SetNumberOfElements(100); Data.Generate(rank + 10, rank + 110); // cout << endl << "Client Data = " << Data.GetValues(0, 110) << endl; status = MyDsm->Put(rank * 16, Data.GetCoreLength(), Data.GetDataPointer()); /* XdmfInt32 Opcode, Dest = 0; XdmfInt64 Address = 0, Length = 100; Address = rank * 100; status = MyDsm->SendCommandHeader(Opcode, Dest, Address, Length); */ if(status == XDMF_SUCCESS){ cout << "Send Succeeded " << endl; }else{ cout << "Send Failed" << endl; } } } MPI_Finalize(); return 0; } xdmf-3.0+git20160803/Examples/Cxx/Original.f0000640000175000017500000001135513003006557020332 0ustar alastairalastairCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C C Create a Grid of Hexahedron Centered at 0,0,0 C CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC SUBROUTINE CreateGrid( IDIM, JDIM, KDIM, XYZ, ICONN ) INTEGER IDIM, JDIM, KDIM REAL*8 XYZ DIMENSION XYZ( 3, IDIM, JDIM, KDIM ) INTEGER ICONN DIMENSION ICONN ( 8, ( IDIM - 1 ) * ( JDIM - 1 ) * ( KDIM - 1 )) INTEGER I, J, K, IDX REAL*8 X, Y, Z, DX, DY, DZ C Print *, 'Size = ', IDIM, JDIM, KDIM PRINT *, 'Initialze Problem' C XYZ Values of Nodes C From -1 to 1 DX = 2.0 / ( IDIM - 1 ) DY = 2.0 / ( JDIM - 1 ) DZ = 2.0 / ( KDIM - 1 ) Z = -1.0 DO 112 K= 1, KDIM Y = -1.0 DO 111 J= 1, JDIM X = -1.0 DO 110 I= 1, IDIM XYZ( 1, I, J, K ) = X XYZ( 2, I, J, K ) = Y XYZ( 3, I, J, K ) = Z X = X + DX 110 CONTINUE Y = Y + DY 111 CONTINUE Z = Z + DZ 112 CONTINUE C Connections IDX = 1 DO 122 K= 0, KDIM - 2 DO 121 J= 0, JDIM - 2 DO 120 I= 1, IDIM - 1 ICONN( 1, IDX ) = ( K * JDIM * IDIM ) + ( J * IDIM ) + I ICONN( 2, IDX ) = ( K * JDIM * IDIM ) + ( J * IDIM ) + I + 1 ICONN( 3, IDX ) = ( ( K + 1 ) * JDIM * IDIM ) + ( J * IDIM ) + I + 1 ICONN( 4, IDX ) = ( ( K + 1 ) * JDIM * IDIM ) + ( J * IDIM ) + I ICONN( 5, IDX ) = ( K * JDIM * IDIM ) + ( ( J + 1 ) * IDIM ) + I ICONN( 6, IDX ) = ( K * JDIM * IDIM ) + ( ( J + 1 ) * IDIM ) + I + 1 ICONN( 7, IDX ) = ( ( K + 1 ) * JDIM * IDIM ) + C ( ( J + 1 ) * IDIM ) + I + 1 ICONN( 8, IDX ) = ( ( K + 1 ) * JDIM * IDIM ) + C ( ( J + 1 ) * IDIM ) + I IDX = IDX + 1 120 CONTINUE 121 CONTINUE 122 CONTINUE RETURN END CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C C Create a Node Centered Solution Field C CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC SUBROUTINE NodeData( IDIM, JDIM, KDIM, XYZ, NCVALUES) INTEGER IDIM, JDIM, KDIM REAL*8 XYZ DIMENSION XYZ( 3, IDIM, JDIM, KDIM ) REAL*8 NCVALUES DIMENSION NCVALUES( IDIM, JDIM, KDIM ) INTEGER I, J, K REAL*8 X, Y, Z PRINT *, 'Calculating Node Centered Data' DO 212, K=1, KDIM DO 211, J=1, JDIM DO 210, I=1, IDIM X = XYZ( 1, I, J, K ) Y = XYZ( 2, I, J, K ) Z = XYZ( 3, I, J, K ) NCVALUES( I, J, K ) = SQRT( ( X * X ) + ( Y * Y ) + ( Z * Z )) 210 CONTINUE 211 CONTINUE 212 CONTINUE RETURN END CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C C Create a Cell Centered Solution Field C CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC SUBROUTINE CellData( IDIM, JDIM, KDIM, ITER, KICKER, XYZ, CCVALUES) INTEGER IDIM, JDIM, KDIM, ITER, KICKER REAL*8 XYZ DIMENSION XYZ( 3, IDIM, JDIM, KDIM ) REAL*8 CCVALUES DIMENSION CCVALUES( IDIM - 1, JDIM - 1, KDIM - 1 ) INTEGER I, J, K PRINT *, 'Calculating Cell Centered Data for Iteration ', ITER DO 312, K=1, KDIM - 1 DO 311, J=1, JDIM - 1 DO 310, I=1, IDIM - 1 X = XYZ( 1, I, J, K ) CCVALUES( I, J, K ) = C SIN( ( ( X + 1 ) * IDIM * KICKER ) / 3 * ITER ) / C EXP( X / ( 1.0 * ITER ) ) 310 CONTINUE 311 CONTINUE 312 CONTINUE C Waste Time DO 313 I=1, 1000000 X = 0.1 * ITER / I Y = SQRT( X * X ) Z = EXP( Y ) 313 CONTINUE RETURN END CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C C Main Program : C Initialize Grid C Initialize Node Centered Data C For Iteration = 1 to 10 C Generate Cell Centered Data C Done C CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC PROGRAM HexMesh PARAMETER ( IDIM = 11 ) PARAMETER ( JDIM = 13 ) PARAMETER ( KDIM = 15 ) REAL*8 XYZ DIMENSION XYZ( 3, IDIM, JDIM, KDIM ) REAL*8 NCVALUES DIMENSION NCVALUES( IDIM, JDIM, KDIM ) REAL*8 CCVALUES DIMENSION CCVALUES( IDIM - 1, JDIM - 1, KDIM - 1 ) INTEGER ICONN DIMENSION ICONN ( 8, ( IDIM - 1 ) * ( JDIM - 1 ) * ( KDIM - 1 )) INTEGER ITER, KICKER, NITER, NARG INTEGER IUNIT CHARACTER*80 ARGIN NARG = IARGC() IF( NARG .GE. 1 ) THEN CALL GETARG( 1, ARGIN ) READ( ARGIN, '(I)') NITER ELSE NITER = 10 ENDIF CALL CreateGrid ( IDIM, JDIM, KDIM, XYZ, ICONN ) CALL NodeData( IDIM, JDIM, KDIM, XYZ, NCVALUES) IUNIT = 14 OPEN( IUNIT, FILE='XYZ.dat', STATUS='unknown' ) REWIND IUNIT WRITE ( IUNIT, * ) IDIM * JDIM * KDIM WRITE ( IUNIT, * ) XYZ CLOSE ( IUNIT ) IUNIT = 14 OPEN( IUNIT, FILE='CONN.dat', STATUS='unknown' ) REWIND IUNIT WRITE ( IUNIT, * ) 'Hex', ( IDIM - 1 ) * ( JDIM - 1 ) * ( KDIM - 1 ) WRITE ( IUNIT, * ) ICONN CLOSE ( IUNIT ) IUNIT = 14 OPEN( IUNIT, FILE='NodeValues.dat', STATUS='unknown' ) REWIND IUNIT WRITE ( IUNIT, * ) NCVALUES CLOSE ( IUNIT ) IUNIT = 14 OPEN( IUNIT, FILE='CellValues.dat', STATUS='unknown' ) REWIND IUNIT KICKER = NITER DO 1000 ITER = 1, NITER CALL CellData( IDIM, JDIM, KDIM, ITER, KICKER, XYZ, CCVALUES) WRITE ( IUNIT, * ) CCVALUES 1000 CONTINUE CLOSE ( IUNIT ) END xdmf-3.0+git20160803/Examples/Cxx/XdmfDsmThreads.cxx0000640000175000017500000000762713003006557022027 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : $Id: XdmfDsmThreads.cxx,v 1.1 2007-10-19 18:55:10 dave.demarle Exp $ */ /* Date : $Date: 2007-10-19 18:55:10 $ */ /* Version : $Revision: 1.1 $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2007 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #include "Xdmf.h" #include "mpi.h" #include "pthread.h" void *DoServer(void *ptr){ XdmfDsmBuffer *MyDsm = (XdmfDsmBuffer *)ptr; XdmfInt32 op = 0; cout << " Starting DSM Service on node " << MyDsm->GetComm()->GetId() << endl; while(op != XDMF_DSM_OPCODE_DONE){ op = 0; MyDsm->ServiceOnce(&op); } cout << " Ending DSM Service on node " << MyDsm->GetComm()->GetId() << endl; } int main( int argc, char **argv ) { XdmfInt32 rank, status; XdmfArray Data; XdmfDsmCommMpi *MyComm = new XdmfDsmCommMpi; XdmfDsmBuffer *MyDsm = new XdmfDsmBuffer; pthread_t thread1; MPI_Init(&argc, &argv); // New Communicator MyComm->Init(); cout << "Hello from " << MyComm->GetId() << " of " << MyComm->GetTotalSize() << endl; rank = MyComm->GetId(); // Uniform Dsm : every node has a buffer of 1000000. Addresses are sequential MyDsm->ConfigureUniform(MyComm, 1000000); MPI_Barrier(MPI_COMM_WORLD); pthread_create( &thread1, NULL, DoServer, MyDsm); Data.SetNumberType(XDMF_INT64_TYPE); Data.SetNumberOfElements(100); Data.Generate(rank + 10, rank + 110); if(rank == 1){ cout << "Before values = " << Data.GetValues(0, 10) << endl; cout << "Put #1" << endl; status = MyDsm->Put(100, sizeof(XdmfInt64), Data.GetDataPointer()); if(status != XDMF_SUCCESS){ cout << "Send Failed" << endl; } cout << "Put #2" << endl; status = MyDsm->Put(100, sizeof(XdmfInt64), Data.GetDataPointer()); if(status != XDMF_SUCCESS){ cout << "Send Failed" << endl; } cout << "Put #3" << endl; status = MyDsm->Put(100, sizeof(XdmfInt64), Data.GetDataPointer()); if(status != XDMF_SUCCESS){ cout << "Send Failed" << endl; } } MPI_Barrier(MPI_COMM_WORLD); // Just write first value status = MyDsm->Put(rank * sizeof(XdmfInt64), sizeof(XdmfInt64), Data.GetDataPointer()); if(status != XDMF_SUCCESS){ cout << "Send Failed" << endl; } MPI_Barrier(MPI_COMM_WORLD); if(rank == 1){ // Get First 10 Values status = MyDsm->Get(0, 10 * sizeof(XdmfInt64), Data.GetDataPointer()); if(status != XDMF_SUCCESS){ cout << "Get Failed" << endl; } cout << "After values = " << Data.GetValues(0, 10) << endl; MyDsm->SendDone(); } pthread_join( thread1, NULL); MPI_Barrier(MPI_COMM_WORLD); delete MyDsm; delete MyComm; MPI_Finalize(); return 0; } xdmf-3.0+git20160803/Examples/Cxx/XdmfFortranExample.f900000640000175000017500000000743513003006557022511 0ustar alastairalastair!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! !! AUTHOR: Kenneth Leiter (kenneth.leiter@arl.army.mil) !! !! Use the Xdmf Fortran Bindings to write out a simple mesh consisting of !! two hexahedrons. Link against the XdmfFortran library to compile. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! PROGRAM XdmfFortranExample !DEC$ ATTRIBUTES DLLIMPORT, ALIAS:'_XdmfInit'::XdmfInit !DEC$ ATTRIBUTES DLLIMPORT, ALIAS:'_XdmfSetGridTopology'::XdmfSetGridTopology !DEC$ ATTRIBUTES DLLIMPORT, ALIAS:'_XdmfSetGridGeometry'::XdmfSetGridGeometry !DEC$ ATTRIBUTES DLLIMPORT, ALIAS:'_XdmfSetGridAttribute'::XdmfSetGridAttribute !DEC$ ATTRIBUTES DLLIMPORT, ALIAS:'_XdmfAddGridAttribute'::XdmfAddGridAttribute !DEC$ ATTRIBUTES DLLIMPORT, ALIAS:'_XdmfWriteGrid'::XdmfWriteGrid !DEC$ ATTRIBUTES DLLIMPORT, ALIAS:'_XdmfWriteToFile'::XdmfWriteToFile !DEC$ ATTRIBUTES DLLIMPORT, ALIAS:'_XdmfSerialize'::XdmfSerialize !DEC$ ATTRIBUTES DLLIMPORT, ALIAS:'_XdmfClose'::XdmfClose INTEGER*8 obj character*256 filename REAL*4 myPoints(3,3,4) INTEGER myConnections(8,2) REAL*8 myCellAttribute(2), myNodeAttribute(3,4) filename = 'my_output'//CHAR(0) myPoints(1,1,1) = 0 myPoints(2,1,1) = 0 myPoints(3,1,1) = 1 myPoints(1,2,1) = 1 myPoints(2,2,1) = 0 myPoints(3,2,1) = 1 myPoints(1,3,1) = 3 myPoints(2,3,1) = 0 myPoints(3,3,1) = 2 myPoints(1,1,2) = 0 myPoints(2,1,2) = 1 myPoints(3,1,2) = 1 myPoints(1,2,2) = 1 myPoints(2,2,2) = 1 myPoints(3,2,2) = 1 myPoints(1,3,2) = 3 myPoints(2,3,2) = 2 myPoints(3,3,2) = 2 myPoints(1,1,3) = 0 myPoints(2,1,3) = 0 myPoints(3,1,3) = -1 myPoints(1,2,3) = 1 myPoints(2,2,3) = 0 myPoints(3,2,3) = -1 myPoints(1,3,3) = 3 myPoints(2,3,3) = 0 myPoints(3,3,3) = -2 myPoints(1,1,4) = 0 myPoints(2,1,4) = 1 myPoints(3,1,4) = -1 myPoints(1,2,4) = 1 myPoints(2,2,4) = 1 myPoints(3,2,4) = -1 myPoints(1,3,4) = 3 myPoints(2,3,4) = 2 myPoints(3,3,4) = -2 myConnections(1,1) = 0 myConnections(2,1) = 1 myConnections(3,1) = 7 myConnections(4,1) = 6 myConnections(5,1) = 3 myConnections(6,1) = 4 myConnections(7,1) = 10 myConnections(8,1) = 9 myConnections(1,2) = 1 myConnections(2,2) = 2 myConnections(3,2) = 8 myConnections(4,2) = 7 myConnections(5,2) = 4 myConnections(6,2) = 5 myConnections(7,2) = 11 myConnections(8,2) = 10 myNodeAttribute(1,1) = 100 myNodeAttribute(1,2) = 300 myNodeAttribute(1,3) = 300 myNodeAttribute(1,4) = 500 myNodeAttribute(2,1) = 200 myNodeAttribute(2,2) = 400 myNodeAttribute(2,3) = 400 myNodeAttribute(2,4) = 600 myNodeAttribute(3,1) = 300 myNodeAttribute(3,2) = 500 myNodeAttribute(3,3) = 500 myNodeAttribute(3,4) = 700 myCellAttribute(1) = 100 myCellAttribute(2) = 200 CALL XDMFINIT(obj, filename) CALL XDMFSETGRIDTOPOLOGY(obj, 'Hexahedron'//CHAR(0), 2, myConnections) CALL XDMFSETGRIDGEOMETRY(obj, 'XYZ'//CHAR(0), 'XDMF_FLOAT32_TYPE'//CHAR(0), 12, myPoints) CALL XDMFADDGRIDATTRIBUTE(obj, 'NodeValues'//CHAR(0),'XDMF_FLOAT64_TYPE'//CHAR(0), 'NODE'//CHAR(0), & 'SCALAR'//CHAR(0), 12, myNodeAttribute) CALL XDMFADDGRIDATTRIBUTE(obj, 'CellValues'//CHAR(0),'XDMF_FLOAT64_TYPE'//CHAR(0), 'CELL'//CHAR(0), & 'SCALAR'//CHAR(0), 2, myCellAttribute) CALL XDMFWRITEGRID(obj, 'TestGrid'//CHAR(0)) CALL XDMFWRITETOFILE(obj) CALL XDMFSERIALIZE(obj) CALL XDMFCLOSE(obj) END xdmf-3.0+git20160803/Examples/Cxx/XdmfSTLConverterExample.cxx0000740000175000017500000000432713003006557023632 0ustar alastairalastair#include "XdmfSTLConverter.cxx" #include #include #include #include #include #include int main( int argc, const char* argv[] ) { /* * Create an STL vector and map and write out to XDMF */ XdmfSTLConverter mySerializer = XdmfSTLConverter(); XdmfDOM myDOM = XdmfDOM(); XdmfRoot myRoot = XdmfRoot(); myRoot.SetDOM(&myDOM); myRoot.Build(); XdmfDomain myDomain = XdmfDomain(); myRoot.Insert(&myDomain); std::vector intVector; int intTotal = 100 ; for (int i=1; i<6; i++) { intTotal += intTotal; intVector.push_back(intTotal); } std::set intSet; intSet.insert(50); intSet.insert(20); intSet.insert(75); std::map myMap; myMap[12]= 13.785412486; myMap[60] = 45451.154987; myMap[-60] = 5231.554874; // Just insert into grid for testing XdmfGrid myGrid = XdmfGrid(); myGrid.SetGridType(XDMF_GRID_COLLECTION); myDomain.Insert(&myGrid); mySerializer.writeSetToXdmf(intVector, &myGrid, "Vector"); mySerializer.writeSetToXdmf(intSet, &myGrid, "Set"); mySerializer.writeMapToXdmf(myMap, &myGrid, "Map"); cout << myDOM.Serialize() << endl; /* * Now attempt to do the reverse. Read XDMF information into STL containers: */ XdmfXmlNode domain = myDOM.FindElement("Domain"); XdmfXmlNode grid = myDOM.FindElement("Grid", 0, domain); for (int i=0; i < myDOM.FindNumberOfElements("Set", grid); i++) { XdmfSet currSet = XdmfSet(); currSet.SetDOM(&myDOM); currSet.SetElement(myDOM.FindElement("Set", i, grid)); currSet.Update(); if (currSet.GetNumberOfAttributes() == 0) { // Must be Non-Associative std::vector myData; mySerializer.getSetFromXdmf(myData, &currSet); cout << "\nVECTOR CONTAINS:" << endl; for (unsigned int j=0; j myData; mySerializer.getMapFromXdmf(myData, &currSet); cout << "\nMAP CONTAINS:" << endl; std::map::iterator iter; for (iter = myData.begin(); iter != myData.end(); iter++) { cout << iter->first << '\t' << iter->second << endl; } } } } xdmf-3.0+git20160803/Examples/Cxx/XdmfDsmH5Slice.cxx0000640000175000017500000001513113003006557021656 0ustar alastairalastair/*******************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : $Id: XdmfDsmH5Slice.cxx,v 1.1 2007-10-19 18:55:10 dave.demarle Exp $ */ /* Date : $Date: 2007-10-19 18:55:10 $ */ /* Version : $Revision: 1.1 $ */ /* */ /* Author: */ /* Jerry A. Clarke */ /* clarke@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2007 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*******************************************************************/ #include "Xdmf.h" #include "mpi.h" #include "pthread.h" // Node 0 Creates the Structure for the DataSet // The DataSet is Size x JDIM x IDIM doubles // Each Node then Writes 1 K Plane of Data // The Last Node Reads the Corners of the DataSet and // reads one J Plane Half way up #define IDIM 15 #define JDIM 30 #define DataSetName "DSM:TestFile.h5:/TestDataSets/Values1" // Fill an array with Values // The Values corespond to the rank and position void FillArray(int rank, int size, XdmfArray *array){ int i, j, cntr = 0; XdmfInt64 Dimensions[] = {1, JDIM, IDIM}; XdmfFloat64 Value; array->SetShape(3, Dimensions); for(j=0;jSetValue(cntr++, Value); } } } // MPI Barrier with a print void WaitForAll(int rank, int value, MPI_Comm comm){ cout << "(" << rank << ") in barrier " << value << endl; MPI_Barrier(comm); cout << "(" << rank << ") out of barrier " << value << endl; } int main( int argc, char **argv ) { MPI_Comm XdmfComm; XdmfInt32 rank, size, status; XdmfArray Data; XdmfDsmCommMpi *MyComm = new XdmfDsmCommMpi; XdmfDsmBuffer *MyDsm = new XdmfDsmBuffer; pthread_t thread1; XdmfInt32 Rank = 3; XdmfInt64 Dimensions[] = { 1, JDIM, IDIM }; XdmfInt64 Start[] = {0, 0, 0}; XdmfInt64 Stride[] = {1, 1, 1}; XdmfInt64 Count[] = {1, JDIM, IDIM}; XdmfHDF *ExternalDataSet; XdmfArray *InCoreCoordinates; int i, k, provided; double *DblPtr; // Initialize MPI for Threads MPI_Init_thread(&argc, &argv, MPI_THREAD_SERIALIZED, &provided); // Initialize Communication Object MyComm->Init(); // New Communicator for Xdmf Transactions MyComm->DupComm( MPI_COMM_WORLD ); cout << "Hello from " << MyComm->GetId() << " of " << MyComm->GetTotalSize() << endl; rank = MyComm->GetId(); size = Dimensions[0] = MyComm->GetTotalSize(); // Uniform Dsm : every node has a buffer of 1000000. Addresses are sequential MyDsm->ConfigureUniform(MyComm, 1000000); // Start another thread to handle DSM requests from other nodes pthread_create(&thread1, NULL, &XdmfDsmBufferServiceThread, (void *)MyDsm); // Wait for is to be ready while(!MyDsm->GetThreadDsmReady()){ // Spin } WaitForAll(rank, 1, MPI_COMM_WORLD); // Begin HDF5 ExternalDataSet = new XdmfHDF(); ExternalDataSet->SetDsmBuffer(MyDsm); ExternalDataSet->SetNumberType(XDMF_FLOAT64_TYPE); ExternalDataSet->SetShape( Rank, Dimensions ); Data.CopyType(ExternalDataSet); FillArray(rank, size, &Data); // Node 0 Creates the Structure for the File // Writes Last Value to Make "File" the Correct size if(rank == 0){ XdmfInt64 BackCorner[] = {size-1,JDIM-1,IDIM-1}; XdmfArray Dummy; if(ExternalDataSet->Open( DataSetName, "rw" ) == XDMF_FAIL){ // Shouldn't be necessary cout << "!! Node 0 Creating Dataset" << endl; ExternalDataSet->CreateDataset(DataSetName); } // Write Last Value ExternalDataSet->SelectCoordinates(1, BackCorner); Dummy.CopyType(ExternalDataSet); Dummy.SetNumberOfElements(1); ExternalDataSet->Write(&Dummy); ExternalDataSet->Close(); } WaitForAll(rank, 2, MPI_COMM_WORLD); // Everyone Writes One K Plane of Data Start[0] = rank; if(ExternalDataSet->Open( DataSetName, "rw" ) == XDMF_FAIL){ cout << "(" << rank << ") !!! Error Dataset has not been created" << endl; } ExternalDataSet->SelectHyperSlab(Start, Stride, Count); ExternalDataSet->Write(&Data); ExternalDataSet->Close(); WaitForAll(rank, 3, MPI_COMM_WORLD); // Last Node Reads Data if(rank == (size - 1)){ XdmfInt64 Corners[] = {0,0,0, 0,0,IDIM - 1, size-1,JDIM-1,0, size-1,JDIM-1,IDIM-1}; XdmfInt64 SliceStart[] = { 0,JDIM/2,0}; XdmfInt64 SliceStride[] = { 1, 1, 1}; XdmfInt64 SliceCount[] = {size, 1, IDIM}; XdmfInt64 *SliceSize = SliceCount; InCoreCoordinates = new XdmfArray(); InCoreCoordinates->CopyType(ExternalDataSet); // Read the corners InCoreCoordinates->SetNumberOfElements(4); ExternalDataSet->Open( DataSetName, "r" ); ExternalDataSet->SelectCoordinates(4, Corners); ExternalDataSet->Read( InCoreCoordinates ); cout << endl; cout << "4 of the Corners == "; DblPtr = (double *)InCoreCoordinates->GetDataPointer(); for( k = 0 ; k < 4 ; k++ ){ cout << " " << *DblPtr++; } cout << endl; // Read 1 J Plane InCoreCoordinates->SetShape(3, SliceSize); ExternalDataSet->SelectHyperSlab(SliceStart, SliceStride, SliceCount); ExternalDataSet->Read(InCoreCoordinates); cout << "Slice == "; cout << endl; DblPtr = (double *)InCoreCoordinates->GetDataPointer(); for( k = 0 ; k < size ; k++ ){ cout << " "; for(i=0;iClose(); MyDsm->SendDone(); } WaitForAll(rank, 4, MPI_COMM_WORLD); pthread_join( thread1, NULL); delete MyDsm; delete MyComm; MPI_Finalize(); return 0; } xdmf-3.0+git20160803/Examples/CVS/0000740000175000017500000000000013003006557016301 5ustar alastairalastairxdmf-3.0+git20160803/Examples/CVS/Repository0000640000175000017500000000001613003006557020402 0ustar alastairalastairXdmf/Examples xdmf-3.0+git20160803/Examples/CVS/Root0000640000175000017500000000006413003006557017151 0ustar alastairalastair:pserver:anonymous@public.kitware.com:/cvsroot/Xdmf xdmf-3.0+git20160803/Examples/CVS/Entries0000640000175000017500000000004213003006557017633 0ustar alastairalastairD/Cxx//// D/Data//// D/Python//// xdmf-3.0+git20160803/Examples/Python/0000740000175000017500000000000013003006557017127 5ustar alastairalastairxdmf-3.0+git20160803/Examples/Python/XdmfDOMTest4.py0000740000175000017500000000214013003006557021663 0ustar alastairalastair#!/bin/env python from Xdmf import * import time NumberOfGrids = 100 # build XML XML = """ """ for i in range(NumberOfGrids) : XML += '\nthis is some text for grid #%d\n\n' % (i + 1, i + 1) XML += """ """ dom = XdmfDOM() dom.Parse(XML) dm = dom.FindElement('Domain') print 'dm = ', dm print 'Domain has %d Children' % dom.GetNumberOfChildren(dm) # Test XPath node = dom.FindElementByPath('/Xdmf/Domain/Grid[10]') print node if(node) : print dom.Serialize(node) node = dom.FindElementByPath('/Xdmf/Domain/Grid[11]') print node if(node) : print dom.Serialize(node) node = dom.FindElementByPath('/Xdmf/Domain/Grid[Information]') print node if(node) : print dom.Serialize(node) node = dom.FindElementByPath('/Xdmf/Domain/Grid[@Name = "GridNumber0020"]') print node if(node) : print dom.Serialize(node) node = dom.FindElementByPath('/Xdmf/Domain/Grid[@Name = "GridNumber0020"]') print node if(node) : print dom.Serialize(node) xdmf-3.0+git20160803/Examples/Python/XdmfDOMTest1.py0000740000175000017500000000443513003006557021671 0ustar alastairalastair#!/bin/env python from Xdmf import * import time NumberOfGrids = 100 # build XML XML = """ """ for i in range(NumberOfGrids) : XML += '\nthis is some text for grid #%d\n\n' % (i + 1, i + 1) XML += """ """ dom = XdmfDOM() dom.Parse(XML) dm = dom.FindElement('Domain') print 'dm = ', dm print 'Domain has %d Children' % dom.GetNumberOfChildren(dm) # print dom.Serialize(dm) ng = dom.FindNumberOfElements('Grid', dm) print 'DOM has %d Grids' % ng print 'Timing Access' start = now = time.time() for i in range(ng) : g = dom.FindElement('Grid', i, dm) # Name = dom.GetAttribute(g, 'Name') Name = dom.GetAttribute(g, 'Name') if (Name != "GridNumber%04d" % (i + 1)) : print 'Error in Name' now = time.time() print 'Accessed %d Grid Attributes in %g Seconds' % (ng, now - start) g = dom.GetChild(ng / 2, dm) print 'Middle Node = ', dom.GetAttribute(g, 'Name') g = dom.FindElement('Grid', ng / 2, dm) print 'Middle Grid = ', dom.GetAttribute(g, 'Name') dom.DeleteNode(g) ng = dom.FindNumberOfElements('Grid', dm) print 'After Deletion DOM has %d Grids' % ng g = dom.FindElement('Grid', ng / 2, dm) print 'Test Serialize' print dom.Serialize(g) print 'Test Add' dom.InsertFromString(g, ' XXYYZZ ') print dom.Serialize(g) # print 'Test Serialize' # print dom.Serialize() print 'Test Set Attribute an CDATA' info = dom.FindElement('Information', 1, g) dom.Set(info, 'CDATA', 'AABBCC') dom.Set(info, 'NewTag', 'NewValue') print dom.Serialize(g) print 'Testing Information' i = XdmfInformation() print 'Setting DOM' i.SetDOM(dom) print 'Setting Element' i.SetElement(info) print 'Update Information' i.UpdateInformation() print 'Ready' print 'info.Get("NewTag") = ', i.Get('NewTag') i.Set('NewTag', 'BrandNewValue') i.Set('CData', 'DDEEFF') print dom.Serialize(g) print 'Name = ',i.GetName() print 'Value = ',i.GetValue() i.Set('Value', 'New Value') print dom.Serialize(g) print 'Value = ',i.GetValue() print dom.Serialize(g) i.SetName('Jerry') print dom.Serialize(g) print 'element Type = ', i.GetElementType() i.SetValue('Last Value of the Day') print dom.Serialize(g) i.Build() dom.Write('Jerry.xmf') xdmf-3.0+git20160803/Examples/Python/SetsMaps.py0000740000175000017500000001131013003006557021237 0ustar alastairalastair#!/bin/env python from Xdmf import * txt = """ 0 1 2 4 5 6 8 9 10 0.0 0.0 0.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 0.0 0.0 0.0 2.0 1.0 0.0 2.0 1.0 1.0 2.0 0.0 1.0 2.0 0.0 0.0 3.0 1.0 0.0 3.0 1.0 1.0 3.0 0.0 1.0 3.0 0.0 0.0 4.0 1.0 0.0 4.0 1.0 1.0 4.0 0.0 1.0 4.0 100 200 300 400 500 600 600 700 800 900 1000 1100 1200 1300 1400 1500 100 200 400 0 2 4 100 200 400 0 1 0 0 0 0 1 1 0 0 0 0 0 1 0 2 100 200 400 600 1000 2000 4000 6000 """ d = XdmfDOM() d.Parse(txt) dm = d.FindElement('Domain') gnode = d.FindElement('Grid', 0, dm) g = XdmfGrid() g.SetDOM(d) g.SetElement(gnode) g.UpdateInformation() g.Update() print 'Grid Sets :', g.GetNumberOfSets() for i in range(g.GetNumberOfSets()) : s = g.GetSets(i) print 'Set #', i print ' Type: ', s.GetSetTypeAsString() print ' Size: ', s.GetSize() s.Update() ids = s.GetIds() print ' # Ids : ', ids.GetNumberOfElements() print ' Ids : ', ids.GetValues() cellids = s.GetCellIds() print ' # Cell Ids : ', cellids.GetNumberOfElements() print ' Cell Ids : ', cellids.GetValues() faceids = s.GetFaceIds() print ' # Face Ids : ', faceids.GetNumberOfElements() print ' Face Ids : ', faceids.GetValues() print ' #Attributes: ', s.GetNumberOfAttributes() for j in range(s.GetNumberOfAttributes()) : a = s.GetAttribute(j) print ' Attribute #', j print ' Attribute values: ', a.GetAttributeTypeAsString() a.Update() v = a.GetValues() print ' Attribute type: ', v.GetValues() ns = XdmfSet() ns.SetDOM(d) ns.SetSetType(XDMF_SET_TYPE_NODE) a = XdmfArray() a.SetNumberOfElements(4) a.SetNumberType(XDMF_INT32_TYPE) a.SetValues(0, "100 200 300 400") ns.SetIds(a) g.Insert(ns) ns.Build() print d.Serialize() xdmf-3.0+git20160803/Examples/Python/XdmfVtk.py0000640000175000017500000000066413003006557021074 0ustar alastairalastair#!/usr/bin/env python from vtk import * from Xdmf import * from libvtkXdmfPython import * import string import sys platform = string.upper(sys.platform) if (platform == 'WIN32') or (platform == 'CYGWIN') : class vtkXdmfRenderWindowInteractor ( vtkXdmfWin32RenderWindowInteractor ) : def __init__(self) : pass else : class vtkXdmfRenderWindowInteractor ( vtkXdmfXRenderWindowInteractor ) : def __init__(self) : pass xdmf-3.0+git20160803/Examples/Python/SetsMaps2.py0000740000175000017500000001533213003006557021331 0ustar alastairalastair#!/bin/env python from Xdmf import * txt = """ 0 1 2 4 5 6 8 9 10 0.0 0.0 0.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 0.0 0.0 0.0 2.0 1.0 0.0 2.0 1.0 1.0 2.0 0.0 1.0 2.0 0.0 0.0 3.0 1.0 0.0 3.0 1.0 1.0 3.0 0.0 1.0 3.0 0.0 0.0 4.0 1.0 0.0 4.0 1.0 1.0 4.0 0.0 1.0 4.0 100 200 300 400 500 600 600 700 800 900 1000 1100 1200 1300 1400 1500 100 200 400 0 2 4 100 200 400 1 2 0 1 1 2 2 2 3 3 2 1 3 3 2 0 1 0 0 0 0 1 1 0 0 0 0 0 1 0 2 100 200 400 600 1000 2000 4000 6000 """ d = XdmfDOM() d.Parse(txt) dm = d.FindElement('Domain') gnode = d.FindElement('Grid', 0, dm) g = XdmfGrid() g.SetDOM(d) g.SetElement(gnode) g.UpdateInformation() g.Update() print 'Grid Sets :', g.GetNumberOfSets() for i in range(g.GetNumberOfSets()) : s = g.GetSets(i) print 'Set #', i print ' Type: ', s.GetSetTypeAsString() print ' Size: ', s.GetSize() s.Update() ids = s.GetIds() print ' # Ids : ', ids.GetNumberOfElements() print ' Ids : ', ids.GetValues() cellids = s.GetCellIds() print ' # Cell Ids : ', cellids.GetNumberOfElements() print ' Cell Ids : ', cellids.GetValues() faceids = s.GetFaceIds() print ' # Face Ids : ', faceids.GetNumberOfElements() print ' Face Ids : ', faceids.GetValues() print ' #Attributes: ', s.GetNumberOfAttributes() for j in range(s.GetNumberOfAttributes()) : a = s.GetAttribute(j) print ' Attribute #', j print ' Attribute values: ', a.GetAttributeTypeAsString() a.Update() v = a.GetValues() print ' Attribute type: ', v.GetValues() print ' #Maps: ', s.GetNumberOfMaps() for j in range(s.GetNumberOfMaps()) : m = s.GetMap(j) print ' Map #', j print ' Map Type : ', m.GetMapTypeAsString() print ' Item Length :', m.GetItemLength() print ' Map Length :', m.GetMapLength() m.Update() ival = m.GetMapIndex() print ' Map Index: ', ival.GetValues() v = m.GetMapData() print ' all Map Values : ', v.GetValues() l = m.GetMapLength() il = m.GetItemLength() for k in range(l) : start = ival.GetValueAsInt64(k * 2) * il len1 = ival.GetValueAsInt64((k * 2) + 1) * il mapvals = v.GetValues(start, len1) imapvals = tuple(int(x) for x in mapvals.split()) for ii in range(len(imapvals) / il) : index = ii * il print ' Map Vals[', k, '] = ', imapvals[index:index+il] ns = XdmfSet() ns.SetDOM(d) ns.SetSetType(XDMF_SET_TYPE_NODE) a = XdmfArray() a.SetNumberOfElements(4) a.SetNumberType(XDMF_INT32_TYPE) a.SetValues(0, "100 200 300 400") ns.SetIds(a) g.Insert(ns) # ns.Build() # print d.Serialize() xdmf-3.0+git20160803/Examples/Python/WriteXdmf1.py0000740000175000017500000000246513003006557021505 0ustar alastairalastair#!/usr/bin/env python from Xdmf import * # Example of How to Generate Xdmf # allowing the Library to write the # Heavy Data d = XdmfDOM() root = XdmfRoot() root.SetDOM(d) root.SetVersion(2.2) # Change the Version number because we can root.Build() # Information i = XdmfInformation() # Arbitrary Name=Value Facility i.SetName("SampleLocation") i.SetValue("4") root.Insert(i) # XML DOM is used as the keeper of the structure # Insert() creates an XML node and inserts it under # the parent # Domain dm = XdmfDomain() root.Insert(dm) # Grid g = XdmfGrid() g.SetName("Structured Grid") # Topology t = g.GetTopology() t.SetTopologyType(XDMF_3DCORECTMESH) t.GetShapeDesc().SetShapeFromString('10 20 30') # Geometry geo = g.GetGeometry() geo.SetGeometryType(XDMF_GEOMETRY_ORIGIN_DXDYDZ) geo.SetOrigin(1, 2, 3) geo.SetDxDyDz(0.1, 0.2, 0.3) dm.Insert(g) # Attribute attr = XdmfAttribute() attr.SetName("Pressure") attr.SetAttributeCenter(XDMF_ATTRIBUTE_CENTER_NODE); attr.SetAttributeType(XDMF_ATTRIBUTE_TYPE_SCALAR); p = attr.GetValues() p.SetShapeFromString("10 20 30") p.Generate(0.0, 1.0, 0, p.GetNumberOfElements() - 1) g.Insert(attr) # Update XML and Write Values to DataItems root.Build() # DataItems > 100 values are heavy print d.Serialize() # prints to stdout d.Write('SMesh.xmf') # write to file xdmf-3.0+git20160803/Examples/Python/FromOBJ.py0000740000175000017500000000740613003006557020751 0ustar alastairalastair#!/usr/bin/env python #/*******************************************************************/ #/* XDMF */ #/* eXtensible Data Model and Format */ #/* */ #/* Id : $Id: FromOBJ.py,v 1.2 2009-01-23 20:48:47 clarke Exp $ */ #/* Date : $Date: 2009-01-23 20:48:47 $ */ #/* Version : $Revision: 1.2 $ */ #/* */ #/* Author: */ #/* Jerry A. Clarke */ #/* clarke@arl.army.mil */ #/* US Army Research Laboratory */ #/* Aberdeen Proving Ground, MD */ #/* */ #/* Copyright @ 2002 US Army Research Laboratory */ #/* All Rights Reserved */ #/* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ #/* */ #/* This software is distributed WITHOUT ANY WARRANTY; without */ #/* even the implied warranty of MERCHANTABILITY or FITNESS */ #/* FOR A PARTICULAR PURPOSE. See the above copyright notice */ #/* for more information. */ #/* */ #/*******************************************************************/ import sys import string print 'Loading vtk' from libVTKCommonPython import * from libVTKGraphicsPython import * from libVTKImagingPython import * from libVTKPatentedPython import * from libVTKContribPython import * from libVTKLocalPython import * print 'Loading Xdmf' import Xdmf class FromOBJ : def __init__( self, FileName ) : self.Convert = 0 self.FileName = FileName BaseList = string.split(FileName, '.') if len( BaseList ) == 1 : self.BaseName = BaseList[0] else : self.BaseName = string.join( BaseList[ : len( BaseList ) - 1 ] ) def CreateXdmf( self ) : ObjReader = vtkOBJReader() ObjReader.SetFileName( self.FileName ) print 'Reading ' + self.FileName ObjReader.Update() TriFilter = vtkTriangleFilter() TriFilter.SetInput( ObjReader.GetOutput() ) TriFilter.Update() if self.Convert == 1 : Points = TriFilter.GetOutput().GetPoints() print 'Converting %d Points' % Points.GetNumberOfPoints() for i in range ( Points.GetNumberOfPoints() ) : x, y, z = Points.GetPoint( i ) x = x * .0254 y = y * .0254 z = z * .0254 Points.SetPoint( i, x, y, z ) Merge = vtkCleanPolyData() Merge.SetTolerance(0) Merge.SetInput( TriFilter.GetOutput() ) Normal = vtkPolyDataNormals() Normal.SetInput( Merge.GetOutput() ) Normal.SetFeatureAngle(0) Normal.SplittingOff() Normal.ConsistencyOn() # Normal.DebugOn() Normal.Update() Writer = vtkXdmfDataSetWriter() Writer.SetInput( Normal.GetOutput() ) Writer.SetHeavyDataSetName(self.BaseName + '.h5') Writer.WriteGrid() Writer.WriteAttributes() XML = Writer.GetXML() fd = open(self.BaseName + '.xml', "w" ) fd.write("""\n""") fd.write("""\n""") fd.write('\n') fd.write("""]>\n""" ) fd.write("""\n\n""") fd.write( XML ) fd.write("""\n\n""") fd.close() if __name__ == '__main__' : argc = len( sys.argv ) FileName = sys.argv[ argc - 1 ] fobj = FromOBJ( FileName ) if argc > 2 : print 'Converting From inches' fobj.Convert = 1 fobj.CreateXdmf() xdmf-3.0+git20160803/Examples/Python/XdmfGridTest3.py0000740000175000017500000001551713003006557022144 0ustar alastairalastair#!/bin/env python from Xdmf import * PointsTxt = """ 0 1 2 3 4 5 6 7 0.0 0.0 0.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 0.0 0.0 0.0 2.0 1.0 0.0 2.0 1.0 1.0 2.0 0.0 1.0 2.0 0 1 5 4 2 3 7 6 0.0 0.0 0.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 0.0 0.0 0.0 2.0 1.0 0.0 2.0 1.0 1.0 2.0 0.0 1.0 2.0 0 1 2 3 4 5 6 7 0.0 0.0 0.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 0.0 0.0 0.0 2.0 1.0 0.0 2.0 1.0 1.0 2.0 0.0 1.0 2.0 0 1 5 4 2 3 7 6 0.0 0.0 0.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 0.0 0.0 0.0 2.0 1.0 0.0 2.0 1.0 1.0 2.0 0.0 1.0 2.0 0 1 6 5 16 17 22 21 10.0 0.0 0.0 10.0 1.0 0.0 10.0 2.0 0.0 10.0 3.0 0.0 10.0 4.0 0.0 10.0 0.0 1.0 10.0 1.0 1.0 10.0 2.0 1.0 10.0 3.0 1.0 10.0 4.0 1.0 10.0 0.0 0.0 10.0 1.0 0.0 10.0 2.0 0.0 10.0 3.0 0.0 10.0 4.0 0.0 10.0 0.0 1.0 10.0 1.0 1.0 10.0 2.0 1.0 10.0 3.0 1.0 10.0 4.0 1.0 10.0 0.0 0.0 10.0 1.0 0.0 10.0 2.0 0.0 10.0 3.0 0.0 10.0 4.0 0.0 10.0 0.0 1.0 10.0 1.0 1.0 10.0 2.0 1.0 10.0 3.0 1.0 10.0 4.0 1.0 /Xdmf/Domain/Grid[@Name="TestGrid"]/Geometry/DataItem[2] """ def PrintGrid(grid) : print 'Grid ', grid.GetName(), ' Type = ', grid.GetGridTypeAsString() if(grid.IsUniform()) : top = grid.GetTopology() top.DebugOn() conn = top.GetConnectivity() print 'Connectivity = ', conn.GetValues() geo = grid.GetGeometry() points = geo.GetPoints() print 'Geo Type = ', geo.GetGeometryTypeAsString(), ' # Points = ', geo.GetNumberOfPoints() print 'Points = ', points.GetValues() else : nc = grid.GetNumberOfChildren() for i in range(nc) : g = grid.GetChild(i) PrintGrid(g) fd = open('Points.xmf', 'w') fd.write(PointsTxt) fd.close() ######## dom = XdmfDOM() dom.Parse('Points.xmf') ge = dom.FindElementByPath('/Xdmf/Domain/Grid[@Name="Tree1"]') grid = XdmfGrid() grid.SetDOM(dom) grid.SetElement(ge) grid.UpdateInformation() grid.Update() PrintGrid(grid) xdmf-3.0+git20160803/Examples/Python/NdgmLs.py0000740000175000017500000000612413003006557020673 0ustar alastairalastair#!/bin/env python #/*******************************************************************/ #/* XDMF */ #/* eXtensible Data Model and Format */ #/* */ #/* Id : $Id: NdgmLs.py,v 1.2 2009-01-23 20:48:54 clarke Exp $ */ #/* Date : $Date: 2009-01-23 20:48:54 $ */ #/* Version : $Revision: 1.2 $ */ #/* */ #/* Author: */ #/* Jerry A. Clarke */ #/* clarke@arl.army.mil */ #/* US Army Research Laboratory */ #/* Aberdeen Proving Ground, MD */ #/* */ #/* Copyright @ 2002 US Army Research Laboratory */ #/* All Rights Reserved */ #/* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ #/* */ #/* This software is distributed WITHOUT ANY WARRANTY; without */ #/* even the implied warranty of MERCHANTABILITY or FITNESS */ #/* FOR A PARTICULAR PURPOSE. See the above copyright notice */ #/* for more information. */ #/* */ #/*******************************************************************/ import sys import string import Xdmf class NdgmLs : def __init__( self, Hostname = None ) : self.BufferLength = 4000 self.Ndgm = Xdmf.XdmfNDGM() self.Ndgm.SetModeToClient() self.entries = None if Hostname != None : self.Ndgm.SetNdgmHost( Hostname ) def Ls( self ) : status = self.Ndgm.Open() if status <= 0 : print "Can't Connect to NDGM Server on " + self.Ndgm.GetNdgmHost() return None # Get the Length Length = self.Ndgm.GetTotalLength() # print 'NDGM on %s is %d bytes' % ( self.Ndgm.GetNdgmHost(), Length ) self.RawString = string.split( Xdmf.XdmfGetNdgmEntries() ) return self.RawString def Format( self, Raw = None) : if Raw == None : Raw = self.RawString NumberOfEntries = len( self.RawString ) / 4 Index = 0 self.entries = [] for i in range( NumberOfEntries ) : # Skip -NDGM_ENTRY- Index += 1 Name = self.RawString[ Index ] Index += 1 Start = self.RawString[ Index ] Index += 1 End = self.RawString[ Index ] Index += 1 self.entries += ['%-20s %12d %12d' % (Name, int(Start), int(End))] return( self.entries ) if __name__ == '__main__' : argc = len( sys.argv ) if argc > 1 : Hostname = sys.argv[ argc - 1 ] else : Hostname = None n = NdgmLs( Hostname ) l = n.Ls() if l == None : sys.exit( 1 ) e = n.Format() NumberOfEntries = len( e ) if NumberOfEntries < 1 : print '-1 : No Entries in NDGM' else : for i in range( NumberOfEntries ) : print '%2d : %s' % ( i, e[ i ]) xdmf-3.0+git20160803/Examples/Python/XdmfVtkTest1.py0000740000175000017500000000243313003006557022012 0ustar alastairalastair#!/bin/env python from Xdmf import * from vtk import * from libvtkXdmfPython import * Reader = vtkXdmfReader() Controller = vtkMPIController() Reader.SetController(Controller) ProcId = Reader.GetController().GetLocalProcessId() NumProcs = Reader.GetController().GetNumberOfProcesses() print 'Hello from %d of %d' % (ProcId, NumProcs) Reader.SetFileName('Points1.xmf') # Reader.DebugOn() Reader.UpdateInformation() Reader.DisableAllGrids() Reader.EnableGrid(2) Reader.EnableAllArrays() Reader.Update() print 'Output = ', Reader.GetOutput() Append = vtkAppendFilter() print ProcId," : Ports = ", Reader.GetNumberOfOutputPorts() for on in range(Reader.GetNumberOfOutputPorts()) : Output = Reader.GetOutput(on) print ProcId, ' Number of Levels ',Output.GetNumberOfLevels() print ProcId, ' Number of Groups ',Output.GetNumberOfGroups() print ProcId, ' Number of DataSets in Group 0 ',Output.GetNumberOfDataSets(0) for i in range(Output.GetNumberOfDataSets(0)) : ds = Output.GetDataSet(0,i) if ds : print '%d : Output %d = %d Cells' % (ProcId, i, ds.GetNumberOfCells()) Append.AddInput(ds) else : print '%d : Output %d = NONE' % (ProcId, i) Append.Update() print Append.GetOutput() xdmf-3.0+git20160803/Examples/Python/PipeView.py0000740000175000017500000001462113003006557021240 0ustar alastairalastair#!/usr/bin/env python #/*******************************************************************/ #/* XDMF */ #/* eXtensible Data Model and Format */ #/* */ #/* Id : $Id: PipeView.py,v 1.2 2009-01-23 20:48:54 clarke Exp $ */ #/* Date : $Date: 2009-01-23 20:48:54 $ */ #/* Version : $Revision: 1.2 $ */ #/* */ #/* Author: */ #/* Jerry A. Clarke */ #/* clarke@arl.army.mil */ #/* US Army Research Laboratory */ #/* Aberdeen Proving Ground, MD */ #/* */ #/* Copyright @ 2002 US Army Research Laboratory */ #/* All Rights Reserved */ #/* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ #/* */ #/* This software is distributed WITHOUT ANY WARRANTY; without */ #/* even the implied warranty of MERCHANTABILITY or FITNESS */ #/* FOR A PARTICULAR PURPOSE. See the above copyright notice */ #/* for more information. */ #/* */ #/*******************************************************************/ import getopt import sys import string print 'Loading Xdmf' import Xdmf print 'Loading vtk' from vtk import * from libvtkXdmfPython import * import vtkRenderWidget import Tkinter # from vtkPipeline import * import vtkPipeline.vtkPipeline class ViewAll: def __init__( self ): self.StartGrid = 0 self.EndGrid = -1 self.Attributes = [] def FindGrids( self, FileName ) : DOM = Xdmf.XdmfDOM() DOM.SetInputFileName( FileName ) DOM.Parse() self.NumberOfGrids = DOM.FindNumberOfElements( 'Grid' ) def Done(self) : sys.exit() def SetUpPipeline( self, Ren ) : root = Tkinter.Tk() root.title("XDMF Viewer") wid = vtkRenderWidget.vtkTkRenderWidget (root, width=500, height=500) wid.pack (expand='true', fill='both') wid.bind ("", lambda e=None: self.Done() ) renWin = wid.GetRenderWindow() renWin.AddRenderer(Ren) renWin.SetSize(500,500) renWin.Render () pipe = vtkPipeline.vtkPipeline.vtkPipelineBrowser (root, renWin) pipe.browse () root.mainloop () def View ( self, FileName ): print 'Parsing ' + FileName if( self.EndGrid <= 0 ) : self.FindGrids( FileName ) self.EndGrid = self.NumberOfGrids - 1 Ren = vtkRenderer() for GridIndex in range( self.StartGrid, self.EndGrid + 1 ) : Reader = vtkXdmfReader() # The XML File is Input Reader.SetInputFileName( FileName ) Reader.SetGridIndex( GridIndex ) # Parse the XML but don't # yet read the Heavy Data (HDF5) # This is necessary so that vtk knows # the topology of the data since it # could be structured or unstructured Reader.Initialize() # Read XDMF Attributes Reader.SetAllAttributeStatusOff() Index = GridIndex - self.StartGrid if Index < len( self.Attributes ) : AttrIndex = self.Attributes[ Index ] print 'Setting Attribute %d On' % AttrIndex Reader.SetAttributeStatusOn( AttrIndex ) GeometryFilter = vtkGeometryFilter() GeometryFilter.SetInput( Reader.GetOutput() ) # Reader.Update() Triggers the Reading of HDF5 # this is triggered by the Viz Pipeline GeometryFilter.Update() # We can access the underlying XdmfGrid # if necessary Gridptr = Reader.GetXdmfGridHandle() Grid = Xdmf.HandleToXdmfGrid( Gridptr ) print 'Grid %d has %d ' % (GridIndex, Grid.GetNumberOfElements()) + \ Grid.GetTopologyTypeAsString() Nattr = Grid.GetNumberOfAttributes() print ' has %d Attributes' % Nattr for i in range( Nattr ) : Attribute = Grid.GetAttribute( i ) print '\tAttribute #%d' % i print '\t\tName: ' + Attribute.GetName() print '\t\tCenter: ' + Attribute.GetAttributeCenterAsString() print '\t\tType: ' + Attribute.GetAttributeTypeAsString() # List All of the Available Arrays PointData = Reader.GetOutput().GetPointData() for i in range( PointData.GetNumberOfArrays() ) : Array = PointData.GetArray( i ) print '\tArray #%d ' % i print '\t\tName: ' + Array.GetName() Min, Max = Array.GetRange() print '\t\tRange: %f -> %f' % (Min, Max) # Use the Third Attribute (Z Coordinate) for Color # GeometryFilter.GetInput().GetPointData().SetActiveScalars('Z Coordinate') Mapper = vtkPolyDataMapper() Mapper.SetInput( GeometryFilter.GetOutput() ) ScalarRange = GeometryFilter.GetOutput().GetScalarRange() Mapper.SetScalarRange( ScalarRange ) # Blue to Red Mapper.GetLookupTable().SetHueRange( .667, 0.0 ) Actor = vtkActor() Actor.SetMapper( Mapper ) # Actor.GetProperty().SetRepresentationToWireframe() Ren.AddActor( Actor ) Ren.SetBackground(.2, .2, .2) self.SetUpPipeline(Ren) # RenWin = vtkRenderWindow() # RenWin.SetSize(500,500) # RenWin.AddRenderer(Ren) # iRen = vtkRenderWindowInteractor() # iRen.SetRenderWindow(RenWin) # Interact with the Mouse and Keyboard # iRen.Initialize() # iRen.Start() def usage (self) : print 'Options : --start=Grid# --end=Grid# --attribute=Index --attribute=Index ... File.xmf' sys.exit(0) def Options( self, opts ) : argc = len( opts ) print '%d Args = ' % argc + str( opts ) try : opts, args = getopt.getopt(opts, "aseh:", ["help", "start=", "end=", "attribute=" ]) except getopt.GetoptError: self.usage() sys.exit(2) print 'opts = ' + str( opts ) print 'args = ' + str( args ) output = None for o, a in opts: if o in ("-h", "--help"): self.usage() sys.exit() if o in ("-s", "--start"): self.StartGrid = int(a) if o in ("-e", "--end"): self.EndGrid = int(a) if o in ("-a", "--attribute"): print 'Appending ' + a self.Attributes.append( int(a) ) print 'StartGrid %d' % self.StartGrid print 'EndGrid %d' % self.EndGrid print 'Attributes = ' + str( self.Attributes ) if __name__ == '__main__' : argc = len( sys.argv ) viewer = ViewAll() viewer.Options( sys.argv[1:] ) viewer.View( sys.argv[ argc - 1 ] ) xdmf-3.0+git20160803/Examples/Python/NdgmCp.py0000740000175000017500000001004513003006557020654 0ustar alastairalastair#!/bin/env python #/*******************************************************************/ #/* XDMF */ #/* eXtensible Data Model and Format */ #/* */ #/* Id : $Id: NdgmCp.py,v 1.2 2009-01-23 20:48:53 clarke Exp $ */ #/* Date : $Date: 2009-01-23 20:48:53 $ */ #/* Version : $Revision: 1.2 $ */ #/* */ #/* Author: */ #/* Jerry A. Clarke */ #/* clarke@arl.army.mil */ #/* US Army Research Laboratory */ #/* Aberdeen Proving Ground, MD */ #/* */ #/* Copyright @ 2002 US Army Research Laboratory */ #/* All Rights Reserved */ #/* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ #/* */ #/* This software is distributed WITHOUT ANY WARRANTY; without */ #/* even the implied warranty of MERCHANTABILITY or FITNESS */ #/* FOR A PARTICULAR PURPOSE. See the above copyright notice */ #/* for more information. */ #/* */ #/*******************************************************************/ import os import sys import string import Xdmf from NdgmLs import * class NdgmCp : def __init__( self, From, To ) : self.Host = None self.From = From self.FromIsFile = 1 self.To = To self.ToIsFile = 1 l = string.split( From, ':' ) if len(l) > 1 : self.FromIsFile = 0 host, name = string.split( From, ':' ) if len( host ) > 0 : if string.upper( host ) == 'NDGM' : host = None self.Host = host self.From = name l = string.split( To, ':' ) if len(l) > 1 : self.ToIsFile = 0 host, name = string.split( To, ':' ) if len( host ) > 0 : if string.upper( host ) == 'NDGM' : host = None self.Host = host self.To = name if self.To == '.' : self.To = self.From self.Conn = NdgmLs( self.Host ) self.Conn.Ls() self.Entries = self.Conn.Format() def Get( self ) : if self.FromIsFile : self.FromLength = os.path.getsize( self.From ) else : for entry in self.Entries : entry = string.split( entry ) if self.From == entry[0] : self.FromStart = int( entry[1] ) self.FromEnd = int( entry[2] ) self.FromLength = self.FromEnd - self.FromStart print 'Source Data is %d bytes' % self.FromLength def Put( self ) : if self.ToIsFile : if self.FromIsFile : Cmd = 'cp ' + self.From + ' ' + self.To print Cmd os.system( Cmd ) else : From = str(self.FromStart) + ':' + str(self.FromEnd) Cmd = 'ice ndgm_cat ' + From + ' ' + self.To print Cmd os.system( Cmd ) else : Found = 0 for entry in self.Entries : entry = string.split( entry ) if self.To == entry[0] : Found = 1 self.ToStart = int( entry[1] ) self.ToEnd = int( entry[2] ) self.ToLength = self.ToEnd - self.ToStart break if Found : pass else : Xdmf.XdmfAddNdgmEntry( self.To, self.FromLength ) self.Conn.Ls() self.Entries = self.Conn.Format() for entry in self.Entries : entry = string.split( entry ) if self.To == entry[0] : Found = 1 self.ToStart = int( entry[1] ) self.ToEnd = int( entry[2] ) self.ToLength = self.ToEnd - self.ToStart break if self.FromIsFile : From = self.From else : From = str(self.FromStart) + ':' + str(self.FromEnd) Cmd = 'ice ndgm_cat ' + From + ' ' + str( self.ToStart ) print Cmd os.system( Cmd ) if __name__ == '__main__' : argc = len( sys.argv ) n = NdgmCp( sys.argv[ argc - 2 ] , sys.argv[ argc - 1 ] ) n.Get() n.Put() xdmf-3.0+git20160803/Examples/Python/XdmfDOMTest3.py0000740000175000017500000000037213003006557021667 0ustar alastairalastair#!/bin/env python from Xdmf import * d = XdmfDOM() root = d.Create() dm = d.InsertNew(root, 'Domain') g = d.InsertNew(dm, 'Grid') geo = d.InsertNew(g, 'Geometry') ds = d.InsertNew(geo, 'DataStructure') print d.Serialize(root) d.Write('junk.xmf') xdmf-3.0+git20160803/Examples/Python/CVS/0000740000175000017500000000000013003006557017562 5ustar alastairalastairxdmf-3.0+git20160803/Examples/Python/CVS/Repository0000640000175000017500000000002513003006557021663 0ustar alastairalastairXdmf/Examples/Python xdmf-3.0+git20160803/Examples/Python/CVS/Root0000640000175000017500000000006413003006557020432 0ustar alastairalastair:pserver:anonymous@public.kitware.com:/cvsroot/Xdmf xdmf-3.0+git20160803/Examples/Python/CVS/Entries0000640000175000017500000000260513003006557021123 0ustar alastairalastair/FromOBJ.py/1.2/Fri Jan 23 20:48:47 2009// /NdgmCp.py/1.2/Fri Jan 23 20:48:53 2009// /NdgmLs.py/1.2/Fri Jan 23 20:48:54 2009// /PipeView.py/1.2/Fri Jan 23 20:48:54 2009// /SetsMaps.py/1.2/Wed Feb 25 16:03:40 2009// /SetsMaps2.py/1.1/Wed Feb 25 16:03:41 2009// /ViewAll.py/1.2/Fri Jan 23 20:48:54 2009// /WriteCompressed.py/1.1/Fri May 8 19:36:27 2009// /WriteXdmf1.py/1.1/Fri Jan 23 20:48:54 2009// /WriteXdmf2.py/1.2/Mon Jan 26 21:15:38 2009// /XReflector.py/1.1/Fri Oct 19 19:01:41 2007// /XVis.py/1.1/Fri Oct 19 19:01:41 2007// /XdmfArrays.py/1.1/Fri Oct 19 18:55:10 2007// /XdmfDOMTest1.py/1.1/Fri Oct 19 18:55:10 2007// /XdmfDOMTest2.py/1.1/Fri Oct 19 18:55:10 2007// /XdmfDOMTest3.py/1.1/Fri Oct 19 18:55:10 2007// /XdmfDOMTest4.py/1.1/Fri Oct 19 18:55:10 2007// /XdmfDataFunction.py/1.1/Fri Oct 19 18:55:11 2007// /XdmfDataItem.py/1.1/Fri Oct 19 18:55:11 2007// /XdmfDataStructureTest.py/1.1/Fri Oct 19 18:55:11 2007// /XdmfDataStructureTest2.py/1.1/Fri Oct 19 18:55:11 2007// /XdmfGridTest.py/1.1/Fri Oct 19 18:55:11 2007// /XdmfGridTest2.py/1.1/Fri Oct 19 18:55:11 2007// /XdmfGridTest3.py/1.1/Fri Oct 19 18:55:11 2007// /XdmfReader.py/1.1/Fri Oct 19 19:01:41 2007// /XdmfTimeTest1.py/1.1/Thu Jan 31 17:28:25 2008// /XdmfVtk.py/1.1/Fri Oct 19 19:01:41 2007// /XdmfVtkTest1.py/1.1/Fri Oct 19 18:55:11 2007// /XdmfVtkTest2.py/1.1/Fri Oct 19 18:55:11 2007// /XdmfWriter.py/1.1/Fri Oct 19 18:55:11 2007// D xdmf-3.0+git20160803/Examples/Python/XdmfArrays.py0000740000175000017500000000255413003006557021572 0ustar alastairalastair#!/bin/env python from Xdmf import * def Expression(*args) : e = '' for arg in args : if hasattr(arg, 'GetTagName') : e += arg.GetTagName() + ' ' else : e += arg + ' ' return XdmfExpr(e) if __name__ == '__main__' : a1 = XdmfArray() a1.SetNumberType(XDMF_FLOAT32_TYPE) a1.SetNumberOfElements(20) a1.Generate(1, 20) a2 = XdmfArray() a2.SetNumberType(XDMF_INT32_TYPE) a2.SetNumberOfElements(5) a2.Generate(2, 10) print 'a1 Values = ', a1.GetValues() print 'a1[2:10] = ' + Expression(a1 , '[ 2:10 ]').GetValues() print 'a2 Values = ', a2.GetValues() print 'a1[a2] = ' + Expression(a1 , '[', a2, ']').GetValues() print 'a1 + a2 = ' + Expression(a1 , ' + ', a2).GetValues() print 'a1 * a2 = ' + Expression(a1 , ' * ', a2).GetValues() a2.SetNumberType(XDMF_FLOAT32_TYPE) a2.SetNumberOfElements(20) a2.Generate(21, 40) print 'a2 Values = ', a2.GetValues() print 'a1 , a2 (Interlace) = ' + Expression(a1 , ' , ', a2).GetValues() print 'a1 , a2, a1 (Interlace) = ' + Expression(a1 , ' , ', a2, ' , ', a1).GetValues() print 'a1 ; a2 (Concat) = ' + Expression(a1 , ' ; ', a2).GetValues() print 'where(a1 > 10) = ' + Expression('Where( ', a1 , ' > 10)').GetValues() print 'a2[where(a1 > 10)] = ' + Expression(a2, '[Where( ', a1 , ' > 10)]').GetValues() xdmf-3.0+git20160803/Examples/Python/XdmfDOMTest2.py0000740000175000017500000000021613003006557021663 0ustar alastairalastair#!/bin/env python from Xdmf import * dom = XdmfDOM() # dom.SetInputFileName('Example2.xmf') dom.Parse('Example2.xmf') print dom.Serialize() xdmf-3.0+git20160803/Examples/Python/XdmfReader.py0000640000175000017500000000417613003006557021534 0ustar alastairalastair#!/bin/env python """Reader for XDMF Grids""" from Xdmf import * from vtk import * from libvtkXdmfPython import * import string class XdmfReader : def __init__( self, DOM, Node ) : self.DOM = DOM self.Node = Node self.GridDOM = None self.GridNode = None self.Reader = vtkXdmfReader() # self.Reader.DebugOn() # Set the Input XML FileName = DOM.Get( Node, "FileName" ) if FileName == None : FileName = DOM.Get( Node, "Input" ) if FileName == None : FileName = DOM.Get( Node, "InputFileName" ) if FileName == None : FileName = DOM.Get( Node, "File" ) if FileName == None : print 'No FileName set' return print 'SetInputFileName(' + FileName + ')' self.Reader.SetInputFileName( FileName ) # Which Grid ? GridName = DOM.Get( Node, "Grid" ) if GridName == None : GridName = DOM.Get( Node, "GridName" ) if GridName : self.Reader.SetGridName(GridName) # Parse the XML self.Reader.Initialize() # Set Up Attributes Nparam = DOM.FindNumberOfElements( 'Parameter', Node ) if Nparam > 0 : # print 'Setting %d Parameters' % Nparam DOMHandle = self.Reader.GetXdmfDOMHandle() RDOM = HandleToXdmfDOM(DOMHandle) for i in range( Nparam) : PNode = DOM.FindElement( 'Parameter', i, Node ) Name = DOM.Get( PNode, "Name" ) Value = DOM.Get( PNode, "CurrentIndex" ) if not Value : Value = DOM.Get( PNode, "Value" ) pnode = 1 j = 0 while pnode : pnode = RDOM.FindElement('Parameter', j, None) if pnode : pName = RDOM.Get(pnode, 'Name') if pName == Name : RDOM.Set(pnode, 'CurrentIndex', Value) j += 1 pnode = RDOM.FindElement('Parameter', j, None) # Set Up Attributes Nattr = DOM.FindNumberOfElements( 'Attribute', Node ) print 'Reading %d Attributes' % Nattr if Nattr > 0 : self.Reader.SetAllAttributeStatusOff() for i in range( Nattr ) : ANode = DOM.FindElement( 'Attribute', i, Node ) Name = DOM.Get( ANode, "Name" ) self.Reader.SetAttributeStatusOn( Name ) def Update(self) : print 'Updating Grid' self.Reader.Update() return( self.Reader ) def GetOutput(self) : return( self.Reader.GetOutput() ) xdmf-3.0+git20160803/Examples/Python/WriteCompressed.py0000740000175000017500000000752113003006557022630 0ustar alastairalastair#!/bin/env python # # Author : Ian Curington # # Example to generate a stack of layered prism elements # Writes a "test20.xmf/h5" files with a 3D unstructured prism grid # N vertical layers based on triangle plan grid # containing "pressure" scalar node values, # uses Compression for connectivity, geometry and attributes. # from Xdmf import * BaseName = 'test20' # define simple triangle mesh in horizontal plane tri_conn = [0,1,6, \ 1,2,6, \ 2,3,6, \ 3,4,6, \ 4,5,6, \ 5,0,6 ] ntris = len(tri_conn)/3 tri_coords = [-2, 0, 0, \ -1, 1, 0, \ 1, 1, 0, \ 2, 0, 0, \ 1,-1, 0, \ -1,-1, 0, \ 0, 0, 0 ] ncoords = len(tri_coords)/3 # prism layers, make large enough to trigger hdf5 writing nlayers = 800 layer_delta = 0.01 """ Reset an existing .h5 file for truncating all or any existing contents, by writing small junk array in 'w' mode. """ # Write H5 Data arr = XdmfArray() #arr.DebugOn() arr.SetNumberType(XDMF_FLOAT64_TYPE) arr.SetShapeFromString("2 3") arr.Generate(0.0, 1.0, 0, arr.GetNumberOfElements() - 1) h5 = XdmfHDF() h5.CopyType(arr) h5.CopyShape(arr) h5.Open( BaseName + '.h5:/_junk_', 'w') h5.Write(arr) h5.Close() # XDMF init d = XdmfDOM() root = XdmfRoot() root.SetDOM(d) root.Build() # Domain dm = XdmfDomain() root.Insert(dm) # Grid g = XdmfGrid() g.SetName("Prism Grid") #g.DebugOn() # Topology - 3D unstructured grid, prism element type t = g.GetTopology() t.SetTopologyType(XDMF_WEDGE) t.SetNumberOfElements(nlayers * ntris) #t.DebugOn() cc = t.GetConnectivity() cc.SetNumberType(XDMF_INT32_TYPE) # length of connectivity nElem = nlayers*ntris*6 cc.SetNumberOfElements(nElem) cc.SetHeavyDataSetName( BaseName + r'.h5:/Connectivity' ) if nElem > 1000: cc.SetCompression(9) c_index = 0 for layer in range(nlayers): for tri in range(ntris): cc.SetValueFromInt64( c_index*6+0, tri_conn[3*tri+0]+layer*ncoords ) cc.SetValueFromInt64( c_index*6+1, tri_conn[3*tri+1]+layer*ncoords ) cc.SetValueFromInt64( c_index*6+2, tri_conn[3*tri+2]+layer*ncoords ) cc.SetValueFromInt64( c_index*6+3, tri_conn[3*tri+0]+(layer+1)*ncoords ) cc.SetValueFromInt64( c_index*6+4, tri_conn[3*tri+1]+(layer+1)*ncoords ) cc.SetValueFromInt64( c_index*6+5, tri_conn[3*tri+2]+(layer+1)*ncoords ) c_index = c_index + 1 # Geometry - origin and cell size geo = g.GetGeometry() geo.SetGeometryType(XDMF_GEOMETRY_XYZ) # three explicit corners ca = geo.GetPoints() ca.SetNumberType(XDMF_FLOAT32_TYPE) ca.SetHeavyDataSetName( BaseName + r'.h5:/Coordinates' ) # number of nodes * 3 nElem = (nlayers+1)*ncoords*3 ca.SetNumberOfElements(nElem) if nElem > 1000: ca.SetCompression(9) c_index = 0 for layer in range(nlayers+1): for node in range(ncoords): ca.SetValueFromFloat64( c_index*3+0, tri_coords[3*node+0] ) ca.SetValueFromFloat64( c_index*3+1, tri_coords[3*node+1] ) ca.SetValueFromFloat64( c_index*3+2, tri_coords[3*node+2]+layer*layer_delta ) c_index = c_index + 1 dm.Insert(g) # Attribute - as scalar node data attr = XdmfAttribute() attr.SetName("Pressure") attr.SetAttributeCenter(XDMF_ATTRIBUTE_CENTER_NODE); attr.SetAttributeType(XDMF_ATTRIBUTE_TYPE_SCALAR); #attr.DebugOn() p = attr.GetValues() p.SetHeavyDataSetName( BaseName + r'.h5:/Pressure') # number of nodes with values nElem = (nlayers+1)*ncoords p.SetNumberOfElements(nElem ) if nElem > 1000: p.SetCompression(9) c_index = 0 for layer in range(nlayers+1): for node in range(ncoords): value = 10.0 + float(layer) * 2.0 p.SetValueFromFloat64( c_index, value ) c_index = c_index + 1 g.Insert(attr) # Update XML and Write Values to DataItems root.Build() # DataItems > 100 values are heavy print d.Serialize() # prints to stdout d.Write( BaseName + r'.xmf') # write to file xdmf-3.0+git20160803/Examples/Python/XdmfDataStructureTest2.py0000740000175000017500000000753113003006557024045 0ustar alastairalastair#!/bin/env python from Xdmf import * PointsTxt = """ 10.0 0.0 0.0 10.0 1.0 0.0 10.0 2.0 0.0 10.0 3.0 0.0 10.0 4.0 0.0 10.0 0.0 1.0 10.0 1.0 1.0 10.0 2.0 1.0 10.0 3.0 1.0 10.0 4.0 1.0 10.0 0.0 0.0 10.0 1.0 0.0 10.0 2.0 0.0 10.0 3.0 0.0 10.0 4.0 0.0 10.0 0.0 1.0 10.0 1.0 1.0 10.0 2.0 1.0 10.0 3.0 1.0 10.0 4.0 1.0 10.0 0.0 0.0 10.0 1.0 0.0 10.0 2.0 0.0 10.0 3.0 0.0 10.0 4.0 0.0 10.0 0.0 1.0 10.0 1.0 1.0 10.0 2.0 1.0 10.0 3.0 1.0 10.0 4.0 1.0 /Xdmf/Domain/Grid[@Name="Shot Points"]/Geometry/DataStructure[2] """ fd = open('Points.xmf', 'w') fd.write(PointsTxt) fd.close() ######## dom = XdmfDOM() dom.Parse('Points.xmf') dm = dom.FindElement('Domain') g = dom.FindElement('Grid', 0, dm) geo = dom.FindElement('Geometry', 0, g) dse = dom.FindElement('DataStructure', 0, geo) ds = XdmfDataStructure() ds.DebugOn() ds.SetDOM(dom) ds.SetElement(dse) ds.UpdateInformation() ds.Update() print 'Values = ', ds.GetDataValues() dsre = dom.FindElement('DataStructure', 1, geo) dsr = XdmfDataStructure() dsr.SetDOM(dom) dsr.DebugOn() # This will clear the reference and cause I/O dsr.SetElement(dsre) dsr.UpdateInformation() dsr.Update() if(dsr.GetIsReference()) : print 'Getting Values' print 'Values = ', dsr.GetDataValues() else : print 'This is not a reference' dsre = dom.FindElement('DataStructure', 3, geo) dsr = XdmfDataStructure() dsr.SetDOM(dom) dsr.DebugOn() # This will clear the reference and cause I/O dsr.SetElement(dsre) # Cause an potential dangling reference # dsr.SetCopyReferenceData(0) print "UI" dsr.UpdateInformation() print "U" dsr.Update() # Cause an dangling reference by deleting refernced object # ds = 0 if(dsr.GetIsReference()) : print 'Getting Values' print 'Values = ', dsr.GetDataValues() else : print 'This is not a reference' xdmf-3.0+git20160803/Examples/Python/XdmfDataItem.py0000740000175000017500000000741113003006557022016 0ustar alastairalastair#!/bin/env python from Xdmf import * PointsTxt = """ 10.0 0.0 0.0 10.0 1.0 0.0 10.0 2.0 0.0 10.0 3.0 0.0 10.0 4.0 0.0 10.0 0.0 1.0 10.0 1.0 1.0 10.0 2.0 1.0 10.0 3.0 1.0 10.0 4.0 1.0 10.0 0.0 0.0 10.0 1.0 0.0 10.0 2.0 0.0 10.0 3.0 0.0 10.0 4.0 0.0 10.0 0.0 1.0 10.0 1.0 1.0 10.0 2.0 1.0 10.0 3.0 1.0 10.0 4.0 1.0 10.0 0.0 0.0 10.0 1.0 0.0 10.0 2.0 0.0 10.0 3.0 0.0 10.0 4.0 0.0 10.0 0.0 1.0 10.0 1.0 1.0 10.0 2.0 1.0 10.0 3.0 1.0 10.0 4.0 1.0 /Xdmf/Domain/Grid[@Name="Shot Points"]/Geometry/DataItem[2] """ fd = open('Points.xmf', 'w') fd.write(PointsTxt) fd.close() ######## dom = XdmfDOM() dom.Parse('Points.xmf') dm = dom.FindElement('Domain') g = dom.FindElement('Grid', 0, dm) geo = dom.FindElement('Geometry', 0, g) dse = dom.FindElement('DataItem', 0, geo) ds = XdmfDataItem() ds.DebugOn() ds.SetDOM(dom) ds.SetElement(dse) ds.UpdateInformation() ds.Update() print 'Values = ', ds.GetDataValues() dsre = dom.FindElement('DataItem', 1, geo) dsr = XdmfDataItem() dsr.SetDOM(dom) dsr.DebugOn() # This will clear the reference and cause I/O dsr.SetElement(dsre) dsr.UpdateInformation() dsr.Update() if(dsr.GetIsReference()) : print 'Getting Values' print 'Values = ', dsr.GetDataValues() else : print 'This is not a reference' dsre = dom.FindElement('DataItem', 3, geo) dsr = XdmfDataItem() dsr.SetDOM(dom) dsr.DebugOn() # This will clear the reference and cause I/O dsr.SetElement(dsre) # Cause an potential dangling reference # dsr.SetCopyReferenceData(0) print "UI" dsr.UpdateInformation() print "U" dsr.Update() # Cause an dangling reference by deleting refernced object # ds = 0 if(dsr.GetIsReference()) : print 'Getting Values' print 'Values = ', dsr.GetDataValues() else : print 'This is not a reference' xdmf-3.0+git20160803/Examples/Python/XVis.py0000740000175000017500000002550113003006557020400 0ustar alastairalastair#!/bin/env python """XVis for Python""" import sys import getopt import Xdmf from XdmfReader import * from XReflector import * import string import math class XVis : def __init__( self ) : self.ParentObject = None self.Reflector = XReflector() self.loop = 1 self.NdgmCheck = None self.Picker = None self.Mesa = 0 self.LastX = 0.0 self.LastY = 0.0 self.LastZ = 0.0 def PickMethod ( self ) : Picker = self.Picker PickMeasure = self.PickMeasure PickViewFile = self.PickViewFile if Picker.GetCellId < 0 : print 'No Cell Picked' return else : SelectionPoint = Picker.GetSelectionPoint() PickPosition = Picker.GetPickPosition() x = PickPosition[0] y = PickPosition[1] z = PickPosition[2] print 'X Y Z : %f %f %f' % ( x, y, z ) dx = x - self.LastX dy = y - self.LastY dz = z - self.LastZ Length = math.sqrt( ( dx * dx ) + ( dy * dy ) + ( dz * dz)) print 'Dx Dy Dz : %f %f %f' % ( dx, dy, dz) print 'Length : %f' % Length self.LastX = x self.LastY = y self.LastZ = z if PickViewFile : print 'Writing View in ' + PickViewFile Window = Picker.GetRenderer().GetRenderWindow() WindowSize = Window.GetSize() # print 'Window Size = ' + str( WindowSize ) WindowPosition = Window.GetPosition() # print 'Window Position = ' + str( WindowPosition ) Camera = Picker.GetRenderer().GetActiveCamera() Position = Camera.GetPosition() # print 'Camera Position = ' + str( Position ) FocalPoint = Camera.GetFocalPoint() # print 'Camera FocalPoint = ' + str( FocalPoint ) ViewUp = Camera.GetViewUp() # print 'Camera ViewUp = ' + str( ViewUp ) ViewFd = open( PickViewFile, "w" ) ViewFd.write('\n') ViewFd.write('\n') ViewFd.write('\n' % ( WindowPosition[0], WindowPosition[1])) ViewFd.write('\n') ViewFd.write('\n' % ( Position[0], Position[1], Position[2])) ViewFd.write('\n') ViewFd.write('\n') ViewFd.close() def Loop ( self, Node ) : DOM = self.DOM iRenName = DOM.Get( Node, "Interactor" ) iRen = self.Reflector.NameToObject( iRenName ) if iRen != None : iRen.Initialize() Continue = 1 while Continue : if iRen != None : if hasattr( iRen, 'LoopOnce') : iRen.LoopOnce() if iRen.GetBreakLoopFlag() != 0 : Continue = 0 break for i in range( DOM.GetNumberOfChildren( Node )) : ChildNode = DOM.GetChild( i, Node ) ChildType = DOM.Get( ChildNode, "NodeType" ) self.Visit( ChildNode ) def Visit( self, Node ) : DOM = self.DOM Reflector = self.Reflector Type = DOM.Get( Node, "NodeType" ) # print 'Visit ' + Type if Type == "Xvis" : return( 1 ) elif Type == "Ndgm" : if self.NdgmCheck == None : self.NdgmCheck = Xdmf.XdmfNDGM() self.NdgmCheck.SetModeToClient() Status = self.NdgmCheck.Open() if Status <= 0 : print "Can't Connect to Ndgm" return None Ndgm = self.NdgmCheck BarrierNumber = DOM.Get( Node, "Barrier" ) if BarrierNumber == None : BarrierNumber = 20 else : BarrierNumber = int( BarrierNumber ) CurrentValue = Ndgm.BarrierPoll( BarrierNumber ) BarrierValue = DOM.Get( Node, "Value" ) if BarrierValue == None : BarrierValue = CurrentValue DOM.Set(Node, "Value", str( CurrentValue ) ) else : BarrierValue = int( BarrierValue ) # print 'NDGM Current Value od %d = %d' % ( BarrierNumber, CurrentValue) if CurrentValue != BarrierValue : print 'Barrier Update #%d' % CurrentValue for i in range( DOM.GetNumberOfChildren( Node )) : ChildNode = DOM.GetChild( i, Node ) ChildType = DOM.Get( ChildNode, "NodeType" ) self.Visit( ChildNode ) CurrentValue = Ndgm.BarrierPoll( BarrierNumber ) # Avoid Multiple Update Locks DOM.Set(Node, "Value", str( CurrentValue ) ) return( CurrentValue ) elif Type == "Loop" : Status = self.Loop( Node ) return( Status ) # elif Type == "Invoke" : # Name = DOM.Get(Node, "Target") # Method = DOM.Get(Node, "Method") # Args = DOM.Get(Node, "Args") # NewObject = Reflector.NameToObject( Name ) # Status = Reflector.CallMethod( NewObject, Method, Args ) # return( Status ) elif Type == "Execute" : CData = string.strip(DOM.Get( Node, "CData" )) try : exec( CData ) return( 1 ) except : return( None ) elif Type == "Print" : TargetName = DOM.Get(Node, "Target") NewLine = DOM.Get(Node, "NewLine" ) TargetObject = Reflector.NameToObject( TargetName ) if (NewLine != None ) and (string.upper( NewLine ) == "FALSE") : if TargetObject != None : print str( TargetObject ) , else : # print "Target == None" print TargetName , else : if TargetObject != None : print str( TargetObject ) else : # print "Target == None" print TargetName return( TargetObject ) elif (Type == "Reference") or (Type == "Invoke") : Name = DOM.Get( Node, "Name" ) TargetName = DOM.Get(Node, "Target") Method = DOM.Get(Node, "Method") Args = DOM.Get(Node, "Args") if TargetName == None : TargetObject = self.ParentObject else : TargetObject = Reflector.NameToObject( TargetName ) if Method == None : NewObject = TargetObject else : # print 'Calling Method ' + Method + ' on ' + str( TargetObject ) NewObject = Reflector.CallMethod( TargetObject, Method, Args ) # Name == None is OK Reflector.RegisterObject( NewObject, Name ) return( NewObject ) elif Type == "XdmfReader" : Name = DOM.Get(Node, "Name") NewObject = XdmfReader(DOM, Node) Reflector.RegisterObject( NewObject, Name ) return( NewObject ) else : Name = DOM.Get( Node, "Name" ) if self.Mesa : if Type == 'PolyDataMapper' : Type = 'MesaPolyDataMapper' if Type == 'Actor' : Type = 'MesaActor' if Type == 'Renderer' : Type = 'MesaRenderer' if Type == 'RenderWindow' : Type = 'XMesaRenderWindow' # print 'Creating a ' + Type NewObject = Reflector.CreateObject( 'vtk' + Type, Name) if NewObject == None : NewObject = Reflector.CreateObject( Type, Name) if NewObject == None : # print "Can't Create " + Type return(None) if (Type == 'XdmfRenderWindowInteractor') or (Type == 'RenderWindowInteractor') : # Create a Picker self.Picker = vtkCellPicker() self.Picker.SetPickMethod( self.PickMethod ) self.PickMeasure = DOM.Get( Node, "Measure" ) self.PickViewFile = DOM.Get( Node, "ViewFile") NewObject.SetPicker( self.Picker ) for i in range( DOM.GetNumberOfAttributes( Node )) : Attribute = DOM.GetAttribute( Node, i ) if Attribute == 'Name' : pass else : Value = DOM.Get( Node, Attribute ) # print 'Try ' + Attribute + ' = ' + Value Status = Reflector.CallMethod( NewObject, Attribute, Value) if Status == None : Status = Reflector.CallMethod( NewObject, 'Set' + Attribute, Value) return( NewObject ) def Traverse( self, Node ) : DOM = self.DOM Reflector = self.Reflector Parent = self.Visit( Node ) self.ParentObject = Parent if Parent == None : return None for i in range( DOM.GetNumberOfChildren( Node )) : ChildNode = DOM.GetChild( i, Node ) ChildType = DOM.Get( ChildNode, "NodeType" ) if ChildType == 'PolyDataMapper' : ChildType = 'Mapper' self.ParentObject = Parent Child = self.Traverse( ChildNode ) # print 'Child = ' + str( Child ) if ( Child != None ) and (ChildType != 'Reference') : # Try Add # print '... ChildType = ' + str( ChildType ) # print '.. Child = ' + str( Child ) # print '... try ' + 'Add' + ChildType Attach = DOM.Get( ChildNode, "AttachAs" ) if Attach == None : if hasattr( Parent, 'Add' + ChildType ) : # print 'Calling Add' + ChildType eval('Parent.Add' + ChildType + '( Child )') elif hasattr( Parent, 'Set' + ChildType ) : # print 'Calling Set' + ChildType eval('Parent.Set' + ChildType + '( Child )') elif hasattr( Child, 'GetOutput' ) : # print 'Calling SetInput' if hasattr( Parent, 'SetInput') : Parent.SetInput( Child.GetOutput()) else : if hasattr( Child, 'GetOutput' ) : Attachment = Child.GetOutput() else : Attachment = Child if Attach == 'Actor2D' : eval('Parent.AddActor2D' + '( Attachment )') else : eval('Parent.Set' + Attach + '( Attachment )') return( Parent ) def usage ( self, argv ) : print 'Usage ' + argv[0] + ' ' + \ str( self.XVisOptions ) XVisOptions = ["help", "loop", "mesa", "replace=", "xml=", "input=" ] def main( self, argv ) : argc = len( argv ) try : # Only Accept Long Options opts, args = getopt.getopt(argv[1:], '', self.XVisOptions ) except getopt.GetoptError: self.usage(argv) return(-1) # print 'opts = ' + str( opts ) # print 'args = ' + str( args ) if len(args) != 0 : self.usage(argv) return(-1) DOM = XdmfDOM() self.DOM = DOM self.defines = {} self.txt = None # self.InputFile = args[0] for o, a in opts: if o in ("-h", "--help"): self.usage(argv) if o == "--mesa" : self.Mesa = 1 if o == "--loop" : self.loop = 1 if o == "--xml" : self.DOM.Parse( a ) if o == "--input" : a = os.path.abspath( a ) dirname = os.path.dirname( a ) fd = open(a, 'r') self.txt = fd.read() fd.close() if o == "--replace" : Key, Value = string.split( a, ',') self.defines[ Key ] = Value # self.DOM.SetInputFileName( a ) for key in self.defines.keys() : self.txt = string.replace( self.txt, key, self.defines[ key ] ) # print 'txt = ' + self.txt self.DOM.Parse( self.txt ) Node = self.DOM.FindElement( 'Xvis' ) if Node == None : print "Can't Find XVis Node" return( -1 ) self.Traverse( Node ) return(0) if __name__ == '__main__' : argv = sys.argv Xv = XVis() Xv.main( argv ) xdmf-3.0+git20160803/Examples/Python/XdmfGridTest2.py0000740000175000017500000000635413003006557022142 0ustar alastairalastair#!/bin/env python from Xdmf import * PointsTxt = """ 0 1 6 5 16 17 22 21 10.0 0.0 0.0 10.0 1.0 0.0 10.0 2.0 0.0 10.0 3.0 0.0 10.0 4.0 0.0 10.0 0.0 1.0 10.0 1.0 1.0 10.0 2.0 1.0 10.0 3.0 1.0 10.0 4.0 1.0 10.0 0.0 0.0 10.0 1.0 0.0 10.0 2.0 0.0 10.0 3.0 0.0 10.0 4.0 0.0 10.0 0.0 1.0 10.0 1.0 1.0 10.0 2.0 1.0 10.0 3.0 1.0 10.0 4.0 1.0 10.0 0.0 0.0 10.0 1.0 0.0 10.0 2.0 0.0 10.0 3.0 0.0 10.0 4.0 0.0 10.0 0.0 1.0 10.0 1.0 1.0 10.0 2.0 1.0 10.0 3.0 1.0 10.0 4.0 1.0 /Xdmf/Domain/Grid[@Name="TestGrid"]/Geometry/DataItem[2] """ fd = open('Points.xmf', 'w') fd.write(PointsTxt) fd.close() ######## dom = XdmfDOM() dom.Parse('Points.xmf') ge = dom.FindElementByPath('/Xdmf/Domain/Grid') grid = XdmfGrid() grid.SetDOM(dom) grid.SetElement(ge) grid.UpdateInformation() grid.Update() top = grid.GetTopology() top.DebugOn() conn = top.GetConnectivity() print 'Values = ', conn.GetValues() geo = grid.GetGeometry() points = geo.GetPoints() print 'Geo Type = ', geo.GetGeometryTypeAsString(), ' # Points = ', geo.GetNumberOfPoints() print 'Points = ', points.GetValues(0, 6) xdmf-3.0+git20160803/Examples/Python/XdmfDataStructureTest.py0000740000175000017500000000664613003006557023771 0ustar alastairalastair#!/bin/env python from Xdmf import * PointsTxt = """ 10.0 0.0 0.0 10.0 1.0 0.0 10.0 2.0 0.0 10.0 3.0 0.0 10.0 4.0 0.0 10.0 0.0 1.0 10.0 1.0 1.0 10.0 2.0 1.0 10.0 3.0 1.0 10.0 4.0 1.0 10.0 0.0 0.0 10.0 1.0 0.0 10.0 2.0 0.0 10.0 3.0 0.0 10.0 4.0 0.0 10.0 0.0 1.0 10.0 1.0 1.0 10.0 2.0 1.0 10.0 3.0 1.0 10.0 4.0 1.0 10.0 0.0 0.0 10.0 1.0 0.0 10.0 2.0 0.0 10.0 3.0 0.0 10.0 4.0 0.0 10.0 0.0 1.0 10.0 1.0 1.0 10.0 2.0 1.0 10.0 3.0 1.0 10.0 4.0 1.0 """ fd = open('Points.xmf', 'w') fd.write(PointsTxt) fd.close() ######## dom = XdmfDOM() dom.Parse('Points.xmf') dm = dom.FindElement('Domain') g = dom.FindElement('Grid', 0, dm) geo = dom.FindElement('Geometry', 0, g) dse = dom.FindElement('DataStructure', 0, geo) ds = XdmfDataStructure() ds.SetDOM(dom) ds.SetElement(dse) ds.UpdateInformation() print 'Rank ', ds.GetRank() print 'Dimensions ', ds.GetDimensions() dd = ds.GetDataDesc() print "Number Type ", dd.GetNumberTypeAsString() print "Number of Elements ", dd.GetNumberOfElements() print "Name = ", ds.GetName() # ds.DebugOn() ds.Update() ds.Build() print ds.Serialize() print 'Values = ', ds.GetDataValues() a = ds.GetArray() a.SetNumberType(XDMF_FLOAT32_TYPE) a.SetNumberOfElements(27) # a.SetShapeFromString("5 5") print "Shape = ", a.GetShapeAsString() a.Generate(1, 10) ds.DebugOn() ds.SetFormat(XDMF_FORMAT_HDF) ds.SetHeavyDataSetName('Jerry.h5:/NewData') ds.Build() print ds.Serialize() dom.Write('NewPoints.xmf') dsr = XdmfDataStructure() dsr.DebugOn() # This will clear the reference and cause I/O dsr.SetElement(ds.GetElement()) dsr.SetDOM(dom) dsr.Reference(ds.GetElement()) if(dsr.GetIsReference()) : print 'Values = ', dsr.GetDataValues() else : print 'This is not a reference' xdmf-3.0+git20160803/Examples/Python/WriteXdmf2.py0000740000175000017500000000312013003006557021473 0ustar alastairalastair#!/usr/bin/env python from Xdmf import * # Example of How to Generate Xdmf # The Heavy Data is written separately # Write H5 Data arr = XdmfArray() arr.SetNumberType(XDMF_FLOAT64_TYPE) arr.SetShapeFromString("10 20 30") arr.Generate(0.0, 1.0, 0, arr.GetNumberOfElements() - 1) h5 = XdmfHDF() h5.CopyType(arr) h5.CopyShape(arr) h5.Open('XdmfByHand.h5:/Mydata', 'w') h5.Write(arr) h5.Close() dv = XdmfValuesHDF() DataXml = dv.DataItemFromHDF('XdmfByHand.h5:/Mydata') # d = XdmfDOM() root = XdmfRoot() root.SetDOM(d) root.SetVersion(2.2) # Change the Version number because we can root.Build() # Information i = XdmfInformation() # Arbitrary Name=Value Facility i.SetName("SampleLocation") i.SetValue("4") root.Insert(i) # XML DOM is used as the keeper of the structure # Insert() creates an XML node and inserts it under # the parent # Domain dm = XdmfDomain() root.Insert(dm) # Grid g = XdmfGrid() g.SetName("Structured Grid") # Topology t = g.GetTopology() t.SetTopologyType(XDMF_3DCORECTMESH) t.GetShapeDesc().SetShapeFromString('10 20 30') # Geometry geo = g.GetGeometry() geo.SetGeometryType(XDMF_GEOMETRY_ORIGIN_DXDYDZ) geo.SetOrigin(1, 2, 3) geo.SetDxDyDz(0.1, 0.2, 0.3) dm.Insert(g) # Attribute attr = XdmfAttribute() attr.SetName("Pressure") attr.SetAttributeCenter(XDMF_ATTRIBUTE_CENTER_NODE); attr.SetAttributeType(XDMF_ATTRIBUTE_TYPE_SCALAR); # Insert the raw XML attr.SetDataXml(DataXml) g.Insert(attr) # Update XML and Write Values to DataItems root.Build() # DataItems > 100 values are heavy print d.Serialize() # prints to stdout d.Write('SMesh.xmf') # write to file xdmf-3.0+git20160803/Examples/Python/XdmfTimeTest1.py0000740000175000017500000002500213003006557022141 0ustar alastairalastair#!/bin/env python from Xdmf import * TimeTestTxt = """ 0 1 2 0 0 0 0.001 0 0 0.001 0.001 0 0 1 2 0 0 0.001 0.001 0 0.001 0.001 0.001 0.001 0 1 2 0 0 0.002 0.001 0 0.002 0.001 0.001 0.002 0 1 2 0 0 0.003 0.001 0 0.003 0.001 0.001 0.003 0 1 2 0 0 0 0.001 0 0 0.001 0.001 0 0 1 2 0 0 0.001 0.001 0 0.001 0.001 0.001 0.001 0 1 2 0 0 0.002 0.001 0 0.002 0.001 0.001 0.002 0 1 2 0 0 0.003 0.001 0 0.003 0.001 0.001 0.003 0 1 2 0 0 0 0.001 0 0 0.001 0.001 0 0 1 2 0 0 0.001 0.001 0 0.001 0.001 0.001 0.001 0 1 2 0 0 0.002 0.001 0 0.002 0.001 0.001 0.002 0 1 2 0 0 0.003 0.001 0 0.003 0.001 0.001 0.003 """ ######## Write out an Xdmf File ############### fd = open('TimeTest.xmf', 'w') fd.write(TimeTestTxt) fd.close() ############################################## dom = XdmfDOM() dom.Parse('TimeTest.xmf') ### Loop thru the Four Collection Grids for GridIndex in range(1, 5) : print 'Reading /Xdmf/Domain/Grid[%d]' % GridIndex ge = dom.FindElementByPath('/Xdmf/Domain/Grid[%d]' % GridIndex) g = XdmfGrid() g.SetDOM(dom) g.SetElement(ge) g.UpdateInformation() # Time is available after Light Data is Read t = g.GetTime() tt = t.GetTimeType() print 'Time Type = ', tt, ' : ', t.GetTimeTypeAsString() if(tt == XDMF_TIME_SINGLE) : print "Value = ", t.GetValue() elif (tt == XDMF_TIME_LIST) : print "List of Times = ", t.GetArray().GetValues() elif (tt == XDMF_TIME_RANGE) : print "Min/Max = ", t.GetArray().GetValues() elif (tt == XDMF_TIME_HYPERSLAB) : print "Start/Stride/Count = ", t.GetArray().GetValues() # Evaluate will populate the array with the indecies of the # XdmfGrids that are entirely in the range a = XdmfArray() if (t.Evaluate(g, a) == XDMF_SUCCESS) : print "Valid times = ", a.GetValues() print "MinMax = ", a.GetMinAsFloat64(), ',' , a.GetMaxAsFloat64() else : print 'No Valid Times ... checking all children' # The "Descend" Parameter will recursively check the children if (t.Evaluate(g, a, 1) == XDMF_SUCCESS) : print "Valid times = ", a.GetValues() print "MinMax = ", a.GetMinAsFloat64(), ',' , a.GetMaxAsFloat64() a = XdmfArray() # By default XdmfTime::Epsilon is 1e-7. Use XdmfTime::SetEpsilon() # to change it if(g.FindGridsInTimeRange(0.05, 0.1, a) == XDMF_SUCCESS) : print 'Grids in Range(0.05, 0.1) = ', a.GetValues() else : print "No times are in Range(0.05, 0.1)" # Read Heavy Data to See the DataItems g.Update() # print g.Serialize() xdmf-3.0+git20160803/Examples/Python/XReflector.py0000640000175000017500000000372413003006557021566 0ustar alastairalastair#!/bin/env python """Reflection for XDMF and vtk""" from Xdmf import * from vtk import * from libvtkXdmfPython import * # from libVTKCommonPython import * # from libVTKGraphicsPython import * # from libVTKLocalPython import * import string import inspect class XReflector : def __init__( self ) : self.Lookup = {} def RegisterObject(self, ObjectToRegister, Name ) : if (ObjectToRegister != None) and (Name != None) : self.Lookup[ Name ] = ObjectToRegister return( ObjectToRegister ) return ( None ) def CreateObject( self, Type, Name ) : try : NewObject = eval( Type + '()') self.RegisterObject( NewObject, Name ) if Name != None : self.Lookup[ Name ] = NewObject return( NewObject ) except : return( None ) def CallMethod( self, ObjectToCall, Method, Args ) : # Methods = inspect.getmembers( XdmfDOM, inspect.ismethod) if hasattr( ObjectToCall, Method ) : RealArgs = ' ' if Args != None : ArgsToTry = string.split( Args, ',' ) # print 'ArgsToTry = ' + str(ArgsToTry) for Arg in ArgsToTry : RealArg = self.NameToObject( Arg ) # print 'RealArg(' + Arg + ') = ' + str( RealArg ) if RealArg == None : RealArgs += Arg + ',' else : try : for item in RealArg : RealArgs += str(item) + ',' except : RealArgs += 'self.NameToObject("' + Arg + '")'+ ',' # print 'RealArgs = ' + RealArgs RealArgs = RealArgs[:-1] try : # print 'Calling ... ObjectToCall.' + Method + '(' + RealArgs + ')' Result = eval('ObjectToCall.' + Method + '(' + RealArgs + ')' ) # print 'Back From Call' if Result == None : Result = 1 return( Result ) except : return( None ) else : return None def NameToObject( self, Name ) : if self.Lookup.has_key( Name ) : return( self.Lookup[ Name ] ) return( None ) def ObjectToName ( self, Object ) : for Name in self.Lookup.keys() : if self.Lookup[ Name ] == Object : return( Name ) return( None ) xdmf-3.0+git20160803/Examples/Python/XdmfVtkTest2.py0000740000175000017500000000370613003006557022017 0ustar alastairalastair#!/bin/env python from Xdmf import * from vtk import * from libvtkXdmfPython import * Reader = vtkXdmfReader() Controller = vtkMPIController() Reader.SetController(Controller) ProcId = Reader.GetController().GetLocalProcessId() NumProcs = Reader.GetController().GetNumberOfProcesses() print 'Hello from %d of %d' % (ProcId, NumProcs) Reader.SetFileName('Mixed.xmf') # Reader.DebugOn() Reader.UpdateInformation() Reader.EnableAllGrids() Reader.EnableAllArrays() Reader.Update() print 'Output = ', Reader.GetOutput() Append = vtkAppendFilter() print ProcId," : Ports = ", Reader.GetNumberOfOutputPorts() RenderWindow = vtkRenderWindow() Renderer = vtkRenderer() RenderWindow.AddRenderer(Renderer) RenderWindowInteractor = vtkXdmfRenderWindowInteractor() RenderWindowInteractor.SetLightFollowCamera(0) RenderWindowInteractor.GetInteractorStyle().SetCurrentStyleToTrackballCamera() RenderWindowInteractor.GetInteractorStyle().SetAutoAdjustCameraClippingRange(1) RenderWindowInteractor.SetRenderWindow(RenderWindow) RenderWindowInteractor.Initialize() for on in range(Reader.GetNumberOfOutputPorts()) : ds = Output = Reader.GetOutput(on) print 'Output has %d Cells', Output.GetNumberOfCells() # for i in range(Output.GetNumberOfCells()) : # cell = Output.GetCell(i) # print 'Cell = ', cell Geometry = vtkGeometryFilter() Geometry.SetInput(Output) Mapper = vtkPolyDataMapper() Mapper.GetLookupTable().SetHueRange( .667, 0.0 ) Mapper.SetInput(Geometry.GetOutput()) Mapper.SetScalarRange(Output.GetScalarRange()) Actor = vtkActor() Actor.SetMapper(Mapper) Renderer.AddActor(Actor) i = 0 # if ds : # print '%d : Output %d = %d Cells' % (ProcId, i, ds.GetNumberOfCells()) # Append.AddInput(ds) # else : # print '%d : Output %d = NONE' % (ProcId, i) #Append.Update() #print Append.GetOutput() RenderWindowInteractor.Start(1) xdmf-3.0+git20160803/Examples/Python/XdmfWriter.py0000740000175000017500000002535713003006557021613 0ustar alastairalastair#!/bin/env python from Xdmf import * from vtk import * from libvtkXdmfPython import * class DataParser : CellTypes = { 1 : 'Vertex', 2 : 'PolyVertex', 3 : 'Line', 4 : 'PolyLine', 5 : 'Triangle', 6 : 'TriangleStrip', 7 : 'Polygon', 8 : 'Pixel', 9 : 'Quadrilateral', 10 : 'Tetrahedron', 11 : 'Voxel', 12 : 'Hexahedron', 13 : 'Wedge', 14 : 'Pyramid', 99 : 'Unknown' } def __init__(self) : self.DOM = XdmfDOM() self.Root = XdmfRoot() self.Root.SetDOM(self.DOM) self.Root.SetVersion(2.0) self.Root.Build() self.Root.DebugOn() self.Domain = XdmfDomain() self.Root.Insert(self.Domain) self.MainGrid = XdmfGrid() self.MainGrid.SetName('Main Grid') self.MainGrid.SetGridType(XDMF_GRID_TREE) self.Domain.Insert(self.MainGrid) self.Grids = [] self.Arrays = [] def ParseUGrid(self, UGrid) : if UGrid.IsHomogeneous() : print 'Homogeneous UGrid ', UGrid Fd = UGrid.GetFieldData() if Fd : NameArray = Fd.GetArray('Name') print 'NameArray = ', NameArray print 'name = ', NameArray.GetValue(0) CellArray = UGrid.GetCells() Conns = CellArray.GetData() print '%d Cells' % UGrid.GetNumberOfCells() for i in range(UGrid.GetNumberOfCells()) : print '(%d) %d = %s' % (i, UGrid.GetCellType(i), self.CellTypes[UGrid.GetCellType(i)]) print '%d Points' % UGrid.GetNumberOfPoints() for i in range(UGrid.GetNumberOfPoints()) : x, y, z = UGrid.GetPoint(i) print '(%d) %f %f %f' % (i, x, y, z) print '%d Connections' % CellArray.GetNumberOfConnectivityEntries() i = 0 while i < Conns.GetNumberOfTuples() : n = Conns.GetValue(i) i += 1 for j in range(n) : p = Conns.GetValue(i) i += 1 print '%d ' % p Pd = UGrid.GetPointData() print '# of Point Attributes = %d' % Pd.GetNumberOfArrays() for i in range(Pd.GetNumberOfArrays()) : Pa = Pd.GetArray(i) print Pd.GetArrayName(i), ' = ',Pa for j in range(Pa.GetNumberOfTuples()) : print '(%d) %f' % (j, Pa.GetValue(j)) Cd = UGrid.GetCellData() print '# of Cell Attributes = %d' % Cd.GetNumberOfArrays() # print UGrid else : print 'Heterogeneous UGrid' def DataArrayToXdmfArray(self, da) : # print 'Converting ', da print 'Data Type', da.GetDataType(), ' = ', da.GetDataTypeAsString() Xda = XdmfArray() Xda.SetNumberOfElements(da.GetNumberOfTuples() * da.GetNumberOfComponents()) Type = da.GetDataTypeAsString() pntr = da.GetVoidPointer(0) Xpntr = VoidPointerHandleToXdmfPointer(pntr) if Type.upper() == 'FLOAT' : # print 'Array is Float32' Xda.SetNumberType(XDMF_FLOAT32_TYPE) elif Type.upper() == 'INT' : # print 'Array is Int32' Xda.SetNumberType(XDMF_INT32_TYPE) elif Type.upper() == 'DOUBLE' : # print 'Array is Float64' Xda.SetNumberType(XDMF_FLOAT64_TYPE) elif Type.upper() == 'LONG' : # print 'Array is Int64' Xda.SetNumberType(XDMF_INT64_TYPE) elif Type.upper() == 'IDTYPE' : # print 'Array is Int64' Xda.SetNumberType(XDMF_INT64_TYPE) else : print 'Illegal NumberType : ', Type return None Xda.SetDataPointer(Xpntr) print 'Values ',Xda.GetValues(0, 10) return Xda def WriteIGrid(self, IGrid, Group, Index) : print 'Homogeneous Image UGrid ', IGrid.GetDimensions() def WriteUGrid(self, UGrid, Group, Index) : if UGrid.IsHomogeneous() : print 'Homogeneous UGrid ' Fd = UGrid.GetFieldData() if Fd : NameArray = Fd.GetArray('Name') print 'NameArray = ', NameArray print 'name = ', NameArray.GetValue(0) Xgrid = XdmfGrid() Xgrid.SetName('Group %05d Index %05d' % (Group, Index)) self.MainGrid.Insert(Xgrid) self.Grids.append(Xgrid) CellArray = UGrid.GetCells() Conns = CellArray.GetData() XConns = self.DataArrayToXdmfArray(Conns) print '%d Cells' % UGrid.GetNumberOfCells() NodesPerElement = XConns.GetValueAsInt64(0) print '%d NodesPerElement' % NodesPerElement XConns.SetShapeFromString("%d %d" % (UGrid.GetNumberOfCells(), NodesPerElement + 1)) print 'Shape ', XConns.GetShapeAsString() Start = '0 1' Stride = '1 1' Count = '%d %d' % (UGrid.GetNumberOfCells(), NodesPerElement) XConns.SelectHyperSlabFromString(Start, Stride, Count) Xtop = Xgrid.GetTopology() Xtop.SetTopologyTypeFromString(self.CellTypes[UGrid.GetCellType(0)]) Xtop.SetNumberOfElements(UGrid.GetNumberOfCells()) H5 = XdmfHDF() H5.CopyType(XConns) H5.SetShapeFromString(Count) H5.Open('CORE:Data.h5:Group %05d/Index %05d/Conns' % (Group, Index), 'rw') H5.Write(XConns) JustConns = XdmfArray() JustConns.CopyType(H5) JustConns.CopyShape(H5) H5.Read(JustConns) Xtop.SetConnectivity(JustConns) H5.Close() self.Arrays.append(JustConns) # for i in range(UGrid.GetNumberOfCells()) : # print '(%d) %d = %s' % (i, UGrid.GetCellType(i), self.CellTypes[UGrid.GetCellType(i)]) print '%d Points' % UGrid.GetNumberOfPoints() pnts = UGrid.GetPoints().GetData() # print "Points = ", pnts Xpnts = self.DataArrayToXdmfArray(pnts) Xgeo = Xgrid.GetGeometry() Xgeo.SetGeometryType(XDMF_GEOMETRY_XYZ) Xgeo.SetPoints(Xpnts) self.Arrays.append(Xpnts) # H5 = XdmfHDF() # H5.CopyType(Xpnts) # H5.CopyShape(Xpnts) # H5.Open('Data.h5:Group %05d/Index %05d/XYZ' % (Group, Index), 'rw') # H5.Write(Xpnts) # H5.Close() # for i in range(UGrid.GetNumberOfPoints()) : # x, y, z = UGrid.GetPoint(i) # print '(%d) %f %f %f' % (i, x, y, z) # print '%d Connections' % CellArray.GetNumberOfConnectivityEntries() # i = 0 # while i < Conns.GetNumberOfTuples() : # n = Conns.GetValue(i) # i += 1 # for j in range(n) : # p = Conns.GetValue(i) # i += 1 # print '%d ' % p Pd = UGrid.GetPointData() print '# of Point Attributes = %d' % Pd.GetNumberOfArrays() for i in range(Pd.GetNumberOfArrays()) : Pa = Pd.GetArray(i) Xpa = self.DataArrayToXdmfArray(Pa) Xattr = XdmfAttribute() Xattr.SetName("Point Attribute %d" % i) Xattr.SetAttributeCenter(XDMF_ATTRIBUTE_CENTER_NODE) Xattr.SetAttributeType(XDMF_ATTRIBUTE_TYPE_SCALAR) Xattr.SetValues(Xpa) Xgrid.Insert(Xattr) self.Arrays.append(Xpa) self.Arrays.append(Xattr) # self.Arrays.append(Xpa) # print Pd.GetArrayName(i), ' = ',Pa # for j in range(Pa.GetNumberOfTuples()) : # print '(%d) %f' % (j, Pa.GetValue(j)) Cd = UGrid.GetCellData() print '# of Cell Attributes = %d' % Cd.GetNumberOfArrays() for i in range(Cd.GetNumberOfArrays()) : Ca = Cd.GetArray(i) Xca = self.DataArrayToXdmfArray(Ca) Xattr = XdmfAttribute() Xattr.SetName("Cell Attribute %d" % i) Xattr.SetAttributeCenter(XDMF_ATTRIBUTE_CENTER_CELL) Xattr.SetAttributeType(XDMF_ATTRIBUTE_TYPE_SCALAR) Xattr.SetValues(Xca) Xgrid.Insert(Xattr) self.Arrays.append(Xca) self.Arrays.append(Xattr) # print UGrid else : print 'Heterogeneous UGrid' def ParseMultiGroup(self, Output) : print 'Parsing a vtkMultiGroupDataSet ' NGroups = Output.GetNumberOfGroups() print 'Output has %d Groups' % NGroups for g in range(NGroups) : NDataSets = Output.GetNumberOfDataSets(g) print 'Group %d has %d DataSets' % (g + 1, NDataSets) for i in range(NDataSets) : ds = Output.GetDataSet(g,i) print 'Output Group %d Index %d (%s) has %d Cells' % (g + 1, i + 1, ds.GetClassName(), ds.GetNumberOfCells()) if ds.IsA('vtkUnstructuredGrid') : self.ParseUGrid(ds) self.WriteUGrid(ds, g, i) if ds.IsA('vtkImageData') : self.WriteIGrid(ds, g, i) else : print 'Can not handle vtk class = ', ds.GetClassName() def Parse(self, Output) : if Output.IsA('vtkMultiGroupDataSet') : self.ParseMultiGroup(Output) else : print 'Can not handle vtk class = ', Output.GetClassName() if __name__ == '__main__' : # Reader = vtkXdmfReader() Reader = vtkXMLMultiGroupDataReader() # Reader = vtkXMLDataReader() # Controller = vtkMPIController() # Reader.SetController(Controller) # ProcId = Reader.GetController().GetLocalProcessId() # NumProcs = Reader.GetController().GetNumberOfProcesses() # print 'Hello from %d of %d' % (ProcId, NumProcs) # Reader.SetFileName('Points1.xmf') # Reader.SetFileName('VtkTest.pvd') Reader.SetFileName('VtkMulti.vtm') Reader.UpdateInformation() # Reader.DisableAllGrids() # Reader.EnableGrid(2) # Reader.DebugOn() # Reader.EnableAllGrids() # Reader.EnableAllArrays() # Reader.DisableGrid(0) # Reader.DisableGrid(1) Reader.Update() p = DataParser() print 'Reader has %d outputs' % Reader.GetNumberOfOutputPorts() for on in range(Reader.GetNumberOfOutputPorts()) : print 'Reading Output ', on Output = Reader.GetOutput(on) p.Parse(Output) p.Root.Build() print p.DOM.Serialize() p.DOM.Write('junk.xmf') xdmf-3.0+git20160803/Examples/Python/XdmfDataFunction.py0000740000175000017500000000342613003006557022707 0ustar alastairalastair#!/bin/env python from Xdmf import * PointsTxt = """ 0 1 2 3 4 5 6 7 8 9 100 101 102 103 104 105 106 107 108 109 0 0 1 2 2 5 0 0 0 9 1 0 1 9 """ fd = open('Points.xmf', 'w') fd.write(PointsTxt) fd.close() ######## dom = XdmfDOM() dom.Parse('Points.xmf') # die = dom.FindElement('DataItem', 1) die = dom.FindElementByPath('//DataItem[@Name = "MyFunction1"]') di = XdmfDataItem() di.DebugOn() di.SetDOM(dom) di.SetElement(die) di.UpdateInformation() di.Update() print 'Dims = ', di.GetArray().GetShapeAsString() print 'Values = ', di.GetDataValues() xdmf-3.0+git20160803/Examples/Python/XdmfGridTest.py0000740000175000017500000000644713003006557022063 0ustar alastairalastair#!/bin/env python from Xdmf import * PointsTxt = """ 0 1 6 5 16 17 22 21 10.0 0.0 0.0 10.0 1.0 0.0 10.0 2.0 0.0 10.0 3.0 0.0 10.0 4.0 0.0 10.0 0.0 1.0 10.0 1.0 1.0 10.0 2.0 1.0 10.0 3.0 1.0 10.0 4.0 1.0 10.0 0.0 0.0 10.0 1.0 0.0 10.0 2.0 0.0 10.0 3.0 0.0 10.0 4.0 0.0 10.0 0.0 1.0 10.0 1.0 1.0 10.0 2.0 1.0 10.0 3.0 1.0 10.0 4.0 1.0 10.0 0.0 0.0 10.0 1.0 0.0 10.0 2.0 0.0 10.0 3.0 0.0 10.0 4.0 0.0 10.0 0.0 1.0 10.0 1.0 1.0 10.0 2.0 1.0 10.0 3.0 1.0 10.0 4.0 1.0 /Xdmf/Domain/Grid[@Name="TestGrid"]/Geometry/DataItem[2] """ fd = open('Points.xmf', 'w') fd.write(PointsTxt) fd.close() ######## dom = XdmfDOM() dom.Parse('Points.xmf') te = dom.FindElementByPath('/Xdmf/Domain/Grid/Topology') top = XdmfTopology() top.DebugOn() top.SetDOM(dom) top.SetElement(te) top.Update() conn = top.GetConnectivity() print 'Values = ', conn.GetValues() ge = dom.FindElementByPath('/Xdmf/Domain/Grid/Geometry') geo = XdmfGeometry() geo.SetDOM(dom) geo.SetElement(ge) geo.Update() points = geo.GetPoints() print 'Geo Type = ', geo.GetGeometryTypeAsString(), ' # Points = ', geo.GetNumberOfPoints() print 'Points = ', points.GetValues(0, 6) xdmf-3.0+git20160803/Examples/Python/ViewAll.py0000740000175000017500000001342113003006557021050 0ustar alastairalastair#!/usr/bin/env python #/*******************************************************************/ #/* XDMF */ #/* eXtensible Data Model and Format */ #/* */ #/* Id : $Id: ViewAll.py,v 1.2 2009-01-23 20:48:54 clarke Exp $ */ #/* Date : $Date: 2009-01-23 20:48:54 $ */ #/* Version : $Revision: 1.2 $ */ #/* */ #/* Author: */ #/* Jerry A. Clarke */ #/* clarke@arl.army.mil */ #/* US Army Research Laboratory */ #/* Aberdeen Proving Ground, MD */ #/* */ #/* Copyright @ 2002 US Army Research Laboratory */ #/* All Rights Reserved */ #/* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ #/* */ #/* This software is distributed WITHOUT ANY WARRANTY; without */ #/* even the implied warranty of MERCHANTABILITY or FITNESS */ #/* FOR A PARTICULAR PURPOSE. See the above copyright notice */ #/* for more information. */ #/* */ #/*******************************************************************/ import getopt import sys import string print 'Loading Xdmf' import Xdmf print 'Loading vtk' from vtk import * from libvtkXdmfPython import * class ViewAll: def __init__( self ): self.StartGrid = 0 self.EndGrid = -1 self.Attributes = [] def FindGrids( self, FileName ) : DOM = Xdmf.XdmfDOM() DOM.SetInputFileName( FileName ) DOM.Parse() self.NumberOfGrids = DOM.FindNumberOfElements( 'Grid' ) def View ( self, FileName ): print 'Parsing ' + FileName if( self.EndGrid <= 0 ) : self.FindGrids( FileName ) self.EndGrid = self.NumberOfGrids - 1 Ren = vtkRenderer() for GridIndex in range( self.StartGrid, self.EndGrid + 1 ) : Reader = vtkXdmfReader() # The XML File is Input Reader.SetInputFileName( FileName ) Reader.SetGridIndex( GridIndex ) # Parse the XML but don't # yet read the Heavy Data (HDF5) # This is necessary so that vtk knows # the topology of the data since it # could be structured or unstructured Reader.Initialize() # Read XDMF Attributes Reader.SetAllAttributeStatusOff() Index = GridIndex - self.StartGrid if Index < len( self.Attributes ) : AttrIndex = self.Attributes[ Index ] print 'Setting Attribute %d On' % AttrIndex Reader.SetAttributeStatusOn( AttrIndex ) GeometryFilter = vtkGeometryFilter() GeometryFilter.SetInput( Reader.GetOutput() ) # Reader.Update() Triggers the Reading of HDF5 # this is triggered by the Viz Pipeline GeometryFilter.Update() # We can access the underlying XdmfGrid # if necessary Gridptr = Reader.GetXdmfGridHandle() Grid = Xdmf.HandleToXdmfGrid( Gridptr ) print 'Grid %d has %d ' % (GridIndex, Grid.GetNumberOfElements()) + \ Grid.GetTopologyTypeAsString() Nattr = Grid.GetNumberOfAttributes() print ' has %d Attributes' % Nattr for i in range( Nattr ) : Attribute = Grid.GetAttribute( i ) print '\tAttribute #%d' % i print '\t\tName: ' + Attribute.GetName() print '\t\tCenter: ' + Attribute.GetAttributeCenterAsString() print '\t\tType: ' + Attribute.GetAttributeTypeAsString() # List All of the Available Arrays PointData = Reader.GetOutput().GetPointData() for i in range( PointData.GetNumberOfArrays() ) : Array = PointData.GetArray( i ) print '\tArray #%d ' % i print '\t\tName: ' + Array.GetName() Min, Max = Array.GetRange() print '\t\tRange: %f -> %f' % (Min, Max) # Use the Third Attribute (Z Coordinate) for Color # GeometryFilter.GetInput().GetPointData().SetActiveScalars('Z Coordinate') Mapper = vtkPolyDataMapper() Mapper.SetInput( GeometryFilter.GetOutput() ) ScalarRange = GeometryFilter.GetOutput().GetScalarRange() Mapper.SetScalarRange( ScalarRange ) # Blue to Red Mapper.GetLookupTable().SetHueRange( .667, 0.0 ) Actor = vtkActor() Actor.SetMapper( Mapper ) Actor.GetProperty().SetRepresentationToWireframe() Ren.AddActor( Actor ) Ren.SetBackground(.2, .2, .2) RenWin = vtkRenderWindow() RenWin.SetSize(500,500) RenWin.AddRenderer(Ren) iRen = vtkRenderWindowInteractor() iRen.SetRenderWindow(RenWin) # Interact with the Mouse and Keyboard iRen.Initialize() iRen.Start() def usage (self) : print 'Options : --start=Grid# --end=Grid# --attribute=Index --attribute=Index ... File.xmf' sys.exit(0) def Options( self, opts ) : argc = len( opts ) print '%d Args = ' % argc + str( opts ) try : opts, args = getopt.getopt(opts, "aseh:", ["help", "start=", "end=", "attribute=" ]) except getopt.GetoptError: self.usage() sys.exit(2) print 'opts = ' + str( opts ) print 'args = ' + str( args ) output = None for o, a in opts: if o in ("-h", "--help"): self.usage() sys.exit() if o in ("-s", "--start"): self.StartGrid = int(a) if o in ("-e", "--end"): self.EndGrid = int(a) if o in ("-a", "--attribute"): print 'Appending ' + a self.Attributes.append( int(a) ) print 'StartGrid %d' % self.StartGrid print 'EndGrid %d' % self.EndGrid print 'Attributes = ' + str( self.Attributes ) if __name__ == '__main__' : argc = len( sys.argv ) viewer = ViewAll() viewer.Options( sys.argv[1:] ) viewer.View( sys.argv[ argc - 1 ] ) xdmf-3.0+git20160803/Examples/Data/0000740000175000017500000000000013003006557016517 5ustar alastairalastairxdmf-3.0+git20160803/Examples/Data/Points1.xmf0000640000175000017500000001546013003006557020600 0ustar alastairalastair 0 1 2 3 4 5 6 7 0.0 0.0 0.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 0.0 0.0 0.0 2.0 1.0 0.0 2.0 1.0 1.0 2.0 0.0 1.0 2.0 100 200 300 400 500 600 600 700 0 1 6 5 16 17 22 21 10.0 0.0 0.0 10.0 1.0 0.0 10.0 2.0 0.0 10.0 3.0 0.0 10.0 4.0 0.0 10.0 0.0 1.0 10.0 1.0 1.0 10.0 2.0 1.0 10.0 3.0 1.0 10.0 4.0 1.0 10.0 0.0 0.0 10.0 1.0 0.0 10.0 2.0 0.0 10.0 3.0 0.0 10.0 4.0 0.0 10.0 0.0 1.0 10.0 1.0 1.0 10.0 2.0 1.0 10.0 3.0 1.0 10.0 4.0 1.0 10.0 0.0 0.0 10.0 1.0 0.0 10.0 2.0 0.0 10.0 3.0 0.0 10.0 4.0 0.0 10.0 0.0 1.0 10.0 1.0 1.0 10.0 2.0 1.0 10.0 3.0 1.0 10.0 4.0 1.0 /Xdmf/Domain/Grid[@Name="TestGrid"]/Geometry/DataItem[2] 0 1 2 3 4 5 6 7 0.0 0.0 0.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 0.0 0.0 0.0 2.0 1.0 0.0 2.0 1.0 1.0 2.0 0.0 1.0 2.0 0 1 5 4 2 3 7 6 0.0 0.0 3.0 1.0 0.0 3.0 1.0 1.0 3.0 0.0 1.0 3.0 0.0 0.0 4.0 1.0 0.0 4.0 1.0 1.0 4.0 0.0 1.0 4.0 0 1 2 3 4 5 6 7 0.0 0.0 0.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 0.0 0.0 0.0 2.0 1.0 0.0 2.0 1.0 1.0 2.0 0.0 1.0 2.0 0 1 5 4 2 3 7 6 0.0 0.0 4.0 1.0 0.0 4.0 1.0 1.0 4.0 0.0 1.0 4.0 0.0 0.0 5.0 1.0 0.0 5.0 1.0 1.0 5.0 0.0 1.0 5.0 xdmf-3.0+git20160803/Examples/Data/Mixed.xmf0000640000175000017500000000312613003006557020305 0ustar alastairalastair A Mixed Topology consisting on a TET (Cell Type 6) A Polygon (Cell Type 3) and A HEX (Cell Type 9) 6 0 1 2 7 3 4 4 5 6 7 9 8 9 10 11 12 13 14 15 0.0 0.0 0.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 0.0 0.0 0.0 2.0 1.0 0.0 2.0 1.0 1.0 2.0 0.0 1.0 2.0 0.0 0.0 3.0 1.0 0.0 3.0 1.0 1.0 3.0 0.0 1.0 3.0 0.0 0.0 4.0 1.0 0.0 4.0 1.0 1.0 4.0 0.0 1.0 4.0 100 200 300 400 500 600 600 700 800 900 1000 1100 1200 1300 1400 1500 xdmf-3.0+git20160803/Examples/Data/BasicReference.xmf0000640000175000017500000002225613003006557022104 0ustar alastairalastair Example of a Polyvertex Topology 0 1 2 4 5 6 8 9 10 0.0 0.0 0.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 0.0 0.0 0.0 2.0 1.0 0.0 2.0 1.0 1.0 2.0 0.0 1.0 2.0 0.0 0.0 3.0 1.0 0.0 3.0 1.0 1.0 3.0 0.0 1.0 3.0 0.0 0.0 4.0 1.0 0.0 4.0 1.0 1.0 4.0 0.0 1.0 4.0 100 200 300 400 500 600 600 700 800 900 1000 1100 1200 1300 1400 1500 100 200 400 Example of a Polyline Topology 0 1 2 4 5 6 8 9 10 100 200 400 Example of a Polygon Topology 0 1 2 3 4 5 6 7 8 9 10 11 100 200 400 Example of a Triangle Topology 0 1 2 4 5 6 8 9 10 100 200 400 Example of a Quadrilateral Topology 0 1 2 3 4 5 6 7 8 9 10 11 100 200 400 Example of a Tetrahedron Topology 0 1 2 4 4 5 6 11 100 400 Example of a Pyramid Topology 0 1 2 3 4 4 5 6 7 11 100 400 Example of a Wedge Topology 0 1 2 4 5 6 5 6 7 9 10 11 100 400 Example of a Hexahedron Topology 0 1 2 3 4 5 6 7 4 5 6 7 8 9 10 11 100 400 xdmf-3.0+git20160803/Examples/Data/CVS/0000740000175000017500000000000013003006557017152 5ustar alastairalastairxdmf-3.0+git20160803/Examples/Data/CVS/Repository0000640000175000017500000000002313003006557021251 0ustar alastairalastairXdmf/Examples/Data xdmf-3.0+git20160803/Examples/Data/CVS/Root0000640000175000017500000000006413003006557020022 0ustar alastairalastair:pserver:anonymous@public.kitware.com:/cvsroot/Xdmf xdmf-3.0+git20160803/Examples/Data/CVS/Entries0000640000175000017500000000036413003006557020513 0ustar alastairalastair/BasicReference.xmf/1.1/Fri Oct 19 18:55:10 2007// /BasicTopology.xmf/1.1/Fri Oct 19 18:55:10 2007// /Mixed.xmf/1.2/Tue Dec 30 17:46:55 2008// /Points1.xmf/1.1/Fri Oct 19 18:55:10 2007// /StructuredTopology.xmf/1.1/Fri Oct 19 18:55:10 2007// D xdmf-3.0+git20160803/Examples/Data/BasicTopology.xmf0000640000175000017500000003633613003006557022026 0ustar alastairalastair Example of a Polyvertex Topology 0 1 2 4 5 6 8 9 10 0.0 0.0 0.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 0.0 0.0 0.0 2.0 1.0 0.0 2.0 1.0 1.0 2.0 0.0 1.0 2.0 0.0 0.0 3.0 1.0 0.0 3.0 1.0 1.0 3.0 0.0 1.0 3.0 0.0 0.0 4.0 1.0 0.0 4.0 1.0 1.0 4.0 0.0 1.0 4.0 100 200 300 400 500 600 600 700 800 900 1000 1100 1200 1300 1400 1500 100 200 400 Example of a Polyline Topology 0 1 2 4 5 6 8 9 10 0.0 0.0 0.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 0.0 0.0 0.0 2.0 1.0 0.0 2.0 1.0 1.0 2.0 0.0 1.0 2.0 0.0 0.0 3.0 1.0 0.0 3.0 1.0 1.0 3.0 0.0 1.0 3.0 0.0 0.0 4.0 1.0 0.0 4.0 1.0 1.0 4.0 0.0 1.0 4.0 100 200 300 400 500 600 600 700 800 900 1000 1100 1200 1300 1400 1500 100 200 400 Example of a Polygon Topology 0 1 2 3 4 5 6 7 8 9 10 11 0.0 0.0 0.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 0.0 0.0 0.0 2.0 1.0 0.0 2.0 1.0 1.0 2.0 0.0 1.0 2.0 0.0 0.0 3.0 1.0 0.0 3.0 1.0 1.0 3.0 0.0 1.0 3.0 0.0 0.0 4.0 1.0 0.0 4.0 1.0 1.0 4.0 0.0 1.0 4.0 100 200 300 400 500 600 600 700 800 900 1000 1100 1200 1300 1400 1500 100 200 400 Example of a Triangle Topology 0 1 2 4 5 6 8 9 10 0.0 0.0 0.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 0.0 0.0 0.0 2.0 1.0 0.0 2.0 1.0 1.0 2.0 0.0 1.0 2.0 0.0 0.0 3.0 1.0 0.0 3.0 1.0 1.0 3.0 0.0 1.0 3.0 0.0 0.0 4.0 1.0 0.0 4.0 1.0 1.0 4.0 0.0 1.0 4.0 100 200 300 400 500 600 600 700 800 900 1000 1100 1200 1300 1400 1500 100 200 400 Example of a Quadrilateral Topology 0 1 2 3 4 5 6 7 8 9 10 11 0.0 0.0 0.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 0.0 0.0 0.0 2.0 1.0 0.0 2.0 1.0 1.0 2.0 0.0 1.0 2.0 0.0 0.0 3.0 1.0 0.0 3.0 1.0 1.0 3.0 0.0 1.0 3.0 0.0 0.0 4.0 1.0 0.0 4.0 1.0 1.0 4.0 0.0 1.0 4.0 100 200 300 400 500 600 600 700 800 900 1000 1100 1200 1300 1400 1500 100 200 400 Example of a Tetrahedron Topology 0 1 2 4 4 5 6 11 0.0 0.0 0.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 0.0 0.0 0.0 2.0 1.0 0.0 2.0 1.0 1.0 2.0 0.0 1.0 2.0 0.0 0.0 3.0 1.0 0.0 3.0 1.0 1.0 3.0 0.0 1.0 3.0 0.0 0.0 4.0 1.0 0.0 4.0 1.0 1.0 4.0 0.0 1.0 4.0 100 200 300 400 500 600 600 700 800 900 1000 1100 1200 1300 1400 1500 100 400 Example of a Pyramid Topology 0 1 2 3 4 4 5 6 7 11 0.0 0.0 0.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 0.0 0.0 0.0 2.0 1.0 0.0 2.0 1.0 1.0 2.0 0.0 1.0 2.0 0.0 0.0 3.0 1.0 0.0 3.0 1.0 1.0 3.0 0.0 1.0 3.0 0.0 0.0 4.0 1.0 0.0 4.0 1.0 1.0 4.0 0.0 1.0 4.0 100 200 300 400 500 600 600 700 800 900 1000 1100 1200 1300 1400 1500 100 400 Example of a Wedge Topology 0 1 2 4 5 6 5 6 7 9 10 11 0.0 0.0 0.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 0.0 0.0 0.0 2.0 1.0 0.0 2.0 1.0 1.0 2.0 0.0 1.0 2.0 0.0 0.0 3.0 1.0 0.0 3.0 1.0 1.0 3.0 0.0 1.0 3.0 0.0 0.0 4.0 1.0 0.0 4.0 1.0 1.0 4.0 0.0 1.0 4.0 100 200 300 400 500 600 600 700 800 900 1000 1100 1200 1300 1400 1500 100 400 Example of a Hexahedron Topology 0 1 2 3 4 5 6 7 4 5 6 7 8 9 10 11 0.0 0.0 0.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 0.0 0.0 0.0 2.0 1.0 0.0 2.0 1.0 1.0 2.0 0.0 1.0 2.0 0.0 0.0 3.0 1.0 0.0 3.0 1.0 1.0 3.0 0.0 1.0 3.0 0.0 0.0 4.0 1.0 0.0 4.0 1.0 1.0 4.0 0.0 1.0 4.0 100 200 300 400 500 600 600 700 800 900 1000 1100 1200 1300 1400 1500 100 400 xdmf-3.0+git20160803/Examples/Data/StructuredTopology.xmf0000640000175000017500000001277713003006557023154 0ustar alastairalastair Example of a 3DSMesh Topology 0.0 0.0 3.0 1.0 0.0 3.0 2.0 0.0 3.0 4.0 0.0 3.0 0.0 1.0 3.3 1.0 1.0 3.3 2.0 1.0 3.3 4.0 1.0 3.3 0.0 2.0 3.9 1.0 2.0 3.9 2.0 2.0 3.9 4.0 2.0 3.9 0.0 0.0 1.0 1.0 0.0 1.0 2.0 0.0 1.0 4.0 0.0 1.0 0.0 1.0 1.3 1.0 1.0 1.3 2.0 1.0 1.3 4.0 1.0 1.3 0.0 2.0 1.9 1.0 2.0 1.9 2.0 2.0 1.9 4.0 2.0 1.9 0.0 0.0 0.0 1.0 0.0 0.0 2.0 0.0 0.0 4.0 0.0 0.0 0.0 1.0 0.3 1.0 1.0 0.3 2.0 1.0 0.3 4.0 1.0 0.3 0.0 2.0 0.9 1.0 2.0 0.9 2.0 2.0 0.9 4.0 2.0 0.9 100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000 2100 2200 2300 2400 2500 2600 2700 2800 2900 3000 3100 2900 3300 3400 3500 3600 100 200 300 400 500 600 700 800 900 1000 1100 1200 Example of a 3DRectMesh Topology 0.0 1.0 2.0 4.0 0.0 1.0 3.0 3.0 1.0 0.0 100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000 2100 2200 2300 2400 2500 2600 2700 2800 2900 3000 3100 2900 3300 3400 3500 3600 100 200 300 400 500 600 700 800 900 1000 1100 1200 Example of a 3DCoRectMesh Topology 0.0 0.0 3.0 1.0 1.5 2.0 100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000 2100 2200 2300 2400 2500 2600 2700 2800 2900 3000 3100 2900 3300 3400 3500 3600 100 200 300 400 500 600 700 800 900 1000 1100 1200 xdmf-3.0+git20160803/XdmfAggregate.hpp0000640000175000017500000001423013003006557017310 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfAggregate.hpp */ /* */ /* Author: */ /* Andrew Burns */ /* andrew.j.burns2@us.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2013 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef XDMFAGGREGATE_HPP_ #define XDMFAGGREGATE_HPP_ // C Compatible Includes #include "Xdmf.hpp" #include "XdmfArrayReference.hpp" #ifdef __cplusplus // Forward Declarations class XdmfArray; // Includes #include #include "XdmfItem.hpp" #include "XdmfSharedPtr.hpp" /** * @brief Couples an XdmfArray with heavy data stored in another XdmfArray. * * This class serves to allow an array to retrieve data that is a subsection * of an already existing array. */ class XDMF_EXPORT XdmfAggregate: public XdmfArrayReference { public: /** * Generates an XdmfAggregate object. * * Example of use: * * C++ * * @dontinclude ExampleXdmfAggregate.cpp * @skipline //#initialization * @until //#initialization * * Python * * @dontinclude XdmfExampleAggregate.py * @skipline #//initialization * @until #//initialization * * @return A constructed XdmfAggregate object. */ static shared_ptr New(); virtual ~XdmfAggregate(); LOKI_DEFINE_VISITABLE(XdmfAggregate, XdmfItem) XDMF_CHILDREN(XdmfAggregate, XdmfArray, Array, Name) static const std::string ItemTag; /** * Get the dimensions of the set referenced by this subset. * * Example of use: * * C++ * * @dontinclude ExampleXdmfAggregate.cpp * @skipline //#initialization * @until //#initialization * @skipline //#getDimensions * @until //#getDimensions * * Python * * @dontinclude XdmfExampleAggregate.py * @skipline #//initialization * @until #//initialization * @skipline #//getDimensions * @until #//getDimensions * * @return A vector containing the size in each dimension of the * set referenced by this subset. */ std::vector getDimensions() const; std::map getItemProperties() const; std::string getItemTag() const; /** * Get the size of the set referenced by this subset. * * Example of use: * * C++ * * @dontinclude ExampleXdmfAggregate.cpp * @skipline //#initialization * @until //#initialization * @skipline //#getSize * @until //#getSize * * Python * * @dontinclude XdmfExampleAggregate.py * @skipline #//initialization * @until #//initialization * @skipline #//getSize * @until #//getSize * * @return An int containing the size of the subset. */ unsigned int getSize() const; /** * Read data reference by this subset and return as an XdmfArray. * * Example of use: * * C++ * * @dontinclude ExampleXdmfAggregate.cpp * @skipline //#initialization * @until //#initialization * @skipline //#read * @until //#read * * Python * * @dontinclude XdmfExampleAggregate.py * @skipline #//initialization * @until #//initialization * @skipline #//read * @until #//read * * @return An array filled with data based on the subset's parameters. */ virtual shared_ptr read() const; void traverse(const shared_ptr visitor); XdmfAggregate(XdmfAggregate&); protected: XdmfAggregate(); void populateItem(const std::map & itemProperties, const std::vector > & childItems, const XdmfCoreReader * const reader); private: XdmfAggregate(const XdmfAggregate&); // Not implemented. void operator=(const XdmfAggregate&); // Not implemented. }; #endif #ifdef __cplusplus extern "C" { #endif // C wrappers go here struct XDMFAGGREGATE; // Simply as a typedef to ensure correct typing typedef struct XDMFAGGREGATE XDMFAGGREGATE; XDMF_EXPORT XDMFAGGREGATE * XdmfAggregateNew(); XDMF_EXPORT XDMFARRAY * XdmfAggregateGetArray(XDMFAGGREGATE * aggregate, unsigned int index); XDMF_EXPORT XDMFARRAY * XdmfAggregateGetArrayByName(XDMFAGGREGATE * aggregate, char * name); XDMF_EXPORT unsigned int XdmfAggregateGetNumberArrays(XDMFAGGREGATE * aggregate); XDMF_EXPORT void XdmfAggregateInsertArray(XDMFAGGREGATE * aggregate, XDMFARRAY * array, int transferOwnership); XDMF_EXPORT void XdmfAggregateRemoveArray(XDMFAGGREGATE * aggregate, unsigned int index); XDMF_EXPORT void XdmfAggregateRemoveArrayByName(XDMFAGGREGATE * aggregate, char * name); // C Wrappers for parent classes are generated by macros XDMF_ITEM_C_CHILD_DECLARE(XdmfAggregate, XDMFAGGREGATE, XDMF) XDMF_ARRAYREFERENCE_C_CHILD_DECLARE(XdmfAggregate, XDMFAGGREGATE, XDMF) #ifdef __cplusplus } #endif #endif /* XDMFAGGREGATE_HPP_ */ xdmf-3.0+git20160803/XdmfAttributeType.hpp0000640000175000017500000001212513003006557020230 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfAttributeType.hpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef XDMFATTRIBUTETYPE_HPP_ #define XDMFATTRIBUTETYPE_HPP_ // C Compatible Includes #include "Xdmf.hpp" #ifdef __cplusplus #include "XdmfItemProperty.hpp" /** * @brief Property describing the type of values an XdmfAttribute * contains. * * XdmfAttributeType is a property used by XdmfAttribute to specify * what type of values the XdmfAttribute contains. A specific * XdmfAttributeType can be created by calling one of the static * methods in the class, i.e. XdmfAttributeType::Scalar(). * * Example of use: * * C++ * * @dontinclude ExampleXdmfAttribute.cpp * @skipline //#initialization * @until //#initialization * @skipline //#setType * @until //#setType * @skipline //#getType * @until //#getType * * Python * * @dontinclude XdmfExampleAttribute.py * @skipline #//initialization * @until #//initialization * @skipline #//setType * @until #//setType * @skipline #//getType * @until #//getType * * Xdmf supports the following attribute types: * NoAttributeType * Scalar * Vector * Tensor * Matrix * Tensor6 * GlobalId */ class XDMF_EXPORT XdmfAttributeType : public XdmfItemProperty { public: virtual ~XdmfAttributeType(); friend class XdmfAttribute; // Supported Xdmf Attribute Types static shared_ptr NoAttributeType(); static shared_ptr Scalar(); static shared_ptr Vector(); static shared_ptr Tensor(); static shared_ptr Matrix(); static shared_ptr Tensor6(); static shared_ptr GlobalId(); void getProperties(std::map & collectedProperties) const; protected: /** * Protected constructor for XdmfAttributeType. The constructor is * protected because all attribute types supported by Xdmf should be * accessed through more specific static methods that construct * XdmfAttributeTypes - i.e. XdmfAttributeType::Scalar(). * * @param name The name of the XdmfAttributeType to construct. */ XdmfAttributeType(const std::string & name); static std::map(*)()> mAttributeDefinitions; static void InitTypes(); private: XdmfAttributeType(const XdmfAttributeType &); // Not implemented. void operator=(const XdmfAttributeType &); // Not implemented. static shared_ptr New(const std::map & itemProperties); std::string mName; }; #endif #ifdef __cplusplus extern "C" { #endif // C wrappers go here #define XDMF_ATTRIBUTE_TYPE_SCALAR 200 #define XDMF_ATTRIBUTE_TYPE_VECTOR 201 #define XDMF_ATTRIBUTE_TYPE_TENSOR 202 #define XDMF_ATTRIBUTE_TYPE_MATRIX 203 #define XDMF_ATTRIBUTE_TYPE_TENSOR6 204 #define XDMF_ATTRIBUTE_TYPE_GLOBALID 205 #define XDMF_ATTRIBUTE_TYPE_NOTYPE 206 XDMF_EXPORT int XdmfAttributeTypeScalar(); XDMF_EXPORT int XdmfAttributeTypeVector(); XDMF_EXPORT int XdmfAttributeTypeTensor(); XDMF_EXPORT int XdmfAttributeTypeMatrix(); XDMF_EXPORT int XdmfAttributeTypeTensor6(); XDMF_EXPORT int XdmfAttributeTypeGlobalId(); XDMF_EXPORT int XdmfAttributeTypeNoAttributeType(); #ifdef __cplusplus } #endif #endif /* XDMFATTRIBUTETYPE_HPP_ */ xdmf-3.0+git20160803/Xdmf.dtd0000640000175000017500000000632513003006557015473 0ustar alastairalastair xdmf-3.0+git20160803/XdmfSet.hpp0000640000175000017500000001543013003006557016160 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfSet.hpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef XDMFSET_HPP_ #define XDMFSET_HPP_ // C Compatible Includes #include "Xdmf.hpp" #include "XdmfArray.hpp" #include "XdmfAttribute.hpp" #include "XdmfSetType.hpp" #ifdef __cplusplus // Forward Declarations class XdmfAttribute; class XdmfHDF5Controller; /** * @brief Holds a collection of individual nodes, cells, faces, or * edges that are part of an XdmfGrid. * * An XdmfSet holds a collection of nodes, cells, faces, or edges that * are part of an XdmfGrid. For instance, a simulation may want to * hold a set of nodes on a boundary. The individual elements making * up the set are determined by their id. An XdmfSet can have * XdmfAttributes attached that contain extra values attached to the * elements in the set. */ class XDMF_EXPORT XdmfSet : public XdmfArray { public: /** * Create a new XdmfSet. * * Example of use: * * C++ * * @dontinclude ExampleXdmfSet.cpp * @skipline //#initialize * @until //#initialize * * Python * * @dontinclude XdmfExampleSet.py * @skipline #//initialize * @until #//initialize * * @return Constructed XdmfSet. */ static shared_ptr New(); virtual ~XdmfSet(); LOKI_DEFINE_VISITABLE(XdmfSet, XdmfArray) XDMF_CHILDREN(XdmfSet, XdmfAttribute, Attribute, Name) static const std::string ItemTag; std::map getItemProperties() const; std::string getItemTag() const; /** * Get the name of the set. * * Example of use: * * C++ * * @dontinclude ExampleXdmfSet.cpp * @skipline //#initialize * @until //#initialize * @skipline //#setName * @until //#setName * @skipline //#getName * @until //#getName * * Python * * @dontinclude XdmfExampleSet.py * @skipline #//initialize * @until #//initialize * @skipline #//setName * @until #//setName * @skipline #//getName * @until #//getName * * @return A string containing the name of the set. */ std::string getName() const; /** * Get the XdmfSetType associated with this set. * * Example of use: * * C++ * * @dontinclude ExampleXdmfSet.cpp * @skipline //#initialize * @until //#initialize * @skipline //#setType * @until //#setType * @skipline //#getType * @until //#getType * * Python * * @dontinclude XdmfExampleSet.py * @skipline #//initialize * @until #//initialize * @skipline #//setType * @until #//setType * @skipline #//getType * @until #//getType * * @return XdmfSetType of this set. */ shared_ptr getType() const; using XdmfArray::insert; #if defined(SWIG) using XdmfItem::insert; #endif /** * Set the name of the set. * * Example of use: * * C++ * * @dontinclude ExampleXdmfSet.cpp * @skipline //#initialize * @until //#initialize * @skipline //#setName * @until //#setName * * Python * * @dontinclude XdmfExampleSet.py * @skipline #//initialize * @until #//initialize * @skipline #//setName * @until #//setName * * @param name A string containing the name to set. */ void setName(const std::string & name); /** * Set the XdmfSetType associated with this set. * * Example of use: * * C++ * * @dontinclude ExampleXdmfSet.cpp * @skipline //#initialize * @until //#initialize * @skipline //#setType * @until //#setType * * Python * * @dontinclude XdmfExampleSet.py * @skipline //#initialize * @until //#initialize * @skipline //#setType * @until //#setType * * @param type The XdmfSetType to set. */ void setType(const shared_ptr type); void traverse(const shared_ptr visitor); XdmfSet(XdmfSet &); protected: XdmfSet(); virtual void populateItem(const std::map & itemProperties, const std::vector > & childItems, const XdmfCoreReader * const reader); private: XdmfSet(const XdmfSet &); void operator=(const XdmfSet &); // Not implemented. std::string mName; shared_ptr mType; }; #endif #ifdef __cplusplus extern "C" { #endif // C wrappers go here struct XDMFSET; // Simply as a typedef to ensure correct typing typedef struct XDMFSET XDMFSET; XDMF_EXPORT XDMFSET * XdmfSetNew(); XDMF_EXPORT XDMFATTRIBUTE * XdmfSetGetAttribute(XDMFSET * set, unsigned int index); XDMF_EXPORT XDMFATTRIBUTE * XdmfSetGetAttributeByName(XDMFSET * set, char * Name); XDMF_EXPORT unsigned int XdmfSetGetNumberAttributes(XDMFSET * set); XDMF_EXPORT int XdmfSetGetType(XDMFSET * set); XDMF_EXPORT void XdmfSetInsertAttribute(XDMFSET * set, XDMFATTRIBUTE * Attribute, int passControl); XDMF_EXPORT void XdmfSetRemoveAttribute(XDMFSET * set, unsigned int index); XDMF_EXPORT void XdmfSetRemoveAttributeByName(XDMFSET * set, char * Name); XDMF_EXPORT void XdmfSetSetType(XDMFSET * set, int type, int * status); XDMF_ITEM_C_CHILD_DECLARE(XdmfSet, XDMFSET, XDMF) XDMF_ARRAY_C_CHILD_DECLARE(XdmfSet, XDMFSET, XDMF) #ifdef __cplusplus } #endif #endif /* XDMFSET_HPP_ */ xdmf-3.0+git20160803/XdmfGraph.cpp0000640000175000017500000001260313003006557016460 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfGraph.cpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #include "XdmfAttribute.hpp" #include "XdmfGraph.hpp" XDMF_CHILDREN_IMPLEMENTATION(XdmfGraph, XdmfAttribute, Attribute, Name) shared_ptr XdmfGraph::New(const unsigned int numberNodes) { shared_ptr p(new XdmfGraph(numberNodes)); return p; } XdmfGraph::XdmfGraph(const unsigned int numberNodes) : XdmfSparseMatrix(numberNodes, numberNodes), mTime(shared_ptr()) { } XdmfGraph::XdmfGraph(XdmfGraph & refGraph) : XdmfSparseMatrix(refGraph), mAttributes(refGraph.mAttributes), mTime(refGraph.mTime) { } XdmfGraph::~XdmfGraph() { } const std::string XdmfGraph::ItemTag = "Graph"; std::string XdmfGraph::getItemTag() const { return ItemTag; } shared_ptr XdmfGraph::getTime() { return boost::const_pointer_cast (static_cast(*this).getTime()); } shared_ptr XdmfGraph::getTime() const { return mTime; } unsigned int XdmfGraph::getNumberNodes() const { // The number of nodes is equal to the number of rows or columns. Either will work. return this->getNumberRows(); } void XdmfGraph::populateItem(const std::map & itemProperties, const std::vector > & childItems, const XdmfCoreReader * const reader) { XdmfSparseMatrix::populateItem(itemProperties, childItems, reader); for(std::vector >::const_iterator iter = childItems.begin(); iter != childItems.end(); ++iter) { if(shared_ptr attribute = shared_dynamic_cast(*iter)) { this->insert(attribute); } } } void XdmfGraph::setTime(const shared_ptr time) { mTime = time; this->setIsChanged(true); } void XdmfGraph::traverse(const shared_ptr visitor) { XdmfSparseMatrix::traverse(visitor); for (unsigned int i = 0; i < mAttributes.size(); ++i) { mAttributes[i]->accept(visitor); } } // C Wrappers XDMFGRAPH * XdmfGraphNew(unsigned int numberNodes) { try { shared_ptr generatedGraph = XdmfGraph::New(numberNodes); return (XDMFGRAPH *)((void *)(new XdmfGraph(*generatedGraph.get()))); } catch (...) { shared_ptr generatedGraph = XdmfGraph::New(numberNodes); return (XDMFGRAPH *)((void *)(new XdmfGraph(*generatedGraph.get()))); } } XDMFATTRIBUTE * XdmfGraphGetAttribute(XDMFGRAPH * graph, unsigned int index) { return (XDMFATTRIBUTE *)((void *)(((XdmfGraph *)(graph))->getAttribute(index).get())); } XDMFATTRIBUTE * XdmfGraphGetAttributeByName(XDMFGRAPH * graph, char * Name) { return (XDMFATTRIBUTE *)((void *)(((XdmfGraph *)(graph))->getAttribute(std::string(Name)).get())); } unsigned int XdmfGraphGetNumberAttributes(XDMFGRAPH * graph) { return ((XdmfGraph *)graph)->getNumberAttributes(); } void XdmfGraphInsertAttribute(XDMFGRAPH * graph, XDMFATTRIBUTE * Attribute, int passControl) { if (passControl) { ((XdmfGraph *)(graph))->insert(shared_ptr((XdmfAttribute *)Attribute)); } else { ((XdmfGraph *)(graph))->insert(shared_ptr((XdmfAttribute *)Attribute, XdmfNullDeleter())); } } void XdmfGraphRemoveAttribute(XDMFGRAPH * graph, unsigned int index) { ((XdmfGraph *)graph)->removeAttribute(index); } void XdmfGraphRemoveAttributeByName(XDMFGRAPH * graph, char * Name) { ((XdmfGraph *)graph)->removeAttribute(std::string(Name)); } unsigned int XdmfGraphGetNumberNodes(XDMFGRAPH * graph) { return ((XdmfGraph *)graph)->getNumberNodes(); } XDMF_ITEM_C_CHILD_WRAPPER(XdmfGraph, XDMFGRAPH) XDMF_SPARSEMATRIX_C_CHILD_WRAPPER(XdmfGraph, XDMFGRAPH) xdmf-3.0+git20160803/XdmfTime.hpp0000640000175000017500000001113513003006557016321 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfTime.hpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef XDMFTIME_HPP_ #define XDMFTIME_HPP_ // C Compatible Includes #include "Xdmf.hpp" #include "XdmfItem.hpp" #ifdef __cplusplus /** * @brief Time specification for an XdmfGrid. * * An XdmfTime sets a time value for an XdmfGrid. */ class XDMF_EXPORT XdmfTime : public XdmfItem { public: /** * Create a new XdmfTime. * * Example of use: * * C++ * * @dontinclude ExampleXdmfTime.cpp * @skipline //#initialization * @until //#initialization * * Python * * @dontinclude XdmfExampleTime.py * @skipline #//initialization * @until #//initialization * * @param value The timeValue of the XdmfTime to create. * @return The new XdmfTime. */ static shared_ptr New(const double & value = 0); virtual ~XdmfTime(); LOKI_DEFINE_VISITABLE(XdmfTime, XdmfItem) static const std::string ItemTag; std::map getItemProperties() const; std::string getItemTag() const; /** * Get the time value associated with this XdmfTime. * * Example of use: * * C++ * * @dontinclude ExampleXdmfTime.cpp * @skipline //#initialization * @until //#initialization * @skipline //#getValue * @until //#getValue * * Python * * @dontinclude XdmfExampleTime.py * @skipline #//initialization * @until #//initialization * @skipline #//getValue * @until #//getValue * * @return A double containing the time value. */ double getValue() const; /** * Set the time value associated with this XdmfTime. * * Example of use: * * C++ * * @dontinclude ExampleXdmfTime.cpp * @skipline //#initialization * @until //#initialization * @skipline //#setValue * @until //#setValue * * Python * * @dontinclude XdmfExampleTime.py * @skipline #//initialization * @until #//initialization * @skipline #//setValue * @until #//setValue * * @param time A double containing the time value. */ void setValue(const double & time); XdmfTime(XdmfTime &); protected: XdmfTime(const double & value); virtual void populateItem(const std::map & itemProperties, const std::vector > & childItems, const XdmfCoreReader * const reader); private: XdmfTime(const XdmfTime &); // Not implemented. void operator=(const XdmfTime &); // Not implemented. double mValue; }; #endif #ifdef __cplusplus extern "C" { #endif // C wrappers go here struct XDMFTIME; // Simply as a typedef to ensure correct typing typedef struct XDMFTIME XDMFTIME; XDMF_EXPORT XDMFTIME * XdmfTimeNew(double value); XDMF_EXPORT double XdmfTimeGetValue(XDMFTIME * timePointer); XDMF_EXPORT void XdmfTimeSetValue(XDMFTIME * timePointer, double time); XDMF_ITEM_C_CHILD_DECLARE(XdmfTime, XDMFTIME, XDMF) #ifdef __cplusplus } #endif #endif /* XDMFTIME_HPP_ */ xdmf-3.0+git20160803/core/0000740000175000017500000000000013003006557015020 5ustar alastairalastairxdmf-3.0+git20160803/core/XdmfBinaryController.cpp0000640000175000017500000003440613003006557021644 0ustar alastairalastair/*****************************************************************************/ /* Xdmf */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfBinaryController.cpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #include #include #include "XdmfArray.hpp" #include "XdmfArrayType.hpp" #include "XdmfBinaryController.hpp" #include "XdmfError.hpp" namespace { template struct ByteSwaper { static inline void swap(void * p){} static inline void swap(void * p, unsigned int length) { char * data = static_cast(p); for(unsigned int i=0; i::swap(data); } } }; template<> void ByteSwaper<2>::swap(void * p){ char one_byte; char* data = static_cast(p); one_byte = data[0]; data[0] = data[1]; data[1] = one_byte; } template<> void ByteSwaper<4>::swap(void * p){ char one_byte; char* data = static_cast(p); one_byte = data[0]; data[0] = data[3]; data[3] = one_byte; one_byte = data[1]; data[1] = data[2]; data[2] = one_byte; } template<> void ByteSwaper<8>::swap(void * p){ char one_byte; char* data = static_cast(p); one_byte = data[0]; data[0] = data[7]; data[7] = one_byte; one_byte = data[1]; data[1] = data[6]; data[6] = one_byte; one_byte = data[2]; data[2] = data[5]; data[5] = one_byte; one_byte = data[3]; data[3] = data[4]; data[4] = one_byte; } } shared_ptr XdmfBinaryController::New(const std::string & filePath, const shared_ptr & type, const Endian & endian, const unsigned int seek, const std::vector & dimensions) { shared_ptr p(new XdmfBinaryController(filePath, type, endian, seek, std::vector(dimensions.size(), 0), std::vector(dimensions.size(), 1), dimensions, dimensions)); return p; } shared_ptr XdmfBinaryController::New(const std::string & filePath, const shared_ptr & type, const Endian & endian, const unsigned int seek, const std::vector & starts, const std::vector & strides, const std::vector & dimensions, const std::vector & dataspaces) { shared_ptr p(new XdmfBinaryController(filePath, type, endian, seek, starts, strides, dimensions, dataspaces)); return p; } XdmfBinaryController::XdmfBinaryController(const std::string & filePath, const shared_ptr & type, const Endian & endian, const unsigned int seek, const std::vector & starts, const std::vector & strides, const std::vector & dimensions, const std::vector & dataspaces) : XdmfHeavyDataController(filePath, type, starts, strides, dimensions, dataspaces), mEndian(endian), mSeek(seek) { } XdmfBinaryController::XdmfBinaryController(const XdmfBinaryController & refController): XdmfHeavyDataController(refController), mEndian(refController.mEndian), mSeek(refController.mSeek) { } XdmfBinaryController::~XdmfBinaryController() { } std::string XdmfBinaryController::getDataspaceDescription() const { std::stringstream descstream; descstream << mSeek << ":" << XdmfHeavyDataController::getDataspaceDescription(); return descstream.str(); } XdmfBinaryController::Endian XdmfBinaryController::getEndian() const { return mEndian; } std::string XdmfBinaryController::getName() const { return "Binary"; } void XdmfBinaryController::getProperties(std::map & collectedProperties) const { collectedProperties["Format"] = this->getName(); if(mEndian == BIG) { collectedProperties["Endian"] = "Big"; } else if(mEndian == LITTLE) { collectedProperties["Endian"] = "Little"; } } unsigned int XdmfBinaryController::getSeek() const { return mSeek; } void XdmfBinaryController::read(XdmfArray * const array) { array->initialize(mType, mDimensions); shared_ptr dataspaceArray = XdmfArray::New(); dataspaceArray->initialize(mType, mDataspaceDimensions); std::ifstream fileStream(mFilePath.c_str(), std::ifstream::binary); if(!fileStream.good()) { XdmfError::message(XdmfError::FATAL, "Error reading " + mFilePath + " in XdmfBinaryController::read"); } fileStream.seekg(mSeek); if(!fileStream.good()) { XdmfError::message(XdmfError::FATAL, "Error seeking " + mFilePath + " in XdmfBinaryController::read"); } fileStream.read(static_cast(dataspaceArray->getValuesInternal()), dataspaceArray->getSize() * mType->getElementSize()); #if defined(XDMF_BIG_ENDIAN) const bool needByteSwap = mEndian == LITTLE; #else const bool needByteSwap = mEndian == BIG; #endif // XDMF_BIG_ENDIAN if(needByteSwap) { switch(mType->getElementSize()){ case 1: break; case 2: ByteSwaper<2>::swap(dataspaceArray->getValuesInternal(), dataspaceArray->getSize()); break; case 4: ByteSwaper<4>::swap(dataspaceArray->getValuesInternal(), dataspaceArray->getSize()); break; case 8: ByteSwaper<8>::swap(dataspaceArray->getValuesInternal(), dataspaceArray->getSize()); break; default: XdmfError::message(XdmfError::FATAL, "Cannot perform endianness swap for datatype"); break; } } array->insert(std::vector(mDimensions.size(), 0), dataspaceArray, mStart, mDataspaceDimensions, mDimensions, std::vector(mDimensions.size(), 1), mStride); } // C Wrappers XDMFBINARYCONTROLLER * XdmfBinaryControllerNew(char * filePath, int type, int endian, unsigned int seek, unsigned int * dimensions, unsigned int numDims, int * status) { XDMF_ERROR_WRAP_START(status) std::vector dimVector(dimensions, dimensions + numDims); shared_ptr buildType = shared_ptr(); switch (type) { case XDMF_ARRAY_TYPE_UINT8: buildType = XdmfArrayType::UInt8(); break; case XDMF_ARRAY_TYPE_UINT16: buildType = XdmfArrayType::UInt16(); break; case XDMF_ARRAY_TYPE_UINT32: buildType = XdmfArrayType::UInt32(); break; case XDMF_ARRAY_TYPE_INT8: buildType = XdmfArrayType::Int8(); break; case XDMF_ARRAY_TYPE_INT16: buildType = XdmfArrayType::Int16(); break; case XDMF_ARRAY_TYPE_INT32: buildType = XdmfArrayType::Int32(); break; case XDMF_ARRAY_TYPE_INT64: buildType = XdmfArrayType::Int64(); break; case XDMF_ARRAY_TYPE_FLOAT32: buildType = XdmfArrayType::Float32(); break; case XDMF_ARRAY_TYPE_FLOAT64: buildType = XdmfArrayType::Float64(); break; default: XdmfError::message(XdmfError::FATAL, "Error: Invalid ArrayType."); break; } XdmfBinaryController::Endian buildEndian = XdmfBinaryController::NATIVE; printf("switch endian = %u\n", endian); switch (endian) { case XDMF_BINARY_CONTROLLER_ENDIAN_BIG: buildEndian = XdmfBinaryController::BIG; break; case XDMF_BINARY_CONTROLLER_ENDIAN_LITTLE: buildEndian = XdmfBinaryController::LITTLE; break; case XDMF_BINARY_CONTROLLER_ENDIAN_NATIVE: buildEndian = XdmfBinaryController::NATIVE; break; default: XdmfError::message(XdmfError::FATAL, "Error: Invalid Endian."); break; } shared_ptr generatedController = XdmfBinaryController::New(std::string(filePath), buildType, buildEndian, seek, dimVector); return (XDMFBINARYCONTROLLER *)((void *)(new XdmfBinaryController(*generatedController.get()))); XDMF_ERROR_WRAP_END(status) return NULL; } XDMFBINARYCONTROLLER * XdmfBinaryControllerNewHyperslab(char * filePath, int type, int endian, unsigned int seek, unsigned int * start, unsigned int * stride, unsigned int * dimensions, unsigned int * dataspaceDimensions, unsigned int numDims, int * status) { XDMF_ERROR_WRAP_START(status) std::vector startVector(start, start + numDims); std::vector strideVector(stride, stride + numDims); std::vector dimVector(dimensions, dimensions + numDims); std::vector dataspaceVector(dataspaceDimensions, dataspaceDimensions + numDims); shared_ptr buildType = shared_ptr(); switch (type) { case XDMF_ARRAY_TYPE_UINT8: buildType = XdmfArrayType::UInt8(); break; case XDMF_ARRAY_TYPE_UINT16: buildType = XdmfArrayType::UInt16(); break; case XDMF_ARRAY_TYPE_UINT32: buildType = XdmfArrayType::UInt32(); break; case XDMF_ARRAY_TYPE_INT8: buildType = XdmfArrayType::Int8(); break; case XDMF_ARRAY_TYPE_INT16: buildType = XdmfArrayType::Int16(); break; case XDMF_ARRAY_TYPE_INT32: buildType = XdmfArrayType::Int32(); break; case XDMF_ARRAY_TYPE_INT64: buildType = XdmfArrayType::Int64(); break; case XDMF_ARRAY_TYPE_FLOAT32: buildType = XdmfArrayType::Float32(); break; case XDMF_ARRAY_TYPE_FLOAT64: buildType = XdmfArrayType::Float64(); break; default: XdmfError::message(XdmfError::FATAL, "Error: Invalid ArrayType."); break; } XdmfBinaryController::Endian buildEndian = XdmfBinaryController::NATIVE; switch (endian) { case XDMF_BINARY_CONTROLLER_ENDIAN_BIG: buildEndian = XdmfBinaryController::BIG; break; case XDMF_BINARY_CONTROLLER_ENDIAN_LITTLE: buildEndian = XdmfBinaryController::LITTLE; break; case XDMF_BINARY_CONTROLLER_ENDIAN_NATIVE: buildEndian = XdmfBinaryController::NATIVE; break; default: XdmfError::message(XdmfError::FATAL, "Error: Invalid Endian."); break; } shared_ptr generatedController = XdmfBinaryController::New(std::string(filePath), buildType, buildEndian, seek, startVector, strideVector, dimVector, dataspaceVector); return (XDMFBINARYCONTROLLER *)((void *)(new XdmfBinaryController(*generatedController.get()))); XDMF_ERROR_WRAP_END(status) return NULL; } int XdmfBinaryControllerGetEndian(XDMFBINARYCONTROLLER * controller) { return ((XdmfBinaryController *)(controller))->getEndian(); } unsigned int XdmfBinaryControllerGetSeek(XDMFBINARYCONTROLLER * controller) { return ((XdmfBinaryController *)(controller))->getSeek(); } // C Wrappers for parent classes are generated by macros XDMF_HEAVYCONTROLLER_C_CHILD_WRAPPER(XdmfBinaryController, XDMFBINARYCONTROLLER) xdmf-3.0+git20160803/core/XdmfCoreReader.cpp0000640000175000017500000003412213003006557020362 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfCoreReader.cpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #include #include #include #include #include #include #include #include #include #include "XdmfArray.hpp" #include "XdmfArrayType.hpp" #include "XdmfCoreItemFactory.hpp" #include "XdmfCoreReader.hpp" #include "XdmfError.hpp" #include "XdmfFunction.hpp" #include "XdmfSubset.hpp" #include "XdmfItem.hpp" #include "XdmfSystemUtils.hpp" /** * PIMPL */ class XdmfCoreReader::XdmfCoreReaderImpl { public: XdmfCoreReaderImpl(const shared_ptr itemFactory, const XdmfCoreReader * const coreReader) : mCoreReader(coreReader), mItemFactory(itemFactory) { }; ~XdmfCoreReaderImpl() { }; void closeFile() { mXPathMap.clear(); xmlXPathFreeContext(mXPathContext); for(std::map::const_iterator iter = mDocuments.begin(); iter != mDocuments.end(); ++iter) { xmlFreeDoc(iter->second); } mDocuments.clear(); xmlCleanupParser(); } void openFile(const std::string & filePath) { mXMLDir = XdmfSystemUtils::getRealPath(filePath); size_t index = mXMLDir.find_last_of("/\\"); if(index != std::string::npos) { mXMLDir = mXMLDir.substr(0, index + 1); } mDocument = xmlReadFile(filePath.c_str(), NULL, XML_PARSE_NOENT); if(mDocument == NULL) { XdmfError::message(XdmfError::FATAL, "xmlReadFile could not read " + filePath + " in XdmfCoreReader::XdmfCoreReaderImpl::openFile"); } mDocuments.insert(std::make_pair((char*)mDocument->URL, mDocument)); mXPathContext = xmlXPtrNewContext(mDocument, NULL, NULL); mXPathMap.clear(); } void parse(const std::string & lightData) { mDocument = xmlParseDoc((const xmlChar*)lightData.c_str()); if(mDocument == NULL) { XdmfError::message(XdmfError::FATAL, "xmlReadFile could not parse passed light data string" " in XdmfCoreReader::XdmfCoreReaderImpl::parse"); } //mDocuments.insert(std::make_pair((char*)mDocument->URL, mDocument)); mXPathContext = xmlXPtrNewContext(mDocument, NULL, NULL); mXPathMap.clear(); } /** * Constructs XdmfItems for all nodes in currNode's tree. * XdmfItems are constructed by recursively calling this function for all * children of currNode. */ std::vector > read(xmlNodePtr currNode) { std::vector > myItems; while(currNode != NULL) { if(currNode->type == XML_ELEMENT_NODE) { // Normal reading this->readSingleNode(currNode, myItems); } currNode = currNode->next; } return myItems; } /** * Reads a single xmlNode into an XdmfItem object in memory. The constructed * XdmfItem is added to myItems and an entry is added mapping the xmlNodePtr * to the new XdmfItem in the mXPathMap. */ void readSingleNode(const xmlNodePtr currNode, std::vector > & myItems) { // Deal with proper resolution of XIncludes if(xmlStrcmp(currNode->name, (xmlChar*)"include") == 0) { xmlChar * xpointer = NULL; xmlChar * href = NULL; xmlAttrPtr currAttribute = currNode->properties; while(currAttribute != NULL) { if(xmlStrcmp(currAttribute->name, (xmlChar*)"xpointer") == 0) { xpointer = currAttribute->children->content; } if(xmlStrcmp(currAttribute->name, (xmlChar*)"href") == 0) { href = currAttribute->children->content; } currAttribute = currAttribute->next; } xmlXPathContextPtr oldContext = mXPathContext; if(href) { xmlDocPtr document; xmlChar * filePath = xmlBuildURI(href, mDocument->URL); std::map::const_iterator iter = mDocuments.find((char*)filePath); if(iter == mDocuments.end()) { document = xmlReadFile((char*)filePath, NULL, 0); mDocuments.insert(std::make_pair((char*)document->URL, document)); } else { document = iter->second; } mXPathContext = xmlXPtrNewContext(document, NULL, NULL); } if(xpointer) { xmlXPathObjectPtr result = xmlXPtrEval(xpointer, mXPathContext); if(result && !xmlXPathNodeSetIsEmpty(result->nodesetval)) { for(int i=0; inodesetval->nodeNr; ++i) { this->readSingleNode(result->nodesetval->nodeTab[i], myItems); } } else { XdmfError::message(XdmfError::FATAL, "Invalid xpointer encountered."); } xmlXPathFreeObject(result); } if(href) { xmlXPathFreeContext(mXPathContext); } mXPathContext = oldContext; } else { // Check to see if the node is already in the XPath Map (seen previously) std::map >::const_iterator iter = mXPathMap.find(currNode); // If it is grab it from the previously stored items if(iter != mXPathMap.end()) { myItems.push_back(iter->second); } else { // Otherwise, generate a new XdmfItem from the node std::map itemProperties; xmlNodePtr childNode = currNode->children; // generate content if an array or arrayReference if (mItemFactory->isArrayTag((char *)currNode->name)) { while(childNode != NULL) { if(childNode->type == XML_TEXT_NODE && childNode->content) { #if 1 //ARL's side const char * content = (char*)childNode->content; // Determine if content is whitespace bool whitespace = true; const char * contentPtr = content; // Step through to end of pointer while(contentPtr != NULL) { // If not a whitespace character, break if(!isspace(*contentPtr++)) { whitespace = false; break; } } if(!whitespace) { std::string contentString(content); boost::algorithm::trim(contentString); itemProperties.insert(std::make_pair("Content", contentString)); itemProperties.insert(std::make_pair("XMLDir", mXMLDir)); break; } #else //VTK's side, breaks XDMF's tests, revisit if problematic in VTK std::string content((char *)childNode->content); boost::algorithm::trim(content); if(content.size() != 0) { itemProperties.insert(std::make_pair("Content", content)); itemProperties.insert(std::make_pair("XMLDir", mXMLDir)); break; } #endif } childNode = childNode->next; } } // Pull attributes from node xmlAttrPtr currAttribute = currNode->properties; while(currAttribute != NULL) { itemProperties.insert(std::make_pair((char *)currAttribute->name, (char *)currAttribute->children->content)); currAttribute = currAttribute->next; } // Build XdmfItem const std::vector > childItems = this->read(currNode->children); shared_ptr newItem = mItemFactory->createItem((const char *)currNode->name, itemProperties, childItems); if(newItem == NULL) { XdmfError::message(XdmfError::FATAL, "mItemFactory failed to createItem in " "XdmfCoreReader::XdmfCoreReaderImpl::readSingleNode"); } // Populate built XdmfItem newItem->populateItem(itemProperties, childItems, mCoreReader); myItems.push_back(newItem); mXPathMap.insert(std::make_pair(currNode, newItem)); } } } void readPathObjects(const std::string & xPath, std::vector > & myItems) { xmlXPathObjectPtr xPathObject = xmlXPathEvalExpression((xmlChar*)xPath.c_str(), mXPathContext); if(xPathObject && xPathObject->nodesetval) { for(int i=0; inodesetval->nodeNr; ++i) { this->readSingleNode(xPathObject->nodesetval->nodeTab[i], myItems); } } xmlXPathFreeObject(xPathObject); } xmlDocPtr mDocument; std::map mDocuments; const XdmfCoreReader * const mCoreReader; const shared_ptr mItemFactory; std::string mXMLDir; xmlXPathContextPtr mXPathContext; std::map > mXPathMap; }; XdmfCoreReader::XdmfCoreReader(const shared_ptr itemFactory) : mImpl(new XdmfCoreReaderImpl(itemFactory, this)) { } XdmfCoreReader::~XdmfCoreReader() { delete mImpl; } XdmfItem * XdmfCoreReader::DuplicatePointer(shared_ptr original) const { if (mImpl == NULL) { XdmfError::message(XdmfError::FATAL, "Error: Reader Internal Object is NULL"); } return mImpl->mItemFactory->DuplicatePointer(original); } std::vector > XdmfCoreReader::generateHeavyDataControllers(std::map controllerProperties, const std::vector & passedDimensions, shared_ptr passedArrayType, const std::string & passedFormat) const { return mImpl->mItemFactory->generateHeavyDataControllers(controllerProperties, passedDimensions, passedArrayType, passedFormat); } shared_ptr XdmfCoreReader::generateHeavyDataWriter(std::string typeName, std::string path) const { return mImpl->mItemFactory->generateHeavyDataWriter(typeName, path); } shared_ptr XdmfCoreReader::parse(const std::string & lightData) const { mImpl->parse(lightData); const xmlNodePtr currNode = xmlDocGetRootElement(mImpl->mDocument); std::vector > toReturn; if(mImpl->mItemFactory->createItem((const char*)currNode->name, std::map(), std::vector >()) == NULL) { toReturn = mImpl->read(currNode->children); } else { toReturn = mImpl->read(currNode); } mImpl->closeFile(); return(toReturn[0]); } std::vector > XdmfCoreReader::readItems(const std::string & filePath) const { mImpl->openFile(filePath); const xmlNodePtr currNode = xmlDocGetRootElement(mImpl->mDocument); const std::vector > toReturn = mImpl->read(currNode->children); mImpl->closeFile(); return toReturn; } shared_ptr XdmfCoreReader::read(const std::string & filePath) const { const std::vector > toReturn = readItems(filePath); if (toReturn.size() == 0) { return(shared_ptr()); } return(toReturn[0]); } std::vector > XdmfCoreReader::read(const std::string & filePath, const std::string & xPath) const { mImpl->openFile(filePath); std::vector > toReturn = this->readPathObjects(xPath); mImpl->closeFile(); return toReturn; } std::vector > XdmfCoreReader::readPathObjects(const std::string & xPath) const { std::vector > toReturn; mImpl->readPathObjects(xPath, toReturn); return toReturn; } // C Wrappers XDMFITEM * XdmfCoreReaderRead(XDMFCOREREADER * reader, char * filePath, int * status) { XDMF_ERROR_WRAP_START(status) shared_ptr returnItem = ((XdmfCoreReader *)reader)->read(filePath); return (XDMFITEM *)((void *)((XdmfItem *)((XdmfCoreReader *)reader)->DuplicatePointer(returnItem))); XDMF_ERROR_WRAP_END(status) return NULL; } xdmf-3.0+git20160803/core/XdmfArrayReference.hpp0000640000175000017500000002376713003006557021266 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfArrayReference.hpp */ /* */ /* Author: */ /* Andrew Burns */ /* andrew.j.burns2@us.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2013 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef XDMFARRAYREFERENCE_HPP_ #define XDMFARRAYREFERENCE_HPP_ // C Compatible Includes #include "XdmfCore.hpp" #include "XdmfArray.hpp" #include "XdmfItem.hpp" #ifdef __cplusplus class XdmfArray; /** * @brief Serves as a link between an array and one or more arrays containing data it pulls from. * * The Array Reference class provides the basic framework for the writing and * reading of the Function and Subset classes by allowing properties and tags * to be migrated to them. */ class XDMFCORE_EXPORT XdmfArrayReference : public XdmfItem { public: virtual ~XdmfArrayReference(); LOKI_DEFINE_VISITABLE(XdmfArrayReference, XdmfItem) /** * Gets the properties of the array that the reference will generate when read from file. * * Example of use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#initexpression * @until //#initexpression * @skipline //#setConstructedProperties * @until //#setConstructedProperties * @skipline //#getConstructedProperties * @until //#getConstructedProperties * * Python * * @dontinclude XdmfExampleFunction.py * @skipline #//initexpression * @until #//initexpression * @skipline #//setConstructedProperties * @until #//setConstructedProperties * @skipline #//getConstructedProperties * @until #//getConstructedProperties * * @return The properties of the array to be generated */ std::map getConstructedProperties(); /** * Gets the type of array that the reference will generate when read from file. * * Example of use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#initexpression * @until //#initexpression * @skipline //#setConstructedType * @until //#setConstructedType * @skipline //#getConstructedType * @until //#getConstructedType * * Python * * @dontinclude XdmfExampleFunction.py * @skipline #//initexpression * @until #//initexpression * @skipline #//setConstructedType * @until #//setConstructedType * @skipline #//getConstructedType * @until #//getConstructedType * * @return The tag of the type to be generated */ std::string getConstructedType() const; virtual std::map getItemProperties() const; /** * Parses the reference and generates an array containing the values that * the reference produces. * * Example of use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#initexpression * @until //#initexpression * @skipline //#read * @until //#read * * Python * * @dontinclude XdmfExampleFunction.py * @skipline #//initexpression * @until #//initexpression * @skipline #//read * @until #//read * * @return The array generated by the reference */ virtual shared_ptr read() const = 0; /** * Sets the properties of array that the reference will generate when read from file. * * Example of use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#initexpression * @until //#initexpression * @skipline //#setConstructedProperties * @until //#setConstructedProperties * * Python * * @dontinclude XdmfExampleFunction.py * @skipline #//initexpression * @until #//initexpression * @skipline #//setConstructedProperties * @until #//setConstructedProperties * * @param newProperties The properties of the array to be generated */ void setConstructedProperties(std::map newProperties); /** * Sets the type of array that the reference will generate when read from file. * * Example of use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#initexpression * @until //#initexpression * @skipline //#setConstructedType * @until //#setConstructedType * * Python * * @dontinclude XdmfExampleFunction.py * @skipline #//initexpression * @until #//initexpression * @skipline #//setConstructedType * @until #//setConstructedType * * @param newType The tag of the type to be generated */ void setConstructedType(std::string newType); XdmfArrayReference(XdmfArrayReference &); protected: XdmfArrayReference(); std::string mConstructedType; std::map mConstructedProperties; private: XdmfArrayReference(const XdmfArrayReference &); // Not implemented. void operator=(const XdmfArrayReference &); // Not implemented. }; #endif #ifdef __cplusplus extern "C" { #endif // C wrappers go here struct XDMFARRAYREFERENCE; // Simply as a typedef to ensure correct typing typedef struct XDMFARRAYREFERENCE XDMFARRAYREFERENCE; XDMFCORE_EXPORT char * XdmfArrayReferenceGetConstructedType(XDMFARRAYREFERENCE * arrayReference); XDMFCORE_EXPORT void * XdmfArrayReferenceRead(XDMFARRAYREFERENCE * arrayReference, int * status); XDMFCORE_EXPORT void XdmfArrayReferenceSetConstructedProperties(XDMFARRAYREFERENCE * arrayReference, void * referenceobject); XDMFCORE_EXPORT void XdmfArrayReferenceSetConstructedType(XDMFARRAYREFERENCE * arrayReference, char * newType); // C Wrappers for parent classes are generated by macros XDMF_ITEM_C_CHILD_DECLARE(XdmfArrayReference, XDMFARRAYREFERENCE, XDMFCORE) #define XDMF_ARRAYREFERENCE_C_CHILD_DECLARE(ClassName, CClassName, Level) \ \ Level##_EXPORT char * ClassName##GetConstructedType( CClassName * arrayReference); \ Level##_EXPORT void * ClassName##Read( CClassName * arrayReference, int * status); \ Level##_EXPORT void ClassName##SetConstructedProperties( CClassName * arrayReference, void * referenceobject); \ Level##_EXPORT void ClassName##SetConstructedType( CClassName * arrayReference, char * newType); #define XDMF_ARRAYREFERENCE_C_CHILD_WRAPPER(ClassName, CClassName) \ \ \ char * ClassName##GetConstructedType(CClassName * arrayReference) \ { \ return XdmfArrayReferenceGetConstructedType((XDMFARRAYREFERENCE *)((void *)arrayReference)); \ } \ \ void * ClassName##Read(CClassName * arrayReference, int * status) \ { \ return XdmfArrayReferenceRead((XDMFARRAYREFERENCE *)((void *)arrayReference), status); \ } \ \ void ClassName##SetConstructedProperties(CClassName * arrayReference, void * referenceobject) \ { \ XdmfArrayReferenceSetConstructedProperties((XDMFARRAYREFERENCE *)((void *)arrayReference), referenceobject); \ } \ \ void ClassName##SetConstructedType(CClassName * arrayReference, char * newType) \ { \ XdmfArrayReferenceSetConstructedType((XDMFARRAYREFERENCE *)((void *)arrayReference), newType); \ } #ifdef __cplusplus } #endif #endif /* XDMFARRAYREFERENCE_HPP_ */ xdmf-3.0+git20160803/core/XdmfCore.i0000640000175000017500000016220413003006557016710 0ustar alastairalastair/* XdmfCorePython.cpp: swig -v -c++ -python -o XdmfCorePython.cpp XdmfCore.i */ %module XdmfCore %{ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include %} // Ignoring C Wrappers // XdmfItem %ignore XdmfItemAccept(XDMFITEM * item, XDMFVISITOR * visitor, int * status); %ignore XdmfItemFree(void * item); %ignore XdmfItemGetInformation(XDMFITEM * item, unsigned int index); %ignore XdmfItemGetInformationByKey(XDMFITEM * item, char * key); %ignore XdmfItemGetNumberInformations(XDMFITEM * item); %ignore XdmfItemInsertInformation(XDMFITEM * item, XDMFINFORMATION * information, int passControl); %ignore XdmfItemRemoveInformation(XDMFITEM * item, unsigned int index); %ignore XdmfItemRemoveInformationByKey(XDMFITEM * item, char * key); %ignore XdmfItemGetItemTag(XDMFITEM * item); // XdmfArray %ignore XdmfArrayNew(); %ignore XdmfArrayClear(XDMFARRAY * array); %ignore XdmfArrayErase(XDMFARRAY * array, unsigned int index); %ignore XdmfArrayGetArrayType(XDMFARRAY * array, int * status); %ignore XdmfArrayGetCapacity(XDMFARRAY * array); %ignore XdmfArrayGetDimensions(XDMFARRAY * array); %ignore XdmfArrayGetDimensionsString(XDMFARRAY * array); %ignore XdmfArrayGetHeavyDataController(XDMFARRAY * array, unsigned int index); %ignore XdmfArrayGetReadMode(XDMFARRAY * array, int * status); %ignore XdmfArrayGetName(XDMFARRAY * array); %ignore XdmfArrayGetNumberDimensions(XDMFARRAY * array); %ignore XdmfArrayGetNumberHeavyDataControllers(XDMFARRAY * array); %ignore XdmfArrayGetSize(XDMFARRAY * array); %ignore XdmfArrayGetReference(XDMFARRAY * array); %ignore XdmfArrayGetValue(XDMFARRAY * array, unsigned int index, int arrayType, int * status); %ignore XdmfArrayGetValues(XDMFARRAY * array, unsigned int startIndex, int arrayType, unsigned int numValues, unsigned int arrayStride, unsigned int valueStride, int * status); %ignore XdmfArrayGetValuesInternal(XDMFARRAY * array); %ignore XdmfArrayGetValuesString(XDMFARRAY * array); %ignore XdmfArrayInitialize(XDMFARRAY * array, int * dims, int numDims, int arrayType, int * status); %ignore XdmfArrayInsertDataFromPointer(XDMFARRAY * array, void * values, int arrayType, unsigned int startIndex, unsigned int numVals, unsigned int arrayStride, unsigned int valueStride, int * status); %ignore XdmfArrayInsertDataFromXdmfArray(XDMFARRAY * array, XDMFARRAY * valArray, int * arrayStarts, int * valueStarts, int * arrayCounts, int * valueCounts, int * arrayStrides, int * valueStrides, int * status); %ignore XdmfArrayInsertHeavyDataController(XDMFARRAY * array, XDMFHEAVYDATACONTROLLER * controller, int passControl); %ignore XdmfArrayInsertValue(XDMFARRAY * array, unsigned int index, void * value, int arrayType, int * status); %ignore XdmfArrayIsInitialized(XDMFARRAY * array); %ignore XdmfArrayPushBack(XDMFARRAY * array, void * value, int arrayType, int * status); %ignore XdmfArrayRead(XDMFARRAY * array, int * status); %ignore XdmfArrayReadController(XDMFARRAY * array, int * status); %ignore XdmfArrayReadReference(XDMFARRAY * array, int * status); %ignore XdmfArrayRelease(XDMFARRAY * array); %ignore XdmfArrayRemoveHeavyDataController(XDMFARRAY * array, unsigned int index); %ignore XdmfArrayReserve(XDMFARRAY * array, int size); %ignore XdmfArrayResize(XDMFARRAY * array, int * dims, int numDims, int arrayType, int * status); %ignore XdmfArraySetReadMode(XDMFARRAY * array, int readMode, int * status); %ignore XdmfArraySetReference(XDMFARRAY * array, XDMFARRAYREFERENCE * reference, int passControl); %ignore XdmfArraySetName(XDMFARRAY * array, char * name, int * status); %ignore XdmfArraySetValuesInternal(XDMFARRAY * array, void * pointer, unsigned int numValues, int arrayType, int transferOwnership, int * status); %ignore XdmfArraySwapWithXdmfArray(XDMFARRAY * array, XDMFARRAY * swapArray); %ignore XdmfArraySwapWithArray(XDMFARRAY * array, void ** pointer, int numValues, int arrayType, int * status); // XdmfArray inherited from XdmfItem %ignore XdmfArrayAccept(XDMFARRAY * item, XDMFVISITOR * visitor, int * status); %ignore XdmfArrayFree(void * item); %ignore XdmfArrayGetInformation(XDMFARRAY * item, unsigned int index); %ignore XdmfArrayGetInformationByKey(XDMFARRAY * item, char * key); %ignore XdmfArrayGetNumberInformations(XDMFARRAY * item); %ignore XdmfArrayInsertInformation(XDMFARRAY * item, XDMFINFORMATION * information, int passControl); %ignore XdmfArrayRemoveInformation(XDMFARRAY * item, unsigned int index); %ignore XdmfArrayRemoveInformationByKey(XDMFARRAY * item, char * key); %ignore XdmfArrayGetItemTag(XDMFARRAY * item); // XdmfArrayReference %ignore XdmfArrayReferenceGetConstructedType(XDMFARRAYREFERENCE * arrayReference); %ignore XdmfArrayReferenceRead(XDMFARRAYREFERENCE * arrayReference, int * status); %ignore XdmfArrayReferenceSetConstructedProperties(XDMFARRAYREFERENCE * arrayReference, void * referenceobject); %ignore XdmfArrayReferenceSetConstructedType(XDMFARRAYREFERENCE * arrayReference, char * newType); // XdmfArrayReference inherited from XdmfItem %ignore XdmfArrayReferenceAccept(XDMFARRAYREFERENCE * item, XDMFVISITOR * visitor, int * status); %ignore XdmfArrayReferenceFree(void * item); %ignore XdmfArrayReferenceGetInformation(XDMFARRAYREFERENCE * item, unsigned int index); %ignore XdmfArrayReferenceGetInformationByKey(XDMFARRAYREFERENCE * item, char * key); %ignore XdmfArrayReferenceGetNumberInformations(XDMFARRAYREFERENCE * item); %ignore XdmfArrayReferenceInsertInformation(XDMFARRAYREFERENCE * item, XDMFINFORMATION * information, int passControl); %ignore XdmfArrayReferenceRemoveInformation(XDMFARRAYREFERENCE * item, unsigned int index); %ignore XdmfArrayReferenceRemoveInformationByKey(XDMFARRAYREFERENCE * item, char * key); %ignore XdmfArrayReferenceGetItemTag(XDMFARRAYREFERENCE * item); // XdmfArrayType %ignore XdmfArrayTypeInt8(); %ignore XdmfArrayTypeInt16(); %ignore XdmfArrayTypeInt32(); %ignore XdmfArrayTypeInt64(); %ignore XdmfArrayTypeFloat32(); %ignore XdmfArrayTypeFloat64(); %ignore XdmfArrayTypeUInt8(); %ignore XdmfArrayTypeUInt16(); %ignore XdmfArrayTypeUInt32(); %ignore XdmfArrayTypeComparePrecision(int type1, int type2, oint * status); %ignore XdmfArrayTypeGetElementSize(int type, int * status); %ignore XdmfArrayTypeGetIsSigned(int type, int * status); %ignore XdmfArrayTypeGetName(int type, int * status); // XdmfCoreReader %ignore XdmfCoreReaderRead(XDMFCOREREADER * reader, char * filePath, int * status); // XdmfError %ignore XdmfErrorSetCErrorsAreFatal(int status); %ignore XdmfErrorSetLevelLimit(int level, int * status); %ignore XdmfErrorSetSuppressionLevel(int level, int * status); %ignore XdmfErrorGetCErrorsAreFatal(); %ignore XdmfErrorGetLevelLimit(); %ignore XdmfErrorGetSuppressionLevel(); // XdmfFunction %ignore XdmfFunctionNew(); %ignore XdmfFunctionNewInit(char * newExpression, char ** keys, XDMFARRAY ** values, int numVariables); %ignore XdmfFunctionAddFunction(char * name, XDMFARRAY *(*functionref)(XDMFARRAY **, unsigned int), int * status); %ignore XdmfFunctionAddOperation(char newoperator, XDMFARRAY *(*operationref)(XDMFARRAY *, XDMFARRAY *), int priority, int * status); %ignore XdmfFunctionAverage(XDMFARRAY ** values, int numValues); %ignore XdmfFunctionChunk(XDMFARRAY * val1, XDMFARRAY * val2, int * status); %ignore XdmfFunctionEvaluateExpression(char * expression, char ** keys, XDMFARRAY ** values, int numVariables, int * status); %ignore XdmfFunctionEvaluateOperation(XDMFARRAY * val1, XDMFARRAY * val2, char operation, int * status); %ignore XdmfFunctionEvaluateFunction(XDMFARRAY ** valueVector, int numValues, char * functionName, int * status); %ignore XdmfFunctionGetExpression(XDMFFUNCTION * function); %ignore XdmfFunctionGetNumberVariables(XDMFFUNCTION * function); %ignore XdmfFunctionGetOperationPriority(char operation); %ignore XdmfFunctionGetSupportedOperations(); %ignore XdmfFunctionGetSupportedFunctions(); %ignore XdmfFunctionGetNumberSupportedFunctions(); %ignore XdmfFunctionGetValidDigitChars(); %ignore XdmfFunctionGetValidVariableChars(); %ignore XdmfFunctionGetVariable(XDMFFUNCTION * function, char * key); %ignore XdmfFunctionGetVariableList(XDMFFUNCTION * function); %ignore XdmfFunctionInterlace(XDMFARRAY * val1, XDMFARRAY * val2, int * status); %ignore XdmfFunctionInsertVariable(XDMFFUNCTION * function, char * key, XDMFARRAY * value, int passControl); %ignore XdmfFunctionRemoveVariable(XDMFFUNCTION * function, char * key); %ignore XdmfFunctionSetExpression(XDMFFUNCTION * function, char * newExpression, int * status); %ignore XdmfFunctionSum(XDMFARRAY ** values, int numValues); // XdmfFunction inherited from XdmfItem %ignore XdmfFunctionAccept(XDMFFUNCTION * item, XDMFVISITOR * visitor, int * status); %ignore XdmfFunctionFree(void * item); %ignore XdmfFunctionGetInformation(XDMFFUNCTION * item, unsigned int index); %ignore XdmfFunctionGetInformationByKey(XDMFFUNCTION * item, char * key); %ignore XdmfFunctionGetNumberInformations(XDMFFUNCTION * item); %ignore XdmfFunctionInsertInformation(XDMFFUNCTION * item, XDMFINFORMATION * information, int passControl); %ignore XdmfFunctionRemoveInformation(XDMFFUNCTION * item, unsigned int index); %ignore XdmfFunctionRemoveInformationByKey(XDMFFUNCTION * item, char * key); %ignore XdmfFunctionGetItemTag(XDMFFUNCTION * item); // XdmfFunction inherited from XdmfArrayReference %ignore XdmfFunctionGetConstructedType(XDMFFUNCTION * arrayReference); %ignore XdmfFunctionRead(XDMFFUNCTION * arrayReference, int * status); %ignore XdmfFunctionSetConstructedProperties(XDMFFUNCTION * arrayReference, void * referenceobject); %ignore XdmfFunctionSetConstructedType(XDMFFUNCTION * arrayReference, char * newType); // XdmfHDF5Controller %ignore XdmfHDF5ControllerNew(char * hdf5FilePath, char * dataSetPath, int type, unsigned int * start, unsigned int * stride, unsigned int * dimensions, unsigned int * dataspaceDimensions, unsigned int numDims, int * status); %ignore XdmfHDF5ControllerGetDataSetPath(XDMFHDF5CONTROLLER * controller); // XdmfHDF5Controller inherited from XdmfHeavyDataController %ignore XdmfHDF5ControllerFree(XDMFHDF5CONTROLLER * item); %ignore XdmfHDF5ControllerGetDataspaceDimensions(XDMFHDF5CONTROLLER * controller); %ignore XdmfHDF5ControllerGetDimensions(XDMFHDF5CONTROLLER * controller); %ignore XdmfHDF5ControllerGetFilePath(XDMFHDF5CONTROLLER * controller); %ignore XdmfHDF5ControllerGetName(XDMFHDF5CONTROLLER * controller); %ignore XdmfHDF5ControllerGetNumberDimensions(XDMFHDF5CONTROLLER * controller); %ignore XdmfHDF5ControllerGetSize(XDMFHDF5CONTROLLER * controller); %ignore XdmfHDF5ControllerGetStart(XDMFHDF5CONTROLLER * controller); %ignore XdmfHDF5ControllerGetStride(XDMFHDF5CONTROLLER * controller); %ignore XdmfHDF5ControllerSetArrayOffset(XDMFHDF5CONTROLLER * controller, unsigned int newOffset); %ignore XdmfHDF5ControllerGetArrayOffset(XDMFHDF5CONTROLLER * controller); %ignore XdmfHDF5ControllerGetType(XDMFHDF5CONTROLLER * controller, int * status); %ignore XdmfHDF5ControllerRead(XDMFHDF5CONTROLLER * controller, void * array, int * status); // XdmfHDF5Writer %ignore XdmfHDF5WriterNew(char * fileName, int clobberFile); %ignore XdmfHDF5WriterCloseFile(XDMFHDF5WRITER * writer, int * status); %ignore XdmfHDF5WriterGetChunkSize(XDMFHDF5WRITER * writer, int * status); %ignore XdmfHDF5WriterOpenFile(XDMFHDF5WRITER * writer, int * status); %ignore XdmfHDF5WriterSetChunkSize(XDMFHDF5WRITER * writer, unsigned int chunkSize, int * status); // XdmfHDF5Writer inherited from XdmfHeavyDataWriter %ignore XdmfHDF5WriterFree(XDMFHDF5WRITER * item); %ignore XdmfHDF5WriterGetAllowSetSplitting(XDMFHDF5WRITER * writer); %ignore XdmfHDF5WriterGetFileIndex(XDMFHDF5WRITER * writer); %ignore XdmfHDF5WriterGetFileOverhead(XDMFHDF5WRITER * writer); %ignore XdmfHDF5WriterGetFilePath(XDMFHDF5WRITER * writer); %ignore XdmfHDF5WriterGetFileSizeLimit(XDMFHDF5WRITER * writer); %ignore XdmfHDF5WriterGetMode(XDMFHDF5WRITER * writer); %ignore XdmfHDF5WriterGetReleaseData(XDMFHDF5WRITER * writer); %ignore XdmfHDF5WriterSetAllowSetSplitting(XDMFHDF5WRITER * writer, int newAllow); %ignore XdmfHDF5WriterSetFileIndex(XDMFHDF5WRITER * writer, int newIndex); %ignore XdmfHDF5WriterSetFileSizeLimit(XDMFHDF5WRITER * writer, int newSize); %ignore XdmfHDF5WriterSetMode(XDMFHDF5WRITER * writer, int mode, int * status); %ignore XdmfHDF5WriterSetReleaseData(XDMFHDF5WRITER * writer, int releaseData); // XdmfHeavyDataController %ignore XdmfHeavyDataControllerFree(XDMFHEAVYDATACONTROLLER * item); %ignore XdmfHeavyDataControllerGetDataspaceDimensions(XDMFHEAVYDATACONTROLLER * controller); %ignore XdmfHeavyDataControllerGetDimensions(XDMFHEAVYDATACONTROLLER * controller); %ignore XdmfHeavyDataControllerGetFilePath(XDMFHEAVYDATACONTROLLER * controller); %ignore XdmfHeavyDataControllerGetName(XDMFHEAVYDATACONTROLLER * controller); %ignore XdmfHeavyDataControllerGetNumberDimensions(XDMFHEAVYDATACONTROLLER * controller); %ignore XdmfHeavyDataControllerGetSize(XDMFHEAVYDATACONTROLLER * controller); %ignore XdmfHeavyDataControllerGetStart(XDMFHEAVYDATACONTROLLER * controller); %ignore XdmfHeavyDataControllerGetStride(XDMFHEAVYDATACONTROLLER * controller); %ignore XdmfHeavyDataControllerSetArrayOffset(XDMFHEAVYDATACONTROLLER * controller, unsigned int newOffset); %ignore XdmfHeavyDataControllerGetArrayOffset(XDMFHEAVYDATACONTROLLER * controller); %ignore XdmfHeavyDataControllerGetType(XDMFHEAVYDATACONTROLLER * controller, int * status); %ignore XdmfHeavyDataControllerRead(XDMFHEAVYDATACONTROLLER * controller, void * array, int * status); // XdmfHeavyDataWriter %ignore XdmfHeavyDataWriterFree(XDMFHEAVYDATAWRITER * item); %ignore XdmfHeavyDataWriterGetAllowSetSplitting(XDMFHEAVYDATAWRITER * writer); %ignore XdmfHeavyDataWriterGetFileIndex(XDMFHEAVYDATAWRITER * writer); %ignore XdmfHeavyDataWriterGetFileOverhead(XDMFHEAVYDATAWRITER * writer); %ignore XdmfHeavyDataWriterGetFilePath(XDMFHEAVYDATAWRITER * writer); %ignore XdmfHeavyDataWriterGetFileSizeLimit(XDMFHEAVYDATAWRITER * writer); %ignore XdmfHeavyDataWriterGetMode(XDMFHEAVYDATAWRITER * writer); %ignore XdmfHeavyDataWriterGetReleaseData(XDMFHEAVYDATAWRITER * writer); %ignore XdmfHeavyDataWriterSetAllowSetSplitting(XDMFHEAVYDATAWRITER * writer, int newAllow); %ignore XdmfHeavyDataWriterSetFileIndex(XDMFHEAVYDATAWRITER * writer, int newIndex); %ignore XdmfHeavyDataWriterSetFileSizeLimit(XDMFHEAVYDATAWRITER * writer, int newSize); %ignore XdmfHeavyDataWriterSetMode(XDMFHEAVYDATAWRITER * writer, int mode, int * status); %ignore XdmfHeavyDataWriterSetReleaseData(XDMFHEAVYDATAWRITER * writer, int releaseData); // XdmfInformation %ignore XdmfInformationNew(char * key, char * value); %ignore XdmfInformationGetArray(XDMFINFORMATION * information, unsigned int index); %ignore XdmfInformationGetArrayByName(XDMFINFORMATION * information, char * name); %ignore XdmfInformationGetKey(XDMFINFORMATION * information); %ignore XdmfInformationGetNumberArrays(XDMFINFORMATION * information); %ignore XdmfInformationGetValue(XDMFINFORMATION * information); %ignore XdmfInformationInsertArray(XDMFINFORMATION * information, XDMFARRAY * array, int transferOwnership); %ignore XdmfInformationRemoveArray(XDMFINFORMATION * information, unsigned int index); %ignore XdmfInformationRemoveArrayByName(XDMFINFORMATION * information, char * name); %ignore XdmfInformationSetKey(XDMFINFORMATION * information, char * key, int * status); %ignore XdmfInformationSetValue(XDMFINFORMATION * information, char * value, int * status); // XdmfInformation inherited from XdmfItem %ignore XdmfInformationAccept(XDMFINFORMATION * item, XDMFVISITOR * visitor, int * status); %ignore XdmfInformationFree(void * item); %ignore XdmfInformationGetInformation(XDMFINFORMATION * item, unsigned int index); %ignore XdmfInformationGetInformationByKey(XDMFINFORMATION * item, char * key); %ignore XdmfInformationGetNumberInformations(XDMFINFORMATION * item); %ignore XdmfInformationInsertInformation(XDMFINFORMATION * item, XDMFINFORMATION * information, int passControl); %ignore XdmfInformationRemoveInformation(XDMFINFORMATION * item, unsigned int index); %ignore XdmfInformationRemoveInformationByKey(XDMFINFORMATION * item, char * key); %ignore XdmfInformationGetItemTag(XDMFINFORMATION * item); // XdmfSparseMatrix %ignore XdmfSparseMatrixNew(unsigned int numberRows, unsigned int numberColumns); %ignore XdmfSparseMatrixGetColumnIndex(XDMFSPARSEMATRIX * matrix, int * status); %ignore XdmfSparseMatrixGetName(XDMFSPARSEMATRIX * matrix); %ignore XdmfSparseMatrixGetNumberColumns(XDMFSPARSEMATRIX * matrix); %ignore XdmfSparseMatrixGetNumberRows(XDMFSPARSEMATRIX * matrix); %ignore XdmfSparseMatrixGetRowPointer(XDMFSPARSEMATRIX * matrix, int * status); %ignore XdmfSparseMatrixGetValues(XDMFSPARSEMATRIX * matrix, int * status); %ignore XdmfSparseMatrixGetValuesString(XDMFSPARSEMATRIX * matrix, int * status); %ignore XdmfSparseMatrixSetColumnIndex(XDMFSPARSEMATRIX * matrix, XDMFARRAY * columnIndex, int passControl, int * status); %ignore XdmfSparseMatrixSetName(XDMFSPARSEMATRIX * matrix, char * name, int * status); %ignore XdmfSparseMatrixSetRowPointer(XDMFSPARSEMATRIX * matrix, XDMFARRAY * rowPointer, int passControl, int * status); %ignore XdmfSparseMatrixSetValues(XDMFSPARSEMATRIX * matrix, XDMFARRAY * values, int passControl, int * status); // XdmfSparseMatrix inherited from XdmfItem %ignore XdmfSparseMatrixAccept(XDMFSPARSEMATRIX * item, XDMFVISITOR * visitor, int * status); %ignore XdmfSparseMatrixFree(void * item); %ignore XdmfSparseMatrixGetInformation(XDMFSPARSEMATRIX * item, unsigned int index); %ignore XdmfSparseMatrixGetInformationByKey(XDMFSPARSEMATRIX * item, char * key); %ignore XdmfSparseMatrixGetNumberInformations(XDMFSPARSEMATRIX * item); %ignore XdmfSparseMatrixInsertInformation(XDMFSPARSEMATRIX * item, XDMFINFORMATION * information, int passControl); %ignore XdmfSparseMatrixRemoveInformation(XDMFSPARSEMATRIX * item, unsigned int index); %ignore XdmfSparseMatrixRemoveInformationByKey(XDMFSPARSEMATRIX * item, char * key); %ignore XdmfSparseMatrixGetItemTag(XDMFSPARSEMATRIX * item); // XdmfSubset %ignore XdmfSubsetNew(void * referenceArray, unsigned int * start, unsigned int * stride, unsigned int * dimensions, unsigned int numDims, int passControl, int * status); %ignore XdmfSubsetGetDimensions(XDMFSUBSET * subset); %ignore XdmfSubsetGetNumberDimensions(XDMFSUBSET * subset); %ignore XdmfSubsetGetReferenceArray(XDMFSUBSET * subset); %ignore XdmfSubsetGetSize(XDMFSUBSET * subset); %ignore XdmfSubsetGetStart(XDMFSUBSET * subset); %ignore XdmfSubsetGetStride(XDMFSUBSET * subset); %ignore XdmfSubsetSetDimensions(XDMFSUBSET * subset, unsigned int * newDimensions, unsigned int numDims, int * status); %ignore XdmfSubsetSetReferenceArray(XDMFSUBSET * subset, XDMFARRAY * referenceArray, int passControl); %ignore XdmfSubsetSetStart(XDMFSUBSET * subset, unsigned int * newStarts, unsigned int numDims, int * status); %ignore XdmfSubsetSetStride(XDMFSUBSET * subset, unsigned int * newStrides, unsigned int numDims, int * status); // XdmfSubset inherited from XdmfItem %ignore XdmfSubsetAccept(XDMFSUBSET * item, XDMFVISITOR * visitor, int * status); %ignore XdmfSubsetFree(void * item); %ignore XdmfSubsetGetInformation(XDMFSUBSET * item, unsigned int index); %ignore XdmfSubsetGetInformationByKey(XDMFSUBSET * item, char * key); %ignore XdmfSubsetGetNumberInformations(XDMFSUBSET * item); %ignore XdmfSubsetInsertInformation(XDMFSUBSET * item, XDMFINFORMATION * information, int passControl); %ignore XdmfSubsetRemoveInformation(XDMFSUBSET * item, unsigned int index); %ignore XdmfSubsetRemoveInformationByKey(XDMFSUBSET * item, char * key); %ignore XdmfSubsetGetItemTag(XDMFSUBSET * item); // XdmfSubset inherited from XdmfArrayReference %ignore XdmfSubsetGetConstructedType(XDMFSUBSET * arrayReference); %ignore XdmfSubsetRead(XDMFSUBSET * arrayReference, int * status); %ignore XdmfSubsetSetConstructedProperties(XDMFSUBSET * arrayReference, void * referenceobject); %ignore XdmfSubsetSetConstructedType(XDMFSUBSET * arrayReference, char * newType); // XdmfWriter %ignore XdmfWriterNew(char * fileName); %ignore XdmfWriterNewSpecifyHeavyDataWriter(char * fileName, XDMFHEAVYDATAWRITER * heavyDataWriter); %ignore XdmfWriterFree(XDMFWRITER * item); %ignore XdmfWriterGetFilePath(XDMFWRITER * writer, int * status); %ignore XdmfWriterGetHeavyDataWriter(XDMFWRITER * writer, int * status); %ignore XdmfWriterGetLightDataLimit(XDMFWRITER * writer, int * status); %ignore XdmfWriterGetMode(XDMFWRITER * writer, int * status); %ignore XdmfWriterGetWriteXPaths(XDMFWRITER * writer, int * status); %ignore XdmfWriterGetXPathParse(XDMFWRITER * writer, int * status); %ignore XdmfWriterSetHeavyDataWriter(XDMFWRITER * writer, XDMFHEAVYDATAWRITER * heavyDataWriter, int transferOwnership, int * status); %ignore XdmfWriterSetLightDataLimit(XDMFWRITER * writer, unsigned int numValues, int * status); %ignore XdmfWriterSetMode(XDMFWRITER * writer, int mode, int * status); %ignore XdmfWriterSetWriteXPaths(XDMFWRITER * writer, int writeXPaths, int * status); %ignore XdmfWriterSetXPathParse(XDMFWRITER * writer, int xPathParse, int * status); #ifdef SWIGJAVA // Ignore const overloaded methods %ignore XdmfArray::getHeavyDataController() const; %ignore XdmfArray::getValuesInternal() const; %ignore XdmfItem::getInformation(const unsigned int) const; %ignore XdmfItem::getInformation(const std::string &) const; %ignore XdmfWriter::getHeavyDataWriter() const; %ignore XdmfInformation::getArray(unsigned int const) const; %ignore XdmfInformation::getArray(std::string const &) const; // Ignore ItemTags %ignore XdmfArray::ItemTag; %ignore XdmfInformation::ItemTag; // Define equality operators %extend XdmfItem { bool equals(boost::shared_ptr item) { if (item == NULL) { return false; } return self == item.get(); } bool IsEqual(boost::shared_ptr item) { if (item == NULL) { return false; } return self == item.get(); } }; %extend XdmfItemProperty { bool equals(boost::shared_ptr itemProperty) { if (itemProperty == NULL) { return false; } return self == itemProperty.get(); } bool IsEqual(boost::shared_ptr itemProperty) { if (itemProperty == NULL) { return false; } return self == itemProperty.get(); } }; %typemap(javacode) XdmfArray %{ public void insertValuesAsInt8(int index, char[] values) { for(int i = 0; i < values.length; i++) this.insertValueAsInt8(index+i, values[i]); } public void insertValuesAsInt16(int index, short[] values) { for(int i = 0; i < values.length; i++) this.insertValueAsInt16(index+i, values[i]); } public void insertValuesAsInt32(int index, int[] values) { for(int i = 0; i < values.length; i++) this.insertValueAsInt32(index+i, values[i]); } public void insertValuesAsFloat32(int index, float[] values) { for(int i = 0; i < values.length; i++) this.insertValueAsFloat32(index+i, values[i]); } public void insertValuesAsFloat64(int index, double[] values) { for(int i = 0; i < values.length; i++) this.insertValueAsFloat64(index+i, values[i]); } %} %pragma(java) jniclasscode=%{ static { try { System.loadLibrary("XdmfCoreJava"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load for" + "XdmfCoreJava\n" + e); System.exit(1); } } %} #endif /* SWIGJAVA */ #ifdef SWIGPYTHON %ignore XdmfArray::insert(const unsigned int startIndex, const T * const valuesPointer, const unsigned int numValues, const unsigned int arrayStride = 1, const unsigned int valuesStride = 1); %ignore XdmfArray::pushBack(const T & value); /*This converts XdmfErrors to Python RuntimeErrors*/ %exception { try { $action } catch (XdmfError e) { PyErr_SetString(PyExc_RuntimeError, e.what()); return NULL; } } /*This causes it to avoid throwing a warning about overloaded functions. We are doing this intentionally so suppressing the warning makes sense.*/ #pragma SWIG nowarn=509 %extend XdmfItem { bool __eq__(const XdmfItem * item) { return $self == item; } }; %extend XdmfItemProperty { bool __eq__(const XdmfItemProperty * item) { return $self == item; } }; %extend XdmfVisitor { bool __eq__(const XdmfVisitor * item) { return $self == item; } }; %extend XdmfHeavyDataWriter { bool __eq__(const XdmfHeavyDataWriter * item) { return $self == item; } }; %extend XdmfHeavyDataController { bool __eq__(const XdmfHeavyDataController * item) { return $self == item; } static shared_ptr XdmfHDF5ControllerCast(PyObject * obj) { void * resultPointer = 0; swig_type_info * returnType = SWIG_TypeQuery("_p_boost__shared_ptrT_XdmfHeavyDataController_t"); SWIG_ConvertPtr(obj, &resultPointer, returnType, 0); shared_ptr * returnControllerPointer = reinterpret_cast *>(resultPointer); shared_ptr returnController = returnControllerPointer[0]; if (shared_ptr returnHDF5Controller = shared_dynamic_cast(returnController)) { return returnHDF5Controller; } else { XdmfError::message(XdmfError::FATAL, "Error: Attempting to cast a non HDF5 Controller to HDF5"); return shared_ptr(); } } }; %extend XdmfCoreReader { bool __eq__(const XdmfCoreReader * item) { return $self == item; } }; %extend XdmfWriter { bool __eq__(const XdmfWriter * item) { return $self == item; } }; // Provide accessors from python lists to XdmfArrays %extend XdmfArray { PyObject * getBuffer() { void *vp = $self->getValuesInternal(); Py_ssize_t sz = $self->getSize() * $self->getArrayType()->getElementSize(); PyObject * c = PyBuffer_FromMemory(vp, sz); return(c); } %pythoncode { def getNumpyArray(self): h5ctl = self.getHeavyDataController() if h5ctl == None : try : from numpy import frombuffer as ___frombuffer except : return None buf = self.getBuffer() aType = self.getArrayType() if aType == XdmfArrayType.Int8() : return(___frombuffer(buf, 'int8')) if aType == XdmfArrayType.Int16() : return(___frombuffer(buf, 'int16')) if aType == XdmfArrayType.Int32() : return(___frombuffer(buf, 'int32')) if aType == XdmfArrayType.Int64() : return(___frombuffer(buf, 'int64')) if aType == XdmfArrayType.Float32() : return(___frombuffer(buf, 'float32')) if aType == XdmfArrayType.Float64() : return(___frombuffer(buf, 'float64')) if aType == XdmfArrayType.UInt8() : return(___frombuffer(buf, 'uint8')) if aType == XdmfArrayType.UInt16() : return(___frombuffer(buf, 'uint16')) if aType == XdmfArrayType.UInt32() : return(___frombuffer(buf, 'uint32')) return None else : if h5ctl.getName() == "HDF": controller = XdmfHeavyDataController.XdmfHDF5ControllerCast(h5ctl) h5FileName = controller.getFilePath() h5DataSetName = controller.getDataSetPath() if (h5FileName == None) | (h5DataSetName == None) : return None try : from h5py import File as ___File from numpy import array as ___array f = ___File(h5FileName, 'r') if h5DataSetName in f.keys() : return(___array(f[h5DataSetName])) except : pass return None else: return None }; void getValues(unsigned int startIndex, PyObject * list, unsigned int numValues = 1, unsigned int arrayStride = 1, unsigned int valuesStride = 1) { Py_ssize_t size = PyList_Size(list); PyObject * placeholderVal; if (valuesStride * numValues > size) { if ($self->XdmfArray::getArrayType() == XdmfArrayType::Int8()) { placeholderVal = PyLong_FromLong((char)0); } else if ($self->XdmfArray::getArrayType() == XdmfArrayType::Int16()) { placeholderVal = PyLong_FromLong((short)0); } else if ($self->XdmfArray::getArrayType() == XdmfArrayType::Int32()) { placeholderVal = PyLong_FromLong((int)0); } else if ($self->XdmfArray::getArrayType() == XdmfArrayType::Int64()) { placeholderVal = PyLong_FromLong((long)0); } else if ($self->XdmfArray::getArrayType() == XdmfArrayType::Float32()) { placeholderVal = PyFloat_FromDouble((float)0); } else if ($self->XdmfArray::getArrayType() == XdmfArrayType::Float64()) { placeholderVal = PyFloat_FromDouble((double)0); } else if ($self->XdmfArray::getArrayType() == XdmfArrayType::UInt8()) { placeholderVal = PyLong_FromUnsignedLong((unsigned char)0); } else if ($self->XdmfArray::getArrayType() == XdmfArrayType::UInt16()) { placeholderVal = PyLong_FromUnsignedLong((unsigned short)0); } else if ($self->XdmfArray::getArrayType() == XdmfArrayType::UInt32()) { placeholderVal = PyLong_FromUnsignedLong((unsigned int)0); } else if ($self->XdmfArray::getArrayType() == XdmfArrayType::String()) { placeholderVal = PyString_FromString(""); } } for (unsigned int i = 0; i < numValues; ++i) { unsigned int index = startIndex + (i * arrayStride); unsigned int insertIndex = i * valuesStride; PyObject * insertedVal; if ($self->XdmfArray::getArrayType() == XdmfArrayType::Int8()) { insertedVal = PyLong_FromLong($self->XdmfArray::getValue(index)); } else if ($self->XdmfArray::getArrayType() == XdmfArrayType::Int16()) { insertedVal = PyLong_FromLong($self->XdmfArray::getValue(index)); } else if ($self->XdmfArray::getArrayType() == XdmfArrayType::Int32()) { insertedVal = PyLong_FromLong($self->XdmfArray::getValue(index)); } else if ($self->XdmfArray::getArrayType() == XdmfArrayType::Int64()) { insertedVal = PyLong_FromLong($self->XdmfArray::getValue(index)); } else if ($self->XdmfArray::getArrayType() == XdmfArrayType::Float32()) { insertedVal = PyFloat_FromDouble($self->XdmfArray::getValue(index)); } else if ($self->XdmfArray::getArrayType() == XdmfArrayType::Float64()) { insertedVal = PyFloat_FromDouble($self->XdmfArray::getValue(index)); } else if ($self->XdmfArray::getArrayType() == XdmfArrayType::UInt8()) { insertedVal = PyLong_FromUnsignedLong($self->XdmfArray::getValue(index)); } else if ($self->XdmfArray::getArrayType() == XdmfArrayType::UInt16()) { insertedVal = PyLong_FromUnsignedLong($self->XdmfArray::getValue(index)); } else if ($self->XdmfArray::getArrayType() == XdmfArrayType::UInt32()) { insertedVal = PyLong_FromUnsignedLong($self->XdmfArray::getValue(index)); } else if ($self->XdmfArray::getArrayType() == XdmfArrayType::String()) { insertedVal = PyString_FromString($self->XdmfArray::getValue(index).c_str()); } if (insertIndex < size) { PyList_SetItem(list, insertIndex, insertedVal); } else { for (unsigned int padding = size; padding < insertIndex; ++padding) { PyList_Append(list, placeholderVal); ++size; } PyList_Append(list, insertedVal); ++size; } } } void insertAsInt8(int startIndex, PyObject * list, int listStartIndex = 0, int numValues = -1, int arrayStride = 1, int listStride = 1) { Py_ssize_t size; if (numValues <= 0) { size = PyList_Size(list); } else { size = numValues; } for(Py_ssize_t i = 0; i < size; ++i) { if (listStartIndex + (i * listStride) >= PyList_Size(list)) { $self->insert(i+startIndex, (char) 0); } else { $self->insert((i * arrayStride) + startIndex, (char)PyLong_AsLong(PyList_GetItem(list, listStartIndex + (i * listStride)))); } } } void insertAsInt16(int startIndex, PyObject * list, int listStartIndex = 0, int numValues = -1, int arrayStride = 1, int listStride = 1) { Py_ssize_t size; if (numValues <= 0) { size = PyList_Size(list); } else { size = numValues; } for(Py_ssize_t i = 0; i < size; ++i) { if (listStartIndex + (i * listStride) >= PyList_Size(list)) { $self->insert(i+startIndex, (short) 0); } else { $self->insert((i * arrayStride) + startIndex, (short)PyLong_AsLong(PyList_GetItem(list, listStartIndex + (i * listStride)))); } } } void insertAsInt32(int startIndex, PyObject * list, int listStartIndex = 0, int numValues = -1, int arrayStride = 1, int listStride = 1) { Py_ssize_t size; if (numValues <= 0) { size = PyList_Size(list); } else { size = numValues; } for(Py_ssize_t i = 0; i < size; ++i) { if (listStartIndex + (i * listStride) >= PyList_Size(list)) { $self->insert(i+startIndex, (int) 0); } else { $self->insert((i * arrayStride) + startIndex, (int)PyLong_AsLong(PyList_GetItem(list, listStartIndex + (i * listStride)))); } } } void insertAsInt64(int startIndex, PyObject * list, int listStartIndex = 0, int numValues = -1, int arrayStride = 1, int listStride = 1) { Py_ssize_t size; if (numValues <= 0) { size = PyList_Size(list); } else { size = numValues; } for(Py_ssize_t i = 0; i < size; ++i) { if (listStartIndex + (i * listStride) >= PyList_Size(list)) { $self->insert(i+startIndex, (long) 0); } else { $self->insert((i * arrayStride) + startIndex, PyLong_AsLong(PyList_GetItem(list, listStartIndex + (i * listStride)))); } } } void insertAsFloat32(int startIndex, PyObject * list, int listStartIndex = 0, int numValues = -1, int arrayStride = 1, int listStride = 1) { Py_ssize_t size; if (numValues <= 0) { size = PyList_Size(list); } else { size = numValues; } for(Py_ssize_t i = 0; i < size; ++i) { if (listStartIndex + (i * listStride) >= PyList_Size(list)) { $self->insert(i+startIndex, (float) 0); } else { $self->insert((i * arrayStride) + startIndex, (float)PyFloat_AsDouble(PyList_GetItem(list, listStartIndex + (i * listStride)))); } } } void insertAsFloat64(int startIndex, PyObject * list, int listStartIndex = 0, int numValues = -1, int arrayStride = 1, int listStride = 1) { Py_ssize_t size; if (numValues <= 0) { size = PyList_Size(list); } else { size = numValues; } for(Py_ssize_t i = 0; i < size; ++i) { if (listStartIndex + (i * listStride) >= PyList_Size(list)) { $self->insert(i+startIndex, (double) 0); } else { $self->insert((i * arrayStride) + startIndex, PyFloat_AsDouble(PyList_GetItem(list, listStartIndex + (i * listStride)))); } } } void insertAsUInt8(int startIndex, PyObject * list, int listStartIndex = 0, int numValues = -1, int arrayStride = 1, int listStride = 1) { Py_ssize_t size; if (numValues <= 0) { size = PyList_Size(list); } else { size = numValues; } for(Py_ssize_t i = 0; i < size; ++i) { if (listStartIndex + (i * listStride) >= PyList_Size(list)) { $self->insert(i+startIndex, (unsigned char) 0); } else { $self->insert((i * arrayStride) + startIndex, (unsigned char)(PyLong_AsUnsignedLong(PyList_GetItem(list, listStartIndex + (i * listStride))))); } } } void insertAsUInt16(int startIndex, PyObject * list, int listStartIndex = 0, int numValues = -1, int arrayStride = 1, int listStride = 1) { Py_ssize_t size; if (numValues <= 0) { size = PyList_Size(list); } else { size = numValues; } for(Py_ssize_t i = 0; i < size; ++i) { if (listStartIndex + (i * listStride) >= PyList_Size(list)) { $self->insert(i+startIndex, (unsigned short) 0); } else { $self->insert((i * arrayStride) + startIndex, (unsigned short)(PyLong_AsUnsignedLong(PyList_GetItem(list, listStartIndex + (i * listStride))))); } } } void insertAsUInt32(int startIndex, PyObject * list, int listStartIndex = 0, int numValues = -1, int arrayStride = 1, int listStride = 1) { Py_ssize_t size; if (numValues <= 0) { size = PyList_Size(list); } else { size = numValues; } for(Py_ssize_t i = 0; i < size; ++i) { if (listStartIndex + (i * listStride) >= PyList_Size(list)) { $self->insert(i+startIndex, (unsigned int) 0); } else { $self->insert((i * arrayStride) + startIndex, (unsigned int)(PyLong_AsUnsignedLong(PyList_GetItem(list, listStartIndex + (i * listStride))))); } } } void insertAsString(int startIndex, PyObject * list, int listStartIndex = 0, int numValues = -1, int arrayStride = 1, int listStride = 1) { Py_ssize_t size; if (numValues <= 0) { size = PyList_Size(list); } else { size = numValues; } for(Py_ssize_t i = 0; i < size; ++i) { if (listStartIndex + (i * listStride) >= PyList_Size(list)) { $self->insert(i+startIndex, ""); } else { $self->insert((i * arrayStride) + startIndex, PyString_AsString(PyList_GetItem(list, listStartIndex + (i * listStride)))); } } } static shared_ptr XdmfArrayPtr(PyObject * obj) { void * resultPointer = 0; swig_type_info * returnType = SWIG_TypeQuery("_p_boost__shared_ptrT_XdmfArray_t"); SWIG_ConvertPtr(obj, &resultPointer, returnType, 0); shared_ptr * returnArrayPointer = reinterpret_cast *>(resultPointer); shared_ptr returnArray = returnArrayPointer[0]; return returnArray; } void pushBackAsInt8(const char & value) { $self->XdmfArray::pushBack(value); } void pushBackAsInt16(const short & value) { $self->XdmfArray::pushBack(value); } void pushBackAsInt32(const int & value) { $self->XdmfArray::pushBack(value); } void pushBackAsInt64(const long & value) { $self->XdmfArray::pushBack(value); } void pushBackAsUInt8(const unsigned char & value) { $self->XdmfArray::pushBack(value); } void pushBackAsUInt16(const unsigned short & value) { $self->XdmfArray::pushBack(value); } void pushBackAsUInt32(const unsigned int & value) { $self->XdmfArray::pushBack(value); } void pushBackAsFloat32(const float & value) { $self->XdmfArray::pushBack(value); } void pushBackAsFloat64(const double & value) { $self->XdmfArray::pushBack(value); } void pushBackAsString(const std::string & value) { $self->XdmfArray::pushBack(value); } void insertValueAsInt8(const unsigned int startIndex, const char * const valuesPointer, const unsigned int numValues = 1, const unsigned int arrayStride = 1, const unsigned int valuesStride = 1) { $self->XdmfArray::insert(startIndex, valuesPointer, numValues, arrayStride, valuesStride); } void insertValueAsInt8(const unsigned int startIndex, const char value) { $self->XdmfArray::insert(startIndex, value); } void insertValueAsInt16(const unsigned int startIndex, const short * const valuesPointer, const unsigned int numValues = 1, const unsigned int arrayStride = 1, const unsigned int valuesStride = 1) { $self->XdmfArray::insert(startIndex, valuesPointer, numValues, arrayStride, valuesStride); } void insertValueAsInt16(const unsigned int startIndex, const short value) { $self->XdmfArray::insert(startIndex, value); } void insertValueAsInt32(const unsigned int startIndex, const int * const valuesPointer, const unsigned int numValues = 1, const unsigned int arrayStride = 1, const unsigned int valuesStride = 1) { $self->XdmfArray::insert(startIndex, valuesPointer, numValues, arrayStride, valuesStride); } void insertValueAsInt32(const unsigned int startIndex, const int value) { $self->XdmfArray::insert(startIndex, value); } void insertValueAsInt64(const unsigned int startIndex, const long * const valuesPointer, const unsigned int numValues = 1, const unsigned int arrayStride = 1, const unsigned int valuesStride = 1) { $self->XdmfArray::insert(startIndex, valuesPointer, numValues, arrayStride, valuesStride); } void insertValueAsInt64(const unsigned int startIndex, const long value) { $self->XdmfArray::insert(startIndex, value); } void insertValueAsUInt8(const unsigned int startIndex, const unsigned char * const valuesPointer, const unsigned int numValues = 1, const unsigned int arrayStride = 1, const unsigned int valuesStride = 1) { $self->XdmfArray::insert(startIndex, valuesPointer, numValues, arrayStride, valuesStride); } void insertValueAsUInt8(const unsigned int startIndex, const unsigned char value) { $self->XdmfArray::insert(startIndex, value); } void insertValueAsUInt16(const unsigned int startIndex, const unsigned short * const valuesPointer, const unsigned int numValues = 1, const unsigned int arrayStride = 1, const unsigned int valuesStride = 1) { $self->XdmfArray::insert(startIndex, valuesPointer, numValues, arrayStride, valuesStride); } void insertValueAsUInt16(const unsigned int startIndex, const unsigned short value) { $self->XdmfArray::insert(startIndex, value); } void insertValueAsUInt32(const unsigned int startIndex, const unsigned int * const valuesPointer, const unsigned int numValues = 1, const unsigned int arrayStride = 1, const unsigned int valuesStride = 1) { $self->XdmfArray::insert(startIndex, (unsigned int *)(valuesPointer), numValues, arrayStride, valuesStride); } void insertValueAsUInt32(const unsigned int startIndex, const unsigned int value) { $self->XdmfArray::insert(startIndex, value); } void insertValueAsFloat32(const unsigned int startIndex, const float * const valuesPointer, const unsigned int numValues = 1, const unsigned int arrayStride = 1, const unsigned int valuesStride = 1) { $self->XdmfArray::insert(startIndex, (float *)(&valuesPointer), numValues, arrayStride, valuesStride); } void insertValueAsFloat32(const unsigned int startIndex, const float value) { $self->XdmfArray::insert(startIndex, value); } void insertValueAsFloat64(const unsigned int startIndex, const double * const valuesPointer, const unsigned int numValues = 1, const unsigned int arrayStride = 1, const unsigned int valuesStride = 1) { $self->XdmfArray::insert(startIndex, (double *)(valuesPointer), numValues, arrayStride, valuesStride); } void insertValueAsFloat64(const unsigned int startIndex, const double value) { $self->XdmfArray::insert(startIndex, value); } void insertValueAsString(const unsigned int startIndex, const char ** const valuesPointer, const unsigned int numValues = 1, const unsigned int arrayStride = 1, const unsigned int valuesStride = 1) { std::string * tempPointer = new std::string[numValues](); for (unsigned int i = 0; i < numValues; ++i) { tempPointer[i] = std::string(valuesPointer[i]); } $self->XdmfArray::insert(startIndex, (std::string *)(tempPointer), numValues, arrayStride, valuesStride); } void insertValueAsString(const unsigned int startIndex, const char * value) { $self->XdmfArray::insert(startIndex, std::string(value)); } }; /*This causes it to avoid throwing a warning for redefining fuctions that are defined for XdmfArray. I do this because doing so was intentional.*/ #pragma SWIG nowarn=302 /*Warning 325 is due to having nested classes in XdmfFunction that are not accessible when wrapped. As of right now, this is acceptable behavior. So, the warning is suppressed*/ #pragma SWIG nowarn=325 %extend XdmfFunction { %{ /*trying to transfer python functions*/ /*note, accessing private members is impossible from swig.*/ /*Class to wrap python functions to be compatible with the XdmfFunction code. This version has an execute that takes a vector of XdmfArrays as parameters, so it is used for functions.*/ class PythonFunction : public XdmfFunction::XdmfFunctionInternal { public: static shared_ptr New(PyObject * functionref) { shared_ptr p (new PythonFunction(functionref)); return p; } ~PythonFunction() { } virtual shared_ptr execute(std::vector > valueVector) { swig_type_info * paramType = SWIG_TypeQuery("_p_std__vectorT_boost__shared_ptrT_XdmfArray_t_std__allocatorT_boost__shared_ptrT_XdmfArray_t_t_t"); PyObject * pyVector = SWIG_NewPointerObj(static_cast(& valueVector), paramType, SWIG_POINTER_NEW); PyObject * args = PyTuple_New(1); /* In this case you could also cast a pointer to the vector into the PyObject * type, but that doesn't work for all types*/ PyTuple_SetItem(args, 0, pyVector); PyObject * resultObject = PyObject_CallObject(mInternalFunction, args); void * resultPointer = 0; swig_type_info * returnType = SWIG_TypeQuery("_p_boost__shared_ptrT_XdmfArray_t"); SWIG_ConvertPtr(resultObject, &resultPointer, returnType, 0); shared_ptr * returnArrayPointer = reinterpret_cast *>(resultPointer); shared_ptr returnArray = returnArrayPointer[0]; return returnArray; } private: PythonFunction(PyObject * functionref) { if (PyCallable_Check(functionref) == 1) { mInternalFunction = functionref; } else { XdmfError::message(XdmfError::FATAL, "Error: Function is not callable"); } } PyObject * mInternalFunction; }; /*Class to wrap python functions to be compatible with the XdmfFunction Operation code. This version has an execute that takes two XdmfArrays as parameters, so it is used for binary operators.*/ class PythonOperation : public XdmfFunction::XdmfOperationInternal { public: static shared_ptr New(PyObject * operationref) { shared_ptr p (new PythonOperation(operationref)); return p; } ~PythonOperation() { } virtual shared_ptr execute(shared_ptr val1, shared_ptr val2) { swig_type_info * paramType = SWIG_TypeQuery("_p_boost__shared_ptrT_XdmfArray_t"); PyObject * pyVal1 = SWIG_NewPointerObj(static_cast(& val1), paramType, SWIG_POINTER_NEW); PyObject * pyVal2 = SWIG_NewPointerObj(static_cast(& val2), paramType, SWIG_POINTER_NEW); PyObject * args = PyTuple_New(2); PyTuple_SetItem(args, 0, pyVal1); PyTuple_SetItem(args, 1, pyVal2); PyObject * resultObject = PyObject_CallObject(mInternalOperation, args); void * resultPointer = 0; swig_type_info * returnType = SWIG_TypeQuery("_p_boost__shared_ptrT_XdmfArray_t"); SWIG_ConvertPtr(resultObject, &resultPointer, returnType, 0); shared_ptr * returnArrayPointer = reinterpret_cast *>(resultPointer); shared_ptr returnArray = returnArrayPointer[0]; return returnArray; } private: PythonOperation(PyObject * operationref) { if (PyCallable_Check(operationref) == 1) { mInternalOperation = operationref; } else { XdmfError::message(XdmfError::FATAL, "Error: Operation is not callable"); } } PyObject * mInternalOperation; }; %} static int addFunction(std::string newName, PyObject * functionref) { shared_ptr newFunction = PythonFunction::New(functionref); return XdmfFunction::addFunction(newName, newFunction); } static int addOperation(char newName, PyObject * calcref, int priority) { shared_ptr newOperation = PythonOperation::New(calcref); return XdmfFunction::addOperation(newName, newOperation, priority); } }; #endif /* SWIGPYTHON */ %include boost_shared_ptr.i %inline %{ #include using namespace boost; %} %include std_string.i %include std_vector.i %include std_map.i %shared_ptr(Loki::BaseVisitor) %shared_ptr(Loki::BaseVisitable) %shared_ptr(Loki::Visitor) %shared_ptr(Loki::Visitor) %include loki/Visitor.h // Shared Pointer Templates %shared_ptr(XdmfArray) %shared_ptr(XdmfArrayReference) %shared_ptr(XdmfArrayType) %shared_ptr(XdmfCoreItemFactory) %shared_ptr(XdmfCoreReader) %shared_ptr(XdmfFunction) %shared_ptr(XdmfHDF5Controller) %shared_ptr(XdmfHDF5Writer) %shared_ptr(XdmfHeavyDataController) %shared_ptr(XdmfHeavyDataWriter) %shared_ptr(XdmfInformation) %shared_ptr(XdmfItem) %shared_ptr(XdmfItemProperty) %shared_ptr(XdmfSparseMatrix) %shared_ptr(XdmfSubset) %shared_ptr(XdmfTIFFController) %shared_ptr(XdmfVisitor) %shared_ptr(XdmfWriter) %shared_ptr(std::vector) // Abstract Base Classes %template(BaseVisitable) Loki::BaseVisitable; %template() Loki::Visitor; %template() Loki::Visitor; %include XdmfCore.hpp %include XdmfError.hpp %include XdmfItem.hpp %include XdmfItemProperty.hpp %include XdmfSparseMatrix.hpp %include XdmfSystemUtils.hpp %include XdmfVisitor.hpp %include XdmfArrayReference.hpp %include XdmfFunction.hpp %include XdmfHeavyDataController.hpp %include XdmfHeavyDataWriter.hpp %include XdmfSubset.hpp %include XdmfCoreItemFactory.hpp %include XdmfCoreReader.hpp %include XdmfInformation.hpp %include XdmfHDF5Controller.hpp %include XdmfHDF5Writer.hpp %include XdmfTIFFController.hpp %include XdmfWriter.hpp %include CMake/VersionSuite/ProjectVersion.hpp %include XdmfVersion.hpp %include XdmfArray.hpp %include XdmfArrayType.hpp #ifdef SWIGPYTHON %pythoncode { XdmfVersion = _XdmfCore.cvar.XdmfVersion }; #endif /* SWIGPYTHON */ %template(getValueAsInt8) XdmfArray::getValue; %template(getValueAsInt16) XdmfArray::getValue; %template(getValueAsInt32) XdmfArray::getValue; %template(getValueAsInt64) XdmfArray::getValue; %template(getValueAsFloat32) XdmfArray::getValue; %template(getValueAsFloat64) XdmfArray::getValue; %template(getValueAsUInt8) XdmfArray::getValue; %template(getValueAsUInt16) XdmfArray::getValue; %template(getValueAsUInt32) XdmfArray::getValue; %template(getValueAsString) XdmfArray::getValue; %template(initializeAsInt8) XdmfArray::initialize; %template(initializeAsInt16) XdmfArray::initialize; %template(initializeAsInt32) XdmfArray::initialize; %template(initializeAsInt64) XdmfArray::initialize; %template(initializeAsFloat32) XdmfArray::initialize; %template(initializeAsFloat64) XdmfArray::initialize; %template(initializeAsUInt8) XdmfArray::initialize; %template(initializeAsUInt16) XdmfArray::initialize; %template(initializeAsUInt32) XdmfArray::initialize; %template(initializeAsString) XdmfArray::initialize; %template(insertValueAsInt8) XdmfArray::insert; %template(insertValueAsInt16) XdmfArray::insert; %template(insertValueAsInt32) XdmfArray::insert; %template(insertValueAsInt64) XdmfArray::insert; %template(insertValueAsFloat32) XdmfArray::insert; %template(insertValueAsFloat64) XdmfArray::insert; %template(insertValueAsUInt8) XdmfArray::insert; %template(insertValueAsUInt16) XdmfArray::insert; %template(insertValueAsUInt32) XdmfArray::insert; %template(insertValueAsString) XdmfArray::insert; %template(pushBackAsInt8) XdmfArray::pushBack; %template(pushBackAsInt16) XdmfArray::pushBack; %template(pushBackAsInt32) XdmfArray::pushBack; %template(pushBackAsInt64) XdmfArray::pushBack; %template(pushBackAsFloat32) XdmfArray::pushBack; %template(pushBackAsFloat64) XdmfArray::pushBack; %template(pushBackAsUInt8) XdmfArray::pushBack; %template(pushBackAsUInt16) XdmfArray::pushBack; %template(pushBackAsUInt32) XdmfArray::pushBack; %template(pushBackAsString) XdmfArray::pushBack; %template(resizeAsInt8) XdmfArray::resize; %template(resizeAsInt16) XdmfArray::resize; %template(resizeAsInt32) XdmfArray::resize; %template(resizeAsInt64) XdmfArray::resize; %template(resizeAsFloat32) XdmfArray::resize; %template(resizeAsFloat64) XdmfArray::resize; %template(resizeAsUInt8) XdmfArray::resize; %template(resizeAsUInt16) XdmfArray::resize; %template(resizeAsUInt32) XdmfArray::resize; %template(resizeAsString) XdmfArray::resize; %template(UInt8Vector) std::vector; %template(UInt16Vector) std::vector; %template(UInt32Vector) std::vector; %template(Int8Vector) std::vector; %template(Int16Vector) std::vector; %template(Int32Vector) std::vector; %template(Int64Vector) std::vector; %template(Float32Vector) std::vector; %template(Float64Vector) std::vector; %template(StringVector) std::vector; %template(ItemVector) std::vector >; %template(HeavyControllerVector) std::vector >; %template(ArrayMap) std::map >; %template(StringMap) std::map; %template(DSMStructreVector) std::vector >; %template(DSMApplicationPair) std::pair; xdmf-3.0+git20160803/core/XdmfHDF5Writer.hpp0000640000175000017500000003521313003006557020241 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfHDF5Writer.hpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef XDMFHDF5WRITER_HPP_ #define XDMFHDF5WRITER_HPP_ // C Compatible includes #include "XdmfCore.hpp" #include "XdmfHeavyDataWriter.hpp" #include "XdmfHeavyDataController.hpp" // So that hdf5 does not need to be included in the header files // It would add a dependancy to programs that use Xdmf #ifndef _H5Ipublic_H #ifndef XDMF_HID_T #define XDMF_HID_T typedef int hid_t; #endif #endif #ifdef __cplusplus // Forward Declarations class XdmfArray; class XdmfArrayType; class XdmfHDF5Controller; // Includes #include #include /** * @brief Traverse the Xdmf graph and write heavy data stored in * XdmfArrays to HDF5 on disk. * * XdmfHDF5Writer traverses an Xdmf graph structure and writes data * stored in XdmfArrays to HDF5. Writing begins by calling the * accept() operation on any XdmfItem and supplying this writer as the * parameter. The writer will write all XdmfArrays under the XdmfItem * to an hdf5 file on disk. It will also attach an XdmfHDF5Controller * to all XdmfArrays that it writes to disk. * * This writer supports all heavy data writing modes listed in * XdmfHeavyDataWriter. */ class XDMFCORE_EXPORT XdmfHDF5Writer : public XdmfHeavyDataWriter { public: /** * Construct XdmfHDF5Writer. * * Example of use: * * C++ * * @dontinclude ExampleXdmfHDF5Writer.cpp * @skipline //#initialization * @until //#initialization * * Python * * @dontinclude XdmfExampleHDF5Writer.py * @skipline #//initialization * @until #//initialization * * @param filePath The location of the hdf5 file to output to on disk. * @param clobberFile Whether to overwrite the previous file if it exists. * * @return New XdmfHDF5Writer. */ static shared_ptr New(const std::string & filePath, const bool clobberFile = false); virtual ~XdmfHDF5Writer(); virtual void closeFile(); /** * Get the chunk size used to output datasets to hdf5. * * C++ * * @dontinclude ExampleXdmfHDF5Writer.cpp * @skipline //#initialization * @until //#initialization * @skipline //#getChunkSize * @until //#getChunkSize * * Python * * @dontinclude XdmfExampleHDF5Writer.py * @skipline #//initialization * @until #//initialization * @skipline #//getChunkSize * @until #//getChunkSize * * @return Chunk size used to output datasets to hdf5. */ unsigned int getChunkSize() const; virtual int getDataSetSize(const std::string & fileName, const std::string & dataSetName); /** * Gets the factor that Deflate uses to compress data. * * Example of use: * * C++ * * @dontinclude ExampleXdmfHDF5Writer.cpp * @skipline //#initialization * @until //#initialization * @skipline //#getDeflateFactor * @until //#getDeflateFactor * * Python * * @dontinclude XdmfExampleHDF5Writer.py * @skipline #//initialization * @until #//initialization * @skipline #//getDeflateFactor * @until #//getDeflateFactor * * @return The factor Deflate uses. */ int getDeflateFactor() const; /** * Gets whether Deflate is enabled. * * Example of use: * * C++ * * @dontinclude ExampleXdmfHDF5Writer.cpp * @skipline //#initialization * @until //#initialization * @skipline //#getUseDeflate * @until //#getUseDeflate * * Python * * @dontinclude XdmfExampleHDF5Writer.py * @skipline #//initialization * @until #//initialization * @skipline #//getUseDeflate * @until #//getUseDeflate * * @return Whether Deflate is in use. */ bool getUseDeflate() const; virtual void openFile(); /** * Set the chunk size used to output datasets to hdf5. For * multidimensional datasets the chunk size is the total number of * elements in the chunk. * * C++ * * @dontinclude ExampleXdmfHDF5Writer.cpp * @skipline //#initialization * @until //#initialization * @skipline //#setChunkSize * @until //#setChunkSize * * Python * * @dontinclude XdmfExampleHDF5Writer.py * @skipline #//initialization * @until #//initialization * @skipline #//setChunkSize * @until #//setChunkSize * * @param chunkSize The number of elements per chunk. */ void setChunkSize(const unsigned int chunkSize); /** * Sets the factor that Deflate will use to compress data. * * Example of use: * * C++ * * @dontinclude ExampleXdmfHDF5Writer.cpp * @skipline //#initialization * @until //#initialization * @skipline //#setDeflateFactor * @until //#setDeflateFactor * * Python * * @dontinclude XdmfExampleHDF5Writer.py * @skipline #//initialization * @until #//initialization * @skipline #//setDeflateFactor * @until #//setDeflateFactor * * @param factor The factor Deflate will use. */ void setDeflateFactor(int factor); /** * Sets whether HDF5 will use Deflate compression * * Example of use: * * C++ * * @dontinclude ExampleXdmfHDF5Writer.cpp * @skipline //#initialization * @until //#initialization * @skipline //#setUseDeflate * @until //#setUseDeflate * * Python * * @dontinclude XdmfExampleHDF5Writer.py * @skipline #//initialization * @until #//initialization * @skipline #//setUseDeflate * @until #//setUseDeflate * * @param status Whether Deflate will be used. */ void setUseDeflate(bool status); using XdmfHeavyDataWriter::visit; virtual void visit(XdmfArray & array, const shared_ptr visitor); virtual void visit(XdmfItem & item, const shared_ptr visitor); XdmfHDF5Writer(const XdmfHDF5Writer &); protected: XdmfHDF5Writer(const std::string & filePath); /** * Create a new HDF5 Controller that is able to read in after being * written by this writer. * * @param hdf5FilePath the location of the hdf5 file the data set resides in. * @param dataSetPath the location of the dataset within the hdf5 file. * @param type the data type of the dataset to read. * @param start the offset of the starting element in each dimension in * the hdf5 data set. * @param stride the number of elements to move in each dimension from the * hdf5 data set. * @param dimensions the number of elements to select in each * dimension from the hdf5 data set. (size in each dimension) * @param dataspaceDimensions the number of elements in the entire * hdf5 data set (may be larger that dimensions if using * hyperslabs). * * @return new HDF5 Controller. */ virtual shared_ptr createController(const std::string & hdf5FilePath, const std::string & descriptor, const shared_ptr type, const std::vector & start, const std::vector & stride, const std::vector & dimensions, const std::vector & dataspaceDimensions); virtual int getDataSetSize(shared_ptr descriptionController); /** * Write the XdmfArray to a hdf5 file. * * @param array An XdmfArray to write to hdf5. */ virtual void write(XdmfArray & array); /** * PIMPL */ class XdmfHDF5WriterImpl { public: XdmfHDF5WriterImpl(); virtual ~XdmfHDF5WriterImpl(); virtual void closeFile(); virtual int openFile(const std::string & filePath, const int mDataSetId); hid_t mHDF5Handle; int mFapl; unsigned int mChunkSize; std::string mOpenFile; int mDepth; std::set mWrittenItems; }; XdmfHDF5WriterImpl * mImpl; bool mUseDeflate; int mDeflateFactor; private: void operator=(const XdmfHDF5Writer &); // Not implemented. virtual void controllerSplitting(XdmfArray & array, int & controllerIndexOffset, shared_ptr heavyDataController, const std::string & checkFileName, const std::string & checkFileExt, const std::string & dataSetPath, int dataSetId, const std::vector & dimensions, const std::vector & dataspaceDimensions, const std::vector & start, const std::vector & stride, std::list & filesWritten, std::list & datasetsWritten, std::list & datasetIdsWritten, std::list & arraysWritten, std::list > & startsWritten, std::list > & stridesWritten, std::list > & dimensionsWritten, std::list > & dataSizesWritten, std::list & arrayOffsetsWritten); }; #endif #ifdef __cplusplus extern "C" { #endif // C wrappers go here struct XDMFHDF5WRITER; // Simply as a typedef to ensure correct typing typedef struct XDMFHDF5WRITER XDMFHDF5WRITER; XDMFCORE_EXPORT XDMFHDF5WRITER * XdmfHDF5WriterNew(char * fileName, int clobberFile); XDMFCORE_EXPORT void XdmfHDF5WriterCloseFile(XDMFHDF5WRITER * writer, int * status); XDMFCORE_EXPORT unsigned int XdmfHDF5WriterGetChunkSize(XDMFHDF5WRITER * writer, int * status); XDMFCORE_EXPORT void XdmfHDF5WriterOpenFile(XDMFHDF5WRITER * writer, int * status); XDMFCORE_EXPORT void XdmfHDF5WriterSetChunkSize(XDMFHDF5WRITER * writer, unsigned int chunkSize, int * status); #define XDMF_HDF5WRITER_C_CHILD_DECLARE(ClassName, CClassName, Level) \ \ Level##_EXPORT void ClassName##CloseFile( CClassName * writer, int * status); \ Level##_EXPORT unsigned int ClassName##GetChunkSize( CClassName * writer, int * status); \ Level##_EXPORT void ClassName##OpenFile( CClassName * writer, int * status); \ Level##_EXPORT void ClassName##SetChunkSize( CClassName * writer, unsigned int chunkSize, int * status); #define XDMF_HDF5WRITER_C_CHILD_WRAPPER(ClassName, CClassName) \ \ void ClassName##CloseFile( CClassName * writer, int * status) \ { \ XdmfHDF5WriterCloseFile((XDMFHDF5WRITER *)((void *)writer), status); \ } \ \ unsigned int ClassName##GetChunkSize( CClassName * writer, int * status) \ { \ return XdmfHDF5WriterGetChunkSize((XDMFHDF5WRITER *)((void *)writer), status); \ } \ \ void ClassName##OpenFile( CClassName * writer, int * status) \ { \ XdmfHDF5WriterOpenFile((XDMFHDF5WRITER *)((void *)writer), status); \ } \ \ void ClassName##SetChunkSize( CClassName * writer, unsigned int chunkSize, int * status) \ { \ XdmfHDF5WriterSetChunkSize((XDMFHDF5WRITER *)((void *)writer), chunkSize, status); \ } // C Wrappers for parent classes are generated by macros XDMF_HEAVYWRITER_C_CHILD_DECLARE(XdmfHDF5Writer, XDMFHDF5WRITER, XDMFCORE) #ifdef __cplusplus } #endif #endif /* XDMFHDF5WRITER_HPP_ */ xdmf-3.0+git20160803/core/XdmfTIFFController.hpp0000640000175000017500000001727313003006557021160 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfTIFFController.hpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef XDMFTIFFCONTROLLER_HPP_ #define XDMFTIFFCONTROLLER_HPP_ // C Compatible Includes #include "XdmfCore.hpp" #include "XdmfHeavyDataController.hpp" #ifdef __cplusplus /** * @brief Couples an XdmfArray with TIFF data stored on disk. * * Serves as an interface between data stored in XdmfArrays and data * stored in tiff files on disk. When an Xdmf file is read from or * written to disk an XdmfTIFFController is attached to * XdmfArrays. This allows data to be released from memory but still * be accessible or have its location written to light data. */ class XDMFCORE_EXPORT XdmfTIFFController : public XdmfHeavyDataController { public: virtual ~XdmfTIFFController(); /** * Create a new controller for an TIFF file on disk. * * Example of use: * * C++ * * @dontinclude ExampleXdmfTIFFController.cpp * @skipline //#initializationsimplified * @until //#initializationsimplified * * Python * * @dontinclude XdmfExampleTIFFController.py * @skipline #//initializationsimplified * @until #//initializationsimplified * * @param filePath The location of the tiff file the data * set resides in. * @param type The data type of the dataset to read. * @param dimensions The number of elements to select in each * dimension from the data set. * (size in each dimension) * * @return New TIFF Controller. */ static shared_ptr New(const std::string & filePath, const shared_ptr & type, const std::vector & dimensions); /** * Create a new controller for an TIFF file on disk. * * Example of use: * * C++ * * @dontinclude ExampleXdmfTIFFController.cpp * @skipline //#initialization * @until //#initialization * * Python * * @dontinclude XdmfExampleTIFFController.py * @skipline #//initialization * @until #//initialization * * @param filePath The location of the tiff file the data set resides in. * @param type The data type of the dataset to read. * @param starts The offset of the starting element in each * dimension in the data set. * @param strides The number of elements to move in each * dimension from the data set. * @param dimensions The number of elements to select in each * dimension from the data set. * (size in each dimension) * @param dataspaces The number of elements in the entire * data set (may be larger than * dimensions if using hyperslabs). * * @return New TIFF Controller. */ static shared_ptr New(const std::string & filePath, const shared_ptr & type, const std::vector & starts, const std::vector & strides, const std::vector & dimensions, const std::vector & dataspaces); virtual std::string getName() const; virtual void getProperties(std::map & collectedProperties) const; virtual void read(XdmfArray * const array); XdmfTIFFController(const XdmfTIFFController &); protected: XdmfTIFFController(const std::string & filePath, const shared_ptr & type, const std::vector & starts, const std::vector & strides, const std::vector & dimensions, const std::vector & dataspaces); virtual shared_ptr createSubController(const std::vector & starts, const std::vector & strides, const std::vector & dimensions); unsigned int getNumberDirectories() const; void readToArray(XdmfArray * const array, void * pointer, unsigned int offset, unsigned int start, unsigned int stride, unsigned int amount, shared_ptr type); private: void operator=(const XdmfTIFFController &); // Not implemented. }; #endif #ifdef __cplusplus extern "C" { #endif struct XDMFTIFFCONTROLLER; // Simply as a typedef to ensure correct typing typedef struct XDMFTIFFCONTROLLER XDMFTIFFCONTROLLER; XDMFCORE_EXPORT XDMFTIFFCONTROLLER * XdmfTIFFControllerNew(char * filePath, int type, unsigned int * dimensions, unsigned int numDims, int * status); XDMFCORE_EXPORT XDMFTIFFCONTROLLER * XdmfTIFFControllerNewHyperslab(char * filePath, int type, unsigned int * starts, unsigned int * strides, unsigned int * dimensions, unsigned int * dataspaces, unsigned int numDims, int * status); XDMF_HEAVYCONTROLLER_C_CHILD_DECLARE(XdmfTIFFController, XDMFTIFFCONTROLLER, XDMFCORE) #ifdef __cplusplus } #endif #endif /* XDMFTIFFCONTROLLER_HPP_ */ xdmf-3.0+git20160803/core/XdmfSharedPtr.hpp0000640000175000017500000000513013003006557020245 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfSharedPtr.hpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef XDMFSHAREDPTR_HPP_ #define XDMFSHAREDPTR_HPP_ #ifdef __cplusplus #include "XdmfCoreConfig.hpp" #include using boost::shared_ptr; #ifdef HAVE_BOOST_SHARED_DYNAMIC_CAST using boost::shared_dynamic_cast; #else template shared_ptr shared_dynamic_cast(shared_ptr const & r) { typedef typename shared_ptr::element_type E; E * p = dynamic_cast< E* >( r.get() ); return p? shared_ptr( r, p ): shared_ptr(); } #endif /* HAVE_BOOST_SHARED_DYNAMIC_CAST */ // Used by C wrappers to prevent shared pointers from prematurely deleting objects // Normally this would be completely against the point of shared pointers, // but the C wrapping requires that objects be seperated from the shared pointers. struct XdmfNullDeleter { template void operator()(T*) {} }; #endif #endif /* XDMFSHAREDPTR_HPP_ */ xdmf-3.0+git20160803/core/XdmfInformation.cpp0000640000175000017500000001776313003006557020650 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfInformation.cpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #include #include "string.h" #include "XdmfArray.hpp" #include "XdmfError.hpp" #include "XdmfInformation.hpp" XDMF_CHILDREN_IMPLEMENTATION(XdmfInformation, XdmfArray, Array, Name) shared_ptr XdmfInformation::New() { shared_ptr p(new XdmfInformation()); return p; } shared_ptr XdmfInformation::New(const std::string & key, const std::string & value) { shared_ptr p(new XdmfInformation(key, value)); return p; } XdmfInformation::XdmfInformation(const std::string & key, const std::string & value) : mKey(key), mValue(value) { } XdmfInformation::XdmfInformation(XdmfInformation & refInfo) : XdmfItem(refInfo), mArrays(refInfo.mArrays) { mKey = refInfo.getKey(); mValue = refInfo.getValue(); } XdmfInformation::~XdmfInformation() { } const std::string XdmfInformation::ItemTag = "Information"; std::map XdmfInformation::getItemProperties() const { std::map informationProperties; informationProperties.insert(std::make_pair("Name", mKey)); informationProperties.insert(std::make_pair("Value", mValue)); return informationProperties; } std::string XdmfInformation::getItemTag() const { return ItemTag; } std::string XdmfInformation::getKey() const { return mKey; } std::string XdmfInformation::getValue() const { return mValue; } void XdmfInformation::populateItem(const std::map & itemProperties, const std::vector > & childItems, const XdmfCoreReader * const reader) { XdmfItem::populateItem(itemProperties, childItems, reader); std::map::const_iterator key = itemProperties.find("Name"); if(key != itemProperties.end()) { mKey = key->second; } else { XdmfError::message(XdmfError::FATAL, "'Name' not found in itemProperties in " "XdmfInformation::populateItem"); } std::map::const_iterator value = itemProperties.find("Value"); if(value != itemProperties.end()) { mValue = value->second; } else { value = itemProperties.find("Content"); if(value != itemProperties.end()) { mValue = value->second; } else { XdmfError::message(XdmfError::FATAL, "'Value' not found in itemProperties in " "XdmfInformation::populateItem"); } } for(std::vector >::const_iterator iter = childItems.begin(); iter != childItems.end(); ++iter) { if(shared_ptr array = shared_dynamic_cast(*iter)) { this->insert(array); } } } void XdmfInformation::setKey(const std::string & key) { mKey = key; this->setIsChanged(true); } void XdmfInformation::setValue(const std::string & value) { mValue = value; this->setIsChanged(true); } void XdmfInformation::traverse(const shared_ptr visitor) { XdmfItem::traverse(visitor); for (unsigned int i = 0; i < mArrays.size(); ++i) { mArrays[i]->accept(visitor); } } // C Wrappers XDMFINFORMATION * XdmfInformationNew(char * key, char * value) { try { std::string createKey(key); std::string createValue(value); shared_ptr generatedInfo = XdmfInformation::New(createKey, createValue); return (XDMFINFORMATION *)((void *)(new XdmfInformation(*generatedInfo.get()))); } catch (...) { std::string createKey(key); std::string createValue(value); shared_ptr generatedInfo = XdmfInformation::New(createKey, createValue); return (XDMFINFORMATION *)((void *)(new XdmfInformation(*generatedInfo.get()))); } } XDMFARRAY * XdmfInformationGetArray(XDMFINFORMATION * information, unsigned int index) { return (XDMFARRAY *)((void *)(((XdmfInformation *)(information))->getArray(index).get())); } XDMFARRAY * XdmfInformationGetArrayByName(XDMFINFORMATION * information, char * name) { return (XDMFARRAY *)((void *)(((XdmfInformation *)(information))->getArray(name).get())); } char * XdmfInformationGetKey(XDMFINFORMATION * information) { try { XdmfInformation referenceInfo = *(XdmfInformation *)(information); char * returnPointer = strdup(referenceInfo.getKey().c_str()); return returnPointer; } catch (...) { XdmfInformation referenceInfo = *(XdmfInformation *)(information); char * returnPointer = strdup(referenceInfo.getKey().c_str()); return returnPointer; } } unsigned int XdmfInformationGetNumberArrays(XDMFINFORMATION * information) { return ((XdmfInformation *)(information))->getNumberArrays(); } char * XdmfInformationGetValue(XDMFINFORMATION * information) { try { XdmfInformation referenceInfo = *(XdmfInformation *)(information); char * returnPointer = strdup(referenceInfo.getValue().c_str()); return returnPointer; } catch (...) { XdmfInformation referenceInfo = *(XdmfInformation *)(information); char * returnPointer = strdup(referenceInfo.getValue().c_str()); return returnPointer; } } void XdmfInformationInsertArray(XDMFINFORMATION * information, XDMFARRAY * array, int transferOwnership) { if (transferOwnership) { ((XdmfInformation *)(information))->insert(shared_ptr((XdmfArray *)array)); } else { ((XdmfInformation *)(information))->insert(shared_ptr((XdmfArray *)array, XdmfNullDeleter())); } } void XdmfInformationRemoveArray(XDMFINFORMATION * information, unsigned int index) { ((XdmfInformation *)(information))->removeArray(index); } void XdmfInformationRemoveArrayByName(XDMFINFORMATION * information, char * name) { ((XdmfInformation *)(information))->removeArray(name); } void XdmfInformationSetKey(XDMFINFORMATION * information, char * key, int * status) { XDMF_ERROR_WRAP_START(status) ((XdmfInformation *)(information))->setKey(key); XDMF_ERROR_WRAP_END(status) } void XdmfInformationSetValue(XDMFINFORMATION * information, char * value, int * status) { XDMF_ERROR_WRAP_START(status) ((XdmfInformation *)(information))->setValue(value); XDMF_ERROR_WRAP_END(status) } // C Wrappers for parent classes are generated by macros XDMF_ITEM_C_CHILD_WRAPPER(XdmfInformation, XDMFINFORMATION) xdmf-3.0+git20160803/core/XdmfSparseMatrix.cpp0000640000175000017500000002744113003006557020777 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfSparseMatrix.cpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #include #include #include "string.h" #include "XdmfSparseMatrix.hpp" #include "XdmfError.hpp" shared_ptr XdmfSparseMatrix::New(const unsigned int numberRows, const unsigned int numberColumns) { shared_ptr p(new XdmfSparseMatrix(numberRows, numberColumns)); return p; } XdmfSparseMatrix::XdmfSparseMatrix(const unsigned int numberRows, const unsigned int numberColumns) : mColumnIndex(XdmfArray::New()), mName(""), mNumberColumns(numberColumns), mNumberRows(numberRows), mRowPointer(XdmfArray::New()), mValues(XdmfArray::New()) { mRowPointer->resize(mNumberRows + 1, 0); } XdmfSparseMatrix::XdmfSparseMatrix(XdmfSparseMatrix & matrixRef) : XdmfItem(matrixRef), mColumnIndex(matrixRef.getColumnIndex()), mName(matrixRef.getName()), mNumberColumns(matrixRef.getNumberColumns()), mNumberRows(matrixRef.getNumberRows()), mRowPointer(matrixRef.getRowPointer()), mValues(matrixRef.getValues()) { } XdmfSparseMatrix::~XdmfSparseMatrix() { } const std::string XdmfSparseMatrix::ItemTag = "SparseMatrix"; shared_ptr XdmfSparseMatrix::getColumnIndex() { return mColumnIndex; } std::map XdmfSparseMatrix::getItemProperties() const { std::map sparseMatrixProperties; sparseMatrixProperties.insert(std::make_pair("Name", mName)); std::stringstream numberRowsString; numberRowsString << mNumberRows; sparseMatrixProperties.insert(std::make_pair("NumberRows", numberRowsString.str())); std::stringstream numberColumnsString; numberColumnsString << mNumberColumns; sparseMatrixProperties.insert(std::make_pair("NumberColumns", numberColumnsString.str())); return sparseMatrixProperties; } std::string XdmfSparseMatrix::getItemTag() const { return ItemTag; } std::string XdmfSparseMatrix::getName() const { if (mName.c_str() == NULL) { return ""; } else { return mName; } } unsigned int XdmfSparseMatrix::getNumberColumns() const { return mNumberColumns; } unsigned int XdmfSparseMatrix::getNumberRows() const { return mNumberRows; } shared_ptr XdmfSparseMatrix::getRowPointer() { return mRowPointer; } shared_ptr XdmfSparseMatrix::getValues() { return mValues; } std::string XdmfSparseMatrix::getValuesString() const { std::stringstream toReturn; for(unsigned int i=0; igetValue(i) > mRowPointer->getValue(i+1)) { XdmfError::message(XdmfError::FATAL, "Error: getValuesString(), Sparse Matrix Row Pointer is not sorted."); } } unsigned int index = 0; for(unsigned int j=mRowPointer->getValue(i); jgetValue(i+1); ++j) { const unsigned int k = mColumnIndex->getValue(j); while(index++ < k) { toReturn << "0.0, "; } toReturn << mValues->getValue(j) << ", "; } while(index++ < mNumberColumns) { toReturn << "0.0, "; } toReturn << std::endl; } return toReturn.str(); } void XdmfSparseMatrix::populateItem(const std::map & itemProperties, const std::vector > & childItems, const XdmfCoreReader * const reader) { XdmfItem::populateItem(itemProperties, childItems, reader); std::map::const_iterator name = itemProperties.find("Name"); if(name != itemProperties.end()) { mName = name->second; } else { XdmfError::message(XdmfError::FATAL, "'Name' not found in itemProperties in " "XdmfSparseMatrix::populateItem"); } std::map::const_iterator numberRows = itemProperties.find("NumberRows"); if(numberRows != itemProperties.end()) { mNumberRows = std::atoi(numberRows->second.c_str()); } else { XdmfError::message(XdmfError::FATAL, "'NumberRows' not found in itemProperties in " "XdmfSparseMatrix::populateItem"); } std::map::const_iterator numberColumns = itemProperties.find("NumberColumns"); if(numberColumns != itemProperties.end()) { mNumberColumns = std::atoi(numberColumns->second.c_str()); } else { XdmfError::message(XdmfError::FATAL, "'NumberColumns' not found in itemProperties in " "XdmfSparseMatrix::populateItem"); } std::vector > arrayVector; arrayVector.reserve(3); for(std::vector >::const_iterator iter = childItems.begin(); iter != childItems.end(); ++iter) { if(shared_ptr array = shared_dynamic_cast(*iter)) { arrayVector.push_back(array); } } if(arrayVector.size() < 3) { // The three required arrays are for // the row pointer, column index, and the contained values. // Without these arrays the object can't be properly built. XdmfError::message(XdmfError::FATAL, "Expected 3 arrays attached to " "XdmfSparseMatrix::populateItem"); } mRowPointer = arrayVector[0]; mColumnIndex = arrayVector[1]; mValues = arrayVector[2]; } void XdmfSparseMatrix::setColumnIndex(const shared_ptr columnIndex) { mColumnIndex = columnIndex; this->setIsChanged(true); } void XdmfSparseMatrix::setName(const std::string & name) { mName = name; this->setIsChanged(true); } void XdmfSparseMatrix::setRowPointer(const shared_ptr rowPointer) { mRowPointer = rowPointer; this->setIsChanged(true); } void XdmfSparseMatrix::setValues(const shared_ptr values) { mValues = values; this->setIsChanged(true); } void XdmfSparseMatrix::traverse(const shared_ptr visitor) { XdmfItem::traverse(visitor); mRowPointer->accept(visitor); mColumnIndex->accept(visitor); mValues->accept(visitor); } // C Wrappers XDMFSPARSEMATRIX * XdmfSparseMatrixNew(unsigned int numberRows, unsigned int numberColumns) { try { shared_ptr generatedMatrix = XdmfSparseMatrix::New(numberRows, numberColumns); return (XDMFSPARSEMATRIX *)((void *)(new XdmfSparseMatrix(*generatedMatrix.get()))); } catch (...) { shared_ptr generatedMatrix = XdmfSparseMatrix::New(numberRows, numberColumns); return (XDMFSPARSEMATRIX *)((void *)(new XdmfSparseMatrix(*generatedMatrix.get()))); } } XDMFARRAY * XdmfSparseMatrixGetColumnIndex(XDMFSPARSEMATRIX * matrix, int * status) { XDMF_ERROR_WRAP_START(status) return (XDMFARRAY *)((void *)(((XdmfSparseMatrix *)(matrix))->getColumnIndex().get())); XDMF_ERROR_WRAP_END(status) return NULL; } char * XdmfSparseMatrixGetName(XDMFSPARSEMATRIX * matrix) { try { char * returnPointer= strdup(((XdmfSparseMatrix *)(matrix))->getName().c_str()); return returnPointer; } catch (...) { char * returnPointer= strdup(((XdmfSparseMatrix *)(matrix))->getName().c_str()); return returnPointer; } } unsigned int XdmfSparseMatrixGetNumberColumns(XDMFSPARSEMATRIX * matrix) { return ((XdmfSparseMatrix *)matrix)->getNumberColumns(); } unsigned int XdmfSparseMatrixGetNumberRows(XDMFSPARSEMATRIX * matrix) { return ((XdmfSparseMatrix *)matrix)->getNumberRows(); } XDMFARRAY * XdmfSparseMatrixGetRowPointer(XDMFSPARSEMATRIX * matrix, int * status) { XDMF_ERROR_WRAP_START(status) return (XDMFARRAY *)((void *)(((XdmfSparseMatrix *)(matrix))->getRowPointer().get())); XDMF_ERROR_WRAP_END(status) return NULL; } XDMFARRAY * XdmfSparseMatrixGetValues(XDMFSPARSEMATRIX * matrix, int * status) { XDMF_ERROR_WRAP_START(status) return (XDMFARRAY *)((void *)(((XdmfSparseMatrix *)(matrix))->getValues().get())); XDMF_ERROR_WRAP_END(status) return NULL; } char * XdmfSparseMatrixGetValuesString(XDMFSPARSEMATRIX * matrix, int * status) { XDMF_ERROR_WRAP_START(status) try { char * returnPointer = strdup(((XdmfSparseMatrix *)(matrix))->getValuesString().c_str()); return returnPointer; } catch (...) { char * returnPointer = strdup(((XdmfSparseMatrix *)(matrix))->getValuesString().c_str()); return returnPointer; } XDMF_ERROR_WRAP_END(status) return NULL; } void XdmfSparseMatrixSetColumnIndex(XDMFSPARSEMATRIX * matrix, XDMFARRAY * columnIndex, int passControl, int * status) { XDMF_ERROR_WRAP_START(status) if (passControl) { ((XdmfSparseMatrix *)(matrix))->setColumnIndex(shared_ptr((XdmfArray *)columnIndex)); } else { ((XdmfSparseMatrix *)(matrix))->setColumnIndex(shared_ptr((XdmfArray *)columnIndex, XdmfNullDeleter())); } XDMF_ERROR_WRAP_END(status) } void XdmfSparseMatrixSetName(XDMFSPARSEMATRIX * matrix, char * name, int * status) { XDMF_ERROR_WRAP_START(status) ((XdmfSparseMatrix *)matrix)->setName(std::string(name)); XDMF_ERROR_WRAP_END(status) } void XdmfSparseMatrixSetRowPointer(XDMFSPARSEMATRIX * matrix, XDMFARRAY * rowPointer, int passControl, int * status) { XDMF_ERROR_WRAP_START(status) if (passControl) { ((XdmfSparseMatrix *)(matrix))->setRowPointer(shared_ptr((XdmfArray *)rowPointer)); } else { ((XdmfSparseMatrix *)(matrix))->setRowPointer(shared_ptr((XdmfArray *)rowPointer, XdmfNullDeleter())); } XDMF_ERROR_WRAP_END(status) } void XdmfSparseMatrixSetValues(XDMFSPARSEMATRIX * matrix, XDMFARRAY * values, int passControl, int * status) { XDMF_ERROR_WRAP_START(status) if (passControl) { ((XdmfSparseMatrix *)(matrix))->setValues(shared_ptr((XdmfArray *)values)); } else { ((XdmfSparseMatrix *)(matrix))->setValues(shared_ptr((XdmfArray *)values, XdmfNullDeleter())); } XDMF_ERROR_WRAP_END(status) } // C Wrappers for parent classes are generated by macros XDMF_ITEM_C_CHILD_WRAPPER(XdmfSparseMatrix, XDMFSPARSEMATRIX) xdmf-3.0+git20160803/core/XdmfArray.hpp0000640000175000017500000026235113003006557017441 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfArray.hpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef XDMFARRAY_HPP_ #define XDMFARRAY_HPP_ // C Compatible Includes #include "XdmfCore.hpp" #include "XdmfArrayReference.hpp" #include "XdmfHeavyDataController.hpp" #include "XdmfItem.hpp" #ifdef __cplusplus // Forward Declarations class XdmfArrayType; class XdmfHeavyDataController; // Includes #include #include /** * @brief Provides storage for data values that are read in or will be * written to heavy data on disk. * * XdmfArray provides a single interface for storing a variety of data * types. The data type stored is determined by the type initially * inserted into the array. An array can be initialized with a * specific data type before insertion of values by calling * initialize(). * * An XdmfArray is associated with heavy data files on disk through an * XdmfHeavyDataController. When an Xdmf file is read from disk, * XdmfHeavyDataControllers are attached to all created XdmfArrays * that contain values stored in heavy data. These values are not read * into memory when the Xdmf file is parsed. The array is * uninitialized and the return value of isInitialized() is false. In * order to read the heavy data values into memory, read() must be * called. This will cause the array to ask for values to be read from * disk using the XdmfHeavyDataController. After the values have been * read from heavy data on disk, isInitialized() will return true. * * This version of Xdmf allows for multiple controllers to be added to * a single array. Be aware that doing this makes the files written * incompatible with previous editions. * * XdmfArray allows for insertion and retrieval of data in two * fundamental ways: * * By Copy: * * getValue * getValues * insert * pushBack * * XdmfArray stores its own copy of the data. Modifications to the * data stored in the XdmfArray will not change values stored in the * original array. * * By Shared Reference: * * getValuesInternal * setValuesInternal * * XdmfArray shares a reference to the data. No copy is * made. XdmfArray holds a shared pointer to the original data. * Modifications to the data stored in the XdmfArray also causes * modification to values stored in the original array. * * Xdmf supports the following datatypes: * Int8 * Int16 * Int32 * Int64 * Float32 * Float64 * UInt8 * UInt16 * UInt32 * String */ class XDMFCORE_EXPORT XdmfArray : public XdmfItem { public: enum ReadMode { Controller, Reference }; /** * Create a new XdmfArray. * * Example of use: * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * * Python * * @dontinclude XdmfExampleArray.py * @skipline #//initialization * @until #//initialization * * @return Constructed XdmfArray. */ static shared_ptr New(); virtual ~XdmfArray(); LOKI_DEFINE_VISITABLE(XdmfArray, XdmfItem) XDMF_CHILDREN(XdmfArray, XdmfHeavyDataController, HeavyDataController, Name) static const std::string ItemTag; /** * Remove all values from this array. * * Example of use: * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#clear * @until //#clear * * Python * * @dontinclude XdmfExampleArray.py * @skipline #//initialization * @until #//initialization * @skipline #//clear * @until #//clear */ void clear(); /** * Remove a value from this array. * * Example of use: * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#erase * @until //#erase * * Python * * @dontinclude XdmfExampleArray.py * @skipline #//initialization * @until #//initialization * @skipline #//arraydefaultvalues * @until #//arraydefaultvalues * @skipline #//erase * @until #//erase * * @param index The index of the value to be removed */ void erase(const unsigned int index); /** * Get the data type of this array. * * Example of use: * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#getArrayType * @until //#getArrayType * * Python * * @dontinclude XdmfExampleArray.py * @skipline #//initialization * @until #//initialization * @skipline #//getArrayType * @until #//getArrayType * * @return An XdmfArrayType containing the data type for the array. */ shared_ptr getArrayType() const; /** * Get the capacity of this array, the number of values the array * can store without reallocation. * * Example of use: * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#getCapacity * @until //#getCapacity * * Python * * @dontinclude XdmfExampleArray.py * @skipline #//initialization * @until #//initialization * @skipline #//getCapacity * @until #//getCapacity * * @return The capacity of this array. */ unsigned int getCapacity() const; /** * Get the dimensions of the array. * If the array isn't initialized the dimensions * will be based on the heavyDataControllers it has, if any. * * Example of use: * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#getDimensions * @until //#getDimensions * * Python * * @dontinclude XdmfExampleArray.py * @skipline #//initialization * @until #//initialization * @skipline #//getDimensions * @until #//getDimensions * * @return The dimensions of the array. */ std::vector getDimensions() const; /** * Get the dimensions of the array as a string. * * Example of use: * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#getDimensionsString * @until //#getDimensionsString * * Python * * @dontinclude XdmfExampleArray.py * @skipline #//initialization * @until #//initialization * @skipline #//getDimensionsString * @until #//getDimensionsString * * @return The dimensions of the array as a string. */ std::string getDimensionsString() const; std::map getItemProperties() const; std::string getItemTag() const; /** * Get the name of the array. * * Example of use: * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#setName * @until //#setName * @skipline //#getName * @until //#getName * * Python * * @dontinclude XdmfExampleArray.py * @skipline #//initialization * @until #//initialization * @skipline #//setName * @until #//setName * @skipline #//getName * @until #//getName * * @return A string containing the name of the array. */ virtual std::string getName() const; /** * Gets the method this array will be written/read. * Possible choices are: Controller, and Reference * * Example of use: * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#setReference * @until //#setReference * @skipline //#setReadMode * @until //#setReadMode * @skipline //#getReadMode * @until //#getReadMode * * * Python * * @dontinclude XdmfExampleArray.py * @skipline #//initialization * @until #//initialization * @skipline #//setReference * @until #//setReference * @skipline #//setReadMode * @until #//setReadMode * @skipline #//getReadMode * @until #//getReadMode * * @return What method will be used when reading/writing the array */ ReadMode getReadMode() const; /** * Get the number of values stored in this array. * * Example of use: * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#getSize * @until //#getSize * * Python * * @dontinclude XdmfExampleArray.py * @skipline #//initialization * @until #//initialization * @skipline #//getSize * @until #//getSize * * @return The number of values stored in this array. */ unsigned int getSize() const; /** * Gets the array reference that the array will pull from when reading from a reference. * * Example of use: * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#setReference * @until //#setReference * @skipline //#getReference * @until //#getReference * * Python * * @dontinclude XdmfExampleArray.py * @skipline #//initialization * @until #//initialization * @skipline #//setReference * @until #//setReference * @skipline #//getReference * @until #//getReference * * @return The reference being pulled from */ shared_ptr getReference(); /** * Get a copy of a single value stored in this array. * * Example of use: * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#datapointersetup * @until //#datapointersetup * @skipline //#initsharedvector * @until //#initsharedvector * @skipline //#getValueindex * @until //#getValueindex * * Python * * @dontinclude XdmfExampleArray.py * @skipline #//initialization * @until #//initialization * @skipline #//arraydefaultvalues * @until #//arraydefaultvalues * @skipline #//getValueindex * @until #//getValueindex * * @return The requested value. */ template T getValue(const unsigned int index) const; /** * Get a copy of the values stored in this array * * Example of use: * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#getValues * @until //#getValues * * Python: * This function is not supported in Python, * it is replaced by the getNumpyArray function * * @dontinclude XdmfExampleArray.py * @skipline #//initialization * @until #//initialization * @skipline #//arraydefaultvalues * @until #//arraydefaultvalues * @skipline #//getNumpyArray * @until #//getNumpyArray * * @param startIndex The index in this array to begin copying from. * @param valuesPointer A pointer to an array to copy into. * @param numValues The number of values to copy. * @param arrayStride Number of values to stride in this array * between each copy. * @param valuesStride Number of values to stride in the pointer * between each copy. */ template void getValues(const unsigned int startIndex, T * const valuesPointer, const unsigned int numValues = 1, const unsigned int arrayStride = 1, const unsigned int valuesStride = 1) const; /** * Get a smart pointer to the internal values stored in this array. * * Example of use: * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#getValuesInternalvector * @until //#getValuesInternalvector * * Python: * Python does not support this version of the getValuesInternal function, * it defaults to the version that returns a void pointer * * @return A smart pointer to the internal vector of values stored * in this array. */ template shared_ptr > getValuesInternal(); /** * Get a pointer to the internal values stored in this array. * * Example of use: * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#getValuesInternalvoid * @until //#getValuesInternalvoid * * Python * * @dontinclude XdmfExampleArray.py * @skipline //#initialization * @until //#initialization * @skipline #//getValuesInternal * @until #//getValuesInternal * * @return A void pointer to the first value stored in this array. */ void * getValuesInternal(); /** * Get a pointer to the internal values stored in this array (const * version). * * Example of use: * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#getValuesInternalvoidconst * @until //#getValuesInternalvoidconst * * Python: * Python does not support this version of the getValuesInternal function, * it defaults to the version that returns a void pointer * * @return A void pointer to the first value stored in this array. */ const void * getValuesInternal() const; /** * Get the values stored in this array as a string. * * Example of use: * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#getValuesString * @until //#getValuesString * * Python * * @dontinclude XdmfExampleArray.py * @skipline #//initialization * @until #//initialization * @skipline #//getValuesparse * @until #//getValuesparse * * @return A string containing the contents of the array. */ std::string getValuesString() const; /** * Initialize the array to a specific size. * * Example of use: * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#sizedeclaration * @until //#sizedeclaration * @skipline //#initializesingletemplate * @until //#initializesingletemplate * * Python: Does not support this version of initialize * * @param size The number of values in the initialized array. * * @return A smart pointer to the internal vector of values * initialized in this array. */ template shared_ptr > initialize(const unsigned int size = 0); /** * Initialize the array to specific dimensions. * * Example of use: * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#sizevectordeclaration * @until //#sizevectordeclaration * @skipline //#initializevectortemplate * @until //#initializevectortemplate * * Python: Does not support this version of initialize * * @param dimensions The dimensions of the initialized array. * * @return A smart pointer to the internal vector of values * initialized in this array. */ template shared_ptr > initialize(const std::vector & dimensions); /** * Initialize the array to contain a specified amount of a particular type. * * Example of use: * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#sizedeclaration * @until //#sizedeclaration * @skipline //#initializesingletype * @until //#initializesingletype * * Python * * @dontinclude XdmfExampleArray.py * @skipline #//initialization * @until #//initialization * @skipline #//initializesingle * @until #//initializesingle * * @param arrayType The type of array to initialize. * @param size The number of values in the initialized array. */ void initialize(const shared_ptr & arrayType, const unsigned int size = 0); /** * Initialize the array with specified dimensions to contain a particular type. * * Example of use: * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#sizevectordeclaration * @until //#sizevectordeclaration * @skipline //#initializevectortype * @until //#initializevectortype * * Python * * @dontinclude XdmfExampleArray.py * @skipline #//initialization * @until #//initialization * @skipline #//initializevector * @until #//initializevector * * @param arrayType The type of array to initialize. * @param dimensions The number dimensions of the initialized array. */ void initialize(const shared_ptr & arrayType, const std::vector & dimensions); using XdmfItem::insert; /** * Insert value into this array * * Example of use: * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#pointinsertvalues * @until //#pointinsertvalues * @skipline //#pointinsert * @until //#pointinsert * * Python * * @dontinclude XdmfExampleArray.py * @skipline #//initialization * @until #//initialization * @skipline #//pointinsert * @until #//pointinsert * * @param index The index in this array to insert. * @param value The value to insert */ template void insert(const unsigned int index, const T & value); /** * Insert values from an XdmfArray into this array. * * Example of use: * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#datapointersetup * @until //#datapointersetup * @skipline //#pointerinsert * @until //#pointerinsert * @skipline //#arrayinsert * @until //#arrayinsert * * Python * * @dontinclude XdmfExampleArray.py * @skipline #//initialization * @until #//initialization * @skipline #//insertarray * @until #//insertarray * * @param startIndex The index in this array to begin insertion. * @param values A shared pointer to an XdmfArray to copy * into this array. * @param valuesStartIndex The index in the XdmfArray to begin copying. * @param numValues The number of values to copy into this array. * @param arrayStride Number of values to stride in this array * between each copy. * @param valuesStride Number of values to stride in the XdmfArray * between each copy. */ void insert(const unsigned int startIndex, const shared_ptr values, const unsigned int valuesStartIndex = 0, const unsigned int numValues = 1, const unsigned int arrayStride = 1, const unsigned int valuesStride = 1); /** * Insert values from an XdmfArray into this array. This is the multidimensional version. * * Example of use: * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#insertmultidim * @until //#insertmultidim * * Python * * @dontinclude XdmfExampleArray.py * @skipline #//insertmultidim * @until #//insertmultidim * * @param startIndex The index in this array to begin * insertion for each dimension * @param values A shared pointer to an XdmfArray * to copy into this array. * @param valuesStartIndex The index in the XdmfArray to begin * copying for each dimension of the * source array * @param numValues The number of values to copy into this * array for each dimension on the * source array * @param numInserted The number of strides to make across * the array being written to for each * dimension * @param arrayStride Number of values to stride in this array * between each copy for each dimension * @param valuesStride Number of values to stride in the * XdmfArray between each copy for each * dimension of the source array */ void insert(const std::vector startIndex, const shared_ptr values, const std::vector valuesStartIndex, const std::vector numValues, const std::vector numInserted, const std::vector arrayStride, const std::vector valuesStride); /** * Insert values into this array. * * Example of use: * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#datapointersetup * @until //#datapointersetup * @skipline //#pointerinsert * @until //#pointerinsert * * Python * * @dontinclude XdmfExampleArray.py * @skipline #//initialization * @until #//initialization * @skipline #//insertlist * @until #//insertlist * * @param startIndex The index in this array to begin insertion. * @param valuesPointer A pointer to the values to copy into this array. * @param numValues The number of values to copy into this array. * @param arrayStride Number of values to stride in this array between * each copy. * @param valuesStride Number of values to stride in the pointer between * each copy. */ template void insert(const unsigned int startIndex, const T * const valuesPointer, const unsigned int numValues, const unsigned int arrayStride = 1, const unsigned int valuesStride = 1); /** * Returns whether the array is initialized (contains values in * memory). * * Example of use: * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#isInitialized * @until //#isInitialized * * Python * * @dontinclude XdmfExampleArray.py * @skipline #//initialization * @until #//initialization * @skipline #//isInitialized * @until #//isInitialized */ virtual bool isInitialized() const; /** * Copy a value to the back of this array * * Example of use; * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#pointinsertvalues * @until //#pointinsertvalues * @skipline //#pushBack * @until //#pushBack * * Python * * @dontinclude XdmfExampleArray.py * @skipline #//initialization * @until #//initialization * @skipline #//pushBack * @until #//pushBack * * @param value The value to be inserted */ template void pushBack(const T & value); /** * Get the first heavy data controller attached to this array. * * Example of use: * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#getHeavyDataController * @until //#getHeavyDataController * * Python * * @dontinclude XdmfExampleArray.py * @skipline #//initialization * @until #//initialization * @skipline #//getHeavyDataController * @until #//getHeavyDataController * * @return The heavy data controller attached to this array. */ shared_ptr getHeavyDataController(); /** * Get the first heavy data controller attached to this array. (const version) * * Example of use: * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#getHeavyDataControllerconst * @until //#getHeavyDataControllerconst * * Python: Doesn't support a constant version of this function * * @return The heavy data controller attached to this array. */ shared_ptr getHeavyDataController() const; /** * Replace all controllers attached to this array with the controller provided. * * Example of use: * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#getHeavyDataController * @until //#getHeavyDataController * @skipline //#setHeavyDataController * @until //#setHeavyDataController * * Python * * @dontinclude XdmfExampleArray.py * @skipline #//initialization * @until #//initialization * @skipline #//getHeavyDataController * @until #//getHeavyDataController * @skipline #//setHeavyDataController * @until #//setHeavyDataController * * @param newController The heavy data controller to attach to this array. */ void setHeavyDataController(shared_ptr newController); /** * Sets the controllers attached to this array to the ones contained * in the provided vector. * * Example of use: * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#setHeavyDataControllerVector * @until //#setHeavyDataControllerVector * * Python * * @dontinclude XdmfExampleArray.py * @skipline #//initialization * @until #//initialization * @skipline #//setHeavyDataControllerVector * @until #//setHeavyDataControllerVector * * @param newControllers The controllers to be set to the array. */ void setHeavyDataController(std::vector > & newControllers); /** * Read data from disk into memory. * * Example of use: * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#read * @until //#read * * Python * * @dontinclude XdmfExampleArray.py * @skipline #//initialization * @until #//initialization * @skipline #//isInitialized * @until #//isInitialized */ void read(); /** * Reads data from the attached controllers to the internal data storage. * * Example of use: * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#getHeavyDataController * @until //#getHeavyDataController * @skipline //#setHeavyDataController * @until //#setHeavyDataController * @skipline //#readController * @until //#readController * * Python * * @dontinclude XdmfExampleArray.py * @skipline #//initialization * @until #//initialization * @skipline #//getHeavyDataController * @until #//getHeavyDataController * @skipline #//setHeavyDataController * @until #//setHeavyDataController * @skipline #//readController * @until #//readController */ void readController(); /** * Reads the data pointed to by the array reference into the array. * * Example of use: * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#setReference * @until //#setReference * @skipline //#readReference * @until //#readReference * * Python * * @dontinclude XdmfExampleArray.py * @skipline #//initialization * @until #//initialization * @skipline #//setReference * @until #//setReference * @skipline #//readReference * @until #//readReference */ void readReference(); /** * Release all data currently held in memory. * * Example of use: * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#release * @until //#release * * Python * * @dontinclude XdmfExampleArray.py * @skipline #//initialization * @until #//initialization * @skipline #//release * @until #//release */ void release(); /** * Set the capacity of the array to at least size. * * Example of use: * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#sizedeclaration * @until //#sizedeclaration * @skipline //#reserve * @until //#reserve * * Python * * @dontinclude XdmfExampleArray.py * @skipline #//initialization * @until #//initialization * @skipline #//reserve * @until #//reserve * * @param size The capacity to set this array to. */ void reserve(const unsigned int size); /** * Resizes the array to contain a number of values. If numValues is * larger than the current size, values are appended to the end of * the array equal to value. If numValues is less than the current * size, values at indices larger than numValues are removed. * * Example of use: * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#sizedeclaration * @until //#sizedeclaration * @skipline //#resizesingle * @until //#resizesingle * * Python * * @dontinclude XdmfExampleArray.py * @skipline #//initialization * @until #//initialization * @skipline #//arraydefaultvalues * @until #//arraydefaultvalues * @skipline #//resizesingle * @until #//resizesingle * * @param numValues The number of values to resize this array to. * @param value The number to initialize newly created * values to, if needed. */ template void resize(const unsigned int numValues, const T & value = 0); /** * Resizes the array to specified dimensions. If the number of * values specified by the dimensions is larger than the current * size, values are appended to the end of the array equal to * value. If numValues is less than the current size, values at * indices larger than numValues are removed. * * Example of use: * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#sizevectordeclaration * @until //#sizevectordeclaration * @skipline //#resizevector * @until //#resizevector * * Python * * @dontinclude XdmfExampleArray.py * @skipline #//initialization * @until #//initialization * @skipline #//arraydefaultvalues * @until #//arraydefaultvalues * @skipline #//resizevector * @until #//resizevector * * @param dimensions The dimensions to resize the array to. * @param value The number to intialize newly created values to, * if needed. */ template void resize(const std::vector & dimensions, const T & value = 0); /** * Sets the array reference from which the Array will fill when readReference is called. * * Example of use: * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#setReference * @until //#setReference * * * Python * * @dontinclude XdmfExampleArray.py * @skipline #//initialization * @until #//initialization * @skipline #//setReference * @until #//setReference * * @param newReference The reference to be associated with this array */ void setReference(shared_ptr newReference); /** * Set the name of the array. * * Example of use: * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#setName * @until //#setName * * Python * * @dontinclude XdmfExampleArray.py * @skipline #//initialization * @until #//initialization * @skipline #//setName * @until #//setName * * @param name Name of the array to set. */ virtual void setName(const std::string & name); /** * Sets the method this array will be written/read. * Possible choices are: Controller, and Reference * * Example of use: * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#setReference * @until //#setReference * @skipline //#setReadMode * @until //#setReadMode * * * Python * * @dontinclude XdmfExampleArray.py * @skipline #//initialization * @until #//initialization * @skipline #//setReference * @until #//setReference * @skipline #//setReadMode * @until #//setReadMode * * @param newStatus The method that the array will be read/written */ void setReadMode(ReadMode newStatus = XdmfArray::Controller); /** * Sets the values of this array to the values stored in the * arrayPointer array. No copy is made. Modifications to the array * are not permitted through the XdmfArray API. Any calls through * the XdmfArray API to modify the array (i.e. any non-const * function) will result in the array being copied into internal * storage. The internal copy is then modified. This prevents * situations where a realloc of the pointer could cause other * references to become invalid. The caller of this method can * continue to modify the values stored in arrayPointer on its * own. This function is meant for applications that have their own * array data structures that merely use Xdmf to output the data, an * operation that should not require a copy. Other applications that * use Xdmf for in memory data storage should avoid this function. * * Example of use: * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#datapointersetup * @until //#datapointersetup * @skipline //#setValuesInternalpointer * @until //#setValuesInternalpointer * * Python: does not support setValuesInternal * * @param arrayPointer A pointer to an array to store in * this XdmfArray. * @param numValues The number of values in the array. * @param transferOwnership Whether to transfer responsibility for * deletion of the array to XdmfArray. */ template void setValuesInternal(const T * const arrayPointer, const unsigned int numValues, const bool transferOwnership = 0); /** * Sets the values of this array to the values stored in the * vector. No copy is made. The caller of this method retains * ownership of the data and must ensure that the array is still * valid for the entire time Xdmf needs it. * * Example of use: * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#initinternalvector * @until //#initinternalvector * @skipline //#setValuesInternalvector * @until //#setValuesInternalvector * * Python: does not support setValuesInternal * * @param array A vector to store in this XdmfArray. * @param transferOwnership Whether to transfer responsibility for * deletion of the array to XdmfArray. */ template void setValuesInternal(std::vector & array, const bool transferOwnership = 0); /** * Sets the values of this array to the values stored in the * vector. No copy is made. This array shares ownership with other * references to the smart pointer. * * Example of use: * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#initinternalvector * @until //#initinternalvector * @skipline //#initsharedvector * @until //#initsharedvector * @skipline //#setValuesInternalsharedvector * @until //#setValuesInternalsharedvector * * Python: does not support setValuesInternal * * @param array A smart pointer to a vector to store in this array. */ template void setValuesInternal(const shared_ptr > array); /** * Exchange the contents of the vector with the contents of this * array. No copy is made. The internal arrays are swapped. * * Example of use * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#initinternalvector * @until //#initinternalvector * @skipline //#swapvector * @until //#swapvector * * Python: The Python version only supports swapping XdmfArrays * * @param array A vector to exchange values with. * @return bool whether the swap was successful. */ template bool swap(std::vector & array); /** * Exchange the contents of the vector with the contents of this * array. No copy is made. The internal arrays are swapped. * * Example of use * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#initinternalvector * @until //#initinternalvector * @skipline //#initsharedvector * @until //#initsharedvector * @skipline //#swapsharedvector * @until //#swapsharedvector * * Python: The Python version only supports swapping XdmfArrays * * @param array A smart pointer to a vector to exchange values with. * @return bool whether the swap was successful. */ template bool swap(const shared_ptr > array); /** * Exchange the contents of an XdmfArray with the contents of this * array. No copy is made. The internal arrays are swapped. * * Example of use * * C++ * * @dontinclude ExampleXdmfArray.cpp * @skipline //#initialization * @until //#initialization * @skipline //#swaparray * @until //#swaparray * * Python * * @dontinclude XdmfExampleArray.py * @skipline #//initialization * @until #//initialization * @skipline #//arraydefaultvalues * @until #//arraydefaultvalues * @skipline //#swap * @until //#swap * * @param array A smart pointer to a vector to exchange values with. */ void swap(const shared_ptr array); virtual void traverse(const shared_ptr visitor); XdmfArray(XdmfArray &); protected: XdmfArray(); virtual void populateItem(const std::map & itemProperties, const std::vector > & childItems, const XdmfCoreReader * const reader); private: XdmfArray(const XdmfArray &); // Not implemented. void operator=(const XdmfArray &); // Not implemented. // Variant Visitor Operations class Clear; class Erase; class GetArrayType; class GetCapacity; template class GetValue; template class GetValues; class GetValuesPointer; class GetValuesString; template class Insert; class InsertArray; class InternalizeArrayPointer; class IsInitialized; struct NullDeleter; template class PushBack; class Reserve; template class Resize; class Size; /** * After setValues() is called, XdmfArray stores a pointer that is * not allowed to be modified through the XdmfArray API. If the user * desires to modify the contents of the pointer, they must do so * without calling any non-const functions of XdmfArray. If they do * call non-const functions of XdmfArray, we attempt to accommodate * by copying the array pointer into internal data structures. */ void internalizeArrayPointer(); typedef boost::variant< boost::blank, shared_ptr >, shared_ptr >, shared_ptr >, shared_ptr >, shared_ptr >, shared_ptr >, shared_ptr >, shared_ptr >, shared_ptr >, shared_ptr >, boost::shared_array, boost::shared_array, boost::shared_array, boost::shared_array, boost::shared_array, boost::shared_array, boost::shared_array, boost::shared_array, boost::shared_array > ArrayVariant; unsigned int mArrayPointerNumValues; std::vector mDimensions; std::string mName; unsigned int mTmpReserveSize; ReadMode mReadMode; shared_ptr mReference; ArrayVariant mArray; }; #include "XdmfArray.tpp" #endif #ifdef __cplusplus extern "C" { #endif #define XDMF_ARRAY_READ_MODE_CONTROLLER 10 #define XDMF_ARRAY_READ_MODE_REFERENCE 11 // C wrappers go here struct XDMFARRAY; // Simply as a typedef to ensure correct typing typedef struct XDMFARRAY XDMFARRAY; XDMFCORE_EXPORT XDMFARRAY * XdmfArrayNew(); XDMFCORE_EXPORT void XdmfArrayClear(XDMFARRAY * array); XDMFCORE_EXPORT void XdmfArrayErase(XDMFARRAY * array, unsigned int index); XDMFCORE_EXPORT int XdmfArrayGetArrayType(XDMFARRAY * array, int * status); XDMFCORE_EXPORT unsigned int XdmfArrayGetCapacity(XDMFARRAY * array); XDMFCORE_EXPORT unsigned int * XdmfArrayGetDimensions(XDMFARRAY * array); XDMFCORE_EXPORT char * XdmfArrayGetDimensionsString(XDMFARRAY * array); XDMFCORE_EXPORT XDMFHEAVYDATACONTROLLER * XdmfArrayGetHeavyDataController(XDMFARRAY * array, unsigned int index); XDMFCORE_EXPORT int XdmfArrayGetReadMode(XDMFARRAY * array, int * status); XDMFCORE_EXPORT char * XdmfArrayGetName(XDMFARRAY * array); XDMFCORE_EXPORT unsigned int XdmfArrayGetNumberDimensions(XDMFARRAY * array); XDMFCORE_EXPORT unsigned int XdmfArrayGetNumberHeavyDataControllers(XDMFARRAY * array); XDMFCORE_EXPORT unsigned int XdmfArrayGetSize(XDMFARRAY * array); XDMFCORE_EXPORT XDMFARRAYREFERENCE * XdmfArrayGetReference(XDMFARRAY * array); XDMFCORE_EXPORT void * XdmfArrayGetValue(XDMFARRAY * array, unsigned int index, int arrayType, int * status); XDMFCORE_EXPORT void * XdmfArrayGetValues(XDMFARRAY * array, unsigned int startIndex, int arrayType, unsigned int numValues, unsigned int arrayStride, unsigned int valueStride, int * status); XDMFCORE_EXPORT void * XdmfArrayGetValuesInternal(XDMFARRAY * array); XDMFCORE_EXPORT char * XdmfArrayGetValuesString(XDMFARRAY * array); XDMFCORE_EXPORT void XdmfArrayInitialize(XDMFARRAY * array, int * dims, int numDims, int arrayType, int * status); XDMFCORE_EXPORT void XdmfArrayInsertDataFromPointer(XDMFARRAY * array, void * values, int arrayType, unsigned int startIndex, unsigned int numVals, unsigned int arrayStride, unsigned int valueStride, int * status); XDMFCORE_EXPORT void XdmfArrayInsertDataFromXdmfArray(XDMFARRAY * array, XDMFARRAY * valArray, int * arrayStarts, int * valueStarts, int * arrayCounts, int * valueCounts, int * arrayStrides, int * valueStrides, int * status); XDMFCORE_EXPORT void XdmfArrayInsertHeavyDataController(XDMFARRAY * array, XDMFHEAVYDATACONTROLLER * controller, int passControl); XDMFCORE_EXPORT void XdmfArrayInsertValue(XDMFARRAY * array, unsigned int index, void * value, int arrayType, int * status); XDMFCORE_EXPORT int XdmfArrayIsInitialized(XDMFARRAY * array); XDMFCORE_EXPORT void XdmfArrayPushBack(XDMFARRAY * array, void * value, int arrayType, int * status); XDMFCORE_EXPORT void XdmfArrayRead(XDMFARRAY * array, int * status); XDMFCORE_EXPORT void XdmfArrayReadController(XDMFARRAY * array, int * status); XDMFCORE_EXPORT void XdmfArrayReadReference(XDMFARRAY * array, int * status); XDMFCORE_EXPORT void XdmfArrayRelease(XDMFARRAY * array); XDMFCORE_EXPORT void XdmfArrayRemoveHeavyDataController(XDMFARRAY * array, unsigned int index); XDMFCORE_EXPORT void XdmfArrayReserve(XDMFARRAY * array, int size); XDMFCORE_EXPORT void XdmfArrayResize(XDMFARRAY * array, int * dims, int numDims, int arrayType, int * status); XDMFCORE_EXPORT void XdmfArraySetReadMode(XDMFARRAY * array, int readMode, int * status); XDMFCORE_EXPORT void XdmfArraySetReference(XDMFARRAY * array, XDMFARRAYREFERENCE * reference, int passControl); XDMFCORE_EXPORT void XdmfArraySetName(XDMFARRAY * array, char * name, int * status); XDMFCORE_EXPORT void XdmfArraySetValuesInternal(XDMFARRAY * array, void * pointer, unsigned int numValues, int arrayType, int transferOwnership, int * status); XDMFCORE_EXPORT void XdmfArraySwapWithXdmfArray(XDMFARRAY * array, XDMFARRAY * swapArray); XDMFCORE_EXPORT void XdmfArraySwapWithArray(XDMFARRAY * array, void ** pointer, int numValues, int arrayType, int * status); // C Wrappers for parent classes are generated by macros XDMF_ITEM_C_CHILD_DECLARE(XdmfArray, XDMFARRAY, XDMFCORE) #define XDMF_ARRAY_C_CHILD_DECLARE(ClassName, CClassName, Level) \ \ Level##_EXPORT void ClassName##Clear( CClassName * array); \ Level##_EXPORT void ClassName##Erase( CClassName * array, unsigned int index); \ Level##_EXPORT int ClassName##GetArrayType( CClassName * array, int * status); \ Level##_EXPORT unsigned int ClassName##GetCapacity( CClassName * array); \ Level##_EXPORT unsigned int * ClassName##GetDimensions( CClassName * array); \ Level##_EXPORT char * ClassName##GetDimensionsString( CClassName * array); \ Level##_EXPORT XDMFHEAVYDATACONTROLLER * ClassName##GetHeavyDataController( CClassName * array, unsigned int index); \ Level##_EXPORT int ClassName##GetReadMode( CClassName * array, int * status); \ Level##_EXPORT char * ClassName##GetName( CClassName * array); \ Level##_EXPORT unsigned int ClassName##GetNumberDimensions( CClassName * array); \ Level##_EXPORT unsigned int ClassName##GetNumberHeavyDataControllers( CClassName * array); \ Level##_EXPORT unsigned int ClassName##GetSize( CClassName * array); \ Level##_EXPORT XDMFARRAYREFERENCE * ClassName##GetReference( CClassName * array); \ Level##_EXPORT void * ClassName##GetValue( CClassName * array, \ unsigned int index, \ int arrayType, \ int * status); \ Level##_EXPORT void * ClassName##GetValues( CClassName * array, \ unsigned int startIndex, \ int arrayType, \ unsigned int numValues, \ unsigned int arrayStride, \ unsigned int valueStride, \ int * status); \ Level##_EXPORT void * ClassName##GetValuesInternal( CClassName * array); \ Level##_EXPORT char * ClassName##GetValuesString( CClassName * array); \ Level##_EXPORT void ClassName##Initialize( CClassName * array, \ int * dims, \ int numDims, \ int arrayType, \ int * status); \ Level##_EXPORT void ClassName##InsertDataFromPointer( CClassName * array, \ void * values, \ int arrayType, \ unsigned int startIndex, \ unsigned int numVals, \ unsigned int arrayStride, \ unsigned int valueStride, \ int * status); \ Level##_EXPORT void ClassName##InsertDataFromXdmfArray( CClassName * array, \ XDMFARRAY * valArray, \ int * arrayStarts, \ int * valueStarts, \ int * arrayCounts, \ int * valueCounts, \ int * arrayStrides, \ int * valueStrides, \ int * status); \ Level##_EXPORT void ClassName##InsertHeavyDataController( CClassName * array, \ XDMFHEAVYDATACONTROLLER * controller, \ int passControl); \ Level##_EXPORT void ClassName##InsertValue( CClassName * array, \ unsigned int index, \ void * value, \ int arrayType, \ int * status); \ Level##_EXPORT int ClassName##IsInitialized( CClassName * array); \ Level##_EXPORT void ClassName##PushBack( CClassName * array, \ void * value, \ int arrayType, \ int * status); \ Level##_EXPORT void ClassName##Read( CClassName * array, int * status); \ Level##_EXPORT void ClassName##ReadController( CClassName * array, int * status); \ Level##_EXPORT void ClassName##ReadReference( CClassName * array, int * status); \ Level##_EXPORT void ClassName##Release( CClassName * array); \ Level##_EXPORT void ClassName##RemoveHeavyDataController( CClassName * array, unsigned int index); \ Level##_EXPORT void ClassName##Reserve( CClassName * array, int size); \ Level##_EXPORT void ClassName##Resize( CClassName * array, \ int * dims, \ int numDims, \ int arrayType, \ int * status); \ Level##_EXPORT void ClassName##SetReadMode( CClassName * array, int readMode, int * status); \ Level##_EXPORT void ClassName##SetReference( CClassName * array, XDMFARRAYREFERENCE * reference, int passControl); \ Level##_EXPORT void ClassName##SetName( CClassName * array, char * name, int * status); \ Level##_EXPORT void ClassName##SetValuesInternal( CClassName * array, \ void * pointer, \ unsigned int numValues, \ int arrayType, \ int transferOwnership, \ int * status); \ Level##_EXPORT void ClassName##SwapWithXdmfArray( CClassName * array, XDMFARRAY * swapArray); \ Level##_EXPORT void ClassName##SwapWithArray( CClassName * array, \ void ** pointer, \ int numValues, \ int arrayType, \ int * status); #define XDMF_ARRAY_C_CHILD_WRAPPER(ClassName, CClassName) \ \ void ClassName##Clear( CClassName * array) \ { \ XdmfArrayClear((XDMFARRAY *)((void *)array)); \ } \ \ void ClassName##Erase( CClassName * array, unsigned int index) \ { \ XdmfArrayErase((XDMFARRAY *)((void *)array), index); \ } \ \ int ClassName##GetArrayType( CClassName * array, int * status) \ { \ return XdmfArrayGetArrayType((XDMFARRAY *)((void *)array), status); \ } \ \ unsigned int ClassName##GetCapacity( CClassName * array) \ { \ return XdmfArrayGetCapacity((XDMFARRAY *)((void *)array)); \ } \ \ unsigned int * \ ClassName##GetDimensions( CClassName * array) \ { \ return XdmfArrayGetDimensions((XDMFARRAY *)((void *)array)); \ } \ \ char * \ ClassName##GetDimensionsString( CClassName * array) \ { \ return XdmfArrayGetDimensionsString((XDMFARRAY *)((void *)array)); \ } \ \ XDMFHEAVYDATACONTROLLER * \ ClassName##GetHeavyDataController( CClassName * array, unsigned int index) \ { \ return XdmfArrayGetHeavyDataController((XDMFARRAY *)((void *)array), index); \ } \ \ char * \ ClassName##GetName( CClassName * array) \ { \ return XdmfArrayGetName((XDMFARRAY *)((void *)array)); \ } \ \ unsigned int \ ClassName##GetNumberDimensions( CClassName * array) \ { \ return XdmfArrayGetNumberDimensions((XDMFARRAY *)((void *)array)); \ } \ \ unsigned int \ ClassName##GetNumberHeavyDataControllers( CClassName * array) \ { \ return XdmfArrayGetNumberHeavyDataControllers((XDMFARRAY *)((void *)array)); \ } \ \ unsigned int \ ClassName##GetSize( CClassName * array) \ { \ return XdmfArrayGetSize((XDMFARRAY *)((void *)array)); \ } \ \ int \ ClassName##GetReadMode( CClassName * array, int * status) \ { \ return XdmfArrayGetReadMode((XDMFARRAY *)((void *)array), status); \ } \ \ XDMFARRAYREFERENCE * \ ClassName##GetReference( CClassName * array) \ { \ return XdmfArrayGetReference((XDMFARRAY *)((void *)array)); \ } \ \ void * \ ClassName##GetValue( CClassName * array, unsigned int index, int arrayType, int * status) \ { \ return XdmfArrayGetValue((XDMFARRAY *)((void *)array), index, arrayType, status); \ } \ \ void * \ ClassName##GetValues( CClassName * array, \ unsigned int startIndex, \ int arrayType, \ unsigned int numValues, \ unsigned int arrayStride, \ unsigned int valueStride, \ int * status) \ { \ return XdmfArrayGetValues((XDMFARRAY *)((void *)array), \ startIndex, \ arrayType, \ numValues, \ arrayStride, \ valueStride, \ status); \ } \ \ void * \ ClassName##GetValuesInternal( CClassName * array) \ { \ return XdmfArrayGetValuesInternal((XDMFARRAY *)((void *)array)); \ } \ \ char * \ ClassName##GetValuesString( CClassName * array) \ { \ return XdmfArrayGetValuesString((XDMFARRAY *)((void *)array)); \ } \ \ void \ ClassName##Initialize( CClassName * array, int * dims, int numDims, int arrayType, int * status) \ { \ XdmfArrayInitialize((XDMFARRAY *)((void *)array), dims, numDims, arrayType, status); \ } \ \ void \ ClassName##InsertDataFromPointer( CClassName * array, \ void * values, \ int arrayType, \ unsigned int startIndex, \ unsigned int numVals, \ unsigned int arrayStride, \ unsigned int valueStride, \ int * status) \ { \ XdmfArrayInsertDataFromPointer((XDMFARRAY *)((void *)array), \ values, \ arrayType, \ startIndex, \ numVals, \ arrayStride, \ valueStride, \ status); \ } \ \ void ClassName##InsertDataFromXdmfArray( CClassName * array, \ XDMFARRAY * valArray, \ int * arrayStarts, \ int * valueStarts, \ int * arrayCounts, \ int * valueCounts, \ int * arrayStrides, \ int * valueStrides, \ int * status) \ { \ XdmfArrayInsertDataFromXdmfArray((XDMFARRAY *)((void *)array), \ valArray, \ arrayStarts, \ valueStarts, \ arrayCounts, \ valueCounts, \ arrayStrides, \ valueStrides, \ status); \ } \ \ void \ ClassName##InsertHeavyDataController( CClassName * array, XDMFHEAVYDATACONTROLLER * controller, int passControl) \ { \ XdmfArrayInsertHeavyDataController((XDMFARRAY *)((void *)array), controller, passControl); \ } \ \ void \ ClassName##InsertValue( CClassName * array, \ unsigned int index, \ void * value, \ int arrayType, \ int * status) \ { \ XdmfArrayInsertValue((XDMFARRAY *)((void *)array), index, value, arrayType, status); \ } \ \ int \ ClassName##IsInitialized( CClassName * array) \ { \ return XdmfArrayIsInitialized((XDMFARRAY *)((void *)array)); \ } \ \ void \ ClassName##PushBack( CClassName * array, void * value, int arrayType, int * status) \ { \ XdmfArrayPushBack((XDMFARRAY *)((void *)array), value, arrayType, status); \ } \ \ void \ ClassName##Read( CClassName * array, int * status) \ { \ XdmfArrayRead((XDMFARRAY *)((void *)array), status); \ } \ \ void \ ClassName##ReadController( CClassName * array, int * status) \ { \ XdmfArrayReadController((XDMFARRAY *)((void *)array), status); \ } \ \ void \ ClassName##ReadReference( CClassName * array, int * status) \ { \ XdmfArrayReadReference((XDMFARRAY *)((void *)array), status); \ } \ \ void \ ClassName##Release( CClassName * array) \ { \ XdmfArrayRelease((XDMFARRAY *)((void *)array)); \ } \ \ void \ ClassName##RemoveHeavyDataController( CClassName * array, unsigned int index) \ { \ XdmfArrayRemoveHeavyDataController((XDMFARRAY *)((void *)array), index); \ } \ \ void \ ClassName##Reserve( CClassName * array, int size) \ { \ XdmfArrayReserve((XDMFARRAY *)((void *)array), size); \ } \ \ void \ ClassName##Resize( CClassName * array, int * dims, int numDims, int arrayType, int * status) \ { \ XdmfArrayResize((XDMFARRAY *)((void *)array), dims, numDims, arrayType, status); \ } \ \ void \ ClassName##SetReadMode( CClassName * array, int readMode, int * status) \ { \ XdmfArraySetReadMode((XDMFARRAY *)((void *)array), readMode, status); \ } \ \ void \ ClassName##SetReference( CClassName * array, XDMFARRAYREFERENCE * reference, int passControl) \ { \ XdmfArraySetReference((XDMFARRAY *)((void *)array), reference, passControl); \ } \ \ void \ ClassName##SetName( CClassName * array, char * name, int * status) \ { \ XdmfArraySetName((XDMFARRAY *)((void *)array), name, status); \ } \ \ void \ ClassName##SetValuesInternal( CClassName * array, \ void * pointer, \ unsigned int numValues, \ int arrayType, \ int transferOwnership, \ int * status) \ { \ XdmfArraySetValuesInternal((XDMFARRAY *)((void *)array), \ pointer, \ numValues, \ arrayType, \ transferOwnership, \ status); \ } \ \ void \ ClassName##SwapWithXdmfArray( CClassName * array, XDMFARRAY * swapArray) \ { \ XdmfArraySwapWithXdmfArray((XDMFARRAY *)((void *)array), swapArray); \ } \ \ void \ ClassName##SwapWithArray( CClassName * array, \ void ** pointer, \ int numValues, \ int arrayType, \ int * status) \ { \ XdmfArraySwapWithArray((XDMFARRAY *)((void *)array), pointer, numValues, arrayType, status); \ } #ifdef __cplusplus } #endif #endif /* XDMFARRAY_HPP_ */ xdmf-3.0+git20160803/core/XdmfError.cpp0000640000175000017500000001035713003006557017444 0ustar alastairalastair#include #include #include XdmfError::XdmfError(Level level, std::string message) : mLevel(level), mMessage(message) { } XdmfError::~XdmfError() throw() { } /************************ *** Public Functions *** ************************/ XdmfError::Level XdmfError::getLevel() const { return XdmfError::mLevel; } void XdmfError::setLevel(Level l) { XdmfError::mLevel = l; } const char * XdmfError::what() const throw() { return XdmfError::mMessage.c_str(); } /******************************* *** Public Static Functions *** *******************************/ bool XdmfError::getCErrorsAreFatal() { return XdmfError::mCErrorsAreFatal; } XdmfError::Level XdmfError::getLevelLimit() { return XdmfError::mLevelLimit; } XdmfError::Level XdmfError::getSuppressionLevel() { return XdmfError::mSuppressLevel; } void XdmfError::setCErrorsAreFatal(bool status) { XdmfError::mCErrorsAreFatal = status; } void XdmfError::setLevelLimit(Level l) { XdmfError::mLevelLimit = l; } void XdmfError::setSuppressionLevel(Level l) { XdmfError::mSuppressLevel = l; } void XdmfError::message(Level level, std::string msg) { if (level<=XdmfError::getSuppressionLevel()) { XdmfError::WriteToStream(msg); } if(level<=XdmfError::getLevelLimit()) { throw XdmfError(level, msg); } } void XdmfError::setBuffer(std::streambuf* buf) { XdmfError::mBuf = buf; } /******************************** *** Private Static Functions *** ********************************/ // automatically writes the message to the provided buffer // by default this is basically a print statement void XdmfError::WriteToStream(std::string msg) { if(msg[msg.length()-1] != '\n') { // using \r\n for windows compatiblity msg+="\r\n"; } XdmfError::mBuf->sputn(msg.c_str(),msg.length()); } /****************************************** *** Initialize Static Member Variables *** ******************************************/ XdmfError::Level XdmfError::mLevelLimit = XdmfError::FATAL; XdmfError::Level XdmfError::mSuppressLevel = XdmfError::WARNING; std::streambuf* XdmfError::mBuf=std::cout.rdbuf(); bool XdmfError::mCErrorsAreFatal = false; // C Wrappers void XdmfErrorSetCErrorsAreFatal(int status) { XdmfError::setCErrorsAreFatal(status); } void XdmfErrorSetLevelLimit(int level, int * status) { XDMF_ERROR_WRAP_START(status) switch (level) { case XDMF_ERROR_FATAL: XdmfError::setLevelLimit(XdmfError::FATAL); break; case XDMF_ERROR_WARNING: XdmfError::setLevelLimit(XdmfError::WARNING); break; case XDMF_ERROR_DEBUG: XdmfError::setLevelLimit(XdmfError::DEBUG); break; default: try { XdmfError::message(XdmfError::FATAL, "Error: Invalid Error Level"); } catch (XdmfError & e) { throw e; } } XDMF_ERROR_WRAP_END(status) } void XdmfErrorSetSuppressionLevel(int level, int * status) { XDMF_ERROR_WRAP_START(status) switch (level) { case XDMF_ERROR_FATAL: XdmfError::setSuppressionLevel(XdmfError::FATAL); break; case XDMF_ERROR_WARNING: XdmfError::setSuppressionLevel(XdmfError::WARNING); break; case XDMF_ERROR_DEBUG: XdmfError::setSuppressionLevel(XdmfError::DEBUG); break; default: XdmfError::message(XdmfError::FATAL, "Error: Invalid Error Level"); } XDMF_ERROR_WRAP_END(status) } int XdmfErrorGetCErrorsAreFatal() { return XdmfError::getCErrorsAreFatal(); } int XdmfErrorGetLevelLimit() { if (XdmfError::getLevelLimit() == XdmfError::FATAL) { return XDMF_ERROR_FATAL; } else if (XdmfError::getLevelLimit() == XdmfError::WARNING) { return XDMF_ERROR_WARNING; } else if (XdmfError::getLevelLimit() == XdmfError::DEBUG) { return XDMF_ERROR_DEBUG; } else { XdmfError::message(XdmfError::FATAL, "Error: Invalid Error Level"); } return -1; } int XdmfErrorGetSuppressionLevel() { if (XdmfError::getSuppressionLevel() == XdmfError::FATAL) { return XDMF_ERROR_FATAL; } else if (XdmfError::getSuppressionLevel() == XdmfError::WARNING) { return XDMF_ERROR_WARNING; } else if (XdmfError::getSuppressionLevel() == XdmfError::DEBUG) { return XDMF_ERROR_DEBUG; } else { XdmfError::message(XdmfError::FATAL, "Error: Invalid Error Level"); } return -1; } xdmf-3.0+git20160803/core/XdmfArrayType.cpp0000640000175000017500000004133413003006557020272 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfArrayType.cpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #include #include #include #include "string.h" #include "XdmfArrayType.hpp" #include "XdmfError.hpp" std::map(*)()> > XdmfArrayType::mArrayDefinitions; // Supported XdmfArrayTypes shared_ptr XdmfArrayType::Uninitialized() { static shared_ptr p(new XdmfArrayType("None", 0, XdmfArrayType::Unsigned)); return p; } shared_ptr XdmfArrayType::Int8() { static shared_ptr p(new XdmfArrayType("Char", 1, XdmfArrayType::Signed)); return p; } shared_ptr XdmfArrayType::Int16() { static shared_ptr p(new XdmfArrayType("Short", 2, XdmfArrayType::Signed)); return p; } shared_ptr XdmfArrayType::Int32() { static shared_ptr p(new XdmfArrayType("Int", 4, XdmfArrayType::Signed)); return p; } shared_ptr XdmfArrayType::Int64() { static shared_ptr p(new XdmfArrayType("Int", 8, XdmfArrayType::Signed)); return p; } shared_ptr XdmfArrayType::Float32() { static shared_ptr p(new XdmfArrayType("Float", 4, XdmfArrayType::Float)); return p; } shared_ptr XdmfArrayType::Float64() { static shared_ptr p(new XdmfArrayType("Float", 8, XdmfArrayType::Float)); return p; } shared_ptr XdmfArrayType::UInt8() { static shared_ptr p(new XdmfArrayType("UChar", 1, XdmfArrayType::Unsigned)); return p; } shared_ptr XdmfArrayType::UInt16() { static shared_ptr p(new XdmfArrayType("UShort", 2, XdmfArrayType::Unsigned)); return p; } shared_ptr XdmfArrayType::UInt32() { static shared_ptr p(new XdmfArrayType("UInt", 4, XdmfArrayType::Unsigned)); return p; } shared_ptr XdmfArrayType::String() { static shared_ptr p(new XdmfArrayType("String", 0, XdmfArrayType::Unsigned)); return p; } void XdmfArrayType::InitTypes() { mArrayDefinitions["NONE"][0] = Uninitialized; mArrayDefinitions["CHAR"][1] = Int8; mArrayDefinitions["SHORT"][2] = Int16; mArrayDefinitions["INT"][4] = Int32; mArrayDefinitions["INT"][8] = Int64; mArrayDefinitions["FLOAT"][4] = Float32; mArrayDefinitions["FLOAT"][8] = Float64; mArrayDefinitions["UCHAR"][1] = UInt8; mArrayDefinitions["USHORT"][2] = UInt16; mArrayDefinitions["UINT"][4] = UInt32; mArrayDefinitions["STRING"][0] = String; } XdmfArrayType::XdmfArrayType(const std::string & name, const unsigned int precision, const Format typeFormat) : mName(name), mPrecision(precision), mTypeFormat(typeFormat) { std::stringstream precisionString; precisionString << precision; mPrecisionString = precisionString.str(); } XdmfArrayType::~XdmfArrayType() { } shared_ptr XdmfArrayType::New(const std::map & itemProperties) { InitTypes(); std::map::const_iterator type = itemProperties.find("DataType"); if(type == itemProperties.end()) { type = itemProperties.find("NumberType"); } if(type == itemProperties.end()) { // to support old xdmf defaults, return Float32() return Float32(); } const std::string & typeVal = ConvertToUpper(type->second); std::map::const_iterator precision = itemProperties.find("Precision"); const unsigned int precisionVal = (precision == itemProperties.end()) ? 0 : atoi(precision->second.c_str()); std::map(*)()> >::const_iterator returnType = mArrayDefinitions.find(typeVal); if (returnType == mArrayDefinitions.end()) { XdmfError::message(XdmfError::FATAL, "Type not one of accepted values: " + typeVal + " in XdmfArrayType::New"); } else { std::map(*)()>::const_iterator returnPrecision = returnType->second.find(precisionVal); // If only one precision is available, assume that if not specified. if (returnType->second.size() == 1 && precisionVal == 0) { return (*((returnType->second.begin())->second))(); } if (returnPrecision == returnType->second.end()) { // Default to 32bit types if not specified otherwise returnPrecision = returnType->second.find(4); } if (returnPrecision == returnType->second.end()) { std::string errorVal = ""; if (precision == itemProperties.end()) { errorVal = "0"; } else { errorVal = precision->second; } XdmfError::message(XdmfError::FATAL, "Type not one of accepted precision: " + errorVal + " in XdmfArrayType::New"); } else { return (*(returnPrecision->second))(); } } XdmfError::message(XdmfError::FATAL, "Type not one of accepted values: " + typeVal + " in XdmfArrayType::New"); // unreachable return shared_ptr(); } shared_ptr XdmfArrayType::comparePrecision(shared_ptr type1, shared_ptr type2) { std::string type1Name = type1->getName(); std::string type2Name = type2->getName(); if (type2Name.compare(type1Name) == 0) { if (type1->getElementSize() >= type2->getElementSize()) { return type1; } else { return type2; } } bool firstIsSigned = false; if (type1Name.compare("UChar") != 0 && type1Name.compare("UShort") != 0 && type1Name.compare("UInt") != 0) { firstIsSigned = true; } bool secondIsSigned = false; if (type2Name.compare("UChar") != 0 && type2Name.compare("UShort") != 0 && type2Name.compare("UInt") != 0) { secondIsSigned = true; } std::map controlmap; controlmap["Char"] = 1; controlmap["UChar"] = 2; controlmap["Short"] = 3; controlmap["UShort"] = 4; controlmap["Int"] = 5; controlmap["UInt"] = 6; controlmap["Float"] = 7; controlmap["String"] = 8; int control = controlmap[type1Name]; // In this switch the starting location is determined by // the first type and then the algorithm cascades // until it finds the second type switch (control) { case 1: // Char case 2: // UChar if (type2Name.compare("Char") == 0 || type2Name.compare("UChar") == 0) { // This statement would be called in the case // where there is a mixed type of Char and UChar // The resulting type should be a Short return Int16(); } case 3: // Short if (type2Name.compare("Char") == 0 || type2Name.compare("UChar") == 0 || type2Name.compare("Short") == 0) { // This will be called for any combination of // Char/UChar and Short // In all of these cases the result shoule be a Short return Int16(); } case 4: // UShort if (type2Name.compare("Char") == 0 || type2Name.compare("Short") == 0) { // When mixing UShort with a signed type that has a lower precision // the resulting type should be an int return Int32(); } else if (type2Name.compare("UChar") == 0 || type2Name.compare("UShort") == 0) { // When mixing UShort with an unsigned type that has a lower precision // a Ushort should be the resulting type if (!firstIsSigned) { return UInt16(); } else { return Int32(); } } case 5: // Int if (type2Name.compare("Int") != 0 && type2Name.compare("UInt") != 0 && type2Name.compare("Float") != 0 && type2Name.compare("String") != 0) { // When mixing an Int with a type of lower precision // the resulting type should match the Int's precision if (type1->getElementSize() == 4) { return Int32(); } else { return Int64(); } } if (type2Name.compare("Int") == 0) { if (type2->getElementSize() == 4) { return Int32(); } else { return Int64(); } } case 6: // UInt if (type2Name.compare("UInt") != 0 && type2Name.compare("Int") != 0 && type2Name.compare("Float") != 0 && type2Name.compare("String") != 0) { // When mixing UInt with another non-floating-point type // the result should be either long or unsigned int // depending on the if the mixed type is signed or not if (!secondIsSigned) { return UInt32(); } else { return Int64(); } } else if (type2Name.compare("UInt") == 0) { if (firstIsSigned) { return Int64(); } else { return UInt32(); } } else if (type2Name.compare("Int") == 0) { return Int64(); } case 7: // Float if (type2Name.compare("String") != 0 && type2Name.compare("Float") != 0 && type2Name.compare("UInt") != 0) { // String is the only type that has priority over a float // This case occurs when type1 is a float return type1; } else if (type2Name.compare("UInt") == 0) { return Float64(); } else if (type2Name.compare("Float") == 0) { // Since there was a check earlier to see if the type names matched // This is the case when type2 is a float if (type1Name.compare("UInt") == 0) { return Float64(); } else { return type2; } } case 8: // String // String has priority over everything return String(); default: break; } // Double is the default value // Should all of the above manage to fail to return a value return Float64(); } unsigned int XdmfArrayType::getElementSize() const { return mPrecision; } std::string XdmfArrayType::getName() const { return mName; } bool XdmfArrayType::getIsFloat() const { if (mTypeFormat == XdmfArrayType::Float) { return true; } else { return false; } } bool XdmfArrayType::getIsSigned() const { if (mTypeFormat == XdmfArrayType::Float || mTypeFormat == XdmfArrayType::Signed) { return true; } else { return false; } } void XdmfArrayType::getProperties(std::map & collectedProperties) const { collectedProperties.insert(std::make_pair("DataType", mName)); collectedProperties.insert(std::make_pair("Precision", mPrecisionString)); } // C Wrappers shared_ptr intToType(int type) { switch (type) { case XDMF_ARRAY_TYPE_UINT8: return XdmfArrayType::UInt8(); break; case XDMF_ARRAY_TYPE_UINT16: return XdmfArrayType::UInt16(); break; case XDMF_ARRAY_TYPE_UINT32: return XdmfArrayType::UInt32(); break; case XDMF_ARRAY_TYPE_INT8: return XdmfArrayType::Int8(); break; case XDMF_ARRAY_TYPE_INT16: return XdmfArrayType::Int16(); break; case XDMF_ARRAY_TYPE_INT32: return XdmfArrayType::Int32(); break; case XDMF_ARRAY_TYPE_INT64: return XdmfArrayType::Int64(); break; case XDMF_ARRAY_TYPE_FLOAT32: return XdmfArrayType::Float32(); break; case XDMF_ARRAY_TYPE_FLOAT64: return XdmfArrayType::Float64(); break; default: XdmfError::message(XdmfError::FATAL, "Error: Invalid ArrayType."); break; } return shared_ptr(); } int typeToInt(shared_ptr type) { std::string typeName = type->getName(); unsigned int typePrecision = type->getElementSize(); if (typeName == XdmfArrayType::UInt8()->getName()) { return XDMF_ARRAY_TYPE_UINT8; } else if (typeName == XdmfArrayType::UInt16()->getName()) { return XDMF_ARRAY_TYPE_UINT16; } else if (typeName == XdmfArrayType::UInt32()->getName()) { return XDMF_ARRAY_TYPE_UINT32; } else if (typeName == XdmfArrayType::Int8()->getName()) { return XDMF_ARRAY_TYPE_INT8; } else if (typeName == XdmfArrayType::Int16()->getName()) { return XDMF_ARRAY_TYPE_INT16; } else if (typeName == XdmfArrayType::Int32()->getName() || typeName == XdmfArrayType::Int64()->getName()) { if (typePrecision == 4) { return XDMF_ARRAY_TYPE_INT32; } else if (typePrecision == 8) { return XDMF_ARRAY_TYPE_INT64; } else { } } else if (typeName == XdmfArrayType::Float32()->getName() || typeName == XdmfArrayType::Float64()->getName()) { if (typePrecision == 4) { return XDMF_ARRAY_TYPE_FLOAT32; } else if (typePrecision == 8) { return XDMF_ARRAY_TYPE_FLOAT64; } else { } } else if (typeName == XdmfArrayType::String()->getName()) { //This shouldn't be used from C bindings XdmfError::message(XdmfError::FATAL, "Error: String type not usable from C."); } else { XdmfError::message(XdmfError::FATAL, "Error: Invalid ArrayType."); } return -1; } int XdmfArrayTypeInt8() { return XDMF_ARRAY_TYPE_INT8; } int XdmfArrayTypeInt16() { return XDMF_ARRAY_TYPE_INT16; } int XdmfArrayTypeInt32() { return XDMF_ARRAY_TYPE_INT32; } int XdmfArrayTypeInt64() { return XDMF_ARRAY_TYPE_INT64; } int XdmfArrayTypeFloat32() { return XDMF_ARRAY_TYPE_FLOAT32; } int XdmfArrayTypeFloat64() { return XDMF_ARRAY_TYPE_FLOAT64; } int XdmfArrayTypeUInt8() { return XDMF_ARRAY_TYPE_UINT8; } int XdmfArrayTypeUInt16() { return XDMF_ARRAY_TYPE_UINT16; } int XdmfArrayTypeUInt32() { return XDMF_ARRAY_TYPE_UINT32; } int XdmfArrayTypeComparePrecision(int type1, int type2, int * status) { XDMF_ERROR_WRAP_START(status) shared_ptr tempType1 = intToType(type1); shared_ptr tempType2 = intToType(type2); shared_ptr returnType = XdmfArrayType::comparePrecision(tempType1, tempType2); return typeToInt(returnType); XDMF_ERROR_WRAP_END(status) return -1; } int XdmfArrayTypeGetElementSize(int type, int * status) { XDMF_ERROR_WRAP_START(status) return intToType(type)->getElementSize(); XDMF_ERROR_WRAP_END(status) return 0; } int XdmfArrayTypeGetIsFloat(int type, int * status) { XDMF_ERROR_WRAP_START(status) return intToType(type)->getIsFloat(); XDMF_ERROR_WRAP_END(status) return false; } int XdmfArrayTypeGetIsSigned(int type, int * status) { XDMF_ERROR_WRAP_START(status) return intToType(type)->getIsSigned(); XDMF_ERROR_WRAP_END(status) return false; } char * XdmfArrayTypeGetName(int type, int * status) { XDMF_ERROR_WRAP_START(status) char * returnPointer = strdup(intToType(type)->getName().c_str()); return returnPointer; XDMF_ERROR_WRAP_END(status) return NULL; } xdmf-3.0+git20160803/core/XdmfHeavyDataController.cpp0000640000175000017500000003013013003006557022254 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfHeavyDataController.cpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #include #include #include "string.h" #include "XdmfArrayType.hpp" #include "XdmfError.hpp" #include "XdmfHeavyDataController.hpp" #include "XdmfSystemUtils.hpp" XdmfHeavyDataController::XdmfHeavyDataController(const std::string & filePath, const shared_ptr & type, const std::vector & starts, const std::vector & strides, const std::vector & dimensions, const std::vector & dataspaces) : mStart(starts), mStride(strides), mDimensions(dimensions), mDataspaceDimensions(dataspaces), mFilePath(filePath), mArrayStartOffset(0), mType(type) { } XdmfHeavyDataController::XdmfHeavyDataController(const XdmfHeavyDataController& refController): mStart(refController.getStart()), mStride(refController.getStride()), mDimensions(refController.getDimensions()), mDataspaceDimensions(refController.getDataspaceDimensions()), mFilePath(refController.getFilePath()), mArrayStartOffset(refController.getArrayOffset()), mType(refController.getType()) { } XdmfHeavyDataController::~XdmfHeavyDataController() { } unsigned int XdmfHeavyDataController::getArrayOffset() const { return mArrayStartOffset; } std::string XdmfHeavyDataController::getDataspaceDescription() const { std::stringstream dimensionStream; for (unsigned int j = 0; j < this->getStart().size(); ++j) { dimensionStream << this->getStart()[j]; if (j < this->getStart().size() - 1) { dimensionStream << " "; } } dimensionStream << ":"; for (unsigned int j = 0; j < this->getStride().size(); ++j) { dimensionStream << this->getStride()[j]; if (j < this->getStride().size() - 1) { dimensionStream << " "; } } dimensionStream << ":"; for (unsigned int j = 0; j < this->getDimensions().size(); ++j) { dimensionStream << this->getDimensions()[j]; if (j < this->getDimensions().size() - 1) { dimensionStream << " "; } } dimensionStream << ":"; for (unsigned int j = 0; j < this->getDataspaceDimensions().size(); ++j) { dimensionStream << this->getDataspaceDimensions()[j]; if (j < this->getDataspaceDimensions().size() - 1) { dimensionStream << " "; } } return dimensionStream.str(); } std::vector XdmfHeavyDataController::getDataspaceDimensions() const { return mDataspaceDimensions; } unsigned int XdmfHeavyDataController::getDataspaceSize() const { return std::accumulate(mDataspaceDimensions.begin(), mDataspaceDimensions.end(), 1, std::multiplies()); } std::string XdmfHeavyDataController::getDescriptor() const { return ""; } std::vector XdmfHeavyDataController::getDimensions() const { return mDimensions; } std::string XdmfHeavyDataController::getFilePath() const { return mFilePath; } std::vector XdmfHeavyDataController::getStart() const { return mStart; } std::vector XdmfHeavyDataController::getStride() const { return mStride; } unsigned int XdmfHeavyDataController::getSize() const { return std::accumulate(mDimensions.begin(), mDimensions.end(), 1, std::multiplies()); } shared_ptr XdmfHeavyDataController::getType() const { return mType; } void XdmfHeavyDataController::setArrayOffset(unsigned int newOffset) { mArrayStartOffset = newOffset; } // C Wrappers void XdmfHeavyDataControllerFree(XDMFHEAVYDATACONTROLLER * item) { if (item != NULL) { delete ((XdmfHeavyDataController *)item); item = NULL; } } unsigned int * XdmfHeavyDataControllerGetDataspaceDimensions(XDMFHEAVYDATACONTROLLER * controller) { try { std::vector tempVector = ((XdmfHeavyDataController *)(controller))->getDataspaceDimensions(); unsigned int returnSize = tempVector.size(); unsigned int * returnArray = new unsigned int[returnSize](); for (unsigned int i = 0; i < returnSize; ++i) { returnArray[i] = tempVector[i]; } return returnArray; } catch (...) { std::vector tempVector = ((XdmfHeavyDataController *)(controller))->getDataspaceDimensions(); unsigned int returnSize = tempVector.size(); unsigned int * returnArray = new unsigned int[returnSize](); for (unsigned int i = 0; i < returnSize; ++i) { returnArray[i] = tempVector[i]; } return returnArray; } } unsigned int * XdmfHeavyDataControllerGetDimensions(XDMFHEAVYDATACONTROLLER * controller) { try { std::vector tempVector = ((XdmfHeavyDataController *)(controller))->getDimensions(); unsigned int returnSize = tempVector.size(); unsigned int * returnArray = new unsigned int[returnSize](); for (unsigned int i = 0; i < returnSize; ++i) { returnArray[i] = tempVector[i]; } return returnArray; } catch (...) { std::vector tempVector = ((XdmfHeavyDataController *)(controller))->getDimensions(); unsigned int returnSize = tempVector.size(); unsigned int * returnArray = new unsigned int[returnSize](); for (unsigned int i = 0; i < returnSize; ++i) { returnArray[i] = tempVector[i]; } return returnArray; } } char * XdmfHeavyDataControllerGetFilePath(XDMFHEAVYDATACONTROLLER * controller) { try { char * returnPointer = strdup(((XdmfHeavyDataController *)(controller))->getFilePath().c_str()); return returnPointer; } catch (...) { char * returnPointer = strdup(((XdmfHeavyDataController *)(controller))->getFilePath().c_str()); return returnPointer; } } char * XdmfHeavyDataControllerGetName(XDMFHEAVYDATACONTROLLER * controller) { try { char * returnPointer = strdup(((XdmfHeavyDataController *)(controller))->getName().c_str()); return returnPointer; } catch (...) { char * returnPointer = strdup(((XdmfHeavyDataController *)(controller))->getName().c_str()); return returnPointer; } } unsigned int XdmfHeavyDataControllerGetNumberDimensions(XDMFHEAVYDATACONTROLLER * controller) { return ((XdmfHeavyDataController *)(controller))->getDimensions().size(); } unsigned int XdmfHeavyDataControllerGetSize(XDMFHEAVYDATACONTROLLER * controller) { return ((XdmfHeavyDataController *)(controller))->getSize(); } unsigned int * XdmfHeavyDataControllerGetStart(XDMFHEAVYDATACONTROLLER * controller) { try { std::vector tempVector = ((XdmfHeavyDataController *)(controller))->getStart(); unsigned int returnSize = tempVector.size(); unsigned int * returnArray = new unsigned int[returnSize](); for (unsigned int i = 0; i < returnSize; ++i) { returnArray[i] = tempVector[i]; } return returnArray; } catch (...) { std::vector tempVector = ((XdmfHeavyDataController *)(controller))->getStart(); unsigned int returnSize = tempVector.size(); unsigned int * returnArray = new unsigned int[returnSize](); for (unsigned int i = 0; i < returnSize; ++i) { returnArray[i] = tempVector[i]; } return returnArray; } } unsigned int * XdmfHeavyDataControllerGetStride(XDMFHEAVYDATACONTROLLER * controller) { try { std::vector tempVector = ((XdmfHeavyDataController *)(controller))->getStride(); unsigned int returnSize = tempVector.size(); unsigned int * returnArray = new unsigned int[returnSize](); for (unsigned int i = 0; i < returnSize; ++i) { returnArray[i] = tempVector[i]; } return returnArray; } catch (...) { std::vector tempVector = ((XdmfHeavyDataController *)(controller))->getStride(); unsigned int returnSize = tempVector.size(); unsigned int * returnArray = new unsigned int[returnSize](); for (unsigned int i = 0; i < returnSize; ++i) { returnArray[i] = tempVector[i]; } return returnArray; } } void XdmfHeavyDataControllerSetArrayOffset(XDMFHEAVYDATACONTROLLER * controller, unsigned int newOffset) { ((XdmfHeavyDataController *)(controller))->setArrayOffset(newOffset); } unsigned int XdmfHeavyDataControllerGetArrayOffset(XDMFHEAVYDATACONTROLLER * controller) { return ((XdmfHeavyDataController *)(controller))->getArrayOffset(); } int XdmfHeavyDataControllerGetType(XDMFHEAVYDATACONTROLLER * controller, int * status) { XDMF_ERROR_WRAP_START(status) shared_ptr compareType = ((XdmfHeavyDataController *)(controller))->getType(); std::string typeName = compareType->getName(); unsigned int typePrecision = compareType->getElementSize(); if (typeName == XdmfArrayType::UInt8()->getName()) { return XDMF_ARRAY_TYPE_UINT8; } else if (typeName == XdmfArrayType::UInt16()->getName()) { return XDMF_ARRAY_TYPE_UINT16; } else if (typeName == XdmfArrayType::UInt32()->getName()) { return XDMF_ARRAY_TYPE_UINT32; } else if (typeName == XdmfArrayType::Int8()->getName()) { return XDMF_ARRAY_TYPE_INT8; } else if (typeName == XdmfArrayType::Int16()->getName()) { return XDMF_ARRAY_TYPE_INT16; } else if (typeName == XdmfArrayType::Int32()->getName() || typeName == XdmfArrayType::Int64()->getName()) { if (typePrecision == 4) { return XDMF_ARRAY_TYPE_INT32; } else if (typePrecision == 8) { return XDMF_ARRAY_TYPE_INT64; } else { } } else if (typeName == XdmfArrayType::Float32()->getName() || typeName == XdmfArrayType::Float64()->getName()) { if (typePrecision == 4) { return XDMF_ARRAY_TYPE_FLOAT32; } else if (typePrecision == 8) { return XDMF_ARRAY_TYPE_FLOAT64; } else { } } else if (typeName == XdmfArrayType::String()->getName()) { //This shouldn't be used from C bindings XdmfError::message(XdmfError::FATAL, "Error: String type not usable from C."); } else { XdmfError::message(XdmfError::FATAL, "Error: Invalid ArrayType."); } XDMF_ERROR_WRAP_END(status) return -1; } void XdmfHeavyDataControllerRead(XDMFHEAVYDATACONTROLLER * controller, void * array, int * status) { XDMF_ERROR_WRAP_START(status) ((XdmfHeavyDataController *)(controller))->read((XdmfArray *)array); XDMF_ERROR_WRAP_END(status) } xdmf-3.0+git20160803/core/XdmfArrayType.hpp0000640000175000017500000002100113003006557020264 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfArrayType.hpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef XDMFARRAYTYPE_HPP_ #define XDMFARRAYTYPE_HPP_ // C Compatible Includes #include "XdmfCore.hpp" #ifdef __cplusplus // Includes #include "XdmfItemProperty.hpp" #include /** * @brief Property describing what types of values an XdmfArray * contains. * * XdmfArrayType specifies the types of values stored in an XdmfArray. * A specific XdmfArrayType can be created by calling one of the * static methods in the class, i.e. XdmfArrayType::Int32(). * * Example of use: * * C++ * * @dontinclude ExampleXdmfArrayType.cpp * @skipline //#getType * @until //#getType * * Python * * @dontinclude XdmfExampleArrayType.py * @skipline #//getType * @until #//getType * * Xdmf supports the following attribute types: * Uninitialized * Int8 * Int16 * Int32 * Int64 * Float32 * Float64 * UInt8 * UInt16 * UInt32 * String */ class XDMFCORE_EXPORT XdmfArrayType : public XdmfItemProperty { public: virtual ~XdmfArrayType(); friend class XdmfArray; friend class XdmfCoreItemFactory; enum Format { Unsigned, Signed, Float }; // Supported XdmfArrayTypes static shared_ptr Uninitialized(); static shared_ptr Int8(); static shared_ptr Int16(); static shared_ptr Int32(); static shared_ptr Int64(); static shared_ptr Float32(); static shared_ptr Float64(); static shared_ptr UInt8(); static shared_ptr UInt16(); static shared_ptr UInt32(); static shared_ptr String(); /** * Compares the two types given and returns a type that is compatible with both. * * Example of use: * * C++ * * @skipline //#comparePrecision * @until //#comparePrecision * * Python * * @skipline #//comparePrecision * @until #//comparePrecision * * @param type1 The first type to be compared * @param type2 The second type to be compared * @return The type that is compatible with both provided types */ static shared_ptr comparePrecision(shared_ptr type1, shared_ptr type2); /** * Get the data size, in bytes, of the value associated with this * array type. * * Example of use: * * C++ * * @dontinclude ExampleXdmfArrayType.cpp * @skipline //#getElementSize * @until //#getElementSize * * Python * * @dontinclude XdmfExampleArrayType.py * @skipline #//getElementSize * @until #//getElementSize * * @return The data size, in bytes. */ unsigned int getElementSize() const; /** * Gets whether the data type is floating point or not. * * Example of use: * * C++ * * @dontinclude ExampleXdmfArrayType.cpp * @skipline //#getIsFloat * @until //#getIsFloat * * Python * * @dontinclude XdmfExampleArrayType.py * @skipline #//getIsFloat * @until #//getIsFloat * * @return Whether the data type is signed. */ bool getIsFloat() const; /** * Gets whether the data type is signed or not. * * Example of use: * * C++ * * @dontinclude ExampleXdmfArrayType.cpp * @skipline //#getIsSigned * @until //#getIsSigned * * Python * * @dontinclude XdmfExampleArrayType.py * @skipline #//getIsSigned * @until #//getIsSigned * * @return Whether the data type is signed. */ bool getIsSigned() const; /** * Get the name of the data type. * * Example of use: * * C++ * * @dontinclude ExampleXdmfArrayType.cpp * @skipline //#getName * @until //#getName * * Python * * @dontinclude XdmfExampleArrayType.py * @skipline #//getName * @until #//getName * * @return The name of the data type. */ std::string getName() const; void getProperties(std::map & collectedProperties) const; protected: /** * Protected constructor for XdmfArrayType. The constructor is * protected because all array types supported by Xdmf should be * accessed through more specific static methods that construct * XdmfArrayTypes - i.e. XdmfArrayType::Float64(). * * @param name the name of the XdmfArrayType to construct. * @param precision the precision, in bytes, of the XdmfArrayType to * construct. * @param typeFormat The format description of the XdmfArrayType. */ XdmfArrayType(const std::string & name, const unsigned int precision, const Format typeFormat); static std::map(*)()> > mArrayDefinitions; static void InitTypes(); private: XdmfArrayType(const XdmfArrayType &); // Not implemented. void operator=(const XdmfArrayType &); // Not implemented. static shared_ptr New(const std::map & itemProperties); const std::string mName; const unsigned int mPrecision; std::string mPrecisionString; Format mTypeFormat; const char * mTypeId; // Allows for up to 16 byte sizes for unsigned, signed, and floating point types // The vector is actually larger than that to allow for the string and uninitialized types static std::vector > mTypes; // Due to uninitialized taking position 0 the size of the array is actually one over the max size static unsigned int mCurrentMaxSize; // Map of typeid to index in mTypes static std::map > mTypeIdMap; }; #endif #define XDMF_ARRAY_TYPE_INT8 0 #define XDMF_ARRAY_TYPE_INT16 1 #define XDMF_ARRAY_TYPE_INT32 2 #define XDMF_ARRAY_TYPE_INT64 3 #define XDMF_ARRAY_TYPE_UINT8 4 #define XDMF_ARRAY_TYPE_UINT16 5 #define XDMF_ARRAY_TYPE_UINT32 6 #define XDMF_ARRAY_TYPE_FLOAT32 7 #define XDMF_ARRAY_TYPE_FLOAT64 8 #ifdef __cplusplus extern "C" { #endif // These simply return the values defined above XDMFCORE_EXPORT int XdmfArrayTypeInt8(); XDMFCORE_EXPORT int XdmfArrayTypeInt16(); XDMFCORE_EXPORT int XdmfArrayTypeInt32(); XDMFCORE_EXPORT int XdmfArrayTypeInt64(); XDMFCORE_EXPORT int XdmfArrayTypeFloat32(); XDMFCORE_EXPORT int XdmfArrayTypeFloat64(); XDMFCORE_EXPORT int XdmfArrayTypeUInt8(); XDMFCORE_EXPORT int XdmfArrayTypeUInt16(); XDMFCORE_EXPORT int XdmfArrayTypeUInt32(); XDMFCORE_EXPORT int XdmfArrayTypeComparePrecision(int type1, int type2, int * status); XDMFCORE_EXPORT int XdmfArrayTypeGetElementSize(int type, int * status); XDMFCORE_EXPORT int XdmfArrayTypeGetIsFloat(int type, int * status); XDMFCORE_EXPORT int XdmfArrayTypeGetIsSigned(int type, int * status); XDMFCORE_EXPORT char * XdmfArrayTypeGetName(int type, int * status); #ifdef __cplusplus } #endif #endif /* XDMFARRAYTYPE_HPP_ */ xdmf-3.0+git20160803/core/XdmfSubset.hpp0000640000175000017500000003064313003006557017625 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfSubset.hpp */ /* */ /* Author: */ /* Andrew Burns */ /* andrew.j.burns2@us.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2013 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef XDMFSUBSET_HPP_ #define XDMFSUBSET_HPP_ // C Compatible Includes #include "XdmfCore.hpp" #include "XdmfArrayReference.hpp" #include "XdmfItem.hpp" #ifdef __cplusplus // Forward Declarations class XdmfArray; // Includes #include #include "XdmfSharedPtr.hpp" /** * @brief Couples an XdmfArray with heavy data stored in another XdmfArray. * * This class serves to allow an array to retrieve data that is a subsection * of an already existing array. */ class XDMFCORE_EXPORT XdmfSubset: public XdmfArrayReference { public: /** * Generates an XdmfSubset object based on the parameters provided * * Example of use: * * C++ * * @dontinclude ExampleXdmfSubset.cpp * @skipline //#initialization * @until //#initialization * * Python * * @dontinclude XdmfExampleSubset.py * @skipline #//initialization * @until #//initialization * * @param referenceArray The array that the subset is generated from. * @param start A vector of the starting points for each * dimension. * @param stride A vector of the strides for each dimension. * @param dimensions A vector of the amount of values read from each * dimension. * @return A constructed XdmfSubset */ static shared_ptr New(shared_ptr referenceArray, std::vector & start, std::vector & stride, std::vector & dimensions); virtual ~XdmfSubset(); LOKI_DEFINE_VISITABLE(XdmfSubset, XdmfItem) static const std::string ItemTag; /** * Get the dimensions of the set referenced by this subset. * * Example of use: * * C++ * * @dontinclude ExampleXdmfSubset.cpp * @skipline //#initialization * @until //#initialization * @skipline //#getDimensions * @until //#getDimensions * * Python * * @dontinclude XdmfExampleSubset.py * @skipline #//initialization * @until #//initialization * @skipline #//getDimensions * @until #//getDimensions * * @return A vector containing the size in each dimension of the * set referenced by this subset. */ std::vector getDimensions() const; std::map getItemProperties() const; std::string getItemTag() const; /** * Gets the array that the subset pulls data from. * * Example of use: * * C++ * * @dontinclude ExampleXdmfSubset.cpp * @skipline //#initialization * @until //#initialization * @skipline //#getReferenceArray * @until //#getReferenceArray * * Python * * @dontinclude XdmfExampleSubset.py * @skipline #//initialization * @until #//initialization * @skipline #//getReferenceArray * @until #//getReferenceArray * * @return The array that the subset pulls data from */ shared_ptr getReferenceArray(); /** * Get the size of the set referenced by this subset. * * Example of use: * * C++ * * @dontinclude ExampleXdmfSubset.cpp * @skipline //#initialization * @until //#initialization * @skipline //#getSize * @until //#getSize * * Python * * @dontinclude XdmfExampleSubset.py * @skipline #//initialization * @until #//initialization * @skipline #//getSize * @until #//getSize * * @return An int containing the size of the subset. */ unsigned int getSize() const; /** * Get the start index of the set referenced by this subset. * * Example of use: * * C++ * * @dontinclude ExampleXdmfSubset.cpp * @skipline //#initialization * @until //#initialization * @skipline //#getStart * @until //#getStart * * Python * * @dontinclude XdmfExampleSubset.py * @skipline #//initialization * @until #//initialization * @skipline #//getStart * @until #//getStart * * @return A vector containing the start index in each dimension of * the set referenced by this subset. */ std::vector getStart() const; /** * Get the stride of the set referenced by this subset. * * Example of use: * * C++ * * @dontinclude ExampleXdmfSubset.cpp * @skipline //#initialization * @until //#initialization * @skipline //#getStride * @until //#getStride * * Python * * @dontinclude XdmfExampleSubset.py * @skipline #//initialization * @until #//initialization * @skipline #//getStride * @until #//getStride * * @return A vector containing the stride in each dimension of the * heavy data set owned by this controller. */ std::vector getStride() const; /** * Read data reference by this subset and return as an XdmfArray. * * Example of use: * * C++ * * @dontinclude ExampleXdmfSubset.cpp * @skipline //#initialization * @until //#initialization * @skipline //#read * @until //#read * * Python * * @dontinclude XdmfExampleSubset.py * @skipline #//initialization * @until #//initialization * @skipline #//read * @until #//read * * @return An array filled with data based on the subset's parameters. */ virtual shared_ptr read() const; /** * Set the dimensions of the set referenced by this subset. * * Example of use: * * C++ * * @dontinclude ExampleXdmfSubset.cpp * @skipline //#initialization * @until //#initialization * @skipline //#getDimensions * @until //#getDimensions * @skipline //#setDimensions * @until //#setDimensions * * Python * * @dontinclude XdmfExampleSubset.py * @skipline #//initialization * @until #//initialization * @skipline #//getDimensions * @until #//getDimensions * @skipline #//setDimensions * @until #//setDimensions * * @param newDimensions A vector containing the size in each dimension * of the set to be referenced by this subset. */ void setDimensions(std::vector newDimensions); /** * Set the Array that the subset is generated from. * * Example of use: * * C++ * * @dontinclude ExampleXdmfSubset.cpp * @skipline //#initialization * @until //#initialization * @skipline //#getReferenceArray * @until //#getReferenceArray * @skipline //#setReferenceArray * @until //#setReferenceArray * * Python * * @dontinclude XdmfExampleSubset.py * @skipline #//initialization * @until #//initialization * @skipline #//getReferenceArray * @until #//getReferenceArray * @skipline #//setReferenceArray * @until #//setReferenceArray * * @param newReference A shared pointer to the array that the subset * will be generated from */ void setReferenceArray(shared_ptr newReference); /** * Set the start index of the set referenced by this subset. * * Example of use: * * C++ * * @dontinclude ExampleXdmfSubset.cpp * @skipline //#initialization * @until //#initialization * @skipline //#getStart * @until //#getStart * @skipline //#setStart * @until //#setStart * * Python * * @dontinclude XdmfExampleSubset.py * @skipline #//initialization * @until #//initialization * @skipline #//getStart * @until #//getStart * @skipline #//setStart * @until #//setStart * * @param newStarts A vector containing the start index in each * dimension of the set to be referenced by this * subset. */ void setStart(std::vector newStarts); /** * Set the stride of the heavy data set owned by this controller. * * Example of use: * * Example of use: * * C++ * * @dontinclude ExampleXdmfSubset.cpp * @skipline //#initialization * @until //#initialization * @skipline //#getStride * @until //#getStride * @skipline //#setStride * @until //#setStride * * Python * * @dontinclude XdmfExampleSubset.py * @skipline #//initialization * @until #//initialization * @skipline #//getStride * @until #//getStride * @skipline #//setStride * @until #//setStride * * @param newStrides A vector containing the stride in each * dimension of the set referenced by this subset. */ void setStride(std::vector newStrides); void traverse(const shared_ptr visitor); XdmfSubset(XdmfSubset&); protected: XdmfSubset(shared_ptr referenceArray, std::vector & start, std::vector & stride, std::vector & dimensions); void populateItem(const std::map & itemProperties, const std::vector > & childItems, const XdmfCoreReader * const reader); shared_ptr mParent; std::vector mDimensions; std::vector mStart; std::vector mStride; private: XdmfSubset(const XdmfSubset&); // Not implemented. void operator=(const XdmfSubset &); // Not implemented. }; #endif #ifdef __cplusplus extern "C" { #endif // C wrappers go here struct XDMFSUBSET; // Simply as a typedef to ensure correct typing typedef struct XDMFSUBSET XDMFSUBSET; XDMFCORE_EXPORT XDMFSUBSET * XdmfSubsetNew(void * referenceArray, unsigned int * start, unsigned int * stride, unsigned int * dimensions, unsigned int numDims, int passControl, int * status); XDMFCORE_EXPORT unsigned int * XdmfSubsetGetDimensions(XDMFSUBSET * subset); XDMFCORE_EXPORT unsigned int XdmfSubsetGetNumberDimensions(XDMFSUBSET * subset); XDMFCORE_EXPORT void * XdmfSubsetGetReferenceArray(XDMFSUBSET * subset); XDMFCORE_EXPORT unsigned int XdmfSubsetGetSize(XDMFSUBSET * subset); XDMFCORE_EXPORT unsigned int * XdmfSubsetGetStart(XDMFSUBSET * subset); XDMFCORE_EXPORT unsigned int * XdmfSubsetGetStride(XDMFSUBSET * subset); XDMFCORE_EXPORT void XdmfSubsetSetDimensions(XDMFSUBSET * subset, unsigned int * newDimensions, unsigned int numDims, int * status); XDMFCORE_EXPORT void XdmfSubsetSetReferenceArray(XDMFSUBSET * subset, XDMFARRAY * referenceArray, int passControl); XDMFCORE_EXPORT void XdmfSubsetSetStart(XDMFSUBSET * subset, unsigned int * newStarts, unsigned int numDims, int * status); XDMFCORE_EXPORT void XdmfSubsetSetStride(XDMFSUBSET * subset, unsigned int * newStrides, unsigned int numDims, int * status); // C Wrappers for parent classes are generated by macros XDMF_ITEM_C_CHILD_DECLARE(XdmfSubset, XDMFSUBSET, XDMFCORE) XDMF_ARRAYREFERENCE_C_CHILD_DECLARE(XdmfSubset, XDMFSUBSET, XDMFCORE) #ifdef __cplusplus } #endif #endif /* XDMFSUBSET_HPP_ */ xdmf-3.0+git20160803/core/XdmfArray.cpp0000640000175000017500000023400413003006557017426 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfArray.cpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #include #include #include #include #include #include #include #include "XdmfArray.hpp" #include "XdmfArrayType.hpp" #include "XdmfArrayReference.hpp" #include "XdmfBinaryController.hpp" #include "XdmfCoreReader.hpp" #include "XdmfFunction.hpp" #include "XdmfSubset.hpp" #include "XdmfHeavyDataController.hpp" #include "XdmfVisitor.hpp" #include "XdmfError.hpp" XDMF_CHILDREN_IMPLEMENTATION(XdmfArray, XdmfHeavyDataController, HeavyDataController, Name) class XdmfArray::Clear : public boost::static_visitor { public: Clear(XdmfArray * const array) : mArray(array) { } void operator()(const boost::blank & array) const { return; } template void operator()(const shared_ptr > & array) const { array->clear(); } template void operator()(const boost::shared_array & array) const { mArray->internalizeArrayPointer(); boost::apply_visitor(*this, mArray->mArray); } private: XdmfArray * const mArray; }; class XdmfArray::Erase : public boost::static_visitor { public: Erase(XdmfArray * const array, const unsigned int index) : mArray(array), mIndex(index) { } void operator()(const boost::blank & array) const { return; } template void operator()(const shared_ptr > & array) const { array->erase(array->begin() + mIndex); } template void operator()(const boost::shared_array & array) const { mArray->internalizeArrayPointer(); boost::apply_visitor(*this, mArray->mArray); } private: XdmfArray * const mArray; const unsigned int mIndex; }; class XdmfArray::GetArrayType : public boost::static_visitor > { public: GetArrayType(const shared_ptr & heavyDataController) : mHeavyDataController(heavyDataController) { } shared_ptr getArrayType(const char * const) const { return XdmfArrayType::Int8(); } shared_ptr getArrayType(const short * const) const { return XdmfArrayType::Int16(); } shared_ptr getArrayType(const int * const) const { return XdmfArrayType::Int32(); } shared_ptr getArrayType(const long * const) const { return XdmfArrayType::Int64(); } shared_ptr getArrayType(const float * const) const { return XdmfArrayType::Float32(); } shared_ptr getArrayType(const double * const) const { return XdmfArrayType::Float64(); } shared_ptr getArrayType(const unsigned char * const) const { return XdmfArrayType::UInt8(); } shared_ptr getArrayType(const unsigned short * const) const { return XdmfArrayType::UInt16(); } shared_ptr getArrayType(const unsigned int * const) const { return XdmfArrayType::UInt32(); } shared_ptr getArrayType(const std::string * const) const { return XdmfArrayType::String(); } shared_ptr operator()(const boost::blank & array) const { if(mHeavyDataController) { return mHeavyDataController->getType(); } return XdmfArrayType::Uninitialized(); } template shared_ptr operator()(const shared_ptr > & array) const { return this->getArrayType(&(array.get()->operator[](0))); } template shared_ptr operator()(const boost::shared_array & array) const { return this->getArrayType(array.get()); } private: const shared_ptr mHeavyDataController; }; class XdmfArray::GetCapacity : public boost::static_visitor { public: GetCapacity() { } unsigned int operator()(const boost::blank & array) const { return 0; } template unsigned int operator()(const shared_ptr > & array) const { return array->capacity(); } template unsigned int operator()(const boost::shared_array & array) const { return 0; } }; class XdmfArray::GetValuesPointer : public boost::static_visitor { public: GetValuesPointer() { } const void * operator()(const boost::blank & array) const { return NULL; } template const void * operator()(const shared_ptr > & array) const { return &array->operator[](0); } template const void * operator()(const boost::shared_array & array) const { return array.get(); } }; class XdmfArray::GetValuesString : public boost::static_visitor { public: GetValuesString(const int arrayPointerNumValues) : mArrayPointerNumValues(arrayPointerNumValues) { } template std::string getValuesString(const T * const array, const int numValues) const { const int lastIndex = numValues - 1; if(lastIndex < 0) { return ""; } std::stringstream toReturn; toReturn.precision(std::numeric_limits::digits10 + 2); for(int i=0; i(array, numValues); } std::string getValuesString(const unsigned char * const array, const int numValues) const { return getValuesString(array, numValues); } template std::string getValuesString(const T * const array, const int numValues) const { return getValuesString(array, numValues); } std::string operator()(const boost::blank & array) const { return ""; } template std::string operator()(const shared_ptr > & array) const { return getValuesString(&(array->operator[](0)), array->size()); } template std::string operator()(const boost::shared_array & array) const { return getValuesString(array.get(), mArrayPointerNumValues); } private: const unsigned int mArrayPointerNumValues; }; class XdmfArray::InsertArray : public boost::static_visitor { public: InsertArray(XdmfArray * const array, const unsigned int startIndex, const unsigned int valuesStartIndex, const unsigned int numValues, const unsigned int arrayStride, const unsigned int valuesStride, std::vector & dimensions, const shared_ptr & arrayToCopy) : mArray(array), mStartIndex(startIndex), mValuesStartIndex(valuesStartIndex), mNumValues(numValues), mArrayStride(arrayStride), mValuesStride(valuesStride), mDimensions(dimensions), mArrayToCopy(arrayToCopy) { } void operator()(const boost::blank & array) const { const shared_ptr copyType = mArrayToCopy->getArrayType(); if(copyType == XdmfArrayType::Uninitialized()) { return; } mArray->initialize(copyType); boost::apply_visitor(*this, mArray->mArray); } template void operator()(const shared_ptr > & array) const { unsigned int size = mStartIndex + (mNumValues - 1) * mArrayStride + 1; if(array->size() < size) { array->resize(size); mDimensions.clear(); } mArrayToCopy->getValues(mValuesStartIndex, &(array->operator[](mStartIndex)), mNumValues, mValuesStride, mArrayStride); } template void operator()(const boost::shared_array & array) const { mArray->internalizeArrayPointer(); boost::apply_visitor(*this, mArray->mArray); } private: XdmfArray * const mArray; const unsigned int mStartIndex; const unsigned int mValuesStartIndex; const unsigned int mNumValues; const unsigned int mArrayStride; const unsigned int mValuesStride; std::vector & mDimensions; const shared_ptr mArrayToCopy; }; class XdmfArray::InternalizeArrayPointer : public boost::static_visitor { public: InternalizeArrayPointer(XdmfArray * const array) : mArray(array) { } void operator()(const boost::blank & array) const { return; } template void operator()(const shared_ptr > & array) const { return; } template void operator()(const boost::shared_array & array) const { const T * const pointer = array.get(); shared_ptr > newArray(new std::vector(pointer, pointer + mArray->mArrayPointerNumValues)); mArray->mArray = newArray; mArray->mArrayPointerNumValues = 0; } private: XdmfArray * const mArray; }; class XdmfArray::IsInitialized : public boost::static_visitor { public: IsInitialized() { } bool operator()(const boost::blank &) const { return false; } template bool operator()(const shared_ptr > &) const { return true; } template bool operator()(const T &) const { return true; } }; class XdmfArray::Reserve : public boost::static_visitor { public: Reserve(XdmfArray * const array, const unsigned int size): mArray(array), mSize(size) { } void operator()(const boost::blank & array) const { mArray->mTmpReserveSize = mSize; } template void operator()(shared_ptr > & array) const { array->reserve(mSize); } template void operator()(const boost::shared_array & array) const { mArray->internalizeArrayPointer(); boost::apply_visitor(*this, mArray->mArray); } private: XdmfArray * const mArray; const unsigned int mSize; }; class XdmfArray::Size : public boost::static_visitor { public: Size(const XdmfArray * const array) : mArray(array) { } unsigned int operator()(const boost::blank & array) const { unsigned int total = 0; for (unsigned int i = 0; i < mArray->mHeavyDataControllers.size(); ++i) { total += mArray->mHeavyDataControllers[i]->getSize(); } return total; } template unsigned int operator()(const shared_ptr > & array) const { return array->size(); } template unsigned int operator()(const boost::shared_array & array) const { return mArray->mArrayPointerNumValues; } private: const XdmfArray * const mArray; }; shared_ptr XdmfArray::New() { shared_ptr p(new XdmfArray()); return p; } XdmfArray::XdmfArray() : mArrayPointerNumValues(0), mName(""), mTmpReserveSize(0), mReadMode(XdmfArray::Controller) { } XdmfArray::XdmfArray(XdmfArray & refArray): XdmfItem(refArray), mDimensions(refArray.getDimensions()), mName(refArray.getName()), mReadMode(refArray.getReadMode()) { if (refArray.getArrayType() != XdmfArrayType::Uninitialized()) { this->initialize(refArray.getArrayType(), 0); if (refArray.getSize() > 0) { shared_ptr tempPointer = shared_ptr(&refArray, XdmfNullDeleter()); this->insert(0, tempPointer, 0, tempPointer->getSize()); } } if (refArray.getNumberHeavyDataControllers() > 0) { for (unsigned int i = 0; i < refArray.getNumberHeavyDataControllers(); ++i) { this->insert(refArray.getHeavyDataController(i)); } } if (refArray.mReference) { this->setReference(refArray.getReference()); } } XdmfArray::~XdmfArray() { } const std::string XdmfArray::ItemTag = "DataItem"; void XdmfArray::clear() { boost::apply_visitor(Clear(this), mArray); mDimensions.clear(); this->setIsChanged(true); } void XdmfArray::erase(const unsigned int index) { boost::apply_visitor(Erase(this, index), mArray); mDimensions.clear(); this->setIsChanged(true); } shared_ptr XdmfArray::getArrayType() const { if (mHeavyDataControllers.size()>0) { return boost::apply_visitor(GetArrayType(mHeavyDataControllers[0]), mArray); } else { return boost::apply_visitor(GetArrayType(shared_ptr()), mArray); } } unsigned int XdmfArray::getCapacity() const { return boost::apply_visitor(GetCapacity(), mArray); } std::vector XdmfArray::getDimensions() const { if(mDimensions.size() == 0) { if(!this->isInitialized() && mHeavyDataControllers.size() > 0) { std::vector returnDimensions; std::vector tempDimensions; // Find the controller with the most dimensions int dimControllerIndex = 0; unsigned int dimSizeMax = 0; unsigned int dimTotal = 0; for (unsigned int i = 0; i < mHeavyDataControllers.size(); ++i) { dimTotal += mHeavyDataControllers[i]->getSize(); if (mHeavyDataControllers[i]->getSize() > dimSizeMax) { dimSizeMax = mHeavyDataControllers[i]->getSize(); dimControllerIndex = i; } } // Total up the size of the lower dimensions int controllerDimensionSubtotal = 1; for (unsigned int i = 0; i < mHeavyDataControllers[dimControllerIndex]->getDimensions().size() - 1; ++i) { returnDimensions.push_back(mHeavyDataControllers[dimControllerIndex]->getDimensions()[i]); controllerDimensionSubtotal *= mHeavyDataControllers[dimControllerIndex]->getDimensions()[i]; } // Divide the total contained by the dimensions by the size of the lower dimensions returnDimensions.push_back(dimTotal/controllerDimensionSubtotal); return returnDimensions; } const unsigned int size = this->getSize(); return std::vector(1, size); } return mDimensions; } std::string XdmfArray::getDimensionsString() const { const std::vector dimensions = this->getDimensions(); return GetValuesString(dimensions.size()).getValuesString(&dimensions[0], dimensions.size()); } std::map XdmfArray::getItemProperties() const { std::map arrayProperties; if(mHeavyDataControllers.size() > 0) { mHeavyDataControllers[0]->getProperties(arrayProperties); } else { arrayProperties.insert(std::make_pair("Format", "XML")); } arrayProperties.insert(std::make_pair("Dimensions", this->getDimensionsString())); if(mName.compare("") != 0) { arrayProperties.insert(std::make_pair("Name", mName)); } shared_ptr type = this->getArrayType(); type->getProperties(arrayProperties); return arrayProperties; } std::string XdmfArray::getItemTag() const { return ItemTag; } std::string XdmfArray::getName() const { return mName; } XdmfArray::ReadMode XdmfArray::getReadMode() const { return mReadMode; } unsigned int XdmfArray::getSize() const { return boost::apply_visitor(Size(this), mArray); } shared_ptr XdmfArray::getReference() { if (mReference) { return mReference; } else { // Returning arbitrary Reference since one isn't defined return shared_ptr(); } } void * XdmfArray::getValuesInternal() { return const_cast (static_cast(*this).getValuesInternal()); } const void * XdmfArray::getValuesInternal() const { return boost::apply_visitor(GetValuesPointer(), mArray); } std::string XdmfArray::getValuesString() const { return boost::apply_visitor(GetValuesString(mArrayPointerNumValues), mArray); } shared_ptr XdmfArray::getHeavyDataController() { return boost::const_pointer_cast (static_cast(*this).getHeavyDataController(0)); } shared_ptr XdmfArray::getHeavyDataController() const { if (mHeavyDataControllers.size() > 0) { return mHeavyDataControllers[0]; } else { return shared_ptr(); } } void XdmfArray::initialize(const shared_ptr & arrayType, const unsigned int size) { if(arrayType == XdmfArrayType::Int8()) { this->initialize(size); } else if(arrayType == XdmfArrayType::Int16()) { this->initialize(size); } else if(arrayType == XdmfArrayType::Int32()) { this->initialize(size); } else if(arrayType == XdmfArrayType::Int64()) { this->initialize(size); } else if(arrayType == XdmfArrayType::Float32()) { this->initialize(size); } else if(arrayType == XdmfArrayType::Float64()) { this->initialize(size); } else if(arrayType == XdmfArrayType::UInt8()) { this->initialize(size); } else if(arrayType == XdmfArrayType::UInt16()) { this->initialize(size); } else if(arrayType == XdmfArrayType::UInt32()) { this->initialize(size); } else if(arrayType == XdmfArrayType::String()) { this->initialize(size); } else if(arrayType == XdmfArrayType::Uninitialized()) { this->release(); } else { XdmfError::message(XdmfError::FATAL, "Array of unsupported type in XdmfArray::initialize"); } this->setIsChanged(true); } void XdmfArray::initialize(const shared_ptr & arrayType, const std::vector & dimensions) { mDimensions = dimensions; const unsigned int size = std::accumulate(dimensions.begin(), dimensions.end(), 1, std::multiplies()); return this->initialize(arrayType, size); } void XdmfArray::insert(const unsigned int startIndex, const shared_ptr values, const unsigned int valuesStartIndex, const unsigned int numValues, const unsigned int arrayStride, const unsigned int valuesStride) { boost::apply_visitor(InsertArray(this, startIndex, valuesStartIndex, numValues, arrayStride, valuesStride, mDimensions, values), mArray); this->setIsChanged(true); } void XdmfArray::insert(const std::vector startIndex, const shared_ptr values, const std::vector valuesStartIndex, const std::vector numValues, const std::vector numInserted, const std::vector arrayStride, const std::vector valuesStride) { // Ensuring dimensions match up when pulling data if ((values->getDimensions().size() == valuesStartIndex.size() && valuesStartIndex.size() == numValues.size() && numValues.size() == valuesStride.size()) && (numInserted.size() == startIndex.size() && startIndex.size() == this->getDimensions().size() && this->getDimensions().size() == arrayStride.size())) { // Pull data from values std::vector dimTotalVector; unsigned int dimTotal = 1; for (unsigned int i = 0; i < values->getDimensions().size(); ++i) { dimTotalVector.push_back(dimTotal); dimTotal *= values->getDimensions()[i]; } std::vector indexVector; for (unsigned int i = 0; i < values->getDimensions().size(); ++i) { indexVector.push_back(0); } shared_ptr holderArray = XdmfArray::New(); unsigned int holderoffset = 0; // End when the last index is incremented while (indexVector[indexVector.size()-1] < 1) { // Initialize the section of the array you're pulling from unsigned int startTotal = 0; dimTotal = 1; for (unsigned int i = 0; i < values->getDimensions().size(); ++i) { // Stride doesn't factor in to the first dimension // Since it's being used with the insert call if (i == 0) { startTotal += valuesStartIndex[i] * dimTotal; } else { startTotal += valuesStartIndex[i] * dimTotal + valuesStride[i] * dimTotal * indexVector[i-1]; } dimTotal *= values->getDimensions()[i]; } // Insert the subsection holderArray->insert(holderoffset, values, startTotal, numValues[0], 1, valuesStride[0]); holderoffset+=numValues[0]; // Increment up the vector bool increment = true; for (unsigned int i = 0; i < indexVector.size() && increment; ++i) { indexVector[i]++; // To keep the loop from breaking at the end if (i+1 < numValues.size()) { if (indexVector[i] >= numValues[i+1]) { indexVector[i] = indexVector[i] % numValues[i+1]; } else { increment = false; } } } } // Values being inserted retrieved // Use an variation of the last loop to insert into this array indexVector.clear(); for (unsigned int i = 0; i < this->getDimensions().size(); ++i) { indexVector.push_back(0); } holderoffset = 0; // End when the last index is incremented while (indexVector[indexVector.size()-1] < 1) { // Initialize the section of the array you're pulling from unsigned int startTotal = 0; dimTotal = 1; for (unsigned int i = 0; i < this->getDimensions().size(); ++i) { if (i == 0) { // Stride doesn't factor in to the first dimension // Since it's being used with the insert call startTotal += startIndex[i] * dimTotal; } else { startTotal += startIndex[i] * dimTotal + arrayStride[i] * dimTotal * indexVector[i-1]; } dimTotal *= this->getDimensions()[i]; } // Insert the subsection this->insert(startTotal, holderArray, holderoffset, numInserted[0], arrayStride[0], 1); holderoffset+=numInserted[0]; // Increment up the vector bool increment = true; for (unsigned int i = 0; i < indexVector.size() && increment; ++i) { indexVector[i]++; if (i+1 < numInserted.size()) { // To keep the loop from breaking at the end if (indexVector[i] >= numInserted[i+1]) { indexVector[i] = indexVector[i] % numInserted[i+1]; } else { increment = false; } } } } this->setIsChanged(true); } else { // Throw an error if (!(values->getDimensions().size() == valuesStartIndex.size() && valuesStartIndex.size() == numValues.size() && numValues.size() == valuesStride.size())) { XdmfError::message(XdmfError::FATAL, "Error: Number of starts, strides, and/or values " "retrieved does not match up with the dimensions " "of the array being retrieved from"); } else if (!(numInserted.size() == startIndex.size() && startIndex.size() == this->getDimensions().size() && this->getDimensions().size() == arrayStride.size())) { XdmfError::message(XdmfError::FATAL, "Error: Number of starts, strides, and/or values " "written does not match up with the dimensions " "of the array being inserted into"); } } } bool XdmfArray::isInitialized() const { return boost::apply_visitor(IsInitialized(), mArray); } void XdmfArray::internalizeArrayPointer() { boost::apply_visitor(InternalizeArrayPointer(this), mArray); } void XdmfArray::populateItem(const std::map & itemProperties, const std::vector > & childItems, const XdmfCoreReader * const reader) { // This inserts any XdmfInformation in childItems into the object. XdmfItem::populateItem(itemProperties, childItems, reader); bool filled = false; // Check for Function std::map::const_iterator itemType = itemProperties.find("ItemType"); if (itemType != itemProperties.end()) { if (itemType->second.compare("Function") == 0) { std::map::const_iterator expressionLocation = itemProperties.find("Function"); if (expressionLocation == itemProperties.end()) { XdmfError::message(XdmfError::FATAL, "'Function' not found in itemProperties for Function" " ItemType in XdmfArray::populateItem"); } std::string expression = expressionLocation->second; // Convert from old format to new Variable format // $X -> ValX size_t loc = expression.find("$"); while (loc != std::string::npos) { expression.replace(loc, 1, "Val"); loc = expression.find("$", loc); } // Create Variable list std::map > variableMap; unsigned int variableIndex = 0; for(std::vector >::const_iterator iter = childItems.begin(); iter != childItems.end(); ++iter) { if(shared_ptr array = shared_dynamic_cast(*iter)) { std::stringstream variableKey; variableKey << "Val" << variableIndex; variableMap[variableKey.str()] = array; variableIndex++; } } shared_ptr function = XdmfFunction::New(expression, variableMap); this->setReference(function); this->setReadMode(XdmfArray::Reference); filled = true; } else if (itemType->second.compare("HyperSlab") == 0) { shared_ptr dimArray; shared_ptr valArray; unsigned int foundArrayIndex = 0; for(std::vector >::const_iterator iter = childItems.begin(); iter != childItems.end(); ++iter) { if(shared_ptr array = shared_dynamic_cast(*iter)) { if (foundArrayIndex == 0) { dimArray = array; foundArrayIndex++; } else if (foundArrayIndex == 1) { valArray = array; foundArrayIndex++; } } } if (!(dimArray)) { XdmfError::message(XdmfError::FATAL, "Error: Hyperslab description missing"); } if (!(valArray)) { XdmfError::message(XdmfError::FATAL, "Error: Hyperslab values missing"); } if (dimArray->getSize() % 3 != 0) { XdmfError::message(XdmfError::FATAL, "Error: Hyperslab description structured improperly"); } // A start, stride, and dimension need to be // specified for each dimension unsigned int numDims = dimArray->getSize() / 3; // Start, stride, and dims are set via the first array provided std::vector start; std::vector stride; std::vector dimensions; unsigned int i = 0; while (i < dimArray->getSize() / 3) { start.push_back(dimArray->getValue(i)); ++i; } while (i < 2 * (dimArray->getSize() / 3)) { stride.push_back(dimArray->getValue(i)); ++i; } while (i < dimArray->getSize()) { dimensions.push_back(dimArray->getValue(i)); ++i; } shared_ptr subset = XdmfSubset::New(valArray, start, stride, dimensions); this->setReference(subset); this->setReadMode(XdmfArray::Reference); filled = true; } } if (!filled) { std::vector > readControllers = reader->generateHeavyDataControllers(itemProperties); mHeavyDataControllers.clear(); for (unsigned int i = 0; i < readControllers.size(); ++i) { mHeavyDataControllers.push_back(readControllers[i]); } const shared_ptr arrayType = XdmfArrayType::New(itemProperties); std::map::const_iterator content = itemProperties.find("Content"); if(content == itemProperties.end()) { XdmfError::message(XdmfError::FATAL, "'Content' not found in itemProperties in " "XdmfArray::populateItem"); } unsigned int contentIndex; const std::string & contentVal = content->second; std::vector contentVals; // Split the content based on "|" characters size_t barSplit = 0; std::string splitString(contentVal); std::string subcontent; while (barSplit != std::string::npos) { barSplit = 0; barSplit = splitString.find_first_of("|", barSplit); if (barSplit == std::string::npos) { subcontent = splitString; } else { subcontent = splitString.substr(0, barSplit); splitString = splitString.substr(barSplit+1); barSplit++; } contentVals.push_back(subcontent); } std::map::const_iterator dimensions = itemProperties.find("Dimensions"); if(dimensions == itemProperties.end()) { XdmfError::message(XdmfError::FATAL, "'Dimensions' not found in itemProperties in " "XdmfArray::populateItem"); } boost::tokenizer<> tokens(dimensions->second); for(boost::tokenizer<>::const_iterator iter = tokens.begin(); iter != tokens.end(); ++iter) { mDimensions.push_back(atoi((*iter).c_str())); } std::map::const_iterator format = itemProperties.find("Format"); if(format == itemProperties.end()) { XdmfError::message(XdmfError::FATAL, "'Format' not found in itemProperties in " "XdmfArray::populateItem"); } const std::string & formatVal = format->second; if (readControllers.size() == 0) { if(formatVal.compare("XML") == 0) { this->initialize(arrayType, mDimensions); unsigned int index = 0; boost::char_separator sep(" \t\n"); for (contentIndex = 0; contentIndex < contentVals.size(); ++contentIndex) { boost::tokenizer > tokens(contentVals[contentIndex], sep); if(arrayType == XdmfArrayType::String()) { for(boost::tokenizer >::const_iterator iter = tokens.begin(); iter != tokens.end(); ++iter, ++index) { this->insert(index, *iter); } } else { for(boost::tokenizer >::const_iterator iter = tokens.begin(); iter != tokens.end(); ++iter, ++index) { this->insert(index, atof((*iter).c_str())); } } } } else { XdmfError::message(XdmfError::FATAL, "Error: Invalid Data Format " "in XdmfArray::populateItem"); } } } std::map::const_iterator name = itemProperties.find("Name"); if(name != itemProperties.end()) { mName = name->second; } else { mName = ""; } this->setIsChanged(true); } void XdmfArray::read() { switch (mReadMode) { case XdmfArray::Controller: this->readController(); break; case XdmfArray::Reference: this->readReference(); break; default: XdmfError::message(XdmfError::FATAL, "Error: Invalid Read Mode"); } } void XdmfArray::readController() { if(mHeavyDataControllers.size() > 1) { this->release(); for (unsigned int i = 0; i < mHeavyDataControllers.size(); ++i) { shared_ptr tempArray = XdmfArray::New(); mHeavyDataControllers[i]->read(tempArray.get()); unsigned int dimTotal = 1; for (unsigned int j = 0; j < mHeavyDataControllers[i]->getDimensions().size(); ++j) { dimTotal *= mHeavyDataControllers[i]->getDimensions()[j]; } this->insert(mHeavyDataControllers[i]->getArrayOffset(), tempArray, 0, dimTotal, 1, 1); } std::vector returnDimensions; std::vector tempDimensions; // Find the controller with the most dimensions int dimControllerIndex = 0; unsigned int dimSizeMax = 0; unsigned int dimTotal = 0; for (unsigned int i = 0; i < mHeavyDataControllers.size(); ++i) { dimTotal += mHeavyDataControllers[i]->getSize(); if (mHeavyDataControllers[i]->getSize() > dimSizeMax) { dimSizeMax = mHeavyDataControllers[i]->getSize(); dimControllerIndex = i; } } // Total up the size of the lower dimensions int controllerDimensionSubtotal = 1; for (unsigned int i = 0; i < mHeavyDataControllers[dimControllerIndex]->getDimensions().size() - 1; ++i) { returnDimensions.push_back(mHeavyDataControllers[dimControllerIndex]->getDimensions()[i]); controllerDimensionSubtotal *= mHeavyDataControllers[dimControllerIndex]->getDimensions()[i]; } // Divide the total contained by the dimensions by the size of the lower dimensions returnDimensions.push_back(dimTotal/controllerDimensionSubtotal); mDimensions = returnDimensions; } else if (mHeavyDataControllers.size() == 1 && mHeavyDataControllers[0]->getArrayOffset() == 0) { this->release(); mHeavyDataControllers[0]->read(this); mDimensions = mHeavyDataControllers[0]->getDimensions(); } else if (mHeavyDataControllers.size() == 1 && mHeavyDataControllers[0]->getArrayOffset() > 0) { this->release(); shared_ptr tempArray = XdmfArray::New(); mHeavyDataControllers[0]->read(tempArray.get()); this->insert(mHeavyDataControllers[0]->getArrayOffset(), tempArray, 0, mHeavyDataControllers[0]->getSize(), 1, 1); mDimensions = mHeavyDataControllers[0]->getDimensions(); } this->setIsChanged(true); } void XdmfArray::readReference() { shared_ptr tempArray = mReference->read(); this->swap(tempArray); this->setIsChanged(true); } void XdmfArray::release() { mArray = boost::blank(); mArrayPointerNumValues = 0; mDimensions.clear(); } void XdmfArray::reserve(const unsigned int size) { boost::apply_visitor(Reserve(this, size), mArray); this->setIsChanged(true); } void XdmfArray::setHeavyDataController(shared_ptr newController) { // Since this is replacing the previous version which was designed to // completely replace the controller of the array // It will clear the current controllers before adding the new one in mHeavyDataControllers.clear(); mHeavyDataControllers.push_back(newController); this->setIsChanged(true); } void XdmfArray::setHeavyDataController(std::vector > & newControllers) { if (mHeavyDataControllers.size() != newControllers.size()) { mHeavyDataControllers.resize(newControllers.size()); } for (unsigned int i = 0; i < newControllers.size(); ++i) { mHeavyDataControllers[i] = newControllers[i]; } this->setIsChanged(true); } void XdmfArray::setName(const std::string & name) { mName = name; this->setIsChanged(true); } void XdmfArray::setReadMode(XdmfArray::ReadMode newStatus) { mReadMode = newStatus; this->setIsChanged(true); } void XdmfArray::setReference(shared_ptr newReference) { mReference = newReference; this->setIsChanged(true); } void XdmfArray::swap(const shared_ptr array) { std::swap(mArray, array->mArray); std::swap(mArrayPointerNumValues, array->mArrayPointerNumValues); std::swap(mDimensions, array->mDimensions); std::swap(mHeavyDataControllers, array->mHeavyDataControllers); this->setIsChanged(true); } void XdmfArray::traverse(const shared_ptr visitor) { XdmfItem::traverse(visitor); if (mReference) { mReference->accept(visitor); } } // C wrappers XDMFARRAY * XdmfArrayNew() { try { XDMFARRAY * returnPointer; shared_ptr generatedArray = XdmfArray::New(); returnPointer = (XDMFARRAY *)((void *)(new XdmfArray(*generatedArray.get()))); generatedArray.reset(); return returnPointer; } catch (...) { XDMFARRAY * returnPointer; shared_ptr generatedArray = XdmfArray::New(); returnPointer = (XDMFARRAY *)((void *)(new XdmfArray(*generatedArray.get()))); generatedArray.reset(); return returnPointer; } } void XdmfArrayClear(XDMFARRAY * array) { ((XdmfArray *)(array))->clear(); } void XdmfArrayErase(XDMFARRAY * array, unsigned int index) { ((XdmfArray *)(array))->erase(index); } int XdmfArrayGetArrayType(XDMFARRAY * array, int * status) { XDMF_ERROR_WRAP_START(status) shared_ptr compareType = ((XdmfArray *)(array))->getArrayType(); std::string typeName = compareType->getName(); unsigned int typePrecision = compareType->getElementSize(); if (typeName == XdmfArrayType::UInt8()->getName()) { return XDMF_ARRAY_TYPE_UINT8; } else if (typeName == XdmfArrayType::UInt16()->getName()) { return XDMF_ARRAY_TYPE_UINT16; } else if (typeName == XdmfArrayType::UInt32()->getName()) { return XDMF_ARRAY_TYPE_UINT32; } else if (typeName == XdmfArrayType::Int8()->getName()) { return XDMF_ARRAY_TYPE_INT8; } else if (typeName == XdmfArrayType::Int16()->getName()) { return XDMF_ARRAY_TYPE_INT16; } else if (typeName == XdmfArrayType::Int32()->getName() || typeName == XdmfArrayType::Int64()->getName()) { if (typePrecision == 4) { return XDMF_ARRAY_TYPE_INT32; } else if (typePrecision == 8) { return XDMF_ARRAY_TYPE_INT64; } else { } } else if (typeName == XdmfArrayType::Float32()->getName() || typeName == XdmfArrayType::Float64()->getName()) { if (typePrecision == 4) { return XDMF_ARRAY_TYPE_FLOAT32; } else if (typePrecision == 8) { return XDMF_ARRAY_TYPE_FLOAT64; } else { } } else if (typeName == XdmfArrayType::String()->getName()) { //This shouldn't be used from C bindings XdmfError::message(XdmfError::FATAL, "Error: String type not usable from C."); } else { XdmfError::message(XdmfError::FATAL, "Error: Invalid ArrayType."); } XDMF_ERROR_WRAP_END(status) return -1; } unsigned int XdmfArrayGetCapacity(XDMFARRAY * array) { return ((XdmfArray *)(array))->getCapacity(); } unsigned int * XdmfArrayGetDimensions(XDMFARRAY * array) { try { std::vector tempVector = ((XdmfArray *)(array))->getDimensions(); unsigned int returnSize = tempVector.size(); unsigned int * returnArray = new unsigned int[returnSize](); for (unsigned int i = 0; i < returnSize; ++i) { returnArray[i] = tempVector[i]; } return returnArray; } catch (...) { std::vector tempVector = ((XdmfArray *)(array))->getDimensions(); unsigned int returnSize = tempVector.size(); unsigned int * returnArray = new unsigned int[returnSize](); for (unsigned int i = 0; i < returnSize; ++i) { returnArray[i] = tempVector[i]; } return returnArray; } } char * XdmfArrayGetDimensionsString(XDMFARRAY * array) { try { char * returnPointer = strdup(((XdmfArray *)(array))->getDimensionsString().c_str()); return returnPointer; } catch (...) { char * returnPointer = strdup(((XdmfArray *)(array))->getDimensionsString().c_str()); return returnPointer; } } XDMFHEAVYDATACONTROLLER * XdmfArrayGetHeavyDataController(XDMFARRAY * array, unsigned int index) { return (XDMFHEAVYDATACONTROLLER *)((void *)(((XdmfArray *)(array))->getHeavyDataController(index).get())); } char * XdmfArrayGetName(XDMFARRAY * array) { try { char * returnPointer = strdup(((XdmfArray *)(array))->getName().c_str()); return returnPointer; } catch (...) { char * returnPointer = strdup(((XdmfArray *)(array))->getName().c_str()); return returnPointer; } } unsigned int XdmfArrayGetNumberDimensions(XDMFARRAY * array) { return ((XdmfArray *)(array))->getDimensions().size(); } unsigned int XdmfArrayGetNumberHeavyDataControllers(XDMFARRAY * array) { return ((XdmfArray *)(array))->getNumberHeavyDataControllers(); } unsigned int XdmfArrayGetSize(XDMFARRAY * array) { return ((XdmfArray *)(array))->getSize(); } int XdmfArrayGetReadMode(XDMFARRAY * array, int * status) { XDMF_ERROR_WRAP_START(status) int readMode = ((XdmfArray *)(array))->getReadMode(); switch (readMode) { case XdmfArray::Controller: return XDMF_ARRAY_READ_MODE_CONTROLLER; break; case XdmfArray::Reference: return XDMF_ARRAY_READ_MODE_REFERENCE; break; default: XdmfError::message(XdmfError::FATAL, "Error: Invalid ReadMode."); break; } XDMF_ERROR_WRAP_END(status) return -1; } XDMFARRAYREFERENCE * XdmfArrayGetReference(XDMFARRAY * array) { return (XDMFARRAYREFERENCE *)((void *)(((XdmfArray *)(array))->getReference().get())); } void * XdmfArrayGetValue(XDMFARRAY * array, unsigned int index, int arrayType, int * status) { XDMF_ERROR_WRAP_START(status) try { void * returnVal; switch (arrayType) { case XDMF_ARRAY_TYPE_UINT8: returnVal = new unsigned char(); *((unsigned char *)returnVal) = ((XdmfArray *)(array))->getValue(index); return returnVal; break; case XDMF_ARRAY_TYPE_UINT16: returnVal = new unsigned short(); *((unsigned short *)returnVal) = ((XdmfArray *)(array))->getValue(index); return returnVal; break; case XDMF_ARRAY_TYPE_UINT32: returnVal = new unsigned int(); *((unsigned int *)returnVal) = ((XdmfArray *)(array))->getValue(index); return returnVal; break; case XDMF_ARRAY_TYPE_INT8: returnVal = new char(); *((char *)returnVal) = ((XdmfArray *)(array))->getValue(index); return returnVal; break; case XDMF_ARRAY_TYPE_INT16: returnVal = new short(); *((short *)returnVal) = ((XdmfArray *)(array))->getValue(index); return returnVal; break; case XDMF_ARRAY_TYPE_INT32: returnVal = new int(); *((int *)returnVal) = ((XdmfArray *)(array))->getValue(index); return returnVal; break; case XDMF_ARRAY_TYPE_INT64: returnVal = new long(); *((long *)returnVal) = ((XdmfArray *)(array))->getValue(index); return returnVal; break; case XDMF_ARRAY_TYPE_FLOAT32: returnVal = new float(); *((float *)returnVal) = ((XdmfArray *)(array))->getValue(index); return returnVal; break; case XDMF_ARRAY_TYPE_FLOAT64: returnVal = new double(); *((double *)returnVal) = ((XdmfArray *)(array))->getValue(index); return returnVal; break; default: XdmfError::message(XdmfError::FATAL, "Error: Invalid ArrayType."); break; } } catch (...) { void * returnVal; switch (arrayType) { case XDMF_ARRAY_TYPE_UINT8: returnVal = new unsigned char(); *((unsigned char *)returnVal) = ((XdmfArray *)(array))->getValue(index); return returnVal; break; case XDMF_ARRAY_TYPE_UINT16: returnVal = new unsigned short(); *((unsigned short *)returnVal) = ((XdmfArray *)(array))->getValue(index); return returnVal; break; case XDMF_ARRAY_TYPE_UINT32: returnVal = new unsigned int(); *((unsigned int *)returnVal) = ((XdmfArray *)(array))->getValue(index); return returnVal; break; case XDMF_ARRAY_TYPE_INT8: returnVal = new char(); *((char *)returnVal) = ((XdmfArray *)(array))->getValue(index); return returnVal; break; case XDMF_ARRAY_TYPE_INT16: returnVal = new short(); *((short *)returnVal) = ((XdmfArray *)(array))->getValue(index); return returnVal; break; case XDMF_ARRAY_TYPE_INT32: returnVal = new int(); *((int *)returnVal) = ((XdmfArray *)(array))->getValue(index); return returnVal; break; case XDMF_ARRAY_TYPE_INT64: returnVal = new long(); *((long *)returnVal) = ((XdmfArray *)(array))->getValue(index); return returnVal; break; case XDMF_ARRAY_TYPE_FLOAT32: returnVal = new float(); *((float *)returnVal) = ((XdmfArray *)(array))->getValue(index); return returnVal; break; case XDMF_ARRAY_TYPE_FLOAT64: returnVal = new double(); *((double *)returnVal) = ((XdmfArray *)(array))->getValue(index); return returnVal; break; default: XdmfError::message(XdmfError::FATAL, "Error: Invalid ArrayType."); break; } } XDMF_ERROR_WRAP_END(status) return NULL; } void * XdmfArrayGetValues(XDMFARRAY * array, unsigned int startIndex, int arrayType, unsigned int numValues, unsigned int arrayStride, unsigned int valueStride, int * status) { XDMF_ERROR_WRAP_START(status) try { void * returnVal; switch (arrayType) { case XDMF_ARRAY_TYPE_UINT8: returnVal = new unsigned char[numValues](); ((XdmfArray *)(array))->getValues(startIndex, (unsigned char *)returnVal, numValues, arrayStride, valueStride); return returnVal; break; case XDMF_ARRAY_TYPE_UINT16: returnVal = new unsigned short[numValues](); ((XdmfArray *)(array))->getValues(startIndex, (unsigned short *)returnVal, numValues, arrayStride, valueStride); return returnVal; break; case XDMF_ARRAY_TYPE_UINT32: returnVal = new unsigned int[numValues](); ((XdmfArray *)(array))->getValues(startIndex, (unsigned int *)returnVal, numValues, arrayStride, valueStride); return returnVal; break; case XDMF_ARRAY_TYPE_INT8: returnVal = new char[numValues](); ((XdmfArray *)(array))->getValues(startIndex, (char *)returnVal, numValues, arrayStride, valueStride); return returnVal; break; case XDMF_ARRAY_TYPE_INT16: returnVal = new short[numValues](); ((XdmfArray *)(array))->getValues(startIndex, (short *)returnVal, numValues, arrayStride, valueStride); return returnVal; break; case XDMF_ARRAY_TYPE_INT32: returnVal = new int[numValues](); ((XdmfArray *)(array))->getValues(startIndex, (int *)returnVal, numValues, arrayStride, valueStride); return returnVal; break; case XDMF_ARRAY_TYPE_INT64: returnVal = new long[numValues](); ((XdmfArray *)(array))->getValues(startIndex, (long *)returnVal, numValues, arrayStride, valueStride); return returnVal; break; case XDMF_ARRAY_TYPE_FLOAT32: returnVal = new float[numValues](); ((XdmfArray *)(array))->getValues(startIndex, (float *)returnVal, numValues, arrayStride, valueStride); return returnVal; break; case XDMF_ARRAY_TYPE_FLOAT64: returnVal = new double[numValues](); ((XdmfArray *)(array))->getValues(startIndex, (double *)returnVal, numValues, arrayStride, valueStride); return returnVal; break; default: XdmfError::message(XdmfError::FATAL, "Error: Invalid ArrayType."); break; } } catch (...) { void * returnVal; switch (arrayType) { case XDMF_ARRAY_TYPE_UINT8: returnVal = new unsigned char[numValues](); ((XdmfArray *)(array))->getValues(startIndex, (unsigned char *)returnVal, numValues, arrayStride, valueStride); return returnVal; break; case XDMF_ARRAY_TYPE_UINT16: returnVal = new unsigned short[numValues](); ((XdmfArray *)(array))->getValues(startIndex, (unsigned short *)returnVal, numValues, arrayStride, valueStride); return returnVal; break; case XDMF_ARRAY_TYPE_UINT32: returnVal = new unsigned int[numValues](); ((XdmfArray *)(array))->getValues(startIndex, (unsigned int *)returnVal, numValues, arrayStride, valueStride); return returnVal; break; case XDMF_ARRAY_TYPE_INT8: returnVal = new char[numValues](); ((XdmfArray *)(array))->getValues(startIndex, (char *)returnVal, numValues, arrayStride, valueStride); return returnVal; break; case XDMF_ARRAY_TYPE_INT16: returnVal = new short[numValues](); ((XdmfArray *)(array))->getValues(startIndex, (short *)returnVal, numValues, arrayStride, valueStride); return returnVal; break; case XDMF_ARRAY_TYPE_INT32: returnVal = new int[numValues](); ((XdmfArray *)(array))->getValues(startIndex, (int *)returnVal, numValues, arrayStride, valueStride); return returnVal; break; case XDMF_ARRAY_TYPE_INT64: returnVal = new long[numValues](); ((XdmfArray *)(array))->getValues(startIndex, (long *)returnVal, numValues, arrayStride, valueStride); return returnVal; break; case XDMF_ARRAY_TYPE_FLOAT32: returnVal = new float[numValues](); ((XdmfArray *)(array))->getValues(startIndex, (float *)returnVal, numValues, arrayStride, valueStride); return returnVal; break; case XDMF_ARRAY_TYPE_FLOAT64: returnVal = new double[numValues](); ((XdmfArray *)(array))->getValues(startIndex, (double *)returnVal, numValues, arrayStride, valueStride); return returnVal; break; default: XdmfError::message(XdmfError::FATAL, "Error: Invalid ArrayType."); break; } } XDMF_ERROR_WRAP_END(status) return NULL; } void * XdmfArrayGetValuesInternal(XDMFARRAY * array) { return ((XdmfArray *)(array))->getValuesInternal(); } char * XdmfArrayGetValuesString(XDMFARRAY * array) { try { char * returnPointer = strdup(((XdmfArray *)(array))->getValuesString().c_str()); return returnPointer; } catch (...) { char * returnPointer = strdup(((XdmfArray *)(array))->getValuesString().c_str()); return returnPointer; } } void XdmfArrayInitialize(XDMFARRAY * array, int * dims, int numDims, int arrayType, int * status) { XDMF_ERROR_WRAP_START(status) std::vector dimVector((int *)dims, (int *)dims + numDims); shared_ptr tempPointer = XdmfArrayType::Uninitialized(); switch (arrayType) { case XDMF_ARRAY_TYPE_UINT8: tempPointer = XdmfArrayType::UInt8(); break; case XDMF_ARRAY_TYPE_UINT16: tempPointer = XdmfArrayType::UInt16(); break; case XDMF_ARRAY_TYPE_UINT32: tempPointer = XdmfArrayType::UInt32(); break; case XDMF_ARRAY_TYPE_INT8: tempPointer = XdmfArrayType::Int8(); break; case XDMF_ARRAY_TYPE_INT16: tempPointer = XdmfArrayType::Int16(); break; case XDMF_ARRAY_TYPE_INT32: tempPointer = XdmfArrayType::Int32(); break; case XDMF_ARRAY_TYPE_INT64: tempPointer = XdmfArrayType::Int64(); break; case XDMF_ARRAY_TYPE_FLOAT32: tempPointer = XdmfArrayType::Float32(); break; case XDMF_ARRAY_TYPE_FLOAT64: tempPointer = XdmfArrayType::Float64(); break; default: XdmfError::message(XdmfError::FATAL, "Error: Invalid ArrayType."); break; } ((XdmfArray *)(array))->initialize(tempPointer, dimVector); XDMF_ERROR_WRAP_END(status) } void XdmfArrayInsertDataFromPointer(XDMFARRAY * array, void * values, int arrayType, unsigned int startIndex, unsigned int numVals, unsigned int arrayStride, unsigned int valueStride, int * status) { XDMF_ERROR_WRAP_START(status) try { switch (arrayType) { case XDMF_ARRAY_TYPE_UINT8: ((XdmfArray *)(array))->insert(startIndex, (unsigned char *)values, numVals, arrayStride, valueStride); break; case XDMF_ARRAY_TYPE_UINT16: ((XdmfArray *)(array))->insert(startIndex, (unsigned short *)values, numVals, arrayStride, valueStride); break; case XDMF_ARRAY_TYPE_UINT32: ((XdmfArray *)(array))->insert(startIndex, (unsigned int *)values, numVals, arrayStride, valueStride); break; case XDMF_ARRAY_TYPE_INT8: ((XdmfArray *)(array))->insert(startIndex, (char *)values, numVals, arrayStride, valueStride); break; case XDMF_ARRAY_TYPE_INT16: ((XdmfArray *)(array))->insert(startIndex, (short *)values, numVals, arrayStride, valueStride); break; case XDMF_ARRAY_TYPE_INT32: ((XdmfArray *)(array))->insert(startIndex, (int *)values, numVals, arrayStride, valueStride); break; case XDMF_ARRAY_TYPE_INT64: ((XdmfArray *)(array))->insert(startIndex, (long *)values, numVals, arrayStride, valueStride); break; case XDMF_ARRAY_TYPE_FLOAT32: ((XdmfArray *)(array))->insert(startIndex, (float *)values, numVals, arrayStride, valueStride); break; case XDMF_ARRAY_TYPE_FLOAT64: ((XdmfArray *)(array))->insert(startIndex, (double *)values, numVals, arrayStride, valueStride); break; default: XdmfError::message(XdmfError::FATAL, "Error: Invalid ArrayType."); break; } } catch (...) { switch (arrayType) { case XDMF_ARRAY_TYPE_UINT8: ((XdmfArray *)(array))->insert(startIndex, (unsigned char *)values, numVals, arrayStride, valueStride); break; case XDMF_ARRAY_TYPE_UINT16: ((XdmfArray *)(array))->insert(startIndex, (unsigned short *)values, numVals, arrayStride, valueStride); break; case XDMF_ARRAY_TYPE_UINT32: ((XdmfArray *)(array))->insert(startIndex, (unsigned int *)values, numVals, arrayStride, valueStride); break; case XDMF_ARRAY_TYPE_INT8: ((XdmfArray *)(array))->insert(startIndex, (char *)values, numVals, arrayStride, valueStride); break; case XDMF_ARRAY_TYPE_INT16: ((XdmfArray *)(array))->insert(startIndex, (short *)values, numVals, arrayStride, valueStride); break; case XDMF_ARRAY_TYPE_INT32: ((XdmfArray *)(array))->insert(startIndex, (int *)values, numVals, arrayStride, valueStride); break; case XDMF_ARRAY_TYPE_INT64: ((XdmfArray *)(array))->insert(startIndex, (long *)values, numVals, arrayStride, valueStride); break; case XDMF_ARRAY_TYPE_FLOAT32: ((XdmfArray *)(array))->insert(startIndex, (float *)values, numVals, arrayStride, valueStride); break; case XDMF_ARRAY_TYPE_FLOAT64: ((XdmfArray *)(array))->insert(startIndex, (double *)values, numVals, arrayStride, valueStride); break; default: XdmfError::message(XdmfError::FATAL, "Error: Invalid ArrayType."); break; } } XDMF_ERROR_WRAP_END(status) } void XdmfArrayInsertDataFromXdmfArray(XDMFARRAY * array, XDMFARRAY * valArray, int * arrayStarts, int * valueStarts, int * arrayCounts, int * valueCounts, int * arrayStrides, int * valueStrides, int * status) { XDMF_ERROR_WRAP_START(status) try { shared_ptr tempPointer((XdmfArray *)valArray, XdmfNullDeleter()); std::vector arrayStartVector((int *)arrayStarts, (int *)arrayStarts + ((XdmfArray *)(array))->getDimensions().size()); std::vector valueStartVector((int *)valueStarts, (int *)valueStarts + tempPointer->getDimensions().size()); std::vector arrayCountVector((int *)arrayCounts, (int *)arrayCounts + ((XdmfArray *)(array))->getDimensions().size()); std::vector valueCountVector((int *)valueCounts, (int *)valueCounts + tempPointer->getDimensions().size()); std::vector arrayStrideVector((int *)arrayStrides, (int *)arrayStrides + ((XdmfArray *)(array))->getDimensions().size()); std::vector valueStrideVector((int *)valueStrides, (int *)valueStrides + tempPointer->getDimensions().size()); ((XdmfArray *)(array))->insert(arrayStartVector, tempPointer, valueStartVector, arrayCountVector, valueCountVector, arrayStrideVector, valueStrideVector); } catch (...) { shared_ptr tempPointer((XdmfArray *)valArray, XdmfNullDeleter()); std::vector arrayStartVector((int *)arrayStarts, (int *)arrayStarts + ((XdmfArray *)(array))->getDimensions().size()); std::vector valueStartVector((int *)valueStarts, (int *)valueStarts + tempPointer->getDimensions().size()); std::vector arrayCountVector((int *)arrayCounts, (int *)arrayCounts + ((XdmfArray *)(array))->getDimensions().size()); std::vector valueCountVector((int *)valueCounts, (int *)valueCounts + tempPointer->getDimensions().size()); std::vector arrayStrideVector((int *)arrayStrides, (int *)arrayStrides + ((XdmfArray *)(array))->getDimensions().size()); std::vector valueStrideVector((int *)valueStrides, (int *)valueStrides + tempPointer->getDimensions().size()); ((XdmfArray *)(array))->insert(arrayStartVector, tempPointer, valueStartVector, arrayCountVector, valueCountVector, arrayStrideVector, valueStrideVector); } XDMF_ERROR_WRAP_END(status) } void XdmfArrayInsertHeavyDataController(XDMFARRAY * array, XDMFHEAVYDATACONTROLLER * controller, int passControl) { if (passControl == 0) { ((XdmfArray *)(array))->insert(shared_ptr((XdmfHeavyDataController *) controller, XdmfNullDeleter())); } else { ((XdmfArray *)(array))->insert(shared_ptr((XdmfHeavyDataController *) controller)); } } void XdmfArrayInsertValue(XDMFARRAY * array, unsigned int index, void * value, int arrayType, int * status) { XDMF_ERROR_WRAP_START(status) try { switch (arrayType) { case XDMF_ARRAY_TYPE_UINT8: ((XdmfArray *)(array))->insert(index, *((unsigned char *)value)); break; case XDMF_ARRAY_TYPE_UINT16: ((XdmfArray *)(array))->insert(index, *((unsigned short *)value)); break; case XDMF_ARRAY_TYPE_UINT32: ((XdmfArray *)(array))->insert(index, *((unsigned int *)value)); break; case XDMF_ARRAY_TYPE_INT8: ((XdmfArray *)(array))->insert(index, *((char *)value)); break; case XDMF_ARRAY_TYPE_INT16: ((XdmfArray *)(array))->insert(index, *((short *)value)); break; case XDMF_ARRAY_TYPE_INT32: ((XdmfArray *)(array))->insert(index, *((int *)value)); break; case XDMF_ARRAY_TYPE_INT64: ((XdmfArray *)(array))->insert(index, *((long *)value)); break; case XDMF_ARRAY_TYPE_FLOAT32: ((XdmfArray *)(array))->insert(index, *((float *)value)); break; case XDMF_ARRAY_TYPE_FLOAT64: ((XdmfArray *)(array))->insert(index, *((double *)value)); break; default: XdmfError::message(XdmfError::FATAL, "Error: Invalid ArrayType."); break; } } catch (...) { switch (arrayType) { case XDMF_ARRAY_TYPE_UINT8: ((XdmfArray *)(array))->insert(index, *((unsigned char *)value)); break; case XDMF_ARRAY_TYPE_UINT16: ((XdmfArray *)(array))->insert(index, *((unsigned short *)value)); break; case XDMF_ARRAY_TYPE_UINT32: ((XdmfArray *)(array))->insert(index, *((unsigned int *)value)); break; case XDMF_ARRAY_TYPE_INT8: ((XdmfArray *)(array))->insert(index, *((char *)value)); break; case XDMF_ARRAY_TYPE_INT16: ((XdmfArray *)(array))->insert(index, *((short *)value)); break; case XDMF_ARRAY_TYPE_INT32: ((XdmfArray *)(array))->insert(index, *((int *)value)); break; case XDMF_ARRAY_TYPE_INT64: ((XdmfArray *)(array))->insert(index, *((long *)value)); break; case XDMF_ARRAY_TYPE_FLOAT32: ((XdmfArray *)(array))->insert(index, *((float *)value)); break; case XDMF_ARRAY_TYPE_FLOAT64: ((XdmfArray *)(array))->insert(index, *((double *)value)); break; default: XdmfError::message(XdmfError::FATAL, "Error: Invalid ArrayType."); break; } } XDMF_ERROR_WRAP_END(status) } int XdmfArrayIsInitialized(XDMFARRAY * array) { return ((XdmfArray *)(array))->isInitialized(); } void XdmfArrayPushBack(XDMFARRAY * array, void * value, int arrayType, int * status) { XDMF_ERROR_WRAP_START(status) try { switch (arrayType) { case XDMF_ARRAY_TYPE_UINT8: ((XdmfArray *)(array))->pushBack(*((unsigned char *)value)); break; case XDMF_ARRAY_TYPE_UINT16: ((XdmfArray *)(array))->pushBack(*((unsigned short *)value)); break; case XDMF_ARRAY_TYPE_UINT32: ((XdmfArray *)(array))->pushBack(*((unsigned int *)value)); break; case XDMF_ARRAY_TYPE_INT8: ((XdmfArray *)(array))->pushBack(*((char *)value)); break; case XDMF_ARRAY_TYPE_INT16: ((XdmfArray *)(array))->pushBack(*((short *)value)); break; case XDMF_ARRAY_TYPE_INT32: ((XdmfArray *)(array))->pushBack(*((int *)value)); break; case XDMF_ARRAY_TYPE_INT64: ((XdmfArray *)(array))->pushBack(*((long *)value)); break; case XDMF_ARRAY_TYPE_FLOAT32: ((XdmfArray *)(array))->pushBack(*((float *)value)); break; case XDMF_ARRAY_TYPE_FLOAT64: ((XdmfArray *)(array))->pushBack(*((double *)value)); break; default: XdmfError::message(XdmfError::FATAL, "Error: Invalid ArrayType."); break; } } catch (...) { switch (arrayType) { case XDMF_ARRAY_TYPE_UINT8: ((XdmfArray *)(array))->pushBack(*((unsigned char *)value)); break; case XDMF_ARRAY_TYPE_UINT16: ((XdmfArray *)(array))->pushBack(*((unsigned short *)value)); break; case XDMF_ARRAY_TYPE_UINT32: ((XdmfArray *)(array))->pushBack(*((unsigned int *)value)); break; case XDMF_ARRAY_TYPE_INT8: ((XdmfArray *)(array))->pushBack(*((char *)value)); break; case XDMF_ARRAY_TYPE_INT16: ((XdmfArray *)(array))->pushBack(*((short *)value)); break; case XDMF_ARRAY_TYPE_INT32: ((XdmfArray *)(array))->pushBack(*((int *)value)); break; case XDMF_ARRAY_TYPE_INT64: ((XdmfArray *)(array))->pushBack(*((long *)value)); break; case XDMF_ARRAY_TYPE_FLOAT32: ((XdmfArray *)(array))->pushBack(*((float *)value)); break; case XDMF_ARRAY_TYPE_FLOAT64: ((XdmfArray *)(array))->pushBack(*((double *)value)); break; default: XdmfError::message(XdmfError::FATAL, "Error: Invalid ArrayType."); break; } } XDMF_ERROR_WRAP_END(status) } void XdmfArrayRead(XDMFARRAY * array, int * status) { XDMF_ERROR_WRAP_START(status) try { ((XdmfArray *)(array))->read(); } catch (...) { ((XdmfArray *)(array))->read(); } XDMF_ERROR_WRAP_END(status) } void XdmfArrayReadController(XDMFARRAY * array, int * status) { XDMF_ERROR_WRAP_START(status) try { ((XdmfArray *)(array))->readController(); } catch (...) { ((XdmfArray *)(array))->readController(); } XDMF_ERROR_WRAP_END(status) } void XdmfArrayReadReference(XDMFARRAY * array, int * status) { XDMF_ERROR_WRAP_START(status) try { ((XdmfArray *)(array))->readReference(); } catch (...) { ((XdmfArray *)(array))->readReference(); } XDMF_ERROR_WRAP_END(status) } void XdmfArrayRelease(XDMFARRAY * array) { ((XdmfArray *)(array))->release(); } void XdmfArrayRemoveHeavyDataController(XDMFARRAY * array, unsigned int index) { ((XdmfArray *)(array))->removeHeavyDataController(index); } void XdmfArrayReserve(XDMFARRAY * array, int size) { ((XdmfArray *)(array))->reserve(size); } void XdmfArrayResize(XDMFARRAY * array, int * dims, int numDims, int arrayType, int * status) { XDMF_ERROR_WRAP_START(status) try { std::vector dimVector((int *)dims, (int *)dims + numDims); switch (arrayType) { case XDMF_ARRAY_TYPE_UINT8: { XdmfArray * classedArray = (XdmfArray *)((void *) array); classedArray->resize(dimVector, (unsigned char) 0); break; } case XDMF_ARRAY_TYPE_UINT16: { XdmfArray * classedArray = (XdmfArray *)((void *) array); classedArray->resize(dimVector, (unsigned short) 0); break; } case XDMF_ARRAY_TYPE_UINT32: { XdmfArray * classedArray = (XdmfArray *)((void *) array); classedArray->resize(dimVector, (unsigned int) 0); break; } case XDMF_ARRAY_TYPE_INT8: { XdmfArray * classedArray = (XdmfArray *)((void *) array); classedArray->resize(dimVector, (char) 0); break; } case XDMF_ARRAY_TYPE_INT16: { XdmfArray * classedArray = (XdmfArray *)((void *) array); classedArray->resize(dimVector, (short) 0); break; } case XDMF_ARRAY_TYPE_INT32: { XdmfArray * classedArray = (XdmfArray *)((void *) array); classedArray->resize(dimVector, (int) 0); break; } case XDMF_ARRAY_TYPE_INT64: { XdmfArray * classedArray = (XdmfArray *)((void *) array); classedArray->resize(dimVector, (long) 0); break; } case XDMF_ARRAY_TYPE_FLOAT32: { XdmfArray * classedArray = (XdmfArray *)((void *) array); classedArray->resize(dimVector, (float) 0); break; } case XDMF_ARRAY_TYPE_FLOAT64: { XdmfArray * classedArray = (XdmfArray *)((void *) array); classedArray->resize(dimVector, (double) 0); break; } default: { XdmfError::message(XdmfError::FATAL, "Error: Invalid ArrayType."); break; } } dimVector.clear(); } catch (...) { std::vector dimVector((int *)dims, (int *)dims + numDims); switch (arrayType) { case XDMF_ARRAY_TYPE_UINT8: { XdmfArray * classedArray = (XdmfArray *)((void *) array); classedArray->resize(dimVector, (unsigned char) 0); break; } case XDMF_ARRAY_TYPE_UINT16: { XdmfArray * classedArray = (XdmfArray *)((void *) array); classedArray->resize(dimVector, (unsigned short) 0); break; } case XDMF_ARRAY_TYPE_UINT32: { XdmfArray * classedArray = (XdmfArray *)((void *) array); classedArray->resize(dimVector, (unsigned int) 0); break; } case XDMF_ARRAY_TYPE_INT8: { XdmfArray * classedArray = (XdmfArray *)((void *) array); classedArray->resize(dimVector, (char) 0); break; } case XDMF_ARRAY_TYPE_INT16: { XdmfArray * classedArray = (XdmfArray *)((void *) array); classedArray->resize(dimVector, (short) 0); break; } case XDMF_ARRAY_TYPE_INT32: { XdmfArray * classedArray = (XdmfArray *)((void *) array); classedArray->resize(dimVector, (int) 0); break; } case XDMF_ARRAY_TYPE_INT64: { XdmfArray * classedArray = (XdmfArray *)((void *) array); classedArray->resize(dimVector, (long) 0); break; } case XDMF_ARRAY_TYPE_FLOAT32: { XdmfArray * classedArray = (XdmfArray *)((void *) array); classedArray->resize(dimVector, (float) 0); break; } case XDMF_ARRAY_TYPE_FLOAT64: { XdmfArray * classedArray = (XdmfArray *)((void *) array); classedArray->resize(dimVector, (double) 0); break; } default: { XdmfError::message(XdmfError::FATAL, "Error: Invalid ArrayType."); break; } } dimVector.clear(); } XDMF_ERROR_WRAP_END(status) } void XdmfArraySetReadMode(XDMFARRAY * array, int readMode, int * status) { XDMF_ERROR_WRAP_START(status) switch (readMode) { case XDMF_ARRAY_READ_MODE_CONTROLLER: ((XdmfArray *)(array))->setReadMode(XdmfArray::Controller); break; case XDMF_ARRAY_READ_MODE_REFERENCE: ((XdmfArray *)(array))->setReadMode(XdmfArray::Reference); break; default: XdmfError::message(XdmfError::FATAL, "Error: Invalid ReadMode."); break; } XDMF_ERROR_WRAP_END(status) } void XdmfArraySetReference(XDMFARRAY * array, XDMFARRAYREFERENCE * reference, int passControl) { if (passControl) { ((XdmfArray *)(array))->setReference(shared_ptr((XdmfArrayReference *)reference)); } else { ((XdmfArray *)(array))->setReference(shared_ptr((XdmfArrayReference *)reference, XdmfNullDeleter())); } } void XdmfArraySetName(XDMFARRAY * array, char * name, int * status) { XDMF_ERROR_WRAP_START(status) ((XdmfArray *)(array))->setName(name); XDMF_ERROR_WRAP_END(status) } void XdmfArraySetValuesInternal(XDMFARRAY * array, void * pointer, unsigned int numValues, int arrayType, int transferOwnership, int * status) { XDMF_ERROR_WRAP_START(status) switch (arrayType) { case XDMF_ARRAY_TYPE_UINT8: ((XdmfArray *)array)->setValuesInternal((unsigned char *)pointer, numValues, transferOwnership); break; case XDMF_ARRAY_TYPE_UINT16: ((XdmfArray *)array)->setValuesInternal((unsigned short *)pointer, numValues, transferOwnership); break; case XDMF_ARRAY_TYPE_UINT32: ((XdmfArray *)array)->setValuesInternal((unsigned int *)pointer, numValues, transferOwnership); break; case XDMF_ARRAY_TYPE_INT8: ((XdmfArray *)array)->setValuesInternal((char *)pointer, numValues, transferOwnership); break; case XDMF_ARRAY_TYPE_INT16: ((XdmfArray *)array)->setValuesInternal((short *)pointer, numValues, transferOwnership); break; case XDMF_ARRAY_TYPE_INT32: ((XdmfArray *)array)->setValuesInternal((int *)pointer, numValues, transferOwnership); break; case XDMF_ARRAY_TYPE_INT64: ((XdmfArray *)array)->setValuesInternal((long *)pointer, numValues, transferOwnership); break; case XDMF_ARRAY_TYPE_FLOAT32: ((XdmfArray *)array)->setValuesInternal((float *)pointer, numValues, transferOwnership); break; case XDMF_ARRAY_TYPE_FLOAT64: ((XdmfArray *)array)->setValuesInternal((double *)pointer, numValues, transferOwnership); break; default: XdmfError::message(XdmfError::FATAL, "Error: Invalid ArrayType."); break; } XDMF_ERROR_WRAP_END(status) } void XdmfArraySwapWithXdmfArray(XDMFARRAY * array, XDMFARRAY * swapArray) { shared_ptr pointerToSwap((XdmfArray *) swapArray, XdmfNullDeleter()); ((XdmfArray *)array)->swap(pointerToSwap); } void XdmfArraySwapWithArray(XDMFARRAY * array, void ** pointer, int numValues, int arrayType, int * status) { XDMF_ERROR_WRAP_START(status) switch (arrayType) { case XDMF_ARRAY_TYPE_UINT8: { std::vector swapVector((unsigned char *)(*pointer), (unsigned char *)(*pointer) + numValues); ((XdmfArray *)array)->swap(swapVector); *pointer = new unsigned char[swapVector.size()]; for (unsigned int i = 0; i < swapVector.size(); ++i) { ((unsigned char *) (*pointer))[i] = swapVector[i]; } break; } case XDMF_ARRAY_TYPE_UINT16: { std::vector swapVector((unsigned short *)(*pointer), (unsigned short *)(*pointer) + numValues); ((XdmfArray *)array)->swap(swapVector); *pointer = new unsigned short[swapVector.size()]; for (unsigned int i = 0; i < swapVector.size(); ++i) { ((unsigned short *) (*pointer))[i] = swapVector[i]; } break; } case XDMF_ARRAY_TYPE_UINT32: { std::vector swapVector((unsigned int *)(*pointer), (unsigned int *)(*pointer) + numValues); ((XdmfArray *)array)->swap(swapVector); *pointer = new unsigned int[swapVector.size()]; for (unsigned int i = 0; i < swapVector.size(); ++i) { ((unsigned int *) (*pointer))[i] = swapVector[i]; } break; } case XDMF_ARRAY_TYPE_INT8: { std::vector swapVector((char *)(*pointer), (char *)(*pointer) + numValues); ((XdmfArray *)array)->swap(swapVector); *pointer = new char[swapVector.size()]; for (unsigned int i = 0; i < swapVector.size(); ++i) { ((char *) (*pointer))[i] = swapVector[i]; } break; } case XDMF_ARRAY_TYPE_INT16: { std::vector swapVector((short *)(*pointer), (short *)(*pointer) + numValues); ((XdmfArray *)array)->swap(swapVector); *pointer = new short[swapVector.size()]; for (unsigned int i = 0; i < swapVector.size(); ++i) { ((short *) (*pointer))[i] = swapVector[i]; } break; } case XDMF_ARRAY_TYPE_INT32: { std::vector swapVector((int *)(*pointer), (int *)(*pointer) + numValues); ((XdmfArray *)array)->swap(swapVector); *pointer = new int[swapVector.size()]; for (unsigned int i = 0; i < swapVector.size(); ++i) { ((int *) (*pointer))[i] = swapVector[i]; } break; } case XDMF_ARRAY_TYPE_INT64: { std::vector swapVector((long *)(*pointer), (long *)(*pointer) + numValues); ((XdmfArray *)array)->swap(swapVector); *pointer = new long[swapVector.size()]; for (unsigned int i = 0; i < swapVector.size(); ++i) { ((long *) (*pointer))[i] = swapVector[i]; } break; } case XDMF_ARRAY_TYPE_FLOAT32: { std::vector swapVector((float *)(*pointer), (float *)(*pointer) + numValues); ((XdmfArray *)array)->swap(swapVector); *pointer = new float[swapVector.size()]; for (unsigned int i = 0; i < swapVector.size(); ++i) { ((float *) (*pointer))[i] = swapVector[i]; } break; } case XDMF_ARRAY_TYPE_FLOAT64: { std::vector swapVector((double *)(*pointer), (double *)(*pointer) + numValues); ((XdmfArray *)array)->swap(swapVector); *pointer = new double[swapVector.size()]; for (unsigned int i = 0; i < swapVector.size(); ++i) { ((double *) (*pointer))[i] = swapVector[i]; } break; } default: XdmfError::message(XdmfError::FATAL, "Error: Invalid ArrayType."); break; } XDMF_ERROR_WRAP_END(status) } // C Wrappers for parent classes are generated by macros XDMF_ITEM_C_CHILD_WRAPPER(XdmfArray, XDMFARRAY) xdmf-3.0+git20160803/core/dsm/0000740000175000017500000000000013003006557015603 5ustar alastairalastairxdmf-3.0+git20160803/core/dsm/XdmfDSMBuffer.cpp0000640000175000017500000024027613003006557020720 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfDSMBuffer.hpp */ /* */ /* Author: */ /* Andrew Burns */ /* andrew.j.burns2@us.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2013 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ /*========================================================================= This code is derived from an earlier work and is distributed with permission from, and thanks to ... =========================================================================*/ /*============================================================================ Project : H5FDdsm Module : H5FDdsmBufferService.cxx H5FDdsmBuffer.cxx Authors: John Biddiscombe Jerome Soumagne biddisco@cscs.ch soumagne@cscs.ch Copyright (C) CSCS - Swiss National Supercomputing Centre. You may use modify and and distribute this code freely providing 1) This copyright notice appears on all copies of source code 2) An acknowledgment appears with any substantial usage of the code 3) If this code is contributed to any other open source project, it must not be reformatted such that the indentation, bracketing or overall style is modified significantly. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. This work has received funding from the European Community's Seventh Framework Programme (FP7/2007-2013) under grant agreement 225967 âxtMuSEâOC ============================================================================*/ #include #include #include #include #include #include #include #ifndef _WIN32 #include #endif XdmfDSMBuffer::XdmfDSMBuffer() { this->CommChannel = XDMF_DSM_INTER_COMM; this->DsmType = XDMF_DSM_TYPE_UNIFORM; this->IsServer = true; this->StartAddress = this->EndAddress = 0; this->StartServerId = this->EndServerId = -1; this->LocalBufferSizeMBytes = 128; this->Length = 0; this->TotalLength = 0; this->BlockLength = XDMF_DSM_DEFAULT_BLOCK_LENGTH; this->NumPages = 0; this->PagesAssigned = 0; this->Comm = NULL; this->DataPointer = NULL; this->InterCommType = XDMF_DSM_COMM_MPI; this->IsConnected = false; this->ResizeFactor = 1; } XdmfDSMBuffer::~XdmfDSMBuffer() { if (this->DataPointer) { free(this->DataPointer); } this->DataPointer = NULL; } class XdmfDSMBuffer::CommandMsg { public: int Opcode; int Source; int Target; int Address; int Length; }; class XdmfDSMBuffer::InfoMsg { public: int type; unsigned int length; unsigned int total_length; unsigned int block_length; int start_server_id; int end_server_id; }; int XdmfDSMBuffer::AddressToId(int Address) { int ServerId = XDMF_DSM_FAIL; switch(this->DsmType) { case XDMF_DSM_TYPE_UNIFORM : case XDMF_DSM_TYPE_UNIFORM_RANGE : // Block based allocation should use PageToId // All Servers have same length // This finds out which server the address provided starts on ServerId = this->StartServerId + (Address / this->Length); if(ServerId > this->EndServerId ){ try { std::stringstream message; message << "ServerId " << ServerId << " for Address " << Address << " is larger than EndServerId " << this->EndServerId; XdmfError::message(XdmfError::FATAL, message.str()); } catch (XdmfError & e) { throw e; } } break; default : // Not Implemented try { std::stringstream message; message << "DsmType " << this->DsmType << " not yet implemented or not uniform"; XdmfError::message(XdmfError::FATAL, message.str()); } catch (XdmfError & e) { throw e; } break; } return(ServerId); } void XdmfDSMBuffer::BroadcastComm(int *comm, int root) { int status; this->Comm->Broadcast(comm, sizeof(int), root, XDMF_DSM_INTRA_COMM); if (status != MPI_SUCCESS) { try { XdmfError(XdmfError::FATAL, "Broadcast of Comm failed"); } catch (XdmfError & e) { throw e; } } } int XdmfDSMBuffer::BufferService(int *returnOpcode) { int opcode, who; int aLength; int address; char *datap; static int syncId = -1; if (this->CommChannel == XDMF_DSM_ANY_COMM) { if (this->Comm->GetId() == 0) { try { this->Comm->Probe(&this->CommChannel); } catch (XdmfError & e) { throw e; } } try { this->BroadcastComm(&this->CommChannel, 0); } catch (XdmfError & e) { throw e; } } try { this->ReceiveCommandHeader(&opcode, &who, &address, &aLength, this->CommChannel, syncId); } catch (XdmfError & e) { throw e; } // Connection is an ID for client or server, // int communicatorId = this->CommChannel; switch(opcode) { // H5FD_DSM_OPCODE_PUT case XDMF_DSM_OPCODE_PUT: if (((unsigned int) aLength + address) > this->Length) { try { std::stringstream message; message << "Length " << aLength << " too long for Address " << address << "\n" << "Server Start = " << this->StartAddress << " End = " << this->EndAddress; XdmfError::message(XdmfError::FATAL, message.str()); } catch (XdmfError & e) { throw e; } } if ((datap = this->DataPointer) == NULL) { try { XdmfError::message(XdmfError::FATAL, "Null Data Pointer when trying to put data"); } catch (XdmfError & e) { throw e; } } datap += address; try { this->ReceiveData(who, datap, aLength, XDMF_DSM_PUT_DATA_TAG, 0, this->CommChannel); } catch (XdmfError & e) { throw e; } break; // H5FD_DSM_OPCODE_GET case XDMF_DSM_OPCODE_GET: if (((unsigned int) aLength + address) > this->Length) { try { std::stringstream message; message << "Length " << aLength << " too long for Address " << address << "\n" << "Server Start = " << this->StartAddress << " End = " << this->EndAddress; XdmfError::message(XdmfError::FATAL, message.str()); } catch (XdmfError & e) { throw e; } } if ((datap = this->DataPointer) == NULL) { try { XdmfError::message(XdmfError::FATAL, "Null Data Pointer when trying to put data"); } catch (XdmfError & e) { throw e; } } datap += address; try { this->SendData(who, datap, aLength, XDMF_DSM_GET_DATA_TAG, 0, this->CommChannel); } catch (XdmfError & e) { throw e; } break; // H5FD_DSM_ACCEPT // Comes from client case XDMF_DSM_ACCEPT: { int numConnections; this->ReceiveAcknowledgment(who, numConnections, XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM); this->Comm->Accept(numConnections); this->SendInfo(); break; } // Comes from client, requests a notifcation when a file is touched. // The notification is sent out when clear is called. case XDMF_DSM_SET_NOTIFY: { // Send the notify info to all cores. int strlength = 0; char * notifystring; int waitingCore = 0; if (this->Comm->GetId() == 0) { waitingCore = who; this->ReceiveAcknowledgment(who, strlength, XDMF_DSM_EXCHANGE_TAG, this->CommChannel); notifystring = new char[strlength+1](); this->ReceiveData(who, notifystring, strlength, XDMF_DSM_EXCHANGE_TAG, 0, this->CommChannel); notifystring[strlength] = 0; WaitingMap[std::string(notifystring)].push_back(who); // Send XDMF_DSM_SET_NOTIFY to all server cores in order of increasing id for (int i = this->GetStartServerId() + 1; // Since this is core 0 sending it i <= this->GetEndServerId(); ++i) { if (i != this->Comm->GetInterId()) { this->SendCommandHeader(XDMF_DSM_SET_NOTIFY, i, 0, 0, XDMF_DSM_INTER_COMM); } } } // broadcast to the other server cores // BCAST strlen this->Comm->Broadcast(&strlength, sizeof(int), 0, XDMF_DSM_INTRA_COMM); // BCAST notifystring if (this->Comm->GetId() != 0) { notifystring = new char[strlength + 1](); } this->Comm->Broadcast(¬ifystring, strlength, 0, XDMF_DSM_INTRA_COMM); notifystring[strlength] = 0; // BCAST locked core this->Comm->Broadcast(&waitingCore, sizeof(int), 0, XDMF_DSM_INTRA_COMM); if (this->Comm->GetId() != 0) { WaitingMap[std::string(notifystring)].push_back(waitingCore); } break; } // sends out and clears the notifcations that are stored for a specific file. case XDMF_DSM_CLEAR_NOTIFY: { // send a command to other cores to clear this notification int strlength = 0; char * notifystring; int clearCode = 0; if (this->Comm->GetId() == 0) { this->ReceiveAcknowledgment(who, strlength, XDMF_DSM_EXCHANGE_TAG, this->CommChannel); notifystring = new char[strlength+1](); this->ReceiveData(who, notifystring, strlength, XDMF_DSM_EXCHANGE_TAG, 0, this->CommChannel); notifystring[strlength] = 0; this->ReceiveAcknowledgment(who, clearCode, XDMF_DSM_EXCHANGE_TAG, this->CommChannel); } // broad cast string to be notified if (WaitingMap[std::string(notifystring)].size() > 0) { // Request the help of the rest of the server // Send XDMF_DSM_SET_NOTIFY to all server cores in order of increasing id for (int i = this->GetStartServerId() + 1; // Since this is core 0 sending it i <= this->GetEndServerId(); ++i) { if (i != this->Comm->GetInterId()) { this->SendCommandHeader(XDMF_DSM_CLEAR_NOTIFY, i, 0, 0, XDMF_DSM_INTER_COMM); } } // BCAST strlen and code this->Comm->Broadcast(&strlength, sizeof(int), 0, XDMF_DSM_INTRA_COMM); this->Comm->Broadcast(&clearCode, sizeof(int), 0, XDMF_DSM_INTRA_COMM); // BCAST notifystring if (this->Comm->GetId() != 0) { notifystring = new char[strlength+1](); } this->Comm->Broadcast(¬ifystring, strlength, 0, XDMF_DSM_INTRA_COMM); notifystring[strlength] = 0; // cores notify based on their index, in order to split up the work std::vector notifiedCores = WaitingMap[std::string(notifystring)]; for (unsigned int i = this->Comm->GetId(); i < notifiedCores.size(); i+=this->Comm->GetIntraSize()) { unsigned int recvCore = notifiedCores[i]; this->SendAcknowledgment(recvCore, clearCode, XDMF_DSM_EXCHANGE_TAG, this->CommChannel); } // Then all cores remove the string from the map of notifications WaitingMap.erase(std::string(notifystring)); } break; } case XDMF_DSM_REGISTER_FILE: { // save file description XdmfDSMBuffer::XDMF_file_desc * newfile = new XdmfDSMBuffer::XDMF_file_desc(); int strlength = 0; this->ReceiveAcknowledgment(who, strlength, XDMF_DSM_EXCHANGE_TAG, this->CommChannel); newfile->name = new char[strlength + 1]; this->ReceiveData(who, newfile->name, strlength, XDMF_DSM_EXCHANGE_TAG, 0, this->CommChannel); newfile->name[strlength] = 0; this->ReceiveData(who, (char *)&newfile->start, sizeof(haddr_t), XDMF_DSM_EXCHANGE_TAG, 0, this->CommChannel); this->ReceiveData(who, (char *)&newfile->end, sizeof(haddr_t), XDMF_DSM_EXCHANGE_TAG, 0, this->CommChannel); int recvNumPages = 0; this->ReceiveAcknowledgment(who, recvNumPages, XDMF_DSM_EXCHANGE_TAG, this->CommChannel); newfile->numPages = recvNumPages; if (newfile->numPages > 0) { newfile->pages = new unsigned int[newfile->numPages](); this->ReceiveData(who, (char *)newfile->pages, newfile->numPages * sizeof(unsigned int), XDMF_DSM_EXCHANGE_TAG, 0, this->CommChannel); } else { newfile->pages = NULL; } // If old description exists, overwrite it. FileDefinitions[std::string(newfile->name)] = newfile; break; } case XDMF_DSM_REQUEST_PAGES: { // set aside pages to a file char * requestfile; int strlength = 0; this->ReceiveAcknowledgment(who, strlength, XDMF_DSM_EXCHANGE_TAG, this->CommChannel); requestfile = new char[strlength + 1]; this->ReceiveData(who, requestfile, strlength, XDMF_DSM_EXCHANGE_TAG, 0, this->CommChannel); requestfile[strlength] = 0; // This file will have its pages appended to. XdmfDSMBuffer::XDMF_file_desc * filedesc; if (FileDefinitions.count(std::string(requestfile)) > 0) { filedesc = FileDefinitions[std::string(requestfile)]; } else { filedesc = new XDMF_file_desc(); filedesc->start = 0; filedesc->end = 0; filedesc->numPages = 0; filedesc->pages = NULL; } int datasize = 0; // Request size required for the file this->ReceiveAcknowledgment(who, datasize, XDMF_DSM_EXCHANGE_TAG, this->CommChannel); // TODO Error handling block length must be greater than 0 // If Block size = 0 then do nothing? // Then return blank data? int requestedblocks = ((double)datasize) / this->BlockLength; // Round up if (requestedblocks * this->BlockLength != datasize) { ++requestedblocks; } while (requestedblocks + PagesAssigned >= this->NumPages * this->Comm->GetIntraSize()) { // If requested blocks are out of range, resize for (int i = this->GetStartServerId() + 1; // Since this is core 0 sending it i <= this->GetEndServerId(); ++i) { if (i != this->Comm->GetInterId()) { this->SendCommandHeader(XDMF_DSM_OPCODE_RESIZE, i, 0, 0, XDMF_DSM_INTER_COMM); } } this->SetLength(this->Length + (this->Length * this->ResizeFactor)); } unsigned int * newpagelist = new unsigned int[filedesc->numPages + requestedblocks](); unsigned int index = 0; for (unsigned int i = 0; i < filedesc->numPages; ++i) { newpagelist[index] = filedesc->pages[index]; ++index; } for (;index < filedesc->numPages + requestedblocks; ++index) { // The number of pages assigned is incremented after the page is added. // The value added is simply an index newpagelist[index] = PagesAssigned++; } filedesc->numPages = filedesc->numPages + requestedblocks; unsigned int * oldpointer = filedesc->pages; filedesc->pages = newpagelist; if (oldpointer != NULL) { delete oldpointer; } // Send back new page allocation pointer this->SendAcknowledgment(who, filedesc->numPages, XDMF_DSM_EXCHANGE_TAG, this->CommChannel); this->SendData(who, (char *)filedesc->pages, filedesc->numPages * sizeof(unsigned int), XDMF_DSM_EXCHANGE_TAG, 0, this->CommChannel); this->SendData(who, (char*)&filedesc->start, sizeof(haddr_t), XDMF_DSM_EXCHANGE_TAG, 0, this->CommChannel); filedesc->end = filedesc->start + (filedesc->numPages * this->BlockLength); this->SendData(who, (char*)&(filedesc->end), sizeof(haddr_t), XDMF_DSM_EXCHANGE_TAG, 0, this->CommChannel); // Notify the current size of the buffer int currentLength = this->Length; this->SendAcknowledgment(who, currentLength, XDMF_DSM_EXCHANGE_TAG, this->CommChannel); break; } case XDMF_DSM_REQUEST_FILE: { char * requestfile; int strlength = 0; this->ReceiveAcknowledgment(who, strlength, XDMF_DSM_EXCHANGE_TAG, this->CommChannel); requestfile = new char[strlength + 1]; this->ReceiveData(who, requestfile, strlength, XDMF_DSM_EXCHANGE_TAG, 0, this->CommChannel); requestfile[strlength] = 0; // This file will be returned. XdmfDSMBuffer::XDMF_file_desc * filedesc; if (FileDefinitions.count(std::string(requestfile)) > 0) { this->SendAcknowledgment(who, XDMF_DSM_SUCCESS, XDMF_DSM_EXCHANGE_TAG, this->CommChannel); filedesc = FileDefinitions[std::string(requestfile)]; this->SendData(who, (char*)&filedesc->start, sizeof(haddr_t), XDMF_DSM_EXCHANGE_TAG, 0, this->CommChannel); this->SendData(who, (char*)&filedesc->end, sizeof(haddr_t), XDMF_DSM_EXCHANGE_TAG, 0, this->CommChannel); int sendNumPages = filedesc->numPages; this->SendAcknowledgment(who, sendNumPages, XDMF_DSM_EXCHANGE_TAG, this->CommChannel); this->SendData(who, (char *)filedesc->pages, filedesc->numPages * sizeof(unsigned int), XDMF_DSM_EXCHANGE_TAG, 0, this->CommChannel); } else { this->SendAcknowledgment(who, XDMF_DSM_FAIL, XDMF_DSM_EXCHANGE_TAG, this->CommChannel); } break; } case XDMF_DSM_OPCODE_RESIZE: this->SetLength(this->Length + (this->Length * this->ResizeFactor)); break; case XDMF_DSM_REQUEST_ACCESS: { int isLocked = 0; char * requestfile; int strlength = 0; this->ReceiveAcknowledgment(who, strlength, XDMF_DSM_EXCHANGE_TAG, this->CommChannel); requestfile = new char[strlength + 1]; this->ReceiveData(who, requestfile, strlength, XDMF_DSM_EXCHANGE_TAG, 0, this->CommChannel); requestfile[strlength] = 0; // If the requesting core is the one who // already locked the file then tell it that there is not lock. std::map::iterator isOwner = FileOwners.find(std::string(requestfile)); if (LockedMap.count(std::string(requestfile)) > 0) { if (isOwner->second != who) { // If the file is locked notify the requesting core and add it to the queue. isLocked = 1; LockedMap[std::string(requestfile)].push(who); } } else { LockedMap[std::string(requestfile)] = std::queue(); FileOwners[std::string(requestfile)] = who; } this->SendAcknowledgment(who, isLocked, XDMF_DSM_EXCHANGE_TAG, this->CommChannel); break; } case XDMF_DSM_UNLOCK_FILE: { char * requestfile; int strlength = 0; this->ReceiveAcknowledgment(who, strlength, XDMF_DSM_EXCHANGE_TAG, this->CommChannel); requestfile = new char[strlength + 1]; this->ReceiveData(who, requestfile, strlength, XDMF_DSM_EXCHANGE_TAG, 0, this->CommChannel); requestfile[strlength] = 0; // If file isn't locked do nothing if (LockedMap.count(std::string(requestfile)) > 0) { // Remove the queue if there are no more waiting if (LockedMap[std::string(requestfile)].size() > 0) { // Pop the next process waiting off the queue unsigned int nextCore = LockedMap[std::string(requestfile)].front(); LockedMap[std::string(requestfile)].pop(); FileOwners[std::string(requestfile)] = nextCore; this->SendAcknowledgment(nextCore, 1, XDMF_DSM_EXCHANGE_TAG, this->CommChannel); } if(LockedMap[std::string(requestfile)].size() == 0) { LockedMap.erase(std::string(requestfile)); FileOwners.erase(std::string(requestfile)); } } break; } case XDMF_DSM_LOCK_ACQUIRE: // Currently unsupported break; // H5FD_DSM_LOCK_RELEASE // Comes from client or server depending on communicator case XDMF_DSM_LOCK_RELEASE: // Currently unsupported break; // H5FD_DSM_OPCODE_DONE // Always received on server case XDMF_DSM_OPCODE_DONE: break; // DEFAULT default : try { std::stringstream message; message << "Error: Unknown Opcode " << opcode; XdmfError::message(XdmfError::FATAL, message.str()); } catch (XdmfError & e) { throw e; } } if (returnOpcode) *returnOpcode = opcode; return(XDMF_DSM_SUCCESS); } void XdmfDSMBuffer::BufferServiceLoop(int *returnOpcode) { int op, status = XDMF_DSM_SUCCESS; while (status == XDMF_DSM_SUCCESS) { try { status = this->BufferService(&op); } catch (XdmfError & e) { throw e; } if (returnOpcode) *returnOpcode = op; if (op == XDMF_DSM_OPCODE_DONE) { break; } } } void XdmfDSMBuffer::Create(MPI_Comm newComm, int startId, int endId) { // // Create DSM communicator // switch (this->InterCommType) { case XDMF_DSM_COMM_MPI: this->Comm = new XdmfDSMCommMPI(); break; default: try { XdmfError::message(XdmfError::FATAL, "DSM communication type not supported"); } catch (XdmfError & e) { throw e; } } this->Comm->DupComm(newComm); this->Comm->Init(); // Uniform Dsm : every node has a buffer the same size. (Addresses are sequential) // Block DSM : nodes are set up using paging long length = (long) (this->LocalBufferSizeMBytes)*1024LU*1024LU; switch (this->DsmType) { case XDMF_DSM_TYPE_UNIFORM: case XDMF_DSM_TYPE_UNIFORM_RANGE: this->ConfigureUniform(this->Comm, length, startId, endId); break; case XDMF_DSM_TYPE_BLOCK_CYCLIC: this->ConfigureUniform(this->Comm, length, startId, endId, this->BlockLength, false); break; case XDMF_DSM_TYPE_BLOCK_RANDOM: this->ConfigureUniform(this->Comm, length, startId, endId, this->BlockLength, true); break; default: try { XdmfError(XdmfError::FATAL, "DSM configuration type not supported"); } catch (XdmfError & e) { throw e; } } } void XdmfDSMBuffer::ConfigureUniform(XdmfDSMCommMPI *aComm, long aLength, int startId, int endId, long aBlockLength, bool random) { if (startId < 0) { startId = 0; } if (endId < 0) { endId = aComm->GetIntraSize() - 1; } this->SetDsmType(XDMF_DSM_TYPE_UNIFORM_RANGE); if ((startId == 0) && (endId == aComm->GetIntraSize() - 1)) { this->SetDsmType(XDMF_DSM_TYPE_UNIFORM); } if (aBlockLength) { if (!random) { this->SetDsmType(XDMF_DSM_TYPE_BLOCK_CYCLIC); } else { this->SetDsmType(XDMF_DSM_TYPE_BLOCK_RANDOM); } this->SetBlockLength(aBlockLength); } this->StartServerId = startId; this->EndServerId = endId; this->SetComm(aComm); if ((aComm->GetId() >= startId) && (aComm->GetId() <= endId) && this->IsServer) { try { if (aBlockLength) { // For optimization we make the DSM length fit to a multiple of block size this->SetLength(((long)(aLength / aBlockLength)) * aBlockLength); this->NumPages = ((long)(aLength / aBlockLength)); } else { this->SetLength(aLength); } } catch (XdmfError & e) { throw e; } this->StartAddress = (aComm->GetId() - startId) * aLength; this->EndAddress = this->StartAddress + aLength - 1; } else { if (aBlockLength) { this->Length = ((long)(aLength / aBlockLength)) * aBlockLength; } else { this->Length = aLength; } } this->TotalLength = this->GetLength() * (endId - startId + 1); // Set DSM structure std::vector > newStructure; // determine size of application before the server if (startId > 0) { newStructure.push_back(std::pair(aComm->GetApplicationName(), startId)); } newStructure.push_back(std::pair("Server", (endId + 1) - startId)); if(aComm->GetInterSize() - (startId +((endId + 1) - startId)) > 0) { newStructure.push_back(std::pair(aComm->GetApplicationName(), aComm->GetInterSize() - (startId +((endId + 1) - startId)))); } aComm->SetDsmProcessStructure(newStructure); } void XdmfDSMBuffer::Connect(bool persist) { int status; do { try { status = this->GetComm()->Connect(); } catch (XdmfError & e) { throw e; } if (status == MPI_SUCCESS) { this->SetIsConnected(true); try { this->ReceiveInfo(); } catch (XdmfError & e) { throw e; } } else { #ifdef _WIN32 Sleep(1000); // Since windows has a different sleep command #else sleep(1); #endif } } while (persist && (status != MPI_SUCCESS)); } void XdmfDSMBuffer::Disconnect() { // Disconnecting is done manually try { this->GetComm()->Disconnect(); } catch (XdmfError & e) { throw e; } this->SetIsConnected(false); } void XdmfDSMBuffer::Get(long Address, long aLength, void *Data) { int who, MyId = this->Comm->GetInterId(); int astart, aend, len; char *datap = (char *)Data; // While there is length left while(aLength) { // Figure out what server core the address is located on who = this->AddressToId(Address); if(who == XDMF_DSM_FAIL){ try { XdmfError::message(XdmfError::FATAL, "Address Error"); } catch (XdmfError & e) { throw e; } } // Get the start and end of the block listed this->GetAddressRangeForId(who, &astart, &aend); // Determine the amount of data to be written to that core // Basically, it's how much data will fit from // the starting point of the address to the end len = std::min(aLength, aend - Address + 1); // If the data is on the core running this code, then the put is simple if(who == MyId){ char *dp; dp = this->DataPointer; dp += Address - this->StartAddress; memcpy(datap, dp, len); } else{ // Otherwise send it to the appropriate core to deal with int dataComm = XDMF_DSM_INTRA_COMM; if (this->Comm->GetInterComm() != MPI_COMM_NULL) { dataComm = XDMF_DSM_INTER_COMM; } try { this->SendCommandHeader(XDMF_DSM_OPCODE_GET, who, Address - astart, len, dataComm); } catch (XdmfError & e) { throw e; } try { this->ReceiveData(who, datap, len, XDMF_DSM_GET_DATA_TAG, Address - astart, dataComm); } catch (XdmfError & e) { throw e; } } // Shift all the numbers by the length of the data written // Until aLength = 0 aLength -= len; Address += len; datap += len; } } void XdmfDSMBuffer::Get(unsigned int * pages, unsigned int numPages, long Address, long aLength, void *Data) { char * currentStart; unsigned int currentPageId = Address / this->BlockLength; unsigned int dsmPage; long startingAddress = Address % this->BlockLength; unsigned int tranferedLength; unsigned int dataPage = 0; long pointeroffset = 0; int serverCore; int writeAddress; while (aLength) { if (dataPage == 0) { tranferedLength = this->BlockLength - startingAddress; } else { tranferedLength = this->BlockLength; } if (tranferedLength > aLength) { tranferedLength = aLength; } dsmPage = pages[currentPageId]; currentStart = (char *)Data + pointeroffset;; // Write page to DSM // page to DSM server Id // page to address // write to location serverCore = PageToId(dsmPage); writeAddress = PageToAddress(dsmPage); if (serverCore == XDMF_DSM_FAIL) { XdmfError::message(XdmfError::FATAL, "Error: Unable to determine server core."); } if (writeAddress == XDMF_DSM_FAIL) { XdmfError::message(XdmfError::FATAL, "Error: Unable to determine write address."); } if (dataPage == 0) { writeAddress += startingAddress; } // If the data is on the core running this code, then the put is simple if(serverCore == this->Comm->GetInterId()){ char *dp; dp = this->DataPointer; dp += writeAddress; memcpy(currentStart, dp, tranferedLength); } else{ // Otherwise send it to the appropriate core to deal with int dataComm = XDMF_DSM_INTRA_COMM; if (this->Comm->GetInterComm() != MPI_COMM_NULL) { dataComm = XDMF_DSM_INTER_COMM; } try { this->SendCommandHeader(XDMF_DSM_OPCODE_GET, serverCore, writeAddress, tranferedLength, dataComm); } catch (XdmfError & e) { throw e; } try { this->ReceiveData(serverCore, currentStart, tranferedLength, XDMF_DSM_GET_DATA_TAG, writeAddress, dataComm); } catch (XdmfError & e) { throw e; } } aLength -= tranferedLength; pointeroffset += tranferedLength; // move to the next page ++currentPageId; ++dataPage; } } void XdmfDSMBuffer::GetAddressRangeForId(int Id, int *Start, int *End){ switch(this->DsmType) { case XDMF_DSM_TYPE_UNIFORM : case XDMF_DSM_TYPE_UNIFORM_RANGE : // All Servers have same length // Start index is equal to the id inside the servers times // the length of the block per server // It is the starting index of the server's data block relative // to the entire block *Start = (Id - this->StartServerId) * this->Length; // End index is simply the start index + the length of the // server's data block. // The range produced is the start of the server's data block to its end. *End = *Start + Length - 1; break; default : // Not Implemented try { std::stringstream message; message << "DsmType " << this->DsmType << " not yet implemented"; XdmfError::message(XdmfError::FATAL, message.str()); } catch (XdmfError & e) { throw e; } break; } } long XdmfDSMBuffer::GetBlockLength() { return this->BlockLength; } XdmfDSMCommMPI * XdmfDSMBuffer::GetComm() { return this->Comm; } char * XdmfDSMBuffer::GetDataPointer() { return this->DataPointer; } int XdmfDSMBuffer::GetDsmType() { return this->DsmType; } int XdmfDSMBuffer::GetEndAddress() { return this->EndAddress; } int XdmfDSMBuffer::GetEndServerId() { return this->EndServerId; } int XdmfDSMBuffer::GetInterCommType() { return this->InterCommType; } bool XdmfDSMBuffer::GetIsConnected() { return IsConnected; } bool XdmfDSMBuffer::GetIsServer() { return this->IsServer; } long XdmfDSMBuffer::GetLength() { // This is the length of the pointer on the current core. // Different from local buffer size as that value is // the starting size. return this->Length; } unsigned int XdmfDSMBuffer::GetLocalBufferSizeMBytes() { // This is the starting value, so it is not updated as the pointer is expanded. return this->LocalBufferSizeMBytes; } double XdmfDSMBuffer::GetResizeFactor() { return this->ResizeFactor; } int XdmfDSMBuffer::GetStartAddress() { return this->StartAddress; } int XdmfDSMBuffer::GetStartServerId() { return this->StartServerId; } long XdmfDSMBuffer::GetTotalLength() { return this->TotalLength; } void XdmfDSMBuffer::Lock(char * filename) { int strlength = std::string(filename).size(); // Request access to the file this->SendCommandHeader(XDMF_DSM_REQUEST_ACCESS, this->GetStartServerId(), 0, 0, XDMF_DSM_INTER_COMM); this->SendAcknowledgment(this->GetStartServerId(), strlength, XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM); this->SendData(this->GetStartServerId(), filename, strlength, XDMF_DSM_EXCHANGE_TAG, 0, XDMF_DSM_INTER_COMM); int isLocked = 0; this->ReceiveAcknowledgment(this->GetStartServerId(), isLocked, XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM); if (isLocked == 1) { // If locked wait for notification that the file is available. this->ReceiveAcknowledgment(this->GetStartServerId(), isLocked, XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM); } } int XdmfDSMBuffer::PageToId(int pageId) { int ServerId = XDMF_DSM_FAIL; switch(this->DsmType) { case XDMF_DSM_TYPE_BLOCK_CYCLIC : case XDMF_DSM_TYPE_BLOCK_RANDOM : { // Block based allocation should use PageToId // All Servers have same length // This finds out which server the address provided starts on int serversize = (this->EndServerId - this->StartServerId); if (serversize < 1) { serversize = 1; } ServerId = pageId % serversize;// This should only be called by the server ServerId += this->StartServerId; // Apply the offset of the server if required. break; } default : // Not Implemented try { std::stringstream message; message << "DsmType " << this->DsmType << " not yet implemented or not paged"; XdmfError::message(XdmfError::FATAL, message.str()); } catch (XdmfError & e) { throw e; } break; } return(ServerId); } int XdmfDSMBuffer::PageToAddress(int pageId) { int resultAddress = XDMF_DSM_FAIL; switch(this->DsmType) { case XDMF_DSM_TYPE_BLOCK_CYCLIC : case XDMF_DSM_TYPE_BLOCK_RANDOM : { // Block based allocation should use PageToId // All Servers have same length // This finds out which server the address provided starts on // Since this is integers being divided the result is truncated. int serversize = (this->EndServerId - this->StartServerId); if (serversize < 1) { serversize = 1; } resultAddress = this->BlockLength * (pageId / serversize); break; } default : // Not Implemented try { std::stringstream message; message << "DsmType " << this->DsmType << " not yet implemented or not paged"; XdmfError::message(XdmfError::FATAL, message.str()); } catch (XdmfError & e) { throw e; } break; } return(resultAddress); } void XdmfDSMBuffer::ProbeCommandHeader(int *comm) { // Used for finding a comm that has a waiting command, then sets the comm int status = XDMF_DSM_FAIL; MPI_Status signalStatus; int flag; MPI_Comm probeComm = static_cast(this->Comm)->GetIntraComm(); // Spin until a message is found on one of the communicators while (status != XDMF_DSM_SUCCESS) { status = MPI_Iprobe(XDMF_DSM_ANY_SOURCE, XDMF_DSM_ANY_TAG, probeComm, &flag, &signalStatus); if (status != MPI_SUCCESS) { try { XdmfError::message(XdmfError::FATAL, "Error: Failed to probe for command header"); } catch (XdmfError & e) { throw e; } } if (flag) { status = XDMF_DSM_SUCCESS; } else { if (static_cast(this->Comm)->GetInterComm() != MPI_COMM_NULL) { if (probeComm == static_cast(this->Comm)->GetIntraComm()) { probeComm = static_cast(this->Comm)->GetInterComm(); } else { probeComm = static_cast(this->Comm)->GetIntraComm(); } } } } if (probeComm == static_cast(this->Comm)->GetInterComm()) { *comm = XDMF_DSM_INTER_COMM; } else { *comm = XDMF_DSM_INTRA_COMM; } probeComm = MPI_COMM_NULL; } void XdmfDSMBuffer::Put(long Address, long aLength, const void *Data) { int who, MyId = this->Comm->GetInterId(); int astart, aend, len; char *datap = (char *)Data; // While there is length left while(aLength){ // Figure out what server core the address is located on who = this->AddressToId(Address); if(who == XDMF_DSM_FAIL){ try { XdmfError::message(XdmfError::FATAL, "Address Error"); } catch (XdmfError & e) { throw e; } } // Get the start and end of the block listed this->GetAddressRangeForId(who, &astart, &aend); // Determine the amount of data to be written to that core // Basically, it's how much data will fit from the starting point of // the address to the end len = std::min(aLength, aend - Address + 1); // If the data is on the core running this code, then the put is simple if(who == MyId){ char *dp; dp = this->DataPointer; dp += Address - this->StartAddress; memcpy(dp, datap, len); } else{ // Otherwise send it to the appropriate core to deal with int dataComm = XDMF_DSM_INTRA_COMM; if (this->Comm->GetInterComm() != MPI_COMM_NULL) { dataComm = XDMF_DSM_INTER_COMM; } try { this->SendCommandHeader(XDMF_DSM_OPCODE_PUT, who, Address - astart, len, dataComm); } catch (XdmfError & e) { throw e; } try { this->SendData(who, datap, len, XDMF_DSM_PUT_DATA_TAG, Address - astart, dataComm); } catch (XdmfError & e) { throw e; } } // Shift all the numbers by the length of the data written // Until aLength = 0 aLength -= len; Address += len; datap += len; } } void XdmfDSMBuffer::Put(unsigned int * pages, unsigned int numPages, haddr_t Address, haddr_t aLength, const void *Data) { char * currentStart; unsigned int currentPageId = Address / this->BlockLength; unsigned int dsmPage = 0; long startingAddress = Address % this->BlockLength; unsigned int tranferedLength; long pointeroffset = 0; unsigned int dataPage = 0; int serverCore = 0; int writeAddress = 0; while (aLength) { if (dataPage == 0) { tranferedLength = this->BlockLength - startingAddress; } else { tranferedLength = this->BlockLength; } if (tranferedLength > aLength) { tranferedLength = aLength; } dsmPage = pages[currentPageId]; currentStart = (char *)Data + pointeroffset; // Write page to DSM // page to DSM server Id // page to address // write to location serverCore = PageToId(dsmPage); writeAddress = PageToAddress(dsmPage); if (serverCore == XDMF_DSM_FAIL) { XdmfError::message(XdmfError::FATAL, "Error: Unable to determine page server core."); } if (writeAddress == XDMF_DSM_FAIL) { XdmfError::message(XdmfError::FATAL, "Error: Unable to determine page address."); } if (dataPage == 0) { writeAddress += startingAddress; } // If the data is on the core running this code, then the put is simple if(serverCore == this->Comm->GetInterId()) { char *dp; dp = this->DataPointer; dp += writeAddress; memcpy(dp, currentStart, tranferedLength); } else{ // Otherwise send it to the appropriate core to deal with int dataComm = XDMF_DSM_INTRA_COMM; if (this->Comm->GetInterComm() != MPI_COMM_NULL) { dataComm = XDMF_DSM_INTER_COMM; } try { this->SendCommandHeader(XDMF_DSM_OPCODE_PUT, serverCore, writeAddress, tranferedLength, dataComm); } catch (XdmfError & e) { throw e; } try { this->SendData(serverCore, currentStart, tranferedLength, XDMF_DSM_PUT_DATA_TAG, writeAddress, dataComm); } catch (XdmfError & e) { throw e; } } aLength -= tranferedLength; pointeroffset += tranferedLength; // move to the next page ++currentPageId; ++dataPage; } } void XdmfDSMBuffer::ReceiveAcknowledgment(int source, int &data, int tag, int comm) { int status; MPI_Status signalStatus; this->Comm->Receive(&data, sizeof(int), source, comm, tag); status = MPI_SUCCESS; if (status != MPI_SUCCESS) { try { XdmfError::message(XdmfError::FATAL, "Error: Failed to receive data"); } catch (XdmfError & e) { throw e; } } } void XdmfDSMBuffer::ReceiveCommandHeader(int *opcode, int *source, int *address, int *aLength, int comm, int remoteSource) { CommandMsg cmd; memset(&cmd, 0, sizeof(CommandMsg)); int status = MPI_ERR_OTHER; MPI_Status signalStatus; if (remoteSource < 0) { remoteSource = MPI_ANY_SOURCE; } this->Comm->Receive(&cmd, sizeof(CommandMsg), remoteSource, comm, XDMF_DSM_COMMAND_TAG); status = MPI_SUCCESS; if (status != MPI_SUCCESS) { try { XdmfError::message(XdmfError::FATAL, "Error: Failed to receive command header"); } catch (XdmfError & e) { throw e; } } else { *opcode = cmd.Opcode; *source = cmd.Source; *address = cmd.Address; *aLength = cmd.Length; } } void XdmfDSMBuffer::ReceiveData(int source, char * data, int aLength, int tag, int aAddress, int comm) { int status; MPI_Status signalStatus; this->Comm->Receive(data, aLength, source, comm, tag); status = MPI_SUCCESS; if (status != MPI_SUCCESS) { try { XdmfError::message(XdmfError::FATAL, "Error: Failed to receive data"); } catch (XdmfError & e) { throw e; } } } void XdmfDSMBuffer::ReceiveInfo() { InfoMsg dsmInfo; int status; memset(&dsmInfo, 0, sizeof(InfoMsg)); int infoStatus = 0; if (this->Comm->GetId() == 0) { infoStatus = 1; } int * groupInfoStatus = new int[this->Comm->GetInterSize()](); this->Comm->AllGather(&infoStatus, sizeof(int), &(groupInfoStatus[0]), sizeof(int), XDMF_DSM_INTER_COMM); int sendCore = 0; for (int i = 0; i < this->Comm->GetInterSize(); ++i) { if (groupInfoStatus[i] == 2) { sendCore = i; } } status = MPI_SUCCESS; this->Comm->Broadcast(&dsmInfo, sizeof(InfoMsg), sendCore, XDMF_DSM_INTER_COMM); if (status != MPI_SUCCESS) { try { XdmfError::message(XdmfError::FATAL, "Error: Failed to broadcast info"); } catch (XdmfError & e) { throw e; } } this->SetDsmType(dsmInfo.type); // We are a client so don't allocate anything but only set a virtual remote length this->SetLength(dsmInfo.length); this->TotalLength = dsmInfo.total_length; this->SetBlockLength(dsmInfo.block_length); this->StartServerId = dsmInfo.start_server_id; this->EndServerId = dsmInfo.end_server_id; MPI_Comm comm = this->Comm->GetInterComm(); // Cray needs to be launched via the colon notation so that it // can properly create a merged communicator int rank = this->Comm->GetInterId(); int size = this->Comm->GetInterSize(); int currentCore = 0; int * checkstatus = new int[size](); int localCheck = 0; std::string applicationName = this->Comm->GetApplicationName(); char * coreTag; int tagSize = 0; std::vector coreSplit; unsigned int splitid = 0; std::vector > newStructure; int * splitIds; unsigned int splitsize = 0; while (currentCore < size) { if (rank == currentCore) { tagSize = applicationName.size(); } MPI_Bcast(&tagSize, 1, MPI_INT, currentCore, comm); coreTag = new char[tagSize+1](); if (rank == currentCore) { strcpy(coreTag, applicationName.c_str()); } MPI_Bcast(coreTag, tagSize, MPI_CHAR, currentCore, comm); coreTag[tagSize] = 0; if (strcmp(coreTag, applicationName.c_str()) == 0) { localCheck = 1; } else { localCheck = 0; } checkstatus[rank] = localCheck; MPI_Allgather(&localCheck, 1, MPI_INT, checkstatus, 1, MPI_INT, comm); bool insplit = false; while (checkstatus[currentCore]) { if (rank == currentCore) { insplit = true; } coreSplit.push_back(currentCore); ++currentCore; if (currentCore >= size) { break; } } if (insplit) { splitIds = (int *)calloc(coreSplit.size(), sizeof(int)); memcpy(splitIds, &(coreSplit[0]), coreSplit.size() * sizeof(int)); splitsize = coreSplit.size(); } newStructure.push_back(std::pair(std::string(coreTag), coreSplit.size())); coreSplit.clear(); ++splitid; } this->Comm->SetDsmProcessStructure(newStructure); } int XdmfDSMBuffer::RegisterFile(char * name, unsigned int * pages, unsigned int numPages, haddr_t start, haddr_t end) { this->SendCommandHeader(XDMF_DSM_REGISTER_FILE, this->GetStartServerId(), 0, 0, XDMF_DSM_INTER_COMM); int strlength = std::string(name).size(); this->SendAcknowledgment(this->GetStartServerId(), strlength, XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM); this->SendData(this->GetStartServerId(), name, strlength, XDMF_DSM_EXCHANGE_TAG, 0, XDMF_DSM_INTER_COMM); this->SendData(this->GetStartServerId(), (char *)&start, sizeof(haddr_t), XDMF_DSM_EXCHANGE_TAG, 0, XDMF_DSM_INTER_COMM); this->SendData(this->GetStartServerId(), (char *)&end, sizeof(haddr_t), XDMF_DSM_EXCHANGE_TAG, 0, XDMF_DSM_INTER_COMM); this->SendAcknowledgment(this->GetStartServerId(), numPages, XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM); if (numPages > 0) { this->SendData(this->GetStartServerId(), (char *)pages, numPages * sizeof(unsigned int), XDMF_DSM_EXCHANGE_TAG, 0, XDMF_DSM_INTER_COMM); } return XDMF_DSM_SUCCESS; } int XdmfDSMBuffer::RequestFileDescription(char * name, std::vector & pages, unsigned int & numPages, haddr_t & start, haddr_t & end) { this->SendCommandHeader(XDMF_DSM_REQUEST_FILE, this->GetStartServerId(), 0, 0, XDMF_DSM_INTER_COMM); int strlength = std::string(name).size(); this->SendAcknowledgment(this->GetStartServerId(), strlength, XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM); this->SendData(this->GetStartServerId(), name, strlength, XDMF_DSM_EXCHANGE_TAG, 0, XDMF_DSM_INTER_COMM); int fileExists = XDMF_DSM_SUCCESS; this->ReceiveAcknowledgment(this->GetStartServerId(), fileExists, XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM); if (fileExists == XDMF_DSM_SUCCESS) { this->ReceiveData(this->GetStartServerId(), (char*)&start, sizeof(haddr_t), XDMF_DSM_EXCHANGE_TAG, 0, XDMF_DSM_INTER_COMM); this->ReceiveData(this->GetStartServerId(), (char*)&end, sizeof(haddr_t), XDMF_DSM_EXCHANGE_TAG, 0, XDMF_DSM_INTER_COMM); int recvNumPages = 0; this->ReceiveAcknowledgment(this->GetStartServerId(), recvNumPages, XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM); numPages = recvNumPages; // Reallocate pointer pages.clear(); unsigned int * pagelist = new unsigned int[numPages]; this->ReceiveData(this->GetStartServerId(), (char *)pagelist, numPages * sizeof(unsigned int), XDMF_DSM_EXCHANGE_TAG, 0, XDMF_DSM_INTER_COMM); for (unsigned int i = 0; i < numPages; ++i) { pages.push_back(pagelist[i]); } return XDMF_DSM_SUCCESS; } else { return XDMF_DSM_FAIL; } } void XdmfDSMBuffer::RequestPages(char * name, haddr_t spaceRequired, std::vector & pages, unsigned int & numPages, haddr_t & start, haddr_t & end) { this->SendCommandHeader(XDMF_DSM_REQUEST_PAGES, this->GetStartServerId(), 0, 0, XDMF_DSM_INTER_COMM); // set aside pages to a file int strlength = std::string(name).size(); this->SendAcknowledgment(this->GetStartServerId(), strlength, XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM); this->SendData(this->GetStartServerId(), name, strlength, XDMF_DSM_EXCHANGE_TAG, 0, XDMF_DSM_INTER_COMM); // Request size required for the file this->SendAcknowledgment(this->GetStartServerId(), spaceRequired, XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM); // Send back new page allocation pointer int newPageCount = 0; this->ReceiveAcknowledgment(this->GetStartServerId(), newPageCount, XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM); numPages = newPageCount; unsigned int * pagelist = new unsigned int[numPages](); pages.clear(); this->ReceiveData(this->GetStartServerId(), (char *) pagelist, numPages * sizeof(unsigned int), XDMF_DSM_EXCHANGE_TAG, 0, XDMF_DSM_INTER_COMM); for (unsigned int i = 0; i < numPages; ++i) { pages.push_back(pagelist[i]); } // Recieve the new start and end addresses this->ReceiveData(this->GetStartServerId(), (char*)&start, sizeof(haddr_t), XDMF_DSM_EXCHANGE_TAG, 0, XDMF_DSM_INTER_COMM); this->ReceiveData(this->GetStartServerId(), (char*)&end, sizeof(haddr_t), XDMF_DSM_EXCHANGE_TAG, 0, XDMF_DSM_INTER_COMM); // If resized, set up the reset the total length. int currentLength = 0; this->ReceiveAcknowledgment(this->GetStartServerId(), currentLength, XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM); this->UpdateLength(currentLength); } void XdmfDSMBuffer::SendAccept(unsigned int numConnections) { #ifndef XDMF_DSM_IS_CRAY for (int i = this->StartServerId; i <= this->EndServerId; ++i) { if (i != this->Comm->GetInterId()){ this->SendCommandHeader(XDMF_DSM_ACCEPT, i, 0, 0, XDMF_DSM_INTER_COMM); this->SendAcknowledgment(i, numConnections, XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM); } } this->Comm->Accept(numConnections); this->SendInfo(); #endif } void XdmfDSMBuffer::SendAcknowledgment(int dest, int data, int tag, int comm) { int status; this->Comm->Send(&data, sizeof(int), dest, comm, tag); status = MPI_SUCCESS; if (status != MPI_SUCCESS) { try { XdmfError::message(XdmfError::FATAL, "Error: Failed to receive data"); } catch (XdmfError & e) { throw e; } } } void XdmfDSMBuffer::SendCommandHeader(int opcode, int dest, int address, int aLength, int comm) { int status; CommandMsg cmd; memset(&cmd, 0, sizeof(CommandMsg)); cmd.Opcode = opcode; if (comm == XDMF_DSM_INTRA_COMM) { cmd.Source = this->Comm->GetId(); } else if (comm == XDMF_DSM_INTER_COMM) { cmd.Source = this->Comm->GetInterId(); } cmd.Target = dest; cmd.Address = address; cmd.Length = aLength; this->Comm->Send(&cmd, sizeof(CommandMsg), dest, comm, XDMF_DSM_COMMAND_TAG); status = MPI_SUCCESS; if (status != MPI_SUCCESS) { try { XdmfError::message(XdmfError::FATAL, "Error: Failed to send command header"); } catch (XdmfError & e) { throw e; } } } void XdmfDSMBuffer::SendData(int dest, char * data, int aLength, int tag, int aAddress, int comm) { int status; this->Comm->Send(data, aLength, dest, comm, tag); status = MPI_SUCCESS; if (status != MPI_SUCCESS) { try { XdmfError::message(XdmfError::FATAL, "Error: Failed to send data"); } catch (XdmfError & e) { throw e; } } } void XdmfDSMBuffer::SendDone() { try { if (static_cast(this->Comm)->GetInterComm() == MPI_COMM_NULL) { for (int i = this->StartServerId; i <= this->EndServerId; ++i) { if (i != this->Comm->GetId()){ this->SendCommandHeader(XDMF_DSM_OPCODE_DONE, i, 0, 0, XDMF_DSM_INTRA_COMM); } } } else { for (int i = this->StartServerId; i <= this->EndServerId; ++i) { if (i != this->Comm->GetId()){ this->SendCommandHeader(XDMF_DSM_OPCODE_DONE, i, 0, 0, XDMF_DSM_INTER_COMM); } } } } catch (XdmfError & e) { throw e; } } void XdmfDSMBuffer::SendInfo() { InfoMsg dsmInfo; int status; memset(&dsmInfo, 0, sizeof(InfoMsg)); dsmInfo.type = this->GetDsmType(); dsmInfo.length = this->GetLength(); dsmInfo.total_length = this->GetTotalLength(); dsmInfo.block_length = this->GetBlockLength(); dsmInfo.start_server_id = this->GetStartServerId(); dsmInfo.end_server_id = this->GetEndServerId(); int infoStatus = 3; if (this->Comm->GetId() == 0) { infoStatus = 2; } int * groupInfoStatus = new int[this->Comm->GetInterSize()](); this->Comm->AllGather(&infoStatus, sizeof(int), &(groupInfoStatus[0]), sizeof(int), XDMF_DSM_INTER_COMM); int sendCore = 0; for (int i = 0; i < this->Comm->GetInterSize(); ++i) { if (groupInfoStatus[i] == 2) { sendCore = i; } } status = MPI_SUCCESS; this->Comm->Broadcast(&dsmInfo, sizeof(InfoMsg), sendCore, XDMF_DSM_INTER_COMM); if (status != MPI_SUCCESS) { try { XdmfError::message(XdmfError::FATAL, "Error: Failed to send info"); } catch (XdmfError & e) { throw e; } } MPI_Comm comm = this->Comm->GetInterComm(); // Cray needs to be launched via the colon notation so that it // can properly create a merged communicator int rank = this->Comm->GetInterId(); int size = this->Comm->GetInterSize(); int currentCore = 0; int * checkstatus = new int[size](); int localCheck = 0; std::string applicationName = this->Comm->GetApplicationName(); char * coreTag; int tagSize = 0; std::vector coreSplit; unsigned int splitid = 0; std::vector > newStructure; int * splitIds; unsigned int splitsize = 0; while (currentCore < size) { if (rank == currentCore) { tagSize = applicationName.size(); } MPI_Bcast(&tagSize, 1, MPI_INT, currentCore, comm); coreTag = new char[tagSize+1](); if (rank == currentCore) { strcpy(coreTag, applicationName.c_str()); } MPI_Bcast(coreTag, tagSize, MPI_CHAR, currentCore, comm); coreTag[tagSize] = 0; if (strcmp(coreTag, applicationName.c_str()) == 0) { localCheck = 1; } else { localCheck = 0; } checkstatus[rank] = localCheck; MPI_Allgather(&localCheck, 1, MPI_INT, checkstatus, 1, MPI_INT, comm); bool insplit = false; while (checkstatus[currentCore]) { if (rank == currentCore) { insplit = true; } coreSplit.push_back(currentCore); ++currentCore; if (currentCore >= size) { break; } } if (insplit) { splitIds = (int *)calloc(coreSplit.size(), sizeof(int)); memcpy(splitIds, &(coreSplit[0]), coreSplit.size() * sizeof(int)); splitsize = coreSplit.size(); } newStructure.push_back(std::pair(std::string(coreTag), coreSplit.size())); coreSplit.clear(); ++splitid; } this->Comm->SetDsmProcessStructure(newStructure); } void XdmfDSMBuffer::SetBlockLength(long newBlock) { this->BlockLength = newBlock; } void XdmfDSMBuffer::SetComm(XdmfDSMCommMPI * newComm) { this->Comm = newComm; } void XdmfDSMBuffer::SetDsmType(int newDsmType) { this->DsmType = newDsmType; } void XdmfDSMBuffer::SetInterCommType(int newType) { this->InterCommType = newType; } void XdmfDSMBuffer::SetIsConnected(bool newStatus) { IsConnected = newStatus; } void XdmfDSMBuffer::SetIsServer(bool newIsServer) { this->IsServer = newIsServer; } void XdmfDSMBuffer::SetResizeFactor(double newFactor) { if (newFactor >= 0) { this->ResizeFactor = newFactor; } else { this->ResizeFactor = newFactor * -1; } } void XdmfDSMBuffer::SetLength(long aLength) { this->Length = aLength; if (this->DataPointer) { // Try to reallocate // This should not be called in most cases this->DataPointer = static_cast(realloc(this->DataPointer, this->Length*sizeof(char))); } else { #ifdef _WIN32 this->DataPointer = calloc(this->Length, sizeof(char)); #else #ifdef _SC_PAGESIZE posix_memalign((void **)(&this->DataPointer), sysconf(_SC_PAGESIZE), this->Length); memset(this->DataPointer, 0, this->Length); #else // Older linux variation, for backwards compatibility posix_memalign((void **)(&this->DataPointer), getpagesize(), this->Length); memset(this->DataPointer, 0, this->Length); #endif #endif } if (this->DataPointer == NULL) { std::stringstream message; message << "Allocation Failed, unable to allocate " << this->Length; XdmfError::message(XdmfError::FATAL, message.str()); } if (this->BlockLength > 0) { this->NumPages = this->Length / this->BlockLength; } } void XdmfDSMBuffer::SetLocalBufferSizeMBytes(unsigned int newSize) { this->LocalBufferSizeMBytes = newSize; } void XdmfDSMBuffer::Unlock(char * filename) { int strlength = std::string(filename).size(); this->SendCommandHeader(XDMF_DSM_UNLOCK_FILE, this->GetStartServerId(), 0, 0, XDMF_DSM_INTER_COMM); this->SendAcknowledgment(this->GetStartServerId(), strlength, XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM); this->SendData(this->GetStartServerId(), filename, strlength, XDMF_DSM_EXCHANGE_TAG, 0, XDMF_DSM_INTER_COMM); } void XdmfDSMBuffer::UpdateLength(unsigned int newLength) { this->Length = newLength; this->TotalLength = this->Length * (this->EndServerId - this->StartServerId); } void XdmfDSMBuffer::WaitRelease(std::string filename, std::string datasetname, int code) { // Send Command Header this->SendCommandHeader(XDMF_DSM_CLEAR_NOTIFY, this->GetStartServerId(), 0, 0, XDMF_DSM_INTER_COMM); // Send string size this->SendAcknowledgment(this->GetStartServerId(), filename.size() + datasetname.size(), XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM); // Send string char * sendPointer = new char[filename.size() + datasetname.size()](); unsigned int placementIndex = 0; for (unsigned int i = 0; i < filename.size(); ++i) { sendPointer[placementIndex++] = filename[i]; } for (unsigned int i = 0; i < datasetname.size(); ++i) { sendPointer[placementIndex++] = datasetname[i]; } this->SendData(this->GetStartServerId(), sendPointer, filename.size() + datasetname.size(), XDMF_DSM_EXCHANGE_TAG, 0, XDMF_DSM_INTER_COMM); delete sendPointer; // Send Release Code this->SendAcknowledgment(this->GetStartServerId(), code, XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM); } int XdmfDSMBuffer::WaitOn(std::string filename, std::string datasetname) { // Send Command Header this->SendCommandHeader(XDMF_DSM_SET_NOTIFY, this->GetStartServerId(), 0, 0, XDMF_DSM_INTER_COMM); // Send string size this->SendAcknowledgment(this->GetStartServerId(), filename.size() + datasetname.size(), XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM); // Send string char * sendPointer = new char[filename.size() + datasetname.size()](); unsigned int placementIndex = 0; for (unsigned int i = 0; i < filename.size(); ++i) { sendPointer[placementIndex++] = filename[i]; } for (unsigned int i = 0; i < datasetname.size(); ++i) { sendPointer[placementIndex++] = datasetname[i]; } this->SendData(this->GetStartServerId(), sendPointer, filename.size() + datasetname.size(), XDMF_DSM_EXCHANGE_TAG, 0, XDMF_DSM_INTER_COMM); // Wait for Release int code = 0; this->ReceiveAcknowledgment(MPI_ANY_SOURCE, code, XDMF_DSM_EXCHANGE_TAG, this->CommChannel); delete sendPointer; // Return Code from Notification return code; } // C Wrappers XDMFDSMBUFFER * XdmfDSMBufferNew() { try { return (XDMFDSMBUFFER *)((void *)(new XdmfDSMBuffer())); } catch (...) { return (XDMFDSMBUFFER *)((void *)(new XdmfDSMBuffer())); } } void XdmfDSMBufferFree(XDMFDSMBUFFER * item) { if (item != NULL) { delete ((XdmfDSMBuffer *)item); } item = NULL; } void XdmfDSMBufferBroadcastComm(XDMFDSMBUFFER * buffer, int *comm, int root, int * status) { XDMF_ERROR_WRAP_START(status) ((XdmfDSMBuffer *)buffer)->BroadcastComm(comm, root); XDMF_ERROR_WRAP_END(status) } int XdmfDSMBufferBufferService(XDMFDSMBUFFER * buffer, int *returnOpcode, int * status) { XDMF_ERROR_WRAP_START(status) return ((XdmfDSMBuffer *)buffer)->BufferService(returnOpcode); XDMF_ERROR_WRAP_END(status) return -1; } void XdmfDSMBufferBufferServiceLoop(XDMFDSMBUFFER * buffer, int *returnOpcode, int * status) { XDMF_ERROR_WRAP_START(status) ((XdmfDSMBuffer *)buffer)->BufferServiceLoop(returnOpcode); XDMF_ERROR_WRAP_END(status) } void XdmfDSMBufferConfigureUniform(XDMFDSMBUFFER * buffer, XDMFDSMCOMMMPI * Comm, long Length, int StartId, int EndId, long aBlockLength, int random, int * status) { XDMF_ERROR_WRAP_START(status) ((XdmfDSMBuffer *)buffer)->ConfigureUniform((XdmfDSMCommMPI *)Comm, Length, StartId, EndId, aBlockLength, random); XDMF_ERROR_WRAP_END(status) } void XdmfDSMBufferConnect(XDMFDSMBUFFER * buffer, int persist, int * status) { XDMF_ERROR_WRAP_START(status) ((XdmfDSMBuffer *)buffer)->Connect(persist); XDMF_ERROR_WRAP_END(status) } void XdmfDSMBufferCreate(XDMFDSMBUFFER * buffer, MPI_Comm comm, int startId, int endId, int * status) { XDMF_ERROR_WRAP_START(status) ((XdmfDSMBuffer *)buffer)->Create(comm, startId, endId); XDMF_ERROR_WRAP_END(status) } void XdmfDSMBufferDisconnect(XDMFDSMBUFFER * buffer, int * status) { XDMF_ERROR_WRAP_START(status) ((XdmfDSMBuffer *)buffer)->Disconnect(); XDMF_ERROR_WRAP_END(status) } void XdmfDSMBufferGet(XDMFDSMBUFFER * buffer, long Address, long aLength, void * Data, int * status) { XDMF_ERROR_WRAP_START(status) ((XdmfDSMBuffer *)buffer)->Get(Address, aLength, Data); XDMF_ERROR_WRAP_END(status) } void XdmfDSMBufferGetAddressRangeForId(XDMFDSMBUFFER * buffer, int Id, int * Start, int * End, int * status) { XDMF_ERROR_WRAP_START(status) ((XdmfDSMBuffer *)buffer)->GetAddressRangeForId(Id, Start, End); XDMF_ERROR_WRAP_END(status) } long XdmfDSMBufferGetBlockLength(XDMFDSMBUFFER * buffer) { try { return ((XdmfDSMBuffer *)buffer)->GetBlockLength(); } catch (...) { return ((XdmfDSMBuffer *)buffer)->GetBlockLength(); } } XDMFDSMCOMMMPI * XdmfDSMBufferGetComm(XDMFDSMBUFFER * buffer) { try { return (XDMFDSMCOMMMPI *)((void *)(((XdmfDSMBuffer *)buffer)->GetComm())); } catch (...) { return (XDMFDSMCOMMMPI *)((void *)(((XdmfDSMBuffer *)buffer)->GetComm())); } } char * XdmfDSMBufferGetDataPointer(XDMFDSMBUFFER * buffer) { try { return ((XdmfDSMBuffer *)buffer)->GetDataPointer(); } catch (...) { return ((XdmfDSMBuffer *)buffer)->GetDataPointer(); } } int XdmfDSMBufferGetDsmType(XDMFDSMBUFFER * buffer) { try { return ((XdmfDSMBuffer *)buffer)->GetDsmType(); } catch (...) { return ((XdmfDSMBuffer *)buffer)->GetDsmType(); } } int XdmfDSMBufferGetEndAddress(XDMFDSMBUFFER * buffer) { try { return ((XdmfDSMBuffer *)buffer)->GetEndAddress(); } catch (...) { return ((XdmfDSMBuffer *)buffer)->GetEndAddress(); } } int XdmfDSMBufferGetEndServerId(XDMFDSMBUFFER * buffer) { try { return ((XdmfDSMBuffer *)buffer)->GetEndServerId(); } catch (...) { return ((XdmfDSMBuffer *)buffer)->GetEndServerId(); } } int XdmfDSMBufferGetInterCommType(XDMFDSMBUFFER * buffer) { try { return ((XdmfDSMBuffer *)buffer)->GetInterCommType(); } catch (...) { return ((XdmfDSMBuffer *)buffer)->GetInterCommType(); } } int XdmfDSMBufferGetIsConnected(XDMFDSMBUFFER * buffer) { try { return ((XdmfDSMBuffer *)buffer)->GetIsConnected(); } catch (...) { return ((XdmfDSMBuffer *)buffer)->GetIsConnected(); } } int XdmfDSMBufferGetIsServer(XDMFDSMBUFFER * buffer) { try { return ((XdmfDSMBuffer *)buffer)->GetIsServer(); } catch (...) { return ((XdmfDSMBuffer *)buffer)->GetIsServer(); } } long XdmfDSMBufferGetLength(XDMFDSMBUFFER * buffer) { try { return ((XdmfDSMBuffer *)buffer)->GetLength(); } catch (...) { return ((XdmfDSMBuffer *)buffer)->GetLength(); } } unsigned int XdmfDSMBufferGetLocalBufferSizeMBytes(XDMFDSMBUFFER * buffer) { try { return ((XdmfDSMBuffer *)buffer)->GetLocalBufferSizeMBytes(); } catch (...) { return ((XdmfDSMBuffer *)buffer)->GetLocalBufferSizeMBytes(); } } double XdmfDSMBufferGetResizeFactor(XDMFDSMBUFFER * buffer) { try { return ((XdmfDSMBuffer *)buffer)->GetResizeFactor(); } catch (...) { return ((XdmfDSMBuffer *)buffer)->GetResizeFactor(); } } int XdmfDSMBufferGetStartAddress(XDMFDSMBUFFER * buffer) { try { return ((XdmfDSMBuffer *)buffer)->GetStartAddress(); } catch (...) { return ((XdmfDSMBuffer *)buffer)->GetStartAddress(); } } int XdmfDSMBufferGetStartServerId(XDMFDSMBUFFER * buffer) { try { return ((XdmfDSMBuffer *)buffer)->GetStartServerId(); } catch (...) { return ((XdmfDSMBuffer *)buffer)->GetStartServerId(); } } long XdmfDSMBufferGetTotalLength(XDMFDSMBUFFER * buffer) { try { return ((XdmfDSMBuffer *)buffer)->GetTotalLength(); } catch (...) { return ((XdmfDSMBuffer *)buffer)->GetTotalLength(); } } void XdmfDSMBufferProbeCommandHeader(XDMFDSMBUFFER * buffer, int * comm, int * status) { XDMF_ERROR_WRAP_START(status) ((XdmfDSMBuffer *)buffer)->ProbeCommandHeader(comm); XDMF_ERROR_WRAP_END(status) } void XdmfDSMBufferPut(XDMFDSMBUFFER * buffer, long Address, long aLength, void * Data, int * status) { XDMF_ERROR_WRAP_START(status) ((XdmfDSMBuffer *)buffer)->Put(Address, aLength, Data); XDMF_ERROR_WRAP_END(status) } void XdmfDSMBufferReceiveAcknowledgment(XDMFDSMBUFFER * buffer, int source, int * data, int tag, int comm, int * status) { XDMF_ERROR_WRAP_START(status) ((XdmfDSMBuffer *)buffer)->ReceiveAcknowledgment(source, *data, tag, comm); XDMF_ERROR_WRAP_END(status) } void XdmfDSMBufferReceiveCommandHeader(XDMFDSMBUFFER * buffer, int * opcode, int * source, int * address, int * aLength, int comm, int remoteSource, int * status) { XDMF_ERROR_WRAP_START(status) ((XdmfDSMBuffer *)buffer)->ReceiveCommandHeader(opcode, source, address, aLength, comm, remoteSource); XDMF_ERROR_WRAP_END(status) } void XdmfDSMBufferReceiveData(XDMFDSMBUFFER * buffer, int source, char * data, int aLength, int tag, int aAddress, int comm, int * status) { XDMF_ERROR_WRAP_START(status) ((XdmfDSMBuffer *)buffer)->ReceiveData(source, data, aLength, tag, aAddress, comm); XDMF_ERROR_WRAP_END(status) } void XdmfDSMBufferReceiveInfo(XDMFDSMBUFFER * buffer, int * status) { XDMF_ERROR_WRAP_START(status) ((XdmfDSMBuffer *)buffer)->ReceiveInfo(); XDMF_ERROR_WRAP_END(status) } void XdmfDSMBufferSendAccept(XDMFDSMBUFFER * buffer, unsigned int numConnects) { ((XdmfDSMBuffer *)buffer)->SendAccept(numConnects); } void XdmfDSMBufferSendAcknowledgment(XDMFDSMBUFFER * buffer, int dest, int data, int tag, int comm, int * status) { XDMF_ERROR_WRAP_START(status) ((XdmfDSMBuffer *)buffer)->SendAcknowledgment(dest, data, tag, comm); XDMF_ERROR_WRAP_END(status) } void XdmfDSMBufferSendCommandHeader(XDMFDSMBUFFER * buffer, int opcode, int dest, int address, int aLength, int comm, int * status) { XDMF_ERROR_WRAP_START(status) ((XdmfDSMBuffer *)buffer)->SendCommandHeader(opcode, dest, address, aLength, comm); XDMF_ERROR_WRAP_END(status) } void XdmfDSMBufferSendData(XDMFDSMBUFFER * buffer, int dest, char * data, int aLength, int tag, int aAddress, int comm, int * status) { XDMF_ERROR_WRAP_START(status) ((XdmfDSMBuffer *)buffer)->SendData(dest, data, aLength, tag, aAddress, comm); XDMF_ERROR_WRAP_END(status) } void XdmfDSMBufferSendDone(XDMFDSMBUFFER * buffer, int * status) { XDMF_ERROR_WRAP_START(status) ((XdmfDSMBuffer *)buffer)->SendDone(); XDMF_ERROR_WRAP_END(status) } void XdmfDSMBufferSendInfo(XDMFDSMBUFFER * buffer, int * status) { XDMF_ERROR_WRAP_START(status) ((XdmfDSMBuffer *)buffer)->SendInfo(); XDMF_ERROR_WRAP_END(status) } void XdmfDSMBufferSetBlockLength(XDMFDSMBUFFER * buffer, long newBlock) { try { ((XdmfDSMBuffer *)buffer)->SetBlockLength(newBlock); } catch (...) { ((XdmfDSMBuffer *)buffer)->SetBlockLength(newBlock); } } void XdmfDSMBufferSetComm(XDMFDSMBUFFER * buffer, XDMFDSMCOMMMPI * newComm) { try { ((XdmfDSMBuffer *)buffer)->SetComm((XdmfDSMCommMPI *)newComm); } catch (...) { ((XdmfDSMBuffer *)buffer)->SetComm((XdmfDSMCommMPI *)newComm); } } void XdmfDSMBufferSetDsmType(XDMFDSMBUFFER * buffer, int newDsmType) { try { ((XdmfDSMBuffer *)buffer)->SetDsmType(newDsmType); } catch (...) { ((XdmfDSMBuffer *)buffer)->SetDsmType(newDsmType); } } void XdmfDSMBufferSetInterCommType(XDMFDSMBUFFER * buffer, int newType) { try { ((XdmfDSMBuffer *)buffer)->SetInterCommType(newType); } catch (...) { ((XdmfDSMBuffer *)buffer)->SetInterCommType(newType); } } void XdmfDSMBufferSetIsConnected(XDMFDSMBUFFER * buffer, int newStatus) { try { ((XdmfDSMBuffer *)buffer)->SetIsConnected(newStatus); } catch (...) { ((XdmfDSMBuffer *)buffer)->SetIsConnected(newStatus); } } void XdmfDSMBufferSetIsServer(XDMFDSMBUFFER * buffer, int newIsServer) { try { ((XdmfDSMBuffer *)buffer)->SetIsServer(newIsServer); } catch (...) { ((XdmfDSMBuffer *)buffer)->SetIsServer(newIsServer); } } void XdmfDSMBufferSetLocalBufferSizeMBytes(XDMFDSMBUFFER * buffer, unsigned int newSize) { try { ((XdmfDSMBuffer *)buffer)->SetLocalBufferSizeMBytes(newSize); } catch (...) { ((XdmfDSMBuffer *)buffer)->SetLocalBufferSizeMBytes(newSize); } } void XdmfDSMBufferSetResizeFactor(XDMFDSMBUFFER * buffer, double newFactor) { try { ((XdmfDSMBuffer *)buffer)->SetResizeFactor(newFactor); } catch (...) { ((XdmfDSMBuffer *)buffer)->SetResizeFactor(newFactor); } } void XdmfDSMBufferWaitRelease(XDMFDSMBUFFER * buffer, char * filename, char * datasetname, int code) { try { ((XdmfDSMBuffer *)buffer)->WaitRelease(std::string(filename), std::string(datasetname), code); } catch (...) { ((XdmfDSMBuffer *)buffer)->WaitRelease(std::string(filename), std::string(datasetname), code); } } int XdmfDSMBufferWaitOn(XDMFDSMBUFFER * buffer, char * filename, char * datasetname) { try { return ((XdmfDSMBuffer *)buffer)->WaitOn(std::string(filename), std::string(datasetname)); } catch (...) { return ((XdmfDSMBuffer *)buffer)->WaitOn(std::string(filename), std::string(datasetname)); } } xdmf-3.0+git20160803/core/dsm/XdmfHDF5ControllerDSM.hpp0000640000175000017500000007020013003006557022232 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfHDF5ControllerDSM.cpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef XDMFHDF5CONTROLLERDSM_HPP_ #define XDMFHDF5CONTROLLERDSM_HPP_ // C Compatible Includes #include "XdmfDSM.hpp" #include "XdmfDSMBuffer.hpp" #include "XdmfHDF5Controller.hpp" #ifdef __cplusplus // Forward Declarations // Includes #include "XdmfDSMDescription.hpp" /** * @brief Couples an XdmfArray with HDF5 data stored in a DSM buffer. * * Serves as an interface between data stored in XdmfArrays and data * stored in DSM buffers. When an Xdmf file is read from or written * to a DSM buffer an XdmfHDF5ControllerDSM is attached to XdmfArrays. * This allows data to be released from memory but still be accessible * or have its location written to light data. */ class XDMFDSM_EXPORT XdmfHDF5ControllerDSM : public XdmfHDF5Controller { public: virtual ~XdmfHDF5ControllerDSM(); /** * Create a new controller for an DSM data set. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#initcontrollerwithbuffer * @until //#initcontrollerwithbuffer * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//initcontrollerwithbuffer * @until #//initcontrollerwithbuffer * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @param hdf5FilePath The path to the hdf5 file that the controller will be accessing * @param dataSetPath The location within the file of the data the controller with be accessing * @param type The data type of the data Ex: XdmfArrayType::Int32() * @param start A vector of the start indexes for all dimensions of the data * @param stride A vector of the distance between reads for all dimensions of the data * @param dimensions A vector of the number of values read from all dimensions of the data * @param dataspaceDimensions A vecotr containing the total size of the dimension in the data space * @param dsmBuffer A pointer to the dsm buffer */ static shared_ptr New(const std::string & hdf5FilePath, const std::string & dataSetPath, const shared_ptr type, const std::vector & start, const std::vector & stride, const std::vector & dimensions, const std::vector & dataspaceDimensions, XdmfDSMBuffer * const dsmBuffer); /** * Create a new controller for an DSM data set. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initcontrollergenerate * @until //#initcontrollergenerate * @skipline //#stopDSMcontroller * @until //#stopDSMcontroller * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initcontrollergenerate * @until #//initcontrollergenerate * @skipline #//stopDSMcontroller * @until #//stopDSMcontroller * @skipline #//finalizeMPI * @until #//finalizeMPI * * @param hdf5FilePath The path to the hdf5 file that the controller will be accessing * @param dataSetPath The location within the file of the data the controller with be accessing * @param type The data type of the data Ex: XdmfArrayType::Int32() * @param start A vector of the start indexes for all dimensions of the data * @param start A vector of the start indexes for all dimensions of the data * @param stride A vector of the distance between reads for all dimensions of the data * @param dimensions A vector of the number of values read from all dimensions of the data * @param dataspaceDimensions A vecotr containing the total size of the dimension in the data space * @param comm The communicator that the DSM buffer will reference * @param bufferSize The size of the buffer to be created on the core calling this function * @param startCoreIndex The index at which the server cores for the buffer start * @param endCoreIndex The index at which the server cores for the buffer end * @param applicationName The name in the process description for this process * @return A constructed HDF5DSM controller. */ static shared_ptr New(const std::string & hdf5FilePath, const std::string & dataSetPath, const shared_ptr type, const std::vector & start, const std::vector & stride, const std::vector & dimensions, const std::vector & dataspaceDimensions, MPI_Comm comm, unsigned int bufferSize, int startCoreIndex, int endCoreIndex, std::string applicationName = "Application"); /** * Create a new controller for an DSM data set. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initcontrollerpagedgenerate * @until //#initcontrollerpagedgenerate * @skipline //#stopDSMcontroller * @until //#stopDSMcontroller * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initcontrollerpagedgenerate * @until #//initcontrollerpagedgenerate * @skipline #//stopDSMcontroller * @until #//stopDSMcontroller * @skipline #//finalizeMPI * @until #//finalizeMPI * * @param hdf5FilePath The path to the hdf5 file that the controller will be accessing * @param dataSetPath The location within the file of the data the controller with be accessing * @param type The data type of the data Ex: XdmfArrayType::Int32() * @param start A vector of the start indexes for all dimensions of the data * @param start A vector of the start indexes for all dimensions of the data * @param stride A vector of the distance between reads for all dimensions of the data * @param dimensions A vector of the number of values read from all dimensions of the data * @param dataspaceDimensions A vecotr containing the total size of the dimension in the data space * @param comm The communicator that the DSM buffer will reference * @param bufferSize The size of the buffer to be created on the core calling this function * @param blockSize The size of the paged in the buffer * @param resizeFactor The factor by which the buffer will be resized when pages are added. * @param startCoreIndex The index at which the server cores for the buffer start * @param endCoreIndex The index at which the server cores for the buffer end * @param applicationName The name in the process description for this process * @return A constructed HDF5DSM controller. */ static shared_ptr New(const std::string & hdf5FilePath, const std::string & dataSetPath, const shared_ptr type, const std::vector & start, const std::vector & stride, const std::vector & dimensions, const std::vector & dataspaceDimensions, MPI_Comm comm, unsigned int bufferSize, unsigned int blockSize, double resizeFactor, int startCoreIndex, int endCoreIndex, std::string applicationName = "Application"); /** * Gets the buffer for the non-threaded version of DSM * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initcontrollergenerate * @until //#initcontrollergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBuffercontroller * @until //#getServerBuffercontroller * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMcontroller * @until //#stopDSMcontroller * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initcontrollergenerate * @until #//initcontrollergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerBuffercontroller * @until #//getServerBuffercontroller * @skipline #//stopDSMcontroller * @until #//stopDSMcontroller * @skipline #//finalizeMPI * @until #//finalizeMPI * * @return The XdmfDSMBuffer that is controlling the data for the DSM */ XdmfDSMBuffer * getServerBuffer(); /** * Checks if the DSM is in server mode or not. * True is server mode, false is threaded * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initcontrollergenerate * @until //#initcontrollergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#getServerModecontroller * @until //#getServerModecontroller * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMcontroller * @until //#stopDSMcontroller * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initcontrollergenerate * @until #//initcontrollergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerModecontroller * @until #//getServerModecontroller * @skipline #//stopDSMcontroller * @until #//stopDSMcontroller * @skipline #//finalizeMPI * @until #//finalizeMPI * * @return If the DSM is in server mode or not */ bool getServerMode() const; std::string getName() const; /** * Gets the Communicator that the workers are using to communicate between themselves * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initcontrollergenerate * @until //#initcontrollergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#getWorkerCommcontroller * @until //#getWorkerCommcontroller * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMcontroller * @until //#stopDSMcontroller * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initcontrollergenerate * @until #//initcontrollergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getWorkerCommcontroller * @until #//getWorkerCommcontroller * @skipline #//stopDSMcontroller * @until #//stopDSMcontroller * @skipline #//finalizeMPI * @until #//finalizeMPI * * @return The comm that the workers are using. */ MPI_Comm getWorkerComm() const; /** * Sets the controller's dsmBuffer to the provided buffer * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initcontrollergenerate * @until //#initcontrollergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBuffercontroller * @until //#getServerBuffercontroller * @skipline //#setBuffercontroller * @until //#setBuffercontroller * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMcontroller * @until //#stopDSMcontroller * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initcontrollergenerate * @until #//initcontrollergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerBuffercontroller * @until #//getServerBuffercontroller * @skipline #//setBuffercontroller * @until #//setBuffercontroller * @skipline #//stopDSMcontroller * @until #//stopDSMcontroller * @skipline #//finalizeMPI * @until #//finalizeMPI * * @param newBuffer A pointer to the buffer to be set */ void setBuffer(XdmfDSMBuffer * newBuffer); /** * Used to switch between server and threaded mode. * True is server mode, false is threaded mode. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initcontrollergenerate * @until //#initcontrollergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#setServerModecontroller * @until //#setServerModecontroller * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMcontroller * @until //#stopDSMcontroller * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initcontrollergenerate * @until #//initcontrollergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//setServerModecontroller * @until #//setServerModecontroller * @skipline #//stopDSMcontroller * @until #//stopDSMcontroller * @skipline #//finalizeMPI * @until #//finalizeMPI * * @param newMode The mode that the writer is to be set to. */ void setServerMode(bool newMode); /** * Sets the comm that the workers will use to communicate * with other worker cores * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initcontrollergenerate * @until //#initcontrollergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#getWorkerCommcontroller * @until //#getWorkerCommcontroller * @skipline //#setWorkerCommcontroller * @until //#setWorkerCommcontroller * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMcontroller * @until //#stopDSMcontroller * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initcontrollergenerate * @until #//initcontrollergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getWorkerCommcontroller * @until #//getWorkerCommcontroller * @skipline #//setWorkerCommcontroller * @until #//setWorkerCommcontroller * @skipline #//stopDSMcontroller * @until #//stopDSMcontroller * @skipline #//finalizeMPI * @until #//finalizeMPI * * @param comm The communicator that the worker will be using to * communicate with the other worker cores. */ void setWorkerComm(MPI_Comm comm); /** * Sends a stop command to all the server cores that the controller is * connected to, ending the DSM. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initcontrollergenerate * @until //#initcontrollergenerate * @skipline //#stopDSMcontroller * @until //#stopDSMcontroller * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until //initwritevector * @skipline #//initcontrollergenerate * @until #//initcontrollergenerate * @skipline #//stopDSMcontroller * @until #//stopDSMcontroller * @skipline #//finalizeMPI * @until #//finalizeMPI */ void stopDSM(); void read(XdmfArray * const array); /** * Restarts the DSM when called on server cores. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initcontrollergenerate * @until //#initcontrollergenerate * @skipline //#stopDSMcontroller * @until //#stopDSMcontroller * @skipline //#restartDSMcontroller * @until //#restartDSMcontroller * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initcontrollergenerate * @until #//initcontrollergenerate * @skipline #//stopDSMcontroller * @until #//stopDSMcontroller * @skipline #//restartDSMcontroller * @until #//restartDSMcontroller * @skipline #//finalizeMPI * @until #//finalizeMPI */ void restartDSM(); XdmfHDF5ControllerDSM(XdmfHDF5ControllerDSM &); protected: XdmfHDF5ControllerDSM(const std::string & hdf5FilePath, const std::string & dataSetPath, const shared_ptr type, const std::vector & start, const std::vector & stride, const std::vector & dimensions, const std::vector & dataspaceDimensions, MPI_Comm comm, unsigned int bufferSize, int startCoreIndex, int endCoreIndex, std::string applicationName); XdmfHDF5ControllerDSM(const std::string & hdf5FilePath, const std::string & dataSetPath, const shared_ptr type, const std::vector & start, const std::vector & stride, const std::vector & dimensions, const std::vector & dataspaceDimensions, MPI_Comm comm, unsigned int bufferSize, unsigned int blockSize, double resizeFactor, int startCoreIndex, int endCoreIndex, std::string applicationName); XdmfHDF5ControllerDSM(const std::string & hdf5FilePath, const std::string & dataSetPath, const shared_ptr type, const std::vector & start, const std::vector & stride, const std::vector & dimensions, const std::vector & dataspaceDimensions, XdmfDSMBuffer * const dsmBuffer); private: // XdmfHDF5ControllerDSM(const XdmfHDF5Controller &); // Not implemented. void operator=(const XdmfHDF5Controller &); // Not implemented. XdmfDSMBuffer * mDSMServerBuffer; MPI_Comm mWorkerComm; bool mServerMode; }; #endif #ifdef __cplusplus extern "C" { #endif // C wrappers go here struct XDMFHDF5CONTROLLERDSM; // Simply as a typedef to ensure correct typing typedef struct XDMFHDF5CONTROLLERDSM XDMFHDF5CONTROLLERDSM; XDMFDSM_EXPORT XDMFHDF5CONTROLLERDSM * XdmfHDF5ControllerDSMNewFromServerBuffer(char * hdf5FilePath, char * dataSetPath, int type, unsigned int * start, unsigned int * stride, unsigned int * dimensions, unsigned int * dataspaceDimensions, unsigned int numDims, void * dsmBuffer, int * status); XDMFDSM_EXPORT XDMFHDF5CONTROLLERDSM * XdmfHDF5ControllerDSMNew(char * hdf5FilePath, char * dataSetPath, int type, unsigned int * start, unsigned int * stride, unsigned int * dimensions, unsigned int * dataspaceDimensions, unsigned int numDims, MPI_Comm comm, unsigned int bufferSize, int startCoreIndex, int endCoreIndex, char * applicationName, int * status); XDMFDSM_EXPORT XDMFHDF5CONTROLLERDSM * XdmfHDF5ControllerDSMNewPaged(char * hdf5FilePath, char * dataSetPath, int type, unsigned int * start, unsigned int * stride, unsigned int * dimensions, unsigned int * dataspaceDimensions, unsigned int numDims, MPI_Comm comm, unsigned int bufferSize, unsigned int blockSize, double resizeFactor, int startCoreIndex, int endCoreIndex, char * applicationName, int * status); XDMFDSM_EXPORT XDMFDSMBUFFER * XdmfHDF5ControllerDSMGetServerBuffer(XDMFHDF5CONTROLLERDSM * controller); XDMFDSM_EXPORT int XdmfHDF5ControllerDSMGetServerMode(XDMFHDF5CONTROLLERDSM * controller); XDMFDSM_EXPORT MPI_Comm XdmfHDF5ControllerDSMGetWorkerComm(XDMFHDF5CONTROLLERDSM * controller); XDMFDSM_EXPORT void XdmfHDF5ControllerDSMSetServerBuffer(XDMFHDF5CONTROLLERDSM * controller, XDMFDSMBUFFER * newBuffer); XDMFDSM_EXPORT void XdmfHDF5ControllerDSMSetServerMode(XDMFHDF5CONTROLLERDSM * controller, int newMode); XDMFDSM_EXPORT void XdmfHDF5ControllerDSMSetWorkerComm(XDMFHDF5CONTROLLERDSM * controller, MPI_Comm comm, int * status); XDMFDSM_EXPORT void XdmfHDF5ControllerDSMStopDSM(XDMFHDF5CONTROLLERDSM * controller, int * status); XDMFDSM_EXPORT void XdmfHDF5ControllerDSMRestartDSM(XDMFHDF5CONTROLLERDSM * controller, int * status); XDMF_HEAVYCONTROLLER_C_CHILD_DECLARE(XdmfHDF5ControllerDSM, XDMFHDF5CONTROLLERDSM, XDMFDSM) XDMF_HDF5CONTROLLER_C_CHILD_DECLARE(XdmfHDF5ControllerDSM, XDMFHDF5CONTROLLERDSM, XDMFDSM) #ifdef __cplusplus } #endif #endif /* XDMFHDF5CONTROLLER_HPP_ */ xdmf-3.0+git20160803/core/dsm/XdmfDSMItemFactory.hpp0000640000175000017500000000755013003006557021736 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfDSMItemFactory.hpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef XDMFDSMITEMFACTORY_HPP_ #define XDMFDSMITEMFACTORY_HPP_ // C Compatible Includes #include "Xdmf.hpp" #include "XdmfCoreItemFactory.hpp" #include "XdmfDSMBuffer.hpp" #ifdef __cplusplus // Forward Declarations class XdmfItem; // Includes /** * @brief Factory for constructing XdmfItems from their ItemTag and * ItemProperties. */ class XDMFDSM_EXPORT XdmfDSMItemFactory : public XdmfCoreItemFactory { public: /** * Create a new XdmfItemFactory. * * Example of use: * * C++ * * @dontinclude ExampleXdmfItemFactory.cpp * @skipline //#initialization * @until //#initialization * * Python * * @dontinclude XdmfExampleItemFactory.py * @skipline #//initialization * @until #//initialization * * @return Constructed XdmfItemFactory. */ static shared_ptr New(); virtual ~XdmfDSMItemFactory(); virtual shared_ptr createItem(const std::string & itemTag, const std::map & itemProperties, const std::vector > & childItems) const; virtual std::vector > generateHeavyDataControllers(const std::map & itemProperties, const std::vector & passedDimensions, shared_ptr passedArrayType, const std::string & passedFormat) const; virtual shared_ptr generateHeavyDataWriter(std::string typeName, std::string path) const; XdmfDSMBuffer * getDSMBuffer(); virtual bool isArrayTag(char * tag) const; void setDSMBuffer(XdmfDSMBuffer * newBuffer); virtual XdmfItem * DuplicatePointer(shared_ptr original) const; protected: XdmfDSMItemFactory(); private: XdmfDSMItemFactory(const XdmfDSMItemFactory &); // Not implemented. void operator=(const XdmfDSMItemFactory &); // Not implemented. XdmfDSMBuffer * mDSMBuffer; }; #ifdef _WIN32 XDMF_TEMPLATE template class XDMF_EXPORT shared_ptr; #endif #endif #endif /* XDMFDSMITEMFACTORY_HPP_ */ xdmf-3.0+git20160803/core/dsm/XdmfDSM.i0000640000175000017500000004502513003006557017227 0ustar alastairalastair/* XdmfDSMPython.cpp: swig -v -c++ -python -o XdmfDSMPython.cpp XdmfDSM.i */ %module XdmfDSM %{ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include %} %import XdmfCore.i // Ignore C Wrappers // XdmfHDF5ControllerDSM %ignore XdmfHDF5ControllerDSMNewFromServerBuffer(char * hdf5FilePath, char * dataSetPath, int type, unsigned int * start, unsigned int * stride, unsigned int * dimensions, unsigned int * dataspaceDimensions, unsigned int numDims, void * dsmBuffer, int * status); %ignore XdmfHDF5ControllerDSMNew(char * hdf5FilePath, char * dataSetPath, int type, unsigned int * start, unsigned int * stride, unsigned int * dimensions, unsigned int * dataspaceDimensions, unsigned int numDims, MPI_Comm comm, unsigned int bufferSize, int startCoreIndex, int endCoreIndex, char * applicationName, int * status); %ignore XdmfHDF5ControllerDSMNewPaged(char * hdf5FilePath, char * dataSetPath, int type, unsigned int * start, unsigned int * stride, unsigned int * dimensions, unsigned int * dataspaceDimensions, unsigned int numDims, MPI_Comm comm, unsigned int bufferSize, unsigned int blockSize, int startCoreIndex, int endCoreIndex, char * applicationName, int * status); %ignore XdmfHDF5ControllerDSMGetServerBuffer(XDMFHDF5CONTROLLERDSM * controller); %ignore XdmfHDF5ControllerDSMGetServerMode(XDMFHDF5CONTROLLERDSM * controller); %ignore XdmfHDF5ControllerDSMGetWorkerComm(XDMFHDF5CONTROLLERDSM * controller); %ignore XdmfHDF5ControllerDSMSetServerBuffer(XDMFHDF5CONTROLLERDSM * controller, XDMFDSMBUFFER * newBuffer); %ignore XdmfHDF5ControllerDSMSetServerMode(XDMFHDF5CONTROLLERDSM * controller, int newMode); %ignore XdmfHDF5ControllerDSMSetWorkerComm(XDMFHDF5CONTROLLERDSM * controller, MPI_Comm comm, int * status); %ignore XdmfHDF5ControllerDSMStopDSM(XDMFHDF5CONTROLLERDSM * controller, int * status); %ignore XdmfHDF5ControllerDSMRestartDSM(XDMFHDF5CONTROLLERDSM * controller, int * status); // XdmfHDF5ControlerDSM inherited from XdmfHDF5Controler %ignore XdmfHDF5ControlerDSMGetDataSetPath(XDMFHDF5CONTROLLERDSM * controller); // XdmfHDF5ControlerDSM inherited from XdmfHeavyDataController %ignore XdmfHDF5ControlerDSMFree(XDMFHDF5CONTROLLERDSM * item); %ignore XdmfHDF5ControlerDSMGetDataspaceDimensions(XDMFHDF5CONTROLLERDSM * controller); %ignore XdmfHDF5ControlerDSMGetDimensions(XDMFHDF5CONTROLLERDSM * controller); %ignore XdmfHDF5ControlerDSMGetFilePath(XDMFHDF5CONTROLLERDSM * controller); %ignore XdmfHDF5ControlerDSMGetName(XDMFHDF5CONTROLLERDSM * controller); %ignore XdmfHDF5ControlerDSMGetNumberDimensions(XDMFHDF5CONTROLLERDSM * controller); %ignore XdmfHDF5ControlerDSMGetSize(XDMFHDF5CONTROLLERDSM * controller); %ignore XdmfHDF5ControlerDSMGetStart(XDMFHDF5CONTROLLERDSM * controller); %ignore XdmfHDF5ControlerDSMGetStride(XDMFHDF5CONTROLLERDSM * controller); %ignore XdmfHDF5ControlerDSMSetArrayOffset(XDMFHDF5CONTROLLERDSM * controller, unsigned int newOffset); %ignore XdmfHDF5ControlerDSMGetArrayOffset(XDMFHDF5CONTROLLERDSM * controller); %ignore XdmfHDF5ControlerDSMGetType(XDMFHDF5CONTROLLERDSM * controller, int * status); %ignore XdmfHDF5ControlerDSMRead(XDMFHDF5CONTROLLERDSM * controller, void * array, int * status); // XdmfHDF5WriterDSM %ignore XdmfHDF5WriterDSMNewFromServerBuffer(char * filePath, void * dsmBuffer, int * status); %ignore XdmfHDF5WriterDSMNew(char * filePath, MPI_Comm comm, unsigned int bufferSize, int startCoreIndex, int endCoreIndex, int * status); %ignore XdmfHDF5WriterDSMNewPaged(char * filePath, MPI_Comm comm, unsigned int bufferSize, unsigned int blockSize, int startCoreIndex, int endCoreIndex, int * status); %ignore XdmfHDF5WriterDSMNewConnectRequired(char * filePath, MPI_Comm comm, char * applicationName, int * status); %ignore XdmfHDF5WriterDSMGetDataSetSize(XDMFHDF5WRITERDSM * writer, char * fileName, char * dataSetName); %ignore XdmfHDF5WriterDSMGetServerBuffer(XDMFHDF5WRITERDSM * writer); %ignore XdmfHDF5WriterDSMGetServerMode(XDMFHDF5WRITERDSM * writer); %ignore XdmfHDF5WriterDSMGetWorkerComm(XDMFHDF5WRITERDSM * writer); %ignore XdmfHDF5WriterDSMSetServerBuffer(XDMFHDF5WRITERDSM * writer, XDMFDSMBUFFER * newBuffer); %ignore XdmfHDF5WriterDSMSetServerMode(XDMFHDF5WRITERDSM * writer, int newMode); %ignore XdmfHDF5WriterDSMSetWorkerComm(XDMFHDF5WRITERDSM * writer, MPI_Comm comm, int * status); %ignore XdmfHDF5WriterDSMStopDSM(XDMFHDF5WRITERDSM * writer, int * status); %ignore XdmfHDF5WriterDSMRestartDSM(XDMFHDF5WRITERDSM * writer, int * status); %ignore XdmfHDF5WriterDSMWaitRelease(XDMFHDF5WRITERDSM * writer, char * fileName, char * datasetName, int code); %ignore XdmfHDF5WriterDSMWaitOn(XDMFHDF5WRITERDSM * writer, char * fileName, char * datasetName); // XdmfHDF5WriterDSM inherited from XdmfHDF5Writer %ignore XdmfHDF5WriterCloseFile(XDMFHDF5WRITER * writer, int * status); %ignore XdmfHDF5WriterGetChunkSize(XDMFHDF5WRITER * writer, int * status); %ignore XdmfHDF5WriterOpenFile(XDMFHDF5WRITER * writer, int * status); %ignore XdmfHDF5WriterSetChunkSize(XDMFHDF5WRITER * writer, unsigned int chunkSize, int * status); // XdmfHDF5WriterDSM inherited from XdmfHeavyDataWriter %ignore XdmfHDF5WriterDSMFree(XDMFHDF5WRITERDSM * item); %ignore XdmfHDF5WriterDSMGetAllowSetSplitting(XDMFHDF5WRITERDSM * writer); %ignore XdmfHDF5WriterDSMGetFileIndex(XDMFHDF5WRITERDSM * writer); %ignore XdmfHDF5WriterDSMGetFileOverhead(XDMFHDF5WRITERDSM * writer); %ignore XdmfHDF5WriterDSMGetFilePath(XDMFHDF5WRITERDSM * writer); %ignore XdmfHDF5WriterDSMGetFileSizeLimit(XDMFHDF5WRITERDSM * writer); %ignore XdmfHDF5WriterDSMGetMode(XDMFHDF5WRITERDSM * writer); %ignore XdmfHDF5WriterDSMGetReleaseData(XDMFHDF5WRITERDSM * writer); %ignore XdmfHDF5WriterDSMSetAllowSetSplitting(XDMFHDF5WRITERDSM * writer, int newAllow); %ignore XdmfHDF5WriterDSMSetFileIndex(XDMFHDF5WRITERDSM * writer, int newIndex); %ignore XdmfHDF5WriterDSMSetFileSizeLimit(XDMFHDF5WRITERDSM * writer, int newSize); %ignore XdmfHDF5WriterDSMSetMode(XDMFHDF5WRITERDSM * writer, int mode, int * status); %ignore XdmfHDF5WriterDSMSetReleaseData(XDMFHDF5WRITERDSM * writer, int releaseData); // XdmfDSMCommMPI %ignore XdmfDSMCommMPINew(); %ignore XdmfDSMCommMPIFree(XDMFDSMCOMMMPI * item); %ignore XdmfDSMCommMPIAccept(XDMFDSMCOMMMPI * dsmComm, unsigned int numConnections, int * status); %ignore XdmfDSMCommMPIClosePort(XDMFDSMCOMMMPI * dsmComm, int * status); %ignore XdmfDSMCommMPIConnect(XDMFDSMCOMMMPI * dsmComm, int * status); %ignore XdmfDSMCommMPIDisconnect(XDMFDSMCOMMMPI * dsmComm, int * status); %ignore XdmfDSMCommMPIDupComm(XDMFDSMCOMMMPI * dsmComm, MPI_Comm comm, int * status); %ignore XdmfDSMCommMPIDupInterComm(XDMFDSMCOMMMPI * dsmComm, MPI_Comm comm, int * status); %ignore XdmfDSMCommMPIGetApplicationName(XDMFDSMCOMMMPI * dsmComm); %ignore XdmfDSMCommMPIGetDsmFileName(XDMFDSMCOMMMPI * dsmComm); %ignore XdmfDSMCommMPIGetDsmPortName(XDMFDSMCOMMMPI * dsmComm); %ignore XdmfDSMCommMPIGetDsmProcessStructure(XDMFDSMCOMMMPI * dsmComm, char ** names, unsigned int * coreCount, int * numApplications); %ignore XdmfDSMCommMPIGetId(XDMFDSMCOMMMPI * dsmComm); %ignore XdmfDSMCommMPIGetInterComm(XDMFDSMCOMMMPI * dsmComm); %ignore XdmfDSMCommMPIGetInterCommType(XDMFDSMCOMMMPI * dsmComm); %ignore XdmfDSMCommMPIGetInterId(XDMFDSMCOMMMPI * dsmComm); %ignore XdmfDSMCommMPIGetInterSize(XDMFDSMCOMMMPI * dsmComm); %ignore XdmfDSMCommMPIGetIntraComm(XDMFDSMCOMMMPI * dsmComm); %ignore XdmfDSMCommMPIGetIntraSize(XDMFDSMCOMMMPI * dsmComm); %ignore XdmfDSMCommMPIGetUseEnvFileName(XDMFDSMCOMMMPI * dsmComm); %ignore XdmfDSMCommMPIInit(XDMFDSMCOMMMPI * dsmComm, int * status); %ignore XdmfDSMCommMPIOpenPort(XDMFDSMCOMMMPI * dsmComm, int * status); %ignore XdmfDSMCommMPIReadDsmPortName(XDMFDSMCOMMMPI * dsmComm); %ignore XdmfDSMCommMPISetApplicationName(XDMFDSMCOMMMPI * dsmComm, char * newName); %ignore XdmfDSMCommMPISetDsmFileName(XDMFDSMCOMMMPI * dsmComm, char * filename); %ignore XdmfDSMCommMPISetDsmPortName(XDMFDSMCOMMMPI * dsmComm, char * hostName); %ignore XdmfDSMCommMPISetUseEnvFileName(XDMFDSMCOMMMPI * dsmComm, int status); // XdmfDSMBuffer %ignore XdmfDSMBufferNew(); %ignore XdmfDSMBufferFree(XDMFDSMBUFFER * item); %ignore XdmfDSMBufferAddressToId(XDMFDSMBUFFER * buffer, int Address, int * status); %ignore XdmfDSMBufferBroadcastComm(XDMFDSMBUFFER * buffer, int *comm, int root, int * status); %ignore XdmfDSMBufferBufferService(XDMFDSMBUFFER * buffer, int *returnOpcode, int * status); %ignore XdmfDSMBufferBufferServiceLoop(XDMFDSMBUFFER * buffer, int *returnOpcode, int * status); %ignore XdmfDSMBufferConfigureUniform(XDMFDSMBUFFER * buffer, XDMFDSMCOMMMPI * Comm, long Length, int StartId, int EndId, long aBlockLength, int random, int * status); %ignore XdmfDSMBufferConnect(XDMFDSMBUFFER * buffer, int persist, int * status); %ignore XdmfDSMBufferCreate(XDMFDSMBUFFER * buffer, int comm, int startId, int endId, int * status); %ignore XdmfDSMBufferDisconnect(XDMFDSMBUFFER * buffer, int * status); %ignore XdmfDSMBufferGet(XDMFDSMBUFFER * buffer, long Address, long aLength, void * Data, int * status); %ignore XdmfDSMBufferGetAddressRangeForId(XDMFDSMBUFFER * buffer, int Id, int * Start, int * End, int * status); %ignore XdmfDSMBufferGetBlockLength(XDMFDSMBUFFER * buffer); %ignore XdmfDSMBufferGetComm(XDMFDSMBUFFER * buffer); %ignore XdmfDSMBufferGetDataPointer(XDMFDSMBUFFER * buffer); %ignore XdmfDSMBufferGetDsmType(XDMFDSMBUFFER * buffer); %ignore XdmfDSMBufferGetEndAddress(XDMFDSMBUFFER * buffer); %ignore XdmfDSMBufferGetEndServerId(XDMFDSMBUFFER * buffer); %ignore XdmfDSMBufferGetInterCommType(XDMFDSMBUFFER * buffer); %ignore XdmfDSMBufferGetIsConnected(XDMFDSMBUFFER * buffer); %ignore XdmfDSMBufferGetIsServer(XDMFDSMBUFFER * buffer); %ignore XdmfDSMBufferGetLength(XDMFDSMBUFFER * buffer); %ignore XdmfDSMBufferGetLocalBufferSizeMBytes(XDMFDSMBUFFER * buffer); %ignore XdmfDSMBufferGetResizeFactor(XDMFDSMBUFFER * buffer); %ignore XdmfDSMBufferGetStartAddress(XDMFDSMBUFFER * buffer); %ignore XdmfDSMBufferGetStartServerId(XDMFDSMBUFFER * buffer); %ignore XdmfDSMBufferGetTotalLength(XDMFDSMBUFFER * buffer); %ignore XdmfDSMBufferProbeCommandHeader(XDMFDSMBUFFER * buffer, int * comm, int * status); %ignore XdmfDSMBufferPut(XDMFDSMBUFFER * buffer, long Address, long aLength, void * Data, int * status); %ignore XdmfDSMBufferReceiveAcknowledgment(XDMFDSMBUFFER * buffer, int source, int * data, int tag, int comm, int * status); %ignore XdmfDSMBufferReceiveCommandHeader(XDMFDSMBUFFER * buffer, int * opcode, int * source, int * address, int * aLength, int comm, int remoteSource, int * status); %ignore XdmfDSMBufferReceiveData(XDMFDSMBUFFER * buffer, int source, char * data, int aLength, int tag, int aAddress, int comm, int * status); %ignore XdmfDSMBufferReceiveInfo(XDMFDSMBUFFER * buffer, int * status); %ignore XdmfDSMBufferSendAccept(XDMFDSMBUFFER * buffer, unsigned int numConnects); %ignore XdmfDSMBufferSendAcknowledgment(XDMFDSMBUFFER * buffer, int dest, int data, int tag, int comm, int * status); %ignore XdmfDSMBufferSendCommandHeader(XDMFDSMBUFFER * buffer, int opcode, int dest, int address, int aLength, int comm, int * status); %ignore XdmfDSMBufferSendData(XDMFDSMBUFFER * buffer, int dest, char * data, int aLength, int tag, int aAddress, int comm, int * status); %ignore XdmfDSMBufferSendDone(XDMFDSMBUFFER * buffer, int * status); %ignore XdmfDSMBufferSendInfo(XDMFDSMBUFFER * buffer, int * status); %ignore XdmfDSMBufferSetBlockLength(XDMFDSMBUFFER * buffer, long newBlock); %ignore XdmfDSMBufferSetComm(XDMFDSMBUFFER * buffer, XDMFDSMCOMMMPI * newComm); %ignore XdmfDSMBufferSetDsmType(XDMFDSMBUFFER * buffer, int newDsmType); %ignore XdmfDSMBufferSetInterCommType(XDMFDSMBUFFER * buffer, int newType); %ignore XdmfDSMBufferSetIsConnected(XDMFDSMBUFFER * buffer, int newStatus); %ignore XdmfDSMBufferSetIsServer(XDMFDSMBUFFER * buffer, int newIsServer); %ignore XdmfDSMBufferSetLocalBufferSizeMBytes(XDMFDSMBUFFER * buffer, unsigned int newSize); %ignore XdmfDSMBufferSetResizeFactor(XDMFDSMBUFFER * buffer, double newFactor); %ignore XdmfDSMBufferWaitRelease(XDMFDSMBUFFER * buffer, char * filename, char * datasetname, int code); %ignore XdmfDSMBufferWaitOn(XDMFDSMBUFFER * buffer, char * filename, char * datasetname); #ifdef SWIGJAVA %pragma(java) jniclasscode=%{ static { try { System.loadLibrary("XdmfDSMJava"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load for" + "XdmfDSMJava\n" + e); System.exit(1); } } %} #endif /* SWIGJAVA */ #ifdef SWIGPYTHON %pythoncode { from XdmfCore import * } %include mpi4py/mpi4py.i %mpi4py_typemap(Comm, MPI_Comm); %include %apply int & INOUT {int & data }; %extend XdmfDSMBuffer { bool __eq__(const XdmfDSMBuffer * item) { return $self == item; } }; %extend XdmfDSMCommMPI { bool __eq__(const XdmfDSMCommMPI * item) { return $self == item; } }; %extend XdmfHeavyDataController { static shared_ptr XdmfHDF5ControllerDSMCast(PyObject * obj) { void * resultPointer = 0; swig_type_info * returnType = SWIG_TypeQuery("_p_boost__shared_ptrT_XdmfHeavyDataController_t"); SWIG_ConvertPtr(obj, &resultPointer, returnType, 0); shared_ptr * returnControllerPointer = reinterpret_cast *>(resultPointer); shared_ptr returnController = returnControllerPointer[0]; if (shared_ptr returnHDF5Controller = shared_dynamic_cast(returnController)) { return returnHDF5Controller; } else { XdmfError::message(XdmfError::FATAL, "Error: Attempting to cast a non HDF5 Controller to HDF5"); return shared_ptr(); } } }; #endif /* SWIGPYTHON */ // Shared Pointer Templates %shared_ptr(XdmfHDF5ControllerDSM) %shared_ptr(XdmfHDF5WriterDSM) %shared_ptr(XdmfDSMItemFactory) %include XdmfDSM.hpp %include XdmfHDF5ControllerDSM.hpp %include XdmfHDF5WriterDSM.hpp %include XdmfDSMBuffer.hpp %include XdmfDSMCommMPI.hpp %include XdmfDSMItemFactory.hpp xdmf-3.0+git20160803/core/dsm/XdmfDSMItemFactory.cpp0000640000175000017500000003212113003006557021721 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfDSMItemFactory.cpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #include #include #include "XdmfInformation.hpp" #include "XdmfDSMDescription.hpp" #include "XdmfDSMDriver.hpp" #include "XdmfDSMBuffer.hpp" #include "XdmfDSMCommMPI.hpp" #include "XdmfDSMItemFactory.hpp" #include "XdmfHDF5ControllerDSM.hpp" #include "XdmfHDF5WriterDSM.hpp" #include "XdmfError.hpp" #include "stdio.h" shared_ptr XdmfDSMItemFactory::New() { shared_ptr p(new XdmfDSMItemFactory()); return p; } XdmfDSMItemFactory::XdmfDSMItemFactory() { if (xdmf_dsm_get_manager()) { XdmfDSMItemFactory::mDSMBuffer = (XdmfDSMBuffer *)xdmf_dsm_get_manager(); } else { // If Null create a new one, or throw error? XdmfDSMItemFactory::mDSMBuffer = new XdmfDSMBuffer(); XdmfDSMItemFactory::mDSMBuffer->SetComm(new XdmfDSMCommMPI()); } } XdmfDSMItemFactory::~XdmfDSMItemFactory() { } shared_ptr XdmfDSMItemFactory::createItem(const std::string & itemTag, const std::map & itemProperties, const std::vector > & childItems) const { shared_ptr newItem = XdmfCoreItemFactory::createItem(itemTag, itemProperties, childItems); if(newItem) { return newItem; } if(itemTag.compare(XdmfDSMDescription::ItemTag) == 0) { // Connect DSM Buffer to DSM Description. // void SetDsmPortName(const char *hostName); // XdmfDSMItemFactory::mDSMBuffer = new XdmfDSMBuffer(); const char * dsmPortName; std::map::const_iterator property = itemProperties.find("Port"); if(property != itemProperties.end()) { dsmPortName = property->second.c_str(); } XdmfDSMItemFactory::mDSMBuffer->GetComm()->SetDsmPortName(dsmPortName); XdmfDSMItemFactory::mDSMBuffer->Connect(); return XdmfDSMDescription::New(); } return shared_ptr(); } std::vector > XdmfDSMItemFactory::generateHeavyDataControllers(const std::map & itemProperties, const std::vector & passedDimensions, shared_ptr passedArrayType, const std::string & passedFormat) const { std::vector > returnControllers = XdmfCoreItemFactory::generateHeavyDataControllers(itemProperties, passedDimensions, passedArrayType, passedFormat); if (returnControllers.size() > 0) { return returnControllers; } std::string formatVal; if (passedFormat.size() > 0) { formatVal = passedFormat; } else { // create a version that passes these in directly std::map::const_iterator format = itemProperties.find("Format"); if(format == itemProperties.end()) { XdmfError::message(XdmfError::FATAL, "'Format' not found in generateHeavyControllers in " "XdmfCoreItemFactory"); } formatVal = format->second; } std::map::const_iterator content = itemProperties.find("Content"); if(content == itemProperties.end()) { XdmfError::message(XdmfError::FATAL, "'Content' not found in generateHeavyControllers in " "XdmfCoreItemFactory"); } unsigned int contentIndex; const std::string & contentVal = content->second; std::vector contentVals; // Split the content based on "|" characters size_t barSplit = 0; std::string splitString(contentVal); std::string subcontent; while (barSplit != std::string::npos) { barSplit = 0; barSplit = splitString.find_first_of("|", barSplit); if (barSplit == std::string::npos) { subcontent = splitString; } else { subcontent = splitString.substr(0, barSplit); splitString = splitString.substr(barSplit+1); barSplit++; } contentVals.push_back(subcontent); } std::vector dimVector; if (passedDimensions.size() > 0) { dimVector = passedDimensions; } else { std::map::const_iterator dimensions = itemProperties.find("Dimensions"); if(dimensions == itemProperties.end()) { XdmfError::message(XdmfError::FATAL, "'Dimensions' not found in generateHeavyControllers in " "XdmfCoreItemFactory"); } boost::tokenizer<> tokens(dimensions->second); for(boost::tokenizer<>::const_iterator iter = tokens.begin(); iter != tokens.end(); ++iter) { dimVector.push_back(atoi((*iter).c_str())); } } shared_ptr arrayType; if (passedArrayType) { arrayType = passedArrayType; } else { arrayType = XdmfCoreItemFactory::getArrayType(itemProperties); } if (contentVals.size() == 0) { return returnControllers; } if(formatVal.compare("HDFDSM") == 0) { // TODO, generate DSM Buffer here, if different from previous contentIndex = 0; int contentStep = 2; while (contentIndex < contentVals.size()) { size_t colonLocation = contentVals[contentIndex].find(":"); if(colonLocation == std::string::npos) { XdmfError::message(XdmfError::FATAL, "':' not found in content generateHeavyControllers in " "XdmfCoreItemFactory -- double check an HDF5 " "data set is specified for the file"); } std::string hdf5Path = contentVals[contentIndex].substr(0, colonLocation); std::string dataSetPath = contentVals[contentIndex].substr(colonLocation+1); hdf5Path = getFullHeavyDataPath(hdf5Path, itemProperties); // Parse dimensions from the content std::vector contentStarts; std::vector contentStrides; std::vector contentDims; std::vector contentDataspaces; if (contentVals.size() > contentIndex+1) { // This is the string that contains the dimensions std::string dataspaceDescription = contentVals[contentIndex+1]; std::vector dataspaceVector; size_t colonSplit = 0; while (colonSplit != std::string::npos) { colonSplit = 0; colonSplit = dataspaceDescription.find_first_of(":", colonSplit); if (colonSplit == std::string::npos) { subcontent = dataspaceDescription; } else { subcontent = dataspaceDescription.substr(0, colonSplit); dataspaceDescription = dataspaceDescription.substr(colonSplit+1); colonSplit++; } dataspaceVector.push_back(subcontent); } // split the description based on tokens boost::tokenizer<> dimtokens(std::string("")); if (dataspaceVector.size() == 1) { dimtokens = boost::tokenizer<>(dataspaceDescription); } else if (dataspaceVector.size() == 4) { dimtokens = boost::tokenizer<>(dataspaceVector[2]); } for(boost::tokenizer<>::const_iterator iter = dimtokens.begin(); iter != dimtokens.end(); ++iter) { contentDims.push_back(atoi((*iter).c_str())); } if (dataspaceVector.size() == 4) { dimtokens = boost::tokenizer<>(dataspaceVector[0]); for(boost::tokenizer<>::const_iterator iter = dimtokens.begin(); iter != dimtokens.end(); ++iter) { contentStarts.push_back(atoi((*iter).c_str())); } dimtokens = boost::tokenizer<>(dataspaceVector[1]); for(boost::tokenizer<>::const_iterator iter = dimtokens.begin(); iter != dimtokens.end(); ++iter) { contentStrides.push_back(atoi((*iter).c_str())); } dimtokens = boost::tokenizer<>(dataspaceVector[3]); for(boost::tokenizer<>::const_iterator iter = dimtokens.begin(); iter != dimtokens.end(); ++iter) { contentDataspaces.push_back(atoi((*iter).c_str())); } } contentStep = 2; // If this works then the dimension content should be skipped over } else { // If it fails then it means that the next content is not a dimension string // In this case it is assumed that the controller will have // dimensions equal to the array for (unsigned int j = 0; j < dimVector.size(); ++j) { contentDims.push_back(dimVector[j]); } contentStep = 1; } if (contentDataspaces.size() == 0) { returnControllers.push_back( XdmfHDF5ControllerDSM::New(hdf5Path, dataSetPath, arrayType, std::vector(contentDims.size(), 0), std::vector(contentDims.size(), 1), contentDims, contentDims, XdmfDSMItemFactory::mDSMBuffer) ); } else { returnControllers.push_back( XdmfHDF5ControllerDSM::New(hdf5Path, dataSetPath, arrayType, contentStarts, contentStrides, contentDims, contentDataspaces, XdmfDSMItemFactory::mDSMBuffer) ); } contentIndex+=contentStep; } } return returnControllers; } shared_ptr XdmfDSMItemFactory::generateHeavyDataWriter(std::string typeName, std::string path) const { shared_ptr returnWriter = XdmfCoreItemFactory::generateHeavyDataWriter(typeName, path); if (returnWriter) { return returnWriter; } /* if (typeName.compare("HDF") == 0) { return XdmfHDF5Writer::New(path); } */ return shared_ptr(); } XdmfDSMBuffer * XdmfDSMItemFactory::getDSMBuffer() { return XdmfDSMItemFactory::mDSMBuffer; } bool XdmfDSMItemFactory::isArrayTag(char * tag) const { if (XdmfCoreItemFactory::isArrayTag(tag)) { return true; } // No DSM specific cases /* else if (XdmfAggregate::ItemTag.compare(tag) == 0) { return true; } */ else { return false; } } void XdmfDSMItemFactory::setDSMBuffer(XdmfDSMBuffer * newBuffer) { XdmfDSMItemFactory::mDSMBuffer = newBuffer; } XdmfItem * XdmfDSMItemFactory::DuplicatePointer(shared_ptr original) const { XdmfItem * returnPointer = XdmfCoreItemFactory::DuplicatePointer(original); if (returnPointer) { return returnPointer; } else { //Right now DSM has no pointers to duplicate. /* if (original->getItemTag().compare(XdmfTime::ItemTag) == 0) { return new XdmfTime(*((XdmfTime *)original.get())); } */ } return NULL; } xdmf-3.0+git20160803/core/dsm/XdmfHDF5WriterDSM.cpp0000640000175000017500000010346013003006557021363 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfHDF5WriterDSM.cpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #include #include #include #include #include #include "XdmfHDF5ControllerDSM.hpp" #include "XdmfHDF5WriterDSM.hpp" #include "XdmfSystemUtils.hpp" #include "XdmfError.hpp" #include #include XdmfHDF5WriterDSM::XdmfHDF5WriterDSMImpl::XdmfHDF5WriterDSMImpl(): XdmfHDF5WriterImpl(), mDSMIsInit(false), mDSMLocked(false) { }; XdmfHDF5WriterDSM::XdmfHDF5WriterDSMImpl::~XdmfHDF5WriterDSMImpl() { closeFile(); }; int XdmfHDF5WriterDSM::XdmfHDF5WriterDSMImpl::openFile(const std::string & filePath, const int mDataSetId) { if(mHDF5Handle >= 0) { // Perhaps we should throw a warning. closeFile(); } // Save old error handler and turn off error handling for now H5E_auto_t old_func; void * old_client_data; H5Eget_auto(0, &old_func, &old_client_data); H5Eset_auto2(0, NULL, NULL); int toReturn = 0; mOpenFile.assign(filePath); std::vector pages; haddr_t start, end; unsigned int numPages; if (((XdmfDSMBuffer *)xdmf_dsm_get_manager())->GetComm()->GetId() == 0 && !mDSMLocked) { ((XdmfDSMBuffer *)xdmf_dsm_get_manager())->Lock(strdup(filePath.c_str())); mDSMLocked = true; } // if (mDSMIsInit) {// if(XdmfDsmFileInDSM(filePath.c_str()) > 0) { if (((XdmfDSMBuffer *)xdmf_dsm_get_manager())->RequestFileDescription(strdup(filePath.c_str()), pages, numPages, start, end) == XDMF_DSM_SUCCESS) { mHDF5Handle = H5Fopen(filePath.c_str(), H5F_ACC_RDWR, mFapl); if(mDataSetId == 0) { hsize_t numObjects; /*herr_t status = */H5Gget_num_objs(mHDF5Handle, &numObjects); toReturn = numObjects; } else { toReturn = mDataSetId; } } else { mHDF5Handle = H5Fcreate(filePath.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, mFapl); mDSMIsInit = true; } // Restore previous error handler H5Eset_auto2(0, old_func, old_client_data); return toReturn; }; void XdmfHDF5WriterDSM::XdmfHDF5WriterDSMImpl::closeFile() { if(mHDF5Handle >= 0) { H5Fclose(mHDF5Handle); mHDF5Handle = -1; } if (mDSMLocked) { if (((XdmfDSMBuffer *)xdmf_dsm_get_manager())->GetComm()->GetId() == 0) { ((XdmfDSMBuffer *)xdmf_dsm_get_manager())->Unlock(strdup(mOpenFile.c_str())); mDSMLocked = false; } } mOpenFile = ""; }; shared_ptr XdmfHDF5WriterDSM::New(const std::string & filePath, XdmfDSMBuffer * const dsmBuffer) { shared_ptr p(new XdmfHDF5WriterDSM(filePath, dsmBuffer)); return p; } shared_ptr XdmfHDF5WriterDSM::New(const std::string & filePath, MPI_Comm comm, unsigned int bufferSize, int startCoreIndex, int endCoreIndex, std::string applicationName) { shared_ptr p(new XdmfHDF5WriterDSM(filePath, comm, bufferSize, startCoreIndex, endCoreIndex, applicationName)); return p; } shared_ptr XdmfHDF5WriterDSM::New(const std::string & filePath, MPI_Comm comm, unsigned int bufferSize, unsigned int blockSize, double resizeFactor, int startCoreIndex, int endCoreIndex, std::string applicationName) { shared_ptr p(new XdmfHDF5WriterDSM(filePath, comm, bufferSize, blockSize, resizeFactor, startCoreIndex, endCoreIndex, applicationName)); return p; } shared_ptr XdmfHDF5WriterDSM::New(const std::string & filePath, MPI_Comm comm, std::string applicationName) { shared_ptr p(new XdmfHDF5WriterDSM(filePath, comm, applicationName)); return p; } // The database/nonthreaded version XdmfHDF5WriterDSM::XdmfHDF5WriterDSM(const std::string & filePath, XdmfDSMBuffer * const dsmBuffer) : XdmfHDF5Writer(filePath), mDSMServerBuffer(dsmBuffer), mServerMode(true), mNotifyOnWrite(true) { if (mImpl) { delete mImpl; } mImpl = new XdmfHDF5WriterDSMImpl(); mImpl->mFapl = -1; mWorkerComm = mDSMServerBuffer->GetComm()->GetIntraComm(); if (xdmf_dsm_get_manager() == NULL) { XDMF_dsm_set_manager(mDSMServerBuffer); } else { xdmf_dsm_set_manager(mDSMServerBuffer); } } XdmfHDF5WriterDSM::XdmfHDF5WriterDSM(const std::string & filePath, MPI_Comm comm, unsigned int bufferSize, int startCoreIndex, int endCoreIndex, std::string applicationName) : XdmfHDF5Writer(filePath), mServerMode(true) { int rank, size; #ifdef XDMF_DSM_IS_CRAY MPI_Comm InterComm = comm; // Cray needs to be launched via the colon notation so that it // can properly create a merged communicator MPI_Comm_size(comm, &size); MPI_Comm_rank(comm, &rank); int currentCore = 0; int * checkstatus = new int[size](); int localCheck = 0; char * coreTag; int tagSize = 0; std::vector coreSplit; unsigned int splitid = 0; int * splitIds; unsigned int splitsize = 0; while (currentCore < size) { if (rank == currentCore) { tagSize = applicationName.size(); } MPI_Bcast(&tagSize, 1, MPI_INT, currentCore, comm); coreTag = new char[tagSize+1](); if (rank == currentCore) { strcpy(coreTag, applicationName.c_str()); } MPI_Bcast(coreTag, tagSize, MPI_CHAR, currentCore, comm); coreTag[tagSize] = 0; if (strcmp(coreTag, applicationName.c_str()) == 0) { localCheck = 1; } else { localCheck = 0; } checkstatus[rank] = localCheck; MPI_Allgather(&localCheck, 1, MPI_INT, checkstatus, 1, MPI_INT, comm); bool insplit = false; while (checkstatus[currentCore]) { if (rank == currentCore) { insplit = true; } coreSplit.push_back(currentCore); ++currentCore; if (currentCore >= size) { break; } } if (insplit) { splitIds = (int *)calloc(coreSplit.size(), sizeof(int)); memcpy(splitIds, &(coreSplit[0]), coreSplit.size() * sizeof(int)); splitsize = coreSplit.size(); } assert(coreTag); coreSplit.clear(); ++splitid; } // Use MPI_Comm_split MPI_Group IntraGroup, InterGroup; MPI_Comm IntraComm; MPI_Comm_group(comm, &InterGroup); MPI_Group_incl(InterGroup, splitsize, splitIds, &IntraGroup); MPI_Comm_create(comm, IntraGroup, &IntraComm); cfree(splitIds); int intraid = 0; int intrasize = 0; MPI_Comm_rank(IntraComm, &intraid); MPI_Comm_size(IntraComm, &intrasize); comm = IntraComm; #endif if (mImpl) { delete mImpl; } mImpl = new XdmfHDF5WriterDSMImpl(); mImpl->mFapl = -1; MPI_Comm_size(comm, &size); MPI_Comm_rank(comm, &rank); // Negative values will be changed to maximum range if (startCoreIndex < 0) { startCoreIndex = 0; } if (endCoreIndex < 0) { endCoreIndex = size - 1; } // Ensure start index is less than end index if (startCoreIndex > endCoreIndex) { int tempholder = startCoreIndex; startCoreIndex = endCoreIndex; endCoreIndex = tempholder; } MPI_Comm serverComm; MPI_Group workers, dsmgroup, serversplit, servergroup; int * ServerIds = (int *)calloc((endCoreIndex - startCoreIndex + 1), sizeof(int)); unsigned int index = 0; for(int i=startCoreIndex ; i <= endCoreIndex ; ++i) { ServerIds[index++] = i; } MPI_Comm_group(comm, &serversplit); MPI_Group_incl(serversplit, index, ServerIds, &servergroup); MPI_Comm_create(comm, servergroup, &serverComm); MPI_Comm_group(comm, &dsmgroup); MPI_Group_excl(dsmgroup, index, ServerIds, &workers); MPI_Comm_create(comm, workers, &mWorkerComm); cfree(ServerIds); // Create the manager mDSMServerBuffer = new XdmfDSMBuffer(); mDSMServerBuffer->SetLocalBufferSizeMBytes(bufferSize); mDSMServerBuffer->SetInterCommType(XDMF_DSM_COMM_MPI); mDSMServerBuffer->SetDsmType(XDMF_DSM_TYPE_UNIFORM); MPI_Barrier(comm); if (rank >= startCoreIndex && rank <= endCoreIndex) { mDSMServerBuffer->Create(serverComm); } else { mDSMServerBuffer->Create(mWorkerComm, startCoreIndex, endCoreIndex); mDSMServerBuffer->SetIsServer(false); } XDMF_dsm_set_manager(mDSMServerBuffer); #ifdef XDMF_DSM_IS_CRAY mDSMServerBuffer->GetComm()->DupInterComm(InterComm); #else mDSMServerBuffer->GetComm()->DupInterComm(comm); #endif if (rank >= startCoreIndex && rank <= endCoreIndex) { mDSMServerBuffer->GetComm()->SetApplicationName("Server"); } else { mDSMServerBuffer->GetComm()->SetApplicationName(applicationName); } mDSMServerBuffer->SetIsConnected(true); if (startCoreIndex < size) { if (rank >= startCoreIndex && rank <= endCoreIndex) { mDSMServerBuffer->ReceiveInfo(); } else { mDSMServerBuffer->SendInfo(); } } MPI_Barrier(comm); // Loop needs to be started before anything can be done to the file // since the service is what sets up the file if (rank < startCoreIndex || rank > endCoreIndex) { // Turn off the server designation mDSMServerBuffer->SetIsServer(false); // If this is set to false then the buffer will attempt to connect // to the intercomm for DSM communications } else { // On cores where memory is set up, start the service loop // This should iterate infinitely until a value to end the loop is passed int returnOpCode; try { mDSMServerBuffer->BufferServiceLoop(&returnOpCode); } catch (XdmfError & e) { throw e; } } } XdmfHDF5WriterDSM::XdmfHDF5WriterDSM(const std::string & filePath, MPI_Comm comm, unsigned int bufferSize, unsigned int blockSize, double resizeFactor, int startCoreIndex, int endCoreIndex, std::string applicationName) : XdmfHDF5Writer(filePath), mServerMode(true) { int rank, size; #ifdef XDMF_DSM_IS_CRAY MPI_Comm InterComm = comm; // Cray needs to be launched via the colon notation so that it // can properly create a merged communicator MPI_Comm_rank(comm, &rank); MPI_Comm_size(comm, &size); int currentCore = 0; int * checkstatus = new int[size](); int localCheck = 0; char * coreTag; int tagSize = 0; std::vector coreSplit; unsigned int splitid = 0; int * splitIds; unsigned int splitsize = 0; while (currentCore < size) { if (rank == currentCore) { tagSize = applicationName.size(); } MPI_Bcast(&tagSize, 1, MPI_INT, currentCore, comm); coreTag = new char[tagSize+1](); if (rank == currentCore) { strcpy(coreTag, applicationName.c_str()); } MPI_Bcast(coreTag, tagSize, MPI_CHAR, currentCore, comm); coreTag[tagSize] = 0; if (strcmp(coreTag, applicationName.c_str()) == 0) { localCheck = 1; } else { localCheck = 0; } checkstatus[rank] = localCheck; MPI_Allgather(&localCheck, 1, MPI_INT, checkstatus, 1, MPI_INT, comm); bool insplit = false; while (checkstatus[currentCore]) { if (rank == currentCore) { insplit = true; } coreSplit.push_back(currentCore); ++currentCore; if (currentCore >= size) { break; } } if (insplit) { splitIds = (int *)calloc(coreSplit.size(), sizeof(int)); memcpy(splitIds, &(coreSplit[0]), coreSplit.size() * sizeof(int)); splitsize = coreSplit.size(); } assert(coreTag); coreSplit.clear(); ++splitid; } // Use MPI_Comm_split MPI_Group IntraGroup, InterGroup; MPI_Comm IntraComm; MPI_Comm_group(comm, &InterGroup); MPI_Group_incl(InterGroup, splitsize, splitIds, &IntraGroup); MPI_Comm_create(comm, IntraGroup, &IntraComm); cfree(splitIds); int intraid = 0; int intrasize = 0; MPI_Comm_rank(IntraComm, &intraid); MPI_Comm_size(IntraComm, &intrasize); comm = IntraComm; #endif if (mImpl) { delete mImpl; } mImpl = new XdmfHDF5WriterDSMImpl(); mImpl->mFapl = -1; // Cray Specific stuff has to occur here MPI_Comm_size(comm, &size); MPI_Comm_rank(comm, &rank); // Negative values will be changed to maximum range if (startCoreIndex < 0) { startCoreIndex = 0; } if (endCoreIndex < 0) { endCoreIndex = size - 1; } // Ensure start index is less than end index if (startCoreIndex > endCoreIndex) { int tempholder = startCoreIndex; startCoreIndex = endCoreIndex; endCoreIndex = tempholder; } MPI_Comm serverComm; MPI_Group workers, dsmgroup, serversplit, servergroup; int * ServerIds = (int *)calloc((endCoreIndex - startCoreIndex + 1), sizeof(int)); unsigned int index = 0; for(int i=startCoreIndex ; i <= endCoreIndex ; ++i) { ServerIds[index++] = i; } MPI_Comm_group(comm, &serversplit); MPI_Group_incl(serversplit, index, ServerIds, &servergroup); MPI_Comm_create(comm, servergroup, &serverComm); MPI_Comm_group(comm, &dsmgroup); MPI_Group_excl(dsmgroup, index, ServerIds, &workers); MPI_Comm_create(comm, workers, &mWorkerComm); cfree(ServerIds); // Create the manager mDSMServerBuffer = new XdmfDSMBuffer(); mDSMServerBuffer->SetLocalBufferSizeMBytes(bufferSize); mDSMServerBuffer->SetInterCommType(XDMF_DSM_COMM_MPI); mDSMServerBuffer->SetBlockLength(blockSize); mDSMServerBuffer->SetDsmType(XDMF_DSM_TYPE_BLOCK_CYCLIC); mDSMServerBuffer->SetResizeFactor(resizeFactor); MPI_Barrier(comm); if (rank >= startCoreIndex && rank <= endCoreIndex) { mDSMServerBuffer->Create(serverComm); } else { mDSMServerBuffer->Create(mWorkerComm, startCoreIndex, endCoreIndex); mDSMServerBuffer->SetIsServer(false); } XDMF_dsm_set_manager(mDSMServerBuffer); #ifdef XDMF_DSM_IS_CRAY mDSMServerBuffer->GetComm()->DupInterComm(InterComm); #else mDSMServerBuffer->GetComm()->DupInterComm(comm); #endif if (rank >= startCoreIndex && rank <= endCoreIndex) { mDSMServerBuffer->GetComm()->SetApplicationName("Server"); } else { mDSMServerBuffer->GetComm()->SetApplicationName(applicationName); } mDSMServerBuffer->SetIsConnected(true); if (startCoreIndex < size) { if (rank >= startCoreIndex && rank <= endCoreIndex) { mDSMServerBuffer->ReceiveInfo(); } else { mDSMServerBuffer->SendInfo(); } } MPI_Barrier(comm); // Loop needs to be started before anything can be done to the file // since the service is what sets up the file if (rank < startCoreIndex || rank > endCoreIndex) { // Turn off the server designation mDSMServerBuffer->SetIsServer(false); // If this is set to false then the buffer will attempt to connect // to the intercomm for DSM communications } else { // On cores where memory is set up, start the service loop // This should iterate infinitely until a value to end the loop is passed int returnOpCode; try { mDSMServerBuffer->BufferServiceLoop(&returnOpCode); } catch (XdmfError & e) { throw e; } } } XdmfHDF5WriterDSM::XdmfHDF5WriterDSM(const std::string & filePath, MPI_Comm comm, std::string applicationName) : XdmfHDF5Writer(filePath), mServerMode(true), mNotifyOnWrite(true) { int rank, size; #ifdef XDMF_DSM_IS_CRAY MPI_Comm InterComm = comm; // Cray needs to be launched via the colon notation so that it // can properly create a merged communicator MPI_Comm_rank(comm, &rank); MPI_Comm_size(comm, &size); int currentCore = 0; int * checkstatus = new int[size](); int localCheck = 0; char * coreTag; int tagSize = 0; std::vector coreSplit; unsigned int splitid = 0; int * splitIds; unsigned int splitsize = 0; while (currentCore < size) { if (rank == currentCore) { tagSize = applicationName.size(); } MPI_Bcast(&tagSize, 1, MPI_INT, currentCore, comm); coreTag = new char[tagSize+1](); if (rank == currentCore) { strcpy(coreTag, applicationName.c_str()); } MPI_Bcast(coreTag, tagSize, MPI_CHAR, currentCore, comm); coreTag[tagSize] = 0; if (strcmp(coreTag, applicationName.c_str()) == 0) { localCheck = 1; } else { localCheck = 0; } checkstatus[rank] = localCheck; MPI_Allgather(&localCheck, 1, MPI_INT, checkstatus, 1, MPI_INT, comm); bool insplit = false; while (checkstatus[currentCore]) { if (rank == currentCore) { insplit = true; } coreSplit.push_back(currentCore); ++currentCore; if (currentCore >= size) { break; } } if (insplit) { splitIds = (int *)calloc(coreSplit.size(), sizeof(int)); memcpy(splitIds, &(coreSplit[0]), coreSplit.size() * sizeof(int)); splitsize = coreSplit.size(); } assert(coreTag); coreSplit.clear(); ++splitid; } // Use MPI_Comm_split MPI_Group IntraGroup, InterGroup; MPI_Comm IntraComm; MPI_Comm_group(comm, &InterGroup); MPI_Group_incl(InterGroup, splitsize, splitIds, &IntraGroup); MPI_Comm_create(comm, IntraGroup, &IntraComm); cfree(splitIds); int intraid = 0; int intrasize = 0; MPI_Comm_rank(IntraComm, &intraid); MPI_Comm_size(IntraComm, &intrasize); comm = IntraComm; #endif if (mImpl) { delete mImpl; } mImpl = new XdmfHDF5WriterDSMImpl(); mImpl->mFapl = -1; // Retrieve the Buffer mDSMServerBuffer = new XdmfDSMBuffer(); mDSMServerBuffer->SetIsServer(false); mDSMServerBuffer->SetInterCommType(XDMF_DSM_COMM_MPI); // Create a Comm object XdmfDSMCommMPI * newComm = new XdmfDSMCommMPI(); newComm->DupComm(comm); #ifdef XDMF_DSM_IS_CRAY newComm->DupInterComm(InterComm); #else newComm->DupInterComm(comm); #endif newComm->Init(); newComm->SetApplicationName(applicationName); // Set the Comm to the buffer mDSMServerBuffer->SetComm(newComm); // Register the manager with the driver XDMF_dsm_set_manager(mDSMServerBuffer); #ifdef XDMF_DSM_IS_CRAY mDSMServerBuffer->ReceiveInfo(); #endif MPI_Barrier(comm); } XdmfHDF5WriterDSM::XdmfHDF5WriterDSM(XdmfHDF5WriterDSM & refWriter): XdmfHDF5Writer(refWriter), mDSMServerBuffer(refWriter.getServerBuffer()), mWorkerComm(refWriter.getWorkerComm()), mServerMode(refWriter.getServerMode()), mNotifyOnWrite(refWriter.mNotifyOnWrite) { mImpl->mFapl = -1; } XdmfHDF5WriterDSM::~XdmfHDF5WriterDSM() { } shared_ptr XdmfHDF5WriterDSM::createController(const std::string & hdf5FilePath, const std::string & dataSetPath, const shared_ptr type, const std::vector & start, const std::vector & stride, const std::vector & dimensions, const std::vector & dataspaceDimensions) { if (mDSMServerBuffer != NULL) { return XdmfHDF5ControllerDSM::New(hdf5FilePath, dataSetPath, type, start, stride, dimensions, dataspaceDimensions, mDSMServerBuffer); } else { return shared_ptr(); } } void XdmfHDF5WriterDSM::closeFile() { if(mImpl->mFapl >= 0) { H5Pclose(mImpl->mFapl); mImpl->mFapl = -1; } XdmfHDF5Writer::closeFile(); } int XdmfHDF5WriterDSM::getDataSetSize(const std::string & fileName, const std::string & dataSetName) { bool closeFAPL = false; if(mImpl->mFapl < 0) { // Set file access property list for DSM mImpl->mFapl = H5Pcreate(H5P_FILE_ACCESS); // Use DSM driver if (mWorkerComm != MPI_COMM_NULL) { XDMFH5Pset_fapl_dsm(mImpl->mFapl, mWorkerComm, mDSMServerBuffer, 0); } closeFAPL = true; } hid_t handle = -1; H5E_auto_t old_func; void * old_client_data; herr_t status; H5Eget_auto(0, &old_func, &old_client_data); H5Eset_auto2(0, NULL, NULL); bool mustClose = false; if (XdmfSystemUtils::getRealPath(fileName) != mImpl->mOpenFile) { // Save old error handler and turn off error handling for now handle = H5Fopen(fileName.c_str(), H5F_ACC_RDWR, mImpl->mFapl); mustClose = true; } else { handle = mImpl->mHDF5Handle; } // Restore previous error handler H5Eset_auto2(0, old_func, old_client_data); if (!H5Lexists(handle, dataSetName.c_str(), H5P_DEFAULT)) { if (handle != mImpl->mHDF5Handle) { H5Fclose(handle); } if(closeFAPL) { // Close file access property list H5Pclose(mImpl->mFapl); mImpl->mFapl = -1; } return 0; } hid_t checkset = H5Dopen(handle, dataSetName.c_str(), H5P_DEFAULT); hid_t checkspace = H5S_ALL; checkspace = H5Dget_space(checkset); hssize_t checksize = H5Sget_simple_extent_npoints(checkspace); if(checkspace != H5S_ALL) { status = H5Sclose(checkspace); } status = H5Dclose(checkset); if (handle != mImpl->mHDF5Handle || mustClose) { H5Fclose(handle); } if(closeFAPL) { // Close file access property list H5Pclose(mImpl->mFapl); mImpl->mFapl = -1; } return checksize; } bool XdmfHDF5WriterDSM::getNotifyOnWrite() { return mNotifyOnWrite; } XdmfDSMBuffer * XdmfHDF5WriterDSM::getServerBuffer() { return mDSMServerBuffer; } bool XdmfHDF5WriterDSM::getServerMode() { return mServerMode; } MPI_Comm XdmfHDF5WriterDSM::getWorkerComm() { MPI_Comm returnComm = MPI_COMM_NULL; if (mWorkerComm != MPI_COMM_NULL) { MPI_Comm_dup(mWorkerComm, &returnComm); } return returnComm; } void XdmfHDF5WriterDSM::setAllowSetSplitting(bool newAllow) { //overrides to disable the parent version XdmfHDF5Writer::setAllowSetSplitting(false); } void XdmfHDF5WriterDSM::setBuffer(XdmfDSMBuffer * newBuffer) { mDSMServerBuffer = newBuffer; } void XdmfHDF5WriterDSM::setNotifyOnWrite(bool status) { mNotifyOnWrite = status; } void XdmfHDF5WriterDSM::setServerMode(bool newMode) { mServerMode = newMode; } void XdmfHDF5WriterDSM::setWorkerComm(MPI_Comm comm) { int status; #ifndef OPEN_MPI if (mWorkerComm != MPI_COMM_NULL) { status = MPI_Comm_free(&mWorkerComm); if (status != MPI_SUCCESS) { try { XdmfError::message(XdmfError::FATAL, "Failed to disconnect Comm"); } catch (XdmfError & e) { throw e; } } } #endif if (comm != MPI_COMM_NULL) { status = MPI_Comm_dup(comm, &mWorkerComm); if (status != MPI_SUCCESS) { try { XdmfError::message(XdmfError::FATAL, "Failed to duplicate Comm"); } catch (XdmfError & e) { throw e; } } } mDSMServerBuffer->GetComm()->DupComm(comm); } void XdmfHDF5WriterDSM::stopDSM() { if (mServerMode) { // Send manually for (int i = mDSMServerBuffer->GetStartServerId(); i <= mDSMServerBuffer->GetEndServerId(); ++i) { try { mDSMServerBuffer->SendCommandHeader(XDMF_DSM_OPCODE_DONE, i, 0, 0, XDMF_DSM_INTER_COMM); } catch (XdmfError & e) { throw e; } } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Stopping DSM manually only available in server mode."); } catch (XdmfError & e) { throw e; } } } void XdmfHDF5WriterDSM::restartDSM() { if (mServerMode) { if (mDSMServerBuffer->GetComm()->GetInterId() >= mDSMServerBuffer->GetStartServerId() && mDSMServerBuffer->GetComm()->GetInterId() <= mDSMServerBuffer->GetEndServerId()) { int returnOpCode; try { mDSMServerBuffer->BufferServiceLoop(&returnOpCode); } catch (XdmfError & e) { throw e; } } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Restarting DSM only available in server mode."); } catch (XdmfError & e) { throw e; } } } void XdmfHDF5WriterDSM::openFile() { if(mImpl->mFapl >= 0) { this->closeFile(); } // Set file access property list for DSM mImpl->mFapl = H5Pcreate(H5P_FILE_ACCESS); if (mWorkerComm != MPI_COMM_NULL) { XDMFH5Pset_fapl_dsm(mImpl->mFapl, mWorkerComm, mDSMServerBuffer, 0); } XdmfHDF5Writer::openFile(); } void XdmfHDF5WriterDSM::visit(XdmfArray & array, const shared_ptr) { bool closeFAPL = false; if(mImpl->mFapl < 0) { // Set file access property list for DSM mImpl->mFapl = H5Pcreate(H5P_FILE_ACCESS); // Use DSM driver if (mWorkerComm != MPI_COMM_NULL) { XDMFH5Pset_fapl_dsm(mImpl->mFapl, mWorkerComm, mDSMServerBuffer, 0); } closeFAPL = true; } // Write to DSM Buffer this->write(array); if(closeFAPL) { // Close file access property list H5Pclose(mImpl->mFapl); mImpl->mFapl = -1; } if (mNotifyOnWrite) { for (unsigned int i = 0; i < array.getNumberHeavyDataControllers(); ++i) { if (array.getHeavyDataController(i)->getName().compare("HDFDSM") == 0) { this->waitRelease(array.getHeavyDataController(i)->getFilePath(), shared_dynamic_cast(array.getHeavyDataController(i))->getDataSetPath()); } } } } void XdmfHDF5WriterDSM::waitRelease(std::string fileName, std::string datasetName, int code) { mDSMServerBuffer->WaitRelease(fileName, datasetName, code); } int XdmfHDF5WriterDSM::waitOn(std::string fileName, std::string datasetName) { return mDSMServerBuffer->WaitOn(fileName, datasetName); } // C Wrappers XDMFHDF5WRITERDSM * XdmfHDF5WriterDSMNewFromServerBuffer(char * filePath, void * dsmBuffer, int * status) { XDMF_ERROR_WRAP_START(status) shared_ptr createdWriter = XdmfHDF5WriterDSM::New(std::string(filePath), (XdmfDSMBuffer *)dsmBuffer); return (XDMFHDF5WRITERDSM *)((void *)(new XdmfHDF5WriterDSM(* createdWriter.get()))); XDMF_ERROR_WRAP_END(status) return NULL; } XDMFHDF5WRITERDSM * XdmfHDF5WriterDSMNew(char * filePath, MPI_Comm comm, unsigned int bufferSize, int startCoreIndex, int endCoreIndex, char * applicationName, int * status) { XDMF_ERROR_WRAP_START(status) shared_ptr createdWriter = XdmfHDF5WriterDSM::New(std::string(filePath), comm, bufferSize, startCoreIndex, endCoreIndex, std::string(applicationName)); return (XDMFHDF5WRITERDSM *)((void *)(new XdmfHDF5WriterDSM(*createdWriter.get()))); XDMF_ERROR_WRAP_END(status) return NULL; } XDMFHDF5WRITERDSM * XdmfHDF5WriterDSMNewPaged(char * filePath, MPI_Comm comm, unsigned int bufferSize, unsigned int blockSize, double resizeFactor, int startCoreIndex, int endCoreIndex, char * applicationName, int * status) { XDMF_ERROR_WRAP_START(status) shared_ptr createdWriter = XdmfHDF5WriterDSM::New(std::string(filePath), comm, bufferSize, blockSize, resizeFactor, startCoreIndex, endCoreIndex, std::string(applicationName)); return (XDMFHDF5WRITERDSM *)((void *)(new XdmfHDF5WriterDSM(*createdWriter.get()))); XDMF_ERROR_WRAP_END(status) return NULL; } XDMFHDF5WRITERDSM * XdmfHDF5WriterDSMNewConnectRequired(char * filePath, MPI_Comm comm, char * applicationName, int * status) { XDMF_ERROR_WRAP_START(status) shared_ptr createdWriter = XdmfHDF5WriterDSM::New(std::string(filePath), comm, std::string(applicationName)); return (XDMFHDF5WRITERDSM *)((void *)(new XdmfHDF5WriterDSM(*createdWriter.get()))); XDMF_ERROR_WRAP_END(status) return NULL; } int XdmfHDF5WriterDSMGetDataSetSize(XDMFHDF5WRITERDSM * writer, char * fileName, char * dataSetName) { return ((XdmfHDF5WriterDSM *) writer)->getDataSetSize(std::string(fileName), std::string(dataSetName)); } XDMFDSMBUFFER * XdmfHDF5WriterDSMGetServerBuffer(XDMFHDF5WRITERDSM * writer) { return (XDMFDSMBUFFER *)((void *)(((XdmfHDF5WriterDSM *) writer)->getServerBuffer())); } int XdmfHDF5WriterDSMGetServerMode(XDMFHDF5WRITERDSM * writer) { return ((XdmfHDF5WriterDSM *) writer)->getServerMode(); } MPI_Comm XdmfHDF5WriterDSMGetWorkerComm(XDMFHDF5WRITERDSM * writer) { return ((XdmfHDF5WriterDSM *) writer)->getWorkerComm(); } void XdmfHDF5WriterDSMSetServerBuffer(XDMFHDF5WRITERDSM * writer, XDMFDSMBUFFER * newBuffer) { ((XdmfHDF5WriterDSM *) writer)->setBuffer((XdmfDSMBuffer *)newBuffer); } void XdmfHDF5WriterDSMSetServerMode(XDMFHDF5WRITERDSM * writer, int newMode) { ((XdmfHDF5WriterDSM *) writer)->setServerMode(newMode); } void XdmfHDF5WriterDSMSetWorkerComm(XDMFHDF5WRITERDSM * writer, MPI_Comm comm, int * status) { XDMF_ERROR_WRAP_START(status) ((XdmfHDF5WriterDSM *) writer)->setWorkerComm(comm); XDMF_ERROR_WRAP_END(status) } void XdmfHDF5WriterDSMStopDSM(XDMFHDF5WRITERDSM * writer, int * status) { XDMF_ERROR_WRAP_START(status) ((XdmfHDF5WriterDSM *) writer)->stopDSM(); XDMF_ERROR_WRAP_END(status) } void XdmfHDF5WriterDSMRestartDSM(XDMFHDF5WRITERDSM * writer, int * status) { XDMF_ERROR_WRAP_START(status) ((XdmfHDF5WriterDSM *) writer)->restartDSM(); XDMF_ERROR_WRAP_END(status) } void XdmfHDF5WriterDSMWaitRelease(XDMFHDF5WRITERDSM * writer, char * fileName, char * datasetName, int code) { ((XdmfHDF5WriterDSM *) writer)->waitRelease(std::string(fileName), std::string(datasetName), code); } int XdmfHDF5WriterDSMWaitOn(XDMFHDF5WRITERDSM * writer, char * fileName, char * datasetName) { return ((XdmfHDF5WriterDSM *) writer)->waitOn(std::string(fileName), std::string(datasetName)); } XDMF_HDF5WRITER_C_CHILD_WRAPPER(XdmfHDF5WriterDSM, XDMFHDF5WRITERDSM) XDMF_HEAVYWRITER_C_CHILD_WRAPPER(XdmfHDF5WriterDSM, XDMFHDF5WRITERDSM) xdmf-3.0+git20160803/core/dsm/CMakeLists.txt0000640000175000017500000001437713003006557020361 0ustar alastairalastairproject(XdmfDSM) cmake_minimum_required(VERSION 2.6) if (POLICY CMP0015) cmake_policy(SET CMP0015 NEW) endif () set(XdmfDSMLinkLibraries XdmfCore) set(XdmfDSMLinkLibraryDir ) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) option(XDMF_BUILD_DSM_THREADS ON) mark_as_advanced(Boost_INCLUDE_DIR) include_directories(${Boost_INCLUDE_DIRS}) mark_as_advanced(FORCE Boost_INCLUDE_DIR) #mark_as_advanced(CLEAR HDF5_C_INCLUDE_DIR) #mark_as_advanced(CLEAR HDF5_hdf5_LIBRARY_DEBUG) #mark_as_advanced(CLEAR HDF5_hdf5_LIBRARY_RELEASE) #find_package(HDF5 REQUIRED) if(HDF5_FOUND) mark_as_advanced(FORCE HDF5_C_INCLUDE_DIR) mark_as_advanced(FORCE HDF5_hdf5_LIBRARY_DEBUG) mark_as_advanced(FORCE HDF5_hdf5_LIBRARY_RELEASE) include_directories(${HDF5_INCLUDE_DIRS}) include_directories(${HDF5_C_INCLUDE_DIR}) set(HDF5_LIBRARIES ${HDF5_hdf5_LIBRARY_RELEASE}) get_filename_component(HDF5_LIBRARY_DIR "${HDF5_hdf5_LIBRARY_RELEASE}" PATH) set(XdmfDSMLinkLibraryDir ${XdmfDSMLinkLibraryDir} ${HDF5_LIBRARY_DIR}) # FIXME: Would like to get this info from HDF5 so we don't have conflicting # MPI versions if(HDF5_IS_PARALLEL) # If MPI variables are already populated don't search again if (NOT MPI_FOUND) find_package(MPI REQUIRED) endif (NOT MPI_FOUND) if(MPI_FOUND) include_directories(${MPI_INCLUDE_PATH}) set(XdmfDSMLinkLibraries ${XdmfDSMLinkLibraries} ${MPI_LIBRARY} ${MPI_EXTRA_LIBRARY}) endif() else() message(SEND_ERROR "Error: XdmfDSM requires a parallel enabled build of HDF5.") endif() set(XdmfDSMLinkLibraries ${XdmfDSMLinkLibraries} ${HDF5_LIBRARIES}) endif() find_package(LibXml2 REQUIRED) if(LIBXML2_FOUND) include_directories(${LIBXML2_INCLUDE_DIR}) set(XdmfDSMLinkLibraries ${XdmfDSMLinkLibraries} ${LIBXML2_LIBRARIES}) endif() set(XdmfDSMSources XdmfHDF5ControllerDSM XdmfHDF5WriterDSM XdmfDSMCommMPI XdmfDSMBuffer XdmfDSMDescription XdmfDSMItemFactory XdmfDSMDriver) if (XDMF_BUILD_DSM_THREADS) add_definitions(-DXDMF_BUILD_DSM_THREADS) endif () if (XDMF_BUILD_DSM_THREADS) find_package(H5FDdsm REQUIRED NO_MODULE) if(H5FDdsm_FOUND) include_directories(${H5FDdsm_INCLUDE_DIR}) get_property(h5fddsm_lib_location TARGET H5FDdsm PROPERTY LOCATION) set(H5FDdsm_LIBRARIES ${h5fddsm_lib_location}) set(XdmfDSMLinkLibraries ${XdmfDSMLinkLibraries} ${H5FDdsm_LIBRARIES}) else() message(SEND_ERROR "Cannot find HDF5 DSM! Please set H5FDdsm_DIR or disable XDMF_BUILD_DSM_THREADS and configure again.") endif() endif () # Set a variable if cray is being used STRING(REGEX MATCH "aprun" IS_CRAY "${MPIEXEC}") set(XDMF_DSM_IS_CRAY "${IS_CRAY}") set(XDMF_DSM_IS_CRAY "${XDMF_DSM_IS_CRAY}" PARENT_SCOPE) if (XDMF_DSM_IS_CRAY) add_definitions(-DXDMF_DSM_IS_CRAY) endif (XDMF_DSM_IS_CRAY) add_library(XdmfDSMObjects OBJECT ${XdmfDSMSources}) set_target_properties(XdmfDSMObjects PROPERTIES POSITION_INDEPENDENT_CODE True) add_library(XdmfDSM $) if (BUILD_SHARED_LIBS) add_library(XdmfDSM_Static STATIC $) if (UNIX) set_target_properties(XdmfDSM_Static PROPERTIES OUTPUT_NAME "XdmfDSM") endif (UNIX) endif (BUILD_SHARED_LIBS) #add_library(XdmfDSM ${XdmfDSMSources}) #if (BUILD_SHARED_LIBS) # add_library(XdmfDSM_Static STATIC ${XdmfDSMSources}) # if (UNIX) # set_target_properties(XdmfDSM_Static PROPERTIES # OUTPUT_NAME "XdmfDSM") # endif (UNIX) #endif (BUILD_SHARED_LIBS) link_directories(${XDMF_LIBRARY_DIRS} ${XdmfDSMLinkLibraryDir}) target_link_libraries(XdmfDSM ${XdmfDSMLinkLibraries}) if (BUILD_SHARED_LIBS) target_link_libraries(XdmfDSM_Static ${XdmfDSMLinkLibraries}) endif (BUILD_SHARED_LIBS) if(WIN32) add_definitions(-D_HDF5USEDLL_ -D_HDF5USEHLDLL_) set_target_properties(XdmfDSM PROPERTIES DEFINE_SYMBOL XdmfDSM_EXPORTS) if (BUILD_SHARED_LIBS) set_target_properties(XdmfDSM_Static PROPERTIES DEFINE_SYMBOL XdmfDSM_EXPORTS) endif (BUILD_SHARED_LIBS) if(NOT MSVC10) set_target_properties(XdmfDSM PROPERTIES PREFIX ../ IMPORT_PREFIX ../ RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) if (BUILD_SHARED_LIBS) set_target_properties(XdmfDSM_Static PROPERTIES PREFIX ../ IMPORT_PREFIX ../ RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) endif() endif() endif() if(XDMF_WRAP_JAVA) XDMF_SWIG_JAVA(XdmfDSM Compiled_XdmfCore_Jar) endif() if(XDMF_WRAP_PYTHON) if (NOT BUILD_SHARED_LIBS) message(FATAL_ERROR "Python Wrappers do not function" " properly without shared libraries") endif (NOT BUILD_SHARED_LIBS) XDMF_SWIG_PYTHON(XdmfDSM XdmfCore) endif() set(XDMF_LIBRARY_DIRS ${XDMF_LIBRARY_DIRS} PARENT_SCOPE) if(WIN32) set(XDMFDSM_LIBRARY ${CMAKE_INSTALL_PREFIX}/lib/XdmfDSM.lib PARENT_SCOPE) endif() if(UNIX) if (BUILD_SHARED_LIBS) set(XDMFDSM_LIBRARY ${CMAKE_INSTALL_PREFIX}/lib/libXdmfDSM.so PARENT_SCOPE) else (BUILD_SHARED_LIBS) set(XDMFDSM_LIBRARY ${CMAKE_INSTALL_PREFIX}/lib/libXdmfDSM.a PARENT_SCOPE) endif (BUILD_SHARED_LIBS) endif() if(APPLE) set(XDMFDSM_LIBRARY ${CMAKE_INSTALL_PREFIX}/lib/libXdmfDSM.dylib PARENT_SCOPE) endif() file(GLOB_RECURSE XdmfDSMHeaders "*.hpp" "*.tpp" "*.i" "../../CMake/VersionSuite/*.hpp") install(FILES ${XdmfDSMHeaders} DESTINATION include) install(TARGETS XdmfDSM RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) if (BUILD_SHARED_LIBS) install(TARGETS XdmfDSM_Static RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) endif (BUILD_SHARED_LIBS) if(XDMF_BUILD_DSM_THREADS) set(XdmfDSM_INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR} ${HDF5_INCLUDE_DIR} ${H5FDdsm_INCLUDE_DIR} ${LIBXML2_INCLUDE_DIR} ${PYTHON_INCLUDE_DIRS} CACHE INTERNAL "") else() set(XdmfDSM_INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR} ${HDF5_INCLUDE_DIR} ${LIBXML2_INCLUDE_DIR} ${PYTHON_INCLUDE_DIRS} CACHE INTERNAL "") endif() include_directories(${XdmfCore_INCLUDE_DIRS} ${XdmfDSM_INCLUDE_DIRS}) if(XDMF_BUILD_TESTING) add_subdirectory(tests) endif() xdmf-3.0+git20160803/core/dsm/XdmfDSMBuffer.hpp0000640000175000017500000026026713003006557020727 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfDSMBuffer.hpp */ /* */ /* Author: */ /* Andrew Burns */ /* andrew.j.burns2@us.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2013 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ /*========================================================================= This code is derived from an earlier work and is distributed with permission from, and thanks to ... =========================================================================*/ /*========================================================================= Project : H5FDdsm Module : H5FDdsmBufferService.h, H5FDdsmBuffer.h Authors: John Biddiscombe Jerome Soumagne biddisco@cscs.ch soumagne@cscs.ch Copyright (C) CSCS - Swiss National Supercomputing Centre. You may use modify and and distribute this code freely providing 1) This copyright notice appears on all copies of source code 2) An acknowledgment appears with any substantial usage of the code 3) If this code is contributed to any other open source project, it must not be reformatted such that the indentation, bracketing or overall style is modified significantly. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. This work has received funding from the European Community's Seventh Framework Programme (FP7/2007-2013) under grant agreement 225967 âxtMuSEâOB =========================================================================*/ #ifndef XDMFDSMBUFFER_HPP_ #define XDMFDSMBUFFER_HPP_ // C Compatible Includes #include #include #include #ifndef _H5public_H #ifndef XDMF_HADDR_T #define XDMF_HADDR_T typedef unsigned long haddr_t; #endif #endif // Definitions /* #define XDMF_DSM_DEFAULT_TAG 0x80 #define XDMF_DSM_COMMAND_TAG 0x81 #define XDMF_DSM_SERVER_ACK_TAG 0x82 #define XDMF_DSM_CLIENT_ACK_TAG 0x83 #define XDMF_DSM_PUT_DATA_TAG 0x84 #define XDMF_DSM_GET_DATA_TAG 0x85 #define XDMF_DSM_EXCHANGE_TAG 0x86 #define XDMF_DSM_ANY_TAG -1 #define XDMF_DSM_ANY_SOURCE -2 */ #define XDMF_DSM_TYPE_UNIFORM 0 #define XDMF_DSM_TYPE_UNIFORM_RANGE 1 #define XDMF_DSM_TYPE_MIXED 2 #define XDMF_DSM_TYPE_BLOCK_CYCLIC 3 #define XDMF_DSM_TYPE_BLOCK_RANDOM 4 #define XDMF_DSM_DEFAULT_LENGTH 10000 #define XDMF_DSM_DEFAULT_BLOCK_LENGTH 1024 #define XDMF_DSM_ALIGNMENT 4096 #define XDMF_DSM_OPCODE_PUT 0x01 #define XDMF_DSM_OPCODE_GET 0x02 #define XDMF_DSM_LOCK_ACQUIRE 0x03 #define XDMF_DSM_LOCK_RELEASE 0x05 #define XDMF_DSM_SET_NOTIFY 0x06 #define XDMF_DSM_CLEAR_NOTIFY 0x07 #define XDMF_DSM_ACCEPT 0x10 #define XDMF_DSM_DISCONNECT 0x11 #define XDMF_DSM_REGISTER_FILE 0x12 #define XDMF_DSM_REQUEST_PAGES 0x13 #define XDMF_DSM_REQUEST_FILE 0x14 #define XDMF_DSM_OPCODE_RESIZE 0x15 #define XDMF_DSM_REQUEST_ACCESS 0x16 #define XDMF_DSM_UNLOCK_FILE 0x17 #define XDMF_DSM_OPCODE_DONE 0xFF #define XDMF_DSM_SUCCESS 1 #define XDMF_DSM_FAIL -1 #ifdef __cplusplus // Forward Declarations class XdmfHDF5WriterDSM; // Includes #include #include /** * @brief Controls the data buffer for DSM. * * XdmfDSMBuffer takes the place of the H5FDdsmBuffer defined in H5FD. * It is primarily for allowing the XdmfDSM to interact with HDF5 dsm * without threads. */ class XDMFDSM_EXPORT XdmfDSMBuffer { public: friend class XdmfHDF5WriterDSM; XdmfDSMBuffer(); ~XdmfDSMBuffer(); /** * Broadcasts the provided comm from the specified core to all other cores. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#BroadcastComm * @until //#BroadcastComm * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python: * Unusable in python unless an object of a cpointer type is * passed via wrapped code * * * * @param comm The communicator to be transmitted * @param root The core that the broadcast is originating from */ void BroadcastComm(int *comm, int root); /** * One iteration of the service loop. * It is not advised to use this function manually. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#BufferService * @until //#BufferService * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerBufferwriter * @until #//getServerBufferwriter * @skipline #//BufferService * @until #//BufferService * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @param returnOpcode A variable that will hold the code at the * end of the loop * @return If the iteration executed without problem * returns XDMF_DSM_SUCCESS */ int BufferService(int *returnOpcode = 0); /** * Starts up the service loop. * The loop then executes until the op code "Done" is sent to this core. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#BufferServiceLoop * @until //#BufferServiceLoop * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerBufferwriter * @until #//getServerBufferwriter * @skipline #//BufferServiceLoop * @until #//BufferServiceLoop * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @param returnOpcode A variable that will hold the code at the * end of the loop */ void BufferServiceLoop(int *returnOpcode = 0); /** * Creates an internal buffer based on the information provided. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#Create * @until //#Create * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerBufferwriter * @until #//getServerBufferwriter * @skipline #//Create * @until #//Create * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @param newComm The communicator that will be used. * @param startId The index of the first server node * @param endId The index of the last server node */ void Create(MPI_Comm newComm, int startId = -1, int endId = -1); /** * Configures the Buffer to match the configuration details provided. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferrwriter * @until //#getServerBufferwriter * @skipline //#ConfigureUniform * @until //#ConfigureUniform * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerBufferwriter * @until #//getServerBufferwriter * @skipline #//ConfigureUniform * @until #//ConfigureUniform * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @param Comm The communicator that will be handling the * communications for the DSM * @param Length The length of the data buffer on server cores * @param StartId The id that the server cores will start on, * if set to -1 then it will default to 0 * @param EndId The id that the server cores will end on, * if set to -1 then it will be the last core * in the communicator * @param aBlockLength The block size of the data buffer, 0 is * no blocking * @param random Whether the assignment is random or cyclic. * Default is cyclic */ void ConfigureUniform(XdmfDSMCommMPI *Comm, long Length, int StartId = -1, int EndId = -1, long aBlockLength = 0, bool random = false); /** * Attempts to connect the buffer to the port that is currently set. * * Example of use: * * C++ * * @dontinclude XdmfConnectTest.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#ReadDsmPortName * @until //#ReadDsmPortName * @skipline //#Connect * @until //#Connect * @skipline //#Disconnectmanager * @until //#Disconnectmanager * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleConnectTest.py * @skipline #//initMPI * @until #//initMPI * @skipline #//ReadDsmPortName * @until #//ReadDsmPortName * @skipline #//Connect * @until #//Connect * @skipline #//Disconnectmanager * * @param persist Whether to try to connect repeatedly */ void Connect(bool persist = false); /** * Disconnects the buffer from the port it was connected to. * * Example of use: * * C++ * * @dontinclude XdmfConnectTest.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#ReadDsmPortName * @until //#ReadDsmPortName * @skipline //#Connect * @until //#Connect * @skipline //#Disconnectmanager * @until //#Disconnectmanager * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleConnectTest.py * @skipline #//initMPI * @until #//initMPI * @skipline #//ReadDsmPortName * @until #//ReadDsmPortName * @skipline #//Connect * @until #//Connect * @skipline #//Disconnectmanager * @until #//Disconnectmanager */ void Disconnect(); /** * Gets data from the server cores. * It is not advised to use this function manually. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#PutGet * @until //#PutGet * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * * Python: * Unusable in python unless an object of a cpointer type is passed via * wrapped code * Use the XdmfHDF5WriterDSM for this functionality * * * * @param Address The starting address of the data retrieved * @param aLength The length of the data to be retrieved * @param Data A pointer in which the data is to be stored * after retieval */ void Get(long Address, long aLength, void *Data); /** * Gets data from the server cores. This version is for paged allocation. * It is not advised to use this function manually. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#PutGetPaged * @until //#PutGetPaged * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * * Python: * Unusable in python unless an object of a cpointer type is passed via * wrapped code * Use the XdmfHDF5WriterDSM for this functionality * * @param pages A pointer to the list of pages to be written to * @param numPages The number of pages in the provided pointer * @param Address The starting address of the data retrieved * @param aLength The length of the data to be retrieved * @param Data A pointer in which the data is to be stored * after retieval */ void Get(unsigned int * pages, unsigned int numPages, long Address, long aLength, void *Data); /** * Gets the starting address and ending address for the core of the provided Id. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declaremanager * @until //#declaremanager * @skipline //#getServerManagerwriter * @until //#getServerManagerwriter * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#GetDsmBuffer * @until //#GetDsmBuffer * @skipline //#GetAddressRangeForId * @until //#GetAddressRangeForId * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python: * Unusable in python unless an object of a cpointer type is passed via * wrapped code * * * * @param Id The core for which the start and end address are * to be found * @param Start A pointer in which the start address is to be placed * @param End A pointer in which the end address is to be placed */ void GetAddressRangeForId(int Id, int *Start, int *End); /** * Gets the size of the blocks for the data buffer. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#GetBlockLengthbuffer * @until //#GetBlockLengthbuffer * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerBufferwriter * @until #//getServerBufferwriter * @skipline #//GetBlockLength * @until #//GetBlockLength * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @return The size of the blocks in the DSM buffer */ long GetBlockLength(); /** * Gets the Comm being used to facilitate the communications for the DSM * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#GetComm * @until //#GetComm * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerBufferwriter * @until #//getServerBufferwriter * @skipline #//GetComm * @until #//GetComm * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @return The Comm controlling the communications for the DSM */ XdmfDSMCommMPI * GetComm(); /** * Gets the data pointer that the buffer controls. * Should be NULL on non-server cores. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#GetDataPointer * @until //#GetDataPointer * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerBufferwriter * @until #//getServerBufferwriter * @skipline #//GetDataPointer * @until #//GetDataPointer * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @return The buffer's internal data pointer. */ char * GetDataPointer(); /** * Gets the DSM type currently being used. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebufferr * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#GetDsmTypebuffer * @until //#GetDsmTypebuffer * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerBufferwriter * @until #//getServerBufferwriter * @skipline #//GetDsmTypebuffer * @until #//GetDsmTypebuffer * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @return The integer representation of the DSM type */ int GetDsmType(); /** * Gets the address at the end of DSM buffer for this buffer. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#GetEndAddress * @until //#GetEndAddress * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerBufferwriter * @until #//getServerBufferwriter * @skipline #//GetEndAddress * @until #//GetEndAddress * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @return The end address of the DSM buffer */ int GetEndAddress(); /** * Gets the id of the last of the server cores that handle the DSM buffer. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#GetEndServerId * @until //#GetEndServerId * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerBufferwriter * @until #//getServerBufferwriter * @skipline #//GetEndServerId * @until #//GetEndServerId * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @return The id of the last core that serves as a DSM server */ int GetEndServerId(); /** * Gets the type of intercomm that the manager is currently using. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#GetInterCommType * @until //#GetInterCommType * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerBufferwriter * @until #//getServerBufferwriter * @skipline #//GetInterCommType * @until #//GetInterCommType * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @return They type of intercomm currently being used */ int GetInterCommType(); /** * Gets if the Buffer is connected to an intercomm * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#GetIsConnectedbuffer * @until //#GetIsConnectedbuffer * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerBufferwriter * @until #//getServerBufferwriter * @skipline #//GetIsConnectedbuffer * @until #//GetIsConnectedbuffer * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @return Whether the buffer is connected */ bool GetIsConnected(); /** * Gets if the buffer is a DSM server. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#GetIsServerbuffer * @until //#GetIsServerbuffer * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerBufferwriter * @until #//getServerBufferwriter * @skipline #//GetIsServerbuffer * @until #//GetIsServerbuffer * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @return If the Buffer is a DSM server */ bool GetIsServer(); /** * The length of the buffer per core. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#GetLength * @until //#GetLength * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerBufferwriter * @until #//getServerBufferwriter * @skipline #//GetLength * @until #//GetLength * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @return The length of the data buffer per core */ long GetLength(); /** * Gets the maximum size of the local buffer on server cores. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#GetLocalBufferSizeMBytes * @until //#GetLocalBufferSizeMBytes * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerBufferwriter * @until #//getServerBufferwriter * @skipline #//GetLocalBufferSizeMBytes * @until #//GetLocalBufferSizeMBytes * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @return the maximum size of the data buffer on server cores */ unsigned int GetLocalBufferSizeMBytes(); /** * Gets the factor by which the size is multiplied when resizing the local buffer. * A factor of 1 doubles the size of the local buffer when resizing. * A factor of 0.5 adds half the original size of the buffer. * * Example of use: * * C++ * * @dontinclude XdmfAcceptTest.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#OpenPort * @until //#OpenPort * @skipline //#SendAccept * @until //#SendAccept * @skipline //#finishwork * @until //#finishwork * @skipline //#ClosePort * @until //#ClosePort * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleAcceptTest.py * @skipline #//initMPI * @until #//initMPI * @skipline #//OpenPort * @until #//OpenPort * @skipline #//SendAccept * @until #//SendAccept * @skipline #//finishwork * @until #//finishwork * @skipline #//ClosePort * @until #//ClosePort * * @return The factor by which the buffer is resized. */ double GetResizeFactor(); /** * Gets the address at the beginning of the DSM buffer for this buffer. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#GetStartAddress * @until //#GetStartAddress * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerBufferwriter * @until #//getServerBufferwriter * @skipline #//GetStartAddress * @until #//GetStartAddress * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @return The beginning address of the DSM buffer */ int GetStartAddress(); /** * Gets the id of the first of the server cores that handle the DSM buffer. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#GetStartServerId * @until //#GetStartServerId * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerBufferwriter * @until #//getServerBufferwriter * @skipline #//GetStartServerId * @until #//GetStartServerId * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @return The id of the first core that serves as a DSM server */ int GetStartServerId(); /** * The total length of the data buffer when combining the buffers in all cores. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#GetTotalLength * @until //#GetTotalLength * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerBufferwriter * @until #//getServerBufferwriter * @skipline #//GetTotalLength * @until #//GetTotalLength * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @return The total length of the data buffer */ long GetTotalLength(); /** * Probes inter and intra comms until a command is found. * Then sets the comm that the command was found on to the provided variable * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#CommandHeader * @until //#CommandHeader * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python: * Unusable in python unless an object of a cpointer type is passed via wrapped code * * * * @param comm a pointer to the variable that the integer code for the * comm is placed in */ void ProbeCommandHeader(int *comm); /** * Puts data to the server cores. * It is not advised to use this function manually. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#PutGet * @until //#PutGet * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python: * Unusable in python unless an object of a cpointer type is passed * via wrapped code * Use the XdmfHDF5WriterDSM for this functionality * * * * @param Address The starting address that the data will * be placed at * @param aLength The length of the data to be sent * @param Data A pointer to the data to be sent */ void Put(long Address, long aLength, const void *Data); /** * Puts data to the server cores. * It is not advised to use this function manually. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#PutGetPaged * @until //#PutGetPaged * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python: * Unusable in python unless an object of a cpointer type is passed * via wrapped code * Use the XdmfHDF5WriterDSM for this functionality * * @param pages A pointer to the list of pages to be read from * @param numPages The number of pages in the provided pointer * @param Address The starting address that the data will * be placed at * @param aLength The length of the data to be sent * @param Data A pointer to the data to be sent */ void Put(unsigned int * pages, unsigned int numPages, haddr_t Address, haddr_t aLength, const void *Data); /** * Recieves an integer as an acknowledgement from the specified core. * It is not advised to use this function manually. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#SendRecvAcknowledgement * @until //#SendRecvAcknowledgement * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python: * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerBufferwriter * @until #//getServerBufferwriter * @skipline #//SendAcknowledgment * @until #//SendAcknowledgment * @skipline #//ReceiveAcknowledgment * @until #//ReceiveAcknowledgment * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @param source The core to recieve from * @param data The integer that the recieved data will be stored in * @param tag The tag associated with the acknowledgement * @param comm The comm over which the acknowldedgement will occur */ void ReceiveAcknowledgment(int source, int &data, int tag, int comm); /** * Recieves command data from either a specified or unspecified source. * If remoteSource is not provided any source currently sending a command is used. * It is not advised to use this function manually. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#CommandHeader * @until //#CommandHeader * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python: * Unusable in python unless an object of a cpointer type is passed * via wrapped code * * @param opcode A pointer to the location where the code * associated with the operation will be stored * @param source A pointer to the location where the index of * the source core will be stored * (will be the same as remoteSource if provided) * @param address A pointer to the location where the address * specified by the command will be stored * @param aLength A pointer to the location where the length of * the data specified by the command will be stored * @param comm The communicator over which the transmission * will occur * @param remoteSource If provided, the core being recieved from */ void ReceiveCommandHeader(int *opcode, int *source, int *address, int *aLength, int comm, int remoteSource = -1); /** * Recieves data from a specific core and stores it in a pointer. * It is not advised to use this function manually. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#SendRecvData * @until //#SendRecvData * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python: * Unusable in python unless an object of a cpointer type is passed * via wrapped code * * * * @param source The core data will be recieved from * @param data The pointer where the recieved data will be * stored * @param aLength The length of the data transmitted * @param tag The communication tag to be used for the * transmission * @param aAddress The location where the data will be written on * the data buffer * @param comm The comunicator over which the data transfer * will occur */ void ReceiveData(int source, char * data, int aLength, int tag, int aAddress, int comm); /** * With the Comm with ID 0 recieve information * about a server from another core on the intercomm. * Used to recieve server data from different managers. * It is not advised to use this function manually. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#SendRecvInfo * @until //#SendRecvInfo * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//SendRecvInfo * @until #//SendRecvInfo * @skipline #//finalizeMPI * @until #//finalizeMPI */ void ReceiveInfo(); /** * Registers a file with the provided information. Overwrites previously registered files. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#PageInfo * @until //#PageInfo * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python: * Unusable in python unless an object of a cpointer type is passed * via wrapped code * Use the XdmfHDF5WriterDSM for this functionality * * @param name The name of the file to be registered * @param pages The pages associated with the file to be registered * @param numPages The number of pages associated with the file to be registered * @param start The starting address for the file to be registered * @param end The ending address for the file to be registered */ int RegisterFile(char * name, unsigned int * pages, unsigned int numPages, haddr_t start, haddr_t end); /** * Requests a file's information from the DSM. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#PageInfo * @until //#PageInfo * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python: * Unusable in python unless an object of a cpointer type is passed * via wrapped code * Use the XdmfHDF5WriterDSM for this functionality * * @param name The name of the file * @param pages The pages associated with the file (output) * @param numPages The number of pages associated with the file (output) * @param start The starting address for the file (output) * @param end The ending address for the file (output) * @return XDMF_DSM_FAIL if the file does not exist in DSM, * otherwise XDMF_DSM_SUCCESS */ int RequestFileDescription(char * name, std::vector & pages, unsigned int & numPages, haddr_t & start, haddr_t & end); /** * Requests additional pages to cover needed data. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#PutGetPaged * @until //#PutGetPaged * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python: * Unusable in python unless an object of a cpointer type is passed * via wrapped code * Use the XdmfHDF5WriterDSM for this functionality * * @param name The name of the file * @param spaceRequired The space needed in bytes to fit the data needed * @param pages The pages associated with the file (output) * @param numPages The number of pages associated with the file (output) * @param start The starting address for the file (output) * @param end The ending address for the file (output) */ void RequestPages(char * name, haddr_t spaceRequired, std::vector & pages, unsigned int & numPages, haddr_t & start, haddr_t & end); /** * Tells the server cores to prepare to accept a new connection. * Then readies to accept a new connection. * * Example of use: * * C++ * * @dontinclude XdmfAcceptTest.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#OpenPort * @until //#OpenPort * @skipline //#SendAccept * @until //#SendAccept * @skipline //#finishwork * @until //#finishwork * @skipline //#ClosePort * @until //#ClosePort * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleAcceptTest.py * @skipline #//initMPI * @until #//initMPI * @skipline #//OpenPort * @until #//OpenPort * @skipline #//SendAccept * @until #//SendAccept * @skipline #//finishwork * @until #//finishwork * @skipline #//ClosePort * @until #//ClosePort * * @param numConnects The number of incoming connections to accept */ void SendAccept(unsigned int numConnects); /** * Sends an integer as an acknowledgement to the specified core. * It is not advised to use this function manually. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#SendRecvAcknowledgement * @until //#SendRecvAcknowledgement * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerBufferwriter * @until #//getServerBufferwriter * @skipline #//SendAcknowledgment * @until #//SendAcknowledgment * @skipline #//ReceiveAcknowledgment * @until #//ReceiveAcknowledgment * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @param dest The core to send to * @param data The integer to send * @param tag The tag associated with the acknowledgement * @param comm The comm over which the acknowldedgement will occur */ void SendAcknowledgment(int dest, int data, int tag, int comm); /** * Sends command data to a specified core. * It is not advised to use this function manually. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#CommandHeader * @until //#CommandHeader * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerBufferwriter * @until #//getServerBufferwriter * @skipline #//SendCommandHeader * @until #//SendCommandHeader * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @param opcode The code for the command to be sent * @param dest The core that the command is to be sent to * @param address The address to be referenced by the command * @param aLength The length of the data to be used by the command * @param comm The communicator over which the transmission will occur */ void SendCommandHeader(int opcode, int dest, int address, int aLength, int comm); /** * Sends data from a pointer to a specified core. * It is not advised to use this function manually. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#SendRecvData * @until //#SendRecvData * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerBufferwriter * @until #//getServerBufferwriter * @skipline #//SendData * @until #//SendData * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @param dest The core that the data will be sent to * @param data A pointer to the location of the data being sent * @param aLength The length of the data being sent * @param tag The communication tag to be used for the transmission * @param aAddress The address on the recieveing core's buffer that * the data is to be placed in * @param comm The communicator over which the data transfer * will take place */ void SendData(int dest, char * data, int aLength, int tag, int aAddress, int comm); /** * Ends the service loop server cores associated with this buffer * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#SendDone * @until //#SendDone * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//SendDone * @until #//SendDone * @skipline #//finalizeMPI * @until #//finalizeMPI */ void SendDone(); /** * From the Comm with ID 0 send out information * about the server to another core on the intercomm. * Used to send server data to different managers. * It is not advised to use this function manually. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#SendRecvInfo * @until //#SendRecvInfo * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//SendRecvInfo * @until #//SendRecvInfo * @skipline #//finalizeMPI * @until #//finalizeMPI */ void SendInfo(); /** * Sets the size of the blocks used in the data buffer. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#GetBlockLengthbuffer * @until //#GetBlockLengthbuffer * @skipline //#SetBlockLengthbuffer * @until //#SetBlockLengthbuffer * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerBufferwriter * @until #//getServerBufferwriter * @skipline #//GetBlockLength * @until #//GetBlockLength * @skipline #//SetBlockLength * @until #//SetBlockLength * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @param newBlock The new block size to be used */ void SetBlockLength(long newBlock); /** * Sets the Comm to be used to facilitate the communications for the DSM * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#GetComm * @until //#GetComm * @skipline //#SetComm * @until //#SetComm * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerBufferwriter * @until #//getServerBufferwriter * @skipline #//GetComm * @until #//GetComm * @skipline #//SetComm * @until #//SetComm * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @param newComm The communicator that is to be used by the DSM */ void SetComm(XdmfDSMCommMPI * newComm); /** * Sets the DSM type to the provided type. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#SetDsmTypebuffer * @until //#SetDsmTypebuffer * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerBufferwriter * @until #//getServerBufferwriter * @skipline #//SetDsmTypebuffer * @until #//SetDsmTypebuffer * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @param newDsmType The Dsm type that the buffer will be changed to */ void SetDsmType(int newDsmType); /** * Sets the type of intercomm that the DSM will use. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#SetInterCommType * @until //#SetInterCommType * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerBufferwriter * @until #//getServerBufferwriter * @skipline #//SetInterCommType * @until #//SetInterCommType * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @param newType The type of intercomm to be generated for now on */ void SetInterCommType(int newType); /** * Sets the Buffer's connection status. Used if the XdmfDSMCommMPI is * connected or disconnected manually. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#GetIsConnectedbuffer * @until //#GetIsConnectedbuffer * @skipline //#SetIsConnectedbuffer * @until //#SetIsConnectedbuffer * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerBufferwriter * @until #//getServerBufferwriter * @skipline #//GetIsConnectedbuffer * @until #//GetIsConnectedbuffer * @skipline #//SetIsConnectedbuffer * @until #//SetIsConnectedbuffer * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @param newStatus The new connection status */ void SetIsConnected(bool newStatus); /** * Sets the maximum size of the local buffer when generating data buffers for server cores. * When using blocked mode it generates a buffer that is a multiple of the block size * that is less than or equal to this number. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#GetLocalBufferSizeMBytes * @until //#GetLocalBufferSizeMBytes * @skipline //#SetLocalBufferSizeMBytes * @until //#SetLocalBufferSizeMBytes * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerBufferwriter * @until #//getServerBufferwriter * @skipline #//GetLocalBufferSizeMBytes * @until #//GetLocalBufferSizeMBytes * @skipline #//SetLocalBufferSizeMBytes * @until #//SetLocalBufferSizeMBytes * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @param newSize The new maximum size of the data buffer on the server cores */ void SetLocalBufferSizeMBytes(unsigned int newSize); /** * Sets whether the buffer is a DSM server. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#GetIsServerbuffer * @until //#GetIsServerbuffer * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerBufferwriter * @until #//getServerBufferwriter * @skipline #//GetIsServerbuffer * @until #//GetIsServerbuffer * @skipline #//SetIsServerbuffer * @until #//SetIsServerbuffer * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @param newIsServer Whether the buffer is to be a DSM server or not */ void SetIsServer(bool newIsServer); /** * Gets the factor by which the size is multiplied when resizing the local buffer. * A factor of 1 doubles the size of the local buffer when resizing. * A factor of 0.5 adds half the original size of the buffer. * * Example of use: * * C++ * * @dontinclude XdmfAcceptTest.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#OpenPort * @until //#OpenPort * @skipline //#SendAccept * @until //#SendAccept * @skipline //#finishwork * @until //#finishwork * @skipline //#ClosePort * @until //#ClosePort * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleAcceptTest.py * @skipline #//initMPI * @until #//initMPI * @skipline #//OpenPort * @until #//OpenPort * @skipline #//SendAccept * @until #//SendAccept * @skipline #//finishwork * @until #//finishwork * @skipline #//ClosePort * @until #//ClosePort * * @param newFactor The factor by which the buffer is resized. */ void SetResizeFactor(double newFactor); /** * Manually update the length of an individual core's buffer. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#GetLength * @until //#GetLength * @skipline //#UpdateLength * @until //#UpdateLength * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerBufferwriter * @until #//getServerBufferwriter * @skipline #//GetLength * @until #//GetLength * @skipline #//UpdateLength * @until #//UpdateLength * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @param newLength The new buffer length, in bytes. */ void UpdateLength(unsigned int newLength); /** * Releases all processes waiting on a specified dataset. Sends those processes a specified code. * * Example of use: * * C++ * * @dontinclude XdmfConnectTest2.cpp * @skipline //#initDSMWriterConnectRequired * @until //#initDSMWriterConnectRequired * @skipline //#buffernotify * @until //#buffernotify * * Python * * @dontinclude XdmfExampleConnectTest2.py * @skipline #//initDSMWriterConnectRequired * @until #//initDSMWriterConnectRequired * @skipline #//buffernotify * @until #//buffernotify * * @param filename The filename of the dataset to wait on. * @param datasetname The dataset name of the dataset to wait on. * @param code The code to be transmitted to waiting processes. */ void WaitRelease(std::string filename, std::string datasetname, int code); /** * Blocks until released by the a waitRelease on the corresponding dataset. * * Example of use: * * C++ * * @dontinclude XdmfConnectTest2.cpp * @skipline //#initDSMWriterConnectRequired * @until //#initDSMWriterConnectRequired * @skipline //#buffernotify * @until //#buffernotify * * Python * * @dontinclude XdmfExampleConnectTest2.py * @skipline #//initDSMWriterConnectRequired * @until #//initDSMWriterConnectRequired * @skipline #//buffernotify * @until #//buffernotify * * @param filename The filename of the dataset to wait on. * @param datasetname The dataset name of the dataset to wait on. * @return The code send from the release. */ int WaitOn(std::string filename, std::string datasetname); protected: class XDMF_file_desc { public: XDMF_file_desc() { name = NULL; start = 0; end = 0; numPages = 0; pages = NULL; } ~XDMF_file_desc() { } char * name; /* filename */ haddr_t start; /* current DSM start address */ haddr_t end; /* current DSM end address */ unsigned int numPages; /* number of pages assigned to the file */ unsigned int * pages; /* list of pages assigned to the file */ }; int AddressToId(int Address); void Lock(char * filename); int PageToId(int pageId); int PageToAddress(int pageId); void Unlock(char * filename); private: void SetLength(long aLength); class CommandMsg; class InfoMsg; bool IsServer; int EndAddress; int StartAddress; int StartServerId; int EndServerId; unsigned int LocalBufferSizeMBytes; unsigned int Length; unsigned int TotalLength; unsigned int BlockLength; XdmfDSMCommMPI * Comm; char * DataPointer; unsigned int NumPages; unsigned int PagesAssigned; int DsmType; int InterCommType; int CommChannel; bool IsConnected; double ResizeFactor; std::map > WaitingMap; std::map > LockedMap; std::map FileOwners; std::map FileDefinitions; }; #endif #ifdef __cplusplus extern "C" { #endif // C wrappers go here struct XDMFDSMBUFFER; // Simply as a typedef to ensure correct typing typedef struct XDMFDSMBUFFER XDMFDSMBUFFER; XDMFDSM_EXPORT XDMFDSMBUFFER * XdmfDSMBufferNew(); XDMFDSM_EXPORT void XdmfDSMBufferFree(XDMFDSMBUFFER * item); XDMFDSM_EXPORT int XdmfDSMBufferAddressToId(XDMFDSMBUFFER * buffer, int Address, int * status); XDMFDSM_EXPORT void XdmfDSMBufferBroadcastComm(XDMFDSMBUFFER * buffer, int *comm, int root, int * status); XDMFDSM_EXPORT int XdmfDSMBufferBufferService(XDMFDSMBUFFER * buffer, int *returnOpcode, int * status); XDMFDSM_EXPORT void XdmfDSMBufferBufferServiceLoop(XDMFDSMBUFFER * buffer, int *returnOpcode, int * status); XDMFDSM_EXPORT void XdmfDSMBufferConfigureUniform(XDMFDSMBUFFER * buffer, XDMFDSMCOMMMPI * Comm, long Length, int StartId, int EndId, long aBlockLength, int random, int * status); XDMFDSM_EXPORT void XdmfDSMBufferConnect(XDMFDSMBUFFER * buffer, int persist, int * status); XDMFDSM_EXPORT void XdmfDSMBufferCreate(XDMFDSMBUFFER * buffer, MPI_Comm comm, int startId, int endId, int * status); XDMFDSM_EXPORT void XdmfDSMBufferDisconnect(XDMFDSMBUFFER * buffer, int * status); XDMFDSM_EXPORT void XdmfDSMBufferGet(XDMFDSMBUFFER * buffer, long Address, long aLength, void * Data, int * status); XDMFDSM_EXPORT void XdmfDSMBufferGetAddressRangeForId(XDMFDSMBUFFER * buffer, int Id, int * Start, int * End, int * status); XDMFDSM_EXPORT long XdmfDSMBufferGetBlockLength(XDMFDSMBUFFER * buffer); XDMFDSM_EXPORT XDMFDSMCOMMMPI * XdmfDSMBufferGetComm(XDMFDSMBUFFER * buffer); XDMFDSM_EXPORT char * XdmfDSMBufferGetDataPointer(XDMFDSMBUFFER * buffer); XDMFDSM_EXPORT int XdmfDSMBufferGetDsmType(XDMFDSMBUFFER * buffer); XDMFDSM_EXPORT int XdmfDSMBufferGetEndAddress(XDMFDSMBUFFER * buffer); XDMFDSM_EXPORT int XdmfDSMBufferGetEndServerId(XDMFDSMBUFFER * buffer); XDMFDSM_EXPORT int XdmfDSMBufferGetInterCommType(XDMFDSMBUFFER * buffer); XDMFDSM_EXPORT int XdmfDSMBufferGetIsConnected(XDMFDSMBUFFER * buffer); XDMFDSM_EXPORT int XdmfDSMBufferGetIsServer(XDMFDSMBUFFER * buffer); XDMFDSM_EXPORT long XdmfDSMBufferGetLength(XDMFDSMBUFFER * buffer); XDMFDSM_EXPORT unsigned int XdmfDSMBufferGetLocalBufferSizeMBytes(XDMFDSMBUFFER * buffer); XDMFDSM_EXPORT double XdmfDSMBufferGetResizeFactor(XDMFDSMBUFFER * buffer); XDMFDSM_EXPORT int XdmfDSMBufferGetStartAddress(XDMFDSMBUFFER * buffer); XDMFDSM_EXPORT int XdmfDSMBufferGetStartServerId(XDMFDSMBUFFER * buffer); XDMFDSM_EXPORT long XdmfDSMBufferGetTotalLength(XDMFDSMBUFFER * buffer); XDMFDSM_EXPORT void XdmfDSMBufferProbeCommandHeader(XDMFDSMBUFFER * buffer, int * comm, int * status); XDMFDSM_EXPORT void XdmfDSMBufferPut(XDMFDSMBUFFER * buffer, long Address, long aLength, void * Data, int * status); XDMFDSM_EXPORT void XdmfDSMBufferReceiveAcknowledgment(XDMFDSMBUFFER * buffer, int source, int * data, int tag, int comm, int * status); XDMFDSM_EXPORT void XdmfDSMBufferReceiveCommandHeader(XDMFDSMBUFFER * buffer, int * opcode, int * source, int * address, int * aLength, int comm, int remoteSource, int * status); XDMFDSM_EXPORT void XdmfDSMBufferReceiveData(XDMFDSMBUFFER * buffer, int source, char * data, int aLength, int tag, int aAddress, int comm, int * status); XDMFDSM_EXPORT void XdmfDSMBufferReceiveInfo(XDMFDSMBUFFER * buffer, int * status); XDMFDSM_EXPORT void XdmfDSMBufferSendAccept(XDMFDSMBUFFER * buffer, unsigned int numConnects); XDMFDSM_EXPORT void XdmfDSMBufferSendAcknowledgment(XDMFDSMBUFFER * buffer, int dest, int data, int tag, int comm, int * status); XDMFDSM_EXPORT void XdmfDSMBufferSendCommandHeader(XDMFDSMBUFFER * buffer, int opcode, int dest, int address, int aLength, int comm, int * status); XDMFDSM_EXPORT void XdmfDSMBufferSendData(XDMFDSMBUFFER * buffer, int dest, char * data, int aLength, int tag, int aAddress, int comm, int * status); XDMFDSM_EXPORT void XdmfDSMBufferSendDone(XDMFDSMBUFFER * buffer, int * status); XDMFDSM_EXPORT void XdmfDSMBufferSendInfo(XDMFDSMBUFFER * buffer, int * status); XDMFDSM_EXPORT void XdmfDSMBufferSetBlockLength(XDMFDSMBUFFER * buffer, long newBlock); XDMFDSM_EXPORT void XdmfDSMBufferSetComm(XDMFDSMBUFFER * buffer, XDMFDSMCOMMMPI * newComm); XDMFDSM_EXPORT void XdmfDSMBufferSetDsmType(XDMFDSMBUFFER * buffer, int newDsmType); XDMFDSM_EXPORT void XdmfDSMBufferSetInterCommType(XDMFDSMBUFFER * buffer, int newType); XDMFDSM_EXPORT void XdmfDSMBufferSetIsConnected(XDMFDSMBUFFER * buffer, int newStatus); XDMFDSM_EXPORT void XdmfDSMBufferSetIsServer(XDMFDSMBUFFER * buffer, int newIsServer); XDMFDSM_EXPORT void XdmfDSMBufferSetLocalBufferSizeMBytes(XDMFDSMBUFFER * buffer, unsigned int newSize); XDMFDSM_EXPORT void XdmfDSMBufferSetResizeFactor(XDMFDSMBUFFER * buffer, double newFactor); XDMFDSM_EXPORT void XdmfDSMBufferWaitRelease(XDMFDSMBUFFER * buffer, char * filename, char * datasetname, int code); XDMFDSM_EXPORT int XdmfDSMBufferWaitOn(XDMFDSMBUFFER * buffer, char * filename, char * datasetname); #ifdef __cplusplus } #endif #endif /* XDMFDSMBUFFER_HPP_ */ xdmf-3.0+git20160803/core/dsm/XdmfHDF5WriterDSM.hpp0000640000175000017500000007117413003006557021376 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfHDF5WriterDSM.hpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef XDMFHDF5WRITERDSM_HPP_ #define XDMFHDF5WRITERDSM_HPP_ // C Compatible Includes #include #include #include #ifdef __cplusplus // Forward Declarations class XdmfDSMBuffer; // Includes /** * @brief Traverse the Xdmf graph and write heavy data stored in * XdmfArrays to a DSM buffer. * * XdmfHDF5WriterDSM traverses an Xdmf graph structure and writes data * stored in XdmfArrays to a DSM buffer. Writing begins by calling the * accept() operation on any XdmfItem and supplying this writer as the * parameter. The writer will write all XdmfArrays under the XdmfItem * to a DSM Buffer. It will also attach an XdmfHDF5ControllerDSM to * all XdmfArrays. * * This writer supports all heavy data writing modes listed in * XdmfHeavyDataWriter. */ class XDMFDSM_EXPORT XdmfHDF5WriterDSM : public XdmfHDF5Writer { public: friend class XdmfDSMBuffer; /** * Contruct XdmfHDF5WriterDSM, nonthreaded version * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#initwriterwithbuffer * @until //#initwriterwithbuffer * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//initwriterwithbuffer * @until #//initwriterwithbuffer * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @param filePath The location of the hdf5 file to output to on disk. * @param dsmBuffer The Buffer to write to. * @return A New XdmfHDF5WriterDSM */ static shared_ptr New(const std::string & filePath, XdmfDSMBuffer * const dsmBuffer); /** * Contruct XdmfHDF5WriterDSM, nonthreaded version * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @param filePath The location of the hdf5 file to output to on disk. * @param comm The communicator that the buffer will be created in. * @param bufferSize The size of the created buffer. * @param startCoreIndex The index of the first core in the server block * @param endCoreIndex The index of the last core in the server block * @param applicationName The name in the process description for this process * @return A New XdmfHDF5WriterDSM */ static shared_ptr New(const std::string & filePath, MPI_Comm comm, unsigned int bufferSize, int startCoreIndex, int endCoreIndex, std::string applicationName = "Application"); /** * Contruct XdmfHDF5WriterDSM, nonthreaded version * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwriterpagedgenerate * @until //#initwriterpagedgenerate * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwriterpagedgenerate * @until #//initwriterpagedgenerate * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @param filePath The location of the hdf5 file to output to on disk. * @param comm The communicator that the buffer will be created in. * @param bufferSize The size of the created buffer. * @param blockSize The size of the pages in the buffer. * @param resizeFactor The size of by which the buffer gets resized when * requesting beyond the size. * @param startCoreIndex The index of the first core in the server block * @param endCoreIndex The index of the last core in the server block * @param applicationName The name in the process description for this process * @return A New XdmfHDF5WriterDSM */ static shared_ptr New(const std::string & filePath, MPI_Comm comm, unsigned int bufferSize, unsigned int blockSize, double resizeFactor, int startCoreIndex, int endCoreIndex, std::string applicationName = "Application"); /** * Contruct XdmfHDF5WriterDSM, nonthreaded version. Does not start up a buffer * and must be connected to a DSMBuffer to function. * * Example of use: * * C++ * * @dontinclude XdmfConnectTest2.cpp * @skipline //#initDSMWriterConnectRequired * @until //#initDSMWriterConnectRequired * * Python * * @dontinclude XdmfExampleConnectTest2.py * @skipline #//initDSMWriterConnectRequired * @until #//initDSMWriterConnectRequired * * @param filePath The location of the hdf5 file to output to on disk. * @param comm The local communicator. */ static shared_ptr New(const std::string & filePath, MPI_Comm comm, std::string applicationName = "Application"); virtual ~XdmfHDF5WriterDSM(); void closeFile(); /** * Gets the number of values contained in the specified dataset. * * @param fileName The filename of the dataset to get the size of. * @param dataSetName The dataset name of the dataset to get the size of. * @return The size of the dataset queried. */ virtual int getDataSetSize(const std::string & fileName, const std::string & dataSetName); /** * Get if each write to dsm will send a notification to the accociated file name. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#getNotifyOnWrite * @until //#getNotifyOnWrite * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getNotifyOnWrite * @until #//getNotifyOnWrite * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @return Whether a notification will be sent */ bool getNotifyOnWrite(); /** * Gets the buffer for the non-threaded version of DSM * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerBufferwriter * @until #//getServerBufferwriter * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @return The XdmfDSMBuffer that is controlling the data for the DSM */ XdmfDSMBuffer * getServerBuffer(); /** * Checks if the DSM is in server mode or not. * True is server mode, false is threaded * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#getServerModewriter * @until //#getServerModewriter * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerModewriter * @until #//getServerModewriter * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @return If the DSM is in server mode or not */ bool getServerMode(); /** * Gets the Communicator that the workers are using to communicate between themselves * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#getWorkerCommwriter * @until //#getWorkerCommwriter * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getWorkerCommwriter * @until #//getWorkerCommwriter * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @return The comm that the workers are using. */ MPI_Comm getWorkerComm(); /** * Sets whether to allow the HDF5 writer to split data sets when writing to hdf5. * Splitting should only occur for massive data sets. * Setting to false assures compatibility with previous editions. * Default setting is false * In DSM this function has no effect because splitting would prevent the algorithm from working * * @param newAllow Whether to allow data sets to be split across hdf5 files. */ void setAllowSetSplitting(bool newAllow); /** * Sets the Writer's dsmBuffer to the provided buffer * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#setBufferwriter * @until //#setBufferwriter * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerBufferwriter * @until #//getServerBufferwriter * @skipline #//setBufferwriter * @until #//setBufferwriter * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @param newBuffer A pointer to the buffer to be set */ void setBuffer(XdmfDSMBuffer * newBuffer); /** * Used to switch between server and threaded mode. * True is server mode, false is threaded mode. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#setServerModewriter * @until //#setServerModewriter * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//setServerModewriter * @until #//setServerModewriter * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @param newMode The mode that the writer is to be set to. */ void setServerMode(bool newMode); /** * If true each write to dsm will send a notification to the accociated file name. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#setNotifyOnWrite * @until //#setNotifyOnWrite * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//setNotifyOnWrite * @until #//setNotifyOnWrite * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @param status Whether to send a notification */ void setNotifyOnWrite(bool status); /** * Sets the comm that the workers will use to communicate with other worker cores * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#getWorkerCommwriter * @until //#getWorkerCommwriter * @skipline //#setWorkerCommwriter * @until //#setWorkerCommwriter * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getWorkerCommwriter * @until #//getWorkerCommwriter * @skipline #//setWorkerCommwriter * @until #//setWorkerCommwriter * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @param comm The communicator that the worker will be using to communicate with the other worker cores. */ void setWorkerComm(MPI_Comm comm); /** * Sends a stop command to all the server cores that the writer is connected to, ending the DSM. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI */ void stopDSM(); /** * Restarts the DSM when called on server cores. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * @skipline //#restartDSMwriter * @until //#restartDSMwriter * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//restartDSMwriter * @until #//restartDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI */ void restartDSM(); void openFile(); using XdmfHeavyDataWriter::visit; void visit(XdmfArray & array, const shared_ptr visitor); /** * Releases all processes waiting on a specified dataset. Sends those processes a specified code. * * Example of use: * * C++ * * @dontinclude XdmfConnectTest2.cpp * @skipline //#initDSMWriterConnectRequired * @until //#initDSMWriterConnectRequired * @skipline //#notify * @until //#notify * * Python * * @dontinclude XdmfExampleConnectTest2.py * @skipline #//initDSMWriterConnectRequired * @until #//initDSMWriterConnectRequired * @skipline #//notify * @until #//notify * * @param fileName The filename of the dataset to wait on. * @param datasetName The dataset name of the dataset to wait on. * @param code The code to be transmitted to waiting processes. */ void waitRelease(std::string fileName, std::string datasetName, int code = 0); /** * Blocks until released by the a waitRelease on the corresponding dataset. * * Example of use: * * C++ * * @dontinclude XdmfConnectTest2.cpp * @skipline //#initDSMWriterConnectRequired * @until //#initDSMWriterConnectRequired * @skipline //#notify * @until //#notify * * Python * * @dontinclude XdmfExampleConnectTest2.py * @skipline #//initDSMWriterConnectRequired * @until #//initDSMWriterConnectRequired * @skipline #//notify * @until #//notify * * @param fileName The filename of the dataset to wait on. * @param datasetName The dataset name of the dataset to wait on. * @return The code send from the release. */ int waitOn(std::string fileName, std::string datasetName); XdmfHDF5WriterDSM(XdmfHDF5WriterDSM &); protected: XdmfHDF5WriterDSM(const std::string & filePath, XdmfDSMBuffer * const dsmBuffer); XdmfHDF5WriterDSM(const std::string & filePath, MPI_Comm comm, unsigned int bufferSize, int startCoreIndex, int endCoreIndex, std::string applicationName); XdmfHDF5WriterDSM(const std::string & filePath, MPI_Comm comm, unsigned int bufferSize, unsigned int blockSize, double resizeFactor, int startCoreIndex, int endCoreIndex, std::string applicationName); XdmfHDF5WriterDSM(const std::string & filePath, MPI_Comm comm, std::string applicationName); virtual shared_ptr createController(const std::string & hdf5FilePath, const std::string & descriptor, const shared_ptr type, const std::vector & start, const std::vector & stride, const std::vector & dimensions, const std::vector & dataspaceDimensions); /** * PIMPL */ class XdmfHDF5WriterDSMImpl : public XdmfHDF5WriterImpl { public: XdmfHDF5WriterDSMImpl(); virtual ~XdmfHDF5WriterDSMImpl(); virtual int openFile(const std::string & filePath, const int mDataSetId); void closeFile(); bool mDSMIsInit; bool mDSMLocked; }; private: XdmfHDF5WriterDSM(const XdmfHDF5WriterDSM &); // Not implemented. void operator=(const XdmfHDF5WriterDSM &); // Not implemented. XdmfDSMBuffer * mDSMServerBuffer; MPI_Comm mWorkerComm; bool mServerMode; bool mNotifyOnWrite; }; #endif #ifdef __cplusplus extern "C" { #endif // C wrappers go here struct XDMFHDF5WRITERDSM; // Simply as a typedef to ensure correct typing typedef struct XDMFHDF5WRITERDSM XDMFHDF5WRITERDSM; XDMFDSM_EXPORT XDMFHDF5WRITERDSM * XdmfHDF5WriterDSMNewFromServerBuffer(char * filePath, void * dsmBuffer, int * status); XDMFDSM_EXPORT XDMFHDF5WRITERDSM * XdmfHDF5WriterDSMNew(char * filePath, MPI_Comm comm, unsigned int bufferSize, int startCoreIndex, int endCoreIndex, char * applicationName, int * status); XDMFDSM_EXPORT XDMFHDF5WRITERDSM * XdmfHDF5WriterDSMNewPaged(char * filePath, MPI_Comm comm, unsigned int bufferSize, unsigned int blockSize, double resizeFactor, int startCoreIndex, int endCoreIndex, char * applicationName, int * status); XDMFDSM_EXPORT XDMFHDF5WRITERDSM * XdmfHDF5WriterDSMNewConnectRequired(char * filePath, MPI_Comm comm, char * applicationName, int * status); XDMFDSM_EXPORT int XdmfHDF5WriterDSMGetDataSetSize(XDMFHDF5WRITERDSM * writer, char * fileName, char * dataSetName); XDMFDSM_EXPORT XDMFDSMBUFFER * XdmfHDF5WriterDSMGetServerBuffer(XDMFHDF5WRITERDSM * writer); XDMFDSM_EXPORT int XdmfHDF5WriterDSMGetServerMode(XDMFHDF5WRITERDSM * writer); XDMFDSM_EXPORT MPI_Comm XdmfHDF5WriterDSMGetWorkerComm(XDMFHDF5WRITERDSM * writer); XDMFDSM_EXPORT void XdmfHDF5WriterDSMSetServerBuffer(XDMFHDF5WRITERDSM * writer, XDMFDSMBUFFER * newBuffer); XDMFDSM_EXPORT void XdmfHDF5WriterDSMSetServerMode(XDMFHDF5WRITERDSM * writer, int newMode); XDMFDSM_EXPORT void XdmfHDF5WriterDSMSetWorkerComm(XDMFHDF5WRITERDSM * writer, MPI_Comm comm, int * status); XDMFDSM_EXPORT void XdmfHDF5WriterDSMStopDSM(XDMFHDF5WRITERDSM * writer, int * status); XDMFDSM_EXPORT void XdmfHDF5WriterDSMRestartDSM(XDMFHDF5WRITERDSM * writer, int * status); XDMFDSM_EXPORT void XdmfHDF5WriterDSMWaitRelease(XDMFHDF5WRITERDSM * writer, char * fileName, char * datasetName, int code); XDMFDSM_EXPORT int XdmfHDF5WriterDSMWaitOn(XDMFHDF5WRITERDSM * writer, char * fileName, char * datasetName); XDMF_HDF5WRITER_C_CHILD_DECLARE(XdmfHDF5WriterDSM, XDMFHDF5WRITERDSM, XDMFDSM) XDMF_HEAVYWRITER_C_CHILD_DECLARE(XdmfHDF5WriterDSM, XDMFHDF5WRITERDSM, XDMFDSM) #ifdef __cplusplus } #endif #endif /* XDMFHDF5WRITERDSM_HPP_ */ xdmf-3.0+git20160803/core/dsm/XdmfDSM.hpp0000640000175000017500000000665113003006557017570 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfCore.hpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef _XDMF_HPP #ifndef _XDMFDSM_HPP #define _XDMFDSM_HPP /* Keep all our Win32 Conversions here */ #ifdef _WIN32 /* Used to export/import from the dlls */ #undef XDMFCORE_EXPORT #define XDMFCORE_EXPORT __declspec(dllimport) #undef XDMFCORE_TEMPLATE #define XDMFCORE_TEMPLATE extern #ifdef XdmfDSM_EXPORTS #define XDMFDSM_EXPORT __declspec(dllexport) #define XDMFDSM_TEMPLATE #else /* Xdmf_EXPORTS */ #define XDMFDSM_EXPORT __declspec(dllimport) #define XDMFDSM_TEMPLATE extern #endif /* Xdmf_EXPORTS */ /* Compiler Warnings */ #ifndef XDMF_DEBUG #pragma warning( disable : 4231 ) /* nonstandard extension used : 'extern' before template explicit instantiation */ #pragma warning( disable : 4251 ) /* needs to have dll-interface to be used by clients (Most of these guys are in private */ #pragma warning( disable : 4275 ) /* non dll-interface class 'std::_Container_base_aux' used as base for dll-interface class */ #pragma warning( disable : 4373 ) /* virtual function overrides, parameters only differed by const/volatile qualifiers */ #pragma warning( disable : 4101 ) /* 'exception' : unreferenced local variable */ #pragma warning( disable : 4355 ) /* 'this' : used in base member initializer list */ #pragma warning( disable : 4748 ) /* /GS can not protect parameters and local variables from local buffer overrun (turned off op)*/ #endif /* XDMF_DEBUG */ /* Compiler Optimizations will result in an 'internal compiler error', so turn them off */ #pragma optimize("g", off) #else /* _WIN32 */ /* We don't need to export/import since there are no dlls */ #define XDMFCORE_EXPORT #define XDMFDSM_EXPORT #define XDMFCORE_TEMPLATE #define XDMFDSM_TEMPLATE #endif /* _WIN32 */ #endif /* _XDMFCORE_HPP */ #endif /*_XDMF_HPP */ xdmf-3.0+git20160803/core/dsm/XdmfDSMDescription.hpp0000640000175000017500000000747113003006557021775 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfDSMDescription.hpp */ /* */ /* Author: */ /* Andrew Burns */ /* andrew.j.burns2@us.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2013 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef XDMFDSMDESCRIPTION_HPP_ #define XDMFDSMDESCRIPTION_HPP_ // C Compatible Includes #include "XdmfCore.hpp" #include "XdmfItem.hpp" #include "XdmfHeavyDataDescription.hpp" #ifdef __cplusplus /** * @brief Holds information about a dsm buffer so that a process can connect. * * XdmfDSMDescription stores the information required to connect * to an existing DSM buffer */ class XDMFCORE_EXPORT XdmfDSMDescription : public XdmfHeavyDataDescription { public: /** * */ static shared_ptr New(); virtual ~XdmfDSMDescription(); LOKI_DEFINE_VISITABLE(XdmfDSMDescription, XdmfItem) static const std::string ItemTag; std::map getItemProperties() const; virtual std::string getItemTag() const; std::string getPortDescription() const; using XdmfItem::insert; void setPortDescription(std::string portDesc); virtual void traverse(const shared_ptr visitor); XdmfDSMDescription(XdmfDSMDescription &); protected: XdmfDSMDescription(); virtual void populateItem(const std::map & itemProperties, const std::vector > & childItems, const XdmfCoreReader * const reader); private: XdmfDSMDescription(const XdmfDSMDescription &); // Not implemented. void operator=(const XdmfDSMDescription &); // Not implemented. std::string mPortDescription; }; #ifdef _WIN32 XDMFCORE_TEMPLATE template class XDMFCORE_EXPORT shared_ptr; XDMFCORE_TEMPLATE template class XDMFCORE_EXPORT Loki::Visitor, shared_ptr >; #endif #endif #ifdef __cplusplus extern "C" { #endif // C wrappers go here struct XDMFDSMDESCRIPTION; // Simply as a typedef to ensure correct typing typedef struct XDMFDSMDESCRIPTION XDMFDSMDESCRIPTION; XDMFCORE_EXPORT XDMFDSMDESCRIPTION * XdmfDSMDescriptionNew(); // C Wrappers for parent classes are generated by macros XDMF_ITEM_C_CHILD_DECLARE(XdmfDSMDescription, XDMFDSMDESCRIPTION, XDMFCORE) #ifdef __cplusplus } #endif #endif /* XDMFDSMDESCRIPTION_HPP_ */ xdmf-3.0+git20160803/core/dsm/XdmfDSMCommMPI.hpp0000640000175000017500000012345213003006557020751 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfDSMCommMPI.hpp */ /* */ /* Author: */ /* Andrew Burns */ /* andrew.j.burns2@us.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2013 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef XDMFDSMCOMMMPI_HPP_ #define XDMFDSMCOMMMPI_HPP_ // C Compatible Includes #include #include // Definitions #define XDMF_DSM_COMM_MPI 0x11 #define XDMF_DSM_INTRA_COMM 0x00 #define XDMF_DSM_INTER_COMM 0x01 #define XDMF_DSM_ANY_COMM 0x02 #define XDMF_DSM_SERVER_ID XDMF_DSM_INTRA_COMM #define XDMF_DSM_CLIENT_ID XDMF_DSM_INTER_COMM #define XDMF_DSM_NUM_CONNECTION_IDS 0x02 #define XDMF_DSM_DEFAULT_TAG 0x80 #define XDMF_DSM_COMMAND_TAG 0x81 #define XDMF_DSM_SERVER_ACK_TAG 0x82 #define XDMF_DSM_CLIENT_ACK_TAG 0x83 #define XDMF_DSM_PUT_DATA_TAG 0x84 #define XDMF_DSM_GET_DATA_TAG 0x85 #define XDMF_DSM_EXCHANGE_TAG 0x86 #define XDMF_DSM_ANY_TAG -1 #define XDMF_DSM_ANY_SOURCE -2 #define XDMF_DSM_SUCCESS 1 #define XDMF_DSM_FAIL -1 #ifdef __cplusplus // Forward Declarations // Includes #include #include /** * @brief Holds communicators for interacting with H5FD dsm. * * XdmfDSMCommMPI takes the place of the H5FDdsmComm defined in H5FD. * It provides more access to the the intra and inter communicators. * It is primarily for allowing the XdmfDSM to interact with HDF5 dsm without threads. */ class XDMFDSM_EXPORT XdmfDSMCommMPI { public: // To allow these classes to set // Process structure directly. friend class XdmfDSMBuffer; XdmfDSMCommMPI(); ~XdmfDSMCommMPI(); /** * Accepts connections to the port currently named by DsmPortName. * Called on server side, accepts from core 0. * * Example of use: * * C++ * * @dontinclude XdmfAcceptTest.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#OpenPort * @until //#OpenPort * @skipline //#manualAccept * @until //#manualAccept * @skipline //#finishwork * @until //#finishwork * @skipline //#ClosePort * @until //#ClosePort * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleAcceptTest.py * @skipline #//initMPI * @until #//initMPI * @skipline #//OpenPort * @until #//OpenPort * @skipline #//manualAccept * @until #//manualAccept * @skipline #//finishwork * @until #//finishwork * @skipline #//ClosePort * @until #//ClosePort */ void Accept(unsigned int numConnections = 1); /** * Equivalent to MPI_Allgather. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#GetComm * @until //#GetComm * @skipline //#DSMAllGather * @until //#DSMAllGather * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * Unusable in python unless an object of a cpointer type is passed via * wrapped code * * @param sendbuf The Buffer that the gathered values will be placed in. * @param sendbytes The size of the values to be gathered per core. * @param recvbuf The Buffer that the gathered values will be taken from. * @param recvbytes The size of the values to be sent per core. * @param comm The Int code for the communicator to be used. */ void AllGather(void *sendbuf, int sendbytes, void *recvbuf, int recvbytes, int comm); /** * Equivalent to MPI_Barrier * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#GetComm * @until //#GetComm * @skipline //#DSMBarrier * @until //#DSMBarrier * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerBufferwriter * @until #//getServerBufferwriter * @skipline #//GetComm * @until #//GetComm * @skipline #//DSMBarrier * @until #//DSMBarrier * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @param comm The Int code for the communicator to be used. */ void Barrier(int comm); /** * Equivalent to MPI_Bcast * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#GetComm * @until //#GetComm * @skipline //#DSMBroadcast * @until //#DSMBroadcast * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * Unusable in python unless an object of a cpointer type is passed via * wrapped code * * @param pointer Pointer to what is being broadcasted * @param sizebytes Size of the pointer to be broadcast. * @param root Core that the broadcast originates from * @param comm The Int code for the communicator to be used. */ void Broadcast(void * pointer, int sizebytes, int root, int comm); /** * Closes the port currently named by DsmPortName. * * Example of use: * * C++ * * @dontinclude XdmfAcceptTest.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#OpenPort * @until //#OpenPort * @skipline //#SendAccept * @until //#SendAccept * @skipline //#finishwork * @until //#finishwork * @skipline //#ClosePort * @until //#ClosePort * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleAcceptTest.py * @skipline #//initMPI * @until #//initMPI * @skipline #//OpenPort * @until #//OpenPort * @skipline #//SendAccept * @until #//SendAccept * @skipline #//finishwork * @until #//finishwork * @skipline #//ClosePort * @until #//ClosePort */ void ClosePort(); /** * If core ID is 0 then attempts to connect to the port currently named by DsmPortName * * Example of use: * * C++ * * @dontinclude XdmfConnectTest.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#ReadDsmPortName * @until //#ReadDsmPortName * @skipline //#manualConnect * @until //#manualConnect * @skipline //#Disconnectcomm * @until //#Disconnectcomm * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleConnectTest.py * @skipline #//initMPI * @until #//initMPI * @skipline #//ReadDsmPortName * @until #//ReadDsmPortName * @skipline #//manualConnect * @until #//manualConnect * @skipline #//Disconnectcomm * @until #//Disconnectcomm * * @return Whether the connection was successful or not */ int Connect(); /** * Disconnects the intercomm if not in static intercomm mode. * Then sets the intercomm to MPI_COMM_NULL. * * Example of use: * * C++ * * @dontinclude XdmfConnectTest.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#ReadDsmPortName * @until //#ReadDsmPortName * @skipline //#manualConnect * @until //#manualConnect * @skipline //#Disconnectcomm * @until //#Disconnectcomm * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleConnectTest.py * @skipline #//initMPI * @until #//initMPI * @skipline #//ReadDsmPortName * @until #//ReadDsmPortName * @skipline #//manualConnect * @until #//manualConnect * @skipline #//Disconnectcomm * @until #//Disconnectcomm */ void Disconnect(); /** * Sets the IntraComm to the provided comm by duplicating it. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#commsplit * @until //#commsplit * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#GetComm * @until //#GetComm * @skipline //#DupComm * @until //#DupComm * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerBufferwriter * @until #//getServerBufferwriter * @skipline #//GetComm * @until #//GetComm * @skipline #//DupComm * @until #//DupComm * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @param comm The comm to be used as the IntraComm */ void DupComm(MPI_Comm comm); /** * Sets the intercomm to the communicator provided by duplicating it. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#commsplit * @until //#commsplit * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#DupInterComm * @until //#DupInterComm * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//GetInterComm * @until #//GetInterComm * @skipline #//DupInterComm * @until #//DupInterComm * @skipline #//finalizeMPI * @until #//finalizeMPI * * @param comm The comm to be used as the intercomm */ void DupInterComm(MPI_Comm comm); /** * Gets the name by which this application will be referenced in the DSM process structure. * * Example of use: * * C++ * * @dontinclude XdmfConnectTest.cpp * @skipline //#initMPI * @until //#initMPI * @skipline #//SetApplicationName * @until #//SetApplicationName * @skipline //#ReadDsmPortName * @until //#ReadDsmPortName * @skipline //#Connect * @until //#Connect * @skipline #//GetApplicationName * @until #//GetApplicationName * * Python * * @dontinclude XdmfExampleConnectTest.py * @skipline #//initMPI * @until #//initMPI * @skipline #//SetApplicationName * @until #//SetApplicationName * @skipline #//ReadDsmPortName * @until #//ReadDsmPortName * @skipline #//Connect * @until #//Connect * @skipline #//GetApplicationName * @until #//GetApplicationName * * @return The name by which the current application is referenced. */ std::string GetApplicationName(); /** * Gets the current file name that connection info will be written to. * * Example of use: * * C++ * * @dontinclude XdmfAcceptTest.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#GetDsmFileName * @until //#GetDsmFileName * @skipline //#OpenPort * @until //#OpenPort * @skipline //#SendAccept * @until //#SendAccept * @skipline //#finishwork * @until //#finishwork * @skipline //#ClosePort * @until //#ClosePort * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleAcceptTest.py * @skipline #//initMPI * @until #//initMPI * @skipline #//GetDsmFileName * @until #//GetDsmFileName * @skipline #//OpenPort * @until #//OpenPort * @skipline #//SendAccept * @until #//SendAccept * @skipline #//finishwork * @until #//finishwork * @skipline #//ClosePort * @until #//ClosePort * * @return The file name where connection info will be written */ std::string GetDsmFileName(); /** * Gets the port name that will be connected to when Connect/Accept is called. * * Example of use: * * C++ * * @dontinclude XdmfConnectTest.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#ReadDsmPortName * @until //#ReadDsmPortName * @skipline //#GetDsmPortName * @until //#GetDsmPortName * @skipline //#manualConnect * @until //#manualConnect * @skipline //#Disconnectcomm * @until //#Disconnectcomm * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleConnectTest.py * @skipline #//initMPI * @until #//initMPI * @skipline #//ReadDsmPortName * @until #//ReadDsmPortName * @skipline #//GetDsmPortName * @until #//GetDsmPortName * @skipline #//manualConnect * @until #//manualConnect * @skipline #//Disconnectcomm * @until #//Disconnectcomm * * @return a pointer to the character string that specifies the port */ char * GetDsmPortName(); /** * Gets the process structure within the dsm. Process 0 is at index 0 of the vector. * * Example of use: * * C++ * * @dontinclude XdmfConnectTest.cpp * @skipline //#initMPI * @until //#initMPI * @skipline #//SetApplicationName * @until #//SetApplicationName * @skipline //#ReadDsmPortName * @until //#ReadDsmPortName * @skipline //#Connect * @until //#Connect * @skipline #//GetApplicationName * @until #//GetApplicationName * @skipline #//GetDsmProcessStructure * @until #//GetDsmProcessStructure * * Python * * @dontinclude XdmfExampleConnectTest.py * @skipline #//initMPI * @until #//initMPI * @skipline #//SetApplicationName * @until #//SetApplicationName * @skipline #//ReadDsmPortName * @until #//ReadDsmPortName * @skipline #//Connect * @until #//Connect * @skipline #//GetApplicationName * @until #//GetApplicationName * @skipline #//GetDsmProcessStructure * @until #//GetDsmProcessStructure * * @return A vector that contains a list of application names and numbers of cores allocated. */ std::vector > GetDsmProcessStructure(); /** * Gets the Id with regards to the IntraComm. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#GetComm * @until //#GetComm * @skipline //#GetId * @until //#GetId * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerBufferwriter * @until #//getServerBufferwriter * @skipline #//GetComm * @until #//GetComm * @skipline #//GetId * @until #//GetId * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @return The Id of the core with regards to the IntraComm */ int GetId(); /** * Gets the communicator that is currently functioning as the intercomm. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#GetInterComm * @until //#GetInterComm * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//GetInterComm * @until #//GetInterComm * @skipline #//finalizeMPI * @until #//finalizeMPI * * @return The communicator currently serving as the intercomm. */ MPI_Comm GetInterComm(); /** * Gets the type of the InterComm. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#GetComm * @until //#GetComm * @skipline //#GetInterCommType * @until //#GetInterCommType * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerBufferwriter * @until #//getServerBufferwriter * @skipline #//GetComm * @until #//GetComm * @skipline #//GetInterCommType * @until #//GetInterCommType * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @return An integer representation of the InterComm's type */ int GetInterCommType(); /** * Gets the Id with regards to the InterComm. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#GetComm * @until //#GetComm * @skipline //#GetInterId * @until //#GetInterId * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerBufferwriter * @until #//getServerBufferwriter * @skipline #//GetComm * @until #//GetComm * @skipline #//GetInterId * @until #//GetInterId * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @return The Id of the core with regards to the IntraComm */ int GetInterId(); /** * Gets the number of cores contained in the InterComm. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#GetComm * @until //#GetComm * @skipline //#GetInterSize * @until //#GetInterSize * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerBufferwriter * @until #//getServerBufferwriter * @skipline #//GetComm * @until #//GetComm * @skipline #//GetInterSize * @until #//GetInterSize * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @return The number of cores in the InterComm */ int GetInterSize(); /** * Gets the communicator that is currently functioning as the intracomm. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#GetComm * @until //#GetComm * @skipline //#GetIntraComm * @until //#GetIntraComm * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerBufferwriter * @until #//getServerBufferwriter * @skipline #//GetComm * @until #//GetComm * @skipline #//GetIntraComm * @until #//GetIntraComm * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @return The communicator currently serving as the intracomm. */ MPI_Comm GetIntraComm(); /** * Gets the number of cores contained in the IntraComm. * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#GetComm * @until //#GetComm * @skipline //#GetIntraSize * @until //#GetIntraSize * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerBufferwriter * @until #//getServerBufferwriter * @skipline #//GetComm * @until #//GetComm * @skipline #//GetIntraSize * @until #//GetIntraSize * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI * * @return The number of cores in the IntraComm */ int GetIntraSize(); /** * If this is true then any created Comms will pull their dsm file name * from the environment instead of using the default. * The default value for this is false. * * Example of use: * * C++ * * @dontinclude XdmfConnectTest.cpp * @skipline //#initMPI * @until //#initMPI * * Python * * @dontinclude XdmfExampleConnectTest.py * @skipline #//initMPI * @until #//initMPI * * @return Whether the filename is being pulled from the environment. */ static bool GetUseEnvFileName(); /** * Initializes the Intracomm rank and size to the associated variables * in the internal structure * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#GetComm * @until //#GetComm * @skipline //#initcomm * @until //#initcomm * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleDSMNoThread.py * @skipline #//initMPI * @until #//initMPI * @skipline #//initwritevector * @until #//initwritevector * @skipline #//initwritergenerate * @until #//initwritergenerate * @skipline #//startworksection * @until #//startworksection * @skipline #//getServerBufferwriter * @until #//getServerBufferwriter * @skipline #//GetComm * @until #//GetComm * @skipline #//initcomm * @until #//initcomm * @skipline #//stopDSMwriter * @until #//stopDSMwriter * @skipline #//finalizeMPI * @until #//finalizeMPI */ void Init(); /** * Opens a port and stores the port name in DsmPortName. * * Example of use: * * C++ * * @dontinclude XdmfAcceptTest.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#OpenPort * @until //#OpenPort * @skipline //#SendAccept * @until //#SendAccept * @skipline //#finishwork * @until //#finishwork * @skipline //#ClosePort * @until //#ClosePort * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleAcceptTest.py * @skipline #//initMPI * @until #//initMPI * @skipline #//OpenPort * @until #//OpenPort * @skipline #//SendAccept * @until #//SendAccept * @skipline #//finishwork * @until #//finishwork * @skipline #//ClosePort * @until #//ClosePort */ void OpenPort(); /** * Equivalent to MPI_Iprobe * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#GetComm * @until //#GetComm * @skipline //#DSMSendRecv * @until //#DSMSendRecv * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * Unusable in python unless an object of a cpointer type is passed via * wrapped code * * @param comm The Int code for the communicator to be used. (output) */ void Probe(int *comm); /** * Reads the connection information from the current DSMfile. * * Example of use: * * C++ * * @dontinclude XdmfConnectTest.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#ReadDsmPortName * @until //#ReadDsmPortName * @skipline //#manualConnect * @until //#manualConnect * @skipline //#Disconnectcomm * @until //#Disconnectcomm * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleConnectTest.py * @skipline #//initMPI * @until #//initMPI * @skipline #//ReadDsmPortName * @until #//ReadDsmPortName * @skipline #//manualConnect * @until #//manualConnect * @skipline #//Disconnectcomm * @until #//Disconnectcomm */ void ReadDsmPortName(); /** * Equivalent to MPI_recv * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#GetComm * @until //#GetComm * @skipline //#DSMSendRecv * @until //#DSMSendRecv * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * Unusable in python unless an object of a cpointer type is passed via * wrapped code * * @param pointer The pointer to place recieved data into. * @param sizebytes The size of the buffer being transmitted. * @param coreFrom The core to recieve data from. * @param comm The Int code for the communicator to be used. * @param tag The tag for the communication. */ void Receive(void * pointer, int sizebytes, int coreFrom, int comm, int tag); /** * Equivalent to MPI_send * * Example of use: * * C++ * * @dontinclude ExampleXdmfDSMNoThread.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#initwritevector * @until //#initwritevector * @skipline //#initwritergenerate * @until //#initwritergenerate * @skipline //#startworksection * @until //#startworksection * @skipline //#declarebuffer * @until //#declarebuffer * @skipline //#getServerBufferwriter * @until //#getServerBufferwriter * @skipline //#GetComm * @until //#GetComm * @skipline //#DSMSendRecv * @until //#DSMSendRecv * @skipline //#endworksection * @until //#endworksection * @skipline //#stopDSMwriter * @until //#stopDSMwriter * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * Unusable in python unless an object of a cpointer type is passed via * wrapped code * * @param pointer The pointer to send. * @param sizebytes The size of the buffer being transmitted. * @param coreTo The core to send data to. * @param comm The Int code for the communicator to be used. * @param tag The tag for the communication. */ void Send(void * pointer, int sizebytes, int coreTo, int comm, int tag); /** * Sets the name by which this process will be referenced in the DSM process structure. * * Default is "Application" * * Example of use: * * C++ * * @dontinclude XdmfConnectTest.cpp * @skipline //#initMPI * @until //#initMPI * @skipline #//SetApplicationName * @until #//SetApplicationName * * Python * * @dontinclude XdmfExampleConnectTest.py * @skipline #//initMPI * @until #//initMPI * @skipline #//SetApplicationName * @until #//SetApplicationName * * @param newName The name by which the application will now be referenced. */ void SetApplicationName(std::string newName); /** * Sets the file name that connection info will be written to. * * Example of use: * * C++ * * @dontinclude XdmfAcceptTest.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#GetDsmFileName * @until //#GetDsmFileName * @skipline //#SetDsmFileName * @until //#SetDsmFileName * @skipline //#OpenPort * @until //#OpenPort * @skipline //#SendAccept * @until //#SendAccept * @skipline //#finishwork * @until //#finishwork * @skipline //#ClosePort * @until //#ClosePort * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleAcceptTest.py * @skipline #//initMPI * @until #//initMPI * @skipline #//GetDsmFileName * @until #//GetDsmFileName * @skipline #//SetDsmFileName * @until #//SetDsmFileName * @skipline #//OpenPort * @until #//OpenPort * @skipline #//SendAccept * @until #//SendAccept * @skipline #//finishwork * @until #//finishwork * @skipline #//ClosePort * @until #//ClosePort * * @param filename The file name where connection info will be written */ void SetDsmFileName(std::string filename); /** * Sets the port name that will be connected to when Connect/Accept is called. * Data is copied, so the provided string is not modified. * * Example of use: * * C++ * * @dontinclude XdmfConnectTest.cpp * @skipline //#initMPI * @until //#initMPI * @skipline //#ReadDsmPortName * @until //#ReadDsmPortName * @skipline //#GetDsmPortName * @until //#GetDsmPortName * @skipline //#manualConnect * @until //#manualConnect * @skipline //#Disconnectcomm * @until //#Disconnectcomm * @skipline //#finalizeMPI * @until //#finalizeMPI * * Python * * @dontinclude XdmfExampleConnectTest.py * @skipline #//initMPI * @until #//initMPI * @skipline #//ReadDsmPortName * @until #//ReadDsmPortName * @skipline #//GetDsmPortName * @until #//GetDsmPortName * @skipline #//SetDsmPortName * @until #//SetDsmPortName * @skipline #//manualConnect * @until #//manualConnect * @skipline #//Disconnectcomm * @until #//Disconnectcomm * * @param hostName a pointer to the character string that specifies the port */ void SetDsmPortName(const char *hostName); /** * Sets whether created comms should use a filename specified * in the environment or the default value. * Default value is false (use default file name). * * Example of use: * * C++ * * @dontinclude XdmfConnectTest.cpp * @skipline //#initMPI * @until //#initMPI * * Python * * @dontinclude XdmfExampleConnectTest.py * @skipline #//initMPI * @until #//initMPI * * @param status Whether to pull the filename from the environment. */ static void SetUseEnvFileName(bool status); protected: void SetDsmProcessStructure(std::vector > & newStructure); private: MPI_Comm IntraComm; int Id; int IntraSize; MPI_Comm InterComm; int InterId; int InterSize; int InterCommType; char DsmPortName[MPI_MAX_PORT_NAME]; std::string DsmFileName; static bool UseEnvFileName; bool HasOpenedPort; std::string ApplicationName; // This is a vector of std::vector > DsmProcessStructure; //#ifdef OPEN_MPI std::vector PreviousDsmPortNames; //#endif }; #endif #ifdef __cplusplus extern "C" { #endif // C wrappers go here struct XDMFDSMCOMMMPI; // Simply as a typedef to ensure correct typing typedef struct XDMFDSMCOMMMPI XDMFDSMCOMMMPI; XDMFDSM_EXPORT XDMFDSMCOMMMPI * XdmfDSMCommMPINew(); XDMFDSM_EXPORT void XdmfDSMCommMPIFree(XDMFDSMCOMMMPI * item); XDMFDSM_EXPORT void XdmfDSMCommMPIAccept(XDMFDSMCOMMMPI * dsmComm, unsigned int numConnections, int * status); XDMFDSM_EXPORT void XdmfDSMCommMPIClosePort(XDMFDSMCOMMMPI * dsmComm, int * status); XDMFDSM_EXPORT int XdmfDSMCommMPIConnect(XDMFDSMCOMMMPI * dsmComm, int * status); XDMFDSM_EXPORT void XdmfDSMCommMPIDisconnect(XDMFDSMCOMMMPI * dsmComm, int * status); XDMFDSM_EXPORT void XdmfDSMCommMPIDupComm(XDMFDSMCOMMMPI * dsmComm, MPI_Comm comm, int * status); XDMFDSM_EXPORT void XdmfDSMCommMPIDupInterComm(XDMFDSMCOMMMPI * dsmComm, MPI_Comm comm, int * status); XDMFDSM_EXPORT char * XdmfDSMCommMPIGetApplicationName(XDMFDSMCOMMMPI * dsmComm); XDMFDSM_EXPORT char * XdmfDSMCommMPIGetDsmFileName(XDMFDSMCOMMMPI * dsmComm); XDMFDSM_EXPORT char * XdmfDSMCommMPIGetDsmPortName(XDMFDSMCOMMMPI * dsmComm); XDMFDSM_EXPORT void XdmfDSMCommMPIGetDsmProcessStructure(XDMFDSMCOMMMPI * dsmComm, char ** names, unsigned int * coreCount, int * numApplications); XDMFDSM_EXPORT int XdmfDSMCommMPIGetId(XDMFDSMCOMMMPI * dsmComm); XDMFDSM_EXPORT MPI_Comm XdmfDSMCommMPIGetInterComm(XDMFDSMCOMMMPI * dsmComm); XDMFDSM_EXPORT int XdmfDSMCommMPIGetInterCommType(XDMFDSMCOMMMPI * dsmComm); XDMFDSM_EXPORT int XdmfDSMCommMPIGetInterId(XDMFDSMCOMMMPI * dsmComm); XDMFDSM_EXPORT int XdmfDSMCommMPIGetInterSize(XDMFDSMCOMMMPI * dsmComm); XDMFDSM_EXPORT MPI_Comm XdmfDSMCommMPIGetIntraComm(XDMFDSMCOMMMPI * dsmComm); XDMFDSM_EXPORT int XdmfDSMCommMPIGetIntraSize(XDMFDSMCOMMMPI * dsmComm); XDMFDSM_EXPORT int XdmfDSMCommMPIGetUseEnvFileName(XDMFDSMCOMMMPI * dsmComm); XDMFDSM_EXPORT void XdmfDSMCommMPIInit(XDMFDSMCOMMMPI * dsmComm, int * status); XDMFDSM_EXPORT void XdmfDSMCommMPIOpenPort(XDMFDSMCOMMMPI * dsmComm, int * status); XDMFDSM_EXPORT void XdmfDSMCommMPIReadDsmPortName(XDMFDSMCOMMMPI * dsmComm); XDMFDSM_EXPORT void XdmfDSMCommMPISetApplicationName(XDMFDSMCOMMMPI * dsmComm, char * newName); XDMFDSM_EXPORT void XdmfDSMCommMPISetDsmFileName(XDMFDSMCOMMMPI * dsmComm, char * filename); XDMFDSM_EXPORT void XdmfDSMCommMPISetDsmPortName(XDMFDSMCOMMMPI * dsmComm, char * hostName); XDMFDSM_EXPORT void XdmfDSMCommMPISetUseEnvFileName(XDMFDSMCOMMMPI * dsmComm, int status); #ifdef __cplusplus } #endif #endif /* XDMFDSMCOMMMPI_HPP_ */ xdmf-3.0+git20160803/core/dsm/XdmfDSMDriver.cpp0000640000175000017500000011240413003006557020731 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfDSMDriver.cpp */ /* */ /* Author: */ /* Andrew Burns */ /* andrew.j.burns2@us.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2013 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ /*========================================================================= This code is derived from an earlier work and is distributed with permission from, and thanks to ... =========================================================================*/ /*============================================================================ Project : H5FDdsm Module : H5FDdsmDriver.cxx H5FDdsm.c Authors: John Biddiscombe Jerome Soumagne biddisco@cscs.ch soumagne@cscs.ch Copyright (C) CSCS - Swiss National Supercomputing Centre. You may use modify and and distribute this code freely providing 1) This copyright notice appears on all copies of source code 2) An acknowledgment appears with any substantial usage of the code 3) If this code is contributed to any other open source project, it must not be reformatted such that the indentation, bracketing or overall style is modified significantly. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. This work has received funding from the European Community's Seventh Framework Programme (FP7/2007-2013) under grant agreement 225967 âxtMuSEâOC ============================================================================*/ #include #include #include #include #include #include #include #include typedef struct XDMF_dsm_t { H5FD_t pub; /* public stuff, must be first */ char *name; /* for equivalence testing */ void *local_buf_ptr; /* underlying local DSM buffer */ size_t local_buf_len; /* local DSM buffer length */ haddr_t eoa; /* end of address marker */ haddr_t eof; /* end of file marker */ haddr_t start; /* current DSM start address */ haddr_t end; /* current DSM end address */ hbool_t read_only; /* file access is read-only */ hbool_t dirty; /* dirty marker */ unsigned int numPages; /* number of pages assigned to the file */ } XDMF_dsm_t; typedef struct XDMF_dsm_fapl_t { void *local_buf_ptr; /* local buffer pointer */ size_t local_buf_len; /* local buffer length */ } XDMF_dsm_fapl_t; typedef struct { long start; long end; } XdmfDSMEntry; /* The driver identification number, initialized at runtime */ static hid_t XDMF_DSM_g = 0; //from driver XdmfDSMBuffer *dsmBuffer = NULL; std::map fileEOF; // holding previously created files std::map > filePages; #define MAXADDR ((haddr_t)((~(size_t)0)-1)) #define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || (A) > (haddr_t)MAXADDR) #define SIZE_OVERFLOW(Z) ((Z) > (hsize_t)MAXADDR) #define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ HADDR_UNDEF==(A)+(Z) || \ (size_t)((A)+(Z))<(size_t)(A)) extern "C" { #include "H5FDprivate.h" /* File drivers */ #include "H5private.h" /* Generic Functions */ #include "H5ACprivate.h" /* Metadata cache */ #include "H5Dprivate.h" /* Dataset functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fprivate.h" /* File access */ #include "H5FDmpi.h" /* MPI-based file drivers */ #include "H5Iprivate.h" /* IDs */ #include "H5Pprivate.h" /* Property lists */ #include /* Private Prototypes */ static void *XDMF_dsm_fapl_get(H5FD_t *_file); static void *XDMF_dsm_fapl_copy(const void *_old_fa); static herr_t XDMF_dsm_fapl_free(void *_fa); static H5FD_t *XDMF_dsm_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); static herr_t XDMF_dsm_close(H5FD_t *_file); static herr_t XDMF_dsm_query(const H5FD_t *_f1, unsigned long *flags); static haddr_t XDMF_dsm_get_eoa(const H5FD_t *_file, H5FD_mem_t type); static herr_t XDMF_dsm_set_eoa(H5FD_t * _file, H5FD_mem_t type, haddr_t addr); static haddr_t XDMF_dsm_get_eof(const H5FD_t *_file); static herr_t XDMF_dsm_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, void *buf); static herr_t XDMF_dsm_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, const void *buf); static herr_t XDMF_dsm_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing); static int XDMF_dsm_mpi_rank(const H5FD_t *_file); static int XDMF_dsm_mpi_size(const H5FD_t *_file); static MPI_Comm XDMF_dsm_communicator(const H5FD_t *_file); /* The DSM file driver information */ static const H5FD_class_mpi_t XDMF_dsm_g = { { "dsm", /* name */ MAXADDR, /* maxaddr */ H5F_CLOSE_SEMI, /* fc_degree */ #if H5_VERSION_GE(1,9,0) XDMF_dsm_term, /* terminate */ #endif NULL, /* sb_size */ NULL, /* sb_encode */ NULL, /* sb_decode */ sizeof(XDMF_dsm_fapl_t), /* fapl_size */ XDMF_dsm_fapl_get, /* fapl_get */ XDMF_dsm_fapl_copy, /* fapl_copy */ XDMF_dsm_fapl_free, /* fapl_free */ 0, /* dxpl_size */ NULL, /* dxpl_copy */ NULL, /* dxpl_free */ XDMF_dsm_open, /* open */ XDMF_dsm_close, /* close */ NULL, /* cmp */ XDMF_dsm_query, /* query */ NULL, /* get_type_map */ NULL, /* alloc */ NULL, /* free */ #ifdef H5_HAVE_VFD_EXTENSIONS XDMF_dsm_term, /* terminate */ #endif XDMF_dsm_get_eoa, /* get_eoa */ XDMF_dsm_set_eoa, /* set_eoa */ XDMF_dsm_get_eof, /* get_eof */ NULL, /* get_handle */ XDMF_dsm_read, /* read */ XDMF_dsm_write, /* write */ XDMF_dsm_flush, /* flush */ NULL, /* truncate */ NULL, /* lock */ NULL, /* unlock */ H5FD_FLMAP_SINGLE /* fl_map */ }, XDMF_dsm_mpi_rank, /* get_rank */ XDMF_dsm_mpi_size, /* get_size */ XDMF_dsm_communicator /* get_comm */ }; #define H5_INTERFACE_INIT_FUNC XDMF_dsm_init_interface static herr_t XDMF_dsm_init_interface(void) { #if H5_VERSION_GE(1,8,9) FUNC_ENTER_NOAPI_NOINIT_NOERR #else FUNC_ENTER_NOAPI_NOINIT_NOFUNC(XDMF_dsm_init_interface) #endif FUNC_LEAVE_NOAPI(XDMF_dsm_init()) } void XdmfUnused(void) { //To remove warning about XDMF_dsm_init_interface being unused XDMF_dsm_init_interface(); } hid_t XDMF_dsm_init(void) { hid_t ret_value; /* Return value */ #if H5_VERSION_GE(1,8,9) FUNC_ENTER_NOAPI(FAIL) #else FUNC_ENTER_NOAPI(XDMF_dsm_init, FAIL) #endif if (H5I_VFL != H5Iget_type(XDMF_DSM_g)) {// registering the driver XDMF_DSM_g = H5FD_register(&XDMF_dsm_g, sizeof(H5FD_class_mpi_t), FALSE); } /* Set return value */ ret_value = XDMF_DSM_g;// return value is the new id of the driver // Removed because error handling isn't called in this function //done: if (err_occurred) { /* Nothing */ } FUNC_LEAVE_NOAPI(ret_value) } #if H5_VERSION_GE(1,9,0) herr_t #else void #endif XDMF_dsm_term(void) { #if H5_VERSION_GE(1,9,0) herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) #else #if H5_VERSION_GE(1,8,9) FUNC_ENTER_NOAPI_NOINIT_NOERR #else FUNC_ENTER_NOAPI_NOINIT_NOFUNC(XDMF_dsm_term) #endif #endif if (SUCCEED != xdmf_dsm_free()) { #if H5_VERSION_GE(1,9,0) HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "dsm_free failed"); #endif } /* Reset VFL ID */ XDMF_DSM_g = 0; #if H5_VERSION_GE(1,9,0) done: FUNC_LEAVE_NOAPI(ret_value) #else FUNC_LEAVE_NOAPI_VOID #endif } herr_t XDMF_dsm_set_options(unsigned long flags) { herr_t ret_value = SUCCEED; #if H5_VERSION_GE(1,8,9) FUNC_ENTER_NOAPI(FAIL) #else FUNC_ENTER_NOAPI(XDMF_dsm_set_options, FAIL) #endif if (SUCCEED != xdmf_dsm_set_options(flags)) HGOTO_ERROR(H5E_VFL, H5E_CANTMODIFY, FAIL, "cannot set options") done: if (err_occurred) { /* Nothing */ } FUNC_LEAVE_NOAPI(ret_value) } herr_t XDMF_dsm_set_manager(void *manager) { herr_t ret_value = SUCCEED; #if H5_VERSION_GE(1,8,9) FUNC_ENTER_NOAPI(FAIL) #else FUNC_ENTER_NOAPI(XDMF_dsm_set_manager, FAIL) #endif xdmf_dsm_set_manager(manager); // Removed because error handling isn't called in this function //done: if (err_occurred) { /* Nothing */ } FUNC_LEAVE_NOAPI(ret_value) } herr_t XDMFH5Pset_fapl_dsm(hid_t fapl_id, MPI_Comm intra_comm, void *local_buf_ptr, size_t local_buf_len) { //printf("XDMFH5Pset_fapl_dsm\n"); XDMF_dsm_fapl_t fa; herr_t ret_value = SUCCEED; H5P_genplist_t *plist; /* Property list pointer */ #if H5_VERSION_GE(1,8,9) FUNC_ENTER_API(FAIL) #else FUNC_ENTER_API(XDMFH5Pset_fapl_dsm, FAIL) #endif /* Check arguments */ if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") if (!xdmf_dsm_get_manager()) { // throw error here instead of calling alloc XdmfError::message(XdmfError::FATAL, "Error: In set_fapl_dsm No manager set"); } if (SUCCEED != xdmf_dsm_get_properties(NULL, &fa.local_buf_ptr, &fa.local_buf_len)) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "cannot get DSM properties") if (!xdmf_dsm_is_server() && !xdmf_dsm_is_connected()) { //it should already be connected when this is called //potentially the connect will connect via port xdmf_dsm_connect(); } /* duplication is done during driver setting */ ret_value = H5P_set_driver(plist, XDMF_DSM, &fa); done: FUNC_LEAVE_API(ret_value) } herr_t XDMFH5Pget_fapl_dsm(hid_t fapl_id, MPI_Comm *intra_comm /* out */, void **local_buf_ptr_ptr /* out */, size_t *local_buf_len_ptr /* out */) { XDMF_dsm_fapl_t *fa; MPI_Comm intra_comm_tmp = MPI_COMM_NULL; H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value = SUCCEED; int mpi_code; #if H5_VERSION_GE(1,8,9) FUNC_ENTER_API(FAIL) #else FUNC_ENTER_API(XDMFH5Pget_fapl_dsm, FAIL) #endif if (NULL == (plist = (H5P_genplist_t*) H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") if (XDMF_DSM != H5P_get_driver(plist)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver") if (NULL == (fa = (XDMF_dsm_fapl_t*) H5P_get_driver_info(plist))) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info") if (intra_comm) { if (MPI_SUCCESS != (mpi_code = MPI_Comm_dup(dsmBuffer->GetComm()->GetIntraComm(), &intra_comm_tmp))) HMPI_GOTO_ERROR(FAIL, "MPI_Comm_dup failed", mpi_code) *intra_comm = intra_comm_tmp; } if (local_buf_ptr_ptr) *local_buf_ptr_ptr = fa->local_buf_ptr; if (local_buf_len_ptr) *local_buf_len_ptr = fa->local_buf_len; done: if (FAIL == ret_value) { /* need to free anything created here */ } FUNC_LEAVE_API(ret_value) } static void * XDMF_dsm_fapl_get(H5FD_t *_file) { //printf("XDMF_dsm_fapl_get\n"); XDMF_dsm_t *file = (XDMF_dsm_t*) _file; XDMF_dsm_fapl_t *fa = NULL; void *ret_value = NULL; int mpi_code; #if H5_VERSION_GE(1,8,9) FUNC_ENTER_NOAPI_NOINIT #else FUNC_ENTER_NOAPI_NOINIT(XDMF_dsm_fapl_get) #endif HDassert(file); HDassert(XDMF_DSM == file->pub.driver_id); if (NULL == (fa = (XDMF_dsm_fapl_t *) calloc((size_t)1, sizeof(XDMF_dsm_fapl_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") fa->local_buf_ptr = file->local_buf_ptr; fa->local_buf_len = file->local_buf_len; /* Set return value */ ret_value = fa; done: if ((NULL == ret_value) && err_occurred) { /* need to free anything created here */ } FUNC_LEAVE_NOAPI(ret_value) } static void * XDMF_dsm_fapl_copy(const void *_old_fa) { //printf("XDMF_dsm_fapl_copy\n"); void *ret_value = NULL; const XDMF_dsm_fapl_t *old_fa = (const XDMF_dsm_fapl_t*)_old_fa; XDMF_dsm_fapl_t *new_fa = NULL; int mpi_code; #if H5_VERSION_GE(1,8,9) FUNC_ENTER_NOAPI_NOINIT #else FUNC_ENTER_NOAPI_NOINIT(XDMF_dsm_fapl_copy) #endif if(NULL == (new_fa = (XDMF_dsm_fapl_t *) calloc((size_t)1, sizeof(XDMF_dsm_fapl_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Copy the general information */ HDmemcpy(new_fa, old_fa, sizeof(XDMF_dsm_fapl_t)); ret_value = new_fa; done: if ((NULL == ret_value) && err_occurred) { /* cleanup */ if (new_fa) free(new_fa); } FUNC_LEAVE_NOAPI(ret_value) } static herr_t XDMF_dsm_fapl_free(void *_fa) { herr_t ret_value = SUCCEED; XDMF_dsm_fapl_t *fa = (XDMF_dsm_fapl_t*)_fa; #if H5_VERSION_GE(1,8,9) FUNC_ENTER_NOAPI_NOINIT_NOERR #else FUNC_ENTER_NOAPI_NOINIT_NOFUNC(XDMF_dsm_fapl_free) #endif assert(fa); free(fa); FUNC_LEAVE_NOAPI(ret_value) } static H5FD_t * XDMF_dsm_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { XDMF_dsm_t *file = NULL; int mpi_rank; /* MPI rank of this process */ int mpi_size; /* Total number of MPI processes */ int mpi_code; /* mpi return code */ const XDMF_dsm_fapl_t *fa = NULL; H5P_genplist_t *plist; /* Property list pointer */ H5FD_t *ret_value = NULL; herr_t dsm_code = SUCCEED; unsigned int * newpages = NULL; #if H5_VERSION_GE(1,8,9) FUNC_ENTER_NOAPI_NOINIT #else FUNC_ENTER_NOAPI_NOINIT(XDMF_dsm_open) #endif /* Check arguments */ if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name") if (0 == maxaddr || HADDR_UNDEF == maxaddr) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr") if (ADDR_OVERFLOW(maxaddr)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "maxaddr overflow") if (H5P_DEFAULT != fapl_id) { if (NULL == (plist = (H5P_genplist_t*) H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") fa = (const XDMF_dsm_fapl_t *) H5P_get_driver_info(plist); assert(fa); } /* Get the MPI rank of this process and the total number of processes */ mpi_rank = dsmBuffer->GetComm()->GetId(); mpi_size = dsmBuffer->GetComm()->GetIntraSize(); /* Build the return value and initialize it */ if (NULL == (file = (XDMF_dsm_t *) calloc((size_t)1, sizeof(XDMF_dsm_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") if (name && *name) { file->name = HDstrdup(name); } /* Get address information from DSM */ if (!xdmf_dsm_get_manager()) HGOTO_ERROR(H5E_VFL, H5E_NOTFOUND, NULL, "DSM buffer not found") file->local_buf_ptr = fa->local_buf_ptr; file->local_buf_len = fa->local_buf_len; // Poll DSM for file information // If file exists fill data from the DSM's results // Otherwise reset data. // For now, multiple files are only supported by paged mode. if (dsmBuffer->GetComm()->GetId() == 0) { if (dsmBuffer->RequestFileDescription(file->name, filePages[file->name], file->numPages, file->start, file->end) == XDMF_DSM_FAIL) { // File not found file->numPages = 0; file->start = 0; file->end = 0; } } dsmBuffer->GetComm()->Broadcast(&file->start, sizeof(haddr_t), 0, XDMF_DSM_INTRA_COMM); dsmBuffer->GetComm()->Broadcast(&file->end, sizeof(haddr_t), 0, XDMF_DSM_INTRA_COMM); dsmBuffer->GetComm()->Broadcast(&file->numPages, sizeof(unsigned int), 0, XDMF_DSM_INTRA_COMM); if (file->numPages > 0) { if (dsmBuffer->GetComm()->GetId() != 0) { filePages[file->name].clear(); for (unsigned int i = 0; i < file->numPages; ++i) { filePages[file->name].push_back(0); } } dsmBuffer->GetComm()->Broadcast(&(filePages[file->name][0]), sizeof(unsigned int) * file->numPages, 0, XDMF_DSM_INTRA_COMM); } if (H5F_ACC_RDWR & flags) { file->read_only = FALSE; } else { file->read_only = TRUE; } if (H5F_ACC_CREAT & flags) { /* Reset start and end markers */ if (fileEOF.count(name) == 0) // Need to store the eof and eoa of the files here { file->start = 0; file->end = 0; file->eof = 0; fileEOF[name] = 0; } else { file->eof = fileEOF[name]; } } else { file->eof = file->end - file->start; } // Poll DSM for page info if in paged mode /* Don't let any proc return until all have created the file. */ if ((H5F_ACC_CREAT & flags)) { dsmBuffer->GetComm()->Barrier(XDMF_DSM_INTRA_COMM); } /* Set return value */ ret_value = (H5FD_t *) file; done: if((ret_value == NULL) && err_occurred) { if (file && file->name) HDfree(file->name); if (file) free(file); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } static herr_t XDMF_dsm_close(H5FD_t *_file) { XDMF_dsm_t *file = (XDMF_dsm_t*) _file; herr_t ret_value = SUCCEED; /* Return value */ int mpi_code; herr_t dsm_code = SUCCEED; unsigned long unlock_flag; #if H5_VERSION_GE(1,8,9) FUNC_ENTER_NOAPI_NOINIT #else FUNC_ENTER_NOAPI_NOINIT(XDMF_dsm_close) #endif assert(file); assert(XDMF_DSM == file->pub.driver_id); if (!file->read_only) { if (dsmBuffer->GetComm()->GetId() == 0) { // Update DSM file description if (dsmBuffer->RegisterFile(file->name, &(filePages[file->name][0]), file->numPages, file->start, file->end) == XDMF_DSM_FAIL) { dsm_code = FAIL; } } /* Wait for the DSM entry to be updated */ dsmBuffer->GetComm()->Broadcast(&dsm_code, sizeof(herr_t), 0, XDMF_DSM_INTRA_COMM); if (SUCCEED != dsm_code) HGOTO_ERROR(H5E_VFL, H5E_CANTUPDATE, FAIL, "cannot update DSM entries") /* * Be sure that everyone's here before releasing resources (done with * collective op). Gather all the dirty flags because some processes may * not have written yet. */ hbool_t * dirtyaccum = new hbool_t[dsmBuffer->GetComm()->GetIntraSize()](); dsmBuffer->GetComm()->AllGather(&file->dirty, sizeof(hbool_t), dirtyaccum, sizeof(hbool_t), XDMF_DSM_INTRA_COMM); for (unsigned int i = 0; i < dsmBuffer->GetComm()->GetIntraSize(); ++i) { if (dirtyaccum[i] > file->dirty) { file->dirty = dirtyaccum[i]; } } delete dirtyaccum; } /* if ReleaseLockOnClose was set, unlocks using whatever notification * unlock_flag was set. */ unlock_flag = (file->dirty) ? XDMF_DSM_NOTIFY_DATA : XDMF_DSM_NOTIFY_NONE; /* Release resources */ if (file->name) HDfree(file->name); HDmemset(file, 0, sizeof(XDMF_dsm_t)); free(file); done: if (err_occurred) { /* Nothing */ } FUNC_LEAVE_NOAPI(ret_value) } static herr_t XDMF_dsm_query(const H5FD_t UNUSED *_file, unsigned long *flags /* out */) { #if H5_VERSION_GE(1,8,9) FUNC_ENTER_NOAPI_NOINIT_NOERR #else FUNC_ENTER_NOAPI_NOINIT_NOFUNC(XDMF_dsm_query) #endif /* Set the VFL feature flags that this driver supports */ if (flags) { *flags = 0; *flags |= H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ #ifdef H5FD_FEAT_HAS_MPI *flags |= H5FD_FEAT_HAS_MPI; /* This driver uses MPI */ #endif #ifdef H5FD_FEAT_ALLOCATE_EARLY *flags |= H5FD_FEAT_ALLOCATE_EARLY; /* Allocate space early instead of late */ #endif } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) } static haddr_t XDMF_dsm_get_eoa(const H5FD_t *_file, H5FD_mem_t UNUSED type) { const XDMF_dsm_t *file = (const XDMF_dsm_t*) _file; #if H5_VERSION_GE(1,8,9) FUNC_ENTER_NOAPI_NOINIT_NOERR #else FUNC_ENTER_NOAPI_NOINIT_NOFUNC(XDMF_dsm_get_eoa) #endif assert(file); assert(XDMF_DSM == file->pub.driver_id); FUNC_LEAVE_NOAPI(file->eoa) } static herr_t XDMF_dsm_set_eoa(H5FD_t * _file, H5FD_mem_t UNUSED type, haddr_t addr) { XDMF_dsm_t *file = (XDMF_dsm_t*) _file; herr_t ret_value = SUCCEED; /* Return value */ int mpi_code; herr_t dsm_code = SUCCEED; #if H5_VERSION_GE(1,8,9) FUNC_ENTER_NOAPI_NOINIT #else FUNC_ENTER_NOAPI_NOINIT(XDMF_dsm_set_eoa) #endif assert(file); assert(XDMF_DSM == file->pub.driver_id); if (ADDR_OVERFLOW(addr)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "address overflow") file->eoa = addr; // If EoA is smaller than the end of the file the address is within page boundaries // If this is not the case then we need to reserve more pages. if ((file->start + file->eoa) > file->end && (((XdmfDSMBuffer *)xdmf_dsm_get_manager())->GetDsmType() == XDMF_DSM_TYPE_BLOCK_CYCLIC || ((XdmfDSMBuffer *)xdmf_dsm_get_manager())->GetDsmType() == XDMF_DSM_TYPE_BLOCK_RANDOM) && !file->read_only) { unsigned int pageCount = file->numPages; unsigned int * newpages; if (dsmBuffer->GetComm()->GetId() == 0) { // Request additional pages to store data dsmBuffer->RequestPages(file->name, file->start + file->eoa - file->end, filePages[file->name], file->numPages, file->start, file->end); } // If requesting pages resized the pointer // Reset the total length to match the new size. unsigned int currentLength = dsmBuffer->GetLength(); dsmBuffer->GetComm()->Broadcast(¤tLength, sizeof(unsigned int), 0, XDMF_DSM_INTRA_COMM); if (currentLength != dsmBuffer->GetLength()) { dsmBuffer->UpdateLength(currentLength); } dsmBuffer->GetComm()->Broadcast(&file->end, sizeof(haddr_t), 0, XDMF_DSM_INTRA_COMM); dsmBuffer->GetComm()->Broadcast(&file->numPages, sizeof(unsigned int), 0, XDMF_DSM_INTRA_COMM); if (pageCount != file->numPages) { if (dsmBuffer->GetComm()->GetId() != 0) { filePages[file->name].clear(); for (unsigned int i = 0; i < file->numPages; ++i) { filePages[file->name].push_back(0); } } dsmBuffer->GetComm()->Broadcast(&(filePages[file->name][0]), sizeof(unsigned int) * file->numPages, 0, XDMF_DSM_INTRA_COMM); } } file->end = MAX((file->start + file->eoa), file->end); file->eof = file->end - file->start; fileEOF[file->name] = file->eof; if (!file->read_only) { if (dsmBuffer->GetComm()->GetId() == 0) { // Update DSM file description if (dsmBuffer->RegisterFile(file->name, &(filePages[file->name][0]), file->numPages, file->start, file->end) == XDMF_DSM_FAIL) { dsm_code = FAIL; } } /* Wait for the DSM entry to be updated */ dsmBuffer->GetComm()->Broadcast(&dsm_code, sizeof(herr_t), 0, XDMF_DSM_INTRA_COMM); if (SUCCEED != dsm_code) HGOTO_ERROR(H5E_VFL, H5E_CANTUPDATE, FAIL, "cannot update DSM entries") } done: if (err_occurred) { /* Nothing */ } FUNC_LEAVE_NOAPI(ret_value) } static haddr_t XDMF_dsm_get_eof(const H5FD_t *_file) { const XDMF_dsm_t *file = (const XDMF_dsm_t*) _file; #if H5_VERSION_GE(1,8,9) FUNC_ENTER_NOAPI_NOINIT_NOERR #else FUNC_ENTER_NOAPI_NOINIT_NOFUNC(XDMF_dsm_get_eof) #endif assert(file); assert(XDMF_DSM == file->pub.driver_id); FUNC_LEAVE_NOAPI(MAX(file->eof, file->eoa)) } static herr_t XDMF_dsm_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, haddr_t addr, size_t size, void *buf /* out */) { XDMF_dsm_t *file = (XDMF_dsm_t*) _file; herr_t ret_value = SUCCEED; /* Return value */ #if H5_VERSION_GE(1,8,9) FUNC_ENTER_NOAPI_NOINIT #else FUNC_ENTER_NOAPI_NOINIT(XDMF_dsm_read) #endif assert(file); assert(XDMF_DSM == file->pub.driver_id); assert(buf); /* Check for overflow conditions */ if (HADDR_UNDEF == addr) HGOTO_ERROR(H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed") if (REGION_OVERFLOW(addr, size)) HGOTO_ERROR(H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed") if (addr + size > file->eoa) HGOTO_ERROR(H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed") /* Read the part which is before the EOF marker */ if (addr < file->eof) { size_t nbytes; hsize_t temp_nbytes; temp_nbytes = file->eof - addr; H5_CHECK_OVERFLOW(temp_nbytes,hsize_t,size_t); nbytes = MIN(size,(size_t)temp_nbytes); if (((XdmfDSMBuffer *)xdmf_dsm_get_manager())->GetDsmType() == XDMF_DSM_TYPE_BLOCK_CYCLIC || ((XdmfDSMBuffer *)xdmf_dsm_get_manager())->GetDsmType() == XDMF_DSM_TYPE_BLOCK_RANDOM) { xdmf_dsm_read_pages(&(filePages[file->name][0]), file->numPages, addr, nbytes, buf); size -= nbytes; addr += nbytes; buf = (char*) buf + nbytes; } else if (((XdmfDSMBuffer *)xdmf_dsm_get_manager())->GetDsmType() == XDMF_DSM_TYPE_UNIFORM || ((XdmfDSMBuffer *)xdmf_dsm_get_manager())->GetDsmType() == XDMF_DSM_TYPE_UNIFORM_RANGE) { /* Read from DSM to BUF */ if (SUCCEED != xdmf_dsm_read(file->start + addr, nbytes, buf)) { HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "cannot read from DSM") } else { size -= nbytes; addr += nbytes; buf = (char*) buf + nbytes; } } else { HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "invalid DSM type") } } /* Read zeros for the part which is after the EOF markers */ if (size > 0) HDmemset(buf, 0, size); done: if (err_occurred) { /* Nothing */ } FUNC_LEAVE_NOAPI(ret_value) } static herr_t XDMF_dsm_write(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, haddr_t addr, size_t size, const void *buf) { XDMF_dsm_t *file = (XDMF_dsm_t*) _file; herr_t ret_value = SUCCEED; /* Return value */ #if H5_VERSION_GE(1,8,9) FUNC_ENTER_NOAPI_NOINIT #else FUNC_ENTER_NOAPI_NOINIT(XDMF_dsm_write) #endif assert(file); assert(XDMF_DSM == file->pub.driver_id); assert(buf); if (file->read_only) HGOTO_ERROR(H5E_IO, H5E_RESOURCE, FAIL, "cannot write to DSM open in read-only") /* Check for overflow conditions */ if (REGION_OVERFLOW(addr, size)) HGOTO_ERROR(H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed") if (addr + size > file->eoa) HGOTO_ERROR(H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed") /* For now, do not allow dynamic reallocation of the DSM */ if (addr + size > file->eof) HGOTO_ERROR(H5E_IO, H5E_NOSPACE, FAIL, "not enough space in DSM") if (((XdmfDSMBuffer *)xdmf_dsm_get_manager())->GetDsmType() == XDMF_DSM_TYPE_BLOCK_CYCLIC || ((XdmfDSMBuffer *)xdmf_dsm_get_manager())->GetDsmType() == XDMF_DSM_TYPE_BLOCK_RANDOM) { xdmf_dsm_write_pages(&(filePages[file->name][0]), file->numPages, addr, size, buf); } else if (((XdmfDSMBuffer *)xdmf_dsm_get_manager())->GetDsmType() == XDMF_DSM_TYPE_UNIFORM || ((XdmfDSMBuffer *)xdmf_dsm_get_manager())->GetDsmType() == XDMF_DSM_TYPE_UNIFORM_RANGE) { /* Write from BUF to DSM */ if (SUCCEED != xdmf_dsm_write(file->start + addr, size, buf)) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "cannot write to DSM") } else { HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "invalid DSM type") } /* Set dirty flag so that we know someone has written something */ file->dirty = TRUE; done: if (err_occurred) { /* Nothing */ } FUNC_LEAVE_NOAPI(ret_value) } static herr_t XDMF_dsm_flush(H5FD_t *_file, hid_t UNUSED dxpl_id, unsigned UNUSED closing) { herr_t ret_value = SUCCEED; /* Return value */ #if H5_VERSION_GE(1,8,9) FUNC_ENTER_NOAPI_NOINIT_NOERR #else FUNC_ENTER_NOAPI_NOINIT_NOFUNC(XDMF_dsm_flush) #endif FUNC_LEAVE_NOAPI(ret_value) } static int XDMF_dsm_mpi_rank(const H5FD_t *_file) { const XDMF_dsm_t *file = (const XDMF_dsm_t*) _file; #if H5_VERSION_GE(1,8,9) FUNC_ENTER_NOAPI_NOINIT_NOERR #else FUNC_ENTER_NOAPI_NOINIT_NOFUNC(XDMF_dsm_mpi_rank) #endif assert(file); assert(XDMF_DSM == file->pub.driver_id); FUNC_LEAVE_NOAPI(dsmBuffer->GetComm()->GetId()) } static int XDMF_dsm_mpi_size(const H5FD_t *_file) { const XDMF_dsm_t *file = (const XDMF_dsm_t*) _file; #if H5_VERSION_GE(1,8,9) FUNC_ENTER_NOAPI_NOINIT_NOERR #else FUNC_ENTER_NOAPI_NOINIT_NOFUNC(XDMF_dsm_mpi_size) #endif assert(file); assert(XDMF_DSM == file->pub.driver_id); FUNC_LEAVE_NOAPI(dsmBuffer->GetComm()->GetIntraSize()) } static MPI_Comm XDMF_dsm_communicator(const H5FD_t *_file) { const XDMF_dsm_t *file = (const XDMF_dsm_t*) _file; #if H5_VERSION_GE(1,8,9) FUNC_ENTER_NOAPI_NOINIT_NOERR #else FUNC_ENTER_NOAPI_NOINIT_NOFUNC(XDMF_dsm_communicator) #endif assert(file); assert(XDMF_DSM == file->pub.driver_id); FUNC_LEAVE_NOAPI(dsmBuffer->GetComm()->GetIntraComm()) } } void* xdmf_dsm_get_manager() { void *ret_value = NULL; if (dsmBuffer) ret_value = static_cast (dsmBuffer); return(ret_value); } herr_t xdmf_dsm_get_properties(MPI_Comm *intra_comm, void **buf_ptr_ptr, size_t *buf_len_ptr) { if (!dsmBuffer) { try { XdmfError::message(XdmfError::FATAL, "No DSM manager found"); } catch (XdmfError & e) { return FAIL; } } if (dsmBuffer->GetIsServer()) { if (buf_ptr_ptr) *buf_ptr_ptr = dsmBuffer->GetDataPointer(); if (buf_len_ptr) *buf_len_ptr = dsmBuffer->GetLength(); } else { if (buf_ptr_ptr) *buf_ptr_ptr = NULL; if (buf_len_ptr) *buf_len_ptr = 0; } return(SUCCEED); } void xdmf_dsm_set_manager(void *manager) { dsmBuffer = static_cast (manager); } herr_t xdmf_dsm_free() { if (dsmBuffer) { /* probably not required, since the autoallocation is not on */ } return(SUCCEED); } hbool_t xdmf_dsm_is_server() { hbool_t ret_value = TRUE; if (!dsmBuffer) { XdmfError::message(XdmfError::FATAL, "No DSM manager found"); } ret_value = dsmBuffer->GetIsServer(); return(ret_value); } herr_t xdmf_dsm_set_options(unsigned long flags) { if (!dsmBuffer) { try { XdmfError::message(XdmfError::FATAL, "No DSM manager found"); } catch (XdmfError & e) { return FAIL; } } // Currently no options to set // All options are set via the dsmBuffer during the dsm's creation return(SUCCEED); } hbool_t xdmf_dsm_is_connected() { hbool_t ret_value = TRUE; if (!dsmBuffer) { XdmfError::message(XdmfError::FATAL, "No DSM manager found"); } ret_value = dsmBuffer->GetIsConnected(); return(ret_value); } herr_t xdmf_dsm_connect() { if (!dsmBuffer) { try { XdmfError::message(XdmfError::FATAL, "No DSM manager found"); } catch (XdmfError & e) { return FAIL; } } // Initialize the connection if it has not been done already if (dsmBuffer->GetIsConnected()) { try { XdmfError::message(XdmfError::FATAL, "Already Connected"); } catch (XdmfError & e) { return FAIL; } } try { dsmBuffer->Connect(); } catch (XdmfError & e) { return FAIL; } return(SUCCEED); } herr_t xdmf_dsm_lock(char * filename) { if (!dsmBuffer) { try { XdmfError::message(XdmfError::FATAL, "No DSM manager found"); } catch (XdmfError & e) { return FAIL; } } return(SUCCEED); } herr_t xdmf_dsm_unlock(char * filename, unsigned long flag) { if (!dsmBuffer) { try { XdmfError::message(XdmfError::FATAL, "No DSM manager found"); } catch (XdmfError & e) { return FAIL; } } return(SUCCEED); } // When writing and reading, we want to provide a list of pages that the file contains. // The appropriate subsections can be retrieved from the pages this way. // We may be able to eliminate these calls and just call straight from the buffer in the file driver. herr_t xdmf_dsm_read(haddr_t addr, size_t len, void *buf_ptr) { if (!dsmBuffer) { try { XdmfError::message(XdmfError::FATAL, "No DSM manager found"); } catch (XdmfError & e) { return FAIL; } } try { dsmBuffer->Get(addr, len, buf_ptr); } catch (XdmfError & e) { return FAIL; } return(SUCCEED); } herr_t xdmf_dsm_read_pages(unsigned int * pages, unsigned int numPages, haddr_t addr, size_t len, void *buf_ptr) { if (!dsmBuffer) { try { XdmfError::message(XdmfError::FATAL, "No DSM manager found"); } catch (XdmfError & e) { return FAIL; } } try { dsmBuffer->Get(pages, numPages, addr, len, buf_ptr); } catch (XdmfError & e) { return FAIL; } return(SUCCEED); } herr_t xdmf_dsm_write(haddr_t addr, size_t len, const void *buf_ptr) { if (!dsmBuffer) { try { XdmfError::message(XdmfError::FATAL, "No DSM manager found"); } catch (XdmfError & e) { return FAIL; } } try { dsmBuffer->Put(addr, len, buf_ptr); } catch (XdmfError & e) { return FAIL; } return(SUCCEED); } herr_t xdmf_dsm_write_pages(unsigned int * pages, unsigned int numPages, haddr_t addr, size_t len, const void *buf_ptr) { if (!dsmBuffer) { try { XdmfError::message(XdmfError::FATAL, "No DSM manager found"); } catch (XdmfError & e) { return FAIL; } } try { dsmBuffer->Put(pages, numPages, addr, len, buf_ptr); } catch (XdmfError & e) { return FAIL; } return(SUCCEED); } xdmf-3.0+git20160803/core/dsm/XdmfDSMDriver.hpp0000640000175000017500000001501113003006557020732 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfDSMDriver.hpp */ /* */ /* Author: */ /* Andrew Burns */ /* andrew.j.burns2@us.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2013 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ /*========================================================================= This code is derived from an earlier work and is distributed with permission from, and thanks to ... =========================================================================*/ /*========================================================================= Project : H5FDdsm Module : H5FDdsmDriver.h H5FDdsm.h Authors: John Biddiscombe Jerome Soumagne biddisco@cscs.ch soumagne@cscs.ch Copyright (C) CSCS - Swiss National Supercomputing Centre. You may use modify and and distribute this code freely providing 1) This copyright notice appears on all copies of source code 2) An acknowledgment appears with any substantial usage of the code 3) If this code is contributed to any other open source project, it must not be reformatted such that the indentation, bracketing or overall style is modified significantly. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. This work has received funding from the European Community's Seventh Framework Programme (FP7/2007-2013) under grant agreement 225967 âxtMuSEâOB =========================================================================*/ #ifndef XDMFDSMDRIVER_HPP_ #define XDMFDSMDRIVER_HPP_ // Forward Declarations // Includes #include #include //#include #include #include #include "H5Ipublic.h" #include "H5FDpublic.h" #ifndef H5_HAVE_PARALLEL #pragma Error : The XdmfDSM virtual File Driver for HDF5 can only be compiled against an HDF5 library with parallel IO support #endif #define XDMF_DSM_NOTIFY_NONE 0x0000 #define XDMF_DSM_NOTIFY_DATA 0x0001 /* this is the default */ #define XDMF_DSM_NOTIFY_INFORMATION 0x0002 /* Internal notifications */ #define XDMF_DSM_NOTIFY_WAIT 0x0003 #define XDMF_DSM_NOTIFY_CONNECTED 0x0004 #define XDMF_DSM_NOTIFY_DISCONNECTED 0x0005 /* User notifications */ #define XDMF_DSM_NOTIFY_USER 0x0010 #define XDMF_DSM (XDMF_dsm_init()) #define IS_XDMF_DSM(f) /* (H5F_t *f) */ \ (XDMF_DSM==H5F_DRIVER_ID(f)) #ifndef H5_HAVE_VFD_EXTENSIONS #include "H5FDmpio.h" #ifndef H5FD_FEAT_HAS_MPI // This is a temporary solution to allow interface with standard hdf5 in addition to hdf5vfd // Hopefully a better solution will be made in the future #define XDMF_dsm_init H5FD_mpio_init //#pragma message(": warning Xdmf: H5FD mpiposix file driver replaced to enable dsm compatibility with hdf5") #endif #endif /* H5_HAVE_VFD_EXTENSIONS */ extern "C" { XDMFDSM_EXPORT hid_t XDMF_dsm_init(void); #if H5_VERSION_GE(1,9,0) XDMFDSM_EXPORT herr_t XDMF_dsm_term(void); #else XDMFDSM_EXPORT void XDMF_dsm_term(void); #endif // lock and unlock are currently disabled the user has to make allowances // to prevent race conditions XDMFDSM_EXPORT herr_t XDMF_dsm_lock(void); XDMFDSM_EXPORT herr_t XDMF_dsm_unlock(unsigned long flag); // Currently no options to set XDMFDSM_EXPORT herr_t XDMF_dsm_set_options(unsigned long flags); XDMFDSM_EXPORT herr_t XDMF_dsm_set_manager(void *manager); XDMFDSM_EXPORT herr_t XDMFH5Pset_fapl_dsm(hid_t fapl_id, MPI_Comm intra_comm, void *local_buf_ptr, size_t local_buf_len); XDMFDSM_EXPORT herr_t XDMFH5Pget_fapl_dsm(hid_t fapl_id, MPI_Comm *intra_comm /* out */, void **local_buf_ptr_ptr /* out */, size_t *local_buf_len_ptr /* out */); XDMFDSM_EXPORT void *xdmf_dsm_get_manager(); XDMFDSM_EXPORT herr_t xdmf_dsm_get_properties(MPI_Comm *intra_comm, void **buf_ptr_ptr, size_t *buf_len_ptr); XDMFDSM_EXPORT void xdmf_dsm_set_manager(void *manager); /* // Probably a bad idea to create managers automatically for the non-threaded version XDMFDSM_EXPORT herr_t xdmf_dsm_alloc(MPI_Comm intra_comm, void *buf_ptr, size_t buf_len); */ XDMFDSM_EXPORT herr_t xdmf_dsm_free(); XDMFDSM_EXPORT hbool_t xdmf_dsm_is_server(); // Currently no options to set XDMFDSM_EXPORT herr_t xdmf_dsm_set_options(unsigned long flags); XDMFDSM_EXPORT hbool_t xdmf_dsm_is_connected(); XDMFDSM_EXPORT herr_t xdmf_dsm_connect(); XDMFDSM_EXPORT herr_t xdmf_dsm_lock(char * filename); XDMFDSM_EXPORT herr_t xdmf_dsm_unlock(char * filename, unsigned long flag); XDMFDSM_EXPORT herr_t xdmf_dsm_read(haddr_t addr, size_t len, void *buf_ptr); XDMFDSM_EXPORT herr_t xdmf_dsm_read_pages(unsigned int * pages, unsigned int numPages, haddr_t addr, size_t len, void *buf_ptr); XDMFDSM_EXPORT herr_t xdmf_dsm_write(haddr_t addr, size_t len, const void *buf_ptr); XDMFDSM_EXPORT herr_t xdmf_dsm_write_pages(unsigned int * pages, unsigned int numPages, haddr_t addr, size_t len, const void *buf_ptr); } #endif /* XDMFDSMDRIVER_HPP_ */ xdmf-3.0+git20160803/core/dsm/XdmfHDF5ControllerDSM.cpp0000640000175000017500000010603213003006557022230 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfHDF5ControllerDSM.cpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #include #include #include "XdmfArray.hpp" #include "XdmfArrayType.hpp" #include "XdmfHDF5ControllerDSM.hpp" #include "XdmfDSMBuffer.hpp" #include "XdmfDSMCommMPI.hpp" #include "XdmfDSMDriver.hpp" #include "XdmfError.hpp" // Server/ nonthreaded versions shared_ptr XdmfHDF5ControllerDSM::New(const std::string & hdf5FilePath, const std::string & dataSetPath, const shared_ptr type, const std::vector & start, const std::vector & stride, const std::vector & dimensions, const std::vector & datspaceDimensions, XdmfDSMBuffer * const dsmBuffer) { shared_ptr p(new XdmfHDF5ControllerDSM(hdf5FilePath, dataSetPath, type, start, stride, dimensions, datspaceDimensions, dsmBuffer)); return p; } shared_ptr XdmfHDF5ControllerDSM::New(const std::string & hdf5FilePath, const std::string & dataSetPath, const shared_ptr type, const std::vector & start, const std::vector & stride, const std::vector & dimensions, const std::vector & datspaceDimensions, MPI_Comm comm, unsigned int bufferSize, int startCoreIndex, int endCoreIndex, std::string applicationName) { shared_ptr p(new XdmfHDF5ControllerDSM(hdf5FilePath, dataSetPath, type, start, stride, dimensions, datspaceDimensions, comm, bufferSize, startCoreIndex, endCoreIndex, applicationName)); return p; } shared_ptr XdmfHDF5ControllerDSM::New(const std::string & hdf5FilePath, const std::string & dataSetPath, const shared_ptr type, const std::vector & start, const std::vector & stride, const std::vector & dimensions, const std::vector & datspaceDimensions, MPI_Comm comm, unsigned int bufferSize, unsigned int blockSize, double resizeFactor, int startCoreIndex, int endCoreIndex, std::string applicationName) { shared_ptr p(new XdmfHDF5ControllerDSM(hdf5FilePath, dataSetPath, type, start, stride, dimensions, datspaceDimensions, comm, bufferSize, blockSize, resizeFactor, startCoreIndex, endCoreIndex, applicationName)); return p; } XdmfHDF5ControllerDSM::XdmfHDF5ControllerDSM(const std::string & hdf5FilePath, const std::string & dataSetPath, const shared_ptr type, const std::vector & start, const std::vector & stride, const std::vector & dimensions, const std::vector & dataspaceDimensions, XdmfDSMBuffer * const dsmBuffer) : XdmfHDF5Controller(hdf5FilePath, dataSetPath, type, start, stride, dimensions, dataspaceDimensions), mDSMServerBuffer(dsmBuffer), mServerMode(true) { mWorkerComm = mDSMServerBuffer->GetComm()->GetIntraComm(); if (xdmf_dsm_get_manager() == NULL) { XDMF_dsm_set_manager(mDSMServerBuffer); } else { xdmf_dsm_set_manager(mDSMServerBuffer); } } XdmfHDF5ControllerDSM::XdmfHDF5ControllerDSM(const std::string & hdf5FilePath, const std::string & dataSetPath, const shared_ptr type, const std::vector & start, const std::vector & stride, const std::vector & dimensions, const std::vector & dataspaceDimensions, MPI_Comm comm, unsigned int bufferSize, int startCoreIndex, int endCoreIndex, std::string applicationName) : XdmfHDF5Controller(hdf5FilePath, dataSetPath, type, start, stride, dimensions, dataspaceDimensions), mServerMode(true) { int rank, size; #ifdef XDMF_DSM_IS_CRAY MPI_Comm InterComm = comm; // Cray needs to be launched via the colon notation so that it // can properly create a merged communicator MPI_Comm_size(comm, &size); MPI_Comm_rank(comm, &rank); int currentCore = 0; int * checkstatus = new int[size](); int localCheck = 0; char * coreTag; int tagSize = 0; std::vector > newStructure; std::vector coreSplit; unsigned int splitid = 0; int * splitIds; unsigned int splitsize = 0; while (currentCore < size) { if (rank == currentCore) { tagSize = applicationName.size(); } MPI_Bcast(&tagSize, 1, MPI_INT, currentCore, comm); coreTag = new char[tagSize+1](); if (rank == currentCore) { strcpy(coreTag, applicationName.c_str()); } MPI_Bcast(coreTag, tagSize, MPI_CHAR, currentCore, comm); coreTag[tagSize] = 0; if (strcmp(coreTag, applicationName.c_str()) == 0) { localCheck = 1; } else { localCheck = 0; } checkstatus[rank] = localCheck; MPI_Allgather(&localCheck, 1, MPI_INT, checkstatus, 1, MPI_INT, comm); bool insplit = false; while (checkstatus[currentCore]) { if (rank == currentCore) { insplit = true; } coreSplit.push_back(currentCore); ++currentCore; if (currentCore >= size) { break; } } if (insplit) { splitIds = (int *)calloc(coreSplit.size(), sizeof(int)); memcpy(splitIds, &(coreSplit[0]), coreSplit.size() * sizeof(int)); splitsize = coreSplit.size(); } newStructure.push_back(std::pair(std::string(coreTag), coreSplit.size())); coreSplit.clear(); ++splitid; } // Use MPI_Comm_split MPI_Group IntraGroup, InterGroup; MPI_Comm IntraComm; MPI_Comm_group(comm, &InterGroup); MPI_Group_incl(InterGroup, splitsize, splitIds, &IntraGroup); MPI_Comm_create(comm, IntraGroup, &IntraComm); cfree(splitIds); int intraid = 0; int intrasize = 0; MPI_Comm_rank(IntraComm, &intraid); MPI_Comm_size(IntraComm, &intrasize); comm = IntraComm; #endif MPI_Comm_size(comm, &size); MPI_Comm_rank(comm, &rank); // Negative values will be changed to maximum range if (startCoreIndex < 0) { startCoreIndex = 0; } if (endCoreIndex < 0) { endCoreIndex = size - 1; } // Ensure start index is less than end index if (startCoreIndex > endCoreIndex) { int tempholder = startCoreIndex; startCoreIndex = endCoreIndex; endCoreIndex = tempholder; } MPI_Comm serverComm; MPI_Group workers, dsmgroup, serversplit, servergroup; int * ServerIds = (int *)calloc((3), sizeof(int)); unsigned int index = 0; for(int i=startCoreIndex ; i <= endCoreIndex ; ++i) { ServerIds[index++] = i; } MPI_Comm_group(comm, &serversplit); MPI_Group_incl(serversplit, index, ServerIds, &servergroup); MPI_Comm_create(comm, servergroup, &serverComm); MPI_Comm_group(comm, &dsmgroup); MPI_Group_excl(dsmgroup, index, ServerIds, &workers); MPI_Comm_create(comm, workers, &mWorkerComm); cfree(ServerIds); // Create the manager mDSMServerBuffer = new XdmfDSMBuffer(); mDSMServerBuffer->SetLocalBufferSizeMBytes(bufferSize); mDSMServerBuffer->SetInterCommType(XDMF_DSM_COMM_MPI); mDSMServerBuffer->SetDsmType(XDMF_DSM_TYPE_UNIFORM); if (rank >= startCoreIndex && rank <= endCoreIndex) { mDSMServerBuffer->GetComm()->SetApplicationName("Server"); } else { mDSMServerBuffer->GetComm()->SetApplicationName(applicationName); } if (rank >= startCoreIndex && rank <= endCoreIndex) { mDSMServerBuffer->Create(serverComm); } else { mDSMServerBuffer->Create(mWorkerComm, startCoreIndex, endCoreIndex); } XDMF_dsm_set_manager(mDSMServerBuffer); #ifdef XDMF_DSM_IS_CRAY mDSMServerBuffer->GetComm()->DupInterComm(InterComm); #else mDSMServerBuffer->GetComm()->DupInterComm(comm); #endif mDSMServerBuffer->SetIsConnected(true); if (startCoreIndex < size) { if (rank >= startCoreIndex && rank <= endCoreIndex) { mDSMServerBuffer->ReceiveInfo(); } else { mDSMServerBuffer->SendInfo(); } } MPI_Barrier(comm); // Loop needs to be started before anything can be done to the file // since the service is what sets up the file if (rank < startCoreIndex || rank > endCoreIndex) { // Turn off the server designation mDSMServerBuffer->SetIsServer(false); // If this is set to false then the buffer will attempt to // connect to the intercomm for DSM stuff } else { // On cores where memory is set up, start the service loop // This should iterate infinitely until a value to end the loop is passed int returnOpCode; try { mDSMServerBuffer->BufferServiceLoop(&returnOpCode); } catch (XdmfError & e) { throw e; } } } XdmfHDF5ControllerDSM::XdmfHDF5ControllerDSM(const std::string & hdf5FilePath, const std::string & dataSetPath, const shared_ptr type, const std::vector & start, const std::vector & stride, const std::vector & dimensions, const std::vector & dataspaceDimensions, MPI_Comm comm, unsigned int bufferSize, unsigned int blockSize, double resizeFactor, int startCoreIndex, int endCoreIndex, std::string applicationName) : XdmfHDF5Controller(hdf5FilePath, dataSetPath, type, start, stride, dimensions, dataspaceDimensions), mServerMode(true) { int rank, size; #ifdef XDMF_DSM_IS_CRAY MPI_Comm InterComm = comm; // Cray needs to be launched via the colon notation so that it // can properly create a merged communicator MPI_Comm_size(comm, &size); MPI_Comm_rank(comm, &rank); int currentCore = 0; int * checkstatus = new int[size](); int localCheck = 0; char * coreTag; int tagSize = 0; std::vector > newStructure; std::vector coreSplit; unsigned int splitid = 0; int * splitIds; unsigned int splitsize = 0; while (currentCore < size) { if (rank == currentCore) { tagSize = applicationName.size(); } MPI_Bcast(&tagSize, 1, MPI_INT, currentCore, comm); coreTag = new char[tagSize+1](); if (rank == currentCore) { strcpy(coreTag, applicationName.c_str()); } MPI_Bcast(coreTag, tagSize, MPI_CHAR, currentCore, comm); coreTag[tagSize] = 0; if (strcmp(coreTag, applicationName.c_str()) == 0) { localCheck = 1; } else { localCheck = 0; } checkstatus[rank] = localCheck; MPI_Allgather(&localCheck, 1, MPI_INT, checkstatus, 1, MPI_INT, comm); bool insplit = false; while (checkstatus[currentCore]) { if (rank == currentCore) { insplit = true; } coreSplit.push_back(currentCore); ++currentCore; if (currentCore >= size) { break; } } if (insplit) { splitIds = (int *)calloc(coreSplit.size(), sizeof(int)); memcpy(splitIds, &(coreSplit[0]), coreSplit.size() * sizeof(int)); splitsize = coreSplit.size(); } newStructure.push_back(std::pair(std::string(coreTag), coreSplit.size())); coreSplit.clear(); ++splitid; } // Use MPI_Comm_split MPI_Group IntraGroup, InterGroup; MPI_Comm IntraComm; MPI_Comm_group(comm, &InterGroup); MPI_Group_incl(InterGroup, splitsize, splitIds, &IntraGroup); MPI_Comm_create(comm, IntraGroup, &IntraComm); cfree(splitIds); int intraid = 0; int intrasize = 0; MPI_Comm_rank(IntraComm, &intraid); MPI_Comm_size(IntraComm, &intrasize); comm = IntraComm; #endif MPI_Comm_size(comm, &size); MPI_Comm_rank(comm, &rank); // Negative values will be changed to maximum range if (startCoreIndex < 0) { startCoreIndex = 0; } if (endCoreIndex < 0) { endCoreIndex = size - 1; } // Ensure start index is less than end index if (startCoreIndex > endCoreIndex) { int tempholder = startCoreIndex; startCoreIndex = endCoreIndex; endCoreIndex = tempholder; } MPI_Comm serverComm; MPI_Group workers, dsmgroup, serversplit, servergroup; int * ServerIds = (int *)calloc((3), sizeof(int)); unsigned int index = 0; for(int i=startCoreIndex ; i <= endCoreIndex ; ++i) { ServerIds[index++] = i; } MPI_Comm_group(comm, &serversplit); MPI_Group_incl(serversplit, index, ServerIds, &servergroup); MPI_Comm_create(comm, servergroup, &serverComm); MPI_Comm_group(comm, &dsmgroup); MPI_Group_excl(dsmgroup, index, ServerIds, &workers); MPI_Comm_create(comm, workers, &mWorkerComm); cfree(ServerIds); // Create the manager mDSMServerBuffer = new XdmfDSMBuffer(); mDSMServerBuffer->SetLocalBufferSizeMBytes(bufferSize); mDSMServerBuffer->SetInterCommType(XDMF_DSM_COMM_MPI); mDSMServerBuffer->SetBlockLength(blockSize); mDSMServerBuffer->SetDsmType(XDMF_DSM_TYPE_BLOCK_CYCLIC); mDSMServerBuffer->SetResizeFactor(resizeFactor); if (rank >= startCoreIndex && rank <= endCoreIndex) { mDSMServerBuffer->GetComm()->SetApplicationName("Server"); } else { mDSMServerBuffer->GetComm()->SetApplicationName(applicationName); } if (rank >= startCoreIndex && rank <= endCoreIndex) { mDSMServerBuffer->Create(serverComm); } else { mDSMServerBuffer->Create(mWorkerComm, startCoreIndex, endCoreIndex); } XDMF_dsm_set_manager(mDSMServerBuffer); #ifdef XDMF_DSM_IS_CRAY mDSMServerBuffer->GetComm()->DupInterComm(InterComm); #else mDSMServerBuffer->GetComm()->DupInterComm(comm); #endif mDSMServerBuffer->SetIsConnected(true); if (startCoreIndex < size) { if (rank >= startCoreIndex && rank <= endCoreIndex) { mDSMServerBuffer->ReceiveInfo(); } else { mDSMServerBuffer->SendInfo(); } } MPI_Barrier(comm); // Loop needs to be started before anything can be done to the file // since the service is what sets up the file if (rank < startCoreIndex || rank > endCoreIndex) { // Turn off the server designation mDSMServerBuffer->SetIsServer(false); // If this is set to false then the buffer will attempt to // connect to the intercomm for DSM stuff } else { // On cores where memory is set up, start the service loop // This should iterate infinitely until a value to end the loop is passed int returnOpCode; try { mDSMServerBuffer->BufferServiceLoop(&returnOpCode); } catch (XdmfError & e) { throw e; } } } XdmfHDF5ControllerDSM::XdmfHDF5ControllerDSM(XdmfHDF5ControllerDSM & refController): XdmfHDF5Controller(refController), mDSMServerBuffer(refController.getServerBuffer()), mServerMode(refController.getServerMode()) { mWorkerComm = mDSMServerBuffer->GetComm()->GetIntraComm(); } XdmfHDF5ControllerDSM::~XdmfHDF5ControllerDSM() { } std::string XdmfHDF5ControllerDSM::getName() const { return "HDFDSM"; } XdmfDSMBuffer * XdmfHDF5ControllerDSM::getServerBuffer() { return mDSMServerBuffer; } bool XdmfHDF5ControllerDSM::getServerMode() const { return mServerMode; } MPI_Comm XdmfHDF5ControllerDSM::getWorkerComm() const { MPI_Comm returnComm = MPI_COMM_NULL; if (mWorkerComm != MPI_COMM_NULL) { MPI_Comm_dup(mWorkerComm, &returnComm); } return returnComm; } void XdmfHDF5ControllerDSM::setBuffer(XdmfDSMBuffer * newBuffer) { mDSMServerBuffer = newBuffer; } void XdmfHDF5ControllerDSM::setServerMode(bool newMode) { mServerMode = newMode; } void XdmfHDF5ControllerDSM::setWorkerComm(MPI_Comm comm) { int status; #ifndef OPEN_MPI if (mWorkerComm != MPI_COMM_NULL) { status = MPI_Comm_free(&mWorkerComm); if (status != MPI_SUCCESS) { try { XdmfError::message(XdmfError::FATAL, "Failed to disconnect Comm"); } catch (XdmfError & e) { throw e; } } } #endif if (comm != MPI_COMM_NULL) { status = MPI_Comm_dup(comm, &mWorkerComm); if (status != MPI_SUCCESS) { try { XdmfError::message(XdmfError::FATAL, "Failed to duplicate Comm"); } catch (XdmfError & e) { throw e; } } } mDSMServerBuffer->GetComm()->DupComm(comm); } void XdmfHDF5ControllerDSM::stopDSM() { if (mServerMode) { // Send manually for (int i = mDSMServerBuffer->GetStartServerId(); i <= mDSMServerBuffer->GetEndServerId(); ++i) { try { mDSMServerBuffer->SendCommandHeader(XDMF_DSM_OPCODE_DONE, i, 0, 0, XDMF_DSM_INTER_COMM); } catch (XdmfError & e) { throw e; } } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Stopping DSM manually only available in server mode."); } catch (XdmfError & e) { throw e; } } } void XdmfHDF5ControllerDSM::restartDSM() { if (mServerMode) { if (mDSMServerBuffer->GetComm()->GetInterId() >= mDSMServerBuffer->GetStartServerId() && mDSMServerBuffer->GetComm()->GetInterId() <= mDSMServerBuffer->GetEndServerId()) { int returnOpCode; try { mDSMServerBuffer->BufferServiceLoop(&returnOpCode); } catch (XdmfError & e) { throw e; } } } else { try { XdmfError::message(XdmfError::FATAL, "Error: Restarting DSM only available in server mode."); } catch (XdmfError & e) { throw e; } } } void XdmfHDF5ControllerDSM::read(XdmfArray * const array) { // Set file access property list for DSM hid_t fapl = H5Pcreate(H5P_FILE_ACCESS); // Use DSM driver if (mWorkerComm != MPI_COMM_NULL) { XDMFH5Pset_fapl_dsm(fapl, mWorkerComm, mDSMServerBuffer, 0); } // Read from DSM Buffer XdmfHDF5Controller::read(array, fapl); // Close file access property list H5Pclose(fapl); } // C Wrappers XDMFHDF5CONTROLLERDSM * XdmfHDF5ControllerDSMNewFromServerBuffer(char * hdf5FilePath, char * dataSetPath, int type, unsigned int * start, unsigned int * stride, unsigned int * dimensions, unsigned int * dataspaceDimensions, unsigned int numDims, void * dsmBuffer, int * status) { XDMF_ERROR_WRAP_START(status) std::vector startVector(start, start + numDims); std::vector strideVector(stride, stride + numDims); std::vector dimVector(dimensions, dimensions + numDims); std::vector dataspaceVector(dataspaceDimensions, dataspaceDimensions + numDims); shared_ptr buildType = shared_ptr(); switch (type) { case XDMF_ARRAY_TYPE_UINT8: buildType = XdmfArrayType::UInt8(); break; case XDMF_ARRAY_TYPE_UINT16: buildType = XdmfArrayType::UInt16(); break; case XDMF_ARRAY_TYPE_UINT32: buildType = XdmfArrayType::UInt32(); break; case XDMF_ARRAY_TYPE_INT8: buildType = XdmfArrayType::Int8(); break; case XDMF_ARRAY_TYPE_INT16: buildType = XdmfArrayType::Int16(); break; case XDMF_ARRAY_TYPE_INT32: buildType = XdmfArrayType::Int32(); break; case XDMF_ARRAY_TYPE_INT64: buildType = XdmfArrayType::Int64(); break; case XDMF_ARRAY_TYPE_FLOAT32: buildType = XdmfArrayType::Float32(); break; case XDMF_ARRAY_TYPE_FLOAT64: buildType = XdmfArrayType::Float64(); break; default: try { XdmfError::message(XdmfError::FATAL, "Error: Invalid ArrayType."); } catch (XdmfError & e) { throw e; } break; } shared_ptr generatedController = XdmfHDF5ControllerDSM::New(std::string(hdf5FilePath), std::string(dataSetPath), buildType, startVector, strideVector, dimVector, dataspaceVector, (XdmfDSMBuffer *) dsmBuffer); return (XDMFHDF5CONTROLLERDSM *)((void *)(new XdmfHDF5ControllerDSM(*generatedController.get()))); XDMF_ERROR_WRAP_END(status) return NULL; } XDMFHDF5CONTROLLERDSM * XdmfHDF5ControllerDSMNew(char * hdf5FilePath, char * dataSetPath, int type, unsigned int * start, unsigned int * stride, unsigned int * dimensions, unsigned int * dataspaceDimensions, unsigned int numDims, MPI_Comm comm, unsigned int bufferSize, int startCoreIndex, int endCoreIndex, char * applicationName, int * status) { XDMF_ERROR_WRAP_START(status) std::vector startVector(start, start + numDims); std::vector strideVector(stride, stride + numDims); std::vector dimVector(dimensions, dimensions + numDims); std::vector dataspaceVector(dataspaceDimensions, dataspaceDimensions + numDims); shared_ptr buildType = shared_ptr(); switch (type) { case XDMF_ARRAY_TYPE_UINT8: buildType = XdmfArrayType::UInt8(); break; case XDMF_ARRAY_TYPE_UINT16: buildType = XdmfArrayType::UInt16(); break; case XDMF_ARRAY_TYPE_UINT32: buildType = XdmfArrayType::UInt32(); break; case XDMF_ARRAY_TYPE_INT8: buildType = XdmfArrayType::Int8(); break; case XDMF_ARRAY_TYPE_INT16: buildType = XdmfArrayType::Int16(); break; case XDMF_ARRAY_TYPE_INT32: buildType = XdmfArrayType::Int32(); break; case XDMF_ARRAY_TYPE_INT64: buildType = XdmfArrayType::Int64(); break; case XDMF_ARRAY_TYPE_FLOAT32: buildType = XdmfArrayType::Float32(); break; case XDMF_ARRAY_TYPE_FLOAT64: buildType = XdmfArrayType::Float64(); break; default: try { XdmfError::message(XdmfError::FATAL, "Error: Invalid ArrayType."); } catch (XdmfError & e) { throw e; } break; } shared_ptr generatedController = XdmfHDF5ControllerDSM::New(std::string(hdf5FilePath), std::string(dataSetPath), buildType, startVector, strideVector, dimVector, dataspaceVector, comm, bufferSize, startCoreIndex, endCoreIndex, std::string(applicationName)); return (XDMFHDF5CONTROLLERDSM *)((void *)(new XdmfHDF5ControllerDSM(*generatedController.get()))); XDMF_ERROR_WRAP_END(status) return NULL; } XDMFHDF5CONTROLLERDSM * XdmfHDF5ControllerDSMNewPaged(char * hdf5FilePath, char * dataSetPath, int type, unsigned int * start, unsigned int * stride, unsigned int * dimensions, unsigned int * dataspaceDimensions, unsigned int numDims, MPI_Comm comm, unsigned int bufferSize, unsigned int blockSize, double resizeFactor, int startCoreIndex, int endCoreIndex, char * applicationName, int * status) { XDMF_ERROR_WRAP_START(status) std::vector startVector(start, start + numDims); std::vector strideVector(stride, stride + numDims); std::vector dimVector(dimensions, dimensions + numDims); std::vector dataspaceVector(dataspaceDimensions, dataspaceDimensions + numDims); shared_ptr buildType = shared_ptr(); switch (type) { case XDMF_ARRAY_TYPE_UINT8: buildType = XdmfArrayType::UInt8(); break; case XDMF_ARRAY_TYPE_UINT16: buildType = XdmfArrayType::UInt16(); break; case XDMF_ARRAY_TYPE_UINT32: buildType = XdmfArrayType::UInt32(); break; case XDMF_ARRAY_TYPE_INT8: buildType = XdmfArrayType::Int8(); break; case XDMF_ARRAY_TYPE_INT16: buildType = XdmfArrayType::Int16(); break; case XDMF_ARRAY_TYPE_INT32: buildType = XdmfArrayType::Int32(); break; case XDMF_ARRAY_TYPE_INT64: buildType = XdmfArrayType::Int64(); break; case XDMF_ARRAY_TYPE_FLOAT32: buildType = XdmfArrayType::Float32(); break; case XDMF_ARRAY_TYPE_FLOAT64: buildType = XdmfArrayType::Float64(); break; default: try { XdmfError::message(XdmfError::FATAL, "Error: Invalid ArrayType."); } catch (XdmfError & e) { throw e; } break; } shared_ptr generatedController = XdmfHDF5ControllerDSM::New(std::string(hdf5FilePath), std::string(dataSetPath), buildType, startVector, strideVector, dimVector, dataspaceVector, comm, bufferSize, blockSize, resizeFactor, startCoreIndex, endCoreIndex, std::string(applicationName)); return (XDMFHDF5CONTROLLERDSM *)((void *)(new XdmfHDF5ControllerDSM(*generatedController.get()))); XDMF_ERROR_WRAP_END(status) return NULL; } XDMFDSMBUFFER * XdmfHDF5ControllerDSMGetServerBuffer(XDMFHDF5CONTROLLERDSM * controller) { return (XDMFDSMBUFFER *)((void *)(((XdmfHDF5ControllerDSM *)controller)->getServerBuffer())); } int XdmfHDF5ControllerDSMGetServerMode(XDMFHDF5CONTROLLERDSM * controller) { return ((XdmfHDF5ControllerDSM *)controller)->getServerMode(); } MPI_Comm XdmfHDF5ControllerDSMGetWorkerComm(XDMFHDF5CONTROLLERDSM * controller) { return ((XdmfHDF5ControllerDSM *)controller)->getWorkerComm(); } void XdmfHDF5ControllerDSMSetServerBuffer(XDMFHDF5CONTROLLERDSM * controller, XDMFDSMBUFFER * newBuffer) { ((XdmfHDF5ControllerDSM *)controller)->setBuffer((XdmfDSMBuffer *)newBuffer); } void XdmfHDF5ControllerDSMSetServerMode(XDMFHDF5CONTROLLERDSM * controller, int newMode) { ((XdmfHDF5ControllerDSM *)controller)->setServerMode(newMode); } void XdmfHDF5ControllerDSMSetWorkerComm(XDMFHDF5CONTROLLERDSM * controller, MPI_Comm comm, int * status) { XDMF_ERROR_WRAP_START(status) ((XdmfHDF5ControllerDSM *)controller)->setWorkerComm(comm); XDMF_ERROR_WRAP_END(status) } void XdmfHDF5ControllerDSMStopDSM(XDMFHDF5CONTROLLERDSM * controller, int * status) { XDMF_ERROR_WRAP_START(status) ((XdmfHDF5ControllerDSM *)controller)->stopDSM(); XDMF_ERROR_WRAP_END(status) } void XdmfHDF5ControllerDSMRestartDSM(XDMFHDF5CONTROLLERDSM * controller, int * status) { XDMF_ERROR_WRAP_START(status) ((XdmfHDF5ControllerDSM *)controller)->restartDSM(); XDMF_ERROR_WRAP_END(status) } // C Wrappers for parent classes are generated by macros XDMF_HEAVYCONTROLLER_C_CHILD_WRAPPER(XdmfHDF5ControllerDSM, XDMFHDF5CONTROLLERDSM) XDMF_HDF5CONTROLLER_C_CHILD_WRAPPER(XdmfHDF5ControllerDSM, XDMFHDF5CONTROLLERDSM) xdmf-3.0+git20160803/core/dsm/XdmfDSMCommMPI.cpp0000640000175000017500000007627513003006557020756 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfDSMCommMPI.cpp */ /* */ /* Author: */ /* Andrew Burns */ /* andrew.j.burns2@us.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2013 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ /*========================================================================= This code is derived from an earlier work and is distributed with permission from, and thanks to ... =========================================================================*/ /*============================================================================ Project : H5FDdsm Module : H5FDdsmCommMpi.cxx Authors: John Biddiscombe Jerome Soumagne biddisco@cscs.ch soumagne@cscs.ch Copyright (C) CSCS - Swiss National Supercomputing Centre. You may use modify and and distribute this code freely providing 1) This copyright notice appears on all copies of source code 2) An acknowledgment appears with any substantial usage of the code 3) If this code is contributed to any other open source project, it must not be reformatted such that the indentation, bracketing or overall style is modified significantly. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. This work has received funding from the European Community's Seventh Framework Programme (FP7/2007-2013) under grant agreement 225967 âxtMuSEâOC ============================================================================*/ #include #include #include #include #include #include #include bool XdmfDSMCommMPI::UseEnvFileName = false; XdmfDSMCommMPI::XdmfDSMCommMPI() { IntraComm = MPI_COMM_NULL; Id = -1; IntraSize = -1; InterComm = MPI_COMM_NULL; InterId = -1; InterSize = -1; SetDsmPortName(""); // This is the default file name for the config file. DsmFileName = "dsmconnect.cfg"; if (XdmfDSMCommMPI::UseEnvFileName) { // Grab from ENV if (std::getenv("XDMFDSM_CONFIG_FILE") != NULL) { DsmFileName = std::getenv("XDMFDSM_CONFIG_FILE"); } } InterCommType = XDMF_DSM_COMM_MPI; HasOpenedPort = false; ApplicationName = "Application"; } XdmfDSMCommMPI::~XdmfDSMCommMPI() { #ifndef OPEN_MPI if (InterComm != MPI_COMM_NULL) { int status = MPI_Comm_free(&InterComm); if (status != MPI_SUCCESS) { try { XdmfError::message(XdmfError::FATAL, "Failed to free intercomm Comm"); } catch (XdmfError & e) { throw e; } } } if (IntraComm != MPI_COMM_NULL) { int status = MPI_Comm_free(&IntraComm); if (status != MPI_SUCCESS) { try { XdmfError::message(XdmfError::FATAL, "Failed to free intercomm Comm"); } catch (XdmfError & e) { throw e; } } } #endif } void XdmfDSMCommMPI::Accept(unsigned int numConnections) { #ifndef XDMF_DSM_IS_CRAY int status; int acceptingLeadId; while (numConnections > 0) { if (InterComm == MPI_COMM_NULL) { acceptingLeadId = this->IntraSize; // If there is no InterComm, then accept from IntraComm and merge into InterComm MPI_Comm tempComm; int * portCheck = new int[GetInterSize()](); int portStatus; portStatus = 0; if (HasOpenedPort) { portStatus = 1; } MPI_Allgather(&portStatus, 1, MPI_INT, &(portCheck[0]), 1, MPI_INT, InterComm); int index = 0; for (index = 0; index < GetInterSize(); ++index) { if (portCheck[index] == 1) { break; } } int status = MPI_Comm_accept(DsmPortName, MPI_INFO_NULL, index, IntraComm, &tempComm); if (status != MPI_SUCCESS) { try { std::string message = "Failed to accept port "; message = message + DsmPortName; XdmfError::message(XdmfError::FATAL, message); } catch (XdmfError & e) { throw e; } } // False is specified for high so that the index of the cores doesn't change MPI_Comm mergedComm; status = MPI_Intercomm_merge(tempComm, false, &mergedComm); this->DupInterComm(mergedComm); if (status != MPI_SUCCESS) { try { XdmfError::message(XdmfError::FATAL, "Failed to merge intercomm"); } catch (XdmfError & e) { throw e; } } else { MPI_Comm_rank(InterComm, &InterId); MPI_Comm_size(InterComm, &InterSize); } } else { acceptingLeadId = this->InterSize; // If there is an InterComm, accept into the InterComm and merge MPI_Comm tempComm; int * portCheck = new int[GetInterSize()](); int portStatus; portStatus = 0; if (HasOpenedPort) { portStatus = 1; } MPI_Allgather(&portStatus, 1, MPI_INT, &(portCheck[0]), 1, MPI_INT, InterComm); int index = 0; for (index = 0; index < GetInterSize(); ++index) { if (portCheck[index] == 1) { break; } } int status = MPI_Comm_accept(DsmPortName, MPI_INFO_NULL, index, InterComm, &tempComm); if (status != MPI_SUCCESS) { try { std::string message = "Failed to accept port "; message = message + DsmPortName; XdmfError::message(XdmfError::FATAL, message); } catch (XdmfError & e) { throw e; } } // False is specified for high so that the index of the cores doesn't change MPI_Comm mergedComm; status = MPI_Intercomm_merge(tempComm, false, &mergedComm); this->DupInterComm(mergedComm); if (status != MPI_SUCCESS) { try { XdmfError::message(XdmfError::FATAL, "Failed to merge InterComm"); } catch (XdmfError & e) { throw e; } } else { MPI_Comm_rank(InterComm, &InterId); MPI_Comm_size(InterComm, &InterSize); } } //regen Intra comm from Inter Comm MPI_Group IntraGroup, InterGroup; MPI_Comm_group(InterComm, &InterGroup); int * ServerIds = (int *)calloc(this->IntraSize, sizeof(int)); unsigned int index = 0; for(int i=this->InterId - this->Id; i < this->InterId - this->Id + this->IntraSize; ++i) { ServerIds[index++] = i; } MPI_Group_incl(InterGroup, this->IntraSize, ServerIds, &IntraGroup); MPI_Comm_create(InterComm, IntraGroup, &IntraComm); cfree(ServerIds); // Since this is accept, we will be recieving the local data from the new core and // sending the overarching data to the connecting cores unsigned int length; char * appname; unsigned int appsize; if (DsmProcessStructure.size() == 0) { DsmProcessStructure.push_back(std::pair(this->ApplicationName, this->IntraSize)); } int numSections = DsmProcessStructure.size(); if (InterId == 0) { // Loop in the applicaiton names of the already existing sections of the DSM // Get the number of application sections MPI_Send(&numSections, 1, MPI_INT, acceptingLeadId, XDMF_DSM_EXCHANGE_TAG, this->InterComm); for (unsigned int i = 0; i < numSections; ++i) { length = DsmProcessStructure[i].first.size(); // Get the length of the name MPI_Send(&length, 1, MPI_UNSIGNED, acceptingLeadId, XDMF_DSM_EXCHANGE_TAG, InterComm); // Get the string of characters appname = new char[length](); strcpy(appname, DsmProcessStructure[i].first.c_str()); MPI_Send(appname, length, MPI_CHAR, acceptingLeadId, XDMF_DSM_EXCHANGE_TAG, InterComm); delete appname; // Get associated numprocs appsize = DsmProcessStructure[i].second; MPI_Send(&appsize, 1, MPI_UNSIGNED, acceptingLeadId, XDMF_DSM_EXCHANGE_TAG, InterComm); } } // Add the information for the newly added application // For each application in the connecting set. MPI_Bcast(&numSections, 1, MPI_UNSIGNED, acceptingLeadId, InterComm); for (unsigned int i = 0; i < numSections; ++i) { MPI_Bcast(&length, 1, MPI_UNSIGNED, acceptingLeadId, InterComm); appname = new char[length+1](); MPI_Bcast(appname, length, MPI_CHAR, acceptingLeadId, InterComm); appname[length] = 0; MPI_Bcast(&appsize, 1, MPI_UNSIGNED, acceptingLeadId, InterComm); DsmProcessStructure.push_back(std::pair(std::string(appname), appsize)); } --numConnections; MPI_Bcast(&numConnections, 1, MPI_INT, 0, InterComm); } #endif } void XdmfDSMCommMPI::AllGather(void *sendbuf, int sendbytes, void *recvbuf, int recvbytes, int comm) { if (comm == XDMF_DSM_INTRA_COMM) { MPI_Allgather(sendbuf, sendbytes, MPI_UNSIGNED_CHAR, recvbuf, recvbytes, MPI_UNSIGNED_CHAR, IntraComm); } else if (comm == XDMF_DSM_INTER_COMM) { MPI_Allgather(sendbuf, sendbytes, MPI_UNSIGNED_CHAR, recvbuf, recvbytes, MPI_UNSIGNED_CHAR, InterComm); } } void XdmfDSMCommMPI::Barrier(int comm) { int status; if (comm == XDMF_DSM_INTRA_COMM) { status = MPI_Barrier(IntraComm); } else if (comm == XDMF_DSM_INTER_COMM) { status = MPI_Barrier(InterComm); } } void XdmfDSMCommMPI::Broadcast(void * pointer, int sizebytes, int root, int comm) { int status; if (comm == XDMF_DSM_INTRA_COMM) { status = MPI_Bcast(pointer, sizebytes, MPI_UNSIGNED_CHAR, root, IntraComm); } else if (comm == XDMF_DSM_INTER_COMM) { status = MPI_Bcast(pointer, sizebytes, MPI_UNSIGNED_CHAR, root, InterComm); } } void XdmfDSMCommMPI::ClosePort() { #ifndef XDMF_DSM_IS_CRAY if (Id == 0) { int status; for (unsigned int i = 0; i < PreviousDsmPortNames.size(); ++i) { status = MPI_Close_port(PreviousDsmPortNames[i]); if (status != MPI_SUCCESS) { try {// OpenMPI iterate through open ports in order to close the multiple needed std::string message = "Failed to close port "; message = message + PreviousDsmPortNames[i]; XdmfError::message(XdmfError::FATAL, message); } catch (XdmfError & e) { throw e; } } } } #endif HasOpenedPort = false; } int XdmfDSMCommMPI::Connect() { #ifndef XDMF_DSM_IS_CRAY int status; MPI_Status mpistatus; if (InterComm == MPI_COMM_NULL) { this->DupInterComm(IntraComm); } MPI_Comm tempComm; MPI_Comm tempConnectComm; MPI_Comm_dup(InterComm, &tempConnectComm); MPI_Errhandler_set(InterComm, MPI_ERRORS_RETURN); status = MPI_Comm_connect(DsmPortName, MPI_INFO_NULL, 0, tempConnectComm, &tempComm); MPI_Errhandler_set(InterComm, MPI_ERRORS_ARE_FATAL); if (status != MPI_SUCCESS) { try { std::string message = "Failed to connect to port "; message = message + DsmPortName; XdmfError::message(XdmfError::FATAL, message); } catch (XdmfError & e) { throw e; } } MPI_Comm mergedComm; status = MPI_Intercomm_merge(tempComm, true, &mergedComm); this->DupInterComm(mergedComm); if (status != MPI_SUCCESS) { try { XdmfError::message(XdmfError::FATAL, "Failed to merge InterComm"); } catch (XdmfError & e) { throw e; } } else { status = MPI_Comm_rank(InterComm, &InterId); status = MPI_Comm_size(InterComm, &InterSize); } //regen Intra comm from Inter Comm MPI_Group IntraGroup, InterGroup; MPI_Comm_group(InterComm, &InterGroup); int * ServerIds = (int *)calloc(this->IntraSize, sizeof(int)); unsigned int index = 0; for(int i=this->InterId - this->Id; i < this->InterId - this->Id + this->IntraSize; ++i) { ServerIds[index++] = i; } MPI_Group_incl(InterGroup, this->IntraSize, ServerIds, &IntraGroup); MPI_Comm_create(InterComm, IntraGroup, &IntraComm); cfree(ServerIds); // Here the process will send information about itself to the server and // the server will diseminate that info across all the connected processes std::vector > structureArchive; // Archive old structure if it exists if (DsmProcessStructure.size() > 0) { for (unsigned int i = 0; i < DsmProcessStructure.size(); ++i) { structureArchive.push_back(DsmProcessStructure[i]); } DsmProcessStructure.clear(); } // Loop in the applicaiton names of the already existing sections of the DSM // Get the number of application sections int numSections; if (this->Id == 0) { MPI_Recv(&numSections, 1, MPI_INT, 0, XDMF_DSM_EXCHANGE_TAG, this->InterComm, &mpistatus); } MPI_Bcast(&numSections, 1, MPI_INT, 0, IntraComm); unsigned int length; char * appname; unsigned int appsize; for (unsigned int i = 0; i < numSections; ++i) { if (this->Id == 0) { // Get the length of the name MPI_Recv(&length, 1, MPI_UNSIGNED, 0, XDMF_DSM_EXCHANGE_TAG, InterComm, &mpistatus); // Get the string of characters appname = new char[length+1](); MPI_Recv(appname, length, MPI_CHAR, 0, XDMF_DSM_EXCHANGE_TAG, InterComm, &mpistatus); appname[length] = 0; // Get associated numprocs MPI_Recv(&appsize, 1, MPI_UNSIGNED, 0, XDMF_DSM_EXCHANGE_TAG, InterComm, &mpistatus); } // Broadcast to local comm MPI_Bcast(&length, 1, MPI_UNSIGNED, 0, IntraComm); if (this->Id != 0) { appname = new char[length+1](); } MPI_Bcast(appname, length+1, MPI_CHAR, 0, IntraComm); MPI_Bcast(&appsize, 1, MPI_UNSIGNED, 0, IntraComm); DsmProcessStructure.push_back(std::pair(std::string(appname), appsize)); } if (structureArchive.size() == 0) { numSections = 1; MPI_Bcast(&numSections, 1, MPI_INT, InterId-Id, InterComm); length = ApplicationName.size(); appsize = this->IntraSize; MPI_Bcast(&length, 1, MPI_UNSIGNED, InterId-Id, InterComm); appname = new char[length](); strcpy(appname, ApplicationName.c_str()); MPI_Bcast(appname, length, MPI_CHAR, InterId-Id, InterComm); delete appname; MPI_Bcast(&appsize, 1, MPI_UNSIGNED, InterId-Id, InterComm); DsmProcessStructure.push_back(std::pair(ApplicationName, appsize)); } else { numSections = structureArchive.size(); MPI_Bcast(&numSections, 1, MPI_UNSIGNED, InterId-Id, InterComm); for (unsigned int i = 0; i < numSections; ++i) { length = structureArchive[i].first.size(); appsize = structureArchive[i].second; MPI_Bcast(&length, 1, MPI_UNSIGNED, InterId-Id, InterComm); appname = new char[length](); strcpy(appname, structureArchive[i].first.c_str()); MPI_Bcast(appname, length, MPI_CHAR, InterId-Id, InterComm); delete appname; MPI_Bcast(&appsize, 1, MPI_UNSIGNED, InterId-Id, InterComm); DsmProcessStructure.push_back(std::pair(structureArchive[i].first, appsize)); } } int numAccepts = 0; MPI_Bcast(&numAccepts, 1, MPI_INT, 0, InterComm); #ifdef OPEN_MPI if (numAccepts > 0) { MPI_Bcast(DsmPortName, MPI_MAX_PORT_NAME, MPI_CHAR, 0, InterComm); } #endif Accept(numAccepts); return MPI_SUCCESS; #endif return MPI_SUCCESS; } void XdmfDSMCommMPI::Disconnect() { #ifndef XDMF_DSM_IS_CRAY #ifndef OPEN_MPI if (InterComm != MPI_COMM_NULL) { int status = MPI_Comm_free(&InterComm); if (status != MPI_SUCCESS) { try { XdmfError::message(XdmfError::FATAL, "Failed to disconnect Comm"); } catch (XdmfError & e) { throw e; } } } #endif #endif InterComm = MPI_COMM_NULL; } void XdmfDSMCommMPI::DupComm(MPI_Comm comm) { if (IntraComm != comm) { int status; #ifndef OPEN_MPI if (IntraComm != MPI_COMM_NULL) { status = MPI_Comm_free(&IntraComm); if (status != MPI_SUCCESS) { try { XdmfError::message(XdmfError::FATAL, "Failed to disconnect Comm"); } catch (XdmfError & e) { throw e; } } } #endif if (comm != MPI_COMM_NULL) { status = MPI_Comm_dup(comm, &IntraComm); if (status != MPI_SUCCESS) { try { XdmfError::message(XdmfError::FATAL, "Failed to duplicate Comm"); } catch (XdmfError & e) { throw e; } } else { status = MPI_Comm_size(IntraComm, &IntraSize); status = MPI_Comm_rank(IntraComm, &Id); } } } } void XdmfDSMCommMPI::DupInterComm(MPI_Comm comm) { if (InterComm != comm) { int status; #ifndef OPEN_MPI if (InterComm != MPI_COMM_NULL) { status = MPI_Comm_free(&InterComm); if (status != MPI_SUCCESS) { try { XdmfError::message(XdmfError::FATAL, "Failed to disconnect Comm"); } catch (XdmfError & e) { throw e; } } } #endif if (comm != MPI_COMM_NULL) { status = MPI_Comm_dup(comm, &InterComm); if (status != MPI_SUCCESS) { try { XdmfError::message(XdmfError::FATAL, "Failed to duplicate Comm"); } catch (XdmfError & e) { throw e; } } else { status = MPI_Comm_rank(InterComm, &InterId); status = MPI_Comm_size(InterComm, &InterSize); } } else { InterId = -1; InterSize = -1; } } } std::string XdmfDSMCommMPI::GetApplicationName() { return ApplicationName; } std::string XdmfDSMCommMPI::GetDsmFileName() { return DsmFileName; } char * XdmfDSMCommMPI::GetDsmPortName() { return DsmPortName; } std::vector > XdmfDSMCommMPI::GetDsmProcessStructure() { return DsmProcessStructure; } int XdmfDSMCommMPI::GetId() { return this->Id; } MPI_Comm XdmfDSMCommMPI::GetInterComm() { return InterComm; } int XdmfDSMCommMPI::GetInterCommType() { return this->InterCommType; } int XdmfDSMCommMPI::GetInterId() { return this->InterId; } int XdmfDSMCommMPI::GetInterSize() { return this->InterSize; } MPI_Comm XdmfDSMCommMPI::GetIntraComm() { return IntraComm; } int XdmfDSMCommMPI::GetIntraSize() { return this->IntraSize; } bool XdmfDSMCommMPI::GetUseEnvFileName() { return XdmfDSMCommMPI::UseEnvFileName; } void XdmfDSMCommMPI::Init() { int size, rank; if (MPI_Comm_size(this->IntraComm, &size) != MPI_SUCCESS) { try { XdmfError::message(XdmfError::FATAL, "Failed to initialize size"); } catch (XdmfError & e) { throw e; } } if (MPI_Comm_rank(this->IntraComm, &rank) != MPI_SUCCESS) { try { XdmfError::message(XdmfError::FATAL, "Failed to initialize rank"); } catch (XdmfError & e) { throw e; } } this->Id = rank; this->IntraSize = size; } void XdmfDSMCommMPI::OpenPort() { if (Id == 0) { #ifndef XDMF_DSM_IS_CRAY int status = MPI_Open_port(MPI_INFO_NULL, DsmPortName); if (status != MPI_SUCCESS) { try { std::string message = "Failed to open port "; message = message + DsmPortName; XdmfError::message(XdmfError::FATAL, message); } catch (XdmfError & e) { throw e; } } PreviousDsmPortNames.push_back(DsmPortName); #endif std::ofstream connectFile (DsmFileName.c_str()); if (connectFile.is_open()) { connectFile << DsmPortName; connectFile.close(); } else { try { XdmfError::message(XdmfError::FATAL, "Failed to write port to file"); } catch (XdmfError & e) { throw e; } } HasOpenedPort = true; } #ifndef XDMF_DSM_IS_CRAY MPI_Bcast(DsmPortName, MPI_MAX_PORT_NAME, MPI_CHAR, 0, IntraComm); #endif } void XdmfDSMCommMPI::Probe(int *comm) { // Used for finding a comm that has a waiting command, then sets the comm int status = XDMF_DSM_FAIL; MPI_Status signalStatus; int flag; MPI_Comm probeComm = this->GetIntraComm(); // Spin until a message is found on one of the communicators while (status != XDMF_DSM_SUCCESS) { status = MPI_Iprobe(XDMF_DSM_ANY_SOURCE, XDMF_DSM_ANY_TAG, probeComm, &flag, &signalStatus); if (status != MPI_SUCCESS) { try { XdmfError::message(XdmfError::FATAL, "Error: Failed to probe for command header"); } catch (XdmfError & e) { throw e; } } if (flag) { status = XDMF_DSM_SUCCESS; } else { if (this->GetInterComm() != MPI_COMM_NULL) { if (probeComm == this->GetIntraComm()) { probeComm = this->GetInterComm(); } else { probeComm = this->GetIntraComm(); } } } } if (probeComm == this->GetInterComm()) { *comm = XDMF_DSM_INTER_COMM; } else { *comm = XDMF_DSM_INTRA_COMM; } probeComm = MPI_COMM_NULL; } void XdmfDSMCommMPI::ReadDsmPortName() { #ifndef XDMF_DSM_IS_CRAY std::ifstream connectFile(DsmFileName.c_str()); std::string connectLine; if (connectFile.is_open()) { getline(connectFile, connectLine); } strcpy(DsmPortName, connectLine.c_str()); #endif } void XdmfDSMCommMPI::Send(void * pointer, int sizebytes, int coreTo, int comm, int tag) { int status; if (comm == XDMF_DSM_INTRA_COMM) { status = MPI_Send(pointer, sizebytes, MPI_UNSIGNED_CHAR, coreTo, tag, IntraComm); } else if (comm == XDMF_DSM_INTER_COMM) { status = MPI_Send(pointer, sizebytes, MPI_UNSIGNED_CHAR, coreTo, tag, InterComm); } } void XdmfDSMCommMPI::Receive(void * pointer, int sizebytes, int coreFrom, int comm, int tag) { int status; MPI_Status signalStatus; if (comm == XDMF_DSM_INTRA_COMM) { status = MPI_Recv(pointer, sizebytes, MPI_UNSIGNED_CHAR, coreFrom, tag, IntraComm, &signalStatus); } else if (comm == XDMF_DSM_INTER_COMM) { status = MPI_Recv(pointer, sizebytes, MPI_UNSIGNED_CHAR, coreFrom, tag, InterComm, &signalStatus); } } void XdmfDSMCommMPI::SetApplicationName(std::string newName) { ApplicationName = newName; } void XdmfDSMCommMPI::SetDsmFileName(std::string filename) { DsmFileName = filename; } void XdmfDSMCommMPI::SetDsmPortName(const char *hostName) { strcpy(DsmPortName, hostName); } void XdmfDSMCommMPI::SetDsmProcessStructure(std::vector > & newStructure) { DsmProcessStructure = newStructure; } void XdmfDSMCommMPI::SetUseEnvFileName(bool status) { XdmfDSMCommMPI::UseEnvFileName = status; } // C Wrappers XDMFDSMCOMMMPI * XdmfDSMCommMPINew() { try { return (XDMFDSMCOMMMPI *)((void *)(new XdmfDSMCommMPI())); } catch (...) { return (XDMFDSMCOMMMPI *)((void *)(new XdmfDSMCommMPI())); } } void XdmfDSMCommMPIFree(XDMFDSMCOMMMPI * item) { if (item != NULL) { delete ((XdmfDSMCommMPI *)item); } item = NULL; } void XdmfDSMCommMPIAccept(XDMFDSMCOMMMPI * dsmComm, unsigned int numConnections, int * status) { XDMF_ERROR_WRAP_START(status) ((XdmfDSMCommMPI *)dsmComm)->Accept(numConnections); XDMF_ERROR_WRAP_END(status) } void XdmfDSMCommMPIClosePort(XDMFDSMCOMMMPI * dsmComm, int * status) { XDMF_ERROR_WRAP_START(status) ((XdmfDSMCommMPI *)dsmComm)->ClosePort(); XDMF_ERROR_WRAP_END(status) } int XdmfDSMCommMPIConnect(XDMFDSMCOMMMPI * dsmComm, int * status) { XDMF_ERROR_WRAP_START(status) return ((XdmfDSMCommMPI *)dsmComm)->Connect(); XDMF_ERROR_WRAP_END(status) return -1; } void XdmfDSMCommMPIDisconnect(XDMFDSMCOMMMPI * dsmComm, int * status) { XDMF_ERROR_WRAP_START(status) ((XdmfDSMCommMPI *)dsmComm)->Disconnect(); XDMF_ERROR_WRAP_END(status) } void XdmfDSMCommMPIDupComm(XDMFDSMCOMMMPI * dsmComm, MPI_Comm comm, int * status) { XDMF_ERROR_WRAP_START(status) ((XdmfDSMCommMPI *)dsmComm)->DupComm(comm); XDMF_ERROR_WRAP_END(status) } void XdmfDSMCommMPIDupInterComm(XDMFDSMCOMMMPI * dsmComm, MPI_Comm comm, int * status) { XDMF_ERROR_WRAP_START(status) ((XdmfDSMCommMPI *)dsmComm)->DupInterComm(comm); XDMF_ERROR_WRAP_END(status) } char * XdmfDSMCommMPIGetApplicationName(XDMFDSMCOMMMPI * dsmComm) { try { char * returnPointer = strdup(((XdmfDSMCommMPI *)dsmComm)->GetApplicationName().c_str()); return returnPointer; } catch (...) { char * returnPointer = strdup(((XdmfDSMCommMPI *)dsmComm)->GetApplicationName().c_str()); return returnPointer; } } char * XdmfDSMCommMPIGetDsmFileName(XDMFDSMCOMMMPI * dsmComm) { try { char * returnPointer = strdup(((XdmfDSMCommMPI *)dsmComm)->GetDsmFileName().c_str()); return returnPointer; } catch (...) { char * returnPointer = strdup(((XdmfDSMCommMPI *)dsmComm)->GetDsmFileName().c_str()); return returnPointer; } } char * XdmfDSMCommMPIGetDsmPortName(XDMFDSMCOMMMPI * dsmComm) { try { return ((XdmfDSMCommMPI *)dsmComm)->GetDsmPortName(); } catch (...) { return ((XdmfDSMCommMPI *)dsmComm)->GetDsmPortName(); } } void XdmfDSMCommMPIGetDsmProcessStructure(XDMFDSMCOMMMPI * dsmComm, char ** names, unsigned int * coreCount, int * numApplications) { try { std::vector > structure = ((XdmfDSMCommMPI *)dsmComm)->GetDsmProcessStructure(); *numApplications = structure.size(); coreCount = new unsigned int[*numApplications](); names = new char *[*numApplications](); for (unsigned int i = 0; i < *numApplications; ++i) { coreCount[i] = structure[i].second; names[i] = strdup(structure[i].first.c_str()); } } catch (...) { std::vector > structure = ((XdmfDSMCommMPI *)dsmComm)->GetDsmProcessStructure(); *numApplications = structure.size(); coreCount = new unsigned int[*numApplications](); names = new char *[*numApplications](); for (unsigned int i = 0; i < *numApplications; ++i) { coreCount[i] = structure[i].second; names[i] = strdup(structure[i].first.c_str()); } } } int XdmfDSMCommMPIGetId(XDMFDSMCOMMMPI * dsmComm) { try { return ((XdmfDSMCommMPI *)dsmComm)->GetId(); } catch (...) { return ((XdmfDSMCommMPI *)dsmComm)->GetId(); } } MPI_Comm XdmfDSMCommMPIGetInterComm(XDMFDSMCOMMMPI * dsmComm) { try { return ((XdmfDSMCommMPI *)dsmComm)->GetInterComm(); } catch (...) { return ((XdmfDSMCommMPI *)dsmComm)->GetInterComm(); } } int XdmfDSMCommMPIGetInterCommType(XDMFDSMCOMMMPI * dsmComm) { try { return ((XdmfDSMCommMPI *)dsmComm)->GetInterCommType(); } catch (...) { return ((XdmfDSMCommMPI *)dsmComm)->GetInterCommType(); } } int XdmfDSMCommMPIGetInterId(XDMFDSMCOMMMPI * dsmComm) { try { return ((XdmfDSMCommMPI *)dsmComm)->GetInterId(); } catch (...) { return ((XdmfDSMCommMPI *)dsmComm)->GetInterId(); } } int XdmfDSMCommMPIGetInterSize(XDMFDSMCOMMMPI * dsmComm) { try { return ((XdmfDSMCommMPI *)dsmComm)->GetInterSize(); } catch (...) { return ((XdmfDSMCommMPI *)dsmComm)->GetInterSize(); } } MPI_Comm XdmfDSMCommMPIGetIntraComm(XDMFDSMCOMMMPI * dsmComm) { try { return ((XdmfDSMCommMPI *)dsmComm)->GetIntraComm(); } catch (...) { return ((XdmfDSMCommMPI *)dsmComm)->GetIntraComm(); } } int XdmfDSMCommMPIGetIntraSize(XDMFDSMCOMMMPI * dsmComm) { try { return ((XdmfDSMCommMPI *)dsmComm)->GetIntraSize(); } catch (...) { return ((XdmfDSMCommMPI *)dsmComm)->GetIntraSize(); } } int XdmfDSMCommMPIGetUseEnvFileName(XDMFDSMCOMMMPI * dsmComm) { try { return ((XdmfDSMCommMPI *)dsmComm)->GetUseEnvFileName(); } catch (...) { return ((XdmfDSMCommMPI *)dsmComm)->GetUseEnvFileName(); } } void XdmfDSMCommMPIInit(XDMFDSMCOMMMPI * dsmComm, int * status) { XDMF_ERROR_WRAP_START(status) ((XdmfDSMCommMPI *)dsmComm)->Init(); XDMF_ERROR_WRAP_END(status) } void XdmfDSMCommMPIOpenPort(XDMFDSMCOMMMPI * dsmComm, int * status) { XDMF_ERROR_WRAP_START(status) ((XdmfDSMCommMPI *)dsmComm)->OpenPort(); XDMF_ERROR_WRAP_END(status) } void XdmfDSMCommMPIReadDsmPortName(XDMFDSMCOMMMPI * dsmComm) { try { ((XdmfDSMCommMPI *)dsmComm)->ReadDsmPortName(); } catch (...) { ((XdmfDSMCommMPI *)dsmComm)->ReadDsmPortName(); } } void XdmfDSMCommMPISetApplicationName(XDMFDSMCOMMMPI * dsmComm, char * newName) { try { ((XdmfDSMCommMPI *)dsmComm)->SetApplicationName(std::string(newName)); } catch (...) { ((XdmfDSMCommMPI *)dsmComm)->SetApplicationName(std::string(newName)); } } void XdmfDSMCommMPISetDsmFileName(XDMFDSMCOMMMPI * dsmComm, char * filename) { try { ((XdmfDSMCommMPI *)dsmComm)->SetDsmFileName(std::string(filename)); } catch (...) { ((XdmfDSMCommMPI *)dsmComm)->SetDsmFileName(std::string(filename)); } } void XdmfDSMCommMPISetDsmPortName(XDMFDSMCOMMMPI * dsmComm, char * hostName) { try { ((XdmfDSMCommMPI *)dsmComm)->SetDsmPortName(hostName); } catch (...) { ((XdmfDSMCommMPI *)dsmComm)->SetDsmPortName(hostName); } } void XdmfDSMCommMPISetUseEnvFileName(XDMFDSMCOMMMPI * dsmComm, int status) { try { ((XdmfDSMCommMPI *)dsmComm)->SetUseEnvFileName(status); } catch (...) { ((XdmfDSMCommMPI *)dsmComm)->SetUseEnvFileName(status); } } xdmf-3.0+git20160803/core/dsm/XdmfDSMDescription.cpp0000640000175000017500000000752213003006557021765 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfDSMDescription.hpp */ /* */ /* Author: */ /* Andrew Burns */ /* andrew.j.burns2@us.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2013 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #include #include "XdmfError.hpp" #include "XdmfDSMDescription.hpp" #include "XdmfSharedPtr.hpp" #include "XdmfVisitor.hpp" #include #include "string.h" shared_ptr XdmfDSMDescription::New() { shared_ptr p(new XdmfDSMDescription()); return p; } XdmfDSMDescription::XdmfDSMDescription() { } XdmfDSMDescription::XdmfDSMDescription(XdmfDSMDescription & refDescription) : XdmfHeavyDataDescription(refDescription) { } XdmfDSMDescription::~XdmfDSMDescription() { } const std::string XdmfDSMDescription::ItemTag = "DSM"; std::map XdmfDSMDescription::getItemProperties() const { std::map descriptionProperties; descriptionProperties["Port"] = mPortDescription; return descriptionProperties; } std::string XdmfDSMDescription::getItemTag() const { return ItemTag; } std::string XdmfDSMDescription::getPortDescription() const { return mPortDescription; } void XdmfDSMDescription::populateItem(const std::map & itemProperties, const std::vector > & childItems, const XdmfCoreReader * const reader) { XdmfItem::populateItem(itemProperties, childItems, reader); } void XdmfDSMDescription::setPortDescription(std::string portDesc) { mPortDescription = portDesc; this->setIsChanged(true); } void XdmfDSMDescription::traverse(const shared_ptr visitor) { } XDMFDSMDESCRIPTION * XdmfDSMDescriptionNew(char * key, char * value) { try { std::string createKey(key); std::string createValue(value); shared_ptr generatedDesc = XdmfDSMDescription::New(); return (XDMFDSMDESCRIPTION *)((void *)(new XdmfDSMDescription(*generatedDesc.get()))); } catch (...) { std::string createKey(key); std::string createValue(value); shared_ptr generatedDesc = XdmfDSMDescription::New(); return (XDMFDSMDESCRIPTION *)((void *)(new XdmfDSMDescription(*generatedDesc.get()))); } } XDMF_ITEM_C_CHILD_WRAPPER(XdmfDSMDescription, XDMFDSMDESCRIPTION) xdmf-3.0+git20160803/core/dsm/tests/0000740000175000017500000000000013003006557016745 5ustar alastairalastairxdmf-3.0+git20160803/core/dsm/tests/Cxx/0000740000175000017500000000000013003006557017507 5ustar alastairalastairxdmf-3.0+git20160803/core/dsm/tests/Cxx/TestXdmfHDF5WriterDSM.cpp0000640000175000017500000001006513003006557024125 0ustar alastairalastair#include #include #include "XdmfArray.hpp" #include "XdmfArrayType.hpp" #include "XdmfHDF5ControllerDSM.hpp" #include "XdmfHDF5WriterDSM.hpp" int main(int argc, char *argv[]) { int rank, size, provided, dsmSize = 16; MPI_Comm comm = MPI_COMM_WORLD; MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided); MPI_Comm_rank(comm, &rank); MPI_Comm_size(comm, &size); if (rank == 0) { if (provided != MPI_THREAD_MULTIPLE) { std::cout << "# MPI_THREAD_MULTIPLE not set, you may need to recompile your " << "MPI distribution with threads enabled" << std::endl; } else { std::cout << "# MPI_THREAD_MULTIPLE is OK" << std::endl; } } // Create DSM H5FDdsmManager * dsmManager = new H5FDdsmManager(); dsmManager->SetMpiComm(comm); dsmManager->SetLocalBufferSizeMBytes(dsmSize / size); dsmManager->SetLocalBufferSizeMBytes(dsmSize / size); dsmManager->SetIsStandAlone(H5FD_DSM_TRUE); dsmManager->Create(); H5FD_dsm_set_manager(dsmManager); H5FD_dsm_set_options(H5FD_DSM_LOCK_ASYNCHRONOUS); H5FDdsmBuffer * dsmBuffer = dsmManager->GetDsmBuffer(); // Get info from remote server double remoteMB = dsmBuffer->GetTotalLength() / (1024.0 * 1024.0); double numServers = dsmBuffer->GetEndServerId() + 1; if (rank == 0) { std::cout << "DSM server memory size is : " << (int)remoteMB << " MB" << std::endl; std::cout << "DSM server process count : " << (int)numServers << std::endl; } // Create Array // Array should be distributed among processes shared_ptr array = XdmfArray::New(); array->initialize(0); array->pushBack(rank*3); array->pushBack(rank*3 + 1); array->pushBack(rank*3 + 2); shared_ptr controller = XdmfHDF5ControllerDSM::New("dsm.h5", "data", XdmfArrayType::Int32(), std::vector(1, rank*3), std::vector(1, 1), std::vector(1, 3), std::vector(1, size*3), dsmBuffer); array->setHeavyDataController(controller); // Create DSM Writer and write to DSM space. shared_ptr writer = XdmfHDF5WriterDSM::New("dsm.h5", dsmBuffer); writer->setMode(XdmfHeavyDataWriter::Hyperslab); array->accept(writer); //H5FD_dsm_dump(); // Release data and read back in to check if we wrote correctly array->release(); array->read(); std::cout << array->getSize() << "?=" << 3 << std::endl; assert(array->getSize() == 3); std::cout << array->getValue(0) << "?=" << 3*rank << std::endl; assert(array->getValue(0) == 3*rank); std::cout << array->getValue(1) << "?=" << ((3*rank) + 1) << std::endl; assert(array->getValue(1) == 3*rank + 1); std::cout << array->getValue(2) << "?=" << ((3*rank) + 2) << std::endl; assert(array->getValue(2) == 3*rank + 2); MPI_Barrier(comm); // Adjust controller to read entire dataset onto each processor shared_ptr fullController = XdmfHDF5ControllerDSM::New("dsm.h5", "data", XdmfArrayType::Int32(), std::vector(1, 0), std::vector(1, 1), std::vector(1, size*3), std::vector(1, size*3), dsmBuffer); array->setHeavyDataController(fullController); array->release(); array->read(); std::cout << array->getSize() << "?=" << (size * 3) << std::endl; assert(array->getSize() == size*3); for(int i=0; igetValue(i) << "?=" << i << std::endl; assert(array->getValue(i) == i); } // Wait for everyone to have finished reading MPI_Barrier(comm); delete dsmManager; MPI_Finalize(); return 0; } xdmf-3.0+git20160803/core/dsm/tests/Cxx/XdmfAcceptTest.cpp0000640000175000017500000000643413003006557023102 0ustar alastairalastair#include #include #include #include #include #include #include #include int main(int argc, char *argv[]) { // This test does not work properly with openmpi // due to an issue with the openmpi code #ifndef OPEN_MPI //#initMPI begin int size, id, dsmSize; dsmSize = 64; MPI_Status status; MPI_Comm comm = MPI_COMM_WORLD; MPI_Init(&argc, &argv); MPI_Comm_rank(comm, &id); MPI_Comm_size(comm, &size); XdmfDSMCommMPI::SetUseEnvFileName(true); std::string newPath = "dsm"; int numServersCores = size - 1; int numConnections = 2; // shared_ptr exampleWriter = XdmfHDF5WriterDSM::New(newPath, comm, dsmSize/numServersCores, size-numServersCores, size-1); shared_ptr exampleWriter = XdmfHDF5WriterDSM::New(newPath, comm, dsmSize/numServersCores, 1, 1, "Accept"); if (id == 0) { //#initMPI end //#GetDsmFileName begin std::string connectionFileName = exampleWriter->getServerBuffer()->GetComm()->GetDsmFileName(); //#GetDsmFileName end //#SetDsmFileName begin exampleWriter->getServerBuffer()->GetComm()->SetDsmFileName(connectionFileName); //#SetDsmFileName end //#OpenPort begin exampleWriter->getServerBuffer()->GetComm()->OpenPort(); //#OpenPort end //#SendAccept begin exampleWriter->getServerBuffer()->SendAccept(numConnections); //#SendAccept end /* //#manualAccept begin // Notify the server cores to accept connections for (int i = exampleWriter->getServerBuffer()->StartServerId; i <= exampleWriter->getServerBuffer()->EndServerId; ++i) { if (i != exampleWriter->getServerBuffer()->Comm->GetId()) { exampleWriter->getServerBuffer()->SendCommandHeader(XDMF_DSM_ACCEPT, i, 0, 0, XDMF_DSM_INTER_COMM); exampleWriter->getServerBuffer()->SendAcknowledgment(i, numConnections, XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM); } } // Accept connections exampleWriter->getServerBuffer()->Comm->Accept(numConnections); // Distribute current DSM status exampleWriter->getServerBuffer()->SendInfo(); //#manualAccept end */ //#finishwork begin MPI_Barrier(exampleWriter->getServerBuffer()->GetComm()->GetIntraComm()); } MPI_Barrier(exampleWriter->getServerBuffer()->GetComm()->GetInterComm()); //#finishwork end //#ClosePort begin if (id == 0) { exampleWriter->getServerBuffer()->GetComm()->ClosePort(); } //#ClosePort end //#finalizeMPI begin MPI_Finalize(); //#finalizeMPI end #else std::cout << "Interprogram DSM does not work properly with OpenMPI" << std::endl; #endif return 0; } xdmf-3.0+git20160803/core/dsm/tests/Cxx/ConnectTest.sh0000740000175000017500000000023513003006557022277 0ustar alastairalastair# Intel MPI requires a minimum of 2 cores per process $MPIEXEC -n 2 ./XdmfAcceptTest & $MPIEXEC -n 2 ./XdmfConnectTest & $MPIEXEC -n 2 ./XdmfConnectTest2 xdmf-3.0+git20160803/core/dsm/tests/Cxx/XdmfConnectTestPaged.cpp0000640000175000017500000002423313003006557024232 0ustar alastairalastair#include #include #include #include #include #include #include #include #include #include #include int main(int argc, char *argv[]) { // This test does not work properly with openmpi // due to an issue with the openmpi code #ifndef OPEN_MPI //#initMPI begin int size, id, dsmSize; dsmSize = 64; MPI_Status status; MPI_Comm comm = MPI_COMM_WORLD; MPI_Init(&argc, &argv); MPI_Comm_rank(comm, &id); MPI_Comm_size(comm, &size); XdmfDSMCommMPI::SetUseEnvFileName(true); std::string newPath = "dsm"; std::string newSetPath = "Data"; // Initializing objects shared_ptr exampleWriter = XdmfHDF5WriterDSM::New(newPath, comm); exampleWriter->getServerBuffer()->GetComm()->SetApplicationName("Connect 1"); /* XdmfDSMCommMPI * testComm = new XdmfDSMCommMPI(); testComm->DupComm(comm); testComm->Init(); XdmfDSMBuffer * testBuffer = new XdmfDSMBuffer(); testBuffer->SetIsServer(false); testBuffer->SetComm(testComm); testBuffer->SetIsConnected(true); shared_ptr exampleWriter = XdmfHDF5WriterDSM::New(newPath, testBuffer); */ //#initMPI end #ifdef _WIN32 Sleep(500) #else sleep(5); #endif char * configFileName = strdup(exampleWriter->getServerBuffer()->GetComm()->GetDsmFileName().c_str()); std::ifstream testStream; testStream.open(configFileName); while (!testStream.good()) { // Wait for the config file to be generated testStream.close(); #ifdef _WIN32 Sleep(500) #else sleep(5); #endif testStream.open(configFileName); } //#ReadDsmPortName begin exampleWriter->getServerBuffer()->GetComm()->ReadDsmPortName(); //#ReadDsmPortName end //#GetDsmPortName begin char * portName = exampleWriter->getServerBuffer()->GetComm()->GetDsmPortName(); //#GetDsmPortName end //#SetDsmPortName begin exampleWriter->getServerBuffer()->GetComm()->SetDsmPortName(portName); //#SetDsmPortName end //#Connect begin exampleWriter->getServerBuffer()->Connect(); //#Connect end exampleWriter->getServerBuffer()->SetIsConnected(true); /* //#manualConnect begin try { status = exampleWriter->getServerBuffer()->GetComm()->Connect(); } catch (XdmfError e) { // Connection failed std::cout << e.what() << std::endl; return 0; } if (status == MPI_SUCCESS) { exampleWriter->getServerBuffer()->SetIsConnected(true); try { exampleWriter->getServerBuffer()->ReceiveInfo(); } catch (XdmfError e) { //ReceiveInfo failed std::cout << e.what() << std::endl; return 0; } } //#manualConnect end */ MPI_Barrier(exampleWriter->getServerBuffer()->GetComm()->GetIntraComm()); // Testing the structure of the DSM if (id == 0) { std::vector structuresizes; structuresizes.push_back(1); structuresizes.push_back(1); structuresizes.push_back(2); structuresizes.push_back(2); std::vector structurenames; structurenames.push_back("Application"); structurenames.push_back("Server"); structurenames.push_back("Connect 1"); structurenames.push_back("Connect 2"); std::vector > teststructure = exampleWriter->getServerBuffer()->GetComm()->GetDsmProcessStructure(); printf("DSM Structure:\n"); for (unsigned int i = 0; i < teststructure.size(); ++i) { std::cout << "(" << teststructure[i].first << ", " << teststructure[i].second << ")" << std::endl; assert(teststructure[i].second == structuresizes[i]); assert(teststructure[i].first.compare(structurenames[i]) == 0); } } MPI_Barrier(exampleWriter->getServerBuffer()->GetComm()->GetIntraComm()); shared_ptr writeArray = XdmfArray::New(); for (int i = 1; i <= 5; ++i) { writeArray->pushBack(i*(id+1)); } std::vector writeStartVector; std::vector writeStrideVector; std::vector writeCountVector; std::vector writeDataSizeVector; writeStartVector.push_back(id*5); writeStrideVector.push_back(1); writeCountVector.push_back(5); writeDataSizeVector.push_back(5*size); shared_ptr writeController = XdmfHDF5ControllerDSM::New( newPath, newSetPath, XdmfArrayType::Int32(), writeStartVector, writeStrideVector, writeCountVector, writeDataSizeVector, exampleWriter->getServerBuffer()); std::vector readStartVector; std::vector readStrideVector; std::vector readCountVector; std::vector readDataSizeVector; readStartVector.push_back(5*id); readStrideVector.push_back(1); readCountVector.push_back(5); readDataSizeVector.push_back(5*size); shared_ptr readController = XdmfHDF5ControllerDSM::New( newPath, newSetPath, XdmfArrayType::Int32(), readStartVector, readStrideVector, readCountVector, readDataSizeVector, exampleWriter->getServerBuffer()); exampleWriter->setMode(XdmfHeavyDataWriter::Hyperslab); // Test Notify int notify = exampleWriter->waitOn(newPath, "notify"); printf("notification value = %d\n", notify); assert(notify == 3); // Done initializing for (int i = 0; i < size; ++i) { MPI_Barrier(exampleWriter->getServerBuffer()->GetComm()->GetIntraComm()); if (i == id) { std::stringstream outputstream; outputstream << "Array on core " << exampleWriter->getServerBuffer()->GetComm()->GetInterId() << " contains:" << std::endl; for (unsigned int j = 0; j < writeArray->getSize(); ++j) { outputstream << "[" << j << "]" << writeArray->getValue(j) << std::endl; } std::cout << outputstream.str(); } } for (unsigned int numloops = 0; numloops < 4; ++numloops) { if (writeArray->getNumberHeavyDataControllers() > 0) { writeArray->removeHeavyDataController(0); } writeArray->insert(writeController); if (id == size - 1) { std::cout << std::endl << std::endl; } writeArray->accept(exampleWriter); if (id == size - 1) { int sentData = 1; exampleWriter->getServerBuffer()->SendAcknowledgment(exampleWriter->getServerBuffer()->GetComm()->GetInterId() + 1, sentData, XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM); exampleWriter->getServerBuffer()->ReceiveAcknowledgment(exampleWriter->getServerBuffer()->GetComm()->GetInterId() + 1, sentData, XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM); } MPI_Barrier(exampleWriter->getServerBuffer()->GetComm()->GetIntraComm()); writeArray->removeHeavyDataController(0); writeArray->insert(readController); writeArray->release(); writeArray->read(); for (int i = 0; i < size; ++i) { MPI_Barrier(exampleWriter->getServerBuffer()->GetComm()->GetIntraComm()); if (i == id) { std::stringstream outputstream; outputstream << "Array on core " << exampleWriter->getServerBuffer()->GetComm()->GetInterId() << " contains:" << std::endl; for (unsigned int j = 0; j < writeArray->getSize(); ++j) { int tempVal = writeArray->getValue(j); tempVal = tempVal * 2; writeArray->insert(j, tempVal); outputstream << "[" << j << "]" << writeArray->getValue(j) << std::endl; } std::cout << outputstream.str(); } } } if (id == size - 1) { int sentData = 1; exampleWriter->getServerBuffer()->SendAcknowledgment(exampleWriter->getServerBuffer()->GetComm()->GetInterId() + 1, sentData, XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM); } MPI_Barrier(exampleWriter->getServerBuffer()->GetComm()->GetIntraComm()); MPI_Barrier(exampleWriter->getServerBuffer()->GetComm()->GetInterComm()); //#Disconnectmanager begin exampleWriter->getServerBuffer()->Disconnect(); //#Disconnectmanager end //#Disconnectcomm begin exampleWriter->getServerBuffer()->GetComm()->Disconnect(); //#Disconnectcomm end //#finalizeMPI begin MPI_Finalize(); //#finalizeMPI end #endif return 0; } xdmf-3.0+git20160803/core/dsm/tests/Cxx/CMakeLists.txt0000640000175000017500000000543513003006557022260 0ustar alastairalastair# Include our test macros include(AddTestsCxx) # Add any dependencies that the cxx core tests may need # Note: The tests already depend on their own file ADD_TEST_CXX_DEPENDENCIES("XdmfCore") ADD_TEST_CXX_DEPENDENCIES("XdmfDSM") # Add any ldpath directories that the cxx tests may need ADD_TEST_CXX_LDPATH("${CMAKE_BINARY_DIR}") ADD_TEST_CXX_LDPATH("${XDMF_LIBRARY_DIRS}") # Add any path directoreis that the Cxx tests may need ADD_TEST_CXX_PATH("${CMAKE_BINARY_DIR}") ADD_TEST_CXX_PATH("${XDMF_BINARIES}") # Add any cxx tests here: # Note: We don't want to use a foreach loop to test the files incase we # have extra arguments (ie: ADD_TEST_CXX(testname inputfile)) # Read UseCxxTest.cmake for more information # --------------------------------------- IF (MPIEXEC_MAX_NUMPROCS STRGREATER 5) if ("${XDMF_DSM_IS_CRAY}" STREQUAL "") ADD_MPI_TEST_CXX(DSMLoopTest.sh DSMLoopTest) ADD_MPI_TEST_CXX(DSMLoopTestPaged.sh DSMLoopTestPaged) ADD_MPI_TEST_CXX(DSMLoopTestPagedSingleCore.sh DSMLoopTestPagedSingleCore) ADD_MPI_TEST_CXX(ConnectTest.sh XdmfAcceptTest,XdmfConnectTest2,XdmfConnectTest) ADD_MPI_TEST_CXX(ConnectTestPaged.sh XdmfAcceptTestPaged,XdmfConnectTest2Paged,XdmfConnectTestPaged) else ("${XDMF_DSM_IS_CRAY}" STREQUAL "") ADD_MPI_TEST_CXX(DSMLoopTestPagedSingleCore.sh DSMLoopTestPagedSingleCore) ADD_MPI_TEST_CXX(CrayConnectTest.sh XdmfAcceptTest,XdmfConnectTest2,XdmfConnectTest) endif ("${XDMF_DSM_IS_CRAY}" STREQUAL "") ENDIF(MPIEXEC_MAX_NUMPROCS STRGREATER 5) # Add any cxx cleanup here: # Note: We don't want to use a foreach loop to test the files incase we # have multiple files (ie: CLEAN_TEST_CXX(testname outputfile1 ...)) # Read UseCxxTest.cmake for more information # --------------------------------------- IF (MPIEXEC_MAX_NUMPROCS STRGREATER 5) if ("${XDMF_DSM_IS_CRAY}" STREQUAL "") CLEAN_TEST_CXX(DSMLoopTest.sh) CLEAN_TEST_CXX(DSMLoopTestPaged.sh) if ("$ENV{XDMFDSM_CONFIG_FILE}" STREQUAL "") CLEAN_TEST_CXX(ConnectTest.sh dsmconnect.cfg) CLEAN_TEST_CXX(ConnectTestPaged.sh dsmconnect.cfg) else ("$ENV{XDMFDSM_CONFIG_FILE}" STREQUAL "") CLEAN_TEST_CXX(ConnectTest.sh "$ENV{XDMFDSM_CONFIG_FILE}") CLEAN_TEST_CXX(ConnectTestPaged.sh "$ENV{XDMFDSM_CONFIG_FILE}") endif ("$ENV{XDMFDSM_CONFIG_FILE}" STREQUAL "") else ("${XDMF_DSM_IS_CRAY}" STREQUAL "") CLEAN_TEST_CXX(DSMLoopTestPagedSingleCore.sh) if ("$ENV{XDMFDSM_CONFIG_FILE}" STREQUAL "") CLEAN_TEST_CXX(CrayConnectTest.sh dsmconnect.cfg) else ("$ENV{XDMFDSM_CONFIG_FILE}" STREQUAL "") CLEAN_TEST_CXX(CrayConnectTest.sh "$ENV{XDMFDSM_CONFIG_FILE}") endif ("$ENV{XDMFDSM_CONFIG_FILE}" STREQUAL "") endif ("${XDMF_DSM_IS_CRAY}" STREQUAL "") ENDIF (MPIEXEC_MAX_NUMPROCS STRGREATER 5) xdmf-3.0+git20160803/core/dsm/tests/Cxx/DSMLoopTestPagedSingleCore.sh0000740000175000017500000000005313003006557025075 0ustar alastairalastair$MPIEXEC -n 4 ./DSMLoopTestPagedSingleCore xdmf-3.0+git20160803/core/dsm/tests/Cxx/DSMLoopTestPagedSingleCore.cpp0000640000175000017500000001222513003006557025250 0ustar alastairalastair#include #include #include #include #include #include "XdmfArray.hpp" #include "XdmfArrayType.hpp" #include "XdmfHDF5WriterDSM.hpp" #include "XdmfHDF5ControllerDSM.hpp" int main(int argc, char *argv[]) { int size, id, dsmSize; dsmSize = 64;//The total size of the DSM being created MPI_Comm comm = MPI_COMM_WORLD; MPI_Init(&argc, &argv); MPI_Comm_rank(comm, &id); MPI_Comm_size(comm, &size); std::vector outputVector; shared_ptr testArray = XdmfArray::New(); testArray->initialize(0); shared_ptr testArray2 = XdmfArray::New(); testArray2->initialize(0); std::string newPath = "dsm"; std::stringstream setPathAggregate; setPathAggregate << "dataspace" << id; std::string newSetPath = setPathAggregate.str(); std::string secondSetPath = "data2"; // Change this to determine the number of cores used as servers unsigned int numServersCores = 2; // Change this to determine the size of the arrays generated when initializing unsigned int writeArraySize = 4; std::vector writeStartVector; std::vector writeStrideVector; std::vector writeCountVector; std::vector writeDataSizeVector; std::vector readStartVector; std::vector readStrideVector; std::vector readCountVector; std::vector readDataSizeVector; std::vector readOutputCountVector; shared_ptr readArray = XdmfArray::New(); readArray->initialize(0); shared_ptr readArray2 = XdmfArray::New(); readArray2->initialize(0); shared_ptr readController; shared_ptr readOutputController; shared_ptr writeController; shared_ptr readController2; shared_ptr readOutputController2; shared_ptr writeController2; MPI_Comm workerComm; MPI_Group workers, dsmgroup; MPI_Comm_group(comm, &dsmgroup); int * ServerIds = (int *)calloc((numServersCores), sizeof(int)); unsigned int index = 0; for(int i=size-numServersCores ; i <= size-1 ; ++i) { ServerIds[index++] = i; } MPI_Group_excl(dsmgroup, index, ServerIds, &workers); int testval = MPI_Comm_create(comm, workers, &workerComm); cfree(ServerIds); shared_ptr exampleWriter = XdmfHDF5WriterDSM::New(newPath, comm, dsmSize/numServersCores, 1024, 1, size-numServersCores, size-1); exampleWriter->setMode(XdmfHeavyDataWriter::Hyperslab); //split out sub-comm for the worker cores //server cores will not progress to this point until after the servers are done running if (id < size - (int)numServersCores) { // Split the comm even further // This Comm is for the individual cores MPI_Comm writeComm; MPI_Group readingCores, writingCores; MPI_Comm_group(workerComm, &workers); int * ServerIds = (int *)calloc(1, sizeof(int)); ServerIds[0] = id; MPI_Group_incl(workers, 1, ServerIds, &writingCores); testval = MPI_Comm_create(workerComm, writingCores, &writeComm); cfree(ServerIds); std::cout << "initializing" << std::endl; writeStartVector.push_back(0); writeStrideVector.push_back(1); writeCountVector.push_back(1); writeDataSizeVector.push_back(1); writeController = XdmfHDF5ControllerDSM::New( newPath, newSetPath, XdmfArrayType::Int32(), writeStartVector, writeStrideVector, writeCountVector, writeDataSizeVector, exampleWriter->getServerBuffer()); testArray->pushBack(id); testArray->insert(writeController); exampleWriter->setWorkerComm(writeComm); printf("writing to dsm\n"); testArray->accept(exampleWriter); printf("done writing to dsm\n"); MPI_Barrier(workerComm); exampleWriter->setWorkerComm(workerComm); printf("reading size\n"); int readsize = exampleWriter->getDataSetSize(newPath, newSetPath); printf("size of dataset %s:%s = %d\n", newPath.c_str(), newSetPath.c_str(), readsize); assert(readsize == 1); // exampleWriter->setWorkerComm(workerComm); } if (id == 0) { exampleWriter->stopDSM(); } MPI_Barrier(comm); printf("finalizing\n"); MPI_Finalize(); return 0; } xdmf-3.0+git20160803/core/dsm/tests/Cxx/XdmfConnectTest.cpp0000640000175000017500000002475713003006557023304 0ustar alastairalastair#include #include #include #include #include #include #include #include #include #include #include int main(int argc, char *argv[]) { // This test does not work properly with openmpi // due to an issue with the openmpi code #ifndef OPEN_MPI //#initMPI begin int size, id, dsmSize; dsmSize = 64; MPI_Status status; MPI_Comm comm = MPI_COMM_WORLD; MPI_Init(&argc, &argv); MPI_Comm_rank(comm, &id); MPI_Comm_size(comm, &size); XdmfDSMCommMPI::SetUseEnvFileName(true); std::string newPath = "dsm"; std::string newSetPath = "Data"; // Initializing objects shared_ptr exampleWriter = XdmfHDF5WriterDSM::New(newPath, comm, "Connect 1"); MPI_Comm_rank(exampleWriter->getServerBuffer()->GetComm()->GetIntraComm(), &id); MPI_Comm_size(exampleWriter->getServerBuffer()->GetComm()->GetIntraComm(), &size); // exampleWriter->getServerBuffer()->GetComm()->SetApplicationName("Connect 1"); /* XdmfDSMCommMPI * testComm = new XdmfDSMCommMPI(); testComm->DupComm(comm); testComm->Init(); XdmfDSMBuffer * testBuffer = new XdmfDSMBuffer(); testBuffer->SetIsServer(false); testBuffer->SetComm(testComm); testBuffer->SetIsConnected(true); shared_ptr exampleWriter = XdmfHDF5WriterDSM::New(newPath, testBuffer); */ //#initMPI end #ifdef _WIN32 Sleep(500) #else sleep(5); #endif char * configFileName = strdup(exampleWriter->getServerBuffer()->GetComm()->GetDsmFileName().c_str()); std::ifstream testStream; testStream.open(configFileName); while (!testStream.good()) { // Wait for the config file to be generated testStream.close(); #ifdef _WIN32 Sleep(500) #else sleep(5); #endif testStream.open(configFileName); } //#ReadDsmPortName begin exampleWriter->getServerBuffer()->GetComm()->ReadDsmPortName(); //#ReadDsmPortName end //#GetDsmPortName begin char * portName = exampleWriter->getServerBuffer()->GetComm()->GetDsmPortName(); //#GetDsmPortName end //#SetDsmPortName begin exampleWriter->getServerBuffer()->GetComm()->SetDsmPortName(portName); //#SetDsmPortName end //#Connect begin exampleWriter->getServerBuffer()->Connect(); //#Connect end exampleWriter->getServerBuffer()->SetIsConnected(true); /* //#manualConnect begin try { status = exampleWriter->getServerBuffer()->GetComm()->Connect(); } catch (XdmfError e) { // Connection failed std::cout << e.what() << std::endl; return 0; } if (status == MPI_SUCCESS) { exampleWriter->getServerBuffer()->SetIsConnected(true); try { exampleWriter->getServerBuffer()->ReceiveInfo(); } catch (XdmfError e) { //ReceiveInfo failed std::cout << e.what() << std::endl; return 0; } } //#manualConnect end */ MPI_Barrier(exampleWriter->getServerBuffer()->GetComm()->GetIntraComm()); // Testing the structure of the DSM if (id == 0) { std::vector structuresizes; structuresizes.push_back(1); structuresizes.push_back(1); structuresizes.push_back(2); structuresizes.push_back(2); std::vector structurenames; structurenames.push_back("Accept"); structurenames.push_back("Server"); structurenames.push_back("Connect 1"); structurenames.push_back("Connect 2"); std::vector > teststructure = exampleWriter->getServerBuffer()->GetComm()->GetDsmProcessStructure(); printf("DSM Structure:\n"); assert(teststructure.size() == structurenames.size()); for (unsigned int i = 0; i < teststructure.size(); ++i) { std::cout << "(" << teststructure[i].first << ", " << teststructure[i].second << ")" << "==" << "(" << structurenames[i] << ", " << structuresizes[i] << ")" << std::endl; assert(teststructure[i].second == structuresizes[i]); assert(teststructure[i].first.compare(structurenames[i]) == 0); } } MPI_Barrier(exampleWriter->getServerBuffer()->GetComm()->GetIntraComm()); shared_ptr writeArray = XdmfArray::New(); for (int i = 1; i <= 5; ++i) { writeArray->pushBack(i*(id+1)); } std::vector writeStartVector; std::vector writeStrideVector; std::vector writeCountVector; std::vector writeDataSizeVector; writeStartVector.push_back(id*5); writeStrideVector.push_back(1); writeCountVector.push_back(5); writeDataSizeVector.push_back(5*size); shared_ptr writeController = XdmfHDF5ControllerDSM::New( newPath, newSetPath, XdmfArrayType::Int32(), writeStartVector, writeStrideVector, writeCountVector, writeDataSizeVector, exampleWriter->getServerBuffer()); std::vector readStartVector; std::vector readStrideVector; std::vector readCountVector; std::vector readDataSizeVector; readStartVector.push_back(5*id); readStrideVector.push_back(1); readCountVector.push_back(5); readDataSizeVector.push_back(5*size); shared_ptr readController = XdmfHDF5ControllerDSM::New( newPath, newSetPath, XdmfArrayType::Int32(), readStartVector, readStrideVector, readCountVector, readDataSizeVector, exampleWriter->getServerBuffer()); exampleWriter->setMode(XdmfHeavyDataWriter::Hyperslab); // Test Notify int notify = exampleWriter->waitOn(newPath, "notify"); printf("notification value = %d\n", notify); assert(notify == 3); // Done initializing for (int i = 0; i < size; ++i) { MPI_Barrier(exampleWriter->getServerBuffer()->GetComm()->GetIntraComm()); if (i == id) { std::stringstream outputstream; outputstream << "Array on core " << exampleWriter->getServerBuffer()->GetComm()->GetInterId() << " contains:" << std::endl; for (unsigned int j = 0; j < writeArray->getSize(); ++j) { outputstream << "[" << j << "]" << writeArray->getValue(j) << std::endl; } std::cout << outputstream.str(); } } for (unsigned int numloops = 0; numloops < 4; ++numloops) { if (writeArray->getNumberHeavyDataControllers() > 0) { writeArray->removeHeavyDataController(0); } writeArray->insert(writeController); if (id == size - 1) { std::cout << std::endl << std::endl; } writeArray->accept(exampleWriter); if (id == size - 1) { int sentData = 1; exampleWriter->getServerBuffer()->SendAcknowledgment(exampleWriter->getServerBuffer()->GetComm()->GetInterId() + 1, sentData, XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM); exampleWriter->getServerBuffer()->ReceiveAcknowledgment(exampleWriter->getServerBuffer()->GetComm()->GetInterId() + 1, sentData, XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM); } MPI_Barrier(exampleWriter->getServerBuffer()->GetComm()->GetIntraComm()); writeArray->removeHeavyDataController(0); writeArray->insert(readController); writeArray->release(); writeArray->read(); for (int i = 0; i < size; ++i) { MPI_Barrier(exampleWriter->getServerBuffer()->GetComm()->GetIntraComm()); if (i == id) { std::stringstream outputstream; outputstream << "Array on core " << exampleWriter->getServerBuffer()->GetComm()->GetInterId() << " contains:" << std::endl; for (unsigned int j = 0; j < writeArray->getSize(); ++j) { int tempVal = writeArray->getValue(j); tempVal = tempVal * 2; writeArray->insert(j, tempVal); outputstream << "[" << j << "]" << writeArray->getValue(j) << std::endl; } std::cout << outputstream.str(); } } } if (id == size - 1) { int sentData = 1; exampleWriter->getServerBuffer()->SendAcknowledgment(exampleWriter->getServerBuffer()->GetComm()->GetInterId() + 1, sentData, XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM); } MPI_Barrier(exampleWriter->getServerBuffer()->GetComm()->GetIntraComm()); MPI_Barrier(exampleWriter->getServerBuffer()->GetComm()->GetInterComm()); //#Disconnectmanager begin exampleWriter->getServerBuffer()->Disconnect(); //#Disconnectmanager end //#Disconnectcomm begin exampleWriter->getServerBuffer()->GetComm()->Disconnect(); //#Disconnectcomm end //#finalizeMPI begin MPI_Finalize(); //#finalizeMPI end #endif return 0; } xdmf-3.0+git20160803/core/dsm/tests/Cxx/XdmfConnectTest2Paged.cpp0000640000175000017500000002032713003006557024314 0ustar alastairalastair#include #include #include #include #include #include #include #include #include #include #include int main(int argc, char *argv[]) { // This test does not work properly with openmpi // due to an issue with the openmpi code #ifndef OPEN_MPI int size, id, dsmSize; dsmSize = 64; MPI_Status status; MPI_Comm comm = MPI_COMM_WORLD; MPI_Init(&argc, &argv); MPI_Comm_rank(comm, &id); MPI_Comm_size(comm, &size); XdmfDSMCommMPI::SetUseEnvFileName(true); std::string newPath = "dsm"; std::string newSetPath = "Data"; // Initializing objects //since the start and end ids are larger than the size there are no buffers alloted //thus, no blockage occurs XdmfDSMCommMPI * testComm = new XdmfDSMCommMPI(); testComm->DupComm(comm); testComm->Init(); testComm->SetApplicationName("Connect 2"); XdmfDSMBuffer * testBuffer = new XdmfDSMBuffer(); testBuffer->SetIsServer(false); testBuffer->SetComm(testComm); testBuffer->SetIsConnected(true); std::vector readStartVector; std::vector readStrideVector; std::vector readCountVector; std::vector readDataSizeVector; readStartVector.push_back(5*id); readStrideVector.push_back(1); readCountVector.push_back(5); readDataSizeVector.push_back(5*size); shared_ptr readArray = XdmfArray::New(); readArray->initialize(0); readArray->reserve(5); shared_ptr readController = XdmfHDF5ControllerDSM::New( newPath, newSetPath, XdmfArrayType::Int32(), readStartVector, readStrideVector, readCountVector, readDataSizeVector, testBuffer); #ifdef _WIN32 Sleep(1000) #else sleep(10); #endif char * configFileName = strdup(testComm->GetDsmFileName().c_str()); std::ifstream testStream; testStream.open(configFileName); while (!testStream.good()) { // Wait for the config file to be generated testStream.close(); #ifdef _WIN32 Sleep(500) #else sleep(5); #endif testStream.open(configFileName); } readController->getServerBuffer()->GetComm()->ReadDsmPortName(); readController->getServerBuffer()->Connect(); shared_ptr exampleWriter = XdmfHDF5WriterDSM::New(newPath, testBuffer); std::vector writeStartVector; std::vector writeStrideVector; std::vector writeCountVector; std::vector writeDataSizeVector; writeStartVector.push_back(id*5); writeStrideVector.push_back(1); writeCountVector.push_back(5); writeDataSizeVector.push_back(5*size); shared_ptr writeController = XdmfHDF5ControllerDSM::New( newPath, newSetPath, XdmfArrayType::Int32(), writeStartVector, writeStrideVector, writeCountVector, writeDataSizeVector, exampleWriter->getServerBuffer()); exampleWriter->setMode(XdmfHeavyDataWriter::Hyperslab); // Done initialization MPI_Barrier(readController->getServerBuffer()->GetComm()->GetIntraComm()); // Let waits be set up #ifdef _WIN32 Sleep(100) #else sleep(1); #endif // Test Notify exampleWriter->waitRelease(newPath, "notify", 3); // Testing the structure of the DSM if (id == 0) { std::vector structuresizes; structuresizes.push_back(1); structuresizes.push_back(1); structuresizes.push_back(2); structuresizes.push_back(2); std::vector structurenames; structurenames.push_back("Application"); structurenames.push_back("Server"); structurenames.push_back("Connect 1"); structurenames.push_back("Connect 2"); std::vector > teststructure = exampleWriter->getServerBuffer()->GetComm()->GetDsmProcessStructure(); printf("DSM Structure:\n"); for (unsigned int i = 0; i < teststructure.size(); ++i) { std::cout << "(" << teststructure[i].first << ", " << teststructure[i].second << ")" << std::endl; assert(teststructure[i].second == structuresizes[i]); assert(teststructure[i].first.compare(structurenames[i]) == 0); } } MPI_Barrier(exampleWriter->getServerBuffer()->GetComm()->GetIntraComm()); for (unsigned int numloops = 0; numloops < 4; ++numloops) { if (id == 0) { int receiveData = 0; readController->getServerBuffer()->ReceiveAcknowledgment(readController->getServerBuffer()->GetComm()->GetInterId() - 1, receiveData, XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM); } MPI_Barrier(readController->getServerBuffer()->GetComm()->GetIntraComm()); if (readArray->getNumberHeavyDataControllers() > 0) { readArray->removeHeavyDataController(0); } readArray->insert(readController); readArray->read(); for (int i = 0; i < size; ++i) { MPI_Barrier(readController->getServerBuffer()->GetComm()->GetIntraComm()); if (i == id) { std::stringstream outputstream; outputstream << "Array on core " << exampleWriter->getServerBuffer()->GetComm()->GetInterId() << " contains:" << std::endl; for (unsigned int j = 0; j < readArray->getSize(); ++j) { int tempVal = readArray->getValue(j); tempVal = tempVal * 3; readArray->insert(j, tempVal); outputstream << "[" << j << "]" << readArray->getValue(j) << std::endl; } std::cout << outputstream.str(); } } MPI_Barrier(readController->getServerBuffer()->GetComm()->GetIntraComm()); if (id == 0) { std::cout << std::endl << std::endl; } readArray->removeHeavyDataController(0); readArray->insert(writeController); readArray->accept(exampleWriter); if (id == 0) { int receiveData = 0; readController->getServerBuffer()->SendAcknowledgment(readController->getServerBuffer()->GetComm()->GetInterId() - 1, receiveData, XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM); } } //this last acknowledgment is to end the loop. if (id == 0) { int receiveData = 0; readController->getServerBuffer()->ReceiveAcknowledgment(readController->getServerBuffer()->GetComm()->GetInterId() - 1, receiveData, XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM); } MPI_Barrier(readController->getServerBuffer()->GetComm()->GetIntraComm()); // Do work stuff here if (id == 0) { readController->stopDSM(); } MPI_Barrier(readController->getServerBuffer()->GetComm()->GetInterComm()); MPI_Finalize(); #endif return 0; } xdmf-3.0+git20160803/core/dsm/tests/Cxx/DSMLoopTest.sh0000740000175000017500000000003413003006557022160 0ustar alastairalastair$MPIEXEC -n 4 ./DSMLoopTest xdmf-3.0+git20160803/core/dsm/tests/Cxx/DSMLoopTestPaged.sh0000740000175000017500000000004113003006557023117 0ustar alastairalastair$MPIEXEC -n 4 ./DSMLoopTestPaged xdmf-3.0+git20160803/core/dsm/tests/Cxx/XdmfAcceptTestPaged.cpp0000640000175000017500000000623513003006557024042 0ustar alastairalastair#include #include #include #include #include #include #include #include int main(int argc, char *argv[]) { // This test does not work properly with openmpi // due to an issue with the openmpi code #ifndef OPEN_MPI //#initMPI begin int size, id, dsmSize; dsmSize = 64; MPI_Status status; MPI_Comm comm = MPI_COMM_WORLD; MPI_Init(&argc, &argv); MPI_Comm_rank(comm, &id); MPI_Comm_size(comm, &size); XdmfDSMCommMPI::SetUseEnvFileName(true); std::string newPath = "dsm"; int numServersCores = size - 1; int numConnections = 2; shared_ptr exampleWriter = XdmfHDF5WriterDSM::New(newPath, comm, dsmSize/numServersCores, 1024, 1, size-numServersCores, size-1); if (id == 0) { //#initMPI end //#GetDsmFileName begin std::string connectionFileName = exampleWriter->getServerBuffer()->GetComm()->GetDsmFileName(); //#GetDsmFileName end //#SetDsmFileName begin exampleWriter->getServerBuffer()->GetComm()->SetDsmFileName(connectionFileName); //#SetDsmFileName end //#OpenPort begin exampleWriter->getServerBuffer()->GetComm()->OpenPort(); //#OpenPort end //#SendAccept begin exampleWriter->getServerBuffer()->SendAccept(numConnections); //#SendAccept end /* //#manualAccept begin // Notify the server cores to accept connections for (int i = exampleWriter->getServerBuffer()->StartServerId; i <= exampleWriter->getServerBuffer()->EndServerId; ++i) { if (i != exampleWriter->getServerBuffer()->Comm->GetId()) { exampleWriter->getServerBuffer()->SendCommandHeader(XDMF_DSM_ACCEPT, i, 0, 0, XDMF_DSM_INTER_COMM); exampleWriter->getServerBuffer()->SendAcknowledgment(i, numConnections, XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM); } } // Accept connections exampleWriter->getServerBuffer()->Comm->Accept(numConnections); // Distribute current DSM status exampleWriter->getServerBuffer()->SendInfo(); //#manualAccept end */ //#finishwork begin MPI_Barrier(exampleWriter->getServerBuffer()->GetComm()->GetIntraComm()); } MPI_Barrier(exampleWriter->getServerBuffer()->GetComm()->GetInterComm()); //#finishwork end //#ClosePort begin if (id == 0) { exampleWriter->getServerBuffer()->GetComm()->ClosePort(); } //#ClosePort end //#finalizeMPI begin MPI_Finalize(); //#finalizeMPI end #else std::cout << "Interprogram DSM does not work properly with OpenMPI" << std::endl; #endif return 0; } xdmf-3.0+git20160803/core/dsm/tests/Cxx/CrayConnectTest.sh0000740000175000017500000000020613003006557023114 0ustar alastairalastair# Intel MPI requires a minimum of 2 cores per process aprun -n 2 ./XdmfAcceptTest : -n 2 ./XdmfConnectTest : -n 2 ./XdmfConnectTest2 xdmf-3.0+git20160803/core/dsm/tests/Cxx/DSMLoopTest.cpp0000640000175000017500000004200513003006557022333 0ustar alastairalastair#include #include #include #include #include #include #include "XdmfArray.hpp" #include "XdmfArrayType.hpp" #include "XdmfHDF5WriterDSM.hpp" #include "XdmfHDF5ControllerDSM.hpp" int main(int argc, char *argv[]) { int size, id, dsmSize; dsmSize = 64;//The total size of the DSM being created MPI_Comm comm = MPI_COMM_WORLD; MPI_Init(&argc, &argv); MPI_Comm_rank(comm, &id); MPI_Comm_size(comm, &size); std::vector outputVector; shared_ptr testArray = XdmfArray::New(); testArray->initialize(0); shared_ptr testArray2 = XdmfArray::New(); testArray2->initialize(0); std::string newPath = "dsm"; std::string newSetPath = "dataspace"; std::string secondSetPath = "data2"; // Change this to determine the number of cores used as servers unsigned int numServersCores = 2; // Change this to determine the size of the arrays generated when initializing unsigned int writeArraySize = 4; std::vector writeStartVector; std::vector writeStrideVector; std::vector writeCountVector; std::vector writeDataSizeVector; std::vector readStartVector; std::vector readStrideVector; std::vector readCountVector; std::vector readDataSizeVector; std::vector readOutputCountVector; shared_ptr readArray = XdmfArray::New(); readArray->initialize(0); shared_ptr readArray2 = XdmfArray::New(); readArray2->initialize(0); shared_ptr readController; shared_ptr readOutputController; shared_ptr writeController; shared_ptr readController2; shared_ptr readOutputController2; shared_ptr writeController2; MPI_Comm workerComm; MPI_Group workers, dsmgroup; MPI_Comm_group(comm, &dsmgroup); int * ServerIds = (int *)calloc((numServersCores), sizeof(int)); unsigned int index = 0; for(int i=size-numServersCores ; i <= size-1 ; ++i) { ServerIds[index++] = i; } MPI_Group_excl(dsmgroup, index, ServerIds, &workers); int testval = MPI_Comm_create(comm, workers, &workerComm); cfree(ServerIds); shared_ptr exampleWriter = XdmfHDF5WriterDSM::New(newPath, comm, dsmSize/numServersCores, size-numServersCores, size-1); exampleWriter->setMode(XdmfHeavyDataWriter::Hyperslab); //split out sub-comm for the worker cores //server cores will not progress to this point until after the servers are done running if (id < size - (int)numServersCores) { // Split the comm even further MPI_Comm readComm, writeComm; MPI_Group readingCores, writingCores; MPI_Comm_group(workerComm, &workers); int * ServerIds = (int *)calloc(((size - numServersCores) / 2), sizeof(int)); unsigned int index = 0; for(int i=0 ; i < (int)((size - numServersCores) / 2) ; ++i) { ServerIds[index++] = i; } MPI_Group_excl(workers, index, ServerIds, &readingCores); testval = MPI_Comm_create(workerComm, readingCores, &readComm); MPI_Group_incl(workers, index, ServerIds, &writingCores); testval = MPI_Comm_create(workerComm, writingCores, &writeComm); cfree(ServerIds); std::cout << "initializing" << std::endl; // Initialize values // Writer is first if (id < (int)((size - numServersCores) / 2)) { for (unsigned int i = 1; i <= writeArraySize; ++i) { testArray->pushBack(i*(id+1)); } for (unsigned int i = 1; i <= writeArraySize; ++i) { testArray2->pushBack(5*i*(id+1)); } writeStartVector.push_back(id*writeArraySize); writeStrideVector.push_back(1); writeCountVector.push_back(writeArraySize); writeDataSizeVector.push_back(writeArraySize*(int)((size-numServersCores) / 2)); writeController = XdmfHDF5ControllerDSM::New( newPath, newSetPath, XdmfArrayType::Int32(), writeStartVector, writeStrideVector, writeCountVector, writeDataSizeVector, exampleWriter->getServerBuffer()); testArray->insert(writeController); writeController2 = XdmfHDF5ControllerDSM::New( newPath, secondSetPath, XdmfArrayType::Int32(), writeStartVector, writeStrideVector, writeCountVector, writeDataSizeVector, exampleWriter->getServerBuffer()); testArray2->insert(writeController2); readStartVector.push_back(0); readStrideVector.push_back(1); readCountVector.push_back(0); readDataSizeVector.push_back(writeArraySize*(int)((size-numServersCores) / 2)); readController = XdmfHDF5ControllerDSM::New( newPath, newSetPath, XdmfArrayType::Int32(), readStartVector, readStrideVector, readCountVector, readDataSizeVector, exampleWriter->getServerBuffer()); readArray->insert(readController); for (unsigned int i = 0; igetSize(); ++i) { std::cout << "core #" << id <<" testArray[" << i << "] = " << testArray->getValue(i) << std::endl; } } } for (unsigned int i = 0; igetSize(); ++i) { std::cout << "core #" << id <<" testArray2[" << i << "] = " << testArray2->getValue(i) << std::endl; } } } } else { // Reader is second readStartVector.push_back(0); readStrideVector.push_back(1); readCountVector.push_back(writeArraySize*(int)((size-numServersCores) / 2)); readDataSizeVector.push_back(writeArraySize*(int)((size-numServersCores) / 2)); readController = XdmfHDF5ControllerDSM::New( newPath, newSetPath, XdmfArrayType::Int32(), readStartVector, readStrideVector, readCountVector, readDataSizeVector, exampleWriter->getServerBuffer()); readArray->insert(readController); readOutputCountVector.push_back(0); readOutputController = XdmfHDF5ControllerDSM::New( newPath, newSetPath, XdmfArrayType::Int32(), readStartVector, readStrideVector, readOutputCountVector, readDataSizeVector, exampleWriter->getServerBuffer()); writeStartVector.push_back(0); writeStrideVector.push_back(1); writeCountVector.push_back(0); writeDataSizeVector.push_back(writeArraySize*(int)((size-numServersCores) / 2)); writeController = XdmfHDF5ControllerDSM::New( newPath, newSetPath, XdmfArrayType::Int32(), writeStartVector, writeStrideVector, writeCountVector, writeDataSizeVector, exampleWriter->getServerBuffer()); writeController2 = XdmfHDF5ControllerDSM::New( newPath, secondSetPath, XdmfArrayType::Int32(), writeStartVector, writeStrideVector, writeCountVector, writeDataSizeVector, exampleWriter->getServerBuffer()); testArray2->insert(writeController2); testArray->insert(writeController); } testArray->accept(exampleWriter); MPI_Barrier(workerComm); // exampleWriter->openFile(); ///* std::cout << "getting dataset size" << std::endl; int checkedsize = exampleWriter->getDataSetSize(newPath, newSetPath); std::cout << "polled size " << checkedsize << " from file should be " << writeArraySize*(int)((size-numServersCores) / 2) << std::endl; assert(checkedsize == writeArraySize*(int)((size-numServersCores) / 2)); checkedsize = exampleWriter->getDataSetSize(newPath, "empty"); std::cout << "polled nonexistant set size = " << checkedsize << std::endl; assert(checkedsize == 0); //*/ MPI_Barrier(workerComm); // exampleWriter->closeFile(); testArray2->accept(exampleWriter); MPI_Barrier(workerComm); // This is the loop that manipulates the data for (unsigned int iteration = 0; iteration < 10; ++iteration) { std::cout << "loop iteration " << iteration << " on core " << id << std::endl; // Read in to the first set of cores if (id >= (int)((size - numServersCores) / 2)) { // Controllers are accessed like this since the writer removes them and creates its own. shared_dynamic_cast(readArray->getHeavyDataController(0))->setWorkerComm(readComm); readArray->read(); MPI_Barrier(readComm); if (id == (int)((size - numServersCores) / 2)) { for(unsigned int i=0; igetSize(); ++i) { int tempVal = readArray->getValue(i); tempVal = tempVal * 2; readArray->insert(i, tempVal); // Pull the value from the array in order to ensure the change has happened std::cout << "core #" << id <<" readArray[" << i << "] = " << readArray->getValue(i) << std::endl; } } } shared_dynamic_cast(readArray->getHeavyDataController(0))->setWorkerComm(workerComm); if (id > (int)((size - numServersCores) / 2)) { // Only the first read core should write out data readArray->removeHeavyDataController(0); readArray->insert(readOutputController); } readArray->accept(exampleWriter); if (id > (int)((size - numServersCores) / 2)) { // Only the first read core should write out data readArray->removeHeavyDataController(0); readArray->insert(readController); } MPI_Barrier(workerComm); std::cout << "on writing cores" << std::endl; if (id < (int)((size - numServersCores) / 2)) { shared_dynamic_cast(testArray->getHeavyDataController(0))->setWorkerComm(writeComm); testArray->read(); MPI_Barrier(writeComm); for (unsigned int i = 0; i<(unsigned int)size; ++i) { MPI_Barrier(writeComm); if (i == (unsigned int)id) { for(unsigned int i=0; igetSize(); ++i) { int tempVal = testArray->getValue(i); unsigned int multiplier1 = std::pow(2, iteration+1); unsigned int multiplier2 = std::pow(3, iteration); assert(tempVal == (i+1)*(id+1) * multiplier1 * multiplier2); tempVal = tempVal * 3; testArray->insert(i, tempVal); // Pull the value from the array in order to ensure the change has happened std::cout << "core #" << id <<" testArray[" << i << "] = " << testArray->getValue(i) << std::endl; } } } testArray2->read(); for (unsigned int i = 1; i <= writeArraySize; ++i) { unsigned int tempVal = testArray2->getValue(i - 1); unsigned int multiplier = std::pow(5, iteration); assert(5*i*(id+1) * multiplier == tempVal); testArray2->insert(i - 1, tempVal * 5); std::cout << "core #" << id <<" testArray2[" << i-1 << "] = " << testArray2->getValue(i-1) << std::endl; } } writeController->setWorkerComm(workerComm); testArray->accept(exampleWriter); testArray2->accept(exampleWriter); } } if (id == 0) { exampleWriter->stopDSM(); } MPI_Barrier(comm); MPI_Finalize(); return 0; } xdmf-3.0+git20160803/core/dsm/tests/Cxx/DSMLoopTestPaged.cpp0000640000175000017500000004201213003006557023272 0ustar alastairalastair#include #include #include #include #include #include #include "XdmfArray.hpp" #include "XdmfArrayType.hpp" #include "XdmfHDF5WriterDSM.hpp" #include "XdmfHDF5ControllerDSM.hpp" int main(int argc, char *argv[]) { int size, id, dsmSize; dsmSize = 64;//The total size of the DSM being created MPI_Comm comm = MPI_COMM_WORLD; MPI_Init(&argc, &argv); MPI_Comm_rank(comm, &id); MPI_Comm_size(comm, &size); std::vector outputVector; shared_ptr testArray = XdmfArray::New(); testArray->initialize(0); shared_ptr testArray2 = XdmfArray::New(); testArray2->initialize(0); std::string newPath = "dsm"; std::string newSetPath = "dataspace"; std::string secondSetPath = "data2"; // Change this to determine the number of cores used as servers unsigned int numServersCores = 2; // Change this to determine the size of the arrays generated when initializing unsigned int writeArraySize = 4; std::vector writeStartVector; std::vector writeStrideVector; std::vector writeCountVector; std::vector writeDataSizeVector; std::vector readStartVector; std::vector readStrideVector; std::vector readCountVector; std::vector readDataSizeVector; std::vector readOutputCountVector; shared_ptr readArray = XdmfArray::New(); readArray->initialize(0); shared_ptr readArray2 = XdmfArray::New(); readArray2->initialize(0); shared_ptr readController; shared_ptr readOutputController; shared_ptr writeController; shared_ptr readController2; shared_ptr readOutputController2; shared_ptr writeController2; MPI_Comm workerComm; MPI_Group workers, dsmgroup; MPI_Comm_group(comm, &dsmgroup); int * ServerIds = (int *)calloc((numServersCores), sizeof(int)); unsigned int index = 0; for(int i=size-numServersCores ; i <= size-1 ; ++i) { ServerIds[index++] = i; } MPI_Group_excl(dsmgroup, index, ServerIds, &workers); int testval = MPI_Comm_create(comm, workers, &workerComm); cfree(ServerIds); shared_ptr exampleWriter = XdmfHDF5WriterDSM::New(newPath, comm, dsmSize/numServersCores, 1024, 1, size-numServersCores, size-1); exampleWriter->setMode(XdmfHeavyDataWriter::Hyperslab); //split out sub-comm for the worker cores //server cores will not progress to this point until after the servers are done running if (id < size - (int)numServersCores) { // Split the comm even further MPI_Comm readComm, writeComm; MPI_Group readingCores, writingCores; MPI_Comm_group(workerComm, &workers); int * ServerIds = (int *)calloc(((size - numServersCores) / 2), sizeof(int)); unsigned int index = 0; for(int i=0 ; i < (int)((size - numServersCores) / 2) ; ++i) { ServerIds[index++] = i; } MPI_Group_excl(workers, index, ServerIds, &readingCores); testval = MPI_Comm_create(workerComm, readingCores, &readComm); MPI_Group_incl(workers, index, ServerIds, &writingCores); testval = MPI_Comm_create(workerComm, writingCores, &writeComm); cfree(ServerIds); std::cout << "initializing" << std::endl; // Initialize values // Writer is first if (id < (int)((size - numServersCores) / 2)) { for (unsigned int i = 1; i <= writeArraySize; ++i) { testArray->pushBack(i*(id+1)); } for (unsigned int i = 1; i <= writeArraySize; ++i) { testArray2->pushBack(5*i*(id+1)); } writeStartVector.push_back(id*writeArraySize); writeStrideVector.push_back(1); writeCountVector.push_back(writeArraySize); writeDataSizeVector.push_back(writeArraySize*(int)((size-numServersCores) / 2)); writeController = XdmfHDF5ControllerDSM::New( newPath, newSetPath, XdmfArrayType::Int32(), writeStartVector, writeStrideVector, writeCountVector, writeDataSizeVector, exampleWriter->getServerBuffer()); testArray->insert(writeController); writeController2 = XdmfHDF5ControllerDSM::New( newPath, secondSetPath, XdmfArrayType::Int32(), writeStartVector, writeStrideVector, writeCountVector, writeDataSizeVector, exampleWriter->getServerBuffer()); testArray2->insert(writeController2); readStartVector.push_back(0); readStrideVector.push_back(1); readCountVector.push_back(0); readDataSizeVector.push_back(writeArraySize*(int)((size-numServersCores) / 2)); readController = XdmfHDF5ControllerDSM::New( newPath, newSetPath, XdmfArrayType::Int32(), readStartVector, readStrideVector, readCountVector, readDataSizeVector, exampleWriter->getServerBuffer()); readArray->insert(readController); for (unsigned int i = 0; igetSize(); ++i) { std::cout << "core #" << id <<" testArray[" << i << "] = " << testArray->getValue(i) << std::endl; } } } for (unsigned int i = 0; igetSize(); ++i) { std::cout << "core #" << id <<" testArray2[" << i << "] = " << testArray2->getValue(i) << std::endl; } } } } else { // Reader is second readStartVector.push_back(0); readStrideVector.push_back(1); readCountVector.push_back(writeArraySize*(int)((size-numServersCores) / 2)); readDataSizeVector.push_back(writeArraySize*(int)((size-numServersCores) / 2)); readController = XdmfHDF5ControllerDSM::New( newPath, newSetPath, XdmfArrayType::Int32(), readStartVector, readStrideVector, readCountVector, readDataSizeVector, exampleWriter->getServerBuffer()); readArray->insert(readController); readOutputCountVector.push_back(0); readOutputController = XdmfHDF5ControllerDSM::New( newPath, newSetPath, XdmfArrayType::Int32(), readStartVector, readStrideVector, readOutputCountVector, readDataSizeVector, exampleWriter->getServerBuffer()); writeStartVector.push_back(0); writeStrideVector.push_back(1); writeCountVector.push_back(0); writeDataSizeVector.push_back(writeArraySize*(int)((size-numServersCores) / 2)); writeController = XdmfHDF5ControllerDSM::New( newPath, newSetPath, XdmfArrayType::Int32(), writeStartVector, writeStrideVector, writeCountVector, writeDataSizeVector, exampleWriter->getServerBuffer()); writeController2 = XdmfHDF5ControllerDSM::New( newPath, secondSetPath, XdmfArrayType::Int32(), writeStartVector, writeStrideVector, writeCountVector, writeDataSizeVector, exampleWriter->getServerBuffer()); testArray2->insert(writeController2); testArray->insert(writeController); } testArray->accept(exampleWriter); MPI_Barrier(workerComm); // exampleWriter->openFile(); /* std::cout << "getting dataset size" << std::endl; int checkedsize = exampleWriter->getDataSetSize(newPath, newSetPath); std::cout << "polled size " << checkedsize << " from file should be " << writeArraySize*(int)((size-numServersCores) / 2) << std::endl; assert(checkedsize == writeArraySize*(int)((size-numServersCores) / 2)); checkedsize = exampleWriter->getDataSetSize(newPath, "empty"); std::cout << "polled nonexistant set size = " << checkedsize << std::endl; assert(checkedsize == 0); */ MPI_Barrier(workerComm); // exampleWriter->closeFile(); testArray2->accept(exampleWriter); MPI_Barrier(workerComm); // This is the loop that manipulates the data for (unsigned int iteration = 0; iteration < 10; ++iteration) { std::cout << "loop iteration " << iteration << " on core " << id << std::endl; // Read in to the first set of cores if (id >= (int)((size - numServersCores) / 2)) { // Controllers are accessed like this since the writer removes them and creates its own. shared_dynamic_cast(readArray->getHeavyDataController(0))->setWorkerComm(readComm); readArray->read(); MPI_Barrier(readComm); if (id == (int)((size - numServersCores) / 2)) { for(unsigned int i=0; igetSize(); ++i) { int tempVal = readArray->getValue(i); tempVal = tempVal * 2; readArray->insert(i, tempVal); // Pull the value from the array in order to ensure the change has happened std::cout << "core #" << id <<" readArray[" << i << "] = " << readArray->getValue(i) << std::endl; } } } shared_dynamic_cast(readArray->getHeavyDataController(0))->setWorkerComm(workerComm); if (id > (int)((size - numServersCores) / 2)) { // Only the first read core should write out data readArray->removeHeavyDataController(0); readArray->insert(readOutputController); } readArray->accept(exampleWriter); if (id > (int)((size - numServersCores) / 2)) { // Only the first read core should write out data readArray->removeHeavyDataController(0); readArray->insert(readController); } MPI_Barrier(workerComm); std::cout << "on writing cores" << std::endl; if (id < (int)((size - numServersCores) / 2)) { shared_dynamic_cast(testArray->getHeavyDataController(0))->setWorkerComm(writeComm); testArray->read(); MPI_Barrier(writeComm); for (unsigned int i = 0; i<(unsigned int)size; ++i) { MPI_Barrier(writeComm); if (i == (unsigned int)id) { for(unsigned int i=0; igetSize(); ++i) { int tempVal = testArray->getValue(i); unsigned int multiplier1 = std::pow(2, iteration+1); unsigned int multiplier2 = std::pow(3, iteration); assert(tempVal == (i+1)*(id+1) * multiplier1 * multiplier2); tempVal = tempVal * 3; testArray->insert(i, tempVal); // Pull the value from the array in order to ensure the change has happened std::cout << "core #" << id <<" testArray[" << i << "] = " << testArray->getValue(i) << std::endl; } } } testArray2->read(); for (unsigned int i = 1; i <= writeArraySize; ++i) { unsigned int tempVal = testArray2->getValue(i - 1); unsigned int multiplier = std::pow(5, iteration); assert(5*i*(id+1) * multiplier == tempVal); testArray2->insert(i - 1, tempVal * 5); std::cout << "core #" << id <<" testArray2[" << i-1 << "] = " << testArray2->getValue(i-1) << std::endl; } } writeController->setWorkerComm(workerComm); testArray->accept(exampleWriter); testArray2->accept(exampleWriter); } } if (id == 0) { exampleWriter->stopDSM(); } MPI_Barrier(comm); MPI_Finalize(); return 0; } xdmf-3.0+git20160803/core/dsm/tests/Cxx/XdmfConnectTest2.cpp0000640000175000017500000002120713003006557023351 0ustar alastairalastair#include #include #include #include #include #include #include #include #include #include #include int main(int argc, char *argv[]) { // This test does not work properly with openmpi // due to an issue with the openmpi code #ifndef OPEN_MPI int size, id, dsmSize; dsmSize = 64; MPI_Status status; MPI_Comm comm = MPI_COMM_WORLD; MPI_Init(&argc, &argv); MPI_Comm_rank(comm, &id); MPI_Comm_size(comm, &size); XdmfDSMCommMPI::SetUseEnvFileName(true); std::string newPath = "dsm"; std::string newSetPath = "Data"; // Initializing objects /* //since the start and end ids are larger than the size there are no buffers alloted //thus, no blockage occurs XdmfDSMCommMPI * testComm = new XdmfDSMCommMPI(); testComm->DupComm(comm); testComm->Init(); testComm->SetApplicationName("Connect 2"); XdmfDSMBuffer * testBuffer = new XdmfDSMBuffer(); testBuffer->SetIsServer(false); testBuffer->SetComm(testComm); testBuffer->SetIsConnected(true); */ shared_ptr exampleWriter = XdmfHDF5WriterDSM::New(newPath, comm, "Connect 2"); MPI_Comm_rank(exampleWriter->getServerBuffer()->GetComm()->GetIntraComm(), &id); MPI_Comm_size(exampleWriter->getServerBuffer()->GetComm()->GetIntraComm(), &size); std::vector readStartVector; std::vector readStrideVector; std::vector readCountVector; std::vector readDataSizeVector; readStartVector.push_back(5*id); readStrideVector.push_back(1); readCountVector.push_back(5); readDataSizeVector.push_back(5*size); shared_ptr readArray = XdmfArray::New(); readArray->initialize(0); readArray->reserve(5); shared_ptr readController = XdmfHDF5ControllerDSM::New( newPath, newSetPath, XdmfArrayType::Int32(), readStartVector, readStrideVector, readCountVector, readDataSizeVector, exampleWriter->getServerBuffer()); #ifdef _WIN32 Sleep(1000) #else sleep(10); #endif char * configFileName = strdup(exampleWriter->getServerBuffer()->GetComm()->GetDsmFileName().c_str()); std::ifstream testStream; testStream.open(configFileName); while (!testStream.good()) { // Wait for the config file to be generated testStream.close(); #ifdef _WIN32 Sleep(500) #else sleep(5); #endif testStream.open(configFileName); } readController->getServerBuffer()->GetComm()->ReadDsmPortName(); readController->getServerBuffer()->Connect(); // shared_ptr exampleWriter = XdmfHDF5WriterDSM::New(newPath, testBuffer); std::vector writeStartVector; std::vector writeStrideVector; std::vector writeCountVector; std::vector writeDataSizeVector; writeStartVector.push_back(id*5); writeStrideVector.push_back(1); writeCountVector.push_back(5); writeDataSizeVector.push_back(5*size); shared_ptr writeController = XdmfHDF5ControllerDSM::New( newPath, newSetPath, XdmfArrayType::Int32(), writeStartVector, writeStrideVector, writeCountVector, writeDataSizeVector, exampleWriter->getServerBuffer()); exampleWriter->setMode(XdmfHeavyDataWriter::Hyperslab); // Done initialization MPI_Barrier(readController->getServerBuffer()->GetComm()->GetIntraComm()); // Let waits be set up #ifdef _WIN32 Sleep(100) #else sleep(1); #endif // Test Notify exampleWriter->waitRelease(newPath, "notify", 3); // Testing the structure of the DSM if (id == 0) { std::vector structuresizes; structuresizes.push_back(1); structuresizes.push_back(1); structuresizes.push_back(2); structuresizes.push_back(2); std::vector structurenames; structurenames.push_back("Accept"); structurenames.push_back("Server"); structurenames.push_back("Connect 1"); structurenames.push_back("Connect 2"); std::vector > teststructure = exampleWriter->getServerBuffer()->GetComm()->GetDsmProcessStructure(); printf("DSM Structure:\n"); for (unsigned int i = 0; i < teststructure.size(); ++i) { std::cout << "(" << teststructure[i].first << ", " << teststructure[i].second << ")" << "==" << "(" << structurenames[i] << ", " << structuresizes[i] << ")" << std::endl; assert(teststructure[i].second == structuresizes[i]); assert(teststructure[i].first.compare(structurenames[i]) == 0); } } MPI_Barrier(exampleWriter->getServerBuffer()->GetComm()->GetIntraComm()); for (unsigned int numloops = 0; numloops < 4; ++numloops) { if (id == 0) { int receiveData = 0; readController->getServerBuffer()->ReceiveAcknowledgment(readController->getServerBuffer()->GetComm()->GetInterId() - 1, receiveData, XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM); } MPI_Barrier(readController->getServerBuffer()->GetComm()->GetIntraComm()); if (readArray->getNumberHeavyDataControllers() > 0) { readArray->removeHeavyDataController(0); } readArray->insert(readController); readArray->read(); for (int i = 0; i < size; ++i) { MPI_Barrier(readController->getServerBuffer()->GetComm()->GetIntraComm()); if (i == id) { std::stringstream outputstream; outputstream << "Array on core " << exampleWriter->getServerBuffer()->GetComm()->GetInterId() << " contains:" << std::endl; for (unsigned int j = 0; j < readArray->getSize(); ++j) { int tempVal = readArray->getValue(j); tempVal = tempVal * 3; readArray->insert(j, tempVal); outputstream << "[" << j << "]" << readArray->getValue(j) << std::endl; } std::cout << outputstream.str(); } } MPI_Barrier(readController->getServerBuffer()->GetComm()->GetIntraComm()); if (id == 0) { std::cout << std::endl << std::endl; } readArray->removeHeavyDataController(0); readArray->insert(writeController); readArray->accept(exampleWriter); if (id == 0) { int receiveData = 0; readController->getServerBuffer()->SendAcknowledgment(readController->getServerBuffer()->GetComm()->GetInterId() - 1, receiveData, XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM); } } //this last acknowledgment is to end the loop. if (id == 0) { int receiveData = 0; readController->getServerBuffer()->ReceiveAcknowledgment(readController->getServerBuffer()->GetComm()->GetInterId() - 1, receiveData, XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM); } MPI_Barrier(readController->getServerBuffer()->GetComm()->GetIntraComm()); // Do work stuff here if (id == 0) { readController->stopDSM(); } MPI_Barrier(readController->getServerBuffer()->GetComm()->GetInterComm()); MPI_Finalize(); #endif return 0; } xdmf-3.0+git20160803/core/dsm/tests/Cxx/ConnectTestPaged.sh0000740000175000017500000000025413003006557023241 0ustar alastairalastair# Intel MPI requires a minimum of 2 cores per process $MPIEXEC -n 2 ./XdmfAcceptTestPaged & $MPIEXEC -n 2 ./XdmfConnectTestPaged & $MPIEXEC -n 2 ./XdmfConnectTest2Paged xdmf-3.0+git20160803/core/dsm/tests/Python/0000740000175000017500000000000013003006557020226 5ustar alastairalastairxdmf-3.0+git20160803/core/dsm/tests/Python/PythonConnect.sh0000740000175000017500000000036413003006557023363 0ustar alastairalastair# Intel MPI requires a minimum of 2 cores per process $MPIEXEC -n 2 $PYTHON_EXECUTABLE ./XdmfExampleAcceptTest.py & $MPIEXEC -n 2 $PYTHON_EXECUTABLE ./XdmfExampleConnectTest.py & $MPIEXEC -n 2 $PYTHON_EXECUTABLE ./XdmfExampleConnectTest2.py xdmf-3.0+git20160803/core/dsm/tests/Python/XdmfExampleConnectTest.py0000640000175000017500000001625413003006557025176 0ustar alastairalastairprint "Connect 1" from mpi4py.MPI import * from Xdmf import * import time import os.path if __name__ == "__main__": if get_vendor()[0] != 'Open MPI': #//initMPI begin dsmSize = 64 comm = COMM_WORLD id = comm.Get_rank() size = comm.Get_size() newPath = "dsm" newSetPath = "Data" # Initializing objects ''' testComm = XdmfDSMCommMPI() testComm.DupComm(comm) testComm.Init() testBuffer = XdmfDSMBuffer() testBuffer.SetIsServer(False) testBuffer.SetComm(testComm) testBuffer.SetIsConnected(True) ''' exampleWriter = XdmfHDF5WriterDSM.New(newPath, comm, "Connect 1") id = exampleWriter.getServerBuffer().GetComm().GetId() size = exampleWriter.getServerBuffer().GetComm().GetIntraSize() testComm = exampleWriter.getServerBuffer().GetComm() #//initMPI end time.sleep(5) configPath = testComm.GetDsmFileName() while not os.path.exists(configPath): time.sleep(5) #//ReadDsmPortName begin exampleWriter.getServerBuffer().GetComm().ReadDsmPortName() #//ReadDsmPortName end #//GetDsmPortName begin portName = exampleWriter.getServerBuffer().GetComm().GetDsmPortName() #//GetDsmPortName end #//SetDsmPortName begin exampleWriter.getServerBuffer().GetComm().SetDsmPortName(portName) #//SetDsmPortName end #//Connect begin exampleWriter.getServerBuffer().Connect() #//Connect end ''' #//manualConnect begin try: status = exampleWriter.getServerBuffer().GetComm().Connect() if status == MPI_SUCCESS: exampleWriter.getServerBuffer().SetIsConnected(true) try: exampleWriter.getServerBuffer().ReceiveInfo() except RuntimeError as e: # ReceiveInfo failed print e.args[0] except RuntimeError as e: # Connection failed print e.args[0] #//manualConnect end ''' exampleWriter.getServerBuffer().GetComm().GetIntraComm().Barrier() writeArray = XdmfArray.New() for i in range(1, 6): writeArray.pushBackAsInt32(i*(id+1)) writeStartVector = UInt32Vector() writeStrideVector = UInt32Vector() writeCountVector = UInt32Vector() writeDataSizeVector = UInt32Vector() writeStartVector.push_back(id*5) writeStrideVector.push_back(1) writeCountVector.push_back(5) writeDataSizeVector.push_back(5*size) writeController = XdmfHDF5ControllerDSM.New( newPath, newSetPath, XdmfArrayType.Int32(), writeStartVector, writeStrideVector, writeCountVector, writeDataSizeVector, exampleWriter.getServerBuffer()); readStartVector = UInt32Vector() readStrideVector = UInt32Vector() readCountVector = UInt32Vector() readDataSizeVector = UInt32Vector() readStartVector.push_back(5*id); readStrideVector.push_back(1); readCountVector.push_back(5); readDataSizeVector.push_back(5*size); readController = XdmfHDF5ControllerDSM.New( newPath, newSetPath, XdmfArrayType.Int32(), readStartVector, readStrideVector, readCountVector, readDataSizeVector, exampleWriter.getServerBuffer()); exampleWriter.setMode(XdmfHeavyDataWriter.Hyperslab); # Done initializing print "for i in range", 0, " ", size for i in range(0, size): print "core id checking array", i exampleWriter.getServerBuffer().GetComm().GetIntraComm().Barrier() print i, "==", id if i == id: outputstream = "Array on core " + str(exampleWriter.getServerBuffer().GetComm().GetInterId()) + " contains:\n" for j in range(0, writeArray.getSize()): outputstream = outputstream + "[" + str(j) + "]" + str(writeArray.getValueAsInt32(j)) + "\n" print outputstream loopamount = 4 for numloops in range(0, loopamount): print "loop ", numloops if writeArray.getNumberHeavyDataControllers() > 0: writeArray.removeHeavyDataController(0); writeArray.insert(writeController) if id == size - 1: print "\n\n" writeArray.accept(exampleWriter) if id == size - 1: sentData = 1 exampleWriter.getServerBuffer().SendAcknowledgment(exampleWriter.getServerBuffer().GetComm().GetInterId() + 1, sentData, XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM) exampleWriter.getServerBuffer().ReceiveAcknowledgment(exampleWriter.getServerBuffer().GetComm().GetInterId() + 1, sentData, XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM) exampleWriter.getServerBuffer().GetComm().GetIntraComm().Barrier() writeArray.removeHeavyDataController(0) writeArray.insert(readController) writeArray.release() writeArray.read() for i in range (0, size): exampleWriter.getServerBuffer().GetComm().GetIntraComm().Barrier() if i == id: outputstream = "Array on core " + str(exampleWriter.getServerBuffer().GetComm().GetInterId()) + " contains:\n" for j in range(0, writeArray.getSize()): tempVal = writeArray.getValueAsInt32(j) tempVal = tempVal * 2 writeArray.insertAsInt32(j, [tempVal]) outputstream = outputstream + "[" + str(j) + "]" + str(writeArray.getValueAsInt32(j)) + "\n" print outputstream if id == size - 1: sentData = 1 exampleWriter.getServerBuffer().SendAcknowledgment(exampleWriter.getServerBuffer().GetComm().GetInterId() + 1, sentData, XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM) exampleWriter.getServerBuffer().GetComm().GetIntraComm().Barrier() exampleWriter.getServerBuffer().GetComm().GetInterComm().Barrier() #//Disconnectmanager begin exampleWriter.getServerBuffer().Disconnect() #//Disconnectmanager end #//Disconnectcomm begin exampleWriter.getServerBuffer().GetComm().Disconnect() #//Disconnectcomm end xdmf-3.0+git20160803/core/dsm/tests/Python/CMakeLists.txt0000640000175000017500000000437413003006557023000 0ustar alastairalastairinclude(AddTestsPython) # Add any dependencies that the python tests may need # Note: The tests already depend on their own file ADD_TEST_PYTHON_DEPENDENCIES("XdmfCore") ADD_TEST_PYTHON_DEPENDENCIES("XdmfDSM") # Add any pythonpath directories that the python tests may need ADD_TEST_PYTHON_PYTHONPATH("${CMAKE_BINARY_DIR}") ADD_TEST_PYTHON_PYTHONPATH("${PYTHON_INCLUDE_MPI4PY_DIR}/../..") # Add any ldpath directories that the python tests may need ADD_TEST_PYTHON_LDPATH("${CMAKE_BINARY_DIR}") ADD_TEST_PYTHON_LDPATH("${XDMF_LIBRARY_DIRS}") # Add any path directories that the python tests may need ADD_TEST_PYTHON_PATH("${CMAKE_BINARY_DIR}") ADD_TEST_PYTHON_PATH("${HDF5_BINARY_DIRS}") ADD_TEST_PYTHON_PATH("${LIBXML2_BINARY_DIRS}") # Add any python tests here: # Note: We don't want to use a foreach loop to test the files incase we # have extra arguments (ie: ADD_TEST_PYTHON(testname inputfile)) # Read UsePYTHONTest.cmake for more information # --------------------------------------- if ("${XDMF_DSM_IS_CRAY}" STREQUAL "") if (MPIEXEC_MAX_NUMPROCS STRGREATER 5) ADD_MPI_TEST_PYTHON(PythonDSM.sh XdmfExampleDsmTest) ADD_MPI_TEST_PYTHON(PythonConnect.sh XdmfExampleAcceptTest,XdmfExampleConnectTest2,XdmfExampleConnectTest) endif(MPIEXEC_MAX_NUMPROCS STRGREATER 5) else ("${XDMF_DSM_IS_CRAY}" STREQUAL "") if (MPIEXEC_MAX_NUMPROCS STRGREATER 5) ADD_MPI_TEST_PYTHON(CrayPythonConnect.sh XdmfExampleAcceptTest,XdmfExampleConnectTest2,XdmfExampleConnectTest) endif(MPIEXEC_MAX_NUMPROCS STRGREATER 5) endif ("${XDMF_DSM_IS_CRAY}" STREQUAL "") # Add any python cleanup here: # Note: We don't want to use a foreach loop to test the files incase we # have multiple files (ie: CLEAN_TEST_PYTHON(testname outputfile1 ...)) # Read UsePYTHONTest.cmake for more information # --------------------------------------- if ("${XDMF_DSM_IS_CRAY}" STREQUAL "") if (MPIEXEC_MAX_NUMPROCS STRGREATER 5) CLEAN_TEST_PYTHON(PythonDSM.sh) CLEAN_TEST_PYTHON(PythonConnect.sh dsmconnect.cfg) endif (MPIEXEC_MAX_NUMPROCS STRGREATER 5) else ("${XDMF_DSM_IS_CRAY}" STREQUAL "") if (MPIEXEC_MAX_NUMPROCS STRGREATER 5) CLEAN_TEST_PYTHON(CrayPythonConnect.sh dsmconnect.cfg) endif(MPIEXEC_MAX_NUMPROCS STRGREATER 5) endif ("${XDMF_DSM_IS_CRAY}" STREQUAL "") xdmf-3.0+git20160803/core/dsm/tests/Python/XdmfExampleDsmTest.py0000640000175000017500000004652213003006557024331 0ustar alastairalastairfrom mpi4py.MPI import * from Xdmf import * if __name__ == "__main__": #//initMPI begin #The total size of the DSM being created dsmSize = 64 comm = COMM_WORLD id = comm.Get_rank() size = comm.Get_size() #//initMPI end testArray = XdmfArray.New() testArray.initializeAsInt32(0) for i in range(1,5): testArray.pushBackAsInt32(i*(id+1)) #//initwritevector begin newPath = "dsm" newSetPath = "data" numServersCores = 2 writeStartVector = UInt32Vector() writeStartVector.push_back(id*4) #writeStartVector.push_back(id); writeStrideVector = UInt32Vector() writeStrideVector.push_back(1) #writeStrideVector.push_back(size-3); writeCountVector = UInt32Vector() writeCountVector.push_back(4) writeDataSizeVector = UInt32Vector() writeDataSizeVector.push_back(4*(size-numServersCores)) #//initwritevector end #//splitcomm begin ServerIds = [] for i in range(size-numServersCores, size): ServerIds.append(i) workers = comm.Get_group().Excl(ServerIds) workerComm = comm.Create(workers) #//splitcomm end #//initwritergenerate begin exampleWriter = XdmfHDF5WriterDSM.New(newPath, comm, dsmSize/numServersCores, size-numServersCores, size-1) #//initwritergenerate end ''' #//initcontrollergenerate begin exampleController = XdmfHDF5ControllerDSM.New( newPath, newSetPath, XdmfArrayType.Int32(), writeStartVector, writeStrideVector, writeCountVector, writeDataSizeVector, comm, dsmSize/numServersCores, size-numServersCores, size-1) #//initcontrollergenerate end ''' # Split out sub-comm for the worker cores # Server cores will not progress to this point until after the servers are done running #//startworksection begin if (id < size - numServersCores): #//startworksection end # This section is to demonstrate the functionality of the XdmfDSM classes #//setServerModewriter begin exampleWriter.setServerMode(True) #//setServerModewriter end #//getServerModewriter begin exampleServerMode = exampleWriter.getServerMode() #//getServerModewriter end #//getWorkerCommwriter begin exampleWorkerComm = exampleWriter.getWorkerComm() #//getWorkerCommwriter end #//setWorkerCommwriter begin exampleWriter.setWorkerComm(exampleWorkerComm) #//setWorkerCommwriter end ''' #//getWorkerCommcontroller begin exampleWorkerComm = exampleController.getWorkerComm() #//getWorkerCommcontroller end #//setWorkerCommcontroller begin exampleController.setWorkerComm(exampleWorkerComm) #//setWorkerCommcontroller end #//setServerModecontroller begin exampleController.setServerMode(True) #//setServerModecontroller end #//getServerModecontroller begin exampleControllerServerMode = exampleController.getServerMode() #//getServerModecontroller end ''' #//initcontrollerfrombuffer begin writeController = XdmfHDF5ControllerDSM.New( newPath, newSetPath, XdmfArrayType.Int32(), writeStartVector, writeStrideVector, writeCountVector, writeDataSizeVector, exampleWriter.getServerBuffer()); #//initcontrollerfrombuffer end #//initwriterfrombuffer begin exampleWriter2 = XdmfHDF5WriterDSM.New(newPath, exampleWriter.getServerBuffer()); #//initwriterfrombuffer end writeController.setServerMode(True) exampleControllerServerMode = writeController.getServerMode() #//getServerBufferwriter begin exampleBuffer = exampleWriter.getServerBuffer() #//getServerBufferwriter end #//setBufferwriter begin exampleWriter.setBuffer(exampleBuffer) #//setBufferwriter end ''' #//getServerBuffercontroller begin exampleBuffer = exampleController.getServerBuffer() #//getServerBuffercontroller end #//setBuffercontroller begin exampleController.setBuffer(exampleBuffer) #//setBuffercontroller end ''' #//GetIsConnectedbuffer begin exampleIsConnected = exampleBuffer.GetIsConnected() #//GetIsConnectedbuffer end #//SetIsConnectedbuffer begin exampleBuffer.SetIsConnected(exampleIsConnected) #//SetIsConnectedbuffer end #//GetDataPointer begin exampleDataPointer = exampleBuffer.GetDataPointer() #//GetDataPointer end #//GetDsmTypebuffer begin exampleDSMType = exampleBuffer.GetDsmType() #//GetDsmTypebuffer end #//SetDsmTypebuffer begin exampleBuffer.SetDsmType(XDMF_DSM_TYPE_UNIFORM) #//SetDsmTypebuffer end #//GetIsServerbuffer begin exampleBufferIsServer = exampleBuffer.GetIsServer() #//GetIsServerbuffer end #//SetIsServerbuffer begin exampleBuffer.SetIsServer(exampleBufferIsServer) #//SetIsServerbuffer end #//GetStartAddress begin exampleBufferStart = exampleBuffer.GetStartAddress() #//GetStartAddress end #//GetEndAddress begin exampleBufferEnd = exampleBuffer.GetEndAddress() #//GetEndAddress end #//GetStartServerId begin exampleServerStart = exampleBuffer.GetStartServerId() #//GetStartServerId end #//GetEndServerid begin exampleServerEnd = exampleBuffer.GetEndServerId() #//GetEndServerId end #//GetLength begin exampleBufferLength = exampleBuffer.GetLength() #//GetLength end #//GetTotalLength begin exampleTotalBufferLength = exampleBuffer.GetTotalLength() #//GetTotalLength end #//GetBlockLengthbuffer begin exampleBufferBlockLength = exampleBuffer.GetBlockLength() #//GetBlockLengthbuffer end #//SetBlockLengthbuffer begin exampleBuffer.SetBlockLength(exampleBufferBlockLength) #//SetBlockLengthbuffer end ''' #//ConfigureUniform begin exampleBuffer.ConfigureUniform(exampleBuffer.GetComm(), dsmSize/numServersCores, size - numServersCores, size - 1) #//ConfigureUniform end ''' sendingCore = -1 #//SendCommandHeader begin if (id == sendingCore): exampleBuffer.SendCommandHeader(XDMF_DSM_OPCODE_DONE, 1, 0, 0, XDMF_DSM_INTER_COMM) #//SendCommandHeader end #//SendData begin if (id == sendingCore): sentData = "datastring" exampleBuffer.SendData(1, sentData, 0, XDMF_DSM_PUT_DATA_TAG, 0, XDMF_DSM_INTER_COMM) #//SendData end #//SendAcknowledgment begin if (id == 1): sentData = 1 exampleBuffer.SendAcknowledgment(0, sentData, XDMF_DSM_PUT_DATA_TAG, XDMF_DSM_INTER_COMM) #//SendAcknowledgment end #//ReceiveAcknowledgement begin if (id == 0): recvData = 0 exampleBuffer.ReceiveAcknowledgment(1, recvData, XDMF_DSM_PUT_DATA_TAG, XDMF_DSM_INTER_COMM) #//ReceiveAcknowledgement end ServerIds = [] for i in range(0, (size - numServersCores) / 2): ServerIds.append(i) readingCores = workerComm.Get_group().Excl(ServerIds) readComm = workerComm.Create(readingCores) writingCores = workerComm.Get_group().Incl(ServerIds) writeComm = workerComm.Create(writingCores) exampleBuffer.GetComm().DupComm(workerComm) #//BufferService begin if (id == 0): serviceOut = exampleBuffer.BufferService() if (id == 1): exampleBuffer.SendCommandHeader(XDMF_DSM_OPCODE_DONE, 0, 0, 0, XDMF_DSM_INTER_COMM) #//BufferService end #//BufferServiceLoop begin if (id == 0): exampleBuffer.BufferServiceLoop() if (id == 1): exampleBuffer.SendCommandHeader(XDMF_DSM_OPCODE_DONE, 0, 0, 0, XDMF_DSM_INTER_COMM) #//BufferServiceLoop end #//GetComm begin exampleDSMComm = exampleBuffer.GetComm() #//GetComm end #//SetComm begin exampleBuffer.SetComm(exampleDSMComm) #//SetComm end #//GetId begin exampleIntraID = exampleDSMComm.GetId() #//GetId end #//GetIntraSize begin exampleIntraSize = exampleDSMComm.GetIntraSize() #//GetIntraSize end #//GetInterId begin exampleInterID = exampleDSMComm.GetInterId() #//GetInterId end #//GetInterSize begin exampleInterSize = exampleDSMComm.GetInterSize() #//GetInterSize end #//GetInterCommType begin exampleInterCommType = exampleDSMComm.GetInterCommType() #//GetInterCommType end #//initcomm begin exampleDSMComm.Init() #//initcomm end #//GetIntraComm begin exampleIntraComm = exampleDSMComm.GetIntraComm() #//GetIntraComm end #//DupComm begin exampleDSMComm.DupComm(exampleIntraComm.Dup()) #//DupComm end print type(exampleDSMComm.GetDsmPortName()) testName = "test" exampleDSMComm.SetDsmPortName(testName) print exampleDSMComm.GetDsmPortName() ''' connectingGroup = True if (id < 5): connectingGroup = True; else: connectingGroup = False; portString = "" if (!connectingGroup): exampleDSMComm.OpenPort() portString = exampleDSMComm.GetDsmPortName() // Send the port string to the connecting group exampleDSMComm.Accept() // When done with connection exampleDSMComm.ClosePort() if (connectingGroup): // Recieve string from Master group exampleDSMComm.SetDsmPortName(portString) exampleDSMComm.Connect() // When done with connection exampleDSMComm.Disconnect() ''' # This is the end of the Demonstration exampleWriter.setMode(XdmfHeavyDataWriter.Hyperslab) testArray.insert(writeController) for i in range(0, size-numServersCores): workerComm.Barrier() if (i == id): print "Core # " + str(id) print "Controller stats" print "datasetpath = " + XdmfHeavyDataController.XdmfHDF5ControllerCast(testArray.getHeavyDataController(0)).getDataSetPath() print "filepath = " + testArray.getHeavyDataController(0).getFilePath() outputVector = XdmfHeavyDataController.XdmfHDF5ControllerCast(testArray.getHeavyDataController(0)).getDataspaceDimensions() print "Data space dimensions" for j in range(0, outputVector.size()): print "[" + str(j) + "] =" + str(outputVector[j]) print "Controller Dimensions" outputVector = testArray.getHeavyDataController(0).getDimensions() for j in range(0, outputVector.size()): print "[" + str(j) + "] =" + str(outputVector[j]) print "Controller size" + str(testArray.getHeavyDataController(0).getSize()) print "Controller starts" outputVector = XdmfHeavyDataController.XdmfHDF5ControllerCast(testArray.getHeavyDataController(0)).getStart() for j in range(0, outputVector.size()): print "[" + str(j) + "] =" + str(outputVector[j]) print "Controller strides" outputVector = XdmfHeavyDataController.XdmfHDF5ControllerCast(testArray.getHeavyDataController(0)).getStride() for j in range(0, outputVector.size()): print "[" + str(j) + "] =" + str(outputVector[j]) for j in range(0, testArray.getSize()): print "core #" + str(id) + " testArray[" + str(j) + "] = " + str(testArray.getValueAsInt32(j)) testArray.accept(exampleWriter) readStartVector = UInt32Vector() readStartVector.push_back(4*(size - id - 1 - numServersCores)) readStrideVector = UInt32Vector() readStrideVector.push_back(1) readCountVector = UInt32Vector() readCountVector.push_back(4) readDataSizeVector = UInt32Vector() readDataSizeVector.push_back(4*(size-numServersCores)) readArray = XdmfArray.New() readArray.initializeAsInt32(0) readArray.reserve(testArray.getSize()) readController = XdmfHDF5ControllerDSM.New( newPath, newSetPath, XdmfArrayType.Int32(), readStartVector, readStrideVector, readCountVector, readDataSizeVector, exampleWriter.getServerBuffer()) readArray.insert(readController) if (id == 0): print "\n\n\n" print "testing read" readArray.read() for i in range (0, size): workerComm.Barrier() if (i == id): print "Core # " + str(id) print "Controller stats" print "datasetpath = " + XdmfHeavyDataController.XdmfHDF5ControllerCast(readArray.getHeavyDataController(0)).getDataSetPath() print "filepath = " + readArray.getHeavyDataController(0).getFilePath() outputVector = XdmfHeavyDataController.XdmfHDF5ControllerCast(readArray.getHeavyDataController(0)).getDataspaceDimensions() print "Data space dimensions" for j in range(0, outputVector.size()): print "[" + str(j) + "] =" + str(outputVector[j]) print "Controller Dimensions" outputVector = readArray.getHeavyDataController(0).getDimensions() for j in range(0, outputVector.size()): print "[" + str(j) + "] =" + str(outputVector[j]) print "Controller size" + str(readArray.getHeavyDataController(0).getSize()) print "Controller starts" outputVector = XdmfHeavyDataController.XdmfHDF5ControllerCast(readArray.getHeavyDataController(0)).getStart() for j in range(0, outputVector.size()): print "[" + str(j) + "] =" + str(outputVector[j]) print "Controller strides" outputVector = XdmfHeavyDataController.XdmfHDF5ControllerCast(readArray.getHeavyDataController(0)).getStride() for j in range(0, outputVector.size()): print "[" + str(j) + "] =" + str(outputVector[j]) for j in range (0, readArray.getSize()): print "core #" + str(id) + " readArray[" + str(j) + "] = " + str(readArray.getValueAsInt32(j)) workerComm.Barrier() # End of Work Section #//stopDSMwriter begin if (id == 0): exampleWriter.stopDSM() #//stopDSMwriter end ''' #//stopDSMcontroller begin if (id == 0): exampleController.stopDSM() #//stopDSMcontroller end #//sendDone begin if (id == 0): closeBuffer = exampleWriter.getServerBuffer() closeBuffer.SendDone() #//sendDone end ''' #//GetInterComm begin exampleDSMComm = exampleWriter.getServerBuffer().GetComm() exampleInterComm = exampleDSMComm.GetInterComm() #//GetInterComm end #//DupInterComm begin exampleDSMComm.DupInterComm(exampleInterComm.Dup()) #//DupInterComm end #//SendRecvInfo begin if (id >= size - numServersCores): exampleWriter.getServerBuffer().SendInfo() else: exampleWriter.getServerBuffer().ReceiveInfo() #//SendRecvInfo end ''' #//restartDSMwriter begin exampleWriter.restartDSM() #//restartDSMwriter end #//restartDSMcontroller begin exampleController.restartDSM() #//restartDSMcontroller end ''' #//finalizeMPI # exampleWriter.deleteManager() #//finalizeMPI ''' exampleController.deleteManager() ''' xdmf-3.0+git20160803/core/dsm/tests/Python/PythonDSM.sh0000740000175000017500000000016013003006557022407 0ustar alastairalastair# Intel MPI requires a minimum of 2 cores per process $MPIEXEC -n 4 $PYTHON_EXECUTABLE ./XdmfExampleDsmTest.py xdmf-3.0+git20160803/core/dsm/tests/Python/XdmfExampleAcceptTest.py0000640000175000017500000000477413003006557025010 0ustar alastairalastairprint "Accept" from mpi4py.MPI import * from Xdmf import * if __name__ == "__main__": if get_vendor()[0] == 'Open MPI': print "Interprogram DSM does not work properly with OpenMPI" else: #//initMPI begin dsmSize = 64 comm = COMM_WORLD id = comm.Get_rank() size = comm.Get_size() newPath = "dsm"; numServersCores = size - 1; numConnections = 2 exampleWriter = XdmfHDF5WriterDSM.New(newPath, comm, dsmSize/numServersCores, 1, 1, "Accept"); if id == 0: #//initMPI end #//GetDsmFileName begin connectionFileName = exampleWriter.getServerBuffer().GetComm().GetDsmFileName() #//GetDsmFileName end #//SetDsmFileName begin exampleWriter.getServerBuffer().GetComm().SetDsmFileName(connectionFileName) #//SetDsmFileName end #//OpenPort begin exampleWriter.getServerBuffer().GetComm().OpenPort() #//OpenPort end #//SendAccept begin exampleWriter.getServerBuffer().SendAccept(numConnections) #//SendAccept end ''' #//manualAccept begin # Notify the server cores to accept connections for i in range(exampleWriter.getServerBuffer().StartServerId, exampleWriter.getServerBuffer().EndServerId+1): if i != exampleWriter.getServerBuffer().Comm.GetId(): exampleWriter.getServerBuffer().SendCommandHeader(XDMF_DSM_ACCEPT, i, 0, 0, XDMF_DSM_INTER_COMM) exampleWriter.getServerBuffer().SendAcknowledgment(i, numConnections, XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM) # Accept connections exampleWriter.getServerBuffer().Comm.Accept(numConnections) # Distribute current DSM status exampleWriter.getServerBuffer().SendInfo() #//manualAccept end ''' #//finishwork begin exampleWriter.getServerBuffer().GetComm().GetIntraComm().Barrier() exampleWriter.getServerBuffer().GetComm().GetInterComm().Barrier() #//finishwork end #//ClosePort begin if id == 0: exampleWriter.getServerBuffer().GetComm().ClosePort() #//ClosePort end xdmf-3.0+git20160803/core/dsm/tests/Python/CrayPythonConnect.sh0000740000175000017500000000061313003006557024177 0ustar alastairalastair# Intel MPI requires a minimum of 2 cores per process echo "aprun -n 2 $PYTHON_EXECUTABLE ./XdmfExampleAcceptTest.py : -n 2 $PYTHON_EXECUTABLE ./XdmfExampleConnectTest.py : -n 2 $PYTHON_EXECUTABLE ./XdmfExampleConnectTest2.py" aprun -n 2 $PYTHON_EXECUTABLE ./XdmfExampleAcceptTest.py : -n 2 $PYTHON_EXECUTABLE ./XdmfExampleConnectTest.py : -n 2 $PYTHON_EXECUTABLE ./XdmfExampleConnectTest2.py xdmf-3.0+git20160803/core/dsm/tests/Python/XdmfExampleConnectTest2.py0000640000175000017500000001330113003006557025246 0ustar alastairalastairprint "Connect 2" from mpi4py.MPI import * from Xdmf import * import time import os.path if __name__ == "__main__": if get_vendor()[0] != 'Open MPI': #//initMPI begin dsmSize = 64 comm = COMM_WORLD id = comm.Get_rank() size = comm.Get_size() newPath = "dsm" newSetPath = "Data" # Initializing objects ''' testComm = XdmfDSMCommMPI() testComm.DupComm(comm) testComm.Init() testBuffer = XdmfDSMBuffer() testBuffer.SetIsServer(False) testBuffer.SetComm(testComm) testBuffer.SetIsConnected(True) ''' exampleWriter = XdmfHDF5WriterDSM.New(newPath, comm, "Connect 2") id = exampleWriter.getServerBuffer().GetComm().GetId() size = exampleWriter.getServerBuffer().GetComm().GetIntraSize() testBuffer = exampleWriter.getServerBuffer() testComm = testBuffer.GetComm() readStartVector = UInt32Vector() readStrideVector = UInt32Vector() readCountVector = UInt32Vector() readDataSizeVector = UInt32Vector() readStartVector.push_back(5*id) readStrideVector.push_back(1) readCountVector.push_back(5) readDataSizeVector.push_back(5*size) readArray = XdmfArray.New() readArray.initializeAsInt32(0) readArray.reserve(5) readController = XdmfHDF5ControllerDSM.New( newPath, newSetPath, XdmfArrayType.Int32(), readStartVector, readStrideVector, readCountVector, readDataSizeVector, testBuffer); time.sleep(10) configPath = testComm.GetDsmFileName() while not os.path.exists(configPath): time.sleep(5) readController.getServerBuffer().GetComm().ReadDsmPortName(); readController.getServerBuffer().Connect(); exampleWriter = XdmfHDF5WriterDSM.New(newPath, testBuffer); writeStartVector = UInt32Vector(); writeStrideVector = UInt32Vector(); writeCountVector = UInt32Vector(); writeDataSizeVector = UInt32Vector(); writeStartVector.push_back(id*5); writeStrideVector.push_back(1); writeCountVector.push_back(5); writeDataSizeVector.push_back(5*size); writeController = XdmfHDF5ControllerDSM.New( newPath, newSetPath, XdmfArrayType.Int32(), writeStartVector, writeStrideVector, writeCountVector, writeDataSizeVector, exampleWriter.getServerBuffer()); exampleWriter.setMode(XdmfHeavyDataWriter.Hyperslab); # Done initialization readController.getServerBuffer().GetComm().GetIntraComm().Barrier() loopamount = 4 print str(range(0, loopamount)) + "'s type = " + str(type(range(0, loopamount))) for numloops in range(0, loopamount): if id == 0: receiveData = 0 readController.getServerBuffer().ReceiveAcknowledgment(readController.getServerBuffer().GetComm().GetInterId() - 1, receiveData, XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM) readController.getServerBuffer().GetComm().GetIntraComm().Barrier() if readArray.getNumberHeavyDataControllers() > 0: readArray.removeHeavyDataController(0) readArray.insert(readController) readArray.read() for i in range(0, size): readController.getServerBuffer().GetComm().GetIntraComm().Barrier() if i == id: outputstream = " " outputstream = outputstream + "Array on core " + str(exampleWriter.getServerBuffer().GetComm().GetInterId()) + " contains:\n" for j in range(0, readArray.getSize()): tempVal = readArray.getValueAsInt32(j) tempVal = tempVal * 3 readArray.insertAsInt32(j, [tempVal]) outputstream = outputstream + "[" + str(j) + "]" + str(readArray.getValueAsInt32(j))+ "\n" print outputstream readController.getServerBuffer().GetComm().GetIntraComm().Barrier() if id == 0: print "\n\n" readArray.removeHeavyDataController(0) readArray.insert(writeController) readArray.accept(exampleWriter) if id == 0: receiveData = 0 readController.getServerBuffer().SendAcknowledgment(readController.getServerBuffer().GetComm().GetInterId() - 1, receiveData, XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM) # This last acknowledgment is to end the loop. if id == 0: receiveData = 0; readController.getServerBuffer().ReceiveAcknowledgment(readController.getServerBuffer().GetComm().GetInterId() - 1, receiveData, XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM) readController.getServerBuffer().GetComm().GetIntraComm().Barrier() if id == 0: readController.stopDSM() readController.getServerBuffer().GetComm().GetInterComm().Barrier() readController.getServerBuffer().Disconnect() xdmf-3.0+git20160803/core/dsm/tests/CMakeLists.txt0000640000175000017500000000016313003006557021507 0ustar alastairalastairadd_subdirectory(C) add_subdirectory(Cxx) if(XDMF_WRAP_PYTHON) add_subdirectory(Python) endif(XDMF_WRAP_PYTHON) xdmf-3.0+git20160803/core/dsm/tests/C/0000740000175000017500000000000013003006557017127 5ustar alastairalastairxdmf-3.0+git20160803/core/dsm/tests/C/CConnectTest.sh0000740000175000017500000000024013003006557022016 0ustar alastairalastair# Intel MPI requires a minimum of 2 cores per process $MPIEXEC -n 2 ./CXdmfAcceptTest & $MPIEXEC -n 2 ./CXdmfConnectTest & $MPIEXEC -n 2 ./CXdmfConnectTest2 xdmf-3.0+git20160803/core/dsm/tests/C/CMakeLists.txt0000640000175000017500000000275413003006557021701 0ustar alastairalastair# Include our test macros include(AddTestsC) # Add any dependencies that the cxx core tests may need # Note: The tests already depend on their own file ADD_TEST_C_DEPENDENCIES("XdmfCore") ADD_TEST_C_DEPENDENCIES("XdmfDSM") # Add any ldpath directories that the cxx tests may need ADD_TEST_C_LDPATH("${CMAKE_BINARY_DIR}") ADD_TEST_C_LDPATH("${XDMF_LIBRARY_DIRS}") # Add any path directoreis that the Cxx tests may need ADD_TEST_C_PATH("${CMAKE_BINARY_DIR}") ADD_TEST_C_PATH("${XDMF_BINARIES}") # Add any cxx tests here: # Note: We don't want to use a foreach loop to test the files incase we # have extra arguments (ie: ADD_TEST_CXX(testname inputfile)) # Read UseCxxTest.cmake for more information # --------------------------------------- if ("${XDMF_DSM_IS_CRAY}" STREQUAL "") if (MPIEXEC_MAX_NUMPROCS STRGREATER 5) ADD_MPI_TEST_C(CDSMLoopTest.sh CDSMLoopTest) ADD_MPI_TEST_C(CConnectTest.sh CXdmfAcceptTest,CXdmfConnectTest2,CXdmfConnectTest) endif(MPIEXEC_MAX_NUMPROCS STRGREATER 5) endif ("${XDMF_DSM_IS_CRAY}" STREQUAL "") # Add any cxx cleanup here: # Note: We don't want to use a foreach loop to test the files incase we # have multiple files (ie: CLEAN_TEST_CXX(testname outputfile1 ...)) # Read UseCxxTest.cmake for more information # --------------------------------------- if ("${XDMF_DSM_IS_CRAY}" STREQUAL "") if(XDMF_BUILD_DSM_THREADS) CLEAN_TEST_C(CConnectTest.sh dsmconnect.cfg) endif(XDMF_BUILD_DSM_THREADS) endif ("${XDMF_DSM_IS_CRAY}" STREQUAL "") xdmf-3.0+git20160803/core/dsm/tests/C/CXdmfConnectTest.c0000640000175000017500000002210113003006557022444 0ustar alastairalastair#include #include #include #include #include #include #include #include #include #include int main(int argc, char *argv[]) { /* This test does not work properly with openmpi*/ /* due to an issue with the openmpi code*/ #ifndef OPEN_MPI /* initMPI begin */ int size, id, dsmSize; dsmSize = 64; MPI_Status status; int xdmfStatus = 0; MPI_Comm comm = MPI_COMM_WORLD; MPI_Init(&argc, &argv); MPI_Comm_rank(comm, &id); MPI_Comm_size(comm, &size); char * newPath = "dsm"; char * newSetPath = "Data"; /* Initializing objects */ void * testComm = XdmfDSMCommMPINew(); XdmfDSMCommMPIDupComm(testComm, comm, &xdmfStatus); XdmfDSMCommMPIInit(testComm, &xdmfStatus); void * testBuffer = XdmfDSMBufferNew(); XdmfDSMBufferSetIsServer(testBuffer, 0); XdmfDSMBufferSetComm(testBuffer, testComm); XdmfDSMBufferSetIsConnected(testBuffer, 1); XDMFHDF5WRITERDSM * exampleWriter = XdmfHDF5WriterDSMNewFromServerBuffer(newPath, testBuffer, &xdmfStatus); #ifdef _WIN32 Sleep(500) #else sleep(5); #endif char * checkFileName = XdmfDSMCommMPIGetDsmFileName(testComm); FILE * checkFile = fopen(checkFileName, "r"); while (checkFile == NULL) { printf("file not found\n"); #ifdef _WIN32 Sleep(500); #else sleep(5); #endif } printf("done check\n"); fclose(checkFile); XdmfDSMCommMPIReadDsmPortName(XdmfDSMBufferGetComm(XdmfHDF5WriterDSMGetServerBuffer(exampleWriter))); char * portName = XdmfDSMCommMPIGetDsmPortName(XdmfDSMBufferGetComm(XdmfHDF5WriterDSMGetServerBuffer(exampleWriter))); XdmfDSMCommMPISetDsmPortName(XdmfDSMBufferGetComm(XdmfHDF5WriterDSMGetServerBuffer(exampleWriter)), portName); XdmfDSMBufferConnect(XdmfHDF5WriterDSMGetServerBuffer(exampleWriter), 0, &xdmfStatus); MPI_Barrier(XdmfDSMCommMPIGetIntraComm(XdmfDSMBufferGetComm(XdmfHDF5WriterDSMGetServerBuffer(exampleWriter)))); void * writeArray = XdmfArrayNew(); /* Iterators */ int i = 0; unsigned int j = 0; for (i = 1; i <= 5; ++i) { int value = i*(id+1); XdmfArrayPushBack(writeArray, &value, XDMF_ARRAY_TYPE_INT32, &xdmfStatus); } unsigned int writeStartVector[1]; unsigned int writeStrideVector[1]; unsigned int writeCountVector[1]; unsigned int writeDataSizeVector[1]; writeStartVector[0] = id*5; writeStrideVector[0] = 1; writeCountVector[0] = 5; writeDataSizeVector[0] = 5*size; XDMFHDF5CONTROLLERDSM * writeController = XdmfHDF5ControllerDSMNewFromServerBuffer( newPath, newSetPath, XDMF_ARRAY_TYPE_INT32, writeStartVector, writeStrideVector, writeCountVector, writeDataSizeVector, 1, XdmfHDF5WriterDSMGetServerBuffer(exampleWriter), &xdmfStatus); unsigned int readStartVector[1]; unsigned int readStrideVector[1]; unsigned int readCountVector[1]; unsigned int readDataSizeVector[1]; readStartVector[0] = 5*id; readStrideVector[0] = 1; readCountVector[0] = 5; readDataSizeVector[0] = 5*size; XDMFHDF5CONTROLLERDSM * readController = XdmfHDF5ControllerDSMNewFromServerBuffer( newPath, newSetPath, XDMF_ARRAY_TYPE_INT32, readStartVector, readStrideVector, readCountVector, readDataSizeVector, 1, XdmfHDF5WriterDSMGetServerBuffer(exampleWriter), &xdmfStatus); XdmfHDF5WriterDSMSetMode(exampleWriter, XDMF_HEAVY_WRITER_MODE_HYPERSLAB, &xdmfStatus); /* Done initializing */ for (i = 0; i < size; ++i) { MPI_Barrier(XdmfDSMCommMPIGetIntraComm(XdmfDSMBufferGetComm(XdmfHDF5WriterDSMGetServerBuffer(exampleWriter)))); if (i == id) { printf("Array on core %d contains:\n", XdmfDSMCommMPIGetInterId(XdmfDSMBufferGetComm(XdmfHDF5WriterDSMGetServerBuffer(exampleWriter)))); for (j = 0; j < XdmfArrayGetSize(writeArray); ++j) { printf("[%d] = %d\n", j, ((int *)XdmfArrayGetValue(writeArray, j, XDMF_ARRAY_TYPE_INT32, &xdmfStatus))[0]); } } } unsigned int numloops = 0; for (numloops = 0; numloops < 4; ++numloops) { if (XdmfArrayGetNumberHeavyDataControllers(writeArray) > 0) { XdmfArrayRemoveHeavyDataController(writeArray, 0); } XdmfArrayInsertHeavyDataController(writeArray, (XDMFHEAVYDATACONTROLLER *)writeController, 0); if (id == size - 1) { printf("\n\n"); } XdmfArrayAccept(writeArray, (XDMFVISITOR *)exampleWriter, &xdmfStatus); if (id == size - 1) { int sentData = 1; XdmfDSMBufferSendAcknowledgment(XdmfHDF5WriterDSMGetServerBuffer(exampleWriter), XdmfDSMCommMPIGetInterId(XdmfDSMBufferGetComm(XdmfHDF5WriterDSMGetServerBuffer(exampleWriter))) + 1, sentData, XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM, &xdmfStatus); XdmfDSMBufferReceiveAcknowledgment(XdmfHDF5WriterDSMGetServerBuffer(exampleWriter), XdmfDSMCommMPIGetInterId(XdmfDSMBufferGetComm(XdmfHDF5WriterDSMGetServerBuffer(exampleWriter))) + 1, &sentData, XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM, &xdmfStatus); } MPI_Barrier(XdmfDSMCommMPIGetIntraComm(XdmfDSMBufferGetComm(XdmfHDF5WriterDSMGetServerBuffer(exampleWriter)))); XdmfArrayRemoveHeavyDataController(writeArray, 0); XdmfArrayInsertHeavyDataController(writeArray, (XDMFHEAVYDATACONTROLLER *)readController, 0); XdmfArrayRelease(writeArray); XdmfArrayRead(writeArray, &xdmfStatus); for (i = 0; i < size; ++i) { MPI_Barrier(XdmfDSMCommMPIGetIntraComm(XdmfDSMBufferGetComm(XdmfHDF5WriterDSMGetServerBuffer(exampleWriter)))); if (i == id) { printf("Array on core %d contains:\n", XdmfDSMCommMPIGetInterId(XdmfDSMBufferGetComm(XdmfHDF5WriterDSMGetServerBuffer(exampleWriter)))); for (j = 0; j < XdmfArrayGetSize(writeArray); ++j) { int tempVal = ((int *)XdmfArrayGetValue(writeArray, j, XDMF_ARRAY_TYPE_INT32, &xdmfStatus))[0]; tempVal = tempVal * 2; XdmfArrayInsertValue(writeArray, j, &tempVal, XDMF_ARRAY_TYPE_INT32, &xdmfStatus); printf("[%d] = %d\n", j, ((int *)XdmfArrayGetValue(writeArray, j, XDMF_ARRAY_TYPE_INT32, &xdmfStatus))[0]); } } } } if (id == size - 1) { int sentData = 1; XdmfDSMBufferSendAcknowledgment(XdmfHDF5WriterDSMGetServerBuffer(exampleWriter), XdmfDSMCommMPIGetInterId(XdmfDSMBufferGetComm(XdmfHDF5WriterDSMGetServerBuffer(exampleWriter))) + 1, sentData, XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM, &xdmfStatus); } MPI_Barrier(XdmfDSMCommMPIGetIntraComm(XdmfDSMBufferGetComm(XdmfHDF5WriterDSMGetServerBuffer(exampleWriter)))); MPI_Barrier(XdmfDSMCommMPIGetInterComm(XdmfDSMBufferGetComm(XdmfHDF5WriterDSMGetServerBuffer(exampleWriter)))); XdmfDSMBufferDisconnect(XdmfHDF5WriterDSMGetServerBuffer(exampleWriter), &xdmfStatus); XdmfDSMCommMPIDisconnect(XdmfDSMBufferGetComm(XdmfHDF5WriterDSMGetServerBuffer(exampleWriter)), &xdmfStatus); MPI_Finalize(); #endif return 0; } xdmf-3.0+git20160803/core/dsm/tests/C/CDSMLoopTest.sh0000740000175000017500000000003513003006557021704 0ustar alastairalastair$MPIEXEC -n 4 ./CDSMLoopTest xdmf-3.0+git20160803/core/dsm/tests/C/CXdmfConnectTest2.c0000640000175000017500000002100113003006557022524 0ustar alastairalastair#include #include #include #include #include #include #include #include #include #include int main(int argc, char *argv[]) { /* This test does not work properly with openmpi*/ /* due to an issue with the openmpi code*/ #ifndef OPEN_MPI int size, id, dsmSize; dsmSize = 64; MPI_Status status; MPI_Comm comm = MPI_COMM_WORLD; int xdmfStatus = 0; /* Iterators */ int i = 0; unsigned int j = 0; MPI_Init(&argc, &argv); MPI_Comm_rank(comm, &id); MPI_Comm_size(comm, &size); char * newPath = "dsm"; char * newSetPath = "Data"; /* Initializing objects */ /* * Since the start and end ids are larger than the size there are no buffers alloted * thus, no blockage occurs */ void * testComm = XdmfDSMCommMPINew(); XdmfDSMCommMPIDupComm(testComm, comm, &xdmfStatus); XdmfDSMCommMPIInit(testComm, &xdmfStatus); void * testBuffer = XdmfDSMBufferNew(); XdmfDSMBufferSetIsServer(testBuffer, 0); XdmfDSMBufferSetComm(testBuffer, testComm); XdmfDSMBufferSetIsConnected(testBuffer, 1); unsigned int readStartVector[1]; unsigned int readStrideVector[1]; unsigned int readCountVector[1]; unsigned int readDataSizeVector[1]; readStartVector[0] = 5*id; readStrideVector[0] = 1; readCountVector[0] = 5; readDataSizeVector[0] = 5*size; void * readArray = XdmfArrayNew(); int arraySize[1] = {5}; XdmfArrayInitialize(readArray, arraySize, 1, XDMF_ARRAY_TYPE_INT32, &xdmfStatus); XDMFHDF5CONTROLLERDSM * readController = XdmfHDF5ControllerDSMNewFromServerBuffer( newPath, newSetPath, XDMF_ARRAY_TYPE_INT32, readStartVector, readStrideVector, readCountVector, readDataSizeVector, 1, testBuffer, &xdmfStatus); #ifdef _WIN32 Sleep(1000) #else sleep(10); #endif char * checkFileName = XdmfDSMCommMPIGetDsmFileName(testComm); FILE * checkFile = fopen(checkFileName, "r"); while (checkFile == NULL) { printf("file not found\n"); #ifdef _WIN32 Sleep(500) #else sleep(5); #endif } printf("done check\n"); fclose(checkFile); XdmfDSMCommMPIReadDsmPortName(XdmfDSMBufferGetComm(XdmfHDF5ControllerDSMGetServerBuffer(readController))); XdmfDSMBufferConnect(XdmfHDF5ControllerDSMGetServerBuffer(readController), 0, &xdmfStatus); XDMFHDF5WRITERDSM * exampleWriter = XdmfHDF5WriterDSMNewFromServerBuffer(newPath, testBuffer, &xdmfStatus); unsigned int writeStartVector[1]; unsigned int writeStrideVector[1]; unsigned int writeCountVector[1]; unsigned int writeDataSizeVector[1]; writeStartVector[0] = id*5; writeStrideVector[0] = 1; writeCountVector[0] = 5; writeDataSizeVector[0] = 5*size; XDMFHDF5CONTROLLERDSM * writeController = XdmfHDF5ControllerDSMNewFromServerBuffer( newPath, newSetPath, XDMF_ARRAY_TYPE_INT32, writeStartVector, writeStrideVector, writeCountVector, writeDataSizeVector, 1, XdmfHDF5WriterDSMGetServerBuffer(exampleWriter), &xdmfStatus); XdmfHDF5WriterDSMSetMode(exampleWriter, XDMF_HEAVY_WRITER_MODE_HYPERSLAB, &xdmfStatus); /* Done initialization */ MPI_Barrier(XdmfDSMCommMPIGetIntraComm(XdmfDSMBufferGetComm(XdmfHDF5ControllerDSMGetServerBuffer(readController)))); unsigned int numloops = 0; for (numloops = 0; numloops < 4; ++numloops) { if (id == 0) { int receiveData = 0; XdmfDSMBufferReceiveAcknowledgment(XdmfHDF5ControllerDSMGetServerBuffer(readController), XdmfDSMCommMPIGetInterId(XdmfDSMBufferGetComm(XdmfHDF5ControllerDSMGetServerBuffer(readController))) - 1, &receiveData, XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM, &xdmfStatus); } MPI_Barrier(XdmfDSMCommMPIGetIntraComm(XdmfDSMBufferGetComm(XdmfHDF5ControllerDSMGetServerBuffer(readController)))); if (XdmfArrayGetNumberHeavyDataControllers(readArray) > 0) { XdmfArrayRemoveHeavyDataController(readArray, 0); } XdmfArrayInsertHeavyDataController(readArray, (XDMFHEAVYDATACONTROLLER *)readController, 0); XdmfArrayRead(readArray, &xdmfStatus); for (i = 0; i < size; ++i) { MPI_Barrier(XdmfDSMCommMPIGetIntraComm(XdmfDSMBufferGetComm(XdmfHDF5ControllerDSMGetServerBuffer(readController)))); if (i == id) { printf("Array on core %d contains:\n", XdmfDSMCommMPIGetInterId(XdmfDSMBufferGetComm(XdmfHDF5WriterDSMGetServerBuffer(exampleWriter)))); for (j = 0; j < XdmfArrayGetSize(readArray); ++j) { int tempVal = ((int *)XdmfArrayGetValue(readArray, j, XDMF_ARRAY_TYPE_INT32, &xdmfStatus))[0]; tempVal = tempVal * 3; XdmfArrayInsertValue(readArray, j, &tempVal, XDMF_ARRAY_TYPE_INT32, &xdmfStatus); printf("[%d] = %d\n", j, ((int *)XdmfArrayGetValue(readArray, j, XDMF_ARRAY_TYPE_INT32, &xdmfStatus))[0]); } } } MPI_Barrier(XdmfDSMCommMPIGetIntraComm(XdmfDSMBufferGetComm(XdmfHDF5ControllerDSMGetServerBuffer(readController)))); if (id == 0) { printf("\n\n"); } XdmfArrayRemoveHeavyDataController(readArray, 0); XdmfArrayInsertHeavyDataController(readArray, (XDMFHEAVYDATACONTROLLER *)writeController, 0); XdmfArrayAccept(readArray, (XDMFVISITOR *)exampleWriter, &xdmfStatus); if (id == 0) { int receiveData = 0; XdmfDSMBufferSendAcknowledgment(XdmfHDF5ControllerDSMGetServerBuffer(readController), XdmfDSMCommMPIGetInterId(XdmfDSMBufferGetComm(XdmfHDF5ControllerDSMGetServerBuffer(readController))) - 1, receiveData, XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM, &xdmfStatus); } } /* This last acknowledgment is to end the loop. */ if (id == 0) { int receiveData = 0; XdmfDSMBufferReceiveAcknowledgment(XdmfHDF5ControllerDSMGetServerBuffer(readController), XdmfDSMCommMPIGetInterId(XdmfDSMBufferGetComm(XdmfHDF5ControllerDSMGetServerBuffer(readController))) - 1, &receiveData, XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM, &xdmfStatus); } MPI_Barrier(XdmfDSMCommMPIGetIntraComm(XdmfDSMBufferGetComm(XdmfHDF5ControllerDSMGetServerBuffer(readController)))); /* Do work stuff here */ if (id == 0) { XdmfHDF5ControllerDSMStopDSM(readController, &xdmfStatus); } MPI_Barrier(XdmfDSMCommMPIGetInterComm(XdmfDSMBufferGetComm(XdmfHDF5ControllerDSMGetServerBuffer(readController)))); MPI_Finalize(); #endif return 0; } xdmf-3.0+git20160803/core/dsm/tests/C/CXdmfAcceptTest.c0000640000175000017500000000307713003006557022265 0ustar alastairalastair#include #include #include #include #include #include int main(int argc, char *argv[]) { /* This test does not work properly with openmpi*/ /* due to an issue with the openmpi code*/ #ifndef OPEN_MPI int size, id, dsmSize; int xdmfStatus = 0; dsmSize = 64; MPI_Status status; MPI_Comm comm = MPI_COMM_WORLD; MPI_Init(&argc, &argv); MPI_Comm_rank(comm, &id); MPI_Comm_size(comm, &size); char * newPath = "dsm"; int numServersCores = size - 1; int numConnections = 2; XDMFHDF5WRITERDSM * exampleWriter = XdmfHDF5WriterDSMNew(newPath, comm, dsmSize/numServersCores, size-numServersCores, size-1, "Accept", &xdmfStatus); if (id == 0) { XdmfDSMCommMPIOpenPort(XdmfDSMBufferGetComm(XdmfHDF5WriterDSMGetServerBuffer(exampleWriter)), &xdmfStatus); XdmfDSMBufferSendAccept(XdmfHDF5WriterDSMGetServerBuffer(exampleWriter), numConnections); MPI_Barrier(XdmfDSMCommMPIGetIntraComm(XdmfDSMBufferGetComm(XdmfHDF5WriterDSMGetServerBuffer(exampleWriter)))); } MPI_Barrier(XdmfDSMCommMPIGetInterComm(XdmfDSMBufferGetComm(XdmfHDF5WriterDSMGetServerBuffer(exampleWriter)))); if (id == 0) { XdmfDSMCommMPIClosePort(XdmfDSMBufferGetComm(XdmfHDF5WriterDSMGetServerBuffer(exampleWriter)), &xdmfStatus); } MPI_Finalize(); #else printf("Interprogram DSM does not work properly with OpenMPI\n"); #endif return 0; } xdmf-3.0+git20160803/core/dsm/tests/C/CDSMLoopTest.c0000640000175000017500000003415313003006557021523 0ustar alastairalastair#include #include #include #include "XdmfArray.hpp" #include "XdmfArrayType.hpp" #include "XdmfHDF5WriterDSM.hpp" #include "XdmfHDF5ControllerDSM.hpp" int main(int argc, char *argv[]) { int size, id, dsmSize; dsmSize = 64;//The total size of the DSM being created MPI_Status status; MPI_Comm comm = MPI_COMM_WORLD; int xdmfStatus = 0; MPI_Init(&argc, &argv); MPI_Comm_rank(comm, &id); MPI_Comm_size(comm, &size); // Change this to determine the number of cores used as servers int numServersCores = 2; // Change this to determine the size of the arrays generated when initializing int writeArraySize = 4; void * testArray = XdmfArrayNew(); XdmfArrayInitialize(testArray, &writeArraySize, 1, XDMF_ARRAY_TYPE_INT32, &xdmfStatus); char * newPath = "dsm"; char * newSetPath = "data"; unsigned int writeStartVector[1]; unsigned int writeStrideVector[1]; unsigned int writeCountVector[1]; unsigned int writeDataSizeVector[1]; unsigned int readStartVector[1]; unsigned int readStrideVector[1]; unsigned int readCountVector[1]; unsigned int readDataSizeVector[1]; unsigned int readOutputCountVector[1]; void * readArray = XdmfArrayNew(); XdmfArrayInitialize(readArray, &writeArraySize, 1, XDMF_ARRAY_TYPE_INT32, &xdmfStatus); XDMFHDF5CONTROLLERDSM * readController; XDMFHDF5CONTROLLERDSM * readOutputController; XDMFHDF5CONTROLLERDSM * writeController; MPI_Comm workerComm; MPI_Group workers, dsmgroup; MPI_Comm_group(comm, &dsmgroup); int * ServerIds = (int *)calloc((numServersCores), sizeof(int)); unsigned int index = 0; int i; for(i=size-numServersCores ; i <= size-1 ; ++i) { ServerIds[index++] = i; } MPI_Group_excl(dsmgroup, index, ServerIds, &workers); int testval = MPI_Comm_create(comm, workers, &workerComm); cfree(ServerIds); XDMFHDF5WRITERDSM * exampleWriter = XdmfHDF5WriterDSMNew(newPath, comm, dsmSize/numServersCores, size-numServersCores, size-1, "Application", &xdmfStatus); XdmfHDF5WriterDSMSetMode(exampleWriter, XDMF_HEAVY_WRITER_MODE_HYPERSLAB, &xdmfStatus); //split out sub-comm for the worker cores //server cores will not progress to this point until after the servers are done running if (id < size - numServersCores) { // Split the comm even further MPI_Comm readComm, writeComm; MPI_Group readingCores, writingCores; MPI_Comm_group(workerComm, &workers); int * ServerIds = (int *)calloc(((size - numServersCores) / 2), sizeof(int)); unsigned int index = 0; for(i=0 ; i < (int)((size - numServersCores) / 2) ; ++i) { ServerIds[index++] = i; } MPI_Group_excl(workers, index, ServerIds, &readingCores); testval = MPI_Comm_create(workerComm, readingCores, &readComm); MPI_Group_incl(workers, index, ServerIds, &writingCores); testval = MPI_Comm_create(workerComm, writingCores, &writeComm); cfree(ServerIds); printf("initializing\n"); // Initialize values // Writer is first if (id < (int)((size - numServersCores) / 2)) { unsigned int j; for (j = 1; j <= writeArraySize; ++j) { int value = j*(id+1); XdmfArrayInsertValue(testArray, j-1, &value, XDMF_ARRAY_TYPE_INT32, &xdmfStatus); } writeStartVector[0] = id*writeArraySize; writeStrideVector[0] = 1; writeCountVector[0] = writeArraySize; writeDataSizeVector[0] = writeArraySize*(int)((size-numServersCores) / 2); writeController = XdmfHDF5ControllerDSMNewFromServerBuffer( newPath, newSetPath, XDMF_ARRAY_TYPE_INT32, writeStartVector, writeStrideVector, writeCountVector, writeDataSizeVector, 1, XdmfHDF5WriterDSMGetServerBuffer(exampleWriter), &xdmfStatus); XdmfArrayInsertHeavyDataController(testArray, (XDMFHEAVYDATACONTROLLER *)writeController, 0); readStartVector[0] = 0; readStrideVector[0] = 1; readCountVector[0] = 0; readDataSizeVector[0] = writeArraySize*(int)((size-numServersCores) / 2); readController = XdmfHDF5ControllerDSMNewFromServerBuffer( newPath, newSetPath, XDMF_ARRAY_TYPE_INT32, readStartVector, readStrideVector, readCountVector, readDataSizeVector, 1, XdmfHDF5WriterDSMGetServerBuffer(exampleWriter), &xdmfStatus); XdmfArrayInsertHeavyDataController(readArray, (XDMFHEAVYDATACONTROLLER *)readController, 0); for (j = 0; j= (int)((size - numServersCores) / 2)) { // Controllers are accessed like this since the writer removes them and creates its own. XdmfHDF5ControllerDSMSetWorkerComm((XDMFHDF5CONTROLLERDSM *)XdmfArrayGetHeavyDataController(readArray, 0), readComm, &xdmfStatus); printf("read on core %d\n", id); XdmfArrayRead(readArray, &xdmfStatus); MPI_Barrier(readComm); if (id == (int)((size - numServersCores) / 2)) { unsigned int j; for(j=0; j (int)((size - numServersCores) / 2)) { // Only the first read core should write out data XdmfArrayRemoveHeavyDataController(readArray, 0); XdmfArrayInsertHeavyDataController(readArray, (XDMFHEAVYDATACONTROLLER *)readOutputController, 0); } XdmfArrayAccept(readArray, (XDMFVISITOR *)exampleWriter, &xdmfStatus); if (id > (int)((size - numServersCores) / 2)) { // Only the first read core should write out data XdmfArrayRemoveHeavyDataController(readArray, 0); XdmfArrayInsertHeavyDataController(readArray, (XDMFHEAVYDATACONTROLLER *)readController, 0); } MPI_Barrier(workerComm); printf("on writing cores\n"); if (id < (int)((size - numServersCores) / 2)) { XdmfHDF5ControllerDSMSetWorkerComm((XDMFHDF5CONTROLLERDSM *)XdmfArrayGetHeavyDataController(testArray, 0), writeComm, &xdmfStatus); XdmfArrayRead(testArray, &xdmfStatus); MPI_Barrier(writeComm); unsigned int i; for (i = 0; i #include #include "XdmfSharedPtr.hpp" /** * @brief Reads an Xdmf file stored on disk into memory. * * Reads an Xdmf file stored on disk into an Xdmf structure in memory. * All light data is parsed in order to create appropriate Xdmf * objects. Heavy data controllers are created and attached to * XdmfArrays but no heavy data is read into memory. * * XdmfCoreReader is an abstract base class. */ class XDMFCORE_EXPORT XdmfCoreReader { public: virtual ~XdmfCoreReader() = 0; /** * Uses the internal item factory to create a copy of the internal pointer * of the provided shared pointer. Primarily used for C wrapping. * * @param original The source shared pointer that the pointer will be pulled from. * @return A duplicate of the object contained in the pointer. */ virtual XdmfItem * DuplicatePointer(shared_ptr original) const; virtual std::vector > generateHeavyDataControllers(std::map controllerProperties, const std::vector & passedDimensions = std::vector(), shared_ptr passedArrayType = shared_ptr(), const std::string & passedFormat = std::string()) const; virtual shared_ptr generateHeavyDataWriter(std::string typeName, std::string path) const; /** * Parse a string containing light data into an Xdmf structure in * memory. * * Example of use: * * C++ * * @dontinclude ExampleXdmfCoreReader.cpp * @skipline //#initialization * @until //#initialization * @skipline //#parse * @until //#parse * * Python * * @dontinclude XdmfExampleCoreReader.py * @skipline #//initialization * @until #//initialization * @skipline #//parse * @until #//parse * * @param lightData A string containing light data description of an * Xdmf file. * * @return An XdmfItem at the root of the Xdmf tree. */ virtual shared_ptr parse(const std::string & lightData) const; /** * Read an Xdmf file from disk into memory. * * Example of use: * * C++ * * @dontinclude ExampleXdmfCoreReader.cpp * @skipline //#initialization * @until //#initialization * @skipline //#readpath * @until //#readpath * @skipline //#readroot * @until //#readroot * * Python * * @dontinclude XdmfExampleCoreReader.py * @skipline #//initialization * @until #//initialization * @skipline #//readpath * @until #//readpath * @skipline #//readroot * @until #//readroot * * @param filePath The path of the Xdmf file to read in from disk. * * @return An XdmfItem at the root of the Xdmf tree. */ virtual shared_ptr read(const std::string & filePath) const; /** * Read part of an Xdmf file from disk into memory. * * Example of use: * * C++ * * @dontinclude ExampleXdmfCoreReader.cpp * @skipline //#initialization * @until //#initialization * @skipline //#readpath * @until //#readpath * @skipline //#readXPath * @until //#readXPath * * Python * * @dontinclude XdmfExampleCoreReader.py * @skipline #//initialization * @until #//initialization * @skipline #//readpath * @until #//readpath * @skipline #//readXPath * @until #//readXPath * * @param filePath The path of the Xdmf file to read in from disk. * @param xPath An XPath corresponding to the portion of the * file to read. * * @return A vector of XdmfItems that are included * in the XPath. */ virtual std::vector > read(const std::string & filePath, const std::string & xPath) const; /** * Read an Xdmf file from disk into memory. * * Example of use: * * C++ * * @dontinclude ExampleXdmfCoreReader.cpp * @skipline //#initialization * @until //#initialization * @skipline //#readpath * @until //#readpath * @skipline //#readItems * @until //#readItems * * Python * * @dontinclude XdmfExampleCoreReader.py * @skipline #//initialization * @until #//initialization * @skipline #//readpath * @until #//readpath * @skipline #//readItems * @until #//readItems * * @param filePath The path of the Xdmf file to read in from disk. * * @return A vector of XdmfItems at the root of the Xdmf tree. */ virtual std::vector > readItems(const std::string & filePath) const; /** * Used by the other functions to read items from an open file. * * Since files are closed between reads, this does nothing by itself. * * @param xPath An XPath corresponding to the portion of the file to read. * * @return A vector of items at the X path provided. */ std::vector > readPathObjects(const std::string & xPath) const; protected: /** * Constructor * * @param itemFactory an XdmfCoreItemFactory to construct XdmfItems * for a specific language. */ XdmfCoreReader(const shared_ptr itemFactory); private: /** * PIMPL */ class XdmfCoreReaderImpl; XdmfCoreReader(const XdmfCoreReader &); // Not implemented. void operator=(const XdmfCoreReader &); // Not implemented. XdmfCoreReaderImpl * const mImpl; }; #endif #ifdef __cplusplus extern "C" { #endif // C wrappers go here struct XDMFCOREREADER; // Simply as a typedef to ensure correct typing typedef struct XDMFCOREREADER XDMFCOREREADER; XDMFCORE_EXPORT XDMFITEM * XdmfCoreReaderRead(XDMFCOREREADER * reader, char * filePath, int * status); #define XDMF_CORE_READER_C_CHILD_DECLARE(ClassName, CClassName, Level) \ \ Level##_EXPORT XDMFITEM * ClassName##Read( CClassName * reader, char * filePath, int * status); #define XDMF_CORE_READER_C_CHILD_WRAPPER(ClassName, CClassName) \ \ XDMFITEM * ClassName##Read( CClassName * reader, char * filePath, int * status) \ { \ return XdmfCoreReaderRead((XDMFCOREREADER *)((void *)reader), filePath, status); \ } #ifdef __cplusplus } #endif #endif /* XDMFCOREREADER_HPP_ */ xdmf-3.0+git20160803/core/XdmfHeavyDataDescription.cpp0000640000175000017500000000663613003006557022432 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfHeavyDataDescription.hpp */ /* */ /* Author: */ /* Andrew Burns */ /* andrew.j.burns2@us.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2013 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #include #include "XdmfError.hpp" #include "XdmfHeavyDataDescription.hpp" #include "XdmfSharedPtr.hpp" #include "XdmfVisitor.hpp" #include "string.h" shared_ptr XdmfHeavyDataDescription::New() { shared_ptr p(new XdmfHeavyDataDescription()); return p; } XdmfHeavyDataDescription::XdmfHeavyDataDescription() { } XdmfHeavyDataDescription::XdmfHeavyDataDescription(XdmfHeavyDataDescription & refDescription) : XdmfItem(refDescription) { } XdmfHeavyDataDescription::~XdmfHeavyDataDescription() { } const std::string XdmfHeavyDataDescription::ItemTag = "HeavyData"; std::map XdmfHeavyDataDescription::getItemProperties() const { std::map descriptionProperties; return descriptionProperties; } std::string XdmfHeavyDataDescription::getItemTag() const { return ItemTag; } void XdmfHeavyDataDescription::populateItem(const std::map & itemProperties, const std::vector > & childItems, const XdmfCoreReader * const reader) { XdmfItem::populateItem(itemProperties, childItems, reader); } void XdmfHeavyDataDescription::traverse(const shared_ptr visitor) { } XDMFHEAVYDATADESCRIPTION * XdmfHeavyDataDescriptionNew(char * key, char * value) { std::string createKey(key); std::string createValue(value); shared_ptr generatedDesc = XdmfHeavyDataDescription::New(); return (XDMFHEAVYDATADESCRIPTION *)((void *)(new XdmfHeavyDataDescription(*generatedDesc.get()))); } XDMF_ITEM_C_CHILD_WRAPPER(XdmfHeavyDataDescription, XDMFHEAVYDATADESCRIPTION) xdmf-3.0+git20160803/core/XdmfHeavyDataDescription.hpp0000640000175000017500000000720213003006557022425 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfHeavyDataDescription.hpp */ /* */ /* Author: */ /* Andrew Burns */ /* andrew.j.burns2@us.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2013 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef XDMFHEAVYDATADESCRIPTION_HPP_ #define XDMFHEAVYDATADESCRIPTION_HPP_ // C Compatible Includes #include "XdmfCore.hpp" #include "XdmfItem.hpp" #ifdef __cplusplus /** * @brief Holds information about a dsm buffer so that a process can connect. * * XdmfDescription stores the information required to process * to a data format */ class XDMFCORE_EXPORT XdmfHeavyDataDescription : public XdmfItem { public: /** * */ static shared_ptr New(); virtual ~XdmfHeavyDataDescription(); LOKI_DEFINE_VISITABLE(XdmfHeavyDataDescription, XdmfItem) static const std::string ItemTag; std::map getItemProperties() const; virtual std::string getItemTag() const; std::string getPortDescription() const; using XdmfItem::insert; void setPortDescription(std::string portDesc); virtual void traverse(const shared_ptr visitor); XdmfHeavyDataDescription(XdmfHeavyDataDescription &); protected: XdmfHeavyDataDescription(); virtual void populateItem(const std::map & itemProperties, const std::vector > & childItems, const XdmfCoreReader * const reader); private: XdmfHeavyDataDescription(const XdmfHeavyDataDescription &); // Not implemented. void operator=(const XdmfHeavyDataDescription &); // Not implemented. std::string mPortDescription; }; #endif #ifdef __cplusplus extern "C" { #endif // C wrappers go here struct XDMFHEAVYDATADESCRIPTION; // Simply as a typedef to ensure correct typing typedef struct XDMFHEAVYDATADESCRIPTION XDMFHEAVYDATADESCRIPTION; XDMFCORE_EXPORT XDMFHEAVYDATADESCRIPTION * XdmfHeavyDataDescriptionNew(); // C Wrappers for parent classes are generated by macros XDMF_ITEM_C_CHILD_DECLARE(XdmfHeavyDataDescription, XDMFHEAVYDATADESCRIPTION, XDMFCORE) #ifdef __cplusplus } #endif #endif /* XDMFHeavyDataDESCRIPTION_HPP_ */ xdmf-3.0+git20160803/core/CMakeLists.txt0000640000175000017500000002043213003006557017563 0ustar alastairalastairproject(XdmfCore) cmake_minimum_required(VERSION 2.6) if (POLICY CMP0015) cmake_policy(SET CMP0015 NEW) endif () include(CheckCXXSourceCompiles) include(SetUpVersion) include(TestBigEndian) if(VERSION_CONTROL_AUTOUPDATE OR NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/XdmfVersion.hpp) VersionCreate("Xdmf" "3" "3" "0" "XDMFCORE_EXPORT" "XdmfCore.hpp") endif() if(BUILD_SHARED_LIBS) set(LIBTYPE SHARED) set(BUILD_SHARED 1) else() set(LIBTYPE STATIC) endif() include_directories(${CMAKE_CURRENT_SOURCE_DIR}) include_directories(${CMAKE_CURRENT_BINARY_DIR}) #set(CMAKE_SKIP_BUILD_RPATH FALSE) #set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) #set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib) #set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) option(XDMF_BUILD_DSM OFF) if(XDMF_BUILD_DSM) option(XDMF_BUILD_DSM_THREADS ON) endif() mark_as_advanced(CLEAR Boost_INCLUDE_DIR) find_package(Boost REQUIRED) if(Boost_FOUND) include_directories(${Boost_INCLUDE_DIRS}) mark_as_advanced(FORCE Boost_INCLUDE_DIR) endif() # Find HDF5_ROOT if not set if ("$ENV{HDF5_ROOT}" STREQUAL "") find_file (HDF5_LIB libhdf5.so HINTS ENV LD_LIBRARY_PATH) if (NOT "${HDF5_LIB}" STREQUAL "") get_filename_component(HDF5_LIBRARY_DIR "${HDF5_LIB}" PATH) get_filename_component(HDF5_ROOT "${HDF5_LIBRARY_DIR}/../" ABSOLUTE) set(ENV{HDF5_ROOT} ${HDF5_ROOT}) endif () endif () mark_as_advanced(CLEAR HDF5_C_INCLUDE_DIR) mark_as_advanced(CLEAR HDF5_hdf5_LIBRARY_DEBUG) mark_as_advanced(CLEAR HDF5_hdf5_LIBRARY_RELEASE) find_package(HDF5 REQUIRED) if(HDF5_FOUND) mark_as_advanced(FORCE HDF5_C_INCLUDE_DIR) mark_as_advanced(FORCE HDF5_hdf5_LIBRARY_DEBUG) mark_as_advanced(FORCE HDF5_hdf5_LIBRARY_RELEASE) include_directories(${HDF5_INCLUDE_DIRS}) include_directories(${HDF5_C_INCLUDE_DIR}) get_filename_component(HDF5_LIBRARY_DIR "${HDF5_hdf5_LIBRARY_RELEASE}" PATH) set(XDMF_LIBRARY_DIRS ${XDMF_LIBRARY_DIRS} ${HDF5_LIBRARY_DIR}) set(HDF5_LIBRARIES ${HDF5_hdf5_LIBRARY_RELEASE}) # FIXME: Would like to get this info from HDF5 so we don't have conflicting # MPI versions if(HDF5_IS_PARALLEL) if (NOT MPI_FOUND) find_package(MPI REQUIRED) if(MPI_FOUND) include_directories(${MPI_INCLUDE_PATH}) set(XDMF_LIBRARIES ${XDMF_LIBRARIES} ${MPI_LIBRARY} ${MPI_EXTRA_LIBRARY}) get_filename_component(MPI_LIBRARY_DIR ${MPI_LIBRARY} PATH) set(XDMF_LIBRARY_DIRS ${XDMF_LIBRARY_DIRS} ${MPI_LIBRARY_DIR}) endif() endif () endif() get_filename_component(HDF5_ROOT "${HDF5_INCLUDE_DIR}/../" REALPATH) set(HDF5_BINARY_DIRS ${HDF5_ROOT}/bin ${HDF5_ROOT}/dll) if (NOT HDF5_LIBRARIES) find_library (HDF5_LIBRARIES hdf5 HINTS ${HDF5_ROOT} ENV LD_LIBRARY_PATH) endif () set(XDMF_LIBRARIES ${XDMF_LIBRARIES} ${HDF5_LIBRARIES}) set(XDMF_HDF5_BINARY_DIRS ${HDF5_BINARY_DIRS} PARENT_SCOPE) set(XDMF_BINARIES ${XDMF_BINARIES} ${HDF5_BINARY_DIRS}) endif() find_package(LibXml2 REQUIRED) if(LIBXML2_FOUND) include_directories(${LIBXML2_INCLUDE_DIR}) get_filename_component(LIBXML2_ROOT "${LIBXML2_INCLUDE_DIR}/../" REALPATH) set(LIBXML2_BINARY_DIRS ${LIBXML2_ROOT}/bin) set(LIBXML2_BINARY_DIRS ${LIBXML2_BINARY_DIRS} PARENT_SCOPE) set(XDMF_LIBRARIES ${XDMF_LIBRARIES} ${LIBXML2_LIBRARIES}) set(XDMF_BINARIES ${XDMF_BINARIES} ${LIBXML2_BINARY_DIRS}) endif() # Perform compile-time checks and generate XdmfCoreConfig.hpp TEST_BIG_ENDIAN(XDMF_BIG_ENDIAN) unset(HAVE_BOOST_SHARED_DYNAMIC_CAST CACHE) set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${Boost_INCLUDE_DIRS}) check_cxx_source_compiles(" #include struct Base { virtual ~Base(){} }; struct Derived : public Base {}; int main(int ac, char * av[]) { boost::shared_ptr ptr(new Base()); boost::shared_dynamic_cast(ptr); } " HAVE_BOOST_SHARED_DYNAMIC_CAST) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/XdmfCoreConfig.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/XdmfCoreConfig.hpp) set(XdmfCoreSources XdmfArray XdmfArrayReference XdmfArrayType XdmfBinaryController XdmfCoreItemFactory XdmfCoreReader XdmfError XdmfFunction XdmfHDF5Controller XdmfHDF5Writer XdmfHeavyDataController XdmfHeavyDataDescription XdmfHeavyDataWriter XdmfInformation XdmfItem XdmfItemProperty XdmfPlaceholder XdmfSparseMatrix XdmfSubset XdmfSystemUtils ${CMAKE_CURRENT_BINARY_DIR}/XdmfVersion XdmfVisitor XdmfWriter) if (TIFF_FOUND) set(XdmfCoreSources ${XdmfCoreSources} XdmfTIFFController) endif() if (XDMF_STATIC_AND_SHARED) add_library(XdmfCoreObjects OBJECT ${XdmfCoreSources}) set_target_properties(XdmfCoreObjects PROPERTIES POSITION_INDEPENDENT_CODE True) add_library(XdmfCore ${LIBTYPE} $) if (BUILD_SHARED_LIBS) add_library(XdmfCore_Static STATIC $) set_target_properties(XdmfCore_Static PROPERTIES OUTPUT_NAME "XdmfCore") endif (BUILD_SHARED_LIBS) else() add_library(XdmfCore ${LIBTYPE} ${XdmfCoreSources}) endif() link_directories(${XDMF_LIBRARY_DIRS}) target_link_libraries(XdmfCore ${XDMF_LIBRARIES}) if (XDMF_STATIC_AND_SHARED AND BUILD_SHARED_LIBS) target_link_libraries(XdmfCore_Static ${XDMF_LIBRARIES}) endif() if (COMMAND vtk_target_install) vtk_target_install(XdmfCore) endif() if(WIN32) add_definitions(-D_HDF5USEDLL_ -D_HDF5USEHLDLL_) if (BUILD_SHARED_LIBS) set_target_properties(XdmfCore PROPERTIES DEFINE_SYMBOL XdmfCore_EXPORTS) if (XDMF_STATIC_AND_SHARED) set_target_properties(XdmfCore_Static PROPERTIES DEFINE_SYMBOL XdmfCore_EXPORTS) endif() endif() if(NOT MSVC10) set_target_properties(XdmfCore PROPERTIES PREFIX ../ IMPORT_PREFIX ../ RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) if (XDMF_STATIC_AND_SHARED AND BUILD_SHARED_LIBS) set_target_properties(XdmfCore_Static PROPERTIES PREFIX ../ IMPORT_PREFIX ../ RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) endif () endif() endif() if(XDMF_WRAP_JAVA) XDMF_SWIG_JAVA(XdmfCore) endif() if(XDMF_WRAP_PYTHON) if (NOT BUILD_SHARED_LIBS) message(FATAL_ERROR "Python Wrappers do not function" " properly without shared libraries") endif (NOT BUILD_SHARED_LIBS) XDMF_SWIG_PYTHON(XdmfCore) endif() set(XDMF_LIBRARY_DIRS ${XDMF_LIBRARY_DIRS} PARENT_SCOPE) if(WIN32) set(XDMFCORE_LIBRARY ${CMAKE_INSTALL_PREFIX}/lib/XdmfCore.lib PARENT_SCOPE) endif() if(UNIX) if (BUILD_SHARED_LIBS) set(XDMFCORE_LIBRARY ${CMAKE_INSTALL_PREFIX}/lib/libXdmfCore.so PARENT_SCOPE) else() set(XDMFCORE_LIBRARY ${CMAKE_INSTALL_PREFIX}/lib/libXdmfCore.a PARENT_SCOPE) endif() endif() if(APPLE) set(XDMFCORE_LIBRARY ${CMAKE_INSTALL_PREFIX}/lib/libXdmfCore.dylib PARENT_SCOPE) endif() file(GLOB_RECURSE XdmfCoreHeaders "*.hpp" "*.tpp" "*.i" "../CMake/VersionSuite/*.hpp") file(GLOB LokiHeaders loki/*.h) set(XdmfCoreHeaders ${XdmfCoreHeaders} ${CMAKE_CURRENT_BINARY_DIR}/XdmfCoreConfig.hpp) install(FILES ${XdmfCoreHeaders} DESTINATION include) install(FILES ${LokiHeaders} DESTINATION include/loki) install(TARGETS XdmfCore RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) if (XDMF_STATIC_AND_SHARED AND BUILD_SHARED_LIBS) install(TARGETS XdmfCore_Static RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) endif () set(XdmfCore_INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${HDF5_INCLUDE_DIR} ${LIBXML2_INCLUDE_DIR} ${PYTHON_INCLUDE_DIRS} CACHE INTERNAL "") set(XDMF_INCLUDE_DIRS ${CMAKE_INSTALL_PREFIX}/include PARENT_SCOPE) set(XDMF_LIBRARIES ${XDMF_LIBRARIES} ${CMAKE_INSTALL_PREFIX}/lib) set(XDMF_DIR ${CMAKE_INSTALL_PREFIX} PARENT_SCOPE) set(XDMF_BINARIES ${XDMF_BINARIES} ${CMAKE_INSTALL_PREFIX}/bin) if(XDMF_BUILD_DSM) add_subdirectory(dsm) set(XDMF_DSM_IS_CRAY "${XDMF_DSM_IS_CRAY}" PARENT_SCOPE) endif(XDMF_BUILD_DSM) if(XDMF_BUILD_TESTING) add_subdirectory(tests) endif() set(XDMF_LIBRARIES ${XDMF_LIBRARIES} PARENT_SCOPE) set(XDMF_BINARIES ${XDMF_BINARIES} PARENT_SCOPE) xdmf-3.0+git20160803/core/XdmfFunction.hpp0000640000175000017500000012076513003006557020152 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfFunction.hpp */ /* */ /* Author: */ /* Andrew Burns */ /* andrew.j.burns2@us.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2013 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef XDMFFUNCTION_HPP_ #define XDMFFUNCTION_HPP_ // C Compatible Includes #include "XdmfCore.hpp" #include "XdmfArray.hpp" #include "XdmfArrayReference.hpp" #ifdef __cplusplus class XdmfArray; /** * @brief Manipulates arrays based on expressions. * * The function class provides a way to manipulate XdmfArrays via predefined functions. */ class XDMFCORE_EXPORT XdmfFunction : public XdmfArrayReference { public: /** * Function wrapper to allow for more flexibility when wrapping * functions to be used in the dynamic library. * * Not required to use the dynamic library because there are * methods that take function pointers. */ class XdmfFunctionInternal { public: virtual ~XdmfFunctionInternal() { } virtual shared_ptr execute(std::vector > valueVector) = 0; }; /** * Binary Operator wrapper to allow for more flexibility when wrapping * operations to be used in the dynamic library. * * Not required to use the dynamic library because there are * methods that take function pointers. */ class XdmfOperationInternal { public: virtual ~XdmfOperationInternal() { } virtual shared_ptr execute(shared_ptr val1, shared_ptr val2) = 0; }; /** * Create a new XdmfFunction * * Example of use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#initialization * @until //#initialization * * Python * * @dontinclude XdmfExampleFunction.py * @skipline #//initialization * @until #//initialization * * @return Constructed XdmfFunction. */ static shared_ptr New(); /** * Create a new XdmfFunction * * Example of use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#initexpression * @until //#initexpression * * Python * * @dontinclude XdmfExampleFunction.py * @skipline #//initexpression * @until #//initexpression * * @param newExpression The expression that the function will evaluate * @param newVariables The arrays that the function will use * to evalute the expression * @return Constructed XdmfFunction. */ static shared_ptr New(std::string newExpression, std::map > newVariables); virtual ~XdmfFunction(); LOKI_DEFINE_VISITABLE(XdmfFunction, XdmfItem) static const std::string ItemTag; /** * Takes the first array provided and returns an array containing * the absolute value equivalent of that array. * * Example of Use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#abs * @until //#abs * * Python * * @dontinclude XdmfExampleFunction.py * @skipline #//abs * @until #//abs * * @param values A vector containing the array to be used * @return An XdmfArray containing the absolute value * equivalent of the first array */ static shared_ptr abs(std::vector > values); /* * Adds a specified function to the list of functions used while * evaluating strings * * Example of Use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#declarefunction * @until //#declarefunction * @skipline //#programstart * @until //#programstart * @skipline //#addFunction * @until //#addFunction * @skipline //#programend * @until //#programend * @skipline //#definefunction * @until //#definefunction * * Python * * @dontinclude XdmfExampleFunction.py * @skipline #//definefunction * @until #//definefunction * @skipline #//programstart * @until #//programstart * @skipline #//addFunction * @until #//addFunction * * @param name A string to be associated with the provided * function during string evaluation * @param functionref A pointer to the function to be associated * with the given string * @return The total number of functions currently usable */ static int addFunction(std::string name, shared_ptr(*functionref)(std::vector >)); /** * Adds a specified function to the list of functions used while * evaluating strings. * This version allows for custom wrapping. * * Example of use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#declarefunctionclass * @until //#declarefunctionclass * @skipline //#programstart * @until //#programstart * @skipline //#addFunctionclass * @until //#addFunctionclass * @skipline //#programend * @until //#programend * * Python: This version of addFunction is not supported in Python * * @param name A string to be associated with the provided * function during string evaluation * @param newFunction A shared pointer to the function to be * associated with the given string * @return The total number of functions currently usable */ static int addFunction(std::string name, shared_ptr newFunction); /** * Adds an operation to the list of viable binary operators. * * Example of Use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#declareoperation * @until //#declareoperation * @skipline //#programstart * @until //#programstart * @skipline //#addOperation * @until //#addOperation * @skipline //#programend * @until //#programend * @skipline //#defineoperation * @until //#defineoperation * * Python * * @dontinclude XdmfExampleFunction.py * @skipline #//defineoperation * @until #//defineoperation * @skipline #//programstart * @until #//programstart * @skipline #//addOperation * @until #//addOperation * * @param newoperator The character to be associated with the provided * binary operation * @param functionref A pointer to the function to be associated with * the provided operator * @param priority Used to determine order of operations, * the higher the value the earlier it is evaluated * @return The number of viable operations */ static int addOperation(char newoperator, shared_ptr(*functionref)(shared_ptr, shared_ptr), int priority); /** * Adds an operation to the list of viable binary operators. * This version allows for custom wrapping. * * Example of use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#declareoperationclass * @until //#declareoperationclass * @skipline //#programstart * @until //#programstart * @skipline //#addOperationclass * @until //#addOperationclass * @skipline //#programend * @until //#programend * * Python: This version of addOperation is not supported in Python * * @param newoperator The character to be associated with the provided * binary operation * @param newOperation A pointer to the function to be associated * with the provided operator * @param priority Used to determine order of operations, * the higher the value the earlier it is evaluated * @return The number of viable operations */ static int addOperation(char newoperator, shared_ptr newOperation, int priority); /** * Takes the arrays provided adds them together, returning the result. * * If the first array has one value an array is generated adding * it to each value of the second array. * * If the second array has one value. That value is added to * all values in the first array. * * If both arrays have the same number of values, the * value of the first array is added to the value of the second array * with the same index. * * An error is thrown if the array sizes are both large than 1 * and do not match. * * Example of Use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#addition * @until //#addition * * Python * * @dontinclude XdmfExampleFunction.py * @skipline #//addition * @until #//addition * * @param val1 The first Array to be used * @param val2 The second Array to be used * @return An XdmfArray containing the sums * of the values of the arrays */ static shared_ptr addition(shared_ptr val1, shared_ptr val2); /** * Takes the first array provided and returns an array containing * the arcsin of all the values in that array. * * Example of Use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#arcsin * @until //#arcsin * * Python * * @dontinclude XdmfExampleFunction.py * @skipline #//arcsin * @until #//arcsin * * @param values A vector containing the array to be used * @return An XdmfArray containing the arcsin of the * values of the first array */ static shared_ptr arcsin(std::vector > values); /** * Takes the first array provided and returns an array containing * the arccos of all the values in that array. * * Example of Use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#arccos * @until //#arccos * * Python * * @dontinclude XdmfExampleFunction.py * @skipline #//arccos * @until #//arccos * * @param values A vector containing the array to be used * @return An XdmfArray containing the arccos of the * values of the first array */ static shared_ptr arccos(std::vector > values); /** * Takes the first array provided and returns an array containing * the arctan of all the values in that array. * * Example of Use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#arctan * @until //#arctan * * Python * * @dontinclude XdmfExampleFunction.py * @skipline #//arctan * @until #//arctan * * @param values A vector containing the array to be used * @return An XdmfArray containing the arctan of the * values of the first array */ static shared_ptr arctan(std::vector > values); /** * Averages the values contained in all the provided arrays. * * Example of Use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#valueinit * @until //#valueinit * @skipline //#average * @until //#average * * Python * * @dontinclude XdmfExampleFunction.py * @skipline #//valueinit * @until #//valueinit * @skipline #//average * @until #//average * * @param values A vector containing the arrays to be used * @return An XdmfArray containing one value which is the average * of all values contained within the provided arrays */ static shared_ptr average(std::vector > values); /** * Joins the two provided arrays together end to end. * * Example of Use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#valueinit * @until //#valueinit * @skipline //#chunk * @until //#chunk * * Python * * @dontinclude XdmfExampleFunction.py * @skipline #//valueinit * @until #//valueinit * @skipline #//chunk * @until #//chunk * * @param val1 The first array being evaluated * @param val2 The second array being evaluated * @return The arrays joined end to end */ static shared_ptr chunk(shared_ptr val1, shared_ptr val2); /** * Takes the first array provided and returns an array containing * the cos of all the values in that array. * * Example of Use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#cos * @until //#cos * * Python * * @dontinclude XdmfExampleFunction.py * @skipline #//cos * @until #//cos * * @param values A vector containing the array to be used * @return An XdmfArray containing the cos of the * values of the first array */ static shared_ptr cos(std::vector > values); /** * Takes the arrays provided and divides the first one by the second, * returning the result. * * If the first array has one value an array is generated * by dividing it by each value of the second array. * * If the second array has one value. Each value in the * first array is divided by that value. * * If both arrays have the same number of values, each value of * the first array is divided by the value of the second array * with the same index. * * An error is thrown if the array sizes are both large than 1 * and do not match. * * Example of Use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#division * @until //#division * * Python * * @dontinclude XdmfExampleFunction.py * @skipline #//division * @until #//division * * @param val1 The array to be divided * @param val2 The array to be divided by * @return An XdmfArray containing the results * of the division of the arrays */ static shared_ptr division(shared_ptr val1, shared_ptr val2); /** * Takes the first array provided and returns an array containing * the values in that array taken to a power relative to the second array. * * If the first array has one value an array is generated by raising that * value to the power of each of the values in the second array * * If the second array has one value. That power is applied to each * value of the first array * * If both arrays have the same number of values, each value of the * first array is raised to the power of the value of the * corresponding index of the second array. * * An error is thrown if the array sizes are both large than 1 * and do not match. * * Example of Use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#exp * @until //#exp * * Python * * @dontinclude XdmfExampleFunction.py * @skipline #//exp * @until #//exp * * @param values A vector containing the array to be used * @return An XdmfArray containing the powers * of the values of the first array */ static shared_ptr exponent(std::vector > values); /** * Evaluates an expression based on the list of variables provided. * A list of valid operations is retrievable from the getSupportedOperations * static method. * None of the XdmfArrays provided are modified during the evaluation process. * * Example of Use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#declarefunction * @until //#declarefunction * @skipline //#declareoperation * @until //#declareoperation * @skipline //#programstart * @until //#programstart * @skipline //#valueinit * @until //#valueinit * @skipline //#addOperation * @until //#addOperation * @skipline //#addFunction * @until //#addFunction * @skipline //#evaluateExpression * @until //#evaluateExpression * @skipline //#programend * @until //#programend * @skipline //#definefunction * @until //#definefunction * @skipline //#defineoperation * @until //#defineoperation * * Python * * @dontinclude XdmfExampleFunction.py * @skipline #//definefunction * @until #//definefunction * @skipline #//defineoperation * @until #//defineoperation * @skipline #//programstart * @until #//programstart * @skipline #//valueinit * @until #//valueinit * @skipline #//addOperation * @until #//addOperation * @skipline #//addFunction * @until #//addFunction * @skipline #//evaluateExpression * @until #//evaluateExpression * * @param expression A string containing the expresion to be evaluated * @param variables A map of strings to their XdmfArray equivalent * @return A shared pointer to the XdmfArray resulting * from the expression */ static shared_ptr evaluateExpression(std::string expression, std::map > variables); /** * Evaluates the operation specified using the two shared pointers to * XdmfArrays provided. * A list of valid operations is retrievable from the getSupportedOperations * static method. * None of the XdmfArrays provided are modified during the evaluation process. * * Example of Use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#declareoperation * @until //#declareoperation * @skipline //#programstart * @until //#programstart * @skipline //#valueinit * @until //#valueinit * @skipline //#addOperation * @until //#addOperation * @skipline //#evaluateOperation * @until //#evaluateOperation * @skipline //#programend * @until //#programend * @skipline //#defineoperation * @until //#defineoperation * * Python * * @dontinclude XdmfExampleFunction.py * @skipline #//defineoperation * @until #//defineoperation * @skipline #//programstart * @until #//programstart * @skipline #//valueinit * @until #//valueinit * @skipline #//addOperation * @until #//addOperation * @skipline #//evaluateOperation * @until #//evaluateOperation * * @param val1 The first array being evaluated * @param val2 The second array being evaluated * @param operation A character specifying the operation performed * @return A shared pointer to the Xdmf Array that results * from the calculation */ static shared_ptr evaluateOperation(shared_ptr val1, shared_ptr val2, char operation); /** * Evaluates the function specified using the vector of XdmfArrays provided. * None of the XdmfArrays provided are modified during the evaluation process. * * Example of Use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#declarefunction * @until //#declarefunction * @skipline //#programstart * @until //#programstart * @skipline //#valueinit * @until //#valueinit * @skipline //#addFunction * @until //#addFunction * @skipline //#evaluateFunction * @until //#evaluateFunction * @skipline //#programend * @until //#programend * @skipline //#definefunction * @until //#definefunction * * Python * * @dontinclude XdmfExampleFunction.py * @skipline #//definefunction * @until #//definefunction * @skipline #//programstart * @until #//programstart * @skipline #//valueinit * @until #//valueinit * @skipline #//addFunction * @until #//addFunction * @skipline #//evaluateFunction * @until #//evaluateFunction * * @param valueVector A vector containing the arrays to be used * @param functionName The string associated with the function being called * @return The result of the function being called, * a scalar will be returned as an XdmfArray with one value */ static shared_ptr evaluateFunction(std::vector > valueVector, std::string functionName); /** * Sets the expression that the function will evaluate. * * Example of use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#initexpression * @until //#initexpression * @skipline //#setExpression * @until //#setExpression * * Python * * @dontinclude XdmfExampleFunction.py * @skipline #//initexpression * @until #//initexpression * @skipline #//setExpression * @until #//setExpression * * @return The expression that the function is currently using to evaluate */ std::string getExpression() const; std::map getItemProperties() const; virtual std::string getItemTag() const; /** * Gets the priority of operation whose associated character is provided. * Returns -1 if the operation is not supported. * The higher the value the earlier that operation is evaluated * during evaluateExpression. * * Example of Use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#getOperationPriority * @until //#getOperationPriority * * Python * * @dontinclude XdmfExampleFunction.py * @skipline #//getOperationPriority * @until #//getOperationPriority * * @param operation The character associated with the operation * to be checked * @return The priority of the operation */ static int getOperationPriority(char operation); /** * Gets a string that contains all the characters of the supported operations. * Parenthesis are included for grouping purposes in expressions. * * Example of Use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#getSupportedOperations * @until //#getSupportedOperations * * Python * * @dontinclude XdmfExampleFunction.py * @skipline #//getSupportedOperations * @until #//getSupportedOperations * * @return A string containing the characters for all supported operations */ static const std::string getSupportedOperations(); /** * Gets a string that contains all the characters of the supported operations. * Parenthesis are included for grouping purposes in expressions. * * Example of Use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#getSupportedFunctions * @until //#getSupportedFunctions * * Python * * @dontinclude XdmfExampleFunction.py * @skipline #//getSupportedFunctions * @until #//getSupportedFunctions * * @return A vector containing the strings associated with all valid functions */ static const std::vector getSupportedFunctions(); /** * Gets a string that contains all strings that are viable for use when mapping * to scalars (which are stored in XdmfArrays of size 1) for the * evaluateExpression function. * * Example of Use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#getValidDigitChars * @until //#getValidDigitChars * * Python * * @dontinclude XdmfExampleFunction.py * @skipline #//getValidDigitChars * @until #//getValidDigitChars * * @return A string containing all valid variable characters */ static const std::string getValidDigitChars(); /** * Gets a string that contains all strings that are viable for use when mapping * to shared pointers of XdmfArrays for the evaluateExpression function. * * Example of Use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#getValidVariableChars * @until //#getValidVariableChars * * Python * * @dontinclude XdmfExampleFunction.py * @skipline #//getValidVariableChars * @until #//getValidVariableChars * * @return A string containing all valid variable characters */ static const std::string getValidVariableChars(); /** * Gets the array associated with the provided string out of the function's * variable list. * * Example of use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#initexpression * @until //#initexpression * @skipline //#insertVariable * @until //#insertVariable * @skipline //#getVariable * @until //#getVariable * * Python * * @dontinclude XdmfExampleFunction.py * @skipline #//initexpression * @until #//initexpression * @skipline #//insertVariable * @until #//insertVariable * @skipline #//getVariable * @until #//getVariable * * @param key The string that is associated with the array to be retrieved * @return The array that corresponds with the key provided. */ shared_ptr getVariable(std::string key); /** * Gets a vector containing all the keys accociated with arrays for this function. * * Example of use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#initexpression * @until //#initexpression * @skipline //#insertVariable * @until //#insertVariable * @skipline //#getVariableList * @until //#getVariableList * * Python * * @dontinclude XdmfExampleFunction.py * @skipline #//initexpression * @until #//initexpression * @skipline #//insertVariable * @until #//insertVariable * @skipline #//getVariableList * @until #//getVariableList * * @return A vector of all the keys for this function */ std::vector getVariableList(); /** * Joins the two provided arrays while interspercing their values evenly. * * Example of Use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#valueinit * @until //#valueinit * @skipline //#interlace * @until //#interlace * * Python * * @dontinclude XdmfExampleFunction.py * @skipline #//valueinit * @until #//valueinit * @skipline #//interlace * @until #//interlace * * @param val1 The first array being evaluated * @param val2 The second array being evaluated * @return The interlaced arrays */ static shared_ptr interlace(shared_ptr val1, shared_ptr val2); /** * Adds a new variable to the list of variables that the Function will use. * * Example of use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#initexpression * @until //#initexpression * @skipline //#insertVariable * @until //#insertVariable * * Python * * @dontinclude XdmfExampleFunction.py * @skipline #//initexpression * @until #//initexpression * @skipline #//insertVariable * @until #//insertVariable * * @param key The string to be associated with the provided array * @param value The value of the variable when evaluated */ void insertVariable(std::string key, shared_ptr value); /** * Concatenates all provided arrays in order provided. * * Example of Use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#join * @until //#join * * Python * * @dontinclude XdmfExampleFunction.py * @skipline #//join * @until #//join * * @param values A vector containing the array to be used * @return An XdmfArray containing the combined values */ static shared_ptr join(std::vector > values); /** * Takes the first array provided and returns an array containing * the log of all the values in that array. If a second array is provided * it specifies the base for the log used. Default is natural log. * * If the first array has one value an array is generated using a log * whose base is specified in the second array. * * If the second array has one value. A log of that base is applied to * all values of the first array. * * If both arrays have the same number of values, the * log of the base specified by the value of the same index * in the second array is used. * * An error is thrown if the array sizes are both large than 1 * and do not match. * * Example of Use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#log * @until //#log * * Python * * @dontinclude XdmfExampleFunction.py * @skipline #//log * @until #//log * * @param values A vector containing the array to be used * @return An XdmfArray containing the log * of the values of the first array */ static shared_ptr log(std::vector > values); /** * Takes the arrays provided and multiplies the first one by the second, * returning the result. * * If the first array has one value an array is generated * by multiplying it by each value of the second array. * * If the second array has one value. Each value in the * first array is multiplied by that value. * * If both arrays have the same number of values, each value of * the first array is multiplied by the value of the second array * with the same index. * * An error is thrown if the array sizes are both large than 1 * and do not match. * * Example of Use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#multiplication * @until //#multiplication * * Python * * @dontinclude XdmfExampleFunction.py * @skipline #//multiplication * @until #//multiplication * * @param val1 The first array to be used * @param val2 The second array to be used * @return An XdmfArray containing the products * of the multiplication of the arrays */ static shared_ptr multiplication(shared_ptr val1, shared_ptr val2); /** * Parses the expression that the function contains and generates an array * containing the values that the function produces. * * Example of use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#initexpression * @until //#initexpression * @skipline //#read * @until //#read * * Python * * @dontinclude XdmfExampleFunction.py * @skipline #//initexpression * @until #//initexpression * @skipline #//read * @until #//read */ virtual shared_ptr read() const; /** * Removes a variable from the function if it exists. * * Example of use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#initexpression * @until //#initexpression * @skipline //#insertVariable * @until //#insertVariable * @skipline //#removeVariable * @until //#removeVariable * * Python * * @dontinclude XdmfExampleFunction.py * @skipline #//initexpression * @until #//initexpression * @skipline #//insertVariable * @until #//insertVariable * @skipline #//removeVariable * @until #//removeVariable * * @param key The string to be associated with the provided array */ void removeVariable(std::string key); /** * Sets the expression that the function will evaluate. * * Example of use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#initexpression * @until //#initexpression * @skipline //#setExpression * @until //#setExpression * * Python * * @dontinclude XdmfExampleFunction.py * @skipline #//initexpression * @until #//initexpression * @skipline #//setExpression * @until #//setExpression * * @param newExpression The expression that the function is to evaluate */ void setExpression(std::string newExpression); /** * Takes the first array provided and returns an array containing * the sin of all the values in that array. * * Example of Use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#sin * @until //#sin * * Python * * @dontinclude XdmfExampleFunction.py * @skipline #//sin * @until #//sin * * @param values A vector containing the array to be used * @return An XdmfArray containing the sin of the * values of the first array */ static shared_ptr sin(std::vector > values); /** * Takes the first array provided and returns an array containing * the square root of all the values in that array. * * Example of Use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#sqrt * @until //#sqrt * * Python * * @dontinclude XdmfExampleFunction.py * @skipline #//sqrt * @until #//sqrt * * @param values A vector containing the array to be used * @return An XdmfArray containing the square root * of the values of the first array */ static shared_ptr sqrt(std::vector > values); /** * Takes the arrays provided and subtracts the second from the first, * returning the result. * * If the first array has one value an array is generated * by subtracting each value of the second array. * * If the second array has one value. That value is * subtracted from each value of the first array. * * If both arrays have the same number of values, each value of * the second array is subtracted from the value of the first array * with the same index. * * An error is thrown if the array sizes are both large than 1 * and do not match. * * Example of Use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#subtraction * @until //#subtraction * * Python * * @dontinclude XdmfExampleFunction.py * @skipline #//subtraction * @until #//subtraction * * @param val1 The array to be subtracted from * @param val2 The array to be subtracted * @return An XdmfArray containing the difference * of the arrays */ static shared_ptr subtraction(shared_ptr val1, shared_ptr val2); /** * Adds together all the values contained in the provided arrays. * * Example of Use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#valueinit * @until //#valueinit * @skipline //#sum * @until //#sum * * Python * * @dontinclude XdmfExampleFunction.py * @skipline #//valueinit * @until #//valueinit * @skipline #//sum * @until #//sum * * @param values A vector containing the arrays to be used * @return An XdmfArray containing one value which is the total * of all the values contained within the provided arrays */ static shared_ptr sum(std::vector > values); /** * Takes the first array provided and returns an array containing * the tan of all the values in that array. * * Example of Use: * * C++ * * @dontinclude ExampleXdmfFunction.cpp * @skipline //#tan * @until //#tan * * Python * * @dontinclude XdmfExampleFunction.py * @skipline #//tan * @until #//tan * * @param values A vector containing the array to be used * @return An XdmfArray containing the tan of the * values of the first array */ static shared_ptr tan(std::vector > values); void traverse(const shared_ptr visitor); XdmfFunction(XdmfFunction &); protected: XdmfFunction(); XdmfFunction(std::string newExpression, std::map > newVariables); private: XdmfFunction(const XdmfFunction &); // Not implemented. void operator=(const XdmfFunction &); // Not implemented. std::map > mVariableList; std::string mExpression; static std::string mSupportedOperations; static const std::string mValidVariableChars; static const std::string mValidDigitChars; static std::map mOperationPriority; static std::map > arrayFunctions; static std::map > operations; }; #endif #ifdef __cplusplus extern "C" { #endif struct XDMFFUNCTION; // Simply as a typedef to ensure correct typing typedef struct XDMFFUNCTION XDMFFUNCTION; XDMFCORE_EXPORT XDMFFUNCTION * XdmfFunctionNew(); XDMFCORE_EXPORT XDMFFUNCTION * XdmfFunctionNewInit(char * newExpression, char ** keys, XDMFARRAY ** values, int numVariables); XDMFCORE_EXPORT int XdmfFunctionAddFunction(char * name, XDMFARRAY *(*functionref)(XDMFARRAY **, unsigned int), int * status); XDMFCORE_EXPORT int XdmfFunctionAddOperation(char newoperator, XDMFARRAY *(*operationref)(XDMFARRAY *, XDMFARRAY *), int priority, int * status); XDMFCORE_EXPORT XDMFARRAY * XdmfFunctionAverage(XDMFARRAY ** values, int numValues); XDMFCORE_EXPORT XDMFARRAY * XdmfFunctionChunk(XDMFARRAY * val1, XDMFARRAY * val2, int * status); XDMFCORE_EXPORT XDMFARRAY * XdmfFunctionEvaluateExpression(char * expression, char ** keys, XDMFARRAY ** values, int numVariables, int * status); XDMFCORE_EXPORT XDMFARRAY * XdmfFunctionEvaluateOperation(XDMFARRAY * val1, XDMFARRAY * val2, char operation, int * status); XDMFCORE_EXPORT XDMFARRAY * XdmfFunctionEvaluateFunction(XDMFARRAY ** valueVector, int numValues, char * functionName, int * status); XDMFCORE_EXPORT char * XdmfFunctionGetExpression(XDMFFUNCTION * function); XDMFCORE_EXPORT unsigned int XdmfFunctionGetNumberVariables(XDMFFUNCTION * function); XDMFCORE_EXPORT int XdmfFunctionGetOperationPriority(char operation); XDMFCORE_EXPORT char * XdmfFunctionGetSupportedOperations(); XDMFCORE_EXPORT char ** XdmfFunctionGetSupportedFunctions(); XDMFCORE_EXPORT unsigned int XdmfFunctionGetNumberSupportedFunctions(); XDMFCORE_EXPORT char * XdmfFunctionGetValidDigitChars(); XDMFCORE_EXPORT char * XdmfFunctionGetValidVariableChars(); XDMFCORE_EXPORT XDMFARRAY * XdmfFunctionGetVariable(XDMFFUNCTION * function, char * key); XDMFCORE_EXPORT char ** XdmfFunctionGetVariableList(XDMFFUNCTION * function); XDMFCORE_EXPORT XDMFARRAY * XdmfFunctionInterlace(XDMFARRAY * val1, XDMFARRAY * val2, int * status); XDMFCORE_EXPORT void XdmfFunctionInsertVariable(XDMFFUNCTION * function, char * key, XDMFARRAY * value, int passControl); XDMFCORE_EXPORT void XdmfFunctionRemoveVariable(XDMFFUNCTION * function, char * key); XDMFCORE_EXPORT void XdmfFunctionSetExpression(XDMFFUNCTION * function, char * newExpression, int * status); XDMFCORE_EXPORT XDMFARRAY * XdmfFunctionSum(XDMFARRAY ** values, int numValues); // C Wrappers for parent classes are generated by macros XDMF_ITEM_C_CHILD_DECLARE(XdmfFunction, XDMFFUNCTION, XDMFCORE) XDMF_ARRAYREFERENCE_C_CHILD_DECLARE(XdmfFunction, XDMFFUNCTION, XDMFCORE) #ifdef __cplusplus } #endif #endif /* XDMFFUNCTION_HPP_ */ xdmf-3.0+git20160803/core/XdmfCoreItemFactory.hpp0000640000175000017500000001114213003006557021410 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfCoreItemFactory.hpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef XDMFCOREITEMFACTORY_HPP_ #define XDMFCOREITEMFACTORY_HPP_ #ifdef __cplusplus // Forward Declarations class XdmfItem; // Includes #include #include #include "XdmfCore.hpp" #include "XdmfHeavyDataController.hpp" #include "XdmfHeavyDataWriter.hpp" #include "XdmfSharedPtr.hpp" /** * @brief Factory that constructs XdmfItems using tags and properties. * * XdmfCoreItemFactory is an abstract base class. */ class XDMFCORE_EXPORT XdmfCoreItemFactory { public: virtual ~XdmfCoreItemFactory() = 0; /** * Create a new XdmfItem. * * Example of use: * * @dontinclude ExampleXdmfCoreItemFactory.cpp * @skipline //#createItem * @until //#createItem * * Python * * @dontinclude XdmfExampleCoreItemFactory.py * @skipline #//createItem * @until #//createItem * * @param itemTag A string containing the tag of the XdmfItem to create. * @param itemProperties A map of key/value properties for the the XdmfItem. * @param childItems The children of the XdmfItem to create. * * @return Constructed XdmfItem. If no XdmfItem can be constructed, * return NULL. */ virtual shared_ptr createItem(const std::string & itemTag, const std::map & itemProperties, const std::vector > & childItems) const; virtual std::vector > generateHeavyDataControllers(const std::map & itemProperties, const std::vector & passedDimensions = std::vector(), shared_ptr passedArrayType = shared_ptr(), const std::string & passedFormat = std::string()) const; virtual shared_ptr generateHeavyDataWriter(std::string typeName, std::string path) const; virtual bool isArrayTag(char * tag) const; /** * Extracts the pointer from the provided shared pointer. Primarily used for C interface. * * @param original The source shared pointer that the pointer will be pulled from. * @return A duplicate of the object contained in the pointer. */ virtual XdmfItem * DuplicatePointer(shared_ptr original) const; protected: shared_ptr getArrayType(const std::map & itemProperties) const; std::string getFullHeavyDataPath(const std::string & filePath, const std::map & itemProperties) const; XdmfCoreItemFactory(); private: XdmfCoreItemFactory(const XdmfCoreItemFactory &); // Not implemented. void operator=(const XdmfCoreItemFactory &); // Not implemented. }; #endif #endif /* XDMFCOREITEMFACTORY_HPP_ */ xdmf-3.0+git20160803/core/XdmfConfig.hpp.in0000640000175000017500000000363613003006557020174 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfConfig.hpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef XDMFCONFIG_HPP_ #define XDMFCONFIG_HPP_ #cmakedefine HAVE_BOOST_SHARED_DYNAMIC_CAST #cmakedefine HAVE_CXX11_ENABLE_IF #cmakedefine XDMF_BIG_ENDIAN #endif /* XDMFSHAREDPTR_HPP_ */ xdmf-3.0+git20160803/core/XdmfArrayReference.cpp0000640000175000017500000001260513003006557021246 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfFunction.cpp */ /* */ /* Author: */ /* Andrew Burns */ /* andrew.j.burns2@us.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2013 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #include "XdmfArray.hpp" #include "XdmfArrayType.hpp" #include "XdmfArrayReference.hpp" #include #include #include #include "XdmfError.hpp" XdmfArrayReference::XdmfArrayReference(): mConstructedType("") { } XdmfArrayReference::XdmfArrayReference(XdmfArrayReference & refReference) : XdmfItem(refReference), mConstructedType(refReference.mConstructedType), mConstructedProperties(refReference.mConstructedProperties) { } XdmfArrayReference::~XdmfArrayReference() { } std::map XdmfArrayReference::getConstructedProperties() { return mConstructedProperties; } std::string XdmfArrayReference::getConstructedType() const { if (mConstructedType.c_str() != NULL) { return mConstructedType; } else { return ""; } } std::map XdmfArrayReference::getItemProperties() const { std::map referenceProperties; referenceProperties["ConstructedType"] = mConstructedType; for (std::map::const_iterator constructedIt = mConstructedProperties.begin(); constructedIt != mConstructedProperties.end(); ++constructedIt) { referenceProperties[constructedIt->first] = constructedIt->second; } // An array is missing a lot of data if not read first if (mConstructedType.compare(XdmfArray::ItemTag) == 0) { shared_ptr resultArray = this->read(); shared_ptr resultArrayType = resultArray->getArrayType(); std::map arrayTypeProperties; resultArrayType->getProperties(arrayTypeProperties); for (std::map::const_iterator arrayTypeIt = arrayTypeProperties.begin(); arrayTypeIt != arrayTypeProperties.end(); ++arrayTypeIt) { referenceProperties[arrayTypeIt->first] = arrayTypeIt->second; } referenceProperties["Format"] = "XML"; referenceProperties["Dimensions"] = resultArray->getDimensionsString(); } return referenceProperties; } void XdmfArrayReference::setConstructedProperties(std::map newProperties) { mConstructedProperties = newProperties; this->setIsChanged(true); } void XdmfArrayReference::setConstructedType(std::string newType) { mConstructedType = newType; this->setIsChanged(true); } // C Wrappers char * XdmfArrayReferenceGetConstructedType(XDMFARRAYREFERENCE * arrayReference) { try { char * returnPointer = strdup((*((XdmfArrayReference *)arrayReference)).getConstructedType().c_str()); return returnPointer; } catch (...) { char * returnPointer = strdup((*((XdmfArrayReference *)arrayReference)).getConstructedType().c_str()); return returnPointer; } } void * XdmfArrayReferenceRead(XDMFARRAYREFERENCE * arrayReference, int * status) { XDMF_ERROR_WRAP_START(status) try { shared_ptr returnItem = ((XdmfArrayReference *)arrayReference)->read(); return new XdmfArray(*returnItem.get()); } catch (...) { shared_ptr returnItem = ((XdmfArrayReference *)arrayReference)->read(); return new XdmfArray(*returnItem.get()); } XDMF_ERROR_WRAP_END(status) return NULL; } void XdmfArrayReferenceSetConstructedProperties(XDMFARRAYREFERENCE * arrayReference, void * referenceobject) { ((XdmfArrayReference *)arrayReference)->setConstructedProperties(((XdmfItem *)referenceobject)->getItemProperties()); } void XdmfArrayReferenceSetConstructedType(XDMFARRAYREFERENCE * arrayReference, char * newType) { ((XdmfArrayReference *)arrayReference)->setConstructedType(newType); } // C Wrappers for parent classes are generated by macros XDMF_ITEM_C_CHILD_WRAPPER(XdmfArrayReference, XDMFARRAYREFERENCE) xdmf-3.0+git20160803/core/XdmfItem.cpp0000640000175000017500000001143013003006557017242 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfItem.cpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #include "XdmfInformation.hpp" #include "XdmfItem.hpp" #include "XdmfVisitor.hpp" #include "XdmfError.hpp" #include "string.h" XDMF_CHILDREN_IMPLEMENTATION(XdmfItem, XdmfInformation, Information, Key) XdmfItem::XdmfItem() : mIsChanged(true) { } XdmfItem::XdmfItem(XdmfItem &refItem) : mInformations(refItem.mInformations), mIsChanged(true) { } XdmfItem::~XdmfItem() { } bool XdmfItem::getIsChanged() { return mIsChanged; } void XdmfItem::setIsChanged(bool status) { // No change if status is the same if (mIsChanged != status) { mIsChanged = status; // If it was changed all parents should be alerted if (status) { for (std::set::iterator iter = mParents.begin(); iter != mParents.end(); ++iter) { (*iter)->setIsChanged(status); } } } } void XdmfItem::populateItem(const std::map &, const std::vector > & childItems, const XdmfCoreReader * const) { for(std::vector >::const_iterator iter = childItems.begin(); iter != childItems.end(); ++iter) { if(shared_ptr information = shared_dynamic_cast(*iter)) { this->insert(information); } } } void XdmfItem::traverse(const shared_ptr visitor) { for (unsigned int i = 0; i < mInformations.size(); ++i) { mInformations[i]->accept(visitor); } } // C Wrappers void XdmfItemAccept(XDMFITEM * item, XDMFVISITOR * visitor, int * status) { XDMF_ERROR_WRAP_START(status) shared_ptr visitPointer((XdmfVisitor *)visitor, XdmfNullDeleter()); ((XdmfItem *)(item))->accept(visitPointer); XDMF_ERROR_WRAP_END(status) } void XdmfItemFree(void * item) { if (item != NULL) { delete ((XdmfItem *)item); item = NULL; } } XDMFINFORMATION * XdmfItemGetInformation(XDMFITEM * item, unsigned int index) { return (XDMFINFORMATION *)((void *)(((XdmfItem *)(item))->getInformation(index).get())); } XDMFINFORMATION * XdmfItemGetInformationByKey(XDMFITEM * item, char * key) { return (XDMFINFORMATION *)((void *)(((XdmfItem *)(item))->getInformation(key).get())); } unsigned int XdmfItemGetNumberInformations(XDMFITEM * item) { return ((XdmfItem *)(item))->getNumberInformations(); } void XdmfItemInsertInformation(XDMFITEM * item, XDMFINFORMATION * information, int passControl) { if (passControl == 0) { ((XdmfItem *)(item))->insert(shared_ptr((XdmfInformation *)information, XdmfNullDeleter())); } else { ((XdmfItem *)(item))->insert(shared_ptr((XdmfInformation *)information)); } } void XdmfItemRemoveInformation(XDMFITEM * item, unsigned int index) { ((XdmfItem *)(item))->removeInformation(index); } void XdmfItemRemoveInformationByKey(XDMFITEM * item, char * key) { ((XdmfItem *)(item))->removeInformation(std::string(key)); } char * XdmfItemGetItemTag(XDMFITEM * item) { char * returnPointer = strdup(((XdmfItem *)(item))->getItemTag().c_str()); return returnPointer; } xdmf-3.0+git20160803/core/XdmfItemProperty.hpp0000640000175000017500000000640513003006557021022 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfItemProperty.hpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef XDMFITEMPROPERTY_HPP_ #define XDMFITEMPROPERTY_HPP_ #ifdef __cplusplus // Includes #include #include #include "XdmfCore.hpp" #include "XdmfSharedPtr.hpp" /** * @brief A property attached to an XdmfItem. * * XdmfItems can have zero or more properties attached to them that * describe a specific characteristic of that item. For instance, * XdmfAttributes have both center and type properties. * * This is an abstract base class to facilitate reading and writing of * properties in a generic way. */ class XDMFCORE_EXPORT XdmfItemProperty { public: virtual ~XdmfItemProperty() = 0; /** * Retrieve the key/value pairs that this XdmfItemProperty contains by * inserting into the passed map. * * Example of use: * * C++ * * @dontinclude ExampleXdmfItemProperty.cpp * @skipline //#getProperties * @until //#getProperties * * Python * * @dontinclude XdmfExampleItemProperty.py * @skipline #//getProperties * @until #//getProperties * * @param collectedProperties A map to insert name / value pairs into. */ virtual void getProperties(std::map & collectedProperties) const = 0; protected: XdmfItemProperty(); static std::string ConvertToUpper(const std::string & converted); static const std::map UpperConversionMap; private: XdmfItemProperty(const XdmfItemProperty &); // Not implemented. void operator=(const XdmfItemProperty &); // Not implemented. }; #endif #endif /* XDMFITEMPROPERTY_HPP_ */ xdmf-3.0+git20160803/core/XdmfHDF5Controller.cpp0000640000175000017500000004010513003006557021077 0ustar alastairalastair/*****************************************************************************/ /* Xdmf */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfHDF5Controller.cpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #include #include #include #include #include "string.h" #include "XdmfArray.hpp" #include "XdmfArrayType.hpp" #include "XdmfError.hpp" #include "XdmfHDF5Controller.hpp" #include "XdmfSystemUtils.hpp" unsigned int XdmfHDF5Controller::mMaxOpenedFiles = 0; static std::map mOpenFiles; std::map XdmfHDF5Controller::mOpenFileUsage; shared_ptr XdmfHDF5Controller::New(const std::string & hdf5FilePath, const std::string & dataSetPath, const shared_ptr & type, const std::vector & start, const std::vector & stride, const std::vector & dimensions, const std::vector & dataspaceDimensions) { shared_ptr p(new XdmfHDF5Controller(hdf5FilePath, dataSetPath, type, start, stride, dimensions, dataspaceDimensions)); return p; } XdmfHDF5Controller::XdmfHDF5Controller(const std::string & hdf5FilePath, const std::string & dataSetPath, const shared_ptr & type, const std::vector & start, const std::vector & stride, const std::vector & dimensions, const std::vector & dataspaceDimensions) : XdmfHeavyDataController(hdf5FilePath, type, start, stride, dimensions, dataspaceDimensions), mDataSetPath(dataSetPath), mDataSetPrefix(""), mDataSetId(-1) { unsigned int i = 0; for (; i < mDataSetPath.size(); ++i) { if (mDataSetPath[(mDataSetPath.size() - 1) - i] != '0' && mDataSetPath[(mDataSetPath.size() - 1) - i] != '1' && mDataSetPath[(mDataSetPath.size() - 1) - i] != '2' && mDataSetPath[(mDataSetPath.size() - 1) - i] != '3' && mDataSetPath[(mDataSetPath.size() - 1) - i] != '4' && mDataSetPath[(mDataSetPath.size() - 1) - i] != '5' && mDataSetPath[(mDataSetPath.size() - 1) - i] != '6' && mDataSetPath[(mDataSetPath.size() - 1) - i] != '7' && mDataSetPath[(mDataSetPath.size() - 1) - i] != '8' && mDataSetPath[(mDataSetPath.size() - 1) - i] != '9') { break; } } unsigned int endOfPrefix = (mDataSetPath.size()) - i; mDataSetPrefix = mDataSetPath.substr(0, endOfPrefix); if (mDataSetPrefix.compare(mDataSetPath) != 0) { mDataSetId = atoi(mDataSetPath.substr(endOfPrefix).c_str()); } } XdmfHDF5Controller::XdmfHDF5Controller(const XdmfHDF5Controller& refController): XdmfHeavyDataController(refController), mDataSetPath(refController.getDataSetPath()), mDataSetPrefix(refController.mDataSetPrefix), mDataSetId(refController.mDataSetId) { } XdmfHDF5Controller::~XdmfHDF5Controller() { } void XdmfHDF5Controller::closeFiles() { for (std::map::iterator closeIter = mOpenFiles.begin(); closeIter != mOpenFiles.end(); ++closeIter) { H5Fclose(closeIter->second); } mOpenFiles.clear(); mOpenFileUsage.clear(); } std::string XdmfHDF5Controller::getDataSetPath() const { return mDataSetPath; } const std::string XdmfHDF5Controller::getDataSetPrefix() const { return mDataSetPrefix; } int XdmfHDF5Controller::getDataSetId() const { return mDataSetId; } std::string XdmfHDF5Controller::getDescriptor() const { return ":" + mDataSetPath; } std::string XdmfHDF5Controller::getName() const { return "HDF"; } unsigned int XdmfHDF5Controller::getMaxOpenedFiles() { return XdmfHDF5Controller::mMaxOpenedFiles; } void XdmfHDF5Controller::getProperties(std::map & collectedProperties) const { collectedProperties["Format"] = this->getName(); } void XdmfHDF5Controller::read(XdmfArray * const array) { this->read(array, H5P_DEFAULT); } void XdmfHDF5Controller::read(XdmfArray * const array, const int fapl) { herr_t status; hid_t hdf5Handle; if (XdmfHDF5Controller::mMaxOpenedFiles == 0) { hdf5Handle = H5Fopen(mFilePath.c_str(), H5F_ACC_RDONLY, fapl); } else { std::map::iterator checkOpen = mOpenFiles.find(mFilePath); if (checkOpen == mOpenFiles.end()) { // If the number of open files would become larger than allowed if (mOpenFiles.size() + 1 > mMaxOpenedFiles) { // Close least used one std::map::iterator walker = mOpenFileUsage.begin(); std::string oldestFile = walker->first; while (walker != mOpenFileUsage.end()) { // We want the file with the fewest accesses // If two are tied, we use the older one if (mOpenFileUsage[oldestFile] > walker->second) { oldestFile = walker->first; } ++walker; } status = H5Fclose(mOpenFiles[oldestFile]); mOpenFiles.erase(oldestFile); mOpenFileUsage.erase(oldestFile); } hdf5Handle = H5Fopen(mFilePath.c_str(), H5F_ACC_RDONLY, fapl); mOpenFiles[mFilePath] = hdf5Handle; mOpenFileUsage[mFilePath] = 1; } else { hdf5Handle = checkOpen->second; mOpenFileUsage[mFilePath]++; } } const hid_t dataset = H5Dopen(hdf5Handle, mDataSetPath.c_str(), H5P_DEFAULT); const hid_t dataspace = H5Dget_space(dataset); const unsigned int dataspaceDims = H5Sget_simple_extent_ndims(dataspace); const std::vector count(mDimensions.begin(), mDimensions.end()); if(dataspaceDims != mDimensions.size()) { // special case where the number of dimensions of the hdf5 dataset // does not equal the number of dimensions in the light data // description - in this case we cannot properly take a hyperslab // selection, so we assume we are reading the entire dataset and // check whether that is ok to do const int numberValuesHDF5 = H5Sget_select_npoints(dataspace); const int numberValuesXdmf = std::accumulate(mDimensions.begin(), mDimensions.end(), 1, std::multiplies()); if(numberValuesHDF5 != numberValuesXdmf) { XdmfError::message(XdmfError::FATAL, "Number of dimensions in light data description in " "Xdmf does not match number of dimensions in hdf5 " "file."); } } else { const std::vector start(mStart.begin(), mStart.end()); const std::vector stride(mStride.begin(), mStride.end()); status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, &start[0], &stride[0], &count[0], NULL); } const hssize_t numVals = H5Sget_select_npoints(dataspace); hid_t memspace = H5Screate_simple(mDimensions.size(), &count[0], NULL); /* status = H5Sselect_hyperslab(memspace, H5S_SELECT_SET, &memStart[0], &memStride[0], &memCount[0], NULL);*/ hid_t datatype = H5T_NO_CLASS; bool closeDatatype = false; if(mType == XdmfArrayType::Int8()) { datatype = H5T_NATIVE_CHAR; } else if(mType == XdmfArrayType::Int16()) { datatype = H5T_NATIVE_SHORT; } else if(mType == XdmfArrayType::Int32()) { datatype = H5T_NATIVE_INT; } else if(mType == XdmfArrayType::Int64()) { datatype = H5T_NATIVE_LONG; } else if(mType == XdmfArrayType::Float32()) { datatype = H5T_NATIVE_FLOAT; } else if(mType == XdmfArrayType::Float64()) { datatype = H5T_NATIVE_DOUBLE; } else if(mType == XdmfArrayType::UInt8()) { datatype = H5T_NATIVE_UCHAR; } else if(mType == XdmfArrayType::UInt16()) { datatype = H5T_NATIVE_USHORT; } else if(mType == XdmfArrayType::UInt32()) { datatype = H5T_NATIVE_UINT; } else if(mType == XdmfArrayType::String()) { datatype = H5Tcopy(H5T_C_S1); H5Tset_size(datatype, H5T_VARIABLE); closeDatatype = true; } else { XdmfError::message(XdmfError::FATAL, "Unknown XdmfArrayType encountered in hdf5 " "controller."); } array->initialize(mType, mDimensions); if(numVals != array->getSize()) { std::stringstream errOut; errOut << "Number of values in hdf5 dataset (" << numVals; errOut << ")\ndoes not match allocated size in XdmfArray (" << array->getSize() << ")."; XdmfError::message(XdmfError::FATAL, errOut.str()); } if(closeDatatype) { char ** data = new char*[numVals]; status = H5Dread(dataset, datatype, memspace, dataspace, H5P_DEFAULT, data); for(hssize_t i=0; iinsert(i, data[i]); } status = H5Dvlen_reclaim(datatype, dataspace, H5P_DEFAULT, data); delete [] data; } else { status = H5Dread(dataset, datatype, memspace, dataspace, H5P_DEFAULT, array->getValuesInternal()); } status = H5Sclose(dataspace); status = H5Sclose(memspace); status = H5Dclose(dataset); if(closeDatatype) { status = H5Tclose(datatype); } if (XdmfHDF5Controller::mMaxOpenedFiles == 0) { status = H5Fclose(hdf5Handle); } } void XdmfHDF5Controller::setMaxOpenedFiles(unsigned int newMax) { XdmfHDF5Controller::mMaxOpenedFiles = newMax; } // C Wrappers XDMFHDF5CONTROLLER * XdmfHDF5ControllerNew(char * hdf5FilePath, char * dataSetPath, int type, unsigned int * start, unsigned int * stride, unsigned int * dimensions, unsigned int * dataspaceDimensions, unsigned int numDims, int * status) { XDMF_ERROR_WRAP_START(status) try { std::vector startVector(start, start + numDims); std::vector strideVector(stride, stride + numDims); std::vector dimVector(dimensions, dimensions + numDims); std::vector dataspaceVector(dataspaceDimensions, dataspaceDimensions + numDims); shared_ptr buildType = shared_ptr(); switch (type) { case XDMF_ARRAY_TYPE_UINT8: buildType = XdmfArrayType::UInt8(); break; case XDMF_ARRAY_TYPE_UINT16: buildType = XdmfArrayType::UInt16(); break; case XDMF_ARRAY_TYPE_UINT32: buildType = XdmfArrayType::UInt32(); break; case XDMF_ARRAY_TYPE_INT8: buildType = XdmfArrayType::Int8(); break; case XDMF_ARRAY_TYPE_INT16: buildType = XdmfArrayType::Int16(); break; case XDMF_ARRAY_TYPE_INT32: buildType = XdmfArrayType::Int32(); break; case XDMF_ARRAY_TYPE_INT64: buildType = XdmfArrayType::Int64(); break; case XDMF_ARRAY_TYPE_FLOAT32: buildType = XdmfArrayType::Float32(); break; case XDMF_ARRAY_TYPE_FLOAT64: buildType = XdmfArrayType::Float64(); break; default: XdmfError::message(XdmfError::FATAL, "Error: Invalid ArrayType."); break; } shared_ptr generatedController = XdmfHDF5Controller::New(std::string(hdf5FilePath), std::string(dataSetPath), buildType, startVector, strideVector, dimVector, dataspaceVector); return (XDMFHDF5CONTROLLER *)((void *)(new XdmfHDF5Controller(*generatedController.get()))); } catch (...) { std::vector startVector(start, start + numDims); std::vector strideVector(stride, stride + numDims); std::vector dimVector(dimensions, dimensions + numDims); std::vector dataspaceVector(dataspaceDimensions, dataspaceDimensions + numDims); shared_ptr buildType = shared_ptr(); switch (type) { case XDMF_ARRAY_TYPE_UINT8: buildType = XdmfArrayType::UInt8(); break; case XDMF_ARRAY_TYPE_UINT16: buildType = XdmfArrayType::UInt16(); break; case XDMF_ARRAY_TYPE_UINT32: buildType = XdmfArrayType::UInt32(); break; case XDMF_ARRAY_TYPE_INT8: buildType = XdmfArrayType::Int8(); break; case XDMF_ARRAY_TYPE_INT16: buildType = XdmfArrayType::Int16(); break; case XDMF_ARRAY_TYPE_INT32: buildType = XdmfArrayType::Int32(); break; case XDMF_ARRAY_TYPE_INT64: buildType = XdmfArrayType::Int64(); break; case XDMF_ARRAY_TYPE_FLOAT32: buildType = XdmfArrayType::Float32(); break; case XDMF_ARRAY_TYPE_FLOAT64: buildType = XdmfArrayType::Float64(); break; default: XdmfError::message(XdmfError::FATAL, "Error: Invalid ArrayType."); break; } shared_ptr generatedController = XdmfHDF5Controller::New(std::string(hdf5FilePath), std::string(dataSetPath), buildType, startVector, strideVector, dimVector, dataspaceVector); return (XDMFHDF5CONTROLLER *)((void *)(new XdmfHDF5Controller(*generatedController.get()))); } XDMF_ERROR_WRAP_END(status) return NULL; } char * XdmfHDF5ControllerGetDataSetPath(XDMFHDF5CONTROLLER * controller) { char * returnPointer = strdup(((XdmfHDF5Controller *)(controller))->getDataSetPath().c_str()); return returnPointer; } // C Wrappers for parent classes are generated by macros XDMF_HEAVYCONTROLLER_C_CHILD_WRAPPER(XdmfHDF5Controller, XDMFHDF5CONTROLLER) xdmf-3.0+git20160803/core/XdmfPlaceholder.hpp0000640000175000017500000001414013003006557020574 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfPlaceholder.hpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #ifndef XDMFPLACEHOLDER_HPP_ #define XDMFPLACEHOLDER_HPP_ // C Compatible Includes #include "XdmfCore.hpp" #include "XdmfHeavyDataController.hpp" #ifdef __cplusplus #include /** * @brief Couples an XdmfArray with an array structure. * * Takes the place of a heavy data set. Allows an array to define * its structure without having to have an associated dataset. */ class XDMFCORE_EXPORT XdmfPlaceholder : public XdmfHeavyDataController { public: virtual ~XdmfPlaceholder(); /** * Create a new placeholder to define array structure. * * Example of use: * * C++ * * @dontinclude ExampleXdmfPlaceholder.cpp * @skipline //#initialization * @until //#initialization * * Python * * @dontinclude XdmfExamplePlaceholder.py * @skipline #//initialization * @until #//initialization * * @param filePath The location of the file the data set resides in. * @param type The data type of the dataset to read. * @param start The offset of the starting element in each * dimension in the data set. * @param stride The number of elements to move in each * dimension from the data set. * @param dimensions The number of elements to select in each * dimension from the data set. * (size in each dimension) * @param dataspaceDimensions The number of elements in the entire * data set (may be larger than * dimensions if using hyperslabs). * * @return New Placeholder. */ static shared_ptr New(const std::string & FilePath, const shared_ptr type, const std::vector & start, const std::vector & stride, const std::vector & dimensions, const std::vector & dataspaceDimensions); virtual std::string getDescriptor() const; virtual std::string getName() const; virtual void getProperties(std::map & collectedProperties) const; virtual void read(XdmfArray * const array); XdmfPlaceholder(const XdmfPlaceholder &); protected: XdmfPlaceholder(const std::string & filePath, const shared_ptr type, const std::vector & start, const std::vector & stride, const std::vector & dimensions, const std::vector & dataspaceDimensions); shared_ptr createSubController(const std::vector & starts, const std::vector & strides, const std::vector & dimensions); virtual shared_ptr getHeavyDataDescription(); void read(XdmfArray * const array, const int fapl); private: void operator=(const XdmfPlaceholder &); // Not implemented. }; #endif #ifdef __cplusplus extern "C" { #endif struct XDMFPLACEHOLDER; // Simply as a typedef to ensure correct typing typedef struct XDMFPLACEHOLDER XDMFPLACEHOLDER; XDMFCORE_EXPORT XDMFPLACEHOLDER * XdmfPlaceholderNew(char * hdf5FilePath, int type, unsigned int * start, unsigned int * stride, unsigned int * dimensions, unsigned int * dataspaceDimensions, unsigned int numDims, int * status); // C Wrappers for parent classes are generated by macros /* XDMFCORE_EXPORT unsigned int * XdmfPlaceholderGetDataspaceDimensions(XDMFPLACEHOLDER * controller); XDMFCORE_EXPORT unsigned int * XdmfPlaceholderGetStart(XDMFPLACEHOLDER * controller); XDMFCORE_EXPORT unsigned int * XdmfPlaceholderGetStride(XDMFPLACEHOLDER * controller); */ XDMF_HEAVYCONTROLLER_C_CHILD_DECLARE(XdmfPlaceholder, XDMFPLACEHOLDER, XDMFCORE) #ifdef __cplusplus } #endif #endif /* XDMFPLACEHOLDER_HPP_ */ xdmf-3.0+git20160803/core/XdmfSubset.cpp0000640000175000017500000003654613003006557017630 0ustar alastairalastair/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfSubset.cpp */ /* */ /* Author: */ /* Andrew Burns */ /* andrew.j.burns2@us.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2013 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* This software is distributed WITHOUT ANY WARRANTY; without */ /* even the implied warranty of MERCHANTABILITY or FITNESS */ /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ /* for more information. */ /* */ /*****************************************************************************/ #include #include #include #include "string.h" #include "XdmfArray.hpp" #include "XdmfError.hpp" #include "XdmfSubset.hpp" #include "XdmfWriter.hpp" XdmfSubset::XdmfSubset(shared_ptr referenceArray, std::vector & start, std::vector & stride, std::vector & dimensions) : mParent(referenceArray), mDimensions(dimensions), mStart(start), mStride(stride) { if(!(mStart.size() == mStride.size() && mStride.size() == mDimensions.size())) { XdmfError::message(XdmfError::FATAL, "mStart, mStride, mDimensions must all be of equal " "length in XdmfSubset constructor"); } } XdmfSubset::XdmfSubset(XdmfSubset & refSubset) : XdmfArrayReference(refSubset), mParent(refSubset.getReferenceArray()), mDimensions(refSubset.getDimensions()), mStart(refSubset.getStart()), mStride(refSubset.getStride()) { } XdmfSubset::~XdmfSubset() { } const std::string XdmfSubset::ItemTag = "Subset"; shared_ptr XdmfSubset::New(shared_ptr referenceArray, std::vector & start, std::vector & stride, std::vector & dimensions) { shared_ptr p(new XdmfSubset(referenceArray, start, stride, dimensions)); return p; } std::vector XdmfSubset::getDimensions() const { return mDimensions; } std::map XdmfSubset::getItemProperties() const { // Check to make sure the subset is valid // before generating the properties. if(!(mStart.size() == mStride.size() && mStride.size() == mDimensions.size())) { XdmfError::message(XdmfError::FATAL, "mStart, mStride, mDimensions must all be of equal " "length in XdmfSubset getItemProperties"); } if (mStart.size() < 1 || mStride.size() < 1 || mDimensions.size() < 1) { XdmfError::message(XdmfError::WARNING, "mStart, mStride, mDimensions must have at least " "one value contained within"); } std::map subsetMap = XdmfArrayReference::getItemProperties(); std::stringstream vectorStream; vectorStream << mStart[0]; for (unsigned int i = 1; i < mStart.size(); ++i) { vectorStream << " " << mStart[i]; } subsetMap["SubsetStarts"] = vectorStream.str(); vectorStream.str(std::string()); vectorStream << mStride[0]; for (unsigned int i = 1; i < mStride.size(); ++i) { vectorStream << " " << mStride[i]; } subsetMap["SubsetStrides"] = vectorStream.str(); vectorStream.str(std::string()); vectorStream << mDimensions[0]; for (unsigned int i = 1; i < mDimensions.size(); ++i) { vectorStream << " " << mDimensions[i]; } subsetMap["SubsetDimensions"] = vectorStream.str(); return subsetMap; } std::string XdmfSubset::getItemTag() const { return ItemTag; } shared_ptr XdmfSubset::getReferenceArray() { if (mParent) { return mParent; } else { return shared_ptr(); } } unsigned int XdmfSubset::getSize() const { return std::accumulate(mDimensions.begin(), mDimensions.end(), 1, std::multiplies()); } std::vector XdmfSubset::getStart() const { return mStart; } std::vector XdmfSubset::getStride() const { return mStride; } void XdmfSubset::populateItem(const std::map & itemProperties, const std::vector > & childItems, const XdmfCoreReader * const reader) { std::map::const_iterator starts = itemProperties.find("SubsetStarts"); boost::tokenizer<> tokens(starts->second); for(boost::tokenizer<>::const_iterator iter = tokens.begin(); iter != tokens.end(); ++iter) { mStart.push_back(atoi((*iter).c_str())); } std::map::const_iterator strides = itemProperties.find("SubsetStrides"); boost::tokenizer<> stridetokens(strides->second); for(boost::tokenizer<>::const_iterator iter = stridetokens.begin(); iter != stridetokens.end(); ++iter) { mStride.push_back(atoi((*iter).c_str())); } std::map::const_iterator dimensions = itemProperties.find("SubsetDimensions"); boost::tokenizer<> dimtokens(dimensions->second); for(boost::tokenizer<>::const_iterator iter = dimtokens.begin(); iter != dimtokens.end(); ++iter) { mDimensions.push_back(atoi((*iter).c_str())); } mParent = shared_dynamic_cast(childItems[0]); } shared_ptr XdmfSubset::read() const { if (mStart.size() < 1 || mStride.size() < 1 || mDimensions.size() < 1) { XdmfError::message(XdmfError::WARNING, "mStart, mStride, mDimensions must have at least " "one value contained within"); } if (!mParent->isInitialized()) { mParent->read(); } shared_ptr tempArray = XdmfArray::New(); tempArray->initialize(mParent->getArrayType()); tempArray->resize(this->getSize(), 0); std::vector writeStarts; writeStarts.push_back(0); std::vector writeStrides; writeStrides.push_back(1); std::vector writeDimensions; writeDimensions.push_back(this->getSize()); tempArray->insert(writeStarts, mParent, mStart, mDimensions, writeDimensions, writeStrides, mStride); return tempArray; } void XdmfSubset::setDimensions(std::vector newDimensions) { mDimensions = newDimensions; // Give the user a warning so they know they might have messed something up. // If they don't want the warning they can suppress it. if(!(mStart.size() == mStride.size() && mStride.size() == mDimensions.size())) { XdmfError::message(XdmfError::WARNING, "mStart, mStride, mDimensions now have different sizes." "The sizes should be equal before use."); } this->setIsChanged(true); } void XdmfSubset::setReferenceArray(shared_ptr newReference) { mParent = newReference; this->setIsChanged(true); } void XdmfSubset::setStart(std::vector newStarts) { mStart = newStarts; // Give the user a warning so they know they might have messed something up. // If they don't want the warning they can suppress it. if(!(mStart.size() == mStride.size() && mStride.size() == mDimensions.size())) { XdmfError::message(XdmfError::WARNING, "mStart, mStride, mDimensions now have different sizes." "The sizes should be equal before use."); } this->setIsChanged(true); } void XdmfSubset::setStride(std::vector newStrides) { mStride = newStrides; // Give the user a warning so they know they might have messed something up. // If they don't want the warning they can suppress it. if(!(mStart.size() == mStride.size() && mStride.size() == mDimensions.size())) { XdmfError::message(XdmfError::WARNING, "mStart, mStride, mDimensions now have different sizes." "The sizes should be equal before use."); } this->setIsChanged(true); } void XdmfSubset::traverse(const shared_ptr visitor) { XdmfItem::traverse(visitor); bool originalXPath; if (shared_ptr writer = shared_dynamic_cast(visitor)) { originalXPath = writer->getWriteXPaths(); writer->setWriteXPaths(false); } shared_ptr spacerarray = XdmfArray::New(); spacerarray->pushBack((int)0); spacerarray->accept(visitor); if (shared_ptr writer = shared_dynamic_cast(visitor)) { writer->setWriteXPaths(originalXPath); } mParent->accept(visitor); } // C Wrappers XDMFSUBSET * XdmfSubsetNew(void * referenceArray, unsigned int * start, unsigned int * stride, unsigned int * dimensions, unsigned int numDims, int passControl, int * status) { XDMF_ERROR_WRAP_START(status) try { std::vector startVector(start, start + numDims); std::vector strideVector(stride, stride + numDims); std::vector dimVector(dimensions, dimensions + numDims); shared_ptr referencePointer; if (passControl) { referencePointer = shared_ptr((XdmfArray *)referenceArray); } else { referencePointer = shared_ptr((XdmfArray *)referenceArray, XdmfNullDeleter()); } shared_ptr generatedSubset = XdmfSubset::New(referencePointer, startVector, strideVector, dimVector); return (XDMFSUBSET *)((void *)(new XdmfSubset(*generatedSubset.get()))); } catch (...) { std::vector startVector(start, start + numDims); std::vector strideVector(stride, stride + numDims); std::vector dimVector(dimensions, dimensions + numDims); shared_ptr referencePointer; if (passControl) { referencePointer = shared_ptr((XdmfArray *)referenceArray); } else { referencePointer = shared_ptr((XdmfArray *)referenceArray, XdmfNullDeleter()); } shared_ptr generatedSubset = XdmfSubset::New(referencePointer, startVector, strideVector, dimVector); return (XDMFSUBSET *)((void *)(new XdmfSubset(*generatedSubset.get()))); } XDMF_ERROR_WRAP_END(status) return NULL; } unsigned int * XdmfSubsetGetDimensions(XDMFSUBSET * subset) { try { std::vector tempVector = ((XdmfSubset *)(subset))->getDimensions(); unsigned int returnSize = tempVector.size(); unsigned int * returnArray = new unsigned int[returnSize](); for (unsigned int i = 0; i < returnSize; ++i) { returnArray[i] = tempVector[i]; } return returnArray; } catch (...) { std::vector tempVector = ((XdmfSubset *)(subset))->getDimensions(); unsigned int returnSize = tempVector.size(); unsigned int * returnArray = new unsigned int[returnSize](); for (unsigned int i = 0; i < returnSize; ++i) { returnArray[i] = tempVector[i]; } return returnArray; } } unsigned int XdmfSubsetGetNumberDimensions(XDMFSUBSET * subset) { return ((XdmfSubset *)(subset))->getDimensions().size(); } void * XdmfSubsetGetReferenceArray(XDMFSUBSET * subset) { shared_ptr returnItem = ((XdmfSubset *)subset)->getReferenceArray(); return returnItem.get(); } unsigned int XdmfSubsetGetSize(XDMFSUBSET * subset) { return ((XdmfSubset *)(subset))->getSize(); } unsigned int * XdmfSubsetGetStart(XDMFSUBSET * subset) { try { std::vector tempVector = ((XdmfSubset *)(subset))->getStart(); unsigned int returnSize = tempVector.size(); unsigned int * returnArray = new unsigned int[returnSize](); for (unsigned int i = 0; i < returnSize; ++i) { returnArray[i] = tempVector[i]; } return returnArray; } catch (...) { std::vector tempVector = ((XdmfSubset *)(subset))->getStart(); unsigned int returnSize = tempVector.size(); unsigned int * returnArray = new unsigned int[returnSize](); for (unsigned int i = 0; i < returnSize; ++i) { returnArray[i] = tempVector[i]; } return returnArray; } } unsigned int * XdmfSubsetGetStride(XDMFSUBSET * subset) { try { std::vector tempVector = ((XdmfSubset *)(subset))->getStride(); unsigned int returnSize = tempVector.size(); unsigned int * returnArray = new unsigned int[returnSize](); for (unsigned int i = 0; i < returnSize; ++i) { returnArray[i] = tempVector[i]; } return returnArray; } catch (...) { std::vector tempVector = ((XdmfSubset *)(subset))->getStride(); unsigned int returnSize = tempVector.size(); unsigned int * returnArray = new unsigned int[returnSize](); for (unsigned int i = 0; i < returnSize; ++i) { returnArray[i] = tempVector[i]; } return returnArray; } } void XdmfSubsetSetDimensions(XDMFSUBSET * subset, unsigned int * newDimensions, unsigned int numDims, int * status) { XDMF_ERROR_WRAP_START(status) std::vector dimVector(newDimensions, newDimensions + numDims); ((XdmfSubset *)(subset))->setDimensions(dimVector); XDMF_ERROR_WRAP_END(status) } void XdmfSubsetSetReferenceArray(XDMFSUBSET * subset, XDMFARRAY * referenceArray, int passControl) { shared_ptr referencePointer; if (passControl) { referencePointer = shared_ptr((XdmfArray *)referenceArray); } else { referencePointer = shared_ptr((XdmfArray *)referenceArray, XdmfNullDeleter()); } ((XdmfSubset *)subset)->setReferenceArray(referencePointer); } void XdmfSubsetSetStart(XDMFSUBSET * subset, unsigned int * newStarts, unsigned int numDims, int * status) { XDMF_ERROR_WRAP_START(status) std::vector startVector(newStarts, newStarts + numDims); ((XdmfSubset *)(subset))->setStart(startVector); XDMF_ERROR_WRAP_END(status) } void XdmfSubsetSetStride(XDMFSUBSET * subset, unsigned int * newStrides, unsigned int numDims, int * status) { XDMF_ERROR_WRAP_START(status) std::vector strideVector(newStrides, newStrides + numDims); ((XdmfSubset *)(subset))->setStride(strideVector); XDMF_ERROR_WRAP_END(status) } // C Wrappers for parent classes are generated by macros XDMF_ITEM_C_CHILD_WRAPPER(XdmfSubset, XDMFSUBSET) XDMF_ARRAYREFERENCE_C_CHILD_WRAPPER(XdmfSubset, XDMFSUBSET) xdmf-3.0+git20160803/core/loki/0000740000175000017500000000000013003006557015756 5ustar alastairalastairxdmf-3.0+git20160803/core/loki/NullType.h0000640000175000017500000000254113003006557017707 0ustar alastairalastair//////////////////////////////////////////////////////////////////////////////// // The Loki Library // Copyright (c) 2001 by Andrei Alexandrescu // This code accompanies the book: // Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design // Patterns Applied". Copyright (c) 2001. Addison-Wesley. // Permission to use, copy, modify, distribute and sell this software for any // purpose is hereby granted without fee, provided that the above copyright // notice appear in all copies and that both that copyright notice and this // permission notice appear in supporting documentation. // The author or Addison-Wesley Longman make no representations about the // suitability of this software for any purpose. It is provided "as is" // without express or implied warranty. //////////////////////////////////////////////////////////////////////////////// #ifndef LOKI_NULLTYPE_INC_ #define LOKI_NULLTYPE_INC_ // $Id: NullType.h 751 2006-10-17 19:50:37Z syntheticpp $ namespace Loki { //////////////////////////////////////////////////////////////////////////////// // class NullType // Used as a placeholder for "no type here" // Useful as an end marker in typelists //////////////////////////////////////////////////////////////////////////////// class NullType {}; } // namespace Loki #endif // end file guardian xdmf-3.0+git20160803/core/loki/HierarchyGenerators.h0000640000175000017500000002354113003006557022106 0ustar alastairalastair//////////////////////////////////////////////////////////////////////////////// // The Loki Library // Copyright (c) 2001 by Andrei Alexandrescu // This code accompanies the book: // Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design // Patterns Applied". Copyright (c) 2001. Addison-Wesley. // Permission to use, copy, modify, distribute and sell this software for any // purpose is hereby granted without fee, provided that the above copyright // notice appear in all copies and that both that copyright notice and this // permission notice appear in supporting documentation. // The author or Addison-Wesley Longman make no representations about the // suitability of this software for any purpose. It is provided "as is" // without express or implied warranty. //////////////////////////////////////////////////////////////////////////////// #ifndef LOKI_HIERARCHYGENERATORS_INC_ #define LOKI_HIERARCHYGENERATORS_INC_ // $Id: HierarchyGenerators.h 751 2006-10-17 19:50:37Z syntheticpp $ #include "Typelist.h" #include "TypeTraits.h" #include "EmptyType.h" namespace Loki { #if defined(_MSC_VER) && _MSC_VER >= 1300 #pragma warning( push ) // 'class1' : base-class 'class2' is already a base-class of 'class3' #pragma warning( disable : 4584 ) #endif // _MSC_VER //////////////////////////////////////////////////////////////////////////////// // class template GenScatterHierarchy // Generates a scattered hierarchy starting from a typelist and a template // Invocation (TList is a typelist, Unit is a template of one arg): // GenScatterHierarchy // The generated class inherits all classes generated by instantiating the // template 'Unit' with the types contained in TList //////////////////////////////////////////////////////////////////////////////// namespace Private { // The following type helps to overcome subtle flaw in the original // implementation of GenScatterHierarchy. // The flaw is revealed when the input type list of GenScatterHierarchy // contains more then one element of the same type (e.g. LOKI_TYPELIST_2(int, int)). // In this case GenScatterHierarchy will contain multiple bases of the same // type and some of them will not be reachable (per 10.3). // For example before the fix the first element of Tuple // is not reachable in any way! template struct ScatterHierarchyTag; } template class Unit> class GenScatterHierarchy; template class Unit> class GenScatterHierarchy, Unit> : public GenScatterHierarchy, Unit> , public GenScatterHierarchy { public: typedef Typelist TList; // Insure that LeftBase is unique and therefore reachable typedef GenScatterHierarchy, Unit> LeftBase; typedef GenScatterHierarchy RightBase; template struct Rebind { typedef Unit Result; }; }; // In the middle *unique* class that resolve possible ambiguity template class Unit> class GenScatterHierarchy, Unit> : public GenScatterHierarchy { }; template class Unit> class GenScatterHierarchy : public Unit { typedef Unit LeftBase; template struct Rebind { typedef Unit Result; }; }; template